import { useActiveEntities } from "../../store/active-entities.js";
import { handleHotKeyDown } from "../../libs/hot-keys.js";
import { useWorkspace } from "../../store/store.js";
import ModalClientContainer_default from "../../v2/components/modals/ModalClientContainer.vue.js";
import { createBlock, createVNode, defineComponent, onBeforeUnmount, onMounted, openBlock, unref, watch, withCtx } from "vue";
import { RouterView } from "vue-router";
//#region src/layouts/Modal/ApiClientModal.vue?vue&type=script&setup=true&lang.ts
var ApiClientModal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "ApiClientModal",
	setup(__props) {
		const { activeWorkspace } = useActiveEntities();
		const { modalState, events } = useWorkspace();
		/** Handles the hotkey events as well as custom config */
		const handleKeyDown = (ev) => handleHotKeyDown(ev, events.hotKeys, activeWorkspace.value?.hotKeyConfig);
		watch(() => modalState.open, (open) => {
			if (open) {
				window.addEventListener("keydown", handleKeyDown);
				document.documentElement.style.overflow = "hidden";
			} else {
				window.removeEventListener("keydown", handleKeyDown);
				document.documentElement.style.removeProperty("overflow");
			}
		});
		const onCloseModal = (event) => event?.closeModal && modalState.open && modalState.hide();
		onMounted(() => events.hotKeys.on(onCloseModal));
		onBeforeUnmount(() => {
			document.documentElement.style.removeProperty("overflow");
			events.hotKeys.off(onCloseModal);
		});
		return (_ctx, _cache) => {
			return openBlock(), createBlock(ModalClientContainer_default, { modalState: unref(modalState) }, {
				default: withCtx(() => [createVNode(unref(RouterView), { key: "$route.fullPath" })]),
				_: 1
			}, 8, ["modalState"]);
		};
	}
});
//#endregion
export { ApiClientModal_vue_vue_type_script_setup_true_lang_default as default };

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