import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeModels, openBlock, toDisplayString, unref, useModel, useSlots, withCtx } from "vue";
import { ScalarButton, ScalarCheckboxInput, ScalarIcon, ScalarListbox, ScalarTooltip } from "@scalar/components";
//#region src/v2/features/command-palette/components/PostmanImportPreview.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = { class: "flex flex-1 flex-col gap-1.5 overflow-hidden" };
var _hoisted_2 = { class: "flex flex-1 flex-col gap-1.5 overflow-hidden" };
var _hoisted_3 = { class: "border-border bg-b-2 text-c-2 shrink-0 rounded border px-2.5 py-1.5 text-xs leading-tight" };
var _hoisted_4 = { class: "text-c-1 truncate font-medium" };
var _hoisted_5 = { class: "text-c-3 mt-0.5 flex flex-wrap items-center gap-x-1.5 gap-y-0.5" };
var _hoisted_6 = { class: "whitespace-nowrap" };
var _hoisted_7 = { class: "whitespace-nowrap" };
var _hoisted_8 = { class: "whitespace-nowrap" };
var _hoisted_9 = {
	key: 0,
	class: "postman-import-path-conflict-callout w-full max-w-full rounded-md border px-2.5 py-1.5 text-xs leading-snug"
};
var _hoisted_10 = { class: "[overflow-wrap:anywhere] [word-break:break-word]" };
var _hoisted_11 = { class: "font-medium" };
var _hoisted_12 = { class: "max-h-[300px] overflow-y-auto" };
var _hoisted_13 = { class: "border-border bg-b-2 flex shrink-0 flex-col gap-3 rounded-md border px-2.5 py-2.5" };
var _hoisted_14 = {
	key: 0,
	class: "border-border flex flex-col gap-2 border-b border-dashed pb-3"
};
var _hoisted_15 = { class: "text-c-1 truncate font-medium" };
var _hoisted_16 = { class: "[&>label]:bg-transparent [&>label]:p-0 [&>label]:shadow-none [&>label]:hover:bg-transparent" };
var PostmanImportPreview_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	name: "PostmanImportPreview",
	props: /* @__PURE__ */ mergeModels({
		title: {},
		version: {},
		schema: {},
		totalRequests: {},
		availableTargetDocuments: {},
		hasCollisionPathKeys: { type: Boolean }
	}, {
		"selectedTargetDocument": {},
		"selectedTargetDocumentModifiers": {},
		"mergeSamePathAndMethod": { type: Boolean },
		"mergeSamePathAndMethodModifiers": {}
	}),
	emits: ["update:selectedTargetDocument", "update:mergeSamePathAndMethod"],
	setup(__props) {
		const props = __props;
		const slots = useSlots();
		const selectedTargetDocument = useModel(__props, "selectedTargetDocument");
		const mergeSamePathAndMethod = useModel(__props, "mergeSamePathAndMethod");
		/** Listbox id for "create a new document" — parent model stays `null`. */
		const NEW_DOCUMENT_LISTBOX_ID = "__postman_import_new__";
		const importDestinationOptions = computed(() => [{
			id: NEW_DOCUMENT_LISTBOX_ID,
			label: "New document"
		}, ...props.availableTargetDocuments.map((d) => ({
			id: d.slug,
			label: d.label
		}))]);
		const resolvedImportDestinationOption = computed(() => {
			const options = importDestinationOptions.value;
			const fallback = options[0];
			const sel = selectedTargetDocument.value;
			if (!sel) return fallback;
			return options.find((o) => o.id === sel.slug) ?? fallback;
		});
		const onImportDestinationChange = (option) => {
			if (option.id === NEW_DOCUMENT_LISTBOX_ID) {
				selectedTargetDocument.value = null;
				return;
			}
			selectedTargetDocument.value = {
				slug: option.id,
				label: option.label
			};
		};
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("div", _hoisted_1, [
				createElementVNode("div", _hoisted_2, [createElementVNode("div", _hoisted_3, [createElementVNode("div", _hoisted_4, toDisplayString(__props.title), 1), createElementVNode("div", _hoisted_5, [
					__props.schema ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createElementVNode("span", _hoisted_6, toDisplayString(__props.schema), 1), _cache[1] || (_cache[1] = createElementVNode("span", {
						"aria-hidden": "true",
						class: "text-c-3 opacity-50"
					}, " · ", -1))], 64)) : createCommentVNode("", true),
					createElementVNode("span", _hoisted_7, " v" + toDisplayString(__props.version), 1),
					_cache[2] || (_cache[2] = createElementVNode("span", {
						"aria-hidden": "true",
						class: "text-c-3 opacity-50"
					}, " · ", -1)),
					createElementVNode("span", _hoisted_8, toDisplayString(__props.totalRequests) + " " + toDisplayString(__props.totalRequests === 1 ? "request" : "requests"), 1)
				])]), __props.hasCollisionPathKeys ? (openBlock(), createElementBlock("div", _hoisted_9, [createElementVNode("div", _hoisted_10, [_cache[11] || (_cache[11] = createElementVNode("span", { class: "font-semibold text-[var(--scalar-color-red)]" }, " Conflict ", -1)), selectedTargetDocument.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
					_cache[6] || (_cache[6] = createTextVNode(" — Same OpenAPI path + method as existing operations in ", -1)),
					createElementVNode("span", _hoisted_11, toDisplayString(selectedTargetDocument.value.label), 1),
					_cache[7] || (_cache[7] = createTextVNode(" . ", -1)),
					!mergeSamePathAndMethod.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
						_cache[3] || (_cache[3] = createTextVNode(" These will overwrite existing operations unless ", -1)),
						_cache[4] || (_cache[4] = createElementVNode("span", { class: "font-medium" }, "Merge same path & method", -1)),
						_cache[5] || (_cache[5] = createTextVNode(" is enabled. ", -1))
					], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(" These will be merged with existing operations. ")], 64))
				], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
					_cache[8] || (_cache[8] = createTextVNode(" — Same OpenAPI path + method for multiple selected requests. Turn on ", -1)),
					_cache[9] || (_cache[9] = createElementVNode("span", { class: "font-medium" }, "Merge same path & method", -1)),
					_cache[10] || (_cache[10] = createTextVNode(" to combine them; otherwise the last one wins. ", -1))
				], 64))])])) : createCommentVNode("", true)]),
				createElementVNode("div", _hoisted_12, [createVNode(slots.treePicker)]),
				createElementVNode("section", _hoisted_13, [__props.availableTargetDocuments.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_14, [_cache[12] || (_cache[12] = createElementVNode("div", null, [createElementVNode("p", { class: "text-c-1 text-xs font-semibold tracking-tight" }, " Import destination "), createElementVNode("p", { class: "text-c-3 mt-1 text-xs leading-snug" }, " Put operations into an existing API description, or create a new document in this workspace. ")], -1)), createVNode(unref(ScalarListbox), {
					id: "postman-import-target",
					label: "Import destination",
					modelValue: resolvedImportDestinationOption.value,
					options: importDestinationOptions.value,
					placement: "bottom-start",
					resize: "",
					"onUpdate:modelValue": onImportDestinationChange
				}, {
					default: withCtx(() => [createVNode(unref(ScalarButton), {
						class: "hover:bg-b-2 h-9 w-full justify-between gap-2 px-2.5 py-2 text-left text-xs",
						variant: "outlined"
					}, {
						default: withCtx(() => [createElementVNode("span", _hoisted_15, toDisplayString(resolvedImportDestinationOption.value.label), 1), createVNode(unref(ScalarIcon), {
							class: "text-c-3 shrink-0",
							icon: "ChevronDown",
							size: "md"
						})]),
						_: 1
					})]),
					_: 1
				}, 8, ["modelValue", "options"])])) : createCommentVNode("", true), createVNode(unref(ScalarTooltip), {
					content: "When several Postman requests map to the same OpenAPI path and HTTP method, merge them into one operation instead of keeping duplicate operations.",
					placement: "top"
				}, {
					default: withCtx(() => [createElementVNode("div", _hoisted_16, [createVNode(unref(ScalarCheckboxInput), {
						modelValue: mergeSamePathAndMethod.value,
						"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => mergeSamePathAndMethod.value = $event)
					}, {
						default: withCtx(() => [..._cache[13] || (_cache[13] = [createElementVNode("span", { class: "text-c-1 text-xs leading-snug font-medium" }, " Merge same path & method ", -1)])]),
						_: 1
					}, 8, ["modelValue"])])]),
					_: 1
				})])
			]);
		};
	}
});
//#endregion
export { PostmanImportPreview_vue_vue_type_script_setup_true_lang_default as default };

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