var Tn=Object.defineProperty;var Mn=(e,t,n)=>t in e?Tn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var lt=(e,t,n)=>Mn(e,typeof t!="symbol"?t+"":t,n);import{r as l,R as j,d as Oe,j as T}from"./react-vendor-jWT2yUdV.js";import{c as Fe,L as ct,u as Nn,k as An,b as jt}from"./index-DiaaLdUu.js";import{z as Bt}from"./react-hot-toast-cGcFZPSt.js";import{p as On,x as Ft}from"./index-FvTxWQTZ.js";import{X as kn}from"./xterm-m1lN6Krd.js";import"./qface-BZLvZXJ8.js";import"./react-router-dom-C6k78GT4.js";import"./iconBase-B7bT1FlI.js";function Ln(){for(var e=arguments.length,t=new Array(e),n=0;nr=>{t.forEach(o=>o(r))},t)}const nt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ye(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function wt(e){return"nodeType"in e}function B(e){var t,n;return e?ye(e)?e:wt(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function xt(e){const{Document:t}=B(e);return e instanceof t}function $e(e){return ye(e)?!1:e instanceof B(e).HTMLElement}function Zt(e){return e instanceof B(e).SVGElement}function De(e){return e?ye(e)?e.document:wt(e)?xt(e)?e:$e(e)||Zt(e)?e.ownerDocument:document:document:document}const Q=nt?l.useLayoutEffect:l.useEffect;function yt(e){const t=l.useRef(e);return Q(()=>{t.current=e}),l.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o{e.current=setInterval(r,o)},[]),n=l.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Pe(e,t){t===void 0&&(t=[e]);const n=l.useRef(e);return Q(()=>{n.current!==e&&(n.current=e)},t),n}function Xe(e,t){const n=l.useRef();return l.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Ze(e){const t=yt(e),n=l.useRef(null),r=l.useCallback(o=>{o!==n.current&&(t==null||t(o,n.current)),n.current=o},[]);return[n,r]}function gt(e){const t=l.useRef();return l.useEffect(()=>{t.current=e},[e]),t.current}let ut={};function Ue(e,t){return l.useMemo(()=>{if(t)return t;const n=ut[e]==null?0:ut[e]+1;return ut[e]=n,e+"-"+n},[e,t])}function Qt(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o{const a=Object.entries(i);for(const[c,d]of a){const u=s[c];u!=null&&(s[c]=u+e*d)}return s},{...t})}}const xe=Qt(1),Qe=Qt(-1);function Pn(e){return"clientX"in e&&"clientY"in e}function Dt(e){if(!e)return!1;const{KeyboardEvent:t}=B(e.target);return t&&e instanceof t}function jn(e){if(!e)return!1;const{TouchEvent:t}=B(e.target);return t&&e instanceof t}function vt(e){if(jn(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Pn(e)?{x:e.clientX,y:e.clientY}:null}const je=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[je.Translate.toString(e),je.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),$t="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Bn(e){return e.matches($t)?e:e.querySelector($t)}const Fn={display:"none"};function $n(e){let{id:t,value:n}=e;return j.createElement("div",{id:t,style:Fn},n)}function Xn(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return j.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function Un(){const[e,t]=l.useState("");return{announce:l.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const en=l.createContext(null);function Wn(e){const t=l.useContext(en);l.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of ");return t(e)},[e,t])}function Yn(){const[e]=l.useState(()=>new Set),t=l.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[l.useCallback(r=>{let{type:o,event:s}=r;e.forEach(i=>{var a;return(a=i[o])==null?void 0:a.call(i,s)})},[e]),t]}const Kn={draggable:` To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel. `},Hn={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Vn(e){let{announcements:t=Hn,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=Kn}=e;const{announce:s,announcement:i}=Un(),a=Ue("DndLiveRegion"),[c,d]=l.useState(!1);if(l.useEffect(()=>{d(!0)},[]),Wn(l.useMemo(()=>({onDragStart(f){let{active:h}=f;s(t.onDragStart({active:h}))},onDragMove(f){let{active:h,over:g}=f;t.onDragMove&&s(t.onDragMove({active:h,over:g}))},onDragOver(f){let{active:h,over:g}=f;s(t.onDragOver({active:h,over:g}))},onDragEnd(f){let{active:h,over:g}=f;s(t.onDragEnd({active:h,over:g}))},onDragCancel(f){let{active:h,over:g}=f;s(t.onDragCancel({active:h,over:g}))}}),[s,t])),!c)return null;const u=j.createElement(j.Fragment,null,j.createElement($n,{id:r,value:o.draggable}),j.createElement(Xn,{id:a,announcement:i}));return n?Oe.createPortal(u,n):u}var A;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(A||(A={}));function et(){}function qn(e,t){return l.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function _n(){for(var e=arguments.length,t=new Array(e),n=0;n[...t].filter(r=>r!=null),[...t])}const q=Object.freeze({x:0,y:0});function Jn(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Gn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Zn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Qn(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function Xt(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const er=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Xt(t,t.left,t.top),s=[];for(const i of r){const{id:a}=i,c=n.get(a);if(c){const d=Jn(Xt(c),o);s.push({id:a,data:{droppableContainer:i,value:d}})}}return s.sort(Gn)};function tr(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),i=o-r,a=s-n;if(r{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const s of r){const{id:i}=s,a=n.get(i);if(a){const c=tr(a,t);c>0&&o.push({id:i,data:{droppableContainer:s,value:c}})}}return o.sort(Zn)};function rr(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function tn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:q}function or(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),s=1;s({...i,top:i.top+e*a.y,bottom:i.bottom+e*a.y,left:i.left+e*a.x,right:i.right+e*a.x}),{...n})}}const sr=or(1);function ir(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function ar(e,t,n){const r=ir(t);if(!r)return e;const{scaleX:o,scaleY:s,x:i,y:a}=r,c=e.left-i-(1-o)*parseFloat(n),d=e.top-a-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),u=o?e.width/o:e.width,f=s?e.height/s:e.height;return{width:u,height:f,top:d,right:c+u,bottom:d+f,left:c}}const lr={ignoreTransform:!1};function Se(e,t){t===void 0&&(t=lr);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:d,transformOrigin:u}=B(e).getComputedStyle(e);d&&(n=ar(n,d,u))}const{top:r,left:o,width:s,height:i,bottom:a,right:c}=n;return{top:r,left:o,width:s,height:i,bottom:a,right:c}}function Ut(e){return Se(e,{ignoreTransform:!0})}function cr(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function ur(e,t){return t===void 0&&(t=B(e).getComputedStyle(e)),t.position==="fixed"}function dr(e,t){t===void 0&&(t=B(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const s=t[o];return typeof s=="string"?n.test(s):!1})}function St(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(xt(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!$e(o)||Zt(o)||n.includes(o))return n;const s=B(e).getComputedStyle(o);return o!==e&&dr(o,s)&&n.push(o),ur(o,s)?n:r(o.parentNode)}return e?r(e):n}function nn(e){const[t]=St(e,1);return t??null}function dt(e){return!nt||!e?null:ye(e)?e:wt(e)?xt(e)||e===De(e).scrollingElement?window:$e(e)?e:null:null}function rn(e){return ye(e)?e.scrollX:e.scrollLeft}function on(e){return ye(e)?e.scrollY:e.scrollTop}function pt(e){return{x:rn(e),y:on(e)}}var k;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(k||(k={}));function sn(e){return!nt||!e?!1:e===document.scrollingElement}function an(e){const t={x:0,y:0},n=sn(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,s=e.scrollLeft<=t.x,i=e.scrollTop>=r.y,a=e.scrollLeft>=r.x;return{isTop:o,isLeft:s,isBottom:i,isRight:a,maxScroll:r,minScroll:t}}const fr={x:.2,y:.2};function hr(e,t,n,r,o){let{top:s,left:i,right:a,bottom:c}=n;r===void 0&&(r=10),o===void 0&&(o=fr);const{isTop:d,isBottom:u,isLeft:f,isRight:h}=an(e),g={x:0,y:0},S={x:0,y:0},v={height:t.height*o.y,width:t.width*o.x};return!d&&s<=t.top+v.height?(g.y=k.Backward,S.y=r*Math.abs((t.top+v.height-s)/v.height)):!u&&c>=t.bottom-v.height&&(g.y=k.Forward,S.y=r*Math.abs((t.bottom-v.height-c)/v.height)),!h&&a>=t.right-v.width?(g.x=k.Forward,S.x=r*Math.abs((t.right-v.width-a)/v.width)):!f&&i<=t.left+v.width&&(g.x=k.Backward,S.x=r*Math.abs((t.left+v.width-i)/v.width)),{direction:g,speed:S}}function gr(e){if(e===document.scrollingElement){const{innerWidth:s,innerHeight:i}=window;return{top:0,left:0,right:s,bottom:i,width:s,height:i}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function ln(e){return e.reduce((t,n)=>xe(t,pt(n)),q)}function vr(e){return e.reduce((t,n)=>t+rn(n),0)}function pr(e){return e.reduce((t,n)=>t+on(n),0)}function br(e,t){if(t===void 0&&(t=Se),!e)return;const{top:n,left:r,bottom:o,right:s}=t(e);nn(e)&&(o<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const mr=[["x",["left","right"],vr],["y",["top","bottom"],pr]];class Ct{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=St(n),o=ln(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[s,i,a]of mr)for(const c of i)Object.defineProperty(this,c,{get:()=>{const d=a(r),u=o[s]-d;return this.rect[c]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class ke{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function wr(e){const{EventTarget:t}=B(e);return e instanceof t?e:De(e)}function ft(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var K;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(K||(K={}));function Wt(e){e.preventDefault()}function xr(e){e.stopPropagation()}var D;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(D||(D={}));const cn={start:[D.Space,D.Enter],cancel:[D.Esc],end:[D.Space,D.Enter,D.Tab]},yr=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case D.Right:return{...n,x:n.x+25};case D.Left:return{...n,x:n.x-25};case D.Down:return{...n,y:n.y+25};case D.Up:return{...n,y:n.y-25}}};class un{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new ke(De(n)),this.windowListeners=new ke(B(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(K.Resize,this.handleCancel),this.windowListeners.add(K.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(K.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&br(r),n(q)}handleKeyDown(t){if(Dt(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:s=cn,coordinateGetter:i=yr,scrollBehavior:a="smooth"}=o,{code:c}=t;if(s.end.includes(c)){this.handleEnd(t);return}if(s.cancel.includes(c)){this.handleCancel(t);return}const{collisionRect:d}=r.current,u=d?{x:d.left,y:d.top}:q;this.referenceCoordinates||(this.referenceCoordinates=u);const f=i(t,{active:n,context:r.current,currentCoordinates:u});if(f){const h=Qe(f,u),g={x:0,y:0},{scrollableAncestors:S}=r.current;for(const v of S){const p=t.code,{isTop:w,isRight:y,isLeft:b,isBottom:C,maxScroll:R,minScroll:E}=an(v),x=gr(v),m={x:Math.min(p===D.Right?x.right-x.width/2:x.right,Math.max(p===D.Right?x.left:x.left+x.width/2,f.x)),y:Math.min(p===D.Down?x.bottom-x.height/2:x.bottom,Math.max(p===D.Down?x.top:x.top+x.height/2,f.y))},N=p===D.Right&&!y||p===D.Left&&!b,O=p===D.Down&&!C||p===D.Up&&!w;if(N&&m.x!==f.x){const M=v.scrollLeft+h.x,H=p===D.Right&&M<=R.x||p===D.Left&&M>=E.x;if(H&&!h.y){v.scrollTo({left:M,behavior:a});return}H?g.x=v.scrollLeft-M:g.x=p===D.Right?v.scrollLeft-R.x:v.scrollLeft-E.x,g.x&&v.scrollBy({left:-g.x,behavior:a});break}else if(O&&m.y!==f.y){const M=v.scrollTop+h.y,H=p===D.Down&&M<=R.y||p===D.Up&&M>=E.y;if(H&&!h.x){v.scrollTo({top:M,behavior:a});return}H?g.y=v.scrollTop-M:g.y=p===D.Down?v.scrollTop-R.y:v.scrollTop-E.y,g.y&&v.scrollBy({top:-g.y,behavior:a});break}}this.handleMove(t,xe(Qe(f,this.referenceCoordinates),g))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}un.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=cn,onActivation:o}=t,{active:s}=n;const{code:i}=e.nativeEvent;if(r.start.includes(i)){const a=s.activatorNode.current;return a&&e.target!==a?!1:(e.preventDefault(),o==null||o({event:e.nativeEvent}),!0)}return!1}}];function Yt(e){return!!(e&&"distance"in e)}function Kt(e){return!!(e&&"delay"in e)}class Rt{constructor(t,n,r){var o;r===void 0&&(r=wr(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:s}=t,{target:i}=s;this.props=t,this.events=n,this.document=De(i),this.documentListeners=new ke(this.document),this.listeners=new ke(r),this.windowListeners=new ke(B(i)),this.initialCoordinates=(o=vt(s))!=null?o:q,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(K.Resize,this.handleCancel),this.windowListeners.add(K.DragStart,Wt),this.windowListeners.add(K.VisibilityChange,this.handleCancel),this.windowListeners.add(K.ContextMenu,Wt),this.documentListeners.add(K.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Kt(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Yt(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(K.Click,xr,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(K.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:s}=this,{onMove:i,options:{activationConstraint:a}}=s;if(!o)return;const c=(n=vt(t))!=null?n:q,d=Qe(o,c);if(!r&&a){if(Yt(a)){if(a.tolerance!=null&&ft(d,a.tolerance))return this.handleCancel();if(ft(d,a.distance))return this.handleStart()}if(Kt(a)&&ft(d,a.tolerance))return this.handleCancel();this.handlePending(a,d);return}t.cancelable&&t.preventDefault(),i(c)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===D.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Dr={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Et extends Rt{constructor(t){const{event:n}=t,r=De(n.target);super(t,Dr,r)}}Et.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r==null||r({event:n}),!0)}}];const Sr={move:{name:"mousemove"},end:{name:"mouseup"}};var bt;(function(e){e[e.RightClick=2]="RightClick"})(bt||(bt={}));class Cr extends Rt{constructor(t){super(t,Sr,De(t.event.target))}}Cr.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===bt.RightClick?!1:(r==null||r({event:n}),!0)}}];const ht={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Rr extends Rt{constructor(t){super(t,ht)}static setup(){return window.addEventListener(ht.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(ht.move.name,t)};function t(){}}}Rr.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r==null||r({event:n}),!0)}}];var Le;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Le||(Le={}));var tt;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(tt||(tt={}));function Er(e){let{acceleration:t,activator:n=Le.Pointer,canScroll:r,draggingRect:o,enabled:s,interval:i=5,order:a=tt.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:u,delta:f,threshold:h}=e;const g=Tr({delta:f,disabled:!s}),[S,v]=zn(),p=l.useRef({x:0,y:0}),w=l.useRef({x:0,y:0}),y=l.useMemo(()=>{switch(n){case Le.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Le.DraggableRect:return o}},[n,o,c]),b=l.useRef(null),C=l.useCallback(()=>{const E=b.current;if(!E)return;const x=p.current.x*w.current.x,m=p.current.y*w.current.y;E.scrollBy(x,m)},[]),R=l.useMemo(()=>a===tt.TreeOrder?[...d].reverse():d,[a,d]);l.useEffect(()=>{if(!s||!d.length||!y){v();return}for(const E of R){if((r==null?void 0:r(E))===!1)continue;const x=d.indexOf(E),m=u[x];if(!m)continue;const{direction:N,speed:O}=hr(E,m,y,t,h);for(const M of["x","y"])g[M][N[M]]||(O[M]=0,N[M]=0);if(O.x>0||O.y>0){v(),b.current=E,S(C,i),p.current=O,w.current=N;return}}p.current={x:0,y:0},w.current={x:0,y:0},v()},[t,C,r,v,s,i,JSON.stringify(y),JSON.stringify(g),S,d,R,u,JSON.stringify(h)])}const Ir={x:{[k.Backward]:!1,[k.Forward]:!1},y:{[k.Backward]:!1,[k.Forward]:!1}};function Tr(e){let{delta:t,disabled:n}=e;const r=gt(t);return Xe(o=>{if(n||!r||!o)return Ir;const s={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[k.Backward]:o.x[k.Backward]||s.x===-1,[k.Forward]:o.x[k.Forward]||s.x===1},y:{[k.Backward]:o.y[k.Backward]||s.y===-1,[k.Forward]:o.y[k.Forward]||s.y===1}}},[n,t,r])}function Mr(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Xe(o=>{var s;return t==null?null:(s=r??o)!=null?s:null},[r,t])}function Nr(e,t){return l.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,s=o.activators.map(i=>({eventName:i.eventName,handler:t(i.handler,r)}));return[...n,...s]},[]),[e,t])}var Be;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Be||(Be={}));var mt;(function(e){e.Optimized="optimized"})(mt||(mt={}));const Ht=new Map;function Ar(e,t){let{dragging:n,dependencies:r,config:o}=t;const[s,i]=l.useState(null),{frequency:a,measure:c,strategy:d}=o,u=l.useRef(e),f=p(),h=Pe(f),g=l.useCallback(function(w){w===void 0&&(w=[]),!h.current&&i(y=>y===null?w:y.concat(w.filter(b=>!y.includes(b))))},[h]),S=l.useRef(null),v=Xe(w=>{if(f&&!n)return Ht;if(!w||w===Ht||u.current!==e||s!=null){const y=new Map;for(let b of e){if(!b)continue;if(s&&s.length>0&&!s.includes(b.id)&&b.rect.current){y.set(b.id,b.rect.current);continue}const C=b.node.current,R=C?new Ct(c(C),C):null;b.rect.current=R,R&&y.set(b.id,R)}return y}return w},[e,s,n,f,c]);return l.useEffect(()=>{u.current=e},[e]),l.useEffect(()=>{f||g()},[n,f]),l.useEffect(()=>{s&&s.length>0&&i(null)},[JSON.stringify(s)]),l.useEffect(()=>{f||typeof a!="number"||S.current!==null||(S.current=setTimeout(()=>{g(),S.current=null},a))},[a,f,g,...r]),{droppableRects:v,measureDroppableContainers:g,measuringScheduled:s!=null};function p(){switch(d){case Be.Always:return!1;case Be.BeforeDragging:return n;default:return!n}}}function dn(e,t){return Xe(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function Or(e,t){return dn(e,t)}function kr(e){let{callback:t,disabled:n}=e;const r=yt(t),o=l.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return l.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function rt(e){let{callback:t,disabled:n}=e;const r=yt(t),o=l.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return l.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function Lr(e){return new Ct(Se(e),e)}function Vt(e,t,n){t===void 0&&(t=Lr);const[r,o]=l.useState(null);function s(){o(c=>{if(!e)return null;if(e.isConnected===!1){var d;return(d=c??n)!=null?d:null}const u=t(e);return JSON.stringify(c)===JSON.stringify(u)?c:u})}const i=kr({callback(c){if(e)for(const d of c){const{type:u,target:f}=d;if(u==="childList"&&f instanceof HTMLElement&&f.contains(e)){s();break}}}}),a=rt({callback:s});return Q(()=>{s(),e?(a==null||a.observe(e),i==null||i.observe(document.body,{childList:!0,subtree:!0})):(a==null||a.disconnect(),i==null||i.disconnect())},[e]),r}function zr(e){const t=dn(e);return tn(e,t)}const qt=[];function Pr(e){const t=l.useRef(e),n=Xe(r=>e?r&&r!==qt&&e&&t.current&&e.parentNode===t.current.parentNode?r:St(e):qt,[e]);return l.useEffect(()=>{t.current=e},[e]),n}function jr(e){const[t,n]=l.useState(null),r=l.useRef(e),o=l.useCallback(s=>{const i=dt(s.target);i&&n(a=>a?(a.set(i,pt(i)),new Map(a)):null)},[]);return l.useEffect(()=>{const s=r.current;if(e!==s){i(s);const a=e.map(c=>{const d=dt(c);return d?(d.addEventListener("scroll",o,{passive:!0}),[d,pt(d)]):null}).filter(c=>c!=null);n(a.length?new Map(a):null),r.current=e}return()=>{i(e),i(s)};function i(a){a.forEach(c=>{const d=dt(c);d==null||d.removeEventListener("scroll",o)})}},[o,e]),l.useMemo(()=>e.length?t?Array.from(t.values()).reduce((s,i)=>xe(s,i),q):ln(e):q,[e,t])}function _t(e,t){t===void 0&&(t=[]);const n=l.useRef(null);return l.useEffect(()=>{n.current=null},t),l.useEffect(()=>{const r=e!==q;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?Qe(e,n.current):q}function Br(e){l.useEffect(()=>{if(!nt)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n==null||n()}},e.map(t=>{let{sensor:n}=t;return n}))}function Fr(e,t){return l.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:s}=r;return n[o]=i=>{s(i,t)},n},{}),[e,t])}function fn(e){return l.useMemo(()=>e?cr(e):null,[e])}const Jt=[];function $r(e,t){t===void 0&&(t=Se);const[n]=e,r=fn(n?B(n):null),[o,s]=l.useState(Jt);function i(){s(()=>e.length?e.map(c=>sn(c)?r:new Ct(t(c),c)):Jt)}const a=rt({callback:i});return Q(()=>{a==null||a.disconnect(),i(),e.forEach(c=>a==null?void 0:a.observe(c))},[e]),o}function Xr(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return $e(t)?t:e}function Ur(e){let{measure:t}=e;const[n,r]=l.useState(null),o=l.useCallback(d=>{for(const{target:u}of d)if($e(u)){r(f=>{const h=t(u);return f?{...f,width:h.width,height:h.height}:h});break}},[t]),s=rt({callback:o}),i=l.useCallback(d=>{const u=Xr(d);s==null||s.disconnect(),u&&(s==null||s.observe(u)),r(u?t(u):null)},[t,s]),[a,c]=Ze(i);return l.useMemo(()=>({nodeRef:a,rect:n,setRef:c}),[n,a,c])}const Wr=[{sensor:Et,options:{}},{sensor:un,options:{}}],Yr={current:{}},Ge={draggable:{measure:Ut},droppable:{measure:Ut,strategy:Be.WhileDragging,frequency:mt.Optimized},dragOverlay:{measure:Se}};class ze extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const Kr={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new ze,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:et},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ge,measureDroppableContainers:et,windowRect:null,measuringScheduled:!1},Hr={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:et,draggableNodes:new Map,over:null,measureDroppableContainers:et},ot=l.createContext(Hr),hn=l.createContext(Kr);function Vr(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ze}}}function qr(e,t){switch(t.type){case A.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case A.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case A.DragEnd:case A.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case A.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new ze(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case A.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,s=e.droppable.containers.get(n);if(!s||r!==s.key)return e;const i=new ze(e.droppable.containers);return i.set(n,{...s,disabled:o}),{...e,droppable:{...e.droppable,containers:i}}}case A.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const s=new ze(e.droppable.containers);return s.delete(n),{...e,droppable:{...e.droppable,containers:s}}}default:return e}}function _r(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=l.useContext(ot),s=gt(r),i=gt(n==null?void 0:n.id);return l.useEffect(()=>{if(!t&&!r&&s&&i!=null){if(!Dt(s)||document.activeElement===s.target)return;const a=o.get(i);if(!a)return;const{activatorNode:c,node:d}=a;if(!c.current&&!d.current)return;requestAnimationFrame(()=>{for(const u of[c.current,d.current]){if(!u)continue;const f=Bn(u);if(f){f.focus();break}}})}},[r,t,o,i,s]),null}function Jr(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,s)=>s({transform:o,...r}),n):n}function Gr(e){return l.useMemo(()=>({draggable:{...Ge.draggable,...e==null?void 0:e.draggable},droppable:{...Ge.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Ge.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function Zr(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const s=l.useRef(!1),{x:i,y:a}=typeof o=="boolean"?{x:o,y:o}:o;Q(()=>{if(!i&&!a||!t){s.current=!1;return}if(s.current||!r)return;const d=t==null?void 0:t.node.current;if(!d||d.isConnected===!1)return;const u=n(d),f=tn(u,r);if(i||(f.x=0),a||(f.y=0),s.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const h=nn(d);h&&h.scrollBy({top:f.y,left:f.x})}},[t,i,a,r,n])}const gn=l.createContext({...q,scaleX:1,scaleY:1});var de;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(de||(de={}));const Qr=l.memo(function(t){var n,r,o,s;let{id:i,accessibility:a,autoScroll:c=!0,children:d,sensors:u=Wr,collisionDetection:f=nr,measuring:h,modifiers:g,...S}=t;const v=l.useReducer(qr,void 0,Vr),[p,w]=v,[y,b]=Yn(),[C,R]=l.useState(de.Uninitialized),E=C===de.Initialized,{draggable:{active:x,nodes:m,translate:N},droppable:{containers:O}}=p,M=x!=null?m.get(x):null,H=l.useRef({initial:null,translated:null}),V=l.useMemo(()=>{var z;return x!=null?{id:x,data:(z=M==null?void 0:M.data)!=null?z:Yr,rect:H}:null},[x,M]),_=l.useRef(null),[Ce,We]=l.useState(null),[F,Ye]=l.useState(null),ee=Pe(S,Object.values(S)),Re=Ue("DndDescribedBy",i),Ke=l.useMemo(()=>O.getEnabled(),[O]),P=Gr(h),{droppableRects:te,measureDroppableContainers:he,measuringScheduled:Ee}=Ar(Ke,{dragging:E,dependencies:[N.x,N.y],config:P.droppable}),W=Mr(m,x),He=l.useMemo(()=>F?vt(F):null,[F]),se=In(),ne=Or(W,P.draggable.measure);Zr({activeNode:x!=null?m.get(x):null,config:se.layoutShiftCompensation,initialRect:ne,measure:P.draggable.measure});const I=Vt(W,P.draggable.measure,ne),Ie=Vt(W?W.parentElement:null),J=l.useRef({activatorEvent:null,active:null,activeNode:W,collisionRect:null,collisions:null,droppableRects:te,draggableNodes:m,draggingNode:null,draggingNodeRect:null,droppableContainers:O,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ge=O.getNodeFor((n=J.current.over)==null?void 0:n.id),re=Ur({measure:P.dragOverlay.measure}),ve=(r=re.nodeRef.current)!=null?r:W,pe=E?(o=re.rect)!=null?o:I:null,Mt=!!(re.nodeRef.current&&re.rect),Nt=zr(Mt?null:I),st=fn(ve?B(ve):null),ie=Pr(E?ge??W:null),Ve=$r(ie),qe=Jr(g,{transform:{x:N.x-Nt.x,y:N.y-Nt.y,scaleX:1,scaleY:1},activatorEvent:F,active:V,activeNodeRect:I,containerNodeRect:Ie,draggingNodeRect:pe,over:J.current.over,overlayNodeRect:re.rect,scrollableAncestors:ie,scrollableAncestorRects:Ve,windowRect:st}),At=He?xe(He,N):null,Ot=jr(ie),xn=_t(Ot),yn=_t(Ot,[I]),be=xe(qe,xn),me=pe?sr(pe,qe):null,Te=V&&me?f({active:V,collisionRect:me,droppableRects:te,droppableContainers:Ke,pointerCoordinates:At}):null,kt=Qn(Te,"id"),[ae,Lt]=l.useState(null),Dn=Mt?qe:xe(qe,yn),Sn=rr(Dn,(s=ae==null?void 0:ae.rect)!=null?s:null,I),it=l.useRef(null),zt=l.useCallback((z,$)=>{let{sensor:X,options:le}=$;if(_.current==null)return;const Y=m.get(_.current);if(!Y)return;const U=z.nativeEvent,G=new X({active:_.current,activeNode:Y,event:U,options:le,context:J,onAbort(L){if(!m.get(L))return;const{onDragAbort:Z}=ee.current,oe={id:L};Z==null||Z(oe),y({type:"onDragAbort",event:oe})},onPending(L,ce,Z,oe){if(!m.get(L))return;const{onDragPending:Ne}=ee.current,ue={id:L,constraint:ce,initialCoordinates:Z,offset:oe};Ne==null||Ne(ue),y({type:"onDragPending",event:ue})},onStart(L){const ce=_.current;if(ce==null)return;const Z=m.get(ce);if(!Z)return;const{onDragStart:oe}=ee.current,Me={activatorEvent:U,active:{id:ce,data:Z.data,rect:H}};Oe.unstable_batchedUpdates(()=>{oe==null||oe(Me),R(de.Initializing),w({type:A.DragStart,initialCoordinates:L,active:ce}),y({type:"onDragStart",event:Me}),We(it.current),Ye(U)})},onMove(L){w({type:A.DragMove,coordinates:L})},onEnd:we(A.DragEnd),onCancel:we(A.DragCancel)});it.current=G;function we(L){return async function(){const{active:Z,collisions:oe,over:Me,scrollAdjustedTranslate:Ne}=J.current;let ue=null;if(Z&&Ne){const{cancelDrop:Ae}=ee.current;ue={activatorEvent:U,active:Z,collisions:oe,delta:Ne,over:Me},L===A.DragEnd&&typeof Ae=="function"&&await Promise.resolve(Ae(ue))&&(L=A.DragCancel)}_.current=null,Oe.unstable_batchedUpdates(()=>{w({type:L}),R(de.Uninitialized),Lt(null),We(null),Ye(null),it.current=null;const Ae=L===A.DragEnd?"onDragEnd":"onDragCancel";if(ue){const at=ee.current[Ae];at==null||at(ue),y({type:Ae,event:ue})}})}}},[m]),Cn=l.useCallback((z,$)=>(X,le)=>{const Y=X.nativeEvent,U=m.get(le);if(_.current!==null||!U||Y.dndKit||Y.defaultPrevented)return;const G={active:U};z(X,$.options,G)===!0&&(Y.dndKit={capturedBy:$.sensor},_.current=le,zt(X,$))},[m,zt]),Pt=Nr(u,Cn);Br(u),Q(()=>{I&&C===de.Initializing&&R(de.Initialized)},[I,C]),l.useEffect(()=>{const{onDragMove:z}=ee.current,{active:$,activatorEvent:X,collisions:le,over:Y}=J.current;if(!$||!X)return;const U={active:$,activatorEvent:X,collisions:le,delta:{x:be.x,y:be.y},over:Y};Oe.unstable_batchedUpdates(()=>{z==null||z(U),y({type:"onDragMove",event:U})})},[be.x,be.y]),l.useEffect(()=>{const{active:z,activatorEvent:$,collisions:X,droppableContainers:le,scrollAdjustedTranslate:Y}=J.current;if(!z||_.current==null||!$||!Y)return;const{onDragOver:U}=ee.current,G=le.get(kt),we=G&&G.rect.current?{id:G.id,rect:G.rect.current,data:G.data,disabled:G.disabled}:null,L={active:z,activatorEvent:$,collisions:X,delta:{x:Y.x,y:Y.y},over:we};Oe.unstable_batchedUpdates(()=>{Lt(we),U==null||U(L),y({type:"onDragOver",event:L})})},[kt]),Q(()=>{J.current={activatorEvent:F,active:V,activeNode:W,collisionRect:me,collisions:Te,droppableRects:te,draggableNodes:m,draggingNode:ve,draggingNodeRect:pe,droppableContainers:O,over:ae,scrollableAncestors:ie,scrollAdjustedTranslate:be},H.current={initial:pe,translated:me}},[V,W,Te,me,m,ve,pe,te,O,ae,ie,be]),Er({...se,delta:N,draggingRect:me,pointerCoordinates:At,scrollableAncestors:ie,scrollableAncestorRects:Ve});const Rn=l.useMemo(()=>({active:V,activeNode:W,activeNodeRect:I,activatorEvent:F,collisions:Te,containerNodeRect:Ie,dragOverlay:re,draggableNodes:m,droppableContainers:O,droppableRects:te,over:ae,measureDroppableContainers:he,scrollableAncestors:ie,scrollableAncestorRects:Ve,measuringConfiguration:P,measuringScheduled:Ee,windowRect:st}),[V,W,I,F,Te,Ie,re,m,O,te,ae,he,ie,Ve,P,Ee,st]),En=l.useMemo(()=>({activatorEvent:F,activators:Pt,active:V,activeNodeRect:I,ariaDescribedById:{draggable:Re},dispatch:w,draggableNodes:m,over:ae,measureDroppableContainers:he}),[F,Pt,V,I,w,Re,m,ae,he]);return j.createElement(en.Provider,{value:b},j.createElement(ot.Provider,{value:En},j.createElement(hn.Provider,{value:Rn},j.createElement(gn.Provider,{value:Sn},d)),j.createElement(_r,{disabled:(a==null?void 0:a.restoreFocus)===!1})),j.createElement(Vn,{...a,hiddenTextDescribedById:Re}));function In(){const z=(Ce==null?void 0:Ce.autoScrollEnabled)===!1,$=typeof c=="object"?c.enabled===!1:c===!1,X=E&&!z&&!$;return typeof c=="object"?{...c,enabled:X}:{enabled:X}}}),eo=l.createContext(null),Gt="button",to="Draggable";function no(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const s=Ue(to),{activators:i,activatorEvent:a,active:c,activeNodeRect:d,ariaDescribedById:u,draggableNodes:f,over:h}=l.useContext(ot),{role:g=Gt,roleDescription:S="draggable",tabIndex:v=0}=o??{},p=(c==null?void 0:c.id)===t,w=l.useContext(p?gn:eo),[y,b]=Ze(),[C,R]=Ze(),E=Fr(i,t),x=Pe(n);Q(()=>(f.set(t,{id:t,key:s,node:y,activatorNode:C,data:x}),()=>{const N=f.get(t);N&&N.key===s&&f.delete(t)}),[f,t]);const m=l.useMemo(()=>({role:g,tabIndex:v,"aria-disabled":r,"aria-pressed":p&&g===Gt?!0:void 0,"aria-roledescription":S,"aria-describedby":u.draggable}),[r,g,v,p,S,u.draggable]);return{active:c,activatorEvent:a,activeNodeRect:d,attributes:m,isDragging:p,listeners:r?void 0:E,node:y,over:h,setNodeRef:b,setActivatorNodeRef:R,transform:w}}function ro(){return l.useContext(hn)}const oo="Droppable",so={timeout:25};function io(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const s=Ue(oo),{active:i,dispatch:a,over:c,measureDroppableContainers:d}=l.useContext(ot),u=l.useRef({disabled:n}),f=l.useRef(!1),h=l.useRef(null),g=l.useRef(null),{disabled:S,updateMeasurementsFor:v,timeout:p}={...so,...o},w=Pe(v??r),y=l.useCallback(()=>{if(!f.current){f.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{d(Array.isArray(w.current)?w.current:[w.current]),g.current=null},p)},[p]),b=rt({callback:y,disabled:S||!i}),C=l.useCallback((m,N)=>{b&&(N&&(b.unobserve(N),f.current=!1),m&&b.observe(m))},[b]),[R,E]=Ze(C),x=Pe(t);return l.useEffect(()=>{!b||!R.current||(b.disconnect(),f.current=!1,b.observe(R.current))},[R,b]),l.useEffect(()=>(a({type:A.RegisterDroppable,element:{id:r,key:s,disabled:n,node:R,rect:h,data:x}}),()=>a({type:A.UnregisterDroppable,key:s,id:r})),[r]),l.useEffect(()=>{n!==u.current.disabled&&(a({type:A.SetDroppableDisabled,id:r,key:s,disabled:n}),u.current.disabled=n)},[r,s,n,a]),{active:i,rect:h,isOver:(c==null?void 0:c.id)===r,node:R,over:c,setNodeRef:E}}function It(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function ao(e,t){return e.reduce((n,r,o)=>{const s=t.get(r);return s&&(n[o]=s),n},Array(e.length))}function _e(e){return e!==null&&e>=0}function lo(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n{var t;let{rects:n,activeNodeRect:r,activeIndex:o,overIndex:s,index:i}=e;const a=(t=n[o])!=null?t:r;if(!a)return null;const c=fo(n,i,o);if(i===o){const d=n[s];return d?{x:oo&&i<=s?{x:-a.width-c,y:0,...Je}:i=s?{x:a.width+c,y:0,...Je}:{x:0,y:0,...Je}};function fo(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];return!r||!o&&!s?0:n{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const s=It(t,r,n),i=t[o],a=s[o];return!a||!i?null:{x:a.left-i.left,y:a.top-i.top,scaleX:a.width/i.width,scaleY:a.height/i.height}},pn="Sortable",bn=j.createContext({activeIndex:-1,containerId:pn,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:vn,disabled:{draggable:!1,droppable:!1}});function ho(e){let{children:t,id:n,items:r,strategy:o=vn,disabled:s=!1}=e;const{active:i,dragOverlay:a,droppableRects:c,over:d,measureDroppableContainers:u}=ro(),f=Ue(pn,n),h=a.rect!==null,g=l.useMemo(()=>r.map(E=>typeof E=="object"&&"id"in E?E.id:E),[r]),S=i!=null,v=i?g.indexOf(i.id):-1,p=d?g.indexOf(d.id):-1,w=l.useRef(g),y=!lo(g,w.current),b=p!==-1&&v===-1||y,C=co(s);Q(()=>{y&&S&&u(g)},[y,g,S,u]),l.useEffect(()=>{w.current=g},[g]);const R=l.useMemo(()=>({activeIndex:v,containerId:f,disabled:C,disableTransforms:b,items:g,overIndex:p,useDragOverlay:h,sortedRects:ao(g,c),strategy:o}),[v,f,C.draggable,C.droppable,b,g,p,c,h,o]);return j.createElement(bn.Provider,{value:R},t)}const go=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return It(n,r,o).indexOf(t)},vo=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:s,newIndex:i,previousItems:a,previousContainerId:c,transition:d}=e;return!d||!r||a!==s&&o===i?!1:n?!0:i!==o&&t===c},po={duration:200,easing:"ease"},mn="transform",bo=je.Transition.toString({property:mn,duration:0,easing:"linear"}),mo={roleDescription:"sortable"};function wo(e){let{disabled:t,index:n,node:r,rect:o}=e;const[s,i]=l.useState(null),a=l.useRef(n);return Q(()=>{if(!t&&n!==a.current&&r.current){const c=o.current;if(c){const d=Se(r.current,{ignoreTransform:!0}),u={x:c.left-d.left,y:c.top-d.top,scaleX:c.width/d.width,scaleY:c.height/d.height};(u.x||u.y)&&i(u)}}n!==a.current&&(a.current=n)},[t,n,r,o]),l.useEffect(()=>{s&&i(null)},[s]),s}function xo(e){let{animateLayoutChanges:t=vo,attributes:n,disabled:r,data:o,getNewIndex:s=go,id:i,strategy:a,resizeObserverConfig:c,transition:d=po}=e;const{items:u,containerId:f,activeIndex:h,disabled:g,disableTransforms:S,sortedRects:v,overIndex:p,useDragOverlay:w,strategy:y}=l.useContext(bn),b=yo(r,g),C=u.indexOf(i),R=l.useMemo(()=>({sortable:{containerId:f,index:C,items:u},...o}),[f,o,C,u]),E=l.useMemo(()=>u.slice(u.indexOf(i)),[u,i]),{rect:x,node:m,isOver:N,setNodeRef:O}=io({id:i,data:R,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:E,...c}}),{active:M,activatorEvent:H,activeNodeRect:V,attributes:_,setNodeRef:Ce,listeners:We,isDragging:F,over:Ye,setActivatorNodeRef:ee,transform:Re}=no({id:i,data:R,attributes:{...mo,...n},disabled:b.draggable}),Ke=Ln(O,Ce),P=!!M,te=P&&!S&&_e(h)&&_e(p),he=!w&&F,Ee=he&&te?Re:null,He=te?Ee??(a??y)({rects:v,activeNodeRect:V,activeIndex:h,overIndex:p,index:C}):null,se=_e(h)&&_e(p)?s({id:i,items:u,activeIndex:h,overIndex:p}):C,ne=M==null?void 0:M.id,I=l.useRef({activeId:ne,items:u,newIndex:se,containerId:f}),Ie=u!==I.current.items,J=t({active:M,containerId:f,isDragging:F,isSorting:P,id:i,index:C,items:u,newIndex:I.current.newIndex,previousItems:I.current.items,previousContainerId:I.current.containerId,transition:d,wasDragging:I.current.activeId!=null}),ge=wo({disabled:!J,index:C,node:m,rect:x});return l.useEffect(()=>{P&&I.current.newIndex!==se&&(I.current.newIndex=se),f!==I.current.containerId&&(I.current.containerId=f),u!==I.current.items&&(I.current.items=u)},[P,se,f,u]),l.useEffect(()=>{if(ne===I.current.activeId)return;if(ne!=null&&I.current.activeId==null){I.current.activeId=ne;return}const ve=setTimeout(()=>{I.current.activeId=ne},50);return()=>clearTimeout(ve)},[ne]),{active:M,activeIndex:h,attributes:_,data:R,rect:x,index:C,newIndex:se,items:u,isOver:N,isSorting:P,isDragging:F,listeners:We,node:m,overIndex:p,over:Ye,setNodeRef:Ke,setActivatorNodeRef:ee,setDroppableNodeRef:O,setDraggableNodeRef:Ce,transform:ge??He,transition:re()};function re(){if(ge||Ie&&I.current.newIndex===C)return bo;if(!(he&&!Dt(H)||!d)&&(P||J))return je.Transition.toString({...d,property:mn})}}function yo(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e==null?void 0:e.draggable)!=null?n:t.draggable,droppable:(r=e==null?void 0:e.droppable)!=null?r:t.droppable}}D.Down,D.Right,D.Up,D.Left;const Tt=l.createContext({activeKey:"",onChange:()=>{}});function Do({activeKey:e,onChange:t,children:n,className:r}){return T.jsx(Tt.Provider,{value:{activeKey:e,onChange:t},children:T.jsx("div",{className:Fe("flex flex-col gap-2",r),children:n})})}function So({children:e,className:t}){return T.jsx("div",{className:Fe("flex items-center gap-1",t),children:e})}const wn=l.forwardRef(({className:e,isSelected:t,value:n,...r},o)=>{const{onChange:s}=l.useContext(Tt),i=a=>{var c;s(n),(c=r.onClick)==null||c.call(r,a)};return T.jsx("div",{ref:o,role:"tab","aria-selected":t,onClick:i,className:Fe("px-3 py-1.5 flex items-center gap-1 text-sm font-medium rounded-xl transition-all duration-200 select-none",t?"bg-white dark:bg-white/[0.12] text-primary shadow-sm shadow-primary-500/10":"text-default-500 hover:text-default-800 dark:hover:text-white hover:bg-white/50 dark:hover:bg-white/[0.06]",e),...r})});wn.displayName="Tab";function Co({value:e,children:t,className:n}){const{activeKey:r}=l.useContext(Tt);return e!==r?null:T.jsx("div",{className:Fe("flex-1",n),children:t})}function Ro({id:e,...t}){const{attributes:n,listeners:r,setNodeRef:o,transform:s,transition:i,isDragging:a}=xo({id:e}),c={transform:je.Transform.toString(s),transition:i,zIndex:a?1:0,position:"relative",touchAction:"none"};return T.jsx(wn,{ref:o,style:c,...n,...r,...t})}class Eo{constructor(){lt(this,"connections",new Map);lt(this,"MAX_BUFFER_SIZE",1e3)}async createTerminal(t,n){const{data:r}=await ct.post("/Log/terminal/create",{cols:t,rows:n});return r.data}async closeTerminal(t){await ct.post(`/Log/terminal/${t}/close`)}async getTerminalList(){const{data:t}=await ct.get("/Log/terminal/list");return t.data}connectTerminal(t,n,r){let o=this.connections.get(t);const{cols:s=80,rows:i=24}=r||{};if(o)o.callbacks.add(n),o.buffer.forEach(a=>n(a));else{const a=new URL(window.location.href);a.protocol=a.protocol.replace("http","ws"),a.pathname="/api/ws/terminal",a.searchParams.set("id",t);const c=JSON.parse(localStorage.getItem("token")||"");if(!c)throw new Error("No token found");a.searchParams.set("token",c);const d=new WebSocket(a.toString());o={ws:d,callbacks:new Set([n]),isConnected:!1,buffer:[]},d.onmessage=u=>{const f=u.data;o==null||o.buffer.push(f),((o==null?void 0:o.buffer.length)??0)>this.MAX_BUFFER_SIZE&&(o==null||o.buffer.shift()),o==null||o.callbacks.forEach(h=>h(f))},d.onopen=()=>{o&&(o.isConnected=!0),this.sendResize(t,s,i)},d.onclose=()=>{o&&(o.isConnected=!1)},this.connections.set(t,o)}return o.ws}disconnectTerminal(t,n){const r=this.connections.get(t);r&&r.callbacks.delete(n)}removeTerminal(t){const n=this.connections.get(t);(n==null?void 0:n.ws.readyState)===WebSocket.OPEN&&n.ws.close(),this.connections.delete(t)}sendInput(t,n){const r=this.connections.get(t);(r==null?void 0:r.ws.readyState)===WebSocket.OPEN&&r.ws.send(JSON.stringify({type:"input",data:n}))}sendResize(t,n,r){const o=this.connections.get(t);(o==null?void 0:o.ws.readyState)===WebSocket.OPEN&&o.ws.send(JSON.stringify({type:"resize",cols:n,rows:r}))}}const fe=new Eo;function Io({id:e}){const t=l.useRef(null),n=l.useRef(!1),r=i=>{var a,c;try{const d=JSON.parse(i);d.data&&((a=t.current)==null||a.write(d.data))}catch{(c=t.current)==null||c.write(i)}};l.useEffect(()=>()=>{n.current&&fe.disconnectTerminal(e,r)},[e]);const o=i=>{fe.sendInput(e,i)},s=(i,a)=>{n.current?fe.sendResize(e,i,a):(n.current=!0,console.log("instance",a,i),fe.connectTerminal(e,r,{rows:a,cols:i}))};return T.jsx(kn,{ref:t,onInput:o,onResize:s,className:"w-full h-full"})}function jo(){const[e,t]=l.useState([]),[n,r]=l.useState(""),[o]=Nn(An.backgroundImage,""),s=!!o;l.useEffect(()=>{fe.getTerminalList().then(u=>{if(u.length===0)return;const f=u.map(h=>({id:h.id,title:h.id}));t(f),r(f[0].id)})},[]);const i=async()=>{try{const{id:u}=await fe.createTerminal(80,24),f={id:u,title:u};t(h=>[...h,f]),r(u)}catch(u){console.error("Failed to create terminal:",u),Bt.error(u.message)}},a=async u=>{var f;try{if(await fe.closeTerminal(u),fe.removeTerminal(u),n===u){const h=e.findIndex(g=>g.id===u)-1;h>=0?r(e[h].id):r(((f=e[0])==null?void 0:f.id)||"")}t(h=>h.filter(g=>g.id!==u))}catch{Bt.error("关闭终端失败")}},c=u=>{const{active:f,over:h}=u;f.id!==(h==null?void 0:h.id)&&t(g=>{const S=g.findIndex(p=>p.id===f.id),v=g.findIndex(p=>p.id===(h==null?void 0:h.id));return It(g,S,v)})},d=_n(qn(Et,{activationConstraint:{distance:8}}));return T.jsx("div",{className:"flex flex-col gap-3 px-3 md:px-6 py-4 md:py-6 h-[calc(100vh-3.5rem)]",children:T.jsx(Qr,{sensors:d,collisionDetection:er,onDragEnd:c,children:T.jsxs(Do,{activeKey:n,onChange:r,className:"h-full overflow-hidden",children:[T.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 flex-grow-0",children:[e.length>0&&T.jsx(So,{className:Fe("flex-1 !overflow-x-auto w-full hide-scrollbar backdrop-blur-xl p-1 rounded-2xl border shadow-sm",s?"bg-black/25 border-white/20":"bg-white/60 dark:bg-white/[0.05] border-white/60 dark:border-white/10"),children:T.jsx(ho,{items:e,strategy:uo,children:e.map(u=>T.jsxs(Ro,{id:u.id,value:u.id,isSelected:n===u.id,className:"flex gap-2 items-center flex-shrink-0",children:[u.title,T.jsx(jt,{isIconOnly:!0,radius:"full",variant:"flat",size:"sm",className:"min-w-0 w-4 h-4 flex-shrink-0",onPress:()=>a(u.id),color:n===u.id?"primary":"default",children:T.jsx(On,{})})]},u.id))})}),T.jsx(jt,{isIconOnly:!0,color:"primary",size:"sm",variant:"flat",onPress:i,startContent:T.jsx(Ft,{}),className:"text-xl ml-auto rounded-xl shadow-sm shadow-primary-500/20"})]}),T.jsxs("div",{className:"flex-grow overflow-hidden",children:[e.length===0&&T.jsxs("div",{className:"flex flex-col gap-3 items-center justify-center h-full text-default-400",children:[T.jsx("div",{className:"w-14 h-14 rounded-2xl bg-white/60 dark:bg-white/[0.06] border border-white/60 dark:border-white/10 flex items-center justify-center",children:T.jsx(Ft,{className:"text-2xl"})}),T.jsx("div",{className:"text-sm",children:"还没有终端会话"}),T.jsx("div",{className:"text-tiny text-default-400",children:"点击右上角 + 新建一个终端"})]}),e.map(u=>T.jsx(Co,{value:u.id,className:"h-full rounded-2xl overflow-hidden border border-white/60 dark:border-white/10 shadow-sm",children:T.jsx(Io,{id:u.id})},u.id))]})]})})})}export{jo as default};