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_ahooks__ from "ahooks";
import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
import * as __WEBPACK_EXTERNAL_MODULE__application_Plugin_mjs__ from "../../application/Plugin.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__DynamicPage_mjs__ from "./DynamicPage.mjs";
class PluginDynamicPage extends __WEBPACK_EXTERNAL_MODULE__application_Plugin_mjs__.Plugin {
    async beforeLoad() {
        this.app.use(PageModeProvider);
    }
    async load() {
        this.app.router.remove('app.page');
        this.app.router.add('app.page', {
            path: '/:entry/:name/*',
            Component: __WEBPACK_EXTERNAL_MODULE__DynamicPage_mjs__.DynamicPage
        });
        this.app.usePageMode = usePageMode;
    }
    async afterLoad() {
        this.app.pluginContextMenu.add(pageMode.name, pageMode);
    }
}
const PageModeContext = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createContext({
    enable: false,
    setEnable: ()=>{}
});
const PageModeProvider = (param)=>{
    let { children } = param;
    const [enable, setEnable] = (0, __WEBPACK_EXTERNAL_MODULE_ahooks__.useLocalStorageState)('tb-page-mode', {
        defaultValue: false
    });
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(PageModeContext.Provider, {
        value: {
            enable,
            setEnable
        },
        children: children
    });
};
const usePageMode = ()=>__WEBPACK_EXTERNAL_MODULE_react__["default"].useContext(PageModeContext);
const pageMode = {
    name: 'pageMode',
    useLoadMethod: ()=>{
        const { enable, setEnable } = usePageMode();
        const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
        return {
            title: t('Page mode: {{enabled}}', {
                enabled: enable ? 'On' : 'Off'
            }),
            actionProps: {
                onClick: ()=>{
                    setEnable(!enable);
                }
            }
        };
    }
};
export { PageModeContext, PageModeProvider, PluginDynamicPage, usePageMode };
