semaphor 0.0.118 → 0.0.119

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.
@@ -492,7 +492,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
492
492
  To pick up a draggable item, press the space bar.
493
493
  While dragging, use the arrow keys to move the item.
494
494
  Press space again to drop the item in its new position, or press escape to cancel.
495
- `},kne={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 Rne(e){let{announcements:t=kne,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=_ne}=e;const{announce:i,announcement:s}=Cne(),a=Np("DndLiveRegion"),[l,c]=k.useState(!1);if(k.useEffect(()=>{c(!0)},[]),Sne(k.useMemo(()=>({onDragStart(d){let{active:h}=d;i(t.onDragStart({active:h}))},onDragMove(d){let{active:h,over:p}=d;t.onDragMove&&i(t.onDragMove({active:h,over:p}))},onDragOver(d){let{active:h,over:p}=d;i(t.onDragOver({active:h,over:p}))},onDragEnd(d){let{active:h,over:p}=d;i(t.onDragEnd({active:h,over:p}))},onDragCancel(d){let{active:h,over:p}=d;i(t.onDragCancel({active:h,over:p}))}}),[i,t])),!l)return null;const u=k.createElement(k.Fragment,null,k.createElement(xne,{id:r,value:o.draggable}),k.createElement(wne,{id:a,announcement:s}));return n?un.createPortal(u,n):u}var In;(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"})(In||(In={}));function jb(){}function xh(e,t){return k.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function o_(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return k.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const Qo=Object.freeze({x:0,y:0});function TF(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Nne(e,t){const n=Tb(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 jF(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Ane(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function pM(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 OF(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function mM(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 i_=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=mM(t,t.left,t.top),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=TF(mM(l),o);i.push({id:a,data:{droppableContainer:s,value:c}})}}return i.sort(jF)},Mne=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=pM(t),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=pM(l),u=o.reduce((h,p,m)=>h+TF(c[m],p),0),d=Number((u/4).toFixed(4));i.push({id:a,data:{droppableContainer:s,value:d}})}}return i.sort(jF)};function Pne(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),i=Math.min(t.top+t.height,e.top+e.height),s=o-r,a=i-n;if(r<o&&n<i){const l=t.width*t.height,c=e.width*e.height,u=s*a,d=u/(l+c-u);return Number(d.toFixed(4))}return 0}const Dne=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const i of r){const{id:s}=i,a=n.get(s);if(a){const l=Pne(a,t);l>0&&o.push({id:s,data:{droppableContainer:i,value:l}})}}return o.sort(Ane)};function Ine(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function FF(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Qo}function Tne(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((s,a)=>({...s,top:s.top+e*a.y,bottom:s.bottom+e*a.y,left:s.left+e*a.x,right:s.right+e*a.x}),{...n})}}const jne=Tne(1);function LF(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 One(e,t,n){const r=LF(t);if(!r)return e;const{scaleX:o,scaleY:i,x:s,y:a}=r,l=e.left-s-(1-o)*parseFloat(n),c=e.top-a-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=o?e.width/o:e.width,d=i?e.height/i:e.height;return{width:u,height:d,top:c,right:l+u,bottom:c+d,left:l}}const Fne={ignoreTransform:!1};function kd(e,t){t===void 0&&(t=Fne);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:u}=Sr(e).getComputedStyle(e);c&&(n=One(n,c,u))}const{top:r,left:o,width:i,height:s,bottom:a,right:l}=n;return{top:r,left:o,width:i,height:s,bottom:a,right:l}}function gM(e){return kd(e,{ignoreTransform:!0})}function Lne(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function $ne(e,t){return t===void 0&&(t=Sr(e).getComputedStyle(e)),t.position==="fixed"}function zne(e,t){t===void 0&&(t=Sr(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=t[o];return typeof i=="string"?n.test(i):!1})}function Sy(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(r_(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!kp(o)||PF(o)||n.includes(o))return n;const i=Sr(e).getComputedStyle(o);return o!==e&&zne(o,i)&&n.push(o),$ne(o,i)?n:r(o.parentNode)}return e?r(e):n}function $F(e){const[t]=Sy(e,1);return t??null}function Fx(e){return!xy||!e?null:Ed(e)?e:n_(e)?r_(e)||e===_d(e).scrollingElement?window:kp(e)?e:null:null}function zF(e){return Ed(e)?e.scrollX:e.scrollLeft}function BF(e){return Ed(e)?e.scrollY:e.scrollTop}function PC(e){return{x:zF(e),y:BF(e)}}var On;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(On||(On={}));function VF(e){return!xy||!e?!1:e===document.scrollingElement}function HF(e){const t={x:0,y:0},n=VF(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,i=e.scrollLeft<=t.x,s=e.scrollTop>=r.y,a=e.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:s,isRight:a,maxScroll:r,minScroll:t}}const Bne={x:.2,y:.2};function Vne(e,t,n,r,o){let{top:i,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=Bne);const{isTop:c,isBottom:u,isLeft:d,isRight:h}=HF(e),p={x:0,y:0},m={x:0,y:0},g={height:t.height*o.y,width:t.width*o.x};return!c&&i<=t.top+g.height?(p.y=On.Backward,m.y=r*Math.abs((t.top+g.height-i)/g.height)):!u&&l>=t.bottom-g.height&&(p.y=On.Forward,m.y=r*Math.abs((t.bottom-g.height-l)/g.height)),!h&&a>=t.right-g.width?(p.x=On.Forward,m.x=r*Math.abs((t.right-g.width-a)/g.width)):!d&&s<=t.left+g.width&&(p.x=On.Backward,m.x=r*Math.abs((t.left+g.width-s)/g.width)),{direction:p,speed:m}}function Hne(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:s}=window;return{top:0,left:0,right:i,bottom:s,width:i,height:s}}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 WF(e){return e.reduce((t,n)=>xu(t,PC(n)),Qo)}function Wne(e){return e.reduce((t,n)=>t+zF(n),0)}function Une(e){return e.reduce((t,n)=>t+BF(n),0)}function UF(e,t){if(t===void 0&&(t=kd),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);$F(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Gne=[["x",["left","right"],Wne],["y",["top","bottom"],Une]];class s_{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=Sy(n),o=WF(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,s,a]of Gne)for(const l of s)Object.defineProperty(this,l,{get:()=>{const c=a(r),u=o[i]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class $f{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 qne(e){const{EventTarget:t}=Sr(e);return e instanceof t?e:_d(e)}function Lx(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 xo;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(xo||(xo={}));function bM(e){e.preventDefault()}function Yne(e){e.stopPropagation()}var gt;(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"})(gt||(gt={}));const GF={start:[gt.Space,gt.Enter],cancel:[gt.Esc],end:[gt.Space,gt.Enter,gt.Tab]},Kne=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case gt.Right:return{...n,x:n.x+25};case gt.Left:return{...n,x:n.x-25};case gt.Down:return{...n,y:n.y+25};case gt.Up:return{...n,y:n.y-25}}};class Ap{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 $f(_d(n)),this.windowListeners=new $f(Sr(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(xo.Resize,this.handleCancel),this.windowListeners.add(xo.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(xo.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&UF(r),n(Qo)}handleKeyDown(t){if(Cy(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=GF,coordinateGetter:s=Kne,scrollBehavior:a="smooth"}=o,{code:l}=t;if(i.end.includes(l)){this.handleEnd(t);return}if(i.cancel.includes(l)){this.handleCancel(t);return}const{collisionRect:c}=r.current,u=c?{x:c.left,y:c.top}:Qo;this.referenceCoordinates||(this.referenceCoordinates=u);const d=s(t,{active:n,context:r.current,currentCoordinates:u});if(d){const h=vh(d,u),p={x:0,y:0},{scrollableAncestors:m}=r.current;for(const g of m){const b=t.code,{isTop:y,isRight:v,isLeft:x,isBottom:S,maxScroll:_,minScroll:E}=HF(g),C=Hne(g),R={x:Math.min(b===gt.Right?C.right-C.width/2:C.right,Math.max(b===gt.Right?C.left:C.left+C.width/2,d.x)),y:Math.min(b===gt.Down?C.bottom-C.height/2:C.bottom,Math.max(b===gt.Down?C.top:C.top+C.height/2,d.y))},M=b===gt.Right&&!v||b===gt.Left&&!x,N=b===gt.Down&&!S||b===gt.Up&&!y;if(M&&R.x!==d.x){const D=g.scrollLeft+h.x,A=b===gt.Right&&D<=_.x||b===gt.Left&&D>=E.x;if(A&&!h.y){g.scrollTo({left:D,behavior:a});return}A?p.x=g.scrollLeft-D:p.x=b===gt.Right?g.scrollLeft-_.x:g.scrollLeft-E.x,p.x&&g.scrollBy({left:-p.x,behavior:a});break}else if(N&&R.y!==d.y){const D=g.scrollTop+h.y,A=b===gt.Down&&D<=_.y||b===gt.Up&&D>=E.y;if(A&&!h.x){g.scrollTo({top:D,behavior:a});return}A?p.y=g.scrollTop-D:p.y=b===gt.Down?g.scrollTop-_.y:g.scrollTop-E.y,p.y&&g.scrollBy({top:-p.y,behavior:a});break}}this.handleMove(t,xu(vh(d,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()}}Ap.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=GF,onActivation:o}=t,{active:i}=n;const{code:s}=e.nativeEvent;if(r.start.includes(s)){const a=i.activatorNode.current;return a&&e.target!==a?!1:(e.preventDefault(),o==null||o({event:e.nativeEvent}),!0)}return!1}}];function yM(e){return!!(e&&"distance"in e)}function vM(e){return!!(e&&"delay"in e)}class a_{constructor(t,n,r){var o;r===void 0&&(r=qne(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:i}=t,{target:s}=i;this.props=t,this.events=n,this.document=_d(s),this.documentListeners=new $f(this.document),this.listeners=new $f(r),this.windowListeners=new $f(Sr(s)),this.initialCoordinates=(o=Tb(i))!=null?o:Qo,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(xo.Resize,this.handleCancel),this.windowListeners.add(xo.DragStart,bM),this.windowListeners.add(xo.VisibilityChange,this.handleCancel),this.windowListeners.add(xo.ContextMenu,bM),this.documentListeners.add(xo.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(vM(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(yM(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(xo.Click,Yne,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(xo.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:s,options:{activationConstraint:a}}=i;if(!o)return;const l=(n=Tb(t))!=null?n:Qo,c=vh(o,l);if(!r&&a){if(yM(a)){if(a.tolerance!=null&&Lx(c,a.tolerance))return this.handleCancel();if(Lx(c,a.distance))return this.handleStart()}if(vM(a)&&Lx(c,a.tolerance))return this.handleCancel();this.handlePending(a,c);return}t.cancelable&&t.preventDefault(),s(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===gt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Xne={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Mp extends a_{constructor(t){const{event:n}=t,r=_d(n.target);super(t,Xne,r)}}Mp.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 Qne={move:{name:"mousemove"},end:{name:"mouseup"}};var DC;(function(e){e[e.RightClick=2]="RightClick"})(DC||(DC={}));class qF extends a_{constructor(t){super(t,Qne,_d(t.event.target))}}qF.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===DC.RightClick?!1:(r==null||r({event:n}),!0)}}];const $x={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Jne extends a_{constructor(t){super(t,$x)}static setup(){return window.addEventListener($x.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener($x.move.name,t)};function t(){}}}Jne.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 zf;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(zf||(zf={}));var Ob;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Ob||(Ob={}));function Zne(e){let{acceleration:t,activator:n=zf.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:s=5,order:a=Ob.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:d,threshold:h}=e;const p=tre({delta:d,disabled:!i}),[m,g]=mne(),b=k.useRef({x:0,y:0}),y=k.useRef({x:0,y:0}),v=k.useMemo(()=>{switch(n){case zf.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case zf.DraggableRect:return o}},[n,o,l]),x=k.useRef(null),S=k.useCallback(()=>{const E=x.current;if(!E)return;const C=b.current.x*y.current.x,R=b.current.y*y.current.y;E.scrollBy(C,R)},[]),_=k.useMemo(()=>a===Ob.TreeOrder?[...c].reverse():c,[a,c]);k.useEffect(()=>{if(!i||!c.length||!v){g();return}for(const E of _){if((r==null?void 0:r(E))===!1)continue;const C=c.indexOf(E),R=u[C];if(!R)continue;const{direction:M,speed:N}=Vne(E,R,v,t,h);for(const D of["x","y"])p[D][M[D]]||(N[D]=0,M[D]=0);if(N.x>0||N.y>0){g(),x.current=E,m(S,s),b.current=N,y.current=M;return}}b.current={x:0,y:0},y.current={x:0,y:0},g()},[t,S,r,g,i,s,JSON.stringify(v),JSON.stringify(p),m,c,_,u,JSON.stringify(h)])}const ere={x:{[On.Backward]:!1,[On.Forward]:!1},y:{[On.Backward]:!1,[On.Forward]:!1}};function tre(e){let{delta:t,disabled:n}=e;const r=Ib(t);return Rp(o=>{if(n||!r||!o)return ere;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[On.Backward]:o.x[On.Backward]||i.x===-1,[On.Forward]:o.x[On.Forward]||i.x===1},y:{[On.Backward]:o.y[On.Backward]||i.y===-1,[On.Forward]:o.y[On.Forward]||i.y===1}}},[n,t,r])}function nre(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Rp(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function rre(e,t){return k.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(s=>({eventName:s.eventName,handler:t(s.handler,r)}));return[...n,...i]},[]),[e,t])}var wh;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(wh||(wh={}));var IC;(function(e){e.Optimized="optimized"})(IC||(IC={}));const xM=new Map;function ore(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,s]=k.useState(null),{frequency:a,measure:l,strategy:c}=o,u=k.useRef(e),d=b(),h=yh(d),p=k.useCallback(function(y){y===void 0&&(y=[]),!h.current&&s(v=>v===null?y:v.concat(y.filter(x=>!v.includes(x))))},[h]),m=k.useRef(null),g=Rp(y=>{if(d&&!n)return xM;if(!y||y===xM||u.current!==e||i!=null){const v=new Map;for(let x of e){if(!x)continue;if(i&&i.length>0&&!i.includes(x.id)&&x.rect.current){v.set(x.id,x.rect.current);continue}const S=x.node.current,_=S?new s_(l(S),S):null;x.rect.current=_,_&&v.set(x.id,_)}return v}return y},[e,i,n,d,l]);return k.useEffect(()=>{u.current=e},[e]),k.useEffect(()=>{d||p()},[n,d]),k.useEffect(()=>{i&&i.length>0&&s(null)},[JSON.stringify(i)]),k.useEffect(()=>{d||typeof a!="number"||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},a))},[a,d,p,...r]),{droppableRects:g,measureDroppableContainers:p,measuringScheduled:i!=null};function b(){switch(c){case wh.Always:return!1;case wh.BeforeDragging:return n;default:return!n}}}function l_(e,t){return Rp(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function ire(e,t){return l_(e,t)}function sre(e){let{callback:t,disabled:n}=e;const r=wy(t),o=k.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return k.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function Ey(e){let{callback:t,disabled:n}=e;const r=wy(t),o=k.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return k.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function are(e){return new s_(kd(e),e)}function wM(e,t,n){t===void 0&&(t=are);const[r,o]=k.useState(null);function i(){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 s=sre({callback(l){if(e)for(const c of l){const{type:u,target:d}=c;if(u==="childList"&&d instanceof HTMLElement&&d.contains(e)){i();break}}}}),a=Ey({callback:i});return Xo(()=>{i(),e?(a==null||a.observe(e),s==null||s.observe(document.body,{childList:!0,subtree:!0})):(a==null||a.disconnect(),s==null||s.disconnect())},[e]),r}function lre(e){const t=l_(e);return FF(e,t)}const CM=[];function cre(e){const t=k.useRef(e),n=Rp(r=>e?r&&r!==CM&&e&&t.current&&e.parentNode===t.current.parentNode?r:Sy(e):CM,[e]);return k.useEffect(()=>{t.current=e},[e]),n}function ure(e){const[t,n]=k.useState(null),r=k.useRef(e),o=k.useCallback(i=>{const s=Fx(i.target);s&&n(a=>a?(a.set(s,PC(s)),new Map(a)):null)},[]);return k.useEffect(()=>{const i=r.current;if(e!==i){s(i);const a=e.map(l=>{const c=Fx(l);return c?(c.addEventListener("scroll",o,{passive:!0}),[c,PC(c)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=e}return()=>{s(e),s(i)};function s(a){a.forEach(l=>{const c=Fx(l);c==null||c.removeEventListener("scroll",o)})}},[o,e]),k.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,s)=>xu(i,s),Qo):WF(e):Qo,[e,t])}function SM(e,t){t===void 0&&(t=[]);const n=k.useRef(null);return k.useEffect(()=>{n.current=null},t),k.useEffect(()=>{const r=e!==Qo;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?vh(e,n.current):Qo}function dre(e){k.useEffect(()=>{if(!xy)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 fre(e,t){return k.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=s=>{i(s,t)},n},{}),[e,t])}function YF(e){return k.useMemo(()=>e?Lne(e):null,[e])}const EM=[];function hre(e,t){t===void 0&&(t=kd);const[n]=e,r=YF(n?Sr(n):null),[o,i]=k.useState(EM);function s(){i(()=>e.length?e.map(l=>VF(l)?r:new s_(t(l),l)):EM)}const a=Ey({callback:s});return Xo(()=>{a==null||a.disconnect(),s(),e.forEach(l=>a==null?void 0:a.observe(l))},[e]),o}function KF(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return kp(t)?t:e}function pre(e){let{measure:t}=e;const[n,r]=k.useState(null),o=k.useCallback(c=>{for(const{target:u}of c)if(kp(u)){r(d=>{const h=t(u);return d?{...d,width:h.width,height:h.height}:h});break}},[t]),i=Ey({callback:o}),s=k.useCallback(c=>{const u=KF(c);i==null||i.disconnect(),u&&(i==null||i.observe(u)),r(u?t(u):null)},[t,i]),[a,l]=Db(s);return k.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const mre=[{sensor:Mp,options:{}},{sensor:Ap,options:{}}],gre={current:{}},Xg={draggable:{measure:gM},droppable:{measure:gM,strategy:wh.WhileDragging,frequency:IC.Optimized},dragOverlay:{measure:kd}};class Bf 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 bre={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Bf,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:jb},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Xg,measureDroppableContainers:jb,windowRect:null,measuringScheduled:!1},XF={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:jb,draggableNodes:new Map,over:null,measureDroppableContainers:jb},Pp=k.createContext(XF),QF=k.createContext(bre);function yre(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Bf}}}function vre(e,t){switch(t.type){case In.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case In.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 In.DragEnd:case In.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case In.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Bf(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case In.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const s=new Bf(e.droppable.containers);return s.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:s}}}case In.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new Bf(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function xre(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=k.useContext(Pp),i=Ib(r),s=Ib(n==null?void 0:n.id);return k.useEffect(()=>{if(!t&&!r&&i&&s!=null){if(!Cy(i)||document.activeElement===i.target)return;const a=o.get(s);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 d=yne(u);if(d){d.focus();break}}})}},[r,t,o,s,i]),null}function JF(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function wre(e){return k.useMemo(()=>({draggable:{...Xg.draggable,...e==null?void 0:e.draggable},droppable:{...Xg.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Xg.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 Cre(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=k.useRef(!1),{x:s,y:a}=typeof o=="boolean"?{x:o,y:o}:o;Xo(()=>{if(!s&&!a||!t){i.current=!1;return}if(i.current||!r)return;const c=t==null?void 0:t.node.current;if(!c||c.isConnected===!1)return;const u=n(c),d=FF(u,r);if(s||(d.x=0),a||(d.y=0),i.current=!0,Math.abs(d.x)>0||Math.abs(d.y)>0){const h=$F(c);h&&h.scrollBy({top:d.y,left:d.x})}},[t,s,a,r,n])}const _y=k.createContext({...Qo,scaleX:1,scaleY:1});var Ys;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Ys||(Ys={}));const c_=k.memo(function(t){var n,r,o,i;let{id:s,accessibility:a,autoScroll:l=!0,children:c,sensors:u=mre,collisionDetection:d=Dne,measuring:h,modifiers:p,...m}=t;const g=k.useReducer(vre,void 0,yre),[b,y]=g,[v,x]=Ene(),[S,_]=k.useState(Ys.Uninitialized),E=S===Ys.Initialized,{draggable:{active:C,nodes:R,translate:M},droppable:{containers:N}}=b,D=C!=null?R.get(C):null,A=k.useRef({initial:null,translated:null}),j=k.useMemo(()=>{var en;return C!=null?{id:C,data:(en=D==null?void 0:D.data)!=null?en:gre,rect:A}:null},[C,D]),O=k.useRef(null),[I,L]=k.useState(null),[F,B]=k.useState(null),z=yh(m,Object.values(m)),T=Np("DndDescribedBy",s),H=k.useMemo(()=>N.getEnabled(),[N]),V=wre(h),{droppableRects:P,measureDroppableContainers:W,measuringScheduled:$}=ore(H,{dragging:E,dependencies:[M.x,M.y],config:V.droppable}),q=nre(R,C),U=k.useMemo(()=>F?Tb(F):null,[F]),G=ho(),Y=ire(q,V.draggable.measure);Cre({activeNode:C!=null?R.get(C):null,config:G.layoutShiftCompensation,initialRect:Y,measure:V.draggable.measure});const Q=wM(q,V.draggable.measure,Y),te=wM(q?q.parentElement:null),J=k.useRef({activatorEvent:null,active:null,activeNode:q,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:R,draggingNode:null,draggingNodeRect:null,droppableContainers:N,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ie=N.getNodeFor((n=J.current.over)==null?void 0:n.id),Z=pre({measure:V.dragOverlay.measure}),ue=(r=Z.nodeRef.current)!=null?r:q,fe=E?(o=Z.rect)!=null?o:Q:null,xe=!!(Z.nodeRef.current&&Z.rect),ge=lre(xe?null:Q),be=YF(ue?Sr(ue):null),Ne=cre(E?ie??q:null),Me=hre(Ne),rt=JF(p,{transform:{x:M.x-ge.x,y:M.y-ge.y,scaleX:1,scaleY:1},activatorEvent:F,active:j,activeNodeRect:Q,containerNodeRect:te,draggingNodeRect:fe,over:J.current.over,overlayNodeRect:Z.rect,scrollableAncestors:Ne,scrollableAncestorRects:Me,windowRect:be}),Te=U?xu(U,M):null,Et=ure(Ne),qe=SM(Et),ne=SM(Et,[Q]),le=xu(rt,qe),ae=fe?jne(fe,rt):null,de=j&&ae?d({active:j,collisionRect:ae,droppableRects:P,droppableContainers:H,pointerCoordinates:Te}):null,Se=OF(de,"id"),[je,$t]=k.useState(null),Qe=xe?rt:xu(rt,ne),he=Ine(Qe,(i=je==null?void 0:je.rect)!=null?i:null,Q),Ot=k.useRef(null),Ye=k.useCallback((en,wt)=>{let{sensor:En,options:Ie}=wt;if(O.current==null)return;const Be=R.get(O.current);if(!Be)return;const Ke=en.nativeEvent,Wt=new En({active:O.current,activeNode:Be,event:Ke,options:Ie,context:J,onAbort(Rt){if(!R.get(Rt))return;const{onDragAbort:Ut}=z.current,fn={id:Rt};Ut==null||Ut(fn),v({type:"onDragAbort",event:fn})},onPending(Rt,wn,Ut,fn){if(!R.get(Rt))return;const{onDragPending:po}=z.current,li={id:Rt,constraint:wn,initialCoordinates:Ut,offset:fn};po==null||po(li),v({type:"onDragPending",event:li})},onStart(Rt){const wn=O.current;if(wn==null)return;const Ut=R.get(wn);if(!Ut)return;const{onDragStart:fn}=z.current,Ga={activatorEvent:Ke,active:{id:wn,data:Ut.data,rect:A}};un.unstable_batchedUpdates(()=>{fn==null||fn(Ga),_(Ys.Initializing),y({type:In.DragStart,initialCoordinates:Rt,active:wn}),v({type:"onDragStart",event:Ga}),L(Ot.current),B(Ke)})},onMove(Rt){y({type:In.DragMove,coordinates:Rt})},onEnd:kt(In.DragEnd),onCancel:kt(In.DragCancel)});Ot.current=Wt;function kt(Rt){return async function(){const{active:Ut,collisions:fn,over:Ga,scrollAdjustedTranslate:po}=J.current;let li=null;if(Ut&&po){const{cancelDrop:qa}=z.current;li={activatorEvent:Ke,active:Ut,collisions:fn,delta:po,over:Ga},Rt===In.DragEnd&&typeof qa=="function"&&await Promise.resolve(qa(li))&&(Rt=In.DragCancel)}O.current=null,un.unstable_batchedUpdates(()=>{y({type:Rt}),_(Ys.Uninitialized),$t(null),L(null),B(null),Ot.current=null;const qa=Rt===In.DragEnd?"onDragEnd":"onDragCancel";if(li){const Yd=z.current[qa];Yd==null||Yd(li),v({type:qa,event:li})}})}}},[R]),_t=k.useCallback((en,wt)=>(En,Ie)=>{const Be=En.nativeEvent,Ke=R.get(Ie);if(O.current!==null||!Ke||Be.dndKit||Be.defaultPrevented)return;const Wt={active:Ke};en(En,wt.options,Wt)===!0&&(Be.dndKit={capturedBy:wt.sensor},O.current=Ie,Ye(En,wt))},[R,Ye]),Ft=rre(u,_t);dre(u),Xo(()=>{Q&&S===Ys.Initializing&&_(Ys.Initialized)},[Q,S]),k.useEffect(()=>{const{onDragMove:en}=z.current,{active:wt,activatorEvent:En,collisions:Ie,over:Be}=J.current;if(!wt||!En)return;const Ke={active:wt,activatorEvent:En,collisions:Ie,delta:{x:le.x,y:le.y},over:Be};un.unstable_batchedUpdates(()=>{en==null||en(Ke),v({type:"onDragMove",event:Ke})})},[le.x,le.y]),k.useEffect(()=>{const{active:en,activatorEvent:wt,collisions:En,droppableContainers:Ie,scrollAdjustedTranslate:Be}=J.current;if(!en||O.current==null||!wt||!Be)return;const{onDragOver:Ke}=z.current,Wt=Ie.get(Se),kt=Wt&&Wt.rect.current?{id:Wt.id,rect:Wt.rect.current,data:Wt.data,disabled:Wt.disabled}:null,Rt={active:en,activatorEvent:wt,collisions:En,delta:{x:Be.x,y:Be.y},over:kt};un.unstable_batchedUpdates(()=>{$t(kt),Ke==null||Ke(Rt),v({type:"onDragOver",event:Rt})})},[Se]),Xo(()=>{J.current={activatorEvent:F,active:j,activeNode:q,collisionRect:ae,collisions:de,droppableRects:P,draggableNodes:R,draggingNode:ue,draggingNodeRect:fe,droppableContainers:N,over:je,scrollableAncestors:Ne,scrollAdjustedTranslate:le},A.current={initial:fe,translated:ae}},[j,q,de,ae,R,ue,fe,P,N,je,Ne,le]),Zne({...G,delta:M,draggingRect:ae,pointerCoordinates:Te,scrollableAncestors:Ne,scrollableAncestorRects:Me});const jn=k.useMemo(()=>({active:j,activeNode:q,activeNodeRect:Q,activatorEvent:F,collisions:de,containerNodeRect:te,dragOverlay:Z,draggableNodes:R,droppableContainers:N,droppableRects:P,over:je,measureDroppableContainers:W,scrollableAncestors:Ne,scrollableAncestorRects:Me,measuringConfiguration:V,measuringScheduled:$,windowRect:be}),[j,q,Q,F,de,te,Z,R,N,P,je,W,Ne,Me,V,$,be]),ai=k.useMemo(()=>({activatorEvent:F,activators:Ft,active:j,activeNodeRect:Q,ariaDescribedById:{draggable:T},dispatch:y,draggableNodes:R,over:je,measureDroppableContainers:W}),[F,Ft,j,Q,y,T,R,je,W]);return k.createElement(IF.Provider,{value:x},k.createElement(Pp.Provider,{value:ai},k.createElement(QF.Provider,{value:jn},k.createElement(_y.Provider,{value:he},c)),k.createElement(xre,{disabled:(a==null?void 0:a.restoreFocus)===!1})),k.createElement(Rne,{...a,hiddenTextDescribedById:T}));function ho(){const en=(I==null?void 0:I.autoScrollEnabled)===!1,wt=typeof l=="object"?l.enabled===!1:l===!1,En=E&&!en&&!wt;return typeof l=="object"?{...l,enabled:En}:{enabled:En}}}),Sre=k.createContext(null),_M="button",Ere="Draggable";function ZF(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=Np(Ere),{activators:s,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:d,over:h}=k.useContext(Pp),{role:p=_M,roleDescription:m="draggable",tabIndex:g=0}=o??{},b=(l==null?void 0:l.id)===t,y=k.useContext(b?_y:Sre),[v,x]=Db(),[S,_]=Db(),E=fre(s,t),C=yh(n);Xo(()=>(d.set(t,{id:t,key:i,node:v,activatorNode:S,data:C}),()=>{const M=d.get(t);M&&M.key===i&&d.delete(t)}),[d,t]);const R=k.useMemo(()=>({role:p,tabIndex:g,"aria-disabled":r,"aria-pressed":b&&p===_M?!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:R,isDragging:b,listeners:r?void 0:E,node:v,over:h,setNodeRef:x,setActivatorNodeRef:_,transform:y}}function e3(){return k.useContext(QF)}const _re="Droppable",kre={timeout:25};function t3(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=Np(_re),{active:s,dispatch:a,over:l,measureDroppableContainers:c}=k.useContext(Pp),u=k.useRef({disabled:n}),d=k.useRef(!1),h=k.useRef(null),p=k.useRef(null),{disabled:m,updateMeasurementsFor:g,timeout:b}={...kre,...o},y=yh(g??r),v=k.useCallback(()=>{if(!d.current){d.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]),x=Ey({callback:v,disabled:m||!s}),S=k.useCallback((R,M)=>{x&&(M&&(x.unobserve(M),d.current=!1),R&&x.observe(R))},[x]),[_,E]=Db(S),C=yh(t);return k.useEffect(()=>{!x||!_.current||(x.disconnect(),d.current=!1,x.observe(_.current))},[_,x]),k.useEffect(()=>(a({type:In.RegisterDroppable,element:{id:r,key:i,disabled:n,node:_,rect:h,data:C}}),()=>a({type:In.UnregisterDroppable,key:i,id:r})),[r]),k.useEffect(()=>{n!==u.current.disabled&&(a({type:In.SetDroppableDisabled,id:r,key:i,disabled:n}),u.current.disabled=n)},[r,i,n,a]),{active:s,rect:h,isOver:(l==null?void 0:l.id)===r,node:_,over:l,setNodeRef:E}}function Rre(e){let{animation:t,children:n}=e;const[r,o]=k.useState(null),[i,s]=k.useState(null),a=Ib(n);return!n&&!r&&a&&o(a),Xo(()=>{if(!i)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,i)).then(()=>{o(null)})},[t,r,i]),k.createElement(k.Fragment,null,n,r?k.cloneElement(r,{ref:s}):null)}const Nre={x:0,y:0,scaleX:1,scaleY:1};function Are(e){let{children:t}=e;return k.createElement(Pp.Provider,{value:XF},k.createElement(_y.Provider,{value:Nre},t))}const Mre={position:"fixed",touchAction:"none"},Pre=e=>Cy(e)?"transform 250ms ease":void 0,Dre=k.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:i,className:s,rect:a,style:l,transform:c,transition:u=Pre}=e;if(!a)return null;const d=o?c:{...c,scaleX:1,scaleY:1},h={...Mre,width:a.width,height:a.height,top:a.top,left:a.left,transform:Di.Transform.toString(d),transformOrigin:o&&r?Nne(r,a):void 0,transition:typeof u=="function"?u(r):u,...l};return k.createElement(n,{className:s,style:h,ref:t},i)}),Ire=e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:i,className:s}=e;if(i!=null&&i.active)for(const[a,l]of Object.entries(i.active))l!==void 0&&(o[a]=n.node.style.getPropertyValue(a),n.node.style.setProperty(a,l));if(i!=null&&i.dragOverlay)for(const[a,l]of Object.entries(i.dragOverlay))l!==void 0&&r.node.style.setProperty(a,l);return s!=null&&s.active&&n.node.classList.add(s.active),s!=null&&s.dragOverlay&&r.node.classList.add(s.dragOverlay),function(){for(const[l,c]of Object.entries(o))n.node.style.setProperty(l,c);s!=null&&s.active&&n.node.classList.remove(s.active)}},Tre=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Di.Transform.toString(t)},{transform:Di.Transform.toString(n)}]},jre={duration:250,easing:"ease",keyframes:Tre,sideEffects:Ire({styles:{active:{opacity:"0"}}})};function Ore(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return wy((i,s)=>{if(t===null)return;const a=n.get(i);if(!a)return;const l=a.node.current;if(!l)return;const c=KF(s);if(!c)return;const{transform:u}=Sr(s).getComputedStyle(s),d=LF(u);if(!d)return;const h=typeof t=="function"?t:Fre(t);return UF(l,o.draggable.measure),h({active:{id:i,data:a.data,node:l,rect:o.draggable.measure(l)},draggableNodes:n,dragOverlay:{node:s,rect:o.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:o,transform:d})})}function Fre(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...jre,...e};return i=>{let{active:s,dragOverlay:a,transform:l,...c}=i;if(!t)return;const u={x:a.rect.left-s.rect.left,y:a.rect.top-s.rect.top},d={scaleX:l.scaleX!==1?s.rect.width*l.scaleX/a.rect.width:1,scaleY:l.scaleY!==1?s.rect.height*l.scaleY/a.rect.height:1},h={x:l.x-u.x,y:l.y-u.y,...d},p=o({...c,active:s,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:s,dragOverlay:a,...c}),y=a.node.animate(p,{duration:t,easing:n,fill:"forwards"});return new Promise(v=>{y.onfinish=()=>{b==null||b(),v()}})}}let kM=0;function Lre(e){return k.useMemo(()=>{if(e!=null)return kM++,kM},[e])}const n3=k.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:o,transition:i,modifiers:s,wrapperElement:a="div",className:l,zIndex:c=999}=e;const{activatorEvent:u,active:d,activeNodeRect:h,containerNodeRect:p,draggableNodes:m,droppableContainers:g,dragOverlay:b,over:y,measuringConfiguration:v,scrollableAncestors:x,scrollableAncestorRects:S,windowRect:_}=e3(),E=k.useContext(_y),C=Lre(d==null?void 0:d.id),R=JF(s,{activatorEvent:u,active:d,activeNodeRect:h,containerNodeRect:p,draggingNodeRect:b.rect,over:y,overlayNodeRect:b.rect,scrollableAncestors:x,scrollableAncestorRects:S,transform:E,windowRect:_}),M=l_(h),N=Ore({config:r,draggableNodes:m,droppableContainers:g,measuringConfiguration:v}),D=M?b.setRef:void 0;return k.createElement(Are,null,k.createElement(Rre,{animation:N},d&&C?k.createElement(Dre,{key:C,id:d.id,ref:D,as:a,activatorEvent:u,adjustScale:t,className:l,transition:i,rect:M,style:{zIndex:c,...o},transform:R},n):null))});function Dp(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function $re(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function Bm(e){return e!==null&&e>=0}function zre(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 Bre(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Vm={scaleX:1,scaleY:1},Vre=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:o,overIndex:i,index:s}=e;const a=(t=n[o])!=null?t:r;if(!a)return null;const l=Hre(n,s,o);if(s===o){const c=n[i];return c?{x:o<i?c.left+c.width-(a.left+a.width):c.left-a.left,y:0,...Vm}:null}return s>o&&s<=i?{x:-a.width-l,y:0,...Vm}:s<o&&s>=i?{x:a.width+l,y:0,...Vm}:{x:0,y:0,...Vm}};function Hre(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return!r||!o&&!i?0:n<t?o?r.left-(o.left+o.width):i.left-(r.left+r.width):i?i.left-(r.left+r.width):r.left-(o.left+o.width)}const r3=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=Dp(t,r,n),s=t[o],a=i[o];return!a||!s?null:{x:a.left-s.left,y:a.top-s.top,scaleX:a.width/s.width,scaleY:a.height/s.height}},Hm={scaleX:1,scaleY:1},o3=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:i,overIndex:s}=e;const a=(t=i[n])!=null?t:r;if(!a)return null;if(o===n){const c=i[s];return c?{x:0,y:n<s?c.top+c.height-(a.top+a.height):c.top-a.top,...Hm}:null}const l=Wre(i,o,n);return o>n&&o<=s?{x:0,y:-a.height-l,...Hm}:o<n&&o>=s?{x:0,y:a.height+l,...Hm}:{x:0,y:0,...Hm}};function Wre(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return r?n<t?o?r.top-(o.top+o.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const i3="Sortable",s3=k.createContext({activeIndex:-1,containerId:i3,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:r3,disabled:{draggable:!1,droppable:!1}});function u_(e){let{children:t,id:n,items:r,strategy:o=r3,disabled:i=!1}=e;const{active:s,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:u}=e3(),d=Np(i3,n),h=a.rect!==null,p=k.useMemo(()=>r.map(E=>typeof E=="object"&&"id"in E?E.id:E),[r]),m=s!=null,g=s?p.indexOf(s.id):-1,b=c?p.indexOf(c.id):-1,y=k.useRef(p),v=!zre(p,y.current),x=b!==-1&&g===-1||v,S=Bre(i);Xo(()=>{v&&m&&u(p)},[v,p,m,u]),k.useEffect(()=>{y.current=p},[p]);const _=k.useMemo(()=>({activeIndex:g,containerId:d,disabled:S,disableTransforms:x,items:p,overIndex:b,useDragOverlay:h,sortedRects:$re(p,l),strategy:o}),[g,d,S.draggable,S.droppable,x,p,b,l,h,o]);return k.createElement(s3.Provider,{value:_},t)}const Ure=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return Dp(n,r,o).indexOf(t)},Gre=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:s,previousItems:a,previousContainerId:l,transition:c}=e;return!c||!r||a!==i&&o===s?!1:n?!0:s!==o&&t===l},qre={duration:200,easing:"ease"},a3="transform",Yre=Di.Transition.toString({property:a3,duration:0,easing:"linear"}),Kre={roleDescription:"sortable"};function Xre(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,s]=k.useState(null),a=k.useRef(n);return Xo(()=>{if(!t&&n!==a.current&&r.current){const l=o.current;if(l){const c=kd(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)&&s(u)}}n!==a.current&&(a.current=n)},[t,n,r,o]),k.useEffect(()=>{i&&s(null)},[i]),i}function d_(e){let{animateLayoutChanges:t=Gre,attributes:n,disabled:r,data:o,getNewIndex:i=Ure,id:s,strategy:a,resizeObserverConfig:l,transition:c=qre}=e;const{items:u,containerId:d,activeIndex:h,disabled:p,disableTransforms:m,sortedRects:g,overIndex:b,useDragOverlay:y,strategy:v}=k.useContext(s3),x=Qre(r,p),S=u.indexOf(s),_=k.useMemo(()=>({sortable:{containerId:d,index:S,items:u},...o}),[d,o,S,u]),E=k.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:C,node:R,isOver:M,setNodeRef:N}=t3({id:s,data:_,disabled:x.droppable,resizeObserverConfig:{updateMeasurementsFor:E,...l}}),{active:D,activatorEvent:A,activeNodeRect:j,attributes:O,setNodeRef:I,listeners:L,isDragging:F,over:B,setActivatorNodeRef:z,transform:T}=ZF({id:s,data:_,attributes:{...Kre,...n},disabled:x.draggable}),H=pne(N,I),V=!!D,P=V&&!m&&Bm(h)&&Bm(b),W=!y&&F,$=W&&P?T:null,U=P?$??(a??v)({rects:g,activeNodeRect:j,activeIndex:h,overIndex:b,index:S}):null,G=Bm(h)&&Bm(b)?i({id:s,items:u,activeIndex:h,overIndex:b}):S,Y=D==null?void 0:D.id,Q=k.useRef({activeId:Y,items:u,newIndex:G,containerId:d}),te=u!==Q.current.items,J=t({active:D,containerId:d,isDragging:F,isSorting:V,id:s,index:S,items:u,newIndex:Q.current.newIndex,previousItems:Q.current.items,previousContainerId:Q.current.containerId,transition:c,wasDragging:Q.current.activeId!=null}),ie=Xre({disabled:!J,index:S,node:R,rect:C});return k.useEffect(()=>{V&&Q.current.newIndex!==G&&(Q.current.newIndex=G),d!==Q.current.containerId&&(Q.current.containerId=d),u!==Q.current.items&&(Q.current.items=u)},[V,G,d,u]),k.useEffect(()=>{if(Y===Q.current.activeId)return;if(Y!=null&&Q.current.activeId==null){Q.current.activeId=Y;return}const ue=setTimeout(()=>{Q.current.activeId=Y},50);return()=>clearTimeout(ue)},[Y]),{active:D,activeIndex:h,attributes:O,data:_,rect:C,index:S,newIndex:G,items:u,isOver:M,isSorting:V,isDragging:F,listeners:L,node:R,overIndex:b,over:B,setNodeRef:H,setActivatorNodeRef:z,setDroppableNodeRef:N,setDraggableNodeRef:I,transform:ie??U,transition:Z()};function Z(){if(ie||te&&Q.current.newIndex===S)return Yre;if(!(W&&!Cy(A)||!c)&&(V||J))return Di.Transition.toString({...c,property:a3})}}function Qre(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 Fb(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 Jre=[gt.Down,gt.Right,gt.Up,gt.Left],f_=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:s,scrollableAncestors:a}}=t;if(Jre.includes(e.code)){if(e.preventDefault(),!n||!r)return;const l=[];i.getEnabled().forEach(d=>{if(!d||d!=null&&d.disabled)return;const h=o.get(d.id);if(h)switch(e.code){case gt.Down:r.top<h.top&&l.push(d);break;case gt.Up:r.top>h.top&&l.push(d);break;case gt.Left:r.left>h.left&&l.push(d);break;case gt.Right:r.left<h.left&&l.push(d);break}});const c=Mne({collisionRect:r,droppableRects:o,droppableContainers:l});let u=OF(c,"id");if(u===(s==null?void 0:s.id)&&c.length>1&&(u=c[1].id),u!=null){const d=i.get(n.id),h=i.get(u),p=h?o.get(h.id):null,m=h==null?void 0:h.node.current;if(m&&p&&d&&h){const b=Sy(m).some((E,C)=>a[C]!==E),y=l3(d,h),v=Zre(d,h),x=b||!y?{x:0,y:0}:{x:v?r.width-p.width:0,y:v?r.height-p.height:0},S={x:p.left,y:p.top};return x.x&&x.y?S:vh(S,x)}}}};function l3(e,t){return!Fb(e)||!Fb(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Zre(e,t){return!Fb(e)||!Fb(t)||!l3(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function eoe(e,t,n){const[r,o]=k.useState(null),[i,s]=k.useState(""),a=()=>{const m={id:`hierarchy_${Date.now()}`,label:i||"New Hierarchy",type:"static",steps:[],default:!1};t([...e,m]),s(""),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:i,setNewHierarchyName:s,createNewHierarchy:a,deleteHierarchy:l,updateHierarchy:c,addStepToHierarchy:(m,g)=>{const b=n.find(x=>x.id===g);if(!b)return;const y={field:b,mode:"drillDown",label:`Drill to ${b.label}`,retainFilters:!0,preferredChartType:"bar"},v=e.find(x=>x.id===m);v&&c(m,{steps:[...v.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(v=>v.id===m);if(y){const v=y.steps.map((x,S)=>S===g?{...x,...b}:x);c(m,{steps:v})}},setDefaultHierarchy:m=>{t(e.map(g=>({...g,default:g.id===m})))}}}function toe({value:e,isEditing:t,onEdit:n,onSave:r,onCancel:o,placeholder:i="Enter text...",inputClassName:s="",displayClassName:a=""}){const[l,c]=k.useState(e);k.useEffect(()=>{c(e)},[e]);const u=m=>{m.key===" "&&m.stopPropagation(),m.key==="Enter"?r(l):m.key==="Escape"&&(c(e),o())},d=()=>{r(l)},h=m=>{m.stopPropagation()},p=m=>{m.stopPropagation()};return t?f.jsx("input",{type:"text",value:l,onChange:m=>c(m.target.value),onKeyDown:u,onBlur:d,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 ${s}`,placeholder:i,autoFocus:!0}):f.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||i})}function noe(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e);w.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 roe="DismissableLayer",TC="dismissableLayer.update",ooe="dismissableLayer.pointerDownOutside",ioe="dismissableLayer.focusOutside",RM,c3=w.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_c=w.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:a,...l}=e,c=w.useContext(c3),[u,d]=w.useState(null),h=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=w.useState({}),m=We(t,C=>d(C)),g=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(b),v=u?g.indexOf(u):-1,x=c.layersWithOutsidePointerEventsDisabled.size>0,S=v>=y,_=loe(C=>{const R=C.target,M=[...c.branches].some(N=>N.contains(R));!S||M||(o==null||o(C),s==null||s(C),C.defaultPrevented||a==null||a())},h),E=coe(C=>{const R=C.target;[...c.branches].some(N=>N.contains(R))||(i==null||i(C),s==null||s(C),C.defaultPrevented||a==null||a())},h);return noe(C=>{v===c.layers.size-1&&(r==null||r(C),!C.defaultPrevented&&a&&(C.preventDefault(),a()))},h),w.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(RM=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),NM(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=RM)}},[u,h,n,c]),w.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),NM())},[u,c]),w.useEffect(()=>{const C=()=>p({});return document.addEventListener(TC,C),()=>document.removeEventListener(TC,C)},[]),f.jsx(Re.div,{...l,ref:m,style:{pointerEvents:x?S?"auto":"none":void 0,...e.style},onFocusCapture:pe(e.onFocusCapture,E.onFocusCapture),onBlurCapture:pe(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:pe(e.onPointerDownCapture,_.onPointerDownCapture)})});_c.displayName=roe;var soe="DismissableLayerBranch",aoe=w.forwardRef((e,t)=>{const n=w.useContext(c3),r=w.useRef(null),o=We(t,r);return w.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),f.jsx(Re.div,{...e,ref:o})});aoe.displayName=soe;function loe(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e),r=w.useRef(!1),o=w.useRef(()=>{});return w.useEffect(()=>{const i=a=>{if(a.target&&!r.current){let l=function(){u3(ooe,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},s=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function coe(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e),r=w.useRef(!1);return w.useEffect(()=>{const o=i=>{i.target&&!r.current&&u3(ioe,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function NM(){const e=new CustomEvent(TC);document.dispatchEvent(e)}function u3(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?c5(o,i):o.dispatchEvent(i)}var zx=0;function ky(){w.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??AM()),document.body.insertAdjacentElement("beforeend",e[1]??AM()),zx++,()=>{zx===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),zx--}},[])}function AM(){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 Bx="focusScope.autoFocusOnMount",Vx="focusScope.autoFocusOnUnmount",MM={bubbles:!1,cancelable:!0},uoe="FocusScope",Ip=w.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=e,[a,l]=w.useState(null),c=Mn(o),u=Mn(i),d=w.useRef(null),h=We(t,g=>l(g)),p=w.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;w.useEffect(()=>{if(r){let g=function(x){if(p.paused||!a)return;const S=x.target;a.contains(S)?d.current=S:Gs(d.current,{select:!0})},b=function(x){if(p.paused||!a)return;const S=x.relatedTarget;S!==null&&(a.contains(S)||Gs(d.current,{select:!0}))},y=function(x){if(document.activeElement===document.body)for(const _ of x)_.removedNodes.length>0&&Gs(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",b);const v=new MutationObserver(y);return a&&v.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",b),v.disconnect()}}},[r,a,p.paused]),w.useEffect(()=>{if(a){DM.add(p);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Bx,MM);a.addEventListener(Bx,c),a.dispatchEvent(y),y.defaultPrevented||(doe(goe(d3(a)),{select:!0}),document.activeElement===g&&Gs(a))}return()=>{a.removeEventListener(Bx,c),setTimeout(()=>{const y=new CustomEvent(Vx,MM);a.addEventListener(Vx,u),a.dispatchEvent(y),y.defaultPrevented||Gs(g??document.body,{select:!0}),a.removeEventListener(Vx,u),DM.remove(p)},0)}}},[a,c,u,p]);const m=w.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 v=g.currentTarget,[x,S]=foe(v);x&&S?!g.shiftKey&&y===S?(g.preventDefault(),n&&Gs(x,{select:!0})):g.shiftKey&&y===x&&(g.preventDefault(),n&&Gs(S,{select:!0})):y===v&&g.preventDefault()}},[n,r,p.paused]);return f.jsx(Re.div,{tabIndex:-1,...s,ref:h,onKeyDown:m})});Ip.displayName=uoe;function doe(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Gs(r,{select:t}),document.activeElement!==n)return}function foe(e){const t=d3(e),n=PM(t,e),r=PM(t.reverse(),e);return[n,r]}function d3(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 PM(e,t){for(const n of e)if(!hoe(n,{upTo:t}))return n}function hoe(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 poe(e){return e instanceof HTMLInputElement&&"select"in e}function Gs(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&poe(e)&&t&&e.select()}}var DM=moe();function moe(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=IM(e,t),e.unshift(t)},remove(t){var n;e=IM(e,t),(n=e[0])==null||n.resume()}}}function IM(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function goe(e){return e.filter(t=>t.tagName!=="A")}const boe=["top","right","bottom","left"],ks=Math.min,tr=Math.max,Ch=Math.round,Wm=Math.floor,Ci=e=>({x:e,y:e}),yoe={left:"right",right:"left",bottom:"top",top:"bottom"},voe={start:"end",end:"start"};function jC(e,t,n){return tr(e,ks(t,n))}function Ii(e,t){return typeof e=="function"?e(t):e}function Rs(e){return e.split("-")[0]}function Rd(e){return e.split("-")[1]}function h_(e){return e==="x"?"y":"x"}function p_(e){return e==="y"?"height":"width"}function xa(e){return["top","bottom"].includes(Rs(e))?"y":"x"}function m_(e){return h_(xa(e))}function xoe(e,t,n){n===void 0&&(n=!1);const r=Rd(e),o=m_(e),i=p_(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=Lb(s)),[s,Lb(s)]}function woe(e){const t=Lb(e);return[OC(e),t,OC(t)]}function OC(e){return e.replace(/start|end/g,t=>voe[t])}function Coe(e,t,n){const r=["left","right"],o=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?i:s;default:return[]}}function Soe(e,t,n,r){const o=Rd(e);let i=Coe(Rs(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(OC)))),i}function Lb(e){return e.replace(/left|right|bottom|top/g,t=>yoe[t])}function Eoe(e){return{top:0,right:0,bottom:0,left:0,...e}}function f3(e){return typeof e!="number"?Eoe(e):{top:e,right:e,bottom:e,left:e}}function $b(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 TM(e,t,n){let{reference:r,floating:o}=e;const i=xa(t),s=m_(t),a=p_(s),l=Rs(t),c=i==="y",u=r.x+r.width/2-o.width/2,d=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:d};break;case"left":p={x:r.x-o.width,y:d};break;default:p={x:r.x,y:r.y}}switch(Rd(t)){case"start":p[s]-=h*(n&&c?-1:1);break;case"end":p[s]+=h*(n&&c?-1:1);break}return p}const _oe=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,a=i.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=TM(c,r,l),h=r,p={},m=0;for(let g=0;g<a.length;g++){const{name:b,fn:y}=a[g],{x:v,y:x,data:S,reset:_}=await y({x:u,y:d,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:s,elements:{reference:e,floating:t}});u=v??u,d=x??d,p={...p,[b]:{...p[b],...S}},_&&m<=50&&(m++,typeof _=="object"&&(_.placement&&(h=_.placement),_.rects&&(c=_.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):_.rects),{x:u,y:d}=TM(c,h,l)),g=-1)}return{x:u,y:d,placement:h,strategy:o,middlewareData:p}};async function ed(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:s,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:p=0}=Ii(t,e),m=f3(p),b=a[h?d==="floating"?"reference":"floating":d],y=$b(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(b)))==null||n?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),v=d==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,x=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),S=await(i.isElement==null?void 0:i.isElement(x))?await(i.getScale==null?void 0:i.getScale(x))||{x:1,y:1}:{x:1,y:1},_=$b(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:x,strategy:l}):v);return{top:(y.top-_.top+m.top)/S.y,bottom:(_.bottom-y.bottom+m.bottom)/S.y,left:(y.left-_.left+m.left)/S.x,right:(_.right-y.right+m.right)/S.x}}const koe=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:s,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=Ii(e,t)||{};if(c==null)return{};const d=f3(u),h={x:n,y:r},p=m_(o),m=p_(p),g=await s.getDimensions(c),b=p==="y",y=b?"top":"left",v=b?"bottom":"right",x=b?"clientHeight":"clientWidth",S=i.reference[m]+i.reference[p]-h[p]-i.floating[m],_=h[p]-i.reference[p],E=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c));let C=E?E[x]:0;(!C||!await(s.isElement==null?void 0:s.isElement(E)))&&(C=a.floating[x]||i.floating[m]);const R=S/2-_/2,M=C/2-g[m]/2-1,N=ks(d[y],M),D=ks(d[v],M),A=N,j=C-g[m]-D,O=C/2-g[m]/2+R,I=jC(A,O,j),L=!l.arrow&&Rd(o)!=null&&O!==I&&i.reference[m]/2-(O<A?N:D)-g[m]/2<0,F=L?O<A?O-A:O-j:0;return{[p]:h[p]+F,data:{[p]:I,centerOffset:O-I-F,...L&&{alignmentOffset:F}},reset:L}}}),Roe=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...b}=Ii(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=Rs(o),v=xa(a),x=Rs(a)===a,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),_=h||(x||!g?[Lb(a)]:woe(a)),E=m!=="none";!h&&E&&_.push(...Soe(a,g,m,S));const C=[a,..._],R=await ed(t,b),M=[];let N=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&M.push(R[y]),d){const O=xoe(o,s,S);M.push(R[O[0]],R[O[1]])}if(N=[...N,{placement:o,overflows:M}],!M.every(O=>O<=0)){var D,A;const O=(((D=i.flip)==null?void 0:D.index)||0)+1,I=C[O];if(I)return{data:{index:O,overflows:N},reset:{placement:I}};let L=(A=N.filter(F=>F.overflows[0]<=0).sort((F,B)=>F.overflows[1]-B.overflows[1])[0])==null?void 0:A.placement;if(!L)switch(p){case"bestFit":{var j;const F=(j=N.filter(B=>{if(E){const z=xa(B.placement);return z===v||z==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(z=>z>0).reduce((z,T)=>z+T,0)]).sort((B,z)=>B[1]-z[1])[0])==null?void 0:j[0];F&&(L=F);break}case"initialPlacement":L=a;break}if(o!==L)return{reset:{placement:L}}}return{}}}};function jM(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function OM(e){return boe.some(t=>e[t]>=0)}const Noe=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Ii(e,t);switch(r){case"referenceHidden":{const i=await ed(t,{...o,elementContext:"reference"}),s=jM(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:OM(s)}}}case"escaped":{const i=await ed(t,{...o,altBoundary:!0}),s=jM(i,n.floating);return{data:{escapedOffsets:s,escaped:OM(s)}}}default:return{}}}}};async function Aoe(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=Rs(n),a=Rd(n),l=xa(n)==="y",c=["left","top"].includes(s)?-1:1,u=i&&l?-1:1,d=Ii(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.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 Moe=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:a}=t,l=await Aoe(t,e);return s===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:i+l.y,data:{...l,placement:s}}}}},Poe=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:a={fn:b=>{let{x:y,y:v}=b;return{x:y,y:v}}},...l}=Ii(e,t),c={x:n,y:r},u=await ed(t,l),d=xa(Rs(o)),h=h_(d);let p=c[h],m=c[d];if(i){const b=h==="y"?"top":"left",y=h==="y"?"bottom":"right",v=p+u[b],x=p-u[y];p=jC(v,p,x)}if(s){const b=d==="y"?"top":"left",y=d==="y"?"bottom":"right",v=m+u[b],x=m-u[y];m=jC(v,m,x)}const g=a.fn({...t,[h]:p,[d]:m});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[h]:i,[d]:s}}}}}},Doe=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Ii(e,t),u={x:n,y:r},d=xa(o),h=h_(d);let p=u[h],m=u[d];const g=Ii(a,t),b=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const x=h==="y"?"height":"width",S=i.reference[h]-i.floating[x]+b.mainAxis,_=i.reference[h]+i.reference[x]-b.mainAxis;p<S?p=S:p>_&&(p=_)}if(c){var y,v;const x=h==="y"?"width":"height",S=["top","left"].includes(Rs(o)),_=i.reference[d]-i.floating[x]+(S&&((y=s.offset)==null?void 0:y[d])||0)+(S?0:b.crossAxis),E=i.reference[d]+i.reference[x]+(S?0:((v=s.offset)==null?void 0:v[d])||0)-(S?b.crossAxis:0);m<_?m=_:m>E&&(m=E)}return{[h]:p,[d]:m}}}},Ioe=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:s,elements:a}=t,{apply:l=()=>{},...c}=Ii(e,t),u=await ed(t,c),d=Rs(o),h=Rd(o),p=xa(o)==="y",{width:m,height:g}=i.floating;let b,y;d==="top"||d==="bottom"?(b=d,y=h===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(y=d,b=h==="end"?"top":"bottom");const v=g-u.top-u.bottom,x=m-u.left-u.right,S=ks(g-u[b],v),_=ks(m-u[y],x),E=!t.middlewareData.shift;let C=S,R=_;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(R=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),E&&!h){const N=tr(u.left,0),D=tr(u.right,0),A=tr(u.top,0),j=tr(u.bottom,0);p?R=m-2*(N!==0||D!==0?N+D:tr(u.left,u.right)):C=g-2*(A!==0||j!==0?A+j:tr(u.top,u.bottom))}await l({...t,availableWidth:R,availableHeight:C});const M=await s.getDimensions(a.floating);return m!==M.width||g!==M.height?{reset:{rects:!0}}:{}}}};function Ry(){return typeof window<"u"}function Nd(e){return h3(e)?(e.nodeName||"").toLowerCase():"#document"}function io(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Wi(e){var t;return(t=(h3(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function h3(e){return Ry()?e instanceof Node||e instanceof io(e).Node:!1}function nr(e){return Ry()?e instanceof Element||e instanceof io(e).Element:!1}function Ti(e){return Ry()?e instanceof HTMLElement||e instanceof io(e).HTMLElement:!1}function FM(e){return!Ry()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof io(e).ShadowRoot}function Tp(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Jo(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function Toe(e){return["table","td","th"].includes(Nd(e))}function Ny(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function g_(e){const t=b_(),n=nr(e)?Jo(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 joe(e){let t=wa(e);for(;Ti(t)&&!td(t);){if(g_(t))return t;if(Ny(t))return null;t=wa(t)}return null}function b_(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function td(e){return["html","body","#document"].includes(Nd(e))}function Jo(e){return io(e).getComputedStyle(e)}function Ay(e){return nr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function wa(e){if(Nd(e)==="html")return e;const t=e.assignedSlot||e.parentNode||FM(e)&&e.host||Wi(e);return FM(t)?t.host:t}function p3(e){const t=wa(e);return td(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ti(t)&&Tp(t)?t:p3(t)}function Sh(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=p3(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=io(o);if(i){const a=FC(s);return t.concat(s,s.visualViewport||[],Tp(o)?o:[],a&&n?Sh(a):[])}return t.concat(o,Sh(o,[],n))}function FC(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function m3(e){const t=Jo(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ti(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=Ch(n)!==i||Ch(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function y_(e){return nr(e)?e:e.contextElement}function wu(e){const t=y_(e);if(!Ti(t))return Ci(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=m3(t);let s=(i?Ch(n.width):n.width)/r,a=(i?Ch(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const Ooe=Ci(0);function g3(e){const t=io(e);return!b_()||!t.visualViewport?Ooe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Foe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==io(e)?!1:t}function Zl(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=y_(e);let s=Ci(1);t&&(r?nr(r)&&(s=wu(r)):s=wu(e));const a=Foe(i,n,r)?g3(i):Ci(0);let l=(o.left+a.x)/s.x,c=(o.top+a.y)/s.y,u=o.width/s.x,d=o.height/s.y;if(i){const h=io(i),p=r&&nr(r)?io(r):r;let m=h,g=FC(m);for(;g&&r&&p!==m;){const b=wu(g),y=g.getBoundingClientRect(),v=Jo(g),x=y.left+(g.clientLeft+parseFloat(v.paddingLeft))*b.x,S=y.top+(g.clientTop+parseFloat(v.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,d*=b.y,l+=x,c+=S,m=io(g),g=FC(m)}}return $b({width:u,height:d,x:l,y:c})}function v_(e,t){const n=Ay(e).scrollLeft;return t?t.left+n:Zl(Wi(e)).left+n}function b3(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:v_(e,r)),i=r.top+t.scrollTop;return{x:o,y:i}}function Loe(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",s=Wi(r),a=t?Ny(t.floating):!1;if(r===s||a&&i)return n;let l={scrollLeft:0,scrollTop:0},c=Ci(1);const u=Ci(0),d=Ti(r);if((d||!d&&!i)&&((Nd(r)!=="body"||Tp(s))&&(l=Ay(r)),Ti(r))){const p=Zl(r);c=wu(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const h=s&&!d&&!i?b3(s,l,!0):Ci(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 $oe(e){return Array.from(e.getClientRects())}function zoe(e){const t=Wi(e),n=Ay(e),r=e.ownerDocument.body,o=tr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=tr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+v_(e);const a=-n.scrollTop;return Jo(r).direction==="rtl"&&(s+=tr(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:a}}function Boe(e,t){const n=io(e),r=Wi(e),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,a=0,l=0;if(o){i=o.width,s=o.height;const c=b_();(!c||c&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:i,height:s,x:a,y:l}}function Voe(e,t){const n=Zl(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Ti(e)?wu(e):Ci(1),s=e.clientWidth*i.x,a=e.clientHeight*i.y,l=o*i.x,c=r*i.y;return{width:s,height:a,x:l,y:c}}function LM(e,t,n){let r;if(t==="viewport")r=Boe(e,n);else if(t==="document")r=zoe(Wi(e));else if(nr(t))r=Voe(t,n);else{const o=g3(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return $b(r)}function y3(e,t){const n=wa(e);return n===t||!nr(n)||td(n)?!1:Jo(n).position==="fixed"||y3(n,t)}function Hoe(e,t){const n=t.get(e);if(n)return n;let r=Sh(e,[],!1).filter(a=>nr(a)&&Nd(a)!=="body"),o=null;const i=Jo(e).position==="fixed";let s=i?wa(e):e;for(;nr(s)&&!td(s);){const a=Jo(s),l=g_(s);!l&&a.position==="fixed"&&(o=null),(i?!l&&!o:!l&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Tp(s)&&!l&&y3(e,s))?r=r.filter(u=>u!==s):o=a,s=wa(s)}return t.set(e,r),r}function Woe(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?Ny(t)?[]:Hoe(t,this._c):[].concat(n),r],a=s[0],l=s.reduce((c,u)=>{const d=LM(t,u,o);return c.top=tr(d.top,c.top),c.right=ks(d.right,c.right),c.bottom=ks(d.bottom,c.bottom),c.left=tr(d.left,c.left),c},LM(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Uoe(e){const{width:t,height:n}=m3(e);return{width:t,height:n}}function Goe(e,t,n){const r=Ti(t),o=Wi(t),i=n==="fixed",s=Zl(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const l=Ci(0);if(r||!r&&!i)if((Nd(t)!=="body"||Tp(o))&&(a=Ay(t)),r){const h=Zl(t,!0,i,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else o&&(l.x=v_(o));const c=o&&!r&&!i?b3(o,a):Ci(0),u=s.left+a.scrollLeft-l.x-c.x,d=s.top+a.scrollTop-l.y-c.y;return{x:u,y:d,width:s.width,height:s.height}}function Hx(e){return Jo(e).position==="static"}function $M(e,t){if(!Ti(e)||Jo(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Wi(e)===n&&(n=n.ownerDocument.body),n}function v3(e,t){const n=io(e);if(Ny(e))return n;if(!Ti(e)){let o=wa(e);for(;o&&!td(o);){if(nr(o)&&!Hx(o))return o;o=wa(o)}return n}let r=$M(e,t);for(;r&&Toe(r)&&Hx(r);)r=$M(r,t);return r&&td(r)&&Hx(r)&&!g_(r)?n:r||joe(e)||n}const qoe=async function(e){const t=this.getOffsetParent||v3,n=this.getDimensions,r=await n(e.floating);return{reference:Goe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Yoe(e){return Jo(e).direction==="rtl"}const Koe={convertOffsetParentRelativeRectToViewportRelativeRect:Loe,getDocumentElement:Wi,getClippingRect:Woe,getOffsetParent:v3,getElementRects:qoe,getClientRects:$oe,getDimensions:Uoe,getScale:wu,isElement:nr,isRTL:Yoe};function x3(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Xoe(e,t){let n=null,r;const o=Wi(e);function i(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function s(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const c=e.getBoundingClientRect(),{left:u,top:d,width:h,height:p}=c;if(a||t(),!h||!p)return;const m=Wm(d),g=Wm(o.clientWidth-(u+h)),b=Wm(o.clientHeight-(d+p)),y=Wm(u),x={rootMargin:-m+"px "+-g+"px "+-b+"px "+-y+"px",threshold:tr(0,ks(1,l))||1};let S=!0;function _(E){const C=E[0].intersectionRatio;if(C!==l){if(!S)return s();C?s(!1,C):r=setTimeout(()=>{s(!1,1e-7)},1e3)}C===1&&!x3(c,e.getBoundingClientRect())&&s(),S=!1}try{n=new IntersectionObserver(_,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(_,x)}n.observe(e)}return s(!0),i}function x_(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=y_(e),u=o||i?[...c?Sh(c):[],...Sh(t)]:[];u.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const d=c&&a?Xoe(c,n):null;let h=-1,p=null;s&&(p=new ResizeObserver(y=>{let[v]=y;v&&v.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var x;(x=p)==null||x.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let m,g=l?Zl(e):null;l&&b();function b(){const y=Zl(e);g&&!x3(g,y)&&n(),g=y,m=requestAnimationFrame(b)}return n(),()=>{var y;u.forEach(v=>{o&&v.removeEventListener("scroll",n),i&&v.removeEventListener("resize",n)}),d==null||d(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(m)}}const Wx=ed,Qoe=Moe,Joe=Poe,Zoe=Roe,eie=Ioe,tie=Noe,zM=koe,nie=Doe,rie=(e,t,n)=>{const r=new Map,o={platform:Koe,...n},i={...o.platform,_c:r};return _oe(e,t,{...o,platform:i})};var Qg=typeof document<"u"?k.useLayoutEffect:k.useEffect;function zb(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(!zb(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 i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!zb(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function w3(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function BM(e,t){const n=w3(e);return Math.round(t*n)/n}function Ux(e){const t=w.useRef(e);return Qg(()=>{t.current=e}),t}function w_(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,d]=w.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=w.useState(r);zb(h,r)||p(r);const[m,g]=w.useState(null),[b,y]=w.useState(null),v=w.useCallback(B=>{B!==E.current&&(E.current=B,g(B))},[]),x=w.useCallback(B=>{B!==C.current&&(C.current=B,y(B))},[]),S=i||m,_=s||b,E=w.useRef(null),C=w.useRef(null),R=w.useRef(u),M=l!=null,N=Ux(l),D=Ux(o),A=Ux(c),j=w.useCallback(()=>{if(!E.current||!C.current)return;const B={placement:t,strategy:n,middleware:h};D.current&&(B.platform=D.current),rie(E.current,C.current,B).then(z=>{const T={...z,isPositioned:A.current!==!1};O.current&&!zb(R.current,T)&&(R.current=T,_s.flushSync(()=>{d(T)}))})},[h,t,n,D,A]);Qg(()=>{c===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,d(B=>({...B,isPositioned:!1})))},[c]);const O=w.useRef(!1);Qg(()=>(O.current=!0,()=>{O.current=!1}),[]),Qg(()=>{if(S&&(E.current=S),_&&(C.current=_),S&&_){if(N.current)return N.current(S,_,j);j()}},[S,_,j,N,M]);const I=w.useMemo(()=>({reference:E,floating:C,setReference:v,setFloating:x}),[v,x]),L=w.useMemo(()=>({reference:S,floating:_}),[S,_]),F=w.useMemo(()=>{const B={position:n,left:0,top:0};if(!L.floating)return B;const z=BM(L.floating,u.x),T=BM(L.floating,u.y);return a?{...B,transform:"translate("+z+"px, "+T+"px)",...w3(L.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:z,top:T}},[n,a,L.floating,u.x,u.y]);return w.useMemo(()=>({...u,update:j,refs:I,elements:L,floatingStyles:F}),[u,j,I,L,F])}const oie=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?zM({element:r.current,padding:o}).fn(n):{}:r?zM({element:r,padding:o}).fn(n):{}}}},My=(e,t)=>({...Qoe(e),options:[e,t]}),C_=(e,t)=>({...Joe(e),options:[e,t]}),C3=(e,t)=>({...nie(e),options:[e,t]}),S_=(e,t)=>({...Zoe(e),options:[e,t]}),E_=(e,t)=>({...eie(e),options:[e,t]}),S3=(e,t)=>({...tie(e),options:[e,t]}),E3=(e,t)=>({...oie(e),options:[e,t]});var iie="Arrow",_3=w.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return f.jsx(Re.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:f.jsx("polygon",{points:"0,0 30,0 15,10"})})});_3.displayName=iie;var sie=_3;function Py(e){const[t,n]=w.useState(void 0);return Un(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,a;if("borderBoxSize"in i){const l=i.borderBoxSize,c=Array.isArray(l)?l[0]:l;s=c.inlineSize,a=c.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var __="Popper",[k3,Ui]=Tn(__),[aie,R3]=k3(__),N3=e=>{const{__scopePopper:t,children:n}=e,[r,o]=w.useState(null);return f.jsx(aie,{scope:t,anchor:r,onAnchorChange:o,children:n})};N3.displayName=__;var A3="PopperAnchor",M3=w.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=R3(A3,n),s=w.useRef(null),a=We(t,s);return w.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||s.current)}),r?null:f.jsx(Re.div,{...o,ref:a})});M3.displayName=A3;var k_="PopperContent",[lie,cie]=k3(k_),P3=w.forwardRef((e,t)=>{var U,G,Y,Q,te,J;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:m,...g}=e,b=R3(k_,n),[y,v]=w.useState(null),x=We(t,ie=>v(ie)),[S,_]=w.useState(null),E=Py(S),C=(E==null?void 0:E.width)??0,R=(E==null?void 0:E.height)??0,M=r+(i!=="center"?"-"+i:""),N=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(c)?c:[c],A=D.length>0,j={padding:N,boundary:D.filter(die),altBoundary:A},{refs:O,floatingStyles:I,placement:L,isPositioned:F,middlewareData:B}=w_({strategy:"fixed",placement:M,whileElementsMounted:(...ie)=>x_(...ie,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[My({mainAxis:o+R,alignmentAxis:s}),l&&C_({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?C3():void 0,...j}),l&&S_({...j}),E_({...j,apply:({elements:ie,rects:Z,availableWidth:ue,availableHeight:fe})=>{const{width:xe,height:ge}=Z.reference,be=ie.floating.style;be.setProperty("--radix-popper-available-width",`${ue}px`),be.setProperty("--radix-popper-available-height",`${fe}px`),be.setProperty("--radix-popper-anchor-width",`${xe}px`),be.setProperty("--radix-popper-anchor-height",`${ge}px`)}}),S&&E3({element:S,padding:a}),fie({arrowWidth:C,arrowHeight:R}),h&&S3({strategy:"referenceHidden",...j})]}),[z,T]=T3(L),H=Mn(m);Un(()=>{F&&(H==null||H())},[F,H]);const V=(U=B.arrow)==null?void 0:U.x,P=(G=B.arrow)==null?void 0:G.y,W=((Y=B.arrow)==null?void 0:Y.centerOffset)!==0,[$,q]=w.useState();return Un(()=>{y&&q(window.getComputedStyle(y).zIndex)},[y]),f.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...I,transform:F?I.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:$,"--radix-popper-transform-origin":[(Q=B.transformOrigin)==null?void 0:Q.x,(te=B.transformOrigin)==null?void 0:te.y].join(" "),...((J=B.hide)==null?void 0:J.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:f.jsx(lie,{scope:n,placedSide:z,onArrowChange:_,arrowX:V,arrowY:P,shouldHideArrow:W,children:f.jsx(Re.div,{"data-side":z,"data-align":T,...g,ref:x,style:{...g.style,animation:F?void 0:"none"}})})})});P3.displayName=k_;var D3="PopperArrow",uie={top:"bottom",right:"left",bottom:"top",left:"right"},I3=w.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=cie(D3,r),s=uie[i.placedSide];return f.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:f.jsx(sie,{...o,ref:n,style:{...o.style,display:"block"}})})});I3.displayName=D3;function die(e){return e!==null}var fie=e=>({name:"transformOrigin",options:e,fn(t){var b,y,v;const{placement:n,rects:r,middlewareData:o}=t,s=((b=o.arrow)==null?void 0:b.centerOffset)!==0,a=s?0:e.arrowWidth,l=s?0:e.arrowHeight,[c,u]=T3(n),d={start:"0%",center:"50%",end:"100%"}[u],h=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((v=o.arrow)==null?void 0:v.y)??0)+l/2;let m="",g="";return c==="bottom"?(m=s?d:`${h}px`,g=`${-l}px`):c==="top"?(m=s?d:`${h}px`,g=`${r.floating.height+l}px`):c==="right"?(m=`${-l}px`,g=s?d:`${p}px`):c==="left"&&(m=`${r.floating.width+l}px`,g=s?d:`${p}px`),{data:{x:m,y:g}}}});function T3(e){const[t,n="center"]=e.split("-");return[t,n]}var Ad=N3,Md=M3,jp=P3,Op=I3,hie="Portal",kc=w.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,i]=w.useState(!1);Un(()=>i(!0),[]);const s=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return s?un.createPortal(f.jsx(Re.div,{...r,ref:t}),s):null});kc.displayName=hie;var j3=w.forwardRef((e,t)=>{const{children:n,...r}=e,o=w.Children.toArray(n),i=o.find(mie);if(i){const s=i.props.children,a=o.map(l=>l===i?w.Children.count(s)>1?w.Children.only(null):w.isValidElement(s)?s.props.children:null:l);return f.jsx(LC,{...r,ref:t,children:w.isValidElement(s)?w.cloneElement(s,void 0,a):null})}return f.jsx(LC,{...r,ref:t,children:n})});j3.displayName="Slot";var LC=w.forwardRef((e,t)=>{const{children:n,...r}=e;if(w.isValidElement(n)){const o=bie(n),i=gie(r,n.props);return n.type!==w.Fragment&&(i.ref=t?wr(t,o):o),w.cloneElement(n,i)}return w.Children.count(n)>1?w.Children.only(null):null});LC.displayName="SlotClone";var pie=({children:e})=>f.jsx(f.Fragment,{children:e});function mie(e){return w.isValidElement(e)&&e.type===pie}function gie(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function bie(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 R_="Popover",[O3,x$e]=Tn(R_,[Ui]),Fp=Ui(),[yie,Oa]=O3(R_),F3=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=Fp(t),l=w.useRef(null),[c,u]=w.useState(!1),[d=!1,h]=Gn({prop:r,defaultProp:o,onChange:i});return f.jsx(Ad,{...a,children:f.jsx(yie,{scope:t,contentId:yn(),triggerRef:l,open:d,onOpenChange:h,onOpenToggle:w.useCallback(()=>h(p=>!p),[h]),hasCustomAnchor:c,onCustomAnchorAdd:w.useCallback(()=>u(!0),[]),onCustomAnchorRemove:w.useCallback(()=>u(!1),[]),modal:s,children:n})})};F3.displayName=R_;var L3="PopoverAnchor",vie=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Oa(L3,n),i=Fp(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=o;return w.useEffect(()=>(s(),()=>a()),[s,a]),f.jsx(Md,{...i,...r,ref:t})});vie.displayName=L3;var $3="PopoverTrigger",z3=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Oa($3,n),i=Fp(n),s=We(t,o.triggerRef),a=f.jsx(Re.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":U3(o.open),...r,ref:s,onClick:pe(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:f.jsx(Md,{asChild:!0,...i,children:a})});z3.displayName=$3;var N_="PopoverPortal",[xie,wie]=O3(N_,{forceMount:void 0}),B3=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=Oa(N_,t);return f.jsx(xie,{scope:t,forceMount:n,children:f.jsx(vn,{present:n||i.open,children:f.jsx(kc,{asChild:!0,container:o,children:r})})})};B3.displayName=N_;var nd="PopoverContent",V3=w.forwardRef((e,t)=>{const n=wie(nd,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=Oa(nd,e.__scopePopover);return f.jsx(vn,{present:r||i.open,children:i.modal?f.jsx(Cie,{...o,ref:t}):f.jsx(Sie,{...o,ref:t})})});V3.displayName=nd;var Cie=w.forwardRef((e,t)=>{const n=Oa(nd,e.__scopePopover),r=w.useRef(null),o=We(t,r),i=w.useRef(!1);return w.useEffect(()=>{const s=r.current;if(s)return Sd(s)},[]),f.jsx(Ec,{as:j3,allowPinchZoom:!0,children:f.jsx(H3,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:pe(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),i.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:pe(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),Sie=w.forwardRef((e,t)=>{const n=Oa(nd,e.__scopePopover),r=w.useRef(!1),o=w.useRef(!1);return f.jsx(H3,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var s,a;(s=e.onCloseAutoFocus)==null||s.call(e,i),i.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;((c=n.triggerRef.current)==null?void 0:c.contains(s))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),H3=w.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...d}=e,h=Oa(nd,n),p=Fp(n);return ky(),f.jsx(Ip,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:f.jsx(_c,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:f.jsx(jp,{"data-state":U3(h.open),role:"dialog",id:h.contentId,...p,...d,ref:t,style:{...d.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)"}})})})}),W3="PopoverClose",Eie=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Oa(W3,n);return f.jsx(Re.button,{type:"button",...r,ref:t,onClick:pe(e.onClick,()=>o.onOpenChange(!1))})});Eie.displayName=W3;var _ie="PopoverArrow",kie=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Fp(n);return f.jsx(Op,{...o,...r,ref:t})});kie.displayName=_ie;function U3(e){return e?"open":"closed"}var Rie=F3,Nie=z3,Aie=B3,Dy=V3;const Rc=Rie,Nc=Nie,Fa=w.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>f.jsx(Aie,{children:f.jsx(ni,{children:f.jsx(Dy,{ref:o,align:t,sideOffset:n,className:re("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})})}));Fa.displayName=Dy.displayName;function $C(e,[t,n]){return Math.min(n,Math.max(t,e))}var G3=w.forwardRef((e,t)=>{const{children:n,...r}=e,o=w.Children.toArray(n),i=o.find(Pie);if(i){const s=i.props.children,a=o.map(l=>l===i?w.Children.count(s)>1?w.Children.only(null):w.isValidElement(s)?s.props.children:null:l);return f.jsx(zC,{...r,ref:t,children:w.isValidElement(s)?w.cloneElement(s,void 0,a):null})}return f.jsx(zC,{...r,ref:t,children:n})});G3.displayName="Slot";var zC=w.forwardRef((e,t)=>{const{children:n,...r}=e;if(w.isValidElement(n)){const o=Iie(n),i=Die(r,n.props);return n.type!==w.Fragment&&(i.ref=t?wr(t,o):o),w.cloneElement(n,i)}return w.Children.count(n)>1?w.Children.only(null):null});zC.displayName="SlotClone";var Mie=({children:e})=>f.jsx(f.Fragment,{children:e});function Pie(e){return w.isValidElement(e)&&e.type===Mie}function Die(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Iie(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 Iy(e){const t=w.useRef({value:e,previous:e});return w.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Tie="VisuallyHidden",A_=w.forwardRef((e,t)=>f.jsx(Re.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}}));A_.displayName=Tie;var jie=A_,Oie=[" ","Enter","ArrowUp","ArrowDown"],Fie=[" ","Enter"],Lp="Select",[Ty,jy,Lie]=X0(Lp),[Pd,w$e]=Tn(Lp,[Lie,Ui]),Oy=Ui(),[$ie,La]=Pd(Lp),[zie,Bie]=Pd(Lp),q3=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:i,value:s,defaultValue:a,onValueChange:l,dir:c,name:u,autoComplete:d,disabled:h,required:p,form:m}=e,g=Oy(t),[b,y]=w.useState(null),[v,x]=w.useState(null),[S,_]=w.useState(!1),E=yc(c),[C=!1,R]=Gn({prop:r,defaultProp:o,onChange:i}),[M,N]=Gn({prop:s,defaultProp:a,onChange:l}),D=w.useRef(null),A=b?m||!!b.closest("form"):!0,[j,O]=w.useState(new Set),I=Array.from(j).map(L=>L.props.value).join(";");return f.jsx(Ad,{...g,children:f.jsxs($ie,{required:p,scope:t,trigger:b,onTriggerChange:y,valueNode:v,onValueNodeChange:x,valueNodeHasChildren:S,onValueNodeHasChildrenChange:_,contentId:yn(),value:M,onValueChange:N,open:C,onOpenChange:R,dir:E,triggerPointerDownPosRef:D,disabled:h,children:[f.jsx(Ty.Provider,{scope:t,children:f.jsx(zie,{scope:e.__scopeSelect,onNativeOptionAdd:w.useCallback(L=>{O(F=>new Set(F).add(L))},[]),onNativeOptionRemove:w.useCallback(L=>{O(F=>{const B=new Set(F);return B.delete(L),B})},[]),children:n})}),A?f.jsxs(vL,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:M,onChange:L=>N(L.target.value),disabled:h,form:m,children:[M===void 0?f.jsx("option",{value:""}):null,Array.from(j)]},I):null]})})};q3.displayName=Lp;var Y3="SelectTrigger",K3=w.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,i=Oy(n),s=La(Y3,n),a=s.disabled||r,l=We(t,s.onTriggerChange),c=jy(n),u=w.useRef("touch"),[d,h,p]=xL(g=>{const b=c().filter(x=>!x.disabled),y=b.find(x=>x.value===s.value),v=wL(b,g,y);v!==void 0&&s.onValueChange(v.value)}),m=g=>{a||(s.onOpenChange(!0),p()),g&&(s.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return f.jsx(Md,{asChild:!0,...i,children:f.jsx(Re.button,{type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":yL(s.value)?"":void 0,...o,ref:l,onClick:pe(o.onClick,g=>{g.currentTarget.focus(),u.current!=="mouse"&&m(g)}),onPointerDown:pe(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:pe(o.onKeyDown,g=>{const b=d.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&h(g.key),!(b&&g.key===" ")&&Oie.includes(g.key)&&(m(),g.preventDefault())})})})});K3.displayName=Y3;var X3="SelectValue",Q3=w.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:i,placeholder:s="",...a}=e,l=La(X3,n),{onValueNodeHasChildrenChange:c}=l,u=i!==void 0,d=We(t,l.onValueNodeChange);return Un(()=>{c(u)},[c,u]),f.jsx(Re.span,{...a,ref:d,style:{pointerEvents:"none"},children:yL(l.value)?f.jsx(f.Fragment,{children:s}):i})});Q3.displayName=X3;var Vie="SelectIcon",J3=w.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return f.jsx(Re.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});J3.displayName=Vie;var Hie="SelectPortal",Z3=e=>f.jsx(kc,{asChild:!0,...e});Z3.displayName=Hie;var ec="SelectContent",eL=w.forwardRef((e,t)=>{const n=La(ec,e.__scopeSelect),[r,o]=w.useState();if(Un(()=>{o(new DocumentFragment)},[]),!n.open){const i=r;return i?_s.createPortal(f.jsx(tL,{scope:e.__scopeSelect,children:f.jsx(Ty.Slot,{scope:e.__scopeSelect,children:f.jsx("div",{children:e.children})})}),i):null}return f.jsx(nL,{...e,ref:t})});eL.displayName=ec;var Fo=10,[tL,$a]=Pd(ec),Wie="SelectContentImpl",nL=w.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:s,side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:h,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:b,...y}=e,v=La(ec,n),[x,S]=w.useState(null),[_,E]=w.useState(null),C=We(t,U=>S(U)),[R,M]=w.useState(null),[N,D]=w.useState(null),A=jy(n),[j,O]=w.useState(!1),I=w.useRef(!1);w.useEffect(()=>{if(x)return Sd(x)},[x]),ky();const L=w.useCallback(U=>{const[G,...Y]=A().map(J=>J.ref.current),[Q]=Y.slice(-1),te=document.activeElement;for(const J of U)if(J===te||(J==null||J.scrollIntoView({block:"nearest"}),J===G&&_&&(_.scrollTop=0),J===Q&&_&&(_.scrollTop=_.scrollHeight),J==null||J.focus(),document.activeElement!==te))return},[A,_]),F=w.useCallback(()=>L([R,x]),[L,R,x]);w.useEffect(()=>{j&&F()},[j,F]);const{onOpenChange:B,triggerPointerDownPosRef:z}=v;w.useEffect(()=>{if(x){let U={x:0,y:0};const G=Q=>{var te,J;U={x:Math.abs(Math.round(Q.pageX)-(((te=z.current)==null?void 0:te.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((J=z.current)==null?void 0:J.y)??0))}},Y=Q=>{U.x<=10&&U.y<=10?Q.preventDefault():x.contains(Q.target)||B(!1),document.removeEventListener("pointermove",G),z.current=null};return z.current!==null&&(document.addEventListener("pointermove",G),document.addEventListener("pointerup",Y,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",G),document.removeEventListener("pointerup",Y,{capture:!0})}}},[x,B,z]),w.useEffect(()=>{const U=()=>B(!1);return window.addEventListener("blur",U),window.addEventListener("resize",U),()=>{window.removeEventListener("blur",U),window.removeEventListener("resize",U)}},[B]);const[T,H]=xL(U=>{const G=A().filter(te=>!te.disabled),Y=G.find(te=>te.ref.current===document.activeElement),Q=wL(G,U,Y);Q&&setTimeout(()=>Q.ref.current.focus())}),V=w.useCallback((U,G,Y)=>{const Q=!I.current&&!Y;(v.value!==void 0&&v.value===G||Q)&&(M(U),Q&&(I.current=!0))},[v.value]),P=w.useCallback(()=>x==null?void 0:x.focus(),[x]),W=w.useCallback((U,G,Y)=>{const Q=!I.current&&!Y;(v.value!==void 0&&v.value===G||Q)&&D(U)},[v.value]),$=r==="popper"?BC:rL,q=$===BC?{side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:h,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:b}:{};return f.jsx(tL,{scope:n,content:x,viewport:_,onViewportChange:E,itemRefCallback:V,selectedItem:R,onItemLeave:P,itemTextRefCallback:W,focusSelectedItem:F,selectedItemText:N,position:r,isPositioned:j,searchRef:T,children:f.jsx(Ec,{as:G3,allowPinchZoom:!0,children:f.jsx(Ip,{asChild:!0,trapped:v.open,onMountAutoFocus:U=>{U.preventDefault()},onUnmountAutoFocus:pe(o,U=>{var G;(G=v.trigger)==null||G.focus({preventScroll:!0}),U.preventDefault()}),children:f.jsx(_c,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:U=>U.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:f.jsx($,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:U=>U.preventDefault(),...y,...q,onPlaced:()=>O(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:pe(y.onKeyDown,U=>{const G=U.ctrlKey||U.altKey||U.metaKey;if(U.key==="Tab"&&U.preventDefault(),!G&&U.key.length===1&&H(U.key),["ArrowUp","ArrowDown","Home","End"].includes(U.key)){let Q=A().filter(te=>!te.disabled).map(te=>te.ref.current);if(["ArrowUp","End"].includes(U.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(U.key)){const te=U.target,J=Q.indexOf(te);Q=Q.slice(J+1)}setTimeout(()=>L(Q)),U.preventDefault()}})})})})})})});nL.displayName=Wie;var Uie="SelectItemAlignedPosition",rL=w.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,i=La(ec,n),s=$a(ec,n),[a,l]=w.useState(null),[c,u]=w.useState(null),d=We(t,C=>u(C)),h=jy(n),p=w.useRef(!1),m=w.useRef(!0),{viewport:g,selectedItem:b,selectedItemText:y,focusSelectedItem:v}=s,x=w.useCallback(()=>{if(i.trigger&&i.valueNode&&a&&c&&g&&b&&y){const C=i.trigger.getBoundingClientRect(),R=c.getBoundingClientRect(),M=i.valueNode.getBoundingClientRect(),N=y.getBoundingClientRect();if(i.dir!=="rtl"){const te=N.left-R.left,J=M.left-te,ie=C.left-J,Z=C.width+ie,ue=Math.max(Z,R.width),fe=window.innerWidth-Fo,xe=$C(J,[Fo,Math.max(Fo,fe-ue)]);a.style.minWidth=Z+"px",a.style.left=xe+"px"}else{const te=R.right-N.right,J=window.innerWidth-M.right-te,ie=window.innerWidth-C.right-J,Z=C.width+ie,ue=Math.max(Z,R.width),fe=window.innerWidth-Fo,xe=$C(J,[Fo,Math.max(Fo,fe-ue)]);a.style.minWidth=Z+"px",a.style.right=xe+"px"}const D=h(),A=window.innerHeight-Fo*2,j=g.scrollHeight,O=window.getComputedStyle(c),I=parseInt(O.borderTopWidth,10),L=parseInt(O.paddingTop,10),F=parseInt(O.borderBottomWidth,10),B=parseInt(O.paddingBottom,10),z=I+L+j+B+F,T=Math.min(b.offsetHeight*5,z),H=window.getComputedStyle(g),V=parseInt(H.paddingTop,10),P=parseInt(H.paddingBottom,10),W=C.top+C.height/2-Fo,$=A-W,q=b.offsetHeight/2,U=b.offsetTop+q,G=I+L+U,Y=z-G;if(G<=W){const te=D.length>0&&b===D[D.length-1].ref.current;a.style.bottom="0px";const J=c.clientHeight-g.offsetTop-g.offsetHeight,ie=Math.max($,q+(te?P:0)+J+F),Z=G+ie;a.style.height=Z+"px"}else{const te=D.length>0&&b===D[0].ref.current;a.style.top="0px";const ie=Math.max(W,I+g.offsetTop+(te?V:0)+q)+Y;a.style.height=ie+"px",g.scrollTop=G-W+g.offsetTop}a.style.margin=`${Fo}px 0`,a.style.minHeight=T+"px",a.style.maxHeight=A+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,i.trigger,i.valueNode,a,c,g,b,y,i.dir,r]);Un(()=>x(),[x]);const[S,_]=w.useState();Un(()=>{c&&_(window.getComputedStyle(c).zIndex)},[c]);const E=w.useCallback(C=>{C&&m.current===!0&&(x(),v==null||v(),m.current=!1)},[x,v]);return f.jsx(qie,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:E,children:f.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:f.jsx(Re.div,{...o,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});rL.displayName=Uie;var Gie="SelectPopperPosition",BC=w.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Fo,...i}=e,s=Oy(n);return f.jsx(jp,{...s,...i,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...i.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)"}})});BC.displayName=Gie;var[qie,M_]=Pd(ec,{}),VC="SelectViewport",oL=w.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,i=$a(VC,n),s=M_(VC,n),a=We(t,i.onViewportChange),l=w.useRef(0);return f.jsxs(f.Fragment,{children:[f.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}),f.jsx(Ty.Slot,{scope:n,children:f.jsx(Re.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:pe(o.onScroll,c=>{const u=c.currentTarget,{contentWrapper:d,shouldExpandOnScrollRef:h}=s;if(h!=null&&h.current&&d){const p=Math.abs(l.current-u.scrollTop);if(p>0){const m=window.innerHeight-Fo*2,g=parseFloat(d.style.minHeight),b=parseFloat(d.style.height),y=Math.max(g,b);if(y<m){const v=y+p,x=Math.min(m,v),S=v-x;d.style.height=x+"px",d.style.bottom==="0px"&&(u.scrollTop=S>0?S:0,d.style.justifyContent="flex-end")}}}l.current=u.scrollTop})})})]})});oL.displayName=VC;var iL="SelectGroup",[Yie,Kie]=Pd(iL),sL=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=yn();return f.jsx(Yie,{scope:n,id:o,children:f.jsx(Re.div,{role:"group","aria-labelledby":o,...r,ref:t})})});sL.displayName=iL;var aL="SelectLabel",lL=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Kie(aL,n);return f.jsx(Re.div,{id:o.id,...r,ref:t})});lL.displayName=aL;var Bb="SelectItem",[Xie,cL]=Pd(Bb),uL=w.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:i,...s}=e,a=La(Bb,n),l=$a(Bb,n),c=a.value===r,[u,d]=w.useState(i??""),[h,p]=w.useState(!1),m=We(t,v=>{var x;return(x=l.itemRefCallback)==null?void 0:x.call(l,v,r,o)}),g=yn(),b=w.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 f.jsx(Xie,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:w.useCallback(v=>{d(x=>x||((v==null?void 0:v.textContent)??"").trim())},[]),children:f.jsx(Ty.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:f.jsx(Re.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,...s,ref:m,onFocus:pe(s.onFocus,()=>p(!0)),onBlur:pe(s.onBlur,()=>p(!1)),onClick:pe(s.onClick,()=>{b.current!=="mouse"&&y()}),onPointerUp:pe(s.onPointerUp,()=>{b.current==="mouse"&&y()}),onPointerDown:pe(s.onPointerDown,v=>{b.current=v.pointerType}),onPointerMove:pe(s.onPointerMove,v=>{var x;b.current=v.pointerType,o?(x=l.onItemLeave)==null||x.call(l):b.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:pe(s.onPointerLeave,v=>{var x;v.currentTarget===document.activeElement&&((x=l.onItemLeave)==null||x.call(l))}),onKeyDown:pe(s.onKeyDown,v=>{var S;((S=l.searchRef)==null?void 0:S.current)!==""&&v.key===" "||(Fie.includes(v.key)&&y(),v.key===" "&&v.preventDefault())})})})})});uL.displayName=Bb;var Sf="SelectItemText",dL=w.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...i}=e,s=La(Sf,n),a=$a(Sf,n),l=cL(Sf,n),c=Bie(Sf,n),[u,d]=w.useState(null),h=We(t,y=>d(y),l.onItemTextChange,y=>{var v;return(v=a.itemTextRefCallback)==null?void 0:v.call(a,y,l.value,l.disabled)}),p=u==null?void 0:u.textContent,m=w.useMemo(()=>f.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:b}=c;return Un(()=>(g(m),()=>b(m)),[g,b,m]),f.jsxs(f.Fragment,{children:[f.jsx(Re.span,{id:l.textId,...i,ref:h}),l.isSelected&&s.valueNode&&!s.valueNodeHasChildren?_s.createPortal(i.children,s.valueNode):null]})});dL.displayName=Sf;var fL="SelectItemIndicator",hL=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return cL(fL,n).isSelected?f.jsx(Re.span,{"aria-hidden":!0,...r,ref:t}):null});hL.displayName=fL;var HC="SelectScrollUpButton",pL=w.forwardRef((e,t)=>{const n=$a(HC,e.__scopeSelect),r=M_(HC,e.__scopeSelect),[o,i]=w.useState(!1),s=We(t,r.onScrollButtonChange);return Un(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;i(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?f.jsx(gL,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});pL.displayName=HC;var WC="SelectScrollDownButton",mL=w.forwardRef((e,t)=>{const n=$a(WC,e.__scopeSelect),r=M_(WC,e.__scopeSelect),[o,i]=w.useState(!1),s=We(t,r.onScrollButtonChange);return Un(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,u=Math.ceil(l.scrollTop)<c;i(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?f.jsx(gL,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});mL.displayName=WC;var gL=w.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,i=$a("SelectScrollButton",n),s=w.useRef(null),a=jy(n),l=w.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return w.useEffect(()=>()=>l(),[l]),Un(()=>{var u;const c=a().find(d=>d.ref.current===document.activeElement);(u=c==null?void 0:c.ref.current)==null||u.scrollIntoView({block:"nearest"})},[a]),f.jsx(Re.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:pe(o.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:pe(o.onPointerMove,()=>{var c;(c=i.onItemLeave)==null||c.call(i),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:pe(o.onPointerLeave,()=>{l()})})}),Qie="SelectSeparator",bL=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return f.jsx(Re.div,{"aria-hidden":!0,...r,ref:t})});bL.displayName=Qie;var UC="SelectArrow",Jie=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Oy(n),i=La(UC,n),s=$a(UC,n);return i.open&&s.position==="popper"?f.jsx(Op,{...o,...r,ref:t}):null});Jie.displayName=UC;function yL(e){return e===""||e===void 0}var vL=w.forwardRef((e,t)=>{const{value:n,...r}=e,o=w.useRef(null),i=We(t,o),s=Iy(n);return w.useEffect(()=>{const a=o.current,l=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(l,"value").set;if(s!==n&&u){const d=new Event("change",{bubbles:!0});u.call(a,n),a.dispatchEvent(d)}},[s,n]),f.jsx(A_,{asChild:!0,children:f.jsx("select",{...r,ref:i,defaultValue:n})})});vL.displayName="BubbleSelect";function xL(e){const t=Mn(e),n=w.useRef(""),r=w.useRef(0),o=w.useCallback(s=>{const a=n.current+s;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),i=w.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return w.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,i]}function wL(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let s=Zie(e,Math.max(i,0));o.length===1&&(s=s.filter(c=>c!==n));const l=s.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Zie(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ese=q3,CL=K3,tse=Q3,nse=J3,rse=Z3,SL=eL,ose=oL,ise=sL,EL=lL,_L=uL,sse=dL,ase=hL,kL=pL,RL=mL,NL=bL;const qt=ese,tu=ise,Yt=tse,zt=w.forwardRef(({className:e,children:t,...n},r)=>f.jsxs(CL,{ref:r,className:re("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,f.jsx(nse,{asChild:!0,children:f.jsx(fa,{className:"h-4 w-4 opacity-50"})})]}));zt.displayName=CL.displayName;const AL=w.forwardRef(({className:e,...t},n)=>f.jsx(kL,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:f.jsx(Ff,{className:"h-4 w-4"})}));AL.displayName=kL.displayName;const ML=w.forwardRef(({className:e,...t},n)=>f.jsx(RL,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:f.jsx(fa,{className:"h-4 w-4"})}));ML.displayName=RL.displayName;const Bt=w.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>f.jsx(rse,{children:f.jsx(ni,{children:f.jsxs(SL,{ref:o,className:re("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:[f.jsx(AL,{}),f.jsx(ose,{className:re("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),f.jsx(ML,{})]})})}));Bt.displayName=SL.displayName;const cl=w.forwardRef(({className:e,...t},n)=>f.jsx(EL,{ref:n,className:re("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));cl.displayName=EL.displayName;const Ee=w.forwardRef(({className:e,children:t,...n},r)=>f.jsxs(_L,{ref:r,className:re("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:[f.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:f.jsx(ase,{children:f.jsx(Wn,{className:"h-4 w-4"})})}),f.jsx(sse,{children:t})]}));Ee.displayName=_L.displayName;const Jg=w.forwardRef(({className:e,...t},n)=>f.jsx(NL,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));Jg.displayName=NL.displayName;const zr=w.forwardRef(({className:e,type:t,...n},r)=>f.jsx("input",{type:t,className:re("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}));zr.displayName="Input";var lse="Label",P_=w.forwardRef((e,t)=>f.jsx(Re.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));P_.displayName=lse;var PL=P_;const cse=my("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ve=w.forwardRef(({className:e,...t},n)=>f.jsx(PL,{ref:n,className:re(cse(),e),...t}));ve.displayName=PL.displayName;function use({step:e,hierarchyId:t,stepIndex:n,onUpdateStep:r,open:o,onOpenChange:i,trigger:s}){return f.jsxs(Rc,{open:o,onOpenChange:i,children:[f.jsx(Nc,{asChild:!0,children:s}),f.jsx(Fa,{className:"z-50 w-80",align:"start",children:f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx(ve,{className:"mb-1 block text-xs font-medium",children:"Chart Type"}),f.jsxs(qt,{value:e.preferredChartType||"bar",onValueChange:a=>{r(t,n,{preferredChartType:a})},children:[f.jsx(zt,{className:"h-8",children:f.jsx(Yt,{})}),f.jsxs(Bt,{children:[f.jsx(Ee,{value:"bar",children:"Bar Chart"}),f.jsx(Ee,{value:"pie",children:"Pie Chart"}),f.jsx(Ee,{value:"line",children:"Line Chart"}),f.jsx(Ee,{value:"donut",children:"Donut Chart"}),f.jsx(Ee,{value:"table",children:"Table"}),f.jsx(Ee,{value:"metric",children:"Metric"})]})]})]}),f.jsxs("div",{children:[f.jsx(ve,{className:"mb-1 block text-xs font-medium",children:"Step Label"}),f.jsx(zr,{value:e.label||"",onChange:a=>r(t,n,{label:a.target.value}),placeholder:"Custom drill label",className:"h-8"})]}),f.jsxs("div",{children:[f.jsx(ve,{className:"mb-1 block text-xs font-medium",children:"Breadcrumb Label Template"}),f.jsx(zr,{value:e.breadcrumbLabelTemplate||"",onChange:a=>r(t,n,{breadcrumbLabelTemplate:a.target.value}),placeholder:"e.g., 'Region: {{value}}'",className:"h-8"})]}),f.jsx("div",{className:"flex items-center gap-4",children:f.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[f.jsx("input",{type:"checkbox",checked:e.retainFilters!==!1,onChange:a=>r(t,n,{retainFilters:a.target.checked}),className:"rounded"}),"Retain filters when drilling"]})}),f.jsx("div",{className:"flex justify-end",children:f.jsx(_e,{size:"sm",variant:"outline",onClick:()=>i(!1),children:"Done"})})]})})]})}function dse({field:e,step:t,stepIndex:n,hierarchyId:r,onUpdateStep:o,onRemoveStep:i,isFirstField:s=!1}){const[a,l]=k.useState(!1),{attributes:c,listeners:u,setNodeRef:d,transform:h,transition:p,isDragging:m}=d_({id:`${r}-${e.id}-${n}`,disabled:!1}),g={transform:Di.Transform.toString(h),transition:p,opacity:m?.8:1,zIndex:m?1e3:1};return f.jsx("div",{ref:d,style:g,className:`relative ${a?"z-[9998]":""}`,...c,children:f.jsx(use,{step:t,hierarchyId:r,stepIndex:n,onUpdateStep:o,open:a,onOpenChange:l,trigger:f.jsxs("div",{className:`flex cursor-pointer items-center gap-2 rounded-lg p-2 transition-colors ${s?"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:[f.jsxs("div",{className:"pointer-events-none flex items-center gap-2",children:[f.jsx("span",{className:"whitespace-nowrap text-sm font-medium",children:e.label}),t.preferredChartType&&t.preferredChartType!=="bar"&&f.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&&f.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:"📊"})]}),f.jsx("button",{className:`pointer-events-auto ml-1 text-xs hover:text-red-800 dark:hover:text-red-400 ${s?"text-muted-foreground":"text-blue-600 dark:text-blue-400"}`,onClick:b=>{b.stopPropagation(),i(r,n)},children:"×"})]})})})}function fse(e){return{sensors:o_(xh(Mp,{activationConstraint:{distance:5}}),xh(Ap,{coordinateGetter:f_})),handleStepDragEnd:(r,o)=>{const{active:i,over:s}=r;if(!s||i.id===s.id)return;const a=i.id.replace(`${o.id}-`,""),l=s.id.replace(`${o.id}-`,""),c=o.steps.findIndex(d=>d.field.id===a),u=o.steps.findIndex(d=>d.field.id===l);if(c!==-1&&u!==-1&&c!==u){const d=Dp(o.steps,c,u);e(o.id,{steps:d})}}}}function hse({hierarchy:e,onUpdateStep:t,onRemoveStep:n,onUpdateHierarchy:r}){const{sensors:o}=fse(r),[i,s]=k.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;s(b||null)},d=h=>{s(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],[v]=y.splice(g,1);y.splice(b,0,v),r(e.id,{steps:y})}};return a.length===0?f.jsx("div",{className:"steps-container",onPointerDown:h=>h.stopPropagation(),children:f.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."})}):f.jsx("div",{className:"steps-container",onPointerDown:h=>h.stopPropagation(),children:f.jsxs(c_,{sensors:o,collisionDetection:i_,onDragStart:u,onDragEnd:d,children:[f.jsx(u_,{items:c,strategy:Vre,children:f.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(f.jsx(Ko,{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(f.jsx(dse,{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"&&un.createPortal(f.jsx(n3,{className:"semaphor-scope",style:{zIndex:9999},children:i?f.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:f.jsx("span",{className:"whitespace-nowrap text-sm font-medium",children:i.label})}):null}),document.body)]})})}var VM=1,pse=.9,mse=.8,gse=.17,Gx=.1,qx=.999,bse=.9999,yse=.99,vse=/[\\\/_+.#"@\[\(\{&]/,xse=/[\\\/_+.#"@\[\(\{&]/g,wse=/[\s-]/,DL=/[\s-]/g;function GC(e,t,n,r,o,i,s){if(i===t.length)return o===e.length?VM:yse;var a=`${o},${i}`;if(s[a]!==void 0)return s[a];for(var l=r.charAt(i),c=n.indexOf(l,o),u=0,d,h,p,m;c>=0;)d=GC(e,t,n,r,c+1,i+1,s),d>u&&(c===o?d*=VM:vse.test(e.charAt(c-1))?(d*=mse,p=e.slice(o,c-1).match(xse),p&&o>0&&(d*=Math.pow(qx,p.length))):wse.test(e.charAt(c-1))?(d*=pse,m=e.slice(o,c-1).match(DL),m&&o>0&&(d*=Math.pow(qx,m.length))):(d*=gse,o>0&&(d*=Math.pow(qx,c-o))),e.charAt(c)!==t.charAt(i)&&(d*=bse)),(d<Gx&&n.charAt(c-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(c-1)!==r.charAt(i))&&(h=GC(e,t,n,r,c+1,i+2,s),h*Gx>d&&(d=h*Gx)),d>u&&(u=d),c=n.indexOf(l,c+1);return s[a]=u,u}function HM(e){return e.toLowerCase().replace(DL," ")}function Cse(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,GC(e,t,HM(e),HM(t),0,0,{})}var tf='[cmdk-group=""]',Yx='[cmdk-group-items=""]',Sse='[cmdk-group-heading=""]',IL='[cmdk-item=""]',WM=`${IL}:not([aria-disabled="true"])`,qC="cmdk-item-select",nu="data-value",Ese=(e,t,n)=>Cse(e,t,n),TL=w.createContext(void 0),$p=()=>w.useContext(TL),jL=w.createContext(void 0),D_=()=>w.useContext(jL),OL=w.createContext(void 0),FL=w.forwardRef((e,t)=>{let n=ru(()=>{var V,P;return{search:"",value:(P=(V=e.value)!=null?V:e.defaultValue)!=null?P:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=ru(()=>new Set),o=ru(()=>new Map),i=ru(()=>new Map),s=ru(()=>new Set),a=LL(e),{label:l,children:c,value:u,onValueChange:d,filter:h,shouldFilter:p,loop:m,disablePointerSelection:g=!1,vimBindings:b=!0,...y}=e,v=yn(),x=yn(),S=yn(),_=w.useRef(null),E=jse();tc(()=>{if(u!==void 0){let V=u.trim();n.current.value=V,C.emit()}},[u]),tc(()=>{E(6,j)},[]);let C=w.useMemo(()=>({subscribe:V=>(s.current.add(V),()=>s.current.delete(V)),snapshot:()=>n.current,setState:(V,P,W)=>{var $,q,U,G;if(!Object.is(n.current[V],P)){if(n.current[V]=P,V==="search")A(),N(),E(1,D);else if(V==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Y=document.getElementById(S);Y?Y.focus():($=document.getElementById(v))==null||$.focus()}if(E(7,()=>{var Y;n.current.selectedItemId=(Y=O())==null?void 0:Y.id,C.emit()}),W||E(5,j),((q=a.current)==null?void 0:q.value)!==void 0){let Y=P??"";(G=(U=a.current).onValueChange)==null||G.call(U,Y);return}}C.emit()}},emit:()=>{s.current.forEach(V=>V())}}),[]),R=w.useMemo(()=>({value:(V,P,W)=>{var $;P!==(($=i.current.get(V))==null?void 0:$.value)&&(i.current.set(V,{value:P,keywords:W}),n.current.filtered.items.set(V,M(P,W)),E(2,()=>{N(),C.emit()}))},item:(V,P)=>(r.current.add(V),P&&(o.current.has(P)?o.current.get(P).add(V):o.current.set(P,new Set([V]))),E(3,()=>{A(),N(),n.current.value||D(),C.emit()}),()=>{i.current.delete(V),r.current.delete(V),n.current.filtered.items.delete(V);let W=O();E(4,()=>{A(),(W==null?void 0:W.getAttribute("id"))===V&&D(),C.emit()})}),group:V=>(o.current.has(V)||o.current.set(V,new Set),()=>{i.current.delete(V),o.current.delete(V)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:v,inputId:S,labelId:x,listInnerRef:_}),[]);function M(V,P){var W,$;let q=($=(W=a.current)==null?void 0:W.filter)!=null?$:Ese;return V?q(V,n.current.search,P):0}function N(){if(!n.current.search||a.current.shouldFilter===!1)return;let V=n.current.filtered.items,P=[];n.current.filtered.groups.forEach($=>{let q=o.current.get($),U=0;q.forEach(G=>{let Y=V.get(G);U=Math.max(Y,U)}),P.push([$,U])});let W=_.current;I().sort(($,q)=>{var U,G;let Y=$.getAttribute("id"),Q=q.getAttribute("id");return((U=V.get(Q))!=null?U:0)-((G=V.get(Y))!=null?G:0)}).forEach($=>{let q=$.closest(Yx);q?q.appendChild($.parentElement===q?$:$.closest(`${Yx} > *`)):W.appendChild($.parentElement===W?$:$.closest(`${Yx} > *`))}),P.sort(($,q)=>q[1]-$[1]).forEach($=>{var q;let U=(q=_.current)==null?void 0:q.querySelector(`${tf}[${nu}="${encodeURIComponent($[0])}"]`);U==null||U.parentElement.appendChild(U)})}function D(){let V=I().find(W=>W.getAttribute("aria-disabled")!=="true"),P=V==null?void 0:V.getAttribute(nu);C.setState("value",P||void 0)}function A(){var V,P,W,$;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let q=0;for(let U of r.current){let G=(P=(V=i.current.get(U))==null?void 0:V.value)!=null?P:"",Y=($=(W=i.current.get(U))==null?void 0:W.keywords)!=null?$:[],Q=M(G,Y);n.current.filtered.items.set(U,Q),Q>0&&q++}for(let[U,G]of o.current)for(let Y of G)if(n.current.filtered.items.get(Y)>0){n.current.filtered.groups.add(U);break}n.current.filtered.count=q}function j(){var V,P,W;let $=O();$&&(((V=$.parentElement)==null?void 0:V.firstChild)===$&&((W=(P=$.closest(tf))==null?void 0:P.querySelector(Sse))==null||W.scrollIntoView({block:"nearest"})),$.scrollIntoView({block:"nearest"}))}function O(){var V;return(V=_.current)==null?void 0:V.querySelector(`${IL}[aria-selected="true"]`)}function I(){var V;return Array.from(((V=_.current)==null?void 0:V.querySelectorAll(WM))||[])}function L(V){let P=I()[V];P&&C.setState("value",P.getAttribute(nu))}function F(V){var P;let W=O(),$=I(),q=$.findIndex(G=>G===W),U=$[q+V];(P=a.current)!=null&&P.loop&&(U=q+V<0?$[$.length-1]:q+V===$.length?$[0]:$[q+V]),U&&C.setState("value",U.getAttribute(nu))}function B(V){let P=O(),W=P==null?void 0:P.closest(tf),$;for(;W&&!$;)W=V>0?Ise(W,tf):Tse(W,tf),$=W==null?void 0:W.querySelector(WM);$?C.setState("value",$.getAttribute(nu)):F(V)}let z=()=>L(I().length-1),T=V=>{V.preventDefault(),V.metaKey?z():V.altKey?B(1):F(1)},H=V=>{V.preventDefault(),V.metaKey?L(0):V.altKey?B(-1):F(-1)};return w.createElement(Re.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:V=>{var P;(P=y.onKeyDown)==null||P.call(y,V);let W=V.nativeEvent.isComposing||V.keyCode===229;if(!(V.defaultPrevented||W))switch(V.key){case"n":case"j":{b&&V.ctrlKey&&T(V);break}case"ArrowDown":{T(V);break}case"p":case"k":{b&&V.ctrlKey&&H(V);break}case"ArrowUp":{H(V);break}case"Home":{V.preventDefault(),L(0);break}case"End":{V.preventDefault(),z();break}case"Enter":{V.preventDefault();let $=O();if($){let q=new Event(qC);$.dispatchEvent(q)}}}}},w.createElement("label",{"cmdk-label":"",htmlFor:R.inputId,id:R.labelId,style:Fse},l),Fy(e,V=>w.createElement(jL.Provider,{value:C},w.createElement(TL.Provider,{value:R},V))))}),_se=w.forwardRef((e,t)=>{var n,r;let o=yn(),i=w.useRef(null),s=w.useContext(OL),a=$p(),l=LL(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:s==null?void 0:s.forceMount;tc(()=>{if(!c)return a.item(o,s==null?void 0:s.id)},[c]);let u=$L(o,i,[e.value,e.children,i],e.keywords),d=D_(),h=Ca(E=>E.value&&E.value===u.current),p=Ca(E=>c||a.filter()===!1?!0:E.search?E.filtered.items.get(o)>0:!0);w.useEffect(()=>{let E=i.current;if(!(!E||e.disabled))return E.addEventListener(qC,m),()=>E.removeEventListener(qC,m)},[p,e.onSelect,e.disabled]);function m(){var E,C;g(),(C=(E=l.current).onSelect)==null||C.call(E,u.current)}function g(){d.setState("value",u.current,!0)}if(!p)return null;let{disabled:b,value:y,onSelect:v,forceMount:x,keywords:S,..._}=e;return w.createElement(Re.div,{ref:wr(i,t),..._,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)}),kse=w.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...i}=e,s=yn(),a=w.useRef(null),l=w.useRef(null),c=yn(),u=$p(),d=Ca(p=>o||u.filter()===!1?!0:p.search?p.filtered.groups.has(s):!0);tc(()=>u.group(s),[]),$L(s,a,[e.value,e.heading,l]);let h=w.useMemo(()=>({id:s,forceMount:o}),[o]);return w.createElement(Re.div,{ref:wr(a,t),...i,"cmdk-group":"",role:"presentation",hidden:d?void 0:!0},n&&w.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Fy(e,p=>w.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},w.createElement(OL.Provider,{value:h},p))))}),Rse=w.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=w.useRef(null),i=Ca(s=>!s.search);return!n&&!i?null:w.createElement(Re.div,{ref:wr(o,t),...r,"cmdk-separator":"",role:"separator"})}),Nse=w.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,i=D_(),s=Ca(c=>c.search),a=Ca(c=>c.selectedItemId),l=$p();return w.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),w.createElement(Re.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:s,onChange:c=>{o||i.setState("search",c.target.value),n==null||n(c.target.value)}})}),Ase=w.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,i=w.useRef(null),s=w.useRef(null),a=Ca(c=>c.selectedItemId),l=$p();return w.useEffect(()=>{if(s.current&&i.current){let c=s.current,u=i.current,d,h=new ResizeObserver(()=>{d=requestAnimationFrame(()=>{let p=c.offsetHeight;u.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return h.observe(c),()=>{cancelAnimationFrame(d),h.unobserve(c)}}},[]),w.createElement(Re.div,{ref:wr(i,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Fy(e,c=>w.createElement("div",{ref:wr(s,l.listInnerRef),"cmdk-list-sizer":""},c)))}),Mse=w.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:i,container:s,...a}=e;return w.createElement(kF,{open:n,onOpenChange:r},w.createElement(RF,{container:s},w.createElement(e_,{"cmdk-overlay":"",className:o}),w.createElement(t_,{"aria-label":e.label,"cmdk-dialog":"",className:i},w.createElement(FL,{ref:t,...a}))))}),Pse=w.forwardRef((e,t)=>Ca(n=>n.filtered.count===0)?w.createElement(Re.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Dse=w.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...i}=e;return w.createElement(Re.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Fy(e,s=>w.createElement("div",{"aria-hidden":!0},s)))}),Ur=Object.assign(FL,{List:Ase,Item:_se,Input:Nse,Group:kse,Separator:Rse,Dialog:Mse,Empty:Pse,Loading:Dse});function Ise(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Tse(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function LL(e){let t=w.useRef(e);return tc(()=>{t.current=e}),t}var tc=typeof window>"u"?w.useEffect:w.useLayoutEffect;function ru(e){let t=w.useRef();return t.current===void 0&&(t.current=e()),t}function Ca(e){let t=D_(),n=()=>e(t.snapshot());return w.useSyncExternalStore(t.subscribe,n,n)}function $L(e,t,n,r=[]){let o=w.useRef(),i=$p();return tc(()=>{var s;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());i.value(e,a,l),(s=t.current)==null||s.setAttribute(nu,a),o.current=a}),o}var jse=()=>{let[e,t]=w.useState(),n=ru(()=>new Map);return tc(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function Ose(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Fy({asChild:e,children:t},n){return e&&w.isValidElement(t)?w.cloneElement(Ose(t),{ref:t.ref},n(t.props.children)):n(t)}var Fse={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Ly=w.forwardRef(({className:e,...t},n)=>f.jsx(Ur,{ref:n,className:re("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Ly.displayName=Ur.displayName;const $y=w.forwardRef(({className:e,...t},n)=>f.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[f.jsx(U2,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),f.jsx(Ur.Input,{ref:n,className:re("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})]}));$y.displayName=Ur.Input.displayName;const zy=w.forwardRef(({className:e,...t},n)=>f.jsx(Ur.List,{ref:n,className:re("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));zy.displayName=Ur.List.displayName;const By=w.forwardRef((e,t)=>f.jsx(Ur.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));By.displayName=Ur.Empty.displayName;const Vy=w.forwardRef(({className:e,...t},n)=>f.jsx(Ur.Group,{ref:n,className:re("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}));Vy.displayName=Ur.Group.displayName;const Lse=w.forwardRef(({className:e,...t},n)=>f.jsx(Ur.Separator,{ref:n,className:re("-mx-1 h-px bg-border",e),...t}));Lse.displayName=Ur.Separator.displayName;const Hy=w.forwardRef(({className:e,...t},n)=>f.jsx(Ur.Item,{ref:n,className:re("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}));Hy.displayName=Ur.Item.displayName;function $se({fields:e,value:t,onValueChange:n,placeholder:r="Select field...",className:o,disabled:i=!1,excludeFieldIds:s=[]}){const[a,l]=k.useState(!1),c=e.filter(d=>!s.includes(d.id)),u=c.find(d=>d.id===t);return f.jsxs(Rc,{open:a,onOpenChange:l,children:[f.jsx(Nc,{asChild:!0,children:f.jsxs(_e,{variant:"outline",role:"combobox","aria-expanded":a,className:re("justify-between",o),disabled:i,children:[u?u.label:r,f.jsx(S4,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),f.jsx(Fa,{className:"z-50 w-[200px] p-0",children:f.jsxs(Ly,{children:[f.jsx($y,{placeholder:"Search fields..."}),f.jsxs(zy,{children:[f.jsx(By,{children:"No field found."}),f.jsx(Vy,{children:c.map(d=>f.jsxs(Hy,{value:d.label,onSelect:()=>{n(d.id),l(!1)},children:[f.jsx(Wn,{className:re("mr-2 h-4 w-4",t===d.id?"opacity-100":"opacity-0")}),d.label]},d.id))})]})]})})]})}function zse({hierarchy:e,editingHierarchy:t,sampleFieldReferences:n,onSetEditingHierarchy:r,onUpdateHierarchy:o,onDeleteHierarchy:i,onSetDefaultHierarchy:s,onUpdateStep:a,onRemoveStep:l,onAddStep:c}){const u=t===e.id,{attributes:d,listeners:h,setNodeRef:p,transform:m,transition:g}=d_({id:e.id,disabled:u}),b={transform:Di.Transform.toString(m),transition:g},y=e.steps.filter(v=>v.field).map(v=>v.field.id);return f.jsxs("div",{ref:p,style:b,className:"hierarchy-container relative rounded-lg border bg-background p-3 transition-shadow hover:shadow-md",children:[f.jsxs("div",{className:`mb-3 flex items-center justify-between ${u?"":"cursor-move"}`,...u?{}:d,...u?{}:h,children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(toe,{value:e.label||"",isEditing:u,onEdit:()=>{r(e.id)},onSave:v=>{o(e.id,{label:v}),r(null)},onCancel:()=>r(null),placeholder:"Hierarchy Name",displayClassName:"font-medium",inputClassName:"font-medium"}),f.jsxs("span",{className:"rounded bg-muted px-2 py-1 text-xs",children:[e.steps.length," steps"]}),e.default?f.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:v=>{v.stopPropagation(),s("")},onPointerDown:v=>v.stopPropagation(),title:"Click to remove default",children:"Default ✓"}):f.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:v=>{v.stopPropagation(),s(e.id)},onPointerDown:v=>v.stopPropagation(),title:"Set as default hierarchy",children:"Set Default"})]}),f.jsx("div",{className:"flex items-center gap-1",children:f.jsx(_e,{size:"sm",variant:"ghost",onClick:v=>{v.stopPropagation(),i(e.id)},onPointerDown:v=>v.stopPropagation(),children:f.jsx(vp,{className:"h-3 w-3"})})})]}),f.jsx(hse,{hierarchy:e,onUpdateStep:a,onRemoveStep:l,onUpdateHierarchy:o}),f.jsx("div",{className:"mt-3 border-t pt-3","data-hierarchy-editing":!0,children:f.jsx("div",{className:"flex items-center gap-2",children:f.jsx($se,{fields:n,excludeFieldIds:y,onValueChange:v=>c(e.id,v),placeholder:"Add drill step...",className:"w-48"})})})]})}function Bse({configuringIntent:e,setConfiguringIntent:t,drillHierarchies:n,onUpdateHierarchies:r,availableFields:o}){const i=o_(xh(Mp),xh(Ap,{coordinateGetter:f_})),{editingHierarchy:s,setEditingHierarchy:a,createNewHierarchy:l,deleteHierarchy:c,updateHierarchy:u,addStepToHierarchy:d,removeStepFromHierarchy:h,updateStep:p,setDefaultHierarchy:m}=eoe(n,r,o),g=b=>{const{active:y,over:v}=b;if(y.id!==(v==null?void 0:v.id)){const x=n.findIndex(_=>_.id===y.id),S=n.findIndex(_=>_.id===(v==null?void 0:v.id));r(Dp(n,x,S))}};return f.jsx("div",{className:"rounded-lg border p-4 hover:bg-muted/50",children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-blue-100",children:f.jsx(x4,{className:"h-5 w-5 text-blue-600 dark:text-blue-400"})}),f.jsxs("div",{className:"flex-1",children:[f.jsx("h4",{className:"mb-1 font-medium",children:"Let users drill deeper into specific paths"}),f.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Set up predefined drill paths like regions → cities, categories → products"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(_e,{size:"sm",variant:"outline",onClick:()=>t(e==="drillDown"?null:"drillDown"),children:e==="drillDown"?"Done":"Set up drill paths"}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:[n.length," hierarchies configured"]})]}),e==="drillDown"&&f.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:[f.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("h5",{className:"font-medium",children:"Drill Hierarchies"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"Create multiple drill paths for different analysis scenarios"})]}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(_e,{size:"sm",onClick:l,children:[f.jsx(Cc,{className:"mr-1 h-4 w-4"}),"Add Hierarchy"]})})]}),f.jsx(c_,{sensors:i,collisionDetection:i_,onDragEnd:g,children:f.jsx(u_,{items:n.map(b=>b.id),strategy:o3,children:f.jsx("div",{className:"mb-6 space-y-4",children:n.map(b=>f.jsx(zse,{hierarchy:b,editingHierarchy:s,sampleFieldReferences:o,onSetEditingHierarchy:a,onUpdateHierarchy:u,onDeleteHierarchy:c,onSetDefaultHierarchy:m,onUpdateStep:p,onRemoveStep:h,onAddStep:d},b.id))})})})]})]})]})})}var I_="Checkbox",[Vse,C$e]=Tn(I_),[Hse,Wse]=Vse(I_),zL=w.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:l="on",onCheckedChange:c,form:u,...d}=e,[h,p]=w.useState(null),m=We(t,S=>p(S)),g=w.useRef(!1),b=h?u||!!h.closest("form"):!0,[y=!1,v]=Gn({prop:o,defaultProp:i,onChange:c}),x=w.useRef(y);return w.useEffect(()=>{const S=h==null?void 0:h.form;if(S){const _=()=>v(x.current);return S.addEventListener("reset",_),()=>S.removeEventListener("reset",_)}},[h,v]),f.jsxs(Hse,{scope:n,state:y,disabled:a,children:[f.jsx(Re.button,{type:"button",role:"checkbox","aria-checked":pa(y)?"mixed":y,"aria-required":s,"data-state":HL(y),"data-disabled":a?"":void 0,disabled:a,value:l,...d,ref:m,onKeyDown:pe(e.onKeyDown,S=>{S.key==="Enter"&&S.preventDefault()}),onClick:pe(e.onClick,S=>{v(_=>pa(_)?!0:!_),b&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),b&&f.jsx(Use,{control:h,bubbles:!g.current,name:r,value:l,checked:y,required:s,disabled:a,form:u,style:{transform:"translateX(-100%)"},defaultChecked:pa(i)?!1:i})]})});zL.displayName=I_;var BL="CheckboxIndicator",VL=w.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=Wse(BL,n);return f.jsx(vn,{present:r||pa(i.state)||i.state===!0,children:f.jsx(Re.span,{"data-state":HL(i.state),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});VL.displayName=BL;var Use=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:o,...i}=e,s=w.useRef(null),a=Iy(n),l=Py(t);w.useEffect(()=>{const u=s.current,d=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(d,"checked").set;if(a!==n&&p){const m=new Event("click",{bubbles:r});u.indeterminate=pa(n),p.call(u,pa(n)?!1:n),u.dispatchEvent(m)}},[a,n,r]);const c=w.useRef(pa(n)?!1:n);return f.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??c.current,...i,tabIndex:-1,ref:s,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function pa(e){return e==="indeterminate"}function HL(e){return pa(e)?"indeterminate":e?"checked":"unchecked"}var WL=zL,Gse=VL;const co=w.forwardRef(({className:e,...t},n)=>f.jsx(WL,{ref:n,className:re("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:f.jsx(Gse,{className:re("flex items-center justify-center text-current"),children:f.jsx(Wn,{className:"h-4 w-4"})})}));co.displayName=WL.displayName;function qse({fields:e,selectedFieldIds:t,onSelectionChange:n,searchPlaceholder:r="Search fields...",className:o=""}){const[i,s]=k.useState(""),a=e.filter(u=>u.label.toLowerCase().includes(i.toLowerCase())||u.qualifiedEntityName&&u.qualifiedEntityName.toLowerCase().includes(i.toLowerCase())),l=()=>{const u=[...new Set([...t,...a.map(d=>d.id)])];n(u)},c=()=>{const u=a.map(d=>d.id);n(t.filter(d=>!u.includes(d)))};return f.jsxs("div",{className:`space-y-2 ${o}`,children:[f.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[f.jsx(zr,{placeholder:r,value:i,onChange:u=>s(u.target.value),className:"flex-1"}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:[a.length," fields"]})]}),f.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[f.jsx(_e,{size:"sm",variant:"outline",onClick:l,children:"Select All"}),f.jsx(_e,{size:"sm",variant:"outline",onClick:c,children:"Deselect All"}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.length," selected"]})]}),f.jsx("div",{className:"grid max-h-32 grid-cols-2 gap-2 overflow-y-auto rounded border p-2",children:a.map(u=>f.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded border p-2 text-xs hover:bg-muted/50",children:[f.jsx(co,{checked:t.includes(u.id),onCheckedChange:d=>{n(d?[...t,u.id]:t.filter(h=>h!==u.id))}}),f.jsx("span",{className:"font-medium",children:u.label})]},u.id))}),i&&a.length===0&&f.jsxs("div",{className:"py-4 text-center text-sm text-muted-foreground",children:['No fields found matching "',i,'"']})]})}const Yse=e=>["string","boolean"].includes(K0(e.dataType));function Kse({configuringIntent:e,setConfiguringIntent:t,selectedDrillTargets:n,setSelectedDrillTargets:r,availableFields:o}){const i=o.filter(Yse),s=n.map(l=>l.id),a=l=>{const c=i.filter(u=>l.includes(u.id));r(c)};return f.jsx("div",{className:"rounded-lg border p-4 hover:bg-muted/50",children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-green-100",children:f.jsx(D4,{className:"h-5 w-5 text-green-600 dark:text-green-400"})}),f.jsxs("div",{className:"flex-1",children:[f.jsx("h4",{className:"mb-1 font-medium",children:"Give users freedom to explore any dimension"}),f.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Let users dynamically drill into any available field they choose"}),f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(_e,{size:"sm",variant:"outline",onClick:()=>t(e==="dynamicDrill"?null:"dynamicDrill"),children:e==="dynamicDrill"?"Done":"Configure available fields"}),f.jsx("span",{className:"text-xs text-muted-foreground",children:n.length>0?`${n.length} fields selected`:"All fields available"})]}),e==="dynamicDrill"&&f.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:[f.jsx("h5",{className:"mb-3 font-medium",children:"Configure Dynamic Drilling"}),f.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Choose which fields users can explore dynamically:"}),f.jsx("div",{className:"border-l-2 border-green-200 pl-4",children:f.jsx(qse,{fields:i,selectedFieldIds:s,onSelectionChange:a,searchPlaceholder:"Search fields..."})})]})]})]})]})})}var T_="Switch",[Xse,S$e]=Tn(T_),[Qse,Jse]=Xse(T_),UL=w.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:l="on",onCheckedChange:c,form:u,...d}=e,[h,p]=w.useState(null),m=We(t,x=>p(x)),g=w.useRef(!1),b=h?u||!!h.closest("form"):!0,[y=!1,v]=Gn({prop:o,defaultProp:i,onChange:c});return f.jsxs(Qse,{scope:n,checked:y,disabled:a,children:[f.jsx(Re.button,{type:"button",role:"switch","aria-checked":y,"aria-required":s,"data-state":YL(y),"data-disabled":a?"":void 0,disabled:a,value:l,...d,ref:m,onClick:pe(e.onClick,x=>{v(S=>!S),b&&(g.current=x.isPropagationStopped(),g.current||x.stopPropagation())})}),b&&f.jsx(Zse,{control:h,bubbles:!g.current,name:r,value:l,checked:y,required:s,disabled:a,form:u,style:{transform:"translateX(-100%)"}})]})});UL.displayName=T_;var GL="SwitchThumb",qL=w.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=Jse(GL,n);return f.jsx(Re.span,{"data-state":YL(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});qL.displayName=GL;var Zse=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,i=w.useRef(null),s=Iy(n),a=Py(t);return w.useEffect(()=>{const l=i.current,c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&d){const h=new Event("click",{bubbles:r});d.call(l,n),l.dispatchEvent(h)}},[s,n,r]),f.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:i,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function YL(e){return e?"checked":"unchecked"}var Wy=UL,KL=qL;const j_=w.forwardRef(({className:e,...t},n)=>f.jsx(Wy,{className:re("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:f.jsx(KL,{className:re("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")})}));j_.displayName=Wy.displayName;var O_="Radio",[eae,XL]=Tn(O_),[tae,nae]=eae(O_),QL=w.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:o=!1,required:i,disabled:s,value:a="on",onCheck:l,form:c,...u}=e,[d,h]=w.useState(null),p=We(t,b=>h(b)),m=w.useRef(!1),g=d?c||!!d.closest("form"):!0;return f.jsxs(tae,{scope:n,checked:o,disabled:s,children:[f.jsx(Re.button,{type:"button",role:"radio","aria-checked":o,"data-state":e$(o),"data-disabled":s?"":void 0,disabled:s,value:a,...u,ref:p,onClick:pe(e.onClick,b=>{o||l==null||l(),g&&(m.current=b.isPropagationStopped(),m.current||b.stopPropagation())})}),g&&f.jsx(rae,{control:d,bubbles:!m.current,name:r,value:a,checked:o,required:i,disabled:s,form:c,style:{transform:"translateX(-100%)"}})]})});QL.displayName=O_;var JL="RadioIndicator",ZL=w.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...o}=e,i=nae(JL,n);return f.jsx(vn,{present:r||i.checked,children:f.jsx(Re.span,{"data-state":e$(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t})})});ZL.displayName=JL;var rae=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,i=w.useRef(null),s=Iy(n),a=Py(t);return w.useEffect(()=>{const l=i.current,c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&d){const h=new Event("click",{bubbles:r});d.call(l,n),l.dispatchEvent(h)}},[s,n,r]),f.jsx("input",{type:"radio","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:i,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function e$(e){return e?"checked":"unchecked"}var oae=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],F_="RadioGroup",[iae,E$e]=Tn(F_,[wd,XL]),t$=wd(),n$=XL(),[sae,aae]=iae(F_),r$=w.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:o,value:i,required:s=!1,disabled:a=!1,orientation:l,dir:c,loop:u=!0,onValueChange:d,...h}=e,p=t$(n),m=yc(c),[g,b]=Gn({prop:i,defaultProp:o,onChange:d});return f.jsx(sae,{scope:n,name:r,required:s,disabled:a,value:g,onValueChange:b,children:f.jsx(c2,{asChild:!0,...p,orientation:l,dir:m,loop:u,children:f.jsx(Re.div,{role:"radiogroup","aria-required":s,"aria-orientation":l,"data-disabled":a?"":void 0,dir:m,...h,ref:t})})})});r$.displayName=F_;var o$="RadioGroupItem",i$=w.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...o}=e,i=aae(o$,n),s=i.disabled||r,a=t$(n),l=n$(n),c=w.useRef(null),u=We(t,c),d=i.value===o.value,h=w.useRef(!1);return w.useEffect(()=>{const p=g=>{oae.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)}},[]),f.jsx(u2,{asChild:!0,...a,focusable:!s,active:d,children:f.jsx(QL,{disabled:s,required:i.required,checked:d,...l,...o,name:i.name,ref:u,onCheck:()=>i.onValueChange(o.value),onKeyDown:pe(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:pe(o.onFocus,()=>{var p;h.current&&((p=c.current)==null||p.click())})})})});i$.displayName=o$;var lae="RadioGroupIndicator",s$=w.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,o=n$(n);return f.jsx(ZL,{...o,...r,ref:t})});s$.displayName=lae;var a$=r$,l$=i$,cae=s$;const Sa=w.forwardRef(({className:e,...t},n)=>f.jsx(a$,{className:re("grid gap-2",e),...t,ref:n}));Sa.displayName=a$.displayName;const Lr=w.forwardRef(({className:e,...t},n)=>f.jsx(l$,{ref:n,className:re("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:f.jsx(cae,{className:"flex items-center justify-center",children:f.jsx(F2,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Lr.displayName=l$.displayName;function uae({configuringIntent:e,setConfiguringIntent:t,incomingFilterFields:n,onUpdateClickFilterInteractions:r,currentClickFilterInteractions:o}){const[i,s]=k.useState(o.length>0),[a,l]=k.useState(o[0]||{filterFields:[],highlightSelf:!0}),[c,u]=k.useState(""),d=NO(),h=e==="clickFilter",p=()=>{const E=!i;if(s(E),E){const C={filterFields:n,highlightSelf:!0,mode:"clickFilter"};l(C),r([C])}else r([])},m=()=>{t("clickFilter")},g=()=>{t(null)},b=E=>{const C={...a,...E};l(C),r([C])},y=()=>a.applyToCardIds!==void 0?"specific-cards":a.excludeCardIds!==void 0?"all-except-specific":"all-cards",v=E=>{const C={};switch(E){case"all-cards":C.applyToCardIds=void 0,C.excludeCardIds=void 0;break;case"specific-cards":C.applyToCardIds=[],C.excludeCardIds=void 0;break;case"all-except-specific":C.applyToCardIds=void 0,C.excludeCardIds=[];break}b(C)},x=(E,C)=>{if(C==="specific-cards"){const R=a.applyToCardIds||[],M=R.includes(E)?R.filter(N=>N!==E):[...R,E];b({applyToCardIds:M})}else if(C==="all-except-specific"){const R=a.excludeCardIds||[],M=R.includes(E)?R.filter(N=>N!==E):[...R,E];b({excludeCardIds:M})}},S=k.useMemo(()=>{if(!c.trim())return d;const E=c.toLowerCase();return d==null?void 0:d.filter(C=>{var R;return(R=C==null?void 0:C.title)==null?void 0:R.toLowerCase().includes(E)})},[c,d]),_=()=>{var C,R;if(!i)return"0 settings configured";const E=y();if(E==="all-cards")return"filtering all cards";if(E==="specific-cards"){const M=((C=a.applyToCardIds)==null?void 0:C.length)||0;return M===0?"no cards selected":`filtering ${M} card${M!==1?"s":""}`}else if(E==="all-except-specific"){const M=((R=a.excludeCardIds)==null?void 0:R.length)||0;return M===0?"filtering all cards":`excluding ${M} card${M!==1?"s":""}`}return"0 settings configured"};return f.jsx("div",{className:"rounded-lg border p-4 hover:bg-muted/50",children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-green-100",children:f.jsx("svg",{className:"h-5 w-5 text-green-600 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.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"})})}),f.jsxs("div",{className:"flex-1",children:[f.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[f.jsx("h4",{className:"font-medium",children:"Enable click filters"}),f.jsx(j_,{checked:i,onCheckedChange:p})]}),f.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Apply filters to other cards when users click on chart elements"}),i&&f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(_e,{size:"sm",variant:"outline",onClick:h?g:m,children:h?"Done":"Configure"}),f.jsx("span",{className:"text-xs text-muted-foreground",children:_()})]}),h&&i&&f.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:[f.jsx("h5",{className:"mb-3 font-medium",children:"Configure Click Filters"}),f.jsx("div",{className:"space-y-6",children:f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"space-y-0.5",children:[f.jsx(ve,{className:"text-sm font-medium",children:"Filter scope"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose which cards should receive the filter"})]}),f.jsxs(Sa,{value:y(),onValueChange:E=>v(E),className:"space-y-3",children:[f.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[f.jsx(Lr,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),f.jsxs("div",{className:"flex-1 space-y-1",children:[f.jsx(ve,{htmlFor:"all-cards",className:"cursor-pointer text-sm font-medium",children:"All cards"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards in the dashboard"})]})]}),f.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[f.jsx(Lr,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),f.jsxs("div",{className:"flex-1 space-y-1",children:[f.jsx(ve,{htmlFor:"specific-cards",className:"cursor-pointer text-sm font-medium",children:"Only specific cards"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to selected cards only"})]})]}),y()==="specific-cards"&&f.jsxs("div",{className:"ml-7 space-y-2",children:[f.jsxs("div",{className:"space-y-0.5",children:[f.jsx(ve,{className:"text-sm font-medium",children:"Cards to filter"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should receive the filter"})]}),f.jsx(zr,{placeholder:"Search cards...",value:c,onChange:E=>u(E.target.value),className:"mb-2"}),f.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:S.length>0?S.map(E=>{const C=(a.applyToCardIds||[]).includes(E.id);return f.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[f.jsx(co,{id:`card-${E.id}`,checked:C,onCheckedChange:()=>x(E.id,"specific-cards")}),f.jsxs("div",{className:"flex-1",children:[f.jsx(ve,{htmlFor:`card-${E.id}`,className:"cursor-pointer text-sm font-medium",children:E.title}),E.description&&f.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:E.description})]})]},E.id)}):f.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',c,'"']})})]}),f.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[f.jsx(Lr,{value:"all-except-specific",id:"all-except-specific",className:"mt-0.5"}),f.jsxs("div",{className:"flex-1 space-y-1",children:[f.jsx(ve,{htmlFor:"all-except-specific",className:"cursor-pointer text-sm font-medium",children:"All cards except specific ones"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards, excluding selected ones"})]})]}),y()==="all-except-specific"&&f.jsxs("div",{className:"ml-7 space-y-2",children:[f.jsxs("div",{className:"space-y-0.5",children:[f.jsx(ve,{className:"text-sm font-medium",children:"Cards to exclude"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should be excluded from filtering"})]}),f.jsx(zr,{placeholder:"Search cards...",value:c,onChange:E=>u(E.target.value),className:"mb-2"}),f.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:S.length>0?S.map(E=>{const C=(a.excludeCardIds||[]).includes(E.id);return f.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[f.jsx(co,{id:`card-exclude-${E.id}`,checked:C,onCheckedChange:()=>x(E.id,"all-except-specific")}),f.jsxs("div",{className:"flex-1",children:[f.jsx(ve,{htmlFor:`card-exclude-${E.id}`,className:"cursor-pointer text-sm font-medium",children:E.title}),E.description&&f.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:E.description})]})]},E.id)}):f.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',c,'"']})})]})]})]})})]})]})]})})}function dae(e){return e.flatMap(t=>t.columns.map(n=>({id:`${t.entityId}-${n.name}`,name:n.name,dataType:n.dataType,qualifiedEntityName:t.qualifiedEntityName,label:n.label||e2(n.name),description:n.description,entityId:t.entityId,entityName:t.entityName,entityType:t.entityType})))}function YC(e){if(e.type==="table"||e.type==="view"||e.type==="dataset"){if(e.database&&e.schema)return`${e.database}.${e.schema}.${e.name}`;if(e.schema)return`${e.schema}.${e.name}`;if(e.database)return`${e.database}.${e.name}`}return e.name}function c$(e){var g;const t=oe(b=>b.authToken)||e,{hasSchemaSupport:n}=Aee(e),r=Ae(b=>{var y;return(y=b.card.dataSource)==null?void 0:y.connectionId}),o=Ae(b=>{var y,v;return(v=(y=b.card.dataSource)==null?void 0:y.selectedEntities)==null?void 0:v.filter(x=>x.type==="model")})||[],i=Ae(b=>{var y,v;return(v=(y=b.card.dataSource)==null?void 0:y.selectedEntities)==null?void 0:v.filter(x=>x.type==="table"||x.type==="view")})||[],s=Ae(b=>{var y,v;return(v=(y=b.card.dataSource)==null?void 0:y.selectedEntities)==null?void 0:v.filter(x=>x.type==="dataset")})||[];function a(b){return b.type==="dataset"?!!r&&!!b.domainId&&!!b.name:b.type==="model"?!!r&&!!b.id:b.type==="table"||b.type==="view"?n?!!r&&!!b.name&&!!b.database&&!!b.schema:["S3","API"].includes(b.connectionType)?!!r&&!!b.name:!!r&&!!b.name&&!!b.database:!1}const l=[...o,...i,...s],c=t5({queries:l.map(b=>{let y={};return b.type==="model"?y={connection_id:r,datamodel_id:b.id,database_name:"",schema_name:"",table_name:""}:b.type==="dataset"?y={connection_id:b.connectionId,domain_id:b.domainId,dataset_name:b.name}:y={connection_id:r,datamodel_id:"",database_name:b.database,schema_name:b.schema,table_name:b.name},{queryKey:["columns",r,b],queryFn:()=>xr("https://semaphor.cloud/api/v1/columns",(t==null?void 0:t.accessToken)||"",y),enabled:!!r&&a(b)}})}),u=c.some(b=>b.isPending),d=c.some(b=>b.isError),h=(g=c.find(b=>b.isError))==null?void 0:g.error,p=c.map((b,y)=>{var S;const v=l[y],x=YC(v);return{entityId:v.id||v.name,entityType:v.type,entityName:v.name,label:v.label,description:v.description,qualifiedEntityName:x,columns:(S=b.data)==null?void 0:S.columns.map(_=>({id:`${v.name}-${_.column_name}`,name:_.column_name,dataType:_.data_type,label:_.label||t2(_.column_name),description:_.description||"",qualifiedEntityName:x,entityId:v.id||v.id||v.name,entityName:v.name,entityType:v.type}))}}).filter(b=>{var y;return((y=b==null?void 0:b.columns)==null?void 0:y.length)>0})||[],m=dae(p);return{columnGroups:p,columns:m,isLoading:u,hasError:d,error:h,refetch:()=>{c.forEach(b=>b.refetch())}}}function fae({isOpen:e,onClose:t}){var I,L,F,B;const n=vee(),r=xee(),{updateCurrentDashboardCard:o}=dn(),{columns:i}=c$(),{groupByFields:s,pivotByFields:a}=AO(),l=[...s,...a],c=i,u=((I=n.interactionConfig)==null?void 0:I.drillHierarchies)||[],d=((L=n.interactionConfig)==null?void 0:L.allowedDrillTargets)||[],h=k.useMemo(()=>{var z;return((z=n.interactionConfig)==null?void 0:z.clickFilterInteractions)||[]},[(F=n.interactionConfig)==null?void 0:F.clickFilterInteractions]),p=k.useMemo(()=>{var z;return((z=n.interactionConfig)==null?void 0:z.drillInteractions)||[]},[(B=n.interactionConfig)==null?void 0:B.drillInteractions]),[m,g]=k.useState(u),[b,y]=k.useState(d||[]),[v,x]=k.useState(null),[S,_]=k.useState(()=>p.filter(z=>z.mode==="drillToURL")),[E,C]=k.useState(()=>p.filter(z=>z.mode==="drillThrough")),[R,M]=k.useState(()=>p.filter(z=>z.mode==="drillToDetail")),[N,D]=k.useState(h),A=k.useRef(null);k.useEffect(()=>{var z,T,H;if(e){g(((z=n.interactionConfig)==null?void 0:z.drillHierarchies)||[]),y(((T=n.interactionConfig)==null?void 0:T.allowedDrillTargets)||[]),x(null);const V=((H=n.interactionConfig)==null?void 0:H.drillInteractions)||[];_(V.filter(P=>P.mode==="drillToURL")),C(V.filter(P=>P.mode==="drillThrough")),M(V.filter(P=>P.mode==="drillToDetail")),D(h)}},[e,n.interactionConfig,h]);const j=()=>{var H;const z=[...S,...E,...R];r.updateDrillHierarchies(m),r.updateDrillInteractions(z),(H=A.current)!=null&&H.saveToGlobal&&A.current.saveToGlobal(),r.updateAllowedDrillTargets(b);const T={...n,interactionConfig:{...n.interactionConfig,drillHierarchies:m,allowedDrillTargets:b,drillInteractions:z,clickFilterInteractions:N}};o(T),t()},O=()=>{x(null),t()};return e?f.jsxs(vy,{modal:!1,open:e,onOpenChange:t,children:[f.jsx("div",{className:"pointer-events-none fixed inset-0 z-40 bg-background/80 backdrop-blur-sm"}),f.jsxs(wp,{className:"flex max-h-[90vh] max-w-4xl flex-col overflow-hidden",children:[f.jsxs(Cp,{children:[f.jsx(Ep,{children:"Configure Interactions"}),f.jsx(_p,{children:"Set up drill behaviors for this chart"})]}),f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsx("div",{className:"space-y-6",children:f.jsx("div",{children:f.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[f.jsx(uae,{configuringIntent:v,setConfiguringIntent:x,incomingFilterFields:l,onUpdateClickFilterInteractions:D,currentClickFilterInteractions:N}),f.jsx(Bse,{configuringIntent:v,setConfiguringIntent:x,drillHierarchies:m,onUpdateHierarchies:g,availableFields:c}),f.jsx(Kse,{configuringIntent:v,setConfiguringIntent:x,selectedDrillTargets:b,setSelectedDrillTargets:y,availableFields:c})]})})})}),f.jsxs(Sp,{className:"border-t-0",children:[f.jsx(_e,{variant:"outline",onClick:O,children:"Cancel"}),f.jsx(_e,{onClick:j,children:"Save Changes"})]})]})]}):null}function u$({frame:e}){var h;const t=oe(p=>p.isDashboardEditing),n=oe(p=>p.isVisualEditing),r=oe(p=>p.selectedSheetId),[o,i]=k.useState(!1),s=e.cards.find(p=>p.id===e.activeCardId),{removeFrame:a}=oe(p=>p.actions),l=oe(p=>p.actions.setIsVisualEditing),{handleEditVisual:c,card:u,data:d}=Mee(e);return f.jsx("section",{onMouseDown:p=>{p.stopPropagation()},className:"absolute right-2 top-2 z-50",children:f.jsxs("div",{className:"flex items-center gap-2",children:[t&&(s==null?void 0:s.config)&&f.jsx("button",{onClick:()=>i(!0),children:f.jsx(Ml,{className:"size-3.5 text-center text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})}),f.jsx(fae,{isOpen:o,onClose:()=>i(!1)}),t&&(n?f.jsx("button",{onClick:()=>{l(!n)},children:f.jsx(mZ,{className:"size-3.5 text-center text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})}):f.jsx("button",{role:"edit-visual",onClick:()=>c(),children:f.jsx(bZ,{className:"ml-1 size-3.5 text-center text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})})),t&&f.jsx("button",{onClick:()=>a(r,e.id),children:f.jsx(g4,{className:"size-3.5 text-center text-muted-foreground/70 hover:cursor-pointer hover:text-muted-foreground"})}),((h=u.preferences)==null?void 0:h.allowDownload)===!0&&f.jsx(UZ,{data:(d==null?void 0:d.records)||[],filename:u.title})]})})}const hae=k.createContext(null),Kx={didCatch:!1,error:null};class zp extends k.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Kx}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,o=arguments.length,i=new Array(o),s=0;s<o;s++)i[s]=arguments[s];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:i,reason:"imperative-api"}),this.setState(Kx)}}componentDidCatch(t,n){var r,o;(r=(o=this.props).onError)===null||r===void 0||r.call(o,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:o}=this.props;if(r&&n.error!==null&&pae(t.resetKeys,o)){var i,s;(i=(s=this.props).onReset)===null||i===void 0||i.call(s,{next:o,prev:t.resetKeys,reason:"keys"}),this.setState(Kx)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:o}=this.props,{didCatch:i,error:s}=this.state;let a=t;if(i){const l={error:s,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(l);else if(r)a=k.createElement(r,l);else if(o!==void 0)a=o;else throw s}return k.createElement(hae.Provider,{value:{didCatch:i,error:s,resetErrorBoundary:this.resetErrorBoundary}},a)}}function pae(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}function d$({customerFacingMessage:e,error:t,resetErrorBoundary:n}){return f.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center rounded-lg border border-dashed border-muted-foreground/25 bg-muted/30 p-6 text-center",children:[f.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:f.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),f.jsx("h3",{className:"mb-2 text-sm font-medium text-foreground",children:"Chart Unavailable"}),f.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:e||"Couldn't display this chart right now. Please try refreshing or check your data configuration."}),f.jsxs("button",{onClick:n,className:"inline-flex items-center justify-center rounded-md bg-primary px-3 py-2 text-xs font-medium text-primary-foreground shadow-sm transition-colors hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[f.jsx("svg",{className:"mr-1.5 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Try Again"]}),mb]})}function L_({error:e}){return f.jsx("div",{className:"flex flex-col items-center justify-center",role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",width:"100%"},children:f.jsxs("div",{style:{backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",boxShadow:"0 2px 6px rgba(0, 0, 0, 0.08)",color:"#b91c1c",fontFamily:"sans-serif",padding:"16px",textAlign:"center",flexDirection:"column",whiteSpace:"pre-wrap",position:"relative"},className:"flex flex-col justify-center space-y-1 rounded-md bg-muted p-10",children:[f.jsx("p",{className:"text-sm",children:"Something went wrong:"}),f.jsx("pre",{className:"text-xs",children:e.message})]})})}function mae({error:e,frame:t}){return f.jsxs("div",{className:"flex h-full flex-col items-center justify-center border",role:"alert",children:[f.jsx(u$,{frame:t}),f.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),f.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[f.jsx("p",{className:"text-lg font-semibold",children:"Oops! Looks like we tripped on a loose wire!"}),f.jsx("p",{className:"text-sm",children:"Something went wrong:"}),f.jsx("pre",{className:"text-xs",children:e.message})]})]})}function Dl(e,t="auto",n={}){switch(t==="auto"&&(t=vae(e,n)),t){case"number":return Uy(e,n);case"currency":return f$(e,n);case"percent":return gae(e,n);case"date":return bae(e,n);case"scientific":return yae(e,n);default:return String(e)}}function Uy(e,t={}){const{decimalPlaces:n=0,useSuffix:r=!1,prefix:o="",suffix:i="",locale:s="en-US",negativeInParentheses:a=!1}=t,l=e<0,c=Math.abs(e);let u=1,d="";if(r&&!i){const b=h$(c,s);u=b.divisor,d=b.suffix}const h=c/u;let p=s;try{new Intl.NumberFormat(s).format(0)}catch{p="en-US"}let g=new Intl.NumberFormat(p,{minimumFractionDigits:n,maximumFractionDigits:n}).format(h);return d&&(g+=d),i&&(g+=i),o&&(g=o+g),l&&(g=a?`(${g})`:`-${g}`),g}function f$(e,t={}){const{currency:n="USD",decimalPlaces:r=2,locale:o="en-US",useSuffix:i=!1,negativeInParentheses:s=!1}=t,a=e<0,l=Math.abs(e);let c=1,u="";if(i){const p=h$(l,o);c=p.divisor,u=p.suffix}const d=l/c;let h=o;try{new Intl.NumberFormat(o,{style:"currency",currency:n}).format(0)}catch{h="en-US"}try{let m=new Intl.NumberFormat(h,{style:"currency",currency:n,minimumFractionDigits:r,maximumFractionDigits:r}).format(d);return u&&(m+=u),a&&!m.includes("-")&&(m=s?`(${m})`:`-${m}`),m}catch{return`${n} ${Uy(e,{...t,prefix:""})}`}}function gae(e,t={}){const{decimalPlaces:n=1,multiplyBy:r=100}=t,o=e*r;return Uy(o,{...t,decimalPlaces:n,suffix:"%",useSuffix:!1})}function bae(e,t={}){const{locale:n="en-US"}=t;try{const r=new Date(e);return isNaN(r.getTime())?String(e):new Intl.DateTimeFormat(n,{dateStyle:"short"}).format(r)}catch{return String(e)}}function yae(e,t={}){const{decimalPlaces:n=2}=t;try{const r=Number(e);return isNaN(r)?String(e):r.toExponential(n)}catch{return String(e)}}function h$(e,t){return e>=1e9?{suffix:"B",divisor:1e9}:e>=1e7&&t==="en-IN"?{suffix:"Cr",divisor:1e7}:e>=1e6?{suffix:"M",divisor:1e6}:e>=1e5&&t==="en-IN"?{suffix:"L",divisor:1e5}:e>=1e3?{suffix:"K",divisor:1e3}:{suffix:"",divisor:1}}function vae(e,t){return t.currency?"currency":typeof e=="string"&&!isNaN(Date.parse(e))?"date":"number"}function xae(e,t={}){return n=>Dl(n,e,t)}function KC({number:e,decimalPlaces:t=0,useSuffix:n=!1,customSuffix:r="",currency:o="",locale:i="en-US"}){return o?f$(e,{currency:o,decimalPlaces:t,locale:i,useSuffix:n}):Uy(e,{decimalPlaces:t,useSuffix:n,suffix:r,locale:i})}function Gy(e){try{const n=new Function("getDatalabelColor",e)(H1);return{options:n==null?void 0:n.options,plugins:(n==null?void 0:n.plugins)||[]}}catch(t){return console.error("Error processing custom visual code",t),{options:{},plugins:[]}}}function wae(e){var t,n,r,o,i,s,a,l,c,u,d,h,p,m,g,b,y,v;return!e||((r=(n=(t=e==null?void 0:e.scales)==null?void 0:t.x)==null?void 0:n.grid)==null?void 0:r.display)===!0&&((s=(i=(o=e==null?void 0:e.scales)==null?void 0:o.y)==null?void 0:i.grid)==null?void 0:s.display)===!0?"xy":(c=(l=(a=e.scales)==null?void 0:a.x)==null?void 0:l.grid)!=null&&c.display?"x":(h=(d=(u=e.scales)==null?void 0:u.y)==null?void 0:d.grid)!=null&&h.display?"y":((g=(m=(p=e.scales)==null?void 0:p.x)==null?void 0:m.grid)==null?void 0:g.display)===!1&&((v=(y=(b=e.scales)==null?void 0:b.y)==null?void 0:y.grid)==null?void 0:v.display)===!1?"none":"xy"}function Cae(e){const t=getComputedStyle(document.documentElement).getPropertyValue(e);return p$(t)}function p$(e){const[t,n,r]=e.split(" "),o=parseFloat(t),i=parseFloat(n),s=parseFloat(r),a=i/100,l=s/100,c=(1-Math.abs(2*l-1))*a,u=c*(1-Math.abs(o/60%2-1)),d=l-c/2;let h=0,p=0,m=0;0<=o&&o<60?(h=c,p=u,m=0):60<=o&&o<120?(h=u,p=c,m=0):120<=o&&o<180?(h=0,p=c,m=u):180<=o&&o<240?(h=0,p=u,m=c):240<=o&&o<300?(h=u,p=0,m=c):300<=o&&o<360&&(h=c,p=0,m=u),h=Math.round((h+d)*255),p=Math.round((p+d)*255),m=Math.round((m+d)*255);const g=b=>{const y=b.toString(16);return y.length==1?"0"+y:y};return`#${g(h)}${g(p)}${g(m)}`}function Sae(e,t){return e.map(r=>Object.fromEntries(Object.entries(r).filter(([o])=>!t.some(i=>i.label===o))))}class Bp{formatAxis(t,n){var o;if(!t)return{};const r={display:t.enabled!==!1};return t.position&&t.position!=="auto"&&(r.position=t.position),t.name&&(r.title={display:t.name.enabled,text:t.name.text||""}),t.labels&&(r.ticks={display:t.labels.enabled!==!1},t.labels.rotation!==void 0&&t.labels.rotation!=="auto"&&(r.ticks.autoSkip=!1,r.ticks.maxRotation=t.labels.rotation,r.ticks.minRotation=t.labels.rotation)),n==="value"&&((o=t.formatOptions)!=null&&o.type)&&t.formatOptions.type!=="auto"&&(r.ticks||(r.ticks={}),r.ticks.callback=this.getFormatter(t.formatOptions.type,t.formatOptions)),n==="value"&&t.scale&&(t.scale.min!=="auto"&&t.scale.min!==void 0&&(r.min=t.scale.min),t.scale.max!=="auto"&&t.scale.max!==void 0&&(r.max=t.scale.max),t.scale.stepSize!=="auto"&&t.scale.stepSize!==void 0&&(r.ticks||(r.ticks={}),r.ticks.stepSize=t.scale.stepSize)),r}getFormatter(t,n){if(!(!t||t==="auto"))return xae(t,n||{})}}class nf extends Bp{getAxisInfo(t){var r;return((r=t==null?void 0:t.chartOptions)==null?void 0:r.indexAxis)==="y"?{hasXAxis:!0,hasYAxis:!0,xAxisType:"value",yAxisType:"category",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}:{hasXAxis:!0,hasYAxis:!0,xAxisType:"category",yAxisType:"value",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}}applyConfig(t,n){var o,i,s,a,l;return((o=n==null?void 0:n.chartOptions)==null?void 0:o.indexAxis)==="y"?{...t,scales:{...t.scales,x:{...(i=t.scales)==null?void 0:i.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"value")},y:{...(s=t.scales)==null?void 0:s.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"category")}}}:{...t,scales:{...t.scales,x:{...(a=t.scales)==null?void 0:a.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"category")},y:{...(l=t.scales)==null?void 0:l.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"value")}}}}}class rf extends Bp{getAxisInfo(t){var r;return((r=t==null?void 0:t.chartOptions)==null?void 0:r.indexAxis)==="y"?{hasXAxis:!0,hasYAxis:!0,xAxisType:"value",yAxisType:"category",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}:{hasXAxis:!0,hasYAxis:!0,xAxisType:"category",yAxisType:"value",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}}applyConfig(t,n){var o,i,s,a,l;return((o=n==null?void 0:n.chartOptions)==null?void 0:o.indexAxis)==="y"?{...t,scales:{...t.scales,x:{...(i=t.scales)==null?void 0:i.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"value")},y:{...(s=t.scales)==null?void 0:s.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"category")}}}:{...t,scales:{...t.scales,x:{...(a=t.scales)==null?void 0:a.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"category")},y:{...(l=t.scales)==null?void 0:l.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"value")}}}}}class UM extends Bp{getAxisInfo(t){var r;return((r=t==null?void 0:t.chartOptions)==null?void 0:r.indexAxis)==="y"?{hasXAxis:!0,hasYAxis:!0,xAxisType:"value",yAxisType:"category",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}:{hasXAxis:!0,hasYAxis:!0,xAxisType:"category",yAxisType:"value",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}}applyConfig(t,n){var o,i,s,a,l;return((o=n==null?void 0:n.chartOptions)==null?void 0:o.indexAxis)==="y"?{...t,scales:{...t.scales,x:{...(i=t.scales)==null?void 0:i.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"value")},y:{...(s=t.scales)==null?void 0:s.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"category")}}}:{...t,scales:{...t.scales,x:{...(a=t.scales)==null?void 0:a.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"category")},y:{...(l=t.scales)==null?void 0:l.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"value")}}}}}class Xx extends Bp{getAxisInfo(){return{hasXAxis:!1,hasYAxis:!1,message:"Pie and doughnut charts do not have axes"}}applyConfig(t){return t}}class Eae extends Bp{getAxisInfo(){return{hasXAxis:!1,hasYAxis:!1,message:"Radar charts use a radial axis system"}}applyConfig(t,n){var r;return n!=null&&n.yAxisConfig?{...t,scales:{...t.scales,r:{...(r=t.scales)==null?void 0:r.r,...this.formatAxis(n.yAxisConfig,"value")}}}:t}}class $_{static getAxisInfo(t,n){return(this.handlers.get(t)||new nf).getAxisInfo(n)}static applyAxisConfig(t,n,r){return!(r!=null&&r.xAxisConfig)&&!(r!=null&&r.yAxisConfig)?t:(this.handlers.get(n)||new nf).applyConfig(t,r)}}we($_,"handlers",new Map([["bar",new rf],["horizontalBar",new rf],["line",new UM],["stackedBar",new rf],["stackedLine",new UM],["pie",new Xx],["doughnut",new Xx],["polarArea",new Xx],["radar",new Eae],["bubble",new nf],["scatter",new nf],["funnel",new nf],["tornado",new rf],["pyramid",new rf]]));function _ae(e,t){var r;if(!t)return e;const n={};return t.display!==void 0&&(n.display=t.display),t.position&&(n.position=t.position),t.align&&(n.align=t.align),{...e,plugins:{...e.plugins,legend:{...(r=e.plugins)==null?void 0:r.legend,...n}}}}function kae(e){return!["kpi","metric","text","table","pivotTable"].includes(e)}function Rae(e,t=!1,n=!1){switch(e){case"bar":case"range":return t?{anchor:"end",align:"right"}:{anchor:"end",align:"top"};case"horizontalBar":return{anchor:"end",align:"right"};case"line":case"radar":return t?{anchor:"end",align:"right"}:{anchor:"end",align:"top"};case"pie":case"doughnut":case"polarArea":case"funnel":return{anchor:"center",align:"center"};case"stackedBar":case"stackedLine":return n?t?{anchor:"end",align:"right"}:{anchor:"end",align:"top"}:{anchor:"center",align:"center"};default:return{anchor:"center",align:"center"}}}function GM(e,t,n,r){return function(o){var i,s;if(o==null)return"";if(r==="range"&&Array.isArray(o)){const a=(e==null?void 0:e.formatOptions)||(t==null?void 0:t.formatOptions)||{},l=(e==null?void 0:e.format)==="auto"?(i=t==null?void 0:t.formatOptions)==null?void 0:i.type:e==null?void 0:e.format;return o.slice(0,2).map(u=>l&&l!=="auto"&&l!=="none"?Dl(Number(u),l,a):u).join(" - ")}return(e==null?void 0:e.format)==="none"?o:!(e!=null&&e.format)||e.format==="auto"?(s=t==null?void 0:t.formatOptions)!=null&&s.type&&t.formatOptions.type!=="auto"?Dl(Number(o),t.formatOptions.type,t.formatOptions||{}):n?n(o):o:Dl(Number(o),e.format,e.formatOptions||{})}}function Um(e,t,n,r,o){if(e!=null&&e.color&&e.color!=="auto")return e.color;const i=n==="end"&&r==="top"||n==="end"&&r==="right",s=n==="start"&&r==="bottom",a=n==="start"&&r==="left";if(i){const l=da();return vs(l)}if(s||a){const l=da();return vs(l)}return l=>{var u,d,h;const c=((d=(u=l.dataset)==null?void 0:u.backgroundColor)==null?void 0:d[l.dataIndex])||((h=l.dataset)==null?void 0:h.backgroundColor)||t||da();return vs(c)}}function z_(e,t,n,r){var y,v,x,S,_,E,C,R,M,N,D,A;const o=(v=(y=n==null?void 0:n.chartOptions)==null?void 0:y.plugins)==null?void 0:v.datalabels,i=(o==null?void 0:o.display)!==!1&&((o==null?void 0:o.anchor)||(o==null?void 0:o.align));if((t==null?void 0:t.enabled)===!1)return{...e,plugins:{...e.plugins,datalabels:{display:!1}}};if(!t&&i)return e;if(!t)return{...e,plugins:{...e.plugins,datalabels:{display:!1}}};const s=r||e.type||"bar",a=((S=(x=e.scales)==null?void 0:x.x)==null?void 0:S.stacked)===!0||((E=(_=e.scales)==null?void 0:_.y)==null?void 0:E.stacked)===!0,l=((C=n==null?void 0:n.chartOptions)==null?void 0:C.indexAxis)==="y",c=l?n==null?void 0:n.xAxisConfig:n==null?void 0:n.yAxisConfig,u=Rae(s,l,t.showTotal),d=a&&!t.showTotal?"center":t.anchor||u.anchor,h=a&&!t.showTotal?"center":t.align||u.align;let p=d,m=h;const g=s==="pie"||s==="doughnut"||s==="polarArea"||s==="funnel";a&&!t.showTotal&&(p="center",m="center");const b={display:t.display!==!1,anchor:p,align:m,clamp:t.clamp??!0,clip:t.clip??!1,formatter:GM(t,c,(M=(R=e.plugins)==null?void 0:R.datalabels)==null?void 0:M.formatter,s),color:Um(t,void 0,p,m),font:{size:((N=t.font)==null?void 0:N.size)||12,weight:((D=t.font)==null?void 0:D.weight)||"normal"},rotation:t.rotation||0,offset:0};if(g&&s!=="funnel"&&(delete b.anchor,delete b.align,Object.assign(b,{anchor:"center",align:"center",offset:0,clamp:!0,clip:!1,display:function(j){if(t.display===!1)return!1;const O=j.dataset.data[j.dataIndex],I=j.dataset.data.reduce((F,B)=>F+B,0);return O/I*100>5}})),s==="funnel"&&t.enabled&&(Object.assign(b,{anchor:function(j){return j.dataset.data[j.dataIndex]<.02?"end":"start"},align:function(j){return j.dataset.data[j.dataIndex]<.02?"end":"center"},textAlign:"center",offset:0,clamp:!0,clip:!1}),b.font||(b.font={}),b.font.size=b.font.size||14),a&&t.showTotal&&(b.display=function(j){const O=j.chart.data.datasets.length;return j.datasetIndex===O-1},b.formatter=function(j,O){var B,z;let I=0;const L=O.dataIndex;return O.chart.data.datasets.forEach(T=>{const H=T.data[L];H&&!isNaN(H)&&(I+=Number(H))}),GM(t,c,(z=(B=e.plugins)==null?void 0:B.datalabels)==null?void 0:z.formatter,s)(I)},b.anchor="end",b.align=l?"right":"top",b.color=Um(t,void 0,"end",l?"right":"top")),!a&&!g&&t.position&&t.position!=="auto"&&t.position!=="custom"){if(l)switch(t.position){case"left":b.anchor="start",b.align="left";break;case"right":b.anchor="end",b.align="right";break;case"center":b.anchor="center",b.align="center";break;case"top":case"bottom":b.anchor="center",b.align="center";break}else switch(t.position){case"top":b.anchor="end",b.align="top";break;case"bottom":b.anchor="start",b.align="bottom";break;case"center":b.anchor="center",b.align="center";break;case"left":case"right":b.anchor="center",b.align="center";break}b.color=Um(t,void 0,b.anchor,b.align)}else t.position==="custom"&&(b.color=Um(t,void 0,b.anchor,b.align));return g||s==="funnel"?{...e,plugins:{...e.plugins,datalabels:b}}:{...e,plugins:{...e.plugins,datalabels:{...(A=e.plugins)==null?void 0:A.datalabels,...b}}}}function Nae(e){return!["kpi","metric","text","table","pivotTable","custom"].includes(e)}function Aae(e){return e.length===1?[e[0]]:e.slice(1).filter(n=>!EO.includes(n))}function Hc({data:e,cfg:t,customCfg:n,preferences:r,cardType:o,card:i}){var S;const s=o==="radar"?.2:1,{keys:a}=gn(e),l=Aae(a);let c="none";o=="bar"?c="bar":o=="line"&&(c="line");const u=a==null?void 0:a[0],d=xp(e,u),p=Y4(l,e,r,s,c,u,o==="stackedBar"||o==="stackedLine"),m=Pl(p,n),{options:g,plugins:b}=Vf({cardType:o,cfg:t,preferences:r,customCfg:n}),y=(S=i.interactionConfig)==null?void 0:S.clickFilterInteractions,v=function(_,E){var R;const C=((R=_.native)==null?void 0:R.target)||_.target;E.length?C.style.cursor="pointer":C.style.cursor="default"};return{type:(n==null?void 0:n.type)||(t==null?void 0:t.type)||"bar",data:{labels:d,datasets:m},options:{...g,onHover:y?v:void 0},plugins:b}}function Mae(e,t){var o,i,s;const n=((o=t==null?void 0:t.options)==null?void 0:o.indexAxis)==="y"?"x":"y";return(i=e==null?void 0:e.chartOptions)!=null&&i.indexAxis?((s=e==null?void 0:e.chartOptions)==null?void 0:s.indexAxis)==="x"?"y":"x":n}function Pae(e){var n,r;return(n=e==null?void 0:e.chartOptions)!=null&&n.indexAxis?((r=e==null?void 0:e.chartOptions)==null?void 0:r.indexAxis)==="x"?"x":"y":"x"}function m$(e,t){var s,a,l,c,u,d,h,p,m,g,b,y;const n=Mae(t,e),r=Pae(t);return(t==null?void 0:t.xAxisConfig)||(t==null?void 0:t.yAxisConfig)?(e==null?void 0:e.options)||{}:{...e==null?void 0:e.options,scales:{...(s=e==null?void 0:e.options)==null?void 0:s.scales,[n]:{...(l=(a=e==null?void 0:e.options)==null?void 0:a.scales)==null?void 0:l[n],ticks:{...(d=(u=(c=e==null?void 0:e.options)==null?void 0:c.scales)==null?void 0:u[n])==null?void 0:d.ticks,callback:v=>{var x,S,_,E;return KC({number:Number(v),decimalPlaces:((x=t==null?void 0:t.numberAxisFormat)==null?void 0:x.decimalPlaces)||0,useSuffix:!!((S=t==null?void 0:t.numberAxisFormat)!=null&&S.suffix),customSuffix:"",locale:((_=t==null?void 0:t.numberAxisFormat)==null?void 0:_.locale)||"",currency:((E=t==null?void 0:t.numberAxisFormat)==null?void 0:E.currency)||""})}}},[r]:{...(m=(p=(h=e==null?void 0:e.options)==null?void 0:h.scales)==null?void 0:p[r])==null?void 0:m.ticks,callback:null}},plugins:{...(g=e==null?void 0:e.options)==null?void 0:g.plugins,datalabels:{...(y=(b=e==null?void 0:e.options)==null?void 0:b.plugins)==null?void 0:y.datalabels,formatter:function(v){var x,S,_,E;return KC({number:Number(v),decimalPlaces:((x=t==null?void 0:t.numberAxisFormat)==null?void 0:x.decimalPlaces)||0,useSuffix:!!((S=t==null?void 0:t.numberAxisFormat)!=null&&S.suffix),customSuffix:"",locale:((_=t==null?void 0:t.numberAxisFormat)==null?void 0:_.locale)||"",currency:((E=t==null?void 0:t.numberAxisFormat)==null?void 0:E.currency)||""})}}}}}function Vf({cardType:e,cfg:t,preferences:n,customCfg:r}){var m,g,b,y,v,x,S,_,E,C,R,M,N,D,A,j,O,I,L,F,B,z,T,H,V,P,W,$,q,U,G;const o=oe.getState().themeStyle,i=m$(t,n),s=Hn((t==null?void 0:t.options)||{},n==null?void 0:n.chartOptions),a=Hn(i,s),l=Hn(a,(r==null?void 0:r.options)||{}),c=Dae(e,n,l),u={...l,scales:{...l==null?void 0:l.scales,x:{...(m=l==null?void 0:l.scales)==null?void 0:m.x,grid:{...(b=(g=l==null?void 0:l.scales)==null?void 0:g.x)==null?void 0:b.grid,color:(_=(S=(x=(v=(y=o==null?void 0:o.chart)==null?void 0:y.options)==null?void 0:v.scales)==null?void 0:x.x)==null?void 0:S.grid)==null?void 0:_.color}},y:{...(E=l==null?void 0:l.scales)==null?void 0:E.y,grid:{...(R=(C=l==null?void 0:l.scales)==null?void 0:C.y)==null?void 0:R.grid,color:(j=(A=(D=(N=(M=o==null?void 0:o.chart)==null?void 0:M.options)==null?void 0:N.scales)==null?void 0:D.y)==null?void 0:A.grid)==null?void 0:j.color}}},plugins:{...l==null?void 0:l.plugins,tooltip:{filter:function(Y){return Y.raw!==void 0&&Y.raw!==0},callbacks:c,...(O=l==null?void 0:l.plugins)==null?void 0:O.tooltip,backgroundColor:(B=(F=(L=(I=o==null?void 0:o.chart)==null?void 0:I.options)==null?void 0:L.plugins)==null?void 0:F.tooltip)==null?void 0:B.backgroundColor,bodyColor:(V=(H=(T=(z=o==null?void 0:o.chart)==null?void 0:z.options)==null?void 0:T.plugins)==null?void 0:H.tooltip)==null?void 0:V.bodyColor,titleColor:(q=($=(W=(P=o==null?void 0:o.chart)==null?void 0:P.options)==null?void 0:W.plugins)==null?void 0:$.tooltip)==null?void 0:q.titleColor}}},{plugins:d,options:h}=Gy((n==null?void 0:n.customVisualCode)||"");let p=$_.applyAxisConfig(u,e||"bar",n);return p=_ae(p,(G=(U=n==null?void 0:n.chartOptions)==null?void 0:U.plugins)==null?void 0:G.legend),p=z_(p,n==null?void 0:n.dataLabelsConfig,n,e),p=Hn(p,h),{options:p,plugins:d}}function Dae(e,t,n){var s,a,l;if(e==="map")return{};const o=((s=t==null?void 0:t.chartOptions)==null?void 0:s.indexAxis)==="y"?t==null?void 0:t.xAxisConfig:t==null?void 0:t.yAxisConfig,i=c=>{var u,d,h,p,m;return(u=o==null?void 0:o.formatOptions)!=null&&u.type&&o.formatOptions.type!=="auto"?Dl(c,o.formatOptions.type,o.formatOptions||{}):KC({number:c,decimalPlaces:((d=t==null?void 0:t.numberAxisFormat)==null?void 0:d.decimalPlaces)||0,useSuffix:!!((h=t==null?void 0:t.numberAxisFormat)!=null&&h.suffix),customSuffix:"",locale:((p=t==null?void 0:t.numberAxisFormat)==null?void 0:p.locale)||"",currency:((m=t==null?void 0:t.numberAxisFormat)==null?void 0:m.currency)||""})};return{title:function(c){var d;const u=((d=c==null?void 0:c[0])==null?void 0:d.label)||"";if(c.length>1&&["stackedBar","stackedLine"].includes(e||"")){const h=c.reduce((m,g)=>{const b=g.raw;return b!==void 0&&b!==0?m+b:m},0),p=i(h);return`${u} (${p})`}return u},label:function(c){var p;const u=((p=c==null?void 0:c.dataset)==null?void 0:p.label)||"",d=c==null?void 0:c.raw;if(d===void 0||d===0)return;const h=i(Number(d));return`${u}: ${h}`},...((l=(a=n==null?void 0:n.plugins)==null?void 0:a.tooltip)==null?void 0:l.callbacks)||{}}}/*!
495
+ `},kne={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 Rne(e){let{announcements:t=kne,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=_ne}=e;const{announce:i,announcement:s}=Cne(),a=Np("DndLiveRegion"),[l,c]=k.useState(!1);if(k.useEffect(()=>{c(!0)},[]),Sne(k.useMemo(()=>({onDragStart(d){let{active:h}=d;i(t.onDragStart({active:h}))},onDragMove(d){let{active:h,over:p}=d;t.onDragMove&&i(t.onDragMove({active:h,over:p}))},onDragOver(d){let{active:h,over:p}=d;i(t.onDragOver({active:h,over:p}))},onDragEnd(d){let{active:h,over:p}=d;i(t.onDragEnd({active:h,over:p}))},onDragCancel(d){let{active:h,over:p}=d;i(t.onDragCancel({active:h,over:p}))}}),[i,t])),!l)return null;const u=k.createElement(k.Fragment,null,k.createElement(xne,{id:r,value:o.draggable}),k.createElement(wne,{id:a,announcement:s}));return n?un.createPortal(u,n):u}var In;(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"})(In||(In={}));function jb(){}function xh(e,t){return k.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function o_(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return k.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const Qo=Object.freeze({x:0,y:0});function TF(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Nne(e,t){const n=Tb(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 jF(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Ane(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function pM(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 OF(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function mM(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 i_=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=mM(t,t.left,t.top),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=TF(mM(l),o);i.push({id:a,data:{droppableContainer:s,value:c}})}}return i.sort(jF)},Mne=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=pM(t),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=pM(l),u=o.reduce((h,p,m)=>h+TF(c[m],p),0),d=Number((u/4).toFixed(4));i.push({id:a,data:{droppableContainer:s,value:d}})}}return i.sort(jF)};function Pne(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),i=Math.min(t.top+t.height,e.top+e.height),s=o-r,a=i-n;if(r<o&&n<i){const l=t.width*t.height,c=e.width*e.height,u=s*a,d=u/(l+c-u);return Number(d.toFixed(4))}return 0}const Dne=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const i of r){const{id:s}=i,a=n.get(s);if(a){const l=Pne(a,t);l>0&&o.push({id:s,data:{droppableContainer:i,value:l}})}}return o.sort(Ane)};function Ine(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function FF(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Qo}function Tne(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((s,a)=>({...s,top:s.top+e*a.y,bottom:s.bottom+e*a.y,left:s.left+e*a.x,right:s.right+e*a.x}),{...n})}}const jne=Tne(1);function LF(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 One(e,t,n){const r=LF(t);if(!r)return e;const{scaleX:o,scaleY:i,x:s,y:a}=r,l=e.left-s-(1-o)*parseFloat(n),c=e.top-a-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=o?e.width/o:e.width,d=i?e.height/i:e.height;return{width:u,height:d,top:c,right:l+u,bottom:c+d,left:l}}const Fne={ignoreTransform:!1};function kd(e,t){t===void 0&&(t=Fne);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:u}=Sr(e).getComputedStyle(e);c&&(n=One(n,c,u))}const{top:r,left:o,width:i,height:s,bottom:a,right:l}=n;return{top:r,left:o,width:i,height:s,bottom:a,right:l}}function gM(e){return kd(e,{ignoreTransform:!0})}function Lne(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function $ne(e,t){return t===void 0&&(t=Sr(e).getComputedStyle(e)),t.position==="fixed"}function zne(e,t){t===void 0&&(t=Sr(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=t[o];return typeof i=="string"?n.test(i):!1})}function Sy(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(r_(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!kp(o)||PF(o)||n.includes(o))return n;const i=Sr(e).getComputedStyle(o);return o!==e&&zne(o,i)&&n.push(o),$ne(o,i)?n:r(o.parentNode)}return e?r(e):n}function $F(e){const[t]=Sy(e,1);return t??null}function Fx(e){return!xy||!e?null:Ed(e)?e:n_(e)?r_(e)||e===_d(e).scrollingElement?window:kp(e)?e:null:null}function zF(e){return Ed(e)?e.scrollX:e.scrollLeft}function BF(e){return Ed(e)?e.scrollY:e.scrollTop}function PC(e){return{x:zF(e),y:BF(e)}}var On;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(On||(On={}));function VF(e){return!xy||!e?!1:e===document.scrollingElement}function HF(e){const t={x:0,y:0},n=VF(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,i=e.scrollLeft<=t.x,s=e.scrollTop>=r.y,a=e.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:s,isRight:a,maxScroll:r,minScroll:t}}const Bne={x:.2,y:.2};function Vne(e,t,n,r,o){let{top:i,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=Bne);const{isTop:c,isBottom:u,isLeft:d,isRight:h}=HF(e),p={x:0,y:0},m={x:0,y:0},g={height:t.height*o.y,width:t.width*o.x};return!c&&i<=t.top+g.height?(p.y=On.Backward,m.y=r*Math.abs((t.top+g.height-i)/g.height)):!u&&l>=t.bottom-g.height&&(p.y=On.Forward,m.y=r*Math.abs((t.bottom-g.height-l)/g.height)),!h&&a>=t.right-g.width?(p.x=On.Forward,m.x=r*Math.abs((t.right-g.width-a)/g.width)):!d&&s<=t.left+g.width&&(p.x=On.Backward,m.x=r*Math.abs((t.left+g.width-s)/g.width)),{direction:p,speed:m}}function Hne(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:s}=window;return{top:0,left:0,right:i,bottom:s,width:i,height:s}}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 WF(e){return e.reduce((t,n)=>xu(t,PC(n)),Qo)}function Wne(e){return e.reduce((t,n)=>t+zF(n),0)}function Une(e){return e.reduce((t,n)=>t+BF(n),0)}function UF(e,t){if(t===void 0&&(t=kd),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);$F(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Gne=[["x",["left","right"],Wne],["y",["top","bottom"],Une]];class s_{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=Sy(n),o=WF(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,s,a]of Gne)for(const l of s)Object.defineProperty(this,l,{get:()=>{const c=a(r),u=o[i]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class $f{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 qne(e){const{EventTarget:t}=Sr(e);return e instanceof t?e:_d(e)}function Lx(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 xo;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(xo||(xo={}));function bM(e){e.preventDefault()}function Yne(e){e.stopPropagation()}var gt;(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"})(gt||(gt={}));const GF={start:[gt.Space,gt.Enter],cancel:[gt.Esc],end:[gt.Space,gt.Enter,gt.Tab]},Kne=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case gt.Right:return{...n,x:n.x+25};case gt.Left:return{...n,x:n.x-25};case gt.Down:return{...n,y:n.y+25};case gt.Up:return{...n,y:n.y-25}}};class Ap{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 $f(_d(n)),this.windowListeners=new $f(Sr(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(xo.Resize,this.handleCancel),this.windowListeners.add(xo.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(xo.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&UF(r),n(Qo)}handleKeyDown(t){if(Cy(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=GF,coordinateGetter:s=Kne,scrollBehavior:a="smooth"}=o,{code:l}=t;if(i.end.includes(l)){this.handleEnd(t);return}if(i.cancel.includes(l)){this.handleCancel(t);return}const{collisionRect:c}=r.current,u=c?{x:c.left,y:c.top}:Qo;this.referenceCoordinates||(this.referenceCoordinates=u);const d=s(t,{active:n,context:r.current,currentCoordinates:u});if(d){const h=vh(d,u),p={x:0,y:0},{scrollableAncestors:m}=r.current;for(const g of m){const b=t.code,{isTop:y,isRight:v,isLeft:x,isBottom:S,maxScroll:_,minScroll:E}=HF(g),C=Hne(g),R={x:Math.min(b===gt.Right?C.right-C.width/2:C.right,Math.max(b===gt.Right?C.left:C.left+C.width/2,d.x)),y:Math.min(b===gt.Down?C.bottom-C.height/2:C.bottom,Math.max(b===gt.Down?C.top:C.top+C.height/2,d.y))},M=b===gt.Right&&!v||b===gt.Left&&!x,N=b===gt.Down&&!S||b===gt.Up&&!y;if(M&&R.x!==d.x){const D=g.scrollLeft+h.x,A=b===gt.Right&&D<=_.x||b===gt.Left&&D>=E.x;if(A&&!h.y){g.scrollTo({left:D,behavior:a});return}A?p.x=g.scrollLeft-D:p.x=b===gt.Right?g.scrollLeft-_.x:g.scrollLeft-E.x,p.x&&g.scrollBy({left:-p.x,behavior:a});break}else if(N&&R.y!==d.y){const D=g.scrollTop+h.y,A=b===gt.Down&&D<=_.y||b===gt.Up&&D>=E.y;if(A&&!h.x){g.scrollTo({top:D,behavior:a});return}A?p.y=g.scrollTop-D:p.y=b===gt.Down?g.scrollTop-_.y:g.scrollTop-E.y,p.y&&g.scrollBy({top:-p.y,behavior:a});break}}this.handleMove(t,xu(vh(d,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()}}Ap.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=GF,onActivation:o}=t,{active:i}=n;const{code:s}=e.nativeEvent;if(r.start.includes(s)){const a=i.activatorNode.current;return a&&e.target!==a?!1:(e.preventDefault(),o==null||o({event:e.nativeEvent}),!0)}return!1}}];function yM(e){return!!(e&&"distance"in e)}function vM(e){return!!(e&&"delay"in e)}class a_{constructor(t,n,r){var o;r===void 0&&(r=qne(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:i}=t,{target:s}=i;this.props=t,this.events=n,this.document=_d(s),this.documentListeners=new $f(this.document),this.listeners=new $f(r),this.windowListeners=new $f(Sr(s)),this.initialCoordinates=(o=Tb(i))!=null?o:Qo,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(xo.Resize,this.handleCancel),this.windowListeners.add(xo.DragStart,bM),this.windowListeners.add(xo.VisibilityChange,this.handleCancel),this.windowListeners.add(xo.ContextMenu,bM),this.documentListeners.add(xo.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(vM(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(yM(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(xo.Click,Yne,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(xo.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:s,options:{activationConstraint:a}}=i;if(!o)return;const l=(n=Tb(t))!=null?n:Qo,c=vh(o,l);if(!r&&a){if(yM(a)){if(a.tolerance!=null&&Lx(c,a.tolerance))return this.handleCancel();if(Lx(c,a.distance))return this.handleStart()}if(vM(a)&&Lx(c,a.tolerance))return this.handleCancel();this.handlePending(a,c);return}t.cancelable&&t.preventDefault(),s(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===gt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Xne={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Mp extends a_{constructor(t){const{event:n}=t,r=_d(n.target);super(t,Xne,r)}}Mp.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 Qne={move:{name:"mousemove"},end:{name:"mouseup"}};var DC;(function(e){e[e.RightClick=2]="RightClick"})(DC||(DC={}));class qF extends a_{constructor(t){super(t,Qne,_d(t.event.target))}}qF.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===DC.RightClick?!1:(r==null||r({event:n}),!0)}}];const $x={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Jne extends a_{constructor(t){super(t,$x)}static setup(){return window.addEventListener($x.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener($x.move.name,t)};function t(){}}}Jne.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 zf;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(zf||(zf={}));var Ob;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Ob||(Ob={}));function Zne(e){let{acceleration:t,activator:n=zf.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:s=5,order:a=Ob.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:d,threshold:h}=e;const p=tre({delta:d,disabled:!i}),[m,g]=mne(),b=k.useRef({x:0,y:0}),y=k.useRef({x:0,y:0}),v=k.useMemo(()=>{switch(n){case zf.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case zf.DraggableRect:return o}},[n,o,l]),x=k.useRef(null),S=k.useCallback(()=>{const E=x.current;if(!E)return;const C=b.current.x*y.current.x,R=b.current.y*y.current.y;E.scrollBy(C,R)},[]),_=k.useMemo(()=>a===Ob.TreeOrder?[...c].reverse():c,[a,c]);k.useEffect(()=>{if(!i||!c.length||!v){g();return}for(const E of _){if((r==null?void 0:r(E))===!1)continue;const C=c.indexOf(E),R=u[C];if(!R)continue;const{direction:M,speed:N}=Vne(E,R,v,t,h);for(const D of["x","y"])p[D][M[D]]||(N[D]=0,M[D]=0);if(N.x>0||N.y>0){g(),x.current=E,m(S,s),b.current=N,y.current=M;return}}b.current={x:0,y:0},y.current={x:0,y:0},g()},[t,S,r,g,i,s,JSON.stringify(v),JSON.stringify(p),m,c,_,u,JSON.stringify(h)])}const ere={x:{[On.Backward]:!1,[On.Forward]:!1},y:{[On.Backward]:!1,[On.Forward]:!1}};function tre(e){let{delta:t,disabled:n}=e;const r=Ib(t);return Rp(o=>{if(n||!r||!o)return ere;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[On.Backward]:o.x[On.Backward]||i.x===-1,[On.Forward]:o.x[On.Forward]||i.x===1},y:{[On.Backward]:o.y[On.Backward]||i.y===-1,[On.Forward]:o.y[On.Forward]||i.y===1}}},[n,t,r])}function nre(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Rp(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function rre(e,t){return k.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(s=>({eventName:s.eventName,handler:t(s.handler,r)}));return[...n,...i]},[]),[e,t])}var wh;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(wh||(wh={}));var IC;(function(e){e.Optimized="optimized"})(IC||(IC={}));const xM=new Map;function ore(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,s]=k.useState(null),{frequency:a,measure:l,strategy:c}=o,u=k.useRef(e),d=b(),h=yh(d),p=k.useCallback(function(y){y===void 0&&(y=[]),!h.current&&s(v=>v===null?y:v.concat(y.filter(x=>!v.includes(x))))},[h]),m=k.useRef(null),g=Rp(y=>{if(d&&!n)return xM;if(!y||y===xM||u.current!==e||i!=null){const v=new Map;for(let x of e){if(!x)continue;if(i&&i.length>0&&!i.includes(x.id)&&x.rect.current){v.set(x.id,x.rect.current);continue}const S=x.node.current,_=S?new s_(l(S),S):null;x.rect.current=_,_&&v.set(x.id,_)}return v}return y},[e,i,n,d,l]);return k.useEffect(()=>{u.current=e},[e]),k.useEffect(()=>{d||p()},[n,d]),k.useEffect(()=>{i&&i.length>0&&s(null)},[JSON.stringify(i)]),k.useEffect(()=>{d||typeof a!="number"||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},a))},[a,d,p,...r]),{droppableRects:g,measureDroppableContainers:p,measuringScheduled:i!=null};function b(){switch(c){case wh.Always:return!1;case wh.BeforeDragging:return n;default:return!n}}}function l_(e,t){return Rp(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function ire(e,t){return l_(e,t)}function sre(e){let{callback:t,disabled:n}=e;const r=wy(t),o=k.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return k.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function Ey(e){let{callback:t,disabled:n}=e;const r=wy(t),o=k.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return k.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function are(e){return new s_(kd(e),e)}function wM(e,t,n){t===void 0&&(t=are);const[r,o]=k.useState(null);function i(){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 s=sre({callback(l){if(e)for(const c of l){const{type:u,target:d}=c;if(u==="childList"&&d instanceof HTMLElement&&d.contains(e)){i();break}}}}),a=Ey({callback:i});return Xo(()=>{i(),e?(a==null||a.observe(e),s==null||s.observe(document.body,{childList:!0,subtree:!0})):(a==null||a.disconnect(),s==null||s.disconnect())},[e]),r}function lre(e){const t=l_(e);return FF(e,t)}const CM=[];function cre(e){const t=k.useRef(e),n=Rp(r=>e?r&&r!==CM&&e&&t.current&&e.parentNode===t.current.parentNode?r:Sy(e):CM,[e]);return k.useEffect(()=>{t.current=e},[e]),n}function ure(e){const[t,n]=k.useState(null),r=k.useRef(e),o=k.useCallback(i=>{const s=Fx(i.target);s&&n(a=>a?(a.set(s,PC(s)),new Map(a)):null)},[]);return k.useEffect(()=>{const i=r.current;if(e!==i){s(i);const a=e.map(l=>{const c=Fx(l);return c?(c.addEventListener("scroll",o,{passive:!0}),[c,PC(c)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=e}return()=>{s(e),s(i)};function s(a){a.forEach(l=>{const c=Fx(l);c==null||c.removeEventListener("scroll",o)})}},[o,e]),k.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,s)=>xu(i,s),Qo):WF(e):Qo,[e,t])}function SM(e,t){t===void 0&&(t=[]);const n=k.useRef(null);return k.useEffect(()=>{n.current=null},t),k.useEffect(()=>{const r=e!==Qo;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?vh(e,n.current):Qo}function dre(e){k.useEffect(()=>{if(!xy)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 fre(e,t){return k.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=s=>{i(s,t)},n},{}),[e,t])}function YF(e){return k.useMemo(()=>e?Lne(e):null,[e])}const EM=[];function hre(e,t){t===void 0&&(t=kd);const[n]=e,r=YF(n?Sr(n):null),[o,i]=k.useState(EM);function s(){i(()=>e.length?e.map(l=>VF(l)?r:new s_(t(l),l)):EM)}const a=Ey({callback:s});return Xo(()=>{a==null||a.disconnect(),s(),e.forEach(l=>a==null?void 0:a.observe(l))},[e]),o}function KF(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return kp(t)?t:e}function pre(e){let{measure:t}=e;const[n,r]=k.useState(null),o=k.useCallback(c=>{for(const{target:u}of c)if(kp(u)){r(d=>{const h=t(u);return d?{...d,width:h.width,height:h.height}:h});break}},[t]),i=Ey({callback:o}),s=k.useCallback(c=>{const u=KF(c);i==null||i.disconnect(),u&&(i==null||i.observe(u)),r(u?t(u):null)},[t,i]),[a,l]=Db(s);return k.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const mre=[{sensor:Mp,options:{}},{sensor:Ap,options:{}}],gre={current:{}},Xg={draggable:{measure:gM},droppable:{measure:gM,strategy:wh.WhileDragging,frequency:IC.Optimized},dragOverlay:{measure:kd}};class Bf 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 bre={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Bf,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:jb},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Xg,measureDroppableContainers:jb,windowRect:null,measuringScheduled:!1},XF={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:jb,draggableNodes:new Map,over:null,measureDroppableContainers:jb},Pp=k.createContext(XF),QF=k.createContext(bre);function yre(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Bf}}}function vre(e,t){switch(t.type){case In.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case In.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 In.DragEnd:case In.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case In.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Bf(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case In.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const s=new Bf(e.droppable.containers);return s.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:s}}}case In.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new Bf(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function xre(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=k.useContext(Pp),i=Ib(r),s=Ib(n==null?void 0:n.id);return k.useEffect(()=>{if(!t&&!r&&i&&s!=null){if(!Cy(i)||document.activeElement===i.target)return;const a=o.get(s);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 d=yne(u);if(d){d.focus();break}}})}},[r,t,o,s,i]),null}function JF(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function wre(e){return k.useMemo(()=>({draggable:{...Xg.draggable,...e==null?void 0:e.draggable},droppable:{...Xg.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Xg.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 Cre(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=k.useRef(!1),{x:s,y:a}=typeof o=="boolean"?{x:o,y:o}:o;Xo(()=>{if(!s&&!a||!t){i.current=!1;return}if(i.current||!r)return;const c=t==null?void 0:t.node.current;if(!c||c.isConnected===!1)return;const u=n(c),d=FF(u,r);if(s||(d.x=0),a||(d.y=0),i.current=!0,Math.abs(d.x)>0||Math.abs(d.y)>0){const h=$F(c);h&&h.scrollBy({top:d.y,left:d.x})}},[t,s,a,r,n])}const _y=k.createContext({...Qo,scaleX:1,scaleY:1});var Ys;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Ys||(Ys={}));const c_=k.memo(function(t){var n,r,o,i;let{id:s,accessibility:a,autoScroll:l=!0,children:c,sensors:u=mre,collisionDetection:d=Dne,measuring:h,modifiers:p,...m}=t;const g=k.useReducer(vre,void 0,yre),[b,y]=g,[v,x]=Ene(),[S,_]=k.useState(Ys.Uninitialized),E=S===Ys.Initialized,{draggable:{active:C,nodes:R,translate:M},droppable:{containers:N}}=b,D=C!=null?R.get(C):null,A=k.useRef({initial:null,translated:null}),j=k.useMemo(()=>{var en;return C!=null?{id:C,data:(en=D==null?void 0:D.data)!=null?en:gre,rect:A}:null},[C,D]),O=k.useRef(null),[I,L]=k.useState(null),[F,B]=k.useState(null),z=yh(m,Object.values(m)),T=Np("DndDescribedBy",s),H=k.useMemo(()=>N.getEnabled(),[N]),V=wre(h),{droppableRects:P,measureDroppableContainers:W,measuringScheduled:$}=ore(H,{dragging:E,dependencies:[M.x,M.y],config:V.droppable}),q=nre(R,C),U=k.useMemo(()=>F?Tb(F):null,[F]),G=ho(),Y=ire(q,V.draggable.measure);Cre({activeNode:C!=null?R.get(C):null,config:G.layoutShiftCompensation,initialRect:Y,measure:V.draggable.measure});const Q=wM(q,V.draggable.measure,Y),te=wM(q?q.parentElement:null),J=k.useRef({activatorEvent:null,active:null,activeNode:q,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:R,draggingNode:null,draggingNodeRect:null,droppableContainers:N,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ie=N.getNodeFor((n=J.current.over)==null?void 0:n.id),Z=pre({measure:V.dragOverlay.measure}),ue=(r=Z.nodeRef.current)!=null?r:q,fe=E?(o=Z.rect)!=null?o:Q:null,xe=!!(Z.nodeRef.current&&Z.rect),ge=lre(xe?null:Q),be=YF(ue?Sr(ue):null),Ne=cre(E?ie??q:null),Me=hre(Ne),rt=JF(p,{transform:{x:M.x-ge.x,y:M.y-ge.y,scaleX:1,scaleY:1},activatorEvent:F,active:j,activeNodeRect:Q,containerNodeRect:te,draggingNodeRect:fe,over:J.current.over,overlayNodeRect:Z.rect,scrollableAncestors:Ne,scrollableAncestorRects:Me,windowRect:be}),Te=U?xu(U,M):null,Et=ure(Ne),qe=SM(Et),ne=SM(Et,[Q]),le=xu(rt,qe),ae=fe?jne(fe,rt):null,de=j&&ae?d({active:j,collisionRect:ae,droppableRects:P,droppableContainers:H,pointerCoordinates:Te}):null,Se=OF(de,"id"),[je,$t]=k.useState(null),Qe=xe?rt:xu(rt,ne),he=Ine(Qe,(i=je==null?void 0:je.rect)!=null?i:null,Q),Ot=k.useRef(null),Ye=k.useCallback((en,wt)=>{let{sensor:En,options:Ie}=wt;if(O.current==null)return;const Be=R.get(O.current);if(!Be)return;const Ke=en.nativeEvent,Wt=new En({active:O.current,activeNode:Be,event:Ke,options:Ie,context:J,onAbort(Rt){if(!R.get(Rt))return;const{onDragAbort:Ut}=z.current,fn={id:Rt};Ut==null||Ut(fn),v({type:"onDragAbort",event:fn})},onPending(Rt,wn,Ut,fn){if(!R.get(Rt))return;const{onDragPending:po}=z.current,li={id:Rt,constraint:wn,initialCoordinates:Ut,offset:fn};po==null||po(li),v({type:"onDragPending",event:li})},onStart(Rt){const wn=O.current;if(wn==null)return;const Ut=R.get(wn);if(!Ut)return;const{onDragStart:fn}=z.current,Ga={activatorEvent:Ke,active:{id:wn,data:Ut.data,rect:A}};un.unstable_batchedUpdates(()=>{fn==null||fn(Ga),_(Ys.Initializing),y({type:In.DragStart,initialCoordinates:Rt,active:wn}),v({type:"onDragStart",event:Ga}),L(Ot.current),B(Ke)})},onMove(Rt){y({type:In.DragMove,coordinates:Rt})},onEnd:kt(In.DragEnd),onCancel:kt(In.DragCancel)});Ot.current=Wt;function kt(Rt){return async function(){const{active:Ut,collisions:fn,over:Ga,scrollAdjustedTranslate:po}=J.current;let li=null;if(Ut&&po){const{cancelDrop:qa}=z.current;li={activatorEvent:Ke,active:Ut,collisions:fn,delta:po,over:Ga},Rt===In.DragEnd&&typeof qa=="function"&&await Promise.resolve(qa(li))&&(Rt=In.DragCancel)}O.current=null,un.unstable_batchedUpdates(()=>{y({type:Rt}),_(Ys.Uninitialized),$t(null),L(null),B(null),Ot.current=null;const qa=Rt===In.DragEnd?"onDragEnd":"onDragCancel";if(li){const Yd=z.current[qa];Yd==null||Yd(li),v({type:qa,event:li})}})}}},[R]),_t=k.useCallback((en,wt)=>(En,Ie)=>{const Be=En.nativeEvent,Ke=R.get(Ie);if(O.current!==null||!Ke||Be.dndKit||Be.defaultPrevented)return;const Wt={active:Ke};en(En,wt.options,Wt)===!0&&(Be.dndKit={capturedBy:wt.sensor},O.current=Ie,Ye(En,wt))},[R,Ye]),Ft=rre(u,_t);dre(u),Xo(()=>{Q&&S===Ys.Initializing&&_(Ys.Initialized)},[Q,S]),k.useEffect(()=>{const{onDragMove:en}=z.current,{active:wt,activatorEvent:En,collisions:Ie,over:Be}=J.current;if(!wt||!En)return;const Ke={active:wt,activatorEvent:En,collisions:Ie,delta:{x:le.x,y:le.y},over:Be};un.unstable_batchedUpdates(()=>{en==null||en(Ke),v({type:"onDragMove",event:Ke})})},[le.x,le.y]),k.useEffect(()=>{const{active:en,activatorEvent:wt,collisions:En,droppableContainers:Ie,scrollAdjustedTranslate:Be}=J.current;if(!en||O.current==null||!wt||!Be)return;const{onDragOver:Ke}=z.current,Wt=Ie.get(Se),kt=Wt&&Wt.rect.current?{id:Wt.id,rect:Wt.rect.current,data:Wt.data,disabled:Wt.disabled}:null,Rt={active:en,activatorEvent:wt,collisions:En,delta:{x:Be.x,y:Be.y},over:kt};un.unstable_batchedUpdates(()=>{$t(kt),Ke==null||Ke(Rt),v({type:"onDragOver",event:Rt})})},[Se]),Xo(()=>{J.current={activatorEvent:F,active:j,activeNode:q,collisionRect:ae,collisions:de,droppableRects:P,draggableNodes:R,draggingNode:ue,draggingNodeRect:fe,droppableContainers:N,over:je,scrollableAncestors:Ne,scrollAdjustedTranslate:le},A.current={initial:fe,translated:ae}},[j,q,de,ae,R,ue,fe,P,N,je,Ne,le]),Zne({...G,delta:M,draggingRect:ae,pointerCoordinates:Te,scrollableAncestors:Ne,scrollableAncestorRects:Me});const jn=k.useMemo(()=>({active:j,activeNode:q,activeNodeRect:Q,activatorEvent:F,collisions:de,containerNodeRect:te,dragOverlay:Z,draggableNodes:R,droppableContainers:N,droppableRects:P,over:je,measureDroppableContainers:W,scrollableAncestors:Ne,scrollableAncestorRects:Me,measuringConfiguration:V,measuringScheduled:$,windowRect:be}),[j,q,Q,F,de,te,Z,R,N,P,je,W,Ne,Me,V,$,be]),ai=k.useMemo(()=>({activatorEvent:F,activators:Ft,active:j,activeNodeRect:Q,ariaDescribedById:{draggable:T},dispatch:y,draggableNodes:R,over:je,measureDroppableContainers:W}),[F,Ft,j,Q,y,T,R,je,W]);return k.createElement(IF.Provider,{value:x},k.createElement(Pp.Provider,{value:ai},k.createElement(QF.Provider,{value:jn},k.createElement(_y.Provider,{value:he},c)),k.createElement(xre,{disabled:(a==null?void 0:a.restoreFocus)===!1})),k.createElement(Rne,{...a,hiddenTextDescribedById:T}));function ho(){const en=(I==null?void 0:I.autoScrollEnabled)===!1,wt=typeof l=="object"?l.enabled===!1:l===!1,En=E&&!en&&!wt;return typeof l=="object"?{...l,enabled:En}:{enabled:En}}}),Sre=k.createContext(null),_M="button",Ere="Draggable";function ZF(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=Np(Ere),{activators:s,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:d,over:h}=k.useContext(Pp),{role:p=_M,roleDescription:m="draggable",tabIndex:g=0}=o??{},b=(l==null?void 0:l.id)===t,y=k.useContext(b?_y:Sre),[v,x]=Db(),[S,_]=Db(),E=fre(s,t),C=yh(n);Xo(()=>(d.set(t,{id:t,key:i,node:v,activatorNode:S,data:C}),()=>{const M=d.get(t);M&&M.key===i&&d.delete(t)}),[d,t]);const R=k.useMemo(()=>({role:p,tabIndex:g,"aria-disabled":r,"aria-pressed":b&&p===_M?!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:R,isDragging:b,listeners:r?void 0:E,node:v,over:h,setNodeRef:x,setActivatorNodeRef:_,transform:y}}function e3(){return k.useContext(QF)}const _re="Droppable",kre={timeout:25};function t3(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=Np(_re),{active:s,dispatch:a,over:l,measureDroppableContainers:c}=k.useContext(Pp),u=k.useRef({disabled:n}),d=k.useRef(!1),h=k.useRef(null),p=k.useRef(null),{disabled:m,updateMeasurementsFor:g,timeout:b}={...kre,...o},y=yh(g??r),v=k.useCallback(()=>{if(!d.current){d.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]),x=Ey({callback:v,disabled:m||!s}),S=k.useCallback((R,M)=>{x&&(M&&(x.unobserve(M),d.current=!1),R&&x.observe(R))},[x]),[_,E]=Db(S),C=yh(t);return k.useEffect(()=>{!x||!_.current||(x.disconnect(),d.current=!1,x.observe(_.current))},[_,x]),k.useEffect(()=>(a({type:In.RegisterDroppable,element:{id:r,key:i,disabled:n,node:_,rect:h,data:C}}),()=>a({type:In.UnregisterDroppable,key:i,id:r})),[r]),k.useEffect(()=>{n!==u.current.disabled&&(a({type:In.SetDroppableDisabled,id:r,key:i,disabled:n}),u.current.disabled=n)},[r,i,n,a]),{active:s,rect:h,isOver:(l==null?void 0:l.id)===r,node:_,over:l,setNodeRef:E}}function Rre(e){let{animation:t,children:n}=e;const[r,o]=k.useState(null),[i,s]=k.useState(null),a=Ib(n);return!n&&!r&&a&&o(a),Xo(()=>{if(!i)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,i)).then(()=>{o(null)})},[t,r,i]),k.createElement(k.Fragment,null,n,r?k.cloneElement(r,{ref:s}):null)}const Nre={x:0,y:0,scaleX:1,scaleY:1};function Are(e){let{children:t}=e;return k.createElement(Pp.Provider,{value:XF},k.createElement(_y.Provider,{value:Nre},t))}const Mre={position:"fixed",touchAction:"none"},Pre=e=>Cy(e)?"transform 250ms ease":void 0,Dre=k.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:i,className:s,rect:a,style:l,transform:c,transition:u=Pre}=e;if(!a)return null;const d=o?c:{...c,scaleX:1,scaleY:1},h={...Mre,width:a.width,height:a.height,top:a.top,left:a.left,transform:Di.Transform.toString(d),transformOrigin:o&&r?Nne(r,a):void 0,transition:typeof u=="function"?u(r):u,...l};return k.createElement(n,{className:s,style:h,ref:t},i)}),Ire=e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:i,className:s}=e;if(i!=null&&i.active)for(const[a,l]of Object.entries(i.active))l!==void 0&&(o[a]=n.node.style.getPropertyValue(a),n.node.style.setProperty(a,l));if(i!=null&&i.dragOverlay)for(const[a,l]of Object.entries(i.dragOverlay))l!==void 0&&r.node.style.setProperty(a,l);return s!=null&&s.active&&n.node.classList.add(s.active),s!=null&&s.dragOverlay&&r.node.classList.add(s.dragOverlay),function(){for(const[l,c]of Object.entries(o))n.node.style.setProperty(l,c);s!=null&&s.active&&n.node.classList.remove(s.active)}},Tre=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Di.Transform.toString(t)},{transform:Di.Transform.toString(n)}]},jre={duration:250,easing:"ease",keyframes:Tre,sideEffects:Ire({styles:{active:{opacity:"0"}}})};function Ore(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return wy((i,s)=>{if(t===null)return;const a=n.get(i);if(!a)return;const l=a.node.current;if(!l)return;const c=KF(s);if(!c)return;const{transform:u}=Sr(s).getComputedStyle(s),d=LF(u);if(!d)return;const h=typeof t=="function"?t:Fre(t);return UF(l,o.draggable.measure),h({active:{id:i,data:a.data,node:l,rect:o.draggable.measure(l)},draggableNodes:n,dragOverlay:{node:s,rect:o.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:o,transform:d})})}function Fre(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...jre,...e};return i=>{let{active:s,dragOverlay:a,transform:l,...c}=i;if(!t)return;const u={x:a.rect.left-s.rect.left,y:a.rect.top-s.rect.top},d={scaleX:l.scaleX!==1?s.rect.width*l.scaleX/a.rect.width:1,scaleY:l.scaleY!==1?s.rect.height*l.scaleY/a.rect.height:1},h={x:l.x-u.x,y:l.y-u.y,...d},p=o({...c,active:s,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:s,dragOverlay:a,...c}),y=a.node.animate(p,{duration:t,easing:n,fill:"forwards"});return new Promise(v=>{y.onfinish=()=>{b==null||b(),v()}})}}let kM=0;function Lre(e){return k.useMemo(()=>{if(e!=null)return kM++,kM},[e])}const n3=k.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:o,transition:i,modifiers:s,wrapperElement:a="div",className:l,zIndex:c=999}=e;const{activatorEvent:u,active:d,activeNodeRect:h,containerNodeRect:p,draggableNodes:m,droppableContainers:g,dragOverlay:b,over:y,measuringConfiguration:v,scrollableAncestors:x,scrollableAncestorRects:S,windowRect:_}=e3(),E=k.useContext(_y),C=Lre(d==null?void 0:d.id),R=JF(s,{activatorEvent:u,active:d,activeNodeRect:h,containerNodeRect:p,draggingNodeRect:b.rect,over:y,overlayNodeRect:b.rect,scrollableAncestors:x,scrollableAncestorRects:S,transform:E,windowRect:_}),M=l_(h),N=Ore({config:r,draggableNodes:m,droppableContainers:g,measuringConfiguration:v}),D=M?b.setRef:void 0;return k.createElement(Are,null,k.createElement(Rre,{animation:N},d&&C?k.createElement(Dre,{key:C,id:d.id,ref:D,as:a,activatorEvent:u,adjustScale:t,className:l,transition:i,rect:M,style:{zIndex:c,...o},transform:R},n):null))});function Dp(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function $re(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function Bm(e){return e!==null&&e>=0}function zre(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 Bre(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Vm={scaleX:1,scaleY:1},Vre=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:o,overIndex:i,index:s}=e;const a=(t=n[o])!=null?t:r;if(!a)return null;const l=Hre(n,s,o);if(s===o){const c=n[i];return c?{x:o<i?c.left+c.width-(a.left+a.width):c.left-a.left,y:0,...Vm}:null}return s>o&&s<=i?{x:-a.width-l,y:0,...Vm}:s<o&&s>=i?{x:a.width+l,y:0,...Vm}:{x:0,y:0,...Vm}};function Hre(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return!r||!o&&!i?0:n<t?o?r.left-(o.left+o.width):i.left-(r.left+r.width):i?i.left-(r.left+r.width):r.left-(o.left+o.width)}const r3=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=Dp(t,r,n),s=t[o],a=i[o];return!a||!s?null:{x:a.left-s.left,y:a.top-s.top,scaleX:a.width/s.width,scaleY:a.height/s.height}},Hm={scaleX:1,scaleY:1},o3=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:i,overIndex:s}=e;const a=(t=i[n])!=null?t:r;if(!a)return null;if(o===n){const c=i[s];return c?{x:0,y:n<s?c.top+c.height-(a.top+a.height):c.top-a.top,...Hm}:null}const l=Wre(i,o,n);return o>n&&o<=s?{x:0,y:-a.height-l,...Hm}:o<n&&o>=s?{x:0,y:a.height+l,...Hm}:{x:0,y:0,...Hm}};function Wre(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return r?n<t?o?r.top-(o.top+o.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const i3="Sortable",s3=k.createContext({activeIndex:-1,containerId:i3,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:r3,disabled:{draggable:!1,droppable:!1}});function u_(e){let{children:t,id:n,items:r,strategy:o=r3,disabled:i=!1}=e;const{active:s,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:u}=e3(),d=Np(i3,n),h=a.rect!==null,p=k.useMemo(()=>r.map(E=>typeof E=="object"&&"id"in E?E.id:E),[r]),m=s!=null,g=s?p.indexOf(s.id):-1,b=c?p.indexOf(c.id):-1,y=k.useRef(p),v=!zre(p,y.current),x=b!==-1&&g===-1||v,S=Bre(i);Xo(()=>{v&&m&&u(p)},[v,p,m,u]),k.useEffect(()=>{y.current=p},[p]);const _=k.useMemo(()=>({activeIndex:g,containerId:d,disabled:S,disableTransforms:x,items:p,overIndex:b,useDragOverlay:h,sortedRects:$re(p,l),strategy:o}),[g,d,S.draggable,S.droppable,x,p,b,l,h,o]);return k.createElement(s3.Provider,{value:_},t)}const Ure=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return Dp(n,r,o).indexOf(t)},Gre=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:s,previousItems:a,previousContainerId:l,transition:c}=e;return!c||!r||a!==i&&o===s?!1:n?!0:s!==o&&t===l},qre={duration:200,easing:"ease"},a3="transform",Yre=Di.Transition.toString({property:a3,duration:0,easing:"linear"}),Kre={roleDescription:"sortable"};function Xre(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,s]=k.useState(null),a=k.useRef(n);return Xo(()=>{if(!t&&n!==a.current&&r.current){const l=o.current;if(l){const c=kd(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)&&s(u)}}n!==a.current&&(a.current=n)},[t,n,r,o]),k.useEffect(()=>{i&&s(null)},[i]),i}function d_(e){let{animateLayoutChanges:t=Gre,attributes:n,disabled:r,data:o,getNewIndex:i=Ure,id:s,strategy:a,resizeObserverConfig:l,transition:c=qre}=e;const{items:u,containerId:d,activeIndex:h,disabled:p,disableTransforms:m,sortedRects:g,overIndex:b,useDragOverlay:y,strategy:v}=k.useContext(s3),x=Qre(r,p),S=u.indexOf(s),_=k.useMemo(()=>({sortable:{containerId:d,index:S,items:u},...o}),[d,o,S,u]),E=k.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:C,node:R,isOver:M,setNodeRef:N}=t3({id:s,data:_,disabled:x.droppable,resizeObserverConfig:{updateMeasurementsFor:E,...l}}),{active:D,activatorEvent:A,activeNodeRect:j,attributes:O,setNodeRef:I,listeners:L,isDragging:F,over:B,setActivatorNodeRef:z,transform:T}=ZF({id:s,data:_,attributes:{...Kre,...n},disabled:x.draggable}),H=pne(N,I),V=!!D,P=V&&!m&&Bm(h)&&Bm(b),W=!y&&F,$=W&&P?T:null,U=P?$??(a??v)({rects:g,activeNodeRect:j,activeIndex:h,overIndex:b,index:S}):null,G=Bm(h)&&Bm(b)?i({id:s,items:u,activeIndex:h,overIndex:b}):S,Y=D==null?void 0:D.id,Q=k.useRef({activeId:Y,items:u,newIndex:G,containerId:d}),te=u!==Q.current.items,J=t({active:D,containerId:d,isDragging:F,isSorting:V,id:s,index:S,items:u,newIndex:Q.current.newIndex,previousItems:Q.current.items,previousContainerId:Q.current.containerId,transition:c,wasDragging:Q.current.activeId!=null}),ie=Xre({disabled:!J,index:S,node:R,rect:C});return k.useEffect(()=>{V&&Q.current.newIndex!==G&&(Q.current.newIndex=G),d!==Q.current.containerId&&(Q.current.containerId=d),u!==Q.current.items&&(Q.current.items=u)},[V,G,d,u]),k.useEffect(()=>{if(Y===Q.current.activeId)return;if(Y!=null&&Q.current.activeId==null){Q.current.activeId=Y;return}const ue=setTimeout(()=>{Q.current.activeId=Y},50);return()=>clearTimeout(ue)},[Y]),{active:D,activeIndex:h,attributes:O,data:_,rect:C,index:S,newIndex:G,items:u,isOver:M,isSorting:V,isDragging:F,listeners:L,node:R,overIndex:b,over:B,setNodeRef:H,setActivatorNodeRef:z,setDroppableNodeRef:N,setDraggableNodeRef:I,transform:ie??U,transition:Z()};function Z(){if(ie||te&&Q.current.newIndex===S)return Yre;if(!(W&&!Cy(A)||!c)&&(V||J))return Di.Transition.toString({...c,property:a3})}}function Qre(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 Fb(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 Jre=[gt.Down,gt.Right,gt.Up,gt.Left],f_=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:s,scrollableAncestors:a}}=t;if(Jre.includes(e.code)){if(e.preventDefault(),!n||!r)return;const l=[];i.getEnabled().forEach(d=>{if(!d||d!=null&&d.disabled)return;const h=o.get(d.id);if(h)switch(e.code){case gt.Down:r.top<h.top&&l.push(d);break;case gt.Up:r.top>h.top&&l.push(d);break;case gt.Left:r.left>h.left&&l.push(d);break;case gt.Right:r.left<h.left&&l.push(d);break}});const c=Mne({collisionRect:r,droppableRects:o,droppableContainers:l});let u=OF(c,"id");if(u===(s==null?void 0:s.id)&&c.length>1&&(u=c[1].id),u!=null){const d=i.get(n.id),h=i.get(u),p=h?o.get(h.id):null,m=h==null?void 0:h.node.current;if(m&&p&&d&&h){const b=Sy(m).some((E,C)=>a[C]!==E),y=l3(d,h),v=Zre(d,h),x=b||!y?{x:0,y:0}:{x:v?r.width-p.width:0,y:v?r.height-p.height:0},S={x:p.left,y:p.top};return x.x&&x.y?S:vh(S,x)}}}};function l3(e,t){return!Fb(e)||!Fb(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Zre(e,t){return!Fb(e)||!Fb(t)||!l3(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function eoe(e,t,n){const[r,o]=k.useState(null),[i,s]=k.useState(""),a=()=>{const m={id:`hierarchy_${Date.now()}`,label:i||"New Hierarchy",type:"static",steps:[],default:!1};t([...e,m]),s(""),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:i,setNewHierarchyName:s,createNewHierarchy:a,deleteHierarchy:l,updateHierarchy:c,addStepToHierarchy:(m,g)=>{const b=n.find(x=>x.id===g);if(!b)return;const y={field:b,mode:"drillDown",label:`Drill to ${b.label}`,retainFilters:!0,preferredChartType:"bar"},v=e.find(x=>x.id===m);v&&c(m,{steps:[...v.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(v=>v.id===m);if(y){const v=y.steps.map((x,S)=>S===g?{...x,...b}:x);c(m,{steps:v})}},setDefaultHierarchy:m=>{t(e.map(g=>({...g,default:g.id===m})))}}}function toe({value:e,isEditing:t,onEdit:n,onSave:r,onCancel:o,placeholder:i="Enter text...",inputClassName:s="",displayClassName:a=""}){const[l,c]=k.useState(e);k.useEffect(()=>{c(e)},[e]);const u=m=>{m.key===" "&&m.stopPropagation(),m.key==="Enter"?r(l):m.key==="Escape"&&(c(e),o())},d=()=>{r(l)},h=m=>{m.stopPropagation()},p=m=>{m.stopPropagation()};return t?f.jsx("input",{type:"text",value:l,onChange:m=>c(m.target.value),onKeyDown:u,onBlur:d,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 ${s}`,placeholder:i,autoFocus:!0}):f.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||i})}function noe(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e);w.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 roe="DismissableLayer",TC="dismissableLayer.update",ooe="dismissableLayer.pointerDownOutside",ioe="dismissableLayer.focusOutside",RM,c3=w.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_c=w.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:a,...l}=e,c=w.useContext(c3),[u,d]=w.useState(null),h=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=w.useState({}),m=We(t,C=>d(C)),g=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(b),v=u?g.indexOf(u):-1,x=c.layersWithOutsidePointerEventsDisabled.size>0,S=v>=y,_=loe(C=>{const R=C.target,M=[...c.branches].some(N=>N.contains(R));!S||M||(o==null||o(C),s==null||s(C),C.defaultPrevented||a==null||a())},h),E=coe(C=>{const R=C.target;[...c.branches].some(N=>N.contains(R))||(i==null||i(C),s==null||s(C),C.defaultPrevented||a==null||a())},h);return noe(C=>{v===c.layers.size-1&&(r==null||r(C),!C.defaultPrevented&&a&&(C.preventDefault(),a()))},h),w.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(RM=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),NM(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=RM)}},[u,h,n,c]),w.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),NM())},[u,c]),w.useEffect(()=>{const C=()=>p({});return document.addEventListener(TC,C),()=>document.removeEventListener(TC,C)},[]),f.jsx(Re.div,{...l,ref:m,style:{pointerEvents:x?S?"auto":"none":void 0,...e.style},onFocusCapture:pe(e.onFocusCapture,E.onFocusCapture),onBlurCapture:pe(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:pe(e.onPointerDownCapture,_.onPointerDownCapture)})});_c.displayName=roe;var soe="DismissableLayerBranch",aoe=w.forwardRef((e,t)=>{const n=w.useContext(c3),r=w.useRef(null),o=We(t,r);return w.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),f.jsx(Re.div,{...e,ref:o})});aoe.displayName=soe;function loe(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e),r=w.useRef(!1),o=w.useRef(()=>{});return w.useEffect(()=>{const i=a=>{if(a.target&&!r.current){let l=function(){u3(ooe,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},s=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function coe(e,t=globalThis==null?void 0:globalThis.document){const n=Mn(e),r=w.useRef(!1);return w.useEffect(()=>{const o=i=>{i.target&&!r.current&&u3(ioe,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function NM(){const e=new CustomEvent(TC);document.dispatchEvent(e)}function u3(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?c5(o,i):o.dispatchEvent(i)}var zx=0;function ky(){w.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??AM()),document.body.insertAdjacentElement("beforeend",e[1]??AM()),zx++,()=>{zx===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),zx--}},[])}function AM(){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 Bx="focusScope.autoFocusOnMount",Vx="focusScope.autoFocusOnUnmount",MM={bubbles:!1,cancelable:!0},uoe="FocusScope",Ip=w.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=e,[a,l]=w.useState(null),c=Mn(o),u=Mn(i),d=w.useRef(null),h=We(t,g=>l(g)),p=w.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;w.useEffect(()=>{if(r){let g=function(x){if(p.paused||!a)return;const S=x.target;a.contains(S)?d.current=S:Gs(d.current,{select:!0})},b=function(x){if(p.paused||!a)return;const S=x.relatedTarget;S!==null&&(a.contains(S)||Gs(d.current,{select:!0}))},y=function(x){if(document.activeElement===document.body)for(const _ of x)_.removedNodes.length>0&&Gs(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",b);const v=new MutationObserver(y);return a&&v.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",b),v.disconnect()}}},[r,a,p.paused]),w.useEffect(()=>{if(a){DM.add(p);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Bx,MM);a.addEventListener(Bx,c),a.dispatchEvent(y),y.defaultPrevented||(doe(goe(d3(a)),{select:!0}),document.activeElement===g&&Gs(a))}return()=>{a.removeEventListener(Bx,c),setTimeout(()=>{const y=new CustomEvent(Vx,MM);a.addEventListener(Vx,u),a.dispatchEvent(y),y.defaultPrevented||Gs(g??document.body,{select:!0}),a.removeEventListener(Vx,u),DM.remove(p)},0)}}},[a,c,u,p]);const m=w.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 v=g.currentTarget,[x,S]=foe(v);x&&S?!g.shiftKey&&y===S?(g.preventDefault(),n&&Gs(x,{select:!0})):g.shiftKey&&y===x&&(g.preventDefault(),n&&Gs(S,{select:!0})):y===v&&g.preventDefault()}},[n,r,p.paused]);return f.jsx(Re.div,{tabIndex:-1,...s,ref:h,onKeyDown:m})});Ip.displayName=uoe;function doe(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Gs(r,{select:t}),document.activeElement!==n)return}function foe(e){const t=d3(e),n=PM(t,e),r=PM(t.reverse(),e);return[n,r]}function d3(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 PM(e,t){for(const n of e)if(!hoe(n,{upTo:t}))return n}function hoe(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 poe(e){return e instanceof HTMLInputElement&&"select"in e}function Gs(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&poe(e)&&t&&e.select()}}var DM=moe();function moe(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=IM(e,t),e.unshift(t)},remove(t){var n;e=IM(e,t),(n=e[0])==null||n.resume()}}}function IM(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function goe(e){return e.filter(t=>t.tagName!=="A")}const boe=["top","right","bottom","left"],ks=Math.min,tr=Math.max,Ch=Math.round,Wm=Math.floor,Ci=e=>({x:e,y:e}),yoe={left:"right",right:"left",bottom:"top",top:"bottom"},voe={start:"end",end:"start"};function jC(e,t,n){return tr(e,ks(t,n))}function Ii(e,t){return typeof e=="function"?e(t):e}function Rs(e){return e.split("-")[0]}function Rd(e){return e.split("-")[1]}function h_(e){return e==="x"?"y":"x"}function p_(e){return e==="y"?"height":"width"}function xa(e){return["top","bottom"].includes(Rs(e))?"y":"x"}function m_(e){return h_(xa(e))}function xoe(e,t,n){n===void 0&&(n=!1);const r=Rd(e),o=m_(e),i=p_(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=Lb(s)),[s,Lb(s)]}function woe(e){const t=Lb(e);return[OC(e),t,OC(t)]}function OC(e){return e.replace(/start|end/g,t=>voe[t])}function Coe(e,t,n){const r=["left","right"],o=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?i:s;default:return[]}}function Soe(e,t,n,r){const o=Rd(e);let i=Coe(Rs(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(OC)))),i}function Lb(e){return e.replace(/left|right|bottom|top/g,t=>yoe[t])}function Eoe(e){return{top:0,right:0,bottom:0,left:0,...e}}function f3(e){return typeof e!="number"?Eoe(e):{top:e,right:e,bottom:e,left:e}}function $b(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 TM(e,t,n){let{reference:r,floating:o}=e;const i=xa(t),s=m_(t),a=p_(s),l=Rs(t),c=i==="y",u=r.x+r.width/2-o.width/2,d=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:d};break;case"left":p={x:r.x-o.width,y:d};break;default:p={x:r.x,y:r.y}}switch(Rd(t)){case"start":p[s]-=h*(n&&c?-1:1);break;case"end":p[s]+=h*(n&&c?-1:1);break}return p}const _oe=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,a=i.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=TM(c,r,l),h=r,p={},m=0;for(let g=0;g<a.length;g++){const{name:b,fn:y}=a[g],{x:v,y:x,data:S,reset:_}=await y({x:u,y:d,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:s,elements:{reference:e,floating:t}});u=v??u,d=x??d,p={...p,[b]:{...p[b],...S}},_&&m<=50&&(m++,typeof _=="object"&&(_.placement&&(h=_.placement),_.rects&&(c=_.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):_.rects),{x:u,y:d}=TM(c,h,l)),g=-1)}return{x:u,y:d,placement:h,strategy:o,middlewareData:p}};async function ed(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:s,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:p=0}=Ii(t,e),m=f3(p),b=a[h?d==="floating"?"reference":"floating":d],y=$b(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(b)))==null||n?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),v=d==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,x=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),S=await(i.isElement==null?void 0:i.isElement(x))?await(i.getScale==null?void 0:i.getScale(x))||{x:1,y:1}:{x:1,y:1},_=$b(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:x,strategy:l}):v);return{top:(y.top-_.top+m.top)/S.y,bottom:(_.bottom-y.bottom+m.bottom)/S.y,left:(y.left-_.left+m.left)/S.x,right:(_.right-y.right+m.right)/S.x}}const koe=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:s,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=Ii(e,t)||{};if(c==null)return{};const d=f3(u),h={x:n,y:r},p=m_(o),m=p_(p),g=await s.getDimensions(c),b=p==="y",y=b?"top":"left",v=b?"bottom":"right",x=b?"clientHeight":"clientWidth",S=i.reference[m]+i.reference[p]-h[p]-i.floating[m],_=h[p]-i.reference[p],E=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c));let C=E?E[x]:0;(!C||!await(s.isElement==null?void 0:s.isElement(E)))&&(C=a.floating[x]||i.floating[m]);const R=S/2-_/2,M=C/2-g[m]/2-1,N=ks(d[y],M),D=ks(d[v],M),A=N,j=C-g[m]-D,O=C/2-g[m]/2+R,I=jC(A,O,j),L=!l.arrow&&Rd(o)!=null&&O!==I&&i.reference[m]/2-(O<A?N:D)-g[m]/2<0,F=L?O<A?O-A:O-j:0;return{[p]:h[p]+F,data:{[p]:I,centerOffset:O-I-F,...L&&{alignmentOffset:F}},reset:L}}}),Roe=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...b}=Ii(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=Rs(o),v=xa(a),x=Rs(a)===a,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),_=h||(x||!g?[Lb(a)]:woe(a)),E=m!=="none";!h&&E&&_.push(...Soe(a,g,m,S));const C=[a,..._],R=await ed(t,b),M=[];let N=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&M.push(R[y]),d){const O=xoe(o,s,S);M.push(R[O[0]],R[O[1]])}if(N=[...N,{placement:o,overflows:M}],!M.every(O=>O<=0)){var D,A;const O=(((D=i.flip)==null?void 0:D.index)||0)+1,I=C[O];if(I)return{data:{index:O,overflows:N},reset:{placement:I}};let L=(A=N.filter(F=>F.overflows[0]<=0).sort((F,B)=>F.overflows[1]-B.overflows[1])[0])==null?void 0:A.placement;if(!L)switch(p){case"bestFit":{var j;const F=(j=N.filter(B=>{if(E){const z=xa(B.placement);return z===v||z==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(z=>z>0).reduce((z,T)=>z+T,0)]).sort((B,z)=>B[1]-z[1])[0])==null?void 0:j[0];F&&(L=F);break}case"initialPlacement":L=a;break}if(o!==L)return{reset:{placement:L}}}return{}}}};function jM(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function OM(e){return boe.some(t=>e[t]>=0)}const Noe=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Ii(e,t);switch(r){case"referenceHidden":{const i=await ed(t,{...o,elementContext:"reference"}),s=jM(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:OM(s)}}}case"escaped":{const i=await ed(t,{...o,altBoundary:!0}),s=jM(i,n.floating);return{data:{escapedOffsets:s,escaped:OM(s)}}}default:return{}}}}};async function Aoe(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=Rs(n),a=Rd(n),l=xa(n)==="y",c=["left","top"].includes(s)?-1:1,u=i&&l?-1:1,d=Ii(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.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 Moe=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:a}=t,l=await Aoe(t,e);return s===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:i+l.y,data:{...l,placement:s}}}}},Poe=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:a={fn:b=>{let{x:y,y:v}=b;return{x:y,y:v}}},...l}=Ii(e,t),c={x:n,y:r},u=await ed(t,l),d=xa(Rs(o)),h=h_(d);let p=c[h],m=c[d];if(i){const b=h==="y"?"top":"left",y=h==="y"?"bottom":"right",v=p+u[b],x=p-u[y];p=jC(v,p,x)}if(s){const b=d==="y"?"top":"left",y=d==="y"?"bottom":"right",v=m+u[b],x=m-u[y];m=jC(v,m,x)}const g=a.fn({...t,[h]:p,[d]:m});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[h]:i,[d]:s}}}}}},Doe=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Ii(e,t),u={x:n,y:r},d=xa(o),h=h_(d);let p=u[h],m=u[d];const g=Ii(a,t),b=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const x=h==="y"?"height":"width",S=i.reference[h]-i.floating[x]+b.mainAxis,_=i.reference[h]+i.reference[x]-b.mainAxis;p<S?p=S:p>_&&(p=_)}if(c){var y,v;const x=h==="y"?"width":"height",S=["top","left"].includes(Rs(o)),_=i.reference[d]-i.floating[x]+(S&&((y=s.offset)==null?void 0:y[d])||0)+(S?0:b.crossAxis),E=i.reference[d]+i.reference[x]+(S?0:((v=s.offset)==null?void 0:v[d])||0)-(S?b.crossAxis:0);m<_?m=_:m>E&&(m=E)}return{[h]:p,[d]:m}}}},Ioe=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:s,elements:a}=t,{apply:l=()=>{},...c}=Ii(e,t),u=await ed(t,c),d=Rs(o),h=Rd(o),p=xa(o)==="y",{width:m,height:g}=i.floating;let b,y;d==="top"||d==="bottom"?(b=d,y=h===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(y=d,b=h==="end"?"top":"bottom");const v=g-u.top-u.bottom,x=m-u.left-u.right,S=ks(g-u[b],v),_=ks(m-u[y],x),E=!t.middlewareData.shift;let C=S,R=_;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(R=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),E&&!h){const N=tr(u.left,0),D=tr(u.right,0),A=tr(u.top,0),j=tr(u.bottom,0);p?R=m-2*(N!==0||D!==0?N+D:tr(u.left,u.right)):C=g-2*(A!==0||j!==0?A+j:tr(u.top,u.bottom))}await l({...t,availableWidth:R,availableHeight:C});const M=await s.getDimensions(a.floating);return m!==M.width||g!==M.height?{reset:{rects:!0}}:{}}}};function Ry(){return typeof window<"u"}function Nd(e){return h3(e)?(e.nodeName||"").toLowerCase():"#document"}function io(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Wi(e){var t;return(t=(h3(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function h3(e){return Ry()?e instanceof Node||e instanceof io(e).Node:!1}function nr(e){return Ry()?e instanceof Element||e instanceof io(e).Element:!1}function Ti(e){return Ry()?e instanceof HTMLElement||e instanceof io(e).HTMLElement:!1}function FM(e){return!Ry()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof io(e).ShadowRoot}function Tp(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Jo(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function Toe(e){return["table","td","th"].includes(Nd(e))}function Ny(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function g_(e){const t=b_(),n=nr(e)?Jo(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 joe(e){let t=wa(e);for(;Ti(t)&&!td(t);){if(g_(t))return t;if(Ny(t))return null;t=wa(t)}return null}function b_(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function td(e){return["html","body","#document"].includes(Nd(e))}function Jo(e){return io(e).getComputedStyle(e)}function Ay(e){return nr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function wa(e){if(Nd(e)==="html")return e;const t=e.assignedSlot||e.parentNode||FM(e)&&e.host||Wi(e);return FM(t)?t.host:t}function p3(e){const t=wa(e);return td(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ti(t)&&Tp(t)?t:p3(t)}function Sh(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=p3(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=io(o);if(i){const a=FC(s);return t.concat(s,s.visualViewport||[],Tp(o)?o:[],a&&n?Sh(a):[])}return t.concat(o,Sh(o,[],n))}function FC(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function m3(e){const t=Jo(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Ti(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=Ch(n)!==i||Ch(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function y_(e){return nr(e)?e:e.contextElement}function wu(e){const t=y_(e);if(!Ti(t))return Ci(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=m3(t);let s=(i?Ch(n.width):n.width)/r,a=(i?Ch(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const Ooe=Ci(0);function g3(e){const t=io(e);return!b_()||!t.visualViewport?Ooe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Foe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==io(e)?!1:t}function Zl(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=y_(e);let s=Ci(1);t&&(r?nr(r)&&(s=wu(r)):s=wu(e));const a=Foe(i,n,r)?g3(i):Ci(0);let l=(o.left+a.x)/s.x,c=(o.top+a.y)/s.y,u=o.width/s.x,d=o.height/s.y;if(i){const h=io(i),p=r&&nr(r)?io(r):r;let m=h,g=FC(m);for(;g&&r&&p!==m;){const b=wu(g),y=g.getBoundingClientRect(),v=Jo(g),x=y.left+(g.clientLeft+parseFloat(v.paddingLeft))*b.x,S=y.top+(g.clientTop+parseFloat(v.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,d*=b.y,l+=x,c+=S,m=io(g),g=FC(m)}}return $b({width:u,height:d,x:l,y:c})}function v_(e,t){const n=Ay(e).scrollLeft;return t?t.left+n:Zl(Wi(e)).left+n}function b3(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:v_(e,r)),i=r.top+t.scrollTop;return{x:o,y:i}}function Loe(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",s=Wi(r),a=t?Ny(t.floating):!1;if(r===s||a&&i)return n;let l={scrollLeft:0,scrollTop:0},c=Ci(1);const u=Ci(0),d=Ti(r);if((d||!d&&!i)&&((Nd(r)!=="body"||Tp(s))&&(l=Ay(r)),Ti(r))){const p=Zl(r);c=wu(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const h=s&&!d&&!i?b3(s,l,!0):Ci(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 $oe(e){return Array.from(e.getClientRects())}function zoe(e){const t=Wi(e),n=Ay(e),r=e.ownerDocument.body,o=tr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=tr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+v_(e);const a=-n.scrollTop;return Jo(r).direction==="rtl"&&(s+=tr(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:a}}function Boe(e,t){const n=io(e),r=Wi(e),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,a=0,l=0;if(o){i=o.width,s=o.height;const c=b_();(!c||c&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:i,height:s,x:a,y:l}}function Voe(e,t){const n=Zl(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Ti(e)?wu(e):Ci(1),s=e.clientWidth*i.x,a=e.clientHeight*i.y,l=o*i.x,c=r*i.y;return{width:s,height:a,x:l,y:c}}function LM(e,t,n){let r;if(t==="viewport")r=Boe(e,n);else if(t==="document")r=zoe(Wi(e));else if(nr(t))r=Voe(t,n);else{const o=g3(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return $b(r)}function y3(e,t){const n=wa(e);return n===t||!nr(n)||td(n)?!1:Jo(n).position==="fixed"||y3(n,t)}function Hoe(e,t){const n=t.get(e);if(n)return n;let r=Sh(e,[],!1).filter(a=>nr(a)&&Nd(a)!=="body"),o=null;const i=Jo(e).position==="fixed";let s=i?wa(e):e;for(;nr(s)&&!td(s);){const a=Jo(s),l=g_(s);!l&&a.position==="fixed"&&(o=null),(i?!l&&!o:!l&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Tp(s)&&!l&&y3(e,s))?r=r.filter(u=>u!==s):o=a,s=wa(s)}return t.set(e,r),r}function Woe(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?Ny(t)?[]:Hoe(t,this._c):[].concat(n),r],a=s[0],l=s.reduce((c,u)=>{const d=LM(t,u,o);return c.top=tr(d.top,c.top),c.right=ks(d.right,c.right),c.bottom=ks(d.bottom,c.bottom),c.left=tr(d.left,c.left),c},LM(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Uoe(e){const{width:t,height:n}=m3(e);return{width:t,height:n}}function Goe(e,t,n){const r=Ti(t),o=Wi(t),i=n==="fixed",s=Zl(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const l=Ci(0);if(r||!r&&!i)if((Nd(t)!=="body"||Tp(o))&&(a=Ay(t)),r){const h=Zl(t,!0,i,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else o&&(l.x=v_(o));const c=o&&!r&&!i?b3(o,a):Ci(0),u=s.left+a.scrollLeft-l.x-c.x,d=s.top+a.scrollTop-l.y-c.y;return{x:u,y:d,width:s.width,height:s.height}}function Hx(e){return Jo(e).position==="static"}function $M(e,t){if(!Ti(e)||Jo(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Wi(e)===n&&(n=n.ownerDocument.body),n}function v3(e,t){const n=io(e);if(Ny(e))return n;if(!Ti(e)){let o=wa(e);for(;o&&!td(o);){if(nr(o)&&!Hx(o))return o;o=wa(o)}return n}let r=$M(e,t);for(;r&&Toe(r)&&Hx(r);)r=$M(r,t);return r&&td(r)&&Hx(r)&&!g_(r)?n:r||joe(e)||n}const qoe=async function(e){const t=this.getOffsetParent||v3,n=this.getDimensions,r=await n(e.floating);return{reference:Goe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Yoe(e){return Jo(e).direction==="rtl"}const Koe={convertOffsetParentRelativeRectToViewportRelativeRect:Loe,getDocumentElement:Wi,getClippingRect:Woe,getOffsetParent:v3,getElementRects:qoe,getClientRects:$oe,getDimensions:Uoe,getScale:wu,isElement:nr,isRTL:Yoe};function x3(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Xoe(e,t){let n=null,r;const o=Wi(e);function i(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function s(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const c=e.getBoundingClientRect(),{left:u,top:d,width:h,height:p}=c;if(a||t(),!h||!p)return;const m=Wm(d),g=Wm(o.clientWidth-(u+h)),b=Wm(o.clientHeight-(d+p)),y=Wm(u),x={rootMargin:-m+"px "+-g+"px "+-b+"px "+-y+"px",threshold:tr(0,ks(1,l))||1};let S=!0;function _(E){const C=E[0].intersectionRatio;if(C!==l){if(!S)return s();C?s(!1,C):r=setTimeout(()=>{s(!1,1e-7)},1e3)}C===1&&!x3(c,e.getBoundingClientRect())&&s(),S=!1}try{n=new IntersectionObserver(_,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(_,x)}n.observe(e)}return s(!0),i}function x_(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=y_(e),u=o||i?[...c?Sh(c):[],...Sh(t)]:[];u.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const d=c&&a?Xoe(c,n):null;let h=-1,p=null;s&&(p=new ResizeObserver(y=>{let[v]=y;v&&v.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var x;(x=p)==null||x.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let m,g=l?Zl(e):null;l&&b();function b(){const y=Zl(e);g&&!x3(g,y)&&n(),g=y,m=requestAnimationFrame(b)}return n(),()=>{var y;u.forEach(v=>{o&&v.removeEventListener("scroll",n),i&&v.removeEventListener("resize",n)}),d==null||d(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(m)}}const Wx=ed,Qoe=Moe,Joe=Poe,Zoe=Roe,eie=Ioe,tie=Noe,zM=koe,nie=Doe,rie=(e,t,n)=>{const r=new Map,o={platform:Koe,...n},i={...o.platform,_c:r};return _oe(e,t,{...o,platform:i})};var Qg=typeof document<"u"?k.useLayoutEffect:k.useEffect;function zb(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(!zb(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 i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!zb(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function w3(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function BM(e,t){const n=w3(e);return Math.round(t*n)/n}function Ux(e){const t=w.useRef(e);return Qg(()=>{t.current=e}),t}function w_(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,d]=w.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=w.useState(r);zb(h,r)||p(r);const[m,g]=w.useState(null),[b,y]=w.useState(null),v=w.useCallback(B=>{B!==E.current&&(E.current=B,g(B))},[]),x=w.useCallback(B=>{B!==C.current&&(C.current=B,y(B))},[]),S=i||m,_=s||b,E=w.useRef(null),C=w.useRef(null),R=w.useRef(u),M=l!=null,N=Ux(l),D=Ux(o),A=Ux(c),j=w.useCallback(()=>{if(!E.current||!C.current)return;const B={placement:t,strategy:n,middleware:h};D.current&&(B.platform=D.current),rie(E.current,C.current,B).then(z=>{const T={...z,isPositioned:A.current!==!1};O.current&&!zb(R.current,T)&&(R.current=T,_s.flushSync(()=>{d(T)}))})},[h,t,n,D,A]);Qg(()=>{c===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,d(B=>({...B,isPositioned:!1})))},[c]);const O=w.useRef(!1);Qg(()=>(O.current=!0,()=>{O.current=!1}),[]),Qg(()=>{if(S&&(E.current=S),_&&(C.current=_),S&&_){if(N.current)return N.current(S,_,j);j()}},[S,_,j,N,M]);const I=w.useMemo(()=>({reference:E,floating:C,setReference:v,setFloating:x}),[v,x]),L=w.useMemo(()=>({reference:S,floating:_}),[S,_]),F=w.useMemo(()=>{const B={position:n,left:0,top:0};if(!L.floating)return B;const z=BM(L.floating,u.x),T=BM(L.floating,u.y);return a?{...B,transform:"translate("+z+"px, "+T+"px)",...w3(L.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:z,top:T}},[n,a,L.floating,u.x,u.y]);return w.useMemo(()=>({...u,update:j,refs:I,elements:L,floatingStyles:F}),[u,j,I,L,F])}const oie=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?zM({element:r.current,padding:o}).fn(n):{}:r?zM({element:r,padding:o}).fn(n):{}}}},My=(e,t)=>({...Qoe(e),options:[e,t]}),C_=(e,t)=>({...Joe(e),options:[e,t]}),C3=(e,t)=>({...nie(e),options:[e,t]}),S_=(e,t)=>({...Zoe(e),options:[e,t]}),E_=(e,t)=>({...eie(e),options:[e,t]}),S3=(e,t)=>({...tie(e),options:[e,t]}),E3=(e,t)=>({...oie(e),options:[e,t]});var iie="Arrow",_3=w.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return f.jsx(Re.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:f.jsx("polygon",{points:"0,0 30,0 15,10"})})});_3.displayName=iie;var sie=_3;function Py(e){const[t,n]=w.useState(void 0);return Un(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,a;if("borderBoxSize"in i){const l=i.borderBoxSize,c=Array.isArray(l)?l[0]:l;s=c.inlineSize,a=c.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var __="Popper",[k3,Ui]=Tn(__),[aie,R3]=k3(__),N3=e=>{const{__scopePopper:t,children:n}=e,[r,o]=w.useState(null);return f.jsx(aie,{scope:t,anchor:r,onAnchorChange:o,children:n})};N3.displayName=__;var A3="PopperAnchor",M3=w.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=R3(A3,n),s=w.useRef(null),a=We(t,s);return w.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||s.current)}),r?null:f.jsx(Re.div,{...o,ref:a})});M3.displayName=A3;var k_="PopperContent",[lie,cie]=k3(k_),P3=w.forwardRef((e,t)=>{var U,G,Y,Q,te,J;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:m,...g}=e,b=R3(k_,n),[y,v]=w.useState(null),x=We(t,ie=>v(ie)),[S,_]=w.useState(null),E=Py(S),C=(E==null?void 0:E.width)??0,R=(E==null?void 0:E.height)??0,M=r+(i!=="center"?"-"+i:""),N=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(c)?c:[c],A=D.length>0,j={padding:N,boundary:D.filter(die),altBoundary:A},{refs:O,floatingStyles:I,placement:L,isPositioned:F,middlewareData:B}=w_({strategy:"fixed",placement:M,whileElementsMounted:(...ie)=>x_(...ie,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[My({mainAxis:o+R,alignmentAxis:s}),l&&C_({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?C3():void 0,...j}),l&&S_({...j}),E_({...j,apply:({elements:ie,rects:Z,availableWidth:ue,availableHeight:fe})=>{const{width:xe,height:ge}=Z.reference,be=ie.floating.style;be.setProperty("--radix-popper-available-width",`${ue}px`),be.setProperty("--radix-popper-available-height",`${fe}px`),be.setProperty("--radix-popper-anchor-width",`${xe}px`),be.setProperty("--radix-popper-anchor-height",`${ge}px`)}}),S&&E3({element:S,padding:a}),fie({arrowWidth:C,arrowHeight:R}),h&&S3({strategy:"referenceHidden",...j})]}),[z,T]=T3(L),H=Mn(m);Un(()=>{F&&(H==null||H())},[F,H]);const V=(U=B.arrow)==null?void 0:U.x,P=(G=B.arrow)==null?void 0:G.y,W=((Y=B.arrow)==null?void 0:Y.centerOffset)!==0,[$,q]=w.useState();return Un(()=>{y&&q(window.getComputedStyle(y).zIndex)},[y]),f.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...I,transform:F?I.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:$,"--radix-popper-transform-origin":[(Q=B.transformOrigin)==null?void 0:Q.x,(te=B.transformOrigin)==null?void 0:te.y].join(" "),...((J=B.hide)==null?void 0:J.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:f.jsx(lie,{scope:n,placedSide:z,onArrowChange:_,arrowX:V,arrowY:P,shouldHideArrow:W,children:f.jsx(Re.div,{"data-side":z,"data-align":T,...g,ref:x,style:{...g.style,animation:F?void 0:"none"}})})})});P3.displayName=k_;var D3="PopperArrow",uie={top:"bottom",right:"left",bottom:"top",left:"right"},I3=w.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=cie(D3,r),s=uie[i.placedSide];return f.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:f.jsx(sie,{...o,ref:n,style:{...o.style,display:"block"}})})});I3.displayName=D3;function die(e){return e!==null}var fie=e=>({name:"transformOrigin",options:e,fn(t){var b,y,v;const{placement:n,rects:r,middlewareData:o}=t,s=((b=o.arrow)==null?void 0:b.centerOffset)!==0,a=s?0:e.arrowWidth,l=s?0:e.arrowHeight,[c,u]=T3(n),d={start:"0%",center:"50%",end:"100%"}[u],h=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((v=o.arrow)==null?void 0:v.y)??0)+l/2;let m="",g="";return c==="bottom"?(m=s?d:`${h}px`,g=`${-l}px`):c==="top"?(m=s?d:`${h}px`,g=`${r.floating.height+l}px`):c==="right"?(m=`${-l}px`,g=s?d:`${p}px`):c==="left"&&(m=`${r.floating.width+l}px`,g=s?d:`${p}px`),{data:{x:m,y:g}}}});function T3(e){const[t,n="center"]=e.split("-");return[t,n]}var Ad=N3,Md=M3,jp=P3,Op=I3,hie="Portal",kc=w.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,i]=w.useState(!1);Un(()=>i(!0),[]);const s=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return s?un.createPortal(f.jsx(Re.div,{...r,ref:t}),s):null});kc.displayName=hie;var j3=w.forwardRef((e,t)=>{const{children:n,...r}=e,o=w.Children.toArray(n),i=o.find(mie);if(i){const s=i.props.children,a=o.map(l=>l===i?w.Children.count(s)>1?w.Children.only(null):w.isValidElement(s)?s.props.children:null:l);return f.jsx(LC,{...r,ref:t,children:w.isValidElement(s)?w.cloneElement(s,void 0,a):null})}return f.jsx(LC,{...r,ref:t,children:n})});j3.displayName="Slot";var LC=w.forwardRef((e,t)=>{const{children:n,...r}=e;if(w.isValidElement(n)){const o=bie(n),i=gie(r,n.props);return n.type!==w.Fragment&&(i.ref=t?wr(t,o):o),w.cloneElement(n,i)}return w.Children.count(n)>1?w.Children.only(null):null});LC.displayName="SlotClone";var pie=({children:e})=>f.jsx(f.Fragment,{children:e});function mie(e){return w.isValidElement(e)&&e.type===pie}function gie(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function bie(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 R_="Popover",[O3,x$e]=Tn(R_,[Ui]),Fp=Ui(),[yie,Oa]=O3(R_),F3=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=Fp(t),l=w.useRef(null),[c,u]=w.useState(!1),[d=!1,h]=Gn({prop:r,defaultProp:o,onChange:i});return f.jsx(Ad,{...a,children:f.jsx(yie,{scope:t,contentId:yn(),triggerRef:l,open:d,onOpenChange:h,onOpenToggle:w.useCallback(()=>h(p=>!p),[h]),hasCustomAnchor:c,onCustomAnchorAdd:w.useCallback(()=>u(!0),[]),onCustomAnchorRemove:w.useCallback(()=>u(!1),[]),modal:s,children:n})})};F3.displayName=R_;var L3="PopoverAnchor",vie=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Oa(L3,n),i=Fp(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=o;return w.useEffect(()=>(s(),()=>a()),[s,a]),f.jsx(Md,{...i,...r,ref:t})});vie.displayName=L3;var $3="PopoverTrigger",z3=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Oa($3,n),i=Fp(n),s=We(t,o.triggerRef),a=f.jsx(Re.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":U3(o.open),...r,ref:s,onClick:pe(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:f.jsx(Md,{asChild:!0,...i,children:a})});z3.displayName=$3;var N_="PopoverPortal",[xie,wie]=O3(N_,{forceMount:void 0}),B3=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=Oa(N_,t);return f.jsx(xie,{scope:t,forceMount:n,children:f.jsx(vn,{present:n||i.open,children:f.jsx(kc,{asChild:!0,container:o,children:r})})})};B3.displayName=N_;var nd="PopoverContent",V3=w.forwardRef((e,t)=>{const n=wie(nd,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=Oa(nd,e.__scopePopover);return f.jsx(vn,{present:r||i.open,children:i.modal?f.jsx(Cie,{...o,ref:t}):f.jsx(Sie,{...o,ref:t})})});V3.displayName=nd;var Cie=w.forwardRef((e,t)=>{const n=Oa(nd,e.__scopePopover),r=w.useRef(null),o=We(t,r),i=w.useRef(!1);return w.useEffect(()=>{const s=r.current;if(s)return Sd(s)},[]),f.jsx(Ec,{as:j3,allowPinchZoom:!0,children:f.jsx(H3,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:pe(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),i.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:pe(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),Sie=w.forwardRef((e,t)=>{const n=Oa(nd,e.__scopePopover),r=w.useRef(!1),o=w.useRef(!1);return f.jsx(H3,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var s,a;(s=e.onCloseAutoFocus)==null||s.call(e,i),i.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;((c=n.triggerRef.current)==null?void 0:c.contains(s))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),H3=w.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...d}=e,h=Oa(nd,n),p=Fp(n);return ky(),f.jsx(Ip,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:f.jsx(_c,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:f.jsx(jp,{"data-state":U3(h.open),role:"dialog",id:h.contentId,...p,...d,ref:t,style:{...d.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)"}})})})}),W3="PopoverClose",Eie=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Oa(W3,n);return f.jsx(Re.button,{type:"button",...r,ref:t,onClick:pe(e.onClick,()=>o.onOpenChange(!1))})});Eie.displayName=W3;var _ie="PopoverArrow",kie=w.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Fp(n);return f.jsx(Op,{...o,...r,ref:t})});kie.displayName=_ie;function U3(e){return e?"open":"closed"}var Rie=F3,Nie=z3,Aie=B3,Dy=V3;const Rc=Rie,Nc=Nie,Fa=w.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>f.jsx(Aie,{children:f.jsx(ni,{children:f.jsx(Dy,{ref:o,align:t,sideOffset:n,className:re("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})})}));Fa.displayName=Dy.displayName;function $C(e,[t,n]){return Math.min(n,Math.max(t,e))}var G3=w.forwardRef((e,t)=>{const{children:n,...r}=e,o=w.Children.toArray(n),i=o.find(Pie);if(i){const s=i.props.children,a=o.map(l=>l===i?w.Children.count(s)>1?w.Children.only(null):w.isValidElement(s)?s.props.children:null:l);return f.jsx(zC,{...r,ref:t,children:w.isValidElement(s)?w.cloneElement(s,void 0,a):null})}return f.jsx(zC,{...r,ref:t,children:n})});G3.displayName="Slot";var zC=w.forwardRef((e,t)=>{const{children:n,...r}=e;if(w.isValidElement(n)){const o=Iie(n),i=Die(r,n.props);return n.type!==w.Fragment&&(i.ref=t?wr(t,o):o),w.cloneElement(n,i)}return w.Children.count(n)>1?w.Children.only(null):null});zC.displayName="SlotClone";var Mie=({children:e})=>f.jsx(f.Fragment,{children:e});function Pie(e){return w.isValidElement(e)&&e.type===Mie}function Die(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Iie(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 Iy(e){const t=w.useRef({value:e,previous:e});return w.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Tie="VisuallyHidden",A_=w.forwardRef((e,t)=>f.jsx(Re.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}}));A_.displayName=Tie;var jie=A_,Oie=[" ","Enter","ArrowUp","ArrowDown"],Fie=[" ","Enter"],Lp="Select",[Ty,jy,Lie]=X0(Lp),[Pd,w$e]=Tn(Lp,[Lie,Ui]),Oy=Ui(),[$ie,La]=Pd(Lp),[zie,Bie]=Pd(Lp),q3=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:i,value:s,defaultValue:a,onValueChange:l,dir:c,name:u,autoComplete:d,disabled:h,required:p,form:m}=e,g=Oy(t),[b,y]=w.useState(null),[v,x]=w.useState(null),[S,_]=w.useState(!1),E=yc(c),[C=!1,R]=Gn({prop:r,defaultProp:o,onChange:i}),[M,N]=Gn({prop:s,defaultProp:a,onChange:l}),D=w.useRef(null),A=b?m||!!b.closest("form"):!0,[j,O]=w.useState(new Set),I=Array.from(j).map(L=>L.props.value).join(";");return f.jsx(Ad,{...g,children:f.jsxs($ie,{required:p,scope:t,trigger:b,onTriggerChange:y,valueNode:v,onValueNodeChange:x,valueNodeHasChildren:S,onValueNodeHasChildrenChange:_,contentId:yn(),value:M,onValueChange:N,open:C,onOpenChange:R,dir:E,triggerPointerDownPosRef:D,disabled:h,children:[f.jsx(Ty.Provider,{scope:t,children:f.jsx(zie,{scope:e.__scopeSelect,onNativeOptionAdd:w.useCallback(L=>{O(F=>new Set(F).add(L))},[]),onNativeOptionRemove:w.useCallback(L=>{O(F=>{const B=new Set(F);return B.delete(L),B})},[]),children:n})}),A?f.jsxs(vL,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:M,onChange:L=>N(L.target.value),disabled:h,form:m,children:[M===void 0?f.jsx("option",{value:""}):null,Array.from(j)]},I):null]})})};q3.displayName=Lp;var Y3="SelectTrigger",K3=w.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,i=Oy(n),s=La(Y3,n),a=s.disabled||r,l=We(t,s.onTriggerChange),c=jy(n),u=w.useRef("touch"),[d,h,p]=xL(g=>{const b=c().filter(x=>!x.disabled),y=b.find(x=>x.value===s.value),v=wL(b,g,y);v!==void 0&&s.onValueChange(v.value)}),m=g=>{a||(s.onOpenChange(!0),p()),g&&(s.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return f.jsx(Md,{asChild:!0,...i,children:f.jsx(Re.button,{type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":yL(s.value)?"":void 0,...o,ref:l,onClick:pe(o.onClick,g=>{g.currentTarget.focus(),u.current!=="mouse"&&m(g)}),onPointerDown:pe(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:pe(o.onKeyDown,g=>{const b=d.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&h(g.key),!(b&&g.key===" ")&&Oie.includes(g.key)&&(m(),g.preventDefault())})})})});K3.displayName=Y3;var X3="SelectValue",Q3=w.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:i,placeholder:s="",...a}=e,l=La(X3,n),{onValueNodeHasChildrenChange:c}=l,u=i!==void 0,d=We(t,l.onValueNodeChange);return Un(()=>{c(u)},[c,u]),f.jsx(Re.span,{...a,ref:d,style:{pointerEvents:"none"},children:yL(l.value)?f.jsx(f.Fragment,{children:s}):i})});Q3.displayName=X3;var Vie="SelectIcon",J3=w.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return f.jsx(Re.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});J3.displayName=Vie;var Hie="SelectPortal",Z3=e=>f.jsx(kc,{asChild:!0,...e});Z3.displayName=Hie;var ec="SelectContent",eL=w.forwardRef((e,t)=>{const n=La(ec,e.__scopeSelect),[r,o]=w.useState();if(Un(()=>{o(new DocumentFragment)},[]),!n.open){const i=r;return i?_s.createPortal(f.jsx(tL,{scope:e.__scopeSelect,children:f.jsx(Ty.Slot,{scope:e.__scopeSelect,children:f.jsx("div",{children:e.children})})}),i):null}return f.jsx(nL,{...e,ref:t})});eL.displayName=ec;var Fo=10,[tL,$a]=Pd(ec),Wie="SelectContentImpl",nL=w.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:s,side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:h,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:b,...y}=e,v=La(ec,n),[x,S]=w.useState(null),[_,E]=w.useState(null),C=We(t,U=>S(U)),[R,M]=w.useState(null),[N,D]=w.useState(null),A=jy(n),[j,O]=w.useState(!1),I=w.useRef(!1);w.useEffect(()=>{if(x)return Sd(x)},[x]),ky();const L=w.useCallback(U=>{const[G,...Y]=A().map(J=>J.ref.current),[Q]=Y.slice(-1),te=document.activeElement;for(const J of U)if(J===te||(J==null||J.scrollIntoView({block:"nearest"}),J===G&&_&&(_.scrollTop=0),J===Q&&_&&(_.scrollTop=_.scrollHeight),J==null||J.focus(),document.activeElement!==te))return},[A,_]),F=w.useCallback(()=>L([R,x]),[L,R,x]);w.useEffect(()=>{j&&F()},[j,F]);const{onOpenChange:B,triggerPointerDownPosRef:z}=v;w.useEffect(()=>{if(x){let U={x:0,y:0};const G=Q=>{var te,J;U={x:Math.abs(Math.round(Q.pageX)-(((te=z.current)==null?void 0:te.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((J=z.current)==null?void 0:J.y)??0))}},Y=Q=>{U.x<=10&&U.y<=10?Q.preventDefault():x.contains(Q.target)||B(!1),document.removeEventListener("pointermove",G),z.current=null};return z.current!==null&&(document.addEventListener("pointermove",G),document.addEventListener("pointerup",Y,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",G),document.removeEventListener("pointerup",Y,{capture:!0})}}},[x,B,z]),w.useEffect(()=>{const U=()=>B(!1);return window.addEventListener("blur",U),window.addEventListener("resize",U),()=>{window.removeEventListener("blur",U),window.removeEventListener("resize",U)}},[B]);const[T,H]=xL(U=>{const G=A().filter(te=>!te.disabled),Y=G.find(te=>te.ref.current===document.activeElement),Q=wL(G,U,Y);Q&&setTimeout(()=>Q.ref.current.focus())}),V=w.useCallback((U,G,Y)=>{const Q=!I.current&&!Y;(v.value!==void 0&&v.value===G||Q)&&(M(U),Q&&(I.current=!0))},[v.value]),P=w.useCallback(()=>x==null?void 0:x.focus(),[x]),W=w.useCallback((U,G,Y)=>{const Q=!I.current&&!Y;(v.value!==void 0&&v.value===G||Q)&&D(U)},[v.value]),$=r==="popper"?BC:rL,q=$===BC?{side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:h,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:b}:{};return f.jsx(tL,{scope:n,content:x,viewport:_,onViewportChange:E,itemRefCallback:V,selectedItem:R,onItemLeave:P,itemTextRefCallback:W,focusSelectedItem:F,selectedItemText:N,position:r,isPositioned:j,searchRef:T,children:f.jsx(Ec,{as:G3,allowPinchZoom:!0,children:f.jsx(Ip,{asChild:!0,trapped:v.open,onMountAutoFocus:U=>{U.preventDefault()},onUnmountAutoFocus:pe(o,U=>{var G;(G=v.trigger)==null||G.focus({preventScroll:!0}),U.preventDefault()}),children:f.jsx(_c,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:U=>U.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:f.jsx($,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:U=>U.preventDefault(),...y,...q,onPlaced:()=>O(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:pe(y.onKeyDown,U=>{const G=U.ctrlKey||U.altKey||U.metaKey;if(U.key==="Tab"&&U.preventDefault(),!G&&U.key.length===1&&H(U.key),["ArrowUp","ArrowDown","Home","End"].includes(U.key)){let Q=A().filter(te=>!te.disabled).map(te=>te.ref.current);if(["ArrowUp","End"].includes(U.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(U.key)){const te=U.target,J=Q.indexOf(te);Q=Q.slice(J+1)}setTimeout(()=>L(Q)),U.preventDefault()}})})})})})})});nL.displayName=Wie;var Uie="SelectItemAlignedPosition",rL=w.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,i=La(ec,n),s=$a(ec,n),[a,l]=w.useState(null),[c,u]=w.useState(null),d=We(t,C=>u(C)),h=jy(n),p=w.useRef(!1),m=w.useRef(!0),{viewport:g,selectedItem:b,selectedItemText:y,focusSelectedItem:v}=s,x=w.useCallback(()=>{if(i.trigger&&i.valueNode&&a&&c&&g&&b&&y){const C=i.trigger.getBoundingClientRect(),R=c.getBoundingClientRect(),M=i.valueNode.getBoundingClientRect(),N=y.getBoundingClientRect();if(i.dir!=="rtl"){const te=N.left-R.left,J=M.left-te,ie=C.left-J,Z=C.width+ie,ue=Math.max(Z,R.width),fe=window.innerWidth-Fo,xe=$C(J,[Fo,Math.max(Fo,fe-ue)]);a.style.minWidth=Z+"px",a.style.left=xe+"px"}else{const te=R.right-N.right,J=window.innerWidth-M.right-te,ie=window.innerWidth-C.right-J,Z=C.width+ie,ue=Math.max(Z,R.width),fe=window.innerWidth-Fo,xe=$C(J,[Fo,Math.max(Fo,fe-ue)]);a.style.minWidth=Z+"px",a.style.right=xe+"px"}const D=h(),A=window.innerHeight-Fo*2,j=g.scrollHeight,O=window.getComputedStyle(c),I=parseInt(O.borderTopWidth,10),L=parseInt(O.paddingTop,10),F=parseInt(O.borderBottomWidth,10),B=parseInt(O.paddingBottom,10),z=I+L+j+B+F,T=Math.min(b.offsetHeight*5,z),H=window.getComputedStyle(g),V=parseInt(H.paddingTop,10),P=parseInt(H.paddingBottom,10),W=C.top+C.height/2-Fo,$=A-W,q=b.offsetHeight/2,U=b.offsetTop+q,G=I+L+U,Y=z-G;if(G<=W){const te=D.length>0&&b===D[D.length-1].ref.current;a.style.bottom="0px";const J=c.clientHeight-g.offsetTop-g.offsetHeight,ie=Math.max($,q+(te?P:0)+J+F),Z=G+ie;a.style.height=Z+"px"}else{const te=D.length>0&&b===D[0].ref.current;a.style.top="0px";const ie=Math.max(W,I+g.offsetTop+(te?V:0)+q)+Y;a.style.height=ie+"px",g.scrollTop=G-W+g.offsetTop}a.style.margin=`${Fo}px 0`,a.style.minHeight=T+"px",a.style.maxHeight=A+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,i.trigger,i.valueNode,a,c,g,b,y,i.dir,r]);Un(()=>x(),[x]);const[S,_]=w.useState();Un(()=>{c&&_(window.getComputedStyle(c).zIndex)},[c]);const E=w.useCallback(C=>{C&&m.current===!0&&(x(),v==null||v(),m.current=!1)},[x,v]);return f.jsx(qie,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:E,children:f.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:f.jsx(Re.div,{...o,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});rL.displayName=Uie;var Gie="SelectPopperPosition",BC=w.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Fo,...i}=e,s=Oy(n);return f.jsx(jp,{...s,...i,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...i.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)"}})});BC.displayName=Gie;var[qie,M_]=Pd(ec,{}),VC="SelectViewport",oL=w.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,i=$a(VC,n),s=M_(VC,n),a=We(t,i.onViewportChange),l=w.useRef(0);return f.jsxs(f.Fragment,{children:[f.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}),f.jsx(Ty.Slot,{scope:n,children:f.jsx(Re.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:pe(o.onScroll,c=>{const u=c.currentTarget,{contentWrapper:d,shouldExpandOnScrollRef:h}=s;if(h!=null&&h.current&&d){const p=Math.abs(l.current-u.scrollTop);if(p>0){const m=window.innerHeight-Fo*2,g=parseFloat(d.style.minHeight),b=parseFloat(d.style.height),y=Math.max(g,b);if(y<m){const v=y+p,x=Math.min(m,v),S=v-x;d.style.height=x+"px",d.style.bottom==="0px"&&(u.scrollTop=S>0?S:0,d.style.justifyContent="flex-end")}}}l.current=u.scrollTop})})})]})});oL.displayName=VC;var iL="SelectGroup",[Yie,Kie]=Pd(iL),sL=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=yn();return f.jsx(Yie,{scope:n,id:o,children:f.jsx(Re.div,{role:"group","aria-labelledby":o,...r,ref:t})})});sL.displayName=iL;var aL="SelectLabel",lL=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Kie(aL,n);return f.jsx(Re.div,{id:o.id,...r,ref:t})});lL.displayName=aL;var Bb="SelectItem",[Xie,cL]=Pd(Bb),uL=w.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:i,...s}=e,a=La(Bb,n),l=$a(Bb,n),c=a.value===r,[u,d]=w.useState(i??""),[h,p]=w.useState(!1),m=We(t,v=>{var x;return(x=l.itemRefCallback)==null?void 0:x.call(l,v,r,o)}),g=yn(),b=w.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 f.jsx(Xie,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:w.useCallback(v=>{d(x=>x||((v==null?void 0:v.textContent)??"").trim())},[]),children:f.jsx(Ty.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:f.jsx(Re.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,...s,ref:m,onFocus:pe(s.onFocus,()=>p(!0)),onBlur:pe(s.onBlur,()=>p(!1)),onClick:pe(s.onClick,()=>{b.current!=="mouse"&&y()}),onPointerUp:pe(s.onPointerUp,()=>{b.current==="mouse"&&y()}),onPointerDown:pe(s.onPointerDown,v=>{b.current=v.pointerType}),onPointerMove:pe(s.onPointerMove,v=>{var x;b.current=v.pointerType,o?(x=l.onItemLeave)==null||x.call(l):b.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:pe(s.onPointerLeave,v=>{var x;v.currentTarget===document.activeElement&&((x=l.onItemLeave)==null||x.call(l))}),onKeyDown:pe(s.onKeyDown,v=>{var S;((S=l.searchRef)==null?void 0:S.current)!==""&&v.key===" "||(Fie.includes(v.key)&&y(),v.key===" "&&v.preventDefault())})})})})});uL.displayName=Bb;var Sf="SelectItemText",dL=w.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...i}=e,s=La(Sf,n),a=$a(Sf,n),l=cL(Sf,n),c=Bie(Sf,n),[u,d]=w.useState(null),h=We(t,y=>d(y),l.onItemTextChange,y=>{var v;return(v=a.itemTextRefCallback)==null?void 0:v.call(a,y,l.value,l.disabled)}),p=u==null?void 0:u.textContent,m=w.useMemo(()=>f.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:b}=c;return Un(()=>(g(m),()=>b(m)),[g,b,m]),f.jsxs(f.Fragment,{children:[f.jsx(Re.span,{id:l.textId,...i,ref:h}),l.isSelected&&s.valueNode&&!s.valueNodeHasChildren?_s.createPortal(i.children,s.valueNode):null]})});dL.displayName=Sf;var fL="SelectItemIndicator",hL=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return cL(fL,n).isSelected?f.jsx(Re.span,{"aria-hidden":!0,...r,ref:t}):null});hL.displayName=fL;var HC="SelectScrollUpButton",pL=w.forwardRef((e,t)=>{const n=$a(HC,e.__scopeSelect),r=M_(HC,e.__scopeSelect),[o,i]=w.useState(!1),s=We(t,r.onScrollButtonChange);return Un(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;i(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?f.jsx(gL,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});pL.displayName=HC;var WC="SelectScrollDownButton",mL=w.forwardRef((e,t)=>{const n=$a(WC,e.__scopeSelect),r=M_(WC,e.__scopeSelect),[o,i]=w.useState(!1),s=We(t,r.onScrollButtonChange);return Un(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,u=Math.ceil(l.scrollTop)<c;i(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?f.jsx(gL,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});mL.displayName=WC;var gL=w.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,i=$a("SelectScrollButton",n),s=w.useRef(null),a=jy(n),l=w.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return w.useEffect(()=>()=>l(),[l]),Un(()=>{var u;const c=a().find(d=>d.ref.current===document.activeElement);(u=c==null?void 0:c.ref.current)==null||u.scrollIntoView({block:"nearest"})},[a]),f.jsx(Re.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:pe(o.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:pe(o.onPointerMove,()=>{var c;(c=i.onItemLeave)==null||c.call(i),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:pe(o.onPointerLeave,()=>{l()})})}),Qie="SelectSeparator",bL=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return f.jsx(Re.div,{"aria-hidden":!0,...r,ref:t})});bL.displayName=Qie;var UC="SelectArrow",Jie=w.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Oy(n),i=La(UC,n),s=$a(UC,n);return i.open&&s.position==="popper"?f.jsx(Op,{...o,...r,ref:t}):null});Jie.displayName=UC;function yL(e){return e===""||e===void 0}var vL=w.forwardRef((e,t)=>{const{value:n,...r}=e,o=w.useRef(null),i=We(t,o),s=Iy(n);return w.useEffect(()=>{const a=o.current,l=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(l,"value").set;if(s!==n&&u){const d=new Event("change",{bubbles:!0});u.call(a,n),a.dispatchEvent(d)}},[s,n]),f.jsx(A_,{asChild:!0,children:f.jsx("select",{...r,ref:i,defaultValue:n})})});vL.displayName="BubbleSelect";function xL(e){const t=Mn(e),n=w.useRef(""),r=w.useRef(0),o=w.useCallback(s=>{const a=n.current+s;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),i=w.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return w.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,i]}function wL(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let s=Zie(e,Math.max(i,0));o.length===1&&(s=s.filter(c=>c!==n));const l=s.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Zie(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ese=q3,CL=K3,tse=Q3,nse=J3,rse=Z3,SL=eL,ose=oL,ise=sL,EL=lL,_L=uL,sse=dL,ase=hL,kL=pL,RL=mL,NL=bL;const qt=ese,tu=ise,Yt=tse,zt=w.forwardRef(({className:e,children:t,...n},r)=>f.jsxs(CL,{ref:r,className:re("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,f.jsx(nse,{asChild:!0,children:f.jsx(fa,{className:"h-4 w-4 opacity-50"})})]}));zt.displayName=CL.displayName;const AL=w.forwardRef(({className:e,...t},n)=>f.jsx(kL,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:f.jsx(Ff,{className:"h-4 w-4"})}));AL.displayName=kL.displayName;const ML=w.forwardRef(({className:e,...t},n)=>f.jsx(RL,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:f.jsx(fa,{className:"h-4 w-4"})}));ML.displayName=RL.displayName;const Bt=w.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>f.jsx(rse,{children:f.jsx(ni,{children:f.jsxs(SL,{ref:o,className:re("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:[f.jsx(AL,{}),f.jsx(ose,{className:re("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),f.jsx(ML,{})]})})}));Bt.displayName=SL.displayName;const cl=w.forwardRef(({className:e,...t},n)=>f.jsx(EL,{ref:n,className:re("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));cl.displayName=EL.displayName;const Ee=w.forwardRef(({className:e,children:t,...n},r)=>f.jsxs(_L,{ref:r,className:re("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:[f.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:f.jsx(ase,{children:f.jsx(Wn,{className:"h-4 w-4"})})}),f.jsx(sse,{children:t})]}));Ee.displayName=_L.displayName;const Jg=w.forwardRef(({className:e,...t},n)=>f.jsx(NL,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));Jg.displayName=NL.displayName;const zr=w.forwardRef(({className:e,type:t,...n},r)=>f.jsx("input",{type:t,className:re("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}));zr.displayName="Input";var lse="Label",P_=w.forwardRef((e,t)=>f.jsx(Re.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));P_.displayName=lse;var PL=P_;const cse=my("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ve=w.forwardRef(({className:e,...t},n)=>f.jsx(PL,{ref:n,className:re(cse(),e),...t}));ve.displayName=PL.displayName;function use({step:e,hierarchyId:t,stepIndex:n,onUpdateStep:r,open:o,onOpenChange:i,trigger:s}){return f.jsxs(Rc,{open:o,onOpenChange:i,children:[f.jsx(Nc,{asChild:!0,children:s}),f.jsx(Fa,{className:"z-50 w-80",align:"start",children:f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx(ve,{className:"mb-1 block text-xs font-medium",children:"Chart Type"}),f.jsxs(qt,{value:e.preferredChartType||"bar",onValueChange:a=>{r(t,n,{preferredChartType:a})},children:[f.jsx(zt,{className:"h-8",children:f.jsx(Yt,{})}),f.jsxs(Bt,{children:[f.jsx(Ee,{value:"bar",children:"Bar Chart"}),f.jsx(Ee,{value:"pie",children:"Pie Chart"}),f.jsx(Ee,{value:"line",children:"Line Chart"}),f.jsx(Ee,{value:"donut",children:"Donut Chart"}),f.jsx(Ee,{value:"table",children:"Table"}),f.jsx(Ee,{value:"metric",children:"Metric"})]})]})]}),f.jsxs("div",{children:[f.jsx(ve,{className:"mb-1 block text-xs font-medium",children:"Step Label"}),f.jsx(zr,{value:e.label||"",onChange:a=>r(t,n,{label:a.target.value}),placeholder:"Custom drill label",className:"h-8"})]}),f.jsxs("div",{children:[f.jsx(ve,{className:"mb-1 block text-xs font-medium",children:"Breadcrumb Label Template"}),f.jsx(zr,{value:e.breadcrumbLabelTemplate||"",onChange:a=>r(t,n,{breadcrumbLabelTemplate:a.target.value}),placeholder:"e.g., 'Region: {{value}}'",className:"h-8"})]}),f.jsx("div",{className:"flex items-center gap-4",children:f.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[f.jsx("input",{type:"checkbox",checked:e.retainFilters!==!1,onChange:a=>r(t,n,{retainFilters:a.target.checked}),className:"rounded"}),"Retain filters when drilling"]})}),f.jsx("div",{className:"flex justify-end",children:f.jsx(_e,{size:"sm",variant:"outline",onClick:()=>i(!1),children:"Done"})})]})})]})}function dse({field:e,step:t,stepIndex:n,hierarchyId:r,onUpdateStep:o,onRemoveStep:i,isFirstField:s=!1}){const[a,l]=k.useState(!1),{attributes:c,listeners:u,setNodeRef:d,transform:h,transition:p,isDragging:m}=d_({id:`${r}-${e.id}-${n}`,disabled:!1}),g={transform:Di.Transform.toString(h),transition:p,opacity:m?.8:1,zIndex:m?1e3:1};return f.jsx("div",{ref:d,style:g,className:`relative ${a?"z-[9998]":""}`,...c,children:f.jsx(use,{step:t,hierarchyId:r,stepIndex:n,onUpdateStep:o,open:a,onOpenChange:l,trigger:f.jsxs("div",{className:`flex cursor-pointer items-center gap-2 rounded-lg p-2 transition-colors ${s?"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:[f.jsxs("div",{className:"pointer-events-none flex items-center gap-2",children:[f.jsx("span",{className:"whitespace-nowrap text-sm font-medium",children:e.label}),t.preferredChartType&&t.preferredChartType!=="bar"&&f.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&&f.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:"📊"})]}),f.jsx("button",{className:`pointer-events-auto ml-1 text-xs hover:text-red-800 dark:hover:text-red-400 ${s?"text-muted-foreground":"text-blue-600 dark:text-blue-400"}`,onClick:b=>{b.stopPropagation(),i(r,n)},children:"×"})]})})})}function fse(e){return{sensors:o_(xh(Mp,{activationConstraint:{distance:5}}),xh(Ap,{coordinateGetter:f_})),handleStepDragEnd:(r,o)=>{const{active:i,over:s}=r;if(!s||i.id===s.id)return;const a=i.id.replace(`${o.id}-`,""),l=s.id.replace(`${o.id}-`,""),c=o.steps.findIndex(d=>d.field.id===a),u=o.steps.findIndex(d=>d.field.id===l);if(c!==-1&&u!==-1&&c!==u){const d=Dp(o.steps,c,u);e(o.id,{steps:d})}}}}function hse({hierarchy:e,onUpdateStep:t,onRemoveStep:n,onUpdateHierarchy:r}){const{sensors:o}=fse(r),[i,s]=k.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;s(b||null)},d=h=>{s(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],[v]=y.splice(g,1);y.splice(b,0,v),r(e.id,{steps:y})}};return a.length===0?f.jsx("div",{className:"steps-container",onPointerDown:h=>h.stopPropagation(),children:f.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."})}):f.jsx("div",{className:"steps-container",onPointerDown:h=>h.stopPropagation(),children:f.jsxs(c_,{sensors:o,collisionDetection:i_,onDragStart:u,onDragEnd:d,children:[f.jsx(u_,{items:c,strategy:Vre,children:f.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(f.jsx(Ko,{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(f.jsx(dse,{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"&&un.createPortal(f.jsx(n3,{className:"semaphor-scope",style:{zIndex:9999},children:i?f.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:f.jsx("span",{className:"whitespace-nowrap text-sm font-medium",children:i.label})}):null}),document.body)]})})}var VM=1,pse=.9,mse=.8,gse=.17,Gx=.1,qx=.999,bse=.9999,yse=.99,vse=/[\\\/_+.#"@\[\(\{&]/,xse=/[\\\/_+.#"@\[\(\{&]/g,wse=/[\s-]/,DL=/[\s-]/g;function GC(e,t,n,r,o,i,s){if(i===t.length)return o===e.length?VM:yse;var a=`${o},${i}`;if(s[a]!==void 0)return s[a];for(var l=r.charAt(i),c=n.indexOf(l,o),u=0,d,h,p,m;c>=0;)d=GC(e,t,n,r,c+1,i+1,s),d>u&&(c===o?d*=VM:vse.test(e.charAt(c-1))?(d*=mse,p=e.slice(o,c-1).match(xse),p&&o>0&&(d*=Math.pow(qx,p.length))):wse.test(e.charAt(c-1))?(d*=pse,m=e.slice(o,c-1).match(DL),m&&o>0&&(d*=Math.pow(qx,m.length))):(d*=gse,o>0&&(d*=Math.pow(qx,c-o))),e.charAt(c)!==t.charAt(i)&&(d*=bse)),(d<Gx&&n.charAt(c-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(c-1)!==r.charAt(i))&&(h=GC(e,t,n,r,c+1,i+2,s),h*Gx>d&&(d=h*Gx)),d>u&&(u=d),c=n.indexOf(l,c+1);return s[a]=u,u}function HM(e){return e.toLowerCase().replace(DL," ")}function Cse(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,GC(e,t,HM(e),HM(t),0,0,{})}var tf='[cmdk-group=""]',Yx='[cmdk-group-items=""]',Sse='[cmdk-group-heading=""]',IL='[cmdk-item=""]',WM=`${IL}:not([aria-disabled="true"])`,qC="cmdk-item-select",nu="data-value",Ese=(e,t,n)=>Cse(e,t,n),TL=w.createContext(void 0),$p=()=>w.useContext(TL),jL=w.createContext(void 0),D_=()=>w.useContext(jL),OL=w.createContext(void 0),FL=w.forwardRef((e,t)=>{let n=ru(()=>{var V,P;return{search:"",value:(P=(V=e.value)!=null?V:e.defaultValue)!=null?P:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=ru(()=>new Set),o=ru(()=>new Map),i=ru(()=>new Map),s=ru(()=>new Set),a=LL(e),{label:l,children:c,value:u,onValueChange:d,filter:h,shouldFilter:p,loop:m,disablePointerSelection:g=!1,vimBindings:b=!0,...y}=e,v=yn(),x=yn(),S=yn(),_=w.useRef(null),E=jse();tc(()=>{if(u!==void 0){let V=u.trim();n.current.value=V,C.emit()}},[u]),tc(()=>{E(6,j)},[]);let C=w.useMemo(()=>({subscribe:V=>(s.current.add(V),()=>s.current.delete(V)),snapshot:()=>n.current,setState:(V,P,W)=>{var $,q,U,G;if(!Object.is(n.current[V],P)){if(n.current[V]=P,V==="search")A(),N(),E(1,D);else if(V==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Y=document.getElementById(S);Y?Y.focus():($=document.getElementById(v))==null||$.focus()}if(E(7,()=>{var Y;n.current.selectedItemId=(Y=O())==null?void 0:Y.id,C.emit()}),W||E(5,j),((q=a.current)==null?void 0:q.value)!==void 0){let Y=P??"";(G=(U=a.current).onValueChange)==null||G.call(U,Y);return}}C.emit()}},emit:()=>{s.current.forEach(V=>V())}}),[]),R=w.useMemo(()=>({value:(V,P,W)=>{var $;P!==(($=i.current.get(V))==null?void 0:$.value)&&(i.current.set(V,{value:P,keywords:W}),n.current.filtered.items.set(V,M(P,W)),E(2,()=>{N(),C.emit()}))},item:(V,P)=>(r.current.add(V),P&&(o.current.has(P)?o.current.get(P).add(V):o.current.set(P,new Set([V]))),E(3,()=>{A(),N(),n.current.value||D(),C.emit()}),()=>{i.current.delete(V),r.current.delete(V),n.current.filtered.items.delete(V);let W=O();E(4,()=>{A(),(W==null?void 0:W.getAttribute("id"))===V&&D(),C.emit()})}),group:V=>(o.current.has(V)||o.current.set(V,new Set),()=>{i.current.delete(V),o.current.delete(V)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:v,inputId:S,labelId:x,listInnerRef:_}),[]);function M(V,P){var W,$;let q=($=(W=a.current)==null?void 0:W.filter)!=null?$:Ese;return V?q(V,n.current.search,P):0}function N(){if(!n.current.search||a.current.shouldFilter===!1)return;let V=n.current.filtered.items,P=[];n.current.filtered.groups.forEach($=>{let q=o.current.get($),U=0;q.forEach(G=>{let Y=V.get(G);U=Math.max(Y,U)}),P.push([$,U])});let W=_.current;I().sort(($,q)=>{var U,G;let Y=$.getAttribute("id"),Q=q.getAttribute("id");return((U=V.get(Q))!=null?U:0)-((G=V.get(Y))!=null?G:0)}).forEach($=>{let q=$.closest(Yx);q?q.appendChild($.parentElement===q?$:$.closest(`${Yx} > *`)):W.appendChild($.parentElement===W?$:$.closest(`${Yx} > *`))}),P.sort(($,q)=>q[1]-$[1]).forEach($=>{var q;let U=(q=_.current)==null?void 0:q.querySelector(`${tf}[${nu}="${encodeURIComponent($[0])}"]`);U==null||U.parentElement.appendChild(U)})}function D(){let V=I().find(W=>W.getAttribute("aria-disabled")!=="true"),P=V==null?void 0:V.getAttribute(nu);C.setState("value",P||void 0)}function A(){var V,P,W,$;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let q=0;for(let U of r.current){let G=(P=(V=i.current.get(U))==null?void 0:V.value)!=null?P:"",Y=($=(W=i.current.get(U))==null?void 0:W.keywords)!=null?$:[],Q=M(G,Y);n.current.filtered.items.set(U,Q),Q>0&&q++}for(let[U,G]of o.current)for(let Y of G)if(n.current.filtered.items.get(Y)>0){n.current.filtered.groups.add(U);break}n.current.filtered.count=q}function j(){var V,P,W;let $=O();$&&(((V=$.parentElement)==null?void 0:V.firstChild)===$&&((W=(P=$.closest(tf))==null?void 0:P.querySelector(Sse))==null||W.scrollIntoView({block:"nearest"})),$.scrollIntoView({block:"nearest"}))}function O(){var V;return(V=_.current)==null?void 0:V.querySelector(`${IL}[aria-selected="true"]`)}function I(){var V;return Array.from(((V=_.current)==null?void 0:V.querySelectorAll(WM))||[])}function L(V){let P=I()[V];P&&C.setState("value",P.getAttribute(nu))}function F(V){var P;let W=O(),$=I(),q=$.findIndex(G=>G===W),U=$[q+V];(P=a.current)!=null&&P.loop&&(U=q+V<0?$[$.length-1]:q+V===$.length?$[0]:$[q+V]),U&&C.setState("value",U.getAttribute(nu))}function B(V){let P=O(),W=P==null?void 0:P.closest(tf),$;for(;W&&!$;)W=V>0?Ise(W,tf):Tse(W,tf),$=W==null?void 0:W.querySelector(WM);$?C.setState("value",$.getAttribute(nu)):F(V)}let z=()=>L(I().length-1),T=V=>{V.preventDefault(),V.metaKey?z():V.altKey?B(1):F(1)},H=V=>{V.preventDefault(),V.metaKey?L(0):V.altKey?B(-1):F(-1)};return w.createElement(Re.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:V=>{var P;(P=y.onKeyDown)==null||P.call(y,V);let W=V.nativeEvent.isComposing||V.keyCode===229;if(!(V.defaultPrevented||W))switch(V.key){case"n":case"j":{b&&V.ctrlKey&&T(V);break}case"ArrowDown":{T(V);break}case"p":case"k":{b&&V.ctrlKey&&H(V);break}case"ArrowUp":{H(V);break}case"Home":{V.preventDefault(),L(0);break}case"End":{V.preventDefault(),z();break}case"Enter":{V.preventDefault();let $=O();if($){let q=new Event(qC);$.dispatchEvent(q)}}}}},w.createElement("label",{"cmdk-label":"",htmlFor:R.inputId,id:R.labelId,style:Fse},l),Fy(e,V=>w.createElement(jL.Provider,{value:C},w.createElement(TL.Provider,{value:R},V))))}),_se=w.forwardRef((e,t)=>{var n,r;let o=yn(),i=w.useRef(null),s=w.useContext(OL),a=$p(),l=LL(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:s==null?void 0:s.forceMount;tc(()=>{if(!c)return a.item(o,s==null?void 0:s.id)},[c]);let u=$L(o,i,[e.value,e.children,i],e.keywords),d=D_(),h=Ca(E=>E.value&&E.value===u.current),p=Ca(E=>c||a.filter()===!1?!0:E.search?E.filtered.items.get(o)>0:!0);w.useEffect(()=>{let E=i.current;if(!(!E||e.disabled))return E.addEventListener(qC,m),()=>E.removeEventListener(qC,m)},[p,e.onSelect,e.disabled]);function m(){var E,C;g(),(C=(E=l.current).onSelect)==null||C.call(E,u.current)}function g(){d.setState("value",u.current,!0)}if(!p)return null;let{disabled:b,value:y,onSelect:v,forceMount:x,keywords:S,..._}=e;return w.createElement(Re.div,{ref:wr(i,t),..._,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)}),kse=w.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...i}=e,s=yn(),a=w.useRef(null),l=w.useRef(null),c=yn(),u=$p(),d=Ca(p=>o||u.filter()===!1?!0:p.search?p.filtered.groups.has(s):!0);tc(()=>u.group(s),[]),$L(s,a,[e.value,e.heading,l]);let h=w.useMemo(()=>({id:s,forceMount:o}),[o]);return w.createElement(Re.div,{ref:wr(a,t),...i,"cmdk-group":"",role:"presentation",hidden:d?void 0:!0},n&&w.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Fy(e,p=>w.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},w.createElement(OL.Provider,{value:h},p))))}),Rse=w.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=w.useRef(null),i=Ca(s=>!s.search);return!n&&!i?null:w.createElement(Re.div,{ref:wr(o,t),...r,"cmdk-separator":"",role:"separator"})}),Nse=w.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,i=D_(),s=Ca(c=>c.search),a=Ca(c=>c.selectedItemId),l=$p();return w.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),w.createElement(Re.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:s,onChange:c=>{o||i.setState("search",c.target.value),n==null||n(c.target.value)}})}),Ase=w.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,i=w.useRef(null),s=w.useRef(null),a=Ca(c=>c.selectedItemId),l=$p();return w.useEffect(()=>{if(s.current&&i.current){let c=s.current,u=i.current,d,h=new ResizeObserver(()=>{d=requestAnimationFrame(()=>{let p=c.offsetHeight;u.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return h.observe(c),()=>{cancelAnimationFrame(d),h.unobserve(c)}}},[]),w.createElement(Re.div,{ref:wr(i,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Fy(e,c=>w.createElement("div",{ref:wr(s,l.listInnerRef),"cmdk-list-sizer":""},c)))}),Mse=w.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:i,container:s,...a}=e;return w.createElement(kF,{open:n,onOpenChange:r},w.createElement(RF,{container:s},w.createElement(e_,{"cmdk-overlay":"",className:o}),w.createElement(t_,{"aria-label":e.label,"cmdk-dialog":"",className:i},w.createElement(FL,{ref:t,...a}))))}),Pse=w.forwardRef((e,t)=>Ca(n=>n.filtered.count===0)?w.createElement(Re.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Dse=w.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...i}=e;return w.createElement(Re.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Fy(e,s=>w.createElement("div",{"aria-hidden":!0},s)))}),Ur=Object.assign(FL,{List:Ase,Item:_se,Input:Nse,Group:kse,Separator:Rse,Dialog:Mse,Empty:Pse,Loading:Dse});function Ise(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Tse(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function LL(e){let t=w.useRef(e);return tc(()=>{t.current=e}),t}var tc=typeof window>"u"?w.useEffect:w.useLayoutEffect;function ru(e){let t=w.useRef();return t.current===void 0&&(t.current=e()),t}function Ca(e){let t=D_(),n=()=>e(t.snapshot());return w.useSyncExternalStore(t.subscribe,n,n)}function $L(e,t,n,r=[]){let o=w.useRef(),i=$p();return tc(()=>{var s;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());i.value(e,a,l),(s=t.current)==null||s.setAttribute(nu,a),o.current=a}),o}var jse=()=>{let[e,t]=w.useState(),n=ru(()=>new Map);return tc(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function Ose(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Fy({asChild:e,children:t},n){return e&&w.isValidElement(t)?w.cloneElement(Ose(t),{ref:t.ref},n(t.props.children)):n(t)}var Fse={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Ly=w.forwardRef(({className:e,...t},n)=>f.jsx(Ur,{ref:n,className:re("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Ly.displayName=Ur.displayName;const $y=w.forwardRef(({className:e,...t},n)=>f.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[f.jsx(U2,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),f.jsx(Ur.Input,{ref:n,className:re("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})]}));$y.displayName=Ur.Input.displayName;const zy=w.forwardRef(({className:e,...t},n)=>f.jsx(Ur.List,{ref:n,className:re("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));zy.displayName=Ur.List.displayName;const By=w.forwardRef((e,t)=>f.jsx(Ur.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));By.displayName=Ur.Empty.displayName;const Vy=w.forwardRef(({className:e,...t},n)=>f.jsx(Ur.Group,{ref:n,className:re("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}));Vy.displayName=Ur.Group.displayName;const Lse=w.forwardRef(({className:e,...t},n)=>f.jsx(Ur.Separator,{ref:n,className:re("-mx-1 h-px bg-border",e),...t}));Lse.displayName=Ur.Separator.displayName;const Hy=w.forwardRef(({className:e,...t},n)=>f.jsx(Ur.Item,{ref:n,className:re("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}));Hy.displayName=Ur.Item.displayName;function $se({fields:e,value:t,onValueChange:n,placeholder:r="Select field...",className:o,disabled:i=!1,excludeFieldIds:s=[]}){const[a,l]=k.useState(!1),c=e.filter(d=>!s.includes(d.id)),u=c.find(d=>d.id===t);return f.jsxs(Rc,{open:a,onOpenChange:l,children:[f.jsx(Nc,{asChild:!0,children:f.jsxs(_e,{variant:"outline",role:"combobox","aria-expanded":a,className:re("justify-between",o),disabled:i,children:[u?u.label:r,f.jsx(S4,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),f.jsx(Fa,{className:"z-50 w-[200px] p-0",children:f.jsxs(Ly,{children:[f.jsx($y,{placeholder:"Search fields..."}),f.jsxs(zy,{children:[f.jsx(By,{children:"No field found."}),f.jsx(Vy,{children:c.map(d=>f.jsxs(Hy,{value:d.label,onSelect:()=>{n(d.id),l(!1)},children:[f.jsx(Wn,{className:re("mr-2 h-4 w-4",t===d.id?"opacity-100":"opacity-0")}),d.label]},d.id))})]})]})})]})}function zse({hierarchy:e,editingHierarchy:t,sampleFieldReferences:n,onSetEditingHierarchy:r,onUpdateHierarchy:o,onDeleteHierarchy:i,onSetDefaultHierarchy:s,onUpdateStep:a,onRemoveStep:l,onAddStep:c}){const u=t===e.id,{attributes:d,listeners:h,setNodeRef:p,transform:m,transition:g}=d_({id:e.id,disabled:u}),b={transform:Di.Transform.toString(m),transition:g},y=e.steps.filter(v=>v.field).map(v=>v.field.id);return f.jsxs("div",{ref:p,style:b,className:"hierarchy-container relative rounded-lg border bg-background p-3 transition-shadow hover:shadow-md",children:[f.jsxs("div",{className:`mb-3 flex items-center justify-between ${u?"":"cursor-move"}`,...u?{}:d,...u?{}:h,children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(toe,{value:e.label||"",isEditing:u,onEdit:()=>{r(e.id)},onSave:v=>{o(e.id,{label:v}),r(null)},onCancel:()=>r(null),placeholder:"Hierarchy Name",displayClassName:"font-medium",inputClassName:"font-medium"}),f.jsxs("span",{className:"rounded bg-muted px-2 py-1 text-xs",children:[e.steps.length," steps"]}),e.default?f.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:v=>{v.stopPropagation(),s("")},onPointerDown:v=>v.stopPropagation(),title:"Click to remove default",children:"Default ✓"}):f.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:v=>{v.stopPropagation(),s(e.id)},onPointerDown:v=>v.stopPropagation(),title:"Set as default hierarchy",children:"Set Default"})]}),f.jsx("div",{className:"flex items-center gap-1",children:f.jsx(_e,{size:"sm",variant:"ghost",onClick:v=>{v.stopPropagation(),i(e.id)},onPointerDown:v=>v.stopPropagation(),children:f.jsx(vp,{className:"h-3 w-3"})})})]}),f.jsx(hse,{hierarchy:e,onUpdateStep:a,onRemoveStep:l,onUpdateHierarchy:o}),f.jsx("div",{className:"mt-3 border-t pt-3","data-hierarchy-editing":!0,children:f.jsx("div",{className:"flex items-center gap-2",children:f.jsx($se,{fields:n,excludeFieldIds:y,onValueChange:v=>c(e.id,v),placeholder:"Add drill step...",className:"w-48"})})})]})}function Bse({configuringIntent:e,setConfiguringIntent:t,drillHierarchies:n,onUpdateHierarchies:r,availableFields:o}){const i=o_(xh(Mp),xh(Ap,{coordinateGetter:f_})),{editingHierarchy:s,setEditingHierarchy:a,createNewHierarchy:l,deleteHierarchy:c,updateHierarchy:u,addStepToHierarchy:d,removeStepFromHierarchy:h,updateStep:p,setDefaultHierarchy:m}=eoe(n,r,o),g=b=>{const{active:y,over:v}=b;if(y.id!==(v==null?void 0:v.id)){const x=n.findIndex(_=>_.id===y.id),S=n.findIndex(_=>_.id===(v==null?void 0:v.id));r(Dp(n,x,S))}};return f.jsx("div",{className:"rounded-lg border p-4 hover:bg-muted/50",children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-blue-100",children:f.jsx(x4,{className:"h-5 w-5 text-blue-600 dark:text-blue-400"})}),f.jsxs("div",{className:"flex-1",children:[f.jsx("h4",{className:"mb-1 font-medium",children:"Let users drill deeper into specific paths"}),f.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Set up predefined drill paths like regions → cities, categories → products"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(_e,{size:"sm",variant:"outline",onClick:()=>t(e==="drillDown"?null:"drillDown"),children:e==="drillDown"?"Done":"Set up drill paths"}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:[n.length," hierarchies configured"]})]}),e==="drillDown"&&f.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:[f.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("h5",{className:"font-medium",children:"Drill Hierarchies"}),f.jsx("p",{className:"text-sm text-muted-foreground",children:"Create multiple drill paths for different analysis scenarios"})]}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(_e,{size:"sm",onClick:l,children:[f.jsx(Cc,{className:"mr-1 h-4 w-4"}),"Add Hierarchy"]})})]}),f.jsx(c_,{sensors:i,collisionDetection:i_,onDragEnd:g,children:f.jsx(u_,{items:n.map(b=>b.id),strategy:o3,children:f.jsx("div",{className:"mb-6 space-y-4",children:n.map(b=>f.jsx(zse,{hierarchy:b,editingHierarchy:s,sampleFieldReferences:o,onSetEditingHierarchy:a,onUpdateHierarchy:u,onDeleteHierarchy:c,onSetDefaultHierarchy:m,onUpdateStep:p,onRemoveStep:h,onAddStep:d},b.id))})})})]})]})]})})}var I_="Checkbox",[Vse,C$e]=Tn(I_),[Hse,Wse]=Vse(I_),zL=w.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:l="on",onCheckedChange:c,form:u,...d}=e,[h,p]=w.useState(null),m=We(t,S=>p(S)),g=w.useRef(!1),b=h?u||!!h.closest("form"):!0,[y=!1,v]=Gn({prop:o,defaultProp:i,onChange:c}),x=w.useRef(y);return w.useEffect(()=>{const S=h==null?void 0:h.form;if(S){const _=()=>v(x.current);return S.addEventListener("reset",_),()=>S.removeEventListener("reset",_)}},[h,v]),f.jsxs(Hse,{scope:n,state:y,disabled:a,children:[f.jsx(Re.button,{type:"button",role:"checkbox","aria-checked":pa(y)?"mixed":y,"aria-required":s,"data-state":HL(y),"data-disabled":a?"":void 0,disabled:a,value:l,...d,ref:m,onKeyDown:pe(e.onKeyDown,S=>{S.key==="Enter"&&S.preventDefault()}),onClick:pe(e.onClick,S=>{v(_=>pa(_)?!0:!_),b&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),b&&f.jsx(Use,{control:h,bubbles:!g.current,name:r,value:l,checked:y,required:s,disabled:a,form:u,style:{transform:"translateX(-100%)"},defaultChecked:pa(i)?!1:i})]})});zL.displayName=I_;var BL="CheckboxIndicator",VL=w.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=Wse(BL,n);return f.jsx(vn,{present:r||pa(i.state)||i.state===!0,children:f.jsx(Re.span,{"data-state":HL(i.state),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});VL.displayName=BL;var Use=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:o,...i}=e,s=w.useRef(null),a=Iy(n),l=Py(t);w.useEffect(()=>{const u=s.current,d=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(d,"checked").set;if(a!==n&&p){const m=new Event("click",{bubbles:r});u.indeterminate=pa(n),p.call(u,pa(n)?!1:n),u.dispatchEvent(m)}},[a,n,r]);const c=w.useRef(pa(n)?!1:n);return f.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??c.current,...i,tabIndex:-1,ref:s,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function pa(e){return e==="indeterminate"}function HL(e){return pa(e)?"indeterminate":e?"checked":"unchecked"}var WL=zL,Gse=VL;const co=w.forwardRef(({className:e,...t},n)=>f.jsx(WL,{ref:n,className:re("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:f.jsx(Gse,{className:re("flex items-center justify-center text-current"),children:f.jsx(Wn,{className:"h-4 w-4"})})}));co.displayName=WL.displayName;function qse({fields:e,selectedFieldIds:t,onSelectionChange:n,searchPlaceholder:r="Search fields...",className:o=""}){const[i,s]=k.useState(""),a=e.filter(u=>u.label.toLowerCase().includes(i.toLowerCase())||u.qualifiedEntityName&&u.qualifiedEntityName.toLowerCase().includes(i.toLowerCase())),l=()=>{const u=[...new Set([...t,...a.map(d=>d.id)])];n(u)},c=()=>{const u=a.map(d=>d.id);n(t.filter(d=>!u.includes(d)))};return f.jsxs("div",{className:`space-y-2 ${o}`,children:[f.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[f.jsx(zr,{placeholder:r,value:i,onChange:u=>s(u.target.value),className:"flex-1"}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:[a.length," fields"]})]}),f.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[f.jsx(_e,{size:"sm",variant:"outline",onClick:l,children:"Select All"}),f.jsx(_e,{size:"sm",variant:"outline",onClick:c,children:"Deselect All"}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.length," selected"]})]}),f.jsx("div",{className:"grid max-h-32 grid-cols-2 gap-2 overflow-y-auto rounded border p-2",children:a.map(u=>f.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded border p-2 text-xs hover:bg-muted/50",children:[f.jsx(co,{checked:t.includes(u.id),onCheckedChange:d=>{n(d?[...t,u.id]:t.filter(h=>h!==u.id))}}),f.jsx("span",{className:"font-medium",children:u.label})]},u.id))}),i&&a.length===0&&f.jsxs("div",{className:"py-4 text-center text-sm text-muted-foreground",children:['No fields found matching "',i,'"']})]})}const Yse=e=>["string","boolean"].includes(K0(e.dataType));function Kse({configuringIntent:e,setConfiguringIntent:t,selectedDrillTargets:n,setSelectedDrillTargets:r,availableFields:o}){const i=o.filter(Yse),s=n.map(l=>l.id),a=l=>{const c=i.filter(u=>l.includes(u.id));r(c)};return f.jsx("div",{className:"rounded-lg border p-4 hover:bg-muted/50",children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-green-100",children:f.jsx(D4,{className:"h-5 w-5 text-green-600 dark:text-green-400"})}),f.jsxs("div",{className:"flex-1",children:[f.jsx("h4",{className:"mb-1 font-medium",children:"Give users freedom to explore any dimension"}),f.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Let users dynamically drill into any available field they choose"}),f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(_e,{size:"sm",variant:"outline",onClick:()=>t(e==="dynamicDrill"?null:"dynamicDrill"),children:e==="dynamicDrill"?"Done":"Configure available fields"}),f.jsx("span",{className:"text-xs text-muted-foreground",children:n.length>0?`${n.length} fields selected`:"All fields available"})]}),e==="dynamicDrill"&&f.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:[f.jsx("h5",{className:"mb-3 font-medium",children:"Configure Dynamic Drilling"}),f.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Choose which fields users can explore dynamically:"}),f.jsx("div",{className:"border-l-2 border-green-200 pl-4",children:f.jsx(qse,{fields:i,selectedFieldIds:s,onSelectionChange:a,searchPlaceholder:"Search fields..."})})]})]})]})]})})}var T_="Switch",[Xse,S$e]=Tn(T_),[Qse,Jse]=Xse(T_),UL=w.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:l="on",onCheckedChange:c,form:u,...d}=e,[h,p]=w.useState(null),m=We(t,x=>p(x)),g=w.useRef(!1),b=h?u||!!h.closest("form"):!0,[y=!1,v]=Gn({prop:o,defaultProp:i,onChange:c});return f.jsxs(Qse,{scope:n,checked:y,disabled:a,children:[f.jsx(Re.button,{type:"button",role:"switch","aria-checked":y,"aria-required":s,"data-state":YL(y),"data-disabled":a?"":void 0,disabled:a,value:l,...d,ref:m,onClick:pe(e.onClick,x=>{v(S=>!S),b&&(g.current=x.isPropagationStopped(),g.current||x.stopPropagation())})}),b&&f.jsx(Zse,{control:h,bubbles:!g.current,name:r,value:l,checked:y,required:s,disabled:a,form:u,style:{transform:"translateX(-100%)"}})]})});UL.displayName=T_;var GL="SwitchThumb",qL=w.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=Jse(GL,n);return f.jsx(Re.span,{"data-state":YL(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});qL.displayName=GL;var Zse=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,i=w.useRef(null),s=Iy(n),a=Py(t);return w.useEffect(()=>{const l=i.current,c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&d){const h=new Event("click",{bubbles:r});d.call(l,n),l.dispatchEvent(h)}},[s,n,r]),f.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:i,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function YL(e){return e?"checked":"unchecked"}var Wy=UL,KL=qL;const j_=w.forwardRef(({className:e,...t},n)=>f.jsx(Wy,{className:re("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:f.jsx(KL,{className:re("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")})}));j_.displayName=Wy.displayName;var O_="Radio",[eae,XL]=Tn(O_),[tae,nae]=eae(O_),QL=w.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:o=!1,required:i,disabled:s,value:a="on",onCheck:l,form:c,...u}=e,[d,h]=w.useState(null),p=We(t,b=>h(b)),m=w.useRef(!1),g=d?c||!!d.closest("form"):!0;return f.jsxs(tae,{scope:n,checked:o,disabled:s,children:[f.jsx(Re.button,{type:"button",role:"radio","aria-checked":o,"data-state":e$(o),"data-disabled":s?"":void 0,disabled:s,value:a,...u,ref:p,onClick:pe(e.onClick,b=>{o||l==null||l(),g&&(m.current=b.isPropagationStopped(),m.current||b.stopPropagation())})}),g&&f.jsx(rae,{control:d,bubbles:!m.current,name:r,value:a,checked:o,required:i,disabled:s,form:c,style:{transform:"translateX(-100%)"}})]})});QL.displayName=O_;var JL="RadioIndicator",ZL=w.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...o}=e,i=nae(JL,n);return f.jsx(vn,{present:r||i.checked,children:f.jsx(Re.span,{"data-state":e$(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t})})});ZL.displayName=JL;var rae=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,i=w.useRef(null),s=Iy(n),a=Py(t);return w.useEffect(()=>{const l=i.current,c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&d){const h=new Event("click",{bubbles:r});d.call(l,n),l.dispatchEvent(h)}},[s,n,r]),f.jsx("input",{type:"radio","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:i,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function e$(e){return e?"checked":"unchecked"}var oae=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],F_="RadioGroup",[iae,E$e]=Tn(F_,[wd,XL]),t$=wd(),n$=XL(),[sae,aae]=iae(F_),r$=w.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:o,value:i,required:s=!1,disabled:a=!1,orientation:l,dir:c,loop:u=!0,onValueChange:d,...h}=e,p=t$(n),m=yc(c),[g,b]=Gn({prop:i,defaultProp:o,onChange:d});return f.jsx(sae,{scope:n,name:r,required:s,disabled:a,value:g,onValueChange:b,children:f.jsx(c2,{asChild:!0,...p,orientation:l,dir:m,loop:u,children:f.jsx(Re.div,{role:"radiogroup","aria-required":s,"aria-orientation":l,"data-disabled":a?"":void 0,dir:m,...h,ref:t})})})});r$.displayName=F_;var o$="RadioGroupItem",i$=w.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...o}=e,i=aae(o$,n),s=i.disabled||r,a=t$(n),l=n$(n),c=w.useRef(null),u=We(t,c),d=i.value===o.value,h=w.useRef(!1);return w.useEffect(()=>{const p=g=>{oae.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)}},[]),f.jsx(u2,{asChild:!0,...a,focusable:!s,active:d,children:f.jsx(QL,{disabled:s,required:i.required,checked:d,...l,...o,name:i.name,ref:u,onCheck:()=>i.onValueChange(o.value),onKeyDown:pe(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:pe(o.onFocus,()=>{var p;h.current&&((p=c.current)==null||p.click())})})})});i$.displayName=o$;var lae="RadioGroupIndicator",s$=w.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,o=n$(n);return f.jsx(ZL,{...o,...r,ref:t})});s$.displayName=lae;var a$=r$,l$=i$,cae=s$;const Sa=w.forwardRef(({className:e,...t},n)=>f.jsx(a$,{className:re("grid gap-2",e),...t,ref:n}));Sa.displayName=a$.displayName;const Lr=w.forwardRef(({className:e,...t},n)=>f.jsx(l$,{ref:n,className:re("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:f.jsx(cae,{className:"flex items-center justify-center",children:f.jsx(F2,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Lr.displayName=l$.displayName;function uae({configuringIntent:e,setConfiguringIntent:t,incomingFilterFields:n,onUpdateClickFilterInteractions:r,currentClickFilterInteractions:o}){const[i,s]=k.useState(o.length>0),[a,l]=k.useState(o[0]||{filterFields:[],highlightSelf:!0}),[c,u]=k.useState(""),d=NO(),h=e==="clickFilter",p=()=>{const E=!i;if(s(E),E){const C={filterFields:n,highlightSelf:!0,mode:"clickFilter"};l(C),r([C])}else r([])},m=()=>{t("clickFilter")},g=()=>{t(null)},b=E=>{const C={...a,...E};l(C),r([C])},y=()=>a.applyToCardIds!==void 0?"specific-cards":a.excludeCardIds!==void 0?"all-except-specific":"all-cards",v=E=>{const C={};switch(E){case"all-cards":C.applyToCardIds=void 0,C.excludeCardIds=void 0;break;case"specific-cards":C.applyToCardIds=[],C.excludeCardIds=void 0;break;case"all-except-specific":C.applyToCardIds=void 0,C.excludeCardIds=[];break}b(C)},x=(E,C)=>{if(C==="specific-cards"){const R=a.applyToCardIds||[],M=R.includes(E)?R.filter(N=>N!==E):[...R,E];b({applyToCardIds:M})}else if(C==="all-except-specific"){const R=a.excludeCardIds||[],M=R.includes(E)?R.filter(N=>N!==E):[...R,E];b({excludeCardIds:M})}},S=k.useMemo(()=>{if(!c.trim())return d;const E=c.toLowerCase();return d==null?void 0:d.filter(C=>{var R;return(R=C==null?void 0:C.title)==null?void 0:R.toLowerCase().includes(E)})},[c,d]),_=()=>{var C,R;if(!i)return"0 settings configured";const E=y();if(E==="all-cards")return"filtering all cards";if(E==="specific-cards"){const M=((C=a.applyToCardIds)==null?void 0:C.length)||0;return M===0?"no cards selected":`filtering ${M} card${M!==1?"s":""}`}else if(E==="all-except-specific"){const M=((R=a.excludeCardIds)==null?void 0:R.length)||0;return M===0?"filtering all cards":`excluding ${M} card${M!==1?"s":""}`}return"0 settings configured"};return f.jsx("div",{className:"rounded-lg border p-4 hover:bg-muted/50",children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-green-100",children:f.jsx("svg",{className:"h-5 w-5 text-green-600 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.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"})})}),f.jsxs("div",{className:"flex-1",children:[f.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[f.jsx("h4",{className:"font-medium",children:"Enable click filters"}),f.jsx(j_,{checked:i,onCheckedChange:p})]}),f.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"Apply filters to other cards when users click on chart elements"}),i&&f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(_e,{size:"sm",variant:"outline",onClick:h?g:m,children:h?"Done":"Configure"}),f.jsx("span",{className:"text-xs text-muted-foreground",children:_()})]}),h&&i&&f.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:[f.jsx("h5",{className:"mb-3 font-medium",children:"Configure Click Filters"}),f.jsx("div",{className:"space-y-6",children:f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"space-y-0.5",children:[f.jsx(ve,{className:"text-sm font-medium",children:"Filter scope"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose which cards should receive the filter"})]}),f.jsxs(Sa,{value:y(),onValueChange:E=>v(E),className:"space-y-3",children:[f.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[f.jsx(Lr,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),f.jsxs("div",{className:"flex-1 space-y-1",children:[f.jsx(ve,{htmlFor:"all-cards",className:"cursor-pointer text-sm font-medium",children:"All cards"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards in the dashboard"})]})]}),f.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[f.jsx(Lr,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),f.jsxs("div",{className:"flex-1 space-y-1",children:[f.jsx(ve,{htmlFor:"specific-cards",className:"cursor-pointer text-sm font-medium",children:"Only specific cards"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to selected cards only"})]})]}),y()==="specific-cards"&&f.jsxs("div",{className:"ml-7 space-y-2",children:[f.jsxs("div",{className:"space-y-0.5",children:[f.jsx(ve,{className:"text-sm font-medium",children:"Cards to filter"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should receive the filter"})]}),f.jsx(zr,{placeholder:"Search cards...",value:c,onChange:E=>u(E.target.value),className:"mb-2"}),f.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:S.length>0?S.map(E=>{const C=(a.applyToCardIds||[]).includes(E.id);return f.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[f.jsx(co,{id:`card-${E.id}`,checked:C,onCheckedChange:()=>x(E.id,"specific-cards")}),f.jsxs("div",{className:"flex-1",children:[f.jsx(ve,{htmlFor:`card-${E.id}`,className:"cursor-pointer text-sm font-medium",children:E.title}),E.description&&f.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:E.description})]})]},E.id)}):f.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',c,'"']})})]}),f.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[f.jsx(Lr,{value:"all-except-specific",id:"all-except-specific",className:"mt-0.5"}),f.jsxs("div",{className:"flex-1 space-y-1",children:[f.jsx(ve,{htmlFor:"all-except-specific",className:"cursor-pointer text-sm font-medium",children:"All cards except specific ones"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards, excluding selected ones"})]})]}),y()==="all-except-specific"&&f.jsxs("div",{className:"ml-7 space-y-2",children:[f.jsxs("div",{className:"space-y-0.5",children:[f.jsx(ve,{className:"text-sm font-medium",children:"Cards to exclude"}),f.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should be excluded from filtering"})]}),f.jsx(zr,{placeholder:"Search cards...",value:c,onChange:E=>u(E.target.value),className:"mb-2"}),f.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:S.length>0?S.map(E=>{const C=(a.excludeCardIds||[]).includes(E.id);return f.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[f.jsx(co,{id:`card-exclude-${E.id}`,checked:C,onCheckedChange:()=>x(E.id,"all-except-specific")}),f.jsxs("div",{className:"flex-1",children:[f.jsx(ve,{htmlFor:`card-exclude-${E.id}`,className:"cursor-pointer text-sm font-medium",children:E.title}),E.description&&f.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:E.description})]})]},E.id)}):f.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',c,'"']})})]})]})]})})]})]})]})})}function dae(e){return e.flatMap(t=>t.columns.map(n=>({id:`${t.entityId}-${n.name}`,name:n.name,qualifiedFieldName:n.qualifiedFieldName,dataType:n.dataType,qualifiedEntityName:t.qualifiedEntityName,label:n.label||e2(n.name),description:n.description,entityId:t.entityId,entityName:t.entityName,entityType:t.entityType})))}function YC(e){if(e.type==="table"||e.type==="view"||e.type==="dataset"){if(e.database&&e.schema)return`${e.database}.${e.schema}.${e.name}`;if(e.schema)return`${e.schema}.${e.name}`;if(e.database)return`${e.database}.${e.name}`}return e.name}function c$(e){var g;const t=oe(b=>b.authToken)||e,{hasSchemaSupport:n}=Aee(e),r=Ae(b=>{var y;return(y=b.card.dataSource)==null?void 0:y.connectionId}),o=Ae(b=>{var y,v;return(v=(y=b.card.dataSource)==null?void 0:y.selectedEntities)==null?void 0:v.filter(x=>x.type==="model")})||[],i=Ae(b=>{var y,v;return(v=(y=b.card.dataSource)==null?void 0:y.selectedEntities)==null?void 0:v.filter(x=>x.type==="table"||x.type==="view")})||[],s=Ae(b=>{var y,v;return(v=(y=b.card.dataSource)==null?void 0:y.selectedEntities)==null?void 0:v.filter(x=>x.type==="dataset")})||[];function a(b){return b.type==="dataset"?!!r&&!!b.domainId&&!!b.name:b.type==="model"?!!r&&!!b.id:b.type==="table"||b.type==="view"?n?!!r&&!!b.name&&!!b.database&&!!b.schema:["S3","API"].includes(b.connectionType)?!!r&&!!b.name:!!r&&!!b.name&&!!b.database:!1}const l=[...o,...i,...s],c=t5({queries:l.map(b=>{let y={};return b.type==="model"?y={connection_id:r,datamodel_id:b.id,database_name:"",schema_name:"",table_name:""}:b.type==="dataset"?y={connection_id:b.connectionId,domain_id:b.domainId,dataset_name:b.name}:y={connection_id:r,datamodel_id:"",database_name:b.database,schema_name:b.schema,table_name:b.name},{queryKey:["columns",r,b],queryFn:()=>xr("https://semaphor.cloud/api/v1/columns",(t==null?void 0:t.accessToken)||"",y),enabled:!!r&&a(b)}})}),u=c.some(b=>b.isPending),d=c.some(b=>b.isError),h=(g=c.find(b=>b.isError))==null?void 0:g.error,p=c.map((b,y)=>{var S;const v=l[y],x=YC(v);return{entityId:v.id||v.name,entityType:v.type,entityName:v.name,label:v.label,description:v.description,qualifiedEntityName:x,columns:(S=b.data)==null?void 0:S.columns.map(_=>({id:`${v.name}-${_.column_name}`,name:_.column_name,qualifiedFieldName:_.qualifiedFieldName||_.column_name,dataType:_.data_type,label:_.label||t2(_.column_name),description:_.description||"",qualifiedEntityName:x,entityId:v.id||v.id||v.name,entityName:v.name,entityType:v.type}))}}).filter(b=>{var y;return((y=b==null?void 0:b.columns)==null?void 0:y.length)>0})||[],m=dae(p);return{columnGroups:p,columns:m,isLoading:u,hasError:d,error:h,refetch:()=>{c.forEach(b=>b.refetch())}}}function fae({isOpen:e,onClose:t}){var I,L,F,B;const n=vee(),r=xee(),{updateCurrentDashboardCard:o}=dn(),{columns:i}=c$(),{groupByFields:s,pivotByFields:a}=AO(),l=[...s,...a],c=i,u=((I=n.interactionConfig)==null?void 0:I.drillHierarchies)||[],d=((L=n.interactionConfig)==null?void 0:L.allowedDrillTargets)||[],h=k.useMemo(()=>{var z;return((z=n.interactionConfig)==null?void 0:z.clickFilterInteractions)||[]},[(F=n.interactionConfig)==null?void 0:F.clickFilterInteractions]),p=k.useMemo(()=>{var z;return((z=n.interactionConfig)==null?void 0:z.drillInteractions)||[]},[(B=n.interactionConfig)==null?void 0:B.drillInteractions]),[m,g]=k.useState(u),[b,y]=k.useState(d||[]),[v,x]=k.useState(null),[S,_]=k.useState(()=>p.filter(z=>z.mode==="drillToURL")),[E,C]=k.useState(()=>p.filter(z=>z.mode==="drillThrough")),[R,M]=k.useState(()=>p.filter(z=>z.mode==="drillToDetail")),[N,D]=k.useState(h),A=k.useRef(null);k.useEffect(()=>{var z,T,H;if(e){g(((z=n.interactionConfig)==null?void 0:z.drillHierarchies)||[]),y(((T=n.interactionConfig)==null?void 0:T.allowedDrillTargets)||[]),x(null);const V=((H=n.interactionConfig)==null?void 0:H.drillInteractions)||[];_(V.filter(P=>P.mode==="drillToURL")),C(V.filter(P=>P.mode==="drillThrough")),M(V.filter(P=>P.mode==="drillToDetail")),D(h)}},[e,n.interactionConfig,h]);const j=()=>{var H;const z=[...S,...E,...R];r.updateDrillHierarchies(m),r.updateDrillInteractions(z),(H=A.current)!=null&&H.saveToGlobal&&A.current.saveToGlobal(),r.updateAllowedDrillTargets(b);const T={...n,interactionConfig:{...n.interactionConfig,drillHierarchies:m,allowedDrillTargets:b,drillInteractions:z,clickFilterInteractions:N}};o(T),t()},O=()=>{x(null),t()};return e?f.jsxs(vy,{modal:!1,open:e,onOpenChange:t,children:[f.jsx("div",{className:"pointer-events-none fixed inset-0 z-40 bg-background/80 backdrop-blur-sm"}),f.jsxs(wp,{className:"flex max-h-[90vh] max-w-4xl flex-col overflow-hidden",children:[f.jsxs(Cp,{children:[f.jsx(Ep,{children:"Configure Interactions"}),f.jsx(_p,{children:"Set up drill behaviors for this chart"})]}),f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsx("div",{className:"space-y-6",children:f.jsx("div",{children:f.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[f.jsx(uae,{configuringIntent:v,setConfiguringIntent:x,incomingFilterFields:l,onUpdateClickFilterInteractions:D,currentClickFilterInteractions:N}),f.jsx(Bse,{configuringIntent:v,setConfiguringIntent:x,drillHierarchies:m,onUpdateHierarchies:g,availableFields:c}),f.jsx(Kse,{configuringIntent:v,setConfiguringIntent:x,selectedDrillTargets:b,setSelectedDrillTargets:y,availableFields:c})]})})})}),f.jsxs(Sp,{className:"border-t-0",children:[f.jsx(_e,{variant:"outline",onClick:O,children:"Cancel"}),f.jsx(_e,{onClick:j,children:"Save Changes"})]})]})]}):null}function u$({frame:e}){var h;const t=oe(p=>p.isDashboardEditing),n=oe(p=>p.isVisualEditing),r=oe(p=>p.selectedSheetId),[o,i]=k.useState(!1),s=e.cards.find(p=>p.id===e.activeCardId),{removeFrame:a}=oe(p=>p.actions),l=oe(p=>p.actions.setIsVisualEditing),{handleEditVisual:c,card:u,data:d}=Mee(e);return f.jsx("section",{onMouseDown:p=>{p.stopPropagation()},className:"absolute right-2 top-2 z-50",children:f.jsxs("div",{className:"flex items-center gap-2",children:[t&&(s==null?void 0:s.config)&&f.jsx("button",{onClick:()=>i(!0),children:f.jsx(Ml,{className:"size-3.5 text-center text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})}),f.jsx(fae,{isOpen:o,onClose:()=>i(!1)}),t&&(n?f.jsx("button",{onClick:()=>{l(!n)},children:f.jsx(mZ,{className:"size-3.5 text-center text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})}):f.jsx("button",{role:"edit-visual",onClick:()=>c(),children:f.jsx(bZ,{className:"ml-1 size-3.5 text-center text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})})),t&&f.jsx("button",{onClick:()=>a(r,e.id),children:f.jsx(g4,{className:"size-3.5 text-center text-muted-foreground/70 hover:cursor-pointer hover:text-muted-foreground"})}),((h=u.preferences)==null?void 0:h.allowDownload)===!0&&f.jsx(UZ,{data:(d==null?void 0:d.records)||[],filename:u.title})]})})}const hae=k.createContext(null),Kx={didCatch:!1,error:null};class zp extends k.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Kx}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,o=arguments.length,i=new Array(o),s=0;s<o;s++)i[s]=arguments[s];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:i,reason:"imperative-api"}),this.setState(Kx)}}componentDidCatch(t,n){var r,o;(r=(o=this.props).onError)===null||r===void 0||r.call(o,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:o}=this.props;if(r&&n.error!==null&&pae(t.resetKeys,o)){var i,s;(i=(s=this.props).onReset)===null||i===void 0||i.call(s,{next:o,prev:t.resetKeys,reason:"keys"}),this.setState(Kx)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:o}=this.props,{didCatch:i,error:s}=this.state;let a=t;if(i){const l={error:s,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(l);else if(r)a=k.createElement(r,l);else if(o!==void 0)a=o;else throw s}return k.createElement(hae.Provider,{value:{didCatch:i,error:s,resetErrorBoundary:this.resetErrorBoundary}},a)}}function pae(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}function d$({customerFacingMessage:e,error:t,resetErrorBoundary:n}){return f.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center rounded-lg border border-dashed border-muted-foreground/25 bg-muted/30 p-6 text-center",children:[f.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:f.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),f.jsx("h3",{className:"mb-2 text-sm font-medium text-foreground",children:"Chart Unavailable"}),f.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:e||"Couldn't display this chart right now. Please try refreshing or check your data configuration."}),f.jsxs("button",{onClick:n,className:"inline-flex items-center justify-center rounded-md bg-primary px-3 py-2 text-xs font-medium text-primary-foreground shadow-sm transition-colors hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[f.jsx("svg",{className:"mr-1.5 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Try Again"]}),mb]})}function L_({error:e}){return f.jsx("div",{className:"flex flex-col items-center justify-center",role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",width:"100%"},children:f.jsxs("div",{style:{backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",boxShadow:"0 2px 6px rgba(0, 0, 0, 0.08)",color:"#b91c1c",fontFamily:"sans-serif",padding:"16px",textAlign:"center",flexDirection:"column",whiteSpace:"pre-wrap",position:"relative"},className:"flex flex-col justify-center space-y-1 rounded-md bg-muted p-10",children:[f.jsx("p",{className:"text-sm",children:"Something went wrong:"}),f.jsx("pre",{className:"text-xs",children:e.message})]})})}function mae({error:e,frame:t}){return f.jsxs("div",{className:"flex h-full flex-col items-center justify-center border",role:"alert",children:[f.jsx(u$,{frame:t}),f.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),f.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[f.jsx("p",{className:"text-lg font-semibold",children:"Oops! Looks like we tripped on a loose wire!"}),f.jsx("p",{className:"text-sm",children:"Something went wrong:"}),f.jsx("pre",{className:"text-xs",children:e.message})]})]})}function Dl(e,t="auto",n={}){switch(t==="auto"&&(t=vae(e,n)),t){case"number":return Uy(e,n);case"currency":return f$(e,n);case"percent":return gae(e,n);case"date":return bae(e,n);case"scientific":return yae(e,n);default:return String(e)}}function Uy(e,t={}){const{decimalPlaces:n=0,useSuffix:r=!1,prefix:o="",suffix:i="",locale:s="en-US",negativeInParentheses:a=!1}=t,l=e<0,c=Math.abs(e);let u=1,d="";if(r&&!i){const b=h$(c,s);u=b.divisor,d=b.suffix}const h=c/u;let p=s;try{new Intl.NumberFormat(s).format(0)}catch{p="en-US"}let g=new Intl.NumberFormat(p,{minimumFractionDigits:n,maximumFractionDigits:n}).format(h);return d&&(g+=d),i&&(g+=i),o&&(g=o+g),l&&(g=a?`(${g})`:`-${g}`),g}function f$(e,t={}){const{currency:n="USD",decimalPlaces:r=2,locale:o="en-US",useSuffix:i=!1,negativeInParentheses:s=!1}=t,a=e<0,l=Math.abs(e);let c=1,u="";if(i){const p=h$(l,o);c=p.divisor,u=p.suffix}const d=l/c;let h=o;try{new Intl.NumberFormat(o,{style:"currency",currency:n}).format(0)}catch{h="en-US"}try{let m=new Intl.NumberFormat(h,{style:"currency",currency:n,minimumFractionDigits:r,maximumFractionDigits:r}).format(d);return u&&(m+=u),a&&!m.includes("-")&&(m=s?`(${m})`:`-${m}`),m}catch{return`${n} ${Uy(e,{...t,prefix:""})}`}}function gae(e,t={}){const{decimalPlaces:n=1,multiplyBy:r=100}=t,o=e*r;return Uy(o,{...t,decimalPlaces:n,suffix:"%",useSuffix:!1})}function bae(e,t={}){const{locale:n="en-US"}=t;try{const r=new Date(e);return isNaN(r.getTime())?String(e):new Intl.DateTimeFormat(n,{dateStyle:"short"}).format(r)}catch{return String(e)}}function yae(e,t={}){const{decimalPlaces:n=2}=t;try{const r=Number(e);return isNaN(r)?String(e):r.toExponential(n)}catch{return String(e)}}function h$(e,t){return e>=1e9?{suffix:"B",divisor:1e9}:e>=1e7&&t==="en-IN"?{suffix:"Cr",divisor:1e7}:e>=1e6?{suffix:"M",divisor:1e6}:e>=1e5&&t==="en-IN"?{suffix:"L",divisor:1e5}:e>=1e3?{suffix:"K",divisor:1e3}:{suffix:"",divisor:1}}function vae(e,t){return t.currency?"currency":typeof e=="string"&&!isNaN(Date.parse(e))?"date":"number"}function xae(e,t={}){return n=>Dl(n,e,t)}function KC({number:e,decimalPlaces:t=0,useSuffix:n=!1,customSuffix:r="",currency:o="",locale:i="en-US"}){return o?f$(e,{currency:o,decimalPlaces:t,locale:i,useSuffix:n}):Uy(e,{decimalPlaces:t,useSuffix:n,suffix:r,locale:i})}function Gy(e){try{const n=new Function("getDatalabelColor",e)(H1);return{options:n==null?void 0:n.options,plugins:(n==null?void 0:n.plugins)||[]}}catch(t){return console.error("Error processing custom visual code",t),{options:{},plugins:[]}}}function wae(e){var t,n,r,o,i,s,a,l,c,u,d,h,p,m,g,b,y,v;return!e||((r=(n=(t=e==null?void 0:e.scales)==null?void 0:t.x)==null?void 0:n.grid)==null?void 0:r.display)===!0&&((s=(i=(o=e==null?void 0:e.scales)==null?void 0:o.y)==null?void 0:i.grid)==null?void 0:s.display)===!0?"xy":(c=(l=(a=e.scales)==null?void 0:a.x)==null?void 0:l.grid)!=null&&c.display?"x":(h=(d=(u=e.scales)==null?void 0:u.y)==null?void 0:d.grid)!=null&&h.display?"y":((g=(m=(p=e.scales)==null?void 0:p.x)==null?void 0:m.grid)==null?void 0:g.display)===!1&&((v=(y=(b=e.scales)==null?void 0:b.y)==null?void 0:y.grid)==null?void 0:v.display)===!1?"none":"xy"}function Cae(e){const t=getComputedStyle(document.documentElement).getPropertyValue(e);return p$(t)}function p$(e){const[t,n,r]=e.split(" "),o=parseFloat(t),i=parseFloat(n),s=parseFloat(r),a=i/100,l=s/100,c=(1-Math.abs(2*l-1))*a,u=c*(1-Math.abs(o/60%2-1)),d=l-c/2;let h=0,p=0,m=0;0<=o&&o<60?(h=c,p=u,m=0):60<=o&&o<120?(h=u,p=c,m=0):120<=o&&o<180?(h=0,p=c,m=u):180<=o&&o<240?(h=0,p=u,m=c):240<=o&&o<300?(h=u,p=0,m=c):300<=o&&o<360&&(h=c,p=0,m=u),h=Math.round((h+d)*255),p=Math.round((p+d)*255),m=Math.round((m+d)*255);const g=b=>{const y=b.toString(16);return y.length==1?"0"+y:y};return`#${g(h)}${g(p)}${g(m)}`}function Sae(e,t){return e.map(r=>Object.fromEntries(Object.entries(r).filter(([o])=>!t.some(i=>i.label===o))))}class Bp{formatAxis(t,n){var o;if(!t)return{};const r={display:t.enabled!==!1};return t.position&&t.position!=="auto"&&(r.position=t.position),t.name&&(r.title={display:t.name.enabled,text:t.name.text||""}),t.labels&&(r.ticks={display:t.labels.enabled!==!1},t.labels.rotation!==void 0&&t.labels.rotation!=="auto"&&(r.ticks.autoSkip=!1,r.ticks.maxRotation=t.labels.rotation,r.ticks.minRotation=t.labels.rotation)),n==="value"&&((o=t.formatOptions)!=null&&o.type)&&t.formatOptions.type!=="auto"&&(r.ticks||(r.ticks={}),r.ticks.callback=this.getFormatter(t.formatOptions.type,t.formatOptions)),n==="value"&&t.scale&&(t.scale.min!=="auto"&&t.scale.min!==void 0&&(r.min=t.scale.min),t.scale.max!=="auto"&&t.scale.max!==void 0&&(r.max=t.scale.max),t.scale.stepSize!=="auto"&&t.scale.stepSize!==void 0&&(r.ticks||(r.ticks={}),r.ticks.stepSize=t.scale.stepSize)),r}getFormatter(t,n){if(!(!t||t==="auto"))return xae(t,n||{})}}class nf extends Bp{getAxisInfo(t){var r;return((r=t==null?void 0:t.chartOptions)==null?void 0:r.indexAxis)==="y"?{hasXAxis:!0,hasYAxis:!0,xAxisType:"value",yAxisType:"category",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}:{hasXAxis:!0,hasYAxis:!0,xAxisType:"category",yAxisType:"value",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}}applyConfig(t,n){var o,i,s,a,l;return((o=n==null?void 0:n.chartOptions)==null?void 0:o.indexAxis)==="y"?{...t,scales:{...t.scales,x:{...(i=t.scales)==null?void 0:i.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"value")},y:{...(s=t.scales)==null?void 0:s.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"category")}}}:{...t,scales:{...t.scales,x:{...(a=t.scales)==null?void 0:a.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"category")},y:{...(l=t.scales)==null?void 0:l.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"value")}}}}}class rf extends Bp{getAxisInfo(t){var r;return((r=t==null?void 0:t.chartOptions)==null?void 0:r.indexAxis)==="y"?{hasXAxis:!0,hasYAxis:!0,xAxisType:"value",yAxisType:"category",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}:{hasXAxis:!0,hasYAxis:!0,xAxisType:"category",yAxisType:"value",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}}applyConfig(t,n){var o,i,s,a,l;return((o=n==null?void 0:n.chartOptions)==null?void 0:o.indexAxis)==="y"?{...t,scales:{...t.scales,x:{...(i=t.scales)==null?void 0:i.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"value")},y:{...(s=t.scales)==null?void 0:s.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"category")}}}:{...t,scales:{...t.scales,x:{...(a=t.scales)==null?void 0:a.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"category")},y:{...(l=t.scales)==null?void 0:l.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"value")}}}}}class UM extends Bp{getAxisInfo(t){var r;return((r=t==null?void 0:t.chartOptions)==null?void 0:r.indexAxis)==="y"?{hasXAxis:!0,hasYAxis:!0,xAxisType:"value",yAxisType:"category",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}:{hasXAxis:!0,hasYAxis:!0,xAxisType:"category",yAxisType:"value",xAxisLabel:"X-Axis",yAxisLabel:"Y-Axis"}}applyConfig(t,n){var o,i,s,a,l;return((o=n==null?void 0:n.chartOptions)==null?void 0:o.indexAxis)==="y"?{...t,scales:{...t.scales,x:{...(i=t.scales)==null?void 0:i.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"value")},y:{...(s=t.scales)==null?void 0:s.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"category")}}}:{...t,scales:{...t.scales,x:{...(a=t.scales)==null?void 0:a.x,...this.formatAxis(n==null?void 0:n.xAxisConfig,"category")},y:{...(l=t.scales)==null?void 0:l.y,...this.formatAxis(n==null?void 0:n.yAxisConfig,"value")}}}}}class Xx extends Bp{getAxisInfo(){return{hasXAxis:!1,hasYAxis:!1,message:"Pie and doughnut charts do not have axes"}}applyConfig(t){return t}}class Eae extends Bp{getAxisInfo(){return{hasXAxis:!1,hasYAxis:!1,message:"Radar charts use a radial axis system"}}applyConfig(t,n){var r;return n!=null&&n.yAxisConfig?{...t,scales:{...t.scales,r:{...(r=t.scales)==null?void 0:r.r,...this.formatAxis(n.yAxisConfig,"value")}}}:t}}class $_{static getAxisInfo(t,n){return(this.handlers.get(t)||new nf).getAxisInfo(n)}static applyAxisConfig(t,n,r){return!(r!=null&&r.xAxisConfig)&&!(r!=null&&r.yAxisConfig)?t:(this.handlers.get(n)||new nf).applyConfig(t,r)}}we($_,"handlers",new Map([["bar",new rf],["horizontalBar",new rf],["line",new UM],["stackedBar",new rf],["stackedLine",new UM],["pie",new Xx],["doughnut",new Xx],["polarArea",new Xx],["radar",new Eae],["bubble",new nf],["scatter",new nf],["funnel",new nf],["tornado",new rf],["pyramid",new rf]]));function _ae(e,t){var r;if(!t)return e;const n={};return t.display!==void 0&&(n.display=t.display),t.position&&(n.position=t.position),t.align&&(n.align=t.align),{...e,plugins:{...e.plugins,legend:{...(r=e.plugins)==null?void 0:r.legend,...n}}}}function kae(e){return!["kpi","metric","text","table","pivotTable"].includes(e)}function Rae(e,t=!1,n=!1){switch(e){case"bar":case"range":return t?{anchor:"end",align:"right"}:{anchor:"end",align:"top"};case"horizontalBar":return{anchor:"end",align:"right"};case"line":case"radar":return t?{anchor:"end",align:"right"}:{anchor:"end",align:"top"};case"pie":case"doughnut":case"polarArea":case"funnel":return{anchor:"center",align:"center"};case"stackedBar":case"stackedLine":return n?t?{anchor:"end",align:"right"}:{anchor:"end",align:"top"}:{anchor:"center",align:"center"};default:return{anchor:"center",align:"center"}}}function GM(e,t,n,r){return function(o){var i,s;if(o==null)return"";if(r==="range"&&Array.isArray(o)){const a=(e==null?void 0:e.formatOptions)||(t==null?void 0:t.formatOptions)||{},l=(e==null?void 0:e.format)==="auto"?(i=t==null?void 0:t.formatOptions)==null?void 0:i.type:e==null?void 0:e.format;return o.slice(0,2).map(u=>l&&l!=="auto"&&l!=="none"?Dl(Number(u),l,a):u).join(" - ")}return(e==null?void 0:e.format)==="none"?o:!(e!=null&&e.format)||e.format==="auto"?(s=t==null?void 0:t.formatOptions)!=null&&s.type&&t.formatOptions.type!=="auto"?Dl(Number(o),t.formatOptions.type,t.formatOptions||{}):n?n(o):o:Dl(Number(o),e.format,e.formatOptions||{})}}function Um(e,t,n,r,o){if(e!=null&&e.color&&e.color!=="auto")return e.color;const i=n==="end"&&r==="top"||n==="end"&&r==="right",s=n==="start"&&r==="bottom",a=n==="start"&&r==="left";if(i){const l=da();return vs(l)}if(s||a){const l=da();return vs(l)}return l=>{var u,d,h;const c=((d=(u=l.dataset)==null?void 0:u.backgroundColor)==null?void 0:d[l.dataIndex])||((h=l.dataset)==null?void 0:h.backgroundColor)||t||da();return vs(c)}}function z_(e,t,n,r){var y,v,x,S,_,E,C,R,M,N,D,A;const o=(v=(y=n==null?void 0:n.chartOptions)==null?void 0:y.plugins)==null?void 0:v.datalabels,i=(o==null?void 0:o.display)!==!1&&((o==null?void 0:o.anchor)||(o==null?void 0:o.align));if((t==null?void 0:t.enabled)===!1)return{...e,plugins:{...e.plugins,datalabels:{display:!1}}};if(!t&&i)return e;if(!t)return{...e,plugins:{...e.plugins,datalabels:{display:!1}}};const s=r||e.type||"bar",a=((S=(x=e.scales)==null?void 0:x.x)==null?void 0:S.stacked)===!0||((E=(_=e.scales)==null?void 0:_.y)==null?void 0:E.stacked)===!0,l=((C=n==null?void 0:n.chartOptions)==null?void 0:C.indexAxis)==="y",c=l?n==null?void 0:n.xAxisConfig:n==null?void 0:n.yAxisConfig,u=Rae(s,l,t.showTotal),d=a&&!t.showTotal?"center":t.anchor||u.anchor,h=a&&!t.showTotal?"center":t.align||u.align;let p=d,m=h;const g=s==="pie"||s==="doughnut"||s==="polarArea"||s==="funnel";a&&!t.showTotal&&(p="center",m="center");const b={display:t.display!==!1,anchor:p,align:m,clamp:t.clamp??!0,clip:t.clip??!1,formatter:GM(t,c,(M=(R=e.plugins)==null?void 0:R.datalabels)==null?void 0:M.formatter,s),color:Um(t,void 0,p,m),font:{size:((N=t.font)==null?void 0:N.size)||12,weight:((D=t.font)==null?void 0:D.weight)||"normal"},rotation:t.rotation||0,offset:0};if(g&&s!=="funnel"&&(delete b.anchor,delete b.align,Object.assign(b,{anchor:"center",align:"center",offset:0,clamp:!0,clip:!1,display:function(j){if(t.display===!1)return!1;const O=j.dataset.data[j.dataIndex],I=j.dataset.data.reduce((F,B)=>F+B,0);return O/I*100>5}})),s==="funnel"&&t.enabled&&(Object.assign(b,{anchor:function(j){return j.dataset.data[j.dataIndex]<.02?"end":"start"},align:function(j){return j.dataset.data[j.dataIndex]<.02?"end":"center"},textAlign:"center",offset:0,clamp:!0,clip:!1}),b.font||(b.font={}),b.font.size=b.font.size||14),a&&t.showTotal&&(b.display=function(j){const O=j.chart.data.datasets.length;return j.datasetIndex===O-1},b.formatter=function(j,O){var B,z;let I=0;const L=O.dataIndex;return O.chart.data.datasets.forEach(T=>{const H=T.data[L];H&&!isNaN(H)&&(I+=Number(H))}),GM(t,c,(z=(B=e.plugins)==null?void 0:B.datalabels)==null?void 0:z.formatter,s)(I)},b.anchor="end",b.align=l?"right":"top",b.color=Um(t,void 0,"end",l?"right":"top")),!a&&!g&&t.position&&t.position!=="auto"&&t.position!=="custom"){if(l)switch(t.position){case"left":b.anchor="start",b.align="left";break;case"right":b.anchor="end",b.align="right";break;case"center":b.anchor="center",b.align="center";break;case"top":case"bottom":b.anchor="center",b.align="center";break}else switch(t.position){case"top":b.anchor="end",b.align="top";break;case"bottom":b.anchor="start",b.align="bottom";break;case"center":b.anchor="center",b.align="center";break;case"left":case"right":b.anchor="center",b.align="center";break}b.color=Um(t,void 0,b.anchor,b.align)}else t.position==="custom"&&(b.color=Um(t,void 0,b.anchor,b.align));return g||s==="funnel"?{...e,plugins:{...e.plugins,datalabels:b}}:{...e,plugins:{...e.plugins,datalabels:{...(A=e.plugins)==null?void 0:A.datalabels,...b}}}}function Nae(e){return!["kpi","metric","text","table","pivotTable","custom"].includes(e)}function Aae(e){return e.length===1?[e[0]]:e.slice(1).filter(n=>!EO.includes(n))}function Hc({data:e,cfg:t,customCfg:n,preferences:r,cardType:o,card:i}){var S;const s=o==="radar"?.2:1,{keys:a}=gn(e),l=Aae(a);let c="none";o=="bar"?c="bar":o=="line"&&(c="line");const u=a==null?void 0:a[0],d=xp(e,u),p=Y4(l,e,r,s,c,u,o==="stackedBar"||o==="stackedLine"),m=Pl(p,n),{options:g,plugins:b}=Vf({cardType:o,cfg:t,preferences:r,customCfg:n}),y=(S=i.interactionConfig)==null?void 0:S.clickFilterInteractions,v=function(_,E){var R;const C=((R=_.native)==null?void 0:R.target)||_.target;E.length?C.style.cursor="pointer":C.style.cursor="default"};return{type:(n==null?void 0:n.type)||(t==null?void 0:t.type)||"bar",data:{labels:d,datasets:m},options:{...g,onHover:y?v:void 0},plugins:b}}function Mae(e,t){var o,i,s;const n=((o=t==null?void 0:t.options)==null?void 0:o.indexAxis)==="y"?"x":"y";return(i=e==null?void 0:e.chartOptions)!=null&&i.indexAxis?((s=e==null?void 0:e.chartOptions)==null?void 0:s.indexAxis)==="x"?"y":"x":n}function Pae(e){var n,r;return(n=e==null?void 0:e.chartOptions)!=null&&n.indexAxis?((r=e==null?void 0:e.chartOptions)==null?void 0:r.indexAxis)==="x"?"x":"y":"x"}function m$(e,t){var s,a,l,c,u,d,h,p,m,g,b,y;const n=Mae(t,e),r=Pae(t);return(t==null?void 0:t.xAxisConfig)||(t==null?void 0:t.yAxisConfig)?(e==null?void 0:e.options)||{}:{...e==null?void 0:e.options,scales:{...(s=e==null?void 0:e.options)==null?void 0:s.scales,[n]:{...(l=(a=e==null?void 0:e.options)==null?void 0:a.scales)==null?void 0:l[n],ticks:{...(d=(u=(c=e==null?void 0:e.options)==null?void 0:c.scales)==null?void 0:u[n])==null?void 0:d.ticks,callback:v=>{var x,S,_,E;return KC({number:Number(v),decimalPlaces:((x=t==null?void 0:t.numberAxisFormat)==null?void 0:x.decimalPlaces)||0,useSuffix:!!((S=t==null?void 0:t.numberAxisFormat)!=null&&S.suffix),customSuffix:"",locale:((_=t==null?void 0:t.numberAxisFormat)==null?void 0:_.locale)||"",currency:((E=t==null?void 0:t.numberAxisFormat)==null?void 0:E.currency)||""})}}},[r]:{...(m=(p=(h=e==null?void 0:e.options)==null?void 0:h.scales)==null?void 0:p[r])==null?void 0:m.ticks,callback:null}},plugins:{...(g=e==null?void 0:e.options)==null?void 0:g.plugins,datalabels:{...(y=(b=e==null?void 0:e.options)==null?void 0:b.plugins)==null?void 0:y.datalabels,formatter:function(v){var x,S,_,E;return KC({number:Number(v),decimalPlaces:((x=t==null?void 0:t.numberAxisFormat)==null?void 0:x.decimalPlaces)||0,useSuffix:!!((S=t==null?void 0:t.numberAxisFormat)!=null&&S.suffix),customSuffix:"",locale:((_=t==null?void 0:t.numberAxisFormat)==null?void 0:_.locale)||"",currency:((E=t==null?void 0:t.numberAxisFormat)==null?void 0:E.currency)||""})}}}}}function Vf({cardType:e,cfg:t,preferences:n,customCfg:r}){var m,g,b,y,v,x,S,_,E,C,R,M,N,D,A,j,O,I,L,F,B,z,T,H,V,P,W,$,q,U,G;const o=oe.getState().themeStyle,i=m$(t,n),s=Hn((t==null?void 0:t.options)||{},n==null?void 0:n.chartOptions),a=Hn(i,s),l=Hn(a,(r==null?void 0:r.options)||{}),c=Dae(e,n,l),u={...l,scales:{...l==null?void 0:l.scales,x:{...(m=l==null?void 0:l.scales)==null?void 0:m.x,grid:{...(b=(g=l==null?void 0:l.scales)==null?void 0:g.x)==null?void 0:b.grid,color:(_=(S=(x=(v=(y=o==null?void 0:o.chart)==null?void 0:y.options)==null?void 0:v.scales)==null?void 0:x.x)==null?void 0:S.grid)==null?void 0:_.color}},y:{...(E=l==null?void 0:l.scales)==null?void 0:E.y,grid:{...(R=(C=l==null?void 0:l.scales)==null?void 0:C.y)==null?void 0:R.grid,color:(j=(A=(D=(N=(M=o==null?void 0:o.chart)==null?void 0:M.options)==null?void 0:N.scales)==null?void 0:D.y)==null?void 0:A.grid)==null?void 0:j.color}}},plugins:{...l==null?void 0:l.plugins,tooltip:{filter:function(Y){return Y.raw!==void 0&&Y.raw!==0},callbacks:c,...(O=l==null?void 0:l.plugins)==null?void 0:O.tooltip,backgroundColor:(B=(F=(L=(I=o==null?void 0:o.chart)==null?void 0:I.options)==null?void 0:L.plugins)==null?void 0:F.tooltip)==null?void 0:B.backgroundColor,bodyColor:(V=(H=(T=(z=o==null?void 0:o.chart)==null?void 0:z.options)==null?void 0:T.plugins)==null?void 0:H.tooltip)==null?void 0:V.bodyColor,titleColor:(q=($=(W=(P=o==null?void 0:o.chart)==null?void 0:P.options)==null?void 0:W.plugins)==null?void 0:$.tooltip)==null?void 0:q.titleColor}}},{plugins:d,options:h}=Gy((n==null?void 0:n.customVisualCode)||"");let p=$_.applyAxisConfig(u,e||"bar",n);return p=_ae(p,(G=(U=n==null?void 0:n.chartOptions)==null?void 0:U.plugins)==null?void 0:G.legend),p=z_(p,n==null?void 0:n.dataLabelsConfig,n,e),p=Hn(p,h),{options:p,plugins:d}}function Dae(e,t,n){var s,a,l;if(e==="map")return{};const o=((s=t==null?void 0:t.chartOptions)==null?void 0:s.indexAxis)==="y"?t==null?void 0:t.xAxisConfig:t==null?void 0:t.yAxisConfig,i=c=>{var u,d,h,p,m;return(u=o==null?void 0:o.formatOptions)!=null&&u.type&&o.formatOptions.type!=="auto"?Dl(c,o.formatOptions.type,o.formatOptions||{}):KC({number:c,decimalPlaces:((d=t==null?void 0:t.numberAxisFormat)==null?void 0:d.decimalPlaces)||0,useSuffix:!!((h=t==null?void 0:t.numberAxisFormat)!=null&&h.suffix),customSuffix:"",locale:((p=t==null?void 0:t.numberAxisFormat)==null?void 0:p.locale)||"",currency:((m=t==null?void 0:t.numberAxisFormat)==null?void 0:m.currency)||""})};return{title:function(c){var d;const u=((d=c==null?void 0:c[0])==null?void 0:d.label)||"";if(c.length>1&&["stackedBar","stackedLine"].includes(e||"")){const h=c.reduce((m,g)=>{const b=g.raw;return b!==void 0&&b!==0?m+b:m},0),p=i(h);return`${u} (${p})`}return u},label:function(c){var p;const u=((p=c==null?void 0:c.dataset)==null?void 0:p.label)||"",d=c==null?void 0:c.raw;if(d===void 0||d===0)return;const h=i(Number(d));return`${u}: ${h}`},...((l=(a=n==null?void 0:n.plugins)==null?void 0:a.tooltip)==null?void 0:l.callbacks)||{}}}/*!
496
496
  * @kurkle/color v0.3.4
497
497
  * https://github.com/kurkle/color#readme
498
498
  * (c) 2024 Jukka Kurkela