epic-modals 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/backdrop.js +1 -1
  2. package/package.json +1 -1
package/dist/backdrop.js CHANGED
@@ -1 +1 @@
1
- var t=Object.defineProperty,e=(e,i,n)=>((e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n)(e,"symbol"!=typeof i?i+"":i,n);const i=Symbol.for("epic-modals-core");if(typeof globalThis<"u"){const t=globalThis;t[i],t[i]=!0}const n=new Map;let o=0,s=null;function a(t){s=t}let r=null;function d(t){r=t}const l=new Set;let h=!1,c=[],g=[],u=[],m=[],p=[],f=[],w=[],y=[],z=[],v=null;function x(t){v=t}const P=new Map;let M=null;function I(t){M=t}const b=new Map,C=new Set,A=new Set,B=new Set;let H=[];function S(t){H=t}function D(t){c=t}function R(t){g=t}function k(t){u=t}function E(t){m=t}function T(t){p=t}function O(t){f=t}function W(t){w=t}function F(t){y=t}function L(){o++,function(){if(!h){h=!0;try{l.forEach(t=>t())}finally{h=!1}}}()}function _(){return o}function G(t){return l.add(t),()=>l.delete(t)}function $(t,e){return!!n.get(t)||(function(){var t,e;try{const i=import.meta;return!0===(null==(t=i.env)?void 0:t.DEV)||"development"===(null==(e=i.env)?void 0:e.MODE)}catch{return!1}}(),!1)}function Y(t,e){const i=n.get(t);if(null==i||!i.childId)return;const o=n.get(i.childId);if(!o)return;const s=e+2;n.set(i.childId,{...o,zIndex:s}),Y(i.childId,s)}function V(t){if(!n.get(t))return;const e=Math.max(...Array.from(n.values()).map(t=>t.zIndex),0),i=function(t){let e=t,i=n.get(e);for(;null!=i&&i.parentId;)e=i.parentId,i=n.get(e);return e}(t),o=n.get(i);if(!o)return;const s=e+2;n.set(i,{...o,zIndex:s}),Y(i,s),L()}function X(t){const e=n.get(t);if(!e)return!1;const i=Math.max(...Array.from(n.values()).map(t=>t.zIndex),0);return e.zIndex===i&&!e.isMinimized&&!e.isHiddenWithParent}const q=8;function K(t,e,i,n,o={}){const{margin:s=q,allowPartialVisibility:a=!1}=o,r=typeof window<"u"?window.innerWidth:1920,d=typeof window<"u"?window.innerHeight:1080;let l,h,c,g;return a&&i>r-2*s?(l=40-i,h=r-40):(l=s,h=Math.max(s,r-i-s)),a&&n>d-2*s?(c=40-n,g=d-40):(c=s,g=Math.max(s,d-n-s)),{x:Math.max(l,Math.min(h,t)),y:Math.max(c,Math.min(g,e))}}function j(t,e,i,n,o={}){const{margin:s=q}=o,a=(typeof window<"u"?window.innerWidth:1920)-2*s,r=(typeof window<"u"?window.innerHeight:1080)-2*s,d=Math.min(i,a),l=Math.min(n,r),h=K(t,e,d,l,o);return{x:h.x,y:h.y,width:d,height:l}}function N(t,e){return Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x))*Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y))}function U(t,e,i,n,o,s){const a={x:t-s,y:e-s,width:i+2*s,height:n+2*s};let r=0;for(const t of o)r+=N(a,t);return r}function J(t){if(typeof document>"u")return[];const e=[];for(const i of t)try{const t=document.querySelectorAll(i);for(const i of t){const t=i.getBoundingClientRect();t.width>0&&t.height>0&&e.push({x:t.left,y:t.top,width:t.width,height:t.height})}}catch{}return e}function Q(t,e,i,n){const o=t-e,s=i-1;if(o<=0)return{interGap:0,edgeGap:0};if(i<=1)return{interGap:0,edgeGap:o/2};const a=o/(i+1);if(a>=n)return{interGap:a,edgeGap:a};const r=s*n;return o>=r?{interGap:n,edgeGap:(o-r)/2}:{interGap:o/s,edgeGap:0}}function Z(t,e,i,n,o=0){if(0===i.length)return{cols:t,rows:e,score:1/0,positions:new Map};const s=new Array(t).fill(0),a=new Array(e).fill(0);for(let e=0;e<i.length;e++){const n=e%t,o=Math.floor(e/t);s[n]=Math.max(s[n],i[e].width),a[o]=Math.max(a[o],i[e].height)}const r=s.reduce((t,e)=>t+e,0),d=a.reduce((t,e)=>t+e,0);if(r>n.width||d>n.height)return null;const{interGap:l,edgeGap:h}=Q(n.width,r,t,o),{interGap:c,edgeGap:g}=Q(n.height,d,e,o),u=new Map,m=[0];for(let e=0;e<t;e++)m.push(m[e]+s[e]);const p=[0];for(let t=0;t<e;t++)p.push(p[t]+a[t]);for(let e=0;e<i.length;e++){const o=e%t,r=Math.floor(e/t),d=i[e],f=n.x+h+o*l+m[o],w=n.y+g+r*c+p[r],y=f+(s[o]-d.width)/2,z=w+(a[r]-d.height)/2;u.set(d.id,{x:Math.round(y),y:Math.round(z)})}const f=t>1?l:h,w=e>1?c:g;return{cols:t,rows:e,score:(.6*Math.min(f,w)+.4*Math.sqrt(f*w))*(n.width>n.height==t>=e?1.02:1),positions:u}}function tt(t,e){const i=new Map,n=Math.max(...t.map(t=>t.width)),o=Math.max(...t.map(t=>t.height)),s=n+40*(t.length-1),a=o+40*(t.length-1);let r=e.x+(e.width-s)/2,d=e.y+(e.height-a)/2;r=Math.max(e.x,r),d=Math.max(e.y,d);for(let e=0;e<t.length;e++)i.set(t[e].id,{x:Math.round(r+40*e),y:Math.round(d+40*e)});return i}function et(t,e,i={}){const{modalGap:n=16,viewportMargin:o=16,avoidBounds:s=[],avoidMargin:a=24}=i,r=typeof window<"u"?window.innerWidth:1920,d=typeof window<"u"?window.innerHeight:1080,l=new Map,h=t.filter(t=>!t.parentId),c=h.map(t=>({id:t.id,width:t.width,height:t.height}));if(e&&c.push({id:e.id,width:e.width,height:e.height}),0===c.length)return{positions:l};const g=new Map(h.map(t=>[t.id,t.currentPosition]));c.sort((t,e)=>{const i=g.get(t.id),n=g.get(e.id);return(i?i.x+t.width/2:1/0)-(n?n.x+e.width/2:1/0)});const u=function(t,e,i,n,o){let s=i,a=i,r=t-i,d=e-i;for(const i of n){const n=i.y,l=e-(i.y+i.height),h=i.x,c=t-(i.x+i.width);let g;if(i.width>i.height)g=n<=l?"top":"bottom";else if(i.height>i.width)g=h<=c?"left":"right";else{const t=Math.min(n,l,h,c);g=t===n?"top":t===l?"bottom":t===h?"left":"right"}"bottom"===g?d=Math.min(d,i.y-o):"top"===g?a=Math.max(a,i.y+i.height+o):"left"===g?s=Math.max(s,i.x+i.width+o):r=Math.min(r,i.x-o)}return{x:s,y:a,width:Math.max(0,r-s),height:Math.max(0,d-a)}}(r,d,o,s,a);if(1===c.length){const t=c[0],e=u.x+(u.width-t.width)/2,i=u.y+(u.height-t.height)/2;return l.set(t.id,{x:Math.round(e),y:Math.round(i)}),{positions:l}}const m=c.length;let p=null;for(let t=1;t<=m;t++){const e=Z(t,Math.ceil(m/t),c,u,n);e&&(null===p||e.score>p.score)&&(p=e)}if(p){for(const[t,e]of p.positions)l.set(t,e);return{positions:l}}if(e){const t=h.map(t=>({x:t.currentPosition.x,y:t.currentPosition.y,width:t.width,height:t.height})),i=function(t,e,i,n,o=20){const s=n.x+(n.width-t)/2,a=n.y+(n.height-e)/2;if(0===i.length)return{x:Math.round(s),y:Math.round(a)};const r=n.x,d=Math.max(n.x,n.x+n.width-t),l=n.y,h=Math.max(n.y,n.y+n.height-e);if(d<=r||h<=l)return{x:Math.round(s),y:Math.round(a)};const c=(d-r)/o,g=(h-l)/o;let u={x:s,y:a},m=1/0;const p=t*e,f=Math.hypot(n.width/2,n.height/2),w=n.x+n.width/2,y=n.y+n.height/2;for(let n=0;n<=o;n++)for(let s=0;s<=o;s++){const o=r+n*c,a=l+s*g,d=U(o,a,t,e,i,0),h=p>0?d/p:0,z=Math.hypot(o+t/2-w,a+e/2-y),v=.5*h+.5*(f>0?z/f:0);v<m&&(m=v,u={x:o,y:a})}return{x:Math.round(u.x),y:Math.round(u.y)}}(e.width,e.height,t,u);return l.set(e.id,i),{positions:l}}return{positions:tt(c,u)}}function it(t){return t}function nt(t){return typeof document>"u"?null:document.querySelector(`.modal-dialog[data-modal-id="${t}"]`)}function ot(t,e){if(!dt(t))throw new Error(`Cannot call ${e}() on unregistered modal "${String(t)}". Ensure the Modal component is rendered.`)}function st(t,e,i,n){var o;const s=e.x-i.x,a=e.y-i.y;if(0===s&&0===a)return null==(o=null==n?void 0:n.onComplete)||o.call(n),()=>{};const r=(null==n?void 0:n.duration)??300,d=(null==n?void 0:n.easing)??"ease-out";let l=!1;function h(){var t;l||(l=!0,clearTimeout(g),null==(t=null==n?void 0:n.onComplete)||t.call(n))}t.style.left=`${i.x}px`,t.style.top=`${i.y}px`;const c=t.animate([{transform:`translate(${s}px, ${a}px)`},{transform:"translate(0, 0)"}],{duration:r,easing:d,fill:"none"});c.onfinish=h;const g=setTimeout(h,r+100);return function(){l||(l=!0,clearTimeout(g),c.cancel())}}function at(t){return n.get(t)}function rt(t){const e=n.get(t);return(null==e?void 0:e.isOpen)??!1}function dt(t){return n.has(t)}function lt(t){return C.has(t)}function ht(){return n}function ct(){const t=[];for(const e of n.values()){if(!e.isOpen||e.isMinimized||e.isHiddenWithParent||A.has(e.id))continue;const i=nt(e.id);if(!i)continue;const n=e.position??{x:i.getBoundingClientRect().left,y:i.getBoundingClientRect().top},o=e.size??{width:i.offsetWidth,height:i.offsetHeight};t.push({id:e.id,width:o.width,height:o.height,currentPosition:n,parentId:e.parentId})}return t}function gt(t,e,i){if(!$(t))return;(function(t){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))throw new Error(`[epic-modals] Invalid position in updateModalPosition: x=${t.x}, y=${t.y}`)})(e),null!=i&&i.size&&function(t){if(t.width<=0||t.height<=0)throw new Error(`[epic-modals] Invalid dimensions in updateModalPosition: width=${t.width}, height=${t.height}`)}(i.size);const o=n.get(t);if(!o)return;let s=e;if(null!=i&&i.constrain&&o.size&&(s=K(e.x,e.y,o.size.width,o.size.height)),n.set(t,{...o,position:s,size:(null==i?void 0:i.size)??o.size,hasBeenDragged:o.hasBeenDragged||(null==i?void 0:i.drag)||!1}),o.childId){let e=t,i=s;for(;;){const t=n.get(e);if(null==t||!t.childId)break;const o=n.get(t.childId);if(null==o||!o.offsetFromParent)break;const s={x:i.x+o.offsetFromParent.x,y:i.y+o.offsetFromParent.y};n.set(t.childId,{...o,position:s,hasBeenDragged:!0}),e=t.childId,i=s}}if(o.parentId&&o.offsetFromParent){const e=oe();let a=t,r=o;for(;r.parentId&&r.offsetFromParent;){const o=n.get(r.parentId);if(!o)break;const d=a===t?s:n.get(a).position,l={x:d.x-r.offsetFromParent.x,y:d.y-r.offsetFromParent.y};if(!("animated"!==e.parentChild.movementMode||null!=i&&i.realtime)){b.set(r.parentId,l);break}n.set(r.parentId,{...o,position:l,hasBeenDragged:!0}),a=r.parentId,r=o}}L()}function ut(t){const e=n.get(t);if(!e||!e.isAnimatingPosition)return;e.isAnimatingPosition=!1;let i=e.childId;for(;i;){const t=n.get(i);t&&(t.isAnimatingPosition=!1),i=null==t?void 0:t.childId}L()}function mt(t,e){const i=n.get(t);i&&(n.set(t,{...i,...e}),L())}function pt(t){const e=oe();"smart"===e.positioning.strategy&&(s&&clearTimeout(s),a(setTimeout(()=>{const i=ct(),n=J(e.positioning.avoidElements);ft(et(i,t,{modalGap:e.positioning.modalGap,viewportMargin:e.positioning.modalGap,avoidBounds:n,avoidMargin:e.positioning.modalGap}).positions),a(null)},50)))}function ft(t){if(0===t.size)return;const e=[],i=new Map;for(const[e]of t){const t=nt(e),n=t?t.getBoundingClientRect():null;i.set(e,{element:t,rect:n})}for(const[o,s]of t){const t=n.get(o);if(!t)continue;const{element:a,rect:r}=i.get(o)||{element:null,rect:null},d=t.position??(r?{x:r.left,y:r.top}:{x:0,y:0}),l=t.size??(r?{width:r.width,height:r.height}:{width:0,height:0});e.push({id:o,element:a,oldPosition:d,newPosition:s,size:l}),wt(o,d,s,e)}for(const{id:t,newPosition:i,size:o}of e){const e=n.get(t);e&&n.set(t,{...e,position:i,size:o,hasBeenDragged:!0,isAnimatingPosition:!0})}L();for(const{id:t,element:i,oldPosition:n,newPosition:o}of e)i?st(i,n,o,{duration:300,onComplete:()=>ut(t)}):setTimeout(()=>ut(t),400)}function wt(t,e,i,o){const s=n.get(t);if(null==s||!s.childId)return;const a=n.get(s.childId);if(null==a||!a.offsetFromParent)return;const r=nt(s.childId),d={x:e.x+a.offsetFromParent.x,y:e.y+a.offsetFromParent.y},l={x:i.x+a.offsetFromParent.x,y:i.y+a.offsetFromParent.y};o.push({id:s.childId,element:r,oldPosition:d,newPosition:l}),n.set(s.childId,{...a,position:l,hasBeenDragged:!0,isAnimatingPosition:!0}),a.childId&&wt(s.childId,d,l,o)}function yt(){r&&clearTimeout(r),d(setTimeout(()=>{pt(null),d(null)},100))}let zt=!1;function vt(){zt||typeof window>"u"||(window.addEventListener("resize",yt),zt=!0)}function xt(){typeof window>"u"||(window.removeEventListener("resize",yt),zt=!1)}function Pt(t){b.delete(t)}function Mt(t){const e=n.get(t);if(null==e||!e.childId)return;const i=n.get(e.childId);i&&(w.includes(e.childId)||W([...w,e.childId]),i.childId&&Mt(e.childId))}function It(t){const e=n.get(t);if(!e||e.isMinimized)return;if(Pt(t),e.parentId){const t=n.get(e.parentId);if(t&&!t.isMinimized)return void It(e.parentId)}D([...c,t]),e.position&&e.size;const i=e.childId;n.set(t,{...e,isMinimized:!0,lastChildId:i}),H.includes(t)||S([...H,t]),L(),e.childId&&Mt(t),pt(null)}function bt(t){const e=n.get(t);if(!e||!e.isMinimized)return;n.set(t,{...e,isMinimized:!1,isOpen:!0}),T([...p,t]),V(t);const i=e.lastChildId||e.childId;i&&Ct(i),L()}function Ct(t){const e=n.get(t);if(e&&e.isHiddenWithParent){O([...f,t]);const i=e.lastChildId||e.childId;i&&Ct(i)}}function At(t){if(!$(t))return;const e=n.get(t);B.has(t)?(B.delete(t),n.set(t,{...e,isTransparent:!1})):(B.add(t),n.set(t,{...e,isTransparent:!0})),L()}function Bt(t){$(t)&&(y.includes(t)||(F([...y,t]),L()))}function Ht(t){t.classList.add("modal-shake"),t.addEventListener("animationend",()=>{t.classList.remove("modal-shake")},{once:!0})}function St(t){if(!$(t))return;const e=n.get(t);B.delete(t),n.set(t,{...e,isTransparent:!1}),L()}function Dt(t,e,i){Rt(t,i,{parentId:e})}function Rt(t,e,i){const o=oe(),s=n.get(t);if(s&&s.isOpen&&!s.isMinimized&&!s.isHiddenWithParent)return Bt(t),void V(t);if(s&&s.isMinimized)return void bt(t);if("x"in e&&"y"in e)P.set(t,e);else{const i=e.getBoundingClientRect();P.set(t,{x:i.left+i.width/2,y:i.top+i.height/2})}if(null!=i&&i.parentId&&o.features.parentChild){const e=n.get(i.parentId);null!=e&&e.childId&&e.childId!==t&&kt(e.childId,!0),I({parentId:i.parentId,childId:t})}if(g.includes(t)||R([...g,t]),L(),!s)return;const a={isOpen:!0};null!=i&&i.parentId&&o.features.parentChild&&(a.parentId=i.parentId),n.set(t,{...s,...a}),V(t)}function kt(t,e=!1){const i=n.get(t);if(i&&(i.isOpen||i.isMinimized)){if(Pt(t),i.childId&&kt(i.childId,e),i.isMinimized)return S(H.filter(e=>e!==t)),void Tt(t);A.add(t),e?E([...m,t]):k([...u,t]),i.parentId||pt(null),L()}}function Et(t){const e=new Set(t??[]);Array.from(n.keys()).filter(t=>!e.has(t)).forEach(t=>kt(t,!0))}function Tt(t){const e=n.get(t);if(e){if(A.delete(t),e.parentId){const i=n.get(e.parentId);i&&i.childId===t&&n.set(e.parentId,{...i,childId:void 0,lastChildId:t})}n.set(t,{...e,isOpen:!1,isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,position:null,size:null,hasBeenDragged:!1,parentId:void 0,childId:void 0,offsetFromParent:void 0}),L()}}function Ot(t){return c.includes(t)}function Wt(t){return w.includes(t)}function Ft(t){return g.includes(t)}function Lt(t){return u.includes(t)}function _t(t){return m.includes(t)}function Gt(t){E(m.filter(e=>e!==t))}function $t(t){return p.includes(t)}function Yt(t){return f.includes(t)}function Vt(t){return(null==M?void 0:M.childId)===t}function Xt(){return M}function qt(t){if("animated"!==oe().parentChild.movementMode)return;const e=n.get(t);if(null==e||!e.parentId||!e.offsetFromParent||!e.position)return;const i={x:e.position.x-e.offsetFromParent.x,y:e.position.y-e.offsetFromParent.y};b.set(e.parentId,i),L()}const Kt={BASE:0,DROPDOWN:100,STICKY:200,OVERLAY:300,MODAL:400,DOCK:8e3,TOAST:9e3};function jt(){oe().zIndex.base}function Nt(t){const e=oe();return"MODAL"===t?e.zIndex.base:"DOCK"===t?e.zIndex.dock:"TOAST"===t?e.zIndex.toast:Kt[t]}function Ut(){oe().zIndex.base}function Jt(){const t=new Map;return{on(e,i){let n=t.get(e);return n||(n=new Set,t.set(e,n)),n.add(i),()=>{null==n||n.delete(i),0===(null==n?void 0:n.size)&&t.delete(e)}},emit(e,i){const n=t.get(e);n&&n.forEach(t=>t(i))},off(e){e?t.delete(e):t.clear()},listenerCount(e){var i;return(null==(i=t.get(e))?void 0:i.size)??0}}}function Qt(t){return"boolean"==typeof t?{visible:t,blockClicks:t}:t}let Zt={features:{dock:!0,minimize:!0,transparency:!0,resize:!0,drag:!0,focusTrap:!0,animations:!0,backdrop:!0,parentChild:!0},dock:{position:"bottom",labelMode:"beside",enableReorder:!0,enableFreeDrag:!0},animations:{open:400,close:250,minimize:500,restore:400,easing:"cubic-bezier(0.34, 1.56, 0.64, 1)"},appearance:{headerLayout:"macos",defaultWidth:"480px",defaultHeight:"auto",minWidth:280,minHeight:200},zIndex:{base:400,dock:8e3,toast:9e3},parentChild:{movementMode:"animated",animationDuration:300},positioning:{strategy:"smart",modalGap:16,avoidElements:[]},portalTarget:"#modal-portal"},te=0;const ee=new Set;function ie(t){return ee.add(t),()=>ee.delete(t)}function ne(){return te}function oe(){return Zt}function se(t){const e=Zt;Zt=ae(Zt,t),te++,ee.forEach(t=>t()),e.features.dock&&!Zt.features.dock&&(Array.from(n.values()).filter(t=>t.isMinimized).map(t=>t.id).forEach(t=>{const e=n.get(t);if(e){n.set(t,{...e,isMinimized:!1,isOpen:!0}),T([...p,t]),V(t);const i=e.lastChildId||e.childId;i&&Ct(i)}}),S([]),L())}function ae(t,e){var i;return{features:{...t.features,...e.features},dock:{...t.dock,...e.dock},animations:{...t.animations,...e.animations},appearance:{...t.appearance,...e.appearance},zIndex:{...t.zIndex,...e.zIndex},parentChild:{...t.parentChild,...e.parentChild},positioning:{...t.positioning,...e.positioning,avoidElements:(null==(i=e.positioning)?void 0:i.avoidElements)??t.positioning.avoidElements},portalTarget:e.portalTarget??t.portalTarget}}function re(t,e){const i=oe(),n=e?ae(i,e):i;return{isFeatureEnabled:e=>{var i;if(void 0!==(null==(i=null==t?void 0:t.features)?void 0:i[e])){const i=t.features[e];if("backdrop"===e){const t=Qt(i);return t.visible||t.blockClicks}return i}const o=n.features[e];if("backdrop"===e){const t=Qt(o);return t.visible||t.blockClicks}return o},getAppearance:e=>{var i;return void 0!==(null==(i=null==t?void 0:t.appearance)?void 0:i[e])?t.appearance[e]:n.appearance[e]},getPositioning:e=>{var i;return void 0!==(null==(i=null==t?void 0:t.positioning)?void 0:i[e])?t.positioning[e]:n.positioning[e]},getEffectiveConfig:()=>n}}function de(t){return{id:t.id,title:t.title,icon:t.icon??"",isOpen:t.autoOpen??!1,isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,isRejected:!1,position:null,size:null,hasBeenDragged:!1,dockPosition:0,glow:t.glow??null,parentId:void 0,childId:void 0,offsetFromParent:void 0}}function le(t){const e=n.get(t.id);let i;i=null!=e&&e.zIndex?e.zIndex:Math.max(...Array.from(n.values()).map(t=>t.zIndex),oe().zIndex.base-2)+2;const o=g.includes(t.id),s=t.isOpen||o;e?n.set(t.id,{...e,title:t.title,icon:t.icon,glow:t.glow,zIndex:i}):n.set(t.id,{...t,isOpen:s,zIndex:i,isAnimating:!1}),L(),t.isMinimized&&!H.includes(t.id)&&S([...H,t.id])}function he(t){const e=n.get(t);if(e){if(S(H.filter(e=>e!==t)),R(g.filter(e=>e!==t)),k(u.filter(e=>e!==t)),E(m.filter(e=>e!==t)),D(c.filter(e=>e!==t)),T(p.filter(e=>e!==t)),O(f.filter(e=>e!==t)),W(w.filter(e=>e!==t)),F(y.filter(e=>e!==t)),e.childId){const t=n.get(e.childId);t&&n.set(e.childId,{...t,parentId:void 0})}if(e.parentId){const t=n.get(e.parentId);t&&n.set(e.parentId,{...t,childId:void 0,lastChildId:e.id})}n.delete(t),L(),B.delete(t),C.delete(t)}}class ce{constructor(t={}){e(this,"element",null),e(this,"resizeHandler",null),e(this,"options"),this.options=t}mount(t){var e,i;this.element=t,this.options.onWindowResize&&(this.resizeHandler=this.options.onWindowResize,window.addEventListener("resize",this.resizeHandler)),null==(i=(e=this.options).onMount)||i.call(e)}destroy(){var t,e;this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=null),this.element=null,null==(e=(t=this.options).onDestroy)||e.call(t)}getElement(){return this.element}isMounted(){return null!==this.element}}const ge={modal:"modal-dialog",header:"modal-header",headerDraggable:"modal-header-draggable",body:"modal-body",footer:"modal-footer",childOverlay:"modal-child-overlay",overlayClosing:"modal-overlay-closing",headerTitle:"modal-header-title",headerIcon:"modal-header-icon",headerTitleGroup:"modal-header-title-group",headerActions:"modal-header-actions",headerTrafficLights:"modal-header-traffic-lights",headerLight:"modal-header-light",headerLightClose:"modal-header-light-close",headerLightMinimize:"modal-header-light-minimize",headerLightStyle:"modal-header-light-style",headerLightDisabled:"modal-header-light-disabled",headerMacCenter:"modal-header-mac-center",headerMacSpacer:"modal-header-mac-spacer",headerBtnWindows:"modal-header-btn-windows",headerBtnWindowsClose:"modal-header-btn-windows-close",headerBtnWindowsStyle:"modal-header-btn-windows-style",headerBtnWindowsDisabled:"modal-header-btn-windows-disabled",resizeHandles:"modal-resize-handles",resizeHandle:"modal-resize-handle",resizePrefix:"modal-resize-",dock:"modal-dock",dockContainer:"modal-dock-container",dockItem:"modal-dock-item",dockItemHasGlow:"modal-dock-item-has-glow",dockItemHasChild:"modal-dock-item-has-child",dockItemLabelBeside:"modal-dock-item-label-beside",dockItemLabelBelow:"modal-dock-item-label-below",dockItemIcon:"modal-dock-item-icon",dockItemIconPlaceholder:"modal-dock-item-icon-placeholder",dockItemLabel:"modal-dock-item-label",dockItemGlow:"modal-dock-item-glow",dockChildIndicator:"modal-dock-child-indicator",dockHandle:"modal-dock-handle",dockHandleDragging:"modal-dock-handle-dragging",backdrop:"modal-backdrop",backdropVisible:"modal-backdrop-visible"},ue={dialog:ge.modal,header:ge.header,headerDraggable:ge.headerDraggable,body:ge.body,footer:ge.footer,childOverlay:ge.childOverlay,headerTitle:ge.headerTitle,headerIcon:ge.headerIcon,headerTitleGroup:ge.headerTitleGroup,headerActions:ge.headerActions,headerTrafficLights:ge.headerTrafficLights,headerLight:ge.headerLight,headerLightClose:ge.headerLightClose,headerLightMinimize:ge.headerLightMinimize,headerLightStyle:ge.headerLightStyle,headerLightDisabled:ge.headerLightDisabled,headerMacCenter:ge.headerMacCenter,headerMacSpacer:ge.headerMacSpacer,headerBtnWindows:ge.headerBtnWindows,headerBtnWindowsClose:ge.headerBtnWindowsClose,headerBtnWindowsStyle:ge.headerBtnWindowsStyle,headerBtnWindowsDisabled:ge.headerBtnWindowsDisabled,resizeHandles:ge.resizeHandles,resizeHandle:ge.resizeHandle,resizePrefix:ge.resizePrefix,dock:ge.dock,dockContainer:ge.dockContainer,dockItem:ge.dockItem,dockItemHasGlow:ge.dockItemHasGlow,dockItemHasChild:ge.dockItemHasChild,dockItemLabelBeside:ge.dockItemLabelBeside,dockItemLabelBelow:ge.dockItemLabelBelow,dockItemIcon:ge.dockItemIcon,dockItemIconPlaceholder:ge.dockItemIconPlaceholder,dockItemLabel:ge.dockItemLabel,dockItemGlow:ge.dockItemGlow,dockChildIndicator:ge.dockChildIndicator,dockHandle:ge.dockHandle,backdrop:ge.backdrop,backdropVisible:ge.backdropVisible},me={modalId:"data-modal-id",resizeDirection:"data-direction"},pe=["n","s","e","w","ne","nw","se","sw"],fe={n:"Resize north",s:"Resize south",e:"Resize east",w:"Resize west",ne:"Resize northeast",nw:"Resize northwest",se:"Resize southeast",sw:"Resize southwest"},we={minWidth:280,minHeight:200},ye=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function ze(t,e){const i=document.querySelector(`.modal-dock-item[data-modal-id="${t}"]`);if(i){const t=i.getBoundingClientRect();return{x:t.left+t.width/2,y:t.top+t.height/2}}const n=document.querySelector('[data-dock-container="true"]');if(n){const t=n.getBoundingClientRect();return{x:t.left+t.width/2,y:t.top+t.height/2}}return{x:typeof window<"u"?window.innerWidth/2:0,y:typeof window<"u"?window.innerHeight-40:0}}function ve(t,e){return function(t,e,i={}){const{timeout:n=5e3,useObservers:o=!0}=i;return new Promise((i,s)=>{const a=performance.now();let r=null,d=null,l=null,h=null,c=!1;const g=()=>{c=!0,null==r||r.disconnect(),null==d||d.disconnect(),l&&clearTimeout(l),h&&cancelAnimationFrame(h)},u=()=>{if(c)return;const n=t();n&&e(n)&&(g(),i(n))};l=setTimeout(()=>{c||(g(),s(new Error(`DOM not ready after ${n}ms`)))},n);const m=t();if(m&&e(m))return g(),void i(m);if(o&&m){r=new MutationObserver(u),r.observe(m,{attributes:!0,attributeFilter:["class","data-state","data-animation-phase","style"],childList:!0,subtree:!1}),d=new ResizeObserver(u),d.observe(m);const t=()=>{c||(u(),c||(h=requestAnimationFrame(()=>{setTimeout(t,100)})))};t()}else{const o=()=>{if(c)return;const s=t(),r=performance.now()-a;if(s&&e(s))return g(),void i(s);r>=n||(h=requestAnimationFrame(o))};o()}})}(t,t=>t.offsetWidth>0&&t.offsetHeight>0,e)}const xe="modal-genie-minimize",Pe="modal-genie-restore",Me="modal-close",Ie="modal-close-centered",be="modal-child-appear",Ce="modal-child-disappear",Ae={[xe]:["minimize"],[Pe]:["restore","open"],[Me]:["close"],[Ie]:["close"],[be]:["open"],[Ce]:["close"]};class Be{constructor(t){e(this,"id"),e(this,"dataId"),e(this,"configHelper"),e(this,"getDragBehavior"),e(this,"getElement"),this.id=t.id,this.dataId=t.dataId,this.configHelper=t.configHelper,this.getDragBehavior=t.getDragBehavior,this.getElement=t.getElement}constrainToViewport(t){const e=this.getDragBehavior();e.hasBeenDragged()&&e.constrainToViewport(t)}shouldApplySmartPositioning(){return!("smart"!==this.configHelper.getPositioning("strategy")||this.getDragBehavior().hasBeenDragged())}applySmartPositioning(){if("smart"!==this.configHelper.getPositioning("strategy"))return!1;const t=at(this.id),e=Xt();if(null!=t&&t.parentId||e&&e.childId===this.id||null!=t&&t.hasBeenDragged||null!=t&&t.position)return!1;const i=this.getElement()||nt(this.id);if(!i)return!1;const n=i.offsetWidth,o=i.offsetHeight;if(n<=0||o<=0)return!1;const s=this.configHelper.getPositioning("modalGap"),a=ct().filter(t=>t.id!==this.id),r=J(this.configHelper.getPositioning("avoidElements")),d=et(a,{id:this.id,width:n,height:o},{modalGap:s,viewportMargin:s,avoidBounds:r,avoidMargin:s}),l=d.positions.get(this.id);if(!l)return!1;const h=new Map;for(const[t,e]of d.positions)t!==this.id&&h.set(t,e);h.size>0&&ft(h);const c=this.getDragBehavior();return c.setPosition(l),c.setHasBeenDragged(!0),gt(this.id,l,{size:{width:n,height:o}}),!0}scheduleSmartPositioning(){ve(()=>this.getElement()||nt(this.id)).then(()=>{this.applySmartPositioning()}).catch(()=>{this.applySmartPositioning()})}centerChildOnParent(t){var e,i;const o=at(t);if(!o)return!1;const s=this.getElement()||nt(this.id),a=nt(t),r=null==a?void 0:a.getBoundingClientRect(),d=o.position??(r?{x:r.left,y:r.top}:null);if(!d||!s)return!1;const l=(null==(e=o.size)?void 0:e.width)??(null==a?void 0:a.offsetWidth)??(null==r?void 0:r.width)??480,h=(null==(i=o.size)?void 0:i.height)??(null==a?void 0:a.offsetHeight)??(null==r?void 0:r.height)??400,c=s.offsetWidth,g=s.offsetHeight;if(l<=0||h<=0||c<=0||g<=0)return!1;const u={x:d.x+(l-c)/2,y:d.y+(h-g)/2},m=this.getDragBehavior();m.setPosition(u),m.setHasBeenDragged(!0),gt(this.id,u,{size:{width:c,height:g}}),(!o.position||!o.size)&&r&&gt(t,{x:r.left,y:r.top},{size:{width:l,height:h}});const p={x:u.x-d.x,y:u.y-d.y};return function(t,e,i){const o=n.get(t),s=n.get(e);!o||!s||(n.set(t,{...o,childId:e}),n.set(e,{...s,parentId:t,offsetFromParent:i}),V(e),L())}(t,this.id,p),!0}scheduleCenterChildOnParent(t){ve(()=>this.getElement()).then(()=>{this.centerChildOnParent(t)}).catch(()=>{this.centerChildOnParent(t)})}}const He=new WeakMap;function Se(t){const e=He.get(t);if(e)return e.elements;const i=De(t),n=new MutationObserver(()=>{!function(t){const e=He.get(t);e&&(e.elements=De(t))}(t)});return n.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["disabled","tabindex","href","hidden"]}),He.set(t,{elements:i,observer:n}),i}function De(t){return Array.from(t.querySelectorAll(ye)).filter(t=>null!==t.offsetParent||"A"===t.tagName)}class Re{constructor(t){e(this,"options"),this.options=t}startDrag(t){const e=this.options.getElement();!this.options.configHelper.isFeatureEnabled("drag")||!e||this.options.getDragBehavior().onPointerDown(t,e)}startResize(t,e){const i=this.options.getState();!this.options.configHelper.isFeatureEnabled("resize")||i.hasChild||this.options.getResizeBehavior().startResize(t,e)}handlePointerMove(t){const e=this.options.getElement();if(!e)return;const i=this.options.getDragBehavior(),n=i.isDragging(),o=this.options.getResizeBehavior(),s=o.hasBeenResized()?o.getSize():{width:e.offsetWidth,height:e.offsetHeight};i.onPointerMove(t,s),n&&i.isDragging()&&this.options.onDragMove()}handlePointerUp(t){const e=this.options.getElement();if(!e)return;const i=this.options.getDragBehavior(),n=i.isDragging();i.onPointerUp(t,e),n&&!this.options.getResizeBehavior().justFinishedResizing()&&this.options.onDragEnd()}handleKeyDown(t){var e,i;this.options.closeOnEscape&&"Escape"===t.key&&this.options.isTopModal()&&(t.stopPropagation(),null==(i=(e=this.options).onClose)||i.call(e))}updateCloseOnEscape(t){this.options.closeOnEscape=t}handleTabKey(t){const e=this.options.getElement();e&&function(t,e){if("Tab"!==t.key)return;const i=Se(e);if(0===i.length)return void t.preventDefault();const n=i[0],o=i[i.length-1],s=document.activeElement;t.shiftKey?s===n&&(o.focus(),t.preventDefault()):s===o&&(n.focus(),t.preventDefault())}(t,e)}focusFirst(){const t=this.options.getElement();t&&function(t){const e=Se(t);e.length>0&&e[0].focus()}(t)}}class ke{constructor(t){e(this,"id"),e(this,"options"),e(this,"_isHandlingMinimize",!1),e(this,"_isAttentionAnimating",!1),e(this,"_wasRestored"),e(this,"_glowStabilizing",!1),e(this,"_restoreHold",!1),e(this,"_isAnimatingToCenter",!1),e(this,"_cancelParentAnimationCleanup",null),e(this,"_parentFlipInFlight",!1),e(this,"_deferredParentTarget",null),e(this,"_parentFlipStartTime",0),e(this,"_isHandlingPendingStates",!1),this.id=t.id,this.options=t,this._wasRestored=!1}handlePendingStates(){if(!this._isHandlingPendingStates&&at(this.id)){this._isHandlingPendingStates=!0;try{if(this.handlePendingForceClose()||(this.handlePendingMinimize(),this.handlePendingMinimizeWithParent(),this.handlePendingRestore(),this.handlePendingChildRestore(),this.handlePendingClose()))return;const t=this.handlePendingParentLink(),e=this.handlePendingOpen(t);this.handlePendingAttention(),this.handlePendingParentAnimation(),this.handleChildCentering(t,e)}finally{this._isHandlingPendingStates=!1}}}handlePendingForceClose(){var t,e;return!!_t(this.id)&&(Gt(this.id),Tt(this.id),null==(e=(t=this.options.options).onClose)||e.call(t),!0)}handlePendingMinimize(){if(!Ot(this.id)||this._isHandlingMinimize)return;this._isHandlingMinimize=!0,x(null);const t=this.options.getElement();if(t){const e=this.options.getDragBehavior(),i=this.options.getResizeBehavior(),n=t.getBoundingClientRect(),o=e.hasBeenDragged()?e.getPosition():{x:n.left,y:n.top},s=i.hasBeenResized()?i.getSize():{width:n.width,height:n.height};mt(this.id,{position:o,size:s,hasBeenDragged:!0})}this.options.getAnimationController().startMinimize(void 0,()=>{var t;t=this.id,D(c.filter(e=>e!==t)),x(null),this._isHandlingMinimize=!1})||(this._isHandlingMinimize=!1)}handlePendingMinimizeWithParent(){if(!Wt(this.id)||this._isHandlingMinimize)return;this._isHandlingMinimize=!0;const t=this.options.getElement();if(t){const e=this.options.getDragBehavior(),i=this.options.getResizeBehavior(),n=t.getBoundingClientRect(),o=e.hasBeenDragged()?e.getPosition():{x:n.left,y:n.top},s=i.hasBeenResized()?i.getSize():{width:n.width,height:n.height};mt(this.id,{position:o,size:s,hasBeenDragged:!0})}this.options.getAnimationController().startMinimize(void 0,()=>{var t;t=this.id,W(w.filter(e=>e!==t)),function(t){const e=n.get(t);e&&(n.set(t,{...e,isHiddenWithParent:!0}),L())}(this.id),this._isHandlingMinimize=!1})}handlePendingRestore(){if(!$t(this.id))return;const t=at(this.id),e=this.options.getAnimationController();var i;i=this.id,T(p.filter(t=>t!==i)),e.startRestore((null==t?void 0:t.position)??void 0,(null==t?void 0:t.size)??void 0),requestAnimationFrame(()=>{this.options.focusFirst()})}handlePendingChildRestore(){if(!Yt(this.id))return;const t=at(this.id),e=this.options.getAnimationController();var i;i=this.id,O(f.filter(t=>t!==i)),e.startRestore((null==t?void 0:t.position)??void 0,(null==t?void 0:t.size)??void 0),function(t){const e=n.get(t);!e||!e.isHiddenWithParent||(n.set(t,{...e,isHiddenWithParent:!1}),L())}(this.id),this._wasRestored=!0}handlePendingClose(){var t,e,i;return!!Lt(this.id)&&(i=this.id,k(u.filter(t=>t!==i)),this.options.getAnimationController().startClose(()=>{var t,e;St(this.id),Tt(this.id),null==(e=(t=this.options.options).onClose)||e.call(t)})||(St(this.id),Tt(this.id),null==(e=(t=this.options.options).onClose)||e.call(t)),!0)}handlePendingParentLink(){const t=Xt();return t&&t.childId===this.id&&(mt(this.id,{parentId:t.parentId}),this._wasRestored=!0),function(t){const e=M;return t&&(null==e?void 0:e.childId)!==t?null:(I(null),e)}(this.id)}handlePendingOpen(t){var e,i;if(!Ft(this.id))return!1;i=this.id,R(g.filter(t=>t!==i));const n=this.options.getDragBehavior(),o=this.options.getResizeBehavior();mt(this.id,{position:null,hasBeenDragged:!1,size:null}),n.setPosition({x:0,y:0}),n.setHasBeenDragged(!1),o.reset();const s=function(t){const e=P.get(t)??null;return P.delete(t),e}(this.id)||this.options.options.openSourcePosition||null,a=!!t||!(null==(e=at(this.id))||!e.parentId);let r=!1;return s?(r=!0,this.options.getAnimationController().setPendingOpenSource(s),a&&t?this.openChildModalWithAnimation(t.parentId):this.openStandaloneModalWithAnimation()):a||this.options.getPositioning().scheduleSmartPositioning(),requestAnimationFrame(()=>{this.options.focusFirst()}),r}openChildModalWithAnimation(t){const e=this.options.getPositioning(),i=this.options.getAnimationController();ve(()=>this.options.getElement()).then(()=>{e.centerChildOnParent(t)&&(i.startOpen(),this._wasRestored=!0)}).catch(()=>{e.centerChildOnParent(t)&&(i.startOpen(),this._wasRestored=!0)})}openStandaloneModalWithAnimation(){const t=this.options.getPositioning(),e=this.options.getAnimationController();ve(()=>this.options.getElement()).then(()=>{t.applySmartPositioning(),e.startOpen()}).catch(()=>{t.applySmartPositioning(),e.startOpen()})}handlePendingAttention(){var t;t=this.id,y.includes(t)&&(function(t){F(y.filter(e=>e!==t)),z.includes(t)||function(t){z=t}([...z,t])}(this.id),this.id,this._isAttentionAnimating=!0,setTimeout(()=>{this._isAttentionAnimating=!1,this.id,this.options.onStateChange()},600))}handlePendingParentAnimation(){if(t=this.id,!b.has(t))return;var t;const e=function(t){const e=b.get(t)??null;return b.delete(t),e}(this.id);if(e){if(this._parentFlipInFlight&&Date.now()-this._parentFlipStartTime<100)return void(this._deferredParentTarget=e);this._deferredParentTarget=null,this.startParentFlip(e)}}startParentFlip(t){var e,i;const n=this.options.getDragBehavior(),o=this.options.getElement(),s=null==o?void 0:o.getBoundingClientRect(),a=s?{x:s.left,y:s.top}:(null==(e=at(this.id))?void 0:e.position)??null;mt(this.id,{position:t,hasBeenDragged:!0,isAnimatingPosition:!0}),n.setPosition(t),n.setHasBeenDragged(!0),null==(i=this._cancelParentAnimationCleanup)||i.call(this),this._parentFlipInFlight=!0,this._parentFlipStartTime=Date.now();const r=this.id,d=()=>{this._parentFlipInFlight=!1,this._cancelParentAnimationCleanup=null,ut(r);const t=this._deferredParentTarget;t?(this._deferredParentTarget=null,this.startParentFlip(t)):qt(r)};o&&a?this._cancelParentAnimationCleanup=st(o,a,t,{duration:300,onComplete:d}):setTimeout(d,400)}handleChildCentering(t,e){t&&this.options.getElement()&&!e&&this.options.getPositioning().scheduleCenterChildOnParent(t.parentId)}get wasRestored(){return this._wasRestored}set wasRestored(t){this._wasRestored=t}get isAttentionAnimating(){return this._isAttentionAnimating}get glowStabilizing(){return this._glowStabilizing}set glowStabilizing(t){this._glowStabilizing=t}get restoreHold(){return this._restoreHold}set restoreHold(t){this._restoreHold=t}get isAnimatingToCenter(){return this._isAnimatingToCenter}set isAnimatingToCenter(t){this._isAnimatingToCenter=t}get isHandlingMinimize(){return this._isHandlingMinimize}}class Ee{constructor(t){var i,n,o,s;e(this,"id"),e(this,"dataId"),e(this,"options"),e(this,"drag"),e(this,"resize"),e(this,"animation"),e(this,"positioning"),e(this,"lifecycle"),e(this,"interactions"),e(this,"stateManager"),e(this,"overlayClosing",!1),e(this,"emitter",Jt()),e(this,"unsubscribeState",null),e(this,"cachedState",null),this.id=t.id,this.dataId=t.id,this.options=t,this.drag=function(t={}){const{initialPosition:e={x:0,y:0},constrain:i=!0}=t,n={...e};let o=!1,s=!1,a=0,r=0,d=0,l=0,h=null,c=null,g=null;const u=Jt();function m(){return{isDragging:o,position:{...n},hasBeenDragged:s}}function p(){u.emit("change",m())}function f(){if(h=null,!c||!g||!o)return;const t=c,e=g;c=null,g=null;const m=t.clientX-a,f=t.clientY-r;let w=d+m,y=l+f;if(i){const t=K(w,y,e.width,e.height);w=t.x,y=t.y}n.x=w,n.y=y,s=!0,u.emit("dragMove",{...n}),p()}return{getState:m,getPosition:()=>({...n}),isDragging:()=>o,hasBeenDragged:()=>s,setPosition:function(t){n.x=t.x,n.y=t.y,p()},setHasBeenDragged:function(t){s=t,p()},reset:function(){n.x=e.x,n.y=e.y,s=!1,o=!1,p()},constrainToViewport:function(t){if(!s)return;const e=K(n.x,n.y,t.width,t.height);n.x=e.x,n.y=e.y,p()},onPointerDown:function(t,e){if(0===t.button){if(!s){const t=e.getBoundingClientRect();n.x=t.left,n.y=t.top}o=!0,a=t.clientX,r=t.clientY,d=n.x,l=n.y,e.setPointerCapture(t.pointerId),u.emit("dragStart",{...n}),p()}},onPointerMove:function(t,e){o&&(c=t,g=e,null===h&&(h=requestAnimationFrame(f)))},onPointerUp:function(t,e){if(o){if(null!==h&&(cancelAnimationFrame(h),h=null),c&&g){const t=c.clientX-a,e=c.clientY-r;let o=d+t,h=l+e;if(i){const t=K(o,h,g.width,g.height);o=t.x,h=t.y}n.x=o,n.y=h,s=!0}c=null,g=null,o=!1,e.releasePointerCapture(t.pointerId),u.emit("dragEnd",{...n}),p()}},subscribe:function(t){return u.on("change",t)},destroy:function(){null!==h&&(cancelAnimationFrame(h),h=null),c=null,g=null,u.off()}}}({initialPosition:{x:0,y:0},constrain:!0}),this.resize=function(t){const{minWidth:e=we.minWidth,minHeight:i=we.minHeight,getPosition:n,setPosition:o,getHasBeenDragged:s,setHasBeenDragged:a,getElement:r,getSymmetricResize:d,onResizeEnd:l}=t;let h=!1,c="",g={width:0,height:0},u=!1,m=!1,p={x:0,y:0,width:0,height:0,posX:0,posY:0,centerX:0,centerY:0},f=null;const w=Jt();let y=null,z=null;function v(){return{isResizing:h,direction:c,size:{...g},hasBeenResized:u}}function x(){w.emit("change",v())}function P(t){if(t.pointerId!==f)return;const n=t.clientX-p.x,s=t.clientY-p.y,a=window.innerWidth,r=window.innerHeight,l=(null==d?void 0:d())??!1;let h=p.width,u=p.height,m=p.posX,y=p.posY;if(l){if(c.includes("e")||c.includes("w")){const t=c.includes("e")?n:-n;h=Math.max(e,p.width+2*t),m=p.centerX-h/2}if(c.includes("s")||c.includes("n")){const t=c.includes("s")?s:-s;u=Math.max(i,p.height+2*t),y=p.centerY-u/2}}else{if(c.includes("e")){const t=a-m;h=Math.max(e,Math.min(p.width+n,t))}if(c.includes("w")){const t=p.width-e,i=Math.min(n,t);h=p.width-i,m=p.posX+i}if(c.includes("s")){const t=r-y;u=Math.max(i,Math.min(p.height+s,t))}if(c.includes("n")){const t=p.height-i,e=Math.min(s,t);u=p.height-e,y=p.posY+e}}const z=j(m,y,h,u);g={width:z.width,height:z.height},o({x:z.x,y:z.y}),w.emit("resizeMove",{size:{...g},position:{x:z.x,y:z.y}}),x()}function M(t){if(t.pointerId!==f)return;h=!1,c="",f=null,y&&window.removeEventListener("pointermove",y),z&&(window.removeEventListener("pointerup",z),window.removeEventListener("pointercancel",z)),y=null,z=null,m=!0;const e=n();w.emit("resizeEnd",{size:{...g},position:e}),l&&l(e,{...g}),x(),setTimeout(()=>{m=!1},0)}return{getState:v,getSize:()=>({...g}),isResizing:()=>h,hasBeenResized:()=>u,justFinishedResizing:()=>m,setSize:function(t){g={...t},u=!0,x()},reset:function(){u=!1,g={width:0,height:0},h=!1,c="",x()},constrainToViewport:function(){const t=n(),e=r();if(!e)return;const i=j(t.x,t.y,g.width||e.offsetWidth,g.height||e.offsetHeight);g={width:i.width,height:i.height},o({x:i.x,y:i.y}),x()},startResize:function(t,e){t.preventDefault(),t.stopPropagation();const i=r();if(!i)return;const d=i.getBoundingClientRect();s()||(o({x:d.left,y:d.top}),a(!0)),u||(g={width:d.width,height:d.height},u=!0);const l=n();h=!0,c=e,f=t.pointerId,p={x:t.clientX,y:t.clientY,width:g.width,height:g.height,posX:l.x,posY:l.y,centerX:l.x+g.width/2,centerY:l.y+g.height/2},y=P,z=M,window.addEventListener("pointermove",y),window.addEventListener("pointerup",z),window.addEventListener("pointercancel",z),w.emit("resizeStart",{direction:e}),x()},subscribe:function(t){return w.on("change",t)},destroy:function(){y&&window.removeEventListener("pointermove",y),z&&(window.removeEventListener("pointerup",z),window.removeEventListener("pointercancel",z)),w.off()}}}({minWidth:(null==(n=null==(i=t.config)?void 0:i.appearance)?void 0:n.minWidth)??oe().appearance.minWidth,minHeight:(null==(s=null==(o=t.config)?void 0:o.appearance)?void 0:s.minHeight)??oe().appearance.minHeight,getPosition:()=>this.drag.getPosition(),setPosition:t=>this.drag.setPosition(t),getHasBeenDragged:()=>this.drag.hasBeenDragged(),setHasBeenDragged:t=>this.drag.setHasBeenDragged(t),getElement:()=>this.element,onResizeEnd:(t,e)=>this.handleResizeEnd(t,e)}),this.animation=function(t){const{getId:e,getElement:i,getPosition:n,setPosition:o,getHasBeenDragged:s,setHasBeenDragged:a,getHasBeenResized:r,getSize:d,areAnimationsEnabled:l=()=>!0,onMinimizeComplete:h,onOpenStart:c}=t;let g="none",u=!1,m=null,p=null,f=null,w=null,y=null,z=null,v=null;const x=Jt();function P(){return{type:g,isAnimating:u,transform:m?{...m}:null}}function M(){x.emit("change",P())}function I(){z&&(clearTimeout(z),z=null)}function b(){const t=i();!t||v||(v=function(t,e){const i=i=>{i.target===t&&e(i.animationName)};return t.addEventListener("animationend",i),()=>t.removeEventListener("animationend",i)}(t,C))}function C(t){I();const e=Ae[t];if(!e||!e.includes(g))return;const i={none:void 0,minimize:A,restore:B,open:H,close:S,attention:void 0}[g];i&&i()}function A(){"minimize"===g&&(I(),w?(w(),w=null):y&&(null==h||h(y.position,!0,y.size)),x.emit("animationEnd",{type:"minimize"}),y=null)}function B(){if("restore"!==g)return;I(),g="none",u=!1,m=null;const t=i();t&&(t.setAttribute("data-state","open"),t.setAttribute("data-animation-phase","idle")),x.emit("animationEnd",{type:"restore"}),M()}function H(){if("open"!==g)return;I(),g="none",u=!1,m=null;const t=i();t&&(t.setAttribute("data-state","open"),t.setAttribute("data-animation-phase","idle")),x.emit("animationEnd",{type:"open"}),M()}function S(){if("close"!==g)return;I(),g="none",u=!1;const t=i();t&&(t.setAttribute("data-state","closed"),t.setAttribute("data-animation-phase","idle")),x.emit("animationEnd",{type:"close"}),f&&(f(),f=null),M()}return{getState:P,isAnimating:()=>u,getAnimationType:()=>g,getTransform:()=>m?{...m}:null,getPendingOpenSource:()=>p?{...p}:null,setPendingOpenSource:t=>{p=t?{...t}:null},startMinimize:function(t,c){const p=i();if(u||!p)return!1;if(b(),I(),!l()){const t=p.getBoundingClientRect(),e=s()?n():{x:t.left,y:t.top},i=r()?d():{width:t.width,height:t.height};return s()||(o(e),a(!0)),c?c():null==h||h(e,!0,i),!0}const f=p.getBoundingClientRect(),v=s()?n():{x:f.left,y:f.top},P=r()?d():{width:f.width,height:f.height};s()||(o(v),a(!0));const C=t??ze(e());return m=function(t,e,i){const n=t.x+e.width/2,o=t.y+e.height/2;return{x:i.x-n,y:i.y-o,originX:i.x-t.x,originY:i.y-t.y}}(v,P,C),w=c||null,y={position:v,size:P},p.setAttribute("data-state","minimizing"),p.setAttribute("data-animation-phase","prepare"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{g="minimize",u=!0,p.setAttribute("data-animation-phase","animate"),x.emit("animationStart",{type:"minimize"}),M()})}),z=setTimeout(()=>{"minimize"===g&&A()},600),!0},startRestore:function(t,n){const s=i();if(b(),I(),!l()){const e=t||{x:window.innerWidth/2,y:window.innerHeight/2};return o(e),void a(!0)}const r=ze(e()),d=t||{x:window.innerWidth/2,y:window.innerHeight/2},h=n||{width:480,height:400};o(d),a(!0),m=function(t,e,i){const n=t.x+e.width/2,o=t.y+e.height/2;return{x:i.x-n,y:i.y-o,originX:i.x-t.x,originY:i.y-t.y}}(d,h,r),g="restore",u=!0,s&&(s.setAttribute("data-state","restoring"),s.setAttribute("data-animation-phase","animate")),x.emit("animationStart",{type:"restore"}),M(),z=setTimeout(()=>{"restore"===g&&B()},500)},startOpen:function(){const t=i();if(!p||!t||u)return!1;if(b(),I(),!l())return p=null,!1;const e=p,r=t.getBoundingClientRect(),d=s()?n():{x:r.left,y:r.top},h=r.width,f=r.height;return s()||(o(d),a(!0)),m=function(t,e,i){const n=t.x+e.width/2,o=t.y+e.height/2;return{x:i.x-n,y:i.y-o,originX:i.x-t.x,originY:i.y-t.y}}(d,{width:h,height:f},e),g="open",u=!0,p=null,t.setAttribute("data-state","opening"),t.setAttribute("data-animation-phase","animate"),x.emit("animationStart",{type:"open"}),null==c||c(),M(),z=setTimeout(()=>{"open"===g&&H()},500),!0},startClose:function(t){const e=i();return!u&&(b(),I(),l()?(f=t,g="close",u=!0,e&&(e.setAttribute("data-state","closing"),e.setAttribute("data-animation-phase","animate")),x.emit("animationStart",{type:"close"}),M(),z=setTimeout(()=>{"close"===g&&S()},350),!0):(t(),!0))},forceClearMinimize:function(){I(),"minimize"===g&&(g="none",u=!1,m=null,w=null,y=null,M())},destroy:function(){I(),null==v||v(),v=null,x.off()},subscribe:t=>x.on("change",t)}}({getId:()=>this.id,getElement:()=>this.element,getPosition:()=>this.drag.getPosition(),setPosition:t=>this.drag.setPosition(t),getHasBeenDragged:()=>this.drag.hasBeenDragged(),setHasBeenDragged:t=>this.drag.setHasBeenDragged(t),getHasBeenResized:()=>this.resize.hasBeenResized(),getSize:()=>this.resize.getSize(),areAnimationsEnabled:()=>this.options.configHelper.isFeatureEnabled("animations"),onMinimizeComplete:(t,e,i)=>{mt(this.id,{position:t,size:i,hasBeenDragged:e}),It(this.id)},onOpenStart:()=>{const t=at(this.id);null!=t&&t.parentId&&(this.stateManager.wasRestored=!0)}}),this.positioning=new Be({id:this.id,dataId:this.dataId,configHelper:t.configHelper,getDragBehavior:()=>this.drag,getElement:()=>this.element}),this.interactions=new Re({id:this.id,configHelper:t.configHelper,getDragBehavior:()=>this.drag,getResizeBehavior:()=>this.resize,getElement:()=>this.element,getState:()=>{var t;return{hasChild:!(null==(t=at(this.id))||!t.childId)}},onDragMove:()=>{if("realtime"===oe().parentChild.movementMode){const t=this.drag.getPosition();gt(this.id,t,{drag:!0,realtime:!0})}},onDragEnd:()=>{const t=this.drag.getPosition();gt(this.id,t,{drag:!0}),"animated"===oe().parentChild.movementMode&&qt(this.id)},onClose:()=>this.close(),closeOnEscape:t.closeOnEscape,isTopModal:()=>X(this.id)}),this.stateManager=new ke({id:this.id,options:{glow:t.glow,openSourcePosition:t.openSourcePosition,onClose:t.onClose},getDragBehavior:()=>this.drag,getResizeBehavior:()=>this.resize,getAnimationController:()=>this.animation,getElement:()=>this.element,getPositioning:()=>this.positioning,onStateChange:()=>this.notifyStateChange(),focusFirst:()=>this.interactions.focusFirst()}),Vt(t.id)&&(this.stateManager.wasRestored=!0),this.lifecycle=new ce({onMount:()=>{this.handleStateChange(),this.handlePendingStates(),this.notifyStateChange()},onDestroy:()=>{var t;null==(t=this.unsubscribeState)||t.call(this),this.drag.destroy(),this.resize.destroy(),this.animation.destroy(),this.emitter.off()},onWindowResize:()=>this.handleWindowResize()}),this.drag.subscribe(()=>this.notifyStateChange()),this.resize.subscribe(()=>this.notifyStateChange()),this.animation.subscribe(()=>{this.handlePendingStates(),this.notifyStateChange()}),this.unsubscribeState=G(()=>{this.handleStateChange(),this.handlePendingStates(),this.notifyStateChange()}),t.skipRegistration||this.register(t.autoOpen??!1),this.handleStateChange(),this.handlePendingStates()}mount(t){this.lifecycle.mount(t)}destroy(){this.lifecycle.destroy()}get element(){return this.lifecycle.getElement()}handleWindowResize(){if(!this.element||!this.drag.hasBeenDragged())return;const t=this.resize.hasBeenResized()?this.resize.getSize():{width:this.element.offsetWidth,height:this.element.offsetHeight};this.positioning.constrainToViewport(t),this.resize.hasBeenResized()&&this.resize.constrainToViewport(),this.notifyStateChange()}register(t){le({id:this.id,title:this.options.title,icon:this.options.icon??"",isOpen:t,isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,isRejected:!1,position:null,size:null,hasBeenDragged:!1,dockPosition:0,glow:this.options.glow??null,parentId:void 0,childId:void 0,offsetFromParent:void 0}),t&&V(this.id)}getState(){if(this.cachedState)return this.cachedState;const t=at(this.id),e=this.drag.getState(),i=this.resize.getState(),n=this.animation.getState(),o=!!t&&(t.isOpen||Lt(this.id))&&(!t.isMinimized||Ot(this.id))&&(!t.isHiddenWithParent||Wt(this.id)||Yt(this.id)),s=!(null==t||!t.childId),a=!(null==t||!t.parentId),r="minimize"===n.type&&n.isAnimating,d="restore"===n.type&&n.isAnimating,l="open"===n.type&&n.isAnimating,h="close"===n.type&&n.isAnimating,c=n.isAnimating,g=(null==t?void 0:t.isAnimatingPosition)??!1,u=g&&null!=t&&t.position?t.position:e.position,m=!!g||e.hasBeenDragged,p=(Yt(this.id)||$t(this.id))&&!d,f=(a||Vt(this.id))&&!l&&(!m||!!this.animation.getPendingOpenSource()),w=d||l||this.stateManager.restoreHold,y=o&&!m&&!c&&!this.animation.getPendingOpenSource()&&!p&&!f;let z="closed";r?z="minimizing":d?z="restoring":l?z="opening":h?z="closing":null!=t&&t.isMinimized?z="minimized":o&&(z="open");const v=this.options.configHelper.isFeatureEnabled("drag"),x=this.options.configHelper.isFeatureEnabled("resize"),P=this.options.configHelper.isFeatureEnabled("minimize"),M=!!this.options.glow,I=function(t){const e={"z-index":t.zIndex};return t.animationTransform?(e.left=`${t.position.x}px`,e.top=`${t.position.y}px`,e["--genie-origin-x"]=`${t.animationTransform.originX}px`,e["--genie-origin-y"]=`${t.animationTransform.originY}px`,e["--genie-translate-x"]=`${t.animationTransform.x}px`,e["--genie-translate-y"]=`${t.animationTransform.y}px`):t.hasBeenDragged&&(e.left=`${t.position.x}px`,e.top=`${t.position.y}px`,t.isAnimatingPosition||(e.transform="none")),t.hasBeenResized?(e.width=`${t.size.width}px`,e.height=`${t.size.height}px`,e["max-width"]="none",e["max-height"]="none"):(t.preferredHeight&&(e["min-height"]=t.preferredHeight),t.maxWidth&&(e["max-width"]=t.maxWidth)),t.glowEnabled&&t.glow&&(e["--modal-glow-color"]=t.glow.color,e["--modal-glow-intensity"]=String(t.glow.intensity??"medium")),e}({position:u,hasBeenDragged:m,hasBeenResized:i.hasBeenResized,size:i.size,animationTransform:n.transform,zIndex:(null==t?void 0:t.zIndex)??1e3,glowEnabled:M,glow:this.options.glow??null,maxWidth:this.options.maxWidth,preferredHeight:this.options.preferredHeight,isAnimatingPosition:g}),b=function(t){const e=["modal-dialog"];return t.isDragging&&e.push("modal-dragging"),t.isResizing&&e.push("modal-resizing"),t.hasBeenDragged&&e.push("modal-positioned"),t.isMinimizing&&e.push("modal-minimizing"),t.isRestoring&&e.push("modal-restoring"),t.isOpening&&e.push("modal-opening"),t.isClosing&&e.push("modal-closing"),t.showCentered&&e.push("modal-centered"),t.isTransparent||e.push("modal-solid"),t.isTransparent&&e.push("modal-transparent"),t.glowEnabled&&e.push("modal-glow"),t.hasChild&&e.push("modal-has-child"),t.isChildModal&&e.push("modal-is-child"),t.wasRestored&&e.push("modal-was-restored"),t.isVisibleByAnimation&&e.push("modal-visible-by-animation"),t.isAwaitingRestore&&e.push("modal-awaiting-restore"),t.isAwaitingChildOpen&&e.push("modal-awaiting-child-open"),t.isAnimatingToCenter&&e.push("modal-animating-to-center"),t.isAnimatingPosition&&e.push("modal-animating-position"),t.isAttentionAnimating&&e.push("modal-attention"),t.glowStabilizing&&t.glowEnabled&&e.push("modal-glow-stabilizing"),e}({isDragging:e.isDragging,isResizing:i.isResizing,hasBeenDragged:m,isMinimizing:r,isRestoring:d,isOpening:l,isClosing:h,showCentered:y,isTransparent:(null==t?void 0:t.isTransparent)??!1,glowEnabled:M,hasChild:s,isChildModal:a,wasRestored:this.stateManager.wasRestored,isVisibleByAnimation:w,isAwaitingRestore:p,isAwaitingChildOpen:f,isAnimatingToCenter:this.stateManager.isAnimatingToCenter,isAnimatingPosition:(null==t?void 0:t.isAnimatingPosition)??!1,isAttentionAnimating:this.stateManager.isAttentionAnimating,glowStabilizing:this.stateManager.glowStabilizing});return this.cachedState={position:e.position,size:i.size,zIndex:(null==t?void 0:t.zIndex)??1e3,isDragging:e.isDragging,isResizing:i.isResizing,hasBeenDragged:e.hasBeenDragged,hasBeenResized:i.hasBeenResized,isMinimizing:r,isRestoring:d,isOpening:l,isClosing:h,isAnyAnimating:c,animationTransform:n.transform,isVisible:o,showCentered:y,isAwaitingRestore:p,isAwaitingChildOpen:f,isVisibleByAnimation:w,hasChild:s,isChildModal:a,showOverlay:s||this.overlayClosing,isTransparent:(null==t?void 0:t.isTransparent)??!1,isAttentionAnimating:this.stateManager.isAttentionAnimating,glowStabilizing:this.stateManager.glowStabilizing,isAnimatingPosition:(null==t?void 0:t.isAnimatingPosition)??!1,isAnimatingToCenter:this.stateManager.isAnimatingToCenter,wasRestored:this.stateManager.wasRestored,overlayClosing:this.overlayClosing,glowEnabled:M,draggable:v,resizable:x,minimizable:P,dataState:z,dataAnimationPhase:n.isAnimating?"animate":"idle",style:I,cssClasses:b},this.cachedState}subscribe(t){return this.emitter.on("stateChange",t)}notifyStateChange(){this.cachedState=null,this.emitter.emit("stateChange",this.getState())}startDrag(t){this.interactions.startDrag(t)}startResize(t,e){this.interactions.startResize(t,e)}handlePointerMove(t){this.interactions.handlePointerMove(t)}handlePointerUp(t){this.interactions.handlePointerUp(t)}handleKeyDown(t){this.interactions.handleKeyDown(t)}handleTabKey(t){this.interactions.handleTabKey(t)}minimize(){this.options.configHelper.isFeatureEnabled("minimize")&&It(this.id)}close(){var t,e;_t(this.id)&&Gt(this.id),kt(this.id),null==(e=(t=this.options).onClose)||e.call(t)}toggleTransparency(){At(this.id)}bringToFront(){V(this.id)}setOpenSourcePosition(t){this.animation.setPendingOpenSource(t)}updateOptions(t){let e=!1;void 0!==t.glow&&this.options.glow!==t.glow&&(this.options.glow=t.glow,mt(this.id,{glow:t.glow??null}),e=!0),void 0!==t.maxWidth&&this.options.maxWidth!==t.maxWidth&&(this.options.maxWidth=t.maxWidth,e=!0),void 0!==t.preferredHeight&&this.options.preferredHeight!==t.preferredHeight&&(this.options.preferredHeight=t.preferredHeight,e=!0),void 0!==t.closeOnEscape&&this.options.closeOnEscape!==t.closeOnEscape&&(this.options.closeOnEscape=t.closeOnEscape,this.interactions.updateCloseOnEscape(t.closeOnEscape)),e&&this.notifyStateChange()}updateGlow(t){this.updateOptions({glow:t})}updateMaxWidth(t){this.updateOptions({maxWidth:t})}updatePreferredHeight(t){this.updateOptions({preferredHeight:t})}updateCloseOnEscape(t){this.updateOptions({closeOnEscape:t})}focusFirst(){this.interactions.focusFirst()}handleResizeEnd(t,e){const i=at(this.id);if(null!=i&&i.parentId){const n=at(i.parentId),o=nt(i.parentId);if(n&&o){const i=n.position??{x:o.getBoundingClientRect().left,y:o.getBoundingClientRect().top},s=n.size??{width:o.offsetWidth,height:o.offsetHeight},a={x:i.x+(s.width-e.width)/2,y:i.y+(s.height-e.height)/2},r=t;this.stateManager.isAnimatingToCenter=!0,this.drag.setPosition(a);const d={x:a.x-i.x,y:a.y-i.y};mt(this.id,{position:a,size:e,hasBeenDragged:!0,offsetFromParent:d});const l=this.lifecycle.getElement();return void(l?st(l,r,a,{duration:200,onComplete:()=>{this.stateManager.isAnimatingToCenter=!1}}):this.stateManager.isAnimatingToCenter=!1)}}mt(this.id,{position:t,size:e,hasBeenDragged:!0})}handleStateChange(){const t=at(this.id);if(t){if((t.parentId||Vt(this.id))&&(this.stateManager.wasRestored=!0),!this.drag.isDragging()&&!this.resize.isResizing()&&t.position){const e=this.drag.getPosition(),i=t.position;(Math.abs(e.x-i.x)>.5||Math.abs(e.y-i.y)>.5)&&(this.drag.setPosition(i),t.hasBeenDragged&&this.drag.setHasBeenDragged(!0))}this.stateManager.handlePendingStates()}}handlePendingStates(){this.stateManager.handlePendingStates()}getId(){return this.id}getDataId(){return this.dataId}getElement(){return this.element}}function Te(){const t=ht();return Array.from(t.values()).filter(t=>t.isMinimized).sort((t,e)=>t.dockPosition-e.dockPosition)}function Oe(t,e,i){const n=K(t.x,t.y,e,i);return{x:Math.round(n.x),y:Math.round(n.y)}}function We(t,e,i,n,o,s=8){const a=window.innerWidth-n-s,r=window.innerHeight-o-s,d=Math.min(Math.max(t-i.x,s),Math.max(s,a)),l=Math.min(Math.max(e-i.y,s),Math.max(s,r));return{x:Math.round(d),y:Math.round(l)}}function Fe(t,e){const i=["modal-dock-container"];return"left"===t?i.push("modal-dock-left"):"right"===t?i.push("modal-dock-right"):"bottom"===t?i.push("modal-dock-bottom"):"free"===t&&i.push("modal-dock-free"),e&&i.push("modal-dock-empty"),i.join(" ")}function Le(t,e){const i=["modal-dock"];return"free"===t&&i.push("horizontal"===e?"modal-dock-free-horizontal":"modal-dock-free-vertical"),i.join(" ")}function _e(){const t=ht();return Array.from(t.values()).some(t=>t.isOpen&&!t.isMinimized&&!t.isHiddenWithParent)}function Ge(){return Qt(oe().features.backdrop)}function $e(){const t=Ge();return t.visible||t.blockClicks}export{_e as A,Nt as B,ue as C,me as D,se as E,jt as F,vt as G,Ut as H,xt as I,Te as J,Oe as K,lt as L,Ee as M,Ht as N,ht as O,We as P,nt as Q,pe as R,ge as S,X as T,Fe as U,Le as V,ae as W,Qt as X,re as Y,Et as Z,At as _,ie as a,ne as b,ot as c,kt as d,Rt as e,at as f,_ as g,rt as h,dt as i,V as j,oe as k,fe as l,It as m,it as n,Dt as o,le as p,de as q,bt as r,G as s,Bt as t,he as u,Ft as v,Lt as w,Ot as x,Ge as y,$e as z};
1
+ var t=Object.defineProperty,e=(e,i,n)=>((e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n)(e,"symbol"!=typeof i?i+"":i,n);const i=Symbol.for("epic-modals-core");if(typeof globalThis<"u"){const t=globalThis;t[i],t[i]=!0}const n=new Map;let o=0,s=null;function a(t){s=t}let r=null;function d(t){r=t}const l=new Set;let h=!1,c=[],g=[],u=[],m=[],p=[],f=[],w=[],y=[],z=[],v=null;function x(t){v=t}const P=new Map;let M=null;function I(t){M=t}const b=new Map,C=new Set,A=new Set,B=new Set;let H=[];function S(t){H=t}function D(t){c=t}function R(t){g=t}function k(t){u=t}function E(t){m=t}function T(t){p=t}function O(t){f=t}function W(t){w=t}function F(t){y=t}function L(){o++,function(){if(!h){h=!0;try{l.forEach(t=>t())}finally{h=!1}}}()}function _(){return o}function G(t){return l.add(t),()=>l.delete(t)}function $(t,e){return!!n.get(t)||(function(){var t,e;try{const i=import.meta;return!0===(null==(t=i.env)?void 0:t.DEV)||"development"===(null==(e=i.env)?void 0:e.MODE)}catch{return!1}}(),!1)}function Y(t,e){const i=n.get(t);if(null==i||!i.childId)return;const o=n.get(i.childId);if(!o)return;const s=e+2;n.set(i.childId,{...o,zIndex:s}),Y(i.childId,s)}function V(t){if(!n.get(t))return;const e=Math.max(...Array.from(n.values()).map(t=>t.zIndex),0),i=function(t){let e=t,i=n.get(e);for(;null!=i&&i.parentId;)e=i.parentId,i=n.get(e);return e}(t),o=n.get(i);if(!o)return;const s=e+2;n.set(i,{...o,zIndex:s}),Y(i,s),L()}function X(t){const e=n.get(t);if(!e)return!1;const i=Math.max(...Array.from(n.values()).map(t=>t.zIndex),0);return e.zIndex===i&&!e.isMinimized&&!e.isHiddenWithParent}const q=8;function K(t,e,i,n,o={}){const{margin:s=q,allowPartialVisibility:a=!1}=o,r=typeof window<"u"?window.innerWidth:1920,d=typeof window<"u"?window.innerHeight:1080;let l,h,c,g;return a&&i>r-2*s?(l=40-i,h=r-40):(l=s,h=Math.max(s,r-i-s)),a&&n>d-2*s?(c=40-n,g=d-40):(c=s,g=Math.max(s,d-n-s)),{x:Math.max(l,Math.min(h,t)),y:Math.max(c,Math.min(g,e))}}function j(t,e,i,n,o={}){const{margin:s=q}=o,a=(typeof window<"u"?window.innerWidth:1920)-2*s,r=(typeof window<"u"?window.innerHeight:1080)-2*s,d=Math.min(i,a),l=Math.min(n,r),h=K(t,e,d,l,o);return{x:h.x,y:h.y,width:d,height:l}}function N(t,e){return Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x))*Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y))}function U(t,e,i,n,o,s){const a={x:t-s,y:e-s,width:i+2*s,height:n+2*s};let r=0;for(const t of o)r+=N(a,t);return r}function J(t){if(typeof document>"u")return[];const e=[];for(const i of t)try{const t=document.querySelectorAll(i);for(const i of t){const t=i.getBoundingClientRect();t.width>0&&t.height>0&&e.push({x:t.left,y:t.top,width:t.width,height:t.height})}}catch{}return e}function Q(t,e,i,n){const o=t-e,s=i-1;if(o<=0)return{interGap:0,edgeGap:0};if(i<=1)return{interGap:0,edgeGap:o/2};const a=o/(i+1);if(a>=n)return{interGap:a,edgeGap:a};const r=s*n;return o>=r?{interGap:n,edgeGap:(o-r)/2}:{interGap:o/s,edgeGap:0}}function Z(t,e,i,n,o=0){if(0===i.length)return{cols:t,rows:e,score:1/0,positions:new Map};const s=new Array(t).fill(0),a=new Array(e).fill(0);for(let e=0;e<i.length;e++){const n=e%t,o=Math.floor(e/t);s[n]=Math.max(s[n],i[e].width),a[o]=Math.max(a[o],i[e].height)}const r=s.reduce((t,e)=>t+e,0),d=a.reduce((t,e)=>t+e,0);if(r>n.width||d>n.height)return null;const{interGap:l,edgeGap:h}=Q(n.width,r,t,o),{interGap:c,edgeGap:g}=Q(n.height,d,e,o),u=new Map,m=[0];for(let e=0;e<t;e++)m.push(m[e]+s[e]);const p=[0];for(let t=0;t<e;t++)p.push(p[t]+a[t]);for(let e=0;e<i.length;e++){const o=e%t,r=Math.floor(e/t),d=i[e],f=n.x+h+o*l+m[o],w=n.y+g+r*c+p[r],y=f+(s[o]-d.width)/2,z=w+(a[r]-d.height)/2;u.set(d.id,{x:Math.round(y),y:Math.round(z)})}const f=t>1?l:h,w=e>1?c:g;return{cols:t,rows:e,score:(.6*Math.min(f,w)+.4*Math.sqrt(f*w))*(n.width>n.height==t>=e?1.02:1),positions:u}}function tt(t,e){const i=new Map,n=Math.max(...t.map(t=>t.width)),o=Math.max(...t.map(t=>t.height)),s=n+40*(t.length-1),a=o+40*(t.length-1);let r=e.x+(e.width-s)/2,d=e.y+(e.height-a)/2;r=Math.max(e.x,r),d=Math.max(e.y,d);for(let e=0;e<t.length;e++)i.set(t[e].id,{x:Math.round(r+40*e),y:Math.round(d+40*e)});return i}function et(t,e,i={}){const{modalGap:n=16,viewportMargin:o=16,avoidBounds:s=[],avoidMargin:a=24}=i,r=typeof window<"u"?window.innerWidth:1920,d=typeof window<"u"?window.innerHeight:1080,l=new Map,h=t.filter(t=>!t.parentId),c=h.map(t=>({id:t.id,width:t.width,height:t.height}));if(e&&c.push({id:e.id,width:e.width,height:e.height}),0===c.length)return{positions:l};const g=new Map(h.map(t=>[t.id,t.currentPosition]));c.sort((t,e)=>{const i=g.get(t.id),n=g.get(e.id);return(i?i.x+t.width/2:1/0)-(n?n.x+e.width/2:1/0)});const u=function(t,e,i,n,o){let s=i,a=i,r=t-i,d=e-i;for(const i of n){const n=i.y,l=e-(i.y+i.height),h=i.x,c=t-(i.x+i.width);let g;if(i.width>i.height)g=n<=l?"top":"bottom";else if(i.height>i.width)g=h<=c?"left":"right";else{const t=Math.min(n,l,h,c);g=t===n?"top":t===l?"bottom":t===h?"left":"right"}"bottom"===g?d=Math.min(d,i.y-o):"top"===g?a=Math.max(a,i.y+i.height+o):"left"===g?s=Math.max(s,i.x+i.width+o):r=Math.min(r,i.x-o)}return{x:s,y:a,width:Math.max(0,r-s),height:Math.max(0,d-a)}}(r,d,o,s,a);if(1===c.length){const t=c[0],e=u.x+(u.width-t.width)/2,i=u.y+(u.height-t.height)/2;return l.set(t.id,{x:Math.round(e),y:Math.round(i)}),{positions:l}}const m=c.length;let p=null;for(let t=1;t<=m;t++){const e=Z(t,Math.ceil(m/t),c,u,n);e&&(null===p||e.score>p.score)&&(p=e)}if(p){for(const[t,e]of p.positions)l.set(t,e);return{positions:l}}if(e){const t=h.map(t=>({x:t.currentPosition.x,y:t.currentPosition.y,width:t.width,height:t.height})),i=function(t,e,i,n,o=20){const s=n.x+(n.width-t)/2,a=n.y+(n.height-e)/2;if(0===i.length)return{x:Math.round(s),y:Math.round(a)};const r=n.x,d=Math.max(n.x,n.x+n.width-t),l=n.y,h=Math.max(n.y,n.y+n.height-e);if(d<=r||h<=l)return{x:Math.round(s),y:Math.round(a)};const c=(d-r)/o,g=(h-l)/o;let u={x:s,y:a},m=1/0;const p=t*e,f=Math.hypot(n.width/2,n.height/2),w=n.x+n.width/2,y=n.y+n.height/2;for(let n=0;n<=o;n++)for(let s=0;s<=o;s++){const o=r+n*c,a=l+s*g,d=U(o,a,t,e,i,0),h=p>0?d/p:0,z=Math.hypot(o+t/2-w,a+e/2-y),v=.5*h+.5*(f>0?z/f:0);v<m&&(m=v,u={x:o,y:a})}return{x:Math.round(u.x),y:Math.round(u.y)}}(e.width,e.height,t,u);return l.set(e.id,i),{positions:l}}return{positions:tt(c,u)}}function it(t){return t}function nt(t){return typeof document>"u"?null:document.querySelector(`.modal-dialog[data-modal-id="${t}"]`)}function ot(t,e){if(!dt(t))throw new Error(`Cannot call ${e}() on unregistered modal "${String(t)}". Ensure the Modal component is rendered.`)}function st(t,e,i,n){var o;const s=e.x-i.x,a=e.y-i.y;if(0===s&&0===a)return null==(o=null==n?void 0:n.onComplete)||o.call(n),()=>{};const r=(null==n?void 0:n.duration)??300,d=(null==n?void 0:n.easing)??"ease-out";let l=!1;function h(){var t;l||(l=!0,clearTimeout(g),null==(t=null==n?void 0:n.onComplete)||t.call(n))}t.style.left=`${i.x}px`,t.style.top=`${i.y}px`;const c=t.animate([{transform:`translate(${s}px, ${a}px)`},{transform:"translate(0, 0)"}],{duration:r,easing:d,fill:"none"});c.onfinish=h;const g=setTimeout(h,r+100);return function(){l||(l=!0,clearTimeout(g),c.cancel())}}function at(t){return n.get(t)}function rt(t){const e=n.get(t);return(null==e?void 0:e.isOpen)??!1}function dt(t){return n.has(t)}function lt(t){return C.has(t)}function ht(){return n}function ct(){const t=[];for(const e of n.values()){if(!e.isOpen||e.isMinimized||e.isHiddenWithParent||A.has(e.id))continue;const i=nt(e.id);if(!i)continue;const n=e.position??{x:i.getBoundingClientRect().left,y:i.getBoundingClientRect().top},o=e.size??{width:i.offsetWidth,height:i.offsetHeight};t.push({id:e.id,width:o.width,height:o.height,currentPosition:n,parentId:e.parentId})}return t}function gt(t,e,i){if(!$(t))return;(function(t){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))throw new Error(`[epic-modals] Invalid position in updateModalPosition: x=${t.x}, y=${t.y}`)})(e),null!=i&&i.size&&function(t){if(t.width<=0||t.height<=0)throw new Error(`[epic-modals] Invalid dimensions in updateModalPosition: width=${t.width}, height=${t.height}`)}(i.size);const o=n.get(t);if(!o)return;let s=e;if(null!=i&&i.constrain&&o.size&&(s=K(e.x,e.y,o.size.width,o.size.height)),n.set(t,{...o,position:s,size:(null==i?void 0:i.size)??o.size,hasBeenDragged:o.hasBeenDragged||(null==i?void 0:i.drag)||!1}),o.childId){let e=t,i=s;for(;;){const t=n.get(e);if(null==t||!t.childId)break;const o=n.get(t.childId);if(null==o||!o.offsetFromParent)break;const s={x:i.x+o.offsetFromParent.x,y:i.y+o.offsetFromParent.y};n.set(t.childId,{...o,position:s,hasBeenDragged:!0}),e=t.childId,i=s}}if(o.parentId&&o.offsetFromParent){const e=oe();let a=t,r=o;for(;r.parentId&&r.offsetFromParent;){const o=n.get(r.parentId);if(!o)break;const d=a===t?s:n.get(a).position,l={x:d.x-r.offsetFromParent.x,y:d.y-r.offsetFromParent.y};if(!("animated"!==e.parentChild.movementMode||null!=i&&i.realtime)){b.set(r.parentId,l);break}n.set(r.parentId,{...o,position:l,hasBeenDragged:!0}),a=r.parentId,r=o}}L()}function ut(t){const e=n.get(t);if(!e||!e.isAnimatingPosition)return;e.isAnimatingPosition=!1;let i=e.childId;for(;i;){const t=n.get(i);t&&(t.isAnimatingPosition=!1),i=null==t?void 0:t.childId}L()}function mt(t,e){const i=n.get(t);i&&(n.set(t,{...i,...e}),L())}function pt(t){const e=oe();"smart"===e.positioning.strategy&&(s&&clearTimeout(s),a(setTimeout(()=>{const i=ct(),n=J(e.positioning.avoidElements);ft(et(i,t,{modalGap:e.positioning.modalGap,viewportMargin:e.positioning.modalGap,avoidBounds:n,avoidMargin:e.positioning.modalGap}).positions),a(null)},50)))}function ft(t){if(0===t.size)return;const e=[],i=new Map;for(const[e]of t){const t=nt(e),n=t?t.getBoundingClientRect():null;i.set(e,{element:t,rect:n})}for(const[o,s]of t){const t=n.get(o);if(!t)continue;const{element:a,rect:r}=i.get(o)||{element:null,rect:null},d=t.position??(r?{x:r.left,y:r.top}:{x:0,y:0}),l=t.size??(r?{width:r.width,height:r.height}:{width:0,height:0});e.push({id:o,element:a,oldPosition:d,newPosition:s,size:l}),wt(o,d,s,e)}for(const{id:t,newPosition:i,size:o}of e){const e=n.get(t);e&&n.set(t,{...e,position:i,size:o,hasBeenDragged:!0,isAnimatingPosition:!0})}L();for(const{id:t,element:i,oldPosition:n,newPosition:o}of e)i?st(i,n,o,{duration:300,onComplete:()=>ut(t)}):setTimeout(()=>ut(t),400)}function wt(t,e,i,o){const s=n.get(t);if(null==s||!s.childId)return;const a=n.get(s.childId);if(null==a||!a.offsetFromParent)return;const r=nt(s.childId),d={x:e.x+a.offsetFromParent.x,y:e.y+a.offsetFromParent.y},l={x:i.x+a.offsetFromParent.x,y:i.y+a.offsetFromParent.y};o.push({id:s.childId,element:r,oldPosition:d,newPosition:l}),n.set(s.childId,{...a,position:l,hasBeenDragged:!0,isAnimatingPosition:!0}),a.childId&&wt(s.childId,d,l,o)}function yt(){r&&clearTimeout(r),d(setTimeout(()=>{pt(null),d(null)},100))}let zt=!1;function vt(){zt||typeof window>"u"||(window.addEventListener("resize",yt),zt=!0)}function xt(){typeof window>"u"||(window.removeEventListener("resize",yt),zt=!1)}function Pt(t){b.delete(t)}function Mt(t){const e=n.get(t);if(null==e||!e.childId)return;const i=n.get(e.childId);i&&(w.includes(e.childId)||W([...w,e.childId]),i.childId&&Mt(e.childId))}function It(t){const e=n.get(t);if(!e||e.isMinimized)return;if(Pt(t),e.parentId){const t=n.get(e.parentId);if(t&&!t.isMinimized)return void It(e.parentId)}D([...c,t]),e.position&&e.size;const i=e.childId;n.set(t,{...e,isMinimized:!0,lastChildId:i}),H.includes(t)||S([...H,t]),L(),e.childId&&Mt(t),pt(null)}function bt(t){const e=n.get(t);if(!e||!e.isMinimized)return;n.set(t,{...e,isMinimized:!1,isOpen:!0}),T([...p,t]),V(t);const i=e.lastChildId||e.childId;i&&Ct(i),L()}function Ct(t){const e=n.get(t);if(e&&e.isHiddenWithParent){O([...f,t]);const i=e.lastChildId||e.childId;i&&Ct(i)}}function At(t){if(!$(t))return;const e=n.get(t);B.has(t)?(B.delete(t),n.set(t,{...e,isTransparent:!1})):(B.add(t),n.set(t,{...e,isTransparent:!0})),L()}function Bt(t){$(t)&&(y.includes(t)||(F([...y,t]),L()))}function Ht(t){t.classList.add("modal-shake"),t.addEventListener("animationend",()=>{t.classList.remove("modal-shake")},{once:!0})}function St(t){if(!$(t))return;const e=n.get(t);B.delete(t),n.set(t,{...e,isTransparent:!1}),L()}function Dt(t,e,i){Rt(t,i,{parentId:e})}function Rt(t,e,i){const o=oe(),s=n.get(t);if(s&&s.isOpen&&!s.isMinimized&&!s.isHiddenWithParent)return Bt(t),void V(t);if(s&&s.isMinimized)return void bt(t);if("x"in e&&"y"in e)P.set(t,e);else{const i=e.getBoundingClientRect();P.set(t,{x:i.left+i.width/2,y:i.top+i.height/2})}if(null!=i&&i.parentId&&o.features.parentChild){const e=n.get(i.parentId);null!=e&&e.childId&&e.childId!==t&&kt(e.childId,!0),I({parentId:i.parentId,childId:t})}if(g.includes(t)||R([...g,t]),L(),!s)return;const a={isOpen:!0};null!=i&&i.parentId&&o.features.parentChild&&(a.parentId=i.parentId),n.set(t,{...s,...a}),V(t)}function kt(t,e=!1){const i=n.get(t);if(i&&(i.isOpen||i.isMinimized)){if(Pt(t),i.childId&&kt(i.childId,e),i.isMinimized)return S(H.filter(e=>e!==t)),void Tt(t);A.add(t),e?E([...m,t]):k([...u,t]),i.parentId||pt(null),L()}}function Et(t){const e=new Set(t??[]);Array.from(n.keys()).filter(t=>!e.has(t)).forEach(t=>kt(t,!0))}function Tt(t){const e=n.get(t);if(e){if(A.delete(t),e.parentId){const i=n.get(e.parentId);i&&i.childId===t&&n.set(e.parentId,{...i,childId:void 0,lastChildId:t})}n.set(t,{...e,isOpen:!1,isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,position:null,size:null,hasBeenDragged:!1,parentId:void 0,childId:void 0,offsetFromParent:void 0}),L()}}function Ot(t){return c.includes(t)}function Wt(t){return w.includes(t)}function Ft(t){return g.includes(t)}function Lt(t){return u.includes(t)}function _t(t){return m.includes(t)}function Gt(t){E(m.filter(e=>e!==t))}function $t(t){return p.includes(t)}function Yt(t){return f.includes(t)}function Vt(t){return(null==M?void 0:M.childId)===t}function Xt(){return M}function qt(t){if("animated"!==oe().parentChild.movementMode)return;const e=n.get(t);if(null==e||!e.parentId||!e.offsetFromParent||!e.position)return;const i={x:e.position.x-e.offsetFromParent.x,y:e.position.y-e.offsetFromParent.y};b.set(e.parentId,i),L()}const Kt={BASE:0,DROPDOWN:100,STICKY:200,OVERLAY:300,MODAL:400,DOCK:8e3,TOAST:9e3};function jt(){oe().zIndex.base}function Nt(t){const e=oe();return"MODAL"===t?e.zIndex.base:"DOCK"===t?e.zIndex.dock:"TOAST"===t?e.zIndex.toast:Kt[t]}function Ut(){oe().zIndex.base}function Jt(){const t=new Map;return{on(e,i){let n=t.get(e);return n||(n=new Set,t.set(e,n)),n.add(i),()=>{null==n||n.delete(i),0===(null==n?void 0:n.size)&&t.delete(e)}},emit(e,i){const n=t.get(e);n&&n.forEach(t=>t(i))},off(e){e?t.delete(e):t.clear()},listenerCount(e){var i;return(null==(i=t.get(e))?void 0:i.size)??0}}}function Qt(t){return"boolean"==typeof t?{visible:t,blockClicks:t}:t}let Zt={features:{dock:!0,minimize:!0,transparency:!0,resize:!0,drag:!0,focusTrap:!0,animations:!0,backdrop:!0,parentChild:!0},dock:{position:"bottom",labelMode:"beside",enableReorder:!0,enableFreeDrag:!0},animations:{open:400,close:250,minimize:500,restore:400,easing:"cubic-bezier(0.34, 1.56, 0.64, 1)"},appearance:{headerLayout:"macos",defaultWidth:"480px",defaultHeight:"auto",minWidth:280,minHeight:200},zIndex:{base:400,dock:8e3,toast:9e3},parentChild:{movementMode:"animated",animationDuration:300},positioning:{strategy:"smart",modalGap:16,avoidElements:[]},portalTarget:"#modal-portal"},te=0;const ee=new Set;function ie(t){return ee.add(t),()=>ee.delete(t)}function ne(){return te}function oe(){return Zt}function se(t){const e=Zt;Zt=ae(Zt,t),te++,ee.forEach(t=>t()),e.features.dock&&!Zt.features.dock&&(Array.from(n.values()).filter(t=>t.isMinimized).map(t=>t.id).forEach(t=>{const e=n.get(t);if(e){n.set(t,{...e,isMinimized:!1,isOpen:!0}),T([...p,t]),V(t);const i=e.lastChildId||e.childId;i&&Ct(i)}}),S([]),L())}function ae(t,e){var i;return{features:{...t.features,...e.features},dock:{...t.dock,...e.dock},animations:{...t.animations,...e.animations},appearance:{...t.appearance,...e.appearance},zIndex:{...t.zIndex,...e.zIndex},parentChild:{...t.parentChild,...e.parentChild},positioning:{...t.positioning,...e.positioning,avoidElements:(null==(i=e.positioning)?void 0:i.avoidElements)??t.positioning.avoidElements},portalTarget:e.portalTarget??t.portalTarget}}function re(t,e){const i=oe(),n=e?ae(i,e):i;return{isFeatureEnabled:e=>{var i;if(void 0!==(null==(i=null==t?void 0:t.features)?void 0:i[e])){const i=t.features[e];if("backdrop"===e){const t=Qt(i);return t.visible||t.blockClicks}return i}const o=n.features[e];if("backdrop"===e){const t=Qt(o);return t.visible||t.blockClicks}return o},getAppearance:e=>{var i;return void 0!==(null==(i=null==t?void 0:t.appearance)?void 0:i[e])?t.appearance[e]:n.appearance[e]},getPositioning:e=>{var i;return void 0!==(null==(i=null==t?void 0:t.positioning)?void 0:i[e])?t.positioning[e]:n.positioning[e]},getEffectiveConfig:()=>n}}function de(t){return{id:t.id,title:t.title,icon:t.icon??"",isOpen:t.autoOpen??!1,isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,isRejected:!1,position:null,size:null,hasBeenDragged:!1,dockPosition:0,glow:t.glow??null,parentId:void 0,childId:void 0,offsetFromParent:void 0}}function le(t){const e=n.get(t.id);let i;i=null!=e&&e.zIndex?e.zIndex:Math.max(...Array.from(n.values()).map(t=>t.zIndex),oe().zIndex.base-2)+2;const o=g.includes(t.id),s=t.isOpen||o;e?n.set(t.id,{...e,title:t.title,icon:t.icon,glow:t.glow,zIndex:i}):n.set(t.id,{...t,isOpen:s,zIndex:i,isAnimating:!1}),L(),t.isMinimized&&!H.includes(t.id)&&S([...H,t.id])}function he(t){const e=n.get(t);if(e){if(S(H.filter(e=>e!==t)),R(g.filter(e=>e!==t)),k(u.filter(e=>e!==t)),E(m.filter(e=>e!==t)),D(c.filter(e=>e!==t)),T(p.filter(e=>e!==t)),O(f.filter(e=>e!==t)),W(w.filter(e=>e!==t)),F(y.filter(e=>e!==t)),e.childId){const t=n.get(e.childId);t&&n.set(e.childId,{...t,parentId:void 0})}if(e.parentId){const t=n.get(e.parentId);t&&n.set(e.parentId,{...t,childId:void 0,lastChildId:e.id})}n.delete(t),L(),B.delete(t),C.delete(t)}}class ce{constructor(t={}){e(this,"element",null),e(this,"resizeHandler",null),e(this,"options"),this.options=t}mount(t){var e,i;this.element=t,this.options.onWindowResize&&(this.resizeHandler=this.options.onWindowResize,window.addEventListener("resize",this.resizeHandler)),null==(i=(e=this.options).onMount)||i.call(e)}destroy(){var t,e;this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=null),this.element=null,null==(e=(t=this.options).onDestroy)||e.call(t)}getElement(){return this.element}isMounted(){return null!==this.element}}const ge={modal:"modal-dialog",header:"modal-header",headerDraggable:"modal-header-draggable",body:"modal-body",footer:"modal-footer",childOverlay:"modal-child-overlay",overlayClosing:"modal-overlay-closing",headerTitle:"modal-header-title",headerIcon:"modal-header-icon",headerTitleGroup:"modal-header-title-group",headerActions:"modal-header-actions",headerTrafficLights:"modal-header-traffic-lights",headerLight:"modal-header-light",headerLightClose:"modal-header-light-close",headerLightMinimize:"modal-header-light-minimize",headerLightStyle:"modal-header-light-style",headerLightDisabled:"modal-header-light-disabled",headerMacCenter:"modal-header-mac-center",headerMacSpacer:"modal-header-mac-spacer",headerBtnWindows:"modal-header-btn-windows",headerBtnWindowsClose:"modal-header-btn-windows-close",headerBtnWindowsStyle:"modal-header-btn-windows-style",headerBtnWindowsDisabled:"modal-header-btn-windows-disabled",resizeHandles:"modal-resize-handles",resizeHandle:"modal-resize-handle",resizePrefix:"modal-resize-",dock:"modal-dock",dockContainer:"modal-dock-container",dockItem:"modal-dock-item",dockItemHasGlow:"modal-dock-item-has-glow",dockItemHasChild:"modal-dock-item-has-child",dockItemLabelBeside:"modal-dock-item-label-beside",dockItemLabelBelow:"modal-dock-item-label-below",dockItemIcon:"modal-dock-item-icon",dockItemIconPlaceholder:"modal-dock-item-icon-placeholder",dockItemLabel:"modal-dock-item-label",dockItemGlow:"modal-dock-item-glow",dockChildIndicator:"modal-dock-child-indicator",dockHandle:"modal-dock-handle",dockHandleDragging:"modal-dock-handle-dragging",backdrop:"modal-backdrop",backdropVisible:"modal-backdrop-visible"},ue={dialog:ge.modal,header:ge.header,headerDraggable:ge.headerDraggable,body:ge.body,footer:ge.footer,childOverlay:ge.childOverlay,headerTitle:ge.headerTitle,headerIcon:ge.headerIcon,headerTitleGroup:ge.headerTitleGroup,headerActions:ge.headerActions,headerTrafficLights:ge.headerTrafficLights,headerLight:ge.headerLight,headerLightClose:ge.headerLightClose,headerLightMinimize:ge.headerLightMinimize,headerLightStyle:ge.headerLightStyle,headerLightDisabled:ge.headerLightDisabled,headerMacCenter:ge.headerMacCenter,headerMacSpacer:ge.headerMacSpacer,headerBtnWindows:ge.headerBtnWindows,headerBtnWindowsClose:ge.headerBtnWindowsClose,headerBtnWindowsStyle:ge.headerBtnWindowsStyle,headerBtnWindowsDisabled:ge.headerBtnWindowsDisabled,resizeHandles:ge.resizeHandles,resizeHandle:ge.resizeHandle,resizePrefix:ge.resizePrefix,dock:ge.dock,dockContainer:ge.dockContainer,dockItem:ge.dockItem,dockItemHasGlow:ge.dockItemHasGlow,dockItemHasChild:ge.dockItemHasChild,dockItemLabelBeside:ge.dockItemLabelBeside,dockItemLabelBelow:ge.dockItemLabelBelow,dockItemIcon:ge.dockItemIcon,dockItemIconPlaceholder:ge.dockItemIconPlaceholder,dockItemLabel:ge.dockItemLabel,dockItemGlow:ge.dockItemGlow,dockChildIndicator:ge.dockChildIndicator,dockHandle:ge.dockHandle,backdrop:ge.backdrop,backdropVisible:ge.backdropVisible},me={modalId:"data-modal-id",resizeDirection:"data-direction"},pe=["n","s","e","w","ne","nw","se","sw"],fe={n:"Resize north",s:"Resize south",e:"Resize east",w:"Resize west",ne:"Resize northeast",nw:"Resize northwest",se:"Resize southeast",sw:"Resize southwest"},we={minWidth:280,minHeight:200},ye=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function ze(t,e){const i=document.querySelector(`.modal-dock-item[data-modal-id="${t}"]`);if(i){const t=i.getBoundingClientRect();return{x:t.left+t.width/2,y:t.top+t.height/2}}const n=document.querySelector('[data-dock-container="true"]');if(n){const t=n.getBoundingClientRect();return{x:t.left+t.width/2,y:t.top+t.height/2}}return{x:typeof window<"u"?window.innerWidth/2:0,y:typeof window<"u"?window.innerHeight-40:0}}function ve(t,e){return function(t,e,i={}){const{timeout:n=5e3,useObservers:o=!0}=i;return new Promise((i,s)=>{const a=performance.now();let r=null,d=null,l=null,h=null,c=!1;const g=()=>{c=!0,null==r||r.disconnect(),null==d||d.disconnect(),l&&clearTimeout(l),h&&cancelAnimationFrame(h)},u=()=>{if(c)return;const n=t();n&&e(n)&&(g(),i(n))};l=setTimeout(()=>{c||(g(),s(new Error(`DOM not ready after ${n}ms`)))},n);const m=t();if(m&&e(m))return g(),void i(m);if(o&&m){r=new MutationObserver(u),r.observe(m,{attributes:!0,attributeFilter:["class","data-state","data-animation-phase","style"],childList:!0,subtree:!1}),d=new ResizeObserver(u),d.observe(m);const t=()=>{c||(u(),c||(h=requestAnimationFrame(()=>{setTimeout(t,100)})))};t()}else{const o=()=>{if(c)return;const s=t(),r=performance.now()-a;if(s&&e(s))return g(),void i(s);r>=n||(h=requestAnimationFrame(o))};o()}})}(t,t=>t.offsetWidth>0&&t.offsetHeight>0,e)}const xe="modal-genie-minimize",Pe="modal-genie-restore",Me="modal-close",Ie="modal-close-centered",be="modal-child-appear",Ce="modal-child-disappear",Ae={[xe]:["minimize"],[Pe]:["restore","open"],[Me]:["close"],[Ie]:["close"],[be]:["open"],[Ce]:["close"]};class Be{constructor(t){e(this,"id"),e(this,"dataId"),e(this,"configHelper"),e(this,"getDragBehavior"),e(this,"getElement"),this.id=t.id,this.dataId=t.dataId,this.configHelper=t.configHelper,this.getDragBehavior=t.getDragBehavior,this.getElement=t.getElement}constrainToViewport(t){const e=this.getDragBehavior();e.hasBeenDragged()&&e.constrainToViewport(t)}shouldApplySmartPositioning(){return!("smart"!==this.configHelper.getPositioning("strategy")||this.getDragBehavior().hasBeenDragged())}applySmartPositioning(){if("smart"!==this.configHelper.getPositioning("strategy"))return!1;const t=at(this.id),e=Xt();if(null!=t&&t.parentId||e&&e.childId===this.id||null!=t&&t.hasBeenDragged||null!=t&&t.position)return!1;const i=this.getElement()||nt(this.id);if(!i)return!1;const n=i.offsetWidth,o=i.offsetHeight;if(n<=0||o<=0)return!1;const s=this.configHelper.getPositioning("modalGap"),a=ct().filter(t=>t.id!==this.id),r=J(this.configHelper.getPositioning("avoidElements")),d=et(a,{id:this.id,width:n,height:o},{modalGap:s,viewportMargin:s,avoidBounds:r,avoidMargin:s}),l=d.positions.get(this.id);if(!l)return!1;const h=new Map;for(const[t,e]of d.positions)t!==this.id&&h.set(t,e);h.size>0&&ft(h);const c=this.getDragBehavior();return c.setPosition(l),c.setHasBeenDragged(!0),gt(this.id,l,{size:{width:n,height:o}}),!0}scheduleSmartPositioning(){ve(()=>this.getElement()||nt(this.id)).then(()=>{this.applySmartPositioning()}).catch(()=>{this.applySmartPositioning()})}centerChildOnParent(t){var e,i;const o=at(t);if(!o)return!1;const s=this.getElement()||nt(this.id),a=nt(t),r=null==a?void 0:a.getBoundingClientRect(),d=o.position??(r?{x:r.left,y:r.top}:null);if(!d||!s)return!1;const l=(null==(e=o.size)?void 0:e.width)??(null==a?void 0:a.offsetWidth)??(null==r?void 0:r.width)??480,h=(null==(i=o.size)?void 0:i.height)??(null==a?void 0:a.offsetHeight)??(null==r?void 0:r.height)??400,c=s.offsetWidth,g=s.offsetHeight;if(l<=0||h<=0||c<=0||g<=0)return!1;const u={x:d.x+(l-c)/2,y:d.y+(h-g)/2},m=this.getDragBehavior();m.setPosition(u),m.setHasBeenDragged(!0),gt(this.id,u,{size:{width:c,height:g}}),(!o.position||!o.size)&&r&&gt(t,{x:r.left,y:r.top},{size:{width:l,height:h}});const p={x:u.x-d.x,y:u.y-d.y};return function(t,e,i){const o=n.get(t),s=n.get(e);!o||!s||(n.set(t,{...o,childId:e}),n.set(e,{...s,parentId:t,offsetFromParent:i}),V(e),L())}(t,this.id,p),!0}scheduleCenterChildOnParent(t){ve(()=>this.getElement()).then(()=>{this.centerChildOnParent(t)}).catch(()=>{this.centerChildOnParent(t)})}}const He=new WeakMap;function Se(t){const e=He.get(t);if(e)return e.elements;const i=De(t),n=new MutationObserver(()=>{!function(t){const e=He.get(t);e&&(e.elements=De(t))}(t)});return n.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["disabled","tabindex","href","hidden"]}),He.set(t,{elements:i,observer:n}),i}function De(t){return Array.from(t.querySelectorAll(ye)).filter(t=>null!==t.offsetParent||"A"===t.tagName)}class Re{constructor(t){e(this,"options"),this.options=t}startDrag(t){const e=this.options.getElement();!this.options.configHelper.isFeatureEnabled("drag")||!e||this.options.getDragBehavior().onPointerDown(t,e)}startResize(t,e){const i=this.options.getState();!this.options.configHelper.isFeatureEnabled("resize")||i.hasChild||this.options.getResizeBehavior().startResize(t,e)}handlePointerMove(t){const e=this.options.getElement();if(!e)return;const i=this.options.getDragBehavior(),n=i.isDragging(),o=this.options.getResizeBehavior(),s=o.hasBeenResized()?o.getSize():{width:e.offsetWidth,height:e.offsetHeight};i.onPointerMove(t,s),n&&i.isDragging()&&this.options.onDragMove()}handlePointerUp(t){const e=this.options.getElement();if(!e)return;const i=this.options.getDragBehavior(),n=i.isDragging();i.onPointerUp(t,e),n&&!this.options.getResizeBehavior().justFinishedResizing()&&this.options.onDragEnd()}handleKeyDown(t){var e,i;this.options.closeOnEscape&&"Escape"===t.key&&this.options.isTopModal()&&(t.stopPropagation(),null==(i=(e=this.options).onClose)||i.call(e))}updateCloseOnEscape(t){this.options.closeOnEscape=t}handleTabKey(t){const e=this.options.getElement();e&&function(t,e){if("Tab"!==t.key)return;const i=Se(e);if(0===i.length)return void t.preventDefault();const n=i[0],o=i[i.length-1],s=document.activeElement;t.shiftKey?s===n&&(o.focus(),t.preventDefault()):s===o&&(n.focus(),t.preventDefault())}(t,e)}focusFirst(){const t=this.options.getElement();t&&function(t){const e=Se(t);e.length>0&&e[0].focus()}(t)}}class ke{constructor(t){e(this,"id"),e(this,"options"),e(this,"_isHandlingMinimize",!1),e(this,"_isAttentionAnimating",!1),e(this,"_wasRestored"),e(this,"_glowStabilizing",!1),e(this,"_restoreHold",!1),e(this,"_isAnimatingToCenter",!1),e(this,"_cancelParentAnimationCleanup",null),e(this,"_parentFlipInFlight",!1),e(this,"_deferredParentTarget",null),e(this,"_parentFlipStartTime",0),e(this,"_isHandlingPendingStates",!1),this.id=t.id,this.options=t,this._wasRestored=!1}handlePendingStates(){if(!this._isHandlingPendingStates&&at(this.id)){this._isHandlingPendingStates=!0;try{if(this.handlePendingForceClose()||(this.handlePendingMinimize(),this.handlePendingMinimizeWithParent(),this.handlePendingRestore(),this.handlePendingChildRestore(),this.handlePendingClose()))return;const t=this.handlePendingParentLink(),e=this.handlePendingOpen(t);this.handlePendingAttention(),this.handlePendingParentAnimation(),this.handleChildCentering(t,e)}finally{this._isHandlingPendingStates=!1}}}handlePendingForceClose(){var t,e;return!!_t(this.id)&&(Gt(this.id),Tt(this.id),null==(e=(t=this.options.options).onClose)||e.call(t),!0)}handlePendingMinimize(){if(!Ot(this.id)||this._isHandlingMinimize)return;this._isHandlingMinimize=!0,x(null);const t=this.options.getElement();if(t){const e=this.options.getDragBehavior(),i=this.options.getResizeBehavior(),n=t.getBoundingClientRect(),o=e.hasBeenDragged()?e.getPosition():{x:n.left,y:n.top},s=i.hasBeenResized()?i.getSize():{width:n.width,height:n.height};mt(this.id,{position:o,size:s,hasBeenDragged:!0})}this.options.getAnimationController().startMinimize(void 0,()=>{var t;t=this.id,D(c.filter(e=>e!==t)),x(null),this._isHandlingMinimize=!1})||(this._isHandlingMinimize=!1)}handlePendingMinimizeWithParent(){if(!Wt(this.id)||this._isHandlingMinimize)return;this._isHandlingMinimize=!0;const t=this.options.getElement();if(t){const e=this.options.getDragBehavior(),i=this.options.getResizeBehavior(),n=t.getBoundingClientRect(),o=e.hasBeenDragged()?e.getPosition():{x:n.left,y:n.top},s=i.hasBeenResized()?i.getSize():{width:n.width,height:n.height};mt(this.id,{position:o,size:s,hasBeenDragged:!0})}this.options.getAnimationController().startMinimize(void 0,()=>{var t;t=this.id,W(w.filter(e=>e!==t)),function(t){const e=n.get(t);e&&(n.set(t,{...e,isHiddenWithParent:!0}),L())}(this.id),this._isHandlingMinimize=!1})}handlePendingRestore(){if(!$t(this.id))return;const t=at(this.id),e=this.options.getAnimationController();var i;i=this.id,T(p.filter(t=>t!==i)),e.startRestore((null==t?void 0:t.position)??void 0,(null==t?void 0:t.size)??void 0),requestAnimationFrame(()=>{this.options.focusFirst()})}handlePendingChildRestore(){if(!Yt(this.id))return;const t=at(this.id),e=this.options.getAnimationController();var i;i=this.id,O(f.filter(t=>t!==i)),e.startRestore((null==t?void 0:t.position)??void 0,(null==t?void 0:t.size)??void 0),function(t){const e=n.get(t);!e||!e.isHiddenWithParent||(n.set(t,{...e,isHiddenWithParent:!1}),L())}(this.id),this._wasRestored=!0}handlePendingClose(){var t,e,i;return!!Lt(this.id)&&(i=this.id,k(u.filter(t=>t!==i)),this.options.getAnimationController().startClose(()=>{var t,e;St(this.id),Tt(this.id),null==(e=(t=this.options.options).onClose)||e.call(t)})||(St(this.id),Tt(this.id),null==(e=(t=this.options.options).onClose)||e.call(t)),!0)}handlePendingParentLink(){const t=Xt();return t&&t.childId===this.id&&(mt(this.id,{parentId:t.parentId}),this._wasRestored=!0),function(t){const e=M;return t&&(null==e?void 0:e.childId)!==t?null:(I(null),e)}(this.id)}handlePendingOpen(t){var e,i;if(!Ft(this.id))return!1;i=this.id,R(g.filter(t=>t!==i));const n=this.options.getDragBehavior(),o=this.options.getResizeBehavior();mt(this.id,{position:null,hasBeenDragged:!1,size:null}),n.setPosition({x:0,y:0}),n.setHasBeenDragged(!1),o.reset();const s=function(t){const e=P.get(t)??null;return P.delete(t),e}(this.id)||this.options.options.openSourcePosition||null,a=!!t||!(null==(e=at(this.id))||!e.parentId);let r=!1;return s?(r=!0,this.options.getAnimationController().setPendingOpenSource(s),a&&t?this.openChildModalWithAnimation(t.parentId):this.openStandaloneModalWithAnimation()):a||this.options.getPositioning().scheduleSmartPositioning(),requestAnimationFrame(()=>{this.options.focusFirst()}),r}openChildModalWithAnimation(t){const e=this.options.getPositioning(),i=this.options.getAnimationController();ve(()=>this.options.getElement()).then(()=>{e.centerChildOnParent(t)&&(i.startOpen(),this._wasRestored=!0)}).catch(()=>{e.centerChildOnParent(t)&&(i.startOpen(),this._wasRestored=!0)})}openStandaloneModalWithAnimation(){const t=this.options.getPositioning(),e=this.options.getAnimationController();ve(()=>this.options.getElement()).then(()=>{t.applySmartPositioning(),e.startOpen()}).catch(()=>{t.applySmartPositioning(),e.startOpen()})}handlePendingAttention(){var t;t=this.id,y.includes(t)&&(function(t){F(y.filter(e=>e!==t)),z.includes(t)||function(t){z=t}([...z,t])}(this.id),this.id,this._isAttentionAnimating=!0,setTimeout(()=>{this._isAttentionAnimating=!1,this.id,this.options.onStateChange()},600))}handlePendingParentAnimation(){if(t=this.id,!b.has(t))return;var t;const e=function(t){const e=b.get(t)??null;return b.delete(t),e}(this.id);if(e){if(this._parentFlipInFlight&&Date.now()-this._parentFlipStartTime<100)return void(this._deferredParentTarget=e);this._deferredParentTarget=null,this.startParentFlip(e)}}startParentFlip(t){var e,i;const n=this.options.getDragBehavior(),o=this.options.getElement(),s=null==o?void 0:o.getBoundingClientRect(),a=s?{x:s.left,y:s.top}:(null==(e=at(this.id))?void 0:e.position)??null;mt(this.id,{position:t,hasBeenDragged:!0,isAnimatingPosition:!0}),n.setPosition(t),n.setHasBeenDragged(!0),null==(i=this._cancelParentAnimationCleanup)||i.call(this),this._parentFlipInFlight=!0,this._parentFlipStartTime=Date.now();const r=this.id,d=()=>{this._parentFlipInFlight=!1,this._cancelParentAnimationCleanup=null,ut(r);const t=this._deferredParentTarget;t?(this._deferredParentTarget=null,this.startParentFlip(t)):qt(r)};o&&a?this._cancelParentAnimationCleanup=st(o,a,t,{duration:300,onComplete:d}):setTimeout(d,400)}handleChildCentering(t,e){t&&this.options.getElement()&&!e&&this.options.getPositioning().scheduleCenterChildOnParent(t.parentId)}get wasRestored(){return this._wasRestored}set wasRestored(t){this._wasRestored=t}get isAttentionAnimating(){return this._isAttentionAnimating}get glowStabilizing(){return this._glowStabilizing}set glowStabilizing(t){this._glowStabilizing=t}get restoreHold(){return this._restoreHold}set restoreHold(t){this._restoreHold=t}get isAnimatingToCenter(){return this._isAnimatingToCenter}set isAnimatingToCenter(t){this._isAnimatingToCenter=t}get isHandlingMinimize(){return this._isHandlingMinimize}}class Ee{constructor(t){var i,n,o,s;e(this,"id"),e(this,"dataId"),e(this,"options"),e(this,"drag"),e(this,"resize"),e(this,"animation"),e(this,"positioning"),e(this,"lifecycle"),e(this,"interactions"),e(this,"stateManager"),e(this,"overlayClosing",!1),e(this,"emitter",Jt()),e(this,"unsubscribeState",null),e(this,"cachedState",null),this.id=t.id,this.dataId=t.id,this.options=t,this.drag=function(t={}){const{initialPosition:e={x:0,y:0},constrain:i=!0}=t,n={...e};let o=!1,s=!1,a=0,r=0,d=0,l=0,h=null,c=null,g=null;const u=Jt();function m(){return{isDragging:o,position:{...n},hasBeenDragged:s}}function p(){u.emit("change",m())}function f(){if(h=null,!c||!g||!o)return;const t=c,e=g;c=null,g=null;const m=t.clientX-a,f=t.clientY-r;let w=d+m,y=l+f;if(i){const t=K(w,y,e.width,e.height);w=t.x,y=t.y}n.x=w,n.y=y,s=!0,u.emit("dragMove",{...n}),p()}return{getState:m,getPosition:()=>({...n}),isDragging:()=>o,hasBeenDragged:()=>s,setPosition:function(t){n.x=t.x,n.y=t.y,p()},setHasBeenDragged:function(t){s=t,p()},reset:function(){n.x=e.x,n.y=e.y,s=!1,o=!1,p()},constrainToViewport:function(t){if(!s)return;const e=K(n.x,n.y,t.width,t.height);n.x=e.x,n.y=e.y,p()},onPointerDown:function(t,e){if(0===t.button){if(!s){const t=e.getBoundingClientRect();n.x=t.left,n.y=t.top}o=!0,a=t.clientX,r=t.clientY,d=n.x,l=n.y,e.setPointerCapture(t.pointerId),u.emit("dragStart",{...n}),p()}},onPointerMove:function(t,e){o&&(c=t,g=e,null===h&&(h=requestAnimationFrame(f)))},onPointerUp:function(t,e){if(o){if(null!==h&&(cancelAnimationFrame(h),h=null),c&&g){const t=c.clientX-a,e=c.clientY-r;let o=d+t,h=l+e;if(i){const t=K(o,h,g.width,g.height);o=t.x,h=t.y}n.x=o,n.y=h,s=!0}c=null,g=null,o=!1,e.releasePointerCapture(t.pointerId),u.emit("dragEnd",{...n}),p()}},subscribe:function(t){return u.on("change",t)},destroy:function(){null!==h&&(cancelAnimationFrame(h),h=null),c=null,g=null,u.off()}}}({initialPosition:{x:0,y:0},constrain:!0}),this.resize=function(t){const{minWidth:e=we.minWidth,minHeight:i=we.minHeight,getPosition:n,setPosition:o,getHasBeenDragged:s,setHasBeenDragged:a,getElement:r,getSymmetricResize:d,onResizeEnd:l}=t;let h=!1,c="",g={width:0,height:0},u=!1,m=!1,p={x:0,y:0,width:0,height:0,posX:0,posY:0,centerX:0,centerY:0},f=null;const w=Jt();let y=null,z=null;function v(){return{isResizing:h,direction:c,size:{...g},hasBeenResized:u}}function x(){w.emit("change",v())}function P(t){if(t.pointerId!==f)return;const n=t.clientX-p.x,s=t.clientY-p.y,a=window.innerWidth,r=window.innerHeight,l=(null==d?void 0:d())??!1;let h=p.width,u=p.height,m=p.posX,y=p.posY;if(l){if(c.includes("e")||c.includes("w")){const t=c.includes("e")?n:-n;h=Math.max(e,p.width+2*t),m=p.centerX-h/2}if(c.includes("s")||c.includes("n")){const t=c.includes("s")?s:-s;u=Math.max(i,p.height+2*t),y=p.centerY-u/2}}else{if(c.includes("e")){const t=a-m;h=Math.max(e,Math.min(p.width+n,t))}if(c.includes("w")){const t=p.width-e,i=Math.min(n,t);h=p.width-i,m=p.posX+i}if(c.includes("s")){const t=r-y;u=Math.max(i,Math.min(p.height+s,t))}if(c.includes("n")){const t=p.height-i,e=Math.min(s,t);u=p.height-e,y=p.posY+e}}const z=j(m,y,h,u);g={width:z.width,height:z.height},o({x:z.x,y:z.y}),w.emit("resizeMove",{size:{...g},position:{x:z.x,y:z.y}}),x()}function M(t){if(t.pointerId!==f)return;h=!1,c="",f=null,y&&window.removeEventListener("pointermove",y),z&&(window.removeEventListener("pointerup",z),window.removeEventListener("pointercancel",z)),y=null,z=null,m=!0;const e=n();w.emit("resizeEnd",{size:{...g},position:e}),l&&l(e,{...g}),x(),setTimeout(()=>{m=!1},0)}return{getState:v,getSize:()=>({...g}),isResizing:()=>h,hasBeenResized:()=>u,justFinishedResizing:()=>m,setSize:function(t){g={...t},u=!0,x()},reset:function(){u=!1,g={width:0,height:0},h=!1,c="",x()},constrainToViewport:function(){const t=n(),e=r();if(!e)return;const i=j(t.x,t.y,g.width||e.offsetWidth,g.height||e.offsetHeight);g={width:i.width,height:i.height},o({x:i.x,y:i.y}),x()},startResize:function(t,e){t.preventDefault(),t.stopPropagation();const i=r();if(!i)return;const d=i.getBoundingClientRect();s()||(o({x:d.left,y:d.top}),a(!0)),u||(g={width:d.width,height:d.height},u=!0);const l=n();h=!0,c=e,f=t.pointerId,p={x:t.clientX,y:t.clientY,width:g.width,height:g.height,posX:l.x,posY:l.y,centerX:l.x+g.width/2,centerY:l.y+g.height/2},y=P,z=M,window.addEventListener("pointermove",y),window.addEventListener("pointerup",z),window.addEventListener("pointercancel",z),w.emit("resizeStart",{direction:e}),x()},subscribe:function(t){return w.on("change",t)},destroy:function(){y&&window.removeEventListener("pointermove",y),z&&(window.removeEventListener("pointerup",z),window.removeEventListener("pointercancel",z)),w.off()}}}({minWidth:(null==(n=null==(i=t.config)?void 0:i.appearance)?void 0:n.minWidth)??oe().appearance.minWidth,minHeight:(null==(s=null==(o=t.config)?void 0:o.appearance)?void 0:s.minHeight)??oe().appearance.minHeight,getPosition:()=>this.drag.getPosition(),setPosition:t=>this.drag.setPosition(t),getHasBeenDragged:()=>this.drag.hasBeenDragged(),setHasBeenDragged:t=>this.drag.setHasBeenDragged(t),getElement:()=>this.element,onResizeEnd:(t,e)=>this.handleResizeEnd(t,e)}),this.animation=function(t){const{getId:e,getElement:i,getPosition:n,setPosition:o,getHasBeenDragged:s,setHasBeenDragged:a,getHasBeenResized:r,getSize:d,areAnimationsEnabled:l=()=>!0,onMinimizeComplete:h,onOpenStart:c}=t;let g="none",u=!1,m=null,p=null,f=null,w=null,y=null,z=null,v=null;const x=Jt();function P(){return{type:g,isAnimating:u,transform:m?{...m}:null}}function M(){x.emit("change",P())}function I(){z&&(clearTimeout(z),z=null)}function b(){const t=i();!t||v||(v=function(t,e){const i=i=>{i.target===t&&e(i.animationName)};return t.addEventListener("animationend",i),()=>t.removeEventListener("animationend",i)}(t,C))}function C(t){I();const e=Ae[t];if(!e||!e.includes(g))return;const i={none:void 0,minimize:A,restore:B,open:H,close:S,attention:void 0}[g];i&&i()}function A(){"minimize"===g&&(I(),w?(w(),w=null):y&&(null==h||h(y.position,!0,y.size)),x.emit("animationEnd",{type:"minimize"}),y=null,g="none",u=!1,m=null,M())}function B(){if("restore"!==g)return;I(),g="none",u=!1,m=null;const t=i();t&&(t.setAttribute("data-state","open"),t.setAttribute("data-animation-phase","idle")),x.emit("animationEnd",{type:"restore"}),M()}function H(){if("open"!==g)return;I(),g="none",u=!1,m=null;const t=i();t&&(t.setAttribute("data-state","open"),t.setAttribute("data-animation-phase","idle")),x.emit("animationEnd",{type:"open"}),M()}function S(){if("close"!==g)return;I(),g="none",u=!1;const t=i();t&&(t.setAttribute("data-state","closed"),t.setAttribute("data-animation-phase","idle")),x.emit("animationEnd",{type:"close"}),f&&(f(),f=null),M()}return{getState:P,isAnimating:()=>u,getAnimationType:()=>g,getTransform:()=>m?{...m}:null,getPendingOpenSource:()=>p?{...p}:null,setPendingOpenSource:t=>{p=t?{...t}:null},startMinimize:function(t,c){const p=i();if(u||!p)return!1;if(b(),I(),!l()){const t=p.getBoundingClientRect(),e=s()?n():{x:t.left,y:t.top},i=r()?d():{width:t.width,height:t.height};return s()||(o(e),a(!0)),c?c():null==h||h(e,!0,i),!0}const f=p.getBoundingClientRect(),v=s()?n():{x:f.left,y:f.top},P=r()?d():{width:f.width,height:f.height};s()||(o(v),a(!0));const C=t??ze(e());return m=function(t,e,i){const n=t.x+e.width/2,o=t.y+e.height/2;return{x:i.x-n,y:i.y-o,originX:i.x-t.x,originY:i.y-t.y}}(v,P,C),w=c||null,y={position:v,size:P},p.setAttribute("data-state","minimizing"),p.setAttribute("data-animation-phase","prepare"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{g="minimize",u=!0,p.setAttribute("data-animation-phase","animate"),x.emit("animationStart",{type:"minimize"}),M()})}),z=setTimeout(()=>{"minimize"===g&&A()},600),!0},startRestore:function(t,n){const s=i();if(b(),I(),!l()){const e=t||{x:window.innerWidth/2,y:window.innerHeight/2};return o(e),void a(!0)}const r=ze(e()),d=t||{x:window.innerWidth/2,y:window.innerHeight/2},h=n||{width:480,height:400};o(d),a(!0),m=function(t,e,i){const n=t.x+e.width/2,o=t.y+e.height/2;return{x:i.x-n,y:i.y-o,originX:i.x-t.x,originY:i.y-t.y}}(d,h,r),g="restore",u=!0,s&&(s.setAttribute("data-state","restoring"),s.setAttribute("data-animation-phase","animate")),x.emit("animationStart",{type:"restore"}),M(),z=setTimeout(()=>{"restore"===g&&B()},500)},startOpen:function(){const t=i();if(!p||!t||u)return!1;if(b(),I(),!l())return p=null,!1;const e=p,r=t.getBoundingClientRect(),d=s()?n():{x:r.left,y:r.top},h=r.width,f=r.height;return s()||(o(d),a(!0)),m=function(t,e,i){const n=t.x+e.width/2,o=t.y+e.height/2;return{x:i.x-n,y:i.y-o,originX:i.x-t.x,originY:i.y-t.y}}(d,{width:h,height:f},e),g="open",u=!0,p=null,t.setAttribute("data-state","opening"),t.setAttribute("data-animation-phase","animate"),x.emit("animationStart",{type:"open"}),null==c||c(),M(),z=setTimeout(()=>{"open"===g&&H()},500),!0},startClose:function(t){const e=i();return!u&&(b(),I(),l()?(f=t,g="close",u=!0,e&&(e.setAttribute("data-state","closing"),e.setAttribute("data-animation-phase","animate")),x.emit("animationStart",{type:"close"}),M(),z=setTimeout(()=>{"close"===g&&S()},350),!0):(t(),!0))},forceClearMinimize:function(){I(),"minimize"===g&&(g="none",u=!1,m=null,w=null,y=null,M())},destroy:function(){I(),null==v||v(),v=null,x.off()},subscribe:t=>x.on("change",t)}}({getId:()=>this.id,getElement:()=>this.element,getPosition:()=>this.drag.getPosition(),setPosition:t=>this.drag.setPosition(t),getHasBeenDragged:()=>this.drag.hasBeenDragged(),setHasBeenDragged:t=>this.drag.setHasBeenDragged(t),getHasBeenResized:()=>this.resize.hasBeenResized(),getSize:()=>this.resize.getSize(),areAnimationsEnabled:()=>this.options.configHelper.isFeatureEnabled("animations"),onMinimizeComplete:(t,e,i)=>{mt(this.id,{position:t,size:i,hasBeenDragged:e}),It(this.id)},onOpenStart:()=>{const t=at(this.id);null!=t&&t.parentId&&(this.stateManager.wasRestored=!0)}}),this.positioning=new Be({id:this.id,dataId:this.dataId,configHelper:t.configHelper,getDragBehavior:()=>this.drag,getElement:()=>this.element}),this.interactions=new Re({id:this.id,configHelper:t.configHelper,getDragBehavior:()=>this.drag,getResizeBehavior:()=>this.resize,getElement:()=>this.element,getState:()=>{var t;return{hasChild:!(null==(t=at(this.id))||!t.childId)}},onDragMove:()=>{if("realtime"===oe().parentChild.movementMode){const t=this.drag.getPosition();gt(this.id,t,{drag:!0,realtime:!0})}},onDragEnd:()=>{const t=this.drag.getPosition();gt(this.id,t,{drag:!0}),"animated"===oe().parentChild.movementMode&&qt(this.id)},onClose:()=>this.close(),closeOnEscape:t.closeOnEscape,isTopModal:()=>X(this.id)}),this.stateManager=new ke({id:this.id,options:{glow:t.glow,openSourcePosition:t.openSourcePosition,onClose:t.onClose},getDragBehavior:()=>this.drag,getResizeBehavior:()=>this.resize,getAnimationController:()=>this.animation,getElement:()=>this.element,getPositioning:()=>this.positioning,onStateChange:()=>this.notifyStateChange(),focusFirst:()=>this.interactions.focusFirst()}),Vt(t.id)&&(this.stateManager.wasRestored=!0),this.lifecycle=new ce({onMount:()=>{this.handleStateChange(),this.handlePendingStates(),this.notifyStateChange()},onDestroy:()=>{var t;null==(t=this.unsubscribeState)||t.call(this),this.drag.destroy(),this.resize.destroy(),this.animation.destroy(),this.emitter.off()},onWindowResize:()=>this.handleWindowResize()}),this.drag.subscribe(()=>this.notifyStateChange()),this.resize.subscribe(()=>this.notifyStateChange()),this.animation.subscribe(()=>{this.handlePendingStates(),this.notifyStateChange()}),this.unsubscribeState=G(()=>{this.handleStateChange(),this.handlePendingStates(),this.notifyStateChange()}),t.skipRegistration||this.register(t.autoOpen??!1),this.handleStateChange(),this.handlePendingStates()}mount(t){this.lifecycle.mount(t)}destroy(){this.lifecycle.destroy()}get element(){return this.lifecycle.getElement()}handleWindowResize(){if(!this.element||!this.drag.hasBeenDragged())return;const t=this.resize.hasBeenResized()?this.resize.getSize():{width:this.element.offsetWidth,height:this.element.offsetHeight};this.positioning.constrainToViewport(t),this.resize.hasBeenResized()&&this.resize.constrainToViewport(),this.notifyStateChange()}register(t){le({id:this.id,title:this.options.title,icon:this.options.icon??"",isOpen:t,isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,isRejected:!1,position:null,size:null,hasBeenDragged:!1,dockPosition:0,glow:this.options.glow??null,parentId:void 0,childId:void 0,offsetFromParent:void 0}),t&&V(this.id)}getState(){if(this.cachedState)return this.cachedState;const t=at(this.id),e=this.drag.getState(),i=this.resize.getState(),n=this.animation.getState(),o=!!t&&(t.isOpen||Lt(this.id))&&(!t.isMinimized||Ot(this.id))&&(!t.isHiddenWithParent||Wt(this.id)||Yt(this.id)),s=!(null==t||!t.childId),a=!(null==t||!t.parentId),r="minimize"===n.type&&n.isAnimating,d="restore"===n.type&&n.isAnimating,l="open"===n.type&&n.isAnimating,h="close"===n.type&&n.isAnimating,c=n.isAnimating,g=(null==t?void 0:t.isAnimatingPosition)??!1,u=g&&null!=t&&t.position?t.position:e.position,m=!!g||e.hasBeenDragged,p=(Yt(this.id)||$t(this.id))&&!d,f=(a||Vt(this.id))&&!l&&(!m||!!this.animation.getPendingOpenSource()),w=d||l||this.stateManager.restoreHold,y=o&&!m&&!c&&!this.animation.getPendingOpenSource()&&!p&&!f;let z="closed";r||Ot(this.id)?z="minimizing":d?z="restoring":l?z="opening":h?z="closing":null!=t&&t.isMinimized?z="minimized":o&&(z="open");const v=this.options.configHelper.isFeatureEnabled("drag"),x=this.options.configHelper.isFeatureEnabled("resize"),P=this.options.configHelper.isFeatureEnabled("minimize"),M=!!this.options.glow,I=function(t){const e={"z-index":t.zIndex};return t.animationTransform?(e.left=`${t.position.x}px`,e.top=`${t.position.y}px`,e["--genie-origin-x"]=`${t.animationTransform.originX}px`,e["--genie-origin-y"]=`${t.animationTransform.originY}px`,e["--genie-translate-x"]=`${t.animationTransform.x}px`,e["--genie-translate-y"]=`${t.animationTransform.y}px`):t.hasBeenDragged&&(e.left=`${t.position.x}px`,e.top=`${t.position.y}px`,t.isAnimatingPosition||(e.transform="none")),t.hasBeenResized?(e.width=`${t.size.width}px`,e.height=`${t.size.height}px`,e["max-width"]="none",e["max-height"]="none"):(t.preferredHeight&&(e["min-height"]=t.preferredHeight),t.maxWidth&&(e["max-width"]=t.maxWidth)),t.glowEnabled&&t.glow&&(e["--modal-glow-color"]=t.glow.color,e["--modal-glow-intensity"]=String(t.glow.intensity??"medium")),e}({position:u,hasBeenDragged:m,hasBeenResized:i.hasBeenResized,size:i.size,animationTransform:n.transform,zIndex:(null==t?void 0:t.zIndex)??1e3,glowEnabled:M,glow:this.options.glow??null,maxWidth:this.options.maxWidth,preferredHeight:this.options.preferredHeight,isAnimatingPosition:g}),b=function(t){const e=["modal-dialog"];return t.isDragging&&e.push("modal-dragging"),t.isResizing&&e.push("modal-resizing"),t.hasBeenDragged&&e.push("modal-positioned"),t.isMinimizing&&e.push("modal-minimizing"),t.isRestoring&&e.push("modal-restoring"),t.isOpening&&e.push("modal-opening"),t.isClosing&&e.push("modal-closing"),t.showCentered&&e.push("modal-centered"),t.isTransparent||e.push("modal-solid"),t.isTransparent&&e.push("modal-transparent"),t.glowEnabled&&e.push("modal-glow"),t.hasChild&&e.push("modal-has-child"),t.isChildModal&&e.push("modal-is-child"),t.wasRestored&&e.push("modal-was-restored"),t.isVisibleByAnimation&&e.push("modal-visible-by-animation"),t.isAwaitingRestore&&e.push("modal-awaiting-restore"),t.isAwaitingChildOpen&&e.push("modal-awaiting-child-open"),t.isAnimatingToCenter&&e.push("modal-animating-to-center"),t.isAnimatingPosition&&e.push("modal-animating-position"),t.isAttentionAnimating&&e.push("modal-attention"),t.glowStabilizing&&t.glowEnabled&&e.push("modal-glow-stabilizing"),e}({isDragging:e.isDragging,isResizing:i.isResizing,hasBeenDragged:m,isMinimizing:r,isRestoring:d,isOpening:l,isClosing:h,showCentered:y,isTransparent:(null==t?void 0:t.isTransparent)??!1,glowEnabled:M,hasChild:s,isChildModal:a,wasRestored:this.stateManager.wasRestored,isVisibleByAnimation:w,isAwaitingRestore:p,isAwaitingChildOpen:f,isAnimatingToCenter:this.stateManager.isAnimatingToCenter,isAnimatingPosition:(null==t?void 0:t.isAnimatingPosition)??!1,isAttentionAnimating:this.stateManager.isAttentionAnimating,glowStabilizing:this.stateManager.glowStabilizing});return this.cachedState={position:e.position,size:i.size,zIndex:(null==t?void 0:t.zIndex)??1e3,isDragging:e.isDragging,isResizing:i.isResizing,hasBeenDragged:e.hasBeenDragged,hasBeenResized:i.hasBeenResized,isMinimizing:r,isRestoring:d,isOpening:l,isClosing:h,isAnyAnimating:c,animationTransform:n.transform,isVisible:o,showCentered:y,isAwaitingRestore:p,isAwaitingChildOpen:f,isVisibleByAnimation:w,hasChild:s,isChildModal:a,showOverlay:s||this.overlayClosing,isTransparent:(null==t?void 0:t.isTransparent)??!1,isAttentionAnimating:this.stateManager.isAttentionAnimating,glowStabilizing:this.stateManager.glowStabilizing,isAnimatingPosition:(null==t?void 0:t.isAnimatingPosition)??!1,isAnimatingToCenter:this.stateManager.isAnimatingToCenter,wasRestored:this.stateManager.wasRestored,overlayClosing:this.overlayClosing,glowEnabled:M,draggable:v,resizable:x,minimizable:P,dataState:z,dataAnimationPhase:n.isAnimating?"animate":"idle",style:I,cssClasses:b},this.cachedState}subscribe(t){return this.emitter.on("stateChange",t)}notifyStateChange(){this.cachedState=null,this.emitter.emit("stateChange",this.getState())}startDrag(t){this.interactions.startDrag(t)}startResize(t,e){this.interactions.startResize(t,e)}handlePointerMove(t){this.interactions.handlePointerMove(t)}handlePointerUp(t){this.interactions.handlePointerUp(t)}handleKeyDown(t){this.interactions.handleKeyDown(t)}handleTabKey(t){this.interactions.handleTabKey(t)}minimize(){this.options.configHelper.isFeatureEnabled("minimize")&&It(this.id)}close(){var t,e;_t(this.id)&&Gt(this.id),kt(this.id),null==(e=(t=this.options).onClose)||e.call(t)}toggleTransparency(){At(this.id)}bringToFront(){V(this.id)}setOpenSourcePosition(t){this.animation.setPendingOpenSource(t)}updateOptions(t){let e=!1;void 0!==t.glow&&this.options.glow!==t.glow&&(this.options.glow=t.glow,mt(this.id,{glow:t.glow??null}),e=!0),void 0!==t.maxWidth&&this.options.maxWidth!==t.maxWidth&&(this.options.maxWidth=t.maxWidth,e=!0),void 0!==t.preferredHeight&&this.options.preferredHeight!==t.preferredHeight&&(this.options.preferredHeight=t.preferredHeight,e=!0),void 0!==t.closeOnEscape&&this.options.closeOnEscape!==t.closeOnEscape&&(this.options.closeOnEscape=t.closeOnEscape,this.interactions.updateCloseOnEscape(t.closeOnEscape)),e&&this.notifyStateChange()}updateGlow(t){this.updateOptions({glow:t})}updateMaxWidth(t){this.updateOptions({maxWidth:t})}updatePreferredHeight(t){this.updateOptions({preferredHeight:t})}updateCloseOnEscape(t){this.updateOptions({closeOnEscape:t})}focusFirst(){this.interactions.focusFirst()}handleResizeEnd(t,e){const i=at(this.id);if(null!=i&&i.parentId){const n=at(i.parentId),o=nt(i.parentId);if(n&&o){const i=n.position??{x:o.getBoundingClientRect().left,y:o.getBoundingClientRect().top},s=n.size??{width:o.offsetWidth,height:o.offsetHeight},a={x:i.x+(s.width-e.width)/2,y:i.y+(s.height-e.height)/2},r=t;this.stateManager.isAnimatingToCenter=!0,this.drag.setPosition(a);const d={x:a.x-i.x,y:a.y-i.y};mt(this.id,{position:a,size:e,hasBeenDragged:!0,offsetFromParent:d});const l=this.lifecycle.getElement();return void(l?st(l,r,a,{duration:200,onComplete:()=>{this.stateManager.isAnimatingToCenter=!1}}):this.stateManager.isAnimatingToCenter=!1)}}mt(this.id,{position:t,size:e,hasBeenDragged:!0})}handleStateChange(){const t=at(this.id);if(t){if((t.parentId||Vt(this.id))&&(this.stateManager.wasRestored=!0),!this.drag.isDragging()&&!this.resize.isResizing()&&t.position){const e=this.drag.getPosition(),i=t.position;(Math.abs(e.x-i.x)>.5||Math.abs(e.y-i.y)>.5)&&(this.drag.setPosition(i),t.hasBeenDragged&&this.drag.setHasBeenDragged(!0))}this.stateManager.handlePendingStates()}}handlePendingStates(){this.stateManager.handlePendingStates()}getId(){return this.id}getDataId(){return this.dataId}getElement(){return this.element}}function Te(){const t=ht();return Array.from(t.values()).filter(t=>t.isMinimized).sort((t,e)=>t.dockPosition-e.dockPosition)}function Oe(t,e,i){const n=K(t.x,t.y,e,i);return{x:Math.round(n.x),y:Math.round(n.y)}}function We(t,e,i,n,o,s=8){const a=window.innerWidth-n-s,r=window.innerHeight-o-s,d=Math.min(Math.max(t-i.x,s),Math.max(s,a)),l=Math.min(Math.max(e-i.y,s),Math.max(s,r));return{x:Math.round(d),y:Math.round(l)}}function Fe(t,e){const i=["modal-dock-container"];return"left"===t?i.push("modal-dock-left"):"right"===t?i.push("modal-dock-right"):"bottom"===t?i.push("modal-dock-bottom"):"free"===t&&i.push("modal-dock-free"),e&&i.push("modal-dock-empty"),i.join(" ")}function Le(t,e){const i=["modal-dock"];return"free"===t&&i.push("horizontal"===e?"modal-dock-free-horizontal":"modal-dock-free-vertical"),i.join(" ")}function _e(){const t=ht();return Array.from(t.values()).some(t=>t.isOpen&&!t.isMinimized&&!t.isHiddenWithParent)}function Ge(){return Qt(oe().features.backdrop)}function $e(){const t=Ge();return t.visible||t.blockClicks}export{_e as A,Nt as B,ue as C,me as D,se as E,jt as F,vt as G,Ut as H,xt as I,Te as J,Oe as K,lt as L,Ee as M,Ht as N,ht as O,We as P,nt as Q,pe as R,ge as S,X as T,Fe as U,Le as V,ae as W,Qt as X,re as Y,Et as Z,At as _,ie as a,ne as b,ot as c,kt as d,Rt as e,at as f,_ as g,rt as h,dt as i,V as j,oe as k,fe as l,It as m,it as n,Dt as o,le as p,de as q,bt as r,G as s,Bt as t,he as u,Ft as v,Lt as w,Ot as x,Ge as y,$e as z};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "epic-modals",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "A stunning modal library with macOS-style animations, drag, resize, and dock. Supports Svelte 5, React, and vanilla JS.",
5
5
  "keywords": [
6
6
  "modal",