"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__, {
    InputFieldInterface: ()=>InputFieldInterface
});
const schema_namespaceObject = require("@tachybase/schema");
const CollectionFieldInterface_js_namespaceObject = require("../../data-source/collection-field-interface/CollectionFieldInterface.js");
const index_js_namespaceObject = require("../../i18n/index.js");
const external_properties_index_js_namespaceObject = require("./properties/index.js");
function _define_property(obj, key, value) {
    if (key in obj) Object.defineProperty(obj, key, {
        value: value,
        enumerable: true,
        configurable: true,
        writable: true
    });
    else obj[key] = value;
    return obj;
}
(0, schema_namespaceObject.registerValidateRules)({
    username (value) {
        return /^[^@.<>"'/]{2,16}$/.test(value) || index_js_namespaceObject.i18n.t('Must be 2-16 characters in length (excluding @.<>"\'/)');
    }
});
class InputFieldInterface extends CollectionFieldInterface_js_namespaceObject.CollectionFieldInterface {
    schemaInitialize(schema, param) {
        let { block } = param;
        if ([
            'Table',
            'Kanban'
        ].includes(block)) {
            schema['x-component-props'] = schema['x-component-props'] || {};
            schema['x-component-props']['ellipsis'] = true;
        }
    }
    validateSchema(fieldSchema) {
        return {
            max: {
                type: 'number',
                title: '{{ t("Max length") }}',
                minimum: 0,
                'x-decorator': 'FormItem',
                'x-component': 'InputNumber',
                'x-component-props': {
                    precision: 0
                },
                'x-reactions': "{{(field) => {\n          const targetValue = field.query('.min').value();\n          field.selfErrors =\n            !!targetValue && !!field.value && targetValue > field.value ? '".concat(index_js_namespaceObject.i18n.t('Max length must greater than min length'), "' : ''\n        }}}")
            },
            min: {
                type: 'number',
                title: '{{ t("Min length") }}',
                minimum: 0,
                'x-decorator': 'FormItem',
                'x-component': 'InputNumber',
                'x-component-props': {
                    precision: 0
                },
                'x-reactions': {
                    dependencies: [
                        '.max'
                    ],
                    fulfill: {
                        state: {
                            selfErrors: "{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '".concat(index_js_namespaceObject.i18n.t('Min length must less than max length'), "' : ''}}")
                        }
                    }
                }
            },
            len: {
                type: 'number',
                title: '{{ t("Length") }}',
                minimum: 0,
                'x-decorator': 'FormItem',
                'x-component': 'InputNumber',
                'x-component-props': {
                    precision: 0
                }
            },
            format: {
                type: 'string',
                title: '{{ t("Format") }}',
                'x-decorator': 'FormItem',
                'x-component': 'Select',
                'x-component-props': {
                    allowClear: true
                },
                enum: [
                    {
                        label: '{{ t("url") }}',
                        value: 'url'
                    },
                    {
                        label: '{{ t("email") }}',
                        value: 'email'
                    },
                    {
                        label: '{{ t("ipv6") }}',
                        value: 'ipv6'
                    },
                    {
                        label: '{{ t("ipv4") }}',
                        value: 'ipv4'
                    },
                    {
                        label: '{{ t("number") }}',
                        value: 'number'
                    },
                    {
                        label: '{{ t("integer") }}',
                        value: 'integer'
                    },
                    {
                        label: '{{ t("idcard") }}',
                        value: 'idcard'
                    },
                    {
                        label: '{{ t("qq") }}',
                        value: 'qq'
                    },
                    {
                        label: '{{ t("phone") }}',
                        value: 'phone'
                    },
                    {
                        label: '{{ t("money") }}',
                        value: 'money'
                    },
                    {
                        label: '{{ t("zh") }}',
                        value: 'zh'
                    },
                    {
                        label: '{{ t("date") }}',
                        value: 'date'
                    },
                    {
                        label: '{{ t("zip") }}',
                        value: 'zip'
                    }
                ]
            },
            pattern: {
                type: 'string',
                title: '{{ t("Regular expression") }}',
                'x-decorator': 'FormItem',
                'x-component': 'Input',
                'x-component-props': {
                    prefix: '/',
                    suffix: '/'
                }
            }
        };
    }
    constructor(...args){
        super(...args), _define_property(this, "name", 'input'), _define_property(this, "type", 'object'), _define_property(this, "group", 'basic'), _define_property(this, "order", 1), _define_property(this, "title", '{{t("Single line text")}}'), _define_property(this, "sortable", true), _define_property(this, "default", {
            interface: 'input',
            type: 'string',
            uiSchema: {
                type: 'string',
                'x-component': 'Input'
            }
        }), _define_property(this, "availableTypes", [
            'string',
            'uid'
        ]), _define_property(this, "hasDefaultValue", true), _define_property(this, "properties", {
            ...external_properties_index_js_namespaceObject.defaultProps,
            layout: {
                type: 'void',
                title: '{{t("Index")}}',
                'x-component': 'Space',
                'x-decorator': 'FormItem',
                'x-decorator-props': {
                    style: {
                        marginBottom: '0px'
                    }
                },
                properties: {
                    primaryKey: external_properties_index_js_namespaceObject.primaryKey,
                    unique: external_properties_index_js_namespaceObject.unique
                }
            }
        }), _define_property(this, "filterable", {
            operators: external_properties_index_js_namespaceObject.operators.string
        }), _define_property(this, "titleUsable", true);
    }
}
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
});
