"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__, {
    SchemaSettingsDateFormat: ()=>SchemaSettingsDateFormat
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
require("react");
const schema_namespaceObject = require("@tachybase/schema");
const external_antd_style_namespaceObject = require("antd-style");
const external_react_i18next_namespaceObject = require("react-i18next");
const external_index_js_namespaceObject = require("../index.js");
const ExpiresRadio_js_namespaceObject = require("./DateFormat/ExpiresRadio.js");
const external_SchemaSettings_js_namespaceObject = require("./SchemaSettings.js");
function _tagged_template_literal(strings, raw) {
    if (!raw) raw = strings.slice(0);
    return Object.freeze(Object.defineProperties(strings, {
        raw: {
            value: Object.freeze(raw)
        }
    }));
}
function _templateObject() {
    const data = _tagged_template_literal([
        "\n      .ant-radio-wrapper {\n        display: flex;\n        margin: 5px 0px;\n      }\n    "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
function _templateObject1() {
    const data = _tagged_template_literal([
        "\n      margin-bottom: 0px;\n    "
    ]);
    _templateObject1 = function() {
        return data;
    };
    return data;
}
function _templateObject2() {
    const data = _tagged_template_literal([
        "\n      color: red;\n      .ant-radio-wrapper {\n        display: flex;\n        margin: 5px 0px;\n      }\n    "
    ]);
    _templateObject2 = function() {
        return data;
    };
    return data;
}
const useStyles = (0, external_antd_style_namespaceObject.createStyles)((param)=>{
    let { css } = param;
    return {
        radio: css(_templateObject()),
        margin: css(_templateObject1()),
        redRadio: css(_templateObject2())
    };
});
const SchemaSettingsDateFormat = function(props) {
    var _fieldSchema_xcomponentprops, _fieldSchema_xcomponentprops1, _collectionField_uiSchema_xcomponentprops, _collectionField_uiSchema, _fieldSchema_xcomponentprops2, _collectionField_uiSchema_xcomponentprops1, _collectionField_uiSchema1, _collectionField_uiSchema_xcomponentprops2, _collectionField_uiSchema2;
    const { styles } = useStyles();
    const { fieldSchema } = props;
    const field = (0, schema_namespaceObject.useField)();
    const { dn } = (0, external_index_js_namespaceObject.useDesignable)();
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const { getCollectionJoinField } = (0, external_index_js_namespaceObject.useCollectionManager_deprecated)();
    const collectionField = getCollectionJoinField(null == fieldSchema ? void 0 : fieldSchema['x-collection-field']) || {};
    const isShowTime = null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.showTime;
    const dateFormatDefaultValue = (null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops1 ? void 0 : _fieldSchema_xcomponentprops1.dateFormat) || (null == collectionField ? void 0 : null === (_collectionField_uiSchema = collectionField.uiSchema) || void 0 === _collectionField_uiSchema ? void 0 : null === (_collectionField_uiSchema_xcomponentprops = _collectionField_uiSchema['x-component-props']) || void 0 === _collectionField_uiSchema_xcomponentprops ? void 0 : _collectionField_uiSchema_xcomponentprops.dateFormat) || 'YYYY-MM-DD';
    const timeFormatDefaultValue = (null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops2 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops2 ? void 0 : _fieldSchema_xcomponentprops2.timeFormat) || (null == collectionField ? void 0 : null === (_collectionField_uiSchema1 = collectionField.uiSchema) || void 0 === _collectionField_uiSchema1 ? void 0 : null === (_collectionField_uiSchema_xcomponentprops1 = _collectionField_uiSchema1['x-component-props']) || void 0 === _collectionField_uiSchema_xcomponentprops1 ? void 0 : _collectionField_uiSchema_xcomponentprops1.timeFormat) || 'HH:mm:ss';
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_SchemaSettings_js_namespaceObject.SchemaSettingsModalItem, {
        title: t('Date display format'),
        schema: {
            type: 'object',
            properties: {
                dateFormat: {
                    type: 'string',
                    title: '{{t("Date format")}}',
                    'x-component': ExpiresRadio_js_namespaceObject.ExpiresRadio,
                    'x-decorator': 'FormItem',
                    'x-decorator-props': {},
                    'x-component-props': {
                        className: styles.radio,
                        defaultValue: 'dddd',
                        formats: [
                            'MMMM Do YYYY',
                            'YYYY-MM-DD',
                            'MM/DD/YY',
                            'YYYY/MM/DD',
                            'DD/MM/YYYY'
                        ]
                    },
                    default: dateFormatDefaultValue,
                    enum: [
                        {
                            label: (0, ExpiresRadio_js_namespaceObject.DateFormatCom)({
                                format: 'MMMM Do YYYY'
                            }),
                            value: 'MMMM Do YYYY'
                        },
                        {
                            label: (0, ExpiresRadio_js_namespaceObject.DateFormatCom)({
                                format: 'YYYY-MM-DD'
                            }),
                            value: 'YYYY-MM-DD'
                        },
                        {
                            label: (0, ExpiresRadio_js_namespaceObject.DateFormatCom)({
                                format: 'MM/DD/YY'
                            }),
                            value: 'MM/DD/YY'
                        },
                        {
                            label: (0, ExpiresRadio_js_namespaceObject.DateFormatCom)({
                                format: 'YYYY/MM/DD'
                            }),
                            value: 'YYYY/MM/DD'
                        },
                        {
                            label: (0, ExpiresRadio_js_namespaceObject.DateFormatCom)({
                                format: 'DD/MM/YYYY'
                            }),
                            value: 'DD/MM/YYYY'
                        },
                        {
                            label: 'custom',
                            value: 'custom'
                        }
                    ]
                },
                showTime: {
                    default: void 0 === isShowTime ? null == collectionField ? void 0 : null === (_collectionField_uiSchema2 = collectionField.uiSchema) || void 0 === _collectionField_uiSchema2 ? void 0 : null === (_collectionField_uiSchema_xcomponentprops2 = _collectionField_uiSchema2['x-component-props']) || void 0 === _collectionField_uiSchema_xcomponentprops2 ? void 0 : _collectionField_uiSchema_xcomponentprops2.showTime : isShowTime,
                    type: 'boolean',
                    'x-decorator': 'FormItem',
                    'x-component': 'Checkbox',
                    'x-content': '{{t("Show time")}}',
                    'x-reactions': [
                        "{{(field) => {\n              field.query('.timeFormat').take(f => {\n                f.display = field.value ? 'visible' : 'none';\n              });\n            }}}"
                    ]
                },
                timeFormat: {
                    type: 'string',
                    title: '{{t("Time format")}}',
                    'x-component': ExpiresRadio_js_namespaceObject.ExpiresRadio,
                    'x-decorator': 'FormItem',
                    'x-decorator-props': {
                        className: styles.margin
                    },
                    'x-component-props': {
                        className: styles.redRadio,
                        defaultValue: 'h:mm a',
                        formats: [
                            'hh:mm:ss a',
                            'HH:mm:ss'
                        ],
                        timeFormat: true
                    },
                    default: timeFormatDefaultValue,
                    enum: [
                        {
                            label: (0, ExpiresRadio_js_namespaceObject.DateFormatCom)({
                                format: 'hh:mm:ss a'
                            }),
                            value: 'hh:mm:ss a'
                        },
                        {
                            label: (0, ExpiresRadio_js_namespaceObject.DateFormatCom)({
                                format: 'HH:mm:ss'
                            }),
                            value: 'HH:mm:ss'
                        },
                        {
                            label: 'custom',
                            value: 'custom'
                        }
                    ]
                }
            }
        },
        onSubmit: (data)=>{
            const schema = {
                ['x-uid']: fieldSchema['x-uid']
            };
            schema['x-component-props'] = fieldSchema['x-component-props'] || {};
            fieldSchema['x-component-props'] = {
                ...fieldSchema['x-component-props'] || {},
                ...data
            };
            schema['x-component-props'] = fieldSchema['x-component-props'];
            field.componentProps = fieldSchema['x-component-props'];
            const parts = field.path.entire.split('.');
            parts.pop();
            const modifiedString = parts.join('.');
            field.query("".concat(modifiedString, ".*[0:].").concat(fieldSchema.name)).forEach((f)=>{
                if (f.props.name === fieldSchema.name) f.setComponentProps({
                    ...data
                });
            });
            dn.emit('patch', {
                schema
            });
            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
});
