"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    pageSettings: ()=>pageSettings
});
const schema_namespaceObject = require("@tachybase/schema");
const external_react_i18next_namespaceObject = require("react-i18next");
const external_react_router_namespaceObject = require("react-router");
const external_index_js_namespaceObject = require("../../index.js");
const index_js_namespaceObject = require("../../../application/schema-settings/index.js");
const schema_toolbar_index_js_namespaceObject = require("../../../application/schema-toolbar/index.js");
function useNotDisableHeader() {
    var _fieldSchema_xcomponentprops;
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    return !(null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.disablePageHeader);
}
const pageSettings = new index_js_namespaceObject.SchemaSettings({
    name: 'PageSettings',
    items: [
        {
            name: 'enablePageHeader',
            type: 'switch',
            useComponentProps () {
                var _fieldSchema_xcomponentprops;
                const { dn } = (0, external_index_js_namespaceObject.useDesignable)();
                const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
                const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
                return {
                    title: t('Enable page header'),
                    checked: !(null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.disablePageHeader),
                    onChange (v) {
                        fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                        fieldSchema['x-component-props']['disablePageHeader'] = !v;
                        dn.emit('patch', {
                            schema: {
                                ['x-uid']: fieldSchema['x-uid'],
                                ['x-component-props']: fieldSchema['x-component-props']
                            }
                        });
                        dn.refresh();
                    }
                };
            }
        },
        {
            name: 'enablesharePage',
            type: 'switch',
            useVisible () {
                const isShare = (0, external_react_router_namespaceObject.useMatch)('/share/:name');
                return !isShare;
            },
            useComponentProps () {
                var _fieldSchema_xcomponentprops;
                const { dn } = (0, external_index_js_namespaceObject.useDesignable)();
                const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
                const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
                const { title } = (0, schema_toolbar_index_js_namespaceObject.useSchemaToolbar)();
                return {
                    title: t('Enable Share page'),
                    checked: null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.enableSharePage,
                    onChange (v) {
                        fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                        fieldSchema['x-component-props']['enableSharePage'] = v;
                        if (!fieldSchema.title) fieldSchema.title = title;
                        dn.emit('patch', {
                            schema: {
                                ['x-uid']: fieldSchema['x-uid'],
                                ['x-component-props']: fieldSchema['x-component-props'],
                                title: fieldSchema.title
                            }
                        });
                        dn.refresh();
                    }
                };
            }
        },
        {
            name: 'divider',
            type: 'divider',
            useVisible: useNotDisableHeader
        },
        {
            name: 'displayPageTitle',
            type: 'switch',
            useVisible: useNotDisableHeader,
            useComponentProps () {
                var _fieldSchema_xcomponentprops;
                const { dn } = (0, external_index_js_namespaceObject.useDesignable)();
                const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
                const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
                return {
                    title: t('Display page title'),
                    checked: !(null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.hidePageTitle),
                    onChange (v) {
                        fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                        fieldSchema['x-component-props']['hidePageTitle'] = !v;
                        dn.emit('patch', {
                            schema: {
                                ['x-uid']: fieldSchema['x-uid'],
                                ['x-component-props']: fieldSchema['x-component-props']
                            }
                        });
                        dn.refresh();
                    }
                };
            }
        },
        {
            name: 'editPageTitle',
            type: 'modal',
            useVisible () {
                var _fieldSchema_xcomponentprops;
                const notDisablePageHeader = useNotDisableHeader();
                const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
                const notHidePageTitle = !(null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.hidePageTitle);
                return notDisablePageHeader && notHidePageTitle;
            },
            useComponentProps () {
                const { dn } = (0, external_index_js_namespaceObject.useDesignable)();
                const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
                const field = (0, schema_namespaceObject.useField)();
                const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
                const { title } = (0, schema_toolbar_index_js_namespaceObject.useSchemaToolbar)();
                return {
                    hide: true,
                    title: t('Edit page title'),
                    schema: {
                        type: 'object',
                        title: t('Edit page title'),
                        properties: {
                            title: {
                                title: t('Title'),
                                required: true,
                                'x-decorator': 'FormItem',
                                'x-component': 'Input',
                                'x-component-props': {}
                            }
                        }
                    },
                    initialValues: {
                        title
                    },
                    onSubmit (param) {
                        let { title } = param;
                        field.title = title;
                        fieldSchema['title'] = title;
                        dn.emit('patch', {
                            schema: {
                                ['x-uid']: fieldSchema['x-uid'],
                                title
                            }
                        });
                    }
                };
            }
        },
        {
            name: 'enablePageTabs',
            type: 'switch',
            useVisible: useNotDisableHeader,
            useComponentProps () {
                var _fieldSchema_xcomponentprops;
                const { dn } = (0, external_index_js_namespaceObject.useDesignable)();
                const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
                const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
                return {
                    title: t('Enable page tabs'),
                    checked: null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.enablePageTabs,
                    onChange (v) {
                        fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                        fieldSchema['x-component-props']['enablePageTabs'] = v;
                        dn.emit('patch', {
                            schema: {
                                ['x-uid']: fieldSchema['x-uid'],
                                ['x-component-props']: fieldSchema['x-component-props']
                            }
                        });
                        dn.refresh();
                    }
                };
            }
        }
    ]
});
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
