{
    "version": "1.0.0",
    "layout_name": "plugin_settings",
    "permissions": [
        "core.plugins.update"
    ],
    "extends": "_admin_base",
    "meta": {
        "title": "$t:sirsoft-verification_kginicis.settings.title",
        "description": "$t:sirsoft-verification_kginicis.settings.description"
    },
    "data_sources": [
        {
            "id": "settings",
            "label_key": "$t:sirsoft-verification_kginicis.editor.data_source.settings",
            "type": "api",
            "endpoint": "/api/admin/plugins/{{route.identifier}}/settings",
            "method": "GET",
            "auto_fetch": true,
            "auth_required": true,
            "initLocal": "form",
            "refetchOnMount": true
        }
    ],
    "slots": {
        "content": [
            {
                "id": "plugin_settings_content",
                "type": "basic",
                "name": "Div",
                "dataKey": "form",
                "trackChanges": true,
                "props": {
                    "className": "admin-page-content-responsive"
                },
                "children": [
                    {
                        "id": "page_header",
                        "type": "composite",
                        "name": "PageHeader",
                        "props": {
                            "title": "$t:sirsoft-verification_kginicis.settings.title",
                            "description": "$t:sirsoft-verification_kginicis.settings.description",
                            "backPath": "/admin/plugins",
                            "backLabel": "$t:admin.plugins.back_to_list"
                        }
                    },
                    {
                        "id": "info_panel",
                        "type": "basic",
                        "name": "Div",
                        "props": {
                            "className": "alert-info"
                        },
                        "children": [
                            {
                                "type": "basic",
                                "name": "Div",
                                "props": { "className": "flex gap-3" },
                                "children": [
                                    {
                                        "type": "basic",
                                        "name": "Icon",
                                        "props": {
                                            "name": "circle-info",
                                            "className": "text-xl text-blue-600 dark:text-blue-400 flex-shrink-0 mt-0.5"
                                        }
                                    },
                                    {
                                        "type": "basic",
                                        "name": "Div",
                                        "props": { "className": "space-y-1 text-info-soft" },
                                        "children": [
                                            { "type": "basic", "name": "P", "text": "$t:sirsoft-verification_kginicis.settings.info.activation" },
                                            { "type": "basic", "name": "P", "text": "$t:sirsoft-verification_kginicis.settings.info.logs" }
                                        ]
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "validation_error",
                        "type": "basic",
                        "name": "Div",
                        "if": "{{_local.errors}}",
                        "props": {
                            "className": "mt-6 alert-danger"
                        },
                        "children": [
                            {
                                "type": "basic",
                                "name": "Div",
                                "props": { "className": "flex gap-3" },
                                "children": [
                                    {
                                        "type": "basic",
                                        "name": "Icon",
                                        "props": {
                                            "name": "triangle-exclamation",
                                            "className": "text-xl text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"
                                        }
                                    },
                                    {
                                        "type": "basic",
                                        "name": "Div",
                                        "children": [
                                            {
                                                "type": "basic",
                                                "name": "H3",
                                                "props": { "className": "text-error-soft" },
                                                "text": "$t:admin.plugins.settings.validation_error"
                                            },
                                            {
                                                "type": "basic",
                                                "name": "Ul",
                                                "if": "{{typeof _local.errors === 'object' && Object.keys(_local.errors).length > 0}}",
                                                "props": { "className": "mt-2 list-disc list-inside space-y-1" },
                                                "iteration": {
                                                    "source": "Object.entries(_local.errors ?? {}).flatMap(([field, messages]) => Array.isArray(messages) ? messages : [messages])",
                                                    "item_var": "message"
                                                },
                                                "children": [
                                                    {
                                                        "type": "basic",
                                                        "name": "Li",
                                                        "props": { "className": "text-error-soft" },
                                                        "text": "{{message}}"
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "test_mode_card",
                        "type": "basic",
                        "name": "Div",
                        "props": {
                            "className": "mt-6 bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700"
                        },
                        "children": [
                            {
                                "type": "basic",
                                "name": "Div",
                                "props": { "className": "p-6" },
                                "children": [
                                    {
                                        "type": "basic",
                                        "name": "Div",
                                        "props": { "className": "flex-between" },
                                        "children": [
                                            {
                                                "type": "basic",
                                                "name": "Div",
                                                "children": [
                                                    {
                                                        "type": "basic",
                                                        "name": "Label",
                                                        "props": { "className": "form-label" },
                                                        "text": "$t:sirsoft-verification_kginicis.settings.test_mode"
                                                    },
                                                    {
                                                        "type": "basic",
                                                        "name": "P",
                                                        "props": { "className": "form-hint" },
                                                        "text": "$t:sirsoft-verification_kginicis.settings.test_mode_hint"
                                                    }
                                                ]
                                            },
                                            {
                                                "type": "composite",
                                                "name": "Toggle",
                                                "props": {
                                                    "name": "is_test_mode"
                                                }
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "live_mode_warning",
                        "type": "basic",
                        "name": "Div",
                        "if": "{{_local.form && !_local.form.is_test_mode}}",
                        "props": {
                            "className": "mt-6 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-700 rounded-lg p-4"
                        },
                        "children": [
                            {
                                "type": "basic",
                                "name": "Div",
                                "props": { "className": "flex gap-3" },
                                "children": [
                                    {
                                        "type": "basic",
                                        "name": "Icon",
                                        "props": {
                                            "name": "triangle-exclamation",
                                            "className": "text-xl text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5"
                                        }
                                    },
                                    {
                                        "type": "basic",
                                        "name": "Div",
                                        "children": [
                                            {
                                                "type": "basic",
                                                "name": "H3",
                                                "props": { "className": "text-sm font-semibold text-warning-soft" },
                                                "text": "$t:sirsoft-verification_kginicis.settings.live_mode_warning_title"
                                            },
                                            {
                                                "type": "basic",
                                                "name": "P",
                                                "props": { "className": "mt-1 text-warning-soft" },
                                                "text": "$t:sirsoft-verification_kginicis.settings.live_mode_warning_body"
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "live_keys_section",
                        "type": "basic",
                        "name": "Div",
                        "props": {
                            "className": "mt-6 bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700"
                        },
                        "children": [
                            {
                                "type": "basic",
                                "name": "Div",
                                "props": { "className": "panel-header-row" },
                                "children": [
                                    {
                                        "type": "basic",
                                        "name": "H3",
                                        "props": { "className": "text-error-strong" },
                                        "text": "$t:sirsoft-verification_kginicis.settings.section_live_keys"
                                    }
                                ]
                            },
                            {
                                "type": "basic",
                                "name": "Div",
                                "props": { "className": "p-6 space-y-6" },
                                "children": [
                                    {
                                        "id": "field_live_mid",
                                        "type": "basic",
                                        "name": "Div",
                                        "props": { "className": "section-heading-md" },
                                        "children": [
                                            {
                                                "type": "basic",
                                                "name": "Div",
                                                "props": { "className": "lg:col-span-1" },
                                                "children": [
                                                    {
                                                        "type": "basic",
                                                        "name": "Label",
                                                        "props": { "className": "form-label" },
                                                        "text": "$t:sirsoft-verification_kginicis.settings.live_mid"
                                                    },
                                                    {
                                                        "type": "basic",
                                                        "name": "P",
                                                        "props": { "className": "form-hint" },
                                                        "text": "$t:sirsoft-verification_kginicis.settings.live_mid_hint"
                                                    }
                                                ]
                                            },
                                            {
                                                "type": "basic",
                                                "name": "Div",
                                                "props": { "className": "lg:col-span-2" },
                                                "children": [
                                                    {
                                                        "type": "basic",
                                                        "name": "Div",
                                                        "props": {
                                                            "className": "{{_local.errors?.live_mid ? 'flex rounded-lg border border-red-500 dark:border-red-500 overflow-hidden' : 'flex rounded-lg border border-gray-300 dark:border-gray-600 overflow-hidden focus-within:ring-2 focus-within:ring-blue-500 dark:focus-within:ring-blue-400 focus-within:border-transparent'}}"
                                                        },
                                                        "children": [
                                                            {
                                                                "type": "basic",
                                                                "name": "Span",
                                                                "props": {
                                                                    "className": "inline-flex items-center px-3 bg-gray-100 dark:bg-gray-600 border-r border-gray-300 dark:border-gray-600 text-body font-mono font-bold select-none"
                                                                },
                                                                "text": "SRB"
                                                            },
                                                            {
                                                                "type": "basic",
                                                                "name": "Input",
                                                                "props": {
                                                                    "type": "text",
                                                                    "name": "live_mid",
                                                                    "autoComplete": "one-time-code",
                                                                    "placeholder": "1234567",
                                                                    "className": "flex-1 font-mono outline-none border-0"
                                                                }
                                                            }
                                                        ]
                                                    },
                                                    {
                                                        "id": "field_live_mid_error",
                                                        "type": "basic",
                                                        "name": "P",
                                                        "if": "{{_local.errors?.live_mid}}",
                                                        "props": { "className": "mt-1 text-sm text-red-600 dark:text-red-400" },
                                                        "text": "{{_local.errors?.live_mid?.[0] ?? ''}}"
                                                    }
                                                ]
                                            }
                                        ]
                                    },
                                    {
                                        "id": "field_live_api_key",
                                        "type": "basic",
                                        "name": "Div",
                                        "props": { "className": "section-heading-md" },
                                        "children": [
                                            {
                                                "type": "basic",
                                                "name": "Div",
                                                "props": { "className": "lg:col-span-1" },
                                                "children": [
                                                    {
                                                        "type": "basic",
                                                        "name": "Label",
                                                        "props": { "className": "form-label" },
                                                        "text": "$t:sirsoft-verification_kginicis.settings.live_api_key"
                                                    }
                                                ]
                                            },
                                            {
                                                "type": "basic",
                                                "name": "Div",
                                                "props": { "className": "lg:col-span-2" },
                                                "children": [
                                                    {
                                                        "type": "basic",
                                                        "name": "Input",
                                                        "props": {
                                                            "type": "password",
                                                            "name": "live_api_key",
                                                            "autoComplete": "new-password",
                                                            "placeholder": "••••••••••••••••",
                                                            "className": "{{_local.errors?.live_api_key ? 'dark:focus:ring-red-400 font-mono border border-red-500 dark:border-red-500 focus:ring-red-500' : 'dark:focus:ring-blue-400 focus:border-transparent font-mono'}}"
                                                        }
                                                    },
                                                    {
                                                        "id": "field_live_api_key_error",
                                                        "type": "basic",
                                                        "name": "P",
                                                        "if": "{{_local.errors?.live_api_key}}",
                                                        "props": { "className": "mt-1 text-sm text-red-600 dark:text-red-400" },
                                                        "text": "{{_local.errors?.live_api_key?.[0] ?? ''}}"
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "duplicate_section",
                        "type": "basic",
                        "name": "Div",
                        "props": {
                            "className": "mt-6 bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700"
                        },
                        "children": [
                            {
                                "id": "section_duplicate_header",
                                "type": "basic",
                                "name": "Div",
                                "props": { "className": "panel-header-row" },
                                "children": [
                                    {
                                        "type": "basic",
                                        "name": "H3",
                                        "props": { "className": "text-error-strong" },
                                        "text": "$t:sirsoft-verification_kginicis.settings.section.duplicate_field"
                                    }
                                ]
                            },
                            {
                                "id": "section_duplicate_body",
                                "type": "basic",
                                "name": "Div",
                                "props": { "className": "p-6 space-y-6" },
                                "children": [
                                    {
                                        "type": "basic",
                                        "name": "Div",
                                        "props": { "className": "grid grid-cols-1 lg:grid-cols-12 gap-4 items-start" },
                                        "children": [
                                            {
                                                "type": "basic",
                                                "name": "Div",
                                                "props": { "className": "lg:col-span-8" },
                                                "children": [
                                                    {
                                                        "type": "basic",
                                                        "name": "Label",
                                                        "props": { "className": "form-label" },
                                                        "text": "$t:sirsoft-verification_kginicis.settings.fields.duplicate_field.label"
                                                    },
                                                    {
                                                        "type": "basic",
                                                        "name": "P",
                                                        "props": { "className": "form-hint" },
                                                        "text": "$t:sirsoft-verification_kginicis.settings.duplicate_field.hint"
                                                    }
                                                ]
                                            },
                                            {
                                                "type": "basic",
                                                "name": "Div",
                                                "props": { "className": "lg:col-span-4 space-y-3" },
                                                "children": [
                                                    {
                                                        "type": "basic",
                                                        "name": "Div",
                                                        "props": { "className": "flex-center justify-end gap-6" },
                                                        "children": [
                                                            {
                                                                "type": "basic",
                                                                "name": "Label",
                                                                "props": { "className": "inline-clickable text-body" },
                                                                "actions": [
                                                                    {
                                                                        "type": "click",
                                                                        "handler": "setState",
                                                                        "params": {
                                                                            "target": "local",
                                                                            "form": {
                                                                                "duplicate_field": "di"
                                                                            },
                                                                            "hasChanges": true
                                                                        }
                                                                    }
                                                                ],
                                                                "children": [
                                                                    {
                                                                        "type": "basic",
                                                                        "name": "Input",
                                                                        "props": {
                                                                            "type": "radio",
                                                                            "name": "duplicate_field",
                                                                            "value": "di",
                                                                            "checked": "{{(_local.form?.duplicate_field ?? 'di') === 'di'}}",
                                                                            "className": "radio pointer-events-none"
                                                                        }
                                                                    },
                                                                    { "type": "basic", "name": "Span", "text": "$t:sirsoft-verification_kginicis.settings.duplicate_field.di" }
                                                                ]
                                                            },
                                                            {
                                                                "type": "basic",
                                                                "name": "Label",
                                                                "props": { "className": "inline-clickable text-body" },
                                                                "actions": [
                                                                    {
                                                                        "type": "click",
                                                                        "handler": "setState",
                                                                        "params": {
                                                                            "target": "local",
                                                                            "form": {
                                                                                "duplicate_field": "ci"
                                                                            },
                                                                            "hasChanges": true
                                                                        }
                                                                    }
                                                                ],
                                                                "children": [
                                                                    {
                                                                        "type": "basic",
                                                                        "name": "Input",
                                                                        "props": {
                                                                            "type": "radio",
                                                                            "name": "duplicate_field",
                                                                            "value": "ci",
                                                                            "checked": "{{_local.form?.duplicate_field === 'ci'}}",
                                                                            "className": "radio pointer-events-none"
                                                                        }
                                                                    },
                                                                    { "type": "basic", "name": "Span", "text": "$t:sirsoft-verification_kginicis.settings.duplicate_field.ci" }
                                                                ]
                                                            }
                                                        ]
                                                    },
                                                    {
                                                        "type": "basic",
                                                        "name": "P",
                                                        "props": { "className": "text-xs text-amber-600 dark:text-amber-400 text-right" },
                                                        "text": "$t:sirsoft-verification_kginicis.settings.duplicate_field.warning"
                                                    }
                                                ]
                                            }
                                        ]
                                    },
                                    {
                                        "id": "field_duplicate_block_enabled",
                                        "type": "basic",
                                        "name": "Div",
                                        "props": { "className": "grid grid-cols-1 lg:grid-cols-12 gap-4 items-start pt-6 border-t border-gray-200 dark:border-gray-700" },
                                        "children": [
                                            {
                                                "type": "basic",
                                                "name": "Div",
                                                "props": { "className": "lg:col-span-8" },
                                                "children": [
                                                    {
                                                        "type": "basic",
                                                        "name": "Label",
                                                        "props": { "className": "form-label" },
                                                        "text": "$t:sirsoft-verification_kginicis.settings.fields.duplicate_block_enabled.label"
                                                    },
                                                    {
                                                        "type": "basic",
                                                        "name": "P",
                                                        "props": { "className": "form-hint" },
                                                        "text": "$t:sirsoft-verification_kginicis.settings.fields.duplicate_block_enabled.hint"
                                                    },
                                                    {
                                                        "type": "basic",
                                                        "name": "P",
                                                        "props": { "className": "text-hint mt-1 italic" },
                                                        "text": "$t:sirsoft-verification_kginicis.settings.fields.duplicate_block_enabled.note"
                                                    }
                                                ]
                                            },
                                            {
                                                "type": "basic",
                                                "name": "Div",
                                                "props": { "className": "flex-center lg:col-span-4 justify-end" },
                                                "children": [
                                                    {
                                                        "type": "composite",
                                                        "name": "Toggle",
                                                        "props": {
                                                            "name": "duplicate_block_enabled"
                                                        }
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "id": "footer_buttons",
                        "type": "basic",
                        "name": "Div",
                        "props": { "className": "sticky-footer-buttons" },
                        "children": [
                            {
                                "id": "cancel_button",
                                "type": "basic",
                                "name": "Button",
                                "props": {
                                    "type": "button",
                                    "className": "btn btn-secondary"
                                },
                                "actions": [
                                    {
                                        "type": "click",
                                        "handler": "navigate",
                                        "params": { "path": "/admin/plugins" }
                                    }
                                ],
                                "children": [
                                    { "type": "basic", "name": "Span", "text": "$t:common.cancel" }
                                ]
                            },
                            {
                                "id": "save_button",
                                "type": "basic",
                                "name": "Button",
                                "props": {
                                    "type": "button",
                                    "disabled": "{{!_local.hasChanges || _local.isSaving}}",
                                    "className": "btn btn-primary flex-center gap-1.5"
                                },
                                "actions": [
                                    {
                                        "type": "click",
                                        "handler": "sequence",
                                        "actions": [
                                            {
                                                "handler": "setState",
                                                "params": { "target": "local", "isSaving": true, "errors": null }
                                            },
                                            {
                                                "handler": "apiCall",
                                                "auth_required": true,
                                                "target": "/api/admin/plugins/{{route.identifier}}/settings",
                                                "params": {
                                                    "method": "PUT",
                                                    "body": "{{_local.form}}"
                                                },
                                                "onSuccess": [
                                                    {
                                                        "handler": "setState",
                                                        "params": { "target": "local", "isSaving": false, "hasChanges": false }
                                                    },
                                                    {
                                                        "handler": "toast",
                                                        "params": { "type": "success", "message": "$t:admin.plugins.settings.save_success" }
                                                    },
                                                    {
                                                        "handler": "refetchDataSource",
                                                        "params": { "dataSourceId": "settings" }
                                                    }
                                                ],
                                                "onError": [
                                                    {
                                                        "handler": "setState",
                                                        "params": {
                                                            "target": "local",
                                                            "isSaving": false,
                                                            "errors": "{{error.errors}}"
                                                        }
                                                    },
                                                    {
                                                        "handler": "toast",
                                                        "params": { "type": "error", "message": "$t:admin.plugins.settings.save_error" }
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ],
                                "children": [
                                    { "type": "basic", "name": "Span", "if": "{{!_local.isSaving}}", "text": "$t:common.save" },
                                    { "type": "basic", "name": "Span", "if": "{{_local.isSaving}}", "text": "$t:common.saving" }
                                ]
                            }
                        ]
                    }
                ]
            }
        ]
    }
}
