@texturehq/edges 5.10.1 → 5.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
`}})]})}function tn(e,t=300){let[r,o]=qe.useState(e);return qe.useEffect(()=>{let n=setTimeout(()=>o(e),t);return ()=>clearTimeout(n)},[e,t]),r}function al(e,t=300){let[r,o]=qe.useState(false);return qe.useEffect(()=>{if(e){let n=setTimeout(()=>{o(true);},t);return ()=>clearTimeout(n)}o(false);},[e,t]),r}var gN=({isEntering:e,isExiting:t,className:r})=>["max-w-[200px] group bg-action-default border border-action-default-hover text-[color:var(--color-action-default-text)] text-sm rounded-lg drop-shadow-lg will-change-transform px-3 py-1",e?"animate-in fade-in placement-bottom:slide-in-from-top-0.5 placement-top:slide-in-from-bottom-0.5 placement-left:slide-in-from-right-0.5 placement-right:slide-in-from-left-0.5 ease-out duration-200":"",t?"animate-out fade-out placement-bottom:slide-out-to-top-0.5 placement-top:slide-out-to-bottom-0.5 placement-left:slide-out-to-right-0.5 placement-right:slide-out-to-left-0.5 ease-in duration-150":"",r].filter(Boolean).join(" ");function dr({children:e,content:t,...r}){return jsxRuntime.jsxs(reactAriaComponents.TooltipTrigger,{delay:200,children:[e,jsxRuntime.jsxs(reactAriaComponents.Tooltip,{...r,offset:10,className:reactAriaComponents.composeRenderProps(r.className,(o,n)=>gN({...n,className:o})),children:[jsxRuntime.jsx(reactAriaComponents.OverlayArrow,{children:jsxRuntime.jsx("svg",{width:8,height:8,viewBox:"0 0 8 8",className:"fill-action-default stroke-action-default-hover group-placement-left:-rotate-90 group-placement-right:rotate-90 group-placement-bottom:rotate-180 forced-colors:fill-[Canvas] forced-colors:stroke-[ButtonBorder]",children:jsxRuntime.jsx("path",{d:"M0 0 L4 4 L8 0"})})}),t]})]})}function ur(){let[e,t]=qe__namespace.default.useState(false),r=qe__namespace.default.useCallback((n,a)=>{t(true),a?.(n);},[]),o=qe__namespace.default.useCallback((n,a)=>{t(false),a?.(n);},[]);return {isFocused:e,handleFocus:r,handleBlur:o}}var Ct=qe__namespace.default.forwardRef(({children:e,className:t},r)=>jsxRuntime.jsx("div",{ref:r,className:tailwindMerge.twMerge("relative w-full",t),children:e}));Ct.displayName="InputWrapper";function Ii({onClick:e,size:t="md",className:r}){return jsxRuntime.jsx("button",{type:"button",onClick:o=>{o.preventDefault(),o.stopPropagation(),e();},className:tailwindMerge.twMerge("absolute right-2 top-[48%] -translate-y-1/2 transform text-text-secondary hover:text-text-primary cursor-pointer",r),"aria-label":"Clear input",onMouseDown:o=>{o.preventDefault(),o.stopPropagation();},children:jsxRuntime.jsx(O,{name:"X",size:t==="sm"?16:20})})}function rn(e){let{isInvalid:t,isDisabled:r,isFocused:o}=e,n="border rounded-[var(--control-border-radius)] !outline-none ";return r?`${n} border-border-muted`:t&&o?`${n} border-feedback-error-border shadow-[inset_0_0_0_1px_var(--color-feedback-error-border)]`:t?`${n} border-feedback-error-border`:o?`${n} border-border-focus shadow-[inset_0_0_0_1px_var(--color-border-focus)]`:`${n} border-border-input`}function Og(e){return e.isDisabled?"bg-background-muted":e.transparent?"bg-transparent":"bg-background-input"}function bN(e){return e==="sm"?"!text-base md:!text-[length:var(--control-text-sm)]":e==="md"?"!text-base md:!text-[length:var(--control-text-md)]":""}function zt(e){let{isInvalid:t,isDisabled:r,isFocused:o,transparent:n,size:a="md",className:i}=e;return tailwindMerge.twMerge("w-full",rn({isInvalid:t,isDisabled:r,isFocused:o}),Og({transparent:n,isDisabled:r}),We[a].text,We[a].height,We[a].padding,bN(a),i)}function hN(e){let{size:t="md",isFocusWithin:r,isInvalid:o,isDisabled:n,transparent:a,className:i}=e;return tailwindMerge.twMerge("group flex items-center rounded-[var(--control-border-radius)] overflow-hidden",Og({transparent:a,isDisabled:n}),We[t].height,rn({isFocused:r,isInvalid:o,isDisabled:n}),i)}function Ke({children:e,size:t="md",tooltip:r,description:o,descriptionPlacement:n="below",isRequired:a,className:i,htmlFor:s}){let l=r||o&&n==="tooltip",c=r||o,d=o&&n==="inline",u=jsxRuntime.jsxs("label",{htmlFor:s,className:tailwindMerge.twMerge(We[t].text,"!text-text-label font-semibold flex items-center gap-1",i),children:[e,a&&jsxRuntime.jsx("span",{children:"*"}),l&&jsxRuntime.jsx("span",{className:"inline-flex items-center text-text-secondary",children:jsxRuntime.jsx(O,{name:"Info",size:t==="sm"?16:20})}),d&&jsxRuntime.jsx("span",{className:"text-text-secondary font-normal ml-1",children:o})]});return l&&c?jsxRuntime.jsx(dr,{content:c,children:u}):u}function Ne({size:e="md",className:t,children:r,...o}){return jsxRuntime.jsx("div",{...o,className:tailwindMerge.twMerge("leading-[2.25] text-text-secondary",We[e].text,t),children:r})}function he({children:e,size:t="md",className:r}){return jsxRuntime.jsx("div",{role:"alert",className:tailwindMerge.twMerge(We[t].text,"text-feedback-error-text",r),children:e})}function sl({size:e="md",isInvalid:t,isDisabled:r,isFocused:o,transparent:n,className:a,...i}){return jsxRuntime.jsx("input",{className:zt({isInvalid:t,isDisabled:r,isFocused:o,transparent:n,size:e,className:a}),...i})}function zg(e){let{children:t,...r}=e;return jsxRuntime.jsx("div",{...r,className:hN(e),children:typeof t=="function"?t(e):t})}var Au=qe.createContext("md");function Kg(){return qe.useContext(Au)}function Mu(e="md"){let t=e==="sm"?"!text-base md:!text-[length:var(--control-text-sm)]":e==="md"?"!text-base md:!text-[length:var(--control-text-md)]":"";return `flex-1 text-start data-[placeholder]:text-text-disabled overflow-hidden text-ellipsis whitespace-nowrap ${We[e].text} ${t}`}function wN(){let e=qe__namespace.default.useCallback((r,o)=>{o?.(r);},[]),t=qe__namespace.default.useCallback((r,o)=>{o?.(r);},[]);return {handleFocus:e,handleBlur:t}}function Bo({label:e,description:t,errorMessage:r,children:o,items:n,renderItem:a,renderSelectedValue:i,size:s="md",selectedKey:l,defaultSelectedKey:c,onSelectionChange:d,placeholder:u,showErrors:p=false,tooltip:m,isRequired:f,transparent:g,reserveErrorSpace:x=false,placement:b="bottom start",shouldFlip:h=true,menuWidth:y="match",descriptionPlacement:v="below",useMobileTray:S=true,...w}){let[N,R]=qe.useState(null),[P,E]=qe.useState(null),[I,T]=qe.useState(false),D=l??N??c,{handleFocus:M,handleBlur:B}=wN(),{isMobile:z}=ar(),V=S&&z,U=qe__namespace.default.useMemo(()=>!i||!D||!n?null:Array.from(n).find(Y=>Y.id===D)??null,[i,D,n]),Z=A=>{d&&A!==null&&d(A),d||R(A);},G=qe.useRef(null),J=qe.useRef(null),W=()=>{V&&T(!I);};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactAriaComponents.Select,{...w,selectedKey:D,defaultSelectedKey:c,onSelectionChange:Z,placeholder:u,className:Me(w.className,"group flex w-full flex-col"),ref:G,onOpenChange:A=>{V||(A&&J.current?E(J.current.offsetWidth):A||G.current?.blur());},children:({isDisabled:A,isInvalid:Y,isOpen:k})=>jsxRuntime.jsxs("div",{className:"flex flex-col",children:[e&&jsxRuntime.jsx(Ke,{size:s,tooltip:m,description:v==="tooltip"||v==="inline"?t:void 0,descriptionPlacement:v,isRequired:f,children:e}),jsxRuntime.jsx(Ct,{children:jsxRuntime.jsx("div",{ref:J,children:jsxRuntime.jsxs($,{variant:"unstyled",className:tailwindMerge.twMerge(zt({isInvalid:Y||p&&!!r,isDisabled:A,isFocused:V?I:k,transparent:g,size:s}),"flex items-center text-start gap-4 cursor-pointer pl-[var(--control-padding-sm)]"),onFocus:C=>M(C,w.onFocus),onBlur:C=>B(C,w.onBlur),onPress:V?W:void 0,"data-open":V?I:k,children:[i&&U?jsxRuntime.jsx("div",{className:Mu(s),children:i(U)}):V&&D?jsxRuntime.jsx("div",{className:Mu(s),children:n?Array.from(n).find(F=>F.id===D)?.label:String(D)}):jsxRuntime.jsx(reactAriaComponents.SelectValue,{className:Mu(s)}),jsxRuntime.jsx(O,{name:"CaretDown","aria-hidden":true,className:tailwindMerge.twMerge("h-4 w-4 text-text-primary group-disabled:text-text-disabled forced-colors:text-[ButtonText] transition-transform",(V?I:k)&&"rotate-180")})]})})}),x?jsxRuntime.jsx("div",{className:"mt-1 min-h-[20px]",children:p?jsxRuntime.jsx(he,{size:s,className:"text-feedback-error-text",children:typeof r=="function"&&w.validationResult?r(w.validationResult):typeof r=="string"?r:null}):t&&v==="below"?jsxRuntime.jsx(Ne,{size:s,children:t}):null}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:p?jsxRuntime.jsx(he,{size:s,className:"mt-1 text-feedback-error-text",children:typeof r=="function"&&w.validationResult?r(w.validationResult):typeof r=="string"?r:null}):t&&v==="below"?jsxRuntime.jsx(Ne,{size:s,className:"mt-1",children:t}):null}),V?null:jsxRuntime.jsx(yt,{className:"bg-background-input shadow-xl border border-border-input/20 backdrop-blur-sm rounded-[var(--control-border-radius)]",style:{width:y==="match"&&P?`${P}px`:void 0,minWidth:y==="auto"&&P?`${P}px`:void 0,maxWidth:y==="auto"?"min(600px, 90vw)":void 0},placement:b,shouldFlip:h,children:jsxRuntime.jsx(Au.Provider,{value:"md",children:jsxRuntime.jsx(reactAriaComponents.ListBox,{items:n,className:"w-full max-h-[300px] overflow-auto bg-background-input p-0 outline-0",children:a&&n?C=>jsxRuntime.jsx(pr,{id:C.id,textValue:C.label,children:jsxRuntime.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap min-w-0 flex-1",children:a(C)})},C.id):o})})})]})}),V&&jsxRuntime.jsx(vt,{isOpen:I,onClose:()=>T(false),title:e??"Select an option",contentPadding:false,children:jsxRuntime.jsx(Au.Provider,{value:"md",children:jsxRuntime.jsx(reactAriaComponents.ListBox,{items:n,className:"w-full bg-background-surface p-0 outline-0 [&_[role=option]]:border-b [&_[role=option]]:border-border-default [&_[role=option]:last-child]:border-0 [&_[role=option]]:!px-6 [&_[role=option]]:!py-4 [&_[role=option]]:rounded-none",selectionMode:"single",selectedKeys:D!=null?[D]:[],onSelectionChange:A=>{let Y=Array.from(A)[0];Y!=null&&(Z(Y),T(false));},children:a&&n?A=>jsxRuntime.jsx(pr,{id:A.id,textValue:A.label,children:jsxRuntime.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap min-w-0 flex-1",children:a(A)})},A.id):o})})})]})}function pr({size:e,className:t,...r}){let o=Kg(),n=e??o;return jsxRuntime.jsx(reactAriaComponents.ListBoxItem,{...r,className:tailwindMerge.twMerge("flex cursor-default items-center gap-2 rounded-sm px-3 outline-none text-text-primary data-[focused]:bg-background-hover data-[focus-visible]:ring-2 data-[focus-visible]:ring-action-default data-[focus-visible]:ring-inset data-[selected]:bg-background-selected data-[selected]:font-medium overflow-hidden",We[n].paddingY,We[n].text,t)})}var FN=[],BN={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",xl:"h-7 w-7"},VN={sm:"pl-8",md:"pl-10",lg:"pl-11",xl:"pl-13"},Jg={sm:"py-1",md:"py-2",lg:"py-3",xl:"py-4"},Fu=(e,t,r)=>{if(e==null||e==="")return "";let n=(r?r.flatMap(a=>a.items):t||[]).find(a=>a.id===e);return n?n.name:""};async function ON(e,t,r){try{let o=e.url.replace("{q}",t),n=new URLSearchParams;e.extraParams&&Object.entries(e.extraParams).forEach(([l,c])=>{n.append(l,c.toString());});let a=`${o}${n.toString()?"?"+n.toString():""}`,i=await fetch(a,{method:"GET",headers:e.headers,signal:r});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);let s=await i.json();return {items:e.transformResponse(s)}}catch(o){if(o instanceof Error&&o.name==="AbortError")return {items:[]};console.error("Error in REST request:",o);let n=o instanceof Error?o.message:"Unknown error occurred";return {items:[],error:n}}}async function zN(e,t,r){try{let o=e.graphqlQuery.replace(`$${e.variableKey||"filter"}`,`"${t}"`),n=await fetch(e.url,{method:"POST",headers:{"Content-Type":"application/json",...e.headers},body:JSON.stringify({query:o}),signal:r});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);let a=await n.json();if(a.errors)throw new Error(a.errors[0]?.message||"GraphQL error occurred");return e.responsePath&&(a=e.responsePath.split(".").reduce((i,s)=>i?.[s],a)),{items:e.transformResponse(a)}}catch(o){if(o instanceof Error&&o.name==="AbortError")return {items:[]};console.error("Error in GraphQL request:",o);let n=o instanceof Error?o.message:"Unknown error occurred";return {items:[],error:n}}}function dl({label:e,staticItems:t=FN,sections:r,selectedKey:o,defaultSelectedKey:n,onSelectionChange:a,requestConfig:i,defaultFilter:s,placeholder:l,errorMessage:c,description:d,size:u="md",tooltip:p,isRequired:m,isDisabled:f,isInvalid:g,validationResult:x,showErrors:b=true,renderItem:h,renderLeftIcon:y,renderSection:v,autoFocus:S=false,reserveErrorSpace:w=false,hideChevron:N=false,useMobileTray:R=true,className:P}){let E=qe__namespace.default.useRef(null),I=qe__namespace.default.useRef(null),[T,D]=qe__namespace.default.useState(),[M,B]=qe.useState(()=>Fu(o||n,t,r)),[z,V]=qe.useState(false),[U,Z]=qe.useState(false),G=tn(M),{contains:J}=reactAria.useFilter({sensitivity:"base"}),[W,A]=qe.useState(),{isMobile:Y}=ar(),k=R&&Y,C=We[u].text,L=reactStately.useAsyncList({async load({signal:ge,filterText:xe=""}){if(!i)return {items:[]};if(!i.url||i.shouldLoad&&!i.shouldLoad(xe))return {items:[]};try{let re;return i.requestType==="GraphQL"?re=await zN(i,xe,ge):re=await ON(i,xe,ge),A(re.error),{items:re.items}}catch(re){return re instanceof Error&&re.name==="AbortError"?{items:[]}:(console.error("Error loading items:",re),A(re instanceof Error?re.message:"Unknown error occurred"),{items:[]})}},initialFilterText:""}),F=i&&G!==""?L:null,j=false,ne=qe.useRef("");qe.useEffect(()=>{S&&V(true);},[S]),qe.useEffect(()=>{let ge=Fu(o,t,r);ge!==M&&B(ge);},[o,t,r]),qe.useEffect(()=>{let ge=()=>{E.current&&D(E.current.offsetWidth);};return ge(),window.addEventListener("resize",ge),()=>window.removeEventListener("resize",ge)},[]),qe.useEffect(()=>{G===""?ne.current="":F&&G!==ne.current&&(ne.current=G,F.setFilterText(G));},[G,F]),j=al(!!F?.isLoading,300);let ce=qe__namespace.default.useMemo(()=>{if(!k||!M)return F?F.items:t;let ge=F?F.items:t,xe=s??(i?()=>true:J);return ge.filter(re=>xe(re.name,M))},[k,M,F,t,s,J]),ee=ge=>{let xe=Fu(ge,t,r);B(xe),a&&a(ge);},ae=ge=>{B(ge);},Le=()=>{k&&Z(true);};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(reactAriaComponents.ComboBox,{onSelectionChange:ee,selectedKey:o||void 0,defaultSelectedKey:n||void 0,items:F?F.items:r?r.flatMap(ge=>ge.items):t,className:Me(P,"group flex flex-col w-full"),menuTrigger:k?"manual":i?"input":"focus",allowsEmptyCollection:!!i,isDisabled:f,isInvalid:g||!!c,inputValue:M,onInputChange:ae,autoFocus:S&&!k,defaultFilter:s??(i?()=>true:J),"aria-label":e||l||"Autocomplete",children:ge=>jsxRuntime.jsxs("div",{className:"flex flex-col",children:[e&&jsxRuntime.jsx(Ke,{size:u,tooltip:p,isRequired:m,children:e}),jsxRuntime.jsxs(Ct,{ref:E,children:[y?jsxRuntime.jsx("div",{className:"pointer-events-none absolute left-3 top-[45%] -translate-y-1/2 z-10",children:y(j)}):jsxRuntime.jsx("div",{className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 z-10 flex items-center",children:j?jsxRuntime.jsx(Wr,{size:16,color:"text-text-secondary"}):jsxRuntime.jsx(O,{name:"MagnifyingGlass",className:`${BN[u]} text-text-secondary`})}),jsxRuntime.jsx(reactAriaComponents.Input,{className:zt({isInvalid:g||!!c,isDisabled:f,isFocused:z||(k?U:ge.isOpen),size:u,className:tailwindMerge.twMerge(VN[u],M&&!f||!N&&!M?"pr-10":"pr-3",k&&"cursor-pointer",P)}),placeholder:l,disabled:f,onFocus:xe=>{V(true),k&&(xe.currentTarget.blur(),Le());},onBlur:()=>{V(false);},onClick:k?Le:void 0,readOnly:k,"aria-label":e||l||"Autocomplete"}),M&&!f&&jsxRuntime.jsx(Ii,{onClick:()=>{B(""),a?.(null);},size:u}),!N&&!M&&jsxRuntime.jsx(reactAriaComponents.Button,{className:"absolute right-3 top-[46%] -translate-y-1/2 transform text-text-secondary hover:text-text-primary","aria-label":"Toggle menu",isDisabled:f,children:({isPressed:xe})=>jsxRuntime.jsx(O,{name:xe?"CaretUp":"CaretDown",className:"h-4 w-4"})})]}),w?jsxRuntime.jsx("div",{className:"mt-1 min-h-[20px]",children:b&&W?jsxRuntime.jsx(he,{size:u,className:"text-feedback-error-text",children:W}):b&&typeof c=="string"?jsxRuntime.jsx(he,{size:u,className:"text-feedback-error-text",children:c}):b&&typeof c=="function"&&x?jsxRuntime.jsx(he,{size:u,className:"text-feedback-error-text",children:c(x)}):d?jsxRuntime.jsx(Ne,{size:u,children:d}):null}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[d&&jsxRuntime.jsx(Ne,{size:u,className:"mt-1",children:d}),b&&W&&jsxRuntime.jsx(he,{size:u,className:"text-feedback-error-text mt-1",children:W}),b&&typeof c=="string"&&jsxRuntime.jsx(he,{size:u,className:"text-feedback-error-text mt-1",children:c}),b&&typeof c=="function"&&x&&jsxRuntime.jsx(he,{size:u,className:"text-feedback-error-text mt-1",children:c(x)})]}),!k&&jsxRuntime.jsx(yt,{className:"bg-background-input shadow-xl border border-border-input/20 backdrop-blur-sm ring-1 ring-black/5 rounded-[var(--control-border-radius)]",style:{minWidth:T?`${T}px`:void 0,zIndex:9999},children:jsxRuntime.jsx(reactAriaComponents.ListBox,{"aria-label":e||l||"Suggestions",className:`max-h-[300px] overflow-auto bg-background-input outline-none ${C}`,children:r?r.map(xe=>{let re=xe.items.map(ie=>jsxRuntime.jsx(pr,{id:ie.id,textValue:ie.name,size:u,className:`flex cursor-default items-center gap-2 px-3 ${Jg[u]} text-text-primary outline-none data-[focused]:bg-background-hover data-[selected]:bg-background-selected data-[selected]:font-medium data-[focus-visible]:ring-0`,children:h?h(ie):ie.name},ie.id));if(v){let ie=v(xe,re);return qe__namespace.default.isValidElement(ie)&&ie.type===reactAriaComponents.ListBoxSection?ie:jsxRuntime.jsx(reactAriaComponents.ListBoxSection,{children:ie},xe.name)}return jsxRuntime.jsxs(reactAriaComponents.ListBoxSection,{children:[jsxRuntime.jsx(reactAriaComponents.Header,{className:"px-3 py-1 text-sm font-bold text-text-secondary",children:xe.name}),re]},xe.name)}):xe=>jsxRuntime.jsx(pr,{id:xe.id,textValue:xe.name,size:u,className:`flex cursor-default items-center gap-2 px-3 ${Jg[u]} text-text-primary outline-none data-[focused]:bg-background-hover data-[selected]:bg-background-selected data-[selected]:font-medium data-[focus-visible]:ring-0`,children:h?h(xe):xe.name},xe.id)})})]})}),k&&jsxRuntime.jsx(vt,{isOpen:U,onClose:()=>Z(false),title:e??l??"Search",contentPadding:false,height:"80vh",children:jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsx("div",{className:"p-4 border-b border-border-default",children:jsxRuntime.jsxs(Ct,{children:[jsxRuntime.jsx("div",{className:"pointer-events-none absolute left-3 top-[45%] -translate-y-1/2 z-10 flex items-center",children:j?jsxRuntime.jsx(Wr,{size:16,color:"text-text-secondary"}):jsxRuntime.jsx(O,{name:"MagnifyingGlass",className:"h-4 w-4 text-text-secondary"})}),jsxRuntime.jsx("input",{ref:I,type:"text",value:M,onChange:ge=>ae(ge.target.value),placeholder:l,autoFocus:true,className:zt({isInvalid:false,isDisabled:false,isFocused:true,size:"md",className:"pl-10 pr-10"})}),M&&jsxRuntime.jsx(Ii,{onClick:()=>{B(""),a?.(null);},size:"md"})]})}),jsxRuntime.jsx("div",{className:"flex-1 overflow-auto",children:jsxRuntime.jsx(reactAriaComponents.ListBox,{"aria-label":e||l||"Suggestions",items:ce,selectedKeys:o?[o]:[],selectionMode:"single",onSelectionChange:ge=>{let xe=Array.from(ge)[0];xe&&(ee(xe),Z(false));},className:"bg-background-input outline-none",children:ge=>jsxRuntime.jsx(pr,{id:ge.id,textValue:ge.name,size:"md",className:"flex cursor-default items-center gap-2 px-4 py-3 text-text-primary outline-none data-[focused]:bg-background-hover data-[selected]:bg-background-selected data-[selected]:font-medium data-[focus-visible]:ring-0",children:h?h(ge):ge.name},ge.id)})})]})})]})}function Vo({src:e,alt:t,firstName:r,lastName:o,fullName:n,onClick:a,size:i="md",shape:s="circle",variant:l="user",className:c,status:d,bordered:u=false,piiEntity:p}){let[m,f]=qe.useState(false),g=qe.useCallback(()=>f(true),[]);qe.useEffect(()=>{f(false);},[e]);let x={xs:"h-6 w-6 text-xs",sm:"h-8 w-8 text-sm",md:"h-10 w-10 text-base",lg:"h-12 w-12 text-lg",xl:"h-16 w-16 text-xl"},b={xs:"h-1.5 w-1.5",sm:"h-2 w-2",md:"h-2.5 w-2.5",lg:"h-3 w-3",xl:"h-4 w-4"},h={xs:"bottom-0 right-0",sm:"bottom-0 right-0",md:"bottom-0 right-0",lg:"bottom-0.5 right-0.5",xl:"bottom-1 right-1"},y={online:"bg-feedback-success-background border-feedback-success-border",offline:"bg-text-secondary border-border-muted",away:"bg-feedback-warning-background border-feedback-warning-border",busy:"bg-feedback-error-background border-feedback-error-border"},v={user:"bg-feedback-info-background text-feedback-info-text",team:"bg-feedback-info-background text-feedback-info-text",organization:"bg-feedback-success-background text-feedback-success-text"},S=s==="circle"?"rounded-full":"rounded-md",w=tailwindMerge.twMerge("relative inline-flex items-center justify-center overflow-hidden transition-opacity outline-none",x[i],S,a&&"cursor-pointer hover:opacity-80",u&&"ring-2 ring-background-surface",c),R=(()=>{if(r||o){let T=r?.[0]||"",D=o?.[0]||"";return (T+D).toUpperCase()}if(n){let T=n.split(" "),D=T[0]?.[0]||"",M=T[T.length-1]?.[0]||"";return D===M?D.toUpperCase():(D+M).toUpperCase()}return ""})(),P=()=>{let T={xs:14,sm:16,md:20,lg:24,xl:32}[i];switch(l){case "team":return jsxRuntime.jsx(lucideReact.Users,{size:T});case "organization":return jsxRuntime.jsx(lucideReact.Building2,{size:T});default:return jsxRuntime.jsx(lucideReact.User,{size:T})}},E=T=>{if(p)return l==="organization"?T?"organization-logo":"initials":T?"avatar":"initials"},I=()=>e&&!m?jsxRuntime.jsx("img",{src:e,alt:t||n||"Avatar",className:"h-full w-full object-cover",onError:g,"data-pii-type":E(true),"data-pii-entity":p}):R?jsxRuntime.jsx("span",{className:"font-semibold","data-pii-type":E(false),"data-pii-entity":p,children:R}):P();return jsxRuntime.jsxs("div",{className:"relative inline-block",children:[jsxRuntime.jsx("div",{"data-avatar":true,className:tailwindMerge.twMerge(w,!e||m?v[l]:""),onClick:a,role:a?"button":void 0,tabIndex:a?0:void 0,children:I()}),d&&jsxRuntime.jsx("span",{className:tailwindMerge.twMerge("absolute border-2 border-background-surface",S,b[i],h[i],y[d]),"aria-label":`Status: ${d}`})]})}var XN={default:"bg-feedback-info-background text-feedback-info-text",success:"bg-feedback-success-background text-feedback-success-text",error:"bg-feedback-error-background text-feedback-error-text",warning:"bg-feedback-warning-background text-feedback-warning-text",info:"bg-feedback-info-background text-feedback-info-text",primary:"bg-action-primary/10 text-action-primary border border-action-primary/20",brand:"bg-action-primary/10 text-action-primary border border-action-primary/20",secondary:"bg-action-secondary text-[color:var(--color-action-secondary-text)] border border-border-muted",neutral:"bg-background-muted text-text-secondary",charging:"bg-state-charging text-state-charging-text",discharging:"bg-state-discharging text-state-discharging-text",heat:"bg-state-heat text-state-heat-text",cool:"bg-state-cool text-state-cool-text",eco:"bg-state-eco text-state-eco-text",auto:"bg-state-auto text-state-auto-text",on:"bg-state-on text-state-on-text",off:"bg-state-off text-state-off-text",idle:"bg-state-idle text-state-idle-text",circulate:"bg-state-circulate text-state-circulate-text",unknown:"bg-state-unknown text-state-unknown-text",connected:"bg-feedback-success-background text-feedback-success-text",disconnected:"bg-feedback-error-background text-feedback-error-text",importing:"bg-state-importing text-state-importing-text",exporting:"bg-state-exporting text-state-exporting-text"},jN={xs:"px-1.5 py-0.5 text-xs",sm:"px-2.5 py-1.5 text-xs",md:"px-3.5 py-2 text-sm",lg:"px-4 py-2.5 text-base"},qN={pill:"rounded-full",rounded:"rounded-lg",square:"rounded-sm"},QN={xs:"w-1 h-1",sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"};function ft({children:e,variant:t="default",size:r="sm",shape:o="square",dot:n=false,dotPosition:a="left",dotPulse:i=false,title:s,className:l}){let c=n&&jsxRuntime.jsx("span",{className:tailwindMerge.twMerge("rounded-full bg-current opacity-75",QN[r],i&&"animate-pulse"),"aria-hidden":"true"});return jsxRuntime.jsxs("span",{title:s,className:tailwindMerge.twMerge("inline-flex items-center gap-1.5 font-medium",jN[r],qN[o],XN[t],l),children:[n&&a==="left"&&c,e,n&&a==="right"&&c]})}var ut=({href:e,children:t,className:r="",external:o=false,title:n,variant:a="secondary",onClick:i,asButton:s=false,onPress:l,showArrow:c=false,alwaysUnderlined:d=false,LinkComponent:u,"data-pii-type":p,"data-pii-entity":m})=>{let f={...p&&{"data-pii-type":p},...m&&{"data-pii-entity":m}},g=o?{target:"_blank",rel:"noopener noreferrer"}:{},v=`${`${d?"underline decoration-1 underline-offset-4 decoration-current":"hover:underline hover:decoration-1 hover:underline-offset-4 hover:decoration-current"} cursor-pointer`} ${{primary:"text-action-primary hover:text-action-primary-hover visited:text-action-primary",secondary:"text-text-link-default hover:text-text-link-hover visited:text-text-link-default",muted:"text-text-secondary hover:text-text-secondary visited:text-text-secondary",unstyled:""}[a==="brand"?"primary":a==="default"?"secondary":a]} ${r}`,S=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t,c&&jsxRuntime.jsxs("span",{children:["\xA0","\u2192"]})]});return s?jsxRuntime.jsx("button",{type:"button",className:v,onClick:l,title:n,...f,children:S}):u&&e?jsxRuntime.jsx(u,{href:e,className:v,title:n,onClick:i,...g,...f,children:S}):jsxRuntime.jsx("a",{href:e||"#",className:v,...g,...f,title:n,onClick:i,children:S})};var ik={info:{subtle:{container:"bg-feedback-info-background border-l-4 border-l-feedback-info-border",iconColor:"text-feedback-info-border",titleColor:"text-text-primary",bodyColor:"text-text-primary"},bold:{container:"bg-feedback-info-border border-feedback-info-border",iconColor:"text-text-inverse",titleColor:"text-text-inverse",bodyColor:"text-text-inverse/90"},icon:lucideReact.Info},success:{subtle:{container:"bg-feedback-success-background border-l-4 border-l-feedback-success-border",iconColor:"text-feedback-success-border",titleColor:"text-text-primary",bodyColor:"text-text-primary"},bold:{container:"bg-feedback-success-border border-feedback-success-border",iconColor:"text-text-inverse",titleColor:"text-text-inverse",bodyColor:"text-text-inverse/90"},icon:lucideReact.CheckCircle},warning:{subtle:{container:"bg-feedback-warning-background border-l-4 border-l-feedback-warning-border",iconColor:"text-feedback-warning-border",titleColor:"text-text-primary",bodyColor:"text-text-primary"},bold:{container:"bg-feedback-warning-border border-feedback-warning-border",iconColor:"text-text-inverse",titleColor:"text-text-inverse",bodyColor:"text-text-inverse/90"},icon:lucideReact.AlertCircle},error:{subtle:{container:"bg-feedback-error-background border-l-4 border-l-feedback-error-border",iconColor:"text-feedback-error-border",titleColor:"text-text-primary",bodyColor:"text-text-primary"},bold:{container:"bg-feedback-error-border border-feedback-error-border",iconColor:"text-text-inverse",titleColor:"text-text-inverse",bodyColor:"text-text-inverse/90"},icon:lucideReact.XCircle},discovery:{subtle:{container:"bg-background-muted border-l-4 border-l-action-brand",iconColor:"text-action-brand",titleColor:"text-text-primary",bodyColor:"text-text-primary"},bold:{container:"bg-action-brand border-action-brand",iconColor:"text-text-inverse",titleColor:"text-text-inverse",bodyColor:"text-text-inverse/90"},icon:lucideReact.Lightbulb}};function pl({variant:e="info",appearance:t="subtle",title:r,children:o,dismissible:n=false,onDismiss:a,primaryAction:i,secondaryAction:s,icon:l,hideIcon:c=false,className:d,testId:u}){let p=ik[e],m=p[t],f=p.icon,g=!!(i||s),x=!!(r||o);return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex gap-3 rounded-sm border p-4",m.container,d),role:"region","aria-live":"polite","data-testid":u,children:[!c&&jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex-shrink-0",m.iconColor),"aria-hidden":"true",children:l||jsxRuntime.jsx(f,{className:"h-5 w-5"})}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-3",children:[x&&jsxRuntime.jsxs("div",{className:"flex-1",children:[r&&jsxRuntime.jsx("div",{className:ir(Tt("headingSm"),m.titleColor),children:r}),o&&jsxRuntime.jsx("div",{className:ir(Tt("bodySm"),r?"mt-1":"",m.bodyColor),children:o})]}),g&&jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[i&&(i.asLink?jsxRuntime.jsx(ut,{asButton:true,onPress:i.onPress,variant:t==="bold"?"unstyled":"default",className:t==="bold"?"text-text-inverse hover:text-text-inverse/80":"",children:i.label}):jsxRuntime.jsx($,{size:"sm",variant:"primary",onPress:i.onPress,className:t==="bold"?"bg-background-surface text-text-primary hover:bg-background-surface/90":"",children:i.label})),s&&(s.asLink?jsxRuntime.jsx(ut,{asButton:true,onPress:s.onPress,variant:t==="bold"?"unstyled":"default",className:t==="bold"?"text-text-inverse hover:text-text-inverse/80":"",children:s.label}):jsxRuntime.jsx($,{size:"sm",variant:"secondary",onPress:s.onPress,className:t==="bold"?"border-text-inverse/30 text-text-inverse hover:bg-text-inverse/10":"",children:s.label}))]})]}),n&&jsxRuntime.jsx("button",{type:"button",onClick:a,className:tailwindMerge.twMerge("flex h-8 w-8 flex-shrink-0 items-center justify-center self-start rounded-md transition-colors hover:bg-background-modal/10",m.iconColor,rt()),"aria-label":"Dismiss banner",children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"})})]})}function Qg({isOpen:e=true,position:t="sticky",className:r,...o}){let n=t==="fixed"?"fixed top-0 left-0 right-0 z-50":"sticky top-0 z-50",a=r?`${r} !rounded-none`:"!rounded-none";return jsxRuntime.jsx(framerMotion.AnimatePresence,{children:e&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeInOut"},className:n,children:jsxRuntime.jsx(pl,{...o,className:a})})})}function Wa(){let[e,t]=qe.useState({width:0,height:0}),r=qe.useRef(null),o=qe.useRef(void 0),n=qe.useCallback(a=>{if(r.current&&(r.current.disconnect(),r.current=null),o.current&&(cancelAnimationFrame(o.current),o.current=void 0),!a){t({width:0,height:0});return}let i=a.getBoundingClientRect();t({width:i.width,height:i.height}),r.current=new ResizeObserver(s=>{o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(l=>{for(let c of s){let{width:d,height:u}=c.contentRect;t(p=>p.width!==d||p.height!==u?{width:d,height:u}:p);}});}),r.current.observe(a);},[]);return qe.useEffect(()=>()=>{o.current&&cancelAnimationFrame(o.current),r.current&&r.current.disconnect();},[]),{ref:n,width:e.width,height:e.height}}function on({value:e,children:t,className:r,size:o="sm",iconPosition:n="right"}){let[a,i]=qe.useState(false),c=jsxRuntime.jsx($,{variant:"icon",size:o,onPress:()=>{let u=e||(typeof t=="string"?t:"");navigator.clipboard.writeText(u),i(true),setTimeout(()=>{i(false);},2e3);},className:"!px-2 relative",style:{top:"0.5px"},children:jsxRuntime.jsx(O,{name:"Copy",size:o==="sm"?14:16})}),d=a?jsxRuntime.jsx(dr,{content:"Copied!",children:c}):c;return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("inline-flex items-center gap-0.5",r),children:[n==="left"&&d,t,n==="right"&&d]})}function ml(e){let{children:t,maxWidth:r=600,className:o,...n}=e,{ref:a,width:i}=Wa(),[s,l]=qe__namespace.default.useState(false),[c,d]=qe__namespace.default.useState(false),u=qe__namespace.default.useRef(false),p=qe__namespace.default.useMemo(()=>t&&!e.items&&typeof t!="function"?qe__namespace.default.Children.toArray(t):null,[t,e.items]);if(qe__namespace.default.useEffect(()=>{p&&p.length>=4&&i>0&&!u.current?(u.current=true,l(i>r),d(true)):(!p||p&&p.length<4)&&d(true);let m=setTimeout(()=>{c||d(true);},100);return ()=>clearTimeout(m)},[i,r,p,c]),p&&s&&p.length>=4){let m=p[0],f=p.slice(1,-2),g=p.slice(-2),x=f.map(b=>{if(qe__namespace.default.isValidElement(b)){let h=b.props;if(typeof h.children=="string")return {label:h.children,href:h.href}}return {label:"..."}});return jsxRuntime.jsxs(reactAriaComponents.Breadcrumbs,{...n,ref:a,className:tailwindMerge.twMerge("flex gap-2",c?"opacity-100":"opacity-0",o),children:[m,jsxRuntime.jsx(gk,{items:x}),g]})}return jsxRuntime.jsx(reactAriaComponents.Breadcrumbs,{...n,ref:a,className:tailwindMerge.twMerge("flex gap-2",c?"opacity-100":"opacity-0",o),children:t})}function gk({items:e}){let t=e.map((r,o)=>({id:`breadcrumb-${o}`,name:r.label,href:r.href}));return jsxRuntime.jsx(reactAriaComponents.Breadcrumb,{className:"flex items-center gap-2",children:jsxRuntime.jsxs("span",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(Oa,{items:t,align:"left",size:"sm",children:jsxRuntime.jsx($,{variant:"icon",size:"sm",icon:"DotsThree","aria-label":"Show hidden breadcrumbs",className:"px-0.5"})}),jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4 text-text-secondary"})]})})}function fl(e){let{className:t,children:r,href:o,copyable:n,copyValue:a,...i}=e;return jsxRuntime.jsx(reactAriaComponents.Breadcrumb,{className:Me(t,"flex items-center gap-2"),...i,children:s=>{let l=s.isCurrent,c=typeof r=="function"?r(s):r;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:l?n?jsxRuntime.jsx(on,{value:a||(typeof c=="string"?c:void 0),size:"sm",iconPosition:"right",children:jsxRuntime.jsx("span",{className:"max-w-[200px] truncate font-semibold text-text-primary sm:max-w-none",children:c})}):jsxRuntime.jsx("span",{className:"max-w-[200px] truncate font-semibold text-text-primary sm:max-w-none",children:c}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ut,{variant:"muted",href:o,className:"max-w-[150px] truncate sm:max-w-[300px] md:max-w-none",children:c}),jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4 shrink-0 text-text-secondary"})]})})}})}function kk({isSelected:e,isDisabled:t}){let r=[rt,"w-9 h-9 text-sm cursor-default rounded-sm flex items-center justify-center forced-color-adjust-none font-semibold"];return t?r.push("text-text-disabled forced-colors:text-[GrayText]"):e?r.push("bg-action-default text-text-inverse invalid:bg-feedback-error-border forced-colors:bg-[Highlight] forced-colors:invalid:bg-[Mark] forced-colors:text-[HighlightText]"):r.push("text-text-primary hover:bg-background-hover pressed:bg-background-selected"),r.join(" ")}function Ua({errorMessage:e,...t}){return jsxRuntime.jsxs(reactAriaComponents.Calendar,{...t,children:[jsxRuntime.jsx(gl,{}),jsxRuntime.jsxs(reactAriaComponents.CalendarGrid,{className:"border-separate [border-spacing:0] [&_td]:p-0 [&_td]:!border-0",children:[jsxRuntime.jsx(bl,{}),jsxRuntime.jsx(reactAriaComponents.CalendarGridBody,{children:r=>jsxRuntime.jsx(reactAriaComponents.CalendarCell,{date:r,className:({isSelected:o,isDisabled:n})=>`${kk({isSelected:o,isDisabled:n})} border-0`})})]}),e&&jsxRuntime.jsx(reactAriaComponents.Text,{slot:"errorMessage",className:"text-sm text-feedback-error-text",children:e})]})}function gl(){let{direction:e}=reactAriaComponents.useLocale(),t=18;return jsxRuntime.jsxs("header",{className:"flex w-full items-center gap-1 px-1 pb-4",children:[jsxRuntime.jsx($,{variant:"icon",slot:"previous",className:"pl-0",children:e==="rtl"?jsxRuntime.jsx(O,{name:"CaretRight","aria-hidden":true,size:t}):jsxRuntime.jsx(O,{name:"CaretLeft","aria-hidden":true,size:t})}),jsxRuntime.jsx(reactAriaComponents.Heading,{className:"text-md mx-2 flex-1 text-center font-semibold text-text-primary"}),jsxRuntime.jsx($,{variant:"icon",slot:"next",className:"pr-0",children:e==="rtl"?jsxRuntime.jsx(O,{name:"CaretLeft","aria-hidden":true,size:t}):jsxRuntime.jsx(O,{name:"CaretRight","aria-hidden":true,size:t})})]})}function bl(){return jsxRuntime.jsx(reactAriaComponents.CalendarGridHeader,{children:e=>jsxRuntime.jsx(reactAriaComponents.CalendarHeaderCell,{className:"text-xs font-semibold text-text-secondary",children:e})})}var ob=qe__namespace.createContext(null);function nn(){let e=qe__namespace.useContext(ob);if(!e)throw new Error("Carousel components must be used within a CarouselRoot");return e}function nb({page:e,defaultPage:t=0,onPageChange:r,orientation:o="horizontal",loop:n=false,autoplay:a=false,autoplayDelay:i=4e3,allowMouseDrag:s=false,spacing:l="1rem",slidesPerView:c=1,slidesPerMove:d=1,className:u,children:p,...m}){let f=e!==void 0,[g,x]=qe__namespace.useState(t),b=f?e:g,h=qe__namespace.useRef(null),[y,v]=qe__namespace.useState(0),[S,w]=qe__namespace.useState(typeof a=="boolean"?a:!!a),[N,R]=qe__namespace.useState(false),P=qe__namespace.useRef(null),E=qe__namespace.useRef(null),I=typeof a=="object"&&a!==null&&a.delay?a.delay:i;qe__namespace.useEffect(()=>{if(h.current){let C=Math.max(1,Math.floor(Number(c)||1)),L=h.current.children;if(L.length===0){v(0);return}let F=Math.ceil(L.length/C);v(F);}},[p,c]);let T=qe__namespace.useRef(-1);qe__namespace.useEffect(()=>{if(b!==T.current&&h.current){let C=Array.from(h.current.children);if(C.length===0)return;let L=b*c,F=Math.min(L,C.length-1),j=C[F];j&&typeof j.scrollIntoView=="function"&&(j.scrollIntoView({behavior:"smooth",block:o==="vertical"?"start":"nearest",inline:o==="horizontal"?"start":"nearest"}),T.current=b);}},[b,c,o]);let D=qe__namespace.useCallback(C=>{let L=C;n?L<0?L=y-1:L>=y&&(L=0):L=Math.max(0,Math.min(C,y-1)),f||x(L),r?.(L);},[f,n,r,y]),M=qe__namespace.useCallback(()=>{D(b+d);},[b,D,d]),B=qe__namespace.useCallback(()=>{D(b-d);},[b,D,d]),z=qe__namespace.useRef(M);qe__namespace.useEffect(()=>{z.current=M;},[M]);let V=y>0&&(n||b<y-1),U=y>0&&(n||b>0),Z=qe__namespace.useCallback(()=>{w(C=>!C);},[]);qe__namespace.useEffect(()=>{if(S&&y>1)return P.current=setInterval(()=>{z.current();},I),()=>{P.current&&(clearInterval(P.current),P.current=null);}},[S,y,I]);let G=qe__namespace.useCallback(()=>{P.current&&(clearInterval(P.current),P.current=null);},[]),J=qe__namespace.useCallback(()=>{S&&y>1&&(P.current=setInterval(()=>{z.current();},I));},[S,y,I]),W=qe__namespace.useCallback(C=>{if(!s)return;R(true);let L="touches"in C&&C.touches&&C.touches.length>0?C.touches[0].clientX:"clientX"in C?C.clientX:0,F="touches"in C&&C.touches&&C.touches.length>0?C.touches[0].clientY:"clientY"in C?C.clientY:0;E.current={x:L,y:F};},[s]),A=qe__namespace.useCallback(C=>{if(!N||!E.current)return;let L="touches"in C&&C.touches&&C.touches.length>0?C.touches[0].clientX:"clientX"in C?C.clientX:0,F="touches"in C&&C.touches&&C.touches.length>0?C.touches[0].clientY:"clientY"in C?C.clientY:0,j=L-E.current.x,ne=F-E.current.y,ce=50;o==="horizontal"&&Math.abs(j)>ce?(j>0?B():M(),R(false),E.current=null):o==="vertical"&&Math.abs(ne)>ce&&(ne>0?B():M(),R(false),E.current=null);},[N,o,M,B]),Y=qe__namespace.useCallback(()=>{R(false),E.current=null;},[]),k={currentPage:b,totalPages:y,orientation:o,loop:n,spacing:l,slidesPerView:c,goToPage:D,goToNext:M,goToPrev:B,canGoNext:V,canGoPrev:U,isAutoplayActive:S,toggleAutoplay:Z,itemsRef:h,isDragging:N,allowMouseDrag:s,handleDragStart:W,handleDragMove:A,handleDragEnd:Y};return jsxRuntime.jsx(ob.Provider,{value:k,children:jsxRuntime.jsx("div",{...m,className:tailwindMerge.twMerge("relative w-full",o==="vertical"?"h-full":"",u),onMouseEnter:G,onMouseLeave:J,children:p})})}function ab({className:e,children:t,...r}){let{itemsRef:o,orientation:n,spacing:a,isDragging:i,allowMouseDrag:s,handleDragStart:l,handleDragMove:c,handleDragEnd:d}=nn();return jsxRuntime.jsx("div",{ref:o,...r,className:tailwindMerge.twMerge("flex overflow-x-auto overflow-y-hidden snap-x snap-mandatory scrollbar-hide scroll-smooth",n==="vertical"&&"flex-col overflow-y-auto overflow-x-hidden snap-y",s&&i&&"cursor-grabbing select-none",s&&!i&&"cursor-grab",e),style:{gap:a,"--carousel-spacing":a,...r.style},onMouseDown:l,onMouseMove:c,onMouseUp:d,onMouseLeave:d,onTouchStart:l,onTouchMove:c,onTouchEnd:d,children:t})}function ib({index:e,className:t,children:r,...o}){let{orientation:n,slidesPerView:a}=nn();return jsxRuntime.jsx("div",{...o,"data-index":e,className:tailwindMerge.twMerge("shrink-0 snap-start",n==="horizontal"?"h-full":"w-full",t),style:{width:n==="horizontal"?`calc((100% - (${a-1} * var(--carousel-spacing, 1rem))) / ${a})`:void 0,height:n==="vertical"?`calc((100% - (${a-1} * var(--carousel-spacing, 1rem))) / ${a})`:void 0,...o.style},children:r})}function sb({className:e,children:t,...r}){return jsxRuntime.jsx("div",{...r,className:tailwindMerge.twMerge("flex items-center justify-center gap-4 mt-4",e),children:t})}function lb({className:e,children:t,...r}){let{goToPrev:o,canGoPrev:n}=nn();return jsxRuntime.jsx("button",{type:"button",...r,onClick:a=>{o(),r.onClick?.(a);},disabled:!n||r.disabled,"aria-label":"Previous slide",className:tailwindMerge.twMerge("inline-flex items-center justify-center rounded-md","h-10 w-10","bg-background-input border border-border-input","text-text-primary hover:bg-background-muted","transition-colors duration-200","disabled:opacity-40 disabled:cursor-not-allowed","focus-visible:outline focus-visible:outline-2 focus-visible:outline-action-default",e),children:t||jsxRuntime.jsx(O,{name:"CaretLeft",size:"sm"})})}function cb({className:e,children:t,...r}){let{goToNext:o,canGoNext:n}=nn();return jsxRuntime.jsx("button",{type:"button",...r,onClick:a=>{o(),r.onClick?.(a);},disabled:!n||r.disabled,"aria-label":"Next slide",className:tailwindMerge.twMerge("inline-flex items-center justify-center rounded-md","h-10 w-10","bg-background-input border border-border-input","text-text-primary hover:bg-background-muted","transition-colors duration-200","disabled:opacity-40 disabled:cursor-not-allowed","focus-visible:outline focus-visible:outline-2 focus-visible:outline-action-default",e),children:t||jsxRuntime.jsx(O,{name:"CaretRight",size:"sm"})})}function Uu({index:e,className:t,children:r,...o}){let{currentPage:n,goToPage:a}=nn(),i=n===e;return jsxRuntime.jsx("button",{type:"button",...o,onClick:s=>{a(e),o.onClick?.(s);},"aria-label":`Go to slide ${e+1}`,"aria-current":i,className:tailwindMerge.twMerge("h-2 rounded-full transition-all duration-200",i?"w-6 bg-action-brand":"w-2 bg-border-muted hover:bg-border-input","focus-visible:outline focus-visible:outline-2 focus-visible:outline-action-default",t),children:r})}function db({className:e,...t}){let{totalPages:r}=nn();return jsxRuntime.jsx("div",{...t,className:tailwindMerge.twMerge("flex items-center gap-2",e),role:"group","aria-label":"Carousel indicators",children:Array.from({length:r},(o,n)=>jsxRuntime.jsx(Uu,{index:n},n))})}function ub({className:e,children:t,...r}){let{isAutoplayActive:o,toggleAutoplay:n}=nn();return jsxRuntime.jsx("button",{type:"button",...r,onClick:a=>{n(),r.onClick?.(a);},"aria-label":o?"Pause autoplay":"Start autoplay",className:tailwindMerge.twMerge("inline-flex items-center justify-center rounded-md","h-10 w-10","bg-background-input border border-border-input","text-text-primary hover:bg-background-muted","transition-colors duration-200","focus-visible:outline focus-visible:outline-2 focus-visible:outline-action-default",e),children:t||jsxRuntime.jsx(O,{name:o?"Pause":"Play",size:"sm"})})}function pb({className:e,...t}){let{currentPage:r,totalPages:o}=nn();return jsxRuntime.jsxs("div",{...t,className:tailwindMerge.twMerge("text-sm text-text-secondary tabular-nums",e),"aria-live":"polite","aria-atomic":"true",children:[r+1," / ",o]})}var Dk="focus:ring-action-primary",Ak="bg-action-primary border-action-primary text-[color:var(--color-action-primary-text)] hover:bg-action-primary-hover hover:border-action-primary-hover";function Ku(e){return jsxRuntime.jsxs(reactAriaComponents.CheckboxGroup,{...e,className:Me(e.className,"flex flex-col gap-2"),children:[jsxRuntime.jsx(Ke,{children:e.label}),e.children,e.description&&jsxRuntime.jsx(Ne,{children:e.description}),jsxRuntime.jsx(he,{children:typeof e.errorMessage=="function"?void 0:e.errorMessage})]})}function Ik({isDisabled:e}){return `relative flex gap-2 items-center group text-sm transition ${e?"text-text-disabled":"text-text-secondary"}`}function Fk({isSelected:e,isInvalid:t,isDisabled:r,isIndeterminate:o}){let n="w-5 h-5 flex-shrink-0 rounded-[var(--control-border-radius)] flex items-center justify-center border-2 transition ring-offset-2 focus:ring-2",a=Dk,i="";return r?i="border-border-muted bg-background-muted":t?i="border-feedback-error-border bg-feedback-error-background":e||o?i=Ak:i="bg-background-input border-border-input hover:border-border-focus",`${n} ${a} ${i}`}var mb="w-4 h-4 text-current group-disabled:text-text-disabled";function Yu({className:e,...t}){return jsxRuntime.jsx("div",{"aria-hidden":"true",className:`${Fk(t)} ${e||""}`,children:t.isIndeterminate?jsxRuntime.jsx(lucideReact.Minus,{"aria-hidden":true,className:mb}):t.isSelected?jsxRuntime.jsx(lucideReact.Check,{"aria-hidden":true,className:mb}):null})}function eo(e){let{children:t,variant:r,...o}=e;return jsxRuntime.jsx(reactAriaComponents.Checkbox,{...o,className:reactAriaComponents.composeRenderProps(e.className,(n,a)=>`${Ik(a)} ${n||""}`),children:n=>{let{isSelected:a,isIndeterminate:i,isDisabled:s,isInvalid:l}=n;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Yu,{isSelected:a,isIndeterminate:i,isDisabled:s,isInvalid:l}),typeof t=="function"?t(n):t]})}})}var Ok={primary:"bg-action-primary/10 text-action-primary border border-action-primary/20 hover:bg-action-primary/15",secondary:"bg-action-secondary text-[color:var(--color-action-secondary-text)] border border-border-muted hover:bg-action-secondary-hover",info:"bg-feedback-info-background text-feedback-info-text border border-feedback-info-border hover:bg-feedback-info-background/80"};function gb(e){return !e||e==="default"?"secondary":e==="brand"?"primary":e}var zk={xs:"px-1.5 py-[2px] gap-0.5",sm:"px-2 py-1 gap-1",md:"px-3 py-1.5 gap-1.5",lg:"px-3 py-2 gap-2",xl:"px-4 py-2.5 gap-2"},Hk="opacity-75 cursor-not-allowed pointer-events-none";function bb(e){let{variant:t,size:r,isDisabled:o,isClickable:n,className:a}=e,i=r==="xs"?"text-xs":We[r].text;return tailwindMerge.twMerge("inline-flex items-center justify-center rounded-full font-medium transition-colors","whitespace-nowrap select-none",zk[r],i,Ok[t],n&&!o&&"cursor-pointer",o&&Hk,a)}function Yr({children:e,onRemove:t,removeLabel:r="Remove",size:o="md",variant:n="secondary",isRemovable:a=true,isDisabled:i=false,className:s,onClick:l}){let c=!!l&&!i,d=a&&t&&!i,u=x=>{x.stopPropagation(),x.preventDefault(),t&&!i&&t();},p=()=>{l&&!i&&l();},m=o==="xs"?10:o==="sm"?12:o==="md"?14:16,g=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"truncate",children:e}),d?c?jsxRuntime.jsx("span",{onClick:u,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),u(x));},role:"button",tabIndex:0,className:"flex-shrink-0 rounded-full p-0.5 hover:bg-text-primary/10 transition-colors cursor-pointer","aria-label":r,title:r,children:jsxRuntime.jsx(O,{name:"X",size:m,className:"text-current opacity-70 hover:opacity-100"})}):jsxRuntime.jsx("button",{type:"button",onClick:u,className:"flex-shrink-0 rounded-full p-0.5 hover:bg-text-primary/10 transition-colors cursor-pointer","aria-label":r,title:r,tabIndex:-1,children:jsxRuntime.jsx(O,{name:"X",size:m,className:"text-current opacity-70 hover:opacity-100"})}):null]});return c?jsxRuntime.jsx("button",{type:"button",onClick:p,className:bb({variant:gb(n),size:o,isDisabled:i,isClickable:c,className:s}),disabled:i,children:g}):jsxRuntime.jsx("span",{className:bb({variant:gb(n),size:o,isDisabled:i,isClickable:c,className:s}),children:g})}function yb({label:e,description:t,errorMessage:r,size:o="md",tooltip:n,isRequired:a=false,isDisabled:i=false,isInvalid:s=false,validationResult:l,placeholder:c="Add items...",selectedItems:d=[],onItemsChange:u,staticItems:p,fetchSuggestions:m,chipVariant:f="secondary",showErrors:g=true,className:x}){let[b,h]=qe.useState(""),[y,v]=qe.useState([]),[S,w]=qe.useState(false),[N,R]=qe.useState(false),[P,E]=qe.useState(-1),I=tn(b,300),T=qe.useRef(null),D=qe.useRef(null),{isFocused:M,handleFocus:B,handleBlur:z}=ur(),V=qe.useId(),U=qe.useCallback(k=>{if(!u||!k.trim())return;let C=k.trim();if(d.includes(C)){h(""),R(false),v([]),E(-1);return}u([...d,C]),h(""),R(false),v([]),E(-1),T.current?.focus();},[d,u]),Z=qe.useCallback(k=>{u&&u(d.filter(C=>C!==k));},[d,u]);qe.useEffect(()=>{if(!m)return;let k=true;return (async()=>{let L=I.trim();if(!L){k&&(w(false),v([]),R(false));return}w(true);try{let F=await m(L);if(!k)return;v(F),R(!0);}catch(F){if(!k)return;console.error("Error fetching suggestions:",F),v([]),R(false);}finally{k&&w(false);}})(),()=>{k=false;}},[I,m]),qe.useEffect(()=>{if(m||!p)return;if(!I.trim()){v([]),R(false);return}let k=p.filter(C=>C.name.toLowerCase().includes(I.toLowerCase())).map(C=>C.id);v(k),R(k.length>0||I.trim().length>0);},[I,p,m]);let G=qe.useMemo(()=>{let k=y.filter(C=>!d.includes(C));return b.trim()&&!k.includes(b.trim())&&!d.includes(b.trim())?[...k,`Create tag: "${b.trim()}"`]:k},[y,b,d]),J=qe.useCallback(k=>{h(k.target.value),E(-1),k.target.value&&R(true);},[]),W=qe.useCallback(k=>{i||(k.startsWith("Create tag:")?U(b):U(k));},[U,b,i]),A=qe.useCallback(k=>{if(!i)switch(k.key){case "Enter":case ",":if(k.preventDefault(),P>=0&&P<G.length){let C=G[P];C.startsWith("Create tag:")?U(b):U(C);}else b.trim()&&U(b.trim());break;case "Backspace":!b&&d.length>0&&(k.preventDefault(),Z(d[d.length-1]));break;case "ArrowDown":k.preventDefault(),N&&E(C=>C<G.length-1?C+1:C);break;case "ArrowUp":k.preventDefault(),N&&E(C=>C>0?C-1:-1);break;case "Escape":R(false),E(-1);break}},[i,b,d,G,P,N,U,Z]);qe.useEffect(()=>{let k=C=>{D.current&&C.target instanceof Node&&!D.current.contains(C.target)&&R(false);};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[]);let Y=()=>tailwindMerge.twMerge("flex items-center gap-1.5 rounded-md overflow-x-auto overflow-y-hidden","[&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]",rn({isInvalid:s,isDisabled:i,isFocused:M}),"bg-background-input",o==="sm"&&"px-2 py-1 h-[32px]",o==="md"&&"px-2.5 py-1.5 h-[40px]",o==="lg"&&"px-3 py-2 h-[44px]",o==="xl"&&"px-3.5 py-2.5 h-[48px]",i&&"opacity-50 cursor-not-allowed bg-background-muted");return jsxRuntime.jsxs("div",{ref:D,className:tailwindMerge.twMerge("relative flex flex-col gap-1",x),children:[e&&jsxRuntime.jsx(Ke,{size:o,tooltip:n,isRequired:a,children:e}),jsxRuntime.jsx(Ct,{children:jsxRuntime.jsxs("div",{className:Y(),onClick:()=>!i&&T.current?.focus(),children:[d.map(k=>jsxRuntime.jsx(Yr,{variant:f,size:"xs",onRemove:()=>Z(k),isDisabled:i,className:"shrink-0 max-h-full",children:k},k)),jsxRuntime.jsx("input",{ref:T,type:"text",role:"combobox","aria-expanded":N,"aria-haspopup":"listbox","aria-controls":V,"aria-autocomplete":"list",value:b,onChange:J,onKeyDown:A,onFocus:k=>B(k),onBlur:k=>z(k),placeholder:d.length===0?c:"",disabled:i,className:"flex-1 min-w-[120px] h-full !border-0 !outline-none !ring-0 bg-transparent text-text-primary text-sm placeholder:text-text-disabled disabled:cursor-not-allowed focus:!ring-0 focus:!outline-none focus:!border-0 focus-visible:!ring-0 focus-visible:!outline-none focus-visible:!border-0",style:{boxShadow:"none",WebkitAppearance:"none",appearance:"none",border:"none",outline:"none"}})]})}),N&&(b||G.length>0)&&jsxRuntime.jsx("div",{id:V,role:"listbox",className:tailwindMerge.twMerge("absolute z-50 mt-1 rounded-lg border border-border-default","max-h-60 overflow-auto bg-background-surface shadow-lg","left-0 right-0 top-full"),children:S?jsxRuntime.jsx("div",{className:"px-3 py-2 text-sm text-text-secondary",children:"Loading..."}):G.length>0?G.map((k,C)=>jsxRuntime.jsx("div",{role:"option","aria-selected":C===P,className:tailwindMerge.twMerge("cursor-pointer px-3 py-2 text-sm transition-colors","hover:bg-background-hover",C===P&&"bg-background-selected",k.startsWith("Create tag:")&&"italic text-text-secondary"),onClick:()=>W(k),children:k},k)):b&&jsxRuntime.jsx("div",{className:"px-3 py-2 text-sm text-text-secondary",children:"No suggestions found"})}),t&&jsxRuntime.jsx(Ne,{size:o,className:"mt-1",children:t}),g&&typeof r=="string"&&jsxRuntime.jsx(he,{size:o,className:"text-feedback-error-text mt-1",children:r}),g&&typeof r=="function"&&l&&jsxRuntime.jsx(he,{size:o,className:"text-feedback-error-text mt-1",children:r(l)})]})}var Qk={json:()=>import('ace-builds/src-noconflict/mode-json'),javascript:()=>import('ace-builds/src-noconflict/mode-javascript'),typescript:()=>import('ace-builds/src-noconflict/mode-typescript'),html:()=>import('ace-builds/src-noconflict/mode-html'),css:()=>import('ace-builds/src-noconflict/mode-css'),markdown:()=>import('ace-builds/src-noconflict/mode-markdown'),yaml:()=>import('ace-builds/src-noconflict/mode-yaml'),xml:()=>import('ace-builds/src-noconflict/mode-xml'),python:()=>import('ace-builds/src-noconflict/mode-python'),sql:()=>import('ace-builds/src-noconflict/mode-sql')},Zk={github:()=>import('ace-builds/src-noconflict/theme-github'),github_dark:()=>import('ace-builds/src-noconflict/theme-github_dark')},_k={"ext-language-tools":()=>import('ace-builds/src-noconflict/ext-language_tools')},Oi=new Set;async function Xu(e,t){Oi.has(e)||(await t(),Oi.add(e));}async function $k(e,t,r){await Promise.all([Xu(`language:${e}`,Qk[e]),Xu(`theme:${t}`,Zk[t]),r?Xu("extension:language-tools",_k["ext-language-tools"]):void 0]);}function Cb(e,t,r){let o=Oi.has(`language:${e}`)&&Oi.has(`theme:${t}`);return r?o&&Oi.has("extension:language-tools"):o}function Sb({value:e,readOnly:t=false,onChange:r,language:o="json",theme:n="github_dark",height:a,width:i="100%",className:s,lineHeight:l=19,minLines:c=3,maxLines:d=50,showLineNumbers:u=true,showGutter:p=true,fontSize:m=14,wrapEnabled:f=false}){let g=qe.useRef(null),[x,b]=qe.useState(()=>Cb(o,n,!t)),h=qe.useMemo(()=>{if(a)return a;let y=(e.match(/\n/g)||[]).length+1;return `${Math.max(c,Math.min(y,d))*l+10}px`},[e,a,l,c,d]);return qe.useEffect(()=>{let y=false,v=!t;return Cb(o,n,v)?(b(true),()=>{y=true;}):(b(false),$k(o,n,v).then(()=>{y||b(true);}).catch(S=>{y||b(true),console.error("Failed to load Ace editor resources",S);}),()=>{y=true;})},[o,t,n]),qe.useEffect(()=>{x&&g.current?.editor&&g.current.editor.resize();},[h,x]),jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("overflow-hidden rounded-md border border-border-input",s),style:{width:i,height:h},children:x?jsxRuntime.jsx(jk__default.default,{ref:g,mode:o,theme:n,value:e,onChange:r,readOnly:t,width:"100%",height:"100%",fontSize:m,showPrintMargin:false,showGutter:p,highlightActiveLine:!t,setOptions:{useWorker:true,showLineNumbers:u,tabSize:2,enableBasicAutocompletion:!t,enableLiveAutocompletion:!t,enableSnippets:!t,showFoldWidgets:true,wrap:f},editorProps:{$blockScrolling:true}}):jsxRuntime.jsx("div",{className:"flex h-full w-full items-center justify-center bg-surface-muted text-foreground-muted",children:"Loading editor\u2026"})})}var Nb=qe__namespace.createContext({variant:"contained",density:"comfortable",showDividers:true}),kb=qe__namespace.createContext(null),nT={contained:"rounded-lg border border-border-default bg-background-surface overflow-hidden",bordered:"rounded-lg border border-border-default bg-background-surface",plain:"bg-transparent"},wb={true:"divide-y divide-border-default",false:"gap-3"},aT={comfortable:"px-5 py-3",compact:"px-4 py-2.5"},iT={comfortable:"px-5 pt-0",compact:"px-4 pt-0"},sT={comfortable:"h-4 w-4",compact:"h-3.5 w-3.5"};function Zu(){return qe__namespace.useContext(Nb)}function lT(e){let t=qe__namespace.useContext(kb);if(!t)throw new Error(`${e} must be used within a <CollapseItem>`);return t}function cT({variant:e,showDividers:t,className:r}){let o="group/collapse-item w-full transition-colors",n={contained:"bg-background-surface",bordered:"bg-background-surface",plain:"bg-transparent"},a=t?"":"rounded-lg border border-border-default bg-background-surface overflow-hidden";return tailwindMerge.twMerge(o,n[e],a,r)}function dT({isDisabled:e,isPressed:t,density:r,variant:o,showDividers:n,className:a}){let i="group/collapse-header flex w-full items-start gap-4 text-left transition-colors duration-150",s=e?"cursor-not-allowed text-text-disabled":"cursor-pointer text-text-primary",l=t&&!e?"bg-background-hover":"",c=aT[r];return tailwindMerge.twMerge(i,rt(),c,s,l,o==="plain"&&n?"px-0":"",a)}function uT({density:e,showDividers:t,className:r}){let o="text-text-primary",n=iT[e];return tailwindMerge.twMerge(o,n,t?"":"rounded-b-lg",r)}function Ka({variant:e="contained",density:t="comfortable",showDividers:r=true,className:o,...n}){let a=qe__namespace.useMemo(()=>({variant:e,density:t,showDividers:r}),[e,t,r]),i=tailwindMerge.twMerge("flex w-full flex-col",nT[e],r?wb.true:wb.false,e==="plain"&&r?"border-y border-border-default/60":"");return jsxRuntime.jsx(Nb.Provider,{value:a,children:jsxRuntime.jsx(reactAriaComponents.DisclosureGroup,{...n,className:Me(o,i)})})}function ln({className:e,children:t,...r}){let{variant:o,showDividers:n}=Zu();return jsxRuntime.jsx(reactAriaComponents.Disclosure,{...r,className:reactAriaComponents.composeRenderProps(e,a=>cT({variant:o,showDividers:n,className:a})),children:a=>jsxRuntime.jsx(kb.Provider,{value:a,children:t})})}ln.displayName="CollapseItem";function cn({title:e,description:t,startContent:r,endContent:o,indicator:n,indicatorPosition:a="end",showIndicator:i=true,keepIndicatorSpace:s=false,children:l,className:c,...d}){let u=lT("CollapseHeader"),{density:p,variant:m,showDividers:f}=Zu(),g=sT[p];return jsxRuntime.jsx(reactAriaComponents.Button,{...d,slot:"trigger","data-expanded":u.isExpanded?"true":void 0,className:reactAriaComponents.composeRenderProps(c,(x,b)=>dT({isDisabled:b.isDisabled??false,isPressed:b.isPressed??false,density:p,variant:m,showDividers:f,className:x})),children:x=>{let b=x.isDisabled??false,h=i?typeof n=="function"?n({isExpanded:u.isExpanded,isDisabled:b}):n??jsxRuntime.jsx(O,{name:"CaretDown",size:p==="compact"?"xs":"sm",weight:"bold","aria-hidden":"true",className:tailwindMerge.twMerge("text-text-secondary transition-transform duration-200",u.isExpanded?"rotate-180":"rotate-0")}):null,y=h?jsxRuntime.jsx("span",{className:tailwindMerge.twMerge("flex flex-shrink-0 items-center justify-center text-text-secondary",g),"aria-hidden":"true",children:h}):s?jsxRuntime.jsx("span",{className:tailwindMerge.twMerge("flex flex-shrink-0 items-center justify-center",g),"aria-hidden":"true"}):null;return jsxRuntime.jsxs("div",{className:"flex w-full items-center gap-4",children:[a==="start"&&y,r&&jsxRuntime.jsx("div",{className:"flex flex-shrink-0 items-center text-text-secondary",children:r}),jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[l??jsxRuntime.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1 text-left",children:[e&&jsxRuntime.jsx("span",{className:"truncate font-medium text-text-primary",children:e}),t&&jsxRuntime.jsx("span",{className:"text-sm text-text-secondary",children:t})]}),o&&jsxRuntime.jsx("div",{className:"flex flex-shrink-0 items-center text-sm text-text-secondary",children:o})]}),a==="end"&&y]})}})}cn.displayName="CollapseHeader";function dn({className:e,children:t,...r}){let{density:o,showDividers:n}=Zu();return jsxRuntime.jsx(reactAriaComponents.DisclosurePanel,{...r,className:reactAriaComponents.composeRenderProps(e,a=>uT({density:o,showDividers:n,className:a})),children:jsxRuntime.jsx(_o,{children:t})})}dn.displayName="CollapseContent";function Ya(e){if(!e)return false;let t=e.startsWith("#")?e.slice(1):e;return /^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(t)}function $u(e){if(!e)return "";let t=e.startsWith("#")?e.slice(1):e;return t.length===3&&(t=t.split("").map(r=>r+r).join("")),`#${t.toUpperCase()}`}function gT({label:e,description:t,errorMessage:r,size:o="md",tooltip:n,isRequired:a,transparent:i,className:s,validationResult:l,value:c,defaultValue:d,onChange:u,placeholder:p="#000000",showColorSwatch:m=true,reserveErrorSpace:f=true,...g}){let[x,b]=qe.useState(d||""),[h,y]=qe.useState(c||d||""),[v,S]=qe.useState(false),[w,N]=qe.useState(null),{isFocused:R,handleFocus:P,handleBlur:E}=ur(),I=c!==void 0?c:x;qe.useEffect(()=>{c!==void 0&&y(c);},[c]);let T=I?!Ya(I):false,D=qe.useCallback(z=>{if(y(z),Ya(z)){let V=$u(z);u?u(V):b(V);}else z===""&&(u?u(""):b(""));},[u]),M=qe.useCallback(z=>{let V=$u(z);y(V),u?u(V):b(V);},[u]),B=qe.useCallback(z=>{if(Ya(h)){let V=$u(h);y(V),u&&V!==I?u(V):!u&&V!==x&&b(V);}E(z,g.onBlur);},[h,I,x,u,E,g.onBlur]);return jsxRuntime.jsx(reactAriaComponents.TextField,{...g,isRequired:a,className:Me(s,"group flex flex-col"),children:({isDisabled:z})=>jsxRuntime.jsxs("div",{className:"flex flex-col",children:[e&&jsxRuntime.jsx(Ke,{size:o,tooltip:n,isRequired:a,children:e}),jsxRuntime.jsx(Ct,{children:jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsxs("div",{className:"flex-1 relative",children:[jsxRuntime.jsx(sl,{size:o,disabled:z,type:"text",value:h,placeholder:p,onFocus:V=>P(V,g.onFocus),onBlur:B,onChange:V=>D(V.target.value),className:tailwindMerge.twMerge(zt({isInvalid:T,isDisabled:z,isFocused:R,size:o,transparent:i}),m?"pr-12":"pr-3","pl-3")}),m&&jsxRuntime.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none",style:{width:We[o].height},children:jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("w-6 h-6 rounded border shadow-sm",Ya(I)?"border-border-default":"border-border-default bg-background-muted"),style:Ya(I)?{backgroundColor:I}:void 0,"aria-hidden":"true",children:!Ya(I)&&jsxRuntime.jsx("div",{className:"w-full h-full flex items-center justify-center",children:jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-border-muted"})})})})]}),jsxRuntime.jsx("div",{ref:N,children:jsxRuntime.jsx($,{variant:"secondary",size:o,icon:"Palette",onPress:()=>S(!v),isDisabled:z,className:"flex-shrink-0",children:"Pick"})})]})}),f?jsxRuntime.jsx("div",{className:"mt-1 min-h-[20px]",children:typeof r=="string"?jsxRuntime.jsx(he,{size:o,children:r}):typeof r=="function"&&l?jsxRuntime.jsx(he,{size:o,children:r(l)}):t?jsxRuntime.jsx(Ne,{size:o,children:t}):null}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:typeof r=="string"?jsxRuntime.jsx(he,{size:o,className:"mt-1",children:r}):typeof r=="function"&&l?jsxRuntime.jsx(he,{size:o,className:"mt-1",children:r(l)}):t?jsxRuntime.jsx(Ne,{size:o,className:"mt-1",children:t}):null}),v&&w&&jsxRuntime.jsx(yt,{triggerRef:{current:w},isOpen:v,onOpenChange:S,placement:"bottom end",className:"bg-background-input shadow-xl border border-border-input/20 backdrop-blur-sm rounded-lg p-4",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntime.jsx(reactColorful.HexColorPicker,{color:I||"#000000",onChange:M,style:{width:"200px",height:"200px"}}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"w-10 h-10 rounded border border-border-default shadow-sm flex-shrink-0",style:{backgroundColor:I||"#000000"}}),jsxRuntime.jsx("div",{className:"flex-1 text-text-primary text-[length:var(--control-text-sm)] font-mono",children:I||"#000000"})]})]})})]})})}function Rb({isOpen:e,onClose:t,onConfirm:r,title:o,message:n,confirmLabel:a="Confirm",cancelLabel:i="Cancel",confirmVariant:s,isDestructive:l=false,isLoading:c=false,maxWidth:d="500px",minWidth:u="400px"}){return jsxRuntime.jsx(cr,{isOpen:e,onClose:t,title:o,maxWidth:d,minWidth:u,primaryAction:{label:a,onPress:()=>{r();},variant:s??(l?"destructive":"primary"),isLoading:c},secondaryAction:{label:i,onPress:t,variant:"secondary",isDisabled:c},children:jsxRuntime.jsx("div",{className:"text-text-primary",children:n})})}function Eb({isConnected:e,connectedAt:t,disconnectedAt:r,showTimestamp:o=false,isLoading:n,size:a="sm",shape:i="pill",...s}){if(n)return jsxRuntime.jsx(X,{className:"inline-flex h-6 w-24"});let l=e?"Connected":"Disconnected",c=e?"success":"neutral",d=null;if(o){if(e&&t)d=Ws(t);else if(!e&&r){let u=Ws(r);d=u?`Offline ${u}`:null;}}return jsxRuntime.jsxs("div",{className:"inline-flex flex-col gap-1",children:[jsxRuntime.jsx(ft,{variant:c,size:a,shape:i,dot:e,dotPulse:e,...s,children:l}),d&&jsxRuntime.jsx("span",{className:"text-xs text-text-secondary",children:d})]})}function Mb({firstName:e,lastName:t,email:r,phone:o,avatarUrl:n,href:a,LinkComponent:i,variant:s="outlined",layout:l="horizontal",showEmail:c=true,showPhone:d=false,isLoading:u=false,className:p,contentClassName:m,piiEntity:f}){let g=`${e} ${t}`.trim(),x=({children:h,className:y})=>a?i?jsxRuntime.jsx(i,{href:a,className:y,children:h}):jsxRuntime.jsx(ut,{href:a,variant:"unstyled",className:tailwindMerge.twMerge("hover:underline",y),asButton:false,children:h}):jsxRuntime.jsx("span",{className:y,children:h}),b=l==="vertical";return u?jsxRuntime.jsx(Ze,{variant:s,className:tailwindMerge.twMerge("flex flex-col",p),children:jsxRuntime.jsx(Ze.Content,{className:"flex items-center flex-1",children:jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("w-full",b?"flex flex-col items-center gap-4":"flex items-center gap-4"),children:[jsxRuntime.jsx(X,{width:56,height:56,className:"rounded flex-shrink-0"}),jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge(b?"w-full text-center":"flex-1","space-y-2"),children:[jsxRuntime.jsx(X,{width:"70%",height:20,className:tailwindMerge.twMerge(b&&"mx-auto")}),jsxRuntime.jsx(X,{width:"100%",height:16,className:tailwindMerge.twMerge(b&&"mx-auto")})]})]})})}):jsxRuntime.jsx(Ze,{variant:s,className:tailwindMerge.twMerge("group/card flex flex-col",p),children:jsxRuntime.jsx(Ze.Content,{className:tailwindMerge.twMerge("flex items-center flex-1",a&&"cursor-pointer",m),children:jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("relative w-full",b?"flex flex-col items-center gap-4 text-center":"flex items-center gap-4"),children:[jsxRuntime.jsx(Vo,{firstName:e,lastName:t,src:n,size:"xl",variant:"user",shape:"square",className:"flex-shrink-0",piiEntity:f}),jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge(b?"w-full":"flex-1 min-w-0"),children:[a&&jsxRuntime.jsx(x,{className:"after:absolute after:inset-0",children:jsxRuntime.jsx("span",{className:"sr-only",children:g})}),jsxRuntime.jsx("span",{className:"text-lg font-semibold leading-tight text-text-primary block mb-1.5 group-hover/card:text-text-brand transition-colors","data-pii-type":f?"full-name":void 0,"data-pii-entity":f,children:g}),jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("space-y-0.5",b&&"flex flex-col items-center"),children:[c&&r&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5 text-text-primary",children:[jsxRuntime.jsx(O,{name:"Envelope",size:16,className:"text-text-secondary flex-shrink-0"}),jsxRuntime.jsx(ut,{href:`mailto:${r}`,variant:"unstyled",className:tailwindMerge.twMerge("text-sm leading-relaxed text-text-primary relative z-20",b?"":"truncate"),"data-pii-type":f?"email":void 0,"data-pii-entity":f,children:r})]}),d&&o&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5 text-text-primary",children:[jsxRuntime.jsx(O,{name:"Phone",size:16,className:"text-text-secondary flex-shrink-0"}),jsxRuntime.jsx(ut,{href:`tel:${o}`,variant:"unstyled",className:tailwindMerge.twMerge("text-sm leading-relaxed text-text-primary relative z-20",b?"":"truncate"),"data-pii-type":f?"phone":void 0,"data-pii-entity":f,children:Ma(o)})]})]})]})]})})})}function yl({firstName:e,lastName:t,email:r,avatarUrl:o,layout:n="stacked",size:a="md",href:i,LinkComponent:s,linkVariant:l="unstyled",emphasis:c="normal",showEmail:d=false,badge:u,avatarShape:p,isLoading:m=false,className:f,piiEntity:g}){let x=p??(n==="inline"?"circle":"square"),h={xs:{avatarSize:"xs",gap:"gap-1.5",textSize:"text-xs",secondaryTextSize:"text-xs",skeletonAvatar:24,skeletonText:80,skeletonSecondary:60},sm:{avatarSize:"sm",gap:"gap-2",textSize:"text-sm",secondaryTextSize:"text-xs",skeletonAvatar:32,skeletonText:96,skeletonSecondary:72},md:{avatarSize:"md",gap:"gap-3",textSize:"text-base",secondaryTextSize:"text-sm",skeletonAvatar:40,skeletonText:128,skeletonSecondary:96},lg:{avatarSize:"lg",gap:"gap-3",textSize:"text-lg",secondaryTextSize:"text-base",skeletonAvatar:48,skeletonText:160,skeletonSecondary:120}}[a],y=`${e} ${t}`.trim(),S={strong:"font-semibold text-text-primary",high:"font-semibold text-text-primary",normal:"text-text-primary",low:"text-text-secondary"}[c],w=({children:N,className:R})=>i?s?jsxRuntime.jsx(s,{href:i,className:R,children:N}):jsxRuntime.jsx(ut,{href:i,variant:l,className:tailwindMerge.twMerge("hover:underline",R),asButton:false,children:N}):jsxRuntime.jsx("span",{className:R,children:N});return m?n==="inline"?jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center",h.gap,f),children:[jsxRuntime.jsx(X,{width:h.skeletonAvatar,height:h.skeletonAvatar,className:"flex-shrink-0 rounded-full"}),jsxRuntime.jsx(X,{width:h.skeletonText,height:h.skeletonAvatar*.5})]}):jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center",h.gap,f),children:[jsxRuntime.jsx(X,{width:h.skeletonAvatar,height:h.skeletonAvatar,className:"flex-shrink-0 rounded-full"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx(X,{width:h.skeletonText,height:16}),d&&jsxRuntime.jsx(X,{width:h.skeletonSecondary,height:12})]})]}):n==="inline"?jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center",h.gap,f),children:[jsxRuntime.jsxs(w,{className:tailwindMerge.twMerge("flex items-center",h.gap),children:[jsxRuntime.jsx(Vo,{firstName:e,lastName:t,src:o,size:h.avatarSize,variant:"user",shape:x,className:"flex-shrink-0",piiEntity:g}),jsxRuntime.jsx("span",{className:tailwindMerge.twMerge("leading-normal truncate hover:text-text-primary",S,h.textSize,i&&"hover:underline hover:decoration-1 hover:underline-offset-4"),"data-pii-type":g?"full-name":void 0,"data-pii-entity":g,children:y})]}),u]}):jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center justify-start",h.gap,f),children:[jsxRuntime.jsx(Vo,{firstName:e,lastName:t,src:o,size:h.avatarSize,variant:"user",shape:x,className:"flex-shrink-0",piiEntity:g}),jsxRuntime.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(w,{className:tailwindMerge.twMerge("leading-normal truncate hover:text-text-primary",S,h.textSize,i&&"hover:underline hover:decoration-1 hover:underline-offset-4"),children:jsxRuntime.jsx("span",{"data-pii-type":g?"full-name":void 0,"data-pii-entity":g,children:y})}),u]}),d&&r&&jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("text-text-secondary leading-normal truncate",h.secondaryTextSize),"data-pii-type":g?"email":void 0,"data-pii-entity":g,children:r})]})]})}var tp=qe.createContext(null);function Lb(e){let t=qe.useContext(tp),r=qe.useRef(null),o=e??r,[n,a]=qe.useState(()=>t||{current:"xl",isSm:true,isMd:true,isLg:true,isXl:true,is2Xl:false,isMobile:false,isDesktop:true});return qe.useEffect(()=>{if(t){a(t);return}let i=o.current;if(!i||typeof ResizeObserver>"u")return;let s=()=>{let c=i.offsetWidth,d=c>=640,u=c>=768,p=c>=1024,m=c>=1280,f=c>=1536,g="base";f?g="2xl":m?g="xl":p?g="lg":u?g="md":d&&(g="sm"),a({current:g,isSm:d,isMd:u,isLg:p,isXl:m,is2Xl:f,isMobile:!u,isDesktop:u});};s();let l=new ResizeObserver(s);return l.observe(i),()=>l.disconnect()},[t,o]),n}function Ab({children:e,className:t}){let r=qe.useRef(null),[o,n]=qe.useState({current:"base",isSm:false,isMd:false,isLg:false,isXl:false,is2Xl:false,isMobile:true,isDesktop:false});return qe.useEffect(()=>{let a=r.current;if(!a||typeof ResizeObserver>"u")return;let i=()=>{let l=a.offsetWidth,c=l>=640,d=l>=768,u=l>=1024,p=l>=1280,m=l>=1536,f="base";m?f="2xl":p?f="xl":u?f="lg":d?f="md":c&&(f="sm"),n({current:f,isSm:c,isMd:d,isLg:u,isXl:p,is2Xl:m,isMobile:!d,isDesktop:d});};i();let s=new ResizeObserver(i);return s.observe(a),()=>s.disconnect()},[]),jsxRuntime.jsx(tp.Provider,{value:o,children:jsxRuntime.jsx("div",{ref:r,className:t,style:{width:"100%"},children:e})})}var vl={duration:.5,ease:"easeInOut"},Jr=qe.createContext(null);function Cl(){let e=qe.useRef({played:false});return qe.useEffect(()=>{e.current.played=true;},[]),e.current}var Kn=()=>{let e=qe.useContext(Jr);if(!e)throw new Error("useChartContext must be used within a ChartContextProvider");return e};function Sl(e,t){if(t<=0||e.length<2)return e;let r=[e[0]];for(let o=1;o<e.length;o++)e[o].xValue.getTime()-e[o-1].xValue.getTime()>t&&r.push(null),r.push(e[o]);return r}var pn=({data:e,color:t="var(--color-viz-default)",baseline:r,fillOpacity:o=.1,showLine:n=true,maxGapMs:a,animate:i=true})=>{let s=qe.useId(),l=qe.useId(),{xScale:c,yScale:d,animationSettings:u,entrance:p}=Kn(),[m]=qe__namespace.default.useState(()=>p?.played!==true),f=i&&m,g=c.range(),x=d.range(),b=(N,R)=>typeof r=="function"?r(N,R):r??0,h=N=>N.chartYValue??N.yValue,y=a!=null?Sl(e,a):e,v=i?void 0:"non-scaling-stroke",S={transformOrigin:`0 ${x[0]}px`,transformBox:"fill-box",isolation:"isolate"},w=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r===void 0?jsxRuntime.jsx(shape.AreaClosed,{data:y,x:N=>N?c(N.xValue):0,y:N=>N?d(h(N)):0,yScale:d,defined:N=>N!=null,fill:`url(#${s})`,curve:curve.curveLinear}):jsxRuntime.jsx(shape.Area,{data:y,x:N=>N?c(N.xValue):0,y0:(N,R)=>N?d(b(N,R)):0,y1:N=>N?d(h(N)):0,defined:N=>N!=null,fill:t,fillOpacity:o,curve:curve.curveLinear}),n?jsxRuntime.jsx(shape.LinePath,{data:y,x:N=>N?c(N.xValue):0,y:N=>N?d(h(N)):0,defined:N=>N!=null,stroke:t,strokeWidth:3,vectorEffect:v,curve:curve.curveLinear}):null]});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsxs("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[jsxRuntime.jsx("stop",{offset:"50%",stopColor:t,stopOpacity:o}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:t,stopOpacity:0})]}),f&&jsxRuntime.jsx("clipPath",{id:l,children:jsxRuntime.jsx("rect",{x:g[0],y:x[1],width:g[1]-g[0],height:x[0]-x[1]})})]}),f?jsxRuntime.jsx("g",{clipPath:`url(#${l})`,children:jsxRuntime.jsx(framerMotion.motion.g,{initial:{scaleY:0},animate:{scaleY:1},transition:{duration:u.duration,ease:u.ease},style:S,children:w})}):jsxRuntime.jsx("g",{style:S,children:w})]})};var Nl=({data:e,color:t="var(--color-viz-default)",opacity:r=1,categoryColors:o={}})=>{let{xScale:n,yScale:a,animationSettings:i}=Kn(),s=qe.useId(),l=n.range(),c=a.range(),d=[...e].sort((m,f)=>m.xValue.getTime()-f.xValue.getTime());if(d.length===0)return null;let u=d.length>1?d[1].xValue.getTime()-d[0].xValue.getTime():15*6e4,p=Math.abs(n(new Date(d[0].xValue.getTime()+u))-n(d[0].xValue));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:s,children:jsxRuntime.jsx("rect",{x:l[0],y:c[1],width:l[1]-l[0],height:c[0]-c[1]})})}),jsxRuntime.jsx("g",{clipPath:`url(#${s})`,children:jsxRuntime.jsx(framerMotion.motion.g,{initial:{scaleY:0},animate:{scaleY:1},transition:{duration:i.duration,ease:i.ease},style:{transformOrigin:`0 ${a(0)}px`,isolation:"isolate"},children:d.map((m,f)=>{let g=n(m.xValue),x=m.chartYValue??m.yValue,b=m.baselineValue??0,h=a(x),y=a(b),v=Math.min(h,y),S=Math.abs(h-y),w=d[f+1],N=w?Math.abs(n(w.xValue)-g):p,R=m.category&&o[m.category]?o[m.category]:t;return jsxRuntime.jsx(shape.Bar,{x:g-N/2,y:v,width:N,height:S,fill:R,opacity:r,rx:1},m.xValue.getTime())})})})]})};function KT(e){return e>=1e9?"GW":e>=1e6?"MW":e>=1e3?"kW":"W"}function YT(e){return e>=1e3?"kA":e<1?"mA":"A"}function JT(e){return e>=1e3?"kV":e<1?"mV":"V"}function XT(e){return e>=1e6?"M\u03A9":e>=1e3?"k\u03A9":e<1?"m\u03A9":"\u03A9"}function Xa(e,t){if(typeof e!="object"||e===null)return e;switch(e.type){case "energy":{if(e.unit||e.autoScale===false)return e;let r=e.sourceUnit?Yd[e.sourceUnit]:1;return {...e,unit:Kd(t*r)}}case "power":return e.unit||e.autoScale===false?e:{...e,unit:KT(t)};case "current":return e.unit||e.autoScale===false?e:{...e,unit:YT(t)};case "voltage":return e.unit||e.autoScale===false?e:{...e,unit:JT(t)};case "resistance":return e.unit||e.autoScale===false?e:{...e,unit:XT(t)};default:return e}}var jT=e=>e.baselineValue??0,He={top:8,right:0,bottom:50,left:60};function Dr(e={type:"number"}){let t=i=>{if(i==null)return "-";let s=fo({value:i,formatter:e});if(s===null)return "-";if(typeof s=="string")return s;if(typeof s=="number")return s.toString();if(typeof s=="object"&&s!==null&&"props"in s){let l=d=>{if(d==null)return "";if(typeof d=="string")return d;if(typeof d=="number")return d.toString();if(typeof d=="object"&&"props"in d){let u=d.props;if(u?.children)return Array.isArray(u.children)?u.children.map(l).join(""):l(u.children)}return ""};return l(s)||i.toString()}return i.toString()},r=i=>{if(i==null)return "-";if(typeof e=="string"){let s=fo({value:i,formatter:e});return s===null?"-":String(s)}if(typeof e=="object"&&e.type)switch(e.type){case "energy":case "power":case "voltage":case "current":case "resistance":case "temperature":case "distance":return t(i);case "currency":return t(i);default:return t(i)}return t(i)},o,n,a;return typeof e=="object"&&e.type&&e.type==="number"&&("min"in e&&(o=e.min),"max"in e&&(n=e.max)),{format:t,tickFormat:r,min:o,max:n,tickInterval:a}}var op=(e,t)=>{let r=d3Array.extent(e,o=>o.xValue);return scale.scaleTime({range:[He.left,t-He.right],domain:r,nice:true})},Hi=(e,t,r,o)=>{let n=Dr(r);if(o)return scale.scaleLinear({range:[t-He.bottom,He.top],domain:o,nice:true});let a=d3Array.min(e,c=>Math.min(c.yValue,c.chartYValue??c.yValue,c.baselineValue??c.yValue))||0,i=d3Array.max(e,c=>Math.max(c.yValue,c.chartYValue??c.yValue,c.baselineValue??c.yValue))||0,s=n.min!==void 0?n.min:a>=0?0:a*1.1,l=n.max!==void 0?n.max:i<=0?0:i*1.1;return scale.scaleLinear({range:[t-He.bottom,He.top],domain:[s,l],nice:true})};function qT(e,t=12,r="system-ui"){if(typeof window>"u"||typeof document>"u")return e.length*(t*.6);let o=document.createElement("canvas"),n=null;try{n=o.getContext("2d");}catch{return e.length*(t*.6)}return n?(n.font=`${t}px ${r}`,n.measureText(e).width):e.length*(t*.6)}function ja(e,t=12,r="system-ui"){return e.length===0?0:Math.max(...e.map(o=>qT(o,t,r)))}function Gi(e){return e instanceof Date&&!Number.isNaN(e.getTime())}function QT(e,t,r=12,o=false){if(!Gi(t[0])||!Gi(t[1]))return console.warn("ChartAxis: Invalid date in domain, skipping tick calculation"),[];let n=t[0].getTime(),a=t[1].getTime(),i=a-n;if(i===0||i<1e3)return [t[0]];let s=nu({start:t[0],end:t[1]},{compact:o}),c=[t[0],new Date((t[0].getTime()+t[1].getTime())/2),t[1]].map(h=>s(h)),d=ja(c,r),p=d+d,m=Math.floor(e/p),f=Math.max(2,Math.min(8,m));if(f<=2)return [t[0],t[1]];let g=[t[0]],x=i/36e5,b;x<=1?b=6e4:x<=6?b=5*6e4:x<=48?b=60*6e4:x<=168?b=360*6e4:b=1440*6e4;for(let h=1;h<f-1;h++){let y=h/(f-1),v=n+i*y,S=Math.round(v/b)*b,w=g[g.length-1].getTime(),N=S>w?S:w+b;if(N>=a)break;g.push(new Date(N));}return g.push(t[1]),g}var ZT=({top:e,scale:t,width:r})=>{let o=t.domain(),n=[o[0],o[o.length-1]],a=Gi(n[0])&&Gi(n[1]),i=r<400,s=a?n[0].getTime():0,l=a?n[1].getTime():0,c=qe.useMemo(()=>a?nu({start:n[0],end:n[1]},{compact:i}):()=>"",[s,l,i,a]),d=qe.useMemo(()=>QT(r,n,12,i),[r,s,l,i]);return d.length===0?null:jsxRuntime.jsx(axis.Axis,{orientation:"bottom",top:e,scale:t,tickValues:d,tickFormat:u=>{let p=u;return Gi(p)?c(p):""},stroke:"var(--color-border-muted)",tickStroke:"var(--color-border-muted)",tickLabelProps:(u,p,m)=>({fill:"var(--color-text-secondary)",fontSize:12,textAnchor:p===0?"start":p===m.length-1?"end":"middle"}),rangePadding:0})};function qa(e,t=12){let r=t*2.5,o=Math.floor(e/r);return Math.max(2,Math.min(6,o))}var np=12,_T=({left:e,scale:t,yFormatter:r,height:o})=>{let n=Dr(r),a=qe.useMemo(()=>!o||o<=0?5:qa(o),[o]);return jsxRuntime.jsx(axis.Axis,{orientation:"left",left:e,scale:t,numTicks:a,tickFormat:i=>(n.tickFormat||n.format)(i),stroke:"var(--color-border-muted)",tickStroke:"var(--color-border-muted)",tickLabelProps:i=>{let s={fill:"var(--color-text-secondary)",fontSize:np,textAnchor:"end"},l=t(i),[c,d]=t.range(),u=Math.min(c,d),p=Math.max(c,d);return l-u<np/2?{...s,verticalAnchor:"start"}:p-l<np/2?{...s,verticalAnchor:"end"}:{...s,dy:"0.33em"}}})},$T=({top:e,scale:t})=>jsxRuntime.jsx(axis.Axis,{orientation:"bottom",top:e,scale:t,stroke:"var(--color-border-muted)",tickStroke:"var(--color-border-muted)",tickLabelProps:()=>({fill:"var(--color-text-secondary)",fontSize:12,textAnchor:"middle",dy:"0.25em"})}),eP=({left:e,scale:t})=>jsxRuntime.jsx(axis.Axis,{orientation:"left",left:e,scale:t,stroke:"var(--color-border-muted)",tickStroke:"var(--color-border-muted)",tickLabelProps:()=>({fill:"var(--color-text-secondary)",fontSize:12,textAnchor:"end",dx:"-0.25em",dy:"0.33em"})}),tP=({top:e,scale:t,yFormatter:r,width:o})=>{let n=Dr(r),a=qe.useMemo(()=>{if(!o||o<=0)return 5;let s=Math.floor(o/60);return Math.max(2,Math.min(8,s))},[o]);return jsxRuntime.jsx(axis.Axis,{orientation:"bottom",top:e,scale:t,numTicks:a,tickFormat:i=>(n.tickFormat||n.format)(i),stroke:"var(--color-border-muted)",tickStroke:"var(--color-border-muted)",tickLabelProps:()=>({fill:"var(--color-text-secondary)",fontSize:12,textAnchor:"middle",dy:"0.25em"})})},Xr={Bottom:ZT,Left:_T,CategoryBottom:$T,CategoryLeft:eP,NumericBottom:tP};var Co=({data:e,formatter:t,label:r,categoryLabels:o})=>{if(!e)return null;let n=qe__namespace.default.useContext(Jr),a=o??n?.categoryLabels,i=n?.xScale,s=n?.width,l=n?.height,c=Dr(t),d=h=>{if(h.baselineValue===void 0)return c.format(h.value);let y=Math.min(h.baselineValue,h.value),v=Math.max(h.baselineValue,h.value);return `${c.format(y)} \u2013 ${c.format(v)}`},u=qe__namespace.default.useRef(null),[p,m]=qe__namespace.default.useState({x:0,y:0,translate:"translate(-50%, -100%)"});qe__namespace.default.useEffect(()=>{if(!u.current)return;let y=u.current.getBoundingClientRect(),v=s??window.innerWidth,S=l??window.innerHeight,w=e.x,N=e.y,R=16,P=e.x+y.width+R<=v,E=e.x-y.width-R>=0,I;e.position==="left"?I=E||!P:I=!P&&E;let T=I?"translate(calc(-100% - 16px), -50%)":"translate(16px, -50%)";if(!P&&!E){let D=v-e.x,M=e.x;D<=M?(w=v,T="translate(-100%, -50%)"):(w=0,T="translate(0, -50%)");}N-y.height/2<0?N=y.height/2:N+y.height/2>S&&(N=S-y.height/2),m({x:w,y:N,translate:T});},[e.x,e.y,e.position,s,l]);let f=i?.domain(),x=f&&f.length===2&&f.every(h=>h instanceof Date)?rg({start:f[0],end:f[1]}):null,b=r||(x&&e.xValue instanceof Date?x(e.xValue):String(e.xValue));return jsxRuntime.jsx(framerMotion.AnimatePresence,{children:jsxRuntime.jsxs(framerMotion.motion.div,{ref:u,role:"tooltip","aria-live":"polite",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},"data-testid":"tooltip",className:"pointer-events-none absolute z-50 rounded-lg bg-background-surface p-4 text-sm shadow-xl ring-1 ring-border-default whitespace-nowrap",style:{left:p.x,top:p.y,transform:p.translate},children:[jsxRuntime.jsx("div",{className:"mb-1 font-medium text-text-primary",children:b}),e.isEvent?jsxRuntime.jsxs("div",{className:"space-y-2",children:[e.series.length>1&&jsxRuntime.jsx("ul",{className:"list-none p-0 border-b border-border-default pb-2",children:e.series.slice(0,-1).map(h=>jsxRuntime.jsxs("li",{className:"py-0.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("span",{className:"font-medium text-text-primary",children:[h.label,":"]}),jsxRuntime.jsx("span",{className:"text-text-secondary",children:d(h)})]}),h.category&&jsxRuntime.jsxs("div",{className:"mt-0.5 flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-3 w-3",style:{backgroundColor:h.categoryColor||h.color,borderRadius:"1px"}}),jsxRuntime.jsx("span",{className:"text-sm text-text-secondary",children:a?.[h.category]||h.category})]}),h.extraTooltipRows&&h.extraTooltipRows.length>0&&jsxRuntime.jsx("div",{className:"mt-0.5 space-y-0.5",children:h.extraTooltipRows.map(y=>jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-secondary",children:[jsxRuntime.jsxs("span",{children:[y.label,":"]}),jsxRuntime.jsx("span",{className:"font-medium text-text-primary",children:y.value})]},y.label))})]},h.label))}),(()=>{let h=e.series[e.series.length-1],y=e.eventItems?.length?e.eventItems:[{label:h.label,color:h.color,metadata:e.eventMetadata}];return jsxRuntime.jsx("div",{className:"space-y-2",children:y.map((v,S)=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:v.color}}),jsxRuntime.jsx("span",{className:"font-medium text-text-primary",children:v.label})]}),v.metadata&&Object.keys(v.metadata).length>0&&jsxRuntime.jsx("div",{className:"ml-4 mt-1 space-y-0.5 text-xs text-text-secondary",children:Object.entries(v.metadata).map(([w,N])=>jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("span",{className:"capitalize",children:[w,":"]}),jsxRuntime.jsx("span",{className:"font-medium",children:N})]},w))})]},`${v.label}-${S}`))})})()]}):jsxRuntime.jsx("ul",{className:"list-none p-0",children:e.series.map(h=>jsxRuntime.jsxs("li",{className:"py-0.5",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("span",{className:"font-medium text-text-primary",children:[h.label,":"]}),jsxRuntime.jsx("span",{className:"text-text-secondary",children:d(h)})]}),h.category&&jsxRuntime.jsxs("div",{className:"mt-0.5 flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-3 w-3",style:{backgroundColor:h.categoryColor||h.color,borderRadius:"1px"}}),jsxRuntime.jsx("span",{className:"text-sm text-text-secondary",children:a?.[h.category]||h.category})]}),h.extraTooltipRows&&h.extraTooltipRows.length>0&&jsxRuntime.jsx("div",{className:"mt-0.5 space-y-0.5",children:h.extraTooltipRows.map(y=>jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-secondary",children:[jsxRuntime.jsxs("span",{children:[y.label,":"]}),jsxRuntime.jsx("span",{className:"font-medium text-text-primary",children:y.value})]},y.label))})]},h.label))})]})})};var dP={top:20,right:20,bottom:50,left:60},Ub=({data:e,width:t,height:r,margin:o=dP,color:n,yFormatter:a={type:"number"},showGrid:i=true,showAxes:s=true,animate:l=true,barRadius:c=4,barPadding:d=.3,onBarClick:u,onBarHover:p,activeIndex:m,className:f,style:g,"aria-label":x,orientation:b="horizontal",showTooltip:h=true})=>{let[y,v]=qe.useState(null),[S,w]=qe.useState(null),[N,R]=qe.useState(null),[P,E]=qe.useState(t??600),[I,T]=qe.useState(r??300),D=qe.useRef(null),M=m??y,B=qe.useId(),z=n||"var(--color-viz-default)";qe.useEffect(()=>{if(t!==void 0&&r!==void 0){E(t),T(r);return}if(!D.current)return;let W=new ResizeObserver(A=>{for(let Y of A)t===void 0&&E(Y.contentRect.width),r===void 0&&T(Y.contentRect.height);});return W.observe(D.current),t===void 0&&E(D.current.offsetWidth),r===void 0&&T(D.current.offsetHeight||300),()=>{W.disconnect();}},[t,r]);let{xScale:V,yScale:U,innerWidth:Z,innerHeight:G}=qe.useMemo(()=>{let W=P-o.left-o.right,A=I-o.top-o.bottom;if(b==="horizontal"){let k=d3Array.max(e,C=>C.value)||0;return {xScale:scale.scaleLinear({range:[0,W],domain:[0,k*1.1],nice:true}),yScale:scale.scaleBand({range:[0,A],domain:e.map(C=>C.label),padding:d}),innerWidth:W,innerHeight:A}}let Y=d3Array.max(e,k=>k.value)||0;return {xScale:scale.scaleBand({range:[0,W],domain:e.map(k=>k.label),padding:d}),yScale:scale.scaleLinear({range:[A,0],domain:[0,Y*1.1],nice:true}),innerWidth:W,innerHeight:A}},[e,P,I,o,d,b]);if(e.length===0)return jsxRuntime.jsx("div",{ref:D,className:tailwindMerge.twMerge("flex h-full min-h-[200px] w-full items-center justify-center rounded-lg border border-dashed border-border-default bg-background-surface text-sm font-medium text-text-secondary",f),style:r!==void 0?{height:r,...g}:g,children:"No data available"});let J=(W,A)=>{if(v(W),p?.(A,W),W!==null&&A){let Y,k;if(b==="horizontal"){let L=V(A.value),F=U(A.label)||0,j=U.bandwidth();Y=o.left+L,k=o.top+F+j/2;}else {let L=V,F=U,j=L(A.label)??0,ne=L.bandwidth(),ce=F(A.value);Y=o.left+j+ne/2,k=o.top+ce;}let C=Y>P/2;R(A.label),w({xValue:new Date,series:[{label:"Value",value:A.value,color:A.color||z}],x:Y,y:k,position:C?"left":"right"});}else w(null),R(null);};return jsxRuntime.jsxs("div",{ref:D,className:tailwindMerge.twMerge("relative h-full w-full overflow-hidden rounded-lg bg-background-surface",f),style:r!==void 0?{height:r,...g}:g,"aria-label":x,role:"img",children:[jsxRuntime.jsxs("svg",{width:P,height:I,children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx(gradient.LinearGradient,{id:`${B}-bar`,from:z,to:z,toOpacity:.85})}),jsxRuntime.jsxs(group.Group,{left:o.left,top:o.top,children:[i&&jsxRuntime.jsx("g",{className:"grid-lines",children:(b==="horizontal"?V.ticks(5):U.ticks(5)).map(W=>{let A=b==="horizontal"?0:U(W),Y=b==="horizontal"?V(W):0;return jsxRuntime.jsx("line",{x1:b==="horizontal"?Y:0,y1:b==="horizontal"?0:A,x2:b==="horizontal"?Y:Z,y2:b==="horizontal"?G:A,stroke:"var(--color-border-default)",strokeOpacity:.5,strokeDasharray:"2,3"},W)})}),e.map((W,A)=>{let Y=M===A||M==null,k=W.color||`url(#${B}-bar)`;if(b==="horizontal"){let ee=V(W.value),ae=U.bandwidth(),Le=U(W.label)||0;return jsxRuntime.jsx(framerMotion.motion.rect,{x:0,y:Le,width:ee,height:ae,fill:k,rx:c,ry:c,initial:l?{width:0,opacity:.5}:void 0,animate:{width:ee,opacity:Y?1:.5},transition:{duration:.5,delay:A*.05,ease:"easeOut",opacity:{duration:.15,delay:0}},style:{cursor:u||p?"pointer":"default"},onMouseEnter:()=>J(A,W),onMouseLeave:()=>J(null,null),onClick:()=>u?.(W,A)},W.label)}let C=V,L=U,F=C.bandwidth(),j=C(W.label)??0,ne=L(W.value),ce=Math.max(0,G-ne);return l?jsxRuntime.jsx(framerMotion.motion.rect,{x:j,width:F,fill:k,rx:c,ry:c,initial:{y:G,height:0,opacity:.5},animate:{y:ne,height:ce,opacity:Y?1:.5},transition:{duration:.5,delay:A*.05,ease:"easeOut",opacity:{duration:.15,delay:0}},style:{cursor:u||p?"pointer":"default"},onMouseEnter:()=>J(A,W),onMouseLeave:()=>J(null,null),onClick:()=>u?.(W,A)},W.label):jsxRuntime.jsx("rect",{x:j,y:ne,width:F,height:ce,fill:k,rx:c,ry:c,opacity:Y?1:.5,style:{cursor:u||p?"pointer":"default",transition:"opacity 150ms ease-out"},onMouseEnter:()=>J(A,W),onMouseLeave:()=>J(null,null),onClick:()=>u?.(W,A)},W.label)}),s&&b==="vertical"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Xr.CategoryBottom,{top:G,scale:V}),jsxRuntime.jsx(Xr.Left,{left:0,scale:U,yFormatter:a,height:G})]}),s&&b==="horizontal"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Xr.NumericBottom,{top:G,scale:V,yFormatter:a,width:Z}),jsxRuntime.jsx(Xr.CategoryLeft,{left:0,scale:U})]})]})]}),h&&jsxRuntime.jsx(Co,{data:S,formatter:a,label:N??void 0})]})};var Kb=({item:e,onToggle:t})=>{let r=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"h-3 w-3 shrink-0",style:{backgroundColor:e.fill,borderRadius:"1px",opacity:e.isHidden?.35:1}}),jsxRuntime.jsx("span",{className:`text-sm whitespace-nowrap ${e.isHidden?"text-text-disabled line-through":"text-text-secondary"}`,children:e.category})]});return t?jsxRuntime.jsx("button",{type:"button",className:"flex items-center gap-2 shrink-0 rounded-sm focus:outline-none focus:ring-2 focus:ring-border-focus disabled:cursor-not-allowed disabled:opacity-60","aria-pressed":!e.isHidden,"aria-label":`${e.isHidden?"Show":"Hide"} ${e.category}`,disabled:e.isDisabled,onClick:()=>t(e.category),children:r}):jsxRuntime.jsx("div",{className:"flex items-center gap-2 shrink-0",children:r})},mP=({items:e,onToggle:t})=>e.length===0?null:jsxRuntime.jsx("div",{className:"flex items-center gap-3 flex-wrap",children:e.map(r=>jsxRuntime.jsx(Kb,{item:r,onToggle:t},r.category))}),Za=({items:e,onExport:t,marginLeft:r=0,marginRight:o=0,isZoomed:n=false,onResetZoom:a,onLegendItemToggle:i})=>{let[s,l]=qe__namespace.default.useState(false),[c,d]=qe__namespace.default.useState(null),[u,p]=qe__namespace.default.useState(false),[m,f]=qe__namespace.default.useState(false),g=qe__namespace.default.useCallback(async b=>{l(true),d(b),f(false);try{await t(b);}catch(h){console.error("Export failed:",h);}finally{l(false),d(null);}},[t]),x=qe__namespace.default.useCallback(async b=>{await g(b);},[g]);return jsxRuntime.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 min-h-[32px]",style:{marginLeft:r,marginRight:o},children:[jsxRuntime.jsx("div",{className:"hidden sm:block flex-1 min-w-0",children:jsxRuntime.jsx(mP,{items:e,onToggle:i})}),jsxRuntime.jsx("div",{className:"sm:hidden flex items-center gap-3",children:e.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{onClick:()=>p(true),className:"text-sm text-text-secondary hover:text-text-primary transition-colors underline decoration-dotted underline-offset-4",children:"Legend"}),jsxRuntime.jsx(vt,{isOpen:u,onClose:()=>p(false),title:"Legend",children:jsxRuntime.jsx("div",{className:"grid grid-cols-1 gap-3 p-4",children:e.map(b=>jsxRuntime.jsx(Kb,{item:b,onToggle:i},b.category))})})]})}),jsxRuntime.jsxs("div",{className:"sm:hidden flex items-center gap-2 shrink-0",children:[n&&a&&jsxRuntime.jsx($,{variant:"secondary",size:"sm",onPress:a,children:jsxRuntime.jsx(O,{name:"ArrowsOut",size:16})}),jsxRuntime.jsx($,{variant:"secondary",size:"sm",onPress:()=>f(true),isDisabled:s,children:jsxRuntime.jsx(O,{name:"Export",size:16})}),jsxRuntime.jsx(vt,{isOpen:m,onClose:()=>f(false),title:"Export Chart",contentPadding:false,children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsxs("button",{onClick:()=>g("csv"),disabled:s,className:"flex items-center gap-3 px-6 py-4 text-left hover:bg-background-hover active:bg-background-muted transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[jsxRuntime.jsx(O,{name:"List",size:20,className:"text-text-secondary"}),jsxRuntime.jsx("span",{className:"text-sm text-text-primary",children:c==="csv"?"Exporting...":"Export as CSV"})]}),jsxRuntime.jsxs("button",{onClick:()=>g("svg"),disabled:s,className:"flex items-center gap-3 px-6 py-4 text-left hover:bg-background-hover active:bg-background-muted transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[jsxRuntime.jsx(O,{name:"Code",size:20,className:"text-text-secondary"}),jsxRuntime.jsx("span",{className:"text-sm text-text-primary",children:c==="svg"?"Exporting...":"Export as SVG"})]}),jsxRuntime.jsxs("button",{onClick:()=>g("png"),disabled:s,className:"flex items-center gap-3 px-6 py-4 text-left hover:bg-background-hover active:bg-background-muted transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[jsxRuntime.jsx(O,{name:"DownloadSimple",size:20,className:"text-text-secondary"}),jsxRuntime.jsx("span",{className:"text-sm text-text-primary",children:c==="png"?"Exporting...":"Export as PNG"})]})]})})]}),jsxRuntime.jsxs("div",{className:"hidden sm:flex items-center gap-2 shrink-0",children:[n&&a&&jsxRuntime.jsxs($,{variant:"secondary",size:"sm",onPress:a,children:[jsxRuntime.jsx(O,{name:"ArrowsOut",size:16}),jsxRuntime.jsx("span",{className:"hidden sm:inline",children:"Reset Zoom"})]}),jsxRuntime.jsxs(reactAriaComponents.DialogTrigger,{children:[jsxRuntime.jsxs($,{variant:"secondary",size:"sm",isDisabled:s,children:[jsxRuntime.jsx(O,{name:"Export",size:16}),s?"Exporting...":"Export"]}),jsxRuntime.jsx(yt,{placement:"top end",className:"min-w-48 p-1 bg-background-surface rounded-lg shadow-xl ring-1 ring-border-default",children:jsxRuntime.jsxs(reactAriaComponents.Menu,{onAction:x,className:"outline-none",children:[jsxRuntime.jsx(reactAriaComponents.MenuItem,{id:"csv",className:"flex items-center gap-2 px-3 py-2 text-sm text-text-primary rounded cursor-pointer hover:bg-background-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus focus-visible:ring-offset-1 focus-visible:ring-offset-background-surface data-[focused]:bg-background-hover data-[focused]:ring-2 data-[focused]:ring-border-focus data-[focused]:ring-offset-1 data-[focused]:ring-offset-background-surface",isDisabled:s,children:jsxRuntime.jsxs("span",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(O,{name:"List",size:14}),c==="csv"?"Exporting...":"Export as CSV"]})}),jsxRuntime.jsx(reactAriaComponents.MenuItem,{id:"svg",className:"flex items-center gap-2 px-3 py-2 text-sm text-text-primary rounded cursor-pointer hover:bg-background-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus focus-visible:ring-offset-1 focus-visible:ring-offset-background-surface data-[focused]:bg-background-hover data-[focused]:ring-2 data-[focused]:ring-border-focus data-[focused]:ring-offset-1 data-[focused]:ring-offset-background-surface",isDisabled:s,children:jsxRuntime.jsxs("span",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(O,{name:"Code",size:14}),c==="svg"?"Exporting...":"Export as SVG"]})}),jsxRuntime.jsx(reactAriaComponents.MenuItem,{id:"png",className:"flex items-center gap-2 px-3 py-2 text-sm text-text-primary rounded cursor-pointer hover:bg-background-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus focus-visible:ring-offset-1 focus-visible:ring-offset-background-surface data-[focused]:bg-background-hover data-[focused]:ring-2 data-[focused]:ring-border-focus data-[focused]:ring-offset-1 data-[focused]:ring-offset-background-surface",isDisabled:s,children:jsxRuntime.jsxs("span",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(O,{name:"DownloadSimple",size:14}),c==="png"?"Exporting...":"Export as PNG"]})})]})})]})]})]})};var Pl=tf(lp());var Jb=["stroke","fill","color","stop-color","flood-color","lighting-color"],Xb=/var\s*\(/;function jb(e,t){let r=[e,...Array.from(e.querySelectorAll("*"))],o=[t,...Array.from(t.querySelectorAll("*"))],n=Math.min(r.length,o.length);for(let a=0;a<n;a++){let i=r[a],s=o[a];if(!(i instanceof Element)||!(s instanceof Element))continue;let l=window.getComputedStyle(i);for(let c of Jb){let d=s.getAttribute(c);if(d&&Xb.test(d)){let u=l.getPropertyValue(c);u&&s.setAttribute(c,u.trim());}}if(s instanceof HTMLElement||s instanceof SVGElement)for(let c of Jb){let d=c,u=s.style.getPropertyValue(d);if(u&&Xb.test(u)){let p=l.getPropertyValue(d);p&&s.style.setProperty(d,p.trim());}}}}function cp(e,t,r=true){let o=e||"chart";if(r){let n=new Date().toISOString().replace(/[:.]/g,"-").slice(0,-5);return `${o}-${n}.${t}`}return `${o}.${t}`}async function dp(e,t,r={},o){let n=Array.isArray(t[0])?t:[t];try{switch(e){case "csv":await gP(n,r);break;case "svg":await bP(o,r);break;case "png":await hP(o,r);break;default:throw new Error(`Unsupported export type: ${e}`)}}catch(a){throw console.error("Export failed:",a),new Error(`Failed to export chart as ${e}: ${a instanceof Error?a.message:"Unknown error"}`)}}async function gP(e,t){try{let r=t.yFormat?ou(t.yFormat):null,o=t.yFormat,n=p=>{if(p==null||p==="")return "";if(!o)return typeof p=="number"?p:String(p);let m=tg(p,o);return m===null?typeof p=="number"?p:String(p):m},a=new Map;e.forEach(p=>{p.forEach(m=>{let f=m.xValue.getTime();a.has(f)||a.set(f,m.xValue);});});let i=Array.from(a.values()).sort((p,m)=>p.getTime()-m.getTime()),s=e.map((p,m)=>{let f=t.seriesLabels?.[m]||`Series ${m+1}`;return r&&!f.includes(`(${r})`)?`${f} (${r})`:f}),l=i.map(p=>{let m={[t.xLabel||"Date"]:p.toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})};return e.forEach((f,g)=>{let x=s[g],b=f.find(h=>h.xValue.getTime()===p.getTime());m[x]=b?n(b.yValue):"",b?.category&&(m[`${x} Category`]=b.category);}),m}),c=fP__default.default.unparse(l,{header:!0,skipEmptyLines:!0}),d=new Blob([c],{type:"text/csv;charset=utf-8;"}),u=cp(t.filename||"chart-data","csv",t.timestamp!==!1);(0,Pl.saveAs)(d,u);}catch(r){throw new Error(`CSV export failed: ${r instanceof Error?r.message:"Unknown error"}`)}}async function bP(e,t){if(!e.current)throw new Error("SVG element not found");try{let r=e.current,o=r.cloneNode(!0);if(jb(r,o),!o.querySelector("rect[data-background]")){let c=document.createElementNS("http://www.w3.org/2000/svg","rect");c.setAttribute("width",o.getAttribute("width")||"100%"),c.setAttribute("height",o.getAttribute("height")||"100%"),c.setAttribute("fill","white"),c.setAttribute("data-background","true"),o.insertBefore(c,o.firstChild);}let i=new XMLSerializer().serializeToString(o);i.includes("<?xml")||(i=`<?xml version="1.0" encoding="UTF-8"?>
|
|
28
|
-
`+i),i.includes("xmlns=")||(i=i.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"'));let s=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),l=cp(t.filename||"chart","svg",t.timestamp!==!1);(0,Pl.saveAs)(s,l);}catch(r){throw new Error(`SVG export failed: ${r instanceof Error?r.message:"Unknown error"}`)}}async function hP(e,t,r=2){if(!e.current)throw new Error("SVG element not found");let o="";try{let n=e.current,a=n.getBoundingClientRect(),i=n.cloneNode(!0);jb(n,i),i.setAttribute("width",String(a.width)),i.setAttribute("height",String(a.height)),i.removeAttribute("transform");let s=i.getElementsByTagName("text");Array.from(s).forEach(p=>{p.style.fontFamily||(p.style.fontFamily="system-ui, -apple-system, sans-serif"),p.style.fontSize||(p.style.fontSize="12px");});let l=document.createElementNS("http://www.w3.org/2000/svg","rect");l.setAttribute("width",String(a.width)),l.setAttribute("height",String(a.height)),l.setAttribute("fill","white"),i.insertBefore(l,i.firstChild);let d=new XMLSerializer().serializeToString(i);d.includes("xmlns=")||(d=d.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"'));let u=new Blob([d],{type:"image/svg+xml;charset=utf-8"});return o=URL.createObjectURL(u),new Promise((p,m)=>{let f=new Image,g=setTimeout(()=>{o&&URL.revokeObjectURL(o),m(new Error("Image loading timeout"));},1e4);f.onload=()=>{clearTimeout(g);try{let x=document.createElement("canvas");x.width=a.width*r,x.height=a.height*r;let b=x.getContext("2d");if(!b)throw new Error("Canvas context not available");b.imageSmoothingEnabled=!0,b.imageSmoothingQuality="high",b.scale(r,r),b.fillStyle="white",b.fillRect(0,0,a.width,a.height),b.drawImage(f,0,0,a.width,a.height),x.toBlob(h=>{if(h){let y=cp(t.filename||"chart","png",t.timestamp!==!1);(0,Pl.saveAs)(h,y),p();}else m(new Error("Failed to create PNG blob"));o&&URL.revokeObjectURL(o);},"image/png",1);}catch(x){o&&URL.revokeObjectURL(o),m(x);}},f.onerror=()=>{clearTimeout(g),o&&URL.revokeObjectURL(o),m(new Error("Failed to load SVG as image"));},f.src=o;})}catch(n){throw o&&URL.revokeObjectURL(o),new Error(`PNG export failed: ${n instanceof Error?n.message:"Unknown error"}`)}}function xP(e){if(typeof window>"u")return false;switch(e){case "csv":return true;case "svg":return typeof XMLSerializer<"u";case "png":return typeof HTMLCanvasElement<"u"&&typeof HTMLCanvasElement.prototype.toBlob=="function";default:return false}}function yP(e){return {csv:"CSV Spreadsheet",svg:"SVG Vector Image",png:"PNG Image"}[e]||"Unknown Format"}function Rl({datasets:e,metadata:t,svgRef:r}){return qe.useCallback(async o=>{try{await dp(o,e,t,r);}catch(n){throw console.error("Chart export failed:",n),n}},[e,t,r])}var up=({data:e,seriesMetadata:t,width:r,height:o,onBrushChange:n,brushRegion:a,margin:i=He,yDomain:s})=>{let l=qe.useRef(null),c=qe.useRef(false),d=qe.useMemo(()=>e.flat(),[e]),u=qe.useMemo(()=>({top:10,bottom:15,left:i.left,right:i.right}),[i]),p=r-u.left-u.right,m=qe.useMemo(()=>{if(d.length===0)return scale.scaleTime({domain:[new Date,new Date],range:[0,p]});let h=new Date(Math.min(...d.map(v=>v.xValue.getTime()))),y=new Date(Math.max(...d.map(v=>v.xValue.getTime())));return scale.scaleTime({domain:[h,y],range:[0,p]})},[d,p]),f=qe.useMemo(()=>{let h=d.length>0?Math.max(0,...d.map(y=>y.yValue)):1;return scale.scaleLinear({domain:s??[0,h],range:[o-u.bottom,u.top]})},[d,o,s,u.top,u.bottom]),g=h=>{if(c.current)return;if(!h){n(null);return}let{x0:y,x1:v}=h;if(y===v)return;let S=new Date(y),w=new Date(v);if(!(Number.isNaN(S.getTime())||Number.isNaN(w.getTime()))){if(d.length>0){let N=Math.min(...d.map(T=>T.xValue.getTime())),R=Math.max(...d.map(T=>T.xValue.getTime())),E=(R-N)*.05;if(Math.abs(S.getTime()-N)<E&&Math.abs(w.getTime()-R)<E){n(null);return}}n([S,w]);}},x=qe.useMemo(()=>{if(d.length!==0)return {start:{x:0,y:u.top},end:{x:p,y:o-u.bottom}}},[p,o,d]);qe.useEffect(()=>{if(!l.current||d.length===0)return;let h=l.current.state;if(h?.isBrushing||h?.activeHandle)return;let y=Math.min(...d.map(P=>P.xValue.getTime())),v=Math.max(...d.map(P=>P.xValue.getTime())),S=a?a[0]:new Date(y),w=a?a[1]:new Date(v),N=l.current.state?.extent;if(N){let P=m.invert(N.x0),E=m.invert(N.x1),I=Math.abs(P.getTime()-S.getTime()),T=Math.abs(E.getTime()-w.getTime());if(I<1e3&&T<1e3)return}c.current=true;let R=P=>{let E=l.current.getExtent({x:m(S),y:u.top},{x:m(w),y:o-u.bottom});return {...P,start:{y:E.y0,x:E.x0},end:{y:E.y1,x:E.x1},extent:E}};l.current.updateBrush(R),setTimeout(()=>{c.current=false;},50);},[a,m,o,d]);let b={fill:"url(#brush_pattern)",fillOpacity:.15,stroke:"var(--color-border-focus)",strokeWidth:1.5,strokeOpacity:.3};return jsxRuntime.jsx("div",{className:"mt-2",children:jsxRuntime.jsxs("svg",{width:r,height:o,children:[jsxRuntime.jsx(pattern.PatternLines,{id:"brush_pattern",height:8,width:8,stroke:"var(--color-text-secondary)",strokeWidth:1,orientation:["diagonal"]}),jsxRuntime.jsxs("g",{transform:`translate(${u.left}, 0)`,children:[e.map((h,y)=>jsxRuntime.jsx(shape.LinePath,{data:h,x:v=>m(v.xValue),y:v=>f(v.yValue),stroke:t[y]?.color||"var(--color-gray-500)",strokeWidth:1.5,opacity:.8},`brush-series-${y}`)),jsxRuntime.jsx(brush.Brush,{xScale:m,yScale:f,width:p,height:o-u.top-u.bottom,margin:{top:u.top,bottom:u.bottom,left:0,right:0},handleSize:8,innerRef:l,resizeTriggerAreas:["left","right"],brushDirection:"horizontal",initialBrushPosition:x,onChange:g,onClick:()=>n(null),selectedBoxStyle:b,useWindowMoveEvents:true})]})]})})};function zo(e){switch(e){case "command":return Vt("--color-action-brand","#111111");case "success":return Vt("--color-feedback-success-border","#278a4a");case "warning":return Vt("--color-feedback-warning-border","#c88420");case "error":return Vt("--color-feedback-error-border","#c42d2d");case "alert":return Vt("--color-feedback-warning-border","#c88420");default:return Vt("--color-text-secondary","#525250")}}function Ml({events:e,color:t,showLabels:r=false}){let o=qe.useContext(Jr),[n,a]=qe.useState(null);if(!o)return console.warn("ChartEventMarkers must be used within a ChartContainer"),null;let{xScale:i,yScale:s,height:l,tooltip:c,datasets:d,seriesMetadata:u,seriesTypes:p,categoryColors:m}=o,f=e.filter(b=>{let h=i(b.timestamp);return h>=He.left&&h<=i.range()[1]}),g=qe.useCallback((b,h)=>{a(h);let y=i(b.timestamp),v=y>(i.range()[1]-He.right-He.left)/2+He.left,S=[];d&&u&&d.forEach((R,P)=>{if(R.length===0)return;let E=d3Array.bisector(B=>B.xValue).left,I=E(R,b.timestamp),T=R[I-1],D=R[I],M;if(!T)M=D;else if(!D)M=T;else {let B=Math.abs(b.timestamp.getTime()-T.xValue.getTime()),z=Math.abs(b.timestamp.getTime()-D.xValue.getTime());M=B<z?T:D;}M&&u[P]&&S.push({label:u[P].label,value:M.yValue,color:u[P].color,type:p?.[P]||"line",...M.category&&{category:M.category,categoryColor:m?.[M.category]}});});let N=f.filter(R=>Math.abs(i(R.timestamp)-y)<=10).map(R=>({label:R.label,color:t||zo(R.type),metadata:R.metadata}));S.push({label:N.length>1?`${N.length} events`:b.label,value:0,color:t||zo(b.type),type:"event"}),c.show({xValue:b.timestamp,series:S,x:y,y:S.length>1&&typeof S[0].value=="number"?s(S[0].value):l/2,position:v?"left":"right",isEvent:true,eventMetadata:b.metadata,eventItems:N});},[i,s,l,c,t,d,u,p,m,f]),x=qe.useCallback(()=>{a(null),c.hide();},[c]);return f.length===0?null:jsxRuntime.jsx("g",{className:"chart-event-markers","data-testid":"chart-event-markers",children:f.map((b,h)=>{let y=i(b.timestamp),v=t||zo(b.type),S=n===h;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:y,y1:He.top,x2:y,y2:l-He.bottom,stroke:v,strokeWidth:S?3:2,strokeDasharray:"4 4",strokeOpacity:S?.9:.6,pointerEvents:"none"}),jsxRuntime.jsx("circle",{cx:y,cy:He.top,r:S?5:4,fill:v,stroke:"var(--color-background-surface)",strokeWidth:2,pointerEvents:"none"}),jsxRuntime.jsx("circle",{cx:y,cy:l-He.bottom,r:S?5:4,fill:v,stroke:"var(--color-background-surface)",strokeWidth:2,pointerEvents:"none"}),r&&jsxRuntime.jsx("text",{x:y,y:He.top-8,textAnchor:"middle",fill:"var(--color-text-secondary)",fontSize:11,fontWeight:500,pointerEvents:"none",children:b.label}),jsxRuntime.jsx("rect",{x:y-10,y:He.top,width:20,height:l-He.top-He.bottom,fill:"transparent",style:{cursor:"pointer"},onMouseEnter:()=>g(b,h),onMouseLeave:x})]},`${b.timestamp.getTime()}-${h}`)})})}function Ll({spans:e,opacity:t=.25,color:r}){let o=qe.useContext(Jr),[n,a]=qe.useState(null),i=o?.xScale,s=o?.height,l=o?.tooltip,[c,d]=i?.domain()??[new Date(0),new Date(0)],[u,p]=i?.range()??[0,0],m=qe.useCallback((S,w)=>{if(!i||!l)return;a(w);let N=S.start<c?c:S.start,R=S.end>d?d:S.end,P=(i(N)+i(R))/2,E=P>(p-u)/2+u,T=e.filter(D=>D.end>D.start&&D.start<S.end&&D.end>S.start).map(D=>({label:D.label,color:D.color??r??zo(D.type),metadata:D.metadata}));l.show({xValue:S.start,series:[{label:T.length>1?`${T.length} scheduled commands`:S.label,value:0,color:S.color??r??zo(S.type),type:"event"}],x:P,y:(s??0)/2,position:E?"left":"right",isEvent:true,eventMetadata:S.metadata,eventItems:T});},[i,s,l,r,c,d,u,p,e]),f=qe.useCallback(()=>{a(null),l?.hide();},[l]);if(!o)return console.warn("ChartEventSpans must be used within a ChartContainer"),null;let{xScale:g,height:x}=o,b=He.top,y=x-He.bottom-b,v=e.filter(S=>S.end>S.start);return v.length===0?null:jsxRuntime.jsx("g",{className:"chart-event-spans","data-testid":"chart-event-spans",children:v.map((S,w)=>{let N=S.start<c?c:S.start,R=S.end>d?d:S.end;if(N>=d||R<=c)return null;let P=g(N),I=g(R)-P;if(I<=0)return null;let T=S.color??r??zo(S.type);return jsxRuntime.jsx("rect",{x:P,y:b,width:I,height:y,fill:T,fillOpacity:n===w?Math.min((t??.25)*1.8,1):t??.25,pointerEvents:"all",style:{cursor:"pointer"},onMouseEnter:()=>m(S,w),onMouseLeave:f},`${S.start.getTime()}-${S.end.getTime()}-${w}`)})})}var rh=qe.createContext(false);function mp({children:e}){return jsxRuntime.jsx(rh.Provider,{value:true,children:e})}function Yn(e){let t=qe.useContext(rh),[r,o]=qe.useState(false),[n,a]=qe.useState(null),i=qe.useRef(null),s=qe.useCallback(u=>{if(i.current?.disconnect(),i.current=null,!u||typeof ResizeObserver>"u")return;let p=new ResizeObserver(([m])=>{if(!m)return;let{width:f,height:g}=m.contentRect;a(x=>x&&x.width===f&&x.height===g?x:{width:f,height:g});});p.observe(u),i.current=p;},[]);qe.useEffect(()=>()=>i.current?.disconnect(),[]);let l=qe.useCallback(()=>{o(false),a(null);},[]),c=t?null:jsxRuntime.jsx($,{variant:"icon",size:"sm",icon:"ArrowsOutSimple","aria-label":`Expand ${e} chart`,onPress:()=>o(true)}),d=qe.useCallback(u=>r&&!t?jsxRuntime.jsx(cr,{isOpen:true,onClose:l,title:e,contentPadding:false,maxWidth:"min(1200px, 100vw)",minWidth:"min(360px, 100vw)",height:"82vh",mobileHeight:"82vh",children:jsxRuntime.jsx("div",{ref:s,className:"h-full w-full p-4",children:u})}):u,[r,t,l,e,s]);return {isExpanded:r,action:c,expandedSize:n,present:d}}var Jn=({data:e,color:t="var(--color-viz-default)",strokeWidth:r=3,strokeDasharray:o,categoryColors:n={},maxGapMs:a,animate:i=true})=>{let{xScale:s,yScale:l,animationSettings:c,entrance:d}=Kn(),[u]=qe__namespace.default.useState(()=>d?.played!==true),p=i&&u,m=l.range(),f=Object.keys(n).length>0,g=w=>w.category?n[w.category]??t:t,x=w=>w.chartYValue??w.yValue,b=e.length===1?e[0]:void 0,h=a!=null?Sl(e,a):e,y=i?void 0:"non-scaling-stroke",v=b?jsxRuntime.jsx("circle",{cx:s(b.xValue),cy:l(x(b)),r,fill:f?g(b):t}):f?e.slice(0,-1).map((w,N)=>{let R=e[N+1];return a!=null&&a>0&&R.xValue.getTime()-w.xValue.getTime()>a?null:jsxRuntime.jsx(shape.LinePath,{data:[w,R],x:P=>s(P.xValue),y:P=>l(x(P)),stroke:g(w),strokeWidth:r,strokeDasharray:o,strokeLinecap:"round",vectorEffect:y,curve:curve.curveLinear},`${w.xValue.getTime()}-${R.xValue.getTime()}`)}):jsxRuntime.jsx(shape.LinePath,{data:h,x:w=>w?s(w.xValue):0,y:w=>w?l(x(w)):0,defined:w=>w!=null,stroke:t,strokeWidth:r,strokeDasharray:o,strokeLinecap:"round",vectorEffect:y,curve:curve.curveLinear}),S={transformOrigin:`0 ${m[0]}px`,transformBox:"fill-box",isolation:"isolate"};return p?jsxRuntime.jsx(framerMotion.motion.g,{initial:{scaleY:0},animate:{scaleY:1},transition:{duration:c.duration,ease:c.ease},style:S,children:v}):jsxRuntime.jsx("g",{style:S,children:v})};var lh=e=>e.type===pn||e.type===Jn||e.type===Nl,KP=e=>e.type===Ml||e.type===Ll,YP=(e,t,r)=>{if(!e.tooltipRange||e.baseline===void 0)return;let o=typeof e.baseline=="function"?e.baseline(t,r):e.baseline;return typeof o=="number"&&Number.isFinite(o)&&o!==t.yValue?o:void 0},JP=d3Array.bisector(e=>e.xValue).left,XP=()=>jsxRuntime.jsx("div",{className:"flex h-full items-center justify-center",children:jsxRuntime.jsx("p",{className:"text-text-secondary",children:"No data available"})}),jP=()=>jsxRuntime.jsxs("div",{className:"flex h-full flex-col gap-4 p-4",children:[jsxRuntime.jsx(X,{className:"h-full w-full"}),jsxRuntime.jsxs("div",{className:"flex gap-4",children:[jsxRuntime.jsx(X,{className:"h-4 w-24"}),jsxRuntime.jsx(X,{className:"h-4 w-24"})]})]}),qP=({parentWidth:e,parentHeight:t,yFormatter:r={type:"number"},yDomain:o,referenceLines:n,isLoading:a=false,enableZoom:i=false,enableBrush:s=false,brushHeight:l=60,onZoomChange:c,zoomDomain:d,hiddenSeriesLabels:u,onHiddenSeriesChange:p,hideBottomBar:m=false,headerActions:f,headerControls:g,title:x,children:b})=>{let h=u!==void 0,y=d!==void 0,[v,S]=qe.useState(null),[w,N]=qe.useState(null),R=y?d:w,[P,E]=qe.useState(()=>new Set),I=h?u:P,T=qe.useRef(null),D=qe.useId(),M=qe.useRef(0),B=qe.useRef(""),z=qe.useRef(null),{colorMode:V}=jt(),U=qe.useMemo(()=>Fo(),[V]),Z=qe.useMemo(()=>Ci(),[V]),{datasets:G,seriesMetadata:J,categoryInfo:W,categoryColors:A,categoryLabels:Y,seriesTypes:k}=qe.useMemo(()=>{let me=qe.Children.toArray(b).filter(Ie=>qe.isValidElement(Ie)&&lh(Ie)),Be=me.filter(Ie=>Ie.props.data).length,Re=[],Oe=[],tt=[],pt=null,Ae=null;me.forEach((Ie,kt)=>{let Fe=Ie.props;if(!Fe.data)return;Re.push(Fe.data);let ka=("color"in Fe&&Fe.color?Fe.color:void 0)||(Be===1?Z:U[kt%U.length]),Rn=Ie.type===pn;Oe.push({label:"label"in Fe&&Fe.label||`Series ${Re.length}`,color:ka,...Rn&&"baseline"in Fe&&Fe.baseline!==void 0?{baseline:Fe.baseline,tooltipRange:"tooltipRange"in Fe&&Fe.tooltipRange||false}:{}});let Nd=Rn?"area":Ie.type===Jn?"line":"bar";tt.push(Nd),"categoryColors"in Fe&&Fe.categoryColors&&(pt=Fe.categoryColors),"categoryLabels"in Fe&&Fe.categoryLabels&&(Ae=Fe.categoryLabels);});let ct=null;if(pt){let Ie=new Set;Re.forEach(kt=>{kt.forEach(Fe=>{Fe.category&&Ie.add(Fe.category);});}),ct=Array.from(Ie).map(kt=>({label:Ae?.[kt]||kt,color:pt[kt]||"#6b7280"}));}return {datasets:Re,seriesMetadata:Oe,categoryInfo:ct,categoryColors:pt,categoryLabels:Ae,seriesTypes:tt}},[b,Z,U,V]),C=Yn(x),L=C.expandedSize?.width??e,F=C.expandedSize?.height??t,ne=!m?C.action:null,ce=f||ne?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[f,ne]}):void 0,{headerRef:ee,headerHeight:ae}=Fa(!!ce,!!g),Le=m?0:60,ge=s?l+8:0,xe=F-ae-Le-ge,re=Math.max(100,xe),ie=qe.useCallback(q=>q?I.has(q):false,[I]),ve=qe.useMemo(()=>J.map((q,me)=>ie(q.label)?null:me).filter(q=>q!==null),[J,ie]),Xe=qe.useMemo(()=>ve.map(q=>G[q]).filter(q=>!!q),[G,ve]),Qe=qe.useMemo(()=>ve.map(q=>J[q]).filter(q=>!!q),[J,ve]),wr=qe.useMemo(()=>ve.map(q=>k[q]).filter(q=>!!q),[k,ve]),Dt=wr.findIndex(q=>q==="bar"),Nr=Dt!==-1,kr=qe.useCallback((q,me)=>{let Be=q.has(me);if(!Be&&J.reduce((tt,pt)=>q.has(pt.label)||pt.label===me?tt:tt+1,0)<1)return q;let Re=new Set(q);return Be?Re.delete(me):Re.add(me),Re},[J]),xt=qe.useCallback(q=>{if(h){let me=u;if(!me.has(q)&&J.reduce((Oe,tt)=>me.has(tt.label)||tt.label===q?Oe:Oe+1,0)<1){S(null);return}p?.(Re=>kr(Re,q));}else E(me=>kr(me,q));S(null);},[h,u,p,J,kr]),Zt=qe.useMemo(()=>J.map(q=>q.label).join(""),[J]),_=qe.useRef(Zt);qe.useEffect(()=>{_.current!==Zt&&(_.current=Zt,h||E(q=>q.size===0?q:new Set));},[Zt,h]);let Ge=qe.useMemo(()=>Xe.flat(),[Xe]),_e=qe.useMemo(()=>{if(Ge.length===0)return null;let q=[...Ge].sort((me,Be)=>me.xValue.getTime()-Be.xValue.getTime());return [q[0].xValue,q[q.length-1].xValue]},[Ge]),ke=R||_e,K=qe.useCallback(q=>{y?c?.(q):N(q);},[y,c]),H=qe.useMemo(()=>ke?G.map(me=>me.filter(Be=>Be.xValue>=ke[0]&&Be.xValue<=ke[1])):G,[G,ke]),de=qe.useMemo(()=>ve.map(q=>H[q]??[]),[ve,H]);qe.useEffect(()=>{c&&c(R);},[R,c]);let se=qe.useMemo(()=>ve.flatMap(q=>H[q]??[]),[H,ve]),ue=qe.useMemo(()=>Hi(se,re,r,o),[se,re,r,o]),Te=qe.useRef(JSON.stringify(r)),$e=qe.useRef(null),te=qe.useMemo(()=>{let[q,me]=ue.domain(),Be=Math.max(Math.abs(q),Math.abs(me)),Re=JSON.stringify(r);if(Re!==Te.current&&(Te.current=Re,$e.current=null),$e.current!==null)return $e.current;if(Be===0)return Xa(r,0);let Oe=Xa(r,Be);return $e.current=Oe,Oe},[ue,r]),pe=qe.useMemo(()=>{let q=re-He.top-He.bottom;return qa(q)},[re]),Q=qe.useMemo(()=>{let q=Dr(te),me=q.tickFormat||q.format,Re=ue.ticks(pe).map(pt=>me(pt)),Oe=ja(Re,12,"system-ui"),tt=Math.ceil(Oe)+12;return {...He,left:Math.max(tt,30),right:8}},[ue,te,pe]),De=qe.useMemo(()=>ke?scale.scaleTime({domain:ke,range:[Q.left,L-Q.right]}):op(Ge,L),[ke,Ge,L,Q]),mo=qe.useCallback(q=>{if(!_e)return;let{scaleX:me,translateX:Be}=q,Re=L-Q.left-Q.right,[Oe,tt]=_e,pt=tt.getTime()-Oe.getTime();if(pt<=0){K(null);return}let Ae=-Be,ct=Ae+Re,Ie=Re*me/pt,kt=Ae/Ie,Fe=ct/Ie,Pn=new Date(Oe.getTime()+kt),ka=new Date(Oe.getTime()+Fe),Rn=Math.abs(Pn.getTime()-Oe.getTime()),Nd=Math.abs(ka.getTime()-tt.getTime()),ef=pt*.02;Rn<ef&&Nd<ef?K(null):K([Pn,ka]);},[_e,L,Q,K]),Is=qe.useCallback(q=>{let{left:me}=T.current?.getBoundingClientRect()||{left:0},Be=q.clientX-me;if(q.timeStamp-(M.current||0)<16)return;M.current=q.timeStamp;let Re=De.invert(Be),Oe=de.map((Ae,ct)=>{if(!Ae||Ae.length===0)return null;let Ie=JP(Ae,Re,1);if(Ie===0)return {point:Ae[0],index:0,datasetIndex:ct};if(Ie>=Ae.length)return {point:Ae[Ae.length-1],index:Ae.length-1,datasetIndex:ct};let kt=Ae[Ie-1],Fe=Ae[Ie];if(!kt||!Fe)return null;let Pn=Math.abs(kt.xValue.getTime()-Re.getTime()),ka=Math.abs(Fe.xValue.getTime()-Re.getTime()),Rn=Pn<ka;return {point:Rn?kt:Fe,index:Rn?Ie-1:Ie,datasetIndex:ct}}).filter(Ae=>Ae!==null&&Qe[Ae.datasetIndex]!==void 0).map(({point:Ae,index:ct,datasetIndex:Ie})=>({label:Qe[Ie].label,value:Ae.yValue,baselineValue:YP(Qe[Ie],Ae,ct),color:Qe[Ie].color,point:Ae,type:wr[Ie]}));if(Oe.length===0){S(null);return}let tt=De(Oe[0].point.xValue),pt=tt>(L-Q.right-Q.left)/2+Q.left;S({xValue:Oe[0].point.xValue,series:Oe.map(({label:Ae,value:ct,baselineValue:Ie,color:kt,point:Fe,type:Pn})=>({label:Ae,value:ct,...Ie!==void 0?{baselineValue:Ie}:{},chartY:Fe.chartYValue??ct,showMarker:Fe.showTooltipMarker??true,color:kt,type:Pn,category:Fe.category,categoryColor:Fe.category&&A?A[Fe.category]:void 0,...Fe.extraTooltipRows&&Fe.extraTooltipRows.length>0?{extraTooltipRows:Fe.extraTooltipRows}:{}})),x:tt,y:ue(Oe[0].point.chartYValue??Oe[0].value),position:pt?"left":"right"});},[de,Qe,wr,De,ue,L,A,Q]),Io=()=>{S(null);},a0=qe.useCallback(()=>{K(null),z.current&&z.current.reset();},[K]),i0=qe.useCallback(q=>{let me={scaleX:1,scaleY:1,translateX:0,translateY:0,skewX:0,skewY:0};if(!q||!_e)return me;let[Be,Re]=_e,Oe=Re.getTime()-Be.getTime();if(Oe<=0)return me;let[tt,pt]=q,Ae=pt.getTime()-tt.getTime();if(Ae<=0)return me;let ct=Oe/Ae,Ie=L-Q.left-Q.right,kt=tt.getTime()-Be.getTime();return {scaleX:ct,scaleY:1,translateX:-(kt/Oe)*Ie*ct,translateY:0,skewX:0,skewY:0}},[_e,L,Q]),Fs=qe.useCallback(q=>{if(!(z.current&&_e))return;let[me,Be]=_e,Re=Be.getTime()-me.getTime();if(Re<=0){z.current.reset();return}if(!q){z.current.reset();return}let[Oe,tt]=q,pt=tt.getTime()-Oe.getTime();if(pt<=0){z.current.reset();return}let Ae=Re/pt,ct=L-Q.left-Q.right,kt=-((Oe.getTime()-me.getTime())/Re)*ct*Ae;z.current.setTransformMatrix({scaleX:Ae,scaleY:1,translateX:kt,translateY:0,skewX:0,skewY:0});},[_e,L,Q]),s0=qe.useCallback(q=>{K(q),Fs(q);},[K,Fs]);qe.useEffect(()=>{y&&Fs(d??null);},[y,d,Fs]);let l0=Cl(),c0={width:L,height:re,xScale:De,yScale:ue,yFormatter:te,animationSettings:vl,entrance:l0,tooltip:{data:v,show:S,hide:()=>S(null)},datasets:de,seriesMetadata:Qe,seriesTypes:wr,categoryColors:A||void 0,categoryLabels:Y||void 0},d0=qe.Children.toArray(b),Qm=0,Zm=[],_m=[],Sd=[];d0.forEach(q=>{if(!qe.isValidElement(q)){Sd.push(q);return}if(KP(q))_m.push(q);else if(lh(q)){let me=Qm;Qm++;let Be=q.props,Re=J[me]?.label;if(ie(Re))return;Zm.push(qe__namespace.default.cloneElement(q,{...Be,data:H[me]||Be.data,color:J[me]?.color}));}else Sd.push(q);});let u0=ve.length,p0=(W||J).map(q=>{let me=!W&&ie(q.label);return {category:q.label,fill:q.color,isHidden:me,isDisabled:!W&&!me&&u0<=1}}),m0=typeof r=="object"&&r!==null&&typeof r.type=="string",f0=Rl({datasets:Xe,metadata:{xLabel:"Date",yLabel:"Value",seriesLabels:Qe.map(q=>q.label),timestamp:true,...m0?{yFormat:r}:{}},svgRef:T}),wd=jsxRuntime.jsx(Ba,{title:x,controls:g,actions:ce,containerRef:ee,marginRight:Q.right});if(a)return C.present(jsxRuntime.jsxs("div",{className:"relative flex h-full flex-col",children:[wd,jsxRuntime.jsx(jP,{})]}));if(G.length===0)return C.present(jsxRuntime.jsxs("div",{className:"relative flex h-full flex-col",children:[wd,jsxRuntime.jsx(XP,{})]}));let $m=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("title",{children:x}),jsxRuntime.jsx("g",{children:ue.ticks(pe).map(q=>{let me=Math.abs(q)<Number.EPSILON;return jsxRuntime.jsx(shape.Line,{from:{x:Q.left,y:ue(q)},to:{x:L-Q.right,y:ue(q)},stroke:me?"var(--color-border-default)":"var(--color-border-muted)",strokeWidth:me?1.5:1},`grid-line-${q}`)})}),jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:D,children:jsxRuntime.jsx("rect",{x:De.range()[0],y:ue.range()[1],width:De.range()[1]-De.range()[0],height:ue.range()[0]-ue.range()[1]})})}),jsxRuntime.jsx("g",{clipPath:`url(#${D})`,children:Zm}),Sd,n&&n.length>0&&jsxRuntime.jsx("g",{children:n.map(q=>{let me=ue(q.value),Be=q.color??"var(--color-error-base)";return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx(shape.Line,{from:{x:Q.left,y:me},to:{x:L-Q.right,y:me},stroke:Be,strokeWidth:1.5,strokeDasharray:"6 4"}),q.label&&jsxRuntime.jsx("text",{x:L-Q.right-4,y:me-4,textAnchor:"end",fontSize:11,fill:Be,children:q.label})]},`ref-line-${q.value}`)})}),jsxRuntime.jsx(Xr.Bottom,{top:re-Q.bottom,scale:De,width:L-Q.left-Q.right}),jsxRuntime.jsx(Xr.Left,{left:Q.left,scale:ue,yFormatter:te,height:re-Q.top-Q.bottom}),v&&!v.isEvent&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[Nr?(()=>{let q=Xe[Dt]??[];if(q.length===0)return null;let me=[...q].sort((Ie,kt)=>Ie.xValue.getTime()-kt.xValue.getTime()),Be=me.findIndex(Ie=>Ie.xValue.getTime()===v.xValue.getTime()),Re=me[Be+1],Oe=me.length>1&&Re?Re.xValue.getTime()-v.xValue.getTime():15*6e4,tt=Math.abs(De(new Date(v.xValue.getTime()+Oe))-De(v.xValue)),Ae=De(v.xValue)-tt/2,ct=ue.range();return jsxRuntime.jsx("rect",{x:Ae,y:ct[1],width:tt,height:ct[0]-ct[1],className:"fill-background-muted",opacity:.5,pointerEvents:"none",style:{transition:"all 100ms ease-out"}})})():null,v.series.filter(q=>q.type!=="bar"&&q.showMarker!==false).map(q=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("circle",{cx:De(v.xValue),cy:ue(q.chartY??q.value),r:8,fill:"white",stroke:q.color,strokeWidth:2,style:{transition:"all 100ms ease-out"}}),jsxRuntime.jsx("circle",{cx:De(v.xValue),cy:ue(q.chartY??q.value),r:4,fill:q.color,style:{transition:"all 100ms ease-out"}})]},`highlight-${q.label}`))]}),jsxRuntime.jsx("rect",{x:Q.left,y:Q.top,width:L-Q.left-Q.right,height:re-Q.top-Q.bottom,fill:"transparent",style:{cursor:i?"grab":"crosshair",touchAction:"none"},onMouseMove:Is,onMouseLeave:Io}),_m]});return C.present(jsxRuntime.jsx("div",{className:"relative flex h-full flex-col",children:jsxRuntime.jsxs(Jr.Provider,{value:c0,children:[wd,i?jsxRuntime.jsx(zoom.Zoom,{initialTransformMatrix:i0(R),width:L,height:re,scaleXMin:1,scaleXMax:20,scaleYMin:1,scaleYMax:1,constrain:q=>{let{scaleX:me,translateX:Be}=q,Re=Math.max(1,Math.min(20,me)),Oe=1,tt=L-Q.left-Q.right,pt=0,Ae=tt*(1-Re),ct=Math.max(Ae,Math.min(pt,Be));return {...q,scaleX:Re,scaleY:Oe,translateX:ct,translateY:0}},children:q=>{if(z.current=q,q.transformMatrix){let{scaleX:me,translateX:Be}=q.transformMatrix,Re=`${me.toFixed(4)}-${Be.toFixed(2)}`;Re!==B.current&&(B.current=Re,setTimeout(()=>{mo(q.transformMatrix);},0));}return jsxRuntime.jsx("svg",{width:L,height:re,className:"overflow-visible",ref:me=>{T.current=me,q.containerRef.current!==me&&(q.containerRef.current=me);},role:"img","aria-label":x,style:{cursor:q.isDragging?"grabbing":"grab",touchAction:"none"},onMouseDown:q.dragStart,onMouseMove:q.dragMove,onMouseUp:q.dragEnd,onMouseLeave:()=>{q.isDragging&&q.dragEnd();},onTouchStart:q.dragStart,onTouchMove:q.dragMove,onTouchEnd:q.dragEnd,children:$m})}},`zoom-${Math.round(L)}x${Math.round(re)}`):jsxRuntime.jsx("svg",{width:L,height:re,className:"overflow-visible",ref:T,role:"img","aria-label":x,children:$m}),jsxRuntime.jsx(Co,{data:v,formatter:te}),s&&_e&&jsxRuntime.jsx(up,{data:Xe,seriesMetadata:Qe,width:L,height:l,onBrushChange:s0,brushRegion:R,margin:Q,...o?{yDomain:o}:{}}),!m&&jsxRuntime.jsx(Za,{onExport:f0,items:p0,marginLeft:0,marginRight:Q.right,isZoomed:R!==null,onResetZoom:a0,onLegendItemToggle:W?void 0:xt})]})}))},ch=responsive.withParentSize(qP);var t1=e=>e.toLocaleString(),r1=e=>`${Math.round(e*100)}%`,mh=({data:e,width:t=800,height:r=400,padding:o=0,barGap:n=30,formatValue:a=t1,formatPercentage:i=r1,color:s,showScale:l=true,showOverallConversion:c=true,overallConversionLabel:d="Overall Conversion:",activeStageId:u,onStageClick:p,onStageHover:m,className:f,style:g,"aria-label":x="Funnel chart"})=>{let[b,h]=qe.useState(null),[y,v]=qe.useState(t),S=qe.useRef(null),w=u??b,N=qe.useId(),R=s||"var(--color-viz-default)";qe.useEffect(()=>{if(!S.current)return;let M=new ResizeObserver(B=>{for(let z of B)v(z.contentRect.width);});return M.observe(S.current),()=>{M.disconnect();}},[]);let{layout:P,overallConversion:E}=qe.useMemo(()=>{if(e.length===0)return {layout:[],overallConversion:0};let M=e[0].value,B=c?60:0,z=r-o*2-B,V=(e.length-1)*n,U=(z-V)/e.length,Z=e.map((J,W)=>{let A=o+B+W*(U+n),Y=M===0?0:J.value/M,k=Y,C=W===0?null:e[W-1].value,L=C==null||C===0?0:1-J.value/C;return {stage:J,index:W,y:A,barHeight:U,widthPercent:Y,conversionRate:k,dropOff:L}}),G=M===0?0:e[e.length-1].value/M;return {layout:Z,overallConversion:G,maxValue:M}},[e,y,r,o,n,l,c]);if(e.length===0)return jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex h-full min-h-[280px] w-full items-center justify-center rounded-lg border border-dashed border-border-default bg-background-surface text-sm font-medium text-text-secondary",f),style:{width:t,height:r,...g},children:"No funnel data available"});let I=l?60:0,T=o+I,D=y-o*2-I;return jsxRuntime.jsx("div",{ref:S,className:tailwindMerge.twMerge("relative w-full overflow-hidden rounded-lg bg-background-surface",f),style:{height:r,...g},"aria-label":x,role:"img",children:jsxRuntime.jsxs("svg",{width:"100%",height:r,className:"relative",children:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsx(gradient.LinearGradient,{id:`${N}-bar`,from:R,to:R,toOpacity:.85}),jsxRuntime.jsx(gradient.LinearGradient,{id:`${N}-bg`,from:R,to:R,fromOpacity:.01,toOpacity:.15,x1:"0",y1:"0",x2:"1",y2:"0"})]}),c&&jsxRuntime.jsxs("text",{x:T,y:o+20,className:"fill-text-primary text-sm font-medium",children:[jsxRuntime.jsx("tspan",{className:"fill-text-secondary",children:d})," ",i(E)]}),l&&jsxRuntime.jsx("g",{children:P.map(M=>{let B=M.y+M.barHeight/2;return jsxRuntime.jsx("text",{x:o+I-12,y:B,textAnchor:"end",dominantBaseline:"middle",className:"fill-text-secondary text-xs",children:i(M.conversionRate)},M.stage.id)})}),P.map(M=>{let B=w===M.stage.id,z=D*M.widthPercent;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:T,y:M.y,width:D,height:M.barHeight,fill:`url(#${N}-bg)`,rx:4}),jsxRuntime.jsx(framerMotion.motion.rect,{x:T,y:M.y,width:z,height:M.barHeight,fill:`url(#${N}-bar)`,rx:4,initial:{width:0},animate:{width:z},transition:{duration:.6,delay:M.index*.1,ease:"easeOut"},opacity:B||w==null?1:.5,style:{cursor:p||m?"pointer":"default",transition:"opacity 150ms ease"},onMouseEnter:()=>{h(M.stage.id),m?.(M.stage);},onMouseLeave:()=>{h(null),m?.(null);},onClick:()=>p?.(M.stage)}),jsxRuntime.jsx("rect",{x:T+10,y:M.y+M.barHeight/2-10,width:70,height:20,className:"fill-background-surface stroke-border-default",strokeWidth:1,rx:4,style:{pointerEvents:"none"}}),jsxRuntime.jsx("text",{x:T+16,y:M.y+M.barHeight/2+4,className:"fill-text-primary text-xs font-semibold",style:{pointerEvents:"none"},children:a(M.stage.value)}),jsxRuntime.jsxs("text",{x:T,y:M.y-8,className:"fill-text-secondary text-xs",style:{pointerEvents:"none"},children:[jsxRuntime.jsx("tspan",{children:M.index+1})," ",M.stage.label]}),M.stage.secondaryValue&&jsxRuntime.jsx("text",{x:T+16,y:M.y-24,className:"fill-text-secondary text-xs",style:{pointerEvents:"none"},children:M.stage.secondaryValue}),M.index>0&&M.dropOff>0&&jsxRuntime.jsxs("text",{x:T+D,y:M.y-8,textAnchor:"end",className:"fill-text-secondary text-xs",children:[i(M.dropOff)," drop"]}),M.stage.annotation&&jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:T+z+8,y:M.y+8,width:60,height:24,rx:3,className:"fill-background-muted"}),jsxRuntime.jsx("text",{x:T+z+16,y:M.y+20,className:"fill-text-secondary text-xs font-medium",children:M.stage.annotation})]})]},M.stage.id)})]})})};var s1=.005,bh=320;function Al(e){return e>0?e:0}function l1(e,t,r){let o=t===0?0:Al(e.value)/t*100;return `${e.label}: ${r(e.value)}, ${o.toFixed(1)}%`}var hh=({data:e,width:t,height:r,innerRadiusRatio:o=0,yFormatter:n={type:"number"},showLegend:a=true,showTooltip:i=true,onSliceClick:s,onSliceHover:l,className:c,style:d,"aria-label":u})=>{let[p,m]=qe.useState(null),[f,g]=qe.useState(null),[x,b]=qe.useState(null),[h,y]=qe.useState(t??600),[v,S]=qe.useState(r??300),w=qe.useRef(null);qe.useEffect(()=>{if(t!==void 0&&r!==void 0){y(t),S(r);return}if(!w.current)return;let V=new ResizeObserver(U=>{for(let Z of U)t===void 0&&y(Z.contentRect.width),r===void 0&&S(Z.contentRect.height);});return V.observe(w.current),t===void 0&&y(w.current.offsetWidth),r===void 0&&S(w.current.offsetHeight||300),()=>{V.disconnect();}},[t,r]);let N=qe.useMemo(()=>e.reduce((V,U)=>V+Al(U.value),0),[e]),R=qe.useMemo(()=>{let V=Si(e.map(U=>U.label));return e.map(U=>({...U,color:U.color||V[U.label]||"var(--color-viz-default)"}))},[e]),P=Dr(n),E=s!==void 0,I=a&&h>=bh,T=I?Math.max(h*.45,bh*.45):h,M=Math.max(0,Math.min(T,v)-8)/2,B=M*Math.min(Math.max(o,0),.95);if(e.length===0||N===0)return jsxRuntime.jsx("div",{ref:w,className:tailwindMerge.twMerge("flex h-full min-h-[200px] w-full items-center justify-center rounded-lg border border-dashed border-border-default bg-background-surface text-sm font-medium text-text-secondary",c),style:r!==void 0?{height:r,...d}:d,children:"No data available"});let z=(V,U,Z)=>{if(m(V),l?.(U,V),V!==null&&U&&Z){let G=T/2+Z[0],J=v/2+Z[1];b(U.label),g({xValue:new Date,series:[{label:"Value",value:U.value,color:U.color||"var(--color-viz-default)"}],x:G,y:J,position:G>h/2?"left":"right"});}else g(null),b(null);};return jsxRuntime.jsxs("div",{ref:w,className:tailwindMerge.twMerge("relative flex h-full w-full items-center gap-4 rounded-lg bg-background-surface",c),style:r!==void 0?{height:r,...d}:d,children:[jsxRuntime.jsx("svg",{width:T,height:v,className:"flex-shrink-0",role:E?"group":"img","aria-label":u,children:jsxRuntime.jsx(group.Group,{top:v/2,left:T/2,children:jsxRuntime.jsx(shape.Pie,{data:R,pieValue:V=>Al(V.value),pieSort:null,pieSortValues:null,outerRadius:M,innerRadius:B,padAngle:s1,children:V=>V.arcs.map((U,Z)=>{let G=p===Z||p===null,J=V.path.centroid(U);return jsxRuntime.jsx("path",{d:V.path(U)??void 0,fill:U.data.color,opacity:G?1:.5,style:{cursor:s||l?"pointer":"default",transition:"opacity 150ms ease-out"},onMouseEnter:()=>z(Z,U.data,J),onMouseLeave:()=>z(null,null),onClick:()=>s?.(U.data,Z),...E?{role:"button",tabIndex:0,"aria-label":l1(U.data,N,P.format),onFocus:()=>z(Z,U.data,J),onBlur:()=>z(null,null),onKeyDown:W=>{W.key!=="Enter"&&W.key!==" "||(W.preventDefault(),s?.(U.data,Z));}}:{}},U.data.label)})})})}),I?jsxRuntime.jsx("ul",{className:"flex min-w-0 flex-col gap-1 overflow-y-auto py-2 text-xs",children:R.map((V,U)=>jsxRuntime.jsxs("li",{className:"flex items-center gap-2",style:{opacity:p===U||p===null?1:.5},onMouseEnter:()=>z(U,V),onMouseLeave:()=>z(null,null),children:[jsxRuntime.jsx("span",{className:"h-3 w-3 flex-shrink-0 rounded-sm",style:{backgroundColor:V.color}}),jsxRuntime.jsx("span",{className:"truncate text-text-primary",title:V.label,children:V.label}),jsxRuntime.jsxs("span",{className:"ml-auto flex-shrink-0 tabular-nums text-text-secondary",children:[P.format(V.value)," (",(Al(V.value)/N*100).toFixed(1),"%)"]})]},V.label))}):null,i&&jsxRuntime.jsx(Co,{data:f,formatter:n,label:x??void 0})]})};function xh(){let e=new Map;return {publish(t,r){for(let[o,n]of e)o!==t&&n(r);},subscribe(t,r){return e.set(t,r),()=>{e.delete(t);}}}}var d1=d3Array.bisector(e=>e.xValue).left,u1=(e,t,r)=>{if(!e.tooltipRange||e.baseline===void 0)return;let o=typeof e.baseline=="function"?e.baseline(t,r):e.baseline;return typeof o=="number"&&Number.isFinite(o)&&o!==t.yValue?o:void 0};function yh(e){let{mouseX:t,datasets:r,seriesMetadata:o,seriesTypes:n,xScale:a,yScale:i,plotLeft:s,plotRight:l}=e,c=a.invert(t),d=r.map((m,f)=>{if(!m||m.length===0)return null;let g=d1(m,c,1);if(g===0)return {point:m[0],index:0,datasetIndex:f};if(g>=m.length)return {point:m[m.length-1],index:m.length-1,datasetIndex:f};let x=m[g-1],b=m[g];if(!x||!b)return null;let h=Math.abs(x.xValue.getTime()-c.getTime()),y=Math.abs(b.xValue.getTime()-c.getTime()),v=h<y;return {point:v?x:b,index:v?g-1:g,datasetIndex:f}}).filter(m=>m!==null&&o[m.datasetIndex]!==void 0).map(({point:m,index:f,datasetIndex:g})=>({label:o[g].label,value:m.yValue,baselineValue:u1(o[g],m,f),color:o[g].color,point:m,type:n[g]}));if(d.length===0)return null;let u=a(d[0].point.xValue),p=u>(s+l)/2;return {xValue:d[0].point.xValue,series:d.map(({label:m,value:f,baselineValue:g,color:x,point:b,type:h})=>({label:m,value:f,...g!==void 0?{baselineValue:g}:{},chartY:b.chartYValue??f,showMarker:b.showTooltipMarker??true,color:x,type:h,...b.category!==void 0?{category:b.category}:{},...b.extraTooltipRows&&b.extraTooltipRows.length>0?{extraTooltipRows:b.extraTooltipRows}:{}})),x:u,y:i(d[0].point.chartYValue??d[0].value),position:p?"left":"right"}}var Sh=e=>e instanceof Date&&!Number.isNaN(e.getTime()),g1=160;function Il(e,t,r){let[o,n]=qe.useState(null);qe.useImperativeHandle(r,()=>({setPreview:n}),[]);let[a,i]=e.range(),s=qe.useMemo(()=>o?d3Scale.scaleTime().domain([new Date(o[0]),new Date(o[1])]).range([a,i]):e,[o,e,a,i]),l=s.domain(),c=l[0],d=l[l.length-1],u=Sh(c)&&Sh(d),p=t<400,m=Math.max(2,Math.min(8,Math.floor(t/(p?70:110)))),f=qe.useMemo(()=>{if(!u)return [];let g=i-a;if(g<=0)return s.ticks(m);let[x,b]=s.domain(),h=x.getTime(),y=b.getTime(),v=(y-h)/g,S=Math.min(g1,g),w=S*v,N=d3Scale.scaleTime().domain([new Date(h-w),new Date(y+w)]).range([a-S,i+S]),R=d3Time.timeTickInterval(x,b,m);if(R)return N.ticks(R);let P=Math.max(2,Math.round(m*(g+2*S)/g));return N.ticks(P)},[s,m,u,a,i]);return {activeScale:s,ticks:f,start:c,end:d,valid:u,compact:p,rangeStart:a,rangeEnd:i}}var y1=6,wh=20,yp=qe.forwardRef(({top:e,scale:t,width:r},o)=>{let{activeScale:n,ticks:a,start:i,end:s,valid:l,compact:c,rangeStart:d,rangeEnd:u}=Il(t,r,o),p=a.length>=2?a[1].getTime()-a[0].getTime():s.getTime()-i.getTime(),m=qe.useMemo(()=>l?og(p,{compact:c}):()=>"",[p,c,l]),f=qe.useId(),g=Math.min(d,u),x=Math.abs(u-d);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:d,x2:u,y1:e,y2:e,stroke:"var(--color-border-muted)",strokeWidth:1}),a.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:f,children:jsxRuntime.jsx("rect",{x:g,y:e-4,width:x,height:wh+16})})}),jsxRuntime.jsx("g",{clipPath:`url(#${f})`,children:a.map(b=>jsxRuntime.jsxs("g",{transform:`translate(${n(b)},${e})`,children:[jsxRuntime.jsx("line",{x1:0,x2:0,y1:0,y2:y1,stroke:"var(--color-border-muted)",strokeWidth:1}),jsxRuntime.jsx("text",{x:0,y:wh,textAnchor:"middle",fontSize:12,fill:"var(--color-text-secondary)",children:m(b)})]},b.getTime()))})]})]})});yp.displayName="LiveTimeAxisBottom";var vp=qe.forwardRef(({scale:e,width:t,top:r,bottom:o},n)=>{let{activeScale:a,ticks:i,rangeStart:s,rangeEnd:l}=Il(e,t,n),c=qe.useId(),d=Math.min(s,l),u=Math.abs(l-s);return jsxRuntime.jsxs("g",{"aria-hidden":"true",children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:c,children:jsxRuntime.jsx("rect",{x:d,y:r,width:u,height:o-r})})}),jsxRuntime.jsx("g",{clipPath:`url(#${c})`,children:i.map(p=>{let m=a(p);return jsxRuntime.jsx("line",{x1:m,x2:m,y1:r,y2:o,stroke:"var(--color-border-muted)",strokeWidth:1},p.getTime())})})]})});vp.displayName="LiveTimeGridlines";function Fl(e,t,r){let o=e[1]-e[0],n=t/Math.max(1,r)*o;return [e[0]-n,e[1]-n]}function Nh(e,t,r){let o=e[1]-e[0],n=e[0]+t*o,a=o/r,i=n-t*a;return [i,i+a]}function Cp(e,t,r=16,o=800){return t===1?e*r:t===2?e*o:e}var kh=(e,t,r,o,n)=>{let a=t!==1?Nh(e,r,t):e;return o!==0&&(a=Fl(a,o,n)),a},Th=(e,t)=>{if(!t)return e;let r=e[1]-e[0];if(r>=t[1]-t[0])return [t[0],t[1]];let[o,n]=e;return n>t[1]&&(n=t[1],o=n-r),o<t[0]&&(o=t[0],n=o+r),[o,n]},k1=e=>typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(()=>e(0),0),T1=e=>{typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):clearTimeout(e);};function Ph(e){let{groupRef:t}=e,r=qe.useRef({xDomain:e.xDomain,plotWidthPx:e.plotWidthPx,plotLeftPx:e.plotLeftPx??0});r.current={xDomain:e.xDomain,plotWidthPx:e.plotWidthPx,plotLeftPx:e.plotLeftPx??0};let o=qe.useRef(e.onCommit);o.current=e.onCommit;let n=qe.useRef(e.panBoundsMs);n.current=e.panBoundsMs;let a=qe.useRef(e.settleMs??140);a.current=e.settleMs??140;let i=qe.useRef(e.zoomIntent??(T=>T.ctrlKey));i.current=e.zoomIntent??(T=>T.ctrlKey);let s=qe.useRef(e.onGestureStart);s.current=e.onGestureStart;let l=qe.useRef(e.onFramePreview);l.current=e.onFramePreview;let c=qe.useRef(null),d=qe.useRef({scale:1,cursorFrac:.5,panDxPx:0,timer:null}),u=qe.useRef(null),p=qe.useRef(null),m=qe.useRef(false),f=qe.useCallback((T,D,M)=>{p.current={translateX:T,scaleX:D,preview:M},u.current==null&&(u.current=k1(()=>{u.current=null;let B=p.current;B!=null&&(t.current?.setAttribute("transform",`translate(${B.translateX},0) scale(${B.scaleX},1)`),l.current?.(B.preview));}));},[t]),g=qe.useCallback(()=>{u.current!=null&&(T1(u.current),u.current=null),p.current=null,t.current?.removeAttribute("transform"),l.current?.(null);},[t]),x=qe.useCallback(()=>{m.current||(m.current=true,s.current?.());},[]),b=qe.useCallback(()=>{m.current=false;},[]),h=qe.useCallback(()=>{d.current.timer!=null&&(clearTimeout(d.current.timer),d.current.timer=null);},[]),y=qe.useCallback(()=>{d.current={scale:1,cursorFrac:.5,panDxPx:0,timer:null};},[]),v=qe.useCallback(()=>{let{xDomain:T,plotWidthPx:D}=r.current,{scale:M,cursorFrac:B,panDxPx:z}=d.current;M===1&&z===0||o.current(Th(kh(T,M,B,z,D),n.current));},[]),S=qe.useCallback(()=>{d.current.timer!=null&&(h(),v(),y(),g());},[h,v,y,g]),w=qe.useCallback(T=>{S(),T.currentTarget.setPointerCapture?.(T.pointerId),c.current={startX:T.clientX,dxPx:0},x();},[S,x]),N=qe.useCallback(T=>{if(!c.current)return;c.current.dxPx=T.clientX-c.current.startX;let{xDomain:D,plotWidthPx:M}=r.current;f(c.current.dxPx,1,Fl(D,c.current.dxPx,M));},[f]),R=qe.useCallback(T=>{if(!c.current)return;let{dxPx:D}=c.current;c.current=null,g(),b(),D!==0&&o.current(Th(Fl(r.current.xDomain,D,r.current.plotWidthPx),n.current));},[g,b]),P=qe.useCallback(()=>{c.current&&(c.current=null,g(),b());},[g,b]),E=qe.useRef(null),I=qe.useCallback(T=>{if(E.current?.(),E.current=null,!T)return;let D=M=>{if(c.current)return;let{plotWidthPx:B,plotLeftPx:z}=r.current,V=Cp(M.deltaY,M.deltaMode),U=Cp(M.deltaX,M.deltaMode),Z=i.current(M);if(!Z&&U===0)return;if(M.preventDefault(),x(),Z){let A=Math.min(1,Math.max(0,(M.clientX-T.getBoundingClientRect().left)/Math.max(1,B)));d.current.scale*=Math.exp(-V/200),d.current.cursorFrac=A;}else d.current.panDxPx-=U;let{scale:G,cursorFrac:J,panDxPx:W}=d.current;f((z+J*B)*(1-G)+W,G,kh(r.current.xDomain,G,J,W,B)),h(),d.current.timer=setTimeout(()=>{v(),y(),g(),b();},a.current);};T.addEventListener("wheel",D,{passive:false}),E.current=()=>T.removeEventListener("wheel",D);},[f,g,h,v,y,x,b]);return qe.useEffect(()=>()=>{E.current?.(),E.current=null,g(),d.current.timer!=null&&clearTimeout(d.current.timer);},[g]),{onPointerDown:w,onPointerMove:N,onPointerUp:R,onPointerCancel:P,wheelTargetRef:I,gestureActiveRef:m}}var Lh=e=>e.type===pn||e.type===Jn,D1=({children:e,title:t,headerActions:r,headerControls:o,viewport:n,panBounds:a,onViewportChange:i,onPlotWidthChange:s,yFormatter:l={type:"number"},yDomain:c,referenceLines:d,cameraSync:u,parentWidth:p=0,parentHeight:m=0})=>{let[f,g]=qe.useState(null),x=qe.useRef(null),b=qe.useRef(0),h=qe.useId(),y=qe.useRef(null),v=qe.useRef(null),S=qe.useRef(null),{colorMode:w}=jt(),N=qe.useMemo(()=>Fo(),[w]),R=qe.useMemo(()=>Ci(),[w]),{datasets:P,seriesMetadata:E,seriesTypes:I}=qe.useMemo(()=>{let oe=qe.Children.toArray(e).filter(se=>qe.isValidElement(se)&&Lh(se)),ke=oe.filter(se=>se.props.data).length,K=[],H=[],de=[];return oe.forEach((se,ue)=>{let Te=se.props;if(!Te.data)return;K.push(Te.data);let te=("color"in Te&&Te.color?Te.color:void 0)||(ke===1?R:N[ue%N.length]),pe=se.type===pn;H.push({label:"label"in Te&&Te.label||`Series ${K.length}`,color:te,...pe&&"baseline"in Te&&Te.baseline!==void 0?{baseline:Te.baseline,tooltipRange:"tooltipRange"in Te&&Te.tooltipRange||false}:{}}),de.push(pe?"area":"line");}),{datasets:K,seriesMetadata:H,seriesTypes:de}},[e,R,N]),T=Yn(t),D=T.expandedSize?.width??p,M=r||T.action?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r,T.action]}):void 0,{headerRef:B,headerHeight:z}=Fa(!!M,!!o),V=Math.max(100,(T.expandedSize?.height??m)-z-60),U=qe.useMemo(()=>[new Date(n.startMs),new Date(n.endMs)],[n.startMs,n.endMs]),Z=qe.useMemo(()=>{let oe=P.flat(),ke=oe.filter(K=>{let H=K.xValue.getTime();return H>=n.startMs&&H<=n.endMs});return ke.length>0?ke:oe},[P,n.startMs,n.endMs]),G=qe.useMemo(()=>{let oe=Hi(Z,V,l,c);if(!c){let[ke,K]=oe.domain();K>ke&&oe.domain([ke,K+(K-ke)*.05]);}return oe},[Z,V,l,c]),J=qe.useRef(JSON.stringify(l)),W=qe.useRef(null),A=qe.useMemo(()=>{let[oe,ke]=G.domain(),K=Math.max(Math.abs(oe),Math.abs(ke)),H=JSON.stringify(l);if(H!==J.current&&(J.current=H,W.current=null),W.current!==null)return W.current;if(K===0)return Xa(l,0);let de=Xa(l,K);return W.current=de,de},[G,l]),Y=qe.useMemo(()=>{let oe=V-He.top-He.bottom;return qa(oe)},[V]),k=qe.useMemo(()=>{let oe=Dr(A),ke=oe.tickFormat||oe.format,H=G.ticks(Y).map(ue=>ke(ue)),de=ja(H,12,"system-ui"),se=Math.ceil(de)+12;return {...He,left:Math.max(se,30)}},[G,A,Y]),C=qe.useMemo(()=>scale.scaleTime({domain:U,range:[k.left,D-k.right]}),[U,D,k]),L=qe.useMemo(()=>[n.startMs,n.endMs],[n.startMs,n.endMs]),F=qe.useMemo(()=>a?[a.startMs,a.endMs]:void 0,[a]),j=qe.useCallback(oe=>{i({startMs:oe[0],endMs:oe[1]});},[i]),ne=D-k.left-k.right,ce=qe.useCallback(()=>g(null),[]),ee=qe.useRef({}),ae=qe.useRef(u);ae.current=u;let Le=qe.useCallback(oe=>{v.current?.setPreview(oe),S.current?.setPreview(oe),ae.current?.publish(ee.current,oe);},[]),{onPointerDown:ge,onPointerMove:xe,onPointerUp:re,onPointerCancel:ie,wheelTargetRef:ve,gestureActiveRef:Xe}=Ph({xDomain:L,plotWidthPx:ne,plotLeftPx:k.left,groupRef:y,onCommit:j,onGestureStart:ce,onFramePreview:Le,...F?{panBoundsMs:F}:{}}),Qe=qe.useRef({startMs:n.startMs,endMs:n.endMs,left:0,width:0});Qe.current={startMs:n.startMs,endMs:n.endMs,left:k.left,width:ne},qe.useEffect(()=>{if(!u)return;let oe=()=>{y.current?.removeAttribute("transform"),v.current?.setPreview(null),S.current?.setPreview(null);},ke=H=>{if(Xe.current)return;if(H==null){oe();return}let{startMs:de,endMs:se,left:ue,width:Te}=Qe.current,$e=se-de,te=H[1]-H[0];if($e<=0||te<=0||Te<=0)return;let pe=$e/te,Q=ue*(1-pe)+(de-H[0])*Te/te;y.current?.setAttribute("transform",`translate(${Q},0) scale(${pe},1)`),v.current?.setPreview(H),S.current?.setPreview(H);},K=u.subscribe(ee.current,ke);return ()=>{K(),Xe.current||oe();}},[u,Xe]),qe.useEffect(()=>{s?.(Math.max(0,D-k.left-k.right));},[D,k,s]);let wr=qe.useCallback(oe=>{if(Xe.current)return;let{left:ke}=x.current?.getBoundingClientRect()||{left:0},K=oe.clientX-ke;oe.timeStamp-(b.current||0)<16||(b.current=oe.timeStamp,g(yh({mouseX:K,datasets:P,seriesMetadata:E,seriesTypes:I,xScale:C,yScale:G,plotLeft:k.left,plotRight:D-k.right})));},[P,E,I,C,G,D,k,Xe]),Dt=qe.useCallback(()=>g(null),[]),Nr=Cl(),kr={width:D,height:V,xScale:C,yScale:G,yFormatter:A,animationSettings:vl,entrance:Nr,tooltip:{data:f,show:g,hide:()=>g(null)},datasets:P,seriesMetadata:E,seriesTypes:I},xt=0,Zt=[];qe.Children.toArray(e).forEach(oe=>{if(!qe.isValidElement(oe)){Zt.push(oe);return}if(Lh(oe)){let ke=xt;xt++;let K=oe.props;Zt.push(qe__namespace.default.cloneElement(oe,{...K,color:E[ke]?.color,animate:false}));}else Zt.push(oe);});let _=E.map(oe=>({category:oe.label,fill:oe.color})),Ge=Rl({datasets:P,metadata:{xLabel:"Date",yLabel:"Value",seriesLabels:E.map(oe=>oe.label),timestamp:true},svgRef:x}),_e=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("title",{children:t}),jsxRuntime.jsx("g",{children:G.ticks(Y).map(oe=>{let ke=Math.abs(oe)<Number.EPSILON;return jsxRuntime.jsx(shape.Line,{from:{x:k.left,y:G(oe)},to:{x:D-k.right,y:G(oe)},stroke:ke?"var(--color-border-default)":"var(--color-border-muted)",strokeWidth:ke?1.5:1},`grid-line-${oe}`)})}),jsxRuntime.jsx(vp,{ref:S,scale:C,width:D-k.left-k.right,top:G.range()[1],bottom:G.range()[0]}),jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:h,children:jsxRuntime.jsx("rect",{x:C.range()[0],y:G.range()[1],width:C.range()[1]-C.range()[0],height:G.range()[0]-G.range()[1]})})}),jsxRuntime.jsx("g",{clipPath:`url(#${h})`,children:jsxRuntime.jsx("g",{"data-camera-plot-group":"",ref:y,children:Zt})}),d&&d.length>0&&jsxRuntime.jsx("g",{children:d.map(oe=>{let ke=G(oe.value),K=oe.color??"var(--color-error-base)";return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx(shape.Line,{from:{x:k.left,y:ke},to:{x:D-k.right,y:ke},stroke:K,strokeWidth:1.5,strokeDasharray:"6 4"}),oe.label&&jsxRuntime.jsx("text",{x:D-k.right-4,y:ke-4,textAnchor:"end",fontSize:11,fill:K,children:oe.label})]},`ref-line-${oe.value}`)})}),jsxRuntime.jsx(yp,{ref:v,top:V-k.bottom,scale:C,width:D-k.left-k.right}),jsxRuntime.jsx(Xr.Left,{left:k.left,scale:G,yFormatter:A,height:V-k.top-k.bottom}),f&&!f.isEvent&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(shape.Line,{"data-testid":"chart-hover-crosshair",from:{x:C(f.xValue),y:G.range()[1]},to:{x:C(f.xValue),y:G.range()[0]},stroke:"var(--color-text-secondary)",strokeWidth:1,strokeDasharray:"3 3",opacity:.7}),f.series.filter(oe=>oe.type!=="bar"&&oe.showMarker!==false).map(oe=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("circle",{cx:C(f.xValue),cy:G(oe.chartY??oe.value),r:8,fill:"white",stroke:oe.color,strokeWidth:2,style:{transition:"all 100ms ease-out"}}),jsxRuntime.jsx("circle",{cx:C(f.xValue),cy:G(oe.chartY??oe.value),r:4,fill:oe.color,style:{transition:"all 100ms ease-out"}})]},`highlight-${oe.label}`))]}),jsxRuntime.jsx("rect",{"data-camera-surface":"",x:k.left,y:k.top,width:D-k.left-k.right,height:V-k.top-k.bottom,fill:"transparent",style:{cursor:"grab",touchAction:"none"},onMouseMove:wr,onMouseLeave:Dt,onPointerDown:ge,onPointerMove:xe,onPointerUp:re,onPointerCancel:ie,ref:ve})]});return T.present(jsxRuntime.jsx("div",{className:"relative flex h-full flex-col",children:jsxRuntime.jsxs(Jr.Provider,{value:kr,children:[jsxRuntime.jsx(Ba,{title:t,controls:o,actions:M,containerRef:B,marginRight:k.right}),jsxRuntime.jsx("svg",{width:D,height:V,className:"overflow-visible",ref:x,role:"img","aria-label":t,children:_e}),jsxRuntime.jsx(Co,{data:f,formatter:A}),jsxRuntime.jsx(Za,{onExport:Ge,items:_,marginLeft:0,marginRight:k.right})]})}))},Bl=responsive.withParentSize(D1);function Vl(e,t,r,o){if(r.length===0)throw new Error("tierForViewport: resolution ladder is empty");let n=[...r].sort((s,l)=>s.bucketMs-l.bucketMs),a=e/Math.max(1,t*o.targetPointsPerPx),i=Math.max(o.nativeMs,a);return n.find(s=>s.bucketMs>=i)??n[n.length-1]}function A1(e,t){return Math.floor(e/t.tileSpanMs)}function mn(e,t,r){let o=A1(e.startMs,t)-r,n=Math.ceil(e.endMs/t.tileSpanMs)-1+r,a=[];for(let i=o;i<=n;i++)a.push({tierId:t.id,index:i,startMs:i*t.tileSpanMs,endMs:(i+1)*t.tileSpanMs});return a}var hr=(e,t)=>`${e}:${t}`;var Dh={erroredTiles:0};function Np(e,t){let r=new Map,o=new Map,n=new Map,a=0;for(let d of e){let u=t.get(hr(d.tierId,d.index));if(u){if(u.status==="error"){a+=1;continue}if(u.data){for(let p of u.data.line)r.set(p.xValue.getTime(),p);for(let p of u.data.band??[])o.set(p.xValue.getTime(),p);for(let[p,m]of Object.entries(u.data.lines??{})){let f=n.get(p);f||(f=new Map,n.set(p,f));for(let g of m)f.set(g.xValue.getTime(),g);}}}}let i=(d,u)=>d.xValue.getTime()-u.xValue.getTime(),s=[...r.values()].sort(i),l=[...o.values()].sort(i),c=Object.fromEntries([...n.entries()].map(([d,u])=>[d,[...u.values()].sort(i)]));return {line:s,band:l,lines:c,coverage:{earliestMs:s.length?s[0].xValue.getTime():void 0,latestMs:s.length?s[s.length-1].xValue.getTime():void 0,erroredTiles:a}}}function I1(e,t,r){let o=mn(e,t,0);return o.length===0?false:o.every(n=>{let a=r.get(hr(n.tierId,n.index));return a!=null&&(a.status==="loaded"||a.status==="empty")})}function Ah(e,t,r){return mn(e,t,0).some(n=>{let a=r.get(hr(n.tierId,n.index));return a?.status==="loaded"&&(a.data?.line.length??0)>0})}function F1(e,t){if(!e.line.length)return false;let r=e.coverage.earliestMs,o=e.coverage.latestMs;return r==null||o==null?false:r<t.endMs&&o>t.startMs}function Ih({viewport:e,targetTier:t,ladder:r,store:o,overscanTiles:n,prev:a}){let i=I1(e,t,o);if(i&&Ah(e,t,o)){let l=mn(e,t,n),{line:c,band:d,lines:u,coverage:p}=Np(l,o);return {line:c,band:d,lines:u,renderTier:t,targetTier:t,isFallback:false,isStale:false,coverage:p}}let s=r.findIndex(l=>l.id===t.id);for(let l=s+1;l<r.length;l++){let c=r[l];if(Ah(e,c,o)){let d=mn(e,c,n),{line:u,band:p,lines:m,coverage:f}=Np(d,o);return {line:u,band:p,lines:m,renderTier:c,targetTier:t,isFallback:true,isStale:false,coverage:f}}}if(i){let l=mn(e,t,n),{line:c,band:d,lines:u,coverage:p}=Np(l,o);return {line:c,band:d,lines:u,renderTier:t,targetTier:t,isFallback:false,isStale:false,coverage:p}}return a?F1(a,e)?{...a,targetTier:t,isFallback:true,isStale:false}:{line:a.line,band:a.band,lines:a.lines,renderTier:null,targetTier:t,isFallback:true,isStale:true,coverage:Dh}:{line:[],band:[],lines:{},renderTier:null,targetTier:t,isFallback:false,isStale:false,coverage:Dh}}var Fh=new Map;function Bh(e,t){switch(t.type){case "reset":return new Map;case "request":{let r=new Map(e);for(let o of t.ids){let n=r.get(o);(!n||n.status==="error")&&r.set(o,{status:"loading"});}return r}case "fulfilled":{let r=new Map(e);return r.set(t.id,{status:t.data.line.length>0?"loaded":"empty",data:t.data}),r}case "failed":{let r=new Map(e);return r.set(t.id,{status:"error",error:t.error}),r}default:return e}}function Oh({refs:e,refsKey:t,store:r,tier:o,viewport:n,fetchTile:a,dispatch:i,concurrency:s,maxFutureMs:l}){let c=qe.useRef(e);c.current=e;let d=qe.useRef(n);d.current=n;let u=qe.useRef(new Map),p=qe.useCallback(()=>{for(let m of u.current.values())m.ac.abort();u.current.clear();},[]);return qe.useEffect(()=>{for(let[b,h]of u.current)h.tierId!==o.id&&(h.ac.abort(),u.current.delete(b));let m=c.current.filter(b=>{let h=hr(b.tierId,b.index),y=r.get(h);return y?y.status==="loading"&&!u.current.has(h):true}),f=(d.current.startMs+d.current.endMs)/2;m.sort((b,h)=>Math.abs((b.startMs+b.endMs)/2-f)-Math.abs((h.startMs+h.endMs)/2-f));let g=Math.max(0,s-u.current.size),x=m.slice(0,g);if(x.length!==0){i({type:"request",ids:x.map(b=>hr(b.tierId,b.index))});for(let b of x){let h=hr(b.tierId,b.index),y=new AbortController;u.current.set(h,{ac:y,tierId:b.tierId});let v=l!=null?Math.min(b.endMs,l):b.endMs;a(o,b.startMs,v,y.signal).then(S=>{y.signal.aborted||i({type:"fulfilled",id:h,data:S});}).catch(S=>{if(!y.signal.aborted){let w=S instanceof Error?S.message:String(S);i({type:"failed",id:h,error:new Error(`tile fetch failed (tile ${h}, tier ${o.id}): ${w}`)});}}).finally(()=>{u.current.delete(h);});}}},[t,r,a,o,i,s,l]),qe.useEffect(()=>p,[p]),{abortAll:p}}var Gh=1.3,O1=25e4,z1=3;function H1(e,t,r){let o=t.tileSpanMs/t.bucketMs,n=Math.max(1,Math.floor(O1/o/r));return Math.min(Math.max(1,Math.ceil(.5*e/t.tileSpanMs)),n)}function Uh(e){let{fetchTile:t,ladder:r,nativeMs:o,viewport:n,widthPx:a,maxFutureMs:i,targetPointsPerPx:s=1,concurrency:l=3,tileCostSeriesCount:c=z1,resetKey:d}=e,u=qe.useMemo(()=>({targetPointsPerPx:s,nativeMs:o}),[s,o]),[p,m]=qe.useState(()=>Vl(n.endMs-n.startMs,Math.max(1,a),r,u)),[f,g]=qe.useReducer(Bh,Fh),x=qe.useRef(n.endMs-n.startMs),b=qe.useRef(u);qe.useEffect(()=>{let z=n.endMs-n.startMs,V=Vl(z,Math.max(1,a),r,u);if(V.id===p.id){b.current=u;return}let Z=Vl(z,Math.max(1,a),r,b.current).id!==V.id,G=z/x.current;(Z||G>Gh||G<1/Gh)&&(x.current=z,b.current=u,m(V));},[n,a,r,p.id,u]);let h=n.endMs-n.startMs,y=qe.useMemo(()=>H1(h,p,c),[h,p,c]),v=qe.useMemo(()=>mn(n,p,y),[n,p,y]),S=qe.useMemo(()=>v.map(z=>hr(z.tierId,z.index)).join(","),[v]),w=qe.useRef(v);w.current=v;let N=qe.useRef(n);N.current=n;let R=qe.useRef(f);R.current=f;let{abortAll:P}=Oh({refs:v,refsKey:S,store:f,tier:p,viewport:n,fetchTile:t,dispatch:g,concurrency:l,...i!=null?{maxFutureMs:i}:{}}),E=qe.useRef(null),I=qe.useRef(false);qe.useEffect(()=>{if(!I.current){I.current=true;return}P(),E.current=null,g({type:"reset"});},[P,d]);let T=qe.useMemo(()=>w.current.map(z=>`${hr(z.tierId,z.index)}:${f.get(hr(z.tierId,z.index))?.status??"\u2205"}`).join("|"),[S,f]),D=qe.useMemo(()=>{let z=Ih({viewport:N.current,targetTier:p,ladder:r,store:R.current,overscanTiles:y,prev:E.current});return E.current=z,z},[T,p,r,y,n.startMs,n.endMs]),M=qe.useMemo(()=>w.current.some(z=>R.current.get(hr(z.tierId,z.index))?.status==="loading"),[T]),B=qe.useMemo(()=>{let z=w.current[0];return z?R.current.get(hr(z.tierId,z.index))?.status==="empty":false},[T]);return {tier:p,series:D,loading:M,atDataStart:B}}function Tp(e){let{initialViewport:t,...r}=e,[o,n]=qe.useState(t),a=Uh({...r,viewport:o}),i=qe.useCallback(l=>n(l),[]),s=qe.useCallback(l=>n(l),[]);return {viewport:o,onViewportChange:i,jumpTo:s,...a}}var G1={sm:"gap-4 px-6 py-8",md:"gap-5 px-8 py-12",lg:"gap-6 px-10 py-16"},W1={sm:"xs",md:"sm",lg:"md"},U1={sm:Tt("bodySm"),md:Tt("bodySm"),lg:Tt("bodyMd")},K1={sm:"h-10 w-10",md:"h-12 w-12",lg:"h-16 w-16"},Y1={sm:20,md:24,lg:32},J1={center:"items-center text-center [&_.empty-state-actions]:justify-center [&_.empty-state-actions]:text-center",start:"items-start text-left [&_.empty-state-actions]:justify-start [&_.empty-state-actions]:text-left"},X1={mesh:"radial-gradient(at 20% 20%, rgba(68, 74, 225, 0.06) 0px, transparent 45%), radial-gradient(at 80% 80%, rgba(68, 74, 225, 0.045) 0px, transparent 45%), radial-gradient(at 50% 50%, rgba(68, 74, 225, 0.03) 0px, transparent 50%)","top-fade":"linear-gradient(to bottom, rgba(68, 74, 225, 0.06) 0%, rgba(68, 74, 225, 0.02) 60%, transparent 100%)",center:"radial-gradient(ellipse 600px 400px at center, rgba(68, 74, 225, 0.06) 0px, transparent 60%)",corners:"radial-gradient(at 0% 0%, rgba(68, 74, 225, 0.06) 0px, transparent 40%), radial-gradient(at 100% 100%, rgba(68, 74, 225, 0.045) 0px, transparent 40%)",bottom:"radial-gradient(ellipse 700px 300px at 50% 100%, rgba(68, 74, 225, 0.06) 0px, transparent 60%)",asymmetric:"radial-gradient(at 15% 30%, rgba(68, 74, 225, 0.06) 0px, transparent 45%), radial-gradient(at 85% 70%, rgba(68, 74, 225, 0.04) 0px, transparent 50%)"};function Ol({icon:e,title:t,description:r,primaryAction:o,secondaryAction:n,actions:a,size:i="md",alignment:s="center",variant:l="default",spotlightPattern:c="mesh",fullHeight:d=false,className:u}){let p=i==="sm"?"sm":"md",m=l==="spotlight",f=m?{background:X1[c]}:void 0,g=()=>a?jsxRuntime.jsx("div",{className:"empty-state-actions mt-2 flex flex-wrap items-center gap-3",children:a}):o||n?jsxRuntime.jsxs("div",{className:"empty-state-actions mt-2 flex flex-col gap-3",children:[o&&(o.href?jsxRuntime.jsx($,{variant:"secondary",size:p,onPress:o.onPress,isDisabled:o.isDisabled,isLoading:o.isLoading,href:o.href,children:o.label}):jsxRuntime.jsx($,{variant:"secondary",size:p,onPress:o.onPress,isDisabled:o.isDisabled,isLoading:o.isLoading,children:o.label})),n&&jsxRuntime.jsx(ut,{href:n.href||"#",variant:"muted",onPress:n.onPress,className:Tt("labelMd"),children:n.label})]}):null;return jsxRuntime.jsxs("section",{"data-testid":"empty-state",role:"status","aria-live":"polite",className:tailwindMerge.twMerge("flex w-full flex-col rounded-xl text-text-primary",G1[i],J1[s],d?"h-full justify-center":"",m?"relative overflow-hidden":"",u),style:f,children:[e&&jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex items-center justify-center rounded-full border border-border-muted bg-background-muted text-text-secondary",K1[i]),children:jsxRuntime.jsx(O,{name:e,size:Y1[i]})}),jsxRuntime.jsx(lr,{size:W1[i],tag:"h2",className:"text-text-secondary",children:t}),r&&jsxRuntime.jsx("p",{className:tailwindMerge.twMerge("max-w-xs text-text-secondary whitespace-pre-line",U1[i]),children:r}),g()]})}var q1=1440*60*1e3,Q1=[{id:"5y",label:"5 years",days:5*365},{id:"year",label:"Year",days:365},{id:"month",label:"Month",days:30},{id:"week",label:"Week",days:7},{id:"day",label:"24h",days:1}],Z1=[{id:"day",days:1},{id:"week",days:7},{id:"month",days:30}];function Yh(e,t=Date.now){return Z1.map(({id:r,days:o})=>({id:r,label:e[r],getRange:()=>{let n=new Date(t());return {after:dateFns.subDays(n,o),before:n}}}))}function zl(e=Date.now){return Q1.map(({id:t,label:r,days:o})=>({id:t,label:r,getRange:()=>{let n=e();return {after:new Date(n-o*q1),before:new Date(n)}}}))}function oR({selectionState:e,isDisabled:t}){let r=`${rt} w-full h-full flex items-center justify-center rounded-sm forced-color-adjust-none font-semibold`,o={none:"text-text-primary group-hover:bg-background-muted group-pressed:bg-background-muted",middle:["bg-background-selected group-hover:bg-background-muted forced-colors:group-hover:bg-[Highlight]","group-invalid:group-hover:bg-feedback-error-background forced-colors:group-invalid:group-hover:bg-[Mark]","group-pressed:bg-background-muted forced-colors:group-pressed:bg-[Highlight] forced-colors:text-[HighlightText]","group-invalid:group-pressed:bg-feedback-error-background forced-colors:group-invalid:group-pressed:bg-[Mark]"].join(" "),cap:"bg-action-default text-[color:var(--color-action-default-text)] group-invalid:bg-feedback-error-border forced-colors:bg-[Highlight] forced-colors:group-invalid:bg-[Mark] forced-colors:text-[HighlightText]"},n=t?"text-text-disabled forced-colors:text-text-disabled font-light":"";return [r,o[e],n].filter(Boolean).join(" ")}function ti({errorMessage:e,...t}){return jsxRuntime.jsxs(reactAriaComponents.RangeCalendar,{...t,children:[jsxRuntime.jsx(gl,{}),jsxRuntime.jsxs(reactAriaComponents.CalendarGrid,{className:"w-full border-separate [border-spacing:0] [&_td]:p-0 [&_td]:!border-0",children:[jsxRuntime.jsx(bl,{}),jsxRuntime.jsx(reactAriaComponents.CalendarGridBody,{children:r=>jsxRuntime.jsx(reactAriaComponents.CalendarCell,{date:r,className:"selection-start:rounded-s-full selection-end:rounded-e-full [td:last-child_&]:rounded-e-end group h-9 w-9 cursor-default text-sm border-0 outside-month:text-text-disabled invalid:selected:bg-feedback-error-background forced-colors:selected:bg-[Highlight] forced-colors:selected:text-[HighlightText] forced-colors:invalid:selected:bg-[Mark] [td:first-child_&]:rounded-s-full [&]:border-0",children:({formattedDate:o,isSelected:n,isSelectionStart:a,isSelectionEnd:i,isFocusVisible:s,isDisabled:l})=>jsxRuntime.jsx("span",{className:oR({selectionState:n&&(a||i)?"cap":n?"middle":"none",isDisabled:l}),children:o})})})]}),e&&jsxRuntime.jsx(reactAriaComponents.Text,{slot:"errorMessage",className:"text-sm text-feedback-error-text",children:e})]})}function Xh(e){return e==="brand"?"primary":e==="default"||e==="secondary"||!e?"subtle":e}var aR={sm:"h-[var(--control-sm-height)] text-xs",md:"h-[var(--control-md-height)] text-sm",lg:"h-[var(--control-lg-height)] text-base",xl:"h-[var(--control-xl-height)] text-lg"},iR={sm:14,md:16,lg:18,xl:20},sR=({isSelected:e,isFirst:t,isLast:r,isDisabled:o,variant:n="subtle"})=>{let a=Xh(n),i=a==="primary"?"focus-visible:outline-action-primary":"focus-visible:outline-[color:var(--color-action-secondary-text)]";return a==="subtle"?tailwindMerge.twMerge(rt(),"focus-visible:outline-[color:var(--color-action-secondary-text)]","px-3 text-center transition cursor-pointer forced-color-adjust-none -ml-px first:ml-0 flex items-center justify-center h-full gap-2",e?"bg-background-muted text-text-primary font-medium forced-colors:!bg-[Highlight] forced-colors:!text-[HighlightText]":"text-text-secondary hover:bg-background-hover pressed:bg-background-hover forced-colors:!bg-[ButtonFace] forced-colors:!text-[ButtonText]",!r&&"border-r border-border-muted",o&&"bg-background-muted text-text-disabled forced-colors:!bg-[ButtonFace] forced-colors:!text-[GrayText] border-border-muted forced-colors:border-[GrayText] cursor-not-allowed"):tailwindMerge.twMerge(rt(),i,"px-3 text-center transition cursor-pointer forced-color-adjust-none -ml-px first:ml-0 flex items-center justify-center h-full gap-2",e?"bg-action-primary text-[color:var(--color-action-primary-text)] font-semibold forced-colors:!bg-[Highlight] forced-colors:!text-[HighlightText]":"text-text-secondary hover:bg-background-hover pressed:bg-background-hover forced-colors:!bg-[ButtonFace] forced-colors:!text-[ButtonText] hover:font-semibold",!r&&"border-r border-border-muted",o&&"bg-background-muted text-text-disabled forced-colors:!bg-[ButtonFace] forced-colors:!text-[GrayText] border-border-muted forced-colors:border-[GrayText] cursor-not-allowed")};function Gl({options:e,value:t,onChange:r,size:o="md",className:n,isDisabled:a,variant:i="subtle",iconOnly:s=false,"aria-label":l}){return jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("inline-flex overflow-hidden rounded-[var(--control-border-radius)]",Xh(i)==="subtle"?"border border-border-muted":"border-2 border-border-muted",aR[o],n),role:"group","aria-label":l,children:e.map((c,d)=>{let u=s&&!!c.icon;return jsxRuntime.jsxs(reactAriaComponents.ToggleButton,{isSelected:t===c.id,onChange:()=>r(c.id),className:sR({isSelected:t===c.id,isFirst:d===0,isLast:d===e.length-1,isDisabled:a,variant:i}),isDisabled:a,"aria-label":c.label,children:[c.icon&&jsxRuntime.jsx(O,{name:c.icon,size:iR[o]}),u?jsxRuntime.jsx("span",{className:"sr-only",children:c.label}):jsxRuntime.jsx("span",{className:"inline-flex flex-col items-center after:content-[attr(data-label)] after:font-semibold after:h-0 after:overflow-hidden after:invisible","data-label":c.label,children:c.label})]},c.id)})})}function uR(e){return e instanceof Date&&!Number.isNaN(e.getTime())}function Mp(e){return uR(e)?e:(console.warn("Invalid date detected in TimeControls, using fallback:",e),new Date)}var $h=120*1e3,pR=.02,ex={FIVE_MINUTES:0,FIFTEEN_MINUTES:1,HOUR:2,DAY:3,WEEK:4,MONTH:5,YEAR:6},mR=[{id:"FIFTEEN_MINUTES",label:"15m"},{id:"HOUR",label:"1h"},{id:"DAY",label:"1d"},{id:"WEEK",label:"1w"}];function Wl({dateRange:e,onDateRangeChange:t,windowSize:r,onWindowSizeChange:o,showWindowSize:n=true,showRangeSelector:a=true,allowDatePicker:i=false,lockWindowSize:s=false,showReset:l=true,restrictToSingleDay:c=false,presetRanges:d=[],windowSizeOptions:u=mR,autoAdjustWindowSize:p=false,className:m}){let[f,g]=qe.useState(0),x=qe.useRef(null),[b,h]=qe.useState(false),[y,v]=qe.useState(null),S=k=>{let L=(k.before.getTime()-k.after.getTime())/(1e3*60*60);return L<=24?"FIFTEEN_MINUTES":L<=72||L<=168?"HOUR":("DAY")};qe.useEffect(()=>{if(p&&!b&&o){let k=S(e);o(k);}},[e,p,b,o]);let w=k=>{let C;for(let L of d){let F=L.getRange(),j=(F.before.getTime()-F.after.getTime())*pR,ne=Math.abs(F.after.getTime()-k.after.getTime()),ce=Math.abs(F.before.getTime()-k.before.getTime());if(ne>j||ce>j)continue;let ee=ne+ce;(!C||ee<C.distance)&&(C={id:L.id,distance:ee});}return C?.id},N=y&&d.some(k=>k.id===y.id)&&Math.abs(y.after-e.after.getTime())<=$h&&Math.abs(y.before-e.before.getTime())<=$h?y.id:w(e),R=Mp(e.after),P=Mp(e.before),E=new Date(P.getTime()-1),I={start:date.fromDate(R,date.getLocalTimeZone()),end:date.fromDate(E,date.getLocalTimeZone())};qe.useEffect(()=>{let k=new ResizeObserver(C=>{for(let L of C)g(L.contentRect.width);});return x.current&&k.observe(x.current),()=>{x.current&&k.unobserve(x.current);}},[]);let T=[...u].sort((k,C)=>ex[k.id]-ex[C.id]),D=k=>{let C=k.toString(),L=d.find(F=>F.id===C);if(L){let F=L.getRange();v({id:C,after:F.after.getTime(),before:F.before.getTime()}),h(false),t(F,{presetId:C});}},M=k=>{if(k?.start&&k?.end){v(null);let C=new Date(k.start.year,k.start.month-1,k.start.day,0,0,0,0),L=new Date(k.end.year,k.end.month-1,k.end.day+1,0,0,0,0);t({after:C,before:L});}},B=k=>{if(k){v(null);let C=new Date(k.year,k.month-1,k.day,0,0,0,0),L=new Date(k.year,k.month-1,k.day+1,0,0,0,0);t({after:C,before:L});}},z=k=>{o&&(h(true),o(k.toString()));},V=()=>{d.length>0&&D(d[0].id);},U=k=>Mp(k).toLocaleDateString("en-US"),Z=T.map(k=>({id:k.id,label:k.label,value:k.id})),G=d.map(k=>({id:k.id,label:k.label,value:k.id})),J=s?jsxRuntime.jsx("div",{className:"flex items-center rounded-md border border-border-muted bg-background-muted px-3 py-2 text-sm text-text-secondary",children:T.find(k=>k.id===r)?.label||r}):jsxRuntime.jsx(Bo,{className:"w-full md:w-auto",selectedKey:r,onSelectionChange:z,items:Z,size:"md","aria-label":"Select Window Size",children:k=>jsxRuntime.jsx(pr,{id:k.id,"aria-label":k.label,size:"md",children:k.label},k.id)}),W=l&&!N&&d.length>0,A=c?jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(reactAriaComponents.DialogTrigger,{children:[jsxRuntime.jsxs($,{className:"border-l pl-2 pr-2 hover:border-border-default hover:bg-background-muted hover:text-text-link-hover",variant:"secondary",children:[jsxRuntime.jsx(O,{name:"CalendarBlank",size:18}),jsxRuntime.jsx("span",{className:"ml-2 hidden md:block",children:U(e.after)})]}),jsxRuntime.jsx(yt,{className:"z-50 w-auto p-3",disableGroup:true,children:jsxRuntime.jsx(Ua,{"aria-label":"Select date",value:date.parseDate(R.toISOString().split("T")[0]),onChange:B})})]})}):jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxs(reactAriaComponents.DialogTrigger,{children:[jsxRuntime.jsxs($,{className:tailwindMerge.twMerge("border-l pl-2 pr-2 hover:border-border-default hover:bg-background-muted hover:text-text-link-hover",W&&"rounded-r-none"),variant:"secondary",children:[jsxRuntime.jsx(O,{name:"CalendarBlank",size:18}),!N&&jsxRuntime.jsx("span",{className:"ml-2 hidden md:block",children:`${U(e.after)} - ${U(E)}`})]}),jsxRuntime.jsx(yt,{className:"z-50 w-auto p-3",disableGroup:true,children:jsxRuntime.jsx(ti,{"aria-label":"Date range calendar",value:I,onChange:M})})]}),W&&jsxRuntime.jsx($,{variant:"ghost",size:"md",onPress:V,children:"Reset"})]}),Y=f<600;return jsxRuntime.jsx("div",{ref:x,className:tailwindMerge.twMerge("flex w-full flex-wrap items-center justify-between gap-4",m),children:Y?jsxRuntime.jsxs("div",{className:"flex w-full justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center",children:[i&&A,a&&d.length>0&&jsxRuntime.jsx(Bo,{selectedKey:N??"",onSelectionChange:D,items:G,size:"md","aria-label":"Select Date Range",children:k=>jsxRuntime.jsx(pr,{id:k.id,size:"md",children:k.label},k.id)})]}),jsxRuntime.jsx("div",{className:"flex items-center",children:n&&r&&J})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[i&&A,a&&d.length>0&&jsxRuntime.jsx(Gl,{options:d.map(k=>({id:k.id,label:k.label})),value:N??"",onChange:D,size:"sm",variant:"secondary","aria-label":"Select Date Range"})]}),jsxRuntime.jsx("div",{className:"flex items-center",children:n&&r&&J})]})})}var xR=1440*60*1e3,yR=6e4,tx=(e,t)=>({startMs:t-e*xR,endMs:t}),vR=e=>({after:new Date(e.startMs),before:new Date(e.endMs)});function rx({source:e,title:t,initialRange:r,viewportEnd:o,yFormatter:n,yDomain:a,referenceLines:i,emptyState:s,presetRanges:l,tierToWindow:c,windowSizeOptions:d,height:u=360,hint:p,dataBounds:m,children:f}){let[g,x]=qe.useState(900),b=m?.endMs,[h,y]=qe.useState(()=>b??Date.now());qe.useEffect(()=>{if(b!=null){y(b);return}y(Date.now());let re=setInterval(()=>y(Date.now()),yR);return ()=>clearInterval(re)},[b]);let v=o?.getTime()??b,S=r?.days??30,w=qe.useMemo(()=>tx(S,v??Date.now()),[S,v]),N=h,R=qe.useMemo(()=>({startMs:m?.startMs??0,endMs:h}),[m?.startMs,h]),P=re=>{let ie=Math.min(re.endMs-re.startMs,R.endMs-R.startMs),ve=Math.max(Math.min(re.endMs,R.endMs),R.startMs+ie);return {startMs:ve-ie,endMs:ve}},[E,I]=qe.useState(null),[T,D]=qe.useState(null),M=E??w,B=Tp({fetchTile:e.fetchTile,ladder:e.ladder,nativeMs:e.nativeMs,initialViewport:w,widthPx:g,maxFutureMs:N,tileCostSeriesCount:e.tileCostSeriesCount,resetKey:e.resetKey}),z=qe.useMemo(()=>zl(()=>v??Date.now()),[v]),V=l??z,U=()=>{if(T&&"presetId"in T){let re=V.find(ie=>ie.id===T.presetId);if(re){let ie=re.getRange();return {startMs:ie.after.getTime(),endMs:ie.before.getTime()}}}return T&&"range"in T?T.range:tx(S,v??Date.now())},{line:Z,coverage:G,renderTier:J,targetTier:W,isFallback:A,isStale:Y}=B.series,k=J?J.bucketMs*1.5:0,C=re=>re==null?"\u2014":new Date(re).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),L=(re,ie)=>{let ve=ie-re<1728e5?{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}:{month:"short",day:"numeric",year:"numeric"},Xe=new Intl.DateTimeFormat("en-US",ve);return `${Xe.format(new Date(re))} \u2013 ${Xe.format(new Date(ie))}`},F=B.viewport.startMs!==M.startMs||B.viewport.endMs!==M.endMs,j=Y||B.loading&&G.earliestMs==null,ne=(B.viewport.endMs-B.viewport.startMs)*.03,ce=!j&&G.earliestMs!=null&&G.earliestMs>B.viewport.startMs+ne,ee=!B.loading&&G.earliestMs==null&&G.latestMs==null&&Z.length===0&&!Y,ae=Yn(t),Le=f({series:B.series,gapMs:k}),ge=qe.isValidElement(Le)&&Le.type===qe.Fragment?Le.props.children:Le,xe=jsxRuntime.jsxs("div",{className:`flex flex-col gap-3${ae.isExpanded?" h-full":""}`,children:[jsxRuntime.jsxs("div",{className:"flex items-start gap-2",children:[jsxRuntime.jsx(Wl,{dateRange:vR(B.viewport),onDateRangeChange:(re,ie)=>{let ve=P({startMs:re.after.getTime(),endMs:re.before.getTime()});D(ie?.presetId?{presetId:ie.presetId}:{range:ve}),I(ve),B.jumpTo(ve);},windowSize:c[W.id],windowSizeOptions:d,lockWindowSize:true,presetRanges:V,allowDatePicker:true,showReset:false}),!ae.isExpanded&&!ee&&ae.action]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-text-secondary",children:[jsxRuntime.jsxs("span",{children:["Window"," ",jsxRuntime.jsx("span",{className:"font-medium text-text-primary",children:L(B.viewport.startMs,B.viewport.endMs)})]}),jsxRuntime.jsx("span",{className:"text-text-tertiary",children:"\u2022"}),jsxRuntime.jsxs("span",{children:["Resolution ",jsxRuntime.jsx("span",{className:"font-medium text-text-primary",children:J?.id??W.id}),A&&jsxRuntime.jsxs("span",{className:"text-text-tertiary",children:[" \xB7 loading ",W.id]})]}),B.loading&&jsxRuntime.jsx("span",{className:"text-text-tertiary",children:"loading\u2026"}),ce&&jsxRuntime.jsxs("span",{className:"text-text-tertiary",children:["showing available history from ",C(G.earliestMs)]}),!ce&&!j&&B.atDataStart&&jsxRuntime.jsx("span",{className:"text-text-tertiary",children:"no earlier data loaded"}),F&&jsxRuntime.jsx($,{variant:"ghost",size:"sm",onPress:()=>{let re=P(U());I(re),B.jumpTo(re);},children:"\u27F2 Reset"})]}),jsxRuntime.jsx("div",{className:`relative overflow-hidden rounded-md border border-border-subtle${ae.isExpanded?" min-h-0 flex-1":""}`,style:ae.isExpanded?void 0:{height:u},children:ee?jsxRuntime.jsx(Ol,{title:s.title,description:s.description}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Bl,{title:t,viewport:B.viewport,panBounds:R,onViewportChange:B.onViewportChange,onPlotWidthChange:x,...n&&{yFormatter:n},...a&&{yDomain:a},...i&&{referenceLines:i},children:ge}),B.loading&&jsxRuntime.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 animate-pulse bg-[var(--color-viz-categorical-1)] opacity-60"})]})}),p&&jsxRuntime.jsx("p",{className:"text-xs text-text-tertiary",children:p})]});return jsxRuntime.jsx(mp,{children:ae.present(xe)})}function Zi({count:e,label:t="results",isLoading:r=false,className:o=""}){if(r)return jsxRuntime.jsx("div",{className:`flex items-center ${o}`,children:jsxRuntime.jsx(X,{width:80,height:16})});let n=t.endsWith("s")?t.slice(0,-1):t,a=e===1?n:t;return jsxRuntime.jsxs("div",{className:`text-sm text-text-secondary whitespace-nowrap ${o}`,children:[e.toLocaleString()," ",a]})}var TR=e=>{let t=zt({isInvalid:e.isInvalid,isDisabled:e.isDisabled,isFocused:e.isFocused,transparent:e.transparent,size:e.size}),r=[e.showSearchIcon?"":"pl-3",e.isClearable&&e.hasValue||e.isPassword?"pr-8":"pr-3"].join(" ");return tailwindMerge.twMerge(t,r,e.className)};function qr({label:e,description:t,errorMessage:r,size:o="md",tooltip:n,isRequired:a,transparent:i,showSearchIcon:s,isClearable:l,onClear:c,type:d,validationResult:u,reserveErrorSpace:p=true,isLoading:m=false,descriptionPlacement:f="below",...g}){let[x,b]=qe__namespace.default.useState(false),{isFocused:h,handleFocus:y,handleBlur:v}=ur(),S=d==="password",w=al(m,300);return jsxRuntime.jsx(reactAriaComponents.TextField,{...g,isRequired:a,className:Me(g.className,"group flex flex-col"),children:({isDisabled:N,isInvalid:R})=>jsxRuntime.jsxs("div",{className:"flex flex-col",children:[e&&jsxRuntime.jsx(Ke,{size:o,tooltip:n,description:f==="tooltip"||f==="inline"?t:void 0,descriptionPlacement:f,isRequired:a,children:e}),jsxRuntime.jsxs(Ct,{children:[s&&jsxRuntime.jsx("div",{className:"pointer-events-none absolute top-1/2 -translate-y-1/2 transform flex items-center z-10",style:{left:9},children:(()=>{let P={sm:14,md:16,lg:18,xl:20}[o];return w?jsxRuntime.jsx(Wr,{size:P,color:"text-text-secondary"}):jsxRuntime.jsx(O,{name:"MagnifyingGlass",size:P,className:`transition-colors ${h?"text-action-brand":"text-text-secondary"}`})})()}),jsxRuntime.jsx(sl,{size:o,disabled:N,type:S?x?"text":"password":d,name:g.name,autoComplete:g.autoComplete,value:g.value,defaultValue:g.defaultValue,placeholder:g.placeholder,onFocus:P=>y(P,g.onFocus),onBlur:P=>v(P,g.onBlur),onChange:P=>g.onChange?.(P.target.value),style:s?{paddingLeft:{sm:28,md:32,lg:36,xl:37}[o]}:void 0,className:TR({isInvalid:R,isDisabled:N,isFocused:h,size:o,transparent:i,showSearchIcon:s,isClearable:l,hasValue:!!g.value,isPassword:S,className:typeof g.className=="string"?g.className:void 0})}),l&&g.value&&!N&&jsxRuntime.jsx(Ii,{onClick:()=>{c?c():g.onChange&&g.onChange("");},size:o}),S&&!N&&jsxRuntime.jsx("button",{type:"button",onClick:()=>b(!x),className:"absolute right-3 top-1/2 -translate-y-1/2 transform text-text-secondary hover:text-text-primary","aria-label":x?"Hide password":"Show password",onMouseDown:P=>{P.preventDefault(),P.stopPropagation();},children:jsxRuntime.jsx(O,{name:x?"EyeSlash":"Eye",size:o==="sm"?16:20,className:"text-text-primary"})})]}),p?jsxRuntime.jsx("div",{className:"mt-1 min-h-[20px]",children:typeof r=="string"?jsxRuntime.jsx(he,{size:o,children:r}):typeof r=="function"&&u?jsxRuntime.jsx(he,{size:o,children:r(u)}):t&&f==="below"?jsxRuntime.jsx(Ne,{size:o,children:t}):null}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:typeof r=="string"?jsxRuntime.jsx(he,{size:o,className:"mt-1",children:r}):typeof r=="function"&&u?jsxRuntime.jsx(he,{size:o,className:"mt-1",children:r(u)}):t&&f==="below"?jsxRuntime.jsx(Ne,{size:o,className:"mt-1",children:t}):null})]})})}function Zn({value:e,onChange:t,onClear:r,placeholder:o="Search...",size:n="sm",className:a="",isLoading:i=false}){return jsxRuntime.jsx("div",{className:`flex-1 min-w-0 sm:max-w-sm ${a}`,children:jsxRuntime.jsx(qr,{value:e,onChange:t,placeholder:o,showSearchIcon:true,isClearable:!!e&&!!r,onClear:r,size:n,"aria-label":o,reserveErrorSpace:false,isLoading:i})})}function _i({value:e,options:t,onChange:r,direction:o,onDirectionChange:n,showLabel:a=true,size:i="sm",className:s="",compact:l=false}){let[c,d]=qe.useState(false),u=o!==void 0&&n!==void 0,p=t.find(m=>m.value===e);return l?jsxRuntime.jsxs("div",{className:`flex items-center gap-2 ${s}`,children:[jsxRuntime.jsx($,{variant:"secondary",size:i,icon:"ArrowsDownUp","aria-label":`Sort by: ${p?.label||"Select"}`,onPress:()=>d(true)}),jsxRuntime.jsx(vt,{isOpen:c,onClose:()=>d(false),title:"Sort by",contentPadding:false,children:jsxRuntime.jsx(reactAriaComponents.ListBox,{items:t.map(m=>({id:m.value,label:m.label,value:m.value})),className:"w-full bg-background-surface p-0 outline-0 [&_[role=option]]:border-b [&_[role=option]]:border-border-default [&_[role=option]:last-child]:border-0 [&_[role=option]]:!px-6 [&_[role=option]]:!py-4 [&_[role=option]]:rounded-none",selectionMode:"single",selectedKeys:e?[e]:[],onSelectionChange:m=>{let f=Array.from(m)[0];f!=null&&(r(f),d(false));},children:m=>jsxRuntime.jsx(pr,{id:m.id,textValue:m.label,children:jsxRuntime.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap min-w-0 flex-1",children:m.label})},m.id)})})]}):jsxRuntime.jsxs("div",{className:`flex items-center gap-2 ${s}`,children:[a&&jsxRuntime.jsx("span",{className:"text-sm text-text-secondary whitespace-nowrap",children:"Sort by:"}),jsxRuntime.jsx(Bo,{selectedKey:e,onSelectionChange:m=>r(m),size:i,className:"min-w-32",items:t.map(m=>({id:m.value,label:m.label,value:m.value})),renderItem:m=>m.label,"aria-label":"Sort by",reserveErrorSpace:false}),u&&jsxRuntime.jsx($,{variant:"ghost",size:i,onClick:()=>n(o==="asc"?"desc":"asc"),"aria-label":`Sort ${o==="asc"?"descending":"ascending"}`,className:"p-1.5",children:o==="asc"?jsxRuntime.jsx(lucideReact.ArrowUp,{className:"w-4 h-4"}):jsxRuntime.jsx(lucideReact.ArrowDown,{className:"w-4 h-4"})})]})}function sx({search:e,searchMobileMode:t="expanded",filters:r=[],onRemoveFilter:o,onClearAllFilters:n,onManageFilters:a,exportControl:i,maxVisibleFilterChips:s=3,sort:l,resultsCount:c,leftControls:d,onManageColumns:u,columnPicker:p,customControls:m,actions:f,interactionMode:g="auto",sticky:x,stickyTop:b="0",zIndex:h=10,className:y="",style:v}){let S=r.length>0;if(!(e||S||a||l||c||d||u||p||m||f||i))return null;let N=x?"sticky bg-background-surface":"",R=x?{top:b,zIndex:h}:{};return jsxRuntime.jsxs("div",{className:`@container flex flex-col gap-3 bg-background-surface py-3 border-b border-border-default ${N} ${y}`,style:{...v,...R},children:[jsxRuntime.jsxs("div",{className:"hidden @[640px]:flex @[640px]:items-center @[640px]:justify-between @[640px]:gap-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[d,d&&c&&jsxRuntime.jsx("div",{className:"h-4 w-px bg-border-default"}),c&&jsxRuntime.jsx(Zi,{count:c.count,label:c.label,isLoading:c.isLoading}),c&&l&&jsxRuntime.jsx("div",{className:"h-4 w-px bg-border-default"}),l&&jsxRuntime.jsx(_i,{value:l.value,options:l.options,onChange:l.onChange,showLabel:l.showLabel,direction:l.direction,onDirectionChange:l.onDirectionChange}),u?jsxRuntime.jsx($,{variant:"secondary",size:"sm",icon:"Columns",onClick:u,children:"Columns"}):p,S&&o&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r.slice(0,s).map(P=>jsxRuntime.jsxs(Yr,{variant:"primary",size:"sm",onRemove:()=>o(P.id),isRemovable:true,children:[P.label,": ",P.value]},P.id)),r.length>s&&a&&jsxRuntime.jsxs($,{variant:"ghost",size:"sm",onClick:a,className:"text-text-secondary hover:text-text-primary whitespace-nowrap",children:["+",r.length-s," more"]}),n&&jsxRuntime.jsx($,{variant:"ghost",size:"sm",onClick:n,className:"text-text-secondary hover:text-text-primary whitespace-nowrap",children:"Clear all"})]})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-3 flex-shrink-0",children:m||jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[f&&f.items.length>0&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:f.items.map(P=>jsxRuntime.jsx($,{variant:P.variant||"secondary",size:"sm",icon:P.icon,onPress:P.onClick,isDisabled:P.disabled,children:P.label},P.id))}),e&&jsxRuntime.jsx("div",{className:"w-64",children:jsxRuntime.jsx(Zn,{value:e.value,onChange:e.onChange,onClear:e.onClear,placeholder:e.placeholder,isLoading:e.isLoading})}),a&&jsxRuntime.jsx($,{variant:"secondary",size:"sm",icon:"Sliders",badgeNumber:r.length>0?r.length:void 0,onClick:a,children:"Filters"}),i&&jsxRuntime.jsx($,{variant:"secondary",size:"sm",icon:"Upload",onClick:i.onClick,isDisabled:i.isDisabled,children:i.label})]})})]}),jsxRuntime.jsxs("div",{className:"@[640px]:hidden",children:[jsxRuntime.jsx("div",{className:"flex flex-col gap-3 mb-3",children:jsxRuntime.jsx("div",{className:"flex items-center gap-3",children:m?jsxRuntime.jsx("div",{className:"flex-1",children:m}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[f&&f.items.length>0&&jsxRuntime.jsx(Oa,{items:f.items.map(P=>({id:P.id,name:P.label,iconName:P.icon,variant:P.variant==="destructive"?"destructive":"primary",disabled:P.disabled,onAction:P.onClick})),align:"left",size:"sm",children:jsxRuntime.jsx($,{variant:"secondary",size:"sm",icon:"DotsThreeVertical","aria-label":f.menuLabel||"Actions"})}),e&&jsxRuntime.jsx("div",{className:"flex-1",children:jsxRuntime.jsx(Zn,{value:e.value,onChange:e.onChange,onClear:e.onClear,placeholder:e.placeholder,isLoading:e.isLoading})}),a&&jsxRuntime.jsx($,{variant:"secondary",size:"sm",icon:"Sliders",badgeNumber:r.length>0?r.length:void 0,onClick:a,"aria-label":`Filters${r.length>0?` (${r.length} active)`:""}`}),i&&jsxRuntime.jsx($,{variant:"secondary",size:"sm",icon:"Upload",onClick:i.onClick,isDisabled:i.isDisabled,children:i.label})]})})}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[d,c&&jsxRuntime.jsx(Zi,{count:c.count,label:c.label,isLoading:c.isLoading})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:l&&jsxRuntime.jsx(_i,{value:l.value,options:l.options,onChange:l.onChange,showLabel:false,direction:l.direction,onDirectionChange:l.onDirectionChange,compact:g!=="desktop"})})]})]})]})}function lx({filters:e,onRemove:t,onClearAll:r,onManageFilters:o,maxVisibleChips:n=3,mode:a="chips",showManageButton:i=true,size:s="sm",className:l=""}){let c=e.length>0,d=e.slice(0,n),u=Math.max(0,e.length-n),p=u>0,m=a==="button"&&!!o,f=a==="chips"&&i&&!!o;if(!c&&!m&&!f)return null;let g=m&&jsxRuntime.jsxs($,{variant:"secondary",size:s,onClick:o,className:"whitespace-nowrap",children:[e.length," ",e.length===1?"filter":"filters"]}),x=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[f&&jsxRuntime.jsx($,{variant:"secondary",size:s,icon:"Sliders",onClick:o,className:"whitespace-nowrap",children:"Filters"}),c&&d.map(h=>jsxRuntime.jsxs(Yr,{variant:"secondary",size:s,onRemove:()=>t(h.id),isRemovable:true,children:[h.label,": ",h.value]},h.id)),c&&p&&o&&jsxRuntime.jsxs($,{variant:"ghost",size:s,onClick:o,className:"text-text-secondary hover:text-text-primary whitespace-nowrap",children:["+",u," more"]}),c&&r&&jsxRuntime.jsx($,{variant:"ghost",size:s,onClick:r,className:"text-text-secondary hover:text-text-primary whitespace-nowrap",children:"Clear all"})]}),b=a==="button"?g:x;return jsxRuntime.jsx("div",{className:`flex flex-wrap items-center gap-2 ${l}`,children:b})}var cx=["isEmpty","isNotEmpty"];function dx(e){return cx.includes(e)}var ux={isEmpty:"is empty",isNotEmpty:"is not empty"};function AR(e,t,r){return {field:e,operator:t,value:r}}function IR(e,t="AND"){return {logic:t,conditions:e}}function $i(){return {logic:"AND",conditions:[]}}function Jl(e){return !e||e.conditions.length===0?true:e.conditions.every(t=>"conditions"in t?Jl(t):false)}function FR(e,t){if(!e)return [];let r=new Map(t?.map(i=>[i.field,i])),o=new Map;function n(i){if("conditions"in i)i.conditions.forEach(s=>n(s));else {let s=o.get(i.field)||[];s.push(i),o.set(i.field,s);}}e.conditions.forEach(i=>n(i));let a=[];for(let[i,s]of o.entries()){let l=r.get(i),c=l?.label||i,d=[],u=[],p=[];for(let m of s)m.operator==="in"&&Array.isArray(m.value)?d.push(...m.value):m.operator==="eq"?m.value!==void 0&&typeof m.value!="boolean"&&!Array.isArray(m.value)?d.push(m.value):p.push(m):["gte","gt","lte","lt"].includes(m.operator)&&m.value!==void 0?u.push({operator:m.operator,value:typeof m.value=="boolean"||Array.isArray(m.value)?String(m.value):m.value}):p.push(m);if(d.length>0){let f=Array.from(new Set(d)).map(g=>l?.values?.find(b=>String(b.value)===String(g))?.label??g);a.push({id:`${i}-in`,label:c,value:f.join(", ")});}if(u.length>0){let m=u.find(g=>g.operator==="gte"||g.operator==="gt"),f=u.find(g=>g.operator==="lte"||g.operator==="lt");if(m&&f){let g=m.operator==="gte"?"\u2265":">",x=f.operator==="lte"?"\u2264":"<";a.push({id:`${i}-range`,label:c,value:`${g} ${m.value} and ${x} ${f.value}`});}else for(let g of u){let x;g.operator==="gte"?x="\u2265":g.operator==="gt"?x=">":g.operator==="lte"?x="\u2264":x="<",a.push({id:`${i}-${g.operator}`,label:c,value:`${x} ${g.value}`});}}for(let m of p){let f;m.operator==="neq"?f=`\u2260 ${m.value}`:m.operator==="contains"?f=`contains "${m.value}"`:m.operator==="startsWith"?f=`starts with "${m.value}"`:m.operator==="endsWith"?f=`ends with "${m.value}"`:dx(m.operator)?f=ux[m.operator]:f=String(m.value),a.push({id:`${i}-${m.operator}`,label:c,value:f});}}return a}function hn(e,t){let r=e||$i();return {...r,conditions:[...r.conditions,t]}}function _n(e,t){if(!e)return $i();let r=e.conditions.filter(o=>"conditions"in o?_n(o,t).conditions.length>0:o.field!==t);return {...e,conditions:r}}function $n(e){if(!e)return [];let t=new Set;function r(o){"conditions"in o?o.conditions.forEach(r):t.add(o.field);}return e.conditions.forEach(r),Array.from(t)}function mx({label:e,description:t,errorMessage:r,size:o="md",tooltip:n,isRequired:a,isDisabled:i,isInvalid:s,showCalendar:l=true,reserveErrorSpace:c=true,validationResult:d,className:u,...p}){let[m,f]=qe.useState(false),g=x=>{p.onChange&&x&&p.onChange(x),f(false);};return jsxRuntime.jsxs(reactAriaComponents.DateField,{...p,isDisabled:i,isRequired:a,isInvalid:s,className:Me(u,"flex flex-col gap-1"),children:[e&&jsxRuntime.jsx(Ke,{size:o,tooltip:n,isRequired:a,children:e}),jsxRuntime.jsx(Ct,{children:jsxRuntime.jsxs("div",{className:"relative w-full",children:[jsxRuntime.jsx(es,{size:o,isDisabled:i,isInvalid:s,hasCalendar:l}),l&&!i&&jsxRuntime.jsxs(reactAriaComponents.DialogTrigger,{isOpen:m,onOpenChange:f,children:[jsxRuntime.jsx($,{variant:"unstyled",className:"absolute right-2 top-1/2 -translate-y-1/2 flex h-8 w-8 items-center justify-center rounded hover:bg-background-hover text-text-secondary hover:text-text-primary transition-colors","aria-label":"Open calendar",children:jsxRuntime.jsx(O,{name:"Calendar",size:18})}),jsxRuntime.jsx(reactAriaComponents.Popover,{className:"bg-background-surface rounded-lg border border-border-default shadow-xl",children:jsxRuntime.jsx(reactAriaComponents.Dialog,{className:"p-4 outline-none",children:jsxRuntime.jsx(Ua,{value:p.value,onChange:g,minValue:p.minValue,maxValue:p.maxValue,isDisabled:i,isReadOnly:p.isReadOnly,isDateUnavailable:p.isDateUnavailable})})})]})]})}),c?jsxRuntime.jsx("div",{className:"mt-1 min-h-[20px]",children:typeof r=="string"?jsxRuntime.jsx(he,{size:o,children:r}):typeof r=="function"&&d?jsxRuntime.jsx(he,{size:o,children:r(d)}):t?jsxRuntime.jsx(Ne,{size:o,children:t}):null}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:typeof r=="string"?jsxRuntime.jsx(he,{size:o,className:"mt-1",children:r}):typeof r=="function"&&d?jsxRuntime.jsx(he,{size:o,className:"mt-1",children:r(d)}):t?jsxRuntime.jsx(Ne,{size:o,className:"mt-1",children:t}):null})]})}function UR({isPlaceholder:e,isDisabled:t,size:r="md"}){return tailwindMerge.twMerge("inline-block box-content px-0.5 rounded outline-none tabular-nums text-center transition-colors",{sm:"text-base md:text-xs",md:"text-base md:text-sm",lg:"text-base",xl:"text-lg"}[r],e?"text-text-disabled italic":"text-text-primary",t?"text-text-disabled cursor-not-allowed":"cursor-text",!t&&"hover:bg-background-hover","data-[focused]:bg-background-selected data-[focused]:text-text-primary")}function es({size:e="md",isDisabled:t,isInvalid:r,hasCalendar:o,className:n,...a}){return jsxRuntime.jsx(reactAriaComponents.DateInput,{className:tailwindMerge.twMerge(rn({isInvalid:r,isDisabled:t}),"px-3 py-2 flex items-center gap-0.5 w-full",o&&"pr-10",n),...a,children:i=>jsxRuntime.jsx(reactAriaComponents.DateSegment,{segment:i,className:UR({isPlaceholder:i.isPlaceholder,isDisabled:!i.isEditable||t,size:e})})})}function Xl({label:e,description:t,errorMessage:r,...o}){return jsxRuntime.jsxs(reactAriaComponents.DateRangePicker,{...o,className:Me(o.className,"group flex flex-col gap-1"),children:[e&&jsxRuntime.jsx(Ke,{children:e}),jsxRuntime.jsxs(zg,{className:"w-auto min-w-[208px]",children:[jsxRuntime.jsx(es,{slot:"start",className:"px-2 py-1.5 text-sm"}),jsxRuntime.jsx("span",{"aria-hidden":"true",className:"text-text-primary group-disabled:text-text-disabled forced-colors:text-[ButtonText] group-disabled:forced-colors:text-[GrayText]",children:"\u2013"}),jsxRuntime.jsx(es,{slot:"end",className:"flex-1 px-2 py-1.5 text-sm"}),jsxRuntime.jsx($,{variant:"icon",className:"mr-1 w-6 rounded outline-offset-0",children:jsxRuntime.jsx(lucideReact.CalendarIcon,{"aria-hidden":true,className:"h-4 w-4"})})]}),t&&jsxRuntime.jsx(Ne,{children:t}),typeof r=="string"?jsxRuntime.jsx(he,{children:r}):null,jsxRuntime.jsx(yt,{children:jsxRuntime.jsx(ti,{})})]})}var _R=e=>{let t=zt({isInvalid:e.isInvalid,isDisabled:e.isDisabled,isFocused:e.isFocused,transparent:e.transparent,size:e.size});return tailwindMerge.twMerge(t,"pr-9","[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",e.className)};function ts({label:e,description:t,errorMessage:r,size:o="md",tooltip:n,isRequired:a,transparent:i,validationResult:s,reserveErrorSpace:l=true,descriptionPlacement:c="below",...d}){let u=qe.useId(),{isFocused:p,handleFocus:m,handleBlur:f}=ur();return jsxRuntime.jsx(reactAriaComponents.NumberField,{...d,id:u,isRequired:a,className:Me(d.className,"group flex flex-col gap-1"),step:d.step??1,onChange:g=>{typeof g=="number"&&(d.maxValue!=null&&g>d.maxValue?d.onChange?.(d.maxValue):d.minValue!=null&&g<d.minValue?d.onChange?.(d.minValue):d.onChange?.(g));},isInvalid:!!r||typeof d.value=="number"&&(d.maxValue!=null&&d.value>d.maxValue||d.minValue!=null&&d.value<d.minValue),children:({isDisabled:g,isInvalid:x})=>jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[e&&jsxRuntime.jsx(Ke,{size:o,tooltip:n,description:c==="tooltip"||c==="inline"?t:void 0,descriptionPlacement:c,isRequired:a,htmlFor:u,children:e}),jsxRuntime.jsx("div",{className:"relative",children:jsxRuntime.jsxs(reactAriaComponents.Group,{className:"relative",children:[jsxRuntime.jsx(reactAriaComponents.Input,{onFocus:h=>m(h,d.onFocus),onBlur:h=>f(h,d.onBlur),className:_R({isInvalid:x||!!r,isDisabled:g,isFocused:p,transparent:i,size:o,className:typeof d.className=="string"?d.className:void 0})}),jsxRuntime.jsxs("div",{className:"absolute inset-y-[2px] right-[2px] flex flex-col divide-y divide-border-default border-l border-border-default overflow-hidden rounded-r-[calc(var(--control-border-radius)-2px)]",children:[jsxRuntime.jsx(reactAriaComponents.Button,{slot:"increment",isDisabled:g,className:"flex h-1/2 w-7 items-center justify-center bg-background-input hover:bg-background-input-hover active:bg-background-input-active disabled:cursor-not-allowed disabled:opacity-50",children:jsxRuntime.jsx(O,{name:"CaretUp",size:14})}),jsxRuntime.jsx(reactAriaComponents.Button,{slot:"decrement",isDisabled:g,className:"flex h-1/2 w-7 items-center justify-center bg-background-input hover:bg-background-input-hover active:bg-background-input-active disabled:cursor-not-allowed disabled:opacity-50",children:jsxRuntime.jsx(O,{name:"CaretDown",size:14})})]})]})}),l?jsxRuntime.jsx("div",{className:"mt-1 min-h-[20px]",children:r?jsxRuntime.jsx(he,{size:o,children:typeof r=="function"?r(s):r}):t&&c==="below"?jsxRuntime.jsx(Ne,{size:o,children:t}):null}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:r?jsxRuntime.jsx(he,{size:o,className:"mt-1",children:typeof r=="function"?r(s):r}):t&&c==="below"?jsxRuntime.jsx(Ne,{size:o,className:"mt-1",children:t}):null})]})})}var Bp={sm:{track:"h-4 w-7",handle:"h-3.5 w-3.5",text:"text-xs"},md:{track:"h-5 w-9",handle:"h-4 w-4",text:"text-sm"},lg:{track:"h-6 w-11",handle:"h-5 w-5",text:"text-base"},xl:{track:"h-7 w-14",handle:"h-6 w-6",text:"text-lg"}};function t2({isSelected:e,isDisabled:t,size:r="md"}){let o="flex px-px items-center shrink-0 cursor-default rounded-full transition duration-200 ease-in-out shadow-inner border border-transparent",n=Bp[r].track,a=rt,i="focus-visible:outline-action-primary",s="";return e?s="bg-action-primary forced-colors:!bg-[Highlight] group-pressed:bg-action-primary-hover":s="bg-border-input group-pressed:bg-border-focus",[o,n,a,i,s,t?"bg-background-muted forced-colors:group-selected:!bg-[GrayText] forced-colors:border-[GrayText]":""].filter(Boolean).join(" ")}function r2({isSelected:e,isDisabled:t,size:r="md"}){let o="transform rounded-full bg-background-surface outline-none shadow transition duration-200 ease-in-out",n=Bp[r].handle;return [o,n,e?"translate-x-[100%]":"translate-x-0",t?"forced-colors:outline-[GrayText]":""].filter(Boolean).join(" ")}function jl({children:e,variant:t="primary",size:r="md",...o}){return jsxRuntime.jsx(reactAriaComponents.Switch,{...o,className:Me(o.className,`relative group flex items-center gap-2 ${Bp[r].text} text-text-primary transition disabled:text-text-disabled forced-colors:disabled:text-[GrayText]`),children:n=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:t2({...n,size:r}),children:jsxRuntime.jsx("span",{className:r2({...n,size:r})})}),e]})})}function bx(e){return new Intl.NumberFormat("en-US").format(e)}function hx({isOpen:e,onClose:t,facetConfigs:r,facetCounts:o={},currentFilters:n,onApply:a,onClear:i,title:s="Filters",resultCount:l}){let[c,d]=qe.useState(n),[u,p]=qe.useState({}),[m,f]=qe.useState({}),[g,x]=qe.useState(null),{isMobile:b}=ar(),h=qe.useMemo(()=>r.some(C=>C.group),[r]),{groups:y,ungroupedFacets:v,facetsByGroup:S}=qe.useMemo(()=>{let C=new Set,L=[],F={};for(let j of r)j.group?(C.has(j.group)||(C.add(j.group),F[j.group]=[]),F[j.group].push(j)):L.push(j);return {groups:Array.from(C),ungroupedFacets:L,facetsByGroup:F}},[r]);qe.useEffect(()=>{e&&(d(n),p({}),f({}),x(!b&&y.length>0?y[0]:null));},[e,n,y,b]);let w=qe.useMemo(()=>!c||Jl(c)?0:$n(c).length,[c]),N=()=>{a(c),t();},R=()=>{let C=$i();d(C),i?i():a(C),t();},P=C=>{if(!c)return [];if(!$n(c).includes(C))return [];let F=[];function j(ne){if(ne)for(let ce of ne.conditions)"conditions"in ce?j(ce):ce.field===C&&ce.operator==="in"&&Array.isArray(ce.value)&&F.push(...ce.value.map(String));}return j(c),F},E=(C,L,F)=>{let j=_n(c,C);L!==void 0&&(j=hn(j,{field:C,operator:"gte",value:L})),F!==void 0&&(j=hn(j,{field:C,operator:"lte",value:F})),d(j);},I=C=>{if(!c)return;let L;function F(j){if(j)for(let ne of j.conditions)"conditions"in ne?F(ne):ne.field===C&&ne.operator==="eq"&&typeof ne.value=="boolean"&&(L=ne.value);}return F(c),L},T=(C,L)=>{let F=_n(c,C);L!==void 0&&(F=hn(F,{field:C,operator:"eq",value:L})),d(F);},D=(C,L,F)=>{let j=_n(c,C);L&&(j=hn(j,{field:C,operator:"gte",value:L.toString()})),F&&(j=hn(j,{field:C,operator:"lte",value:F.toString()})),d(j);},M=C=>{let L=S[C]||[],F=c?$n(c):[];return L.filter(j=>F.includes(j.field)).length},B="pr-9 bg-background-muted/50",z="border-t border-border-muted",V="text-sm font-medium text-text-link-default",U=C=>jsxRuntime.jsx("span",{className:V,children:C}),Z=C=>{let L=o[C.field]||{},F=u[C.field]||"",j=[];C.values?j=C.values.map(ee=>({value:String(ee.value),label:ee.label,count:L[String(ee.value)]})):j=Object.entries(L).map(([ee,ae])=>({value:ee,label:ee,count:ae}));let ne=j.length;if(F){let ee=F.toLowerCase();j=j.filter(ae=>ae.label.toLowerCase().includes(ee));}j.sort((ee,ae)=>ee.count!==void 0&&ae.count!==void 0&&ae.count!==ee.count?ae.count-ee.count:ee.label.localeCompare(ae.label));let ce=C.type||"string";if(ce==="string"||!C.type){let ee=P(C.field),ae=C.searchThreshold??10,Le=C.maxVisibleOptions??50,ge=m[C.field]??false,xe=ge||j.length<=Le?j:j.slice(0,Le),re=j.length>Le&&!ge;return jsxRuntime.jsxs(ln,{id:C.field,children:[jsxRuntime.jsx(cn,{title:C.label,description:C.description,className:B,endContent:ee.length>0?U(`${ee.length} selected`):void 0}),jsxRuntime.jsx(dn,{className:z,children:jsxRuntime.jsxs("div",{className:"space-y-4 pt-4 pb-4",children:[ne>ae&&jsxRuntime.jsx(Zn,{value:F,onChange:ie=>p(ve=>({...ve,[C.field]:ie})),onClear:()=>p(ie=>({...ie,[C.field]:""})),placeholder:`Search ${C.label.toLowerCase()}...`,size:"sm",className:"w-full !max-w-none pr-4"}),jsxRuntime.jsx(Ku,{value:ee,onChange:ie=>{let ve=_n(c,C.field);ie.length>0&&(ve=hn(ve,{field:C.field,operator:"in",value:ie})),d(ve);},children:jsxRuntime.jsx("div",{className:"space-y-1.5",children:xe.map(ie=>jsxRuntime.jsx("div",{className:"rounded-md py-2 pr-4 transition-colors hover:bg-background-hover",children:jsxRuntime.jsx(eo,{value:ie.value,children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-3 flex-1",children:[C.renderLabel?C.renderLabel(ie.value,ie.label):jsxRuntime.jsx("span",{className:"text-sm font-medium text-text-primary",children:ie.label}),ie.count!==void 0&&jsxRuntime.jsx("span",{className:"text-xs font-medium text-text-secondary tabular-nums",children:bx(ie.count)})]})})},ie.value))})}),re&&jsxRuntime.jsx("div",{className:"pt-2 border-t border-border-muted",children:jsxRuntime.jsxs($,{variant:"ghost",size:"sm",onPress:()=>f(ie=>({...ie,[C.field]:true})),className:"w-full",children:["Show all ",j.length," options"]})}),ge&&j.length>Le&&jsxRuntime.jsx("div",{className:"pt-2 border-t border-border-muted",children:jsxRuntime.jsx($,{variant:"ghost",size:"sm",onPress:()=>f(ie=>({...ie,[C.field]:false})),className:"w-full",children:"Show less"})})]})})]},C.field)}if(ce==="number"){let ee,ae,Le=xe=>{if(xe)for(let re of xe.conditions)"conditions"in re?Le(re):re.field===C.field&&(re.operator==="gte"&&typeof re.value=="number"&&(ee=re.value),re.operator==="lte"&&typeof re.value=="number"&&(ae=re.value));};Le(c);let ge=ee!==void 0||ae!==void 0;return jsxRuntime.jsxs(ln,{id:C.field,children:[jsxRuntime.jsx(cn,{title:C.label,description:C.description,className:B,endContent:ge?U(ee!==void 0&&ae!==void 0?`${ee} - ${ae}`:ee!==void 0?`\u2265 ${ee}`:`\u2264 ${ae}`):void 0}),jsxRuntime.jsx(dn,{className:z,children:jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-4 pt-4 pb-4",children:[jsxRuntime.jsx(ts,{label:"Min",value:ee,onChange:xe=>E(C.field,xe,ae)},`${C.field}-min`),jsxRuntime.jsx(ts,{label:"Max",value:ae,onChange:xe=>E(C.field,ee,xe)},`${C.field}-max`)]})})]},C.field)}if(ce==="boolean"){let ee=I(C.field);return jsxRuntime.jsxs(ln,{id:C.field,children:[jsxRuntime.jsx(cn,{title:C.label,description:C.description,className:B,endContent:ee!==void 0?U(ee?"Yes":"No"):void 0}),jsxRuntime.jsx(dn,{className:z,children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4 pb-4",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-text-primary",children:ee!==void 0?ee?"Enabled":"Disabled":"No filter applied"}),jsxRuntime.jsx(jl,{size:"lg",isSelected:ee??false,onChange:ae=>T(C.field,ae?true:void 0),children:ee?"Yes":"No"})]})})]},C.field)}if(ce==="date"){let ee,ae,Le=ve=>{if(ve)for(let Xe of ve.conditions)"conditions"in Xe?Le(Xe):Xe.field===C.field&&(Xe.operator==="gte"&&(ee=String(Xe.value)),Xe.operator==="lte"&&(ae=String(Xe.value)));};Le(c);let ge=ee!==void 0||ae!==void 0,xe=ve=>{if(ve)try{return /^\d{4}-\d{2}-\d{2}$/.test(ve)?date.parseDate(ve):void 0}catch{return}},re=xe(ee),ie=xe(ae);return jsxRuntime.jsxs(ln,{id:C.field,children:[jsxRuntime.jsx(cn,{title:C.label,description:C.description,className:B,endContent:ge?U("Date range selected"):void 0}),jsxRuntime.jsx(dn,{className:z,children:jsxRuntime.jsx("div",{className:"pt-4 pb-4",children:jsxRuntime.jsx(Xl,{label:"Date Range",value:re&&ie?{start:re,end:ie}:void 0,onChange:ve=>{ve?D(C.field,ve.start,ve.end):D(C.field,void 0,void 0);}})})})]},C.field)}return null},G=()=>jsxRuntime.jsxs("div",{className:"flex flex-col",children:[v.map(C=>{let F=(c?$n(c):[]).includes(C.field);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>x(`__ungrouped__${C.field}`),className:"flex items-center justify-between px-6 py-3 text-left hover:bg-background-hover border-b border-border-muted transition-colors",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-text-primary",children:C.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[F&&jsxRuntime.jsx("span",{className:V,children:"1 active"}),jsxRuntime.jsx(O,{name:"CaretRight",size:"sm",className:"text-text-secondary"})]})]},C.field)}),y.map(C=>{let L=M(C);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>x(C),className:"flex items-center justify-between px-6 py-3 text-left hover:bg-background-hover border-b border-border-muted transition-colors",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-text-primary",children:C}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[L>0&&jsxRuntime.jsxs("span",{className:V,children:[L," active"]}),jsxRuntime.jsx(O,{name:"CaretRight",size:"sm",className:"text-text-secondary"})]})]},C)})]}),J=C=>{if(C.startsWith("__ungrouped__")){let F=C.replace("__ungrouped__",""),j=v.find(ne=>ne.field===F);return j?jsxRuntime.jsx(Ka,{variant:"contained",density:"comfortable",showDividers:true,defaultExpandedKeys:[j.field],children:Z(j)}):null}let L=S[C]||[];return L.length===0?null:jsxRuntime.jsx(Ka,{variant:"contained",density:"comfortable",showDividers:true,defaultExpandedKeys:[L[0].field],children:L.map(F=>Z(F))})},W=()=>{if(g){let C=g.startsWith("__ungrouped__")&&v.find(L=>L.field===g.replace("__ungrouped__",""))?.label||g;return jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>x(null),className:"flex items-center gap-2 px-4 py-3 border-b border-border-muted hover:bg-background-hover transition-colors",children:[jsxRuntime.jsx(O,{name:"CaretLeft",size:"sm",className:"text-text-secondary"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-text-primary",children:C})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto",children:J(g)})]})}return G()},A=()=>jsxRuntime.jsxs("div",{className:"flex h-full",children:[jsxRuntime.jsxs("div",{className:"w-48 flex-shrink-0 border-r border-border-muted overflow-y-auto bg-background-muted/30",children:[v.map(C=>{let F=(c?$n(c):[]).includes(C.field),j=g===`__ungrouped__${C.field}`;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>x(`__ungrouped__${C.field}`),className:`flex items-center justify-between w-full px-4 py-3 text-left border-b border-border-muted transition-colors ${j?"bg-background-selected":"hover:bg-background-hover"}`,children:[jsxRuntime.jsx("span",{className:`text-sm truncate ${j?"font-semibold text-text-primary":"font-medium text-text-primary"}`,children:C.label}),F&&jsxRuntime.jsx("span",{className:"w-2 h-2 rounded-full bg-action-primary flex-shrink-0 ml-2"})]},C.field)}),y.map(C=>{let L=M(C),F=g===C;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>x(C),className:`flex items-center justify-between w-full px-4 py-3 text-left border-b border-border-muted transition-colors ${F?"bg-background-selected":"hover:bg-background-hover"}`,children:[jsxRuntime.jsx("span",{className:`text-sm truncate ${F?"font-semibold text-text-primary":"font-medium text-text-primary"}`,children:C}),L>0&&jsxRuntime.jsx("span",{className:"w-2 h-2 rounded-full bg-action-primary flex-shrink-0 ml-2"})]},C)})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto",children:g?J(g):jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-text-secondary text-sm",children:"Select a category to view filters"})})]}),Y=()=>jsxRuntime.jsx(Ka,{variant:"contained",density:"comfortable",showDividers:true,defaultExpandedKeys:[r[0].field],children:r.map(C=>Z(C))});return jsxRuntime.jsx(cr,{isOpen:e,onClose:t,title:h&&b&&g?g.startsWith("__ungrouped__")?v.find(C=>C.field===g.replace("__ungrouped__",""))?.label||s:g:w>0?`${s} (${w} active)`:s,hideCloseIcon:false,primaryAction:{label:"Apply filters",onPress:N,variant:"primary"},secondaryAction:{label:"Clear all",onPress:R},maxWidth:h?"800px":"700px",height:"600px",mobileHeight:"85vh",contentPadding:false,footerContent:l!==void 0?jsxRuntime.jsxs("div",{className:"text-sm text-text-secondary text-center",children:[jsxRuntime.jsx("span",{className:"font-semibold text-text-primary",children:bx(l)})," ",l===1?"result":"results"," with current filters"]}):void 0,children:r.length===0?jsxRuntime.jsx("div",{className:"py-12 text-center",children:jsxRuntime.jsx("div",{className:"text-sm font-medium text-text-secondary",children:"No filters available"})}):h?b?W():A():Y()})}function Op(e="left"){switch(e){case "center":return "justify-center text-center";case "right":return "justify-end text-right";default:return "justify-start text-left"}}function yr(e="normal",t){return tailwindMerge.twMerge({strong:"font-semibold text-text-primary",high:"font-semibold text-text-primary",normal:"text-text-primary",low:"text-text-secondary"}[e],t&&"hover:text-action-primary cursor-pointer transition-colors")}function Se(e="left",t){return tailwindMerge.twMerge("flex items-center gap-1 min-w-0 overflow-hidden",Op(e),t)}function Zl(e,t="\u2014"){return e==null||e===""?t:String(e)}var xn={xs:"h-4 w-12",sm:"h-4 w-20",md:"h-4 w-24",lg:"h-4 w-32",xl:"h-4 w-40"};function Nt(e="normal"){return {strong:xn.lg,high:xn.lg,normal:xn.md,low:xn.sm}[e]}function fe(e,...t){return typeof e=="function"?e(...t):e}function xx(e="neutral",t="sm"){return tailwindMerge.twMerge("inline-flex items-center rounded-full font-medium",t==="sm"?"px-2 py-0.5 text-xs":"px-2.5 py-1 text-sm",{success:"bg-feedback-success-background text-feedback-success-text",error:"bg-feedback-error-background text-feedback-error-text",warning:"bg-feedback-warning-background text-feedback-warning-text",info:"bg-feedback-info-background text-feedback-info-text",neutral:"bg-background-muted text-text-secondary"}[e])}function yx(e){return e?"success":"neutral"}function _l(e,t=false){return t?e>0?"text-feedback-success-text":e<0?"text-feedback-error-text":"text-text-primary":"text-text-primary"}function zp(e="hover",t="secondary"){let r={primary:"text-action-primary hover:text-action-primary-hover visited:text-action-primary",secondary:"text-text-link-default hover:text-text-link-hover visited:text-text-link-default",default:"text-text-link-default hover:text-text-link-hover visited:text-text-link-default",brand:"text-action-primary hover:text-action-primary-hover visited:text-action-primary",muted:"text-text-secondary hover:text-text-secondary visited:text-text-secondary",unstyled:""},o={visible:"underline underline-offset-4 decoration-1 cursor-pointer",hover:"hover:underline hover:underline-offset-4 hover:decoration-1 cursor-pointer transition-colors",none:"cursor-pointer"},n=r[t],a=o[e]||"";return `${n} ${a}`.trim()}function Po(e,t,r,o="hover",n="secondary",a,i){if(!t)return e;let s=typeof t=="function"&&r?t(r):t,l=zp(o,n);return jsxRuntime.jsx("a",{href:s,className:tailwindMerge.twMerge(l,a==="strong"||a==="high"?"font-semibold":"",i),onClick:d=>{d.metaKey||d.ctrlKey;},children:e})}function vx({row:e,context:t,actions:r,align:o="right",size:n="sm"}){let{isLoading:a}=t;if(a)return jsxRuntime.jsx(X,{className:xn.sm});let s=(typeof r=="function"?r(e):r).filter(c=>!fe(c.hidden,e));if(s.length===0)return null;let l=Se(o);return jsxRuntime.jsx("div",{className:l,children:s.map(c=>{let d=fe(c.disabled,e);return c.variant==="icon"||!c.label?jsxRuntime.jsx($,{variant:"icon",size:n,onPress:()=>{c.onClick(e);},isDisabled:d,"aria-label":c.label||c.id,children:jsxRuntime.jsx(O,{name:c.icon||"DotsThree",size:n==="sm"?16:20})},c.id):jsxRuntime.jsxs($,{variant:c.variant||"secondary",size:n,onPress:()=>{c.onClick(e);},isDisabled:d,children:[c.icon&&jsxRuntime.jsx(O,{name:c.icon,size:n==="sm"?14:16}),c.label]},c.id)})})}function Sx({value:e,row:t,context:r,variant:o="default",label:n,size:a="sm",shape:i="square",dot:s,dotPosition:l="left",dotPulse:c,align:d="left",emptyText:u="\u2014",className:p,maxVisible:m=2,maxLabelLength:f}){let{isLoading:g}=r,x=(w,N)=>{if(!f||w.length<=f)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:w});let R=w.slice(0,f-1)+"\u2026";return jsxRuntime.jsx(dr,{content:N,children:jsxRuntime.jsx("span",{children:R})})};if(g)return jsxRuntime.jsx(X,{className:Nt("normal")});if(e==null||e==="")return jsxRuntime.jsx("div",{className:Se(d,"text-text-secondary"),children:u});if(Array.isArray(e)&&e.length===0)return jsxRuntime.jsx("div",{className:Se(d,"text-text-secondary"),children:u});let b=Se(d,p);if(Array.isArray(e)){let w=e.slice(0,m),N=e.slice(m),R=N.length>0;return jsxRuntime.jsx("div",{className:b,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[w.map((P,E)=>{let I=fe(o,P,t),T=n!==void 0?fe(n,P,t):String(P),D=fe(s,P,t),M=fe(c,P,t);return jsxRuntime.jsx("span",{className:"flex-shrink-0 whitespace-nowrap",children:jsxRuntime.jsx(ft,{variant:I,size:a,shape:i,dot:D,dotPosition:l,dotPulse:M,children:x(T,T)})},E)}),R&&jsxRuntime.jsx(dr,{content:N.join(", "),children:jsxRuntime.jsx("span",{className:"flex-shrink-0 whitespace-nowrap",children:jsxRuntime.jsxs(ft,{variant:"neutral",size:a,shape:i,children:["+",N.length]})})})]})})}let h=fe(o,e,t),y=n!==void 0?fe(n,e,t):String(e),v=fe(s,e,t),S=fe(c,e,t);return jsxRuntime.jsx("div",{className:b,children:jsxRuntime.jsx(ft,{variant:h,size:a,shape:i,dot:v,dotPosition:l,dotPulse:S,children:x(y,y)})})}function wx({value:e,context:t,format:r="icon",trueText:o="Yes",falseText:n="No",trueIcon:a="Check",falseIcon:i="X",showFalse:s=true,align:l="center",emphasis:c="normal",className:d}){let{isLoading:u}=t;if(u)return jsxRuntime.jsx(X,{className:Nt(c)});let p=!!e;if(!p&&!s)return jsxRuntime.jsx("div",{className:Se(l,d)});let m=Se(l,d);switch(r){case "icon":return jsxRuntime.jsx("div",{className:m,children:jsxRuntime.jsx(O,{name:p?a:i,size:16,className:p?"text-feedback-success-text":"text-text-disabled"})});case "text":return jsxRuntime.jsx("div",{className:m,children:jsxRuntime.jsx("span",{className:yr(c),children:p?o:n})});case "badge":return jsxRuntime.jsx("div",{className:m,children:jsxRuntime.jsx(ft,{variant:p?"success":"neutral",size:"sm",children:p?o:n})});default:return null}}var $l="var(--color-text-subtle)",Nx=zs().map((e,t)=>`var(--color-viz-categorical-${t+1})`);function Tx({value:e,row:t,context:r,color:o,swatch:n="dot",emptyText:a="\u2014",align:i="left",className:s}){let{isLoading:l}=r;if(l)return jsxRuntime.jsx(X,{className:Nt("normal")});let c=fe(e,t),d=c==null?"":String(c);return d.length===0?jsxRuntime.jsx("div",{className:Se(i,"text-text-secondary"),children:a}):jsxRuntime.jsxs("div",{className:Se(i,tailwindMerge.twMerge("gap-2",s)),children:[jsxRuntime.jsx("span",{"aria-hidden":"true",className:tailwindMerge.twMerge("h-2 w-2 flex-shrink-0",n==="dot"?"rounded-full":"rounded-sm"),style:{backgroundColor:o??$l}}),jsxRuntime.jsx("span",{className:"truncate",children:d})]})}function Rx({row:e,context:t,firstName:r,lastName:o,email:n,avatarUrl:a,layout:i="stacked",size:s="sm",href:l,LinkComponent:c,linkVariant:d="secondary",showEmail:u=false,badge:p,emphasis:m="normal",align:f="left",className:g,piiEntity:x}){let{isLoading:b}=t,h=fe(r,e),y=fe(o,e),v=fe(n,e),S=fe(a,e),w=fe(l,e),N=fe(p,e),R=fe(x,e),P=Se(f,g);return jsxRuntime.jsx("div",{className:P,children:jsxRuntime.jsx(yl,{firstName:h,lastName:y,email:v,avatarUrl:S,layout:i,size:s,href:w,LinkComponent:c,linkVariant:d,showEmail:u,badge:N,emphasis:m,isLoading:b,piiEntity:R})})}function Ex({value:e,row:t,context:r,render:o,className:n}){let a=o(e,t,r);return jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("h-full w-full",n),children:a})}function Mx({value:e,row:t,context:r,format:o="date",customFormat:n,emptyText:a="\u2014",align:i="left",emphasis:s="normal",href:l,linkBehavior:c="hover",className:d}){let{isLoading:u}=r;if(u)return jsxRuntime.jsx(X,{className:Nt(s)});if(!e)return jsxRuntime.jsx("div",{className:Se(i,"text-text-secondary"),children:a});let p=e instanceof Date?e:new Date(e);if(isNaN(p.getTime()))return jsxRuntime.jsx("div",{className:Se(i,"text-text-secondary"),children:a});let m;switch(o){case "date":m=p.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});break;case "time":m=p.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});break;case "datetime":m=p.toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});break;case "relative":m=f2(p);break;case "custom":m=n?p.toLocaleString("en-US",n):p.toISOString();break;default:m=p.toLocaleDateString();}let f=Se(i,tailwindMerge.twMerge(yr(s),d)),g=fe(l,t);return g?jsxRuntime.jsx("div",{className:f,children:Po(m,g,t,c)}):jsxRuntime.jsx("div",{className:f,children:m})}function f2(e){let r=new Date().getTime()-e.getTime(),o=Math.floor(r/1e3),n=Math.floor(o/60),a=Math.floor(n/60),i=Math.floor(a/24);return o<60?"just now":n<60?`${n} minute${n!==1?"s":""} ago`:a<24?`${a} hour${a!==1?"s":""} ago`:i<7?`${i} day${i!==1?"s":""} ago`:e.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}var b2={up:"ArrowUp",down:"ArrowDown",flat:"Minus"},h2={positive:"text-feedback-success-text",negative:"text-feedback-error-text",neutral:"text-text-secondary"};function Hp(e){return e>0?"up":e<0?"down":"flat"}function x2(e,t,r){switch(e){case "percent":return {type:"percentage",decimals:t};case "currency":return {type:"currency",currency:r,minimumFractionDigits:t,maximumFractionDigits:t};case "compact":return {type:"number",notation:"compact",decimals:t,thousandsSeparator:true};default:return {type:"number",decimals:t,thousandsSeparator:true}}}function Lx({value:e,row:t,context:r,direction:o,tone:n="neutral",format:a="number",decimals:i=0,currency:s="USD",showIcon:l=true,align:c="right",emphasis:d="normal",emptyText:u="\u2014",className:p}){let{isLoading:m}=r;if(m)return jsxRuntime.jsx(X,{className:Nt(d)});let f=typeof e=="number"?e:Number(e);if(e==null||e===""||!Number.isFinite(f))return jsxRuntime.jsx("div",{className:Se(c,"text-text-secondary"),children:u});let g=fe(o,t)??Hp(f),x=fe(n,t)??"neutral",b=Pr(f,x2(a,i,s))??u,h=f>0?"+":"",v=Se(c,tailwindMerge.twMerge(d==="strong"||d==="high"?"font-semibold":void 0,p,h2[x]));return jsxRuntime.jsxs("div",{className:v,children:[l&&jsxRuntime.jsx(O,{name:b2[g],size:"xs","aria-hidden":true}),jsxRuntime.jsx("span",{children:`${h}${b}`})]})}function rc({manufacturer:e,model:t,deviceType:r,deviceTypeIconName:o,logoUrl:n,layout:a="stacked",size:i="md",href:s,LinkComponent:l,linkVariant:c="unstyled",showDeviceTypeIcon:d=true,showLogo:u=true,emphasis:p="normal",isLoading:m=false,className:f,piiEntity:g}){let[x,b]=qe.useState(false),h=o||(r?C2(r):"DeviceMobile"),v={xs:{iconSize:28,logoSize:"w-7 h-7",gap:"gap-1.5",textSize:"text-xs",secondaryTextSize:"text-xs",iconInTextSize:12,skeletonIcon:28,skeletonText:80,skeletonSecondary:60},sm:{iconSize:32,logoSize:"w-8 h-8",gap:"gap-2",textSize:"text-sm",secondaryTextSize:"text-xs",iconInTextSize:14,skeletonIcon:32,skeletonText:96,skeletonSecondary:72},md:{iconSize:32,logoSize:"w-9 h-9",gap:"gap-3",textSize:"text-base",secondaryTextSize:"text-sm",iconInTextSize:16,skeletonIcon:36,skeletonText:128,skeletonSecondary:96},lg:{iconSize:40,logoSize:"w-10 h-10",gap:"gap-3",textSize:"text-lg",secondaryTextSize:"text-base",iconInTextSize:18,skeletonIcon:40,skeletonText:160,skeletonSecondary:120}}[i],S=n&&!x&&u,N={strong:"font-semibold text-text-primary",high:"font-semibold text-text-primary",normal:"text-text-primary",low:"text-text-secondary"}[p],R=({children:P,className:E})=>s?l?jsxRuntime.jsx(l,{href:s,className:E,children:P}):jsxRuntime.jsx(ut,{href:s,variant:c,className:tailwindMerge.twMerge("hover:underline",E),asButton:false,children:P}):jsxRuntime.jsx("span",{className:E,children:P});if(m)return a==="inline"?jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center",v.gap,f),children:[jsxRuntime.jsx(X,{width:v.skeletonIcon,height:v.skeletonIcon,className:"flex-shrink-0 rounded"}),jsxRuntime.jsx(X,{width:v.skeletonText,height:v.skeletonIcon*.6})]}):jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center",v.gap,f),children:[jsxRuntime.jsx(X,{width:v.skeletonIcon,height:v.skeletonIcon,className:"flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx(X,{width:v.skeletonText,height:16}),jsxRuntime.jsx(X,{width:v.skeletonSecondary,height:12})]})]});if(a==="inline"){let P=`${e} ${t}`;return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center",v.gap,f),children:[jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex-shrink-0 flex items-center justify-center rounded border border-border-muted",v.logoSize),children:S?jsxRuntime.jsx("img",{src:n,alt:`${e} logo`,className:"w-full h-full object-contain",onError:()=>b(true)}):jsxRuntime.jsx(O,{name:h,size:v.iconSize*.6,className:"text-text-secondary"})}),jsxRuntime.jsx(R,{className:tailwindMerge.twMerge("truncate leading-normal hover:text-text-primary",N,v.textSize,s&&"hover:underline hover:decoration-1 hover:underline-offset-4"),children:jsxRuntime.jsx("span",{"data-pii-type":g?"device-name":void 0,"data-pii-entity":g,children:P})})]})}return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center justify-start",v.gap,f),children:[u&&jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex-shrink-0 flex items-center justify-center rounded border border-border-muted",v.logoSize),children:S?jsxRuntime.jsx("img",{src:n,alt:`${e} logo`,className:"w-full h-full object-contain",onError:()=>b(true)}):jsxRuntime.jsx(O,{name:h,size:v.iconSize*.6,className:"text-text-secondary"})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[jsxRuntime.jsx(R,{className:tailwindMerge.twMerge("truncate leading-normal hover:text-text-primary",N,v.textSize,s&&"hover:underline hover:decoration-1 hover:underline-offset-4"),children:jsxRuntime.jsx("span",{"data-pii-type":g?"device-name":void 0,"data-pii-entity":g,children:e})}),jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center gap-1.5 text-text-secondary leading-normal",v.secondaryTextSize),children:[d&&jsxRuntime.jsx(O,{name:h,size:v.iconInTextSize,className:"flex-shrink-0"}),jsxRuntime.jsx("span",{className:"truncate","data-pii-type":g?"device-name":void 0,"data-pii-entity":g,children:t})]})]})]})}function C2(e){switch(e){case "battery":return "BatteryHigh";case "charger":return "ChargingStation";case "inverter":return "Power";case "thermostat":return "ThermometerSimple";case "vehicle":return "CarSimple";case "water_heater":return "DropHalfBottom";case "meter":return "Gauge";default:return "DeviceMobile"}}function Ax({row:e,context:t,manufacturer:r,model:o,deviceType:n,logoUrl:a,layout:i="stacked",size:s="sm",href:l,LinkComponent:c,linkVariant:d="secondary",showDeviceTypeIcon:u=true,showLogo:p=true,emphasis:m="normal",align:f="left",className:g,piiEntity:x}){let{isLoading:b}=t,h=fe(r,e),y=fe(o,e),v=fe(n,e),S=fe(a,e),w=fe(l,e),N=fe(x,e),R=Se(f,g);return jsxRuntime.jsx("div",{className:R,children:jsxRuntime.jsx(rc,{manufacturer:h,model:y,deviceType:v,logoUrl:S,layout:i,size:s,href:w,LinkComponent:c,linkVariant:d,showDeviceTypeIcon:u,showLogo:p,emphasis:m,isLoading:b,piiEntity:N})})}var iX={charging:"percentage",discharging:"percentage",on:"kW",idle:void 0,off:void 0,heat:"temperature",cool:"temperature",auto:"temperature",eco:"temperature",circulate:void 0,unknown:void 0,connected:void 0,disconnected:void 0},S2=["charging","discharging","heat","cool","on","circulate","connected"],w2={unknown:"Unknown",on:"On",off:"Off",idle:"Idle",charging:"Charging",discharging:"Discharging",heat:"Heating",eco:"Eco Mode",cool:"Cooling",auto:"Auto",circulate:"Circulating",connected:"Connected",disconnected:"Disconnected"};function Gp(e){return S2.includes(e)}function Wp(e){return w2[e]}function ta({state:e,label:t,icon:r,isLoading:o,size:n="sm",shape:a="pill",dot:i,dotPulse:s,fixedWidth:l,className:c,...d}){if(o)return jsxRuntime.jsx(X,{className:"inline-flex h-6 w-20"});let u=t??Wp(e),p=Gp(e);return jsxRuntime.jsxs(ft,{variant:e,size:n,shape:a,dot:i??p,dotPulse:s??p,className:l?`w-28 justify-center ${c||""}`:c,...d,children:[r&&jsxRuntime.jsx(O,{name:r,size:n==="sm"?12:n==="md"?14:16}),u]})}var k2={importing:"Importing",exporting:"Exporting",idle:"Idle",unknown:"Unknown"};function Fx(e){return k2[e]}var T2={importing:"ArrowDown",exporting:"ArrowUp"};function nc({state:e,label:t,showIcon:r=false,isLoading:o,size:n="sm",shape:a="pill",fixedWidth:i,className:s,...l}){if(o)return jsxRuntime.jsx(X,{className:"inline-flex h-6 w-24"});let c=t??Fx(e),d=T2[e],u=n==="sm"?12:n==="md"?14:16;return r&&d?jsxRuntime.jsx(ft,{variant:e,size:n,shape:a,className:`w-6 justify-center ${s||""}`,...l,children:jsxRuntime.jsx(O,{name:d,size:u})}):jsxRuntime.jsx(ft,{variant:e,size:n,shape:a,className:i?`w-28 justify-center ${s||""}`:s,...l,children:c})}function ac({state:e,stateLabel:t,metric:r,metricFormatter:o,secondaryState:n,layout:a="horizontal",isLoading:i,size:s="sm",shape:l="pill",icon:c,fixedWidth:d,secondaryStateIconOnly:u=false,className:p}){if(i)return jsxRuntime.jsx(X,{className:tailwindMerge.twMerge("inline-flex h-6 w-32",p)});let m=r!=null&&o?Pr(r,o):null,f=a==="horizontal",g=o&&!m;return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("inline-flex items-center",f?"gap-2":"flex-col gap-1",p),children:[(m||g)&&jsxRuntime.jsx("span",{className:tailwindMerge.twMerge("font-medium inline-block",m?"text-text-primary":"text-text-secondary",s==="sm"&&"text-xs min-w-12",s==="md"&&"text-sm min-w-14",s==="lg"&&"text-base min-w-16"),children:m||"\u2014"}),jsxRuntime.jsx(ta,{state:e,label:t,icon:c,size:s,shape:l,fixedWidth:d}),n&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:n==="importing"||n==="exporting"?jsxRuntime.jsx(nc,{state:n,size:s,shape:l,fixedWidth:d,showIcon:u}):jsxRuntime.jsx(ta,{state:n,size:s,shape:l,fixedWidth:d})})]})}function Bx({value:e,row:t,context:r,metric:o,metricFormatter:n,secondaryState:a,size:i="sm",shape:s="pill",label:l,icon:c,fixedWidth:d=true,align:u="left",compact:p=false,className:m}){let{isLoading:f}=r;if(f){let v={pill:"rounded-full",rounded:"rounded-lg",square:"rounded-sm"}[s],S=o!=null||n!=null;return jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:S?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(X,{className:"h-4 w-12"}),jsxRuntime.jsx(X,{className:`h-6 w-24 ${v}`}),jsxRuntime.jsx(X,{className:`h-6 w-20 ${v}`})]}):jsxRuntime.jsx(X,{className:`h-6 w-24 ${v}`})})}if(!e)return jsxRuntime.jsx("div",{className:Se(u,m),children:jsxRuntime.jsx("span",{className:"text-text-secondary",children:"\u2014"})});let g=fe(o,t),x=fe(a,t),b=typeof l=="function"?l(e,t):l,h=Se(u,m);return g!=null||n?jsxRuntime.jsx("div",{className:tailwindMerge.twMerge(h),children:jsxRuntime.jsx(ac,{state:e,stateLabel:b,metric:g,metricFormatter:n,secondaryState:x||void 0,size:i,shape:s,icon:c,fixedWidth:d,secondaryStateIconOnly:p,layout:"horizontal"})}):jsxRuntime.jsx("div",{className:h,children:jsxRuntime.jsx(ta,{state:e,label:b,icon:c,size:i,shape:s,fixedWidth:d})})}function Ox({value:e,row:t,context:r,formatter:o,align:n="left",emphasis:a="normal",href:i,linkBehavior:s="hover",className:l,emptyText:c="\u2014",emptyClassName:d="text-text-secondary"}){let{isLoading:u}=r;if(u)return jsxRuntime.jsx(X,{className:Nt(a)});let p=fo({value:e,formatter:o,emptyText:c,emptyClassName:d}),m=yr(a),f=Se(n,tailwindMerge.twMerge(m,l)),g=jsxRuntime.jsx("div",{className:f,children:p}),x=fe(i,t);return x?Po(g,x,t,s):g}var Kp=qe__namespace.default.memo(({value:e,min:t,max:r,color:o="var(--color-viz-default)",backgroundColor:n="var(--color-background-muted)",colorScale:a,showLabel:i=true,formatLabel:s,height:l=20,minWidth:c=4,segments:d,segmentGap:u=2,barWidth:p,context:m})=>{let f=qe.useMemo(()=>r===t?100:Math.max(0,Math.min(100,(e-t)/(r-t)*100)),[e,t,r]),g=qe.useMemo(()=>o==="auto"&&a?a.type==="diverging"&&a.center!==void 0?Ti(e,t,r,a.center,a.scheme):ki(e,t,r,a.scheme):o,[o,a,e,t,r]);if(m.isLoading)return jsxRuntime.jsx("div",{className:"flex items-center gap-2 w-full",style:{height:l},children:jsxRuntime.jsx("div",{className:"h-full flex-1 animate-pulse bg-border-default rounded"})});if(d&&d>0){let h=`calc((100% - ${u*(d-1)}px) / ${d})`,y=Math.ceil(f/100*d),v={height:l,...p&&{width:typeof p=="number"?`${p}px`:p,flexShrink:0}};return jsxRuntime.jsxs("div",{className:"flex items-center gap-2 w-full",children:[jsxRuntime.jsx("div",{className:`flex gap-0.5 ${p?"":"flex-1"}`,style:v,children:Array.from({length:d}).map((S,w)=>{let N=w<y;return jsxRuntime.jsx("div",{className:"rounded-sm",style:{width:h,backgroundColor:N?g:n==="none"?"transparent":n,marginRight:w<d-1?`${u}px`:0}},w)})}),i&&jsxRuntime.jsx("span",{className:"text-sm text-text-primary whitespace-nowrap",children:s?s(e):e.toLocaleString()})]})}let x={height:l,backgroundColor:n==="none"?"transparent":n,...p&&{width:typeof p=="number"?`${p}px`:p,flexShrink:0}};return jsxRuntime.jsxs("div",{className:"flex items-center gap-2 w-full",children:[jsxRuntime.jsx("div",{className:`relative rounded-sm ${p?"":"flex-1"}`,style:x,children:jsxRuntime.jsx("div",{className:"absolute left-0 top-0 h-full rounded-sm",style:{width:`${f}%`,minWidth:f>0?c:0,backgroundColor:g}})}),i&&jsxRuntime.jsx("span",{className:"text-sm text-text-primary whitespace-nowrap",children:s?s(e):e.toLocaleString()})]})});Kp.displayName="HorizontalBarCell";function F2(e){return Math.max(1,String(Math.max(1,Math.trunc(e))).length)}function Gx({context:e,startAt:t=1,padTo:r,rowCount:o,align:n="right",className:a}){let{isLoading:i,rowIndex:s}=e;if(i)return jsxRuntime.jsx(X,{className:Nt("normal")});if(typeof s!="number"||!Number.isFinite(s))return jsxRuntime.jsx("div",{className:Se(n,"text-text-muted"),children:"\u2014"});let l=s+t,c=r??(o===void 0?void 0:F2(o+t-1)),d=c===void 0?String(l):String(l).padStart(c,"0");return jsxRuntime.jsx("div",{className:Se(n,tailwindMerge.twMerge("font-mono text-text-muted tabular-nums",a)),children:jsxRuntime.jsx("span",{children:d})})}var Yp=qe__namespace.default.memo(({value:e,data:t,color:r="var(--color-viz-default)",categoryColors:o,context:n,width:a,height:i=40})=>{let s=e||t||[],l=x=>"xValue"in x?x.xValue:x.x,c=x=>"yValue"in x?x.yValue:x.y,d=a||100,u=i,{xScale:p,yScale:m,barWidth:f}=qe.useMemo(()=>{if(s.length===0)return {xScale:scale.scaleTime({range:[0,d],domain:[new Date,new Date]}),yScale:scale.scaleLinear({range:[u,0],domain:[0,1]}),barWidth:2};let x=d3Array.extent(s,N=>l(N)),b=d3Array.min(s,N=>c(N))??0,h=d3Array.max(s,N=>c(N))??0,y=b<0?b:0,v=scale.scaleTime({range:[0,d],domain:x}),S=scale.scaleLinear({range:[u,0],domain:[y,h*1.05]}),w=s.length>1?d/s.length*.8:8;return {xScale:v,yScale:S,barWidth:Math.max(2,w)}},[s,d,u]);if(n.isLoading)return jsxRuntime.jsx("div",{className:"flex items-center gap-0.5",style:{width:d,height:u},children:Array.from({length:5}).map((x,b)=>jsxRuntime.jsx("div",{className:"flex-1 animate-pulse bg-border-default rounded"},b))});if(!s||s.length===0)return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-text-secondary text-xs",style:{width:d,height:u},children:"No data"});let g=m(0);return jsxRuntime.jsx("svg",{width:d,height:u,children:s.map((x,b)=>{let h=c(x),y=p(l(x)),v=m(h),S=Math.abs(g-v),w=x.category&&o?.[x.category]?o[x.category]:r;return jsxRuntime.jsx(shape.Bar,{x:y-f/2,y:h>=0?v:g,width:f,height:S,fill:w,rx:1},`bar-${b}`)})})});Yp.displayName="MiniBarCell";function Kx({value:e,row:t,context:r,format:o="number",decimals:n=0,prefix:a,suffix:i,emptyText:s="\u2014",align:l="right",emphasis:c="normal",href:d,linkBehavior:u="hover",showPositiveSign:p=false,colorCode:m=false,className:f}){let{isLoading:g}=r;if(g)return jsxRuntime.jsx(X,{className:Nt(c)});if(e==null||isNaN(Number(e)))return jsxRuntime.jsx("div",{className:Se(l,"text-text-secondary"),children:s});let x=Number(e),b;switch(o){case "currency":b=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:n,maximumFractionDigits:n}).format(x);break;case "percent":b=new Intl.NumberFormat("en-US",{style:"percent",minimumFractionDigits:n,maximumFractionDigits:n}).format(x/100);break;case "compact":b=new Intl.NumberFormat("en-US",{notation:"compact",minimumFractionDigits:n>0?1:0,maximumFractionDigits:n}).format(x);break;default:b=new Intl.NumberFormat("en-US",{minimumFractionDigits:n,maximumFractionDigits:n}).format(x);}let y=`${p&&x>0?"+":""}${b}`,v=m?_l(x,true):yr(c),S=Se(l,tailwindMerge.twMerge(v,f)),w=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[a&&jsxRuntime.jsx("span",{className:"text-text-secondary",children:a}),jsxRuntime.jsx("span",{children:y}),i&&jsxRuntime.jsx("span",{className:"text-text-secondary",children:i})]}),N=fe(d,t);return N?jsxRuntime.jsx("div",{className:S,children:Po(w,N,t,u)}):jsxRuntime.jsx("div",{className:S,children:w})}var J2={low:"var(--color-feedback-warning-text)",critical:"var(--color-feedback-error-text)"};function Xp(e,t){if(t){if(t.critical!==void 0&&e<=t.critical)return "critical";if(t.low!==void 0&&e<=t.low)return "low"}}var jp=qe__namespace.default.memo(({value:e,showLabel:t=true,color:r="var(--color-viz-categorical-1)",backgroundColor:o="var(--color-background-muted)",height:n=20,segments:a,segmentGap:i=2,colorScale:s,thresholds:l,context:c})=>{let d=qe.useMemo(()=>Math.max(0,Math.min(100,e)),[e]),u=qe.useMemo(()=>Xp(d,l),[d,l]),p=qe.useMemo(()=>u?J2[u]:r==="auto"&&s?s.type==="diverging"&&s.center!==void 0?Ti(e,0,100,s.center,s.scheme):ki(e,0,100,s.scheme):r,[r,s,u,e]);if(c.isLoading)return jsxRuntime.jsx("div",{className:"flex items-center gap-2",style:{height:n},children:jsxRuntime.jsx("div",{className:"h-full w-full animate-pulse bg-border-default rounded"})});if(a&&a>0){let f=`calc((100% - ${i*(a-1)}px) / ${a})`,g=Math.ceil(d/100*a);return jsxRuntime.jsxs("div",{className:"flex items-center gap-2 w-full","data-threshold":u,children:[jsxRuntime.jsx("div",{className:"flex gap-0.5 flex-1",style:{height:n},children:Array.from({length:a}).map((x,b)=>{let h=b<g,y=p;if(!u&&r==="auto"&&s&&h){let v=(b+1)/a*100;s.type==="diverging"&&s.center!==void 0?y=Ti(v,0,100,s.center,s.scheme):y=ki(v,0,100,s.scheme);}return jsxRuntime.jsx("div",{className:"rounded-sm",style:{width:f,backgroundColor:h?y:o==="none"?"transparent":o,marginRight:b<a-1?`${i}px`:0}},b)})}),t&&jsxRuntime.jsxs("span",{className:"text-sm text-text-primary whitespace-nowrap",children:[d.toFixed(0),"%"]})]})}return jsxRuntime.jsxs("div",{className:"flex items-center gap-2 w-full","data-threshold":u,children:[jsxRuntime.jsx("div",{className:"relative flex-1 rounded-sm",style:{height:n,backgroundColor:o==="none"?"transparent":o},children:jsxRuntime.jsx("div",{className:"absolute left-0 top-0 h-full rounded-sm transition-all duration-300",style:{width:`${d}%`,backgroundColor:p}})}),t&&jsxRuntime.jsxs("span",{className:"text-sm text-text-primary whitespace-nowrap",children:[d.toFixed(0),"%"]})]})});jp.displayName="PercentBarCell";var j2="\u2013",Yx="\u200A";function Jx(e){if(e==null||e==="")return;let t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:void 0}function Xx({row:e,context:t,min:r,max:o,decimals:n=0,unit:a,emptyText:i="\u2014",align:s="right",emphasis:l="normal",className:c}){let{isLoading:d}=t;if(d)return jsxRuntime.jsx(X,{className:Nt(l)});let u=Jx(fe(r,e)),p=Jx(fe(o,e));if(u===void 0&&p===void 0)return jsxRuntime.jsx("div",{className:Se(s,"text-text-secondary"),children:i});let m=x=>new Intl.NumberFormat("en-US",{minimumFractionDigits:n,maximumFractionDigits:n}).format(x),f=u!==void 0&&p!==void 0?`${m(u)}${Yx}${j2}${Yx}${m(p)}`:m(u!==void 0?u:p),g=Se(s,tailwindMerge.twMerge("tabular-nums",yr(l),c));return jsxRuntime.jsxs("div",{className:g,children:[jsxRuntime.jsx("span",{children:f}),a&&jsxRuntime.jsx("span",{className:"text-text-secondary",children:a})]})}function dc({row:e,context:t,isSelected:r=false,onSelect:o,isDisabled:n=false,align:a="center"}){let{isLoading:i}=t;if(i)return jsxRuntime.jsx("div",{className:Se(a),children:jsxRuntime.jsx(X,{className:"h-4 w-4 rounded"})});let s=fe(n,e),l=Se(a);return jsxRuntime.jsx("div",{className:l,children:jsxRuntime.jsx(eo,{isSelected:r,onChange:c=>{o?.(e,c);},isDisabled:s,"aria-label":"Select row"})})}function uc({streetAddress:e,city:t,state:r,postalCode:o,layout:n="stacked",size:a="md",href:i,LinkComponent:s,linkVariant:l="unstyled",emphasis:c="normal",isLoading:d=false,className:u,piiEntity:p}){let f={xs:{iconSize:16,iconContainerSize:"w-7 h-7",gap:"gap-1.5",textSize:"text-xs",secondaryTextSize:"text-xs",skeletonIconStacked:28,skeletonIconInline:16,skeletonText:80,skeletonSecondary:60},sm:{iconSize:20,iconContainerSize:"w-8 h-8",gap:"gap-2",textSize:"text-sm",secondaryTextSize:"text-xs",skeletonIconStacked:32,skeletonIconInline:20,skeletonText:96,skeletonSecondary:72},md:{iconSize:24,iconContainerSize:"w-9 h-9",gap:"gap-3",textSize:"text-base",secondaryTextSize:"text-sm",skeletonIconStacked:36,skeletonIconInline:24,skeletonText:128,skeletonSecondary:96},lg:{iconSize:28,iconContainerSize:"w-10 h-10",gap:"gap-3",textSize:"text-lg",secondaryTextSize:"text-base",skeletonIconStacked:40,skeletonIconInline:28,skeletonText:160,skeletonSecondary:120}}[a],x={strong:"font-semibold text-text-primary",high:"font-semibold text-text-primary",normal:"text-text-primary",low:"text-text-secondary"}[c],b=[];t&&b.push(t),r&&o?b.push(`${r} ${o}`):r?b.push(r):o&&b.push(o);let h=b.join(", "),y=({children:S,className:w})=>i?s?jsxRuntime.jsx(s,{href:i,className:w,children:S}):jsxRuntime.jsx(ut,{href:i,variant:l,className:tailwindMerge.twMerge("hover:underline",w),asButton:false,children:S}):jsxRuntime.jsx("span",{className:w,children:S});if(d)return n==="inline"?jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center",f.gap,u),children:[jsxRuntime.jsx(X,{width:f.skeletonIconInline,height:f.skeletonIconInline,className:"flex-shrink-0 rounded"}),jsxRuntime.jsx(X,{width:f.skeletonText,height:f.skeletonIconInline*.8})]}):jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center",f.gap,u),children:[jsxRuntime.jsx(X,{width:f.skeletonIconStacked,height:f.skeletonIconStacked,className:"flex-shrink-0 rounded"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx(X,{width:f.skeletonText,height:16}),jsxRuntime.jsx(X,{width:f.skeletonSecondary,height:12})]})]});if(n==="inline")return jsxRuntime.jsxs(y,{className:tailwindMerge.twMerge("flex items-center",f.gap,i&&"hover:bg-background-hover transition-colors",u),children:[jsxRuntime.jsx(O,{name:"MapPin",size:f.iconSize,className:"text-text-secondary flex-shrink-0"}),jsxRuntime.jsx("span",{className:tailwindMerge.twMerge("leading-normal truncate hover:text-text-primary",x,f.textSize,i&&"hover:underline hover:decoration-1 hover:underline-offset-4"),"data-pii-type":p?"address":void 0,"data-pii-entity":p,children:e})]});let v=()=>{if(p){if(t&&r&&o)return "city-state-zip";if(t&&r)return "city-state";if(t)return "city";if(r)return "state";if(o)return "postal-code"}};return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center justify-start",f.gap,u),children:[jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex-shrink-0 flex items-center justify-center rounded border border-border-muted",f.iconContainerSize),children:jsxRuntime.jsx(O,{name:"MapPin",size:f.iconSize,className:"text-text-secondary"})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[jsxRuntime.jsx(y,{className:tailwindMerge.twMerge("leading-normal truncate hover:text-text-primary",x,f.textSize,i&&"hover:underline hover:decoration-1 hover:underline-offset-4"),children:jsxRuntime.jsx("span",{"data-pii-type":p?"address":void 0,"data-pii-entity":p,children:e})}),h&&jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("text-text-secondary leading-normal truncate",f.secondaryTextSize),"data-pii-type":v(),"data-pii-entity":p,children:h})]})]})}function qx({row:e,context:t,streetAddress:r,city:o,state:n,postalCode:a,layout:i="stacked",size:s="sm",href:l,LinkComponent:c,linkVariant:d="secondary",emphasis:u="normal",align:p="left",className:m,piiEntity:f}){let{isLoading:g}=t,x=fe(r,e),b=fe(o,e),h=fe(n,e),y=fe(a,e),v=fe(l,e),S=fe(f,e),w=Se(p,m);return jsxRuntime.jsx("div",{className:w,children:jsxRuntime.jsx(uc,{streetAddress:x,city:b,state:h,postalCode:y,layout:i,size:s,href:v,LinkComponent:c,linkVariant:d,emphasis:u,isLoading:g,piiEntity:S})})}var qp=qe__namespace.default.memo(({value:e,data:t,type:r="line",color:o="var(--color-viz-default)",strokeWidth:n=2,categoryColors:a,context:i,width:s,height:l=40})=>{let c=e||t||[],d=s||100,u=l,{xScale:p,yScale:m}=qe.useMemo(()=>{if(c.length===0)return {xScale:scale.scaleTime({range:[0,d],domain:[new Date,new Date]}),yScale:scale.scaleLinear({range:[u,0],domain:[0,1]})};let g=d3Array.extent(c,y=>y.xValue),x=d3Array.min(c,y=>y.yValue)||0,b=d3Array.max(c,y=>y.yValue)||0,h=(b-x)*.1||1;return {xScale:scale.scaleTime({range:[0,d],domain:g}),yScale:scale.scaleLinear({range:[u,0],domain:[x-h,b+h]})}},[c,d,u]);if(i.isLoading)return jsxRuntime.jsx("div",{className:"flex items-center",style:{width:d,height:u},children:jsxRuntime.jsx("div",{className:"h-1 w-full animate-pulse bg-border-default rounded"})});if(!c||c.length===0)return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-text-secondary text-xs",style:{width:d,height:u},children:"No data"});let f=a&&c[0]?.category&&a[c[0].category]?a[c[0].category]:o;return jsxRuntime.jsxs("svg",{width:d,height:u,className:"overflow-visible",children:[(r==="area"||r==="both")&&jsxRuntime.jsx(shape.AreaClosed,{data:c,x:g=>p(g.xValue),y:g=>m(g.yValue),yScale:m,fill:f,fillOpacity:.15,curve:curve.curveLinear}),(r==="line"||r==="both")&&jsxRuntime.jsx(shape.LinePath,{data:c,x:g=>p(g.xValue),y:g=>m(g.yValue),stroke:f,strokeWidth:n,strokeLinecap:"round",curve:curve.curveLinear})]})});qp.displayName="SparklineCell";function $x({value:e,row:t,context:r,prefix:o,suffix:n,emptyText:a="\u2014",href:i,linkBehavior:s="hover",linkVariant:l="secondary",emphasis:c="normal",truncate:d=true,copyable:u=false,align:p="left",className:m,piiType:f,piiEntity:g}){let{isLoading:x}=r;if(x)return jsxRuntime.jsx(X,{className:Nt(c)});let b=Zl(e,a),h=fe(i,t),y=fe(g,t),v=b,S=false,w=false;if(d&&b&&typeof b=="string")if(typeof d=="boolean")w=true;else {let{position:M="end",length:B=16,ellipsis:z="...",tooltip:V=true}=d;if(b.length>B){switch(M){case "start":v=Js(b,B);break;case "middle":v=La(b,B);break;case "end":v=Xs(b,B,z);break}S=V;}}let N=f&&y?{"data-pii-type":f,"data-pii-entity":y}:{},R=Object.keys(N).length>0,P=jsxRuntime.jsx("span",{className:w?"truncate":"",...N,children:v}),E=S?jsxRuntime.jsx(dr,{content:R?jsxRuntime.jsx("span",{...N,children:String(b)}):String(b),children:P}):P,I=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[o&&jsxRuntime.jsx("span",{className:"text-text-secondary",children:o}),E,n&&jsxRuntime.jsx("span",{className:"text-text-secondary",children:n})]}),T=I;if(u&&b&&b!==a){let M=typeof u=="function"?u(t):String(b);T=jsxRuntime.jsx(on,{value:M,size:"sm",children:I});}if(h){let M=Se(p,m);return jsxRuntime.jsx("div",{className:M,children:Po(T,h,t,s,l,c)})}let D=Se(p,tailwindMerge.twMerge(yr(c),m));return jsxRuntime.jsx("div",{className:D,children:T})}var sE={sm:"sm:hidden",md:"md:hidden",lg:"lg:hidden",xl:"xl:hidden"},lE={sm:"hidden sm:grid",md:"hidden md:grid",lg:"hidden lg:grid",xl:"hidden xl:grid"};function pc(e,t){return t.accessor?typeof t.accessor=="function"?t.accessor(e):e[t.accessor]:null}function mc(e,t,r,o){if(r.cell){let n=r.cell,a=typeof r.cellProps=="function"?r.cellProps(e,t):r.cellProps;return jsxRuntime.jsx(n,{value:e,row:t,context:o,...a})}return r.render?r.render(e,t,o):e?.toString()??"\u2014"}function gc({row:e,columns:t,density:r,isLoading:o,onClick:n}){let a=t.filter(u=>u.mobile!==false).map(u=>{let p=u.mobile===false?null:u.mobile;return {...u,mobilePriority:p?.priority??2,mobileFormat:p?.format??"secondary",showLabel:p?.label??p?.format==="secondary",icon:p?.icon}}).sort((u,p)=>u.mobilePriority-p.mobilePriority),i=a.filter(u=>u.mobilePriority===1||u.mobileFormat==="primary"),s=a.filter(u=>u.mobilePriority===2&&u.mobileFormat!=="primary"),l=a.filter(u=>u.mobileFormat==="badge"),c={isLoading:!!o,rowIndex:0,columnIndex:0,density:r};return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("border-b border-border-default bg-background-surface transition-colors",n&&"cursor-pointer hover:bg-background-hover active:bg-background-pressed",{compact:"px-3 py-2",default:"px-4 py-3",relaxed:"px-4 py-4"}[r]),onClick:n,role:n?"button":void 0,tabIndex:n?0:void 0,children:[i.length>0&&jsxRuntime.jsxs("div",{className:"mb-2 flex items-start justify-between",children:[jsxRuntime.jsx("div",{className:"flex-1",children:i.map(u=>{let p=pc(e,u);return jsxRuntime.jsx("div",{className:"font-medium text-text-primary [&>*]:!justify-start [&>*]:!text-left",children:mc(p,e,u,c)},u.id)})}),l.length>0&&jsxRuntime.jsx("div",{className:"ml-2 flex flex-wrap gap-1",children:l.map(u=>{let p=pc(e,u);return jsxRuntime.jsx("div",{className:"inline-flex",children:mc(p,e,u,c)},u.id)})})]}),s.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:s.map(u=>{let p=pc(e,u),m=u.showLabel&&u.label;return jsxRuntime.jsxs("div",{className:"flex items-center text-sm text-text-secondary",children:[u.icon&&jsxRuntime.jsx(O,{name:u.icon,className:"mr-1.5 h-4 w-4 flex-shrink-0"}),m&&jsxRuntime.jsxs("span",{className:"mr-1 font-medium",children:[u.label,":"]}),jsxRuntime.jsx("span",{className:"truncate [&>*]:!justify-start [&>*]:!text-left",children:mc(p,e,u,c)})]},u.id)})})]})}function bc({row:e,columns:t,density:r,isLoading:o,onClick:n}){let a=t.filter(l=>l.mobile!==false),i={isLoading:!!o,rowIndex:0,columnIndex:0,density:r};return jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("border-b border-border-default bg-background-surface transition-colors",n&&"cursor-pointer hover:bg-background-hover active:bg-background-pressed",{compact:"px-3 py-2",default:"px-4 py-3",relaxed:"px-4 py-4"}[r]),onClick:n,role:n?"button":void 0,tabIndex:n?0:void 0,children:jsxRuntime.jsx("div",{className:"space-y-2",children:a.map((l,c)=>{let d=pc(e,l),u=c===0;return jsxRuntime.jsxs("div",{children:[!u&&jsxRuntime.jsx("div",{className:"text-xs text-text-secondary",children:l.label}),jsxRuntime.jsx("div",{className:tailwindMerge.twMerge(u?"font-medium text-text-primary":"text-sm text-text-primary","[&>*]:!justify-start [&>*]:!text-left"),children:mc(d,e,l,i)})]},l.id)})})})}function ey(e="md"){return {mobile:sE[e],desktop:lE[e]}}function ty({density:e}){return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("border-b border-border-default bg-background-surface",{compact:"px-3 py-2",default:"px-4 py-3",relaxed:"px-4 py-4"}[e]),children:[jsxRuntime.jsx("div",{className:"mb-2 h-5 w-3/4 animate-pulse rounded bg-background-muted"}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-4 w-1/2 animate-pulse rounded bg-background-muted"}),jsxRuntime.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-background-muted"})]})]})}var CE={compact:"py-1.5 px-3 text-sm",default:"py-3 px-4 text-sm",relaxed:"py-4 px-4 text-base"},SE={left:"text-left justify-start",center:"text-center justify-center",right:"text-right justify-end"};function wE(e){let t={};return e.width!==void 0&&(t.width=typeof e.width=="number"?`${e.width}px`:e.width),e.minWidth!==void 0&&(t.minWidth=typeof e.minWidth=="number"?`${e.minWidth}px`:e.minWidth),e.maxWidth!==void 0&&(t.maxWidth=typeof e.maxWidth=="number"?`${e.maxWidth}px`:e.maxWidth),e.flex!==void 0&&(t.flex=`${e.flex} 1 0`),t}function NE({column:e,sortConfig:t,onSort:r,stickyHeader:o,stickyFirstColumn:n,isFirstColumn:a,density:i="default",isLoading:s=false,headerContent:l,sortNote:c}){let d=e.reorderable!==false,{attributes:u,listeners:p,setNodeRef:m,transform:f,transition:g,isDragging:x}=sortable.useSortable({id:e.id,disabled:!d||s}),{role:b,"aria-pressed":h,...y}=u,v=t?.columnId===e.id,S=v?t.direction:null,w=n&&a,N=v?c:void 0,R={...wE(e),transform:utilities.CSS.Transform.toString(f),transition:g,opacity:x?.8:1,zIndex:x?50:void 0};return jsxRuntime.jsx("div",{ref:m,className:tailwindMerge.twMerge("flex items-center border-b border-border-default bg-background-surface",e.sortable?"gap-2":"gap-1",CE[i],SE[e.align||"left"],o&&"sticky top-0 z-10",w&&"sticky left-0 z-20 shadow-[2px_0_4px_-2px_rgba(0,0,0,0.1)]",o&&w&&"z-30",e.sortable&&!s&&"hover:bg-background-hover",s&&"cursor-not-allowed opacity-60",v?"font-bold text-text-primary":"font-medium text-text-secondary",x&&"bg-background-hover"),style:R,...y,...p,role:"columnheader","aria-sort":v?S==="asc"?"ascending":"descending":"none","aria-disabled":s,title:N,"data-sort-note":N,children:s?jsxRuntime.jsx(X,{className:"h-4 w-24"}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[l??jsxRuntime.jsx("span",{className:"flex-1 truncate cursor-pointer",onClick:()=>!s&&e.sortable&&r(e.id),children:e.label}),N&&jsxRuntime.jsx("span",{className:"sr-only",children:N}),e.sortable&&jsxRuntime.jsx("button",{type:"button",className:"flex flex-shrink-0 cursor-pointer",onClick:()=>!s&&r(e.id),"aria-label":`Sort by ${e.label}`,children:v?jsxRuntime.jsx(O,{name:S==="asc"?"CaretUp":"CaretDown",size:14,weight:N?"regular":"bold",className:N?"text-text-secondary opacity-40":"text-text-primary"}):jsxRuntime.jsx(O,{name:"CaretUpDown",size:12,className:"text-text-secondary opacity-40"})})]})})}function oy({columns:e,columnOrder:t,onColumnOrderChange:r,sortConfig:o,onSort:n,stickyHeader:a,stickyFirstColumn:i,density:s="default",isLoading:l=false,renderHeaderContent:c,sortNote:d}){let u=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:5}}),core.useSensor(core.KeyboardSensor,{coordinateGetter:sortable.sortableKeyboardCoordinates})),p=new Map(e.map(g=>[g.id,g])),m=g=>{let{active:x,over:b}=g;if(b&&x.id!==b.id){let h=t.indexOf(x.id),y=t.indexOf(b.id);if(p.get(b.id)?.reorderable===false)return;let S=0;for(let P=0;P<t.length&&p.get(t[P])?.reorderable===false;P++)S=P+1;if(y<S)return;let w=Math.min(h,y),N=Math.max(h,y);for(let P=w;P<=N;P++){if(P===h)continue;if(p.get(t[P])?.reorderable===false)return}let R=sortable.arrayMove(t,h,y);r(R);}},f=t.map(g=>p.get(g)).filter(g=>g!==void 0);return jsxRuntime.jsx(core.DndContext,{sensors:u,collisionDetection:core.closestCenter,onDragEnd:m,children:jsxRuntime.jsx(sortable.SortableContext,{items:t,strategy:sortable.horizontalListSortingStrategy,children:jsxRuntime.jsx("div",{className:"contents",role:"rowgroup",children:f.map((g,x)=>jsxRuntime.jsx(NE,{column:g,sortConfig:o,onSort:n,stickyHeader:a,stickyFirstColumn:i,isFirstColumn:x===0,density:s,isLoading:l,headerContent:c?.(g),sortNote:d},g.id))})})})}var hc="__select",ME=new Set,Zp={compact:"py-1.5 px-3 text-sm",default:"py-3 px-4 text-sm",relaxed:"py-4 px-4 text-base"},_p={left:"text-left justify-start",center:"text-center justify-center",right:"text-right justify-end"},LE={full:"w-full",auto:"w-auto inline-block",contained:"w-full max-w-6xl mx-auto"},DE={auto:"table-auto",fixed:"table-fixed",responsive:"table-auto"};function $p(e){let t={};return e.width!==void 0&&(t.width=typeof e.width=="number"?`${e.width}px`:e.width),e.minWidth!==void 0&&(t.minWidth=typeof e.minWidth=="number"?`${e.minWidth}px`:e.minWidth),e.maxWidth!==void 0&&(t.maxWidth=typeof e.maxWidth=="number"?`${e.maxWidth}px`:e.maxWidth),e.flex!==void 0&&(t.flex=`${e.flex} 1 0`),t}function AE(e,t){return t.accessor?typeof t.accessor=="function"?t.accessor(e):e[t.accessor]:null}function IE({column:e,sortConfig:t,onSort:r,stickyHeader:o,stickyFirstColumn:n,isFirstColumn:a,density:i="default",isLoading:s=false,headerContent:l,sortNote:c}){let d=t?.columnId===e.id,u=d?t.direction:null,p=n&&a,m=d?c:void 0;return jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex items-center border-b border-border-default bg-background-surface",e.sortable?"gap-2":"gap-1",Zp[i],_p[e.align||"left"],o&&"sticky top-0 z-10",p&&"sticky left-0 z-20 shadow-[2px_0_4px_-2px_rgba(0,0,0,0.1)]",o&&p&&"z-30",e.sortable&&!s&&"cursor-pointer hover:bg-background-hover",s&&"cursor-not-allowed opacity-60",d?"font-bold text-text-primary":"font-medium text-text-secondary"),onClick:()=>!s&&e.sortable&&r(e.id),role:"columnheader","aria-sort":d?u==="asc"?"ascending":"descending":"none","aria-disabled":s,title:m,"data-sort-note":m,style:$p(e),children:s?jsxRuntime.jsx(X,{className:"h-4 w-24"}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[l??jsxRuntime.jsx("span",{className:"truncate",children:e.label}),m&&jsxRuntime.jsx("span",{className:"sr-only",children:m}),e.sortable&&jsxRuntime.jsx("div",{className:"flex flex-shrink-0",children:d?jsxRuntime.jsx(O,{name:u==="asc"?"CaretUp":"CaretDown",size:14,weight:m?"regular":"bold",className:m?"text-text-secondary opacity-40":"text-text-primary"}):jsxRuntime.jsx(O,{name:"CaretUpDown",size:12,className:"text-text-secondary opacity-40"})})]})})}function FE({column:e,row:t,rowIndex:r,columnIndex:o,isHovered:n,isSelected:a,density:i="default",className:s,stickyFirstColumn:l}){let c=l&&o===0,d=AE(t,e),u={isLoading:false,isHovered:n,...a===void 0?{}:{isSelected:a},rowIndex:r,columnIndex:o,density:i},p;if(e.cell){let m=e.cell,f=typeof e.cellProps=="function"?e.cellProps(d,t):e.cellProps;p=jsxRuntime.jsx(m,{value:d,row:t,context:u,...f});}else e.render?p=e.render(d,t,u):p=jsxRuntime.jsx("span",{className:"truncate",children:d?.toString()??""});if(e.popover){let m=e.popover,f,g="top",x=false,b="hover";typeof m=="string"?f=m:typeof m=="function"?f=m(d,t):(f=typeof m.content=="function"?m.content(d,t):m.content,g=m.placement||"top",x=m.showArrow??false,b=m.trigger||"hover"),p=jsxRuntime.jsxs(reactAriaComponents.DialogTrigger,{...b==="hover"?{trigger:"longPress"}:{},children:[jsxRuntime.jsx("div",{className:"cursor-help",children:p}),jsxRuntime.jsx(yt,{placement:g,showArrow:x,children:jsxRuntime.jsx("div",{className:"p-2",children:f})})]});}return jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex items-center border-b border-border-default bg-background-surface",e.noCellPadding?"":Zp[i],_p[e.align||"left"],c&&"sticky left-0 z-10 shadow-[2px_0_4px_-2px_rgba(0,0,0,0.1)]",s),role:"cell",style:$p(e),children:p})}function BE({column:e,rowIndex:t,columnIndex:r,density:o="default",stickyFirstColumn:n}){let a=n&&r===0,i={isLoading:true,rowIndex:t,columnIndex:r,density:o},s;if(e.cell){let l=e.cell,c=typeof e.cellProps=="function"?e.cellProps(null,{}):e.cellProps;s=jsxRuntime.jsx(l,{value:null,row:{},context:i,...c});}else e.render?s=e.render(null,{},i):s=jsxRuntime.jsx(X,{className:"h-4 w-full max-w-[200px]"});return jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex items-center border-b border-border-default bg-background-surface",e.noCellPadding?"":Zp[o],_p[e.align||"left"],a&&"sticky left-0 z-10 shadow-[2px_0_4px_-2px_rgba(0,0,0,0.1)]"),role:"cell",style:$p(e),children:s})}function VE(e,t){let r=new Set(["BUTTON","A","INPUT","SELECT","TEXTAREA"]),o=new Set(["button","link","checkbox","switch","menuitem","option"]),n=e;for(;n&&n!==t;){if(r.has(n.tagName))return true;let a=n.getAttribute("role");if(a&&o.has(a))return true;n=n.parentElement;}return false}function ny({columns:e,row:t,rowIndex:r,density:o="default",onClick:n,stickyFirstColumn:a,isSelected:i}){let[s,l]=qe.useState(false),c=qe.useCallback(d=>{if(!n)return;let u=d.target,p=d.currentTarget;VE(u,p)||n(t);},[n,t]);return jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("contents group",n&&"cursor-pointer"),role:"row","aria-selected":i===void 0?void 0:i,onClick:c,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),children:e.map((d,u)=>jsxRuntime.jsx(FE,{column:d,row:t,rowIndex:r,columnIndex:u,isHovered:s,isSelected:i,density:o,className:tailwindMerge.twMerge(n?"group-hover:bg-background-hover":"",i&&"bg-background-selected"),stickyFirstColumn:a},d.id))})}function ay({columns:e,rowIndex:t,density:r="default",stickyFirstColumn:o}){return jsxRuntime.jsx("div",{className:"contents",role:"row",children:e.map((n,a)=>jsxRuntime.jsx(BE,{column:n,rowIndex:t,columnIndex:a,density:r,stickyFirstColumn:o},n.id))})}function iy({columns:e,data:t,className:r,density:o="default",width:n="full",height:a,maxHeight:i,layout:s="auto",mobileRenderer:l="auto",customMobileRowRender:c,mobileBreakpoint:d="md",isLoading:u=false,loadingState:p,loadingRowCount:m=5,onLoadMore:f,hasMore:g=false,enableVirtualization:x,estimatedRowHeight:b,loadingIndicator:h,stickyHeader:y=false,stickyFirstColumn:v=false,onRowClick:S,getRowId:w,selectedRowIds:N,onSelectionChange:R,selectionMode:P="multi",hideHeader:E=false,sortConfig:I,onSort:T,sortNote:D,"aria-label":M,enableColumnReorder:B=false,columnOrder:z,onColumnOrderChange:V}){let U=R!==void 0,Z=N??ME,G=qe.useCallback((te,pe)=>{if(w)return w(te);let Q=te.id;return typeof Q=="string"&&Q.length>0?Q:typeof Q=="number"&&Number.isFinite(Q)?String(Q):`row-${pe}`},[w]),J=qe.useMemo(()=>t.map((te,pe)=>G(te,pe)),[t,G]),W=qe.useCallback((te,pe)=>{if(!R)return;if(P==="single"){R(pe?new Set([te]):new Set);return}let Q=new Set(Z);pe?Q.add(te):Q.delete(te),R(Q);},[R,Z,P]),A=J.filter(te=>Z.has(te)).length,Y=J.length>0&&A===J.length,k=A>0&&!Y,C=qe.useCallback(te=>{if(!R)return;let pe=new Set(Z);for(let Q of J)te?pe.add(Q):pe.delete(Q);R(pe);},[R,J,Z]),L=qe.useMemo(()=>U?[{id:hc,label:"",width:44,align:"center",sortable:false,reorderable:false,exportable:false,mobile:false,render:(pe,Q,De)=>{let mo=G(Q,De.rowIndex);return jsxRuntime.jsx(dc,{value:void 0,row:Q,context:De,isSelected:Z.has(mo),onSelect:(Is,Io)=>W(mo,Io)})}},...e]:e,[e,U,Z,G,W]),F=U&&P==="multi"?jsxRuntime.jsx(eo,{isSelected:Y,isIndeterminate:k,onChange:te=>C(te),isDisabled:J.length===0,"aria-label":Y?"Deselect all rows on this page":"Select all rows on this page"}):void 0,j=qe.useCallback(te=>te.id===hc?F:void 0,[F]),[ne,ce]=qe.useState(null),ee=I!==void 0,ae=ee?I:ne,Le=qe.useRef(null),ge=qe.useMemo(()=>L.map(te=>te.id),[L]),[xe,re]=qe.useState(ge),ie=z!==void 0,ve=ie?z:xe;qe.useEffect(()=>{ie||re(te=>{let pe=L.map(Io=>Io.id),Q=new Set(pe),De=new Set(te),mo=te.filter(Io=>Q.has(Io)),Is=pe.filter(Io=>!De.has(Io));return [...mo,...Is]});},[L,ie]);let Xe=qe.useCallback(te=>{ie||re(te),V?.(te);},[ie,V]),Qe=qe.useMemo(()=>{if(!B&&!z)return L;let te=new Map(L.map(De=>[De.id,De])),pe=ve.map(De=>te.get(De)).filter(De=>De!==void 0),Q=te.get(hc);return Q&&!pe.some(De=>De.id===hc)?[Q,...pe]:pe},[L,ve,B,z]),wr=$o({items:t,onLoadMore:f,hasMore:g,isLoading:u,loadingState:p,enableVirtualization:x,estimatedItemSize:b||(o==="compact"?40:o==="relaxed"?60:48),overscan:5}),Dt=f?wr:null,Nr=Dt?.scrollRef??Le,{loadMoreRef:kr,virtualizer:xt,virtualItems:Zt,isLoadingMore:_,computedLoadingState:Ge}=Dt||{},{gridTemplateColumns:_e,totalMinWidth:oe}=qe.useMemo(()=>{let te=0;return {gridTemplateColumns:Qe.map(Q=>{if(Q.minWidth?te+=typeof Q.minWidth=="number"?Q.minWidth:0:Q.width&&typeof Q.width=="number"&&(te+=Q.width),Q.width)return typeof Q.width=="number"?`${Q.width}px`:Q.width;if(Q.flex)return `${Q.flex}fr`;if(Q.minWidth&&Q.maxWidth){let De=typeof Q.minWidth=="number"?`${Q.minWidth}px`:Q.minWidth,mo=typeof Q.maxWidth=="number"?`${Q.maxWidth}px`:Q.maxWidth;return `minmax(${De}, ${mo})`}return Q.minWidth?`minmax(${typeof Q.minWidth=="number"?`${Q.minWidth}px`:Q.minWidth}, 1fr)`:Q.maxWidth?`minmax(0, ${typeof Q.maxWidth=="number"?`${Q.maxWidth}px`:Q.maxWidth})`:"1fr"}).join(" "),totalMinWidth:te}},[Qe]),ke=qe.useCallback(te=>{if(!L.find(De=>De.id===te)?.sortable)return;let Q;ae?.columnId===te?Q={columnId:te,direction:ae.direction==="asc"?"desc":"asc"}:Q={columnId:te,direction:"asc"},ee||ce(Q),T?.(Q);},[L,ae,T,ee]),K=Ge==="loading"||u&&t.length===0,H={};a?(H.height=typeof a=="number"?`${a}px`:a,H.overflowY="auto"):i?(H.maxHeight=typeof i=="number"?`${i}px`:i,H.overflowY="auto"):f&&(H.height="600px",H.overflowY="auto");let de=tailwindMerge.twMerge(LE[n],!f&&(s==="responsive"?"overflow-x-auto scrollbar-visible":"overflow-auto scrollbar-visible"),r),se=ey(d),ue=l!=="none",Te=(te,pe)=>ue?l==="custom"&&c?c(te,pe):jsxRuntime.jsx(l==="cards"?bc:gc,{row:te,columns:Qe,density:o,isLoading:u,onClick:S?()=>S(te):void 0}):null,$e=xt?Zt?.map(te=>({virtualItem:te,row:t[te.index],index:te.index}))||[]:t.map((te,pe)=>({row:te,index:pe,virtualItem:null}));return jsxRuntime.jsxs("div",{ref:Nr,className:de,style:{...H,position:xt?"relative":void 0},children:[jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("grid border-separate border-spacing-0",DE[s],n==="auto"?"inline-grid w-auto":"w-full",ue&&se.desktop),role:"table","aria-label":M,style:{gridTemplateColumns:_e,minWidth:oe>0?`${oe}px`:void 0},children:[!E&&(B?jsxRuntime.jsx(oy,{columns:L,columnOrder:ve,onColumnOrderChange:Xe,sortConfig:ae,onSort:ke,stickyHeader:y,stickyFirstColumn:v,density:o,isLoading:K,renderHeaderContent:j,sortNote:D}):jsxRuntime.jsx("div",{className:"contents",role:"rowgroup",children:Qe.map((te,pe)=>jsxRuntime.jsx(IE,{column:te,sortConfig:ae,onSort:ke,stickyHeader:y,stickyFirstColumn:v,isFirstColumn:pe===0,density:o,isLoading:K,headerContent:j(te),sortNote:D},te.id))})),xt?jsxRuntime.jsx("div",{className:"col-span-full",style:{gridColumn:"1 / -1",height:`${xt.getTotalSize()}px`,position:"relative"},role:"rowgroup",children:K?Array.from({length:m}).map((te,pe)=>jsxRuntime.jsx("div",{className:"contents",children:jsxRuntime.jsx(ay,{columns:Qe,rowIndex:pe,density:o,stickyFirstColumn:v})},`loading-${pe}`)):t.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[$e.map(({row:te,index:pe,virtualItem:Q})=>{if(!te||!Q)return null;let De=w?w(te):`row-${pe}`;return jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",display:"grid",gridTemplateColumns:_e,transform:`translateY(${Q.start}px)`},"data-index":Q.index,ref:xt.measureElement,children:jsxRuntime.jsx(ny,{columns:Qe,row:te,rowIndex:pe,density:o,onClick:S,stickyFirstColumn:v,isSelected:U?Z.has(G(te,pe)):void 0})},De)}),_&&jsxRuntime.jsx("div",{style:{position:"absolute",top:`${xt.getTotalSize()}px`,left:0,width:"100%"},children:h||jsxRuntime.jsx(Ur,{state:"loading-more"})})]}):jsxRuntime.jsx("div",{className:"py-12 text-center text-text-secondary",children:"No data available"})}):jsxRuntime.jsx("div",{className:"contents",role:"rowgroup",children:K?Array.from({length:m}).map((te,pe)=>jsxRuntime.jsx(ay,{columns:Qe,rowIndex:pe,density:o,stickyFirstColumn:v},`loading-${pe}`)):t.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[$e.map(({row:te,index:pe})=>{if(!te)return null;let Q=w?w(te):`row-${pe}`;return jsxRuntime.jsx(ny,{columns:Qe,row:te,rowIndex:pe,density:o,onClick:S,stickyFirstColumn:v,isSelected:U?Z.has(G(te,pe)):void 0},Q)}),_&&jsxRuntime.jsx("div",{className:"col-span-full",style:{gridColumn:"1 / -1"},children:h||jsxRuntime.jsx(Ur,{state:"loading-more"})})]}):jsxRuntime.jsx("div",{className:"col-span-full py-12 text-center text-text-secondary",role:"row",children:jsxRuntime.jsx("div",{role:"cell",children:"No data available"})})})]}),ue&&jsxRuntime.jsx("div",{className:se.mobile,children:K?Array.from({length:m}).map((te,pe)=>jsxRuntime.jsx(ty,{density:o},`mobile-loading-${pe}`)):t.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[$e.map(({row:te,index:pe})=>{if(!te)return null;let Q=w?w(te):`mobile-row-${pe}`;return jsxRuntime.jsx("div",{className:"border-b border-border-default last:border-b-0",children:Te(te,pe)},Q)}),_&&(h||jsxRuntime.jsx(Ur,{state:"loading-more"}))]}):jsxRuntime.jsx("div",{className:"py-12 text-center text-text-secondary",children:"No data available"})}),f&&g&&!K&&(xt?jsxRuntime.jsx("div",{ref:kr,style:{position:"absolute",top:`${xt.getTotalSize()}px`,left:0,width:"100%",height:1}}):jsxRuntime.jsx("div",{ref:kr,className:"h-px w-full"}))]})}function ly({status:e,alertCount:t,showCount:r=false,isLoading:o,size:n="sm",shape:a="pill",...i}){if(o)return jsxRuntime.jsx(X,{className:"inline-flex h-6 w-20"});let s={healthy:"success",warning:"warning",error:"error",unknown:"neutral"},l={healthy:"Healthy",warning:"Warning",error:"Error",unknown:"Unknown"},c=e==="warning"||e==="error",d=r&&t?`${l[e]} (${t})`:l[e];return jsxRuntime.jsx(ft,{variant:s[e],size:n,shape:a,dot:c,dotPulse:c,...i,children:d})}var zE={battery:"BatteryHigh",charger:"ChargingStation",thermostat:"ThermometerSimple",inverter:"Power",vehicle:"Car",water_heater:"DropHalfBottom",meter:"Gauge",gateway:"WifiHigh",other:"Cube",unknown:"Question"},HE={battery:"Battery",charger:"Charger",thermostat:"Thermostat",inverter:"Inverter",vehicle:"Vehicle",water_heater:"Water Heater",meter:"Meter",gateway:"Gateway",other:"Other",unknown:"Unknown"};function dy({deviceType:e,iconName:t,size:r="md",showLabel:o=false,className:n}){let a=t||(e?zE[e]:"Question"),i=e?HE[e]:void 0;return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("inline-flex items-center",o?"flex-col gap-1":"gap-0",n),children:[jsxRuntime.jsx(O,{name:a,size:r}),o&&i&&jsxRuntime.jsx("span",{className:"text-xs text-text-secondary",children:i})]})}function ss({children:e,title:t,headerContent:r,titleAlign:o="left",hideCloseIcon:n=false,hasBackArrow:a=false,onBack:i,isOpen:s,slideInFrom:l="right",transparentOverlay:c=false,onClose:d,className:u,primaryAction:p,secondaryAction:m,tertiaryAction:f,footerContent:g,contentPadding:x=true,maxWidth:b="400px"}){if(!s)return null;let h=t||r,y=p||m||f||g;return jsxRuntime.jsx($r,{children:jsxRuntime.jsx(Tr,{isOpen:s,onOpenChange:v=>!v&&d?.(),isDismissable:true,transparent:c,children:jsxRuntime.jsx(reactAriaComponents.Modal,{className:"outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0",children:jsxRuntime.jsxs(reactAriaComponents.Dialog,{className:tailwindMerge.twMerge("fixed top-0 bottom-0 flex flex-col bg-background-surface shadow-xl overflow-hidden",l==="right"?"right-0":"left-0",l==="right"?"animate-in slide-in-from-right duration-300 ease-out":"animate-in slide-in-from-left duration-300 ease-out","data-[exiting]:animate-out",l==="right"?"data-[exiting]:slide-out-to-right":"data-[exiting]:slide-out-to-left","data-[exiting]:duration-200 data-[exiting]:ease-in","outline-none focus-visible:outline focus-visible:outline-2 focus-visible:outline-action-default focus-visible:outline-offset-0",u),style:{maxWidth:b,width:"100%"},children:[h&&(a&&i?jsxRuntime.jsx(_t,{title:t,headerContent:r,titleAlign:o,hideCloseIcon:n,hasBackArrow:true,onBack:i,onClose:d}):jsxRuntime.jsx(_t,{title:t,headerContent:r,titleAlign:o,hideCloseIcon:n,onClose:d})),jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex-1 overflow-y-auto overscroll-contain",x?"px-6 py-6":"p-0"),children:e}),y&&jsxRuntime.jsx(Zo,{primaryAction:p,secondaryAction:m,tertiaryAction:f,footerContent:g})]})})})})}ss.displayName="Drawer";function py({status:e,programName:t,isLoading:r,size:o="sm",shape:n="pill",...a}){if(r)return jsxRuntime.jsx(X,{className:"inline-flex h-6 w-20"});let i={enrolled:"success",eligible:"info",pending:"warning",not_eligible:"neutral",opted_out:"neutral"},s={enrolled:"Enrolled",eligible:"Eligible",pending:"Pending",not_eligible:"Not Eligible",opted_out:"Opted Out"},l=jsxRuntime.jsx(ft,{variant:i[e],size:o,shape:n,...a,children:s[e]});return t?jsxRuntime.jsx(dr,{content:t,children:l}):l}function fy({value:e,onChange:t,onUrlChange:r,accept:o="image/*",maxSize:n,isDisabled:a=false,onUpload:i,className:s,showPreview:l=true,placeholder:c="Drop files here or click to browse"}){let[d,u]=qe.useState(false),[p,m]=qe.useState(false),[f,g]=qe.useState(null),[x,b]=qe.useState(e),h=qe.useRef(null),y=async w=>{if(g(null),n&&w.size>n){g(`File size must be less than ${(n/1024/1024).toFixed(2)}MB`);return}if(l&&w.type.startsWith("image/")){let N=new FileReader;N.onloadend=()=>{b(N.result);},N.readAsDataURL(w);}if(i){m(true);try{let N=await i(w);b(N),r?.(N);}catch(N){g("Failed to upload file"),console.error("Upload error:",N);}finally{m(false);}}t?.(w,x);},v=async w=>{try{let N=w.items;if(N.length>0){let R=N[0];if(R.kind==="file"){let P=await R.getFile();P&&y(P);}}}catch(N){g("Failed to upload file"),console.error("Upload error:",N);}finally{u(false);}},S=()=>{b(void 0),g(null),t?.(null),r?.(""),h.current&&(h.current.value="");};return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("w-full",s),children:[jsxRuntime.jsxs(reactAriaComponents.DropZone,{className:tailwindMerge.twMerge("relative flex min-h-[200px] w-full flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",d?"border-action-brand bg-action-brand/5":"border-border-muted hover:border-border-default",a&&"pointer-events-none opacity-50",f&&"border-feedback-error-border bg-feedback-error-background/50"),onDrop:v,onDropEnter:()=>u(true),onDropExit:()=>u(false),children:[x?jsxRuntime.jsxs("div",{className:"relative flex h-full w-full items-center justify-center p-4",children:[l&&(x.startsWith("data:image")||x.startsWith("http"))?jsxRuntime.jsx("img",{src:x,alt:"Preview",className:"max-h-48 max-w-full rounded-md object-contain"}):jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Image,{className:"h-12 w-12 text-text-secondary"}),jsxRuntime.jsx("span",{className:"text-sm text-text-secondary",children:"File uploaded"})]}),!a&&jsxRuntime.jsx($,{variant:"icon",size:"sm",onPress:S,className:"absolute right-2 top-2 bg-background-surface shadow-md",children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"})})]}):jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-4 p-6",children:[jsxRuntime.jsx(lucideReact.Upload,{className:"h-12 w-12 text-text-secondary"}),jsxRuntime.jsxs("div",{className:"text-center",children:[jsxRuntime.jsx("p",{className:"text-sm text-text-primary",children:c}),jsxRuntime.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:o==="image/*"?"PNG, JPG, GIF up to 10MB":`Accepts ${o}`})]}),jsxRuntime.jsx(reactAriaComponents.FileTrigger,{acceptedFileTypes:o.split(","),onSelect:w=>{let N=Array.from(w||[]);N.length>0&&y(N[0]);},children:jsxRuntime.jsx($,{variant:"secondary",size:"sm",isDisabled:a,children:"Choose File"})})]}),p&&jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded-lg bg-background-surface/80",children:jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-action-brand border-t-transparent"}),jsxRuntime.jsx("span",{className:"text-sm text-text-secondary",children:"Uploading..."})]})})]}),f&&jsxRuntime.jsx("p",{className:"mt-2 text-sm text-feedback-error-text",children:f})]})}function by({version:e,isLatest:t,updateAvailable:r,isLoading:o,size:n="sm",shape:a="rounded",...i}){if(o)return jsxRuntime.jsx(X,{className:"inline-flex h-6 w-16"});let s="neutral",l=e;return t?s="success":r&&(s="warning",l=`${e} (Update)`),jsxRuntime.jsx(ft,{variant:s,size:n,shape:a,...i,children:l})}function ai(e){return jsxRuntime.jsx(reactAriaComponents.Form,{validationBehavior:"aria",...e,className:tailwindMerge.twMerge("flex flex-col gap-6",e.className)})}function xy({placeholder:e="Search...",value:t,onChange:r,isOpen:o,onOpenChange:n,trigger:a,children:i,showShortcutHint:s=true,showInput:l=true,className:c}){let[d,u]=qe.useState(false),p=nr("(max-width: 767px)"),m=o!==void 0?o:d,f=qe.useCallback(h=>{n?n(h):u(h);},[n]);qe.useEffect(()=>{let h=y=>{(y.metaKey||y.ctrlKey)&&y.key==="k"&&(y.preventDefault(),f(!m)),y.key==="Escape"&&m&&f(false);};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[m,f]);let g=qe.useCallback(h=>{r?.(h);},[r]),x=jsxRuntime.jsxs("button",{type:"button",className:"flex items-center gap-2 px-3 py-2 text-sm text-text-secondary hover:text-text-primary hover:bg-background-hover rounded-md transition-colors","aria-label":"Open search",children:[jsxRuntime.jsx(O,{name:"MagnifyingGlass",size:18}),!p&&s&&jsxRuntime.jsxs("span",{className:"hidden md:flex items-center gap-1 text-xs",children:[jsxRuntime.jsx("kbd",{className:"px-1.5 py-0.5 bg-background-muted border border-border-muted rounded text-xs",children:navigator.platform.includes("Mac")?"\u2318":"Ctrl"}),jsxRuntime.jsx("kbd",{className:"px-1.5 py-0.5 bg-background-muted border border-border-muted rounded text-xs",children:"K"})]})]}),b=a===null||qe.isValidElement(a)&&a.type===qe.Fragment&&!a.props.children;return p?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!b&&(a?jsxRuntime.jsx("button",{type:"button",onClick:()=>f(true),className:"appearance-none bg-transparent border-none p-0 cursor-pointer",children:a}):jsxRuntime.jsx("button",{type:"button",onClick:()=>f(true),className:"appearance-none bg-transparent border-none p-0 cursor-pointer",children:x})),jsxRuntime.jsx(vt,{isOpen:m,onClose:()=>f(false),hideCloseIcon:false,contentPadding:false,maxHeight:"90vh",children:jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[l&&jsxRuntime.jsx("div",{className:"p-4 border-b border-border-muted flex-shrink-0",children:jsxRuntime.jsx(qr,{value:t,onChange:g,placeholder:e,showSearchIcon:true,isClearable:!!t,onClear:()=>r?.(""),reserveErrorSpace:false,className:c,autoFocus:true})}),jsxRuntime.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:i})]})})]}):b?null:jsxRuntime.jsxs(reactAriaComponents.DialogTrigger,{isOpen:m,onOpenChange:f,children:[a||x,jsxRuntime.jsx(yt,{placement:"bottom",className:"w-[600px] max-w-[90vw] bg-background-surface shadow-xl border border-border-default rounded-lg overflow-hidden",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[l&&jsxRuntime.jsx("div",{className:"p-4 border-b border-border-muted",children:jsxRuntime.jsx(qr,{value:t,onChange:g,placeholder:e,showSearchIcon:true,isClearable:!!t,onClear:()=>r?.(""),reserveErrorSpace:false,className:c,autoFocus:true})}),jsxRuntime.jsx("div",{className:"max-h-[500px] overflow-hidden",children:i})]})})]})}function Cy({placeholder:e="Search...",value:t,onChange:r,isOpen:o,onOpenChange:n,children:a,maxHeight:i="400px",variant:s="default",className:l}){let[c,d]=qe.useState(false),u=nr("(max-width: 767px)"),p=qe.useRef(null),m=qe.useRef(null),f=o!==void 0?o:c,g=qe.useCallback(E=>{n?n(E):d(E);},[n]);qe.useEffect(()=>{let E=I=>{(I.metaKey||I.ctrlKey)&&I.key==="k"&&(I.preventDefault(),g(!f)),I.key==="Escape"&&f&&g(false);};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[f,g]),qe.useEffect(()=>{f&&!u&&p.current&&setTimeout(()=>{p.current?.querySelector("input")?.focus();},0);},[f,u]),qe.useEffect(()=>{if(!f||u)return;let E=I=>{let T=I.target,D=p.current?.contains(T),M=m.current?.contains(T);!D&&!M&&g(false);};return document.addEventListener("mousedown",E,true),()=>document.removeEventListener("mousedown",E,true)},[f,u,g]);let x=E=>{r?.(E);},b=qe.useCallback(()=>{g(false);},[g]),h=qe.useCallback(()=>{r?.("");},[r]),[y,v]=qe.useState(null);qe.useEffect(()=>{if(f&&!u&&p.current){let E=null,I=()=>{let D=p.current?.getBoundingClientRect();D&&v({top:D.bottom+8,left:D.left,width:D.width});},T=()=>{E===null&&(E=requestAnimationFrame(()=>{I(),E=null;}));};return I(),window.addEventListener("resize",T),window.addEventListener("scroll",T,true),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,true),E!==null&&cancelAnimationFrame(E);}}},[f,u]);let S=qe.useCallback(()=>{g(true);},[g]);if(u)return jsxRuntime.jsxs("div",{className:l,children:[jsxRuntime.jsx("button",{type:"button",onClick:S,className:"flex items-center justify-center w-10 h-10 rounded-lg hover:bg-background-hover transition-colors","aria-label":"Open search",children:jsxRuntime.jsx(O,{name:"MagnifyingGlass",size:"md"})}),jsxRuntime.jsxs(vt,{isOpen:f,onClose:b,contentPadding:false,height:"80vh",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-4 pt-4",children:[jsxRuntime.jsx("div",{className:"flex-1",children:jsxRuntime.jsx(qr,{value:t,onChange:x,placeholder:e,showSearchIcon:true,isClearable:!!t,onClear:h,reserveErrorSpace:false,autoFocus:true})}),jsxRuntime.jsx($,{variant:"icon",onPress:b,"aria-label":"Close search",className:"flex-shrink-0",children:jsxRuntime.jsx(O,{name:"X",size:"md"})})]}),jsxRuntime.jsx("div",{className:"mt-4",children:a})]})]},"mobile");let w=E=>{let T=E.target.tagName==="INPUT";if(E.key==="ArrowDown"&&f&&T){E.preventDefault();let D=m.current?.querySelector("[data-search-result]");D&&D.focus();}},N=E=>{let I=E.target;if(!I.hasAttribute("data-search-result"))return;let D=Array.from(m.current?.querySelectorAll("[data-search-result]")||[]),M=D.indexOf(I);if(E.key==="ArrowDown"){E.preventDefault(),E.stopPropagation();let B=Math.min(M+1,D.length-1);D[B]?.focus();}else if(E.key==="ArrowUp")if(E.preventDefault(),E.stopPropagation(),M===0)p.current?.querySelector("input")?.focus();else {let B=Math.max(M-1,0);D[B]?.focus();}else E.key==="Escape"&&(E.preventDefault(),E.stopPropagation(),g(false),p.current?.querySelector("input")?.focus());},R=f&&y&&typeof document<"u"?reactDom.createPortal(jsxRuntime.jsx("div",{ref:m,style:{position:"fixed",top:`${y.top}px`,left:`${y.left}px`,width:`${y.width}px`,zIndex:9999},role:"listbox",onKeyDown:N,children:jsxRuntime.jsx("div",{className:"bg-background-surface shadow-2xl border border-border-default rounded-lg overflow-hidden animate-in fade-in zoom-in-95 duration-200",children:jsxRuntime.jsx("div",{className:"overflow-y-auto",style:{maxHeight:i},children:a})})}),document.body):null,P=s==="elevated"?"bg-background-muted/50 border-border-subtle/50 focus-within:bg-background-body focus-within:border-border-focus focus-within:shadow-md backdrop-blur-sm transition-all duration-200":"";return jsxRuntime.jsxs("div",{ref:p,className:`relative w-full ${l||""}`,onKeyDown:w,children:[jsxRuntime.jsx(qr,{value:t,onChange:x,placeholder:e,showSearchIcon:true,isClearable:!!t,onClear:()=>r?.(""),reserveErrorSpace:false,className:P,onFocus:()=>g(true)}),R]},"desktop")}function Sy({message:e="No results found",suggestion:t,icon:r="MagnifyingGlass",className:o=""}){return jsxRuntime.jsxs("div",{className:`flex flex-col items-center justify-center py-12 px-4 text-center ${o}`,children:[jsxRuntime.jsx("div",{className:"text-text-secondary mb-3",children:jsxRuntime.jsx(O,{name:r,size:48})}),jsxRuntime.jsx("p",{className:"text-base font-medium text-text-primary mb-1",children:e}),t&&jsxRuntime.jsx("p",{className:"text-sm text-text-secondary max-w-xs",children:t})]})}function Ny({count:e=3,className:t=""}){return jsxRuntime.jsx("div",{className:`flex flex-col ${t}`,children:Array.from({length:e}).map((r,o)=>jsxRuntime.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[jsxRuntime.jsx(X,{width:20,height:20,variant:"circle"}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[jsxRuntime.jsx(X,{width:"60%",height:16}),jsxRuntime.jsx(X,{width:"40%",height:12})]}),jsxRuntime.jsx(X,{width:16,height:16})]},o))})}function Ty({title:e,count:t,isLoading:r,footer:o,children:n,className:a}){return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex flex-col",a),children:[jsxRuntime.jsxs("div",{className:"flex items-baseline gap-1.5 px-4 pt-4 pb-2 border-t border-border-muted first:border-t-0",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:e}),!r&&t!==void 0&&jsxRuntime.jsx("span",{className:"text-xs text-text-secondary",children:t}),r&&jsxRuntime.jsx("span",{className:"text-xs text-text-secondary animate-pulse",children:"Loading..."})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:n}),o&&jsxRuntime.jsx("div",{className:"px-4 py-2 border-t border-border-subtle",children:o})]})}function Py({id:e,title:t,subtitle:r,metadata:o,icon:n,customIcon:a,onSelect:i,isFocused:s=false,className:l,testId:c}){return jsxRuntime.jsxs("div",{role:"option",tabIndex:0,onClick:()=>{i?.(e);},onKeyDown:p=>{let m=p.currentTarget;switch(p.key){case "Enter":case " ":{p.preventDefault(),i?.(e);break}case "ArrowDown":{p.preventDefault();let f=Array.from(document.querySelectorAll("[data-search-result]")),g=f.indexOf(m);g!==-1&&g<f.length-1&&f[g+1].focus();break}case "ArrowUp":{p.preventDefault();let f=Array.from(document.querySelectorAll("[data-search-result]")),g=f.indexOf(m);if(g>0)f[g-1].focus();else {let x=document.querySelector('input[type="text"][placeholder*="Search"]');x&&x.focus();}break}case "Escape":{p.preventDefault();let f=document.querySelector('input[type="text"][placeholder*="Search"]');f&&f.focus();break}}},"data-testid":c,"data-search-result":true,className:tailwindMerge.twMerge("group flex items-center gap-3 px-4 py-3 cursor-pointer outline-none transition-colors","text-text-primary hover:bg-background-hover","focus-visible:bg-background-muted focus-visible:outline-none","data-[focused]:bg-background-hover",s&&"bg-background-hover",l),"data-focused":s||void 0,children:[a?jsxRuntime.jsx("div",{className:"flex-shrink-0",children:a}):n?jsxRuntime.jsx("div",{className:"flex-shrink-0 text-text-secondary",children:jsxRuntime.jsx(O,{name:n,size:20})}):null,jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-baseline gap-2",children:[jsxRuntime.jsx("span",{className:"font-medium text-text-primary truncate",children:t}),o&&jsxRuntime.jsx("span",{className:"text-xs text-text-secondary flex-shrink-0",children:o})]}),r&&jsxRuntime.jsx("div",{className:"text-sm text-text-secondary truncate mt-0.5",children:r})]}),jsxRuntime.jsx("div",{className:"flex-shrink-0 opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100 group-data-[focused]:opacity-100 transition-opacity",children:jsxRuntime.jsx(O,{name:"ArrowRight",size:16,className:"text-text-secondary"})})]})}function Ry({children:e,maxHeight:t="400px",className:r}){return jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("overflow-y-auto overscroll-contain","divide-y divide-border-muted",r),style:{maxHeight:t},children:e})}function My({placeholder:e="Search...",onClick:t,showShortcut:r=true,variant:o="default",className:n=""}){let a=typeof navigator<"u"&&navigator.platform.includes("Mac");return jsxRuntime.jsxs("button",{type:"button",onClick:t,className:`
|
|
28
|
+
`+i),i.includes("xmlns=")||(i=i.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"'));let s=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),l=cp(t.filename||"chart","svg",t.timestamp!==!1);(0,Pl.saveAs)(s,l);}catch(r){throw new Error(`SVG export failed: ${r instanceof Error?r.message:"Unknown error"}`)}}async function hP(e,t,r=2){if(!e.current)throw new Error("SVG element not found");let o="";try{let n=e.current,a=n.getBoundingClientRect(),i=n.cloneNode(!0);jb(n,i),i.setAttribute("width",String(a.width)),i.setAttribute("height",String(a.height)),i.removeAttribute("transform");let s=i.getElementsByTagName("text");Array.from(s).forEach(p=>{p.style.fontFamily||(p.style.fontFamily="system-ui, -apple-system, sans-serif"),p.style.fontSize||(p.style.fontSize="12px");});let l=document.createElementNS("http://www.w3.org/2000/svg","rect");l.setAttribute("width",String(a.width)),l.setAttribute("height",String(a.height)),l.setAttribute("fill","white"),i.insertBefore(l,i.firstChild);let d=new XMLSerializer().serializeToString(i);d.includes("xmlns=")||(d=d.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"'));let u=new Blob([d],{type:"image/svg+xml;charset=utf-8"});return o=URL.createObjectURL(u),new Promise((p,m)=>{let f=new Image,g=setTimeout(()=>{o&&URL.revokeObjectURL(o),m(new Error("Image loading timeout"));},1e4);f.onload=()=>{clearTimeout(g);try{let x=document.createElement("canvas");x.width=a.width*r,x.height=a.height*r;let b=x.getContext("2d");if(!b)throw new Error("Canvas context not available");b.imageSmoothingEnabled=!0,b.imageSmoothingQuality="high",b.scale(r,r),b.fillStyle="white",b.fillRect(0,0,a.width,a.height),b.drawImage(f,0,0,a.width,a.height),x.toBlob(h=>{if(h){let y=cp(t.filename||"chart","png",t.timestamp!==!1);(0,Pl.saveAs)(h,y),p();}else m(new Error("Failed to create PNG blob"));o&&URL.revokeObjectURL(o);},"image/png",1);}catch(x){o&&URL.revokeObjectURL(o),m(x);}},f.onerror=()=>{clearTimeout(g),o&&URL.revokeObjectURL(o),m(new Error("Failed to load SVG as image"));},f.src=o;})}catch(n){throw o&&URL.revokeObjectURL(o),new Error(`PNG export failed: ${n instanceof Error?n.message:"Unknown error"}`)}}function xP(e){if(typeof window>"u")return false;switch(e){case "csv":return true;case "svg":return typeof XMLSerializer<"u";case "png":return typeof HTMLCanvasElement<"u"&&typeof HTMLCanvasElement.prototype.toBlob=="function";default:return false}}function yP(e){return {csv:"CSV Spreadsheet",svg:"SVG Vector Image",png:"PNG Image"}[e]||"Unknown Format"}function Rl({datasets:e,metadata:t,svgRef:r}){return qe.useCallback(async o=>{try{await dp(o,e,t,r);}catch(n){throw console.error("Chart export failed:",n),n}},[e,t,r])}var up=({data:e,seriesMetadata:t,width:r,height:o,onBrushChange:n,brushRegion:a,margin:i=He,yDomain:s})=>{let l=qe.useRef(null),c=qe.useRef(false),d=qe.useMemo(()=>e.flat(),[e]),u=qe.useMemo(()=>({top:10,bottom:15,left:i.left,right:i.right}),[i]),p=r-u.left-u.right,m=qe.useMemo(()=>{if(d.length===0)return scale.scaleTime({domain:[new Date,new Date],range:[0,p]});let h=new Date(Math.min(...d.map(v=>v.xValue.getTime()))),y=new Date(Math.max(...d.map(v=>v.xValue.getTime())));return scale.scaleTime({domain:[h,y],range:[0,p]})},[d,p]),f=qe.useMemo(()=>{let h=d.length>0?Math.max(0,...d.map(y=>y.yValue)):1;return scale.scaleLinear({domain:s??[0,h],range:[o-u.bottom,u.top]})},[d,o,s,u.top,u.bottom]),g=h=>{if(c.current)return;if(!h){n(null);return}let{x0:y,x1:v}=h;if(y===v)return;let S=new Date(y),w=new Date(v);if(!(Number.isNaN(S.getTime())||Number.isNaN(w.getTime()))){if(d.length>0){let N=Math.min(...d.map(T=>T.xValue.getTime())),R=Math.max(...d.map(T=>T.xValue.getTime())),E=(R-N)*.05;if(Math.abs(S.getTime()-N)<E&&Math.abs(w.getTime()-R)<E){n(null);return}}n([S,w]);}},x=qe.useMemo(()=>{if(d.length!==0)return {start:{x:0,y:u.top},end:{x:p,y:o-u.bottom}}},[p,o,d]);qe.useEffect(()=>{if(!l.current||d.length===0)return;let h=l.current.state;if(h?.isBrushing||h?.activeHandle)return;let y=Math.min(...d.map(P=>P.xValue.getTime())),v=Math.max(...d.map(P=>P.xValue.getTime())),S=a?a[0]:new Date(y),w=a?a[1]:new Date(v),N=l.current.state?.extent;if(N){let P=m.invert(N.x0),E=m.invert(N.x1),I=Math.abs(P.getTime()-S.getTime()),T=Math.abs(E.getTime()-w.getTime());if(I<1e3&&T<1e3)return}c.current=true;let R=P=>{let E=l.current.getExtent({x:m(S),y:u.top},{x:m(w),y:o-u.bottom});return {...P,start:{y:E.y0,x:E.x0},end:{y:E.y1,x:E.x1},extent:E}};l.current.updateBrush(R),setTimeout(()=>{c.current=false;},50);},[a,m,o,d]);let b={fill:"url(#brush_pattern)",fillOpacity:.15,stroke:"var(--color-border-focus)",strokeWidth:1.5,strokeOpacity:.3};return jsxRuntime.jsx("div",{className:"mt-2",children:jsxRuntime.jsxs("svg",{width:r,height:o,children:[jsxRuntime.jsx(pattern.PatternLines,{id:"brush_pattern",height:8,width:8,stroke:"var(--color-text-secondary)",strokeWidth:1,orientation:["diagonal"]}),jsxRuntime.jsxs("g",{transform:`translate(${u.left}, 0)`,children:[e.map((h,y)=>jsxRuntime.jsx(shape.LinePath,{data:h,x:v=>m(v.xValue),y:v=>f(v.yValue),stroke:t[y]?.color||"var(--color-gray-500)",strokeWidth:1.5,opacity:.8},`brush-series-${y}`)),jsxRuntime.jsx(brush.Brush,{xScale:m,yScale:f,width:p,height:o-u.top-u.bottom,margin:{top:u.top,bottom:u.bottom,left:0,right:0},handleSize:8,innerRef:l,resizeTriggerAreas:["left","right"],brushDirection:"horizontal",initialBrushPosition:x,onChange:g,onClick:()=>n(null),selectedBoxStyle:b,useWindowMoveEvents:true})]})]})})};function zo(e){switch(e){case "command":return Vt("--color-action-brand","#111111");case "success":return Vt("--color-feedback-success-border","#278a4a");case "warning":return Vt("--color-feedback-warning-border","#c88420");case "error":return Vt("--color-feedback-error-border","#c42d2d");case "alert":return Vt("--color-feedback-warning-border","#c88420");default:return Vt("--color-text-secondary","#525250")}}function Ml({events:e,color:t,showLabels:r=false}){let o=qe.useContext(Jr),[n,a]=qe.useState(null);if(!o)return console.warn("ChartEventMarkers must be used within a ChartContainer"),null;let{xScale:i,yScale:s,height:l,tooltip:c,datasets:d,seriesMetadata:u,seriesTypes:p,categoryColors:m}=o,f=e.filter(b=>{let h=i(b.timestamp);return h>=He.left&&h<=i.range()[1]}),g=qe.useCallback((b,h)=>{a(h);let y=i(b.timestamp),v=y>(i.range()[1]-He.right-He.left)/2+He.left,S=[];d&&u&&d.forEach((R,P)=>{if(R.length===0)return;let E=d3Array.bisector(B=>B.xValue).left,I=E(R,b.timestamp),T=R[I-1],D=R[I],M;if(!T)M=D;else if(!D)M=T;else {let B=Math.abs(b.timestamp.getTime()-T.xValue.getTime()),z=Math.abs(b.timestamp.getTime()-D.xValue.getTime());M=B<z?T:D;}M&&u[P]&&S.push({label:u[P].label,value:M.yValue,color:u[P].color,type:p?.[P]||"line",...M.category&&{category:M.category,categoryColor:m?.[M.category]}});});let N=f.filter(R=>Math.abs(i(R.timestamp)-y)<=10).map(R=>({label:R.label,color:R.color??t??zo(R.type),metadata:R.metadata}));S.push({label:N.length>1?`${N.length} events`:b.label,value:0,color:b.color??t??zo(b.type),type:"event"}),c.show({xValue:b.timestamp,series:S,x:y,y:S.length>1&&typeof S[0].value=="number"?s(S[0].value):l/2,position:v?"left":"right",isEvent:true,eventMetadata:b.metadata,eventItems:N});},[i,s,l,c,t,d,u,p,m,f]),x=qe.useCallback(()=>{a(null),c.hide();},[c]);return f.length===0?null:jsxRuntime.jsx("g",{className:"chart-event-markers","data-testid":"chart-event-markers",children:f.map((b,h)=>{let y=i(b.timestamp),v=b.color??t??zo(b.type),S=n===h;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:y,y1:He.top,x2:y,y2:l-He.bottom,stroke:v,strokeWidth:S?3:2,strokeDasharray:"4 4",strokeOpacity:S?.9:.6,pointerEvents:"none"}),jsxRuntime.jsx("circle",{cx:y,cy:He.top,r:S?5:4,fill:v,stroke:"var(--color-background-surface)",strokeWidth:2,pointerEvents:"none"}),jsxRuntime.jsx("circle",{cx:y,cy:l-He.bottom,r:S?5:4,fill:v,stroke:"var(--color-background-surface)",strokeWidth:2,pointerEvents:"none"}),r&&jsxRuntime.jsx("text",{x:y,y:He.top-8,textAnchor:"middle",fill:"var(--color-text-secondary)",fontSize:11,fontWeight:500,pointerEvents:"none",children:b.label}),jsxRuntime.jsx("rect",{x:y-10,y:He.top,width:20,height:l-He.top-He.bottom,fill:"transparent",style:{cursor:"pointer"},onMouseEnter:()=>g(b,h),onMouseLeave:x})]},`${b.timestamp.getTime()}-${h}`)})})}function Ll({spans:e,opacity:t=.25,color:r}){let o=qe.useContext(Jr),[n,a]=qe.useState(null),i=o?.xScale,s=o?.height,l=o?.tooltip,[c,d]=i?.domain()??[new Date(0),new Date(0)],[u,p]=i?.range()??[0,0],m=qe.useCallback((S,w)=>{if(!i||!l)return;a(w);let N=S.start<c?c:S.start,R=S.end>d?d:S.end,P=(i(N)+i(R))/2,E=P>(p-u)/2+u,T=e.filter(D=>D.end>D.start&&D.start<S.end&&D.end>S.start).map(D=>({label:D.label,color:D.color??r??zo(D.type),metadata:D.metadata}));l.show({xValue:S.start,series:[{label:T.length>1?`${T.length} scheduled commands`:S.label,value:0,color:S.color??r??zo(S.type),type:"event"}],x:P,y:(s??0)/2,position:E?"left":"right",isEvent:true,eventMetadata:S.metadata,eventItems:T});},[i,s,l,r,c,d,u,p,e]),f=qe.useCallback(()=>{a(null),l?.hide();},[l]);if(!o)return console.warn("ChartEventSpans must be used within a ChartContainer"),null;let{xScale:g,height:x}=o,b=He.top,y=x-He.bottom-b,v=e.filter(S=>S.end>S.start);return v.length===0?null:jsxRuntime.jsx("g",{className:"chart-event-spans","data-testid":"chart-event-spans",children:v.map((S,w)=>{let N=S.start<c?c:S.start,R=S.end>d?d:S.end;if(N>=d||R<=c)return null;let P=g(N),I=g(R)-P;if(I<=0)return null;let T=S.color??r??zo(S.type);return jsxRuntime.jsx("rect",{x:P,y:b,width:I,height:y,fill:T,fillOpacity:n===w?Math.min((t??.25)*1.8,1):t??.25,pointerEvents:"all",style:{cursor:"pointer"},onMouseEnter:()=>m(S,w),onMouseLeave:f},`${S.start.getTime()}-${S.end.getTime()}-${w}`)})})}var rh=qe.createContext(false);function mp({children:e}){return jsxRuntime.jsx(rh.Provider,{value:true,children:e})}function Yn(e){let t=qe.useContext(rh),[r,o]=qe.useState(false),[n,a]=qe.useState(null),i=qe.useRef(null),s=qe.useCallback(u=>{if(i.current?.disconnect(),i.current=null,!u||typeof ResizeObserver>"u")return;let p=new ResizeObserver(([m])=>{if(!m)return;let{width:f,height:g}=m.contentRect;a(x=>x&&x.width===f&&x.height===g?x:{width:f,height:g});});p.observe(u),i.current=p;},[]);qe.useEffect(()=>()=>i.current?.disconnect(),[]);let l=qe.useCallback(()=>{o(false),a(null);},[]),c=t?null:jsxRuntime.jsx($,{variant:"icon",size:"sm",icon:"ArrowsOutSimple","aria-label":`Expand ${e} chart`,onPress:()=>o(true)}),d=qe.useCallback(u=>r&&!t?jsxRuntime.jsx(cr,{isOpen:true,onClose:l,title:e,contentPadding:false,maxWidth:"min(1200px, 100vw)",minWidth:"min(360px, 100vw)",height:"82vh",mobileHeight:"82vh",children:jsxRuntime.jsx("div",{ref:s,className:"h-full w-full p-4",children:u})}):u,[r,t,l,e,s]);return {isExpanded:r,action:c,expandedSize:n,present:d}}var Jn=({data:e,color:t="var(--color-viz-default)",strokeWidth:r=3,strokeDasharray:o,categoryColors:n={},maxGapMs:a,animate:i=true})=>{let{xScale:s,yScale:l,animationSettings:c,entrance:d}=Kn(),[u]=qe__namespace.default.useState(()=>d?.played!==true),p=i&&u,m=l.range(),f=Object.keys(n).length>0,g=w=>w.category?n[w.category]??t:t,x=w=>w.chartYValue??w.yValue,b=e.length===1?e[0]:void 0,h=a!=null?Sl(e,a):e,y=i?void 0:"non-scaling-stroke",v=b?jsxRuntime.jsx("circle",{cx:s(b.xValue),cy:l(x(b)),r,fill:f?g(b):t}):f?e.slice(0,-1).map((w,N)=>{let R=e[N+1];return a!=null&&a>0&&R.xValue.getTime()-w.xValue.getTime()>a?null:jsxRuntime.jsx(shape.LinePath,{data:[w,R],x:P=>s(P.xValue),y:P=>l(x(P)),stroke:g(w),strokeWidth:r,strokeDasharray:o,strokeLinecap:"round",vectorEffect:y,curve:curve.curveLinear},`${w.xValue.getTime()}-${R.xValue.getTime()}`)}):jsxRuntime.jsx(shape.LinePath,{data:h,x:w=>w?s(w.xValue):0,y:w=>w?l(x(w)):0,defined:w=>w!=null,stroke:t,strokeWidth:r,strokeDasharray:o,strokeLinecap:"round",vectorEffect:y,curve:curve.curveLinear}),S={transformOrigin:`0 ${m[0]}px`,transformBox:"fill-box",isolation:"isolate"};return p?jsxRuntime.jsx(framerMotion.motion.g,{initial:{scaleY:0},animate:{scaleY:1},transition:{duration:c.duration,ease:c.ease},style:S,children:v}):jsxRuntime.jsx("g",{style:S,children:v})};var lh=e=>e.type===pn||e.type===Jn||e.type===Nl,KP=e=>e.type===Ml||e.type===Ll,YP=(e,t,r)=>{if(!e.tooltipRange||e.baseline===void 0)return;let o=typeof e.baseline=="function"?e.baseline(t,r):e.baseline;return typeof o=="number"&&Number.isFinite(o)&&o!==t.yValue?o:void 0},JP=d3Array.bisector(e=>e.xValue).left,XP=()=>jsxRuntime.jsx("div",{className:"flex h-full items-center justify-center",children:jsxRuntime.jsx("p",{className:"text-text-secondary",children:"No data available"})}),jP=()=>jsxRuntime.jsxs("div",{className:"flex h-full flex-col gap-4 p-4",children:[jsxRuntime.jsx(X,{className:"h-full w-full"}),jsxRuntime.jsxs("div",{className:"flex gap-4",children:[jsxRuntime.jsx(X,{className:"h-4 w-24"}),jsxRuntime.jsx(X,{className:"h-4 w-24"})]})]}),qP=({parentWidth:e,parentHeight:t,yFormatter:r={type:"number"},yDomain:o,referenceLines:n,isLoading:a=false,enableZoom:i=false,enableBrush:s=false,brushHeight:l=60,onZoomChange:c,zoomDomain:d,hiddenSeriesLabels:u,onHiddenSeriesChange:p,hideBottomBar:m=false,headerActions:f,headerControls:g,title:x,children:b})=>{let h=u!==void 0,y=d!==void 0,[v,S]=qe.useState(null),[w,N]=qe.useState(null),R=y?d:w,[P,E]=qe.useState(()=>new Set),I=h?u:P,T=qe.useRef(null),D=qe.useId(),M=qe.useRef(0),B=qe.useRef(""),z=qe.useRef(null),{colorMode:V}=jt(),U=qe.useMemo(()=>Fo(),[V]),Z=qe.useMemo(()=>Ci(),[V]),{datasets:G,seriesMetadata:J,categoryInfo:W,categoryColors:A,categoryLabels:Y,seriesTypes:k}=qe.useMemo(()=>{let me=qe.Children.toArray(b).filter(Ie=>qe.isValidElement(Ie)&&lh(Ie)),Be=me.filter(Ie=>Ie.props.data).length,Re=[],Oe=[],tt=[],pt=null,Ae=null;me.forEach((Ie,kt)=>{let Fe=Ie.props;if(!Fe.data)return;Re.push(Fe.data);let ka=("color"in Fe&&Fe.color?Fe.color:void 0)||(Be===1?Z:U[kt%U.length]),Rn=Ie.type===pn;Oe.push({label:"label"in Fe&&Fe.label||`Series ${Re.length}`,color:ka,...Rn&&"baseline"in Fe&&Fe.baseline!==void 0?{baseline:Fe.baseline,tooltipRange:"tooltipRange"in Fe&&Fe.tooltipRange||false}:{}});let Nd=Rn?"area":Ie.type===Jn?"line":"bar";tt.push(Nd),"categoryColors"in Fe&&Fe.categoryColors&&(pt=Fe.categoryColors),"categoryLabels"in Fe&&Fe.categoryLabels&&(Ae=Fe.categoryLabels);});let ct=null;if(pt){let Ie=new Set;Re.forEach(kt=>{kt.forEach(Fe=>{Fe.category&&Ie.add(Fe.category);});}),ct=Array.from(Ie).map(kt=>({label:Ae?.[kt]||kt,color:pt[kt]||"#6b7280"}));}return {datasets:Re,seriesMetadata:Oe,categoryInfo:ct,categoryColors:pt,categoryLabels:Ae,seriesTypes:tt}},[b,Z,U,V]),C=Yn(x),L=C.expandedSize?.width??e,F=C.expandedSize?.height??t,ne=!m?C.action:null,ce=f||ne?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[f,ne]}):void 0,{headerRef:ee,headerHeight:ae}=Fa(!!ce,!!g),Le=m?0:60,ge=s?l+8:0,xe=F-ae-Le-ge,re=Math.max(100,xe),ie=qe.useCallback(q=>q?I.has(q):false,[I]),ve=qe.useMemo(()=>J.map((q,me)=>ie(q.label)?null:me).filter(q=>q!==null),[J,ie]),Xe=qe.useMemo(()=>ve.map(q=>G[q]).filter(q=>!!q),[G,ve]),Qe=qe.useMemo(()=>ve.map(q=>J[q]).filter(q=>!!q),[J,ve]),wr=qe.useMemo(()=>ve.map(q=>k[q]).filter(q=>!!q),[k,ve]),Dt=wr.findIndex(q=>q==="bar"),Nr=Dt!==-1,kr=qe.useCallback((q,me)=>{let Be=q.has(me);if(!Be&&J.reduce((tt,pt)=>q.has(pt.label)||pt.label===me?tt:tt+1,0)<1)return q;let Re=new Set(q);return Be?Re.delete(me):Re.add(me),Re},[J]),xt=qe.useCallback(q=>{if(h){let me=u;if(!me.has(q)&&J.reduce((Oe,tt)=>me.has(tt.label)||tt.label===q?Oe:Oe+1,0)<1){S(null);return}p?.(Re=>kr(Re,q));}else E(me=>kr(me,q));S(null);},[h,u,p,J,kr]),Zt=qe.useMemo(()=>J.map(q=>q.label).join(""),[J]),_=qe.useRef(Zt);qe.useEffect(()=>{_.current!==Zt&&(_.current=Zt,h||E(q=>q.size===0?q:new Set));},[Zt,h]);let Ge=qe.useMemo(()=>Xe.flat(),[Xe]),_e=qe.useMemo(()=>{if(Ge.length===0)return null;let q=[...Ge].sort((me,Be)=>me.xValue.getTime()-Be.xValue.getTime());return [q[0].xValue,q[q.length-1].xValue]},[Ge]),ke=R||_e,K=qe.useCallback(q=>{y?c?.(q):N(q);},[y,c]),H=qe.useMemo(()=>ke?G.map(me=>me.filter(Be=>Be.xValue>=ke[0]&&Be.xValue<=ke[1])):G,[G,ke]),de=qe.useMemo(()=>ve.map(q=>H[q]??[]),[ve,H]);qe.useEffect(()=>{c&&c(R);},[R,c]);let se=qe.useMemo(()=>ve.flatMap(q=>H[q]??[]),[H,ve]),ue=qe.useMemo(()=>Hi(se,re,r,o),[se,re,r,o]),Te=qe.useRef(JSON.stringify(r)),$e=qe.useRef(null),te=qe.useMemo(()=>{let[q,me]=ue.domain(),Be=Math.max(Math.abs(q),Math.abs(me)),Re=JSON.stringify(r);if(Re!==Te.current&&(Te.current=Re,$e.current=null),$e.current!==null)return $e.current;if(Be===0)return Xa(r,0);let Oe=Xa(r,Be);return $e.current=Oe,Oe},[ue,r]),pe=qe.useMemo(()=>{let q=re-He.top-He.bottom;return qa(q)},[re]),Q=qe.useMemo(()=>{let q=Dr(te),me=q.tickFormat||q.format,Re=ue.ticks(pe).map(pt=>me(pt)),Oe=ja(Re,12,"system-ui"),tt=Math.ceil(Oe)+12;return {...He,left:Math.max(tt,30),right:8}},[ue,te,pe]),De=qe.useMemo(()=>ke?scale.scaleTime({domain:ke,range:[Q.left,L-Q.right]}):op(Ge,L),[ke,Ge,L,Q]),mo=qe.useCallback(q=>{if(!_e)return;let{scaleX:me,translateX:Be}=q,Re=L-Q.left-Q.right,[Oe,tt]=_e,pt=tt.getTime()-Oe.getTime();if(pt<=0){K(null);return}let Ae=-Be,ct=Ae+Re,Ie=Re*me/pt,kt=Ae/Ie,Fe=ct/Ie,Pn=new Date(Oe.getTime()+kt),ka=new Date(Oe.getTime()+Fe),Rn=Math.abs(Pn.getTime()-Oe.getTime()),Nd=Math.abs(ka.getTime()-tt.getTime()),ef=pt*.02;Rn<ef&&Nd<ef?K(null):K([Pn,ka]);},[_e,L,Q,K]),Is=qe.useCallback(q=>{let{left:me}=T.current?.getBoundingClientRect()||{left:0},Be=q.clientX-me;if(q.timeStamp-(M.current||0)<16)return;M.current=q.timeStamp;let Re=De.invert(Be),Oe=de.map((Ae,ct)=>{if(!Ae||Ae.length===0)return null;let Ie=JP(Ae,Re,1);if(Ie===0)return {point:Ae[0],index:0,datasetIndex:ct};if(Ie>=Ae.length)return {point:Ae[Ae.length-1],index:Ae.length-1,datasetIndex:ct};let kt=Ae[Ie-1],Fe=Ae[Ie];if(!kt||!Fe)return null;let Pn=Math.abs(kt.xValue.getTime()-Re.getTime()),ka=Math.abs(Fe.xValue.getTime()-Re.getTime()),Rn=Pn<ka;return {point:Rn?kt:Fe,index:Rn?Ie-1:Ie,datasetIndex:ct}}).filter(Ae=>Ae!==null&&Qe[Ae.datasetIndex]!==void 0).map(({point:Ae,index:ct,datasetIndex:Ie})=>({label:Qe[Ie].label,value:Ae.yValue,baselineValue:YP(Qe[Ie],Ae,ct),color:Qe[Ie].color,point:Ae,type:wr[Ie]}));if(Oe.length===0){S(null);return}let tt=De(Oe[0].point.xValue),pt=tt>(L-Q.right-Q.left)/2+Q.left;S({xValue:Oe[0].point.xValue,series:Oe.map(({label:Ae,value:ct,baselineValue:Ie,color:kt,point:Fe,type:Pn})=>({label:Ae,value:ct,...Ie!==void 0?{baselineValue:Ie}:{},chartY:Fe.chartYValue??ct,showMarker:Fe.showTooltipMarker??true,color:kt,type:Pn,category:Fe.category,categoryColor:Fe.category&&A?A[Fe.category]:void 0,...Fe.extraTooltipRows&&Fe.extraTooltipRows.length>0?{extraTooltipRows:Fe.extraTooltipRows}:{}})),x:tt,y:ue(Oe[0].point.chartYValue??Oe[0].value),position:pt?"left":"right"});},[de,Qe,wr,De,ue,L,A,Q]),Io=()=>{S(null);},a0=qe.useCallback(()=>{K(null),z.current&&z.current.reset();},[K]),i0=qe.useCallback(q=>{let me={scaleX:1,scaleY:1,translateX:0,translateY:0,skewX:0,skewY:0};if(!q||!_e)return me;let[Be,Re]=_e,Oe=Re.getTime()-Be.getTime();if(Oe<=0)return me;let[tt,pt]=q,Ae=pt.getTime()-tt.getTime();if(Ae<=0)return me;let ct=Oe/Ae,Ie=L-Q.left-Q.right,kt=tt.getTime()-Be.getTime();return {scaleX:ct,scaleY:1,translateX:-(kt/Oe)*Ie*ct,translateY:0,skewX:0,skewY:0}},[_e,L,Q]),Fs=qe.useCallback(q=>{if(!(z.current&&_e))return;let[me,Be]=_e,Re=Be.getTime()-me.getTime();if(Re<=0){z.current.reset();return}if(!q){z.current.reset();return}let[Oe,tt]=q,pt=tt.getTime()-Oe.getTime();if(pt<=0){z.current.reset();return}let Ae=Re/pt,ct=L-Q.left-Q.right,kt=-((Oe.getTime()-me.getTime())/Re)*ct*Ae;z.current.setTransformMatrix({scaleX:Ae,scaleY:1,translateX:kt,translateY:0,skewX:0,skewY:0});},[_e,L,Q]),s0=qe.useCallback(q=>{K(q),Fs(q);},[K,Fs]);qe.useEffect(()=>{y&&Fs(d??null);},[y,d,Fs]);let l0=Cl(),c0={width:L,height:re,xScale:De,yScale:ue,yFormatter:te,animationSettings:vl,entrance:l0,tooltip:{data:v,show:S,hide:()=>S(null)},datasets:de,seriesMetadata:Qe,seriesTypes:wr,categoryColors:A||void 0,categoryLabels:Y||void 0},d0=qe.Children.toArray(b),Qm=0,Zm=[],_m=[],Sd=[];d0.forEach(q=>{if(!qe.isValidElement(q)){Sd.push(q);return}if(KP(q))_m.push(q);else if(lh(q)){let me=Qm;Qm++;let Be=q.props,Re=J[me]?.label;if(ie(Re))return;Zm.push(qe__namespace.default.cloneElement(q,{...Be,data:H[me]||Be.data,color:J[me]?.color}));}else Sd.push(q);});let u0=ve.length,p0=(W||J).map(q=>{let me=!W&&ie(q.label);return {category:q.label,fill:q.color,isHidden:me,isDisabled:!W&&!me&&u0<=1}}),m0=typeof r=="object"&&r!==null&&typeof r.type=="string",f0=Rl({datasets:Xe,metadata:{xLabel:"Date",yLabel:"Value",seriesLabels:Qe.map(q=>q.label),timestamp:true,...m0?{yFormat:r}:{}},svgRef:T}),wd=jsxRuntime.jsx(Ba,{title:x,controls:g,actions:ce,containerRef:ee,marginRight:Q.right});if(a)return C.present(jsxRuntime.jsxs("div",{className:"relative flex h-full flex-col",children:[wd,jsxRuntime.jsx(jP,{})]}));if(G.length===0)return C.present(jsxRuntime.jsxs("div",{className:"relative flex h-full flex-col",children:[wd,jsxRuntime.jsx(XP,{})]}));let $m=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("title",{children:x}),jsxRuntime.jsx("g",{children:ue.ticks(pe).map(q=>{let me=Math.abs(q)<Number.EPSILON;return jsxRuntime.jsx(shape.Line,{from:{x:Q.left,y:ue(q)},to:{x:L-Q.right,y:ue(q)},stroke:me?"var(--color-border-default)":"var(--color-border-muted)",strokeWidth:me?1.5:1},`grid-line-${q}`)})}),jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:D,children:jsxRuntime.jsx("rect",{x:De.range()[0],y:ue.range()[1],width:De.range()[1]-De.range()[0],height:ue.range()[0]-ue.range()[1]})})}),jsxRuntime.jsx("g",{clipPath:`url(#${D})`,children:Zm}),Sd,n&&n.length>0&&jsxRuntime.jsx("g",{children:n.map(q=>{let me=ue(q.value),Be=q.color??"var(--color-error-base)";return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx(shape.Line,{from:{x:Q.left,y:me},to:{x:L-Q.right,y:me},stroke:Be,strokeWidth:1.5,strokeDasharray:"6 4"}),q.label&&jsxRuntime.jsx("text",{x:L-Q.right-4,y:me-4,textAnchor:"end",fontSize:11,fill:Be,children:q.label})]},`ref-line-${q.value}`)})}),jsxRuntime.jsx(Xr.Bottom,{top:re-Q.bottom,scale:De,width:L-Q.left-Q.right}),jsxRuntime.jsx(Xr.Left,{left:Q.left,scale:ue,yFormatter:te,height:re-Q.top-Q.bottom}),v&&!v.isEvent&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[Nr?(()=>{let q=Xe[Dt]??[];if(q.length===0)return null;let me=[...q].sort((Ie,kt)=>Ie.xValue.getTime()-kt.xValue.getTime()),Be=me.findIndex(Ie=>Ie.xValue.getTime()===v.xValue.getTime()),Re=me[Be+1],Oe=me.length>1&&Re?Re.xValue.getTime()-v.xValue.getTime():15*6e4,tt=Math.abs(De(new Date(v.xValue.getTime()+Oe))-De(v.xValue)),Ae=De(v.xValue)-tt/2,ct=ue.range();return jsxRuntime.jsx("rect",{x:Ae,y:ct[1],width:tt,height:ct[0]-ct[1],className:"fill-background-muted",opacity:.5,pointerEvents:"none",style:{transition:"all 100ms ease-out"}})})():null,v.series.filter(q=>q.type!=="bar"&&q.showMarker!==false).map(q=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("circle",{cx:De(v.xValue),cy:ue(q.chartY??q.value),r:8,fill:"white",stroke:q.color,strokeWidth:2,style:{transition:"all 100ms ease-out"}}),jsxRuntime.jsx("circle",{cx:De(v.xValue),cy:ue(q.chartY??q.value),r:4,fill:q.color,style:{transition:"all 100ms ease-out"}})]},`highlight-${q.label}`))]}),jsxRuntime.jsx("rect",{x:Q.left,y:Q.top,width:L-Q.left-Q.right,height:re-Q.top-Q.bottom,fill:"transparent",style:{cursor:i?"grab":"crosshair",touchAction:"none"},onMouseMove:Is,onMouseLeave:Io}),_m]});return C.present(jsxRuntime.jsx("div",{className:"relative flex h-full flex-col",children:jsxRuntime.jsxs(Jr.Provider,{value:c0,children:[wd,i?jsxRuntime.jsx(zoom.Zoom,{initialTransformMatrix:i0(R),width:L,height:re,scaleXMin:1,scaleXMax:20,scaleYMin:1,scaleYMax:1,constrain:q=>{let{scaleX:me,translateX:Be}=q,Re=Math.max(1,Math.min(20,me)),Oe=1,tt=L-Q.left-Q.right,pt=0,Ae=tt*(1-Re),ct=Math.max(Ae,Math.min(pt,Be));return {...q,scaleX:Re,scaleY:Oe,translateX:ct,translateY:0}},children:q=>{if(z.current=q,q.transformMatrix){let{scaleX:me,translateX:Be}=q.transformMatrix,Re=`${me.toFixed(4)}-${Be.toFixed(2)}`;Re!==B.current&&(B.current=Re,setTimeout(()=>{mo(q.transformMatrix);},0));}return jsxRuntime.jsx("svg",{width:L,height:re,className:"overflow-visible",ref:me=>{T.current=me,q.containerRef.current!==me&&(q.containerRef.current=me);},role:"img","aria-label":x,style:{cursor:q.isDragging?"grabbing":"grab",touchAction:"none"},onMouseDown:q.dragStart,onMouseMove:q.dragMove,onMouseUp:q.dragEnd,onMouseLeave:()=>{q.isDragging&&q.dragEnd();},onTouchStart:q.dragStart,onTouchMove:q.dragMove,onTouchEnd:q.dragEnd,children:$m})}},`zoom-${Math.round(L)}x${Math.round(re)}`):jsxRuntime.jsx("svg",{width:L,height:re,className:"overflow-visible",ref:T,role:"img","aria-label":x,children:$m}),jsxRuntime.jsx(Co,{data:v,formatter:te}),s&&_e&&jsxRuntime.jsx(up,{data:Xe,seriesMetadata:Qe,width:L,height:l,onBrushChange:s0,brushRegion:R,margin:Q,...o?{yDomain:o}:{}}),!m&&jsxRuntime.jsx(Za,{onExport:f0,items:p0,marginLeft:0,marginRight:Q.right,isZoomed:R!==null,onResetZoom:a0,onLegendItemToggle:W?void 0:xt})]})}))},ch=responsive.withParentSize(qP);var t1=e=>e.toLocaleString(),r1=e=>`${Math.round(e*100)}%`,mh=({data:e,width:t=800,height:r=400,padding:o=0,barGap:n=30,formatValue:a=t1,formatPercentage:i=r1,color:s,showScale:l=true,showOverallConversion:c=true,overallConversionLabel:d="Overall Conversion:",activeStageId:u,onStageClick:p,onStageHover:m,className:f,style:g,"aria-label":x="Funnel chart"})=>{let[b,h]=qe.useState(null),[y,v]=qe.useState(t),S=qe.useRef(null),w=u??b,N=qe.useId(),R=s||"var(--color-viz-default)";qe.useEffect(()=>{if(!S.current)return;let M=new ResizeObserver(B=>{for(let z of B)v(z.contentRect.width);});return M.observe(S.current),()=>{M.disconnect();}},[]);let{layout:P,overallConversion:E}=qe.useMemo(()=>{if(e.length===0)return {layout:[],overallConversion:0};let M=e[0].value,B=c?60:0,z=r-o*2-B,V=(e.length-1)*n,U=(z-V)/e.length,Z=e.map((J,W)=>{let A=o+B+W*(U+n),Y=M===0?0:J.value/M,k=Y,C=W===0?null:e[W-1].value,L=C==null||C===0?0:1-J.value/C;return {stage:J,index:W,y:A,barHeight:U,widthPercent:Y,conversionRate:k,dropOff:L}}),G=M===0?0:e[e.length-1].value/M;return {layout:Z,overallConversion:G,maxValue:M}},[e,y,r,o,n,l,c]);if(e.length===0)return jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex h-full min-h-[280px] w-full items-center justify-center rounded-lg border border-dashed border-border-default bg-background-surface text-sm font-medium text-text-secondary",f),style:{width:t,height:r,...g},children:"No funnel data available"});let I=l?60:0,T=o+I,D=y-o*2-I;return jsxRuntime.jsx("div",{ref:S,className:tailwindMerge.twMerge("relative w-full overflow-hidden rounded-lg bg-background-surface",f),style:{height:r,...g},"aria-label":x,role:"img",children:jsxRuntime.jsxs("svg",{width:"100%",height:r,className:"relative",children:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsx(gradient.LinearGradient,{id:`${N}-bar`,from:R,to:R,toOpacity:.85}),jsxRuntime.jsx(gradient.LinearGradient,{id:`${N}-bg`,from:R,to:R,fromOpacity:.01,toOpacity:.15,x1:"0",y1:"0",x2:"1",y2:"0"})]}),c&&jsxRuntime.jsxs("text",{x:T,y:o+20,className:"fill-text-primary text-sm font-medium",children:[jsxRuntime.jsx("tspan",{className:"fill-text-secondary",children:d})," ",i(E)]}),l&&jsxRuntime.jsx("g",{children:P.map(M=>{let B=M.y+M.barHeight/2;return jsxRuntime.jsx("text",{x:o+I-12,y:B,textAnchor:"end",dominantBaseline:"middle",className:"fill-text-secondary text-xs",children:i(M.conversionRate)},M.stage.id)})}),P.map(M=>{let B=w===M.stage.id,z=D*M.widthPercent;return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:T,y:M.y,width:D,height:M.barHeight,fill:`url(#${N}-bg)`,rx:4}),jsxRuntime.jsx(framerMotion.motion.rect,{x:T,y:M.y,width:z,height:M.barHeight,fill:`url(#${N}-bar)`,rx:4,initial:{width:0},animate:{width:z},transition:{duration:.6,delay:M.index*.1,ease:"easeOut"},opacity:B||w==null?1:.5,style:{cursor:p||m?"pointer":"default",transition:"opacity 150ms ease"},onMouseEnter:()=>{h(M.stage.id),m?.(M.stage);},onMouseLeave:()=>{h(null),m?.(null);},onClick:()=>p?.(M.stage)}),jsxRuntime.jsx("rect",{x:T+10,y:M.y+M.barHeight/2-10,width:70,height:20,className:"fill-background-surface stroke-border-default",strokeWidth:1,rx:4,style:{pointerEvents:"none"}}),jsxRuntime.jsx("text",{x:T+16,y:M.y+M.barHeight/2+4,className:"fill-text-primary text-xs font-semibold",style:{pointerEvents:"none"},children:a(M.stage.value)}),jsxRuntime.jsxs("text",{x:T,y:M.y-8,className:"fill-text-secondary text-xs",style:{pointerEvents:"none"},children:[jsxRuntime.jsx("tspan",{children:M.index+1})," ",M.stage.label]}),M.stage.secondaryValue&&jsxRuntime.jsx("text",{x:T+16,y:M.y-24,className:"fill-text-secondary text-xs",style:{pointerEvents:"none"},children:M.stage.secondaryValue}),M.index>0&&M.dropOff>0&&jsxRuntime.jsxs("text",{x:T+D,y:M.y-8,textAnchor:"end",className:"fill-text-secondary text-xs",children:[i(M.dropOff)," drop"]}),M.stage.annotation&&jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("rect",{x:T+z+8,y:M.y+8,width:60,height:24,rx:3,className:"fill-background-muted"}),jsxRuntime.jsx("text",{x:T+z+16,y:M.y+20,className:"fill-text-secondary text-xs font-medium",children:M.stage.annotation})]})]},M.stage.id)})]})})};var s1=.005,bh=320;function Al(e){return e>0?e:0}function l1(e,t,r){let o=t===0?0:Al(e.value)/t*100;return `${e.label}: ${r(e.value)}, ${o.toFixed(1)}%`}var hh=({data:e,width:t,height:r,innerRadiusRatio:o=0,yFormatter:n={type:"number"},showLegend:a=true,showTooltip:i=true,onSliceClick:s,onSliceHover:l,className:c,style:d,"aria-label":u})=>{let[p,m]=qe.useState(null),[f,g]=qe.useState(null),[x,b]=qe.useState(null),[h,y]=qe.useState(t??600),[v,S]=qe.useState(r??300),w=qe.useRef(null);qe.useEffect(()=>{if(t!==void 0&&r!==void 0){y(t),S(r);return}if(!w.current)return;let V=new ResizeObserver(U=>{for(let Z of U)t===void 0&&y(Z.contentRect.width),r===void 0&&S(Z.contentRect.height);});return V.observe(w.current),t===void 0&&y(w.current.offsetWidth),r===void 0&&S(w.current.offsetHeight||300),()=>{V.disconnect();}},[t,r]);let N=qe.useMemo(()=>e.reduce((V,U)=>V+Al(U.value),0),[e]),R=qe.useMemo(()=>{let V=Si(e.map(U=>U.label));return e.map(U=>({...U,color:U.color||V[U.label]||"var(--color-viz-default)"}))},[e]),P=Dr(n),E=s!==void 0,I=a&&h>=bh,T=I?Math.max(h*.45,bh*.45):h,M=Math.max(0,Math.min(T,v)-8)/2,B=M*Math.min(Math.max(o,0),.95);if(e.length===0||N===0)return jsxRuntime.jsx("div",{ref:w,className:tailwindMerge.twMerge("flex h-full min-h-[200px] w-full items-center justify-center rounded-lg border border-dashed border-border-default bg-background-surface text-sm font-medium text-text-secondary",c),style:r!==void 0?{height:r,...d}:d,children:"No data available"});let z=(V,U,Z)=>{if(m(V),l?.(U,V),V!==null&&U&&Z){let G=T/2+Z[0],J=v/2+Z[1];b(U.label),g({xValue:new Date,series:[{label:"Value",value:U.value,color:U.color||"var(--color-viz-default)"}],x:G,y:J,position:G>h/2?"left":"right"});}else g(null),b(null);};return jsxRuntime.jsxs("div",{ref:w,className:tailwindMerge.twMerge("relative flex h-full w-full items-center gap-4 rounded-lg bg-background-surface",c),style:r!==void 0?{height:r,...d}:d,children:[jsxRuntime.jsx("svg",{width:T,height:v,className:"flex-shrink-0",role:E?"group":"img","aria-label":u,children:jsxRuntime.jsx(group.Group,{top:v/2,left:T/2,children:jsxRuntime.jsx(shape.Pie,{data:R,pieValue:V=>Al(V.value),pieSort:null,pieSortValues:null,outerRadius:M,innerRadius:B,padAngle:s1,children:V=>V.arcs.map((U,Z)=>{let G=p===Z||p===null,J=V.path.centroid(U);return jsxRuntime.jsx("path",{d:V.path(U)??void 0,fill:U.data.color,opacity:G?1:.5,style:{cursor:s||l?"pointer":"default",transition:"opacity 150ms ease-out"},onMouseEnter:()=>z(Z,U.data,J),onMouseLeave:()=>z(null,null),onClick:()=>s?.(U.data,Z),...E?{role:"button",tabIndex:0,"aria-label":l1(U.data,N,P.format),onFocus:()=>z(Z,U.data,J),onBlur:()=>z(null,null),onKeyDown:W=>{W.key!=="Enter"&&W.key!==" "||(W.preventDefault(),s?.(U.data,Z));}}:{}},U.data.label)})})})}),I?jsxRuntime.jsx("ul",{className:"flex min-w-0 flex-col gap-1 overflow-y-auto py-2 text-xs",children:R.map((V,U)=>jsxRuntime.jsxs("li",{className:"flex items-center gap-2",style:{opacity:p===U||p===null?1:.5},onMouseEnter:()=>z(U,V),onMouseLeave:()=>z(null,null),children:[jsxRuntime.jsx("span",{className:"h-3 w-3 flex-shrink-0 rounded-sm",style:{backgroundColor:V.color}}),jsxRuntime.jsx("span",{className:"truncate text-text-primary",title:V.label,children:V.label}),jsxRuntime.jsxs("span",{className:"ml-auto flex-shrink-0 tabular-nums text-text-secondary",children:[P.format(V.value)," (",(Al(V.value)/N*100).toFixed(1),"%)"]})]},V.label))}):null,i&&jsxRuntime.jsx(Co,{data:f,formatter:n,label:x??void 0})]})};function xh(){let e=new Map;return {publish(t,r){for(let[o,n]of e)o!==t&&n(r);},subscribe(t,r){return e.set(t,r),()=>{e.delete(t);}}}}var d1=d3Array.bisector(e=>e.xValue).left,u1=(e,t,r)=>{if(!e.tooltipRange||e.baseline===void 0)return;let o=typeof e.baseline=="function"?e.baseline(t,r):e.baseline;return typeof o=="number"&&Number.isFinite(o)&&o!==t.yValue?o:void 0};function yh(e){let{mouseX:t,datasets:r,seriesMetadata:o,seriesTypes:n,xScale:a,yScale:i,plotLeft:s,plotRight:l}=e,c=a.invert(t),d=r.map((m,f)=>{if(!m||m.length===0)return null;let g=d1(m,c,1);if(g===0)return {point:m[0],index:0,datasetIndex:f};if(g>=m.length)return {point:m[m.length-1],index:m.length-1,datasetIndex:f};let x=m[g-1],b=m[g];if(!x||!b)return null;let h=Math.abs(x.xValue.getTime()-c.getTime()),y=Math.abs(b.xValue.getTime()-c.getTime()),v=h<y;return {point:v?x:b,index:v?g-1:g,datasetIndex:f}}).filter(m=>m!==null&&o[m.datasetIndex]!==void 0).map(({point:m,index:f,datasetIndex:g})=>({label:o[g].label,value:m.yValue,baselineValue:u1(o[g],m,f),color:o[g].color,point:m,type:n[g]}));if(d.length===0)return null;let u=a(d[0].point.xValue),p=u>(s+l)/2;return {xValue:d[0].point.xValue,series:d.map(({label:m,value:f,baselineValue:g,color:x,point:b,type:h})=>({label:m,value:f,...g!==void 0?{baselineValue:g}:{},chartY:b.chartYValue??f,showMarker:b.showTooltipMarker??true,color:x,type:h,...b.category!==void 0?{category:b.category}:{},...b.extraTooltipRows&&b.extraTooltipRows.length>0?{extraTooltipRows:b.extraTooltipRows}:{}})),x:u,y:i(d[0].point.chartYValue??d[0].value),position:p?"left":"right"}}var Sh=e=>e instanceof Date&&!Number.isNaN(e.getTime()),g1=160;function Il(e,t,r){let[o,n]=qe.useState(null);qe.useImperativeHandle(r,()=>({setPreview:n}),[]);let[a,i]=e.range(),s=qe.useMemo(()=>o?d3Scale.scaleTime().domain([new Date(o[0]),new Date(o[1])]).range([a,i]):e,[o,e,a,i]),l=s.domain(),c=l[0],d=l[l.length-1],u=Sh(c)&&Sh(d),p=t<400,m=Math.max(2,Math.min(8,Math.floor(t/(p?70:110)))),f=qe.useMemo(()=>{if(!u)return [];let g=i-a;if(g<=0)return s.ticks(m);let[x,b]=s.domain(),h=x.getTime(),y=b.getTime(),v=(y-h)/g,S=Math.min(g1,g),w=S*v,N=d3Scale.scaleTime().domain([new Date(h-w),new Date(y+w)]).range([a-S,i+S]),R=d3Time.timeTickInterval(x,b,m);if(R)return N.ticks(R);let P=Math.max(2,Math.round(m*(g+2*S)/g));return N.ticks(P)},[s,m,u,a,i]);return {activeScale:s,ticks:f,start:c,end:d,valid:u,compact:p,rangeStart:a,rangeEnd:i}}var y1=6,wh=20,yp=qe.forwardRef(({top:e,scale:t,width:r},o)=>{let{activeScale:n,ticks:a,start:i,end:s,valid:l,compact:c,rangeStart:d,rangeEnd:u}=Il(t,r,o),p=a.length>=2?a[1].getTime()-a[0].getTime():s.getTime()-i.getTime(),m=qe.useMemo(()=>l?og(p,{compact:c}):()=>"",[p,c,l]),f=qe.useId(),g=Math.min(d,u),x=Math.abs(u-d);return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("line",{x1:d,x2:u,y1:e,y2:e,stroke:"var(--color-border-muted)",strokeWidth:1}),a.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:f,children:jsxRuntime.jsx("rect",{x:g,y:e-4,width:x,height:wh+16})})}),jsxRuntime.jsx("g",{clipPath:`url(#${f})`,children:a.map(b=>jsxRuntime.jsxs("g",{transform:`translate(${n(b)},${e})`,children:[jsxRuntime.jsx("line",{x1:0,x2:0,y1:0,y2:y1,stroke:"var(--color-border-muted)",strokeWidth:1}),jsxRuntime.jsx("text",{x:0,y:wh,textAnchor:"middle",fontSize:12,fill:"var(--color-text-secondary)",children:m(b)})]},b.getTime()))})]})]})});yp.displayName="LiveTimeAxisBottom";var vp=qe.forwardRef(({scale:e,width:t,top:r,bottom:o},n)=>{let{activeScale:a,ticks:i,rangeStart:s,rangeEnd:l}=Il(e,t,n),c=qe.useId(),d=Math.min(s,l),u=Math.abs(l-s);return jsxRuntime.jsxs("g",{"aria-hidden":"true",children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:c,children:jsxRuntime.jsx("rect",{x:d,y:r,width:u,height:o-r})})}),jsxRuntime.jsx("g",{clipPath:`url(#${c})`,children:i.map(p=>{let m=a(p);return jsxRuntime.jsx("line",{x1:m,x2:m,y1:r,y2:o,stroke:"var(--color-border-muted)",strokeWidth:1},p.getTime())})})]})});vp.displayName="LiveTimeGridlines";function Fl(e,t,r){let o=e[1]-e[0],n=t/Math.max(1,r)*o;return [e[0]-n,e[1]-n]}function Nh(e,t,r){let o=e[1]-e[0],n=e[0]+t*o,a=o/r,i=n-t*a;return [i,i+a]}function Cp(e,t,r=16,o=800){return t===1?e*r:t===2?e*o:e}var kh=(e,t,r,o,n)=>{let a=t!==1?Nh(e,r,t):e;return o!==0&&(a=Fl(a,o,n)),a},Th=(e,t)=>{if(!t)return e;let r=e[1]-e[0];if(r>=t[1]-t[0])return [t[0],t[1]];let[o,n]=e;return n>t[1]&&(n=t[1],o=n-r),o<t[0]&&(o=t[0],n=o+r),[o,n]},k1=e=>typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(()=>e(0),0),T1=e=>{typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):clearTimeout(e);};function Ph(e){let{groupRef:t}=e,r=qe.useRef({xDomain:e.xDomain,plotWidthPx:e.plotWidthPx,plotLeftPx:e.plotLeftPx??0});r.current={xDomain:e.xDomain,plotWidthPx:e.plotWidthPx,plotLeftPx:e.plotLeftPx??0};let o=qe.useRef(e.onCommit);o.current=e.onCommit;let n=qe.useRef(e.panBoundsMs);n.current=e.panBoundsMs;let a=qe.useRef(e.settleMs??140);a.current=e.settleMs??140;let i=qe.useRef(e.zoomIntent??(T=>T.ctrlKey));i.current=e.zoomIntent??(T=>T.ctrlKey);let s=qe.useRef(e.onGestureStart);s.current=e.onGestureStart;let l=qe.useRef(e.onFramePreview);l.current=e.onFramePreview;let c=qe.useRef(null),d=qe.useRef({scale:1,cursorFrac:.5,panDxPx:0,timer:null}),u=qe.useRef(null),p=qe.useRef(null),m=qe.useRef(false),f=qe.useCallback((T,D,M)=>{p.current={translateX:T,scaleX:D,preview:M},u.current==null&&(u.current=k1(()=>{u.current=null;let B=p.current;B!=null&&(t.current?.setAttribute("transform",`translate(${B.translateX},0) scale(${B.scaleX},1)`),l.current?.(B.preview));}));},[t]),g=qe.useCallback(()=>{u.current!=null&&(T1(u.current),u.current=null),p.current=null,t.current?.removeAttribute("transform"),l.current?.(null);},[t]),x=qe.useCallback(()=>{m.current||(m.current=true,s.current?.());},[]),b=qe.useCallback(()=>{m.current=false;},[]),h=qe.useCallback(()=>{d.current.timer!=null&&(clearTimeout(d.current.timer),d.current.timer=null);},[]),y=qe.useCallback(()=>{d.current={scale:1,cursorFrac:.5,panDxPx:0,timer:null};},[]),v=qe.useCallback(()=>{let{xDomain:T,plotWidthPx:D}=r.current,{scale:M,cursorFrac:B,panDxPx:z}=d.current;M===1&&z===0||o.current(Th(kh(T,M,B,z,D),n.current));},[]),S=qe.useCallback(()=>{d.current.timer!=null&&(h(),v(),y(),g());},[h,v,y,g]),w=qe.useCallback(T=>{S(),T.currentTarget.setPointerCapture?.(T.pointerId),c.current={startX:T.clientX,dxPx:0},x();},[S,x]),N=qe.useCallback(T=>{if(!c.current)return;c.current.dxPx=T.clientX-c.current.startX;let{xDomain:D,plotWidthPx:M}=r.current;f(c.current.dxPx,1,Fl(D,c.current.dxPx,M));},[f]),R=qe.useCallback(T=>{if(!c.current)return;let{dxPx:D}=c.current;c.current=null,g(),b(),D!==0&&o.current(Th(Fl(r.current.xDomain,D,r.current.plotWidthPx),n.current));},[g,b]),P=qe.useCallback(()=>{c.current&&(c.current=null,g(),b());},[g,b]),E=qe.useRef(null),I=qe.useCallback(T=>{if(E.current?.(),E.current=null,!T)return;let D=M=>{if(c.current)return;let{plotWidthPx:B,plotLeftPx:z}=r.current,V=Cp(M.deltaY,M.deltaMode),U=Cp(M.deltaX,M.deltaMode),Z=i.current(M);if(!Z&&U===0)return;if(M.preventDefault(),x(),Z){let A=Math.min(1,Math.max(0,(M.clientX-T.getBoundingClientRect().left)/Math.max(1,B)));d.current.scale*=Math.exp(-V/200),d.current.cursorFrac=A;}else d.current.panDxPx-=U;let{scale:G,cursorFrac:J,panDxPx:W}=d.current;f((z+J*B)*(1-G)+W,G,kh(r.current.xDomain,G,J,W,B)),h(),d.current.timer=setTimeout(()=>{v(),y(),g(),b();},a.current);};T.addEventListener("wheel",D,{passive:false}),E.current=()=>T.removeEventListener("wheel",D);},[f,g,h,v,y,x,b]);return qe.useEffect(()=>()=>{E.current?.(),E.current=null,g(),d.current.timer!=null&&clearTimeout(d.current.timer);},[g]),{onPointerDown:w,onPointerMove:N,onPointerUp:R,onPointerCancel:P,wheelTargetRef:I,gestureActiveRef:m}}var Lh=e=>e.type===pn||e.type===Jn,D1=({children:e,title:t,headerActions:r,headerControls:o,viewport:n,panBounds:a,onViewportChange:i,onPlotWidthChange:s,yFormatter:l={type:"number"},yDomain:c,referenceLines:d,cameraSync:u,parentWidth:p=0,parentHeight:m=0})=>{let[f,g]=qe.useState(null),x=qe.useRef(null),b=qe.useRef(0),h=qe.useId(),y=qe.useRef(null),v=qe.useRef(null),S=qe.useRef(null),{colorMode:w}=jt(),N=qe.useMemo(()=>Fo(),[w]),R=qe.useMemo(()=>Ci(),[w]),{datasets:P,seriesMetadata:E,seriesTypes:I}=qe.useMemo(()=>{let oe=qe.Children.toArray(e).filter(se=>qe.isValidElement(se)&&Lh(se)),ke=oe.filter(se=>se.props.data).length,K=[],H=[],de=[];return oe.forEach((se,ue)=>{let Te=se.props;if(!Te.data)return;K.push(Te.data);let te=("color"in Te&&Te.color?Te.color:void 0)||(ke===1?R:N[ue%N.length]),pe=se.type===pn;H.push({label:"label"in Te&&Te.label||`Series ${K.length}`,color:te,...pe&&"baseline"in Te&&Te.baseline!==void 0?{baseline:Te.baseline,tooltipRange:"tooltipRange"in Te&&Te.tooltipRange||false}:{}}),de.push(pe?"area":"line");}),{datasets:K,seriesMetadata:H,seriesTypes:de}},[e,R,N]),T=Yn(t),D=T.expandedSize?.width??p,M=r||T.action?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r,T.action]}):void 0,{headerRef:B,headerHeight:z}=Fa(!!M,!!o),V=Math.max(100,(T.expandedSize?.height??m)-z-60),U=qe.useMemo(()=>[new Date(n.startMs),new Date(n.endMs)],[n.startMs,n.endMs]),Z=qe.useMemo(()=>{let oe=P.flat(),ke=oe.filter(K=>{let H=K.xValue.getTime();return H>=n.startMs&&H<=n.endMs});return ke.length>0?ke:oe},[P,n.startMs,n.endMs]),G=qe.useMemo(()=>{let oe=Hi(Z,V,l,c);if(!c){let[ke,K]=oe.domain();K>ke&&oe.domain([ke,K+(K-ke)*.05]);}return oe},[Z,V,l,c]),J=qe.useRef(JSON.stringify(l)),W=qe.useRef(null),A=qe.useMemo(()=>{let[oe,ke]=G.domain(),K=Math.max(Math.abs(oe),Math.abs(ke)),H=JSON.stringify(l);if(H!==J.current&&(J.current=H,W.current=null),W.current!==null)return W.current;if(K===0)return Xa(l,0);let de=Xa(l,K);return W.current=de,de},[G,l]),Y=qe.useMemo(()=>{let oe=V-He.top-He.bottom;return qa(oe)},[V]),k=qe.useMemo(()=>{let oe=Dr(A),ke=oe.tickFormat||oe.format,H=G.ticks(Y).map(ue=>ke(ue)),de=ja(H,12,"system-ui"),se=Math.ceil(de)+12;return {...He,left:Math.max(se,30)}},[G,A,Y]),C=qe.useMemo(()=>scale.scaleTime({domain:U,range:[k.left,D-k.right]}),[U,D,k]),L=qe.useMemo(()=>[n.startMs,n.endMs],[n.startMs,n.endMs]),F=qe.useMemo(()=>a?[a.startMs,a.endMs]:void 0,[a]),j=qe.useCallback(oe=>{i({startMs:oe[0],endMs:oe[1]});},[i]),ne=D-k.left-k.right,ce=qe.useCallback(()=>g(null),[]),ee=qe.useRef({}),ae=qe.useRef(u);ae.current=u;let Le=qe.useCallback(oe=>{v.current?.setPreview(oe),S.current?.setPreview(oe),ae.current?.publish(ee.current,oe);},[]),{onPointerDown:ge,onPointerMove:xe,onPointerUp:re,onPointerCancel:ie,wheelTargetRef:ve,gestureActiveRef:Xe}=Ph({xDomain:L,plotWidthPx:ne,plotLeftPx:k.left,groupRef:y,onCommit:j,onGestureStart:ce,onFramePreview:Le,...F?{panBoundsMs:F}:{}}),Qe=qe.useRef({startMs:n.startMs,endMs:n.endMs,left:0,width:0});Qe.current={startMs:n.startMs,endMs:n.endMs,left:k.left,width:ne},qe.useEffect(()=>{if(!u)return;let oe=()=>{y.current?.removeAttribute("transform"),v.current?.setPreview(null),S.current?.setPreview(null);},ke=H=>{if(Xe.current)return;if(H==null){oe();return}let{startMs:de,endMs:se,left:ue,width:Te}=Qe.current,$e=se-de,te=H[1]-H[0];if($e<=0||te<=0||Te<=0)return;let pe=$e/te,Q=ue*(1-pe)+(de-H[0])*Te/te;y.current?.setAttribute("transform",`translate(${Q},0) scale(${pe},1)`),v.current?.setPreview(H),S.current?.setPreview(H);},K=u.subscribe(ee.current,ke);return ()=>{K(),Xe.current||oe();}},[u,Xe]),qe.useEffect(()=>{s?.(Math.max(0,D-k.left-k.right));},[D,k,s]);let wr=qe.useCallback(oe=>{if(Xe.current)return;let{left:ke}=x.current?.getBoundingClientRect()||{left:0},K=oe.clientX-ke;oe.timeStamp-(b.current||0)<16||(b.current=oe.timeStamp,g(yh({mouseX:K,datasets:P,seriesMetadata:E,seriesTypes:I,xScale:C,yScale:G,plotLeft:k.left,plotRight:D-k.right})));},[P,E,I,C,G,D,k,Xe]),Dt=qe.useCallback(()=>g(null),[]),Nr=Cl(),kr={width:D,height:V,xScale:C,yScale:G,yFormatter:A,animationSettings:vl,entrance:Nr,tooltip:{data:f,show:g,hide:()=>g(null)},datasets:P,seriesMetadata:E,seriesTypes:I},xt=0,Zt=[];qe.Children.toArray(e).forEach(oe=>{if(!qe.isValidElement(oe)){Zt.push(oe);return}if(Lh(oe)){let ke=xt;xt++;let K=oe.props;Zt.push(qe__namespace.default.cloneElement(oe,{...K,color:E[ke]?.color,animate:false}));}else Zt.push(oe);});let _=E.map(oe=>({category:oe.label,fill:oe.color})),Ge=Rl({datasets:P,metadata:{xLabel:"Date",yLabel:"Value",seriesLabels:E.map(oe=>oe.label),timestamp:true},svgRef:x}),_e=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("title",{children:t}),jsxRuntime.jsx("g",{children:G.ticks(Y).map(oe=>{let ke=Math.abs(oe)<Number.EPSILON;return jsxRuntime.jsx(shape.Line,{from:{x:k.left,y:G(oe)},to:{x:D-k.right,y:G(oe)},stroke:ke?"var(--color-border-default)":"var(--color-border-muted)",strokeWidth:ke?1.5:1},`grid-line-${oe}`)})}),jsxRuntime.jsx(vp,{ref:S,scale:C,width:D-k.left-k.right,top:G.range()[1],bottom:G.range()[0]}),jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:h,children:jsxRuntime.jsx("rect",{x:C.range()[0],y:G.range()[1],width:C.range()[1]-C.range()[0],height:G.range()[0]-G.range()[1]})})}),jsxRuntime.jsx("g",{clipPath:`url(#${h})`,children:jsxRuntime.jsx("g",{"data-camera-plot-group":"",ref:y,children:Zt})}),d&&d.length>0&&jsxRuntime.jsx("g",{children:d.map(oe=>{let ke=G(oe.value),K=oe.color??"var(--color-error-base)";return jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx(shape.Line,{from:{x:k.left,y:ke},to:{x:D-k.right,y:ke},stroke:K,strokeWidth:1.5,strokeDasharray:"6 4"}),oe.label&&jsxRuntime.jsx("text",{x:D-k.right-4,y:ke-4,textAnchor:"end",fontSize:11,fill:K,children:oe.label})]},`ref-line-${oe.value}`)})}),jsxRuntime.jsx(yp,{ref:v,top:V-k.bottom,scale:C,width:D-k.left-k.right}),jsxRuntime.jsx(Xr.Left,{left:k.left,scale:G,yFormatter:A,height:V-k.top-k.bottom}),f&&!f.isEvent&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(shape.Line,{"data-testid":"chart-hover-crosshair",from:{x:C(f.xValue),y:G.range()[1]},to:{x:C(f.xValue),y:G.range()[0]},stroke:"var(--color-text-secondary)",strokeWidth:1,strokeDasharray:"3 3",opacity:.7}),f.series.filter(oe=>oe.type!=="bar"&&oe.showMarker!==false).map(oe=>jsxRuntime.jsxs("g",{children:[jsxRuntime.jsx("circle",{cx:C(f.xValue),cy:G(oe.chartY??oe.value),r:8,fill:"white",stroke:oe.color,strokeWidth:2,style:{transition:"all 100ms ease-out"}}),jsxRuntime.jsx("circle",{cx:C(f.xValue),cy:G(oe.chartY??oe.value),r:4,fill:oe.color,style:{transition:"all 100ms ease-out"}})]},`highlight-${oe.label}`))]}),jsxRuntime.jsx("rect",{"data-camera-surface":"",x:k.left,y:k.top,width:D-k.left-k.right,height:V-k.top-k.bottom,fill:"transparent",style:{cursor:"grab",touchAction:"none"},onMouseMove:wr,onMouseLeave:Dt,onPointerDown:ge,onPointerMove:xe,onPointerUp:re,onPointerCancel:ie,ref:ve})]});return T.present(jsxRuntime.jsx("div",{className:"relative flex h-full flex-col",children:jsxRuntime.jsxs(Jr.Provider,{value:kr,children:[jsxRuntime.jsx(Ba,{title:t,controls:o,actions:M,containerRef:B,marginRight:k.right}),jsxRuntime.jsx("svg",{width:D,height:V,className:"overflow-visible",ref:x,role:"img","aria-label":t,children:_e}),jsxRuntime.jsx(Co,{data:f,formatter:A}),jsxRuntime.jsx(Za,{onExport:Ge,items:_,marginLeft:0,marginRight:k.right})]})}))},Bl=responsive.withParentSize(D1);function Vl(e,t,r,o){if(r.length===0)throw new Error("tierForViewport: resolution ladder is empty");let n=[...r].sort((s,l)=>s.bucketMs-l.bucketMs),a=e/Math.max(1,t*o.targetPointsPerPx),i=Math.max(o.nativeMs,a);return n.find(s=>s.bucketMs>=i)??n[n.length-1]}function A1(e,t){return Math.floor(e/t.tileSpanMs)}function mn(e,t,r){let o=A1(e.startMs,t)-r,n=Math.ceil(e.endMs/t.tileSpanMs)-1+r,a=[];for(let i=o;i<=n;i++)a.push({tierId:t.id,index:i,startMs:i*t.tileSpanMs,endMs:(i+1)*t.tileSpanMs});return a}var hr=(e,t)=>`${e}:${t}`;var Dh={erroredTiles:0};function Np(e,t){let r=new Map,o=new Map,n=new Map,a=0;for(let d of e){let u=t.get(hr(d.tierId,d.index));if(u){if(u.status==="error"){a+=1;continue}if(u.data){for(let p of u.data.line)r.set(p.xValue.getTime(),p);for(let p of u.data.band??[])o.set(p.xValue.getTime(),p);for(let[p,m]of Object.entries(u.data.lines??{})){let f=n.get(p);f||(f=new Map,n.set(p,f));for(let g of m)f.set(g.xValue.getTime(),g);}}}}let i=(d,u)=>d.xValue.getTime()-u.xValue.getTime(),s=[...r.values()].sort(i),l=[...o.values()].sort(i),c=Object.fromEntries([...n.entries()].map(([d,u])=>[d,[...u.values()].sort(i)]));return {line:s,band:l,lines:c,coverage:{earliestMs:s.length?s[0].xValue.getTime():void 0,latestMs:s.length?s[s.length-1].xValue.getTime():void 0,erroredTiles:a}}}function I1(e,t,r){let o=mn(e,t,0);return o.length===0?false:o.every(n=>{let a=r.get(hr(n.tierId,n.index));return a!=null&&(a.status==="loaded"||a.status==="empty")})}function Ah(e,t,r){return mn(e,t,0).some(n=>{let a=r.get(hr(n.tierId,n.index));return a?.status==="loaded"&&(a.data?.line.length??0)>0})}function F1(e,t){if(!e.line.length)return false;let r=e.coverage.earliestMs,o=e.coverage.latestMs;return r==null||o==null?false:r<t.endMs&&o>t.startMs}function Ih({viewport:e,targetTier:t,ladder:r,store:o,overscanTiles:n,prev:a}){let i=I1(e,t,o);if(i&&Ah(e,t,o)){let l=mn(e,t,n),{line:c,band:d,lines:u,coverage:p}=Np(l,o);return {line:c,band:d,lines:u,renderTier:t,targetTier:t,isFallback:false,isStale:false,coverage:p}}let s=r.findIndex(l=>l.id===t.id);for(let l=s+1;l<r.length;l++){let c=r[l];if(Ah(e,c,o)){let d=mn(e,c,n),{line:u,band:p,lines:m,coverage:f}=Np(d,o);return {line:u,band:p,lines:m,renderTier:c,targetTier:t,isFallback:true,isStale:false,coverage:f}}}if(i){let l=mn(e,t,n),{line:c,band:d,lines:u,coverage:p}=Np(l,o);return {line:c,band:d,lines:u,renderTier:t,targetTier:t,isFallback:false,isStale:false,coverage:p}}return a?F1(a,e)?{...a,targetTier:t,isFallback:true,isStale:false}:{line:a.line,band:a.band,lines:a.lines,renderTier:null,targetTier:t,isFallback:true,isStale:true,coverage:Dh}:{line:[],band:[],lines:{},renderTier:null,targetTier:t,isFallback:false,isStale:false,coverage:Dh}}var Fh=new Map;function Bh(e,t){switch(t.type){case "reset":return new Map;case "request":{let r=new Map(e);for(let o of t.ids){let n=r.get(o);(!n||n.status==="error")&&r.set(o,{status:"loading"});}return r}case "fulfilled":{let r=new Map(e);return r.set(t.id,{status:t.data.line.length>0?"loaded":"empty",data:t.data}),r}case "failed":{let r=new Map(e);return r.set(t.id,{status:"error",error:t.error}),r}default:return e}}function Oh({refs:e,refsKey:t,store:r,tier:o,viewport:n,fetchTile:a,dispatch:i,concurrency:s,maxFutureMs:l}){let c=qe.useRef(e);c.current=e;let d=qe.useRef(n);d.current=n;let u=qe.useRef(new Map),p=qe.useCallback(()=>{for(let m of u.current.values())m.ac.abort();u.current.clear();},[]);return qe.useEffect(()=>{for(let[b,h]of u.current)h.tierId!==o.id&&(h.ac.abort(),u.current.delete(b));let m=c.current.filter(b=>{let h=hr(b.tierId,b.index),y=r.get(h);return y?y.status==="loading"&&!u.current.has(h):true}),f=(d.current.startMs+d.current.endMs)/2;m.sort((b,h)=>Math.abs((b.startMs+b.endMs)/2-f)-Math.abs((h.startMs+h.endMs)/2-f));let g=Math.max(0,s-u.current.size),x=m.slice(0,g);if(x.length!==0){i({type:"request",ids:x.map(b=>hr(b.tierId,b.index))});for(let b of x){let h=hr(b.tierId,b.index),y=new AbortController;u.current.set(h,{ac:y,tierId:b.tierId});let v=l!=null?Math.min(b.endMs,l):b.endMs;a(o,b.startMs,v,y.signal).then(S=>{y.signal.aborted||i({type:"fulfilled",id:h,data:S});}).catch(S=>{if(!y.signal.aborted){let w=S instanceof Error?S.message:String(S);i({type:"failed",id:h,error:new Error(`tile fetch failed (tile ${h}, tier ${o.id}): ${w}`)});}}).finally(()=>{u.current.delete(h);});}}},[t,r,a,o,i,s,l]),qe.useEffect(()=>p,[p]),{abortAll:p}}var Gh=1.3,O1=25e4,z1=3;function H1(e,t,r){let o=t.tileSpanMs/t.bucketMs,n=Math.max(1,Math.floor(O1/o/r));return Math.min(Math.max(1,Math.ceil(.5*e/t.tileSpanMs)),n)}function Uh(e){let{fetchTile:t,ladder:r,nativeMs:o,viewport:n,widthPx:a,maxFutureMs:i,targetPointsPerPx:s=1,concurrency:l=3,tileCostSeriesCount:c=z1,resetKey:d}=e,u=qe.useMemo(()=>({targetPointsPerPx:s,nativeMs:o}),[s,o]),[p,m]=qe.useState(()=>Vl(n.endMs-n.startMs,Math.max(1,a),r,u)),[f,g]=qe.useReducer(Bh,Fh),x=qe.useRef(n.endMs-n.startMs),b=qe.useRef(u);qe.useEffect(()=>{let z=n.endMs-n.startMs,V=Vl(z,Math.max(1,a),r,u);if(V.id===p.id){b.current=u;return}let Z=Vl(z,Math.max(1,a),r,b.current).id!==V.id,G=z/x.current;(Z||G>Gh||G<1/Gh)&&(x.current=z,b.current=u,m(V));},[n,a,r,p.id,u]);let h=n.endMs-n.startMs,y=qe.useMemo(()=>H1(h,p,c),[h,p,c]),v=qe.useMemo(()=>mn(n,p,y),[n,p,y]),S=qe.useMemo(()=>v.map(z=>hr(z.tierId,z.index)).join(","),[v]),w=qe.useRef(v);w.current=v;let N=qe.useRef(n);N.current=n;let R=qe.useRef(f);R.current=f;let{abortAll:P}=Oh({refs:v,refsKey:S,store:f,tier:p,viewport:n,fetchTile:t,dispatch:g,concurrency:l,...i!=null?{maxFutureMs:i}:{}}),E=qe.useRef(null),I=qe.useRef(false);qe.useEffect(()=>{if(!I.current){I.current=true;return}P(),E.current=null,g({type:"reset"});},[P,d]);let T=qe.useMemo(()=>w.current.map(z=>`${hr(z.tierId,z.index)}:${f.get(hr(z.tierId,z.index))?.status??"\u2205"}`).join("|"),[S,f]),D=qe.useMemo(()=>{let z=Ih({viewport:N.current,targetTier:p,ladder:r,store:R.current,overscanTiles:y,prev:E.current});return E.current=z,z},[T,p,r,y,n.startMs,n.endMs]),M=qe.useMemo(()=>w.current.some(z=>R.current.get(hr(z.tierId,z.index))?.status==="loading"),[T]),B=qe.useMemo(()=>{let z=w.current[0];return z?R.current.get(hr(z.tierId,z.index))?.status==="empty":false},[T]);return {tier:p,series:D,loading:M,atDataStart:B}}function Tp(e){let{initialViewport:t,...r}=e,[o,n]=qe.useState(t),a=Uh({...r,viewport:o}),i=qe.useCallback(l=>n(l),[]),s=qe.useCallback(l=>n(l),[]);return {viewport:o,onViewportChange:i,jumpTo:s,...a}}var G1={sm:"gap-4 px-6 py-8",md:"gap-5 px-8 py-12",lg:"gap-6 px-10 py-16"},W1={sm:"xs",md:"sm",lg:"md"},U1={sm:Tt("bodySm"),md:Tt("bodySm"),lg:Tt("bodyMd")},K1={sm:"h-10 w-10",md:"h-12 w-12",lg:"h-16 w-16"},Y1={sm:20,md:24,lg:32},J1={center:"items-center text-center [&_.empty-state-actions]:justify-center [&_.empty-state-actions]:text-center",start:"items-start text-left [&_.empty-state-actions]:justify-start [&_.empty-state-actions]:text-left"},X1={mesh:"radial-gradient(at 20% 20%, rgba(68, 74, 225, 0.06) 0px, transparent 45%), radial-gradient(at 80% 80%, rgba(68, 74, 225, 0.045) 0px, transparent 45%), radial-gradient(at 50% 50%, rgba(68, 74, 225, 0.03) 0px, transparent 50%)","top-fade":"linear-gradient(to bottom, rgba(68, 74, 225, 0.06) 0%, rgba(68, 74, 225, 0.02) 60%, transparent 100%)",center:"radial-gradient(ellipse 600px 400px at center, rgba(68, 74, 225, 0.06) 0px, transparent 60%)",corners:"radial-gradient(at 0% 0%, rgba(68, 74, 225, 0.06) 0px, transparent 40%), radial-gradient(at 100% 100%, rgba(68, 74, 225, 0.045) 0px, transparent 40%)",bottom:"radial-gradient(ellipse 700px 300px at 50% 100%, rgba(68, 74, 225, 0.06) 0px, transparent 60%)",asymmetric:"radial-gradient(at 15% 30%, rgba(68, 74, 225, 0.06) 0px, transparent 45%), radial-gradient(at 85% 70%, rgba(68, 74, 225, 0.04) 0px, transparent 50%)"};function Ol({icon:e,title:t,description:r,primaryAction:o,secondaryAction:n,actions:a,size:i="md",alignment:s="center",variant:l="default",spotlightPattern:c="mesh",fullHeight:d=false,className:u}){let p=i==="sm"?"sm":"md",m=l==="spotlight",f=m?{background:X1[c]}:void 0,g=()=>a?jsxRuntime.jsx("div",{className:"empty-state-actions mt-2 flex flex-wrap items-center gap-3",children:a}):o||n?jsxRuntime.jsxs("div",{className:"empty-state-actions mt-2 flex flex-col gap-3",children:[o&&(o.href?jsxRuntime.jsx($,{variant:"secondary",size:p,onPress:o.onPress,isDisabled:o.isDisabled,isLoading:o.isLoading,href:o.href,children:o.label}):jsxRuntime.jsx($,{variant:"secondary",size:p,onPress:o.onPress,isDisabled:o.isDisabled,isLoading:o.isLoading,children:o.label})),n&&jsxRuntime.jsx(ut,{href:n.href||"#",variant:"muted",onPress:n.onPress,className:Tt("labelMd"),children:n.label})]}):null;return jsxRuntime.jsxs("section",{"data-testid":"empty-state",role:"status","aria-live":"polite",className:tailwindMerge.twMerge("flex w-full flex-col rounded-xl text-text-primary",G1[i],J1[s],d?"h-full justify-center":"",m?"relative overflow-hidden":"",u),style:f,children:[e&&jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex items-center justify-center rounded-full border border-border-muted bg-background-muted text-text-secondary",K1[i]),children:jsxRuntime.jsx(O,{name:e,size:Y1[i]})}),jsxRuntime.jsx(lr,{size:W1[i],tag:"h2",className:"text-text-secondary",children:t}),r&&jsxRuntime.jsx("p",{className:tailwindMerge.twMerge("max-w-xs text-text-secondary whitespace-pre-line",U1[i]),children:r}),g()]})}var q1=1440*60*1e3,Q1=[{id:"5y",label:"5 years",days:5*365},{id:"year",label:"Year",days:365},{id:"month",label:"Month",days:30},{id:"week",label:"Week",days:7},{id:"day",label:"24h",days:1}],Z1=[{id:"day",days:1},{id:"week",days:7},{id:"month",days:30}];function Yh(e,t=Date.now){return Z1.map(({id:r,days:o})=>({id:r,label:e[r],getRange:()=>{let n=new Date(t());return {after:dateFns.subDays(n,o),before:n}}}))}function zl(e=Date.now){return Q1.map(({id:t,label:r,days:o})=>({id:t,label:r,getRange:()=>{let n=e();return {after:new Date(n-o*q1),before:new Date(n)}}}))}function oR({selectionState:e,isDisabled:t}){let r=`${rt} w-full h-full flex items-center justify-center rounded-sm forced-color-adjust-none font-semibold`,o={none:"text-text-primary group-hover:bg-background-muted group-pressed:bg-background-muted",middle:["bg-background-selected group-hover:bg-background-muted forced-colors:group-hover:bg-[Highlight]","group-invalid:group-hover:bg-feedback-error-background forced-colors:group-invalid:group-hover:bg-[Mark]","group-pressed:bg-background-muted forced-colors:group-pressed:bg-[Highlight] forced-colors:text-[HighlightText]","group-invalid:group-pressed:bg-feedback-error-background forced-colors:group-invalid:group-pressed:bg-[Mark]"].join(" "),cap:"bg-action-default text-[color:var(--color-action-default-text)] group-invalid:bg-feedback-error-border forced-colors:bg-[Highlight] forced-colors:group-invalid:bg-[Mark] forced-colors:text-[HighlightText]"},n=t?"text-text-disabled forced-colors:text-text-disabled font-light":"";return [r,o[e],n].filter(Boolean).join(" ")}function ti({errorMessage:e,...t}){return jsxRuntime.jsxs(reactAriaComponents.RangeCalendar,{...t,children:[jsxRuntime.jsx(gl,{}),jsxRuntime.jsxs(reactAriaComponents.CalendarGrid,{className:"w-full border-separate [border-spacing:0] [&_td]:p-0 [&_td]:!border-0",children:[jsxRuntime.jsx(bl,{}),jsxRuntime.jsx(reactAriaComponents.CalendarGridBody,{children:r=>jsxRuntime.jsx(reactAriaComponents.CalendarCell,{date:r,className:"selection-start:rounded-s-full selection-end:rounded-e-full [td:last-child_&]:rounded-e-end group h-9 w-9 cursor-default text-sm border-0 outside-month:text-text-disabled invalid:selected:bg-feedback-error-background forced-colors:selected:bg-[Highlight] forced-colors:selected:text-[HighlightText] forced-colors:invalid:selected:bg-[Mark] [td:first-child_&]:rounded-s-full [&]:border-0",children:({formattedDate:o,isSelected:n,isSelectionStart:a,isSelectionEnd:i,isFocusVisible:s,isDisabled:l})=>jsxRuntime.jsx("span",{className:oR({selectionState:n&&(a||i)?"cap":n?"middle":"none",isDisabled:l}),children:o})})})]}),e&&jsxRuntime.jsx(reactAriaComponents.Text,{slot:"errorMessage",className:"text-sm text-feedback-error-text",children:e})]})}function Xh(e){return e==="brand"?"primary":e==="default"||e==="secondary"||!e?"subtle":e}var aR={sm:"h-[var(--control-sm-height)] text-xs",md:"h-[var(--control-md-height)] text-sm",lg:"h-[var(--control-lg-height)] text-base",xl:"h-[var(--control-xl-height)] text-lg"},iR={sm:14,md:16,lg:18,xl:20},sR=({isSelected:e,isFirst:t,isLast:r,isDisabled:o,variant:n="subtle"})=>{let a=Xh(n),i=a==="primary"?"focus-visible:outline-action-primary":"focus-visible:outline-[color:var(--color-action-secondary-text)]";return a==="subtle"?tailwindMerge.twMerge(rt(),"focus-visible:outline-[color:var(--color-action-secondary-text)]","px-3 text-center transition cursor-pointer forced-color-adjust-none -ml-px first:ml-0 flex items-center justify-center h-full gap-2",e?"bg-background-muted text-text-primary font-medium forced-colors:!bg-[Highlight] forced-colors:!text-[HighlightText]":"text-text-secondary hover:bg-background-hover pressed:bg-background-hover forced-colors:!bg-[ButtonFace] forced-colors:!text-[ButtonText]",!r&&"border-r border-border-muted",o&&"bg-background-muted text-text-disabled forced-colors:!bg-[ButtonFace] forced-colors:!text-[GrayText] border-border-muted forced-colors:border-[GrayText] cursor-not-allowed"):tailwindMerge.twMerge(rt(),i,"px-3 text-center transition cursor-pointer forced-color-adjust-none -ml-px first:ml-0 flex items-center justify-center h-full gap-2",e?"bg-action-primary text-[color:var(--color-action-primary-text)] font-semibold forced-colors:!bg-[Highlight] forced-colors:!text-[HighlightText]":"text-text-secondary hover:bg-background-hover pressed:bg-background-hover forced-colors:!bg-[ButtonFace] forced-colors:!text-[ButtonText] hover:font-semibold",!r&&"border-r border-border-muted",o&&"bg-background-muted text-text-disabled forced-colors:!bg-[ButtonFace] forced-colors:!text-[GrayText] border-border-muted forced-colors:border-[GrayText] cursor-not-allowed")};function Gl({options:e,value:t,onChange:r,size:o="md",className:n,isDisabled:a,variant:i="subtle",iconOnly:s=false,"aria-label":l}){return jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("inline-flex overflow-hidden rounded-[var(--control-border-radius)]",Xh(i)==="subtle"?"border border-border-muted":"border-2 border-border-muted",aR[o],n),role:"group","aria-label":l,children:e.map((c,d)=>{let u=s&&!!c.icon;return jsxRuntime.jsxs(reactAriaComponents.ToggleButton,{isSelected:t===c.id,onChange:()=>r(c.id),className:sR({isSelected:t===c.id,isFirst:d===0,isLast:d===e.length-1,isDisabled:a,variant:i}),isDisabled:a,"aria-label":c.label,children:[c.icon&&jsxRuntime.jsx(O,{name:c.icon,size:iR[o]}),u?jsxRuntime.jsx("span",{className:"sr-only",children:c.label}):jsxRuntime.jsx("span",{className:"inline-flex flex-col items-center after:content-[attr(data-label)] after:font-semibold after:h-0 after:overflow-hidden after:invisible","data-label":c.label,children:c.label})]},c.id)})})}function uR(e){return e instanceof Date&&!Number.isNaN(e.getTime())}function Mp(e){return uR(e)?e:(console.warn("Invalid date detected in TimeControls, using fallback:",e),new Date)}var $h=120*1e3,pR=.02,ex={FIVE_MINUTES:0,FIFTEEN_MINUTES:1,HOUR:2,DAY:3,WEEK:4,MONTH:5,YEAR:6},mR=[{id:"FIFTEEN_MINUTES",label:"15m"},{id:"HOUR",label:"1h"},{id:"DAY",label:"1d"},{id:"WEEK",label:"1w"}];function Wl({dateRange:e,onDateRangeChange:t,windowSize:r,onWindowSizeChange:o,showWindowSize:n=true,showRangeSelector:a=true,allowDatePicker:i=false,lockWindowSize:s=false,showReset:l=true,restrictToSingleDay:c=false,presetRanges:d=[],windowSizeOptions:u=mR,autoAdjustWindowSize:p=false,className:m}){let[f,g]=qe.useState(0),x=qe.useRef(null),[b,h]=qe.useState(false),[y,v]=qe.useState(null),S=k=>{let L=(k.before.getTime()-k.after.getTime())/(1e3*60*60);return L<=24?"FIFTEEN_MINUTES":L<=72||L<=168?"HOUR":("DAY")};qe.useEffect(()=>{if(p&&!b&&o){let k=S(e);o(k);}},[e,p,b,o]);let w=k=>{let C;for(let L of d){let F=L.getRange(),j=(F.before.getTime()-F.after.getTime())*pR,ne=Math.abs(F.after.getTime()-k.after.getTime()),ce=Math.abs(F.before.getTime()-k.before.getTime());if(ne>j||ce>j)continue;let ee=ne+ce;(!C||ee<C.distance)&&(C={id:L.id,distance:ee});}return C?.id},N=y&&d.some(k=>k.id===y.id)&&Math.abs(y.after-e.after.getTime())<=$h&&Math.abs(y.before-e.before.getTime())<=$h?y.id:w(e),R=Mp(e.after),P=Mp(e.before),E=new Date(P.getTime()-1),I={start:date.fromDate(R,date.getLocalTimeZone()),end:date.fromDate(E,date.getLocalTimeZone())};qe.useEffect(()=>{let k=new ResizeObserver(C=>{for(let L of C)g(L.contentRect.width);});return x.current&&k.observe(x.current),()=>{x.current&&k.unobserve(x.current);}},[]);let T=[...u].sort((k,C)=>ex[k.id]-ex[C.id]),D=k=>{let C=k.toString(),L=d.find(F=>F.id===C);if(L){let F=L.getRange();v({id:C,after:F.after.getTime(),before:F.before.getTime()}),h(false),t(F,{presetId:C});}},M=k=>{if(k?.start&&k?.end){v(null);let C=new Date(k.start.year,k.start.month-1,k.start.day,0,0,0,0),L=new Date(k.end.year,k.end.month-1,k.end.day+1,0,0,0,0);t({after:C,before:L});}},B=k=>{if(k){v(null);let C=new Date(k.year,k.month-1,k.day,0,0,0,0),L=new Date(k.year,k.month-1,k.day+1,0,0,0,0);t({after:C,before:L});}},z=k=>{o&&(h(true),o(k.toString()));},V=()=>{d.length>0&&D(d[0].id);},U=k=>Mp(k).toLocaleDateString("en-US"),Z=T.map(k=>({id:k.id,label:k.label,value:k.id})),G=d.map(k=>({id:k.id,label:k.label,value:k.id})),J=s?jsxRuntime.jsx("div",{className:"flex items-center rounded-md border border-border-muted bg-background-muted px-3 py-2 text-sm text-text-secondary",children:T.find(k=>k.id===r)?.label||r}):jsxRuntime.jsx(Bo,{className:"w-full md:w-auto",selectedKey:r,onSelectionChange:z,items:Z,size:"md","aria-label":"Select Window Size",children:k=>jsxRuntime.jsx(pr,{id:k.id,"aria-label":k.label,size:"md",children:k.label},k.id)}),W=l&&!N&&d.length>0,A=c?jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsxs(reactAriaComponents.DialogTrigger,{children:[jsxRuntime.jsxs($,{className:"border-l pl-2 pr-2 hover:border-border-default hover:bg-background-muted hover:text-text-link-hover",variant:"secondary",children:[jsxRuntime.jsx(O,{name:"CalendarBlank",size:18}),jsxRuntime.jsx("span",{className:"ml-2 hidden md:block",children:U(e.after)})]}),jsxRuntime.jsx(yt,{className:"z-50 w-auto p-3",disableGroup:true,children:jsxRuntime.jsx(Ua,{"aria-label":"Select date",value:date.parseDate(R.toISOString().split("T")[0]),onChange:B})})]})}):jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsxs(reactAriaComponents.DialogTrigger,{children:[jsxRuntime.jsxs($,{className:tailwindMerge.twMerge("border-l pl-2 pr-2 hover:border-border-default hover:bg-background-muted hover:text-text-link-hover",W&&"rounded-r-none"),variant:"secondary",children:[jsxRuntime.jsx(O,{name:"CalendarBlank",size:18}),!N&&jsxRuntime.jsx("span",{className:"ml-2 hidden md:block",children:`${U(e.after)} - ${U(E)}`})]}),jsxRuntime.jsx(yt,{className:"z-50 w-auto p-3",disableGroup:true,children:jsxRuntime.jsx(ti,{"aria-label":"Date range calendar",value:I,onChange:M})})]}),W&&jsxRuntime.jsx($,{variant:"ghost",size:"md",onPress:V,children:"Reset"})]}),Y=f<600;return jsxRuntime.jsx("div",{ref:x,className:tailwindMerge.twMerge("flex w-full flex-wrap items-center justify-between gap-4",m),children:Y?jsxRuntime.jsxs("div",{className:"flex w-full justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center",children:[i&&A,a&&d.length>0&&jsxRuntime.jsx(Bo,{selectedKey:N??"",onSelectionChange:D,items:G,size:"md","aria-label":"Select Date Range",children:k=>jsxRuntime.jsx(pr,{id:k.id,size:"md",children:k.label},k.id)})]}),jsxRuntime.jsx("div",{className:"flex items-center",children:n&&r&&J})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[i&&A,a&&d.length>0&&jsxRuntime.jsx(Gl,{options:d.map(k=>({id:k.id,label:k.label})),value:N??"",onChange:D,size:"sm",variant:"secondary","aria-label":"Select Date Range"})]}),jsxRuntime.jsx("div",{className:"flex items-center",children:n&&r&&J})]})})}var xR=1440*60*1e3,yR=6e4,tx=(e,t)=>({startMs:t-e*xR,endMs:t}),vR=e=>({after:new Date(e.startMs),before:new Date(e.endMs)});function rx({source:e,title:t,initialRange:r,viewportEnd:o,yFormatter:n,yDomain:a,referenceLines:i,emptyState:s,presetRanges:l,tierToWindow:c,windowSizeOptions:d,height:u=360,hint:p,dataBounds:m,children:f}){let[g,x]=qe.useState(900),b=m?.endMs,[h,y]=qe.useState(()=>b??Date.now());qe.useEffect(()=>{if(b!=null){y(b);return}y(Date.now());let re=setInterval(()=>y(Date.now()),yR);return ()=>clearInterval(re)},[b]);let v=o?.getTime()??b,S=r?.days??30,w=qe.useMemo(()=>tx(S,v??Date.now()),[S,v]),N=h,R=qe.useMemo(()=>({startMs:m?.startMs??0,endMs:h}),[m?.startMs,h]),P=re=>{let ie=Math.min(re.endMs-re.startMs,R.endMs-R.startMs),ve=Math.max(Math.min(re.endMs,R.endMs),R.startMs+ie);return {startMs:ve-ie,endMs:ve}},[E,I]=qe.useState(null),[T,D]=qe.useState(null),M=E??w,B=Tp({fetchTile:e.fetchTile,ladder:e.ladder,nativeMs:e.nativeMs,initialViewport:w,widthPx:g,maxFutureMs:N,tileCostSeriesCount:e.tileCostSeriesCount,resetKey:e.resetKey}),z=qe.useMemo(()=>zl(()=>v??Date.now()),[v]),V=l??z,U=()=>{if(T&&"presetId"in T){let re=V.find(ie=>ie.id===T.presetId);if(re){let ie=re.getRange();return {startMs:ie.after.getTime(),endMs:ie.before.getTime()}}}return T&&"range"in T?T.range:tx(S,v??Date.now())},{line:Z,coverage:G,renderTier:J,targetTier:W,isFallback:A,isStale:Y}=B.series,k=J?J.bucketMs*1.5:0,C=re=>re==null?"\u2014":new Date(re).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),L=(re,ie)=>{let ve=ie-re<1728e5?{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}:{month:"short",day:"numeric",year:"numeric"},Xe=new Intl.DateTimeFormat("en-US",ve);return `${Xe.format(new Date(re))} \u2013 ${Xe.format(new Date(ie))}`},F=B.viewport.startMs!==M.startMs||B.viewport.endMs!==M.endMs,j=Y||B.loading&&G.earliestMs==null,ne=(B.viewport.endMs-B.viewport.startMs)*.03,ce=!j&&G.earliestMs!=null&&G.earliestMs>B.viewport.startMs+ne,ee=!B.loading&&G.earliestMs==null&&G.latestMs==null&&Z.length===0&&!Y,ae=Yn(t),Le=f({series:B.series,gapMs:k}),ge=qe.isValidElement(Le)&&Le.type===qe.Fragment?Le.props.children:Le,xe=jsxRuntime.jsxs("div",{className:`flex flex-col gap-3${ae.isExpanded?" h-full":""}`,children:[jsxRuntime.jsxs("div",{className:"flex items-start gap-2",children:[jsxRuntime.jsx(Wl,{dateRange:vR(B.viewport),onDateRangeChange:(re,ie)=>{let ve=P({startMs:re.after.getTime(),endMs:re.before.getTime()});D(ie?.presetId?{presetId:ie.presetId}:{range:ve}),I(ve),B.jumpTo(ve);},windowSize:c[W.id],windowSizeOptions:d,lockWindowSize:true,presetRanges:V,allowDatePicker:true,showReset:false}),!ae.isExpanded&&!ee&&ae.action]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-text-secondary",children:[jsxRuntime.jsxs("span",{children:["Window"," ",jsxRuntime.jsx("span",{className:"font-medium text-text-primary",children:L(B.viewport.startMs,B.viewport.endMs)})]}),jsxRuntime.jsx("span",{className:"text-text-tertiary",children:"\u2022"}),jsxRuntime.jsxs("span",{children:["Resolution ",jsxRuntime.jsx("span",{className:"font-medium text-text-primary",children:J?.id??W.id}),A&&jsxRuntime.jsxs("span",{className:"text-text-tertiary",children:[" \xB7 loading ",W.id]})]}),B.loading&&jsxRuntime.jsx("span",{className:"text-text-tertiary",children:"loading\u2026"}),ce&&jsxRuntime.jsxs("span",{className:"text-text-tertiary",children:["showing available history from ",C(G.earliestMs)]}),!ce&&!j&&B.atDataStart&&jsxRuntime.jsx("span",{className:"text-text-tertiary",children:"no earlier data loaded"}),F&&jsxRuntime.jsx($,{variant:"ghost",size:"sm",onPress:()=>{let re=P(U());I(re),B.jumpTo(re);},children:"\u27F2 Reset"})]}),jsxRuntime.jsx("div",{className:`relative overflow-hidden rounded-md border border-border-subtle${ae.isExpanded?" min-h-0 flex-1":""}`,style:ae.isExpanded?void 0:{height:u},children:ee?jsxRuntime.jsx(Ol,{title:s.title,description:s.description}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Bl,{title:t,viewport:B.viewport,panBounds:R,onViewportChange:B.onViewportChange,onPlotWidthChange:x,...n&&{yFormatter:n},...a&&{yDomain:a},...i&&{referenceLines:i},children:ge}),B.loading&&jsxRuntime.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 animate-pulse bg-[var(--color-viz-categorical-1)] opacity-60"})]})}),p&&jsxRuntime.jsx("p",{className:"text-xs text-text-tertiary",children:p})]});return jsxRuntime.jsx(mp,{children:ae.present(xe)})}function Zi({count:e,label:t="results",isLoading:r=false,className:o=""}){if(r)return jsxRuntime.jsx("div",{className:`flex items-center ${o}`,children:jsxRuntime.jsx(X,{width:80,height:16})});let n=t.endsWith("s")?t.slice(0,-1):t,a=e===1?n:t;return jsxRuntime.jsxs("div",{className:`text-sm text-text-secondary whitespace-nowrap ${o}`,children:[e.toLocaleString()," ",a]})}var TR=e=>{let t=zt({isInvalid:e.isInvalid,isDisabled:e.isDisabled,isFocused:e.isFocused,transparent:e.transparent,size:e.size}),r=[e.showSearchIcon?"":"pl-3",e.isClearable&&e.hasValue||e.isPassword?"pr-8":"pr-3"].join(" ");return tailwindMerge.twMerge(t,r,e.className)};function qr({label:e,description:t,errorMessage:r,size:o="md",tooltip:n,isRequired:a,transparent:i,showSearchIcon:s,isClearable:l,onClear:c,type:d,validationResult:u,reserveErrorSpace:p=true,isLoading:m=false,descriptionPlacement:f="below",...g}){let[x,b]=qe__namespace.default.useState(false),{isFocused:h,handleFocus:y,handleBlur:v}=ur(),S=d==="password",w=al(m,300);return jsxRuntime.jsx(reactAriaComponents.TextField,{...g,isRequired:a,className:Me(g.className,"group flex flex-col"),children:({isDisabled:N,isInvalid:R})=>jsxRuntime.jsxs("div",{className:"flex flex-col",children:[e&&jsxRuntime.jsx(Ke,{size:o,tooltip:n,description:f==="tooltip"||f==="inline"?t:void 0,descriptionPlacement:f,isRequired:a,children:e}),jsxRuntime.jsxs(Ct,{children:[s&&jsxRuntime.jsx("div",{className:"pointer-events-none absolute top-1/2 -translate-y-1/2 transform flex items-center z-10",style:{left:9},children:(()=>{let P={sm:14,md:16,lg:18,xl:20}[o];return w?jsxRuntime.jsx(Wr,{size:P,color:"text-text-secondary"}):jsxRuntime.jsx(O,{name:"MagnifyingGlass",size:P,className:`transition-colors ${h?"text-action-brand":"text-text-secondary"}`})})()}),jsxRuntime.jsx(sl,{size:o,disabled:N,type:S?x?"text":"password":d,name:g.name,autoComplete:g.autoComplete,value:g.value,defaultValue:g.defaultValue,placeholder:g.placeholder,onFocus:P=>y(P,g.onFocus),onBlur:P=>v(P,g.onBlur),onChange:P=>g.onChange?.(P.target.value),style:s?{paddingLeft:{sm:28,md:32,lg:36,xl:37}[o]}:void 0,className:TR({isInvalid:R,isDisabled:N,isFocused:h,size:o,transparent:i,showSearchIcon:s,isClearable:l,hasValue:!!g.value,isPassword:S,className:typeof g.className=="string"?g.className:void 0})}),l&&g.value&&!N&&jsxRuntime.jsx(Ii,{onClick:()=>{c?c():g.onChange&&g.onChange("");},size:o}),S&&!N&&jsxRuntime.jsx("button",{type:"button",onClick:()=>b(!x),className:"absolute right-3 top-1/2 -translate-y-1/2 transform text-text-secondary hover:text-text-primary","aria-label":x?"Hide password":"Show password",onMouseDown:P=>{P.preventDefault(),P.stopPropagation();},children:jsxRuntime.jsx(O,{name:x?"EyeSlash":"Eye",size:o==="sm"?16:20,className:"text-text-primary"})})]}),p?jsxRuntime.jsx("div",{className:"mt-1 min-h-[20px]",children:typeof r=="string"?jsxRuntime.jsx(he,{size:o,children:r}):typeof r=="function"&&u?jsxRuntime.jsx(he,{size:o,children:r(u)}):t&&f==="below"?jsxRuntime.jsx(Ne,{size:o,children:t}):null}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:typeof r=="string"?jsxRuntime.jsx(he,{size:o,className:"mt-1",children:r}):typeof r=="function"&&u?jsxRuntime.jsx(he,{size:o,className:"mt-1",children:r(u)}):t&&f==="below"?jsxRuntime.jsx(Ne,{size:o,className:"mt-1",children:t}):null})]})})}function Zn({value:e,onChange:t,onClear:r,placeholder:o="Search...",size:n="sm",className:a="",isLoading:i=false}){return jsxRuntime.jsx("div",{className:`flex-1 min-w-0 sm:max-w-sm ${a}`,children:jsxRuntime.jsx(qr,{value:e,onChange:t,placeholder:o,showSearchIcon:true,isClearable:!!e&&!!r,onClear:r,size:n,"aria-label":o,reserveErrorSpace:false,isLoading:i})})}function _i({value:e,options:t,onChange:r,direction:o,onDirectionChange:n,showLabel:a=true,size:i="sm",className:s="",compact:l=false}){let[c,d]=qe.useState(false),u=o!==void 0&&n!==void 0,p=t.find(m=>m.value===e);return l?jsxRuntime.jsxs("div",{className:`flex items-center gap-2 ${s}`,children:[jsxRuntime.jsx($,{variant:"secondary",size:i,icon:"ArrowsDownUp","aria-label":`Sort by: ${p?.label||"Select"}`,onPress:()=>d(true)}),jsxRuntime.jsx(vt,{isOpen:c,onClose:()=>d(false),title:"Sort by",contentPadding:false,children:jsxRuntime.jsx(reactAriaComponents.ListBox,{items:t.map(m=>({id:m.value,label:m.label,value:m.value})),className:"w-full bg-background-surface p-0 outline-0 [&_[role=option]]:border-b [&_[role=option]]:border-border-default [&_[role=option]:last-child]:border-0 [&_[role=option]]:!px-6 [&_[role=option]]:!py-4 [&_[role=option]]:rounded-none",selectionMode:"single",selectedKeys:e?[e]:[],onSelectionChange:m=>{let f=Array.from(m)[0];f!=null&&(r(f),d(false));},children:m=>jsxRuntime.jsx(pr,{id:m.id,textValue:m.label,children:jsxRuntime.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap min-w-0 flex-1",children:m.label})},m.id)})})]}):jsxRuntime.jsxs("div",{className:`flex items-center gap-2 ${s}`,children:[a&&jsxRuntime.jsx("span",{className:"text-sm text-text-secondary whitespace-nowrap",children:"Sort by:"}),jsxRuntime.jsx(Bo,{selectedKey:e,onSelectionChange:m=>r(m),size:i,className:"min-w-32",items:t.map(m=>({id:m.value,label:m.label,value:m.value})),renderItem:m=>m.label,"aria-label":"Sort by",reserveErrorSpace:false}),u&&jsxRuntime.jsx($,{variant:"ghost",size:i,onClick:()=>n(o==="asc"?"desc":"asc"),"aria-label":`Sort ${o==="asc"?"descending":"ascending"}`,className:"p-1.5",children:o==="asc"?jsxRuntime.jsx(lucideReact.ArrowUp,{className:"w-4 h-4"}):jsxRuntime.jsx(lucideReact.ArrowDown,{className:"w-4 h-4"})})]})}function sx({search:e,searchMobileMode:t="expanded",filters:r=[],onRemoveFilter:o,onClearAllFilters:n,onManageFilters:a,exportControl:i,maxVisibleFilterChips:s=3,sort:l,resultsCount:c,leftControls:d,onManageColumns:u,columnPicker:p,customControls:m,actions:f,interactionMode:g="auto",sticky:x,stickyTop:b="0",zIndex:h=10,className:y="",style:v}){let S=r.length>0;if(!(e||S||a||l||c||d||u||p||m||f||i))return null;let N=x?"sticky bg-background-surface":"",R=x?{top:b,zIndex:h}:{};return jsxRuntime.jsxs("div",{className:`@container flex flex-col gap-3 bg-background-surface py-3 border-b border-border-default ${N} ${y}`,style:{...v,...R},children:[jsxRuntime.jsxs("div",{className:"hidden @[640px]:flex @[640px]:items-center @[640px]:justify-between @[640px]:gap-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[d,d&&c&&jsxRuntime.jsx("div",{className:"h-4 w-px bg-border-default"}),c&&jsxRuntime.jsx(Zi,{count:c.count,label:c.label,isLoading:c.isLoading}),c&&l&&jsxRuntime.jsx("div",{className:"h-4 w-px bg-border-default"}),l&&jsxRuntime.jsx(_i,{value:l.value,options:l.options,onChange:l.onChange,showLabel:l.showLabel,direction:l.direction,onDirectionChange:l.onDirectionChange}),u?jsxRuntime.jsx($,{variant:"secondary",size:"sm",icon:"Columns",onClick:u,children:"Columns"}):p,S&&o&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r.slice(0,s).map(P=>jsxRuntime.jsxs(Yr,{variant:"primary",size:"sm",onRemove:()=>o(P.id),isRemovable:true,children:[P.label,": ",P.value]},P.id)),r.length>s&&a&&jsxRuntime.jsxs($,{variant:"ghost",size:"sm",onClick:a,className:"text-text-secondary hover:text-text-primary whitespace-nowrap",children:["+",r.length-s," more"]}),n&&jsxRuntime.jsx($,{variant:"ghost",size:"sm",onClick:n,className:"text-text-secondary hover:text-text-primary whitespace-nowrap",children:"Clear all"})]})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-3 flex-shrink-0",children:m||jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[f&&f.items.length>0&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:f.items.map(P=>jsxRuntime.jsx($,{variant:P.variant||"secondary",size:"sm",icon:P.icon,onPress:P.onClick,isDisabled:P.disabled,children:P.label},P.id))}),e&&jsxRuntime.jsx("div",{className:"w-64",children:jsxRuntime.jsx(Zn,{value:e.value,onChange:e.onChange,onClear:e.onClear,placeholder:e.placeholder,isLoading:e.isLoading})}),a&&jsxRuntime.jsx($,{variant:"secondary",size:"sm",icon:"Sliders",badgeNumber:r.length>0?r.length:void 0,onClick:a,children:"Filters"}),i&&jsxRuntime.jsx($,{variant:"secondary",size:"sm",icon:"Upload",onClick:i.onClick,isDisabled:i.isDisabled,children:i.label})]})})]}),jsxRuntime.jsxs("div",{className:"@[640px]:hidden",children:[jsxRuntime.jsx("div",{className:"flex flex-col gap-3 mb-3",children:jsxRuntime.jsx("div",{className:"flex items-center gap-3",children:m?jsxRuntime.jsx("div",{className:"flex-1",children:m}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[f&&f.items.length>0&&jsxRuntime.jsx(Oa,{items:f.items.map(P=>({id:P.id,name:P.label,iconName:P.icon,variant:P.variant==="destructive"?"destructive":"primary",disabled:P.disabled,onAction:P.onClick})),align:"left",size:"sm",children:jsxRuntime.jsx($,{variant:"secondary",size:"sm",icon:"DotsThreeVertical","aria-label":f.menuLabel||"Actions"})}),e&&jsxRuntime.jsx("div",{className:"flex-1",children:jsxRuntime.jsx(Zn,{value:e.value,onChange:e.onChange,onClear:e.onClear,placeholder:e.placeholder,isLoading:e.isLoading})}),a&&jsxRuntime.jsx($,{variant:"secondary",size:"sm",icon:"Sliders",badgeNumber:r.length>0?r.length:void 0,onClick:a,"aria-label":`Filters${r.length>0?` (${r.length} active)`:""}`}),i&&jsxRuntime.jsx($,{variant:"secondary",size:"sm",icon:"Upload",onClick:i.onClick,isDisabled:i.isDisabled,children:i.label})]})})}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[d,c&&jsxRuntime.jsx(Zi,{count:c.count,label:c.label,isLoading:c.isLoading})]}),jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:l&&jsxRuntime.jsx(_i,{value:l.value,options:l.options,onChange:l.onChange,showLabel:false,direction:l.direction,onDirectionChange:l.onDirectionChange,compact:g!=="desktop"})})]})]})]})}function lx({filters:e,onRemove:t,onClearAll:r,onManageFilters:o,maxVisibleChips:n=3,mode:a="chips",showManageButton:i=true,size:s="sm",className:l=""}){let c=e.length>0,d=e.slice(0,n),u=Math.max(0,e.length-n),p=u>0,m=a==="button"&&!!o,f=a==="chips"&&i&&!!o;if(!c&&!m&&!f)return null;let g=m&&jsxRuntime.jsxs($,{variant:"secondary",size:s,onClick:o,className:"whitespace-nowrap",children:[e.length," ",e.length===1?"filter":"filters"]}),x=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[f&&jsxRuntime.jsx($,{variant:"secondary",size:s,icon:"Sliders",onClick:o,className:"whitespace-nowrap",children:"Filters"}),c&&d.map(h=>jsxRuntime.jsxs(Yr,{variant:"secondary",size:s,onRemove:()=>t(h.id),isRemovable:true,children:[h.label,": ",h.value]},h.id)),c&&p&&o&&jsxRuntime.jsxs($,{variant:"ghost",size:s,onClick:o,className:"text-text-secondary hover:text-text-primary whitespace-nowrap",children:["+",u," more"]}),c&&r&&jsxRuntime.jsx($,{variant:"ghost",size:s,onClick:r,className:"text-text-secondary hover:text-text-primary whitespace-nowrap",children:"Clear all"})]}),b=a==="button"?g:x;return jsxRuntime.jsx("div",{className:`flex flex-wrap items-center gap-2 ${l}`,children:b})}var cx=["isEmpty","isNotEmpty"];function dx(e){return cx.includes(e)}var ux={isEmpty:"is empty",isNotEmpty:"is not empty"};function AR(e,t,r){return {field:e,operator:t,value:r}}function IR(e,t="AND"){return {logic:t,conditions:e}}function $i(){return {logic:"AND",conditions:[]}}function Jl(e){return !e||e.conditions.length===0?true:e.conditions.every(t=>"conditions"in t?Jl(t):false)}function FR(e,t){if(!e)return [];let r=new Map(t?.map(i=>[i.field,i])),o=new Map;function n(i){if("conditions"in i)i.conditions.forEach(s=>n(s));else {let s=o.get(i.field)||[];s.push(i),o.set(i.field,s);}}e.conditions.forEach(i=>n(i));let a=[];for(let[i,s]of o.entries()){let l=r.get(i),c=l?.label||i,d=[],u=[],p=[];for(let m of s)m.operator==="in"&&Array.isArray(m.value)?d.push(...m.value):m.operator==="eq"?m.value!==void 0&&typeof m.value!="boolean"&&!Array.isArray(m.value)?d.push(m.value):p.push(m):["gte","gt","lte","lt"].includes(m.operator)&&m.value!==void 0?u.push({operator:m.operator,value:typeof m.value=="boolean"||Array.isArray(m.value)?String(m.value):m.value}):p.push(m);if(d.length>0){let f=Array.from(new Set(d)).map(g=>l?.values?.find(b=>String(b.value)===String(g))?.label??g);a.push({id:`${i}-in`,label:c,value:f.join(", ")});}if(u.length>0){let m=u.find(g=>g.operator==="gte"||g.operator==="gt"),f=u.find(g=>g.operator==="lte"||g.operator==="lt");if(m&&f){let g=m.operator==="gte"?"\u2265":">",x=f.operator==="lte"?"\u2264":"<";a.push({id:`${i}-range`,label:c,value:`${g} ${m.value} and ${x} ${f.value}`});}else for(let g of u){let x;g.operator==="gte"?x="\u2265":g.operator==="gt"?x=">":g.operator==="lte"?x="\u2264":x="<",a.push({id:`${i}-${g.operator}`,label:c,value:`${x} ${g.value}`});}}for(let m of p){let f;m.operator==="neq"?f=`\u2260 ${m.value}`:m.operator==="contains"?f=`contains "${m.value}"`:m.operator==="startsWith"?f=`starts with "${m.value}"`:m.operator==="endsWith"?f=`ends with "${m.value}"`:dx(m.operator)?f=ux[m.operator]:f=String(m.value),a.push({id:`${i}-${m.operator}`,label:c,value:f});}}return a}function hn(e,t){let r=e||$i();return {...r,conditions:[...r.conditions,t]}}function _n(e,t){if(!e)return $i();let r=e.conditions.filter(o=>"conditions"in o?_n(o,t).conditions.length>0:o.field!==t);return {...e,conditions:r}}function $n(e){if(!e)return [];let t=new Set;function r(o){"conditions"in o?o.conditions.forEach(r):t.add(o.field);}return e.conditions.forEach(r),Array.from(t)}function mx({label:e,description:t,errorMessage:r,size:o="md",tooltip:n,isRequired:a,isDisabled:i,isInvalid:s,showCalendar:l=true,reserveErrorSpace:c=true,validationResult:d,className:u,...p}){let[m,f]=qe.useState(false),g=x=>{p.onChange&&x&&p.onChange(x),f(false);};return jsxRuntime.jsxs(reactAriaComponents.DateField,{...p,isDisabled:i,isRequired:a,isInvalid:s,className:Me(u,"flex flex-col gap-1"),children:[e&&jsxRuntime.jsx(Ke,{size:o,tooltip:n,isRequired:a,children:e}),jsxRuntime.jsx(Ct,{children:jsxRuntime.jsxs("div",{className:"relative w-full",children:[jsxRuntime.jsx(es,{size:o,isDisabled:i,isInvalid:s,hasCalendar:l}),l&&!i&&jsxRuntime.jsxs(reactAriaComponents.DialogTrigger,{isOpen:m,onOpenChange:f,children:[jsxRuntime.jsx($,{variant:"unstyled",className:"absolute right-2 top-1/2 -translate-y-1/2 flex h-8 w-8 items-center justify-center rounded hover:bg-background-hover text-text-secondary hover:text-text-primary transition-colors","aria-label":"Open calendar",children:jsxRuntime.jsx(O,{name:"Calendar",size:18})}),jsxRuntime.jsx(reactAriaComponents.Popover,{className:"bg-background-surface rounded-lg border border-border-default shadow-xl",children:jsxRuntime.jsx(reactAriaComponents.Dialog,{className:"p-4 outline-none",children:jsxRuntime.jsx(Ua,{value:p.value,onChange:g,minValue:p.minValue,maxValue:p.maxValue,isDisabled:i,isReadOnly:p.isReadOnly,isDateUnavailable:p.isDateUnavailable})})})]})]})}),c?jsxRuntime.jsx("div",{className:"mt-1 min-h-[20px]",children:typeof r=="string"?jsxRuntime.jsx(he,{size:o,children:r}):typeof r=="function"&&d?jsxRuntime.jsx(he,{size:o,children:r(d)}):t?jsxRuntime.jsx(Ne,{size:o,children:t}):null}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:typeof r=="string"?jsxRuntime.jsx(he,{size:o,className:"mt-1",children:r}):typeof r=="function"&&d?jsxRuntime.jsx(he,{size:o,className:"mt-1",children:r(d)}):t?jsxRuntime.jsx(Ne,{size:o,className:"mt-1",children:t}):null})]})}function UR({isPlaceholder:e,isDisabled:t,size:r="md"}){return tailwindMerge.twMerge("inline-block box-content px-0.5 rounded outline-none tabular-nums text-center transition-colors",{sm:"text-base md:text-xs",md:"text-base md:text-sm",lg:"text-base",xl:"text-lg"}[r],e?"text-text-disabled italic":"text-text-primary",t?"text-text-disabled cursor-not-allowed":"cursor-text",!t&&"hover:bg-background-hover","data-[focused]:bg-background-selected data-[focused]:text-text-primary")}function es({size:e="md",isDisabled:t,isInvalid:r,hasCalendar:o,className:n,...a}){return jsxRuntime.jsx(reactAriaComponents.DateInput,{className:tailwindMerge.twMerge(rn({isInvalid:r,isDisabled:t}),"px-3 py-2 flex items-center gap-0.5 w-full",o&&"pr-10",n),...a,children:i=>jsxRuntime.jsx(reactAriaComponents.DateSegment,{segment:i,className:UR({isPlaceholder:i.isPlaceholder,isDisabled:!i.isEditable||t,size:e})})})}function Xl({label:e,description:t,errorMessage:r,...o}){return jsxRuntime.jsxs(reactAriaComponents.DateRangePicker,{...o,className:Me(o.className,"group flex flex-col gap-1"),children:[e&&jsxRuntime.jsx(Ke,{children:e}),jsxRuntime.jsxs(zg,{className:"w-auto min-w-[208px]",children:[jsxRuntime.jsx(es,{slot:"start",className:"px-2 py-1.5 text-sm"}),jsxRuntime.jsx("span",{"aria-hidden":"true",className:"text-text-primary group-disabled:text-text-disabled forced-colors:text-[ButtonText] group-disabled:forced-colors:text-[GrayText]",children:"\u2013"}),jsxRuntime.jsx(es,{slot:"end",className:"flex-1 px-2 py-1.5 text-sm"}),jsxRuntime.jsx($,{variant:"icon",className:"mr-1 w-6 rounded outline-offset-0",children:jsxRuntime.jsx(lucideReact.CalendarIcon,{"aria-hidden":true,className:"h-4 w-4"})})]}),t&&jsxRuntime.jsx(Ne,{children:t}),typeof r=="string"?jsxRuntime.jsx(he,{children:r}):null,jsxRuntime.jsx(yt,{children:jsxRuntime.jsx(ti,{})})]})}var _R=e=>{let t=zt({isInvalid:e.isInvalid,isDisabled:e.isDisabled,isFocused:e.isFocused,transparent:e.transparent,size:e.size});return tailwindMerge.twMerge(t,"pr-9","[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",e.className)};function ts({label:e,description:t,errorMessage:r,size:o="md",tooltip:n,isRequired:a,transparent:i,validationResult:s,reserveErrorSpace:l=true,descriptionPlacement:c="below",...d}){let u=qe.useId(),{isFocused:p,handleFocus:m,handleBlur:f}=ur();return jsxRuntime.jsx(reactAriaComponents.NumberField,{...d,id:u,isRequired:a,className:Me(d.className,"group flex flex-col gap-1"),step:d.step??1,onChange:g=>{typeof g=="number"&&(d.maxValue!=null&&g>d.maxValue?d.onChange?.(d.maxValue):d.minValue!=null&&g<d.minValue?d.onChange?.(d.minValue):d.onChange?.(g));},isInvalid:!!r||typeof d.value=="number"&&(d.maxValue!=null&&d.value>d.maxValue||d.minValue!=null&&d.value<d.minValue),children:({isDisabled:g,isInvalid:x})=>jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[e&&jsxRuntime.jsx(Ke,{size:o,tooltip:n,description:c==="tooltip"||c==="inline"?t:void 0,descriptionPlacement:c,isRequired:a,htmlFor:u,children:e}),jsxRuntime.jsx("div",{className:"relative",children:jsxRuntime.jsxs(reactAriaComponents.Group,{className:"relative",children:[jsxRuntime.jsx(reactAriaComponents.Input,{onFocus:h=>m(h,d.onFocus),onBlur:h=>f(h,d.onBlur),className:_R({isInvalid:x||!!r,isDisabled:g,isFocused:p,transparent:i,size:o,className:typeof d.className=="string"?d.className:void 0})}),jsxRuntime.jsxs("div",{className:"absolute inset-y-[2px] right-[2px] flex flex-col divide-y divide-border-default border-l border-border-default overflow-hidden rounded-r-[calc(var(--control-border-radius)-2px)]",children:[jsxRuntime.jsx(reactAriaComponents.Button,{slot:"increment",isDisabled:g,className:"flex h-1/2 w-7 items-center justify-center bg-background-input hover:bg-background-input-hover active:bg-background-input-active disabled:cursor-not-allowed disabled:opacity-50",children:jsxRuntime.jsx(O,{name:"CaretUp",size:14})}),jsxRuntime.jsx(reactAriaComponents.Button,{slot:"decrement",isDisabled:g,className:"flex h-1/2 w-7 items-center justify-center bg-background-input hover:bg-background-input-hover active:bg-background-input-active disabled:cursor-not-allowed disabled:opacity-50",children:jsxRuntime.jsx(O,{name:"CaretDown",size:14})})]})]})}),l?jsxRuntime.jsx("div",{className:"mt-1 min-h-[20px]",children:r?jsxRuntime.jsx(he,{size:o,children:typeof r=="function"?r(s):r}):t&&c==="below"?jsxRuntime.jsx(Ne,{size:o,children:t}):null}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:r?jsxRuntime.jsx(he,{size:o,className:"mt-1",children:typeof r=="function"?r(s):r}):t&&c==="below"?jsxRuntime.jsx(Ne,{size:o,className:"mt-1",children:t}):null})]})})}var Bp={sm:{track:"h-4 w-7",handle:"h-3.5 w-3.5",text:"text-xs"},md:{track:"h-5 w-9",handle:"h-4 w-4",text:"text-sm"},lg:{track:"h-6 w-11",handle:"h-5 w-5",text:"text-base"},xl:{track:"h-7 w-14",handle:"h-6 w-6",text:"text-lg"}};function t2({isSelected:e,isDisabled:t,size:r="md"}){let o="flex px-px items-center shrink-0 cursor-default rounded-full transition duration-200 ease-in-out shadow-inner border border-transparent",n=Bp[r].track,a=rt,i="focus-visible:outline-action-primary",s="";return e?s="bg-action-primary forced-colors:!bg-[Highlight] group-pressed:bg-action-primary-hover":s="bg-border-input group-pressed:bg-border-focus",[o,n,a,i,s,t?"bg-background-muted forced-colors:group-selected:!bg-[GrayText] forced-colors:border-[GrayText]":""].filter(Boolean).join(" ")}function r2({isSelected:e,isDisabled:t,size:r="md"}){let o="transform rounded-full bg-background-surface outline-none shadow transition duration-200 ease-in-out",n=Bp[r].handle;return [o,n,e?"translate-x-[100%]":"translate-x-0",t?"forced-colors:outline-[GrayText]":""].filter(Boolean).join(" ")}function jl({children:e,variant:t="primary",size:r="md",...o}){return jsxRuntime.jsx(reactAriaComponents.Switch,{...o,className:Me(o.className,`relative group flex items-center gap-2 ${Bp[r].text} text-text-primary transition disabled:text-text-disabled forced-colors:disabled:text-[GrayText]`),children:n=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:t2({...n,size:r}),children:jsxRuntime.jsx("span",{className:r2({...n,size:r})})}),e]})})}function bx(e){return new Intl.NumberFormat("en-US").format(e)}function hx({isOpen:e,onClose:t,facetConfigs:r,facetCounts:o={},currentFilters:n,onApply:a,onClear:i,title:s="Filters",resultCount:l}){let[c,d]=qe.useState(n),[u,p]=qe.useState({}),[m,f]=qe.useState({}),[g,x]=qe.useState(null),{isMobile:b}=ar(),h=qe.useMemo(()=>r.some(C=>C.group),[r]),{groups:y,ungroupedFacets:v,facetsByGroup:S}=qe.useMemo(()=>{let C=new Set,L=[],F={};for(let j of r)j.group?(C.has(j.group)||(C.add(j.group),F[j.group]=[]),F[j.group].push(j)):L.push(j);return {groups:Array.from(C),ungroupedFacets:L,facetsByGroup:F}},[r]);qe.useEffect(()=>{e&&(d(n),p({}),f({}),x(!b&&y.length>0?y[0]:null));},[e,n,y,b]);let w=qe.useMemo(()=>!c||Jl(c)?0:$n(c).length,[c]),N=()=>{a(c),t();},R=()=>{let C=$i();d(C),i?i():a(C),t();},P=C=>{if(!c)return [];if(!$n(c).includes(C))return [];let F=[];function j(ne){if(ne)for(let ce of ne.conditions)"conditions"in ce?j(ce):ce.field===C&&ce.operator==="in"&&Array.isArray(ce.value)&&F.push(...ce.value.map(String));}return j(c),F},E=(C,L,F)=>{let j=_n(c,C);L!==void 0&&(j=hn(j,{field:C,operator:"gte",value:L})),F!==void 0&&(j=hn(j,{field:C,operator:"lte",value:F})),d(j);},I=C=>{if(!c)return;let L;function F(j){if(j)for(let ne of j.conditions)"conditions"in ne?F(ne):ne.field===C&&ne.operator==="eq"&&typeof ne.value=="boolean"&&(L=ne.value);}return F(c),L},T=(C,L)=>{let F=_n(c,C);L!==void 0&&(F=hn(F,{field:C,operator:"eq",value:L})),d(F);},D=(C,L,F)=>{let j=_n(c,C);L&&(j=hn(j,{field:C,operator:"gte",value:L.toString()})),F&&(j=hn(j,{field:C,operator:"lte",value:F.toString()})),d(j);},M=C=>{let L=S[C]||[],F=c?$n(c):[];return L.filter(j=>F.includes(j.field)).length},B="pr-9 bg-background-muted/50",z="border-t border-border-muted",V="text-sm font-medium text-text-link-default",U=C=>jsxRuntime.jsx("span",{className:V,children:C}),Z=C=>{let L=o[C.field]||{},F=u[C.field]||"",j=[];C.values?j=C.values.map(ee=>({value:String(ee.value),label:ee.label,count:L[String(ee.value)]})):j=Object.entries(L).map(([ee,ae])=>({value:ee,label:ee,count:ae}));let ne=j.length;if(F){let ee=F.toLowerCase();j=j.filter(ae=>ae.label.toLowerCase().includes(ee));}j.sort((ee,ae)=>ee.count!==void 0&&ae.count!==void 0&&ae.count!==ee.count?ae.count-ee.count:ee.label.localeCompare(ae.label));let ce=C.type||"string";if(ce==="string"||!C.type){let ee=P(C.field),ae=C.searchThreshold??10,Le=C.maxVisibleOptions??50,ge=m[C.field]??false,xe=ge||j.length<=Le?j:j.slice(0,Le),re=j.length>Le&&!ge;return jsxRuntime.jsxs(ln,{id:C.field,children:[jsxRuntime.jsx(cn,{title:C.label,description:C.description,className:B,endContent:ee.length>0?U(`${ee.length} selected`):void 0}),jsxRuntime.jsx(dn,{className:z,children:jsxRuntime.jsxs("div",{className:"space-y-4 pt-4 pb-4",children:[ne>ae&&jsxRuntime.jsx(Zn,{value:F,onChange:ie=>p(ve=>({...ve,[C.field]:ie})),onClear:()=>p(ie=>({...ie,[C.field]:""})),placeholder:`Search ${C.label.toLowerCase()}...`,size:"sm",className:"w-full !max-w-none pr-4"}),jsxRuntime.jsx(Ku,{value:ee,onChange:ie=>{let ve=_n(c,C.field);ie.length>0&&(ve=hn(ve,{field:C.field,operator:"in",value:ie})),d(ve);},children:jsxRuntime.jsx("div",{className:"space-y-1.5",children:xe.map(ie=>jsxRuntime.jsx("div",{className:"rounded-md py-2 pr-4 transition-colors hover:bg-background-hover",children:jsxRuntime.jsx(eo,{value:ie.value,children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-3 flex-1",children:[C.renderLabel?C.renderLabel(ie.value,ie.label):jsxRuntime.jsx("span",{className:"text-sm font-medium text-text-primary",children:ie.label}),ie.count!==void 0&&jsxRuntime.jsx("span",{className:"text-xs font-medium text-text-secondary tabular-nums",children:bx(ie.count)})]})})},ie.value))})}),re&&jsxRuntime.jsx("div",{className:"pt-2 border-t border-border-muted",children:jsxRuntime.jsxs($,{variant:"ghost",size:"sm",onPress:()=>f(ie=>({...ie,[C.field]:true})),className:"w-full",children:["Show all ",j.length," options"]})}),ge&&j.length>Le&&jsxRuntime.jsx("div",{className:"pt-2 border-t border-border-muted",children:jsxRuntime.jsx($,{variant:"ghost",size:"sm",onPress:()=>f(ie=>({...ie,[C.field]:false})),className:"w-full",children:"Show less"})})]})})]},C.field)}if(ce==="number"){let ee,ae,Le=xe=>{if(xe)for(let re of xe.conditions)"conditions"in re?Le(re):re.field===C.field&&(re.operator==="gte"&&typeof re.value=="number"&&(ee=re.value),re.operator==="lte"&&typeof re.value=="number"&&(ae=re.value));};Le(c);let ge=ee!==void 0||ae!==void 0;return jsxRuntime.jsxs(ln,{id:C.field,children:[jsxRuntime.jsx(cn,{title:C.label,description:C.description,className:B,endContent:ge?U(ee!==void 0&&ae!==void 0?`${ee} - ${ae}`:ee!==void 0?`\u2265 ${ee}`:`\u2264 ${ae}`):void 0}),jsxRuntime.jsx(dn,{className:z,children:jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-4 pt-4 pb-4",children:[jsxRuntime.jsx(ts,{label:"Min",value:ee,onChange:xe=>E(C.field,xe,ae)},`${C.field}-min`),jsxRuntime.jsx(ts,{label:"Max",value:ae,onChange:xe=>E(C.field,ee,xe)},`${C.field}-max`)]})})]},C.field)}if(ce==="boolean"){let ee=I(C.field);return jsxRuntime.jsxs(ln,{id:C.field,children:[jsxRuntime.jsx(cn,{title:C.label,description:C.description,className:B,endContent:ee!==void 0?U(ee?"Yes":"No"):void 0}),jsxRuntime.jsx(dn,{className:z,children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between pt-4 pb-4",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-text-primary",children:ee!==void 0?ee?"Enabled":"Disabled":"No filter applied"}),jsxRuntime.jsx(jl,{size:"lg",isSelected:ee??false,onChange:ae=>T(C.field,ae?true:void 0),children:ee?"Yes":"No"})]})})]},C.field)}if(ce==="date"){let ee,ae,Le=ve=>{if(ve)for(let Xe of ve.conditions)"conditions"in Xe?Le(Xe):Xe.field===C.field&&(Xe.operator==="gte"&&(ee=String(Xe.value)),Xe.operator==="lte"&&(ae=String(Xe.value)));};Le(c);let ge=ee!==void 0||ae!==void 0,xe=ve=>{if(ve)try{return /^\d{4}-\d{2}-\d{2}$/.test(ve)?date.parseDate(ve):void 0}catch{return}},re=xe(ee),ie=xe(ae);return jsxRuntime.jsxs(ln,{id:C.field,children:[jsxRuntime.jsx(cn,{title:C.label,description:C.description,className:B,endContent:ge?U("Date range selected"):void 0}),jsxRuntime.jsx(dn,{className:z,children:jsxRuntime.jsx("div",{className:"pt-4 pb-4",children:jsxRuntime.jsx(Xl,{label:"Date Range",value:re&&ie?{start:re,end:ie}:void 0,onChange:ve=>{ve?D(C.field,ve.start,ve.end):D(C.field,void 0,void 0);}})})})]},C.field)}return null},G=()=>jsxRuntime.jsxs("div",{className:"flex flex-col",children:[v.map(C=>{let F=(c?$n(c):[]).includes(C.field);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>x(`__ungrouped__${C.field}`),className:"flex items-center justify-between px-6 py-3 text-left hover:bg-background-hover border-b border-border-muted transition-colors",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-text-primary",children:C.label}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[F&&jsxRuntime.jsx("span",{className:V,children:"1 active"}),jsxRuntime.jsx(O,{name:"CaretRight",size:"sm",className:"text-text-secondary"})]})]},C.field)}),y.map(C=>{let L=M(C);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>x(C),className:"flex items-center justify-between px-6 py-3 text-left hover:bg-background-hover border-b border-border-muted transition-colors",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium text-text-primary",children:C}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[L>0&&jsxRuntime.jsxs("span",{className:V,children:[L," active"]}),jsxRuntime.jsx(O,{name:"CaretRight",size:"sm",className:"text-text-secondary"})]})]},C)})]}),J=C=>{if(C.startsWith("__ungrouped__")){let F=C.replace("__ungrouped__",""),j=v.find(ne=>ne.field===F);return j?jsxRuntime.jsx(Ka,{variant:"contained",density:"comfortable",showDividers:true,defaultExpandedKeys:[j.field],children:Z(j)}):null}let L=S[C]||[];return L.length===0?null:jsxRuntime.jsx(Ka,{variant:"contained",density:"comfortable",showDividers:true,defaultExpandedKeys:[L[0].field],children:L.map(F=>Z(F))})},W=()=>{if(g){let C=g.startsWith("__ungrouped__")&&v.find(L=>L.field===g.replace("__ungrouped__",""))?.label||g;return jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[jsxRuntime.jsxs("button",{type:"button",onClick:()=>x(null),className:"flex items-center gap-2 px-4 py-3 border-b border-border-muted hover:bg-background-hover transition-colors",children:[jsxRuntime.jsx(O,{name:"CaretLeft",size:"sm",className:"text-text-secondary"}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-text-primary",children:C})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto",children:J(g)})]})}return G()},A=()=>jsxRuntime.jsxs("div",{className:"flex h-full",children:[jsxRuntime.jsxs("div",{className:"w-48 flex-shrink-0 border-r border-border-muted overflow-y-auto bg-background-muted/30",children:[v.map(C=>{let F=(c?$n(c):[]).includes(C.field),j=g===`__ungrouped__${C.field}`;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>x(`__ungrouped__${C.field}`),className:`flex items-center justify-between w-full px-4 py-3 text-left border-b border-border-muted transition-colors ${j?"bg-background-selected":"hover:bg-background-hover"}`,children:[jsxRuntime.jsx("span",{className:`text-sm truncate ${j?"font-semibold text-text-primary":"font-medium text-text-primary"}`,children:C.label}),F&&jsxRuntime.jsx("span",{className:"w-2 h-2 rounded-full bg-action-primary flex-shrink-0 ml-2"})]},C.field)}),y.map(C=>{let L=M(C),F=g===C;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>x(C),className:`flex items-center justify-between w-full px-4 py-3 text-left border-b border-border-muted transition-colors ${F?"bg-background-selected":"hover:bg-background-hover"}`,children:[jsxRuntime.jsx("span",{className:`text-sm truncate ${F?"font-semibold text-text-primary":"font-medium text-text-primary"}`,children:C}),L>0&&jsxRuntime.jsx("span",{className:"w-2 h-2 rounded-full bg-action-primary flex-shrink-0 ml-2"})]},C)})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto",children:g?J(g):jsxRuntime.jsx("div",{className:"flex items-center justify-center h-full text-text-secondary text-sm",children:"Select a category to view filters"})})]}),Y=()=>jsxRuntime.jsx(Ka,{variant:"contained",density:"comfortable",showDividers:true,defaultExpandedKeys:[r[0].field],children:r.map(C=>Z(C))});return jsxRuntime.jsx(cr,{isOpen:e,onClose:t,title:h&&b&&g?g.startsWith("__ungrouped__")?v.find(C=>C.field===g.replace("__ungrouped__",""))?.label||s:g:w>0?`${s} (${w} active)`:s,hideCloseIcon:false,primaryAction:{label:"Apply filters",onPress:N,variant:"primary"},secondaryAction:{label:"Clear all",onPress:R},maxWidth:h?"800px":"700px",height:"600px",mobileHeight:"85vh",contentPadding:false,footerContent:l!==void 0?jsxRuntime.jsxs("div",{className:"text-sm text-text-secondary text-center",children:[jsxRuntime.jsx("span",{className:"font-semibold text-text-primary",children:bx(l)})," ",l===1?"result":"results"," with current filters"]}):void 0,children:r.length===0?jsxRuntime.jsx("div",{className:"py-12 text-center",children:jsxRuntime.jsx("div",{className:"text-sm font-medium text-text-secondary",children:"No filters available"})}):h?b?W():A():Y()})}function Op(e="left"){switch(e){case "center":return "justify-center text-center";case "right":return "justify-end text-right";default:return "justify-start text-left"}}function yr(e="normal",t){return tailwindMerge.twMerge({strong:"font-semibold text-text-primary",high:"font-semibold text-text-primary",normal:"text-text-primary",low:"text-text-secondary"}[e],t&&"hover:text-action-primary cursor-pointer transition-colors")}function Se(e="left",t){return tailwindMerge.twMerge("flex items-center gap-1 min-w-0 overflow-hidden",Op(e),t)}function Zl(e,t="\u2014"){return e==null||e===""?t:String(e)}var xn={xs:"h-4 w-12",sm:"h-4 w-20",md:"h-4 w-24",lg:"h-4 w-32",xl:"h-4 w-40"};function Nt(e="normal"){return {strong:xn.lg,high:xn.lg,normal:xn.md,low:xn.sm}[e]}function fe(e,...t){return typeof e=="function"?e(...t):e}function xx(e="neutral",t="sm"){return tailwindMerge.twMerge("inline-flex items-center rounded-full font-medium",t==="sm"?"px-2 py-0.5 text-xs":"px-2.5 py-1 text-sm",{success:"bg-feedback-success-background text-feedback-success-text",error:"bg-feedback-error-background text-feedback-error-text",warning:"bg-feedback-warning-background text-feedback-warning-text",info:"bg-feedback-info-background text-feedback-info-text",neutral:"bg-background-muted text-text-secondary"}[e])}function yx(e){return e?"success":"neutral"}function _l(e,t=false){return t?e>0?"text-feedback-success-text":e<0?"text-feedback-error-text":"text-text-primary":"text-text-primary"}function zp(e="hover",t="secondary"){let r={primary:"text-action-primary hover:text-action-primary-hover visited:text-action-primary",secondary:"text-text-link-default hover:text-text-link-hover visited:text-text-link-default",default:"text-text-link-default hover:text-text-link-hover visited:text-text-link-default",brand:"text-action-primary hover:text-action-primary-hover visited:text-action-primary",muted:"text-text-secondary hover:text-text-secondary visited:text-text-secondary",unstyled:""},o={visible:"underline underline-offset-4 decoration-1 cursor-pointer",hover:"hover:underline hover:underline-offset-4 hover:decoration-1 cursor-pointer transition-colors",none:"cursor-pointer"},n=r[t],a=o[e]||"";return `${n} ${a}`.trim()}function Po(e,t,r,o="hover",n="secondary",a,i){if(!t)return e;let s=typeof t=="function"&&r?t(r):t,l=zp(o,n);return jsxRuntime.jsx("a",{href:s,className:tailwindMerge.twMerge(l,a==="strong"||a==="high"?"font-semibold":"",i),onClick:d=>{d.metaKey||d.ctrlKey;},children:e})}function vx({row:e,context:t,actions:r,align:o="right",size:n="sm"}){let{isLoading:a}=t;if(a)return jsxRuntime.jsx(X,{className:xn.sm});let s=(typeof r=="function"?r(e):r).filter(c=>!fe(c.hidden,e));if(s.length===0)return null;let l=Se(o);return jsxRuntime.jsx("div",{className:l,children:s.map(c=>{let d=fe(c.disabled,e);return c.variant==="icon"||!c.label?jsxRuntime.jsx($,{variant:"icon",size:n,onPress:()=>{c.onClick(e);},isDisabled:d,"aria-label":c.label||c.id,children:jsxRuntime.jsx(O,{name:c.icon||"DotsThree",size:n==="sm"?16:20})},c.id):jsxRuntime.jsxs($,{variant:c.variant||"secondary",size:n,onPress:()=>{c.onClick(e);},isDisabled:d,children:[c.icon&&jsxRuntime.jsx(O,{name:c.icon,size:n==="sm"?14:16}),c.label]},c.id)})})}function Sx({value:e,row:t,context:r,variant:o="default",label:n,size:a="sm",shape:i="square",dot:s,dotPosition:l="left",dotPulse:c,align:d="left",emptyText:u="\u2014",className:p,maxVisible:m=2,maxLabelLength:f}){let{isLoading:g}=r,x=(w,N)=>{if(!f||w.length<=f)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:w});let R=w.slice(0,f-1)+"\u2026";return jsxRuntime.jsx(dr,{content:N,children:jsxRuntime.jsx("span",{children:R})})};if(g)return jsxRuntime.jsx(X,{className:Nt("normal")});if(e==null||e==="")return jsxRuntime.jsx("div",{className:Se(d,"text-text-secondary"),children:u});if(Array.isArray(e)&&e.length===0)return jsxRuntime.jsx("div",{className:Se(d,"text-text-secondary"),children:u});let b=Se(d,p);if(Array.isArray(e)){let w=e.slice(0,m),N=e.slice(m),R=N.length>0;return jsxRuntime.jsx("div",{className:b,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[w.map((P,E)=>{let I=fe(o,P,t),T=n!==void 0?fe(n,P,t):String(P),D=fe(s,P,t),M=fe(c,P,t);return jsxRuntime.jsx("span",{className:"flex-shrink-0 whitespace-nowrap",children:jsxRuntime.jsx(ft,{variant:I,size:a,shape:i,dot:D,dotPosition:l,dotPulse:M,children:x(T,T)})},E)}),R&&jsxRuntime.jsx(dr,{content:N.join(", "),children:jsxRuntime.jsx("span",{className:"flex-shrink-0 whitespace-nowrap",children:jsxRuntime.jsxs(ft,{variant:"neutral",size:a,shape:i,children:["+",N.length]})})})]})})}let h=fe(o,e,t),y=n!==void 0?fe(n,e,t):String(e),v=fe(s,e,t),S=fe(c,e,t);return jsxRuntime.jsx("div",{className:b,children:jsxRuntime.jsx(ft,{variant:h,size:a,shape:i,dot:v,dotPosition:l,dotPulse:S,children:x(y,y)})})}function wx({value:e,context:t,format:r="icon",trueText:o="Yes",falseText:n="No",trueIcon:a="Check",falseIcon:i="X",showFalse:s=true,align:l="center",emphasis:c="normal",className:d}){let{isLoading:u}=t;if(u)return jsxRuntime.jsx(X,{className:Nt(c)});let p=!!e;if(!p&&!s)return jsxRuntime.jsx("div",{className:Se(l,d)});let m=Se(l,d);switch(r){case "icon":return jsxRuntime.jsx("div",{className:m,children:jsxRuntime.jsx(O,{name:p?a:i,size:16,className:p?"text-feedback-success-text":"text-text-disabled"})});case "text":return jsxRuntime.jsx("div",{className:m,children:jsxRuntime.jsx("span",{className:yr(c),children:p?o:n})});case "badge":return jsxRuntime.jsx("div",{className:m,children:jsxRuntime.jsx(ft,{variant:p?"success":"neutral",size:"sm",children:p?o:n})});default:return null}}var $l="var(--color-text-subtle)",Nx=zs().map((e,t)=>`var(--color-viz-categorical-${t+1})`);function Tx({value:e,row:t,context:r,color:o,swatch:n="dot",emptyText:a="\u2014",align:i="left",className:s}){let{isLoading:l}=r;if(l)return jsxRuntime.jsx(X,{className:Nt("normal")});let c=fe(e,t),d=c==null?"":String(c);return d.length===0?jsxRuntime.jsx("div",{className:Se(i,"text-text-secondary"),children:a}):jsxRuntime.jsxs("div",{className:Se(i,tailwindMerge.twMerge("gap-2",s)),children:[jsxRuntime.jsx("span",{"aria-hidden":"true",className:tailwindMerge.twMerge("h-2 w-2 flex-shrink-0",n==="dot"?"rounded-full":"rounded-sm"),style:{backgroundColor:o??$l}}),jsxRuntime.jsx("span",{className:"truncate",children:d})]})}function Rx({row:e,context:t,firstName:r,lastName:o,email:n,avatarUrl:a,layout:i="stacked",size:s="sm",href:l,LinkComponent:c,linkVariant:d="secondary",showEmail:u=false,badge:p,emphasis:m="normal",align:f="left",className:g,piiEntity:x}){let{isLoading:b}=t,h=fe(r,e),y=fe(o,e),v=fe(n,e),S=fe(a,e),w=fe(l,e),N=fe(p,e),R=fe(x,e),P=Se(f,g);return jsxRuntime.jsx("div",{className:P,children:jsxRuntime.jsx(yl,{firstName:h,lastName:y,email:v,avatarUrl:S,layout:i,size:s,href:w,LinkComponent:c,linkVariant:d,showEmail:u,badge:N,emphasis:m,isLoading:b,piiEntity:R})})}function Ex({value:e,row:t,context:r,render:o,className:n}){let a=o(e,t,r);return jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("h-full w-full",n),children:a})}function Mx({value:e,row:t,context:r,format:o="date",customFormat:n,emptyText:a="\u2014",align:i="left",emphasis:s="normal",href:l,linkBehavior:c="hover",className:d}){let{isLoading:u}=r;if(u)return jsxRuntime.jsx(X,{className:Nt(s)});if(!e)return jsxRuntime.jsx("div",{className:Se(i,"text-text-secondary"),children:a});let p=e instanceof Date?e:new Date(e);if(isNaN(p.getTime()))return jsxRuntime.jsx("div",{className:Se(i,"text-text-secondary"),children:a});let m;switch(o){case "date":m=p.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});break;case "time":m=p.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});break;case "datetime":m=p.toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});break;case "relative":m=f2(p);break;case "custom":m=n?p.toLocaleString("en-US",n):p.toISOString();break;default:m=p.toLocaleDateString();}let f=Se(i,tailwindMerge.twMerge(yr(s),d)),g=fe(l,t);return g?jsxRuntime.jsx("div",{className:f,children:Po(m,g,t,c)}):jsxRuntime.jsx("div",{className:f,children:m})}function f2(e){let r=new Date().getTime()-e.getTime(),o=Math.floor(r/1e3),n=Math.floor(o/60),a=Math.floor(n/60),i=Math.floor(a/24);return o<60?"just now":n<60?`${n} minute${n!==1?"s":""} ago`:a<24?`${a} hour${a!==1?"s":""} ago`:i<7?`${i} day${i!==1?"s":""} ago`:e.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}var b2={up:"ArrowUp",down:"ArrowDown",flat:"Minus"},h2={positive:"text-feedback-success-text",negative:"text-feedback-error-text",neutral:"text-text-secondary"};function Hp(e){return e>0?"up":e<0?"down":"flat"}function x2(e,t,r){switch(e){case "percent":return {type:"percentage",decimals:t};case "currency":return {type:"currency",currency:r,minimumFractionDigits:t,maximumFractionDigits:t};case "compact":return {type:"number",notation:"compact",decimals:t,thousandsSeparator:true};default:return {type:"number",decimals:t,thousandsSeparator:true}}}function Lx({value:e,row:t,context:r,direction:o,tone:n="neutral",format:a="number",decimals:i=0,currency:s="USD",showIcon:l=true,align:c="right",emphasis:d="normal",emptyText:u="\u2014",className:p}){let{isLoading:m}=r;if(m)return jsxRuntime.jsx(X,{className:Nt(d)});let f=typeof e=="number"?e:Number(e);if(e==null||e===""||!Number.isFinite(f))return jsxRuntime.jsx("div",{className:Se(c,"text-text-secondary"),children:u});let g=fe(o,t)??Hp(f),x=fe(n,t)??"neutral",b=Pr(f,x2(a,i,s))??u,h=f>0?"+":"",v=Se(c,tailwindMerge.twMerge(d==="strong"||d==="high"?"font-semibold":void 0,p,h2[x]));return jsxRuntime.jsxs("div",{className:v,children:[l&&jsxRuntime.jsx(O,{name:b2[g],size:"xs","aria-hidden":true}),jsxRuntime.jsx("span",{children:`${h}${b}`})]})}function rc({manufacturer:e,model:t,deviceType:r,deviceTypeIconName:o,logoUrl:n,layout:a="stacked",size:i="md",href:s,LinkComponent:l,linkVariant:c="unstyled",showDeviceTypeIcon:d=true,showLogo:u=true,emphasis:p="normal",isLoading:m=false,className:f,piiEntity:g}){let[x,b]=qe.useState(false),h=o||(r?C2(r):"DeviceMobile"),v={xs:{iconSize:28,logoSize:"w-7 h-7",gap:"gap-1.5",textSize:"text-xs",secondaryTextSize:"text-xs",iconInTextSize:12,skeletonIcon:28,skeletonText:80,skeletonSecondary:60},sm:{iconSize:32,logoSize:"w-8 h-8",gap:"gap-2",textSize:"text-sm",secondaryTextSize:"text-xs",iconInTextSize:14,skeletonIcon:32,skeletonText:96,skeletonSecondary:72},md:{iconSize:32,logoSize:"w-9 h-9",gap:"gap-3",textSize:"text-base",secondaryTextSize:"text-sm",iconInTextSize:16,skeletonIcon:36,skeletonText:128,skeletonSecondary:96},lg:{iconSize:40,logoSize:"w-10 h-10",gap:"gap-3",textSize:"text-lg",secondaryTextSize:"text-base",iconInTextSize:18,skeletonIcon:40,skeletonText:160,skeletonSecondary:120}}[i],S=n&&!x&&u,N={strong:"font-semibold text-text-primary",high:"font-semibold text-text-primary",normal:"text-text-primary",low:"text-text-secondary"}[p],R=({children:P,className:E})=>s?l?jsxRuntime.jsx(l,{href:s,className:E,children:P}):jsxRuntime.jsx(ut,{href:s,variant:c,className:tailwindMerge.twMerge("hover:underline",E),asButton:false,children:P}):jsxRuntime.jsx("span",{className:E,children:P});if(m)return a==="inline"?jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center",v.gap,f),children:[jsxRuntime.jsx(X,{width:v.skeletonIcon,height:v.skeletonIcon,className:"flex-shrink-0 rounded"}),jsxRuntime.jsx(X,{width:v.skeletonText,height:v.skeletonIcon*.6})]}):jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center",v.gap,f),children:[jsxRuntime.jsx(X,{width:v.skeletonIcon,height:v.skeletonIcon,className:"flex-shrink-0"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx(X,{width:v.skeletonText,height:16}),jsxRuntime.jsx(X,{width:v.skeletonSecondary,height:12})]})]});if(a==="inline"){let P=`${e} ${t}`;return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center",v.gap,f),children:[jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex-shrink-0 flex items-center justify-center rounded border border-border-muted",v.logoSize),children:S?jsxRuntime.jsx("img",{src:n,alt:`${e} logo`,className:"w-full h-full object-contain",onError:()=>b(true)}):jsxRuntime.jsx(O,{name:h,size:v.iconSize*.6,className:"text-text-secondary"})}),jsxRuntime.jsx(R,{className:tailwindMerge.twMerge("truncate leading-normal hover:text-text-primary",N,v.textSize,s&&"hover:underline hover:decoration-1 hover:underline-offset-4"),children:jsxRuntime.jsx("span",{"data-pii-type":g?"device-name":void 0,"data-pii-entity":g,children:P})})]})}return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center justify-start",v.gap,f),children:[u&&jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex-shrink-0 flex items-center justify-center rounded border border-border-muted",v.logoSize),children:S?jsxRuntime.jsx("img",{src:n,alt:`${e} logo`,className:"w-full h-full object-contain",onError:()=>b(true)}):jsxRuntime.jsx(O,{name:h,size:v.iconSize*.6,className:"text-text-secondary"})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[jsxRuntime.jsx(R,{className:tailwindMerge.twMerge("truncate leading-normal hover:text-text-primary",N,v.textSize,s&&"hover:underline hover:decoration-1 hover:underline-offset-4"),children:jsxRuntime.jsx("span",{"data-pii-type":g?"device-name":void 0,"data-pii-entity":g,children:e})}),jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center gap-1.5 text-text-secondary leading-normal",v.secondaryTextSize),children:[d&&jsxRuntime.jsx(O,{name:h,size:v.iconInTextSize,className:"flex-shrink-0"}),jsxRuntime.jsx("span",{className:"truncate","data-pii-type":g?"device-name":void 0,"data-pii-entity":g,children:t})]})]})]})}function C2(e){switch(e){case "battery":return "BatteryHigh";case "charger":return "ChargingStation";case "inverter":return "Power";case "thermostat":return "ThermometerSimple";case "vehicle":return "CarSimple";case "water_heater":return "DropHalfBottom";case "meter":return "Gauge";default:return "DeviceMobile"}}function Ax({row:e,context:t,manufacturer:r,model:o,deviceType:n,logoUrl:a,layout:i="stacked",size:s="sm",href:l,LinkComponent:c,linkVariant:d="secondary",showDeviceTypeIcon:u=true,showLogo:p=true,emphasis:m="normal",align:f="left",className:g,piiEntity:x}){let{isLoading:b}=t,h=fe(r,e),y=fe(o,e),v=fe(n,e),S=fe(a,e),w=fe(l,e),N=fe(x,e),R=Se(f,g);return jsxRuntime.jsx("div",{className:R,children:jsxRuntime.jsx(rc,{manufacturer:h,model:y,deviceType:v,logoUrl:S,layout:i,size:s,href:w,LinkComponent:c,linkVariant:d,showDeviceTypeIcon:u,showLogo:p,emphasis:m,isLoading:b,piiEntity:N})})}var iX={charging:"percentage",discharging:"percentage",on:"kW",idle:void 0,off:void 0,heat:"temperature",cool:"temperature",auto:"temperature",eco:"temperature",circulate:void 0,unknown:void 0,connected:void 0,disconnected:void 0},S2=["charging","discharging","heat","cool","on","circulate","connected"],w2={unknown:"Unknown",on:"On",off:"Off",idle:"Idle",charging:"Charging",discharging:"Discharging",heat:"Heating",eco:"Eco Mode",cool:"Cooling",auto:"Auto",circulate:"Circulating",connected:"Connected",disconnected:"Disconnected"};function Gp(e){return S2.includes(e)}function Wp(e){return w2[e]}function ta({state:e,label:t,icon:r,isLoading:o,size:n="sm",shape:a="pill",dot:i,dotPulse:s,fixedWidth:l,className:c,...d}){if(o)return jsxRuntime.jsx(X,{className:"inline-flex h-6 w-20"});let u=t??Wp(e),p=Gp(e);return jsxRuntime.jsxs(ft,{variant:e,size:n,shape:a,dot:i??p,dotPulse:s??p,className:l?`w-28 justify-center ${c||""}`:c,...d,children:[r&&jsxRuntime.jsx(O,{name:r,size:n==="sm"?12:n==="md"?14:16}),u]})}var k2={importing:"Importing",exporting:"Exporting",idle:"Idle",unknown:"Unknown"};function Fx(e){return k2[e]}var T2={importing:"ArrowDown",exporting:"ArrowUp"};function nc({state:e,label:t,showIcon:r=false,isLoading:o,size:n="sm",shape:a="pill",fixedWidth:i,className:s,...l}){if(o)return jsxRuntime.jsx(X,{className:"inline-flex h-6 w-24"});let c=t??Fx(e),d=T2[e],u=n==="sm"?12:n==="md"?14:16;return r&&d?jsxRuntime.jsx(ft,{variant:e,size:n,shape:a,className:`w-6 justify-center ${s||""}`,...l,children:jsxRuntime.jsx(O,{name:d,size:u})}):jsxRuntime.jsx(ft,{variant:e,size:n,shape:a,className:i?`w-28 justify-center ${s||""}`:s,...l,children:c})}function ac({state:e,stateLabel:t,metric:r,metricFormatter:o,secondaryState:n,layout:a="horizontal",isLoading:i,size:s="sm",shape:l="pill",icon:c,fixedWidth:d,secondaryStateIconOnly:u=false,className:p}){if(i)return jsxRuntime.jsx(X,{className:tailwindMerge.twMerge("inline-flex h-6 w-32",p)});let m=r!=null&&o?Pr(r,o):null,f=a==="horizontal",g=o&&!m;return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("inline-flex items-center",f?"gap-2":"flex-col gap-1",p),children:[(m||g)&&jsxRuntime.jsx("span",{className:tailwindMerge.twMerge("font-medium inline-block",m?"text-text-primary":"text-text-secondary",s==="sm"&&"text-xs min-w-12",s==="md"&&"text-sm min-w-14",s==="lg"&&"text-base min-w-16"),children:m||"\u2014"}),jsxRuntime.jsx(ta,{state:e,label:t,icon:c,size:s,shape:l,fixedWidth:d}),n&&jsxRuntime.jsx(jsxRuntime.Fragment,{children:n==="importing"||n==="exporting"?jsxRuntime.jsx(nc,{state:n,size:s,shape:l,fixedWidth:d,showIcon:u}):jsxRuntime.jsx(ta,{state:n,size:s,shape:l,fixedWidth:d})})]})}function Bx({value:e,row:t,context:r,metric:o,metricFormatter:n,secondaryState:a,size:i="sm",shape:s="pill",label:l,icon:c,fixedWidth:d=true,align:u="left",compact:p=false,className:m}){let{isLoading:f}=r;if(f){let v={pill:"rounded-full",rounded:"rounded-lg",square:"rounded-sm"}[s],S=o!=null||n!=null;return jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:S?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(X,{className:"h-4 w-12"}),jsxRuntime.jsx(X,{className:`h-6 w-24 ${v}`}),jsxRuntime.jsx(X,{className:`h-6 w-20 ${v}`})]}):jsxRuntime.jsx(X,{className:`h-6 w-24 ${v}`})})}if(!e)return jsxRuntime.jsx("div",{className:Se(u,m),children:jsxRuntime.jsx("span",{className:"text-text-secondary",children:"\u2014"})});let g=fe(o,t),x=fe(a,t),b=typeof l=="function"?l(e,t):l,h=Se(u,m);return g!=null||n?jsxRuntime.jsx("div",{className:tailwindMerge.twMerge(h),children:jsxRuntime.jsx(ac,{state:e,stateLabel:b,metric:g,metricFormatter:n,secondaryState:x||void 0,size:i,shape:s,icon:c,fixedWidth:d,secondaryStateIconOnly:p,layout:"horizontal"})}):jsxRuntime.jsx("div",{className:h,children:jsxRuntime.jsx(ta,{state:e,label:b,icon:c,size:i,shape:s,fixedWidth:d})})}function Ox({value:e,row:t,context:r,formatter:o,align:n="left",emphasis:a="normal",href:i,linkBehavior:s="hover",className:l,emptyText:c="\u2014",emptyClassName:d="text-text-secondary"}){let{isLoading:u}=r;if(u)return jsxRuntime.jsx(X,{className:Nt(a)});let p=fo({value:e,formatter:o,emptyText:c,emptyClassName:d}),m=yr(a),f=Se(n,tailwindMerge.twMerge(m,l)),g=jsxRuntime.jsx("div",{className:f,children:p}),x=fe(i,t);return x?Po(g,x,t,s):g}var Kp=qe__namespace.default.memo(({value:e,min:t,max:r,color:o="var(--color-viz-default)",backgroundColor:n="var(--color-background-muted)",colorScale:a,showLabel:i=true,formatLabel:s,height:l=20,minWidth:c=4,segments:d,segmentGap:u=2,barWidth:p,context:m})=>{let f=qe.useMemo(()=>r===t?100:Math.max(0,Math.min(100,(e-t)/(r-t)*100)),[e,t,r]),g=qe.useMemo(()=>o==="auto"&&a?a.type==="diverging"&&a.center!==void 0?Ti(e,t,r,a.center,a.scheme):ki(e,t,r,a.scheme):o,[o,a,e,t,r]);if(m.isLoading)return jsxRuntime.jsx("div",{className:"flex items-center gap-2 w-full",style:{height:l},children:jsxRuntime.jsx("div",{className:"h-full flex-1 animate-pulse bg-border-default rounded"})});if(d&&d>0){let h=`calc((100% - ${u*(d-1)}px) / ${d})`,y=Math.ceil(f/100*d),v={height:l,...p&&{width:typeof p=="number"?`${p}px`:p,flexShrink:0}};return jsxRuntime.jsxs("div",{className:"flex items-center gap-2 w-full",children:[jsxRuntime.jsx("div",{className:`flex gap-0.5 ${p?"":"flex-1"}`,style:v,children:Array.from({length:d}).map((S,w)=>{let N=w<y;return jsxRuntime.jsx("div",{className:"rounded-sm",style:{width:h,backgroundColor:N?g:n==="none"?"transparent":n,marginRight:w<d-1?`${u}px`:0}},w)})}),i&&jsxRuntime.jsx("span",{className:"text-sm text-text-primary whitespace-nowrap",children:s?s(e):e.toLocaleString()})]})}let x={height:l,backgroundColor:n==="none"?"transparent":n,...p&&{width:typeof p=="number"?`${p}px`:p,flexShrink:0}};return jsxRuntime.jsxs("div",{className:"flex items-center gap-2 w-full",children:[jsxRuntime.jsx("div",{className:`relative rounded-sm ${p?"":"flex-1"}`,style:x,children:jsxRuntime.jsx("div",{className:"absolute left-0 top-0 h-full rounded-sm",style:{width:`${f}%`,minWidth:f>0?c:0,backgroundColor:g}})}),i&&jsxRuntime.jsx("span",{className:"text-sm text-text-primary whitespace-nowrap",children:s?s(e):e.toLocaleString()})]})});Kp.displayName="HorizontalBarCell";function F2(e){return Math.max(1,String(Math.max(1,Math.trunc(e))).length)}function Gx({context:e,startAt:t=1,padTo:r,rowCount:o,align:n="right",className:a}){let{isLoading:i,rowIndex:s}=e;if(i)return jsxRuntime.jsx(X,{className:Nt("normal")});if(typeof s!="number"||!Number.isFinite(s))return jsxRuntime.jsx("div",{className:Se(n,"text-text-muted"),children:"\u2014"});let l=s+t,c=r??(o===void 0?void 0:F2(o+t-1)),d=c===void 0?String(l):String(l).padStart(c,"0");return jsxRuntime.jsx("div",{className:Se(n,tailwindMerge.twMerge("font-mono text-text-muted tabular-nums",a)),children:jsxRuntime.jsx("span",{children:d})})}var Yp=qe__namespace.default.memo(({value:e,data:t,color:r="var(--color-viz-default)",categoryColors:o,context:n,width:a,height:i=40})=>{let s=e||t||[],l=x=>"xValue"in x?x.xValue:x.x,c=x=>"yValue"in x?x.yValue:x.y,d=a||100,u=i,{xScale:p,yScale:m,barWidth:f}=qe.useMemo(()=>{if(s.length===0)return {xScale:scale.scaleTime({range:[0,d],domain:[new Date,new Date]}),yScale:scale.scaleLinear({range:[u,0],domain:[0,1]}),barWidth:2};let x=d3Array.extent(s,N=>l(N)),b=d3Array.min(s,N=>c(N))??0,h=d3Array.max(s,N=>c(N))??0,y=b<0?b:0,v=scale.scaleTime({range:[0,d],domain:x}),S=scale.scaleLinear({range:[u,0],domain:[y,h*1.05]}),w=s.length>1?d/s.length*.8:8;return {xScale:v,yScale:S,barWidth:Math.max(2,w)}},[s,d,u]);if(n.isLoading)return jsxRuntime.jsx("div",{className:"flex items-center gap-0.5",style:{width:d,height:u},children:Array.from({length:5}).map((x,b)=>jsxRuntime.jsx("div",{className:"flex-1 animate-pulse bg-border-default rounded"},b))});if(!s||s.length===0)return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-text-secondary text-xs",style:{width:d,height:u},children:"No data"});let g=m(0);return jsxRuntime.jsx("svg",{width:d,height:u,children:s.map((x,b)=>{let h=c(x),y=p(l(x)),v=m(h),S=Math.abs(g-v),w=x.category&&o?.[x.category]?o[x.category]:r;return jsxRuntime.jsx(shape.Bar,{x:y-f/2,y:h>=0?v:g,width:f,height:S,fill:w,rx:1},`bar-${b}`)})})});Yp.displayName="MiniBarCell";function Kx({value:e,row:t,context:r,format:o="number",decimals:n=0,prefix:a,suffix:i,emptyText:s="\u2014",align:l="right",emphasis:c="normal",href:d,linkBehavior:u="hover",showPositiveSign:p=false,colorCode:m=false,className:f}){let{isLoading:g}=r;if(g)return jsxRuntime.jsx(X,{className:Nt(c)});if(e==null||isNaN(Number(e)))return jsxRuntime.jsx("div",{className:Se(l,"text-text-secondary"),children:s});let x=Number(e),b;switch(o){case "currency":b=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:n,maximumFractionDigits:n}).format(x);break;case "percent":b=new Intl.NumberFormat("en-US",{style:"percent",minimumFractionDigits:n,maximumFractionDigits:n}).format(x/100);break;case "compact":b=new Intl.NumberFormat("en-US",{notation:"compact",minimumFractionDigits:n>0?1:0,maximumFractionDigits:n}).format(x);break;default:b=new Intl.NumberFormat("en-US",{minimumFractionDigits:n,maximumFractionDigits:n}).format(x);}let y=`${p&&x>0?"+":""}${b}`,v=m?_l(x,true):yr(c),S=Se(l,tailwindMerge.twMerge(v,f)),w=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[a&&jsxRuntime.jsx("span",{className:"text-text-secondary",children:a}),jsxRuntime.jsx("span",{children:y}),i&&jsxRuntime.jsx("span",{className:"text-text-secondary",children:i})]}),N=fe(d,t);return N?jsxRuntime.jsx("div",{className:S,children:Po(w,N,t,u)}):jsxRuntime.jsx("div",{className:S,children:w})}var J2={low:"var(--color-feedback-warning-text)",critical:"var(--color-feedback-error-text)"};function Xp(e,t){if(t){if(t.critical!==void 0&&e<=t.critical)return "critical";if(t.low!==void 0&&e<=t.low)return "low"}}var jp=qe__namespace.default.memo(({value:e,showLabel:t=true,color:r="var(--color-viz-categorical-1)",backgroundColor:o="var(--color-background-muted)",height:n=20,segments:a,segmentGap:i=2,colorScale:s,thresholds:l,context:c})=>{let d=qe.useMemo(()=>Math.max(0,Math.min(100,e)),[e]),u=qe.useMemo(()=>Xp(d,l),[d,l]),p=qe.useMemo(()=>u?J2[u]:r==="auto"&&s?s.type==="diverging"&&s.center!==void 0?Ti(e,0,100,s.center,s.scheme):ki(e,0,100,s.scheme):r,[r,s,u,e]);if(c.isLoading)return jsxRuntime.jsx("div",{className:"flex items-center gap-2",style:{height:n},children:jsxRuntime.jsx("div",{className:"h-full w-full animate-pulse bg-border-default rounded"})});if(a&&a>0){let f=`calc((100% - ${i*(a-1)}px) / ${a})`,g=Math.ceil(d/100*a);return jsxRuntime.jsxs("div",{className:"flex items-center gap-2 w-full","data-threshold":u,children:[jsxRuntime.jsx("div",{className:"flex gap-0.5 flex-1",style:{height:n},children:Array.from({length:a}).map((x,b)=>{let h=b<g,y=p;if(!u&&r==="auto"&&s&&h){let v=(b+1)/a*100;s.type==="diverging"&&s.center!==void 0?y=Ti(v,0,100,s.center,s.scheme):y=ki(v,0,100,s.scheme);}return jsxRuntime.jsx("div",{className:"rounded-sm",style:{width:f,backgroundColor:h?y:o==="none"?"transparent":o,marginRight:b<a-1?`${i}px`:0}},b)})}),t&&jsxRuntime.jsxs("span",{className:"text-sm text-text-primary whitespace-nowrap",children:[d.toFixed(0),"%"]})]})}return jsxRuntime.jsxs("div",{className:"flex items-center gap-2 w-full","data-threshold":u,children:[jsxRuntime.jsx("div",{className:"relative flex-1 rounded-sm",style:{height:n,backgroundColor:o==="none"?"transparent":o},children:jsxRuntime.jsx("div",{className:"absolute left-0 top-0 h-full rounded-sm transition-all duration-300",style:{width:`${d}%`,backgroundColor:p}})}),t&&jsxRuntime.jsxs("span",{className:"text-sm text-text-primary whitespace-nowrap",children:[d.toFixed(0),"%"]})]})});jp.displayName="PercentBarCell";var j2="\u2013",Yx="\u200A";function Jx(e){if(e==null||e==="")return;let t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:void 0}function Xx({row:e,context:t,min:r,max:o,decimals:n=0,unit:a,emptyText:i="\u2014",align:s="right",emphasis:l="normal",className:c}){let{isLoading:d}=t;if(d)return jsxRuntime.jsx(X,{className:Nt(l)});let u=Jx(fe(r,e)),p=Jx(fe(o,e));if(u===void 0&&p===void 0)return jsxRuntime.jsx("div",{className:Se(s,"text-text-secondary"),children:i});let m=x=>new Intl.NumberFormat("en-US",{minimumFractionDigits:n,maximumFractionDigits:n}).format(x),f=u!==void 0&&p!==void 0?`${m(u)}${Yx}${j2}${Yx}${m(p)}`:m(u!==void 0?u:p),g=Se(s,tailwindMerge.twMerge("tabular-nums",yr(l),c));return jsxRuntime.jsxs("div",{className:g,children:[jsxRuntime.jsx("span",{children:f}),a&&jsxRuntime.jsx("span",{className:"text-text-secondary",children:a})]})}function dc({row:e,context:t,isSelected:r=false,onSelect:o,isDisabled:n=false,align:a="center"}){let{isLoading:i}=t;if(i)return jsxRuntime.jsx("div",{className:Se(a),children:jsxRuntime.jsx(X,{className:"h-4 w-4 rounded"})});let s=fe(n,e),l=Se(a);return jsxRuntime.jsx("div",{className:l,children:jsxRuntime.jsx(eo,{isSelected:r,onChange:c=>{o?.(e,c);},isDisabled:s,"aria-label":"Select row"})})}function uc({streetAddress:e,city:t,state:r,postalCode:o,layout:n="stacked",size:a="md",href:i,LinkComponent:s,linkVariant:l="unstyled",emphasis:c="normal",isLoading:d=false,className:u,piiEntity:p}){let f={xs:{iconSize:16,iconContainerSize:"w-7 h-7",gap:"gap-1.5",textSize:"text-xs",secondaryTextSize:"text-xs",skeletonIconStacked:28,skeletonIconInline:16,skeletonText:80,skeletonSecondary:60},sm:{iconSize:20,iconContainerSize:"w-8 h-8",gap:"gap-2",textSize:"text-sm",secondaryTextSize:"text-xs",skeletonIconStacked:32,skeletonIconInline:20,skeletonText:96,skeletonSecondary:72},md:{iconSize:24,iconContainerSize:"w-9 h-9",gap:"gap-3",textSize:"text-base",secondaryTextSize:"text-sm",skeletonIconStacked:36,skeletonIconInline:24,skeletonText:128,skeletonSecondary:96},lg:{iconSize:28,iconContainerSize:"w-10 h-10",gap:"gap-3",textSize:"text-lg",secondaryTextSize:"text-base",skeletonIconStacked:40,skeletonIconInline:28,skeletonText:160,skeletonSecondary:120}}[a],x={strong:"font-semibold text-text-primary",high:"font-semibold text-text-primary",normal:"text-text-primary",low:"text-text-secondary"}[c],b=[];t&&b.push(t),r&&o?b.push(`${r} ${o}`):r?b.push(r):o&&b.push(o);let h=b.join(", "),y=({children:S,className:w})=>i?s?jsxRuntime.jsx(s,{href:i,className:w,children:S}):jsxRuntime.jsx(ut,{href:i,variant:l,className:tailwindMerge.twMerge("hover:underline",w),asButton:false,children:S}):jsxRuntime.jsx("span",{className:w,children:S});if(d)return n==="inline"?jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center",f.gap,u),children:[jsxRuntime.jsx(X,{width:f.skeletonIconInline,height:f.skeletonIconInline,className:"flex-shrink-0 rounded"}),jsxRuntime.jsx(X,{width:f.skeletonText,height:f.skeletonIconInline*.8})]}):jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center",f.gap,u),children:[jsxRuntime.jsx(X,{width:f.skeletonIconStacked,height:f.skeletonIconStacked,className:"flex-shrink-0 rounded"}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-1",children:[jsxRuntime.jsx(X,{width:f.skeletonText,height:16}),jsxRuntime.jsx(X,{width:f.skeletonSecondary,height:12})]})]});if(n==="inline")return jsxRuntime.jsxs(y,{className:tailwindMerge.twMerge("flex items-center",f.gap,i&&"hover:bg-background-hover transition-colors",u),children:[jsxRuntime.jsx(O,{name:"MapPin",size:f.iconSize,className:"text-text-secondary flex-shrink-0"}),jsxRuntime.jsx("span",{className:tailwindMerge.twMerge("leading-normal truncate hover:text-text-primary",x,f.textSize,i&&"hover:underline hover:decoration-1 hover:underline-offset-4"),"data-pii-type":p?"address":void 0,"data-pii-entity":p,children:e})]});let v=()=>{if(p){if(t&&r&&o)return "city-state-zip";if(t&&r)return "city-state";if(t)return "city";if(r)return "state";if(o)return "postal-code"}};return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex items-center justify-start",f.gap,u),children:[jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex-shrink-0 flex items-center justify-center rounded border border-border-muted",f.iconContainerSize),children:jsxRuntime.jsx(O,{name:"MapPin",size:f.iconSize,className:"text-text-secondary"})}),jsxRuntime.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[jsxRuntime.jsx(y,{className:tailwindMerge.twMerge("leading-normal truncate hover:text-text-primary",x,f.textSize,i&&"hover:underline hover:decoration-1 hover:underline-offset-4"),children:jsxRuntime.jsx("span",{"data-pii-type":p?"address":void 0,"data-pii-entity":p,children:e})}),h&&jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("text-text-secondary leading-normal truncate",f.secondaryTextSize),"data-pii-type":v(),"data-pii-entity":p,children:h})]})]})}function qx({row:e,context:t,streetAddress:r,city:o,state:n,postalCode:a,layout:i="stacked",size:s="sm",href:l,LinkComponent:c,linkVariant:d="secondary",emphasis:u="normal",align:p="left",className:m,piiEntity:f}){let{isLoading:g}=t,x=fe(r,e),b=fe(o,e),h=fe(n,e),y=fe(a,e),v=fe(l,e),S=fe(f,e),w=Se(p,m);return jsxRuntime.jsx("div",{className:w,children:jsxRuntime.jsx(uc,{streetAddress:x,city:b,state:h,postalCode:y,layout:i,size:s,href:v,LinkComponent:c,linkVariant:d,emphasis:u,isLoading:g,piiEntity:S})})}var qp=qe__namespace.default.memo(({value:e,data:t,type:r="line",color:o="var(--color-viz-default)",strokeWidth:n=2,categoryColors:a,context:i,width:s,height:l=40})=>{let c=e||t||[],d=s||100,u=l,{xScale:p,yScale:m}=qe.useMemo(()=>{if(c.length===0)return {xScale:scale.scaleTime({range:[0,d],domain:[new Date,new Date]}),yScale:scale.scaleLinear({range:[u,0],domain:[0,1]})};let g=d3Array.extent(c,y=>y.xValue),x=d3Array.min(c,y=>y.yValue)||0,b=d3Array.max(c,y=>y.yValue)||0,h=(b-x)*.1||1;return {xScale:scale.scaleTime({range:[0,d],domain:g}),yScale:scale.scaleLinear({range:[u,0],domain:[x-h,b+h]})}},[c,d,u]);if(i.isLoading)return jsxRuntime.jsx("div",{className:"flex items-center",style:{width:d,height:u},children:jsxRuntime.jsx("div",{className:"h-1 w-full animate-pulse bg-border-default rounded"})});if(!c||c.length===0)return jsxRuntime.jsx("div",{className:"flex items-center justify-center text-text-secondary text-xs",style:{width:d,height:u},children:"No data"});let f=a&&c[0]?.category&&a[c[0].category]?a[c[0].category]:o;return jsxRuntime.jsxs("svg",{width:d,height:u,className:"overflow-visible",children:[(r==="area"||r==="both")&&jsxRuntime.jsx(shape.AreaClosed,{data:c,x:g=>p(g.xValue),y:g=>m(g.yValue),yScale:m,fill:f,fillOpacity:.15,curve:curve.curveLinear}),(r==="line"||r==="both")&&jsxRuntime.jsx(shape.LinePath,{data:c,x:g=>p(g.xValue),y:g=>m(g.yValue),stroke:f,strokeWidth:n,strokeLinecap:"round",curve:curve.curveLinear})]})});qp.displayName="SparklineCell";function $x({value:e,row:t,context:r,prefix:o,suffix:n,emptyText:a="\u2014",href:i,linkBehavior:s="hover",linkVariant:l="secondary",emphasis:c="normal",truncate:d=true,copyable:u=false,align:p="left",className:m,piiType:f,piiEntity:g}){let{isLoading:x}=r;if(x)return jsxRuntime.jsx(X,{className:Nt(c)});let b=Zl(e,a),h=fe(i,t),y=fe(g,t),v=b,S=false,w=false;if(d&&b&&typeof b=="string")if(typeof d=="boolean")w=true;else {let{position:M="end",length:B=16,ellipsis:z="...",tooltip:V=true}=d;if(b.length>B){switch(M){case "start":v=Js(b,B);break;case "middle":v=La(b,B);break;case "end":v=Xs(b,B,z);break}S=V;}}let N=f&&y?{"data-pii-type":f,"data-pii-entity":y}:{},R=Object.keys(N).length>0,P=jsxRuntime.jsx("span",{className:w?"truncate":"",...N,children:v}),E=S?jsxRuntime.jsx(dr,{content:R?jsxRuntime.jsx("span",{...N,children:String(b)}):String(b),children:P}):P,I=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[o&&jsxRuntime.jsx("span",{className:"text-text-secondary",children:o}),E,n&&jsxRuntime.jsx("span",{className:"text-text-secondary",children:n})]}),T=I;if(u&&b&&b!==a){let M=typeof u=="function"?u(t):String(b);T=jsxRuntime.jsx(on,{value:M,size:"sm",children:I});}if(h){let M=Se(p,m);return jsxRuntime.jsx("div",{className:M,children:Po(T,h,t,s,l,c)})}let D=Se(p,tailwindMerge.twMerge(yr(c),m));return jsxRuntime.jsx("div",{className:D,children:T})}var sE={sm:"sm:hidden",md:"md:hidden",lg:"lg:hidden",xl:"xl:hidden"},lE={sm:"hidden sm:grid",md:"hidden md:grid",lg:"hidden lg:grid",xl:"hidden xl:grid"};function pc(e,t){return t.accessor?typeof t.accessor=="function"?t.accessor(e):e[t.accessor]:null}function mc(e,t,r,o){if(r.cell){let n=r.cell,a=typeof r.cellProps=="function"?r.cellProps(e,t):r.cellProps;return jsxRuntime.jsx(n,{value:e,row:t,context:o,...a})}return r.render?r.render(e,t,o):e?.toString()??"\u2014"}function gc({row:e,columns:t,density:r,isLoading:o,onClick:n}){let a=t.filter(u=>u.mobile!==false).map(u=>{let p=u.mobile===false?null:u.mobile;return {...u,mobilePriority:p?.priority??2,mobileFormat:p?.format??"secondary",showLabel:p?.label??p?.format==="secondary",icon:p?.icon}}).sort((u,p)=>u.mobilePriority-p.mobilePriority),i=a.filter(u=>u.mobilePriority===1||u.mobileFormat==="primary"),s=a.filter(u=>u.mobilePriority===2&&u.mobileFormat!=="primary"),l=a.filter(u=>u.mobileFormat==="badge"),c={isLoading:!!o,rowIndex:0,columnIndex:0,density:r};return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("border-b border-border-default bg-background-surface transition-colors",n&&"cursor-pointer hover:bg-background-hover active:bg-background-pressed",{compact:"px-3 py-2",default:"px-4 py-3",relaxed:"px-4 py-4"}[r]),onClick:n,role:n?"button":void 0,tabIndex:n?0:void 0,children:[i.length>0&&jsxRuntime.jsxs("div",{className:"mb-2 flex items-start justify-between",children:[jsxRuntime.jsx("div",{className:"flex-1",children:i.map(u=>{let p=pc(e,u);return jsxRuntime.jsx("div",{className:"font-medium text-text-primary [&>*]:!justify-start [&>*]:!text-left",children:mc(p,e,u,c)},u.id)})}),l.length>0&&jsxRuntime.jsx("div",{className:"ml-2 flex flex-wrap gap-1",children:l.map(u=>{let p=pc(e,u);return jsxRuntime.jsx("div",{className:"inline-flex",children:mc(p,e,u,c)},u.id)})})]}),s.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:s.map(u=>{let p=pc(e,u),m=u.showLabel&&u.label;return jsxRuntime.jsxs("div",{className:"flex items-center text-sm text-text-secondary",children:[u.icon&&jsxRuntime.jsx(O,{name:u.icon,className:"mr-1.5 h-4 w-4 flex-shrink-0"}),m&&jsxRuntime.jsxs("span",{className:"mr-1 font-medium",children:[u.label,":"]}),jsxRuntime.jsx("span",{className:"truncate [&>*]:!justify-start [&>*]:!text-left",children:mc(p,e,u,c)})]},u.id)})})]})}function bc({row:e,columns:t,density:r,isLoading:o,onClick:n}){let a=t.filter(l=>l.mobile!==false),i={isLoading:!!o,rowIndex:0,columnIndex:0,density:r};return jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("border-b border-border-default bg-background-surface transition-colors",n&&"cursor-pointer hover:bg-background-hover active:bg-background-pressed",{compact:"px-3 py-2",default:"px-4 py-3",relaxed:"px-4 py-4"}[r]),onClick:n,role:n?"button":void 0,tabIndex:n?0:void 0,children:jsxRuntime.jsx("div",{className:"space-y-2",children:a.map((l,c)=>{let d=pc(e,l),u=c===0;return jsxRuntime.jsxs("div",{children:[!u&&jsxRuntime.jsx("div",{className:"text-xs text-text-secondary",children:l.label}),jsxRuntime.jsx("div",{className:tailwindMerge.twMerge(u?"font-medium text-text-primary":"text-sm text-text-primary","[&>*]:!justify-start [&>*]:!text-left"),children:mc(d,e,l,i)})]},l.id)})})})}function ey(e="md"){return {mobile:sE[e],desktop:lE[e]}}function ty({density:e}){return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("border-b border-border-default bg-background-surface",{compact:"px-3 py-2",default:"px-4 py-3",relaxed:"px-4 py-4"}[e]),children:[jsxRuntime.jsx("div",{className:"mb-2 h-5 w-3/4 animate-pulse rounded bg-background-muted"}),jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("div",{className:"h-4 w-1/2 animate-pulse rounded bg-background-muted"}),jsxRuntime.jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-background-muted"})]})]})}var CE={compact:"py-1.5 px-3 text-sm",default:"py-3 px-4 text-sm",relaxed:"py-4 px-4 text-base"},SE={left:"text-left justify-start",center:"text-center justify-center",right:"text-right justify-end"};function wE(e){let t={};return e.width!==void 0&&(t.width=typeof e.width=="number"?`${e.width}px`:e.width),e.minWidth!==void 0&&(t.minWidth=typeof e.minWidth=="number"?`${e.minWidth}px`:e.minWidth),e.maxWidth!==void 0&&(t.maxWidth=typeof e.maxWidth=="number"?`${e.maxWidth}px`:e.maxWidth),e.flex!==void 0&&(t.flex=`${e.flex} 1 0`),t}function NE({column:e,sortConfig:t,onSort:r,stickyHeader:o,stickyFirstColumn:n,isFirstColumn:a,density:i="default",isLoading:s=false,headerContent:l,sortNote:c}){let d=e.reorderable!==false,{attributes:u,listeners:p,setNodeRef:m,transform:f,transition:g,isDragging:x}=sortable.useSortable({id:e.id,disabled:!d||s}),{role:b,"aria-pressed":h,...y}=u,v=t?.columnId===e.id,S=v?t.direction:null,w=n&&a,N=v?c:void 0,R={...wE(e),transform:utilities.CSS.Transform.toString(f),transition:g,opacity:x?.8:1,zIndex:x?50:void 0};return jsxRuntime.jsx("div",{ref:m,className:tailwindMerge.twMerge("flex items-center border-b border-border-default bg-background-surface",e.sortable?"gap-2":"gap-1",CE[i],SE[e.align||"left"],o&&"sticky top-0 z-10",w&&"sticky left-0 z-20 shadow-[2px_0_4px_-2px_rgba(0,0,0,0.1)]",o&&w&&"z-30",e.sortable&&!s&&"hover:bg-background-hover",s&&"cursor-not-allowed opacity-60",v?"font-bold text-text-primary":"font-medium text-text-secondary",x&&"bg-background-hover"),style:R,...y,...p,role:"columnheader","aria-sort":v?S==="asc"?"ascending":"descending":"none","aria-disabled":s,title:N,"data-sort-note":N,children:s?jsxRuntime.jsx(X,{className:"h-4 w-24"}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[l??jsxRuntime.jsx("span",{className:"flex-1 truncate cursor-pointer",onClick:()=>!s&&e.sortable&&r(e.id),children:e.label}),N&&jsxRuntime.jsx("span",{className:"sr-only",children:N}),e.sortable&&jsxRuntime.jsx("button",{type:"button",className:"flex flex-shrink-0 cursor-pointer",onClick:()=>!s&&r(e.id),"aria-label":`Sort by ${e.label}`,children:v?jsxRuntime.jsx(O,{name:S==="asc"?"CaretUp":"CaretDown",size:14,weight:N?"regular":"bold",className:N?"text-text-secondary opacity-40":"text-text-primary"}):jsxRuntime.jsx(O,{name:"CaretUpDown",size:12,className:"text-text-secondary opacity-40"})})]})})}function oy({columns:e,columnOrder:t,onColumnOrderChange:r,sortConfig:o,onSort:n,stickyHeader:a,stickyFirstColumn:i,density:s="default",isLoading:l=false,renderHeaderContent:c,sortNote:d}){let u=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:5}}),core.useSensor(core.KeyboardSensor,{coordinateGetter:sortable.sortableKeyboardCoordinates})),p=new Map(e.map(g=>[g.id,g])),m=g=>{let{active:x,over:b}=g;if(b&&x.id!==b.id){let h=t.indexOf(x.id),y=t.indexOf(b.id);if(p.get(b.id)?.reorderable===false)return;let S=0;for(let P=0;P<t.length&&p.get(t[P])?.reorderable===false;P++)S=P+1;if(y<S)return;let w=Math.min(h,y),N=Math.max(h,y);for(let P=w;P<=N;P++){if(P===h)continue;if(p.get(t[P])?.reorderable===false)return}let R=sortable.arrayMove(t,h,y);r(R);}},f=t.map(g=>p.get(g)).filter(g=>g!==void 0);return jsxRuntime.jsx(core.DndContext,{sensors:u,collisionDetection:core.closestCenter,onDragEnd:m,children:jsxRuntime.jsx(sortable.SortableContext,{items:t,strategy:sortable.horizontalListSortingStrategy,children:jsxRuntime.jsx("div",{className:"contents",role:"rowgroup",children:f.map((g,x)=>jsxRuntime.jsx(NE,{column:g,sortConfig:o,onSort:n,stickyHeader:a,stickyFirstColumn:i,isFirstColumn:x===0,density:s,isLoading:l,headerContent:c?.(g),sortNote:d},g.id))})})})}var hc="__select",ME=new Set,Zp={compact:"py-1.5 px-3 text-sm",default:"py-3 px-4 text-sm",relaxed:"py-4 px-4 text-base"},_p={left:"text-left justify-start",center:"text-center justify-center",right:"text-right justify-end"},LE={full:"w-full",auto:"w-auto inline-block",contained:"w-full max-w-6xl mx-auto"},DE={auto:"table-auto",fixed:"table-fixed",responsive:"table-auto"};function $p(e){let t={};return e.width!==void 0&&(t.width=typeof e.width=="number"?`${e.width}px`:e.width),e.minWidth!==void 0&&(t.minWidth=typeof e.minWidth=="number"?`${e.minWidth}px`:e.minWidth),e.maxWidth!==void 0&&(t.maxWidth=typeof e.maxWidth=="number"?`${e.maxWidth}px`:e.maxWidth),e.flex!==void 0&&(t.flex=`${e.flex} 1 0`),t}function AE(e,t){return t.accessor?typeof t.accessor=="function"?t.accessor(e):e[t.accessor]:null}function IE({column:e,sortConfig:t,onSort:r,stickyHeader:o,stickyFirstColumn:n,isFirstColumn:a,density:i="default",isLoading:s=false,headerContent:l,sortNote:c}){let d=t?.columnId===e.id,u=d?t.direction:null,p=n&&a,m=d?c:void 0;return jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex items-center border-b border-border-default bg-background-surface",e.sortable?"gap-2":"gap-1",Zp[i],_p[e.align||"left"],o&&"sticky top-0 z-10",p&&"sticky left-0 z-20 shadow-[2px_0_4px_-2px_rgba(0,0,0,0.1)]",o&&p&&"z-30",e.sortable&&!s&&"cursor-pointer hover:bg-background-hover",s&&"cursor-not-allowed opacity-60",d?"font-bold text-text-primary":"font-medium text-text-secondary"),onClick:()=>!s&&e.sortable&&r(e.id),role:"columnheader","aria-sort":d?u==="asc"?"ascending":"descending":"none","aria-disabled":s,title:m,"data-sort-note":m,style:$p(e),children:s?jsxRuntime.jsx(X,{className:"h-4 w-24"}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[l??jsxRuntime.jsx("span",{className:"truncate",children:e.label}),m&&jsxRuntime.jsx("span",{className:"sr-only",children:m}),e.sortable&&jsxRuntime.jsx("div",{className:"flex flex-shrink-0",children:d?jsxRuntime.jsx(O,{name:u==="asc"?"CaretUp":"CaretDown",size:14,weight:m?"regular":"bold",className:m?"text-text-secondary opacity-40":"text-text-primary"}):jsxRuntime.jsx(O,{name:"CaretUpDown",size:12,className:"text-text-secondary opacity-40"})})]})})}function FE({column:e,row:t,rowIndex:r,columnIndex:o,isHovered:n,isSelected:a,density:i="default",className:s,stickyFirstColumn:l}){let c=l&&o===0,d=AE(t,e),u={isLoading:false,isHovered:n,...a===void 0?{}:{isSelected:a},rowIndex:r,columnIndex:o,density:i},p;if(e.cell){let m=e.cell,f=typeof e.cellProps=="function"?e.cellProps(d,t):e.cellProps;p=jsxRuntime.jsx(m,{value:d,row:t,context:u,...f});}else e.render?p=e.render(d,t,u):p=jsxRuntime.jsx("span",{className:"truncate",children:d?.toString()??""});if(e.popover){let m=e.popover,f,g="top",x=false,b="hover";typeof m=="string"?f=m:typeof m=="function"?f=m(d,t):(f=typeof m.content=="function"?m.content(d,t):m.content,g=m.placement||"top",x=m.showArrow??false,b=m.trigger||"hover"),p=jsxRuntime.jsxs(reactAriaComponents.DialogTrigger,{...b==="hover"?{trigger:"longPress"}:{},children:[jsxRuntime.jsx("div",{className:"cursor-help",children:p}),jsxRuntime.jsx(yt,{placement:g,showArrow:x,children:jsxRuntime.jsx("div",{className:"p-2",children:f})})]});}return jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex items-center border-b border-border-default bg-background-surface",e.noCellPadding?"":Zp[i],_p[e.align||"left"],c&&"sticky left-0 z-10 shadow-[2px_0_4px_-2px_rgba(0,0,0,0.1)]",s),role:"cell",style:$p(e),children:p})}function BE({column:e,rowIndex:t,columnIndex:r,density:o="default",stickyFirstColumn:n}){let a=n&&r===0,i={isLoading:true,rowIndex:t,columnIndex:r,density:o},s;if(e.cell){let l=e.cell,c=typeof e.cellProps=="function"?e.cellProps(null,{}):e.cellProps;s=jsxRuntime.jsx(l,{value:null,row:{},context:i,...c});}else e.render?s=e.render(null,{},i):s=jsxRuntime.jsx(X,{className:"h-4 w-full max-w-[200px]"});return jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex items-center border-b border-border-default bg-background-surface",e.noCellPadding?"":Zp[o],_p[e.align||"left"],a&&"sticky left-0 z-10 shadow-[2px_0_4px_-2px_rgba(0,0,0,0.1)]"),role:"cell",style:$p(e),children:s})}function VE(e,t){let r=new Set(["BUTTON","A","INPUT","SELECT","TEXTAREA"]),o=new Set(["button","link","checkbox","switch","menuitem","option"]),n=e;for(;n&&n!==t;){if(r.has(n.tagName))return true;let a=n.getAttribute("role");if(a&&o.has(a))return true;n=n.parentElement;}return false}function ny({columns:e,row:t,rowIndex:r,density:o="default",onClick:n,stickyFirstColumn:a,isSelected:i}){let[s,l]=qe.useState(false),c=qe.useCallback(d=>{if(!n)return;let u=d.target,p=d.currentTarget;VE(u,p)||n(t);},[n,t]);return jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("contents group",n&&"cursor-pointer"),role:"row","aria-selected":i===void 0?void 0:i,onClick:c,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),children:e.map((d,u)=>jsxRuntime.jsx(FE,{column:d,row:t,rowIndex:r,columnIndex:u,isHovered:s,isSelected:i,density:o,className:tailwindMerge.twMerge(n?"group-hover:bg-background-hover":"",i&&"bg-background-selected"),stickyFirstColumn:a},d.id))})}function ay({columns:e,rowIndex:t,density:r="default",stickyFirstColumn:o}){return jsxRuntime.jsx("div",{className:"contents",role:"row",children:e.map((n,a)=>jsxRuntime.jsx(BE,{column:n,rowIndex:t,columnIndex:a,density:r,stickyFirstColumn:o},n.id))})}function iy({columns:e,data:t,className:r,density:o="default",width:n="full",height:a,maxHeight:i,layout:s="auto",mobileRenderer:l="auto",customMobileRowRender:c,mobileBreakpoint:d="md",isLoading:u=false,loadingState:p,loadingRowCount:m=5,onLoadMore:f,hasMore:g=false,enableVirtualization:x,estimatedRowHeight:b,loadingIndicator:h,stickyHeader:y=false,stickyFirstColumn:v=false,onRowClick:S,getRowId:w,selectedRowIds:N,onSelectionChange:R,selectionMode:P="multi",hideHeader:E=false,sortConfig:I,onSort:T,sortNote:D,"aria-label":M,enableColumnReorder:B=false,columnOrder:z,onColumnOrderChange:V}){let U=R!==void 0,Z=N??ME,G=qe.useCallback((te,pe)=>{if(w)return w(te);let Q=te.id;return typeof Q=="string"&&Q.length>0?Q:typeof Q=="number"&&Number.isFinite(Q)?String(Q):`row-${pe}`},[w]),J=qe.useMemo(()=>t.map((te,pe)=>G(te,pe)),[t,G]),W=qe.useCallback((te,pe)=>{if(!R)return;if(P==="single"){R(pe?new Set([te]):new Set);return}let Q=new Set(Z);pe?Q.add(te):Q.delete(te),R(Q);},[R,Z,P]),A=J.filter(te=>Z.has(te)).length,Y=J.length>0&&A===J.length,k=A>0&&!Y,C=qe.useCallback(te=>{if(!R)return;let pe=new Set(Z);for(let Q of J)te?pe.add(Q):pe.delete(Q);R(pe);},[R,J,Z]),L=qe.useMemo(()=>U?[{id:hc,label:"",width:44,align:"center",sortable:false,reorderable:false,exportable:false,mobile:false,render:(pe,Q,De)=>{let mo=G(Q,De.rowIndex);return jsxRuntime.jsx(dc,{value:void 0,row:Q,context:De,isSelected:Z.has(mo),onSelect:(Is,Io)=>W(mo,Io)})}},...e]:e,[e,U,Z,G,W]),F=U&&P==="multi"?jsxRuntime.jsx(eo,{isSelected:Y,isIndeterminate:k,onChange:te=>C(te),isDisabled:J.length===0,"aria-label":Y?"Deselect all rows on this page":"Select all rows on this page"}):void 0,j=qe.useCallback(te=>te.id===hc?F:void 0,[F]),[ne,ce]=qe.useState(null),ee=I!==void 0,ae=ee?I:ne,Le=qe.useRef(null),ge=qe.useMemo(()=>L.map(te=>te.id),[L]),[xe,re]=qe.useState(ge),ie=z!==void 0,ve=ie?z:xe;qe.useEffect(()=>{ie||re(te=>{let pe=L.map(Io=>Io.id),Q=new Set(pe),De=new Set(te),mo=te.filter(Io=>Q.has(Io)),Is=pe.filter(Io=>!De.has(Io));return [...mo,...Is]});},[L,ie]);let Xe=qe.useCallback(te=>{ie||re(te),V?.(te);},[ie,V]),Qe=qe.useMemo(()=>{if(!B&&!z)return L;let te=new Map(L.map(De=>[De.id,De])),pe=ve.map(De=>te.get(De)).filter(De=>De!==void 0),Q=te.get(hc);return Q&&!pe.some(De=>De.id===hc)?[Q,...pe]:pe},[L,ve,B,z]),wr=$o({items:t,onLoadMore:f,hasMore:g,isLoading:u,loadingState:p,enableVirtualization:x,estimatedItemSize:b||(o==="compact"?40:o==="relaxed"?60:48),overscan:5}),Dt=f?wr:null,Nr=Dt?.scrollRef??Le,{loadMoreRef:kr,virtualizer:xt,virtualItems:Zt,isLoadingMore:_,computedLoadingState:Ge}=Dt||{},{gridTemplateColumns:_e,totalMinWidth:oe}=qe.useMemo(()=>{let te=0;return {gridTemplateColumns:Qe.map(Q=>{if(Q.minWidth?te+=typeof Q.minWidth=="number"?Q.minWidth:0:Q.width&&typeof Q.width=="number"&&(te+=Q.width),Q.width)return typeof Q.width=="number"?`${Q.width}px`:Q.width;if(Q.flex)return `${Q.flex}fr`;if(Q.minWidth&&Q.maxWidth){let De=typeof Q.minWidth=="number"?`${Q.minWidth}px`:Q.minWidth,mo=typeof Q.maxWidth=="number"?`${Q.maxWidth}px`:Q.maxWidth;return `minmax(${De}, ${mo})`}return Q.minWidth?`minmax(${typeof Q.minWidth=="number"?`${Q.minWidth}px`:Q.minWidth}, 1fr)`:Q.maxWidth?`minmax(0, ${typeof Q.maxWidth=="number"?`${Q.maxWidth}px`:Q.maxWidth})`:"1fr"}).join(" "),totalMinWidth:te}},[Qe]),ke=qe.useCallback(te=>{if(!L.find(De=>De.id===te)?.sortable)return;let Q;ae?.columnId===te?Q={columnId:te,direction:ae.direction==="asc"?"desc":"asc"}:Q={columnId:te,direction:"asc"},ee||ce(Q),T?.(Q);},[L,ae,T,ee]),K=Ge==="loading"||u&&t.length===0,H={};a?(H.height=typeof a=="number"?`${a}px`:a,H.overflowY="auto"):i?(H.maxHeight=typeof i=="number"?`${i}px`:i,H.overflowY="auto"):f&&(H.height="600px",H.overflowY="auto");let de=tailwindMerge.twMerge(LE[n],!f&&(s==="responsive"?"overflow-x-auto scrollbar-visible":"overflow-auto scrollbar-visible"),r),se=ey(d),ue=l!=="none",Te=(te,pe)=>ue?l==="custom"&&c?c(te,pe):jsxRuntime.jsx(l==="cards"?bc:gc,{row:te,columns:Qe,density:o,isLoading:u,onClick:S?()=>S(te):void 0}):null,$e=xt?Zt?.map(te=>({virtualItem:te,row:t[te.index],index:te.index}))||[]:t.map((te,pe)=>({row:te,index:pe,virtualItem:null}));return jsxRuntime.jsxs("div",{ref:Nr,className:de,style:{...H,position:xt?"relative":void 0},children:[jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("grid border-separate border-spacing-0",DE[s],n==="auto"?"inline-grid w-auto":"w-full",ue&&se.desktop),role:"table","aria-label":M,style:{gridTemplateColumns:_e,minWidth:oe>0?`${oe}px`:void 0},children:[!E&&(B?jsxRuntime.jsx(oy,{columns:L,columnOrder:ve,onColumnOrderChange:Xe,sortConfig:ae,onSort:ke,stickyHeader:y,stickyFirstColumn:v,density:o,isLoading:K,renderHeaderContent:j,sortNote:D}):jsxRuntime.jsx("div",{className:"contents",role:"rowgroup",children:Qe.map((te,pe)=>jsxRuntime.jsx(IE,{column:te,sortConfig:ae,onSort:ke,stickyHeader:y,stickyFirstColumn:v,isFirstColumn:pe===0,density:o,isLoading:K,headerContent:j(te),sortNote:D},te.id))})),xt?jsxRuntime.jsx("div",{className:"col-span-full",style:{gridColumn:"1 / -1",height:`${xt.getTotalSize()}px`,position:"relative"},role:"rowgroup",children:K?Array.from({length:m}).map((te,pe)=>jsxRuntime.jsx("div",{className:"contents",children:jsxRuntime.jsx(ay,{columns:Qe,rowIndex:pe,density:o,stickyFirstColumn:v})},`loading-${pe}`)):t.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[$e.map(({row:te,index:pe,virtualItem:Q})=>{if(!te||!Q)return null;let De=w?w(te):`row-${pe}`;return jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",display:"grid",gridTemplateColumns:_e,transform:`translateY(${Q.start}px)`},"data-index":Q.index,ref:xt.measureElement,children:jsxRuntime.jsx(ny,{columns:Qe,row:te,rowIndex:pe,density:o,onClick:S,stickyFirstColumn:v,isSelected:U?Z.has(G(te,pe)):void 0})},De)}),_&&jsxRuntime.jsx("div",{style:{position:"absolute",top:`${xt.getTotalSize()}px`,left:0,width:"100%"},children:h||jsxRuntime.jsx(Ur,{state:"loading-more"})})]}):jsxRuntime.jsx("div",{className:"py-12 text-center text-text-secondary",children:"No data available"})}):jsxRuntime.jsx("div",{className:"contents",role:"rowgroup",children:K?Array.from({length:m}).map((te,pe)=>jsxRuntime.jsx(ay,{columns:Qe,rowIndex:pe,density:o,stickyFirstColumn:v},`loading-${pe}`)):t.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[$e.map(({row:te,index:pe})=>{if(!te)return null;let Q=w?w(te):`row-${pe}`;return jsxRuntime.jsx(ny,{columns:Qe,row:te,rowIndex:pe,density:o,onClick:S,stickyFirstColumn:v,isSelected:U?Z.has(G(te,pe)):void 0},Q)}),_&&jsxRuntime.jsx("div",{className:"col-span-full",style:{gridColumn:"1 / -1"},children:h||jsxRuntime.jsx(Ur,{state:"loading-more"})})]}):jsxRuntime.jsx("div",{className:"col-span-full py-12 text-center text-text-secondary",role:"row",children:jsxRuntime.jsx("div",{role:"cell",children:"No data available"})})})]}),ue&&jsxRuntime.jsx("div",{className:se.mobile,children:K?Array.from({length:m}).map((te,pe)=>jsxRuntime.jsx(ty,{density:o},`mobile-loading-${pe}`)):t.length>0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[$e.map(({row:te,index:pe})=>{if(!te)return null;let Q=w?w(te):`mobile-row-${pe}`;return jsxRuntime.jsx("div",{className:"border-b border-border-default last:border-b-0",children:Te(te,pe)},Q)}),_&&(h||jsxRuntime.jsx(Ur,{state:"loading-more"}))]}):jsxRuntime.jsx("div",{className:"py-12 text-center text-text-secondary",children:"No data available"})}),f&&g&&!K&&(xt?jsxRuntime.jsx("div",{ref:kr,style:{position:"absolute",top:`${xt.getTotalSize()}px`,left:0,width:"100%",height:1}}):jsxRuntime.jsx("div",{ref:kr,className:"h-px w-full"}))]})}function ly({status:e,alertCount:t,showCount:r=false,isLoading:o,size:n="sm",shape:a="pill",...i}){if(o)return jsxRuntime.jsx(X,{className:"inline-flex h-6 w-20"});let s={healthy:"success",warning:"warning",error:"error",unknown:"neutral"},l={healthy:"Healthy",warning:"Warning",error:"Error",unknown:"Unknown"},c=e==="warning"||e==="error",d=r&&t?`${l[e]} (${t})`:l[e];return jsxRuntime.jsx(ft,{variant:s[e],size:n,shape:a,dot:c,dotPulse:c,...i,children:d})}var zE={battery:"BatteryHigh",charger:"ChargingStation",thermostat:"ThermometerSimple",inverter:"Power",vehicle:"Car",water_heater:"DropHalfBottom",meter:"Gauge",gateway:"WifiHigh",other:"Cube",unknown:"Question"},HE={battery:"Battery",charger:"Charger",thermostat:"Thermostat",inverter:"Inverter",vehicle:"Vehicle",water_heater:"Water Heater",meter:"Meter",gateway:"Gateway",other:"Other",unknown:"Unknown"};function dy({deviceType:e,iconName:t,size:r="md",showLabel:o=false,className:n}){let a=t||(e?zE[e]:"Question"),i=e?HE[e]:void 0;return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("inline-flex items-center",o?"flex-col gap-1":"gap-0",n),children:[jsxRuntime.jsx(O,{name:a,size:r}),o&&i&&jsxRuntime.jsx("span",{className:"text-xs text-text-secondary",children:i})]})}function ss({children:e,title:t,headerContent:r,titleAlign:o="left",hideCloseIcon:n=false,hasBackArrow:a=false,onBack:i,isOpen:s,slideInFrom:l="right",transparentOverlay:c=false,onClose:d,className:u,primaryAction:p,secondaryAction:m,tertiaryAction:f,footerContent:g,contentPadding:x=true,maxWidth:b="400px"}){if(!s)return null;let h=t||r,y=p||m||f||g;return jsxRuntime.jsx($r,{children:jsxRuntime.jsx(Tr,{isOpen:s,onOpenChange:v=>!v&&d?.(),isDismissable:true,transparent:c,children:jsxRuntime.jsx(reactAriaComponents.Modal,{className:"outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0",children:jsxRuntime.jsxs(reactAriaComponents.Dialog,{className:tailwindMerge.twMerge("fixed top-0 bottom-0 flex flex-col bg-background-surface shadow-xl overflow-hidden",l==="right"?"right-0":"left-0",l==="right"?"animate-in slide-in-from-right duration-300 ease-out":"animate-in slide-in-from-left duration-300 ease-out","data-[exiting]:animate-out",l==="right"?"data-[exiting]:slide-out-to-right":"data-[exiting]:slide-out-to-left","data-[exiting]:duration-200 data-[exiting]:ease-in","outline-none focus-visible:outline focus-visible:outline-2 focus-visible:outline-action-default focus-visible:outline-offset-0",u),style:{maxWidth:b,width:"100%"},children:[h&&(a&&i?jsxRuntime.jsx(_t,{title:t,headerContent:r,titleAlign:o,hideCloseIcon:n,hasBackArrow:true,onBack:i,onClose:d}):jsxRuntime.jsx(_t,{title:t,headerContent:r,titleAlign:o,hideCloseIcon:n,onClose:d})),jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("flex-1 overflow-y-auto overscroll-contain",x?"px-6 py-6":"p-0"),children:e}),y&&jsxRuntime.jsx(Zo,{primaryAction:p,secondaryAction:m,tertiaryAction:f,footerContent:g})]})})})})}ss.displayName="Drawer";function py({status:e,programName:t,isLoading:r,size:o="sm",shape:n="pill",...a}){if(r)return jsxRuntime.jsx(X,{className:"inline-flex h-6 w-20"});let i={enrolled:"success",eligible:"info",pending:"warning",not_eligible:"neutral",opted_out:"neutral"},s={enrolled:"Enrolled",eligible:"Eligible",pending:"Pending",not_eligible:"Not Eligible",opted_out:"Opted Out"},l=jsxRuntime.jsx(ft,{variant:i[e],size:o,shape:n,...a,children:s[e]});return t?jsxRuntime.jsx(dr,{content:t,children:l}):l}function fy({value:e,onChange:t,onUrlChange:r,accept:o="image/*",maxSize:n,isDisabled:a=false,onUpload:i,className:s,showPreview:l=true,placeholder:c="Drop files here or click to browse"}){let[d,u]=qe.useState(false),[p,m]=qe.useState(false),[f,g]=qe.useState(null),[x,b]=qe.useState(e),h=qe.useRef(null),y=async w=>{if(g(null),n&&w.size>n){g(`File size must be less than ${(n/1024/1024).toFixed(2)}MB`);return}if(l&&w.type.startsWith("image/")){let N=new FileReader;N.onloadend=()=>{b(N.result);},N.readAsDataURL(w);}if(i){m(true);try{let N=await i(w);b(N),r?.(N);}catch(N){g("Failed to upload file"),console.error("Upload error:",N);}finally{m(false);}}t?.(w,x);},v=async w=>{try{let N=w.items;if(N.length>0){let R=N[0];if(R.kind==="file"){let P=await R.getFile();P&&y(P);}}}catch(N){g("Failed to upload file"),console.error("Upload error:",N);}finally{u(false);}},S=()=>{b(void 0),g(null),t?.(null),r?.(""),h.current&&(h.current.value="");};return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("w-full",s),children:[jsxRuntime.jsxs(reactAriaComponents.DropZone,{className:tailwindMerge.twMerge("relative flex min-h-[200px] w-full flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",d?"border-action-brand bg-action-brand/5":"border-border-muted hover:border-border-default",a&&"pointer-events-none opacity-50",f&&"border-feedback-error-border bg-feedback-error-background/50"),onDrop:v,onDropEnter:()=>u(true),onDropExit:()=>u(false),children:[x?jsxRuntime.jsxs("div",{className:"relative flex h-full w-full items-center justify-center p-4",children:[l&&(x.startsWith("data:image")||x.startsWith("http"))?jsxRuntime.jsx("img",{src:x,alt:"Preview",className:"max-h-48 max-w-full rounded-md object-contain"}):jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Image,{className:"h-12 w-12 text-text-secondary"}),jsxRuntime.jsx("span",{className:"text-sm text-text-secondary",children:"File uploaded"})]}),!a&&jsxRuntime.jsx($,{variant:"icon",size:"sm",onPress:S,className:"absolute right-2 top-2 bg-background-surface shadow-md",children:jsxRuntime.jsx(lucideReact.X,{className:"h-4 w-4"})})]}):jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-4 p-6",children:[jsxRuntime.jsx(lucideReact.Upload,{className:"h-12 w-12 text-text-secondary"}),jsxRuntime.jsxs("div",{className:"text-center",children:[jsxRuntime.jsx("p",{className:"text-sm text-text-primary",children:c}),jsxRuntime.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:o==="image/*"?"PNG, JPG, GIF up to 10MB":`Accepts ${o}`})]}),jsxRuntime.jsx(reactAriaComponents.FileTrigger,{acceptedFileTypes:o.split(","),onSelect:w=>{let N=Array.from(w||[]);N.length>0&&y(N[0]);},children:jsxRuntime.jsx($,{variant:"secondary",size:"sm",isDisabled:a,children:"Choose File"})})]}),p&&jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded-lg bg-background-surface/80",children:jsxRuntime.jsxs("div",{className:"flex flex-col items-center gap-2",children:[jsxRuntime.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-action-brand border-t-transparent"}),jsxRuntime.jsx("span",{className:"text-sm text-text-secondary",children:"Uploading..."})]})})]}),f&&jsxRuntime.jsx("p",{className:"mt-2 text-sm text-feedback-error-text",children:f})]})}function by({version:e,isLatest:t,updateAvailable:r,isLoading:o,size:n="sm",shape:a="rounded",...i}){if(o)return jsxRuntime.jsx(X,{className:"inline-flex h-6 w-16"});let s="neutral",l=e;return t?s="success":r&&(s="warning",l=`${e} (Update)`),jsxRuntime.jsx(ft,{variant:s,size:n,shape:a,...i,children:l})}function ai(e){return jsxRuntime.jsx(reactAriaComponents.Form,{validationBehavior:"aria",...e,className:tailwindMerge.twMerge("flex flex-col gap-6",e.className)})}function xy({placeholder:e="Search...",value:t,onChange:r,isOpen:o,onOpenChange:n,trigger:a,children:i,showShortcutHint:s=true,showInput:l=true,className:c}){let[d,u]=qe.useState(false),p=nr("(max-width: 767px)"),m=o!==void 0?o:d,f=qe.useCallback(h=>{n?n(h):u(h);},[n]);qe.useEffect(()=>{let h=y=>{(y.metaKey||y.ctrlKey)&&y.key==="k"&&(y.preventDefault(),f(!m)),y.key==="Escape"&&m&&f(false);};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[m,f]);let g=qe.useCallback(h=>{r?.(h);},[r]),x=jsxRuntime.jsxs("button",{type:"button",className:"flex items-center gap-2 px-3 py-2 text-sm text-text-secondary hover:text-text-primary hover:bg-background-hover rounded-md transition-colors","aria-label":"Open search",children:[jsxRuntime.jsx(O,{name:"MagnifyingGlass",size:18}),!p&&s&&jsxRuntime.jsxs("span",{className:"hidden md:flex items-center gap-1 text-xs",children:[jsxRuntime.jsx("kbd",{className:"px-1.5 py-0.5 bg-background-muted border border-border-muted rounded text-xs",children:navigator.platform.includes("Mac")?"\u2318":"Ctrl"}),jsxRuntime.jsx("kbd",{className:"px-1.5 py-0.5 bg-background-muted border border-border-muted rounded text-xs",children:"K"})]})]}),b=a===null||qe.isValidElement(a)&&a.type===qe.Fragment&&!a.props.children;return p?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!b&&(a?jsxRuntime.jsx("button",{type:"button",onClick:()=>f(true),className:"appearance-none bg-transparent border-none p-0 cursor-pointer",children:a}):jsxRuntime.jsx("button",{type:"button",onClick:()=>f(true),className:"appearance-none bg-transparent border-none p-0 cursor-pointer",children:x})),jsxRuntime.jsx(vt,{isOpen:m,onClose:()=>f(false),hideCloseIcon:false,contentPadding:false,maxHeight:"90vh",children:jsxRuntime.jsxs("div",{className:"flex flex-col h-full",children:[l&&jsxRuntime.jsx("div",{className:"p-4 border-b border-border-muted flex-shrink-0",children:jsxRuntime.jsx(qr,{value:t,onChange:g,placeholder:e,showSearchIcon:true,isClearable:!!t,onClear:()=>r?.(""),reserveErrorSpace:false,className:c,autoFocus:true})}),jsxRuntime.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:i})]})})]}):b?null:jsxRuntime.jsxs(reactAriaComponents.DialogTrigger,{isOpen:m,onOpenChange:f,children:[a||x,jsxRuntime.jsx(yt,{placement:"bottom",className:"w-[600px] max-w-[90vw] bg-background-surface shadow-xl border border-border-default rounded-lg overflow-hidden",children:jsxRuntime.jsxs("div",{className:"flex flex-col",children:[l&&jsxRuntime.jsx("div",{className:"p-4 border-b border-border-muted",children:jsxRuntime.jsx(qr,{value:t,onChange:g,placeholder:e,showSearchIcon:true,isClearable:!!t,onClear:()=>r?.(""),reserveErrorSpace:false,className:c,autoFocus:true})}),jsxRuntime.jsx("div",{className:"max-h-[500px] overflow-hidden",children:i})]})})]})}function Cy({placeholder:e="Search...",value:t,onChange:r,isOpen:o,onOpenChange:n,children:a,maxHeight:i="400px",variant:s="default",className:l}){let[c,d]=qe.useState(false),u=nr("(max-width: 767px)"),p=qe.useRef(null),m=qe.useRef(null),f=o!==void 0?o:c,g=qe.useCallback(E=>{n?n(E):d(E);},[n]);qe.useEffect(()=>{let E=I=>{(I.metaKey||I.ctrlKey)&&I.key==="k"&&(I.preventDefault(),g(!f)),I.key==="Escape"&&f&&g(false);};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[f,g]),qe.useEffect(()=>{f&&!u&&p.current&&setTimeout(()=>{p.current?.querySelector("input")?.focus();},0);},[f,u]),qe.useEffect(()=>{if(!f||u)return;let E=I=>{let T=I.target,D=p.current?.contains(T),M=m.current?.contains(T);!D&&!M&&g(false);};return document.addEventListener("mousedown",E,true),()=>document.removeEventListener("mousedown",E,true)},[f,u,g]);let x=E=>{r?.(E);},b=qe.useCallback(()=>{g(false);},[g]),h=qe.useCallback(()=>{r?.("");},[r]),[y,v]=qe.useState(null);qe.useEffect(()=>{if(f&&!u&&p.current){let E=null,I=()=>{let D=p.current?.getBoundingClientRect();D&&v({top:D.bottom+8,left:D.left,width:D.width});},T=()=>{E===null&&(E=requestAnimationFrame(()=>{I(),E=null;}));};return I(),window.addEventListener("resize",T),window.addEventListener("scroll",T,true),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,true),E!==null&&cancelAnimationFrame(E);}}},[f,u]);let S=qe.useCallback(()=>{g(true);},[g]);if(u)return jsxRuntime.jsxs("div",{className:l,children:[jsxRuntime.jsx("button",{type:"button",onClick:S,className:"flex items-center justify-center w-10 h-10 rounded-lg hover:bg-background-hover transition-colors","aria-label":"Open search",children:jsxRuntime.jsx(O,{name:"MagnifyingGlass",size:"md"})}),jsxRuntime.jsxs(vt,{isOpen:f,onClose:b,contentPadding:false,height:"80vh",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 px-4 pt-4",children:[jsxRuntime.jsx("div",{className:"flex-1",children:jsxRuntime.jsx(qr,{value:t,onChange:x,placeholder:e,showSearchIcon:true,isClearable:!!t,onClear:h,reserveErrorSpace:false,autoFocus:true})}),jsxRuntime.jsx($,{variant:"icon",onPress:b,"aria-label":"Close search",className:"flex-shrink-0",children:jsxRuntime.jsx(O,{name:"X",size:"md"})})]}),jsxRuntime.jsx("div",{className:"mt-4",children:a})]})]},"mobile");let w=E=>{let T=E.target.tagName==="INPUT";if(E.key==="ArrowDown"&&f&&T){E.preventDefault();let D=m.current?.querySelector("[data-search-result]");D&&D.focus();}},N=E=>{let I=E.target;if(!I.hasAttribute("data-search-result"))return;let D=Array.from(m.current?.querySelectorAll("[data-search-result]")||[]),M=D.indexOf(I);if(E.key==="ArrowDown"){E.preventDefault(),E.stopPropagation();let B=Math.min(M+1,D.length-1);D[B]?.focus();}else if(E.key==="ArrowUp")if(E.preventDefault(),E.stopPropagation(),M===0)p.current?.querySelector("input")?.focus();else {let B=Math.max(M-1,0);D[B]?.focus();}else E.key==="Escape"&&(E.preventDefault(),E.stopPropagation(),g(false),p.current?.querySelector("input")?.focus());},R=f&&y&&typeof document<"u"?reactDom.createPortal(jsxRuntime.jsx("div",{ref:m,style:{position:"fixed",top:`${y.top}px`,left:`${y.left}px`,width:`${y.width}px`,zIndex:9999},role:"listbox",onKeyDown:N,children:jsxRuntime.jsx("div",{className:"bg-background-surface shadow-2xl border border-border-default rounded-lg overflow-hidden animate-in fade-in zoom-in-95 duration-200",children:jsxRuntime.jsx("div",{className:"overflow-y-auto",style:{maxHeight:i},children:a})})}),document.body):null,P=s==="elevated"?"bg-background-muted/50 border-border-subtle/50 focus-within:bg-background-body focus-within:border-border-focus focus-within:shadow-md backdrop-blur-sm transition-all duration-200":"";return jsxRuntime.jsxs("div",{ref:p,className:`relative w-full ${l||""}`,onKeyDown:w,children:[jsxRuntime.jsx(qr,{value:t,onChange:x,placeholder:e,showSearchIcon:true,isClearable:!!t,onClear:()=>r?.(""),reserveErrorSpace:false,className:P,onFocus:()=>g(true)}),R]},"desktop")}function Sy({message:e="No results found",suggestion:t,icon:r="MagnifyingGlass",className:o=""}){return jsxRuntime.jsxs("div",{className:`flex flex-col items-center justify-center py-12 px-4 text-center ${o}`,children:[jsxRuntime.jsx("div",{className:"text-text-secondary mb-3",children:jsxRuntime.jsx(O,{name:r,size:48})}),jsxRuntime.jsx("p",{className:"text-base font-medium text-text-primary mb-1",children:e}),t&&jsxRuntime.jsx("p",{className:"text-sm text-text-secondary max-w-xs",children:t})]})}function Ny({count:e=3,className:t=""}){return jsxRuntime.jsx("div",{className:`flex flex-col ${t}`,children:Array.from({length:e}).map((r,o)=>jsxRuntime.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[jsxRuntime.jsx(X,{width:20,height:20,variant:"circle"}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[jsxRuntime.jsx(X,{width:"60%",height:16}),jsxRuntime.jsx(X,{width:"40%",height:12})]}),jsxRuntime.jsx(X,{width:16,height:16})]},o))})}function Ty({title:e,count:t,isLoading:r,footer:o,children:n,className:a}){return jsxRuntime.jsxs("div",{className:tailwindMerge.twMerge("flex flex-col",a),children:[jsxRuntime.jsxs("div",{className:"flex items-baseline gap-1.5 px-4 pt-4 pb-2 border-t border-border-muted first:border-t-0",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:e}),!r&&t!==void 0&&jsxRuntime.jsx("span",{className:"text-xs text-text-secondary",children:t}),r&&jsxRuntime.jsx("span",{className:"text-xs text-text-secondary animate-pulse",children:"Loading..."})]}),jsxRuntime.jsx("div",{className:"flex flex-col",children:n}),o&&jsxRuntime.jsx("div",{className:"px-4 py-2 border-t border-border-subtle",children:o})]})}function Py({id:e,title:t,subtitle:r,metadata:o,icon:n,customIcon:a,onSelect:i,isFocused:s=false,className:l,testId:c}){return jsxRuntime.jsxs("div",{role:"option",tabIndex:0,onClick:()=>{i?.(e);},onKeyDown:p=>{let m=p.currentTarget;switch(p.key){case "Enter":case " ":{p.preventDefault(),i?.(e);break}case "ArrowDown":{p.preventDefault();let f=Array.from(document.querySelectorAll("[data-search-result]")),g=f.indexOf(m);g!==-1&&g<f.length-1&&f[g+1].focus();break}case "ArrowUp":{p.preventDefault();let f=Array.from(document.querySelectorAll("[data-search-result]")),g=f.indexOf(m);if(g>0)f[g-1].focus();else {let x=document.querySelector('input[type="text"][placeholder*="Search"]');x&&x.focus();}break}case "Escape":{p.preventDefault();let f=document.querySelector('input[type="text"][placeholder*="Search"]');f&&f.focus();break}}},"data-testid":c,"data-search-result":true,className:tailwindMerge.twMerge("group flex items-center gap-3 px-4 py-3 cursor-pointer outline-none transition-colors","text-text-primary hover:bg-background-hover","focus-visible:bg-background-muted focus-visible:outline-none","data-[focused]:bg-background-hover",s&&"bg-background-hover",l),"data-focused":s||void 0,children:[a?jsxRuntime.jsx("div",{className:"flex-shrink-0",children:a}):n?jsxRuntime.jsx("div",{className:"flex-shrink-0 text-text-secondary",children:jsxRuntime.jsx(O,{name:n,size:20})}):null,jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-baseline gap-2",children:[jsxRuntime.jsx("span",{className:"font-medium text-text-primary truncate",children:t}),o&&jsxRuntime.jsx("span",{className:"text-xs text-text-secondary flex-shrink-0",children:o})]}),r&&jsxRuntime.jsx("div",{className:"text-sm text-text-secondary truncate mt-0.5",children:r})]}),jsxRuntime.jsx("div",{className:"flex-shrink-0 opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100 group-data-[focused]:opacity-100 transition-opacity",children:jsxRuntime.jsx(O,{name:"ArrowRight",size:16,className:"text-text-secondary"})})]})}function Ry({children:e,maxHeight:t="400px",className:r}){return jsxRuntime.jsx("div",{className:tailwindMerge.twMerge("overflow-y-auto overscroll-contain","divide-y divide-border-muted",r),style:{maxHeight:t},children:e})}function My({placeholder:e="Search...",onClick:t,showShortcut:r=true,variant:o="default",className:n=""}){let a=typeof navigator<"u"&&navigator.platform.includes("Mac");return jsxRuntime.jsxs("button",{type:"button",onClick:t,className:`
|
|
29
29
|
flex items-center gap-3 w-full px-4 py-2.5 rounded-lg
|
|
30
30
|
transition-all duration-200 cursor-text
|
|
31
31
|
${{default:`
|