import { E as modalRoutes, _ as createApiClient, d as handleHotKeyDown, r as useWorkspace, w as useActiveEntities } from "./store-DpSUVhjp.js";
import { t as ModalClientContainer_default } from "./ModalClientContainer-qHsZi4wQ.js";
import { createBlock, createVNode, defineComponent, onBeforeUnmount, onMounted, openBlock, unref, watch, withCtx } from "vue";
import { RouterView, createMemoryHistory, createRouter } from "vue-router";
//#endregion
//#region src/layouts/Modal/ApiClientModal.vue
var ApiClientModal_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
//#region src/layouts/Modal/create-api-client-modal.ts
/**
* Initialize Scalar API Client Modal Sync
*
* This sync method does not include the spec, just sets up an empty workspace
*/
var createApiClientModal = ({ el = null, configuration = {}, mountOnInitialize = true, store }) => {
	const router = createRouter({
		history: createMemoryHistory(),
		routes: modalRoutes
	});
	return {
		client: createApiClient({
			el,
			appComponent: ApiClientModal_default,
			configuration,
			persistData: false,
			isReadOnly: true,
			mountOnInitialize,
			store,
			router,
			layout: "modal"
		}),
		router
	};
};
//#endregion
export { createApiClientModal as t };

//# sourceMappingURL=Modal-sQ9vH6MN.js.map