import DeleteSidebarListElement_default from "../../../components/Sidebar/Actions/DeleteSidebarListElement.vue.js";
import Section_default from "./components/Section.vue.js";
import { Fragment, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, toDisplayString, unref, withCtx } from "vue";
import { ScalarButton, ScalarIcon, ScalarModal, ScalarToggle, useModal } from "@scalar/components";
//#region src/v2/features/settings/DocumentSettings.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = { class: "flex flex-col gap-12" };
var _hoisted_2 = { class: "bg-b-2 rounded-lg border text-sm" };
var _hoisted_3 = { class: "bg-b-1 flex items-center justify-between gap-4 rounded-t-lg p-3" };
var _hoisted_4 = { class: "text-c-1 flex items-center overflow-x-auto border-t py-1.5 whitespace-nowrap" };
var _hoisted_5 = { class: "flex items-center" };
var _hoisted_6 = ["href"];
var _hoisted_7 = { class: "flex items-center justify-between rounded-lg border p-3 text-sm" };
var DocumentSettings_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "DocumentSettings",
	props: {
		documentUrl: {},
		watchMode: { type: Boolean },
		title: {},
		isDraftDocument: {
			type: Boolean,
			default: false
		}
	},
	emits: ["delete:document", "update:watchMode"],
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		const deleteModal = useModal();
		/**
		* Handles the delete button click.
		* Prevents opening the modal if the document is a draft.
		*/
		const handleDeleteClick = () => {
			if (__props.isDraftDocument) return;
			deleteModal.show();
		};
		const handleDocumentDelete = () => {
			emit("delete:document");
			deleteModal.hide();
		};
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock(Fragment, null, [createElementVNode("div", _hoisted_1, [createVNode(Section_default, null, {
				title: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("Features", -1)])]),
				default: withCtx(() => [createElementVNode("div", _hoisted_2, [createElementVNode("div", _hoisted_3, [_cache[3] || (_cache[3] = 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: !__props.documentUrl,
					modelValue: __props.watchMode ?? false,
					"onUpdate:modelValue": _cache[0] || (_cache[0] = (value) => emit("update:watchMode", value))
				}, null, 8, ["disabled", "modelValue"])]), createElementVNode("div", _hoisted_4, [createElementVNode("div", _hoisted_5, [__props.documentUrl ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [_cache[4] || (_cache[4] = 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: __props.documentUrl,
					target: "_blank"
				}, [createTextVNode(toDisplayString(__props.documentUrl) + " ", 1), createVNode(unref(ScalarIcon), {
					class: "ml-1 hidden w-2.5 group-hover:inline",
					icon: "ExternalLink"
				})], 8, _hoisted_6)], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createVNode(unref(ScalarIcon), {
					class: "text-c-2 mr-2 ml-3 w-4",
					icon: "NotAllowed",
					size: "sm"
				}), _cache[5] || (_cache[5] = createElementVNode("span", { class: "text-c-2 pr-3" }, " No URL configured. Try importing an OpenAPI document from an URL. ", -1))], 64))])])])]),
				_: 1
			}), createVNode(Section_default, null, {
				title: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode("Danger Zone", -1)])]),
				default: withCtx(() => [createElementVNode("div", _hoisted_7, [_cache[8] || (_cache[8] = 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), {
					disabled: __props.isDraftDocument,
					size: "sm",
					variant: "danger",
					onClick: handleDeleteClick
				}, {
					default: withCtx(() => [..._cache[7] || (_cache[7] = [createTextVNode(" Delete Collection ", -1)])]),
					_: 1
				}, 8, ["disabled"])])]),
				_: 1
			})]), createVNode(unref(ScalarModal), {
				size: "xxs",
				state: unref(deleteModal),
				title: `Delete ${__props.title}`
			}, {
				default: withCtx(() => [createVNode(DeleteSidebarListElement_default, {
					variableName: __props.title ?? "",
					warningMessage: "This action cannot be undone.",
					onClose: _cache[1] || (_cache[1] = ($event) => unref(deleteModal).hide()),
					onDelete: handleDocumentDelete
				}, null, 8, ["variableName"])]),
				_: 1
			}, 8, ["state", "title"])], 64);
		};
	}
});
//#endregion
export { DocumentSettings_vue_vue_type_script_setup_true_lang_default as default };

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