epic-modals 0.0.4 → 0.0.5
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/core/utils.d.ts +10 -0
- package/dist/index.js +1 -1
- package/dist/react/Dock.d.ts +2 -5
- package/dist/react/Modal.d.ts +2 -4
- package/dist/react.js +1 -1
- package/dist/styles/modal.css +1 -1
- package/dist/svelte/actions/appendElement.d.ts +9 -0
- package/dist/svelte/hooks/useModal.svelte.d.ts +1 -1
- package/dist/svelte/hooks/useModalZIndex.svelte.d.ts +1 -1
- package/dist/svelte.js +1 -1
- package/dist/vanilla.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core utility functions
|
|
3
|
+
*/
|
|
4
|
+
export type ModalId = string | symbol;
|
|
5
|
+
/**
|
|
6
|
+
* Convert a modal ID (string or Symbol) to a string suitable for DOM attributes
|
|
7
|
+
* Symbols are converted using their description property
|
|
8
|
+
*/
|
|
9
|
+
export declare function toDataId(id: ModalId): string;
|
|
10
|
+
//# sourceMappingURL=utils.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as t from"svelte/internal/client";const e={BASE:0,DROPDOWN:100,STICKY:200,OVERLAY:300,MODAL:400,DOCK:8e3,TOAST:9e3};let n=t.state(t.proxy(e.MODAL));function i(){t.set(n,oe().zIndex.base,!0)}function o(){const e=t.get(n);return t.set(n,t.get(n)+2),e}function r(t){const n=oe();return"MODAL"===t?n.zIndex.base:"DOCK"===t?n.zIndex.dock:"TOAST"===t?n.zIndex.toast:e[t]}function s(){t.set(n,oe().zIndex.base,!0)}const d=8;function a(t,e,n,i,o={}){const{margin:r=d,allowPartialVisibility:s=!1}=o,a="undefined"!=typeof window?window.innerWidth:1920,c="undefined"!=typeof window?window.innerHeight:1080;let u,l,f,g;return s&&n>a-2*r?(u=40-n,l=a-40):(u=r,l=Math.max(r,a-n-r)),s&&i>c-2*r?(f=40-i,g=c-40):(f=r,g=Math.max(r,c-i-r)),{x:Math.max(u,Math.min(l,t)),y:Math.max(f,Math.min(g,e))}}function c(t,e,n,i,o={}){const{margin:r=d}=o,s=("undefined"!=typeof window?window.innerWidth:1920)-2*r,c=("undefined"!=typeof window?window.innerHeight:1080)-2*r,u=Math.min(n,s),l=Math.min(i,c),f=a(t,e,u,l,o);return{x:f.x,y:f.y,width:u,height:l}}function u(t,e){return Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x))*Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y))}function l(t,e,n,i,o,r){const s={x:t-r,y:e-r,width:n+2*r,height:i+2*r};let d=0;for(const t of o)d+=u(s,t);return d}function f(t){if("undefined"==typeof document)return[];const e=[];for(const n of t)try{const t=document.querySelectorAll(n);for(const n of t){const t=n.getBoundingClientRect();t.width>0&&t.height>0&&e.push({x:t.left,y:t.top,width:t.width,height:t.height})}}catch{}return e}function g(t,e,n,i,o,r,s){const d=(o-n)/2,a=(r-i)/2,c=d-s,u=a-s,l=Math.abs(t-d)/(c||1),f=Math.abs(e-a)/(u||1),g=Math.sqrt(l*l+f*f)/Math.SQRT2,h=50,p=t-s,m=o-n-s-t,x=e-s,I=r-i-s-e;let y=0;return p<h&&(y+=.3*(1-p/h)),m<h&&(y+=.3*(1-m/h)),x<h&&(y+=.2*(1-x/h)),I<h&&(y+=.2*(1-I/h)),Math.min(1,g+y)}function h(t,e,n,i={}){const{modalGap:o=16,gridResolution:r=10,avoidBounds:s=[],avoidMargin:d=16}=i,a=i.margin??o,c="undefined"!=typeof window?window.innerWidth:1920,u="undefined"!=typeof window?window.innerHeight:1080,f=s.map(t=>({x:t.x-d,y:t.y-d,width:t.width+2*d,height:t.height+2*d})),h={x:(c-t)/2,y:(u-e)/2};if(0===n.length&&0===f.length)return h;const p=a,m=Math.max(a,c-t-a),x=a,I=Math.max(a,u-e-a);if(m<=p||I<=x)return h;const y=l(h.x,h.y,t,e,n,o),w=l(h.x,h.y,t,e,f,0);if(0===y&&0===w)return h;const z=[],M=(m-p)/r,v=(I-x)/r;for(let i=0;i<=r;i++)for(let s=0;s<=r;s++){const r=p+i*M,d=x+s*v,h=l(r,d,t,e,n,o),m=l(r,d,t,e,f,0),I=g(r,d,t,e,c,u,a);z.push({pos:{x:r,y:d},modalOverlap:h,avoidOverlap:m,centerDist:I})}const O=z.filter(t=>0===t.avoidOverlap),P=O.length>0?O:z,C=t*e,D=Math.min(...P.map(t=>t.modalOverlap))/C;return P.sort((t,e)=>{if(0===O.length&&t.avoidOverlap!==e.avoidOverlap)return t.avoidOverlap-e.avoidOverlap;const n=t.modalOverlap/C,i=e.modalOverlap/C;if(D<.3){const o=.3,r=n<=o,s=i<=o;if(r&&s)return t.centerDist+.3*n-(e.centerDist+.3*i);if(r)return-1;if(s)return 1}return.6*n+.4*t.centerDist-(.6*i+.4*e.centerDist)}),P[0].pos}function p(t,e,n,i={}){const{modalGap:o=16}=i,r=i.margin??o,s="undefined"!=typeof window?window.innerWidth:1920,d="undefined"!=typeof window?window.innerHeight:1080,a=n.reduce((t,e)=>t+e.width,0)+t,c=n.length*o,u=s-2*r;if(a+c>u)return null;const l=u-a-c;n.length;const f=l/2,g=s/2,h=[...n.map(t=>({id:t.id,width:t.width,height:t.height,currentX:t.x+t.width/2,currentY:t.y,isNew:!1})),{id:"__new__",width:t,height:e,currentX:g,currentY:(d-e)/2,isNew:!0}];h.sort((t,e)=>t.currentX-e.currentX);let p=r+f;const m=new Map;let x=null;for(const t of h){const e=p;if(t.isNew)x={x:Math.round(e),y:Math.round(t.currentY)};else{const i=n.find(e=>e.id===t.id);Math.abs(e-i.x)>5&&m.set(t.id,{x:Math.round(e),y:Math.round(i.y)})}p+=t.width+o}return x?{newModalPosition:x,existingModalMoves:m}:null}let m=t.proxy(new Map),x=t.state(0);const I=new Set;function y(){t.update(x),queueMicrotask(()=>{I.forEach(t=>t())})}function w(t){return I.add(t),()=>I.delete(t)}let z=t.state(t.proxy([])),M=t.state(t.proxy([])),v=t.state(t.proxy([])),O=t.state(t.proxy([])),P=t.state(t.proxy([])),C=t.state(t.proxy([])),D=t.state(t.proxy([])),k=t.state(t.proxy([])),T=t.state(null),b=t.proxy(new Map),A=t.state(null),F=t.proxy(new Map),W=t.proxy(new Set),H=t.proxy(new Set),B=t.state(t.proxy([])),S=null,R=null;function X(e){const n=m.get(e.id),i=(null==n?void 0:n.zIndex)??o();n?m.set(e.id,{...n,title:e.title,icon:e.icon,glow:e.glow,zIndex:i}):m.set(e.id,{...e,zIndex:i,isAnimating:!1}),y(),e.isMinimized&&!t.get(B).includes(e.id)&&t.get(B).push(e.id)}function E(e){const n=m.get(e);if(n){if(t.set(B,t.get(B).filter(t=>t!==e),!0),n.childId){const t=m.get(n.childId);t&&m.set(n.childId,{...t,parentId:void 0})}if(n.parentId){const t=m.get(n.parentId);t&&m.set(n.parentId,{...t,childId:void 0,lastChildId:n.id})}m.delete(e),y(),H.delete(e),W.delete(e)}}function Y(e){const n=m.get(e);if(!n||n.isMinimized)return;if(Kt(e),n.parentId){const t=m.get(n.parentId);if(t&&!t.isMinimized)return void Y(n.parentId)}if(t.set(z,[...t.get(z),e],!0),n.position&&n.size&&R){const i=R(),o=t.get(B).indexOf(e),r=i.x+o*(i.height+8),s=i.y;t.set(T,{x:r,y:s,originX:n.position.x+n.size.width/2,originY:n.position.y+n.size.height/2},!0)}const i=n.childId;m.set(e,{...n,isMinimized:!0,lastChildId:i}),y(),t.get(B).includes(e)||t.get(B).push(e),n.childId&&ot(e)}function q(e){const n=m.get(e);if(!n||!n.isMinimized)return;m.set(e,{...n,isMinimized:!1,isOpen:!0}),y(),t.set(P,[...t.get(P),e],!0),V(e);const i=n.lastChildId||n.childId;i&&N(i)}function L(){Array.from(m.values()).filter(t=>t.isMinimized).map(t=>t.id).forEach(e=>{const n=m.get(e);if(n){m.set(e,{...n,isMinimized:!1,isOpen:!0}),t.set(P,[...t.get(P),e],!0),V(e);const i=n.lastChildId||n.childId;i&&N(i)}}),t.set(B,[],!0),y()}function N(e){const n=m.get(e);n&&n.isHiddenWithParent&&(m.set(e,{...n,isHiddenWithParent:!1}),y(),t.set(C,[...t.get(C),e],!0))}function _(t,e,n){const i=m.get(t);if(!i)return;let o=e;if((null==n?void 0:n.constrain)&&i.size&&(o=a(e.x,e.y,i.size.width,i.size.height)),m.set(t,{...i,position:o,size:(null==n?void 0:n.size)??i.size,hasBeenDragged:i.hasBeenDragged||(null==n?void 0:n.drag)||!1}),i.childId){let e=t,n=o;for(;;){const t=m.get(e);if(!(null==t?void 0:t.childId))break;const i=m.get(t.childId);if(!(null==i?void 0:i.offsetFromParent))break;const o={x:n.x+i.offsetFromParent.x,y:n.y+i.offsetFromParent.y};m.set(t.childId,{...i,position:o,hasBeenDragged:!0}),e=t.childId,n=o}}if(i.parentId&&i.offsetFromParent){const e=oe();let n=t,r=i;for(;r.parentId&&r.offsetFromParent;){const i=m.get(r.parentId);if(!i)break;const s=n===t?o:m.get(n).position,d={x:s.x-r.offsetFromParent.x,y:s.y-r.offsetFromParent.y};"animated"===e.parentChild.movementMode?F.set(r.parentId,d):m.set(r.parentId,{...i,position:d,hasBeenDragged:!0}),n=r.parentId,r=i}}y()}function G(t,e){const n=m.get(t);n&&(m.set(t,{...n,size:e}),y())}function K(t,e){const n=m.get(t);n&&(m.set(t,{...n,...e}),y())}function V(t){var e;const n=m.get(t);if(!n)return;const i=Math.max(...Array.from(m.values()).map(t=>t.zIndex),0);if(n.parentId){const o=m.get(n.parentId);o&&o.zIndex<i&&m.set(n.parentId,{...o,zIndex:i+2});const r=(null==(e=m.get(n.parentId))?void 0:e.zIndex)??i+2;return n.zIndex<=r&&m.set(t,{...n,zIndex:r+2}),void y()}if(n.zIndex<i&&(m.set(t,{...n,zIndex:i+2}),y()),n.childId){const e=m.get(n.childId),i=m.get(t);e&&i&&e.zIndex<=i.zIndex&&(m.set(n.childId,{...e,zIndex:i.zIndex+2}),y())}}function $(t){const e=m.get(t);if(!e)return!1;const n=Math.max(...Array.from(m.values()).map(t=>t.zIndex),0);return e.zIndex===n&&!e.isMinimized&&!e.isHiddenWithParent}function j(e){t.set(B,e,!0)}function Q(e,n,i){const o=n.getBoundingClientRect();b.set(e,{x:o.left+o.width/2,y:o.top+o.height/2});const r=oe();(null==i?void 0:i.parentId)&&r.features.parentChild&&t.set(A,{parentId:i.parentId,childId:e},!0),t.get(M).includes(e)||t.set(M,[...t.get(M),e],!0),y();const s=m.get(e);if(s){if(s.isOpen&&!s.isMinimized&&!s.isHiddenWithParent)return t.set(M,t.get(M).filter(t=>t!==e),!0),kt(e),void V(e);if(s.isMinimized)return t.set(M,t.get(M).filter(t=>t!==e),!0),void q(e);m.set(e,{...s,isOpen:!0}),V(e),null==S||S.push(e)}}function J(e){X(e);const n=m.get(e.id);n&&(m.set(e.id,{...n,isOpen:!0}),y()),t.set(M,[...t.get(M),e.id],!0),y(),V(e.id),null==S||S.push(e.id)}function U(e,n=!1){const i=m.get(e);i&&(Kt(e),n?t.set(O,[...t.get(O),e],!0):t.set(v,[...t.get(v),e],!0),y(),i.childId&&U(i.childId,n),null==S||S.pop())}function Z(){Array.from(m.keys()).forEach(t=>U(t,!0))}function tt(t){const e=m.get(t);if(e){if(e.parentId){const n=m.get(e.parentId);n&&n.childId===t&&m.set(e.parentId,{...n,childId:void 0,lastChildId:t})}m.set(t,{...e,isOpen:!1,isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,position:null,size:null,hasBeenDragged:!1,parentId:void 0,childId:void 0,offsetFromParent:void 0}),y()}}function et(t){const e=m.get(t);if(!e)return[t];const n=[t];return e.childId&&n.push(...et(e.childId)),n}function nt(e,n,i){const o=oe();if(i&&!b.has(e.id)){const t=i.getBoundingClientRect();b.set(e.id,{x:t.left+t.width/2,y:t.top+t.height/2})}const r={id:e.id,title:e.title??"",icon:e.icon??"",isOpen:!0,isMinimized:!1,isHiddenWithParent:!1,isTransparent:e.isTransparent??!1,isRejected:!1,position:e.position??null,size:e.size??null,hasBeenDragged:e.hasBeenDragged??!1,dockPosition:e.dockPosition??-1,glow:e.glow??null};if(!o.features.parentChild){X(r);const n=m.get(e.id);return n&&m.set(e.id,{...n,isOpen:!0}),t.set(M,[...t.get(M),e.id],!0),y(),void V(e.id)}const s=m.get(n);if(!s)return;s.childId&&U(s.childId,!0),X({...r,parentId:n});const d=m.get(e.id);d&&m.set(e.id,{...d,isOpen:!0,parentId:n}),t.set(M,[...t.get(M),e.id],!0),y(),V(e.id),t.set(A,{parentId:n,childId:e.id},!0)}function it(t,e){if(!oe().features.parentChild)return;const n=m.get(t),i=m.get(e);if(!n||!i)return;let o={x:40,y:40};n.position&&i.position&&(o={x:i.position.x-n.position.x,y:i.position.y-n.position.y});const r=Math.max(i.zIndex,n.zIndex+1);m.set(t,{...n,childId:e,lastChildId:e}),m.set(e,{...i,parentId:t,offsetFromParent:o,zIndex:r}),y()}function ot(t){const e=m.get(t);if(!(null==e?void 0:e.childId))return;const n=m.get(e.childId);n&&(m.set(e.childId,{...n,isHiddenWithParent:!0}),y())}function rt(t,e){const n=m.get(t);if(!(null==n?void 0:n.childId))return;const i=m.get(n.childId);if(!i||!i.offsetFromParent)return;const o={x:e.x+i.offsetFromParent.x,y:e.y+i.offsetFromParent.y};m.set(n.childId,{...i,position:o}),y()}function st(t,e){const n=m.get(t),i=m.get(e);if(!(null==n?void 0:n.position)||!(null==i?void 0:i.position))return;const o={x:n.position.x-i.position.x,y:n.position.y-i.position.y};m.set(t,{...n,offsetFromParent:o}),y()}function dt(e){return t.get(z).includes(e)}function at(e){return!!t.get(z).includes(e)&&(t.set(z,t.get(z).filter(t=>t!==e),!0),!0)}function ct(){return t.get(z).length>0}function ut(){return Array.from(m.keys())}function lt(t){return m.get(t)}function ft(t){const e=[];for(const[n,i]of m.entries())if(n!==t&&i.isOpen&&!i.isMinimized&&!i.isHiddenWithParent&&!i.parentId)if(i.position&&i.size)e.push({id:String(n),x:i.position.x,y:i.position.y,width:i.size.width,height:i.size.height});else{const t=document.querySelector(`[data-modal-id="${String(n)}"]`);if(t){const i=t.getBoundingClientRect();e.push({id:String(n),x:i.left,y:i.top,width:i.width,height:i.height})}}return e}function gt(t){const e=[];for(const[n,i]of m.entries())if(n!==t&&i.isOpen&&!i.isMinimized&&!i.isHiddenWithParent)if(i.position&&i.size)e.push({x:i.position.x,y:i.position.y,width:i.size.width,height:i.size.height});else{const t=document.querySelector(`[data-modal-id="${String(n)}"]`);if(t){const n=t.getBoundingClientRect();e.push({x:n.left,y:n.top,width:n.width,height:n.height})}}return e}function ht(){return t.get(x)}function pt(){const e=t.get(T);return t.set(T,null),e}function mt(e){return t.get(M).includes(e)}function xt(e){return!!t.get(M).includes(e)&&(t.set(M,t.get(M).filter(t=>t!==e),!0),!0)}function It(e){return t.get(v).includes(e)}function yt(e){return!!t.get(v).includes(e)&&(t.set(v,t.get(v).filter(t=>t!==e),!0),!0)}function wt(e){return t.get(O).includes(e)}function zt(e){return!!t.get(O).includes(e)&&(t.set(O,t.get(O).filter(t=>t!==e),!0),!0)}function Mt(e){return t.get(P).includes(e)}function vt(e){return!!t.get(P).includes(e)&&(t.set(P,t.get(P).filter(t=>t!==e),!0),!0)}function Ot(e){return t.get(C).includes(e)}function Pt(e){return!!t.get(C).includes(e)&&(t.set(C,t.get(C).filter(t=>t!==e),!0),!0)}function Ct(e){return t.get(D).includes(e)}function Dt(e){return!!t.get(D).includes(e)&&(t.set(D,t.get(D).filter(t=>t!==e),!0),!0)}function kt(e){m.get(e)&&(t.get(D).includes(e)||t.get(k).includes(e)||(t.set(D,[...t.get(D),e],!0),y()))}function Tt(e){t.get(k).includes(e)||t.set(k,[...t.get(k),e],!0)}function bt(e){t.set(k,t.get(k).filter(t=>t!==e),!0)}function At(){return t.get(A)}function Ft(e){if(!t.get(A)||t.get(A).childId!==e)return null;const n=t.get(A);return t.set(A,null),n}function Wt(t,e){b.set(t,e)}function Ht(t){const e=b.get(t);return e&&b.delete(t),e??null}function Bt(t,e){e?W.add(t):W.delete(t)}function St(t){return W.has(t)}function Rt(t){const e=m.get(t);return void 0!==e&&e.isOpen&&!e.isMinimized&&!e.isHiddenWithParent}function Xt(t){return m.has(t)}function Et(){return{get modals(){return m},get pendingMinimize(){return t.get(z)},get pendingOpen(){return t.get(M)},get pendingClose(){return t.get(v)},get pendingRestore(){return t.get(P)},get dockOrder(){return t.get(B)}}}function Yt(t){H.has(t)?H.delete(t):H.add(t);const e=m.get(t);e&&(m.set(t,{...e,isTransparent:H.has(t)}),y())}function qt(t){H.delete(t);const e=m.get(t);e&&(m.set(t,{...e,isTransparent:!1}),y())}function Lt(t){t.animate([{transform:"translateX(0)"},{transform:"translateX(-6px)"},{transform:"translateX(6px)"},{transform:"translateX(-6px)"},{transform:"translateX(6px)"},{transform:"translateX(0)"}],{duration:300,easing:"ease-in-out"})}function Nt(t){const e=F.get(t);if(!e)return;const n=m.get(t);n&&(m.set(t,{...n,isAnimatingPosition:!0,position:e}),F.delete(t),y())}function _t(t){const e=m.get(t);e&&(m.set(t,{...e,isAnimatingPosition:!1}),y())}function Gt(t){return F.has(t)}function Kt(t){F.delete(t)}function Vt(t){const e=oe().parentChild.animationDuration;for(const[e,n]of t){const t=m.get(e);t&&m.set(e,{...t,position:n,isAnimatingPosition:!0,hasBeenDragged:!0})}y(),setTimeout(()=>{for(const e of t.keys()){const t=m.get(e);t&&m.set(e,{...t,isAnimatingPosition:!1})}y()},e)}function $t(t){const e=oe();if("animated"!==e.parentChild.movementMode)return;const n=e.parentChild.animationDuration,i=[];let o=t;for(;;){const t=m.get(o);if(!(null==t?void 0:t.parentId))break;i.push({parentId:t.parentId,childId:o}),o=t.parentId}i.forEach(({parentId:t,childId:e},i)=>{setTimeout(()=>{const i=m.get(e),o=m.get(t);if(!(null==i?void 0:i.position)||!i.offsetFromParent||!o)return;const r={x:i.position.x-i.offsetFromParent.x,y:i.position.y-i.offsetFromParent.y};F.set(t,r),Nt(t),setTimeout(()=>_t(t),n)},i*n)})}function jt(t){}function Qt(t){S=t}function Jt(t){R=t}function Ut(){return{modals:m,pendingMinimize:t.get(z),pendingOpen:t.get(M),pendingClose:t.get(v),pendingRestore:t.get(P),dockOrder:t.get(B),animatingModals:W,transparentModals:H}}function Zt(){m.clear(),t.get(z).length=0,t.get(M).length=0,t.get(v).length=0,t.get(O).length=0,t.get(P).length=0,t.get(C).length=0,t.set(T,null),b.clear(),t.set(A,null),F.clear(),W.clear(),H.clear(),t.get(B).length=0,S=null,R=null}const te={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},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={...te},ne=t.state(0);function ie(){return t.get(ne)}function oe(){return ee}function re(e){const n=ee;ee=de(te,e),t.update(ne),n.features.dock&&!ee.features.dock&&L()}function se(){ee={...te},t.update(ne)}function de(t,e){return{features:{...t.features,...e.features},dock:{...t.dock,...e.dock},animations:{...t.animations,...e.animations},appearance:{...t.appearance,...e.appearance},zIndex:{...t.zIndex,...e.zIndex},parentChild:{...t.parentChild,...e.parentChild},positioning:{...t.positioning,...e.positioning},portalTarget:e.portalTarget??t.portalTarget}}function ae(t){return ee.features[t]}export{Ut as _getInternalState,Zt as _resetInternalState,o as acquireModalZIndex,Vt as animateModalsToPositions,Nt as animateParentToPosition,V as bringToFront,u as calculateOverlap,g as calculatePositionScore,p as calculateRearrangement,l as calculateTotalOverlap,_t as clearParentAnimationFlag,Kt as clearPendingParentAnimation,Z as closeAllModals,U as closeModal,c as constrainSizeToViewport,a as constrainToViewport,Ht as consumeOpenSourcePosition,Dt as consumePendingAttention,Pt as consumePendingChildRestore,yt as consumePendingClose,zt as consumePendingForceClose,at as consumePendingMinimize,pt as consumePendingMinimizeTarget,xt as consumePendingOpen,Ft as consumePendingParentLink,vt as consumePendingRestore,J as createModal,te as defaultConfig,bt as endAttentionAnimation,tt as finalizeModalClose,h as findSmartPosition,oe as getConfig,ie as getConfigVersion,f as getElementBounds,r as getLayerZIndex,lt as getModalState,Et as getModalsStore,et as getModalsToClose,gt as getOpenModalBounds,ft as getOpenModalBoundsWithIds,At as getPendingParentLink,ut as getRegisteredModalIds,ht as getStateVersion,ct as hasAnyPendingMinimize,Ct as hasPendingAttention,Ot as hasPendingChildRestore,It as hasPendingClose,wt as hasPendingForceClose,dt as hasPendingMinimize,mt as hasPendingOpen,Gt as hasPendingParentAnimation,Mt as hasPendingRestore,ot as hideChildWithParent,i as initializeStacking,ae as isFeatureEnabled,St as isModalAnimating,Rt as isModalOpen,Xt as isModalRegistered,$ as isTopModal,it as linkModals,de as mergeConfig,Y as minimizeModal,nt as openChildModal,Q as openModal,X as registerModal,j as reorderDock,se as resetConfig,qt as resetModalTransparency,s as resetStacking,L as restoreAllMinimizedModals,N as restoreChildModal,q as restoreModal,st as setChildOffsetFromParent,re as setConfig,Jt as setDockPositionGetter,Bt as setModalAnimating,jt as setRegistryFunctions,Qt as setURLStateCallbacks,Lt as shakeElement,Tt as startAttentionAnimation,Wt as storeOpenSourcePosition,w as subscribe,Yt as toggleModalTransparency,kt as triggerAttention,$t as triggerCascadingParentAnimations,E as unregisterModal,rt as updateChildPosition,K as updateModal,_ as updateModalPosition,G as updateModalSize};
|
|
1
|
+
import*as t from"svelte/internal/client";const e={BASE:0,DROPDOWN:100,STICKY:200,OVERLAY:300,MODAL:400,DOCK:8e3,TOAST:9e3};let n=t.state(t.proxy(e.MODAL));function i(){t.set(n,re().zIndex.base,!0)}function o(){const e=t.get(n);return t.set(n,t.get(n)+2),e}function r(t){const n=re();return"MODAL"===t?n.zIndex.base:"DOCK"===t?n.zIndex.dock:"TOAST"===t?n.zIndex.toast:e[t]}function s(){t.set(n,re().zIndex.base,!0)}const d=8;function a(t,e,n,i,o={}){const{margin:r=d,allowPartialVisibility:s=!1}=o,a="undefined"!=typeof window?window.innerWidth:1920,c="undefined"!=typeof window?window.innerHeight:1080;let u,l,f,g;return s&&n>a-2*r?(u=40-n,l=a-40):(u=r,l=Math.max(r,a-n-r)),s&&i>c-2*r?(f=40-i,g=c-40):(f=r,g=Math.max(r,c-i-r)),{x:Math.max(u,Math.min(l,t)),y:Math.max(f,Math.min(g,e))}}function c(t,e,n,i,o={}){const{margin:r=d}=o,s=("undefined"!=typeof window?window.innerWidth:1920)-2*r,c=("undefined"!=typeof window?window.innerHeight:1080)-2*r,u=Math.min(n,s),l=Math.min(i,c),f=a(t,e,u,l,o);return{x:f.x,y:f.y,width:u,height:l}}function u(t,e){return Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x))*Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y))}function l(t,e,n,i,o,r){const s={x:t-r,y:e-r,width:n+2*r,height:i+2*r};let d=0;for(const t of o)d+=u(s,t);return d}function f(t){if("undefined"==typeof document)return[];const e=[];for(const n of t)try{const t=document.querySelectorAll(n);for(const n of t){const t=n.getBoundingClientRect();t.width>0&&t.height>0&&e.push({x:t.left,y:t.top,width:t.width,height:t.height})}}catch{}return e}function g(t,e,n,i,o,r,s){const d=(o-n)/2,a=(r-i)/2,c=d-s,u=a-s,l=Math.abs(t-d)/(c||1),f=Math.abs(e-a)/(u||1),g=Math.sqrt(l*l+f*f)/Math.SQRT2,h=50,p=t-s,m=o-n-s-t,x=e-s,I=r-i-s-e;let y=0;return p<h&&(y+=.3*(1-p/h)),m<h&&(y+=.3*(1-m/h)),x<h&&(y+=.2*(1-x/h)),I<h&&(y+=.2*(1-I/h)),Math.min(1,g+y)}function h(t,e,n,i={}){const{modalGap:o=16,gridResolution:r=10,avoidBounds:s=[],avoidMargin:d=16}=i,a=i.margin??o,c="undefined"!=typeof window?window.innerWidth:1920,u="undefined"!=typeof window?window.innerHeight:1080,f=s.map(t=>({x:t.x-d,y:t.y-d,width:t.width+2*d,height:t.height+2*d})),h={x:(c-t)/2,y:(u-e)/2};if(0===n.length&&0===f.length)return h;const p=a,m=Math.max(a,c-t-a),x=a,I=Math.max(a,u-e-a);if(m<=p||I<=x)return h;const y=l(h.x,h.y,t,e,n,o),w=l(h.x,h.y,t,e,f,0);if(0===y&&0===w)return h;const z=[],M=(m-p)/r,v=(I-x)/r;for(let i=0;i<=r;i++)for(let s=0;s<=r;s++){const r=p+i*M,d=x+s*v,h=l(r,d,t,e,n,o),m=l(r,d,t,e,f,0),I=g(r,d,t,e,c,u,a);z.push({pos:{x:r,y:d},modalOverlap:h,avoidOverlap:m,centerDist:I})}const O=z.filter(t=>0===t.avoidOverlap),P=O.length>0?O:z,C=t*e,D=Math.min(...P.map(t=>t.modalOverlap))/C;return P.sort((t,e)=>{if(0===O.length&&t.avoidOverlap!==e.avoidOverlap)return t.avoidOverlap-e.avoidOverlap;const n=t.modalOverlap/C,i=e.modalOverlap/C;if(D<.3){const o=.3,r=n<=o,s=i<=o;if(r&&s)return t.centerDist+.3*n-(e.centerDist+.3*i);if(r)return-1;if(s)return 1}return.6*n+.4*t.centerDist-(.6*i+.4*e.centerDist)}),P[0].pos}function p(t,e,n,i={}){const{modalGap:o=16}=i,r=i.margin??o,s="undefined"!=typeof window?window.innerWidth:1920,d="undefined"!=typeof window?window.innerHeight:1080,a=n.reduce((t,e)=>t+e.width,0)+t,c=n.length*o,u=s-2*r;if(a+c>u)return null;const l=u-a-c;n.length;const f=l/2,g=s/2,h=[...n.map(t=>({id:t.id,width:t.width,height:t.height,currentX:t.x+t.width/2,currentY:t.y,isNew:!1})),{id:"__new__",width:t,height:e,currentX:g,currentY:(d-e)/2,isNew:!0}];h.sort((t,e)=>t.currentX-e.currentX);let p=r+f;const m=new Map;let x=null;for(const t of h){const e=p;if(t.isNew)x={x:Math.round(e),y:Math.round(t.currentY)};else{const i=n.find(e=>e.id===t.id);Math.abs(e-i.x)>5&&m.set(t.id,{x:Math.round(e),y:Math.round(i.y)})}p+=t.width+o}return x?{newModalPosition:x,existingModalMoves:m}:null}function m(t){return"symbol"==typeof t?t.description??"symbol":t}let x=t.proxy(new Map),I=t.state(0);const y=new Set;function w(){t.update(I),queueMicrotask(()=>{y.forEach(t=>t())})}function z(t){return y.add(t),()=>y.delete(t)}let M=t.state(t.proxy([])),v=t.state(t.proxy([])),O=t.state(t.proxy([])),P=t.state(t.proxy([])),C=t.state(t.proxy([])),D=t.state(t.proxy([])),k=t.state(t.proxy([])),b=t.state(t.proxy([])),T=t.state(null),A=t.proxy(new Map),F=t.state(null),W=t.proxy(new Map),H=t.proxy(new Set),B=t.proxy(new Set),R=t.state(t.proxy([])),S=null,X=null;function E(e){const n=x.get(e.id),i=(null==n?void 0:n.zIndex)??o();n?x.set(e.id,{...n,title:e.title,icon:e.icon,glow:e.glow,zIndex:i}):x.set(e.id,{...e,zIndex:i,isAnimating:!1}),w(),e.isMinimized&&!t.get(R).includes(e.id)&&t.get(R).push(e.id)}function Y(e){const n=x.get(e);if(n){if(t.set(R,t.get(R).filter(t=>t!==e),!0),n.childId){const t=x.get(n.childId);t&&x.set(n.childId,{...t,parentId:void 0})}if(n.parentId){const t=x.get(n.parentId);t&&x.set(n.parentId,{...t,childId:void 0,lastChildId:n.id})}x.delete(e),w(),B.delete(e),H.delete(e)}}function q(e){const n=x.get(e);if(!n||n.isMinimized)return;if(Vt(e),n.parentId){const t=x.get(n.parentId);if(t&&!t.isMinimized)return void q(n.parentId)}if(t.set(M,[...t.get(M),e],!0),n.position&&n.size&&X){const i=X(),o=t.get(R).indexOf(e),r=i.x+o*(i.height+8),s=i.y;t.set(T,{x:r,y:s,originX:n.position.x+n.size.width/2,originY:n.position.y+n.size.height/2},!0)}const i=n.childId;x.set(e,{...n,isMinimized:!0,lastChildId:i}),w(),t.get(R).includes(e)||t.get(R).push(e),n.childId&&rt(e)}function L(e){const n=x.get(e);if(!n||!n.isMinimized)return;x.set(e,{...n,isMinimized:!1,isOpen:!0}),w(),t.set(C,[...t.get(C),e],!0),$(e);const i=n.lastChildId||n.childId;i&&_(i)}function N(){Array.from(x.values()).filter(t=>t.isMinimized).map(t=>t.id).forEach(e=>{const n=x.get(e);if(n){x.set(e,{...n,isMinimized:!1,isOpen:!0}),t.set(C,[...t.get(C),e],!0),$(e);const i=n.lastChildId||n.childId;i&&_(i)}}),t.set(R,[],!0),w()}function _(e){const n=x.get(e);n&&n.isHiddenWithParent&&(x.set(e,{...n,isHiddenWithParent:!1}),w(),t.set(D,[...t.get(D),e],!0))}function G(t,e,n){const i=x.get(t);if(!i)return;let o=e;if((null==n?void 0:n.constrain)&&i.size&&(o=a(e.x,e.y,i.size.width,i.size.height)),x.set(t,{...i,position:o,size:(null==n?void 0:n.size)??i.size,hasBeenDragged:i.hasBeenDragged||(null==n?void 0:n.drag)||!1}),i.childId){let e=t,n=o;for(;;){const t=x.get(e);if(!(null==t?void 0:t.childId))break;const i=x.get(t.childId);if(!(null==i?void 0:i.offsetFromParent))break;const o={x:n.x+i.offsetFromParent.x,y:n.y+i.offsetFromParent.y};x.set(t.childId,{...i,position:o,hasBeenDragged:!0}),e=t.childId,n=o}}if(i.parentId&&i.offsetFromParent){const e=re();let n=t,r=i;for(;r.parentId&&r.offsetFromParent;){const i=x.get(r.parentId);if(!i)break;const s=n===t?o:x.get(n).position,d={x:s.x-r.offsetFromParent.x,y:s.y-r.offsetFromParent.y};"animated"===e.parentChild.movementMode?W.set(r.parentId,d):x.set(r.parentId,{...i,position:d,hasBeenDragged:!0}),n=r.parentId,r=i}}w()}function K(t,e){const n=x.get(t);n&&(x.set(t,{...n,size:e}),w())}function V(t,e){const n=x.get(t);n&&(x.set(t,{...n,...e}),w())}function $(t){var e;const n=x.get(t);if(!n)return;const i=Math.max(...Array.from(x.values()).map(t=>t.zIndex),0);if(n.parentId){const o=x.get(n.parentId);o&&o.zIndex<i&&x.set(n.parentId,{...o,zIndex:i+2});const r=(null==(e=x.get(n.parentId))?void 0:e.zIndex)??i+2;return n.zIndex<=r&&x.set(t,{...n,zIndex:r+2}),void w()}if(n.zIndex<i&&(x.set(t,{...n,zIndex:i+2}),w()),n.childId){const e=x.get(n.childId),i=x.get(t);e&&i&&e.zIndex<=i.zIndex&&(x.set(n.childId,{...e,zIndex:i.zIndex+2}),w())}}function j(t){const e=x.get(t);if(!e)return!1;const n=Math.max(...Array.from(x.values()).map(t=>t.zIndex),0);return e.zIndex===n&&!e.isMinimized&&!e.isHiddenWithParent}function Q(e){t.set(R,e,!0)}function J(e,n,i){const o=n.getBoundingClientRect();A.set(e,{x:o.left+o.width/2,y:o.top+o.height/2});const r=re();(null==i?void 0:i.parentId)&&r.features.parentChild&&t.set(F,{parentId:i.parentId,childId:e},!0),t.get(v).includes(e)||t.set(v,[...t.get(v),e],!0),w();const s=x.get(e);if(s){if(s.isOpen&&!s.isMinimized&&!s.isHiddenWithParent)return t.set(v,t.get(v).filter(t=>t!==e),!0),bt(e),void $(e);if(s.isMinimized)return t.set(v,t.get(v).filter(t=>t!==e),!0),void L(e);x.set(e,{...s,isOpen:!0}),$(e),null==S||S.push(e)}}function U(e){E(e);const n=x.get(e.id);n&&(x.set(e.id,{...n,isOpen:!0}),w()),t.set(v,[...t.get(v),e.id],!0),w(),$(e.id),null==S||S.push(e.id)}function Z(e,n=!1){const i=x.get(e);i&&(Vt(e),n?t.set(P,[...t.get(P),e],!0):t.set(O,[...t.get(O),e],!0),w(),i.childId&&Z(i.childId,n),null==S||S.pop())}function tt(){Array.from(x.keys()).forEach(t=>Z(t,!0))}function et(t){const e=x.get(t);if(e){if(e.parentId){const n=x.get(e.parentId);n&&n.childId===t&&x.set(e.parentId,{...n,childId:void 0,lastChildId:t})}x.set(t,{...e,isOpen:!1,isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,position:null,size:null,hasBeenDragged:!1,parentId:void 0,childId:void 0,offsetFromParent:void 0}),w()}}function nt(t){const e=x.get(t);if(!e)return[t];const n=[t];return e.childId&&n.push(...nt(e.childId)),n}function it(e,n,i){const o=re();if(i&&!A.has(e.id)){const t=i.getBoundingClientRect();A.set(e.id,{x:t.left+t.width/2,y:t.top+t.height/2})}const r={id:e.id,title:e.title??"",icon:e.icon??"",isOpen:!0,isMinimized:!1,isHiddenWithParent:!1,isTransparent:e.isTransparent??!1,isRejected:!1,position:e.position??null,size:e.size??null,hasBeenDragged:e.hasBeenDragged??!1,dockPosition:e.dockPosition??-1,glow:e.glow??null};if(!o.features.parentChild){E(r);const n=x.get(e.id);return n&&x.set(e.id,{...n,isOpen:!0}),t.set(v,[...t.get(v),e.id],!0),w(),void $(e.id)}const s=x.get(n);if(!s)return;s.childId&&Z(s.childId,!0),E({...r,parentId:n});const d=x.get(e.id);d&&x.set(e.id,{...d,isOpen:!0,parentId:n}),t.set(v,[...t.get(v),e.id],!0),w(),$(e.id),t.set(F,{parentId:n,childId:e.id},!0)}function ot(t,e){if(!re().features.parentChild)return;const n=x.get(t),i=x.get(e);if(!n||!i)return;let o={x:40,y:40};n.position&&i.position&&(o={x:i.position.x-n.position.x,y:i.position.y-n.position.y});const r=Math.max(i.zIndex,n.zIndex+1);x.set(t,{...n,childId:e,lastChildId:e}),x.set(e,{...i,parentId:t,offsetFromParent:o,zIndex:r}),w()}function rt(t){const e=x.get(t);if(!(null==e?void 0:e.childId))return;const n=x.get(e.childId);n&&(x.set(e.childId,{...n,isHiddenWithParent:!0}),w())}function st(t,e){const n=x.get(t);if(!(null==n?void 0:n.childId))return;const i=x.get(n.childId);if(!i||!i.offsetFromParent)return;const o={x:e.x+i.offsetFromParent.x,y:e.y+i.offsetFromParent.y};x.set(n.childId,{...i,position:o}),w()}function dt(t,e){const n=x.get(t),i=x.get(e);if(!(null==n?void 0:n.position)||!(null==i?void 0:i.position))return;const o={x:n.position.x-i.position.x,y:n.position.y-i.position.y};x.set(t,{...n,offsetFromParent:o}),w()}function at(e){return t.get(M).includes(e)}function ct(e){return!!t.get(M).includes(e)&&(t.set(M,t.get(M).filter(t=>t!==e),!0),!0)}function ut(){return t.get(M).length>0}function lt(){return Array.from(x.keys())}function ft(t){return x.get(t)}function gt(t){const e=[];for(const[n,i]of x.entries())if(n!==t&&i.isOpen&&!i.isMinimized&&!i.isHiddenWithParent&&!i.parentId)if(i.position&&i.size)e.push({id:m(n),x:i.position.x,y:i.position.y,width:i.size.width,height:i.size.height});else{const t=document.querySelector(`[data-modal-id="${m(n)}"]`);if(t){const i=t.getBoundingClientRect();e.push({id:m(n),x:i.left,y:i.top,width:i.width,height:i.height})}}return e}function ht(t){const e=[];for(const[n,i]of x.entries())if(n!==t&&i.isOpen&&!i.isMinimized&&!i.isHiddenWithParent)if(i.position&&i.size)e.push({x:i.position.x,y:i.position.y,width:i.size.width,height:i.size.height});else{const t=document.querySelector(`[data-modal-id="${m(n)}"]`);if(t){const n=t.getBoundingClientRect();e.push({x:n.left,y:n.top,width:n.width,height:n.height})}}return e}function pt(){return t.get(I)}function mt(){const e=t.get(T);return t.set(T,null),e}function xt(e){return t.get(v).includes(e)}function It(e){return!!t.get(v).includes(e)&&(t.set(v,t.get(v).filter(t=>t!==e),!0),!0)}function yt(e){return t.get(O).includes(e)}function wt(e){return!!t.get(O).includes(e)&&(t.set(O,t.get(O).filter(t=>t!==e),!0),!0)}function zt(e){return t.get(P).includes(e)}function Mt(e){return!!t.get(P).includes(e)&&(t.set(P,t.get(P).filter(t=>t!==e),!0),!0)}function vt(e){return t.get(C).includes(e)}function Ot(e){return!!t.get(C).includes(e)&&(t.set(C,t.get(C).filter(t=>t!==e),!0),!0)}function Pt(e){return t.get(D).includes(e)}function Ct(e){return!!t.get(D).includes(e)&&(t.set(D,t.get(D).filter(t=>t!==e),!0),!0)}function Dt(e){return t.get(k).includes(e)}function kt(e){return!!t.get(k).includes(e)&&(t.set(k,t.get(k).filter(t=>t!==e),!0),!0)}function bt(e){x.get(e)&&(t.get(k).includes(e)||t.get(b).includes(e)||(t.set(k,[...t.get(k),e],!0),w()))}function Tt(e){t.get(b).includes(e)||t.set(b,[...t.get(b),e],!0)}function At(e){t.set(b,t.get(b).filter(t=>t!==e),!0)}function Ft(){return t.get(F)}function Wt(e){if(!t.get(F)||t.get(F).childId!==e)return null;const n=t.get(F);return t.set(F,null),n}function Ht(t,e){A.set(t,e)}function Bt(t){const e=A.get(t);return e&&A.delete(t),e??null}function Rt(t,e){e?H.add(t):H.delete(t)}function St(t){return H.has(t)}function Xt(t){const e=x.get(t);return void 0!==e&&e.isOpen&&!e.isMinimized&&!e.isHiddenWithParent}function Et(t){return x.has(t)}function Yt(){return{get modals(){return x},get pendingMinimize(){return t.get(M)},get pendingOpen(){return t.get(v)},get pendingClose(){return t.get(O)},get pendingRestore(){return t.get(C)},get dockOrder(){return t.get(R)}}}function qt(t){B.has(t)?B.delete(t):B.add(t);const e=x.get(t);e&&(x.set(t,{...e,isTransparent:B.has(t)}),w())}function Lt(t){B.delete(t);const e=x.get(t);e&&(x.set(t,{...e,isTransparent:!1}),w())}function Nt(t){t.animate([{transform:"translateX(0)"},{transform:"translateX(-6px)"},{transform:"translateX(6px)"},{transform:"translateX(-6px)"},{transform:"translateX(6px)"},{transform:"translateX(0)"}],{duration:300,easing:"ease-in-out"})}function _t(t){const e=W.get(t);if(!e)return;const n=x.get(t);n&&(x.set(t,{...n,isAnimatingPosition:!0,position:e}),W.delete(t),w())}function Gt(t){const e=x.get(t);e&&(x.set(t,{...e,isAnimatingPosition:!1}),w())}function Kt(t){return W.has(t)}function Vt(t){W.delete(t)}function $t(t){const e=re().parentChild.animationDuration;for(const[e,n]of t){const t=x.get(e);t&&x.set(e,{...t,position:n,isAnimatingPosition:!0,hasBeenDragged:!0})}w(),setTimeout(()=>{for(const e of t.keys()){const t=x.get(e);t&&x.set(e,{...t,isAnimatingPosition:!1})}w()},e)}function jt(t){const e=re();if("animated"!==e.parentChild.movementMode)return;const n=e.parentChild.animationDuration,i=[];let o=t;for(;;){const t=x.get(o);if(!(null==t?void 0:t.parentId))break;i.push({parentId:t.parentId,childId:o}),o=t.parentId}i.forEach(({parentId:t,childId:e},i)=>{setTimeout(()=>{const i=x.get(e),o=x.get(t);if(!(null==i?void 0:i.position)||!i.offsetFromParent||!o)return;const r={x:i.position.x-i.offsetFromParent.x,y:i.position.y-i.offsetFromParent.y};W.set(t,r),_t(t),setTimeout(()=>Gt(t),n)},i*n)})}function Qt(t){}function Jt(t){S=t}function Ut(t){X=t}function Zt(){return{modals:x,pendingMinimize:t.get(M),pendingOpen:t.get(v),pendingClose:t.get(O),pendingRestore:t.get(C),dockOrder:t.get(R),animatingModals:H,transparentModals:B}}function te(){x.clear(),t.get(M).length=0,t.get(v).length=0,t.get(O).length=0,t.get(P).length=0,t.get(C).length=0,t.get(D).length=0,t.set(T,null),A.clear(),t.set(F,null),W.clear(),H.clear(),B.clear(),t.get(R).length=0,S=null,X=null}const ee={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},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 ne={...ee},ie=t.state(0);function oe(){return t.get(ie)}function re(){return ne}function se(e){const n=ne;ne=ae(ee,e),t.update(ie),n.features.dock&&!ne.features.dock&&N()}function de(){ne={...ee},t.update(ie)}function ae(t,e){return{features:{...t.features,...e.features},dock:{...t.dock,...e.dock},animations:{...t.animations,...e.animations},appearance:{...t.appearance,...e.appearance},zIndex:{...t.zIndex,...e.zIndex},parentChild:{...t.parentChild,...e.parentChild},positioning:{...t.positioning,...e.positioning},portalTarget:e.portalTarget??t.portalTarget}}function ce(t){return ne.features[t]}export{Zt as _getInternalState,te as _resetInternalState,o as acquireModalZIndex,$t as animateModalsToPositions,_t as animateParentToPosition,$ as bringToFront,u as calculateOverlap,g as calculatePositionScore,p as calculateRearrangement,l as calculateTotalOverlap,Gt as clearParentAnimationFlag,Vt as clearPendingParentAnimation,tt as closeAllModals,Z as closeModal,c as constrainSizeToViewport,a as constrainToViewport,Bt as consumeOpenSourcePosition,kt as consumePendingAttention,Ct as consumePendingChildRestore,wt as consumePendingClose,Mt as consumePendingForceClose,ct as consumePendingMinimize,mt as consumePendingMinimizeTarget,It as consumePendingOpen,Wt as consumePendingParentLink,Ot as consumePendingRestore,U as createModal,ee as defaultConfig,At as endAttentionAnimation,et as finalizeModalClose,h as findSmartPosition,re as getConfig,oe as getConfigVersion,f as getElementBounds,r as getLayerZIndex,ft as getModalState,Yt as getModalsStore,nt as getModalsToClose,ht as getOpenModalBounds,gt as getOpenModalBoundsWithIds,Ft as getPendingParentLink,lt as getRegisteredModalIds,pt as getStateVersion,ut as hasAnyPendingMinimize,Dt as hasPendingAttention,Pt as hasPendingChildRestore,yt as hasPendingClose,zt as hasPendingForceClose,at as hasPendingMinimize,xt as hasPendingOpen,Kt as hasPendingParentAnimation,vt as hasPendingRestore,rt as hideChildWithParent,i as initializeStacking,ce as isFeatureEnabled,St as isModalAnimating,Xt as isModalOpen,Et as isModalRegistered,j as isTopModal,ot as linkModals,ae as mergeConfig,q as minimizeModal,it as openChildModal,J as openModal,E as registerModal,Q as reorderDock,de as resetConfig,Lt as resetModalTransparency,s as resetStacking,N as restoreAllMinimizedModals,_ as restoreChildModal,L as restoreModal,dt as setChildOffsetFromParent,se as setConfig,Ut as setDockPositionGetter,Rt as setModalAnimating,Qt as setRegistryFunctions,Jt as setURLStateCallbacks,Nt as shakeElement,Tt as startAttentionAnimation,Ht as storeOpenSourcePosition,z as subscribe,qt as toggleModalTransparency,bt as triggerAttention,jt as triggerCascadingParentAnimations,Y as unregisterModal,st as updateChildPosition,V as updateModal,G as updateModalPosition,K as updateModalSize};
|
package/dist/react/Dock.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
export interface DockProps {
|
|
3
3
|
/** Custom icon renderer - receives icon name, returns React element */
|
|
4
4
|
renderIcon?: (props: {
|
|
5
5
|
icon: string;
|
|
6
6
|
}) => ReactNode;
|
|
7
7
|
}
|
|
8
|
-
export declare function Dock({ renderIcon }: DockProps):
|
|
9
|
-
ref: React.RefObject<HTMLDivElement | null>;
|
|
10
|
-
'data-dock-bridge': boolean;
|
|
11
|
-
}, string | React.JSXElementConstructor<any>>;
|
|
8
|
+
export declare function Dock({ renderIcon }: DockProps): import("react/jsx-runtime").JSX.Element;
|
|
12
9
|
export default Dock;
|
|
13
10
|
//# sourceMappingURL=Dock.d.ts.map
|
package/dist/react/Modal.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { BaseModalProps } from '../core/types';
|
|
3
3
|
export interface ModalProps extends BaseModalProps {
|
|
4
4
|
children?: ReactNode;
|
|
5
5
|
footer?: ReactNode;
|
|
6
|
-
/** Custom icon as React element (overrides icon string if provided) */
|
|
7
|
-
customIcon?: ReactNode;
|
|
8
6
|
}
|
|
9
|
-
export declare function Modal({ id, title, icon,
|
|
7
|
+
export declare function Modal({ id, title, icon, maxWidth, preferredHeight, autoOpen, glow, config, closeOnEscape, onClose, children, footer, }: ModalProps): import("react/jsx-runtime").JSX.Element;
|
|
10
8
|
export default Modal;
|
|
11
9
|
//# sourceMappingURL=Modal.d.ts.map
|
package/dist/react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e,{createContext as t,useRef as i,useEffect as n,useCallback as o,useSyncExternalStore as r}from"react";import{onMount as d,getContext as s,setContext as a,tick as l,onDestroy as c,mount as g,unmount as u}from"svelte";import"svelte/internal/disclose-version";import*as h from"svelte/internal/client";import{scale as p,fly as f}from"svelte/transition";import{cubicOut as m,backOut as v}from"svelte/easing";const w={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},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 y={...w},x=h.state(0);function z(){return h.get(x)}function I(){return y}function b(e){const t=y;var i,n;y={features:{...(i=w).features,...(n=e).features},dock:{...i.dock,...n.dock},animations:{...i.animations,...n.animations},appearance:{...i.appearance,...n.appearance},zIndex:{...i.zIndex,...n.zIndex},parentChild:{...i.parentChild,...n.parentChild},positioning:{...i.positioning,...n.positioning},portalTarget:n.portalTarget??i.portalTarget},h.update(x),t.features.dock&&!y.features.dock&&(Array.from(E.values()).filter(e=>e.isMinimized).map(e=>e.id).forEach(e=>{const t=E.get(e);if(t){E.set(e,{...t,isMinimized:!1,isOpen:!0}),h.set(L,[...h.get(L),e],!0),oe(e);const i=t.lastChildId||t.childId;i&&te(i)}}),h.set(K,[],!0),T())}let M=h.state(h.proxy(400));const _=8;function k(e,t,i,n,o={}){const{margin:r=_,allowPartialVisibility:d=!1}=o,s="undefined"!=typeof window?window.innerWidth:1920,a="undefined"!=typeof window?window.innerHeight:1080;let l,c,g,u;return d&&i>s-2*r?(l=40-i,c=s-40):(l=r,c=Math.max(r,s-i-r)),d&&n>a-2*r?(g=40-n,u=a-40):(g=r,u=Math.max(r,a-n-r)),{x:Math.max(l,Math.min(c,e)),y:Math.max(g,Math.min(u,t))}}function C(e,t,i,n,o={}){const{margin:r=_}=o,d=("undefined"!=typeof window?window.innerWidth:1920)-2*r,s=("undefined"!=typeof window?window.innerHeight:1080)-2*r,a=Math.min(i,d),l=Math.min(n,s),c=k(e,t,a,l,o);return{x:c.x,y:c.y,width:a,height:l}}function P(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 D(e,t,i,n,o,r){const d={x:e-r,y:t-r,width:i+2*r,height:n+2*r};let s=0;for(const e of o)s+=P(d,e);return s}function B(e,t,i,n,o,r,d){const s=(o-i)/2,a=(r-n)/2,l=s-d,c=a-d,g=Math.abs(e-s)/(l||1),u=Math.abs(t-a)/(c||1),h=Math.sqrt(g*g+u*u)/Math.SQRT2,p=50,f=e-d,m=o-i-d-e,v=t-d,w=r-n-d-t;let y=0;return f<p&&(y+=.3*(1-f/p)),m<p&&(y+=.3*(1-m/p)),v<p&&(y+=.2*(1-v/p)),w<p&&(y+=.2*(1-w/p)),Math.min(1,h+y)}let E=h.proxy(new Map),R=h.state(0);const O=new Set;function T(){h.update(R),queueMicrotask(()=>{O.forEach(e=>e())})}function H(e){return O.add(e),()=>O.delete(e)}let S=h.state(h.proxy([])),W=h.state(h.proxy([])),F=h.state(h.proxy([])),$=h.state(h.proxy([])),L=h.state(h.proxy([])),X=h.state(h.proxy([])),A=h.state(h.proxy([])),Y=h.state(h.proxy([])),q=h.state(null),j=h.proxy(new Map),N=h.state(null),G=h.proxy(new Map),U=h.proxy(new Set),V=h.proxy(new Set),K=h.state(h.proxy([]));function Q(e){const t=E.get(e.id),i=(null==t?void 0:t.zIndex)??function(){const e=h.get(M);return h.set(M,h.get(M)+2),e}();t?E.set(e.id,{...t,title:e.title,icon:e.icon,glow:e.glow,zIndex:i}):E.set(e.id,{...e,zIndex:i,isAnimating:!1}),T(),e.isMinimized&&!h.get(K).includes(e.id)&&h.get(K).push(e.id)}function J(e){const t=E.get(e);if(t){if(h.set(K,h.get(K).filter(t=>t!==e),!0),t.childId){const e=E.get(t.childId);e&&E.set(t.childId,{...e,parentId:void 0})}if(t.parentId){const e=E.get(t.parentId);e&&E.set(t.parentId,{...e,childId:void 0,lastChildId:t.id})}E.delete(e),T(),V.delete(e),U.delete(e)}}function Z(e){const t=E.get(e);if(!t||t.isMinimized)return;if(ke(e),t.parentId){const e=E.get(t.parentId);if(e&&!e.isMinimized)return void Z(t.parentId)}h.set(S,[...h.get(S),e],!0),t.position&&t.size;const i=t.childId;E.set(e,{...t,isMinimized:!0,lastChildId:i}),T(),h.get(K).includes(e)||h.get(K).push(e),t.childId&&function(e){const t=E.get(e);if(!(null==t?void 0:t.childId))return;const i=E.get(t.childId);i&&(E.set(t.childId,{...i,isHiddenWithParent:!0}),T())}(e)}function ee(e){const t=E.get(e);if(!t||!t.isMinimized)return;E.set(e,{...t,isMinimized:!1,isOpen:!0}),T(),h.set(L,[...h.get(L),e],!0),oe(e);const i=t.lastChildId||t.childId;i&&te(i)}function te(e){const t=E.get(e);t&&t.isHiddenWithParent&&(E.set(e,{...t,isHiddenWithParent:!1}),T(),h.set(X,[...h.get(X),e],!0))}function ie(e,t,i){const n=E.get(e);if(!n)return;let o=t;if((null==i?void 0:i.constrain)&&n.size&&(o=k(t.x,t.y,n.size.width,n.size.height)),E.set(e,{...n,position:o,size:(null==i?void 0:i.size)??n.size,hasBeenDragged:n.hasBeenDragged||(null==i?void 0:i.drag)||!1}),n.childId){let t=e,i=o;for(;;){const e=E.get(t);if(!(null==e?void 0:e.childId))break;const n=E.get(e.childId);if(!(null==n?void 0:n.offsetFromParent))break;const o={x:i.x+n.offsetFromParent.x,y:i.y+n.offsetFromParent.y};E.set(e.childId,{...n,position:o,hasBeenDragged:!0}),t=e.childId,i=o}}if(n.parentId&&n.offsetFromParent){const t=I();let i=e,r=n;for(;r.parentId&&r.offsetFromParent;){const n=E.get(r.parentId);if(!n)break;const d=i===e?o:E.get(i).position,s={x:d.x-r.offsetFromParent.x,y:d.y-r.offsetFromParent.y};"animated"===t.parentChild.movementMode?G.set(r.parentId,s):E.set(r.parentId,{...n,position:s,hasBeenDragged:!0}),i=r.parentId,r=n}}T()}function ne(e,t){const i=E.get(e);i&&(E.set(e,{...i,...t}),T())}function oe(e){var t;const i=E.get(e);if(!i)return;const n=Math.max(...Array.from(E.values()).map(e=>e.zIndex),0);if(i.parentId){const o=E.get(i.parentId);o&&o.zIndex<n&&E.set(i.parentId,{...o,zIndex:n+2});const r=(null==(t=E.get(i.parentId))?void 0:t.zIndex)??n+2;return i.zIndex<=r&&E.set(e,{...i,zIndex:r+2}),void T()}if(i.zIndex<n&&(E.set(e,{...i,zIndex:n+2}),T()),i.childId){const t=E.get(i.childId),n=E.get(e);t&&n&&t.zIndex<=n.zIndex&&(E.set(i.childId,{...t,zIndex:n.zIndex+2}),T())}}function re(e){const t=E.get(e);if(!t)return!1;const i=Math.max(...Array.from(E.values()).map(e=>e.zIndex),0);return t.zIndex===i&&!t.isMinimized&&!t.isHiddenWithParent}function de(e){h.set(K,e,!0)}function se(e,t,i){const n=t.getBoundingClientRect();j.set(e,{x:n.left+n.width/2,y:n.top+n.height/2});const o=I();(null==i?void 0:i.parentId)&&o.features.parentChild&&h.set(N,{parentId:i.parentId,childId:e},!0),h.get(W).includes(e)||h.set(W,[...h.get(W),e],!0),T();const r=E.get(e);if(r){if(r.isOpen&&!r.isMinimized&&!r.isHiddenWithParent)return h.set(W,h.get(W).filter(t=>t!==e),!0),xe(e),void oe(e);if(r.isMinimized)return h.set(W,h.get(W).filter(t=>t!==e),!0),void ee(e);E.set(e,{...r,isOpen:!0}),oe(e)}}function ae(e,t=!1){const i=E.get(e);i&&(ke(e),t?h.set($,[...h.get($),e],!0):h.set(F,[...h.get(F),e],!0),T(),i.childId&&ae(i.childId,t))}function le(){Array.from(E.keys()).forEach(e=>ae(e,!0))}function ce(e,t,i){const n=I();if(i&&!j.has(e.id)){const t=i.getBoundingClientRect();j.set(e.id,{x:t.left+t.width/2,y:t.top+t.height/2})}const o={id:e.id,title:e.title??"",icon:e.icon??"",isOpen:!0,isMinimized:!1,isHiddenWithParent:!1,isTransparent:e.isTransparent??!1,isRejected:!1,position:e.position??null,size:e.size??null,hasBeenDragged:e.hasBeenDragged??!1,dockPosition:e.dockPosition??-1,glow:e.glow??null};if(!n.features.parentChild){Q(o);const t=E.get(e.id);return t&&E.set(e.id,{...t,isOpen:!0}),h.set(W,[...h.get(W),e.id],!0),T(),void oe(e.id)}const r=E.get(t);if(!r)return;r.childId&&ae(r.childId,!0),Q({...o,parentId:t});const d=E.get(e.id);d&&E.set(e.id,{...d,isOpen:!0,parentId:t}),h.set(W,[...h.get(W),e.id],!0),T(),oe(e.id),h.set(N,{parentId:t,childId:e.id},!0)}function ge(e){return h.get(S).includes(e)}function ue(e){return E.get(e)}function he(){return h.get(R)}function pe(e){return h.get(W).includes(e)}function fe(e){return h.get(F).includes(e)}function me(e){return h.get($).includes(e)}function ve(e){return!!h.get($).includes(e)&&(h.set($,h.get($).filter(t=>t!==e),!0),!0)}function we(e){return h.get(L).includes(e)}function ye(e){return h.get(X).includes(e)}function xe(e){E.get(e)&&(h.get(A).includes(e)||h.get(Y).includes(e)||(h.set(A,[...h.get(A),e],!0),T()))}function ze(e){const t=E.get(e);return void 0!==t&&t.isOpen&&!t.isMinimized&&!t.isHiddenWithParent}function Ie(e){return E.has(e)}function be(){return{get modals(){return E},get pendingMinimize(){return h.get(S)},get pendingOpen(){return h.get(W)},get pendingClose(){return h.get(F)},get pendingRestore(){return h.get(L)},get dockOrder(){return h.get(K)}}}function Me(e){V.has(e)?V.delete(e):V.add(e);const t=E.get(e);t&&(E.set(e,{...t,isTransparent:V.has(e)}),T())}function _e(e){V.delete(e);const t=E.get(e);t&&(E.set(e,{...t,isTransparent:!1}),T())}function ke(e){G.delete(e)}const Ce=Symbol("modal-render-icon"),Pe=Symbol("modal-id");function De(){return I().features.animations}const Be=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function Ee(e){return Array.from(e.querySelectorAll(Be)).filter(e=>null!==e.offsetParent||"A"===e.tagName)}function Re(e,t){if("Tab"!==e.key)return;const i=Ee(t);if(0===i.length)return void e.preventDefault();const n=i[0],o=i[i.length-1],r=document.activeElement;e.shiftKey?r===n&&(o.focus(),e.preventDefault()):r===o&&(n.focus(),e.preventDefault())}function Oe(e){const t=Ee(e);return t.length>0&&(t[0].focus(),!0)}const Te="modal-portal";var He=h.from_html('<div style="display: contents;"><!></div>');function Se(e,t){h.push(t,!0);let i=h.prop(t,"target",3,"body"),n=null,o=null;const{mount:r}={mount:function(e,t=null){const i=function(e){if("undefined"==typeof window)return null;if(e instanceof HTMLElement)return e;if("string"==typeof e){const t=document.querySelector(e);if(t)return t;if(e.startsWith("#")){const t=e.slice(1),i=document.createElement("div");return i.id=t,document.body.appendChild(i),i}}let t=document.getElementById(Te);return t||(t=document.createElement("div"),t.id=Te,document.body.appendChild(t)),t}(t);return i?(i.appendChild(e),()=>{e.parentNode===i&&i.removeChild(e),i.id!==Te&&0===i.children.length&&i.parentNode&&i.parentNode.removeChild(i)}):()=>{}}};d(()=>(n&&(o=r(n,i())),()=>{null==o||o()}));var s=He(),a=h.child(s);h.snippet(a,()=>t.children),h.reset(s),h.bind_this(s,e=>n=e,()=>n),h.append(e,s),h.pop()}var We=h.from_html('<button type="button" aria-label="Minimize"></button>'),Fe=h.from_html('<button type="button" class="modal-header-light modal-header-light-style" aria-label="Toggle style"></button>'),$e=h.from_html('<div class="modal-header-icon"><!></div>'),Le=h.from_html('<div class="modal-header-icon"><!></div>'),Xe=h.from_html('<h2 class="modal-header-title"> </h2>'),Ae=h.from_html('<h2 class="modal-header-title"> </h2>'),Ye=h.from_html('<div class="modal-header-traffic-lights"><button type="button" class="modal-header-light modal-header-light-close" aria-label="Close"></button> <!> <!></div> <div class="modal-header-mac-center"><!> <div class="modal-header-title-group"><!></div></div> <div class="modal-header-mac-spacer"></div>',1),qe=h.from_html('<div class="modal-header-icon"><!></div>'),je=h.from_html('<div class="modal-header-icon"><!></div>'),Ne=h.from_html('<h2 class="modal-header-title"> </h2>'),Ge=h.from_html('<h2 class="modal-header-title"> </h2>'),Ue=h.from_html('<button type="button" class="modal-header-btn-windows modal-header-btn-windows-style" aria-label="Toggle style">◇</button>'),Ve=h.from_html('<button type="button" aria-label="Minimize">–</button>'),Ke=h.from_html('<div class="modal-header-title-group"><!> <!></div> <div class="modal-header-actions"><!> <!> <button type="button" class="modal-header-btn-windows modal-header-btn-windows-close" aria-label="Close">×</button></div>',1),Qe=h.from_html("<header><!></header>");h.delegate(["pointerdown","click"]);var Je=h.from_html("<div></div>"),Ze=h.from_html('<div class="modal-resize-handles"></div>');h.delegate(["pointerdown"]);var et=h.from_html('<div class="modal-footer"><!></div>'),tt=h.from_html("<div></div>"),it=h.from_html('<div role="dialog" aria-modal="true" tabindex="-1"><!> <div class="modal-body"><!></div> <!> <!> <!></div>');function nt(e,t){h.push(t,!0);let i=h.prop(t,"maxWidth",3,"600px"),n=h.prop(t,"autoOpen",3,!1),o=h.prop(t,"closeOnEscape",3,!0),r=h.state(!1);d(()=>{Q({id:t.id,title:t.title,icon:t.icon??"",isOpen:n(),isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,isRejected:!1,position:null,size:null,hasBeenDragged:!1,dockPosition:0,glow:t.glow??null,parentId:void 0,childId:void 0,offsetFromParent:void 0}),h.set(r,!0)}),c(()=>{J(t.id)});const g=h.derived(()=>{if(!h.get(r))return!1;he();const e=ue(t.id);return!!e&&(e.isOpen||e.isMinimized||pe(t.id)||fe(t.id)||ge(t.id))});var u=h.comment(),p=h.first_child(u),f=e=>{!function(e,t){h.push(t,!0);let i=h.prop(t,"maxWidth",3,"600px"),n=h.prop(t,"autoOpen",3,!1),o=h.prop(t,"closeOnEscape",3,!0),r=h.prop(t,"skipRegistration",3,!1);a(Pe,t.id);const g=I().portalTarget;function u(e){var i,n;return(null==(n=null==(i=t.config)?void 0:i.features)?void 0:n[e])??function(e){return y.features[e]}(e)}const p=h.derived(()=>(z(),u("drag"))),f=h.derived(()=>(z(),u("minimize"))),m=h.derived(()=>(z(),!u("dock"))),v=h.derived(()=>(z(),u("transparency"))),w=h.derived(()=>(z(),u("resize"))),x=h.derived(()=>{var e,i;return z(),(null==(i=null==(e=t.config)?void 0:e.appearance)?void 0:i.headerLayout)??I().appearance.headerLayout});let b=h.state(null),M=h.state(!1),_=h.state(!1),P=h.state(!1),R=h.state(!1),O=h.state(!1);const H=h.derived(()=>(he(),ue(t.id))),$=h.derived(()=>h.get(H)&&(h.get(H).isOpen||fe(t.id))&&(!h.get(H).isMinimized||ge(t.id))&&!h.get(H).isHiddenWithParent),U=h.derived(()=>{var e;return!!(null==(e=h.get(H))?void 0:e.childId)}),V=h.derived(()=>{var e;return!!(null==(e=h.get(H))?void 0:e.parentId)}),K=h.derived(()=>h.get(U)||h.get(_)),ee=h.derived(()=>!!t.glow),te=h.derived(()=>`modal-title-${t.id}`),de=h.derived(()=>{var e;return(null==(e=h.get(H))?void 0:e.zIndex)??1e3}),se=function(e={x:0,y:0}){const t=h.proxy({...e}),i=h.proxy({isDragging:!1,startX:0,startY:0,initialX:0,initialY:0,hasBeenDragged:!1});return{get position(){return t},get hasBeenDragged(){return i.hasBeenDragged},get isDragging(){return i.isDragging},onPointerDown:function(e,n){if(0===e.button){if(!i.hasBeenDragged){const e=n.getBoundingClientRect();t.x=e.left,t.y=e.top}i.isDragging=!0,i.startX=e.clientX,i.startY=e.clientY,i.initialX=t.x,i.initialY=t.y,n.setPointerCapture(e.pointerId)}},onPointerMove:function(e,n,o){if(!i.isDragging)return;const r=e.clientX-i.startX,d=e.clientY-i.startY,s=k(i.initialX+r,i.initialY+d,o.width,o.height);t.x=s.x,t.y=s.y,i.hasBeenDragged=!0},onPointerUp:function(e,t){i.isDragging&&(i.isDragging=!1,t.releasePointerCapture(e.pointerId))},setPosition:function(e){t.x=e.x,t.y=e.y},setHasBeenDragged:function(e){i.hasBeenDragged=e},reset:function(){t.x=e.x,t.y=e.y,i.hasBeenDragged=!1}}}({x:0,y:0});let le=h.state(!1);const ce=function(e,i,n){let o=h.state(!1),r=h.state(""),d=h.state(h.proxy({width:0,height:0})),s=h.state(!1),a=h.state(!1),l={x:0,y:0,width:0,height:0,posX:0,posY:0},c=null;function g(t,a){t.preventDefault(),t.stopPropagation();const g=e();if(!g)return;const f=g.getBoundingClientRect();se.hasBeenDragged||(n({x:f.left,y:f.top}),se.setHasBeenDragged(!0)),h.get(s)||(h.set(d,{width:f.width,height:f.height},!0),h.set(s,!0));const m=i();h.set(o,!0),h.set(r,a,!0),c=t.pointerId,l={x:t.clientX,y:t.clientY,width:h.get(d).width,height:h.get(d).height,posX:m.x,posY:m.y,centerX:m.x+h.get(d).width/2,centerY:m.y+h.get(d).height/2},window.addEventListener("pointermove",u),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p)}function u(e){if(e.pointerId!==c)return;const t=e.clientX-l.x,i=e.clientY-l.y,o=window.innerWidth,s=window.innerHeight;let a=l.width,g=l.height,u=l.posX,p=l.posY;if(h.get(r).includes("e")){const e=o-u;a=Math.max(280,Math.min(l.width+t,e))}if(h.get(r).includes("w")){const e=l.width-280,i=Math.min(t,e);a=l.width-i,u=l.posX+i}if(h.get(r).includes("s")){const e=s-p;g=Math.max(200,Math.min(l.height+i,e))}if(h.get(r).includes("n")){const e=l.height-200,t=Math.min(i,e);g=l.height-t,p=l.posY+t}const f=C(u,p,a,g);h.set(d,{width:f.width,height:f.height},!0),n({x:f.x,y:f.y})}function p(e){e.pointerId===c&&(h.set(o,!1),c=null,window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),h.set(a,!0),((e,i)=>{const n=ue(t.id);if(null==n?void 0:n.parentId){const e=ue(n.parentId),o=document.querySelector(`[data-modal-id="${n.parentId}"]`);if(e&&o){const n=e.position??{x:o.getBoundingClientRect().left,y:o.getBoundingClientRect().top},r=e.size??{width:o.offsetWidth,height:o.offsetHeight},d={x:n.x+(r.width-i.width)/2,y:n.y+(r.height-i.height)/2};h.set(le,!0),se.setPosition(d);const s={x:d.x-n.x,y:d.y-n.y};return ne(t.id,{position:d,size:i,hasBeenDragged:!0,offsetFromParent:s}),void setTimeout(()=>{h.set(le,!1)},200)}}ne(t.id,{position:e,size:i,hasBeenDragged:!0})})(i(),h.get(d)),setTimeout(()=>{h.set(a,!1)},0))}const f={startResize:g};return{get isResizing(){return h.get(o)},get resizeDirection(){return h.get(r)},get size(){return h.get(d)},get hasBeenResized(){return h.get(s)},get isActive(){return h.get(o)},get justFinishedResizing(){return h.get(a)},start:g,setHasBeenResized:()=>{},setSize:function(e){h.set(d,e,!0),h.set(s,!0)},reset:function(){h.set(s,!1),h.set(d,{width:0,height:0},!0)},constrainToViewport:function(){const t=i(),o=e();if(!o)return;const r=C(t.x,t.y,h.get(d).width||o.offsetWidth,h.get(d).height||o.offsetHeight);h.set(d,{width:r.width,height:r.height},!0),n({x:r.x,y:r.y})},handlers:f}}(()=>h.get(b),()=>se.position,e=>se.setPosition(e)),xe=function(e,i,n,o,r,d,s,a,l){let c=h.state(!1),g=h.state(!1),u=h.state(!1),p=h.state(!1),f=h.state(null),m=h.state(null),v=null,w=null;function y(){w&&(clearTimeout(w),w=null)}function x(){const e=t.id,i=document.querySelector(`.modal-dock-item[data-modal-id="${e}"]`),n=document.querySelector('[data-dock-container="true"]'),o=i||n;if(o){const e=o.getBoundingClientRect();return{x:e.left+e.width/2,y:e.top+e.height/2}}return{x:window.innerWidth/2,y:window.innerHeight-40}}return h.user_effect(()=>()=>{y(),h.set(c,!1),h.set(g,!1),h.set(u,!1),h.set(p,!1),h.set(f,null),h.set(m,null),v=null}),{get isMinimizing(){return h.get(c)},get isRestoring(){return h.get(g)},get isOpening(){return h.get(u)},get isClosing(){return h.get(p)},get animationTransform(){return h.get(f)},get pendingOpenSource(){return h.get(m)},startMinimize:function(e,t){const p=i();if(h.get(c)||!p)return;if(h.set(g,!1),h.set(u,!1),y(),!De()){const e=p.getBoundingClientRect();let i=r()?n():{x:e.left,y:e.top},c=s()?a():{width:e.width,height:e.height};return r()||(o(i),d(!0)),void(t?t():l(i,!0,c))}const m=p.getBoundingClientRect(),v=m.left+m.width/2,z=m.top+m.height/2;let I=r()?n():{x:m.left,y:m.top},b=s()?a():{width:m.width,height:m.height};r()||(o(I),d(!0));const M=e??x(),_=M.x-m.left,k=M.y-m.top,C={x:M.x-v,y:M.y-z,originX:_,originY:k};h.set(f,C,!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{h.set(c,!0)})}),w=setTimeout(()=>{t?t():l(I,!0,b)},500)},startRestore:function(e,t){if(!De()){const t=e||{x:window.innerWidth/2,y:window.innerHeight/2};return o(t),void d(!0)}const i=x(),n=e||{x:window.innerWidth/2,y:window.innerHeight/2},r=t||{width:480,height:400};o(n),d(!0);const s=n.x+r.width/2,a=n.y+r.height/2,l=i.x-n.x,c=i.y-n.y;h.set(f,{x:i.x-s,y:i.y-a,originX:l,originY:c},!0),h.set(g,!0),setTimeout(()=>{h.set(g,!1),h.set(f,null)},400)},startClose:function(e){h.get(p)||h.get(c)||(De()?(v=e,h.set(p,!0),setTimeout(()=>{h.set(p,!1),v&&(v(),v=null)},250)):e())},setPendingOpenSource:function(e){h.set(m,e,!0)},tryStartOpenAnimation:function(){const e=i();if(!h.get(m)||!e||h.get(u))return!1;if(!De())return h.set(m,null),!1;const t=h.get(m);h.set(m,null);const s=e.getBoundingClientRect(),a=r()?n():{x:s.left,y:s.top},l=s.width,c=s.height,g=a.x+l/2,p=a.y+c/2;r()||(o(a),d(!0));const v=t.x-a.x,w=t.y-a.y;return h.set(f,{x:t.x-g,y:t.y-p,originX:v,originY:w},!0),h.set(u,!0),setTimeout(()=>{h.set(u,!1),h.set(f,null)},400),!0},forceClearMinimize:function(){y(),h.set(c,!1),h.set(f,null)}}}(0,()=>h.get(b),()=>se.position,e=>se.setPosition(e),()=>se.hasBeenDragged,e=>se.setHasBeenDragged(e),()=>ce.hasBeenResized,()=>ce.size,(e,i,n)=>{ne(t.id,{position:e,size:n,hasBeenDragged:i}),Z(t.id)}),{trapFocus:ze,focusFirstElement:Ie}={trapFocus:Re,focusFirstElement:Oe},be=h.derived(()=>xe.isMinimizing||xe.isRestoring||xe.isOpening||xe.isClosing),ke=h.derived(()=>(ye(t.id)||we(t.id))&&!xe.isRestoring);let Be=h.state(!1);const Ee=h.derived(()=>xe.isRestoring||xe.isOpening||h.get(Be)),Te=h.derived(()=>h.get($)&&!se.hasBeenDragged&&!h.get(be)&&!xe.pendingOpenSource&&!h.get(ke)),He=h.derived(()=>{const e=[];return e.push(`z-index: ${h.get(de)};`),xe.animationTransform?(e.push(`left: ${se.position.x}px; top: ${se.position.y}px;`),e.push(`--genie-origin-x: ${xe.animationTransform.originX}px;`),e.push(`--genie-origin-y: ${xe.animationTransform.originY}px;`),e.push(`--genie-translate-x: ${xe.animationTransform.x}px;`),e.push(`--genie-translate-y: ${xe.animationTransform.y}px;`)):se.hasBeenDragged&&e.push(`left: ${se.position.x}px; top: ${se.position.y}px; transform: none;`),ce.hasBeenResized?e.push(`width: ${ce.size.width}px; height: ${ce.size.height}px; max-width: none; max-height: none;`):(t.preferredHeight&&e.push(`min-height: ${t.preferredHeight};`),i()&&e.push(`max-width: ${i()};`)),h.get(ee)&&t.glow&&(e.push(`--modal-glow-color: ${t.glow.color};`),e.push(`--modal-glow-intensity: ${t.glow.intensity};`)),e.join(" ")});function nt(){h.get(f)&&Z(t.id)}function ot(){var e;me(t.id)&&ve(t.id),ae(t.id),null==(e=t.onClose)||e.call(t)}function rt(){Me(t.id)}function dt(e){h.get(p)&&h.get(b)&&se.onPointerDown(e,h.get(b))}function st(e){o()&&"Escape"===e.key&&re(t.id)&&(e.stopPropagation(),ot())}function at(e){if(!h.get(b))return;const i=se.isDragging,n=ce.hasBeenResized?ce.size:{width:h.get(b).offsetWidth,height:h.get(b).offsetHeight};se.onPointerMove(e,h.get(b),n),se.isDragging&&i&&ie(t.id,se.position,{drag:!0})}function lt(e){if(!h.get(b))return;const i=se.isDragging;se.onPointerUp(e,h.get(b)),i&&!ce.justFinishedResizing&&(ie(t.id,se.position,{drag:!0}),function(e){const t=I();if("animated"!==t.parentChild.movementMode)return;const i=t.parentChild.animationDuration,n=[];let o=e;for(;;){const e=E.get(o);if(!(null==e?void 0:e.parentId))break;n.push({parentId:e.parentId,childId:o}),o=e.parentId}n.forEach(({parentId:e,childId:t},n)=>{setTimeout(()=>{const n=E.get(t),o=E.get(e);if(!(null==n?void 0:n.position)||!n.offsetFromParent||!o)return;const r={x:n.position.x-n.offsetFromParent.x,y:n.position.y-n.offsetFromParent.y};G.set(e,r),function(e){const t=G.get(e);if(!t)return;const i=E.get(e);i&&(E.set(e,{...i,isAnimatingPosition:!0,position:t}),G.delete(e),T())}(e),setTimeout(()=>function(e){const t=E.get(e);t&&(E.set(e,{...t,isAnimatingPosition:!1}),T())}(e),i)},n*i)})}(t.id))}function ct(){var e;const i=I();if("smart"!==(null==(e=i.positioning)?void 0:e.strategy))return!1;const n=ue(t.id);if(null==n?void 0:n.parentId)return!1;if((null==n?void 0:n.hasBeenDragged)||(null==n?void 0:n.position))return!1;const o=h.get(b)||document.querySelector(`[data-modal-id="${t.id}"]`);if(!o)return!1;const r=o.offsetWidth,d=o.offsetHeight;if(r<=0||d<=0)return!1;const s=i.positioning.modalGap??16,a=function(e){const t=[];for(const[i,n]of E.entries())if(i!==e&&n.isOpen&&!n.isMinimized&&!n.isHiddenWithParent)if(n.position&&n.size)t.push({x:n.position.x,y:n.position.y,width:n.size.width,height:n.size.height});else{const e=document.querySelector(`[data-modal-id="${String(i)}"]`);if(e){const i=e.getBoundingClientRect();t.push({x:i.left,y:i.top,width:i.width,height:i.height})}}return t}(t.id),l=function(e){if("undefined"==typeof document)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}(i.positioning.avoidElements??[]),c=function(e,t,i,n={}){const{modalGap:o=16,gridResolution:r=10,avoidBounds:d=[],avoidMargin:s=16}=n,a=n.margin??o,l="undefined"!=typeof window?window.innerWidth:1920,c="undefined"!=typeof window?window.innerHeight:1080,g=d.map(e=>({x:e.x-s,y:e.y-s,width:e.width+2*s,height:e.height+2*s})),u={x:(l-e)/2,y:(c-t)/2};if(0===i.length&&0===g.length)return u;const h=a,p=Math.max(a,l-e-a),f=a,m=Math.max(a,c-t-a);if(p<=h||m<=f)return u;const v=D(u.x,u.y,e,t,i,o),w=D(u.x,u.y,e,t,g,0);if(0===v&&0===w)return u;const y=[],x=(p-h)/r,z=(m-f)/r;for(let n=0;n<=r;n++)for(let d=0;d<=r;d++){const r=h+n*x,s=f+d*z,u=D(r,s,e,t,i,o),p=D(r,s,e,t,g,0),m=B(r,s,e,t,l,c,a);y.push({pos:{x:r,y:s},modalOverlap:u,avoidOverlap:p,centerDist:m})}const I=y.filter(e=>0===e.avoidOverlap),b=I.length>0?I:y,M=e*t,_=Math.min(...b.map(e=>e.modalOverlap))/M;return b.sort((e,t)=>{if(0===I.length&&e.avoidOverlap!==t.avoidOverlap)return e.avoidOverlap-t.avoidOverlap;const i=e.modalOverlap/M,n=t.modalOverlap/M;if(_<.3){const o=.3,r=i<=o,d=n<=o;if(r&&d)return e.centerDist+.3*i-(t.centerDist+.3*n);if(r)return-1;if(d)return 1}return.6*i+.4*e.centerDist-(.6*n+.4*t.centerDist)}),b[0].pos}(r,d,a,{modalGap:s,avoidBounds:l});if(D(c.x,c.y,r,d,a,s)/(r*d)>.1&&a.length>0){const e=function(e){const t=[];for(const[i,n]of E.entries())if(i!==e&&n.isOpen&&!n.isMinimized&&!n.isHiddenWithParent&&!n.parentId)if(n.position&&n.size)t.push({id:String(i),x:n.position.x,y:n.position.y,width:n.size.width,height:n.size.height});else{const e=document.querySelector(`[data-modal-id="${String(i)}"]`);if(e){const n=e.getBoundingClientRect();t.push({id:String(i),x:n.left,y:n.top,width:n.width,height:n.height})}}return t}(t.id),i=function(e,t,i,n={}){const{modalGap:o=16}=n,r=n.margin??o,d="undefined"!=typeof window?window.innerWidth:1920,s="undefined"!=typeof window?window.innerHeight:1080,a=i.reduce((e,t)=>e+t.width,0)+e,l=i.length*o,c=d-2*r;if(a+l>c)return null;const g=c-a-l;i.length;const u=g/2,h=d/2,p=[...i.map(e=>({id:e.id,width:e.width,height:e.height,currentX:e.x+e.width/2,currentY:e.y,isNew:!1})),{id:"__new__",width:e,height:t,currentX:h,currentY:(s-t)/2,isNew:!0}];p.sort((e,t)=>e.currentX-t.currentX);let f=r+u;const m=new Map;let v=null;for(const e of p){const t=f;if(e.isNew)v={x:Math.round(t),y:Math.round(e.currentY)};else{const n=i.find(t=>t.id===e.id);Math.abs(t-n.x)>5&&m.set(e.id,{x:Math.round(t),y:Math.round(n.y)})}f+=e.width+o}return v?{newModalPosition:v,existingModalMoves:m}:null}(r,d,e,{modalGap:s});if(i&&i.existingModalMoves.size>0)return function(e){const t=I().parentChild.animationDuration;for(const[t,i]of e){const e=E.get(t);e&&E.set(t,{...e,position:i,isAnimatingPosition:!0,hasBeenDragged:!0})}T(),setTimeout(()=>{for(const t of e.keys()){const e=E.get(t);e&&E.set(t,{...e,isAnimatingPosition:!1})}T()},t)}(i.existingModalMoves),se.setPosition(i.newModalPosition),se.setHasBeenDragged(!0),ie(t.id,i.newModalPosition,{size:{width:r,height:d}}),!0}return se.setPosition(c),se.setHasBeenDragged(!0),ie(t.id,c,{size:{width:r,height:d}}),!0}function gt(){l().then(()=>l()).then(()=>{let e=0;const t=()=>{e+=1,ct()||e>5||requestAnimationFrame(t)};h.get(b)?t():requestAnimationFrame(t)})}d(()=>{var e;function i(){const e=ue(t.id);if(!(null==e?void 0:e.position)||!h.get(b))return;if(e.parentId)return;const i=ce.hasBeenResized?ce.size.width:h.get(b).offsetWidth,n=ce.hasBeenResized?ce.size.height:h.get(b).offsetHeight;if(i<=0||n<=0)return;const o=k(e.position.x,e.position.y,i,n);(Math.abs(o.x-e.position.x)>1||Math.abs(o.y-e.position.y)>1)&&(se.setPosition(o),ie(t.id,o))}return r()||(e=n(),Q({id:t.id,title:t.title,icon:t.icon??"",isOpen:e,isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,isRejected:!1,position:null,size:null,hasBeenDragged:!1,dockPosition:0,glow:t.glow??null,parentId:void 0,childId:void 0,offsetFromParent:void 0}),e&&oe(t.id)),n()&&(l().then(()=>{h.get(b)&&Ie(h.get(b))}),gt()),window.addEventListener("pointermove",at),window.addEventListener("pointerup",lt),window.addEventListener("resize",i),()=>{window.removeEventListener("pointermove",at),window.removeEventListener("pointerup",lt),window.removeEventListener("resize",i)}}),c(()=>{_e(t.id),r()||J(t.id)}),h.user_effect(()=>{he();const e=ue(t.id);if(e){if(h.set(M,e.isTransparent,!0),!se.isDragging&&!ce.isResizing&&e.position){const t=se.position,i=e.position;(Math.abs(t.x-i.x)>.5||Math.abs(t.y-i.y)>.5)&&(se.setPosition(i),e.hasBeenDragged&&se.setHasBeenDragged(!0))}l().then(()=>function(){var e,i;if(!ue(t.id))return;if(me(t.id))return ve(t.id),void(null==(e=t.onClose)||e.call(t));if(ge(t.id)&&!h.get(R)){if(h.set(R,!0),h.get(q),h.set(q,null),h.get(b)){const e=h.get(b).getBoundingClientRect(),i=se.hasBeenDragged?se.position:{x:e.left,y:e.top},n=ce.hasBeenResized?ce.size:{width:e.width,height:e.height};ne(t.id,{position:i,size:n,hasBeenDragged:!0})}xe.startMinimize(void 0,()=>{var e;e=t.id,h.get(S).includes(e)&&h.set(S,h.get(S).filter(t=>t!==e),!0),h.set(R,!1)})}if(we(t.id)){i=t.id,h.get(L).includes(i)&&h.set(L,h.get(L).filter(e=>e!==i),!0);const e=ue(t.id);xe.startRestore((null==e?void 0:e.position)??void 0,(null==e?void 0:e.size)??void 0),l().then(()=>{h.get(b)&&Ie(h.get(b))})}if(ye(t.id)){!function(e){h.get(X).includes(e)&&h.set(X,h.get(X).filter(t=>t!==e),!0)}(t.id);const e=ue(t.id);xe.startRestore((null==e?void 0:e.position)??void 0,(null==e?void 0:e.size)??void 0)}if(fe(t.id)&&(function(e){h.get(F).includes(e)&&h.set(F,h.get(F).filter(t=>t!==e),!0)}(t.id),xe.startClose(()=>{var e;_e(t.id),function(e){const t=E.get(e);if(t){if(t.parentId){const i=E.get(t.parentId);i&&i.childId===e&&E.set(t.parentId,{...i,childId:void 0,lastChildId:e})}E.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}),T()}}(t.id),null==(e=t.onClose)||e.call(t)})),pe(t.id)){!function(e){h.get(W).includes(e)&&h.set(W,h.get(W).filter(t=>t!==e),!0)}(t.id);const e=function(e){const t=j.get(e);return t&&j.delete(e),t??null}(t.id)||t.openSourcePosition||null;e?(xe.setPendingOpenSource(e),l().then(()=>l()).then(()=>{ct(),xe.tryStartOpenAnimation()})):gt(),l().then(()=>{h.get(b)&&Ie(h.get(b))})}(function(e){return h.get(A).includes(e)})(t.id)&&(function(e){h.get(A).includes(e)&&h.set(A,h.get(A).filter(t=>t!==e),!0)}(t.id),function(e){h.get(Y).includes(e)||h.set(Y,[...h.get(Y),e],!0)}(t.id),h.set(O,!0),setTimeout(()=>{h.set(O,!1),function(e){h.set(Y,h.get(Y).filter(t=>t!==e),!0)}(t.id)},600));const n=function(e){if(!h.get(N)||h.get(N).childId!==e)return null;const t=h.get(N);return h.set(N,null),t}(t.id);var o;n&&h.get(b)&&(o=n.parentId,l().then(()=>l()).then(()=>{let e=0;const i=()=>{e+=1;const n=function(e){var i,n;const o=ue(e);if(!o)return!1;const r=h.get(b)||document.querySelector(`[data-modal-id="${t.id}"]`),d=document.querySelector(`[data-modal-id="${e}"]`),s=null==d?void 0:d.getBoundingClientRect(),a=o.position??(s?{x:s.left,y:s.top}:null);if(!a||!r)return!1;const l=(null==(i=o.size)?void 0:i.width)??(null==d?void 0:d.offsetWidth)??(null==s?void 0:s.width)??480,c=(null==(n=o.size)?void 0:n.height)??(null==d?void 0:d.offsetHeight)??(null==s?void 0:s.height)??400,g=r.offsetWidth,u=r.offsetHeight;if(l<=0||c<=0||g<=0||u<=0)return!1;const p={x:a.x+(l-g)/2,y:a.y+(c-u)/2};return se.setPosition(p),se.setHasBeenDragged(!0),ie(t.id,p,{size:{width:g,height:u}}),o.position&&o.size||!s||ie(e,{x:s.left,y:s.top},{size:{width:l,height:c}}),function(e,t){if(!I().features.parentChild)return;const i=E.get(e),n=E.get(t);if(!i||!n)return;let o={x:40,y:40};i.position&&n.position&&(o={x:n.position.x-i.position.x,y:n.position.y-i.position.y});const r=Math.max(n.zIndex,i.zIndex+1);E.set(e,{...i,childId:t,lastChildId:t}),E.set(t,{...n,parentId:e,offsetFromParent:o,zIndex:r}),T()}(e,t.id),!0}(o);n||e>5||requestAnimationFrame(i)};h.get(b)?i():requestAnimationFrame(i)}))}())}}),h.user_effect(()=>{const e=ue(t.id);e&&e.isTransparent!==h.get(M)&&h.set(M,e.isTransparent,!0)}),h.user_effect(()=>{if(h.get($)&&h.get(b)){const e=e=>function(e){h.get(b)&&ze(e,h.get(b))}(e);return h.get(b).addEventListener("keydown",e),()=>{var t;return null==(t=h.get(b))?void 0:t.removeEventListener("keydown",e)}}}),h.user_effect(()=>{!h.get($)&&xe.isMinimizing&&xe.forceClearMinimize()}),h.user_effect(()=>{xe.isRestoring||xe.isOpening?h.set(Be,!0):h.get(Be)&&requestAnimationFrame(()=>{h.set(Be,!1)})}),h.user_effect(()=>{h.get(P)&&!h.get(U)&&(h.set(_,!0),setTimeout(()=>{h.set(_,!1)},200)),h.set(P,h.get(U),!0)});var ut=h.comment(),ht=h.first_child(ut),pt=e=>{Se(e,{get target(){return g},children:(e,i)=>{var n=it();let o;n.__keydown=st;var r=h.child(n);{let e=h.derived(()=>h.get(p)?dt:void 0);!function(e,t){h.push(t,!0);let i=h.prop(t,"isTransparent",3,!1),n=h.prop(t,"headerLayout",3,"macos"),o=h.prop(t,"minimizable",3,!0),r=h.prop(t,"minimizeDisabled",3,!1),d=h.prop(t,"transparencyEnabled",3,!0);const a=s(Ce),l=h.derived(()=>null==a?void 0:a()),c=h.derived(()=>"macos"===n());var g=Qe();let u;g.__pointerdown=function(e){var i;e.target.closest("button")||null==(i=t.onStartDrag)||i.call(t,e)};var p=h.child(g),f=e=>{var i=Ye(),n=h.first_child(i),s=h.child(n);s.__click=function(...e){var i;null==(i=t.onClose)||i.apply(this,e)};var a=h.sibling(s,2),c=e=>{var i=We();let n;i.__click=function(...e){var i;null==(i=r()?void 0:t.onMinimize)||i.apply(this,e)},h.template_effect(()=>{n=h.set_class(i,1,"modal-header-light modal-header-light-minimize",null,n,{"modal-header-light-disabled":r()}),i.disabled=r(),h.set_attribute(i,"title",r()?"Enable dock to minimize":void 0)}),h.append(e,i)};h.if(a,e=>{o()&&e(c)});var g=h.sibling(a,2),u=e=>{var i=Fe();i.__click=function(...e){var i;null==(i=t.onToggleStyle)||i.apply(this,e)},h.append(e,i)};h.if(g,e=>{d()&&e(u)}),h.reset(n);var p=h.sibling(n,2),f=h.child(p),m=e=>{var i=$e(),n=h.child(i);h.snippet(n,()=>t.customIcon),h.reset(i),h.append(e,i)},v=e=>{var i=h.comment(),n=h.first_child(i),o=e=>{var i=Le(),n=h.child(i);h.snippet(n,()=>h.get(l),()=>t.icon),h.reset(i),h.append(e,i)};h.if(n,e=>{t.icon&&h.get(l)&&e(o)},!0),h.append(e,i)};h.if(f,e=>{t.customIcon?e(m):e(v,!1)});var w=h.sibling(f,2),y=h.child(w),x=e=>{var i=Xe(),n=h.child(i,!0);h.reset(i),h.template_effect(()=>{h.set_attribute(i,"id",t.titleId),h.set_text(n,t.title)}),h.append(e,i)},z=e=>{var i=Ae(),n=h.child(i,!0);h.reset(i),h.template_effect(()=>h.set_text(n,t.title)),h.append(e,i)};h.if(y,e=>{t.titleId?e(x):e(z,!1)}),h.reset(w),h.reset(p),h.next(2),h.append(e,i)},m=e=>{var i=Ke(),n=h.first_child(i),s=h.child(n),a=e=>{var i=qe(),n=h.child(i);h.snippet(n,()=>t.customIcon),h.reset(i),h.append(e,i)},c=e=>{var i=h.comment(),n=h.first_child(i),o=e=>{var i=je(),n=h.child(i);h.snippet(n,()=>h.get(l),()=>t.icon),h.reset(i),h.append(e,i)};h.if(n,e=>{t.icon&&h.get(l)&&e(o)},!0),h.append(e,i)};h.if(s,e=>{t.customIcon?e(a):e(c,!1)});var g=h.sibling(s,2),u=e=>{var i=Ne(),n=h.child(i,!0);h.reset(i),h.template_effect(()=>{h.set_attribute(i,"id",t.titleId),h.set_text(n,t.title)}),h.append(e,i)},p=e=>{var i=Ge(),n=h.child(i,!0);h.reset(i),h.template_effect(()=>h.set_text(n,t.title)),h.append(e,i)};h.if(g,e=>{t.titleId?e(u):e(p,!1)}),h.reset(n);var f=h.sibling(n,2),m=h.child(f),v=e=>{var i=Ue();i.__click=function(...e){var i;null==(i=t.onToggleStyle)||i.apply(this,e)},h.append(e,i)};h.if(m,e=>{d()&&e(v)});var w=h.sibling(m,2),y=e=>{var i=Ve();let n;i.__click=function(...e){var i;null==(i=r()?void 0:t.onMinimize)||i.apply(this,e)},h.template_effect(()=>{n=h.set_class(i,1,"modal-header-btn-windows",null,n,{"modal-header-btn-windows-disabled":r()}),i.disabled=r(),h.set_attribute(i,"title",r()?"Enable dock to minimize":void 0)}),h.append(e,i)};h.if(w,e=>{o()&&e(y)}),h.sibling(w,2).__click=function(...e){var i;null==(i=t.onClose)||i.apply(this,e)},h.reset(f),h.append(e,i)};h.if(p,e=>{h.get(c)?e(f):e(m,!1)}),h.reset(g),h.template_effect(()=>u=h.set_class(g,1,"modal-header",null,u,{"modal-header-draggable":!!t.onStartDrag,transparent:i()})),h.append(e,g),h.pop()}(r,{get title(){return t.title},get customIcon(){return t.customIcon},get icon(){return t.icon},get isTransparent(){return h.get(M)},get titleId(){return h.get(te)},get headerLayout(){return h.get(x)},get onStartDrag(){return h.get(e)},onToggleStyle:rt,onMinimize:nt,onClose:ot,get minimizable(){return h.get(f)},get minimizeDisabled(){return h.get(m)},get transparencyEnabled(){return h.get(v)}})}var d=h.sibling(r,2),a=h.child(d);h.snippet(a,()=>t.children??h.noop),h.reset(d);var l=h.sibling(d,2),c=e=>{var i=et(),n=h.child(i);h.snippet(n,()=>t.footer),h.reset(i),h.append(e,i)};h.if(l,e=>{t.footer&&e(c)});var g=h.sibling(l,2);{let e=h.derived(()=>h.get(w)&&!h.get(U)?ce.handlers.startResize:void 0);!function(e,t){h.push(t,!0);const i=["n","s","e","w","ne","nw","se","sw"];var n=h.comment(),o=h.first_child(n),r=e=>{var n=Ze();h.each(n,21,()=>i,h.index,(e,i)=>{var n=Je();n.__pointerdown=e=>function(e,i){var n;null==(n=t.onStartResize)||n.call(t,e,i)}(e,h.get(i)),h.template_effect(()=>h.set_class(n,1,`modal-resize-handle modal-resize-${h.get(i)??""}`)),h.append(e,n)}),h.reset(n),h.append(e,n)};h.if(o,e=>{t.onStartResize&&e(r)}),h.append(e,n),h.pop()}(g,{get onStartResize(){return h.get(e)}})}var u=h.sibling(g,2),y=e=>{var t=tt();let i;h.template_effect(()=>i=h.set_class(t,1,"modal-child-overlay",null,i,{"modal-overlay-closing":h.get(_)})),h.append(e,t)};h.if(u,e=>{h.get(K)&&e(y)}),h.reset(n),h.bind_this(n,e=>h.set(b,e),()=>h.get(b)),h.template_effect(()=>{var e;o=h.set_class(n,1,"modal-dialog",null,o,{"modal-dragging":se.isDragging,"modal-resizing":ce.isResizing,"modal-positioned":se.hasBeenDragged,"modal-minimizing":xe.isMinimizing,"modal-restoring":xe.isRestoring,"modal-opening":xe.isOpening,"modal-closing":xe.isClosing,"modal-centered":h.get(Te),"modal-solid":!h.get(M),"modal-transparent":h.get(M),"modal-glow":h.get(ee),"modal-has-child":h.get(U),"modal-is-child":h.get(V),"modal-visible-by-animation":h.get(Ee),"modal-animating-to-center":h.get(le),"modal-animating-position":null==(e=h.get(H))?void 0:e.isAnimatingPosition,"modal-attention":h.get(O)}),h.set_attribute(n,"data-modal-id",t.id),h.set_style(n,h.get(He)),h.set_attribute(n,"aria-labelledby",h.get(te))}),h.event("pointerdown",n,()=>oe(t.id),!0),h.append(e,n)},$$slots:{default:!0}})};h.if(ht,e=>{h.get($)&&e(pt)}),h.append(e,ut),h.pop()}(e,{get id(){return t.id},get title(){return t.title},get icon(){return t.icon},get customIcon(){return t.customIcon},get maxWidth(){return i()},get preferredHeight(){return t.preferredHeight},get autoOpen(){return n()},get openSourcePosition(){return t.openSourcePosition},get glow(){return t.glow},get config(){return t.config},get closeOnEscape(){return o()},get onClose(){return t.onClose},get children(){return t.children},get footer(){return t.footer},skipRegistration:!0})};h.if(p,e=>{h.get(g)&&e(f)}),h.append(e,u),h.pop()}h.delegate(["keydown"]);const ot=t(null);function rt({id:t,title:o,icon:r,customIcon:d,maxWidth:s,preferredHeight:a,autoOpen:l=!1,openSourcePosition:c,glow:h,config:p,closeOnEscape:f=!0,onClose:m,children:v,footer:w}){const y=i(null),x=i(null),z=i(null),I=i(null),b=i(null);n(()=>{if(!y.current)return;const e=v?()=>z.current:void 0,i=w?()=>I.current:void 0,n=d?()=>b.current:void 0;return x.current=g(nt,{target:y.current,props:{id:t,title:o,icon:r,customIcon:n,maxWidth:s,preferredHeight:a,autoOpen:l,openSourcePosition:c,glow:h,config:p,closeOnEscape:f,onClose:m,children:e,footer:i}}),()=>{x.current&&(u(x.current),x.current=null)}},[t]),n(()=>{x.current&&Object.assign(x.current,{title:o,maxWidth:s,preferredHeight:a,glow:h,config:p,closeOnEscape:f,onClose:m})},[o,s,a,h,p,f,m]);const M="symbol"==typeof t?t.description??"symbol":t;return e.createElement(ot.Provider,{value:t},e.createElement("div",{ref:y,"data-modal-bridge":M}),e.createElement("div",{style:{display:"none"}},v&&e.createElement("div",{ref:z},v),w&&e.createElement("div",{ref:I},w),d&&e.createElement("div",{ref:b},d)))}function dt({config:t,children:i}){return n(()=>{t&&b(t),h.set(M,I().zIndex.base,!0);const e=I().portalTarget;let i=null;return"string"==typeof e&&"undefined"!=typeof document&&(document.querySelector(e)||(i=document.createElement("div"),i.id=e.replace("#",""),document.body.appendChild(i))),()=>{y={...w},h.update(x),h.set(M,I().zIndex.base,!0),i&&i.remove()}},[t]),e.createElement(e.Fragment,null,i)}var st=h.from_html('<button type="button" aria-label="Drag dock"></button>'),at=h.from_html('<span class="modal-dock-item-icon-placeholder"> </span>'),lt=h.from_html('<span class="modal-dock-item-label"> </span>'),ct=h.from_html("<span>+</span>"),gt=h.from_html('<span class="modal-dock-child-indicator"><!></span>'),ut=h.from_html('<button><span class="modal-dock-item-icon"><!></span> <!> <span class="modal-dock-item-glow"></span> <!></button>'),ht=h.from_html('<div data-dock-container="true"><div><!> <!></div></div>');function pt(e,t){h.push(t,!0);const i=s(Ce),n=h.derived(()=>t.renderIcon??(null==i?void 0:i())),o=be(),r=h.derived(()=>(z(),I())),d=h.derived(()=>I().zIndex.dock),a=h.derived(()=>h.get(r).dock.position),l=h.derived(()=>h.get(r).dock.labelMode);let c=h.state("horizontal"),g=h.state(h.proxy({x:100,y:100})),u=h.state(null),w=h.state(!1),y={x:0,y:0},x=null;const b=h.derived(()=>(he(),Array.from(o.modals.values()).filter(e=>e.isMinimized).sort((e,t)=>e.dockPosition-t.dockPosition))),M=h.derived(()=>{switch(h.get(a)){case"left":return{x:-20,duration:250,easing:m};case"right":return{x:20,duration:250,easing:m};default:return{y:20,duration:250,easing:m}}});function _(e){var t;"free"===h.get(a)&&(h.set(w,!0),x=e.pointerId,y={x:e.clientX-h.get(g).x,y:e.clientY-h.get(g).y},null==(t=e.currentTarget)||t.setPointerCapture(e.pointerId),window.addEventListener("pointermove",C),window.addEventListener("pointerup",P),window.addEventListener("pointercancel",P))}function C(e){if(e.pointerId!==x||!h.get(u))return;const t=h.get(u).getBoundingClientRect(),i=window.innerWidth-t.width-8,n=window.innerHeight-t.height-8,o=Math.min(Math.max(e.clientX-y.x,8),Math.max(8,i)),r=Math.min(Math.max(e.clientY-y.y,8),Math.max(8,n));h.set(g,{x:Math.round(o),y:Math.round(r)},!0)}function P(e){e.pointerId===x&&(h.set(w,!1),x=null,window.removeEventListener("pointermove",C),window.removeEventListener("pointerup",P),window.removeEventListener("pointercancel",P))}const{addListener:D}=function(){function e(e,t,i){return"undefined"==typeof window?()=>{}:(window.addEventListener(e,t,i),()=>{window.removeEventListener(e,t,i)})}return{addListener:e,addListenerEffect:function(t,i,n){h.user_effect(()=>{if("undefined"!=typeof window)return e(t,i,n)})}}}();function B(){if("free"!==h.get(a)||!h.get(u))return;const e=h.get(u).getBoundingClientRect(),t=k(h.get(g).x,h.get(g).y,e.width,e.height);t.x===h.get(g).x&&t.y===h.get(g).y||h.set(g,{x:Math.round(t.x),y:Math.round(t.y)},!0)}h.user_effect(()=>{"undefined"!=typeof window&&D("resize",B)});var E={setDockOrientation:function(e){h.set(c,e,!0)},setDockFreePosition:function(e){h.set(g,e,!0)},getDockState:function(){return{dockPosition:h.get(a),dockOrientation:h.get(c),dockFreePosition:h.get(g),dockLabelMode:h.get(l)}}};return Se(e,{get target(){return h.get(r).portalTarget},children:(e,t)=>{var i=ht();let r,s;var m=h.child(i);let y;var x=h.child(m),z=e=>{var t=st();let i;t.__pointerdown=_,h.template_effect(()=>i=h.set_class(t,1,"modal-dock-handle",null,i,{"modal-dock-handle-dragging":h.get(w)})),h.append(e,t)};h.if(x,e=>{"free"===h.get(a)&&e(z)});var I=h.sibling(x,2);h.each(I,19,()=>h.get(b),e=>e.id,(e,t,i)=>{const r=h.derived(()=>h.get(t).lastChildId?o.modals.get(h.get(t).lastChildId):null);var d=ut();let s;d.__click=e=>{var i;i=h.get(t).id,U.has(i)?e.currentTarget.animate([{transform:"translateX(0)"},{transform:"translateX(-6px)"},{transform:"translateX(6px)"},{transform:"translateX(-6px)"},{transform:"translateX(6px)"},{transform:"translateX(0)"}],{duration:300,easing:"ease-in-out"}):ee(h.get(t).id)};var a=h.child(d),c=h.child(a),g=e=>{var i=h.comment(),o=h.first_child(i);h.snippet(o,()=>h.get(n),()=>h.get(t).icon),h.append(e,i)},u=e=>{var i=at(),n=h.child(i,!0);h.reset(i),h.template_effect(e=>h.set_text(n,e),[()=>h.get(t).title.charAt(0)]),h.append(e,i)};h.if(c,e=>{h.get(t).icon&&h.get(n)?e(g):e(u,!1)}),h.reset(a);var f=h.sibling(a,2),m=e=>{var i=lt(),n=h.child(i,!0);h.reset(i),h.template_effect(()=>h.set_text(n,h.get(t).title)),h.append(e,i)};h.if(f,e=>{"hidden"!==h.get(l)&&e(m)});var w=h.sibling(f,4),y=e=>{var t=gt(),i=h.child(t),o=e=>{var t=h.comment(),i=h.first_child(t);h.snippet(i,()=>h.get(n),()=>h.get(r).icon),h.append(e,t)},d=e=>{var t=ct();h.append(e,t)};h.if(i,e=>{h.get(r).icon&&h.get(n)?e(o):e(d,!1)}),h.reset(t),h.append(e,t)};h.if(w,e=>{h.get(t).lastChildId&&h.get(r)&&e(y)}),h.reset(d),h.template_effect(()=>{s=h.set_class(d,1,"modal-dock-item",null,s,{"modal-dock-item-has-glow":!!h.get(t).glow,"modal-dock-item-has-child":!!h.get(t).lastChildId,"modal-dock-item-label-beside":"beside"===h.get(l),"modal-dock-item-label-below":"below"===h.get(l)}),h.set_attribute(d,"data-modal-id",h.get(t).id),h.set_style(d,h.get(t).glow?`--modal-dock-glow-color: ${h.get(t).glow.color};`:"")}),h.transition(3,d,()=>p,()=>({duration:300,delay:50*h.get(i),easing:v,start:.5})),h.append(e,d)}),h.reset(m),h.reset(i),h.bind_this(i,e=>h.set(u,e),()=>h.get(u)),h.template_effect(()=>{r=h.set_class(i,1,"modal-dock-container",null,r,{"modal-dock-left":"left"===h.get(a),"modal-dock-right":"right"===h.get(a),"modal-dock-bottom":"bottom"===h.get(a),"modal-dock-free":"free"===h.get(a),"modal-dock-empty":0===h.get(b).length}),s=h.set_style(i,"free"===h.get(a)?`left: ${h.get(g).x}px; top: ${h.get(g).y}px;`:"",s,{"z-index":h.get(d)}),y=h.set_class(m,1,"modal-dock",null,y,{"modal-dock-free-horizontal":"free"===h.get(a)&&"horizontal"===h.get(c),"modal-dock-free-vertical":"free"===h.get(a)&&"vertical"===h.get(c)})}),h.transition(3,i,()=>f,()=>h.get(b).length>0?h.get(M):{duration:0}),h.append(e,i)},$$slots:{default:!0}}),h.pop(E)}function ft({renderIcon:t}){const o=i(null),r=i(null);return n(()=>{if(o.current)return r.current=g(pt,{target:o.current,props:{}}),()=>{r.current&&(u(r.current),r.current=null)}},[]),e.createElement("div",{ref:o,"data-dock-bridge":!0})}function mt(e,t){if(!Ie(e))throw new Error(`Cannot call ${t}() on unregistered modal "${String(e)}". Ensure the Modal component is rendered.`)}h.delegate(["pointerdown","click"]);const vt=new Map;function wt(e){const t=o(()=>function(e){const t=be().modals.get(e),i=void 0!==t&&!t.isMinimized,n=(null==t?void 0:t.isMinimized)??!1,o=void 0!==t,r=vt.get(e);if(r&&r.isOpen===i&&r.isMinimized===n&&r.isRegistered===o)return r;const d={isOpen:i,isMinimized:n,isRegistered:o};return vt.set(e,d),d}(e),[e]);return{...r(H,t,t),open:o(t=>{mt(e,"open"),se(e,t)},[e]),close:o(()=>{mt(e,"close"),ae(e)},[e]),minimize:o(()=>{mt(e,"minimize"),Z(e)},[e]),restore:o(()=>{mt(e,"restore"),ee(e)},[e]),openChild:o((t,i)=>{mt(e,"openChild"),ce({id:t},e,i)},[e]),shake:o(()=>{mt(e,"shake"),xe(e)},[e]),bringToFront:o(()=>{mt(e,"bringToFront"),oe(e)},[e])}}let yt=null;function xt(){const e=be(),t=Array.from(e.modals.values()),i=t.filter(e=>e.isMinimized).length,n=t.filter(e=>!e.isMinimized).length;return yt&&yt.modals===e.modals&&yt.minimizedCount===i&&yt.openCount===n||(yt={modals:e.modals,minimizedCount:i,openCount:n}),yt}function zt(){return r(H,xt,xt)}export{ft as Dock,rt as Modal,dt as ModalProvider,oe as bringToFront,le as closeAllModals,ae as closeModal,I as getConfig,ze as isModalOpen,Ie as isModalRegistered,re as isTopModal,Z as minimizeModal,ce as openChildModal,se as openModal,de as reorderDock,ee as restoreModal,b as setConfig,Me as toggleModalTransparency,wt as useModal,zt as useModals};
|
|
1
|
+
var e,t,n,i,r,o,l,s,a,u,d,c,f,h,p,v,g,m,y,w,x,b,k,z,M,_,I,S,P,C,E,O,D,T,W,R,B,A,$,j,H,L,F=Object.defineProperty,N=e=>{throw TypeError(e)},q=(e,t,n)=>((e,t,n)=>t in e?F(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),X=(e,t,n)=>t.has(e)||N("Cannot "+n),Y=(e,t,n)=>(X(e,t,"read from private field"),n?n.call(e):t.get(e)),G=(e,t,n)=>t.has(e)?N("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),U=(e,t,n,i)=>(X(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),V=(e,t,n)=>(X(e,t,"access private method"),n);import K,{useRef as Q,useState as J,useEffect as Z,useCallback as ee,useSyncExternalStore as te}from"react";import{createPortal as ne}from"react-dom";var ie,re,oe,le={exports:{}},se={},ae={},ue=(oe||(oe=1,"production"===process.env.NODE_ENV?le.exports=function(){if(ie)return se;ie=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(t,n,i){var r=null;if(void 0!==i&&(r=""+i),void 0!==n.key&&(r=""+n.key),"key"in n)for(var o in i={},n)"key"!==o&&(i[o]=n[o]);else i=n;return n=i.ref,{$$typeof:e,type:t,key:r,ref:void 0!==n?n:null,props:i}}return se.Fragment=t,se.jsx=n,se.jsxs=n,se}():le.exports=(re||(re=1,"production"!==process.env.NODE_ENV&&function(){function e(t){if(null==t)return null;if("function"==typeof t)return t.$$typeof===M?null:t.displayName||t.name||null;if("string"==typeof t)return t;switch(t){case h:return"Fragment";case v:return"Profiler";case p:return"StrictMode";case w:return"Suspense";case x:return"SuspenseList";case z:return"Activity"}if("object"==typeof t)switch(t.tag,t.$$typeof){case f:return"Portal";case m:return t.displayName||"Context";case g:return(t._context.displayName||"Context")+".Consumer";case y:var n=t.render;return(t=t.displayName)||(t=""!==(t=n.displayName||n.name||"")?"ForwardRef("+t+")":"ForwardRef"),t;case b:return null!==(n=t.displayName||null)?n:e(t.type)||"Memo";case k:n=t._payload,t=t._init;try{return e(t(n))}catch(e){}}return null}function t(e){return""+e}function n(e){try{t(e);var n=!1}catch(e){n=!0}if(n){var i=(n=console).error,r="function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return i.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",r),t(e)}}function i(t){if(t===h)return"<>";if("object"==typeof t&&null!==t&&t.$$typeof===k)return"<...>";try{var n=e(t);return n?"<"+n+">":"<...>"}catch(e){return"<...>"}}function r(){return Error("react-stack-top-frame")}function o(){var t=e(this.type);return C[t]||(C[t]=!0),void 0!==(t=this.props.ref)?t:null}function l(t,i,r,l,a,d){var f,h=i.children;if(void 0!==h)if(l){if(S(h)){for(l=0;l<h.length;l++)s(h[l]);Object.freeze&&Object.freeze(h)}}else s(h);if(I.call(i,"key")){h=e(t);var p=Object.keys(i).filter(function(e){return"key"!==e});l=0<p.length?"{key: someKey, "+p.join(": ..., ")+": ...}":"{key: someKey}",D[h+l]||(p=0<p.length?"{"+p.join(": ..., ")+": ...}":"{}",D[h+l]=!0)}if(h=null,void 0!==r&&(n(r),h=""+r),function(e){if(I.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(i)&&(n(i.key),h=""+i.key),"key"in i)for(var v in r={},i)"key"!==v&&(r[v]=i[v]);else r=i;return h&&function(e){function t(){u||(u=!0)}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}(r,"function"==typeof t&&(t.displayName||t.name)),function(e,t,n,i,r,l){var s=n.ref;return e={$$typeof:c,type:e,key:t,props:n,_owner:i},null!==(void 0!==s?s:null)?Object.defineProperty(e,"ref",{enumerable:!1,get:o}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:r}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:l}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(t,h,r,null===(f=_.A)?null:f.getOwner(),a,d)}function s(e){a(e)?e._store&&(e._store.validated=1):"object"==typeof e&&null!==e&&e.$$typeof===k&&("fulfilled"===e._payload.status?a(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function a(e){return"object"==typeof e&&null!==e&&e.$$typeof===c}var u,d=K,c=Symbol.for("react.transitional.element"),f=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),g=Symbol.for("react.consumer"),m=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),z=Symbol.for("react.activity"),M=Symbol.for("react.client.reference"),_=d.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=Object.prototype.hasOwnProperty,S=Array.isArray,P=console.createTask?console.createTask:function(){return null},C={},E=(d={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(d,r)(),O=P(i(r)),D={};ae.Fragment=h,ae.jsx=function(e,t,n){var r=1e4>_.recentlyCreatedOwnerStacks++;return l(e,t,n,!1,r?Error("react-stack-top-frame"):E,r?P(i(e)):O)},ae.jsxs=function(e,t,n){var r=1e4>_.recentlyCreatedOwnerStacks++;return l(e,t,n,!0,r?Error("react-stack-top-frame"):E,r?P(i(e)):O)}}()),ae)),le.exports),de=Array.isArray,ce=Array.prototype.indexOf,fe=Array.from,he=Object.defineProperty,pe=Object.getOwnPropertyDescriptor,ve=Object.getOwnPropertyDescriptors,ge=Object.prototype,me=Array.prototype,ye=Object.getPrototypeOf,we=Object.isExtensible;const xe=()=>{};function be(){var e,t;return{promise:new Promise((n,i)=>{e=n,t=i}),resolve:e,reject:t}}const ke=16,ze=512,Me=1024,_e=2048,Ie=4096,Se=8192,Pe=16384,Ce=32768,Ee=65536,Oe=1<<18,De=1<<19,Te=1<<25,We=32768,Re=1<<21,Be=1<<23,Ae=Symbol("$state"),$e=Symbol(""),je=new class extends Error{constructor(){super(...arguments),q(this,"name","StaleReactionError"),q(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};function He(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}const Le=Symbol();function Fe(e){return e===this.v}function Ne(e,t){return e!=e?t==t:e!==t||null!==e&&"object"==typeof e||"function"==typeof e}function qe(e){return!Ne(e,this.v)}let Xe=null;function Ye(e){Xe=e}function Ge(e){return Ke().get(e)}function Ue(e,t=!1,n){Xe={p:Xe,i:!1,c:null,e:null,s:e,x:null,l:null}}function Ve(e){var t=Xe,n=t.e;if(null!==n)for(var i of(t.e=null,n))en(i);return void 0!==e&&(t.x=e),t.i=!0,Xe=t.p,e??{}}function Ke(e){return null===Xe&&He(),Xe.c??(Xe.c=new Map(function(){let e=Xe.p;for(;null!==e;){const t=e.c;if(null!==t)return t;e=e.p}return null}()||void 0))}let Qe=[];function Je(){var e=Qe;Qe=[],function(e){for(var t=0;t<e.length;t++)e[t]()}(e)}function Ze(e){if(0===Qe.length&&!ut){var t=Qe;queueMicrotask(()=>{t===Qe&&Je()})}Qe.push(e)}function et(){for(;Qe.length>0;)Je()}function tt(e){var t=zn;if(null===t)return xn.f|=Be,e;if(0===(t.f&Ce)){if(!(128&t.f))throw e;t.b.error(e)}else nt(e,t)}function nt(e,t){for(;null!==t;){if(128&t.f)try{return void t.b.error(e)}catch(t){e=t}t=t.parent}throw e}const it=new Set;let rt=null,ot=null,lt=[],st=null,at=!1,ut=!1;e=new WeakMap,t=new WeakMap,n=new WeakMap,i=new WeakMap,r=new WeakMap,o=new WeakMap,l=new WeakMap,s=new WeakSet,a=function(e,t){var n;e.f^=Me;for(var i=e.first;null!==i;){var r=i.f,l=!!(96&r),a=l&&0!==(r&Me)||0!==(r&Se)||this.skipped_effects.has(i);if(!!(128&i.f)&&(null==(n=i.b)?void 0:n.is_pending())&&(t={parent:t,effect:i,effects:[],render_effects:[]}),!a&&null!==i.fn){l?i.f^=Me:4&r?t.effects.push(i):Rn(i)&&(0!==(i.f&ke)&&Y(this,o).add(i),Hn(i));var d=i.first;if(null!==d){i=d;continue}}var c=i.parent;for(i=i.next;null===i&&null!==c;)c===t.effect&&(V(this,s,u).call(this,t.effects),V(this,s,u).call(this,t.render_effects),t=t.parent),i=c.next,c=c.parent}},u=function(e){for(const t of e)0!==(t.f&_e)?Y(this,o).add(t):0!==(t.f&Ie)&&Y(this,l).add(t),V(this,s,d).call(this,t.deps),Gn(t,Me)},d=function(e){if(null!==e)for(const t of e)2&t.f&&0!==(t.f&We)&&(t.f^=We,V(this,s,d).call(this,t.deps))},c=function(){if(0===Y(this,i)){for(const t of Y(this,e))t();Y(this,e).clear()}0===Y(this,n)&&V(this,s,f).call(this)},f=function(){var e;if(it.size>1){this.previous.clear();var t=ot,n=!0,i={parent:null,effect:null,effects:[],render_effects:[]};for(const t of it){if(t===this){n=!1;continue}const o=[];for(const[e,i]of this.current){if(t.current.has(e)){if(!n||i===t.current.get(e))continue;t.current.set(e,i)}o.push(e)}if(0===o.length)continue;const l=[...t.current.keys()].filter(e=>!this.current.has(e));if(l.length>0){var r=lt;lt=[];const n=new Set,u=new Map;for(const e of o)vt(e,l,n,u);if(lt.length>0){rt=t,t.apply();for(const n of lt)V(e=t,s,a).call(e,n,i);t.deactivate()}lt=r}}rt=null,ot=t}this.committed=!0,it.delete(this)};let dt=class d{constructor(){G(this,s),q(this,"committed",!1),q(this,"current",new Map),q(this,"previous",new Map),G(this,e,new Set),G(this,t,new Set),G(this,n,0),G(this,i,0),G(this,r,null),G(this,o,new Set),G(this,l,new Set),q(this,"skipped_effects",new Set),q(this,"is_fork",!1)}is_deferred(){return this.is_fork||Y(this,i)>0}process(e){var t;lt=[],this.apply();var n={parent:null,effect:null,effects:[],render_effects:[]};for(const t of e)V(this,s,a).call(this,t,n);this.is_fork||V(this,s,c).call(this),this.is_deferred()?(V(this,s,u).call(this,n.effects),V(this,s,u).call(this,n.render_effects)):(rt=null,pt(n.render_effects),pt(n.effects),null==(t=Y(this,r))||t.resolve()),ot=null}capture(e,t){this.previous.has(e)||this.previous.set(e,t),0===(e.f&Be)&&(this.current.set(e,e.v),null==ot||ot.set(e,e.v))}activate(){rt=this,this.apply()}deactivate(){rt===this&&(rt=null,ot=null)}flush(){if(this.activate(),lt.length>0){if(ct(),null!==rt&&rt!==this)return}else 0===Y(this,n)&&this.process([]);this.deactivate()}discard(){for(const e of Y(this,t))e(this);Y(this,t).clear()}increment(e){U(this,n,Y(this,n)+1),e&&U(this,i,Y(this,i)+1)}decrement(e){U(this,n,Y(this,n)-1),e&&U(this,i,Y(this,i)-1),this.revive()}revive(){for(const e of Y(this,o))Y(this,l).delete(e),Gn(e,_e),mt(e);for(const e of Y(this,l))Gn(e,Ie),mt(e);this.flush()}oncommit(t){Y(this,e).add(t)}ondiscard(e){Y(this,t).add(e)}settled(){return(Y(this,r)??U(this,r,be())).promise}static ensure(){if(null===rt){const e=rt=new d;it.add(rt),ut||d.enqueue(()=>{rt===e&&e.flush()})}return rt}static enqueue(e){Ze(e)}apply(){}};function ct(){var e=gn;at=!0;try{var t=0;for(mn(!0);lt.length>0;){var n=dt.ensure();t++>1e3&&ft(),n.process(lt),Pt.clear()}}finally{at=!1,mn(e),st=null}}function ft(){try{!function(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}()}catch(e){nt(e,st)}}let ht=null;function pt(e){var t=e.length;if(0!==t){for(var n=0;n<t;){var i=e[n++];if(!(24576&i.f)&&Rn(i)&&(ht=new Set,Hn(i),null===i.deps&&null===i.first&&null===i.nodes&&(null===i.teardown&&null===i.ac?dn(i):i.fn=null),(null==ht?void 0:ht.size)>0)){Pt.clear();for(const e of ht){if(24576&e.f)continue;const t=[e];let n=e.parent;for(;null!==n;)ht.has(n)&&(ht.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){const n=t[e];24576&n.f||Hn(n)}}ht.clear()}}ht=null}}function vt(e,t,n,i){if(!n.has(e)&&(n.add(e),null!==e.reactions))for(const r of e.reactions){const e=r.f;2&e?vt(r,t,n,i):4194320&e&&0===(e&_e)&>(r,t,i)&&(Gn(r,_e),mt(r))}}function gt(e,t,n){const i=n.get(e);if(void 0!==i)return i;if(null!==e.deps)for(const i of e.deps){if(t.includes(i))return!0;if(2&i.f&>(i,t,n))return n.set(i,!0),!0}return n.set(e,!1),!1}function mt(e){for(var t=st=e;null!==t.parent;){var n=(t=t.parent).f;if(at&&t===zn&&0!==(n&ke)&&0===(n&Oe))return;if(96&n){if(0===(n&Me))return;t.f^=Me}}lt.push(t)}class yt{constructor(e,t,n){G(this,C),q(this,"parent"),G(this,h,!1),G(this,p),G(this,v,null),G(this,g),G(this,m),G(this,y),G(this,w,null),G(this,x,null),G(this,b,null),G(this,k,null),G(this,z,null),G(this,M,0),G(this,_,0),G(this,I,!1),G(this,S,null),G(this,P,function(e){let t,n=0,i=Et(0);return()=>{Qt()&&(Fn(i),nn(()=>(0===n&&(t=Xn(()=>e())),n+=1,()=>{Ze(()=>{n-=1,0===n&&(null==t||t(),t=void 0,Bt(i))})})))}}(()=>(U(this,S,Et(Y(this,M))),()=>{U(this,S,null)}))),U(this,p,e),U(this,g,t),U(this,m,n),this.parent=zn.b,U(this,h,!!Y(this,g).pending),U(this,y,on(()=>{zn.b=this;var e=V(this,C,E).call(this);try{U(this,w,ln(()=>n(e)))}catch(e){this.error(e)}return Y(this,_)>0?V(this,C,D).call(this):U(this,h,!1),()=>{var e;null==(e=Y(this,z))||e.remove()}},589952))}is_pending(){return Y(this,h)||!!this.parent&&this.parent.is_pending()}has_pending_snippet(){return!!Y(this,g).pending}update_pending_count(e){V(this,C,T).call(this,e),U(this,M,Y(this,M)+e),Y(this,S)&&Wt(Y(this,S),Y(this,M))}get_effect_pending(){return Y(this,P).call(this),Fn(Y(this,S))}error(e){var t=Y(this,g).onerror;let n=Y(this,g).failed;if(Y(this,I)||!t&&!n)throw e;Y(this,w)&&(un(Y(this,w)),U(this,w,null)),Y(this,x)&&(un(Y(this,x)),U(this,x,null)),Y(this,b)&&(un(Y(this,b)),U(this,b,null));var i=!1,r=!1;const o=()=>{i||(i=!0,r&&function(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}(),dt.ensure(),U(this,M,0),null!==Y(this,b)&&cn(Y(this,b),()=>{U(this,b,null)}),U(this,h,this.has_pending_snippet()),U(this,w,V(this,C,O).call(this,()=>(U(this,I,!1),ln(()=>Y(this,m).call(this,Y(this,p)))))),Y(this,_)>0?V(this,C,D).call(this):U(this,h,!1))};var l=xn;try{kn(null),r=!0,null==t||t(e,o),r=!1}catch(e){nt(e,Y(this,y)&&Y(this,y).parent)}finally{kn(l)}n&&Ze(()=>{U(this,b,V(this,C,O).call(this,()=>{dt.ensure(),U(this,I,!0);try{return ln(()=>{n(Y(this,p),()=>e,()=>o)})}catch(e){return nt(e,Y(this,y).parent),null}finally{U(this,I,!1)}}))})}}function wt(){Mn(null),kn(null),Ye(null)}function xt(e){var t=null!==xn&&2&xn.f?xn:null;return null!==zn&&(zn.f|=De),{ctx:Xe,deps:null,effects:null,equals:Fe,f:2050,fn:e,reactions:null,rv:0,v:Le,wv:0,parent:t??zn,ac:null}}function bt(e,t){let n=zn;null===n&&function(){throw new Error("https://svelte.dev/e/async_derived_orphan")}();var i=n.b,r=void 0,o=Et(Le),l=!xn,s=new Map;return function(e){Kt(4718592,e,!0)}(()=>{var t,n=be();r=n.promise;try{Promise.resolve(e()).then(n.resolve,n.reject).then(()=>{a===rt&&a.committed&&a.deactivate(),wt()})}catch(e){n.reject(e),wt()}var a=rt;if(l){var u=!i.is_pending();i.update_pending_count(1),a.increment(u),null==(t=s.get(a))||t.reject(je),s.delete(a),s.set(a,n)}const d=(e,t=void 0)=>{if(a.activate(),t)t!==je&&(o.f|=Be,Wt(o,t));else{0!==(o.f&Be)&&(o.f^=Be),Wt(o,e);for(const[e,t]of s){if(s.delete(e),e===a)break;t.reject(je)}}l&&(i.update_pending_count(-1),a.decrement(u))};n.promise.then(d,e=>d(null,e||"unknown"))}),Jt(()=>{for(const e of s.values())e.reject(je)}),new Promise(e=>{!function t(n){function i(){n===r?e(o):t(r)}n.then(i,i)}(r)})}function kt(e){const t=xt(e);return In(t),t}function zt(e){const t=xt(e);return t.equals=qe,t}function Mt(e){var t=e.effects;if(null!==t){e.effects=null;for(var n=0;n<t.length;n+=1)un(t[n])}}function _t(e){var t,n=zn;Mn(function(e){for(var t=e.parent;null!==t;){if(!(2&t.f))return 0===(t.f&Pe)?t:null;t=t.parent}return null}(e));try{e.f&=-32769,Mt(e),t=An(e)}finally{Mn(n)}return t}function It(e){var t=_t(e);e.equals(t)||((null==rt?void 0:rt.is_fork)||(e.v=t),e.wv=Wn()),yn||(null!==ot?(Qt()||(null==rt?void 0:rt.is_fork))&&ot.set(e,t):Gn(e,0===(e.f&ze)?Ie:Me))}h=new WeakMap,p=new WeakMap,v=new WeakMap,g=new WeakMap,m=new WeakMap,y=new WeakMap,w=new WeakMap,x=new WeakMap,b=new WeakMap,k=new WeakMap,z=new WeakMap,M=new WeakMap,_=new WeakMap,I=new WeakMap,S=new WeakMap,P=new WeakMap,C=new WeakSet,E=function(){var e=Y(this,p);return Y(this,h)&&(U(this,z,Nt()),Y(this,p).before(Y(this,z)),e=Y(this,z)),e},O=function(e){var t=zn,n=xn,i=Xe;Mn(Y(this,y)),kn(Y(this,y)),Ye(Y(this,y).ctx);try{return e()}catch(e){return tt(e),null}finally{Mn(t),kn(n),Ye(i)}},D=function(){const e=Y(this,g).pending;null!==Y(this,w)&&(U(this,k,document.createDocumentFragment()),Y(this,k).append(Y(this,z)),vn(Y(this,w),Y(this,k))),null===Y(this,x)&&U(this,x,ln(()=>e(Y(this,p))))},T=function(e){var t;this.has_pending_snippet()?(U(this,_,Y(this,_)+e),0===Y(this,_)&&(U(this,h,!1),Y(this,x)&&cn(Y(this,x),()=>{U(this,x,null)}),Y(this,k)&&(Y(this,p).before(Y(this,k)),U(this,k,null)))):this.parent&&V(t=this.parent,C,T).call(t,e)};let St=new Set;const Pt=new Map;let Ct=!1;function Et(e,t){return{f:0,v:e,reactions:null,equals:Fe,rv:0,wv:0}}function Ot(e,t){const n=Et(e);return In(n),n}function Dt(e,t=!1,n=!0){const i=Et(e);return t||(i.equals=qe),i}function Tt(e,t,n=!1){return null===xn||bn&&!(131072&xn.f)||!(4325394&xn.f)||(null==_n?void 0:_n.includes(e))||function(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}(),Wt(e,n?$t(t):t)}function Wt(e,t){if(!e.equals(t)){var n=e.v;yn?Pt.set(e,t):Pt.set(e,n),e.v=t;var i=dt.ensure();i.capture(e,n),2&e.f&&(0!==(e.f&_e)&&_t(e),Gn(e,0!==(e.f&ze)?Me:Ie)),e.wv=Wn(),At(e,_e),null===zn||0===(zn.f&Me)||96&zn.f||(null===Cn?function(e){Cn=e}([e]):Cn.push(e)),!i.is_fork&&St.size>0&&!Ct&&function(){Ct=!1;var e=gn;mn(!0);const t=Array.from(St);try{for(const e of t)0!==(e.f&Me)&&Gn(e,Ie),Rn(e)&&Hn(e)}finally{mn(e)}St.clear()}()}return t}function Rt(e,t=1){var n=Fn(e),i=1===t?n++:n--;return Tt(e,n),i}function Bt(e){Tt(e,e.v+1)}function At(e,t){var n=e.reactions;if(null!==n)for(var i=n.length,r=0;r<i;r++){var o=n[r],l=o.f,s=0===(l&_e);if(s&&Gn(o,t),2&l){var a=o;null==ot||ot.delete(a),0===(l&We)&&(l&ze&&(o.f|=We),At(a,Ie))}else s&&(0!==(l&ke)&&null!==ht&&ht.add(o),mt(o))}}function $t(e){if("object"!=typeof e||null===e||Ae in e)return e;const t=ye(e);if(t!==ge&&t!==me)return e;var n=new Map,i=de(e),r=Ot(0),o=Dn,l=e=>{if(Dn===o)return e();var t=xn,n=Dn;kn(null),Tn(o);var i=e();return kn(t),Tn(n),i};return i&&n.set("length",Ot(e.length)),new Proxy(e,{defineProperty(e,t,i){"value"in i&&!1!==i.configurable&&!1!==i.enumerable&&!1!==i.writable||function(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}();var r=n.get(t);return void 0===r?r=l(()=>{var e=Ot(i.value);return n.set(t,e),e}):Tt(r,i.value,!0),!0},deleteProperty(e,t){var i=n.get(t);if(void 0===i){if(t in e){const e=l(()=>Ot(Le));n.set(t,e),Bt(r)}}else Tt(i,Le),Bt(r);return!0},get(t,i,r){var o;if(i===Ae)return e;var s=n.get(i),a=i in t;if(void 0!==s||a&&!(null==(o=pe(t,i))?void 0:o.writable)||(s=l(()=>Ot($t(a?t[i]:Le))),n.set(i,s)),void 0!==s){var u=Fn(s);return u===Le?void 0:u}return Reflect.get(t,i,r)},getOwnPropertyDescriptor(e,t){var i=Reflect.getOwnPropertyDescriptor(e,t);if(i&&"value"in i){var r=n.get(t);r&&(i.value=Fn(r))}else if(void 0===i){var o=n.get(t),l=null==o?void 0:o.v;if(void 0!==o&&l!==Le)return{enumerable:!0,configurable:!0,value:l,writable:!0}}return i},has(e,t){var i;if(t===Ae)return!0;var r=n.get(t),o=void 0!==r&&r.v!==Le||Reflect.has(e,t);return!((void 0!==r||null!==zn&&(!o||(null==(i=pe(e,t))?void 0:i.writable)))&&(void 0===r&&(r=l(()=>Ot(o?$t(e[t]):Le)),n.set(t,r)),Fn(r)===Le))&&o},set(e,t,o,s){var a,u=n.get(t),d=t in e;if(i&&"length"===t)for(var c=o;c<u.v;c+=1){var f=n.get(c+"");void 0!==f?Tt(f,Le):c in e&&(f=l(()=>Ot(Le)),n.set(c+"",f))}void 0===u?d&&!(null==(a=pe(e,t))?void 0:a.writable)||(Tt(u=l(()=>Ot(void 0)),$t(o)),n.set(t,u)):(d=u.v!==Le,Tt(u,l(()=>$t(o))));var h=Reflect.getOwnPropertyDescriptor(e,t);if((null==h?void 0:h.set)&&h.set.call(s,o),!d){if(i&&"string"==typeof t){var p=n.get("length"),v=Number(t);Number.isInteger(v)&&v>=p.v&&Tt(p,v+1)}Bt(r)}return!0},ownKeys(e){Fn(r);var t=Reflect.ownKeys(e).filter(e=>{var t=n.get(e);return void 0===t||t.v!==Le});for(var[i,o]of n)o.v===Le||i in e||t.push(i);return t},setPrototypeOf(){!function(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}()}})}var jt,Ht,Lt,Ft;function Nt(e=""){return document.createTextNode(e)}function qt(e){return Lt.call(e)}function Xt(e){return Ft.call(e)}function Yt(e,t){return qt(e)}function Gt(e,t=!1){var n=qt(e);return n instanceof Comment&&""===n.data?Xt(n):n}function Ut(e,t=1,n=!1){let i=e;for(;t--;)i=Xt(i);return i}function Vt(e){var t=xn,n=zn;kn(null),Mn(null);try{return e()}finally{kn(t),Mn(n)}}function Kt(e,t,n){var i=zn;null!==i&&0!==(i.f&Se)&&(e|=Se);var r={ctx:Xe,deps:null,nodes:null,f:e|_e|ze,first:null,fn:t,last:null,next:null,parent:i,b:i&&i.b,prev:null,teardown:null,wv:0,ac:null};if(n)try{Hn(r),r.f|=Ce}catch(e){throw un(r),e}else null!==t&&mt(r);var o=r;if(n&&null===o.deps&&null===o.teardown&&null===o.nodes&&o.first===o.last&&0===(o.f&De)&&(o=o.first,0!==(e&ke)&&0!==(e&Ee)&&null!==o&&(o.f|=Ee)),null!==o&&(o.parent=i,null!==i&&function(e,t){var n=t.last;null===n?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}(o,i),null!==xn&&2&xn.f&&!(64&e))){var l=xn;(l.effects??(l.effects=[])).push(o)}return r}function Qt(){return null!==xn&&!bn}function Jt(e){const t=Kt(8,null,!1);return Gn(t,Me),t.teardown=e,t}function Zt(e){null===zn&&(null===xn&&function(){throw new Error("https://svelte.dev/e/effect_orphan")}(),function(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}()),yn&&function(){throw new Error("https://svelte.dev/e/effect_in_teardown")}();var t=zn.f;if(xn||!(32&t)||0!==(t&Ce))return en(e);var n=Xe;(n.e??(n.e=[])).push(e)}function en(e){return Kt(1048580,e,!1)}function tn(e){return Kt(4,e,!1)}function nn(e,t=0){return Kt(8|t,e,!0)}function rn(e,t=[],n=[],i=[]){!function(e,t,n,i){const r=xt;if(0!==n.length||0!==e.length){var o,l,s,a,u=rt,d=zn,c=(o=zn,l=xn,s=Xe,a=rt,function(e=!0){Mn(o),kn(l),Ye(s),e&&(null==a||a.activate())});e.length>0?Promise.all(e).then(()=>{c();try{return f()}finally{null==u||u.deactivate(),wt()}}):f()}else i(t.map(r));function f(){Promise.all(n.map(e=>bt(e))).then(e=>{c();try{i([...t.map(r),...e])}catch(e){0===(d.f&Pe)&&nt(e,d)}null==u||u.deactivate(),wt()}).catch(e=>{nt(e,d)})}}(i,t,n,t=>{Kt(8,()=>e(...t.map(Fn)),!0)})}function on(e,t=0){return Kt(ke|t,e,!0)}function ln(e){return Kt(524320,e,!0)}function sn(e){var t=e.teardown;if(null!==t){const e=yn,n=xn;wn(!0),kn(null);try{t.call(null)}finally{wn(e),kn(n)}}}function an(e,t=!1){var n=e.first;for(e.first=e.last=null;null!==n;){const e=n.ac;null!==e&&Vt(()=>{e.abort(je)});var i=n.next;64&n.f?n.parent=null:un(n,t),n=i}}function un(e,t=!0){var n=!1;!t&&0===(e.f&Oe)||null===e.nodes||null===e.nodes.end||(function(e,t){for(;null!==e;){var n=e===t?null:Xt(e);e.remove(),e=n}}(e.nodes.start,e.nodes.end),n=!0),an(e,t&&!n),jn(e,0),Gn(e,Pe);var i=e.nodes&&e.nodes.t;if(null!==i)for(const e of i)e.stop();sn(e);var r=e.parent;null!==r&&null!==r.first&&dn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=null}function dn(e){var t=e.parent,n=e.prev,i=e.next;null!==n&&(n.next=i),null!==i&&(i.prev=n),null!==t&&(t.first===e&&(t.first=i),t.last===e&&(t.last=n))}function cn(e,t,n=!0){var i=[];fn(e,i,!0);var r=()=>{n&&un(e),t&&t()},o=i.length;if(o>0){var l=()=>--o||r();for(var s of i)s.out(l)}else r()}function fn(e,t,n){if(0===(e.f&Se)){e.f^=Se;var i=e.nodes&&e.nodes.t;if(null!==i)for(const e of i)(e.is_global||n)&&t.push(e);for(var r=e.first;null!==r;){var o=r.next;fn(r,t,!!(0!==(r.f&Ee)||32&r.f&&0!==(e.f&ke))&&n),r=o}}}function hn(e){pn(e,!0)}function pn(e,t){if(0!==(e.f&Se)){e.f^=Se,0===(e.f&Me)&&(Gn(e,_e),mt(e));for(var n=e.first;null!==n;){var i=n.next;pn(n,!!(0!==(n.f&Ee)||32&n.f)&&t),n=i}var r=e.nodes&&e.nodes.t;if(null!==r)for(const e of r)(e.is_global||t)&&e.in()}}function vn(e,t){if(e.nodes)for(var n=e.nodes.start,i=e.nodes.end;null!==n;){var r=n===i?null:Xt(n);t.append(n),n=r}}let gn=!1;function mn(e){gn=e}let yn=!1;function wn(e){yn=e}let xn=null,bn=!1;function kn(e){xn=e}let zn=null;function Mn(e){zn=e}let _n=null;function In(e){null!==xn&&(null===_n?_n=[e]:_n.push(e))}let Sn=null,Pn=0,Cn=null,En=1,On=0,Dn=On;function Tn(e){Dn=e}function Wn(){return++En}function Rn(e){var t=e.f;if(0!==(t&_e))return!0;if(2&t&&(e.f&=-32769),0!==(t&Ie)){var n=e.deps;if(null!==n)for(var i=n.length,r=0;r<i;r++){var o=n[r];if(Rn(o)&&It(o),o.wv>e.wv)return!0}0!==(t&ze)&&null===ot&&Gn(e,Me)}return!1}function Bn(e,t,n=!0){var i=e.reactions;if(null!==i&&!(null==_n?void 0:_n.includes(e)))for(var r=0;r<i.length;r++){var o=i[r];2&o.f?Bn(o,t,!1):t===o&&(n?Gn(o,_e):0!==(o.f&Me)&&Gn(o,Ie),mt(o))}}function An(e){var t,n=Sn,i=Pn,r=Cn,o=xn,l=_n,s=Xe,a=bn,u=Dn,d=e.f;Sn=null,Pn=0,Cn=null,xn=96&d?null:e,_n=null,Ye(e.ctx),bn=!1,Dn=++On,null!==e.ac&&(Vt(()=>{e.ac.abort(je)}),e.ac=null);try{e.f|=Re;var c=(0,e.fn)(),f=e.deps;if(null!==Sn){var h;if(jn(e,Pn),null!==f&&Pn>0)for(f.length=Pn+Sn.length,h=0;h<Sn.length;h++)f[Pn+h]=Sn[h];else e.deps=f=Sn;if(Qt()&&0!==(e.f&ze))for(h=Pn;h<f.length;h++)((t=f[h]).reactions??(t.reactions=[])).push(e)}else null!==f&&Pn<f.length&&(jn(e,Pn),f.length=Pn);if(!(null===Cn||bn||null===f||6146&e.f))for(h=0;h<Cn.length;h++)Bn(Cn[h],e);return null!==o&&o!==e&&(On++,null!==Cn&&(null===r?r=Cn:r.push(...Cn))),0!==(e.f&Be)&&(e.f^=Be),c}catch(e){return tt(e)}finally{e.f^=Re,Sn=n,Pn=i,Cn=r,xn=o,_n=l,Ye(s),bn=a,Dn=u}}function $n(e,t){let n=t.reactions;if(null!==n){var i=ce.call(n,e);if(-1!==i){var r=n.length-1;0===r?n=t.reactions=null:(n[i]=n[r],n.pop())}}null===n&&2&t.f&&(null===Sn||!Sn.includes(t))&&(Gn(t,Ie),0!==(t.f&ze)&&(t.f^=ze,t.f&=-32769),Mt(t),jn(t,0))}function jn(e,t){var n=e.deps;if(null!==n)for(var i=t;i<n.length;i++)$n(e,n[i])}function Hn(e){var t=e.f;if(0===(t&Pe)){Gn(e,Me);var n=zn,i=gn;zn=e,gn=!0;try{16777232&t?function(e){for(var t=e.first;null!==t;){var n=t.next;!(32&t.f)&&un(t),t=n}}(e):an(e),sn(e);var r=An(e);e.teardown="function"==typeof r?r:null,e.wv=En}finally{gn=i,zn=n}}}async function Ln(){await Promise.resolve(),function(){var e=ut;ut=!0;try{for(;;){if(et(),0===lt.length&&(null==rt||rt.flush(),0===lt.length))return void(st=null);ct()}}finally{ut=e}}()}function Fn(e){var t=!!(2&e.f);if(!(null===xn||bn||null!==zn&&0!==(zn.f&Pe)||(null==_n?void 0:_n.includes(e)))){var n=xn.deps;if(0!==(xn.f&Re))e.rv<On&&(e.rv=On,null===Sn&&null!==n&&n[Pn]===e?Pn++:null===Sn?Sn=[e]:Sn.includes(e)||Sn.push(e));else{(xn.deps??(xn.deps=[])).push(e);var i=e.reactions;null===i?e.reactions=[xn]:i.includes(xn)||i.push(xn)}}if(yn){if(Pt.has(e))return Pt.get(e);if(t){var r=e,o=r.v;return(0===(r.f&Me)&&null!==r.reactions||qn(r))&&(o=_t(r)),Pt.set(r,o),o}}else t&&(!(null==ot?void 0:ot.has(e))||(null==rt?void 0:rt.is_fork)&&!Qt())&&(Rn(r=e)&&It(r),gn&&Qt()&&0===(r.f&ze)&&Nn(r));if(null==ot?void 0:ot.has(e))return ot.get(e);if(0!==(e.f&Be))throw e.v;return e.v}function Nn(e){if(null!==e.deps){e.f^=ze;for(const t of e.deps)(t.reactions??(t.reactions=[])).push(e),2&t.f&&0===(t.f&ze)&&Nn(t)}}function qn(e){if(e.v===Le)return!0;if(null===e.deps)return!1;for(const t of e.deps){if(Pt.has(t))return!0;if(2&t.f&&qn(t))return!0}return!1}function Xn(e){var t=bn;try{return bn=!0,e()}finally{bn=t}}const Yn=-7169;function Gn(e,t){e.f=e.f&Yn|t}function Un(e,t=new Set){if(!("object"!=typeof e||null===e||e instanceof EventTarget||t.has(e))){t.add(e),e instanceof Date&&e.getTime();for(let n in e)try{Un(e[n],t)}catch(e){}const n=ye(e);if(n!==Object.prototype&&n!==Array.prototype&&n!==Map.prototype&&n!==Set.prototype&&n!==Date.prototype){const t=ve(n);for(let n in t){const i=t[n].get;if(i)try{i.call(e)}catch(e){}}}}}const Vn=["touchstart","touchmove"];function Kn(e){return Vn.includes(e)}const Qn=new Set,Jn=new Set;function Zn(e){for(var t=0;t<e.length;t++)Qn.add(e[t]);for(var n of Jn)n(e)}let ei=null;function ti(e){var t,n=this,i=n.ownerDocument,r=e.type,o=(null==(t=e.composedPath)?void 0:t.call(e))||[],l=o[0]||e.target;ei=e;var s=0,a=ei===e&&e.__root;if(a){var u=o.indexOf(a);if(-1!==u&&(n===document||n===window))return void(e.__root=n);var d=o.indexOf(n);if(-1===d)return;u<=d&&(s=u)}if((l=o[s]||e.target)!==n){he(e,"currentTarget",{configurable:!0,get:()=>l||i});var c=xn,f=zn;kn(null),Mn(null);try{for(var h,p=[];null!==l;){var v=l.assignedSlot||l.parentNode||l.host||null;try{var g=l["__"+r];null==g||l.disabled&&e.target!==l||g.call(l,e)}catch(e){h?p.push(e):h=e}if(e.cancelBubble||v===n||null===v)break;l=v}if(h){for(let e of p)queueMicrotask(()=>{throw e});throw h}}finally{e.__root=n,delete e.currentTarget,kn(c),Mn(f)}}}function ni(e,t){var n=zn;null===n.nodes&&(n.nodes={start:e,end:t,a:null,t:null})}function ii(e,t){var n,i=!!(1&t),r=!!(2&t),o=!e.startsWith("<!>");return()=>{var t,l;void 0===n&&(t=o?e:"<!>"+e,(l=document.createElement("template")).innerHTML=t.replaceAll("<!>","\x3c!----\x3e"),n=l.content,i||(n=qt(n)));var s=r||Ht?document.importNode(n,!0):n.cloneNode(!0);return i?ni(qt(s),s.lastChild):ni(s,s),s}}function ri(){var e=document.createDocumentFragment(),t=document.createComment(""),n=Nt();return e.append(t,n),ni(t,n),e}function oi(e,t){null!==e&&e.before(t)}let li=!0;function si(e,t){var n=null==t?"":"object"==typeof t?t+"":t;n!==(e.__t??(e.__t=e.nodeValue))&&(e.__t=n,e.nodeValue=n+"")}function ai(e,t){return function(e,{target:t,anchor:n,props:i={},events:r,context:o,intro:l=!0}){!function(){if(void 0===jt){jt=window,Ht=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;Lt=pe(t,"firstChild").get,Ft=pe(t,"nextSibling").get,we(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),we(n)&&(n.__t=void 0)}}();var s=new Set,a=e=>{for(var n=0;n<e.length;n++){var i=e[n];if(!s.has(i)){s.add(i);var r=Kn(i);t.addEventListener(i,ti,{passive:r});var o=ui.get(i);void 0===o?(document.addEventListener(i,ti,{passive:r}),ui.set(i,1)):ui.set(i,o+1)}}};a(fe(Qn)),Jn.add(a);var u=void 0,d=function(){dt.ensure();const d=Kt(524352,()=>{var d=n??t.appendChild(Nt());return new yt(d,{pending:()=>{}},t=>{o&&(Ue({}),Xe.c=o),r&&(i.$$events=r),li=l,u=e(t,i)||{},li=!0,o&&Ve()}),()=>{var e;for(var i of s){t.removeEventListener(i,ti);var r=ui.get(i);0===--r?(document.removeEventListener(i,ti),ui.delete(i)):ui.set(i,r)}Jn.delete(a),d!==n&&(null==(e=d.parentNode)||e.removeChild(d))}},!0);return(e={})=>new Promise(t=>{e.outro?cn(d,()=>{un(d),t(void 0)}):(un(d),t(void 0))})}();return di.set(u,d),u}(e,t)}const ui=new Map;let di=new WeakMap;function ci(e,t){const n=di.get(e);return n?(di.delete(e),n(t)):Promise.resolve()}class fi{constructor(e,t=!0){q(this,"anchor"),G(this,W,new Map),G(this,R,new Map),G(this,B,new Map),G(this,A,new Set),G(this,$,!0),G(this,j,()=>{var e=rt;if(Y(this,W).has(e)){var t=Y(this,W).get(e),n=Y(this,R).get(t);if(n)hn(n),Y(this,A).delete(t);else{var i=Y(this,B).get(t);i&&(Y(this,R).set(t,i.effect),Y(this,B).delete(t),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),n=i.effect)}for(const[t,n]of Y(this,W)){if(Y(this,W).delete(t),t===e)break;const i=Y(this,B).get(n);i&&(un(i.effect),Y(this,B).delete(n))}for(const[e,i]of Y(this,R)){if(e===t||Y(this,A).has(e))continue;const r=()=>{if(Array.from(Y(this,W).values()).includes(e)){var t=document.createDocumentFragment();vn(i,t),t.append(Nt()),Y(this,B).set(e,{effect:i,fragment:t})}else un(i);Y(this,A).delete(e),Y(this,R).delete(e)};Y(this,$)||!n?(Y(this,A).add(e),cn(i,r,!1)):r()}}}),G(this,H,e=>{Y(this,W).delete(e);const t=Array.from(Y(this,W).values());for(const[e,n]of Y(this,B))t.includes(e)||(un(n.effect),Y(this,B).delete(e))}),this.anchor=e,U(this,$,t)}ensure(e,t){var n=rt;!t||Y(this,R).has(e)||Y(this,B).has(e)||Y(this,R).set(e,ln(()=>t(this.anchor))),Y(this,W).set(n,e),Y(this,j).call(this)}}function hi(e,t,n=!1){var i=new fi(e);function r(e,t){i.ensure(e,t)}on(()=>{var e=!1;t((t,n=!0)=>{e=!0,r(n,t)}),e||r(!1,null)},n?Ee:0)}function pi(e,t){return t}function vi(e,t=!0){for(var n=0;n<e.length;n++)un(e[n],t)}var gi;function mi(e,t,n,i,r,o=null){var l=e,s=new Map;!(4&t)||(l=e.appendChild(Nt()));var a,u=null,d=zt(()=>{var e=n();return de(e)?e:null==e?[]:fe(e)}),c=!0,f={effect:on(()=>{for(var e=(a=Fn(d)).length,h=new Set,p=0;p<e;p+=1){var v=a[p],g=i(v,p),m=c?null:s.get(g);m?(m.v&&Wt(m.v,v),m.i&&Wt(m.i,p)):(m=yi(s,c?l:gi??(gi=Nt()),v,g,p,r,t,n),c||(m.e.f|=Te),s.set(g,m)),h.add(g)}0===e&&o&&!u&&(c?u=ln(()=>o(l)):(u=ln(()=>o(gi??(gi=Nt())))).f|=Te),c||(f.fallback=u,function(e,t,n,i,r){var o,l,s,a,u,d,c,f,h,p,v,g,m,y,w=!!(8&i),x=t.length,b=e.items,k=e.effect.first,z=null,M=[],_=[];if(w)for(y=0;y<x;y+=1)g=r(t[y],y),0===((m=b.get(g).e).f&Te)&&(null==(l=null==(o=m.nodes)?void 0:o.a)||l.measure(),(v??(v=new Set)).add(m));for(y=0;y<x;y+=1){if(g=r(t[y],y),m=b.get(g).e,null!==e.outrogroups)for(const t of e.outrogroups)t.pending.delete(m),t.done.delete(m);if(0!==(m.f&Te)){if(m.f^=Te,m!==k){var I=z?z.next:k;m===e.effect.last&&(e.effect.last=m.prev),m.prev&&(m.prev.next=m.next),m.next&&(m.next.prev=m.prev),xi(e,z,m),xi(e,m,I),wi(m,I,n),M=[],_=[],k=(z=m).next;continue}wi(m,null,n)}if(0!==(m.f&Se)&&(hn(m),w&&(null==(a=null==(s=m.nodes)?void 0:s.a)||a.unfix(),(v??(v=new Set)).delete(m))),m!==k){if(void 0!==p&&p.has(m)){if(M.length<_.length){var S,P=_[0];z=P.prev;var C=M[0],E=M[M.length-1];for(S=0;S<M.length;S+=1)wi(M[S],P,n);for(S=0;S<_.length;S+=1)p.delete(_[S]);xi(e,C.prev,E.next),xi(e,z,C),xi(e,E,P),k=P,z=E,y-=1,M=[],_=[]}else p.delete(m),wi(m,k,n),xi(e,m.prev,m.next),xi(e,m,null===z?e.effect.first:z.next),xi(e,z,m),z=m;continue}for(M=[],_=[];null!==k&&k!==m;)(p??(p=new Set)).add(k),_.push(k),k=k.next;if(null===k)continue}0===(m.f&Te)&&M.push(m),z=m,k=m.next}if(null!==e.outrogroups){for(const t of e.outrogroups)0===t.pending.size&&(vi(fe(t.done)),null==(u=e.outrogroups)||u.delete(t));0===e.outrogroups.size&&(e.outrogroups=null)}if(null!==k||void 0!==p){var O=[];if(void 0!==p)for(m of p)0===(m.f&Se)&&O.push(m);for(;null!==k;)0===(k.f&Se)&&k!==e.fallback&&O.push(k),k=k.next;var D=O.length;if(D>0){var T=4&i&&0===x?n:null;if(w){for(y=0;y<D;y+=1)null==(c=null==(d=O[y].nodes)?void 0:d.a)||c.measure();for(y=0;y<D;y+=1)null==(h=null==(f=O[y].nodes)?void 0:f.a)||h.fix()}!function(e,t,n){for(var i,r=t.length,o=t.length,l=0;l<r;l++){let n=t[l];cn(n,()=>{if(i){if(i.pending.delete(n),i.done.add(n),0===i.pending.size){var t=e.outrogroups;vi(fe(i.done)),t.delete(i),0===t.size&&(e.outrogroups=null)}}else o-=1},!1)}if(0===o){var s=null!==n;if(s){var a=n,u=a.parentNode;u.textContent="",u.append(a),e.items.clear()}vi(t,!s)}else i={pending:new Set(t),done:new Set},(e.outrogroups??(e.outrogroups=new Set)).add(i)}(e,O,T)}}w&&Ze(()=>{var e,t;if(void 0!==v)for(m of v)null==(t=null==(e=m.nodes)?void 0:e.a)||t.apply()})}(f,a,l,t,i),null!==u&&(0===a.length?0===(u.f&Te)?hn(u):(u.f^=Te,wi(u,null,l)):cn(u,()=>{u=null}))),Fn(d)}),items:s,outrogroups:null,fallback:u};c=!1}function yi(e,t,n,i,r,o,l,s){var a=1&l?16&l?Et(n):Dt(n,!1,!1):null,u=2&l?Et(r):null;return{v:a,i:u,e:ln(()=>(o(t,a??n,u??r,s),()=>{e.delete(i)}))}}function wi(e,t,n){if(e.nodes)for(var i=e.nodes.start,r=e.nodes.end,o=t&&0===(t.f&Te)?t.nodes.start:n;null!==i;){var l=Xt(i);if(o.before(i),i===r)return;i=l}}function xi(e,t,n){null===t?e.effect.first=n:t.next=n,null===n?e.effect.last=t:n.prev=t}function bi(e,t,...n){var i=new fi(e);on(()=>{const e=t()??null;i.ensure(e,e&&(t=>e(t,...n)))},Ee)}W=new WeakMap,R=new WeakMap,B=new WeakMap,A=new WeakMap,$=new WeakMap,j=new WeakMap,H=new WeakMap;const ki={tick:e=>requestAnimationFrame(e),now:()=>performance.now(),tasks:new Set};function zi(){const e=ki.now();ki.tasks.forEach(t=>{t.c(e)||(ki.tasks.delete(t),t.f())}),0!==ki.tasks.size&&ki.tick(zi)}function Mi(e,t){Vt(()=>{e.dispatchEvent(new CustomEvent(t))})}function _i(e){if("float"===e)return"cssFloat";if("offset"===e)return"cssOffset";if(e.startsWith("--"))return e;const t=e.split("-");return 1===t.length?t[0]:t[0]+t.slice(1).map(e=>e[0].toUpperCase()+e.slice(1)).join("")}function Ii(e){const t={},n=e.split(";");for(const e of n){const[n,i]=e.split(":");if(!n||void 0===i)break;t[_i(n.trim())]=i.trim()}return t}const Si=e=>e;function Pi(e,t,n,i){var r,o,l,s,a=!!(4&e),u=t.inert,d=t.style.overflow;function c(){return Vt(()=>o??(o=n()(t,(null==i?void 0:i())??{},{direction:"both"})))}var f={is_global:a,in(){t.inert=u,Mi(t,"introstart"),l=Ci(t,c(),s,1,()=>{Mi(t,"introend"),null==l||l.abort(),l=o=void 0,t.style.overflow=d})},out(e){t.inert=!0,Mi(t,"outrostart"),s=Ci(t,c(),l,0,()=>{Mi(t,"outroend"),null==e||e()})},stop:()=>{null==l||l.abort(),null==s||s.abort()}},h=zn;if(((r=h.nodes).t??(r.t=[])).push(f),li){var p=a;if(!p){for(var v=h.parent;v&&0!==(v.f&Ee);)for(;(v=v.parent)&&0===(v.f&ke););p=!v||0!==(v.f&Ce)}p&&tn(()=>{Xn(()=>f.in())})}}function Ci(e,t,n,i,r){var o=1===i;if("function"==typeof t){var l,s=!1;return Ze(()=>{if(!s){var a=t({direction:o?"in":"out"});l=Ci(e,a,n,i,r)}}),{abort:()=>{s=!0,null==l||l.abort()},deactivate:()=>l.deactivate(),reset:()=>l.reset(),t:()=>l.t()}}if(null==n||n.deactivate(),!(null==t?void 0:t.duration))return r(),{abort:xe,deactivate:xe,reset:xe,t:()=>i};const{delay:a=0,css:u,tick:d,easing:c=Si}=t;var f=[];if(o&&void 0===n&&(d&&d(0,1),u)){var h=Ii(u(0,1));f.push(h,h)}var p=()=>1-i,v=e.animate(f,{duration:a,fill:"forwards"});return v.onfinish=()=>{v.cancel();var o=(null==n?void 0:n.t())??1-i;null==n||n.abort();var l=i-o,s=t.duration*Math.abs(l),a=[];if(s>0){var f=!1;if(u)for(var h=Math.ceil(s/(1e3/60)),g=0;g<=h;g+=1){var m=o+l*c(g/h),y=Ii(u(m,1-m));a.push(y),f||(f="hidden"===y.overflow)}f&&(e.style.overflow="hidden"),p=()=>{var e=v.currentTime;return o+l*c(e/s)},d&&function(e){let t;0===ki.tasks.size&&ki.tick(zi),new Promise(n=>{ki.tasks.add(t={c:e,f:n})})}(()=>{if("running"!==v.playState)return!1;var e=p();return d(e,1-e),!0})}(v=e.animate(a,{duration:s,fill:"forwards"})).onfinish=()=>{p=()=>i,null==d||d(i,1-i),r()}},{abort:()=>{v&&(v.cancel(),v.effect=null,v.onfinish=xe)},deactivate:()=>{r=xe},reset:()=>{0===i&&(null==d||d(1,0))},t:()=>p()}}function Ei(e,t,n){tn(()=>{var i=Xn(()=>t(e,null==n?void 0:n())||{});if(n&&(null==i?void 0:i.update)){var r=!1,o={};nn(()=>{var e=n();!function(e){if("object"==typeof e&&e&&!(e instanceof EventTarget))if(Ae in e)Un(e);else if(!Array.isArray(e))for(let t in e){const n=e[t];"object"==typeof n&&n&&Ae in n&&Un(n)}}(e),r&&Ne(o,e)&&(o=e,i.update(e))}),r=!0}if(null==i?void 0:i.destroy)return()=>i.destroy()})}const Oi=[..." \t\n\r\f \v\ufeff"];function Di(e,t=!1){var n=t?" !important;":";",i="";for(var r in e){var o=e[r];null!=o&&""!==o&&(i+=" "+r+": "+o+n)}return i}function Ti(e){return"-"!==e[0]||"-"!==e[1]?e.toLowerCase():e}function Wi(e,t,n,i,r,o){var l=e.__className;if(l!==n||void 0===l){var s=function(e,t,n){var i=null==e?"":""+e;if(t&&(i=i?i+" "+t:t),n)for(var r in n)if(n[r])i=i?i+" "+r:r;else if(i.length)for(var o=r.length,l=0;(l=i.indexOf(r,l))>=0;){var s=l+o;0!==l&&!Oi.includes(i[l-1])||s!==i.length&&!Oi.includes(i[s])?l=s:i=(0===l?"":i.substring(0,l))+i.substring(s+1)}return""===i?null:i}(n,i,o);null==s?e.removeAttribute("class"):e.className=s,e.__className=n}else if(o&&r!==o)for(var a in o){var u=!!o[a];null!=r&&u===!!r[a]||e.classList.toggle(a,u)}return o}function Ri(e,t={},n,i){for(var r in n){var o=n[r];t[r]!==o&&(null==n[r]?e.style.removeProperty(r):e.style.setProperty(r,o,i))}}function Bi(e,t,n,i){if(e.__style!==t){var r=function(e,t){if(t){var n,i,r="";if(Array.isArray(t)?(n=t[0],i=t[1]):n=t,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var o=!1,l=0,s=!1,a=[];n&&a.push(...Object.keys(n).map(Ti)),i&&a.push(...Object.keys(i).map(Ti));var u=0,d=-1;const t=e.length;for(var c=0;c<t;c++){var f=e[c];if(s?"/"===f&&"*"===e[c-1]&&(s=!1):o?o===f&&(o=!1):"/"===f&&"*"===e[c+1]?s=!0:'"'===f||"'"===f?o=f:"("===f?l++:")"===f&&l--,!s&&!1===o&&0===l)if(":"===f&&-1===d)d=c;else if(";"===f||c===t-1){if(-1!==d){var h=Ti(e.substring(u,d).trim());a.includes(h)||(";"!==f&&c++,r+=" "+e.substring(u,c).trim()+";")}u=c+1,d=-1}}}return n&&(r+=Di(n)),i&&(r+=Di(i,!0)),""===(r=r.trim())?null:r}return null==e?null:String(e)}(t,i);null==r?e.removeAttribute("style"):e.style.cssText=r,e.__style=t}else i&&(Array.isArray(i)?(Ri(e,null==n?void 0:n[0],i[0]),Ri(e,null==n?void 0:n[1],i[1],"important")):Ri(e,n,i));return i}const Ai=Symbol("is custom element"),$i=Symbol("is html");function ji(e,t,n,i){var r=function(e){return e.__attributes??(e.__attributes={[Ai]:e.nodeName.includes("-"),[$i]:"http://www.w3.org/1999/xhtml"===e.namespaceURI})}(e);r[t]!==(r[t]=n)&&("loading"===t&&(e[$e]=n),null==n?e.removeAttribute(t):"string"!=typeof n&&function(e){var t,n=e.getAttribute("is")||e.nodeName,i=Hi.get(n);if(i)return i;Hi.set(n,i=[]);for(var r=e,o=Element.prototype;o!==r;){for(var l in t=ve(r))t[l].set&&i.push(l);r=ye(r)}return i}(e).includes(t)?e[t]=n:e.setAttribute(t,n))}var Hi=new Map;function Li(e,t){return e===t||(null==e?void 0:e[Ae])===t}function Fi(e={},t,n,i){return tn(()=>{var i,r;return nn(()=>{i=r,r=[],Xn(()=>{e!==n(...r)&&(t(e,...r),i&&Li(n(...i),e)&&t(null,...i))})}),()=>{Ze(()=>{r&&Li(n(...r),e)&&t(null,...r)})}}),e}function Ni(e,t,n,i){var r=i,o=!0,l=()=>(o&&(o=!1,r=i),r);return void 0===e[t]&&void 0!==i&&l(),()=>{var n=e[t];return void 0===n?l():(o=!0,n)}}function qi(e){null===Xe&&He(),Zt(()=>{const t=Xn(e);if("function"==typeof t)return t})}"undefined"!=typeof window&&((L=window.__svelte??(window.__svelte={})).v??(L.v=new Set)).add("5");const Xi=Symbol("modal-render-icon"),Yi=Symbol("modal-id"),Gi={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},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 Ui={...Gi},Vi=Ot(0);function Ki(){return Fn(Vi)}function Qi(){return Ui}function Ji(e){const t=Ui;var n,i;Ui={features:{...(n=Gi).features,...(i=e).features},dock:{...n.dock,...i.dock},animations:{...n.animations,...i.animations},appearance:{...n.appearance,...i.appearance},zIndex:{...n.zIndex,...i.zIndex},parentChild:{...n.parentChild,...i.parentChild},positioning:{...n.positioning,...i.positioning},portalTarget:i.portalTarget??n.portalTarget},Rt(Vi),t.features.dock&&!Ui.features.dock&&(Array.from(sr.values()).filter(e=>e.isMinimized).map(e=>e.id).forEach(e=>{const t=sr.get(e);if(t){sr.set(e,{...t,isMinimized:!1,isOpen:!0}),Tt(gr,[...Fn(gr),e],!0),Wr(e);const n=t.lastChildId||t.childId;n&&Or(n)}}),Tt(Ir,[],!0),dr())}let Zi=Ot($t(400));const er=8;function tr(e,t,n,i,r={}){const{margin:o=er,allowPartialVisibility:l=!1}=r,s="undefined"!=typeof window?window.innerWidth:1920,a="undefined"!=typeof window?window.innerHeight:1080;let u,d,c,f;return l&&n>s-2*o?(u=40-n,d=s-40):(u=o,d=Math.max(o,s-n-o)),l&&i>a-2*o?(c=40-i,f=a-40):(c=o,f=Math.max(o,a-i-o)),{x:Math.max(u,Math.min(d,e)),y:Math.max(c,Math.min(f,t))}}function nr(e,t,n,i,r={}){const{margin:o=er}=r,l=("undefined"!=typeof window?window.innerWidth:1920)-2*o,s=("undefined"!=typeof window?window.innerHeight:1080)-2*o,a=Math.min(n,l),u=Math.min(i,s),d=tr(e,t,a,u,r);return{x:d.x,y:d.y,width:a,height:u}}function ir(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 rr(e,t,n,i,r,o){const l={x:e-o,y:t-o,width:n+2*o,height:i+2*o};let s=0;for(const e of r)s+=ir(l,e);return s}function or(e,t,n,i,r,o,l){const s=(r-n)/2,a=(o-i)/2,u=s-l,d=a-l,c=Math.abs(e-s)/(u||1),f=Math.abs(t-a)/(d||1),h=Math.sqrt(c*c+f*f)/Math.SQRT2,p=50,v=e-l,g=r-n-l-e,m=t-l,y=o-i-l-t;let w=0;return v<p&&(w+=.3*(1-v/p)),g<p&&(w+=.3*(1-g/p)),m<p&&(w+=.2*(1-m/p)),y<p&&(w+=.2*(1-y/p)),Math.min(1,h+w)}function lr(e){return"symbol"==typeof e?e.description??"symbol":e}let sr=$t(new Map),ar=Ot(0);const ur=new Set;function dr(){Rt(ar),queueMicrotask(()=>{ur.forEach(e=>e())})}function cr(e){return ur.add(e),()=>ur.delete(e)}let fr=Ot($t([])),hr=Ot($t([])),pr=Ot($t([])),vr=Ot($t([])),gr=Ot($t([])),mr=Ot($t([])),yr=Ot($t([])),wr=Ot($t([])),xr=Ot(null),br=$t(new Map),kr=Ot(null),zr=$t(new Map),Mr=$t(new Set),_r=$t(new Set),Ir=Ot($t([]));function Sr(e){const t=sr.get(e.id),n=(null==t?void 0:t.zIndex)??function(){const e=Fn(Zi);return Tt(Zi,Fn(Zi)+2),e}();t?sr.set(e.id,{...t,title:e.title,icon:e.icon,glow:e.glow,zIndex:n}):sr.set(e.id,{...e,zIndex:n,isAnimating:!1}),dr(),e.isMinimized&&!Fn(Ir).includes(e.id)&&Fn(Ir).push(e.id)}function Pr(e){const t=sr.get(e);if(t){if(Tt(Ir,Fn(Ir).filter(t=>t!==e),!0),t.childId){const e=sr.get(t.childId);e&&sr.set(t.childId,{...e,parentId:void 0})}if(t.parentId){const e=sr.get(t.parentId);e&&sr.set(t.parentId,{...e,childId:void 0,lastChildId:t.id})}sr.delete(e),dr(),_r.delete(e),Mr.delete(e)}}function Cr(e){const t=sr.get(e);if(!t||t.isMinimized)return;if(to(e),t.parentId){const e=sr.get(t.parentId);if(e&&!e.isMinimized)return void Cr(t.parentId)}Tt(fr,[...Fn(fr),e],!0),t.position&&t.size;const n=t.childId;sr.set(e,{...t,isMinimized:!0,lastChildId:n}),dr(),Fn(Ir).includes(e)||Fn(Ir).push(e),t.childId&&function(e){const t=sr.get(e);if(!(null==t?void 0:t.childId))return;const n=sr.get(t.childId);n&&(sr.set(t.childId,{...n,isHiddenWithParent:!0}),dr())}(e)}function Er(e){const t=sr.get(e);if(!t||!t.isMinimized)return;sr.set(e,{...t,isMinimized:!1,isOpen:!0}),dr(),Tt(gr,[...Fn(gr),e],!0),Wr(e);const n=t.lastChildId||t.childId;n&&Or(n)}function Or(e){const t=sr.get(e);t&&t.isHiddenWithParent&&(sr.set(e,{...t,isHiddenWithParent:!1}),dr(),Tt(mr,[...Fn(mr),e],!0))}function Dr(e,t,n){const i=sr.get(e);if(!i)return;let r=t;if((null==n?void 0:n.constrain)&&i.size&&(r=tr(t.x,t.y,i.size.width,i.size.height)),sr.set(e,{...i,position:r,size:(null==n?void 0:n.size)??i.size,hasBeenDragged:i.hasBeenDragged||(null==n?void 0:n.drag)||!1}),i.childId){let t=e,n=r;for(;;){const e=sr.get(t);if(!(null==e?void 0:e.childId))break;const i=sr.get(e.childId);if(!(null==i?void 0:i.offsetFromParent))break;const r={x:n.x+i.offsetFromParent.x,y:n.y+i.offsetFromParent.y};sr.set(e.childId,{...i,position:r,hasBeenDragged:!0}),t=e.childId,n=r}}if(i.parentId&&i.offsetFromParent){const t=Qi();let n=e,o=i;for(;o.parentId&&o.offsetFromParent;){const i=sr.get(o.parentId);if(!i)break;const l=n===e?r:sr.get(n).position,s={x:l.x-o.offsetFromParent.x,y:l.y-o.offsetFromParent.y};"animated"===t.parentChild.movementMode?zr.set(o.parentId,s):sr.set(o.parentId,{...i,position:s,hasBeenDragged:!0}),n=o.parentId,o=i}}dr()}function Tr(e,t){const n=sr.get(e);n&&(sr.set(e,{...n,...t}),dr())}function Wr(e){var t;const n=sr.get(e);if(!n)return;const i=Math.max(...Array.from(sr.values()).map(e=>e.zIndex),0);if(n.parentId){const r=sr.get(n.parentId);r&&r.zIndex<i&&sr.set(n.parentId,{...r,zIndex:i+2});const o=(null==(t=sr.get(n.parentId))?void 0:t.zIndex)??i+2;return n.zIndex<=o&&sr.set(e,{...n,zIndex:o+2}),void dr()}if(n.zIndex<i&&(sr.set(e,{...n,zIndex:i+2}),dr()),n.childId){const t=sr.get(n.childId),i=sr.get(e);t&&i&&t.zIndex<=i.zIndex&&(sr.set(n.childId,{...t,zIndex:i.zIndex+2}),dr())}}function Rr(e){const t=sr.get(e);if(!t)return!1;const n=Math.max(...Array.from(sr.values()).map(e=>e.zIndex),0);return t.zIndex===n&&!t.isMinimized&&!t.isHiddenWithParent}function Br(e){Tt(Ir,e,!0)}function Ar(e,t,n){const i=t.getBoundingClientRect();br.set(e,{x:i.left+i.width/2,y:i.top+i.height/2});const r=Qi();(null==n?void 0:n.parentId)&&r.features.parentChild&&Tt(kr,{parentId:n.parentId,childId:e},!0),Fn(hr).includes(e)||Tt(hr,[...Fn(hr),e],!0),dr();const o=sr.get(e);if(o){if(o.isOpen&&!o.isMinimized&&!o.isHiddenWithParent)return Tt(hr,Fn(hr).filter(t=>t!==e),!0),Vr(e),void Wr(e);if(o.isMinimized)return Tt(hr,Fn(hr).filter(t=>t!==e),!0),void Er(e);sr.set(e,{...o,isOpen:!0}),Wr(e)}}function $r(e,t=!1){const n=sr.get(e);n&&(to(e),t?Tt(vr,[...Fn(vr),e],!0):Tt(pr,[...Fn(pr),e],!0),dr(),n.childId&&$r(n.childId,t))}function jr(){Array.from(sr.keys()).forEach(e=>$r(e,!0))}function Hr(e,t,n){const i=Qi();if(n&&!br.has(e.id)){const t=n.getBoundingClientRect();br.set(e.id,{x:t.left+t.width/2,y:t.top+t.height/2})}const r={id:e.id,title:e.title??"",icon:e.icon??"",isOpen:!0,isMinimized:!1,isHiddenWithParent:!1,isTransparent:e.isTransparent??!1,isRejected:!1,position:e.position??null,size:e.size??null,hasBeenDragged:e.hasBeenDragged??!1,dockPosition:e.dockPosition??-1,glow:e.glow??null};if(!i.features.parentChild){Sr(r);const t=sr.get(e.id);return t&&sr.set(e.id,{...t,isOpen:!0}),Tt(hr,[...Fn(hr),e.id],!0),dr(),void Wr(e.id)}const o=sr.get(t);if(!o)return;o.childId&&$r(o.childId,!0),Sr({...r,parentId:t});const l=sr.get(e.id);l&&sr.set(e.id,{...l,isOpen:!0,parentId:t}),Tt(hr,[...Fn(hr),e.id],!0),dr(),Wr(e.id),Tt(kr,{parentId:t,childId:e.id},!0)}function Lr(e){return Fn(fr).includes(e)}function Fr(e){return sr.get(e)}function Nr(){return Fn(ar)}function qr(e){return Fn(pr).includes(e)}function Xr(e){return Fn(vr).includes(e)}function Yr(e){return!!Fn(vr).includes(e)&&(Tt(vr,Fn(vr).filter(t=>t!==e),!0),!0)}function Gr(e){return Fn(gr).includes(e)}function Ur(e){return Fn(mr).includes(e)}function Vr(e){sr.get(e)&&(Fn(yr).includes(e)||Fn(wr).includes(e)||(Tt(yr,[...Fn(yr),e],!0),dr()))}function Kr(e){const t=sr.get(e);return void 0!==t&&t.isOpen&&!t.isMinimized&&!t.isHiddenWithParent}function Qr(e){return sr.has(e)}function Jr(){return{get modals(){return sr},get pendingMinimize(){return Fn(fr)},get pendingOpen(){return Fn(hr)},get pendingClose(){return Fn(pr)},get pendingRestore(){return Fn(gr)},get dockOrder(){return Fn(Ir)}}}function Zr(e){_r.has(e)?_r.delete(e):_r.add(e);const t=sr.get(e);t&&(sr.set(e,{...t,isTransparent:_r.has(e)}),dr())}function eo(e){_r.delete(e);const t=sr.get(e);t&&(sr.set(e,{...t,isTransparent:!1}),dr())}function to(e){zr.delete(e)}function no(){return Qi().features.animations}const io=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function ro(e){return Array.from(e.querySelectorAll(io)).filter(e=>null!==e.offsetParent||"A"===e.tagName)}function oo(e,t){if("Tab"!==e.key)return;const n=ro(t);if(0===n.length)return void e.preventDefault();const i=n[0],r=n[n.length-1],o=document.activeElement;e.shiftKey?o===i&&(r.focus(),e.preventDefault()):o===r&&(i.focus(),e.preventDefault())}function lo(e){const t=ro(e);return t.length>0&&(t[0].focus(),!0)}const so="modal-portal";var ao=ii('<div style="display: contents;"><!></div>');function uo(e,t){Ue(t,!0);let n=Ni(t,"target",0,"body"),i=null,r=null;const{mount:o}={mount:function(e,t=null){const n=function(e){if("undefined"==typeof window)return null;if(e instanceof HTMLElement)return e;if("string"==typeof e){const t=document.querySelector(e);if(t)return t;if(e.startsWith("#")){const t=e.slice(1),n=document.createElement("div");return n.id=t,document.body.appendChild(n),n}}let t=document.getElementById(so);return t||(t=document.createElement("div"),t.id=so,document.body.appendChild(t)),t}(t);return n?(n.appendChild(e),()=>{e.parentNode===n&&n.removeChild(e),n.id!==so&&0===n.children.length&&n.parentNode&&n.parentNode.removeChild(n)}):()=>{}}};qi(()=>(i&&(r=o(i,n())),()=>{null==r||r()}));var l=ao();bi(Yt(l),()=>t.children),Fi(l,e=>i=e,()=>i),oi(e,l),Ve()}var co=ii('<button type="button" aria-label="Minimize"></button>'),fo=ii('<button type="button" class="modal-header-light modal-header-light-style" aria-label="Toggle style"></button>'),ho=ii('<div class="modal-header-icon"><!></div>'),po=ii('<div class="modal-header-icon"><!></div>'),vo=ii('<h2 class="modal-header-title"> </h2>'),go=ii('<h2 class="modal-header-title"> </h2>'),mo=ii('<div class="modal-header-traffic-lights"><button type="button" class="modal-header-light modal-header-light-close" aria-label="Close"></button> <!> <!></div> <div class="modal-header-mac-center"><!> <div class="modal-header-title-group"><!></div></div> <div class="modal-header-mac-spacer"></div>',1),yo=ii('<div class="modal-header-icon"><!></div>'),wo=ii('<div class="modal-header-icon"><!></div>'),xo=ii('<h2 class="modal-header-title"> </h2>'),bo=ii('<h2 class="modal-header-title"> </h2>'),ko=ii('<button type="button" class="modal-header-btn-windows modal-header-btn-windows-style" aria-label="Toggle style">◇</button>'),zo=ii('<button type="button" aria-label="Minimize">–</button>'),Mo=ii('<div class="modal-header-title-group"><!> <!></div> <div class="modal-header-actions"><!> <!> <button type="button" class="modal-header-btn-windows modal-header-btn-windows-close" aria-label="Close">×</button></div>',1),_o=ii("<header><!></header>");Zn(["pointerdown","click"]);var Io=ii("<div></div>"),So=ii('<div class="modal-resize-handles"></div>');function Po(e,t){return t&&e.appendChild(t),{update(t){e.innerHTML="",t&&e.appendChild(t)},destroy(){e.innerHTML=""}}}Zn(["pointerdown"]);var Co=ii('<div class="modal-footer"><!></div>'),Eo=ii("<div></div>"),Oo=ii('<div role="dialog" aria-modal="true" tabindex="-1"><!> <div class="modal-body"><!></div> <!> <!> <!></div>');function Do(e,t){Ue(t,!0);let n=Ni(t,"maxWidth",0,"600px"),i=Ni(t,"autoOpen",0,!1),r=Ni(t,"closeOnEscape",0,!0),o=Ni(t,"skipRegistration",0,!1);var l,s;l=Yi,s=t.id,Ke().set(l,s);const a=Qi().portalTarget,u=lr(t.id);function d(e){var n,i;return(null==(i=null==(n=t.config)?void 0:n.features)?void 0:i[e])??function(e){return Ui.features[e]}(e)}const c=kt(()=>(Ki(),d("drag"))),f=kt(()=>(Ki(),d("minimize"))),h=kt(()=>(Ki(),!d("dock"))),p=kt(()=>(Ki(),d("transparency"))),v=kt(()=>(Ki(),d("resize"))),g=kt(()=>{var e,n;return Ki(),(null==(n=null==(e=t.config)?void 0:e.appearance)?void 0:n.headerLayout)??Qi().appearance.headerLayout});let m=Ot(null),y=Ot(!1),w=Ot(!1),x=Ot(!1),b=Ot(!1),k=Ot(!1);const z=kt(()=>(Nr(),Fr(t.id))),M=kt(()=>Fn(z)&&(Fn(z).isOpen||qr(t.id))&&(!Fn(z).isMinimized||Lr(t.id))&&!Fn(z).isHiddenWithParent),_=kt(()=>{var e;return!!(null==(e=Fn(z))?void 0:e.childId)}),I=kt(()=>{var e;return!!(null==(e=Fn(z))?void 0:e.parentId)}),S=kt(()=>Fn(_)||Fn(w)),P=kt(()=>!!t.glow),C=kt(()=>`modal-title-${u}`),E=kt(()=>{var e;return(null==(e=Fn(z))?void 0:e.zIndex)??1e3}),O=function(e={x:0,y:0}){const t=$t({...e}),n=$t({isDragging:!1,startX:0,startY:0,initialX:0,initialY:0,hasBeenDragged:!1});return{get position(){return t},get hasBeenDragged(){return n.hasBeenDragged},get isDragging(){return n.isDragging},onPointerDown:function(e,i){if(0===e.button){if(!n.hasBeenDragged){const e=i.getBoundingClientRect();t.x=e.left,t.y=e.top}n.isDragging=!0,n.startX=e.clientX,n.startY=e.clientY,n.initialX=t.x,n.initialY=t.y,i.setPointerCapture(e.pointerId)}},onPointerMove:function(e,i,r){if(!n.isDragging)return;const o=e.clientX-n.startX,l=e.clientY-n.startY,s=tr(n.initialX+o,n.initialY+l,r.width,r.height);t.x=s.x,t.y=s.y,n.hasBeenDragged=!0},onPointerUp:function(e,t){n.isDragging&&(n.isDragging=!1,t.releasePointerCapture(e.pointerId))},setPosition:function(e){t.x=e.x,t.y=e.y},setHasBeenDragged:function(e){n.hasBeenDragged=e},reset:function(){t.x=e.x,t.y=e.y,n.hasBeenDragged=!1}}}({x:0,y:0});let D=Ot(!1);const T=function(e,n,i){let r=Ot(!1),o=Ot(""),l=Ot($t({width:0,height:0})),s=Ot(!1),a=Ot(!1),u={x:0,y:0,width:0,height:0,posX:0,posY:0},d=null;function c(t,a){t.preventDefault(),t.stopPropagation();const c=e();if(!c)return;const p=c.getBoundingClientRect();O.hasBeenDragged||(i({x:p.left,y:p.top}),O.setHasBeenDragged(!0)),Fn(s)||(Tt(l,{width:p.width,height:p.height},!0),Tt(s,!0));const v=n();Tt(r,!0),Tt(o,a,!0),d=t.pointerId,u={x:t.clientX,y:t.clientY,width:Fn(l).width,height:Fn(l).height,posX:v.x,posY:v.y,centerX:v.x+Fn(l).width/2,centerY:v.y+Fn(l).height/2},window.addEventListener("pointermove",f),window.addEventListener("pointerup",h),window.addEventListener("pointercancel",h)}function f(e){if(e.pointerId!==d)return;const t=e.clientX-u.x,n=e.clientY-u.y,r=window.innerWidth,s=window.innerHeight;let a=u.width,c=u.height,f=u.posX,h=u.posY;if(Fn(o).includes("e")){const e=r-f;a=Math.max(280,Math.min(u.width+t,e))}if(Fn(o).includes("w")){const e=u.width-280,n=Math.min(t,e);a=u.width-n,f=u.posX+n}if(Fn(o).includes("s")){const e=s-h;c=Math.max(200,Math.min(u.height+n,e))}if(Fn(o).includes("n")){const e=u.height-200,t=Math.min(n,e);c=u.height-t,h=u.posY+t}const p=nr(f,h,a,c);Tt(l,{width:p.width,height:p.height},!0),i({x:p.x,y:p.y})}function h(e){e.pointerId===d&&(Tt(r,!1),d=null,window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h),Tt(a,!0),((e,n)=>{const i=Fr(t.id);if(null==i?void 0:i.parentId){const e=Fr(i.parentId),r=document.querySelector(`[data-modal-id="${lr(i.parentId)}"]`);if(e&&r){const i=e.position??{x:r.getBoundingClientRect().left,y:r.getBoundingClientRect().top},o=e.size??{width:r.offsetWidth,height:r.offsetHeight},l={x:i.x+(o.width-n.width)/2,y:i.y+(o.height-n.height)/2};Tt(D,!0),O.setPosition(l);const s={x:l.x-i.x,y:l.y-i.y};return Tr(t.id,{position:l,size:n,hasBeenDragged:!0,offsetFromParent:s}),void setTimeout(()=>{Tt(D,!1)},200)}}Tr(t.id,{position:e,size:n,hasBeenDragged:!0})})(n(),Fn(l)),setTimeout(()=>{Tt(a,!1)},0))}const p={startResize:c};return{get isResizing(){return Fn(r)},get resizeDirection(){return Fn(o)},get size(){return Fn(l)},get hasBeenResized(){return Fn(s)},get isActive(){return Fn(r)},get justFinishedResizing(){return Fn(a)},start:c,setHasBeenResized:()=>{},setSize:function(e){Tt(l,e,!0),Tt(s,!0)},reset:function(){Tt(s,!1),Tt(l,{width:0,height:0},!0)},constrainToViewport:function(){const t=n(),r=e();if(!r)return;const o=nr(t.x,t.y,Fn(l).width||r.offsetWidth,Fn(l).height||r.offsetHeight);Tt(l,{width:o.width,height:o.height},!0),i({x:o.x,y:o.y})},handlers:p}}(()=>Fn(m),()=>O.position,e=>O.setPosition(e)),W=function(e,n,i,r,o,l,s,a,u){let d=Ot(!1),c=Ot(!1),f=Ot(!1),h=Ot(!1),p=Ot(null),v=Ot(null),g=null,m=null;function y(){m&&(clearTimeout(m),m=null)}function w(){const e=t.id,n=document.querySelector(`.modal-dock-item[data-modal-id="${lr(e)}"]`),i=document.querySelector('[data-dock-container="true"]'),r=n||i;if(r){const e=r.getBoundingClientRect();return{x:e.left+e.width/2,y:e.top+e.height/2}}return{x:window.innerWidth/2,y:window.innerHeight-40}}return Zt(()=>()=>{y(),Tt(d,!1),Tt(c,!1),Tt(f,!1),Tt(h,!1),Tt(p,null),Tt(v,null),g=null}),{get isMinimizing(){return Fn(d)},get isRestoring(){return Fn(c)},get isOpening(){return Fn(f)},get isClosing(){return Fn(h)},get animationTransform(){return Fn(p)},get pendingOpenSource(){return Fn(v)},startMinimize:function(e,t){const h=n();if(Fn(d)||!h)return;if(Tt(c,!1),Tt(f,!1),y(),!no()){const e=h.getBoundingClientRect();let n=o()?i():{x:e.left,y:e.top},d=s()?a():{width:e.width,height:e.height};return o()||(r(n),l(!0)),void(t?t():u(n,!0,d))}const v=h.getBoundingClientRect(),g=v.left+v.width/2,x=v.top+v.height/2;let b=o()?i():{x:v.left,y:v.top},k=s()?a():{width:v.width,height:v.height};o()||(r(b),l(!0));const z=e??w(),M=z.x-v.left,_=z.y-v.top,I={x:z.x-g,y:z.y-x,originX:M,originY:_};Tt(p,I,!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Tt(d,!0)})}),m=setTimeout(()=>{t?t():u(b,!0,k)},500)},startRestore:function(e,t){if(!no()){const t=e||{x:window.innerWidth/2,y:window.innerHeight/2};return r(t),void l(!0)}const n=w(),i=e||{x:window.innerWidth/2,y:window.innerHeight/2},o=t||{width:480,height:400};r(i),l(!0);const s=i.x+o.width/2,a=i.y+o.height/2,u=n.x-i.x,d=n.y-i.y;Tt(p,{x:n.x-s,y:n.y-a,originX:u,originY:d},!0),Tt(c,!0),setTimeout(()=>{Tt(c,!1),Tt(p,null)},400)},startClose:function(e){Fn(h)||Fn(d)||(no()?(g=e,Tt(h,!0),setTimeout(()=>{Tt(h,!1),g&&(g(),g=null)},250)):e())},setPendingOpenSource:function(e){Tt(v,e,!0)},tryStartOpenAnimation:function(){const e=n();if(!Fn(v)||!e||Fn(f))return!1;if(!no())return Tt(v,null),!1;const t=Fn(v);Tt(v,null);const s=e.getBoundingClientRect(),a=o()?i():{x:s.left,y:s.top},u=s.width,d=s.height,c=a.x+u/2,h=a.y+d/2;o()||(r(a),l(!0));const g=t.x-a.x,m=t.y-a.y;return Tt(p,{x:t.x-c,y:t.y-h,originX:g,originY:m},!0),Tt(f,!0),setTimeout(()=>{Tt(f,!1),Tt(p,null)},400),!0},forceClearMinimize:function(){y(),Tt(d,!1),Tt(p,null)}}}(0,()=>Fn(m),()=>O.position,e=>O.setPosition(e),()=>O.hasBeenDragged,e=>O.setHasBeenDragged(e),()=>T.hasBeenResized,()=>T.size,(e,n,i)=>{Tr(t.id,{position:e,size:i,hasBeenDragged:n}),Cr(t.id)}),{trapFocus:R,focusFirstElement:B}={trapFocus:oo,focusFirstElement:lo},A=kt(()=>W.isMinimizing||W.isRestoring||W.isOpening||W.isClosing),$=kt(()=>(Ur(t.id)||Gr(t.id))&&!W.isRestoring);let j=Ot(!1);const H=kt(()=>W.isRestoring||W.isOpening||Fn(j)),L=kt(()=>Fn(M)&&!O.hasBeenDragged&&!Fn(A)&&!W.pendingOpenSource&&!Fn($)),F=kt(()=>{const e=[];return e.push(`z-index: ${Fn(E)};`),W.animationTransform?(e.push(`left: ${O.position.x}px; top: ${O.position.y}px;`),e.push(`--genie-origin-x: ${W.animationTransform.originX}px;`),e.push(`--genie-origin-y: ${W.animationTransform.originY}px;`),e.push(`--genie-translate-x: ${W.animationTransform.x}px;`),e.push(`--genie-translate-y: ${W.animationTransform.y}px;`)):O.hasBeenDragged&&e.push(`left: ${O.position.x}px; top: ${O.position.y}px; transform: none;`),T.hasBeenResized?e.push(`width: ${T.size.width}px; height: ${T.size.height}px; max-width: none; max-height: none;`):(t.preferredHeight&&e.push(`min-height: ${t.preferredHeight};`),n()&&e.push(`max-width: ${n()};`)),Fn(P)&&t.glow&&(e.push(`--modal-glow-color: ${t.glow.color};`),e.push(`--modal-glow-intensity: ${t.glow.intensity};`)),e.join(" ")});function N(){Fn(f)&&Cr(t.id)}function q(){var e;Xr(t.id)&&Yr(t.id),$r(t.id),null==(e=t.onClose)||e.call(t)}function X(){Zr(t.id)}function Y(e){Fn(c)&&Fn(m)&&O.onPointerDown(e,Fn(m))}function G(e){r()&&"Escape"===e.key&&Rr(t.id)&&(e.stopPropagation(),q())}function U(e){if(!Fn(m))return;const n=O.isDragging,i=T.hasBeenResized?T.size:{width:Fn(m).offsetWidth,height:Fn(m).offsetHeight};O.onPointerMove(e,Fn(m),i),O.isDragging&&n&&Dr(t.id,O.position,{drag:!0})}function V(e){if(!Fn(m))return;const n=O.isDragging;O.onPointerUp(e,Fn(m)),n&&!T.justFinishedResizing&&(Dr(t.id,O.position,{drag:!0}),function(e){const t=Qi();if("animated"!==t.parentChild.movementMode)return;const n=t.parentChild.animationDuration,i=[];let r=e;for(;;){const e=sr.get(r);if(!(null==e?void 0:e.parentId))break;i.push({parentId:e.parentId,childId:r}),r=e.parentId}i.forEach(({parentId:e,childId:t},i)=>{setTimeout(()=>{const i=sr.get(t),r=sr.get(e);if(!(null==i?void 0:i.position)||!i.offsetFromParent||!r)return;const o={x:i.position.x-i.offsetFromParent.x,y:i.position.y-i.offsetFromParent.y};zr.set(e,o),function(e){const t=zr.get(e);if(!t)return;const n=sr.get(e);n&&(sr.set(e,{...n,isAnimatingPosition:!0,position:t}),zr.delete(e),dr())}(e),setTimeout(()=>function(e){const t=sr.get(e);t&&(sr.set(e,{...t,isAnimatingPosition:!1}),dr())}(e),n)},i*n)})}(t.id))}function K(){var e;const n=Qi();if("smart"!==(null==(e=n.positioning)?void 0:e.strategy))return!1;const i=Fr(t.id);if(null==i?void 0:i.parentId)return!1;if((null==i?void 0:i.hasBeenDragged)||(null==i?void 0:i.position))return!1;const r=Fn(m)||document.querySelector(`[data-modal-id="${u}"]`);if(!r)return!1;const o=r.offsetWidth,l=r.offsetHeight;if(o<=0||l<=0)return!1;const s=n.positioning.modalGap??16,a=function(e){const t=[];for(const[n,i]of sr.entries())if(n!==e&&i.isOpen&&!i.isMinimized&&!i.isHiddenWithParent)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=document.querySelector(`[data-modal-id="${lr(n)}"]`);if(e){const n=e.getBoundingClientRect();t.push({x:n.left,y:n.top,width:n.width,height:n.height})}}return t}(t.id),d=function(e){if("undefined"==typeof document)return[];const t=[];for(const n of e)try{const e=document.querySelectorAll(n);for(const n of e){const e=n.getBoundingClientRect();e.width>0&&e.height>0&&t.push({x:e.left,y:e.top,width:e.width,height:e.height})}}catch{}return t}(n.positioning.avoidElements??[]),c=function(e,t,n,i={}){const{modalGap:r=16,gridResolution:o=10,avoidBounds:l=[],avoidMargin:s=16}=i,a=i.margin??r,u="undefined"!=typeof window?window.innerWidth:1920,d="undefined"!=typeof window?window.innerHeight:1080,c=l.map(e=>({x:e.x-s,y:e.y-s,width:e.width+2*s,height:e.height+2*s})),f={x:(u-e)/2,y:(d-t)/2};if(0===n.length&&0===c.length)return f;const h=a,p=Math.max(a,u-e-a),v=a,g=Math.max(a,d-t-a);if(p<=h||g<=v)return f;const m=rr(f.x,f.y,e,t,n,r),y=rr(f.x,f.y,e,t,c,0);if(0===m&&0===y)return f;const w=[],x=(p-h)/o,b=(g-v)/o;for(let i=0;i<=o;i++)for(let l=0;l<=o;l++){const o=h+i*x,s=v+l*b,f=rr(o,s,e,t,n,r),p=rr(o,s,e,t,c,0),g=or(o,s,e,t,u,d,a);w.push({pos:{x:o,y:s},modalOverlap:f,avoidOverlap:p,centerDist:g})}const k=w.filter(e=>0===e.avoidOverlap),z=k.length>0?k:w,M=e*t,_=Math.min(...z.map(e=>e.modalOverlap))/M;return z.sort((e,t)=>{if(0===k.length&&e.avoidOverlap!==t.avoidOverlap)return e.avoidOverlap-t.avoidOverlap;const n=e.modalOverlap/M,i=t.modalOverlap/M;if(_<.3){const r=.3,o=n<=r,l=i<=r;if(o&&l)return e.centerDist+.3*n-(t.centerDist+.3*i);if(o)return-1;if(l)return 1}return.6*n+.4*e.centerDist-(.6*i+.4*t.centerDist)}),z[0].pos}(o,l,a,{modalGap:s,avoidBounds:d});if(rr(c.x,c.y,o,l,a,s)/(o*l)>.1&&a.length>0){const e=function(e){const t=[];for(const[n,i]of sr.entries())if(n!==e&&i.isOpen&&!i.isMinimized&&!i.isHiddenWithParent&&!i.parentId)if(i.position&&i.size)t.push({id:lr(n),x:i.position.x,y:i.position.y,width:i.size.width,height:i.size.height});else{const e=document.querySelector(`[data-modal-id="${lr(n)}"]`);if(e){const i=e.getBoundingClientRect();t.push({id:lr(n),x:i.left,y:i.top,width:i.width,height:i.height})}}return t}(t.id),n=function(e,t,n,i={}){const{modalGap:r=16}=i,o=i.margin??r,l="undefined"!=typeof window?window.innerWidth:1920,s="undefined"!=typeof window?window.innerHeight:1080,a=n.reduce((e,t)=>e+t.width,0)+e,u=n.length*r,d=l-2*o;if(a+u>d)return null;const c=d-a-u;n.length;const f=c/2,h=l/2,p=[...n.map(e=>({id:e.id,width:e.width,height:e.height,currentX:e.x+e.width/2,currentY:e.y,isNew:!1})),{id:"__new__",width:e,height:t,currentX:h,currentY:(s-t)/2,isNew:!0}];p.sort((e,t)=>e.currentX-t.currentX);let v=o+f;const g=new Map;let m=null;for(const e of p){const t=v;if(e.isNew)m={x:Math.round(t),y:Math.round(e.currentY)};else{const i=n.find(t=>t.id===e.id);Math.abs(t-i.x)>5&&g.set(e.id,{x:Math.round(t),y:Math.round(i.y)})}v+=e.width+r}return m?{newModalPosition:m,existingModalMoves:g}:null}(o,l,e,{modalGap:s});if(n&&n.existingModalMoves.size>0)return function(e){const t=Qi().parentChild.animationDuration;for(const[t,n]of e){const e=sr.get(t);e&&sr.set(t,{...e,position:n,isAnimatingPosition:!0,hasBeenDragged:!0})}dr(),setTimeout(()=>{for(const t of e.keys()){const e=sr.get(t);e&&sr.set(t,{...e,isAnimatingPosition:!1})}dr()},t)}(n.existingModalMoves),O.setPosition(n.newModalPosition),O.setHasBeenDragged(!0),Dr(t.id,n.newModalPosition,{size:{width:o,height:l}}),!0}return O.setPosition(c),O.setHasBeenDragged(!0),Dr(t.id,c,{size:{width:o,height:l}}),!0}function Q(){Ln().then(()=>Ln()).then(()=>{let e=0;const t=()=>{e+=1,K()||e>5||requestAnimationFrame(t)};Fn(m)?t():requestAnimationFrame(t)})}var J;qi(()=>{var e;function n(){const e=Fr(t.id);if(!(null==e?void 0:e.position)||!Fn(m))return;if(e.parentId)return;const n=T.hasBeenResized?T.size.width:Fn(m).offsetWidth,i=T.hasBeenResized?T.size.height:Fn(m).offsetHeight;if(n<=0||i<=0)return;const r=tr(e.position.x,e.position.y,n,i);(Math.abs(r.x-e.position.x)>1||Math.abs(r.y-e.position.y)>1)&&(O.setPosition(r),Dr(t.id,r))}return o()||(e=i(),Sr({id:t.id,title:t.title,icon:t.icon??"",isOpen:e,isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,isRejected:!1,position:null,size:null,hasBeenDragged:!1,dockPosition:0,glow:t.glow??null,parentId:void 0,childId:void 0,offsetFromParent:void 0}),e&&Wr(t.id)),i()&&(Ln().then(()=>{Fn(m)&&B(Fn(m))}),Q()),window.addEventListener("pointermove",U),window.addEventListener("pointerup",V),window.addEventListener("resize",n),()=>{window.removeEventListener("pointermove",U),window.removeEventListener("pointerup",V),window.removeEventListener("resize",n)}}),J=()=>{eo(t.id),o()||Pr(t.id)},null===Xe&&He(),qi(()=>()=>Xn(J)),Zt(()=>{Nr();const e=Fr(t.id);if(e){if(Tt(y,e.isTransparent,!0),!O.isDragging&&!T.isResizing&&e.position){const t=O.position,n=e.position;(Math.abs(t.x-n.x)>.5||Math.abs(t.y-n.y)>.5)&&(O.setPosition(n),e.hasBeenDragged&&O.setHasBeenDragged(!0))}Ln().then(()=>function(){var e,n;if(!Fr(t.id))return;if(Xr(t.id))return Yr(t.id),void(null==(e=t.onClose)||e.call(t));if(Lr(t.id)&&!Fn(b)){if(Tt(b,!0),Fn(xr),Tt(xr,null),Fn(m)){const e=Fn(m).getBoundingClientRect(),n=O.hasBeenDragged?O.position:{x:e.left,y:e.top},i=T.hasBeenResized?T.size:{width:e.width,height:e.height};Tr(t.id,{position:n,size:i,hasBeenDragged:!0})}W.startMinimize(void 0,()=>{var e;e=t.id,Fn(fr).includes(e)&&Tt(fr,Fn(fr).filter(t=>t!==e),!0),Tt(b,!1)})}if(Gr(t.id)){n=t.id,Fn(gr).includes(n)&&Tt(gr,Fn(gr).filter(e=>e!==n),!0);const e=Fr(t.id);W.startRestore((null==e?void 0:e.position)??void 0,(null==e?void 0:e.size)??void 0),Ln().then(()=>{Fn(m)&&B(Fn(m))})}if(Ur(t.id)){!function(e){Fn(mr).includes(e)&&Tt(mr,Fn(mr).filter(t=>t!==e),!0)}(t.id);const e=Fr(t.id);W.startRestore((null==e?void 0:e.position)??void 0,(null==e?void 0:e.size)??void 0)}if(qr(t.id)&&(function(e){Fn(pr).includes(e)&&Tt(pr,Fn(pr).filter(t=>t!==e),!0)}(t.id),W.startClose(()=>{var e;eo(t.id),function(e){const t=sr.get(e);if(t){if(t.parentId){const n=sr.get(t.parentId);n&&n.childId===e&&sr.set(t.parentId,{...n,childId:void 0,lastChildId:e})}sr.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}),dr()}}(t.id),null==(e=t.onClose)||e.call(t)})),function(e){return Fn(hr).includes(e)}(t.id)){!function(e){Fn(hr).includes(e)&&Tt(hr,Fn(hr).filter(t=>t!==e),!0)}(t.id);const e=function(e){const t=br.get(e);return t&&br.delete(e),t??null}(t.id)||t.openSourcePosition||null;e?(W.setPendingOpenSource(e),Ln().then(()=>Ln()).then(()=>{K(),W.tryStartOpenAnimation()})):Q(),Ln().then(()=>{Fn(m)&&B(Fn(m))})}(function(e){return Fn(yr).includes(e)})(t.id)&&(function(e){Fn(yr).includes(e)&&Tt(yr,Fn(yr).filter(t=>t!==e),!0)}(t.id),function(e){Fn(wr).includes(e)||Tt(wr,[...Fn(wr),e],!0)}(t.id),Tt(k,!0),setTimeout(()=>{Tt(k,!1),function(e){Tt(wr,Fn(wr).filter(t=>t!==e),!0)}(t.id)},600));const i=function(e){if(!Fn(kr)||Fn(kr).childId!==e)return null;const t=Fn(kr);return Tt(kr,null),t}(t.id);var r;i&&Fn(m)&&(r=i.parentId,Ln().then(()=>Ln()).then(()=>{let e=0;const n=()=>{e+=1;const i=function(e){var n,i;const r=Fr(e);if(!r)return!1;const o=Fn(m)||document.querySelector(`[data-modal-id="${u}"]`),l=document.querySelector(`[data-modal-id="${lr(e)}"]`),s=null==l?void 0:l.getBoundingClientRect(),a=r.position??(s?{x:s.left,y:s.top}:null);if(!a||!o)return!1;const d=(null==(n=r.size)?void 0:n.width)??(null==l?void 0:l.offsetWidth)??(null==s?void 0:s.width)??480,c=(null==(i=r.size)?void 0:i.height)??(null==l?void 0:l.offsetHeight)??(null==s?void 0:s.height)??400,f=o.offsetWidth,h=o.offsetHeight;if(d<=0||c<=0||f<=0||h<=0)return!1;const p={x:a.x+(d-f)/2,y:a.y+(c-h)/2};return O.setPosition(p),O.setHasBeenDragged(!0),Dr(t.id,p,{size:{width:f,height:h}}),r.position&&r.size||!s||Dr(e,{x:s.left,y:s.top},{size:{width:d,height:c}}),function(e,t){if(!Qi().features.parentChild)return;const n=sr.get(e),i=sr.get(t);if(!n||!i)return;let r={x:40,y:40};n.position&&i.position&&(r={x:i.position.x-n.position.x,y:i.position.y-n.position.y});const o=Math.max(i.zIndex,n.zIndex+1);sr.set(e,{...n,childId:t,lastChildId:t}),sr.set(t,{...i,parentId:e,offsetFromParent:r,zIndex:o}),dr()}(e,t.id),!0}(r);i||e>5||requestAnimationFrame(n)};Fn(m)?n():requestAnimationFrame(n)}))}())}}),Zt(()=>{const e=Fr(t.id);e&&e.isTransparent!==Fn(y)&&Tt(y,e.isTransparent,!0)}),Zt(()=>{if(Fn(M)&&Fn(m)){const e=e=>function(e){Fn(m)&&R(e,Fn(m))}(e);return Fn(m).addEventListener("keydown",e),()=>{var t;return null==(t=Fn(m))?void 0:t.removeEventListener("keydown",e)}}}),Zt(()=>{!Fn(M)&&W.isMinimizing&&W.forceClearMinimize()}),Zt(()=>{W.isRestoring||W.isOpening?Tt(j,!0):Fn(j)&&requestAnimationFrame(()=>{Tt(j,!1)})}),Zt(()=>{Fn(x)&&!Fn(_)&&(Tt(w,!0),setTimeout(()=>{Tt(w,!1)},200)),Tt(x,Fn(_),!0)});var Z=ri(),ee=Gt(Z),te=e=>{uo(e,{get target(){return a},children:(e,n)=>{var i=Oo();let r;i.__keydown=G;var o=Yt(i);{let e=kt(()=>Fn(c)?Y:void 0);!function(e,t){Ue(t,!0);let n=Ni(t,"isTransparent",0,!1),i=Ni(t,"headerLayout",0,"macos"),r=Ni(t,"minimizable",0,!0),o=Ni(t,"minimizeDisabled",0,!1),l=Ni(t,"transparencyEnabled",0,!0);const s=Ge(Xi),a=kt(()=>null==s?void 0:s()),u=kt(()=>"macos"===i());var d=_o();let c;d.__pointerdown=function(e){var n;e.target.closest("button")||null==(n=t.onStartDrag)||n.call(t,e)};var f=Yt(d),h=e=>{var n=mo(),i=Gt(n),s=Yt(i);s.__click=function(...e){var n;null==(n=t.onClose)||n.apply(this,e)};var u=Ut(s,2),d=e=>{var n=co();let i;n.__click=function(...e){var n;null==(n=o()?void 0:t.onMinimize)||n.apply(this,e)},rn(()=>{i=Wi(n,0,"modal-header-light modal-header-light-minimize",null,i,{"modal-header-light-disabled":o()}),n.disabled=o(),ji(n,"title",o()?"Enable dock to minimize":void 0)}),oi(e,n)};hi(u,e=>{r()&&e(d)});var c=Ut(u,2),f=e=>{var n=fo();n.__click=function(...e){var n;null==(n=t.onToggleStyle)||n.apply(this,e)},oi(e,n)};hi(c,e=>{l()&&e(f)});var h=Yt(Ut(i,2)),p=e=>{var n=ho();bi(Yt(n),()=>t.customIcon),oi(e,n)},v=e=>{var n=ri(),i=Gt(n),r=e=>{var n=po();bi(Yt(n),()=>Fn(a),()=>t.icon),oi(e,n)};hi(i,e=>{t.icon&&Fn(a)&&e(r)},!0),oi(e,n)};hi(h,e=>{t.customIcon?e(p):e(v,!1)});var g=Yt(Ut(h,2)),m=e=>{var n=vo(),i=Yt(n);rn(()=>{ji(n,"id",t.titleId),si(i,t.title)}),oi(e,n)},y=e=>{var n=go(),i=Yt(n);rn(()=>si(i,t.title)),oi(e,n)};hi(g,e=>{t.titleId?e(m):e(y,!1)}),oi(e,n)},p=e=>{var n=Mo(),i=Gt(n),s=Yt(i),u=e=>{var n=yo();bi(Yt(n),()=>t.customIcon),oi(e,n)},d=e=>{var n=ri(),i=Gt(n),r=e=>{var n=wo();bi(Yt(n),()=>Fn(a),()=>t.icon),oi(e,n)};hi(i,e=>{t.icon&&Fn(a)&&e(r)},!0),oi(e,n)};hi(s,e=>{t.customIcon?e(u):e(d,!1)});var c=Ut(s,2),f=e=>{var n=xo(),i=Yt(n);rn(()=>{ji(n,"id",t.titleId),si(i,t.title)}),oi(e,n)},h=e=>{var n=bo(),i=Yt(n);rn(()=>si(i,t.title)),oi(e,n)};hi(c,e=>{t.titleId?e(f):e(h,!1)});var p=Yt(Ut(i,2)),v=e=>{var n=ko();n.__click=function(...e){var n;null==(n=t.onToggleStyle)||n.apply(this,e)},oi(e,n)};hi(p,e=>{l()&&e(v)});var g=Ut(p,2),m=e=>{var n=zo();let i;n.__click=function(...e){var n;null==(n=o()?void 0:t.onMinimize)||n.apply(this,e)},rn(()=>{i=Wi(n,0,"modal-header-btn-windows",null,i,{"modal-header-btn-windows-disabled":o()}),n.disabled=o(),ji(n,"title",o()?"Enable dock to minimize":void 0)}),oi(e,n)};hi(g,e=>{r()&&e(m)}),Ut(g,2).__click=function(...e){var n;null==(n=t.onClose)||n.apply(this,e)},oi(e,n)};hi(f,e=>{Fn(u)?e(h):e(p,!1)}),rn(()=>c=Wi(d,0,"modal-header",null,c,{"modal-header-draggable":!!t.onStartDrag,transparent:n()})),oi(e,d),Ve()}(o,{get title(){return t.title},get customIcon(){return t.customIcon},get icon(){return t.icon},get isTransparent(){return Fn(y)},get titleId(){return Fn(C)},get headerLayout(){return Fn(g)},get onStartDrag(){return Fn(e)},onToggleStyle:X,onMinimize:N,onClose:q,get minimizable(){return Fn(f)},get minimizeDisabled(){return Fn(h)},get transparencyEnabled(){return Fn(p)}})}var l=Ut(o,2);bi(Yt(l),()=>t.children??xe),Ei(l,(e,t)=>null==Po?void 0:Po(e,t),()=>t.bodyElement);var s=Ut(l,2),a=e=>{var n=Co(),i=Yt(n),r=e=>{var n=ri();bi(Gt(n),()=>t.footer),oi(e,n)};hi(i,e=>{t.footer&&e(r)}),Ei(n,(e,t)=>null==Po?void 0:Po(e,t),()=>t.footerElement),oi(e,n)};hi(s,e=>{(t.footer||t.footerElement)&&e(a)});var d=Ut(s,2);{let e=kt(()=>Fn(v)&&!Fn(_)?T.handlers.startResize:void 0);!function(e,t){Ue(t,!0);const n=["n","s","e","w","ne","nw","se","sw"];var i=ri(),r=Gt(i),o=e=>{var i=So();mi(i,21,()=>n,pi,(e,n)=>{var i=Io();i.__pointerdown=e=>function(e,n){var i;null==(i=t.onStartResize)||i.call(t,e,n)}(e,Fn(n)),rn(()=>Wi(i,0,`modal-resize-handle modal-resize-${Fn(n)??""}`)),oi(e,i)}),oi(e,i)};hi(r,e=>{t.onStartResize&&e(o)}),oi(e,i),Ve()}(d,{get onStartResize(){return Fn(e)}})}var x,b,M,E=Ut(d,2),R=e=>{var t=Eo();let n;rn(()=>n=Wi(t,0,"modal-child-overlay",null,n,{"modal-overlay-closing":Fn(w)})),oi(e,t)};hi(E,e=>{Fn(S)&&e(R)}),Fi(i,e=>Tt(m,e),()=>Fn(m)),rn(()=>{var e;r=Wi(i,0,"modal-dialog",null,r,{"modal-dragging":O.isDragging,"modal-resizing":T.isResizing,"modal-positioned":O.hasBeenDragged,"modal-minimizing":W.isMinimizing,"modal-restoring":W.isRestoring,"modal-opening":W.isOpening,"modal-closing":W.isClosing,"modal-centered":Fn(L),"modal-solid":!Fn(y),"modal-transparent":Fn(y),"modal-glow":Fn(P),"modal-has-child":Fn(_),"modal-is-child":Fn(I),"modal-visible-by-animation":Fn(H),"modal-animating-to-center":Fn(D),"modal-animating-position":null==(e=Fn(z))?void 0:e.isAnimatingPosition,"modal-attention":Fn(k)}),ji(i,"data-modal-id",u),Bi(i,Fn(F)),ji(i,"aria-labelledby",Fn(C))}),M=function(e,t,n,i={}){function r(e){if(i.capture||ti.call(t,e),!e.cancelBubble)return Vt(()=>null==n?void 0:n.call(this,e))}return e.startsWith("pointer")||e.startsWith("touch")||"wheel"===e?Ze(()=>{t.addEventListener(e,r,i)}):t.addEventListener(e,r,i),r}("pointerdown",x=i,()=>Wr(t.id),b={capture:!0,passive:void 0}),(x===document.body||x===window||x===document||x instanceof HTMLMediaElement)&&Jt(()=>{x.removeEventListener("pointerdown",M,b)}),oi(e,i)},$$slots:{default:!0}})};hi(ee,e=>{Fn(M)&&e(te)}),oi(e,Z),Ve()}function To({id:e,title:t,icon:n,maxWidth:i="600px",preferredHeight:r,autoOpen:o=!1,glow:l,config:s,closeOnEscape:a=!0,onClose:u,children:d,footer:c}){const f=Q(null),h=Q(null),p=Q(null),v=Q(null),[g,m]=J(!1),[y,w]=J(!1);Z(()=>(Sr({id:e,title:t,icon:n??"",isOpen:o,isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,isRejected:!1,position:null,size:null,hasBeenDragged:!1,dockPosition:0,glow:l??null}),m(!0),()=>{Pr(e)}),[e]),Z(()=>{if(!g||!f.current)return;const o=d?(p.current||"undefined"==typeof document||(p.current=document.createElement("div"),p.current.className="react-modal-body-content"),p.current):null,l=c?(v.current||"undefined"==typeof document||(v.current=document.createElement("div"),v.current.className="react-modal-footer-content"),v.current):null;return h.current=ai(Do,{target:f.current,props:{id:e,title:t,icon:n??"",maxWidth:i,preferredHeight:r,closeOnEscape:a,onClose:u,bodyElement:o,footerElement:l}}),w(!0),()=>{h.current&&(ci(h.current),h.current=null,w(!1)),p.current=null,v.current=null}},[g,e]);const x=lr(e),b=y?p.current:null,k=y?v.current:null;return ue.jsxs(ue.Fragment,{children:[ue.jsx("div",{ref:f,"data-modal-bridge":x,style:{display:"contents"}}),b&&d&&ne(d,b),k&&c&&ne(c,k)]})}function Wo({config:e,children:t}){return Z(()=>{e&&Ji(e),Tt(Zi,Qi().zIndex.base,!0);const t=Qi().portalTarget;let n=null;return"string"==typeof t&&"undefined"!=typeof document&&(document.querySelector(t)||(n=document.createElement("div"),n.id=t.replace("#",""),document.body.appendChild(n))),()=>{Ui={...Gi},Rt(Vi),Tt(Zi,Qi().zIndex.base,!0),n&&n.remove()}},[e]),K.createElement(K.Fragment,null,t)}function Ro(e){const t=e-1;return t*t*t+1}function Bo(e){const t="string"==typeof e&&e.match(/^\s*(-?[\d.]+)([^\s]*)\s*$/);return t?[parseFloat(t[1]),t[2]||"px"]:[e,"px"]}function Ao(e,{delay:t=0,duration:n=400,easing:i=Ro,x:r=0,y:o=0,opacity:l=0}={}){const s=getComputedStyle(e),a=+s.opacity,u="none"===s.transform?"":s.transform,d=a*(1-l),[c,f]=Bo(r),[h,p]=Bo(o);return{delay:t,duration:n,easing:i,css:(e,t)=>`\n\t\t\ttransform: ${u} translate(${(1-e)*c}${f}, ${(1-e)*h}${p});\n\t\t\topacity: ${a-d*t}`}}function $o(e,{delay:t=0,duration:n=400,easing:i=Ro,start:r=0,opacity:o=0}={}){const l=getComputedStyle(e),s=+l.opacity,a="none"===l.transform?"":l.transform,u=1-r,d=s*(1-o);return{delay:t,duration:n,easing:i,css:(e,t)=>`\n\t\t\ttransform: ${a} scale(${1-u*t});\n\t\t\topacity: ${s-d*t}\n\t\t`}}function jo(e){const t=1.70158;return--e*e*((t+1)*e+t)+1}function Ho(e){const t=e-1;return t*t*t+1}Zn(["keydown"]);var Lo=ii('<button type="button" aria-label="Drag dock"></button>'),Fo=ii('<span class="modal-dock-item-icon-placeholder"> </span>'),No=ii('<span class="modal-dock-item-label"> </span>'),qo=ii("<span>+</span>"),Xo=ii('<span class="modal-dock-child-indicator"><!></span>'),Yo=ii('<button><span class="modal-dock-item-icon"><!></span> <!> <span class="modal-dock-item-glow"></span> <!></button>'),Go=ii('<div data-dock-container="true"><div><!> <!></div></div>');function Uo(e,t){Ue(t,!0);const n=Ge(Xi),i=kt(()=>t.renderIcon??(null==n?void 0:n())),r=Jr(),o=kt(()=>(Ki(),Qi())),l=kt(()=>Qi().zIndex.dock),s=kt(()=>Fn(o).dock.position),a=kt(()=>Fn(o).dock.labelMode);let u=Ot("horizontal"),d=Ot($t({x:100,y:100})),c=Ot(null),f=Ot(!1),h={x:0,y:0},p=null;const v=kt(()=>(Nr(),Array.from(r.modals.values()).filter(e=>e.isMinimized).sort((e,t)=>e.dockPosition-t.dockPosition))),g=kt(()=>{switch(Fn(s)){case"left":return{x:-20,duration:250,easing:Ho};case"right":return{x:20,duration:250,easing:Ho};default:return{y:20,duration:250,easing:Ho}}});function m(e){var t;"free"===Fn(s)&&(Tt(f,!0),p=e.pointerId,h={x:e.clientX-Fn(d).x,y:e.clientY-Fn(d).y},null==(t=e.currentTarget)||t.setPointerCapture(e.pointerId),window.addEventListener("pointermove",y),window.addEventListener("pointerup",w),window.addEventListener("pointercancel",w))}function y(e){if(e.pointerId!==p||!Fn(c))return;const t=Fn(c).getBoundingClientRect(),n=window.innerWidth-t.width-8,i=window.innerHeight-t.height-8,r=Math.min(Math.max(e.clientX-h.x,8),Math.max(8,n)),o=Math.min(Math.max(e.clientY-h.y,8),Math.max(8,i));Tt(d,{x:Math.round(r),y:Math.round(o)},!0)}function w(e){e.pointerId===p&&(Tt(f,!1),p=null,window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w))}const{addListener:x}=function(){function e(e,t,n){return"undefined"==typeof window?()=>{}:(window.addEventListener(e,t,n),()=>{window.removeEventListener(e,t,n)})}return{addListener:e,addListenerEffect:function(t,n,i){Zt(()=>{if("undefined"!=typeof window)return e(t,n,i)})}}}();function b(){if("free"!==Fn(s)||!Fn(c))return;const e=Fn(c).getBoundingClientRect(),t=tr(Fn(d).x,Fn(d).y,e.width,e.height);t.x===Fn(d).x&&t.y===Fn(d).y||Tt(d,{x:Math.round(t.x),y:Math.round(t.y)},!0)}Zt(()=>{"undefined"!=typeof window&&x("resize",b)});var k={setDockOrientation:function(e){Tt(u,e,!0)},setDockFreePosition:function(e){Tt(d,e,!0)},getDockState:function(){return{dockPosition:Fn(s),dockOrientation:Fn(u),dockFreePosition:Fn(d),dockLabelMode:Fn(a)}}};return uo(e,{get target(){return Fn(o).portalTarget},children:(e,t)=>{var n=Go();let o,h;var p=Yt(n);let y;var w=Yt(p),x=e=>{var t=Lo();let n;t.__pointerdown=m,rn(()=>n=Wi(t,0,"modal-dock-handle",null,n,{"modal-dock-handle-dragging":Fn(f)})),oi(e,t)};hi(w,e=>{"free"===Fn(s)&&e(x)}),mi(Ut(w,2),19,()=>Fn(v),e=>e.id,(e,t,n)=>{const o=kt(()=>Fn(t).lastChildId?r.modals.get(Fn(t).lastChildId):null);var l=Yo();let s;l.__click=e=>{var n;n=Fn(t).id,Mr.has(n)?e.currentTarget.animate([{transform:"translateX(0)"},{transform:"translateX(-6px)"},{transform:"translateX(6px)"},{transform:"translateX(-6px)"},{transform:"translateX(6px)"},{transform:"translateX(0)"}],{duration:300,easing:"ease-in-out"}):Er(Fn(t).id)};var u=Yt(l),d=Yt(u),c=e=>{var n=ri();bi(Gt(n),()=>Fn(i),()=>Fn(t).icon),oi(e,n)},f=e=>{var n=Fo(),i=Yt(n);rn(e=>si(i,e),[()=>Fn(t).title.charAt(0)]),oi(e,n)};hi(d,e=>{Fn(t).icon&&Fn(i)?e(c):e(f,!1)});var h=Ut(u,2),p=e=>{var n=No(),i=Yt(n);rn(()=>si(i,Fn(t).title)),oi(e,n)};hi(h,e=>{"hidden"!==Fn(a)&&e(p)});var v=Ut(h,4),g=e=>{var t=Xo(),n=Yt(t),r=e=>{var t=ri();bi(Gt(t),()=>Fn(i),()=>Fn(o).icon),oi(e,t)},l=e=>{oi(e,qo())};hi(n,e=>{Fn(o).icon&&Fn(i)?e(r):e(l,!1)}),oi(e,t)};hi(v,e=>{Fn(t).lastChildId&&Fn(o)&&e(g)}),rn(e=>{s=Wi(l,0,"modal-dock-item",null,s,{"modal-dock-item-has-glow":!!Fn(t).glow,"modal-dock-item-has-child":!!Fn(t).lastChildId,"modal-dock-item-label-beside":"beside"===Fn(a),"modal-dock-item-label-below":"below"===Fn(a)}),ji(l,"data-modal-id",e),Bi(l,Fn(t).glow?`--modal-dock-glow-color: ${Fn(t).glow.color};`:"")},[()=>lr(Fn(t).id)]),Pi(3,l,()=>$o,()=>({duration:300,delay:50*Fn(n),easing:jo,start:.5})),oi(e,l)}),Fi(n,e=>Tt(c,e),()=>Fn(c)),rn(()=>{o=Wi(n,0,"modal-dock-container",null,o,{"modal-dock-left":"left"===Fn(s),"modal-dock-right":"right"===Fn(s),"modal-dock-bottom":"bottom"===Fn(s),"modal-dock-free":"free"===Fn(s),"modal-dock-empty":0===Fn(v).length}),h=Bi(n,"free"===Fn(s)?`left: ${Fn(d).x}px; top: ${Fn(d).y}px;`:"",h,{"z-index":Fn(l)}),y=Wi(p,0,"modal-dock",null,y,{"modal-dock-free-horizontal":"free"===Fn(s)&&"horizontal"===Fn(u),"modal-dock-free-vertical":"free"===Fn(s)&&"vertical"===Fn(u)})}),Pi(3,n,()=>Ao,()=>Fn(v).length>0?Fn(g):{duration:0}),oi(e,n)},$$slots:{default:!0}}),Ve(k)}function Vo({renderIcon:e}){const t=Q(null),n=Q(null);return Z(()=>{if(t.current)return n.current=ai(Uo,{target:t.current,props:{}}),()=>{n.current&&(ci(n.current),n.current=null)}},[]),ue.jsx("div",{ref:t,"data-dock-bridge":"true",style:{display:"contents"}})}function Ko(e,t){if(!Qr(e))throw new Error(`Cannot call ${t}() on unregistered modal "${String(e)}". Ensure the Modal component is rendered.`)}Zn(["pointerdown","click"]);const Qo=new Map;function Jo(e){const t=ee(()=>function(e){const t=Jr().modals.get(e),n=void 0!==t&&!t.isMinimized,i=(null==t?void 0:t.isMinimized)??!1,r=void 0!==t,o=Qo.get(e);if(o&&o.isOpen===n&&o.isMinimized===i&&o.isRegistered===r)return o;const l={isOpen:n,isMinimized:i,isRegistered:r};return Qo.set(e,l),l}(e),[e]);return{...te(cr,t,t),open:ee(t=>{Ko(e,"open"),Ar(e,t)},[e]),close:ee(()=>{Ko(e,"close"),$r(e)},[e]),minimize:ee(()=>{Ko(e,"minimize"),Cr(e)},[e]),restore:ee(()=>{Ko(e,"restore"),Er(e)},[e]),openChild:ee((t,n)=>{Ko(e,"openChild"),Hr({id:t},e,n)},[e]),shake:ee(()=>{Ko(e,"shake"),Vr(e)},[e]),bringToFront:ee(()=>{Ko(e,"bringToFront"),Wr(e)},[e])}}let Zo=null;function el(){const e=Jr(),t=Array.from(e.modals.values()),n=t.filter(e=>e.isMinimized).length,i=t.filter(e=>!e.isMinimized).length;return Zo&&Zo.modals===e.modals&&Zo.minimizedCount===n&&Zo.openCount===i||(Zo={modals:e.modals,minimizedCount:n,openCount:i}),Zo}function tl(){return te(cr,el,el)}export{Vo as Dock,To as Modal,Wo as ModalProvider,Wr as bringToFront,jr as closeAllModals,$r as closeModal,Qi as getConfig,Kr as isModalOpen,Qr as isModalRegistered,Rr as isTopModal,Cr as minimizeModal,Hr as openChildModal,Ar as openModal,Br as reorderDock,Er as restoreModal,Ji as setConfig,Zr as toggleModalTransparency,Jo as useModal,tl as useModals};
|
package/dist/styles/modal.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.modal-dialog{background:var(--modal-bg);border:1px solid var(--modal-border);border-radius:var(--modal-border-radius);width:calc(100% - 2rem);max-width:480px;max-height:80vh;box-shadow:var(--modal-shadow-lg);opacity:0;outline:none;flex-direction:column;transition:height .15s ease-out,background-color .2s,border-color .2s;display:flex;position:fixed;top:50%;left:50%;overflow:visible;transform:translate(-50%,-50%)}.modal-dialog.modal-positioned{opacity:1;transform:none}.modal-dialog.modal-centered{opacity:1}.modal-dialog.modal-awaiting-restore{pointer-events:none;opacity:0!important}.modal-dialog.modal-dragging{opacity:.9;user-select:none;transition:none}.modal-dialog.modal-resizing{user-select:none;transition:none}.modal-dialog.modal-animating-to-center{transition:left .2s ease-out,top .2s ease-out}.modal-dialog.modal-animating-position{transition:left var(--modal-parent-animation-duration)ease-out,top var(--modal-parent-animation-duration)ease-out}.modal-dialog.modal-solid{background:var(--modal-bg)}.modal-dialog.modal-transparent{background:var(--modal-bg-transparent);opacity:.4}.modal-dialog.modal-minimizing{pointer-events:none;animation:modal-genie-minimize var(--modal-animation-duration-minimize)ease-in forwards;transform-origin:var(--genie-origin-x,50%)var(--genie-origin-y,100%);will-change:transform,opacity;backface-visibility:hidden}.modal-dialog.modal-restoring{pointer-events:none;animation:modal-genie-restore var(--modal-animation-duration-restore)ease-out forwards;transform-origin:var(--genie-origin-x,50%)var(--genie-origin-y,100%);will-change:transform,opacity;backface-visibility:hidden}.modal-dialog.modal-opening{pointer-events:none;animation:modal-genie-restore var(--modal-animation-duration-open)ease-out forwards;transform-origin:var(--genie-origin-x,50%)var(--genie-origin-y,50%);will-change:transform,opacity;backface-visibility:hidden}.modal-dialog.modal-closing{pointer-events:none;animation:modal-close var(--modal-animation-duration-close)ease-in forwards;will-change:transform,opacity;backface-visibility:hidden}.modal-dialog.modal-closing:not(.modal-positioned){animation-name:modal-close-centered}.modal-dialog.modal-positioned.modal-minimizing,.modal-dialog.modal-positioned.modal-closing{transform:unset;opacity:unset}.modal-dialog.modal-positioned.modal-opening,.modal-dialog.modal-positioned.modal-restoring{transform:unset;opacity:1}.modal-dialog.modal-visible-by-animation{opacity:1}.modal-dialog.modal-attention{animation:.5s cubic-bezier(.36,.07,.19,.97) both modal-shake-positioned,.6s ease-out both modal-attention-glow}.modal-dialog.modal-attention:not(.modal-positioned){animation:.5s cubic-bezier(.36,.07,.19,.97) both modal-shake-centered,.6s ease-out both modal-attention-glow}.modal-dialog.modal-attention.modal-glow{--modal-attention-color:var(--modal-glow-color)}.modal-dialog.modal-glow{border-color:rgb(var(--modal-glow-color));animation:2s ease-in-out infinite modal-glow-medium}.modal-dialog.modal-glow.modal-glow-low{animation-name:modal-glow-low}.modal-dialog.modal-glow.modal-glow-high{animation-name:modal-glow-high}.modal-dialog.modal-glow.modal-minimizing{animation:modal-genie-minimize var(--modal-animation-duration-minimize)ease-in forwards}.modal-dialog.modal-glow.modal-restoring{animation:modal-genie-restore var(--modal-animation-duration-restore)ease-out forwards}.modal-dialog.modal-glow.modal-opening{animation:modal-genie-restore var(--modal-animation-duration-open)ease-out forwards}.modal-dialog.modal-glow.modal-closing{animation:modal-close var(--modal-animation-duration-close)ease-in forwards}.modal-header{padding:var(--modal-header-padding);border-bottom:1px solid var(--modal-header-border);z-index:101;outline:none;flex-shrink:0;align-items:center;gap:.75rem;display:flex;position:relative;overflow:visible}.modal-header.modal-header-draggable{cursor:grab;user-select:none;touch-action:none}.modal-header.modal-header-draggable:active{cursor:grabbing}.modal-header-traffic-lights{gap:var(--modal-btn-gap);z-index:100;flex-shrink:0;display:flex;position:relative}.modal-header-traffic-lights .modal-header-light{width:var(--modal-btn-size);height:var(--modal-btn-size);cursor:pointer;border:none;border-radius:50%;outline:none;flex-shrink:0;padding:0;transition:filter .15s,transform .1s;position:relative}.modal-header-traffic-lights .modal-header-light:before{content:"";opacity:0;justify-content:center;align-items:center;transition:opacity .15s;display:flex;position:absolute;inset:0}.modal-header-traffic-lights .modal-header-light:hover{transform:scale(1.1)}.modal-header-traffic-lights .modal-header-light:hover:before{opacity:1}.modal-header-traffic-lights .modal-header-light:focus-visible{box-shadow:0 0 0 2px #ffffff80,0 0 0 4px #0003}.modal-header-light-close{background:var(--modal-btn-close);box-shadow:inset 0 0 0 .5px #0000001f}.modal-header-light-close:hover{filter:brightness(.92)}.modal-header-traffic-lights .modal-header-light.modal-header-light-close:before{content:"×";color:#4a0002cc;font-size:11px;font-weight:600;line-height:13px}.modal-header-light-minimize{background:var(--modal-btn-minimize);box-shadow:inset 0 0 0 .5px #0000001f}.modal-header-light-minimize:hover{filter:brightness(.92)}.modal-header-traffic-lights .modal-header-light.modal-header-light-minimize:before{content:"−";color:#995700cc;font-size:13px;font-weight:600;line-height:12px}.modal-header-light-style{background:var(--modal-btn-style);box-shadow:inset 0 0 0 .5px #0000001f}.modal-header-light-style:hover{filter:brightness(.92)}.modal-header-traffic-lights .modal-header-light.modal-header-light-style:before{content:"◇";color:#006500cc;font-size:7px;line-height:13px}.modal-header-light.modal-header-light-disabled{opacity:.5;cursor:not-allowed;background:#ccc}.modal-header-light.modal-header-light-disabled:hover{filter:none}.modal-header-traffic-lights .modal-header-light.modal-header-light-disabled:before{opacity:.4}.modal-header-mac-center{pointer-events:none;justify-content:center;align-items:center;gap:.5rem;display:flex;position:absolute;left:0;right:0}.modal-header-mac-center .modal-header-title-group{flex:unset;pointer-events:auto}.modal-header-mac-center .modal-header-icon{pointer-events:auto}.modal-header-mac-spacer{display:none}.modal-header-title-group{flex:1;align-items:center;gap:.5rem;min-width:0;display:flex}.modal-header-title{font-size:var(--modal-title-size);color:var(--modal-title-color);white-space:nowrap;text-overflow:ellipsis;min-width:0;margin:0;overflow:hidden}.modal-header-icon{font-size:var(--modal-icon-size);width:var(--modal-icon-size);height:var(--modal-icon-size);flex-shrink:0;justify-content:center;align-items:center;display:inline-flex;position:relative}.modal-header-icon-badge{font-size:var(--modal-icon-badge-size);background:var(--modal-bg);border-radius:50%;padding:2px;line-height:1;position:absolute;bottom:-6px;right:-8px;box-shadow:0 1px 3px #0003}.modal-header-btn-windows{color:var(--modal-btn-windows-color);cursor:pointer;background:0 0;border:none;border-radius:4px;padding:.25rem;font-size:1.25rem;line-height:1;transition:background-color .15s,color .15s}.modal-header-btn-windows:hover{color:var(--modal-btn-windows-hover-color);background:var(--modal-btn-windows-hover-bg)}.modal-header-btn-windows-style{font-size:.9rem}.modal-header-btn-windows-close{padding:0;font-size:1.5rem}.modal-header-btn-windows.modal-header-btn-windows-disabled{opacity:.35;cursor:not-allowed}.modal-header-btn-windows.modal-header-btn-windows-disabled:hover{color:var(--modal-btn-windows-color);background:0 0}.modal-body{min-height:0;padding:var(--modal-content-padding);flex-direction:column;flex:auto;display:flex;position:relative;overflow-y:auto}.modal-body::-webkit-scrollbar{width:6px}.modal-body::-webkit-scrollbar-track{background:#0000000d}.modal-body::-webkit-scrollbar-thumb{background:#0003;border-radius:3px}.modal-footer{padding:var(--modal-footer-padding);border-top:1px solid var(--modal-footer-border);flex-shrink:0}.modal-resize-handle{z-index:10;touch-action:none;position:absolute}.modal-resize-n,.modal-resize-s{height:var(--modal-resize-handle-size);cursor:ns-resize;left:8px;right:8px}.modal-resize-n{top:calc(var(--modal-resize-handle-size)/-2)}.modal-resize-s{bottom:calc(var(--modal-resize-handle-size)/-2)}.modal-resize-e,.modal-resize-w{width:var(--modal-resize-handle-size);cursor:ew-resize;top:8px;bottom:8px}.modal-resize-e{right:calc(var(--modal-resize-handle-size)/-2)}.modal-resize-w{left:calc(var(--modal-resize-handle-size)/-2)}.modal-resize-ne,.modal-resize-nw,.modal-resize-se,.modal-resize-sw{width:var(--modal-resize-corner-size);height:var(--modal-resize-corner-size)}.modal-resize-ne{top:calc(var(--modal-resize-handle-size)/-2);right:calc(var(--modal-resize-handle-size)/-2);cursor:nesw-resize}.modal-resize-nw{top:calc(var(--modal-resize-handle-size)/-2);left:calc(var(--modal-resize-handle-size)/-2);cursor:nwse-resize}.modal-resize-se{bottom:calc(var(--modal-resize-handle-size)/-2);right:calc(var(--modal-resize-handle-size)/-2);cursor:nwse-resize}.modal-resize-sw{bottom:calc(var(--modal-resize-handle-size)/-2);left:calc(var(--modal-resize-handle-size)/-2);cursor:nesw-resize}.modal-child-overlay{background:var(--modal-child-overlay-bg);backdrop-filter:blur(var(--modal-child-overlay-blur));border-radius:inherit;z-index:100;cursor:not-allowed;pointer-events:all;animation:.2s ease-out forwards modal-overlay-fade-in;position:absolute;inset:0}.modal-child-overlay.modal-overlay-closing{pointer-events:none;animation:.2s ease-in forwards modal-overlay-fade-out}.modal-dialog.modal-has-child .modal-header-actions{pointer-events:none;opacity:.5}.modal-dialog.modal-has-child .modal-header-draggable{cursor:not-allowed}.modal-dialog.modal-is-child.modal-positioned:not(.modal-closing):not(.modal-minimizing):not(.modal-restoring){animation:.25s ease-out forwards modal-child-appear}.modal-dialog.modal-is-child.modal-closing{animation:.2s ease-in forwards modal-child-disappear}
|
|
1
|
+
.modal-dialog{background:var(--modal-bg);border:1px solid var(--modal-border);border-radius:var(--modal-border-radius);width:calc(100% - 2rem);max-width:480px;max-height:80vh;box-shadow:var(--modal-shadow-lg);opacity:0;outline:none;flex-direction:column;transition:height .15s ease-out,background-color .2s,border-color .2s;display:flex;position:fixed;top:50%;left:50%;overflow:visible;transform:translate(-50%,-50%)}.modal-dialog.modal-positioned{opacity:1;transform:none}.modal-dialog.modal-centered{opacity:1}.modal-dialog.modal-awaiting-restore{pointer-events:none;opacity:0!important}.modal-dialog.modal-dragging{opacity:.9;user-select:none;transition:none}.modal-dialog.modal-resizing{user-select:none;transition:none}.modal-dialog.modal-animating-to-center{transition:left .2s ease-out,top .2s ease-out}.modal-dialog.modal-animating-position{transition:left var(--modal-parent-animation-duration)ease-out,top var(--modal-parent-animation-duration)ease-out}.modal-dialog.modal-solid{background:var(--modal-bg)}.modal-dialog.modal-transparent{background:var(--modal-bg-transparent);opacity:.4}.modal-dialog.modal-minimizing{pointer-events:none;animation:modal-genie-minimize var(--modal-animation-duration-minimize)ease-in forwards;transform-origin:var(--genie-origin-x,50%)var(--genie-origin-y,100%);will-change:transform,opacity;backface-visibility:hidden}.modal-dialog.modal-restoring{pointer-events:none;animation:modal-genie-restore var(--modal-animation-duration-restore)ease-out forwards;transform-origin:var(--genie-origin-x,50%)var(--genie-origin-y,100%);will-change:transform,opacity;backface-visibility:hidden}.modal-dialog.modal-opening{pointer-events:none;animation:modal-genie-restore var(--modal-animation-duration-open)ease-out forwards;transform-origin:var(--genie-origin-x,50%)var(--genie-origin-y,50%);will-change:transform,opacity;backface-visibility:hidden}.modal-dialog.modal-closing{pointer-events:none;animation:modal-close var(--modal-animation-duration-close)ease-in forwards;will-change:transform,opacity;backface-visibility:hidden}.modal-dialog.modal-closing:not(.modal-positioned){animation-name:modal-close-centered}.modal-dialog.modal-positioned.modal-minimizing,.modal-dialog.modal-positioned.modal-closing{transform:unset;opacity:unset}.modal-dialog.modal-positioned.modal-opening,.modal-dialog.modal-positioned.modal-restoring{transform:unset;opacity:1}.modal-dialog.modal-visible-by-animation{opacity:1}.modal-dialog.modal-attention{animation:.5s cubic-bezier(.36,.07,.19,.97) both modal-shake-positioned,.6s ease-out both modal-attention-glow}.modal-dialog.modal-attention:not(.modal-positioned){animation:.5s cubic-bezier(.36,.07,.19,.97) both modal-shake-centered,.6s ease-out both modal-attention-glow}.modal-dialog.modal-attention.modal-glow{--modal-attention-color:var(--modal-glow-color)}.modal-dialog.modal-glow{border-color:rgb(var(--modal-glow-color));animation:2s ease-in-out infinite modal-glow-medium}.modal-dialog.modal-glow.modal-glow-low{animation-name:modal-glow-low}.modal-dialog.modal-glow.modal-glow-high{animation-name:modal-glow-high}.modal-dialog.modal-glow.modal-minimizing{animation:modal-genie-minimize var(--modal-animation-duration-minimize)ease-in forwards}.modal-dialog.modal-glow.modal-restoring{animation:modal-genie-restore var(--modal-animation-duration-restore)ease-out forwards}.modal-dialog.modal-glow.modal-opening{animation:modal-genie-restore var(--modal-animation-duration-open)ease-out forwards}.modal-dialog.modal-glow.modal-closing{animation:modal-close var(--modal-animation-duration-close)ease-in forwards}.modal-header{padding:var(--modal-header-padding);border-bottom:1px solid var(--modal-header-border);z-index:101;outline:none;flex-shrink:0;align-items:center;gap:.75rem;display:flex;position:relative;overflow:visible}.modal-header.modal-header-draggable{cursor:grab;user-select:none;touch-action:none}.modal-header.modal-header-draggable:active{cursor:grabbing}.modal-header-traffic-lights{gap:var(--modal-btn-gap);z-index:100;flex-shrink:0;display:flex;position:relative}.modal-header-traffic-lights .modal-header-light{width:var(--modal-btn-size);height:var(--modal-btn-size);cursor:pointer;border:none;border-radius:50%;outline:none;flex-shrink:0;padding:0;transition:filter .15s,transform .1s;position:relative}.modal-header-traffic-lights .modal-header-light:before{content:"";opacity:0;justify-content:center;align-items:center;transition:opacity .15s;display:flex;position:absolute;inset:0}.modal-header-traffic-lights .modal-header-light:hover{transform:scale(1.1)}.modal-header-traffic-lights .modal-header-light:hover:before{opacity:1}.modal-header-traffic-lights .modal-header-light:focus-visible{box-shadow:0 0 0 2px #ffffff80,0 0 0 4px #0003}.modal-header-light-close{background:var(--modal-btn-close);box-shadow:inset 0 0 0 .5px #0000001f}.modal-header-light-close:hover{filter:brightness(.92)}.modal-header-traffic-lights .modal-header-light.modal-header-light-close:before{content:"×";color:#4a0002cc;font-size:11px;font-weight:600;line-height:13px}.modal-header-light-minimize{background:var(--modal-btn-minimize);box-shadow:inset 0 0 0 .5px #0000001f}.modal-header-light-minimize:hover{filter:brightness(.92)}.modal-header-traffic-lights .modal-header-light.modal-header-light-minimize:before{content:"−";color:#995700cc;font-size:13px;font-weight:600;line-height:12px}.modal-header-light-style{background:var(--modal-btn-style);box-shadow:inset 0 0 0 .5px #0000001f}.modal-header-light-style:hover{filter:brightness(.92)}.modal-header-traffic-lights .modal-header-light.modal-header-light-style:before{content:"◇";color:#006500cc;font-size:7px;line-height:13px}.modal-header-light.modal-header-light-disabled{opacity:.5;cursor:not-allowed;background:#ccc}.modal-header-light.modal-header-light-disabled:hover{filter:none}.modal-header-traffic-lights .modal-header-light.modal-header-light-disabled:before{opacity:.4}.modal-header-mac-center{pointer-events:none;justify-content:center;align-items:center;gap:.5rem;display:flex;position:absolute;left:0;right:0}.modal-header-mac-center .modal-header-title-group{flex:unset;pointer-events:auto}.modal-header-mac-center .modal-header-icon{pointer-events:auto}.modal-header-mac-spacer{display:none}.modal-header-title-group{flex:1;align-items:center;gap:.5rem;min-width:0;display:flex}.modal-header-title{font-size:var(--modal-title-size);color:var(--modal-title-color);white-space:nowrap;text-overflow:ellipsis;min-width:0;margin:0;overflow:hidden}.modal-header-icon{font-size:var(--modal-icon-size);width:var(--modal-icon-size);height:var(--modal-icon-size);flex-shrink:0;justify-content:center;align-items:center;display:inline-flex;position:relative}.modal-header-icon-badge{font-size:var(--modal-icon-badge-size);background:var(--modal-bg);border-radius:50%;padding:2px;line-height:1;position:absolute;bottom:-6px;right:-8px;box-shadow:0 1px 3px #0003}.modal-header-btn-windows{color:var(--modal-btn-windows-color);cursor:pointer;background:0 0;border:none;border-radius:4px;padding:.25rem;font-size:1.25rem;line-height:1;transition:background-color .15s,color .15s}.modal-header-btn-windows:hover{color:var(--modal-btn-windows-hover-color);background:var(--modal-btn-windows-hover-bg)}.modal-header-btn-windows-style{font-size:.9rem}.modal-header-btn-windows-close{padding:0;font-size:1.5rem}.modal-header-btn-windows.modal-header-btn-windows-disabled{opacity:.35;cursor:not-allowed}.modal-header-btn-windows.modal-header-btn-windows-disabled:hover{color:var(--modal-btn-windows-color);background:0 0}.modal-body{min-height:0;padding:var(--modal-content-padding);color:var(--modal-content-color);flex-direction:column;flex:auto;display:flex;position:relative;overflow-y:auto}.modal-body::-webkit-scrollbar{width:6px}.modal-body::-webkit-scrollbar-track{background:#0000000d}.modal-body::-webkit-scrollbar-thumb{background:#0003;border-radius:3px}.modal-footer{padding:var(--modal-footer-padding);border-top:1px solid var(--modal-footer-border);flex-shrink:0}.modal-footer-empty:empty{display:none}.modal-resize-handle{z-index:10;touch-action:none;position:absolute}.modal-resize-n,.modal-resize-s{height:var(--modal-resize-handle-size);cursor:ns-resize;left:8px;right:8px}.modal-resize-n{top:calc(var(--modal-resize-handle-size)/-2)}.modal-resize-s{bottom:calc(var(--modal-resize-handle-size)/-2)}.modal-resize-e,.modal-resize-w{width:var(--modal-resize-handle-size);cursor:ew-resize;top:8px;bottom:8px}.modal-resize-e{right:calc(var(--modal-resize-handle-size)/-2)}.modal-resize-w{left:calc(var(--modal-resize-handle-size)/-2)}.modal-resize-ne,.modal-resize-nw,.modal-resize-se,.modal-resize-sw{width:var(--modal-resize-corner-size);height:var(--modal-resize-corner-size)}.modal-resize-ne{top:calc(var(--modal-resize-handle-size)/-2);right:calc(var(--modal-resize-handle-size)/-2);cursor:nesw-resize}.modal-resize-nw{top:calc(var(--modal-resize-handle-size)/-2);left:calc(var(--modal-resize-handle-size)/-2);cursor:nwse-resize}.modal-resize-se{bottom:calc(var(--modal-resize-handle-size)/-2);right:calc(var(--modal-resize-handle-size)/-2);cursor:nwse-resize}.modal-resize-sw{bottom:calc(var(--modal-resize-handle-size)/-2);left:calc(var(--modal-resize-handle-size)/-2);cursor:nesw-resize}.modal-child-overlay{background:var(--modal-child-overlay-bg);backdrop-filter:blur(var(--modal-child-overlay-blur));border-radius:inherit;z-index:100;cursor:not-allowed;pointer-events:all;animation:.2s ease-out forwards modal-overlay-fade-in;position:absolute;inset:0}.modal-child-overlay.modal-overlay-closing{pointer-events:none;animation:.2s ease-in forwards modal-overlay-fade-out}.modal-dialog.modal-has-child .modal-header-actions{pointer-events:none;opacity:.5}.modal-dialog.modal-has-child .modal-header-draggable{cursor:not-allowed}.modal-dialog.modal-is-child.modal-positioned:not(.modal-closing):not(.modal-minimizing):not(.modal-restoring){animation:.25s ease-out forwards modal-child-appear}.modal-dialog.modal-is-child.modal-closing{animation:.2s ease-in forwards modal-child-disappear}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte action to append an external DOM element
|
|
3
|
+
* Used by React bridge to inject React-rendered content
|
|
4
|
+
*/
|
|
5
|
+
export declare function appendElement(node: HTMLElement, element: HTMLElement | null | undefined): {
|
|
6
|
+
update(newElement: HTMLElement | null | undefined): void;
|
|
7
|
+
destroy(): void;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=appendElement.d.ts.map
|
|
@@ -13,7 +13,7 @@ export interface UseModalZIndexReturn {
|
|
|
13
13
|
* @example
|
|
14
14
|
* ```svelte
|
|
15
15
|
* <script lang="ts">
|
|
16
|
-
* import { useModalZIndex, Portal } from '
|
|
16
|
+
* import { useModalZIndex, Portal } from 'epic-modals/svelte';
|
|
17
17
|
*
|
|
18
18
|
* // Automatically uses parent modal's ID from context
|
|
19
19
|
* const { zIndex, portalTarget } = useModalZIndex();
|
package/dist/svelte.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"svelte/internal/client";import"svelte/internal/disclose-version";import{getContext as t,onMount as n,setContext as i,tick as o,onDestroy as r,untrack as s}from"svelte";import{scale as d,fly as a,fade as l}from"svelte/transition";import{cubicOut as c,backOut as g}from"svelte/easing";const u={BASE:0,DROPDOWN:100,STICKY:200,OVERLAY:300,MODAL:400,DOCK:8e3,TOAST:9e3};let h=e.state(e.proxy(u.MODAL));function p(){e.set(h,ft().zIndex.base,!0)}function f(){const t=e.get(h);return e.set(h,e.get(h)+2),t}function m(e){const t=ft();return"MODAL"===e?t.zIndex.base:"DOCK"===e?t.zIndex.dock:"TOAST"===e?t.zIndex.toast:u[e]}function v(){e.set(h,ft().zIndex.base,!0)}const w=8;function y(e,t,n,i,o={}){const{margin:r=w,allowPartialVisibility:s=!1}=o,d="undefined"!=typeof window?window.innerWidth:1920,a="undefined"!=typeof window?window.innerHeight:1080;let l,c,g,u;return s&&n>d-2*r?(l=40-n,c=d-40):(l=r,c=Math.max(r,d-n-r)),s&&i>a-2*r?(g=40-i,u=a-40):(g=r,u=Math.max(r,a-i-r)),{x:Math.max(l,Math.min(c,e)),y:Math.max(g,Math.min(u,t))}}function x(e,t,n,i,o={}){const{margin:r=w}=o,s=("undefined"!=typeof window?window.innerWidth:1920)-2*r,d=("undefined"!=typeof window?window.innerHeight:1080)-2*r,a=Math.min(n,s),l=Math.min(i,d),c=y(e,t,a,l,o);return{x:c.x,y:c.y,width:a,height:l}}function z(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 I(e,t,n,i,o,r){const s={x:e-r,y:t-r,width:n+2*r,height:i+2*r};let d=0;for(const e of o)d+=z(s,e);return d}function b(e){if("undefined"==typeof document)return[];const t=[];for(const n of e)try{const e=document.querySelectorAll(n);for(const n of e){const e=n.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 _(e,t,n,i,o,r,s){const d=(o-n)/2,a=(r-i)/2,l=d-s,c=a-s,g=Math.abs(e-d)/(l||1),u=Math.abs(t-a)/(c||1),h=Math.sqrt(g*g+u*u)/Math.SQRT2,p=50,f=e-s,m=o-n-s-e,v=t-s,w=r-i-s-t;let y=0;return f<p&&(y+=.3*(1-f/p)),m<p&&(y+=.3*(1-m/p)),v<p&&(y+=.2*(1-v/p)),w<p&&(y+=.2*(1-w/p)),Math.min(1,h+y)}function M(e,t,n,i={}){const{modalGap:o=16,gridResolution:r=10,avoidBounds:s=[],avoidMargin:d=16}=i,a=i.margin??o,l="undefined"!=typeof window?window.innerWidth:1920,c="undefined"!=typeof window?window.innerHeight:1080,g=s.map(e=>({x:e.x-d,y:e.y-d,width:e.width+2*d,height:e.height+2*d})),u={x:(l-e)/2,y:(c-t)/2};if(0===n.length&&0===g.length)return u;const h=a,p=Math.max(a,l-e-a),f=a,m=Math.max(a,c-t-a);if(p<=h||m<=f)return u;const v=I(u.x,u.y,e,t,n,o),w=I(u.x,u.y,e,t,g,0);if(0===v&&0===w)return u;const y=[],x=(p-h)/r,z=(m-f)/r;for(let i=0;i<=r;i++)for(let s=0;s<=r;s++){const r=h+i*x,d=f+s*z,u=I(r,d,e,t,n,o),p=I(r,d,e,t,g,0),m=_(r,d,e,t,l,c,a);y.push({pos:{x:r,y:d},modalOverlap:u,avoidOverlap:p,centerDist:m})}const b=y.filter(e=>0===e.avoidOverlap),M=b.length>0?b:y,k=e*t,D=Math.min(...M.map(e=>e.modalOverlap))/k;return M.sort((e,t)=>{if(0===b.length&&e.avoidOverlap!==t.avoidOverlap)return e.avoidOverlap-t.avoidOverlap;const n=e.modalOverlap/k,i=t.modalOverlap/k;if(D<.3){const o=.3,r=n<=o,s=i<=o;if(r&&s)return e.centerDist+.3*n-(t.centerDist+.3*i);if(r)return-1;if(s)return 1}return.6*n+.4*e.centerDist-(.6*i+.4*t.centerDist)}),M[0].pos}function k(e,t,n,i={}){const{modalGap:o=16}=i,r=i.margin??o,s="undefined"!=typeof window?window.innerWidth:1920,d="undefined"!=typeof window?window.innerHeight:1080,a=n.reduce((e,t)=>e+t.width,0)+e,l=n.length*o,c=s-2*r;if(a+l>c)return null;const g=c-a-l;n.length;const u=g/2,h=s/2,p=[...n.map(e=>({id:e.id,width:e.width,height:e.height,currentX:e.x+e.width/2,currentY:e.y,isNew:!1})),{id:"__new__",width:e,height:t,currentX:h,currentY:(d-t)/2,isNew:!0}];p.sort((e,t)=>e.currentX-t.currentX);let f=r+u;const m=new Map;let v=null;for(const e of p){const t=f;if(e.isNew)v={x:Math.round(t),y:Math.round(e.currentY)};else{const i=n.find(t=>t.id===e.id);Math.abs(t-i.x)>5&&m.set(e.id,{x:Math.round(t),y:Math.round(i.y)})}f+=e.width+o}return v?{newModalPosition:v,existingModalMoves:m}:null}let D=e.proxy(new Map),P=e.state(0);const C=new Set;function B(){e.update(P),queueMicrotask(()=>{C.forEach(e=>e())})}function O(e){return C.add(e),()=>C.delete(e)}let T=e.state(e.proxy([])),R=e.state(e.proxy([])),E=e.state(e.proxy([])),S=e.state(e.proxy([])),H=e.state(e.proxy([])),F=e.state(e.proxy([])),L=e.state(e.proxy([])),W=e.state(e.proxy([])),A=e.state(null),$=e.proxy(new Map),X=e.state(null),Y=e.proxy(new Map),q=e.proxy(new Set),N=e.proxy(new Set),j=e.state(e.proxy([])),G=null,K=null;function V(t){const n=D.get(t.id),i=(null==n?void 0:n.zIndex)??f();n?D.set(t.id,{...n,title:t.title,icon:t.icon,glow:t.glow,zIndex:i}):D.set(t.id,{...t,zIndex:i,isAnimating:!1}),B(),t.isMinimized&&!e.get(j).includes(t.id)&&e.get(j).push(t.id)}function U(t){const n=D.get(t);if(n){if(e.set(j,e.get(j).filter(e=>e!==t),!0),n.childId){const e=D.get(n.childId);e&&D.set(n.childId,{...e,parentId:void 0})}if(n.parentId){const e=D.get(n.parentId);e&&D.set(n.parentId,{...e,childId:void 0,lastChildId:n.id})}D.delete(t),B(),N.delete(t),q.delete(t)}}function Q(t){const n=D.get(t);if(!n||n.isMinimized)return;if(it(t),n.parentId){const e=D.get(n.parentId);if(e&&!e.isMinimized)return void Q(n.parentId)}if(e.set(T,[...e.get(T),t],!0),n.position&&n.size&&K){const i=K(),o=e.get(j).indexOf(t),r=i.x+o*(i.height+8),s=i.y;e.set(A,{x:r,y:s,originX:n.position.x+n.size.width/2,originY:n.position.y+n.size.height/2},!0)}const i=n.childId;D.set(t,{...n,isMinimized:!0,lastChildId:i}),B(),e.get(j).includes(t)||e.get(j).push(t),n.childId&&fe(t)}function Z(t){const n=D.get(t);if(!n||!n.isMinimized)return;D.set(t,{...n,isMinimized:!1,isOpen:!0}),B(),e.set(H,[...e.get(H),t],!0),oe(t);const i=n.lastChildId||n.childId;i&&ee(i)}function J(){Array.from(D.values()).filter(e=>e.isMinimized).map(e=>e.id).forEach(t=>{const n=D.get(t);if(n){D.set(t,{...n,isMinimized:!1,isOpen:!0}),e.set(H,[...e.get(H),t],!0),oe(t);const i=n.lastChildId||n.childId;i&&ee(i)}}),e.set(j,[],!0),B()}function ee(t){const n=D.get(t);n&&n.isHiddenWithParent&&(D.set(t,{...n,isHiddenWithParent:!1}),B(),e.set(F,[...e.get(F),t],!0))}function te(e,t,n){const i=D.get(e);if(!i)return;let o=t;if((null==n?void 0:n.constrain)&&i.size&&(o=y(t.x,t.y,i.size.width,i.size.height)),D.set(e,{...i,position:o,size:(null==n?void 0:n.size)??i.size,hasBeenDragged:i.hasBeenDragged||(null==n?void 0:n.drag)||!1}),i.childId){let t=e,n=o;for(;;){const e=D.get(t);if(!(null==e?void 0:e.childId))break;const i=D.get(e.childId);if(!(null==i?void 0:i.offsetFromParent))break;const o={x:n.x+i.offsetFromParent.x,y:n.y+i.offsetFromParent.y};D.set(e.childId,{...i,position:o,hasBeenDragged:!0}),t=e.childId,n=o}}if(i.parentId&&i.offsetFromParent){const t=ft();let n=e,r=i;for(;r.parentId&&r.offsetFromParent;){const i=D.get(r.parentId);if(!i)break;const s=n===e?o:D.get(n).position,d={x:s.x-r.offsetFromParent.x,y:s.y-r.offsetFromParent.y};"animated"===t.parentChild.movementMode?Y.set(r.parentId,d):D.set(r.parentId,{...i,position:d,hasBeenDragged:!0}),n=r.parentId,r=i}}B()}function ne(e,t){const n=D.get(e);n&&(D.set(e,{...n,size:t}),B())}function ie(e,t){const n=D.get(e);n&&(D.set(e,{...n,...t}),B())}function oe(e){var t;const n=D.get(e);if(!n)return;const i=Math.max(...Array.from(D.values()).map(e=>e.zIndex),0);if(n.parentId){const o=D.get(n.parentId);o&&o.zIndex<i&&D.set(n.parentId,{...o,zIndex:i+2});const r=(null==(t=D.get(n.parentId))?void 0:t.zIndex)??i+2;return n.zIndex<=r&&D.set(e,{...n,zIndex:r+2}),void B()}if(n.zIndex<i&&(D.set(e,{...n,zIndex:i+2}),B()),n.childId){const t=D.get(n.childId),i=D.get(e);t&&i&&t.zIndex<=i.zIndex&&(D.set(n.childId,{...t,zIndex:i.zIndex+2}),B())}}function re(e){const t=D.get(e);if(!t)return!1;const n=Math.max(...Array.from(D.values()).map(e=>e.zIndex),0);return t.zIndex===n&&!t.isMinimized&&!t.isHiddenWithParent}function se(t){e.set(j,t,!0)}function de(t,n,i){const o=n.getBoundingClientRect();$.set(t,{x:o.left+o.width/2,y:o.top+o.height/2});const r=ft();(null==i?void 0:i.parentId)&&r.features.parentChild&&e.set(X,{parentId:i.parentId,childId:t},!0),e.get(R).includes(t)||e.set(R,[...e.get(R),t],!0),B();const s=D.get(t);if(s){if(s.isOpen&&!s.isMinimized&&!s.isHiddenWithParent)return e.set(R,e.get(R).filter(e=>e!==t),!0),We(t),void oe(t);if(s.isMinimized)return e.set(R,e.get(R).filter(e=>e!==t),!0),void Z(t);D.set(t,{...s,isOpen:!0}),oe(t),null==G||G.push(t)}}function ae(t){V(t);const n=D.get(t.id);n&&(D.set(t.id,{...n,isOpen:!0}),B()),e.set(R,[...e.get(R),t.id],!0),B(),oe(t.id),null==G||G.push(t.id)}function le(t,n=!1){const i=D.get(t);i&&(it(t),n?e.set(S,[...e.get(S),t],!0):e.set(E,[...e.get(E),t],!0),B(),i.childId&&le(i.childId,n),null==G||G.pop())}function ce(){Array.from(D.keys()).forEach(e=>le(e,!0))}function ge(e){const t=D.get(e);if(t){if(t.parentId){const n=D.get(t.parentId);n&&n.childId===e&&D.set(t.parentId,{...n,childId:void 0,lastChildId:e})}D.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}),B()}}function ue(e){const t=D.get(e);if(!t)return[e];const n=[e];return t.childId&&n.push(...ue(t.childId)),n}function he(t,n,i){const o=ft();if(i&&!$.has(t.id)){const e=i.getBoundingClientRect();$.set(t.id,{x:e.left+e.width/2,y:e.top+e.height/2})}const r={id:t.id,title:t.title??"",icon:t.icon??"",isOpen:!0,isMinimized:!1,isHiddenWithParent:!1,isTransparent:t.isTransparent??!1,isRejected:!1,position:t.position??null,size:t.size??null,hasBeenDragged:t.hasBeenDragged??!1,dockPosition:t.dockPosition??-1,glow:t.glow??null};if(!o.features.parentChild){V(r);const n=D.get(t.id);return n&&D.set(t.id,{...n,isOpen:!0}),e.set(R,[...e.get(R),t.id],!0),B(),void oe(t.id)}const s=D.get(n);if(!s)return;s.childId&&le(s.childId,!0),V({...r,parentId:n});const d=D.get(t.id);d&&D.set(t.id,{...d,isOpen:!0,parentId:n}),e.set(R,[...e.get(R),t.id],!0),B(),oe(t.id),e.set(X,{parentId:n,childId:t.id},!0)}function pe(e,t){if(!ft().features.parentChild)return;const n=D.get(e),i=D.get(t);if(!n||!i)return;let o={x:40,y:40};n.position&&i.position&&(o={x:i.position.x-n.position.x,y:i.position.y-n.position.y});const r=Math.max(i.zIndex,n.zIndex+1);D.set(e,{...n,childId:t,lastChildId:t}),D.set(t,{...i,parentId:e,offsetFromParent:o,zIndex:r}),B()}function fe(e){const t=D.get(e);if(!(null==t?void 0:t.childId))return;const n=D.get(t.childId);n&&(D.set(t.childId,{...n,isHiddenWithParent:!0}),B())}function me(e,t){const n=D.get(e);if(!(null==n?void 0:n.childId))return;const i=D.get(n.childId);if(!i||!i.offsetFromParent)return;const o={x:t.x+i.offsetFromParent.x,y:t.y+i.offsetFromParent.y};D.set(n.childId,{...i,position:o}),B()}function ve(e,t){const n=D.get(e),i=D.get(t);if(!(null==n?void 0:n.position)||!(null==i?void 0:i.position))return;const o={x:n.position.x-i.position.x,y:n.position.y-i.position.y};D.set(e,{...n,offsetFromParent:o}),B()}function we(t){return e.get(T).includes(t)}function ye(t){return!!e.get(T).includes(t)&&(e.set(T,e.get(T).filter(e=>e!==t),!0),!0)}function xe(){return e.get(T).length>0}function ze(){return Array.from(D.keys())}function Ie(e){return D.get(e)}function be(e){const t=[];for(const[n,i]of D.entries())if(n!==e&&i.isOpen&&!i.isMinimized&&!i.isHiddenWithParent&&!i.parentId)if(i.position&&i.size)t.push({id:String(n),x:i.position.x,y:i.position.y,width:i.size.width,height:i.size.height});else{const e=document.querySelector(`[data-modal-id="${String(n)}"]`);if(e){const i=e.getBoundingClientRect();t.push({id:String(n),x:i.left,y:i.top,width:i.width,height:i.height})}}return t}function _e(e){const t=[];for(const[n,i]of D.entries())if(n!==e&&i.isOpen&&!i.isMinimized&&!i.isHiddenWithParent)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=document.querySelector(`[data-modal-id="${String(n)}"]`);if(e){const n=e.getBoundingClientRect();t.push({x:n.left,y:n.top,width:n.width,height:n.height})}}return t}function Me(){return e.get(P)}function ke(){const t=e.get(A);return e.set(A,null),t}function De(t){return e.get(R).includes(t)}function Pe(t){return!!e.get(R).includes(t)&&(e.set(R,e.get(R).filter(e=>e!==t),!0),!0)}function Ce(t){return e.get(E).includes(t)}function Be(t){return!!e.get(E).includes(t)&&(e.set(E,e.get(E).filter(e=>e!==t),!0),!0)}function Oe(t){return e.get(S).includes(t)}function Te(t){return!!e.get(S).includes(t)&&(e.set(S,e.get(S).filter(e=>e!==t),!0),!0)}function Re(t){return e.get(H).includes(t)}function Ee(t){return!!e.get(H).includes(t)&&(e.set(H,e.get(H).filter(e=>e!==t),!0),!0)}function Se(t){return e.get(F).includes(t)}function He(t){return!!e.get(F).includes(t)&&(e.set(F,e.get(F).filter(e=>e!==t),!0),!0)}function Fe(t){return e.get(L).includes(t)}function Le(t){return!!e.get(L).includes(t)&&(e.set(L,e.get(L).filter(e=>e!==t),!0),!0)}function We(t){D.get(t)&&(e.get(L).includes(t)||e.get(W).includes(t)||(e.set(L,[...e.get(L),t],!0),B()))}function Ae(t){e.get(W).includes(t)||e.set(W,[...e.get(W),t],!0)}function $e(t){e.set(W,e.get(W).filter(e=>e!==t),!0)}function Xe(){return e.get(X)}function Ye(t){if(!e.get(X)||e.get(X).childId!==t)return null;const n=e.get(X);return e.set(X,null),n}function qe(e,t){$.set(e,t)}function Ne(e){const t=$.get(e);return t&&$.delete(e),t??null}function je(e,t){t?q.add(e):q.delete(e)}function Ge(e){return q.has(e)}function Ke(e){const t=D.get(e);return void 0!==t&&t.isOpen&&!t.isMinimized&&!t.isHiddenWithParent}function Ve(e){return D.has(e)}function Ue(){return{get modals(){return D},get pendingMinimize(){return e.get(T)},get pendingOpen(){return e.get(R)},get pendingClose(){return e.get(E)},get pendingRestore(){return e.get(H)},get dockOrder(){return e.get(j)}}}function Qe(e){N.has(e)?N.delete(e):N.add(e);const t=D.get(e);t&&(D.set(e,{...t,isTransparent:N.has(e)}),B())}function Ze(e){N.delete(e);const t=D.get(e);t&&(D.set(e,{...t,isTransparent:!1}),B())}function Je(e){e.animate([{transform:"translateX(0)"},{transform:"translateX(-6px)"},{transform:"translateX(6px)"},{transform:"translateX(-6px)"},{transform:"translateX(6px)"},{transform:"translateX(0)"}],{duration:300,easing:"ease-in-out"})}function et(e){const t=Y.get(e);if(!t)return;const n=D.get(e);n&&(D.set(e,{...n,isAnimatingPosition:!0,position:t}),Y.delete(e),B())}function tt(e){const t=D.get(e);t&&(D.set(e,{...t,isAnimatingPosition:!1}),B())}function nt(e){return Y.has(e)}function it(e){Y.delete(e)}function ot(e){const t=ft().parentChild.animationDuration;for(const[t,n]of e){const e=D.get(t);e&&D.set(t,{...e,position:n,isAnimatingPosition:!0,hasBeenDragged:!0})}B(),setTimeout(()=>{for(const t of e.keys()){const e=D.get(t);e&&D.set(t,{...e,isAnimatingPosition:!1})}B()},t)}function rt(e){const t=ft();if("animated"!==t.parentChild.movementMode)return;const n=t.parentChild.animationDuration,i=[];let o=e;for(;;){const e=D.get(o);if(!(null==e?void 0:e.parentId))break;i.push({parentId:e.parentId,childId:o}),o=e.parentId}i.forEach(({parentId:e,childId:t},i)=>{setTimeout(()=>{const i=D.get(t),o=D.get(e);if(!(null==i?void 0:i.position)||!i.offsetFromParent||!o)return;const r={x:i.position.x-i.offsetFromParent.x,y:i.position.y-i.offsetFromParent.y};Y.set(e,r),et(e),setTimeout(()=>tt(e),n)},i*n)})}function st(e){}function dt(e){G=e}function at(e){K=e}function lt(){return{modals:D,pendingMinimize:e.get(T),pendingOpen:e.get(R),pendingClose:e.get(E),pendingRestore:e.get(H),dockOrder:e.get(j),animatingModals:q,transparentModals:N}}function ct(){D.clear(),e.get(T).length=0,e.get(R).length=0,e.get(E).length=0,e.get(S).length=0,e.get(H).length=0,e.get(F).length=0,e.set(A,null),$.clear(),e.set(X,null),Y.clear(),q.clear(),N.clear(),e.get(j).length=0,G=null,K=null}const gt={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},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 ut={...gt},ht=e.state(0);function pt(){return e.get(ht)}function ft(){return ut}function mt(t){const n=ut;ut=wt(gt,t),e.update(ht),n.features.dock&&!ut.features.dock&&J()}function vt(){ut={...gt},e.update(ht)}function wt(e,t){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},portalTarget:t.portalTarget??e.portalTarget}}function yt(e){return ut.features[e]}const xt=Symbol("modal-render-icon"),zt=Symbol("modal-id");function It(e,t){if(!Ve(e))throw new Error(`Cannot call ${t}() on unregistered modal "${String(e)}". Ensure the Modal component is rendered.`)}function bt(e){return{shake:()=>{It(e,"shake"),We(e)},bringToFront:()=>{It(e,"bringToFront"),oe(e)},isOpen:()=>Ke(e),isRegistered:()=>Ve(e),open:t=>{It(e,"open"),de(e,t)},close:()=>{It(e,"close"),le(e)},minimize:()=>{It(e,"minimize"),Q(e)},restore:()=>{It(e,"restore"),Z(e)},openChild:(t,n)=>{It(e,"openChild"),he({id:t},e,n)}}}function _t(t={x:0,y:0}){const n=e.proxy({...t}),i=e.proxy({isDragging:!1,startX:0,startY:0,initialX:0,initialY:0,hasBeenDragged:!1});return{get position(){return n},get hasBeenDragged(){return i.hasBeenDragged},get isDragging(){return i.isDragging},onPointerDown:function(e,t){if(0===e.button){if(!i.hasBeenDragged){const e=t.getBoundingClientRect();n.x=e.left,n.y=e.top}i.isDragging=!0,i.startX=e.clientX,i.startY=e.clientY,i.initialX=n.x,i.initialY=n.y,t.setPointerCapture(e.pointerId)}},onPointerMove:function(e,t,o){if(!i.isDragging)return;const r=e.clientX-i.startX,s=e.clientY-i.startY,d=y(i.initialX+r,i.initialY+s,o.width,o.height);n.x=d.x,n.y=d.y,i.hasBeenDragged=!0},onPointerUp:function(e,t){i.isDragging&&(i.isDragging=!1,t.releasePointerCapture(e.pointerId))},setPosition:function(e){n.x=e.x,n.y=e.y},setHasBeenDragged:function(e){i.hasBeenDragged=e},reset:function(){n.x=t.x,n.y=t.y,i.hasBeenDragged=!1}}}function Mt(t,n,i,o,r,s,d){let a=e.state(!1),l=e.state(""),c=e.state(e.proxy({width:0,height:0})),g=e.state(!1),u=e.state(!1),h={x:0,y:0,width:0,height:0,posX:0,posY:0,centerX:0,centerY:0},p=null;function f(s,d){s.preventDefault(),s.stopPropagation();const u=t();if(!u)return;const f=u.getBoundingClientRect();o()||(i({x:f.left,y:f.top}),r(!0)),e.get(g)||(e.set(c,{width:f.width,height:f.height},!0),e.set(g,!0));const w=n();e.set(a,!0),e.set(l,d,!0),p=s.pointerId,h={x:s.clientX,y:s.clientY,width:e.get(c).width,height:e.get(c).height,posX:w.x,posY:w.y,centerX:w.x+e.get(c).width/2,centerY:w.y+e.get(c).height/2},window.addEventListener("pointermove",m),window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v)}function m(t){if(t.pointerId!==p)return;const n=t.clientX-h.x,o=t.clientY-h.y,r=window.innerWidth,s=window.innerHeight,a=(null==d?void 0:d())??!1;let g=h.width,u=h.height,f=h.posX,m=h.posY;if(a){if(e.get(l).includes("e")||e.get(l).includes("w")){const t=e.get(l).includes("e")?n:-n;g=Math.max(280,h.width+2*t),f=h.centerX-g/2}if(e.get(l).includes("s")||e.get(l).includes("n")){const t=e.get(l).includes("s")?o:-o;u=Math.max(200,h.height+2*t),m=h.centerY-u/2}}else{if(e.get(l).includes("e")){const e=r-f;g=Math.max(280,Math.min(h.width+n,e))}if(e.get(l).includes("w")){const e=h.width-280,t=Math.min(n,e);g=h.width-t,f=h.posX+t}if(e.get(l).includes("s")){const e=s-m;u=Math.max(200,Math.min(h.height+o,e))}if(e.get(l).includes("n")){const e=h.height-200,t=Math.min(o,e);u=h.height-t,m=h.posY+t}}const v=x(f,m,g,u);e.set(c,{width:v.width,height:v.height},!0),i({x:v.x,y:v.y})}function v(t){t.pointerId===p&&(e.set(a,!1),p=null,window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v),e.set(u,!0),s(n(),e.get(c)),setTimeout(()=>{e.set(u,!1)},0))}const w={startResize:f};return{get isResizing(){return e.get(a)},get resizeDirection(){return e.get(l)},get size(){return e.get(c)},get hasBeenResized(){return e.get(g)},get isActive(){return e.get(a)},get justFinishedResizing(){return e.get(u)},start:f,setHasBeenResized:()=>{},setSize:function(t){e.set(c,t,!0),e.set(g,!0)},reset:function(){e.set(g,!1),e.set(c,{width:0,height:0},!0)},constrainToViewport:function(){const o=n(),r=t();if(!r)return;const s=x(o.x,o.y,e.get(c).width||r.offsetWidth,e.get(c).height||r.offsetHeight);e.set(c,{width:s.width,height:s.height},!0),i({x:s.x,y:s.y})},handlers:w}}function kt(){return ft().features.animations}function Dt(t,n,i,o,r,s,d,a,l){let c=e.state(!1),g=e.state(!1),u=e.state(!1),h=e.state(!1),p=e.state(null),f=e.state(null),m=null,v=null;function w(){v&&(clearTimeout(v),v=null)}function y(){const e=t(),n=document.querySelector(`.modal-dock-item[data-modal-id="${e}"]`),i=document.querySelector('[data-dock-container="true"]'),o=n||i;if(o){const e=o.getBoundingClientRect();return{x:e.left+e.width/2,y:e.top+e.height/2}}return{x:window.innerWidth/2,y:window.innerHeight-40}}return e.user_effect(()=>()=>{w(),e.set(c,!1),e.set(g,!1),e.set(u,!1),e.set(h,!1),e.set(p,null),e.set(f,null),m=null}),{get isMinimizing(){return e.get(c)},get isRestoring(){return e.get(g)},get isOpening(){return e.get(u)},get isClosing(){return e.get(h)},get animationTransform(){return e.get(p)},get pendingOpenSource(){return e.get(f)},startMinimize:function(t,h){const f=n();if(e.get(c)||!f)return;if(e.set(g,!1),e.set(u,!1),w(),!kt()){const e=f.getBoundingClientRect();let t=r()?i():{x:e.left,y:e.top},n=d()?a():{width:e.width,height:e.height};return r()||(o(t),s(!0)),void(h?h():l(t,!0,n))}const m=f.getBoundingClientRect(),x=m.left+m.width/2,z=m.top+m.height/2;let I=r()?i():{x:m.left,y:m.top},b=d()?a():{width:m.width,height:m.height};r()||(o(I),s(!0));const _=t??y(),M=_.x-m.left,k=_.y-m.top,D={x:_.x-x,y:_.y-z,originX:M,originY:k};e.set(p,D,!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.set(c,!0)})}),v=setTimeout(()=>{h?h():l(I,!0,b)},500)},startRestore:function(t,n){if(!kt()){const e=t||{x:window.innerWidth/2,y:window.innerHeight/2};return o(e),void s(!0)}const i=y(),r=t||{x:window.innerWidth/2,y:window.innerHeight/2},d=n||{width:480,height:400};o(r),s(!0);const a=r.x+d.width/2,l=r.y+d.height/2,c=i.x-r.x,u=i.y-r.y;e.set(p,{x:i.x-a,y:i.y-l,originX:c,originY:u},!0),e.set(g,!0),setTimeout(()=>{e.set(g,!1),e.set(p,null)},400)},startClose:function(t){e.get(h)||e.get(c)||(kt()?(m=t,e.set(h,!0),setTimeout(()=>{e.set(h,!1),m&&(m(),m=null)},250)):t())},setPendingOpenSource:function(t){e.set(f,t,!0)},tryStartOpenAnimation:function(){const t=n();if(!e.get(f)||!t||e.get(u))return!1;if(!kt())return e.set(f,null),!1;const d=e.get(f);e.set(f,null);const a=t.getBoundingClientRect(),l=r()?i():{x:a.left,y:a.top},c=a.width,g=a.height,h=l.x+c/2,m=l.y+g/2;r()||(o(l),s(!0));const v=d.x-l.x,w=d.y-l.y;return e.set(p,{x:d.x-h,y:d.y-m,originX:v,originY:w},!0),e.set(u,!0),setTimeout(()=>{e.set(u,!1),e.set(p,null)},400),!0},forceClearMinimize:function(){w(),e.set(c,!1),e.set(p,null)}}}const Pt=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function Ct(e){return Array.from(e.querySelectorAll(Pt)).filter(e=>null!==e.offsetParent||"A"===e.tagName)}function Bt(e,t){if("Tab"!==e.key)return;const n=Ct(t);if(0===n.length)return void e.preventDefault();const i=n[0],o=n[n.length-1],r=document.activeElement;e.shiftKey?r===i&&(o.focus(),e.preventDefault()):r===o&&(i.focus(),e.preventDefault())}function Ot(e){const t=Ct(e);return t.length>0&&(t[0].focus(),!0)}function Tt(){return{trapFocus:Bt,focusFirstElement:Ot}}const Rt="modal-portal";function Et(){return{mount:function(e,t=null){const n=function(e){if("undefined"==typeof window)return null;if(e instanceof HTMLElement)return e;if("string"==typeof e){const t=document.querySelector(e);if(t)return t;if(e.startsWith("#")){const t=e.slice(1),n=document.createElement("div");return n.id=t,document.body.appendChild(n),n}}let t=document.getElementById(Rt);return t||(t=document.createElement("div"),t.id=Rt,document.body.appendChild(t)),t}(t);return n?(n.appendChild(e),()=>{e.parentNode===n&&n.removeChild(e),n.id!==Rt&&0===n.children.length&&n.parentNode&&n.parentNode.removeChild(n)}):()=>{}}}}function St(e){const n=t(zt),i=e??n;if(!i)throw new Error("useModalZIndex: No modal ID provided and no modal context found. Either pass a modal ID or use this hook inside a Modal component.");return{get zIndex(){const e=Ie(i);return((null==e?void 0:e.zIndex)??ft().zIndex.base)+1},get portalTarget(){return ft().portalTarget}}}function Ht(){function t(e,t,n){return"undefined"==typeof window?()=>{}:(window.addEventListener(e,t,n),()=>{window.removeEventListener(e,t,n)})}return{addListener:t,addListenerEffect:function(n,i,o){e.user_effect(()=>{if("undefined"!=typeof window)return t(n,i,o)})}}}var Ft=e.from_html('<div style="display: contents;"><!></div>');function Lt(t,i){e.push(i,!0);let o=e.prop(i,"target",3,"body"),r=null,s=null;const{mount:d}=Et();n(()=>(r&&(s=d(r,o())),()=>{null==s||s()}));var a=Ft(),l=e.child(a);e.snippet(l,()=>i.children),e.reset(a),e.bind_this(a,e=>r=e,()=>r),e.append(t,a),e.pop()}var Wt=e.from_html('<button type="button" aria-label="Minimize"></button>'),At=e.from_html('<button type="button" class="modal-header-light modal-header-light-style" aria-label="Toggle style"></button>'),$t=e.from_html('<div class="modal-header-icon"><!></div>'),Xt=e.from_html('<div class="modal-header-icon"><!></div>'),Yt=e.from_html('<h2 class="modal-header-title"> </h2>'),qt=e.from_html('<h2 class="modal-header-title"> </h2>'),Nt=e.from_html('<div class="modal-header-traffic-lights"><button type="button" class="modal-header-light modal-header-light-close" aria-label="Close"></button> <!> <!></div> <div class="modal-header-mac-center"><!> <div class="modal-header-title-group"><!></div></div> <div class="modal-header-mac-spacer"></div>',1),jt=e.from_html('<div class="modal-header-icon"><!></div>'),Gt=e.from_html('<div class="modal-header-icon"><!></div>'),Kt=e.from_html('<h2 class="modal-header-title"> </h2>'),Vt=e.from_html('<h2 class="modal-header-title"> </h2>'),Ut=e.from_html('<button type="button" class="modal-header-btn-windows modal-header-btn-windows-style" aria-label="Toggle style">◇</button>'),Qt=e.from_html('<button type="button" aria-label="Minimize">–</button>'),Zt=e.from_html('<div class="modal-header-title-group"><!> <!></div> <div class="modal-header-actions"><!> <!> <button type="button" class="modal-header-btn-windows modal-header-btn-windows-close" aria-label="Close">×</button></div>',1),Jt=e.from_html("<header><!></header>");function en(n,i){e.push(i,!0);let o=e.prop(i,"isTransparent",3,!1),r=e.prop(i,"headerLayout",3,"macos"),s=e.prop(i,"minimizable",3,!0),d=e.prop(i,"minimizeDisabled",3,!1),a=e.prop(i,"transparencyEnabled",3,!0);const l=t(xt),c=e.derived(()=>null==l?void 0:l()),g=e.derived(()=>"macos"===r());var u=Jt();let h;u.__pointerdown=function(e){var t;e.target.closest("button")||null==(t=i.onStartDrag)||t.call(i,e)};var p=e.child(u),f=t=>{var n=Nt(),o=e.first_child(n),r=e.child(o);r.__click=function(...e){var t;null==(t=i.onClose)||t.apply(this,e)};var l=e.sibling(r,2),g=t=>{var n=Wt();let o;n.__click=function(...e){var t;null==(t=d()?void 0:i.onMinimize)||t.apply(this,e)},e.template_effect(()=>{o=e.set_class(n,1,"modal-header-light modal-header-light-minimize",null,o,{"modal-header-light-disabled":d()}),n.disabled=d(),e.set_attribute(n,"title",d()?"Enable dock to minimize":void 0)}),e.append(t,n)};e.if(l,e=>{s()&&e(g)});var u=e.sibling(l,2),h=t=>{var n=At();n.__click=function(...e){var t;null==(t=i.onToggleStyle)||t.apply(this,e)},e.append(t,n)};e.if(u,e=>{a()&&e(h)}),e.reset(o);var p=e.sibling(o,2),f=e.child(p),m=t=>{var n=$t(),o=e.child(n);e.snippet(o,()=>i.customIcon),e.reset(n),e.append(t,n)},v=t=>{var n=e.comment(),o=e.first_child(n),r=t=>{var n=Xt(),o=e.child(n);e.snippet(o,()=>e.get(c),()=>i.icon),e.reset(n),e.append(t,n)};e.if(o,t=>{i.icon&&e.get(c)&&t(r)},!0),e.append(t,n)};e.if(f,e=>{i.customIcon?e(m):e(v,!1)});var w=e.sibling(f,2),y=e.child(w),x=t=>{var n=Yt(),o=e.child(n,!0);e.reset(n),e.template_effect(()=>{e.set_attribute(n,"id",i.titleId),e.set_text(o,i.title)}),e.append(t,n)},z=t=>{var n=qt(),o=e.child(n,!0);e.reset(n),e.template_effect(()=>e.set_text(o,i.title)),e.append(t,n)};e.if(y,e=>{i.titleId?e(x):e(z,!1)}),e.reset(w),e.reset(p),e.next(2),e.append(t,n)},m=t=>{var n=Zt(),o=e.first_child(n),r=e.child(o),l=t=>{var n=jt(),o=e.child(n);e.snippet(o,()=>i.customIcon),e.reset(n),e.append(t,n)},g=t=>{var n=e.comment(),o=e.first_child(n),r=t=>{var n=Gt(),o=e.child(n);e.snippet(o,()=>e.get(c),()=>i.icon),e.reset(n),e.append(t,n)};e.if(o,t=>{i.icon&&e.get(c)&&t(r)},!0),e.append(t,n)};e.if(r,e=>{i.customIcon?e(l):e(g,!1)});var u=e.sibling(r,2),h=t=>{var n=Kt(),o=e.child(n,!0);e.reset(n),e.template_effect(()=>{e.set_attribute(n,"id",i.titleId),e.set_text(o,i.title)}),e.append(t,n)},p=t=>{var n=Vt(),o=e.child(n,!0);e.reset(n),e.template_effect(()=>e.set_text(o,i.title)),e.append(t,n)};e.if(u,e=>{i.titleId?e(h):e(p,!1)}),e.reset(o);var f=e.sibling(o,2),m=e.child(f),v=t=>{var n=Ut();n.__click=function(...e){var t;null==(t=i.onToggleStyle)||t.apply(this,e)},e.append(t,n)};e.if(m,e=>{a()&&e(v)});var w=e.sibling(m,2),y=t=>{var n=Qt();let o;n.__click=function(...e){var t;null==(t=d()?void 0:i.onMinimize)||t.apply(this,e)},e.template_effect(()=>{o=e.set_class(n,1,"modal-header-btn-windows",null,o,{"modal-header-btn-windows-disabled":d()}),n.disabled=d(),e.set_attribute(n,"title",d()?"Enable dock to minimize":void 0)}),e.append(t,n)};e.if(w,e=>{s()&&e(y)}),e.sibling(w,2).__click=function(...e){var t;null==(t=i.onClose)||t.apply(this,e)},e.reset(f),e.append(t,n)};e.if(p,t=>{e.get(g)?t(f):t(m,!1)}),e.reset(u),e.template_effect(()=>h=e.set_class(u,1,"modal-header",null,h,{"modal-header-draggable":!!i.onStartDrag,transparent:o()})),e.append(n,u),e.pop()}e.delegate(["pointerdown","click"]);var tn=e.from_html("<div></div>"),nn=e.from_html('<div class="modal-resize-handles"></div>');function on(t,n){e.push(n,!0);const i=["n","s","e","w","ne","nw","se","sw"];var o=e.comment(),r=e.first_child(o),s=t=>{var o=nn();e.each(o,21,()=>i,e.index,(t,i)=>{var o=tn();o.__pointerdown=t=>function(e,t){var i;null==(i=n.onStartResize)||i.call(n,e,t)}(t,e.get(i)),e.template_effect(()=>e.set_class(o,1,`modal-resize-handle modal-resize-${e.get(i)??""}`)),e.append(t,o)}),e.reset(o),e.append(t,o)};e.if(r,e=>{n.onStartResize&&e(s)}),e.append(t,o),e.pop()}e.delegate(["pointerdown"]);var rn=e.from_html('<div class="modal-footer"><!></div>'),sn=e.from_html("<div></div>"),dn=e.from_html('<div role="dialog" aria-modal="true" tabindex="-1"><!> <div class="modal-body"><!></div> <!> <!> <!></div>');function an(t,s){e.push(s,!0);let d=e.prop(s,"maxWidth",3,"600px"),a=e.prop(s,"autoOpen",3,!1),l=e.prop(s,"closeOnEscape",3,!0),c=e.state(!1);n(()=>{V({id:s.id,title:s.title,icon:s.icon??"",isOpen:a(),isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,isRejected:!1,position:null,size:null,hasBeenDragged:!1,dockPosition:0,glow:s.glow??null,parentId:void 0,childId:void 0,offsetFromParent:void 0}),e.set(c,!0)}),r(()=>{U(s.id)});const g=e.derived(()=>{if(!e.get(c))return!1;Me();const t=Ie(s.id);return!!t&&(t.isOpen||t.isMinimized||De(s.id)||Ce(s.id)||we(s.id))});var u=e.comment(),h=e.first_child(u),p=t=>{!function(t,s){e.push(s,!0);let d=e.prop(s,"maxWidth",3,"600px"),a=e.prop(s,"autoOpen",3,!1),l=e.prop(s,"closeOnEscape",3,!0),c=e.prop(s,"skipRegistration",3,!1);i(zt,s.id);const g=ft().portalTarget;function u(e){var t,n;return(null==(n=null==(t=s.config)?void 0:t.features)?void 0:n[e])??yt(e)}const h=e.derived(()=>(pt(),u("drag"))),p=e.derived(()=>(pt(),u("minimize"))),f=e.derived(()=>(pt(),!u("dock"))),m=e.derived(()=>(pt(),u("transparency"))),v=e.derived(()=>(pt(),u("resize"))),w=e.derived(()=>{var e,t;return pt(),(null==(t=null==(e=s.config)?void 0:e.appearance)?void 0:t.headerLayout)??ft().appearance.headerLayout});let x=e.state(null),z=e.state(!1),_=e.state(!1),D=e.state(!1),P=e.state(!1),C=e.state(!1);const B=e.derived(()=>(Me(),Ie(s.id))),O=e.derived(()=>e.get(B)&&(e.get(B).isOpen||Ce(s.id))&&(!e.get(B).isMinimized||we(s.id))&&!e.get(B).isHiddenWithParent),T=e.derived(()=>{var t;return!!(null==(t=e.get(B))?void 0:t.childId)}),R=e.derived(()=>{var t;return!!(null==(t=e.get(B))?void 0:t.parentId)}),E=e.derived(()=>e.get(T)||e.get(_)),S=e.derived(()=>!!s.glow),H=e.derived(()=>`modal-title-${s.id}`),F=e.derived(()=>{var t;return(null==(t=e.get(B))?void 0:t.zIndex)??1e3}),L=_t({x:0,y:0});let W=e.state(!1);const A=Mt(()=>e.get(x),()=>L.position,e=>L.setPosition(e),()=>L.hasBeenDragged,e=>L.setHasBeenDragged(e),(t,n)=>{const i=Ie(s.id);if(null==i?void 0:i.parentId){const t=Ie(i.parentId),o=document.querySelector(`[data-modal-id="${i.parentId}"]`);if(t&&o){const i=t.position??{x:o.getBoundingClientRect().left,y:o.getBoundingClientRect().top},r=t.size??{width:o.offsetWidth,height:o.offsetHeight},d={x:i.x+(r.width-n.width)/2,y:i.y+(r.height-n.height)/2};e.set(W,!0),L.setPosition(d);const a={x:d.x-i.x,y:d.y-i.y};return ie(s.id,{position:d,size:n,hasBeenDragged:!0,offsetFromParent:a}),void setTimeout(()=>{e.set(W,!1)},200)}}ie(s.id,{position:t,size:n,hasBeenDragged:!0})}),$=Dt(()=>s.id,()=>e.get(x),()=>L.position,e=>L.setPosition(e),()=>L.hasBeenDragged,e=>L.setHasBeenDragged(e),()=>A.hasBeenResized,()=>A.size,(e,t,n)=>{ie(s.id,{position:e,size:n,hasBeenDragged:t}),Q(s.id)}),{trapFocus:X,focusFirstElement:Y}=Tt(),q=e.derived(()=>$.isMinimizing||$.isRestoring||$.isOpening||$.isClosing),N=e.derived(()=>(Se(s.id)||Re(s.id))&&!$.isRestoring);let j=e.state(!1);const G=e.derived(()=>$.isRestoring||$.isOpening||e.get(j)),K=e.derived(()=>e.get(O)&&!L.hasBeenDragged&&!e.get(q)&&!$.pendingOpenSource&&!e.get(N)),Z=e.derived(()=>{const t=[];return t.push(`z-index: ${e.get(F)};`),$.animationTransform?(t.push(`left: ${L.position.x}px; top: ${L.position.y}px;`),t.push(`--genie-origin-x: ${$.animationTransform.originX}px;`),t.push(`--genie-origin-y: ${$.animationTransform.originY}px;`),t.push(`--genie-translate-x: ${$.animationTransform.x}px;`),t.push(`--genie-translate-y: ${$.animationTransform.y}px;`)):L.hasBeenDragged&&t.push(`left: ${L.position.x}px; top: ${L.position.y}px; transform: none;`),A.hasBeenResized?t.push(`width: ${A.size.width}px; height: ${A.size.height}px; max-width: none; max-height: none;`):(s.preferredHeight&&t.push(`min-height: ${s.preferredHeight};`),d()&&t.push(`max-width: ${d()};`)),e.get(S)&&s.glow&&(t.push(`--modal-glow-color: ${s.glow.color};`),t.push(`--modal-glow-intensity: ${s.glow.intensity};`)),t.join(" ")});function J(){e.get(p)&&Q(s.id)}function ee(){var e;Oe(s.id)&&Te(s.id),le(s.id),null==(e=s.onClose)||e.call(s)}function ne(){Qe(s.id)}function se(t){e.get(h)&&e.get(x)&&L.onPointerDown(t,e.get(x))}function de(e){l()&&"Escape"===e.key&&re(s.id)&&(e.stopPropagation(),ee())}function ae(t){if(!e.get(x))return;const n=L.isDragging,i=A.hasBeenResized?A.size:{width:e.get(x).offsetWidth,height:e.get(x).offsetHeight};L.onPointerMove(t,e.get(x),i),L.isDragging&&n&&te(s.id,L.position,{drag:!0})}function ce(t){if(!e.get(x))return;const n=L.isDragging;L.onPointerUp(t,e.get(x)),n&&!A.justFinishedResizing&&(te(s.id,L.position,{drag:!0}),rt(s.id))}function ue(){var t;const n=ft();if("smart"!==(null==(t=n.positioning)?void 0:t.strategy))return!1;const i=Ie(s.id);if(null==i?void 0:i.parentId)return!1;if((null==i?void 0:i.hasBeenDragged)||(null==i?void 0:i.position))return!1;const o=e.get(x)||document.querySelector(`[data-modal-id="${s.id}"]`);if(!o)return!1;const r=o.offsetWidth,d=o.offsetHeight;if(r<=0||d<=0)return!1;const a=n.positioning.modalGap??16,l=_e(s.id),c=M(r,d,l,{modalGap:a,avoidBounds:b(n.positioning.avoidElements??[])});if(I(c.x,c.y,r,d,l,a)/(r*d)>.1&&l.length>0){const e=k(r,d,be(s.id),{modalGap:a});if(e&&e.existingModalMoves.size>0)return ot(e.existingModalMoves),L.setPosition(e.newModalPosition),L.setHasBeenDragged(!0),te(s.id,e.newModalPosition,{size:{width:r,height:d}}),!0}return L.setPosition(c),L.setHasBeenDragged(!0),te(s.id,c,{size:{width:r,height:d}}),!0}function he(){o().then(()=>o()).then(()=>{let t=0;const n=()=>{t+=1,ue()||t>5||requestAnimationFrame(n)};e.get(x)?n():requestAnimationFrame(n)})}n(()=>{var t;function n(){const t=Ie(s.id);if(!(null==t?void 0:t.position)||!e.get(x))return;if(t.parentId)return;const n=A.hasBeenResized?A.size.width:e.get(x).offsetWidth,i=A.hasBeenResized?A.size.height:e.get(x).offsetHeight;if(n<=0||i<=0)return;const o=y(t.position.x,t.position.y,n,i);(Math.abs(o.x-t.position.x)>1||Math.abs(o.y-t.position.y)>1)&&(L.setPosition(o),te(s.id,o))}return c()||(t=a(),V({id:s.id,title:s.title,icon:s.icon??"",isOpen:t,isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,isRejected:!1,position:null,size:null,hasBeenDragged:!1,dockPosition:0,glow:s.glow??null,parentId:void 0,childId:void 0,offsetFromParent:void 0}),t&&oe(s.id)),a()&&(o().then(()=>{e.get(x)&&Y(e.get(x))}),he()),window.addEventListener("pointermove",ae),window.addEventListener("pointerup",ce),window.addEventListener("resize",n),()=>{window.removeEventListener("pointermove",ae),window.removeEventListener("pointerup",ce),window.removeEventListener("resize",n)}}),r(()=>{Ze(s.id),c()||U(s.id)}),e.user_effect(()=>{Me();const t=Ie(s.id);if(t){if(e.set(z,t.isTransparent,!0),!L.isDragging&&!A.isResizing&&t.position){const e=L.position,n=t.position;(Math.abs(e.x-n.x)>.5||Math.abs(e.y-n.y)>.5)&&(L.setPosition(n),t.hasBeenDragged&&L.setHasBeenDragged(!0))}o().then(()=>function(){var t;if(!Ie(s.id))return;if(Oe(s.id))return Te(s.id),void(null==(t=s.onClose)||t.call(s));if(we(s.id)&&!e.get(P)){if(e.set(P,!0),ke(),e.get(x)){const t=e.get(x).getBoundingClientRect(),n=L.hasBeenDragged?L.position:{x:t.left,y:t.top},i=A.hasBeenResized?A.size:{width:t.width,height:t.height};ie(s.id,{position:n,size:i,hasBeenDragged:!0})}$.startMinimize(void 0,()=>{ye(s.id),e.set(P,!1)})}if(Re(s.id)){Ee(s.id);const t=Ie(s.id);$.startRestore((null==t?void 0:t.position)??void 0,(null==t?void 0:t.size)??void 0),o().then(()=>{e.get(x)&&Y(e.get(x))})}if(Se(s.id)){He(s.id);const e=Ie(s.id);$.startRestore((null==e?void 0:e.position)??void 0,(null==e?void 0:e.size)??void 0)}if(Ce(s.id)&&(Be(s.id),$.startClose(()=>{var e;Ze(s.id),ge(s.id),null==(e=s.onClose)||e.call(s)})),De(s.id)){Pe(s.id);const t=Ne(s.id)||s.openSourcePosition||null;t?($.setPendingOpenSource(t),o().then(()=>o()).then(()=>{ue(),$.tryStartOpenAnimation()})):he(),o().then(()=>{e.get(x)&&Y(e.get(x))})}Fe(s.id)&&(Le(s.id),Ae(s.id),e.set(C,!0),setTimeout(()=>{e.set(C,!1),$e(s.id)},600));const n=Ye(s.id);var i;n&&e.get(x)&&(i=n.parentId,o().then(()=>o()).then(()=>{let t=0;const n=()=>{t+=1;const o=function(t){var n,i;const o=Ie(t);if(!o)return!1;const r=e.get(x)||document.querySelector(`[data-modal-id="${s.id}"]`),d=document.querySelector(`[data-modal-id="${t}"]`),a=null==d?void 0:d.getBoundingClientRect(),l=o.position??(a?{x:a.left,y:a.top}:null);if(!l||!r)return!1;const c=(null==(n=o.size)?void 0:n.width)??(null==d?void 0:d.offsetWidth)??(null==a?void 0:a.width)??480,g=(null==(i=o.size)?void 0:i.height)??(null==d?void 0:d.offsetHeight)??(null==a?void 0:a.height)??400,u=r.offsetWidth,h=r.offsetHeight;if(c<=0||g<=0||u<=0||h<=0)return!1;const p={x:l.x+(c-u)/2,y:l.y+(g-h)/2};return L.setPosition(p),L.setHasBeenDragged(!0),te(s.id,p,{size:{width:u,height:h}}),o.position&&o.size||!a||te(t,{x:a.left,y:a.top},{size:{width:c,height:g}}),pe(t,s.id),!0}(i);o||t>5||requestAnimationFrame(n)};e.get(x)?n():requestAnimationFrame(n)}))}())}}),e.user_effect(()=>{const t=Ie(s.id);t&&t.isTransparent!==e.get(z)&&e.set(z,t.isTransparent,!0)}),e.user_effect(()=>{if(e.get(O)&&e.get(x)){const t=t=>function(t){e.get(x)&&X(t,e.get(x))}(t);return e.get(x).addEventListener("keydown",t),()=>{var n;return null==(n=e.get(x))?void 0:n.removeEventListener("keydown",t)}}}),e.user_effect(()=>{!e.get(O)&&$.isMinimizing&&$.forceClearMinimize()}),e.user_effect(()=>{$.isRestoring||$.isOpening?e.set(j,!0):e.get(j)&&requestAnimationFrame(()=>{e.set(j,!1)})}),e.user_effect(()=>{e.get(D)&&!e.get(T)&&(e.set(_,!0),setTimeout(()=>{e.set(_,!1)},200)),e.set(D,e.get(T),!0)});var fe=e.comment(),me=e.first_child(fe),ve=t=>{Lt(t,{get target(){return g},children:(t,n)=>{var i=dn();let o;i.__keydown=de;var r=e.child(i);{let t=e.derived(()=>e.get(h)?se:void 0);en(r,{get title(){return s.title},get customIcon(){return s.customIcon},get icon(){return s.icon},get isTransparent(){return e.get(z)},get titleId(){return e.get(H)},get headerLayout(){return e.get(w)},get onStartDrag(){return e.get(t)},onToggleStyle:ne,onMinimize:J,onClose:ee,get minimizable(){return e.get(p)},get minimizeDisabled(){return e.get(f)},get transparencyEnabled(){return e.get(m)}})}var d=e.sibling(r,2),a=e.child(d);e.snippet(a,()=>s.children??e.noop),e.reset(d);var l=e.sibling(d,2),c=t=>{var n=rn(),i=e.child(n);e.snippet(i,()=>s.footer),e.reset(n),e.append(t,n)};e.if(l,e=>{s.footer&&e(c)});var g=e.sibling(l,2);{let t=e.derived(()=>e.get(v)&&!e.get(T)?A.handlers.startResize:void 0);on(g,{get onStartResize(){return e.get(t)}})}var u=e.sibling(g,2),y=t=>{var n=sn();let i;e.template_effect(()=>i=e.set_class(n,1,"modal-child-overlay",null,i,{"modal-overlay-closing":e.get(_)})),e.append(t,n)};e.if(u,t=>{e.get(E)&&t(y)}),e.reset(i),e.bind_this(i,t=>e.set(x,t),()=>e.get(x)),e.template_effect(()=>{var t;o=e.set_class(i,1,"modal-dialog",null,o,{"modal-dragging":L.isDragging,"modal-resizing":A.isResizing,"modal-positioned":L.hasBeenDragged,"modal-minimizing":$.isMinimizing,"modal-restoring":$.isRestoring,"modal-opening":$.isOpening,"modal-closing":$.isClosing,"modal-centered":e.get(K),"modal-solid":!e.get(z),"modal-transparent":e.get(z),"modal-glow":e.get(S),"modal-has-child":e.get(T),"modal-is-child":e.get(R),"modal-visible-by-animation":e.get(G),"modal-animating-to-center":e.get(W),"modal-animating-position":null==(t=e.get(B))?void 0:t.isAnimatingPosition,"modal-attention":e.get(C)}),e.set_attribute(i,"data-modal-id",s.id),e.set_style(i,e.get(Z)),e.set_attribute(i,"aria-labelledby",e.get(H))}),e.event("pointerdown",i,()=>oe(s.id),!0),e.append(t,i)},$$slots:{default:!0}})};e.if(me,t=>{e.get(O)&&t(ve)}),e.append(t,fe),e.pop()}(t,{get id(){return s.id},get title(){return s.title},get icon(){return s.icon},get customIcon(){return s.customIcon},get maxWidth(){return d()},get preferredHeight(){return s.preferredHeight},get autoOpen(){return a()},get openSourcePosition(){return s.openSourcePosition},get glow(){return s.glow},get config(){return s.config},get closeOnEscape(){return l()},get onClose(){return s.onClose},get children(){return s.children},get footer(){return s.footer},skipRegistration:!0})};e.if(h,t=>{e.get(g)&&t(p)}),e.append(t,u),e.pop()}e.delegate(["keydown"]);var ln=e.from_html('<button type="button" aria-label="Drag dock"></button>'),cn=e.from_html('<span class="modal-dock-item-icon-placeholder"> </span>'),gn=e.from_html('<span class="modal-dock-item-label"> </span>'),un=e.from_html("<span>+</span>"),hn=e.from_html('<span class="modal-dock-child-indicator"><!></span>'),pn=e.from_html('<button><span class="modal-dock-item-icon"><!></span> <!> <span class="modal-dock-item-glow"></span> <!></button>'),fn=e.from_html('<div data-dock-container="true"><div><!> <!></div></div>');function mn(n,i){e.push(i,!0);const o=t(xt),r=e.derived(()=>i.renderIcon??(null==o?void 0:o())),s=Ue(),l=e.derived(()=>(pt(),ft())),u=e.derived(()=>m("DOCK")),h=e.derived(()=>e.get(l).dock.position),p=e.derived(()=>e.get(l).dock.labelMode);let f=e.state("horizontal"),v=e.state(e.proxy({x:100,y:100})),w=e.state(null),x=e.state(!1),z={x:0,y:0},I=null;const b=e.derived(()=>(Me(),Array.from(s.modals.values()).filter(e=>e.isMinimized).sort((e,t)=>e.dockPosition-t.dockPosition))),_=e.derived(()=>{switch(e.get(h)){case"left":return{x:-20,duration:250,easing:c};case"right":return{x:20,duration:250,easing:c};default:return{y:20,duration:250,easing:c}}});function M(t){var n;"free"===e.get(h)&&(e.set(x,!0),I=t.pointerId,z={x:t.clientX-e.get(v).x,y:t.clientY-e.get(v).y},null==(n=t.currentTarget)||n.setPointerCapture(t.pointerId),window.addEventListener("pointermove",k),window.addEventListener("pointerup",D),window.addEventListener("pointercancel",D))}function k(t){if(t.pointerId!==I||!e.get(w))return;const n=e.get(w).getBoundingClientRect(),i=window.innerWidth-n.width-8,o=window.innerHeight-n.height-8,r=Math.min(Math.max(t.clientX-z.x,8),Math.max(8,i)),s=Math.min(Math.max(t.clientY-z.y,8),Math.max(8,o));e.set(v,{x:Math.round(r),y:Math.round(s)},!0)}function D(t){t.pointerId===I&&(e.set(x,!1),I=null,window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",D),window.removeEventListener("pointercancel",D))}const{addListener:P}=Ht();function C(){if("free"!==e.get(h)||!e.get(w))return;const t=e.get(w).getBoundingClientRect(),n=y(e.get(v).x,e.get(v).y,t.width,t.height);n.x===e.get(v).x&&n.y===e.get(v).y||e.set(v,{x:Math.round(n.x),y:Math.round(n.y)},!0)}e.user_effect(()=>{"undefined"!=typeof window&&P("resize",C)});var B={setDockOrientation:function(t){e.set(f,t,!0)},setDockFreePosition:function(t){e.set(v,t,!0)},getDockState:function(){return{dockPosition:e.get(h),dockOrientation:e.get(f),dockFreePosition:e.get(v),dockLabelMode:e.get(p)}}};return Lt(n,{get target(){return e.get(l).portalTarget},children:(t,n)=>{var i=fn();let o,l;var c=e.child(i);let m;var y=e.child(c),z=t=>{var n=ln();let i;n.__pointerdown=M,e.template_effect(()=>i=e.set_class(n,1,"modal-dock-handle",null,i,{"modal-dock-handle-dragging":e.get(x)})),e.append(t,n)};e.if(y,t=>{"free"===e.get(h)&&t(z)});var I=e.sibling(y,2);e.each(I,19,()=>e.get(b),e=>e.id,(t,n,i)=>{const o=e.derived(()=>e.get(n).lastChildId?s.modals.get(e.get(n).lastChildId):null);var a=pn();let l;a.__click=t=>{Ge(e.get(n).id)?Je(t.currentTarget):Z(e.get(n).id)};var c=e.child(a),u=e.child(c),h=t=>{var i=e.comment(),o=e.first_child(i);e.snippet(o,()=>e.get(r),()=>e.get(n).icon),e.append(t,i)},f=t=>{var i=cn(),o=e.child(i,!0);e.reset(i),e.template_effect(t=>e.set_text(o,t),[()=>e.get(n).title.charAt(0)]),e.append(t,i)};e.if(u,t=>{e.get(n).icon&&e.get(r)?t(h):t(f,!1)}),e.reset(c);var m=e.sibling(c,2),v=t=>{var i=gn(),o=e.child(i,!0);e.reset(i),e.template_effect(()=>e.set_text(o,e.get(n).title)),e.append(t,i)};e.if(m,t=>{"hidden"!==e.get(p)&&t(v)});var w=e.sibling(m,4),y=t=>{var n=hn(),i=e.child(n),s=t=>{var n=e.comment(),i=e.first_child(n);e.snippet(i,()=>e.get(r),()=>e.get(o).icon),e.append(t,n)},d=t=>{var n=un();e.append(t,n)};e.if(i,t=>{e.get(o).icon&&e.get(r)?t(s):t(d,!1)}),e.reset(n),e.append(t,n)};e.if(w,t=>{e.get(n).lastChildId&&e.get(o)&&t(y)}),e.reset(a),e.template_effect(()=>{l=e.set_class(a,1,"modal-dock-item",null,l,{"modal-dock-item-has-glow":!!e.get(n).glow,"modal-dock-item-has-child":!!e.get(n).lastChildId,"modal-dock-item-label-beside":"beside"===e.get(p),"modal-dock-item-label-below":"below"===e.get(p)}),e.set_attribute(a,"data-modal-id",e.get(n).id),e.set_style(a,e.get(n).glow?`--modal-dock-glow-color: ${e.get(n).glow.color};`:"")}),e.transition(3,a,()=>d,()=>({duration:300,delay:50*e.get(i),easing:g,start:.5})),e.append(t,a)}),e.reset(c),e.reset(i),e.bind_this(i,t=>e.set(w,t),()=>e.get(w)),e.template_effect(()=>{o=e.set_class(i,1,"modal-dock-container",null,o,{"modal-dock-left":"left"===e.get(h),"modal-dock-right":"right"===e.get(h),"modal-dock-bottom":"bottom"===e.get(h),"modal-dock-free":"free"===e.get(h),"modal-dock-empty":0===e.get(b).length}),l=e.set_style(i,"free"===e.get(h)?`left: ${e.get(v).x}px; top: ${e.get(v).y}px;`:"",l,{"z-index":e.get(u)}),m=e.set_class(c,1,"modal-dock",null,m,{"modal-dock-free-horizontal":"free"===e.get(h)&&"horizontal"===e.get(f),"modal-dock-free-vertical":"free"===e.get(h)&&"vertical"===e.get(f)})}),e.transition(3,i,()=>a,()=>e.get(b).length>0?e.get(_):{duration:0}),e.append(t,i)},$$slots:{default:!0}}),e.pop(B)}e.delegate(["pointerdown","click"]);var vn=e.from_html('<div class="modal-backdrop svelte-1d3nq4t" aria-hidden="true"></div>');function wn(t,n){e.push(n,!0);const i=Ue(),o=e.derived(()=>(pt(),ft())),r=e.derived(()=>e.get(o).features.backdrop),s=e.derived(()=>(Me(),Array.from(i.modals.values()).some(e=>e.isOpen&&!e.isMinimized&&!e.isHiddenWithParent))),d=e.derived(()=>e.get(r)&&e.get(s)),a=e.derived(()=>m("MODAL")-1);Lt(t,{get target(){return e.get(o).portalTarget},children:(t,n)=>{var i=e.comment(),o=e.first_child(i),r=t=>{var n=vn();let i;e.template_effect(()=>i=e.set_style(n,"",i,{"z-index":e.get(a)})),e.transition(3,n,()=>l,()=>({duration:200})),e.append(t,n)};e.if(o,t=>{e.get(d)&&t(r)}),e.append(t,i)},$$slots:{default:!0}}),e.pop()}var yn=e.from_html("<!> <!>",1);function xn(t,n){e.push(n,!0),i(xt,()=>n.renderIcon),e.user_effect(()=>(s(()=>{n.config&&mt(n.config),p()}),()=>{vt(),v()})),e.user_effect(()=>{if("undefined"==typeof document)return;const e=s(()=>ft().portalTarget);if("string"==typeof e&&!document.querySelector(e)){const t=document.createElement("div");return t.id=e.replace("#",""),document.body.appendChild(t),()=>{t.remove()}}});var o=yn(),r=e.first_child(o);wn(r,{});var d=e.sibling(r,2);e.snippet(d,()=>n.children??e.noop),e.append(t,o),e.pop()}export{wn as Backdrop,mn as Dock,an as Modal,en as ModalHeader,xn as ModalProvider,Lt as Portal,on as ResizeHandles,lt as _getInternalState,ct as _resetInternalState,f as acquireModalZIndex,ot as animateModalsToPositions,et as animateParentToPosition,oe as bringToFront,z as calculateOverlap,_ as calculatePositionScore,k as calculateRearrangement,I as calculateTotalOverlap,tt as clearParentAnimationFlag,it as clearPendingParentAnimation,ce as closeAllModals,le as closeModal,x as constrainSizeToViewport,y as constrainToViewport,Ne as consumeOpenSourcePosition,Le as consumePendingAttention,He as consumePendingChildRestore,Be as consumePendingClose,Te as consumePendingForceClose,ye as consumePendingMinimize,ke as consumePendingMinimizeTarget,Pe as consumePendingOpen,Ye as consumePendingParentLink,Ee as consumePendingRestore,ae as createModal,gt as defaultConfig,$e as endAttentionAnimation,ge as finalizeModalClose,M as findSmartPosition,Ot as focusFirstElement,ft as getConfig,pt as getConfigVersion,b as getElementBounds,m as getLayerZIndex,Ie as getModalState,Ue as getModalsStore,ue as getModalsToClose,_e as getOpenModalBounds,be as getOpenModalBoundsWithIds,Xe as getPendingParentLink,ze as getRegisteredModalIds,Me as getStateVersion,xe as hasAnyPendingMinimize,Fe as hasPendingAttention,Se as hasPendingChildRestore,Ce as hasPendingClose,Oe as hasPendingForceClose,we as hasPendingMinimize,De as hasPendingOpen,nt as hasPendingParentAnimation,Re as hasPendingRestore,fe as hideChildWithParent,p as initializeStacking,yt as isFeatureEnabled,Ge as isModalAnimating,Ke as isModalOpen,Ve as isModalRegistered,re as isTopModal,pe as linkModals,wt as mergeConfig,Q as minimizeModal,he as openChildModal,de as openModal,V as registerModal,se as reorderDock,vt as resetConfig,Ze as resetModalTransparency,v as resetStacking,J as restoreAllMinimizedModals,ee as restoreChildModal,Z as restoreModal,ve as setChildOffsetFromParent,mt as setConfig,at as setDockPositionGetter,je as setModalAnimating,st as setRegistryFunctions,dt as setURLStateCallbacks,Je as shakeElement,Ae as startAttentionAnimation,qe as storeOpenSourcePosition,O as subscribe,Qe as toggleModalTransparency,Bt as trapFocus,We as triggerAttention,rt as triggerCascadingParentAnimations,U as unregisterModal,me as updateChildPosition,ie as updateModal,te as updateModalPosition,ne as updateModalSize,Tt as useFocusTrap,bt as useModal,Dt as useModalAnimation,_t as useModalDrag,Mt as useModalResize,St as useModalZIndex,Et as usePortal,Ht as useWindowEvent};
|
|
1
|
+
import*as e from"svelte/internal/client";import"svelte/internal/disclose-version";import{getContext as t,onMount as n,setContext as i,tick as o,onDestroy as r,untrack as s}from"svelte";import{scale as d,fly as a,fade as l}from"svelte/transition";import{cubicOut as c,backOut as g}from"svelte/easing";const u={BASE:0,DROPDOWN:100,STICKY:200,OVERLAY:300,MODAL:400,DOCK:8e3,TOAST:9e3};let h=e.state(e.proxy(u.MODAL));function p(){e.set(h,mt().zIndex.base,!0)}function f(){const t=e.get(h);return e.set(h,e.get(h)+2),t}function m(e){const t=mt();return"MODAL"===e?t.zIndex.base:"DOCK"===e?t.zIndex.dock:"TOAST"===e?t.zIndex.toast:u[e]}function v(){e.set(h,mt().zIndex.base,!0)}const y=8;function w(e,t,n,i,o={}){const{margin:r=y,allowPartialVisibility:s=!1}=o,d="undefined"!=typeof window?window.innerWidth:1920,a="undefined"!=typeof window?window.innerHeight:1080;let l,c,g,u;return s&&n>d-2*r?(l=40-n,c=d-40):(l=r,c=Math.max(r,d-n-r)),s&&i>a-2*r?(g=40-i,u=a-40):(g=r,u=Math.max(r,a-i-r)),{x:Math.max(l,Math.min(c,e)),y:Math.max(g,Math.min(u,t))}}function x(e,t,n,i,o={}){const{margin:r=y}=o,s=("undefined"!=typeof window?window.innerWidth:1920)-2*r,d=("undefined"!=typeof window?window.innerHeight:1080)-2*r,a=Math.min(n,s),l=Math.min(i,d),c=w(e,t,a,l,o);return{x:c.x,y:c.y,width:a,height:l}}function z(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 I(e,t,n,i,o,r){const s={x:e-r,y:t-r,width:n+2*r,height:i+2*r};let d=0;for(const e of o)d+=z(s,e);return d}function b(e){if("undefined"==typeof document)return[];const t=[];for(const n of e)try{const e=document.querySelectorAll(n);for(const n of e){const e=n.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 _(e,t,n,i,o,r,s){const d=(o-n)/2,a=(r-i)/2,l=d-s,c=a-s,g=Math.abs(e-d)/(l||1),u=Math.abs(t-a)/(c||1),h=Math.sqrt(g*g+u*u)/Math.SQRT2,p=50,f=e-s,m=o-n-s-e,v=t-s,y=r-i-s-t;let w=0;return f<p&&(w+=.3*(1-f/p)),m<p&&(w+=.3*(1-m/p)),v<p&&(w+=.2*(1-v/p)),y<p&&(w+=.2*(1-y/p)),Math.min(1,h+w)}function M(e,t,n,i={}){const{modalGap:o=16,gridResolution:r=10,avoidBounds:s=[],avoidMargin:d=16}=i,a=i.margin??o,l="undefined"!=typeof window?window.innerWidth:1920,c="undefined"!=typeof window?window.innerHeight:1080,g=s.map(e=>({x:e.x-d,y:e.y-d,width:e.width+2*d,height:e.height+2*d})),u={x:(l-e)/2,y:(c-t)/2};if(0===n.length&&0===g.length)return u;const h=a,p=Math.max(a,l-e-a),f=a,m=Math.max(a,c-t-a);if(p<=h||m<=f)return u;const v=I(u.x,u.y,e,t,n,o),y=I(u.x,u.y,e,t,g,0);if(0===v&&0===y)return u;const w=[],x=(p-h)/r,z=(m-f)/r;for(let i=0;i<=r;i++)for(let s=0;s<=r;s++){const r=h+i*x,d=f+s*z,u=I(r,d,e,t,n,o),p=I(r,d,e,t,g,0),m=_(r,d,e,t,l,c,a);w.push({pos:{x:r,y:d},modalOverlap:u,avoidOverlap:p,centerDist:m})}const b=w.filter(e=>0===e.avoidOverlap),M=b.length>0?b:w,k=e*t,D=Math.min(...M.map(e=>e.modalOverlap))/k;return M.sort((e,t)=>{if(0===b.length&&e.avoidOverlap!==t.avoidOverlap)return e.avoidOverlap-t.avoidOverlap;const n=e.modalOverlap/k,i=t.modalOverlap/k;if(D<.3){const o=.3,r=n<=o,s=i<=o;if(r&&s)return e.centerDist+.3*n-(t.centerDist+.3*i);if(r)return-1;if(s)return 1}return.6*n+.4*e.centerDist-(.6*i+.4*t.centerDist)}),M[0].pos}function k(e,t,n,i={}){const{modalGap:o=16}=i,r=i.margin??o,s="undefined"!=typeof window?window.innerWidth:1920,d="undefined"!=typeof window?window.innerHeight:1080,a=n.reduce((e,t)=>e+t.width,0)+e,l=n.length*o,c=s-2*r;if(a+l>c)return null;const g=c-a-l;n.length;const u=g/2,h=s/2,p=[...n.map(e=>({id:e.id,width:e.width,height:e.height,currentX:e.x+e.width/2,currentY:e.y,isNew:!1})),{id:"__new__",width:e,height:t,currentX:h,currentY:(d-t)/2,isNew:!0}];p.sort((e,t)=>e.currentX-t.currentX);let f=r+u;const m=new Map;let v=null;for(const e of p){const t=f;if(e.isNew)v={x:Math.round(t),y:Math.round(e.currentY)};else{const i=n.find(t=>t.id===e.id);Math.abs(t-i.x)>5&&m.set(e.id,{x:Math.round(t),y:Math.round(i.y)})}f+=e.width+o}return v?{newModalPosition:v,existingModalMoves:m}:null}function D(e){return"symbol"==typeof e?e.description??"symbol":e}let P=e.proxy(new Map),C=e.state(0);const B=new Set;function O(){e.update(C),queueMicrotask(()=>{B.forEach(e=>e())})}function T(e){return B.add(e),()=>B.delete(e)}let R=e.state(e.proxy([])),E=e.state(e.proxy([])),H=e.state(e.proxy([])),S=e.state(e.proxy([])),L=e.state(e.proxy([])),F=e.state(e.proxy([])),W=e.state(e.proxy([])),A=e.state(e.proxy([])),$=e.state(null),X=e.proxy(new Map),Y=e.state(null),q=e.proxy(new Map),N=e.proxy(new Set),j=e.proxy(new Set),G=e.state(e.proxy([])),K=null,V=null;function U(t){const n=P.get(t.id),i=(null==n?void 0:n.zIndex)??f();n?P.set(t.id,{...n,title:t.title,icon:t.icon,glow:t.glow,zIndex:i}):P.set(t.id,{...t,zIndex:i,isAnimating:!1}),O(),t.isMinimized&&!e.get(G).includes(t.id)&&e.get(G).push(t.id)}function Q(t){const n=P.get(t);if(n){if(e.set(G,e.get(G).filter(e=>e!==t),!0),n.childId){const e=P.get(n.childId);e&&P.set(n.childId,{...e,parentId:void 0})}if(n.parentId){const e=P.get(n.parentId);e&&P.set(n.parentId,{...e,childId:void 0,lastChildId:n.id})}P.delete(t),O(),j.delete(t),N.delete(t)}}function Z(t){const n=P.get(t);if(!n||n.isMinimized)return;if(ot(t),n.parentId){const e=P.get(n.parentId);if(e&&!e.isMinimized)return void Z(n.parentId)}if(e.set(R,[...e.get(R),t],!0),n.position&&n.size&&V){const i=V(),o=e.get(G).indexOf(t),r=i.x+o*(i.height+8),s=i.y;e.set($,{x:r,y:s,originX:n.position.x+n.size.width/2,originY:n.position.y+n.size.height/2},!0)}const i=n.childId;P.set(t,{...n,isMinimized:!0,lastChildId:i}),O(),e.get(G).includes(t)||e.get(G).push(t),n.childId&&me(t)}function J(t){const n=P.get(t);if(!n||!n.isMinimized)return;P.set(t,{...n,isMinimized:!1,isOpen:!0}),O(),e.set(L,[...e.get(L),t],!0),re(t);const i=n.lastChildId||n.childId;i&&te(i)}function ee(){Array.from(P.values()).filter(e=>e.isMinimized).map(e=>e.id).forEach(t=>{const n=P.get(t);if(n){P.set(t,{...n,isMinimized:!1,isOpen:!0}),e.set(L,[...e.get(L),t],!0),re(t);const i=n.lastChildId||n.childId;i&&te(i)}}),e.set(G,[],!0),O()}function te(t){const n=P.get(t);n&&n.isHiddenWithParent&&(P.set(t,{...n,isHiddenWithParent:!1}),O(),e.set(F,[...e.get(F),t],!0))}function ne(e,t,n){const i=P.get(e);if(!i)return;let o=t;if((null==n?void 0:n.constrain)&&i.size&&(o=w(t.x,t.y,i.size.width,i.size.height)),P.set(e,{...i,position:o,size:(null==n?void 0:n.size)??i.size,hasBeenDragged:i.hasBeenDragged||(null==n?void 0:n.drag)||!1}),i.childId){let t=e,n=o;for(;;){const e=P.get(t);if(!(null==e?void 0:e.childId))break;const i=P.get(e.childId);if(!(null==i?void 0:i.offsetFromParent))break;const o={x:n.x+i.offsetFromParent.x,y:n.y+i.offsetFromParent.y};P.set(e.childId,{...i,position:o,hasBeenDragged:!0}),t=e.childId,n=o}}if(i.parentId&&i.offsetFromParent){const t=mt();let n=e,r=i;for(;r.parentId&&r.offsetFromParent;){const i=P.get(r.parentId);if(!i)break;const s=n===e?o:P.get(n).position,d={x:s.x-r.offsetFromParent.x,y:s.y-r.offsetFromParent.y};"animated"===t.parentChild.movementMode?q.set(r.parentId,d):P.set(r.parentId,{...i,position:d,hasBeenDragged:!0}),n=r.parentId,r=i}}O()}function ie(e,t){const n=P.get(e);n&&(P.set(e,{...n,size:t}),O())}function oe(e,t){const n=P.get(e);n&&(P.set(e,{...n,...t}),O())}function re(e){var t;const n=P.get(e);if(!n)return;const i=Math.max(...Array.from(P.values()).map(e=>e.zIndex),0);if(n.parentId){const o=P.get(n.parentId);o&&o.zIndex<i&&P.set(n.parentId,{...o,zIndex:i+2});const r=(null==(t=P.get(n.parentId))?void 0:t.zIndex)??i+2;return n.zIndex<=r&&P.set(e,{...n,zIndex:r+2}),void O()}if(n.zIndex<i&&(P.set(e,{...n,zIndex:i+2}),O()),n.childId){const t=P.get(n.childId),i=P.get(e);t&&i&&t.zIndex<=i.zIndex&&(P.set(n.childId,{...t,zIndex:i.zIndex+2}),O())}}function se(e){const t=P.get(e);if(!t)return!1;const n=Math.max(...Array.from(P.values()).map(e=>e.zIndex),0);return t.zIndex===n&&!t.isMinimized&&!t.isHiddenWithParent}function de(t){e.set(G,t,!0)}function ae(t,n,i){const o=n.getBoundingClientRect();X.set(t,{x:o.left+o.width/2,y:o.top+o.height/2});const r=mt();(null==i?void 0:i.parentId)&&r.features.parentChild&&e.set(Y,{parentId:i.parentId,childId:t},!0),e.get(E).includes(t)||e.set(E,[...e.get(E),t],!0),O();const s=P.get(t);if(s){if(s.isOpen&&!s.isMinimized&&!s.isHiddenWithParent)return e.set(E,e.get(E).filter(e=>e!==t),!0),Ae(t),void re(t);if(s.isMinimized)return e.set(E,e.get(E).filter(e=>e!==t),!0),void J(t);P.set(t,{...s,isOpen:!0}),re(t),null==K||K.push(t)}}function le(t){U(t);const n=P.get(t.id);n&&(P.set(t.id,{...n,isOpen:!0}),O()),e.set(E,[...e.get(E),t.id],!0),O(),re(t.id),null==K||K.push(t.id)}function ce(t,n=!1){const i=P.get(t);i&&(ot(t),n?e.set(S,[...e.get(S),t],!0):e.set(H,[...e.get(H),t],!0),O(),i.childId&&ce(i.childId,n),null==K||K.pop())}function ge(){Array.from(P.keys()).forEach(e=>ce(e,!0))}function ue(e){const t=P.get(e);if(t){if(t.parentId){const n=P.get(t.parentId);n&&n.childId===e&&P.set(t.parentId,{...n,childId:void 0,lastChildId:e})}P.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}),O()}}function he(e){const t=P.get(e);if(!t)return[e];const n=[e];return t.childId&&n.push(...he(t.childId)),n}function pe(t,n,i){const o=mt();if(i&&!X.has(t.id)){const e=i.getBoundingClientRect();X.set(t.id,{x:e.left+e.width/2,y:e.top+e.height/2})}const r={id:t.id,title:t.title??"",icon:t.icon??"",isOpen:!0,isMinimized:!1,isHiddenWithParent:!1,isTransparent:t.isTransparent??!1,isRejected:!1,position:t.position??null,size:t.size??null,hasBeenDragged:t.hasBeenDragged??!1,dockPosition:t.dockPosition??-1,glow:t.glow??null};if(!o.features.parentChild){U(r);const n=P.get(t.id);return n&&P.set(t.id,{...n,isOpen:!0}),e.set(E,[...e.get(E),t.id],!0),O(),void re(t.id)}const s=P.get(n);if(!s)return;s.childId&&ce(s.childId,!0),U({...r,parentId:n});const d=P.get(t.id);d&&P.set(t.id,{...d,isOpen:!0,parentId:n}),e.set(E,[...e.get(E),t.id],!0),O(),re(t.id),e.set(Y,{parentId:n,childId:t.id},!0)}function fe(e,t){if(!mt().features.parentChild)return;const n=P.get(e),i=P.get(t);if(!n||!i)return;let o={x:40,y:40};n.position&&i.position&&(o={x:i.position.x-n.position.x,y:i.position.y-n.position.y});const r=Math.max(i.zIndex,n.zIndex+1);P.set(e,{...n,childId:t,lastChildId:t}),P.set(t,{...i,parentId:e,offsetFromParent:o,zIndex:r}),O()}function me(e){const t=P.get(e);if(!(null==t?void 0:t.childId))return;const n=P.get(t.childId);n&&(P.set(t.childId,{...n,isHiddenWithParent:!0}),O())}function ve(e,t){const n=P.get(e);if(!(null==n?void 0:n.childId))return;const i=P.get(n.childId);if(!i||!i.offsetFromParent)return;const o={x:t.x+i.offsetFromParent.x,y:t.y+i.offsetFromParent.y};P.set(n.childId,{...i,position:o}),O()}function ye(e,t){const n=P.get(e),i=P.get(t);if(!(null==n?void 0:n.position)||!(null==i?void 0:i.position))return;const o={x:n.position.x-i.position.x,y:n.position.y-i.position.y};P.set(e,{...n,offsetFromParent:o}),O()}function we(t){return e.get(R).includes(t)}function xe(t){return!!e.get(R).includes(t)&&(e.set(R,e.get(R).filter(e=>e!==t),!0),!0)}function ze(){return e.get(R).length>0}function Ie(){return Array.from(P.keys())}function be(e){return P.get(e)}function _e(e){const t=[];for(const[n,i]of P.entries())if(n!==e&&i.isOpen&&!i.isMinimized&&!i.isHiddenWithParent&&!i.parentId)if(i.position&&i.size)t.push({id:D(n),x:i.position.x,y:i.position.y,width:i.size.width,height:i.size.height});else{const e=document.querySelector(`[data-modal-id="${D(n)}"]`);if(e){const i=e.getBoundingClientRect();t.push({id:D(n),x:i.left,y:i.top,width:i.width,height:i.height})}}return t}function Me(e){const t=[];for(const[n,i]of P.entries())if(n!==e&&i.isOpen&&!i.isMinimized&&!i.isHiddenWithParent)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=document.querySelector(`[data-modal-id="${D(n)}"]`);if(e){const n=e.getBoundingClientRect();t.push({x:n.left,y:n.top,width:n.width,height:n.height})}}return t}function ke(){return e.get(C)}function De(){const t=e.get($);return e.set($,null),t}function Pe(t){return e.get(E).includes(t)}function Ce(t){return!!e.get(E).includes(t)&&(e.set(E,e.get(E).filter(e=>e!==t),!0),!0)}function Be(t){return e.get(H).includes(t)}function Oe(t){return!!e.get(H).includes(t)&&(e.set(H,e.get(H).filter(e=>e!==t),!0),!0)}function Te(t){return e.get(S).includes(t)}function Re(t){return!!e.get(S).includes(t)&&(e.set(S,e.get(S).filter(e=>e!==t),!0),!0)}function Ee(t){return e.get(L).includes(t)}function He(t){return!!e.get(L).includes(t)&&(e.set(L,e.get(L).filter(e=>e!==t),!0),!0)}function Se(t){return e.get(F).includes(t)}function Le(t){return!!e.get(F).includes(t)&&(e.set(F,e.get(F).filter(e=>e!==t),!0),!0)}function Fe(t){return e.get(W).includes(t)}function We(t){return!!e.get(W).includes(t)&&(e.set(W,e.get(W).filter(e=>e!==t),!0),!0)}function Ae(t){P.get(t)&&(e.get(W).includes(t)||e.get(A).includes(t)||(e.set(W,[...e.get(W),t],!0),O()))}function $e(t){e.get(A).includes(t)||e.set(A,[...e.get(A),t],!0)}function Xe(t){e.set(A,e.get(A).filter(e=>e!==t),!0)}function Ye(){return e.get(Y)}function qe(t){if(!e.get(Y)||e.get(Y).childId!==t)return null;const n=e.get(Y);return e.set(Y,null),n}function Ne(e,t){X.set(e,t)}function je(e){const t=X.get(e);return t&&X.delete(e),t??null}function Ge(e,t){t?N.add(e):N.delete(e)}function Ke(e){return N.has(e)}function Ve(e){const t=P.get(e);return void 0!==t&&t.isOpen&&!t.isMinimized&&!t.isHiddenWithParent}function Ue(e){return P.has(e)}function Qe(){return{get modals(){return P},get pendingMinimize(){return e.get(R)},get pendingOpen(){return e.get(E)},get pendingClose(){return e.get(H)},get pendingRestore(){return e.get(L)},get dockOrder(){return e.get(G)}}}function Ze(e){j.has(e)?j.delete(e):j.add(e);const t=P.get(e);t&&(P.set(e,{...t,isTransparent:j.has(e)}),O())}function Je(e){j.delete(e);const t=P.get(e);t&&(P.set(e,{...t,isTransparent:!1}),O())}function et(e){e.animate([{transform:"translateX(0)"},{transform:"translateX(-6px)"},{transform:"translateX(6px)"},{transform:"translateX(-6px)"},{transform:"translateX(6px)"},{transform:"translateX(0)"}],{duration:300,easing:"ease-in-out"})}function tt(e){const t=q.get(e);if(!t)return;const n=P.get(e);n&&(P.set(e,{...n,isAnimatingPosition:!0,position:t}),q.delete(e),O())}function nt(e){const t=P.get(e);t&&(P.set(e,{...t,isAnimatingPosition:!1}),O())}function it(e){return q.has(e)}function ot(e){q.delete(e)}function rt(e){const t=mt().parentChild.animationDuration;for(const[t,n]of e){const e=P.get(t);e&&P.set(t,{...e,position:n,isAnimatingPosition:!0,hasBeenDragged:!0})}O(),setTimeout(()=>{for(const t of e.keys()){const e=P.get(t);e&&P.set(t,{...e,isAnimatingPosition:!1})}O()},t)}function st(e){const t=mt();if("animated"!==t.parentChild.movementMode)return;const n=t.parentChild.animationDuration,i=[];let o=e;for(;;){const e=P.get(o);if(!(null==e?void 0:e.parentId))break;i.push({parentId:e.parentId,childId:o}),o=e.parentId}i.forEach(({parentId:e,childId:t},i)=>{setTimeout(()=>{const i=P.get(t),o=P.get(e);if(!(null==i?void 0:i.position)||!i.offsetFromParent||!o)return;const r={x:i.position.x-i.offsetFromParent.x,y:i.position.y-i.offsetFromParent.y};q.set(e,r),tt(e),setTimeout(()=>nt(e),n)},i*n)})}function dt(e){}function at(e){K=e}function lt(e){V=e}function ct(){return{modals:P,pendingMinimize:e.get(R),pendingOpen:e.get(E),pendingClose:e.get(H),pendingRestore:e.get(L),dockOrder:e.get(G),animatingModals:N,transparentModals:j}}function gt(){P.clear(),e.get(R).length=0,e.get(E).length=0,e.get(H).length=0,e.get(S).length=0,e.get(L).length=0,e.get(F).length=0,e.set($,null),X.clear(),e.set(Y,null),q.clear(),N.clear(),j.clear(),e.get(G).length=0,K=null,V=null}const ut={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},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 ht={...ut},pt=e.state(0);function ft(){return e.get(pt)}function mt(){return ht}function vt(t){const n=ht;ht=wt(ut,t),e.update(pt),n.features.dock&&!ht.features.dock&&ee()}function yt(){ht={...ut},e.update(pt)}function wt(e,t){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},portalTarget:t.portalTarget??e.portalTarget}}function xt(e){return ht.features[e]}const zt=Symbol("modal-render-icon"),It=Symbol("modal-id");function bt(e,t){if(!Ue(e))throw new Error(`Cannot call ${t}() on unregistered modal "${String(e)}". Ensure the Modal component is rendered.`)}function _t(e){return{shake:()=>{bt(e,"shake"),Ae(e)},bringToFront:()=>{bt(e,"bringToFront"),re(e)},isOpen:()=>Ve(e),isRegistered:()=>Ue(e),open:t=>{bt(e,"open"),ae(e,t)},close:()=>{bt(e,"close"),ce(e)},minimize:()=>{bt(e,"minimize"),Z(e)},restore:()=>{bt(e,"restore"),J(e)},openChild:(t,n)=>{bt(e,"openChild"),pe({id:t},e,n)}}}function Mt(t={x:0,y:0}){const n=e.proxy({...t}),i=e.proxy({isDragging:!1,startX:0,startY:0,initialX:0,initialY:0,hasBeenDragged:!1});return{get position(){return n},get hasBeenDragged(){return i.hasBeenDragged},get isDragging(){return i.isDragging},onPointerDown:function(e,t){if(0===e.button){if(!i.hasBeenDragged){const e=t.getBoundingClientRect();n.x=e.left,n.y=e.top}i.isDragging=!0,i.startX=e.clientX,i.startY=e.clientY,i.initialX=n.x,i.initialY=n.y,t.setPointerCapture(e.pointerId)}},onPointerMove:function(e,t,o){if(!i.isDragging)return;const r=e.clientX-i.startX,s=e.clientY-i.startY,d=w(i.initialX+r,i.initialY+s,o.width,o.height);n.x=d.x,n.y=d.y,i.hasBeenDragged=!0},onPointerUp:function(e,t){i.isDragging&&(i.isDragging=!1,t.releasePointerCapture(e.pointerId))},setPosition:function(e){n.x=e.x,n.y=e.y},setHasBeenDragged:function(e){i.hasBeenDragged=e},reset:function(){n.x=t.x,n.y=t.y,i.hasBeenDragged=!1}}}function kt(t,n,i,o,r,s,d){let a=e.state(!1),l=e.state(""),c=e.state(e.proxy({width:0,height:0})),g=e.state(!1),u=e.state(!1),h={x:0,y:0,width:0,height:0,posX:0,posY:0,centerX:0,centerY:0},p=null;function f(s,d){s.preventDefault(),s.stopPropagation();const u=t();if(!u)return;const f=u.getBoundingClientRect();o()||(i({x:f.left,y:f.top}),r(!0)),e.get(g)||(e.set(c,{width:f.width,height:f.height},!0),e.set(g,!0));const y=n();e.set(a,!0),e.set(l,d,!0),p=s.pointerId,h={x:s.clientX,y:s.clientY,width:e.get(c).width,height:e.get(c).height,posX:y.x,posY:y.y,centerX:y.x+e.get(c).width/2,centerY:y.y+e.get(c).height/2},window.addEventListener("pointermove",m),window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v)}function m(t){if(t.pointerId!==p)return;const n=t.clientX-h.x,o=t.clientY-h.y,r=window.innerWidth,s=window.innerHeight,a=(null==d?void 0:d())??!1;let g=h.width,u=h.height,f=h.posX,m=h.posY;if(a){if(e.get(l).includes("e")||e.get(l).includes("w")){const t=e.get(l).includes("e")?n:-n;g=Math.max(280,h.width+2*t),f=h.centerX-g/2}if(e.get(l).includes("s")||e.get(l).includes("n")){const t=e.get(l).includes("s")?o:-o;u=Math.max(200,h.height+2*t),m=h.centerY-u/2}}else{if(e.get(l).includes("e")){const e=r-f;g=Math.max(280,Math.min(h.width+n,e))}if(e.get(l).includes("w")){const e=h.width-280,t=Math.min(n,e);g=h.width-t,f=h.posX+t}if(e.get(l).includes("s")){const e=s-m;u=Math.max(200,Math.min(h.height+o,e))}if(e.get(l).includes("n")){const e=h.height-200,t=Math.min(o,e);u=h.height-t,m=h.posY+t}}const v=x(f,m,g,u);e.set(c,{width:v.width,height:v.height},!0),i({x:v.x,y:v.y})}function v(t){t.pointerId===p&&(e.set(a,!1),p=null,window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v),e.set(u,!0),s(n(),e.get(c)),setTimeout(()=>{e.set(u,!1)},0))}const y={startResize:f};return{get isResizing(){return e.get(a)},get resizeDirection(){return e.get(l)},get size(){return e.get(c)},get hasBeenResized(){return e.get(g)},get isActive(){return e.get(a)},get justFinishedResizing(){return e.get(u)},start:f,setHasBeenResized:()=>{},setSize:function(t){e.set(c,t,!0),e.set(g,!0)},reset:function(){e.set(g,!1),e.set(c,{width:0,height:0},!0)},constrainToViewport:function(){const o=n(),r=t();if(!r)return;const s=x(o.x,o.y,e.get(c).width||r.offsetWidth,e.get(c).height||r.offsetHeight);e.set(c,{width:s.width,height:s.height},!0),i({x:s.x,y:s.y})},handlers:y}}function Dt(){return mt().features.animations}function Pt(t,n,i,o,r,s,d,a,l){let c=e.state(!1),g=e.state(!1),u=e.state(!1),h=e.state(!1),p=e.state(null),f=e.state(null),m=null,v=null;function y(){v&&(clearTimeout(v),v=null)}function w(){const e=t(),n=document.querySelector(`.modal-dock-item[data-modal-id="${D(e)}"]`),i=document.querySelector('[data-dock-container="true"]'),o=n||i;if(o){const e=o.getBoundingClientRect();return{x:e.left+e.width/2,y:e.top+e.height/2}}return{x:window.innerWidth/2,y:window.innerHeight-40}}return e.user_effect(()=>()=>{y(),e.set(c,!1),e.set(g,!1),e.set(u,!1),e.set(h,!1),e.set(p,null),e.set(f,null),m=null}),{get isMinimizing(){return e.get(c)},get isRestoring(){return e.get(g)},get isOpening(){return e.get(u)},get isClosing(){return e.get(h)},get animationTransform(){return e.get(p)},get pendingOpenSource(){return e.get(f)},startMinimize:function(t,h){const f=n();if(e.get(c)||!f)return;if(e.set(g,!1),e.set(u,!1),y(),!Dt()){const e=f.getBoundingClientRect();let t=r()?i():{x:e.left,y:e.top},n=d()?a():{width:e.width,height:e.height};return r()||(o(t),s(!0)),void(h?h():l(t,!0,n))}const m=f.getBoundingClientRect(),x=m.left+m.width/2,z=m.top+m.height/2;let I=r()?i():{x:m.left,y:m.top},b=d()?a():{width:m.width,height:m.height};r()||(o(I),s(!0));const _=t??w(),M=_.x-m.left,k=_.y-m.top,D={x:_.x-x,y:_.y-z,originX:M,originY:k};e.set(p,D,!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.set(c,!0)})}),v=setTimeout(()=>{h?h():l(I,!0,b)},500)},startRestore:function(t,n){if(!Dt()){const e=t||{x:window.innerWidth/2,y:window.innerHeight/2};return o(e),void s(!0)}const i=w(),r=t||{x:window.innerWidth/2,y:window.innerHeight/2},d=n||{width:480,height:400};o(r),s(!0);const a=r.x+d.width/2,l=r.y+d.height/2,c=i.x-r.x,u=i.y-r.y;e.set(p,{x:i.x-a,y:i.y-l,originX:c,originY:u},!0),e.set(g,!0),setTimeout(()=>{e.set(g,!1),e.set(p,null)},400)},startClose:function(t){e.get(h)||e.get(c)||(Dt()?(m=t,e.set(h,!0),setTimeout(()=>{e.set(h,!1),m&&(m(),m=null)},250)):t())},setPendingOpenSource:function(t){e.set(f,t,!0)},tryStartOpenAnimation:function(){const t=n();if(!e.get(f)||!t||e.get(u))return!1;if(!Dt())return e.set(f,null),!1;const d=e.get(f);e.set(f,null);const a=t.getBoundingClientRect(),l=r()?i():{x:a.left,y:a.top},c=a.width,g=a.height,h=l.x+c/2,m=l.y+g/2;r()||(o(l),s(!0));const v=d.x-l.x,y=d.y-l.y;return e.set(p,{x:d.x-h,y:d.y-m,originX:v,originY:y},!0),e.set(u,!0),setTimeout(()=>{e.set(u,!1),e.set(p,null)},400),!0},forceClearMinimize:function(){y(),e.set(c,!1),e.set(p,null)}}}const Ct=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function Bt(e){return Array.from(e.querySelectorAll(Ct)).filter(e=>null!==e.offsetParent||"A"===e.tagName)}function Ot(e,t){if("Tab"!==e.key)return;const n=Bt(t);if(0===n.length)return void e.preventDefault();const i=n[0],o=n[n.length-1],r=document.activeElement;e.shiftKey?r===i&&(o.focus(),e.preventDefault()):r===o&&(i.focus(),e.preventDefault())}function Tt(e){const t=Bt(e);return t.length>0&&(t[0].focus(),!0)}function Rt(){return{trapFocus:Ot,focusFirstElement:Tt}}const Et="modal-portal";function Ht(){return{mount:function(e,t=null){const n=function(e){if("undefined"==typeof window)return null;if(e instanceof HTMLElement)return e;if("string"==typeof e){const t=document.querySelector(e);if(t)return t;if(e.startsWith("#")){const t=e.slice(1),n=document.createElement("div");return n.id=t,document.body.appendChild(n),n}}let t=document.getElementById(Et);return t||(t=document.createElement("div"),t.id=Et,document.body.appendChild(t)),t}(t);return n?(n.appendChild(e),()=>{e.parentNode===n&&n.removeChild(e),n.id!==Et&&0===n.children.length&&n.parentNode&&n.parentNode.removeChild(n)}):()=>{}}}}function St(e){const n=t(It),i=e??n;if(!i)throw new Error("useModalZIndex: No modal ID provided and no modal context found. Either pass a modal ID or use this hook inside a Modal component.");return{get zIndex(){const e=be(i);return((null==e?void 0:e.zIndex)??mt().zIndex.base)+1},get portalTarget(){return mt().portalTarget}}}function Lt(){function t(e,t,n){return"undefined"==typeof window?()=>{}:(window.addEventListener(e,t,n),()=>{window.removeEventListener(e,t,n)})}return{addListener:t,addListenerEffect:function(n,i,o){e.user_effect(()=>{if("undefined"!=typeof window)return t(n,i,o)})}}}var Ft=e.from_html('<div style="display: contents;"><!></div>');function Wt(t,i){e.push(i,!0);let o=e.prop(i,"target",3,"body"),r=null,s=null;const{mount:d}=Ht();n(()=>(r&&(s=d(r,o())),()=>{null==s||s()}));var a=Ft(),l=e.child(a);e.snippet(l,()=>i.children),e.reset(a),e.bind_this(a,e=>r=e,()=>r),e.append(t,a),e.pop()}var At=e.from_html('<button type="button" aria-label="Minimize"></button>'),$t=e.from_html('<button type="button" class="modal-header-light modal-header-light-style" aria-label="Toggle style"></button>'),Xt=e.from_html('<div class="modal-header-icon"><!></div>'),Yt=e.from_html('<div class="modal-header-icon"><!></div>'),qt=e.from_html('<h2 class="modal-header-title"> </h2>'),Nt=e.from_html('<h2 class="modal-header-title"> </h2>'),jt=e.from_html('<div class="modal-header-traffic-lights"><button type="button" class="modal-header-light modal-header-light-close" aria-label="Close"></button> <!> <!></div> <div class="modal-header-mac-center"><!> <div class="modal-header-title-group"><!></div></div> <div class="modal-header-mac-spacer"></div>',1),Gt=e.from_html('<div class="modal-header-icon"><!></div>'),Kt=e.from_html('<div class="modal-header-icon"><!></div>'),Vt=e.from_html('<h2 class="modal-header-title"> </h2>'),Ut=e.from_html('<h2 class="modal-header-title"> </h2>'),Qt=e.from_html('<button type="button" class="modal-header-btn-windows modal-header-btn-windows-style" aria-label="Toggle style">◇</button>'),Zt=e.from_html('<button type="button" aria-label="Minimize">–</button>'),Jt=e.from_html('<div class="modal-header-title-group"><!> <!></div> <div class="modal-header-actions"><!> <!> <button type="button" class="modal-header-btn-windows modal-header-btn-windows-close" aria-label="Close">×</button></div>',1),en=e.from_html("<header><!></header>");function tn(n,i){e.push(i,!0);let o=e.prop(i,"isTransparent",3,!1),r=e.prop(i,"headerLayout",3,"macos"),s=e.prop(i,"minimizable",3,!0),d=e.prop(i,"minimizeDisabled",3,!1),a=e.prop(i,"transparencyEnabled",3,!0);const l=t(zt),c=e.derived(()=>null==l?void 0:l()),g=e.derived(()=>"macos"===r());var u=en();let h;u.__pointerdown=function(e){var t;e.target.closest("button")||null==(t=i.onStartDrag)||t.call(i,e)};var p=e.child(u),f=t=>{var n=jt(),o=e.first_child(n),r=e.child(o);r.__click=function(...e){var t;null==(t=i.onClose)||t.apply(this,e)};var l=e.sibling(r,2),g=t=>{var n=At();let o;n.__click=function(...e){var t;null==(t=d()?void 0:i.onMinimize)||t.apply(this,e)},e.template_effect(()=>{o=e.set_class(n,1,"modal-header-light modal-header-light-minimize",null,o,{"modal-header-light-disabled":d()}),n.disabled=d(),e.set_attribute(n,"title",d()?"Enable dock to minimize":void 0)}),e.append(t,n)};e.if(l,e=>{s()&&e(g)});var u=e.sibling(l,2),h=t=>{var n=$t();n.__click=function(...e){var t;null==(t=i.onToggleStyle)||t.apply(this,e)},e.append(t,n)};e.if(u,e=>{a()&&e(h)}),e.reset(o);var p=e.sibling(o,2),f=e.child(p),m=t=>{var n=Xt(),o=e.child(n);e.snippet(o,()=>i.customIcon),e.reset(n),e.append(t,n)},v=t=>{var n=e.comment(),o=e.first_child(n),r=t=>{var n=Yt(),o=e.child(n);e.snippet(o,()=>e.get(c),()=>i.icon),e.reset(n),e.append(t,n)};e.if(o,t=>{i.icon&&e.get(c)&&t(r)},!0),e.append(t,n)};e.if(f,e=>{i.customIcon?e(m):e(v,!1)});var y=e.sibling(f,2),w=e.child(y),x=t=>{var n=qt(),o=e.child(n,!0);e.reset(n),e.template_effect(()=>{e.set_attribute(n,"id",i.titleId),e.set_text(o,i.title)}),e.append(t,n)},z=t=>{var n=Nt(),o=e.child(n,!0);e.reset(n),e.template_effect(()=>e.set_text(o,i.title)),e.append(t,n)};e.if(w,e=>{i.titleId?e(x):e(z,!1)}),e.reset(y),e.reset(p),e.next(2),e.append(t,n)},m=t=>{var n=Jt(),o=e.first_child(n),r=e.child(o),l=t=>{var n=Gt(),o=e.child(n);e.snippet(o,()=>i.customIcon),e.reset(n),e.append(t,n)},g=t=>{var n=e.comment(),o=e.first_child(n),r=t=>{var n=Kt(),o=e.child(n);e.snippet(o,()=>e.get(c),()=>i.icon),e.reset(n),e.append(t,n)};e.if(o,t=>{i.icon&&e.get(c)&&t(r)},!0),e.append(t,n)};e.if(r,e=>{i.customIcon?e(l):e(g,!1)});var u=e.sibling(r,2),h=t=>{var n=Vt(),o=e.child(n,!0);e.reset(n),e.template_effect(()=>{e.set_attribute(n,"id",i.titleId),e.set_text(o,i.title)}),e.append(t,n)},p=t=>{var n=Ut(),o=e.child(n,!0);e.reset(n),e.template_effect(()=>e.set_text(o,i.title)),e.append(t,n)};e.if(u,e=>{i.titleId?e(h):e(p,!1)}),e.reset(o);var f=e.sibling(o,2),m=e.child(f),v=t=>{var n=Qt();n.__click=function(...e){var t;null==(t=i.onToggleStyle)||t.apply(this,e)},e.append(t,n)};e.if(m,e=>{a()&&e(v)});var y=e.sibling(m,2),w=t=>{var n=Zt();let o;n.__click=function(...e){var t;null==(t=d()?void 0:i.onMinimize)||t.apply(this,e)},e.template_effect(()=>{o=e.set_class(n,1,"modal-header-btn-windows",null,o,{"modal-header-btn-windows-disabled":d()}),n.disabled=d(),e.set_attribute(n,"title",d()?"Enable dock to minimize":void 0)}),e.append(t,n)};e.if(y,e=>{s()&&e(w)}),e.sibling(y,2).__click=function(...e){var t;null==(t=i.onClose)||t.apply(this,e)},e.reset(f),e.append(t,n)};e.if(p,t=>{e.get(g)?t(f):t(m,!1)}),e.reset(u),e.template_effect(()=>h=e.set_class(u,1,"modal-header",null,h,{"modal-header-draggable":!!i.onStartDrag,transparent:o()})),e.append(n,u),e.pop()}e.delegate(["pointerdown","click"]);var nn=e.from_html("<div></div>"),on=e.from_html('<div class="modal-resize-handles"></div>');function rn(t,n){e.push(n,!0);const i=["n","s","e","w","ne","nw","se","sw"];var o=e.comment(),r=e.first_child(o),s=t=>{var o=on();e.each(o,21,()=>i,e.index,(t,i)=>{var o=nn();o.__pointerdown=t=>function(e,t){var i;null==(i=n.onStartResize)||i.call(n,e,t)}(t,e.get(i)),e.template_effect(()=>e.set_class(o,1,`modal-resize-handle modal-resize-${e.get(i)??""}`)),e.append(t,o)}),e.reset(o),e.append(t,o)};e.if(r,e=>{n.onStartResize&&e(s)}),e.append(t,o),e.pop()}function sn(e,t){return t&&e.appendChild(t),{update(t){e.innerHTML="",t&&e.appendChild(t)},destroy(){e.innerHTML=""}}}e.delegate(["pointerdown"]);var dn=e.from_html('<div class="modal-footer"><!></div>'),an=e.from_html("<div></div>"),ln=e.from_html('<div role="dialog" aria-modal="true" tabindex="-1"><!> <div class="modal-body"><!></div> <!> <!> <!></div>');function cn(t,s){e.push(s,!0);let d=e.prop(s,"maxWidth",3,"600px"),a=e.prop(s,"autoOpen",3,!1),l=e.prop(s,"closeOnEscape",3,!0),c=e.state(!1);n(()=>{U({id:s.id,title:s.title,icon:s.icon??"",isOpen:a(),isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,isRejected:!1,position:null,size:null,hasBeenDragged:!1,dockPosition:0,glow:s.glow??null,parentId:void 0,childId:void 0,offsetFromParent:void 0}),e.set(c,!0)}),r(()=>{Q(s.id)});const g=e.derived(()=>{if(!e.get(c))return!1;ke();const t=be(s.id);return!!t&&(t.isOpen||t.isMinimized||Pe(s.id)||Be(s.id)||we(s.id))});var u=e.comment(),h=e.first_child(u),p=t=>{!function(t,s){e.push(s,!0);let d=e.prop(s,"maxWidth",3,"600px"),a=e.prop(s,"autoOpen",3,!1),l=e.prop(s,"closeOnEscape",3,!0),c=e.prop(s,"skipRegistration",3,!1);i(It,s.id);const g=mt().portalTarget,u=D(s.id);function h(e){var t,n;return(null==(n=null==(t=s.config)?void 0:t.features)?void 0:n[e])??xt(e)}const p=e.derived(()=>(ft(),h("drag"))),f=e.derived(()=>(ft(),h("minimize"))),m=e.derived(()=>(ft(),!h("dock"))),v=e.derived(()=>(ft(),h("transparency"))),y=e.derived(()=>(ft(),h("resize"))),x=e.derived(()=>{var e,t;return ft(),(null==(t=null==(e=s.config)?void 0:e.appearance)?void 0:t.headerLayout)??mt().appearance.headerLayout});let z=e.state(null),_=e.state(!1),P=e.state(!1),C=e.state(!1),B=e.state(!1),O=e.state(!1);const T=e.derived(()=>(ke(),be(s.id))),R=e.derived(()=>e.get(T)&&(e.get(T).isOpen||Be(s.id))&&(!e.get(T).isMinimized||we(s.id))&&!e.get(T).isHiddenWithParent),E=e.derived(()=>{var t;return!!(null==(t=e.get(T))?void 0:t.childId)}),H=e.derived(()=>{var t;return!!(null==(t=e.get(T))?void 0:t.parentId)}),S=e.derived(()=>e.get(E)||e.get(P)),L=e.derived(()=>!!s.glow),F=e.derived(()=>`modal-title-${u}`),W=e.derived(()=>{var t;return(null==(t=e.get(T))?void 0:t.zIndex)??1e3}),A=Mt({x:0,y:0});let $=e.state(!1);const X=kt(()=>e.get(z),()=>A.position,e=>A.setPosition(e),()=>A.hasBeenDragged,e=>A.setHasBeenDragged(e),(t,n)=>{const i=be(s.id);if(null==i?void 0:i.parentId){const t=be(i.parentId),o=document.querySelector(`[data-modal-id="${D(i.parentId)}"]`);if(t&&o){const i=t.position??{x:o.getBoundingClientRect().left,y:o.getBoundingClientRect().top},r=t.size??{width:o.offsetWidth,height:o.offsetHeight},d={x:i.x+(r.width-n.width)/2,y:i.y+(r.height-n.height)/2};e.set($,!0),A.setPosition(d);const a={x:d.x-i.x,y:d.y-i.y};return oe(s.id,{position:d,size:n,hasBeenDragged:!0,offsetFromParent:a}),void setTimeout(()=>{e.set($,!1)},200)}}oe(s.id,{position:t,size:n,hasBeenDragged:!0})}),Y=Pt(()=>s.id,()=>e.get(z),()=>A.position,e=>A.setPosition(e),()=>A.hasBeenDragged,e=>A.setHasBeenDragged(e),()=>X.hasBeenResized,()=>X.size,(e,t,n)=>{oe(s.id,{position:e,size:n,hasBeenDragged:t}),Z(s.id)}),{trapFocus:q,focusFirstElement:N}=Rt(),j=e.derived(()=>Y.isMinimizing||Y.isRestoring||Y.isOpening||Y.isClosing),G=e.derived(()=>(Se(s.id)||Ee(s.id))&&!Y.isRestoring);let K=e.state(!1);const V=e.derived(()=>Y.isRestoring||Y.isOpening||e.get(K)),J=e.derived(()=>e.get(R)&&!A.hasBeenDragged&&!e.get(j)&&!Y.pendingOpenSource&&!e.get(G)),ee=e.derived(()=>{const t=[];return t.push(`z-index: ${e.get(W)};`),Y.animationTransform?(t.push(`left: ${A.position.x}px; top: ${A.position.y}px;`),t.push(`--genie-origin-x: ${Y.animationTransform.originX}px;`),t.push(`--genie-origin-y: ${Y.animationTransform.originY}px;`),t.push(`--genie-translate-x: ${Y.animationTransform.x}px;`),t.push(`--genie-translate-y: ${Y.animationTransform.y}px;`)):A.hasBeenDragged&&t.push(`left: ${A.position.x}px; top: ${A.position.y}px; transform: none;`),X.hasBeenResized?t.push(`width: ${X.size.width}px; height: ${X.size.height}px; max-width: none; max-height: none;`):(s.preferredHeight&&t.push(`min-height: ${s.preferredHeight};`),d()&&t.push(`max-width: ${d()};`)),e.get(L)&&s.glow&&(t.push(`--modal-glow-color: ${s.glow.color};`),t.push(`--modal-glow-intensity: ${s.glow.intensity};`)),t.join(" ")});function te(){e.get(f)&&Z(s.id)}function ie(){var e;Te(s.id)&&Re(s.id),ce(s.id),null==(e=s.onClose)||e.call(s)}function de(){Ze(s.id)}function ae(t){e.get(p)&&e.get(z)&&A.onPointerDown(t,e.get(z))}function le(e){l()&&"Escape"===e.key&&se(s.id)&&(e.stopPropagation(),ie())}function ge(t){if(!e.get(z))return;const n=A.isDragging,i=X.hasBeenResized?X.size:{width:e.get(z).offsetWidth,height:e.get(z).offsetHeight};A.onPointerMove(t,e.get(z),i),A.isDragging&&n&&ne(s.id,A.position,{drag:!0})}function he(t){if(!e.get(z))return;const n=A.isDragging;A.onPointerUp(t,e.get(z)),n&&!X.justFinishedResizing&&(ne(s.id,A.position,{drag:!0}),st(s.id))}function pe(){var t;const n=mt();if("smart"!==(null==(t=n.positioning)?void 0:t.strategy))return!1;const i=be(s.id);if(null==i?void 0:i.parentId)return!1;if((null==i?void 0:i.hasBeenDragged)||(null==i?void 0:i.position))return!1;const o=e.get(z)||document.querySelector(`[data-modal-id="${u}"]`);if(!o)return!1;const r=o.offsetWidth,d=o.offsetHeight;if(r<=0||d<=0)return!1;const a=n.positioning.modalGap??16,l=Me(s.id),c=M(r,d,l,{modalGap:a,avoidBounds:b(n.positioning.avoidElements??[])});if(I(c.x,c.y,r,d,l,a)/(r*d)>.1&&l.length>0){const e=k(r,d,_e(s.id),{modalGap:a});if(e&&e.existingModalMoves.size>0)return rt(e.existingModalMoves),A.setPosition(e.newModalPosition),A.setHasBeenDragged(!0),ne(s.id,e.newModalPosition,{size:{width:r,height:d}}),!0}return A.setPosition(c),A.setHasBeenDragged(!0),ne(s.id,c,{size:{width:r,height:d}}),!0}function me(){o().then(()=>o()).then(()=>{let t=0;const n=()=>{t+=1,pe()||t>5||requestAnimationFrame(n)};e.get(z)?n():requestAnimationFrame(n)})}n(()=>{var t;function n(){const t=be(s.id);if(!(null==t?void 0:t.position)||!e.get(z))return;if(t.parentId)return;const n=X.hasBeenResized?X.size.width:e.get(z).offsetWidth,i=X.hasBeenResized?X.size.height:e.get(z).offsetHeight;if(n<=0||i<=0)return;const o=w(t.position.x,t.position.y,n,i);(Math.abs(o.x-t.position.x)>1||Math.abs(o.y-t.position.y)>1)&&(A.setPosition(o),ne(s.id,o))}return c()||(t=a(),U({id:s.id,title:s.title,icon:s.icon??"",isOpen:t,isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,isRejected:!1,position:null,size:null,hasBeenDragged:!1,dockPosition:0,glow:s.glow??null,parentId:void 0,childId:void 0,offsetFromParent:void 0}),t&&re(s.id)),a()&&(o().then(()=>{e.get(z)&&N(e.get(z))}),me()),window.addEventListener("pointermove",ge),window.addEventListener("pointerup",he),window.addEventListener("resize",n),()=>{window.removeEventListener("pointermove",ge),window.removeEventListener("pointerup",he),window.removeEventListener("resize",n)}}),r(()=>{Je(s.id),c()||Q(s.id)}),e.user_effect(()=>{ke();const t=be(s.id);if(t){if(e.set(_,t.isTransparent,!0),!A.isDragging&&!X.isResizing&&t.position){const e=A.position,n=t.position;(Math.abs(e.x-n.x)>.5||Math.abs(e.y-n.y)>.5)&&(A.setPosition(n),t.hasBeenDragged&&A.setHasBeenDragged(!0))}o().then(()=>function(){var t;if(!be(s.id))return;if(Te(s.id))return Re(s.id),void(null==(t=s.onClose)||t.call(s));if(we(s.id)&&!e.get(B)){if(e.set(B,!0),De(),e.get(z)){const t=e.get(z).getBoundingClientRect(),n=A.hasBeenDragged?A.position:{x:t.left,y:t.top},i=X.hasBeenResized?X.size:{width:t.width,height:t.height};oe(s.id,{position:n,size:i,hasBeenDragged:!0})}Y.startMinimize(void 0,()=>{xe(s.id),e.set(B,!1)})}if(Ee(s.id)){He(s.id);const t=be(s.id);Y.startRestore((null==t?void 0:t.position)??void 0,(null==t?void 0:t.size)??void 0),o().then(()=>{e.get(z)&&N(e.get(z))})}if(Se(s.id)){Le(s.id);const e=be(s.id);Y.startRestore((null==e?void 0:e.position)??void 0,(null==e?void 0:e.size)??void 0)}if(Be(s.id)&&(Oe(s.id),Y.startClose(()=>{var e;Je(s.id),ue(s.id),null==(e=s.onClose)||e.call(s)})),Pe(s.id)){Ce(s.id);const t=je(s.id)||s.openSourcePosition||null;t?(Y.setPendingOpenSource(t),o().then(()=>o()).then(()=>{pe(),Y.tryStartOpenAnimation()})):me(),o().then(()=>{e.get(z)&&N(e.get(z))})}Fe(s.id)&&(We(s.id),$e(s.id),e.set(O,!0),setTimeout(()=>{e.set(O,!1),Xe(s.id)},600));const n=qe(s.id);var i;n&&e.get(z)&&(i=n.parentId,o().then(()=>o()).then(()=>{let t=0;const n=()=>{t+=1;const o=function(t){var n,i;const o=be(t);if(!o)return!1;const r=e.get(z)||document.querySelector(`[data-modal-id="${u}"]`),d=document.querySelector(`[data-modal-id="${D(t)}"]`),a=null==d?void 0:d.getBoundingClientRect(),l=o.position??(a?{x:a.left,y:a.top}:null);if(!l||!r)return!1;const c=(null==(n=o.size)?void 0:n.width)??(null==d?void 0:d.offsetWidth)??(null==a?void 0:a.width)??480,g=(null==(i=o.size)?void 0:i.height)??(null==d?void 0:d.offsetHeight)??(null==a?void 0:a.height)??400,h=r.offsetWidth,p=r.offsetHeight;if(c<=0||g<=0||h<=0||p<=0)return!1;const f={x:l.x+(c-h)/2,y:l.y+(g-p)/2};return A.setPosition(f),A.setHasBeenDragged(!0),ne(s.id,f,{size:{width:h,height:p}}),o.position&&o.size||!a||ne(t,{x:a.left,y:a.top},{size:{width:c,height:g}}),fe(t,s.id),!0}(i);o||t>5||requestAnimationFrame(n)};e.get(z)?n():requestAnimationFrame(n)}))}())}}),e.user_effect(()=>{const t=be(s.id);t&&t.isTransparent!==e.get(_)&&e.set(_,t.isTransparent,!0)}),e.user_effect(()=>{if(e.get(R)&&e.get(z)){const t=t=>function(t){e.get(z)&&q(t,e.get(z))}(t);return e.get(z).addEventListener("keydown",t),()=>{var n;return null==(n=e.get(z))?void 0:n.removeEventListener("keydown",t)}}}),e.user_effect(()=>{!e.get(R)&&Y.isMinimizing&&Y.forceClearMinimize()}),e.user_effect(()=>{Y.isRestoring||Y.isOpening?e.set(K,!0):e.get(K)&&requestAnimationFrame(()=>{e.set(K,!1)})}),e.user_effect(()=>{e.get(C)&&!e.get(E)&&(e.set(P,!0),setTimeout(()=>{e.set(P,!1)},200)),e.set(C,e.get(E),!0)});var ve=e.comment(),ye=e.first_child(ve),ze=t=>{Wt(t,{get target(){return g},children:(t,n)=>{var i=ln();let o;i.__keydown=le;var r=e.child(i);{let t=e.derived(()=>e.get(p)?ae:void 0);tn(r,{get title(){return s.title},get customIcon(){return s.customIcon},get icon(){return s.icon},get isTransparent(){return e.get(_)},get titleId(){return e.get(F)},get headerLayout(){return e.get(x)},get onStartDrag(){return e.get(t)},onToggleStyle:de,onMinimize:te,onClose:ie,get minimizable(){return e.get(f)},get minimizeDisabled(){return e.get(m)},get transparencyEnabled(){return e.get(v)}})}var d=e.sibling(r,2),a=e.child(d);e.snippet(a,()=>s.children??e.noop),e.reset(d),e.action(d,(e,t)=>null==sn?void 0:sn(e,t),()=>s.bodyElement);var l=e.sibling(d,2),c=t=>{var n=dn(),i=e.child(n),o=t=>{var n=e.comment(),i=e.first_child(n);e.snippet(i,()=>s.footer),e.append(t,n)};e.if(i,e=>{s.footer&&e(o)}),e.reset(n),e.action(n,(e,t)=>null==sn?void 0:sn(e,t),()=>s.footerElement),e.append(t,n)};e.if(l,e=>{(s.footer||s.footerElement)&&e(c)});var g=e.sibling(l,2);{let t=e.derived(()=>e.get(y)&&!e.get(E)?X.handlers.startResize:void 0);rn(g,{get onStartResize(){return e.get(t)}})}var h=e.sibling(g,2),w=t=>{var n=an();let i;e.template_effect(()=>i=e.set_class(n,1,"modal-child-overlay",null,i,{"modal-overlay-closing":e.get(P)})),e.append(t,n)};e.if(h,t=>{e.get(S)&&t(w)}),e.reset(i),e.bind_this(i,t=>e.set(z,t),()=>e.get(z)),e.template_effect(()=>{var t;o=e.set_class(i,1,"modal-dialog",null,o,{"modal-dragging":A.isDragging,"modal-resizing":X.isResizing,"modal-positioned":A.hasBeenDragged,"modal-minimizing":Y.isMinimizing,"modal-restoring":Y.isRestoring,"modal-opening":Y.isOpening,"modal-closing":Y.isClosing,"modal-centered":e.get(J),"modal-solid":!e.get(_),"modal-transparent":e.get(_),"modal-glow":e.get(L),"modal-has-child":e.get(E),"modal-is-child":e.get(H),"modal-visible-by-animation":e.get(V),"modal-animating-to-center":e.get($),"modal-animating-position":null==(t=e.get(T))?void 0:t.isAnimatingPosition,"modal-attention":e.get(O)}),e.set_attribute(i,"data-modal-id",u),e.set_style(i,e.get(ee)),e.set_attribute(i,"aria-labelledby",e.get(F))}),e.event("pointerdown",i,()=>re(s.id),!0),e.append(t,i)},$$slots:{default:!0}})};e.if(ye,t=>{e.get(R)&&t(ze)}),e.append(t,ve),e.pop()}(t,{get id(){return s.id},get title(){return s.title},get icon(){return s.icon},get customIcon(){return s.customIcon},get maxWidth(){return d()},get preferredHeight(){return s.preferredHeight},get autoOpen(){return a()},get openSourcePosition(){return s.openSourcePosition},get glow(){return s.glow},get config(){return s.config},get closeOnEscape(){return l()},get onClose(){return s.onClose},get children(){return s.children},get footer(){return s.footer},skipRegistration:!0})};e.if(h,t=>{e.get(g)&&t(p)}),e.append(t,u),e.pop()}e.delegate(["keydown"]);var gn=e.from_html('<button type="button" aria-label="Drag dock"></button>'),un=e.from_html('<span class="modal-dock-item-icon-placeholder"> </span>'),hn=e.from_html('<span class="modal-dock-item-label"> </span>'),pn=e.from_html("<span>+</span>"),fn=e.from_html('<span class="modal-dock-child-indicator"><!></span>'),mn=e.from_html('<button><span class="modal-dock-item-icon"><!></span> <!> <span class="modal-dock-item-glow"></span> <!></button>'),vn=e.from_html('<div data-dock-container="true"><div><!> <!></div></div>');function yn(n,i){e.push(i,!0);const o=t(zt),r=e.derived(()=>i.renderIcon??(null==o?void 0:o())),s=Qe(),l=e.derived(()=>(ft(),mt())),u=e.derived(()=>m("DOCK")),h=e.derived(()=>e.get(l).dock.position),p=e.derived(()=>e.get(l).dock.labelMode);let f=e.state("horizontal"),v=e.state(e.proxy({x:100,y:100})),y=e.state(null),x=e.state(!1),z={x:0,y:0},I=null;const b=e.derived(()=>(ke(),Array.from(s.modals.values()).filter(e=>e.isMinimized).sort((e,t)=>e.dockPosition-t.dockPosition))),_=e.derived(()=>{switch(e.get(h)){case"left":return{x:-20,duration:250,easing:c};case"right":return{x:20,duration:250,easing:c};default:return{y:20,duration:250,easing:c}}});function M(t){var n;"free"===e.get(h)&&(e.set(x,!0),I=t.pointerId,z={x:t.clientX-e.get(v).x,y:t.clientY-e.get(v).y},null==(n=t.currentTarget)||n.setPointerCapture(t.pointerId),window.addEventListener("pointermove",k),window.addEventListener("pointerup",P),window.addEventListener("pointercancel",P))}function k(t){if(t.pointerId!==I||!e.get(y))return;const n=e.get(y).getBoundingClientRect(),i=window.innerWidth-n.width-8,o=window.innerHeight-n.height-8,r=Math.min(Math.max(t.clientX-z.x,8),Math.max(8,i)),s=Math.min(Math.max(t.clientY-z.y,8),Math.max(8,o));e.set(v,{x:Math.round(r),y:Math.round(s)},!0)}function P(t){t.pointerId===I&&(e.set(x,!1),I=null,window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",P),window.removeEventListener("pointercancel",P))}const{addListener:C}=Lt();function B(){if("free"!==e.get(h)||!e.get(y))return;const t=e.get(y).getBoundingClientRect(),n=w(e.get(v).x,e.get(v).y,t.width,t.height);n.x===e.get(v).x&&n.y===e.get(v).y||e.set(v,{x:Math.round(n.x),y:Math.round(n.y)},!0)}e.user_effect(()=>{"undefined"!=typeof window&&C("resize",B)});var O={setDockOrientation:function(t){e.set(f,t,!0)},setDockFreePosition:function(t){e.set(v,t,!0)},getDockState:function(){return{dockPosition:e.get(h),dockOrientation:e.get(f),dockFreePosition:e.get(v),dockLabelMode:e.get(p)}}};return Wt(n,{get target(){return e.get(l).portalTarget},children:(t,n)=>{var i=vn();let o,l;var c=e.child(i);let m;var w=e.child(c),z=t=>{var n=gn();let i;n.__pointerdown=M,e.template_effect(()=>i=e.set_class(n,1,"modal-dock-handle",null,i,{"modal-dock-handle-dragging":e.get(x)})),e.append(t,n)};e.if(w,t=>{"free"===e.get(h)&&t(z)});var I=e.sibling(w,2);e.each(I,19,()=>e.get(b),e=>e.id,(t,n,i)=>{const o=e.derived(()=>e.get(n).lastChildId?s.modals.get(e.get(n).lastChildId):null);var a=mn();let l;a.__click=t=>{Ke(e.get(n).id)?et(t.currentTarget):J(e.get(n).id)};var c=e.child(a),u=e.child(c),h=t=>{var i=e.comment(),o=e.first_child(i);e.snippet(o,()=>e.get(r),()=>e.get(n).icon),e.append(t,i)},f=t=>{var i=un(),o=e.child(i,!0);e.reset(i),e.template_effect(t=>e.set_text(o,t),[()=>e.get(n).title.charAt(0)]),e.append(t,i)};e.if(u,t=>{e.get(n).icon&&e.get(r)?t(h):t(f,!1)}),e.reset(c);var m=e.sibling(c,2),v=t=>{var i=hn(),o=e.child(i,!0);e.reset(i),e.template_effect(()=>e.set_text(o,e.get(n).title)),e.append(t,i)};e.if(m,t=>{"hidden"!==e.get(p)&&t(v)});var y=e.sibling(m,4),w=t=>{var n=fn(),i=e.child(n),s=t=>{var n=e.comment(),i=e.first_child(n);e.snippet(i,()=>e.get(r),()=>e.get(o).icon),e.append(t,n)},d=t=>{var n=pn();e.append(t,n)};e.if(i,t=>{e.get(o).icon&&e.get(r)?t(s):t(d,!1)}),e.reset(n),e.append(t,n)};e.if(y,t=>{e.get(n).lastChildId&&e.get(o)&&t(w)}),e.reset(a),e.template_effect(t=>{l=e.set_class(a,1,"modal-dock-item",null,l,{"modal-dock-item-has-glow":!!e.get(n).glow,"modal-dock-item-has-child":!!e.get(n).lastChildId,"modal-dock-item-label-beside":"beside"===e.get(p),"modal-dock-item-label-below":"below"===e.get(p)}),e.set_attribute(a,"data-modal-id",t),e.set_style(a,e.get(n).glow?`--modal-dock-glow-color: ${e.get(n).glow.color};`:"")},[()=>D(e.get(n).id)]),e.transition(3,a,()=>d,()=>({duration:300,delay:50*e.get(i),easing:g,start:.5})),e.append(t,a)}),e.reset(c),e.reset(i),e.bind_this(i,t=>e.set(y,t),()=>e.get(y)),e.template_effect(()=>{o=e.set_class(i,1,"modal-dock-container",null,o,{"modal-dock-left":"left"===e.get(h),"modal-dock-right":"right"===e.get(h),"modal-dock-bottom":"bottom"===e.get(h),"modal-dock-free":"free"===e.get(h),"modal-dock-empty":0===e.get(b).length}),l=e.set_style(i,"free"===e.get(h)?`left: ${e.get(v).x}px; top: ${e.get(v).y}px;`:"",l,{"z-index":e.get(u)}),m=e.set_class(c,1,"modal-dock",null,m,{"modal-dock-free-horizontal":"free"===e.get(h)&&"horizontal"===e.get(f),"modal-dock-free-vertical":"free"===e.get(h)&&"vertical"===e.get(f)})}),e.transition(3,i,()=>a,()=>e.get(b).length>0?e.get(_):{duration:0}),e.append(t,i)},$$slots:{default:!0}}),e.pop(O)}e.delegate(["pointerdown","click"]);var wn=e.from_html('<div class="modal-backdrop svelte-1d3nq4t" aria-hidden="true"></div>');function xn(t,n){e.push(n,!0);const i=Qe(),o=e.derived(()=>(ft(),mt())),r=e.derived(()=>e.get(o).features.backdrop),s=e.derived(()=>(ke(),Array.from(i.modals.values()).some(e=>e.isOpen&&!e.isMinimized&&!e.isHiddenWithParent))),d=e.derived(()=>e.get(r)&&e.get(s)),a=e.derived(()=>m("MODAL")-1);Wt(t,{get target(){return e.get(o).portalTarget},children:(t,n)=>{var i=e.comment(),o=e.first_child(i),r=t=>{var n=wn();let i;e.template_effect(()=>i=e.set_style(n,"",i,{"z-index":e.get(a)})),e.transition(3,n,()=>l,()=>({duration:200})),e.append(t,n)};e.if(o,t=>{e.get(d)&&t(r)}),e.append(t,i)},$$slots:{default:!0}}),e.pop()}var zn=e.from_html("<!> <!>",1);function In(t,n){e.push(n,!0),i(zt,()=>n.renderIcon),e.user_effect(()=>(s(()=>{n.config&&vt(n.config),p()}),()=>{yt(),v()})),e.user_effect(()=>{if("undefined"==typeof document)return;const e=s(()=>mt().portalTarget);if("string"==typeof e&&!document.querySelector(e)){const t=document.createElement("div");return t.id=e.replace("#",""),document.body.appendChild(t),()=>{t.remove()}}});var o=zn(),r=e.first_child(o);xn(r,{});var d=e.sibling(r,2);e.snippet(d,()=>n.children??e.noop),e.append(t,o),e.pop()}export{xn as Backdrop,yn as Dock,cn as Modal,tn as ModalHeader,In as ModalProvider,Wt as Portal,rn as ResizeHandles,ct as _getInternalState,gt as _resetInternalState,f as acquireModalZIndex,rt as animateModalsToPositions,tt as animateParentToPosition,re as bringToFront,z as calculateOverlap,_ as calculatePositionScore,k as calculateRearrangement,I as calculateTotalOverlap,nt as clearParentAnimationFlag,ot as clearPendingParentAnimation,ge as closeAllModals,ce as closeModal,x as constrainSizeToViewport,w as constrainToViewport,je as consumeOpenSourcePosition,We as consumePendingAttention,Le as consumePendingChildRestore,Oe as consumePendingClose,Re as consumePendingForceClose,xe as consumePendingMinimize,De as consumePendingMinimizeTarget,Ce as consumePendingOpen,qe as consumePendingParentLink,He as consumePendingRestore,le as createModal,ut as defaultConfig,Xe as endAttentionAnimation,ue as finalizeModalClose,M as findSmartPosition,Tt as focusFirstElement,mt as getConfig,ft as getConfigVersion,b as getElementBounds,m as getLayerZIndex,be as getModalState,Qe as getModalsStore,he as getModalsToClose,Me as getOpenModalBounds,_e as getOpenModalBoundsWithIds,Ye as getPendingParentLink,Ie as getRegisteredModalIds,ke as getStateVersion,ze as hasAnyPendingMinimize,Fe as hasPendingAttention,Se as hasPendingChildRestore,Be as hasPendingClose,Te as hasPendingForceClose,we as hasPendingMinimize,Pe as hasPendingOpen,it as hasPendingParentAnimation,Ee as hasPendingRestore,me as hideChildWithParent,p as initializeStacking,xt as isFeatureEnabled,Ke as isModalAnimating,Ve as isModalOpen,Ue as isModalRegistered,se as isTopModal,fe as linkModals,wt as mergeConfig,Z as minimizeModal,pe as openChildModal,ae as openModal,U as registerModal,de as reorderDock,yt as resetConfig,Je as resetModalTransparency,v as resetStacking,ee as restoreAllMinimizedModals,te as restoreChildModal,J as restoreModal,ye as setChildOffsetFromParent,vt as setConfig,lt as setDockPositionGetter,Ge as setModalAnimating,dt as setRegistryFunctions,at as setURLStateCallbacks,et as shakeElement,$e as startAttentionAnimation,Ne as storeOpenSourcePosition,T as subscribe,Ze as toggleModalTransparency,Ot as trapFocus,Ae as triggerAttention,st as triggerCascadingParentAnimations,Q as unregisterModal,ve as updateChildPosition,oe as updateModal,ne as updateModalPosition,ie as updateModalSize,Rt as useFocusTrap,_t as useModal,Pt as useModalAnimation,Mt as useModalDrag,kt as useModalResize,St as useModalZIndex,Ht as usePortal,Lt as useWindowEvent};
|
package/dist/vanilla.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{onMount as e,getContext as t,setContext as i,tick as n,onDestroy as o,mount as r,unmount as d}from"svelte";import"svelte/internal/disclose-version";import*as s from"svelte/internal/client";import{scale as a,fly as l,fade as c}from"svelte/transition";import{cubicOut as g,backOut as u}from"svelte/easing";const h={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},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 p={...h},f=s.state(0);function m(){return s.get(f)}function v(){return p}function w(e){const t=p;var i,n;p={features:{...(i=h).features,...(n=e).features},dock:{...i.dock,...n.dock},animations:{...i.animations,...n.animations},appearance:{...i.appearance,...n.appearance},zIndex:{...i.zIndex,...n.zIndex},parentChild:{...i.parentChild,...n.parentChild},positioning:{...i.positioning,...n.positioning},portalTarget:n.portalTarget??i.portalTarget},s.update(f),t.features.dock&&!p.features.dock&&(Array.from(P.values()).filter(e=>e.isMinimized).map(e=>e.id).forEach(e=>{const t=P.get(e);if(t){P.set(e,{...t,isMinimized:!1,isOpen:!0}),s.set(S,[...s.get(S),e],!0),ee(e);const i=t.lastChildId||t.childId;i&&Q(i)}}),s.set(j,[],!0),O())}const y={BASE:0,DROPDOWN:100,STICKY:200,OVERLAY:300,MODAL:400,DOCK:8e3,TOAST:9e3};let x=s.state(s.proxy(y.MODAL));function z(e){const t=v();return"MODAL"===e?t.zIndex.base:"DOCK"===e?t.zIndex.dock:"TOAST"===e?t.zIndex.toast:y[e]}const I=8;function b(e,t,i,n,o={}){const{margin:r=I,allowPartialVisibility:d=!1}=o,s="undefined"!=typeof window?window.innerWidth:1920,a="undefined"!=typeof window?window.innerHeight:1080;let l,c,g,u;return d&&i>s-2*r?(l=40-i,c=s-40):(l=r,c=Math.max(r,s-i-r)),d&&n>a-2*r?(g=40-n,u=a-40):(g=r,u=Math.max(r,a-n-r)),{x:Math.max(l,Math.min(c,e)),y:Math.max(g,Math.min(u,t))}}function _(e,t,i,n,o={}){const{margin:r=I}=o,d=("undefined"!=typeof window?window.innerWidth:1920)-2*r,s=("undefined"!=typeof window?window.innerHeight:1080)-2*r,a=Math.min(i,d),l=Math.min(n,s),c=b(e,t,a,l,o);return{x:c.x,y:c.y,width:a,height:l}}function M(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 k(e,t,i,n,o,r){const d={x:e-r,y:t-r,width:i+2*r,height:n+2*r};let s=0;for(const e of o)s+=M(d,e);return s}function D(e,t,i,n,o,r,d){const s=(o-i)/2,a=(r-n)/2,l=s-d,c=a-d,g=Math.abs(e-s)/(l||1),u=Math.abs(t-a)/(c||1),h=Math.sqrt(g*g+u*u)/Math.SQRT2,p=50,f=e-d,m=o-i-d-e,v=t-d,w=r-n-d-t;let y=0;return f<p&&(y+=.3*(1-f/p)),m<p&&(y+=.3*(1-m/p)),v<p&&(y+=.2*(1-v/p)),w<p&&(y+=.2*(1-w/p)),Math.min(1,h+y)}let P=s.proxy(new Map),C=s.state(0);const B=new Set;function O(){s.update(C),queueMicrotask(()=>{B.forEach(e=>e())})}let R=s.state(s.proxy([])),T=s.state(s.proxy([])),E=s.state(s.proxy([])),H=s.state(s.proxy([])),S=s.state(s.proxy([])),L=s.state(s.proxy([])),W=s.state(s.proxy([])),A=s.state(s.proxy([])),$=s.state(null),F=s.proxy(new Map),X=s.state(null),Y=s.proxy(new Map),q=s.proxy(new Set),N=s.proxy(new Set),j=s.state(s.proxy([]));function G(e){const t=P.get(e.id),i=(null==t?void 0:t.zIndex)??function(){const e=s.get(x);return s.set(x,s.get(x)+2),e}();t?P.set(e.id,{...t,title:e.title,icon:e.icon,glow:e.glow,zIndex:i}):P.set(e.id,{...e,zIndex:i,isAnimating:!1}),O(),e.isMinimized&&!s.get(j).includes(e.id)&&s.get(j).push(e.id)}function K(e){const t=P.get(e);if(t){if(s.set(j,s.get(j).filter(t=>t!==e),!0),t.childId){const e=P.get(t.childId);e&&P.set(t.childId,{...e,parentId:void 0})}if(t.parentId){const e=P.get(t.parentId);e&&P.set(t.parentId,{...e,childId:void 0,lastChildId:t.id})}P.delete(e),O(),N.delete(e),q.delete(e)}}function V(e){const t=P.get(e);if(!t||t.isMinimized)return;if(ye(e),t.parentId){const e=P.get(t.parentId);if(e&&!e.isMinimized)return void V(t.parentId)}s.set(R,[...s.get(R),e],!0),t.position&&t.size;const i=t.childId;P.set(e,{...t,isMinimized:!0,lastChildId:i}),O(),s.get(j).includes(e)||s.get(j).push(e),t.childId&&function(e){const t=P.get(e);if(!(null==t?void 0:t.childId))return;const i=P.get(t.childId);i&&(P.set(t.childId,{...i,isHiddenWithParent:!0}),O())}(e)}function U(e){const t=P.get(e);if(!t||!t.isMinimized)return;P.set(e,{...t,isMinimized:!1,isOpen:!0}),O(),s.set(S,[...s.get(S),e],!0),ee(e);const i=t.lastChildId||t.childId;i&&Q(i)}function Q(e){const t=P.get(e);t&&t.isHiddenWithParent&&(P.set(e,{...t,isHiddenWithParent:!1}),O(),s.set(L,[...s.get(L),e],!0))}function J(e,t,i){const n=P.get(e);if(!n)return;let o=t;if((null==i?void 0:i.constrain)&&n.size&&(o=b(t.x,t.y,n.size.width,n.size.height)),P.set(e,{...n,position:o,size:(null==i?void 0:i.size)??n.size,hasBeenDragged:n.hasBeenDragged||(null==i?void 0:i.drag)||!1}),n.childId){let t=e,i=o;for(;;){const e=P.get(t);if(!(null==e?void 0:e.childId))break;const n=P.get(e.childId);if(!(null==n?void 0:n.offsetFromParent))break;const o={x:i.x+n.offsetFromParent.x,y:i.y+n.offsetFromParent.y};P.set(e.childId,{...n,position:o,hasBeenDragged:!0}),t=e.childId,i=o}}if(n.parentId&&n.offsetFromParent){const t=v();let i=e,r=n;for(;r.parentId&&r.offsetFromParent;){const n=P.get(r.parentId);if(!n)break;const d=i===e?o:P.get(i).position,s={x:d.x-r.offsetFromParent.x,y:d.y-r.offsetFromParent.y};"animated"===t.parentChild.movementMode?Y.set(r.parentId,s):P.set(r.parentId,{...n,position:s,hasBeenDragged:!0}),i=r.parentId,r=n}}O()}function Z(e,t){const i=P.get(e);i&&(P.set(e,{...i,...t}),O())}function ee(e){var t;const i=P.get(e);if(!i)return;const n=Math.max(...Array.from(P.values()).map(e=>e.zIndex),0);if(i.parentId){const o=P.get(i.parentId);o&&o.zIndex<n&&P.set(i.parentId,{...o,zIndex:n+2});const r=(null==(t=P.get(i.parentId))?void 0:t.zIndex)??n+2;return i.zIndex<=r&&P.set(e,{...i,zIndex:r+2}),void O()}if(i.zIndex<n&&(P.set(e,{...i,zIndex:n+2}),O()),i.childId){const t=P.get(i.childId),n=P.get(e);t&&n&&t.zIndex<=n.zIndex&&(P.set(i.childId,{...t,zIndex:n.zIndex+2}),O())}}function te(e,t,i){const n=t.getBoundingClientRect();F.set(e,{x:n.left+n.width/2,y:n.top+n.height/2});const o=v();(null==i?void 0:i.parentId)&&o.features.parentChild&&s.set(X,{parentId:i.parentId,childId:e},!0),s.get(T).includes(e)||s.set(T,[...s.get(T),e],!0),O();const r=P.get(e);if(r){if(r.isOpen&&!r.isMinimized&&!r.isHiddenWithParent)return s.set(T,s.get(T).filter(t=>t!==e),!0),function(e){P.get(e)&&(s.get(W).includes(e)||s.get(A).includes(e)||(s.set(W,[...s.get(W),e],!0),O()))}(e),void ee(e);if(r.isMinimized)return s.set(T,s.get(T).filter(t=>t!==e),!0),void U(e);P.set(e,{...r,isOpen:!0}),ee(e)}}function ie(e,t=!1){const i=P.get(e);i&&(ye(e),t?s.set(H,[...s.get(H),e],!0):s.set(E,[...s.get(E),e],!0),O(),i.childId&&ie(i.childId,t))}function ne(){Array.from(P.keys()).forEach(e=>ie(e,!0))}function oe(e,t,i){const n=v();if(i&&!F.has(e.id)){const t=i.getBoundingClientRect();F.set(e.id,{x:t.left+t.width/2,y:t.top+t.height/2})}const o={id:e.id,title:e.title??"",icon:e.icon??"",isOpen:!0,isMinimized:!1,isHiddenWithParent:!1,isTransparent:e.isTransparent??!1,isRejected:!1,position:e.position??null,size:e.size??null,hasBeenDragged:e.hasBeenDragged??!1,dockPosition:e.dockPosition??-1,glow:e.glow??null};if(!n.features.parentChild){G(o);const t=P.get(e.id);return t&&P.set(e.id,{...t,isOpen:!0}),s.set(T,[...s.get(T),e.id],!0),O(),void ee(e.id)}const r=P.get(t);if(!r)return;r.childId&&ie(r.childId,!0),G({...o,parentId:t});const d=P.get(e.id);d&&P.set(e.id,{...d,isOpen:!0,parentId:t}),s.set(T,[...s.get(T),e.id],!0),O(),ee(e.id),s.set(X,{parentId:t,childId:e.id},!0)}function re(e){return s.get(R).includes(e)}function de(e){return P.get(e)}function se(){return s.get(C)}function ae(e){return s.get(T).includes(e)}function le(e){return s.get(E).includes(e)}function ce(e){return s.get(H).includes(e)}function ge(e){return!!s.get(H).includes(e)&&(s.set(H,s.get(H).filter(t=>t!==e),!0),!0)}function ue(e){return s.get(S).includes(e)}function he(e){return s.get(L).includes(e)}function pe(e){const t=P.get(e);return void 0!==t&&t.isOpen&&!t.isMinimized&&!t.isHiddenWithParent}function fe(e){return P.has(e)}function me(){return{get modals(){return P},get pendingMinimize(){return s.get(R)},get pendingOpen(){return s.get(T)},get pendingClose(){return s.get(E)},get pendingRestore(){return s.get(S)},get dockOrder(){return s.get(j)}}}function ve(e){N.has(e)?N.delete(e):N.add(e);const t=P.get(e);t&&(P.set(e,{...t,isTransparent:N.has(e)}),O())}function we(e){N.delete(e);const t=P.get(e);t&&(P.set(e,{...t,isTransparent:!1}),O())}function ye(e){Y.delete(e)}const xe=Symbol("modal-render-icon"),ze=Symbol("modal-id");function Ie(){return v().features.animations}const be=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function _e(e){return Array.from(e.querySelectorAll(be)).filter(e=>null!==e.offsetParent||"A"===e.tagName)}function Me(e,t){if("Tab"!==e.key)return;const i=_e(t);if(0===i.length)return void e.preventDefault();const n=i[0],o=i[i.length-1],r=document.activeElement;e.shiftKey?r===n&&(o.focus(),e.preventDefault()):r===o&&(n.focus(),e.preventDefault())}function ke(e){const t=_e(e);return t.length>0&&(t[0].focus(),!0)}const De="modal-portal";var Pe=s.from_html('<div style="display: contents;"><!></div>');function Ce(t,i){s.push(i,!0);let n=s.prop(i,"target",3,"body"),o=null,r=null;const{mount:d}={mount:function(e,t=null){const i=function(e){if("undefined"==typeof window)return null;if(e instanceof HTMLElement)return e;if("string"==typeof e){const t=document.querySelector(e);if(t)return t;if(e.startsWith("#")){const t=e.slice(1),i=document.createElement("div");return i.id=t,document.body.appendChild(i),i}}let t=document.getElementById(De);return t||(t=document.createElement("div"),t.id=De,document.body.appendChild(t)),t}(t);return i?(i.appendChild(e),()=>{e.parentNode===i&&i.removeChild(e),i.id!==De&&0===i.children.length&&i.parentNode&&i.parentNode.removeChild(i)}):()=>{}}};e(()=>(o&&(r=d(o,n())),()=>{null==r||r()}));var a=Pe(),l=s.child(a);s.snippet(l,()=>i.children),s.reset(a),s.bind_this(a,e=>o=e,()=>o),s.append(t,a),s.pop()}var Be=s.from_html('<button type="button" aria-label="Minimize"></button>'),Oe=s.from_html('<button type="button" class="modal-header-light modal-header-light-style" aria-label="Toggle style"></button>'),Re=s.from_html('<div class="modal-header-icon"><!></div>'),Te=s.from_html('<div class="modal-header-icon"><!></div>'),Ee=s.from_html('<h2 class="modal-header-title"> </h2>'),He=s.from_html('<h2 class="modal-header-title"> </h2>'),Se=s.from_html('<div class="modal-header-traffic-lights"><button type="button" class="modal-header-light modal-header-light-close" aria-label="Close"></button> <!> <!></div> <div class="modal-header-mac-center"><!> <div class="modal-header-title-group"><!></div></div> <div class="modal-header-mac-spacer"></div>',1),Le=s.from_html('<div class="modal-header-icon"><!></div>'),We=s.from_html('<div class="modal-header-icon"><!></div>'),Ae=s.from_html('<h2 class="modal-header-title"> </h2>'),$e=s.from_html('<h2 class="modal-header-title"> </h2>'),Fe=s.from_html('<button type="button" class="modal-header-btn-windows modal-header-btn-windows-style" aria-label="Toggle style">◇</button>'),Xe=s.from_html('<button type="button" aria-label="Minimize">–</button>'),Ye=s.from_html('<div class="modal-header-title-group"><!> <!></div> <div class="modal-header-actions"><!> <!> <button type="button" class="modal-header-btn-windows modal-header-btn-windows-close" aria-label="Close">×</button></div>',1),qe=s.from_html("<header><!></header>");s.delegate(["pointerdown","click"]);var Ne=s.from_html("<div></div>"),je=s.from_html('<div class="modal-resize-handles"></div>');s.delegate(["pointerdown"]);var Ge=s.from_html('<div class="modal-footer"><!></div>'),Ke=s.from_html("<div></div>"),Ve=s.from_html('<div role="dialog" aria-modal="true" tabindex="-1"><!> <div class="modal-body"><!></div> <!> <!> <!></div>');function Ue(r,d){s.push(d,!0);let a=s.prop(d,"maxWidth",3,"600px"),l=s.prop(d,"autoOpen",3,!1),c=s.prop(d,"closeOnEscape",3,!0),g=s.state(!1);e(()=>{G({id:d.id,title:d.title,icon:d.icon??"",isOpen:l(),isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,isRejected:!1,position:null,size:null,hasBeenDragged:!1,dockPosition:0,glow:d.glow??null,parentId:void 0,childId:void 0,offsetFromParent:void 0}),s.set(g,!0)}),o(()=>{K(d.id)});const u=s.derived(()=>{if(!s.get(g))return!1;se();const e=de(d.id);return!!e&&(e.isOpen||e.isMinimized||ae(d.id)||le(d.id)||re(d.id))});var h=s.comment(),f=s.first_child(h),w=r=>{!function(r,d){s.push(d,!0);let a=s.prop(d,"maxWidth",3,"600px"),l=s.prop(d,"autoOpen",3,!1),c=s.prop(d,"closeOnEscape",3,!0),g=s.prop(d,"skipRegistration",3,!1);i(ze,d.id);const u=v().portalTarget;function h(e){var t,i;return(null==(i=null==(t=d.config)?void 0:t.features)?void 0:i[e])??function(e){return p.features[e]}(e)}const f=s.derived(()=>(m(),h("drag"))),w=s.derived(()=>(m(),h("minimize"))),y=s.derived(()=>(m(),!h("dock"))),x=s.derived(()=>(m(),h("transparency"))),z=s.derived(()=>(m(),h("resize"))),I=s.derived(()=>{var e,t;return m(),(null==(t=null==(e=d.config)?void 0:e.appearance)?void 0:t.headerLayout)??v().appearance.headerLayout});let M=s.state(null),C=s.state(!1),B=s.state(!1),H=s.state(!1),q=s.state(!1),N=s.state(!1);const j=s.derived(()=>(se(),de(d.id))),U=s.derived(()=>s.get(j)&&(s.get(j).isOpen||le(d.id))&&(!s.get(j).isMinimized||re(d.id))&&!s.get(j).isHiddenWithParent),Q=s.derived(()=>{var e;return!!(null==(e=s.get(j))?void 0:e.childId)}),te=s.derived(()=>{var e;return!!(null==(e=s.get(j))?void 0:e.parentId)}),ne=s.derived(()=>s.get(Q)||s.get(B)),oe=s.derived(()=>!!d.glow),pe=s.derived(()=>`modal-title-${d.id}`),fe=s.derived(()=>{var e;return(null==(e=s.get(j))?void 0:e.zIndex)??1e3}),me=function(e={x:0,y:0}){const t=s.proxy({...e}),i=s.proxy({isDragging:!1,startX:0,startY:0,initialX:0,initialY:0,hasBeenDragged:!1});return{get position(){return t},get hasBeenDragged(){return i.hasBeenDragged},get isDragging(){return i.isDragging},onPointerDown:function(e,n){if(0===e.button){if(!i.hasBeenDragged){const e=n.getBoundingClientRect();t.x=e.left,t.y=e.top}i.isDragging=!0,i.startX=e.clientX,i.startY=e.clientY,i.initialX=t.x,i.initialY=t.y,n.setPointerCapture(e.pointerId)}},onPointerMove:function(e,n,o){if(!i.isDragging)return;const r=e.clientX-i.startX,d=e.clientY-i.startY,s=b(i.initialX+r,i.initialY+d,o.width,o.height);t.x=s.x,t.y=s.y,i.hasBeenDragged=!0},onPointerUp:function(e,t){i.isDragging&&(i.isDragging=!1,t.releasePointerCapture(e.pointerId))},setPosition:function(e){t.x=e.x,t.y=e.y},setHasBeenDragged:function(e){i.hasBeenDragged=e},reset:function(){t.x=e.x,t.y=e.y,i.hasBeenDragged=!1}}}({x:0,y:0});let ye=s.state(!1);const be=function(e,t,i){let n=s.state(!1),o=s.state(""),r=s.state(s.proxy({width:0,height:0})),a=s.state(!1),l=s.state(!1),c={x:0,y:0,width:0,height:0,posX:0,posY:0},g=null;function u(d,l){d.preventDefault(),d.stopPropagation();const u=e();if(!u)return;const f=u.getBoundingClientRect();me.hasBeenDragged||(i({x:f.left,y:f.top}),me.setHasBeenDragged(!0)),s.get(a)||(s.set(r,{width:f.width,height:f.height},!0),s.set(a,!0));const m=t();s.set(n,!0),s.set(o,l,!0),g=d.pointerId,c={x:d.clientX,y:d.clientY,width:s.get(r).width,height:s.get(r).height,posX:m.x,posY:m.y,centerX:m.x+s.get(r).width/2,centerY:m.y+s.get(r).height/2},window.addEventListener("pointermove",h),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p)}function h(e){if(e.pointerId!==g)return;const t=e.clientX-c.x,n=e.clientY-c.y,d=window.innerWidth,a=window.innerHeight;let l=c.width,u=c.height,h=c.posX,p=c.posY;if(s.get(o).includes("e")){const e=d-h;l=Math.max(280,Math.min(c.width+t,e))}if(s.get(o).includes("w")){const e=c.width-280,i=Math.min(t,e);l=c.width-i,h=c.posX+i}if(s.get(o).includes("s")){const e=a-p;u=Math.max(200,Math.min(c.height+n,e))}if(s.get(o).includes("n")){const e=c.height-200,t=Math.min(n,e);u=c.height-t,p=c.posY+t}const f=_(h,p,l,u);s.set(r,{width:f.width,height:f.height},!0),i({x:f.x,y:f.y})}function p(e){e.pointerId===g&&(s.set(n,!1),g=null,window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),s.set(l,!0),((e,t)=>{const i=de(d.id);if(null==i?void 0:i.parentId){const e=de(i.parentId),n=document.querySelector(`[data-modal-id="${i.parentId}"]`);if(e&&n){const i=e.position??{x:n.getBoundingClientRect().left,y:n.getBoundingClientRect().top},o=e.size??{width:n.offsetWidth,height:n.offsetHeight},r={x:i.x+(o.width-t.width)/2,y:i.y+(o.height-t.height)/2};s.set(ye,!0),me.setPosition(r);const a={x:r.x-i.x,y:r.y-i.y};return Z(d.id,{position:r,size:t,hasBeenDragged:!0,offsetFromParent:a}),void setTimeout(()=>{s.set(ye,!1)},200)}}Z(d.id,{position:e,size:t,hasBeenDragged:!0})})(t(),s.get(r)),setTimeout(()=>{s.set(l,!1)},0))}const f={startResize:u};return{get isResizing(){return s.get(n)},get resizeDirection(){return s.get(o)},get size(){return s.get(r)},get hasBeenResized(){return s.get(a)},get isActive(){return s.get(n)},get justFinishedResizing(){return s.get(l)},start:u,setHasBeenResized:()=>{},setSize:function(e){s.set(r,e,!0),s.set(a,!0)},reset:function(){s.set(a,!1),s.set(r,{width:0,height:0},!0)},constrainToViewport:function(){const n=t(),o=e();if(!o)return;const d=_(n.x,n.y,s.get(r).width||o.offsetWidth,s.get(r).height||o.offsetHeight);s.set(r,{width:d.width,height:d.height},!0),i({x:d.x,y:d.y})},handlers:f}}(()=>s.get(M),()=>me.position,e=>me.setPosition(e)),_e=function(e,t,i,n,o,r,a,l,c){let g=s.state(!1),u=s.state(!1),h=s.state(!1),p=s.state(!1),f=s.state(null),m=s.state(null),v=null,w=null;function y(){w&&(clearTimeout(w),w=null)}function x(){const e=d.id,t=document.querySelector(`.modal-dock-item[data-modal-id="${e}"]`),i=document.querySelector('[data-dock-container="true"]'),n=t||i;if(n){const e=n.getBoundingClientRect();return{x:e.left+e.width/2,y:e.top+e.height/2}}return{x:window.innerWidth/2,y:window.innerHeight-40}}return s.user_effect(()=>()=>{y(),s.set(g,!1),s.set(u,!1),s.set(h,!1),s.set(p,!1),s.set(f,null),s.set(m,null),v=null}),{get isMinimizing(){return s.get(g)},get isRestoring(){return s.get(u)},get isOpening(){return s.get(h)},get isClosing(){return s.get(p)},get animationTransform(){return s.get(f)},get pendingOpenSource(){return s.get(m)},startMinimize:function(e,d){const p=t();if(s.get(g)||!p)return;if(s.set(u,!1),s.set(h,!1),y(),!Ie()){const e=p.getBoundingClientRect();let t=o()?i():{x:e.left,y:e.top},s=a()?l():{width:e.width,height:e.height};return o()||(n(t),r(!0)),void(d?d():c(t,!0,s))}const m=p.getBoundingClientRect(),v=m.left+m.width/2,z=m.top+m.height/2;let I=o()?i():{x:m.left,y:m.top},b=a()?l():{width:m.width,height:m.height};o()||(n(I),r(!0));const _=e??x(),M=_.x-m.left,k=_.y-m.top,D={x:_.x-v,y:_.y-z,originX:M,originY:k};s.set(f,D,!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.set(g,!0)})}),w=setTimeout(()=>{d?d():c(I,!0,b)},500)},startRestore:function(e,t){if(!Ie()){const t=e||{x:window.innerWidth/2,y:window.innerHeight/2};return n(t),void r(!0)}const i=x(),o=e||{x:window.innerWidth/2,y:window.innerHeight/2},d=t||{width:480,height:400};n(o),r(!0);const a=o.x+d.width/2,l=o.y+d.height/2,c=i.x-o.x,g=i.y-o.y;s.set(f,{x:i.x-a,y:i.y-l,originX:c,originY:g},!0),s.set(u,!0),setTimeout(()=>{s.set(u,!1),s.set(f,null)},400)},startClose:function(e){s.get(p)||s.get(g)||(Ie()?(v=e,s.set(p,!0),setTimeout(()=>{s.set(p,!1),v&&(v(),v=null)},250)):e())},setPendingOpenSource:function(e){s.set(m,e,!0)},tryStartOpenAnimation:function(){const e=t();if(!s.get(m)||!e||s.get(h))return!1;if(!Ie())return s.set(m,null),!1;const d=s.get(m);s.set(m,null);const a=e.getBoundingClientRect(),l=o()?i():{x:a.left,y:a.top},c=a.width,g=a.height,u=l.x+c/2,p=l.y+g/2;o()||(n(l),r(!0));const v=d.x-l.x,w=d.y-l.y;return s.set(f,{x:d.x-u,y:d.y-p,originX:v,originY:w},!0),s.set(h,!0),setTimeout(()=>{s.set(h,!1),s.set(f,null)},400),!0},forceClearMinimize:function(){y(),s.set(g,!1),s.set(f,null)}}}(0,()=>s.get(M),()=>me.position,e=>me.setPosition(e),()=>me.hasBeenDragged,e=>me.setHasBeenDragged(e),()=>be.hasBeenResized,()=>be.size,(e,t,i)=>{Z(d.id,{position:e,size:i,hasBeenDragged:t}),V(d.id)}),{trapFocus:De,focusFirstElement:Pe}={trapFocus:Me,focusFirstElement:ke},Ue=s.derived(()=>_e.isMinimizing||_e.isRestoring||_e.isOpening||_e.isClosing),Qe=s.derived(()=>(he(d.id)||ue(d.id))&&!_e.isRestoring);let Je=s.state(!1);const Ze=s.derived(()=>_e.isRestoring||_e.isOpening||s.get(Je)),et=s.derived(()=>s.get(U)&&!me.hasBeenDragged&&!s.get(Ue)&&!_e.pendingOpenSource&&!s.get(Qe)),tt=s.derived(()=>{const e=[];return e.push(`z-index: ${s.get(fe)};`),_e.animationTransform?(e.push(`left: ${me.position.x}px; top: ${me.position.y}px;`),e.push(`--genie-origin-x: ${_e.animationTransform.originX}px;`),e.push(`--genie-origin-y: ${_e.animationTransform.originY}px;`),e.push(`--genie-translate-x: ${_e.animationTransform.x}px;`),e.push(`--genie-translate-y: ${_e.animationTransform.y}px;`)):me.hasBeenDragged&&e.push(`left: ${me.position.x}px; top: ${me.position.y}px; transform: none;`),be.hasBeenResized?e.push(`width: ${be.size.width}px; height: ${be.size.height}px; max-width: none; max-height: none;`):(d.preferredHeight&&e.push(`min-height: ${d.preferredHeight};`),a()&&e.push(`max-width: ${a()};`)),s.get(oe)&&d.glow&&(e.push(`--modal-glow-color: ${d.glow.color};`),e.push(`--modal-glow-intensity: ${d.glow.intensity};`)),e.join(" ")});function it(){s.get(w)&&V(d.id)}function nt(){var e;ce(d.id)&&ge(d.id),ie(d.id),null==(e=d.onClose)||e.call(d)}function ot(){ve(d.id)}function rt(e){s.get(f)&&s.get(M)&&me.onPointerDown(e,s.get(M))}function dt(e){c()&&"Escape"===e.key&&function(e){const t=P.get(e);if(!t)return!1;const i=Math.max(...Array.from(P.values()).map(e=>e.zIndex),0);return t.zIndex===i&&!t.isMinimized&&!t.isHiddenWithParent}(d.id)&&(e.stopPropagation(),nt())}function st(e){if(!s.get(M))return;const t=me.isDragging,i=be.hasBeenResized?be.size:{width:s.get(M).offsetWidth,height:s.get(M).offsetHeight};me.onPointerMove(e,s.get(M),i),me.isDragging&&t&&J(d.id,me.position,{drag:!0})}function at(e){if(!s.get(M))return;const t=me.isDragging;me.onPointerUp(e,s.get(M)),t&&!be.justFinishedResizing&&(J(d.id,me.position,{drag:!0}),function(e){const t=v();if("animated"!==t.parentChild.movementMode)return;const i=t.parentChild.animationDuration,n=[];let o=e;for(;;){const e=P.get(o);if(!(null==e?void 0:e.parentId))break;n.push({parentId:e.parentId,childId:o}),o=e.parentId}n.forEach(({parentId:e,childId:t},n)=>{setTimeout(()=>{const n=P.get(t),o=P.get(e);if(!(null==n?void 0:n.position)||!n.offsetFromParent||!o)return;const r={x:n.position.x-n.offsetFromParent.x,y:n.position.y-n.offsetFromParent.y};Y.set(e,r),function(e){const t=Y.get(e);if(!t)return;const i=P.get(e);i&&(P.set(e,{...i,isAnimatingPosition:!0,position:t}),Y.delete(e),O())}(e),setTimeout(()=>function(e){const t=P.get(e);t&&(P.set(e,{...t,isAnimatingPosition:!1}),O())}(e),i)},n*i)})}(d.id))}function lt(){var e;const t=v();if("smart"!==(null==(e=t.positioning)?void 0:e.strategy))return!1;const i=de(d.id);if(null==i?void 0:i.parentId)return!1;if((null==i?void 0:i.hasBeenDragged)||(null==i?void 0:i.position))return!1;const n=s.get(M)||document.querySelector(`[data-modal-id="${d.id}"]`);if(!n)return!1;const o=n.offsetWidth,r=n.offsetHeight;if(o<=0||r<=0)return!1;const a=t.positioning.modalGap??16,l=function(e){const t=[];for(const[i,n]of P.entries())if(i!==e&&n.isOpen&&!n.isMinimized&&!n.isHiddenWithParent)if(n.position&&n.size)t.push({x:n.position.x,y:n.position.y,width:n.size.width,height:n.size.height});else{const e=document.querySelector(`[data-modal-id="${String(i)}"]`);if(e){const i=e.getBoundingClientRect();t.push({x:i.left,y:i.top,width:i.width,height:i.height})}}return t}(d.id),c=function(e){if("undefined"==typeof document)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}(t.positioning.avoidElements??[]),g=function(e,t,i,n={}){const{modalGap:o=16,gridResolution:r=10,avoidBounds:d=[],avoidMargin:s=16}=n,a=n.margin??o,l="undefined"!=typeof window?window.innerWidth:1920,c="undefined"!=typeof window?window.innerHeight:1080,g=d.map(e=>({x:e.x-s,y:e.y-s,width:e.width+2*s,height:e.height+2*s})),u={x:(l-e)/2,y:(c-t)/2};if(0===i.length&&0===g.length)return u;const h=a,p=Math.max(a,l-e-a),f=a,m=Math.max(a,c-t-a);if(p<=h||m<=f)return u;const v=k(u.x,u.y,e,t,i,o),w=k(u.x,u.y,e,t,g,0);if(0===v&&0===w)return u;const y=[],x=(p-h)/r,z=(m-f)/r;for(let n=0;n<=r;n++)for(let d=0;d<=r;d++){const r=h+n*x,s=f+d*z,u=k(r,s,e,t,i,o),p=k(r,s,e,t,g,0),m=D(r,s,e,t,l,c,a);y.push({pos:{x:r,y:s},modalOverlap:u,avoidOverlap:p,centerDist:m})}const I=y.filter(e=>0===e.avoidOverlap),b=I.length>0?I:y,_=e*t,M=Math.min(...b.map(e=>e.modalOverlap))/_;return b.sort((e,t)=>{if(0===I.length&&e.avoidOverlap!==t.avoidOverlap)return e.avoidOverlap-t.avoidOverlap;const i=e.modalOverlap/_,n=t.modalOverlap/_;if(M<.3){const o=.3,r=i<=o,d=n<=o;if(r&&d)return e.centerDist+.3*i-(t.centerDist+.3*n);if(r)return-1;if(d)return 1}return.6*i+.4*e.centerDist-(.6*n+.4*t.centerDist)}),b[0].pos}(o,r,l,{modalGap:a,avoidBounds:c});if(k(g.x,g.y,o,r,l,a)/(o*r)>.1&&l.length>0){const e=function(e){const t=[];for(const[i,n]of P.entries())if(i!==e&&n.isOpen&&!n.isMinimized&&!n.isHiddenWithParent&&!n.parentId)if(n.position&&n.size)t.push({id:String(i),x:n.position.x,y:n.position.y,width:n.size.width,height:n.size.height});else{const e=document.querySelector(`[data-modal-id="${String(i)}"]`);if(e){const n=e.getBoundingClientRect();t.push({id:String(i),x:n.left,y:n.top,width:n.width,height:n.height})}}return t}(d.id),t=function(e,t,i,n={}){const{modalGap:o=16}=n,r=n.margin??o,d="undefined"!=typeof window?window.innerWidth:1920,s="undefined"!=typeof window?window.innerHeight:1080,a=i.reduce((e,t)=>e+t.width,0)+e,l=i.length*o,c=d-2*r;if(a+l>c)return null;const g=c-a-l;i.length;const u=g/2,h=d/2,p=[...i.map(e=>({id:e.id,width:e.width,height:e.height,currentX:e.x+e.width/2,currentY:e.y,isNew:!1})),{id:"__new__",width:e,height:t,currentX:h,currentY:(s-t)/2,isNew:!0}];p.sort((e,t)=>e.currentX-t.currentX);let f=r+u;const m=new Map;let v=null;for(const e of p){const t=f;if(e.isNew)v={x:Math.round(t),y:Math.round(e.currentY)};else{const n=i.find(t=>t.id===e.id);Math.abs(t-n.x)>5&&m.set(e.id,{x:Math.round(t),y:Math.round(n.y)})}f+=e.width+o}return v?{newModalPosition:v,existingModalMoves:m}:null}(o,r,e,{modalGap:a});if(t&&t.existingModalMoves.size>0)return function(e){const t=v().parentChild.animationDuration;for(const[t,i]of e){const e=P.get(t);e&&P.set(t,{...e,position:i,isAnimatingPosition:!0,hasBeenDragged:!0})}O(),setTimeout(()=>{for(const t of e.keys()){const e=P.get(t);e&&P.set(t,{...e,isAnimatingPosition:!1})}O()},t)}(t.existingModalMoves),me.setPosition(t.newModalPosition),me.setHasBeenDragged(!0),J(d.id,t.newModalPosition,{size:{width:o,height:r}}),!0}return me.setPosition(g),me.setHasBeenDragged(!0),J(d.id,g,{size:{width:o,height:r}}),!0}function ct(){n().then(()=>n()).then(()=>{let e=0;const t=()=>{e+=1,lt()||e>5||requestAnimationFrame(t)};s.get(M)?t():requestAnimationFrame(t)})}e(()=>{var e;function t(){const e=de(d.id);if(!(null==e?void 0:e.position)||!s.get(M))return;if(e.parentId)return;const t=be.hasBeenResized?be.size.width:s.get(M).offsetWidth,i=be.hasBeenResized?be.size.height:s.get(M).offsetHeight;if(t<=0||i<=0)return;const n=b(e.position.x,e.position.y,t,i);(Math.abs(n.x-e.position.x)>1||Math.abs(n.y-e.position.y)>1)&&(me.setPosition(n),J(d.id,n))}return g()||(e=l(),G({id:d.id,title:d.title,icon:d.icon??"",isOpen:e,isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,isRejected:!1,position:null,size:null,hasBeenDragged:!1,dockPosition:0,glow:d.glow??null,parentId:void 0,childId:void 0,offsetFromParent:void 0}),e&&ee(d.id)),l()&&(n().then(()=>{s.get(M)&&Pe(s.get(M))}),ct()),window.addEventListener("pointermove",st),window.addEventListener("pointerup",at),window.addEventListener("resize",t),()=>{window.removeEventListener("pointermove",st),window.removeEventListener("pointerup",at),window.removeEventListener("resize",t)}}),o(()=>{we(d.id),g()||K(d.id)}),s.user_effect(()=>{se();const e=de(d.id);if(e){if(s.set(C,e.isTransparent,!0),!me.isDragging&&!be.isResizing&&e.position){const t=me.position,i=e.position;(Math.abs(t.x-i.x)>.5||Math.abs(t.y-i.y)>.5)&&(me.setPosition(i),e.hasBeenDragged&&me.setHasBeenDragged(!0))}n().then(()=>function(){var e,t;if(!de(d.id))return;if(ce(d.id))return ge(d.id),void(null==(e=d.onClose)||e.call(d));if(re(d.id)&&!s.get(q)){if(s.set(q,!0),s.get($),s.set($,null),s.get(M)){const e=s.get(M).getBoundingClientRect(),t=me.hasBeenDragged?me.position:{x:e.left,y:e.top},i=be.hasBeenResized?be.size:{width:e.width,height:e.height};Z(d.id,{position:t,size:i,hasBeenDragged:!0})}_e.startMinimize(void 0,()=>{var e;e=d.id,s.get(R).includes(e)&&s.set(R,s.get(R).filter(t=>t!==e),!0),s.set(q,!1)})}if(ue(d.id)){t=d.id,s.get(S).includes(t)&&s.set(S,s.get(S).filter(e=>e!==t),!0);const e=de(d.id);_e.startRestore((null==e?void 0:e.position)??void 0,(null==e?void 0:e.size)??void 0),n().then(()=>{s.get(M)&&Pe(s.get(M))})}if(he(d.id)){!function(e){s.get(L).includes(e)&&s.set(L,s.get(L).filter(t=>t!==e),!0)}(d.id);const e=de(d.id);_e.startRestore((null==e?void 0:e.position)??void 0,(null==e?void 0:e.size)??void 0)}if(le(d.id)&&(function(e){s.get(E).includes(e)&&s.set(E,s.get(E).filter(t=>t!==e),!0)}(d.id),_e.startClose(()=>{var e;we(d.id),function(e){const t=P.get(e);if(t){if(t.parentId){const i=P.get(t.parentId);i&&i.childId===e&&P.set(t.parentId,{...i,childId:void 0,lastChildId:e})}P.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}),O()}}(d.id),null==(e=d.onClose)||e.call(d)})),ae(d.id)){!function(e){s.get(T).includes(e)&&s.set(T,s.get(T).filter(t=>t!==e),!0)}(d.id);const e=function(e){const t=F.get(e);return t&&F.delete(e),t??null}(d.id)||d.openSourcePosition||null;e?(_e.setPendingOpenSource(e),n().then(()=>n()).then(()=>{lt(),_e.tryStartOpenAnimation()})):ct(),n().then(()=>{s.get(M)&&Pe(s.get(M))})}(function(e){return s.get(W).includes(e)})(d.id)&&(function(e){s.get(W).includes(e)&&s.set(W,s.get(W).filter(t=>t!==e),!0)}(d.id),function(e){s.get(A).includes(e)||s.set(A,[...s.get(A),e],!0)}(d.id),s.set(N,!0),setTimeout(()=>{s.set(N,!1),function(e){s.set(A,s.get(A).filter(t=>t!==e),!0)}(d.id)},600));const i=function(e){if(!s.get(X)||s.get(X).childId!==e)return null;const t=s.get(X);return s.set(X,null),t}(d.id);var o;i&&s.get(M)&&(o=i.parentId,n().then(()=>n()).then(()=>{let e=0;const t=()=>{e+=1;const i=function(e){var t,i;const n=de(e);if(!n)return!1;const o=s.get(M)||document.querySelector(`[data-modal-id="${d.id}"]`),r=document.querySelector(`[data-modal-id="${e}"]`),a=null==r?void 0:r.getBoundingClientRect(),l=n.position??(a?{x:a.left,y:a.top}:null);if(!l||!o)return!1;const c=(null==(t=n.size)?void 0:t.width)??(null==r?void 0:r.offsetWidth)??(null==a?void 0:a.width)??480,g=(null==(i=n.size)?void 0:i.height)??(null==r?void 0:r.offsetHeight)??(null==a?void 0:a.height)??400,u=o.offsetWidth,h=o.offsetHeight;if(c<=0||g<=0||u<=0||h<=0)return!1;const p={x:l.x+(c-u)/2,y:l.y+(g-h)/2};return me.setPosition(p),me.setHasBeenDragged(!0),J(d.id,p,{size:{width:u,height:h}}),n.position&&n.size||!a||J(e,{x:a.left,y:a.top},{size:{width:c,height:g}}),function(e,t){if(!v().features.parentChild)return;const i=P.get(e),n=P.get(t);if(!i||!n)return;let o={x:40,y:40};i.position&&n.position&&(o={x:n.position.x-i.position.x,y:n.position.y-i.position.y});const r=Math.max(n.zIndex,i.zIndex+1);P.set(e,{...i,childId:t,lastChildId:t}),P.set(t,{...n,parentId:e,offsetFromParent:o,zIndex:r}),O()}(e,d.id),!0}(o);i||e>5||requestAnimationFrame(t)};s.get(M)?t():requestAnimationFrame(t)}))}())}}),s.user_effect(()=>{const e=de(d.id);e&&e.isTransparent!==s.get(C)&&s.set(C,e.isTransparent,!0)}),s.user_effect(()=>{if(s.get(U)&&s.get(M)){const e=e=>function(e){s.get(M)&&De(e,s.get(M))}(e);return s.get(M).addEventListener("keydown",e),()=>{var t;return null==(t=s.get(M))?void 0:t.removeEventListener("keydown",e)}}}),s.user_effect(()=>{!s.get(U)&&_e.isMinimizing&&_e.forceClearMinimize()}),s.user_effect(()=>{_e.isRestoring||_e.isOpening?s.set(Je,!0):s.get(Je)&&requestAnimationFrame(()=>{s.set(Je,!1)})}),s.user_effect(()=>{s.get(H)&&!s.get(Q)&&(s.set(B,!0),setTimeout(()=>{s.set(B,!1)},200)),s.set(H,s.get(Q),!0)});var gt=s.comment(),ut=s.first_child(gt),ht=e=>{Ce(e,{get target(){return u},children:(e,i)=>{var n=Ve();let o;n.__keydown=dt;var r=s.child(n);{let e=s.derived(()=>s.get(f)?rt:void 0);!function(e,i){s.push(i,!0);let n=s.prop(i,"isTransparent",3,!1),o=s.prop(i,"headerLayout",3,"macos"),r=s.prop(i,"minimizable",3,!0),d=s.prop(i,"minimizeDisabled",3,!1),a=s.prop(i,"transparencyEnabled",3,!0);const l=t(xe),c=s.derived(()=>null==l?void 0:l()),g=s.derived(()=>"macos"===o());var u=qe();let h;u.__pointerdown=function(e){var t;e.target.closest("button")||null==(t=i.onStartDrag)||t.call(i,e)};var p=s.child(u),f=e=>{var t=Se(),n=s.first_child(t),o=s.child(n);o.__click=function(...e){var t;null==(t=i.onClose)||t.apply(this,e)};var l=s.sibling(o,2),g=e=>{var t=Be();let n;t.__click=function(...e){var t;null==(t=d()?void 0:i.onMinimize)||t.apply(this,e)},s.template_effect(()=>{n=s.set_class(t,1,"modal-header-light modal-header-light-minimize",null,n,{"modal-header-light-disabled":d()}),t.disabled=d(),s.set_attribute(t,"title",d()?"Enable dock to minimize":void 0)}),s.append(e,t)};s.if(l,e=>{r()&&e(g)});var u=s.sibling(l,2),h=e=>{var t=Oe();t.__click=function(...e){var t;null==(t=i.onToggleStyle)||t.apply(this,e)},s.append(e,t)};s.if(u,e=>{a()&&e(h)}),s.reset(n);var p=s.sibling(n,2),f=s.child(p),m=e=>{var t=Re(),n=s.child(t);s.snippet(n,()=>i.customIcon),s.reset(t),s.append(e,t)},v=e=>{var t=s.comment(),n=s.first_child(t),o=e=>{var t=Te(),n=s.child(t);s.snippet(n,()=>s.get(c),()=>i.icon),s.reset(t),s.append(e,t)};s.if(n,e=>{i.icon&&s.get(c)&&e(o)},!0),s.append(e,t)};s.if(f,e=>{i.customIcon?e(m):e(v,!1)});var w=s.sibling(f,2),y=s.child(w),x=e=>{var t=Ee(),n=s.child(t,!0);s.reset(t),s.template_effect(()=>{s.set_attribute(t,"id",i.titleId),s.set_text(n,i.title)}),s.append(e,t)},z=e=>{var t=He(),n=s.child(t,!0);s.reset(t),s.template_effect(()=>s.set_text(n,i.title)),s.append(e,t)};s.if(y,e=>{i.titleId?e(x):e(z,!1)}),s.reset(w),s.reset(p),s.next(2),s.append(e,t)},m=e=>{var t=Ye(),n=s.first_child(t),o=s.child(n),l=e=>{var t=Le(),n=s.child(t);s.snippet(n,()=>i.customIcon),s.reset(t),s.append(e,t)},g=e=>{var t=s.comment(),n=s.first_child(t),o=e=>{var t=We(),n=s.child(t);s.snippet(n,()=>s.get(c),()=>i.icon),s.reset(t),s.append(e,t)};s.if(n,e=>{i.icon&&s.get(c)&&e(o)},!0),s.append(e,t)};s.if(o,e=>{i.customIcon?e(l):e(g,!1)});var u=s.sibling(o,2),h=e=>{var t=Ae(),n=s.child(t,!0);s.reset(t),s.template_effect(()=>{s.set_attribute(t,"id",i.titleId),s.set_text(n,i.title)}),s.append(e,t)},p=e=>{var t=$e(),n=s.child(t,!0);s.reset(t),s.template_effect(()=>s.set_text(n,i.title)),s.append(e,t)};s.if(u,e=>{i.titleId?e(h):e(p,!1)}),s.reset(n);var f=s.sibling(n,2),m=s.child(f),v=e=>{var t=Fe();t.__click=function(...e){var t;null==(t=i.onToggleStyle)||t.apply(this,e)},s.append(e,t)};s.if(m,e=>{a()&&e(v)});var w=s.sibling(m,2),y=e=>{var t=Xe();let n;t.__click=function(...e){var t;null==(t=d()?void 0:i.onMinimize)||t.apply(this,e)},s.template_effect(()=>{n=s.set_class(t,1,"modal-header-btn-windows",null,n,{"modal-header-btn-windows-disabled":d()}),t.disabled=d(),s.set_attribute(t,"title",d()?"Enable dock to minimize":void 0)}),s.append(e,t)};s.if(w,e=>{r()&&e(y)}),s.sibling(w,2).__click=function(...e){var t;null==(t=i.onClose)||t.apply(this,e)},s.reset(f),s.append(e,t)};s.if(p,e=>{s.get(g)?e(f):e(m,!1)}),s.reset(u),s.template_effect(()=>h=s.set_class(u,1,"modal-header",null,h,{"modal-header-draggable":!!i.onStartDrag,transparent:n()})),s.append(e,u),s.pop()}(r,{get title(){return d.title},get customIcon(){return d.customIcon},get icon(){return d.icon},get isTransparent(){return s.get(C)},get titleId(){return s.get(pe)},get headerLayout(){return s.get(I)},get onStartDrag(){return s.get(e)},onToggleStyle:ot,onMinimize:it,onClose:nt,get minimizable(){return s.get(w)},get minimizeDisabled(){return s.get(y)},get transparencyEnabled(){return s.get(x)}})}var a=s.sibling(r,2),l=s.child(a);s.snippet(l,()=>d.children??s.noop),s.reset(a);var c=s.sibling(a,2),g=e=>{var t=Ge(),i=s.child(t);s.snippet(i,()=>d.footer),s.reset(t),s.append(e,t)};s.if(c,e=>{d.footer&&e(g)});var u=s.sibling(c,2);{let e=s.derived(()=>s.get(z)&&!s.get(Q)?be.handlers.startResize:void 0);!function(e,t){s.push(t,!0);const i=["n","s","e","w","ne","nw","se","sw"];var n=s.comment(),o=s.first_child(n),r=e=>{var n=je();s.each(n,21,()=>i,s.index,(e,i)=>{var n=Ne();n.__pointerdown=e=>function(e,i){var n;null==(n=t.onStartResize)||n.call(t,e,i)}(e,s.get(i)),s.template_effect(()=>s.set_class(n,1,`modal-resize-handle modal-resize-${s.get(i)??""}`)),s.append(e,n)}),s.reset(n),s.append(e,n)};s.if(o,e=>{t.onStartResize&&e(r)}),s.append(e,n),s.pop()}(u,{get onStartResize(){return s.get(e)}})}var h=s.sibling(u,2),p=e=>{var t=Ke();let i;s.template_effect(()=>i=s.set_class(t,1,"modal-child-overlay",null,i,{"modal-overlay-closing":s.get(B)})),s.append(e,t)};s.if(h,e=>{s.get(ne)&&e(p)}),s.reset(n),s.bind_this(n,e=>s.set(M,e),()=>s.get(M)),s.template_effect(()=>{var e;o=s.set_class(n,1,"modal-dialog",null,o,{"modal-dragging":me.isDragging,"modal-resizing":be.isResizing,"modal-positioned":me.hasBeenDragged,"modal-minimizing":_e.isMinimizing,"modal-restoring":_e.isRestoring,"modal-opening":_e.isOpening,"modal-closing":_e.isClosing,"modal-centered":s.get(et),"modal-solid":!s.get(C),"modal-transparent":s.get(C),"modal-glow":s.get(oe),"modal-has-child":s.get(Q),"modal-is-child":s.get(te),"modal-visible-by-animation":s.get(Ze),"modal-animating-to-center":s.get(ye),"modal-animating-position":null==(e=s.get(j))?void 0:e.isAnimatingPosition,"modal-attention":s.get(N)}),s.set_attribute(n,"data-modal-id",d.id),s.set_style(n,s.get(tt)),s.set_attribute(n,"aria-labelledby",s.get(pe))}),s.event("pointerdown",n,()=>ee(d.id),!0),s.append(e,n)},$$slots:{default:!0}})};s.if(ut,e=>{s.get(U)&&e(ht)}),s.append(r,gt),s.pop()}(r,{get id(){return d.id},get title(){return d.title},get icon(){return d.icon},get customIcon(){return d.customIcon},get maxWidth(){return a()},get preferredHeight(){return d.preferredHeight},get autoOpen(){return l()},get openSourcePosition(){return d.openSourcePosition},get glow(){return d.glow},get config(){return d.config},get closeOnEscape(){return c()},get onClose(){return d.onClose},get children(){return d.children},get footer(){return d.footer},skipRegistration:!0})};s.if(f,e=>{s.get(u)&&e(w)}),s.append(r,h),s.pop()}s.delegate(["keydown"]);var Qe=s.from_html('<button type="button" aria-label="Drag dock"></button>'),Je=s.from_html('<span class="modal-dock-item-icon-placeholder"> </span>'),Ze=s.from_html('<span class="modal-dock-item-label"> </span>'),et=s.from_html("<span>+</span>"),tt=s.from_html('<span class="modal-dock-child-indicator"><!></span>'),it=s.from_html('<button><span class="modal-dock-item-icon"><!></span> <!> <span class="modal-dock-item-glow"></span> <!></button>'),nt=s.from_html('<div data-dock-container="true"><div><!> <!></div></div>');function ot(e,i){s.push(i,!0);const n=t(xe),o=s.derived(()=>i.renderIcon??(null==n?void 0:n())),r=me(),d=s.derived(()=>(m(),v())),c=s.derived(()=>z("DOCK")),h=s.derived(()=>s.get(d).dock.position),p=s.derived(()=>s.get(d).dock.labelMode);let f=s.state("horizontal"),w=s.state(s.proxy({x:100,y:100})),y=s.state(null),x=s.state(!1),I={x:0,y:0},_=null;const M=s.derived(()=>(se(),Array.from(r.modals.values()).filter(e=>e.isMinimized).sort((e,t)=>e.dockPosition-t.dockPosition))),k=s.derived(()=>{switch(s.get(h)){case"left":return{x:-20,duration:250,easing:g};case"right":return{x:20,duration:250,easing:g};default:return{y:20,duration:250,easing:g}}});function D(e){var t;"free"===s.get(h)&&(s.set(x,!0),_=e.pointerId,I={x:e.clientX-s.get(w).x,y:e.clientY-s.get(w).y},null==(t=e.currentTarget)||t.setPointerCapture(e.pointerId),window.addEventListener("pointermove",P),window.addEventListener("pointerup",C),window.addEventListener("pointercancel",C))}function P(e){if(e.pointerId!==_||!s.get(y))return;const t=s.get(y).getBoundingClientRect(),i=window.innerWidth-t.width-8,n=window.innerHeight-t.height-8,o=Math.min(Math.max(e.clientX-I.x,8),Math.max(8,i)),r=Math.min(Math.max(e.clientY-I.y,8),Math.max(8,n));s.set(w,{x:Math.round(o),y:Math.round(r)},!0)}function C(e){e.pointerId===_&&(s.set(x,!1),_=null,window.removeEventListener("pointermove",P),window.removeEventListener("pointerup",C),window.removeEventListener("pointercancel",C))}const{addListener:B}=function(){function e(e,t,i){return"undefined"==typeof window?()=>{}:(window.addEventListener(e,t,i),()=>{window.removeEventListener(e,t,i)})}return{addListener:e,addListenerEffect:function(t,i,n){s.user_effect(()=>{if("undefined"!=typeof window)return e(t,i,n)})}}}();function O(){if("free"!==s.get(h)||!s.get(y))return;const e=s.get(y).getBoundingClientRect(),t=b(s.get(w).x,s.get(w).y,e.width,e.height);t.x===s.get(w).x&&t.y===s.get(w).y||s.set(w,{x:Math.round(t.x),y:Math.round(t.y)},!0)}s.user_effect(()=>{"undefined"!=typeof window&&B("resize",O)});var R={setDockOrientation:function(e){s.set(f,e,!0)},setDockFreePosition:function(e){s.set(w,e,!0)},getDockState:function(){return{dockPosition:s.get(h),dockOrientation:s.get(f),dockFreePosition:s.get(w),dockLabelMode:s.get(p)}}};return Ce(e,{get target(){return s.get(d).portalTarget},children:(e,t)=>{var i=nt();let n,d;var g=s.child(i);let m;var v=s.child(g),z=e=>{var t=Qe();let i;t.__pointerdown=D,s.template_effect(()=>i=s.set_class(t,1,"modal-dock-handle",null,i,{"modal-dock-handle-dragging":s.get(x)})),s.append(e,t)};s.if(v,e=>{"free"===s.get(h)&&e(z)});var I=s.sibling(v,2);s.each(I,19,()=>s.get(M),e=>e.id,(e,t,i)=>{const n=s.derived(()=>s.get(t).lastChildId?r.modals.get(s.get(t).lastChildId):null);var d=it();let l;d.__click=e=>{var i;i=s.get(t).id,q.has(i)?e.currentTarget.animate([{transform:"translateX(0)"},{transform:"translateX(-6px)"},{transform:"translateX(6px)"},{transform:"translateX(-6px)"},{transform:"translateX(6px)"},{transform:"translateX(0)"}],{duration:300,easing:"ease-in-out"}):U(s.get(t).id)};var c=s.child(d),g=s.child(c),h=e=>{var i=s.comment(),n=s.first_child(i);s.snippet(n,()=>s.get(o),()=>s.get(t).icon),s.append(e,i)},f=e=>{var i=Je(),n=s.child(i,!0);s.reset(i),s.template_effect(e=>s.set_text(n,e),[()=>s.get(t).title.charAt(0)]),s.append(e,i)};s.if(g,e=>{s.get(t).icon&&s.get(o)?e(h):e(f,!1)}),s.reset(c);var m=s.sibling(c,2),v=e=>{var i=Ze(),n=s.child(i,!0);s.reset(i),s.template_effect(()=>s.set_text(n,s.get(t).title)),s.append(e,i)};s.if(m,e=>{"hidden"!==s.get(p)&&e(v)});var w=s.sibling(m,4),y=e=>{var t=tt(),i=s.child(t),r=e=>{var t=s.comment(),i=s.first_child(t);s.snippet(i,()=>s.get(o),()=>s.get(n).icon),s.append(e,t)},d=e=>{var t=et();s.append(e,t)};s.if(i,e=>{s.get(n).icon&&s.get(o)?e(r):e(d,!1)}),s.reset(t),s.append(e,t)};s.if(w,e=>{s.get(t).lastChildId&&s.get(n)&&e(y)}),s.reset(d),s.template_effect(()=>{l=s.set_class(d,1,"modal-dock-item",null,l,{"modal-dock-item-has-glow":!!s.get(t).glow,"modal-dock-item-has-child":!!s.get(t).lastChildId,"modal-dock-item-label-beside":"beside"===s.get(p),"modal-dock-item-label-below":"below"===s.get(p)}),s.set_attribute(d,"data-modal-id",s.get(t).id),s.set_style(d,s.get(t).glow?`--modal-dock-glow-color: ${s.get(t).glow.color};`:"")}),s.transition(3,d,()=>a,()=>({duration:300,delay:50*s.get(i),easing:u,start:.5})),s.append(e,d)}),s.reset(g),s.reset(i),s.bind_this(i,e=>s.set(y,e),()=>s.get(y)),s.template_effect(()=>{n=s.set_class(i,1,"modal-dock-container",null,n,{"modal-dock-left":"left"===s.get(h),"modal-dock-right":"right"===s.get(h),"modal-dock-bottom":"bottom"===s.get(h),"modal-dock-free":"free"===s.get(h),"modal-dock-empty":0===s.get(M).length}),d=s.set_style(i,"free"===s.get(h)?`left: ${s.get(w).x}px; top: ${s.get(w).y}px;`:"",d,{"z-index":s.get(c)}),m=s.set_class(g,1,"modal-dock",null,m,{"modal-dock-free-horizontal":"free"===s.get(h)&&"horizontal"===s.get(f),"modal-dock-free-vertical":"free"===s.get(h)&&"vertical"===s.get(f)})}),s.transition(3,i,()=>l,()=>s.get(M).length>0?s.get(k):{duration:0}),s.append(e,i)},$$slots:{default:!0}}),s.pop(R)}s.delegate(["pointerdown","click"]);var rt=s.from_html('<div class="modal-backdrop svelte-1d3nq4t" aria-hidden="true"></div>');function dt(e,t){s.push(t,!0);const i=me(),n=s.derived(()=>(m(),v())),o=s.derived(()=>s.get(n).features.backdrop),r=s.derived(()=>(se(),Array.from(i.modals.values()).some(e=>e.isOpen&&!e.isMinimized&&!e.isHiddenWithParent))),d=s.derived(()=>s.get(o)&&s.get(r)),a=s.derived(()=>z("MODAL")-1);Ce(e,{get target(){return s.get(n).portalTarget},children:(e,t)=>{var i=s.comment(),n=s.first_child(i),o=e=>{var t=rt();let i;s.template_effect(()=>i=s.set_style(t,"",i,{"z-index":s.get(a)})),s.transition(3,t,()=>c,()=>({duration:200})),s.append(e,t)};s.if(n,e=>{s.get(d)&&e(o)}),s.append(e,i)},$$slots:{default:!0}}),s.pop()}function st(e){const{content:t,footer:i,icon:n,...o}=e,s=r(Ue,{target:document.body,props:{...o,children:t?()=>lt(t):void 0,footer:i?()=>lt(i):void 0,icon:n?()=>lt(n):void 0}});return{destroy:()=>d(s)}}function at(){const e=r(ot,{target:document.body,props:{}});return{destroy:()=>d(e)}}function lt(e){if("string"==typeof e){const t=document.createElement("div");return t.innerHTML=e,t}return e}function ct(){const e=r(dt,{target:document.body,props:{}});return{destroy:()=>d(e)}}function gt(e={}){const{config:t}=e;t&&w(t),s.set(x,v().zIndex.base,!0);const i=v(),n=e.backdrop??i.features.backdrop?ct():null,o=e.dock??i.features.dock?at():null;return{backdrop:n,dock:o,destroy:()=>{null==n||n.destroy(),null==o||o.destroy()}}}export{ee as bringToFront,ne as closeAllModals,ie as closeModal,ct as createBackdrop,at as createDock,st as createModal,v as getConfig,gt as init,pe as isModalOpen,fe as isModalRegistered,V as minimizeModal,oe as openChildModal,te as openModal,U as restoreModal,w as setConfig,ve as toggleModalTransparency};
|
|
1
|
+
import{onMount as e,getContext as t,setContext as i,tick as n,onDestroy as o,mount as r,unmount as d}from"svelte";import"svelte/internal/disclose-version";import*as s from"svelte/internal/client";import{scale as a,fly as l,fade as c}from"svelte/transition";import{cubicOut as g,backOut as u}from"svelte/easing";const h={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},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 p={...h},f=s.state(0);function m(){return s.get(f)}function v(){return p}function y(e){const t=p;var i,n;p={features:{...(i=h).features,...(n=e).features},dock:{...i.dock,...n.dock},animations:{...i.animations,...n.animations},appearance:{...i.appearance,...n.appearance},zIndex:{...i.zIndex,...n.zIndex},parentChild:{...i.parentChild,...n.parentChild},positioning:{...i.positioning,...n.positioning},portalTarget:n.portalTarget??i.portalTarget},s.update(f),t.features.dock&&!p.features.dock&&(Array.from(C.values()).filter(e=>e.isMinimized).map(e=>e.id).forEach(e=>{const t=C.get(e);if(t){C.set(e,{...t,isMinimized:!1,isOpen:!0}),s.set(L,[...s.get(L),e],!0),te(e);const i=t.lastChildId||t.childId;i&&J(i)}}),s.set(G,[],!0),T())}const w={BASE:0,DROPDOWN:100,STICKY:200,OVERLAY:300,MODAL:400,DOCK:8e3,TOAST:9e3};let x=s.state(s.proxy(w.MODAL));function z(e){const t=v();return"MODAL"===e?t.zIndex.base:"DOCK"===e?t.zIndex.dock:"TOAST"===e?t.zIndex.toast:w[e]}const I=8;function b(e,t,i,n,o={}){const{margin:r=I,allowPartialVisibility:d=!1}=o,s="undefined"!=typeof window?window.innerWidth:1920,a="undefined"!=typeof window?window.innerHeight:1080;let l,c,g,u;return d&&i>s-2*r?(l=40-i,c=s-40):(l=r,c=Math.max(r,s-i-r)),d&&n>a-2*r?(g=40-n,u=a-40):(g=r,u=Math.max(r,a-n-r)),{x:Math.max(l,Math.min(c,e)),y:Math.max(g,Math.min(u,t))}}function _(e,t,i,n,o={}){const{margin:r=I}=o,d=("undefined"!=typeof window?window.innerWidth:1920)-2*r,s=("undefined"!=typeof window?window.innerHeight:1080)-2*r,a=Math.min(i,d),l=Math.min(n,s),c=b(e,t,a,l,o);return{x:c.x,y:c.y,width:a,height:l}}function M(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 k(e,t,i,n,o,r){const d={x:e-r,y:t-r,width:i+2*r,height:n+2*r};let s=0;for(const e of o)s+=M(d,e);return s}function D(e,t,i,n,o,r,d){const s=(o-i)/2,a=(r-n)/2,l=s-d,c=a-d,g=Math.abs(e-s)/(l||1),u=Math.abs(t-a)/(c||1),h=Math.sqrt(g*g+u*u)/Math.SQRT2,p=50,f=e-d,m=o-i-d-e,v=t-d,y=r-n-d-t;let w=0;return f<p&&(w+=.3*(1-f/p)),m<p&&(w+=.3*(1-m/p)),v<p&&(w+=.2*(1-v/p)),y<p&&(w+=.2*(1-y/p)),Math.min(1,h+w)}function P(e){return"symbol"==typeof e?e.description??"symbol":e}let C=s.proxy(new Map),B=s.state(0);const O=new Set;function T(){s.update(B),queueMicrotask(()=>{O.forEach(e=>e())})}let R=s.state(s.proxy([])),E=s.state(s.proxy([])),H=s.state(s.proxy([])),S=s.state(s.proxy([])),L=s.state(s.proxy([])),W=s.state(s.proxy([])),A=s.state(s.proxy([])),$=s.state(s.proxy([])),F=s.state(null),X=s.proxy(new Map),Y=s.state(null),q=s.proxy(new Map),N=s.proxy(new Set),j=s.proxy(new Set),G=s.state(s.proxy([]));function K(e){const t=C.get(e.id),i=(null==t?void 0:t.zIndex)??function(){const e=s.get(x);return s.set(x,s.get(x)+2),e}();t?C.set(e.id,{...t,title:e.title,icon:e.icon,glow:e.glow,zIndex:i}):C.set(e.id,{...e,zIndex:i,isAnimating:!1}),T(),e.isMinimized&&!s.get(G).includes(e.id)&&s.get(G).push(e.id)}function V(e){const t=C.get(e);if(t){if(s.set(G,s.get(G).filter(t=>t!==e),!0),t.childId){const e=C.get(t.childId);e&&C.set(t.childId,{...e,parentId:void 0})}if(t.parentId){const e=C.get(t.parentId);e&&C.set(t.parentId,{...e,childId:void 0,lastChildId:t.id})}C.delete(e),T(),j.delete(e),N.delete(e)}}function U(e){const t=C.get(e);if(!t||t.isMinimized)return;if(xe(e),t.parentId){const e=C.get(t.parentId);if(e&&!e.isMinimized)return void U(t.parentId)}s.set(R,[...s.get(R),e],!0),t.position&&t.size;const i=t.childId;C.set(e,{...t,isMinimized:!0,lastChildId:i}),T(),s.get(G).includes(e)||s.get(G).push(e),t.childId&&function(e){const t=C.get(e);if(!(null==t?void 0:t.childId))return;const i=C.get(t.childId);i&&(C.set(t.childId,{...i,isHiddenWithParent:!0}),T())}(e)}function Q(e){const t=C.get(e);if(!t||!t.isMinimized)return;C.set(e,{...t,isMinimized:!1,isOpen:!0}),T(),s.set(L,[...s.get(L),e],!0),te(e);const i=t.lastChildId||t.childId;i&&J(i)}function J(e){const t=C.get(e);t&&t.isHiddenWithParent&&(C.set(e,{...t,isHiddenWithParent:!1}),T(),s.set(W,[...s.get(W),e],!0))}function Z(e,t,i){const n=C.get(e);if(!n)return;let o=t;if((null==i?void 0:i.constrain)&&n.size&&(o=b(t.x,t.y,n.size.width,n.size.height)),C.set(e,{...n,position:o,size:(null==i?void 0:i.size)??n.size,hasBeenDragged:n.hasBeenDragged||(null==i?void 0:i.drag)||!1}),n.childId){let t=e,i=o;for(;;){const e=C.get(t);if(!(null==e?void 0:e.childId))break;const n=C.get(e.childId);if(!(null==n?void 0:n.offsetFromParent))break;const o={x:i.x+n.offsetFromParent.x,y:i.y+n.offsetFromParent.y};C.set(e.childId,{...n,position:o,hasBeenDragged:!0}),t=e.childId,i=o}}if(n.parentId&&n.offsetFromParent){const t=v();let i=e,r=n;for(;r.parentId&&r.offsetFromParent;){const n=C.get(r.parentId);if(!n)break;const d=i===e?o:C.get(i).position,s={x:d.x-r.offsetFromParent.x,y:d.y-r.offsetFromParent.y};"animated"===t.parentChild.movementMode?q.set(r.parentId,s):C.set(r.parentId,{...n,position:s,hasBeenDragged:!0}),i=r.parentId,r=n}}T()}function ee(e,t){const i=C.get(e);i&&(C.set(e,{...i,...t}),T())}function te(e){var t;const i=C.get(e);if(!i)return;const n=Math.max(...Array.from(C.values()).map(e=>e.zIndex),0);if(i.parentId){const o=C.get(i.parentId);o&&o.zIndex<n&&C.set(i.parentId,{...o,zIndex:n+2});const r=(null==(t=C.get(i.parentId))?void 0:t.zIndex)??n+2;return i.zIndex<=r&&C.set(e,{...i,zIndex:r+2}),void T()}if(i.zIndex<n&&(C.set(e,{...i,zIndex:n+2}),T()),i.childId){const t=C.get(i.childId),n=C.get(e);t&&n&&t.zIndex<=n.zIndex&&(C.set(i.childId,{...t,zIndex:n.zIndex+2}),T())}}function ie(e,t,i){const n=t.getBoundingClientRect();X.set(e,{x:n.left+n.width/2,y:n.top+n.height/2});const o=v();(null==i?void 0:i.parentId)&&o.features.parentChild&&s.set(Y,{parentId:i.parentId,childId:e},!0),s.get(E).includes(e)||s.set(E,[...s.get(E),e],!0),T();const r=C.get(e);if(r){if(r.isOpen&&!r.isMinimized&&!r.isHiddenWithParent)return s.set(E,s.get(E).filter(t=>t!==e),!0),function(e){C.get(e)&&(s.get(A).includes(e)||s.get($).includes(e)||(s.set(A,[...s.get(A),e],!0),T()))}(e),void te(e);if(r.isMinimized)return s.set(E,s.get(E).filter(t=>t!==e),!0),void Q(e);C.set(e,{...r,isOpen:!0}),te(e)}}function ne(e,t=!1){const i=C.get(e);i&&(xe(e),t?s.set(S,[...s.get(S),e],!0):s.set(H,[...s.get(H),e],!0),T(),i.childId&&ne(i.childId,t))}function oe(){Array.from(C.keys()).forEach(e=>ne(e,!0))}function re(e,t,i){const n=v();if(i&&!X.has(e.id)){const t=i.getBoundingClientRect();X.set(e.id,{x:t.left+t.width/2,y:t.top+t.height/2})}const o={id:e.id,title:e.title??"",icon:e.icon??"",isOpen:!0,isMinimized:!1,isHiddenWithParent:!1,isTransparent:e.isTransparent??!1,isRejected:!1,position:e.position??null,size:e.size??null,hasBeenDragged:e.hasBeenDragged??!1,dockPosition:e.dockPosition??-1,glow:e.glow??null};if(!n.features.parentChild){K(o);const t=C.get(e.id);return t&&C.set(e.id,{...t,isOpen:!0}),s.set(E,[...s.get(E),e.id],!0),T(),void te(e.id)}const r=C.get(t);if(!r)return;r.childId&&ne(r.childId,!0),K({...o,parentId:t});const d=C.get(e.id);d&&C.set(e.id,{...d,isOpen:!0,parentId:t}),s.set(E,[...s.get(E),e.id],!0),T(),te(e.id),s.set(Y,{parentId:t,childId:e.id},!0)}function de(e){return s.get(R).includes(e)}function se(e){return C.get(e)}function ae(){return s.get(B)}function le(e){return s.get(E).includes(e)}function ce(e){return s.get(H).includes(e)}function ge(e){return s.get(S).includes(e)}function ue(e){return!!s.get(S).includes(e)&&(s.set(S,s.get(S).filter(t=>t!==e),!0),!0)}function he(e){return s.get(L).includes(e)}function pe(e){return s.get(W).includes(e)}function fe(e){const t=C.get(e);return void 0!==t&&t.isOpen&&!t.isMinimized&&!t.isHiddenWithParent}function me(e){return C.has(e)}function ve(){return{get modals(){return C},get pendingMinimize(){return s.get(R)},get pendingOpen(){return s.get(E)},get pendingClose(){return s.get(H)},get pendingRestore(){return s.get(L)},get dockOrder(){return s.get(G)}}}function ye(e){j.has(e)?j.delete(e):j.add(e);const t=C.get(e);t&&(C.set(e,{...t,isTransparent:j.has(e)}),T())}function we(e){j.delete(e);const t=C.get(e);t&&(C.set(e,{...t,isTransparent:!1}),T())}function xe(e){q.delete(e)}const ze=Symbol("modal-render-icon"),Ie=Symbol("modal-id");function be(){return v().features.animations}const _e=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function Me(e){return Array.from(e.querySelectorAll(_e)).filter(e=>null!==e.offsetParent||"A"===e.tagName)}function ke(e,t){if("Tab"!==e.key)return;const i=Me(t);if(0===i.length)return void e.preventDefault();const n=i[0],o=i[i.length-1],r=document.activeElement;e.shiftKey?r===n&&(o.focus(),e.preventDefault()):r===o&&(n.focus(),e.preventDefault())}function De(e){const t=Me(e);return t.length>0&&(t[0].focus(),!0)}const Pe="modal-portal";var Ce=s.from_html('<div style="display: contents;"><!></div>');function Be(t,i){s.push(i,!0);let n=s.prop(i,"target",3,"body"),o=null,r=null;const{mount:d}={mount:function(e,t=null){const i=function(e){if("undefined"==typeof window)return null;if(e instanceof HTMLElement)return e;if("string"==typeof e){const t=document.querySelector(e);if(t)return t;if(e.startsWith("#")){const t=e.slice(1),i=document.createElement("div");return i.id=t,document.body.appendChild(i),i}}let t=document.getElementById(Pe);return t||(t=document.createElement("div"),t.id=Pe,document.body.appendChild(t)),t}(t);return i?(i.appendChild(e),()=>{e.parentNode===i&&i.removeChild(e),i.id!==Pe&&0===i.children.length&&i.parentNode&&i.parentNode.removeChild(i)}):()=>{}}};e(()=>(o&&(r=d(o,n())),()=>{null==r||r()}));var a=Ce(),l=s.child(a);s.snippet(l,()=>i.children),s.reset(a),s.bind_this(a,e=>o=e,()=>o),s.append(t,a),s.pop()}var Oe=s.from_html('<button type="button" aria-label="Minimize"></button>'),Te=s.from_html('<button type="button" class="modal-header-light modal-header-light-style" aria-label="Toggle style"></button>'),Re=s.from_html('<div class="modal-header-icon"><!></div>'),Ee=s.from_html('<div class="modal-header-icon"><!></div>'),He=s.from_html('<h2 class="modal-header-title"> </h2>'),Se=s.from_html('<h2 class="modal-header-title"> </h2>'),Le=s.from_html('<div class="modal-header-traffic-lights"><button type="button" class="modal-header-light modal-header-light-close" aria-label="Close"></button> <!> <!></div> <div class="modal-header-mac-center"><!> <div class="modal-header-title-group"><!></div></div> <div class="modal-header-mac-spacer"></div>',1),We=s.from_html('<div class="modal-header-icon"><!></div>'),Ae=s.from_html('<div class="modal-header-icon"><!></div>'),$e=s.from_html('<h2 class="modal-header-title"> </h2>'),Fe=s.from_html('<h2 class="modal-header-title"> </h2>'),Xe=s.from_html('<button type="button" class="modal-header-btn-windows modal-header-btn-windows-style" aria-label="Toggle style">◇</button>'),Ye=s.from_html('<button type="button" aria-label="Minimize">–</button>'),qe=s.from_html('<div class="modal-header-title-group"><!> <!></div> <div class="modal-header-actions"><!> <!> <button type="button" class="modal-header-btn-windows modal-header-btn-windows-close" aria-label="Close">×</button></div>',1),Ne=s.from_html("<header><!></header>");s.delegate(["pointerdown","click"]);var je=s.from_html("<div></div>"),Ge=s.from_html('<div class="modal-resize-handles"></div>');function Ke(e,t){return t&&e.appendChild(t),{update(t){e.innerHTML="",t&&e.appendChild(t)},destroy(){e.innerHTML=""}}}s.delegate(["pointerdown"]);var Ve=s.from_html('<div class="modal-footer"><!></div>'),Ue=s.from_html("<div></div>"),Qe=s.from_html('<div role="dialog" aria-modal="true" tabindex="-1"><!> <div class="modal-body"><!></div> <!> <!> <!></div>');function Je(r,d){s.push(d,!0);let a=s.prop(d,"maxWidth",3,"600px"),l=s.prop(d,"autoOpen",3,!1),c=s.prop(d,"closeOnEscape",3,!0),g=s.state(!1);e(()=>{K({id:d.id,title:d.title,icon:d.icon??"",isOpen:l(),isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,isRejected:!1,position:null,size:null,hasBeenDragged:!1,dockPosition:0,glow:d.glow??null,parentId:void 0,childId:void 0,offsetFromParent:void 0}),s.set(g,!0)}),o(()=>{V(d.id)});const u=s.derived(()=>{if(!s.get(g))return!1;ae();const e=se(d.id);return!!e&&(e.isOpen||e.isMinimized||le(d.id)||ce(d.id)||de(d.id))});var h=s.comment(),f=s.first_child(h),y=r=>{!function(r,d){s.push(d,!0);let a=s.prop(d,"maxWidth",3,"600px"),l=s.prop(d,"autoOpen",3,!1),c=s.prop(d,"closeOnEscape",3,!0),g=s.prop(d,"skipRegistration",3,!1);i(Ie,d.id);const u=v().portalTarget,h=P(d.id);function f(e){var t,i;return(null==(i=null==(t=d.config)?void 0:t.features)?void 0:i[e])??function(e){return p.features[e]}(e)}const y=s.derived(()=>(m(),f("drag"))),w=s.derived(()=>(m(),f("minimize"))),x=s.derived(()=>(m(),!f("dock"))),z=s.derived(()=>(m(),f("transparency"))),I=s.derived(()=>(m(),f("resize"))),M=s.derived(()=>{var e,t;return m(),(null==(t=null==(e=d.config)?void 0:e.appearance)?void 0:t.headerLayout)??v().appearance.headerLayout});let B=s.state(null),O=s.state(!1),S=s.state(!1),N=s.state(!1),j=s.state(!1),G=s.state(!1);const Q=s.derived(()=>(ae(),se(d.id))),J=s.derived(()=>s.get(Q)&&(s.get(Q).isOpen||ce(d.id))&&(!s.get(Q).isMinimized||de(d.id))&&!s.get(Q).isHiddenWithParent),ie=s.derived(()=>{var e;return!!(null==(e=s.get(Q))?void 0:e.childId)}),oe=s.derived(()=>{var e;return!!(null==(e=s.get(Q))?void 0:e.parentId)}),re=s.derived(()=>s.get(ie)||s.get(S)),fe=s.derived(()=>!!d.glow),me=s.derived(()=>`modal-title-${h}`),ve=s.derived(()=>{var e;return(null==(e=s.get(Q))?void 0:e.zIndex)??1e3}),xe=function(e={x:0,y:0}){const t=s.proxy({...e}),i=s.proxy({isDragging:!1,startX:0,startY:0,initialX:0,initialY:0,hasBeenDragged:!1});return{get position(){return t},get hasBeenDragged(){return i.hasBeenDragged},get isDragging(){return i.isDragging},onPointerDown:function(e,n){if(0===e.button){if(!i.hasBeenDragged){const e=n.getBoundingClientRect();t.x=e.left,t.y=e.top}i.isDragging=!0,i.startX=e.clientX,i.startY=e.clientY,i.initialX=t.x,i.initialY=t.y,n.setPointerCapture(e.pointerId)}},onPointerMove:function(e,n,o){if(!i.isDragging)return;const r=e.clientX-i.startX,d=e.clientY-i.startY,s=b(i.initialX+r,i.initialY+d,o.width,o.height);t.x=s.x,t.y=s.y,i.hasBeenDragged=!0},onPointerUp:function(e,t){i.isDragging&&(i.isDragging=!1,t.releasePointerCapture(e.pointerId))},setPosition:function(e){t.x=e.x,t.y=e.y},setHasBeenDragged:function(e){i.hasBeenDragged=e},reset:function(){t.x=e.x,t.y=e.y,i.hasBeenDragged=!1}}}({x:0,y:0});let _e=s.state(!1);const Me=function(e,t,i){let n=s.state(!1),o=s.state(""),r=s.state(s.proxy({width:0,height:0})),a=s.state(!1),l=s.state(!1),c={x:0,y:0,width:0,height:0,posX:0,posY:0},g=null;function u(d,l){d.preventDefault(),d.stopPropagation();const u=e();if(!u)return;const f=u.getBoundingClientRect();xe.hasBeenDragged||(i({x:f.left,y:f.top}),xe.setHasBeenDragged(!0)),s.get(a)||(s.set(r,{width:f.width,height:f.height},!0),s.set(a,!0));const m=t();s.set(n,!0),s.set(o,l,!0),g=d.pointerId,c={x:d.clientX,y:d.clientY,width:s.get(r).width,height:s.get(r).height,posX:m.x,posY:m.y,centerX:m.x+s.get(r).width/2,centerY:m.y+s.get(r).height/2},window.addEventListener("pointermove",h),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p)}function h(e){if(e.pointerId!==g)return;const t=e.clientX-c.x,n=e.clientY-c.y,d=window.innerWidth,a=window.innerHeight;let l=c.width,u=c.height,h=c.posX,p=c.posY;if(s.get(o).includes("e")){const e=d-h;l=Math.max(280,Math.min(c.width+t,e))}if(s.get(o).includes("w")){const e=c.width-280,i=Math.min(t,e);l=c.width-i,h=c.posX+i}if(s.get(o).includes("s")){const e=a-p;u=Math.max(200,Math.min(c.height+n,e))}if(s.get(o).includes("n")){const e=c.height-200,t=Math.min(n,e);u=c.height-t,p=c.posY+t}const f=_(h,p,l,u);s.set(r,{width:f.width,height:f.height},!0),i({x:f.x,y:f.y})}function p(e){e.pointerId===g&&(s.set(n,!1),g=null,window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),s.set(l,!0),((e,t)=>{const i=se(d.id);if(null==i?void 0:i.parentId){const e=se(i.parentId),n=document.querySelector(`[data-modal-id="${P(i.parentId)}"]`);if(e&&n){const i=e.position??{x:n.getBoundingClientRect().left,y:n.getBoundingClientRect().top},o=e.size??{width:n.offsetWidth,height:n.offsetHeight},r={x:i.x+(o.width-t.width)/2,y:i.y+(o.height-t.height)/2};s.set(_e,!0),xe.setPosition(r);const a={x:r.x-i.x,y:r.y-i.y};return ee(d.id,{position:r,size:t,hasBeenDragged:!0,offsetFromParent:a}),void setTimeout(()=>{s.set(_e,!1)},200)}}ee(d.id,{position:e,size:t,hasBeenDragged:!0})})(t(),s.get(r)),setTimeout(()=>{s.set(l,!1)},0))}const f={startResize:u};return{get isResizing(){return s.get(n)},get resizeDirection(){return s.get(o)},get size(){return s.get(r)},get hasBeenResized(){return s.get(a)},get isActive(){return s.get(n)},get justFinishedResizing(){return s.get(l)},start:u,setHasBeenResized:()=>{},setSize:function(e){s.set(r,e,!0),s.set(a,!0)},reset:function(){s.set(a,!1),s.set(r,{width:0,height:0},!0)},constrainToViewport:function(){const n=t(),o=e();if(!o)return;const d=_(n.x,n.y,s.get(r).width||o.offsetWidth,s.get(r).height||o.offsetHeight);s.set(r,{width:d.width,height:d.height},!0),i({x:d.x,y:d.y})},handlers:f}}(()=>s.get(B),()=>xe.position,e=>xe.setPosition(e)),Pe=function(e,t,i,n,o,r,a,l,c){let g=s.state(!1),u=s.state(!1),h=s.state(!1),p=s.state(!1),f=s.state(null),m=s.state(null),v=null,y=null;function w(){y&&(clearTimeout(y),y=null)}function x(){const e=d.id,t=document.querySelector(`.modal-dock-item[data-modal-id="${P(e)}"]`),i=document.querySelector('[data-dock-container="true"]'),n=t||i;if(n){const e=n.getBoundingClientRect();return{x:e.left+e.width/2,y:e.top+e.height/2}}return{x:window.innerWidth/2,y:window.innerHeight-40}}return s.user_effect(()=>()=>{w(),s.set(g,!1),s.set(u,!1),s.set(h,!1),s.set(p,!1),s.set(f,null),s.set(m,null),v=null}),{get isMinimizing(){return s.get(g)},get isRestoring(){return s.get(u)},get isOpening(){return s.get(h)},get isClosing(){return s.get(p)},get animationTransform(){return s.get(f)},get pendingOpenSource(){return s.get(m)},startMinimize:function(e,d){const p=t();if(s.get(g)||!p)return;if(s.set(u,!1),s.set(h,!1),w(),!be()){const e=p.getBoundingClientRect();let t=o()?i():{x:e.left,y:e.top},s=a()?l():{width:e.width,height:e.height};return o()||(n(t),r(!0)),void(d?d():c(t,!0,s))}const m=p.getBoundingClientRect(),v=m.left+m.width/2,z=m.top+m.height/2;let I=o()?i():{x:m.left,y:m.top},b=a()?l():{width:m.width,height:m.height};o()||(n(I),r(!0));const _=e??x(),M=_.x-m.left,k=_.y-m.top,D={x:_.x-v,y:_.y-z,originX:M,originY:k};s.set(f,D,!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.set(g,!0)})}),y=setTimeout(()=>{d?d():c(I,!0,b)},500)},startRestore:function(e,t){if(!be()){const t=e||{x:window.innerWidth/2,y:window.innerHeight/2};return n(t),void r(!0)}const i=x(),o=e||{x:window.innerWidth/2,y:window.innerHeight/2},d=t||{width:480,height:400};n(o),r(!0);const a=o.x+d.width/2,l=o.y+d.height/2,c=i.x-o.x,g=i.y-o.y;s.set(f,{x:i.x-a,y:i.y-l,originX:c,originY:g},!0),s.set(u,!0),setTimeout(()=>{s.set(u,!1),s.set(f,null)},400)},startClose:function(e){s.get(p)||s.get(g)||(be()?(v=e,s.set(p,!0),setTimeout(()=>{s.set(p,!1),v&&(v(),v=null)},250)):e())},setPendingOpenSource:function(e){s.set(m,e,!0)},tryStartOpenAnimation:function(){const e=t();if(!s.get(m)||!e||s.get(h))return!1;if(!be())return s.set(m,null),!1;const d=s.get(m);s.set(m,null);const a=e.getBoundingClientRect(),l=o()?i():{x:a.left,y:a.top},c=a.width,g=a.height,u=l.x+c/2,p=l.y+g/2;o()||(n(l),r(!0));const v=d.x-l.x,y=d.y-l.y;return s.set(f,{x:d.x-u,y:d.y-p,originX:v,originY:y},!0),s.set(h,!0),setTimeout(()=>{s.set(h,!1),s.set(f,null)},400),!0},forceClearMinimize:function(){w(),s.set(g,!1),s.set(f,null)}}}(0,()=>s.get(B),()=>xe.position,e=>xe.setPosition(e),()=>xe.hasBeenDragged,e=>xe.setHasBeenDragged(e),()=>Me.hasBeenResized,()=>Me.size,(e,t,i)=>{ee(d.id,{position:e,size:i,hasBeenDragged:t}),U(d.id)}),{trapFocus:Ce,focusFirstElement:Je}={trapFocus:ke,focusFirstElement:De},Ze=s.derived(()=>Pe.isMinimizing||Pe.isRestoring||Pe.isOpening||Pe.isClosing),et=s.derived(()=>(pe(d.id)||he(d.id))&&!Pe.isRestoring);let tt=s.state(!1);const it=s.derived(()=>Pe.isRestoring||Pe.isOpening||s.get(tt)),nt=s.derived(()=>s.get(J)&&!xe.hasBeenDragged&&!s.get(Ze)&&!Pe.pendingOpenSource&&!s.get(et)),ot=s.derived(()=>{const e=[];return e.push(`z-index: ${s.get(ve)};`),Pe.animationTransform?(e.push(`left: ${xe.position.x}px; top: ${xe.position.y}px;`),e.push(`--genie-origin-x: ${Pe.animationTransform.originX}px;`),e.push(`--genie-origin-y: ${Pe.animationTransform.originY}px;`),e.push(`--genie-translate-x: ${Pe.animationTransform.x}px;`),e.push(`--genie-translate-y: ${Pe.animationTransform.y}px;`)):xe.hasBeenDragged&&e.push(`left: ${xe.position.x}px; top: ${xe.position.y}px; transform: none;`),Me.hasBeenResized?e.push(`width: ${Me.size.width}px; height: ${Me.size.height}px; max-width: none; max-height: none;`):(d.preferredHeight&&e.push(`min-height: ${d.preferredHeight};`),a()&&e.push(`max-width: ${a()};`)),s.get(fe)&&d.glow&&(e.push(`--modal-glow-color: ${d.glow.color};`),e.push(`--modal-glow-intensity: ${d.glow.intensity};`)),e.join(" ")});function rt(){s.get(w)&&U(d.id)}function dt(){var e;ge(d.id)&&ue(d.id),ne(d.id),null==(e=d.onClose)||e.call(d)}function st(){ye(d.id)}function at(e){s.get(y)&&s.get(B)&&xe.onPointerDown(e,s.get(B))}function lt(e){c()&&"Escape"===e.key&&function(e){const t=C.get(e);if(!t)return!1;const i=Math.max(...Array.from(C.values()).map(e=>e.zIndex),0);return t.zIndex===i&&!t.isMinimized&&!t.isHiddenWithParent}(d.id)&&(e.stopPropagation(),dt())}function ct(e){if(!s.get(B))return;const t=xe.isDragging,i=Me.hasBeenResized?Me.size:{width:s.get(B).offsetWidth,height:s.get(B).offsetHeight};xe.onPointerMove(e,s.get(B),i),xe.isDragging&&t&&Z(d.id,xe.position,{drag:!0})}function gt(e){if(!s.get(B))return;const t=xe.isDragging;xe.onPointerUp(e,s.get(B)),t&&!Me.justFinishedResizing&&(Z(d.id,xe.position,{drag:!0}),function(e){const t=v();if("animated"!==t.parentChild.movementMode)return;const i=t.parentChild.animationDuration,n=[];let o=e;for(;;){const e=C.get(o);if(!(null==e?void 0:e.parentId))break;n.push({parentId:e.parentId,childId:o}),o=e.parentId}n.forEach(({parentId:e,childId:t},n)=>{setTimeout(()=>{const n=C.get(t),o=C.get(e);if(!(null==n?void 0:n.position)||!n.offsetFromParent||!o)return;const r={x:n.position.x-n.offsetFromParent.x,y:n.position.y-n.offsetFromParent.y};q.set(e,r),function(e){const t=q.get(e);if(!t)return;const i=C.get(e);i&&(C.set(e,{...i,isAnimatingPosition:!0,position:t}),q.delete(e),T())}(e),setTimeout(()=>function(e){const t=C.get(e);t&&(C.set(e,{...t,isAnimatingPosition:!1}),T())}(e),i)},n*i)})}(d.id))}function ut(){var e;const t=v();if("smart"!==(null==(e=t.positioning)?void 0:e.strategy))return!1;const i=se(d.id);if(null==i?void 0:i.parentId)return!1;if((null==i?void 0:i.hasBeenDragged)||(null==i?void 0:i.position))return!1;const n=s.get(B)||document.querySelector(`[data-modal-id="${h}"]`);if(!n)return!1;const o=n.offsetWidth,r=n.offsetHeight;if(o<=0||r<=0)return!1;const a=t.positioning.modalGap??16,l=function(e){const t=[];for(const[i,n]of C.entries())if(i!==e&&n.isOpen&&!n.isMinimized&&!n.isHiddenWithParent)if(n.position&&n.size)t.push({x:n.position.x,y:n.position.y,width:n.size.width,height:n.size.height});else{const e=document.querySelector(`[data-modal-id="${P(i)}"]`);if(e){const i=e.getBoundingClientRect();t.push({x:i.left,y:i.top,width:i.width,height:i.height})}}return t}(d.id),c=function(e){if("undefined"==typeof document)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}(t.positioning.avoidElements??[]),g=function(e,t,i,n={}){const{modalGap:o=16,gridResolution:r=10,avoidBounds:d=[],avoidMargin:s=16}=n,a=n.margin??o,l="undefined"!=typeof window?window.innerWidth:1920,c="undefined"!=typeof window?window.innerHeight:1080,g=d.map(e=>({x:e.x-s,y:e.y-s,width:e.width+2*s,height:e.height+2*s})),u={x:(l-e)/2,y:(c-t)/2};if(0===i.length&&0===g.length)return u;const h=a,p=Math.max(a,l-e-a),f=a,m=Math.max(a,c-t-a);if(p<=h||m<=f)return u;const v=k(u.x,u.y,e,t,i,o),y=k(u.x,u.y,e,t,g,0);if(0===v&&0===y)return u;const w=[],x=(p-h)/r,z=(m-f)/r;for(let n=0;n<=r;n++)for(let d=0;d<=r;d++){const r=h+n*x,s=f+d*z,u=k(r,s,e,t,i,o),p=k(r,s,e,t,g,0),m=D(r,s,e,t,l,c,a);w.push({pos:{x:r,y:s},modalOverlap:u,avoidOverlap:p,centerDist:m})}const I=w.filter(e=>0===e.avoidOverlap),b=I.length>0?I:w,_=e*t,M=Math.min(...b.map(e=>e.modalOverlap))/_;return b.sort((e,t)=>{if(0===I.length&&e.avoidOverlap!==t.avoidOverlap)return e.avoidOverlap-t.avoidOverlap;const i=e.modalOverlap/_,n=t.modalOverlap/_;if(M<.3){const o=.3,r=i<=o,d=n<=o;if(r&&d)return e.centerDist+.3*i-(t.centerDist+.3*n);if(r)return-1;if(d)return 1}return.6*i+.4*e.centerDist-(.6*n+.4*t.centerDist)}),b[0].pos}(o,r,l,{modalGap:a,avoidBounds:c});if(k(g.x,g.y,o,r,l,a)/(o*r)>.1&&l.length>0){const e=function(e){const t=[];for(const[i,n]of C.entries())if(i!==e&&n.isOpen&&!n.isMinimized&&!n.isHiddenWithParent&&!n.parentId)if(n.position&&n.size)t.push({id:P(i),x:n.position.x,y:n.position.y,width:n.size.width,height:n.size.height});else{const e=document.querySelector(`[data-modal-id="${P(i)}"]`);if(e){const n=e.getBoundingClientRect();t.push({id:P(i),x:n.left,y:n.top,width:n.width,height:n.height})}}return t}(d.id),t=function(e,t,i,n={}){const{modalGap:o=16}=n,r=n.margin??o,d="undefined"!=typeof window?window.innerWidth:1920,s="undefined"!=typeof window?window.innerHeight:1080,a=i.reduce((e,t)=>e+t.width,0)+e,l=i.length*o,c=d-2*r;if(a+l>c)return null;const g=c-a-l;i.length;const u=g/2,h=d/2,p=[...i.map(e=>({id:e.id,width:e.width,height:e.height,currentX:e.x+e.width/2,currentY:e.y,isNew:!1})),{id:"__new__",width:e,height:t,currentX:h,currentY:(s-t)/2,isNew:!0}];p.sort((e,t)=>e.currentX-t.currentX);let f=r+u;const m=new Map;let v=null;for(const e of p){const t=f;if(e.isNew)v={x:Math.round(t),y:Math.round(e.currentY)};else{const n=i.find(t=>t.id===e.id);Math.abs(t-n.x)>5&&m.set(e.id,{x:Math.round(t),y:Math.round(n.y)})}f+=e.width+o}return v?{newModalPosition:v,existingModalMoves:m}:null}(o,r,e,{modalGap:a});if(t&&t.existingModalMoves.size>0)return function(e){const t=v().parentChild.animationDuration;for(const[t,i]of e){const e=C.get(t);e&&C.set(t,{...e,position:i,isAnimatingPosition:!0,hasBeenDragged:!0})}T(),setTimeout(()=>{for(const t of e.keys()){const e=C.get(t);e&&C.set(t,{...e,isAnimatingPosition:!1})}T()},t)}(t.existingModalMoves),xe.setPosition(t.newModalPosition),xe.setHasBeenDragged(!0),Z(d.id,t.newModalPosition,{size:{width:o,height:r}}),!0}return xe.setPosition(g),xe.setHasBeenDragged(!0),Z(d.id,g,{size:{width:o,height:r}}),!0}function ht(){n().then(()=>n()).then(()=>{let e=0;const t=()=>{e+=1,ut()||e>5||requestAnimationFrame(t)};s.get(B)?t():requestAnimationFrame(t)})}e(()=>{var e;function t(){const e=se(d.id);if(!(null==e?void 0:e.position)||!s.get(B))return;if(e.parentId)return;const t=Me.hasBeenResized?Me.size.width:s.get(B).offsetWidth,i=Me.hasBeenResized?Me.size.height:s.get(B).offsetHeight;if(t<=0||i<=0)return;const n=b(e.position.x,e.position.y,t,i);(Math.abs(n.x-e.position.x)>1||Math.abs(n.y-e.position.y)>1)&&(xe.setPosition(n),Z(d.id,n))}return g()||(e=l(),K({id:d.id,title:d.title,icon:d.icon??"",isOpen:e,isMinimized:!1,isHiddenWithParent:!1,isTransparent:!1,isRejected:!1,position:null,size:null,hasBeenDragged:!1,dockPosition:0,glow:d.glow??null,parentId:void 0,childId:void 0,offsetFromParent:void 0}),e&&te(d.id)),l()&&(n().then(()=>{s.get(B)&&Je(s.get(B))}),ht()),window.addEventListener("pointermove",ct),window.addEventListener("pointerup",gt),window.addEventListener("resize",t),()=>{window.removeEventListener("pointermove",ct),window.removeEventListener("pointerup",gt),window.removeEventListener("resize",t)}}),o(()=>{we(d.id),g()||V(d.id)}),s.user_effect(()=>{ae();const e=se(d.id);if(e){if(s.set(O,e.isTransparent,!0),!xe.isDragging&&!Me.isResizing&&e.position){const t=xe.position,i=e.position;(Math.abs(t.x-i.x)>.5||Math.abs(t.y-i.y)>.5)&&(xe.setPosition(i),e.hasBeenDragged&&xe.setHasBeenDragged(!0))}n().then(()=>function(){var e,t;if(!se(d.id))return;if(ge(d.id))return ue(d.id),void(null==(e=d.onClose)||e.call(d));if(de(d.id)&&!s.get(j)){if(s.set(j,!0),s.get(F),s.set(F,null),s.get(B)){const e=s.get(B).getBoundingClientRect(),t=xe.hasBeenDragged?xe.position:{x:e.left,y:e.top},i=Me.hasBeenResized?Me.size:{width:e.width,height:e.height};ee(d.id,{position:t,size:i,hasBeenDragged:!0})}Pe.startMinimize(void 0,()=>{var e;e=d.id,s.get(R).includes(e)&&s.set(R,s.get(R).filter(t=>t!==e),!0),s.set(j,!1)})}if(he(d.id)){t=d.id,s.get(L).includes(t)&&s.set(L,s.get(L).filter(e=>e!==t),!0);const e=se(d.id);Pe.startRestore((null==e?void 0:e.position)??void 0,(null==e?void 0:e.size)??void 0),n().then(()=>{s.get(B)&&Je(s.get(B))})}if(pe(d.id)){!function(e){s.get(W).includes(e)&&s.set(W,s.get(W).filter(t=>t!==e),!0)}(d.id);const e=se(d.id);Pe.startRestore((null==e?void 0:e.position)??void 0,(null==e?void 0:e.size)??void 0)}if(ce(d.id)&&(function(e){s.get(H).includes(e)&&s.set(H,s.get(H).filter(t=>t!==e),!0)}(d.id),Pe.startClose(()=>{var e;we(d.id),function(e){const t=C.get(e);if(t){if(t.parentId){const i=C.get(t.parentId);i&&i.childId===e&&C.set(t.parentId,{...i,childId:void 0,lastChildId:e})}C.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}),T()}}(d.id),null==(e=d.onClose)||e.call(d)})),le(d.id)){!function(e){s.get(E).includes(e)&&s.set(E,s.get(E).filter(t=>t!==e),!0)}(d.id);const e=function(e){const t=X.get(e);return t&&X.delete(e),t??null}(d.id)||d.openSourcePosition||null;e?(Pe.setPendingOpenSource(e),n().then(()=>n()).then(()=>{ut(),Pe.tryStartOpenAnimation()})):ht(),n().then(()=>{s.get(B)&&Je(s.get(B))})}(function(e){return s.get(A).includes(e)})(d.id)&&(function(e){s.get(A).includes(e)&&s.set(A,s.get(A).filter(t=>t!==e),!0)}(d.id),function(e){s.get($).includes(e)||s.set($,[...s.get($),e],!0)}(d.id),s.set(G,!0),setTimeout(()=>{s.set(G,!1),function(e){s.set($,s.get($).filter(t=>t!==e),!0)}(d.id)},600));const i=function(e){if(!s.get(Y)||s.get(Y).childId!==e)return null;const t=s.get(Y);return s.set(Y,null),t}(d.id);var o;i&&s.get(B)&&(o=i.parentId,n().then(()=>n()).then(()=>{let e=0;const t=()=>{e+=1;const i=function(e){var t,i;const n=se(e);if(!n)return!1;const o=s.get(B)||document.querySelector(`[data-modal-id="${h}"]`),r=document.querySelector(`[data-modal-id="${P(e)}"]`),a=null==r?void 0:r.getBoundingClientRect(),l=n.position??(a?{x:a.left,y:a.top}:null);if(!l||!o)return!1;const c=(null==(t=n.size)?void 0:t.width)??(null==r?void 0:r.offsetWidth)??(null==a?void 0:a.width)??480,g=(null==(i=n.size)?void 0:i.height)??(null==r?void 0:r.offsetHeight)??(null==a?void 0:a.height)??400,u=o.offsetWidth,p=o.offsetHeight;if(c<=0||g<=0||u<=0||p<=0)return!1;const f={x:l.x+(c-u)/2,y:l.y+(g-p)/2};return xe.setPosition(f),xe.setHasBeenDragged(!0),Z(d.id,f,{size:{width:u,height:p}}),n.position&&n.size||!a||Z(e,{x:a.left,y:a.top},{size:{width:c,height:g}}),function(e,t){if(!v().features.parentChild)return;const i=C.get(e),n=C.get(t);if(!i||!n)return;let o={x:40,y:40};i.position&&n.position&&(o={x:n.position.x-i.position.x,y:n.position.y-i.position.y});const r=Math.max(n.zIndex,i.zIndex+1);C.set(e,{...i,childId:t,lastChildId:t}),C.set(t,{...n,parentId:e,offsetFromParent:o,zIndex:r}),T()}(e,d.id),!0}(o);i||e>5||requestAnimationFrame(t)};s.get(B)?t():requestAnimationFrame(t)}))}())}}),s.user_effect(()=>{const e=se(d.id);e&&e.isTransparent!==s.get(O)&&s.set(O,e.isTransparent,!0)}),s.user_effect(()=>{if(s.get(J)&&s.get(B)){const e=e=>function(e){s.get(B)&&Ce(e,s.get(B))}(e);return s.get(B).addEventListener("keydown",e),()=>{var t;return null==(t=s.get(B))?void 0:t.removeEventListener("keydown",e)}}}),s.user_effect(()=>{!s.get(J)&&Pe.isMinimizing&&Pe.forceClearMinimize()}),s.user_effect(()=>{Pe.isRestoring||Pe.isOpening?s.set(tt,!0):s.get(tt)&&requestAnimationFrame(()=>{s.set(tt,!1)})}),s.user_effect(()=>{s.get(N)&&!s.get(ie)&&(s.set(S,!0),setTimeout(()=>{s.set(S,!1)},200)),s.set(N,s.get(ie),!0)});var pt=s.comment(),ft=s.first_child(pt),mt=e=>{Be(e,{get target(){return u},children:(e,i)=>{var n=Qe();let o;n.__keydown=lt;var r=s.child(n);{let e=s.derived(()=>s.get(y)?at:void 0);!function(e,i){s.push(i,!0);let n=s.prop(i,"isTransparent",3,!1),o=s.prop(i,"headerLayout",3,"macos"),r=s.prop(i,"minimizable",3,!0),d=s.prop(i,"minimizeDisabled",3,!1),a=s.prop(i,"transparencyEnabled",3,!0);const l=t(ze),c=s.derived(()=>null==l?void 0:l()),g=s.derived(()=>"macos"===o());var u=Ne();let h;u.__pointerdown=function(e){var t;e.target.closest("button")||null==(t=i.onStartDrag)||t.call(i,e)};var p=s.child(u),f=e=>{var t=Le(),n=s.first_child(t),o=s.child(n);o.__click=function(...e){var t;null==(t=i.onClose)||t.apply(this,e)};var l=s.sibling(o,2),g=e=>{var t=Oe();let n;t.__click=function(...e){var t;null==(t=d()?void 0:i.onMinimize)||t.apply(this,e)},s.template_effect(()=>{n=s.set_class(t,1,"modal-header-light modal-header-light-minimize",null,n,{"modal-header-light-disabled":d()}),t.disabled=d(),s.set_attribute(t,"title",d()?"Enable dock to minimize":void 0)}),s.append(e,t)};s.if(l,e=>{r()&&e(g)});var u=s.sibling(l,2),h=e=>{var t=Te();t.__click=function(...e){var t;null==(t=i.onToggleStyle)||t.apply(this,e)},s.append(e,t)};s.if(u,e=>{a()&&e(h)}),s.reset(n);var p=s.sibling(n,2),f=s.child(p),m=e=>{var t=Re(),n=s.child(t);s.snippet(n,()=>i.customIcon),s.reset(t),s.append(e,t)},v=e=>{var t=s.comment(),n=s.first_child(t),o=e=>{var t=Ee(),n=s.child(t);s.snippet(n,()=>s.get(c),()=>i.icon),s.reset(t),s.append(e,t)};s.if(n,e=>{i.icon&&s.get(c)&&e(o)},!0),s.append(e,t)};s.if(f,e=>{i.customIcon?e(m):e(v,!1)});var y=s.sibling(f,2),w=s.child(y),x=e=>{var t=He(),n=s.child(t,!0);s.reset(t),s.template_effect(()=>{s.set_attribute(t,"id",i.titleId),s.set_text(n,i.title)}),s.append(e,t)},z=e=>{var t=Se(),n=s.child(t,!0);s.reset(t),s.template_effect(()=>s.set_text(n,i.title)),s.append(e,t)};s.if(w,e=>{i.titleId?e(x):e(z,!1)}),s.reset(y),s.reset(p),s.next(2),s.append(e,t)},m=e=>{var t=qe(),n=s.first_child(t),o=s.child(n),l=e=>{var t=We(),n=s.child(t);s.snippet(n,()=>i.customIcon),s.reset(t),s.append(e,t)},g=e=>{var t=s.comment(),n=s.first_child(t),o=e=>{var t=Ae(),n=s.child(t);s.snippet(n,()=>s.get(c),()=>i.icon),s.reset(t),s.append(e,t)};s.if(n,e=>{i.icon&&s.get(c)&&e(o)},!0),s.append(e,t)};s.if(o,e=>{i.customIcon?e(l):e(g,!1)});var u=s.sibling(o,2),h=e=>{var t=$e(),n=s.child(t,!0);s.reset(t),s.template_effect(()=>{s.set_attribute(t,"id",i.titleId),s.set_text(n,i.title)}),s.append(e,t)},p=e=>{var t=Fe(),n=s.child(t,!0);s.reset(t),s.template_effect(()=>s.set_text(n,i.title)),s.append(e,t)};s.if(u,e=>{i.titleId?e(h):e(p,!1)}),s.reset(n);var f=s.sibling(n,2),m=s.child(f),v=e=>{var t=Xe();t.__click=function(...e){var t;null==(t=i.onToggleStyle)||t.apply(this,e)},s.append(e,t)};s.if(m,e=>{a()&&e(v)});var y=s.sibling(m,2),w=e=>{var t=Ye();let n;t.__click=function(...e){var t;null==(t=d()?void 0:i.onMinimize)||t.apply(this,e)},s.template_effect(()=>{n=s.set_class(t,1,"modal-header-btn-windows",null,n,{"modal-header-btn-windows-disabled":d()}),t.disabled=d(),s.set_attribute(t,"title",d()?"Enable dock to minimize":void 0)}),s.append(e,t)};s.if(y,e=>{r()&&e(w)}),s.sibling(y,2).__click=function(...e){var t;null==(t=i.onClose)||t.apply(this,e)},s.reset(f),s.append(e,t)};s.if(p,e=>{s.get(g)?e(f):e(m,!1)}),s.reset(u),s.template_effect(()=>h=s.set_class(u,1,"modal-header",null,h,{"modal-header-draggable":!!i.onStartDrag,transparent:n()})),s.append(e,u),s.pop()}(r,{get title(){return d.title},get customIcon(){return d.customIcon},get icon(){return d.icon},get isTransparent(){return s.get(O)},get titleId(){return s.get(me)},get headerLayout(){return s.get(M)},get onStartDrag(){return s.get(e)},onToggleStyle:st,onMinimize:rt,onClose:dt,get minimizable(){return s.get(w)},get minimizeDisabled(){return s.get(x)},get transparencyEnabled(){return s.get(z)}})}var a=s.sibling(r,2),l=s.child(a);s.snippet(l,()=>d.children??s.noop),s.reset(a),s.action(a,(e,t)=>null==Ke?void 0:Ke(e,t),()=>d.bodyElement);var c=s.sibling(a,2),g=e=>{var t=Ve(),i=s.child(t),n=e=>{var t=s.comment(),i=s.first_child(t);s.snippet(i,()=>d.footer),s.append(e,t)};s.if(i,e=>{d.footer&&e(n)}),s.reset(t),s.action(t,(e,t)=>null==Ke?void 0:Ke(e,t),()=>d.footerElement),s.append(e,t)};s.if(c,e=>{(d.footer||d.footerElement)&&e(g)});var u=s.sibling(c,2);{let e=s.derived(()=>s.get(I)&&!s.get(ie)?Me.handlers.startResize:void 0);!function(e,t){s.push(t,!0);const i=["n","s","e","w","ne","nw","se","sw"];var n=s.comment(),o=s.first_child(n),r=e=>{var n=Ge();s.each(n,21,()=>i,s.index,(e,i)=>{var n=je();n.__pointerdown=e=>function(e,i){var n;null==(n=t.onStartResize)||n.call(t,e,i)}(e,s.get(i)),s.template_effect(()=>s.set_class(n,1,`modal-resize-handle modal-resize-${s.get(i)??""}`)),s.append(e,n)}),s.reset(n),s.append(e,n)};s.if(o,e=>{t.onStartResize&&e(r)}),s.append(e,n),s.pop()}(u,{get onStartResize(){return s.get(e)}})}var p=s.sibling(u,2),f=e=>{var t=Ue();let i;s.template_effect(()=>i=s.set_class(t,1,"modal-child-overlay",null,i,{"modal-overlay-closing":s.get(S)})),s.append(e,t)};s.if(p,e=>{s.get(re)&&e(f)}),s.reset(n),s.bind_this(n,e=>s.set(B,e),()=>s.get(B)),s.template_effect(()=>{var e;o=s.set_class(n,1,"modal-dialog",null,o,{"modal-dragging":xe.isDragging,"modal-resizing":Me.isResizing,"modal-positioned":xe.hasBeenDragged,"modal-minimizing":Pe.isMinimizing,"modal-restoring":Pe.isRestoring,"modal-opening":Pe.isOpening,"modal-closing":Pe.isClosing,"modal-centered":s.get(nt),"modal-solid":!s.get(O),"modal-transparent":s.get(O),"modal-glow":s.get(fe),"modal-has-child":s.get(ie),"modal-is-child":s.get(oe),"modal-visible-by-animation":s.get(it),"modal-animating-to-center":s.get(_e),"modal-animating-position":null==(e=s.get(Q))?void 0:e.isAnimatingPosition,"modal-attention":s.get(G)}),s.set_attribute(n,"data-modal-id",h),s.set_style(n,s.get(ot)),s.set_attribute(n,"aria-labelledby",s.get(me))}),s.event("pointerdown",n,()=>te(d.id),!0),s.append(e,n)},$$slots:{default:!0}})};s.if(ft,e=>{s.get(J)&&e(mt)}),s.append(r,pt),s.pop()}(r,{get id(){return d.id},get title(){return d.title},get icon(){return d.icon},get customIcon(){return d.customIcon},get maxWidth(){return a()},get preferredHeight(){return d.preferredHeight},get autoOpen(){return l()},get openSourcePosition(){return d.openSourcePosition},get glow(){return d.glow},get config(){return d.config},get closeOnEscape(){return c()},get onClose(){return d.onClose},get children(){return d.children},get footer(){return d.footer},skipRegistration:!0})};s.if(f,e=>{s.get(u)&&e(y)}),s.append(r,h),s.pop()}s.delegate(["keydown"]);var Ze=s.from_html('<button type="button" aria-label="Drag dock"></button>'),et=s.from_html('<span class="modal-dock-item-icon-placeholder"> </span>'),tt=s.from_html('<span class="modal-dock-item-label"> </span>'),it=s.from_html("<span>+</span>"),nt=s.from_html('<span class="modal-dock-child-indicator"><!></span>'),ot=s.from_html('<button><span class="modal-dock-item-icon"><!></span> <!> <span class="modal-dock-item-glow"></span> <!></button>'),rt=s.from_html('<div data-dock-container="true"><div><!> <!></div></div>');function dt(e,i){s.push(i,!0);const n=t(ze),o=s.derived(()=>i.renderIcon??(null==n?void 0:n())),r=ve(),d=s.derived(()=>(m(),v())),c=s.derived(()=>z("DOCK")),h=s.derived(()=>s.get(d).dock.position),p=s.derived(()=>s.get(d).dock.labelMode);let f=s.state("horizontal"),y=s.state(s.proxy({x:100,y:100})),w=s.state(null),x=s.state(!1),I={x:0,y:0},_=null;const M=s.derived(()=>(ae(),Array.from(r.modals.values()).filter(e=>e.isMinimized).sort((e,t)=>e.dockPosition-t.dockPosition))),k=s.derived(()=>{switch(s.get(h)){case"left":return{x:-20,duration:250,easing:g};case"right":return{x:20,duration:250,easing:g};default:return{y:20,duration:250,easing:g}}});function D(e){var t;"free"===s.get(h)&&(s.set(x,!0),_=e.pointerId,I={x:e.clientX-s.get(y).x,y:e.clientY-s.get(y).y},null==(t=e.currentTarget)||t.setPointerCapture(e.pointerId),window.addEventListener("pointermove",C),window.addEventListener("pointerup",B),window.addEventListener("pointercancel",B))}function C(e){if(e.pointerId!==_||!s.get(w))return;const t=s.get(w).getBoundingClientRect(),i=window.innerWidth-t.width-8,n=window.innerHeight-t.height-8,o=Math.min(Math.max(e.clientX-I.x,8),Math.max(8,i)),r=Math.min(Math.max(e.clientY-I.y,8),Math.max(8,n));s.set(y,{x:Math.round(o),y:Math.round(r)},!0)}function B(e){e.pointerId===_&&(s.set(x,!1),_=null,window.removeEventListener("pointermove",C),window.removeEventListener("pointerup",B),window.removeEventListener("pointercancel",B))}const{addListener:O}=function(){function e(e,t,i){return"undefined"==typeof window?()=>{}:(window.addEventListener(e,t,i),()=>{window.removeEventListener(e,t,i)})}return{addListener:e,addListenerEffect:function(t,i,n){s.user_effect(()=>{if("undefined"!=typeof window)return e(t,i,n)})}}}();function T(){if("free"!==s.get(h)||!s.get(w))return;const e=s.get(w).getBoundingClientRect(),t=b(s.get(y).x,s.get(y).y,e.width,e.height);t.x===s.get(y).x&&t.y===s.get(y).y||s.set(y,{x:Math.round(t.x),y:Math.round(t.y)},!0)}s.user_effect(()=>{"undefined"!=typeof window&&O("resize",T)});var R={setDockOrientation:function(e){s.set(f,e,!0)},setDockFreePosition:function(e){s.set(y,e,!0)},getDockState:function(){return{dockPosition:s.get(h),dockOrientation:s.get(f),dockFreePosition:s.get(y),dockLabelMode:s.get(p)}}};return Be(e,{get target(){return s.get(d).portalTarget},children:(e,t)=>{var i=rt();let n,d;var g=s.child(i);let m;var v=s.child(g),z=e=>{var t=Ze();let i;t.__pointerdown=D,s.template_effect(()=>i=s.set_class(t,1,"modal-dock-handle",null,i,{"modal-dock-handle-dragging":s.get(x)})),s.append(e,t)};s.if(v,e=>{"free"===s.get(h)&&e(z)});var I=s.sibling(v,2);s.each(I,19,()=>s.get(M),e=>e.id,(e,t,i)=>{const n=s.derived(()=>s.get(t).lastChildId?r.modals.get(s.get(t).lastChildId):null);var d=ot();let l;d.__click=e=>{var i;i=s.get(t).id,N.has(i)?e.currentTarget.animate([{transform:"translateX(0)"},{transform:"translateX(-6px)"},{transform:"translateX(6px)"},{transform:"translateX(-6px)"},{transform:"translateX(6px)"},{transform:"translateX(0)"}],{duration:300,easing:"ease-in-out"}):Q(s.get(t).id)};var c=s.child(d),g=s.child(c),h=e=>{var i=s.comment(),n=s.first_child(i);s.snippet(n,()=>s.get(o),()=>s.get(t).icon),s.append(e,i)},f=e=>{var i=et(),n=s.child(i,!0);s.reset(i),s.template_effect(e=>s.set_text(n,e),[()=>s.get(t).title.charAt(0)]),s.append(e,i)};s.if(g,e=>{s.get(t).icon&&s.get(o)?e(h):e(f,!1)}),s.reset(c);var m=s.sibling(c,2),v=e=>{var i=tt(),n=s.child(i,!0);s.reset(i),s.template_effect(()=>s.set_text(n,s.get(t).title)),s.append(e,i)};s.if(m,e=>{"hidden"!==s.get(p)&&e(v)});var y=s.sibling(m,4),w=e=>{var t=nt(),i=s.child(t),r=e=>{var t=s.comment(),i=s.first_child(t);s.snippet(i,()=>s.get(o),()=>s.get(n).icon),s.append(e,t)},d=e=>{var t=it();s.append(e,t)};s.if(i,e=>{s.get(n).icon&&s.get(o)?e(r):e(d,!1)}),s.reset(t),s.append(e,t)};s.if(y,e=>{s.get(t).lastChildId&&s.get(n)&&e(w)}),s.reset(d),s.template_effect(e=>{l=s.set_class(d,1,"modal-dock-item",null,l,{"modal-dock-item-has-glow":!!s.get(t).glow,"modal-dock-item-has-child":!!s.get(t).lastChildId,"modal-dock-item-label-beside":"beside"===s.get(p),"modal-dock-item-label-below":"below"===s.get(p)}),s.set_attribute(d,"data-modal-id",e),s.set_style(d,s.get(t).glow?`--modal-dock-glow-color: ${s.get(t).glow.color};`:"")},[()=>P(s.get(t).id)]),s.transition(3,d,()=>a,()=>({duration:300,delay:50*s.get(i),easing:u,start:.5})),s.append(e,d)}),s.reset(g),s.reset(i),s.bind_this(i,e=>s.set(w,e),()=>s.get(w)),s.template_effect(()=>{n=s.set_class(i,1,"modal-dock-container",null,n,{"modal-dock-left":"left"===s.get(h),"modal-dock-right":"right"===s.get(h),"modal-dock-bottom":"bottom"===s.get(h),"modal-dock-free":"free"===s.get(h),"modal-dock-empty":0===s.get(M).length}),d=s.set_style(i,"free"===s.get(h)?`left: ${s.get(y).x}px; top: ${s.get(y).y}px;`:"",d,{"z-index":s.get(c)}),m=s.set_class(g,1,"modal-dock",null,m,{"modal-dock-free-horizontal":"free"===s.get(h)&&"horizontal"===s.get(f),"modal-dock-free-vertical":"free"===s.get(h)&&"vertical"===s.get(f)})}),s.transition(3,i,()=>l,()=>s.get(M).length>0?s.get(k):{duration:0}),s.append(e,i)},$$slots:{default:!0}}),s.pop(R)}s.delegate(["pointerdown","click"]);var st=s.from_html('<div class="modal-backdrop svelte-1d3nq4t" aria-hidden="true"></div>');function at(e,t){s.push(t,!0);const i=ve(),n=s.derived(()=>(m(),v())),o=s.derived(()=>s.get(n).features.backdrop),r=s.derived(()=>(ae(),Array.from(i.modals.values()).some(e=>e.isOpen&&!e.isMinimized&&!e.isHiddenWithParent))),d=s.derived(()=>s.get(o)&&s.get(r)),a=s.derived(()=>z("MODAL")-1);Be(e,{get target(){return s.get(n).portalTarget},children:(e,t)=>{var i=s.comment(),n=s.first_child(i),o=e=>{var t=st();let i;s.template_effect(()=>i=s.set_style(t,"",i,{"z-index":s.get(a)})),s.transition(3,t,()=>c,()=>({duration:200})),s.append(e,t)};s.if(n,e=>{s.get(d)&&e(o)}),s.append(e,i)},$$slots:{default:!0}}),s.pop()}function lt(e){const{content:t,footer:i,icon:n,...o}=e,s=r(Je,{target:document.body,props:{...o,children:t?()=>gt(t):void 0,footer:i?()=>gt(i):void 0,icon:n?()=>gt(n):void 0}});return{destroy:()=>d(s)}}function ct(){const e=r(dt,{target:document.body,props:{}});return{destroy:()=>d(e)}}function gt(e){if("string"==typeof e){const t=document.createElement("div");return t.innerHTML=e,t}return e}function ut(){const e=r(at,{target:document.body,props:{}});return{destroy:()=>d(e)}}function ht(e={}){const{config:t}=e;t&&y(t),s.set(x,v().zIndex.base,!0);const i=v(),n=e.backdrop??i.features.backdrop?ut():null,o=e.dock??i.features.dock?ct():null;return{backdrop:n,dock:o,destroy:()=>{null==n||n.destroy(),null==o||o.destroy()}}}export{te as bringToFront,oe as closeAllModals,ne as closeModal,ut as createBackdrop,ct as createDock,lt as createModal,v as getConfig,ht as init,fe as isModalOpen,me as isModalRegistered,U as minimizeModal,re as openChildModal,ie as openModal,Q as restoreModal,y as setConfig,ye as toggleModalTransparency};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "epic-modals",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "A stunning modal library with macOS-style animations, drag, resize, and dock. Supports Svelte 5, React, and vanilla JS.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"modal",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
],
|
|
51
51
|
"scripts": {
|
|
52
52
|
"dev": "vite dev",
|
|
53
|
-
"build": "ENTRY=index vite build --mode development && ENTRY=svelte vite build --mode development && ENTRY=react vite build --mode development && ENTRY=vanilla vite build --mode development",
|
|
53
|
+
"build": "ENTRY=index vite build --mode development && ENTRY=svelte vite build --mode development && ENTRY=react vite build --mode development && ENTRY=vanilla vite build --mode development && node scripts/build-css.js",
|
|
54
54
|
"build:prod": "ENTRY=index vite build && ENTRY=svelte vite build && ENTRY=react vite build && ENTRY=vanilla vite build && node scripts/build-css.js",
|
|
55
55
|
"check": "svelte-check --tsconfig ./tsconfig.json",
|
|
56
56
|
"test": "vitest run",
|