import { n as Resize_default } from "./resize-D2IYvVdh.js";
import { t as useSearchIndex } from "./search-CmsQQkjn.js";
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, guardReactiveProps, isRef, mergeModels, normalizeClass, normalizeProps, openBlock, ref, renderSlot, toDisplayString, unref, useModel, useSlots, withCtx } from "vue";
import { ScalarIconButton, ScalarMenu, ScalarMenuLink, ScalarMenuProducts, ScalarMenuResources, ScalarMenuSection, ScalarMenuSupport, ScalarMenuWorkspacePicker, ScalarSidebarSearchInput } from "@scalar/components";
import { ScalarIconFileDashed, ScalarIconGear, ScalarIconMagnifyingGlass } from "@scalar/icons";
import { ScalarSidebar } from "@scalar/sidebar";
//#endregion
//#region src/v2/components/sidebar/SidebarMenu.vue
var SidebarMenu_default = /* @__PURE__ */ defineComponent({
	__name: "SidebarMenu",
	props: {
		activeWorkspace: {},
		workspaces: {}
	},
	emits: [
		"create:workspace",
		"select:workspace",
		"navigate:to:settings"
	],
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(ScalarMenu), null, {
				products: withCtx(() => [createVNode(unref(ScalarMenuProducts), { selected: "client" })]),
				sections: withCtx(({ close }) => [
					createVNode(unref(ScalarMenuSection), null, {
						default: withCtx(() => [renderSlot(_ctx.$slots, "sidebarMenuActions", {}, () => [createVNode(unref(ScalarMenuWorkspacePicker), {
							modelValue: __props.activeWorkspace.id,
							workspaceOptions: __props.workspaces,
							onCreateWorkspace: _cache[0] || (_cache[0] = ($event) => emit("create:workspace")),
							"onUpdate:modelValue": _cache[1] || (_cache[1] = (value) => emit("select:workspace", value))
						}, null, 8, ["modelValue", "workspaceOptions"]), createVNode(unref(ScalarMenuLink), {
							is: "button",
							icon: unref(ScalarIconGear),
							onClick: () => {
								close();
								emit("navigate:to:settings");
							}
						}, {
							default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode(" Settings ", -1)])]),
							_: 1
						}, 8, ["icon", "onClick"])])]),
						_: 2
					}, 1024),
					createVNode(unref(ScalarMenuResources)),
					createVNode(unref(ScalarMenuSupport))
				]),
				_: 3
			});
		};
	}
});
//#endregion
//#region src/v2/components/sidebar/Sidebar.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$1 = { class: "flex items-center justify-between" };
var _hoisted_2$1 = { key: 1 };
//#endregion
//#region src/v2/components/sidebar/Sidebar.vue
var Sidebar_default = /* @__PURE__ */ defineComponent({
	__name: "Sidebar",
	props: /* @__PURE__ */ mergeModels({
		sidebarState: {},
		layout: {},
		activeWorkspace: {},
		workspaces: {},
		documents: {},
		isDroppable: { type: [Boolean, Function] }
	}, {
		"sidebarWidth": {
			required: true,
			default: 288
		},
		"sidebarWidthModifiers": {}
	}),
	emits: /* @__PURE__ */ mergeModels([
		"selectItem",
		"select:workspace",
		"create:workspace",
		"reorder",
		"navigate:to:settings"
	], ["update:sidebarWidth"]),
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		const slots = useSlots();
		/** Controls the visibility of the search input */
		const isSearchVisible = ref(false);
		/** Controls the width of the sidebar */
		const sidebarWidth = useModel(__props, "sidebarWidth");
		const isDraft = (item) => {
			return item.type === "example" && item.title === "draft";
		};
		/** We handle search results out here so we can show them in the sidebar */
		const { query, results } = useSearchIndex(() => __props.documents);
		/** We show either the search results or the sidebar items */
		const items = computed(() => results.value ?? __props.sidebarState.items.value);
		/** Select an item and clear the search query */
		const handleSelectItem = (id) => {
			emit("selectItem", id);
			query.value = "";
			isSearchVisible.value = false;
		};
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(Resize_default), {
				width: sidebarWidth.value,
				"onUpdate:width": _cache[6] || (_cache[6] = ($event) => sidebarWidth.value = $event),
				class: "flex flex-col"
			}, {
				default: withCtx(() => [createVNode(unref(ScalarSidebar), {
					class: "flex w-auto flex-1",
					indent: 20,
					isDraggable: __props.layout !== "modal",
					isDroppable: __props.isDroppable,
					isExpanded: __props.sidebarState.isExpanded,
					isSelected: __props.sidebarState.isSelected,
					items: items.value,
					layout: "client",
					onReorder: _cache[5] || (_cache[5] = (draggingItem, hoveredItem) => emit("reorder", draggingItem, hoveredItem)),
					onSelectItem: handleSelectItem
				}, createSlots({
					header: withCtx(() => [_cache[7] || (_cache[7] = createElementVNode("div", { class: "mac:h-12 mac:app-drag-region h-2" }, null, -1)), createElementVNode("div", { class: normalizeClass(["bg-sidebar-b-1 z-1 flex flex-col gap-1.5 px-3 pb-1.5", { "max-md:pt-12": __props.layout !== "modal" }]) }, [createElementVNode("div", _hoisted_1$1, [__props.layout !== "modal" ? (openBlock(), createBlock(SidebarMenu_default, {
						key: 0,
						activeWorkspace: __props.activeWorkspace,
						workspaces: __props.workspaces,
						"onCreate:workspace": _cache[0] || (_cache[0] = ($event) => emit("create:workspace")),
						"onNavigate:to:settings": _cache[1] || (_cache[1] = ($event) => emit("navigate:to:settings")),
						"onSelect:workspace": _cache[2] || (_cache[2] = (id) => emit("select:workspace", id))
					}, {
						sidebarMenuActions: withCtx(() => [renderSlot(_ctx.$slots, "sidebarMenuActions")]),
						_: 3
					}, 8, ["activeWorkspace", "workspaces"])) : __props.layout === "modal" ? (openBlock(), createElementBlock("div", _hoisted_2$1)) : createCommentVNode("", true), createVNode(unref(ScalarIconButton), {
						icon: unref(ScalarIconMagnifyingGlass),
						label: "Search",
						onClick: _cache[3] || (_cache[3] = ($event) => isSearchVisible.value = !isSearchVisible.value)
					}, null, 8, ["icon"])]), isSearchVisible.value ? (openBlock(), createBlock(unref(ScalarSidebarSearchInput), {
						key: 0,
						modelValue: unref(query),
						"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => isRef(query) ? query.value = $event : null),
						autofocus: ""
					}, null, 8, ["modelValue"])) : createCommentVNode("", true)], 2)]),
					spacer: withCtx(() => [_cache[8] || (_cache[8] = createElementVNode("div", { class: "mac:app-drag-region flex-1" }, null, -1))]),
					decorator: withCtx((decoratorProps) => [renderSlot(_ctx.$slots, "decorator", normalizeProps(guardReactiveProps(decoratorProps)))]),
					icon: withCtx((iconProps) => [slots.icon || isDraft(iconProps.item) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [isDraft(iconProps.item) ? (openBlock(), createBlock(unref(ScalarIconFileDashed), { key: 0 })) : createCommentVNode("", true), renderSlot(_ctx.$slots, "icon", normalizeProps(guardReactiveProps(iconProps)))], 64)) : createCommentVNode("", true)]),
					before: withCtx(() => [renderSlot(_ctx.$slots, "workspaceButton")]),
					footer: withCtx(() => [renderSlot(_ctx.$slots, "footer")]),
					_: 2
				}, [slots.empty ? {
					name: "empty",
					fn: withCtx((emptyProps) => [renderSlot(_ctx.$slots, "empty", normalizeProps(guardReactiveProps(emptyProps)))]),
					key: "0"
				} : void 0]), 1032, [
					"isDraggable",
					"isDroppable",
					"isExpanded",
					"isSelected",
					"items"
				])]),
				_: 3
			}, 8, ["width"]);
		};
	}
});
//#endregion
//#region src/v2/components/sidebar/SidebarToggle.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = ["aria-pressed"];
var _hoisted_2 = { class: "sr-only" };
var _hoisted_3 = {
	class: "size-4",
	fill: "none",
	viewBox: "0 0 24 24",
	xmlns: "http://www.w3.org/2000/svg"
};
var _hoisted_4 = { "clip-path": "url(#mask)" };
//#endregion
//#region src/v2/components/sidebar/SidebarToggle.vue
var SidebarToggle_default = /* @__PURE__ */ defineComponent({
	__name: "SidebarToggle",
	props: {
		"modelValue": {
			type: Boolean,
			required: true
		},
		"modelModifiers": {}
	},
	emits: ["update:modelValue"],
	setup(__props) {
		const isSidebarOpen = useModel(__props, "modelValue");
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("button", {
				"aria-pressed": isSidebarOpen.value,
				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] = ($event) => isSidebarOpen.value = !isSidebarOpen.value)
			}, [createElementVNode("span", _hoisted_2, toDisplayString(isSidebarOpen.value ? "Hide" : "Show") + " sidebar", 1), (openBlock(), createElementBlock("svg", _hoisted_3, [
				_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, [createElementVNode("path", {
					class: normalizeClass(["transition-transform duration-300", isSidebarOpen.value ? "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);
		};
	}
});
//#endregion
export { Sidebar_default as n, SidebarMenu_default as r, SidebarToggle_default as t };

//# sourceMappingURL=sidebar-ceSbYmnt.js.map