react-semaphor 0.0.623 → 0.0.624

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.
@@ -647,7 +647,7 @@ Valid keys: `+JSON.stringify(Object.keys(I),null," "));var q=ee(U,J,W,Y,X+"."+J
647
647
  To pick up a draggable item, press the space bar.
648
648
  While dragging, use the arrow keys to move the item.
649
649
  Press space again to drop the item in its new position, or press escape to cancel.
650
- `},bce={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 yce(e){let{announcements:t=bce,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=gce}=e;const{announce:s,announcement:i}=hce(),a=$g("DndLiveRegion"),[l,c]=_.useState(!1);if(_.useEffect(()=>{c(!0)},[]),pce(_.useMemo(()=>({onDragStart(f){let{active:h}=f;s(t.onDragStart({active:h}))},onDragMove(f){let{active:h,over:p}=f;t.onDragMove&&s(t.onDragMove({active:h,over:p}))},onDragOver(f){let{active:h,over:p}=f;s(t.onDragOver({active:h,over:p}))},onDragEnd(f){let{active:h,over:p}=f;s(t.onDragEnd({active:h,over:p}))},onDragCancel(f){let{active:h,over:p}=f;s(t.onDragCancel({active:h,over:p}))}}),[s,t])),!l)return null;const u=_.createElement(_.Fragment,null,_.createElement(dce,{id:r,value:o.draggable}),_.createElement(fce,{id:a,announcement:i}));return n?jn.createPortal(u,n):u}var cr;(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"})(cr||(cr={}));function J0(){}function Am(e,t){return _.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function sM(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return _.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const Ys=Object.freeze({x:0,y:0});function X6(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function xce(e,t){const n=Q0(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function Q6(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function vce(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function CT(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function J6(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function ET(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 iM=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=ET(t,t.left,t.top),s=[];for(const i of r){const{id:a}=i,l=n.get(a);if(l){const c=X6(ET(l),o);s.push({id:a,data:{droppableContainer:i,value:c}})}}return s.sort(Q6)},wce=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=CT(t),s=[];for(const i of r){const{id:a}=i,l=n.get(a);if(l){const c=CT(l),u=o.reduce((h,p,m)=>h+X6(c[m],p),0),f=Number((u/4).toFixed(4));s.push({id:a,data:{droppableContainer:i,value:f}})}}return s.sort(Q6)};function Sce(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<o&&n<s){const l=t.width*t.height,c=e.width*e.height,u=i*a,f=u/(l+c-u);return Number(f.toFixed(4))}return 0}const Cce=e=>{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 l=Sce(a,t);l>0&&o.push({id:i,data:{droppableContainer:s,value:l}})}}return o.sort(vce)};function Ece(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function e8(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Ys}function _ce(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),s=1;s<r;s++)o[s-1]=arguments[s];return o.reduce((i,a)=>({...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 kce=_ce(1);function t8(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 Nce(e,t,n){const r=t8(t);if(!r)return e;const{scaleX:o,scaleY:s,x:i,y:a}=r,l=e.left-i-(1-o)*parseFloat(n),c=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:c,right:l+u,bottom:c+f,left:l}}const Mce={ignoreTransform:!1};function xh(e,t){t===void 0&&(t=Mce);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:u}=ao(e).getComputedStyle(e);c&&(n=Nce(n,c,u))}const{top:r,left:o,width:s,height:i,bottom:a,right:l}=n;return{top:r,left:o,width:s,height:i,bottom:a,right:l}}function _T(e){return xh(e,{ignoreTransform:!0})}function jce(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Rce(e,t){return t===void 0&&(t=ao(e).getComputedStyle(e)),t.position==="fixed"}function Dce(e,t){t===void 0&&(t=ao(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 ow(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(oM(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Og(o)||Y6(o)||n.includes(o))return n;const s=ao(e).getComputedStyle(o);return o!==e&&Dce(o,s)&&n.push(o),Rce(o,s)?n:r(o.parentNode)}return e?r(e):n}function n8(e){const[t]=ow(e,1);return t??null}function MS(e){return!tw||!e?null:bh(e)?e:rM(e)?oM(e)||e===yh(e).scrollingElement?window:Og(e)?e:null:null}function r8(e){return bh(e)?e.scrollX:e.scrollLeft}function o8(e){return bh(e)?e.scrollY:e.scrollTop}function NE(e){return{x:r8(e),y:o8(e)}}var gr;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(gr||(gr={}));function s8(e){return!tw||!e?!1:e===document.scrollingElement}function i8(e){const t={x:0,y:0},n=s8(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 Pce={x:.2,y:.2};function Tce(e,t,n,r,o){let{top:s,left:i,right:a,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=Pce);const{isTop:c,isBottom:u,isLeft:f,isRight:h}=i8(e),p={x:0,y:0},m={x:0,y:0},g={height:t.height*o.y,width:t.width*o.x};return!c&&s<=t.top+g.height?(p.y=gr.Backward,m.y=r*Math.abs((t.top+g.height-s)/g.height)):!u&&l>=t.bottom-g.height&&(p.y=gr.Forward,m.y=r*Math.abs((t.bottom-g.height-l)/g.height)),!h&&a>=t.right-g.width?(p.x=gr.Forward,m.x=r*Math.abs((t.right-g.width-a)/g.width)):!f&&i<=t.left+g.width&&(p.x=gr.Backward,m.x=r*Math.abs((t.left+g.width-i)/g.width)),{direction:p,speed:m}}function Ace(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 a8(e){return e.reduce((t,n)=>tf(t,NE(n)),Ys)}function Ice(e){return e.reduce((t,n)=>t+r8(n),0)}function Oce(e){return e.reduce((t,n)=>t+o8(n),0)}function l8(e,t){if(t===void 0&&(t=xh),!e)return;const{top:n,left:r,bottom:o,right:s}=t(e);n8(e)&&(o<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Fce=[["x",["left","right"],Ice],["y",["top","bottom"],Oce]];class aM{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=ow(n),o=a8(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[s,i,a]of Fce)for(const l of i)Object.defineProperty(this,l,{get:()=>{const c=a(r),u=o[s]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Vp{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 $ce(e){const{EventTarget:t}=ao(e);return e instanceof t?e:yh(e)}function jS(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 us;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(us||(us={}));function kT(e){e.preventDefault()}function Lce(e){e.stopPropagation()}var Rt;(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"})(Rt||(Rt={}));const c8={start:[Rt.Space,Rt.Enter],cancel:[Rt.Esc],end:[Rt.Space,Rt.Enter,Rt.Tab]},zce=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Rt.Right:return{...n,x:n.x+25};case Rt.Left:return{...n,x:n.x-25};case Rt.Down:return{...n,y:n.y+25};case Rt.Up:return{...n,y:n.y-25}}};class Lg{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 Vp(yh(n)),this.windowListeners=new Vp(ao(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(us.Resize,this.handleCancel),this.windowListeners.add(us.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(us.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&l8(r),n(Ys)}handleKeyDown(t){if(rw(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:s=c8,coordinateGetter:i=zce,scrollBehavior:a="smooth"}=o,{code:l}=t;if(s.end.includes(l)){this.handleEnd(t);return}if(s.cancel.includes(l)){this.handleCancel(t);return}const{collisionRect:c}=r.current,u=c?{x:c.left,y:c.top}:Ys;this.referenceCoordinates||(this.referenceCoordinates=u);const f=i(t,{active:n,context:r.current,currentCoordinates:u});if(f){const h=Tm(f,u),p={x:0,y:0},{scrollableAncestors:m}=r.current;for(const g of m){const b=t.code,{isTop:y,isRight:x,isLeft:v,isBottom:w,maxScroll:S,minScroll:k}=i8(g),E=Ace(g),N={x:Math.min(b===Rt.Right?E.right-E.width/2:E.right,Math.max(b===Rt.Right?E.left:E.left+E.width/2,f.x)),y:Math.min(b===Rt.Down?E.bottom-E.height/2:E.bottom,Math.max(b===Rt.Down?E.top:E.top+E.height/2,f.y))},R=b===Rt.Right&&!x||b===Rt.Left&&!v,M=b===Rt.Down&&!w||b===Rt.Up&&!y;if(R&&N.x!==f.x){const T=g.scrollLeft+h.x,D=b===Rt.Right&&T<=S.x||b===Rt.Left&&T>=k.x;if(D&&!h.y){g.scrollTo({left:T,behavior:a});return}D?p.x=g.scrollLeft-T:p.x=b===Rt.Right?g.scrollLeft-S.x:g.scrollLeft-k.x,p.x&&g.scrollBy({left:-p.x,behavior:a});break}else if(M&&N.y!==f.y){const T=g.scrollTop+h.y,D=b===Rt.Down&&T<=S.y||b===Rt.Up&&T>=k.y;if(D&&!h.x){g.scrollTo({top:T,behavior:a});return}D?p.y=g.scrollTop-T:p.y=b===Rt.Down?g.scrollTop-S.y:g.scrollTop-k.y,p.y&&g.scrollBy({top:-p.y,behavior:a});break}}this.handleMove(t,tf(Tm(f,this.referenceCoordinates),p))}}}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()}}Lg.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=c8,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 NT(e){return!!(e&&"distance"in e)}function MT(e){return!!(e&&"delay"in e)}class lM{constructor(t,n,r){var o;r===void 0&&(r=$ce(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=yh(i),this.documentListeners=new Vp(this.document),this.listeners=new Vp(r),this.windowListeners=new Vp(ao(i)),this.initialCoordinates=(o=Q0(s))!=null?o:Ys,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(us.Resize,this.handleCancel),this.windowListeners.add(us.DragStart,kT),this.windowListeners.add(us.VisibilityChange,this.handleCancel),this.windowListeners.add(us.ContextMenu,kT),this.documentListeners.add(us.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(MT(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(NT(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(us.Click,Lce,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(us.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 l=(n=Q0(t))!=null?n:Ys,c=Tm(o,l);if(!r&&a){if(NT(a)){if(a.tolerance!=null&&jS(c,a.tolerance))return this.handleCancel();if(jS(c,a.distance))return this.handleStart()}if(MT(a)&&jS(c,a.tolerance))return this.handleCancel();this.handlePending(a,c);return}t.cancelable&&t.preventDefault(),i(l)}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===Rt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Bce={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class zg extends lM{constructor(t){const{event:n}=t,r=yh(n.target);super(t,Bce,r)}}zg.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 Vce={move:{name:"mousemove"},end:{name:"mouseup"}};var ME;(function(e){e[e.RightClick=2]="RightClick"})(ME||(ME={}));class u8 extends lM{constructor(t){super(t,Vce,yh(t.event.target))}}u8.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===ME.RightClick?!1:(r==null||r({event:n}),!0)}}];const RS={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Hce extends lM{constructor(t){super(t,RS)}static setup(){return window.addEventListener(RS.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(RS.move.name,t)};function t(){}}}Hce.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 Hp;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Hp||(Hp={}));var ex;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(ex||(ex={}));function Wce(e){let{acceleration:t,activator:n=Hp.Pointer,canScroll:r,draggingRect:o,enabled:s,interval:i=5,order:a=ex.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:f,threshold:h}=e;const p=qce({delta:f,disabled:!s}),[m,g]=ice(),b=_.useRef({x:0,y:0}),y=_.useRef({x:0,y:0}),x=_.useMemo(()=>{switch(n){case Hp.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Hp.DraggableRect:return o}},[n,o,l]),v=_.useRef(null),w=_.useCallback(()=>{const k=v.current;if(!k)return;const E=b.current.x*y.current.x,N=b.current.y*y.current.y;k.scrollBy(E,N)},[]),S=_.useMemo(()=>a===ex.TreeOrder?[...c].reverse():c,[a,c]);_.useEffect(()=>{if(!s||!c.length||!x){g();return}for(const k of S){if((r==null?void 0:r(k))===!1)continue;const E=c.indexOf(k),N=u[E];if(!N)continue;const{direction:R,speed:M}=Tce(k,N,x,t,h);for(const T of["x","y"])p[T][R[T]]||(M[T]=0,R[T]=0);if(M.x>0||M.y>0){g(),v.current=k,m(w,i),b.current=M,y.current=R;return}}b.current={x:0,y:0},y.current={x:0,y:0},g()},[t,w,r,g,s,i,JSON.stringify(x),JSON.stringify(p),m,c,S,u,JSON.stringify(h)])}const Uce={x:{[gr.Backward]:!1,[gr.Forward]:!1},y:{[gr.Backward]:!1,[gr.Forward]:!1}};function qce(e){let{delta:t,disabled:n}=e;const r=X0(t);return Fg(o=>{if(n||!r||!o)return Uce;const s={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[gr.Backward]:o.x[gr.Backward]||s.x===-1,[gr.Forward]:o.x[gr.Forward]||s.x===1},y:{[gr.Backward]:o.y[gr.Backward]||s.y===-1,[gr.Forward]:o.y[gr.Forward]||s.y===1}}},[n,t,r])}function Gce(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Fg(o=>{var s;return t==null?null:(s=r??o)!=null?s:null},[r,t])}function Yce(e,t){return _.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 Im;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Im||(Im={}));var jE;(function(e){e.Optimized="optimized"})(jE||(jE={}));const jT=new Map;function Zce(e,t){let{dragging:n,dependencies:r,config:o}=t;const[s,i]=_.useState(null),{frequency:a,measure:l,strategy:c}=o,u=_.useRef(e),f=b(),h=Pm(f),p=_.useCallback(function(y){y===void 0&&(y=[]),!h.current&&i(x=>x===null?y:x.concat(y.filter(v=>!x.includes(v))))},[h]),m=_.useRef(null),g=Fg(y=>{if(f&&!n)return jT;if(!y||y===jT||u.current!==e||s!=null){const x=new Map;for(let v of e){if(!v)continue;if(s&&s.length>0&&!s.includes(v.id)&&v.rect.current){x.set(v.id,v.rect.current);continue}const w=v.node.current,S=w?new aM(l(w),w):null;v.rect.current=S,S&&x.set(v.id,S)}return x}return y},[e,s,n,f,l]);return _.useEffect(()=>{u.current=e},[e]),_.useEffect(()=>{f||p()},[n,f]),_.useEffect(()=>{s&&s.length>0&&i(null)},[JSON.stringify(s)]),_.useEffect(()=>{f||typeof a!="number"||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},a))},[a,f,p,...r]),{droppableRects:g,measureDroppableContainers:p,measuringScheduled:s!=null};function b(){switch(c){case Im.Always:return!1;case Im.BeforeDragging:return n;default:return!n}}}function cM(e,t){return Fg(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function Kce(e,t){return cM(e,t)}function Xce(e){let{callback:t,disabled:n}=e;const r=nw(t),o=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return _.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function sw(e){let{callback:t,disabled:n}=e;const r=nw(t),o=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return _.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function Qce(e){return new aM(xh(e),e)}function RT(e,t,n){t===void 0&&(t=Qce);const[r,o]=_.useState(null);function s(){o(l=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=l??n)!=null?c:null}const u=t(e);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const i=Xce({callback(l){if(e)for(const c of l){const{type:u,target:f}=c;if(u==="childList"&&f instanceof HTMLElement&&f.contains(e)){s();break}}}}),a=sw({callback:s});return Gs(()=>{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 Jce(e){const t=cM(e);return e8(e,t)}const DT=[];function eue(e){const t=_.useRef(e),n=Fg(r=>e?r&&r!==DT&&e&&t.current&&e.parentNode===t.current.parentNode?r:ow(e):DT,[e]);return _.useEffect(()=>{t.current=e},[e]),n}function tue(e){const[t,n]=_.useState(null),r=_.useRef(e),o=_.useCallback(s=>{const i=MS(s.target);i&&n(a=>a?(a.set(i,NE(i)),new Map(a)):null)},[]);return _.useEffect(()=>{const s=r.current;if(e!==s){i(s);const a=e.map(l=>{const c=MS(l);return c?(c.addEventListener("scroll",o,{passive:!0}),[c,NE(c)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=e}return()=>{i(e),i(s)};function i(a){a.forEach(l=>{const c=MS(l);c==null||c.removeEventListener("scroll",o)})}},[o,e]),_.useMemo(()=>e.length?t?Array.from(t.values()).reduce((s,i)=>tf(s,i),Ys):a8(e):Ys,[e,t])}function PT(e,t){t===void 0&&(t=[]);const n=_.useRef(null);return _.useEffect(()=>{n.current=null},t),_.useEffect(()=>{const r=e!==Ys;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?Tm(e,n.current):Ys}function nue(e){_.useEffect(()=>{if(!tw)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 rue(e,t){return _.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:s}=r;return n[o]=i=>{s(i,t)},n},{}),[e,t])}function d8(e){return _.useMemo(()=>e?jce(e):null,[e])}const TT=[];function oue(e,t){t===void 0&&(t=xh);const[n]=e,r=d8(n?ao(n):null),[o,s]=_.useState(TT);function i(){s(()=>e.length?e.map(l=>s8(l)?r:new aM(t(l),l)):TT)}const a=sw({callback:i});return Gs(()=>{a==null||a.disconnect(),i(),e.forEach(l=>a==null?void 0:a.observe(l))},[e]),o}function f8(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Og(t)?t:e}function sue(e){let{measure:t}=e;const[n,r]=_.useState(null),o=_.useCallback(c=>{for(const{target:u}of c)if(Og(u)){r(f=>{const h=t(u);return f?{...f,width:h.width,height:h.height}:h});break}},[t]),s=sw({callback:o}),i=_.useCallback(c=>{const u=f8(c);s==null||s.disconnect(),u&&(s==null||s.observe(u)),r(u?t(u):null)},[t,s]),[a,l]=K0(i);return _.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const iue=[{sensor:zg,options:{}},{sensor:Lg,options:{}}],aue={current:{}},h0={draggable:{measure:_T},droppable:{measure:_T,strategy:Im.WhileDragging,frequency:jE.Optimized},dragOverlay:{measure:xh}};class Wp 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 lue={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Wp,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:J0},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:h0,measureDroppableContainers:J0,windowRect:null,measuringScheduled:!1},h8={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:J0,draggableNodes:new Map,over:null,measureDroppableContainers:J0},Bg=_.createContext(h8),p8=_.createContext(lue);function cue(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Wp}}}function uue(e,t){switch(t.type){case cr.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case cr.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 cr.DragEnd:case cr.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case cr.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Wp(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case cr.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 Wp(e.droppable.containers);return i.set(n,{...s,disabled:o}),{...e,droppable:{...e.droppable,containers:i}}}case cr.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const s=new Wp(e.droppable.containers);return s.delete(n),{...e,droppable:{...e.droppable,containers:s}}}default:return e}}function due(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=_.useContext(Bg),s=X0(r),i=X0(n==null?void 0:n.id);return _.useEffect(()=>{if(!t&&!r&&s&&i!=null){if(!rw(s)||document.activeElement===s.target)return;const a=o.get(i);if(!a)return;const{activatorNode:l,node:c}=a;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const u of[l.current,c.current]){if(!u)continue;const f=cce(u);if(f){f.focus();break}}})}},[r,t,o,i,s]),null}function m8(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,s)=>s({transform:o,...r}),n):n}function fue(e){return _.useMemo(()=>({draggable:{...h0.draggable,...e==null?void 0:e.draggable},droppable:{...h0.droppable,...e==null?void 0:e.droppable},dragOverlay:{...h0.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 hue(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const s=_.useRef(!1),{x:i,y:a}=typeof o=="boolean"?{x:o,y:o}:o;Gs(()=>{if(!i&&!a||!t){s.current=!1;return}if(s.current||!r)return;const c=t==null?void 0:t.node.current;if(!c||c.isConnected===!1)return;const u=n(c),f=e8(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=n8(c);h&&h.scrollBy({top:f.y,left:f.x})}},[t,i,a,r,n])}const iw=_.createContext({...Ys,scaleX:1,scaleY:1});var cl;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(cl||(cl={}));const uM=_.memo(function(t){var n,r,o,s;let{id:i,accessibility:a,autoScroll:l=!0,children:c,sensors:u=iue,collisionDetection:f=Cce,measuring:h,modifiers:p,...m}=t;const g=_.useReducer(uue,void 0,cue),[b,y]=g,[x,v]=mce(),[w,S]=_.useState(cl.Uninitialized),k=w===cl.Initialized,{draggable:{active:E,nodes:N,translate:R},droppable:{containers:M}}=b,T=E!=null?N.get(E):null,D=_.useRef({initial:null,translated:null}),A=_.useMemo(()=>{var Se;return E!=null?{id:E,data:(Se=T==null?void 0:T.data)!=null?Se:aue,rect:D}:null},[E,T]),O=_.useRef(null),[j,F]=_.useState(null),[L,V]=_.useState(null),$=Pm(m,Object.values(m)),I=$g("DndDescribedBy",i),H=_.useMemo(()=>M.getEnabled(),[M]),B=fue(h),{droppableRects:P,measureDroppableContainers:W,measuringScheduled:Y}=Zce(H,{dragging:k,dependencies:[R.x,R.y],config:B.droppable}),X=Gce(N,E),U=_.useMemo(()=>L?Q0(L):null,[L]),z=ye(),G=Kce(X,B.draggable.measure);hue({activeNode:E!=null?N.get(E):null,config:z.layoutShiftCompensation,initialRect:G,measure:B.draggable.measure});const J=RT(X,B.draggable.measure,G),ee=RT(X?X.parentElement:null),q=_.useRef({activatorEvent:null,active:null,activeNode:X,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:N,draggingNode:null,draggingNodeRect:null,droppableContainers:M,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ie=M.getNodeFor((n=q.current.over)==null?void 0:n.id),ne=sue({measure:B.dragOverlay.measure}),le=(r=ne.nodeRef.current)!=null?r:X,ge=k?(o=ne.rect)!=null?o:J:null,Me=!!(ne.nodeRef.current&&ne.rect),ue=Jce(Me?null:J),ke=d8(le?ao(le):null),Te=eue(k?ie??X:null),et=oue(Te),at=m8(p,{transform:{x:R.x-ue.x,y:R.y-ue.y,scaleX:1,scaleY:1},activatorEvent:L,active:A,activeNodeRect:J,containerNodeRect:ee,draggingNodeRect:ge,over:q.current.over,overlayNodeRect:ne.rect,scrollableAncestors:Te,scrollableAncestorRects:et,windowRect:ke}),He=U?tf(U,R):null,tt=tue(Te),bn=PT(tt),oe=PT(tt,[J]),he=tf(at,bn),De=ge?kce(ge,at):null,pe=A&&De?f({active:A,collisionRect:De,droppableRects:P,droppableContainers:H,pointerCoordinates:He}):null,ze=J6(pe,"id"),[nt,Nt]=_.useState(null),$t=Me?at:tf(at,oe),ve=Ece($t,(s=nt==null?void 0:nt.rect)!=null?s:null,J),Lt=_.useRef(null),yt=_.useCallback((Se,je)=>{let{sensor:Ie,options:Be}=je;if(O.current==null)return;const Ke=N.get(O.current);if(!Ke)return;const rt=Se.nativeEvent,zt=new Ie({active:O.current,activeNode:Ke,event:rt,options:Be,context:q,onAbort(Bt){if(!N.get(Bt))return;const{onDragAbort:rn}=$.current,An={id:Bt};rn==null||rn(An),x({type:"onDragAbort",event:An})},onPending(Bt,Gn,rn,An){if(!N.get(Bt))return;const{onDragPending:Gr}=$.current,To={id:Bt,constraint:Gn,initialCoordinates:rn,offset:An};Gr==null||Gr(To),x({type:"onDragPending",event:To})},onStart(Bt){const Gn=O.current;if(Gn==null)return;const rn=N.get(Gn);if(!rn)return;const{onDragStart:An}=$.current,ri={activatorEvent:rt,active:{id:Gn,data:rn.data,rect:D}};jn.unstable_batchedUpdates(()=>{An==null||An(ri),S(cl.Initializing),y({type:cr.DragStart,initialCoordinates:Bt,active:Gn}),x({type:"onDragStart",event:ri}),F(Lt.current),V(rt)})},onMove(Bt){y({type:cr.DragMove,coordinates:Bt})},onEnd:Mt(cr.DragEnd),onCancel:Mt(cr.DragCancel)});Lt.current=zt;function Mt(Bt){return async function(){const{active:rn,collisions:An,over:ri,scrollAdjustedTranslate:Gr}=q.current;let To=null;if(rn&&Gr){const{cancelDrop:oi}=$.current;To={activatorEvent:rt,active:rn,collisions:An,delta:Gr,over:ri},Bt===cr.DragEnd&&typeof oi=="function"&&await Promise.resolve(oi(To))&&(Bt=cr.DragCancel)}O.current=null,jn.unstable_batchedUpdates(()=>{y({type:Bt}),S(cl.Uninitialized),Nt(null),F(null),V(null),Lt.current=null;const oi=Bt===cr.DragEnd?"onDragEnd":"onDragCancel";if(To){const Ka=$.current[oi];Ka==null||Ka(To),x({type:oi,event:To})}})}}},[N]),Tn=_.useCallback((Se,je)=>(Ie,Be)=>{const Ke=Ie.nativeEvent,rt=N.get(Be);if(O.current!==null||!rt||Ke.dndKit||Ke.defaultPrevented)return;const zt={active:rt};Se(Ie,je.options,zt)===!0&&(Ke.dndKit={capturedBy:je.sensor},O.current=Be,yt(Ie,je))},[N,yt]),st=Yce(u,Tn);nue(u),Gs(()=>{J&&w===cl.Initializing&&S(cl.Initialized)},[J,w]),_.useEffect(()=>{const{onDragMove:Se}=$.current,{active:je,activatorEvent:Ie,collisions:Be,over:Ke}=q.current;if(!je||!Ie)return;const rt={active:je,activatorEvent:Ie,collisions:Be,delta:{x:he.x,y:he.y},over:Ke};jn.unstable_batchedUpdates(()=>{Se==null||Se(rt),x({type:"onDragMove",event:rt})})},[he.x,he.y]),_.useEffect(()=>{const{active:Se,activatorEvent:je,collisions:Ie,droppableContainers:Be,scrollAdjustedTranslate:Ke}=q.current;if(!Se||O.current==null||!je||!Ke)return;const{onDragOver:rt}=$.current,zt=Be.get(ze),Mt=zt&&zt.rect.current?{id:zt.id,rect:zt.rect.current,data:zt.data,disabled:zt.disabled}:null,Bt={active:Se,activatorEvent:je,collisions:Ie,delta:{x:Ke.x,y:Ke.y},over:Mt};jn.unstable_batchedUpdates(()=>{Nt(Mt),rt==null||rt(Bt),x({type:"onDragOver",event:Bt})})},[ze]),Gs(()=>{q.current={activatorEvent:L,active:A,activeNode:X,collisionRect:De,collisions:pe,droppableRects:P,draggableNodes:N,draggingNode:le,draggingNodeRect:ge,droppableContainers:M,over:nt,scrollableAncestors:Te,scrollAdjustedTranslate:he},D.current={initial:ge,translated:De}},[A,X,pe,De,N,le,ge,P,M,nt,Te,he]),Wce({...z,delta:R,draggingRect:De,pointerCoordinates:He,scrollableAncestors:Te,scrollableAncestorRects:et});const $e=_.useMemo(()=>({active:A,activeNode:X,activeNodeRect:J,activatorEvent:L,collisions:pe,containerNodeRect:ee,dragOverlay:ne,draggableNodes:N,droppableContainers:M,droppableRects:P,over:nt,measureDroppableContainers:W,scrollableAncestors:Te,scrollableAncestorRects:et,measuringConfiguration:B,measuringScheduled:Y,windowRect:ke}),[A,X,J,L,pe,ee,ne,N,M,P,nt,W,Te,et,B,Y,ke]),be=_.useMemo(()=>({activatorEvent:L,activators:st,active:A,activeNodeRect:J,ariaDescribedById:{draggable:I},dispatch:y,draggableNodes:N,over:nt,measureDroppableContainers:W}),[L,st,A,J,y,I,N,nt,W]);return _.createElement(K6.Provider,{value:v},_.createElement(Bg.Provider,{value:be},_.createElement(p8.Provider,{value:$e},_.createElement(iw.Provider,{value:ve},c)),_.createElement(due,{disabled:(a==null?void 0:a.restoreFocus)===!1})),_.createElement(yce,{...a,hiddenTextDescribedById:I}));function ye(){const Se=(j==null?void 0:j.autoScrollEnabled)===!1,je=typeof l=="object"?l.enabled===!1:l===!1,Ie=k&&!Se&&!je;return typeof l=="object"?{...l,enabled:Ie}:{enabled:Ie}}}),pue=_.createContext(null),AT="button",mue="Draggable";function g8(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const s=$g(mue),{activators:i,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:f,over:h}=_.useContext(Bg),{role:p=AT,roleDescription:m="draggable",tabIndex:g=0}=o??{},b=(l==null?void 0:l.id)===t,y=_.useContext(b?iw:pue),[x,v]=K0(),[w,S]=K0(),k=rue(i,t),E=Pm(n);Gs(()=>(f.set(t,{id:t,key:s,node:x,activatorNode:w,data:E}),()=>{const R=f.get(t);R&&R.key===s&&f.delete(t)}),[f,t]);const N=_.useMemo(()=>({role:p,tabIndex:g,"aria-disabled":r,"aria-pressed":b&&p===AT?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,g,b,m,u.draggable]);return{active:l,activatorEvent:a,activeNodeRect:c,attributes:N,isDragging:b,listeners:r?void 0:k,node:x,over:h,setNodeRef:v,setActivatorNodeRef:S,transform:y}}function b8(){return _.useContext(p8)}const gue="Droppable",bue={timeout:25};function y8(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const s=$g(gue),{active:i,dispatch:a,over:l,measureDroppableContainers:c}=_.useContext(Bg),u=_.useRef({disabled:n}),f=_.useRef(!1),h=_.useRef(null),p=_.useRef(null),{disabled:m,updateMeasurementsFor:g,timeout:b}={...bue,...o},y=Pm(g??r),x=_.useCallback(()=>{if(!f.current){f.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{c(Array.isArray(y.current)?y.current:[y.current]),p.current=null},b)},[b]),v=sw({callback:x,disabled:m||!i}),w=_.useCallback((N,R)=>{v&&(R&&(v.unobserve(R),f.current=!1),N&&v.observe(N))},[v]),[S,k]=K0(w),E=Pm(t);return _.useEffect(()=>{!v||!S.current||(v.disconnect(),f.current=!1,v.observe(S.current))},[S,v]),_.useEffect(()=>(a({type:cr.RegisterDroppable,element:{id:r,key:s,disabled:n,node:S,rect:h,data:E}}),()=>a({type:cr.UnregisterDroppable,key:s,id:r})),[r]),_.useEffect(()=>{n!==u.current.disabled&&(a({type:cr.SetDroppableDisabled,id:r,key:s,disabled:n}),u.current.disabled=n)},[r,s,n,a]),{active:i,rect:h,isOver:(l==null?void 0:l.id)===r,node:S,over:l,setNodeRef:k}}function yue(e){let{animation:t,children:n}=e;const[r,o]=_.useState(null),[s,i]=_.useState(null),a=X0(n);return!n&&!r&&a&&o(a),Gs(()=>{if(!s)return;const l=r==null?void 0:r.key,c=r==null?void 0:r.props.id;if(l==null||c==null){o(null);return}Promise.resolve(t(c,s)).then(()=>{o(null)})},[t,r,s]),_.createElement(_.Fragment,null,n,r?_.cloneElement(r,{ref:i}):null)}const xue={x:0,y:0,scaleX:1,scaleY:1};function vue(e){let{children:t}=e;return _.createElement(Bg.Provider,{value:h8},_.createElement(iw.Provider,{value:xue},t))}const wue={position:"fixed",touchAction:"none"},Sue=e=>rw(e)?"transform 250ms ease":void 0,Cue=_.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:s,className:i,rect:a,style:l,transform:c,transition:u=Sue}=e;if(!a)return null;const f=o?c:{...c,scaleX:1,scaleY:1},h={...wue,width:a.width,height:a.height,top:a.top,left:a.left,transform:Ti.Transform.toString(f),transformOrigin:o&&r?xce(r,a):void 0,transition:typeof u=="function"?u(r):u,...l};return _.createElement(n,{className:i,style:h,ref:t},s)}),Eue=e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:s,className:i}=e;if(s!=null&&s.active)for(const[a,l]of Object.entries(s.active))l!==void 0&&(o[a]=n.node.style.getPropertyValue(a),n.node.style.setProperty(a,l));if(s!=null&&s.dragOverlay)for(const[a,l]of Object.entries(s.dragOverlay))l!==void 0&&r.node.style.setProperty(a,l);return i!=null&&i.active&&n.node.classList.add(i.active),i!=null&&i.dragOverlay&&r.node.classList.add(i.dragOverlay),function(){for(const[l,c]of Object.entries(o))n.node.style.setProperty(l,c);i!=null&&i.active&&n.node.classList.remove(i.active)}},_ue=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Ti.Transform.toString(t)},{transform:Ti.Transform.toString(n)}]},kue={duration:250,easing:"ease",keyframes:_ue,sideEffects:Eue({styles:{active:{opacity:"0"}}})};function Nue(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return nw((s,i)=>{if(t===null)return;const a=n.get(s);if(!a)return;const l=a.node.current;if(!l)return;const c=f8(i);if(!c)return;const{transform:u}=ao(i).getComputedStyle(i),f=t8(u);if(!f)return;const h=typeof t=="function"?t:Mue(t);return l8(l,o.draggable.measure),h({active:{id:s,data:a.data,node:l,rect:o.draggable.measure(l)},draggableNodes:n,dragOverlay:{node:i,rect:o.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:o,transform:f})})}function Mue(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...kue,...e};return s=>{let{active:i,dragOverlay:a,transform:l,...c}=s;if(!t)return;const u={x:a.rect.left-i.rect.left,y:a.rect.top-i.rect.top},f={scaleX:l.scaleX!==1?i.rect.width*l.scaleX/a.rect.width:1,scaleY:l.scaleY!==1?i.rect.height*l.scaleY/a.rect.height:1},h={x:l.x-u.x,y:l.y-u.y,...f},p=o({...c,active:i,dragOverlay:a,transform:{initial:l,final:h}}),[m]=p,g=p[p.length-1];if(JSON.stringify(m)===JSON.stringify(g))return;const b=r==null?void 0:r({active:i,dragOverlay:a,...c}),y=a.node.animate(p,{duration:t,easing:n,fill:"forwards"});return new Promise(x=>{y.onfinish=()=>{b==null||b(),x()}})}}let IT=0;function jue(e){return _.useMemo(()=>{if(e!=null)return IT++,IT},[e])}const x8=_.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:o,transition:s,modifiers:i,wrapperElement:a="div",className:l,zIndex:c=999}=e;const{activatorEvent:u,active:f,activeNodeRect:h,containerNodeRect:p,draggableNodes:m,droppableContainers:g,dragOverlay:b,over:y,measuringConfiguration:x,scrollableAncestors:v,scrollableAncestorRects:w,windowRect:S}=b8(),k=_.useContext(iw),E=jue(f==null?void 0:f.id),N=m8(i,{activatorEvent:u,active:f,activeNodeRect:h,containerNodeRect:p,draggingNodeRect:b.rect,over:y,overlayNodeRect:b.rect,scrollableAncestors:v,scrollableAncestorRects:w,transform:k,windowRect:S}),R=cM(h),M=Nue({config:r,draggableNodes:m,droppableContainers:g,measuringConfiguration:x}),T=R?b.setRef:void 0;return _.createElement(vue,null,_.createElement(yue,{animation:M},f&&E?_.createElement(Cue,{key:E,id:f.id,ref:T,as:a,activatorEvent:u,adjustScale:t,className:l,transition:s,rect:R,style:{zIndex:c,...o},transform:N},n):null))});function Vg(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function Rue(e,t){return e.reduce((n,r,o)=>{const s=t.get(r);return s&&(n[o]=s),n},Array(e.length))}function ry(e){return e!==null&&e>=0}function Due(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Pue(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const oy={scaleX:1,scaleY:1},Tue=e=>{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 l=Aue(n,i,o);if(i===o){const c=n[s];return c?{x:o<s?c.left+c.width-(a.left+a.width):c.left-a.left,y:0,...oy}:null}return i>o&&i<=s?{x:-a.width-l,y:0,...oy}:i<o&&i>=s?{x:a.width+l,y:0,...oy}:{x:0,y:0,...oy}};function Aue(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];return!r||!o&&!s?0:n<t?o?r.left-(o.left+o.width):s.left-(r.left+r.width):s?s.left-(r.left+r.width):r.left-(o.left+o.width)}const v8=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const s=Vg(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}},sy={scaleX:1,scaleY:1},w8=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:s,overIndex:i}=e;const a=(t=s[n])!=null?t:r;if(!a)return null;if(o===n){const c=s[i];return c?{x:0,y:n<i?c.top+c.height-(a.top+a.height):c.top-a.top,...sy}:null}const l=Iue(s,o,n);return o>n&&o<=i?{x:0,y:-a.height-l,...sy}:o<n&&o>=i?{x:0,y:a.height+l,...sy}:{x:0,y:0,...sy}};function Iue(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];return r?n<t?o?r.top-(o.top+o.height):s?s.top-(r.top+r.height):0:s?s.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const S8="Sortable",C8=_.createContext({activeIndex:-1,containerId:S8,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:v8,disabled:{draggable:!1,droppable:!1}});function dM(e){let{children:t,id:n,items:r,strategy:o=v8,disabled:s=!1}=e;const{active:i,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:u}=b8(),f=$g(S8,n),h=a.rect!==null,p=_.useMemo(()=>r.map(k=>typeof k=="object"&&"id"in k?k.id:k),[r]),m=i!=null,g=i?p.indexOf(i.id):-1,b=c?p.indexOf(c.id):-1,y=_.useRef(p),x=!Due(p,y.current),v=b!==-1&&g===-1||x,w=Pue(s);Gs(()=>{x&&m&&u(p)},[x,p,m,u]),_.useEffect(()=>{y.current=p},[p]);const S=_.useMemo(()=>({activeIndex:g,containerId:f,disabled:w,disableTransforms:v,items:p,overIndex:b,useDragOverlay:h,sortedRects:Rue(p,l),strategy:o}),[g,f,w.draggable,w.droppable,v,p,b,l,h,o]);return _.createElement(C8.Provider,{value:S},t)}const Oue=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return Vg(n,r,o).indexOf(t)},Fue=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:s,newIndex:i,previousItems:a,previousContainerId:l,transition:c}=e;return!c||!r||a!==s&&o===i?!1:n?!0:i!==o&&t===l},$ue={duration:200,easing:"ease"},E8="transform",Lue=Ti.Transition.toString({property:E8,duration:0,easing:"linear"}),zue={roleDescription:"sortable"};function Bue(e){let{disabled:t,index:n,node:r,rect:o}=e;const[s,i]=_.useState(null),a=_.useRef(n);return Gs(()=>{if(!t&&n!==a.current&&r.current){const l=o.current;if(l){const c=xh(r.current,{ignoreTransform:!0}),u={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(u.x||u.y)&&i(u)}}n!==a.current&&(a.current=n)},[t,n,r,o]),_.useEffect(()=>{s&&i(null)},[s]),s}function fM(e){let{animateLayoutChanges:t=Fue,attributes:n,disabled:r,data:o,getNewIndex:s=Oue,id:i,strategy:a,resizeObserverConfig:l,transition:c=$ue}=e;const{items:u,containerId:f,activeIndex:h,disabled:p,disableTransforms:m,sortedRects:g,overIndex:b,useDragOverlay:y,strategy:x}=_.useContext(C8),v=Vue(r,p),w=u.indexOf(i),S=_.useMemo(()=>({sortable:{containerId:f,index:w,items:u},...o}),[f,o,w,u]),k=_.useMemo(()=>u.slice(u.indexOf(i)),[u,i]),{rect:E,node:N,isOver:R,setNodeRef:M}=y8({id:i,data:S,disabled:v.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...l}}),{active:T,activatorEvent:D,activeNodeRect:A,attributes:O,setNodeRef:j,listeners:F,isDragging:L,over:V,setActivatorNodeRef:$,transform:I}=g8({id:i,data:S,attributes:{...zue,...n},disabled:v.draggable}),H=sce(M,j),B=!!T,P=B&&!m&&ry(h)&&ry(b),W=!y&&L,Y=W&&P?I:null,U=P?Y??(a??x)({rects:g,activeNodeRect:A,activeIndex:h,overIndex:b,index:w}):null,z=ry(h)&&ry(b)?s({id:i,items:u,activeIndex:h,overIndex:b}):w,G=T==null?void 0:T.id,J=_.useRef({activeId:G,items:u,newIndex:z,containerId:f}),ee=u!==J.current.items,q=t({active:T,containerId:f,isDragging:L,isSorting:B,id:i,index:w,items:u,newIndex:J.current.newIndex,previousItems:J.current.items,previousContainerId:J.current.containerId,transition:c,wasDragging:J.current.activeId!=null}),ie=Bue({disabled:!q,index:w,node:N,rect:E});return _.useEffect(()=>{B&&J.current.newIndex!==z&&(J.current.newIndex=z),f!==J.current.containerId&&(J.current.containerId=f),u!==J.current.items&&(J.current.items=u)},[B,z,f,u]),_.useEffect(()=>{if(G===J.current.activeId)return;if(G!=null&&J.current.activeId==null){J.current.activeId=G;return}const le=setTimeout(()=>{J.current.activeId=G},50);return()=>clearTimeout(le)},[G]),{active:T,activeIndex:h,attributes:O,data:S,rect:E,index:w,newIndex:z,items:u,isOver:R,isSorting:B,isDragging:L,listeners:F,node:N,overIndex:b,over:V,setNodeRef:H,setActivatorNodeRef:$,setDroppableNodeRef:M,setDraggableNodeRef:j,transform:ie??U,transition:ne()};function ne(){if(ie||ee&&J.current.newIndex===w)return Lue;if(!(W&&!rw(D)||!c)&&(B||q))return Ti.Transition.toString({...c,property:E8})}}function Vue(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}}function tx(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const Hue=[Rt.Down,Rt.Right,Rt.Up,Rt.Left],hM=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:s,over:i,scrollableAncestors:a}}=t;if(Hue.includes(e.code)){if(e.preventDefault(),!n||!r)return;const l=[];s.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const h=o.get(f.id);if(h)switch(e.code){case Rt.Down:r.top<h.top&&l.push(f);break;case Rt.Up:r.top>h.top&&l.push(f);break;case Rt.Left:r.left>h.left&&l.push(f);break;case Rt.Right:r.left<h.left&&l.push(f);break}});const c=wce({collisionRect:r,droppableRects:o,droppableContainers:l});let u=J6(c,"id");if(u===(i==null?void 0:i.id)&&c.length>1&&(u=c[1].id),u!=null){const f=s.get(n.id),h=s.get(u),p=h?o.get(h.id):null,m=h==null?void 0:h.node.current;if(m&&p&&f&&h){const b=ow(m).some((k,E)=>a[E]!==k),y=_8(f,h),x=Wue(f,h),v=b||!y?{x:0,y:0}:{x:x?r.width-p.width:0,y:x?r.height-p.height:0},w={x:p.left,y:p.top};return v.x&&v.y?w:Tm(w,v)}}}};function _8(e,t){return!tx(e)||!tx(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Wue(e,t){return!tx(e)||!tx(t)||!_8(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function Uue(e,t,n){const[r,o]=_.useState(null),[s,i]=_.useState(""),a=()=>{const m={id:`hierarchy_${Date.now()}`,label:s||"New Hierarchy",type:"static",steps:[],default:!1};t([...e,m]),i(""),o(m.id)},l=m=>{t(e.filter(g=>g.id!==m))},c=(m,g)=>{t(e.map(b=>b.id===m?{...b,...g}:b))};return{editingHierarchy:r,setEditingHierarchy:o,newHierarchyName:s,setNewHierarchyName:i,createNewHierarchy:a,deleteHierarchy:l,updateHierarchy:c,addStepToHierarchy:(m,g)=>{const b=n.find(v=>v.id===g);if(!b)return;const y={field:b,mode:"drillDown",label:`Drill to ${b.label}`,retainFilters:!0,preferredChartType:"bar"},x=e.find(v=>v.id===m);x&&c(m,{steps:[...x.steps,y]})},removeStepFromHierarchy:(m,g)=>{const b=e.find(y=>y.id===m);if(b){const y=[...b.steps];y.splice(g,1),c(m,{steps:y})}},updateStep:(m,g,b)=>{const y=e.find(x=>x.id===m);if(y){const x=y.steps.map((v,w)=>w===g?{...v,...b}:v);c(m,{steps:x})}},setDefaultHierarchy:m=>{t(e.map(g=>({...g,default:g.id===m})))}}}function que({value:e,isEditing:t,onEdit:n,onSave:r,onCancel:o,placeholder:s="Enter text...",inputClassName:i="",displayClassName:a=""}){const[l,c]=_.useState(e);_.useEffect(()=>{c(e)},[e]);const u=m=>{m.key===" "&&m.stopPropagation(),m.key==="Enter"?r(l):m.key==="Escape"&&(c(e),o())},f=()=>{r(l)},h=m=>{m.stopPropagation()},p=m=>{m.stopPropagation()};return t?d.jsx("input",{type:"text",value:l,onChange:m=>c(m.target.value),onKeyDown:u,onBlur:f,onMouseDown:h,onPointerDown:p,className:`min-w-0 border-b border-blue-300 bg-transparent focus:border-blue-500 focus:outline-none dark:border-blue-600 dark:focus:border-blue-400 ${i}`,placeholder:s,autoFocus:!0}):d.jsx("span",{className:`cursor-pointer transition-colors hover:text-blue-600 dark:hover:text-blue-400 ${a}`,onClick:m=>{m.stopPropagation(),n()},onPointerDown:m=>m.stopPropagation(),title:"Click to edit",children:e||s})}function Gue(e,t=globalThis==null?void 0:globalThis.document){const n=rr(e);C.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Yue="DismissableLayer",RE="dismissableLayer.update",Zue="dismissableLayer.pointerDownOutside",Kue="dismissableLayer.focusOutside",OT,k8=C.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Yu=C.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=C.useContext(k8),[u,f]=C.useState(null),h=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=C.useState({}),m=Je(t,E=>f(E)),g=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(b),x=u?g.indexOf(u):-1,v=c.layersWithOutsidePointerEventsDisabled.size>0,w=x>=y,S=Jue(E=>{const N=E.target,R=[...c.branches].some(M=>M.contains(N));!w||R||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),k=ede(E=>{const N=E.target;[...c.branches].some(M=>M.contains(N))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return Gue(E=>{x===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),C.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(OT=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),FT(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=OT)}},[u,h,n,c]),C.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),FT())},[u,c]),C.useEffect(()=>{const E=()=>p({});return document.addEventListener(RE,E),()=>document.removeEventListener(RE,E)},[]),d.jsx(Pe.div,{...l,ref:m,style:{pointerEvents:v?w?"auto":"none":void 0,...e.style},onFocusCapture:xe(e.onFocusCapture,k.onFocusCapture),onBlurCapture:xe(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:xe(e.onPointerDownCapture,S.onPointerDownCapture)})});Yu.displayName=Yue;var Xue="DismissableLayerBranch",Que=C.forwardRef((e,t)=>{const n=C.useContext(k8),r=C.useRef(null),o=Je(t,r);return C.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),d.jsx(Pe.div,{...e,ref:o})});Que.displayName=Xue;function Jue(e,t=globalThis==null?void 0:globalThis.document){const n=rr(e),r=C.useRef(!1),o=C.useRef(()=>{});return C.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){N8(Zue,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function ede(e,t=globalThis==null?void 0:globalThis.document){const n=rr(e),r=C.useRef(!1);return C.useEffect(()=>{const o=s=>{s.target&&!r.current&&N8(Kue,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function FT(){const e=new CustomEvent(RE);document.dispatchEvent(e)}function N8(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?kL(o,s):o.dispatchEvent(s)}var DS=0;function aw(){C.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??$T()),document.body.insertAdjacentElement("beforeend",e[1]??$T()),DS++,()=>{DS===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),DS--}},[])}function $T(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var PS="focusScope.autoFocusOnMount",TS="focusScope.autoFocusOnUnmount",LT={bubbles:!1,cancelable:!0},tde="FocusScope",Hg=C.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=C.useState(null),c=rr(o),u=rr(s),f=C.useRef(null),h=Je(t,g=>l(g)),p=C.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;C.useEffect(()=>{if(r){let g=function(v){if(p.paused||!a)return;const w=v.target;a.contains(w)?f.current=w:il(f.current,{select:!0})},b=function(v){if(p.paused||!a)return;const w=v.relatedTarget;w!==null&&(a.contains(w)||il(f.current,{select:!0}))},y=function(v){if(document.activeElement===document.body)for(const S of v)S.removedNodes.length>0&&il(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",b);const x=new MutationObserver(y);return a&&x.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",b),x.disconnect()}}},[r,a,p.paused]),C.useEffect(()=>{if(a){BT.add(p);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(PS,LT);a.addEventListener(PS,c),a.dispatchEvent(y),y.defaultPrevented||(nde(ade(M8(a)),{select:!0}),document.activeElement===g&&il(a))}return()=>{a.removeEventListener(PS,c),setTimeout(()=>{const y=new CustomEvent(TS,LT);a.addEventListener(TS,u),a.dispatchEvent(y),y.defaultPrevented||il(g??document.body,{select:!0}),a.removeEventListener(TS,u),BT.remove(p)},0)}}},[a,c,u,p]);const m=C.useCallback(g=>{if(!n&&!r||p.paused)return;const b=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(b&&y){const x=g.currentTarget,[v,w]=rde(x);v&&w?!g.shiftKey&&y===w?(g.preventDefault(),n&&il(v,{select:!0})):g.shiftKey&&y===v&&(g.preventDefault(),n&&il(w,{select:!0})):y===x&&g.preventDefault()}},[n,r,p.paused]);return d.jsx(Pe.div,{tabIndex:-1,...i,ref:h,onKeyDown:m})});Hg.displayName=tde;function nde(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(il(r,{select:t}),document.activeElement!==n)return}function rde(e){const t=M8(e),n=zT(t,e),r=zT(t.reverse(),e);return[n,r]}function M8(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function zT(e,t){for(const n of e)if(!ode(n,{upTo:t}))return n}function ode(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function sde(e){return e instanceof HTMLInputElement&&"select"in e}function il(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&sde(e)&&t&&e.select()}}var BT=ide();function ide(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=VT(e,t),e.unshift(t)},remove(t){var n;e=VT(e,t),(n=e[0])==null||n.resume()}}}function VT(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ade(e){return e.filter(t=>t.tagName!=="A")}const lde=["top","right","bottom","left"],Da=Math.min,Lr=Math.max,Om=Math.round,iy=Math.floor,yi=e=>({x:e,y:e}),cde={left:"right",right:"left",bottom:"top",top:"bottom"},ude={start:"end",end:"start"};function DE(e,t,n){return Lr(e,Da(t,n))}function Ai(e,t){return typeof e=="function"?e(t):e}function Pa(e){return e.split("-")[0]}function vh(e){return e.split("-")[1]}function pM(e){return e==="x"?"y":"x"}function mM(e){return e==="y"?"height":"width"}function Tl(e){return["top","bottom"].includes(Pa(e))?"y":"x"}function gM(e){return pM(Tl(e))}function dde(e,t,n){n===void 0&&(n=!1);const r=vh(e),o=gM(e),s=mM(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=nx(i)),[i,nx(i)]}function fde(e){const t=nx(e);return[PE(e),t,PE(t)]}function PE(e){return e.replace(/start|end/g,t=>ude[t])}function hde(e,t,n){const r=["left","right"],o=["right","left"],s=["top","bottom"],i=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?s:i;default:return[]}}function pde(e,t,n,r){const o=vh(e);let s=hde(Pa(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(PE)))),s}function nx(e){return e.replace(/left|right|bottom|top/g,t=>cde[t])}function mde(e){return{top:0,right:0,bottom:0,left:0,...e}}function j8(e){return typeof e!="number"?mde(e):{top:e,right:e,bottom:e,left:e}}function rx(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function HT(e,t,n){let{reference:r,floating:o}=e;const s=Tl(t),i=gM(t),a=mM(i),l=Pa(t),c=s==="y",u=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:u,y:r.y-o.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(vh(t)){case"start":p[i]-=h*(n&&c?-1:1);break;case"end":p[i]+=h*(n&&c?-1:1);break}return p}const gde=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:f}=HT(c,r,l),h=r,p={},m=0;for(let g=0;g<a.length;g++){const{name:b,fn:y}=a[g],{x,y:v,data:w,reset:S}=await y({x:u,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});u=x??u,f=v??f,p={...p,[b]:{...p[b],...w}},S&&m<=50&&(m++,typeof S=="object"&&(S.placement&&(h=S.placement),S.rects&&(c=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:u,y:f}=HT(c,h,l)),g=-1)}return{x:u,y:f,placement:h,strategy:o,middlewareData:p}};async function Lf(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=Ai(t,e),m=j8(p),b=a[h?f==="floating"?"reference":"floating":f],y=rx(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(b)))==null||n?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),x=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,v=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),w=await(s.isElement==null?void 0:s.isElement(v))?await(s.getScale==null?void 0:s.getScale(v))||{x:1,y:1}:{x:1,y:1},S=rx(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:v,strategy:l}):x);return{top:(y.top-S.top+m.top)/w.y,bottom:(S.bottom-y.bottom+m.bottom)/w.y,left:(y.left-S.left+m.left)/w.x,right:(S.right-y.right+m.right)/w.x}}const bde=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=Ai(e,t)||{};if(c==null)return{};const f=j8(u),h={x:n,y:r},p=gM(o),m=mM(p),g=await i.getDimensions(c),b=p==="y",y=b?"top":"left",x=b?"bottom":"right",v=b?"clientHeight":"clientWidth",w=s.reference[m]+s.reference[p]-h[p]-s.floating[m],S=h[p]-s.reference[p],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=k?k[v]:0;(!E||!await(i.isElement==null?void 0:i.isElement(k)))&&(E=a.floating[v]||s.floating[m]);const N=w/2-S/2,R=E/2-g[m]/2-1,M=Da(f[y],R),T=Da(f[x],R),D=M,A=E-g[m]-T,O=E/2-g[m]/2+N,j=DE(D,O,A),F=!l.arrow&&vh(o)!=null&&O!==j&&s.reference[m]/2-(O<D?M:T)-g[m]/2<0,L=F?O<D?O-D:O-A:0;return{[p]:h[p]+L,data:{[p]:j,centerOffset:O-j-L,...F&&{alignmentOffset:L}},reset:F}}}),yde=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...b}=Ai(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Pa(o),x=Tl(a),v=Pa(a)===a,w=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=h||(v||!g?[nx(a)]:fde(a)),k=m!=="none";!h&&k&&S.push(...pde(a,g,m,w));const E=[a,...S],N=await Lf(t,b),R=[];let M=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&R.push(N[y]),f){const O=dde(o,i,w);R.push(N[O[0]],N[O[1]])}if(M=[...M,{placement:o,overflows:R}],!R.every(O=>O<=0)){var T,D;const O=(((T=s.flip)==null?void 0:T.index)||0)+1,j=E[O];if(j)return{data:{index:O,overflows:M},reset:{placement:j}};let F=(D=M.filter(L=>L.overflows[0]<=0).sort((L,V)=>L.overflows[1]-V.overflows[1])[0])==null?void 0:D.placement;if(!F)switch(p){case"bestFit":{var A;const L=(A=M.filter(V=>{if(k){const $=Tl(V.placement);return $===x||$==="y"}return!0}).map(V=>[V.placement,V.overflows.filter($=>$>0).reduce(($,I)=>$+I,0)]).sort((V,$)=>V[1]-$[1])[0])==null?void 0:A[0];L&&(F=L);break}case"initialPlacement":F=a;break}if(o!==F)return{reset:{placement:F}}}return{}}}};function WT(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function UT(e){return lde.some(t=>e[t]>=0)}const xde=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Ai(e,t);switch(r){case"referenceHidden":{const s=await Lf(t,{...o,elementContext:"reference"}),i=WT(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:UT(i)}}}case"escaped":{const s=await Lf(t,{...o,altBoundary:!0}),i=WT(s,n.floating);return{data:{escapedOffsets:i,escaped:UT(i)}}}default:return{}}}}};async function vde(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Pa(n),a=vh(n),l=Tl(n)==="y",c=["left","top"].includes(i)?-1:1,u=s&&l?-1:1,f=Ai(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*u,y:h*c}:{x:h*c,y:p*u}}const wde=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await vde(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},Sde=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:b=>{let{x:y,y:x}=b;return{x:y,y:x}}},...l}=Ai(e,t),c={x:n,y:r},u=await Lf(t,l),f=Tl(Pa(o)),h=pM(f);let p=c[h],m=c[f];if(s){const b=h==="y"?"top":"left",y=h==="y"?"bottom":"right",x=p+u[b],v=p-u[y];p=DE(x,p,v)}if(i){const b=f==="y"?"top":"left",y=f==="y"?"bottom":"right",x=m+u[b],v=m-u[y];m=DE(x,m,v)}const g=a.fn({...t,[h]:p,[f]:m});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[h]:s,[f]:i}}}}}},Cde=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Ai(e,t),u={x:n,y:r},f=Tl(o),h=pM(f);let p=u[h],m=u[f];const g=Ai(a,t),b=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const v=h==="y"?"height":"width",w=s.reference[h]-s.floating[v]+b.mainAxis,S=s.reference[h]+s.reference[v]-b.mainAxis;p<w?p=w:p>S&&(p=S)}if(c){var y,x;const v=h==="y"?"width":"height",w=["top","left"].includes(Pa(o)),S=s.reference[f]-s.floating[v]+(w&&((y=i.offset)==null?void 0:y[f])||0)+(w?0:b.crossAxis),k=s.reference[f]+s.reference[v]+(w?0:((x=i.offset)==null?void 0:x[f])||0)-(w?b.crossAxis:0);m<S?m=S:m>k&&(m=k)}return{[h]:p,[f]:m}}}},Ede=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=Ai(e,t),u=await Lf(t,c),f=Pa(o),h=vh(o),p=Tl(o)==="y",{width:m,height:g}=s.floating;let b,y;f==="top"||f==="bottom"?(b=f,y=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=f,b=h==="end"?"top":"bottom");const x=g-u.top-u.bottom,v=m-u.left-u.right,w=Da(g-u[b],x),S=Da(m-u[y],v),k=!t.middlewareData.shift;let E=w,N=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=v),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=x),k&&!h){const M=Lr(u.left,0),T=Lr(u.right,0),D=Lr(u.top,0),A=Lr(u.bottom,0);p?N=m-2*(M!==0||T!==0?M+T:Lr(u.left,u.right)):E=g-2*(D!==0||A!==0?D+A:Lr(u.top,u.bottom))}await l({...t,availableWidth:N,availableHeight:E});const R=await i.getDimensions(a.floating);return m!==R.width||g!==R.height?{reset:{rects:!0}}:{}}}};function lw(){return typeof window<"u"}function wh(e){return R8(e)?(e.nodeName||"").toLowerCase():"#document"}function Yo(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ui(e){var t;return(t=(R8(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function R8(e){return lw()?e instanceof Node||e instanceof Yo(e).Node:!1}function zr(e){return lw()?e instanceof Element||e instanceof Yo(e).Element:!1}function Ii(e){return lw()?e instanceof HTMLElement||e instanceof Yo(e).HTMLElement:!1}function qT(e){return!lw()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Yo(e).ShadowRoot}function Wg(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Zs(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function _de(e){return["table","td","th"].includes(wh(e))}function cw(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function bM(e){const t=yM(),n=zr(e)?Zs(e):e;return["transform","translate","scale","rotate","perspective"].some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function kde(e){let t=Al(e);for(;Ii(t)&&!zf(t);){if(bM(t))return t;if(cw(t))return null;t=Al(t)}return null}function yM(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function zf(e){return["html","body","#document"].includes(wh(e))}function Zs(e){return Yo(e).getComputedStyle(e)}function uw(e){return zr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Al(e){if(wh(e)==="html")return e;const t=e.assignedSlot||e.parentNode||qT(e)&&e.host||Ui(e);return qT(t)?t.host:t}function D8(e){const t=Al(e);return zf(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ii(t)&&Wg(t)?t:D8(t)}function Fm(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=D8(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Yo(o);if(s){const a=TE(i);return t.concat(i,i.visualViewport||[],Wg(o)?o:[],a&&n?Fm(a):[])}return t.concat(o,Fm(o,[],n))}function TE(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function P8(e){const t=Zs(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ii(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Om(n)!==s||Om(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function xM(e){return zr(e)?e:e.contextElement}function nf(e){const t=xM(e);if(!Ii(t))return yi(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=P8(t);let i=(s?Om(n.width):n.width)/r,a=(s?Om(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Nde=yi(0);function T8(e){const t=Yo(e);return!yM()||!t.visualViewport?Nde:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Mde(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Yo(e)?!1:t}function Su(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=xM(e);let i=yi(1);t&&(r?zr(r)&&(i=nf(r)):i=nf(e));const a=Mde(s,n,r)?T8(s):yi(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,u=o.width/i.x,f=o.height/i.y;if(s){const h=Yo(s),p=r&&zr(r)?Yo(r):r;let m=h,g=TE(m);for(;g&&r&&p!==m;){const b=nf(g),y=g.getBoundingClientRect(),x=Zs(g),v=y.left+(g.clientLeft+parseFloat(x.paddingLeft))*b.x,w=y.top+(g.clientTop+parseFloat(x.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,f*=b.y,l+=v,c+=w,m=Yo(g),g=TE(m)}}return rx({width:u,height:f,x:l,y:c})}function vM(e,t){const n=uw(e).scrollLeft;return t?t.left+n:Su(Ui(e)).left+n}function A8(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:vM(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function jde(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Ui(r),a=t?cw(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=yi(1);const u=yi(0),f=Ii(r);if((f||!f&&!s)&&((wh(r)!=="body"||Wg(i))&&(l=uw(r)),Ii(r))){const p=Su(r);c=nf(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const h=i&&!f&&!s?A8(i,l,!0):yi(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-l.scrollTop*c.y+u.y+h.y}}function Rde(e){return Array.from(e.getClientRects())}function Dde(e){const t=Ui(e),n=uw(e),r=e.ownerDocument.body,o=Lr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Lr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+vM(e);const a=-n.scrollTop;return Zs(r).direction==="rtl"&&(i+=Lr(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function Pde(e,t){const n=Yo(e),r=Ui(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const c=yM();(!c||c&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a,y:l}}function Tde(e,t){const n=Su(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Ii(e)?nf(e):yi(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function GT(e,t,n){let r;if(t==="viewport")r=Pde(e,n);else if(t==="document")r=Dde(Ui(e));else if(zr(t))r=Tde(t,n);else{const o=T8(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return rx(r)}function I8(e,t){const n=Al(e);return n===t||!zr(n)||zf(n)?!1:Zs(n).position==="fixed"||I8(n,t)}function Ade(e,t){const n=t.get(e);if(n)return n;let r=Fm(e,[],!1).filter(a=>zr(a)&&wh(a)!=="body"),o=null;const s=Zs(e).position==="fixed";let i=s?Al(e):e;for(;zr(i)&&!zf(i);){const a=Zs(i),l=bM(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Wg(i)&&!l&&I8(e,i))?r=r.filter(u=>u!==i):o=a,i=Al(i)}return t.set(e,r),r}function Ide(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?cw(t)?[]:Ade(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,u)=>{const f=GT(t,u,o);return c.top=Lr(f.top,c.top),c.right=Da(f.right,c.right),c.bottom=Da(f.bottom,c.bottom),c.left=Lr(f.left,c.left),c},GT(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Ode(e){const{width:t,height:n}=P8(e);return{width:t,height:n}}function Fde(e,t,n){const r=Ii(t),o=Ui(t),s=n==="fixed",i=Su(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=yi(0);if(r||!r&&!s)if((wh(t)!=="body"||Wg(o))&&(a=uw(t)),r){const h=Su(t,!0,s,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else o&&(l.x=vM(o));const c=o&&!r&&!s?A8(o,a):yi(0),u=i.left+a.scrollLeft-l.x-c.x,f=i.top+a.scrollTop-l.y-c.y;return{x:u,y:f,width:i.width,height:i.height}}function AS(e){return Zs(e).position==="static"}function YT(e,t){if(!Ii(e)||Zs(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ui(e)===n&&(n=n.ownerDocument.body),n}function O8(e,t){const n=Yo(e);if(cw(e))return n;if(!Ii(e)){let o=Al(e);for(;o&&!zf(o);){if(zr(o)&&!AS(o))return o;o=Al(o)}return n}let r=YT(e,t);for(;r&&_de(r)&&AS(r);)r=YT(r,t);return r&&zf(r)&&AS(r)&&!bM(r)?n:r||kde(e)||n}const $de=async function(e){const t=this.getOffsetParent||O8,n=this.getDimensions,r=await n(e.floating);return{reference:Fde(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Lde(e){return Zs(e).direction==="rtl"}const zde={convertOffsetParentRelativeRectToViewportRelativeRect:jde,getDocumentElement:Ui,getClippingRect:Ide,getOffsetParent:O8,getElementRects:$de,getClientRects:Rde,getDimensions:Ode,getScale:nf,isElement:zr,isRTL:Lde};function F8(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Bde(e,t){let n=null,r;const o=Ui(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:u,top:f,width:h,height:p}=c;if(a||t(),!h||!p)return;const m=iy(f),g=iy(o.clientWidth-(u+h)),b=iy(o.clientHeight-(f+p)),y=iy(u),v={rootMargin:-m+"px "+-g+"px "+-b+"px "+-y+"px",threshold:Lr(0,Da(1,l))||1};let w=!0;function S(k){const E=k[0].intersectionRatio;if(E!==l){if(!w)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!F8(c,e.getBoundingClientRect())&&i(),w=!1}try{n=new IntersectionObserver(S,{...v,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,v)}n.observe(e)}return i(!0),s}function wM(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=xM(e),u=o||s?[...c?Fm(c):[],...Fm(t)]:[];u.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=c&&a?Bde(c,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(y=>{let[x]=y;x&&x.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var v;(v=p)==null||v.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let m,g=l?Su(e):null;l&&b();function b(){const y=Su(e);g&&!F8(g,y)&&n(),g=y,m=requestAnimationFrame(b)}return n(),()=>{var y;u.forEach(x=>{o&&x.removeEventListener("scroll",n),s&&x.removeEventListener("resize",n)}),f==null||f(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(m)}}const IS=Lf,Vde=wde,Hde=Sde,Wde=yde,Ude=Ede,qde=xde,ZT=bde,Gde=Cde,Yde=(e,t,n)=>{const r=new Map,o={platform:zde,...n},s={...o.platform,_c:r};return gde(e,t,{...o,platform:s})};var p0=typeof document<"u"?_.useLayoutEffect:_.useEffect;function ox(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ox(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!ox(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function $8(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function KT(e,t){const n=$8(e);return Math.round(t*n)/n}function OS(e){const t=C.useRef(e);return p0(()=>{t.current=e}),t}function SM(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,f]=C.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=C.useState(r);ox(h,r)||p(r);const[m,g]=C.useState(null),[b,y]=C.useState(null),x=C.useCallback(V=>{V!==k.current&&(k.current=V,g(V))},[]),v=C.useCallback(V=>{V!==E.current&&(E.current=V,y(V))},[]),w=s||m,S=i||b,k=C.useRef(null),E=C.useRef(null),N=C.useRef(u),R=l!=null,M=OS(l),T=OS(o),D=OS(c),A=C.useCallback(()=>{if(!k.current||!E.current)return;const V={placement:t,strategy:n,middleware:h};T.current&&(V.platform=T.current),Yde(k.current,E.current,V).then($=>{const I={...$,isPositioned:D.current!==!1};O.current&&!ox(N.current,I)&&(N.current=I,ja.flushSync(()=>{f(I)}))})},[h,t,n,T,D]);p0(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f(V=>({...V,isPositioned:!1})))},[c]);const O=C.useRef(!1);p0(()=>(O.current=!0,()=>{O.current=!1}),[]),p0(()=>{if(w&&(k.current=w),S&&(E.current=S),w&&S){if(M.current)return M.current(w,S,A);A()}},[w,S,A,M,R]);const j=C.useMemo(()=>({reference:k,floating:E,setReference:x,setFloating:v}),[x,v]),F=C.useMemo(()=>({reference:w,floating:S}),[w,S]),L=C.useMemo(()=>{const V={position:n,left:0,top:0};if(!F.floating)return V;const $=KT(F.floating,u.x),I=KT(F.floating,u.y);return a?{...V,transform:"translate("+$+"px, "+I+"px)",...$8(F.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:$,top:I}},[n,a,F.floating,u.x,u.y]);return C.useMemo(()=>({...u,update:A,refs:j,elements:F,floatingStyles:L}),[u,A,j,F,L])}const Zde=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?ZT({element:r.current,padding:o}).fn(n):{}:r?ZT({element:r,padding:o}).fn(n):{}}}},dw=(e,t)=>({...Vde(e),options:[e,t]}),CM=(e,t)=>({...Hde(e),options:[e,t]}),L8=(e,t)=>({...Gde(e),options:[e,t]}),EM=(e,t)=>({...Wde(e),options:[e,t]}),_M=(e,t)=>({...Ude(e),options:[e,t]}),z8=(e,t)=>({...qde(e),options:[e,t]}),B8=(e,t)=>({...Zde(e),options:[e,t]});var Kde="Arrow",V8=C.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return d.jsx(Pe.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});V8.displayName=Kde;var Xde=V8;function fw(e){const[t,n]=C.useState(void 0);return Mr(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var kM="Popper",[H8,qi]=hr(kM),[Qde,W8]=H8(kM),U8=e=>{const{__scopePopper:t,children:n}=e,[r,o]=C.useState(null);return d.jsx(Qde,{scope:t,anchor:r,onAnchorChange:o,children:n})};U8.displayName=kM;var q8="PopperAnchor",G8=C.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=W8(q8,n),i=C.useRef(null),a=Je(t,i);return C.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||i.current)}),r?null:d.jsx(Pe.div,{...o,ref:a})});G8.displayName=q8;var NM="PopperContent",[Jde,efe]=H8(NM),Y8=C.forwardRef((e,t)=>{var U,z,G,J,ee,q;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:m,...g}=e,b=W8(NM,n),[y,x]=C.useState(null),v=Je(t,ie=>x(ie)),[w,S]=C.useState(null),k=fw(w),E=(k==null?void 0:k.width)??0,N=(k==null?void 0:k.height)??0,R=r+(s!=="center"?"-"+s:""),M=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},T=Array.isArray(c)?c:[c],D=T.length>0,A={padding:M,boundary:T.filter(nfe),altBoundary:D},{refs:O,floatingStyles:j,placement:F,isPositioned:L,middlewareData:V}=SM({strategy:"fixed",placement:R,whileElementsMounted:(...ie)=>wM(...ie,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[dw({mainAxis:o+N,alignmentAxis:i}),l&&CM({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?L8():void 0,...A}),l&&EM({...A}),_M({...A,apply:({elements:ie,rects:ne,availableWidth:le,availableHeight:ge})=>{const{width:Me,height:ue}=ne.reference,ke=ie.floating.style;ke.setProperty("--radix-popper-available-width",`${le}px`),ke.setProperty("--radix-popper-available-height",`${ge}px`),ke.setProperty("--radix-popper-anchor-width",`${Me}px`),ke.setProperty("--radix-popper-anchor-height",`${ue}px`)}}),w&&B8({element:w,padding:a}),rfe({arrowWidth:E,arrowHeight:N}),h&&z8({strategy:"referenceHidden",...A})]}),[$,I]=X8(F),H=rr(m);Mr(()=>{L&&(H==null||H())},[L,H]);const B=(U=V.arrow)==null?void 0:U.x,P=(z=V.arrow)==null?void 0:z.y,W=((G=V.arrow)==null?void 0:G.centerOffset)!==0,[Y,X]=C.useState();return Mr(()=>{y&&X(window.getComputedStyle(y).zIndex)},[y]),d.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...j,transform:L?j.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Y,"--radix-popper-transform-origin":[(J=V.transformOrigin)==null?void 0:J.x,(ee=V.transformOrigin)==null?void 0:ee.y].join(" "),...((q=V.hide)==null?void 0:q.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:d.jsx(Jde,{scope:n,placedSide:$,onArrowChange:S,arrowX:B,arrowY:P,shouldHideArrow:W,children:d.jsx(Pe.div,{"data-side":$,"data-align":I,...g,ref:v,style:{...g.style,animation:L?void 0:"none"}})})})});Y8.displayName=NM;var Z8="PopperArrow",tfe={top:"bottom",right:"left",bottom:"top",left:"right"},K8=C.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=efe(Z8,r),i=tfe[s.placedSide];return d.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:d.jsx(Xde,{...o,ref:n,style:{...o.style,display:"block"}})})});K8.displayName=Z8;function nfe(e){return e!==null}var rfe=e=>({name:"transformOrigin",options:e,fn(t){var b,y,x;const{placement:n,rects:r,middlewareData:o}=t,i=((b=o.arrow)==null?void 0:b.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,u]=X8(n),f={start:"0%",center:"50%",end:"100%"}[u],h=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((x=o.arrow)==null?void 0:x.y)??0)+l/2;let m="",g="";return c==="bottom"?(m=i?f:`${h}px`,g=`${-l}px`):c==="top"?(m=i?f:`${h}px`,g=`${r.floating.height+l}px`):c==="right"?(m=`${-l}px`,g=i?f:`${p}px`):c==="left"&&(m=`${r.floating.width+l}px`,g=i?f:`${p}px`),{data:{x:m,y:g}}}});function X8(e){const[t,n="center"]=e.split("-");return[t,n]}var Sh=U8,Ch=G8,Ug=Y8,qg=K8,ofe="Portal",Zu=C.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=C.useState(!1);Mr(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?jn.createPortal(d.jsx(Pe.div,{...r,ref:t}),i):null});Zu.displayName=ofe;var Q8=C.forwardRef((e,t)=>{const{children:n,...r}=e,o=C.Children.toArray(n),s=o.find(ife);if(s){const i=s.props.children,a=o.map(l=>l===s?C.Children.count(i)>1?C.Children.only(null):C.isValidElement(i)?i.props.children:null:l);return d.jsx(AE,{...r,ref:t,children:C.isValidElement(i)?C.cloneElement(i,void 0,a):null})}return d.jsx(AE,{...r,ref:t,children:n})});Q8.displayName="Slot";var AE=C.forwardRef((e,t)=>{const{children:n,...r}=e;if(C.isValidElement(n)){const o=lfe(n),s=afe(r,n.props);return n.type!==C.Fragment&&(s.ref=t?so(t,o):o),C.cloneElement(n,s)}return C.Children.count(n)>1?C.Children.only(null):null});AE.displayName="SlotClone";var sfe=({children:e})=>d.jsx(d.Fragment,{children:e});function ife(e){return C.isValidElement(e)&&e.type===sfe}function afe(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function lfe(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var MM="Popover",[J8,JZe]=hr(MM,[qi]),Gg=qi(),[cfe,tc]=J8(MM),ez=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,a=Gg(t),l=C.useRef(null),[c,u]=C.useState(!1),[f=!1,h]=jr({prop:r,defaultProp:o,onChange:s});return d.jsx(Sh,{...a,children:d.jsx(cfe,{scope:t,contentId:Wn(),triggerRef:l,open:f,onOpenChange:h,onOpenToggle:C.useCallback(()=>h(p=>!p),[h]),hasCustomAnchor:c,onCustomAnchorAdd:C.useCallback(()=>u(!0),[]),onCustomAnchorRemove:C.useCallback(()=>u(!1),[]),modal:i,children:n})})};ez.displayName=MM;var tz="PopoverAnchor",ufe=C.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=tc(tz,n),s=Gg(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:a}=o;return C.useEffect(()=>(i(),()=>a()),[i,a]),d.jsx(Ch,{...s,...r,ref:t})});ufe.displayName=tz;var nz="PopoverTrigger",rz=C.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=tc(nz,n),s=Gg(n),i=Je(t,o.triggerRef),a=d.jsx(Pe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":lz(o.open),...r,ref:i,onClick:xe(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:d.jsx(Ch,{asChild:!0,...s,children:a})});rz.displayName=nz;var jM="PopoverPortal",[dfe,ffe]=J8(jM,{forceMount:void 0}),oz=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,s=tc(jM,t);return d.jsx(dfe,{scope:t,forceMount:n,children:d.jsx(Un,{present:n||s.open,children:d.jsx(Zu,{asChild:!0,container:o,children:r})})})};oz.displayName=jM;var Bf="PopoverContent",sz=C.forwardRef((e,t)=>{const n=ffe(Bf,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,s=tc(Bf,e.__scopePopover);return d.jsx(Un,{present:r||s.open,children:s.modal?d.jsx(hfe,{...o,ref:t}):d.jsx(pfe,{...o,ref:t})})});sz.displayName=Bf;var hfe=C.forwardRef((e,t)=>{const n=tc(Bf,e.__scopePopover),r=C.useRef(null),o=Je(t,r),s=C.useRef(!1);return C.useEffect(()=>{const i=r.current;if(i)return ph(i)},[]),d.jsx(Hu,{as:Q8,allowPinchZoom:!0,children:d.jsx(iz,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:xe(e.onCloseAutoFocus,i=>{var a;i.preventDefault(),s.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:xe(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;s.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:xe(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),pfe=C.forwardRef((e,t)=>{const n=tc(Bf,e.__scopePopover),r=C.useRef(!1),o=C.useRef(!1);return d.jsx(iz,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),iz=C.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...f}=e,h=tc(Bf,n),p=Gg(n);return aw(),d.jsx(Hg,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:d.jsx(Yu,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:d.jsx(Ug,{"data-state":lz(h.open),role:"dialog",id:h.contentId,...p,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),az="PopoverClose",mfe=C.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=tc(az,n);return d.jsx(Pe.button,{type:"button",...r,ref:t,onClick:xe(e.onClick,()=>o.onOpenChange(!1))})});mfe.displayName=az;var gfe="PopoverArrow",bfe=C.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Gg(n);return d.jsx(qg,{...o,...r,ref:t})});bfe.displayName=gfe;function lz(e){return e?"open":"closed"}var yfe=ez,xfe=rz,vfe=oz,hw=sz;const Zo=yfe,Ko=xfe,_o=C.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>d.jsx(vfe,{children:d.jsx(Qs,{children:d.jsx(hw,{ref:o,align:t,sideOffset:n,className:K("z-49 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})})}));_o.displayName=hw.displayName;function IE(e,[t,n]){return Math.min(n,Math.max(t,e))}var cz=C.forwardRef((e,t)=>{const{children:n,...r}=e,o=C.Children.toArray(n),s=o.find(Sfe);if(s){const i=s.props.children,a=o.map(l=>l===s?C.Children.count(i)>1?C.Children.only(null):C.isValidElement(i)?i.props.children:null:l);return d.jsx(OE,{...r,ref:t,children:C.isValidElement(i)?C.cloneElement(i,void 0,a):null})}return d.jsx(OE,{...r,ref:t,children:n})});cz.displayName="Slot";var OE=C.forwardRef((e,t)=>{const{children:n,...r}=e;if(C.isValidElement(n)){const o=Efe(n),s=Cfe(r,n.props);return n.type!==C.Fragment&&(s.ref=t?so(t,o):o),C.cloneElement(n,s)}return C.Children.count(n)>1?C.Children.only(null):null});OE.displayName="SlotClone";var wfe=({children:e})=>d.jsx(d.Fragment,{children:e});function Sfe(e){return C.isValidElement(e)&&e.type===wfe}function Cfe(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function Efe(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function pw(e){const t=C.useRef({value:e,previous:e});return C.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var _fe="VisuallyHidden",RM=C.forwardRef((e,t)=>d.jsx(Pe.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));RM.displayName=_fe;var kfe=RM,Nfe=[" ","Enter","ArrowUp","ArrowDown"],Mfe=[" ","Enter"],Yg="Select",[mw,gw,jfe]=zv(Yg),[Eh,eKe]=hr(Yg,[jfe,qi]),bw=qi(),[Rfe,nc]=Eh(Yg),[Dfe,Pfe]=Eh(Yg),uz=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:u,autoComplete:f,disabled:h,required:p,form:m}=e,g=bw(t),[b,y]=C.useState(null),[x,v]=C.useState(null),[w,S]=C.useState(!1),k=Wu(c),[E=!1,N]=jr({prop:r,defaultProp:o,onChange:s}),[R,M]=jr({prop:i,defaultProp:a,onChange:l}),T=C.useRef(null),D=b?m||!!b.closest("form"):!0,[A,O]=C.useState(new Set),j=Array.from(A).map(F=>F.props.value).join(";");return d.jsx(Sh,{...g,children:d.jsxs(Rfe,{required:p,scope:t,trigger:b,onTriggerChange:y,valueNode:x,onValueNodeChange:v,valueNodeHasChildren:w,onValueNodeHasChildrenChange:S,contentId:Wn(),value:R,onValueChange:M,open:E,onOpenChange:N,dir:k,triggerPointerDownPosRef:T,disabled:h,children:[d.jsx(mw.Provider,{scope:t,children:d.jsx(Dfe,{scope:e.__scopeSelect,onNativeOptionAdd:C.useCallback(F=>{O(L=>new Set(L).add(F))},[]),onNativeOptionRemove:C.useCallback(F=>{O(L=>{const V=new Set(L);return V.delete(F),V})},[]),children:n})}),D?d.jsxs(Oz,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:f,value:R,onChange:F=>M(F.target.value),disabled:h,form:m,children:[R===void 0?d.jsx("option",{value:""}):null,Array.from(A)]},j):null]})})};uz.displayName=Yg;var dz="SelectTrigger",fz=C.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=bw(n),i=nc(dz,n),a=i.disabled||r,l=Je(t,i.onTriggerChange),c=gw(n),u=C.useRef("touch"),[f,h,p]=Fz(g=>{const b=c().filter(v=>!v.disabled),y=b.find(v=>v.value===i.value),x=$z(b,g,y);x!==void 0&&i.onValueChange(x.value)}),m=g=>{a||(i.onOpenChange(!0),p()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return d.jsx(Ch,{asChild:!0,...s,children:d.jsx(Pe.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Iz(i.value)?"":void 0,...o,ref:l,onClick:xe(o.onClick,g=>{g.currentTarget.focus(),u.current!=="mouse"&&m(g)}),onPointerDown:xe(o.onPointerDown,g=>{u.current=g.pointerType;const b=g.target;b.hasPointerCapture(g.pointerId)&&b.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(m(g),g.preventDefault())}),onKeyDown:xe(o.onKeyDown,g=>{const b=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&h(g.key),!(b&&g.key===" ")&&Nfe.includes(g.key)&&(m(),g.preventDefault())})})})});fz.displayName=dz;var hz="SelectValue",pz=C.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=nc(hz,n),{onValueNodeHasChildrenChange:c}=l,u=s!==void 0,f=Je(t,l.onValueNodeChange);return Mr(()=>{c(u)},[c,u]),d.jsx(Pe.span,{...a,ref:f,style:{pointerEvents:"none"},children:Iz(l.value)?d.jsx(d.Fragment,{children:i}):s})});pz.displayName=hz;var Tfe="SelectIcon",mz=C.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return d.jsx(Pe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});mz.displayName=Tfe;var Afe="SelectPortal",gz=e=>d.jsx(Zu,{asChild:!0,...e});gz.displayName=Afe;var Cu="SelectContent",bz=C.forwardRef((e,t)=>{const n=nc(Cu,e.__scopeSelect),[r,o]=C.useState();if(Mr(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?ja.createPortal(d.jsx(yz,{scope:e.__scopeSelect,children:d.jsx(mw.Slot,{scope:e.__scopeSelect,children:d.jsx("div",{children:e.children})})}),s):null}return d.jsx(xz,{...e,ref:t})});bz.displayName=Cu;var Ds=10,[yz,rc]=Eh(Cu),Ife="SelectContentImpl",xz=C.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:b,...y}=e,x=nc(Cu,n),[v,w]=C.useState(null),[S,k]=C.useState(null),E=Je(t,U=>w(U)),[N,R]=C.useState(null),[M,T]=C.useState(null),D=gw(n),[A,O]=C.useState(!1),j=C.useRef(!1);C.useEffect(()=>{if(v)return ph(v)},[v]),aw();const F=C.useCallback(U=>{const[z,...G]=D().map(q=>q.ref.current),[J]=G.slice(-1),ee=document.activeElement;for(const q of U)if(q===ee||(q==null||q.scrollIntoView({block:"nearest"}),q===z&&S&&(S.scrollTop=0),q===J&&S&&(S.scrollTop=S.scrollHeight),q==null||q.focus(),document.activeElement!==ee))return},[D,S]),L=C.useCallback(()=>F([N,v]),[F,N,v]);C.useEffect(()=>{A&&L()},[A,L]);const{onOpenChange:V,triggerPointerDownPosRef:$}=x;C.useEffect(()=>{if(v){let U={x:0,y:0};const z=J=>{var ee,q;U={x:Math.abs(Math.round(J.pageX)-(((ee=$.current)==null?void 0:ee.x)??0)),y:Math.abs(Math.round(J.pageY)-(((q=$.current)==null?void 0:q.y)??0))}},G=J=>{U.x<=10&&U.y<=10?J.preventDefault():v.contains(J.target)||V(!1),document.removeEventListener("pointermove",z),$.current=null};return $.current!==null&&(document.addEventListener("pointermove",z),document.addEventListener("pointerup",G,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",z),document.removeEventListener("pointerup",G,{capture:!0})}}},[v,V,$]),C.useEffect(()=>{const U=()=>V(!1);return window.addEventListener("blur",U),window.addEventListener("resize",U),()=>{window.removeEventListener("blur",U),window.removeEventListener("resize",U)}},[V]);const[I,H]=Fz(U=>{const z=D().filter(ee=>!ee.disabled),G=z.find(ee=>ee.ref.current===document.activeElement),J=$z(z,U,G);J&&setTimeout(()=>J.ref.current.focus())}),B=C.useCallback((U,z,G)=>{const J=!j.current&&!G;(x.value!==void 0&&x.value===z||J)&&(R(U),J&&(j.current=!0))},[x.value]),P=C.useCallback(()=>v==null?void 0:v.focus(),[v]),W=C.useCallback((U,z,G)=>{const J=!j.current&&!G;(x.value!==void 0&&x.value===z||J)&&T(U)},[x.value]),Y=r==="popper"?FE:vz,X=Y===FE?{side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:b}:{};return d.jsx(yz,{scope:n,content:v,viewport:S,onViewportChange:k,itemRefCallback:B,selectedItem:N,onItemLeave:P,itemTextRefCallback:W,focusSelectedItem:L,selectedItemText:M,position:r,isPositioned:A,searchRef:I,children:d.jsx(Hu,{as:cz,allowPinchZoom:!0,children:d.jsx(Hg,{asChild:!0,trapped:x.open,onMountAutoFocus:U=>{U.preventDefault()},onUnmountAutoFocus:xe(o,U=>{var z;(z=x.trigger)==null||z.focus({preventScroll:!0}),U.preventDefault()}),children:d.jsx(Yu,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:U=>U.preventDefault(),onDismiss:()=>x.onOpenChange(!1),children:d.jsx(Y,{role:"listbox",id:x.contentId,"data-state":x.open?"open":"closed",dir:x.dir,onContextMenu:U=>U.preventDefault(),...y,...X,onPlaced:()=>O(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:xe(y.onKeyDown,U=>{const z=U.ctrlKey||U.altKey||U.metaKey;if(U.key==="Tab"&&U.preventDefault(),!z&&U.key.length===1&&H(U.key),["ArrowUp","ArrowDown","Home","End"].includes(U.key)){let J=D().filter(ee=>!ee.disabled).map(ee=>ee.ref.current);if(["ArrowUp","End"].includes(U.key)&&(J=J.slice().reverse()),["ArrowUp","ArrowDown"].includes(U.key)){const ee=U.target,q=J.indexOf(ee);J=J.slice(q+1)}setTimeout(()=>F(J)),U.preventDefault()}})})})})})})});xz.displayName=Ife;var Ofe="SelectItemAlignedPosition",vz=C.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=nc(Cu,n),i=rc(Cu,n),[a,l]=C.useState(null),[c,u]=C.useState(null),f=Je(t,E=>u(E)),h=gw(n),p=C.useRef(!1),m=C.useRef(!0),{viewport:g,selectedItem:b,selectedItemText:y,focusSelectedItem:x}=i,v=C.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&b&&y){const E=s.trigger.getBoundingClientRect(),N=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),M=y.getBoundingClientRect();if(s.dir!=="rtl"){const ee=M.left-N.left,q=R.left-ee,ie=E.left-q,ne=E.width+ie,le=Math.max(ne,N.width),ge=window.innerWidth-Ds,Me=IE(q,[Ds,Math.max(Ds,ge-le)]);a.style.minWidth=ne+"px",a.style.left=Me+"px"}else{const ee=N.right-M.right,q=window.innerWidth-R.right-ee,ie=window.innerWidth-E.right-q,ne=E.width+ie,le=Math.max(ne,N.width),ge=window.innerWidth-Ds,Me=IE(q,[Ds,Math.max(Ds,ge-le)]);a.style.minWidth=ne+"px",a.style.right=Me+"px"}const T=h(),D=window.innerHeight-Ds*2,A=g.scrollHeight,O=window.getComputedStyle(c),j=parseInt(O.borderTopWidth,10),F=parseInt(O.paddingTop,10),L=parseInt(O.borderBottomWidth,10),V=parseInt(O.paddingBottom,10),$=j+F+A+V+L,I=Math.min(b.offsetHeight*5,$),H=window.getComputedStyle(g),B=parseInt(H.paddingTop,10),P=parseInt(H.paddingBottom,10),W=E.top+E.height/2-Ds,Y=D-W,X=b.offsetHeight/2,U=b.offsetTop+X,z=j+F+U,G=$-z;if(z<=W){const ee=T.length>0&&b===T[T.length-1].ref.current;a.style.bottom="0px";const q=c.clientHeight-g.offsetTop-g.offsetHeight,ie=Math.max(Y,X+(ee?P:0)+q+L),ne=z+ie;a.style.height=ne+"px"}else{const ee=T.length>0&&b===T[0].ref.current;a.style.top="0px";const ie=Math.max(W,j+g.offsetTop+(ee?B:0)+X)+G;a.style.height=ie+"px",g.scrollTop=z-W+g.offsetTop}a.style.margin=`${Ds}px 0`,a.style.minHeight=I+"px",a.style.maxHeight=D+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,c,g,b,y,s.dir,r]);Mr(()=>v(),[v]);const[w,S]=C.useState();Mr(()=>{c&&S(window.getComputedStyle(c).zIndex)},[c]);const k=C.useCallback(E=>{E&&m.current===!0&&(v(),x==null||x(),m.current=!1)},[v,x]);return d.jsx($fe,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:k,children:d.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:d.jsx(Pe.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});vz.displayName=Ofe;var Ffe="SelectPopperPosition",FE=C.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Ds,...s}=e,i=bw(n);return d.jsx(Ug,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});FE.displayName=Ffe;var[$fe,DM]=Eh(Cu,{}),$E="SelectViewport",wz=C.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=rc($E,n),i=DM($E,n),a=Je(t,s.onViewportChange),l=C.useRef(0);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),d.jsx(mw.Slot,{scope:n,children:d.jsx(Pe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:xe(o.onScroll,c=>{const u=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-u.scrollTop);if(p>0){const m=window.innerHeight-Ds*2,g=parseFloat(f.style.minHeight),b=parseFloat(f.style.height),y=Math.max(g,b);if(y<m){const x=y+p,v=Math.min(m,x),w=x-v;f.style.height=v+"px",f.style.bottom==="0px"&&(u.scrollTop=w>0?w:0,f.style.justifyContent="flex-end")}}}l.current=u.scrollTop})})})]})});wz.displayName=$E;var Sz="SelectGroup",[Lfe,zfe]=Eh(Sz),Cz=C.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Wn();return d.jsx(Lfe,{scope:n,id:o,children:d.jsx(Pe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Cz.displayName=Sz;var Ez="SelectLabel",_z=C.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=zfe(Ez,n);return d.jsx(Pe.div,{id:o.id,...r,ref:t})});_z.displayName=Ez;var sx="SelectItem",[Bfe,kz]=Eh(sx),Nz=C.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=nc(sx,n),l=rc(sx,n),c=a.value===r,[u,f]=C.useState(s??""),[h,p]=C.useState(!1),m=Je(t,x=>{var v;return(v=l.itemRefCallback)==null?void 0:v.call(l,x,r,o)}),g=Wn(),b=C.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return d.jsx(Bfe,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:C.useCallback(x=>{f(v=>v||((x==null?void 0:x.textContent)??"").trim())},[]),children:d.jsx(mw.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:d.jsx(Pe.div,{role:"option","aria-labelledby":g,"data-highlighted":h?"":void 0,"aria-selected":c&&h,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:m,onFocus:xe(i.onFocus,()=>p(!0)),onBlur:xe(i.onBlur,()=>p(!1)),onClick:xe(i.onClick,()=>{b.current!=="mouse"&&y()}),onPointerUp:xe(i.onPointerUp,()=>{b.current==="mouse"&&y()}),onPointerDown:xe(i.onPointerDown,x=>{b.current=x.pointerType}),onPointerMove:xe(i.onPointerMove,x=>{var v;b.current=x.pointerType,o?(v=l.onItemLeave)==null||v.call(l):b.current==="mouse"&&x.currentTarget.focus({preventScroll:!0})}),onPointerLeave:xe(i.onPointerLeave,x=>{var v;x.currentTarget===document.activeElement&&((v=l.onItemLeave)==null||v.call(l))}),onKeyDown:xe(i.onKeyDown,x=>{var w;((w=l.searchRef)==null?void 0:w.current)!==""&&x.key===" "||(Mfe.includes(x.key)&&y(),x.key===" "&&x.preventDefault())})})})})});Nz.displayName=sx;var vp="SelectItemText",Mz=C.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=nc(vp,n),a=rc(vp,n),l=kz(vp,n),c=Pfe(vp,n),[u,f]=C.useState(null),h=Je(t,y=>f(y),l.onItemTextChange,y=>{var x;return(x=a.itemTextRefCallback)==null?void 0:x.call(a,y,l.value,l.disabled)}),p=u==null?void 0:u.textContent,m=C.useMemo(()=>d.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:b}=c;return Mr(()=>(g(m),()=>b(m)),[g,b,m]),d.jsxs(d.Fragment,{children:[d.jsx(Pe.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?ja.createPortal(s.children,i.valueNode):null]})});Mz.displayName=vp;var jz="SelectItemIndicator",Rz=C.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return kz(jz,n).isSelected?d.jsx(Pe.span,{"aria-hidden":!0,...r,ref:t}):null});Rz.displayName=jz;var LE="SelectScrollUpButton",Dz=C.forwardRef((e,t)=>{const n=rc(LE,e.__scopeSelect),r=DM(LE,e.__scopeSelect),[o,s]=C.useState(!1),i=Je(t,r.onScrollButtonChange);return Mr(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?d.jsx(Tz,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Dz.displayName=LE;var zE="SelectScrollDownButton",Pz=C.forwardRef((e,t)=>{const n=rc(zE,e.__scopeSelect),r=DM(zE,e.__scopeSelect),[o,s]=C.useState(!1),i=Je(t,r.onScrollButtonChange);return Mr(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,u=Math.ceil(l.scrollTop)<c;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?d.jsx(Tz,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Pz.displayName=zE;var Tz=C.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=rc("SelectScrollButton",n),i=C.useRef(null),a=gw(n),l=C.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return C.useEffect(()=>()=>l(),[l]),Mr(()=>{var u;const c=a().find(f=>f.ref.current===document.activeElement);(u=c==null?void 0:c.ref.current)==null||u.scrollIntoView({block:"nearest"})},[a]),d.jsx(Pe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:xe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:xe(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:xe(o.onPointerLeave,()=>{l()})})}),Vfe="SelectSeparator",Az=C.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return d.jsx(Pe.div,{"aria-hidden":!0,...r,ref:t})});Az.displayName=Vfe;var BE="SelectArrow",Hfe=C.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=bw(n),s=nc(BE,n),i=rc(BE,n);return s.open&&i.position==="popper"?d.jsx(qg,{...o,...r,ref:t}):null});Hfe.displayName=BE;function Iz(e){return e===""||e===void 0}var Oz=C.forwardRef((e,t)=>{const{value:n,...r}=e,o=C.useRef(null),s=Je(t,o),i=pw(n);return C.useEffect(()=>{const a=o.current,l=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==n&&u){const f=new Event("change",{bubbles:!0});u.call(a,n),a.dispatchEvent(f)}},[i,n]),d.jsx(RM,{asChild:!0,children:d.jsx("select",{...r,ref:s,defaultValue:n})})});Oz.displayName="BubbleSelect";function Fz(e){const t=rr(e),n=C.useRef(""),r=C.useRef(0),o=C.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=C.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return C.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function $z(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=Wfe(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Wfe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ufe=uz,Lz=fz,qfe=pz,Gfe=mz,Yfe=gz,zz=bz,Zfe=wz,Kfe=Cz,Bz=_z,Vz=Nz,Xfe=Mz,Qfe=Rz,Hz=Dz,Wz=Pz,Uz=Az;const hn=Ufe,qz=Kfe,pn=qfe,an=C.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(Lz,{ref:r,className:K("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-0 focus:ring-ring focus:ring-offset-0 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,d.jsx(Gfe,{asChild:!0,children:d.jsx(Eo,{className:"h-4 w-4 opacity-50"})})]}));an.displayName=Lz.displayName;const Gz=C.forwardRef(({className:e,...t},n)=>d.jsx(Hz,{ref:n,className:K("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(Qd,{className:"h-4 w-4"})}));Gz.displayName=Hz.displayName;const Yz=C.forwardRef(({className:e,...t},n)=>d.jsx(Wz,{ref:n,className:K("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(Eo,{className:"h-4 w-4"})}));Yz.displayName=Wz.displayName;const ln=C.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>d.jsx(Yfe,{children:d.jsx(Qs,{children:d.jsxs(zz,{ref:o,className:K("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[d.jsx(Gz,{}),d.jsx(Zfe,{className:K("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),d.jsx(Yz,{})]})})}));ln.displayName=zz.displayName;const PM=C.forwardRef(({className:e,...t},n)=>d.jsx(Bz,{ref:n,className:K("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));PM.displayName=Bz.displayName;const Ne=C.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(Vz,{ref:r,className:K("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[d.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(Qfe,{children:d.jsx(_r,{className:"h-4 w-4"})})}),d.jsx(Xfe,{children:t})]}));Ne.displayName=Vz.displayName;const Jfe=C.forwardRef(({className:e,...t},n)=>d.jsx(Uz,{ref:n,className:K("-mx-1 my-1 h-px bg-muted",e),...t}));Jfe.displayName=Uz.displayName;const yr=C.forwardRef(({className:e,type:t,...n},r)=>d.jsx("input",{type:t,className:K("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-inset ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));yr.displayName="Input";function ehe({step:e,hierarchyId:t,stepIndex:n,onUpdateStep:r,open:o,onOpenChange:s,trigger:i}){return d.jsxs(Zo,{open:o,onOpenChange:s,children:[d.jsx(Ko,{asChild:!0,children:i}),d.jsx(_o,{className:"z-50 w-80",align:"start",children:d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{children:[d.jsx(de,{className:"mb-1 block text-xs font-medium",children:"Chart Type"}),d.jsxs(hn,{value:e.preferredChartType||"bar",onValueChange:a=>{r(t,n,{preferredChartType:a})},children:[d.jsx(an,{className:"h-8",children:d.jsx(pn,{})}),d.jsxs(ln,{children:[d.jsx(Ne,{value:"bar",children:"Bar Chart"}),d.jsx(Ne,{value:"pie",children:"Pie Chart"}),d.jsx(Ne,{value:"line",children:"Line Chart"}),d.jsx(Ne,{value:"donut",children:"Donut Chart"}),d.jsx(Ne,{value:"table",children:"Table"}),d.jsx(Ne,{value:"metric",children:"Metric"})]})]})]}),d.jsxs("div",{children:[d.jsx(de,{className:"mb-1 block text-xs font-medium",children:"Step Label"}),d.jsx(yr,{value:e.label||"",onChange:a=>r(t,n,{label:a.target.value}),placeholder:"Custom drill label",className:"h-8"})]}),d.jsxs("div",{children:[d.jsx(de,{className:"mb-1 block text-xs font-medium",children:"Breadcrumb Label Template"}),d.jsx(yr,{value:e.breadcrumbLabelTemplate||"",onChange:a=>r(t,n,{breadcrumbLabelTemplate:a.target.value}),placeholder:"e.g., 'Region: {{value}}'",className:"h-8"})]}),d.jsx("div",{className:"flex items-center gap-4",children:d.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[d.jsx("input",{type:"checkbox",checked:e.retainFilters!==!1,onChange:a=>r(t,n,{retainFilters:a.target.checked}),className:"rounded"}),"Retain filters when drilling"]})}),d.jsx("div",{className:"flex justify-end",children:d.jsx(ae,{size:"sm",variant:"outline",onClick:()=>s(!1),children:"Done"})})]})})]})}function the({field:e,step:t,stepIndex:n,hierarchyId:r,onUpdateStep:o,onRemoveStep:s,isFirstField:i=!1}){const[a,l]=_.useState(!1),{attributes:c,listeners:u,setNodeRef:f,transform:h,transition:p,isDragging:m}=fM({id:`${r}-${e.id}-${n}`,disabled:!1}),g={transform:Ti.Transform.toString(h),transition:p,opacity:m?.8:1,zIndex:m?1e3:1};return d.jsx("div",{ref:f,style:g,className:`relative ${a?"z-[9998]":""}`,...c,children:d.jsx(ehe,{step:t,hierarchyId:r,stepIndex:n,onUpdateStep:o,open:a,onOpenChange:l,trigger:d.jsxs("div",{className:`flex cursor-pointer items-center gap-2 rounded-lg p-2 transition-colors ${i?"bg-muted hover:bg-muted/50":"bg-blue-100 hover:bg-blue-200 dark:bg-blue-900/50 dark:hover:bg-blue-900/70"} ${m?"shadow-lg ring-2 ring-blue-300 dark:ring-blue-600":""}`,...u,onClick:b=>{b.stopPropagation(),l(y=>!y)},children:[d.jsxs("div",{className:"pointer-events-none flex items-center gap-2",children:[d.jsx("span",{className:"whitespace-nowrap text-sm font-medium",children:e.label}),t.preferredChartType&&t.preferredChartType!=="bar"&&d.jsx("span",{className:"whitespace-nowrap rounded bg-purple-100 px-1 py-0.5 text-xs text-purple-700 dark:bg-purple-900/50 dark:text-purple-300",children:t.preferredChartType}),t.linkedInsightId&&d.jsx("span",{className:"whitespace-nowrap rounded bg-green-100 px-1 py-0.5 text-xs text-green-700 dark:bg-green-900/50 dark:text-green-300",children:"📊"})]}),d.jsx("button",{className:`pointer-events-auto ml-1 text-xs hover:text-red-800 dark:hover:text-red-400 ${i?"text-muted-foreground":"text-blue-600 dark:text-blue-400"}`,onClick:b=>{b.stopPropagation(),s(r,n)},children:"×"})]})})})}function nhe(e){return{sensors:sM(Am(zg,{activationConstraint:{distance:5}}),Am(Lg,{coordinateGetter:hM})),handleStepDragEnd:(r,o)=>{const{active:s,over:i}=r;if(!i||s.id===i.id)return;const a=s.id.replace(`${o.id}-`,""),l=i.id.replace(`${o.id}-`,""),c=o.steps.findIndex(f=>f.field.id===a),u=o.steps.findIndex(f=>f.field.id===l);if(c!==-1&&u!==-1&&c!==u){const f=Vg(o.steps,c,u);e(o.id,{steps:f})}}}}function rhe({hierarchy:e,onUpdateStep:t,onRemoveStep:n,onUpdateHierarchy:r}){const{sensors:o}=nhe(r),[s,i]=_.useState(null),a=e.steps.filter(h=>h&&h.field&&h.field.id),c=a.map(h=>h.field).map((h,p)=>`${e.id}-${h.id}-${p}`),u=h=>{const p=h.active.id,m=Number.parseInt(p.split("-").pop()||"0"),g=a[m],b=g==null?void 0:g.field;i(b||null)},f=h=>{i(null);const{active:p,over:m}=h;if(!m||p.id===m.id)return;const g=Number.parseInt(p.id.split("-").pop()||"0"),b=Number.parseInt(m.id.split("-").pop()||"0");if(g!==b&&g<a.length&&b<a.length){const y=[...e.steps],[x]=y.splice(g,1);y.splice(b,0,x),r(e.id,{steps:y})}};return a.length===0?d.jsx("div",{className:"steps-container",onPointerDown:h=>h.stopPropagation(),children:d.jsx("div",{className:"rounded-lg border bg-muted/50 p-2 text-sm text-muted-foreground",children:"No drill steps configured. Add steps to create a drill hierarchy."})}):d.jsx("div",{className:"steps-container",onPointerDown:h=>h.stopPropagation(),children:d.jsxs(uM,{sensors:o,collisionDetection:iM,onDragStart:u,onDragEnd:f,children:[d.jsx(dM,{items:c,strategy:Tue,children:d.jsx("div",{className:"flex flex-wrap items-center gap-2",style:{minHeight:"40px"},children:a.map((h,p)=>{if(!h||!h.field||!h.field.id)return null;const m=[];p>0&&m.push(d.jsx(qs,{className:"pointer-events-none h-4 w-4 text-gray-400"},`arrow-${p}`));const g=p===0,b=p===a.length-1;return m.push(d.jsx(the,{field:h.field,step:h,stepIndex:p,hierarchyId:e.id,onUpdateStep:t,onRemoveStep:n,isFirstField:g,isLastField:b},`field-${h.field.id}-${p}`)),m})})}),typeof window<"u"&&jn.createPortal(d.jsx(x8,{className:"semaphor-scope",style:{zIndex:9999},children:s?d.jsx("div",{className:"flex items-center gap-2 rounded-lg border-2 border-blue-300 bg-blue-200 p-2 shadow-lg dark:border-blue-600 dark:bg-blue-900/70",children:d.jsx("span",{className:"whitespace-nowrap text-sm font-medium",children:s.label})}):null}),document.body)]})})}var XT=1,ohe=.9,she=.8,ihe=.17,FS=.1,$S=.999,ahe=.9999,lhe=.99,che=/[\\\/_+.#"@\[\(\{&]/,uhe=/[\\\/_+.#"@\[\(\{&]/g,dhe=/[\s-]/,Zz=/[\s-]/g;function VE(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?XT:lhe;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),u=0,f,h,p,m;c>=0;)f=VE(e,t,n,r,c+1,s+1,i),f>u&&(c===o?f*=XT:che.test(e.charAt(c-1))?(f*=she,p=e.slice(o,c-1).match(uhe),p&&o>0&&(f*=Math.pow($S,p.length))):dhe.test(e.charAt(c-1))?(f*=ohe,m=e.slice(o,c-1).match(Zz),m&&o>0&&(f*=Math.pow($S,m.length))):(f*=ihe,o>0&&(f*=Math.pow($S,c-o))),e.charAt(c)!==t.charAt(s)&&(f*=ahe)),(f<FS&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(h=VE(e,t,n,r,c+1,s+2,i),h*FS>f&&(f=h*FS)),f>u&&(u=f),c=n.indexOf(l,c+1);return i[a]=u,u}function QT(e){return e.toLowerCase().replace(Zz," ")}function fhe(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,VE(e,t,QT(e),QT(t),0,0,{})}var Kh='[cmdk-group=""]',LS='[cmdk-group-items=""]',hhe='[cmdk-group-heading=""]',Kz='[cmdk-item=""]',JT=`${Kz}:not([aria-disabled="true"])`,HE="cmdk-item-select",Nd="data-value",phe=(e,t,n)=>fhe(e,t,n),Xz=C.createContext(void 0),Zg=()=>C.useContext(Xz),Qz=C.createContext(void 0),TM=()=>C.useContext(Qz),Jz=C.createContext(void 0),e9=C.forwardRef((e,t)=>{let n=Md(()=>{var B,P;return{search:"",value:(P=(B=e.value)!=null?B:e.defaultValue)!=null?P:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Md(()=>new Set),o=Md(()=>new Map),s=Md(()=>new Map),i=Md(()=>new Set),a=t9(e),{label:l,children:c,value:u,onValueChange:f,filter:h,shouldFilter:p,loop:m,disablePointerSelection:g=!1,vimBindings:b=!0,...y}=e,x=Wn(),v=Wn(),w=Wn(),S=C.useRef(null),k=_he();Eu(()=>{if(u!==void 0){let B=u.trim();n.current.value=B,E.emit()}},[u]),Eu(()=>{k(6,A)},[]);let E=C.useMemo(()=>({subscribe:B=>(i.current.add(B),()=>i.current.delete(B)),snapshot:()=>n.current,setState:(B,P,W)=>{var Y,X,U,z;if(!Object.is(n.current[B],P)){if(n.current[B]=P,B==="search")D(),M(),k(1,T);else if(B==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let G=document.getElementById(w);G?G.focus():(Y=document.getElementById(x))==null||Y.focus()}if(k(7,()=>{var G;n.current.selectedItemId=(G=O())==null?void 0:G.id,E.emit()}),W||k(5,A),((X=a.current)==null?void 0:X.value)!==void 0){let G=P??"";(z=(U=a.current).onValueChange)==null||z.call(U,G);return}}E.emit()}},emit:()=>{i.current.forEach(B=>B())}}),[]),N=C.useMemo(()=>({value:(B,P,W)=>{var Y;P!==((Y=s.current.get(B))==null?void 0:Y.value)&&(s.current.set(B,{value:P,keywords:W}),n.current.filtered.items.set(B,R(P,W)),k(2,()=>{M(),E.emit()}))},item:(B,P)=>(r.current.add(B),P&&(o.current.has(P)?o.current.get(P).add(B):o.current.set(P,new Set([B]))),k(3,()=>{D(),M(),n.current.value||T(),E.emit()}),()=>{s.current.delete(B),r.current.delete(B),n.current.filtered.items.delete(B);let W=O();k(4,()=>{D(),(W==null?void 0:W.getAttribute("id"))===B&&T(),E.emit()})}),group:B=>(o.current.has(B)||o.current.set(B,new Set),()=>{s.current.delete(B),o.current.delete(B)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:x,inputId:w,labelId:v,listInnerRef:S}),[]);function R(B,P){var W,Y;let X=(Y=(W=a.current)==null?void 0:W.filter)!=null?Y:phe;return B?X(B,n.current.search,P):0}function M(){if(!n.current.search||a.current.shouldFilter===!1)return;let B=n.current.filtered.items,P=[];n.current.filtered.groups.forEach(Y=>{let X=o.current.get(Y),U=0;X.forEach(z=>{let G=B.get(z);U=Math.max(G,U)}),P.push([Y,U])});let W=S.current;j().sort((Y,X)=>{var U,z;let G=Y.getAttribute("id"),J=X.getAttribute("id");return((U=B.get(J))!=null?U:0)-((z=B.get(G))!=null?z:0)}).forEach(Y=>{let X=Y.closest(LS);X?X.appendChild(Y.parentElement===X?Y:Y.closest(`${LS} > *`)):W.appendChild(Y.parentElement===W?Y:Y.closest(`${LS} > *`))}),P.sort((Y,X)=>X[1]-Y[1]).forEach(Y=>{var X;let U=(X=S.current)==null?void 0:X.querySelector(`${Kh}[${Nd}="${encodeURIComponent(Y[0])}"]`);U==null||U.parentElement.appendChild(U)})}function T(){let B=j().find(W=>W.getAttribute("aria-disabled")!=="true"),P=B==null?void 0:B.getAttribute(Nd);E.setState("value",P||void 0)}function D(){var B,P,W,Y;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let X=0;for(let U of r.current){let z=(P=(B=s.current.get(U))==null?void 0:B.value)!=null?P:"",G=(Y=(W=s.current.get(U))==null?void 0:W.keywords)!=null?Y:[],J=R(z,G);n.current.filtered.items.set(U,J),J>0&&X++}for(let[U,z]of o.current)for(let G of z)if(n.current.filtered.items.get(G)>0){n.current.filtered.groups.add(U);break}n.current.filtered.count=X}function A(){var B,P,W;let Y=O();Y&&(((B=Y.parentElement)==null?void 0:B.firstChild)===Y&&((W=(P=Y.closest(Kh))==null?void 0:P.querySelector(hhe))==null||W.scrollIntoView({block:"nearest"})),Y.scrollIntoView({block:"nearest"}))}function O(){var B;return(B=S.current)==null?void 0:B.querySelector(`${Kz}[aria-selected="true"]`)}function j(){var B;return Array.from(((B=S.current)==null?void 0:B.querySelectorAll(JT))||[])}function F(B){let P=j()[B];P&&E.setState("value",P.getAttribute(Nd))}function L(B){var P;let W=O(),Y=j(),X=Y.findIndex(z=>z===W),U=Y[X+B];(P=a.current)!=null&&P.loop&&(U=X+B<0?Y[Y.length-1]:X+B===Y.length?Y[0]:Y[X+B]),U&&E.setState("value",U.getAttribute(Nd))}function V(B){let P=O(),W=P==null?void 0:P.closest(Kh),Y;for(;W&&!Y;)W=B>0?Che(W,Kh):Ehe(W,Kh),Y=W==null?void 0:W.querySelector(JT);Y?E.setState("value",Y.getAttribute(Nd)):L(B)}let $=()=>F(j().length-1),I=B=>{B.preventDefault(),B.metaKey?$():B.altKey?V(1):L(1)},H=B=>{B.preventDefault(),B.metaKey?F(0):B.altKey?V(-1):L(-1)};return C.createElement(Pe.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:B=>{var P;(P=y.onKeyDown)==null||P.call(y,B);let W=B.nativeEvent.isComposing||B.keyCode===229;if(!(B.defaultPrevented||W))switch(B.key){case"n":case"j":{b&&B.ctrlKey&&I(B);break}case"ArrowDown":{I(B);break}case"p":case"k":{b&&B.ctrlKey&&H(B);break}case"ArrowUp":{H(B);break}case"Home":{B.preventDefault(),F(0);break}case"End":{B.preventDefault(),$();break}case"Enter":{B.preventDefault();let Y=O();if(Y){let X=new Event(HE);Y.dispatchEvent(X)}}}}},C.createElement("label",{"cmdk-label":"",htmlFor:N.inputId,id:N.labelId,style:Nhe},l),yw(e,B=>C.createElement(Qz.Provider,{value:E},C.createElement(Xz.Provider,{value:N},B))))}),mhe=C.forwardRef((e,t)=>{var n,r;let o=Wn(),s=C.useRef(null),i=C.useContext(Jz),a=Zg(),l=t9(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;Eu(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let u=n9(o,s,[e.value,e.children,s],e.keywords),f=TM(),h=Il(k=>k.value&&k.value===u.current),p=Il(k=>c||a.filter()===!1?!0:k.search?k.filtered.items.get(o)>0:!0);C.useEffect(()=>{let k=s.current;if(!(!k||e.disabled))return k.addEventListener(HE,m),()=>k.removeEventListener(HE,m)},[p,e.onSelect,e.disabled]);function m(){var k,E;g(),(E=(k=l.current).onSelect)==null||E.call(k,u.current)}function g(){f.setState("value",u.current,!0)}if(!p)return null;let{disabled:b,value:y,onSelect:x,forceMount:v,keywords:w,...S}=e;return C.createElement(Pe.div,{ref:so(s,t),...S,id:o,"cmdk-item":"",role:"option","aria-disabled":!!b,"aria-selected":!!h,"data-disabled":!!b,"data-selected":!!h,onPointerMove:b||a.getDisablePointerSelection()?void 0:g,onClick:b?void 0:m},e.children)}),ghe=C.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Wn(),a=C.useRef(null),l=C.useRef(null),c=Wn(),u=Zg(),f=Il(p=>o||u.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);Eu(()=>u.group(i),[]),n9(i,a,[e.value,e.heading,l]);let h=C.useMemo(()=>({id:i,forceMount:o}),[o]);return C.createElement(Pe.div,{ref:so(a,t),...s,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&C.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),yw(e,p=>C.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},C.createElement(Jz.Provider,{value:h},p))))}),bhe=C.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=C.useRef(null),s=Il(i=>!i.search);return!n&&!s?null:C.createElement(Pe.div,{ref:so(o,t),...r,"cmdk-separator":"",role:"separator"})}),yhe=C.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=TM(),i=Il(c=>c.search),a=Il(c=>c.selectedItemId),l=Zg();return C.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),C.createElement(Pe.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),xhe=C.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=C.useRef(null),i=C.useRef(null),a=Il(c=>c.selectedItemId),l=Zg();return C.useEffect(()=>{if(i.current&&s.current){let c=i.current,u=s.current,f,h=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=c.offsetHeight;u.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return h.observe(c),()=>{cancelAnimationFrame(f),h.unobserve(c)}}},[]),C.createElement(Pe.div,{ref:so(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},yw(e,c=>C.createElement("div",{ref:so(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),vhe=C.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return C.createElement(vL,{open:n,onOpenChange:r},C.createElement(wL,{container:i},C.createElement(yN,{"cmdk-overlay":"",className:o}),C.createElement(xN,{"aria-label":e.label,"cmdk-dialog":"",className:s},C.createElement(e9,{ref:t,...a}))))}),whe=C.forwardRef((e,t)=>Il(n=>n.filtered.count===0)?C.createElement(Pe.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),She=C.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return C.createElement(Pe.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},yw(e,i=>C.createElement("div",{"aria-hidden":!0},i)))}),Ro=Object.assign(e9,{List:xhe,Item:mhe,Input:yhe,Group:ghe,Separator:bhe,Dialog:vhe,Empty:whe,Loading:She});function Che(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Ehe(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function t9(e){let t=C.useRef(e);return Eu(()=>{t.current=e}),t}var Eu=typeof window>"u"?C.useEffect:C.useLayoutEffect;function Md(e){let t=C.useRef();return t.current===void 0&&(t.current=e()),t}function Il(e){let t=TM(),n=()=>e(t.snapshot());return C.useSyncExternalStore(t.subscribe,n,n)}function n9(e,t,n,r=[]){let o=C.useRef(),s=Zg();return Eu(()=>{var i;let a=(()=>{var c;for(let u of n){if(typeof u=="string")return u.trim();if(typeof u=="object"&&"current"in u)return u.current?(c=u.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Nd,a),o.current=a}),o}var _he=()=>{let[e,t]=C.useState(),n=Md(()=>new Map);return Eu(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function khe(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function yw({asChild:e,children:t},n){return e&&C.isValidElement(t)?C.cloneElement(khe(t),{ref:t.ref},n(t.props.children)):n(t)}var Nhe={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const xw=C.forwardRef(({className:e,...t},n)=>d.jsx(Ro,{ref:n,className:K("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));xw.displayName=Ro.displayName;const vw=C.forwardRef(({className:e,...t},n)=>d.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[d.jsx(dN,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),d.jsx(Ro.Input,{ref:n,className:K("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));vw.displayName=Ro.Input.displayName;const ww=C.forwardRef(({className:e,...t},n)=>d.jsx(Ro.List,{ref:n,className:K("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));ww.displayName=Ro.List.displayName;const Sw=C.forwardRef((e,t)=>d.jsx(Ro.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Sw.displayName=Ro.Empty.displayName;const Cw=C.forwardRef(({className:e,...t},n)=>d.jsx(Ro.Group,{ref:n,className:K("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Cw.displayName=Ro.Group.displayName;const Mhe=C.forwardRef(({className:e,...t},n)=>d.jsx(Ro.Separator,{ref:n,className:K("-mx-1 h-px bg-border",e),...t}));Mhe.displayName=Ro.Separator.displayName;const Ew=C.forwardRef(({className:e,...t},n)=>d.jsx(Ro.Item,{ref:n,className:K("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50",e),...t}));Ew.displayName=Ro.Item.displayName;function jhe({fields:e,value:t,onValueChange:n,placeholder:r="Select field...",className:o,disabled:s=!1,excludeFieldIds:i=[]}){const[a,l]=_.useState(!1),c=e.filter(f=>!i.includes(f.id)),u=c.find(f=>f.id===t);return d.jsxs(Zo,{open:a,onOpenChange:l,children:[d.jsx(Ko,{asChild:!0,children:d.jsxs(ae,{variant:"outline",role:"combobox","aria-expanded":a,className:K("justify-between",o),disabled:s,children:[u?u.label:r,d.jsx(w3,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),d.jsx(_o,{className:"z-50 w-[200px] p-0",children:d.jsxs(xw,{children:[d.jsx(vw,{placeholder:"Search fields..."}),d.jsxs(ww,{children:[d.jsx(Sw,{children:"No field found."}),d.jsx(Cw,{children:c.map(f=>d.jsxs(Ew,{value:f.label,onSelect:()=>{n(f.id),l(!1)},children:[d.jsx(_r,{className:K("mr-2 h-4 w-4",t===f.id?"opacity-100":"opacity-0")}),f.label]},f.id))})]})]})})]})}function Rhe({hierarchy:e,editingHierarchy:t,sampleFieldReferences:n,onSetEditingHierarchy:r,onUpdateHierarchy:o,onDeleteHierarchy:s,onSetDefaultHierarchy:i,onUpdateStep:a,onRemoveStep:l,onAddStep:c}){const u=t===e.id,{attributes:f,listeners:h,setNodeRef:p,transform:m,transition:g}=fM({id:e.id,disabled:u}),b={transform:Ti.Transform.toString(m),transition:g},y=e.steps.filter(x=>x.field).map(x=>x.field.id);return d.jsxs("div",{ref:p,style:b,className:"hierarchy-container relative rounded-lg border bg-background p-3 transition-shadow hover:shadow-md",children:[d.jsxs("div",{className:`mb-3 flex items-center justify-between ${u?"":"cursor-move"}`,...u?{}:f,...u?{}:h,children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(que,{value:e.label||"",isEditing:u,onEdit:()=>{r(e.id)},onSave:x=>{o(e.id,{label:x}),r(null)},onCancel:()=>r(null),placeholder:"Hierarchy Name",displayClassName:"font-medium",inputClassName:"font-medium"}),d.jsxs("span",{className:"rounded bg-muted px-2 py-1 text-xs",children:[e.steps.length," steps"]}),e.default?d.jsx("span",{className:"cursor-pointer rounded bg-blue-100 px-2 py-1 text-xs text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",onClick:x=>{x.stopPropagation(),i("")},onPointerDown:x=>x.stopPropagation(),title:"Click to remove default",children:"Default ✓"}):d.jsx("button",{className:"rounded bg-muted px-2 py-1 text-xs transition-colors hover:bg-blue-100 dark:hover:bg-blue-900/50",onClick:x=>{x.stopPropagation(),i(e.id)},onPointerDown:x=>x.stopPropagation(),title:"Set as default hierarchy",children:"Set Default"})]}),d.jsx("div",{className:"flex items-center gap-1",children:d.jsx(ae,{size:"sm",variant:"ghost",onClick:x=>{x.stopPropagation(),s(e.id)},onPointerDown:x=>x.stopPropagation(),children:d.jsx(Bu,{className:"h-3 w-3"})})})]}),d.jsx(rhe,{hierarchy:e,onUpdateStep:a,onRemoveStep:l,onUpdateHierarchy:o}),d.jsx("div",{className:"mt-3 border-t pt-3","data-hierarchy-editing":!0,children:d.jsx("div",{className:"flex items-center gap-2",children:d.jsx(jhe,{fields:n,excludeFieldIds:y,onValueChange:x=>c(e.id,x),placeholder:"Add drill step...",className:"w-48"})})})]})}function Dhe({configuringIntent:e,setConfiguringIntent:t,drillHierarchies:n,onUpdateHierarchies:r,availableFields:o}){const s=sM(Am(zg),Am(Lg,{coordinateGetter:hM})),{editingHierarchy:i,setEditingHierarchy:a,createNewHierarchy:l,deleteHierarchy:c,updateHierarchy:u,addStepToHierarchy:f,removeStepFromHierarchy:h,updateStep:p,setDefaultHierarchy:m}=Uue(n,r,o),g=b=>{const{active:y,over:x}=b;if(y.id!==(x==null?void 0:x.id)){const v=n.findIndex(S=>S.id===y.id),w=n.findIndex(S=>S.id===(x==null?void 0:x.id));r(Vg(n,v,w))}};return d.jsx("div",{className:"rounded-lg border p-4 hover:bg-muted/50",children:d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-blue-100",children:d.jsx(Dg,{className:"h-5 w-5 text-blue-600 dark:text-blue-400"})}),d.jsxs("div",{className:"flex-1",children:[d.jsx("h4",{className:"mb-1 font-medium",children:"Let users drill deeper into specific paths"}),d.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Set up predefined drill paths like regions → cities, categories → products"}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(ae,{size:"sm",variant:"outline",onClick:()=>t(e==="drillDown"?null:"drillDown"),children:e==="drillDown"?"Done":"Set up drill paths"}),d.jsxs("span",{className:"text-xs text-muted-foreground",children:[n.length," hierarchies configured"]})]}),e==="drillDown"&&d.jsxs("div",{className:"mt-4 space-y-3 rounded-lg border border-blue-100 bg-blue-200/50 p-4 dark:border-blue-900 dark:bg-blue-900/50",children:[d.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[d.jsxs("div",{children:[d.jsx("h5",{className:"font-medium",children:"Drill Hierarchies"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Create multiple drill paths for different analysis scenarios"})]}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(ae,{size:"sm",onClick:l,children:[d.jsx(Ri,{className:"mr-1 h-4 w-4"}),"Add Hierarchy"]})})]}),d.jsx(uM,{sensors:s,collisionDetection:iM,onDragEnd:g,children:d.jsx(dM,{items:n.map(b=>b.id),strategy:w8,children:d.jsx("div",{className:"mb-6 space-y-4",children:n.map(b=>d.jsx(Rhe,{hierarchy:b,editingHierarchy:i,sampleFieldReferences:o,onSetEditingHierarchy:a,onUpdateHierarchy:u,onDeleteHierarchy:c,onSetDefaultHierarchy:m,onUpdateStep:p,onRemoveStep:h,onAddStep:f},b.id))})})})]})]})]})})}var AM="Checkbox",[Phe,tKe]=hr(AM),[The,Ahe]=Phe(AM),r9=C.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:u,...f}=e,[h,p]=C.useState(null),m=Je(t,w=>p(w)),g=C.useRef(!1),b=h?u||!!h.closest("form"):!0,[y=!1,x]=jr({prop:o,defaultProp:s,onChange:c}),v=C.useRef(y);return C.useEffect(()=>{const w=h==null?void 0:h.form;if(w){const S=()=>x(v.current);return w.addEventListener("reset",S),()=>w.removeEventListener("reset",S)}},[h,x]),d.jsxs(The,{scope:n,state:y,disabled:a,children:[d.jsx(Pe.button,{type:"button",role:"checkbox","aria-checked":Rl(y)?"mixed":y,"aria-required":i,"data-state":i9(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:m,onKeyDown:xe(e.onKeyDown,w=>{w.key==="Enter"&&w.preventDefault()}),onClick:xe(e.onClick,w=>{x(S=>Rl(S)?!0:!S),b&&(g.current=w.isPropagationStopped(),g.current||w.stopPropagation())})}),b&&d.jsx(Ihe,{control:h,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:u,style:{transform:"translateX(-100%)"},defaultChecked:Rl(s)?!1:s})]})});r9.displayName=AM;var o9="CheckboxIndicator",s9=C.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,s=Ahe(o9,n);return d.jsx(Un,{present:r||Rl(s.state)||s.state===!0,children:d.jsx(Pe.span,{"data-state":i9(s.state),"data-disabled":s.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});s9.displayName=o9;var Ihe=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:o,...s}=e,i=C.useRef(null),a=pw(n),l=fw(t);C.useEffect(()=>{const u=i.current,f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(a!==n&&p){const m=new Event("click",{bubbles:r});u.indeterminate=Rl(n),p.call(u,Rl(n)?!1:n),u.dispatchEvent(m)}},[a,n,r]);const c=C.useRef(Rl(n)?!1:n);return d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??c.current,...s,tabIndex:-1,ref:i,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function Rl(e){return e==="indeterminate"}function i9(e){return Rl(e)?"indeterminate":e?"checked":"unchecked"}var a9=r9,Ohe=s9;const No=C.forwardRef(({className:e,...t},n)=>d.jsx(a9,{ref:n,className:K("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:d.jsx(Ohe,{className:K("flex items-center justify-center text-current"),children:d.jsx(_r,{className:"h-4 w-4"})})}));No.displayName=a9.displayName;function Fhe({fields:e,selectedFieldIds:t,onSelectionChange:n,searchPlaceholder:r="Search fields...",className:o=""}){const[s,i]=_.useState(""),a=e.filter(u=>u.label.toLowerCase().includes(s.toLowerCase())||u.qualifiedEntityName&&u.qualifiedEntityName.toLowerCase().includes(s.toLowerCase())),l=()=>{const u=[...new Set([...t,...a.map(f=>f.id)])];n(u)},c=()=>{const u=a.map(f=>f.id);n(t.filter(f=>!u.includes(f)))};return d.jsxs("div",{className:`space-y-2 ${o}`,children:[d.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[d.jsx(yr,{placeholder:r,value:s,onChange:u=>i(u.target.value),className:"flex-1"}),d.jsxs("span",{className:"text-xs text-muted-foreground",children:[a.length," fields"]})]}),d.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[d.jsx(ae,{size:"sm",variant:"outline",onClick:l,children:"Select All"}),d.jsx(ae,{size:"sm",variant:"outline",onClick:c,children:"Deselect All"}),d.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.length," selected"]})]}),d.jsx("div",{className:"grid max-h-32 grid-cols-2 gap-2 overflow-y-auto rounded border p-2",children:a.map(u=>d.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded border p-2 text-xs hover:bg-muted/50",children:[d.jsx(No,{checked:t.includes(u.id),onCheckedChange:f=>{n(f?[...t,u.id]:t.filter(h=>h!==u.id))}}),d.jsx("span",{className:"font-medium",children:u.label})]},u.id))}),s&&a.length===0&&d.jsxs("div",{className:"py-4 text-center text-sm text-muted-foreground",children:['No fields found matching "',s,'"']})]})}const $he=e=>["string","boolean"].includes(Dv(e.dataType));function Lhe({configuringIntent:e,setConfiguringIntent:t,selectedDrillTargets:n,setSelectedDrillTargets:r,availableFields:o}){const s=o.filter($he),i=n.map(l=>l.id),a=l=>{const c=s.filter(u=>l.includes(u.id));r(c)};return d.jsx("div",{className:"rounded-lg border p-4 hover:bg-muted/50",children:d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-green-100",children:d.jsx(D3,{className:"h-5 w-5 text-green-600 dark:text-green-400"})}),d.jsxs("div",{className:"flex-1",children:[d.jsx("h4",{className:"mb-1 font-medium",children:"Give users freedom to explore any dimension"}),d.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Let users dynamically drill into any available field they choose"}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(ae,{size:"sm",variant:"outline",onClick:()=>t(e==="dynamicDrill"?null:"dynamicDrill"),children:e==="dynamicDrill"?"Done":"Configure available fields"}),d.jsx("span",{className:"text-xs text-muted-foreground",children:n.length>0?`${n.length} fields selected`:"All fields available"})]}),e==="dynamicDrill"&&d.jsxs("div",{className:"mt-4 space-y-3 rounded-lg border border-green-100 bg-green-200/50 p-4 dark:border-green-900 dark:bg-green-900/50",children:[d.jsx("h5",{className:"mb-3 font-medium",children:"Configure Dynamic Drilling"}),d.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Choose which fields users can explore dynamically:"}),d.jsx("div",{className:"border-l-2 border-green-200 pl-4",children:d.jsx(Fhe,{fields:s,selectedFieldIds:i,onSelectionChange:a,searchPlaceholder:"Search fields..."})})]})]})]})]})})}var IM="Switch",[zhe,nKe]=hr(IM),[Bhe,Vhe]=zhe(IM),l9=C.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:u,...f}=e,[h,p]=C.useState(null),m=Je(t,v=>p(v)),g=C.useRef(!1),b=h?u||!!h.closest("form"):!0,[y=!1,x]=jr({prop:o,defaultProp:s,onChange:c});return d.jsxs(Bhe,{scope:n,checked:y,disabled:a,children:[d.jsx(Pe.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":d9(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:m,onClick:xe(e.onClick,v=>{x(w=>!w),b&&(g.current=v.isPropagationStopped(),g.current||v.stopPropagation())})}),b&&d.jsx(Hhe,{control:h,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:u,style:{transform:"translateX(-100%)"}})]})});l9.displayName=IM;var c9="SwitchThumb",u9=C.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=Vhe(c9,n);return d.jsx(Pe.span,{"data-state":d9(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});u9.displayName=c9;var Hhe=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,s=C.useRef(null),i=pw(n),a=fw(t);return C.useEffect(()=>{const l=s.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(i!==n&&f){const h=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(h)}},[i,n,r]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:s,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function d9(e){return e?"checked":"unchecked"}var _w=l9,f9=u9;const OM=C.forwardRef(({className:e,...t},n)=>d.jsx(_w,{className:K("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:d.jsx(f9,{className:K("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));OM.displayName=_w.displayName;var FM="Radio",[Whe,h9]=hr(FM),[Uhe,qhe]=Whe(FM),p9=C.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:o=!1,required:s,disabled:i,value:a="on",onCheck:l,form:c,...u}=e,[f,h]=C.useState(null),p=Je(t,b=>h(b)),m=C.useRef(!1),g=f?c||!!f.closest("form"):!0;return d.jsxs(Uhe,{scope:n,checked:o,disabled:i,children:[d.jsx(Pe.button,{type:"button",role:"radio","aria-checked":o,"data-state":b9(o),"data-disabled":i?"":void 0,disabled:i,value:a,...u,ref:p,onClick:xe(e.onClick,b=>{o||l==null||l(),g&&(m.current=b.isPropagationStopped(),m.current||b.stopPropagation())})}),g&&d.jsx(Ghe,{control:f,bubbles:!m.current,name:r,value:a,checked:o,required:s,disabled:i,form:c,style:{transform:"translateX(-100%)"}})]})});p9.displayName=FM;var m9="RadioIndicator",g9=C.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...o}=e,s=qhe(m9,n);return d.jsx(Un,{present:r||s.checked,children:d.jsx(Pe.span,{"data-state":b9(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t})})});g9.displayName=m9;var Ghe=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,s=C.useRef(null),i=pw(n),a=fw(t);return C.useEffect(()=>{const l=s.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(i!==n&&f){const h=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(h)}},[i,n,r]),d.jsx("input",{type:"radio","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:s,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function b9(e){return e?"checked":"unchecked"}var Yhe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],$M="RadioGroup",[Zhe,rKe]=hr($M,[gh,h9]),y9=gh(),x9=h9(),[Khe,Xhe]=Zhe($M),v9=C.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:o,value:s,required:i=!1,disabled:a=!1,orientation:l,dir:c,loop:u=!0,onValueChange:f,...h}=e,p=y9(n),m=Wu(c),[g,b]=jr({prop:s,defaultProp:o,onChange:f});return d.jsx(Khe,{scope:n,name:r,required:i,disabled:a,value:g,onValueChange:b,children:d.jsx(NN,{asChild:!0,...p,orientation:l,dir:m,loop:u,children:d.jsx(Pe.div,{role:"radiogroup","aria-required":i,"aria-orientation":l,"data-disabled":a?"":void 0,dir:m,...h,ref:t})})})});v9.displayName=$M;var w9="RadioGroupItem",S9=C.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...o}=e,s=Xhe(w9,n),i=s.disabled||r,a=y9(n),l=x9(n),c=C.useRef(null),u=Je(t,c),f=s.value===o.value,h=C.useRef(!1);return C.useEffect(()=>{const p=g=>{Yhe.includes(g.key)&&(h.current=!0)},m=()=>h.current=!1;return document.addEventListener("keydown",p),document.addEventListener("keyup",m),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",m)}},[]),d.jsx(MN,{asChild:!0,...a,focusable:!i,active:f,children:d.jsx(p9,{disabled:i,required:s.required,checked:f,...l,...o,name:s.name,ref:u,onCheck:()=>s.onValueChange(o.value),onKeyDown:xe(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:xe(o.onFocus,()=>{var p;h.current&&((p=c.current)==null||p.click())})})})});S9.displayName=w9;var Qhe="RadioGroupIndicator",C9=C.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,o=x9(n);return d.jsx(g9,{...o,...r,ref:t})});C9.displayName=Qhe;var E9=v9,_9=S9,Jhe=C9;const Bs=C.forwardRef(({className:e,...t},n)=>d.jsx(E9,{className:K("grid gap-2",e),...t,ref:n}));Bs.displayName=E9.displayName;const Yn=C.forwardRef(({className:e,...t},n)=>d.jsx(_9,{ref:n,className:K("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(Jhe,{className:"flex items-center justify-center",children:d.jsx(rN,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Yn.displayName=_9.displayName;function epe({configuringIntent:e,setConfiguringIntent:t,incomingFilterFields:n,onUpdateClickFilterInteractions:r,currentClickFilterInteractions:o}){const[s,i]=_.useState(o.length>0),[a,l]=_.useState(o[0]||{filterFields:[],highlightSelf:!0}),[c,u]=_.useState(""),f=j$(),h=e==="clickFilter",p=()=>{const k=!s;if(i(k),k){const E={filterFields:n,highlightSelf:!0,mode:"clickFilter"};l(E),r([E])}else r([])},m=()=>{t("clickFilter")},g=()=>{t(null)},b=k=>{const E={...a,...k};l(E),r([E])},y=()=>a.applyToCardIds!==void 0?"specific-cards":a.excludeCardIds!==void 0?"all-except-specific":"all-cards",x=k=>{const E={};switch(k){case"all-cards":E.applyToCardIds=void 0,E.excludeCardIds=void 0;break;case"specific-cards":E.applyToCardIds=[],E.excludeCardIds=void 0;break;case"all-except-specific":E.applyToCardIds=void 0,E.excludeCardIds=[];break}b(E)},v=(k,E)=>{if(E==="specific-cards"){const N=a.applyToCardIds||[],R=N.includes(k)?N.filter(M=>M!==k):[...N,k];b({applyToCardIds:R})}else if(E==="all-except-specific"){const N=a.excludeCardIds||[],R=N.includes(k)?N.filter(M=>M!==k):[...N,k];b({excludeCardIds:R})}},w=_.useMemo(()=>{if(!c.trim())return f;const k=c.toLowerCase();return f==null?void 0:f.filter(E=>{var N;return(N=E==null?void 0:E.title)==null?void 0:N.toLowerCase().includes(k)})},[c,f]),S=()=>{var E,N;if(!s)return"0 settings configured";const k=y();if(k==="all-cards")return"filtering all cards";if(k==="specific-cards"){const R=((E=a.applyToCardIds)==null?void 0:E.length)||0;return R===0?"no cards selected":`filtering ${R} card${R!==1?"s":""}`}else if(k==="all-except-specific"){const R=((N=a.excludeCardIds)==null?void 0:N.length)||0;return R===0?"filtering all cards":`excluding ${R} card${R!==1?"s":""}`}return"0 settings configured"};return d.jsx("div",{className:"rounded-lg border p-4 hover:bg-muted/50",children:d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-green-100",children:d.jsx("svg",{className:"h-5 w-5 text-green-600 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"})})}),d.jsxs("div",{className:"flex-1",children:[d.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[d.jsx("h4",{className:"font-medium",children:"Enable click filters"}),d.jsx(OM,{checked:s,onCheckedChange:p})]}),d.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Apply filters to other cards when users click on chart elements"}),s&&d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(ae,{size:"sm",variant:"outline",onClick:h?g:m,children:h?"Done":"Configure"}),d.jsx("span",{className:"text-xs text-muted-foreground",children:S()})]}),h&&s&&d.jsxs("div",{className:"mt-4 space-y-3 rounded-lg border border-green-100 bg-green-200/50 p-4 dark:border-green-900 dark:bg-green-900/50",children:[d.jsx("h5",{className:"mb-3 font-medium",children:"Configure Click Filters"}),d.jsx("div",{className:"space-y-6",children:d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"space-y-0.5",children:[d.jsx(de,{className:"text-sm font-medium",children:"Filter scope"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose which cards should receive the filter"})]}),d.jsxs(Bs,{value:y(),onValueChange:k=>x(k),className:"space-y-3",children:[d.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[d.jsx(Yn,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),d.jsxs("div",{className:"flex-1 space-y-1",children:[d.jsx(de,{htmlFor:"all-cards",className:"cursor-pointer text-sm font-medium",children:"All cards"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards in the dashboard"})]})]}),d.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[d.jsx(Yn,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),d.jsxs("div",{className:"flex-1 space-y-1",children:[d.jsx(de,{htmlFor:"specific-cards",className:"cursor-pointer text-sm font-medium",children:"Only specific cards"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to selected cards only"})]})]}),y()==="specific-cards"&&d.jsxs("div",{className:"ml-7 space-y-2",children:[d.jsxs("div",{className:"space-y-0.5",children:[d.jsx(de,{className:"text-sm font-medium",children:"Cards to filter"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should receive the filter"})]}),d.jsx(yr,{placeholder:"Search cards...",value:c,onChange:k=>u(k.target.value),className:"mb-2"}),d.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:w.length>0?w.map(k=>{const E=(a.applyToCardIds||[]).includes(k.id);return d.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[d.jsx(No,{id:`card-${k.id}`,checked:E,onCheckedChange:()=>v(k.id,"specific-cards")}),d.jsxs("div",{className:"flex-1",children:[d.jsx(de,{htmlFor:`card-${k.id}`,className:"cursor-pointer text-sm font-medium",children:k.title}),k.description&&d.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:k.description})]})]},k.id)}):d.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',c,'"']})})]}),d.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[d.jsx(Yn,{value:"all-except-specific",id:"all-except-specific",className:"mt-0.5"}),d.jsxs("div",{className:"flex-1 space-y-1",children:[d.jsx(de,{htmlFor:"all-except-specific",className:"cursor-pointer text-sm font-medium",children:"All cards except specific ones"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards, excluding selected ones"})]})]}),y()==="all-except-specific"&&d.jsxs("div",{className:"ml-7 space-y-2",children:[d.jsxs("div",{className:"space-y-0.5",children:[d.jsx(de,{className:"text-sm font-medium",children:"Cards to exclude"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should be excluded from filtering"})]}),d.jsx(yr,{placeholder:"Search cards...",value:c,onChange:k=>u(k.target.value),className:"mb-2"}),d.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:w.length>0?w.map(k=>{const E=(a.excludeCardIds||[]).includes(k.id);return d.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[d.jsx(No,{id:`card-exclude-${k.id}`,checked:E,onCheckedChange:()=>v(k.id,"all-except-specific")}),d.jsxs("div",{className:"flex-1",children:[d.jsx(de,{htmlFor:`card-exclude-${k.id}`,className:"cursor-pointer text-sm font-medium",children:k.title}),k.description&&d.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:k.description})]})]},k.id)}):d.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',c,'"']})})]})]})]})})]})]})]})})}function tpe({isOpen:e,onClose:t}){var j,F,L,V;const n=mse(),r=gse(),{updateCurrentDashboardCard:o}=mn(),{columns:s}=PL(),{groupByFields:i,pivotByFields:a}=R$(),l=[...i,...a],c=s,u=((j=n.interactionConfig)==null?void 0:j.drillHierarchies)||[],f=((F=n.interactionConfig)==null?void 0:F.allowedDrillTargets)||[],h=_.useMemo(()=>{var $;return(($=n.interactionConfig)==null?void 0:$.clickFilterInteractions)||[]},[(L=n.interactionConfig)==null?void 0:L.clickFilterInteractions]),p=_.useMemo(()=>{var $;return(($=n.interactionConfig)==null?void 0:$.drillInteractions)||[]},[(V=n.interactionConfig)==null?void 0:V.drillInteractions]),[m,g]=_.useState(u),[b,y]=_.useState(f||[]),[x,v]=_.useState(null),[w,S]=_.useState(()=>p.filter($=>$.mode==="drillToURL")),[k,E]=_.useState(()=>p.filter($=>$.mode==="drillThrough")),[N,R]=_.useState(()=>p.filter($=>$.mode==="drillToDetail")),[M,T]=_.useState(h),D=_.useRef(null);_.useEffect(()=>{var $,I,H;if(e){g((($=n.interactionConfig)==null?void 0:$.drillHierarchies)||[]),y(((I=n.interactionConfig)==null?void 0:I.allowedDrillTargets)||[]),v(null);const B=((H=n.interactionConfig)==null?void 0:H.drillInteractions)||[];S(B.filter(P=>P.mode==="drillToURL")),E(B.filter(P=>P.mode==="drillThrough")),R(B.filter(P=>P.mode==="drillToDetail")),T(h)}},[e,n.interactionConfig,h]);const A=()=>{var H;const $=[...w,...k,...N];r.updateDrillHierarchies(m),r.updateDrillInteractions($),(H=D.current)!=null&&H.saveToGlobal&&D.current.saveToGlobal(),r.updateAllowedDrillTargets(b);const I={...n,interactionConfig:{...n.interactionConfig,drillHierarchies:m,allowedDrillTargets:b,drillInteractions:$,clickFilterInteractions:M}};o(I),t()},O=()=>{v(null),t()};return e?d.jsxs(Xl,{modal:!1,open:e,onOpenChange:t,children:[d.jsx("div",{className:"pointer-events-none fixed inset-0 z-40 bg-background/80 backdrop-blur-sm"}),d.jsxs(La,{className:"flex max-h-[90vh] max-w-4xl flex-col overflow-hidden",children:[d.jsxs(za,{children:[d.jsx(Ba,{children:"Configure Interactions"}),d.jsx(Va,{children:"Set up drill behaviors for this chart"})]}),d.jsx("div",{className:"flex-1 overflow-y-auto",children:d.jsx("div",{className:"space-y-6",children:d.jsx("div",{children:d.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[d.jsx(epe,{configuringIntent:x,setConfiguringIntent:v,incomingFilterFields:l,onUpdateClickFilterInteractions:T,currentClickFilterInteractions:M}),d.jsx(Dhe,{configuringIntent:x,setConfiguringIntent:v,drillHierarchies:m,onUpdateHierarchies:g,availableFields:c}),d.jsx(Lhe,{configuringIntent:x,setConfiguringIntent:v,selectedDrillTargets:b,setSelectedDrillTargets:y,availableFields:c})]})})})}),d.jsxs(Ql,{className:"border-t-0",children:[d.jsx(ae,{variant:"outline",onClick:O,children:"Cancel"}),d.jsx(ae,{onClick:A,children:"Save Changes"})]})]})]}):null}async function k9(e){var o;if(re.getState().isDownloadingPdf)return;const n=new URLSearchParams;n.set("theme",e.theme),n.set("filterValues",JSON.stringify(e.filterValues)),n.set("dashboardId",e.dashboardId),e.selectedSheetId!==void 0&&n.set("selectedSheetId",e.selectedSheetId),e.dashboardTitle!==void 0&&n.set("dashboardTitle",e.dashboardTitle),e.visualId!==void 0&&n.set("visualId",e.visualId),e.frameId!==void 0&&n.set("frameId",e.frameId),e.tableMode!==void 0&&n.set("tableMode",String(e.tableMode)),e.cardTitle!==void 0&&n.set("reportTitle",e.cardTitle),e.password&&n.set("password",e.password),e.pageSize&&n.set("pageSize",e.pageSize),e.orientation&&n.set("orientation",e.orientation),e.filterLine&&n.set("filterLine",e.filterLine);const r=`https://semaphor.cloud/api/v1/pdf?params=${encodeURIComponent(n.toString())}`;re.setState({isDownloadingPdf:!0});try{const s=await fetch(r,{method:"GET",headers:{Authorization:`Bearer ${(o=e.authToken)==null?void 0:o.accessToken}`}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const i=await s.json();if(!i.url)throw new Error("No download URL received from server");const a=i.url,l=document.createElement("a");l.href=a,l.download=e.fileName,l.click(),re.setState({isDownloadingPdf:!1})}catch(s){throw re.setState({isDownloadingPdf:!1}),s}}function N9(){var o;const e=re.getState().authToken,t=(o=re.getState().dashboard)==null?void 0:o.id,n=re.getState().theme,r=re.getState().filterValues;return{authToken:e,dashboardId:t||"",theme:n||"light",filterValues:r}}function LM(){var r;const e=(r=re.getState().dashboard)==null?void 0:r.title,t=re.getState().selectedSheetId;return{...N9(),dashboardTitle:e||"",selectedSheetId:t||""}}async function npe(e){const{authToken:t,theme:n,filterValues:r,dashboardTitle:o,selectedSheetId:s,dashboardId:i}=LM(),a=`${o}-${new Date().toISOString()}.pdf`;return k9({authToken:t,theme:n,filterValues:r,dashboardId:i,fileName:a,password:e,dashboardTitle:o,selectedSheetId:s})}function rpe(e,t,n){return{...N9(),cardId:e||"",frameId:t||"",cardTitle:n||""}}async function M9(e,t,n,r,o,s,i,a){const{authToken:l,theme:c,filterValues:u,dashboardId:f}=rpe(e,t,n),h=`${n}-${new Date().toISOString()}.pdf`;return k9({authToken:l,cardTitle:n,theme:c,filterValues:u,dashboardId:f,fileName:h,password:o,visualId:e,frameId:t,tableMode:r==="table"||r==="aggregateTable",pageSize:s,orientation:i,filterLine:a})}function ope(e,t){return C.useReducer((n,r)=>t[n][r]??n,e)}var zM="ScrollArea",[j9,oKe]=hr(zM),[spe,Es]=j9(zM),R9=C.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=C.useState(null),[c,u]=C.useState(null),[f,h]=C.useState(null),[p,m]=C.useState(null),[g,b]=C.useState(null),[y,x]=C.useState(0),[v,w]=C.useState(0),[S,k]=C.useState(!1),[E,N]=C.useState(!1),R=Je(t,T=>l(T)),M=Wu(o);return d.jsx(spe,{scope:n,type:r,dir:M,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:u,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:S,onScrollbarXEnabledChange:k,scrollbarY:g,onScrollbarYChange:b,scrollbarYEnabled:E,onScrollbarYEnabledChange:N,onCornerWidthChange:x,onCornerHeightChange:w,children:d.jsx(Pe.div,{dir:M,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":v+"px",...e.style}})})});R9.displayName=zM;var D9="ScrollAreaViewport",P9=C.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Es(D9,n),a=C.useRef(null),l=Je(t,a,i.onViewportChange);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),d.jsx(Pe.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:d.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});P9.displayName=D9;var Gi="ScrollAreaScrollbar",BM=C.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Es(Gi,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return C.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?d.jsx(ipe,{...r,ref:t,forceMount:n}):o.type==="scroll"?d.jsx(ape,{...r,ref:t,forceMount:n}):o.type==="auto"?d.jsx(T9,{...r,ref:t,forceMount:n}):o.type==="always"?d.jsx(VM,{...r,ref:t}):null});BM.displayName=Gi;var ipe=C.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Es(Gi,e.__scopeScrollArea),[s,i]=C.useState(!1);return C.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},u=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",u),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),d.jsx(Un,{present:n||s,children:d.jsx(T9,{"data-state":s?"visible":"hidden",...r,ref:t})})}),ape=C.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Es(Gi,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Nw(()=>l("SCROLL_END"),100),[a,l]=ope("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return C.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),C.useEffect(()=>{const c=o.viewport,u=s?"scrollLeft":"scrollTop";if(c){let f=c[u];const h=()=>{const p=c[u];f!==p&&(l("SCROLL"),i()),f=p};return c.addEventListener("scroll",h),()=>c.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),d.jsx(Un,{present:n||a!=="hidden",children:d.jsx(VM,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:xe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:xe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),T9=C.forwardRef((e,t)=>{const n=Es(Gi,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=C.useState(!1),a=e.orientation==="horizontal",l=Nw(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,u=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:u)}},10);return Vf(n.viewport,l),Vf(n.content,l),d.jsx(Un,{present:r||s,children:d.jsx(VM,{"data-state":s?"visible":"hidden",...o,ref:t})})}),VM=C.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Es(Gi,e.__scopeScrollArea),s=C.useRef(null),i=C.useRef(0),[a,l]=C.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=$9(a.viewport,a.content),u={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return hpe(h,i.current,a,p)}return n==="horizontal"?d.jsx(lpe,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=eA(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?d.jsx(cpe,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=eA(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),lpe=C.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Es(Gi,e.__scopeScrollArea),[i,a]=C.useState(),l=C.useRef(null),c=Je(t,l,s.onScrollbarXChange);return C.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),d.jsx(I9,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":kw(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+u.deltaX;e.onWheelScroll(h),z9(h,f)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:ax(i.paddingLeft),paddingEnd:ax(i.paddingRight)}})}})}),cpe=C.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Es(Gi,e.__scopeScrollArea),[i,a]=C.useState(),l=C.useRef(null),c=Je(t,l,s.onScrollbarYChange);return C.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),d.jsx(I9,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":kw(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,f)=>{if(s.viewport){const h=s.viewport.scrollTop+u.deltaY;e.onWheelScroll(h),z9(h,f)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:ax(i.paddingTop),paddingEnd:ax(i.paddingBottom)}})}})}),[upe,A9]=j9(Gi),I9=C.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:u,onResize:f,...h}=e,p=Es(Gi,n),[m,g]=C.useState(null),b=Je(t,R=>g(R)),y=C.useRef(null),x=C.useRef(""),v=p.viewport,w=r.content-r.viewport,S=rr(u),k=rr(l),E=Nw(f,10);function N(R){if(y.current){const M=R.clientX-y.current.left,T=R.clientY-y.current.top;c({x:M,y:T})}}return C.useEffect(()=>{const R=M=>{const T=M.target;(m==null?void 0:m.contains(T))&&S(M,w)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[v,m,w,S]),C.useEffect(k,[r,k]),Vf(m,E),Vf(p.content,E),d.jsx(upe,{scope:n,scrollbar:m,hasThumb:o,onThumbChange:rr(s),onThumbPointerUp:rr(i),onThumbPositionChange:k,onThumbPointerDown:rr(a),children:d.jsx(Pe.div,{...h,ref:b,style:{position:"absolute",...h.style},onPointerDown:xe(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=m.getBoundingClientRect(),x.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),N(R))}),onPointerMove:xe(e.onPointerMove,N),onPointerUp:xe(e.onPointerUp,R=>{const M=R.target;M.hasPointerCapture(R.pointerId)&&M.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=x.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),ix="ScrollAreaThumb",O9=C.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=A9(ix,e.__scopeScrollArea);return d.jsx(Un,{present:n||o.hasThumb,children:d.jsx(dpe,{ref:t,...r})})}),dpe=C.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Es(ix,n),i=A9(ix,n),{onThumbPositionChange:a}=i,l=Je(t,f=>i.onThumbChange(f)),c=C.useRef(void 0),u=Nw(()=>{c.current&&(c.current(),c.current=void 0)},100);return C.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(u(),!c.current){const p=ppe(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,u,a]),d.jsx(Pe.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:xe(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),m=f.clientX-p.left,g=f.clientY-p.top;i.onThumbPointerDown({x:m,y:g})}),onPointerUp:xe(e.onPointerUp,i.onThumbPointerUp)})});O9.displayName=ix;var HM="ScrollAreaCorner",F9=C.forwardRef((e,t)=>{const n=Es(HM,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?d.jsx(fpe,{...e,ref:t}):null});F9.displayName=HM;var fpe=C.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Es(HM,n),[s,i]=C.useState(0),[a,l]=C.useState(0),c=!!(s&&a);return Vf(o.scrollbarX,()=>{var f;const u=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(u),l(u)}),Vf(o.scrollbarY,()=>{var f;const u=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(u),i(u)}),c?d.jsx(Pe.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ax(e){return e?parseInt(e,10):0}function $9(e,t){const n=e/t;return isNaN(n)?0:n}function kw(e){const t=$9(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function hpe(e,t,n,r="ltr"){const o=kw(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,u=n.content-n.viewport,f=r==="ltr"?[0,u]:[u*-1,0];return L9([l,c],f)(e)}function eA(e,t,n="ltr"){const r=kw(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=IE(e,l);return L9([0,i],[0,a])(c)}function L9(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function z9(e,t){return e>0&&e<t}var ppe=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function Nw(e,t){const n=rr(e),r=C.useRef(0);return C.useEffect(()=>()=>window.clearTimeout(r.current),[]),C.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Vf(e,t){const n=rr(t);Mr(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var Mw=R9,B9=P9,V9=F9;const Ta=C.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(Mw,{ref:r,className:K("relative overflow-hidden",e),...n,children:[d.jsx(B9,{className:"h-full w-full rounded-[inherit]",children:t}),d.jsx(Aa,{}),d.jsx(V9,{})]}));Ta.displayName=Mw.displayName;const Aa=C.forwardRef(({className:e,orientation:t="vertical",...n},r)=>d.jsx(BM,{ref:r,orientation:t,className:K("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:d.jsx(O9,{className:"relative flex-1 rounded-full bg-border"})}));Aa.displayName=BM.displayName;var mpe="Separator",tA="horizontal",gpe=["horizontal","vertical"],H9=C.forwardRef((e,t)=>{const{decorative:n,orientation:r=tA,...o}=e,s=bpe(r)?r:tA,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return d.jsx(Pe.div,{"data-orientation":s,...a,...o,ref:t})});H9.displayName=mpe;function bpe(e){return gpe.includes(e)}var W9=H9;const Ks=C.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>d.jsx(W9,{ref:o,decorative:n,orientation:t,className:K("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Ks.displayName=W9.displayName;function U9(e){const t=e.split(".");return t[t.length-1].replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1).toLowerCase()).join(" ")}function nA(e){const{name:t,operation:n,values:r,valueType:o}=e,s=U9(t);if(!r||r.length===0)return n==="is null"?`${s} is empty`:n==="is not null"?`${s} is not empty`:"";const i=a=>{if(o==="date"&&a){const l=new Date(a);if(!isNaN(l.getTime()))return l.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}return String(a)};switch(n){case"=":return`${s}: ${i(r[0])}`;case"!=":return`${s} ≠ ${i(r[0])}`;case">":return`${s} > ${i(r[0])}`;case"<":return`${s} < ${i(r[0])}`;case">=":return`${s} ≥ ${i(r[0])}`;case"<=":return`${s} ≤ ${i(r[0])}`;case"between":case"not between":{const a=`${i(r[0])} - ${i(r[1])}`;return n==="between"?`${s}: ${a}`:`${s} not in ${a}`}case"in":{if(r.length===1)return`${s}: ${i(r[0])}`;const a=r.map(i).join(", ");return`${s}: ${a}`}case"not in":{const a=r.map(i).join(", ");return`${s} not in (${a})`}case"like":return`${s} contains "${r[0]}"`;case"not like":return`${s} doesn't contain "${r[0]}"`;default:return`${s}: ${r.map(i).join(", ")}`}}function WE(e){if(!e||e.length===0)return"";const t=new Map;e.forEach(r=>{const o=t.get(r.name)||[];o.push(r),t.set(r.name,o)});const n=[];return t.forEach((r,o)=>{if(r.length===1){const s=nA(r[0]);s&&n.push(s)}else{const s=U9(o),i=r.map(a=>nA(a).replace(`${s}: `,"").replace(`${s} `,"")).filter(Boolean);i.length>0&&n.push(`${s}: ${i.join(" and ")}`)}}),n.join(" | ")}function Ol({size:e="md",color:t="muted",className:n=""}){const r={xs:"w-0.5 h-0.5",sm:"w-1 h-1",md:"w-2 h-2",lg:"w-3 h-3"},o={muted:"bg-muted-foreground/70",primary:"bg-primary",secondary:"bg-secondary-foreground",accent:"bg-accent-foreground",destructive:"bg-destructive",gray:"bg-gray-400 dark:bg-gray-500",blue:"bg-blue-500 dark:bg-blue-400",green:"bg-green-500 dark:bg-green-400",red:"bg-red-500 dark:bg-red-400"},s=K(r[e],o[t],"rounded-full animate-pulse");return d.jsxs("div",{className:K("flex items-center gap-1",n),children:[d.jsx("div",{className:s,style:{animationDelay:"0ms",animationDuration:"1.4s"}}),d.jsx("div",{className:s,style:{animationDelay:"200ms",animationDuration:"1.4s"}}),d.jsx("div",{className:s,style:{animationDelay:"400ms",animationDuration:"1.4s"}})]})}const Ku=C.forwardRef(({className:e,children:t,style:n,...r},o)=>d.jsxs(Mw,{style:n,className:K("relative overflow-hidden",e),children:[d.jsx(B9,{ref:o,...r,className:"h-full w-full rounded-[inherit]",children:t}),d.jsx(Aa,{}),d.jsx(V9,{})]}));Ku.displayName=Mw.displayName;/**
650
+ `},bce={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 yce(e){let{announcements:t=bce,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=gce}=e;const{announce:s,announcement:i}=hce(),a=$g("DndLiveRegion"),[l,c]=_.useState(!1);if(_.useEffect(()=>{c(!0)},[]),pce(_.useMemo(()=>({onDragStart(f){let{active:h}=f;s(t.onDragStart({active:h}))},onDragMove(f){let{active:h,over:p}=f;t.onDragMove&&s(t.onDragMove({active:h,over:p}))},onDragOver(f){let{active:h,over:p}=f;s(t.onDragOver({active:h,over:p}))},onDragEnd(f){let{active:h,over:p}=f;s(t.onDragEnd({active:h,over:p}))},onDragCancel(f){let{active:h,over:p}=f;s(t.onDragCancel({active:h,over:p}))}}),[s,t])),!l)return null;const u=_.createElement(_.Fragment,null,_.createElement(dce,{id:r,value:o.draggable}),_.createElement(fce,{id:a,announcement:i}));return n?jn.createPortal(u,n):u}var cr;(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"})(cr||(cr={}));function J0(){}function Am(e,t){return _.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function sM(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return _.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const Ys=Object.freeze({x:0,y:0});function X6(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function xce(e,t){const n=Q0(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function Q6(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function vce(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function CT(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function J6(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function ET(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 iM=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=ET(t,t.left,t.top),s=[];for(const i of r){const{id:a}=i,l=n.get(a);if(l){const c=X6(ET(l),o);s.push({id:a,data:{droppableContainer:i,value:c}})}}return s.sort(Q6)},wce=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=CT(t),s=[];for(const i of r){const{id:a}=i,l=n.get(a);if(l){const c=CT(l),u=o.reduce((h,p,m)=>h+X6(c[m],p),0),f=Number((u/4).toFixed(4));s.push({id:a,data:{droppableContainer:i,value:f}})}}return s.sort(Q6)};function Sce(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<o&&n<s){const l=t.width*t.height,c=e.width*e.height,u=i*a,f=u/(l+c-u);return Number(f.toFixed(4))}return 0}const Cce=e=>{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 l=Sce(a,t);l>0&&o.push({id:i,data:{droppableContainer:s,value:l}})}}return o.sort(vce)};function Ece(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function e8(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Ys}function _ce(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),s=1;s<r;s++)o[s-1]=arguments[s];return o.reduce((i,a)=>({...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 kce=_ce(1);function t8(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 Nce(e,t,n){const r=t8(t);if(!r)return e;const{scaleX:o,scaleY:s,x:i,y:a}=r,l=e.left-i-(1-o)*parseFloat(n),c=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:c,right:l+u,bottom:c+f,left:l}}const Mce={ignoreTransform:!1};function xh(e,t){t===void 0&&(t=Mce);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:u}=ao(e).getComputedStyle(e);c&&(n=Nce(n,c,u))}const{top:r,left:o,width:s,height:i,bottom:a,right:l}=n;return{top:r,left:o,width:s,height:i,bottom:a,right:l}}function _T(e){return xh(e,{ignoreTransform:!0})}function jce(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Rce(e,t){return t===void 0&&(t=ao(e).getComputedStyle(e)),t.position==="fixed"}function Dce(e,t){t===void 0&&(t=ao(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 ow(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(oM(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Og(o)||Y6(o)||n.includes(o))return n;const s=ao(e).getComputedStyle(o);return o!==e&&Dce(o,s)&&n.push(o),Rce(o,s)?n:r(o.parentNode)}return e?r(e):n}function n8(e){const[t]=ow(e,1);return t??null}function MS(e){return!tw||!e?null:bh(e)?e:rM(e)?oM(e)||e===yh(e).scrollingElement?window:Og(e)?e:null:null}function r8(e){return bh(e)?e.scrollX:e.scrollLeft}function o8(e){return bh(e)?e.scrollY:e.scrollTop}function NE(e){return{x:r8(e),y:o8(e)}}var gr;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(gr||(gr={}));function s8(e){return!tw||!e?!1:e===document.scrollingElement}function i8(e){const t={x:0,y:0},n=s8(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 Pce={x:.2,y:.2};function Tce(e,t,n,r,o){let{top:s,left:i,right:a,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=Pce);const{isTop:c,isBottom:u,isLeft:f,isRight:h}=i8(e),p={x:0,y:0},m={x:0,y:0},g={height:t.height*o.y,width:t.width*o.x};return!c&&s<=t.top+g.height?(p.y=gr.Backward,m.y=r*Math.abs((t.top+g.height-s)/g.height)):!u&&l>=t.bottom-g.height&&(p.y=gr.Forward,m.y=r*Math.abs((t.bottom-g.height-l)/g.height)),!h&&a>=t.right-g.width?(p.x=gr.Forward,m.x=r*Math.abs((t.right-g.width-a)/g.width)):!f&&i<=t.left+g.width&&(p.x=gr.Backward,m.x=r*Math.abs((t.left+g.width-i)/g.width)),{direction:p,speed:m}}function Ace(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 a8(e){return e.reduce((t,n)=>tf(t,NE(n)),Ys)}function Ice(e){return e.reduce((t,n)=>t+r8(n),0)}function Oce(e){return e.reduce((t,n)=>t+o8(n),0)}function l8(e,t){if(t===void 0&&(t=xh),!e)return;const{top:n,left:r,bottom:o,right:s}=t(e);n8(e)&&(o<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Fce=[["x",["left","right"],Ice],["y",["top","bottom"],Oce]];class aM{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=ow(n),o=a8(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[s,i,a]of Fce)for(const l of i)Object.defineProperty(this,l,{get:()=>{const c=a(r),u=o[s]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Vp{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 $ce(e){const{EventTarget:t}=ao(e);return e instanceof t?e:yh(e)}function jS(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 us;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(us||(us={}));function kT(e){e.preventDefault()}function Lce(e){e.stopPropagation()}var Rt;(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"})(Rt||(Rt={}));const c8={start:[Rt.Space,Rt.Enter],cancel:[Rt.Esc],end:[Rt.Space,Rt.Enter,Rt.Tab]},zce=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Rt.Right:return{...n,x:n.x+25};case Rt.Left:return{...n,x:n.x-25};case Rt.Down:return{...n,y:n.y+25};case Rt.Up:return{...n,y:n.y-25}}};class Lg{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 Vp(yh(n)),this.windowListeners=new Vp(ao(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(us.Resize,this.handleCancel),this.windowListeners.add(us.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(us.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&l8(r),n(Ys)}handleKeyDown(t){if(rw(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:s=c8,coordinateGetter:i=zce,scrollBehavior:a="smooth"}=o,{code:l}=t;if(s.end.includes(l)){this.handleEnd(t);return}if(s.cancel.includes(l)){this.handleCancel(t);return}const{collisionRect:c}=r.current,u=c?{x:c.left,y:c.top}:Ys;this.referenceCoordinates||(this.referenceCoordinates=u);const f=i(t,{active:n,context:r.current,currentCoordinates:u});if(f){const h=Tm(f,u),p={x:0,y:0},{scrollableAncestors:m}=r.current;for(const g of m){const b=t.code,{isTop:y,isRight:x,isLeft:v,isBottom:w,maxScroll:S,minScroll:k}=i8(g),E=Ace(g),N={x:Math.min(b===Rt.Right?E.right-E.width/2:E.right,Math.max(b===Rt.Right?E.left:E.left+E.width/2,f.x)),y:Math.min(b===Rt.Down?E.bottom-E.height/2:E.bottom,Math.max(b===Rt.Down?E.top:E.top+E.height/2,f.y))},R=b===Rt.Right&&!x||b===Rt.Left&&!v,M=b===Rt.Down&&!w||b===Rt.Up&&!y;if(R&&N.x!==f.x){const T=g.scrollLeft+h.x,D=b===Rt.Right&&T<=S.x||b===Rt.Left&&T>=k.x;if(D&&!h.y){g.scrollTo({left:T,behavior:a});return}D?p.x=g.scrollLeft-T:p.x=b===Rt.Right?g.scrollLeft-S.x:g.scrollLeft-k.x,p.x&&g.scrollBy({left:-p.x,behavior:a});break}else if(M&&N.y!==f.y){const T=g.scrollTop+h.y,D=b===Rt.Down&&T<=S.y||b===Rt.Up&&T>=k.y;if(D&&!h.x){g.scrollTo({top:T,behavior:a});return}D?p.y=g.scrollTop-T:p.y=b===Rt.Down?g.scrollTop-S.y:g.scrollTop-k.y,p.y&&g.scrollBy({top:-p.y,behavior:a});break}}this.handleMove(t,tf(Tm(f,this.referenceCoordinates),p))}}}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()}}Lg.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=c8,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 NT(e){return!!(e&&"distance"in e)}function MT(e){return!!(e&&"delay"in e)}class lM{constructor(t,n,r){var o;r===void 0&&(r=$ce(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=yh(i),this.documentListeners=new Vp(this.document),this.listeners=new Vp(r),this.windowListeners=new Vp(ao(i)),this.initialCoordinates=(o=Q0(s))!=null?o:Ys,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(us.Resize,this.handleCancel),this.windowListeners.add(us.DragStart,kT),this.windowListeners.add(us.VisibilityChange,this.handleCancel),this.windowListeners.add(us.ContextMenu,kT),this.documentListeners.add(us.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(MT(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(NT(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(us.Click,Lce,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(us.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 l=(n=Q0(t))!=null?n:Ys,c=Tm(o,l);if(!r&&a){if(NT(a)){if(a.tolerance!=null&&jS(c,a.tolerance))return this.handleCancel();if(jS(c,a.distance))return this.handleStart()}if(MT(a)&&jS(c,a.tolerance))return this.handleCancel();this.handlePending(a,c);return}t.cancelable&&t.preventDefault(),i(l)}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===Rt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Bce={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class zg extends lM{constructor(t){const{event:n}=t,r=yh(n.target);super(t,Bce,r)}}zg.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 Vce={move:{name:"mousemove"},end:{name:"mouseup"}};var ME;(function(e){e[e.RightClick=2]="RightClick"})(ME||(ME={}));class u8 extends lM{constructor(t){super(t,Vce,yh(t.event.target))}}u8.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===ME.RightClick?!1:(r==null||r({event:n}),!0)}}];const RS={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Hce extends lM{constructor(t){super(t,RS)}static setup(){return window.addEventListener(RS.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(RS.move.name,t)};function t(){}}}Hce.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 Hp;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Hp||(Hp={}));var ex;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(ex||(ex={}));function Wce(e){let{acceleration:t,activator:n=Hp.Pointer,canScroll:r,draggingRect:o,enabled:s,interval:i=5,order:a=ex.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:f,threshold:h}=e;const p=qce({delta:f,disabled:!s}),[m,g]=ice(),b=_.useRef({x:0,y:0}),y=_.useRef({x:0,y:0}),x=_.useMemo(()=>{switch(n){case Hp.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Hp.DraggableRect:return o}},[n,o,l]),v=_.useRef(null),w=_.useCallback(()=>{const k=v.current;if(!k)return;const E=b.current.x*y.current.x,N=b.current.y*y.current.y;k.scrollBy(E,N)},[]),S=_.useMemo(()=>a===ex.TreeOrder?[...c].reverse():c,[a,c]);_.useEffect(()=>{if(!s||!c.length||!x){g();return}for(const k of S){if((r==null?void 0:r(k))===!1)continue;const E=c.indexOf(k),N=u[E];if(!N)continue;const{direction:R,speed:M}=Tce(k,N,x,t,h);for(const T of["x","y"])p[T][R[T]]||(M[T]=0,R[T]=0);if(M.x>0||M.y>0){g(),v.current=k,m(w,i),b.current=M,y.current=R;return}}b.current={x:0,y:0},y.current={x:0,y:0},g()},[t,w,r,g,s,i,JSON.stringify(x),JSON.stringify(p),m,c,S,u,JSON.stringify(h)])}const Uce={x:{[gr.Backward]:!1,[gr.Forward]:!1},y:{[gr.Backward]:!1,[gr.Forward]:!1}};function qce(e){let{delta:t,disabled:n}=e;const r=X0(t);return Fg(o=>{if(n||!r||!o)return Uce;const s={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[gr.Backward]:o.x[gr.Backward]||s.x===-1,[gr.Forward]:o.x[gr.Forward]||s.x===1},y:{[gr.Backward]:o.y[gr.Backward]||s.y===-1,[gr.Forward]:o.y[gr.Forward]||s.y===1}}},[n,t,r])}function Gce(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Fg(o=>{var s;return t==null?null:(s=r??o)!=null?s:null},[r,t])}function Yce(e,t){return _.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 Im;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Im||(Im={}));var jE;(function(e){e.Optimized="optimized"})(jE||(jE={}));const jT=new Map;function Zce(e,t){let{dragging:n,dependencies:r,config:o}=t;const[s,i]=_.useState(null),{frequency:a,measure:l,strategy:c}=o,u=_.useRef(e),f=b(),h=Pm(f),p=_.useCallback(function(y){y===void 0&&(y=[]),!h.current&&i(x=>x===null?y:x.concat(y.filter(v=>!x.includes(v))))},[h]),m=_.useRef(null),g=Fg(y=>{if(f&&!n)return jT;if(!y||y===jT||u.current!==e||s!=null){const x=new Map;for(let v of e){if(!v)continue;if(s&&s.length>0&&!s.includes(v.id)&&v.rect.current){x.set(v.id,v.rect.current);continue}const w=v.node.current,S=w?new aM(l(w),w):null;v.rect.current=S,S&&x.set(v.id,S)}return x}return y},[e,s,n,f,l]);return _.useEffect(()=>{u.current=e},[e]),_.useEffect(()=>{f||p()},[n,f]),_.useEffect(()=>{s&&s.length>0&&i(null)},[JSON.stringify(s)]),_.useEffect(()=>{f||typeof a!="number"||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},a))},[a,f,p,...r]),{droppableRects:g,measureDroppableContainers:p,measuringScheduled:s!=null};function b(){switch(c){case Im.Always:return!1;case Im.BeforeDragging:return n;default:return!n}}}function cM(e,t){return Fg(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function Kce(e,t){return cM(e,t)}function Xce(e){let{callback:t,disabled:n}=e;const r=nw(t),o=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return _.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function sw(e){let{callback:t,disabled:n}=e;const r=nw(t),o=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return _.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function Qce(e){return new aM(xh(e),e)}function RT(e,t,n){t===void 0&&(t=Qce);const[r,o]=_.useState(null);function s(){o(l=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=l??n)!=null?c:null}const u=t(e);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const i=Xce({callback(l){if(e)for(const c of l){const{type:u,target:f}=c;if(u==="childList"&&f instanceof HTMLElement&&f.contains(e)){s();break}}}}),a=sw({callback:s});return Gs(()=>{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 Jce(e){const t=cM(e);return e8(e,t)}const DT=[];function eue(e){const t=_.useRef(e),n=Fg(r=>e?r&&r!==DT&&e&&t.current&&e.parentNode===t.current.parentNode?r:ow(e):DT,[e]);return _.useEffect(()=>{t.current=e},[e]),n}function tue(e){const[t,n]=_.useState(null),r=_.useRef(e),o=_.useCallback(s=>{const i=MS(s.target);i&&n(a=>a?(a.set(i,NE(i)),new Map(a)):null)},[]);return _.useEffect(()=>{const s=r.current;if(e!==s){i(s);const a=e.map(l=>{const c=MS(l);return c?(c.addEventListener("scroll",o,{passive:!0}),[c,NE(c)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=e}return()=>{i(e),i(s)};function i(a){a.forEach(l=>{const c=MS(l);c==null||c.removeEventListener("scroll",o)})}},[o,e]),_.useMemo(()=>e.length?t?Array.from(t.values()).reduce((s,i)=>tf(s,i),Ys):a8(e):Ys,[e,t])}function PT(e,t){t===void 0&&(t=[]);const n=_.useRef(null);return _.useEffect(()=>{n.current=null},t),_.useEffect(()=>{const r=e!==Ys;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?Tm(e,n.current):Ys}function nue(e){_.useEffect(()=>{if(!tw)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 rue(e,t){return _.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:s}=r;return n[o]=i=>{s(i,t)},n},{}),[e,t])}function d8(e){return _.useMemo(()=>e?jce(e):null,[e])}const TT=[];function oue(e,t){t===void 0&&(t=xh);const[n]=e,r=d8(n?ao(n):null),[o,s]=_.useState(TT);function i(){s(()=>e.length?e.map(l=>s8(l)?r:new aM(t(l),l)):TT)}const a=sw({callback:i});return Gs(()=>{a==null||a.disconnect(),i(),e.forEach(l=>a==null?void 0:a.observe(l))},[e]),o}function f8(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Og(t)?t:e}function sue(e){let{measure:t}=e;const[n,r]=_.useState(null),o=_.useCallback(c=>{for(const{target:u}of c)if(Og(u)){r(f=>{const h=t(u);return f?{...f,width:h.width,height:h.height}:h});break}},[t]),s=sw({callback:o}),i=_.useCallback(c=>{const u=f8(c);s==null||s.disconnect(),u&&(s==null||s.observe(u)),r(u?t(u):null)},[t,s]),[a,l]=K0(i);return _.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const iue=[{sensor:zg,options:{}},{sensor:Lg,options:{}}],aue={current:{}},h0={draggable:{measure:_T},droppable:{measure:_T,strategy:Im.WhileDragging,frequency:jE.Optimized},dragOverlay:{measure:xh}};class Wp 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 lue={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Wp,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:J0},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:h0,measureDroppableContainers:J0,windowRect:null,measuringScheduled:!1},h8={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:J0,draggableNodes:new Map,over:null,measureDroppableContainers:J0},Bg=_.createContext(h8),p8=_.createContext(lue);function cue(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Wp}}}function uue(e,t){switch(t.type){case cr.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case cr.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 cr.DragEnd:case cr.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case cr.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Wp(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case cr.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 Wp(e.droppable.containers);return i.set(n,{...s,disabled:o}),{...e,droppable:{...e.droppable,containers:i}}}case cr.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const s=new Wp(e.droppable.containers);return s.delete(n),{...e,droppable:{...e.droppable,containers:s}}}default:return e}}function due(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=_.useContext(Bg),s=X0(r),i=X0(n==null?void 0:n.id);return _.useEffect(()=>{if(!t&&!r&&s&&i!=null){if(!rw(s)||document.activeElement===s.target)return;const a=o.get(i);if(!a)return;const{activatorNode:l,node:c}=a;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const u of[l.current,c.current]){if(!u)continue;const f=cce(u);if(f){f.focus();break}}})}},[r,t,o,i,s]),null}function m8(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,s)=>s({transform:o,...r}),n):n}function fue(e){return _.useMemo(()=>({draggable:{...h0.draggable,...e==null?void 0:e.draggable},droppable:{...h0.droppable,...e==null?void 0:e.droppable},dragOverlay:{...h0.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 hue(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const s=_.useRef(!1),{x:i,y:a}=typeof o=="boolean"?{x:o,y:o}:o;Gs(()=>{if(!i&&!a||!t){s.current=!1;return}if(s.current||!r)return;const c=t==null?void 0:t.node.current;if(!c||c.isConnected===!1)return;const u=n(c),f=e8(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=n8(c);h&&h.scrollBy({top:f.y,left:f.x})}},[t,i,a,r,n])}const iw=_.createContext({...Ys,scaleX:1,scaleY:1});var cl;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(cl||(cl={}));const uM=_.memo(function(t){var n,r,o,s;let{id:i,accessibility:a,autoScroll:l=!0,children:c,sensors:u=iue,collisionDetection:f=Cce,measuring:h,modifiers:p,...m}=t;const g=_.useReducer(uue,void 0,cue),[b,y]=g,[x,v]=mce(),[w,S]=_.useState(cl.Uninitialized),k=w===cl.Initialized,{draggable:{active:E,nodes:N,translate:R},droppable:{containers:M}}=b,T=E!=null?N.get(E):null,D=_.useRef({initial:null,translated:null}),A=_.useMemo(()=>{var Se;return E!=null?{id:E,data:(Se=T==null?void 0:T.data)!=null?Se:aue,rect:D}:null},[E,T]),O=_.useRef(null),[j,F]=_.useState(null),[L,V]=_.useState(null),$=Pm(m,Object.values(m)),I=$g("DndDescribedBy",i),H=_.useMemo(()=>M.getEnabled(),[M]),B=fue(h),{droppableRects:P,measureDroppableContainers:W,measuringScheduled:Y}=Zce(H,{dragging:k,dependencies:[R.x,R.y],config:B.droppable}),X=Gce(N,E),U=_.useMemo(()=>L?Q0(L):null,[L]),z=ye(),G=Kce(X,B.draggable.measure);hue({activeNode:E!=null?N.get(E):null,config:z.layoutShiftCompensation,initialRect:G,measure:B.draggable.measure});const J=RT(X,B.draggable.measure,G),ee=RT(X?X.parentElement:null),q=_.useRef({activatorEvent:null,active:null,activeNode:X,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:N,draggingNode:null,draggingNodeRect:null,droppableContainers:M,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ie=M.getNodeFor((n=q.current.over)==null?void 0:n.id),ne=sue({measure:B.dragOverlay.measure}),le=(r=ne.nodeRef.current)!=null?r:X,ge=k?(o=ne.rect)!=null?o:J:null,Me=!!(ne.nodeRef.current&&ne.rect),ue=Jce(Me?null:J),ke=d8(le?ao(le):null),Te=eue(k?ie??X:null),et=oue(Te),at=m8(p,{transform:{x:R.x-ue.x,y:R.y-ue.y,scaleX:1,scaleY:1},activatorEvent:L,active:A,activeNodeRect:J,containerNodeRect:ee,draggingNodeRect:ge,over:q.current.over,overlayNodeRect:ne.rect,scrollableAncestors:Te,scrollableAncestorRects:et,windowRect:ke}),He=U?tf(U,R):null,tt=tue(Te),bn=PT(tt),oe=PT(tt,[J]),he=tf(at,bn),De=ge?kce(ge,at):null,pe=A&&De?f({active:A,collisionRect:De,droppableRects:P,droppableContainers:H,pointerCoordinates:He}):null,ze=J6(pe,"id"),[nt,Nt]=_.useState(null),$t=Me?at:tf(at,oe),ve=Ece($t,(s=nt==null?void 0:nt.rect)!=null?s:null,J),Lt=_.useRef(null),yt=_.useCallback((Se,je)=>{let{sensor:Ie,options:Be}=je;if(O.current==null)return;const Ke=N.get(O.current);if(!Ke)return;const rt=Se.nativeEvent,zt=new Ie({active:O.current,activeNode:Ke,event:rt,options:Be,context:q,onAbort(Bt){if(!N.get(Bt))return;const{onDragAbort:rn}=$.current,An={id:Bt};rn==null||rn(An),x({type:"onDragAbort",event:An})},onPending(Bt,Gn,rn,An){if(!N.get(Bt))return;const{onDragPending:Gr}=$.current,To={id:Bt,constraint:Gn,initialCoordinates:rn,offset:An};Gr==null||Gr(To),x({type:"onDragPending",event:To})},onStart(Bt){const Gn=O.current;if(Gn==null)return;const rn=N.get(Gn);if(!rn)return;const{onDragStart:An}=$.current,ri={activatorEvent:rt,active:{id:Gn,data:rn.data,rect:D}};jn.unstable_batchedUpdates(()=>{An==null||An(ri),S(cl.Initializing),y({type:cr.DragStart,initialCoordinates:Bt,active:Gn}),x({type:"onDragStart",event:ri}),F(Lt.current),V(rt)})},onMove(Bt){y({type:cr.DragMove,coordinates:Bt})},onEnd:Mt(cr.DragEnd),onCancel:Mt(cr.DragCancel)});Lt.current=zt;function Mt(Bt){return async function(){const{active:rn,collisions:An,over:ri,scrollAdjustedTranslate:Gr}=q.current;let To=null;if(rn&&Gr){const{cancelDrop:oi}=$.current;To={activatorEvent:rt,active:rn,collisions:An,delta:Gr,over:ri},Bt===cr.DragEnd&&typeof oi=="function"&&await Promise.resolve(oi(To))&&(Bt=cr.DragCancel)}O.current=null,jn.unstable_batchedUpdates(()=>{y({type:Bt}),S(cl.Uninitialized),Nt(null),F(null),V(null),Lt.current=null;const oi=Bt===cr.DragEnd?"onDragEnd":"onDragCancel";if(To){const Ka=$.current[oi];Ka==null||Ka(To),x({type:oi,event:To})}})}}},[N]),Tn=_.useCallback((Se,je)=>(Ie,Be)=>{const Ke=Ie.nativeEvent,rt=N.get(Be);if(O.current!==null||!rt||Ke.dndKit||Ke.defaultPrevented)return;const zt={active:rt};Se(Ie,je.options,zt)===!0&&(Ke.dndKit={capturedBy:je.sensor},O.current=Be,yt(Ie,je))},[N,yt]),st=Yce(u,Tn);nue(u),Gs(()=>{J&&w===cl.Initializing&&S(cl.Initialized)},[J,w]),_.useEffect(()=>{const{onDragMove:Se}=$.current,{active:je,activatorEvent:Ie,collisions:Be,over:Ke}=q.current;if(!je||!Ie)return;const rt={active:je,activatorEvent:Ie,collisions:Be,delta:{x:he.x,y:he.y},over:Ke};jn.unstable_batchedUpdates(()=>{Se==null||Se(rt),x({type:"onDragMove",event:rt})})},[he.x,he.y]),_.useEffect(()=>{const{active:Se,activatorEvent:je,collisions:Ie,droppableContainers:Be,scrollAdjustedTranslate:Ke}=q.current;if(!Se||O.current==null||!je||!Ke)return;const{onDragOver:rt}=$.current,zt=Be.get(ze),Mt=zt&&zt.rect.current?{id:zt.id,rect:zt.rect.current,data:zt.data,disabled:zt.disabled}:null,Bt={active:Se,activatorEvent:je,collisions:Ie,delta:{x:Ke.x,y:Ke.y},over:Mt};jn.unstable_batchedUpdates(()=>{Nt(Mt),rt==null||rt(Bt),x({type:"onDragOver",event:Bt})})},[ze]),Gs(()=>{q.current={activatorEvent:L,active:A,activeNode:X,collisionRect:De,collisions:pe,droppableRects:P,draggableNodes:N,draggingNode:le,draggingNodeRect:ge,droppableContainers:M,over:nt,scrollableAncestors:Te,scrollAdjustedTranslate:he},D.current={initial:ge,translated:De}},[A,X,pe,De,N,le,ge,P,M,nt,Te,he]),Wce({...z,delta:R,draggingRect:De,pointerCoordinates:He,scrollableAncestors:Te,scrollableAncestorRects:et});const $e=_.useMemo(()=>({active:A,activeNode:X,activeNodeRect:J,activatorEvent:L,collisions:pe,containerNodeRect:ee,dragOverlay:ne,draggableNodes:N,droppableContainers:M,droppableRects:P,over:nt,measureDroppableContainers:W,scrollableAncestors:Te,scrollableAncestorRects:et,measuringConfiguration:B,measuringScheduled:Y,windowRect:ke}),[A,X,J,L,pe,ee,ne,N,M,P,nt,W,Te,et,B,Y,ke]),be=_.useMemo(()=>({activatorEvent:L,activators:st,active:A,activeNodeRect:J,ariaDescribedById:{draggable:I},dispatch:y,draggableNodes:N,over:nt,measureDroppableContainers:W}),[L,st,A,J,y,I,N,nt,W]);return _.createElement(K6.Provider,{value:v},_.createElement(Bg.Provider,{value:be},_.createElement(p8.Provider,{value:$e},_.createElement(iw.Provider,{value:ve},c)),_.createElement(due,{disabled:(a==null?void 0:a.restoreFocus)===!1})),_.createElement(yce,{...a,hiddenTextDescribedById:I}));function ye(){const Se=(j==null?void 0:j.autoScrollEnabled)===!1,je=typeof l=="object"?l.enabled===!1:l===!1,Ie=k&&!Se&&!je;return typeof l=="object"?{...l,enabled:Ie}:{enabled:Ie}}}),pue=_.createContext(null),AT="button",mue="Draggable";function g8(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const s=$g(mue),{activators:i,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:f,over:h}=_.useContext(Bg),{role:p=AT,roleDescription:m="draggable",tabIndex:g=0}=o??{},b=(l==null?void 0:l.id)===t,y=_.useContext(b?iw:pue),[x,v]=K0(),[w,S]=K0(),k=rue(i,t),E=Pm(n);Gs(()=>(f.set(t,{id:t,key:s,node:x,activatorNode:w,data:E}),()=>{const R=f.get(t);R&&R.key===s&&f.delete(t)}),[f,t]);const N=_.useMemo(()=>({role:p,tabIndex:g,"aria-disabled":r,"aria-pressed":b&&p===AT?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,g,b,m,u.draggable]);return{active:l,activatorEvent:a,activeNodeRect:c,attributes:N,isDragging:b,listeners:r?void 0:k,node:x,over:h,setNodeRef:v,setActivatorNodeRef:S,transform:y}}function b8(){return _.useContext(p8)}const gue="Droppable",bue={timeout:25};function y8(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const s=$g(gue),{active:i,dispatch:a,over:l,measureDroppableContainers:c}=_.useContext(Bg),u=_.useRef({disabled:n}),f=_.useRef(!1),h=_.useRef(null),p=_.useRef(null),{disabled:m,updateMeasurementsFor:g,timeout:b}={...bue,...o},y=Pm(g??r),x=_.useCallback(()=>{if(!f.current){f.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{c(Array.isArray(y.current)?y.current:[y.current]),p.current=null},b)},[b]),v=sw({callback:x,disabled:m||!i}),w=_.useCallback((N,R)=>{v&&(R&&(v.unobserve(R),f.current=!1),N&&v.observe(N))},[v]),[S,k]=K0(w),E=Pm(t);return _.useEffect(()=>{!v||!S.current||(v.disconnect(),f.current=!1,v.observe(S.current))},[S,v]),_.useEffect(()=>(a({type:cr.RegisterDroppable,element:{id:r,key:s,disabled:n,node:S,rect:h,data:E}}),()=>a({type:cr.UnregisterDroppable,key:s,id:r})),[r]),_.useEffect(()=>{n!==u.current.disabled&&(a({type:cr.SetDroppableDisabled,id:r,key:s,disabled:n}),u.current.disabled=n)},[r,s,n,a]),{active:i,rect:h,isOver:(l==null?void 0:l.id)===r,node:S,over:l,setNodeRef:k}}function yue(e){let{animation:t,children:n}=e;const[r,o]=_.useState(null),[s,i]=_.useState(null),a=X0(n);return!n&&!r&&a&&o(a),Gs(()=>{if(!s)return;const l=r==null?void 0:r.key,c=r==null?void 0:r.props.id;if(l==null||c==null){o(null);return}Promise.resolve(t(c,s)).then(()=>{o(null)})},[t,r,s]),_.createElement(_.Fragment,null,n,r?_.cloneElement(r,{ref:i}):null)}const xue={x:0,y:0,scaleX:1,scaleY:1};function vue(e){let{children:t}=e;return _.createElement(Bg.Provider,{value:h8},_.createElement(iw.Provider,{value:xue},t))}const wue={position:"fixed",touchAction:"none"},Sue=e=>rw(e)?"transform 250ms ease":void 0,Cue=_.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:s,className:i,rect:a,style:l,transform:c,transition:u=Sue}=e;if(!a)return null;const f=o?c:{...c,scaleX:1,scaleY:1},h={...wue,width:a.width,height:a.height,top:a.top,left:a.left,transform:Ti.Transform.toString(f),transformOrigin:o&&r?xce(r,a):void 0,transition:typeof u=="function"?u(r):u,...l};return _.createElement(n,{className:i,style:h,ref:t},s)}),Eue=e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:s,className:i}=e;if(s!=null&&s.active)for(const[a,l]of Object.entries(s.active))l!==void 0&&(o[a]=n.node.style.getPropertyValue(a),n.node.style.setProperty(a,l));if(s!=null&&s.dragOverlay)for(const[a,l]of Object.entries(s.dragOverlay))l!==void 0&&r.node.style.setProperty(a,l);return i!=null&&i.active&&n.node.classList.add(i.active),i!=null&&i.dragOverlay&&r.node.classList.add(i.dragOverlay),function(){for(const[l,c]of Object.entries(o))n.node.style.setProperty(l,c);i!=null&&i.active&&n.node.classList.remove(i.active)}},_ue=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Ti.Transform.toString(t)},{transform:Ti.Transform.toString(n)}]},kue={duration:250,easing:"ease",keyframes:_ue,sideEffects:Eue({styles:{active:{opacity:"0"}}})};function Nue(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return nw((s,i)=>{if(t===null)return;const a=n.get(s);if(!a)return;const l=a.node.current;if(!l)return;const c=f8(i);if(!c)return;const{transform:u}=ao(i).getComputedStyle(i),f=t8(u);if(!f)return;const h=typeof t=="function"?t:Mue(t);return l8(l,o.draggable.measure),h({active:{id:s,data:a.data,node:l,rect:o.draggable.measure(l)},draggableNodes:n,dragOverlay:{node:i,rect:o.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:o,transform:f})})}function Mue(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...kue,...e};return s=>{let{active:i,dragOverlay:a,transform:l,...c}=s;if(!t)return;const u={x:a.rect.left-i.rect.left,y:a.rect.top-i.rect.top},f={scaleX:l.scaleX!==1?i.rect.width*l.scaleX/a.rect.width:1,scaleY:l.scaleY!==1?i.rect.height*l.scaleY/a.rect.height:1},h={x:l.x-u.x,y:l.y-u.y,...f},p=o({...c,active:i,dragOverlay:a,transform:{initial:l,final:h}}),[m]=p,g=p[p.length-1];if(JSON.stringify(m)===JSON.stringify(g))return;const b=r==null?void 0:r({active:i,dragOverlay:a,...c}),y=a.node.animate(p,{duration:t,easing:n,fill:"forwards"});return new Promise(x=>{y.onfinish=()=>{b==null||b(),x()}})}}let IT=0;function jue(e){return _.useMemo(()=>{if(e!=null)return IT++,IT},[e])}const x8=_.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:o,transition:s,modifiers:i,wrapperElement:a="div",className:l,zIndex:c=999}=e;const{activatorEvent:u,active:f,activeNodeRect:h,containerNodeRect:p,draggableNodes:m,droppableContainers:g,dragOverlay:b,over:y,measuringConfiguration:x,scrollableAncestors:v,scrollableAncestorRects:w,windowRect:S}=b8(),k=_.useContext(iw),E=jue(f==null?void 0:f.id),N=m8(i,{activatorEvent:u,active:f,activeNodeRect:h,containerNodeRect:p,draggingNodeRect:b.rect,over:y,overlayNodeRect:b.rect,scrollableAncestors:v,scrollableAncestorRects:w,transform:k,windowRect:S}),R=cM(h),M=Nue({config:r,draggableNodes:m,droppableContainers:g,measuringConfiguration:x}),T=R?b.setRef:void 0;return _.createElement(vue,null,_.createElement(yue,{animation:M},f&&E?_.createElement(Cue,{key:E,id:f.id,ref:T,as:a,activatorEvent:u,adjustScale:t,className:l,transition:s,rect:R,style:{zIndex:c,...o},transform:N},n):null))});function Vg(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function Rue(e,t){return e.reduce((n,r,o)=>{const s=t.get(r);return s&&(n[o]=s),n},Array(e.length))}function ry(e){return e!==null&&e>=0}function Due(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Pue(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const oy={scaleX:1,scaleY:1},Tue=e=>{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 l=Aue(n,i,o);if(i===o){const c=n[s];return c?{x:o<s?c.left+c.width-(a.left+a.width):c.left-a.left,y:0,...oy}:null}return i>o&&i<=s?{x:-a.width-l,y:0,...oy}:i<o&&i>=s?{x:a.width+l,y:0,...oy}:{x:0,y:0,...oy}};function Aue(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];return!r||!o&&!s?0:n<t?o?r.left-(o.left+o.width):s.left-(r.left+r.width):s?s.left-(r.left+r.width):r.left-(o.left+o.width)}const v8=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const s=Vg(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}},sy={scaleX:1,scaleY:1},w8=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:s,overIndex:i}=e;const a=(t=s[n])!=null?t:r;if(!a)return null;if(o===n){const c=s[i];return c?{x:0,y:n<i?c.top+c.height-(a.top+a.height):c.top-a.top,...sy}:null}const l=Iue(s,o,n);return o>n&&o<=i?{x:0,y:-a.height-l,...sy}:o<n&&o>=i?{x:0,y:a.height+l,...sy}:{x:0,y:0,...sy}};function Iue(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];return r?n<t?o?r.top-(o.top+o.height):s?s.top-(r.top+r.height):0:s?s.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const S8="Sortable",C8=_.createContext({activeIndex:-1,containerId:S8,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:v8,disabled:{draggable:!1,droppable:!1}});function dM(e){let{children:t,id:n,items:r,strategy:o=v8,disabled:s=!1}=e;const{active:i,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:u}=b8(),f=$g(S8,n),h=a.rect!==null,p=_.useMemo(()=>r.map(k=>typeof k=="object"&&"id"in k?k.id:k),[r]),m=i!=null,g=i?p.indexOf(i.id):-1,b=c?p.indexOf(c.id):-1,y=_.useRef(p),x=!Due(p,y.current),v=b!==-1&&g===-1||x,w=Pue(s);Gs(()=>{x&&m&&u(p)},[x,p,m,u]),_.useEffect(()=>{y.current=p},[p]);const S=_.useMemo(()=>({activeIndex:g,containerId:f,disabled:w,disableTransforms:v,items:p,overIndex:b,useDragOverlay:h,sortedRects:Rue(p,l),strategy:o}),[g,f,w.draggable,w.droppable,v,p,b,l,h,o]);return _.createElement(C8.Provider,{value:S},t)}const Oue=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return Vg(n,r,o).indexOf(t)},Fue=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:s,newIndex:i,previousItems:a,previousContainerId:l,transition:c}=e;return!c||!r||a!==s&&o===i?!1:n?!0:i!==o&&t===l},$ue={duration:200,easing:"ease"},E8="transform",Lue=Ti.Transition.toString({property:E8,duration:0,easing:"linear"}),zue={roleDescription:"sortable"};function Bue(e){let{disabled:t,index:n,node:r,rect:o}=e;const[s,i]=_.useState(null),a=_.useRef(n);return Gs(()=>{if(!t&&n!==a.current&&r.current){const l=o.current;if(l){const c=xh(r.current,{ignoreTransform:!0}),u={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(u.x||u.y)&&i(u)}}n!==a.current&&(a.current=n)},[t,n,r,o]),_.useEffect(()=>{s&&i(null)},[s]),s}function fM(e){let{animateLayoutChanges:t=Fue,attributes:n,disabled:r,data:o,getNewIndex:s=Oue,id:i,strategy:a,resizeObserverConfig:l,transition:c=$ue}=e;const{items:u,containerId:f,activeIndex:h,disabled:p,disableTransforms:m,sortedRects:g,overIndex:b,useDragOverlay:y,strategy:x}=_.useContext(C8),v=Vue(r,p),w=u.indexOf(i),S=_.useMemo(()=>({sortable:{containerId:f,index:w,items:u},...o}),[f,o,w,u]),k=_.useMemo(()=>u.slice(u.indexOf(i)),[u,i]),{rect:E,node:N,isOver:R,setNodeRef:M}=y8({id:i,data:S,disabled:v.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...l}}),{active:T,activatorEvent:D,activeNodeRect:A,attributes:O,setNodeRef:j,listeners:F,isDragging:L,over:V,setActivatorNodeRef:$,transform:I}=g8({id:i,data:S,attributes:{...zue,...n},disabled:v.draggable}),H=sce(M,j),B=!!T,P=B&&!m&&ry(h)&&ry(b),W=!y&&L,Y=W&&P?I:null,U=P?Y??(a??x)({rects:g,activeNodeRect:A,activeIndex:h,overIndex:b,index:w}):null,z=ry(h)&&ry(b)?s({id:i,items:u,activeIndex:h,overIndex:b}):w,G=T==null?void 0:T.id,J=_.useRef({activeId:G,items:u,newIndex:z,containerId:f}),ee=u!==J.current.items,q=t({active:T,containerId:f,isDragging:L,isSorting:B,id:i,index:w,items:u,newIndex:J.current.newIndex,previousItems:J.current.items,previousContainerId:J.current.containerId,transition:c,wasDragging:J.current.activeId!=null}),ie=Bue({disabled:!q,index:w,node:N,rect:E});return _.useEffect(()=>{B&&J.current.newIndex!==z&&(J.current.newIndex=z),f!==J.current.containerId&&(J.current.containerId=f),u!==J.current.items&&(J.current.items=u)},[B,z,f,u]),_.useEffect(()=>{if(G===J.current.activeId)return;if(G!=null&&J.current.activeId==null){J.current.activeId=G;return}const le=setTimeout(()=>{J.current.activeId=G},50);return()=>clearTimeout(le)},[G]),{active:T,activeIndex:h,attributes:O,data:S,rect:E,index:w,newIndex:z,items:u,isOver:R,isSorting:B,isDragging:L,listeners:F,node:N,overIndex:b,over:V,setNodeRef:H,setActivatorNodeRef:$,setDroppableNodeRef:M,setDraggableNodeRef:j,transform:ie??U,transition:ne()};function ne(){if(ie||ee&&J.current.newIndex===w)return Lue;if(!(W&&!rw(D)||!c)&&(B||q))return Ti.Transition.toString({...c,property:E8})}}function Vue(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}}function tx(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const Hue=[Rt.Down,Rt.Right,Rt.Up,Rt.Left],hM=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:s,over:i,scrollableAncestors:a}}=t;if(Hue.includes(e.code)){if(e.preventDefault(),!n||!r)return;const l=[];s.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const h=o.get(f.id);if(h)switch(e.code){case Rt.Down:r.top<h.top&&l.push(f);break;case Rt.Up:r.top>h.top&&l.push(f);break;case Rt.Left:r.left>h.left&&l.push(f);break;case Rt.Right:r.left<h.left&&l.push(f);break}});const c=wce({collisionRect:r,droppableRects:o,droppableContainers:l});let u=J6(c,"id");if(u===(i==null?void 0:i.id)&&c.length>1&&(u=c[1].id),u!=null){const f=s.get(n.id),h=s.get(u),p=h?o.get(h.id):null,m=h==null?void 0:h.node.current;if(m&&p&&f&&h){const b=ow(m).some((k,E)=>a[E]!==k),y=_8(f,h),x=Wue(f,h),v=b||!y?{x:0,y:0}:{x:x?r.width-p.width:0,y:x?r.height-p.height:0},w={x:p.left,y:p.top};return v.x&&v.y?w:Tm(w,v)}}}};function _8(e,t){return!tx(e)||!tx(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Wue(e,t){return!tx(e)||!tx(t)||!_8(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function Uue(e,t,n){const[r,o]=_.useState(null),[s,i]=_.useState(""),a=()=>{const m={id:`hierarchy_${Date.now()}`,label:s||"New Hierarchy",type:"static",steps:[],default:!1};t([...e,m]),i(""),o(m.id)},l=m=>{t(e.filter(g=>g.id!==m))},c=(m,g)=>{t(e.map(b=>b.id===m?{...b,...g}:b))};return{editingHierarchy:r,setEditingHierarchy:o,newHierarchyName:s,setNewHierarchyName:i,createNewHierarchy:a,deleteHierarchy:l,updateHierarchy:c,addStepToHierarchy:(m,g)=>{const b=n.find(v=>v.id===g);if(!b)return;const y={field:b,mode:"drillDown",label:`Drill to ${b.label}`,retainFilters:!0,preferredChartType:"bar"},x=e.find(v=>v.id===m);x&&c(m,{steps:[...x.steps,y]})},removeStepFromHierarchy:(m,g)=>{const b=e.find(y=>y.id===m);if(b){const y=[...b.steps];y.splice(g,1),c(m,{steps:y})}},updateStep:(m,g,b)=>{const y=e.find(x=>x.id===m);if(y){const x=y.steps.map((v,w)=>w===g?{...v,...b}:v);c(m,{steps:x})}},setDefaultHierarchy:m=>{t(e.map(g=>({...g,default:g.id===m})))}}}function que({value:e,isEditing:t,onEdit:n,onSave:r,onCancel:o,placeholder:s="Enter text...",inputClassName:i="",displayClassName:a=""}){const[l,c]=_.useState(e);_.useEffect(()=>{c(e)},[e]);const u=m=>{m.key===" "&&m.stopPropagation(),m.key==="Enter"?r(l):m.key==="Escape"&&(c(e),o())},f=()=>{r(l)},h=m=>{m.stopPropagation()},p=m=>{m.stopPropagation()};return t?d.jsx("input",{type:"text",value:l,onChange:m=>c(m.target.value),onKeyDown:u,onBlur:f,onMouseDown:h,onPointerDown:p,className:`min-w-0 border-b border-blue-300 bg-transparent focus:border-blue-500 focus:outline-none dark:border-blue-600 dark:focus:border-blue-400 ${i}`,placeholder:s,autoFocus:!0}):d.jsx("span",{className:`cursor-pointer transition-colors hover:text-blue-600 dark:hover:text-blue-400 ${a}`,onClick:m=>{m.stopPropagation(),n()},onPointerDown:m=>m.stopPropagation(),title:"Click to edit",children:e||s})}function Gue(e,t=globalThis==null?void 0:globalThis.document){const n=rr(e);C.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Yue="DismissableLayer",RE="dismissableLayer.update",Zue="dismissableLayer.pointerDownOutside",Kue="dismissableLayer.focusOutside",OT,k8=C.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Yu=C.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=C.useContext(k8),[u,f]=C.useState(null),h=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=C.useState({}),m=Je(t,E=>f(E)),g=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(b),x=u?g.indexOf(u):-1,v=c.layersWithOutsidePointerEventsDisabled.size>0,w=x>=y,S=Jue(E=>{const N=E.target,R=[...c.branches].some(M=>M.contains(N));!w||R||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),k=ede(E=>{const N=E.target;[...c.branches].some(M=>M.contains(N))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return Gue(E=>{x===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),C.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(OT=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),FT(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=OT)}},[u,h,n,c]),C.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),FT())},[u,c]),C.useEffect(()=>{const E=()=>p({});return document.addEventListener(RE,E),()=>document.removeEventListener(RE,E)},[]),d.jsx(Pe.div,{...l,ref:m,style:{pointerEvents:v?w?"auto":"none":void 0,...e.style},onFocusCapture:xe(e.onFocusCapture,k.onFocusCapture),onBlurCapture:xe(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:xe(e.onPointerDownCapture,S.onPointerDownCapture)})});Yu.displayName=Yue;var Xue="DismissableLayerBranch",Que=C.forwardRef((e,t)=>{const n=C.useContext(k8),r=C.useRef(null),o=Je(t,r);return C.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),d.jsx(Pe.div,{...e,ref:o})});Que.displayName=Xue;function Jue(e,t=globalThis==null?void 0:globalThis.document){const n=rr(e),r=C.useRef(!1),o=C.useRef(()=>{});return C.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){N8(Zue,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function ede(e,t=globalThis==null?void 0:globalThis.document){const n=rr(e),r=C.useRef(!1);return C.useEffect(()=>{const o=s=>{s.target&&!r.current&&N8(Kue,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function FT(){const e=new CustomEvent(RE);document.dispatchEvent(e)}function N8(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?kL(o,s):o.dispatchEvent(s)}var DS=0;function aw(){C.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??$T()),document.body.insertAdjacentElement("beforeend",e[1]??$T()),DS++,()=>{DS===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),DS--}},[])}function $T(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var PS="focusScope.autoFocusOnMount",TS="focusScope.autoFocusOnUnmount",LT={bubbles:!1,cancelable:!0},tde="FocusScope",Hg=C.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=C.useState(null),c=rr(o),u=rr(s),f=C.useRef(null),h=Je(t,g=>l(g)),p=C.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;C.useEffect(()=>{if(r){let g=function(v){if(p.paused||!a)return;const w=v.target;a.contains(w)?f.current=w:il(f.current,{select:!0})},b=function(v){if(p.paused||!a)return;const w=v.relatedTarget;w!==null&&(a.contains(w)||il(f.current,{select:!0}))},y=function(v){if(document.activeElement===document.body)for(const S of v)S.removedNodes.length>0&&il(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",b);const x=new MutationObserver(y);return a&&x.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",b),x.disconnect()}}},[r,a,p.paused]),C.useEffect(()=>{if(a){BT.add(p);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(PS,LT);a.addEventListener(PS,c),a.dispatchEvent(y),y.defaultPrevented||(nde(ade(M8(a)),{select:!0}),document.activeElement===g&&il(a))}return()=>{a.removeEventListener(PS,c),setTimeout(()=>{const y=new CustomEvent(TS,LT);a.addEventListener(TS,u),a.dispatchEvent(y),y.defaultPrevented||il(g??document.body,{select:!0}),a.removeEventListener(TS,u),BT.remove(p)},0)}}},[a,c,u,p]);const m=C.useCallback(g=>{if(!n&&!r||p.paused)return;const b=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(b&&y){const x=g.currentTarget,[v,w]=rde(x);v&&w?!g.shiftKey&&y===w?(g.preventDefault(),n&&il(v,{select:!0})):g.shiftKey&&y===v&&(g.preventDefault(),n&&il(w,{select:!0})):y===x&&g.preventDefault()}},[n,r,p.paused]);return d.jsx(Pe.div,{tabIndex:-1,...i,ref:h,onKeyDown:m})});Hg.displayName=tde;function nde(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(il(r,{select:t}),document.activeElement!==n)return}function rde(e){const t=M8(e),n=zT(t,e),r=zT(t.reverse(),e);return[n,r]}function M8(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function zT(e,t){for(const n of e)if(!ode(n,{upTo:t}))return n}function ode(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function sde(e){return e instanceof HTMLInputElement&&"select"in e}function il(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&sde(e)&&t&&e.select()}}var BT=ide();function ide(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=VT(e,t),e.unshift(t)},remove(t){var n;e=VT(e,t),(n=e[0])==null||n.resume()}}}function VT(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ade(e){return e.filter(t=>t.tagName!=="A")}const lde=["top","right","bottom","left"],Da=Math.min,Lr=Math.max,Om=Math.round,iy=Math.floor,yi=e=>({x:e,y:e}),cde={left:"right",right:"left",bottom:"top",top:"bottom"},ude={start:"end",end:"start"};function DE(e,t,n){return Lr(e,Da(t,n))}function Ai(e,t){return typeof e=="function"?e(t):e}function Pa(e){return e.split("-")[0]}function vh(e){return e.split("-")[1]}function pM(e){return e==="x"?"y":"x"}function mM(e){return e==="y"?"height":"width"}function Tl(e){return["top","bottom"].includes(Pa(e))?"y":"x"}function gM(e){return pM(Tl(e))}function dde(e,t,n){n===void 0&&(n=!1);const r=vh(e),o=gM(e),s=mM(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=nx(i)),[i,nx(i)]}function fde(e){const t=nx(e);return[PE(e),t,PE(t)]}function PE(e){return e.replace(/start|end/g,t=>ude[t])}function hde(e,t,n){const r=["left","right"],o=["right","left"],s=["top","bottom"],i=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?s:i;default:return[]}}function pde(e,t,n,r){const o=vh(e);let s=hde(Pa(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(PE)))),s}function nx(e){return e.replace(/left|right|bottom|top/g,t=>cde[t])}function mde(e){return{top:0,right:0,bottom:0,left:0,...e}}function j8(e){return typeof e!="number"?mde(e):{top:e,right:e,bottom:e,left:e}}function rx(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function HT(e,t,n){let{reference:r,floating:o}=e;const s=Tl(t),i=gM(t),a=mM(i),l=Pa(t),c=s==="y",u=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:u,y:r.y-o.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(vh(t)){case"start":p[i]-=h*(n&&c?-1:1);break;case"end":p[i]+=h*(n&&c?-1:1);break}return p}const gde=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:f}=HT(c,r,l),h=r,p={},m=0;for(let g=0;g<a.length;g++){const{name:b,fn:y}=a[g],{x,y:v,data:w,reset:S}=await y({x:u,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});u=x??u,f=v??f,p={...p,[b]:{...p[b],...w}},S&&m<=50&&(m++,typeof S=="object"&&(S.placement&&(h=S.placement),S.rects&&(c=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:u,y:f}=HT(c,h,l)),g=-1)}return{x:u,y:f,placement:h,strategy:o,middlewareData:p}};async function Lf(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=Ai(t,e),m=j8(p),b=a[h?f==="floating"?"reference":"floating":f],y=rx(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(b)))==null||n?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),x=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,v=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),w=await(s.isElement==null?void 0:s.isElement(v))?await(s.getScale==null?void 0:s.getScale(v))||{x:1,y:1}:{x:1,y:1},S=rx(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:v,strategy:l}):x);return{top:(y.top-S.top+m.top)/w.y,bottom:(S.bottom-y.bottom+m.bottom)/w.y,left:(y.left-S.left+m.left)/w.x,right:(S.right-y.right+m.right)/w.x}}const bde=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=Ai(e,t)||{};if(c==null)return{};const f=j8(u),h={x:n,y:r},p=gM(o),m=mM(p),g=await i.getDimensions(c),b=p==="y",y=b?"top":"left",x=b?"bottom":"right",v=b?"clientHeight":"clientWidth",w=s.reference[m]+s.reference[p]-h[p]-s.floating[m],S=h[p]-s.reference[p],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=k?k[v]:0;(!E||!await(i.isElement==null?void 0:i.isElement(k)))&&(E=a.floating[v]||s.floating[m]);const N=w/2-S/2,R=E/2-g[m]/2-1,M=Da(f[y],R),T=Da(f[x],R),D=M,A=E-g[m]-T,O=E/2-g[m]/2+N,j=DE(D,O,A),F=!l.arrow&&vh(o)!=null&&O!==j&&s.reference[m]/2-(O<D?M:T)-g[m]/2<0,L=F?O<D?O-D:O-A:0;return{[p]:h[p]+L,data:{[p]:j,centerOffset:O-j-L,...F&&{alignmentOffset:L}},reset:F}}}),yde=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...b}=Ai(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Pa(o),x=Tl(a),v=Pa(a)===a,w=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=h||(v||!g?[nx(a)]:fde(a)),k=m!=="none";!h&&k&&S.push(...pde(a,g,m,w));const E=[a,...S],N=await Lf(t,b),R=[];let M=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&R.push(N[y]),f){const O=dde(o,i,w);R.push(N[O[0]],N[O[1]])}if(M=[...M,{placement:o,overflows:R}],!R.every(O=>O<=0)){var T,D;const O=(((T=s.flip)==null?void 0:T.index)||0)+1,j=E[O];if(j)return{data:{index:O,overflows:M},reset:{placement:j}};let F=(D=M.filter(L=>L.overflows[0]<=0).sort((L,V)=>L.overflows[1]-V.overflows[1])[0])==null?void 0:D.placement;if(!F)switch(p){case"bestFit":{var A;const L=(A=M.filter(V=>{if(k){const $=Tl(V.placement);return $===x||$==="y"}return!0}).map(V=>[V.placement,V.overflows.filter($=>$>0).reduce(($,I)=>$+I,0)]).sort((V,$)=>V[1]-$[1])[0])==null?void 0:A[0];L&&(F=L);break}case"initialPlacement":F=a;break}if(o!==F)return{reset:{placement:F}}}return{}}}};function WT(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function UT(e){return lde.some(t=>e[t]>=0)}const xde=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Ai(e,t);switch(r){case"referenceHidden":{const s=await Lf(t,{...o,elementContext:"reference"}),i=WT(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:UT(i)}}}case"escaped":{const s=await Lf(t,{...o,altBoundary:!0}),i=WT(s,n.floating);return{data:{escapedOffsets:i,escaped:UT(i)}}}default:return{}}}}};async function vde(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Pa(n),a=vh(n),l=Tl(n)==="y",c=["left","top"].includes(i)?-1:1,u=s&&l?-1:1,f=Ai(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*u,y:h*c}:{x:h*c,y:p*u}}const wde=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await vde(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},Sde=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:b=>{let{x:y,y:x}=b;return{x:y,y:x}}},...l}=Ai(e,t),c={x:n,y:r},u=await Lf(t,l),f=Tl(Pa(o)),h=pM(f);let p=c[h],m=c[f];if(s){const b=h==="y"?"top":"left",y=h==="y"?"bottom":"right",x=p+u[b],v=p-u[y];p=DE(x,p,v)}if(i){const b=f==="y"?"top":"left",y=f==="y"?"bottom":"right",x=m+u[b],v=m-u[y];m=DE(x,m,v)}const g=a.fn({...t,[h]:p,[f]:m});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[h]:s,[f]:i}}}}}},Cde=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Ai(e,t),u={x:n,y:r},f=Tl(o),h=pM(f);let p=u[h],m=u[f];const g=Ai(a,t),b=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const v=h==="y"?"height":"width",w=s.reference[h]-s.floating[v]+b.mainAxis,S=s.reference[h]+s.reference[v]-b.mainAxis;p<w?p=w:p>S&&(p=S)}if(c){var y,x;const v=h==="y"?"width":"height",w=["top","left"].includes(Pa(o)),S=s.reference[f]-s.floating[v]+(w&&((y=i.offset)==null?void 0:y[f])||0)+(w?0:b.crossAxis),k=s.reference[f]+s.reference[v]+(w?0:((x=i.offset)==null?void 0:x[f])||0)-(w?b.crossAxis:0);m<S?m=S:m>k&&(m=k)}return{[h]:p,[f]:m}}}},Ede=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=Ai(e,t),u=await Lf(t,c),f=Pa(o),h=vh(o),p=Tl(o)==="y",{width:m,height:g}=s.floating;let b,y;f==="top"||f==="bottom"?(b=f,y=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=f,b=h==="end"?"top":"bottom");const x=g-u.top-u.bottom,v=m-u.left-u.right,w=Da(g-u[b],x),S=Da(m-u[y],v),k=!t.middlewareData.shift;let E=w,N=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=v),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=x),k&&!h){const M=Lr(u.left,0),T=Lr(u.right,0),D=Lr(u.top,0),A=Lr(u.bottom,0);p?N=m-2*(M!==0||T!==0?M+T:Lr(u.left,u.right)):E=g-2*(D!==0||A!==0?D+A:Lr(u.top,u.bottom))}await l({...t,availableWidth:N,availableHeight:E});const R=await i.getDimensions(a.floating);return m!==R.width||g!==R.height?{reset:{rects:!0}}:{}}}};function lw(){return typeof window<"u"}function wh(e){return R8(e)?(e.nodeName||"").toLowerCase():"#document"}function Yo(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ui(e){var t;return(t=(R8(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function R8(e){return lw()?e instanceof Node||e instanceof Yo(e).Node:!1}function zr(e){return lw()?e instanceof Element||e instanceof Yo(e).Element:!1}function Ii(e){return lw()?e instanceof HTMLElement||e instanceof Yo(e).HTMLElement:!1}function qT(e){return!lw()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Yo(e).ShadowRoot}function Wg(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Zs(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function _de(e){return["table","td","th"].includes(wh(e))}function cw(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function bM(e){const t=yM(),n=zr(e)?Zs(e):e;return["transform","translate","scale","rotate","perspective"].some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function kde(e){let t=Al(e);for(;Ii(t)&&!zf(t);){if(bM(t))return t;if(cw(t))return null;t=Al(t)}return null}function yM(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function zf(e){return["html","body","#document"].includes(wh(e))}function Zs(e){return Yo(e).getComputedStyle(e)}function uw(e){return zr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Al(e){if(wh(e)==="html")return e;const t=e.assignedSlot||e.parentNode||qT(e)&&e.host||Ui(e);return qT(t)?t.host:t}function D8(e){const t=Al(e);return zf(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ii(t)&&Wg(t)?t:D8(t)}function Fm(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=D8(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Yo(o);if(s){const a=TE(i);return t.concat(i,i.visualViewport||[],Wg(o)?o:[],a&&n?Fm(a):[])}return t.concat(o,Fm(o,[],n))}function TE(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function P8(e){const t=Zs(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ii(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Om(n)!==s||Om(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function xM(e){return zr(e)?e:e.contextElement}function nf(e){const t=xM(e);if(!Ii(t))return yi(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=P8(t);let i=(s?Om(n.width):n.width)/r,a=(s?Om(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Nde=yi(0);function T8(e){const t=Yo(e);return!yM()||!t.visualViewport?Nde:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Mde(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Yo(e)?!1:t}function Su(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=xM(e);let i=yi(1);t&&(r?zr(r)&&(i=nf(r)):i=nf(e));const a=Mde(s,n,r)?T8(s):yi(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,u=o.width/i.x,f=o.height/i.y;if(s){const h=Yo(s),p=r&&zr(r)?Yo(r):r;let m=h,g=TE(m);for(;g&&r&&p!==m;){const b=nf(g),y=g.getBoundingClientRect(),x=Zs(g),v=y.left+(g.clientLeft+parseFloat(x.paddingLeft))*b.x,w=y.top+(g.clientTop+parseFloat(x.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,f*=b.y,l+=v,c+=w,m=Yo(g),g=TE(m)}}return rx({width:u,height:f,x:l,y:c})}function vM(e,t){const n=uw(e).scrollLeft;return t?t.left+n:Su(Ui(e)).left+n}function A8(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:vM(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function jde(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Ui(r),a=t?cw(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=yi(1);const u=yi(0),f=Ii(r);if((f||!f&&!s)&&((wh(r)!=="body"||Wg(i))&&(l=uw(r)),Ii(r))){const p=Su(r);c=nf(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const h=i&&!f&&!s?A8(i,l,!0):yi(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-l.scrollTop*c.y+u.y+h.y}}function Rde(e){return Array.from(e.getClientRects())}function Dde(e){const t=Ui(e),n=uw(e),r=e.ownerDocument.body,o=Lr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Lr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+vM(e);const a=-n.scrollTop;return Zs(r).direction==="rtl"&&(i+=Lr(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function Pde(e,t){const n=Yo(e),r=Ui(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const c=yM();(!c||c&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a,y:l}}function Tde(e,t){const n=Su(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Ii(e)?nf(e):yi(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function GT(e,t,n){let r;if(t==="viewport")r=Pde(e,n);else if(t==="document")r=Dde(Ui(e));else if(zr(t))r=Tde(t,n);else{const o=T8(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return rx(r)}function I8(e,t){const n=Al(e);return n===t||!zr(n)||zf(n)?!1:Zs(n).position==="fixed"||I8(n,t)}function Ade(e,t){const n=t.get(e);if(n)return n;let r=Fm(e,[],!1).filter(a=>zr(a)&&wh(a)!=="body"),o=null;const s=Zs(e).position==="fixed";let i=s?Al(e):e;for(;zr(i)&&!zf(i);){const a=Zs(i),l=bM(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Wg(i)&&!l&&I8(e,i))?r=r.filter(u=>u!==i):o=a,i=Al(i)}return t.set(e,r),r}function Ide(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?cw(t)?[]:Ade(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,u)=>{const f=GT(t,u,o);return c.top=Lr(f.top,c.top),c.right=Da(f.right,c.right),c.bottom=Da(f.bottom,c.bottom),c.left=Lr(f.left,c.left),c},GT(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Ode(e){const{width:t,height:n}=P8(e);return{width:t,height:n}}function Fde(e,t,n){const r=Ii(t),o=Ui(t),s=n==="fixed",i=Su(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=yi(0);if(r||!r&&!s)if((wh(t)!=="body"||Wg(o))&&(a=uw(t)),r){const h=Su(t,!0,s,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else o&&(l.x=vM(o));const c=o&&!r&&!s?A8(o,a):yi(0),u=i.left+a.scrollLeft-l.x-c.x,f=i.top+a.scrollTop-l.y-c.y;return{x:u,y:f,width:i.width,height:i.height}}function AS(e){return Zs(e).position==="static"}function YT(e,t){if(!Ii(e)||Zs(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ui(e)===n&&(n=n.ownerDocument.body),n}function O8(e,t){const n=Yo(e);if(cw(e))return n;if(!Ii(e)){let o=Al(e);for(;o&&!zf(o);){if(zr(o)&&!AS(o))return o;o=Al(o)}return n}let r=YT(e,t);for(;r&&_de(r)&&AS(r);)r=YT(r,t);return r&&zf(r)&&AS(r)&&!bM(r)?n:r||kde(e)||n}const $de=async function(e){const t=this.getOffsetParent||O8,n=this.getDimensions,r=await n(e.floating);return{reference:Fde(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Lde(e){return Zs(e).direction==="rtl"}const zde={convertOffsetParentRelativeRectToViewportRelativeRect:jde,getDocumentElement:Ui,getClippingRect:Ide,getOffsetParent:O8,getElementRects:$de,getClientRects:Rde,getDimensions:Ode,getScale:nf,isElement:zr,isRTL:Lde};function F8(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Bde(e,t){let n=null,r;const o=Ui(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:u,top:f,width:h,height:p}=c;if(a||t(),!h||!p)return;const m=iy(f),g=iy(o.clientWidth-(u+h)),b=iy(o.clientHeight-(f+p)),y=iy(u),v={rootMargin:-m+"px "+-g+"px "+-b+"px "+-y+"px",threshold:Lr(0,Da(1,l))||1};let w=!0;function S(k){const E=k[0].intersectionRatio;if(E!==l){if(!w)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!F8(c,e.getBoundingClientRect())&&i(),w=!1}try{n=new IntersectionObserver(S,{...v,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,v)}n.observe(e)}return i(!0),s}function wM(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=xM(e),u=o||s?[...c?Fm(c):[],...Fm(t)]:[];u.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=c&&a?Bde(c,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(y=>{let[x]=y;x&&x.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var v;(v=p)==null||v.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let m,g=l?Su(e):null;l&&b();function b(){const y=Su(e);g&&!F8(g,y)&&n(),g=y,m=requestAnimationFrame(b)}return n(),()=>{var y;u.forEach(x=>{o&&x.removeEventListener("scroll",n),s&&x.removeEventListener("resize",n)}),f==null||f(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(m)}}const IS=Lf,Vde=wde,Hde=Sde,Wde=yde,Ude=Ede,qde=xde,ZT=bde,Gde=Cde,Yde=(e,t,n)=>{const r=new Map,o={platform:zde,...n},s={...o.platform,_c:r};return gde(e,t,{...o,platform:s})};var p0=typeof document<"u"?_.useLayoutEffect:_.useEffect;function ox(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ox(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!ox(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function $8(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function KT(e,t){const n=$8(e);return Math.round(t*n)/n}function OS(e){const t=C.useRef(e);return p0(()=>{t.current=e}),t}function SM(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,f]=C.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=C.useState(r);ox(h,r)||p(r);const[m,g]=C.useState(null),[b,y]=C.useState(null),x=C.useCallback(V=>{V!==k.current&&(k.current=V,g(V))},[]),v=C.useCallback(V=>{V!==E.current&&(E.current=V,y(V))},[]),w=s||m,S=i||b,k=C.useRef(null),E=C.useRef(null),N=C.useRef(u),R=l!=null,M=OS(l),T=OS(o),D=OS(c),A=C.useCallback(()=>{if(!k.current||!E.current)return;const V={placement:t,strategy:n,middleware:h};T.current&&(V.platform=T.current),Yde(k.current,E.current,V).then($=>{const I={...$,isPositioned:D.current!==!1};O.current&&!ox(N.current,I)&&(N.current=I,ja.flushSync(()=>{f(I)}))})},[h,t,n,T,D]);p0(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f(V=>({...V,isPositioned:!1})))},[c]);const O=C.useRef(!1);p0(()=>(O.current=!0,()=>{O.current=!1}),[]),p0(()=>{if(w&&(k.current=w),S&&(E.current=S),w&&S){if(M.current)return M.current(w,S,A);A()}},[w,S,A,M,R]);const j=C.useMemo(()=>({reference:k,floating:E,setReference:x,setFloating:v}),[x,v]),F=C.useMemo(()=>({reference:w,floating:S}),[w,S]),L=C.useMemo(()=>{const V={position:n,left:0,top:0};if(!F.floating)return V;const $=KT(F.floating,u.x),I=KT(F.floating,u.y);return a?{...V,transform:"translate("+$+"px, "+I+"px)",...$8(F.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:$,top:I}},[n,a,F.floating,u.x,u.y]);return C.useMemo(()=>({...u,update:A,refs:j,elements:F,floatingStyles:L}),[u,A,j,F,L])}const Zde=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?ZT({element:r.current,padding:o}).fn(n):{}:r?ZT({element:r,padding:o}).fn(n):{}}}},dw=(e,t)=>({...Vde(e),options:[e,t]}),CM=(e,t)=>({...Hde(e),options:[e,t]}),L8=(e,t)=>({...Gde(e),options:[e,t]}),EM=(e,t)=>({...Wde(e),options:[e,t]}),_M=(e,t)=>({...Ude(e),options:[e,t]}),z8=(e,t)=>({...qde(e),options:[e,t]}),B8=(e,t)=>({...Zde(e),options:[e,t]});var Kde="Arrow",V8=C.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return d.jsx(Pe.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});V8.displayName=Kde;var Xde=V8;function fw(e){const[t,n]=C.useState(void 0);return Mr(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var kM="Popper",[H8,qi]=hr(kM),[Qde,W8]=H8(kM),U8=e=>{const{__scopePopper:t,children:n}=e,[r,o]=C.useState(null);return d.jsx(Qde,{scope:t,anchor:r,onAnchorChange:o,children:n})};U8.displayName=kM;var q8="PopperAnchor",G8=C.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=W8(q8,n),i=C.useRef(null),a=Je(t,i);return C.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||i.current)}),r?null:d.jsx(Pe.div,{...o,ref:a})});G8.displayName=q8;var NM="PopperContent",[Jde,efe]=H8(NM),Y8=C.forwardRef((e,t)=>{var U,z,G,J,ee,q;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:m,...g}=e,b=W8(NM,n),[y,x]=C.useState(null),v=Je(t,ie=>x(ie)),[w,S]=C.useState(null),k=fw(w),E=(k==null?void 0:k.width)??0,N=(k==null?void 0:k.height)??0,R=r+(s!=="center"?"-"+s:""),M=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},T=Array.isArray(c)?c:[c],D=T.length>0,A={padding:M,boundary:T.filter(nfe),altBoundary:D},{refs:O,floatingStyles:j,placement:F,isPositioned:L,middlewareData:V}=SM({strategy:"fixed",placement:R,whileElementsMounted:(...ie)=>wM(...ie,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[dw({mainAxis:o+N,alignmentAxis:i}),l&&CM({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?L8():void 0,...A}),l&&EM({...A}),_M({...A,apply:({elements:ie,rects:ne,availableWidth:le,availableHeight:ge})=>{const{width:Me,height:ue}=ne.reference,ke=ie.floating.style;ke.setProperty("--radix-popper-available-width",`${le}px`),ke.setProperty("--radix-popper-available-height",`${ge}px`),ke.setProperty("--radix-popper-anchor-width",`${Me}px`),ke.setProperty("--radix-popper-anchor-height",`${ue}px`)}}),w&&B8({element:w,padding:a}),rfe({arrowWidth:E,arrowHeight:N}),h&&z8({strategy:"referenceHidden",...A})]}),[$,I]=X8(F),H=rr(m);Mr(()=>{L&&(H==null||H())},[L,H]);const B=(U=V.arrow)==null?void 0:U.x,P=(z=V.arrow)==null?void 0:z.y,W=((G=V.arrow)==null?void 0:G.centerOffset)!==0,[Y,X]=C.useState();return Mr(()=>{y&&X(window.getComputedStyle(y).zIndex)},[y]),d.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...j,transform:L?j.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Y,"--radix-popper-transform-origin":[(J=V.transformOrigin)==null?void 0:J.x,(ee=V.transformOrigin)==null?void 0:ee.y].join(" "),...((q=V.hide)==null?void 0:q.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:d.jsx(Jde,{scope:n,placedSide:$,onArrowChange:S,arrowX:B,arrowY:P,shouldHideArrow:W,children:d.jsx(Pe.div,{"data-side":$,"data-align":I,...g,ref:v,style:{...g.style,animation:L?void 0:"none"}})})})});Y8.displayName=NM;var Z8="PopperArrow",tfe={top:"bottom",right:"left",bottom:"top",left:"right"},K8=C.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=efe(Z8,r),i=tfe[s.placedSide];return d.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:d.jsx(Xde,{...o,ref:n,style:{...o.style,display:"block"}})})});K8.displayName=Z8;function nfe(e){return e!==null}var rfe=e=>({name:"transformOrigin",options:e,fn(t){var b,y,x;const{placement:n,rects:r,middlewareData:o}=t,i=((b=o.arrow)==null?void 0:b.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,u]=X8(n),f={start:"0%",center:"50%",end:"100%"}[u],h=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((x=o.arrow)==null?void 0:x.y)??0)+l/2;let m="",g="";return c==="bottom"?(m=i?f:`${h}px`,g=`${-l}px`):c==="top"?(m=i?f:`${h}px`,g=`${r.floating.height+l}px`):c==="right"?(m=`${-l}px`,g=i?f:`${p}px`):c==="left"&&(m=`${r.floating.width+l}px`,g=i?f:`${p}px`),{data:{x:m,y:g}}}});function X8(e){const[t,n="center"]=e.split("-");return[t,n]}var Sh=U8,Ch=G8,Ug=Y8,qg=K8,ofe="Portal",Zu=C.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=C.useState(!1);Mr(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?jn.createPortal(d.jsx(Pe.div,{...r,ref:t}),i):null});Zu.displayName=ofe;var Q8=C.forwardRef((e,t)=>{const{children:n,...r}=e,o=C.Children.toArray(n),s=o.find(ife);if(s){const i=s.props.children,a=o.map(l=>l===s?C.Children.count(i)>1?C.Children.only(null):C.isValidElement(i)?i.props.children:null:l);return d.jsx(AE,{...r,ref:t,children:C.isValidElement(i)?C.cloneElement(i,void 0,a):null})}return d.jsx(AE,{...r,ref:t,children:n})});Q8.displayName="Slot";var AE=C.forwardRef((e,t)=>{const{children:n,...r}=e;if(C.isValidElement(n)){const o=lfe(n),s=afe(r,n.props);return n.type!==C.Fragment&&(s.ref=t?so(t,o):o),C.cloneElement(n,s)}return C.Children.count(n)>1?C.Children.only(null):null});AE.displayName="SlotClone";var sfe=({children:e})=>d.jsx(d.Fragment,{children:e});function ife(e){return C.isValidElement(e)&&e.type===sfe}function afe(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function lfe(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var MM="Popover",[J8,JZe]=hr(MM,[qi]),Gg=qi(),[cfe,tc]=J8(MM),ez=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,a=Gg(t),l=C.useRef(null),[c,u]=C.useState(!1),[f=!1,h]=jr({prop:r,defaultProp:o,onChange:s});return d.jsx(Sh,{...a,children:d.jsx(cfe,{scope:t,contentId:Wn(),triggerRef:l,open:f,onOpenChange:h,onOpenToggle:C.useCallback(()=>h(p=>!p),[h]),hasCustomAnchor:c,onCustomAnchorAdd:C.useCallback(()=>u(!0),[]),onCustomAnchorRemove:C.useCallback(()=>u(!1),[]),modal:i,children:n})})};ez.displayName=MM;var tz="PopoverAnchor",ufe=C.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=tc(tz,n),s=Gg(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:a}=o;return C.useEffect(()=>(i(),()=>a()),[i,a]),d.jsx(Ch,{...s,...r,ref:t})});ufe.displayName=tz;var nz="PopoverTrigger",rz=C.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=tc(nz,n),s=Gg(n),i=Je(t,o.triggerRef),a=d.jsx(Pe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":lz(o.open),...r,ref:i,onClick:xe(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:d.jsx(Ch,{asChild:!0,...s,children:a})});rz.displayName=nz;var jM="PopoverPortal",[dfe,ffe]=J8(jM,{forceMount:void 0}),oz=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,s=tc(jM,t);return d.jsx(dfe,{scope:t,forceMount:n,children:d.jsx(Un,{present:n||s.open,children:d.jsx(Zu,{asChild:!0,container:o,children:r})})})};oz.displayName=jM;var Bf="PopoverContent",sz=C.forwardRef((e,t)=>{const n=ffe(Bf,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,s=tc(Bf,e.__scopePopover);return d.jsx(Un,{present:r||s.open,children:s.modal?d.jsx(hfe,{...o,ref:t}):d.jsx(pfe,{...o,ref:t})})});sz.displayName=Bf;var hfe=C.forwardRef((e,t)=>{const n=tc(Bf,e.__scopePopover),r=C.useRef(null),o=Je(t,r),s=C.useRef(!1);return C.useEffect(()=>{const i=r.current;if(i)return ph(i)},[]),d.jsx(Hu,{as:Q8,allowPinchZoom:!0,children:d.jsx(iz,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:xe(e.onCloseAutoFocus,i=>{var a;i.preventDefault(),s.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:xe(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;s.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:xe(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),pfe=C.forwardRef((e,t)=>{const n=tc(Bf,e.__scopePopover),r=C.useRef(!1),o=C.useRef(!1);return d.jsx(iz,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),iz=C.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...f}=e,h=tc(Bf,n),p=Gg(n);return aw(),d.jsx(Hg,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:d.jsx(Yu,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:d.jsx(Ug,{"data-state":lz(h.open),role:"dialog",id:h.contentId,...p,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),az="PopoverClose",mfe=C.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=tc(az,n);return d.jsx(Pe.button,{type:"button",...r,ref:t,onClick:xe(e.onClick,()=>o.onOpenChange(!1))})});mfe.displayName=az;var gfe="PopoverArrow",bfe=C.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Gg(n);return d.jsx(qg,{...o,...r,ref:t})});bfe.displayName=gfe;function lz(e){return e?"open":"closed"}var yfe=ez,xfe=rz,vfe=oz,hw=sz;const Zo=yfe,Ko=xfe,_o=C.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>d.jsx(vfe,{children:d.jsx(Qs,{children:d.jsx(hw,{ref:o,align:t,sideOffset:n,className:K("z-49 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})})}));_o.displayName=hw.displayName;function IE(e,[t,n]){return Math.min(n,Math.max(t,e))}var cz=C.forwardRef((e,t)=>{const{children:n,...r}=e,o=C.Children.toArray(n),s=o.find(Sfe);if(s){const i=s.props.children,a=o.map(l=>l===s?C.Children.count(i)>1?C.Children.only(null):C.isValidElement(i)?i.props.children:null:l);return d.jsx(OE,{...r,ref:t,children:C.isValidElement(i)?C.cloneElement(i,void 0,a):null})}return d.jsx(OE,{...r,ref:t,children:n})});cz.displayName="Slot";var OE=C.forwardRef((e,t)=>{const{children:n,...r}=e;if(C.isValidElement(n)){const o=Efe(n),s=Cfe(r,n.props);return n.type!==C.Fragment&&(s.ref=t?so(t,o):o),C.cloneElement(n,s)}return C.Children.count(n)>1?C.Children.only(null):null});OE.displayName="SlotClone";var wfe=({children:e})=>d.jsx(d.Fragment,{children:e});function Sfe(e){return C.isValidElement(e)&&e.type===wfe}function Cfe(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function Efe(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function pw(e){const t=C.useRef({value:e,previous:e});return C.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var _fe="VisuallyHidden",RM=C.forwardRef((e,t)=>d.jsx(Pe.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));RM.displayName=_fe;var kfe=RM,Nfe=[" ","Enter","ArrowUp","ArrowDown"],Mfe=[" ","Enter"],Yg="Select",[mw,gw,jfe]=zv(Yg),[Eh,eKe]=hr(Yg,[jfe,qi]),bw=qi(),[Rfe,nc]=Eh(Yg),[Dfe,Pfe]=Eh(Yg),uz=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:u,autoComplete:f,disabled:h,required:p,form:m}=e,g=bw(t),[b,y]=C.useState(null),[x,v]=C.useState(null),[w,S]=C.useState(!1),k=Wu(c),[E=!1,N]=jr({prop:r,defaultProp:o,onChange:s}),[R,M]=jr({prop:i,defaultProp:a,onChange:l}),T=C.useRef(null),D=b?m||!!b.closest("form"):!0,[A,O]=C.useState(new Set),j=Array.from(A).map(F=>F.props.value).join(";");return d.jsx(Sh,{...g,children:d.jsxs(Rfe,{required:p,scope:t,trigger:b,onTriggerChange:y,valueNode:x,onValueNodeChange:v,valueNodeHasChildren:w,onValueNodeHasChildrenChange:S,contentId:Wn(),value:R,onValueChange:M,open:E,onOpenChange:N,dir:k,triggerPointerDownPosRef:T,disabled:h,children:[d.jsx(mw.Provider,{scope:t,children:d.jsx(Dfe,{scope:e.__scopeSelect,onNativeOptionAdd:C.useCallback(F=>{O(L=>new Set(L).add(F))},[]),onNativeOptionRemove:C.useCallback(F=>{O(L=>{const V=new Set(L);return V.delete(F),V})},[]),children:n})}),D?d.jsxs(Oz,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:f,value:R,onChange:F=>M(F.target.value),disabled:h,form:m,children:[R===void 0?d.jsx("option",{value:""}):null,Array.from(A)]},j):null]})})};uz.displayName=Yg;var dz="SelectTrigger",fz=C.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=bw(n),i=nc(dz,n),a=i.disabled||r,l=Je(t,i.onTriggerChange),c=gw(n),u=C.useRef("touch"),[f,h,p]=Fz(g=>{const b=c().filter(v=>!v.disabled),y=b.find(v=>v.value===i.value),x=$z(b,g,y);x!==void 0&&i.onValueChange(x.value)}),m=g=>{a||(i.onOpenChange(!0),p()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return d.jsx(Ch,{asChild:!0,...s,children:d.jsx(Pe.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Iz(i.value)?"":void 0,...o,ref:l,onClick:xe(o.onClick,g=>{g.currentTarget.focus(),u.current!=="mouse"&&m(g)}),onPointerDown:xe(o.onPointerDown,g=>{u.current=g.pointerType;const b=g.target;b.hasPointerCapture(g.pointerId)&&b.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(m(g),g.preventDefault())}),onKeyDown:xe(o.onKeyDown,g=>{const b=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&h(g.key),!(b&&g.key===" ")&&Nfe.includes(g.key)&&(m(),g.preventDefault())})})})});fz.displayName=dz;var hz="SelectValue",pz=C.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=nc(hz,n),{onValueNodeHasChildrenChange:c}=l,u=s!==void 0,f=Je(t,l.onValueNodeChange);return Mr(()=>{c(u)},[c,u]),d.jsx(Pe.span,{...a,ref:f,style:{pointerEvents:"none"},children:Iz(l.value)?d.jsx(d.Fragment,{children:i}):s})});pz.displayName=hz;var Tfe="SelectIcon",mz=C.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return d.jsx(Pe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});mz.displayName=Tfe;var Afe="SelectPortal",gz=e=>d.jsx(Zu,{asChild:!0,...e});gz.displayName=Afe;var Cu="SelectContent",bz=C.forwardRef((e,t)=>{const n=nc(Cu,e.__scopeSelect),[r,o]=C.useState();if(Mr(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?ja.createPortal(d.jsx(yz,{scope:e.__scopeSelect,children:d.jsx(mw.Slot,{scope:e.__scopeSelect,children:d.jsx("div",{children:e.children})})}),s):null}return d.jsx(xz,{...e,ref:t})});bz.displayName=Cu;var Ds=10,[yz,rc]=Eh(Cu),Ife="SelectContentImpl",xz=C.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:b,...y}=e,x=nc(Cu,n),[v,w]=C.useState(null),[S,k]=C.useState(null),E=Je(t,U=>w(U)),[N,R]=C.useState(null),[M,T]=C.useState(null),D=gw(n),[A,O]=C.useState(!1),j=C.useRef(!1);C.useEffect(()=>{if(v)return ph(v)},[v]),aw();const F=C.useCallback(U=>{const[z,...G]=D().map(q=>q.ref.current),[J]=G.slice(-1),ee=document.activeElement;for(const q of U)if(q===ee||(q==null||q.scrollIntoView({block:"nearest"}),q===z&&S&&(S.scrollTop=0),q===J&&S&&(S.scrollTop=S.scrollHeight),q==null||q.focus(),document.activeElement!==ee))return},[D,S]),L=C.useCallback(()=>F([N,v]),[F,N,v]);C.useEffect(()=>{A&&L()},[A,L]);const{onOpenChange:V,triggerPointerDownPosRef:$}=x;C.useEffect(()=>{if(v){let U={x:0,y:0};const z=J=>{var ee,q;U={x:Math.abs(Math.round(J.pageX)-(((ee=$.current)==null?void 0:ee.x)??0)),y:Math.abs(Math.round(J.pageY)-(((q=$.current)==null?void 0:q.y)??0))}},G=J=>{U.x<=10&&U.y<=10?J.preventDefault():v.contains(J.target)||V(!1),document.removeEventListener("pointermove",z),$.current=null};return $.current!==null&&(document.addEventListener("pointermove",z),document.addEventListener("pointerup",G,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",z),document.removeEventListener("pointerup",G,{capture:!0})}}},[v,V,$]),C.useEffect(()=>{const U=()=>V(!1);return window.addEventListener("blur",U),window.addEventListener("resize",U),()=>{window.removeEventListener("blur",U),window.removeEventListener("resize",U)}},[V]);const[I,H]=Fz(U=>{const z=D().filter(ee=>!ee.disabled),G=z.find(ee=>ee.ref.current===document.activeElement),J=$z(z,U,G);J&&setTimeout(()=>J.ref.current.focus())}),B=C.useCallback((U,z,G)=>{const J=!j.current&&!G;(x.value!==void 0&&x.value===z||J)&&(R(U),J&&(j.current=!0))},[x.value]),P=C.useCallback(()=>v==null?void 0:v.focus(),[v]),W=C.useCallback((U,z,G)=>{const J=!j.current&&!G;(x.value!==void 0&&x.value===z||J)&&T(U)},[x.value]),Y=r==="popper"?FE:vz,X=Y===FE?{side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:b}:{};return d.jsx(yz,{scope:n,content:v,viewport:S,onViewportChange:k,itemRefCallback:B,selectedItem:N,onItemLeave:P,itemTextRefCallback:W,focusSelectedItem:L,selectedItemText:M,position:r,isPositioned:A,searchRef:I,children:d.jsx(Hu,{as:cz,allowPinchZoom:!0,children:d.jsx(Hg,{asChild:!0,trapped:x.open,onMountAutoFocus:U=>{U.preventDefault()},onUnmountAutoFocus:xe(o,U=>{var z;(z=x.trigger)==null||z.focus({preventScroll:!0}),U.preventDefault()}),children:d.jsx(Yu,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:U=>U.preventDefault(),onDismiss:()=>x.onOpenChange(!1),children:d.jsx(Y,{role:"listbox",id:x.contentId,"data-state":x.open?"open":"closed",dir:x.dir,onContextMenu:U=>U.preventDefault(),...y,...X,onPlaced:()=>O(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:xe(y.onKeyDown,U=>{const z=U.ctrlKey||U.altKey||U.metaKey;if(U.key==="Tab"&&U.preventDefault(),!z&&U.key.length===1&&H(U.key),["ArrowUp","ArrowDown","Home","End"].includes(U.key)){let J=D().filter(ee=>!ee.disabled).map(ee=>ee.ref.current);if(["ArrowUp","End"].includes(U.key)&&(J=J.slice().reverse()),["ArrowUp","ArrowDown"].includes(U.key)){const ee=U.target,q=J.indexOf(ee);J=J.slice(q+1)}setTimeout(()=>F(J)),U.preventDefault()}})})})})})})});xz.displayName=Ife;var Ofe="SelectItemAlignedPosition",vz=C.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=nc(Cu,n),i=rc(Cu,n),[a,l]=C.useState(null),[c,u]=C.useState(null),f=Je(t,E=>u(E)),h=gw(n),p=C.useRef(!1),m=C.useRef(!0),{viewport:g,selectedItem:b,selectedItemText:y,focusSelectedItem:x}=i,v=C.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&b&&y){const E=s.trigger.getBoundingClientRect(),N=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),M=y.getBoundingClientRect();if(s.dir!=="rtl"){const ee=M.left-N.left,q=R.left-ee,ie=E.left-q,ne=E.width+ie,le=Math.max(ne,N.width),ge=window.innerWidth-Ds,Me=IE(q,[Ds,Math.max(Ds,ge-le)]);a.style.minWidth=ne+"px",a.style.left=Me+"px"}else{const ee=N.right-M.right,q=window.innerWidth-R.right-ee,ie=window.innerWidth-E.right-q,ne=E.width+ie,le=Math.max(ne,N.width),ge=window.innerWidth-Ds,Me=IE(q,[Ds,Math.max(Ds,ge-le)]);a.style.minWidth=ne+"px",a.style.right=Me+"px"}const T=h(),D=window.innerHeight-Ds*2,A=g.scrollHeight,O=window.getComputedStyle(c),j=parseInt(O.borderTopWidth,10),F=parseInt(O.paddingTop,10),L=parseInt(O.borderBottomWidth,10),V=parseInt(O.paddingBottom,10),$=j+F+A+V+L,I=Math.min(b.offsetHeight*5,$),H=window.getComputedStyle(g),B=parseInt(H.paddingTop,10),P=parseInt(H.paddingBottom,10),W=E.top+E.height/2-Ds,Y=D-W,X=b.offsetHeight/2,U=b.offsetTop+X,z=j+F+U,G=$-z;if(z<=W){const ee=T.length>0&&b===T[T.length-1].ref.current;a.style.bottom="0px";const q=c.clientHeight-g.offsetTop-g.offsetHeight,ie=Math.max(Y,X+(ee?P:0)+q+L),ne=z+ie;a.style.height=ne+"px"}else{const ee=T.length>0&&b===T[0].ref.current;a.style.top="0px";const ie=Math.max(W,j+g.offsetTop+(ee?B:0)+X)+G;a.style.height=ie+"px",g.scrollTop=z-W+g.offsetTop}a.style.margin=`${Ds}px 0`,a.style.minHeight=I+"px",a.style.maxHeight=D+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,c,g,b,y,s.dir,r]);Mr(()=>v(),[v]);const[w,S]=C.useState();Mr(()=>{c&&S(window.getComputedStyle(c).zIndex)},[c]);const k=C.useCallback(E=>{E&&m.current===!0&&(v(),x==null||x(),m.current=!1)},[v,x]);return d.jsx($fe,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:k,children:d.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:d.jsx(Pe.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});vz.displayName=Ofe;var Ffe="SelectPopperPosition",FE=C.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Ds,...s}=e,i=bw(n);return d.jsx(Ug,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});FE.displayName=Ffe;var[$fe,DM]=Eh(Cu,{}),$E="SelectViewport",wz=C.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=rc($E,n),i=DM($E,n),a=Je(t,s.onViewportChange),l=C.useRef(0);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),d.jsx(mw.Slot,{scope:n,children:d.jsx(Pe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:xe(o.onScroll,c=>{const u=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-u.scrollTop);if(p>0){const m=window.innerHeight-Ds*2,g=parseFloat(f.style.minHeight),b=parseFloat(f.style.height),y=Math.max(g,b);if(y<m){const x=y+p,v=Math.min(m,x),w=x-v;f.style.height=v+"px",f.style.bottom==="0px"&&(u.scrollTop=w>0?w:0,f.style.justifyContent="flex-end")}}}l.current=u.scrollTop})})})]})});wz.displayName=$E;var Sz="SelectGroup",[Lfe,zfe]=Eh(Sz),Cz=C.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Wn();return d.jsx(Lfe,{scope:n,id:o,children:d.jsx(Pe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Cz.displayName=Sz;var Ez="SelectLabel",_z=C.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=zfe(Ez,n);return d.jsx(Pe.div,{id:o.id,...r,ref:t})});_z.displayName=Ez;var sx="SelectItem",[Bfe,kz]=Eh(sx),Nz=C.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=nc(sx,n),l=rc(sx,n),c=a.value===r,[u,f]=C.useState(s??""),[h,p]=C.useState(!1),m=Je(t,x=>{var v;return(v=l.itemRefCallback)==null?void 0:v.call(l,x,r,o)}),g=Wn(),b=C.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return d.jsx(Bfe,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:C.useCallback(x=>{f(v=>v||((x==null?void 0:x.textContent)??"").trim())},[]),children:d.jsx(mw.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:d.jsx(Pe.div,{role:"option","aria-labelledby":g,"data-highlighted":h?"":void 0,"aria-selected":c&&h,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:m,onFocus:xe(i.onFocus,()=>p(!0)),onBlur:xe(i.onBlur,()=>p(!1)),onClick:xe(i.onClick,()=>{b.current!=="mouse"&&y()}),onPointerUp:xe(i.onPointerUp,()=>{b.current==="mouse"&&y()}),onPointerDown:xe(i.onPointerDown,x=>{b.current=x.pointerType}),onPointerMove:xe(i.onPointerMove,x=>{var v;b.current=x.pointerType,o?(v=l.onItemLeave)==null||v.call(l):b.current==="mouse"&&x.currentTarget.focus({preventScroll:!0})}),onPointerLeave:xe(i.onPointerLeave,x=>{var v;x.currentTarget===document.activeElement&&((v=l.onItemLeave)==null||v.call(l))}),onKeyDown:xe(i.onKeyDown,x=>{var w;((w=l.searchRef)==null?void 0:w.current)!==""&&x.key===" "||(Mfe.includes(x.key)&&y(),x.key===" "&&x.preventDefault())})})})})});Nz.displayName=sx;var vp="SelectItemText",Mz=C.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=nc(vp,n),a=rc(vp,n),l=kz(vp,n),c=Pfe(vp,n),[u,f]=C.useState(null),h=Je(t,y=>f(y),l.onItemTextChange,y=>{var x;return(x=a.itemTextRefCallback)==null?void 0:x.call(a,y,l.value,l.disabled)}),p=u==null?void 0:u.textContent,m=C.useMemo(()=>d.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:b}=c;return Mr(()=>(g(m),()=>b(m)),[g,b,m]),d.jsxs(d.Fragment,{children:[d.jsx(Pe.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?ja.createPortal(s.children,i.valueNode):null]})});Mz.displayName=vp;var jz="SelectItemIndicator",Rz=C.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return kz(jz,n).isSelected?d.jsx(Pe.span,{"aria-hidden":!0,...r,ref:t}):null});Rz.displayName=jz;var LE="SelectScrollUpButton",Dz=C.forwardRef((e,t)=>{const n=rc(LE,e.__scopeSelect),r=DM(LE,e.__scopeSelect),[o,s]=C.useState(!1),i=Je(t,r.onScrollButtonChange);return Mr(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?d.jsx(Tz,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Dz.displayName=LE;var zE="SelectScrollDownButton",Pz=C.forwardRef((e,t)=>{const n=rc(zE,e.__scopeSelect),r=DM(zE,e.__scopeSelect),[o,s]=C.useState(!1),i=Je(t,r.onScrollButtonChange);return Mr(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,u=Math.ceil(l.scrollTop)<c;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?d.jsx(Tz,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Pz.displayName=zE;var Tz=C.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=rc("SelectScrollButton",n),i=C.useRef(null),a=gw(n),l=C.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return C.useEffect(()=>()=>l(),[l]),Mr(()=>{var u;const c=a().find(f=>f.ref.current===document.activeElement);(u=c==null?void 0:c.ref.current)==null||u.scrollIntoView({block:"nearest"})},[a]),d.jsx(Pe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:xe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:xe(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:xe(o.onPointerLeave,()=>{l()})})}),Vfe="SelectSeparator",Az=C.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return d.jsx(Pe.div,{"aria-hidden":!0,...r,ref:t})});Az.displayName=Vfe;var BE="SelectArrow",Hfe=C.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=bw(n),s=nc(BE,n),i=rc(BE,n);return s.open&&i.position==="popper"?d.jsx(qg,{...o,...r,ref:t}):null});Hfe.displayName=BE;function Iz(e){return e===""||e===void 0}var Oz=C.forwardRef((e,t)=>{const{value:n,...r}=e,o=C.useRef(null),s=Je(t,o),i=pw(n);return C.useEffect(()=>{const a=o.current,l=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==n&&u){const f=new Event("change",{bubbles:!0});u.call(a,n),a.dispatchEvent(f)}},[i,n]),d.jsx(RM,{asChild:!0,children:d.jsx("select",{...r,ref:s,defaultValue:n})})});Oz.displayName="BubbleSelect";function Fz(e){const t=rr(e),n=C.useRef(""),r=C.useRef(0),o=C.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=C.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return C.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function $z(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=Wfe(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Wfe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ufe=uz,Lz=fz,qfe=pz,Gfe=mz,Yfe=gz,zz=bz,Zfe=wz,Kfe=Cz,Bz=_z,Vz=Nz,Xfe=Mz,Qfe=Rz,Hz=Dz,Wz=Pz,Uz=Az;const hn=Ufe,qz=Kfe,pn=qfe,an=C.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(Lz,{ref:r,className:K("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-0 focus:ring-ring focus:ring-offset-0 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,d.jsx(Gfe,{asChild:!0,children:d.jsx(Eo,{className:"h-4 w-4 opacity-50"})})]}));an.displayName=Lz.displayName;const Gz=C.forwardRef(({className:e,...t},n)=>d.jsx(Hz,{ref:n,className:K("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(Qd,{className:"h-4 w-4"})}));Gz.displayName=Hz.displayName;const Yz=C.forwardRef(({className:e,...t},n)=>d.jsx(Wz,{ref:n,className:K("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(Eo,{className:"h-4 w-4"})}));Yz.displayName=Wz.displayName;const ln=C.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>d.jsx(Yfe,{children:d.jsx(Qs,{children:d.jsxs(zz,{ref:o,className:K("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[d.jsx(Gz,{}),d.jsx(Zfe,{className:K("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),d.jsx(Yz,{})]})})}));ln.displayName=zz.displayName;const PM=C.forwardRef(({className:e,...t},n)=>d.jsx(Bz,{ref:n,className:K("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));PM.displayName=Bz.displayName;const Ne=C.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(Vz,{ref:r,className:K("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[d.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(Qfe,{children:d.jsx(_r,{className:"h-4 w-4"})})}),d.jsx(Xfe,{children:t})]}));Ne.displayName=Vz.displayName;const Jfe=C.forwardRef(({className:e,...t},n)=>d.jsx(Uz,{ref:n,className:K("-mx-1 my-1 h-px bg-muted",e),...t}));Jfe.displayName=Uz.displayName;const yr=C.forwardRef(({className:e,type:t,...n},r)=>d.jsx("input",{type:t,className:K("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-inset ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));yr.displayName="Input";function ehe({step:e,hierarchyId:t,stepIndex:n,onUpdateStep:r,open:o,onOpenChange:s,trigger:i}){return d.jsxs(Zo,{open:o,onOpenChange:s,children:[d.jsx(Ko,{asChild:!0,children:i}),d.jsx(_o,{className:"z-50 w-80",align:"start",children:d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{children:[d.jsx(de,{className:"mb-1 block text-xs font-medium",children:"Chart Type"}),d.jsxs(hn,{value:e.preferredChartType||"bar",onValueChange:a=>{r(t,n,{preferredChartType:a})},children:[d.jsx(an,{className:"h-8",children:d.jsx(pn,{})}),d.jsxs(ln,{children:[d.jsx(Ne,{value:"bar",children:"Bar Chart"}),d.jsx(Ne,{value:"pie",children:"Pie Chart"}),d.jsx(Ne,{value:"line",children:"Line Chart"}),d.jsx(Ne,{value:"donut",children:"Donut Chart"}),d.jsx(Ne,{value:"table",children:"Table"}),d.jsx(Ne,{value:"metric",children:"Metric"})]})]})]}),d.jsxs("div",{children:[d.jsx(de,{className:"mb-1 block text-xs font-medium",children:"Step Label"}),d.jsx(yr,{value:e.label||"",onChange:a=>r(t,n,{label:a.target.value}),placeholder:"Custom drill label",className:"h-8"})]}),d.jsxs("div",{children:[d.jsx(de,{className:"mb-1 block text-xs font-medium",children:"Breadcrumb Label Template"}),d.jsx(yr,{value:e.breadcrumbLabelTemplate||"",onChange:a=>r(t,n,{breadcrumbLabelTemplate:a.target.value}),placeholder:"e.g., 'Region: {{value}}'",className:"h-8"})]}),d.jsx("div",{className:"flex items-center gap-4",children:d.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[d.jsx("input",{type:"checkbox",checked:e.retainFilters!==!1,onChange:a=>r(t,n,{retainFilters:a.target.checked}),className:"rounded"}),"Retain filters when drilling"]})}),d.jsx("div",{className:"flex justify-end",children:d.jsx(ae,{size:"sm",variant:"outline",onClick:()=>s(!1),children:"Done"})})]})})]})}function the({field:e,step:t,stepIndex:n,hierarchyId:r,onUpdateStep:o,onRemoveStep:s,isFirstField:i=!1}){const[a,l]=_.useState(!1),{attributes:c,listeners:u,setNodeRef:f,transform:h,transition:p,isDragging:m}=fM({id:`${r}-${e.id}-${n}`,disabled:!1}),g={transform:Ti.Transform.toString(h),transition:p,opacity:m?.8:1,zIndex:m?1e3:1};return d.jsx("div",{ref:f,style:g,className:`relative ${a?"z-[9998]":""}`,...c,children:d.jsx(ehe,{step:t,hierarchyId:r,stepIndex:n,onUpdateStep:o,open:a,onOpenChange:l,trigger:d.jsxs("div",{className:`flex cursor-pointer items-center gap-2 rounded-lg p-2 transition-colors ${i?"bg-muted hover:bg-muted/50":"bg-blue-100 hover:bg-blue-200 dark:bg-blue-900/50 dark:hover:bg-blue-900/70"} ${m?"shadow-lg ring-2 ring-blue-300 dark:ring-blue-600":""}`,...u,onClick:b=>{b.stopPropagation(),l(y=>!y)},children:[d.jsxs("div",{className:"pointer-events-none flex items-center gap-2",children:[d.jsx("span",{className:"whitespace-nowrap text-sm font-medium",children:e.label}),t.preferredChartType&&t.preferredChartType!=="bar"&&d.jsx("span",{className:"whitespace-nowrap rounded bg-purple-100 px-1 py-0.5 text-xs text-purple-700 dark:bg-purple-900/50 dark:text-purple-300",children:t.preferredChartType}),t.linkedInsightId&&d.jsx("span",{className:"whitespace-nowrap rounded bg-green-100 px-1 py-0.5 text-xs text-green-700 dark:bg-green-900/50 dark:text-green-300",children:"📊"})]}),d.jsx("button",{className:`pointer-events-auto ml-1 text-xs hover:text-red-800 dark:hover:text-red-400 ${i?"text-muted-foreground":"text-blue-600 dark:text-blue-400"}`,onClick:b=>{b.stopPropagation(),s(r,n)},children:"×"})]})})})}function nhe(e){return{sensors:sM(Am(zg,{activationConstraint:{distance:5}}),Am(Lg,{coordinateGetter:hM})),handleStepDragEnd:(r,o)=>{const{active:s,over:i}=r;if(!i||s.id===i.id)return;const a=s.id.replace(`${o.id}-`,""),l=i.id.replace(`${o.id}-`,""),c=o.steps.findIndex(f=>f.field.id===a),u=o.steps.findIndex(f=>f.field.id===l);if(c!==-1&&u!==-1&&c!==u){const f=Vg(o.steps,c,u);e(o.id,{steps:f})}}}}function rhe({hierarchy:e,onUpdateStep:t,onRemoveStep:n,onUpdateHierarchy:r}){const{sensors:o}=nhe(r),[s,i]=_.useState(null),a=e.steps.filter(h=>h&&h.field&&h.field.id),c=a.map(h=>h.field).map((h,p)=>`${e.id}-${h.id}-${p}`),u=h=>{const p=h.active.id,m=Number.parseInt(p.split("-").pop()||"0"),g=a[m],b=g==null?void 0:g.field;i(b||null)},f=h=>{i(null);const{active:p,over:m}=h;if(!m||p.id===m.id)return;const g=Number.parseInt(p.id.split("-").pop()||"0"),b=Number.parseInt(m.id.split("-").pop()||"0");if(g!==b&&g<a.length&&b<a.length){const y=[...e.steps],[x]=y.splice(g,1);y.splice(b,0,x),r(e.id,{steps:y})}};return a.length===0?d.jsx("div",{className:"steps-container",onPointerDown:h=>h.stopPropagation(),children:d.jsx("div",{className:"rounded-lg border bg-muted/50 p-2 text-sm text-muted-foreground",children:"No drill steps configured. Add steps to create a drill hierarchy."})}):d.jsx("div",{className:"steps-container",onPointerDown:h=>h.stopPropagation(),children:d.jsxs(uM,{sensors:o,collisionDetection:iM,onDragStart:u,onDragEnd:f,children:[d.jsx(dM,{items:c,strategy:Tue,children:d.jsx("div",{className:"flex flex-wrap items-center gap-2",style:{minHeight:"40px"},children:a.map((h,p)=>{if(!h||!h.field||!h.field.id)return null;const m=[];p>0&&m.push(d.jsx(qs,{className:"pointer-events-none h-4 w-4 text-gray-400"},`arrow-${p}`));const g=p===0,b=p===a.length-1;return m.push(d.jsx(the,{field:h.field,step:h,stepIndex:p,hierarchyId:e.id,onUpdateStep:t,onRemoveStep:n,isFirstField:g,isLastField:b},`field-${h.field.id}-${p}`)),m})})}),typeof window<"u"&&jn.createPortal(d.jsx(x8,{className:"semaphor-scope",style:{zIndex:9999},children:s?d.jsx("div",{className:"flex items-center gap-2 rounded-lg border-2 border-blue-300 bg-blue-200 p-2 shadow-lg dark:border-blue-600 dark:bg-blue-900/70",children:d.jsx("span",{className:"whitespace-nowrap text-sm font-medium",children:s.label})}):null}),document.body)]})})}var XT=1,ohe=.9,she=.8,ihe=.17,FS=.1,$S=.999,ahe=.9999,lhe=.99,che=/[\\\/_+.#"@\[\(\{&]/,uhe=/[\\\/_+.#"@\[\(\{&]/g,dhe=/[\s-]/,Zz=/[\s-]/g;function VE(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?XT:lhe;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),u=0,f,h,p,m;c>=0;)f=VE(e,t,n,r,c+1,s+1,i),f>u&&(c===o?f*=XT:che.test(e.charAt(c-1))?(f*=she,p=e.slice(o,c-1).match(uhe),p&&o>0&&(f*=Math.pow($S,p.length))):dhe.test(e.charAt(c-1))?(f*=ohe,m=e.slice(o,c-1).match(Zz),m&&o>0&&(f*=Math.pow($S,m.length))):(f*=ihe,o>0&&(f*=Math.pow($S,c-o))),e.charAt(c)!==t.charAt(s)&&(f*=ahe)),(f<FS&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(h=VE(e,t,n,r,c+1,s+2,i),h*FS>f&&(f=h*FS)),f>u&&(u=f),c=n.indexOf(l,c+1);return i[a]=u,u}function QT(e){return e.toLowerCase().replace(Zz," ")}function fhe(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,VE(e,t,QT(e),QT(t),0,0,{})}var Kh='[cmdk-group=""]',LS='[cmdk-group-items=""]',hhe='[cmdk-group-heading=""]',Kz='[cmdk-item=""]',JT=`${Kz}:not([aria-disabled="true"])`,HE="cmdk-item-select",Nd="data-value",phe=(e,t,n)=>fhe(e,t,n),Xz=C.createContext(void 0),Zg=()=>C.useContext(Xz),Qz=C.createContext(void 0),TM=()=>C.useContext(Qz),Jz=C.createContext(void 0),e9=C.forwardRef((e,t)=>{let n=Md(()=>{var B,P;return{search:"",value:(P=(B=e.value)!=null?B:e.defaultValue)!=null?P:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Md(()=>new Set),o=Md(()=>new Map),s=Md(()=>new Map),i=Md(()=>new Set),a=t9(e),{label:l,children:c,value:u,onValueChange:f,filter:h,shouldFilter:p,loop:m,disablePointerSelection:g=!1,vimBindings:b=!0,...y}=e,x=Wn(),v=Wn(),w=Wn(),S=C.useRef(null),k=_he();Eu(()=>{if(u!==void 0){let B=u.trim();n.current.value=B,E.emit()}},[u]),Eu(()=>{k(6,A)},[]);let E=C.useMemo(()=>({subscribe:B=>(i.current.add(B),()=>i.current.delete(B)),snapshot:()=>n.current,setState:(B,P,W)=>{var Y,X,U,z;if(!Object.is(n.current[B],P)){if(n.current[B]=P,B==="search")D(),M(),k(1,T);else if(B==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let G=document.getElementById(w);G?G.focus():(Y=document.getElementById(x))==null||Y.focus()}if(k(7,()=>{var G;n.current.selectedItemId=(G=O())==null?void 0:G.id,E.emit()}),W||k(5,A),((X=a.current)==null?void 0:X.value)!==void 0){let G=P??"";(z=(U=a.current).onValueChange)==null||z.call(U,G);return}}E.emit()}},emit:()=>{i.current.forEach(B=>B())}}),[]),N=C.useMemo(()=>({value:(B,P,W)=>{var Y;P!==((Y=s.current.get(B))==null?void 0:Y.value)&&(s.current.set(B,{value:P,keywords:W}),n.current.filtered.items.set(B,R(P,W)),k(2,()=>{M(),E.emit()}))},item:(B,P)=>(r.current.add(B),P&&(o.current.has(P)?o.current.get(P).add(B):o.current.set(P,new Set([B]))),k(3,()=>{D(),M(),n.current.value||T(),E.emit()}),()=>{s.current.delete(B),r.current.delete(B),n.current.filtered.items.delete(B);let W=O();k(4,()=>{D(),(W==null?void 0:W.getAttribute("id"))===B&&T(),E.emit()})}),group:B=>(o.current.has(B)||o.current.set(B,new Set),()=>{s.current.delete(B),o.current.delete(B)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:x,inputId:w,labelId:v,listInnerRef:S}),[]);function R(B,P){var W,Y;let X=(Y=(W=a.current)==null?void 0:W.filter)!=null?Y:phe;return B?X(B,n.current.search,P):0}function M(){if(!n.current.search||a.current.shouldFilter===!1)return;let B=n.current.filtered.items,P=[];n.current.filtered.groups.forEach(Y=>{let X=o.current.get(Y),U=0;X.forEach(z=>{let G=B.get(z);U=Math.max(G,U)}),P.push([Y,U])});let W=S.current;j().sort((Y,X)=>{var U,z;let G=Y.getAttribute("id"),J=X.getAttribute("id");return((U=B.get(J))!=null?U:0)-((z=B.get(G))!=null?z:0)}).forEach(Y=>{let X=Y.closest(LS);X?X.appendChild(Y.parentElement===X?Y:Y.closest(`${LS} > *`)):W.appendChild(Y.parentElement===W?Y:Y.closest(`${LS} > *`))}),P.sort((Y,X)=>X[1]-Y[1]).forEach(Y=>{var X;let U=(X=S.current)==null?void 0:X.querySelector(`${Kh}[${Nd}="${encodeURIComponent(Y[0])}"]`);U==null||U.parentElement.appendChild(U)})}function T(){let B=j().find(W=>W.getAttribute("aria-disabled")!=="true"),P=B==null?void 0:B.getAttribute(Nd);E.setState("value",P||void 0)}function D(){var B,P,W,Y;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let X=0;for(let U of r.current){let z=(P=(B=s.current.get(U))==null?void 0:B.value)!=null?P:"",G=(Y=(W=s.current.get(U))==null?void 0:W.keywords)!=null?Y:[],J=R(z,G);n.current.filtered.items.set(U,J),J>0&&X++}for(let[U,z]of o.current)for(let G of z)if(n.current.filtered.items.get(G)>0){n.current.filtered.groups.add(U);break}n.current.filtered.count=X}function A(){var B,P,W;let Y=O();Y&&(((B=Y.parentElement)==null?void 0:B.firstChild)===Y&&((W=(P=Y.closest(Kh))==null?void 0:P.querySelector(hhe))==null||W.scrollIntoView({block:"nearest"})),Y.scrollIntoView({block:"nearest"}))}function O(){var B;return(B=S.current)==null?void 0:B.querySelector(`${Kz}[aria-selected="true"]`)}function j(){var B;return Array.from(((B=S.current)==null?void 0:B.querySelectorAll(JT))||[])}function F(B){let P=j()[B];P&&E.setState("value",P.getAttribute(Nd))}function L(B){var P;let W=O(),Y=j(),X=Y.findIndex(z=>z===W),U=Y[X+B];(P=a.current)!=null&&P.loop&&(U=X+B<0?Y[Y.length-1]:X+B===Y.length?Y[0]:Y[X+B]),U&&E.setState("value",U.getAttribute(Nd))}function V(B){let P=O(),W=P==null?void 0:P.closest(Kh),Y;for(;W&&!Y;)W=B>0?Che(W,Kh):Ehe(W,Kh),Y=W==null?void 0:W.querySelector(JT);Y?E.setState("value",Y.getAttribute(Nd)):L(B)}let $=()=>F(j().length-1),I=B=>{B.preventDefault(),B.metaKey?$():B.altKey?V(1):L(1)},H=B=>{B.preventDefault(),B.metaKey?F(0):B.altKey?V(-1):L(-1)};return C.createElement(Pe.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:B=>{var P;(P=y.onKeyDown)==null||P.call(y,B);let W=B.nativeEvent.isComposing||B.keyCode===229;if(!(B.defaultPrevented||W))switch(B.key){case"n":case"j":{b&&B.ctrlKey&&I(B);break}case"ArrowDown":{I(B);break}case"p":case"k":{b&&B.ctrlKey&&H(B);break}case"ArrowUp":{H(B);break}case"Home":{B.preventDefault(),F(0);break}case"End":{B.preventDefault(),$();break}case"Enter":{B.preventDefault();let Y=O();if(Y){let X=new Event(HE);Y.dispatchEvent(X)}}}}},C.createElement("label",{"cmdk-label":"",htmlFor:N.inputId,id:N.labelId,style:Nhe},l),yw(e,B=>C.createElement(Qz.Provider,{value:E},C.createElement(Xz.Provider,{value:N},B))))}),mhe=C.forwardRef((e,t)=>{var n,r;let o=Wn(),s=C.useRef(null),i=C.useContext(Jz),a=Zg(),l=t9(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;Eu(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let u=n9(o,s,[e.value,e.children,s],e.keywords),f=TM(),h=Il(k=>k.value&&k.value===u.current),p=Il(k=>c||a.filter()===!1?!0:k.search?k.filtered.items.get(o)>0:!0);C.useEffect(()=>{let k=s.current;if(!(!k||e.disabled))return k.addEventListener(HE,m),()=>k.removeEventListener(HE,m)},[p,e.onSelect,e.disabled]);function m(){var k,E;g(),(E=(k=l.current).onSelect)==null||E.call(k,u.current)}function g(){f.setState("value",u.current,!0)}if(!p)return null;let{disabled:b,value:y,onSelect:x,forceMount:v,keywords:w,...S}=e;return C.createElement(Pe.div,{ref:so(s,t),...S,id:o,"cmdk-item":"",role:"option","aria-disabled":!!b,"aria-selected":!!h,"data-disabled":!!b,"data-selected":!!h,onPointerMove:b||a.getDisablePointerSelection()?void 0:g,onClick:b?void 0:m},e.children)}),ghe=C.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Wn(),a=C.useRef(null),l=C.useRef(null),c=Wn(),u=Zg(),f=Il(p=>o||u.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);Eu(()=>u.group(i),[]),n9(i,a,[e.value,e.heading,l]);let h=C.useMemo(()=>({id:i,forceMount:o}),[o]);return C.createElement(Pe.div,{ref:so(a,t),...s,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&C.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),yw(e,p=>C.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},C.createElement(Jz.Provider,{value:h},p))))}),bhe=C.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=C.useRef(null),s=Il(i=>!i.search);return!n&&!s?null:C.createElement(Pe.div,{ref:so(o,t),...r,"cmdk-separator":"",role:"separator"})}),yhe=C.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=TM(),i=Il(c=>c.search),a=Il(c=>c.selectedItemId),l=Zg();return C.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),C.createElement(Pe.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),xhe=C.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=C.useRef(null),i=C.useRef(null),a=Il(c=>c.selectedItemId),l=Zg();return C.useEffect(()=>{if(i.current&&s.current){let c=i.current,u=s.current,f,h=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=c.offsetHeight;u.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return h.observe(c),()=>{cancelAnimationFrame(f),h.unobserve(c)}}},[]),C.createElement(Pe.div,{ref:so(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},yw(e,c=>C.createElement("div",{ref:so(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),vhe=C.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return C.createElement(vL,{open:n,onOpenChange:r},C.createElement(wL,{container:i},C.createElement(yN,{"cmdk-overlay":"",className:o}),C.createElement(xN,{"aria-label":e.label,"cmdk-dialog":"",className:s},C.createElement(e9,{ref:t,...a}))))}),whe=C.forwardRef((e,t)=>Il(n=>n.filtered.count===0)?C.createElement(Pe.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),She=C.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return C.createElement(Pe.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},yw(e,i=>C.createElement("div",{"aria-hidden":!0},i)))}),Ro=Object.assign(e9,{List:xhe,Item:mhe,Input:yhe,Group:ghe,Separator:bhe,Dialog:vhe,Empty:whe,Loading:She});function Che(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Ehe(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function t9(e){let t=C.useRef(e);return Eu(()=>{t.current=e}),t}var Eu=typeof window>"u"?C.useEffect:C.useLayoutEffect;function Md(e){let t=C.useRef();return t.current===void 0&&(t.current=e()),t}function Il(e){let t=TM(),n=()=>e(t.snapshot());return C.useSyncExternalStore(t.subscribe,n,n)}function n9(e,t,n,r=[]){let o=C.useRef(),s=Zg();return Eu(()=>{var i;let a=(()=>{var c;for(let u of n){if(typeof u=="string")return u.trim();if(typeof u=="object"&&"current"in u)return u.current?(c=u.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Nd,a),o.current=a}),o}var _he=()=>{let[e,t]=C.useState(),n=Md(()=>new Map);return Eu(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function khe(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function yw({asChild:e,children:t},n){return e&&C.isValidElement(t)?C.cloneElement(khe(t),{ref:t.ref},n(t.props.children)):n(t)}var Nhe={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const xw=C.forwardRef(({className:e,...t},n)=>d.jsx(Ro,{ref:n,className:K("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));xw.displayName=Ro.displayName;const vw=C.forwardRef(({className:e,...t},n)=>d.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[d.jsx(dN,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),d.jsx(Ro.Input,{ref:n,className:K("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));vw.displayName=Ro.Input.displayName;const ww=C.forwardRef(({className:e,...t},n)=>d.jsx(Ro.List,{ref:n,className:K("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));ww.displayName=Ro.List.displayName;const Sw=C.forwardRef((e,t)=>d.jsx(Ro.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Sw.displayName=Ro.Empty.displayName;const Cw=C.forwardRef(({className:e,...t},n)=>d.jsx(Ro.Group,{ref:n,className:K("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Cw.displayName=Ro.Group.displayName;const Mhe=C.forwardRef(({className:e,...t},n)=>d.jsx(Ro.Separator,{ref:n,className:K("-mx-1 h-px bg-border",e),...t}));Mhe.displayName=Ro.Separator.displayName;const Ew=C.forwardRef(({className:e,...t},n)=>d.jsx(Ro.Item,{ref:n,className:K("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50",e),...t}));Ew.displayName=Ro.Item.displayName;function jhe({fields:e,value:t,onValueChange:n,placeholder:r="Select field...",className:o,disabled:s=!1,excludeFieldIds:i=[]}){const[a,l]=_.useState(!1),c=e.filter(f=>!i.includes(f.id)),u=c.find(f=>f.id===t);return d.jsxs(Zo,{open:a,onOpenChange:l,children:[d.jsx(Ko,{asChild:!0,children:d.jsxs(ae,{variant:"outline",role:"combobox","aria-expanded":a,className:K("justify-between",o),disabled:s,children:[u?u.label:r,d.jsx(w3,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),d.jsx(_o,{className:"z-50 w-[200px] p-0",children:d.jsxs(xw,{children:[d.jsx(vw,{placeholder:"Search fields..."}),d.jsxs(ww,{children:[d.jsx(Sw,{children:"No field found."}),d.jsx(Cw,{children:c.map(f=>d.jsxs(Ew,{value:f.label,onSelect:()=>{n(f.id),l(!1)},children:[d.jsx(_r,{className:K("mr-2 h-4 w-4",t===f.id?"opacity-100":"opacity-0")}),f.label]},f.id))})]})]})})]})}function Rhe({hierarchy:e,editingHierarchy:t,sampleFieldReferences:n,onSetEditingHierarchy:r,onUpdateHierarchy:o,onDeleteHierarchy:s,onSetDefaultHierarchy:i,onUpdateStep:a,onRemoveStep:l,onAddStep:c}){const u=t===e.id,{attributes:f,listeners:h,setNodeRef:p,transform:m,transition:g}=fM({id:e.id,disabled:u}),b={transform:Ti.Transform.toString(m),transition:g},y=e.steps.filter(x=>x.field).map(x=>x.field.id);return d.jsxs("div",{ref:p,style:b,className:"hierarchy-container relative rounded-lg border bg-background p-3 transition-shadow hover:shadow-md",children:[d.jsxs("div",{className:`mb-3 flex items-center justify-between ${u?"":"cursor-move"}`,...u?{}:f,...u?{}:h,children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(que,{value:e.label||"",isEditing:u,onEdit:()=>{r(e.id)},onSave:x=>{o(e.id,{label:x}),r(null)},onCancel:()=>r(null),placeholder:"Hierarchy Name",displayClassName:"font-medium",inputClassName:"font-medium"}),d.jsxs("span",{className:"rounded bg-muted px-2 py-1 text-xs",children:[e.steps.length," steps"]}),e.default?d.jsx("span",{className:"cursor-pointer rounded bg-blue-100 px-2 py-1 text-xs text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",onClick:x=>{x.stopPropagation(),i("")},onPointerDown:x=>x.stopPropagation(),title:"Click to remove default",children:"Default ✓"}):d.jsx("button",{className:"rounded bg-muted px-2 py-1 text-xs transition-colors hover:bg-blue-100 dark:hover:bg-blue-900/50",onClick:x=>{x.stopPropagation(),i(e.id)},onPointerDown:x=>x.stopPropagation(),title:"Set as default hierarchy",children:"Set Default"})]}),d.jsx("div",{className:"flex items-center gap-1",children:d.jsx(ae,{size:"sm",variant:"ghost",onClick:x=>{x.stopPropagation(),s(e.id)},onPointerDown:x=>x.stopPropagation(),children:d.jsx(Bu,{className:"h-3 w-3"})})})]}),d.jsx(rhe,{hierarchy:e,onUpdateStep:a,onRemoveStep:l,onUpdateHierarchy:o}),d.jsx("div",{className:"mt-3 border-t pt-3","data-hierarchy-editing":!0,children:d.jsx("div",{className:"flex items-center gap-2",children:d.jsx(jhe,{fields:n,excludeFieldIds:y,onValueChange:x=>c(e.id,x),placeholder:"Add drill step...",className:"w-48"})})})]})}function Dhe({configuringIntent:e,setConfiguringIntent:t,drillHierarchies:n,onUpdateHierarchies:r,availableFields:o}){const s=sM(Am(zg),Am(Lg,{coordinateGetter:hM})),{editingHierarchy:i,setEditingHierarchy:a,createNewHierarchy:l,deleteHierarchy:c,updateHierarchy:u,addStepToHierarchy:f,removeStepFromHierarchy:h,updateStep:p,setDefaultHierarchy:m}=Uue(n,r,o),g=b=>{const{active:y,over:x}=b;if(y.id!==(x==null?void 0:x.id)){const v=n.findIndex(S=>S.id===y.id),w=n.findIndex(S=>S.id===(x==null?void 0:x.id));r(Vg(n,v,w))}};return d.jsx("div",{className:"rounded-lg border p-4 hover:bg-muted/50",children:d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-blue-100",children:d.jsx(Dg,{className:"h-5 w-5 text-blue-600 dark:text-blue-400"})}),d.jsxs("div",{className:"flex-1",children:[d.jsx("h4",{className:"mb-1 font-medium",children:"Let users drill deeper into specific paths"}),d.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Set up predefined drill paths like regions → cities, categories → products"}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(ae,{size:"sm",variant:"outline",onClick:()=>t(e==="drillDown"?null:"drillDown"),children:e==="drillDown"?"Done":"Set up drill paths"}),d.jsxs("span",{className:"text-xs text-muted-foreground",children:[n.length," hierarchies configured"]})]}),e==="drillDown"&&d.jsxs("div",{className:"mt-4 space-y-3 rounded-lg border border-blue-100 bg-blue-200/50 p-4 dark:border-blue-900 dark:bg-blue-900/50",children:[d.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[d.jsxs("div",{children:[d.jsx("h5",{className:"font-medium",children:"Drill Hierarchies"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Create multiple drill paths for different analysis scenarios"})]}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(ae,{size:"sm",onClick:l,children:[d.jsx(Ri,{className:"mr-1 h-4 w-4"}),"Add Hierarchy"]})})]}),d.jsx(uM,{sensors:s,collisionDetection:iM,onDragEnd:g,children:d.jsx(dM,{items:n.map(b=>b.id),strategy:w8,children:d.jsx("div",{className:"mb-6 space-y-4",children:n.map(b=>d.jsx(Rhe,{hierarchy:b,editingHierarchy:i,sampleFieldReferences:o,onSetEditingHierarchy:a,onUpdateHierarchy:u,onDeleteHierarchy:c,onSetDefaultHierarchy:m,onUpdateStep:p,onRemoveStep:h,onAddStep:f},b.id))})})})]})]})]})})}var AM="Checkbox",[Phe,tKe]=hr(AM),[The,Ahe]=Phe(AM),r9=C.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:u,...f}=e,[h,p]=C.useState(null),m=Je(t,w=>p(w)),g=C.useRef(!1),b=h?u||!!h.closest("form"):!0,[y=!1,x]=jr({prop:o,defaultProp:s,onChange:c}),v=C.useRef(y);return C.useEffect(()=>{const w=h==null?void 0:h.form;if(w){const S=()=>x(v.current);return w.addEventListener("reset",S),()=>w.removeEventListener("reset",S)}},[h,x]),d.jsxs(The,{scope:n,state:y,disabled:a,children:[d.jsx(Pe.button,{type:"button",role:"checkbox","aria-checked":Rl(y)?"mixed":y,"aria-required":i,"data-state":i9(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:m,onKeyDown:xe(e.onKeyDown,w=>{w.key==="Enter"&&w.preventDefault()}),onClick:xe(e.onClick,w=>{x(S=>Rl(S)?!0:!S),b&&(g.current=w.isPropagationStopped(),g.current||w.stopPropagation())})}),b&&d.jsx(Ihe,{control:h,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:u,style:{transform:"translateX(-100%)"},defaultChecked:Rl(s)?!1:s})]})});r9.displayName=AM;var o9="CheckboxIndicator",s9=C.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,s=Ahe(o9,n);return d.jsx(Un,{present:r||Rl(s.state)||s.state===!0,children:d.jsx(Pe.span,{"data-state":i9(s.state),"data-disabled":s.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});s9.displayName=o9;var Ihe=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:o,...s}=e,i=C.useRef(null),a=pw(n),l=fw(t);C.useEffect(()=>{const u=i.current,f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(a!==n&&p){const m=new Event("click",{bubbles:r});u.indeterminate=Rl(n),p.call(u,Rl(n)?!1:n),u.dispatchEvent(m)}},[a,n,r]);const c=C.useRef(Rl(n)?!1:n);return d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??c.current,...s,tabIndex:-1,ref:i,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function Rl(e){return e==="indeterminate"}function i9(e){return Rl(e)?"indeterminate":e?"checked":"unchecked"}var a9=r9,Ohe=s9;const No=C.forwardRef(({className:e,...t},n)=>d.jsx(a9,{ref:n,className:K("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:d.jsx(Ohe,{className:K("flex items-center justify-center text-current"),children:d.jsx(_r,{className:"h-4 w-4"})})}));No.displayName=a9.displayName;function Fhe({fields:e,selectedFieldIds:t,onSelectionChange:n,searchPlaceholder:r="Search fields...",className:o=""}){const[s,i]=_.useState(""),a=e.filter(u=>u.label.toLowerCase().includes(s.toLowerCase())||u.qualifiedEntityName&&u.qualifiedEntityName.toLowerCase().includes(s.toLowerCase())),l=()=>{const u=[...new Set([...t,...a.map(f=>f.id)])];n(u)},c=()=>{const u=a.map(f=>f.id);n(t.filter(f=>!u.includes(f)))};return d.jsxs("div",{className:`space-y-2 ${o}`,children:[d.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[d.jsx(yr,{placeholder:r,value:s,onChange:u=>i(u.target.value),className:"flex-1"}),d.jsxs("span",{className:"text-xs text-muted-foreground",children:[a.length," fields"]})]}),d.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[d.jsx(ae,{size:"sm",variant:"outline",onClick:l,children:"Select All"}),d.jsx(ae,{size:"sm",variant:"outline",onClick:c,children:"Deselect All"}),d.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.length," selected"]})]}),d.jsx("div",{className:"grid max-h-32 grid-cols-2 gap-2 overflow-y-auto rounded border p-2",children:a.map(u=>d.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded border p-2 text-xs hover:bg-muted/50",children:[d.jsx(No,{checked:t.includes(u.id),onCheckedChange:f=>{n(f?[...t,u.id]:t.filter(h=>h!==u.id))}}),d.jsx("span",{className:"font-medium",children:u.label})]},u.id))}),s&&a.length===0&&d.jsxs("div",{className:"py-4 text-center text-sm text-muted-foreground",children:['No fields found matching "',s,'"']})]})}const $he=e=>["string","boolean"].includes(Dv(e.dataType));function Lhe({configuringIntent:e,setConfiguringIntent:t,selectedDrillTargets:n,setSelectedDrillTargets:r,availableFields:o}){const s=o.filter($he),i=n.map(l=>l.id),a=l=>{const c=s.filter(u=>l.includes(u.id));r(c)};return d.jsx("div",{className:"rounded-lg border p-4 hover:bg-muted/50",children:d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-green-100",children:d.jsx(D3,{className:"h-5 w-5 text-green-600 dark:text-green-400"})}),d.jsxs("div",{className:"flex-1",children:[d.jsx("h4",{className:"mb-1 font-medium",children:"Give users freedom to explore any dimension"}),d.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Let users dynamically drill into any available field they choose"}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(ae,{size:"sm",variant:"outline",onClick:()=>t(e==="dynamicDrill"?null:"dynamicDrill"),children:e==="dynamicDrill"?"Done":"Configure available fields"}),d.jsx("span",{className:"text-xs text-muted-foreground",children:n.length>0?`${n.length} fields selected`:"All fields available"})]}),e==="dynamicDrill"&&d.jsxs("div",{className:"mt-4 space-y-3 rounded-lg border border-green-100 bg-green-200/50 p-4 dark:border-green-900 dark:bg-green-900/50",children:[d.jsx("h5",{className:"mb-3 font-medium",children:"Configure Dynamic Drilling"}),d.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Choose which fields users can explore dynamically:"}),d.jsx("div",{className:"border-l-2 border-green-200 pl-4",children:d.jsx(Fhe,{fields:s,selectedFieldIds:i,onSelectionChange:a,searchPlaceholder:"Search fields..."})})]})]})]})]})})}var IM="Switch",[zhe,nKe]=hr(IM),[Bhe,Vhe]=zhe(IM),l9=C.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:u,...f}=e,[h,p]=C.useState(null),m=Je(t,v=>p(v)),g=C.useRef(!1),b=h?u||!!h.closest("form"):!0,[y=!1,x]=jr({prop:o,defaultProp:s,onChange:c});return d.jsxs(Bhe,{scope:n,checked:y,disabled:a,children:[d.jsx(Pe.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":d9(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:m,onClick:xe(e.onClick,v=>{x(w=>!w),b&&(g.current=v.isPropagationStopped(),g.current||v.stopPropagation())})}),b&&d.jsx(Hhe,{control:h,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:u,style:{transform:"translateX(-100%)"}})]})});l9.displayName=IM;var c9="SwitchThumb",u9=C.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=Vhe(c9,n);return d.jsx(Pe.span,{"data-state":d9(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});u9.displayName=c9;var Hhe=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,s=C.useRef(null),i=pw(n),a=fw(t);return C.useEffect(()=>{const l=s.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(i!==n&&f){const h=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(h)}},[i,n,r]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:s,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function d9(e){return e?"checked":"unchecked"}var _w=l9,f9=u9;const OM=C.forwardRef(({className:e,...t},n)=>d.jsx(_w,{className:K("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:d.jsx(f9,{className:K("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));OM.displayName=_w.displayName;var FM="Radio",[Whe,h9]=hr(FM),[Uhe,qhe]=Whe(FM),p9=C.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:o=!1,required:s,disabled:i,value:a="on",onCheck:l,form:c,...u}=e,[f,h]=C.useState(null),p=Je(t,b=>h(b)),m=C.useRef(!1),g=f?c||!!f.closest("form"):!0;return d.jsxs(Uhe,{scope:n,checked:o,disabled:i,children:[d.jsx(Pe.button,{type:"button",role:"radio","aria-checked":o,"data-state":b9(o),"data-disabled":i?"":void 0,disabled:i,value:a,...u,ref:p,onClick:xe(e.onClick,b=>{o||l==null||l(),g&&(m.current=b.isPropagationStopped(),m.current||b.stopPropagation())})}),g&&d.jsx(Ghe,{control:f,bubbles:!m.current,name:r,value:a,checked:o,required:s,disabled:i,form:c,style:{transform:"translateX(-100%)"}})]})});p9.displayName=FM;var m9="RadioIndicator",g9=C.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...o}=e,s=qhe(m9,n);return d.jsx(Un,{present:r||s.checked,children:d.jsx(Pe.span,{"data-state":b9(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t})})});g9.displayName=m9;var Ghe=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,s=C.useRef(null),i=pw(n),a=fw(t);return C.useEffect(()=>{const l=s.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(i!==n&&f){const h=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(h)}},[i,n,r]),d.jsx("input",{type:"radio","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:s,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function b9(e){return e?"checked":"unchecked"}var Yhe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],$M="RadioGroup",[Zhe,rKe]=hr($M,[gh,h9]),y9=gh(),x9=h9(),[Khe,Xhe]=Zhe($M),v9=C.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:o,value:s,required:i=!1,disabled:a=!1,orientation:l,dir:c,loop:u=!0,onValueChange:f,...h}=e,p=y9(n),m=Wu(c),[g,b]=jr({prop:s,defaultProp:o,onChange:f});return d.jsx(Khe,{scope:n,name:r,required:i,disabled:a,value:g,onValueChange:b,children:d.jsx(NN,{asChild:!0,...p,orientation:l,dir:m,loop:u,children:d.jsx(Pe.div,{role:"radiogroup","aria-required":i,"aria-orientation":l,"data-disabled":a?"":void 0,dir:m,...h,ref:t})})})});v9.displayName=$M;var w9="RadioGroupItem",S9=C.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...o}=e,s=Xhe(w9,n),i=s.disabled||r,a=y9(n),l=x9(n),c=C.useRef(null),u=Je(t,c),f=s.value===o.value,h=C.useRef(!1);return C.useEffect(()=>{const p=g=>{Yhe.includes(g.key)&&(h.current=!0)},m=()=>h.current=!1;return document.addEventListener("keydown",p),document.addEventListener("keyup",m),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",m)}},[]),d.jsx(MN,{asChild:!0,...a,focusable:!i,active:f,children:d.jsx(p9,{disabled:i,required:s.required,checked:f,...l,...o,name:s.name,ref:u,onCheck:()=>s.onValueChange(o.value),onKeyDown:xe(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:xe(o.onFocus,()=>{var p;h.current&&((p=c.current)==null||p.click())})})})});S9.displayName=w9;var Qhe="RadioGroupIndicator",C9=C.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,o=x9(n);return d.jsx(g9,{...o,...r,ref:t})});C9.displayName=Qhe;var E9=v9,_9=S9,Jhe=C9;const Bs=C.forwardRef(({className:e,...t},n)=>d.jsx(E9,{className:K("grid gap-2",e),...t,ref:n}));Bs.displayName=E9.displayName;const Yn=C.forwardRef(({className:e,...t},n)=>d.jsx(_9,{ref:n,className:K("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(Jhe,{className:"flex items-center justify-center",children:d.jsx(rN,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Yn.displayName=_9.displayName;function epe({configuringIntent:e,setConfiguringIntent:t,incomingFilterFields:n,onUpdateClickFilterInteractions:r,currentClickFilterInteractions:o}){const[s,i]=_.useState(o.length>0),[a,l]=_.useState(o[0]||{filterFields:[],highlightSelf:!0}),[c,u]=_.useState(""),f=j$(),h=e==="clickFilter",p=()=>{const k=!s;if(i(k),k){const E={filterFields:n,highlightSelf:!0,mode:"clickFilter"};l(E),r([E])}else r([])},m=()=>{t("clickFilter")},g=()=>{t(null)},b=k=>{const E={...a,...k};l(E),r([E])},y=()=>a.applyToCardIds!==void 0?"specific-cards":a.excludeCardIds!==void 0?"all-except-specific":"all-cards",x=k=>{const E={};switch(k){case"all-cards":E.applyToCardIds=void 0,E.excludeCardIds=void 0;break;case"specific-cards":E.applyToCardIds=[],E.excludeCardIds=void 0;break;case"all-except-specific":E.applyToCardIds=void 0,E.excludeCardIds=[];break}b(E)},v=(k,E)=>{if(E==="specific-cards"){const N=a.applyToCardIds||[],R=N.includes(k)?N.filter(M=>M!==k):[...N,k];b({applyToCardIds:R})}else if(E==="all-except-specific"){const N=a.excludeCardIds||[],R=N.includes(k)?N.filter(M=>M!==k):[...N,k];b({excludeCardIds:R})}},w=_.useMemo(()=>{if(!c.trim())return f;const k=c.toLowerCase();return f==null?void 0:f.filter(E=>{var N;return(N=E==null?void 0:E.title)==null?void 0:N.toLowerCase().includes(k)})},[c,f]),S=()=>{var E,N;if(!s)return"0 settings configured";const k=y();if(k==="all-cards")return"filtering all cards";if(k==="specific-cards"){const R=((E=a.applyToCardIds)==null?void 0:E.length)||0;return R===0?"no cards selected":`filtering ${R} card${R!==1?"s":""}`}else if(k==="all-except-specific"){const R=((N=a.excludeCardIds)==null?void 0:N.length)||0;return R===0?"filtering all cards":`excluding ${R} card${R!==1?"s":""}`}return"0 settings configured"};return d.jsx("div",{className:"rounded-lg border p-4 hover:bg-muted/50",children:d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-green-100",children:d.jsx("svg",{className:"h-5 w-5 text-green-600 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"})})}),d.jsxs("div",{className:"flex-1",children:[d.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[d.jsx("h4",{className:"font-medium",children:"Enable click filters"}),d.jsx(OM,{checked:s,onCheckedChange:p})]}),d.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Apply filters to other cards when users click on chart elements"}),s&&d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(ae,{size:"sm",variant:"outline",onClick:h?g:m,children:h?"Done":"Configure"}),d.jsx("span",{className:"text-xs text-muted-foreground",children:S()})]}),h&&s&&d.jsxs("div",{className:"mt-4 space-y-3 rounded-lg border border-green-100 bg-green-200/50 p-4 dark:border-green-900 dark:bg-green-900/50",children:[d.jsx("h5",{className:"mb-3 font-medium",children:"Configure Click Filters"}),d.jsx("div",{className:"space-y-6",children:d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"space-y-0.5",children:[d.jsx(de,{className:"text-sm font-medium",children:"Filter scope"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose which cards should receive the filter"})]}),d.jsxs(Bs,{value:y(),onValueChange:k=>x(k),className:"space-y-3",children:[d.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[d.jsx(Yn,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),d.jsxs("div",{className:"flex-1 space-y-1",children:[d.jsx(de,{htmlFor:"all-cards",className:"cursor-pointer text-sm font-medium",children:"All cards"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards in the dashboard"})]})]}),d.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[d.jsx(Yn,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),d.jsxs("div",{className:"flex-1 space-y-1",children:[d.jsx(de,{htmlFor:"specific-cards",className:"cursor-pointer text-sm font-medium",children:"Only specific cards"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to selected cards only"})]})]}),y()==="specific-cards"&&d.jsxs("div",{className:"ml-7 space-y-2",children:[d.jsxs("div",{className:"space-y-0.5",children:[d.jsx(de,{className:"text-sm font-medium",children:"Cards to filter"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should receive the filter"})]}),d.jsx(yr,{placeholder:"Search cards...",value:c,onChange:k=>u(k.target.value),className:"mb-2"}),d.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:w.length>0?w.map(k=>{const E=(a.applyToCardIds||[]).includes(k.id);return d.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[d.jsx(No,{id:`card-${k.id}`,checked:E,onCheckedChange:()=>v(k.id,"specific-cards")}),d.jsxs("div",{className:"flex-1",children:[d.jsx(de,{htmlFor:`card-${k.id}`,className:"cursor-pointer text-sm font-medium",children:k.title}),k.description&&d.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:k.description})]})]},k.id)}):d.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',c,'"']})})]}),d.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[d.jsx(Yn,{value:"all-except-specific",id:"all-except-specific",className:"mt-0.5"}),d.jsxs("div",{className:"flex-1 space-y-1",children:[d.jsx(de,{htmlFor:"all-except-specific",className:"cursor-pointer text-sm font-medium",children:"All cards except specific ones"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards, excluding selected ones"})]})]}),y()==="all-except-specific"&&d.jsxs("div",{className:"ml-7 space-y-2",children:[d.jsxs("div",{className:"space-y-0.5",children:[d.jsx(de,{className:"text-sm font-medium",children:"Cards to exclude"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should be excluded from filtering"})]}),d.jsx(yr,{placeholder:"Search cards...",value:c,onChange:k=>u(k.target.value),className:"mb-2"}),d.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:w.length>0?w.map(k=>{const E=(a.excludeCardIds||[]).includes(k.id);return d.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[d.jsx(No,{id:`card-exclude-${k.id}`,checked:E,onCheckedChange:()=>v(k.id,"all-except-specific")}),d.jsxs("div",{className:"flex-1",children:[d.jsx(de,{htmlFor:`card-exclude-${k.id}`,className:"cursor-pointer text-sm font-medium",children:k.title}),k.description&&d.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:k.description})]})]},k.id)}):d.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',c,'"']})})]})]})]})})]})]})]})})}function tpe({isOpen:e,onClose:t}){var j,F,L,V;const n=mse(),r=gse(),{updateCurrentDashboardCard:o}=mn(),{columns:s}=PL(),{groupByFields:i,pivotByFields:a}=R$(),l=[...i,...a],c=s,u=((j=n.interactionConfig)==null?void 0:j.drillHierarchies)||[],f=((F=n.interactionConfig)==null?void 0:F.allowedDrillTargets)||[],h=_.useMemo(()=>{var $;return(($=n.interactionConfig)==null?void 0:$.clickFilterInteractions)||[]},[(L=n.interactionConfig)==null?void 0:L.clickFilterInteractions]),p=_.useMemo(()=>{var $;return(($=n.interactionConfig)==null?void 0:$.drillInteractions)||[]},[(V=n.interactionConfig)==null?void 0:V.drillInteractions]),[m,g]=_.useState(u),[b,y]=_.useState(f||[]),[x,v]=_.useState(null),[w,S]=_.useState(()=>p.filter($=>$.mode==="drillToURL")),[k,E]=_.useState(()=>p.filter($=>$.mode==="drillThrough")),[N,R]=_.useState(()=>p.filter($=>$.mode==="drillToDetail")),[M,T]=_.useState(h),D=_.useRef(null);_.useEffect(()=>{var $,I,H;if(e){g((($=n.interactionConfig)==null?void 0:$.drillHierarchies)||[]),y(((I=n.interactionConfig)==null?void 0:I.allowedDrillTargets)||[]),v(null);const B=((H=n.interactionConfig)==null?void 0:H.drillInteractions)||[];S(B.filter(P=>P.mode==="drillToURL")),E(B.filter(P=>P.mode==="drillThrough")),R(B.filter(P=>P.mode==="drillToDetail")),T(h)}},[e,n.interactionConfig,h]);const A=()=>{var H;const $=[...w,...k,...N];r.updateDrillHierarchies(m),r.updateDrillInteractions($),(H=D.current)!=null&&H.saveToGlobal&&D.current.saveToGlobal(),r.updateAllowedDrillTargets(b);const I={...n,interactionConfig:{...n.interactionConfig,drillHierarchies:m,allowedDrillTargets:b,drillInteractions:$,clickFilterInteractions:M}};o(I),t()},O=()=>{v(null),t()};return e?d.jsxs(Xl,{modal:!1,open:e,onOpenChange:t,children:[d.jsx("div",{className:"pointer-events-none fixed inset-0 z-40 bg-background/80 backdrop-blur-sm"}),d.jsxs(La,{className:"flex max-h-[90vh] max-w-4xl flex-col overflow-hidden",children:[d.jsxs(za,{children:[d.jsx(Ba,{children:"Configure Interactions"}),d.jsx(Va,{children:"Set up drill behaviors for this chart"})]}),d.jsx("div",{className:"flex-1 overflow-y-auto",children:d.jsx("div",{className:"space-y-6",children:d.jsx("div",{children:d.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[d.jsx(epe,{configuringIntent:x,setConfiguringIntent:v,incomingFilterFields:l,onUpdateClickFilterInteractions:T,currentClickFilterInteractions:M}),d.jsx(Dhe,{configuringIntent:x,setConfiguringIntent:v,drillHierarchies:m,onUpdateHierarchies:g,availableFields:c}),d.jsx(Lhe,{configuringIntent:x,setConfiguringIntent:v,selectedDrillTargets:b,setSelectedDrillTargets:y,availableFields:c})]})})})}),d.jsxs(Ql,{className:"border-t-0",children:[d.jsx(ae,{variant:"outline",onClick:O,children:"Cancel"}),d.jsx(ae,{onClick:A,children:"Save Changes"})]})]})]}):null}async function k9(e){var s;if(re.getState().isDownloadingPdf)return;const n=Intl.DateTimeFormat().resolvedOptions().timeZone,r=new URLSearchParams;r.set("theme",e.theme),r.set("filterValues",JSON.stringify(e.filterValues)),r.set("dashboardId",e.dashboardId),e.selectedSheetId!==void 0&&r.set("selectedSheetId",e.selectedSheetId),e.dashboardTitle!==void 0&&r.set("dashboardTitle",e.dashboardTitle),e.visualId!==void 0&&r.set("visualId",e.visualId),e.frameId!==void 0&&r.set("frameId",e.frameId),e.tableMode!==void 0&&r.set("tableMode",String(e.tableMode)),e.cardTitle!==void 0&&r.set("reportTitle",e.cardTitle),e.password&&r.set("password",e.password),e.pageSize&&r.set("pageSize",e.pageSize),e.orientation&&r.set("orientation",e.orientation),e.filterLine&&r.set("filterLine",e.filterLine),r.set("timezone",e.timezone||n);const o=`https://semaphor.cloud/api/v1/pdf?params=${encodeURIComponent(r.toString())}`;re.setState({isDownloadingPdf:!0});try{const i=await fetch(o,{method:"GET",headers:{Authorization:`Bearer ${(s=e.authToken)==null?void 0:s.accessToken}`}});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);const a=await i.json();if(!a.url)throw new Error("No download URL received from server");const l=a.url,c=document.createElement("a");c.href=l,c.download=e.fileName,c.click(),re.setState({isDownloadingPdf:!1})}catch(i){throw re.setState({isDownloadingPdf:!1}),i}}function N9(){var o;const e=re.getState().authToken,t=(o=re.getState().dashboard)==null?void 0:o.id,n=re.getState().theme,r=re.getState().filterValues;return{authToken:e,dashboardId:t||"",theme:n||"light",filterValues:r}}function LM(){var r;const e=(r=re.getState().dashboard)==null?void 0:r.title,t=re.getState().selectedSheetId;return{...N9(),dashboardTitle:e||"",selectedSheetId:t||""}}async function npe(e){const{authToken:t,theme:n,filterValues:r,dashboardTitle:o,selectedSheetId:s,dashboardId:i}=LM(),a=`${o}-${new Date().toISOString()}.pdf`;return k9({authToken:t,theme:n,filterValues:r,dashboardId:i,fileName:a,password:e,dashboardTitle:o,selectedSheetId:s})}function rpe(e,t,n){return{...N9(),cardId:e||"",frameId:t||"",cardTitle:n||""}}async function M9(e,t,n,r,o,s,i,a){const{authToken:l,theme:c,filterValues:u,dashboardId:f}=rpe(e,t,n),h=`${n}-${new Date().toISOString()}.pdf`;return k9({authToken:l,cardTitle:n,theme:c,filterValues:u,dashboardId:f,fileName:h,password:o,visualId:e,frameId:t,tableMode:r==="table"||r==="aggregateTable",pageSize:s,orientation:i,filterLine:a})}function ope(e,t){return C.useReducer((n,r)=>t[n][r]??n,e)}var zM="ScrollArea",[j9,oKe]=hr(zM),[spe,Es]=j9(zM),R9=C.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=C.useState(null),[c,u]=C.useState(null),[f,h]=C.useState(null),[p,m]=C.useState(null),[g,b]=C.useState(null),[y,x]=C.useState(0),[v,w]=C.useState(0),[S,k]=C.useState(!1),[E,N]=C.useState(!1),R=Je(t,T=>l(T)),M=Wu(o);return d.jsx(spe,{scope:n,type:r,dir:M,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:u,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:S,onScrollbarXEnabledChange:k,scrollbarY:g,onScrollbarYChange:b,scrollbarYEnabled:E,onScrollbarYEnabledChange:N,onCornerWidthChange:x,onCornerHeightChange:w,children:d.jsx(Pe.div,{dir:M,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":v+"px",...e.style}})})});R9.displayName=zM;var D9="ScrollAreaViewport",P9=C.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Es(D9,n),a=C.useRef(null),l=Je(t,a,i.onViewportChange);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),d.jsx(Pe.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:d.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});P9.displayName=D9;var Gi="ScrollAreaScrollbar",BM=C.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Es(Gi,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return C.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?d.jsx(ipe,{...r,ref:t,forceMount:n}):o.type==="scroll"?d.jsx(ape,{...r,ref:t,forceMount:n}):o.type==="auto"?d.jsx(T9,{...r,ref:t,forceMount:n}):o.type==="always"?d.jsx(VM,{...r,ref:t}):null});BM.displayName=Gi;var ipe=C.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Es(Gi,e.__scopeScrollArea),[s,i]=C.useState(!1);return C.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},u=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",u),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),d.jsx(Un,{present:n||s,children:d.jsx(T9,{"data-state":s?"visible":"hidden",...r,ref:t})})}),ape=C.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Es(Gi,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Nw(()=>l("SCROLL_END"),100),[a,l]=ope("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return C.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),C.useEffect(()=>{const c=o.viewport,u=s?"scrollLeft":"scrollTop";if(c){let f=c[u];const h=()=>{const p=c[u];f!==p&&(l("SCROLL"),i()),f=p};return c.addEventListener("scroll",h),()=>c.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),d.jsx(Un,{present:n||a!=="hidden",children:d.jsx(VM,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:xe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:xe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),T9=C.forwardRef((e,t)=>{const n=Es(Gi,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=C.useState(!1),a=e.orientation==="horizontal",l=Nw(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,u=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:u)}},10);return Vf(n.viewport,l),Vf(n.content,l),d.jsx(Un,{present:r||s,children:d.jsx(VM,{"data-state":s?"visible":"hidden",...o,ref:t})})}),VM=C.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Es(Gi,e.__scopeScrollArea),s=C.useRef(null),i=C.useRef(0),[a,l]=C.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=$9(a.viewport,a.content),u={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return hpe(h,i.current,a,p)}return n==="horizontal"?d.jsx(lpe,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=eA(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?d.jsx(cpe,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=eA(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),lpe=C.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Es(Gi,e.__scopeScrollArea),[i,a]=C.useState(),l=C.useRef(null),c=Je(t,l,s.onScrollbarXChange);return C.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),d.jsx(I9,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":kw(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+u.deltaX;e.onWheelScroll(h),z9(h,f)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:ax(i.paddingLeft),paddingEnd:ax(i.paddingRight)}})}})}),cpe=C.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Es(Gi,e.__scopeScrollArea),[i,a]=C.useState(),l=C.useRef(null),c=Je(t,l,s.onScrollbarYChange);return C.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),d.jsx(I9,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":kw(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,f)=>{if(s.viewport){const h=s.viewport.scrollTop+u.deltaY;e.onWheelScroll(h),z9(h,f)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:ax(i.paddingTop),paddingEnd:ax(i.paddingBottom)}})}})}),[upe,A9]=j9(Gi),I9=C.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:u,onResize:f,...h}=e,p=Es(Gi,n),[m,g]=C.useState(null),b=Je(t,R=>g(R)),y=C.useRef(null),x=C.useRef(""),v=p.viewport,w=r.content-r.viewport,S=rr(u),k=rr(l),E=Nw(f,10);function N(R){if(y.current){const M=R.clientX-y.current.left,T=R.clientY-y.current.top;c({x:M,y:T})}}return C.useEffect(()=>{const R=M=>{const T=M.target;(m==null?void 0:m.contains(T))&&S(M,w)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[v,m,w,S]),C.useEffect(k,[r,k]),Vf(m,E),Vf(p.content,E),d.jsx(upe,{scope:n,scrollbar:m,hasThumb:o,onThumbChange:rr(s),onThumbPointerUp:rr(i),onThumbPositionChange:k,onThumbPointerDown:rr(a),children:d.jsx(Pe.div,{...h,ref:b,style:{position:"absolute",...h.style},onPointerDown:xe(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=m.getBoundingClientRect(),x.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),N(R))}),onPointerMove:xe(e.onPointerMove,N),onPointerUp:xe(e.onPointerUp,R=>{const M=R.target;M.hasPointerCapture(R.pointerId)&&M.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=x.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),ix="ScrollAreaThumb",O9=C.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=A9(ix,e.__scopeScrollArea);return d.jsx(Un,{present:n||o.hasThumb,children:d.jsx(dpe,{ref:t,...r})})}),dpe=C.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Es(ix,n),i=A9(ix,n),{onThumbPositionChange:a}=i,l=Je(t,f=>i.onThumbChange(f)),c=C.useRef(void 0),u=Nw(()=>{c.current&&(c.current(),c.current=void 0)},100);return C.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(u(),!c.current){const p=ppe(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,u,a]),d.jsx(Pe.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:xe(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),m=f.clientX-p.left,g=f.clientY-p.top;i.onThumbPointerDown({x:m,y:g})}),onPointerUp:xe(e.onPointerUp,i.onThumbPointerUp)})});O9.displayName=ix;var HM="ScrollAreaCorner",F9=C.forwardRef((e,t)=>{const n=Es(HM,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?d.jsx(fpe,{...e,ref:t}):null});F9.displayName=HM;var fpe=C.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Es(HM,n),[s,i]=C.useState(0),[a,l]=C.useState(0),c=!!(s&&a);return Vf(o.scrollbarX,()=>{var f;const u=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(u),l(u)}),Vf(o.scrollbarY,()=>{var f;const u=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(u),i(u)}),c?d.jsx(Pe.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ax(e){return e?parseInt(e,10):0}function $9(e,t){const n=e/t;return isNaN(n)?0:n}function kw(e){const t=$9(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function hpe(e,t,n,r="ltr"){const o=kw(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,u=n.content-n.viewport,f=r==="ltr"?[0,u]:[u*-1,0];return L9([l,c],f)(e)}function eA(e,t,n="ltr"){const r=kw(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=IE(e,l);return L9([0,i],[0,a])(c)}function L9(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function z9(e,t){return e>0&&e<t}var ppe=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function Nw(e,t){const n=rr(e),r=C.useRef(0);return C.useEffect(()=>()=>window.clearTimeout(r.current),[]),C.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Vf(e,t){const n=rr(t);Mr(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var Mw=R9,B9=P9,V9=F9;const Ta=C.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(Mw,{ref:r,className:K("relative overflow-hidden",e),...n,children:[d.jsx(B9,{className:"h-full w-full rounded-[inherit]",children:t}),d.jsx(Aa,{}),d.jsx(V9,{})]}));Ta.displayName=Mw.displayName;const Aa=C.forwardRef(({className:e,orientation:t="vertical",...n},r)=>d.jsx(BM,{ref:r,orientation:t,className:K("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:d.jsx(O9,{className:"relative flex-1 rounded-full bg-border"})}));Aa.displayName=BM.displayName;var mpe="Separator",tA="horizontal",gpe=["horizontal","vertical"],H9=C.forwardRef((e,t)=>{const{decorative:n,orientation:r=tA,...o}=e,s=bpe(r)?r:tA,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return d.jsx(Pe.div,{"data-orientation":s,...a,...o,ref:t})});H9.displayName=mpe;function bpe(e){return gpe.includes(e)}var W9=H9;const Ks=C.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>d.jsx(W9,{ref:o,decorative:n,orientation:t,className:K("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Ks.displayName=W9.displayName;function U9(e){const t=e.split(".");return t[t.length-1].replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1).toLowerCase()).join(" ")}function nA(e){const{name:t,operation:n,values:r,valueType:o}=e,s=U9(t);if(!r||r.length===0)return n==="is null"?`${s} is empty`:n==="is not null"?`${s} is not empty`:"";const i=a=>{if(o==="date"&&a){const l=new Date(a);if(!isNaN(l.getTime()))return l.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}return String(a)};switch(n){case"=":return`${s}: ${i(r[0])}`;case"!=":return`${s} ≠ ${i(r[0])}`;case">":return`${s} > ${i(r[0])}`;case"<":return`${s} < ${i(r[0])}`;case">=":return`${s} ≥ ${i(r[0])}`;case"<=":return`${s} ≤ ${i(r[0])}`;case"between":case"not between":{const a=`${i(r[0])} - ${i(r[1])}`;return n==="between"?`${s}: ${a}`:`${s} not in ${a}`}case"in":{if(r.length===1)return`${s}: ${i(r[0])}`;const a=r.map(i).join(", ");return`${s}: ${a}`}case"not in":{const a=r.map(i).join(", ");return`${s} not in (${a})`}case"like":return`${s} contains "${r[0]}"`;case"not like":return`${s} doesn't contain "${r[0]}"`;default:return`${s}: ${r.map(i).join(", ")}`}}function WE(e){if(!e||e.length===0)return"";const t=new Map;e.forEach(r=>{const o=t.get(r.name)||[];o.push(r),t.set(r.name,o)});const n=[];return t.forEach((r,o)=>{if(r.length===1){const s=nA(r[0]);s&&n.push(s)}else{const s=U9(o),i=r.map(a=>nA(a).replace(`${s}: `,"").replace(`${s} `,"")).filter(Boolean);i.length>0&&n.push(`${s}: ${i.join(" and ")}`)}}),n.join(" | ")}function Ol({size:e="md",color:t="muted",className:n=""}){const r={xs:"w-0.5 h-0.5",sm:"w-1 h-1",md:"w-2 h-2",lg:"w-3 h-3"},o={muted:"bg-muted-foreground/70",primary:"bg-primary",secondary:"bg-secondary-foreground",accent:"bg-accent-foreground",destructive:"bg-destructive",gray:"bg-gray-400 dark:bg-gray-500",blue:"bg-blue-500 dark:bg-blue-400",green:"bg-green-500 dark:bg-green-400",red:"bg-red-500 dark:bg-red-400"},s=K(r[e],o[t],"rounded-full animate-pulse");return d.jsxs("div",{className:K("flex items-center gap-1",n),children:[d.jsx("div",{className:s,style:{animationDelay:"0ms",animationDuration:"1.4s"}}),d.jsx("div",{className:s,style:{animationDelay:"200ms",animationDuration:"1.4s"}}),d.jsx("div",{className:s,style:{animationDelay:"400ms",animationDuration:"1.4s"}})]})}const Ku=C.forwardRef(({className:e,children:t,style:n,...r},o)=>d.jsxs(Mw,{style:n,className:K("relative overflow-hidden",e),children:[d.jsx(B9,{ref:o,...r,className:"h-full w-full rounded-[inherit]",children:t}),d.jsx(Aa,{}),d.jsx(V9,{})]}));Ku.displayName=Mw.displayName;/**
651
651
  * table-core
652
652
  *
653
653
  * Copyright (c) TanStack
@@ -787,7 +787,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
787
787
  `)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}function aR(e,t){const n=t.endsWith(".csv")?t:`${t}.csv`,r="\uFEFF",o=new Blob([r+e],{type:"text/csv;charset=utf-8;"}),s=URL.createObjectURL(o),i=document.createElement("a");i.href=s,i.download=n,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(s)}function Sje(e,t,n,r,o){if(!e||e.length===0){console.warn("No data to export");return}const s=(o==null?void 0:o.delimiter)||",",i=[];i.length===0&&i.push(...Object.keys(e[0]));let a="";{const l=i.map(c=>Nl(c,s));a+=l.join(s)+`
788
788
  `}e.forEach(l=>{const c=i.map(u=>{const f=l[u];return(l.isSubtotal||l.isGrandTotal)&&i.indexOf(u)===0?Nl(l.isGrandTotal?"Grand Total":`${f} Total`,s):f==null?"":Nl(String(f),s)});a+=c.join(s)+`
789
789
  `}),aR(a,t)}function Cje(e,t,n,r,o){if(!e||e.length===0){console.warn("No data to export");return}const s=(o==null?void 0:o.delimiter)||",";let i="";e.forEach(a=>{const l=Object.values(a).map(c=>c==null?"":Nl(String(c),s));i+=l.join(s)+`
790
- `}),aR(i,t)}const Eje={letter:{width:816,height:1056},a4:{width:794,height:1123},legal:{width:816,height:1344},tabloid:{width:1056,height:1632},a3:{width:1123,height:1587}};function GW({isOpen:e,onClose:t,frame:n,card:r,data:o}){const{currentUser:s}=hh(),i=re(ne=>ne.filterValues),[a,l]=_.useState({reportTitle:(r==null?void 0:r.title)||"Report",pageSize:"letter",orientation:"portrait",password:"",showPassword:!1}),[c,u]=_.useState({recipients:(s==null?void 0:s.email)||"",subject:`Report: ${(r==null?void 0:r.title)||"Visual"}`,message:"Please find the attached report."}),[f,h]=_.useState("download"),[p,m]=_.useState("pdf"),[g,b]=_.useState(!1),[y,x]=_.useState(!1),{schedules:v,isLoading:w,createSchedule:S,deleteSchedule:k,isSubmitting:E,submitError:N,deletingId:R,refetch:M}=qW({reportType:"VISUAL",visualId:r==null?void 0:r.id,frameId:n.id,pageSettings:{pageSize:a.pageSize,orientation:a.orientation,reportTitle:a.reportTitle,isPdfRender:!0,filterLine:a.filterLine}});_.useEffect(()=>{e&&(r!=null&&r.id)&&M()},[e,r==null?void 0:r.id,M]);const T=_.useMemo(()=>({id:"dummy",type:"table",title:"",frameId:"",config:{},queryConfig:{}}),[]),{data:D,isLoading:A,isFetching:O,pagination:j}=Yw(r||T),F=r?D:null,L=r?A:!1,V=r?O:!1,$=_.useMemo(()=>{const ne=o||F;return ne?ne.records&&ne.records.length>100?{...ne,records:ne.records.slice(0,100)}:ne:null},[o,F]),I=ab(r,$);_.useEffect(()=>{if(e&&!y){const ne=re.getState().filterValues,le=WE(ne||[]);l({reportTitle:(r==null?void 0:r.title)||"Report",pageSize:"letter",orientation:"portrait",password:"",showPassword:!1,filterLine:le}),u({recipients:(s==null?void 0:s.email)||"",subject:`Report: ${(r==null?void 0:r.title)||"Visual"}`,message:"Please find the attached report."}),x(!0),h("download")}!e&&y&&x(!1)},[e,y,r==null?void 0:r.title,s==null?void 0:s.email]);const H=_.useRef(null),[B,P]=_.useState({width:0,height:0}),W=_.useMemo(()=>{const ne=Eje[a.pageSize];let le=ne.width,ge=ne.height;return a.orientation==="landscape"&&([le,ge]=[ge,le]),{width:le,height:ge}},[a.pageSize,a.orientation]),Y=_.useMemo(()=>{if(B.width===0||B.height===0)return .5;const ne=40,le=B.width-ne,ge=B.height-ne,Me=le/W.width,ue=ge/W.height;return Math.min(Me,ue,.9)},[B,W]);_.useEffect(()=>{const ne=()=>{if(H.current){const Me=H.current.getBoundingClientRect();P({width:Me.width,height:Me.height})}},le=setTimeout(ne,50);window.addEventListener("resize",ne);const ge=new ResizeObserver(ne);return H.current&&ge.observe(H.current),()=>{clearTimeout(le),window.removeEventListener("resize",ne),ge.disconnect()}},[e]);const X=async()=>{var ne;if(!r||!$){dt.error("No data to export");return}b(!0);try{if(p==="csv"){const le=a.reportTitle||r.title||"Report",ge=(ne=r.preferences)==null?void 0:ne.tablePrefs;r.type==="aggregateTable"?Sje($.records||[],le,void 0,void 0,{includeHeaders:!0,includeSubtotals:!0,includeGrandTotal:!0}):r.type==="pivotTable"?Cje($.records||[],le,void 0,void 0,{includeHeaders:!0}):wje($.records||[],le,ge,{includeHeaders:!0}),dt.success("CSV downloaded successfully"),t()}else await M9(r.id,n.id,a.reportTitle||r.title||"Report",r.type,void 0,a.pageSize,a.orientation,WE(i||[])),dt.success("PDF downloaded successfully"),t()}catch(le){dt.error(`Failed to generate ${p.toUpperCase()}`,{description:le instanceof Error?le.message:"Please try again"})}finally{b(!1)}},U=async()=>{if(!r||!$){dt.error("No data to send");return}if(!c.recipients){dt.error("Please enter recipient email addresses");return}const ne=c.recipients.split(/[,;]/).map(ue=>ue.trim()).filter(ue=>ue),le=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ge=ne.filter(ue=>!le.test(ue));if(ge.length>0){dt.error(`Invalid email addresses: ${ge.join(", ")}`);return}b(!0);const Me=dt.loading("Sending email...");try{await new Promise(Te=>setTimeout(Te,2e3)),dt.dismiss(Me);const ue=ne.length,ke=ue===1?ne[0]:`${ue} recipients`;dt.success(`✅ Email has been sent to ${ke}`,{duration:4e3})}catch(ue){dt.error("Failed to send email",{description:ue instanceof Error?ue.message:"Please try again or contact support.",richColors:!0,duration:5e3}),console.error("Email send error:",ue)}},z=async ne=>{var le;if(!r){dt.error("No visual selected");return}b(!0);try{const ge={format:p};if(p==="pdf"&&(ge.pdfOptions={pageSize:a.pageSize,orientation:a.orientation,includeFilters:!0,includeTimestamp:!0}),p==="csv"&&(ge.csvOptions={delimiter:",",includeHeaders:!0,useFormattedValues:!0}),r.type==="table"||r.type==="aggregateTable"||r.type==="pivotTable"){const Me=(le=r.preferences)==null?void 0:le.tablePrefs;Me&&(ge.tablePreferences=Me)}await S({...ne,reportParams:ge}),t()}catch(ge){console.error("Schedule creation error:",ge)}finally{b(!1)}},G=async ne=>{try{await k(ne)}catch(le){console.error("Failed to delete schedule:",le)}},J=async()=>{switch(f){case"download":await X();break;case"email":await U();break}},ee=_.useMemo(()=>({mode:"table-print"}),[]),q=_.useMemo(()=>({displayPreferences:ee,shouldShowElement:()=>!1}),[ee]),ie=()=>!r||!$?d.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"No data to preview"}):L||V?d.jsx("div",{className:"flex h-full items-center justify-center",children:d.jsx(Ol,{size:"md",color:"muted","aria-label":"Loading preview"})}):d.jsx(tM.Provider,{value:q,children:d.jsxs("div",{className:"flex h-full flex-col",children:[d.jsxs("div",{className:"mb-4",children:[d.jsx("h1",{className:"text-xl font-bold",children:a.reportTitle}),a.filterLine&&d.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Filters: ",a.filterLine]})]}),d.jsx("div",{className:"flex-1",children:r.type==="table"?d.jsx(Wf,{card:r,data:$.records||[],paginationMetadata:j||void 0,onPaginationChange:()=>{},isLoading:!1}):r.type==="aggregateTable"?d.jsx(Iw,{card:r,data:$.records||[],groupByColumns:$.groupByColumns,pivotSchema:$.pivotSchema,paginationMetadata:j||void 0,onPaginationChange:()=>{},onAggregationChange:()=>{},isLoading:!1}):r.type==="pivotTable"&&I?d.jsx(lb,{card:r,data:I.data,options:{...I.options,pagination:{enabled:!1,pageSize:100}},onAggregationChange:()=>{},onAggregationLabelChange:()=>{}}):r.type==="pivotTable"&&!I?d.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"No pivot table data to preview"}):d.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Preview not available for this card type"})})]})});return d.jsx(Xl,{open:e,onOpenChange:t,children:d.jsxs(La,{className:"flex h-[90vh] w-[90vw] max-w-[1400px] flex-col gap-0 p-0",children:[d.jsxs(za,{className:"shrink-0 border-b px-6 py-4",children:[d.jsxs(Ba,{children:["PDF Preview - ",a.reportTitle]}),d.jsx(Va,{children:"Preview how your table will appear in the PDF and adjust settings before exporting"})]}),d.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[d.jsxs("div",{className:"flex w-[450px] shrink-0 flex-col border-r bg-muted/10",children:[d.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-6",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{htmlFor:"report-title",children:"Report Title"}),d.jsx(yr,{id:"report-title",value:a.reportTitle,onChange:ne=>l({...a,reportTitle:ne.target.value}),placeholder:"Enter report title"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{children:"Action"}),d.jsxs(Bs,{value:f,onValueChange:ne=>h(ne),className:"flex gap-4",children:[d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Yn,{value:"download",id:"download"}),d.jsxs(de,{htmlFor:"download",className:"flex cursor-pointer items-center",children:[d.jsx(Tf,{className:"mr-2 h-4 w-4"}),"Download PDF"]})]}),d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Yn,{value:"email",id:"email"}),d.jsxs(de,{htmlFor:"email",className:"flex cursor-pointer items-center",children:[d.jsx(H0,{className:"mr-2 h-4 w-4"}),"Email"]})]}),d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Yn,{value:"schedule",id:"schedule"}),d.jsxs(de,{htmlFor:"schedule",className:"flex cursor-pointer items-center",children:[d.jsx(Nr,{className:"mr-2 h-4 w-4"}),"Schedule"]})]})]})]}),((r==null?void 0:r.type)==="table"||(r==null?void 0:r.type)==="aggregateTable"||(r==null?void 0:r.type)==="pivotTable")&&d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{children:"Export Format"}),d.jsxs(Bs,{value:p,onValueChange:ne=>m(ne),className:"flex gap-4",children:[d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Yn,{value:"pdf",id:"format-pdf"}),d.jsxs(de,{htmlFor:"format-pdf",className:"flex cursor-pointer items-center",children:[d.jsx(ro,{className:"mr-2 h-4 w-4"}),"PDF"]})]}),d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Yn,{value:"csv",id:"format-csv"}),d.jsxs(de,{htmlFor:"format-csv",className:"flex cursor-pointer items-center",children:[d.jsx(Af,{className:"mr-2 h-4 w-4"}),"CSV"]})]})]}),p==="csv"&&d.jsx("p",{className:"text-xs text-muted-foreground",children:"CSV export preserves your column visibility and ordering"})]}),p==="pdf"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{htmlFor:"page-size",children:"Page Size"}),d.jsxs(hn,{value:a.pageSize,onValueChange:ne=>l({...a,pageSize:ne}),children:[d.jsx(an,{id:"page-size",children:d.jsx(pn,{})}),d.jsxs(ln,{children:[d.jsx(Ne,{value:"letter",children:'Letter (8.5" x 11")'}),d.jsx(Ne,{value:"a4",children:"A4 (210mm x 297mm)"}),d.jsx(Ne,{value:"legal",children:'Legal (8.5" x 14")'}),d.jsx(Ne,{value:"tabloid",children:'Tabloid (11" x 17")'}),d.jsx(Ne,{value:"a3",children:"A3 (297mm x 420mm)"})]})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{children:"Orientation"}),d.jsxs(Bs,{value:a.orientation,onValueChange:ne=>l({...a,orientation:ne}),className:"flex gap-4",children:[d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Yn,{value:"portrait",id:"portrait"}),d.jsxs(de,{htmlFor:"portrait",className:"flex cursor-pointer items-center",children:[d.jsx(ro,{className:"mr-2 h-4 w-4"}),"Portrait"]})]}),d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Yn,{value:"landscape",id:"landscape"}),d.jsxs(de,{htmlFor:"landscape",className:"flex cursor-pointer items-center",children:[d.jsx(ro,{className:"mr-2 h-4 w-4 rotate-90"}),"Landscape"]})]})]})]})]}),f==="download"&&p==="pdf"&&d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{htmlFor:"password",children:"Password Protection (Optional)"}),d.jsxs("div",{className:"relative",children:[d.jsx(yr,{id:"password",type:a.showPassword?"text":"password",value:a.password,onChange:ne=>l({...a,password:ne.target.value}),placeholder:"Enter password",className:"pr-10"}),d.jsx(ae,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>l({...a,showPassword:!a.showPassword}),children:a.showPassword?d.jsx(Pv,{className:"h-4 w-4 text-muted-foreground"}):d.jsx(fh,{className:"h-4 w-4 text-muted-foreground"})})]}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"If set, the PDF will require this password to open"})]}),f==="email"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{htmlFor:"recipients",children:"Recipients"}),d.jsx(yr,{id:"recipients",type:"text",value:c.recipients,onChange:ne=>u({...c,recipients:ne.target.value}),placeholder:s!=null&&s.email?"Add more emails separated by commas":"email@example.com, email2@example.com"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Separate multiple emails with commas"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{htmlFor:"subject",children:"Subject"}),d.jsx(yr,{id:"subject",value:c.subject,onChange:ne=>u({...c,subject:ne.target.value})})]})]}),f==="schedule"&&d.jsxs(d.Fragment,{children:[((r==null?void 0:r.type)==="table"||(r==null?void 0:r.type)==="aggregateTable"||(r==null?void 0:r.type)==="pivotTable")&&d.jsx("div",{className:"rounded-lg bg-muted/50 p-3 text-sm",children:d.jsx("div",{className:"flex items-center gap-2",children:p==="pdf"?d.jsxs(d.Fragment,{children:[d.jsx(ro,{className:"h-4 w-4 text-muted-foreground"}),d.jsxs("span",{children:["Reports will be sent as ",d.jsx("strong",{children:"PDF"})," (",a.pageSize,", ",a.orientation,")"]})]}):d.jsxs(d.Fragment,{children:[d.jsx(Af,{className:"h-4 w-4 text-muted-foreground"}),d.jsxs("span",{children:["Reports will be sent as ",d.jsx("strong",{children:"CSV"})," with column preferences preserved"]})]})})}),d.jsx(sW,{reportType:"VISUAL",defaultValues:{subject:`Visual Report: ${(r==null?void 0:r.title)||"Report"}`,recipients:(s==null?void 0:s.email)||""},onSubmit:z,isSubmitting:E,submitError:N}),v&&v.length>0&&d.jsxs(d.Fragment,{children:[d.jsx(Ks,{className:"my-4"}),d.jsx(UW,{schedules:v,onDelete:G,isDeleting:R,isLoading:w,onRefresh:M})]})]})]}),d.jsx(Ql,{className:"border-t p-4",children:f!=="schedule"&&d.jsx(ae,{onClick:J,disabled:g,className:"w-full",children:g?d.jsxs(d.Fragment,{children:[d.jsx(ji,{className:"mr-2 h-4 w-4 animate-spin"}),"Processing..."]}):f==="download"?d.jsxs(d.Fragment,{children:[d.jsx(Tf,{className:"mr-2 h-4 w-4"}),"Download PDF"]}):d.jsxs(d.Fragment,{children:[d.jsx(H0,{className:"mr-2 h-4 w-4"}),"Send Email"]})})})]}),d.jsx("div",{ref:H,className:"flex flex-1 items-center justify-center bg-muted/5 p-4",children:d.jsx("div",{className:"relative overflow-hidden rounded-lg bg-white shadow-lg transition-all duration-200",style:{width:`${W.width*Y}px`,height:`${W.height*Y}px`},children:d.jsx(Ta,{className:"h-full w-full p-8",children:ie()})})})]})]})})}function YW(e,t,n,r,o,s){if(!e||e.length===0)return"";const i=[],a=[];if(n.forEach(l=>{a.push(l.label||l.name)}),r.forEach(l=>{l.isMetricColumn&&a.push(l.displayLabel||l.metricLabel||l.metricName||"")}),i.push(a.map(MC).join(",")),e.forEach(l=>{const c=[];if(l.isSubtotal&&!l.isGrandTotal){const u=l.subtotalLevel,f=n.findIndex(h=>h.alias===u);n.forEach((h,p)=>{var g,b,y,x;const m=h.alias||h.name;if(p===f){const v=l.aggregate||"SUM",w=(y=(b=(g=o==null?void 0:o.config)==null?void 0:g.rowAggregates)==null?void 0:b.find(S=>S.groupLevel===l.subtotalLevel&&S.function===v))==null?void 0:y.label;if(w)c.push(w);else{const k=(((x=l.subtotalContext)==null?void 0:x.groupByValues)||{})[m],E=v==="SUM"?"Total":v.charAt(0).toUpperCase()+v.slice(1).toLowerCase();k&&k!=="__TOTAL__"?c.push(`Subtotal (${k})`):c.push(`Subtotal ${E}`)}}else if(p<f){const v=l[m];c.push(v&&v!=="__TOTAL__"?String(v):"")}else c.push("")}),r.forEach(h=>{if(h.isMetricColumn){const p=l[h.alias],m=s==null?void 0:s[h.alias];c.push(NC(p,m))}})}else n.forEach(u=>{const f=u.alias||u.name,h=l[f];c.push(h?String(h):"")}),r.forEach(u=>{if(u.isMetricColumn){const f=l[u.alias],h=s==null?void 0:s[u.alias];c.push(NC(f,h))}});i.push(c.map(MC).join(","))}),t){const l=[];n.forEach((c,u)=>{var f,h;if(u===0){const p=(h=(f=o==null?void 0:o.config)==null?void 0:f.rowAggregates)==null?void 0:h.find(m=>m.groupLevel==="ALL");if(p!=null&&p.label)l.push(p.label);else{const m=t.aggregate||"SUM",g=m==="SUM"?"Total":m.charAt(0).toUpperCase()+m.slice(1).toLowerCase();l.push(`Grand ${g}`)}}else l.push("")}),r.forEach(c=>{if(c.isMetricColumn){const u=t[c.alias],f=s==null?void 0:s[c.alias];l.push(NC(u,f))}}),i.push(l.map(MC).join(","))}return i.join(`
790
+ `}),aR(i,t)}const Eje={letter:{width:816,height:1056},a4:{width:794,height:1123},legal:{width:816,height:1344},tabloid:{width:1056,height:1632},a3:{width:1123,height:1587}};function GW({isOpen:e,onClose:t,frame:n,card:r,data:o}){const{currentUser:s}=hh(),i=re(ne=>ne.filterValues),[a,l]=_.useState({reportTitle:(r==null?void 0:r.title)||"Report",pageSize:"letter",orientation:"portrait",password:"",showPassword:!1}),[c,u]=_.useState({recipients:(s==null?void 0:s.email)||"",subject:`Report: ${(r==null?void 0:r.title)||"Visual"}`,message:"Please find the attached report."}),[f,h]=_.useState("download"),[p,m]=_.useState("pdf"),[g,b]=_.useState(!1),[y,x]=_.useState(!1),{schedules:v,isLoading:w,createSchedule:S,deleteSchedule:k,isSubmitting:E,submitError:N,deletingId:R,refetch:M}=qW({reportType:"VISUAL",visualId:r==null?void 0:r.id,frameId:n.id,pageSettings:{pageSize:a.pageSize,orientation:a.orientation,reportTitle:a.reportTitle,isPdfRender:!0,filterLine:a.filterLine}});_.useEffect(()=>{e&&(r!=null&&r.id)&&M()},[e,r==null?void 0:r.id,M]);const T=_.useMemo(()=>({id:"dummy",type:"table",title:"",frameId:"",config:{},queryConfig:{}}),[]),{data:D,isLoading:A,isFetching:O,pagination:j}=Yw(r||T),F=r?D:null,L=r?A:!1,V=r?O:!1,$=_.useMemo(()=>{const ne=o||F;return ne?ne.records&&ne.records.length>100?{...ne,records:ne.records.slice(0,100)}:ne:null},[o,F]),I=ab(r,$);_.useEffect(()=>{if(e&&!y){const ne=re.getState().filterValues,le=WE(ne||[]);l({reportTitle:(r==null?void 0:r.title)||"Report",pageSize:"letter",orientation:"portrait",password:"",showPassword:!1,filterLine:le}),u({recipients:(s==null?void 0:s.email)||"",subject:`Report: ${(r==null?void 0:r.title)||"Visual"}`,message:"Please find the attached report."}),x(!0),h("download")}!e&&y&&x(!1)},[e,y,r==null?void 0:r.title,s==null?void 0:s.email]);const H=_.useRef(null),[B,P]=_.useState({width:0,height:0}),W=_.useMemo(()=>{const ne=Eje[a.pageSize];let le=ne.width,ge=ne.height;return a.orientation==="landscape"&&([le,ge]=[ge,le]),{width:le,height:ge}},[a.pageSize,a.orientation]),Y=_.useMemo(()=>{if(B.width===0||B.height===0)return .5;const ne=40,le=B.width-ne,ge=B.height-ne,Me=le/W.width,ue=ge/W.height;return Math.min(Me,ue,.9)},[B,W]);_.useEffect(()=>{const ne=()=>{if(H.current){const Me=H.current.getBoundingClientRect();P({width:Me.width,height:Me.height})}},le=setTimeout(ne,50);window.addEventListener("resize",ne);const ge=new ResizeObserver(ne);return H.current&&ge.observe(H.current),()=>{clearTimeout(le),window.removeEventListener("resize",ne),ge.disconnect()}},[e]);const X=async()=>{var ne;if(!r||!$){dt.error("No data to export");return}b(!0);try{if(p==="csv"){const le=a.reportTitle||r.title||"Report",ge=(ne=r.preferences)==null?void 0:ne.tablePrefs;r.type==="aggregateTable"?Sje($.records||[],le,void 0,void 0,{includeHeaders:!0,includeSubtotals:!0,includeGrandTotal:!0}):r.type==="pivotTable"?Cje($.records||[],le,void 0,void 0,{includeHeaders:!0}):wje($.records||[],le,ge,{includeHeaders:!0}),dt.success("CSV downloaded successfully"),t()}else await M9(r.id,n.id,a.reportTitle||r.title||"Report",r.type,a.password||void 0,a.pageSize,a.orientation,WE(i||[])),dt.success("PDF downloaded successfully"),t()}catch(le){dt.error(`Failed to generate ${p.toUpperCase()}`,{description:le instanceof Error?le.message:"Please try again"})}finally{b(!1)}},U=async()=>{if(!r||!$){dt.error("No data to send");return}if(!c.recipients){dt.error("Please enter recipient email addresses");return}const ne=c.recipients.split(/[,;]/).map(ue=>ue.trim()).filter(ue=>ue),le=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ge=ne.filter(ue=>!le.test(ue));if(ge.length>0){dt.error(`Invalid email addresses: ${ge.join(", ")}`);return}b(!0);const Me=dt.loading("Sending email...");try{await new Promise(Te=>setTimeout(Te,2e3)),dt.dismiss(Me);const ue=ne.length,ke=ue===1?ne[0]:`${ue} recipients`;dt.success(`✅ Email has been sent to ${ke}`,{duration:4e3})}catch(ue){dt.error("Failed to send email",{description:ue instanceof Error?ue.message:"Please try again or contact support.",richColors:!0,duration:5e3}),console.error("Email send error:",ue)}},z=async ne=>{var le;if(!r){dt.error("No visual selected");return}b(!0);try{const ge={format:p};if(p==="pdf"&&(ge.pdfOptions={pageSize:a.pageSize,orientation:a.orientation,includeFilters:!0,includeTimestamp:!0}),p==="csv"&&(ge.csvOptions={delimiter:",",includeHeaders:!0,useFormattedValues:!0}),r.type==="table"||r.type==="aggregateTable"||r.type==="pivotTable"){const Me=(le=r.preferences)==null?void 0:le.tablePrefs;Me&&(ge.tablePreferences=Me)}await S({...ne,reportParams:ge}),t()}catch(ge){console.error("Schedule creation error:",ge)}finally{b(!1)}},G=async ne=>{try{await k(ne)}catch(le){console.error("Failed to delete schedule:",le)}},J=async()=>{switch(f){case"download":await X();break;case"email":await U();break}},ee=_.useMemo(()=>({mode:"table-print"}),[]),q=_.useMemo(()=>({displayPreferences:ee,shouldShowElement:()=>!1}),[ee]),ie=()=>!r||!$?d.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"No data to preview"}):L||V?d.jsx("div",{className:"flex h-full items-center justify-center",children:d.jsx(Ol,{size:"md",color:"muted","aria-label":"Loading preview"})}):d.jsx(tM.Provider,{value:q,children:d.jsxs("div",{className:"flex h-full flex-col",children:[d.jsxs("div",{className:"mb-4",children:[d.jsx("h1",{className:"text-xl font-bold",children:a.reportTitle}),a.filterLine&&d.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Filters: ",a.filterLine]})]}),d.jsx("div",{className:"flex-1",children:r.type==="table"?d.jsx(Wf,{card:r,data:$.records||[],paginationMetadata:j||void 0,onPaginationChange:()=>{},isLoading:!1}):r.type==="aggregateTable"?d.jsx(Iw,{card:r,data:$.records||[],groupByColumns:$.groupByColumns,pivotSchema:$.pivotSchema,paginationMetadata:j||void 0,onPaginationChange:()=>{},onAggregationChange:()=>{},isLoading:!1}):r.type==="pivotTable"&&I?d.jsx(lb,{card:r,data:I.data,options:{...I.options,pagination:{enabled:!1,pageSize:100}},onAggregationChange:()=>{},onAggregationLabelChange:()=>{}}):r.type==="pivotTable"&&!I?d.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"No pivot table data to preview"}):d.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Preview not available for this card type"})})]})});return d.jsx(Xl,{open:e,onOpenChange:t,children:d.jsxs(La,{className:"flex h-[90vh] w-[90vw] max-w-[1400px] flex-col gap-0 p-0",children:[d.jsxs(za,{className:"shrink-0 border-b px-6 py-4",children:[d.jsxs(Ba,{children:["PDF Preview - ",a.reportTitle]}),d.jsx(Va,{children:"Preview how your table will appear in the PDF and adjust settings before exporting"})]}),d.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[d.jsxs("div",{className:"flex w-[450px] shrink-0 flex-col border-r bg-muted/10",children:[d.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-6",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{htmlFor:"report-title",children:"Report Title"}),d.jsx(yr,{id:"report-title",value:a.reportTitle,onChange:ne=>l({...a,reportTitle:ne.target.value}),placeholder:"Enter report title"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{children:"Action"}),d.jsxs(Bs,{value:f,onValueChange:ne=>h(ne),className:"flex gap-4",children:[d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Yn,{value:"download",id:"download"}),d.jsxs(de,{htmlFor:"download",className:"flex cursor-pointer items-center",children:[d.jsx(Tf,{className:"mr-2 h-4 w-4"}),"Download PDF"]})]}),d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Yn,{value:"email",id:"email"}),d.jsxs(de,{htmlFor:"email",className:"flex cursor-pointer items-center",children:[d.jsx(H0,{className:"mr-2 h-4 w-4"}),"Email"]})]}),d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Yn,{value:"schedule",id:"schedule"}),d.jsxs(de,{htmlFor:"schedule",className:"flex cursor-pointer items-center",children:[d.jsx(Nr,{className:"mr-2 h-4 w-4"}),"Schedule"]})]})]})]}),((r==null?void 0:r.type)==="table"||(r==null?void 0:r.type)==="aggregateTable"||(r==null?void 0:r.type)==="pivotTable")&&d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{children:"Export Format"}),d.jsxs(Bs,{value:p,onValueChange:ne=>m(ne),className:"flex gap-4",children:[d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Yn,{value:"pdf",id:"format-pdf"}),d.jsxs(de,{htmlFor:"format-pdf",className:"flex cursor-pointer items-center",children:[d.jsx(ro,{className:"mr-2 h-4 w-4"}),"PDF"]})]}),d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Yn,{value:"csv",id:"format-csv"}),d.jsxs(de,{htmlFor:"format-csv",className:"flex cursor-pointer items-center",children:[d.jsx(Af,{className:"mr-2 h-4 w-4"}),"CSV"]})]})]}),p==="csv"&&d.jsx("p",{className:"text-xs text-muted-foreground",children:"CSV export preserves your column visibility and ordering"})]}),p==="pdf"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{htmlFor:"page-size",children:"Page Size"}),d.jsxs(hn,{value:a.pageSize,onValueChange:ne=>l({...a,pageSize:ne}),children:[d.jsx(an,{id:"page-size",children:d.jsx(pn,{})}),d.jsxs(ln,{children:[d.jsx(Ne,{value:"letter",children:'Letter (8.5" x 11")'}),d.jsx(Ne,{value:"a4",children:"A4 (210mm x 297mm)"}),d.jsx(Ne,{value:"legal",children:'Legal (8.5" x 14")'}),d.jsx(Ne,{value:"tabloid",children:'Tabloid (11" x 17")'}),d.jsx(Ne,{value:"a3",children:"A3 (297mm x 420mm)"})]})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{children:"Orientation"}),d.jsxs(Bs,{value:a.orientation,onValueChange:ne=>l({...a,orientation:ne}),className:"flex gap-4",children:[d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Yn,{value:"portrait",id:"portrait"}),d.jsxs(de,{htmlFor:"portrait",className:"flex cursor-pointer items-center",children:[d.jsx(ro,{className:"mr-2 h-4 w-4"}),"Portrait"]})]}),d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Yn,{value:"landscape",id:"landscape"}),d.jsxs(de,{htmlFor:"landscape",className:"flex cursor-pointer items-center",children:[d.jsx(ro,{className:"mr-2 h-4 w-4 rotate-90"}),"Landscape"]})]})]})]})]}),f==="download"&&p==="pdf"&&d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{htmlFor:"password",children:"Password Protection (Optional)"}),d.jsxs("div",{className:"relative",children:[d.jsx(yr,{id:"password",type:a.showPassword?"text":"password",value:a.password,onChange:ne=>l({...a,password:ne.target.value}),placeholder:"Enter password",className:"pr-10"}),d.jsx(ae,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>l({...a,showPassword:!a.showPassword}),children:a.showPassword?d.jsx(Pv,{className:"h-4 w-4 text-muted-foreground"}):d.jsx(fh,{className:"h-4 w-4 text-muted-foreground"})})]}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"If set, the PDF will require this password to open"})]}),f==="email"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{htmlFor:"recipients",children:"Recipients"}),d.jsx(yr,{id:"recipients",type:"text",value:c.recipients,onChange:ne=>u({...c,recipients:ne.target.value}),placeholder:s!=null&&s.email?"Add more emails separated by commas":"email@example.com, email2@example.com"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Separate multiple emails with commas"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(de,{htmlFor:"subject",children:"Subject"}),d.jsx(yr,{id:"subject",value:c.subject,onChange:ne=>u({...c,subject:ne.target.value})})]})]}),f==="schedule"&&d.jsxs(d.Fragment,{children:[((r==null?void 0:r.type)==="table"||(r==null?void 0:r.type)==="aggregateTable"||(r==null?void 0:r.type)==="pivotTable")&&d.jsx("div",{className:"rounded-lg bg-muted/50 p-3 text-sm",children:d.jsx("div",{className:"flex items-center gap-2",children:p==="pdf"?d.jsxs(d.Fragment,{children:[d.jsx(ro,{className:"h-4 w-4 text-muted-foreground"}),d.jsxs("span",{children:["Reports will be sent as ",d.jsx("strong",{children:"PDF"})," (",a.pageSize,", ",a.orientation,")"]})]}):d.jsxs(d.Fragment,{children:[d.jsx(Af,{className:"h-4 w-4 text-muted-foreground"}),d.jsxs("span",{children:["Reports will be sent as ",d.jsx("strong",{children:"CSV"})," with column preferences preserved"]})]})})}),d.jsx(sW,{reportType:"VISUAL",defaultValues:{subject:`Visual Report: ${(r==null?void 0:r.title)||"Report"}`,recipients:(s==null?void 0:s.email)||""},onSubmit:z,isSubmitting:E,submitError:N}),v&&v.length>0&&d.jsxs(d.Fragment,{children:[d.jsx(Ks,{className:"my-4"}),d.jsx(UW,{schedules:v,onDelete:G,isDeleting:R,isLoading:w,onRefresh:M})]})]})]}),d.jsx(Ql,{className:"border-t p-4",children:f!=="schedule"&&d.jsx(ae,{onClick:J,disabled:g,className:"w-full",children:g?d.jsxs(d.Fragment,{children:[d.jsx(ji,{className:"mr-2 h-4 w-4 animate-spin"}),"Processing..."]}):f==="download"?d.jsxs(d.Fragment,{children:[d.jsx(Tf,{className:"mr-2 h-4 w-4"}),"Download PDF"]}):d.jsxs(d.Fragment,{children:[d.jsx(H0,{className:"mr-2 h-4 w-4"}),"Send Email"]})})})]}),d.jsx("div",{ref:H,className:"flex flex-1 items-center justify-center bg-muted/5 p-4",children:d.jsx("div",{className:"relative overflow-hidden rounded-lg bg-white shadow-lg transition-all duration-200",style:{width:`${W.width*Y}px`,height:`${W.height*Y}px`},children:d.jsx(Ta,{className:"h-full w-full p-8",children:ie()})})})]})]})})}function YW(e,t,n,r,o,s){if(!e||e.length===0)return"";const i=[],a=[];if(n.forEach(l=>{a.push(l.label||l.name)}),r.forEach(l=>{l.isMetricColumn&&a.push(l.displayLabel||l.metricLabel||l.metricName||"")}),i.push(a.map(MC).join(",")),e.forEach(l=>{const c=[];if(l.isSubtotal&&!l.isGrandTotal){const u=l.subtotalLevel,f=n.findIndex(h=>h.alias===u);n.forEach((h,p)=>{var g,b,y,x;const m=h.alias||h.name;if(p===f){const v=l.aggregate||"SUM",w=(y=(b=(g=o==null?void 0:o.config)==null?void 0:g.rowAggregates)==null?void 0:b.find(S=>S.groupLevel===l.subtotalLevel&&S.function===v))==null?void 0:y.label;if(w)c.push(w);else{const k=(((x=l.subtotalContext)==null?void 0:x.groupByValues)||{})[m],E=v==="SUM"?"Total":v.charAt(0).toUpperCase()+v.slice(1).toLowerCase();k&&k!=="__TOTAL__"?c.push(`Subtotal (${k})`):c.push(`Subtotal ${E}`)}}else if(p<f){const v=l[m];c.push(v&&v!=="__TOTAL__"?String(v):"")}else c.push("")}),r.forEach(h=>{if(h.isMetricColumn){const p=l[h.alias],m=s==null?void 0:s[h.alias];c.push(NC(p,m))}})}else n.forEach(u=>{const f=u.alias||u.name,h=l[f];c.push(h?String(h):"")}),r.forEach(u=>{if(u.isMetricColumn){const f=l[u.alias],h=s==null?void 0:s[u.alias];c.push(NC(f,h))}});i.push(c.map(MC).join(","))}),t){const l=[];n.forEach((c,u)=>{var f,h;if(u===0){const p=(h=(f=o==null?void 0:o.config)==null?void 0:f.rowAggregates)==null?void 0:h.find(m=>m.groupLevel==="ALL");if(p!=null&&p.label)l.push(p.label);else{const m=t.aggregate||"SUM",g=m==="SUM"?"Total":m.charAt(0).toUpperCase()+m.slice(1).toLowerCase();l.push(`Grand ${g}`)}}else l.push("")}),r.forEach(c=>{if(c.isMetricColumn){const u=t[c.alias],f=s==null?void 0:s[c.alias];l.push(NC(u,f))}}),i.push(l.map(MC).join(","))}return i.join(`
791
791
  `)}function NC(e,t){if(e==null)return"";if((t==null?void 0:t.type)==="number"&&typeof e=="number"){const{numberFormat:n}=t;return n.style==="percent"?new Intl.NumberFormat(n.locale||"en-US",{style:"percent",minimumFractionDigits:n.minimumFractionDigits??0,maximumFractionDigits:n.maximumFractionDigits??2}).format(e/100):n.style==="currency"?new Intl.NumberFormat(n.locale||"en-US",{style:"currency",currency:n.currency||"USD",minimumFractionDigits:n.minimumFractionDigits??0,maximumFractionDigits:n.maximumFractionDigits??2}).format(e):new Intl.NumberFormat(n.locale||"en-US",{minimumFractionDigits:n.minimumFractionDigits??0,maximumFractionDigits:n.maximumFractionDigits??2}).format(e)}return typeof e=="number"?e.toLocaleString():String(e)}function MC(e){return/[",\n\r]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function Vx(e,t){const n=new Blob([e],{type:"text/csv;charset=utf-8;"}),r=window.URL.createObjectURL(n),o=document.createElement("a");o.setAttribute("href",r),o.setAttribute("download",t),o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(r)}const _je=e=>{const t=window.getSelection();if(!t||t.rangeCount===0)return 0;const n=t.getRangeAt(0),r=n.cloneRange();return r.selectNodeContents(e),r.setEnd(n.endContainer,n.endOffset),r.toString().length},kje=(e,t)=>{var i,a;const n=window.getSelection(),r=document.createRange();let o=0;const s=l=>{var c;if(l.nodeType===Node.TEXT_NODE){const u=((c=l.textContent)==null?void 0:c.length)||0;if(o+u>=t)return r.setStart(l,t-o),r.setEnd(l,t-o),!0;o+=u}else for(let u=0;u<l.childNodes.length;u++)if(s(l.childNodes[u]))return!0;return!1};if(!s(e)&&e.childNodes.length>0){const l=e.childNodes[e.childNodes.length-1];l.nodeType===Node.TEXT_NODE&&(r.setStart(l,((i=l.textContent)==null?void 0:i.length)||0),r.setEnd(l,((a=l.textContent)==null?void 0:a.length)||0))}n==null||n.removeAllRanges(),n==null||n.addRange(r)};function KO({value:e,onSave:t,placeholder:n="Click to add content...",className:r,disabled:o=!1,isDynamicText:s=!1}){const i=_.useRef(null),[a,l]=_.useState(!1),[c,u]=_.useState(!1),f=_.useRef(),h=_.useRef(e),[p,m]=_.useState(e),g=_.useRef(!1),y=re(N=>N.isDashboardEditing)&&!o&&!s;_.useEffect(()=>{!g.current&&i.current&&(i.current.innerHTML=e||"",g.current=!0)},[e]),_.useEffect(()=>{!a&&e!==p&&(m(e),i.current&&g.current&&(i.current.innerHTML=e||""),h.current=e)},[e,a,p]);const x=_.useCallback(()=>{if(!i.current||!y)return;u(!0);const N=i.current.innerHTML;m(N),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{var M;const R=((M=i.current)==null?void 0:M.innerHTML)||"";if(R!==h.current){const T=i.current?_je(i.current):0;t(R),h.current=R,m(R),u(!1),setTimeout(()=>{i.current&&a&&(i.current.focus(),kje(i.current,T))},0)}},500)},[y,t,a]),v=_.useCallback(N=>{N.preventDefault();const R=N.clipboardData.getData("text/plain"),M=N.clipboardData.getData("text/html");let T="";if(M&&!R){const j=document.createElement("div");j.innerHTML=M,j.querySelectorAll("script, style").forEach(F=>F.remove()),j.querySelectorAll("p, div, br").forEach(F=>{if(F.tagName==="BR")F.replaceWith(`
792
792
  `);else{const L=F.textContent||"";L&&F.replaceWith(L+`
793
793
  `)}}),T=j.innerHTML.replace(/\n\n+/g,`