"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    CollectionCategroriesProvider: ()=>CollectionCategroriesProvider,
    CollectionManagerProvider_deprecated: ()=>CollectionManagerProvider_deprecated,
    RemoteCollectionManagerProvider: ()=>RemoteCollectionManagerProvider
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
require("react");
const index_js_namespaceObject = require("../api-client/index.js");
const CollectionManagerProvider_js_namespaceObject = require("../data-source/collection/CollectionManagerProvider.js");
const DataSourceManagerProvider_js_namespaceObject = require("../data-source/data-source/DataSourceManagerProvider.js");
const external_CollectionHistoryProvider_js_namespaceObject = require("./CollectionHistoryProvider.js");
const external_CollectionManagerSchemaComponentProvider_js_namespaceObject = require("./CollectionManagerSchemaComponentProvider.js");
const external_context_js_namespaceObject = require("./context.js");
const CollectionManagerProvider_deprecated = (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CollectionManagerProvider_js_namespaceObject.CollectionManagerProvider, {
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CollectionManagerSchemaComponentProvider_js_namespaceObject.CollectionManagerSchemaComponentProvider, {
            children: props.children
        })
    });
const RemoteCollectionManagerProvider = (props)=>{
    const api = (0, index_js_namespaceObject.useAPIClient)();
    const dm = (0, DataSourceManagerProvider_js_namespaceObject.useDataSourceManager)();
    const { refreshCH } = (0, external_CollectionHistoryProvider_js_namespaceObject.useCollectionHistory)();
    const coptions = {
        url: 'collectionCategories:list',
        params: {
            paginate: false,
            sort: [
                'sort'
            ]
        }
    };
    const service = (0, index_js_namespaceObject.useRequest)(()=>dm.reload().then(refreshCH));
    const result = (0, index_js_namespaceObject.useRequest)(coptions);
    if (service.loading) return;
    const refreshCategory = async ()=>{
        const { data } = await api.request(coptions);
        result.mutate(data);
        return (null == data ? void 0 : data.data) || [];
    };
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CollectionCategroriesProvider, {
        service: {
            ...result
        },
        refreshCategory: refreshCategory,
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CollectionManagerProvider_deprecated, {
            ...props
        })
    });
};
const CollectionCategroriesProvider = (props)=>{
    var _service_data;
    const { service, refreshCategory } = props;
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_context_js_namespaceObject.CollectionCategroriesContext.Provider, {
        value: {
            data: null == service ? void 0 : null === (_service_data = service.data) || void 0 === _service_data ? void 0 : _service_data.data,
            refresh: refreshCategory,
            ...props
        },
        children: props.children
    });
};
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
