import ContextMenu_default from "../../../components/context-menu/ContextMenu.vue.js";
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, openBlock, resolveDynamicComponent, toDisplayString, unref, withCtx } from "vue";
import { ScalarDropdownButton, ScalarDropdownDivider, ScalarDropdownMenu, ScalarFloating, ScalarHotkey, ScalarTooltip } from "@scalar/components";
import { isMacOS } from "@scalar/helpers/general/is-mac-os";
import { ScalarIconArrowUpRight, ScalarIconFolderSimple, ScalarIconLinkSimple, ScalarIconPlusSquare, ScalarIconTabs, ScalarIconX, ScalarIconXSquare } from "@scalar/icons";
//#region src/v2/features/app/components/DesktopTab.vue?vue&type=script&setup=true&lang.ts
var DesktopTab_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "DesktopTab",
	props: {
		hotkey: {},
		active: { type: Boolean },
		isSingleTab: {
			type: Boolean,
			default: false
		},
		tab: {}
	},
	emits: [
		"click",
		"close",
		"newTab",
		"copyUrl",
		"closeOtherTabs"
	],
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		const ICONS = {
			request: ScalarIconArrowUpRight,
			document: ScalarIconFolderSimple
		};
		/** Display the appropriate modifier key based on the operating system */
		const modifierKey = computed(() => isMacOS() ? "⌘" : "^");
		/** The tooltip content showing the keyboard shortcut */
		const tooltipContent = computed(() => __props.hotkey ? `${modifierKey.value} ${__props.hotkey}` : "");
		/**
		* Handle the close button click.
		* We stop propagation to prevent triggering the tab activation click.
		*/
		const handleClose = (event) => {
			event.stopPropagation();
			emit("close");
		};
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(ContextMenu_default), { triggerClass: "overflow-hidden w-full flex-1 select-none\n" }, {
				trigger: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(__props.isSingleTab ? "div" : unref(ScalarTooltip)), {
					content: tooltipContent.value,
					placement: "bottom"
				}, {
					default: withCtx(() => [createElementVNode("div", {
						class: normalizeClass(["app-no-drag-region", [__props.isSingleTab ? "nav-single-tab" : "nav-item", { "nav-item__active": __props.active && !__props.isSingleTab }]]),
						onClick: _cache[0] || (_cache[0] = ($event) => !__props.isSingleTab && emit("click"))
					}, [createElementVNode("div", { class: normalizeClass(["flex items-center justify-center gap-1.5", __props.isSingleTab ? "custom-scroll h-full w-full whitespace-nowrap" : "nav-item-icon-copy flex-1"]) }, [__props.tab.icon && ICONS[__props.tab.icon] ? (openBlock(), createBlock(resolveDynamicComponent(ICONS[__props.tab.icon]), { key: 0 })) : createCommentVNode("", true), createElementVNode("span", { class: normalizeClass([__props.isSingleTab ? "" : "custom-scroll nav-item-copy", "text-sm"]) }, toDisplayString(__props.tab.title), 3)], 2), !__props.isSingleTab ? (openBlock(), createElementBlock("button", {
						key: 0,
						class: "nav-item-close",
						type: "button",
						onClick: handleClose
					}, [(openBlock(), createBlock(resolveDynamicComponent(unref(ScalarIconX))))])) : createCommentVNode("", true)], 2)]),
					_: 1
				}, 8, ["content"]))]),
				content: withCtx(() => [createVNode(unref(ScalarFloating), { placement: "right-start" }, {
					floating: withCtx(() => [createVNode(unref(ScalarDropdownMenu), { class: "scalar-app scalar-client" }, {
						default: withCtx(() => [
							createVNode(unref(ScalarDropdownButton), {
								class: "flex items-center gap-1.5",
								onClick: _cache[1] || (_cache[1] = ($event) => emit("newTab"))
							}, {
								default: withCtx(() => [
									(openBlock(), createBlock(resolveDynamicComponent(unref(ScalarIconPlusSquare)))),
									_cache[5] || (_cache[5] = createTextVNode(" New Tab ", -1)),
									createVNode(unref(ScalarHotkey), {
										class: "bg-b-2 ml-auto",
										hotkey: "T"
									})
								]),
								_: 1
							}),
							createVNode(unref(ScalarDropdownButton), {
								class: "flex items-center gap-1.5",
								onClick: _cache[2] || (_cache[2] = ($event) => emit("copyUrl"))
							}, {
								default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(unref(ScalarIconLinkSimple)))), _cache[6] || (_cache[6] = createTextVNode(" Copy URL ", -1))]),
								_: 1
							}),
							!__props.isSingleTab ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
								createVNode(unref(ScalarDropdownDivider)),
								createVNode(unref(ScalarDropdownButton), {
									class: "flex items-center gap-1.5",
									onClick: _cache[3] || (_cache[3] = ($event) => emit("close"))
								}, {
									default: withCtx(() => [
										(openBlock(), createBlock(resolveDynamicComponent(unref(ScalarIconXSquare)))),
										_cache[7] || (_cache[7] = createTextVNode(" Close Tab ", -1)),
										createVNode(unref(ScalarHotkey), {
											class: "bg-b-2 ml-auto",
											hotkey: "W"
										})
									]),
									_: 1
								}),
								createVNode(unref(ScalarDropdownButton), {
									class: "flex items-center gap-1.5",
									onClick: _cache[4] || (_cache[4] = ($event) => emit("closeOtherTabs"))
								}, {
									default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(unref(ScalarIconTabs)))), _cache[8] || (_cache[8] = createTextVNode(" Close Other Tabs ", -1))]),
									_: 1
								})
							], 64)) : createCommentVNode("", true)
						]),
						_: 1
					})]),
					_: 1
				})]),
				_: 1
			});
		};
	}
});
//#endregion
export { DesktopTab_vue_vue_type_script_setup_true_lang_default as default };

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