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_antd__ from "antd";
import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
import * as __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__ from "../../hooks/index.mjs";
const SaveDefaultValue = (props)=>{
    const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
    const { designable, dn, refresh } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useDesignable)();
    const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const form = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useForm)();
    if (!designable) return null;
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Button, {
        style: {
            borderColor: 'var(--colorSettings)',
            color: 'var(--colorSettings)'
        },
        type: 'dashed',
        onClick: ()=>{
            var _fieldSchema_parent_parent_parent_properties, _fieldSchema_parent_parent_parent, _fieldSchema_parent_parent, _fieldSchema_parent;
            const filterSchema = null == fieldSchema ? void 0 : null === (_fieldSchema_parent = fieldSchema.parent) || void 0 === _fieldSchema_parent ? void 0 : null === (_fieldSchema_parent_parent = _fieldSchema_parent.parent) || void 0 === _fieldSchema_parent_parent ? void 0 : null === (_fieldSchema_parent_parent_parent = _fieldSchema_parent_parent.parent) || void 0 === _fieldSchema_parent_parent_parent ? void 0 : null === (_fieldSchema_parent_parent_parent_properties = _fieldSchema_parent_parent_parent.properties) || void 0 === _fieldSchema_parent_parent_parent_properties ? void 0 : _fieldSchema_parent_parent_parent_properties.filter;
            if (!filterSchema) return;
            const defaultValue = form.values.filter;
            dn.emit('patch', {
                schema: {
                    'x-uid': filterSchema['x-uid'],
                    default: defaultValue
                }
            });
            dn.refresh();
            filterSchema.default = defaultValue;
        },
        children: t('Save conditions')
    });
};
export { SaveDefaultValue };
