import { CollectionFieldInterface } from "../../data-source/collection-field-interface/CollectionFieldInterface.mjs";
import { i18n } from "../../i18n/index.mjs";
import { defaultProps, unique } from "./properties/index.mjs";
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;
}
class PasswordFieldInterface extends CollectionFieldInterface {
    constructor(...args){
        super(...args), _define_property(this, "name", 'password'), _define_property(this, "type", 'object'), _define_property(this, "group", 'basic'), _define_property(this, "order", 9), _define_property(this, "title", '{{t("Password")}}'), _define_property(this, "default", {
            type: 'password',
            hidden: true,
            uiSchema: {
                type: 'string',
                'x-component': 'Password'
            }
        }), _define_property(this, "availableTypes", [
            'password'
        ]), _define_property(this, "hasDefaultValue", true), _define_property(this, "properties", {
            ...defaultProps,
            unique: unique
        }), _define_property(this, "validateSchema", (fieldSchema)=>({
                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(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(i18n.t('Min length must less than max length'), "' : ''}}")
                            }
                        }
                    }
                }
            }));
    }
}
export { PasswordFieldInterface };
