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_axios_mock_adapter__ from "axios-mock-adapter";
const apiClient = new __WEBPACK_EXTERNAL_MODULE__tachybase_client__.APIClient();
const mock = new __WEBPACK_EXTERNAL_MODULE_axios_mock_adapter__["default"](apiClient.axios);
mock.onGet('/posts/1/tags:list').reply(200, {
    data: [
        {
            id: 1,
            name: 'Tag 1'
        },
        {
            id: 2,
            name: 'Tag 2'
        }
    ]
});
const collection = {
    name: 'posts',
    fields: [
        {
            type: 'belongsToMany',
            name: 'tags',
            targetKey: 'id',
            sourceKey: 'id',
            foreignKey: 'postId',
            otherKey: 'tagId'
        }
    ]
};
const record = {
    id: 1
};
const providers = [
    [
        __WEBPACK_EXTERNAL_MODULE__tachybase_client__.APIClientProvider,
        {
            apiClient
        }
    ],
    [
        __WEBPACK_EXTERNAL_MODULE__tachybase_client__.RecordProvider,
        {
            record
        }
    ],
    [
        __WEBPACK_EXTERNAL_MODULE__tachybase_client__.CollectionProvider_deprecated,
        {
            collection
        }
    ],
    [
        __WEBPACK_EXTERNAL_MODULE__tachybase_client__.CollectionFieldProvider,
        {
            name: 'tags'
        }
    ]
];
const demo3_rslib_entry_ = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_client__.compose)(...providers)(()=>{
    const { resource } = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_client__.useCollectionField_deprecated)();
    const [items, setItems] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)([]);
    (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
        resource.list().then((response)=>{
            var _response_data;
            setItems(null == response ? void 0 : null === (_response_data = response.data) || void 0 === _response_data ? void 0 : _response_data.data);
        }).catch(console.error);
    }, []);
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
        children: null == items ? void 0 : items.map((item, key)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
                children: item.name
            }, key))
    });
});
export { demo3_rslib_entry_ as default };
