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__ahooksjs_use_url_state__ from "@ahooksjs/use-url-state";
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
import * as __WEBPACK_EXTERNAL_MODULE__createApp_mjs__ from "./createApp.mjs";
const collection = 'users';
const associationField = 'roles';
const association = "".concat(collection, ".").concat(associationField);
const action = 'list';
const schema = {
    type: 'void',
    name: 'root',
    'x-decorator': 'DataBlockProvider',
    'x-use-decorator-props': 'useBlockDecoratorProps',
    'x-decorator-props': {
        association,
        action
    },
    'x-component': 'CardItem',
    properties: {
        demo: {
            type: 'array',
            'x-component': 'MyTable',
            'x-use-component-props': 'useTableProps'
        }
    }
};
const MyTable = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_client__.withDynamicSchemaProps)(__WEBPACK_EXTERNAL_MODULE_antd__.Table);
function useTableProps() {
    const { data, loading } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_client__.useDataBlockRequest)();
    return {
        loading,
        dataSource: (null == data ? void 0 : data.data) || [],
        columns: [
            {
                title: 'Name',
                dataIndex: 'name'
            },
            {
                title: 'Title',
                dataIndex: 'title'
            },
            {
                title: 'Description',
                dataIndex: 'description'
            }
        ]
    };
}
const useBlockDecoratorProps = ()=>{
    const [state] = (0, __WEBPACK_EXTERNAL_MODULE__ahooksjs_use_url_state__["default"])({
        userId: '1'
    });
    return {
        sourceId: state.userId
    };
};
const Demo = ()=>{
    const [state, setState] = (0, __WEBPACK_EXTERNAL_MODULE__ahooksjs_use_url_state__["default"])({
        userId: '1'
    });
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment, {
        children: [
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Select, {
                defaultValue: state.userId,
                options: [
                    {
                        key: 1,
                        value: '1',
                        label: 'Tom'
                    },
                    {
                        key: 2,
                        value: '2',
                        label: 'Jack'
                    }
                ],
                onChange: (v)=>{
                    setState({
                        userId: v
                    });
                }
            }),
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_client__.SchemaComponent, {
                schema: schema
            })
        ]
    });
};
const mocks = {
    ["".concat(collection, "/1/").concat(associationField, ":").concat(action)]: {
        data: [
            {
                name: 'admin',
                title: 'Admin',
                description: 'Admin description'
            },
            {
                name: 'developer',
                title: 'Developer',
                description: 'Developer description'
            }
        ]
    },
    ["".concat(collection, "/2/").concat(associationField, ":").concat(action)]: {
        data: [
            {
                name: 'developer',
                title: 'Developer',
                description: 'Developer description'
            },
            {
                name: 'tester',
                title: 'Tester',
                description: 'Tester description'
            }
        ]
    },
    ["".concat(collection, ":get/1")]: {
        id: 1,
        username: 'Tom'
    },
    ["".concat(collection, ":get/2")]: {
        id: 1,
        username: 'Jack'
    }
};
const Root = (0, __WEBPACK_EXTERNAL_MODULE__createApp_mjs__.createApp)(Demo, {
    components: {
        MyTable
    },
    scopes: {
        useTableProps,
        useBlockDecoratorProps
    }
}, mocks);
const association_table_list_and_source_id_rslib_entry_ = Root;
export { association_table_list_and_source_id_rslib_entry_ as default };
