import DeleteSidebarListElement_default from "./Actions/DeleteSidebarListElement.vue.js";
import { Fragment, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, openBlock, ref, unref, withCtx, withModifiers } from "vue";
import { ScalarIcon, ScalarModal, useModal } from "@scalar/components";
import { useClipboard } from "@scalar/use-hooks/useClipboard";
//#region src/components/Sidebar/SidebarListElementActions.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = { class: "absolute right-1 flex opacity-0 group-hover:opacity-100" };
var ModalAction = /* @__PURE__ */ function(ModalAction) {
	ModalAction["Delete"] = "Delete";
	ModalAction["None"] = "None";
	return ModalAction;
}(ModalAction || {});
var SidebarListElementActions_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "SidebarListElementActions",
	props: {
		variable: {},
		warningMessage: {},
		isCopyable: { type: Boolean },
		isDeletable: { type: Boolean },
		isRenameable: { type: Boolean }
	},
	emits: ["delete", "rename"],
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		const currentAction = ref({
			action: ModalAction.None,
			name: ""
		});
		const modalState = useModal();
		const { copyToClipboard } = useClipboard();
		function startActionFlow(action) {
			currentAction.value = {
				action,
				name: __props.variable.name
			};
			modalState.show();
		}
		function handleModalClose() {
			modalState.hide();
			currentAction.value = {
				action: ModalAction.None,
				name: ""
			};
		}
		function handleDelete(id) {
			emit("delete", id);
			handleModalClose();
		}
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock(Fragment, null, [createElementVNode("div", _hoisted_1, [
				__props.isCopyable ? (openBlock(), createElementBlock("button", {
					key: 0,
					class: "text-c-3 hover:bg-b-3 hover:text-c-1 rounded p-[5px]",
					type: "button",
					onClick: _cache[0] || (_cache[0] = ($event) => unref(copyToClipboard)(__props.variable.name))
				}, [createVNode(unref(ScalarIcon), {
					class: "h-3 w-3",
					icon: "Clipboard"
				})])) : createCommentVNode("", true),
				__props.isRenameable ? (openBlock(), createElementBlock("button", {
					key: 1,
					class: "text-c-3 hover:bg-b-3 hover:text-c-1 rounded p-[5px]",
					type: "button",
					onClick: _cache[1] || (_cache[1] = ($event) => emit("rename", __props.variable.uid))
				}, [createVNode(unref(ScalarIcon), {
					class: "h-3 w-3",
					icon: "Edit"
				})])) : createCommentVNode("", true),
				!__props.variable.isDefault && __props.isDeletable ? (openBlock(), createElementBlock("button", {
					key: 2,
					class: "text-c-3 hover:bg-b-3 hover:text-c-1 rounded p-1",
					type: "button",
					onClick: _cache[2] || (_cache[2] = withModifiers(($event) => startActionFlow(ModalAction.Delete), ["prevent"]))
				}, [createVNode(unref(ScalarIcon), {
					class: "h-3.5 w-3.5",
					icon: "Close"
				})])) : createCommentVNode("", true)
			]), createVNode(unref(ScalarModal), {
				size: "sm",
				state: unref(modalState),
				title: `${currentAction.value.action} ${currentAction.value.name}`
			}, {
				default: withCtx(() => [currentAction.value.action === ModalAction.Delete ? (openBlock(), createBlock(DeleteSidebarListElement_default, {
					key: 0,
					variableName: currentAction.value.name,
					warningMessage: __props.warningMessage,
					onClose: handleModalClose,
					onDelete: _cache[3] || (_cache[3] = ($event) => handleDelete(__props.variable.uid))
				}, null, 8, ["variableName", "warningMessage"])) : createCommentVNode("", true)]),
				_: 1
			}, 8, ["state", "title"])], 64);
		};
	}
});
//#endregion
export { SidebarListElementActions_vue_vue_type_script_setup_true_lang_default as default };

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