import CommandActionForm_default from "../../components/CommandPalette/CommandActionForm.vue.js";
import CommandActionInput_default from "../../components/CommandPalette/CommandActionInput.vue.js";
import { createBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, ref, unref, watch, withCtx } from "vue";
import { ScalarModal } from "@scalar/components";
import { useToasts } from "@scalar/use-toasts";
//#region src/views/Cookies/CookieModal.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = { class: "flex h-8 items-start gap-2 text-sm" };
var _hoisted_2 = { class: "flex h-8 items-start gap-2 text-sm" };
var _hoisted_3 = { class: "flex h-8 items-start gap-2 text-sm" };
var CookieModal_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "CookieModal",
	props: { state: {} },
	emits: ["cancel", "submit"],
	setup(__props, { emit: __emit }) {
		const props = __props;
		const emit = __emit;
		const cookieData = ref({
			name: "",
			value: "",
			domain: ""
		});
		const { toast } = useToasts();
		const handleSubmit = () => {
			if (!cookieData.value.name || !cookieData.value.value) {
				toast("Please fill in all fields before adding a cookie.", "error");
				return;
			}
			emit("submit", cookieData.value);
			props.state.hide();
		};
		watch(() => props.state.open, (isOpen) => {
			if (isOpen) cookieData.value = {
				name: "",
				value: "",
				domain: ""
			};
		});
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(ScalarModal), {
				size: "xs",
				state: __props.state,
				title: "Add Cookie"
			}, {
				default: withCtx(() => [createVNode(CommandActionForm_default, {
					disabled: !cookieData.value.name || !cookieData.value.value,
					onCancel: _cache[3] || (_cache[3] = ($event) => emit("cancel")),
					onSubmit: handleSubmit
				}, {
					submit: withCtx(() => [..._cache[7] || (_cache[7] = [createTextVNode("Add Cookie", -1)])]),
					default: withCtx(() => [
						createElementVNode("div", _hoisted_1, [_cache[4] || (_cache[4] = createTextVNode(" Name: ", -1)), createVNode(CommandActionInput_default, {
							modelValue: cookieData.value.name,
							"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => cookieData.value.name = $event),
							autofocus: "",
							class: "!p-0",
							placeholder: "session_id"
						}, null, 8, ["modelValue"])]),
						createElementVNode("div", _hoisted_2, [_cache[5] || (_cache[5] = createTextVNode(" Value: ", -1)), createVNode(CommandActionInput_default, {
							modelValue: cookieData.value.value,
							"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => cookieData.value.value = $event),
							autofocus: "",
							class: "!p-0",
							placeholder: "my-cookie-session-id"
						}, null, 8, ["modelValue"])]),
						createElementVNode("div", _hoisted_3, [_cache[6] || (_cache[6] = createTextVNode(" Domain: ", -1)), createVNode(CommandActionInput_default, {
							modelValue: cookieData.value.domain,
							"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => cookieData.value.domain = $event),
							autofocus: "",
							class: "!p-0",
							placeholder: "example.com"
						}, null, 8, ["modelValue"])])
					]),
					_: 1
				}, 8, ["disabled"])]),
				_: 1
			}, 8, ["state"]);
		};
	}
});
//#endregion
export { CookieModal_vue_vue_type_script_setup_true_lang_default as default };

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