import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_client__ from "@tachybase/client";
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
import * as __WEBPACK_EXTERNAL_MODULE__useFilterActionProps_mjs__ from "../useFilterActionProps.mjs";
const collections = [
    {
        name: 'test1',
        template: 'general',
        fields: [
            {
                type: 'string',
                name: 'title1',
                interface: 'input',
                uiSchema: {
                    title: 'Title1',
                    type: 'string',
                    'x-component': 'Input',
                    required: true
                }
            }
        ]
    },
    {
        name: 'test2',
        template: 'general',
        fields: [
            {
                type: 'string',
                name: 'title2',
                interface: 'input',
                uiSchema: {
                    title: 'Title2',
                    type: 'string',
                    'x-component': 'Input',
                    required: true
                }
            }
        ]
    }
];
const schema = {
    type: 'void',
    properties: {
        demo: {
            name: 'filter',
            type: 'object',
            'x-component': 'Filter',
            'x-use-component-props': ()=>{
                const { name } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_client__.useCollection_deprecated)();
                const options = (0, __WEBPACK_EXTERNAL_MODULE__useFilterActionProps_mjs__.useFilterOptions)(name);
                return {
                    options
                };
            }
        }
    }
};
const SwitchCollection = (props)=>{
    const [collection, setCollection] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(collections[0].name);
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("div", {
        children: [
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Select, {
                options: [
                    {
                        label: 'test1',
                        value: 'test1'
                    },
                    {
                        label: 'test2',
                        value: 'test2'
                    }
                ],
                defaultValue: 'test1',
                onChange: (value)=>{
                    setCollection(value);
                }
            }),
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("br", {}),
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("br", {}),
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.CollectionProvider_deprecated, {
                name: collection,
                children: props.children
            })
        ]
    });
};
const Demo = ()=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.AntdSchemaComponentProvider, {
        children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(SwitchCollection, {
            children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaComponent, {
                schema: schema
            })
        })
    });
class MyPlugin extends __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Plugin {
    async load() {
        this.app.dataSourceManager.addDataSource(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.LocalDataSource, {
            key: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.DEFAULT_DATA_SOURCE_KEY,
            displayName: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.DEFAULT_DATA_SOURCE_TITLE,
            collections: collections
        });
    }
}
const app = new __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Application({
    plugins: [
        __WEBPACK_EXTERNAL_MODULE__tachybase_client__.CollectionPlugin,
        MyPlugin
    ],
    components: {
        Input: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Input,
        Filter: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Filter
    },
    providers: [
        Demo
    ]
});
const demo6_rslib_entry_ = app.getRootComponent();
export { demo6_rslib_entry_ as default };
