import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
import * as __WEBPACK_EXTERNAL_MODULE__index_mjs__ from "../../../index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__application_index_mjs__ from "../../../application/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__application_schema_settings_SchemaSettings_mjs__ from "../../../application/schema-settings/SchemaSettings.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_antd_action_Action_Designer_mjs__ from "../../../schema-component/antd/action/Action.Designer.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_settings_index_mjs__ from "../../../schema-settings/index.mjs";
function ButtonEditor() {
    var _fieldSchema_xcomponentprops, _fieldSchema_xcomponentprops1;
    const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
    const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const { dn } = (0, __WEBPACK_EXTERNAL_MODULE__index_mjs__.useDesignable)();
    const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
    const { titleExpand, titleCollapse, iconExpand, iconCollapse } = fieldSchema['x-component-props'] || {};
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__schema_settings_index_mjs__.SchemaSettingsModalItem, {
        title: t('Edit button'),
        schema: {
            type: 'object',
            title: t('Edit button'),
            properties: {
                titleExpand: {
                    'x-decorator': 'FormItem',
                    'x-component': 'Input',
                    title: "".concat(t('Button title'), " - ").concat(t('Expand all')),
                    default: titleExpand
                },
                titleCollapse: {
                    'x-decorator': 'FormItem',
                    'x-component': 'Input',
                    title: "".concat(t('Button title'), " - ").concat(t('Collapse all')),
                    default: titleCollapse
                },
                iconExpand: {
                    'x-decorator': 'FormItem',
                    'x-component': 'IconPicker',
                    title: "".concat(t('Button icon'), " - ").concat(t('Expand all')),
                    default: iconExpand
                },
                iconCollapse: {
                    'x-decorator': 'FormItem',
                    'x-component': 'IconPicker',
                    title: "".concat(t('Button icon'), " - ").concat(t('Collapse all')),
                    default: iconCollapse
                },
                type: {
                    'x-decorator': 'FormItem',
                    'x-component': 'Radio.Group',
                    title: t('Button background color'),
                    default: (null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.danger) ? 'danger' : (null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops1 ? void 0 : _fieldSchema_xcomponentprops1.type) === 'primary' ? 'primary' : 'default',
                    enum: [
                        {
                            value: 'default',
                            label: '{{t("Default")}}'
                        },
                        {
                            value: 'primary',
                            label: '{{t("Highlight")}}'
                        },
                        {
                            value: 'danger',
                            label: '{{t("Danger red")}}'
                        }
                    ]
                }
            }
        },
        onSubmit: (param)=>{
            let { titleExpand, titleCollapse, iconExpand, iconCollapse, type } = param;
            fieldSchema.title = t('Expand/Collapse');
            field.title = t('Expand/Collapse');
            field.componentProps.icon = iconExpand;
            field.componentProps.danger = 'danger' === type;
            field.componentProps.type = type;
            fieldSchema['x-component-props'] = {
                ...fieldSchema['x-component-props'] || {},
                titleExpand,
                titleCollapse,
                iconExpand,
                iconCollapse,
                type,
                danger: 'danger' === type
            };
            dn.emit('patch', {
                schema: {
                    'x-uid': fieldSchema['x-uid'],
                    'x-component-props': fieldSchema['x-component-props'],
                    title: fieldSchema.title
                }
            });
            dn.refresh();
        }
    });
}
const expendableActionSettings = new __WEBPACK_EXTERNAL_MODULE__application_schema_settings_SchemaSettings_mjs__.SchemaSettings({
    name: 'actionSettings:expendable',
    items: [
        {
            name: 'editButton',
            Component: ButtonEditor,
            useComponentProps () {
                const { buttonEditorProps } = (0, __WEBPACK_EXTERNAL_MODULE__application_index_mjs__.useSchemaToolbar)();
                return buttonEditorProps;
            }
        },
        {
            name: 'remove',
            sort: 100,
            Component: __WEBPACK_EXTERNAL_MODULE__schema_component_antd_action_Action_Designer_mjs__.RemoveButton,
            useComponentProps () {
                const { removeButtonProps } = (0, __WEBPACK_EXTERNAL_MODULE__application_index_mjs__.useSchemaToolbar)();
                return removeButtonProps;
            }
        }
    ]
});
export { expendableActionSettings };
