import { jsx } from "react/jsx-runtime";
import "react";
import { useField, useFieldSchema } from "@tachybase/schema";
import { useDesignable } from "../schema-component/index.mjs";
import { useFieldComponents } from "../schema-initializer/index.mjs";
import { SchemaSettingsSelectItem } from "./SchemaSettings.mjs";
function SchemaSettingComponent() {
    const fieldSchema = useFieldSchema();
    const field = useField();
    const checkedItems = [
        'Radio.Group',
        'Checkbox.Group'
    ];
    const component = fieldSchema['x-component'];
    const options = useFieldComponents().options.map((item)=>{
        if (checkedItems.includes(component)) return checkedItems.includes(item.value) ? item : null;
        return checkedItems.includes(item.value) || 'DatePicker' === item.value || 'AssociationCascader' === item.value ? null : item;
    }).filter(Boolean);
    const { dn } = useDesignable();
    return /*#__PURE__*/ jsx(SchemaSettingsSelectItem, {
        title: "Field Component",
        options: options,
        value: fieldSchema['x-component'],
        onChange: (mode)=>{
            field.component = mode;
            fieldSchema['x-component'] = mode;
            field.componentProps = fieldSchema['x-component-props'];
            dn.emit('patch', {
                schema: {
                    ['x-uid']: fieldSchema['x-uid'],
                    ['x-component']: fieldSchema['x-component']
                }
            });
            dn.refresh();
        }
    }, "component-field");
}
export { SchemaSettingComponent };
