import { T as PathId, r as useWorkspace, w as useActiveEntities } from "./store-DpSUVhjp.js";
import { t as DeleteSidebarListElement_default } from "./DeleteSidebarListElement-C-p87d03.js";
import { Fragment, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, toDisplayString, unref, withCtx } from "vue";
import { ScalarButton, ScalarIcon, ScalarModal, ScalarToggle, useModal } from "@scalar/components";
import { useRouter } from "vue-router";
//#region src/views/Collection/CollectionSettings.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = { class: "flex h-full w-full flex-col gap-12 px-1.5 pt-8" };
var _hoisted_2 = { class: "flex flex-col gap-2" };
var _hoisted_3 = { class: "bg-b-2 rounded-lg border text-sm" };
var _hoisted_4 = { class: "bg-b-1 flex items-center justify-between gap-4 rounded-t-lg p-3" };
var _hoisted_5 = { class: "text-c-1 flex items-center overflow-x-auto border-t py-1.5 whitespace-nowrap" };
var _hoisted_6 = { class: "flex items-center" };
var _hoisted_7 = ["href"];
var _hoisted_8 = { class: "flex flex-col gap-4" };
var _hoisted_9 = { class: "flex items-center justify-between rounded-lg border p-3 text-sm" };
//#endregion
//#region src/views/Collection/CollectionSettings.vue
var CollectionSettings_default = /* @__PURE__ */ defineComponent({
	__name: "CollectionSettings",
	setup(__props) {
		const { activeCollection, activeWorkspace, activeWorkspaceCollections } = useActiveEntities();
		const { collectionMutators } = useWorkspace();
		const { replace } = useRouter();
		const deleteModal = useModal();
		function handleToggleWatchMode() {
			if (!activeCollection.value) return;
			if (!activeCollection.value?.documentUrl) return;
			collectionMutators.edit(activeCollection.value.uid, "watchMode", !activeCollection.value?.watchMode);
		}
		function handleDeleteCollection() {
			if (!activeCollection.value) return;
			if (!activeWorkspace.value) return;
			collectionMutators.delete(activeCollection.value, activeWorkspace.value);
			const firstCollection = activeWorkspaceCollections.value[0];
			if (firstCollection) replace({
				name: "collection",
				params: {
					[PathId.Workspace]: activeWorkspace.value.uid,
					[PathId.Collection]: firstCollection.uid
				}
			});
			deleteModal.hide();
		}
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock(Fragment, null, [createElementVNode("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [_cache[5] || (_cache[5] = createElementVNode("div", { class: "flex h-8 items-center" }, [createElementVNode("h3", { class: "font-bold" }, "Features")], -1)), createElementVNode("div", _hoisted_3, [createElementVNode("div", _hoisted_4, [_cache[2] || (_cache[2] = createElementVNode("div", null, [createElementVNode("h4", null, "Watch Mode"), createElementVNode("p", { class: "text-c-2 mt-1" }, " When enabled, the OpenAPI document will be polled for changes. The collection will be updated automatically. ")], -1)), createVNode(unref(ScalarToggle), {
				class: "w-4",
				disabled: !unref(activeCollection)?.documentUrl,
				modelValue: unref(activeCollection)?.watchMode ?? false,
				"onUpdate:modelValue": handleToggleWatchMode
			}, null, 8, ["disabled", "modelValue"])]), createElementVNode("div", _hoisted_5, [createElementVNode("div", _hoisted_6, [unref(activeCollection)?.documentUrl ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [_cache[3] || (_cache[3] = createElementVNode("span", { class: "bg-b-2 sticky left-0 pr-2 pl-3" }, "Source", -1)), createElementVNode("a", {
				class: "text-c-2 group rounded pr-3 no-underline hover:underline",
				href: unref(activeCollection).documentUrl,
				target: "_blank"
			}, [createTextVNode(toDisplayString(unref(activeCollection).documentUrl) + " ", 1), createVNode(unref(ScalarIcon), {
				class: "ml-1 hidden w-2.5 group-hover:inline",
				icon: "ExternalLink"
			})], 8, _hoisted_7)], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createVNode(unref(ScalarIcon), {
				class: "text-c-2 mr-2 ml-3 w-4",
				icon: "NotAllowed",
				size: "sm"
			}), _cache[4] || (_cache[4] = createElementVNode("span", { class: "text-c-2 pr-3" }, " No URL configured. Try importing an OpenAPI document from an URL. ", -1))], 64))])])])]), createElementVNode("div", _hoisted_8, [_cache[8] || (_cache[8] = createElementVNode("h3", { class: "font-bold" }, "Danger Zone", -1)), createElementVNode("div", _hoisted_9, [_cache[7] || (_cache[7] = createElementVNode("div", null, [createElementVNode("h4", null, "Delete Collection"), createElementVNode("p", { class: "text-c-2 mt-1" }, " Be careful, my friend. Once deleted, there is no way to recover the collection. ")], -1)), createVNode(unref(ScalarButton), {
				size: "sm",
				variant: "danger",
				onClick: _cache[0] || (_cache[0] = ($event) => unref(deleteModal).show())
			}, {
				default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode(" Delete Collection ", -1)])]),
				_: 1
			})])])]), createVNode(unref(ScalarModal), {
				size: "xxs",
				state: unref(deleteModal),
				title: `Delete ${unref(activeCollection)?.info?.title}`
			}, {
				default: withCtx(() => [createVNode(DeleteSidebarListElement_default, {
					variableName: unref(activeCollection)?.info?.title ?? "",
					warningMessage: "This action cannot be undone.",
					onClose: _cache[1] || (_cache[1] = ($event) => unref(deleteModal).hide()),
					onDelete: handleDeleteCollection
				}, null, 8, ["variableName"])]),
				_: 1
			}, 8, ["state", "title"])], 64);
		};
	}
});
//#endregion
export { CollectionSettings_default as default };

//# sourceMappingURL=CollectionSettings-HVSlp2Gv.js.map