import { useWorkspace } from "../../store/store.js";
import CommandActionForm_default from "./CommandActionForm.vue.js";
import CommandActionInput_default from "./CommandActionInput.vue.js";
import { createBlock, createTextVNode, createVNode, defineComponent, openBlock, ref, withCtx } from "vue";
import { useToasts } from "@scalar/use-toasts";
import { useRouter } from "vue-router";
//#region src/components/CommandPalette/CommandPaletteWorkspace.vue?vue&type=script&setup=true&lang.ts
var CommandPaletteWorkspace_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "CommandPaletteWorkspace",
	emits: ["close", "back"],
	setup(__props, { emit: __emit }) {
		const emits = __emit;
		const { push } = useRouter();
		const { toast } = useToasts();
		const { workspaceMutators } = useWorkspace();
		const workspaceName = ref("");
		const handleSubmit = () => {
			if (!workspaceName.value.trim()) {
				toast("Please enter a name before creating a workspace.", "error");
				return;
			}
			push({
				name: "workspace",
				params: { workspace: workspaceMutators.add({ name: workspaceName.value }).uid }
			});
			emits("close");
		};
		return (_ctx, _cache) => {
			return openBlock(), createBlock(CommandActionForm_default, {
				disabled: !workspaceName.value.trim(),
				onSubmit: handleSubmit
			}, {
				submit: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("Create Workspace", -1)])]),
				default: withCtx(() => [createVNode(CommandActionInput_default, {
					modelValue: workspaceName.value,
					"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => workspaceName.value = $event),
					label: "Workspace Name",
					placeholder: "Workspace Name",
					onOnDelete: _cache[1] || (_cache[1] = ($event) => emits("back", $event))
				}, null, 8, ["modelValue"])]),
				_: 1
			}, 8, ["disabled"]);
		};
	}
});
//#endregion
export { CommandPaletteWorkspace_vue_vue_type_script_setup_true_lang_default as default };

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