'use client';
"use strict";var e=require("react/jsx-runtime"),l=require("react"),n=require("@gem-sdk/core"),s=require("../../common/const.js"),t=require("../common/helpers.js"),i=require("react-dom");const r=({title:i,content:r,willUnmount:o,closeOnEscape:a,onKeypressEscape:p,keyCodeForClose:c,closeOnClickOutside:g,onClickOutside:d,buttons:u,dialogId:m,overlayClassName:x,className:f})=>{let C=l.useRef(null),b=l.useCallback(()=>{t.removeBodyClass(),t.removeElementReconfirm(m)},[m]),k=l.useCallback(e=>{let l=e.code;c?.includes(l)&&b(),a&&"Escape"===l&&(p?.(e),b())},[b,a,c,p]);l.useEffect(()=>(document.addEventListener("keydown",k,!1),()=>{document.removeEventListener("keydown",k,!1),o?.()}),[k,o]);let h=e=>{e.onClick&&e.onClick(),b()};return e.jsx("div",{className:"gp-fixed gp-inset-0 gp-z-100 gp-overflow-y-auto",style:{zIndex:s.ELEMENT_Z_INDEX.CART_DRAWER_CONFIRM_MODAL},children:e.jsxs("div",{className:"gp-min-h-screen gp-px-4 gp-text-center",children:[e.jsx("div",{ref:C,className:n.cls("gp-fixed gp-inset-0 gp-bg-black/60 gp-backdrop-blur-sm",x),onClick:e=>{let l=e.target===C.current;g&&l&&(d?.(),b())},"aria-hidden":!0}),e.jsx("span",{className:"gp-inline-block gp-h-screen gp-align-middle"}),e.jsxs("div",{className:n.cls("gp-relative gp-my-8 gp-inline-flex gp-min-w-[320px] gp-flex-col gp-overflow-hidden gp-bg-white gp-p-6 gp-text-left gp-align-middle gp-shadow-xl gp-transition-all",f),children:[i,r,e.jsx("div",{className:"gp-flex gp-justify-center gp-gap-4 gp-pt-6",children:u?.map((l,s)=>e.jsx("button",{onClick:()=>h(l),className:n.cls("gp-inline-flex gp-select-none gp-items-center gp-justify-center gp-rounded-md gp-border gp-border-transparent gp-bg-slate-400 gp-py-2 gp-px-5 gp-text-base gp-font-medium gp-text-white gp-shadow-sm gp-transition-all gp-duration-300 gp-ease-in-out",l.className),children:l.label},s))})]})]})})};r.defaultProps={buttons:[{label:"Cancel",onClick:()=>null},{label:"Confirm",onClick:()=>null}],closeOnClickOutside:!0,closeOnEscape:!0,keyCodeForClose:[],willUnmount:()=>null,afterClose:()=>null,onClickOutside:()=>null,onKeypressEscape:()=>null},exports.openConfirm=function(l){t.addBodyClass(),function(l){let n=t.getOrCreateRootDialog(l.dialogId);i.render(e.jsx(r,{...l}),n)}({...l,dialogId:`dialog-${Math.floor(1e5*Math.random())}`})};
