import { T as PathId, a as specDictionary, b as useClientConfig, i as createInitialRequest, r as useWorkspace, u as getModifiers, w as useActiveEntities } from "./store-DpSUVhjp.js";
import { a as useLayout, r as useSidebar } from "./useSidebar-DLTwHDI-.js";
import { n as usePluginManager } from "./plugins-B52hCIyZ.js";
import { a as ERRORS, t as createRequestOperation } from "./send-request-BsTfRiBC.js";
import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper-BmmBcIzD.js";
import { t as IconSelector_default } from "./IconSelector-BDC_GQXv.js";
import { t as HttpMethod_default } from "./HttpMethod-rnWEgC3T.js";
import { t as analytics } from "./analytics-BZimCWcw.js";
import "./CodeInput-C-igR77V.js";
import "./Server-DnA_BzPS.js";
import "./AddressBar-B4xnl66I.js";
import "./components-ChixwQhN.js";
import { t as Sidebar_default } from "./Sidebar-C6AdX6-N.js";
import { t as ScalarAsciiArt_default } from "./ScalarAsciiArt-BjuSnj8e.js";
import { n as rabbit_default, t as rabbitjump_default } from "./rabbitjump-CMZXAR6d.js";
import { n as SidebarListElementForm_default, t as DeleteSidebarListElement_default } from "./DeleteSidebarListElement-C-p87d03.js";
import { t as EditSidebarListElement_default } from "./EditSidebarListElement-CodWPnM6.js";
import { t as WorkspaceDropdown_default } from "./components-CSxJTn6F.js";
import { a as mutateSecuritySchemeDiff, i as mutateRequestDiff, o as mutateServerDiff, r as mutateCollectionDiff, s as mutateTagDiff, t as combineRenameDiffs } from "./watch-mode-Dbaqd9bG.js";
import { t as SidebarButton_default } from "./SidebarButton-BAagdMDe.js";
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, isRef, nextTick, normalizeClass, onBeforeUnmount, onMounted, openBlock, reactive, ref, renderList, renderSlot, resolveComponent, toDisplayString, unref, useCssVars, useId, vShow, watch, withCtx, withDirectives, withKeys, withModifiers } from "vue";
import { ScalarButton, ScalarDropdown, ScalarDropdownButton, ScalarDropdownDivider, ScalarDropdownItem, ScalarDropdownMenu, ScalarFloating, ScalarIcon, ScalarListboxCheckbox, ScalarModal, ScalarSearchResultItem, ScalarSearchResultList, ScalarSidebarGroupToggle, ScalarSidebarSearchInput, ScalarTextInput, ScalarTooltip, useModal } from "@scalar/components";
import { useToasts } from "@scalar/use-toasts";
import { RouterLink, RouterView, useRouter } from "vue-router";
import { LibraryIcon } from "@scalar/icons/library";
import { createHash, fetchDocument, isDefined, shouldIgnoreEntity } from "@scalar/oas-utils/helpers";
import { parseSchema } from "@scalar/oas-utils/transforms";
import { isDefined as isDefined$1 } from "@scalar/helpers/array/is-defined";
import { useTimeoutPoll } from "@vueuse/core";
import Fuse from "fuse.js";
import microdiff from "microdiff";
import { Draggable } from "@scalar/draggable";
import { safeJSON } from "@scalar/object-utils/parse";
//#region src/components/Sidebar/SidebarToggle.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$5 = ["aria-pressed"];
var _hoisted_2$5 = { class: "sr-only" };
var _hoisted_3$2 = {
	class: "size-4",
	fill: "none",
	viewBox: "0 0 24 24",
	xmlns: "http://www.w3.org/2000/svg"
};
var _hoisted_4$2 = { "clip-path": "url(#mask)" };
//#endregion
//#region src/components/Sidebar/SidebarToggle.vue
var SidebarToggle_default = /* @__PURE__ */ defineComponent({
	__name: "SidebarToggle",
	setup(__props) {
		const { isSidebarOpen, toggleSidebarOpen } = useSidebar();
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("button", {
				"aria-pressed": unref(isSidebarOpen),
				class: "scalar-sidebar-toggle text-c-3 hover:bg-b-2 active:text-c-1 rounded-lg p-2",
				type: "button",
				onClick: _cache[0] || (_cache[0] = (...args) => unref(toggleSidebarOpen) && unref(toggleSidebarOpen)(...args))
			}, [createElementVNode("span", _hoisted_2$5, toDisplayString(unref(isSidebarOpen) ? "Hide" : "Show") + " sidebar", 1), (openBlock(), createElementBlock("svg", _hoisted_3$2, [
				_cache[1] || (_cache[1] = createElementVNode("defs", null, [createElementVNode("clipPath", { id: "mask" }, [createElementVNode("path", {
					"clip-rule": "evenodd",
					d: "M9 3.2H4c-1.7 0-3 1.3-3 3v11.5c0 1.7 1.3 3 3 3h5V3.2z"
				})])], -1)),
				createElementVNode("g", _hoisted_4$2, [createElementVNode("path", {
					class: normalizeClass(["transition-transform duration-300", unref(isSidebarOpen) ? "translate-x-0" : "-translate-x-1/2"]),
					d: "M1 3.2h8v17.5H1z",
					fill: "currentColor"
				}, null, 2)]),
				_cache[2] || (_cache[2] = createElementVNode("path", {
					d: "M20 20.8H4c-1.7 0-3-1.3-3-3V6.2c0-1.7 1.3-3 3-3h16c1.7 0 3 1.3 3 3v11.5c0 1.7-1.3 3-3 3zM9 3.2v17.5",
					stroke: "currentColor",
					"stroke-linecap": "round",
					"stroke-linejoin": "round",
					"stroke-width": "2"
				}, null, -1))
			]))], 8, _hoisted_1$5);
		};
	}
});
//#endregion
//#region src/hooks/useAnalytics.ts
/** Gets the correct analytics client based on the layout. */
function useAnalytics() {
	const { layout } = useLayout();
	if (!useClientConfig().value.telemetry || layout === "modal") return;
	return analytics;
}
//#endregion
//#region src/libs/validate-parameters.ts
/**
* Validate required parameters from an example.
*
* Returns both the set of invalid parameter keys and a flag indicating
* if there are blocking errors (empty required path parameters) that
* should prevent the request from being sent.
*/
var validateParameters = (example) => {
	const result = {
		invalidParams: /* @__PURE__ */ new Set(),
		hasBlockingErrors: false
	};
	if (!example) return result;
	example.parameters?.path?.forEach((param) => {
		if (param.enabled && param.value.trim() === "") {
			result.invalidParams.add(param.key);
			result.hasBlockingErrors = true;
		}
	});
	[
		"query",
		"headers",
		"cookies"
	].forEach((paramType) => {
		example.parameters?.[paramType]?.forEach((param) => {
			if (param.required && param.value === "") result.invalidParams.add(param.key);
		});
	});
	return result;
};
//#endregion
//#region src/views/Request/hooks/useOpenApiWatcher.ts
/** Timeout for the watch mode polling */
var POLLING_INTERVAL = 5 * 1e3;
/** Pause for 60 seconds after an error */
var ERROR_TIMEOUT = 60 * 1e3;
/**
* Hook which handles polling the documentUrl for changes then attempts to merge what is new
*
* TODO:
* - check lastModified or similar headers
* - speed up the polling when there's a change then slowly slow it down
*/
var useOpenApiWatcher = () => {
	const { toast } = useToasts();
	const activeEntities = useActiveEntities();
	const store = useWorkspace();
	const { activeCollection, activeWorkspace } = activeEntities;
	const { collectionMutators } = store;
	/** Little toast helper */
	const toastError = (type) => toast(`[useOpenApiWatcher] Changes to the ${type} were not applied`, "error");
	const applyDiff = (d) => {
		if (d.path[0] === "info" || d.path[0] === "security") {
			if (!mutateCollectionDiff(d, activeEntities, store)) toastError("collection");
		} else if (d.path[0] === "components" && d.path[1] === "securitySchemes") {
			if (!mutateSecuritySchemeDiff(d, activeEntities, store)) toastError("securitySchemes");
		} else if (d.path[0] === "servers") {
			if (!mutateServerDiff(d, activeEntities, store)) toastError("servers");
		} else if (d.path[0] === "tags") {
			if (!mutateTagDiff(d, activeEntities, store)) toastError("tags");
		} else if (d.path[0] === "paths") {
			if (!mutateRequestDiff(d, activeEntities, store)) toastError("requests");
		}
	};
	const { pause, resume } = useTimeoutPoll(async () => {
		const url = activeCollection.value?.documentUrl;
		if (!url) return;
		const old = specDictionary[url];
		try {
			const spec = await fetchDocument(url, activeWorkspace.value?.proxyUrl, void 0, false);
			const hash = createHash(spec);
			collectionMutators.edit(activeCollection.value.uid, "watchModeStatus", "WATCHING");
			if (!old?.hash) {
				const { schema } = await parseSchema(spec);
				if (schema) specDictionary[url] = {
					hash,
					schema
				};
			} else if (old.hash && old.hash !== hash) {
				const { schema } = await parseSchema(spec);
				const combined = combineRenameDiffs(microdiff(old.schema, schema));
				try {
					combined.forEach(applyDiff);
					specDictionary[url] = {
						hash,
						schema
					};
				} catch (e) {
					console.error("[useOpenApiWatcher] Error:", e);
				}
			} else console.log("[useOpenApiWatcher] No changes detected yet…");
		} catch (e) {
			console.error("[useOpenApiWatcher] Error:", e);
			console.info("[useOpenApiWatcher] Pausing watcher for 60 seconds");
			pause();
			collectionMutators.edit(activeCollection.value.uid, "watchModeStatus", "ERROR");
			toast("[useOpenApiWatcher] Unable to fetch the spec file, paused the watcher for 60 seconds", "error");
			setTimeout(() => {
				console.info("[useOpenApiWatcher] Resuming watcher");
				resume();
			}, ERROR_TIMEOUT);
		}
	}, POLLING_INTERVAL);
	watch([() => activeCollection.value?.documentUrl, () => activeCollection.value?.watchMode], ([documentUrl, watchMode]) => {
		if (documentUrl && watchMode) {
			console.info(`[useOpenApiWatcher] Watching ${documentUrl} …`);
			resume();
		} else if (activeCollection.value) {
			pause();
			collectionMutators.edit(activeCollection.value.uid, "watchModeStatus", "IDLE");
		}
	}, { immediate: true });
};
//#endregion
//#region src/components/EnvironmentSelector/EnvironmentSelector.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$4 = { class: "m-0 flex items-center gap-1.5 font-medium whitespace-nowrap" };
var _hoisted_2$4 = { class: "flex h-4 w-4 items-center justify-center" };
//#endregion
//#region src/components/EnvironmentSelector/EnvironmentSelector.vue
var EnvironmentSelector_default = /* @__PURE__ */ defineComponent({
	__name: "EnvironmentSelector",
	setup(__props) {
		const { activeCollection, activeWorkspace, activeEnvironment } = useActiveEntities();
		const { collectionMutators } = useWorkspace();
		const { layout } = useLayout();
		const router = useRouter();
		const updateSelected = (uid) => {
			if (activeCollection.value && activeWorkspace.value) {
				collectionMutators.edit(activeCollection.value.uid, "x-scalar-active-environment", uid);
				activeWorkspace.value.activeEnvironmentId = uid;
			}
		};
		const redirectToEnvironments = () => router.push({
			name: "environment.default",
			params: { [PathId.Workspace]: activeWorkspace.value?.uid }
		});
		const selectedEnvironment = computed(() => {
			const { value: environment } = activeEnvironment;
			const { value: collection } = activeCollection;
			return environment?.name || collection?.["x-scalar-active-environment"] || "No Environment";
		});
		const availableEnvironments = computed(() => {
			const { value: collection } = activeCollection;
			const environments = collection?.["x-scalar-environments"];
			return environments ? Object.entries(environments).map(([key, env]) => ({
				...env,
				uid: key,
				name: key
			})) : [];
		});
		const selectLatestEnvironment = () => {
			const environments = availableEnvironments.value;
			if (environments.length > 0) {
				const latestEnvironment = environments[environments.length - 1];
				if (latestEnvironment?.uid) updateSelected(latestEnvironment.uid);
			}
		};
		watch(availableEnvironments, (newEnvs, oldEnvs) => {
			if (newEnvs.length > oldEnvs.length) selectLatestEnvironment();
		});
		const setInitialEnvironment = (collection) => {
			const activeEnv = collection["x-scalar-active-environment"];
			if (activeEnv && activeCollection.value && activeWorkspace.value) {
				activeCollection.value["x-scalar-active-environment"] = activeEnv;
				activeWorkspace.value.activeEnvironmentId = activeEnv;
			} else if (activeWorkspace.value) activeWorkspace.value.activeEnvironmentId = "";
		};
		watch(activeCollection, (newCollection) => newCollection && setInitialEnvironment(newCollection));
		onMounted(() => {
			activeCollection.value && setInitialEnvironment(activeCollection.value);
		});
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(ScalarDropdown), { teleport: "" }, {
				items: withCtx(() => [
					(openBlock(true), createElementBlock(Fragment, null, renderList(availableEnvironments.value, (environment) => {
						return openBlock(), createBlock(unref(ScalarDropdownItem), {
							key: environment.uid,
							class: "group/item flex items-center gap-1.5 overflow-hidden text-ellipsis whitespace-nowrap",
							onClick: withModifiers(($event) => updateSelected(environment.uid), ["stop"])
						}, {
							default: withCtx(() => [createVNode(unref(ScalarListboxCheckbox), { selected: unref(activeCollection)?.["x-scalar-active-environment"] === environment.uid }, null, 8, ["selected"]), createTextVNode(" " + toDisplayString(environment.name), 1)]),
							_: 2
						}, 1032, ["onClick"]);
					}), 128)),
					createVNode(unref(ScalarDropdownItem), {
						class: "group/item flex items-center gap-1.5 overflow-hidden text-ellipsis whitespace-nowrap",
						onClick: _cache[0] || (_cache[0] = withModifiers(($event) => updateSelected(""), ["stop"]))
					}, {
						default: withCtx(() => [createVNode(unref(ScalarListboxCheckbox), { selected: unref(activeEnvironment)?.uid === "" && unref(activeCollection)?.["x-scalar-active-environment"] === "" || unref(activeEnvironment)?.name === "No Environment" }, null, 8, ["selected"]), _cache[1] || (_cache[1] = createTextVNode(" No Environment ", -1))]),
						_: 1
					}),
					createVNode(unref(ScalarDropdownDivider)),
					unref(layout) !== "modal" ? (openBlock(), createBlock(unref(ScalarDropdownItem), {
						key: 0,
						class: "flex items-center gap-1.5",
						onClick: redirectToEnvironments
					}, {
						default: withCtx(() => [createElementVNode("div", _hoisted_2$4, [createVNode(unref(ScalarIcon), {
							icon: "Brackets",
							size: "sm"
						})]), _cache[2] || (_cache[2] = createElementVNode("span", { class: "leading-none" }, "Manage Environments", -1))]),
						_: 1
					})) : createCommentVNode("", true)
				]),
				default: withCtx(() => [createVNode(unref(ScalarButton), {
					class: "text-c-1 hover:bg-b-2 line-clamp-1 h-auto w-fit justify-start px-1.5 py-1.5 font-normal",
					variant: "ghost"
				}, {
					default: withCtx(() => [createElementVNode("h2", _hoisted_1$4, toDisplayString(selectedEnvironment.value), 1)]),
					_: 1
				})]),
				_: 1
			});
		};
	}
});
//#endregion
//#region src/components/Search/useSearch.ts
/**
* Hook for managing search functionality.
* Provides search state, results, and methods for searching.
*/
function useSearch() {
	const router = useRouter();
	const { activeWorkspace, activeWorkspaceRequests, activeWorkspaceCollections } = useActiveEntities();
	const { requests, tags } = useWorkspace();
	const fuseDataArray = ref([]);
	const searchResults = ref([]);
	const selectedSearchResult = ref(0);
	const searchText = ref("");
	const searchInputRef = ref(null);
	const searchResultRefs = ref([]);
	const fuse = new Fuse(fuseDataArray.value, { keys: [
		"title",
		"description",
		"body"
	] });
	const resetSearch = () => {
		searchText.value = "";
		selectedSearchResult.value = 0;
		searchResults.value = [];
		if (searchInputRef.value instanceof HTMLInputElement) searchInputRef.value.blur();
	};
	const populateFuseDataArray = (items) => {
		fuseDataArray.value = items.filter((request) => !shouldIgnoreEntity(request)).filter((request) => {
			const collection = activeWorkspaceCollections.value?.find((activeWorkspaceCollection) => activeWorkspaceCollection.requests.includes(request.uid));
			return !Boolean(collection?.tags.map((uid) => tags[uid]).filter(isDefined).filter((tag) => request.tags?.includes(tag.name)).filter((tag) => shouldIgnoreEntity(tag)).length);
		}).map((request) => ({
			id: request.uid,
			title: request.summary ?? request.method,
			description: request.description ?? "",
			httpVerb: request.method,
			path: request.path,
			link: router?.resolve({
				name: "request",
				params: {
					[PathId.Request]: request.uid,
					[PathId.Workspace]: activeWorkspace.value?.uid
				}
			})?.href
		}));
		fuse.setCollection(fuseDataArray.value);
	};
	const fuseSearch = () => {
		selectedSearchResult.value = 0;
		searchResults.value = fuse.search(searchText.value);
	};
	watch(searchText, (newValue) => {
		if (newValue.length) fuseSearch();
		else searchResults.value = [];
	});
	const navigateSearchResults = (direction) => {
		const offset = direction === "up" ? -1 : 1;
		const length = searchResultsWithPlaceholderResults.value.length;
		selectedSearchResult.value = (selectedSearchResult.value + offset + length) % length;
		nextTick(() => {
			const element = searchResultRefs.value[selectedSearchResult.value];
			if (element instanceof HTMLElement) element.scrollIntoView({
				behavior: "smooth",
				block: "center"
			});
		});
	};
	const selectSearchResult = () => {
		if (selectedSearchResult.value >= 0) {
			const selectedResult = searchResultsWithPlaceholderResults.value[selectedSearchResult.value];
			if (selectedResult) onSearchResultClick(selectedResult);
		}
	};
	const validRequests = computed(() => activeWorkspaceRequests.value.map((uid) => requests[uid]).filter(isDefined));
	watch(activeWorkspaceRequests, () => {
		populateFuseDataArray(validRequests.value);
	}, { immediate: true });
	const onSearchResultClick = (entry) => {
		router.push(entry.item.id);
		resetSearch();
	};
	const searchResultsWithPlaceholderResults = computed(() => {
		if (searchText.value.length === 0) return fuseDataArray.value.map((item) => {
			return { item };
		});
		return searchResults.value;
	});
	return {
		searchText,
		searchResultsWithPlaceholderResults,
		selectedSearchResult,
		onSearchResultClick,
		fuseSearch,
		searchInputRef,
		searchResultRefs,
		navigateSearchResults,
		selectSearchResult,
		populateFuseDataArray
	};
}
//#endregion
//#region src/views/Request/handle-drag.ts
/** Create DnD handlers */
function dragHandlerFactory(activeWorkspace, { collections, collectionMutators, tags, tagMutators, workspaceMutators }) {
	const { layout } = useLayout();
	/** Mutate tag OR collection */
	const mutateTagOrCollection = (parent, childUids) => {
		if (parent.type === "collection") collectionMutators.edit(parent.uid, "children", childUids);
		else if (parent.type === "tag") tagMutators.edit(parent.uid, "children", childUids);
	};
	/** Drag handler that mutates depending on the entity types */
	const handleDragEnd = (draggingItem, hoveredItem) => {
		if (!draggingItem || !hoveredItem) return;
		const { id: draggingUid, parentId: draggingParentUid } = draggingItem;
		const { id: hoveredUid, parentId: hoveredParentUid, offset } = hoveredItem;
		if (!draggingParentUid) workspaceMutators.edit(activeWorkspace.value?.uid, "collections", activeWorkspace.value?.collections.filter((uid) => uid !== draggingUid) ?? []);
		else if (collections[draggingParentUid]) collectionMutators.edit(draggingParentUid, "children", collections[draggingParentUid].children.filter((uid) => uid !== draggingUid));
		else if (tags[draggingParentUid]) tagMutators.edit(draggingParentUid, "children", tags[draggingParentUid].children.filter((uid) => uid !== draggingUid));
		if (offset === 2) {
			const parent = collections[hoveredUid] || tags[hoveredUid];
			if (parent) mutateTagOrCollection(parent, [...parent.children ?? [], draggingUid]);
		} else if (!hoveredParentUid) {
			const newChildUids = [...activeWorkspace.value?.collections ?? []];
			const hoveredIndex = newChildUids.findIndex((uid) => hoveredUid === uid) ?? 0;
			newChildUids.splice(hoveredIndex + offset, 0, draggingUid);
			workspaceMutators.edit(activeWorkspace.value?.uid, "collections", newChildUids);
		} else {
			const parent = collections[hoveredParentUid] || tags[hoveredParentUid];
			if (!parent) return;
			const newChildUids = [...parent.children ?? []];
			const hoveredIndex = newChildUids.findIndex((uid) => hoveredUid === uid) ?? 0;
			newChildUids.splice(hoveredIndex + offset, 0, draggingUid);
			mutateTagOrCollection(parent, newChildUids);
		}
	};
	/** Ensure only collections are allowed at the top level OR resources dropped INTO (offset 2) */
	const isDroppable = (draggingItem, hoveredItem) => {
		if (layout === "modal") return false;
		if (!collections[draggingItem.id] && hoveredItem.offset !== 2) return false;
		if (collections[draggingItem.id] && collections[hoveredItem.id]?.info?.title === "Drafts") return false;
		return true;
	};
	return {
		handleDragEnd,
		isDroppable
	};
}
//#endregion
//#region src/components/Sidebar/Actions/EditSidebarListCollection.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$3 = { class: "grid grid-cols-[auto_1fr] gap-2" };
var _hoisted_2$3 = { class: "flex aspect-square" };
//#endregion
//#region src/components/Sidebar/Actions/EditSidebarListCollection.vue
var EditSidebarListCollection_default = /* @__PURE__ */ defineComponent({
	__name: "EditSidebarListCollection",
	props: {
		name: {},
		icon: {}
	},
	emits: ["close", "edit"],
	setup(__props, { emit: __emit }) {
		const props = __props;
		const emit = __emit;
		const newName = ref(props.name);
		const newIcon = ref(props.icon);
		return (_ctx, _cache) => {
			return openBlock(), createBlock(SidebarListElementForm_default, {
				onCancel: _cache[2] || (_cache[2] = ($event) => emit("close")),
				onSubmit: _cache[3] || (_cache[3] = ($event) => emit("edit", newName.value, newIcon.value))
			}, {
				default: withCtx(() => [createElementVNode("div", _hoisted_1$3, [createElementVNode("div", _hoisted_2$3, [createVNode(IconSelector_default, {
					modelValue: newIcon.value,
					"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => newIcon.value = $event),
					placement: "bottom-start"
				}, {
					default: withCtx(() => [createVNode(unref(ScalarButton), {
						class: "aspect-square h-auto px-0",
						variant: "outlined"
					}, {
						default: withCtx(() => [createVNode(unref(LibraryIcon), {
							class: "text-c-2 size-4",
							src: newIcon.value
						}, null, 8, ["src"])]),
						_: 1
					})]),
					_: 1
				}, 8, ["modelValue"])]), createVNode(unref(ScalarTextInput), {
					modelValue: newName.value,
					"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => newName.value = $event),
					autofocus: "",
					class: "flex-1"
				}, null, 8, ["modelValue"])])]),
				_: 1
			});
		};
	}
});
//#endregion
//#region src/views/Request/RequestSidebarItemMenu.vue
var RequestSidebarItemMenu_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "RequestSidebarItemMenu",
	props: { menuItem: {} },
	emits: [
		"closeMenu",
		"toggleWatchMode",
		"clearDrafts"
	],
	setup(__props, { emit: __emit }) {
		const props = __props;
		const emit = __emit;
		const { replace } = useRouter();
		const { activeRouterParams, activeWorkspaceCollections, activeWorkspaceRequests } = useActiveEntities();
		const { events, requestMutators } = useWorkspace();
		const editModal = useModal();
		const deleteModal = useModal();
		const clearDraftsModal = useModal();
		/** Add example */
		const handleAddExample = () => events.commandPalette.emit({
			commandName: "Add Example",
			metaData: { itemUid: props.menuItem.item?.entity.uid }
		});
		const handleEdit = (newName, newIcon) => {
			props.menuItem.item?.edit(newName, newIcon);
			editModal.hide();
		};
		/** Delete with redirect for both requests and requestExamples */
		const handleItemDelete = () => {
			props.menuItem.item?.delete();
			if (!activeWorkspaceRequests.value.length) {
				const { request } = createInitialRequest();
				const draftCollection = activeWorkspaceCollections.value.find((collection) => collection.info?.title === "Drafts");
				if (draftCollection) {
					requestMutators.add(request, draftCollection.uid);
					replace({
						name: "request",
						params: { [PathId.Request]: request.uid }
					});
				}
			}
			if (activeRouterParams.value[PathId.Request] === props.menuItem.item?.entity.uid) replace({
				name: "request",
				params: { [PathId.Request]: "default" }
			});
			if (activeRouterParams.value[PathId.Examples] === props.menuItem.item?.entity.uid) replace({
				name: "request",
				params: { [PathId.Request]: "default" }
			});
			if (activeWorkspaceCollections.value[0]) {
				const firstRequest = activeWorkspaceCollections.value[0].requests[0];
				replace({
					name: "request",
					params: { [PathId.Request]: firstRequest }
				});
			}
			deleteModal.hide();
		};
		const menuRef = ref(null);
		watch([() => props.menuItem.open, menuRef], ([open]) => {
			if (open && menuRef.value?.$parent?.$el) menuRef.value.$parent.$el.focus();
		});
		const globalClickListener = () => props.menuItem.open && emit("closeMenu");
		onMounted(() => window.addEventListener("click", globalClickListener));
		onBeforeUnmount(() => window.removeEventListener("click", globalClickListener));
		const toggleWatchMode = () => {
			emit("toggleWatchMode", props.menuItem.item);
		};
		const handleClearDrafts = () => {
			emit("clearDrafts");
			clearDraftsModal.hide();
		};
		const isDraftsMenuItem = computed(() => {
			return props.menuItem.item?.title === "Drafts";
		});
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock(Fragment, null, [
				__props.menuItem.targetRef && __props.menuItem.open ? (openBlock(), createBlock(unref(ScalarFloating), {
					key: 0,
					placement: "right-start",
					target: __props.menuItem.targetRef,
					teleport: ""
				}, {
					floating: withCtx(() => [createVNode(unref(ScalarDropdownMenu), { onKeydown: _cache[3] || (_cache[3] = withKeys(($event) => _ctx.$emit("closeMenu"), ["escape"])) }, {
						default: withCtx(() => [
							__props.menuItem.item?.entity.type === "request" ? (openBlock(), createBlock(unref(ScalarDropdownButton), {
								key: 0,
								class: "flex items-center gap-2",
								onClick: handleAddExample
							}, {
								default: withCtx(() => [createVNode(unref(ScalarIcon), {
									class: "inline-flex",
									icon: "Example",
									size: "md",
									thickness: "1.5"
								}), _cache[8] || (_cache[8] = createElementVNode("span", null, "Add Example", -1))]),
								_: 1
							})) : createCommentVNode("", true),
							!isDraftsMenuItem.value ? (openBlock(), createBlock(unref(ScalarDropdownButton), {
								key: 1,
								ref_key: "menuRef",
								ref: menuRef,
								class: "flex items-center gap-2",
								onClick: _cache[0] || (_cache[0] = ($event) => unref(editModal).show())
							}, {
								default: withCtx(() => [createVNode(unref(ScalarIcon), {
									class: "inline-flex",
									icon: "Edit",
									size: "md",
									thickness: "1.5"
								}), createElementVNode("span", null, [__props.menuItem.item?.entity.type === "collection" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createTextVNode(" Edit ")], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(" Rename ")], 64))])]),
								_: 1
							}, 512)) : createCommentVNode("", true),
							__props.menuItem.item?.documentUrl ? (openBlock(), createBlock(unref(ScalarDropdownButton), {
								key: 2,
								ref_key: "menuRef",
								ref: menuRef,
								class: "flex items-center gap-2",
								onClick: toggleWatchMode
							}, {
								default: withCtx(() => [createVNode(unref(ScalarIcon), {
									class: "inline-flex",
									icon: __props.menuItem.item?.watchMode ? "Unwatch" : "Watch",
									size: "md",
									thickness: "1.5"
								}, null, 8, ["icon"]), createElementVNode("span", null, toDisplayString(__props.menuItem.item?.watchMode ? "Disable Watch Mode" : "Enable Watch Mode"), 1)]),
								_: 1
							}, 512)) : createCommentVNode("", true),
							!isDraftsMenuItem.value ? (openBlock(), createBlock(unref(ScalarDropdownButton), {
								key: 3,
								class: "flex items-center gap-2",
								onClick: _cache[1] || (_cache[1] = ($event) => unref(deleteModal).show())
							}, {
								default: withCtx(() => [createVNode(unref(ScalarIcon), {
									class: "inline-flex",
									icon: "Delete",
									size: "md",
									thickness: "1.5"
								}), _cache[9] || (_cache[9] = createElementVNode("span", null, "Delete", -1))]),
								_: 1
							})) : createCommentVNode("", true),
							isDraftsMenuItem.value ? (openBlock(), createBlock(unref(ScalarDropdownButton), {
								key: 4,
								class: "flex items-center gap-2",
								onClick: _cache[2] || (_cache[2] = ($event) => unref(clearDraftsModal).show())
							}, {
								default: withCtx(() => [createVNode(unref(ScalarIcon), {
									class: "inline-flex",
									icon: "Delete",
									size: "md",
									thickness: "1.5"
								}), _cache[10] || (_cache[10] = createElementVNode("span", null, "Clear Drafts", -1))]),
								_: 1
							})) : createCommentVNode("", true)
						]),
						_: 1
					})]),
					_: 1
				}, 8, ["target"])) : createCommentVNode("", true),
				createVNode(unref(ScalarModal), {
					size: "xxs",
					state: unref(deleteModal),
					title: `Delete ${__props.menuItem.item?.resourceTitle}`
				}, {
					default: withCtx(() => [createVNode(DeleteSidebarListElement_default, {
						variableName: __props.menuItem.item?.title ?? "",
						warningMessage: __props.menuItem.item?.warning,
						onClose: _cache[4] || (_cache[4] = ($event) => unref(deleteModal).hide()),
						onDelete: handleItemDelete
					}, null, 8, ["variableName", "warningMessage"])]),
					_: 1
				}, 8, ["state", "title"]),
				createVNode(unref(ScalarModal), {
					size: "xxs",
					state: unref(editModal),
					title: `Edit ${__props.menuItem.item?.resourceTitle}`
				}, {
					default: withCtx(() => [__props.menuItem.item?.resourceTitle === "Collection" ? (openBlock(), createBlock(EditSidebarListCollection_default, {
						key: 0,
						icon: __props.menuItem.item?.icon || "interface-content-folder",
						name: __props.menuItem.item?.title,
						onClose: _cache[5] || (_cache[5] = ($event) => unref(editModal).hide()),
						onEdit: handleEdit
					}, null, 8, ["icon", "name"])) : (openBlock(), createBlock(EditSidebarListElement_default, {
						key: 1,
						name: __props.menuItem.item?.title ?? "",
						onClose: _cache[6] || (_cache[6] = ($event) => unref(editModal).hide()),
						onEdit: handleEdit
					}, null, 8, ["name"]))]),
					_: 1
				}, 8, ["state", "title"]),
				createVNode(unref(ScalarModal), {
					size: "xxs",
					state: unref(clearDraftsModal),
					title: "Clear Drafts"
				}, {
					default: withCtx(() => [createVNode(DeleteSidebarListElement_default, {
						variableName: "All Drafts",
						warningMessage: "This action will clear all drafts. This cannot be undone.",
						onClose: _cache[7] || (_cache[7] = ($event) => unref(clearDraftsModal).hide()),
						onDelete: handleClearDrafts
					})]),
					_: 1
				}, 8, ["state"])
			], 64);
		};
	}
}), [["__scopeId", "data-v-01a1ab71"]]);
//#endregion
//#region src/views/Request/RequestSection/helpers/getting-started.ts
/**
* Checks if the user gets the getting started state displayed
*/
var isGettingStarted = (activeWorkspaceCollections, activeWorkspaceRequests, requests) => {
	const draftCollection = activeWorkspaceCollections.find((collection) => collection.info?.title === "Drafts");
	const hasSingleRequest = activeWorkspaceRequests.length === 1;
	if (!activeWorkspaceRequests[0]) return false;
	const isDraftsRequest = draftCollection?.requests.includes(activeWorkspaceRequests[0]);
	if (!isDraftsRequest) return false;
	const isRenamed = requests[draftCollection?.requests[0] ?? ""]?.summary !== "My First Request";
	return hasSingleRequest && isDraftsRequest && !isRenamed;
};
//#endregion
//#region src/views/Request/RequestSidebarItem.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$2 = { class: "line-clamp-1 w-full pl-2 break-all" };
var _hoisted_2$2 = { class: "flex flex-row items-center gap-1" };
var _hoisted_3$1 = { class: "relative" };
var _hoisted_4$1 = { class: "flex items-start" };
var _hoisted_5$1 = { class: "flex h-5 max-w-[14px] shrink-0 items-center justify-center" };
var _hoisted_6$1 = { class: "flex flex-1 flex-row justify-between font-medium" };
var _hoisted_7$1 = { class: "line-clamp-1 w-full text-left break-all" };
var _hoisted_8$1 = { class: "relative flex h-fit items-center justify-end gap-0.5" };
var _hoisted_9 = {
	class: "flex items-center justify-center",
	type: "button"
};
var _hoisted_10 = ["aria-expanded"];
var _hoisted_11 = { class: "flex h-5 max-w-[14px] shrink-0 items-center justify-center" };
var _hoisted_12 = { class: "flex flex-1 flex-row justify-between" };
var _hoisted_13 = { class: "line-clamp-1 w-full text-left font-medium break-all" };
var _hoisted_14 = { class: "relative flex h-fit items-center justify-end gap-0.5" };
var _hoisted_15 = {
	class: "flex items-center justify-center",
	type: "button"
};
var _hoisted_16 = { key: 3 };
var highlightClasses = "hover:bg-sidebar-b-active indent-padding-left";
//#endregion
//#region src/views/Request/RequestSidebarItem.vue
var RequestSidebarItem_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "RequestSidebarItem",
	props: {
		isDraggable: {
			type: Boolean,
			default: false
		},
		isDroppable: {
			type: [Boolean, Function],
			default: false
		},
		parentUids: {},
		uid: {},
		menuItem: {}
	},
	emits: [
		"onDragEnd",
		"newTab",
		"openMenu"
	],
	setup(__props, { emit: __emit }) {
		useCssVars((_ctx) => ({
			"v2bb71a6d": leftOffset.value,
			"b961af9e": paddingOffset.value
		}));
		const emit = __emit;
		const { activeCollection, activeRequest, activeRouterParams, activeWorkspace } = useActiveEntities();
		const { collections, tags, requests, requestExamples, collectionMutators, tagMutators, requestMutators, requestExampleMutators, events } = useWorkspace();
		const router = useRouter();
		const { collapsedSidebarFolders, toggleSidebarFolder } = useSidebar();
		const { layout } = useLayout();
		/** Normalize properties across different types for easy consumption */
		const item = computed(() => {
			const collection = collections[__props.uid];
			const tag = tags[__props.uid];
			const request = requests[__props.uid];
			const requestExample = requestExamples[__props.uid];
			if (collection) return {
				title: collection.info?.title || "Untitled Collection",
				entity: collection,
				resourceTitle: "Collection",
				children: collection.children,
				icon: collection["x-scalar-icon"],
				documentUrl: collection.documentUrl,
				watchMode: collection.watchMode,
				to: collection.uid && collection?.info?.title !== "Drafts" ? {
					name: "collection",
					params: {
						[PathId.Workspace]: activeWorkspace.value?.uid,
						[PathId.Collection]: collection.uid
					}
				} : void 0,
				warning: "This cannot be undone. You're about to delete the collection and all folders and requests inside it.",
				edit: (name, icon) => {
					collectionMutators.edit(collection.uid, "info.title", name);
					if (icon) collectionMutators.edit(collection.uid, "x-scalar-icon", icon);
				},
				delete: () => {
					if (activeWorkspace.value) collectionMutators.delete(collection, activeWorkspace.value);
				}
			};
			if (tag) return {
				title: tag.name,
				entity: tag,
				resourceTitle: "Tag",
				children: tag.children,
				warning: "This cannot be undone. You're about to delete the tag and all requests inside it",
				edit: (name) => tagMutators.edit(tag.uid, "name", name),
				delete: () => __props.parentUids[0] && tagMutators.delete(tag, __props.parentUids[0])
			};
			if (request) return {
				title: request.summary ?? request.path,
				to: {
					name: "request",
					params: {
						workspace: activeWorkspace.value?.uid,
						request: request.uid
					}
				},
				method: request.method,
				entity: request,
				resourceTitle: "Request",
				warning: "This cannot be undone. You're about to delete the request.",
				children: request.examples.slice(1),
				edit: (name) => requestMutators.edit(request.uid, "summary", name),
				delete: () => __props.parentUids[0] && requestMutators.delete(request, __props.parentUids[0])
			};
			if (requestExample?.requestUid) return {
				title: requestExample.name,
				to: {
					name: "request.examples",
					params: {
						workspace: activeWorkspace.value?.uid,
						request: requestExample.requestUid,
						examples: requestExample.uid
					}
				},
				method: requests[requestExample.requestUid]?.method,
				entity: requestExample,
				resourceTitle: "Example",
				warning: "This cannot be undone. You're about to delete the example from the request.",
				children: [],
				edit: (name) => requestExampleMutators.edit(requestExample.uid, "name", name),
				delete: () => requestExampleMutators.delete(requestExample)
			};
			return {
				title: "Unknown",
				entity: {
					uid: "",
					type: "unknown"
				},
				resourceTitle: "Unknown",
				children: [],
				edit: () => null,
				delete: () => null
			};
		});
		/** Checks to see if it is a draft collection with the title of Drafts */
		const isDraftCollection = computed(() => item.value.entity.type === "collection" && item.value.title === "Drafts");
		const leftOffset = computed(() => {
			if (!__props.parentUids.length) return "12px";
			if (layout === "modal") return `${(__props.parentUids.length - 1) * 12}px`;
			return `${__props.parentUids.length * 12}px`;
		});
		const paddingOffset = computed(() => {
			if (!__props.parentUids.length) return "0px";
			if (layout === "modal") return `${(__props.parentUids.length - 1) * 12}px`;
			return `${__props.parentUids.length * 12}px`;
		});
		/**
		* Show folders if they are open,
		* show examples if there are more than one and the request is active
		*/
		const showChildren = computed(() => collapsedSidebarFolders[__props.uid] || activeRequest.value?.uid === __props.uid && item.value.entity.examples.length > 1);
		/** Since we have exact routing, we should check if the default request is active */
		const isDefaultActive = computed(() => typeof router.currentRoute.value.name === "string" && router.currentRoute.value.name.startsWith("request") && activeRouterParams.value[PathId.Request] === "default" && activeRequest.value?.uid === __props.uid);
		/** The draggable component */
		const draggableRef = ref(null);
		/** Calculate offsets which change a little depending on whats being dragged and hovered over */
		const getDraggableOffsets = computed(() => {
			let ceiling = .5;
			let floor = .5;
			if (!draggableRef.value) return {
				ceiling,
				floor
			};
			const { draggingItem } = draggableRef.value;
			if (!collections[draggingItem?.id] && item.value.entity.type === "collection") {
				ceiling = 1;
				floor = 0;
			} else if (item.value.entity.type === "tag") {
				ceiling = .8;
				floor = .2;
			}
			return {
				ceiling,
				floor
			};
		});
		/** Guard to check if an element is able to be dropped on */
		const _isDroppable = (draggingItem, hoveredItem) => {
			if (layout === "modal") return false;
			if (requestExamples[hoveredItem.id]) return false;
			if (collections[draggingItem.id]) return false;
			return true;
		};
		const handleNavigation = (event, _item) => {
			if (event) {
				if (getModifiers(["default"]).some((key) => event[key])) emit("newTab", _item.title || "", _item.entity.uid);
				else if (_item.to) router.push(_item.to);
				nextTick(() => events.focusAddressBar.emit());
			}
		};
		function addRequest(entityUid) {
			const collectionUid = __props.parentUids[0] ? collections[__props.parentUids[0]]?.uid || "" : entityUid;
			const requestData = __props.parentUids[0] && tags[entityUid]?.name ? { tags: [tags[entityUid].name] } : {};
			const newRequest = requestMutators.add(requestData, collectionUid);
			if (newRequest) {
				router.push({
					name: "request",
					params: {
						workspace: activeWorkspace.value?.uid,
						request: newRequest.uid
					}
				});
				events.hotKeys.emit({ focusAddressBar: new KeyboardEvent("keydown", { key: "l" }) });
			}
		}
		const watchIconColor = computed(() => {
			const { uid: _uid, watchModeStatus } = activeCollection.value || {};
			if (_uid !== item.value.entity.uid) return "text-c-3";
			if (watchModeStatus === "WATCHING") return "text-c-1";
			if (watchModeStatus === "ERROR") return "text-red";
			return "text-c-3";
		});
		const hasDraftRequests = computed(() => {
			return item.value.title === "Drafts" && layout !== "modal" && item.value.children.length > 0;
		});
		/**
		* Check if the item should be shown.
		* This is used to hide items that are marked as hidden/internal.
		*/
		const shouldShowItem = computed(() => {
			const request = requests[__props.uid];
			if (request) return !shouldIgnoreEntity(request);
			const tag = tags[__props.uid];
			if (tag) return !shouldIgnoreEntity(tag);
			return true;
		});
		return (_ctx, _cache) => {
			const _component_RequestSidebarItem = resolveComponent("RequestSidebarItem", true);
			return shouldShowItem.value ? (openBlock(), createElementBlock("li", {
				key: 0,
				class: normalizeClass(["relative flex flex-row", [unref(layout) === "modal" && __props.parentUids.length > 1 || unref(layout) !== "modal" && __props.parentUids.length ? "before:bg-border indent-border-line-offset mb-[.5px] before:pointer-events-none before:absolute before:top-0 before:left-[calc(.75rem_+_.5px)] before:z-1 before:h-[calc(100%_+_.5px)] before:w-[.5px] last:mb-0 last:before:h-full" : ""]])
			}, [createVNode(unref(Draggable), {
				id: item.value.entity.uid,
				ref_key: "draggableRef",
				ref: draggableRef,
				ceiling: getDraggableOffsets.value.ceiling,
				class: "gap-1/2 flex flex-1 flex-col text-base/5",
				floor: getDraggableOffsets.value.floor,
				isDraggable: __props.isDraggable,
				isDroppable: __props.isDroppable,
				parentIds: __props.parentUids,
				onOnDragEnd: _cache[13] || (_cache[13] = (...args) => _ctx.$emit("onDragEnd", ...args))
			}, {
				default: withCtx(() => [(item.value.entity.type === "request" || item.value.entity.type === "requestExample") && item.value.to ? (openBlock(), createBlock(unref(RouterLink), {
					key: 0,
					class: "group no-underline",
					to: item.value.to,
					onClick: _cache[1] || (_cache[1] = withModifiers((event) => handleNavigation(event, item.value), ["prevent"]))
				}, {
					default: withCtx(({ isExactActive }) => [createElementVNode("div", { class: normalizeClass(["relative flex min-h-8 w-full cursor-pointer flex-row items-start justify-between gap-0.5 rounded py-1.5 pr-2", [highlightClasses, isExactActive || isDefaultActive.value ? "bg-sidebar-b-active text-sidebar-c-active font-medium transition-none" : "text-sidebar-c-2"]]) }, [createElementVNode("span", _hoisted_1$2, toDisplayString(item.value.title || "Untitled"), 1), createElementVNode("div", _hoisted_2$2, [createElementVNode("div", _hoisted_3$1, [unref(layout) !== "modal" ? (openBlock(), createBlock(unref(ScalarButton), {
						key: 0,
						class: normalizeClass(["hover:bg-b-3 hidden aspect-square h-fit px-0.5 py-0 opacity-0 group-hover:flex group-hover:opacity-100 group-focus-visible:opacity-100 group-has-[:focus-visible]:opacity-100", { flex: __props.menuItem?.item?.entity.uid === item.value.entity.uid && __props.menuItem.open }]),
						size: "sm",
						type: "button",
						variant: "ghost",
						onClick: _cache[0] || (_cache[0] = withModifiers((ev) => _ctx.$emit("openMenu", {
							item: item.value,
							parentUids: __props.parentUids,
							targetRef: ev.currentTarget,
							open: !__props.menuItem.open
						}), ["stop", "prevent"]))
					}, {
						default: withCtx(() => [createVNode(unref(ScalarIcon), {
							icon: "Ellipses",
							size: "md"
						})]),
						_: 1
					}, 8, ["class"])) : createCommentVNode("", true)]), createElementVNode("span", _hoisted_4$1, [
						_cache[14] || (_cache[14] = createTextVNode("   ", -1)),
						_cache[15] || (_cache[15] = createElementVNode("span", { class: "sr-only" }, "HTTP Method:", -1)),
						item.value.method ? (openBlock(), createBlock(unref(HttpMethod_default), {
							key: 0,
							class: "font-bold",
							method: item.value.method
						}, null, 8, ["method"])) : createCommentVNode("", true)
					])])], 2)]),
					_: 1
				}, 8, ["to"])) : (unref(layout) !== "modal" || __props.parentUids.length) && item.value.entity.type === "collection" && item.value.to ? (openBlock(), createBlock(unref(RouterLink), {
					key: 1,
					"aria-expanded": Boolean(unref(collapsedSidebarFolders)[item.value.entity.uid]),
					class: normalizeClass(["hover:bg-b-2 group relative flex w-full flex-row justify-start gap-1.5 rounded p-1.5 no-underline focus-visible:z-10", [highlightClasses, {
						"bg-sidebar-b-active text-sidebar-c-active transition-none": typeof unref(router).currentRoute.value.name === "string" && unref(router).currentRoute.value.name.startsWith("collection") && unref(router).currentRoute.value.params[unref(PathId).Collection] === item.value.entity.uid,
						"text-c-2": item.value.title === "Untitled Collection"
					}]]),
					to: item.value.to
				}, {
					default: withCtx(() => [createElementVNode("span", _hoisted_5$1, [renderSlot(_ctx.$slots, "leftIcon", {}, void 0, true), _cache[16] || (_cache[16] = createTextVNode("   ", -1))]), createElementVNode("div", _hoisted_6$1, [createElementVNode("span", _hoisted_7$1, toDisplayString(item.value.title), 1), createElementVNode("div", _hoisted_8$1, [
						createElementVNode("div", { class: normalizeClass(["items-center gap-px opacity-0 group-hover:flex group-hover:opacity-100 group-focus-visible:opacity-100 group-has-[:focus-visible]:opacity-100", {
							flex: __props.menuItem.open,
							hidden: !__props.menuItem.open || __props.menuItem.item?.entity.uid !== item.value.entity.uid
						}]) }, [unref(layout) !== "modal" && !isDraftCollection.value || isDraftCollection.value && hasDraftRequests.value ? (openBlock(), createBlock(unref(ScalarButton), {
							key: 0,
							class: "hover:bg-b-3 hover:text-c-1 aspect-square h-fit px-0.5 py-0 group-focus-visible:opacity-100 group-has-[:focus-visible]:opacity-100",
							size: "sm",
							variant: "ghost",
							onClick: _cache[2] || (_cache[2] = withModifiers((ev) => _ctx.$emit("openMenu", {
								item: item.value,
								parentUids: __props.parentUids,
								targetRef: ev.currentTarget?.parentNode,
								open: true
							}), ["stop", "prevent"]))
						}, {
							default: withCtx(() => [createVNode(unref(ScalarIcon), {
								icon: "Ellipses",
								size: "md"
							})]),
							_: 1
						})) : createCommentVNode("", true), unref(layout) !== "modal" ? (openBlock(), createBlock(unref(ScalarButton), {
							key: 1,
							class: "hover:bg-b-3 hover:text-c-1 aspect-square h-fit px-0.5 py-0 group-focus-visible:opacity-100 group-has-[:focus-visible]:opacity-100",
							size: "sm",
							variant: "ghost",
							onClick: _cache[3] || (_cache[3] = withModifiers(($event) => addRequest(item.value.entity.uid), ["stop", "prevent"]))
						}, {
							default: withCtx(() => [createVNode(unref(ScalarIcon), {
								icon: "Add",
								size: "md",
								thickness: "2"
							})]),
							_: 1
						})) : createCommentVNode("", true)], 2),
						item.value.watchMode ? (openBlock(), createBlock(unref(ScalarTooltip), {
							key: 0,
							content: `Watching: ${item.value.documentUrl}`,
							offset: 12,
							placement: "right"
						}, {
							default: withCtx(() => [createElementVNode("button", _hoisted_9, [createVNode(unref(ScalarIcon), {
								class: normalizeClass(["ml-0.5 text-sm", watchIconColor.value]),
								icon: "Watch",
								size: "md",
								thickness: "2"
							}, null, 8, ["class"])])]),
							_: 1
						}, 8, ["content"])) : createCommentVNode("", true),
						createElementVNode("span", {
							class: "flex cursor-pointer items-center justify-center",
							onClick: _cache[4] || (_cache[4] = withModifiers(($event) => unref(toggleSidebarFolder)(item.value.entity.uid), ["stop", "prevent"]))
						}, [createVNode(unref(ScalarSidebarGroupToggle), {
							class: "text-c-3 hover:text-c-1 shrink-0",
							open: Boolean(unref(collapsedSidebarFolders)[item.value.entity.uid])
						}, null, 8, ["open"])])
					])])]),
					_: 3
				}, 8, [
					"aria-expanded",
					"class",
					"to"
				])) : unref(layout) !== "modal" || __props.parentUids.length ? (openBlock(), createElementBlock("button", {
					key: 2,
					"aria-expanded": Boolean(unref(collapsedSidebarFolders)[item.value.entity.uid]),
					class: normalizeClass(["hover:bg-b-2 group relative flex w-full flex-row justify-start gap-1.5 rounded p-1.5 focus-visible:z-10", [highlightClasses]]),
					type: "button",
					onClick: _cache[8] || (_cache[8] = ($event) => unref(toggleSidebarFolder)(item.value.entity.uid))
				}, [createElementVNode("span", _hoisted_11, [renderSlot(_ctx.$slots, "leftIcon", {}, void 0, true), _cache[17] || (_cache[17] = createTextVNode("   ", -1))]), createElementVNode("div", _hoisted_12, [createElementVNode("span", _hoisted_13, toDisplayString(item.value.title), 1), createElementVNode("div", _hoisted_14, [
					createElementVNode("div", { class: normalizeClass(["items-center gap-px opacity-0 group-hover:flex group-hover:opacity-100 group-focus-visible:opacity-100 group-has-[:focus-visible]:opacity-100", {
						flex: __props.menuItem.open,
						hidden: !__props.menuItem.open || __props.menuItem.item?.entity.uid !== item.value.entity.uid
					}]) }, [unref(layout) !== "modal" && !isDraftCollection.value || isDraftCollection.value && hasDraftRequests.value ? (openBlock(), createBlock(unref(ScalarButton), {
						key: 0,
						class: "hover:bg-b-3 hover:text-c-1 aspect-square h-fit px-0.5 py-0 group-focus-visible:opacity-100 group-has-[:focus-visible]:opacity-100",
						size: "sm",
						variant: "ghost",
						onClick: _cache[5] || (_cache[5] = withModifiers((ev) => _ctx.$emit("openMenu", {
							item: item.value,
							parentUids: __props.parentUids,
							targetRef: ev.currentTarget?.parentNode,
							open: true
						}), ["stop", "prevent"]))
					}, {
						default: withCtx(() => [createVNode(unref(ScalarIcon), {
							icon: "Ellipses",
							size: "md"
						})]),
						_: 1
					})) : createCommentVNode("", true), unref(layout) !== "modal" ? (openBlock(), createBlock(unref(ScalarButton), {
						key: 1,
						class: "hover:bg-b-3 hover:text-c-1 aspect-square h-fit px-0.5 py-0 group-focus-visible:opacity-100 group-has-[:focus-visible]:opacity-100",
						size: "sm",
						variant: "ghost",
						onClick: _cache[6] || (_cache[6] = withModifiers(($event) => addRequest(item.value.entity.uid), ["stop", "prevent"]))
					}, {
						default: withCtx(() => [createVNode(unref(ScalarIcon), {
							icon: "Add",
							size: "md",
							thickness: "2"
						})]),
						_: 1
					})) : createCommentVNode("", true)], 2),
					item.value.watchMode ? (openBlock(), createBlock(unref(ScalarTooltip), {
						key: 0,
						content: "Watching: {{ item.documentUrl }}",
						offset: 12,
						placement: "right"
					}, {
						default: withCtx(() => [createElementVNode("button", _hoisted_15, [createVNode(unref(ScalarIcon), {
							class: normalizeClass(["ml-0.5 text-sm", watchIconColor.value]),
							icon: "Watch",
							size: "md",
							thickness: "2"
						}, null, 8, ["class"])])]),
						_: 1
					})) : createCommentVNode("", true),
					createElementVNode("span", {
						class: "flex cursor-pointer items-center justify-center",
						onClick: _cache[7] || (_cache[7] = withModifiers(($event) => unref(toggleSidebarFolder)(item.value.entity.uid), ["stop", "prevent"]))
					}, [createVNode(unref(ScalarSidebarGroupToggle), {
						class: "text-c-3 hover:text-c-1 shrink-0",
						open: Boolean(unref(collapsedSidebarFolders)[item.value.entity.uid])
					}, null, 8, ["open"])])
				])])], 10, _hoisted_10)) : createCommentVNode("", true), showChildren.value ? (openBlock(), createElementBlock("ul", _hoisted_16, [(openBlock(true), createElementBlock(Fragment, null, renderList(item.value.children, (childUid) => {
					return openBlock(), createBlock(_component_RequestSidebarItem, {
						key: childUid,
						isDraggable: !unref(requestExamples)[childUid],
						isDroppable: _isDroppable,
						menuItem: __props.menuItem,
						parentUids: [...__props.parentUids, __props.uid],
						uid: childUid,
						onNewTab: _cache[9] || (_cache[9] = (name, uid) => _ctx.$emit("newTab", name, uid)),
						onOnDragEnd: _cache[10] || (_cache[10] = (...args) => _ctx.$emit("onDragEnd", ...args)),
						onOpenMenu: _cache[11] || (_cache[11] = (item) => _ctx.$emit("openMenu", item))
					}, null, 8, [
						"isDraggable",
						"menuItem",
						"parentUids",
						"uid"
					]);
				}), 128)), item.value.children.length === 0 ? (openBlock(), createBlock(unref(ScalarButton), {
					key: 0,
					class: normalizeClass(["text-c-1 hover:bg-b-2 flex h-8 w-full justify-start gap-1.5 py-0 text-xs", __props.parentUids.length ? "pl-9" : ""]),
					variant: "ghost",
					onClick: _cache[12] || (_cache[12] = ($event) => addRequest(item.value.entity.uid))
				}, {
					default: withCtx(() => [createVNode(unref(ScalarIcon), {
						icon: "Add",
						size: "sm"
					}), _cache[18] || (_cache[18] = createElementVNode("span", null, "Add Request", -1))]),
					_: 1
				}, 8, ["class"])) : createCommentVNode("", true)])) : createCommentVNode("", true)]),
				_: 3
			}, 8, [
				"id",
				"ceiling",
				"floor",
				"isDraggable",
				"isDroppable",
				"parentIds"
			])], 2)) : createCommentVNode("", true);
		};
	}
}), [["__scopeId", "data-v-b2f06757"]]);
//#endregion
//#region src/views/Request/RequestSidebar.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$1 = { class: "bg-b-1 sticky top-0 z-20 flex h-12 items-center px-3" };
var _hoisted_2$1 = {
	key: 1,
	class: "text-c-3"
};
var _hoisted_3 = ["aria-pressed"];
var _hoisted_4 = { class: "sr-only" };
var _hoisted_5 = {
	key: 0,
	class: "search-button-fade sticky top-12 z-10 px-3 py-2.5 pt-0 focus-within:z-20",
	role: "search"
};
var _hoisted_6 = {
	key: 1,
	class: "contents"
};
var _hoisted_7 = {
	key: 0,
	class: "empty-sidebar-item-content px-2.5 py-2.5"
};
var _hoisted_8 = { class: "rabbit-ascii relative m-auto mt-2 h-[68px] w-[60px]" };
//#endregion
//#region src/views/Request/RequestSidebar.vue
var RequestSidebar_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "RequestSidebar",
	emits: ["newTab", "clearDrafts"],
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		const { isSidebarOpen, setCollapsedSidebarFolder, toggleSidebarOpen } = useSidebar();
		const { layout } = useLayout();
		const workspaceContext = useWorkspace();
		const { activeCollection, activeWorkspaceCollections, activeRequest, activeWorkspaceRequests, activeWorkspace } = useActiveEntities();
		const { findRequestParents, events, requestMutators, requests } = workspaceContext;
		const { handleDragEnd, isDroppable } = dragHandlerFactory(activeWorkspace, workspaceContext);
		const { replace } = useRouter();
		const openCommandPaletteImport = () => {
			events.commandPalette.emit({ commandName: "Import from OpenAPI/Swagger/Postman/cURL" });
		};
		const searchResultsId = useId();
		const { toast } = useToasts();
		/** The currently selected sidebarMenuItem for the context menu */
		const menuItem = reactive({ open: false });
		const isSearchVisible = ref(false);
		/** Watch to see if activeRequest changes and ensure we open any folders */
		watch(activeRequest, (request) => {
			if (!request) return;
			findRequestParents(request).forEach((uid) => setCollapsedSidebarFolder(uid, true));
		}, { immediate: true });
		const { searchText, searchResultsWithPlaceholderResults, selectedSearchResult, onSearchResultClick, fuseSearch, searchInputRef, searchResultRefs, navigateSearchResults, selectSearchResult } = useSearch();
		const searchToggleRef = ref();
		/** Handle hotkey events from the bus */
		const handleHotKey = (event) => {
			if (!event) return;
			if (event.toggleSidebar) toggleSidebarOpen();
			if (event.focusRequestSearch) searchInputRef.value?.focus();
		};
		onMounted(() => events.hotKeys.on(handleHotKey));
		/**
		* Need to manually remove listener on unmount due to vueuse memory leak
		*
		* @see https://github.com/vueuse/vueuse/issues/3498#issuecomment-2055546566
		*/
		onBeforeUnmount(() => {
			events.hotKeys.off(handleHotKey);
		});
		const handleToggleWatchMode = (item) => {
			if (item?.documentUrl) {
				item.watchMode = !item.watchMode;
				const currentCollection = activeWorkspaceCollections.value.find((collection) => collection.uid === item.entity.uid);
				if (currentCollection) currentCollection.watchMode = item.watchMode;
			}
		};
		watch(() => activeWorkspaceCollections.value.map((collection) => collection.watchMode), (newWatchModes, oldWatchModes) => {
			newWatchModes.forEach((newWatchMode, index) => {
				if (layout !== "modal" && newWatchMode !== oldWatchModes[index] && activeWorkspaceCollections.value[index]?.info?.title !== "Drafts" && activeWorkspaceCollections.value[index]) {
					const currentCollection = activeWorkspaceCollections.value[index];
					if (!currentCollection) return;
					toast(`${currentCollection.info?.title}: Watch Mode ${newWatchMode ? "enabled" : "disabled"}`, "info");
				}
			});
		});
		/** Screen reader label for the search input */
		const srLabel = computed(() => {
			const results = searchResultsWithPlaceholderResults.value;
			if (!results.length) return "No results found";
			const result = results[selectedSearchResult.value]?.item;
			if (!result) return "No result selected";
			const resultsFoundLabel = searchText.value.length ? `${results.length} result${results.length === 1 ? "" : "s"} found, ` : "";
			const selectedResultDescription = `, HTTP Method ${result.httpVerb}, Path ${result.path}`;
			return `${resultsFoundLabel}Selected: ${`${result.title} ${selectedResultDescription}`}`;
		});
		const handleClearDrafts = () => {
			const draftCollection = activeWorkspaceCollections.value.find((collection) => collection.info?.title === "Drafts");
			if (draftCollection) draftCollection.requests.forEach((requestUid) => {
				if (requests[requestUid]) requestMutators.delete(requests[requestUid], draftCollection.uid);
			});
			if (activeWorkspaceRequests.value.length) {
				const firstRequest = activeWorkspaceCollections.value[0]?.requests[0];
				if (firstRequest) replace({
					name: "request",
					params: { [PathId.Request]: firstRequest }
				});
			} else {
				const { request } = createInitialRequest();
				if (draftCollection) {
					requestMutators.add(request, draftCollection.uid);
					replace({
						name: "request",
						params: { [PathId.Request]: request.uid }
					});
				}
			}
		};
		watch(isSearchVisible, (isVisible) => {
			if (!isVisible) searchText.value = "";
		});
		const showGettingStarted = computed(() => isGettingStarted(activeWorkspaceCollections.value, activeWorkspaceRequests.value, requests));
		/** We ensure in modal mode we only show the current requests collection */
		const collections = computed(() => {
			if (layout === "modal" && activeCollection.value) return [activeCollection.value];
			return activeWorkspaceCollections.value;
		});
		/** Hide the search input if the text is empty */
		function handleBlur(e) {
			if (!searchText.value && e.relatedTarget !== searchToggleRef.value) isSearchVisible.value = false;
		}
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock(Fragment, null, [withDirectives(createVNode(unref(Sidebar_default), { class: normalizeClass([unref(isSidebarOpen) ? "sidebar-active-width" : ""]) }, createSlots({
				content: withCtx(() => [
					createElementVNode("div", _hoisted_1$1, [
						createElementVNode("div", { class: normalizeClass(["size-8", { "xl:hidden": unref(layout) !== "modal" }]) }, null, 2),
						unref(layout) !== "modal" ? (openBlock(), createBlock(unref(WorkspaceDropdown_default), { key: 0 })) : createCommentVNode("", true),
						unref(layout) !== "modal" ? (openBlock(), createElementBlock("span", _hoisted_2$1, " / ")) : createCommentVNode("", true),
						unref(layout) !== "modal" ? (openBlock(), createBlock(EnvironmentSelector_default, { key: 2 })) : createCommentVNode("", true),
						createElementVNode("button", {
							ref_key: "searchToggleRef",
							ref: searchToggleRef,
							"aria-pressed": isSearchVisible.value,
							class: "ml-auto",
							type: "button",
							onClick: _cache[0] || (_cache[0] = ($event) => isSearchVisible.value = !isSearchVisible.value)
						}, [createElementVNode("span", _hoisted_4, toDisplayString(isSearchVisible.value ? "Hide" : "Show") + " search ", 1), createVNode(unref(ScalarIcon), {
							class: "text-c-3 hover:bg-b-2 max-h-8 max-w-8 rounded-lg p-1.75 text-sm",
							icon: "Search"
						})], 8, _hoisted_3)
					]),
					isSearchVisible.value ? (openBlock(), createElementBlock("div", _hoisted_5, [createVNode(unref(ScalarSidebarSearchInput), {
						ref_key: "searchInputRef",
						ref: searchInputRef,
						modelValue: unref(searchText),
						"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(searchText) ? searchText.value = $event : null),
						autofocus: "",
						"aria-controls": unref(searchResultsId),
						label: srLabel.value,
						onInput: unref(fuseSearch),
						onKeydown: [
							_cache[2] || (_cache[2] = withKeys(withModifiers(($event) => unref(navigateSearchResults)("down"), ["stop"]), ["down"])),
							_cache[3] || (_cache[3] = withKeys(withModifiers(($event) => unref(selectSearchResult)(), ["stop"]), ["enter"])),
							_cache[4] || (_cache[4] = withKeys(withModifiers(($event) => unref(navigateSearchResults)("up"), ["stop"]), ["up"]))
						],
						onBlur: handleBlur
					}, null, 8, [
						"modelValue",
						"aria-controls",
						"label",
						"onInput"
					])])) : createCommentVNode("", true),
					createElementVNode("div", {
						class: normalizeClass(["gap-1/2 flex flex-1 flex-col overflow-visible overflow-y-auto px-3 pt-0 pb-3", [{ "pb-14": unref(layout) !== "modal" }, { "h-[calc(100%-273.5px)]": showGettingStarted.value }]]),
						onDragenter: _cache[7] || (_cache[7] = withModifiers(() => {}, ["prevent"])),
						onDragover: _cache[8] || (_cache[8] = withModifiers(() => {}, ["prevent"]))
					}, [unref(searchText) ? (openBlock(), createBlock(unref(ScalarSearchResultList), {
						key: 0,
						id: unref(searchResultsId),
						"aria-label": "Search Results",
						class: "gap-px",
						noResults: !unref(searchResultsWithPlaceholderResults).length
					}, {
						default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(searchResultsWithPlaceholderResults), (entry, index) => {
							return openBlock(), createBlock(unref(ScalarSearchResultItem), {
								id: `#search-input-${entry.item.id}`,
								key: entry.refIndex,
								ref_for: true,
								ref: (el) => unref(searchResultRefs)[index] = el,
								selected: unref(selectedSearchResult) === index,
								class: "px-2",
								href: entry.item.link,
								onClick: withModifiers(($event) => unref(onSearchResultClick)(entry), ["prevent"]),
								onFocus: ($event) => selectedSearchResult.value = index
							}, {
								addon: withCtx(() => [_cache[10] || (_cache[10] = createElementVNode("span", { class: "sr-only" }, "HTTP Method:", -1)), createVNode(HttpMethod_default, {
									class: "font-bold",
									method: entry.item.httpVerb ?? "get"
								}, null, 8, ["method"])]),
								default: withCtx(() => [createTextVNode(toDisplayString(entry.item.title) + " ", 1)]),
								_: 2
							}, 1032, [
								"id",
								"selected",
								"href",
								"onClick",
								"onFocus"
							]);
						}), 128))]),
						_: 1
					}, 8, ["id", "noResults"])) : (openBlock(), createElementBlock("nav", _hoisted_6, [(openBlock(true), createElementBlock(Fragment, null, renderList(collections.value, (collection) => {
						return openBlock(), createBlock(RequestSidebarItem_default, {
							key: collection.uid,
							isDraggable: unref(layout) !== "modal" && collection.info?.title !== "Drafts",
							isDroppable: unref(isDroppable),
							menuItem,
							parentUids: [],
							uid: collection.uid,
							onNewTab: _cache[5] || (_cache[5] = (name, uid) => emit("newTab", {
								name,
								uid
							})),
							onOnDragEnd: unref(handleDragEnd),
							onOpenMenu: _cache[6] || (_cache[6] = (item) => Object.assign(menuItem, item))
						}, {
							leftIcon: withCtx(() => [collection.info?.title === "Drafts" ? (openBlock(), createBlock(unref(ScalarIcon), {
								key: 0,
								class: "text-sidebar-c-2",
								icon: "Scribble",
								thickness: "2.25"
							})) : (openBlock(), createBlock(unref(LibraryIcon), {
								key: 1,
								class: "text-sidebar-c-2 size-3.5 min-w-3.5 stroke-2",
								src: collection["x-scalar-icon"] || "interface-content-folder"
							}, null, 8, ["src"]))]),
							_: 2
						}, 1032, [
							"isDraggable",
							"isDroppable",
							"menuItem",
							"uid",
							"onOnDragEnd"
						]);
					}), 128))]))], 34)
				]),
				button: withCtx(() => [createElementVNode("div", { class: normalizeClass({ "empty-sidebar-item": showGettingStarted.value }) }, [
					showGettingStarted.value ? (openBlock(), createElementBlock("div", _hoisted_7, [createElementVNode("div", _hoisted_8, [createVNode(ScalarAsciiArt_default, {
						art: unref(rabbit_default),
						class: "rabbitsit font-bold"
					}, null, 8, ["art"]), createVNode(ScalarAsciiArt_default, {
						art: unref(rabbitjump_default),
						class: "rabbitjump absolute top-0 left-0 font-bold"
					}, null, 8, ["art"])]), _cache[11] || (_cache[11] = createElementVNode("div", { class: "mt-2 mb-2 text-center text-sm text-balance" }, [createElementVNode("b", { class: "font-medium" }, "Let's Get Started"), createElementVNode("p", { class: "mt-2" }, " Create request, folder, collection or import from OpenAPI/Postman ")], -1))])) : createCommentVNode("", true),
					unref(layout) !== "modal" ? (openBlock(), createBlock(unref(ScalarButton), {
						key: 1,
						class: normalizeClass(["mb-1.5 hidden h-fit w-full p-1.5 opacity-0", { "flex opacity-100": showGettingStarted.value }]),
						onClick: openCommandPaletteImport
					}, {
						default: withCtx(() => [..._cache[12] || (_cache[12] = [createTextVNode(" Import Collection ", -1)])]),
						_: 1
					}, 8, ["class"])) : createCommentVNode("", true),
					unref(layout) !== "modal" ? (openBlock(), createBlock(SidebarButton_default, {
						key: 2,
						click: unref(events).commandPalette.emit,
						hotkey: "K"
					}, {
						title: withCtx(() => [..._cache[13] || (_cache[13] = [createTextVNode(" Add Item ", -1)])]),
						_: 1
					}, 8, ["click"])) : createCommentVNode("", true)
				], 2)]),
				_: 2
			}, [unref(layout) !== "modal" ? {
				name: "header",
				fn: withCtx(() => []),
				key: "0"
			} : void 0]), 1032, ["class"]), [[vShow, unref(isSidebarOpen)]]), unref(layout) !== "modal" && menuItem ? (openBlock(), createBlock(RequestSidebarItemMenu_default, {
				key: 0,
				menuItem,
				onClearDrafts: handleClearDrafts,
				onCloseMenu: _cache[9] || (_cache[9] = ($event) => menuItem.open = false),
				onToggleWatchMode: handleToggleWatchMode
			}, null, 8, ["menuItem"])) : createCommentVNode("", true)], 64);
		};
	}
}), [["__scopeId", "data-v-23d35bb5"]]);
//#endregion
//#region src/views/Request/RequestRoot.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = { class: "flex h-full" };
var _hoisted_2 = { class: "flex h-full flex-1 flex-col" };
//#endregion
//#region src/views/Request/RequestRoot.vue
var RequestRoot_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "RequestRoot",
	emits: ["newTab"],
	setup(__props) {
		const workspaceContext = useWorkspace();
		const { toast } = useToasts();
		const { layout } = useLayout();
		const config = useClientConfig();
		const { isSidebarOpen } = useSidebar();
		const analytics = useAnalytics();
		const { activeCollection, activeExample, activeEnvironment, activeRequest, activeWorkspace, activeServer } = useActiveEntities();
		const { cookies, requestHistory, showSidebar, securitySchemes, modalState, events } = workspaceContext;
		const pluginManager = usePluginManager();
		/** Root element (bound in template via ref="_element") */
		const _element = ref();
		const requestAbortController = ref();
		/** Computed Validation State Update on Example Change */
		const validation = computed(() => validateParameters(activeExample.value ?? null));
		const requestResult = ref(null);
		/**
		* Selected scheme UIDs
		*
		* In the modal we use collection.selectedSecuritySchemes and in the
		* standalone client we use request.selectedSecuritySchemeUids
		*
		* These are centralized here so they can be drilled down AND used in send-request
		*/
		const selectedSecuritySchemeUids = computed(() => (activeCollection.value?.useCollectionSecurity ? activeCollection.value?.selectedSecuritySchemeUids : activeRequest.value?.selectedSecuritySchemeUids) ?? []);
		/**
		* Execute the request
		* called from the send button as well as keyboard shortcuts
		*/
		const executeRequest = async () => {
			if (!activeRequest.value || !activeExample.value || !activeCollection.value) return;
			if (validation.value.hasBlockingErrors) {
				toast("Path parameters must have values.", "error");
				events.requestStatus.emit("abort");
				return;
			}
			const environmentValue = typeof activeEnvironment.value === "object" ? activeEnvironment.value.value : "{}";
			const e = safeJSON.parse(environmentValue);
			if (e.error) console.error("INVALID ENVIRONMENT!");
			const environment = e.error || typeof e.data !== "object" ? {} : e.data ?? {};
			const globalCookies = activeWorkspace.value?.cookies.map((c) => cookies[c]).filter(isDefined$1) ?? [];
			const server = activeCollection.value?.info?.title === "Drafts" ? void 0 : activeServer.value;
			const [error, requestOperation] = createRequestOperation({
				request: activeRequest.value,
				example: activeExample.value,
				selectedSecuritySchemeUids: selectedSecuritySchemeUids.value,
				proxyUrl: activeWorkspace.value?.proxyUrl ?? "",
				environment,
				globalCookies,
				status: events.requestStatus,
				securitySchemes,
				server,
				pluginManager
			});
			config.value?.onRequestSent?.(activeRequest.value.path ?? "");
			if (error) {
				toast(error.message, "error");
				return;
			}
			requestAbortController.value = requestOperation.controller;
			const [sendRequestError, result] = await requestOperation.sendRequest();
			requestResult.value = result;
			if (sendRequestError) toast(sendRequestError.message, "error");
			else requestHistory.push(cloneRequestResult(result));
		};
		/** Cancel a live request */
		const cancelRequest = async () => requestAbortController.value?.abort(ERRORS.REQUEST_ABORTED);
		/** Subscribed to executeRequest, used for logging / analytics. */
		function logRequest() {
			analytics?.capture("client-send-request");
		}
		/**
		* Cancel request when closing the modal
		* @see https://github.com/scalar/scalar/issues/7115
		*/
		watch(modalState, ({ open }) => {
			if (!open) cancelRequest();
		});
		onMounted(() => {
			events.executeRequest.on(executeRequest);
			events.executeRequest.on(logRequest);
			events.cancelRequest.on(cancelRequest);
		});
		useOpenApiWatcher();
		/**
		* Need to manually remove listener on unmount due to vueuse memory leak
		*
		* @see https://github.com/vueuse/vueuse/issues/3498#issuecomment-2055546566
		*/
		onBeforeUnmount(() => {
			events.executeRequest.off(executeRequest);
			events.executeRequest.off(logRequest);
			events.cancelRequest.off(cancelRequest);
		});
		const cloneRequestResult = (result) => {
			try {
				return structuredClone(result);
			} catch {
				const clone = { ...result };
				if (result.response?.data) if (result.response.data instanceof Blob || result.response.data instanceof ArrayBuffer) clone.response.data = result.response.data;
				else clone.response.data = JSON.parse(JSON.stringify(result.response.data));
				return clone;
			}
		};
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("div", {
				ref_key: "_element",
				ref: _element,
				class: normalizeClass(["bg-b-1 relative z-0 flex h-full flex-1 flex-col overflow-hidden pt-0", { "!mr-0 !mb-0 !border-0": unref(layout) === "modal" }])
			}, [unref(showSidebar) ? (openBlock(), createBlock(SidebarToggle_default, {
				key: 0,
				modelValue: unref(isSidebarOpen),
				"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(isSidebarOpen) ? isSidebarOpen.value = $event : null),
				class: normalizeClass(["absolute top-2 left-3 z-50", [
					{ hidden: unref(isSidebarOpen) },
					{ "xl:!flex": !unref(isSidebarOpen) },
					{ "!flex": unref(layout) === "modal" }
				]])
			}, null, 8, ["modelValue", "class"])) : createCommentVNode("", true), createElementVNode("div", _hoisted_1, [unref(showSidebar) ? (openBlock(), createBlock(RequestSidebar_default, {
				key: 0,
				onNewTab: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("newTab", $event))
			})) : createCommentVNode("", true), createElementVNode("div", _hoisted_2, [createVNode(unref(RouterView), {
				invalidParams: validation.value.invalidParams,
				requestResult: requestResult.value,
				selectedSecuritySchemeUids: selectedSecuritySchemeUids.value
			}, null, 8, [
				"invalidParams",
				"requestResult",
				"selectedSecuritySchemeUids"
			])])])], 2);
		};
	}
}), [["__scopeId", "data-v-02af05d1"]]);
//#endregion
export { RequestRoot_default as default };

//# sourceMappingURL=RequestRoot-3Bj8JZD-.js.map