import LabelInput_default from "./components/LabelInput.vue.js";
import Tabs_default from "./components/Tabs.vue.js";
import { computed, createElementBlock, createElementVNode, createVNode, defineComponent, mergeProps, openBlock, ref, unref, watch } from "vue";
import { RouterView } from "vue-router";
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
import { isHttpMethod } from "@scalar/helpers/http/is-http-method";
//#region src/v2/features/collection/OperationCollection.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = {
	key: 0,
	class: "custom-scroll h-full"
};
var _hoisted_2 = { class: "w-full px-3 md:mx-auto md:max-w-180" };
var _hoisted_3 = ["aria-label"];
var _hoisted_4 = { class: "group relative ml-1.25" };
var _hoisted_5 = { class: "px-1.5 py-8" };
var _hoisted_6 = {
	key: 1,
	class: "flex w-full flex-1 items-center justify-center"
};
var OperationCollection_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "OperationCollection",
	props: {
		documentSlug: {},
		document: {},
		eventBus: {},
		layout: {},
		path: {},
		method: {},
		exampleName: {},
		environment: {},
		securitySchemes: {},
		workspaceStore: {},
		activeWorkspace: {},
		plugins: {},
		customThemes: {},
		currentTheme: {},
		isDarkMode: { type: Boolean },
		fetchRegistryDocument: { type: Function },
		telemetry: { type: Boolean },
		onUpdateTelemetry: { type: Function }
	},
	setup(__props) {
		const props = __props;
		const operation = computed(() => {
			if (!props.path || !props.method) return;
			return getResolvedRef(props.document?.paths?.[props.path]?.[props.method]);
		});
		/**
		* Local copy of the label so we can reset on empty-blur rejection and stay in
		* sync when Vue Router reuses this component across workspace navigations.
		*/
		const operationSummary = ref(operation.value?.summary ?? "");
		watch(() => operation.value?.summary, (newSummary) => {
			operationSummary.value = newSummary ?? "";
		});
		/** Emits the rename event on blur, or resets the input if the title is blank. */
		const handleSummaryUpdate = (payload) => {
			const { path, method } = props;
			if (!path || !method || !isHttpMethod(method)) return;
			props.eventBus.emit("operation:update:meta", {
				meta: {
					path,
					method
				},
				payload: { summary: payload.trim() }
			});
		};
		const operationPlaceholder = computed(() => {
			if (!props.path || !props.method) return "Untitled Operation";
			return `${props.method.toUpperCase()} ${props.path}`;
		});
		return (_ctx, _cache) => {
			return operation.value !== void 0 ? (openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [
				createElementVNode("div", {
					"aria-label": `title: ${operationSummary.value}`,
					class: "mx-auto flex h-fit w-full flex-row items-center gap-2 pt-14 pb-3 md:max-w-180 md:pt-8"
				}, [createElementVNode("div", _hoisted_4, [createVNode(LabelInput_default, {
					modelValue: operationSummary.value,
					"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => operationSummary.value = $event),
					class: "text-xl font-bold",
					inputId: "operationSummary",
					placeholder: operationPlaceholder.value,
					onBlur: handleSummaryUpdate
				}, null, 8, ["modelValue", "placeholder"])])], 8, _hoisted_3),
				createVNode(Tabs_default, { type: "operation" }),
				createElementVNode("div", _hoisted_5, [createVNode(unref(RouterView), mergeProps(props, { collectionType: "operation" }), null, 16)])
			])])) : (openBlock(), createElementBlock("div", _hoisted_6, [..._cache[1] || (_cache[1] = [createElementVNode("div", { class: "flex h-full flex-col items-center justify-center" }, [createElementVNode("h1", { class: "text-2xl font-bold" }, "Operation not found"), createElementVNode("p", { class: "text-gray-500" }, " The operation you are looking for does not exist. ")], -1)])]));
		};
	}
});
//#endregion
export { OperationCollection_vue_vue_type_script_setup_true_lang_default as default };

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