exports.id = 308;
exports.ids = [308];
exports.modules = {

/***/ 3418:
/***/ ((module) => {

// Exports
module.exports = {
	"center": "ThemeMarket_center__f_y1V",
	"paper": "ThemeMarket_paper__XE49S",
	"styledScrollBarList": "ThemeMarket_styledScrollBarList__e2ee_",
	"page": "ThemeMarket_page__DUqHe",
	"pageHeader": "ThemeMarket_pageHeader__nLyoe",
	"pageContent": "ThemeMarket_pageContent__n4ipZ",
	"pageTitle": "ThemeMarket_pageTitle__gqWjY",
	"customIcon": "ThemeMarket_customIcon__h6ypV",
	"ThemeMarket": "ThemeMarket_ThemeMarket__ZBZpT",
	"list": "ThemeMarket_list__IyVw5",
	"listHeader": "ThemeMarket_listHeader__wAkj0",
	"filter": "ThemeMarket_filter__Myipt",
	"pageActions": "ThemeMarket_pageActions__Xg03w",
	"listWrapper": "ThemeMarket_listWrapper__GP9_s",
	"listItem": "ThemeMarket_listItem__vdiQE",
	"listContainer": "ThemeMarket_listContainer__cOUCS",
	"paginationContainer": "ThemeMarket_paginationContainer__v2URG",
	"pagination": "ThemeMarket_pagination__NHalV",
	"filterItem": "ThemeMarket_filterItem__Cquph"
};


/***/ }),

/***/ 6308:
/***/ ((module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (/* binding */ ThemeMarket)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2322);
/* harmony import */ var _cromwell_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1815);
/* harmony import */ var _cromwell_core_frontend__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4536);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5692);
/* harmony import */ var _mui_material__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_mui_material__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var throttle_debounce__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7261);
/* harmony import */ var _components_market_MarketItem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5904);
/* harmony import */ var _components_market_MarketModal__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(591);
/* harmony import */ var _components_modal_Modal__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(248);
/* harmony import */ var _components_pagination_Pagination__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(9336);
/* harmony import */ var _components_toast_toast__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(9035);
/* harmony import */ var _styles_common_module_scss__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(1490);
/* harmony import */ var _styles_common_module_scss__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(_styles_common_module_scss__WEBPACK_IMPORTED_MODULE_12__);
/* harmony import */ var _ThemeMarket_module_scss__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(3418);
/* harmony import */ var _ThemeMarket_module_scss__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(_ThemeMarket_module_scss__WEBPACK_IMPORTED_MODULE_11__);
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([throttle_debounce__WEBPACK_IMPORTED_MODULE_5__, _components_toast_toast__WEBPACK_IMPORTED_MODULE_10__]);
([throttle_debounce__WEBPACK_IMPORTED_MODULE_5__, _components_toast_toast__WEBPACK_IMPORTED_MODULE_10__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);













class ThemeMarket extends react__WEBPACK_IMPORTED_MODULE_4__.Component {
    constructor(props){
        super(props);
        this.listId = "plugin_market";
        this.filterInput = {};
        this.getThemeList = async ()=>{
            try {
                const infos = await (0,_cromwell_core_frontend__WEBPACK_IMPORTED_MODULE_2__.getRestApiClient)()?.getThemesInfo();
                if (infos && Array.isArray(infos)) {
                    this.setState({
                        installedThemes: infos
                    });
                }
            } catch (e) {
                console.error(e);
            }
        };
        this.loadList = async ({ pagedParams  })=>{
            return (0,_cromwell_core_frontend__WEBPACK_IMPORTED_MODULE_2__.getCentralServerClient)().getThemeList(pagedParams, this.filterInput);
        };
        this.openTheme = (info)=>{
            this.setState({
                openedTheme: info
            });
        };
        this.installTheme = async (info)=>{
            let success = false;
            try {
                success = await (0,_cromwell_core_frontend__WEBPACK_IMPORTED_MODULE_2__.getRestApiClient)().installTheme(info.name);
            } catch (error) {
                console.error(error);
            }
            await this.getThemeList();
            if (success) {
                _components_toast_toast__WEBPACK_IMPORTED_MODULE_10__/* .toast.success */ .A.success("Theme installed");
            } else {
                _components_toast_toast__WEBPACK_IMPORTED_MODULE_10__/* .toast.error */ .A.error("Failed to install theme");
            }
            return success;
        };
        this.resetList = ()=>{
            const list = (0,_cromwell_core__WEBPACK_IMPORTED_MODULE_1__.getBlockInstance)(this.listId)?.getContentInstance();
            list?.clearState();
            list?.init();
        };
        this.handleFilterInput = (0,throttle_debounce__WEBPACK_IMPORTED_MODULE_5__.debounce)(400, ()=>{
            this.resetList();
        });
        this.state = {
            isLoading: true,
            installedThemes: []
        };
    }
    componentDidMount() {
        this.init();
    }
    async init() {
        this.setState({
            isLoading: true
        });
        await this.getThemeList();
        this.setState({
            isLoading: false
        });
    }
    render() {
        return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
            className: (_ThemeMarket_module_scss__WEBPACK_IMPORTED_MODULE_11___default().ThemeMarket),
            children: [
                /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                    className: (_ThemeMarket_module_scss__WEBPACK_IMPORTED_MODULE_11___default().listHeader),
                    children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_3__.TextField, {
                        className: (_ThemeMarket_module_scss__WEBPACK_IMPORTED_MODULE_11___default().filterItem),
                        placeholder: "Search",
                        variant: "standard",
                        onChange: (event)=>{
                            this.filterInput.search = event.target.value;
                            this.handleFilterInput();
                        }
                    })
                }),
                this.state.isLoading && preloader,
                !this.state.isLoading && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_cromwell_core_frontend__WEBPACK_IMPORTED_MODULE_2__.CList, {
                    className: (_ThemeMarket_module_scss__WEBPACK_IMPORTED_MODULE_11___default().listWrapper),
                    id: this.listId,
                    ListItem: _components_market_MarketItem__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z,
                    listItemProps: {
                        installedModules: this.state?.installedThemes ?? [],
                        install: this.installTheme,
                        open: this.openTheme
                    },
                    useAutoLoading: true,
                    usePagination: true,
                    useQueryPagination: true,
                    loader: this.loadList,
                    cssClasses: {
                        scrollBox: (_ThemeMarket_module_scss__WEBPACK_IMPORTED_MODULE_11___default().list),
                        page: (_ThemeMarket_module_scss__WEBPACK_IMPORTED_MODULE_11___default().listContainer)
                    },
                    elements: {
                        pagination: _components_pagination_Pagination__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z,
                        preloader: preloader
                    }
                }),
                /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_modal_Modal__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z, {
                    open: !!this.state.openedTheme,
                    blurSelector: "#root",
                    className: (_styles_common_module_scss__WEBPACK_IMPORTED_MODULE_12___default().center),
                    onClose: ()=>this.setState({
                            openedTheme: undefined
                        }),
                    children: this.state?.openedTheme && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_market_MarketModal__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z, {
                        installedModules: this.state?.installedThemes ?? [],
                        install: this.installTheme,
                        data: this.state.openedTheme
                    })
                })
            ]
        });
    }
}
const preloader = /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
    className: (_ThemeMarket_module_scss__WEBPACK_IMPORTED_MODULE_11___default().listContainer),
    children: Array(4).fill(1).map((it, index)=>{
        return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Grid, {
            item: true,
            xs: 6,
            lg: 4,
            className: (_ThemeMarket_module_scss__WEBPACK_IMPORTED_MODULE_11___default().listItem),
            children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_mui_material__WEBPACK_IMPORTED_MODULE_3__.Skeleton, {
                variant: "rectangular",
                height: "388px",
                width: "100%",
                style: {
                    margin: "0 10px 20px 10px"
                },
                children: " "
            })
        }, index);
    })
});

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });

/***/ })

};
;