import{b as W}from"./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";import{d as H,b$ as R,r as k,cs as S,a4 as m,l as u,c as A,o as F,cr as q,aa as z,c6 as G,w as d,D as U,H as J,ab as f,j as C,B as K,p as I,A as T,G as O,i as Q,E as Z,c5 as ee,ac as te,cl as oe}from"./index-9PRMimni.js";const ne=function(g,p){if(!g)return;const v={target:g,bounding:window,edgeLock:!0,onMove:function(){},onEnd:function(){}};p=p||{};const i={};for(const e in v)typeof p[e]<"u"?i[e]=p[e]:i[e]=v[e];const a=i.target,l=i.bounding;let n=l,c={start:"mousedown",move:"mousemove",end:"mouseup"};"ontouchstart"in document&&(c={start:"touchstart",move:"touchmove",end:"touchend"});const o={};g.addEventListener(c.start,function(e){if((!window.WeakMap||typeof document.msHidden<"u")&&e.preventDefault(),e.touches&&e.touches.length&&(e=e.touches[0]),o.y=e.pageY,o.x=e.pageX,o.isMoving=!0,o.top=parseFloat(getComputedStyle(a).top)||0,o.left=parseFloat(getComputedStyle(a).left)||0,i.edgeLock===!0&&l){l===window?n={left:0,top:0,bottom:innerHeight,right:Math.min(innerWidth,document.documentElement.clientWidth)}:l.tagName&&(n=l.getBoundingClientRect());const s=a.getBoundingClientRect();o.range={y:[n.top-s.top,n.bottom-s.bottom],x:[n.left-s.left,n.right-s.right]}}}),document.addEventListener(c.move,function(e){if(o.isMoving){e.preventDefault(),e.touches&&e.touches.length&&(e=e.touches[0]);let s=e.pageY-o.y,r=e.pageX-o.x;if(i.edgeLock===!0&&l){const w=Math.min.apply(null,o.range.x),h=Math.max.apply(null,o.range.x),M=Math.min.apply(null,o.range.y),b=Math.max.apply(null,o.range.y);r<w?r=w:r>h&&(r=h),s<M?s=M:s>b&&(s=b)}const x=o.top+s,_=o.left+r;a.style.top=x+"px",a.style.left=_+"px",i.onMove(_,x)}},{passive:!1}),document.addEventListener(c.end,function(){o.isMoving&&(o.isMoving=!1,i.onEnd())})},se=["id"],ce=H({__name:"basicModal",props:{...W},emits:["on-close","on-ok","register"],setup(g,{expose:p,emit:v}){const i=R(),a=g,l=v,n=k(null),c=k(!1),o=k(!1),e=S("basic-modal-"),s=S("basic-modal-bar-"),r=m(()=>({...a,...u(n)})),x=m(()=>{const{width:t}=u(n);return{width:`${t||a.width}px`}}),_=m(()=>{const{subBtuText:t}=n.value;return t||a.subBtuText}),w=m(()=>{const{cancelText:t}=n.value;return t||a.cancelText});async function h(t){n.value=ee(u(n)||{},t)}const M=m(()=>u(r).isDraggable),b=m(()=>({...i,...u(r),...u(n)}));function E(t){o.value=t}function $(){c.value=!0,u(r).isDraggable&&te(()=>{const t=document.getElementById(e),y=document.getElementById(s);if(!t||!y){console.warn("not found modal");return}ne(y,{target:t})})}function B(){c.value=!1,o.value=!1,l("on-close")}function j(){c.value=!1,l("on-close")}function D(){o.value=!0,l("on-ok")}const N={setProps:h,openModal:$,closeModal:B,setSubLoading:E};return oe()&&l("register",N),p({openModal:$,closeModal:B,setProps:h,setSubLoading:E,handleSubmit:D}),(t,y)=>{const V=O,L=K,X=J,Y=q;return F(),A(Y,z({id:u(e),key:u(e)},b.value,{style:x.value,show:c.value,"onUpdate:show":y[0]||(y[0]=P=>c.value=P),onClose:j}),G({header:d(()=>[Q("div",{id:u(s),class:Z(["w-full",{"cursor-move":M.value}])},T(b.value.title),11,se)]),default:d(()=>[C(V,{class:"w-full mt-0 border-t-[1.2px]"}),f(t.$slots,"default")]),prefix:d(()=>[f(t.$slots,"prefix ")]),suffix:d(()=>[f(t.$slots,"suffix")]),_:2},[a.showAction&&!t.$slots.action?{name:"action",fn:d(()=>[t.$slots.action?U("",!0):(F(),A(X,{key:0,class:"flex-1",justify:"center"},{default:d(()=>[f(t.$slots,"prefixFooter"),C(L,{class:"w-24",style:{"--n-color":"#E4F4ED","--n-text-color":"#6DA18A"},onClick:B},{default:d(()=>[I(T(w.value),1)]),_:1}),f(t.$slots,"centerFooter"),C(L,{class:"w-24",loading:o.value,type:"primary",onClick:D},{default:d(()=>[I(T(_.value),1)]),_:1},8,["loading"]),f(t.$slots,"suffixFooter")]),_:3}))]),key:"0"}:void 0,a.showAction&&t.$slots.action?{name:"action",fn:d(()=>[f(t.$slots,"action")]),key:"1"}:void 0]),1040,["id","style","show"])}}});export{ce as _};
