import { useActiveEntities } from "../../store/active-entities.js";
import { useWorkspace } from "../../store/store.js";
import IconSelector_default from "../IconSelector.vue.js";
import CommandActionForm_default from "./CommandActionForm.vue.js";
import CommandActionInput_default from "./CommandActionInput.vue.js";
import { createBlock, createTextVNode, createVNode, defineComponent, openBlock, ref, unref, withCtx } from "vue";
import { ScalarButton } from "@scalar/components";
import { useToasts } from "@scalar/use-toasts";
import { LibraryIcon } from "@scalar/icons/library";
//#region src/components/CommandPalette/CommandPaletteCollection.vue?vue&type=script&setup=true&lang.ts
var CommandPaletteCollection_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "CommandPaletteCollection",
	emits: ["close", "back"],
	setup(__props, { emit: __emit }) {
		const emits = __emit;
		const { activeWorkspace } = useActiveEntities();
		const { collectionMutators } = useWorkspace();
		const collectionName = ref("");
		const collectionIcon = ref("interface-content-folder");
		const { toast } = useToasts();
		const handleSubmit = () => {
			if (!collectionName.value) {
				toast("Please enter a name before creating a collection.", "error");
				return;
			}
			if (!activeWorkspace.value?.uid) {
				toast("No active workspace found.", "error");
				return;
			}
			collectionMutators.add({
				"openapi": "3.1.0",
				"info": {
					title: collectionName.value,
					version: "0.0.1"
				},
				"x-scalar-icon": collectionIcon.value
			}, activeWorkspace.value?.uid);
			emits("close");
		};
		return (_ctx, _cache) => {
			return openBlock(), createBlock(CommandActionForm_default, {
				disabled: !collectionName.value.trim(),
				onSubmit: handleSubmit
			}, {
				options: withCtx(() => [createVNode(IconSelector_default, {
					modelValue: collectionIcon.value,
					"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => collectionIcon.value = $event),
					placement: "bottom-start"
				}, {
					default: withCtx(() => [createVNode(unref(ScalarButton), {
						class: "aspect-square h-auto px-0",
						variant: "outlined"
					}, {
						default: withCtx(() => [createVNode(unref(LibraryIcon), {
							class: "text-c-2 size-4 stroke-[1.75]",
							src: collectionIcon.value
						}, null, 8, ["src"])]),
						_: 1
					})]),
					_: 1
				}, 8, ["modelValue"])]),
				submit: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode(" Create Collection ", -1)])]),
				default: withCtx(() => [createVNode(CommandActionInput_default, {
					modelValue: collectionName.value,
					"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => collectionName.value = $event),
					label: "Collection Name",
					placeholder: "Collection Name",
					onOnDelete: _cache[1] || (_cache[1] = ($event) => emits("back", $event))
				}, null, 8, ["modelValue"])]),
				_: 1
			}, 8, ["disabled"]);
		};
	}
});
//#endregion
export { CommandPaletteCollection_vue_vue_type_script_setup_true_lang_default as default };

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