import { useActiveEntities } from "../../store/active-entities.js";
import { useSidebar } from "../../hooks/useSidebar.js";
import { handleHotKeyDown } from "../../libs/hot-keys.js";
import { useWorkspace } from "../../store/store.js";
import MainLayout_default from "../App/MainLayout.vue.js";
import ImportCollectionListener_default from "../../components/ImportCollection/ImportCollectionListener.vue.js";
import { KeepAlive, computed, createBlock, createCommentVNode, createElementVNode, createVNode, defineComponent, onBeforeMount, onBeforeUnmount, onMounted, openBlock, resolveDynamicComponent, unref, watch, withCtx } from "vue";
import { ScalarTeleportRoot, addScalarClassesToHeadless } from "@scalar/components";
import { getThemeStyles } from "@scalar/themes";
import { useBreakpoints } from "@scalar/use-hooks/useBreakpoints";
import { useColorMode } from "@scalar/use-hooks/useColorMode";
import { ScalarToasts } from "@scalar/use-toasts";
import { RouterView } from "vue-router";
//#region src/layouts/Web/ApiClientWeb.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = ["innerHTML"];
var ApiClientWeb_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "ApiClientWeb",
	setup(__props) {
		useColorMode();
		const { activeWorkspace } = useActiveEntities();
		const { events } = useWorkspace();
		onBeforeMount(() => addScalarClassesToHeadless());
		/** Handles the hotkey events, we will pass in custom hotkeys here */
		const handleKeyDown = (ev) => handleHotKeyDown(ev, events.hotKeys);
		const handleHotKey = (event) => {
			if (!event) return;
			if (event.openCommandPalette) {
				event.openCommandPalette.preventDefault();
				events.commandPalette.emit();
			}
		};
		onMounted(() => {
			window.addEventListener("keydown", handleKeyDown);
			events.hotKeys.on(handleHotKey);
		});
		onBeforeUnmount(() => {
			window.removeEventListener("keydown", handleKeyDown);
			events.hotKeys.off(handleHotKey);
		});
		const { mediaQueries } = useBreakpoints();
		const { setSidebarOpen } = useSidebar();
		watch(mediaQueries.xl, setSidebarOpen, { immediate: true });
		const themeStyleTag = computed(() => activeWorkspace.value && `<style>${getThemeStyles(activeWorkspace.value?.themeId)}</style>`);
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(ScalarTeleportRoot), null, {
				default: withCtx(() => [createVNode(unref(ImportCollectionListener_default), null, {
					default: withCtx(() => [
						createElementVNode("div", { innerHTML: themeStyleTag.value }, null, 8, _hoisted_1),
						unref(activeWorkspace)?.uid ? (openBlock(), createBlock(MainLayout_default, { key: 0 }, {
							default: withCtx(() => [createVNode(unref(RouterView), null, {
								default: withCtx(({ Component }) => [(openBlock(), createBlock(KeepAlive, null, [(openBlock(), createBlock(resolveDynamicComponent(Component)))], 1024))]),
								_: 1
							})]),
							_: 1
						})) : createCommentVNode("", true),
						createVNode(unref(ScalarToasts))
					]),
					_: 1
				})]),
				_: 1
			});
		};
	}
});
//#endregion
export { ApiClientWeb_vue_vue_type_script_setup_true_lang_default as default };

//# sourceMappingURL=ApiClientWeb.vue.script.js.map