import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_client__ from "@tachybase/client";
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
const mySettings = new __WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaSettings({
    name: 'mySettings',
    items: [
        {
            name: 'remove',
            type: 'remove',
            componentProps: {
                removeParentsIfNoChildren: true
            }
        }
    ]
});
const myInitializer = new __WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaInitializer({
    name: 'myInitializer',
    title: 'Button Text',
    wrap: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Grid.wrap,
    items: [
        {
            name: 'demo1',
            title: 'Demo1',
            Component: ()=>{
                const itemConfig = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_client__.useSchemaInitializerItem)();
                const { insert } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_client__.useSchemaInitializer)();
                const handleClick = ()=>{
                    insert({
                        type: 'void',
                        'x-settings': 'mySettings',
                        'x-decorator': 'CardItem',
                        'x-component': 'Hello'
                    });
                };
                return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaInitializerItem, {
                    title: itemConfig.title,
                    onClick: handleClick
                });
            }
        }
    ]
});
const Hello = ()=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("h1", {
        children: "Hello, world!"
    });
const Btn = ()=>{
    const { designable, setDesignable } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_client__.useSchemaComponentContext)();
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)(__WEBPACK_EXTERNAL_MODULE_antd__.Button, {
        style: {
            marginBottom: 24
        },
        onClick: ()=>{
            setDesignable(!designable);
        },
        children: [
            "designable: ",
            designable ? 'true' : 'false'
        ]
    });
};
const HelloPage = ()=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("div", {
        children: [
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(Btn, {}),
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaComponent, {
                schema: {
                    name: 'hello',
                    type: 'void',
                    'x-component': 'Grid',
                    'x-initializer': 'myInitializer'
                }
            })
        ]
    });
class PluginHello extends __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Plugin {
    async load() {
        this.app.addComponents({
            Grid: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Grid,
            CardItem: __WEBPACK_EXTERNAL_MODULE__tachybase_client__.CardItem,
            Hello
        });
        this.app.schemaSettingsManager.add(mySettings);
        this.app.schemaInitializerManager.add(myInitializer);
        this.router.add('hello', {
            path: '/',
            Component: HelloPage
        });
    }
}
const app = new __WEBPACK_EXTERNAL_MODULE__tachybase_client__.Application({
    router: {
        type: 'memory'
    },
    designable: true,
    plugins: [
        PluginHello
    ]
});
const demo3_rslib_entry_ = app.getRootComponent();
export { demo3_rslib_entry_ as default };
