import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, openBlock, toDisplayString, unref, withCtx } from "vue";
import { ScalarButton, ScalarLoading, ScalarToggle } from "@scalar/components";
//#region src/v2/features/collection/components/Editor/components/EditorSavePanel.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = { class: "bg-b-1 pointer-events-auto flex flex-col items-stretch overflow-hidden rounded-lg border shadow-sm" };
var _hoisted_2 = { class: "flex items-center gap-2 px-2 py-1.5" };
var _hoisted_3 = { class: "min-w-[48px]" };
var _hoisted_4 = {
	key: 1,
	class: "text-c-3 flex h-6 items-center justify-center rounded px-2 text-[11px] whitespace-nowrap"
};
var _hoisted_5 = {
	key: 0,
	class: "bg-b-2/40 flex items-center gap-2 border-t px-2 py-1 text-[11px]"
};
var EditorSavePanel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "EditorSavePanel",
	props: {
		isAutoSaveEnabled: { type: Boolean },
		isDirty: { type: Boolean },
		saveLoader: {}
	},
	emits: ["update:isAutoSaveEnabled", "saveNow"],
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		const editorStatusText = computed(() => {
			if (!__props.isAutoSaveEnabled && __props.isDirty) return "Unsaved";
			if (!__props.saveLoader.isActive) return null;
			if (__props.saveLoader.isLoading) return "Saving…";
			if (__props.saveLoader.isInvalid) return "Save failed";
			if (__props.saveLoader.isValid) return "Saved";
			return null;
		});
		const shouldShowEditorStatus = computed(() => editorStatusText.value !== null);
		const editorStatusTone = computed(() => {
			if (!shouldShowEditorStatus.value) return null;
			if (!__props.isAutoSaveEnabled && __props.isDirty) return "warning";
			if (__props.saveLoader.isLoading) return "loading";
			if (__props.saveLoader.isInvalid) return "danger";
			if (__props.saveLoader.isValid) return "success";
			return null;
		});
		const editorStatusDotClass = computed(() => {
			switch (editorStatusTone.value) {
				case "warning": return "bg-c-alert";
				case "success": return "bg-c-accent";
				case "danger": return "bg-c-danger";
				default: return "bg-b-3";
			}
		});
		const editorStatusTextClass = computed(() => {
			switch (editorStatusTone.value) {
				case "warning": return "text-c-alert";
				case "success": return "text-c-accent";
				case "danger": return "text-c-danger";
				default: return "text-c-2";
			}
		});
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [
				_cache[3] || (_cache[3] = createElementVNode("span", { class: "text-c-2 text-[11px] font-medium whitespace-nowrap" }, " Auto-save ", -1)),
				createVNode(unref(ScalarToggle), {
					modelValue: __props.isAutoSaveEnabled,
					"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => emit("update:isAutoSaveEnabled", $event))
				}, null, 8, ["modelValue"]),
				_cache[4] || (_cache[4] = createElementVNode("div", { class: "bg-b-3 mx-1 h-4 w-px" }, null, -1)),
				createElementVNode("div", _hoisted_3, [!__props.isAutoSaveEnabled ? (openBlock(), createBlock(unref(ScalarButton), {
					key: 0,
					disabled: !__props.isDirty || __props.saveLoader.isLoading,
					size: "xs",
					variant: "outlined",
					onClick: _cache[1] || (_cache[1] = ($event) => emit("saveNow"))
				}, {
					default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode(" Save ", -1)])]),
					_: 1
				}, 8, ["disabled"])) : (openBlock(), createElementBlock("div", _hoisted_4, " Auto "))])
			]), shouldShowEditorStatus.value ? (openBlock(), createElementBlock("div", _hoisted_5, [__props.saveLoader.isActive ? (openBlock(), createBlock(unref(ScalarLoading), {
				key: 0,
				class: "self-center",
				loader: __props.saveLoader,
				size: "sm"
			}, null, 8, ["loader"])) : (openBlock(), createElementBlock("span", {
				key: 1,
				class: normalizeClass(["size-1.5 rounded-full", editorStatusDotClass.value])
			}, null, 2)), createElementVNode("span", { class: normalizeClass(["whitespace-nowrap", editorStatusTextClass.value]) }, toDisplayString(editorStatusText.value), 3)])) : createCommentVNode("", true)]);
		};
	}
});
//#endregion
export { EditorSavePanel_vue_vue_type_script_setup_true_lang_default as default };

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