react-semaphor 0.1.66 → 0.1.67

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.
@@ -942,7 +942,7 @@ Defaulting to \`null\`.`}const oY=nY,hMe=cMe,UT=E.forwardRef(({className:e,value
942
942
  font-size: .6rem;
943
943
  font-weight: bold;
944
944
  color: hsl(${Math.max(0,Math.min(120-120*g,120))}deg 100% 31%);`,n==null?void 0:n.key)}return(l=n==null?void 0:n.onChange)==null||l.call(n,s),s}}function vN(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const jIe=(e,t)=>Math.abs(e-t)<1,kIe=(e,t,n)=>{let r;return function(...s){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,s),n)}},EIe=e=>e,_Ie=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let s=t;s<=n;s++)r.push(s);return r},DIe=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const s=i=>{const{width:a,height:l}=i;t({width:Math.round(a),height:Math.round(l)})};if(s(n.getBoundingClientRect()),!r.ResizeObserver)return()=>{};const o=new r.ResizeObserver(i=>{const a=()=>{const l=i[0];if(l!=null&&l.borderBoxSize){const u=l.borderBoxSize[0];if(u){s({width:u.inlineSize,height:u.blockSize});return}}s(n.getBoundingClientRect())};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return o.observe(n,{box:"border-box"}),()=>{o.unobserve(n)}},rF={passive:!0},sF=typeof window>"u"?!0:"onscrollend"in window,TIe=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let s=0;const o=e.options.useScrollendEvent&&sF?()=>{}:kIe(r,()=>{t(s,!1)},e.options.isScrollingResetDelay),i=d=>()=>{const{horizontal:f,isRtl:h}=e.options;s=f?n.scrollLeft*(h&&-1||1):n.scrollTop,o(),t(s,d)},a=i(!0),l=i(!1);l(),n.addEventListener("scroll",a,rF);const u=e.options.useScrollendEvent&&sF;return u&&n.addEventListener("scrollend",l,rF),()=>{n.removeEventListener("scroll",a),u&&n.removeEventListener("scrollend",l)}},RIe=(e,t,n)=>{if(t!=null&&t.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return Math.round(e.getBoundingClientRect()[n.options.horizontal?"width":"height"])},MIe=(e,{adjustments:t=0,behavior:n},r)=>{var s,o;const i=e+t;(o=(s=r.scrollElement)==null?void 0:s.scrollTo)==null||o.call(s,{[r.options.horizontal?"left":"top"]:i,behavior:n})};class IIe{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollToIndexTimeoutId=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(s=>{s.forEach(o=>{const i=()=>{this._measureElement(o.target,o)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var s;(s=r())==null||s.disconnect(),n=null},observe:s=>{var o;return(o=r())==null?void 0:o.observe(s,{box:"border-box"})},unobserve:s=>{var o;return(o=r())==null?void 0:o.unobserve(s)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,s])=>{typeof s>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:EIe,rangeExtractor:_Ie,onChange:()=>{},measureElement:RIe,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!0,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,s;(s=(r=this.options).onChange)==null||s.call(r,this,n)},this.maybeNotify=Yd(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(s=>{this.observer.observe(s)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,o)=>{this.scrollAdjustments=0,this.scrollDirection=o?this.getScrollOffset()<s?"forward":"backward":null,this.scrollOffset=s,this.isScrolling=o,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const s=new Map,o=new Map;for(let i=r-1;i>=0;i--){const a=n[i];if(s.has(a.lane))continue;const l=o.get(a.lane);if(l==null||a.end>l.end?o.set(a.lane,a):a.end<l.end&&s.set(a.lane,!0),s.size===this.options.lanes)break}return o.size===this.options.lanes?Array.from(o.values()).sort((i,a)=>i.end===a.end?i.index-a.index:i.end-a.end)[0]:void 0},this.getMeasurementOptions=Yd(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(n,r,s,o,i)=>(this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:s,getItemKey:o,enabled:i}),{key:!1}),this.getMeasurements=Yd(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:s,getItemKey:o,enabled:i},a)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(d=>{this.itemSizeCache.set(d.key,d.size)}));const l=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const u=this.measurementsCache.slice(0,l);for(let d=l;d<n;d++){const f=o(d),h=this.options.lanes===1?u[d-1]:this.getFurthestMeasurement(u,d),p=h?h.end+this.options.gap:r+s,m=a.get(f),g=typeof m=="number"?m:this.options.estimateSize(d),b=p+g,x=h?h.lane:d%this.options.lanes;u[d]={index:d,start:p,size:g,end:b,key:f,lane:x}}return this.measurementsCache=u,u},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=Yd(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,s,o)=>this.range=n.length>0&&r>0?AIe({measurements:n,outerSize:r,scrollOffset:s,lanes:o}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=Yd(()=>{let n=null,r=null;const s=this.calculateRange();return s&&(n=s.startIndex,r=s.endIndex),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,s,o,i)=>o===null||i===null?[]:n({startIndex:o,endIndex:i,overscan:r,count:s}),{key:process.env.NODE_ENV!=="production"&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,s=n.getAttribute(r);return s?parseInt(s,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(n,r)=>{const s=this.indexFromElement(n),o=this.measurementsCache[s];if(!o)return;const i=o.key,a=this.elementsCache.get(i);a!==n&&(a&&this.observer.unobserve(a),this.observer.observe(n),this.elementsCache.set(i,n)),n.isConnected&&this.resizeItem(s,this.options.measureElement(n,r,this))},this.resizeItem=(n,r)=>{const s=this.measurementsCache[n];if(!s)return;const o=this.itemSizeCache.get(s.key)??s.size,i=r-o;i!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(s,i,this):s.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",i),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=i,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(s.index),this.itemSizeCache=new Map(this.itemSizeCache.set(s.key,r)),this.notify(!1))},this.measureElement=n=>{if(!n){this.elementsCache.forEach((r,s)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(s))});return}this._measureElement(n,void 0)},this.getVirtualItems=Yd(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const s=[];for(let o=0,i=n.length;o<i;o++){const a=n[o],l=r[a];s.push(l)}return s},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return vN(r[IY(0,r.length-1,s=>vN(r[s]).start,n)])},this.getOffsetForAlignment=(n,r,s=0)=>{const o=this.getSize(),i=this.getScrollOffset();r==="auto"&&(r=n>=i+o?"end":"start"),r==="center"?n+=(s-o)/2:r==="end"&&(n-=o);const a=this.options.horizontal?"scrollWidth":"scrollHeight",u=(this.scrollElement?"document"in this.scrollElement?this.scrollElement.document.documentElement[a]:this.scrollElement[a]:0)-o;return Math.max(Math.min(u,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const s=this.measurementsCache[n];if(!s)return;const o=this.getSize(),i=this.getScrollOffset();if(r==="auto")if(s.end>=i+o-this.options.scrollPaddingEnd)r="end";else if(s.start<=i+this.options.scrollPaddingStart)r="start";else return[i,r];const a=r==="end"?s.end+this.options.scrollPaddingEnd:s.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,r,s.size),r]},this.isDynamicMode=()=>this.elementsCache.size>0,this.cancelScrollToIndex=()=>{this.scrollToIndexTimeoutId!==null&&this.targetWindow&&(this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId),this.scrollToIndexTimeoutId=null)},this.scrollToOffset=(n,{align:r="start",behavior:s}={})=>{this.cancelScrollToIndex(),s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(n,r),{adjustments:void 0,behavior:s})},this.scrollToIndex=(n,{align:r="auto",behavior:s}={})=>{n=Math.max(0,Math.min(n,this.options.count-1)),this.cancelScrollToIndex(),s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");const o=this.getOffsetForIndex(n,r);if(!o)return;const[i,a]=o;this._scrollToOffset(i,{adjustments:void 0,behavior:s}),s!=="smooth"&&this.isDynamicMode()&&this.targetWindow&&(this.scrollToIndexTimeoutId=this.targetWindow.setTimeout(()=>{if(this.scrollToIndexTimeoutId=null,this.elementsCache.has(this.options.getItemKey(n))){const[u]=vN(this.getOffsetForIndex(n,a));jIe(u,this.getScrollOffset())||this.scrollToIndex(n,{align:a,behavior:s})}else this.scrollToIndex(n,{align:a,behavior:s})}))},this.scrollBy=(n,{behavior:r}={})=>{this.cancelScrollToIndex(),r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+n,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let s;return r.length===0?s=this.options.paddingStart:s=this.options.lanes===1?((n=r[r.length-1])==null?void 0:n.end)??0:Math.max(...r.slice(-this.options.lanes).map(o=>o.end)),Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:s})=>{this.options.scrollToFn(n,{behavior:s,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(t)}}const IY=(e,t,n,r)=>{for(;e<=t;){const s=(e+t)/2|0,o=n(s);if(o<r)e=s+1;else if(o>r)t=s-1;else return s}return e>0?e-1:0};function AIe({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const s=e.length-1;let i=IY(0,s,l=>e[l].start,n),a=i;for(;a<s&&e[a].end<n+t;)a++;return r>1&&(i=Math.max(0,i-i%r),a=Math.min(s,a+(r-1-a%r))),{startIndex:i,endIndex:a}}const oF=typeof document<"u"?E.useLayoutEffect:E.useEffect;function PIe(e){const t=E.useReducer(()=>({}),{})[1],n={...e,onChange:(s,o)=>{var i;o?_n.flushSync(t):t(),(i=e.onChange)==null||i.call(e,s,o)}},[r]=E.useState(()=>new IIe(n));return r.setOptions(n),oF(()=>r._didMount(),[]),oF(()=>r._willUpdate()),r}function OIe(e){return PIe({observeElementRect:DIe,observeElementOffset:TIe,scrollToFn:MIe,...e})}function FIe(e,t){return e!==null&&t!==null&&typeof e=="object"&&typeof t=="object"&&"id"in e&&"id"in t?e.id===t.id:e===t}function $Ie(e=FIe){return C.useCallback((t,n)=>{if(typeof e=="string"){let r=e;return(t==null?void 0:t[r])===(n==null?void 0:n[r])}return e(t,n)},[e])}function LIe(e){if(e===null)return{width:0,height:0};let{width:t,height:n}=e.getBoundingClientRect();return{width:t,height:n}}function iF(e,t=!1){let[n,r]=C.useReducer(()=>({}),{}),s=C.useMemo(()=>LIe(e),[e,n]);return Yn(()=>{if(!e)return;let o=new ResizeObserver(r);return o.observe(e),()=>{o.disconnect()}},[e]),t?{width:`${s.width}px`,height:`${s.height}px`}:s}let zIe=class extends Map{constructor(t){super(),this.factory=t}get(t){let n=super.get(t);return n===void 0&&(n=this.factory(t),this.set(t,n)),n}};function AY(e,t){let n=e(),r=new Set;return{getSnapshot(){return n},subscribe(s){return r.add(s),()=>r.delete(s)},dispatch(s,...o){let i=t[s].call(n,...o);i&&(n=i,r.forEach(a=>a()))}}}function PY(e){return C.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}let BIe=new zIe(()=>AY(()=>[],{ADD(e){return this.includes(e)?this:[...this,e]},REMOVE(e){let t=this.indexOf(e);if(t===-1)return this;let n=this.slice();return n.splice(t,1),n}}));function XT(e,t){let n=BIe.get(t),r=C.useId(),s=PY(n);if(Yn(()=>{if(e)return n.dispatch("ADD",r),()=>n.dispatch("REMOVE",r)},[n,e]),!e)return!1;let o=s.indexOf(r),i=s.length;return o===-1&&(o=i,i+=1),o===i-1}let Dk=new Map,Mm=new Map;function aF(e){var t;let n=(t=Mm.get(e))!=null?t:0;return Mm.set(e,n+1),n!==0?()=>lF(e):(Dk.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>lF(e))}function lF(e){var t;let n=(t=Mm.get(e))!=null?t:1;if(n===1?Mm.delete(e):Mm.set(e,n-1),n!==1)return;let r=Dk.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,Dk.delete(e))}function VIe(e,{allowed:t,disallowed:n}={}){let r=XT(e,"inert-others");Yn(()=>{var s,o;if(!r)return;let i=sa();for(let l of(s=n==null?void 0:n())!=null?s:[])l&&i.add(aF(l));let a=(o=t==null?void 0:t())!=null?o:[];for(let l of a){if(!l)continue;let u=Bb(l);if(!u)continue;let d=l.parentElement;for(;d&&d!==u.body;){for(let f of d.children)a.some(h=>f.contains(h))||i.add(aF(f));d=d.parentElement}}return i.dispose},[r,t,n])}function HIe(e,t,n){let r=_d(s=>{let o=s.getBoundingClientRect();o.x===0&&o.y===0&&o.width===0&&o.height===0&&n()});C.useEffect(()=>{if(!e)return;let s=t===null?null:t instanceof HTMLElement?t:t.current;if(!s)return;let o=sa();if(typeof ResizeObserver<"u"){let i=new ResizeObserver(()=>r.current(s));i.observe(s),o.add(()=>i.disconnect())}if(typeof IntersectionObserver<"u"){let i=new IntersectionObserver(()=>r.current(s));i.observe(s),o.add(()=>i.disconnect())}return()=>o.dispose()},[t,r,e])}let Tk=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var UIe=(e=>(e[e.First=1]="First",e[e.Previous=2]="Previous",e[e.Next=4]="Next",e[e.Last=8]="Last",e[e.WrapAround=16]="WrapAround",e[e.NoScroll=32]="NoScroll",e[e.AutoFocus=64]="AutoFocus",e))(UIe||{}),WIe=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(WIe||{}),qIe=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(qIe||{}),OY=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(OY||{});function YIe(e,t=0){var n;return e===((n=Bb(e))==null?void 0:n.body)?!1:Ya(t,{0(){return e.matches(Tk)},1(){let r=e;for(;r!==null;){if(r.matches(Tk))return!0;r=r.parentElement}return!1}})}var GIe=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(GIe||{});typeof window<"u"&&typeof document<"u"&&(document.addEventListener("keydown",e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",e=>{e.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:e.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));function ZIe(e,t=n=>n){return e.slice().sort((n,r)=>{let s=t(n),o=t(r);if(s===null||o===null)return 0;let i=s.compareDocumentPosition(o);return i&Node.DOCUMENT_POSITION_FOLLOWING?-1:i&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function FY(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function KIe(){return/Android/gi.test(window.navigator.userAgent)}function $Y(){return FY()||KIe()}function Tp(e,t,n,r){let s=_d(n);C.useEffect(()=>{if(!e)return;function o(i){s.current(i)}return document.addEventListener(t,o,r),()=>document.removeEventListener(t,o,r)},[e,t,r])}function XIe(e,t,n,r){let s=_d(n);C.useEffect(()=>{if(!e)return;function o(i){s.current(i)}return window.addEventListener(t,o,r),()=>window.removeEventListener(t,o,r)},[e,t,r])}const cF=30;function QIe(e,t,n){let r=XT(e,"outside-click"),s=_d(n),o=C.useCallback(function(l,u){if(l.defaultPrevented)return;let d=u(l);if(d===null||!d.getRootNode().contains(d)||!d.isConnected)return;let f=function h(p){return typeof p=="function"?h(p()):Array.isArray(p)||p instanceof Set?p:[p]}(t);for(let h of f)if(h!==null&&(h.contains(d)||l.composed&&l.composedPath().includes(h)))return;return!YIe(d,OY.Loose)&&d.tabIndex!==-1&&l.preventDefault(),s.current(l,d)},[s,t]),i=C.useRef(null);Tp(r,"pointerdown",l=>{var u,d;i.current=((d=(u=l.composedPath)==null?void 0:u.call(l))==null?void 0:d[0])||l.target},!0),Tp(r,"mousedown",l=>{var u,d;i.current=((d=(u=l.composedPath)==null?void 0:u.call(l))==null?void 0:d[0])||l.target},!0),Tp(r,"click",l=>{$Y()||i.current&&(o(l,()=>i.current),i.current=null)},!0);let a=C.useRef({x:0,y:0});Tp(r,"touchstart",l=>{a.current.x=l.touches[0].clientX,a.current.y=l.touches[0].clientY},!0),Tp(r,"touchend",l=>{let u={x:l.changedTouches[0].clientX,y:l.changedTouches[0].clientY};if(!(Math.abs(u.x-a.current.x)>=cF||Math.abs(u.y-a.current.y)>=cF))return o(l,()=>l.target instanceof HTMLElement?l.target:null)},!0),XIe(r,"blur",l=>o(l,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}function F1(...e){return C.useMemo(()=>Bb(...e),[...e])}function JIe(e,t,n,r){let s=_d(n);C.useEffect(()=>{e=e??window;function o(i){s.current(i)}return e.addEventListener(t,o,r),()=>e.removeEventListener(t,o,r)},[e,t,r])}function LY(e){let t=C.useRef({value:"",selectionStart:null,selectionEnd:null});return JIe(e,"blur",n=>{let r=n.target;r instanceof HTMLInputElement&&(t.current={value:r.value,selectionStart:r.selectionStart,selectionEnd:r.selectionEnd})}),wt(()=>{if(document.activeElement!==e&&e instanceof HTMLInputElement&&e.isConnected){if(e.focus({preventScroll:!0}),e.value!==t.current.value)e.setSelectionRange(e.value.length,e.value.length);else{let{selectionStart:n,selectionEnd:r}=t.current;n!==null&&r!==null&&e.setSelectionRange(n,r)}t.current={value:"",selectionStart:null,selectionEnd:null}}})}function eAe(e,t){return C.useMemo(()=>{var n;if(e.type)return e.type;let r=(n=e.as)!=null?n:"button";if(typeof r=="string"&&r.toLowerCase()==="button"||(t==null?void 0:t.tagName)==="BUTTON"&&!t.hasAttribute("type"))return"button"},[e.type,e.as,t])}function tAe(){let e;return{before({doc:t}){var n;let r=t.documentElement,s=(n=t.defaultView)!=null?n:window;e=Math.max(0,s.innerWidth-r.clientWidth)},after({doc:t,d:n}){let r=t.documentElement,s=Math.max(0,r.clientWidth-r.offsetWidth),o=Math.max(0,e-s);n.style(r,"paddingRight",`${o}px`)}}}function nAe(){return FY()?{before({doc:e,d:t,meta:n}){function r(s){return n.containers.flatMap(o=>o()).some(o=>o.contains(s))}t.microTask(()=>{var s;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let a=sa();a.style(e.documentElement,"scrollBehavior","auto"),t.add(()=>t.microTask(()=>a.dispose()))}let o=(s=window.scrollY)!=null?s:window.pageYOffset,i=null;t.addEventListener(e,"click",a=>{if(a.target instanceof HTMLElement)try{let l=a.target.closest("a");if(!l)return;let{hash:u}=new URL(l.href),d=e.querySelector(u);d&&!r(d)&&(i=d)}catch{}},!0),t.addEventListener(e,"touchstart",a=>{if(a.target instanceof HTMLElement)if(r(a.target)){let l=a.target;for(;l.parentElement&&r(l.parentElement);)l=l.parentElement;t.style(l,"overscrollBehavior","contain")}else t.style(a.target,"touchAction","none")}),t.addEventListener(e,"touchmove",a=>{if(a.target instanceof HTMLElement){if(a.target.tagName==="INPUT")return;if(r(a.target)){let l=a.target;for(;l.parentElement&&l.dataset.headlessuiPortal!==""&&!(l.scrollHeight>l.clientHeight||l.scrollWidth>l.clientWidth);)l=l.parentElement;l.dataset.headlessuiPortal===""&&a.preventDefault()}else a.preventDefault()}},{passive:!1}),t.add(()=>{var a;let l=(a=window.scrollY)!=null?a:window.pageYOffset;o!==l&&window.scrollTo(0,o),i&&i.isConnected&&(i.scrollIntoView({block:"nearest"}),i=null)})})}}:{}}function rAe(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function sAe(e){let t={};for(let n of e)Object.assign(t,n(t));return t}let ou=AY(()=>new Map,{PUSH(e,t){var n;let r=(n=this.get(e))!=null?n:{doc:e,count:0,d:sa(),meta:new Set};return r.count++,r.meta.add(t),this.set(e,r),this},POP(e,t){let n=this.get(e);return n&&(n.count--,n.meta.delete(t)),this},SCROLL_PREVENT({doc:e,d:t,meta:n}){let r={doc:e,d:t,meta:sAe(n)},s=[nAe(),tAe(),rAe()];s.forEach(({before:o})=>o==null?void 0:o(r)),s.forEach(({after:o})=>o==null?void 0:o(r))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});ou.subscribe(()=>{let e=ou.getSnapshot(),t=new Map;for(let[n]of e)t.set(n,n.documentElement.style.overflow);for(let n of e.values()){let r=t.get(n.doc)==="hidden",s=n.count!==0;(s&&!r||!s&&r)&&ou.dispatch(n.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",n),n.count===0&&ou.dispatch("TEARDOWN",n)}});function oAe(e,t,n=()=>({containers:[]})){let r=PY(ou),s=t?r.get(t):void 0,o=s?s.count>0:!1;return Yn(()=>{if(!(!t||!e))return ou.dispatch("PUSH",t,n),()=>ou.dispatch("POP",t,n)},[e,t]),o}function iAe(e,t,n=()=>[document.body]){let r=XT(e,"scroll-lock");oAe(r,t,s=>{var o;return{containers:[...(o=s.containers)!=null?o:[],n]}})}function uF(e){return[e.screenX,e.screenY]}function aAe(){let e=C.useRef([-1,-1]);return{wasMoved(t){let n=uF(t);return e.current[0]===n[0]&&e.current[1]===n[1]?!1:(e.current=n,!0)},update(t){e.current=uF(t)}}}function lAe(e=0){let[t,n]=C.useState(e),r=C.useCallback(l=>n(l),[t]),s=C.useCallback(l=>n(u=>u|l),[t]),o=C.useCallback(l=>(t&l)===l,[t]),i=C.useCallback(l=>n(u=>u&~l),[n]),a=C.useCallback(l=>n(u=>u^l),[n]);return{flags:t,setFlag:r,addFlag:s,hasFlag:o,removeFlag:i,toggleFlag:a}}var dF,fF;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((dF=process==null?void 0:process.env)==null?void 0:dF.NODE_ENV)==="test"&&typeof((fF=Element==null?void 0:Element.prototype)==null?void 0:fF.getAnimations)>"u"&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(`
945
- `)),[]});var cAe=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(cAe||{});function uAe(e){let t={};for(let n in e)e[n]===!0&&(t[`data-${n}`]="");return t}function dAe(e,t,n,r){let[s,o]=C.useState(n),{hasFlag:i,addFlag:a,removeFlag:l}=lAe(e&&s?3:0),u=C.useRef(!1),d=C.useRef(!1),f=Vb();return Yn(()=>{var h;if(e){if(n&&o(!0),!t){n&&a(3);return}return(h=void 0)==null||h.call(r,n),fAe(t,{inFlight:u,prepare(){d.current?d.current=!1:d.current=u.current,u.current=!0,!d.current&&(n?(a(3),l(4)):(a(4),l(2)))},run(){d.current?n?(l(3),a(4)):(l(4),a(3)):n?l(1):a(1)},done(){var p;d.current&&typeof t.getAnimations=="function"&&t.getAnimations().length>0||(u.current=!1,l(7),n||o(!1),(p=void 0)==null||p.call(r,n))}})}},[e,n,t,f]),e?[s,{closed:i(1),enter:i(2),leave:i(4),transition:i(2)||i(4)}]:[n,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function fAe(e,{prepare:t,run:n,done:r,inFlight:s}){let o=sa();return pAe(e,{prepare:t,inFlight:s}),o.nextFrame(()=>{n(),o.requestAnimationFrame(()=>{o.add(hAe(e,r))})}),o.dispose}function hAe(e,t){var n,r;let s=sa();if(!e)return s.dispose;let o=!1;s.add(()=>{o=!0});let i=(r=(n=e.getAnimations)==null?void 0:n.call(e).filter(a=>a instanceof CSSTransition))!=null?r:[];return i.length===0?(t(),s.dispose):(Promise.allSettled(i.map(a=>a.finished)).then(()=>{o||t()}),s.dispose)}function pAe(e,{inFlight:t,prepare:n}){if(t!=null&&t.current){n();return}let r=e.style.transition;e.style.transition="none",n(),e.offsetHeight,e.style.transition=r}function mAe(e,{container:t,accept:n,walk:r}){let s=C.useRef(n),o=C.useRef(r);C.useEffect(()=>{s.current=n,o.current=r},[n,r]),Yn(()=>{if(!t||!e)return;let i=Bb(t);if(!i)return;let a=s.current,l=o.current,u=Object.assign(f=>a(f),{acceptNode:a}),d=i.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,u,!1);for(;d.nextNode();)l(d.currentNode)},[t,e,s,o])}function hF(e,t){let n=C.useRef([]),r=wt(e);C.useEffect(()=>{let s=[...n.current];for(let[o,i]of t.entries())if(n.current[o]!==i){let a=r(t,s);return n.current=t,a}},[r,...t])}function gAe(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:n,version:r}=t;return n+"/"+r}).join(" "):navigator.userAgent}const zY={...E},bAe=zY.useInsertionEffect,xAe=bAe||(e=>e());function BY(e){const t=E.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return xAe(()=>{t.current=e}),E.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return t.current==null?void 0:t.current(...r)},[])}var Rk=typeof document<"u"?C.useLayoutEffect:C.useEffect;let pF=!1,yAe=0;const mF=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+yAe++;function vAe(){const[e,t]=E.useState(()=>pF?mF():void 0);return Rk(()=>{e==null&&t(mF())},[]),E.useEffect(()=>{pF=!0},[]),e}const wAe=zY.useId,SAe=wAe||vAe;let Cg;process.env.NODE_ENV!=="production"&&(Cg=new Set);function CAe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((e=Cg)!=null&&e.has(s))){var o;(o=Cg)==null||o.add(s),console.warn(s)}}function NAe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((e=Cg)!=null&&e.has(s))){var o;(o=Cg)==null||o.add(s),console.error(s)}}function jAe(){const e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(s=>s(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var r;e.set(t,((r=e.get(t))==null?void 0:r.filter(s=>s!==n))||[])}}}const kAe=E.createContext(null),EAe=E.createContext(null),_Ae=()=>{var e;return((e=E.useContext(kAe))==null?void 0:e.id)||null},DAe=()=>E.useContext(EAe),TAe="data-floating-ui-focusable";function RAe(e){const{open:t=!1,onOpenChange:n,elements:r}=e,s=SAe(),o=E.useRef({}),[i]=E.useState(()=>jAe()),a=_Ae()!=null;if(process.env.NODE_ENV!=="production"){const p=r.reference;p&&!Kr(p)&&NAe("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[l,u]=E.useState(r.reference),d=BY((p,m,g)=>{o.current.openEvent=p?m:void 0,i.emit("openchange",{open:p,event:m,reason:g,nested:a}),n==null||n(p,m,g)}),f=E.useMemo(()=>({setPositionReference:u}),[]),h=E.useMemo(()=>({reference:l||r.reference||null,floating:r.floating||null,domReference:r.reference}),[l,r.reference,r.floating]);return E.useMemo(()=>({dataRef:o,open:t,onOpenChange:d,elements:h,events:i,floatingId:s,refs:f}),[t,d,h,i,s,f])}function MAe(e){e===void 0&&(e={});const{nodeId:t}=e,n=RAe({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||n,s=r.elements,[o,i]=E.useState(null),[a,l]=E.useState(null),d=(s==null?void 0:s.domReference)||o,f=E.useRef(null),h=DAe();Rk(()=>{d&&(f.current=d)},[d]);const p=e6({...e,elements:{...s,...a&&{reference:a}}}),m=E.useCallback(v=>{const w=Kr(v)?{getBoundingClientRect:()=>v.getBoundingClientRect(),contextElement:v}:v;l(w),p.refs.setReference(w)},[p.refs]),g=E.useCallback(v=>{(Kr(v)||v===null)&&(f.current=v,i(v)),(Kr(p.refs.reference.current)||p.refs.reference.current===null||v!==null&&!Kr(v))&&p.refs.setReference(v)},[p.refs]),b=E.useMemo(()=>({...p.refs,setReference:g,setPositionReference:m,domReference:f}),[p.refs,g,m]),x=E.useMemo(()=>({...p.elements,domReference:d}),[p.elements,d]),y=E.useMemo(()=>({...p,...r,refs:b,elements:x,nodeId:t}),[p,b,x,t,r]);return Rk(()=>{r.dataRef.current.floatingContext=y;const v=h==null?void 0:h.nodesRef.current.find(w=>w.id===t);v&&(v.context=y)}),E.useMemo(()=>({...p,context:y,refs:b,elements:x}),[p,b,x,y])}const gF="active",bF="selected";function wN(e,t,n){const r=new Map,s=n==="item";let o=e;if(s&&e){const{[gF]:i,[bF]:a,...l}=e;o=l}return{...n==="floating"&&{tabIndex:-1,[TAe]:""},...o,...t.map(i=>{const a=i?i[n]:null;return typeof a=="function"?e?a(e):null:a}).concat(e).reduce((i,a)=>(a&&Object.entries(a).forEach(l=>{let[u,d]=l;if(!(s&&[gF,bF].includes(u)))if(u.indexOf("on")===0){if(r.has(u)||r.set(u,[]),typeof d=="function"){var f;(f=r.get(u))==null||f.push(d),i[u]=function(){for(var h,p=arguments.length,m=new Array(p),g=0;g<p;g++)m[g]=arguments[g];return(h=r.get(u))==null?void 0:h.map(b=>b(...m)).find(b=>b!==void 0)}}}else i[u]=d}),i),{})}}function IAe(e){e===void 0&&(e=[]);const t=e.map(a=>a==null?void 0:a.reference),n=e.map(a=>a==null?void 0:a.floating),r=e.map(a=>a==null?void 0:a.item),s=E.useCallback(a=>wN(a,e,"reference"),t),o=E.useCallback(a=>wN(a,e,"floating"),n),i=E.useCallback(a=>wN(a,e,"item"),r);return E.useMemo(()=>({getReferenceProps:s,getFloatingProps:o,getItemProps:i}),[s,o,i])}function xF(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}const AAe=e=>({name:"inner",options:e,async fn(t){const{listRef:n,overflowRef:r,onFallbackChange:s,offset:o=0,index:i=0,minItemsVisible:a=4,referenceOverflowThreshold:l=0,scrollRef:u,...d}=Ji(e,t),{rects:f,elements:{floating:h}}=t,p=n.current[i],m=(u==null?void 0:u.current)||h,g=h.clientTop||m.clientTop,b=h.clientTop!==0,x=m.clientTop!==0,y=h===m;if(process.env.NODE_ENV!=="production"&&(t.placement.startsWith("bottom")||CAe('`placement` side must be "bottom" when using the `inner`',"middleware.")),!p)return{};const v={...t,...await n_(-p.offsetTop-h.clientTop-f.reference.height/2-p.offsetHeight/2-o).fn(t)},w=await BS(xF(v,m.scrollHeight+g+h.clientTop),d),S=await BS(v,{...d,elementContext:"reference"}),N=Zr(0,w.top),j=v.y+N,D=(m.scrollHeight>m.clientHeight?T=>T:Gm)(Zr(0,m.scrollHeight+(b&&y||x?g*2:0)-N-Zr(0,w.bottom)));if(m.style.maxHeight=D+"px",m.scrollTop=N,s){const T=m.offsetHeight<p.offsetHeight*Qa(a,n.current.length)-1||S.top>=-l||S.bottom>=-l;Gl.flushSync(()=>s(T))}return r&&(r.current=await BS(xF({...v,y:j},m.offsetHeight+g+h.clientTop),d)),{y:j}}});function PAe(e,t){const{open:n,elements:r}=e,{enabled:s=!0,overflowRef:o,scrollRef:i,onChange:a}=t,l=BY(a),u=E.useRef(!1),d=E.useRef(null),f=E.useRef(null);E.useEffect(()=>{if(!s)return;function p(g){if(g.ctrlKey||!m||o.current==null)return;const b=g.deltaY,x=o.current.top>=-.5,y=o.current.bottom>=-.5,v=m.scrollHeight-m.clientHeight,w=b<0?-1:1,S=b<0?"max":"min";m.scrollHeight<=m.clientHeight||(!x&&b>0||!y&&b<0?(g.preventDefault(),Gl.flushSync(()=>{l(N=>N+Math[S](b,v*w))})):/firefox/i.test(gAe())&&(m.scrollTop+=b))}const m=(i==null?void 0:i.current)||r.floating;if(n&&m)return m.addEventListener("wheel",p),requestAnimationFrame(()=>{d.current=m.scrollTop,o.current!=null&&(f.current={...o.current})}),()=>{d.current=null,f.current=null,m.removeEventListener("wheel",p)}},[s,n,r.floating,o,i,l]);const h=E.useMemo(()=>({onKeyDown(){u.current=!0},onWheel(){u.current=!1},onPointerMove(){u.current=!1},onScroll(){const p=(i==null?void 0:i.current)||r.floating;if(!(!o.current||!p||!u.current)){if(d.current!==null){const m=p.scrollTop-d.current;(o.current.bottom<-.5&&m<-1||o.current.top<-.5&&m>1)&&Gl.flushSync(()=>l(g=>g+m))}requestAnimationFrame(()=>{d.current=p.scrollTop})}}}),[r.floating,l,o,i]);return E.useMemo(()=>s?{floating:h}:{},[s,h])}let Hb=C.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});Hb.displayName="FloatingContext";let QT=C.createContext(null);QT.displayName="PlacementContext";function OAe(e){return C.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function FAe(){return C.useContext(Hb).setReference}function $Ae(){let{getFloatingProps:e,slot:t}=C.useContext(Hb);return C.useCallback((...n)=>Object.assign({},e(...n),{"data-anchor":t.anchor}),[e,t])}function LAe(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let t=C.useContext(QT),n=C.useMemo(()=>e,[JSON.stringify(e,(s,o)=>{var i;return(i=o==null?void 0:o.outerHTML)!=null?i:o})]);Yn(()=>{t==null||t(n??null)},[t,n]);let r=C.useContext(Hb);return C.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let yF=4;function zAe({children:e,enabled:t=!0}){let[n,r]=C.useState(null),[s,o]=C.useState(0),i=C.useRef(null),[a,l]=C.useState(null);BAe(a);let u=t&&n!==null&&a!==null,{to:d="bottom",gap:f=0,offset:h=0,padding:p=0,inner:m}=VAe(n,a),[g,b="center"]=d.split(" ");Yn(()=>{u&&o(0)},[u]);let{refs:x,floatingStyles:y,context:v}=MAe({open:u,placement:g==="selection"?b==="center"?"bottom":`bottom-${b}`:b==="center"?`${g}`:`${g}-${b}`,strategy:"absolute",transform:!1,middleware:[n_({mainAxis:g==="selection"?0:f,crossAxis:h}),t6({padding:p}),g!=="selection"&&n6({padding:p}),g==="selection"&&m?AAe({...m,padding:p,overflowRef:i,offset:s,minItemsVisible:yF,referenceOverflowThreshold:p,onFallbackChange(T){var R,O;if(!T)return;let M=v.elements.floating;if(!M)return;let P=parseFloat(getComputedStyle(M).scrollPaddingBottom)||0,F=Math.min(yF,M.childElementCount),V=0,H=0;for(let L of(O=(R=v.elements.floating)==null?void 0:R.childNodes)!=null?O:[])if(L instanceof HTMLElement){let I=L.offsetTop,B=I+L.clientHeight+P,z=M.scrollTop,A=z+M.clientHeight;if(I>=z&&B<=A)F--;else{H=Math.max(0,Math.min(B,A)-Math.max(I,z)),V=L.clientHeight;break}}F>=1&&o(L=>{let I=V*F-H+P;return L>=I?L:I})}}):null,r6({padding:p,apply({availableWidth:T,availableHeight:R,elements:O}){Object.assign(O.floating.style,{overflow:"auto",maxWidth:`${T}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${R}px)`})}})].filter(Boolean),whileElementsMounted:QL}),[w=g,S=b]=v.placement.split("-");g==="selection"&&(w="selection");let N=C.useMemo(()=>({anchor:[w,S].filter(Boolean).join(" ")}),[w,S]),j=PAe(v,{overflowRef:i,onChange:o}),{getReferenceProps:_,getFloatingProps:k}=IAe([j]),D=wt(T=>{l(T),x.setFloating(T)});return E.createElement(QT.Provider,{value:r},E.createElement(Hb.Provider,{value:{setFloating:D,setReference:x.setReference,styles:y,getReferenceProps:_,getFloatingProps:k,slot:N}},e))}function BAe(e){Yn(()=>{if(!e)return;let t=new MutationObserver(()=>{let n=window.getComputedStyle(e).maxHeight,r=parseFloat(n);if(isNaN(r))return;let s=parseInt(n);isNaN(s)||r!==s&&(e.style.maxHeight=`${Math.ceil(r)}px`)});return t.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{t.disconnect()}},[e])}function VAe(e,t){var n,r,s;let o=SN((n=e==null?void 0:e.gap)!=null?n:"var(--anchor-gap, 0)",t),i=SN((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",t),a=SN((s=e==null?void 0:e.padding)!=null?s:"var(--anchor-padding, 0)",t);return{...e,gap:o,offset:i,padding:a}}function SN(e,t,n=void 0){let r=Vb(),s=wt((l,u)=>{if(l==null)return[n,null];if(typeof l=="number")return[l,null];if(typeof l=="string"){if(!u)return[n,null];let d=vF(l,u);return[d,f=>{let h=VY(l);{let p=h.map(m=>window.getComputedStyle(u).getPropertyValue(m));r.requestAnimationFrame(function m(){r.nextFrame(m);let g=!1;for(let[x,y]of h.entries()){let v=window.getComputedStyle(u).getPropertyValue(y);if(p[x]!==v){p[x]=v,g=!0;break}}if(!g)return;let b=vF(l,u);d!==b&&(f(b),d=b)})}return r.dispose}]}return[n,null]}),o=C.useMemo(()=>s(e,t)[0],[e,t]),[i=o,a]=C.useState();return Yn(()=>{let[l,u]=s(e,t);if(a(l),!!u)return u(a)},[e,t]),i}function VY(e){let t=/var\((.*)\)/.exec(e);if(t){let n=t[1].indexOf(",");if(n===-1)return[t[1]];let r=t[1].slice(0,n).trim(),s=t[1].slice(n+1).trim();return s?[r,...VY(s)]:[r]}return[]}function vF(e,t){let n=document.createElement("div");t.appendChild(n),n.style.setProperty("margin-top","0px","important"),n.style.setProperty("margin-top",e,"important");let r=parseFloat(window.getComputedStyle(n).marginTop)||0;return t.removeChild(n),r}function HAe({children:e,freeze:t}){let n=Mk(t,e);return C.createElement(C.Fragment,null,n)}function Mk(e,t){let[n,r]=C.useState(t);return!e&&n!==t&&r(t),e?n:t}let JT=C.createContext(null);JT.displayName="OpenClosedContext";var Ng=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(Ng||{});function UAe(){return C.useContext(JT)}function WAe({value:e,children:t}){return C.createElement(JT.Provider,{value:e},t)}function qAe(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let Xc=[];qAe(()=>{function e(t){if(!(t.target instanceof HTMLElement)||t.target===document.body||Xc[0]===t.target)return;let n=t.target;n=n.closest(Tk),Xc.unshift(n??t.target),Xc=Xc.filter(r=>r!=null&&r.isConnected),Xc.splice(10)}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})});function YAe(e){throw new Error("Unexpected object: "+e)}var ur=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(ur||{});function wF(e,t){let n=t.resolveItems();if(n.length<=0)return null;let r=t.resolveActiveIndex(),s=r??-1;switch(e.focus){case 0:{for(let o=0;o<n.length;++o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 1:{s===-1&&(s=n.length);for(let o=s-1;o>=0;--o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 2:{for(let o=s+1;o<n.length;++o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 3:{for(let o=n.length-1;o>=0;--o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 4:{for(let o=0;o<n.length;++o)if(t.resolveId(n[o],o,n)===e.id)return o;return r}case 5:return null;default:YAe(e)}}var eR=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(eR||{});function GAe(e){let t=wt(e),n=C.useRef(!1);C.useEffect(()=>(n.current=!1,()=>{n.current=!0,CY(()=>{n.current&&t()})}),[t])}function ZAe(){let e=typeof document>"u";return"useSyncExternalStore"in E?(t=>t.useSyncExternalStore)(E)(()=>()=>{},()=>!1,()=>!e):!1}function KAe(){let e=ZAe(),[t,n]=E.useState(Iu.isHandoffComplete);return t&&Iu.isHandoffComplete===!1&&n(!1),E.useEffect(()=>{t!==!0&&n(!0)},[t]),E.useEffect(()=>Iu.handoff(),[]),e?!1:t}let XAe=C.createContext(!1);function QAe(){return C.useContext(XAe)}function JAe(e){let t=QAe(),n=C.useContext(UY),r=F1(e),[s,o]=C.useState(()=>{var i;if(!t&&n!==null)return(i=n.current)!=null?i:null;if(Iu.isServer)return null;let a=r==null?void 0:r.getElementById("headlessui-portal-root");if(a)return a;if(r===null)return null;let l=r.createElement("div");return l.setAttribute("id","headlessui-portal-root"),r.body.appendChild(l)});return C.useEffect(()=>{s!==null&&(r!=null&&r.body.contains(s)||r==null||r.body.appendChild(s))},[s,r]),C.useEffect(()=>{t||n!==null&&o(n.current)},[n,o,t]),s}let HY=C.Fragment,ePe=Ni(function(e,t){let n=e,r=C.useRef(null),s=ll(mIe(f=>{r.current=f}),t),o=F1(r),i=JAe(r),[a]=C.useState(()=>{var f;return Iu.isServer?null:(f=o==null?void 0:o.createElement("div"))!=null?f:null}),l=C.useContext(sPe),u=KAe();Yn(()=>{!i||!a||i.contains(a)||(a.setAttribute("data-headlessui-portal",""),i.appendChild(a))},[i,a]),Yn(()=>{if(a&&l)return l.register(a)},[l,a]),GAe(()=>{var f;!i||!a||(a instanceof Node&&i.contains(a)&&i.removeChild(a),i.childNodes.length<=0&&((f=i.parentElement)==null||f.removeChild(i)))});let d=Ci();return u?!i||!a?null:_n.createPortal(d({ourProps:{ref:s},theirProps:n,slot:{},defaultTag:HY,name:"Portal"}),a):null});function tPe(e,t){let n=ll(t),{enabled:r=!0,...s}=e,o=Ci();return r?C.createElement(ePe,{...s,ref:n}):o({ourProps:{ref:n},theirProps:s,slot:{},defaultTag:HY,name:"Portal"})}let nPe=C.Fragment,UY=C.createContext(null);function rPe(e,t){let{target:n,...r}=e,s={ref:ll(t)},o=Ci();return C.createElement(UY.Provider,{value:n},o({ourProps:s,theirProps:r,defaultTag:nPe,name:"Popover.Group"}))}let sPe=C.createContext(null),oPe=Ni(tPe),iPe=Ni(rPe),aPe=Object.assign(oPe,{Group:iPe});var lPe=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(lPe||{}),cPe=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(cPe||{}),uPe=(e=>(e[e.Pointer=0]="Pointer",e[e.Focus=1]="Focus",e[e.Other=2]="Other",e))(uPe||{}),dPe=(e=>(e[e.OpenCombobox=0]="OpenCombobox",e[e.CloseCombobox=1]="CloseCombobox",e[e.GoToOption=2]="GoToOption",e[e.SetTyping=3]="SetTyping",e[e.RegisterOption=4]="RegisterOption",e[e.UnregisterOption=5]="UnregisterOption",e[e.SetActivationTrigger=6]="SetActivationTrigger",e[e.UpdateVirtualConfiguration=7]="UpdateVirtualConfiguration",e[e.SetInputElement=8]="SetInputElement",e[e.SetButtonElement=9]="SetButtonElement",e[e.SetOptionsElement=10]="SetOptionsElement",e))(dPe||{});function CN(e,t=n=>n){let n=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=t(e.options.slice()),s=r.length>0&&r[0].dataRef.current.order!==null?r.sort((i,a)=>i.dataRef.current.order-a.dataRef.current.order):ZIe(r,i=>i.dataRef.current.domRef.current),o=n?s.indexOf(n):null;return o===-1&&(o=null),{options:s,activeOptionIndex:o}}let fPe={1(e){var t;return(t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===1?e:{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,__demoMode:!1}},0(e){var t,n;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===0)return e;if((n=e.dataRef.current)!=null&&n.value){let r=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(r!==-1)return{...e,activeOptionIndex:r,comboboxState:0,__demoMode:!1}}return{...e,comboboxState:0,__demoMode:!1}},3(e,t){return e.isTyping===t.isTyping?e:{...e,isTyping:t.isTyping}},2(e,t){var n,r,s,o;if((n=e.dataRef.current)!=null&&n.disabled||e.optionsElement&&!((r=e.dataRef.current)!=null&&r.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:u,disabled:d}=e.virtual,f=t.focus===ur.Specific?t.idx:wF(t,{resolveItems:()=>u,resolveActiveIndex:()=>{var p,m;return(m=(p=e.activeOptionIndex)!=null?p:u.findIndex(g=>!d(g)))!=null?m:null},resolveDisabled:d,resolveId(){throw new Error("Function not implemented.")}}),h=(s=t.trigger)!=null?s:2;return e.activeOptionIndex===f&&e.activationTrigger===h?e:{...e,activeOptionIndex:f,activationTrigger:h,isTyping:!1,__demoMode:!1}}let i=CN(e);if(i.activeOptionIndex===null){let u=i.options.findIndex(d=>!d.dataRef.current.disabled);u!==-1&&(i.activeOptionIndex=u)}let a=t.focus===ur.Specific?t.idx:wF(t,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:u=>u.id,resolveDisabled:u=>u.dataRef.current.disabled}),l=(o=t.trigger)!=null?o:2;return e.activeOptionIndex===a&&e.activationTrigger===l?e:{...e,...i,isTyping:!1,activeOptionIndex:a,activationTrigger:l,__demoMode:!1}},4:(e,t)=>{var n,r,s;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:[...e.options,t.payload]};let o=t.payload,i=CN(e,l=>(l.push(o),l));e.activeOptionIndex===null&&(r=e.dataRef.current)!=null&&r.isSelected(t.payload.dataRef.current.value)&&(i.activeOptionIndex=i.options.indexOf(o));let a={...e,...i,activationTrigger:2};return(s=e.dataRef.current)!=null&&s.__demoMode&&e.dataRef.current.value===void 0&&(a.activeOptionIndex=0),a},5:(e,t)=>{var n;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:e.options.filter(s=>s.id!==t.id)};let r=CN(e,s=>{let o=s.findIndex(i=>i.id===t.id);return o!==-1&&s.splice(o,1),s});return{...e,...r,activationTrigger:2}},6:(e,t)=>e.activationTrigger===t.trigger?e:{...e,activationTrigger:t.trigger},7:(e,t)=>{var n,r;if(e.virtual===null)return{...e,virtual:{options:t.options,disabled:(n=t.disabled)!=null?n:()=>!1}};if(e.virtual.options===t.options&&e.virtual.disabled===t.disabled)return e;let s=e.activeOptionIndex;if(e.activeOptionIndex!==null){let o=t.options.indexOf(e.virtual.options[e.activeOptionIndex]);o!==-1?s=o:s=null}return{...e,activeOptionIndex:s,virtual:{options:t.options,disabled:(r=t.disabled)!=null?r:()=>!1}}},8:(e,t)=>e.inputElement===t.element?e:{...e,inputElement:t.element},9:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},10:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element}},tR=C.createContext(null);tR.displayName="ComboboxActionsContext";function Ub(e){let t=C.useContext(tR);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Ub),n}return t}let WY=C.createContext(null);function hPe(e){let t=rp("VirtualProvider"),{options:n}=t.virtual,[r,s]=C.useMemo(()=>{let u=t.optionsElement;if(!u)return[0,0];let d=window.getComputedStyle(u);return[parseFloat(d.paddingBlockStart||d.paddingTop),parseFloat(d.paddingBlockEnd||d.paddingBottom)]},[t.optionsElement]),o=OIe({enabled:n.length!==0,scrollPaddingStart:r,scrollPaddingEnd:s,count:n.length,estimateSize(){return 40},getScrollElement(){return t.optionsElement},overscan:12}),[i,a]=C.useState(0);Yn(()=>{a(u=>u+1)},[n]);let l=o.getVirtualItems();return l.length===0?null:C.createElement(WY.Provider,{value:o},C.createElement("div",{style:{position:"relative",width:"100%",height:`${o.getTotalSize()}px`},ref:u=>{u&&t.activationTrigger!==0&&t.activeOptionIndex!==null&&n.length>t.activeOptionIndex&&o.scrollToIndex(t.activeOptionIndex)}},l.map(u=>{var d;return C.createElement(C.Fragment,{key:u.key},C.cloneElement((d=e.children)==null?void 0:d.call(e,{...e.slot,option:n[u.index]}),{key:`${i}-${u.key}`,"data-index":u.index,"aria-setsize":n.length,"aria-posinset":u.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${u.start}px)`,overflowAnchor:"none"}}))})))}let jg=C.createContext(null);jg.displayName="ComboboxDataContext";function rp(e){let t=C.useContext(jg);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,rp),n}return t}function pPe(e,t){return Ya(t.type,fPe,e,t)}let mPe=C.Fragment;function gPe(e,t){var n,r;let s=YT(),{value:o,defaultValue:i,onChange:a,form:l,name:u,by:d,disabled:f=s||!1,onClose:h,__demoMode:p=!1,multiple:m=!1,immediate:g=!1,virtual:b=null,nullable:x,...y}=e,v=oIe(i),[w=m?[]:void 0,S]=sIe(o,a,v),[N,j]=C.useReducer(pPe,{dataRef:C.createRef(),comboboxState:p?0:1,isTyping:!1,options:[],virtual:b?{options:b.options,disabled:(n=b.disabled)!=null?n:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:p}),_=C.useRef(!1),k=C.useRef({static:!1,hold:!1}),D=$Ie(d),T=wt(ie=>b?d===null?b.options.indexOf(ie):b.options.findIndex(ue=>D(ue,ie)):N.options.findIndex(ue=>D(ue.dataRef.current.value,ie))),R=C.useCallback(ie=>Ya(M.mode,{1:()=>w.some(ue=>D(ue,ie)),0:()=>D(w,ie)}),[w]),O=wt(ie=>N.activeOptionIndex===T(ie)),M=C.useMemo(()=>({...N,immediate:g,optionsPropsRef:k,value:w,defaultValue:v,disabled:f,mode:m?1:0,virtual:b?N.virtual:null,get activeOptionIndex(){if(_.current&&N.activeOptionIndex===null&&(b?b.options.length>0:N.options.length>0)){if(b){let ue=b.options.findIndex(ae=>{var Se,ye;return!((ye=(Se=b.disabled)==null?void 0:Se.call(b,ae))!=null&&ye)});if(ue!==-1)return ue}let ie=N.options.findIndex(ue=>!ue.dataRef.current.disabled);if(ie!==-1)return ie}return N.activeOptionIndex},calculateIndex:T,compare:D,isSelected:R,isActive:O}),[w,v,f,m,p,N,b]);Yn(()=>{var ie;b&&j({type:7,options:b.options,disabled:(ie=b.disabled)!=null?ie:null})},[b,b==null?void 0:b.options,b==null?void 0:b.disabled]),Yn(()=>{N.dataRef.current=M},[M]);let P=M.comboboxState===0;QIe(P,[M.buttonElement,M.inputElement,M.optionsElement],()=>$.closeCombobox());let F=C.useMemo(()=>{var ie,ue,ae;return{open:M.comboboxState===0,disabled:f,activeIndex:M.activeOptionIndex,activeOption:M.activeOptionIndex===null?null:M.virtual?M.virtual.options[(ie=M.activeOptionIndex)!=null?ie:0]:(ae=(ue=M.options[M.activeOptionIndex])==null?void 0:ue.dataRef.current.value)!=null?ae:null,value:w}},[M,f,w]),V=wt(()=>{if(M.activeOptionIndex!==null){if($.setIsTyping(!1),M.virtual)A(M.virtual.options[M.activeOptionIndex]);else{let{dataRef:ie}=M.options[M.activeOptionIndex];A(ie.current.value)}$.goToOption(ur.Specific,M.activeOptionIndex)}}),H=wt(()=>{j({type:0}),_.current=!0}),L=wt(()=>{j({type:1}),_.current=!1,h==null||h()}),I=wt(ie=>{j({type:3,isTyping:ie})}),B=wt((ie,ue,ae)=>(_.current=!1,ie===ur.Specific?j({type:2,focus:ur.Specific,idx:ue,trigger:ae}):j({type:2,focus:ie,trigger:ae}))),z=wt((ie,ue)=>(j({type:4,payload:{id:ie,dataRef:ue}}),()=>{M.isActive(ue.current.value)&&(_.current=!0),j({type:5,id:ie})})),A=wt(ie=>Ya(M.mode,{0(){return S==null?void 0:S(ie)},1(){let ue=M.value.slice(),ae=ue.findIndex(Se=>D(Se,ie));return ae===-1?ue.push(ie):ue.splice(ae,1),S==null?void 0:S(ue)}})),W=wt(ie=>{j({type:6,trigger:ie})}),q=wt(ie=>{j({type:8,element:ie})}),Y=wt(ie=>{j({type:9,element:ie})}),U=wt(ie=>{j({type:10,element:ie})}),$=C.useMemo(()=>({onChange:A,registerOption:z,goToOption:B,setIsTyping:I,closeCombobox:L,openCombobox:H,setActivationTrigger:W,selectActiveOption:V,setInputElement:q,setButtonElement:Y,setOptionsElement:U}),[]),[G,Z]=vIe(),te=t===null?{}:{ref:t},Q=C.useCallback(()=>{if(v!==void 0)return S==null?void 0:S(v)},[S,v]),ne=Ci();return C.createElement(Z,{value:G,props:{htmlFor:(r=M.inputElement)==null?void 0:r.id},slot:{open:M.comboboxState===0,disabled:f}},C.createElement(zAe,null,C.createElement(tR.Provider,{value:$},C.createElement(jg.Provider,{value:M},C.createElement(WAe,{value:Ya(M.comboboxState,{0:Ng.Open,1:Ng.Closed})},u!=null&&C.createElement(uIe,{disabled:f,data:w!=null?{[u]:w}:{},form:l,onReset:Q}),ne({ourProps:te,theirProps:y,slot:F,defaultTag:mPe,name:"Combobox"}))))))}let bPe="input";function xPe(e,t){var n,r,s,o,i;let a=rp("Combobox.Input"),l=Ub("Combobox.Input"),u=C.useId(),d=DY(),{id:f=d||`headlessui-combobox-input-${u}`,onChange:h,displayValue:p,disabled:m=a.disabled||!1,autoFocus:g=!1,type:b="text",...x}=e,y=C.useRef(null),v=ll(y,t,FAe(),l.setInputElement),w=F1(a.inputElement),S=Vb(),N=wt(()=>{l.onChange(null),a.optionsElement&&(a.optionsElement.scrollTop=0),l.goToOption(ur.Nothing)}),j=C.useMemo(()=>{var A;return typeof p=="function"&&a.value!==void 0?(A=p(a.value))!=null?A:"":typeof a.value=="string"?a.value:""},[a.value,p]);hF(([A,W],[q,Y])=>{if(a.isTyping)return;let U=y.current;U&&((Y===0&&W===1||A!==q)&&(U.value=A),requestAnimationFrame(()=>{if(a.isTyping||!U||(w==null?void 0:w.activeElement)!==U)return;let{selectionStart:$,selectionEnd:G}=U;Math.abs((G??0)-($??0))===0&&$===0&&U.setSelectionRange(U.value.length,U.value.length)}))},[j,a.comboboxState,w,a.isTyping]),hF(([A],[W])=>{if(A===0&&W===1){if(a.isTyping)return;let q=y.current;if(!q)return;let Y=q.value,{selectionStart:U,selectionEnd:$,selectionDirection:G}=q;q.value="",q.value=Y,G!==null?q.setSelectionRange(U,$,G):q.setSelectionRange(U,$)}},[a.comboboxState]);let _=C.useRef(!1),k=wt(()=>{_.current=!0}),D=wt(()=>{S.nextFrame(()=>{_.current=!1})}),T=wt(A=>{switch(l.setIsTyping(!0),A.key){case gs.Enter:if(a.comboboxState!==0||_.current)return;if(A.preventDefault(),A.stopPropagation(),a.activeOptionIndex===null){l.closeCombobox();return}l.selectActiveOption(),a.mode===0&&l.closeCombobox();break;case gs.ArrowDown:return A.preventDefault(),A.stopPropagation(),Ya(a.comboboxState,{0:()=>l.goToOption(ur.Next),1:()=>l.openCombobox()});case gs.ArrowUp:return A.preventDefault(),A.stopPropagation(),Ya(a.comboboxState,{0:()=>l.goToOption(ur.Previous),1:()=>{_n.flushSync(()=>l.openCombobox()),a.value||l.goToOption(ur.Last)}});case gs.Home:if(A.shiftKey)break;return A.preventDefault(),A.stopPropagation(),l.goToOption(ur.First);case gs.PageUp:return A.preventDefault(),A.stopPropagation(),l.goToOption(ur.First);case gs.End:if(A.shiftKey)break;return A.preventDefault(),A.stopPropagation(),l.goToOption(ur.Last);case gs.PageDown:return A.preventDefault(),A.stopPropagation(),l.goToOption(ur.Last);case gs.Escape:return a.comboboxState!==0?void 0:(A.preventDefault(),a.optionsElement&&!a.optionsPropsRef.current.static&&A.stopPropagation(),a.mode===0&&a.value===null&&N(),l.closeCombobox());case gs.Tab:if(a.comboboxState!==0)return;a.mode===0&&a.activationTrigger!==1&&l.selectActiveOption(),l.closeCombobox();break}}),R=wt(A=>{h==null||h(A),a.mode===0&&A.target.value===""&&N(),l.openCombobox()}),O=wt(A=>{var W,q,Y;let U=(W=A.relatedTarget)!=null?W:Xc.find($=>$!==A.currentTarget);if(!((q=a.optionsElement)!=null&&q.contains(U))&&!((Y=a.buttonElement)!=null&&Y.contains(U))&&a.comboboxState===0)return A.preventDefault(),a.mode===0&&a.value===null&&N(),l.closeCombobox()}),M=wt(A=>{var W,q,Y;let U=(W=A.relatedTarget)!=null?W:Xc.find($=>$!==A.currentTarget);(q=a.buttonElement)!=null&&q.contains(U)||(Y=a.optionsElement)!=null&&Y.contains(U)||a.disabled||a.immediate&&a.comboboxState!==0&&S.microTask(()=>{_n.flushSync(()=>l.openCombobox()),l.setActivationTrigger(1)})}),P=O1(),F=gIe(),{isFocused:V,focusProps:H}=SY({autoFocus:g}),{isHovered:L,hoverProps:I}=wY({isDisabled:m}),B=C.useMemo(()=>({open:a.comboboxState===0,disabled:m,hover:L,focus:V,autofocus:g}),[a,L,V,g,m]),z=GT({ref:v,id:f,role:"combobox",type:b,"aria-controls":(n=a.optionsElement)==null?void 0:n.id,"aria-expanded":a.comboboxState===0,"aria-activedescendant":a.activeOptionIndex===null?void 0:a.virtual?(r=a.options.find(A=>!A.dataRef.current.disabled&&a.compare(A.dataRef.current.value,a.virtual.options[a.activeOptionIndex])))==null?void 0:r.id:(s=a.options[a.activeOptionIndex])==null?void 0:s.id,"aria-labelledby":P,"aria-describedby":F,"aria-autocomplete":"list",defaultValue:(i=(o=e.defaultValue)!=null?o:a.defaultValue!==void 0?p==null?void 0:p(a.defaultValue):null)!=null?i:a.defaultValue,disabled:m||void 0,autoFocus:g,onCompositionStart:k,onCompositionEnd:D,onKeyDown:T,onChange:R,onFocus:M,onBlur:O},H,I);return Ci()({ourProps:z,theirProps:x,slot:B,defaultTag:bPe,name:"Combobox.Input"})}let yPe="button";function vPe(e,t){var n;let r=rp("Combobox.Button"),s=Ub("Combobox.Button"),o=ll(t,s.setButtonElement),i=C.useId(),{id:a=`headlessui-combobox-button-${i}`,disabled:l=r.disabled||!1,autoFocus:u=!1,...d}=e,f=LY(r.inputElement),h=wt(j=>{switch(j.key){case gs.Space:case gs.Enter:j.preventDefault(),j.stopPropagation(),r.comboboxState===1&&_n.flushSync(()=>s.openCombobox()),f();return;case gs.ArrowDown:j.preventDefault(),j.stopPropagation(),r.comboboxState===1&&(_n.flushSync(()=>s.openCombobox()),r.value||s.goToOption(ur.First)),f();return;case gs.ArrowUp:j.preventDefault(),j.stopPropagation(),r.comboboxState===1&&(_n.flushSync(()=>s.openCombobox()),r.value||s.goToOption(ur.Last)),f();return;case gs.Escape:if(r.comboboxState!==0)return;j.preventDefault(),r.optionsElement&&!r.optionsPropsRef.current.static&&j.stopPropagation(),_n.flushSync(()=>s.closeCombobox()),f();return;default:return}}),p=wt(j=>{j.preventDefault(),!hIe(j.currentTarget)&&(j.button===eR.Left&&(r.comboboxState===0?s.closeCombobox():s.openCombobox()),f())}),m=O1([a]),{isFocusVisible:g,focusProps:b}=SY({autoFocus:u}),{isHovered:x,hoverProps:y}=wY({isDisabled:l}),{pressed:v,pressProps:w}=XMe({disabled:l}),S=C.useMemo(()=>({open:r.comboboxState===0,active:v||r.comboboxState===0,disabled:l,value:r.value,hover:x,focus:g}),[r,x,g,v,l]),N=GT({ref:o,id:a,type:eAe(e,r.buttonElement),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":(n=r.optionsElement)==null?void 0:n.id,"aria-expanded":r.comboboxState===0,"aria-labelledby":m,disabled:l||void 0,autoFocus:u,onMouseDown:p,onKeyDown:h},b,y,w);return Ci()({ourProps:N,theirProps:d,slot:S,defaultTag:yPe,name:"Combobox.Button"})}let wPe="div",SPe=_k.RenderStrategy|_k.Static;function CPe(e,t){var n,r,s;let o=C.useId(),{id:i=`headlessui-combobox-options-${o}`,hold:a=!1,anchor:l,portal:u=!1,modal:d=!0,transition:f=!1,...h}=e,p=rp("Combobox.Options"),m=Ub("Combobox.Options"),g=OAe(l);g&&(u=!0);let[b,x]=LAe(g),[y,v]=C.useState(null),w=$Ae(),S=ll(t,g?b:null,m.setOptionsElement,v),N=F1(p.optionsElement),j=UAe(),[_,k]=dAe(f,y,j!==null?(j&Ng.Open)===Ng.Open:p.comboboxState===0);HIe(_,p.inputElement,m.closeCombobox);let D=p.__demoMode?!1:d&&p.comboboxState===0;iAe(D,N);let T=p.__demoMode?!1:d&&p.comboboxState===0;VIe(T,{allowed:C.useCallback(()=>[p.inputElement,p.buttonElement,p.optionsElement],[p.inputElement,p.buttonElement,p.optionsElement])}),Yn(()=>{var z;p.optionsPropsRef.current.static=(z=e.static)!=null?z:!1},[p.optionsPropsRef,e.static]),Yn(()=>{p.optionsPropsRef.current.hold=a},[p.optionsPropsRef,a]),mAe(p.comboboxState===0,{container:p.optionsElement,accept(z){return z.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:z.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(z){z.setAttribute("role","none")}});let R=O1([(n=p.buttonElement)==null?void 0:n.id]),O=C.useMemo(()=>({open:p.comboboxState===0,option:void 0}),[p.comboboxState]),M=wt(()=>{m.setActivationTrigger(0)}),P=wt(z=>{z.preventDefault(),m.setActivationTrigger(0)}),F=GT(g?w():{},{"aria-labelledby":R,role:"listbox","aria-multiselectable":p.mode===1?!0:void 0,id:i,ref:S,style:{...h.style,...x,"--input-width":iF(p.inputElement,!0).width,"--button-width":iF(p.buttonElement,!0).width},onWheel:p.activationTrigger===0?void 0:M,onMouseDown:P,...uAe(k)}),V=_&&p.comboboxState===1,H=Mk(V,(r=p.virtual)==null?void 0:r.options),L=Mk(V,p.value),I=wt(z=>p.compare(L,z));if(p.virtual){if(H===void 0)throw new Error("Missing `options` in virtual mode");Object.assign(h,{children:C.createElement(jg.Provider,{value:H!==p.virtual.options?{...p,virtual:{...p.virtual,options:H}}:p},C.createElement(hPe,{slot:O},h.children))})}let B=Ci();return C.createElement(aPe,{enabled:u?e.static||_:!1},C.createElement(jg.Provider,{value:p.mode===1?p:{...p,isSelected:I}},B({ourProps:F,theirProps:{...h,children:C.createElement(HAe,{freeze:V},typeof h.children=="function"?(s=h.children)==null?void 0:s.call(h,O):h.children)},slot:O,defaultTag:wPe,features:SPe,visible:_,name:"Combobox.Options"})))}let NPe="div";function jPe(e,t){var n,r,s,o;let i=rp("Combobox.Option"),a=Ub("Combobox.Option"),l=C.useId(),{id:u=`headlessui-combobox-option-${l}`,value:d,disabled:f=(s=(r=(n=i.virtual)==null?void 0:n.disabled)==null?void 0:r.call(n,d))!=null?s:!1,order:h=null,...p}=e,m=LY(i.inputElement),g=i.virtual?i.activeOptionIndex===i.calculateIndex(d):i.activeOptionIndex===null?!1:((o=i.options[i.activeOptionIndex])==null?void 0:o.id)===u,b=i.isSelected(d),x=C.useRef(null),y=_d({disabled:f,value:d,domRef:x,order:h}),v=C.useContext(WY),w=ll(t,x,v?v.measureElement:null),S=wt(()=>{a.setIsTyping(!1),a.onChange(d)});Yn(()=>a.registerOption(u,y),[y,u]);let N=C.useRef(!(i.virtual||i.__demoMode));Yn(()=>{if(!i.virtual&&!i.__demoMode)return sa().requestAnimationFrame(()=>{N.current=!0})},[i.virtual,i.__demoMode]),Yn(()=>{if(N.current&&i.comboboxState===0&&g&&i.activationTrigger!==0)return sa().requestAnimationFrame(()=>{var P,F;(F=(P=x.current)==null?void 0:P.scrollIntoView)==null||F.call(P,{block:"nearest"})})},[x,g,i.comboboxState,i.activationTrigger,i.activeOptionIndex]);let j=wt(P=>{P.preventDefault(),P.button===eR.Left&&(f||(S(),$Y()||requestAnimationFrame(()=>m()),i.mode===0&&a.closeCombobox()))}),_=wt(()=>{if(f)return a.goToOption(ur.Nothing);let P=i.calculateIndex(d);a.goToOption(ur.Specific,P)}),k=aAe(),D=wt(P=>k.update(P)),T=wt(P=>{if(!k.wasMoved(P)||f||g)return;let F=i.calculateIndex(d);a.goToOption(ur.Specific,F,0)}),R=wt(P=>{k.wasMoved(P)&&(f||g&&(i.optionsPropsRef.current.hold||a.goToOption(ur.Nothing)))}),O=C.useMemo(()=>({active:g,focus:g,selected:b,disabled:f}),[g,b,f]),M={id:u,ref:w,role:"option",tabIndex:f===!0?void 0:-1,"aria-disabled":f===!0?!0:void 0,"aria-selected":b,disabled:void 0,onMouseDown:j,onFocus:_,onPointerEnter:D,onMouseEnter:D,onPointerMove:T,onMouseMove:T,onPointerLeave:R,onMouseLeave:R};return Ci()({ourProps:M,theirProps:p,slot:O,defaultTag:NPe,name:"Combobox.Option"})}let kPe=Ni(gPe),qY=Ni(vPe),YY=Ni(xPe),EPe=NIe,GY=Ni(CPe),ZY=Ni(jPe),_Pe=Object.assign(kPe,{Input:YY,Button:qY,Label:EPe,Options:GY,Option:ZY});function DPe({elementId:e}){const t=C.useRef(!1);return C.useEffect(()=>{if(t.current)return;const n=document.getElementById(e);return n&&(n.classList.add("semaphor-scope"),t.current=!0),()=>{n&&(n.classList.remove("semaphor-scope"),t.current=!1)}},[e]),null}const TPe=C.memo(({option:e,currentStyle:t})=>c.jsxs(ZY,{style:{borderRadius:t==null?void 0:t.controlInputRadius},value:e,className:"group flex cursor-default select-none items-start gap-2 rounded-sm px-3 py-1.5 data-[focus]:bg-muted",children:[c.jsx(Dr,{className:"invisible size-4 shrink-0 group-data-[selected]:visible"}),e.value]},e.id),(e,t)=>e.option.id===t.option.id&&e.option.value===t.option.value);function RPe({options:e,onChange:t,selectedOptions:n,multiple:r=!0,externalFilteredOptions:s,selectAllChecked:o,onSelectAllCheckedChange:i,inputClassName:a,renderFilterModeButton:l,showNegativeIndicator:u,isSearching:d,resultSource:f="local",searchError:h,query:p,onQueryChange:m,filterDataType:g,onEnterKey:b,activeFilterValue:x}){const[y,v]=C.useState(""),w=p!==void 0?p:y,S=m||v,N=ee(M=>M.themeStyle),j=s||e;function _(M,P){if(P)return"";const F=[">","<",">=","<=","="];return(g?Vi(g):!1)&&x&&F.includes(x.operation)?`${x.operation}${x.values[0]}`:M!=null&&M.length?M==null?void 0:M.map(H=>H.value).join(", "):""}function k(M){Array.isArray(M)||(M=[M]),t(M)}function D(){return d||j&&j.length>0?null:c.jsx("div",{className:"relative cursor-default select-none px-4 py-2",children:"No records found."})}function T(){return d?c.jsxs("div",{className:"flex items-center gap-2 border-b border-b-muted px-4 py-2 text-xs text-muted-foreground",children:[c.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Searching..."]}):h&&w?c.jsx("div",{className:"border-b border-b-muted px-4 py-2 text-xs text-amber-600",children:"Search unavailable. Showing available results."}):null}function R(){return w||!(e!=null&&e.length)?null:c.jsxs("div",{className:"border-b border-b-muted px-4 py-2 text-xs text-muted-foreground",children:["Showing top ",e.length," values. Type to search more..."]})}function O(){return!r||!(j!=null&&j.length)?null:c.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-b-muted px-4 py-2",children:[l==null?void 0:l(),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{children:"All"}),c.jsx(on,{className:"border-muted-foreground/50",checked:o,onCheckedChange:i})]})]})}return c.jsx(_Pe,{multiple:r,value:n,onChange:k,onClose:()=>{S("")},by:(M,P)=>Array.isArray(M)||Array.isArray(P)?!1:!M||!P?M===P:M.id===P.id,children:({open:M})=>c.jsxs("div",{children:[c.jsxs("div",{className:"relative flex items-center gap-0.5",children:[u&&c.jsx("div",{className:"h-8 w-0.5 bg-red-400"}),c.jsx(YY,{className:K("h-8 w-full rounded-sm border border-border bg-background py-1.5 pl-3 pr-8 text-sm","data-[focus]:outline-border-none focus:outline-none data-[focus]:outline-none data-[focus]:-outline-offset-2",a),style:{borderRadius:N==null?void 0:N.controlInputRadius},displayValue:P=>_(P,M),onChange:P=>S(P.target.value),onKeyDown:P=>{if(P.key==="Enter"&&b){const F=/^(>=|<=|>|<|=)/.test(w.trim()),V=g?Vi(g):!1;F&&V&&(P.preventDefault(),b()&&P.target.blur())}}}),c.jsx(qY,{className:"group absolute inset-y-0 right-0 rounded-sm bg-muted/40 px-2.5 transition-colors hover:bg-muted/60",children:c.jsx(Bs,{className:"size-4 text-muted-foreground transition-colors group-hover:text-foreground"})})]}),c.jsxs(GY,{anchor:"bottom",transition:!0,style:{borderRadius:N==null?void 0:N.controlInputRadius},className:Ou("mt-1 !max-h-60 w-[var(--input-width)] overflow-y-auto rounded-sm border border-border bg-background p-1 text-sm [--anchor-gap:var(--spacing-1)] empty:invisible","transition duration-100 ease-in data-[leave]:data-[closed]:opacity-0"),children:[M&&c.jsx(DPe,{elementId:"headlessui-portal-root"}),T(),R(),D(),O(),j==null?void 0:j.map(P=>c.jsx(TPe,{option:P,currentStyle:N},P.id))]})]})})}const SF=[{value:"=",label:"Equal to",symbol:"="},{value:">",label:"Greater than",symbol:">"},{value:">=",label:"Greater than or equal",symbol:"≥"},{value:"<",label:"Less than",symbol:"<"},{value:"<=",label:"Less than or equal",symbol:"≤"},{value:"between",label:"Between",symbol:"⟷"},{value:"not between",label:"Not Between",symbol:"⇎"}],MPe=new Set(["=",">","<",">=","<=","between","not between"]);function IPe(e){return MPe.has(e)?e:">="}function APe({filter:e}){var S;const[t,n]=C.useState(">="),[r,s]=C.useState(""),[o,i]=C.useState(""),[a,l]=C.useState(""),[u,d]=C.useState(!0),f=C.useRef(null),h=C.useRef(!1),[,p]=C.useTransition(),m=vm(r,300),g=vm(o,300),b=vm(a,300),x=ee(N=>N.filterValues),y=ee(N=>N.themeStyle),{addOrUpdateFilterValue:v,removeFilterValues:w}=Jt();return C.useEffect(()=>()=>{f.current=null,h.current=!1},[]),C.useEffect(()=>{const N=x==null?void 0:x.find(j=>j.filterId===e.id);if(N&&N.operation!=="in"){const j=IPe(N.operation);if(f.current!==j&&(n(j),f.current=j,h.current=!1),j==="between"||j==="not between"){const k=N.values[0],D=N.values[1];i(k!=null?String(k):""),l(D!=null?String(D):""),s("")}else{const k=N.values[0];s(k!=null?String(k):""),i(""),l("")}}else f.current!==null&&(s(""),i(""),l(""),!h.current&&f.current!==t&&(n(">="),h.current=!1),f.current=null),d(!1)},[x,e.id]),C.useEffect(()=>{u&&(t==="between"||t==="not between"?g===o&&b===a&&d(!1):m===r&&d(!1))},[u,t,r,m,o,a,g,b]),C.useEffect(()=>{if(!u)if(t==="between"||t==="not between"){const N=g&&g.trim()!=="",j=b&&b.trim()!=="";if(!N||!j){!N&&!j&&(p(()=>{w(e.id)}),f.current=t);return}const _=Number(g),k=Number(b);if(isNaN(_)||isNaN(k))return;const D={filterId:e.id,connectionType:e.database==="NA"?"api":"database",name:e.column,valueType:ri(e),operation:t,values:[_,k]};p(()=>{v(D)}),f.current=t}else{if(!m||m.trim()===""){p(()=>{w(e.id)}),f.current=null;return}const N=Number(m);if(isNaN(N))return;const j={filterId:e.id,connectionType:e.database==="NA"?"api":"database",name:e.column,valueType:ri(e),operation:t,values:[N]};p(()=>{v(j)}),f.current=t}},[t,m,g,b,e.id,e.column,e.database,u,v,w,e]),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(at,{value:t,onValueChange:N=>{h.current=!0,n(N)},children:[c.jsx(st,{className:"h-8 w-16",style:{borderRadius:y==null?void 0:y.controlInputRadius},children:c.jsx("span",{className:"font-mono text-base",children:(S=SF.find(N=>N.value===t))==null?void 0:S.symbol})}),c.jsx(ot,{children:SF.map(N=>c.jsx(fe,{value:N.value,children:c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"font-mono",children:N.symbol}),c.jsx("span",{children:N.label})]})},N.value))})]}),t==="between"||t==="not between"?c.jsxs(c.Fragment,{children:[c.jsx(Hn,{type:"number",placeholder:"Min",value:o,onChange:N=>i(N.target.value),className:"h-8 flex-1",style:{borderRadius:y==null?void 0:y.controlInputRadius}}),c.jsx(Hn,{type:"number",placeholder:"Max",value:a,onChange:N=>l(N.target.value),className:"h-8 flex-1",style:{borderRadius:y==null?void 0:y.controlInputRadius}})]}):c.jsx(Hn,{type:"number",placeholder:"Value",value:r,onChange:N=>s(N.target.value),className:"h-8 flex-1",style:{borderRadius:y==null?void 0:y.controlInputRadius}})]})}function PPe({filter:e}){const t=e.searchMode==="numeric",n=ee(v=>v.themeStyle),{filteredRecords:r,isSingleSelect:s,allSelected:o,handleChange:i,handleSelectAll:a,handleApplyOperatorExpression:l,query:u,setQuery:d,isLoading:f,isFetching:h,isError:p,selectedRecords:m,isSearching:g,searchError:b,resultSource:x,activeFilterValue:y}=A1(e,{enableServerSearch:!0,searchDebounceMs:300,minSearchLength:2,searchThreshold:5});return f||h?c.jsx(Hi,{style:{borderRadius:n==null?void 0:n.controlInputRadius},className:"h-8 w-full bg-foreground/10"}):p?c.jsx("div",{className:"flex h-8 w-full items-center bg-muted px-2 text-sm",children:"Error"}):t?c.jsx(APe,{filter:e}):c.jsx(RPe,{showNegativeIndicator:e.operation==="not in",renderFilterModeButton:()=>c.jsx(OPe,{filter:e}),inputClassName:"h-8",options:r,selectedOptions:m,onChange:i,multiple:!s,selectAllChecked:o,onSelectAllCheckedChange:a,isSearching:g,resultSource:x,searchError:b,query:u,onQueryChange:d,filterDataType:e.dataType,activeFilterValue:y,onEnterKey:l})}function OPe({filter:e}){const t=e.operation==="in"?"include":"exclude",{setFilterMode:n,setFilterDefaultValues:r}=Jt(),s=ee(d=>d.isDashboardEditing),o=ee(d=>{var f;return(f=d.filterValues)==null?void 0:f.find(h=>h.filterId===e.id)});function i(){t==="include"?n(e.id,"exclude"):n(e.id,"include")}function a(){o!=null&&o.values&&r(e.id,o.values)}const l=(o==null?void 0:o.values)&&o.values.length>0,u=e.defaultValues&&e.defaultValues.length>0;return c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(se,{onClick:i,variant:"secondary",size:"sm",className:K("h-6 text-xs hover:underline",{}),children:dw(t)}),s&&c.jsx(se,{onClick:a,variant:u?"default":"ghost",size:"sm",className:K("h-6 text-xs",{"opacity-50":!l}),disabled:!l,title:u?"Update default values":l?"Set current selection as default":"Select values to set as default",children:"Default"})]})}function FPe({filter:e}){var o;const{filteredRecords:t,handleChange:n,selectedRecords:r}=A1(e);function s(i){n([{value:i,id:i}])}return c.jsx(ra,{onValueChange:s,value:((o=r==null?void 0:r[0])==null?void 0:o.value)||"",className:"mt-2 flex gap-3 overflow-x-auto",children:t==null?void 0:t.map(i=>c.jsxs("div",{className:"flex gap-2",children:[c.jsx(vr,{value:i.value,id:"r1"}),c.jsx(le,{className:"text-muted-foreground",htmlFor:"r1",children:i.value})]},i.value))})}function $Pe({filter:e}){var d;const t=ee(f=>f.themeStyle),{filteredRecords:n,handleChange:r,selectedRecords:s,isLoading:o,isFetching:i,isError:a}=A1(e),l=n&&n.length>10;function u(f){r([{value:f,id:f}])}return o||i?c.jsx(Hi,{style:{borderRadius:t==null?void 0:t.controlInputRadius},className:"h-8 w-full bg-foreground/10"}):a?c.jsx("div",{className:"flex h-8 w-full items-center bg-muted px-2 text-sm",children:"Error loading filter options"}):c.jsxs("div",{className:"mt-2 space-y-2",children:[l&&c.jsx("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:c.jsx(fr,{children:c.jsxs(Dn,{delayDuration:0,children:[c.jsx(Tn,{asChild:!0,children:c.jsxs("div",{className:"flex items-center gap-1 rounded-sm bg-amber-500/10 px-2 py-1",children:[c.jsx(wr,{className:"h-3 w-3 text-amber-600"}),c.jsxs("span",{className:"text-amber-600",children:["Many options (",n.length,")"]})]})}),c.jsx($n,{side:"bottom",className:"max-w-xs",children:c.jsxs("p",{className:"text-xs",children:["This filter has ",n.length," options. Consider using a dropdown for better usability with many options."]})})]})})}),c.jsx(js,{value:((d=s==null?void 0:s[0])==null?void 0:d.value)||"",onValueChange:u,className:"w-full",children:c.jsx(os,{className:"h-auto max-h-[6rem] flex-wrap justify-start overflow-x-auto",children:n==null?void 0:n.map(f=>c.jsx(Qt,{value:f.value,children:f.value},f.value))})})]})}function nR({filter:e}){return dd(e.dataType)?c.jsx(kMe,{filter:e}):e.uiType==="radio"&&e.type==="single"?c.jsx(FPe,{filter:e}):e.uiType==="tabs"&&e.type==="single"?c.jsx($Pe,{filter:e}):c.jsx(PPe,{filter:e})}function LPe({frame:e}){const[t,n]=C.useState(!1),r=e==null?void 0:e.cards[0],{data:s,isPending:o,isError:i}=Jl(r),a=e==null?void 0:e.cards[1],{data:l,isLoading:u,isFetching:d}=Jl(a);return(a==null?void 0:a.type)!=="text"?c.jsx(Sg,{card:r,data:(s==null?void 0:s.records)||[],isPending:o,isError:i}):c.jsxs(qs,{className:K("group relative overflow-y-auto",t?"m-4":"mx-0"),children:[t?c.jsx("div",{className:"overflow-y-auto break-words p-1",children:c.jsx(gh,{card:a,data:(l==null?void 0:l.records)||[],isLoading:!1})}):c.jsx(Sg,{card:r,data:(s==null?void 0:s.records)||[],isPending:o,isError:i}),c.jsx("div",{className:K("fixed z-10",{"invisible bottom-4 right-4 group-hover:visible":t,"right-6 top-6":!t}),children:c.jsx($b,{disabled:u||d,className:K("h-7 p-1"),pressed:t,onPressedChange:n,"aria-label":"Toggle bold",children:t?c.jsx(Rne,{className:"size-4 text-muted-foreground/70"}):c.jsx(Mne,{className:"size-4 text-muted-foreground/70"})})})]})}function Tv(e){return{clickFilter:Bl,drillToDetail:tb,drillThrough:Cy,drillToURL:eb,drillDown:Pne,drillUp:One,dynamicDrill:rl,inlineDrill:bw}[e]||Bl}function Dd(e){return{clickFilter:"Filter Dashboard",drillToDetail:"Show Details",drillThrough:"Navigate to Dashboard",drillToURL:"Open External Link",drillDown:"Drill Down",drillUp:"Drill Up",dynamicDrill:"Explore Field",inlineDrill:"Drill"}[e]||"Interaction"}function zPe(e,t,n,r,s){const o=Tv(e.mode),i=e.label||Dd(e.mode),a=BPe(e,t,n,r,s);return{label:i,icon:o,targetInfo:a,interaction:e}}function BPe(e,t,n=0,r,s){var o,i,a,l,u,d;switch(e.mode){case"clickFilter":{if((o=e.applyToCardIds)!=null&&o.length){const f=e.applyToCardIds.length;return`Apply to ${f} ${f===1?"card":"cards"}`}return(i=e.excludeCardIds)!=null&&i.length?"Apply to all cards":"Apply to other cards"}case"drillToDetail":{if(e.targetInsightId)return"Drill into Insight";const f=((a=e.detailFields)==null?void 0:a.length)||0;return f>0?`Show ${f} detail ${f===1?"field":"fields"}`:"Show detail table"}case"drillThrough":return e.targetDashboardId,"Navigate to dashboard";case"drillToURL":{if(e.urlTemplate)try{return`Open ${new URL(e.urlTemplate).hostname}`}catch{return"Open external link"}return"Open external link"}case"drillDown":{if(e.hierarchyId&&t){const f=t.find(h=>h.id===e.hierarchyId);if(f&&f.steps.length>0){let h;if((f.type==="date"||f.baseField)&&r&&f.baseField){const p=yE(f,r,s),m=xE(f,p);h=m==null?void 0:m.field}else h=(l=f.steps[n])==null?void 0:l.field;return h?h.label:n>=f.steps.length?"End of path":f.label||"Drill by hierarchy"}}return"Drill to next level"}case"drillUp":{if(n>0&&e.hierarchyId&&t){const f=t.find(h=>h.id===e.hierarchyId);if(f&&f.steps.length>0){const h=(u=f.steps[n-2])==null?void 0:u.field;return h?`Back to ${h.label}`:`Back to All: ${f.label||"Data"}`}}return"Go back one level"}case"dynamicDrill":{if(e.drillField)return`Drill into ${e.drillField.label} data`;if((d=e.availableFields)!=null&&d.length){const f=e.availableFields.length;return`Choose from ${f} ${f===1?"dimension":"dimensions"}`}return"Explore dimension"}case"inlineDrill":{const f=e.inlineLimit||100,h=e.displayMode||"table";return`Show ${f} records as ${h}`}default:return""}}function VPe(e,t,n,r,s){return e.map(o=>zPe(o,t,n,r,s))}function HPe({open:e,onOpenChange:t,position:n,interactions:r,selectedConditions:s,onSelectInteraction:o,drillHierarchies:i,cardId:a,card:l}){const{currentDepth:u,breadcrumbs:d}=Ut(w=>{var S,N,j;return{currentDepth:a?((N=(S=w.interactionStates[a])==null?void 0:S.breadcrumbs)==null?void 0:N.length)??0:0,breadcrumbs:a?((j=w.interactionStates[a])==null?void 0:j.breadcrumbs)??[]:[]}}),f=E.useMemo(()=>VPe(r,i,u,l,d),[r,i,u,l,d]),h=E.useMemo(()=>{if(s.length===0)return"";const w=s[0];if(w.label){const S=w.label.split(/[=><]/);if(S.length>1)return S[1].trim()}return String(w.value)},[s]);if(E.useEffect(()=>{if(!e)return;const w=S=>{S.key==="Escape"&&t(!1)};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[e,t]),!e||!n)return null;const p=280,m=80+f.length*60,g=window.innerWidth,b=window.innerHeight;let x=n.x,y=n.y+8;x+p>g&&(x=Math.max(8,g-p-8)),y+m>b&&(y=Math.max(8,n.y-m-8));const v=c.jsxs("div",{className:"semaphor-scope",style:{position:"fixed",inset:0,pointerEvents:"none",background:"transparent"},children:[c.jsx("div",{className:"fixed inset-0",style:{zIndex:50,pointerEvents:"auto",background:"transparent"},onClick:()=>t(!1),"aria-hidden":"true"}),c.jsxs("div",{className:K("fixed rounded-lg border bg-popover shadow-lg","animate-in fade-in-0 zoom-in-95"),style:{left:`${x}px`,top:`${y}px`,zIndex:51,width:`${p}px`,maxHeight:"400px",pointerEvents:"auto"},role:"menu","aria-label":"Select interaction",children:[h&&c.jsxs("div",{className:"border-b px-4 py-3",children:[c.jsx("p",{className:"text-xs text-muted-foreground",children:"Selected"}),c.jsx("p",{className:"text-sm font-medium",children:h})]}),c.jsx("div",{className:"max-h-80 overflow-y-auto py-1",children:f.map((w,S)=>{var _;const N=w.icon,j=w.interaction.mode==="dynamicDrill"&&(S===0||((_=f[S-1])==null?void 0:_.interaction.mode)!=="dynamicDrill");return c.jsxs(E.Fragment,{children:[j&&c.jsx("div",{className:"border-t px-4 py-2",children:c.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"⚡ Explore Other Fields"})}),c.jsxs("button",{className:K("flex w-full items-start gap-3 px-4 py-3","hover:bg-accent hover:text-accent-foreground","cursor-pointer transition-colors","border-b text-left last:border-b-0"),onClick:()=>{o(w.interaction),t(!1)},role:"menuitem",children:[c.jsx("div",{className:"mt-0.5 flex-shrink-0",children:c.jsx(N,{className:"h-4 w-4 text-muted-foreground"})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("p",{className:"mb-1 text-sm font-medium leading-none",children:w.label}),w.targetInfo&&c.jsx("p",{className:"text-xs text-muted-foreground",children:w.targetInfo})]})]})]},S)})})]})]});return _n.createPortal(v,document.body)}function UPe(e){const t=C.useRef([]),n=C.useRef(null),r=C.useRef(null),o=ni(e.interactionConfig).some(h=>h.mode==="clickFilter"&&h.trigger!==void 0),i=im(h=>h.registerClearBlurCallback),a=im(h=>h.unregisterCard);C.useEffect(()=>{const h=()=>{r.current&&f(r.current)};return i(e.id,h),()=>{a(e.id)}},[e.id,i,a]);function l({chart:h,selectedSegments:p,storedOriginalColorsRef:m}){if(!h||!h.canvas||!h.canvas.ownerDocument){console.warn("Chart or canvas is null when trying to toggle blur segments");return}const g=h.data.datasets;m.current||(m.current=g.map((x,y)=>h.getDatasetMeta(y).data.map(w=>w.options.backgroundColor)));const b=m.current;g.forEach((x,y)=>{const v=b[y];if(p.length===0){x.backgroundColor=[...v];return}x.backgroundColor=v.map((w,S)=>p.some(j=>j.datasetIndex===y&&j.dataIndex===S)?w:u(w,.2))});try{h.update()}catch(x){console.warn("Failed to update chart during blur toggle:",x)}}function u(h,p=.2){if(h.startsWith("rgba"))return h.replace(/[\d.]+\)$/g,`${p})`);if(h.startsWith("#")){const m=parseInt(h.slice(1,3),16),g=parseInt(h.slice(3,5),16),b=parseInt(h.slice(5,7),16);return`rgba(${m}, ${g}, ${b}, ${p})`}return h}function d(h,p){var v;if(!o||!p)return;r.current=p;const m=p.getElementsAtEventForMode(h,"nearest",{intersect:!0},!0);if(!m.length)return;const{datasetIndex:g,index:b}=m[0],x={datasetIndex:g,dataIndex:b};if(((v=h.native)==null?void 0:v.shiftKey)||h.shiftKey){const w=t.current.findIndex(S=>S.datasetIndex===g&&S.dataIndex===b);w>=0?t.current.splice(w,1):t.current.push(x)}else{const w=t.current.length===1&&t.current[0].datasetIndex===g&&t.current[0].dataIndex===b;t.current=w?[]:[x]}l({chart:p,selectedSegments:t.current,storedOriginalColorsRef:n})}function f(h){h&&(t.current=[],n.current&&l({chart:h,selectedSegments:[],storedOriginalColorsRef:n}))}return{handleChartClick:d,clearBlur:f}}function WPe({resolvedCardConfig:e,card:t,records:n,chart:r,clickEvent:s}){var u,d,f,h,p,m,g,b,x,y;const o=r==null?void 0:r.getElementsAtEventForMode(s,"nearest",{intersect:!0},!0);if(!o.length)return;const i=o[0].datasetIndex,a=o[0].index,l=(d=(u=o[0].element)==null?void 0:u.$context)==null?void 0:d.raw;console.log("datasetIndex",i),console.log("clickIndex",a),console.log("value",l);try{if(!(n!=null&&n.length))return;const{keys:v}=hr(n),{groupByColumns:w=[],pivotByColumns:S=[],metricColumns:N=[]}=e||t.config,j=_=>w.find(k=>k.label===_)||S.find(k=>k.label===_)||N.find(k=>k.label===_);if(t.type==="map"){const _=v[0],k=((h=(f=l==null?void 0:l.feature)==null?void 0:f.properties)==null?void 0:h.name)||((m=(p=l==null?void 0:l.feature)==null?void 0:p.properties)==null?void 0:m.NAME),D=j(_);return!D||k==null?void 0:{conditions:[{field:D,operator:"=",value:k}]}}if(["pie","funnel","doughnut"].includes(t.type)){const _=v[0],k=v==null?void 0:v[1+i],D=j(_),T=j(k),R=(g=n==null?void 0:n[a])==null?void 0:g[_];if(!D||R==null){console.log("no dim field or value",_,R);return}return{conditions:[{field:D,operator:"=",value:R}],metrics:T?[{field:T,value:l}]:void 0}}if(["stackedBar","bar","line"].includes(t.type)){const _=v[0],k=j(_),D=(b=n==null?void 0:n[a])==null?void 0:b[_];if(!k||D==null){console.log("no dim field or value for stacked bar",_,D);return}const T=N[i]||N[0];if(!T){console.log("no metric field found");return}const R=S[0],M=Object.keys(n[0]).filter(H=>H!==_)[i],F=(M?(x=n==null?void 0:n[a])==null?void 0:x[M]:(y=n==null?void 0:n[a])==null?void 0:y[T.label])??l,V=[{field:k,operator:"=",value:D}];return R&&M&&V.push({field:R,operator:"=",value:M}),{conditions:V,metrics:[{field:T,value:F}]}}}catch(v){console.error("getClickContextFromChart error",v)}}function qPe(e){return e&&typeof e=="object"&&"field"in e&&"operator"in e}function YPe(e){return e&&typeof e=="object"&&"filterId"in e&&"operation"in e&&"values"in e}function KY({filters:e,filterDefinitions:t,contextMode:n,className:r,showLabel:s=!0,labelText:o="Applied Filters:",icon:i}){if(!e||e.length===0)return n==="none"?c.jsx("div",{className:"px-6 pb-4",children:c.jsx("span",{className:"text-xs text-muted-foreground",children:"No filters applied"})}):null;const l=e.map(u=>{var d,f;if(qPe(u))return{fieldName:((d=u.field)==null?void 0:d.label)||((f=u.field)==null?void 0:f.name)||"Unknown",operator:u.operator,value:ZPe(u)};if(YPe(u)){const h=t==null?void 0:t.find(p=>p.id===u.filterId);return{fieldName:(h==null?void 0:h.title)||u.name,operator:u.operation,value:GPe(u)}}else return{fieldName:"Unknown",operator:"=",value:String(u)}}).reduce((u,d)=>(u[d.fieldName]||(u[d.fieldName]=[]),u[d.fieldName].push(d),u),{});return c.jsxs("div",{className:r||"px-6 pb-4 border-b",children:[c.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s&&i&&c.jsxs("div",{className:"flex items-center gap-2 text-foreground/80",children:[i,c.jsx("span",{className:"text-sm font-medium whitespace-nowrap",children:o})]}),s&&!i&&c.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:o}),c.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(l).map(([u,d])=>c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsxs("span",{className:"text-sm font-medium",children:[u,":"]}),d.map((f,h)=>c.jsx(Pe,{variant:"secondary",className:"border border-primary/20 bg-primary/10 text-primary",children:f.value},`${u}-${h}`))]},u))})]}),n&&c.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[n==="interactionFilters"&&c.jsx("span",{children:"Showing data filtered by interaction only"}),n==="full"&&c.jsx("span",{children:"Showing data with all dashboard filters + interaction filters"}),n==="none"&&c.jsx("span",{children:"Showing all data (no filters applied)"})]})]})}function GPe(e){const{values:t,operation:n}=e;return!t||t.length===0?"":n==="="||n==="!="||n===">"||n==="<"||n===">="||n==="<="?String(t[0]):n==="in"||n==="not in"?t.map(r=>String(r)).join(", "):(n==="between"||n==="not between")&&t.length===2?`${t[0]} - ${t[1]}`:String(t[0])}function ZPe(e){const{operator:t,value:n}=e;if(e.label){const r=e.label.split(/[=><]/);if(r.length>1)return r[1].trim()}switch(t){case"=":return String(n);case"!=":return`≠ ${n}`;case">":return`> ${n}`;case"<":return`< ${n}`;case">=":return`≥ ${n}`;case"<=":return`≤ ${n}`;case"in":return Array.isArray(n)?n.join(", "):String(n);case"not in":return`not ${Array.isArray(n)?n.join(", "):n}`;case"contains":return`contains ${n}`;case"startsWith":return`starts with ${n}`;case"endsWith":return`ends with ${n}`;case"between":return Array.isArray(n)?`between ${n[0]} and ${n[1]}`:String(n);case"not between":return Array.isArray(n)?`not between ${n[0]} and ${n[1]}`:String(n);case"isNull":return"is null";case"isNotNull":return"is not null";default:return String(n)}}function KPe({cardId:e,className:t}){const n=Ut(d=>d.interactionStates[e]),r=Ut(d=>d.popInteractionStep),s=Ut(d=>d.resetInteractionState),o=(n==null?void 0:n.breadcrumbs)??[];if(n==null||n.hierarchyId,o.length===0)return null;const i=d=>{const f=o.length-d-1;for(let h=0;h<f;h++)r(e)},a=()=>{s(e)},l=d=>(d.sourceFilterGroups[0],d.toField?d.toField.label||d.toField.name:"Drill Step"),u=d=>{const f=d.sourceFilterGroups.flatMap(h=>h.filters);return c.jsxs("div",{className:"max-w-xs space-y-2 text-sm",children:[f.length>0&&c.jsx(KY,{filters:f,className:"pb-2",labelText:"Drill Down Filters:",icon:c.jsx(Lne,{className:"h-4 w-4 text-foreground/80"})}),d.granularity&&c.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[c.jsx(ts,{className:"h-4 w-4 text-foreground/80"}),c.jsxs("span",{className:"text-sm font-medium text-foreground/80",children:["Granularity: ",d.granularity]})]}),d.metric&&c.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[c.jsx(Nne,{className:"h-4 w-4 text-foreground/80"}),c.jsxs("span",{className:"text-sm font-medium text-foreground/80",children:["Value:"," ",d.metric.formattedValue||d.metric.value]})]})]})};return c.jsx(fr,{children:c.jsxs("div",{className:K("flex items-center gap-1 text-sm",t),children:[c.jsx(Dn,{children:c.jsx(Tn,{asChild:!0,children:c.jsx("button",{className:"flex items-center p-0 text-muted-foreground hover:text-foreground",onClick:a,"aria-label":"Reset drill path",children:c.jsx(FE,{className:"h-3.5 w-3.5"})})})}),c.jsx(Za,{className:"ml-0.5 h-3 w-3 text-muted-foreground"}),c.jsx("div",{className:"flex items-center",children:o.map((d,f)=>c.jsxs("div",{className:"flex items-center",children:[f>0&&c.jsx(Za,{className:"mx-1 h-3 w-3 text-muted-foreground"}),c.jsxs(Dn,{delayDuration:0,children:[c.jsx(Tn,{asChild:!0,children:c.jsx(se,{variant:"link",size:"sm",className:"h-6 px-1 text-muted-foreground no-underline hover:text-foreground hover:no-underline",onClick:()=>i(f),"aria-label":`Go back to: ${l(d)}`,children:l(d)})}),c.jsx(HT,{className:"ml-4",side:"bottom",children:u(d)})]})]},f))})]})})}function XPe(e){switch(e){case"content-only":return{showHeader:!1,showTitle:!1,showDescription:!1,showTabs:!1,showFooter:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1};case"print":return{showHeader:!0,showTitle:!0,showDescription:!0,showTabs:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1,showTableToolbar:!1,showColumnSettings:!1};case"embed":return{showHeader:!1,showTitle:!0,showDescription:!1,showTabs:!0,showFooter:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1};case"table-print":return{showHeader:!1,showTitle:!0,showDescription:!1,showTabs:!1,showFooter:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1,showPagination:!1,showTableToolbar:!1,showColumnSettings:!1};case"full":default:return{showHeader:!0,showTitle:!0,showDescription:!0,showTabs:!0,showFooter:!0,showFilters:!0,showBreadcrumbs:!0,showRefreshIndicator:!0,showFilterInfo:!0}}}function rR({children:e,displayPreferences:t={mode:"full"},currentUser:n}){const r=C.useMemo(()=>{const s=t.mode||"full",o=XPe(s),i=lU(n||null),a={mode:s,overrides:{...o,...i,...t.overrides}};return{displayPreferences:a,shouldShowElement:u=>{var d;return((d=a.overrides)==null?void 0:d[u])??!0}}},[t,n]);return c.jsx($9.Provider,{value:r,children:e})}function CF({card:e,frame:t}){var ue,ae,Se,ye,Fe,Ye,me,Me,Ne;const{customCards:n,placeholders:r,tokenProps:s}=Xe(),{shouldShowElement:o}=hc(),i=Ut(ge=>ge.interactionStates[e.id]),a=((ue=i==null?void 0:i.breadcrumbs)==null?void 0:ue.length)>0,l=ee(ge=>ge.themeStyle),u=ee(ge=>ge.selectedSheetId),d=ee(ge=>ge.isDashboardEditing);ee(ge=>ge.selectedLensId);const f=ee(ge=>ge.dashboard.filters),h=f==null?void 0:f.find(ge=>ge.id===t.filterId&&!ge.hide),{setCardTitle:p,setCardDescription:m,setSelectedFrameId:g,updateFilter:b}=Jt(),{updateFrame:x}=Jt(),{handleChartClick:y}=UPe(e),v=o("showHeader")&&(((ae=e.customCardPreferences)==null?void 0:ae.showCardHeader)??!0),{isError:w,isLoading:S,isFetching:N,cfg:j,isPending:_,data:k,handleDatapointClick:D,pagination:T,comparisonMetadata:R}=Sb(e),[O,M]=C.useState({open:!1,position:null,interactions:[],context:null}),{breadcrumbs:P,hierarchyId:F}=Ut(ge=>{var _e,re;return{breadcrumbs:((_e=ge.interactionStates[e.id])==null?void 0:_e.breadcrumbs)??[],hierarchyId:(re=ge.interactionStates[e.id])==null?void 0:re.hierarchyId}}),V=(ge,_e,re)=>{var Qe;const ce=P.length>0?[{mode:"drillUp",trigger:(Qe=ge[0])==null?void 0:Qe.trigger,label:"Drill Up",hierarchyId:F}]:[],xe=[];for(const ct of ge)if(ct.mode==="dynamicDrill"&&ct.availableFields){const ft=ct.availableFields.filter(At=>!P.some(Ce=>{var yt;return((yt=Ce.toField)==null?void 0:yt.id)===At.id}));for(const At of ft)xe.push({mode:"dynamicDrill",trigger:ct.trigger,drillField:At,label:At.label,availableFields:ct.availableFields})}const Ie=ge.filter(ct=>ct.mode!=="dynamicDrill"),Oe=[...ce,...Ie,...xe];M({open:!0,position:re||{x:0,y:0},interactions:Oe,context:_e})},{handlePointerInteraction:H,applySelectedInteraction:L}=m$(e,t.id,u||"",V),I=vE(e),B=C.useMemo(()=>{var ge;return e.type!=="pivotTable"||!((ge=k==null?void 0:k.records)!=null&&ge.length)?null:{records:k.records,columnSubtotalMeta:k.columnSubtotalMeta,subtotalColumns:k.subtotalColumns||[],pivotSchema:k.pivotSchema||[],groupByColumns:k.groupByColumns}},[e.type,k==null?void 0:k.records,k==null?void 0:k.columnSubtotalMeta,k==null?void 0:k.subtotalColumns,k==null?void 0:k.pivotSchema,k==null?void 0:k.groupByColumns]),z=Zh(e,B),A=(ge,_e)=>{const re={...e,paginationConfig:{page:ge+1,pageSize:_e}},ce={...t,cards:t.cards.map(xe=>xe.id===e.id?re:xe)};u&&x(u,ce)},W=ge=>{var xe,Ie;const _e=pW(ge,(xe=e.config)==null?void 0:xe.metricColumns,(Ie=e.config)==null?void 0:Ie.groupByColumns),re={...e,config:{...e.config||{},sortByColumns:_e}},ce={...t,cards:t.cards.map(Oe=>Oe.id===e.id?re:Oe)};u&&x(u,ce)};function q(ge,_e){ge.stopPropagation();const re=WPe({resolvedCardConfig:I,card:e,records:(k==null?void 0:k.records)||[],chart:_e,clickEvent:ge.nativeEvent});if(!re)return;const ce=ni(e.interactionConfig),xe=aw(ce,re),Ie=xe.length===1&&xe[0].mode==="clickFilter",Oe=xe.some(ft=>ft.mode==="dynamicDrill"),Qe=xe.length>1||Oe;ge.button===0&&Ie&&!Qe&&y(ge.nativeEvent,_e);const ct={shift:ge.shiftKey,ctrl:ge.ctrlKey,meta:ge.metaKey};ge.button===0?H({context:re,gesture:"leftClick",modifierKeys:ct,position:{x:ge.clientX,y:ge.clientY}}):ge.button===2&&H({context:re,gesture:"rightClick",modifierKeys:ct,position:{x:ge.clientX,y:ge.clientY}})}function Y(){var ge,_e,re;if(n&&n.length>0){const ce=n.find(xe=>xe.cardId===e.id);if(ce&&ce.replaceDefault){const xe=ce.content;if(xe)return c.jsx(xe,{card:e})}}if(e.type==="kpi"){if(((ge=t==null?void 0:t.cards)==null?void 0:ge.length)===1)return c.jsx(Sg,{card:e,data:w?[]:(k==null?void 0:k.records)||[],isPending:_,isError:w});if(((_e=t==null?void 0:t.cards)==null?void 0:_e.length)>1)return c.jsx(LPe,{frame:t})}return e.type==="text"&&((re=t==null?void 0:t.cards)==null?void 0:re.length)===1?c.jsx(qs,{className:"my-4 overflow-y-auto break-words px-4",children:c.jsx(gh,{isLoading:S||N,card:e,data:(k==null?void 0:k.records)||[]})}):ne}function U(){if(w)return c.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[c.jsx(UE,{className:"size-8 text-destructive"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Error fetching data. Check your card settings."})]});if((S||N)&&e.type!=="table")return c.jsx("div",{className:"flex h-full w-full items-center justify-center",children:c.jsx(td,{size:"md",color:"muted","aria-label":"Loading data"})});if(k!=null&&k.records&&(k==null?void 0:k.records.length)===0)return r!=null&&r.NoRecords?c.jsx("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:r.NoRecords}):c.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[c.jsx(qE,{className:"size-8 text-muted-foreground"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"No results to display"})]});if(e.type==="table")return c.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:c.jsx(Rb,{card:e,data:(k==null?void 0:k.records)||[],paginationMetadata:T,onPaginationChange:A,onSortChange:W,isLoading:S||N,frameId:t.id,sheetId:u||"",onMultipleInteractions:V})});if(e.type==="pivotTable"&&z)return c.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:c.jsx(Ib,{card:e,data:z.data,options:z.options,onAggregationChange:ge=>{const _e=Ck(ge,e.config),re={...e,config:_e},ce={...t,cards:t.cards.map(xe=>xe.id===e.id?re:xe)};u&&x(u,ce)},onAggregationLabelChange:ge=>{const _e=uY(ge,e.config),re={...e,config:_e},ce={...t,cards:t.cards.map(xe=>xe.id===e.id?re:xe)};u&&x(u,ce)}})});if(e.type==="aggregateTable")return c.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:c.jsx(j1,{card:e,data:(k==null?void 0:k.records)||[],groupByColumns:k==null?void 0:k.groupByColumns,pivotSchema:k==null?void 0:k.pivotSchema,paginationMetadata:T,onPaginationChange:A,onAggregationChange:ge=>{const _e=Ck(ge,e.config),re={...e,config:_e},ce={...t,cards:t.cards.map(xe=>xe.id===e.id?re:xe)};u&&x(u,ce)},isLoading:S||N})});if(e.type==="text")return c.jsx(qs,{className:"overflow-y-auto break-words pr-2",children:c.jsx(gh,{isLoading:S||N,card:e,data:(k==null?void 0:k.records)||[]})});if(e.type==="custom")return c.jsx(Nc,{FallbackComponent:_1,children:c.jsx(PT,{frame:t,card:e})});if(n&&n.length>0){const ge=n.find(_e=>_e.cardId===e.id);if(ge&&ge.content){const _e=ge.content;return c.jsx(_e,{card:e})}}if(j)return c.jsx(Mb,{cfg:j,onChartClick:q,onDatapointClick:D})}function $(){if(n&&n.length>0){const ge=n.find(_e=>_e.cardId===e.id);if(ge&&ge.footer){const _e=ge.footer;if(_e)return c.jsx(_e,{card:e})}}return null}function G(){var re;const ge=t.cards.filter(ce=>{var xe;return!((xe=ce.tabTitle)!=null&&xe.endsWith("__Header"))&&(ce.displayTab===!0||ce.displayTab===void 0)}),_e=l==null?void 0:l.controlInputRadius;return c.jsx(js,{value:t.activeCardId,className:"flex items-center justify-end gap-3",onValueChange:ce=>{const xe={...t,activeCardId:ce};x(u,xe)},children:c.jsx(os,{style:{borderRadius:l==null?void 0:l.controlInputRadius},className:"flex-end flex h-9 flex-wrap items-center border border-border bg-background p-0",children:(re=t.cards.filter(ce=>{var xe;return!((xe=ce.tabTitle)!=null&&xe.endsWith("__Header"))&&(ce.displayTab===!0||ce.displayTab===void 0)}))==null?void 0:re.map((ce,xe)=>c.jsx(Qt,{className:K("h-full items-center rounded-none data-[state=active]:bg-muted data-[state=active]:shadow-none",{"border-r":xe!==ge.length-1}),style:{borderTopLeftRadius:xe===0?_e:0,borderTopRightRadius:xe===ge.length-1?_e:0,borderBottomLeftRadius:xe===0?_e:0,borderBottomRightRadius:xe===ge.length-1?_e:0},value:ce.id,children:ce.tabTitle||ce.title},ce.id))})})}function Z(){var _e,re,ce,xe;let ge=t.cards.find(Ie=>Ie.type==="kpi"&&Ie.tabTitle===`${e.tabTitle}__Header`);return ge||(ge=t.cards.find(Ie=>Ie.type==="kpi"&&Ie.tabTitle==="All__Header")),ge?c.jsx("div",{className:"flex items-end gap-2",children:c.jsx(yMe,{renderFilterInfo:()=>{var Ie,Oe,Qe,ct;return o("showFilterInfo")&&((Oe=(Ie=e.preferences)==null?void 0:Ie.displayOptions)==null?void 0:Oe.showFilterInfo)!==!1?c.jsx(Sk,{cardId:e.id,cardFilters:(Qe=e.config)==null?void 0:Qe.filters,cardFilterCount:Ev(((ct=e.config)==null?void 0:ct.filters)||null)}):null},card:ge})}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{role:"card-title-container",className:"flex h-7 items-center gap-2",children:[o("showTitle")&&c.jsx(hi,{className:K("text-base",{}),children:c.jsx($o,{value:e.title,onSave:Ie=>p(u,e.id,Ie),isEditable:d,placeholder:"Add title",displayClassName:"text-base font-semibold",inputClassName:"text-base font-semibold"})}),o("showTitle")&&(d||e.info)&&c.jsx(lY,{card:e}),o("showRefreshIndicator")&&e.refreshInterval&&c.jsxs(Dn,{children:[c.jsx(Tn,{className:"pr-1",children:c.jsx("div",{className:K("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":S||N})})}),c.jsx($n,{side:"right",align:"center",children:c.jsx("p",{className:"text-xs",children:`Realtime (${e==null?void 0:e.refreshInterval})`})})]}),o("showFilterInfo")&&((re=(_e=e.preferences)==null?void 0:_e.displayOptions)==null?void 0:re.showFilterInfo)!==!1&&c.jsx(Sk,{cardId:e.id,cardFilters:(ce=e.config)==null?void 0:ce.filters,cardFilterCount:Ev(((xe=e.config)==null?void 0:xe.filters)||null)}),R&&c.jsx(cY,{metadata:R,variant:"compact"})]}),c.jsxs("div",{"data-content":"card-description-and-breadcrumb",className:"flex h-6 items-center overflow-y-auto",children:[!a&&o("showDescription")&&c.jsx("div",{className:K("text-sm text-muted-foreground",{}),children:c.jsx($o,{value:(e==null?void 0:e.description)||"",onSave:Ie=>m(u,e.id,Ie),isEditable:d,placeholder:"Add description",displayClassName:"text-sm text-muted-foreground",inputClassName:"text-sm"})}),a&&o("showBreadcrumbs")&&c.jsx(KPe,{cardId:e.id})]})]})}if(!e.id)return null;const te=((ye=(Se=e.preferences)==null?void 0:Se.displayOptions)==null?void 0:ye.showChrome)??!0,Q=((Ye=(Fe=e.preferences)==null?void 0:Fe.displayOptions)==null?void 0:Ye.allowScroll)??!0,ne=te?c.jsxs(c.Fragment,{children:[v?c.jsx(fi,{children:c.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[c.jsx("div",{className:"flex-1 basis-0 scroll-pb-2 overflow-x-auto",role:"header-container",children:Z()}),c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c.jsx("div",{children:h&&o("showFilters")&&c.jsxs("div",{style:{borderRadius:(Me=(me=l==null?void 0:l.chart)==null?void 0:me.options)==null?void 0:Me.borderRadius},"data-content":"frame-filter-container",className:"flex shrink-0 items-center",children:[!dd(h.dataType)&&c.jsx(le,{className:"my-1 shrink-0 px-3",children:c.jsx($o,{value:h.title||h.column,onSave:ge=>b({...h,title:ge}),isEditable:d,placeholder:"Filter",displayClassName:"text-sm",inputClassName:"text-sm"})}),c.jsx(nR,{filter:h})]})}),t.cards.length>1&&o("showTabs")&&G()]})]})}):c.jsx("div",{className:"h-8"}),c.jsx(Qi,{"data-role":"card-content",className:"relative flex min-h-0 grow flex-col",children:U()}),o("showFooter")&&c.jsx(sL,{children:$()})]}):U(),ie=()=>te&&Q?"flex h-full flex-col":te&&!Q?"flex h-full flex-col overflow-hidden":!te&&!Q?"h-full":"h-full overflow-auto";return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:K(ie(),{"animate-pulse":S||N}),children:Y()}),O.context&&c.jsx(HPe,{open:O.open,onOpenChange:ge=>{M(_e=>({..._e,open:ge}))},position:O.position,interactions:O.interactions,selectedConditions:O.context.conditions,drillHierarchies:(Ne=e.interactionConfig)==null?void 0:Ne.drillHierarchies,cardId:e.id,card:e,onSelectInteraction:ge=>{O.context&&L(ge,O.context),M({open:!1,position:null,interactions:[],context:null})}})]})}function XY({card:e,frame:t}){return e.displayPreferences?c.jsx(rR,{displayPreferences:e.displayPreferences,children:c.jsx(CF,{card:e,frame:t})}):c.jsx(CF,{card:e,frame:t})}function QPe({card:e,frame:t,showTitle:n=!0}){const{isError:r,isLoading:s,isFetching:o,cfg:i,data:a,pagination:l}=Sb(e),u=C.useMemo(()=>{var h;return e.type!=="pivotTable"||!((h=a==null?void 0:a.records)!=null&&h.length)?null:{records:a.records,columnSubtotalMeta:a.columnSubtotalMeta,subtotalColumns:a.subtotalColumns||[],pivotSchema:a.pivotSchema||[],groupByColumns:a.groupByColumns}},[e.type,a==null?void 0:a.records,a==null?void 0:a.columnSubtotalMeta,a==null?void 0:a.subtotalColumns,a==null?void 0:a.pivotSchema,a==null?void 0:a.groupByColumns]),d=Zh(e,u);if(s||o)return c.jsxs("div",{className:"flex h-full grow flex-col items-center justify-center gap-4 p-12",children:[c.jsx(In,{className:"h-8 w-8 animate-spin text-muted-foreground"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading visual..."})]});if(r)return c.jsx("div",{className:"flex flex-col items-center justify-center gap-2 p-12",children:c.jsx("p",{className:"text-sm font-medium text-destructive",children:"Failed to load visual"})});function f(){return e.type==="kpi"?c.jsx(Sg,{card:e,data:(a==null?void 0:a.records)||[],isPending:s||o}):e.type==="table"?c.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:c.jsx(Rb,{card:e,data:(a==null?void 0:a.records)||[],isLoading:s||o,paginationMetadata:l})}):e.type==="pivotTable"&&d?c.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:c.jsx(Ib,{card:e,data:(a==null?void 0:a.records)||[],onAggregationChange:()=>{},onAggregationLabelChange:()=>{}})}):e.type==="aggregateTable"?c.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:c.jsx(j1,{card:e,data:(a==null?void 0:a.records)||[],groupByColumns:a==null?void 0:a.groupByColumns,pivotSchema:a==null?void 0:a.pivotSchema,paginationMetadata:l,onAggregationChange:()=>{},isLoading:s||o})}):e.type==="text"?c.jsx(qs,{className:"overflow-y-auto break-words pr-2",children:c.jsx(gh,{isLoading:s||o,card:e,data:(a==null?void 0:a.records)||[]})}):e.type==="custom"?c.jsx(Nc,{FallbackComponent:_1,children:c.jsx(PT,{frame:t,card:e})}):i?c.jsx(Mb,{cfg:i,onChartClick:()=>{},onDatapointClick:()=>{}}):null}return c.jsxs("div",{className:"flex h-full w-full flex-col",children:[n&&e.title&&c.jsxs("div",{className:"border-b px-4 py-2",children:[c.jsx("h3",{className:"text-lg font-medium",children:e.title}),e.description&&c.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:e.description})]}),c.jsx("div",{className:"min-h-0 flex-1 p-4",children:f()})]})}function QY({insightId:e,filters:t,contextMode:n}){const{data:r,isLoading:s,isError:o,error:i}=b_(e,{enabled:!!e}),a=Ut(f=>f.setInteractionState),l=Ut(f=>f.resetInteractionState),u=C.useMemo(()=>{var h;if(!r)return null;const f=(r==null?void 0:r.frameObject)??((h=r==null?void 0:r.visual)==null?void 0:h.frameObject);if(!f)return null;if(typeof f=="string")try{return JSON.parse(f)}catch{return null}return f},[r]),d=C.useMemo(()=>{var f;return(f=u==null?void 0:u.cards)!=null&&f.length?u.activeCardId&&u.cards.find(h=>h.id===u.activeCardId)||u.cards[0]:null},[u]);return C.useEffect(()=>{if(!d)return;if(n==="none"||!(t!=null&&t.length)){const m={...To(),contextMode:n};a(d.id,m);return}const h={sourceCardId:"drill-to-insight",interactionMode:"clickFilter",filterGroups:[{filters:t}],applyToCardIds:[d.id]},p={...To(),appliedClickFilters:[h],contextMode:n};return a(d.id,p),()=>{l(d.id)}},[d,t,n,a,l]),s?c.jsxs("div",{className:"flex h-full grow flex-col items-center justify-center gap-4 p-12",children:[c.jsx(In,{className:"h-8 w-8 animate-spin text-muted-foreground"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading visual..."})]}):o?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-12",children:[c.jsx("p",{className:"text-sm font-medium text-destructive",children:"Failed to load insight"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:i instanceof Error?i.message:"Unknown error"})]}):!u||!d?c.jsx("div",{className:"flex items-center justify-center p-12",children:c.jsx("p",{className:"text-sm text-muted-foreground",children:"This insight has no visual data to display"})}):c.jsx("div",{className:"h-full w-full",children:c.jsx(QPe,{card:d,frame:u,showTitle:!1})})}function JPe({filters:e,contextMode:t}){if(!e||e.length===0)return t==="none"?c.jsxs(Pe,{variant:"outline",className:"gap-1 whitespace-nowrap",children:[c.jsx(Bl,{className:"h-3 w-3"}),"No filters"]}):null;const n=e.reduce((s,o)=>{var a,l;const i=((a=o.field)==null?void 0:a.label)||((l=o.field)==null?void 0:l.name)||"Unknown";return s[i]||(s[i]=[]),s[i].push(o),s},{});e.length;const r=Object.keys(n).length;return c.jsx(fr,{children:c.jsxs(Dn,{delayDuration:200,children:[c.jsx(Tn,{asChild:!0,children:c.jsxs(Pe,{variant:"secondary",className:"cursor-help gap-1 whitespace-nowrap border border-blue-500/20 bg-blue-500/10 text-blue-700 dark:text-blue-300",children:[c.jsx(Bl,{className:"h-3 w-3"}),r," ",r===1?"filter":"filters"]})}),c.jsx($n,{side:"bottom",align:"start",className:"max-w-md",children:c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:"text-sm font-medium",children:"Applied Filters"}),c.jsx("div",{className:"space-y-1.5",children:Object.entries(n).map(([s,o])=>c.jsxs("div",{className:"text-xs",children:[c.jsxs("span",{className:"font-medium",children:[s,":"]})," ",o.map((i,a)=>c.jsxs("span",{children:[eOe(i),a<o.length-1?", ":""]},a))]},s))}),t&&c.jsx("div",{className:"border-t pt-2 text-xs text-muted-foreground",children:tOe(t)})]})})]})})}function eOe(e){const{operator:t,value:n}=e;if(e.label){const r=e.label.split(/[=><]/);if(r.length>1)return r[1].trim()}switch(t){case"=":return String(n);case"!=":return`≠ ${n}`;case">":return`> ${n}`;case"<":return`< ${n}`;case">=":return`≥ ${n}`;case"<=":return`≤ ${n}`;case"in":return Array.isArray(n)?n.join(", "):String(n);case"not in":return`not ${Array.isArray(n)?n.join(", "):n}`;case"contains":return`contains ${n}`;case"startsWith":return`starts with ${n}`;case"endsWith":return`ends with ${n}`;case"between":return Array.isArray(n)?`${n[0]}-${n[1]}`:String(n);case"not between":return Array.isArray(n)?`not ${n[0]}-${n[1]}`:String(n);case"isNull":return"is null";case"isNotNull":return"is not null";default:return String(n)}}function tOe(e){switch(e){case"filters":case"interactionFilters":return"Showing data filtered by interaction only";case"full":return"Showing data with all dashboard filters + interaction filters";case"none":return"Showing all data (no filters applied)"}}function JY(e,t={}){const{enabled:n=!0}=t,{data:r}=b_(e,{enabled:n&&!!e});return C.useMemo(()=>{var l,u;if(!r)return{title:"",description:void 0};const o=(r==null?void 0:r.frameObject)??((l=r==null?void 0:r.visual)==null?void 0:l.frameObject);if(!o)return{title:"",description:void 0};let i=null;if(typeof o=="string")try{i=JSON.parse(o)}catch{return{title:"",description:void 0}}else i=o;if(!((u=i==null?void 0:i.cards)!=null&&u.length))return{title:"",description:void 0};const a=i.activeCardId&&i.cards.find(d=>d.id===i.activeCardId)||i.cards[0];return{title:a.title,description:a.description}},[r])}function nOe({cardId:e,children:t}){const n=Ut(o=>o.replacedCards[e]),r=Ut(o=>o.restoreCard),s=JY((n==null?void 0:n.insightId)||"",{enabled:!!(n!=null&&n.insightId)});return n?c.jsxs("div",{className:"flex h-full w-full flex-col",children:[c.jsxs("div",{className:"border-b bg-muted/30",children:[c.jsx("div",{className:"flex items-baseline gap-2 px-5 pb-2 pt-4",children:s.title&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"truncate text-sm font-semibold",children:s.title}),s.description&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-muted-foreground",children:"-"}),c.jsx("span",{className:"truncate text-xs text-muted-foreground",children:s.description})]})]})}),c.jsxs("div",{className:"flex items-center gap-3 px-4 pb-2",children:[c.jsxs(se,{variant:"ghost",size:"sm",onClick:()=>r(e),className:"flex-shrink-0 gap-1",children:[c.jsx(iL,{className:"h-4 w-4"}),"Back"]}),c.jsx(JPe,{filters:n.filters,contextMode:n.contextMode})]})]}),c.jsx("div",{className:"min-h-0 flex-1",children:c.jsx(QY,{insightId:n.insightId,filters:n.filters,contextMode:n.contextMode})})]}):c.jsx(c.Fragment,{children:t})}function rOe({frame:e,footer:t,className:n,...r}){var w,S;const s=C.useRef(null),[o,i]=C.useState(!1),a=ee(N=>N.themeStyle),l=ee(N=>N.isVisualEditing),u=ee(N=>N.selectedFrameId),d=ee(N=>N.isDashboardEditing),{setSelectedFrameId:f}=Jt(),{clearSelectedVisual:h}=Qg(),{setSelectedConnectionId:p,setSelectedDatabaseName:m,setSelectedSchemaName:g,setSelectedTableName:b,setCard:x}=is();C.useEffect(()=>{if(u===e.id&&d&&!l){const N=s==null?void 0:s.current;N==null||N.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[u,e.id,d,l,s]);const y=e.cards.find(N=>N.id===e.activeCardId);function v(N){N.stopPropagation(),f(e.id),h(),y&&x(y),y!=null&&y.connectionId&&p(y==null?void 0:y.connectionId),y!=null&&y.lastSelectedDatabase&&m(y==null?void 0:y.lastSelectedDatabase),y!=null&&y.lastSelectedSchema&&g(y==null?void 0:y.lastSelectedSchema),y!=null&&y.lastSelectedTable&&b(y==null?void 0:y.lastSelectedTable)}return c.jsx(Nc,{FallbackComponent:OT,children:c.jsxs("div",{tabIndex:-1,ref:s,role:"card-frame","data-frame-id":e.id,"data-active-card-id":y==null?void 0:y.id,onClick:v,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{borderRadius:a==null?void 0:a.cardBorderRadius},className:K("relative flex h-full flex-col rounded-sm border bg-background shadow-sm",{"border-dashed border-foreground/50":u===e.id&&d},a==null?void 0:a.dashboardCard,n,"semaphor-card-frame"),...r,children:[(d||((S=(w=y==null?void 0:y.preferences)==null?void 0:w.displayOptions)==null?void 0:S.showCardToolbar)!==!1)&&c.jsx(Kq,{frame:e,isHovered:o}),y&&c.jsx(nOe,{cardId:y.id,children:c.jsx(XY,{card:y,frame:e},y.id)})]})})}function sOe({label:e,onCheckedChange:t,checked:n}){return c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx(on,{onCheckedChange:t,id:"terms",checked:n}),c.jsx("label",{htmlFor:"terms",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:e})]})}function sR(e,t){if(e==null)return{};var n={},r=Object.keys(e),s,o;for(o=0;o<r.length;o++)s=r[o],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}var oOe=["color"],iOe=C.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,s=sR(e,oOe);return C.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s,{ref:t}),C.createElement("path",{d:"M4.93179 5.43179C4.75605 5.60753 4.75605 5.89245 4.93179 6.06819C5.10753 6.24392 5.39245 6.24392 5.56819 6.06819L7.49999 4.13638L9.43179 6.06819C9.60753 6.24392 9.89245 6.24392 10.0682 6.06819C10.2439 5.89245 10.2439 5.60753 10.0682 5.43179L7.81819 3.18179C7.73379 3.0974 7.61933 3.04999 7.49999 3.04999C7.38064 3.04999 7.26618 3.0974 7.18179 3.18179L4.93179 5.43179ZM10.0682 9.56819C10.2439 9.39245 10.2439 9.10753 10.0682 8.93179C9.89245 8.75606 9.60753 8.75606 9.43179 8.93179L7.49999 10.8636L5.56819 8.93179C5.39245 8.75606 5.10753 8.75606 4.93179 8.93179C4.75605 9.10753 4.75605 9.39245 4.93179 9.56819L7.18179 11.8182C7.35753 11.9939 7.64245 11.9939 7.81819 11.8182L10.0682 9.56819Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),aOe=["color"],eG=C.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,s=sR(e,aOe);return C.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s,{ref:t}),C.createElement("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),lOe=["color"],cOe=C.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,s=sR(e,lOe);return C.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s,{ref:t}),C.createElement("path",{d:"M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))});function wh({text:e,className:t}){const[n,r]=C.useState(!1);return c.jsx(se,{className:K("h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",t),variant:"ghost",size:"icon",onClick:()=>{navigator.clipboard.writeText(e),r(!0),setTimeout(()=>{r(!1)},1e3)},children:n?c.jsx(eG,{className:"size-3.5"}):c.jsx(hw,{className:"size-3.5"})})}function uOe({filter:e,onUpdate:t}){const[n,r]=C.useState(""),s=ee(y=>y.dashboard.sheets)||[],o=ee(y=>y.selectedSheetId),i=C.useMemo(()=>{const y=[];return s==null||s.forEach(v=>{var w;(w=v.frames)==null||w.forEach(S=>{var N;(N=S.cards)==null||N.forEach(j=>{y.push({...j,sheetId:v.id,sheetTitle:v.title||v.id})})})}),y},[s]),a=()=>e.applyToSheetIds!==void 0?"specific-sheets":e.excludeSheetIds!==void 0?"all-except-specific":"all-sheets",l=()=>e.applyToCardIds!==void 0?"specific-cards":e.excludeCardIds!==void 0?"all-except-specific":"all-cards",u=y=>{const v={};switch(y){case"all-sheets":v.applyToSheetIds=void 0,v.excludeSheetIds=void 0;break;case"specific-sheets":v.applyToSheetIds=[],v.excludeSheetIds=void 0;break;case"all-except-specific":v.applyToSheetIds=void 0,v.excludeSheetIds=[];break}t(v)},d=y=>{const v={};switch(y){case"all-cards":v.applyToCardIds=void 0,v.excludeCardIds=void 0;break;case"specific-cards":v.applyToCardIds=[],v.excludeCardIds=void 0;break;case"all-except-specific":v.applyToCardIds=void 0,v.excludeCardIds=[];break}t(v)},f=(y,v)=>{if(v==="specific-sheets"){const w=e.applyToSheetIds||[],S=w.includes(y)?w.filter(N=>N!==y):[...w,y];t({applyToSheetIds:S})}else if(v==="all-except-specific"){const w=e.excludeSheetIds||[],S=w.includes(y)?w.filter(N=>N!==y):[...w,y];t({excludeSheetIds:S})}},h=(y,v)=>{if(v==="specific-cards"){const w=e.applyToCardIds||[],S=w.includes(y)?w.filter(N=>N!==y):[...w,y];t({applyToCardIds:S})}else if(v==="all-except-specific"){const w=e.excludeCardIds||[],S=w.includes(y)?w.filter(N=>N!==y):[...w,y];t({excludeCardIds:S})}},p=()=>{const y=a();return y==="specific-sheets"?e.applyToSheetIds||[]:y==="all-except-specific"?(s==null?void 0:s.filter(v=>{var w;return!((w=e.excludeSheetIds)!=null&&w.includes(v.id))}).map(v=>v.id))||[]:(s==null?void 0:s.map(v=>v.id))||[]},m=C.useMemo(()=>{const y=p();return i.filter(v=>y.includes(v.sheetId))},[i,e.applyToSheetIds,e.excludeSheetIds]),g=C.useMemo(()=>{if(!n.trim())return m;const y=n.toLowerCase();return m.filter(v=>{var w;return(w=v==null?void 0:v.title)==null?void 0:w.toLowerCase().includes(y)})},[n,m]),b=a(),x=l();return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"space-y-0.5",children:[c.jsx(le,{className:"text-sm font-medium",children:"Sheet Scope"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Which sheets should display this filter?"})]}),c.jsxs(ra,{value:b,onValueChange:y=>u(y),className:"space-y-3",children:[c.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[c.jsx(vr,{value:"all-sheets",id:"all-sheets",className:"mt-0.5"}),c.jsxs("div",{className:"flex-1 space-y-1",children:[c.jsx(le,{htmlFor:"all-sheets",className:"cursor-pointer text-sm font-medium",children:"All sheets"}),c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Display filter on all sheets (",(s==null?void 0:s.length)||0," sheets)"]})]})]}),c.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[c.jsx(vr,{value:"specific-sheets",id:"specific-sheets",className:"mt-0.5"}),c.jsxs("div",{className:"flex-1 space-y-1",children:[c.jsx(le,{htmlFor:"specific-sheets",className:"cursor-pointer text-sm font-medium",children:"Only specific sheets"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Display filter on selected sheets only"})]})]}),b==="specific-sheets"&&c.jsx("div",{className:"ml-7 space-y-2",children:c.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==null?void 0:s.map(y=>{const v=(e.applyToSheetIds||[]).includes(y.id);return c.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[c.jsx(on,{id:`sheet-${y.id}`,checked:v,onCheckedChange:()=>f(y.id,"specific-sheets")}),c.jsxs(le,{htmlFor:`sheet-${y.id}`,className:"cursor-pointer text-sm font-medium",children:[y.title||y.id,y.id===o&&c.jsx("span",{className:"ml-1.5 text-xs text-muted-foreground",children:"(this sheet)"})]})]},y.id)})})}),c.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[c.jsx(vr,{value:"all-except-specific",id:"all-sheets-except",className:"mt-0.5"}),c.jsxs("div",{className:"flex-1 space-y-1",children:[c.jsx(le,{htmlFor:"all-sheets-except",className:"cursor-pointer text-sm font-medium",children:"All sheets except specific ones"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Display filter on all sheets except selected ones"})]})]}),b==="all-except-specific"&&c.jsx("div",{className:"ml-7 space-y-2",children:c.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==null?void 0:s.map(y=>{const v=(e.excludeSheetIds||[]).includes(y.id);return c.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[c.jsx(on,{id:`sheet-exclude-${y.id}`,checked:v,onCheckedChange:()=>f(y.id,"all-except-specific")}),c.jsxs(le,{htmlFor:`sheet-exclude-${y.id}`,className:"cursor-pointer text-sm font-medium",children:[y.title||y.id,y.id===o&&c.jsx("span",{className:"ml-1.5 text-xs text-muted-foreground",children:"(this sheet)"})]})]},y.id)})})})]})]}),c.jsxs("div",{className:"space-y-3 border-t pt-4",children:[c.jsxs("div",{className:"space-y-0.5",children:[c.jsx(le,{className:"text-sm font-medium",children:"Card Scope"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Which cards should receive this filter?"})]}),c.jsxs(ra,{value:x,onValueChange:y=>d(y),className:"space-y-3",children:[c.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[c.jsx(vr,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),c.jsxs("div",{className:"flex-1 space-y-1",children:[c.jsx(le,{htmlFor:"all-cards",className:"cursor-pointer text-sm font-medium",children:"All cards"}),c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Apply filter to all cards in applicable sheets (",m.length," cards)"]})]})]}),c.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[c.jsx(vr,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),c.jsxs("div",{className:"flex-1 space-y-1",children:[c.jsx(le,{htmlFor:"specific-cards",className:"cursor-pointer text-sm font-medium",children:"Only specific cards"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to selected cards only"})]})]}),x==="specific-cards"&&c.jsxs("div",{className:"ml-7 space-y-2",children:[c.jsx(xn,{placeholder:"Search cards...",value:n,onChange:y=>r(y.target.value),className:"mb-2"}),c.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:g.length>0?g.map(y=>{const v=(e.applyToCardIds||[]).includes(y.id);return c.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[c.jsx(on,{id:`card-${y.id}`,checked:v,onCheckedChange:()=>h(y.id,"specific-cards")}),c.jsxs("div",{className:"flex-1",children:[c.jsx(le,{htmlFor:`card-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title}),c.jsx("p",{className:"text-xs text-muted-foreground",children:y.sheetTitle})]})]},y.id)}):c.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',n,'"']})})]}),c.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[c.jsx(vr,{value:"all-except-specific",id:"all-cards-except",className:"mt-0.5"}),c.jsxs("div",{className:"flex-1 space-y-1",children:[c.jsx(le,{htmlFor:"all-cards-except",className:"cursor-pointer text-sm font-medium",children:"All cards except specific ones"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards except selected ones"})]})]}),x==="all-except-specific"&&c.jsxs("div",{className:"ml-7 space-y-2",children:[c.jsx(xn,{placeholder:"Search cards...",value:n,onChange:y=>r(y.target.value),className:"mb-2"}),c.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:g.length>0?g.map(y=>{const v=(e.excludeCardIds||[]).includes(y.id);return c.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[c.jsx(on,{id:`card-exclude-${y.id}`,checked:v,onCheckedChange:()=>h(y.id,"all-except-specific")}),c.jsxs("div",{className:"flex-1",children:[c.jsx(le,{htmlFor:`card-exclude-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title}),c.jsx("p",{className:"text-xs text-muted-foreground",children:y.sheetTitle})]})]},y.id)}):c.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',n,'"']})})]})]})]}),c.jsx("div",{className:"rounded-md bg-blue-50 p-3 text-xs text-blue-900 dark:bg-blue-950 dark:text-blue-100",children:"ℹ️ Cards are filtered based on sheet scope selection. Only cards from applicable sheets are shown in card scope."})]})}function dOe({filter:e}){var N;const[t,n]=C.useState(e.sql),[r,s]=C.useState(!1),[o,i]=C.useState({}),[a,l]=C.useState(e.title||""),[u,d]=C.useState(e.column),[f,h]=C.useState(e.searchMode||"auto"),[p,m]=C.useState(((N=e.defaultValues)==null?void 0:N.map(j=>String(j)))||[]),g=ee(j=>j.selectedSheetId),{updateFilter:b}=Jt(),{data:x}=WT(e);function y(){const j=a.trim(),_=u.trim(),k={sql:t,...o},D=_||e.column;_&&_!==e.column&&(k.column=D),k.title=j||D,Vi(e.dataType)&&(k.searchMode=f),k.defaultValues=p.length>0?p.map(R=>{const O=Number(R);return!isNaN(O)&&Vi(e.dataType)?O:R}):void 0;const T={...e,...k};b(T),i({}),s(!1)}C.useEffect(()=>{var j;r&&(i({}),n(e.sql),l(e.title===e.column?"":e.title||""),d(e.column),h(e.searchMode||"auto"),m(((j=e.defaultValues)==null?void 0:j.map(_=>String(_)))||[]))},[r,e.sql,e.title,e.column,e.searchMode,e.defaultValues]);function v(j){const _={...e,type:j};b(_)}function w(j){const _={...e,uiType:j};b(_)}function S(j){if(!g)return;const _={...e,sheetId:j?g:void 0};b(_)}return c.jsxs(Hs,{open:r,onOpenChange:s,children:[c.jsx(Us,{children:c.jsx(xu,{className:"invisible h-3 w-3 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),c.jsx(Ws,{onMouseDown:j=>j.stopPropagation(),onDoubleClick:j=>j.stopPropagation(),className:"z-50 m-2 h-[600px] w-[500px]",children:c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[c.jsx("h4",{className:"font-medium leading-none",title:e.column,children:e.column.split(".").pop()}),c.jsx(Pe,{variant:"secondary",className:"flex-shrink-0 text-xs font-normal",children:e.dataType})]}),c.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:"Customize filter settings and scope"}),c.jsxs(js,{defaultValue:"scope",className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[c.jsxs(os,{className:"grid w-full flex-shrink-0 grid-cols-2",children:[c.jsx(Qt,{value:"scope",children:"Scope"}),c.jsx(Qt,{value:"advanced",children:"Configuration"})]}),c.jsx(qn,{value:"scope",className:"mt-4 flex-1 overflow-y-auto",children:c.jsx(uOe,{filter:{...e,...o},onUpdate:j=>{i(_=>({..._,...j}))}})}),c.jsxs(qn,{value:"advanced",className:"mt-4 flex-1 space-y-5 overflow-y-auto",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(le,{className:"text-sm font-medium",children:"Custom Title (optional)"}),c.jsx(fr,{children:c.jsxs(Dn,{delayDuration:0,children:[c.jsx(Tn,{asChild:!0,children:c.jsx(wr,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),c.jsx($n,{side:"right",className:"max-w-xs",children:c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"text-xs",children:"Leave empty to use the column name. Provide a custom title to override it."}),c.jsxs("div",{className:"space-y-1 border-t pt-2",children:[c.jsx("p",{className:"text-xs font-medium",children:"Filter ID"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("p",{className:"break-all font-mono text-xs text-muted-foreground",children:e.id}),c.jsx(wh,{text:e.id})]})]})]})})]})})]}),c.jsx(Hn,{value:a,onChange:j=>l(j.target.value),placeholder:e.column,className:"h-8 text-sm"})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx(le,{className:"text-sm font-medium",children:"Column Name"}),c.jsx(Hn,{value:u,onChange:j=>d(j.target.value),placeholder:"Enter column name",className:"h-8 font-mono text-xs"})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx(le,{className:"text-sm font-medium",children:"Selection Type"}),c.jsxs(at,{value:e.type||"multiple",onValueChange:v,children:[c.jsx(st,{className:"h-8",children:c.jsx(dt,{})}),c.jsxs(ot,{children:[c.jsx(fe,{value:"multiple",children:"Multiple"}),c.jsx(fe,{value:"single",children:"Single"})]})]})]}),e.type==="single"&&c.jsxs("div",{className:"space-y-1",children:[c.jsx(le,{className:"text-sm font-medium",children:"UI Component"}),c.jsxs(at,{value:e.uiType||"dropdown",onValueChange:w,children:[c.jsx(st,{className:"h-8",children:c.jsx(dt,{})}),c.jsxs(ot,{children:[c.jsx(fe,{value:"dropdown",children:"Dropdown"}),c.jsx(fe,{value:"radio",children:"Radio"}),c.jsx(fe,{value:"tabs",children:"Tabs"})]})]})]}),Vi(e.dataType)&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(le,{className:"text-sm font-medium",children:"Search Mode"}),c.jsx(fr,{children:c.jsxs(Dn,{delayDuration:0,children:[c.jsx(Tn,{asChild:!0,children:c.jsx(wr,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),c.jsx($n,{side:"right",className:"max-w-xs",children:c.jsxs("div",{className:"space-y-2 text-xs",children:[c.jsxs("p",{children:[c.jsx("strong",{children:"Text Search:"}),' Treats numbers as text (e.g., ZIP codes, IDs). Search for "90210".']}),c.jsxs("p",{children:[c.jsx("strong",{children:"Numeric Operators:"})," Supports comparison operators (e.g., >100, <=50, =100) for quantities, prices."]}),c.jsxs("p",{children:[c.jsx("strong",{children:"Auto-detect:"})," Tries numeric first, falls back to text search."]})]})})]})})]}),c.jsxs(at,{value:f,onValueChange:j=>h(j),children:[c.jsx(st,{className:"h-8",children:c.jsx(dt,{})}),c.jsxs(ot,{children:[c.jsx(fe,{value:"text",children:"Text Search"}),c.jsx(fe,{value:"numeric",children:"Numeric Operators"}),c.jsx(fe,{value:"auto",children:"Auto-detect"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(le,{className:"text-sm font-medium",children:"Default Values (optional)"}),c.jsx(fr,{children:c.jsxs(Dn,{delayDuration:0,children:[c.jsx(Tn,{asChild:!0,children:c.jsx(wr,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),c.jsx($n,{side:"right",className:"max-w-xs",children:c.jsx("p",{className:"text-xs",children:"Select values that will be automatically applied when the dashboard first loads. Works like a filter selection."})})]})})]}),x!=null&&x.records&&x.records.length>0?c.jsxs(at,{value:"",onValueChange:j=>{j&&!p.includes(j)&&m([...p,j])},children:[c.jsx(st,{className:"h-8",children:c.jsx(dt,{placeholder:"Select values to add..."})}),c.jsxs(ot,{children:[x.records.filter(j=>{var D;const _=(D=e.column.split(".").pop())==null?void 0:D.replace(/"/g,""),k=_?j[_]:j.value;return k!=null&&!p.includes(String(k))}).map(j=>{var D;const _=(D=e.column.split(".").pop())==null?void 0:D.replace(/"/g,""),k=_?j[_]:j.value;return c.jsx(fe,{value:String(k),children:String(k)},String(k))}),x.records.every(j=>{var D;const _=(D=e.column.split(".").pop())==null?void 0:D.replace(/"/g,""),k=_?j[_]:j.value;return k==null||p.includes(String(k))})&&c.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"All values selected"})]})]}):c.jsx("div",{className:"flex h-8 items-center rounded-md border bg-muted px-2 text-xs text-muted-foreground",children:"Loading filter options..."}),p.length>0&&c.jsxs("div",{className:"space-y-1.5",children:[c.jsxs("div",{className:"text-xs font-medium text-muted-foreground",children:["Selected (",p.length,"):"]}),c.jsx("div",{className:"flex flex-wrap gap-1.5",children:p.map(j=>c.jsxs(Pe,{variant:"secondary",className:"gap-1.5 text-xs",children:[String(j),c.jsx(Tt,{className:"h-3 w-3 cursor-pointer hover:text-destructive",onClick:()=>{m(_=>_.filter(k=>k!==j))}})]},j))})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(le,{className:"text-sm font-medium",children:"SQL"}),c.jsx(fr,{children:c.jsxs(Dn,{delayDuration:0,children:[c.jsx(Tn,{asChild:!0,children:c.jsx(wr,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),c.jsx($n,{side:"right",className:"max-w-xs",children:c.jsx("p",{className:"text-xs",children:"This SQL will be used to fetch the filter values"})})]})})]}),c.jsx(vd,{onKeyDown:j=>{j.stopPropagation()},value:t,onChange:j=>n(j.target.value),className:`h-32 w-full resize-none break-all font-mono text-xs ${xf}`,placeholder:"SELECT column FROM table..."})]}),c.jsx("div",{className:"border-t pt-2",children:c.jsx(sOe,{label:"Local to sheet",onCheckedChange:S,checked:!!e.sheetId})})]})]}),c.jsx("div",{className:"mt-3 flex justify-end gap-2 border-t pt-3",children:c.jsxs(se,{onClick:y,size:"sm",variant:"outline",children:[c.jsx(Dr,{className:"mr-2 size-4"}),"Accept"]})})]})})]})}function tG({filter:e}){var u;const t=ee(d=>d.isDashboardEditing),{preferences:n}=Ph(),r=((u=n==null?void 0:n.cardDisplay)==null?void 0:u.mode)==="print",s=ee(d=>d.filterValues),o=s==null?void 0:s.some(d=>d.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:l}=Jt();return c.jsxs("div",{className:"group mb-1 flex h-5 items-center justify-between",children:[c.jsxs("div",{className:"flex grow items-center gap-2",children:[c.jsx(le,{className:"my-1 inline-block text-sm",children:c.jsx($o,{value:e.title||e.column,onSave:d=>l({...e,title:d}),isEditable:t,placeholder:"Filter",displayClassName:"text-sm",inputClassName:"text-sm"})}),o&&!r&&c.jsx("button",{onClick:()=>i(e.id),className:"text-muted-foreground",children:c.jsx(Tne,{className:"size-3.5"})}),t&&c.jsx("button",{className:"invisible group-hover:visible",onClick:()=>{l({...e,hide:!e.hide})},children:e.hide?c.jsx(Xa,{className:"size-3.5 text-muted-foreground hover:text-foreground"}):c.jsx(gw,{className:"size-3.5 text-muted-foreground hover:text-foreground"})}),t&&c.jsx(dOe,{filter:e})]}),c.jsx("div",{className:"flex items-center gap-2",children:t&&c.jsx(Tt,{onClick:()=>{i(e.id),a(e.id)},className:"size-3 cursor-pointer text-muted-foreground hover:cursor-pointer hover:text-foreground"})})]})}function nG(){var g;const e=ee(b=>b.isDashboardEditing),t=ee(b=>b.selectedSheetId),n=ee(b=>b.dashboard),r=n==null?void 0:n.sheets,s=r==null?void 0:r.find(b=>b.id===t),o=ze(b=>b.card),i=ze(b=>b.selectedConnectionId),{addFrame:a,setSelectedFrameId:l,setIsVisualEditing:u}=Jt(),{setFrame:d,setCard:f,setActiveTabCardId:h}=is();function p(){var v,w;const b=o==null?void 0:o.dataSource;if(b)return b;const x=(w=(v=n==null?void 0:n.aiContext)==null?void 0:v.selectedEntities)==null?void 0:w[0],y=x==null?void 0:x.type;if(x)return{connectionId:x.connectionId,connectionType:x.connectionType,type:y,selectedEntities:[x]}}function m(b){const x=(b==null?void 0:b.sheetId)||t,y=r==null?void 0:r.find(j=>j.id===x);if(!y){console.warn("Cannot add frame: No sheet found");return}if(!(!y.frames||y.frames.length===0)&&!e){console.warn("Cannot add frame: Dashboard not in editing mode");return}const w=p(),S={id:Er(),title:"Title",type:"bar",connectionId:i||"",dataSource:w,preferences:{onClickFilter:[{columnIndex:0,expression:""}]},sql:"",data:[]},N={id:Er(),cards:[S],activeCardId:S.id};return x&&(a(x,N),l(N.id)),b!=null&&b.openVisualEditor&&(d(N),f(S),h(S.id),u(!0)),N}return{handleAddNewFrame:m,canAddFrame:e||!((g=s==null?void 0:s.frames)!=null&&g.length)}}function fOe({sheetId:e}){const{handleAddNewFrame:t}=nG(),n=ee(s=>s.themeStyle),r=()=>{t({openVisualEditor:!0,sheetId:e})};return c.jsx("div",{className:"flex h-full min-h-[400px] items-start justify-start p-4",children:c.jsxs("button",{onClick:r,style:{borderRadius:n==null?void 0:n.cardBorderRadius},className:"group flex h-96 w-[600px] flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed border-muted-foreground/25 bg-background transition-all hover:border-muted-foreground/50 hover:bg-muted/50",children:[c.jsx("div",{className:"rounded-full bg-primary/10 p-3 transition-colors group-hover:bg-primary/20",children:c.jsx(Sr,{className:"h-6 w-6 text-primary"})}),c.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Add new Visual"})]})})}function Rv(e){const t=(e||"").toLowerCase(),n=ia(t);return n==="string"?c.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm border border-blue-200/70 bg-gradient-to-r from-blue-100/60 to-blue-200/40 text-blue-900 shadow-sm dark:border-blue-800/50 dark:from-blue-950/40 dark:to-blue-900/30 dark:text-blue-100",children:c.jsx(z2,{className:"h-3 w-3"})}):n==="number"?c.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm border border-green-200/70 bg-gradient-to-r from-green-100/60 to-green-200/40 text-green-900 shadow-sm dark:border-green-800/50 dark:from-green-950/40 dark:to-green-900/30 dark:text-green-100",children:c.jsx(_L,{className:"h-3 w-3"})}):n==="date"?c.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm border border-purple-200/70 bg-gradient-to-r from-purple-100/60 to-purple-200/40 text-purple-900 shadow-sm dark:border-purple-800/50 dark:from-purple-950/40 dark:to-purple-900/30 dark:text-purple-100",children:c.jsx(ts,{className:"h-3 w-3"})}):n==="boolean"?c.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm border border-orange-200/70 bg-gradient-to-r from-orange-100/60 to-orange-200/40 text-orange-900 shadow-sm dark:border-orange-800/50 dark:from-orange-950/40 dark:to-orange-900/30 dark:text-orange-100",children:c.jsx(Une,{className:"h-3 w-3"})}):n==="json"?c.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm border border-gray-200/70 bg-gradient-to-r from-gray-100/60 to-gray-200/40 text-gray-900 shadow-sm dark:border-gray-800/50 dark:from-gray-950/40 dark:to-gray-900/30 dark:text-gray-100",children:c.jsx(SL,{className:"h-3 w-3"})}):n==="geo"?c.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm border border-amber-200/70 bg-gradient-to-r from-amber-100/60 to-amber-200/40 text-amber-900 shadow-sm dark:border-amber-800/50 dark:from-amber-950/40 dark:to-amber-900/30 dark:text-amber-100",children:c.jsx(Ine,{className:"h-3 w-3"})}):n==="calculated"?c.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm border border-indigo-200/70 bg-gradient-to-r from-indigo-100/60 to-indigo-200/40 text-indigo-900 shadow-sm dark:border-indigo-800/50 dark:from-indigo-950/40 dark:to-indigo-900/30 dark:text-indigo-100",children:c.jsx(cL,{className:"h-3 w-3"})}):c.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm border border-gray-200/70 bg-gradient-to-r from-gray-100/60 to-gray-200/40 text-gray-900 shadow-sm dark:border-gray-800/50 dark:from-gray-950/40 dark:to-gray-900/30 dark:text-gray-100",children:c.jsx(z2,{className:"h-3 w-3"})})}function hOe({value:e,onChange:t,metrics:n,attributes:r}){const s=(o,i)=>(e==null?void 0:e.field.id)===o.id&&(e==null?void 0:e.type)===i;return c.jsx(fr,{children:c.jsxs("div",{className:"space-y-4",children:[n.length>0&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase",children:"Value of Metric"}),c.jsxs(Dn,{children:[c.jsx(Tn,{asChild:!0,children:c.jsx(wr,{className:"h-3.5 w-3.5 text-muted-foreground"})}),c.jsxs($n,{className:"max-w-xs",children:[c.jsx("p",{className:"text-xs font-medium mb-1",children:"Captures intersection of all dimensions"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:`Example: Clicking a bar segment in "Sales by Country, stacked by State" captures both Country='USA' AND State='California'`})]})]})]}),c.jsx("div",{className:"space-y-1",children:n.map(o=>{const i=s(o,"metric");return c.jsxs(se,{variant:i?"default":"outline",size:"sm",className:K("w-full justify-start font-normal",i&&"bg-primary text-primary-foreground"),onClick:()=>t({type:"metric",field:o}),children:[i&&c.jsx(Dr,{className:"mr-2 h-4 w-4"}),Rv(o.dataType),c.jsx("span",{className:"ml-2",children:o.label})]},o.id)})})]}),r.length>0&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase",children:"Value of Attribute"}),c.jsxs(Dn,{children:[c.jsx(Tn,{asChild:!0,children:c.jsx(wr,{className:"h-3.5 w-3.5 text-muted-foreground"})}),c.jsxs($n,{className:"max-w-xs",children:[c.jsx("p",{className:"text-xs font-medium mb-1",children:"Captures only this dimension"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:`Example: If configured on "State", clicking a bar in "Sales by Country, stacked by State" captures only State='California' (Country is not included)`})]})]})]}),c.jsx("div",{className:"space-y-1",children:r.map(o=>{const i=s(o,"attribute");return c.jsxs(se,{variant:i?"default":"outline",size:"sm",className:K("w-full justify-start font-normal",i&&"bg-primary text-primary-foreground"),onClick:()=>t({type:"attribute",field:o}),children:[i&&c.jsx(Dr,{className:"mr-2 h-4 w-4"}),Rv(o.dataType),c.jsx("span",{className:"ml-2",children:o.label})]},o.id)})})]}),n.length===0&&r.length===0&&c.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"No metrics or attributes available in this chart"})]})})}const NF=[{value:"clickFilter",label:"Cross filter",description:"Filter other cards on the dashboard"},{value:"drillDown",label:"Drill down",description:"Navigate through a hierarchy of dimensions"},{value:"dynamicDrill",label:"Explore dimensions",description:"Let users explore any dimension dynamically"},{value:"drillThrough",label:"Drill into dashboard",description:"Navigate to another dashboard"},{value:"drillToDetail",label:"Drill into insight",description:"Navigate to a saved insight"},{value:"drillToURL",label:"Drill into URL",description:"Navigate to a custom URL"}];function pOe({value:e,onChange:t}){const n=NF.find(r=>r.value===e);return c.jsx("div",{className:"space-y-2",children:c.jsxs(at,{value:e,onValueChange:t,children:[c.jsx(st,{className:"w-full",children:c.jsx(dt,{placeholder:"Choose action...",children:n&&c.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const r=Tv(n.value);return c.jsx(r,{className:"h-4 w-4"})})(),c.jsx("span",{children:n.label})]})})}),c.jsx(ot,{children:NF.map(r=>{const s=Tv(r.value);return c.jsx(fe,{value:r.value,children:c.jsxs("div",{className:"flex items-start gap-2 py-1",children:[c.jsx(s,{className:"mt-0.5 h-4 w-4 shrink-0"}),c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{className:"font-medium",children:r.label}),c.jsx("span",{className:"text-xs text-muted-foreground",children:r.description})]})]})},r.value)})})]})})}function mOe({interaction:e,onUpdate:t}){const[n,r]=C.useState(""),s=_$(),o=()=>e.applyToCardIds!==void 0?"specific-cards":e.excludeCardIds!==void 0?"all-except-specific":"all-cards",i=d=>{const f={};switch(d){case"all-cards":f.applyToCardIds=void 0,f.excludeCardIds=void 0;break;case"specific-cards":f.applyToCardIds=[],f.excludeCardIds=void 0;break;case"all-except-specific":f.applyToCardIds=void 0,f.excludeCardIds=[];break}t({...e,...f})},a=(d,f)=>{if(f==="specific-cards"){const h=e.applyToCardIds||[],p=h.includes(d)?h.filter(m=>m!==d):[...h,d];t({...e,applyToCardIds:p})}else if(f==="all-except-specific"){const h=e.excludeCardIds||[],p=h.includes(d)?h.filter(m=>m!==d):[...h,d];t({...e,excludeCardIds:p})}},l=C.useMemo(()=>{if(!n.trim())return s;const d=n.toLowerCase();return s==null?void 0:s.filter(f=>{var h;return(h=f==null?void 0:f.title)==null?void 0:h.toLowerCase().includes(d)})},[n,s]),u=o();return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"space-y-0.5",children:[c.jsx(le,{className:"text-sm font-medium",children:"Filter scope"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose which cards should receive the filter"})]}),c.jsxs(ra,{value:u,onValueChange:d=>i(d),className:"space-y-2",children:[c.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[c.jsx(vr,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),c.jsxs("div",{className:"flex-1 space-y-1",children:[c.jsx(le,{htmlFor:"all-cards",className:"cursor-pointer text-sm font-medium",children:"All cards"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards in the dashboard"})]})]}),c.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[c.jsx(vr,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),c.jsxs("div",{className:"flex-1 space-y-1",children:[c.jsx(le,{htmlFor:"specific-cards",className:"cursor-pointer text-sm font-medium",children:"Only specific cards"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to selected cards only"})]})]}),u==="specific-cards"&&c.jsxs("div",{className:"ml-7 space-y-2",children:[c.jsxs("div",{className:"space-y-0.5",children:[c.jsx(le,{className:"text-sm font-medium",children:"Cards to filter"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should receive the filter"})]}),c.jsx(xn,{placeholder:"Search cards...",value:n,onChange:d=>r(d.target.value),className:"mb-2"}),c.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:l&&l.length>0?l.map(d=>{const f=(e.applyToCardIds||[]).includes(d.id);return c.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[c.jsx(on,{id:`card-${d.id}`,checked:f,onCheckedChange:()=>a(d.id,"specific-cards")}),c.jsxs("div",{className:"flex-1",children:[c.jsx(le,{htmlFor:`card-${d.id}`,className:"cursor-pointer text-sm font-medium",children:d.title}),d.description&&c.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:d.description})]})]},d.id)}):c.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:n?`No cards found matching "${n}"`:"No cards available"})})]}),c.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[c.jsx(vr,{value:"all-except-specific",id:"all-except-specific",className:"mt-0.5"}),c.jsxs("div",{className:"flex-1 space-y-1",children:[c.jsx(le,{htmlFor:"all-except-specific",className:"cursor-pointer text-sm font-medium",children:"All cards except specific ones"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards, excluding selected ones"})]})]}),u==="all-except-specific"&&c.jsxs("div",{className:"ml-7 space-y-2",children:[c.jsxs("div",{className:"space-y-0.5",children:[c.jsx(le,{className:"text-sm font-medium",children:"Cards to exclude"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should be excluded from filtering"})]}),c.jsx(xn,{placeholder:"Search cards...",value:n,onChange:d=>r(d.target.value),className:"mb-2"}),c.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:l&&l.length>0?l.map(d=>{const f=(e.excludeCardIds||[]).includes(d.id);return c.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[c.jsx(on,{id:`card-exclude-${d.id}`,checked:f,onCheckedChange:()=>a(d.id,"all-except-specific")}),c.jsxs("div",{className:"flex-1",children:[c.jsx(le,{htmlFor:`card-exclude-${d.id}`,className:"cursor-pointer text-sm font-medium",children:d.title}),d.description&&c.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:d.description})]})]},d.id)}):c.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:n?`No cards found matching "${n}"`:"No cards available"})})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(le,{className:"text-sm font-medium",children:"Menu label"}),c.jsx(xn,{value:e.label||"",onChange:d=>t({...e,label:d.target.value}),placeholder:Dd(e.mode)}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"How this interaction appears when multiple actions are available"})]})]})}var oR="Collapsible",[gOe,rG]=Nr(oR),[bOe,iR]=gOe(oR),sG=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:s,disabled:o,onOpenChange:i,...a}=e,[l=!1,u]=Pr({prop:r,defaultProp:s,onChange:i});return c.jsx(bOe,{scope:n,disabled:o,contentId:Jn(),open:l,onOpenToggle:E.useCallback(()=>u(d=>!d),[u]),children:c.jsx($e.div,{"data-state":uR(l),"data-disabled":o?"":void 0,...a,ref:t})})});sG.displayName=oR;var oG="CollapsibleTrigger",aR=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,s=iR(oG,n);return c.jsx($e.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":uR(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:t,onClick:je(e.onClick,s.onOpenToggle)})});aR.displayName=oG;var lR="CollapsibleContent",cR=E.forwardRef((e,t)=>{const{forceMount:n,...r}=e,s=iR(lR,e.__scopeCollapsible);return c.jsx(er,{present:n||s.open,children:({present:o})=>c.jsx(xOe,{...r,ref:t,present:o})})});cR.displayName=lR;var xOe=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:s,...o}=e,i=iR(lR,n),[a,l]=E.useState(r),u=E.useRef(null),d=mt(t,u),f=E.useRef(0),h=f.current,p=E.useRef(0),m=p.current,g=i.open||a,b=E.useRef(g),x=E.useRef(void 0);return E.useEffect(()=>{const y=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(y)},[]),Or(()=>{const y=u.current;if(y){x.current=x.current||{transitionDuration:y.style.transitionDuration,animationName:y.style.animationName},y.style.transitionDuration="0s",y.style.animationName="none";const v=y.getBoundingClientRect();f.current=v.height,p.current=v.width,b.current||(y.style.transitionDuration=x.current.transitionDuration,y.style.animationName=x.current.animationName),l(r)}},[i.open,r]),c.jsx($e.div,{"data-state":uR(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...o,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:g&&s})});function uR(e){return e?"open":"closed"}var iG=sG,yOe=aR,vOe=cR;const sd=iG,od=aR,id=cR;function wOe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return C.useMemo(()=>r=>{t.forEach(s=>s(r))},t)}const $1=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function sp(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function dR(e){return"nodeType"in e}function ks(e){var t,n;return e?sp(e)?e:dR(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function fR(e){const{Document:t}=ks(e);return e instanceof t}function Wb(e){return sp(e)?!1:e instanceof ks(e).HTMLElement}function aG(e){return e instanceof ks(e).SVGElement}function op(e){return e?sp(e)?e.document:dR(e)?fR(e)?e:Wb(e)||aG(e)?e.ownerDocument:document:document:document}const gi=$1?C.useLayoutEffect:C.useEffect;function L1(e){const t=C.useRef(e);return gi(()=>{t.current=e}),C.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return t.current==null?void 0:t.current(...r)},[])}function SOe(){const e=C.useRef(null),t=C.useCallback((r,s)=>{e.current=setInterval(r,s)},[]),n=C.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function kg(e,t){t===void 0&&(t=[e]);const n=C.useRef(e);return gi(()=>{n.current!==e&&(n.current=e)},t),n}function qb(e,t){const n=C.useRef();return C.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Mv(e){const t=L1(e),n=C.useRef(null),r=C.useCallback(s=>{s!==n.current&&(t==null||t(s,n.current)),n.current=s},[]);return[n,r]}function Iv(e){const t=C.useRef();return C.useEffect(()=>{t.current=e},[e]),t.current}let NN={};function Yb(e,t){return C.useMemo(()=>{if(t)return t;const n=NN[e]==null?0:NN[e]+1;return NN[e]=n,e+"-"+n},[e,t])}function lG(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return r.reduce((o,i)=>{const a=Object.entries(i);for(const[l,u]of a){const d=o[l];d!=null&&(o[l]=d+e*u)}return o},{...t})}}const Rf=lG(1),Eg=lG(-1);function COe(e){return"clientX"in e&&"clientY"in e}function z1(e){if(!e)return!1;const{KeyboardEvent:t}=ks(e.target);return t&&e instanceof t}function NOe(e){if(!e)return!1;const{TouchEvent:t}=ks(e.target);return t&&e instanceof t}function Av(e){if(NOe(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return COe(e)?{x:e.clientX,y:e.clientY}:null}const oa=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[oa.Translate.toString(e),oa.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),jF="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function jOe(e){return e.matches(jF)?e:e.querySelector(jF)}const kOe={display:"none"};function EOe(e){let{id:t,value:n}=e;return C.createElement("div",{id:t,style:kOe},n)}function _Oe(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const s={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return C.createElement("div",{id:t,style:s,role:"status","aria-live":r,"aria-atomic":!0},n)}function DOe(){const[e,t]=C.useState("");return{announce:C.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const cG=C.createContext(null);function TOe(e){const t=C.useContext(cG);C.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function ROe(){const[e]=C.useState(()=>new Set),t=C.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[C.useCallback(r=>{let{type:s,event:o}=r;e.forEach(i=>{var a;return(a=i[s])==null?void 0:a.call(i,o)})},[e]),t]}const MOe={draggable:`
945
+ `)),[]});var cAe=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(cAe||{});function uAe(e){let t={};for(let n in e)e[n]===!0&&(t[`data-${n}`]="");return t}function dAe(e,t,n,r){let[s,o]=C.useState(n),{hasFlag:i,addFlag:a,removeFlag:l}=lAe(e&&s?3:0),u=C.useRef(!1),d=C.useRef(!1),f=Vb();return Yn(()=>{var h;if(e){if(n&&o(!0),!t){n&&a(3);return}return(h=void 0)==null||h.call(r,n),fAe(t,{inFlight:u,prepare(){d.current?d.current=!1:d.current=u.current,u.current=!0,!d.current&&(n?(a(3),l(4)):(a(4),l(2)))},run(){d.current?n?(l(3),a(4)):(l(4),a(3)):n?l(1):a(1)},done(){var p;d.current&&typeof t.getAnimations=="function"&&t.getAnimations().length>0||(u.current=!1,l(7),n||o(!1),(p=void 0)==null||p.call(r,n))}})}},[e,n,t,f]),e?[s,{closed:i(1),enter:i(2),leave:i(4),transition:i(2)||i(4)}]:[n,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function fAe(e,{prepare:t,run:n,done:r,inFlight:s}){let o=sa();return pAe(e,{prepare:t,inFlight:s}),o.nextFrame(()=>{n(),o.requestAnimationFrame(()=>{o.add(hAe(e,r))})}),o.dispose}function hAe(e,t){var n,r;let s=sa();if(!e)return s.dispose;let o=!1;s.add(()=>{o=!0});let i=(r=(n=e.getAnimations)==null?void 0:n.call(e).filter(a=>a instanceof CSSTransition))!=null?r:[];return i.length===0?(t(),s.dispose):(Promise.allSettled(i.map(a=>a.finished)).then(()=>{o||t()}),s.dispose)}function pAe(e,{inFlight:t,prepare:n}){if(t!=null&&t.current){n();return}let r=e.style.transition;e.style.transition="none",n(),e.offsetHeight,e.style.transition=r}function mAe(e,{container:t,accept:n,walk:r}){let s=C.useRef(n),o=C.useRef(r);C.useEffect(()=>{s.current=n,o.current=r},[n,r]),Yn(()=>{if(!t||!e)return;let i=Bb(t);if(!i)return;let a=s.current,l=o.current,u=Object.assign(f=>a(f),{acceptNode:a}),d=i.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,u,!1);for(;d.nextNode();)l(d.currentNode)},[t,e,s,o])}function hF(e,t){let n=C.useRef([]),r=wt(e);C.useEffect(()=>{let s=[...n.current];for(let[o,i]of t.entries())if(n.current[o]!==i){let a=r(t,s);return n.current=t,a}},[r,...t])}function gAe(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:n,version:r}=t;return n+"/"+r}).join(" "):navigator.userAgent}const zY={...E},bAe=zY.useInsertionEffect,xAe=bAe||(e=>e());function BY(e){const t=E.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return xAe(()=>{t.current=e}),E.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return t.current==null?void 0:t.current(...r)},[])}var Rk=typeof document<"u"?C.useLayoutEffect:C.useEffect;let pF=!1,yAe=0;const mF=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+yAe++;function vAe(){const[e,t]=E.useState(()=>pF?mF():void 0);return Rk(()=>{e==null&&t(mF())},[]),E.useEffect(()=>{pF=!0},[]),e}const wAe=zY.useId,SAe=wAe||vAe;let Cg;process.env.NODE_ENV!=="production"&&(Cg=new Set);function CAe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((e=Cg)!=null&&e.has(s))){var o;(o=Cg)==null||o.add(s),console.warn(s)}}function NAe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((e=Cg)!=null&&e.has(s))){var o;(o=Cg)==null||o.add(s),console.error(s)}}function jAe(){const e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(s=>s(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var r;e.set(t,((r=e.get(t))==null?void 0:r.filter(s=>s!==n))||[])}}}const kAe=E.createContext(null),EAe=E.createContext(null),_Ae=()=>{var e;return((e=E.useContext(kAe))==null?void 0:e.id)||null},DAe=()=>E.useContext(EAe),TAe="data-floating-ui-focusable";function RAe(e){const{open:t=!1,onOpenChange:n,elements:r}=e,s=SAe(),o=E.useRef({}),[i]=E.useState(()=>jAe()),a=_Ae()!=null;if(process.env.NODE_ENV!=="production"){const p=r.reference;p&&!Kr(p)&&NAe("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[l,u]=E.useState(r.reference),d=BY((p,m,g)=>{o.current.openEvent=p?m:void 0,i.emit("openchange",{open:p,event:m,reason:g,nested:a}),n==null||n(p,m,g)}),f=E.useMemo(()=>({setPositionReference:u}),[]),h=E.useMemo(()=>({reference:l||r.reference||null,floating:r.floating||null,domReference:r.reference}),[l,r.reference,r.floating]);return E.useMemo(()=>({dataRef:o,open:t,onOpenChange:d,elements:h,events:i,floatingId:s,refs:f}),[t,d,h,i,s,f])}function MAe(e){e===void 0&&(e={});const{nodeId:t}=e,n=RAe({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||n,s=r.elements,[o,i]=E.useState(null),[a,l]=E.useState(null),d=(s==null?void 0:s.domReference)||o,f=E.useRef(null),h=DAe();Rk(()=>{d&&(f.current=d)},[d]);const p=e6({...e,elements:{...s,...a&&{reference:a}}}),m=E.useCallback(v=>{const w=Kr(v)?{getBoundingClientRect:()=>v.getBoundingClientRect(),contextElement:v}:v;l(w),p.refs.setReference(w)},[p.refs]),g=E.useCallback(v=>{(Kr(v)||v===null)&&(f.current=v,i(v)),(Kr(p.refs.reference.current)||p.refs.reference.current===null||v!==null&&!Kr(v))&&p.refs.setReference(v)},[p.refs]),b=E.useMemo(()=>({...p.refs,setReference:g,setPositionReference:m,domReference:f}),[p.refs,g,m]),x=E.useMemo(()=>({...p.elements,domReference:d}),[p.elements,d]),y=E.useMemo(()=>({...p,...r,refs:b,elements:x,nodeId:t}),[p,b,x,t,r]);return Rk(()=>{r.dataRef.current.floatingContext=y;const v=h==null?void 0:h.nodesRef.current.find(w=>w.id===t);v&&(v.context=y)}),E.useMemo(()=>({...p,context:y,refs:b,elements:x}),[p,b,x,y])}const gF="active",bF="selected";function wN(e,t,n){const r=new Map,s=n==="item";let o=e;if(s&&e){const{[gF]:i,[bF]:a,...l}=e;o=l}return{...n==="floating"&&{tabIndex:-1,[TAe]:""},...o,...t.map(i=>{const a=i?i[n]:null;return typeof a=="function"?e?a(e):null:a}).concat(e).reduce((i,a)=>(a&&Object.entries(a).forEach(l=>{let[u,d]=l;if(!(s&&[gF,bF].includes(u)))if(u.indexOf("on")===0){if(r.has(u)||r.set(u,[]),typeof d=="function"){var f;(f=r.get(u))==null||f.push(d),i[u]=function(){for(var h,p=arguments.length,m=new Array(p),g=0;g<p;g++)m[g]=arguments[g];return(h=r.get(u))==null?void 0:h.map(b=>b(...m)).find(b=>b!==void 0)}}}else i[u]=d}),i),{})}}function IAe(e){e===void 0&&(e=[]);const t=e.map(a=>a==null?void 0:a.reference),n=e.map(a=>a==null?void 0:a.floating),r=e.map(a=>a==null?void 0:a.item),s=E.useCallback(a=>wN(a,e,"reference"),t),o=E.useCallback(a=>wN(a,e,"floating"),n),i=E.useCallback(a=>wN(a,e,"item"),r);return E.useMemo(()=>({getReferenceProps:s,getFloatingProps:o,getItemProps:i}),[s,o,i])}function xF(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}const AAe=e=>({name:"inner",options:e,async fn(t){const{listRef:n,overflowRef:r,onFallbackChange:s,offset:o=0,index:i=0,minItemsVisible:a=4,referenceOverflowThreshold:l=0,scrollRef:u,...d}=Ji(e,t),{rects:f,elements:{floating:h}}=t,p=n.current[i],m=(u==null?void 0:u.current)||h,g=h.clientTop||m.clientTop,b=h.clientTop!==0,x=m.clientTop!==0,y=h===m;if(process.env.NODE_ENV!=="production"&&(t.placement.startsWith("bottom")||CAe('`placement` side must be "bottom" when using the `inner`',"middleware.")),!p)return{};const v={...t,...await n_(-p.offsetTop-h.clientTop-f.reference.height/2-p.offsetHeight/2-o).fn(t)},w=await BS(xF(v,m.scrollHeight+g+h.clientTop),d),S=await BS(v,{...d,elementContext:"reference"}),N=Zr(0,w.top),j=v.y+N,D=(m.scrollHeight>m.clientHeight?T=>T:Gm)(Zr(0,m.scrollHeight+(b&&y||x?g*2:0)-N-Zr(0,w.bottom)));if(m.style.maxHeight=D+"px",m.scrollTop=N,s){const T=m.offsetHeight<p.offsetHeight*Qa(a,n.current.length)-1||S.top>=-l||S.bottom>=-l;Gl.flushSync(()=>s(T))}return r&&(r.current=await BS(xF({...v,y:j},m.offsetHeight+g+h.clientTop),d)),{y:j}}});function PAe(e,t){const{open:n,elements:r}=e,{enabled:s=!0,overflowRef:o,scrollRef:i,onChange:a}=t,l=BY(a),u=E.useRef(!1),d=E.useRef(null),f=E.useRef(null);E.useEffect(()=>{if(!s)return;function p(g){if(g.ctrlKey||!m||o.current==null)return;const b=g.deltaY,x=o.current.top>=-.5,y=o.current.bottom>=-.5,v=m.scrollHeight-m.clientHeight,w=b<0?-1:1,S=b<0?"max":"min";m.scrollHeight<=m.clientHeight||(!x&&b>0||!y&&b<0?(g.preventDefault(),Gl.flushSync(()=>{l(N=>N+Math[S](b,v*w))})):/firefox/i.test(gAe())&&(m.scrollTop+=b))}const m=(i==null?void 0:i.current)||r.floating;if(n&&m)return m.addEventListener("wheel",p),requestAnimationFrame(()=>{d.current=m.scrollTop,o.current!=null&&(f.current={...o.current})}),()=>{d.current=null,f.current=null,m.removeEventListener("wheel",p)}},[s,n,r.floating,o,i,l]);const h=E.useMemo(()=>({onKeyDown(){u.current=!0},onWheel(){u.current=!1},onPointerMove(){u.current=!1},onScroll(){const p=(i==null?void 0:i.current)||r.floating;if(!(!o.current||!p||!u.current)){if(d.current!==null){const m=p.scrollTop-d.current;(o.current.bottom<-.5&&m<-1||o.current.top<-.5&&m>1)&&Gl.flushSync(()=>l(g=>g+m))}requestAnimationFrame(()=>{d.current=p.scrollTop})}}}),[r.floating,l,o,i]);return E.useMemo(()=>s?{floating:h}:{},[s,h])}let Hb=C.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});Hb.displayName="FloatingContext";let QT=C.createContext(null);QT.displayName="PlacementContext";function OAe(e){return C.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function FAe(){return C.useContext(Hb).setReference}function $Ae(){let{getFloatingProps:e,slot:t}=C.useContext(Hb);return C.useCallback((...n)=>Object.assign({},e(...n),{"data-anchor":t.anchor}),[e,t])}function LAe(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let t=C.useContext(QT),n=C.useMemo(()=>e,[JSON.stringify(e,(s,o)=>{var i;return(i=o==null?void 0:o.outerHTML)!=null?i:o})]);Yn(()=>{t==null||t(n??null)},[t,n]);let r=C.useContext(Hb);return C.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let yF=4;function zAe({children:e,enabled:t=!0}){let[n,r]=C.useState(null),[s,o]=C.useState(0),i=C.useRef(null),[a,l]=C.useState(null);BAe(a);let u=t&&n!==null&&a!==null,{to:d="bottom",gap:f=0,offset:h=0,padding:p=0,inner:m}=VAe(n,a),[g,b="center"]=d.split(" ");Yn(()=>{u&&o(0)},[u]);let{refs:x,floatingStyles:y,context:v}=MAe({open:u,placement:g==="selection"?b==="center"?"bottom":`bottom-${b}`:b==="center"?`${g}`:`${g}-${b}`,strategy:"absolute",transform:!1,middleware:[n_({mainAxis:g==="selection"?0:f,crossAxis:h}),t6({padding:p}),g!=="selection"&&n6({padding:p}),g==="selection"&&m?AAe({...m,padding:p,overflowRef:i,offset:s,minItemsVisible:yF,referenceOverflowThreshold:p,onFallbackChange(T){var R,O;if(!T)return;let M=v.elements.floating;if(!M)return;let P=parseFloat(getComputedStyle(M).scrollPaddingBottom)||0,F=Math.min(yF,M.childElementCount),V=0,H=0;for(let L of(O=(R=v.elements.floating)==null?void 0:R.childNodes)!=null?O:[])if(L instanceof HTMLElement){let I=L.offsetTop,B=I+L.clientHeight+P,z=M.scrollTop,A=z+M.clientHeight;if(I>=z&&B<=A)F--;else{H=Math.max(0,Math.min(B,A)-Math.max(I,z)),V=L.clientHeight;break}}F>=1&&o(L=>{let I=V*F-H+P;return L>=I?L:I})}}):null,r6({padding:p,apply({availableWidth:T,availableHeight:R,elements:O}){Object.assign(O.floating.style,{overflow:"auto",maxWidth:`${T}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${R}px)`})}})].filter(Boolean),whileElementsMounted:QL}),[w=g,S=b]=v.placement.split("-");g==="selection"&&(w="selection");let N=C.useMemo(()=>({anchor:[w,S].filter(Boolean).join(" ")}),[w,S]),j=PAe(v,{overflowRef:i,onChange:o}),{getReferenceProps:_,getFloatingProps:k}=IAe([j]),D=wt(T=>{l(T),x.setFloating(T)});return E.createElement(QT.Provider,{value:r},E.createElement(Hb.Provider,{value:{setFloating:D,setReference:x.setReference,styles:y,getReferenceProps:_,getFloatingProps:k,slot:N}},e))}function BAe(e){Yn(()=>{if(!e)return;let t=new MutationObserver(()=>{let n=window.getComputedStyle(e).maxHeight,r=parseFloat(n);if(isNaN(r))return;let s=parseInt(n);isNaN(s)||r!==s&&(e.style.maxHeight=`${Math.ceil(r)}px`)});return t.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{t.disconnect()}},[e])}function VAe(e,t){var n,r,s;let o=SN((n=e==null?void 0:e.gap)!=null?n:"var(--anchor-gap, 0)",t),i=SN((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",t),a=SN((s=e==null?void 0:e.padding)!=null?s:"var(--anchor-padding, 0)",t);return{...e,gap:o,offset:i,padding:a}}function SN(e,t,n=void 0){let r=Vb(),s=wt((l,u)=>{if(l==null)return[n,null];if(typeof l=="number")return[l,null];if(typeof l=="string"){if(!u)return[n,null];let d=vF(l,u);return[d,f=>{let h=VY(l);{let p=h.map(m=>window.getComputedStyle(u).getPropertyValue(m));r.requestAnimationFrame(function m(){r.nextFrame(m);let g=!1;for(let[x,y]of h.entries()){let v=window.getComputedStyle(u).getPropertyValue(y);if(p[x]!==v){p[x]=v,g=!0;break}}if(!g)return;let b=vF(l,u);d!==b&&(f(b),d=b)})}return r.dispose}]}return[n,null]}),o=C.useMemo(()=>s(e,t)[0],[e,t]),[i=o,a]=C.useState();return Yn(()=>{let[l,u]=s(e,t);if(a(l),!!u)return u(a)},[e,t]),i}function VY(e){let t=/var\((.*)\)/.exec(e);if(t){let n=t[1].indexOf(",");if(n===-1)return[t[1]];let r=t[1].slice(0,n).trim(),s=t[1].slice(n+1).trim();return s?[r,...VY(s)]:[r]}return[]}function vF(e,t){let n=document.createElement("div");t.appendChild(n),n.style.setProperty("margin-top","0px","important"),n.style.setProperty("margin-top",e,"important");let r=parseFloat(window.getComputedStyle(n).marginTop)||0;return t.removeChild(n),r}function HAe({children:e,freeze:t}){let n=Mk(t,e);return C.createElement(C.Fragment,null,n)}function Mk(e,t){let[n,r]=C.useState(t);return!e&&n!==t&&r(t),e?n:t}let JT=C.createContext(null);JT.displayName="OpenClosedContext";var Ng=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(Ng||{});function UAe(){return C.useContext(JT)}function WAe({value:e,children:t}){return C.createElement(JT.Provider,{value:e},t)}function qAe(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let Xc=[];qAe(()=>{function e(t){if(!(t.target instanceof HTMLElement)||t.target===document.body||Xc[0]===t.target)return;let n=t.target;n=n.closest(Tk),Xc.unshift(n??t.target),Xc=Xc.filter(r=>r!=null&&r.isConnected),Xc.splice(10)}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})});function YAe(e){throw new Error("Unexpected object: "+e)}var ur=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(ur||{});function wF(e,t){let n=t.resolveItems();if(n.length<=0)return null;let r=t.resolveActiveIndex(),s=r??-1;switch(e.focus){case 0:{for(let o=0;o<n.length;++o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 1:{s===-1&&(s=n.length);for(let o=s-1;o>=0;--o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 2:{for(let o=s+1;o<n.length;++o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 3:{for(let o=n.length-1;o>=0;--o)if(!t.resolveDisabled(n[o],o,n))return o;return r}case 4:{for(let o=0;o<n.length;++o)if(t.resolveId(n[o],o,n)===e.id)return o;return r}case 5:return null;default:YAe(e)}}var eR=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))(eR||{});function GAe(e){let t=wt(e),n=C.useRef(!1);C.useEffect(()=>(n.current=!1,()=>{n.current=!0,CY(()=>{n.current&&t()})}),[t])}function ZAe(){let e=typeof document>"u";return"useSyncExternalStore"in E?(t=>t.useSyncExternalStore)(E)(()=>()=>{},()=>!1,()=>!e):!1}function KAe(){let e=ZAe(),[t,n]=E.useState(Iu.isHandoffComplete);return t&&Iu.isHandoffComplete===!1&&n(!1),E.useEffect(()=>{t!==!0&&n(!0)},[t]),E.useEffect(()=>Iu.handoff(),[]),e?!1:t}let XAe=C.createContext(!1);function QAe(){return C.useContext(XAe)}function JAe(e){let t=QAe(),n=C.useContext(UY),r=F1(e),[s,o]=C.useState(()=>{var i;if(!t&&n!==null)return(i=n.current)!=null?i:null;if(Iu.isServer)return null;let a=r==null?void 0:r.getElementById("headlessui-portal-root");if(a)return a;if(r===null)return null;let l=r.createElement("div");return l.setAttribute("id","headlessui-portal-root"),r.body.appendChild(l)});return C.useEffect(()=>{s!==null&&(r!=null&&r.body.contains(s)||r==null||r.body.appendChild(s))},[s,r]),C.useEffect(()=>{t||n!==null&&o(n.current)},[n,o,t]),s}let HY=C.Fragment,ePe=Ni(function(e,t){let n=e,r=C.useRef(null),s=ll(mIe(f=>{r.current=f}),t),o=F1(r),i=JAe(r),[a]=C.useState(()=>{var f;return Iu.isServer?null:(f=o==null?void 0:o.createElement("div"))!=null?f:null}),l=C.useContext(sPe),u=KAe();Yn(()=>{!i||!a||i.contains(a)||(a.setAttribute("data-headlessui-portal",""),i.appendChild(a))},[i,a]),Yn(()=>{if(a&&l)return l.register(a)},[l,a]),GAe(()=>{var f;!i||!a||(a instanceof Node&&i.contains(a)&&i.removeChild(a),i.childNodes.length<=0&&((f=i.parentElement)==null||f.removeChild(i)))});let d=Ci();return u?!i||!a?null:_n.createPortal(d({ourProps:{ref:s},theirProps:n,slot:{},defaultTag:HY,name:"Portal"}),a):null});function tPe(e,t){let n=ll(t),{enabled:r=!0,...s}=e,o=Ci();return r?C.createElement(ePe,{...s,ref:n}):o({ourProps:{ref:n},theirProps:s,slot:{},defaultTag:HY,name:"Portal"})}let nPe=C.Fragment,UY=C.createContext(null);function rPe(e,t){let{target:n,...r}=e,s={ref:ll(t)},o=Ci();return C.createElement(UY.Provider,{value:n},o({ourProps:s,theirProps:r,defaultTag:nPe,name:"Popover.Group"}))}let sPe=C.createContext(null),oPe=Ni(tPe),iPe=Ni(rPe),aPe=Object.assign(oPe,{Group:iPe});var lPe=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(lPe||{}),cPe=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(cPe||{}),uPe=(e=>(e[e.Pointer=0]="Pointer",e[e.Focus=1]="Focus",e[e.Other=2]="Other",e))(uPe||{}),dPe=(e=>(e[e.OpenCombobox=0]="OpenCombobox",e[e.CloseCombobox=1]="CloseCombobox",e[e.GoToOption=2]="GoToOption",e[e.SetTyping=3]="SetTyping",e[e.RegisterOption=4]="RegisterOption",e[e.UnregisterOption=5]="UnregisterOption",e[e.SetActivationTrigger=6]="SetActivationTrigger",e[e.UpdateVirtualConfiguration=7]="UpdateVirtualConfiguration",e[e.SetInputElement=8]="SetInputElement",e[e.SetButtonElement=9]="SetButtonElement",e[e.SetOptionsElement=10]="SetOptionsElement",e))(dPe||{});function CN(e,t=n=>n){let n=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=t(e.options.slice()),s=r.length>0&&r[0].dataRef.current.order!==null?r.sort((i,a)=>i.dataRef.current.order-a.dataRef.current.order):ZIe(r,i=>i.dataRef.current.domRef.current),o=n?s.indexOf(n):null;return o===-1&&(o=null),{options:s,activeOptionIndex:o}}let fPe={1(e){var t;return(t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===1?e:{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,__demoMode:!1}},0(e){var t,n;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===0)return e;if((n=e.dataRef.current)!=null&&n.value){let r=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(r!==-1)return{...e,activeOptionIndex:r,comboboxState:0,__demoMode:!1}}return{...e,comboboxState:0,__demoMode:!1}},3(e,t){return e.isTyping===t.isTyping?e:{...e,isTyping:t.isTyping}},2(e,t){var n,r,s,o;if((n=e.dataRef.current)!=null&&n.disabled||e.optionsElement&&!((r=e.dataRef.current)!=null&&r.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:u,disabled:d}=e.virtual,f=t.focus===ur.Specific?t.idx:wF(t,{resolveItems:()=>u,resolveActiveIndex:()=>{var p,m;return(m=(p=e.activeOptionIndex)!=null?p:u.findIndex(g=>!d(g)))!=null?m:null},resolveDisabled:d,resolveId(){throw new Error("Function not implemented.")}}),h=(s=t.trigger)!=null?s:2;return e.activeOptionIndex===f&&e.activationTrigger===h?e:{...e,activeOptionIndex:f,activationTrigger:h,isTyping:!1,__demoMode:!1}}let i=CN(e);if(i.activeOptionIndex===null){let u=i.options.findIndex(d=>!d.dataRef.current.disabled);u!==-1&&(i.activeOptionIndex=u)}let a=t.focus===ur.Specific?t.idx:wF(t,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:u=>u.id,resolveDisabled:u=>u.dataRef.current.disabled}),l=(o=t.trigger)!=null?o:2;return e.activeOptionIndex===a&&e.activationTrigger===l?e:{...e,...i,isTyping:!1,activeOptionIndex:a,activationTrigger:l,__demoMode:!1}},4:(e,t)=>{var n,r,s;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:[...e.options,t.payload]};let o=t.payload,i=CN(e,l=>(l.push(o),l));e.activeOptionIndex===null&&(r=e.dataRef.current)!=null&&r.isSelected(t.payload.dataRef.current.value)&&(i.activeOptionIndex=i.options.indexOf(o));let a={...e,...i,activationTrigger:2};return(s=e.dataRef.current)!=null&&s.__demoMode&&e.dataRef.current.value===void 0&&(a.activeOptionIndex=0),a},5:(e,t)=>{var n;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:e.options.filter(s=>s.id!==t.id)};let r=CN(e,s=>{let o=s.findIndex(i=>i.id===t.id);return o!==-1&&s.splice(o,1),s});return{...e,...r,activationTrigger:2}},6:(e,t)=>e.activationTrigger===t.trigger?e:{...e,activationTrigger:t.trigger},7:(e,t)=>{var n,r;if(e.virtual===null)return{...e,virtual:{options:t.options,disabled:(n=t.disabled)!=null?n:()=>!1}};if(e.virtual.options===t.options&&e.virtual.disabled===t.disabled)return e;let s=e.activeOptionIndex;if(e.activeOptionIndex!==null){let o=t.options.indexOf(e.virtual.options[e.activeOptionIndex]);o!==-1?s=o:s=null}return{...e,activeOptionIndex:s,virtual:{options:t.options,disabled:(r=t.disabled)!=null?r:()=>!1}}},8:(e,t)=>e.inputElement===t.element?e:{...e,inputElement:t.element},9:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},10:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element}},tR=C.createContext(null);tR.displayName="ComboboxActionsContext";function Ub(e){let t=C.useContext(tR);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Ub),n}return t}let WY=C.createContext(null);function hPe(e){let t=rp("VirtualProvider"),{options:n}=t.virtual,[r,s]=C.useMemo(()=>{let u=t.optionsElement;if(!u)return[0,0];let d=window.getComputedStyle(u);return[parseFloat(d.paddingBlockStart||d.paddingTop),parseFloat(d.paddingBlockEnd||d.paddingBottom)]},[t.optionsElement]),o=OIe({enabled:n.length!==0,scrollPaddingStart:r,scrollPaddingEnd:s,count:n.length,estimateSize(){return 40},getScrollElement(){return t.optionsElement},overscan:12}),[i,a]=C.useState(0);Yn(()=>{a(u=>u+1)},[n]);let l=o.getVirtualItems();return l.length===0?null:C.createElement(WY.Provider,{value:o},C.createElement("div",{style:{position:"relative",width:"100%",height:`${o.getTotalSize()}px`},ref:u=>{u&&t.activationTrigger!==0&&t.activeOptionIndex!==null&&n.length>t.activeOptionIndex&&o.scrollToIndex(t.activeOptionIndex)}},l.map(u=>{var d;return C.createElement(C.Fragment,{key:u.key},C.cloneElement((d=e.children)==null?void 0:d.call(e,{...e.slot,option:n[u.index]}),{key:`${i}-${u.key}`,"data-index":u.index,"aria-setsize":n.length,"aria-posinset":u.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${u.start}px)`,overflowAnchor:"none"}}))})))}let jg=C.createContext(null);jg.displayName="ComboboxDataContext";function rp(e){let t=C.useContext(jg);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,rp),n}return t}function pPe(e,t){return Ya(t.type,fPe,e,t)}let mPe=C.Fragment;function gPe(e,t){var n,r;let s=YT(),{value:o,defaultValue:i,onChange:a,form:l,name:u,by:d,disabled:f=s||!1,onClose:h,__demoMode:p=!1,multiple:m=!1,immediate:g=!1,virtual:b=null,nullable:x,...y}=e,v=oIe(i),[w=m?[]:void 0,S]=sIe(o,a,v),[N,j]=C.useReducer(pPe,{dataRef:C.createRef(),comboboxState:p?0:1,isTyping:!1,options:[],virtual:b?{options:b.options,disabled:(n=b.disabled)!=null?n:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:p}),_=C.useRef(!1),k=C.useRef({static:!1,hold:!1}),D=$Ie(d),T=wt(ie=>b?d===null?b.options.indexOf(ie):b.options.findIndex(ue=>D(ue,ie)):N.options.findIndex(ue=>D(ue.dataRef.current.value,ie))),R=C.useCallback(ie=>Ya(M.mode,{1:()=>w.some(ue=>D(ue,ie)),0:()=>D(w,ie)}),[w]),O=wt(ie=>N.activeOptionIndex===T(ie)),M=C.useMemo(()=>({...N,immediate:g,optionsPropsRef:k,value:w,defaultValue:v,disabled:f,mode:m?1:0,virtual:b?N.virtual:null,get activeOptionIndex(){if(_.current&&N.activeOptionIndex===null&&(b?b.options.length>0:N.options.length>0)){if(b){let ue=b.options.findIndex(ae=>{var Se,ye;return!((ye=(Se=b.disabled)==null?void 0:Se.call(b,ae))!=null&&ye)});if(ue!==-1)return ue}let ie=N.options.findIndex(ue=>!ue.dataRef.current.disabled);if(ie!==-1)return ie}return N.activeOptionIndex},calculateIndex:T,compare:D,isSelected:R,isActive:O}),[w,v,f,m,p,N,b]);Yn(()=>{var ie;b&&j({type:7,options:b.options,disabled:(ie=b.disabled)!=null?ie:null})},[b,b==null?void 0:b.options,b==null?void 0:b.disabled]),Yn(()=>{N.dataRef.current=M},[M]);let P=M.comboboxState===0;QIe(P,[M.buttonElement,M.inputElement,M.optionsElement],()=>$.closeCombobox());let F=C.useMemo(()=>{var ie,ue,ae;return{open:M.comboboxState===0,disabled:f,activeIndex:M.activeOptionIndex,activeOption:M.activeOptionIndex===null?null:M.virtual?M.virtual.options[(ie=M.activeOptionIndex)!=null?ie:0]:(ae=(ue=M.options[M.activeOptionIndex])==null?void 0:ue.dataRef.current.value)!=null?ae:null,value:w}},[M,f,w]),V=wt(()=>{if(M.activeOptionIndex!==null){if($.setIsTyping(!1),M.virtual)A(M.virtual.options[M.activeOptionIndex]);else{let{dataRef:ie}=M.options[M.activeOptionIndex];A(ie.current.value)}$.goToOption(ur.Specific,M.activeOptionIndex)}}),H=wt(()=>{j({type:0}),_.current=!0}),L=wt(()=>{j({type:1}),_.current=!1,h==null||h()}),I=wt(ie=>{j({type:3,isTyping:ie})}),B=wt((ie,ue,ae)=>(_.current=!1,ie===ur.Specific?j({type:2,focus:ur.Specific,idx:ue,trigger:ae}):j({type:2,focus:ie,trigger:ae}))),z=wt((ie,ue)=>(j({type:4,payload:{id:ie,dataRef:ue}}),()=>{M.isActive(ue.current.value)&&(_.current=!0),j({type:5,id:ie})})),A=wt(ie=>Ya(M.mode,{0(){return S==null?void 0:S(ie)},1(){let ue=M.value.slice(),ae=ue.findIndex(Se=>D(Se,ie));return ae===-1?ue.push(ie):ue.splice(ae,1),S==null?void 0:S(ue)}})),W=wt(ie=>{j({type:6,trigger:ie})}),q=wt(ie=>{j({type:8,element:ie})}),Y=wt(ie=>{j({type:9,element:ie})}),U=wt(ie=>{j({type:10,element:ie})}),$=C.useMemo(()=>({onChange:A,registerOption:z,goToOption:B,setIsTyping:I,closeCombobox:L,openCombobox:H,setActivationTrigger:W,selectActiveOption:V,setInputElement:q,setButtonElement:Y,setOptionsElement:U}),[]),[G,Z]=vIe(),te=t===null?{}:{ref:t},Q=C.useCallback(()=>{if(v!==void 0)return S==null?void 0:S(v)},[S,v]),ne=Ci();return C.createElement(Z,{value:G,props:{htmlFor:(r=M.inputElement)==null?void 0:r.id},slot:{open:M.comboboxState===0,disabled:f}},C.createElement(zAe,null,C.createElement(tR.Provider,{value:$},C.createElement(jg.Provider,{value:M},C.createElement(WAe,{value:Ya(M.comboboxState,{0:Ng.Open,1:Ng.Closed})},u!=null&&C.createElement(uIe,{disabled:f,data:w!=null?{[u]:w}:{},form:l,onReset:Q}),ne({ourProps:te,theirProps:y,slot:F,defaultTag:mPe,name:"Combobox"}))))))}let bPe="input";function xPe(e,t){var n,r,s,o,i;let a=rp("Combobox.Input"),l=Ub("Combobox.Input"),u=C.useId(),d=DY(),{id:f=d||`headlessui-combobox-input-${u}`,onChange:h,displayValue:p,disabled:m=a.disabled||!1,autoFocus:g=!1,type:b="text",...x}=e,y=C.useRef(null),v=ll(y,t,FAe(),l.setInputElement),w=F1(a.inputElement),S=Vb(),N=wt(()=>{l.onChange(null),a.optionsElement&&(a.optionsElement.scrollTop=0),l.goToOption(ur.Nothing)}),j=C.useMemo(()=>{var A;return typeof p=="function"&&a.value!==void 0?(A=p(a.value))!=null?A:"":typeof a.value=="string"?a.value:""},[a.value,p]);hF(([A,W],[q,Y])=>{if(a.isTyping)return;let U=y.current;U&&((Y===0&&W===1||A!==q)&&(U.value=A),requestAnimationFrame(()=>{if(a.isTyping||!U||(w==null?void 0:w.activeElement)!==U)return;let{selectionStart:$,selectionEnd:G}=U;Math.abs((G??0)-($??0))===0&&$===0&&U.setSelectionRange(U.value.length,U.value.length)}))},[j,a.comboboxState,w,a.isTyping]),hF(([A],[W])=>{if(A===0&&W===1){if(a.isTyping)return;let q=y.current;if(!q)return;let Y=q.value,{selectionStart:U,selectionEnd:$,selectionDirection:G}=q;q.value="",q.value=Y,G!==null?q.setSelectionRange(U,$,G):q.setSelectionRange(U,$)}},[a.comboboxState]);let _=C.useRef(!1),k=wt(()=>{_.current=!0}),D=wt(()=>{S.nextFrame(()=>{_.current=!1})}),T=wt(A=>{switch(l.setIsTyping(!0),A.key){case gs.Enter:if(a.comboboxState!==0||_.current)return;if(A.preventDefault(),A.stopPropagation(),a.activeOptionIndex===null){l.closeCombobox();return}l.selectActiveOption(),a.mode===0&&l.closeCombobox();break;case gs.ArrowDown:return A.preventDefault(),A.stopPropagation(),Ya(a.comboboxState,{0:()=>l.goToOption(ur.Next),1:()=>l.openCombobox()});case gs.ArrowUp:return A.preventDefault(),A.stopPropagation(),Ya(a.comboboxState,{0:()=>l.goToOption(ur.Previous),1:()=>{_n.flushSync(()=>l.openCombobox()),a.value||l.goToOption(ur.Last)}});case gs.Home:if(A.shiftKey)break;return A.preventDefault(),A.stopPropagation(),l.goToOption(ur.First);case gs.PageUp:return A.preventDefault(),A.stopPropagation(),l.goToOption(ur.First);case gs.End:if(A.shiftKey)break;return A.preventDefault(),A.stopPropagation(),l.goToOption(ur.Last);case gs.PageDown:return A.preventDefault(),A.stopPropagation(),l.goToOption(ur.Last);case gs.Escape:return a.comboboxState!==0?void 0:(A.preventDefault(),a.optionsElement&&!a.optionsPropsRef.current.static&&A.stopPropagation(),a.mode===0&&a.value===null&&N(),l.closeCombobox());case gs.Tab:if(a.comboboxState!==0)return;a.mode===0&&a.activationTrigger!==1&&l.selectActiveOption(),l.closeCombobox();break}}),R=wt(A=>{h==null||h(A),a.mode===0&&A.target.value===""&&N(),l.openCombobox()}),O=wt(A=>{var W,q,Y;let U=(W=A.relatedTarget)!=null?W:Xc.find($=>$!==A.currentTarget);if(!((q=a.optionsElement)!=null&&q.contains(U))&&!((Y=a.buttonElement)!=null&&Y.contains(U))&&a.comboboxState===0)return A.preventDefault(),a.mode===0&&a.value===null&&N(),l.closeCombobox()}),M=wt(A=>{var W,q,Y;let U=(W=A.relatedTarget)!=null?W:Xc.find($=>$!==A.currentTarget);(q=a.buttonElement)!=null&&q.contains(U)||(Y=a.optionsElement)!=null&&Y.contains(U)||a.disabled||a.immediate&&a.comboboxState!==0&&S.microTask(()=>{_n.flushSync(()=>l.openCombobox()),l.setActivationTrigger(1)})}),P=O1(),F=gIe(),{isFocused:V,focusProps:H}=SY({autoFocus:g}),{isHovered:L,hoverProps:I}=wY({isDisabled:m}),B=C.useMemo(()=>({open:a.comboboxState===0,disabled:m,hover:L,focus:V,autofocus:g}),[a,L,V,g,m]),z=GT({ref:v,id:f,role:"combobox",type:b,"aria-controls":(n=a.optionsElement)==null?void 0:n.id,"aria-expanded":a.comboboxState===0,"aria-activedescendant":a.activeOptionIndex===null?void 0:a.virtual?(r=a.options.find(A=>!A.dataRef.current.disabled&&a.compare(A.dataRef.current.value,a.virtual.options[a.activeOptionIndex])))==null?void 0:r.id:(s=a.options[a.activeOptionIndex])==null?void 0:s.id,"aria-labelledby":P,"aria-describedby":F,"aria-autocomplete":"list",defaultValue:(i=(o=e.defaultValue)!=null?o:a.defaultValue!==void 0?p==null?void 0:p(a.defaultValue):null)!=null?i:a.defaultValue,disabled:m||void 0,autoFocus:g,onCompositionStart:k,onCompositionEnd:D,onKeyDown:T,onChange:R,onFocus:M,onBlur:O},H,I);return Ci()({ourProps:z,theirProps:x,slot:B,defaultTag:bPe,name:"Combobox.Input"})}let yPe="button";function vPe(e,t){var n;let r=rp("Combobox.Button"),s=Ub("Combobox.Button"),o=ll(t,s.setButtonElement),i=C.useId(),{id:a=`headlessui-combobox-button-${i}`,disabled:l=r.disabled||!1,autoFocus:u=!1,...d}=e,f=LY(r.inputElement),h=wt(j=>{switch(j.key){case gs.Space:case gs.Enter:j.preventDefault(),j.stopPropagation(),r.comboboxState===1&&_n.flushSync(()=>s.openCombobox()),f();return;case gs.ArrowDown:j.preventDefault(),j.stopPropagation(),r.comboboxState===1&&(_n.flushSync(()=>s.openCombobox()),r.value||s.goToOption(ur.First)),f();return;case gs.ArrowUp:j.preventDefault(),j.stopPropagation(),r.comboboxState===1&&(_n.flushSync(()=>s.openCombobox()),r.value||s.goToOption(ur.Last)),f();return;case gs.Escape:if(r.comboboxState!==0)return;j.preventDefault(),r.optionsElement&&!r.optionsPropsRef.current.static&&j.stopPropagation(),_n.flushSync(()=>s.closeCombobox()),f();return;default:return}}),p=wt(j=>{j.preventDefault(),!hIe(j.currentTarget)&&(j.button===eR.Left&&(r.comboboxState===0?s.closeCombobox():s.openCombobox()),f())}),m=O1([a]),{isFocusVisible:g,focusProps:b}=SY({autoFocus:u}),{isHovered:x,hoverProps:y}=wY({isDisabled:l}),{pressed:v,pressProps:w}=XMe({disabled:l}),S=C.useMemo(()=>({open:r.comboboxState===0,active:v||r.comboboxState===0,disabled:l,value:r.value,hover:x,focus:g}),[r,x,g,v,l]),N=GT({ref:o,id:a,type:eAe(e,r.buttonElement),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":(n=r.optionsElement)==null?void 0:n.id,"aria-expanded":r.comboboxState===0,"aria-labelledby":m,disabled:l||void 0,autoFocus:u,onMouseDown:p,onKeyDown:h},b,y,w);return Ci()({ourProps:N,theirProps:d,slot:S,defaultTag:yPe,name:"Combobox.Button"})}let wPe="div",SPe=_k.RenderStrategy|_k.Static;function CPe(e,t){var n,r,s;let o=C.useId(),{id:i=`headlessui-combobox-options-${o}`,hold:a=!1,anchor:l,portal:u=!1,modal:d=!0,transition:f=!1,...h}=e,p=rp("Combobox.Options"),m=Ub("Combobox.Options"),g=OAe(l);g&&(u=!0);let[b,x]=LAe(g),[y,v]=C.useState(null),w=$Ae(),S=ll(t,g?b:null,m.setOptionsElement,v),N=F1(p.optionsElement),j=UAe(),[_,k]=dAe(f,y,j!==null?(j&Ng.Open)===Ng.Open:p.comboboxState===0);HIe(_,p.inputElement,m.closeCombobox);let D=p.__demoMode?!1:d&&p.comboboxState===0;iAe(D,N);let T=p.__demoMode?!1:d&&p.comboboxState===0;VIe(T,{allowed:C.useCallback(()=>[p.inputElement,p.buttonElement,p.optionsElement],[p.inputElement,p.buttonElement,p.optionsElement])}),Yn(()=>{var z;p.optionsPropsRef.current.static=(z=e.static)!=null?z:!1},[p.optionsPropsRef,e.static]),Yn(()=>{p.optionsPropsRef.current.hold=a},[p.optionsPropsRef,a]),mAe(p.comboboxState===0,{container:p.optionsElement,accept(z){return z.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:z.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(z){z.setAttribute("role","none")}});let R=O1([(n=p.buttonElement)==null?void 0:n.id]),O=C.useMemo(()=>({open:p.comboboxState===0,option:void 0}),[p.comboboxState]),M=wt(()=>{m.setActivationTrigger(0)}),P=wt(z=>{z.preventDefault(),m.setActivationTrigger(0)}),F=GT(g?w():{},{"aria-labelledby":R,role:"listbox","aria-multiselectable":p.mode===1?!0:void 0,id:i,ref:S,style:{...h.style,...x,"--input-width":iF(p.inputElement,!0).width,"--button-width":iF(p.buttonElement,!0).width},onWheel:p.activationTrigger===0?void 0:M,onMouseDown:P,...uAe(k)}),V=_&&p.comboboxState===1,H=Mk(V,(r=p.virtual)==null?void 0:r.options),L=Mk(V,p.value),I=wt(z=>p.compare(L,z));if(p.virtual){if(H===void 0)throw new Error("Missing `options` in virtual mode");Object.assign(h,{children:C.createElement(jg.Provider,{value:H!==p.virtual.options?{...p,virtual:{...p.virtual,options:H}}:p},C.createElement(hPe,{slot:O},h.children))})}let B=Ci();return C.createElement(aPe,{enabled:u?e.static||_:!1},C.createElement(jg.Provider,{value:p.mode===1?p:{...p,isSelected:I}},B({ourProps:F,theirProps:{...h,children:C.createElement(HAe,{freeze:V},typeof h.children=="function"?(s=h.children)==null?void 0:s.call(h,O):h.children)},slot:O,defaultTag:wPe,features:SPe,visible:_,name:"Combobox.Options"})))}let NPe="div";function jPe(e,t){var n,r,s,o;let i=rp("Combobox.Option"),a=Ub("Combobox.Option"),l=C.useId(),{id:u=`headlessui-combobox-option-${l}`,value:d,disabled:f=(s=(r=(n=i.virtual)==null?void 0:n.disabled)==null?void 0:r.call(n,d))!=null?s:!1,order:h=null,...p}=e,m=LY(i.inputElement),g=i.virtual?i.activeOptionIndex===i.calculateIndex(d):i.activeOptionIndex===null?!1:((o=i.options[i.activeOptionIndex])==null?void 0:o.id)===u,b=i.isSelected(d),x=C.useRef(null),y=_d({disabled:f,value:d,domRef:x,order:h}),v=C.useContext(WY),w=ll(t,x,v?v.measureElement:null),S=wt(()=>{a.setIsTyping(!1),a.onChange(d)});Yn(()=>a.registerOption(u,y),[y,u]);let N=C.useRef(!(i.virtual||i.__demoMode));Yn(()=>{if(!i.virtual&&!i.__demoMode)return sa().requestAnimationFrame(()=>{N.current=!0})},[i.virtual,i.__demoMode]),Yn(()=>{if(N.current&&i.comboboxState===0&&g&&i.activationTrigger!==0)return sa().requestAnimationFrame(()=>{var P,F;(F=(P=x.current)==null?void 0:P.scrollIntoView)==null||F.call(P,{block:"nearest"})})},[x,g,i.comboboxState,i.activationTrigger,i.activeOptionIndex]);let j=wt(P=>{P.preventDefault(),P.button===eR.Left&&(f||(S(),$Y()||requestAnimationFrame(()=>m()),i.mode===0&&a.closeCombobox()))}),_=wt(()=>{if(f)return a.goToOption(ur.Nothing);let P=i.calculateIndex(d);a.goToOption(ur.Specific,P)}),k=aAe(),D=wt(P=>k.update(P)),T=wt(P=>{if(!k.wasMoved(P)||f||g)return;let F=i.calculateIndex(d);a.goToOption(ur.Specific,F,0)}),R=wt(P=>{k.wasMoved(P)&&(f||g&&(i.optionsPropsRef.current.hold||a.goToOption(ur.Nothing)))}),O=C.useMemo(()=>({active:g,focus:g,selected:b,disabled:f}),[g,b,f]),M={id:u,ref:w,role:"option",tabIndex:f===!0?void 0:-1,"aria-disabled":f===!0?!0:void 0,"aria-selected":b,disabled:void 0,onMouseDown:j,onFocus:_,onPointerEnter:D,onMouseEnter:D,onPointerMove:T,onMouseMove:T,onPointerLeave:R,onMouseLeave:R};return Ci()({ourProps:M,theirProps:p,slot:O,defaultTag:NPe,name:"Combobox.Option"})}let kPe=Ni(gPe),qY=Ni(vPe),YY=Ni(xPe),EPe=NIe,GY=Ni(CPe),ZY=Ni(jPe),_Pe=Object.assign(kPe,{Input:YY,Button:qY,Label:EPe,Options:GY,Option:ZY});function DPe({elementId:e}){const t=C.useRef(!1);return C.useEffect(()=>{if(t.current)return;const n=document.getElementById(e);return n&&(n.classList.add("semaphor-scope"),t.current=!0),()=>{n&&(n.classList.remove("semaphor-scope"),t.current=!1)}},[e]),null}const TPe=C.memo(({option:e,currentStyle:t})=>c.jsxs(ZY,{style:{borderRadius:t==null?void 0:t.controlInputRadius},value:e,className:"group flex cursor-default select-none items-start gap-2 rounded-sm px-3 py-1.5 data-[focus]:bg-muted",children:[c.jsx(Dr,{className:"invisible size-4 shrink-0 group-data-[selected]:visible"}),e.value]},e.id),(e,t)=>e.option.id===t.option.id&&e.option.value===t.option.value);function RPe({options:e,onChange:t,selectedOptions:n,multiple:r=!0,externalFilteredOptions:s,selectAllChecked:o,onSelectAllCheckedChange:i,inputClassName:a,renderFilterModeButton:l,showNegativeIndicator:u,isSearching:d,resultSource:f="local",searchError:h,query:p,onQueryChange:m,filterDataType:g,onEnterKey:b,activeFilterValue:x}){const[y,v]=C.useState(""),w=p!==void 0?p:y,S=m||v,N=ee(M=>M.themeStyle),j=s||e;function _(M,P){if(P)return"";const F=[">","<",">=","<=","="];return(g?Vi(g):!1)&&x&&F.includes(x.operation)?`${x.operation}${x.values[0]}`:M!=null&&M.length?M==null?void 0:M.map(H=>H.value).join(", "):""}function k(M){Array.isArray(M)||(M=[M]),t(M)}function D(){return d||j&&j.length>0?null:c.jsx("div",{className:"relative cursor-default select-none px-4 py-2",children:"No records found."})}function T(){return d?c.jsxs("div",{className:"flex items-center gap-2 border-b border-b-muted px-4 py-2 text-xs text-muted-foreground",children:[c.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Searching..."]}):h&&w?c.jsx("div",{className:"border-b border-b-muted px-4 py-2 text-xs text-amber-600",children:"Search unavailable. Showing available results."}):null}function R(){return w||!(e!=null&&e.length)?null:c.jsxs("div",{className:"border-b border-b-muted px-4 py-2 text-xs text-muted-foreground",children:["Showing top ",e.length," values. Type to search more..."]})}function O(){return!r||!(j!=null&&j.length)?null:c.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-b-muted px-4 py-2",children:[l==null?void 0:l(),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{children:"All"}),c.jsx(on,{className:"border-muted-foreground/50",checked:o,onCheckedChange:i})]})]})}return c.jsx(_Pe,{multiple:r,value:n,onChange:k,onClose:()=>{S("")},by:(M,P)=>Array.isArray(M)||Array.isArray(P)?!1:!M||!P?M===P:M.id===P.id,children:({open:M})=>c.jsxs("div",{children:[c.jsxs("div",{className:"relative flex items-center gap-0.5",children:[u&&c.jsx("div",{className:"h-8 w-0.5 bg-red-400"}),c.jsx(YY,{className:K("h-8 w-full rounded-sm border border-border bg-background py-1.5 pl-3 pr-8 text-sm","data-[focus]:outline-border-none focus:outline-none data-[focus]:outline-none data-[focus]:-outline-offset-2",a),style:{borderRadius:N==null?void 0:N.controlInputRadius},displayValue:P=>_(P,M),onChange:P=>S(P.target.value),onKeyDown:P=>{if(P.key==="Enter"&&b){const F=/^(>=|<=|>|<|=)/.test(w.trim()),V=g?Vi(g):!1;F&&V&&(P.preventDefault(),b()&&P.target.blur())}}}),c.jsx(qY,{className:"group absolute inset-y-0 right-0 rounded-sm bg-muted/40 px-2.5 transition-colors hover:bg-muted/60",children:c.jsx(Bs,{className:"size-4 text-muted-foreground transition-colors group-hover:text-foreground"})})]}),c.jsxs(GY,{anchor:"bottom",transition:!0,style:{borderRadius:N==null?void 0:N.controlInputRadius},className:Ou("mt-1 !max-h-60 w-[var(--input-width)] overflow-y-auto rounded-sm border border-border bg-background p-1 text-sm [--anchor-gap:var(--spacing-1)] empty:invisible","transition duration-100 ease-in data-[leave]:data-[closed]:opacity-0"),children:[M&&c.jsx(DPe,{elementId:"headlessui-portal-root"}),T(),R(),D(),O(),j==null?void 0:j.map(P=>c.jsx(TPe,{option:P,currentStyle:N},P.id))]})]})})}const SF=[{value:"=",label:"Equal to",symbol:"="},{value:">",label:"Greater than",symbol:">"},{value:">=",label:"Greater than or equal",symbol:"≥"},{value:"<",label:"Less than",symbol:"<"},{value:"<=",label:"Less than or equal",symbol:"≤"},{value:"between",label:"Between",symbol:"⟷"},{value:"not between",label:"Not Between",symbol:"⇎"}],MPe=new Set(["=",">","<",">=","<=","between","not between"]);function IPe(e){return MPe.has(e)?e:">="}function APe({filter:e}){var S;const[t,n]=C.useState(">="),[r,s]=C.useState(""),[o,i]=C.useState(""),[a,l]=C.useState(""),[u,d]=C.useState(!0),f=C.useRef(null),h=C.useRef(!1),[,p]=C.useTransition(),m=vm(r,300),g=vm(o,300),b=vm(a,300),x=ee(N=>N.filterValues),y=ee(N=>N.themeStyle),{addOrUpdateFilterValue:v,removeFilterValues:w}=Jt();return C.useEffect(()=>()=>{f.current=null,h.current=!1},[]),C.useEffect(()=>{const N=x==null?void 0:x.find(j=>j.filterId===e.id);if(N&&N.operation!=="in"){const j=IPe(N.operation);if(f.current!==j&&(n(j),f.current=j,h.current=!1),j==="between"||j==="not between"){const k=N.values[0],D=N.values[1];i(k!=null?String(k):""),l(D!=null?String(D):""),s("")}else{const k=N.values[0];s(k!=null?String(k):""),i(""),l("")}}else f.current!==null&&(s(""),i(""),l(""),!h.current&&f.current!==t&&(n(">="),h.current=!1),f.current=null),d(!1)},[x,e.id]),C.useEffect(()=>{u&&(t==="between"||t==="not between"?g===o&&b===a&&d(!1):m===r&&d(!1))},[u,t,r,m,o,a,g,b]),C.useEffect(()=>{if(!u)if(t==="between"||t==="not between"){const N=g&&g.trim()!=="",j=b&&b.trim()!=="";if(!N||!j){!N&&!j&&(p(()=>{w(e.id)}),f.current=t);return}const _=Number(g),k=Number(b);if(isNaN(_)||isNaN(k))return;const D={filterId:e.id,connectionType:e.database==="NA"?"api":"database",name:e.column,valueType:ri(e),operation:t,values:[_,k]};p(()=>{v(D)}),f.current=t}else{if(!m||m.trim()===""){p(()=>{w(e.id)}),f.current=null;return}const N=Number(m);if(isNaN(N))return;const j={filterId:e.id,connectionType:e.database==="NA"?"api":"database",name:e.column,valueType:ri(e),operation:t,values:[N]};p(()=>{v(j)}),f.current=t}},[t,m,g,b,e.id,e.column,e.database,u,v,w,e]),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(at,{value:t,onValueChange:N=>{h.current=!0,n(N)},children:[c.jsx(st,{className:"h-8 w-16",style:{borderRadius:y==null?void 0:y.controlInputRadius},children:c.jsx("span",{className:"font-mono text-base",children:(S=SF.find(N=>N.value===t))==null?void 0:S.symbol})}),c.jsx(ot,{children:SF.map(N=>c.jsx(fe,{value:N.value,children:c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"font-mono",children:N.symbol}),c.jsx("span",{children:N.label})]})},N.value))})]}),t==="between"||t==="not between"?c.jsxs(c.Fragment,{children:[c.jsx(Hn,{type:"number",placeholder:"Min",value:o,onChange:N=>i(N.target.value),className:"h-8 flex-1",style:{borderRadius:y==null?void 0:y.controlInputRadius}}),c.jsx(Hn,{type:"number",placeholder:"Max",value:a,onChange:N=>l(N.target.value),className:"h-8 flex-1",style:{borderRadius:y==null?void 0:y.controlInputRadius}})]}):c.jsx(Hn,{type:"number",placeholder:"Value",value:r,onChange:N=>s(N.target.value),className:"h-8 flex-1",style:{borderRadius:y==null?void 0:y.controlInputRadius}})]})}function PPe({filter:e}){const t=e.searchMode==="numeric",n=ee(v=>v.themeStyle),{filteredRecords:r,isSingleSelect:s,allSelected:o,handleChange:i,handleSelectAll:a,handleApplyOperatorExpression:l,query:u,setQuery:d,isLoading:f,isFetching:h,isError:p,selectedRecords:m,isSearching:g,searchError:b,resultSource:x,activeFilterValue:y}=A1(e,{enableServerSearch:!0,searchDebounceMs:300,minSearchLength:2,searchThreshold:5});return f||h?c.jsx(Hi,{style:{borderRadius:n==null?void 0:n.controlInputRadius},className:"h-8 w-full bg-foreground/10"}):p?c.jsx("div",{className:"flex h-8 w-full items-center bg-muted px-2 text-sm",children:"Error"}):t?c.jsx(APe,{filter:e}):c.jsx(RPe,{showNegativeIndicator:e.operation==="not in",renderFilterModeButton:()=>c.jsx(OPe,{filter:e}),inputClassName:"h-8",options:r,selectedOptions:m,onChange:i,multiple:!s,selectAllChecked:o,onSelectAllCheckedChange:a,isSearching:g,resultSource:x,searchError:b,query:u,onQueryChange:d,filterDataType:e.dataType,activeFilterValue:y,onEnterKey:l})}function OPe({filter:e}){const t=e.operation==="in"?"include":"exclude",{setFilterMode:n,setFilterDefaultValues:r}=Jt(),s=ee(d=>d.isDashboardEditing),o=ee(d=>{var f;return(f=d.filterValues)==null?void 0:f.find(h=>h.filterId===e.id)});function i(){t==="include"?n(e.id,"exclude"):n(e.id,"include")}function a(){o!=null&&o.values&&r(e.id,o.values)}const l=(o==null?void 0:o.values)&&o.values.length>0,u=e.defaultValues&&e.defaultValues.length>0;return c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(se,{onClick:i,variant:"secondary",size:"sm",className:K("h-6 text-xs hover:underline",{}),children:dw(t)}),s&&c.jsx(se,{onClick:a,variant:u?"default":"ghost",size:"sm",className:K("h-6 text-xs",{"opacity-50":!l}),disabled:!l,title:u?"Update default values":l?"Set current selection as default":"Select values to set as default",children:"Default"})]})}function FPe({filter:e}){var o;const{filteredRecords:t,handleChange:n,selectedRecords:r}=A1(e);function s(i){n([{value:i,id:i}])}return c.jsx(ra,{onValueChange:s,value:((o=r==null?void 0:r[0])==null?void 0:o.value)||"",className:"mt-2 flex gap-3 overflow-x-auto",children:t==null?void 0:t.map(i=>c.jsxs("div",{className:"flex gap-2",children:[c.jsx(vr,{value:i.value,id:"r1"}),c.jsx(le,{className:"text-muted-foreground",htmlFor:"r1",children:i.value})]},i.value))})}function $Pe({filter:e}){var d;const t=ee(f=>f.themeStyle),{filteredRecords:n,handleChange:r,selectedRecords:s,isLoading:o,isFetching:i,isError:a}=A1(e),l=n&&n.length>10;function u(f){r([{value:f,id:f}])}return o||i?c.jsx(Hi,{style:{borderRadius:t==null?void 0:t.controlInputRadius},className:"h-8 w-full bg-foreground/10"}):a?c.jsx("div",{className:"flex h-8 w-full items-center bg-muted px-2 text-sm",children:"Error loading filter options"}):c.jsxs("div",{className:"mt-2 space-y-2",children:[l&&c.jsx("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:c.jsx(fr,{children:c.jsxs(Dn,{delayDuration:0,children:[c.jsx(Tn,{asChild:!0,children:c.jsxs("div",{className:"flex items-center gap-1 rounded-sm bg-amber-500/10 px-2 py-1",children:[c.jsx(wr,{className:"h-3 w-3 text-amber-600"}),c.jsxs("span",{className:"text-amber-600",children:["Many options (",n.length,")"]})]})}),c.jsx($n,{side:"bottom",className:"max-w-xs",children:c.jsxs("p",{className:"text-xs",children:["This filter has ",n.length," options. Consider using a dropdown for better usability with many options."]})})]})})}),c.jsx(js,{value:((d=s==null?void 0:s[0])==null?void 0:d.value)||"",onValueChange:u,className:"w-full",children:c.jsx(os,{className:"h-auto max-h-[6rem] flex-wrap justify-start overflow-x-auto",children:n==null?void 0:n.map(f=>c.jsx(Qt,{value:f.value,children:f.value},f.value))})})]})}function nR({filter:e}){return dd(e.dataType)?c.jsx(kMe,{filter:e}):e.uiType==="radio"&&e.type==="single"?c.jsx(FPe,{filter:e}):e.uiType==="tabs"&&e.type==="single"?c.jsx($Pe,{filter:e}):c.jsx(PPe,{filter:e})}function LPe({frame:e}){const[t,n]=C.useState(!1),r=e==null?void 0:e.cards[0],{data:s,isPending:o,isError:i}=Jl(r),a=e==null?void 0:e.cards[1],{data:l,isLoading:u,isFetching:d}=Jl(a);return(a==null?void 0:a.type)!=="text"?c.jsx(Sg,{card:r,data:(s==null?void 0:s.records)||[],isPending:o,isError:i}):c.jsxs(qs,{className:K("group relative overflow-y-auto",t?"m-4":"mx-0"),children:[t?c.jsx("div",{className:"overflow-y-auto break-words p-1",children:c.jsx(gh,{card:a,data:(l==null?void 0:l.records)||[],isLoading:!1})}):c.jsx(Sg,{card:r,data:(s==null?void 0:s.records)||[],isPending:o,isError:i}),c.jsx("div",{className:K("fixed z-10",{"invisible bottom-4 right-4 group-hover:visible":t,"right-6 top-6":!t}),children:c.jsx($b,{disabled:u||d,className:K("h-7 p-1"),pressed:t,onPressedChange:n,"aria-label":"Toggle bold",children:t?c.jsx(Rne,{className:"size-4 text-muted-foreground/70"}):c.jsx(Mne,{className:"size-4 text-muted-foreground/70"})})})]})}function Tv(e){return{clickFilter:Bl,drillToDetail:tb,drillThrough:Cy,drillToURL:eb,drillDown:Pne,drillUp:One,dynamicDrill:rl,inlineDrill:bw}[e]||Bl}function Dd(e){return{clickFilter:"Filter Dashboard",drillToDetail:"Show Details",drillThrough:"Navigate to Dashboard",drillToURL:"Open External Link",drillDown:"Drill Down",drillUp:"Drill Up",dynamicDrill:"Explore Field",inlineDrill:"Drill"}[e]||"Interaction"}function zPe(e,t,n,r,s){const o=Tv(e.mode),i=e.label||Dd(e.mode),a=BPe(e,t,n,r,s);return{label:i,icon:o,targetInfo:a,interaction:e}}function BPe(e,t,n=0,r,s){var o,i,a,l,u,d;switch(e.mode){case"clickFilter":{if((o=e.applyToCardIds)!=null&&o.length){const f=e.applyToCardIds.length;return`Apply to ${f} ${f===1?"card":"cards"}`}return(i=e.excludeCardIds)!=null&&i.length?"Apply to all cards":"Apply to other cards"}case"drillToDetail":{if(e.targetInsightId)return"Drill into Insight";const f=((a=e.detailFields)==null?void 0:a.length)||0;return f>0?`Show ${f} detail ${f===1?"field":"fields"}`:"Show detail table"}case"drillThrough":return e.targetDashboardId,"Navigate to dashboard";case"drillToURL":{if(e.urlTemplate)try{return`Open ${new URL(e.urlTemplate).hostname}`}catch{return"Open external link"}return"Open external link"}case"drillDown":{if(e.hierarchyId&&t){const f=t.find(h=>h.id===e.hierarchyId);if(f&&f.steps.length>0){let h;if((f.type==="date"||f.baseField)&&r&&f.baseField){const p=yE(f,r,s),m=xE(f,p);h=m==null?void 0:m.field}else h=(l=f.steps[n])==null?void 0:l.field;return h?h.label:n>=f.steps.length?"End of path":f.label||"Drill by hierarchy"}}return"Drill to next level"}case"drillUp":{if(n>0&&e.hierarchyId&&t){const f=t.find(h=>h.id===e.hierarchyId);if(f&&f.steps.length>0){const h=(u=f.steps[n-2])==null?void 0:u.field;return h?`Back to ${h.label}`:`Back to All: ${f.label||"Data"}`}}return"Go back one level"}case"dynamicDrill":{if(e.drillField)return`Drill into ${e.drillField.label} data`;if((d=e.availableFields)!=null&&d.length){const f=e.availableFields.length;return`Choose from ${f} ${f===1?"dimension":"dimensions"}`}return"Explore dimension"}case"inlineDrill":{const f=e.inlineLimit||100,h=e.displayMode||"table";return`Show ${f} records as ${h}`}default:return""}}function VPe(e,t,n,r,s){return e.map(o=>zPe(o,t,n,r,s))}function HPe({open:e,onOpenChange:t,position:n,interactions:r,selectedConditions:s,onSelectInteraction:o,drillHierarchies:i,cardId:a,card:l}){const{currentDepth:u,breadcrumbs:d}=Ut(w=>{var S,N,j;return{currentDepth:a?((N=(S=w.interactionStates[a])==null?void 0:S.breadcrumbs)==null?void 0:N.length)??0:0,breadcrumbs:a?((j=w.interactionStates[a])==null?void 0:j.breadcrumbs)??[]:[]}}),f=E.useMemo(()=>VPe(r,i,u,l,d),[r,i,u,l,d]),h=E.useMemo(()=>{if(s.length===0)return"";const w=s[0];if(w.label){const S=w.label.split(/[=><]/);if(S.length>1)return S[1].trim()}return String(w.value)},[s]);if(E.useEffect(()=>{if(!e)return;const w=S=>{S.key==="Escape"&&t(!1)};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[e,t]),!e||!n)return null;const p=280,m=80+f.length*60,g=window.innerWidth,b=window.innerHeight;let x=n.x,y=n.y+8;x+p>g&&(x=Math.max(8,g-p-8)),y+m>b&&(y=Math.max(8,n.y-m-8));const v=c.jsxs("div",{className:"semaphor-scope",style:{position:"fixed",inset:0,pointerEvents:"none",background:"transparent"},children:[c.jsx("div",{className:"fixed inset-0",style:{zIndex:50,pointerEvents:"auto",background:"transparent"},onClick:()=>t(!1),"aria-hidden":"true"}),c.jsxs("div",{className:K("fixed rounded-lg border bg-popover shadow-lg","animate-in fade-in-0 zoom-in-95"),style:{left:`${x}px`,top:`${y}px`,zIndex:51,width:`${p}px`,maxHeight:"400px",pointerEvents:"auto"},role:"menu","aria-label":"Select interaction",children:[h&&c.jsxs("div",{className:"border-b px-4 py-3",children:[c.jsx("p",{className:"text-xs text-muted-foreground",children:"Selected"}),c.jsx("p",{className:"text-sm font-medium",children:h})]}),c.jsx("div",{className:"max-h-80 overflow-y-auto py-1",children:f.map((w,S)=>{var _;const N=w.icon,j=w.interaction.mode==="dynamicDrill"&&(S===0||((_=f[S-1])==null?void 0:_.interaction.mode)!=="dynamicDrill");return c.jsxs(E.Fragment,{children:[j&&c.jsx("div",{className:"border-t px-4 py-2",children:c.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"⚡ Explore Other Fields"})}),c.jsxs("button",{className:K("flex w-full items-start gap-3 px-4 py-3","hover:bg-accent hover:text-accent-foreground","cursor-pointer transition-colors","border-b text-left last:border-b-0"),onClick:()=>{o(w.interaction),t(!1)},role:"menuitem",children:[c.jsx("div",{className:"mt-0.5 flex-shrink-0",children:c.jsx(N,{className:"h-4 w-4 text-muted-foreground"})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("p",{className:"mb-1 text-sm font-medium leading-none",children:w.label}),w.targetInfo&&c.jsx("p",{className:"text-xs text-muted-foreground",children:w.targetInfo})]})]})]},S)})})]})]});return _n.createPortal(v,document.body)}function UPe(e){const t=C.useRef([]),n=C.useRef(null),r=C.useRef(null),o=ni(e.interactionConfig).some(h=>h.mode==="clickFilter"&&h.trigger!==void 0),i=im(h=>h.registerClearBlurCallback),a=im(h=>h.unregisterCard);C.useEffect(()=>{const h=()=>{r.current&&f(r.current)};return i(e.id,h),()=>{a(e.id)}},[e.id,i,a]);function l({chart:h,selectedSegments:p,storedOriginalColorsRef:m}){if(!h||!h.canvas||!h.canvas.ownerDocument){console.warn("Chart or canvas is null when trying to toggle blur segments");return}const g=h.data.datasets;m.current||(m.current=g.map((x,y)=>h.getDatasetMeta(y).data.map(w=>w.options.backgroundColor)));const b=m.current;g.forEach((x,y)=>{const v=b[y];if(p.length===0){x.backgroundColor=[...v];return}x.backgroundColor=v.map((w,S)=>p.some(j=>j.datasetIndex===y&&j.dataIndex===S)?w:u(w,.2))});try{h.update()}catch(x){console.warn("Failed to update chart during blur toggle:",x)}}function u(h,p=.2){if(h.startsWith("rgba"))return h.replace(/[\d.]+\)$/g,`${p})`);if(h.startsWith("#")){const m=parseInt(h.slice(1,3),16),g=parseInt(h.slice(3,5),16),b=parseInt(h.slice(5,7),16);return`rgba(${m}, ${g}, ${b}, ${p})`}return h}function d(h,p){var v;if(!o||!p)return;r.current=p;const m=p.getElementsAtEventForMode(h,"nearest",{intersect:!0},!0);if(!m.length)return;const{datasetIndex:g,index:b}=m[0],x={datasetIndex:g,dataIndex:b};if(((v=h.native)==null?void 0:v.shiftKey)||h.shiftKey){const w=t.current.findIndex(S=>S.datasetIndex===g&&S.dataIndex===b);w>=0?t.current.splice(w,1):t.current.push(x)}else{const w=t.current.length===1&&t.current[0].datasetIndex===g&&t.current[0].dataIndex===b;t.current=w?[]:[x]}l({chart:p,selectedSegments:t.current,storedOriginalColorsRef:n})}function f(h){h&&(t.current=[],n.current&&l({chart:h,selectedSegments:[],storedOriginalColorsRef:n}))}return{handleChartClick:d,clearBlur:f}}function WPe({resolvedCardConfig:e,card:t,records:n,chart:r,clickEvent:s}){var u,d,f,h,p,m,g,b,x,y;const o=r==null?void 0:r.getElementsAtEventForMode(s,"nearest",{intersect:!0},!0);if(!o.length)return;const i=o[0].datasetIndex,a=o[0].index,l=(d=(u=o[0].element)==null?void 0:u.$context)==null?void 0:d.raw;console.log("datasetIndex",i),console.log("clickIndex",a),console.log("value",l);try{if(!(n!=null&&n.length))return;const{keys:v}=hr(n),{groupByColumns:w=[],pivotByColumns:S=[],metricColumns:N=[]}=e||t.config,j=_=>w.find(k=>k.label===_)||S.find(k=>k.label===_)||N.find(k=>k.label===_);if(t.type==="map"){const _=v[0],k=((h=(f=l==null?void 0:l.feature)==null?void 0:f.properties)==null?void 0:h.name)||((m=(p=l==null?void 0:l.feature)==null?void 0:p.properties)==null?void 0:m.NAME),D=j(_);return!D||k==null?void 0:{conditions:[{field:D,operator:"=",value:k}]}}if(["pie","funnel","doughnut"].includes(t.type)){const _=v[0],k=v==null?void 0:v[1+i],D=j(_),T=j(k),R=(g=n==null?void 0:n[a])==null?void 0:g[_];if(!D||R==null){console.log("no dim field or value",_,R);return}return{conditions:[{field:D,operator:"=",value:R}],metrics:T?[{field:T,value:l}]:void 0}}if(["stackedBar","bar","line"].includes(t.type)){const _=v[0],k=j(_),D=(b=n==null?void 0:n[a])==null?void 0:b[_];if(!k||D==null){console.log("no dim field or value for stacked bar",_,D);return}const T=N[i]||N[0];if(!T){console.log("no metric field found");return}const R=S[0],M=Object.keys(n[0]).filter(H=>H!==_)[i],F=(M?(x=n==null?void 0:n[a])==null?void 0:x[M]:(y=n==null?void 0:n[a])==null?void 0:y[T.label])??l,V=[{field:k,operator:"=",value:D}];return R&&M&&V.push({field:R,operator:"=",value:M}),{conditions:V,metrics:[{field:T,value:F}]}}}catch(v){console.error("getClickContextFromChart error",v)}}function qPe(e){return e&&typeof e=="object"&&"field"in e&&"operator"in e}function YPe(e){return e&&typeof e=="object"&&"filterId"in e&&"operation"in e&&"values"in e}function KY({filters:e,filterDefinitions:t,contextMode:n,className:r,showLabel:s=!0,labelText:o="Applied Filters:",icon:i}){if(!e||e.length===0)return n==="none"?c.jsx("div",{className:"px-6 pb-4",children:c.jsx("span",{className:"text-xs text-muted-foreground",children:"No filters applied"})}):null;const l=e.map(u=>{var d,f;if(qPe(u))return{fieldName:((d=u.field)==null?void 0:d.label)||((f=u.field)==null?void 0:f.name)||"Unknown",operator:u.operator,value:ZPe(u)};if(YPe(u)){const h=t==null?void 0:t.find(p=>p.id===u.filterId);return{fieldName:(h==null?void 0:h.title)||u.name,operator:u.operation,value:GPe(u)}}else return{fieldName:"Unknown",operator:"=",value:String(u)}}).reduce((u,d)=>(u[d.fieldName]||(u[d.fieldName]=[]),u[d.fieldName].push(d),u),{});return c.jsxs("div",{className:r||"border-b px-6 pb-4",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s&&i&&c.jsxs("div",{className:"flex items-center gap-2 text-foreground/80",children:[i,c.jsx("span",{className:"whitespace-nowrap text-sm font-medium",children:o})]}),s&&!i&&c.jsx("span",{className:"whitespace-nowrap text-sm text-muted-foreground",children:o}),c.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(l).map(([u,d])=>c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsxs("span",{className:"text-sm font-medium",children:[u,":"]}),d.map((f,h)=>c.jsx(Pe,{variant:"outline",className:"cursor-pointer select-none border-primary/20 bg-gradient-to-r from-primary/5 to-primary/10 text-primary shadow-sm transition-all hover:from-primary/10 hover:to-primary/15 hover:shadow-md dark:border-primary/30 dark:from-primary/10 dark:to-primary/20 dark:text-primary dark:hover:from-primary/15 dark:hover:to-primary/25",children:f.value},`${u}-${h}`))]},u))})]}),n&&c.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[n==="interactionFilters"&&c.jsx("span",{children:"Showing data filtered by interaction only"}),n==="full"&&c.jsx("span",{children:"Showing data with all dashboard filters + interaction filters"}),n==="none"&&c.jsx("span",{children:"Showing all data (no filters applied)"})]})]})}function GPe(e){const{values:t,operation:n}=e;return!t||t.length===0?"":n==="="||n==="!="||n===">"||n==="<"||n===">="||n==="<="?String(t[0]):n==="in"||n==="not in"?t.map(r=>String(r)).join(", "):(n==="between"||n==="not between")&&t.length===2?`${t[0]} - ${t[1]}`:String(t[0])}function ZPe(e){const{operator:t,value:n}=e;if(e.label){const r=e.label.split(/[=><]/);if(r.length>1)return r[1].trim()}switch(t){case"=":return String(n);case"!=":return`≠ ${n}`;case">":return`> ${n}`;case"<":return`< ${n}`;case">=":return`≥ ${n}`;case"<=":return`≤ ${n}`;case"in":return Array.isArray(n)?n.join(", "):String(n);case"not in":return`not ${Array.isArray(n)?n.join(", "):n}`;case"contains":return`contains ${n}`;case"startsWith":return`starts with ${n}`;case"endsWith":return`ends with ${n}`;case"between":return Array.isArray(n)?`between ${n[0]} and ${n[1]}`:String(n);case"not between":return Array.isArray(n)?`not between ${n[0]} and ${n[1]}`:String(n);case"isNull":return"is null";case"isNotNull":return"is not null";default:return String(n)}}function KPe({cardId:e,className:t}){const n=Ut(d=>d.interactionStates[e]),r=Ut(d=>d.popInteractionStep),s=Ut(d=>d.resetInteractionState),o=(n==null?void 0:n.breadcrumbs)??[];if(n==null||n.hierarchyId,o.length===0)return null;const i=d=>{const f=o.length-d-1;for(let h=0;h<f;h++)r(e)},a=()=>{s(e)},l=d=>(d.sourceFilterGroups[0],d.toField?d.toField.label||d.toField.name:"Drill Step"),u=d=>{const f=d.sourceFilterGroups.flatMap(h=>h.filters);return c.jsxs("div",{className:"max-w-xs space-y-2 text-sm",children:[f.length>0&&c.jsx(KY,{filters:f,className:"pb-2",labelText:"Drill Down Filters:",icon:c.jsx(Lne,{className:"h-4 w-4 text-foreground/80"})}),d.granularity&&c.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[c.jsx(ts,{className:"h-4 w-4 text-foreground/80"}),c.jsxs("span",{className:"text-sm font-medium text-foreground/80",children:["Granularity: ",d.granularity]})]}),d.metric&&c.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[c.jsx(Nne,{className:"h-4 w-4 text-foreground/80"}),c.jsxs("span",{className:"text-sm font-medium text-foreground/80",children:["Value:"," ",d.metric.formattedValue||d.metric.value]})]})]})};return c.jsx(fr,{children:c.jsxs("div",{className:K("flex items-center gap-1 text-sm",t),children:[c.jsx(Dn,{children:c.jsx(Tn,{asChild:!0,children:c.jsx("button",{className:"flex items-center p-0 text-muted-foreground hover:text-foreground",onClick:a,"aria-label":"Reset drill path",children:c.jsx(FE,{className:"h-3.5 w-3.5"})})})}),c.jsx(Za,{className:"ml-0.5 h-3 w-3 text-muted-foreground"}),c.jsx("div",{className:"flex items-center",children:o.map((d,f)=>c.jsxs("div",{className:"flex items-center",children:[f>0&&c.jsx(Za,{className:"mx-1 h-3 w-3 text-muted-foreground"}),c.jsxs(Dn,{delayDuration:0,children:[c.jsx(Tn,{asChild:!0,children:c.jsx(se,{variant:"link",size:"sm",className:"h-6 px-1 text-muted-foreground no-underline hover:text-foreground hover:no-underline",onClick:()=>i(f),"aria-label":`Go back to: ${l(d)}`,children:l(d)})}),c.jsx(HT,{className:"ml-4",side:"bottom",children:u(d)})]})]},f))})]})})}function XPe(e){switch(e){case"content-only":return{showHeader:!1,showTitle:!1,showDescription:!1,showTabs:!1,showFooter:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1};case"print":return{showHeader:!0,showTitle:!0,showDescription:!0,showTabs:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1,showTableToolbar:!1,showColumnSettings:!1};case"embed":return{showHeader:!1,showTitle:!0,showDescription:!1,showTabs:!0,showFooter:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1};case"table-print":return{showHeader:!1,showTitle:!0,showDescription:!1,showTabs:!1,showFooter:!1,showFilters:!1,showBreadcrumbs:!1,showRefreshIndicator:!1,showFilterInfo:!1,showPagination:!1,showTableToolbar:!1,showColumnSettings:!1};case"full":default:return{showHeader:!0,showTitle:!0,showDescription:!0,showTabs:!0,showFooter:!0,showFilters:!0,showBreadcrumbs:!0,showRefreshIndicator:!0,showFilterInfo:!0}}}function rR({children:e,displayPreferences:t={mode:"full"},currentUser:n}){const r=C.useMemo(()=>{const s=t.mode||"full",o=XPe(s),i=lU(n||null),a={mode:s,overrides:{...o,...i,...t.overrides}};return{displayPreferences:a,shouldShowElement:u=>{var d;return((d=a.overrides)==null?void 0:d[u])??!0}}},[t,n]);return c.jsx($9.Provider,{value:r,children:e})}function CF({card:e,frame:t}){var ue,ae,Se,ye,Fe,Ye,me,Me,Ne;const{customCards:n,placeholders:r,tokenProps:s}=Xe(),{shouldShowElement:o}=hc(),i=Ut(ge=>ge.interactionStates[e.id]),a=((ue=i==null?void 0:i.breadcrumbs)==null?void 0:ue.length)>0,l=ee(ge=>ge.themeStyle),u=ee(ge=>ge.selectedSheetId),d=ee(ge=>ge.isDashboardEditing);ee(ge=>ge.selectedLensId);const f=ee(ge=>ge.dashboard.filters),h=f==null?void 0:f.find(ge=>ge.id===t.filterId&&!ge.hide),{setCardTitle:p,setCardDescription:m,setSelectedFrameId:g,updateFilter:b}=Jt(),{updateFrame:x}=Jt(),{handleChartClick:y}=UPe(e),v=o("showHeader")&&(((ae=e.customCardPreferences)==null?void 0:ae.showCardHeader)??!0),{isError:w,isLoading:S,isFetching:N,cfg:j,isPending:_,data:k,handleDatapointClick:D,pagination:T,comparisonMetadata:R}=Sb(e),[O,M]=C.useState({open:!1,position:null,interactions:[],context:null}),{breadcrumbs:P,hierarchyId:F}=Ut(ge=>{var _e,re;return{breadcrumbs:((_e=ge.interactionStates[e.id])==null?void 0:_e.breadcrumbs)??[],hierarchyId:(re=ge.interactionStates[e.id])==null?void 0:re.hierarchyId}}),V=(ge,_e,re)=>{var Qe;const ce=P.length>0?[{mode:"drillUp",trigger:(Qe=ge[0])==null?void 0:Qe.trigger,label:"Drill Up",hierarchyId:F}]:[],xe=[];for(const ct of ge)if(ct.mode==="dynamicDrill"&&ct.availableFields){const ft=ct.availableFields.filter(At=>!P.some(Ce=>{var yt;return((yt=Ce.toField)==null?void 0:yt.id)===At.id}));for(const At of ft)xe.push({mode:"dynamicDrill",trigger:ct.trigger,drillField:At,label:At.label,availableFields:ct.availableFields})}const Ie=ge.filter(ct=>ct.mode!=="dynamicDrill"),Oe=[...ce,...Ie,...xe];M({open:!0,position:re||{x:0,y:0},interactions:Oe,context:_e})},{handlePointerInteraction:H,applySelectedInteraction:L}=m$(e,t.id,u||"",V),I=vE(e),B=C.useMemo(()=>{var ge;return e.type!=="pivotTable"||!((ge=k==null?void 0:k.records)!=null&&ge.length)?null:{records:k.records,columnSubtotalMeta:k.columnSubtotalMeta,subtotalColumns:k.subtotalColumns||[],pivotSchema:k.pivotSchema||[],groupByColumns:k.groupByColumns}},[e.type,k==null?void 0:k.records,k==null?void 0:k.columnSubtotalMeta,k==null?void 0:k.subtotalColumns,k==null?void 0:k.pivotSchema,k==null?void 0:k.groupByColumns]),z=Zh(e,B),A=(ge,_e)=>{const re={...e,paginationConfig:{page:ge+1,pageSize:_e}},ce={...t,cards:t.cards.map(xe=>xe.id===e.id?re:xe)};u&&x(u,ce)},W=ge=>{var xe,Ie;const _e=pW(ge,(xe=e.config)==null?void 0:xe.metricColumns,(Ie=e.config)==null?void 0:Ie.groupByColumns),re={...e,config:{...e.config||{},sortByColumns:_e}},ce={...t,cards:t.cards.map(Oe=>Oe.id===e.id?re:Oe)};u&&x(u,ce)};function q(ge,_e){ge.stopPropagation();const re=WPe({resolvedCardConfig:I,card:e,records:(k==null?void 0:k.records)||[],chart:_e,clickEvent:ge.nativeEvent});if(!re)return;const ce=ni(e.interactionConfig),xe=aw(ce,re),Ie=xe.length===1&&xe[0].mode==="clickFilter",Oe=xe.some(ft=>ft.mode==="dynamicDrill"),Qe=xe.length>1||Oe;ge.button===0&&Ie&&!Qe&&y(ge.nativeEvent,_e);const ct={shift:ge.shiftKey,ctrl:ge.ctrlKey,meta:ge.metaKey};ge.button===0?H({context:re,gesture:"leftClick",modifierKeys:ct,position:{x:ge.clientX,y:ge.clientY}}):ge.button===2&&H({context:re,gesture:"rightClick",modifierKeys:ct,position:{x:ge.clientX,y:ge.clientY}})}function Y(){var ge,_e,re;if(n&&n.length>0){const ce=n.find(xe=>xe.cardId===e.id);if(ce&&ce.replaceDefault){const xe=ce.content;if(xe)return c.jsx(xe,{card:e})}}if(e.type==="kpi"){if(((ge=t==null?void 0:t.cards)==null?void 0:ge.length)===1)return c.jsx(Sg,{card:e,data:w?[]:(k==null?void 0:k.records)||[],isPending:_,isError:w});if(((_e=t==null?void 0:t.cards)==null?void 0:_e.length)>1)return c.jsx(LPe,{frame:t})}return e.type==="text"&&((re=t==null?void 0:t.cards)==null?void 0:re.length)===1?c.jsx(qs,{className:"my-4 overflow-y-auto break-words px-4",children:c.jsx(gh,{isLoading:S||N,card:e,data:(k==null?void 0:k.records)||[]})}):ne}function U(){if(w)return c.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[c.jsx(UE,{className:"size-8 text-destructive"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Error fetching data. Check your card settings."})]});if((S||N)&&e.type!=="table")return c.jsx("div",{className:"flex h-full w-full items-center justify-center",children:c.jsx(td,{size:"md",color:"muted","aria-label":"Loading data"})});if(k!=null&&k.records&&(k==null?void 0:k.records.length)===0)return r!=null&&r.NoRecords?c.jsx("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:r.NoRecords}):c.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[c.jsx(qE,{className:"size-8 text-muted-foreground"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"No results to display"})]});if(e.type==="table")return c.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:c.jsx(Rb,{card:e,data:(k==null?void 0:k.records)||[],paginationMetadata:T,onPaginationChange:A,onSortChange:W,isLoading:S||N,frameId:t.id,sheetId:u||"",onMultipleInteractions:V})});if(e.type==="pivotTable"&&z)return c.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:c.jsx(Ib,{card:e,data:z.data,options:z.options,onAggregationChange:ge=>{const _e=Ck(ge,e.config),re={...e,config:_e},ce={...t,cards:t.cards.map(xe=>xe.id===e.id?re:xe)};u&&x(u,ce)},onAggregationLabelChange:ge=>{const _e=uY(ge,e.config),re={...e,config:_e},ce={...t,cards:t.cards.map(xe=>xe.id===e.id?re:xe)};u&&x(u,ce)}})});if(e.type==="aggregateTable")return c.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:c.jsx(j1,{card:e,data:(k==null?void 0:k.records)||[],groupByColumns:k==null?void 0:k.groupByColumns,pivotSchema:k==null?void 0:k.pivotSchema,paginationMetadata:T,onPaginationChange:A,onAggregationChange:ge=>{const _e=Ck(ge,e.config),re={...e,config:_e},ce={...t,cards:t.cards.map(xe=>xe.id===e.id?re:xe)};u&&x(u,ce)},isLoading:S||N})});if(e.type==="text")return c.jsx(qs,{className:"overflow-y-auto break-words pr-2",children:c.jsx(gh,{isLoading:S||N,card:e,data:(k==null?void 0:k.records)||[]})});if(e.type==="custom")return c.jsx(Nc,{FallbackComponent:_1,children:c.jsx(PT,{frame:t,card:e})});if(n&&n.length>0){const ge=n.find(_e=>_e.cardId===e.id);if(ge&&ge.content){const _e=ge.content;return c.jsx(_e,{card:e})}}if(j)return c.jsx(Mb,{cfg:j,onChartClick:q,onDatapointClick:D})}function $(){if(n&&n.length>0){const ge=n.find(_e=>_e.cardId===e.id);if(ge&&ge.footer){const _e=ge.footer;if(_e)return c.jsx(_e,{card:e})}}return null}function G(){var re;const ge=t.cards.filter(ce=>{var xe;return!((xe=ce.tabTitle)!=null&&xe.endsWith("__Header"))&&(ce.displayTab===!0||ce.displayTab===void 0)}),_e=l==null?void 0:l.controlInputRadius;return c.jsx(js,{value:t.activeCardId,className:"flex items-center justify-end gap-3",onValueChange:ce=>{const xe={...t,activeCardId:ce};x(u,xe)},children:c.jsx(os,{style:{borderRadius:l==null?void 0:l.controlInputRadius},className:"flex-end flex h-9 flex-wrap items-center border border-border bg-background p-0",children:(re=t.cards.filter(ce=>{var xe;return!((xe=ce.tabTitle)!=null&&xe.endsWith("__Header"))&&(ce.displayTab===!0||ce.displayTab===void 0)}))==null?void 0:re.map((ce,xe)=>c.jsx(Qt,{className:K("h-full items-center rounded-none data-[state=active]:bg-muted data-[state=active]:shadow-none",{"border-r":xe!==ge.length-1}),style:{borderTopLeftRadius:xe===0?_e:0,borderTopRightRadius:xe===ge.length-1?_e:0,borderBottomLeftRadius:xe===0?_e:0,borderBottomRightRadius:xe===ge.length-1?_e:0},value:ce.id,children:ce.tabTitle||ce.title},ce.id))})})}function Z(){var _e,re,ce,xe;let ge=t.cards.find(Ie=>Ie.type==="kpi"&&Ie.tabTitle===`${e.tabTitle}__Header`);return ge||(ge=t.cards.find(Ie=>Ie.type==="kpi"&&Ie.tabTitle==="All__Header")),ge?c.jsx("div",{className:"flex items-end gap-2",children:c.jsx(yMe,{renderFilterInfo:()=>{var Ie,Oe,Qe,ct;return o("showFilterInfo")&&((Oe=(Ie=e.preferences)==null?void 0:Ie.displayOptions)==null?void 0:Oe.showFilterInfo)!==!1?c.jsx(Sk,{cardId:e.id,cardFilters:(Qe=e.config)==null?void 0:Qe.filters,cardFilterCount:Ev(((ct=e.config)==null?void 0:ct.filters)||null)}):null},card:ge})}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{role:"card-title-container",className:"flex h-7 items-center gap-2",children:[o("showTitle")&&c.jsx(hi,{className:K("text-base",{}),children:c.jsx($o,{value:e.title,onSave:Ie=>p(u,e.id,Ie),isEditable:d,placeholder:"Add title",displayClassName:"text-base font-semibold",inputClassName:"text-base font-semibold"})}),o("showTitle")&&(d||e.info)&&c.jsx(lY,{card:e}),o("showRefreshIndicator")&&e.refreshInterval&&c.jsxs(Dn,{children:[c.jsx(Tn,{className:"pr-1",children:c.jsx("div",{className:K("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":S||N})})}),c.jsx($n,{side:"right",align:"center",children:c.jsx("p",{className:"text-xs",children:`Realtime (${e==null?void 0:e.refreshInterval})`})})]}),o("showFilterInfo")&&((re=(_e=e.preferences)==null?void 0:_e.displayOptions)==null?void 0:re.showFilterInfo)!==!1&&c.jsx(Sk,{cardId:e.id,cardFilters:(ce=e.config)==null?void 0:ce.filters,cardFilterCount:Ev(((xe=e.config)==null?void 0:xe.filters)||null)}),R&&c.jsx(cY,{metadata:R,variant:"compact"})]}),c.jsxs("div",{"data-content":"card-description-and-breadcrumb",className:"flex h-6 items-center overflow-y-auto",children:[!a&&o("showDescription")&&c.jsx("div",{className:K("text-sm text-muted-foreground",{}),children:c.jsx($o,{value:(e==null?void 0:e.description)||"",onSave:Ie=>m(u,e.id,Ie),isEditable:d,placeholder:"Add description",displayClassName:"text-sm text-muted-foreground",inputClassName:"text-sm"})}),a&&o("showBreadcrumbs")&&c.jsx(KPe,{cardId:e.id})]})]})}if(!e.id)return null;const te=((ye=(Se=e.preferences)==null?void 0:Se.displayOptions)==null?void 0:ye.showChrome)??!0,Q=((Ye=(Fe=e.preferences)==null?void 0:Fe.displayOptions)==null?void 0:Ye.allowScroll)??!0,ne=te?c.jsxs(c.Fragment,{children:[v?c.jsx(fi,{children:c.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[c.jsx("div",{className:"flex-1 basis-0 scroll-pb-2 overflow-x-auto",role:"header-container",children:Z()}),c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c.jsx("div",{children:h&&o("showFilters")&&c.jsxs("div",{style:{borderRadius:(Me=(me=l==null?void 0:l.chart)==null?void 0:me.options)==null?void 0:Me.borderRadius},"data-content":"frame-filter-container",className:"flex shrink-0 items-center",children:[!dd(h.dataType)&&c.jsx(le,{className:"my-1 shrink-0 px-3",children:c.jsx($o,{value:h.title||h.column,onSave:ge=>b({...h,title:ge}),isEditable:d,placeholder:"Filter",displayClassName:"text-sm",inputClassName:"text-sm"})}),c.jsx(nR,{filter:h})]})}),t.cards.length>1&&o("showTabs")&&G()]})]})}):c.jsx("div",{className:"h-8"}),c.jsx(Qi,{"data-role":"card-content",className:"relative flex min-h-0 grow flex-col",children:U()}),o("showFooter")&&c.jsx(sL,{children:$()})]}):U(),ie=()=>te&&Q?"flex h-full flex-col":te&&!Q?"flex h-full flex-col overflow-hidden":!te&&!Q?"h-full":"h-full overflow-auto";return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:K(ie(),{"animate-pulse":S||N}),children:Y()}),O.context&&c.jsx(HPe,{open:O.open,onOpenChange:ge=>{M(_e=>({..._e,open:ge}))},position:O.position,interactions:O.interactions,selectedConditions:O.context.conditions,drillHierarchies:(Ne=e.interactionConfig)==null?void 0:Ne.drillHierarchies,cardId:e.id,card:e,onSelectInteraction:ge=>{O.context&&L(ge,O.context),M({open:!1,position:null,interactions:[],context:null})}})]})}function XY({card:e,frame:t}){return e.displayPreferences?c.jsx(rR,{displayPreferences:e.displayPreferences,children:c.jsx(CF,{card:e,frame:t})}):c.jsx(CF,{card:e,frame:t})}function QPe({card:e,frame:t,showTitle:n=!0}){const{isError:r,isLoading:s,isFetching:o,cfg:i,data:a,pagination:l}=Sb(e),u=C.useMemo(()=>{var h;return e.type!=="pivotTable"||!((h=a==null?void 0:a.records)!=null&&h.length)?null:{records:a.records,columnSubtotalMeta:a.columnSubtotalMeta,subtotalColumns:a.subtotalColumns||[],pivotSchema:a.pivotSchema||[],groupByColumns:a.groupByColumns}},[e.type,a==null?void 0:a.records,a==null?void 0:a.columnSubtotalMeta,a==null?void 0:a.subtotalColumns,a==null?void 0:a.pivotSchema,a==null?void 0:a.groupByColumns]),d=Zh(e,u);if(s||o)return c.jsxs("div",{className:"flex h-full grow flex-col items-center justify-center gap-4 p-12",children:[c.jsx(In,{className:"h-8 w-8 animate-spin text-muted-foreground"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading visual..."})]});if(r)return c.jsx("div",{className:"flex flex-col items-center justify-center gap-2 p-12",children:c.jsx("p",{className:"text-sm font-medium text-destructive",children:"Failed to load visual"})});function f(){return e.type==="kpi"?c.jsx(Sg,{card:e,data:(a==null?void 0:a.records)||[],isPending:s||o}):e.type==="table"?c.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:c.jsx(Rb,{card:e,data:(a==null?void 0:a.records)||[],isLoading:s||o,paginationMetadata:l})}):e.type==="pivotTable"&&d?c.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:c.jsx(Ib,{card:e,data:(a==null?void 0:a.records)||[],onAggregationChange:()=>{},onAggregationLabelChange:()=>{}})}):e.type==="aggregateTable"?c.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 grow basis-0",children:c.jsx(j1,{card:e,data:(a==null?void 0:a.records)||[],groupByColumns:a==null?void 0:a.groupByColumns,pivotSchema:a==null?void 0:a.pivotSchema,paginationMetadata:l,onAggregationChange:()=>{},isLoading:s||o})}):e.type==="text"?c.jsx(qs,{className:"overflow-y-auto break-words pr-2",children:c.jsx(gh,{isLoading:s||o,card:e,data:(a==null?void 0:a.records)||[]})}):e.type==="custom"?c.jsx(Nc,{FallbackComponent:_1,children:c.jsx(PT,{frame:t,card:e})}):i?c.jsx(Mb,{cfg:i,onChartClick:()=>{},onDatapointClick:()=>{}}):null}return c.jsxs("div",{className:"flex h-full w-full flex-col",children:[n&&e.title&&c.jsxs("div",{className:"border-b px-4 py-2",children:[c.jsx("h3",{className:"text-lg font-medium",children:e.title}),e.description&&c.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:e.description})]}),c.jsx("div",{className:"min-h-0 flex-1 p-4",children:f()})]})}function QY({insightId:e,filters:t,contextMode:n}){const{data:r,isLoading:s,isError:o,error:i}=b_(e,{enabled:!!e}),a=Ut(f=>f.setInteractionState),l=Ut(f=>f.resetInteractionState),u=C.useMemo(()=>{var h;if(!r)return null;const f=(r==null?void 0:r.frameObject)??((h=r==null?void 0:r.visual)==null?void 0:h.frameObject);if(!f)return null;if(typeof f=="string")try{return JSON.parse(f)}catch{return null}return f},[r]),d=C.useMemo(()=>{var f;return(f=u==null?void 0:u.cards)!=null&&f.length?u.activeCardId&&u.cards.find(h=>h.id===u.activeCardId)||u.cards[0]:null},[u]);return C.useEffect(()=>{if(!d)return;if(n==="none"||!(t!=null&&t.length)){const m={...To(),contextMode:n};a(d.id,m);return}const h={sourceCardId:"drill-to-insight",interactionMode:"clickFilter",filterGroups:[{filters:t}],applyToCardIds:[d.id]},p={...To(),appliedClickFilters:[h],contextMode:n};return a(d.id,p),()=>{l(d.id)}},[d,t,n,a,l]),s?c.jsxs("div",{className:"flex h-full grow flex-col items-center justify-center gap-4 p-12",children:[c.jsx(In,{className:"h-8 w-8 animate-spin text-muted-foreground"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading visual..."})]}):o?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-12",children:[c.jsx("p",{className:"text-sm font-medium text-destructive",children:"Failed to load insight"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:i instanceof Error?i.message:"Unknown error"})]}):!u||!d?c.jsx("div",{className:"flex items-center justify-center p-12",children:c.jsx("p",{className:"text-sm text-muted-foreground",children:"This insight has no visual data to display"})}):c.jsx("div",{className:"h-full w-full",children:c.jsx(QPe,{card:d,frame:u,showTitle:!1})})}function JPe({filters:e,contextMode:t}){if(!e||e.length===0)return t==="none"?c.jsxs(Pe,{variant:"outline",className:"gap-1 whitespace-nowrap",children:[c.jsx(Bl,{className:"h-3 w-3"}),"No filters"]}):null;const n=e.reduce((s,o)=>{var a,l;const i=((a=o.field)==null?void 0:a.label)||((l=o.field)==null?void 0:l.name)||"Unknown";return s[i]||(s[i]=[]),s[i].push(o),s},{});e.length;const r=Object.keys(n).length;return c.jsx(fr,{children:c.jsxs(Dn,{delayDuration:200,children:[c.jsx(Tn,{asChild:!0,children:c.jsxs(Pe,{variant:"secondary",className:"cursor-help gap-1 whitespace-nowrap border border-blue-500/20 bg-blue-500/10 text-blue-700 dark:text-blue-300",children:[c.jsx(Bl,{className:"h-3 w-3"}),r," ",r===1?"filter":"filters"]})}),c.jsx($n,{side:"bottom",align:"start",className:"max-w-md",children:c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:"text-sm font-medium",children:"Applied Filters"}),c.jsx("div",{className:"space-y-1.5",children:Object.entries(n).map(([s,o])=>c.jsxs("div",{className:"text-xs",children:[c.jsxs("span",{className:"font-medium",children:[s,":"]})," ",o.map((i,a)=>c.jsxs("span",{children:[eOe(i),a<o.length-1?", ":""]},a))]},s))}),t&&c.jsx("div",{className:"border-t pt-2 text-xs text-muted-foreground",children:tOe(t)})]})})]})})}function eOe(e){const{operator:t,value:n}=e;if(e.label){const r=e.label.split(/[=><]/);if(r.length>1)return r[1].trim()}switch(t){case"=":return String(n);case"!=":return`≠ ${n}`;case">":return`> ${n}`;case"<":return`< ${n}`;case">=":return`≥ ${n}`;case"<=":return`≤ ${n}`;case"in":return Array.isArray(n)?n.join(", "):String(n);case"not in":return`not ${Array.isArray(n)?n.join(", "):n}`;case"contains":return`contains ${n}`;case"startsWith":return`starts with ${n}`;case"endsWith":return`ends with ${n}`;case"between":return Array.isArray(n)?`${n[0]}-${n[1]}`:String(n);case"not between":return Array.isArray(n)?`not ${n[0]}-${n[1]}`:String(n);case"isNull":return"is null";case"isNotNull":return"is not null";default:return String(n)}}function tOe(e){switch(e){case"filters":case"interactionFilters":return"Showing data filtered by interaction only";case"full":return"Showing data with all dashboard filters + interaction filters";case"none":return"Showing all data (no filters applied)"}}function JY(e,t={}){const{enabled:n=!0}=t,{data:r}=b_(e,{enabled:n&&!!e});return C.useMemo(()=>{var l,u;if(!r)return{title:"",description:void 0};const o=(r==null?void 0:r.frameObject)??((l=r==null?void 0:r.visual)==null?void 0:l.frameObject);if(!o)return{title:"",description:void 0};let i=null;if(typeof o=="string")try{i=JSON.parse(o)}catch{return{title:"",description:void 0}}else i=o;if(!((u=i==null?void 0:i.cards)!=null&&u.length))return{title:"",description:void 0};const a=i.activeCardId&&i.cards.find(d=>d.id===i.activeCardId)||i.cards[0];return{title:a.title,description:a.description}},[r])}function nOe({cardId:e,children:t}){const n=Ut(o=>o.replacedCards[e]),r=Ut(o=>o.restoreCard),s=JY((n==null?void 0:n.insightId)||"",{enabled:!!(n!=null&&n.insightId)});return n?c.jsxs("div",{className:"flex h-full w-full flex-col",children:[c.jsxs("div",{className:"border-b bg-muted/30",children:[c.jsx("div",{className:"flex items-baseline gap-2 px-5 pb-2 pt-4",children:s.title&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"truncate text-sm font-semibold",children:s.title}),s.description&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-muted-foreground",children:"-"}),c.jsx("span",{className:"truncate text-xs text-muted-foreground",children:s.description})]})]})}),c.jsxs("div",{className:"flex items-center gap-3 px-4 pb-2",children:[c.jsxs(se,{variant:"ghost",size:"sm",onClick:()=>r(e),className:"flex-shrink-0 gap-1",children:[c.jsx(iL,{className:"h-4 w-4"}),"Back"]}),c.jsx(JPe,{filters:n.filters,contextMode:n.contextMode})]})]}),c.jsx("div",{className:"min-h-0 flex-1",children:c.jsx(QY,{insightId:n.insightId,filters:n.filters,contextMode:n.contextMode})})]}):c.jsx(c.Fragment,{children:t})}function rOe({frame:e,footer:t,className:n,...r}){var w,S;const s=C.useRef(null),[o,i]=C.useState(!1),a=ee(N=>N.themeStyle),l=ee(N=>N.isVisualEditing),u=ee(N=>N.selectedFrameId),d=ee(N=>N.isDashboardEditing),{setSelectedFrameId:f}=Jt(),{clearSelectedVisual:h}=Qg(),{setSelectedConnectionId:p,setSelectedDatabaseName:m,setSelectedSchemaName:g,setSelectedTableName:b,setCard:x}=is();C.useEffect(()=>{if(u===e.id&&d&&!l){const N=s==null?void 0:s.current;N==null||N.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[u,e.id,d,l,s]);const y=e.cards.find(N=>N.id===e.activeCardId);function v(N){N.stopPropagation(),f(e.id),h(),y&&x(y),y!=null&&y.connectionId&&p(y==null?void 0:y.connectionId),y!=null&&y.lastSelectedDatabase&&m(y==null?void 0:y.lastSelectedDatabase),y!=null&&y.lastSelectedSchema&&g(y==null?void 0:y.lastSelectedSchema),y!=null&&y.lastSelectedTable&&b(y==null?void 0:y.lastSelectedTable)}return c.jsx(Nc,{FallbackComponent:OT,children:c.jsxs("div",{tabIndex:-1,ref:s,role:"card-frame","data-frame-id":e.id,"data-active-card-id":y==null?void 0:y.id,onClick:v,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{borderRadius:a==null?void 0:a.cardBorderRadius},className:K("relative flex h-full flex-col rounded-sm border bg-background shadow-sm",{"border-dashed border-foreground/50":u===e.id&&d},a==null?void 0:a.dashboardCard,n,"semaphor-card-frame"),...r,children:[(d||((S=(w=y==null?void 0:y.preferences)==null?void 0:w.displayOptions)==null?void 0:S.showCardToolbar)!==!1)&&c.jsx(Kq,{frame:e,isHovered:o}),y&&c.jsx(nOe,{cardId:y.id,children:c.jsx(XY,{card:y,frame:e},y.id)})]})})}function sOe({label:e,onCheckedChange:t,checked:n}){return c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx(on,{onCheckedChange:t,id:"terms",checked:n}),c.jsx("label",{htmlFor:"terms",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:e})]})}function sR(e,t){if(e==null)return{};var n={},r=Object.keys(e),s,o;for(o=0;o<r.length;o++)s=r[o],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}var oOe=["color"],iOe=C.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,s=sR(e,oOe);return C.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s,{ref:t}),C.createElement("path",{d:"M4.93179 5.43179C4.75605 5.60753 4.75605 5.89245 4.93179 6.06819C5.10753 6.24392 5.39245 6.24392 5.56819 6.06819L7.49999 4.13638L9.43179 6.06819C9.60753 6.24392 9.89245 6.24392 10.0682 6.06819C10.2439 5.89245 10.2439 5.60753 10.0682 5.43179L7.81819 3.18179C7.73379 3.0974 7.61933 3.04999 7.49999 3.04999C7.38064 3.04999 7.26618 3.0974 7.18179 3.18179L4.93179 5.43179ZM10.0682 9.56819C10.2439 9.39245 10.2439 9.10753 10.0682 8.93179C9.89245 8.75606 9.60753 8.75606 9.43179 8.93179L7.49999 10.8636L5.56819 8.93179C5.39245 8.75606 5.10753 8.75606 4.93179 8.93179C4.75605 9.10753 4.75605 9.39245 4.93179 9.56819L7.18179 11.8182C7.35753 11.9939 7.64245 11.9939 7.81819 11.8182L10.0682 9.56819Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),aOe=["color"],eG=C.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,s=sR(e,aOe);return C.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s,{ref:t}),C.createElement("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),lOe=["color"],cOe=C.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,s=sR(e,lOe);return C.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s,{ref:t}),C.createElement("path",{d:"M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))});function wh({text:e,className:t}){const[n,r]=C.useState(!1);return c.jsx(se,{className:K("h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",t),variant:"ghost",size:"icon",onClick:()=>{navigator.clipboard.writeText(e),r(!0),setTimeout(()=>{r(!1)},1e3)},children:n?c.jsx(eG,{className:"size-3.5"}):c.jsx(hw,{className:"size-3.5"})})}function uOe({filter:e,onUpdate:t}){const[n,r]=C.useState(""),s=ee(y=>y.dashboard.sheets)||[],o=ee(y=>y.selectedSheetId),i=C.useMemo(()=>{const y=[];return s==null||s.forEach(v=>{var w;(w=v.frames)==null||w.forEach(S=>{var N;(N=S.cards)==null||N.forEach(j=>{y.push({...j,sheetId:v.id,sheetTitle:v.title||v.id})})})}),y},[s]),a=()=>e.applyToSheetIds!==void 0?"specific-sheets":e.excludeSheetIds!==void 0?"all-except-specific":"all-sheets",l=()=>e.applyToCardIds!==void 0?"specific-cards":e.excludeCardIds!==void 0?"all-except-specific":"all-cards",u=y=>{const v={};switch(y){case"all-sheets":v.applyToSheetIds=void 0,v.excludeSheetIds=void 0;break;case"specific-sheets":v.applyToSheetIds=[],v.excludeSheetIds=void 0;break;case"all-except-specific":v.applyToSheetIds=void 0,v.excludeSheetIds=[];break}t(v)},d=y=>{const v={};switch(y){case"all-cards":v.applyToCardIds=void 0,v.excludeCardIds=void 0;break;case"specific-cards":v.applyToCardIds=[],v.excludeCardIds=void 0;break;case"all-except-specific":v.applyToCardIds=void 0,v.excludeCardIds=[];break}t(v)},f=(y,v)=>{if(v==="specific-sheets"){const w=e.applyToSheetIds||[],S=w.includes(y)?w.filter(N=>N!==y):[...w,y];t({applyToSheetIds:S})}else if(v==="all-except-specific"){const w=e.excludeSheetIds||[],S=w.includes(y)?w.filter(N=>N!==y):[...w,y];t({excludeSheetIds:S})}},h=(y,v)=>{if(v==="specific-cards"){const w=e.applyToCardIds||[],S=w.includes(y)?w.filter(N=>N!==y):[...w,y];t({applyToCardIds:S})}else if(v==="all-except-specific"){const w=e.excludeCardIds||[],S=w.includes(y)?w.filter(N=>N!==y):[...w,y];t({excludeCardIds:S})}},p=()=>{const y=a();return y==="specific-sheets"?e.applyToSheetIds||[]:y==="all-except-specific"?(s==null?void 0:s.filter(v=>{var w;return!((w=e.excludeSheetIds)!=null&&w.includes(v.id))}).map(v=>v.id))||[]:(s==null?void 0:s.map(v=>v.id))||[]},m=C.useMemo(()=>{const y=p();return i.filter(v=>y.includes(v.sheetId))},[i,e.applyToSheetIds,e.excludeSheetIds]),g=C.useMemo(()=>{if(!n.trim())return m;const y=n.toLowerCase();return m.filter(v=>{var w;return(w=v==null?void 0:v.title)==null?void 0:w.toLowerCase().includes(y)})},[n,m]),b=a(),x=l();return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"space-y-0.5",children:[c.jsx(le,{className:"text-sm font-medium",children:"Sheet Scope"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Which sheets should display this filter?"})]}),c.jsxs(ra,{value:b,onValueChange:y=>u(y),className:"space-y-3",children:[c.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[c.jsx(vr,{value:"all-sheets",id:"all-sheets",className:"mt-0.5"}),c.jsxs("div",{className:"flex-1 space-y-1",children:[c.jsx(le,{htmlFor:"all-sheets",className:"cursor-pointer text-sm font-medium",children:"All sheets"}),c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Display filter on all sheets (",(s==null?void 0:s.length)||0," sheets)"]})]})]}),c.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[c.jsx(vr,{value:"specific-sheets",id:"specific-sheets",className:"mt-0.5"}),c.jsxs("div",{className:"flex-1 space-y-1",children:[c.jsx(le,{htmlFor:"specific-sheets",className:"cursor-pointer text-sm font-medium",children:"Only specific sheets"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Display filter on selected sheets only"})]})]}),b==="specific-sheets"&&c.jsx("div",{className:"ml-7 space-y-2",children:c.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==null?void 0:s.map(y=>{const v=(e.applyToSheetIds||[]).includes(y.id);return c.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[c.jsx(on,{id:`sheet-${y.id}`,checked:v,onCheckedChange:()=>f(y.id,"specific-sheets")}),c.jsxs(le,{htmlFor:`sheet-${y.id}`,className:"cursor-pointer text-sm font-medium",children:[y.title||y.id,y.id===o&&c.jsx("span",{className:"ml-1.5 text-xs text-muted-foreground",children:"(this sheet)"})]})]},y.id)})})}),c.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[c.jsx(vr,{value:"all-except-specific",id:"all-sheets-except",className:"mt-0.5"}),c.jsxs("div",{className:"flex-1 space-y-1",children:[c.jsx(le,{htmlFor:"all-sheets-except",className:"cursor-pointer text-sm font-medium",children:"All sheets except specific ones"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Display filter on all sheets except selected ones"})]})]}),b==="all-except-specific"&&c.jsx("div",{className:"ml-7 space-y-2",children:c.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==null?void 0:s.map(y=>{const v=(e.excludeSheetIds||[]).includes(y.id);return c.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[c.jsx(on,{id:`sheet-exclude-${y.id}`,checked:v,onCheckedChange:()=>f(y.id,"all-except-specific")}),c.jsxs(le,{htmlFor:`sheet-exclude-${y.id}`,className:"cursor-pointer text-sm font-medium",children:[y.title||y.id,y.id===o&&c.jsx("span",{className:"ml-1.5 text-xs text-muted-foreground",children:"(this sheet)"})]})]},y.id)})})})]})]}),c.jsxs("div",{className:"space-y-3 border-t pt-4",children:[c.jsxs("div",{className:"space-y-0.5",children:[c.jsx(le,{className:"text-sm font-medium",children:"Card Scope"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Which cards should receive this filter?"})]}),c.jsxs(ra,{value:x,onValueChange:y=>d(y),className:"space-y-3",children:[c.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[c.jsx(vr,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),c.jsxs("div",{className:"flex-1 space-y-1",children:[c.jsx(le,{htmlFor:"all-cards",className:"cursor-pointer text-sm font-medium",children:"All cards"}),c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Apply filter to all cards in applicable sheets (",m.length," cards)"]})]})]}),c.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[c.jsx(vr,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),c.jsxs("div",{className:"flex-1 space-y-1",children:[c.jsx(le,{htmlFor:"specific-cards",className:"cursor-pointer text-sm font-medium",children:"Only specific cards"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to selected cards only"})]})]}),x==="specific-cards"&&c.jsxs("div",{className:"ml-7 space-y-2",children:[c.jsx(xn,{placeholder:"Search cards...",value:n,onChange:y=>r(y.target.value),className:"mb-2"}),c.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:g.length>0?g.map(y=>{const v=(e.applyToCardIds||[]).includes(y.id);return c.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[c.jsx(on,{id:`card-${y.id}`,checked:v,onCheckedChange:()=>h(y.id,"specific-cards")}),c.jsxs("div",{className:"flex-1",children:[c.jsx(le,{htmlFor:`card-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title}),c.jsx("p",{className:"text-xs text-muted-foreground",children:y.sheetTitle})]})]},y.id)}):c.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',n,'"']})})]}),c.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[c.jsx(vr,{value:"all-except-specific",id:"all-cards-except",className:"mt-0.5"}),c.jsxs("div",{className:"flex-1 space-y-1",children:[c.jsx(le,{htmlFor:"all-cards-except",className:"cursor-pointer text-sm font-medium",children:"All cards except specific ones"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards except selected ones"})]})]}),x==="all-except-specific"&&c.jsxs("div",{className:"ml-7 space-y-2",children:[c.jsx(xn,{placeholder:"Search cards...",value:n,onChange:y=>r(y.target.value),className:"mb-2"}),c.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:g.length>0?g.map(y=>{const v=(e.excludeCardIds||[]).includes(y.id);return c.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[c.jsx(on,{id:`card-exclude-${y.id}`,checked:v,onCheckedChange:()=>h(y.id,"all-except-specific")}),c.jsxs("div",{className:"flex-1",children:[c.jsx(le,{htmlFor:`card-exclude-${y.id}`,className:"cursor-pointer text-sm font-medium",children:y.title}),c.jsx("p",{className:"text-xs text-muted-foreground",children:y.sheetTitle})]})]},y.id)}):c.jsxs("p",{className:"py-4 text-center text-sm text-muted-foreground",children:['No cards found matching "',n,'"']})})]})]})]}),c.jsx("div",{className:"rounded-md bg-blue-50 p-3 text-xs text-blue-900 dark:bg-blue-950 dark:text-blue-100",children:"ℹ️ Cards are filtered based on sheet scope selection. Only cards from applicable sheets are shown in card scope."})]})}function dOe({filter:e}){var N;const[t,n]=C.useState(e.sql),[r,s]=C.useState(!1),[o,i]=C.useState({}),[a,l]=C.useState(e.title||""),[u,d]=C.useState(e.column),[f,h]=C.useState(e.searchMode||"auto"),[p,m]=C.useState(((N=e.defaultValues)==null?void 0:N.map(j=>String(j)))||[]),g=ee(j=>j.selectedSheetId),{updateFilter:b}=Jt(),{data:x}=WT(e);function y(){const j=a.trim(),_=u.trim(),k={sql:t,...o},D=_||e.column;_&&_!==e.column&&(k.column=D),k.title=j||D,Vi(e.dataType)&&(k.searchMode=f),k.defaultValues=p.length>0?p.map(R=>{const O=Number(R);return!isNaN(O)&&Vi(e.dataType)?O:R}):void 0;const T={...e,...k};b(T),i({}),s(!1)}C.useEffect(()=>{var j;r&&(i({}),n(e.sql),l(e.title===e.column?"":e.title||""),d(e.column),h(e.searchMode||"auto"),m(((j=e.defaultValues)==null?void 0:j.map(_=>String(_)))||[]))},[r,e.sql,e.title,e.column,e.searchMode,e.defaultValues]);function v(j){const _={...e,type:j};b(_)}function w(j){const _={...e,uiType:j};b(_)}function S(j){if(!g)return;const _={...e,sheetId:j?g:void 0};b(_)}return c.jsxs(Hs,{open:r,onOpenChange:s,children:[c.jsx(Us,{children:c.jsx(xu,{className:"invisible h-3 w-3 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),c.jsx(Ws,{onMouseDown:j=>j.stopPropagation(),onDoubleClick:j=>j.stopPropagation(),className:"z-50 m-2 h-[600px] w-[500px]",children:c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[c.jsx("h4",{className:"font-medium leading-none",title:e.column,children:e.column.split(".").pop()}),c.jsx(Pe,{variant:"secondary",className:"flex-shrink-0 text-xs font-normal",children:e.dataType})]}),c.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:"Customize filter settings and scope"}),c.jsxs(js,{defaultValue:"scope",className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[c.jsxs(os,{className:"grid w-full flex-shrink-0 grid-cols-2",children:[c.jsx(Qt,{value:"scope",children:"Scope"}),c.jsx(Qt,{value:"advanced",children:"Configuration"})]}),c.jsx(qn,{value:"scope",className:"mt-4 flex-1 overflow-y-auto",children:c.jsx(uOe,{filter:{...e,...o},onUpdate:j=>{i(_=>({..._,...j}))}})}),c.jsxs(qn,{value:"advanced",className:"mt-4 flex-1 space-y-5 overflow-y-auto",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(le,{className:"text-sm font-medium",children:"Custom Title (optional)"}),c.jsx(fr,{children:c.jsxs(Dn,{delayDuration:0,children:[c.jsx(Tn,{asChild:!0,children:c.jsx(wr,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),c.jsx($n,{side:"right",className:"max-w-xs",children:c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"text-xs",children:"Leave empty to use the column name. Provide a custom title to override it."}),c.jsxs("div",{className:"space-y-1 border-t pt-2",children:[c.jsx("p",{className:"text-xs font-medium",children:"Filter ID"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("p",{className:"break-all font-mono text-xs text-muted-foreground",children:e.id}),c.jsx(wh,{text:e.id})]})]})]})})]})})]}),c.jsx(Hn,{value:a,onChange:j=>l(j.target.value),placeholder:e.column,className:"h-8 text-sm"})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx(le,{className:"text-sm font-medium",children:"Column Name"}),c.jsx(Hn,{value:u,onChange:j=>d(j.target.value),placeholder:"Enter column name",className:"h-8 font-mono text-xs"})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx(le,{className:"text-sm font-medium",children:"Selection Type"}),c.jsxs(at,{value:e.type||"multiple",onValueChange:v,children:[c.jsx(st,{className:"h-8",children:c.jsx(dt,{})}),c.jsxs(ot,{children:[c.jsx(fe,{value:"multiple",children:"Multiple"}),c.jsx(fe,{value:"single",children:"Single"})]})]})]}),e.type==="single"&&c.jsxs("div",{className:"space-y-1",children:[c.jsx(le,{className:"text-sm font-medium",children:"UI Component"}),c.jsxs(at,{value:e.uiType||"dropdown",onValueChange:w,children:[c.jsx(st,{className:"h-8",children:c.jsx(dt,{})}),c.jsxs(ot,{children:[c.jsx(fe,{value:"dropdown",children:"Dropdown"}),c.jsx(fe,{value:"radio",children:"Radio"}),c.jsx(fe,{value:"tabs",children:"Tabs"})]})]})]}),Vi(e.dataType)&&c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(le,{className:"text-sm font-medium",children:"Search Mode"}),c.jsx(fr,{children:c.jsxs(Dn,{delayDuration:0,children:[c.jsx(Tn,{asChild:!0,children:c.jsx(wr,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),c.jsx($n,{side:"right",className:"max-w-xs",children:c.jsxs("div",{className:"space-y-2 text-xs",children:[c.jsxs("p",{children:[c.jsx("strong",{children:"Text Search:"}),' Treats numbers as text (e.g., ZIP codes, IDs). Search for "90210".']}),c.jsxs("p",{children:[c.jsx("strong",{children:"Numeric Operators:"})," Supports comparison operators (e.g., >100, <=50, =100) for quantities, prices."]}),c.jsxs("p",{children:[c.jsx("strong",{children:"Auto-detect:"})," Tries numeric first, falls back to text search."]})]})})]})})]}),c.jsxs(at,{value:f,onValueChange:j=>h(j),children:[c.jsx(st,{className:"h-8",children:c.jsx(dt,{})}),c.jsxs(ot,{children:[c.jsx(fe,{value:"text",children:"Text Search"}),c.jsx(fe,{value:"numeric",children:"Numeric Operators"}),c.jsx(fe,{value:"auto",children:"Auto-detect"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(le,{className:"text-sm font-medium",children:"Default Values (optional)"}),c.jsx(fr,{children:c.jsxs(Dn,{delayDuration:0,children:[c.jsx(Tn,{asChild:!0,children:c.jsx(wr,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),c.jsx($n,{side:"right",className:"max-w-xs",children:c.jsx("p",{className:"text-xs",children:"Select values that will be automatically applied when the dashboard first loads. Works like a filter selection."})})]})})]}),x!=null&&x.records&&x.records.length>0?c.jsxs(at,{value:"",onValueChange:j=>{j&&!p.includes(j)&&m([...p,j])},children:[c.jsx(st,{className:"h-8",children:c.jsx(dt,{placeholder:"Select values to add..."})}),c.jsxs(ot,{children:[x.records.filter(j=>{var D;const _=(D=e.column.split(".").pop())==null?void 0:D.replace(/"/g,""),k=_?j[_]:j.value;return k!=null&&!p.includes(String(k))}).map(j=>{var D;const _=(D=e.column.split(".").pop())==null?void 0:D.replace(/"/g,""),k=_?j[_]:j.value;return c.jsx(fe,{value:String(k),children:String(k)},String(k))}),x.records.every(j=>{var D;const _=(D=e.column.split(".").pop())==null?void 0:D.replace(/"/g,""),k=_?j[_]:j.value;return k==null||p.includes(String(k))})&&c.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"All values selected"})]})]}):c.jsx("div",{className:"flex h-8 items-center rounded-md border bg-muted px-2 text-xs text-muted-foreground",children:"Loading filter options..."}),p.length>0&&c.jsxs("div",{className:"space-y-1.5",children:[c.jsxs("div",{className:"text-xs font-medium text-muted-foreground",children:["Selected (",p.length,"):"]}),c.jsx("div",{className:"flex flex-wrap gap-1.5",children:p.map(j=>c.jsxs(Pe,{variant:"secondary",className:"gap-1.5 text-xs",children:[String(j),c.jsx(Tt,{className:"h-3 w-3 cursor-pointer hover:text-destructive",onClick:()=>{m(_=>_.filter(k=>k!==j))}})]},j))})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(le,{className:"text-sm font-medium",children:"SQL"}),c.jsx(fr,{children:c.jsxs(Dn,{delayDuration:0,children:[c.jsx(Tn,{asChild:!0,children:c.jsx(wr,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),c.jsx($n,{side:"right",className:"max-w-xs",children:c.jsx("p",{className:"text-xs",children:"This SQL will be used to fetch the filter values"})})]})})]}),c.jsx(vd,{onKeyDown:j=>{j.stopPropagation()},value:t,onChange:j=>n(j.target.value),className:`h-32 w-full resize-none break-all font-mono text-xs ${xf}`,placeholder:"SELECT column FROM table..."})]}),c.jsx("div",{className:"border-t pt-2",children:c.jsx(sOe,{label:"Local to sheet",onCheckedChange:S,checked:!!e.sheetId})})]})]}),c.jsx("div",{className:"mt-3 flex justify-end gap-2 border-t pt-3",children:c.jsxs(se,{onClick:y,size:"sm",variant:"outline",children:[c.jsx(Dr,{className:"mr-2 size-4"}),"Accept"]})})]})})]})}function tG({filter:e}){var u;const t=ee(d=>d.isDashboardEditing),{preferences:n}=Ph(),r=((u=n==null?void 0:n.cardDisplay)==null?void 0:u.mode)==="print",s=ee(d=>d.filterValues),o=s==null?void 0:s.some(d=>d.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:l}=Jt();return c.jsxs("div",{className:"group mb-1 flex h-5 items-center justify-between",children:[c.jsxs("div",{className:"flex grow items-center gap-2",children:[c.jsx(le,{className:"my-1 inline-block text-sm",children:c.jsx($o,{value:e.title||e.column,onSave:d=>l({...e,title:d}),isEditable:t,placeholder:"Filter",displayClassName:"text-sm",inputClassName:"text-sm"})}),o&&!r&&c.jsx("button",{onClick:()=>i(e.id),className:"text-muted-foreground",children:c.jsx(Tne,{className:"size-3.5"})}),t&&c.jsx("button",{className:"invisible group-hover:visible",onClick:()=>{l({...e,hide:!e.hide})},children:e.hide?c.jsx(Xa,{className:"size-3.5 text-muted-foreground hover:text-foreground"}):c.jsx(gw,{className:"size-3.5 text-muted-foreground hover:text-foreground"})}),t&&c.jsx(dOe,{filter:e})]}),c.jsx("div",{className:"flex items-center gap-2",children:t&&c.jsx(Tt,{onClick:()=>{i(e.id),a(e.id)},className:"size-3 cursor-pointer text-muted-foreground hover:cursor-pointer hover:text-foreground"})})]})}function nG(){var g;const e=ee(b=>b.isDashboardEditing),t=ee(b=>b.selectedSheetId),n=ee(b=>b.dashboard),r=n==null?void 0:n.sheets,s=r==null?void 0:r.find(b=>b.id===t),o=ze(b=>b.card),i=ze(b=>b.selectedConnectionId),{addFrame:a,setSelectedFrameId:l,setIsVisualEditing:u}=Jt(),{setFrame:d,setCard:f,setActiveTabCardId:h}=is();function p(){var v,w;const b=o==null?void 0:o.dataSource;if(b)return b;const x=(w=(v=n==null?void 0:n.aiContext)==null?void 0:v.selectedEntities)==null?void 0:w[0],y=x==null?void 0:x.type;if(x)return{connectionId:x.connectionId,connectionType:x.connectionType,type:y,selectedEntities:[x]}}function m(b){const x=(b==null?void 0:b.sheetId)||t,y=r==null?void 0:r.find(j=>j.id===x);if(!y){console.warn("Cannot add frame: No sheet found");return}if(!(!y.frames||y.frames.length===0)&&!e){console.warn("Cannot add frame: Dashboard not in editing mode");return}const w=p(),S={id:Er(),title:"Title",type:"bar",connectionId:i||"",dataSource:w,preferences:{onClickFilter:[{columnIndex:0,expression:""}]},sql:"",data:[]},N={id:Er(),cards:[S],activeCardId:S.id};return x&&(a(x,N),l(N.id)),b!=null&&b.openVisualEditor&&(d(N),f(S),h(S.id),u(!0)),N}return{handleAddNewFrame:m,canAddFrame:e||!((g=s==null?void 0:s.frames)!=null&&g.length)}}function fOe({sheetId:e}){const{handleAddNewFrame:t}=nG(),n=ee(s=>s.themeStyle),r=()=>{t({openVisualEditor:!0,sheetId:e})};return c.jsx("div",{className:"flex h-full min-h-[400px] items-start justify-start p-4",children:c.jsxs("button",{onClick:r,style:{borderRadius:n==null?void 0:n.cardBorderRadius},className:"group flex h-96 w-[600px] flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed border-muted-foreground/25 bg-background transition-all hover:border-muted-foreground/50 hover:bg-muted/50",children:[c.jsx("div",{className:"rounded-full bg-primary/10 p-3 transition-colors group-hover:bg-primary/20",children:c.jsx(Sr,{className:"h-6 w-6 text-primary"})}),c.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Add new Visual"})]})})}function Rv(e){const t=(e||"").toLowerCase(),n=ia(t);return n==="string"?c.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm border border-blue-200/70 bg-gradient-to-r from-blue-100/60 to-blue-200/40 text-blue-900 shadow-sm dark:border-blue-800/50 dark:from-blue-950/40 dark:to-blue-900/30 dark:text-blue-100",children:c.jsx(z2,{className:"h-3 w-3"})}):n==="number"?c.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm border border-green-200/70 bg-gradient-to-r from-green-100/60 to-green-200/40 text-green-900 shadow-sm dark:border-green-800/50 dark:from-green-950/40 dark:to-green-900/30 dark:text-green-100",children:c.jsx(_L,{className:"h-3 w-3"})}):n==="date"?c.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm border border-purple-200/70 bg-gradient-to-r from-purple-100/60 to-purple-200/40 text-purple-900 shadow-sm dark:border-purple-800/50 dark:from-purple-950/40 dark:to-purple-900/30 dark:text-purple-100",children:c.jsx(ts,{className:"h-3 w-3"})}):n==="boolean"?c.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm border border-orange-200/70 bg-gradient-to-r from-orange-100/60 to-orange-200/40 text-orange-900 shadow-sm dark:border-orange-800/50 dark:from-orange-950/40 dark:to-orange-900/30 dark:text-orange-100",children:c.jsx(Une,{className:"h-3 w-3"})}):n==="json"?c.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm border border-gray-200/70 bg-gradient-to-r from-gray-100/60 to-gray-200/40 text-gray-900 shadow-sm dark:border-gray-800/50 dark:from-gray-950/40 dark:to-gray-900/30 dark:text-gray-100",children:c.jsx(SL,{className:"h-3 w-3"})}):n==="geo"?c.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm border border-amber-200/70 bg-gradient-to-r from-amber-100/60 to-amber-200/40 text-amber-900 shadow-sm dark:border-amber-800/50 dark:from-amber-950/40 dark:to-amber-900/30 dark:text-amber-100",children:c.jsx(Ine,{className:"h-3 w-3"})}):n==="calculated"?c.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm border border-indigo-200/70 bg-gradient-to-r from-indigo-100/60 to-indigo-200/40 text-indigo-900 shadow-sm dark:border-indigo-800/50 dark:from-indigo-950/40 dark:to-indigo-900/30 dark:text-indigo-100",children:c.jsx(cL,{className:"h-3 w-3"})}):c.jsx("div",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm border border-gray-200/70 bg-gradient-to-r from-gray-100/60 to-gray-200/40 text-gray-900 shadow-sm dark:border-gray-800/50 dark:from-gray-950/40 dark:to-gray-900/30 dark:text-gray-100",children:c.jsx(z2,{className:"h-3 w-3"})})}function hOe({value:e,onChange:t,metrics:n,attributes:r}){const s=(o,i)=>(e==null?void 0:e.field.id)===o.id&&(e==null?void 0:e.type)===i;return c.jsx(fr,{children:c.jsxs("div",{className:"space-y-4",children:[n.length>0&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase",children:"Value of Metric"}),c.jsxs(Dn,{children:[c.jsx(Tn,{asChild:!0,children:c.jsx(wr,{className:"h-3.5 w-3.5 text-muted-foreground"})}),c.jsxs($n,{className:"max-w-xs",children:[c.jsx("p",{className:"text-xs font-medium mb-1",children:"Captures intersection of all dimensions"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:`Example: Clicking a bar segment in "Sales by Country, stacked by State" captures both Country='USA' AND State='California'`})]})]})]}),c.jsx("div",{className:"space-y-1",children:n.map(o=>{const i=s(o,"metric");return c.jsxs(se,{variant:i?"default":"outline",size:"sm",className:K("w-full justify-start font-normal",i&&"bg-primary text-primary-foreground"),onClick:()=>t({type:"metric",field:o}),children:[i&&c.jsx(Dr,{className:"mr-2 h-4 w-4"}),Rv(o.dataType),c.jsx("span",{className:"ml-2",children:o.label})]},o.id)})})]}),r.length>0&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase",children:"Value of Attribute"}),c.jsxs(Dn,{children:[c.jsx(Tn,{asChild:!0,children:c.jsx(wr,{className:"h-3.5 w-3.5 text-muted-foreground"})}),c.jsxs($n,{className:"max-w-xs",children:[c.jsx("p",{className:"text-xs font-medium mb-1",children:"Captures only this dimension"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:`Example: If configured on "State", clicking a bar in "Sales by Country, stacked by State" captures only State='California' (Country is not included)`})]})]})]}),c.jsx("div",{className:"space-y-1",children:r.map(o=>{const i=s(o,"attribute");return c.jsxs(se,{variant:i?"default":"outline",size:"sm",className:K("w-full justify-start font-normal",i&&"bg-primary text-primary-foreground"),onClick:()=>t({type:"attribute",field:o}),children:[i&&c.jsx(Dr,{className:"mr-2 h-4 w-4"}),Rv(o.dataType),c.jsx("span",{className:"ml-2",children:o.label})]},o.id)})})]}),n.length===0&&r.length===0&&c.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"No metrics or attributes available in this chart"})]})})}const NF=[{value:"clickFilter",label:"Cross filter",description:"Filter other cards on the dashboard"},{value:"drillDown",label:"Drill down",description:"Navigate through a hierarchy of dimensions"},{value:"dynamicDrill",label:"Explore dimensions",description:"Let users explore any dimension dynamically"},{value:"drillThrough",label:"Drill into dashboard",description:"Navigate to another dashboard"},{value:"drillToDetail",label:"Drill into insight",description:"Navigate to a saved insight"},{value:"drillToURL",label:"Drill into URL",description:"Navigate to a custom URL"}];function pOe({value:e,onChange:t}){const n=NF.find(r=>r.value===e);return c.jsx("div",{className:"space-y-2",children:c.jsxs(at,{value:e,onValueChange:t,children:[c.jsx(st,{className:"w-full",children:c.jsx(dt,{placeholder:"Choose action...",children:n&&c.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const r=Tv(n.value);return c.jsx(r,{className:"h-4 w-4"})})(),c.jsx("span",{children:n.label})]})})}),c.jsx(ot,{children:NF.map(r=>{const s=Tv(r.value);return c.jsx(fe,{value:r.value,children:c.jsxs("div",{className:"flex items-start gap-2 py-1",children:[c.jsx(s,{className:"mt-0.5 h-4 w-4 shrink-0"}),c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{className:"font-medium",children:r.label}),c.jsx("span",{className:"text-xs text-muted-foreground",children:r.description})]})]})},r.value)})})]})})}function mOe({interaction:e,onUpdate:t}){const[n,r]=C.useState(""),s=_$(),o=()=>e.applyToCardIds!==void 0?"specific-cards":e.excludeCardIds!==void 0?"all-except-specific":"all-cards",i=d=>{const f={};switch(d){case"all-cards":f.applyToCardIds=void 0,f.excludeCardIds=void 0;break;case"specific-cards":f.applyToCardIds=[],f.excludeCardIds=void 0;break;case"all-except-specific":f.applyToCardIds=void 0,f.excludeCardIds=[];break}t({...e,...f})},a=(d,f)=>{if(f==="specific-cards"){const h=e.applyToCardIds||[],p=h.includes(d)?h.filter(m=>m!==d):[...h,d];t({...e,applyToCardIds:p})}else if(f==="all-except-specific"){const h=e.excludeCardIds||[],p=h.includes(d)?h.filter(m=>m!==d):[...h,d];t({...e,excludeCardIds:p})}},l=C.useMemo(()=>{if(!n.trim())return s;const d=n.toLowerCase();return s==null?void 0:s.filter(f=>{var h;return(h=f==null?void 0:f.title)==null?void 0:h.toLowerCase().includes(d)})},[n,s]),u=o();return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"space-y-0.5",children:[c.jsx(le,{className:"text-sm font-medium",children:"Filter scope"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose which cards should receive the filter"})]}),c.jsxs(ra,{value:u,onValueChange:d=>i(d),className:"space-y-2",children:[c.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[c.jsx(vr,{value:"all-cards",id:"all-cards",className:"mt-0.5"}),c.jsxs("div",{className:"flex-1 space-y-1",children:[c.jsx(le,{htmlFor:"all-cards",className:"cursor-pointer text-sm font-medium",children:"All cards"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards in the dashboard"})]})]}),c.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[c.jsx(vr,{value:"specific-cards",id:"specific-cards",className:"mt-0.5"}),c.jsxs("div",{className:"flex-1 space-y-1",children:[c.jsx(le,{htmlFor:"specific-cards",className:"cursor-pointer text-sm font-medium",children:"Only specific cards"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to selected cards only"})]})]}),u==="specific-cards"&&c.jsxs("div",{className:"ml-7 space-y-2",children:[c.jsxs("div",{className:"space-y-0.5",children:[c.jsx(le,{className:"text-sm font-medium",children:"Cards to filter"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should receive the filter"})]}),c.jsx(xn,{placeholder:"Search cards...",value:n,onChange:d=>r(d.target.value),className:"mb-2"}),c.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:l&&l.length>0?l.map(d=>{const f=(e.applyToCardIds||[]).includes(d.id);return c.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[c.jsx(on,{id:`card-${d.id}`,checked:f,onCheckedChange:()=>a(d.id,"specific-cards")}),c.jsxs("div",{className:"flex-1",children:[c.jsx(le,{htmlFor:`card-${d.id}`,className:"cursor-pointer text-sm font-medium",children:d.title}),d.description&&c.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:d.description})]})]},d.id)}):c.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:n?`No cards found matching "${n}"`:"No cards available"})})]}),c.jsxs("div",{className:"flex items-start space-x-3 rounded-md border bg-background p-3",children:[c.jsx(vr,{value:"all-except-specific",id:"all-except-specific",className:"mt-0.5"}),c.jsxs("div",{className:"flex-1 space-y-1",children:[c.jsx(le,{htmlFor:"all-except-specific",className:"cursor-pointer text-sm font-medium",children:"All cards except specific ones"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply filter to all cards, excluding selected ones"})]})]}),u==="all-except-specific"&&c.jsxs("div",{className:"ml-7 space-y-2",children:[c.jsxs("div",{className:"space-y-0.5",children:[c.jsx(le,{className:"text-sm font-medium",children:"Cards to exclude"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which cards should be excluded from filtering"})]}),c.jsx(xn,{placeholder:"Search cards...",value:n,onChange:d=>r(d.target.value),className:"mb-2"}),c.jsx("div",{className:"grid max-h-40 grid-cols-1 gap-2 overflow-y-auto rounded-md border bg-muted/20 p-3",children:l&&l.length>0?l.map(d=>{const f=(e.excludeCardIds||[]).includes(d.id);return c.jsxs("div",{className:"flex items-center space-x-3 rounded p-2 hover:bg-background/50",children:[c.jsx(on,{id:`card-exclude-${d.id}`,checked:f,onCheckedChange:()=>a(d.id,"all-except-specific")}),c.jsxs("div",{className:"flex-1",children:[c.jsx(le,{htmlFor:`card-exclude-${d.id}`,className:"cursor-pointer text-sm font-medium",children:d.title}),d.description&&c.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:d.description})]})]},d.id)}):c.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:n?`No cards found matching "${n}"`:"No cards available"})})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(le,{className:"text-sm font-medium",children:"Menu label"}),c.jsx(xn,{value:e.label||"",onChange:d=>t({...e,label:d.target.value}),placeholder:Dd(e.mode)}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"How this interaction appears when multiple actions are available"})]})]})}var oR="Collapsible",[gOe,rG]=Nr(oR),[bOe,iR]=gOe(oR),sG=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:s,disabled:o,onOpenChange:i,...a}=e,[l=!1,u]=Pr({prop:r,defaultProp:s,onChange:i});return c.jsx(bOe,{scope:n,disabled:o,contentId:Jn(),open:l,onOpenToggle:E.useCallback(()=>u(d=>!d),[u]),children:c.jsx($e.div,{"data-state":uR(l),"data-disabled":o?"":void 0,...a,ref:t})})});sG.displayName=oR;var oG="CollapsibleTrigger",aR=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,s=iR(oG,n);return c.jsx($e.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":uR(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:t,onClick:je(e.onClick,s.onOpenToggle)})});aR.displayName=oG;var lR="CollapsibleContent",cR=E.forwardRef((e,t)=>{const{forceMount:n,...r}=e,s=iR(lR,e.__scopeCollapsible);return c.jsx(er,{present:n||s.open,children:({present:o})=>c.jsx(xOe,{...r,ref:t,present:o})})});cR.displayName=lR;var xOe=E.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:s,...o}=e,i=iR(lR,n),[a,l]=E.useState(r),u=E.useRef(null),d=mt(t,u),f=E.useRef(0),h=f.current,p=E.useRef(0),m=p.current,g=i.open||a,b=E.useRef(g),x=E.useRef(void 0);return E.useEffect(()=>{const y=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(y)},[]),Or(()=>{const y=u.current;if(y){x.current=x.current||{transitionDuration:y.style.transitionDuration,animationName:y.style.animationName},y.style.transitionDuration="0s",y.style.animationName="none";const v=y.getBoundingClientRect();f.current=v.height,p.current=v.width,b.current||(y.style.transitionDuration=x.current.transitionDuration,y.style.animationName=x.current.animationName),l(r)}},[i.open,r]),c.jsx($e.div,{"data-state":uR(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...o,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:g&&s})});function uR(e){return e?"open":"closed"}var iG=sG,yOe=aR,vOe=cR;const sd=iG,od=aR,id=cR;function wOe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return C.useMemo(()=>r=>{t.forEach(s=>s(r))},t)}const $1=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function sp(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function dR(e){return"nodeType"in e}function ks(e){var t,n;return e?sp(e)?e:dR(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function fR(e){const{Document:t}=ks(e);return e instanceof t}function Wb(e){return sp(e)?!1:e instanceof ks(e).HTMLElement}function aG(e){return e instanceof ks(e).SVGElement}function op(e){return e?sp(e)?e.document:dR(e)?fR(e)?e:Wb(e)||aG(e)?e.ownerDocument:document:document:document}const gi=$1?C.useLayoutEffect:C.useEffect;function L1(e){const t=C.useRef(e);return gi(()=>{t.current=e}),C.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return t.current==null?void 0:t.current(...r)},[])}function SOe(){const e=C.useRef(null),t=C.useCallback((r,s)=>{e.current=setInterval(r,s)},[]),n=C.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function kg(e,t){t===void 0&&(t=[e]);const n=C.useRef(e);return gi(()=>{n.current!==e&&(n.current=e)},t),n}function qb(e,t){const n=C.useRef();return C.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Mv(e){const t=L1(e),n=C.useRef(null),r=C.useCallback(s=>{s!==n.current&&(t==null||t(s,n.current)),n.current=s},[]);return[n,r]}function Iv(e){const t=C.useRef();return C.useEffect(()=>{t.current=e},[e]),t.current}let NN={};function Yb(e,t){return C.useMemo(()=>{if(t)return t;const n=NN[e]==null?0:NN[e]+1;return NN[e]=n,e+"-"+n},[e,t])}function lG(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return r.reduce((o,i)=>{const a=Object.entries(i);for(const[l,u]of a){const d=o[l];d!=null&&(o[l]=d+e*u)}return o},{...t})}}const Rf=lG(1),Eg=lG(-1);function COe(e){return"clientX"in e&&"clientY"in e}function z1(e){if(!e)return!1;const{KeyboardEvent:t}=ks(e.target);return t&&e instanceof t}function NOe(e){if(!e)return!1;const{TouchEvent:t}=ks(e.target);return t&&e instanceof t}function Av(e){if(NOe(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return COe(e)?{x:e.clientX,y:e.clientY}:null}const oa=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[oa.Translate.toString(e),oa.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),jF="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function jOe(e){return e.matches(jF)?e:e.querySelector(jF)}const kOe={display:"none"};function EOe(e){let{id:t,value:n}=e;return C.createElement("div",{id:t,style:kOe},n)}function _Oe(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const s={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return C.createElement("div",{id:t,style:s,role:"status","aria-live":r,"aria-atomic":!0},n)}function DOe(){const[e,t]=C.useState("");return{announce:C.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const cG=C.createContext(null);function TOe(e){const t=C.useContext(cG);C.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function ROe(){const[e]=C.useState(()=>new Set),t=C.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[C.useCallback(r=>{let{type:s,event:o}=r;e.forEach(i=>{var a;return(a=i[s])==null?void 0:a.call(i,o)})},[e]),t]}const MOe={draggable:`
946
946
  To pick up a draggable item, press the space bar.
947
947
  While dragging, use the arrow keys to move the item.
948
948
  Press space again to drop the item in its new position, or press escape to cancel.