epic-modals 1.0.3 → 1.0.4
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.
- package/dist/backdrop.js +1 -0
- package/dist/core.d.ts +0 -1174
- package/dist/core.js +1 -1
- package/dist/react.js +1 -1
- package/dist/resolution.js +1 -0
- package/dist/svelte.d.ts +14 -165
- package/dist/svelte.js +1 -1
- package/dist/vanilla.d.ts +0 -24
- package/dist/vanilla.js +1 -1
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=(t,i,n)=>((t,i,n)=>i in t?e(t,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[i]=n)(t,"symbol"!=typeof i?i+"":i,n);const i=Symbol.for("epic-modals-core");if(typeof globalThis<"u"){const e=globalThis;e[i],e[i]=!0}const n=new Map;let o=0,s=null;function a(e){s=e}let r=null;function d(e){r=e}const l=new Set;let h=!1,c=!1,g=!1,u=[],m=[],p=[],f=[],w=[],y=[],z=[],v=[],M=[],P=null;function C(e){P=e}const x=new Map;let I=null;function b(e){I=e}const A=new Map,k=new Set,S=new Set,R=new Set;let D=[];function E(e){D=e}let B=null;function H(e){B=e}let T=null;function O(e){T=e}let F=null;function L(e){F=e}function W(e){u=e}function _(e){m=e}function G(e){p=e}function $(e){f=e}function V(e){w=e}function N(e){y=e}function Y(e){z=e}function X(e){v=e}function q(e){M=e}function U(){if(!g){g=!0;try{l.forEach(e=>e())}finally{g=!1}}}function j(){o++,h?c=!0:U()}function K(){return o}function Z(e){return l.add(e),()=>l.delete(e)}function J(e){const t=h;h=!0;try{e()}finally{h=t,!t&&c&&(c=!1,queueMicrotask(()=>{U()}))}}function Q(e,t){if(e.width<=0||e.height<=0)throw new Error(`[epic-modals] Invalid dimensions in ${t}: width=${e.width}, height=${e.height}`)}function ee(e,t){return!!n.get(e)||(function(){var e,t;try{const i=import.meta;return!0===(null==(e=i.env)?void 0:e.DEV)||"development"===(null==(t=i.env)?void 0:t.MODE)}catch{return!1}}(),!1)}function te(){n.clear(),u=[],m=[],p=[],f=[],w=[],y=[],z=[],v=[],M=[],P=null,x.clear(),I=null,A.clear(),k.clear(),S.clear(),R.clear(),D=[],B=null,T=null,F=null,s&&(clearTimeout(s),s=null),r&&(clearTimeout(r),r=null)}function ie(){return{modals:n,pendingMinimize:u,pendingOpen:m,pendingClose:p,pendingRestore:w,dockOrder:D,animatingModals:k,transparentModals:R}}function ne(e){return{id:e.id,title:e.title,icon:e.icon??"",isOpen:e.autoOpen??!1,isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,isRejected:!1,position:null,size:null,hasBeenDragged:!1,dockPosition:0,glow:e.glow??null,parentId:void 0,childId:void 0,offsetFromParent:void 0}}function oe(e){const t=n.get(e.id);let i;i=null!=t&&t.zIndex?t.zIndex:Math.max(...Array.from(n.values()).map(e=>e.zIndex),mi().zIndex.base-2)+2;const o=m.includes(e.id),s=e.isOpen||o;t?n.set(e.id,{...t,title:e.title,icon:e.icon,glow:e.glow,zIndex:i}):n.set(e.id,{...e,isOpen:s,zIndex:i,isAnimating:!1}),j(),e.isMinimized&&!D.includes(e.id)&&E([...D,e.id])}function se(e){const t=n.get(e);if(t){if(E(D.filter(t=>t!==e)),_(m.filter(t=>t!==e)),G(p.filter(t=>t!==e)),$(f.filter(t=>t!==e)),W(u.filter(t=>t!==e)),V(w.filter(t=>t!==e)),N(y.filter(t=>t!==e)),Y(z.filter(t=>t!==e)),X(v.filter(t=>t!==e)),t.childId){const e=n.get(t.childId);e&&n.set(t.childId,{...e,parentId:void 0})}if(t.parentId){const e=n.get(t.parentId);e&&n.set(t.parentId,{...e,childId:void 0,lastChildId:t.id})}n.delete(e),j(),R.delete(e),k.delete(e)}}function ae(e,t){const i=n.get(e);if(null==i||!i.childId)return;const o=n.get(i.childId);if(!o)return;const s=t+2;n.set(i.childId,{...o,zIndex:s}),ae(i.childId,s)}function re(e){if(!n.get(e))return;const t=Math.max(...Array.from(n.values()).map(e=>e.zIndex),0),i=function(e){let t=e,i=n.get(t);for(;null!=i&&i.parentId;)t=i.parentId,i=n.get(t);return t}(e),o=n.get(i);if(!o)return;const s=t+2;n.set(i,{...o,zIndex:s}),ae(i,s),j()}function de(e){const t=n.get(e);if(!t)return!1;const i=Math.max(...Array.from(n.values()).map(e=>e.zIndex),0);return t.zIndex===i&&!t.isMinimized&&!t.isHiddenWithParent}function le(e,t){if(Array.isArray(e))E(e);else if("number"==typeof t){const i=e,n=[...D],[o]=n.splice(i,1);n.splice(t,0,o),E(n)}}const he=8;function ce(e,t,i,n,o={}){const{margin:s=he,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,e)),y:Math.max(c,Math.min(g,t))}}function ge(e,t,i,n,o={}){const{margin:s=he}=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=ce(e,t,d,l,o);return{x:h.x,y:h.y,width:d,height:l}}function ue(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function me(e,t,i,n,o,s){const a={x:e-s,y:t-s,width:i+2*s,height:n+2*s};let r=0;for(const e of o)r+=ue(a,e);return r}function pe(e,t){const i=t.x-(e.x+e.width),n=e.x-(t.x+t.width),o=t.y-(e.y+e.height),s=e.y-(t.y+t.height),a=Math.max(i,n,0),r=Math.max(o,s,0);return 0===a&&0===r?0:Math.sqrt(a*a+r*r)}function fe(e){if(typeof document>"u")return[];const t=[];for(const i of e)try{const e=document.querySelectorAll(i);for(const i of e){const e=i.getBoundingClientRect();e.width>0&&e.height>0&&t.push({x:e.left,y:e.top,width:e.width,height:e.height})}}catch{}return t}function we(e,t,i,n,o){let s=i,a=i,r=e-i,d=t-i;for(const i of n){const n=i.y,l=t-(i.y+i.height),h=i.x,c=e-(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 e=Math.min(n,l,h,c);g=e===n?"top":e===l?"bottom":e===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)}}function ye(e,t,i,n){const o=e-t,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 ze(e,t,i,n,o=0){if(0===i.length)return{cols:e,rows:t,score:1/0,positions:new Map};const s=new Array(e).fill(0),a=new Array(t).fill(0);for(let t=0;t<i.length;t++){const n=t%e,o=Math.floor(t/e);s[n]=Math.max(s[n],i[t].width),a[o]=Math.max(a[o],i[t].height)}const r=s.reduce((e,t)=>e+t,0),d=a.reduce((e,t)=>e+t,0);if(r>n.width||d>n.height)return null;const{interGap:l,edgeGap:h}=ye(n.width,r,e,o),{interGap:c,edgeGap:g}=ye(n.height,d,t,o),u=new Map,m=[0];for(let t=0;t<e;t++)m.push(m[t]+s[t]);const p=[0];for(let e=0;e<t;e++)p.push(p[e]+a[e]);for(let t=0;t<i.length;t++){const o=t%e,r=Math.floor(t/e),d=i[t],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=e>1?l:h,w=t>1?c:g;return{cols:e,rows:t,score:(.6*Math.min(f,w)+.4*Math.sqrt(f*w))*(n.width>n.height==e>=t?1.02:1),positions:u}}function ve(e,t){const i=new Map,n=Math.max(...e.map(e=>e.width)),o=Math.max(...e.map(e=>e.height)),s=n+40*(e.length-1),a=o+40*(e.length-1);let r=t.x+(t.width-s)/2,d=t.y+(t.height-a)/2;r=Math.max(t.x,r),d=Math.max(t.y,d);for(let t=0;t<e.length;t++)i.set(e[t].id,{x:Math.round(r+40*t),y:Math.round(d+40*t)});return i}function Me(e,t,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=e.filter(e=>!e.parentId),c=h.map(e=>({id:e.id,width:e.width,height:e.height}));if(t&&c.push({id:t.id,width:t.width,height:t.height}),0===c.length)return{positions:l};const g=new Map(h.map(e=>[e.id,e.currentPosition]));c.sort((e,t)=>{const i=g.get(e.id),n=g.get(t.id);return(i?i.x+e.width/2:1/0)-(n?n.x+t.width/2:1/0)});const u=we(r,d,o,s,a);if(1===c.length){const e=c[0],t=u.x+(u.width-e.width)/2,i=u.y+(u.height-e.height)/2;return l.set(e.id,{x:Math.round(t),y:Math.round(i)}),{positions:l}}const m=c.length;let p=null;for(let e=1;e<=m;e++){const t=ze(e,Math.ceil(m/e),c,u,n);t&&(null===p||t.score>p.score)&&(p=t)}if(p){for(const[e,t]of p.positions)l.set(e,t);return{positions:l}}if(t){const e=h.map(e=>({x:e.currentPosition.x,y:e.currentPosition.y,width:e.width,height:e.height})),i=function(e,t,i,n,o=20){const s=n.x+(n.width-e)/2,a=n.y+(n.height-t)/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-e),l=n.y,h=Math.max(n.y,n.y+n.height-t);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=e*t,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=me(o,a,e,t,i,0),h=p>0?d/p:0,z=Math.hypot(o+e/2-w,a+t/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)}}(t.width,t.height,e,u);return l.set(t.id,i),{positions:l}}return{positions:ve(c,u)}}function Pe(e){return e}function Ce(e){return typeof document>"u"?null:document.querySelector(`.modal-dialog[data-modal-id="${e}"]`)}function xe(){return{x:window.innerWidth/2,y:window.innerHeight/2}}const Ie={minimize:500,restore:400,open:400,close:250,attention:300,parentMove:300,parentRetargetInterval:100,centerAfterResize:200,glowStabilize:1e3,overlayFade:200},be=100,Ae={easeOut:"ease-out",easeOutCubic:"cubic-bezier(0.25, 0.1, 0.25, 1)",linear:"linear",easeInOut:"ease-in-out"};function ke(e){switch(e){case"open":return Ie.open;case"close":return Ie.close;case"minimize":return Ie.minimize;case"restore":return Ie.restore;case"attention":return Ie.attention;default:return 0}}function Se(e){switch(e){case"open":case"restore":return Ae.easeOut;case"close":case"minimize":return Ae.easeOutCubic;case"attention":return Ae.easeInOut;default:return Ae.linear}}function Re(e,t,i,n){var o;const s=t.x-i.x,a=t.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)??Ie.parentMove,d=(null==n?void 0:n.easing)??"ease-out";let l=!1;function h(){var e;l||(l=!0,clearTimeout(g),null==(e=null==n?void 0:n.onComplete)||e.call(n))}e.style.left=`${i.x}px`,e.style.top=`${i.y}px`;const c=e.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+be);return function(){l||(l=!0,clearTimeout(g),c.cancel())}}function De(e){return n.get(e)}function Ee(e){const t=n.get(e);return(null==t?void 0:t.isOpen)??!1}function Be(e){return n.has(e)}function He(e){return k.has(e)}function Te(e,t){t?k.add(e):k.delete(e)}function Oe(){return n}function Fe(){return D}function Le(e){return typeof document>"u"?null:document.querySelector(`[data-dock-item="${e}"]`)}function We(){const e=[];for(const t of n.values()){if(!t.isOpen||t.isMinimized||t.isHiddenWithParent||S.has(t.id))continue;const i=Ce(t.id);if(!i)continue;const n=t.position??{x:i.getBoundingClientRect().left,y:i.getBoundingClientRect().top},o=t.size??{width:i.offsetWidth,height:i.offsetHeight};e.push({id:t.id,width:o.width,height:o.height,currentPosition:n,parentId:t.parentId})}return e}function _e(e){const t=[];for(const i of n.values())if(i.isOpen&&!i.isMinimized&&!i.isHiddenWithParent&&(!e||i.id!==e))if(i.position&&i.size)t.push({x:i.position.x,y:i.position.y,width:i.size.width,height:i.size.height});else{const e=Ce(i.id);if(e){const i=e.getBoundingClientRect();t.push({x:i.left,y:i.top,width:i.width,height:i.height})}}return t}function Ge(e){const t=[];for(const i of n.values())if(i.isOpen&&!i.isMinimized&&!i.isHiddenWithParent&&(!e||i.id!==e))if(i.position&&i.size)t.push({id:i.id,x:i.position.x,y:i.position.y,width:i.size.width,height:i.size.height});else{const e=Ce(i.id);if(e){const n=e.getBoundingClientRect();t.push({id:i.id,x:n.left,y:n.top,width:n.width,height:n.height})}}return t}function $e(e,t,i){if(!ee(e))return;(function(e){if(!Number.isFinite(e.x)||!Number.isFinite(e.y))throw new Error(`[epic-modals] Invalid position in updateModalPosition: x=${e.x}, y=${e.y}`)})(t),null!=i&&i.size&&Q(i.size,"updateModalPosition");const o=n.get(e);if(!o)return;let s=t;if(null!=i&&i.constrain&&o.size&&(s=ce(t.x,t.y,o.size.width,o.size.height)),n.set(e,{...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 t=e,i=s;for(;;){const e=n.get(t);if(null==e||!e.childId)break;const o=n.get(e.childId);if(null==o||!o.offsetFromParent)break;const s={x:i.x+o.offsetFromParent.x,y:i.y+o.offsetFromParent.y};n.set(e.childId,{...o,position:s,hasBeenDragged:!0}),t=e.childId,i=s}}if(o.parentId&&o.offsetFromParent){const t=mi();let a=e,r=o;for(;r.parentId&&r.offsetFromParent;){const o=n.get(r.parentId);if(!o)break;const d=a===e?s:n.get(a).position,l={x:d.x-r.offsetFromParent.x,y:d.y-r.offsetFromParent.y};if(!("animated"!==t.parentChild.movementMode||null!=i&&i.realtime)){A.set(r.parentId,l);break}n.set(r.parentId,{...o,position:l,hasBeenDragged:!0}),a=r.parentId,r=o}}j()}function Ve(e){const t=n.get(e);if(!t||!t.isAnimatingPosition)return;t.isAnimatingPosition=!1;let i=t.childId;for(;i;){const e=n.get(i);e&&(e.isAnimatingPosition=!1),i=null==e?void 0:e.childId}j()}function Ne(e,t){if(!ee(e))return;Q(t,"updateModalSize");const i=n.get(e);i&&(n.set(e,{...i,size:t}),j())}function Ye(e,t){const i=n.get(e);i&&(n.set(e,{...i,...t}),j())}function Xe(e){const t=mi();"smart"===t.positioning.strategy&&(s&&clearTimeout(s),a(setTimeout(()=>{const i=We(),n=fe(t.positioning.avoidElements);qe(Me(i,e,{modalGap:t.positioning.modalGap,viewportMargin:t.positioning.modalGap,avoidBounds:n,avoidMargin:t.positioning.modalGap}).positions),a(null)},50)))}function qe(e){if(0===e.size)return;const t=[];for(const[i,o]of e){const e=n.get(i);if(!e)continue;const s=Ce(i),a=e.position??(s?{x:s.getBoundingClientRect().left,y:s.getBoundingClientRect().top}:{x:0,y:0}),r=e.size??(s?{width:s.offsetWidth,height:s.offsetHeight}:{width:0,height:0});t.push({id:i,element:s,oldPosition:a,newPosition:o,size:r}),Ue(i,a,o,t)}for(const{id:e,newPosition:i,size:o}of t){const t=n.get(e);t&&n.set(e,{...t,position:i,size:o,hasBeenDragged:!0,isAnimatingPosition:!0})}j();for(const{id:e,element:i,oldPosition:n,newPosition:o}of t)i?Re(i,n,o,{duration:Ie.parentMove,onComplete:()=>Ve(e)}):setTimeout(()=>Ve(e),Ie.parentMove+be)}function Ue(e,t,i,o){const s=n.get(e);if(null==s||!s.childId)return;const a=n.get(s.childId);if(null==a||!a.offsetFromParent)return;const r=Ce(s.childId),d={x:t.x+a.offsetFromParent.x,y:t.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&&Ue(s.childId,d,l,o)}function je(){r&&clearTimeout(r),d(setTimeout(()=>{Xe(null),d(null)},100))}let Ke=!1;function Ze(){Ke||typeof window>"u"||(window.addEventListener("resize",je),Ke=!0)}function Je(){typeof window>"u"||(window.removeEventListener("resize",je),Ke=!1)}function Qe(e){if(0===e.size)return;const t=[];for(const[i,o]of e){const e=n.get(i);if(!e)continue;const s=Ce(i),a=e.position??(s?{x:s.getBoundingClientRect().left,y:s.getBoundingClientRect().top}:{x:0,y:0});t.push({id:i,element:s,oldPosition:a,newPosition:o})}for(const{id:e,newPosition:i}of t){const t=n.get(e);t&&n.set(e,{...t,position:i,hasBeenDragged:!0,isAnimatingPosition:!0})}j();for(const{id:e,element:i,oldPosition:n,newPosition:o}of t)i?Re(i,n,o,{duration:Ie.parentMove,onComplete:()=>Ve(e)}):setTimeout(()=>Ve(e),Ie.parentMove+be)}function et(e){A.delete(e)}function tt(e){const t=n.get(e);if(null==t||!t.childId)return;const i=n.get(t.childId);i&&(z.includes(t.childId)||Y([...z,t.childId]),i.childId&&tt(t.childId))}function it(e){const t=n.get(e);if(!t||t.isMinimized)return;if(et(e),t.parentId){const e=n.get(t.parentId);if(e&&!e.isMinimized)return void it(t.parentId)}if(W([...u,e]),t.position&&t.size&&T){const i=T(),n=D.indexOf(e);C({x:i.x+n*(i.height+8),y:i.y,originX:t.position.x+t.size.width/2,originY:t.position.y+t.size.height/2})}const i=t.childId;n.set(e,{...t,isMinimized:!0,lastChildId:i}),D.includes(e)||E([...D,e]),j(),t.childId&&tt(e),Xe(null)}function nt(e){const t=n.get(e);if(!t||!t.isMinimized)return;n.set(e,{...t,isMinimized:!1,isOpen:!0}),V([...w,e]),re(e);const i=t.lastChildId||t.childId;i&&st(i),j()}function ot(){Array.from(n.values()).filter(e=>e.isMinimized).map(e=>e.id).forEach(e=>{const t=n.get(e);if(t){n.set(e,{...t,isMinimized:!1,isOpen:!0}),V([...w,e]),re(e);const i=t.lastChildId||t.childId;i&&st(i)}}),E([]),j()}function st(e){const t=n.get(e);if(t&&t.isHiddenWithParent){N([...y,e]);const i=t.lastChildId||t.childId;i&&st(i)}}function at(e){const t=n.get(e);!t||!t.isHiddenWithParent||(n.set(e,{...t,isHiddenWithParent:!1}),j())}function rt(e){const t=n.get(e);t&&(n.set(e,{...t,isHiddenWithParent:!0}),j())}function dt(e){const t=n.get(e);if(null==t||!t.childId)return;const i=n.get(t.childId);i&&(i.childId&&dt(t.childId),n.set(t.childId,{...i,isHiddenWithParent:!0}),j())}function lt(e){if(!ee(e))return;const t=n.get(e);R.has(e)?(R.delete(e),n.set(e,{...t,isTransparent:!1})):(R.add(e),n.set(e,{...t,isTransparent:!0})),j()}function ht(e){ee(e)&&(v.includes(e)||(X([...v,e]),j()))}function ct(e){e.classList.add("modal-shake"),e.addEventListener("animationend",()=>{e.classList.remove("modal-shake")},{once:!0})}function gt(e){if(!ee(e))return;const t=n.get(e);n.set(e,{...t,isRejected:!0}),j(),setTimeout(()=>{const t=n.get(e);t&&(n.set(e,{...t,isRejected:!1}),j())},300);const i=Ce(e);i&&ct(i)}function ut(e){if(!ee(e))return;const t=n.get(e);R.delete(e),n.set(e,{...t,isTransparent:!1}),j()}function mt(e){}function pt(e){}function ft(e,t,i){wt(e,i,{parentId:t})}function wt(e,t,i){const o=mi(),s=n.get(e);if(s&&s.isOpen&&!s.isMinimized&&!s.isHiddenWithParent)return ht(e),void re(e);if(s&&s.isMinimized)return void nt(e);if("x"in t&&"y"in t)x.set(e,t);else{const i=t.getBoundingClientRect();x.set(e,{x:i.left+i.width/2,y:i.top+i.height/2})}if(null!=i&&i.parentId&&o.features.parentChild){const t=n.get(i.parentId);null!=t&&t.childId&&t.childId!==e&&zt(t.childId,!0),b({parentId:i.parentId,childId:e})}if(m.includes(e)||_([...m,e]),j(),!s)return void(null!=F&&F.isRegisteredInRegistry(e)&&F.mountModal(e));const a={isOpen:!0};null!=i&&i.parentId&&o.features.parentChild&&(a.parentId=i.parentId),n.set(e,{...s,...a}),re(e),null==B||B.push(e)}function yt(e){oe(e);const t=n.get(e.id);t&&(n.set(e.id,{...t,isOpen:!0}),j()),_([...m,e.id]),j(),re(e.id),null==B||B.push(e.id)}function zt(e,t=!1){const i=n.get(e);if(i&&(i.isOpen||i.isMinimized)){if(et(e),i.childId&&zt(i.childId,t),i.isMinimized)return E(D.filter(t=>t!==e)),Mt(e),void(null==B||B.pop());S.add(e),t?$([...f,e]):G([...p,e]),i.parentId||Xe(null),j(),null==B||B.pop()}}function vt(e){const t=new Set(e??[]);Array.from(n.keys()).filter(e=>!t.has(e)).forEach(e=>zt(e,!0))}function Mt(e){const t=n.get(e);if(t){if(S.delete(e),t.parentId){const i=n.get(t.parentId);i&&i.childId===e&&n.set(t.parentId,{...i,childId:void 0,lastChildId:e})}n.set(e,{...t,isOpen:!1,isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,position:null,size:null,hasBeenDragged:!1,parentId:void 0,childId:void 0,offsetFromParent:void 0}),j()}}function Pt(e){if(Array.isArray(e)){const t=new Set(e);return Array.from(n.entries()).filter(([e,i])=>i.isOpen&&!t.has(e)).map(([e])=>e)}const t=n.get(e);if(!t)return[e];const i=[e];return t.childId&&i.push(...Pt(t.childId)),i}function Ct(e){return u.includes(e)}function xt(e){W(u.filter(t=>t!==e));const t=P;return C(null),t}function It(e){return z.includes(e)}function bt(e){Y(z.filter(t=>t!==e))}function At(e){return m.includes(e)}function kt(e){_(m.filter(t=>t!==e))}function St(e){return p.includes(e)}function Rt(e){G(p.filter(t=>t!==e))}function Dt(e){return f.includes(e)}function Et(e){$(f.filter(t=>t!==e))}function Bt(e){return w.includes(e)}function Ht(e){V(w.filter(t=>t!==e))}function Tt(e){return y.includes(e)}function Ot(e){N(y.filter(t=>t!==e))}function Ft(e){return v.includes(e)}function Lt(e){X(v.filter(t=>t!==e)),M.includes(e)||q([...M,e])}function Wt(e){q(M.filter(t=>t!==e))}function _t(e){return(null==I?void 0:I.childId)===e}function Gt(e){return A.has(e)}function $t(e){const t=A.get(e)??null;return A.delete(e),t}function Vt(e,t){x.set(e,t)}function Nt(e){return x.get(e)??null}function Yt(e){const t=x.get(e)??null;return x.delete(e),t}function Xt(){const e=P;return C(null),e}function qt(e){const t=I;return e&&(null==t?void 0:t.childId)!==e?null:(b(null),t)}function Ut(e,t,i){const o=n.get(e),s=n.get(t);!o||!s||(n.set(e,{...o,childId:t}),n.set(t,{...s,parentId:e,offsetFromParent:i}),re(t),j())}function jt(){return I}function Kt(e){if("animated"!==mi().parentChild.movementMode)return;const t=n.get(e);if(null==t||!t.parentId||!t.offsetFromParent||!t.position)return;const i={x:t.position.x-t.offsetFromParent.x,y:t.position.y-t.offsetFromParent.y};A.set(t.parentId,i),j()}function Zt(e){return A.get(e)??null}function Jt(e,t,i){const o=n.get(e);if(!o)return null;const s=Ce(e);if(!s)return null;const a=o.position??{x:s.getBoundingClientRect().left,y:s.getBoundingClientRect().top},r=o.size??{width:s.offsetWidth,height:s.offsetHeight};return{x:a.x+(r.width-t)/2,y:a.y+(r.height-i)/2}}const Qt={BASE:0,DROPDOWN:100,STICKY:200,OVERLAY:300,MODAL:400,DOCK:8e3,TOAST:9e3};let ei=Qt.MODAL;function ti(){ei=mi().zIndex.base}function ii(){const e=ei;return ei+=2,e}function ni(e){const t=mi();return"MODAL"===e?t.zIndex.base:"DOCK"===e?t.zIndex.dock:"TOAST"===e?t.zIndex.toast:Qt[e]}function oi(){ei=mi().zIndex.base}function si(){const e=new Map;return{on(t,i){let n=e.get(t);return n||(n=new Set,e.set(t,n)),n.add(i),()=>{null==n||n.delete(i),0===(null==n?void 0:n.size)&&e.delete(t)}},emit(t,i){const n=e.get(t);n&&n.forEach(e=>e(i))},off(t){t?e.delete(t):e.clear()},listenerCount(t){var i;return(null==(i=e.get(t))?void 0:i.size)??0}}}function ai(e){return"boolean"==typeof e?{visible:e,blockClicks:e}:e}const ri={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"};let di={...ri},li=0;const hi=new Set;function ci(e){return hi.add(e),()=>hi.delete(e)}function gi(){hi.forEach(e=>e())}function ui(){return li}function mi(){return di}function pi(e){const t=di;di=wi(di,e),li++,gi(),t.features.dock&&!di.features.dock&&ot()}function fi(){di={...ri},li++,gi()}function wi(e,t){var i;return{features:{...e.features,...t.features},dock:{...e.dock,...t.dock},animations:{...e.animations,...t.animations},appearance:{...e.appearance,...t.appearance},zIndex:{...e.zIndex,...t.zIndex},parentChild:{...e.parentChild,...t.parentChild},positioning:{...e.positioning,...t.positioning,avoidElements:(null==(i=t.positioning)?void 0:i.avoidElements)??e.positioning.avoidElements},portalTarget:t.portalTarget??e.portalTarget}}function yi(e){const t=di.features[e];if("backdrop"===e){const e=ai(t);return e.visible||e.blockClicks}return t}function zi(e,t){const i=mi(),n=t?wi(i,t):i;return{isFeatureEnabled:t=>{var i;if(void 0!==(null==(i=null==e?void 0:e.features)?void 0:i[t])){const i=e.features[t];if("backdrop"===t){const e=ai(i);return e.visible||e.blockClicks}return i}const o=n.features[t];if("backdrop"===t){const e=ai(o);return e.visible||e.blockClicks}return o},getAppearance:t=>{var i;return void 0!==(null==(i=null==e?void 0:e.appearance)?void 0:i[t])?e.appearance[t]:n.appearance[t]},getPositioning:t=>{var i;return void 0!==(null==(i=null==e?void 0:e.positioning)?void 0:i[t])?e.positioning[t]:n.positioning[t]},getEffectiveConfig:()=>n}}function vi(e){const{getModalConfig:t,getProviderConfig:i}=e;return{getEffectiveConfig:function(){const e=mi(),n=i(),o=t();let s=e;return n&&(s=wi(s,n)),o&&(s={...s,features:{...s.features,...o.features},appearance:{...s.appearance,...o.appearance},animations:{...s.animations,...o.animations},positioning:{...s.positioning,...o.positioning},parentChild:{...s.parentChild,...o.parentChild}}),s},isFeatureEnabled:function(e){var n,o;const s=t(),a=i(),r=t=>{if(void 0!==t){if("backdrop"===e&&"object"==typeof t){const e=ai(t);return e.visible||e.blockClicks}return t}},d=r(null==(n=null==s?void 0:s.features)?void 0:n[e]);if(void 0!==d)return d;const l=r(null==(o=null==a?void 0:a.features)?void 0:o[e]);return void 0!==l?l:r(mi().features[e])??!1},getAppearance:function(e){var n,o;const s=t(),a=i();return void 0!==(null==(n=null==s?void 0:s.appearance)?void 0:n[e])?s.appearance[e]:void 0!==(null==(o=null==a?void 0:a.appearance)?void 0:o[e])?a.appearance[e]:mi().appearance[e]},getAnimation:function(e){var n,o;const s=t(),a=i();return void 0!==(null==(n=null==s?void 0:s.animations)?void 0:n[e])?s.animations[e]:void 0!==(null==(o=null==a?void 0:a.animations)?void 0:o[e])?a.animations[e]:mi().animations[e]},getPositioning:function(e){var n,o;const s=t(),a=i();return void 0!==(null==(n=null==s?void 0:s.positioning)?void 0:n[e])?s.positioning[e]:void 0!==(null==(o=null==a?void 0:a.positioning)?void 0:o[e])?a.positioning[e]:mi().positioning[e]},getParentChild:function(e){var n,o;const s=t(),a=i();return void 0!==(null==(n=null==s?void 0:s.parentChild)?void 0:n[e])?s.parentChild[e]:void 0!==(null==(o=null==a?void 0:a.parentChild)?void 0:o[e])?a.parentChild[e]:mi().parentChild[e]}}}const Mi={modal:"modal-dialog",modalDragging:"modal-dragging",modalResizing:"modal-resizing",modalPositioned:"modal-positioned",modalMinimizing:"modal-minimizing",modalRestoring:"modal-restoring",modalOpening:"modal-opening",modalClosing:"modal-closing",modalCentered:"modal-centered",modalSolid:"modal-solid",modalTransparent:"modal-transparent",modalGlow:"modal-glow",modalHasGlow:"modal-has-glow",modalHasChild:"modal-has-child",modalIsChild:"modal-is-child",modalWasRestored:"modal-was-restored",modalVisibleByAnimation:"modal-visible-by-animation",modalAwaitingRestore:"modal-awaiting-restore",modalAwaitingChildOpen:"modal-awaiting-child-open",modalAnimatingToCenter:"modal-animating-to-center",modalAnimatingPosition:"modal-animating-position",modalAttention:"modal-attention",modalGlowStabilizing:"modal-glow-stabilizing",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",resizeN:"modal-resize-n",resizeS:"modal-resize-s",resizeE:"modal-resize-e",resizeW:"modal-resize-w",resizeNE:"modal-resize-ne",resizeNW:"modal-resize-nw",resizeSE:"modal-resize-se",resizeSW:"modal-resize-sw",resizePrefix:"modal-resize-",dock:"modal-dock",dockContainer:"modal-dock-container",dockItem:"modal-dock-item",dockItemActive:"modal-dock-item-active",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",dockLeft:"modal-dock-left",dockRight:"modal-dock-right",dockBottom:"modal-dock-bottom",dockFree:"modal-dock-free",dockEmpty:"modal-dock-empty",dockFreeHorizontal:"modal-dock-free-horizontal",dockFreeVertical:"modal-dock-free-vertical",backdrop:"modal-backdrop",backdropVisible:"modal-backdrop-visible",srOnly:"sr-only",reactBodyContent:"react-modal-body-content",reactFooterContent:"react-modal-footer-content"},Pi={dialog:Mi.modal,dialogCentered:Mi.modalCentered,dialogDragging:Mi.modalDragging,dialogResizing:Mi.modalResizing,dialogMinimizing:Mi.modalMinimizing,dialogRestoring:Mi.modalRestoring,dialogOpening:Mi.modalOpening,dialogClosing:Mi.modalClosing,dialogSolid:Mi.modalSolid,dialogTransparent:Mi.modalTransparent,dialogHasGlow:Mi.modalHasGlow,dialogHasChild:Mi.modalHasChild,dialogIsChild:Mi.modalIsChild,dialogAnimatingPosition:Mi.modalAnimatingPosition,dialogAttention:Mi.modalAttention,header:Mi.header,headerDraggable:Mi.headerDraggable,headerLayout:e=>`modal-header--${e}`,body:Mi.body,footer:Mi.footer,childOverlay:Mi.childOverlay,overlayClosing:Mi.overlayClosing,headerTitle:Mi.headerTitle,headerIcon:Mi.headerIcon,headerTitleGroup:Mi.headerTitleGroup,headerActions:Mi.headerActions,headerTrafficLights:Mi.headerTrafficLights,headerLight:Mi.headerLight,headerLightClose:Mi.headerLightClose,headerLightMinimize:Mi.headerLightMinimize,headerLightStyle:Mi.headerLightStyle,headerLightDisabled:Mi.headerLightDisabled,headerMacCenter:Mi.headerMacCenter,headerMacSpacer:Mi.headerMacSpacer,headerBtnWindows:Mi.headerBtnWindows,headerBtnWindowsClose:Mi.headerBtnWindowsClose,headerBtnWindowsStyle:Mi.headerBtnWindowsStyle,headerBtnWindowsDisabled:Mi.headerBtnWindowsDisabled,resizeHandles:Mi.resizeHandles,resizeHandle:Mi.resizeHandle,resizePrefix:Mi.resizePrefix,dock:Mi.dock,dockContainer:Mi.dockContainer,dockItem:Mi.dockItem,dockItemActive:Mi.dockItemActive,dockItemHasGlow:Mi.dockItemHasGlow,dockItemHasChild:Mi.dockItemHasChild,dockItemLabelBeside:Mi.dockItemLabelBeside,dockItemLabelBelow:Mi.dockItemLabelBelow,dockItemIcon:Mi.dockItemIcon,dockItemIconPlaceholder:Mi.dockItemIconPlaceholder,dockItemLabel:Mi.dockItemLabel,dockItemGlow:Mi.dockItemGlow,dockChildIndicator:Mi.dockChildIndicator,dockHandle:Mi.dockHandle,dockHandleDragging:Mi.dockHandleDragging,dockLeft:Mi.dockLeft,dockRight:Mi.dockRight,dockBottom:Mi.dockBottom,dockFree:Mi.dockFree,dockEmpty:Mi.dockEmpty,dockFreeHorizontal:Mi.dockFreeHorizontal,dockFreeVertical:Mi.dockFreeVertical,backdrop:Mi.backdrop,backdropVisible:Mi.backdropVisible},Ci={modalId:"data-modal-id",dockContainer:"data-dock-container",resizeDir:"data-resize-dir",modalBridge:"data-modal-bridge"},xi={modalId:Ci.modalId,resizeDirection:"data-direction",dockItemId:"data-dock-item-id"},Ii=["n","s","e","w","ne","nw","se","sw"],bi={n:"Resize north",s:"Resize south",e:"Resize east",w:"Resize west",ne:"Resize northeast",nw:"Resize northwest",se:"Resize southeast",sw:"Resize southwest"},Ai={minimize:500,restore:400,open:400,close:250,overlay:200,centerAfterResize:200,glowStabilize:1e3},ki={minWidth:280,minHeight:200,maxWidth:"600px",zIndexBase:1e3},Si=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function Ri(e,t){return function(e,t,i={}){const{timeout:n=5e3}=i;return new Promise((i,o)=>{const s=performance.now(),a=()=>{const r=e(),d=performance.now()-s;r&&t(r)?i(r):d>=n?o(new Error(`DOM not ready after ${n}ms`)):requestAnimationFrame(a)};a()})}(e,e=>e.offsetWidth>0&&e.offsetHeight>0,t)}function Di(e,t,i=2e3){return new Promise((n,o)=>{let s=!1;const a=i=>{t&&i.animationName!==t||s||(s=!0,e.removeEventListener("animationend",a),n(i))};e.addEventListener("animationend",a),setTimeout(()=>{s||(s=!0,e.removeEventListener("animationend",a),o(new Error(`Animation '${t||"any"}' did not complete within ${i}ms`)))},i)})}const Ei={MINIMIZE:"modal-genie-minimize",RESTORE:"modal-genie-restore",OPEN:"modal-genie-restore",CLOSE:"modal-close",CLOSE_CENTERED:"modal-close-centered",CHILD_APPEAR:"modal-child-appear",CHILD_DISAPPEAR:"modal-child-disappear"};function Bi(e,t){const i=i=>{i.target===e&&t(i.animationName)};return e.addEventListener("animationend",i),()=>e.removeEventListener("animationend",i)}function Hi(){const e=Oe();return Array.from(e.values()).filter(e=>e.isMinimized).sort((e,t)=>e.dockPosition-t.dockPosition)}function Ti(e,t,i){const n=ce(e.x,e.y,t,i);return{x:Math.round(n.x),y:Math.round(n.y)}}function Oi(e,t,i,n,o,s=8){const a=window.innerWidth-n-s,r=window.innerHeight-o-s,d=Math.min(Math.max(e-i.x,s),Math.max(s,a)),l=Math.min(Math.max(t-i.y,s),Math.max(s,r));return{x:Math.round(d),y:Math.round(l)}}function Fi(e,t){const i=["modal-dock-container"];return"left"===e?i.push("modal-dock-left"):"right"===e?i.push("modal-dock-right"):"bottom"===e?i.push("modal-dock-bottom"):"free"===e&&i.push("modal-dock-free"),t&&i.push("modal-dock-empty"),i.join(" ")}function Li(e,t){const i=["modal-dock"];return"free"===e&&i.push("horizontal"===t?"modal-dock-free-horizontal":"modal-dock-free-vertical"),i.join(" ")}function Wi(){const e=Oe();return Array.from(e.values()).some(e=>e.isOpen&&!e.isMinimized&&!e.isHiddenWithParent)}function _i(){return ai(mi().features.backdrop)}function Gi(){const e=_i();return e.visible||e.blockClicks}function $i(e={}){const{initialPosition:t={x:0,y:0},constrain:i=!0}=e,n={...t};let o=!1,s=!1,a=0,r=0,d=0,l=0;const h=si();function c(){return{isDragging:o,position:{...n},hasBeenDragged:s}}function g(){h.emit("change",c())}return{getState:c,getPosition:()=>({...n}),isDragging:()=>o,hasBeenDragged:()=>s,setPosition:function(e){n.x=e.x,n.y=e.y,g()},setHasBeenDragged:function(e){s=e,g()},reset:function(){n.x=t.x,n.y=t.y,s=!1,o=!1,g()},constrainToViewport:function(e){if(!s)return;const t=ce(n.x,n.y,e.width,e.height);n.x=t.x,n.y=t.y,g()},onPointerDown:function(e,t){if(0===e.button){if(!s){const e=t.getBoundingClientRect();n.x=e.left,n.y=e.top}o=!0,a=e.clientX,r=e.clientY,d=n.x,l=n.y,t.setPointerCapture(e.pointerId),h.emit("dragStart",{...n}),g()}},onPointerMove:function(e,t){if(!o)return;const c=e.clientX-a,u=e.clientY-r;let m=d+c,p=l+u;if(i){const e=ce(m,p,t.width,t.height);m=e.x,p=e.y}n.x=m,n.y=p,s=!0,h.emit("dragMove",{...n}),g()},onPointerUp:function(e,t){o&&(o=!1,t.releasePointerCapture(e.pointerId),h.emit("dragEnd",{...n}),g())},subscribe:function(e){return h.on("change",e)},destroy:function(){h.off()}}}function Vi(e){const{minWidth:t=ki.minWidth,minHeight:i=ki.minHeight,getPosition:n,setPosition:o,getHasBeenDragged:s,setHasBeenDragged:a,getElement:r,getSymmetricResize:d,onResizeEnd:l}=e;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=si();let y=null,z=null;function v(){return{isResizing:h,direction:c,size:{...g},hasBeenResized:u}}function M(){w.emit("change",v())}function P(e){if(e.pointerId!==f)return;const n=e.clientX-p.x,s=e.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 e=c.includes("e")?n:-n;h=Math.max(t,p.width+2*e),m=p.centerX-h/2}if(c.includes("s")||c.includes("n")){const e=c.includes("s")?s:-s;u=Math.max(i,p.height+2*e),y=p.centerY-u/2}}else{if(c.includes("e")){const e=a-m;h=Math.max(t,Math.min(p.width+n,e))}if(c.includes("w")){const e=p.width-t,i=Math.min(n,e);h=p.width-i,m=p.posX+i}if(c.includes("s")){const e=r-y;u=Math.max(i,Math.min(p.height+s,e))}if(c.includes("n")){const e=p.height-i,t=Math.min(s,e);u=p.height-t,y=p.posY+t}}const z=ge(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}}),M()}function C(e){if(e.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 t=n();w.emit("resizeEnd",{size:{...g},position:t}),l&&l(t,{...g}),M(),setTimeout(()=>{m=!1},0)}return{getState:v,getSize:()=>({...g}),isResizing:()=>h,hasBeenResized:()=>u,justFinishedResizing:()=>m,setSize:function(e){g={...e},u=!0,M()},reset:function(){u=!1,g={width:0,height:0},h=!1,c="",M()},constrainToViewport:function(){const e=n(),t=r();if(!t)return;const i=ge(e.x,e.y,g.width||t.offsetWidth,g.height||t.offsetHeight);g={width:i.width,height:i.height},o({x:i.x,y:i.y}),M()},startResize:function(e,t){e.preventDefault(),e.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=t,f=e.pointerId,p={x:e.clientX,y:e.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=C,window.addEventListener("pointermove",y),window.addEventListener("pointerup",z),window.addEventListener("pointercancel",z),w.emit("resizeStart",{direction:t}),M()},subscribe:function(e){return w.on("change",e)},destroy:function(){y&&window.removeEventListener("pointermove",y),z&&(window.removeEventListener("pointerup",z),window.removeEventListener("pointercancel",z)),w.off()}}}function Ni(e){return Array.from(e.querySelectorAll(Si)).filter(e=>null!==e.offsetParent||"A"===e.tagName)}function Yi(e,t){if("Tab"!==e.key)return;const i=Ni(t);if(0===i.length)return void e.preventDefault();const n=i[0],o=i[i.length-1],s=document.activeElement;e.shiftKey?s===n&&(o.focus(),e.preventDefault()):s===o&&(n.focus(),e.preventDefault())}function Xi(e){const t=Ni(e);return t.length>0&&(t[0].focus(),!0)}function qi(e){const t=Ni(e);return t.length>0&&(t[t.length-1].focus(),!0)}function Ui(e){return e.contains(document.activeElement)}function ji(e){let t=null;return{activate(){t=document.activeElement,Xi(e)},deactivate(){t&&"function"==typeof t.focus&&t.focus(),t=null},handleKeyDown(t){Yi(t,e)},containsFocus:()=>Ui(e)}}function Ki(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Zi(e,t){return{x:e.x+t.x,y:e.y+t.y}}function Ji(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Qi(e,t,i){return{x:e.x+(t.width-i.width)/2,y:e.y+(t.height-i.height)/2}}function en(e){const t=e.getBoundingClientRect();return{position:{x:t.left,y:t.top},size:{width:t.width,height:t.height}}}function tn(e){return Ce(e)}function nn(e){return Ce(e)}function on(e,t,i){return e&&!t&&!i}function sn(e,t){const i=[];let n=t(e);for(;n;)i.push(n),n=t(n);return i}function an(e,t){const i=[];let n=t(e);for(;n;)i.push(n),n=t(n);return i}function rn(e,t){let i=e,n=t(i);for(;n;)i=n,n=t(i);return i}function dn(e,t,i){const n=e.x+t.width/2,o=e.y+t.height/2;return{x:i.x-n,y:i.y-o,originX:i.x-e.x,originY:i.y-e.y}}function ln(e,t,i){const n=e.x+t.width/2,o=e.y+t.height/2;return{x:i.x-n,y:i.y-o,originX:i.x-e.x,originY:i.y-e.y}}function hn(e,t,i){const n=e.x+t.width/2,o=e.y+t.height/2;return{x:i.x-n,y:i.y-o,originX:i.x-e.x,originY:i.y-e.y}}function cn(e){return{"--modal-transform-x":`${e.x}px`,"--modal-transform-y":`${e.y}px`,"--modal-origin-x":`${e.originX}px`,"--modal-origin-y":`${e.originY}px`}}function gn(){return{x:typeof window<"u"?window.innerWidth/2:0,y:typeof window<"u"?window.innerHeight-40:0}}function un(e,t){const i=document.querySelector(`.modal-dock-item[data-modal-id="${e}"]`);if(i){const e=i.getBoundingClientRect();return{x:e.left+e.width/2,y:e.top+e.height/2}}const n=document.querySelector('[data-dock-container="true"]');if(n){const e=n.getBoundingClientRect();return{x:e.left+e.width/2,y:e.top+e.height/2}}return t??gn()}function mn(e){const{getId:t,getElement:i,getPosition:n,setPosition:o,getHasBeenDragged:s,setHasBeenDragged:a,getHasBeenResized:r,getSize:d,areAnimationsEnabled:l=()=>!0,onMinimizeComplete:h,onOpenStart:c}=e;let g="none",u=!1,m=null,p=null,f=null,w=null,y=null,z=null,v=null;const M=si();function P(){return{type:g,isAnimating:u,transform:m?{...m}:null}}function C(){M.emit("change",P())}function x(){z&&(clearTimeout(z),z=null)}function I(){const e=i();!e||v||(v=Bi(e,b))}function b(e){switch(x(),e){case Ei.MINIMIZE:"minimize"===g&&A();break;case Ei.RESTORE:"restore"===g?k():"open"===g&&S();break;case Ei.CLOSE:case Ei.CLOSE_CENTERED:case Ei.CHILD_DISAPPEAR:"close"===g&&R();break;case Ei.CHILD_APPEAR:"open"===g&&S()}}function A(){"minimize"===g&&(x(),w?(w(),w=null):y&&(null==h||h(y.position,!0,y.size)),M.emit("animationEnd",{type:"minimize"}),y=null)}function k(){if("restore"!==g)return;x(),g="none",u=!1,m=null;const e=i();e&&(e.setAttribute("data-state","open"),e.setAttribute("data-animation-phase","idle")),M.emit("animationEnd",{type:"restore"}),C()}function S(){if("open"!==g)return;x(),g="none",u=!1,m=null;const e=i();e&&(e.setAttribute("data-state","open"),e.setAttribute("data-animation-phase","idle")),M.emit("animationEnd",{type:"open"}),C()}function R(){if("close"!==g)return;x(),g="none",u=!1;const e=i();e&&(e.setAttribute("data-state","closed"),e.setAttribute("data-animation-phase","idle")),M.emit("animationEnd",{type:"close"}),f&&(f(),f=null),C()}return{getState:P,isAnimating:()=>u,getAnimationType:()=>g,getTransform:()=>m?{...m}:null,getPendingOpenSource:()=>p?{...p}:null,setPendingOpenSource:e=>{p=e?{...e}:null},startMinimize:function(e,c){const p=i();if(u||!p)return!1;if(I(),x(),!l()){const e=p.getBoundingClientRect(),t=s()?n():{x:e.left,y:e.top},i=r()?d():{width:e.width,height:e.height};return s()||(o(t),a(!0)),c?c():null==h||h(t,!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 b=e??un(t());return m=dn(v,P,b),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"),M.emit("animationStart",{type:"minimize"}),C()})}),z=setTimeout(()=>{"minimize"===g&&A()},Ie.minimize+be),!0},startRestore:function(e,n){const s=i();if(I(),x(),!l()){const t=e||{x:window.innerWidth/2,y:window.innerHeight/2};return o(t),void a(!0)}const r=un(t()),d=e||{x:window.innerWidth/2,y:window.innerHeight/2},h=n||{width:480,height:400};o(d),a(!0),m=ln(d,h,r),g="restore",u=!0,s&&(s.setAttribute("data-state","restoring"),s.setAttribute("data-animation-phase","animate")),M.emit("animationStart",{type:"restore"}),C(),z=setTimeout(()=>{"restore"===g&&k()},Ie.restore+be)},startOpen:function(){const e=i();if(!p||!e||u)return!1;if(I(),x(),!l())return p=null,!1;const t=p,r=e.getBoundingClientRect(),d=s()?n():{x:r.left,y:r.top},h=r.width,f=r.height;return s()||(o(d),a(!0)),m=hn(d,{width:h,height:f},t),g="open",u=!0,p=null,e.setAttribute("data-state","opening"),e.setAttribute("data-animation-phase","animate"),M.emit("animationStart",{type:"open"}),null==c||c(),C(),z=setTimeout(()=>{"open"===g&&S()},Ie.open+be),!0},startClose:function(e){const t=i();return!u&&(I(),x(),l()?(f=e,g="close",u=!0,t&&(t.setAttribute("data-state","closing"),t.setAttribute("data-animation-phase","animate")),M.emit("animationStart",{type:"close"}),C(),z=setTimeout(()=>{"close"===g&&R()},Ie.close+be),!0):(e(),!0))},forceClearMinimize:function(){x(),"minimize"===g&&(g="none",u=!1,m=null,w=null,y=null,C())},destroy:function(){x(),null==v||v(),v=null,M.off()},subscribe:e=>M.on("change",e)}}function pn(e){const t={"z-index":e.zIndex};return e.animationTransform?(t.left=`${e.position.x}px`,t.top=`${e.position.y}px`,t["--genie-origin-x"]=`${e.animationTransform.originX}px`,t["--genie-origin-y"]=`${e.animationTransform.originY}px`,t["--genie-translate-x"]=`${e.animationTransform.x}px`,t["--genie-translate-y"]=`${e.animationTransform.y}px`):e.hasBeenDragged&&(t.left=`${e.position.x}px`,t.top=`${e.position.y}px`,e.isAnimatingPosition||(t.transform="none")),e.hasBeenResized?(t.width=`${e.size.width}px`,t.height=`${e.size.height}px`,t["max-width"]="none",t["max-height"]="none"):(e.preferredHeight&&(t["min-height"]=e.preferredHeight),e.maxWidth&&(t["max-width"]=e.maxWidth)),e.glowEnabled&&e.glow&&(t["--modal-glow-color"]=e.glow.color,t["--modal-glow-intensity"]=String(e.glow.intensity??"medium")),t}function fn(e){const t=["modal-dialog"];return e.isDragging&&t.push("modal-dragging"),e.isResizing&&t.push("modal-resizing"),e.hasBeenDragged&&t.push("modal-positioned"),e.isMinimizing&&t.push("modal-minimizing"),e.isRestoring&&t.push("modal-restoring"),e.isOpening&&t.push("modal-opening"),e.isClosing&&t.push("modal-closing"),e.showCentered&&t.push("modal-centered"),e.isTransparent||t.push("modal-solid"),e.isTransparent&&t.push("modal-transparent"),e.glowEnabled&&t.push("modal-glow"),e.hasChild&&t.push("modal-has-child"),e.isChildModal&&t.push("modal-is-child"),e.wasRestored&&t.push("modal-was-restored"),e.isVisibleByAnimation&&t.push("modal-visible-by-animation"),e.isAwaitingRestore&&t.push("modal-awaiting-restore"),e.isAwaitingChildOpen&&t.push("modal-awaiting-child-open"),e.isAnimatingToCenter&&t.push("modal-animating-to-center"),e.isAnimatingPosition&&t.push("modal-animating-position"),e.isAttentionAnimating&&t.push("modal-attention"),e.glowStabilizing&&e.glowEnabled&&t.push("modal-glow-stabilizing"),t}class wn{constructor(e={}){t(this,"element",null),t(this,"resizeHandler",null),t(this,"options"),this.options=e}mount(e){var t,i;this.element=e,this.options.onWindowResize&&(this.resizeHandler=this.options.onWindowResize,window.addEventListener("resize",this.resizeHandler)),null==(i=(t=this.options).onMount)||i.call(t)}destroy(){var e,t;this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=null),this.element=null,null==(t=(e=this.options).onDestroy)||t.call(e)}getElement(){return this.element}isMounted(){return null!==this.element}}class yn{constructor(e){t(this,"id"),t(this,"dataId"),t(this,"configHelper"),t(this,"getDragBehavior"),t(this,"getElement"),this.id=e.id,this.dataId=e.dataId,this.configHelper=e.configHelper,this.getDragBehavior=e.getDragBehavior,this.getElement=e.getElement}constrainToViewport(e){const t=this.getDragBehavior();t.hasBeenDragged()&&t.constrainToViewport(e)}shouldApplySmartPositioning(){return!("smart"!==this.configHelper.getPositioning("strategy")||this.getDragBehavior().hasBeenDragged())}applySmartPositioning(){if("smart"!==this.configHelper.getPositioning("strategy"))return!1;const e=De(this.id),t=jt();if(null!=e&&e.parentId||t&&t.childId===this.id||null!=e&&e.hasBeenDragged||null!=e&&e.position)return!1;const i=this.getElement()||Ce(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=We().filter(e=>e.id!==this.id),r=fe(this.configHelper.getPositioning("avoidElements")),d=Me(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[e,t]of d.positions)e!==this.id&&h.set(e,t);h.size>0&&qe(h);const c=this.getDragBehavior();return c.setPosition(l),c.setHasBeenDragged(!0),$e(this.id,l,{size:{width:n,height:o}}),!0}scheduleSmartPositioning(){Ri(()=>this.getElement()||Ce(this.id)).then(()=>{this.applySmartPositioning()}).catch(()=>{this.applySmartPositioning()})}centerChildOnParent(e){var t,i;const n=De(e);if(!n)return!1;const o=this.getElement()||Ce(this.id),s=Ce(e),a=null==s?void 0:s.getBoundingClientRect(),r=n.position??(a?{x:a.left,y:a.top}:null);if(!r||!o)return!1;const d=(null==(t=n.size)?void 0:t.width)??(null==s?void 0:s.offsetWidth)??(null==a?void 0:a.width)??480,l=(null==(i=n.size)?void 0:i.height)??(null==s?void 0:s.offsetHeight)??(null==a?void 0:a.height)??400,h=o.offsetWidth,c=o.offsetHeight;if(d<=0||l<=0||h<=0||c<=0)return!1;const g={x:r.x+(d-h)/2,y:r.y+(l-c)/2},u=this.getDragBehavior();u.setPosition(g),u.setHasBeenDragged(!0),$e(this.id,g,{size:{width:h,height:c}}),(!n.position||!n.size)&&a&&$e(e,{x:a.left,y:a.top},{size:{width:d,height:l}});const m={x:g.x-r.x,y:g.y-r.y};return Ut(e,this.id,m),!0}scheduleCenterChildOnParent(e){Ri(()=>this.getElement()).then(()=>{this.centerChildOnParent(e)}).catch(()=>{this.centerChildOnParent(e)})}}class zn{constructor(e){t(this,"options"),this.options=e}startDrag(e){const t=this.options.getElement();!this.options.configHelper.isFeatureEnabled("drag")||!t||this.options.getDragBehavior().onPointerDown(e,t)}startResize(e,t){const i=this.options.getState();!this.options.configHelper.isFeatureEnabled("resize")||i.hasChild||this.options.getResizeBehavior().startResize(e,t)}handlePointerMove(e){const t=this.options.getElement();if(!t)return;const i=this.options.getDragBehavior(),n=i.isDragging(),o=this.options.getResizeBehavior(),s=o.hasBeenResized()?o.getSize():{width:t.offsetWidth,height:t.offsetHeight};i.onPointerMove(e,s),n&&i.isDragging()&&this.options.onDragMove()}handlePointerUp(e){const t=this.options.getElement();if(!t)return;const i=this.options.getDragBehavior(),n=i.isDragging();i.onPointerUp(e,t),n&&!this.options.getResizeBehavior().justFinishedResizing()&&this.options.onDragEnd()}handleKeyDown(e){var t,i;this.options.closeOnEscape&&"Escape"===e.key&&this.options.isTopModal()&&(e.stopPropagation(),null==(i=(t=this.options).onClose)||i.call(t))}handleTabKey(e){const t=this.options.getElement();t&&Yi(e,t)}focusFirst(){const e=this.options.getElement();e&&Xi(e)}}class vn{constructor(e){t(this,"id"),t(this,"options"),t(this,"_isHandlingMinimize",!1),t(this,"_isAttentionAnimating",!1),t(this,"_wasRestored"),t(this,"_glowStabilizing",!1),t(this,"_restoreHold",!1),t(this,"_isAnimatingToCenter",!1),t(this,"_cancelParentAnimationCleanup",null),t(this,"_parentFlipInFlight",!1),t(this,"_deferredParentTarget",null),t(this,"_parentFlipStartTime",0),this.id=e.id,this.options=e,this._wasRestored=!1}handlePendingStates(){if(!De(this.id)||this.handlePendingForceClose()||(this.handlePendingMinimize(),this.handlePendingMinimizeWithParent(),this.handlePendingRestore(),this.handlePendingChildRestore(),this.handlePendingClose()))return;const e=this.handlePendingParentLink(),t=this.handlePendingOpen(e);this.handlePendingAttention(),this.handlePendingParentAnimation(),this.handleChildCentering(e,t)}handlePendingForceClose(){var e,t;return!!Dt(this.id)&&(Et(this.id),Mt(this.id),null==(t=(e=this.options.options).onClose)||t.call(e),!0)}handlePendingMinimize(){if(!Ct(this.id)||this._isHandlingMinimize)return;this._isHandlingMinimize=!0,Xt();const e=this.options.getElement();if(e){const t=this.options.getDragBehavior(),i=this.options.getResizeBehavior(),n=e.getBoundingClientRect(),o=t.hasBeenDragged()?t.getPosition():{x:n.left,y:n.top},s=i.hasBeenResized()?i.getSize():{width:n.width,height:n.height};Ye(this.id,{position:o,size:s,hasBeenDragged:!0})}this.options.getAnimationController().startMinimize(void 0,()=>{xt(this.id),this._isHandlingMinimize=!1})||(this._isHandlingMinimize=!1)}handlePendingMinimizeWithParent(){if(!It(this.id)||this._isHandlingMinimize)return;this._isHandlingMinimize=!0;const e=this.options.getElement();if(e){const t=this.options.getDragBehavior(),i=this.options.getResizeBehavior(),n=e.getBoundingClientRect(),o=t.hasBeenDragged()?t.getPosition():{x:n.left,y:n.top},s=i.hasBeenResized()?i.getSize():{width:n.width,height:n.height};Ye(this.id,{position:o,size:s,hasBeenDragged:!0})}this.options.getAnimationController().startMinimize(void 0,()=>{bt(this.id),rt(this.id),this._isHandlingMinimize=!1})}handlePendingRestore(){if(!Bt(this.id))return;const e=De(this.id),t=this.options.getAnimationController();Ht(this.id),t.startRestore((null==e?void 0:e.position)??void 0,(null==e?void 0:e.size)??void 0),requestAnimationFrame(()=>{this.options.focusFirst()})}handlePendingChildRestore(){if(!Tt(this.id))return;const e=De(this.id),t=this.options.getAnimationController();Ot(this.id),t.startRestore((null==e?void 0:e.position)??void 0,(null==e?void 0:e.size)??void 0),at(this.id),this._wasRestored=!0}handlePendingClose(){var e,t;return!!St(this.id)&&(Rt(this.id),this.options.getAnimationController().startClose(()=>{var e,t;ut(this.id),Mt(this.id),null==(t=(e=this.options.options).onClose)||t.call(e)})||(ut(this.id),Mt(this.id),null==(t=(e=this.options.options).onClose)||t.call(e)),!0)}handlePendingParentLink(){const e=jt();return e&&e.childId===this.id&&(Ye(this.id,{parentId:e.parentId}),this._wasRestored=!0),qt(this.id)}handlePendingOpen(e){var t;if(!At(this.id))return!1;kt(this.id);const i=this.options.getDragBehavior(),n=this.options.getResizeBehavior();Ye(this.id,{position:null,hasBeenDragged:!1,size:null}),i.setPosition({x:0,y:0}),i.setHasBeenDragged(!1),n.reset();const o=Yt(this.id)||this.options.options.openSourcePosition||null,s=!!e||!(null==(t=De(this.id))||!t.parentId);let a=!1;return o?(a=!0,this.options.getAnimationController().setPendingOpenSource(o),s&&e?this.openChildModalWithAnimation(e.parentId):this.openStandaloneModalWithAnimation()):s||this.options.getPositioning().scheduleSmartPositioning(),requestAnimationFrame(()=>{this.options.focusFirst()}),a}openChildModalWithAnimation(e){const t=this.options.getPositioning(),i=this.options.getAnimationController();Ri(()=>this.options.getElement()).then(()=>{t.centerChildOnParent(e)&&(i.startOpen(),this._wasRestored=!0)}).catch(()=>{t.centerChildOnParent(e)&&(i.startOpen(),this._wasRestored=!0)})}openStandaloneModalWithAnimation(){const e=this.options.getPositioning(),t=this.options.getAnimationController();Ri(()=>this.options.getElement()).then(()=>{e.applySmartPositioning(),t.startOpen()}).catch(()=>{e.applySmartPositioning(),t.startOpen()})}handlePendingAttention(){Ft(this.id)&&(Lt(this.id),this.id,this._isAttentionAnimating=!0,setTimeout(()=>{this._isAttentionAnimating=!1,this.id,this.options.onStateChange()},600))}handlePendingParentAnimation(){if(!Gt(this.id))return;const e=$t(this.id);if(e){if(this._parentFlipInFlight&&Date.now()-this._parentFlipStartTime<Ie.parentRetargetInterval)return void(this._deferredParentTarget=e);this._deferredParentTarget=null,this.startParentFlip(e)}}startParentFlip(e){var t,i;const n=this.options.getDragBehavior(),o=this.options.getElement(),s=o?{x:o.getBoundingClientRect().left,y:o.getBoundingClientRect().top}:(null==(t=De(this.id))?void 0:t.position)??null;Ye(this.id,{position:e,hasBeenDragged:!0,isAnimatingPosition:!0}),n.setPosition(e),n.setHasBeenDragged(!0),null==(i=this._cancelParentAnimationCleanup)||i.call(this),this._parentFlipInFlight=!0,this._parentFlipStartTime=Date.now();const a=this.id,r=()=>{this._parentFlipInFlight=!1,this._cancelParentAnimationCleanup=null,Ve(a);const e=this._deferredParentTarget;e?(this._deferredParentTarget=null,this.startParentFlip(e)):Kt(a)};o&&s?this._cancelParentAnimationCleanup=Re(o,s,e,{duration:Ie.parentMove,onComplete:r}):setTimeout(r,Ie.parentMove+be)}handleChildCentering(e,t){e&&this.options.getElement()&&!t&&this.options.getPositioning().scheduleCenterChildOnParent(e.parentId)}get wasRestored(){return this._wasRestored}set wasRestored(e){this._wasRestored=e}get isAttentionAnimating(){return this._isAttentionAnimating}get glowStabilizing(){return this._glowStabilizing}set glowStabilizing(e){this._glowStabilizing=e}get restoreHold(){return this._restoreHold}set restoreHold(e){this._restoreHold=e}get isAnimatingToCenter(){return this._isAnimatingToCenter}set isAnimatingToCenter(e){this._isAnimatingToCenter=e}get isHandlingMinimize(){return this._isHandlingMinimize}}class Mn{constructor(e){var i,n,o,s;t(this,"id"),t(this,"dataId"),t(this,"options"),t(this,"drag"),t(this,"resize"),t(this,"animation"),t(this,"positioning"),t(this,"lifecycle"),t(this,"interactions"),t(this,"stateManager"),t(this,"overlayClosing",!1),t(this,"emitter",si()),t(this,"unsubscribeState",null),t(this,"cachedState",null),this.id=e.id,this.dataId=e.id,this.options=e,this.drag=$i({initialPosition:{x:0,y:0},constrain:!0}),this.resize=Vi({minWidth:(null==(n=null==(i=e.config)?void 0:i.appearance)?void 0:n.minWidth)??mi().appearance.minWidth,minHeight:(null==(s=null==(o=e.config)?void 0:o.appearance)?void 0:s.minHeight)??mi().appearance.minHeight,getPosition:()=>this.drag.getPosition(),setPosition:e=>this.drag.setPosition(e),getHasBeenDragged:()=>this.drag.hasBeenDragged(),setHasBeenDragged:e=>this.drag.setHasBeenDragged(e),getElement:()=>this.element,onResizeEnd:(e,t)=>this.handleResizeEnd(e,t)}),this.animation=mn({getId:()=>this.id,getElement:()=>this.element,getPosition:()=>this.drag.getPosition(),setPosition:e=>this.drag.setPosition(e),getHasBeenDragged:()=>this.drag.hasBeenDragged(),setHasBeenDragged:e=>this.drag.setHasBeenDragged(e),getHasBeenResized:()=>this.resize.hasBeenResized(),getSize:()=>this.resize.getSize(),areAnimationsEnabled:()=>this.options.configHelper.isFeatureEnabled("animations"),onMinimizeComplete:(e,t,i)=>{Ye(this.id,{position:e,size:i,hasBeenDragged:t}),it(this.id)},onOpenStart:()=>{const e=De(this.id);null!=e&&e.parentId&&(this.stateManager.wasRestored=!0)}}),this.positioning=new yn({id:this.id,dataId:this.dataId,configHelper:e.configHelper,getDragBehavior:()=>this.drag,getElement:()=>this.element}),this.interactions=new zn({id:this.id,configHelper:e.configHelper,getDragBehavior:()=>this.drag,getResizeBehavior:()=>this.resize,getElement:()=>this.element,getState:()=>{var e;return{hasChild:!(null==(e=De(this.id))||!e.childId)}},onDragMove:()=>{if("realtime"===mi().parentChild.movementMode){const e=this.drag.getPosition();$e(this.id,e,{drag:!0,realtime:!0})}},onDragEnd:()=>{const e=this.drag.getPosition();$e(this.id,e,{drag:!0}),"animated"===mi().parentChild.movementMode&&Kt(this.id)},onClose:()=>this.close(),closeOnEscape:e.closeOnEscape,isTopModal:()=>de(this.id)}),this.stateManager=new vn({id:this.id,options:{glow:e.glow,openSourcePosition:e.openSourcePosition,onClose:e.onClose},getDragBehavior:()=>this.drag,getResizeBehavior:()=>this.resize,getAnimationController:()=>this.animation,getElement:()=>this.element,getPositioning:()=>this.positioning,onStateChange:()=>this.notifyStateChange(),focusFirst:()=>this.interactions.focusFirst()}),_t(e.id)&&(this.stateManager.wasRestored=!0),this.lifecycle=new wn({onMount:()=>{this.handleStateChange(),this.handlePendingStates(),this.notifyStateChange()},onDestroy:()=>{var e;null==(e=this.unsubscribeState)||e.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=Z(()=>{this.handleStateChange(),this.handlePendingStates(),this.notifyStateChange()}),e.skipRegistration||this.register(e.autoOpen??!1),this.handleStateChange(),this.handlePendingStates()}mount(e){this.lifecycle.mount(e)}destroy(){this.lifecycle.destroy()}get element(){return this.lifecycle.getElement()}handleWindowResize(){if(!this.element||!this.drag.hasBeenDragged())return;const e=this.resize.hasBeenResized()?this.resize.getSize():{width:this.element.offsetWidth,height:this.element.offsetHeight};this.positioning.constrainToViewport(e),this.resize.hasBeenResized()&&this.resize.constrainToViewport(),this.notifyStateChange()}register(e){oe({id:this.id,title:this.options.title,icon:this.options.icon??"",isOpen:e,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}),e&&re(this.id)}getState(){if(this.cachedState)return this.cachedState;const e=De(this.id),t=this.drag.getState(),i=this.resize.getState(),n=this.animation.getState(),o=!!e&&(e.isOpen||St(this.id))&&(!e.isMinimized||Ct(this.id))&&(!e.isHiddenWithParent||It(this.id)||Tt(this.id)),s=!(null==e||!e.childId),a=!(null==e||!e.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==e?void 0:e.isAnimatingPosition)??!1,u=g&&null!=e&&e.position?e.position:t.position,m=!!g||t.hasBeenDragged,p=(Tt(this.id)||Bt(this.id))&&!d,f=(a||_t(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!=e&&e.isMinimized?z="minimized":o&&(z="open");const v=this.options.configHelper.isFeatureEnabled("drag"),M=this.options.configHelper.isFeatureEnabled("resize"),P=this.options.configHelper.isFeatureEnabled("minimize"),C=!!this.options.glow,x=pn({position:u,hasBeenDragged:m,hasBeenResized:i.hasBeenResized,size:i.size,animationTransform:n.transform,zIndex:(null==e?void 0:e.zIndex)??1e3,glowEnabled:C,glow:this.options.glow??null,maxWidth:this.options.maxWidth,preferredHeight:this.options.preferredHeight,isAnimatingPosition:g}),I=fn({isDragging:t.isDragging,isResizing:i.isResizing,hasBeenDragged:m,isMinimizing:r,isRestoring:d,isOpening:l,isClosing:h,showCentered:y,isTransparent:(null==e?void 0:e.isTransparent)??!1,glowEnabled:C,hasChild:s,isChildModal:a,wasRestored:this.stateManager.wasRestored,isVisibleByAnimation:w,isAwaitingRestore:p,isAwaitingChildOpen:f,isAnimatingToCenter:this.stateManager.isAnimatingToCenter,isAnimatingPosition:(null==e?void 0:e.isAnimatingPosition)??!1,isAttentionAnimating:this.stateManager.isAttentionAnimating,glowStabilizing:this.stateManager.glowStabilizing});return this.cachedState={position:t.position,size:i.size,zIndex:(null==e?void 0:e.zIndex)??1e3,isDragging:t.isDragging,isResizing:i.isResizing,hasBeenDragged:t.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==e?void 0:e.isTransparent)??!1,isAttentionAnimating:this.stateManager.isAttentionAnimating,glowStabilizing:this.stateManager.glowStabilizing,isAnimatingPosition:(null==e?void 0:e.isAnimatingPosition)??!1,isAnimatingToCenter:this.stateManager.isAnimatingToCenter,wasRestored:this.stateManager.wasRestored,overlayClosing:this.overlayClosing,glowEnabled:C,draggable:v,resizable:M,minimizable:P,dataState:z,dataAnimationPhase:n.isAnimating?"animate":"idle",style:x,cssClasses:I},this.cachedState}subscribe(e){return this.emitter.on("stateChange",e)}notifyStateChange(){this.cachedState=null,this.emitter.emit("stateChange",this.getState())}startDrag(e){this.interactions.startDrag(e)}startResize(e,t){this.interactions.startResize(e,t)}handlePointerMove(e){this.interactions.handlePointerMove(e)}handlePointerUp(e){this.interactions.handlePointerUp(e)}handleKeyDown(e){this.interactions.handleKeyDown(e)}handleTabKey(e){this.interactions.handleTabKey(e)}minimize(){this.options.configHelper.isFeatureEnabled("minimize")&&it(this.id)}close(){var e,t;Dt(this.id)&&Et(this.id),zt(this.id),null==(t=(e=this.options).onClose)||t.call(e)}toggleTransparency(){lt(this.id)}bringToFront(){re(this.id)}setOpenSourcePosition(e){this.animation.setPendingOpenSource(e)}updateGlow(e){this.options.glow!==e&&(this.options.glow=e,Ye(this.id,{glow:e??null}),this.notifyStateChange())}focusFirst(){this.interactions.focusFirst()}handleResizeEnd(e,t){const i=De(this.id);if(null!=i&&i.parentId){const n=De(i.parentId),o=Ce(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-t.width)/2,y:i.y+(s.height-t.height)/2},r=e;this.stateManager.isAnimatingToCenter=!0,this.drag.setPosition(a);const d={x:a.x-i.x,y:a.y-i.y};Ye(this.id,{position:a,size:t,hasBeenDragged:!0,offsetFromParent:d});const l=this.lifecycle.getElement();return void(l?Re(l,r,a,{duration:Ie.centerAfterResize,onComplete:()=>{this.stateManager.isAnimatingToCenter=!1}}):this.stateManager.isAnimatingToCenter=!1)}}Ye(this.id,{position:e,size:t,hasBeenDragged:!0})}handleStateChange(){const e=De(this.id);if(e){if((e.parentId||_t(this.id))&&(this.stateManager.wasRestored=!0),!this.drag.isDragging()&&!this.resize.isResizing()&&e.position){const t=this.drag.getPosition(),i=e.position;(Math.abs(t.x-i.x)>.5||Math.abs(t.y-i.y)>.5)&&(this.drag.setPosition(i),e.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 Pn(e){return new Mn(e)}export{Ai as ANIMATION_DURATIONS,Ei as ANIMATION_NAMES,Mi as CSS,Pi as CSS_CLASSES,xi as DATA_ATTRIBUTES,Ci as DATA_ATTRS,ki as DEFAULTS,Ie as DURATIONS,Ae as EASINGS,Si as FOCUSABLE_SELECTORS,Mn as ModalController,zn as ModalInteractions,wn as ModalLifecycle,yn as ModalPositioning,vn as ModalStateManager,Ii as RESIZE_DIRECTIONS,bi as RESIZE_DIRECTION_LABELS,ie as _getInternalState,te as _resetInternalState,ii as acquireModalZIndex,Qe as animateModalsToPositions,qe as applyLayoutPositions,J as batchUpdates,re as bringToFront,Qi as calculateCenteredChildPosition,Jt as calculateChildCenterPosition,Zi as calculateChildPosition,Oi as calculateDockDragPosition,Me as calculateEqualSpaceLayout,pe as calculateMinDistance,dn as calculateMinimizeTransform,Ki as calculateOffsetFromParent,hn as calculateOpenTransform,ue as calculateOverlap,Ji as calculateParentPosition,ln as calculateRestoreTransform,Me as calculateSmartLayout,me as calculateTotalOverlap,Je as cleanupResizeListener,Wt as clearActiveAttention,et as clearPendingParentAnimation,Ve as clearPositionAnimation,vt as closeAllModals,zt as closeModal,we as computeAvailableArea,fn as computeCssClasses,pn as computeStyle,Ti as constrainDockPosition,ge as constrainSizeToViewport,ce as constrainToViewport,Yt as consumeOpenSourcePosition,Lt as consumePendingAttention,Ot as consumePendingChildRestore,Rt as consumePendingClose,Et as consumePendingForceClose,xt as consumePendingMinimize,Xt as consumePendingMinimizeTarget,bt as consumePendingMinimizeWithParent,kt as consumePendingOpen,$t as consumePendingParentAnimation,qt as consumePendingParentLink,Ht as consumePendingRestore,Ui as containsFocus,mn as createAnimationController,zi as createConfigHelper,vi as createConfigResolver,$i as createDragBehavior,si as createEventEmitter,ji as createFocusTrap,yt as createModal,Pn as createModalController,ne as createModalRegistration,Vi as createResizeBehavior,ri as defaultConfig,pt as endAttentionAnimation,rt as finalizeChildMinimize,Mt as finalizeModalClose,nn as findChildModalElement,tn as findParentModalElement,rn as findRootAncestor,Re as flipAnimate,Xi as focusFirstElement,qi as focusLastElement,an as getAncestorIds,_i as getBackdropConfig,mi as getConfig,ui as getConfigVersion,gn as getDefaultDockTarget,sn as getDescendantIds,Li as getDockClasses,Fi as getDockContainerClasses,Le as getDockItemElement,un as getDockItemPosition,Fe as getDockOrder,ke as getDuration,Se as getEasing,fe as getElementBounds,Ni as getFocusableElements,ni as getLayerZIndex,Hi as getMinimizedModals,en as getModalBounds,Ce as getModalDialogElement,We as getModalLayoutInfos,De as getModalState,Oe as getModalsStore,Pt as getModalsToClose,_e as getOpenModalBounds,Ge as getOpenModalBoundsWithIds,Nt as getOpenSourcePosition,Zt as getPendingParentAnimation,jt as getPendingParentLink,K as getStateVersion,je as handleWindowResize,Wi as hasOpenModals,Ft as hasPendingAttention,Tt as hasPendingChildRestore,St as hasPendingClose,Dt as hasPendingForceClose,Ct as hasPendingMinimize,It as hasPendingMinimizeWithParent,At as hasPendingOpen,Gt as hasPendingParentAnimation,_t as hasPendingParentLinkFor,Bt as hasPendingRestore,dt as hideChildWithParent,Ze as initializeResizeListener,ti as initializeStacking,Gi as isBackdropEnabled,yi as isFeatureEnabled,He as isModalAnimating,Ee as isModalOpen,Be as isModalRegistered,de as isTopModal,Ut as linkModals,wi as mergeConfig,it as minimizeModal,ai as normalizeBackdropConfig,Di as onAnimationEnd,ft as openChildModal,wt as openModal,oe as registerModal,le as reorderDock,fi as resetConfig,ut as resetModalTransparency,oi as resetStacking,ot as restoreAllMinimizedModals,st as restoreChildModal,nt as restoreModal,xe as screenCenter,pi as setConfig,O as setDockPositionGetterInternal,Te as setModalAnimating,L as setRegistryCallbacksInternal,L as setRegistryFunctions,H as setURLCallbacks,H as setURLStateCallbacks,Bi as setupAnimationEndListener,ct as shakeElement,on as shouldChildBeVisible,mt as startAttentionAnimation,Vt as storeOpenSourcePosition,Z as subscribe,ci as subscribeToConfig,Pe as toDataId,lt as toggleModalTransparency,cn as transformToCSSVars,Yi as trapFocus,ht as triggerAttention,Kt as triggerCascadingParentAnimations,Xe as triggerRearrangement,gt as triggerRejection,at as unhideChildModal,se as unregisterModal,Ye as updateModal,$e as updateModalPosition,Ne as updateModalSize,Ri as whenHasDimensions};
|
|
1
|
+
const e=Symbol.for("epic-modals-core");if(typeof globalThis<"u"){const t=globalThis;t[e],t[e]=!0}const t=new Map;let i=null;function n(e){i=e}const o=new Set;let d=!1,a=[],r=[],l=[],s=[],c=[],h=[],m=[],f=[];const u=new Map,g=new Map,p=new Set;let I=[];function w(e){I=e}function M(e){r=e}function y(e){c=e}function x(){!function(){if(!d){d=!0;try{o.forEach(e=>e())}finally{d=!1}}}()}function z(e,t){if(e.width<=0||e.height<=0)throw new Error(`[epic-modals] Invalid dimensions in ${t}: width=${e.width}, height=${e.height}`)}function k(e,i){return!!t.get(e)||(function(){var e,t;try{const i=import.meta;return!0===(null==(e=i.env)?void 0:e.DEV)||"development"===(null==(t=i.env)?void 0:t.MODE)}catch{return!1}}(),!1)}function b(e,i){const n=t.get(e);if(null==n||!n.childId)return;const o=t.get(n.childId);if(!o)return;const d=i+2;t.set(n.childId,{...o,zIndex:d}),b(n.childId,d)}function v(e){if(!t.get(e))return;const i=Math.max(...Array.from(t.values()).map(e=>e.zIndex),0),n=function(e){let i=e,n=t.get(i);for(;null!=n&&n.parentId;)i=n.parentId,n=t.get(i);return i}(e),o=t.get(n);if(!o)return;const d=i+2;t.set(n,{...o,zIndex:d}),b(n,d),x()}function C(e){const i=t.get(e);if(!i)return!1;const n=Math.max(...Array.from(t.values()).map(e=>e.zIndex),0);return i.zIndex===n&&!i.isMinimized&&!i.isHiddenWithParent}const P=8;function A(e,t,i,n){const o=e-t,d=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=d*n;return o>=r?{interGap:n,edgeGap:(o-r)/2}:{interGap:o/d,edgeGap:0}}function G(e,t,i,n,o=0){if(0===i.length)return{cols:e,rows:t,score:1/0,positions:new Map};const d=new Array(e).fill(0),a=new Array(t).fill(0);for(let t=0;t<i.length;t++){const n=t%e,o=Math.floor(t/e);d[n]=Math.max(d[n],i[t].width),a[o]=Math.max(a[o],i[t].height)}const r=d.reduce((e,t)=>e+t,0),l=a.reduce((e,t)=>e+t,0);if(r>n.width||l>n.height)return null;const{interGap:s,edgeGap:c}=A(n.width,r,e,o),{interGap:h,edgeGap:m}=A(n.height,l,t,o),f=new Map,u=[0];for(let t=0;t<e;t++)u.push(u[t]+d[t]);const g=[0];for(let e=0;e<t;e++)g.push(g[e]+a[e]);for(let t=0;t<i.length;t++){const o=t%e,r=Math.floor(t/e),l=i[t],p=n.x+c+o*s+u[o],I=n.y+m+r*h+g[r],w=p+(d[o]-l.width)/2,M=I+(a[r]-l.height)/2;f.set(l.id,{x:Math.round(w),y:Math.round(M)})}const p=e>1?s:c,I=t>1?h:m;return{cols:e,rows:t,score:(.6*Math.min(p,I)+.4*Math.sqrt(p*I))*(n.width>n.height==e>=t?1.02:1),positions:f}}function T(e,t){const i=new Map,n=Math.max(...e.map(e=>e.width)),o=Math.max(...e.map(e=>e.height)),d=n+40*(e.length-1),a=o+40*(e.length-1);let r=t.x+(t.width-d)/2,l=t.y+(t.height-a)/2;r=Math.max(t.x,r),l=Math.max(t.y,l);for(let t=0;t<e.length;t++)i.set(e[t].id,{x:Math.round(r+40*t),y:Math.round(l+40*t)});return i}function B(e){return typeof document>"u"?null:document.querySelector(`.modal-dialog[data-modal-id="${e}"]`)}function F(){return{x:window.innerWidth/2,y:window.innerHeight/2}}function H(e,t,i,n){var o;const d=t.x-i.x,a=t.y-i.y;if(0===d&&0===a)return null==(o=null==n?void 0:n.onComplete)||o.call(n),()=>{};const r=null==n?void 0:n.duration,l=(null==n?void 0:n.easing)??"ease-out";let s=!1;function c(){var e;s||(s=!0,clearTimeout(m),null==(e=null==n?void 0:n.onComplete)||e.call(n))}e.style.left=`${i.x}px`,e.style.top=`${i.y}px`;const h=e.animate([{transform:`translate(${d}px, ${a}px)`},{transform:"translate(0, 0)"}],{duration:r,easing:l,fill:"none"});h.onfinish=c;const m=setTimeout(c,r+100);return function(){s||(s=!0,clearTimeout(m),h.cancel())}}function S(e){return t.get(e)}function D(e){const i=t.get(e);return(null==i?void 0:i.isOpen)??!1}function E(e){return t.has(e)}function W(e,i,n){if(!k(e))return;(function(e){if(!Number.isFinite(e.x)||!Number.isFinite(e.y))throw new Error(`[epic-modals] Invalid position in updateModalPosition: x=${e.x}, y=${e.y}`)})(i),null!=n&&n.size&&z(n.size,"updateModalPosition");const o=t.get(e);if(!o)return;let d=i;if(null!=n&&n.constrain&&o.size&&(d=function(e,t,i,n,o={}){const{margin:d=P,allowPartialVisibility:a=!1}=o,r=typeof window<"u"?window.innerWidth:1920,l=typeof window<"u"?window.innerHeight:1080;let s,c,h,m;return a&&i>r-2*d?(s=40-i,c=r-40):(s=d,c=Math.max(d,r-i-d)),a&&n>l-2*d?(h=40-n,m=l-40):(h=d,m=Math.max(d,l-n-d)),{x:Math.max(s,Math.min(c,e)),y:Math.max(h,Math.min(m,t))}}(i.x,i.y,o.size.width,o.size.height)),t.set(e,{...o,position:d,size:(null==n?void 0:n.size)??o.size,hasBeenDragged:o.hasBeenDragged||(null==n?void 0:n.drag)||!1}),o.childId){let i=e,n=d;for(;;){const e=t.get(i);if(null==e||!e.childId)break;const o=t.get(e.childId);if(null==o||!o.offsetFromParent)break;const d={x:n.x+o.offsetFromParent.x,y:n.y+o.offsetFromParent.y};t.set(e.childId,{...o,position:d,hasBeenDragged:!0}),i=e.childId,n=d}}if(o.parentId&&o.offsetFromParent){const i=ne();let a=e,r=o;for(;r.parentId&&r.offsetFromParent;){const o=t.get(r.parentId);if(!o)break;const l=a===e?d:t.get(a).position,s={x:l.x-r.offsetFromParent.x,y:l.y-r.offsetFromParent.y};if(!("animated"!==i.parentChild.movementMode||null!=n&&n.realtime)){g.set(r.parentId,s);break}t.set(r.parentId,{...o,position:s,hasBeenDragged:!0}),a=r.parentId,r=o}}x()}function O(e){const i=t.get(e);if(!i||!i.isAnimatingPosition)return;i.isAnimatingPosition=!1;let n=i.childId;for(;n;){const e=t.get(n);e&&(e.isAnimatingPosition=!1),n=null==e?void 0:e.childId}x()}function L(e,i){if(!k(e))return;z(i,"updateModalSize");const n=t.get(e);n&&(t.set(e,{...n,size:i}),x())}function R(e){const o=ne();"smart"===o.positioning.strategy&&(i&&clearTimeout(i),n(setTimeout(()=>{const e=function(){const e=[];for(const i of t.values()){if(!i.isOpen||i.isMinimized||i.isHiddenWithParent||p.has(i.id))continue;const t=B(i.id);if(!t)continue;const n=i.position??{x:t.getBoundingClientRect().left,y:t.getBoundingClientRect().top},o=i.size??{width:t.offsetWidth,height:t.offsetHeight};e.push({id:i.id,width:o.width,height:o.height,currentPosition:n,parentId:i.parentId})}return e}(),i=function(e){if(typeof document>"u")return[];const t=[];for(const i of e)try{const e=document.querySelectorAll(i);for(const i of e){const e=i.getBoundingClientRect();e.width>0&&e.height>0&&t.push({x:e.left,y:e.top,width:e.width,height:e.height})}}catch{}return t}(o.positioning.avoidElements);(function(e){if(0===e.size)return;const i=[];for(const[n,o]of e){const e=t.get(n);if(!e)continue;const d=B(n),a=e.position??(d?{x:d.getBoundingClientRect().left,y:d.getBoundingClientRect().top}:{x:0,y:0}),r=e.size??(d?{width:d.offsetWidth,height:d.offsetHeight}:{width:0,height:0});i.push({id:n,element:d,oldPosition:a,newPosition:o,size:r}),$(n,a,o,i)}for(const{id:e,newPosition:n,size:o}of i){const i=t.get(e);i&&t.set(e,{...i,position:n,size:o,hasBeenDragged:!0,isAnimatingPosition:!0})}x();for(const{id:e,element:t,oldPosition:n,newPosition:o}of i)t?H(t,n,o,{duration:300,onComplete:()=>O(e)}):setTimeout(()=>O(e),400)})(function(e,t,i={}){const{modalGap:n=16,viewportMargin:o=16,avoidBounds:d=[],avoidMargin:a=24}=i,r=typeof window<"u"?window.innerWidth:1920,l=typeof window<"u"?window.innerHeight:1080,s=new Map,c=e.filter(e=>!e.parentId),h=c.map(e=>({id:e.id,width:e.width,height:e.height}));if(0===h.length)return{positions:s};const m=new Map(c.map(e=>[e.id,e.currentPosition]));h.sort((e,t)=>{const i=m.get(e.id),n=m.get(t.id);return(i?i.x+e.width/2:1/0)-(n?n.x+t.width/2:1/0)});const f=function(e,t,i,n,o){let d=i,a=i,r=e-i,l=t-i;for(const i of n){const n=i.y,s=t-(i.y+i.height),c=i.x,h=e-(i.x+i.width);let m;if(i.width>i.height)m=n<=s?"top":"bottom";else if(i.height>i.width)m=c<=h?"left":"right";else{const e=Math.min(n,s,c,h);m=e===n?"top":e===s?"bottom":e===c?"left":"right"}"bottom"===m?l=Math.min(l,i.y-o):"top"===m?a=Math.max(a,i.y+i.height+o):"left"===m?d=Math.max(d,i.x+i.width+o):r=Math.min(r,i.x-o)}return{x:d,y:a,width:Math.max(0,r-d),height:Math.max(0,l-a)}}(r,l,o,d,a);if(1===h.length){const e=h[0],t=f.x+(f.width-e.width)/2,i=f.y+(f.height-e.height)/2;return s.set(e.id,{x:Math.round(t),y:Math.round(i)}),{positions:s}}const u=h.length;let g=null;for(let e=1;e<=u;e++){const t=G(e,Math.ceil(u/e),h,f,n);t&&(null===g||t.score>g.score)&&(g=t)}if(g){for(const[e,t]of g.positions)s.set(e,t);return{positions:s}}return{positions:T(h,f)}}(e,0,{modalGap:o.positioning.modalGap,viewportMargin:o.positioning.modalGap,avoidBounds:i,avoidMargin:o.positioning.modalGap}).positions),n(null)},50)))}function $(e,i,n,o){const d=t.get(e);if(null==d||!d.childId)return;const a=t.get(d.childId);if(null==a||!a.offsetFromParent)return;const r=B(d.childId),l={x:i.x+a.offsetFromParent.x,y:i.y+a.offsetFromParent.y},s={x:n.x+a.offsetFromParent.x,y:n.y+a.offsetFromParent.y};o.push({id:d.childId,element:r,oldPosition:l,newPosition:s}),t.set(d.childId,{...a,position:s,hasBeenDragged:!0,isAnimatingPosition:!0}),a.childId&&$(d.childId,l,s,o)}function V(e){g.delete(e)}function q(e){const i=t.get(e);if(null==i||!i.childId)return;const n=t.get(i.childId);n&&(m.includes(i.childId)||function(e){m=e}([...m,i.childId]),n.childId&&q(i.childId))}function N(e){const i=t.get(e);if(!i||i.isMinimized)return;if(V(e),i.parentId){const e=t.get(i.parentId);if(e&&!e.isMinimized)return void N(i.parentId)}(function(e){a=e})([...a,e]),i.position&&i.size;const n=i.childId;t.set(e,{...i,isMinimized:!0,lastChildId:n}),I.includes(e)||w([...I,e]),x(),i.childId&&q(e),R()}function _(e){const i=t.get(e);if(!i||!i.isMinimized)return;t.set(e,{...i,isMinimized:!1,isOpen:!0}),y([...c,e]),v(e);const n=i.lastChildId||i.childId;n&&j(n),x()}function U(){Array.from(t.values()).filter(e=>e.isMinimized).map(e=>e.id).forEach(e=>{const i=t.get(e);if(i){t.set(e,{...i,isMinimized:!1,isOpen:!0}),y([...c,e]),v(e);const n=i.lastChildId||i.childId;n&&j(n)}}),w([]),x()}function j(e){const i=t.get(e);if(i&&i.isHiddenWithParent){!function(e){h=e}([...h,e]);const t=i.lastChildId||i.childId;t&&j(t)}}function J(e){k(e)&&(f.includes(e)||(function(e){f=e}([...f,e]),x()))}function K(e,i,n){const o=ne(),d=t.get(e);if(d&&d.isOpen&&!d.isMinimized&&!d.isHiddenWithParent)return J(e),void v(e);if(d&&d.isMinimized)return void _(e);if("x"in i&&"y"in i)u.set(e,i);else{const t=i.getBoundingClientRect();u.set(e,{x:t.left+t.width/2,y:t.top+t.height/2})}if(null!=n&&n.parentId&&o.features.parentChild){const i=t.get(n.parentId);null!=i&&i.childId&&i.childId!==e&&X(i.childId,!0),n.parentId}if(r.includes(e)||M([...r,e]),x(),!d)return;const a={isOpen:!0};null!=n&&n.parentId&&o.features.parentChild&&(a.parentId=n.parentId),t.set(e,{...d,...a}),v(e)}function Q(e){!function(e){const i=t.get(e.id);let n;n=null!=i&&i.zIndex?i.zIndex:Math.max(...Array.from(t.values()).map(e=>e.zIndex),ne().zIndex.base-2)+2;const o=r.includes(e.id),d=e.isOpen||o;i?t.set(e.id,{...i,title:e.title,icon:e.icon,glow:e.glow,zIndex:n}):t.set(e.id,{...e,isOpen:d,zIndex:n,isAnimating:!1}),x(),e.isMinimized&&!I.includes(e.id)&&w([...I,e.id])}(e);const i=t.get(e.id);i&&(t.set(e.id,{...i,isOpen:!0}),x()),M([...r,e.id]),x(),v(e.id)}function X(e,i=!1){const n=t.get(e);if(n&&(n.isOpen||n.isMinimized)){if(V(e),n.childId&&X(n.childId,i),n.isMinimized)return w(I.filter(t=>t!==e)),void function(e){const i=t.get(e);if(i){if(p.delete(e),i.parentId){const n=t.get(i.parentId);n&&n.childId===e&&t.set(i.parentId,{...n,childId:void 0,lastChildId:e})}t.set(e,{...i,isOpen:!1,isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,position:null,size:null,hasBeenDragged:!1,parentId:void 0,childId:void 0,offsetFromParent:void 0}),x()}}(e);p.add(e),i?function(e){s=e}([...s,e]):function(e){l=e}([...l,e]),n.parentId||R(),x()}}function Y(e){const i=new Set(e??[]);Array.from(t.keys()).filter(e=>!i.has(e)).forEach(e=>X(e,!0))}const Z={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"};let ee={...Z};const te=new Set;function ie(){te.forEach(e=>e())}function ne(){return ee}function oe(e){const t=ee;ee=function(e,t){var i;return{features:{...e.features,...t.features},dock:{...e.dock,...t.dock},animations:{...e.animations,...t.animations},appearance:{...e.appearance,...t.appearance},zIndex:{...e.zIndex,...t.zIndex},parentChild:{...e.parentChild,...t.parentChild},positioning:{...e.positioning,...t.positioning,avoidElements:(null==(i=t.positioning)?void 0:i.avoidElements)??e.positioning.avoidElements},portalTarget:t.portalTarget??e.portalTarget}}(ee,e),ie(),t.features.dock&&!ee.features.dock&&U()}function de(){ee={...Z},ie()}function ae(e){const t=ee.features[e];if("backdrop"===e){const e=function(e){return"boolean"==typeof e?{visible:e,blockClicks:e}:e}(t);return e.visible||e.blockClicks}return t}const re={dialog:"modal-dialog",dialogCentered:"modal-centered",dialogDragging:"modal-dragging",dialogResizing:"modal-resizing",dialogMinimizing:"modal-minimizing",dialogRestoring:"modal-restoring",dialogOpening:"modal-opening",dialogClosing:"modal-closing",dialogSolid:"modal-solid",dialogTransparent:"modal-transparent",dialogHasGlow:"modal-has-glow",dialogHasChild:"modal-has-child",dialogIsChild:"modal-is-child",dialogAnimatingPosition:"modal-animating-position",dialogAttention:"modal-attention",header:"modal-header",headerDraggable:"modal-header-draggable",headerLayout:e=>`modal-header--${e}`,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",dockItemActive:"modal-dock-item-active",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",dockLeft:"modal-dock-left",dockRight:"modal-dock-right",dockBottom:"modal-dock-bottom",dockFree:"modal-dock-free",dockEmpty:"modal-dock-empty",dockFreeHorizontal:"modal-dock-free-horizontal",dockFreeVertical:"modal-dock-free-vertical",backdrop:"modal-backdrop",backdropVisible:"modal-backdrop-visible"},le={modalId:"data-modal-id",resizeDirection:"data-direction",dockItemId:"data-dock-item-id"};export{re as CSS_CLASSES,le as DATA_ATTRIBUTES,v as bringToFront,Y as closeAllModals,X as closeModal,Q as createModal,Z as defaultConfig,ne as getConfig,S as getModalState,ae as isFeatureEnabled,D as isModalOpen,E as isModalRegistered,C as isTopModal,N as minimizeModal,K as openModal,de as resetConfig,U as restoreAllMinimizedModals,_ as restoreModal,F as screenCenter,oe as setConfig,J as triggerAttention,W as updateModalPosition,L as updateModalSize};
|
package/dist/react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as n,Fragment as t}from"react/jsx-runtime";import i,{useRef as r,createContext as o,useContext as a,useState as l,useEffect as s,useMemo as d,useCallback as c,Children as u,isValidElement as m,useSyncExternalStore as p}from"react";import{bringToFront as g,isTopModal as h,registerModal as f,createModalRegistration as b,unregisterModal as v,isModalAnimating as y,shakeElement as w,restoreModal as C,subscribe as z,getModalsStore as k,openModal as x,closeModal as I,minimizeModal as N,openChildModal as E,triggerAttention as M,isModalRegistered as S}from"./core.js";import{CSS as D,RESIZE_DIRECTIONS as T,RESIZE_DIRECTION_LABELS as $}from"./core.js";import{ModalController as L}from"./core.js";import{toDataId as R}from"./core.js";import{createPortal as P}from"react-dom";import{getConfigVersion as O,getConfig as A}from"./core.js";import{createConfigResolver as B}from"./core.js";import{getLayerZIndex as j,initializeStacking as W,resetStacking as H}from"./core.js";import{initializeResizeListener as F,cleanupResizeListener as V}from"./core.js";import{isBackdropEnabled as X,getBackdropConfig as G,hasOpenModals as _}from"./core.js";import{getMinimizedModals as K,getDockContainerClasses as U,getDockClasses as Y,calculateDockDragPosition as Z,constrainDockPosition as q}from"./core.js";function J({target:e="#modal-portal",children:n}){const t=r(null);if(null===t.current)if("string"==typeof e){let n=document.querySelector(e);n||(e.startsWith("#")?(n=document.createElement("div"),n.id=e.slice(1),document.body.appendChild(n)):n=document.body),t.current=n}else t.current=e;return P(n,t.current)}const Q=o(null),ee=o(void 0),ne=o(void 0);function te({title:t,customIcon:i,icon:r,isTransparent:o=!1,titleId:l,headerLayout:s="macos",onStartDrag:d,onToggleStyle:c,onMinimize:u,onClose:m,minimizable:p=!0,minimizeDisabled:g=!1,transparencyEnabled:h=!0}){const f=a(ne),b="macos"===s;function v(e){e.target.closest("button")||null==d||d(e)}const y=[D.header,d&&D.headerDraggable,o&&"transparent"].filter(Boolean).join(" "),w=i??(r&&f?f(r):null);return e("header",b?{className:y,onPointerDown:v,children:[e("div",{className:D.headerTrafficLights,children:[n("button",{type:"button",className:`${D.headerLight} ${D.headerLightClose}`,onClick:m,"aria-label":"Close"}),p&&n("button",{type:"button",className:`${D.headerLight} ${D.headerLightMinimize}${g?` ${D.headerLightDisabled}`:""}`,onClick:g?void 0:u,disabled:g,"aria-label":"Minimize",title:g?"Enable dock to minimize":void 0}),h&&n("button",{type:"button",className:`${D.headerLight} ${D.headerLightStyle}`,onClick:c,"aria-label":"Toggle style"})]}),e("div",{className:D.headerMacCenter,children:[w&&n("div",{className:D.headerIcon,children:w}),n("div",{className:D.headerTitleGroup,children:n("h2",l?{id:l,className:D.headerTitle,children:t}:{className:D.headerTitle,children:t})})]}),n("div",{className:D.headerMacSpacer})]}:{className:y,onPointerDown:v,children:[e("div",{className:D.headerTitleGroup,children:[w&&n("div",{className:D.headerIcon,children:w}),n("h2",l?{id:l,className:D.headerTitle,children:t}:{className:D.headerTitle,children:t})]}),e("div",{className:D.headerActions,children:[h&&n("button",{type:"button",className:`${D.headerBtnWindows} ${D.headerBtnWindowsStyle}`,onClick:c,"aria-label":"Toggle style",children:"◇"}),p&&n("button",{type:"button",className:`${D.headerBtnWindows}${g?` ${D.headerBtnWindowsDisabled}`:""}`,onClick:g?void 0:u,disabled:g,"aria-label":"Minimize",title:g?"Enable dock to minimize":void 0,children:"–"}),n("button",{type:"button",className:`${D.headerBtnWindows} ${D.headerBtnWindowsClose}`,onClick:m,"aria-label":"Close",children:"×"})]})]})}function ie({onStartResize:e}){return e?n("div",{className:D.resizeHandles,role:"group","aria-label":"Resize handles",children:T.map(t=>n("div",{className:`${D.resizeHandle} ${D.resizePrefix}${t}`,role:"separator",tabIndex:0,"aria-label":$[t],"aria-orientation":"n"===t||"s"===t?"horizontal":"vertical",onPointerDown:n=>e(n,t)},t))}):null}function re(e){return e.replace(/-([a-z])/g,(e,n)=>n.toUpperCase())}const oe={position:{x:0,y:0},size:{width:0,height:0},zIndex:1e3,isDragging:!1,isResizing:!1,hasBeenDragged:!1,hasBeenResized:!1,isMinimizing:!1,isRestoring:!1,isOpening:!1,isClosing:!1,isAnyAnimating:!1,animationTransform:null,isVisible:!1,showCentered:!1,isAwaitingRestore:!1,isAwaitingChildOpen:!1,isVisibleByAnimation:!1,hasChild:!1,isChildModal:!1,showOverlay:!1,isTransparent:!1,isAttentionAnimating:!1,glowStabilizing:!1,isAnimatingPosition:!1,isAnimatingToCenter:!1,wasRestored:!1,overlayClosing:!1,glowEnabled:!1,draggable:!0,resizable:!0,minimizable:!0,dataState:"closed",dataAnimationPhase:"none",style:{},cssClasses:[D.modal]};function ae({id:t,title:i,renderIcon:o,icon:u,description:m,maxWidth:p="600px",preferredHeight:f,autoOpen:b=!1,openSourcePosition:v,glow:y,config:w,providerConfig:C,closeOnEscape:z=!0,onClose:k,children:x,footer:I,skipRegistration:N=!1}){const E=r(null),M=r(null),S=a(ee),T=C??S,$=function(e={}){const{modalConfig:n}=e,t=a(ee),[i,r]=l(()=>O());return s(()=>{const e=setInterval(()=>{const e=O();e!==i&&r(e)},50);return()=>clearInterval(e)},[i]),d(()=>({...B({getModalConfig:()=>n,getProviderConfig:()=>t??void 0}),providerConfig:t}),[n,t,i])}({modalConfig:w}),P=$.getEffectiveConfig().portalTarget,A=!$.isFeatureEnabled("dock"),j=$.isFeatureEnabled("transparency"),W=$.getAppearance("headerLayout"),[H,F]=l(oe),V=R(t),X=`modal-title-${V}`,G=m?`modal-desc-${V}`:void 0;s(()=>{const e=new L({id:t,title:i,icon:u,config:w,providerConfig:T,maxWidth:p,preferredHeight:f,glow:y,closeOnEscape:z,autoOpen:b,openSourcePosition:v,onClose:k,skipRegistration:N,configHelper:$});M.current=e;const n=e.subscribe(e=>{F(e)});return F(e.getState()),()=>{n(),e.destroy(),M.current=null}},[t]),s(()=>{E.current&&M.current&&H.isVisible&&M.current.mount(E.current)},[H.isVisible]),s(()=>{var e;null==(e=M.current)||e.updateGlow(y)},[y]);const _=r(H.isVisible);_.current=H.isVisible,s(()=>{if(!z)return;const e=e=>{"Escape"===e.key&&_.current&&(e._modalEscapeHandled||M.current&&h(t)&&(M.current.handleKeyDown(e),e._modalEscapeHandled=!0))};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[z,t]),s(()=>{M.current&&void 0!==v&&M.current.setOpenSourcePosition(v)},[v]);const K=c(e=>{var n;null==(n=M.current)||n.startDrag(e.nativeEvent)},[]),U=c(e=>{var n;null==(n=M.current)||n.handlePointerMove(e.nativeEvent)},[]),Y=c(e=>{var n;null==(n=M.current)||n.handlePointerUp(e.nativeEvent)},[]),Z=c(e=>{var n;null==(n=M.current)||n.handleKeyDown(e.nativeEvent)},[]),q=c(()=>{var e;null==(e=M.current)||e.minimize()},[]),ne=c(()=>{var e;null==(e=M.current)||e.close()},[]),ae=c(()=>{var e;null==(e=M.current)||e.toggleTransparency()},[]),le=c((e,n)=>{var t;null==(t=M.current)||t.startResize(e.nativeEvent,n)},[]),se=d(()=>function(e){const n={};for(const[t,i]of Object.entries(e))t.startsWith("--")?n[t]=i:n[re(t)]=i;return n}(H.style),[H.style]);return H.isVisible?n(J,{target:P,children:n(Q.Provider,{value:t,children:e("div",{ref:E,className:H.cssClasses.join(" "),"data-modal-id":V,"data-state":H.dataState,"data-animation-phase":H.dataAnimationPhase,style:se,role:"dialog","aria-modal":"true","aria-labelledby":X,"aria-describedby":G,tabIndex:-1,onKeyDown:Z,onPointerMove:U,onPointerUp:Y,onPointerDownCapture:()=>g(t),children:[m&&n("span",{id:G,className:"sr-only",children:m}),n(te,{title:i,customIcon:null==o?void 0:o(),icon:u,isTransparent:H.isTransparent,titleId:X,headerLayout:W,onStartDrag:H.draggable?K:void 0,onToggleStyle:ae,onMinimize:q,onClose:ne,minimizable:H.minimizable,minimizeDisabled:A,transparencyEnabled:j}),n("div",{className:D.body,children:x}),I&&n("div",{className:D.footer,children:I}),n(ie,{onStartResize:H.resizable&&!H.hasChild?le:void 0}),H.showOverlay&&n("div",{className:`${D.childOverlay}${H.overlayClosing?` ${D.overlayClosing}`:""}`})]})})}):null}function le({id:e,title:t,icon:i,maxWidth:r="600px",preferredHeight:o,autoOpen:l=!1,glow:d,config:c,closeOnEscape:u=!0,onClose:m,children:p,footer:h,renderIcon:y}){const w=a(ee),C=a(ne);return s(()=>(f(b({id:e,title:t,icon:i,autoOpen:l,glow:d})),l&&g(e),()=>{v(e)}),[e]),n(ae,{id:e,title:t,icon:i,renderIcon:y??(i&&C?()=>C(i):void 0),maxWidth:r,preferredHeight:o,autoOpen:l,glow:d,config:c,providerConfig:w??void 0,closeOnEscape:u,onClose:m,skipRegistration:!0,footer:h,children:p})}function se({children:e}){return n(t,{children:e})}function de(e){var n;return m(e)&&(e.type===se||"WizardStep"===(null==(n=e.type)?void 0:n.displayName))}function ce({id:t,onComplete:i,onStepChange:o,footer:a,showProgress:d=!0,showNavigation:m=!0,maxWidth:p="500px",children:g,onClose:h,...f}){const b=u.toArray(g).filter(de),[v,y]=l(0),[w,C]=l("forward"),[z,k]=l(!1),[x,I]=l(0),N=r(v),E=b[v],M=(null==E?void 0:E.props.canProceed)??!0;s(()=>{if(v!==N.current){C(v>N.current?"forward":"backward"),k(!0),I(e=>e+1);const e=setTimeout(()=>k(!1),300);return N.current=v,()=>clearTimeout(e)}},[v]);const S=c(()=>{if(M)if(v>=b.length-1)null==i||i();else{const e=v+1;y(e),null==o||o(e,"forward")}},[v,b.length,M,i,o]),D=c(()=>{if(v>0){const e=v-1;y(e),null==o||o(e,"backward")}},[v,o]),T=c(e=>{e<v&&e>=0&&(y(e),null==o||o(e,"backward"))},[v,o]),$=0===v,L=v===b.length-1,R=b.length>0?(v+1)/b.length*100:0,P=b.length,O=b.map(e=>({title:e.props.title||""})),A={currentStep:v,totalSteps:P,isFirstStep:$,isLastStep:L,canProceed:M,progress:R,steps:O,next:S,back:D,goToStep:T},B=c(()=>{y(0),null==h||h()},[h]),j=d&&P>1,W=m?e("div",{className:"wizard-navigation",style:me.navigation,children:[n("button",{className:"wizard-btn-back",style:{...me.button,...$?me.buttonDisabled:{}},onClick:D,disabled:$,children:"Back"}),n("button",{className:"wizard-btn-next",style:{...me.button,...me.buttonPrimary,...M?{}:me.buttonDisabled},onClick:S,disabled:!M,children:L?"Finish":"Next"})]}):null;return e(le,{id:t,maxWidth:p,onClose:B,footer:a?a(A):W,...f,children:[e("div",{className:"wizard-viewport",style:ue.viewport,children:[j&&n("div",{className:"wizard-progress",style:me.progress,children:O.map((t,i)=>e("div",{style:me.stepItem,children:[n("button",{className:`wizard-step-dot ${i===v?"active":""} ${i<v?"completed":""}`,style:{...me.stepDot,...i===v?me.stepDotActive:{},...i<v?me.stepDotCompleted:{}},onClick:()=>T(i),disabled:i>=v}),t.title&&n("span",{style:me.stepTitle,children:t.title})]},i))}),n("div",{className:"wizard-container",style:ue.container,children:n("div",{className:"wizard-step-content "+(z?"forward"===w?"wizard-slide-left":"wizard-slide-right":""),style:ue.stepContent,children:E},x)})]}),n("style",{children:pe})]})}se.displayName="WizardStep";const ue={viewport:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},container:{display:"flex",flexDirection:"column",flex:1,minHeight:0},stepContent:{flex:1,overflowY:"auto"}},me={progress:{display:"flex",justifyContent:"center",alignItems:"flex-start",gap:"24px",padding:"12px 16px",borderBottom:"1px solid rgba(255, 255, 255, 0.1)"},stepItem:{display:"flex",flexDirection:"column",alignItems:"center",gap:"6px"},stepDot:{width:"10px",height:"10px",borderRadius:"50%",border:"2px solid rgba(255, 255, 255, 0.3)",background:"transparent",padding:0,cursor:"pointer",transition:"all 0.2s ease"},stepDotActive:{borderColor:"#6366f1",background:"#6366f1",transform:"scale(1.2)"},stepDotCompleted:{borderColor:"#6366f1",background:"#6366f1",opacity:.6},stepTitle:{fontSize:"11px",color:"rgba(255, 255, 255, 0.6)",textAlign:"center",maxWidth:"80px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},navigation:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",borderTop:"1px solid rgba(255, 255, 255, 0.1)",gap:"12px"},button:{padding:"8px 16px",borderRadius:"6px",border:"1px solid rgba(255, 255, 255, 0.2)",background:"rgba(255, 255, 255, 0.05)",color:"rgba(255, 255, 255, 0.8)",cursor:"pointer",fontSize:"14px",fontWeight:500,transition:"all 0.2s ease"},buttonPrimary:{background:"linear-gradient(135deg, #6366f1, #8b5cf6)",border:"none",color:"white"},buttonDisabled:{opacity:.4,cursor:"not-allowed"}},pe="\n .wizard-slide-left {\n animation: wizardSlideInFromRight 0.3s ease forwards;\n }\n .wizard-slide-right {\n animation: wizardSlideInFromLeft 0.3s ease forwards;\n }\n @keyframes wizardSlideInFromRight {\n from { opacity: 0; transform: translateX(30px); }\n to { opacity: 1; transform: translateX(0); }\n }\n @keyframes wizardSlideInFromLeft {\n from { opacity: 0; transform: translateX(-30px); }\n to { opacity: 1; transform: translateX(0); }\n }\n";function ge({className:e}){const t=a(ee),[,i]=l(0);s(()=>{const e=setInterval(()=>{i(e=>e+1)},50);return()=>clearInterval(e)},[]);const r=A(),o=(null==t?void 0:t.portalTarget)??r.portalTarget,d=X(),c=G(),u=_(),m=j("MODAL")-1;if(!d||!u)return null;const p=[D.backdrop,c.visible&&"backdrop-visible",c.blockClicks&&"backdrop-blocking",e].filter(Boolean).join(" ");return n(J,{target:o,children:n("div",{className:p,style:{zIndex:m},"aria-hidden":"true"})})}function he({config:e,children:n}){s(()=>{W(),F();const n=A(),t=(null==e?void 0:e.portalTarget)??n.portalTarget;let i=null;return"string"==typeof t&&typeof document<"u"&&(document.querySelector(t)||(i=document.createElement("div"),i.id=t.replace("#",""),document.body.appendChild(i))),()=>{H(),V(),i&&i.remove()}},[e]);const t=d(()=>e,[e]);return i.createElement(ee.Provider,{value:t},i.createElement(i.Fragment,null,n,i.createElement(ge,null)))}function fe({modal:t,childModal:i,labelMode:r="beside",renderIcon:o,animationDelay:l=0}){const s=a(ne),d=o??s,u=c(e=>{y(t.id)?w(e.currentTarget):C(t.id)},[t.id]),m=R(t.id),p=!!t.glow,g=!!t.lastChildId,h=[D.dockItem,p&&D.dockItemHasGlow,g&&D.dockItemHasChild,"beside"===r&&D.dockItemLabelBeside,"below"===r&&D.dockItemLabelBelow].filter(Boolean).join(" "),f={...t.glow?{"--modal-dock-glow-color":t.glow.color}:{},animationDelay:l>0?`${l}ms`:void 0};return e("button",{className:h,"data-modal-id":m,"aria-label":`Restore ${t.title}`,onClick:u,style:f,children:[n("span",{className:D.dockItemIcon,children:t.icon&&d?d(t.icon):n("span",{className:D.dockItemIconPlaceholder,children:t.title.charAt(0)})}),"hidden"!==r&&n("span",{className:D.dockItemLabel,children:t.title}),n("span",{className:D.dockItemGlow}),g&&i&&n("span",{className:D.dockChildIndicator,children:i.icon&&d?d(i.icon):n("span",{children:"+"})})]})}function be({renderIcon:t}){var i,o,d;const u=a(ne),m=a(ee),p=t??u,[g,h]=l(0),[f,b]=l(0),[v,y]=l("horizontal"),[w,C]=l({x:100,y:100}),[x,I]=l(!1),N=r(null),E=r({x:0,y:0}),M=r(null);s(()=>z(()=>{h(e=>e+1),b(O())}),[]);const S=A(),T=j("DOCK"),$=(null==(i=null==m?void 0:m.dock)?void 0:i.position)??S.dock.position,L=(null==(o=null==m?void 0:m.dock)?void 0:o.labelMode)??S.dock.labelMode,R=(null==(d=null==m?void 0:m.features)?void 0:d.dock)??S.features.dock,P=(null==m?void 0:m.portalTarget)??S.portalTarget,B=k(),W=K(),H=c(e=>{var n;"free"===$&&(I(!0),M.current=e.pointerId,E.current={x:e.clientX-w.x,y:e.clientY-w.y},null==(n=e.currentTarget)||n.setPointerCapture(e.pointerId))},[$,w]);if(s(()=>{if(!x)return;const e=e=>{if(e.pointerId!==M.current||!N.current)return;const n=N.current.getBoundingClientRect(),t=Z(e.clientX,e.clientY,E.current,n.width,n.height);C(t)},n=e=>{e.pointerId===M.current&&(I(!1),M.current=null)};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",n),window.addEventListener("pointercancel",n),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",n),window.removeEventListener("pointercancel",n)}},[x]),s(()=>{if("free"!==$)return;const e=()=>{if(!N.current)return;const e=N.current.getBoundingClientRect(),n=q(w,e.width,e.height);(n.x!==w.x||n.y!==w.y)&&C(n)};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[$,w]),!R)return null;const F=U($,0===W.length),V=Y($,v),X={zIndex:T,..."free"===$?{left:`${w.x}px`,top:`${w.y}px`}:{}};return n(J,{target:P,children:n("div",{ref:N,className:F,style:X,"data-dock-container":"true",children:e("div",{className:V,children:["free"===$&&n("button",{type:"button",className:`${D.dockHandle}${x?` ${D.dockHandleDragging}`:""}`,onPointerDown:H,"aria-label":"Drag dock"}),W.map((e,t)=>{const i=e.lastChildId?B.get(e.lastChildId):null;return n(fe,{modal:e,childModal:i,labelMode:L,renderIcon:p??void 0,animationDelay:50*t},String(e.id))})]})})})}function ve(e,n){if(!S(e))throw new Error(`Cannot call ${n}() on unregistered modal "${String(e)}". Ensure the Modal component is rendered.`)}const ye=new Map;function we(e){const n=c(()=>function(e){const n=k().get(e),t=void 0!==n&&!n.isMinimized,i=(null==n?void 0:n.isMinimized)??!1,r=void 0!==n,o=ye.get(e);if(o&&o.isOpen===t&&o.isMinimized===i&&o.isRegistered===r)return o;const a={isOpen:t,isMinimized:i,isRegistered:r};return ye.set(e,a),a}(e),[e]);return{...p(z,n,n),open:c(n=>{ve(e,"open"),x(e,n)},[e]),close:c(()=>{ve(e,"close"),I(e)},[e]),minimize:c(()=>{ve(e,"minimize"),N(e)},[e]),restore:c(()=>{ve(e,"restore"),C(e)},[e]),openChild:c((n,t)=>{ve(e,"openChild"),E(n,e,t??document.body)},[e]),shake:c(()=>{ve(e,"shake"),M(e)},[e]),bringToFront:c(()=>{ve(e,"bringToFront"),g(e)},[e])}}let Ce=null,ze=null;function ke(){const e=k();if(Ce===e&&ze)return ze;const n=Array.from(e.values()),t=n.filter(e=>e.isMinimized).length,i=n.filter(e=>!e.isMinimized).length;return ze&&ze.minimizedCount===t&&ze.openCount===i?(Ce=e,ze={...ze,modals:e},ze):(Ce=e,ze={modals:e,minimizedCount:t,openCount:i},ze)}function xe(){return p(z,ke,ke)}export{be as Dock,le as Modal,he as ModalProvider,ce as WizardModal,se as WizardStep,we as useModal,xe as useModals};
|
|
1
|
+
import{jsxs as e,jsx as n,Fragment as t}from"react/jsx-runtime";import i,{useRef as r,createContext as a,useContext as o,useState as l,useEffect as s,useMemo as d,useCallback as c,Children as u,isValidElement as p,useSyncExternalStore as m}from"react";import{Q as h,R as g,k as f,b,M as v,h as y,S as w,l as C,n as x,p as z,u as k,y as N,x as I,z as E,A as S,j as D,E as T,F as M,G as $,H as L,K as P,L as R,r as O,s as A,I as W,T as B,O as H,J as j,U as F,N as V,d as G,c as X,m as K,o as U,t as Y,i as q}from"./backdrop.js";import{createPortal as _}from"react-dom";import{c as J}from"./resolution.js";function Q({target:e="#modal-portal",children:n}){const t=r(null);if(null===t.current)if("string"==typeof e){let n=document.querySelector(e);n||(e.startsWith("#")?(n=document.createElement("div"),n.id=e.slice(1),document.body.appendChild(n)):n=document.body),t.current=n}else t.current=e;return _(n,t.current)}const Z=a(null),ee=a(void 0),ne=a(void 0);function te({title:t,customIcon:i,icon:r,isTransparent:a=!1,titleId:l,headerLayout:s="macos",onStartDrag:d,onToggleStyle:c,onMinimize:u,onClose:p,minimizable:m=!0,minimizeDisabled:g=!1,transparencyEnabled:f=!0}){const b=o(ne),v="macos"===s;function y(e){e.target.closest("button")||null==d||d(e)}const w=[h.header,d&&h.headerDraggable,a&&"transparent"].filter(Boolean).join(" "),C=i??(r&&b?b(r):null);return e("header",v?{className:w,onPointerDown:y,children:[e("div",{className:h.headerTrafficLights,children:[n("button",{type:"button",className:`${h.headerLight} ${h.headerLightClose}`,onClick:p,"aria-label":"Close"}),m&&n("button",{type:"button",className:`${h.headerLight} ${h.headerLightMinimize}${g?` ${h.headerLightDisabled}`:""}`,onClick:g?void 0:u,disabled:g,"aria-label":"Minimize",title:g?"Enable dock to minimize":void 0}),f&&n("button",{type:"button",className:`${h.headerLight} ${h.headerLightStyle}`,onClick:c,"aria-label":"Toggle style"})]}),e("div",{className:h.headerMacCenter,children:[C&&n("div",{className:h.headerIcon,children:C}),n("div",{className:h.headerTitleGroup,children:n("h2",l?{id:l,className:h.headerTitle,children:t}:{className:h.headerTitle,children:t})})]}),n("div",{className:h.headerMacSpacer})]}:{className:w,onPointerDown:y,children:[e("div",{className:h.headerTitleGroup,children:[C&&n("div",{className:h.headerIcon,children:C}),n("h2",l?{id:l,className:h.headerTitle,children:t}:{className:h.headerTitle,children:t})]}),e("div",{className:h.headerActions,children:[f&&n("button",{type:"button",className:`${h.headerBtnWindows} ${h.headerBtnWindowsStyle}`,onClick:c,"aria-label":"Toggle style",children:"◇"}),m&&n("button",{type:"button",className:`${h.headerBtnWindows}${g?` ${h.headerBtnWindowsDisabled}`:""}`,onClick:g?void 0:u,disabled:g,"aria-label":"Minimize",title:g?"Enable dock to minimize":void 0,children:"–"}),n("button",{type:"button",className:`${h.headerBtnWindows} ${h.headerBtnWindowsClose}`,onClick:p,"aria-label":"Close",children:"×"})]})]})}function ie({onStartResize:e}){return e?n("div",{className:h.resizeHandles,role:"group","aria-label":"Resize handles",children:g.map(t=>n("div",{className:`${h.resizeHandle} ${h.resizePrefix}${t}`,role:"separator",tabIndex:0,"aria-label":f[t],"aria-orientation":"n"===t||"s"===t?"horizontal":"vertical",onPointerDown:n=>e(n,t)},t))}):null}function re(e){return e.replace(/-([a-z])/g,(e,n)=>n.toUpperCase())}const ae={position:{x:0,y:0},size:{width:0,height:0},zIndex:1e3,isDragging:!1,isResizing:!1,hasBeenDragged:!1,hasBeenResized:!1,isMinimizing:!1,isRestoring:!1,isOpening:!1,isClosing:!1,isAnyAnimating:!1,animationTransform:null,isVisible:!1,showCentered:!1,isAwaitingRestore:!1,isAwaitingChildOpen:!1,isVisibleByAnimation:!1,hasChild:!1,isChildModal:!1,showOverlay:!1,isTransparent:!1,isAttentionAnimating:!1,glowStabilizing:!1,isAnimatingPosition:!1,isAnimatingToCenter:!1,wasRestored:!1,overlayClosing:!1,glowEnabled:!1,draggable:!0,resizable:!0,minimizable:!0,dataState:"closed",dataAnimationPhase:"none",style:{},cssClasses:[h.modal]};function oe({id:t,title:i,renderIcon:a,icon:u,description:p,maxWidth:m="600px",preferredHeight:g,autoOpen:f=!1,openSourcePosition:x,glow:z,config:k,providerConfig:N,closeOnEscape:I=!0,onClose:E,children:S,footer:D,skipRegistration:T=!1}){const M=r(null),$=r(null),L=o(ee),P=N??L,R=function(e={}){const{modalConfig:n}=e,t=o(ee),[i,r]=l(()=>b());return s(()=>{const e=setInterval(()=>{const e=b();e!==i&&r(e)},50);return()=>clearInterval(e)},[i]),d(()=>({...J({getModalConfig:()=>n,getProviderConfig:()=>t??void 0}),providerConfig:t}),[n,t,i])}({modalConfig:k}),O=R.getEffectiveConfig().portalTarget,A=!R.isFeatureEnabled("dock"),W=R.isFeatureEnabled("transparency"),B=R.getAppearance("headerLayout"),[H,j]=l(ae),F=C(t),V=`modal-title-${F}`,G=p?`modal-desc-${F}`:void 0;s(()=>{const e=new v({id:t,title:i,icon:u,config:k,providerConfig:P,maxWidth:m,preferredHeight:g,glow:z,closeOnEscape:I,autoOpen:f,openSourcePosition:x,onClose:E,skipRegistration:T,configHelper:R});$.current=e;const n=e.subscribe(e=>{j(e)});return j(e.getState()),()=>{n(),e.destroy(),$.current=null}},[t]),s(()=>{M.current&&$.current&&H.isVisible&&$.current.mount(M.current)},[H.isVisible]),s(()=>{var e;null==(e=$.current)||e.updateGlow(z)},[z]);const X=r(H.isVisible);X.current=H.isVisible,s(()=>{if(!I)return;const e=e=>{"Escape"===e.key&&X.current&&(e._modalEscapeHandled||$.current&&w(t)&&($.current.handleKeyDown(e),e._modalEscapeHandled=!0))};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[I,t]),s(()=>{$.current&&void 0!==x&&$.current.setOpenSourcePosition(x)},[x]);const K=c(e=>{var n;null==(n=$.current)||n.startDrag(e.nativeEvent)},[]),U=c(e=>{var n;null==(n=$.current)||n.handlePointerMove(e.nativeEvent)},[]),Y=c(e=>{var n;null==(n=$.current)||n.handlePointerUp(e.nativeEvent)},[]),q=c(e=>{var n;null==(n=$.current)||n.handleKeyDown(e.nativeEvent)},[]),_=c(()=>{var e;null==(e=$.current)||e.minimize()},[]),ne=c(()=>{var e;null==(e=$.current)||e.close()},[]),oe=c(()=>{var e;null==(e=$.current)||e.toggleTransparency()},[]),le=c((e,n)=>{var t;null==(t=$.current)||t.startResize(e.nativeEvent,n)},[]),se=d(()=>function(e){const n={};for(const[t,i]of Object.entries(e))t.startsWith("--")?n[t]=i:n[re(t)]=i;return n}(H.style),[H.style]);return H.isVisible?n(Q,{target:O,children:n(Z.Provider,{value:t,children:e("div",{ref:M,className:H.cssClasses.join(" "),"data-modal-id":F,"data-state":H.dataState,"data-animation-phase":H.dataAnimationPhase,style:se,role:"dialog","aria-modal":"true","aria-labelledby":V,"aria-describedby":G,tabIndex:-1,onKeyDown:q,onPointerMove:U,onPointerUp:Y,onPointerDownCapture:()=>y(t),children:[p&&n("span",{id:G,className:"sr-only",children:p}),n(te,{title:i,customIcon:null==a?void 0:a(),icon:u,isTransparent:H.isTransparent,titleId:V,headerLayout:B,onStartDrag:H.draggable?K:void 0,onToggleStyle:oe,onMinimize:_,onClose:ne,minimizable:H.minimizable,minimizeDisabled:A,transparencyEnabled:W}),n("div",{className:h.body,children:S}),D&&n("div",{className:h.footer,children:D}),n(ie,{onStartResize:H.resizable&&!H.hasChild?le:void 0}),H.showOverlay&&n("div",{className:`${h.childOverlay}${H.overlayClosing?` ${h.overlayClosing}`:""}`})]})})}):null}function le({id:e,title:t,icon:i,maxWidth:r="600px",preferredHeight:a,autoOpen:l=!1,glow:d,config:c,closeOnEscape:u=!0,onClose:p,children:m,footer:h,renderIcon:g}){const f=o(ee),b=o(ne);return s(()=>(x(z({id:e,title:t,icon:i,autoOpen:l,glow:d})),l&&y(e),()=>{k(e)}),[e]),n(oe,{id:e,title:t,icon:i,renderIcon:g??(i&&b?()=>b(i):void 0),maxWidth:r,preferredHeight:a,autoOpen:l,glow:d,config:c,providerConfig:f??void 0,closeOnEscape:u,onClose:p,skipRegistration:!0,footer:h,children:m})}function se({children:e}){return n(t,{children:e})}function de(e){var n;return p(e)&&(e.type===se||"WizardStep"===(null==(n=e.type)?void 0:n.displayName))}function ce({id:t,onComplete:i,onStepChange:a,footer:o,showProgress:d=!0,showNavigation:p=!0,maxWidth:m="500px",children:h,onClose:g,...f}){const b=u.toArray(h).filter(de),[v,y]=l(0),[w,C]=l("forward"),[x,z]=l(!1),[k,N]=l(0),I=r(v),E=b[v],S=(null==E?void 0:E.props.canProceed)??!0;s(()=>{if(v!==I.current){C(v>I.current?"forward":"backward"),z(!0),N(e=>e+1);const e=setTimeout(()=>z(!1),300);return I.current=v,()=>clearTimeout(e)}},[v]);const D=c(()=>{if(S)if(v>=b.length-1)null==i||i();else{const e=v+1;y(e),null==a||a(e,"forward")}},[v,b.length,S,i,a]),T=c(()=>{if(v>0){const e=v-1;y(e),null==a||a(e,"backward")}},[v,a]),M=c(e=>{e<v&&e>=0&&(y(e),null==a||a(e,"backward"))},[v,a]),$=0===v,L=v===b.length-1,P=b.length>0?(v+1)/b.length*100:0,R=b.length,O=b.map(e=>({title:e.props.title||""})),A={currentStep:v,totalSteps:R,isFirstStep:$,isLastStep:L,canProceed:S,progress:P,steps:O,next:D,back:T,goToStep:M},W=c(()=>{y(0),null==g||g()},[g]),B=d&&R>1,H=p?e("div",{className:"wizard-navigation",style:pe.navigation,children:[n("button",{className:"wizard-btn-back",style:{...pe.button,...$?pe.buttonDisabled:{}},onClick:T,disabled:$,children:"Back"}),n("button",{className:"wizard-btn-next",style:{...pe.button,...pe.buttonPrimary,...S?{}:pe.buttonDisabled},onClick:D,disabled:!S,children:L?"Finish":"Next"})]}):null;return e(le,{id:t,maxWidth:m,onClose:W,footer:o?o(A):H,...f,children:[e("div",{className:"wizard-viewport",style:ue.viewport,children:[B&&n("div",{className:"wizard-progress",style:pe.progress,children:O.map((t,i)=>e("div",{style:pe.stepItem,children:[n("button",{className:`wizard-step-dot ${i===v?"active":""} ${i<v?"completed":""}`,style:{...pe.stepDot,...i===v?pe.stepDotActive:{},...i<v?pe.stepDotCompleted:{}},onClick:()=>M(i),disabled:i>=v}),t.title&&n("span",{style:pe.stepTitle,children:t.title})]},i))}),n("div",{className:"wizard-container",style:ue.container,children:n("div",{className:"wizard-step-content "+(x?"forward"===w?"wizard-slide-left":"wizard-slide-right":""),style:ue.stepContent,children:E},k)})]}),n("style",{children:me})]})}se.displayName="WizardStep";const ue={viewport:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},container:{display:"flex",flexDirection:"column",flex:1,minHeight:0},stepContent:{flex:1,overflowY:"auto"}},pe={progress:{display:"flex",justifyContent:"center",alignItems:"flex-start",gap:"24px",padding:"12px 16px",borderBottom:"1px solid rgba(255, 255, 255, 0.1)"},stepItem:{display:"flex",flexDirection:"column",alignItems:"center",gap:"6px"},stepDot:{width:"10px",height:"10px",borderRadius:"50%",border:"2px solid rgba(255, 255, 255, 0.3)",background:"transparent",padding:0,cursor:"pointer",transition:"all 0.2s ease"},stepDotActive:{borderColor:"#6366f1",background:"#6366f1",transform:"scale(1.2)"},stepDotCompleted:{borderColor:"#6366f1",background:"#6366f1",opacity:.6},stepTitle:{fontSize:"11px",color:"rgba(255, 255, 255, 0.6)",textAlign:"center",maxWidth:"80px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},navigation:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",borderTop:"1px solid rgba(255, 255, 255, 0.1)",gap:"12px"},button:{padding:"8px 16px",borderRadius:"6px",border:"1px solid rgba(255, 255, 255, 0.2)",background:"rgba(255, 255, 255, 0.05)",color:"rgba(255, 255, 255, 0.8)",cursor:"pointer",fontSize:"14px",fontWeight:500,transition:"all 0.2s ease"},buttonPrimary:{background:"linear-gradient(135deg, #6366f1, #8b5cf6)",border:"none",color:"white"},buttonDisabled:{opacity:.4,cursor:"not-allowed"}},me="\n .wizard-slide-left {\n animation: wizardSlideInFromRight 0.3s ease forwards;\n }\n .wizard-slide-right {\n animation: wizardSlideInFromLeft 0.3s ease forwards;\n }\n @keyframes wizardSlideInFromRight {\n from { opacity: 0; transform: translateX(30px); }\n to { opacity: 1; transform: translateX(0); }\n }\n @keyframes wizardSlideInFromLeft {\n from { opacity: 0; transform: translateX(-30px); }\n to { opacity: 1; transform: translateX(0); }\n }\n";function he({className:e}){const t=o(ee),[,i]=l(0);s(()=>{const e=setInterval(()=>{i(e=>e+1)},50);return()=>clearInterval(e)},[]);const r=D(),a=(null==t?void 0:t.portalTarget)??r.portalTarget,d=N(),c=I(),u=E(),p=S("MODAL")-1;if(!d||!u)return null;const m=[h.backdrop,c.visible&&"backdrop-visible",c.blockClicks&&"backdrop-blocking",e].filter(Boolean).join(" ");return n(Q,{target:a,children:n("div",{className:m,style:{zIndex:p},"aria-hidden":"true"})})}function ge({config:e,children:n}){s(()=>{T(),M();const n=D(),t=(null==e?void 0:e.portalTarget)??n.portalTarget;let i=null;return"string"==typeof t&&typeof document<"u"&&(document.querySelector(t)||(i=document.createElement("div"),i.id=t.replace("#",""),document.body.appendChild(i))),()=>{$(),L(),i&&i.remove()}},[e]);const t=d(()=>e,[e]);return i.createElement(ee.Provider,{value:t},i.createElement(i.Fragment,null,n,i.createElement(he,null)))}function fe({modal:t,childModal:i,labelMode:r="beside",renderIcon:a,animationDelay:l=0}){const s=o(ne),d=a??s,u=c(e=>{P(t.id)?R(e.currentTarget):O(t.id)},[t.id]),p=C(t.id),m=!!t.glow,g=!!t.lastChildId,f=[h.dockItem,m&&h.dockItemHasGlow,g&&h.dockItemHasChild,"beside"===r&&h.dockItemLabelBeside,"below"===r&&h.dockItemLabelBelow].filter(Boolean).join(" "),b={...t.glow?{"--modal-dock-glow-color":t.glow.color}:{},animationDelay:l>0?`${l}ms`:void 0};return e("button",{className:f,"data-modal-id":p,"aria-label":`Restore ${t.title}`,onClick:u,style:b,children:[n("span",{className:h.dockItemIcon,children:t.icon&&d?d(t.icon):n("span",{className:h.dockItemIconPlaceholder,children:t.title.charAt(0)})}),"hidden"!==r&&n("span",{className:h.dockItemLabel,children:t.title}),n("span",{className:h.dockItemGlow}),g&&i&&n("span",{className:h.dockChildIndicator,children:i.icon&&d?d(i.icon):n("span",{children:"+"})})]})}function be({renderIcon:t}){var i,a,d;const u=o(ne),p=o(ee),m=t??u,[g,f]=l(0),[v,y]=l(0),[w,C]=l("horizontal"),[x,z]=l({x:100,y:100}),[k,N]=l(!1),I=r(null),E=r({x:0,y:0}),T=r(null);s(()=>A(()=>{f(e=>e+1),y(b())}),[]);const M=D(),$=S("DOCK"),L=(null==(i=null==p?void 0:p.dock)?void 0:i.position)??M.dock.position,P=(null==(a=null==p?void 0:p.dock)?void 0:a.labelMode)??M.dock.labelMode,R=(null==(d=null==p?void 0:p.features)?void 0:d.dock)??M.features.dock,O=(null==p?void 0:p.portalTarget)??M.portalTarget,G=V(),X=W(),K=c(e=>{var n;"free"===L&&(N(!0),T.current=e.pointerId,E.current={x:e.clientX-x.x,y:e.clientY-x.y},null==(n=e.currentTarget)||n.setPointerCapture(e.pointerId))},[L,x]);if(s(()=>{if(!k)return;const e=e=>{if(e.pointerId!==T.current||!I.current)return;const n=I.current.getBoundingClientRect(),t=H(e.clientX,e.clientY,E.current,n.width,n.height);z(t)},n=e=>{e.pointerId===T.current&&(N(!1),T.current=null)};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",n),window.addEventListener("pointercancel",n),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",n),window.removeEventListener("pointercancel",n)}},[k]),s(()=>{if("free"!==L)return;const e=()=>{if(!I.current)return;const e=I.current.getBoundingClientRect(),n=j(x,e.width,e.height);(n.x!==x.x||n.y!==x.y)&&z(n)};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[L,x]),!R)return null;const U=B(L,0===X.length),Y=F(L,w),q={zIndex:$,..."free"===L?{left:`${x.x}px`,top:`${x.y}px`}:{}};return n(Q,{target:O,children:n("div",{ref:I,className:U,style:q,"data-dock-container":"true",children:e("div",{className:Y,children:["free"===L&&n("button",{type:"button",className:`${h.dockHandle}${k?` ${h.dockHandleDragging}`:""}`,onPointerDown:K,"aria-label":"Drag dock"}),X.map((e,t)=>{const i=e.lastChildId?G.get(e.lastChildId):null;return n(fe,{modal:e,childModal:i,labelMode:P,renderIcon:m??void 0,animationDelay:50*t},String(e.id))})]})})})}function ve(e,n){if(!q(e))throw new Error(`Cannot call ${n}() on unregistered modal "${String(e)}". Ensure the Modal component is rendered.`)}const ye=new Map;function we(e){const n=c(()=>function(e){const n=V().get(e),t=void 0!==n&&!n.isMinimized,i=(null==n?void 0:n.isMinimized)??!1,r=void 0!==n,a=ye.get(e);if(a&&a.isOpen===t&&a.isMinimized===i&&a.isRegistered===r)return a;const o={isOpen:t,isMinimized:i,isRegistered:r};return ye.set(e,o),o}(e),[e]);return{...m(A,n,n),open:c(n=>{ve(e,"open"),G(e,n)},[e]),close:c(()=>{ve(e,"close"),X(e)},[e]),minimize:c(()=>{ve(e,"minimize"),K(e)},[e]),restore:c(()=>{ve(e,"restore"),O(e)},[e]),openChild:c((n,t)=>{ve(e,"openChild"),U(n,e,t??document.body)},[e]),shake:c(()=>{ve(e,"shake"),Y(e)},[e]),bringToFront:c(()=>{ve(e,"bringToFront"),y(e)},[e])}}let Ce=null,xe=null;function ze(){const e=V();if(Ce===e&&xe)return xe;const n=Array.from(e.values()),t=n.filter(e=>e.isMinimized).length,i=n.filter(e=>!e.isMinimized).length;return xe&&xe.minimizedCount===t&&xe.openCount===i?(Ce=e,xe={...xe,modals:e},xe):(Ce=e,xe={modals:e,minimizedCount:t,openCount:i},xe)}function ke(){return m(A,ze,ze)}export{be as Dock,le as Modal,ge as ModalProvider,ce as WizardModal,se as WizardStep,we as useModal,ke as useModals};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as n,V as i,W as o}from"./backdrop.js";function t(t){const{getModalConfig:a,getProviderConfig:e}=t;return{getEffectiveConfig:function(){const o=n(),t=e(),r=a();let l=o;return t&&(l=i(l,t)),r&&(l={...l,features:{...l.features,...r.features},appearance:{...l.appearance,...r.appearance},animations:{...l.animations,...r.animations},positioning:{...l.positioning,...r.positioning},parentChild:{...l.parentChild,...r.parentChild}}),l},isFeatureEnabled:function(i){var t,r;const l=a(),d=e(),u=n=>{if(void 0!==n){if("backdrop"===i&&"object"==typeof n){const i=o(n);return i.visible||i.blockClicks}return n}},s=u(null==(t=null==l?void 0:l.features)?void 0:t[i]);if(void 0!==s)return s;const p=u(null==(r=null==d?void 0:d.features)?void 0:r[i]);return void 0!==p?p:u(n().features[i])??!1},getAppearance:function(i){var o,t;const r=a(),l=e();return void 0!==(null==(o=null==r?void 0:r.appearance)?void 0:o[i])?r.appearance[i]:void 0!==(null==(t=null==l?void 0:l.appearance)?void 0:t[i])?l.appearance[i]:n().appearance[i]},getAnimation:function(i){var o,t;const r=a(),l=e();return void 0!==(null==(o=null==r?void 0:r.animations)?void 0:o[i])?r.animations[i]:void 0!==(null==(t=null==l?void 0:l.animations)?void 0:t[i])?l.animations[i]:n().animations[i]},getPositioning:function(i){var o,t;const r=a(),l=e();return void 0!==(null==(o=null==r?void 0:r.positioning)?void 0:o[i])?r.positioning[i]:void 0!==(null==(t=null==l?void 0:l.positioning)?void 0:t[i])?l.positioning[i]:n().positioning[i]},getParentChild:function(i){var o,t;const r=a(),l=e();return void 0!==(null==(o=null==r?void 0:r.parentChild)?void 0:o[i])?r.parentChild[i]:void 0!==(null==(t=null==l?void 0:l.parentChild)?void 0:t[i])?l.parentChild[i]:n().parentChild[i]}}}export{t as c};
|
package/dist/svelte.d.ts
CHANGED
|
@@ -1,178 +1,47 @@
|
|
|
1
|
-
import { AnimationDurations } from './core/config';
|
|
2
|
-
import { AnimationDurations as AnimationDurations_2 } from '../../core/config';
|
|
3
|
-
import { AppearanceConfig } from '../../core/config';
|
|
4
|
-
import { bringToFront } from './core/state';
|
|
5
|
-
import { closeAllModals } from './core/state';
|
|
6
1
|
import { closeModal } from './core/state';
|
|
7
|
-
import {
|
|
2
|
+
import { DockLabelMode } from './core/types';
|
|
3
|
+
import { DockPosition } from './core/types';
|
|
8
4
|
import { getConfig } from './core/config';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { getStateVersion } from './core/state';
|
|
13
|
-
import { isModalAnimating } from './core/state';
|
|
14
|
-
import { isModalOpen } from './core/state';
|
|
15
|
-
import { isModalRegistered } from './core/state';
|
|
16
|
-
import { linkModals } from './core/state';
|
|
17
|
-
import { minimizeModal } from './core/state';
|
|
18
|
-
import { ModalConfigOverrides } from '../../core/types';
|
|
19
|
-
import { ModalFeatures } from '../../core/config';
|
|
20
|
-
import { ModalId } from '../../core/types';
|
|
21
|
-
import { ModalLibraryConfig } from './core/config';
|
|
22
|
-
import { ModalLibraryConfig as ModalLibraryConfig_2 } from '../../core/config';
|
|
23
|
-
import { ModalState } from '../../core/types';
|
|
5
|
+
import { HeaderLayout } from './core/types';
|
|
6
|
+
import { ModalId } from './core/types';
|
|
7
|
+
import { ModalId as ModalId_2 } from '../../core/types';
|
|
24
8
|
import { openChildModal } from './core/state';
|
|
25
9
|
import { openModal } from './core/state';
|
|
26
|
-
import { ParentChildConfig } from './core/config';
|
|
27
|
-
import { ParentChildConfig as ParentChildConfig_2 } from '../../core/config';
|
|
28
|
-
import { PartialModalLibraryConfig } from '../../core/config';
|
|
29
|
-
import { PositioningConfig } from './core/config';
|
|
30
|
-
import { PositioningConfig as PositioningConfig_2 } from '../../core/config';
|
|
31
|
-
import { registerModal } from './core/state';
|
|
32
|
-
import { reorderDock } from './core/state';
|
|
33
|
-
import { resetConfig } from './core/config';
|
|
34
|
-
import { restoreAllMinimizedModals } from './core/state';
|
|
35
|
-
import { restoreModal } from './core/state';
|
|
36
|
-
import { screenCenter } from './core/utils/helpers';
|
|
37
10
|
import { setConfig } from './core/config';
|
|
38
|
-
import { setModalAnimating } from './core/state';
|
|
39
|
-
import { setRegistryFunctions } from './core/state';
|
|
40
|
-
import { setURLStateCallbacks } from './core/state';
|
|
41
|
-
import { shakeElement } from './core/state';
|
|
42
|
-
import { storeOpenSourcePosition } from './core/state';
|
|
43
11
|
import { SvelteComponent } from 'svelte';
|
|
44
|
-
import { toggleModalTransparency } from './core/state';
|
|
45
12
|
import { triggerAttention } from './core/state';
|
|
46
|
-
import { updateModalPosition } from './core/state';
|
|
47
|
-
|
|
48
|
-
export { AnimationDurations }
|
|
49
|
-
|
|
50
|
-
export { bringToFront }
|
|
51
|
-
|
|
52
|
-
export { closeAllModals }
|
|
53
13
|
|
|
54
14
|
export { closeModal }
|
|
55
15
|
|
|
56
|
-
export {
|
|
16
|
+
export { DockLabelMode }
|
|
57
17
|
|
|
58
|
-
export
|
|
18
|
+
export { DockPosition }
|
|
59
19
|
|
|
60
20
|
export { getConfig }
|
|
61
21
|
|
|
62
|
-
export {
|
|
63
|
-
|
|
64
|
-
export { getModalsStore }
|
|
65
|
-
|
|
66
|
-
export { getModalsToClose }
|
|
67
|
-
|
|
68
|
-
export declare function getReactiveConfigVersion(): number;
|
|
69
|
-
|
|
70
|
-
export declare function getReactiveStateVersion(): number;
|
|
71
|
-
|
|
72
|
-
export { getStateVersion }
|
|
73
|
-
|
|
74
|
-
export { isModalAnimating }
|
|
75
|
-
|
|
76
|
-
export { isModalOpen }
|
|
77
|
-
|
|
78
|
-
export { isModalRegistered }
|
|
79
|
-
|
|
80
|
-
export { linkModals }
|
|
81
|
-
|
|
82
|
-
export { minimizeModal }
|
|
83
|
-
|
|
84
|
-
export declare const MODAL_ID_CONTEXT: unique symbol;
|
|
22
|
+
export { HeaderLayout }
|
|
85
23
|
|
|
86
|
-
export {
|
|
24
|
+
export { ModalId }
|
|
87
25
|
|
|
88
26
|
export { openChildModal }
|
|
89
27
|
|
|
90
28
|
export { openModal }
|
|
91
29
|
|
|
92
|
-
export { ParentChildConfig }
|
|
93
|
-
|
|
94
|
-
declare type PortalTarget = string | HTMLElement | null;
|
|
95
|
-
|
|
96
|
-
export { PositioningConfig }
|
|
97
|
-
|
|
98
|
-
export { registerModal }
|
|
99
|
-
|
|
100
|
-
export declare const RENDER_ICON_CONTEXT: unique symbol;
|
|
101
|
-
|
|
102
|
-
export { reorderDock }
|
|
103
|
-
|
|
104
|
-
export { resetConfig }
|
|
105
|
-
|
|
106
|
-
export { restoreAllMinimizedModals }
|
|
107
|
-
|
|
108
|
-
export { restoreModal }
|
|
109
|
-
|
|
110
|
-
export { screenCenter }
|
|
111
|
-
|
|
112
30
|
export { setConfig }
|
|
113
31
|
|
|
114
|
-
export { setModalAnimating }
|
|
115
|
-
|
|
116
|
-
export { setRegistryFunctions }
|
|
117
|
-
|
|
118
|
-
export { setURLStateCallbacks }
|
|
119
|
-
|
|
120
|
-
export { shakeElement }
|
|
121
|
-
|
|
122
|
-
export { storeOpenSourcePosition }
|
|
123
|
-
|
|
124
32
|
export { SvelteComponent as Backdrop }
|
|
125
33
|
export { SvelteComponent as Dock }
|
|
126
34
|
export { SvelteComponent as Modal }
|
|
127
|
-
export { SvelteComponent as ModalHeader }
|
|
128
35
|
export { SvelteComponent as ModalProvider }
|
|
129
36
|
export { SvelteComponent as Portal }
|
|
130
|
-
export { SvelteComponent as ResizeHandles }
|
|
131
37
|
export { SvelteComponent as WizardModal }
|
|
132
38
|
export { SvelteComponent as WizardStep }
|
|
133
39
|
|
|
134
|
-
export { toggleModalTransparency }
|
|
135
|
-
|
|
136
|
-
export declare function trapFocus(event: KeyboardEvent, container: HTMLElement): void;
|
|
137
|
-
|
|
138
40
|
export { triggerAttention }
|
|
139
41
|
|
|
140
|
-
export
|
|
141
|
-
|
|
142
|
-
export declare function useFocusTrap(): {
|
|
143
|
-
trapFocus: typeof trapFocus;
|
|
144
|
-
focusFirstElement: typeof focusFirstElement;
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
export declare function useModal(id: ModalId): UseModalReturn;
|
|
148
|
-
|
|
149
|
-
export declare function useModalConfig(options?: UseModalConfigOptions): UseModalConfigReturn;
|
|
150
|
-
|
|
151
|
-
export declare interface UseModalConfigOptions {
|
|
152
|
-
|
|
153
|
-
getModalConfig?: () => ModalConfigOverrides | undefined;
|
|
154
|
-
|
|
155
|
-
getProviderConfig?: () => PartialModalLibraryConfig | undefined;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export declare interface UseModalConfigReturn {
|
|
159
|
-
|
|
160
|
-
getEffectiveConfig: () => ModalLibraryConfig_2;
|
|
161
|
-
|
|
162
|
-
isFeatureEnabled: (feature: keyof ModalFeatures) => boolean;
|
|
163
|
-
|
|
164
|
-
getAppearance: <K extends keyof AppearanceConfig>(key: K) => AppearanceConfig[K];
|
|
42
|
+
export declare function useModal(id: ModalId_2): UseModalReturn;
|
|
165
43
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
getPositioning: <K extends keyof PositioningConfig_2>(key: K) => PositioningConfig_2[K];
|
|
169
|
-
|
|
170
|
-
getParentChild: <K extends keyof ParentChildConfig_2>(key: K) => ParentChildConfig_2[K];
|
|
171
|
-
|
|
172
|
-
getProviderConfig: () => PartialModalLibraryConfig | undefined;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
export declare interface UseModalReturn {
|
|
44
|
+
declare interface UseModalReturn {
|
|
176
45
|
|
|
177
46
|
shake: () => void;
|
|
178
47
|
|
|
@@ -192,36 +61,16 @@ export declare interface UseModalReturn {
|
|
|
192
61
|
|
|
193
62
|
restore: () => void;
|
|
194
63
|
|
|
195
|
-
openChild: (childId:
|
|
64
|
+
openChild: (childId: ModalId_2, sourceElement?: HTMLElement) => void;
|
|
196
65
|
}
|
|
197
66
|
|
|
198
|
-
export declare function
|
|
199
|
-
|
|
200
|
-
export declare interface UseModalsReturn {
|
|
201
|
-
|
|
202
|
-
getModals: () => Map<ModalId, ModalState>;
|
|
67
|
+
export declare function useModalZIndex(modalId?: ModalId_2): UseModalZIndexReturn;
|
|
203
68
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
getOpenCount: () => number;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export declare function useModalZIndex(modalId?: ModalId): UseModalZIndexReturn;
|
|
210
|
-
|
|
211
|
-
export declare interface UseModalZIndexReturn {
|
|
69
|
+
declare interface UseModalZIndexReturn {
|
|
212
70
|
|
|
213
71
|
zIndex: number;
|
|
214
72
|
|
|
215
73
|
portalTarget: string | HTMLElement;
|
|
216
74
|
}
|
|
217
75
|
|
|
218
|
-
export declare function usePortal(): {
|
|
219
|
-
mount: (element: HTMLElement, target?: PortalTarget) => () => void;
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
export declare function useWindowEvent(): {
|
|
223
|
-
addListener: <K extends keyof WindowEventMap>(type: K, listener: (this: Window, ev: WindowEventMap[K]) => unknown, options?: AddEventListenerOptions) => () => void;
|
|
224
|
-
addListenerEffect: <K extends keyof WindowEventMap>(type: K, listener: (this: Window, ev: WindowEventMap[K]) => unknown, options?: AddEventListenerOptions) => void;
|
|
225
|
-
};
|
|
226
|
-
|
|
227
76
|
export { }
|