tokentracker-cli 0.12.1 → 0.14.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/README.md +4 -2
- package/dashboard/dist/assets/{main-CjKIAPGE.js → main-Dc116CZl.js} +3 -1
- package/dashboard/dist/brand-logos/kilo.svg +4 -0
- package/dashboard/dist/index.html +1 -1
- package/dashboard/dist/share.html +1 -1
- package/package.json +2 -2
- package/src/commands/init.js +28 -0
- package/src/commands/status.js +18 -0
- package/src/commands/sync.js +66 -2
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +397 -17
|
@@ -276,6 +276,8 @@ leaderboard.column.hermes,dashboard,LeaderboardPage,LeaderboardPage,column_herme
|
|
|
276
276
|
leaderboard.column.kiro,dashboard,LeaderboardPage,LeaderboardPage,column_kiro,"Kiro",,active
|
|
277
277
|
leaderboard.column.copilot,dashboard,LeaderboardPage,LeaderboardPage,column_copilot,"GitHub Copilot",,active
|
|
278
278
|
leaderboard.column.kimi,dashboard,LeaderboardPage,LeaderboardPage,column_kimi,"Kimi Code",,active
|
|
279
|
+
leaderboard.column.kilo-cli,dashboard,LeaderboardPage,LeaderboardPage,column_kilo_cli,"Kilo CLI",,active
|
|
280
|
+
leaderboard.column.kilo-code,dashboard,LeaderboardPage,LeaderboardPage,column_kilo_code,"Kilo Code",,active
|
|
279
281
|
limits.copilot.otelHint.title,dashboard,LimitsPage,LimitsPage,otel_hint_title,"Track Copilot token usage",,active
|
|
280
282
|
limits.copilot.otelHint.body,dashboard,LimitsPage,LimitsPage,otel_hint_body,"Limits load via your GitHub OAuth token. To also record per-token usage, enable Copilot's OpenTelemetry export and add these lines to your shell profile (~/.zshrc or ~/.bashrc):",,active
|
|
281
283
|
limits.copilot.otelHint.copy,dashboard,LimitsPage,LimitsPage,otel_hint_copy,"Copy",,active
|
|
@@ -617,7 +619,7 @@ dashboard.context_breakdown.exec_details.group_by_exit,dashboard,DashboardPage,C
|
|
|
617
619
|
${a.right}px ${a.bottom}px,
|
|
618
620
|
${a.right}px ${a.top}px,
|
|
619
621
|
${a.left}px ${a.top}px
|
|
620
|
-
)`}return p.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...i,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:s}})});function gy(t,e){t&&Object.assign(t.style,e)}const Hne={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},Wne={position:"fixed"},Gne=x.forwardRef(function(e,n){const{anchor:r,positionMethod:i="absolute",className:s,render:a,side:o="bottom",align:c="center",sideOffset:u=0,alignOffset:f=0,collisionBoundary:h="clipping-ancestors",collisionPadding:m,arrowPadding:g=5,sticky:v=!1,disableAnchorTracking:w,alignItemWithTrigger:b=!0,collisionAvoidance:_=cee,...E}=e,{store:M,listRef:T,labelsRef:R,alignItemWithTriggerActiveRef:A,selectedItemTextRef:P,valuesRef:k,initialValueRef:N,popupRef:B,setValue:L}=Wl(),z=g5(),I=mn(M,hn.open),V=mn(M,hn.mounted),W=mn(M,hn.modal),X=mn(M,hn.value),J=mn(M,hn.openMethod),F=mn(M,hn.positionerElement),G=mn(M,hn.triggerElement),Y=mn(M,hn.isItemEqualToValue),H=x.useRef(null),te=x.useRef(null),[re,ue]=x.useState(b),ce=V&&re&&J!=="touch";!V&&re!==b&&ue(b),Yt(()=>{V||(hn.scrollUpArrowVisible(M.state)&&M.set("scrollUpArrowVisible",!1),hn.scrollDownArrowVisible(M.state)&&M.set("scrollDownArrowVisible",!1))},[M,V]),x.useImperativeHandle(A,()=>ce),NE((ce||W)&&I&&J!=="touch",G);const ee=M5({anchor:r,floatingRootContext:z,positionMethod:i,mounted:V,side:o,sideOffset:u,align:c,alignOffset:f,arrowPadding:g,collisionBoundary:h,collisionPadding:m,sticky:v,disableAnchorTracking:w??ce,collisionAvoidance:_,keepMounted:!0}),le=ce?"none":ee.side,ve=ce?Wne:ee.positionerStyles,Ne=x.useMemo(()=>{const _e={};return I||(_e.pointerEvents="none"),{role:"presentation",hidden:!V,style:{...ve,..._e}}},[I,V,ve]),be=x.useMemo(()=>({open:I,side:le,align:ee.align,anchorHidden:ee.anchorHidden}),[I,le,ee.align,ee.anchorHidden]),qe=Bt(_e=>{M.set("positionerElement",_e)}),he=Xr("div",e,{ref:[n,qe],state:be,stateAttributesMapping:hu,props:[Ne,E]}),Ue=x.useRef(0),je=Bt(_e=>{if(_e.size===0&&Ue.current===0||k.current.length===0)return;const oe=Ue.current;if(Ue.current=_e.size,_e.size===oe)return;const Q=Mn(nv);if(oe!==0&&!M.state.multiple&&X!==null&&C1(k.current,X,Y)===-1){const Re=N.current,Le=Re!=null&&p_(k.current,Re,Y)?Re:null;L(Le,Q),Le===null&&(M.set("selectedIndex",null),P.current=null)}if(oe!==0&&M.state.multiple&&Array.isArray(X)){const ze=X.filter(Re=>p_(k.current,Re,Y));(ze.length!==X.length||ze.some(Re=>!p_(X,Re,Y)))&&(L(ze,Q),ze.length===0&&(M.set("selectedIndex",null),P.current=null))}if(I&&ce){M.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const ze={height:""};gy(F,ze),gy(B.current,ze)}}),et=x.useMemo(()=>({...ee,side:le,alignItemWithTriggerActive:ce,setControlledAlignItemWithTrigger:ue,scrollUpArrowRef:H,scrollDownArrowRef:te}),[ee,le,ce,ue]);return p.jsx(Nne,{elementsRef:T,labelsRef:R,onMapChange:je,children:p.jsxs(T5.Provider,{value:et,children:[V&&W&&p.jsx(DE,{inert:PE(!I),cutout:G}),he]})})});function C5(t){const e=t.currentTarget.getBoundingClientRect();return e.top+1<=t.clientY&&t.clientY<=e.bottom-1&&e.left+1<=t.clientX&&t.clientX<=e.right-1}const Mg="base-ui-disable-scrollbar",nP={className:Mg,getElement(t){return p.jsx("style",{nonce:t,href:Mg,precedence:"base-ui:low",children:`.${Mg}{scrollbar-width:none}.${Mg}::-webkit-scrollbar{display:none}`})}},$ne=x.createContext(void 0);function A5(t){return x.useContext($ne)}const R5="ArrowUp",P5="ArrowDown",N5="ArrowLeft",D5="ArrowRight",L5="Home",I5="End",Yne=new Set([N5,D5]),qne=new Set([R5,P5]),Xne=new Set([...Yne,...qne]);[...Xne];const LE=new Set([R5,P5,N5,D5,L5,I5]);function IE(t){return t==="starting"?lee:ei}function Kne(t,e=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(e,Math.min(t,n))}const Zne=x.createContext(void 0),Jne={disableStyleElements:!1};function Qne(){return x.useContext(Zne)??Jne}const ere={...hu,...df},tre=x.forwardRef(function(e,n){const{render:r,className:i,...s}=e,{store:a,popupRef:o,onOpenChangeComplete:c,setOpen:u,valueRef:f,selectedItemTextRef:h,keyboardActiveRef:m,multiple:g,handleScrollArrowVisibility:v,scrollHandlerRef:w,highlightItemOnHover:b}=Wl(),{side:_,align:E,alignItemWithTriggerActive:M,setControlledAlignItemWithTrigger:T,scrollDownArrowRef:R,scrollUpArrowRef:A}=Vne(),P=A5()!=null,k=g5(),{nonce:N,disableStyleElements:B}=Qne(),L=ji(),z=mn(a,hn.id),I=mn(a,hn.open),V=mn(a,hn.mounted),W=mn(a,hn.popupProps),X=mn(a,hn.transitionStatus),J=mn(a,hn.triggerElement),F=mn(a,hn.positionerElement),G=mn(a,hn.listElement),Y=x.useRef(0),H=x.useRef(!1),te=x.useRef(0),re=x.useRef(!1),ue=x.useRef({}),ce=Zy(),ee=Bt(be=>{if(!F||!o.current||!re.current)return;if(H.current||!M){v();return}const qe=F.style.top==="0px",he=F.style.bottom==="0px",Ue=F.getBoundingClientRect().height,je=Ga(F),et=getComputedStyle(F),_e=parseFloat(et.marginTop),oe=parseFloat(et.marginBottom),Q=rP(getComputedStyle(o.current)),ze=je.documentElement.clientHeight-_e-oe,Re=be.scrollTop,De=be.scrollHeight,Le=be.clientHeight,$=De-Le;let U=0,Z=null,pe=!1;if(qe){const Se=$-Re,xe=Ue+Se,Ie=Math.min(xe,ze);U=Ie,Ie!==ze?Z=$:pe=!0}else if(he){const Se=Re-0,xe=Ue+Se,Ie=Math.min(xe,ze),He=xe-ze;U=Ie,Ie!==ze?Z=0:(pe=!0,Re<$&&(Z=Re-(Se-He)))}U!==0&&(F.style.height=`${U}px`),Z!=null&&(be.scrollTop=Z),(pe||U>=Q)&&(H.current=!0),v()});x.useImperativeHandle(w,()=>ee,[ee]),ff({open:I,ref:o,onComplete(){I&&c?.(!0)}});const le=x.useMemo(()=>({open:I,transitionStatus:X,side:_,align:E}),[I,X,_,E]);Yt(()=>{!F||!o.current||Object.keys(ue.current).length||(ue.current={top:F.style.top||"0",left:F.style.left||"0",right:F.style.right,height:F.style.height,bottom:F.style.bottom,minHeight:F.style.minHeight,maxHeight:F.style.maxHeight,marginTop:F.style.marginTop,marginBottom:F.style.marginBottom})},[o,F]),Yt(()=>{I||M||(re.current=!1,H.current=!1,Y.current=0,te.current=0,gy(F,ue.current))},[I,M,F,o]),Yt(()=>{const be=o.current;if(!(!I||!J||!F||!be||a.state.transitionStatus==="ending")){if(!M){re.current=!0,ce.request(v),be.style.removeProperty("--transform-origin");return}queueMicrotask(()=>{const qe=rre(be);be.style.removeProperty("--transform-origin");try{const he=getComputedStyle(F),Ue=getComputedStyle(be),je=Ga(J),et=Pr(F),_e=J.getBoundingClientRect(),oe=F.getBoundingClientRect(),Q=_e.left,ze=_e.height,Re=G||be,De=Re.scrollHeight,Le=parseFloat(Ue.borderBottomWidth),$=parseFloat(he.marginTop)||10,U=parseFloat(he.marginBottom)||10,Z=parseFloat(he.minHeight)||100,pe=rP(Ue),Se=5,xe=5,Ie=20,He=je.documentElement.clientHeight-$-U,Ye=je.documentElement.clientWidth,ft=He-_e.bottom+ze,We=h.current,Xe=f.current;let nt,ct=0,Ke=0;if(We&&Xe){const _t=Xe.getBoundingClientRect();nt=We.getBoundingClientRect();const wt=_t.left-Q,un=nt.left-oe.left,xn=_t.top-_e.top+_t.height/2,ie=nt.top-oe.top+nt.height/2;ct=wt-un,Ke=ie-xn}const gt=ft+Ke+U+Le;let ne=Math.min(He,gt);const Be=He-$-U,ke=gt-ne,Ae=Math.max(Se,Q+ct),Ve=Ye-xe,ge=Math.max(0,Ae+oe.width-Ve);F.style.left=`${Ae-ge}px`,F.style.height=`${ne}px`,F.style.maxHeight="auto",F.style.marginTop=`${$}px`,F.style.marginBottom=`${U}px`,be.style.height="100%";const ut=Re.scrollHeight-Re.clientHeight,yt=ke>=ut;yt&&(ne=Math.min(He,oe.height)-(ke-ut));const qt=_e.top<Ie||_e.bottom>He-Ie||ne<Math.min(De,Z),Lt=(et.visualViewport?.scale??1)!==1&&x4;if(qt||Lt){re.current=!0,gy(F,ue.current),gi.flushSync(()=>T(!1));return}if(yt){const _t=Math.max(0,He-gt);F.style.top=oe.height>=Be?"0":`${_t}px`,F.style.height=`${ne}px`,Re.scrollTop=Re.scrollHeight-Re.clientHeight,Y.current=Math.max(Z,ne)}else F.style.bottom="0",Y.current=Math.max(Z,ne),Re.scrollTop=ke;if(nt){const _t=oe.top,wt=oe.height,un=nt.top+nt.height/2,xn=wt>0?(un-_t)/wt*100:50,ie=Kne(xn,0,100);be.style.setProperty("--transform-origin",`50% ${ie}%`)}(Y.current===He||ne>=pe)&&(H.current=!0),v(),setTimeout(()=>{re.current=!0})}finally{qe()}})}},[a,I,F,J,f,h,o,v,M,T,ce,R,A,G]),x.useEffect(()=>{if(!M||!F||!I)return;const be=Pr(F);function qe(he){u(!1,Mn(pee,he))}return be.addEventListener("resize",qe),()=>{be.removeEventListener("resize",qe)}},[u,M,F,I]);const ve={...G?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":g||void 0,id:`${z}-list`},onKeyDown(be){m.current=!0,P&&LE.has(be.key)&&be.stopPropagation()},onMouseMove(){m.current=!1},onPointerLeave(be){if(!b||C5(be)||be.pointerType==="touch")return;const qe=be.currentTarget;L.start(0,()=>{a.set("activeIndex",null),qe.focus({preventScroll:!0})})},onScroll(be){G||w.current?.(be.currentTarget)},...M&&{style:G?{height:"100%"}:Hne}},Ne=Xr("div",e,{ref:[n,o],state:le,stateAttributesMapping:ere,props:[W,ve,IE(X),{className:!G&&M?nP.className:void 0},s]});return p.jsxs(x.Fragment,{children:[!B&&nP.getElement(N),p.jsx(kE,{context:k,modal:!1,disabled:!V,restoreFocus:!0,children:Ne})]})});function rP(t){const e=t.maxHeight||"";return e.endsWith("px")&&parseFloat(e)||1/0}const iP={transform:"none",scale:"1",translate:"0 0"};function nre(t,e,n){n?t.setProperty(e,n):t.removeProperty(e)}function rre(t){const{style:e}=t,n={},r=Object.keys(iP);for(const i of r)n[i]=e.getPropertyValue(i),e.setProperty(i,iP[i]);return()=>{for(const i of r)nre(e,i,n[i])}}let O5=(function(t){return t[t.None=0]="None",t[t.GuessFromOrder=1]="GuessFromOrder",t})({});function ire(t={}){const{label:e,metadata:n,textRef:r,indexGuessBehavior:i,index:s}=t,{register:a,unregister:o,subscribeMapChange:c,elementsRef:u,labelsRef:f,nextIndexRef:h}=Pne(),m=x.useRef(-1),[g,v]=x.useState(s??(i===O5.GuessFromOrder?()=>{if(m.current===-1){const _=h.current;h.current+=1,m.current=_}return m.current}:-1)),w=x.useRef(null),b=x.useCallback(_=>{if(w.current=_,g!==-1&&_!==null&&(u.current[g]=_,f)){const E=e!==void 0;f.current[g]=E?e:r?.current?.textContent??_.textContent}},[g,u,f,e,r]);return Yt(()=>{if(s!=null)return;const _=w.current;if(_)return a(_,n),()=>{o(_)}},[s,a,o,n]),Yt(()=>{if(s==null)return c(_=>{const E=w.current?_.get(w.current)?.index:null;E!=null&&v(E)})},[s,c,v]),x.useMemo(()=>({ref:b,index:g}),[g,b])}const F5=x.createContext(void 0);function OE(){const t=x.useContext(F5);if(!t)throw new Error(Wi(57));return t}const sP=x.memo(x.forwardRef(function(e,n){const{render:r,className:i,value:s=null,label:a,disabled:o=!1,nativeButton:c=!1,...u}=e,f=x.useRef(null),h=ire({label:a,textRef:f,indexGuessBehavior:O5.GuessFromOrder}),{store:m,getItemProps:g,setOpen:v,setValue:w,selectionRef:b,typingRef:_,valuesRef:E,keyboardActiveRef:M,multiple:T,highlightItemOnHover:R}=Wl(),A=ji(),P=mn(m,hn.isActive,h.index),k=mn(m,hn.isSelected,h.index,s),N=mn(m,hn.isSelectedByFocus,h.index),B=mn(m,hn.isItemEqualToValue),L=h.index,z=L!==-1,I=x.useRef(null),V=jr(L);Yt(()=>{if(!z)return;const ee=E.current;return ee[L]=s,()=>{delete ee[L]}},[z,L,s,E]),Yt(()=>{if(!z)return;const ee=m.state.value;let le=ee;T&&Array.isArray(ee)&&ee.length>0&&(le=ee[ee.length-1]),le!==void 0&&$d(le,s,B)&&m.set("selectedIndex",L)},[z,L,T,B,m,s]);const W=x.useMemo(()=>({disabled:o,selected:k,highlighted:P}),[o,k,P]),X=g({active:P,selected:k});X.onFocus=void 0,X.id=void 0;const J=x.useRef(null),F=x.useRef("mouse"),G=x.useRef(!1),{getButtonProps:Y,buttonRef:H}=cv({disabled:o,focusableWhenDisabled:!0,native:c});function te(ee){const le=m.state.value;if(T){const ve=Array.isArray(le)?le:[],Ne=k?Zte(ve,s,B):[...ve,s];w(Ne,Mn(s_,ee))}else w(s,Mn(s_,ee)),v(!1,Mn(s_,ee))}const re={role:"option","aria-selected":k,tabIndex:P?0:-1,onFocus(){m.set("activeIndex",L)},onMouseEnter(){!M.current&&m.state.selectedIndex===null&&m.set("activeIndex",L)},onMouseMove(){R&&m.set("activeIndex",L)},onMouseLeave(ee){!R||M.current||C5(ee)||A.start(0,()=>{m.state.activeIndex===L&&m.set("activeIndex",null)})},onTouchStart(){b.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(ee){J.current=ee.key,m.set("activeIndex",L)},onClick(ee){G.current=!1,!(ee.type==="keydown"&&J.current===null)&&(o||J.current===" "&&_.current||F.current!=="touch"&&!P||(J.current=null,te(ee.nativeEvent)))},onPointerEnter(ee){F.current=ee.pointerType},onPointerDown(ee){F.current=ee.pointerType,G.current=!0},onMouseUp(ee){if(o)return;if(G.current){G.current=!1;return}const le=!b.current.allowSelectedMouseUp&&k,ve=!b.current.allowUnselectedMouseUp&&!k;le||ve||F.current!=="touch"&&!P||te(ee.nativeEvent)}},ue=Xr("div",e,{ref:[H,n,h.ref,I],state:W,props:[X,re,u,Y]}),ce=x.useMemo(()=>({selected:k,indexRef:V,textRef:f,selectedByFocus:N,hasRegistered:z}),[k,V,f,N,z]);return p.jsx(F5.Provider,{value:ce,children:ue})})),aP=x.forwardRef(function(e,n){const r=e.keepMounted??!1,{selected:i}=OE();return r||i?p.jsx(sre,{...e,ref:n}):null}),sre=x.memo(x.forwardRef((t,e)=>{const{render:n,className:r,keepMounted:i,...s}=t,{selected:a}=OE(),o=x.useRef(null),{transitionStatus:c,setMounted:u}=CE(a),f=x.useMemo(()=>({selected:a,transitionStatus:c}),[a,c]),h=Xr("span",t,{ref:[e,o],state:f,props:[{"aria-hidden":!0,children:"✔️"},s],stateAttributesMapping:df});return ff({open:a,ref:o,onComplete(){a||u(!1)}}),h})),oP=x.memo(x.forwardRef(function(e,n){const{indexRef:r,textRef:i,selectedByFocus:s,hasRegistered:a}=OE(),{selectedItemTextRef:o}=Wl(),{className:c,render:u,...f}=e,h=x.useCallback(g=>{if(!g||!a)return;const v=o.current===null||!o.current.isConnected;(s||v&&r.current===0)&&(o.current=g)},[o,r,s,a]);return Xr("div",e,{ref:[h,n,i],props:f})}));function U5({prefersReducedMotion:t,screenshotCapture:e}){return!(e||t)}function are({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z"})})}function ore({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",className:e,children:p.jsx("path",{d:"M8.086.457a6.105 6.105 0 013.046-.415c1.333.153 2.521.72 3.564 1.7a.117.117 0 00.107.029c1.408-.346 2.762-.224 4.061.366l.063.03.154.076c1.357.703 2.33 1.77 2.918 3.198.278.679.418 1.388.421 2.126a5.655 5.655 0 01-.18 1.631.167.167 0 00.04.155 5.982 5.982 0 011.578 2.891c.385 1.901-.01 3.615-1.183 5.14l-.182.22a6.063 6.063 0 01-2.934 1.851.162.162 0 00-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451-1.583-.008-2.986-.587-4.21-1.736a.145.145 0 00-.14-.032c-.518.167-1.04.191-1.604.185a5.924 5.924 0 01-2.595-.622 6.058 6.058 0 01-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74 7.74 0 01-.495-1.283 6.11 6.11 0 01-.017-3.064.166.166 0 00.008-.074.115.115 0 00-.037-.064 5.958 5.958 0 01-1.38-2.202 5.196 5.196 0 01-.333-1.589 6.915 6.915 0 01.188-2.132c.45-1.484 1.309-2.648 2.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129 0 00.087-.087A6.016 6.016 0 015.635 2.31C6.315 1.464 7.132.846 8.086.457zm-.804 7.85a.848.848 0 00-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 001.46.864l1.94-3.272a.849.849 0 00.007-.854l-1.94-3.393zm5.446 6.24a.849.849 0 000 1.695h4.848a.849.849 0 000-1.696h-4.848z"})})}function lre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M22.106 5.68L12.5.135a.998.998 0 00-.998 0L1.893 5.68a.84.84 0 00-.419.726v11.186c0 .3.16.577.42.727l9.607 5.547a.999.999 0 00.998 0l9.608-5.547a.84.84 0 00.42-.727V6.407a.84.84 0 00-.42-.726zm-.603 1.176L12.228 22.92c-.063.108-.228.064-.228-.061V12.34a.59.59 0 00-.295-.51l-9.11-5.26c-.107-.062-.063-.228.062-.228h18.55c.264 0 .428.286.296.514z"})})}function cre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z"})})}function ure({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 -1 22 28",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M4.125 20.149c-2.69 5.959 3.036 7.453 7.26 3.966 1.24 3.91 5.898.993 7.569-2.036 3.682-6.678 2.195-13.49 1.813-14.895-2.617-9.582-15.699-9.592-17.95.049-.526 1.687-.535 3.606-.833 5.598-.15 1.005-.256 1.646-.645 2.703-.223.607-.53 1.147-1.014 2.056-.75 1.412-.434 4.138 3.434 2.724v.001ZM11.895 11.332c-1.073 0-1.234-1.283-1.234-2.048 0-.69.124-1.239.358-1.586a1 1 0 0 1 .876-.462c.375 0 .697.158.924.47.259.354.395.9.395 1.578 0 1.283-.493 2.048-1.319 2.048Zm4.416 0c-1.073 0-1.234-1.283-1.234-2.048 0-.69.124-1.239.358-1.586a1 1 0 0 1 .876-.462c.375 0 .697.158.924.47.259.354.396.9.396 1.578 0 1.283-.494 2.048-1.32 2.048Z"})})}function dre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M16 6H8v12h8V6zm4 16H4V2h16v20z"})})}function fre({size:t=16,className:e=""}){return p.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:[p.jsx("path",{d:"M21.846 0a1.923 1.923 0 110 3.846H20.15a.226.226 0 01-.227-.226V1.923C19.923.861 20.784 0 21.846 0z"}),p.jsx("path",{d:"M11.065 11.199l7.257-7.2c.137-.136.06-.41-.116-.41H14.3a.164.164 0 00-.117.051l-7.82 7.756c-.122.12-.302.013-.302-.179V3.82c0-.127-.083-.23-.185-.23H3.186c-.103 0-.186.103-.186.23V19.77c0 .128.083.23.186.23h2.69c.103 0 .186-.102.186-.23v-3.25c0-.069.025-.135.069-.178l2.424-2.406a.158.158 0 01.205-.023l6.484 4.772a7.677 7.677 0 003.453 1.283c.108.012.2-.095.2-.23v-3.06c0-.117-.07-.212-.164-.227a5.028 5.028 0 01-2.027-.807l-5.613-4.064c-.117-.078-.132-.279-.028-.381z"})]})}function hre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M19.245 5.364c1.322 1.36 1.877 3.216 2.11 5.817.622 0 1.2.135 1.592.654l.73.964c.21.278.323.61.323.955v2.62c0 .339-.173.669-.453.868C20.239 19.602 16.157 21.5 12 21.5c-4.6 0-9.205-2.583-11.547-4.258-.28-.2-.452-.53-.453-.868v-2.62c0-.345.113-.679.321-.956l.73-.963c.392-.517.974-.654 1.593-.654l.029-.297c.25-2.446.81-4.213 2.082-5.52 2.461-2.54 5.71-2.851 7.146-2.864h.198c1.436.013 4.685.323 7.146 2.864zm-7.244 4.328c-.284 0-.613.016-.962.05-.123.447-.305.85-.57 1.108-1.05 1.023-2.316 1.18-2.994 1.18-.638 0-1.306-.13-1.851-.464-.516.165-1.012.403-1.044.996a65.882 65.882 0 00-.063 2.884l-.002.48c-.002.563-.005 1.126-.013 1.69.002.326.204.63.51.765 2.482 1.102 4.83 1.657 6.99 1.657 2.156 0 4.504-.555 6.985-1.657a.854.854 0 00.51-.766c.03-1.682.006-3.372-.076-5.053-.031-.596-.528-.83-1.046-.996-.546.333-1.212.464-1.85.464-.677 0-1.942-.157-2.993-1.18-.266-.258-.447-.661-.57-1.108-.32-.032-.64-.049-.96-.05zm-2.525 4.013c.539 0 .976.426.976.95v1.753c0 .525-.437.95-.976.95a.964.964 0 01-.976-.95v-1.752c0-.525.437-.951.976-.951zm5 0c.539 0 .976.426.976.95v1.753c0 .525-.437.95-.976.95a.964.964 0 01-.976-.95v-1.752c0-.525.437-.951.976-.951zM7.635 5.087c-1.05.102-1.935.438-2.385.906-.975 1.037-.765 3.668-.21 4.224.405.394 1.17.657 1.995.657h.09c.649-.013 1.785-.176 2.73-1.11.435-.41.705-1.433.675-2.47-.03-.834-.27-1.52-.63-1.813-.39-.336-1.275-.482-2.265-.394zm6.465.394c-.36.292-.6.98-.63 1.813-.03 1.037.24 2.06.675 2.47.968.957 2.136 1.104 2.776 1.11h.044c.825 0 1.59-.263 1.995-.657.555-.556.765-3.187-.21-4.224-.45-.468-1.335-.804-2.385-.906-.99-.088-1.875.058-2.265.394zM12 7.615c-.24 0-.525.015-.84.044.03.16.045.336.06.526l-.001.159a2.94 2.94 0 01-.014.25c.225-.022.425-.027.612-.028h.366c.187 0 .387.006.612.028-.015-.146-.015-.277-.015-.409.015-.19.03-.365.06-.526a9.29 9.29 0 00-.84-.044z"})})}function pre({size:t=16,className:e=""}){return p.jsxs("svg",{width:t,height:t,viewBox:"0 0 64 60",fill:"none",className:e,"aria-hidden":"true",children:[p.jsx("path",{fill:"currentColor",d:"M37.2114 3.75318C37.6821 3.33106 37.7106 3.31457 38.0558 3.29385C38.6149 3.2531 39.1272 3.52199 39.9989 4.31564C42.0356 6.16652 44.8714 9.97183 46.6346 13.2212L47.3163 14.4819L48.2782 14.9605C49.2072 15.4299 50.7308 16.3923 51.3672 16.9085C51.655 17.1464 51.6956 17.1508 51.9947 17.0344C53.3454 16.5084 55.2803 17.206 56.9869 18.8432C58.5231 20.3155 59.9943 22.8312 60.558 24.9308C60.6403 25.2687 60.7493 25.9952 60.7891 26.5362C60.9177 28.4358 60.3092 29.9532 59.1362 30.64C58.8965 30.7784 58.8801 30.8158 58.8868 31.4132C58.9409 34.2583 58.1741 37.0985 56.6335 39.8679C54.8946 42.9773 51.7981 46.1938 47.6074 49.2243C45.357 50.8619 40.0323 53.964 37.6248 55.0532C31.8578 57.6496 27.2346 58.646 23.2188 58.154C20.8236 57.8638 18.1124 56.9287 16.5082 55.8433C16.086 55.5515 16.0191 55.5329 15.6966 55.6251C13.9793 56.1185 11.73 55.1053 9.81931 52.9844C9.05725 52.1366 7.82714 50.0548 7.42839 48.9409C6.50606 46.3339 6.68976 43.9816 7.91836 42.5767C8.23573 42.2149 8.2453 42.1995 8.17598 41.5912C8.06148 40.5951 8.00971 39.1206 8.06202 38.1692L8.10361 37.2803L6.76977 34.9212C4.70378 31.2451 3.3912 28.1582 2.88489 25.7998C2.61762 24.5066 2.63385 23.9324 2.96214 23.5078C3.16198 23.2515 3.81796 22.9866 4.60785 22.8407C6.59665 22.4917 10.9334 22.8076 15.7581 23.6595L16.259 23.7458L17.3608 22.7713C19.1891 21.1519 20.4038 20.244 22.6429 18.8478C24.9768 17.3876 27.6108 16.1858 30.577 15.2346L31.5295 14.9294L32.0526 13.5561C33.9257 8.61146 35.8437 4.96584 37.2114 3.75318ZM21.5208 29.0919C19.404 30.314 18.3453 30.9251 17.5676 31.6099C14.4179 34.3835 13.2414 38.777 14.5823 42.7537C14.9135 43.7357 15.5247 44.7942 16.7469 46.9111C17.9691 49.0279 18.5801 50.0865 19.2649 50.8643C22.0385 54.014 26.4316 55.1918 30.4084 53.8509C31.3904 53.5198 32.4489 52.9085 34.5657 51.6863L46.7442 44.6551C48.8613 43.4328 49.9205 42.8214 50.6983 42.1365C53.8479 39.363 55.0245 34.9695 53.6835 30.9927C53.3524 30.0107 52.7412 28.9522 51.519 26.8354C50.2968 24.7185 49.6858 23.66 49.0009 22.8822C46.2274 19.7325 41.8342 18.5547 37.8575 19.8956C36.8754 20.2267 35.8163 20.8383 33.6993 22.0606L21.5208 29.0919Z"}),p.jsx("g",{transform:"rotate(-30 22.6953 37.6011)",children:p.jsx("rect",{x:"22.6953",y:"37.6011",width:"4.81084",height:"9.99175",rx:"2.40542",fill:"currentColor"})}),p.jsx("g",{transform:"rotate(-30 35.6748 30.1074)",children:p.jsx("rect",{x:"35.6748",y:"30.1074",width:"4.81084",height:"9.99175",rx:"2.40542",fill:"currentColor"})})]})}function mre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",className:e,children:p.jsx("path",{d:"M7 2h10a5 5 0 015 5v10a5 5 0 01-5 5H7a5 5 0 01-5-5V7a5 5 0 015-5zm0 4.5v11h2.35v-4.55h5.3V17.5H17v-11h-2.35v4.1h-5.3V6.5H7z"})})}function gre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"currentColor",className:e,children:p.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"})})}function yre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":"true",children:p.jsx("g",{transform:"translate(3.4502, 3)",fill:"#9570BE",children:p.jsx("path",{d:"M3.17890888,3.6 L3.17890888,0 L16,0 L16,3.6 L3.17890888,3.6 Z M9.642,7.2 L9.64218223,10.8 L0,10.8 L0,3.6 L16,3.6 L16,7.2 L9.642,7.2 Z M3.17890888,18 L3.178,14.4 L0,14.4 L0,10.8 L16,10.8 L16,18 L3.17890888,18 Z",fillRule:"nonzero"})})})}function vre({size:t=16,className:e=""}){return p.jsxs("svg",{width:t,height:t,viewBox:"0 0 120 90",fill:"currentColor",className:e,children:[p.jsx("rect",{x:"10",y:"8",width:"100",height:"12",rx:"2"}),p.jsx("rect",{x:"25",y:"20",width:"12",height:"62",rx:"2"}),p.jsx("rect",{x:"75",y:"20",width:"12",height:"45",rx:"2"}),p.jsx("rect",{x:"71",y:"55",width:"20",height:"16",rx:"3"}),p.jsx("rect",{x:"76",y:"71",width:"3",height:"8",rx:"1"}),p.jsx("rect",{x:"82",y:"71",width:"3",height:"8",rx:"1"})]})}function xre({size:t=16,className:e=""}){return p.jsxs("svg",{width:t,height:t,viewBox:"0 0 120 90",fill:"currentColor",className:e,children:[p.jsx("rect",{x:"10",y:"8",width:"100",height:"12",rx:"2"}),p.jsx("rect",{x:"25",y:"20",width:"12",height:"62",rx:"2"}),p.jsx("rect",{x:"83",y:"20",width:"12",height:"62",rx:"2"})]})}const bre={CLAUDE:are,CODEBUDDY:pre,CODEX:ore,COPILOT:hre,CRAFT:yre,CURSOR:lre,GEMINI:cre,GITHUB:gre,HERMES:mre,KIMI:fre,KIRO:ure,OPENCODE:dre,OMP:vre,PI:xre},_re={ANTIGRAVITY:"/brand-logos/antigravity.svg",CLAUDE:"/brand-logos/claude-code.svg",CODEX:"/brand-logos/codex.svg",GEMINI:"/brand-logos/gemini.svg",HERMES:"/brand-logos/hermes.svg",OPENCLAW:"/brand-logos/openclaw.svg",OPENCODE:"/brand-logos/opencode.svg"};function nu({provider:t,size:e=16,color:n,className:r=""}){const i=t?.toUpperCase?.()||"",s=_re[i];if(s)return p.jsx("img",{src:s,alt:"",width:e,height:e,className:r,style:{width:e,height:e,objectFit:"contain"},"aria-hidden":!0});const a=bre[i];return a?p.jsx(a,{size:e,className:r}):p.jsx("div",{className:"rounded-full shrink-0",style:{width:e*.5,height:e*.5,backgroundColor:n}})}function pu({children:t,title:e,subtitle:n,className:r="",bodyClassName:i=""}){return p.jsxs("div",{className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 transition-colors duration-200 ${r}`,children:[(e||n)&&p.jsxs("div",{className:"px-5 py-4 border-b border-oai-gray-200 dark:border-oai-gray-800 transition-colors duration-200",children:[e&&p.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide transition-colors duration-200",children:e}),n&&p.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300 mt-1 transition-colors duration-200",children:n})]}),p.jsx("div",{className:`p-5 ${i}`,children:t})]})}function wre(){return p.jsxs(Ei,{to:"/landing",className:"flex items-center gap-2.5 no-underline hover:opacity-80 transition-opacity",children:[p.jsx("img",{src:"/app-icon.png",alt:"Token Tracker",width:28,height:28,className:"rounded-md"}),p.jsx("span",{className:"text-base font-semibold text-oai-black dark:text-oai-white leading-tight",children:"Token Tracker"})]})}function Sre({children:t,header:e,footer:n,className:r="",hideHeader:i=!1,hideFooter:s=!1,bare:a=!1}){return a?p.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${r}`,children:[p.jsx("main",{className:"flex-1 px-6 py-6",children:t}),!s&&n&&p.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 mt-auto transition-colors duration-200",children:n})]}):p.jsxs("div",{className:`min-h-screen bg-oai-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-white font-sans flex flex-col transition-colors duration-200 ${r}`,children:[!i&&p.jsxs("header",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 flex items-center justify-between transition-colors duration-200",children:[p.jsx(wre,{}),p.jsx("div",{className:"flex-1 flex justify-center",children:e})]}),p.jsx("main",{className:"flex-1 px-6 py-6",children:t}),!s&&n&&p.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 mt-auto transition-colors duration-200",children:n})]})}function kre(t){if(!t||typeof t!="object")return null;const e=t.user_metadata&&typeof t.user_metadata=="object"?t.user_metadata:{},n=t.profile&&typeof t.profile=="object"?t.profile:{},r=e.avatar_url||e.picture||n.avatar_url||t.avatar_url;return typeof r=="string"&&r.trim()?r.trim():null}function lP(t){const e=String(t||"").trim();if(!e)return"?";const n=e.split(/\s+/).filter(Boolean);return n.length>=2?(n[0][0]+n[n.length-1][0]).toUpperCase():e.slice(0,2).toUpperCase()}function yy({className:t,variant:e="header",collapsed:n=!1,onAfterAction:r}){lu();const i=e==="sidebar",{enabled:s,loading:a,signedIn:o,user:c,displayName:u}=la(),{openLoginModal:f}=Cp(),h=tf(),m=x.useMemo(()=>kre(c),[c]);if(!s)return null;if(a)return p.jsx("div",{className:vt("h-9 w-9 shrink-0 rounded-full bg-oai-gray-200 dark:bg-oai-gray-800 animate-pulse",t),"aria-hidden":!0});if(!o)return i?p.jsxs("button",{type:"button",onClick:()=>{f(),r?.()},className:vt("flex items-center gap-2 rounded-md px-2 py-1.5 text-[13px] font-medium text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 min-w-0",n?"h-8 w-8 justify-center px-0":"w-full",t),"aria-label":O("header.auth.sign_in_aria"),title:n?O("header.auth.sign_in_aria"):void 0,children:[p.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center",children:p.jsx("img",{src:"/app-icon.png",alt:"",width:18,height:18,className:"h-[18px] w-[18px] rounded"})}),!n&&p.jsx("span",{className:"truncate flex-1 text-left",children:O("header.auth.sign_in_aria")})]}):p.jsx("button",{type:"button",onClick:f,className:vt("shrink-0 inline-flex h-9 items-center justify-center gap-1.5 rounded-full px-5 text-sm font-medium transition-colors duration-200 ease-out shadow-sm ring-1 ring-oai-gray-200 dark:ring-white/10 bg-oai-gray-900 text-white hover:bg-oai-gray-800 active:bg-oai-gray-950 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 dark:active:bg-oai-gray-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-oai-gray-950",t),"aria-label":O("header.auth.sign_in_aria"),children:O("header.auth.sign_in_aria")});const g=()=>{h("/settings"),r?.()};return p.jsx("div",{className:vt(i?"relative flex w-full shrink-0 items-center":"relative flex shrink-0 items-center",t),children:p.jsxs("button",{type:"button",onClick:g,className:vt(i?vt("flex w-full items-center gap-2 rounded-md px-2 py-1.5 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 transition-colors min-w-0",n&&"justify-center px-0 py-0 h-9 w-9"):"flex items-center gap-2 rounded-full pl-1 pr-2 py-1 border border-transparent hover:bg-oai-gray-100 dark:hover:bg-oai-gray-900/80 hover:border-oai-gray-200 dark:hover:border-oai-gray-800 transition-colors"),"aria-label":O("header.auth.open_settings"),title:i&&n?u:void 0,children:[i?p.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center",children:m?p.jsx("img",{src:m,alt:"",width:20,height:20,className:"h-5 w-5 rounded-full object-cover ring-1 ring-oai-gray-300 dark:ring-oai-gray-700",referrerPolicy:"no-referrer"}):p.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-oai-brand-600 text-[9px] font-semibold text-white ring-1 ring-oai-brand-500/50",children:lP(u)})}):m?p.jsx("img",{src:m,alt:"",width:32,height:32,className:"h-8 w-8 rounded-full object-cover ring-1 ring-oai-gray-300 dark:ring-oai-gray-700 shrink-0",referrerPolicy:"no-referrer"}):p.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-oai-brand-600 text-xs font-semibold text-white ring-1 ring-oai-brand-500/50",children:lP(u)}),i?!n&&p.jsx("span",{className:"truncate text-[13px] font-medium text-oai-gray-900 dark:text-oai-gray-200 flex-1 text-left min-w-0",children:u}):p.jsx("span",{className:"hidden sm:inline truncate text-sm font-medium text-oai-gray-900 dark:text-oai-gray-200 max-w-[120px]",children:u})]})})}const P1="tt.sidebarCollapsed";function Ere(){return[{id:"general",label:O("nav.group.general"),items:[{id:"usage",to:"/dashboard",icon:OW,label:O("nav.usage")},{id:"limits",to:"/limits",icon:GW,label:O("nav.limits")},{id:"leaderboard",to:"/leaderboard",icon:kG,label:O("nav.leaderboard")}]},{id:"tools",label:O("nav.group.tools"),items:[{id:"widgets",to:"/widgets",icon:QW,label:O("nav.widgets")},{id:"skills",to:"/skills",icon:hG,label:O("nav.skills")},{id:"ip-check",to:"/ip-check",icon:YW,label:O("nav.ip_check")}]},{id:"account",label:O("nav.group.account"),items:[{id:"settings",to:"/settings",icon:WL,label:O("nav.settings")}]}]}function Mre(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(P1)==="1"}catch{return!1}}function Tre(){const[t,e]=x.useState(Mre),n=x.useCallback(()=>{e(r=>{const i=!r;try{typeof window<"u"&&window.localStorage.setItem(P1,i?"1":"0")}catch{}return i})},[]);return x.useEffect(()=>{if(typeof window>"u")return;const r=i=>{i.key===P1&&e(i.newValue==="1")};return window.addEventListener("storage",r),()=>window.removeEventListener("storage",r)},[]),{collapsed:t,toggle:n}}function Cre(t,e){const n=t.replace(/\/+$/,"")||"/";return e==="/dashboard"?n==="/dashboard"||n==="/":e==="/leaderboard"?n==="/leaderboard"||n.startsWith("/leaderboard/"):n===e}function Are({label:t,collapsed:e,first:n}){return e?n?null:p.jsx("div",{className:"mx-2 my-2 h-px bg-oai-gray-200/70 dark:bg-oai-gray-800/70","aria-hidden":!0}):p.jsx("div",{className:vt("px-3 pb-1 text-[10px] uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-500",n?"pt-2":"pt-4"),children:t})}function Rre({item:t,collapsed:e,active:n,onClick:r}){const i=t.icon;return p.jsxs(Ei,{to:t.to,onClick:r,title:e?t.label:void 0,"aria-current":n?"page":void 0,className:vt("flex items-center gap-2 rounded-md px-2 py-1.5 text-[13px] no-underline transition-colors",e&&"justify-center px-0 py-2",n?"bg-oai-gray-200/70 text-oai-black font-medium dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/50 hover:text-oai-black dark:hover:bg-oai-gray-800/60 dark:hover:text-white"),children:[p.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center",children:p.jsx(i,{className:"h-[15px] w-[15px]","aria-hidden":!0})}),!e&&p.jsx("span",{className:"truncate",children:t.label})]})}function Pre({as:t="button",title:e,onClick:n,href:r,children:i,className:s,...a}){const o=vt("flex h-10 w-10 items-center justify-center rounded-lg text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",s);return t==="a"?p.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",title:e,"aria-label":e,className:o,...a,children:i}):p.jsx("button",{type:"button",title:e,"aria-label":e,onClick:n,className:o,...a,children:i})}function Nre({repo:t="mm7894215/TokenTracker",glassChrome:e=!1}){const[n,r]=x.useState(null);return x.useEffect(()=>{if(typeof window>"u")return;const i=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;U5({prefersReducedMotion:i,screenshotCapture:!1})&&fetch(`https://api.github.com/repos/${t}`).then(s=>s.json()).then(s=>{s&&typeof s.stargazers_count=="number"&&r(s.stargazers_count)}).catch(()=>{})},[t]),p.jsxs("a",{href:`https://github.com/${t}`,target:"_blank",rel:"noopener noreferrer","aria-label":n!==null?`Star on GitHub (${n})`:"Star on GitHub",className:vt("inline-flex h-7 items-center gap-1.5 rounded-full px-2.5 text-xs font-medium transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"border border-gray-500/20 dark:border-gray-500/30 bg-gray-500/[0.04] dark:bg-gray-500/[0.06] backdrop-blur-[2px] text-oai-gray-700 dark:text-oai-gray-300 hover:bg-gray-500/10 dark:hover:bg-gray-500/12 hover:border-gray-500/30 dark:hover:border-gray-500/40 hover:text-oai-black dark:hover:text-white":"border border-oai-gray-200 dark:border-oai-gray-700 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white hover:border-oai-gray-300 dark:hover:border-oai-gray-600"),children:[p.jsx("svg",{height:"12",viewBox:"0 0 16 16",width:"12",className:"shrink-0 fill-current",children:p.jsx("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})}),p.jsx("span",{children:"Star"}),n!==null&&p.jsx("span",{className:"text-[10px] text-oai-gray-500 dark:text-oai-gray-500 tabular-nums",children:n})]})}const Dre=[{value:"light",label:"Light",Icon:Rk},{value:"dark",label:"Dark",Icon:Ck},{value:"system",label:"System",Icon:Wy}];function Lre({theme:t,resolvedTheme:e,onSetTheme:n,glassChrome:r=!1}){const[i,s]=x.useState(!1),a=x.useRef(null),o=e==="dark"?Ck:Rk;return x.useEffect(()=>{if(!i)return;const c=f=>{a.current&&!a.current.contains(f.target)&&s(!1)},u=f=>{f.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",c),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",u)}},[i]),p.jsxs("div",{ref:a,className:"relative",children:[p.jsx("button",{type:"button","aria-label":"Theme","aria-expanded":i,"aria-haspopup":"menu",title:"Theme",onClick:()=>s(c=>!c),className:vt("inline-flex h-7 w-7 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",r?"border border-gray-500/20 dark:border-gray-500/30 bg-gray-500/[0.04] dark:bg-gray-500/[0.06] backdrop-blur-[2px] text-oai-gray-700 dark:text-oai-gray-300 hover:bg-gray-500/10 dark:hover:bg-gray-500/12 hover:border-gray-500/30 dark:hover:border-gray-500/40 hover:text-oai-black dark:hover:text-white":"border border-oai-gray-200 dark:border-oai-gray-700 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white hover:border-oai-gray-300 dark:hover:border-oai-gray-600"),children:p.jsx(o,{className:"h-3.5 w-3.5","aria-hidden":!0})}),i&&p.jsx("div",{role:"menu",className:"absolute bottom-full left-0 mb-2 z-50 min-w-[140px] py-1 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 shadow-lg",children:Dre.map(({value:c,label:u,Icon:f})=>{const h=t===c;return p.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{n(c),s(!1)},className:vt("flex w-full items-center gap-2.5 px-3 py-1.5 text-[13px] transition-colors",h?"text-oai-black dark:text-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/60 hover:text-oai-black dark:hover:text-white"),children:[p.jsx(f,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),p.jsx("span",{children:u})]},c)})})]})}function j5({collapsed:t,onToggleCollapsed:e,onItemClick:n,showCloseButton:r=!1,onClose:i,glassChrome:s=!1}){const o=Hi()?.pathname||"/",{theme:c,resolvedTheme:u,setTheme:f}=Op(),{resolvedLocale:h}=lu(),m=x.useMemo(()=>Ere(),[h]);return p.jsxs(p.Fragment,{children:[p.jsx("div",{className:vt("px-2 pt-2 pb-2",t&&"flex justify-center"),children:r?p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("div",{className:"flex-1 min-w-0",children:p.jsx(yy,{variant:"sidebar",collapsed:t,onAfterAction:n})}),p.jsx("button",{type:"button",onClick:i,"aria-label":O("nav.close_menu"),title:O("nav.close_menu"),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-oai-gray-500 dark:text-oai-gray-500 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-gray-900 dark:hover:text-oai-gray-200 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:p.jsx(Pk,{className:"h-4 w-4",strokeWidth:1.75,"aria-hidden":!0})})]}):p.jsx(yy,{variant:"sidebar",collapsed:t,onAfterAction:n})}),p.jsx("nav",{"aria-label":O("nav.nav_label"),className:"flex-1 px-2 pb-2 flex flex-col overflow-y-auto",children:m.map((g,v)=>p.jsxs("div",{className:"flex flex-col",children:[p.jsx(Are,{label:g.label,collapsed:t,first:v===0}),p.jsx("div",{className:"flex flex-col gap-0.5",children:g.items.map(w=>p.jsx(Rre,{item:w,collapsed:t,active:Cre(o,w.to),onClick:n},w.id))})]},g.id))}),p.jsxs("div",{className:vt("flex items-center px-2 py-3",t?"flex-col justify-center gap-2":"justify-between gap-2"),children:[p.jsx(Lre,{theme:c,resolvedTheme:u,onSetTheme:f,glassChrome:s}),p.jsx("div",{className:"flex items-center gap-1.5",children:!t&&p.jsx(Nre,{glassChrome:s})})]})]})}function Ire({collapsed:t,onToggleCollapsed:e}){const n=x.useMemo(()=>typeof window>"u"?!1:Js()||Ek(),[]);return p.jsx("aside",{"aria-label":O("nav.aside_label"),className:vt("hidden lg:flex flex-col shrink-0 h-full min-h-0 transition-[width] duration-200",t?"w-[72px]":"w-[220px]"),children:p.jsx(j5,{collapsed:t,onToggleCollapsed:e,glassChrome:n})})}function Ore({open:t,onClose:e}){return x.useEffect(()=>{if(!t)return;const n=r=>{r.key==="Escape"&&e()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[t,e]),x.useEffect(()=>{if(!t)return;const n=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=n}},[t]),t?p.jsxs("div",{className:"lg:hidden fixed inset-0 z-[80] flex",children:[p.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:e,"aria-hidden":!0}),p.jsx("aside",{"aria-label":O("nav.aside_label"),className:"relative w-[260px] max-w-[80vw] flex flex-col bg-oai-white dark:bg-oai-gray-900 border-r border-oai-gray-200 dark:border-oai-gray-800 shadow-2xl",children:p.jsx(j5,{collapsed:!1,showCloseButton:!0,onClose:e,onItemClick:e})})]}):null}function Fre({onOpenDrawer:t}){return p.jsxs("div",{className:"lg:hidden flex items-center justify-between gap-2 px-3 h-14 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[p.jsx(Pre,{title:O("nav.menu"),onClick:t,children:p.jsx(aG,{className:"h-5 w-5","aria-hidden":!0})}),p.jsxs(Ei,{to:"/landing",className:"flex items-center gap-2 no-underline hover:opacity-80 transition-opacity","aria-label":"Token Tracker",children:[p.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white",children:"Token Tracker"})]}),p.jsx("div",{className:"w-10 shrink-0","aria-hidden":!0})]})}function Ure({children:t}){const{collapsed:e,toggle:n}=Tre(),[r,i]=x.useState(!1),s=x.useCallback(()=>i(!0),[]),a=x.useCallback(()=>i(!1),[]),o=x.useMemo(()=>typeof window>"u"?!1:Js()||Ek(),[]);return p.jsxs("div",{className:vt("fixed inset-0 flex flex-col text-oai-black dark:text-oai-white font-sans overflow-hidden",o?"bg-transparent":"bg-oai-gray-100 dark:bg-oai-gray-950"),children:[o&&p.jsx("div",{className:"h-7 shrink-0",style:{WebkitAppRegion:"drag"},"aria-hidden":!0}),p.jsxs("div",{className:"flex-1 min-h-0 flex",children:[p.jsx(Ire,{collapsed:e,onToggleCollapsed:n}),p.jsx(Ore,{open:r,onClose:a}),p.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-2 lg:pl-0 lg:pr-3 lg:pb-3 flex flex-col",children:p.jsxs("div",{className:vt("flex-1 min-h-0 flex flex-col bg-oai-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",o?"tt-native-main-card":"rounded-2xl",!o&&"shadow-sm"),children:[p.jsx(Fre,{onOpenDrawer:s}),p.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:t})]})})]})]})}function jre({children:t,variant:e="info",size:n="md",className:r=""}){const i="inline-flex items-center font-medium",s={success:"bg-oai-brand-100 dark:bg-oai-brand-900/30 text-oai-brand-700 dark:text-oai-brand-400 rounded-full",warning:"bg-oai-amber-50 dark:bg-oai-amber-900/30 text-oai-amber-dark dark:text-oai-amber-400 rounded-full",error:"bg-red-50 dark:bg-red-900/30 text-red-600 dark:text-red-400 rounded-full",info:"bg-oai-gray-100 dark:bg-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-300 rounded-full",secondary:"bg-oai-gray-100 dark:bg-oai-gray-800 text-oai-gray-500 dark:text-oai-gray-300 rounded-md"},a={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm"},o=`${i} ${s[e]} ${a[n]} ${r}`.trim();return p.jsx("span",{className:o,children:t})}const B5=x.createContext(void 0);function Gl(t){const e=x.useContext(B5);if(t===!1&&e===void 0)throw new Error(Wi(27));return e}const Bre={...hu,...df},z5=x.forwardRef(function(e,n){const{render:r,className:i,forceRender:s=!1,...a}=e,{store:o}=Gl(),c=o.useState("open"),u=o.useState("nested"),f=o.useState("mounted"),h=o.useState("transitionStatus"),m=x.useMemo(()=>({open:c,transitionStatus:h}),[c,h]);return Xr("div",e,{state:m,ref:[o.context.backdropRef,n],stateAttributesMapping:Bre,props:[{role:"presentation",hidden:!f,style:{userSelect:"none",WebkitUserSelect:"none"}},a],enabled:s||!u})}),zre=x.forwardRef(function(e,n){const{render:r,className:i,disabled:s=!1,nativeButton:a=!0,...o}=e,{store:c}=Gl(),u=c.useState("open");function f(v){u&&c.setOpen(!1,Mn(fee,v.nativeEvent))}const{getButtonProps:h,buttonRef:m}=cv({disabled:s,native:a}),g=x.useMemo(()=>({disabled:s}),[s]);return Xr("button",e,{state:g,ref:[n,m],props:[{onClick:f},o,h]})}),Vre=x.forwardRef(function(e,n){const{render:r,className:i,id:s,...a}=e,{store:o}=Gl(),c=lv(s);return o.useSyncedValueWithCleanup("descriptionElementId",c),Xr("p",e,{ref:n,props:[{id:c},a]})});let Hre=(function(t){return t.nestedDialogs="--nested-dialogs",t})({}),Wre=(function(t){return t[t.open=Qs.open]="open",t[t.closed=Qs.closed]="closed",t[t.startingStyle=Qs.startingStyle]="startingStyle",t[t.endingStyle=Qs.endingStyle]="endingStyle",t.nested="data-nested",t.nestedDialogOpen="data-nested-dialog-open",t})({});const V5=x.createContext(void 0);function H5(){const t=x.useContext(V5);if(t===void 0)throw new Error(Wi(26));return t}const Gre={...hu,...df,nestedDialogOpen(t){return t?{[Wre.nestedDialogOpen]:""}:null}},W5=x.forwardRef(function(e,n){const{className:r,finalFocus:i,initialFocus:s,render:a,...o}=e,{store:c}=Gl(),u=c.useState("descriptionElementId"),f=c.useState("disablePointerDismissal"),h=c.useState("floatingRootContext"),m=c.useState("popupProps"),g=c.useState("modal"),v=c.useState("mounted"),w=c.useState("nested"),b=c.useState("nestedOpenDialogCount"),_=c.useState("open"),E=c.useState("openMethod"),M=c.useState("titleElementId"),T=c.useState("transitionStatus"),R=c.useState("role");H5(),ff({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});function A(L){return L==="touch"?c.context.popupRef.current:!0}const P=s===void 0?A:s,k=b>0,N=x.useMemo(()=>({open:_,nested:w,transitionStatus:T,nestedDialogOpen:k}),[_,w,T,k]),B=Xr("div",e,{state:N,props:[m,{"aria-labelledby":M??void 0,"aria-describedby":u??void 0,role:R,tabIndex:-1,hidden:!v,onKeyDown(L){LE.has(L.key)&&L.stopPropagation()},style:{[Hre.nestedDialogs]:b}},o],ref:[n,c.context.popupRef,c.useStateSetter("popupElement")],stateAttributesMapping:Gre});return p.jsx(kE,{context:h,openInteractionType:E,disabled:!v,closeOnFocusOut:!f,initialFocus:P,returnFocus:i,modal:g!==!1,restoreFocus:"popup",children:B})}),G5=x.forwardRef(function(e,n){const{keepMounted:r=!1,...i}=e,{store:s}=Gl(),a=s.useState("mounted"),o=s.useState("modal"),c=s.useState("open");return a||r?p.jsx(V5.Provider,{value:r,children:p.jsxs(wE,{ref:n,...i,children:[a&&o===!0&&p.jsx(DE,{ref:s.context.internalBackdropRef,inert:PE(!c)}),e.children]})}):null});function $re(t){const{store:e,parentContext:n,actionsRef:r}=t,i=e.useState("open"),s=e.useState("disablePointerDismissal"),a=e.useState("modal"),o=e.useState("popupElement"),{openMethod:c,triggerProps:u,reset:f}=RE(i);a5(e);const{forceUnmount:h}=o5(i,e,()=>{f()}),m=Bt(B=>{const L=Mn(B);return L.preventUnmountOnClose=()=>{e.set("preventUnmountingOnClose",!0)},L}),g=x.useCallback(()=>{e.setOpen(!1,m(W4))},[e,m]);x.useImperativeHandle(r,()=>({unmount:h,close:g}),[h,g]);const v=d5({popupStore:e,onOpenChange:e.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[w,b]=x.useState(0),_=w===0,E=h5(v),M=ME(v,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?"intentional":{mouse:a==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(B){if("button"in B&&B.button!==0||"touches"in B&&B.touches.length!==1)return!1;const L=Fi(B);if(_&&!s){const z=L;return a&&(e.context.internalBackdropRef.current||e.context.backdropRef.current)?e.context.internalBackdropRef.current===z||e.context.backdropRef.current===z||On(z,o)&&!z?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:_});NE(i&&a===!0,o);const{getReferenceProps:T,getFloatingProps:R,getTriggerProps:A}=av([E,M]);e.useContextCallback("onNestedDialogOpen",B=>{b(B+1)}),e.useContextCallback("onNestedDialogClose",()=>{b(0)}),x.useEffect(()=>(n?.onNestedDialogOpen&&i&&n.onNestedDialogOpen(w),n?.onNestedDialogClose&&!i&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&i&&n.onNestedDialogClose()}),[i,n,w]);const P=x.useMemo(()=>T(u),[T,u]),k=x.useMemo(()=>A(u),[A,u]),N=x.useMemo(()=>R(),[R]);e.useSyncedValues({openMethod:c,activeTriggerProps:P,inactiveTriggerProps:k,popupProps:N,floatingRootContext:v,nestedOpenDialogCount:w})}const Yre={...c5,modal:Rt(t=>t.modal),nested:Rt(t=>t.nested),nestedOpenDialogCount:Rt(t=>t.nestedOpenDialogCount),disablePointerDismissal:Rt(t=>t.disablePointerDismissal),openMethod:Rt(t=>t.openMethod),descriptionElementId:Rt(t=>t.descriptionElementId),titleElementId:Rt(t=>t.titleElementId),viewportElement:Rt(t=>t.viewportElement),role:Rt(t=>t.role)};class qre extends fE{constructor(e){super(Xre(e),{popupRef:x.createRef(),backdropRef:x.createRef(),internalBackdropRef:x.createRef(),triggerElements:new sv,onOpenChange:void 0,onOpenChangeComplete:void 0},Yre)}setOpen=(e,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!e&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,n),n.isCanceled)return;const r={open:e,nativeEvent:n.event,reason:n.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit("openchange",r);const i={open:e},s=n.trigger?.id??null;(s||e)&&(i.activeTriggerId=s,i.activeTriggerElement=n.trigger??null),this.update(i)}}function Xre(t={}){return{...l5(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...t}}function $5(t){const{children:e,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:s,disablePointerDismissal:a=!1,modal:o=!0,actionsRef:c,handle:u,triggerId:f,defaultTriggerId:h=null}=t,m=Gl(!0),g=!!m,v=Vi(()=>u?.store??new qre({open:n??r,activeTriggerId:f!==void 0?f:h,modal:o,disablePointerDismissal:a,nested:g})).current;v.useControlledProp("open",n,r),v.useControlledProp("activeTriggerId",f,h),v.useSyncedValues({disablePointerDismissal:a,nested:g,modal:o}),v.useContextCallback("onOpenChange",i),v.useContextCallback("onOpenChangeComplete",s);const w=v.useState("payload");$re({store:v,actionsRef:c,parentContext:m?.store.context});const b=x.useMemo(()=>({store:v}),[v]);return p.jsx(B5.Provider,{value:b,children:typeof e=="function"?e({payload:w}):e})}let cP=(function(t){return t[t.open=Qs.open]="open",t[t.closed=Qs.closed]="closed",t[t.startingStyle=Qs.startingStyle]="startingStyle",t[t.endingStyle=Qs.endingStyle]="endingStyle",t.nested="data-nested",t.nestedDialogOpen="data-nested-dialog-open",t})({});const Kre={...hu,...df,nested(t){return t?{[cP.nested]:""}:null},nestedDialogOpen(t){return t?{[cP.nestedDialogOpen]:""}:null}},Y5=x.forwardRef(function(e,n){const{className:r,render:i,children:s,...a}=e,o=H5(),{store:c}=Gl(),u=c.useState("open"),f=c.useState("nested"),h=c.useState("transitionStatus"),m=c.useState("nestedOpenDialogCount"),g=c.useState("mounted"),v=m>0,w=x.useMemo(()=>({open:u,nested:f,transitionStatus:h,nestedDialogOpen:v}),[u,f,h,v]);return Xr("div",e,{enabled:o||g,state:w,ref:[n,c.useStateSetter("viewportElement")],stateAttributesMapping:Kre,props:[{role:"presentation",hidden:!g,children:s},a]})}),q5=x.forwardRef(function(e,n){const{render:r,className:i,id:s,...a}=e,{store:o}=Gl(),c=lv(s);return o.useSyncedValueWithCleanup("titleElementId",c),Xr("h2",e,{ref:n,props:[{id:c},a]})});function Zre({open:t,title:e,description:n,confirmLabel:r,cancelLabel:i,destructive:s=!1,busy:a=!1,onConfirm:o,onCancel:c}){return p.jsx($5,{open:t,onOpenChange:u=>{!u&&!a&&c?.()},children:p.jsxs(G5,{children:[p.jsx(z5,{className:"fixed inset-0 z-[100] bg-black/40 backdrop-blur-[2px] transition-opacity duration-200 ease-out data-[ending-style]:opacity-0 data-[starting-style]:opacity-0"}),p.jsx(Y5,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:p.jsxs(W5,{className:"relative w-full max-w-md rounded-2xl bg-white p-6 shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] ring-1 ring-oai-gray-200 transition-[opacity,transform] duration-[220ms] ease-[cubic-bezier(0.16,1,0.3,1)] data-[ending-style]:translate-y-2 data-[ending-style]:scale-[0.96] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-2 data-[starting-style]:scale-[0.96] data-[starting-style]:opacity-0 dark:bg-oai-gray-950 dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)] dark:ring-oai-gray-800",children:[p.jsx(q5,{className:"text-base font-semibold text-oai-black dark:text-white",children:e}),n?p.jsx(Vre,{className:"mt-2 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:n}):null,p.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[p.jsx(Ui,{type:"button",variant:"secondary",size:"sm",disabled:a,onClick:()=>c?.(),children:i}),p.jsx(Ui,{type:"button",size:"sm",disabled:a,onClick:()=>o?.(),className:vt(s&&"!bg-red-600 hover:!bg-red-700 focus-visible:!outline-red-600 dark:!bg-red-600 dark:hover:!bg-red-500"),children:r})]})]})})]})})}function X5({value:t,onChange:e,placeholder:n,disabled:r=!1,type:i="text",label:s,error:a,className:o="",...c}){const m=`w-full bg-oai-white dark:bg-oai-gray-900 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md text-oai-black dark:text-oai-white placeholder-oai-gray-400 dark:placeholder-oai-gray-500 transition-all duration-200 focus:outline-none focus:border-oai-brand dark:focus:border-oai-brand focus:ring-1 focus:ring-oai-brand/30 ${r?"bg-oai-gray-50 dark:bg-oai-gray-800 text-oai-gray-400 dark:text-oai-gray-400 cursor-not-allowed":""} ${a?"border-oai-error focus:border-oai-error focus:ring-oai-error/30":""} h-10 px-3 text-sm ${o}`;return p.jsxs("div",{className:"w-full",children:[s&&p.jsx("label",{className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5 transition-colors duration-200",children:s}),p.jsx("input",{type:i,value:t,onChange:e,placeholder:n,disabled:r,className:m,...c}),a&&p.jsx("p",{className:"mt-1.5 text-sm text-oai-error",children:a})]})}var Jre={};function Qre(t,e){return t==="."?{width:"0.34ch",justifyContent:"center",marginInline:"-0.04ch"}:t===","?{width:"0.08ch",justifyContent:"center",marginInline:"-0.30ch"}:{width:"0.72ch",justifyContent:"flex-start",paddingLeft:"0.04ch",height:e}}function eie({mv:t,digit:e,height:n}){const r=OO(t,i=>{const s=(i%10+10)%10,a=(10+e-s)%10;let o=a*n;return a>5&&(o-=10*n),o});return p.jsx(tr.span,{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",y:r},children:e})}function tie(t){const e=Math.round(t),n=1e-9*Math.max(1,Math.abs(t));return Math.abs(t-e)<n?e:t}function nie(t,e){const n=t/e;return Math.floor(tie(n))}function rie(t){const e=String(t??""),n=Array.from(e),r=n.indexOf(".");let i=n.filter((o,c)=>/\d/.test(o)&&(r===-1||c<r)).length,s=0,a=!1;return n.map(o=>{if(!/\d/.test(o))return o==="."&&(a=!0),o;if(!a){const c=10**Math.max(i-1,0);return i-=1,c}return s+=1,10**-s})}function iie({place:t,value:e,height:n,digitStyle:r,shouldReduceMotion:i}){if(typeof t!="number"){const c=Qre(t,n);return p.jsx("span",{"data-counter-token":"static",className:"relative inline-flex items-center justify-center",style:{height:n,...c,...r},children:t})}const s=nie(e,t),a=sE(0),o=FK(a,{stiffness:220,damping:26,mass:.8});return x.useEffect(()=>{a.set(s)},[a,s]),i?p.jsx("span",{"data-counter-token":"digit",className:"relative inline-flex items-center justify-center overflow-hidden",style:{height:n,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...r},children:Math.abs(s)%10}):p.jsx("span",{"data-counter-token":"digit",className:"relative inline-flex overflow-hidden",style:{height:n,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...r},children:Array.from({length:10},(c,u)=>p.jsx(eie,{mv:o,digit:u,height:n},u))})}function sie({value:t,displayValue:e,fontSize:n=72,padding:r=0,places:i,gap:s=6,borderRadius:a=4,horizontalPadding:o=0,textColor:c="inherit",fontWeight:u="inherit",containerStyle:f,counterStyle:h,digitStyle:m,gradientHeight:g=14,gradientFrom:v="rgba(255,255,255,0.95)",gradientTo:w="rgba(255,255,255,0)",topGradientStyle:b,bottomGradientStyle:_}){const E=String(e??t??""),M=x.useMemo(()=>Array.isArray(i)&&i.length?i:rie(E),[i,E]),T=typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent||"")||typeof process<"u"&&Jre?.VITEST==="true",R=cu()||T,A=Number.isFinite(Number(t))?Math.abs(Number(t)):0,P=n+r;return R?p.jsx("span",{"data-counter-root":"true",style:{display:"inline-flex",alignItems:"center",color:c,fontSize:n,fontWeight:u,lineHeight:1,...f,...h},children:E}):p.jsxs("span",{"data-counter-root":"true",style:{position:"relative",display:"inline-block",...f},children:[p.jsx("span",{style:{fontSize:n,display:"flex",gap:s,overflow:"hidden",borderRadius:a,paddingLeft:o,paddingRight:o,lineHeight:1,color:c,fontWeight:u,...h},children:M.map((k,N)=>p.jsx(iie,{place:k,value:A,height:P,digitStyle:m,shouldReduceMotion:R},`${String(k)}-${N}`))}),p.jsxs("span",{style:{pointerEvents:"none",position:"absolute",inset:0,display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[p.jsx("span",{style:b??{height:g,background:`linear-gradient(to bottom, ${v}, ${w})`}}),p.jsx("span",{style:_??{height:g,background:`linear-gradient(to top, ${v}, ${w})`}})]})]})}function aie(t){if(!Number.isFinite(t))return O("shared.placeholder.short");const e=Uy(t.toFixed(2),{decimals:2});return e==="-"?O("shared.placeholder.short"):e}function uP(t){return!Number.isFinite(t)||t<=0?null:t<.01?"<$0.01":Uy(t.toFixed(2),{decimals:2})}function dP(t){const e=Number(t);return!Number.isFinite(e)||e<=0?null:Ms(e,{decimals:1})}const oie=ot.memo(function({isOpen:e,onClose:n,fleetData:r=[]}){const i=x.useMemo(()=>(Array.isArray(r)?r:[]).map(a=>{const o=ti(a?.usd)??0,c=ti(a?.usage)??0,u=Array.isArray(a?.models)?a.models:[];return{label:a?.label?String(a.label):"",usdValue:o,usdLabel:uP(o),tokensLabel:dP(c),models:u.map(f=>{const h=ti(f?.usage)??0,m=ti(f?.cost)??0;return{id:f?.id?String(f.id):"",name:f?.name?String(f.name):"",tokensLabel:dP(h),costLabel:uP(m),sortCost:m}}).filter(f=>f.costLabel||f.tokensLabel).sort((f,h)=>h.sortCost-f.sortCost)}}).filter(a=>a.usdValue>0||a.models.length>0).sort((a,o)=>o.usdValue-a.usdValue),[r]),s=x.useMemo(()=>{const a=i.reduce((o,c)=>o+c.usdValue,0);return aie(a)},[i]);return p.jsx($5,{open:e,onOpenChange:a=>{a||n?.()},children:p.jsxs(G5,{children:[p.jsx(z5,{className:"cost-modal-backdrop","data-cost-analysis-backdrop":"true"}),p.jsx(Y5,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:p.jsxs(W5,{className:"cost-modal-popup relative w-full max-w-[460px] max-h-[calc(100vh-2rem)] flex flex-col rounded-2xl bg-white dark:bg-oai-gray-950 shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)] ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 overflow-hidden",children:[p.jsx(q5,{render:p.jsx("h2",{className:"sr-only"}),children:O("dashboard.cost_breakdown.title")}),p.jsx(zre,{type:"button",className:"absolute top-3 right-3 flex h-9 w-9 items-center justify-center rounded-md text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-800 dark:hover:text-oai-gray-100 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/50 transition-colors z-10","aria-label":O("dashboard.cost_breakdown.close"),children:p.jsx(Pk,{size:16,strokeWidth:2,"aria-hidden":!0})}),p.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto oai-scrollbar",children:p.jsxs("div",{className:"px-3 py-6",children:[p.jsx("p",{className:"text-label uppercase tracking-[0.12em] text-oai-gray-500 dark:text-oai-gray-400 mb-2",children:O("dashboard.cost_breakdown.total_label")}),p.jsx("p",{className:"font-bold text-oai-brand tabular-nums tracking-tight leading-none mb-6",style:{fontSize:"clamp(24px, 6.5vw, 32px)"},children:s}),i.length===0?p.jsx("p",{className:"text-body-sm text-oai-gray-500 dark:text-oai-gray-400",children:"No spend recorded."}):p.jsxs("div",{role:"table","aria-label":O("dashboard.cost_breakdown.title"),children:[p.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-2 mb-2 border-b border-oai-gray-200 dark:border-oai-gray-800 text-label uppercase text-oai-gray-500 dark:text-oai-gray-400",children:[p.jsx("span",{role:"columnheader",children:"Model"}),p.jsx("span",{role:"columnheader",children:"Cost"})]}),i.map((a,o)=>{const c=`fleet-${o}`;return p.jsxs("div",{role:"rowgroup","aria-labelledby":c,className:o>0?"mt-5":"mt-2",children:[p.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-2",children:[p.jsx("span",{id:c,role:"rowheader",className:"flex-1 min-w-0 text-body-sm font-semibold text-oai-black dark:text-oai-white truncate leading-none",children:a.label}),p.jsx("span",{role:"cell",className:"shrink-0 text-body-sm font-semibold text-oai-black dark:text-oai-white tabular-nums leading-none",children:a.usdLabel||"—"})]}),a.models.map((u,f)=>p.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-[5px]",children:[p.jsx("span",{role:"cell",className:"flex-1 min-w-0 text-caption text-oai-gray-500 dark:text-oai-gray-400 truncate leading-none",title:u.name,children:u.name}),p.jsx("span",{role:"cell",className:"shrink-0 text-caption text-oai-gray-700 dark:text-oai-gray-300 tabular-nums leading-none",children:u.costLabel||""})]},u.id||`${u.name}-${f}`))]},`${a.label}-${o}`)})]})]})})]})})]})})});function lie({projectEntries:t=[],projectLimit:e=3,onProjectLimitChange:n,copy:r,hasDetailsActual:i,dailyEmptyPrefix:s,installSyncCmd:a,dailyEmptySuffix:o,detailsColumns:c,ariaSortFor:u,toggleSort:f,sortIconFor:h,pagedDetails:m,dailyBreakdownRows:g=[],dailyBreakdownColumns:v=[],dailyBreakdownAriaSortFor:w,dailyBreakdownSortIconFor:b,dailyBreakdownDateKey:_="day",detailsDateKey:E,renderDetailDate:M,renderDailyBreakdownDate:T,renderDetailCell:R,DETAILS_PAGED_PERIODS:A,period:P,detailsPageCount:k,detailsPage:N,setDetailsPage:B}){const[L,z]=x.useState("daily");return p.jsxs(pu,{children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[p.jsxs("div",{role:"tablist","aria-label":"Data view",className:"flex gap-1",children:[p.jsx("button",{role:"tab","aria-selected":L==="daily",type:"button",onClick:()=>z("daily"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${L==="daily"?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/50"}`,children:r("dashboard.daily.title")}),p.jsx("button",{role:"tab","aria-selected":L==="projects",type:"button",onClick:()=>z("projects"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${L==="projects"?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/50"}`,children:r("dashboard.projects.title")})]}),L==="projects"&&p.jsxs("select",{"aria-label":"Number of projects to display",value:e,onChange:I=>n?.(Number(I.target.value)),className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded px-2 py-1 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 focus:border-oai-brand dark:focus:border-oai-brand focus:outline-none transition-colors",children:[p.jsx("option",{value:3,children:r("dashboard.projects.limit_top_3")}),p.jsx("option",{value:6,children:r("dashboard.projects.limit_top_6")}),p.jsx("option",{value:10,children:r("dashboard.projects.limit_top_10")})]})]}),L==="projects"&&p.jsx("div",{className:"space-y-1",children:t.slice(0,e).map(I=>p.jsxs("a",{href:I?.project_ref||"#",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-2 rounded-lg hover:oai-bg-elevated transition-colors",children:[p.jsx("div",{className:"w-8 h-8 rounded-md oai-bg-elevated flex items-center justify-center oai-text-caption font-medium text-oai-gray-500 dark:text-oai-gray-300",children:(I?.project_key?.[0]||"?").toUpperCase()}),p.jsx("div",{className:"min-w-0 flex-1",children:p.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white truncate",children:I?.project_key||I?.project_ref?.split("/")?.pop()||"—"})}),p.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",children:(()=>{const V=I?.billable_total_tokens??I?.total_tokens,W=Number(V);return Number.isFinite(W)?W.toLocaleString():"—"})()})]},I?.project_key||I?.project_ref))}),L==="daily"&&p.jsxs("div",{children:[g?.length===0?p.jsxs("div",{className:"oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300 mb-4",children:[s,p.jsx("code",{className:"mx-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 oai-bg-elevated px-1.5 py-0.5 font-mono oai-text-caption",children:a}),o]}):p.jsx("div",{className:"overflow-auto max-h-[384px] -mx-4 oai-scrollbar",children:p.jsxs("table",{className:"w-full border-collapse",children:[p.jsx("thead",{className:"sticky top-0 z-10",children:p.jsx("tr",{className:"border-b border-oai-gray-200 dark:border-oai-gray-700",children:v.map(I=>p.jsx("th",{"aria-sort":w?.(I.key)||"none",className:"text-left p-0 bg-white dark:bg-oai-gray-900",children:p.jsx("button",{type:"button",onClick:()=>f(I.key),className:"flex w-full items-center justify-start px-4 py-2 text-left oai-text-caption font-semibold text-oai-gray-600 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white transition-colors",children:p.jsxs("span",{className:"inline-flex items-center gap-1",children:[p.jsx("span",{children:I.label}),p.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-400",children:b?.(I.key)||""})]})})},I.key))})}),p.jsx("tbody",{children:g.map(I=>p.jsxs("tr",{className:`border-b border-oai-gray-100 dark:border-oai-gray-800 last:border-b-0 hover:bg-oai-gray-50/50 dark:hover:bg-oai-gray-800/50 transition-colors ${I.missing?"text-oai-gray-400 dark:text-oai-gray-400":I.future?"text-oai-gray-300 dark:text-oai-gray-600":"text-oai-black dark:text-oai-white"}`,children:[p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300",children:T?T(I):M(I)}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",children:R(I,"total_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:R(I,"input_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:R(I,"output_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:R(I,"cached_input_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:R(I,"reasoning_output_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:R(I,"conversation_count")})]},String(I?.[_]||I?.day||I?.hour||I?.month||"")))})]})}),L!=="daily"&&A.has(P)&&k>1?p.jsxs("div",{className:"mt-3 flex items-center justify-between oai-text-caption",children:[p.jsx("button",{type:"button",onClick:()=>B(I=>Math.max(0,I-1)),disabled:N===0,className:"px-3 py-1.5 text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 rounded-md disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("details.pagination.prev")}),p.jsxs("span",{className:"oai-text-muted",children:[N+1," / ",k]}),p.jsx("button",{type:"button",onClick:()=>B(I=>Math.min(k-1,I+1)),disabled:N+1>=k,className:"px-3 py-1.5 text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 rounded-md disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("details.pagination.next")})]}):null]})]})}function k0(t){return typeof t!="string"?"":t.trim()}function fP(t){const e=k0(t);return e?e.split(/[_\-\s]+/).filter(Boolean).map(n=>n.slice(0,1).toUpperCase()+n.slice(1).toLowerCase()).join(" "):""}function cie(t){if(!Array.isArray(t))return[];const e=new Map;for(const n of t){if(!n||typeof n!="object")continue;const r=k0(n.tool),i=k0(n.planType)||k0(n.plan_type);if(!r||!i)continue;const s=fP(r)||r,a=fP(i)||i;e.set(`${r.toLowerCase()}::${i.toLowerCase()}`,{tool:s,plan:a})}return Array.from(e.values())}function uie({period:t="month",rankLabel:e,streakDays:n,subscriptions:r=[],periodConversations:i,rolling:s,topModels:a=[],className:o=""}){const c=O("shared.placeholder.short"),u=O("shared.unit.percent"),f=e??O("identity_card.rank_placeholder"),h=Number.isFinite(Number(n))?Number(n):0,m=h?O("identity_card.streak_value",{days:h}):O("identity_card.rank_placeholder"),g=cie(r),v={thousandSuffix:O("shared.unit.thousand_abbrev"),millionSuffix:O("shared.unit.million_abbrev"),billionSuffix:O("shared.unit.billion_abbrev")},w=E=>{if(E==null)return c;const M=Ms(E,v);return M==="-"?c:M},b=(()=>{switch(t){case"day":return O("stats.period.today");case"week":return O("stats.period.week");case"month":return O("stats.period.month");case"total":return O("stats.period.all");default:return O("stats.period.convs")}})(),_=a.slice(0,3);return p.jsxs(pu,{className:`h-full ${o}`,children:[p.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[p.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:w(s?.last_7d?.totals?.billable_total_tokens)}),p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:"7d"})]}),p.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:w(s?.last_30d?.totals?.billable_total_tokens)}),p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:"30d"})]}),p.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:w(s?.last_30d?.avg_per_active_day)}),p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:"avg"})]}),p.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:w(i)}),p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:b})]})]}),_.length>0&&p.jsx("div",{className:"mt-4 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800",children:_.map((E,M)=>{const T=E?.name?String(E.name):c,R=E?.percent?String(E.percent):"",A=M===_.length-1,P=M+1;return p.jsxs("div",{className:`flex items-center py-2 ${A?"":"border-b border-oai-gray-50 dark:border-oai-gray-800"}`,children:[p.jsx("span",{className:"w-5 h-5 flex items-center justify-center rounded-full bg-oai-gray-100 dark:bg-oai-gray-800 text-[10px] font-semibold text-oai-gray-500 dark:text-oai-gray-300 flex-shrink-0",children:P}),p.jsx("span",{className:"flex-1 text-sm text-oai-gray-700 dark:text-oai-gray-300 truncate px-2.5",title:T,children:T}),p.jsxs("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums flex-shrink-0",children:[R,u]})]},E.id||T)})}),g.length>0&&p.jsx("div",{className:"mt-3 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800 flex flex-wrap gap-1.5",children:g.map((E,M)=>p.jsxs(jre,{variant:"secondary",size:"sm",children:[E.tool," ",E.plan]},`${E.tool}:${E.plan}:${M}`))}),p.jsxs("div",{className:"mt-4 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800 flex items-center justify-between text-xs text-oai-gray-400 dark:text-oai-gray-400",children:[p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx("span",{children:O("identity_card.rank_label")}),p.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:f})]}),p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("span",{children:O("identity_card.streak_label")}),p.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:m})]})]})]})}const K5=x.createContext(void 0);function jp(t){const e=x.useContext(K5);if(e===void 0&&!t)throw new Error(Wi(47));return e}function die(){return{...l5(),disabled:!1,modal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1}}const fie={...c5,disabled:Rt(t=>t.disabled),instantType:Rt(t=>t.instantType),openMethod:Rt(t=>t.openMethod),openChangeReason:Rt(t=>t.openChangeReason),modal:Rt(t=>t.modal),stickIfOpen:Rt(t=>t.stickIfOpen),titleElementId:Rt(t=>t.titleElementId),descriptionElementId:Rt(t=>t.descriptionElementId),openOnHover:Rt(t=>t.openOnHover),closeDelay:Rt(t=>t.closeDelay),hasViewport:Rt(t=>t.hasViewport)};class FE extends fE{constructor(e){const n={...die(),...e};n.open&&e?.mounted===void 0&&(n.mounted=!0),super(n,{popupRef:x.createRef(),backdropRef:x.createRef(),internalBackdropRef:x.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:x.createRef(),beforeContentFocusGuardRef:x.createRef(),stickIfOpenTimeout:new Il,triggerElements:new sv},fie)}setOpen=(e,n)=>{const r=n.reason===ss,i=n.reason===Pl&&n.event.detail===0,s=!e&&(n.reason===H4||n.reason==null);if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},this.context.onOpenChange?.(e,n),n.isCanceled)return;const a={open:e,nativeEvent:n.event,reason:n.reason,nested:this.state.nested,triggerElement:n.trigger};this.state.floatingRootContext.context.events?.emit("openchange",a);const c=()=>{const u={open:e,openChangeReason:n.reason},f=n.trigger?.id??null;(f||e)&&(u.activeTriggerId=f,u.activeTriggerElement=n.trigger??null),this.update(u)};r?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(oee,()=>{this.set("stickIfOpen",!1)}),gi.flushSync(c)):c(),i||s?this.set("instantType",i?"click":"dismiss"):n.reason===eu?this.set("instantType","focus"):this.set("instantType",void 0)};static useStore(e,n){const r=Vi(()=>new FE(n)).current,i=e??r;return hE(r.disposeEffect),i}disposeEffect=()=>this.context.stickIfOpenTimeout.disposeEffect()}function hP({props:t}){const{children:e,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:s,modal:a=!1,handle:o,triggerId:c,defaultTriggerId:u=null}=t,f=FE.useStore(o?.store,{open:n??r,modal:a,activeTriggerId:c!==void 0?c:u});f.useControlledProp("open",n,r),f.useControlledProp("activeTriggerId",c,u);const h=f.useState("open"),m=f.useState("positionerElement"),g=f.useState("payload"),v=f.useState("openChangeReason");f.useContextCallback("onOpenChange",i),f.useContextCallback("onOpenChangeComplete",s);const{openMethod:w,triggerProps:b,reset:_}=RE(h);a5(f);const{forceUnmount:E}=o5(h,f,()=>{f.update({stickIfOpen:!0,openChangeReason:null}),_()});NE(h&&a===!0&&v!==ss&&w!=="touch",m),x.useEffect(()=>{h||f.context.stickIfOpenTimeout.clear()},[f,h]);const M=x.useCallback(W=>{const X=Mn(W);return X.preventUnmountOnClose=()=>{f.set("preventUnmountingOnClose",!0)},X},[f]),T=x.useCallback(()=>{f.setOpen(!1,M(W4))},[f,M]);x.useImperativeHandle(t.actionsRef,()=>({unmount:E,close:T}),[E,T]);const R=d5({popupStore:f,onOpenChange:f.setOpen}),A=ME(R,{outsidePressEvent:{mouse:a==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),P=h5(R),{getReferenceProps:k,getFloatingProps:N,getTriggerProps:B}=av([A,P]),L=x.useMemo(()=>k(b),[k,b]),z=x.useMemo(()=>B(b),[B,b]),I=x.useMemo(()=>N(),[N]);f.useSyncedValues({modal:a,openMethod:w,activeTriggerProps:L,inactiveTriggerProps:z,popupProps:I,floatingRootContext:R,nested:Hl()!=null});const V=x.useMemo(()=>({store:f}),[f]);return p.jsx(K5.Provider,{value:V,children:typeof e=="function"?e({payload:g}):e})}function Z5(t){return jp(!0)?p.jsx(hP,{props:t}):p.jsx(aee,{children:p.jsx(hP,{props:t})})}const hie=300,J5=x.forwardRef(function(e,n){const{render:r,className:i,disabled:s=!1,nativeButton:a=!0,handle:o,payload:c,openOnHover:u=!1,delay:f=hie,closeDelay:h=0,id:m,...g}=e,v=jp(!0),w=o?.store??v?.store;if(!w)throw new Error(Wi(74));const b=lv(m),_=w.useState("isTriggerActive",b),E=w.useState("floatingRootContext"),M=w.useState("isOpenedByTrigger",b),T=x.useRef(null),{registerTrigger:R,isMountedByThisTrigger:A}=Cte(b,T,w,{payload:c,disabled:s,openOnHover:u,closeDelay:h}),P=w.useState("openChangeReason"),k=w.useState("stickIfOpen"),N=w.useState("openMethod"),B=Fte(E,{enabled:E!=null&&u&&(N!=="touch"||P!==Pl),mouseOnly:!0,move:!1,handleClose:Gte(),restMs:f,delay:{close:h},triggerElementRef:T,isActiveTrigger:_}),L=K4(E,{enabled:E!=null,stickIfOpen:k}),z=av([L]),I=w.useState("triggerProps",A),V=x.useMemo(()=>({disabled:s,open:M}),[s,M]),{getButtonProps:W,buttonRef:X}=cv({disabled:s,native:a}),J=x.useMemo(()=>({open(te){return te&&P===Pl?S5.open(te):w5.open(te)}}),[P]),F=Xr("button",e,{state:V,ref:[X,n,R,T],props:[z.getReferenceProps(),B,I,{[V4]:"",id:b},g,W],stateAttributesMapping:J}),G=x.useRef(null),Y=Bt(te=>{gi.flushSync(()=>{w.setOpen(!1,Mn(eu,te.nativeEvent,te.currentTarget))}),QQ(G.current)?.focus()}),H=Bt(te=>{const re=w.select("positionerElement");if(re&&Rd(te,re))w.context.beforeContentFocusGuardRef.current?.focus();else{gi.flushSync(()=>{w.setOpen(!1,Mn(eu,te.nativeEvent,te.currentTarget))});let ue=JQ(w.context.triggerFocusTargetRef.current||T.current);for(;ue!==null&&On(re,ue);){const ce=ue;if(ue=bE(ue),ue===ce)break}ue?.focus()}});return _?p.jsxs(x.Fragment,{children:[p.jsx(Gd,{ref:G,onFocus:Y}),p.jsx(x.Fragment,{children:F},b),p.jsx(Gd,{ref:w.context.triggerFocusTargetRef,onFocus:H})]}):p.jsx(x.Fragment,{children:F},b)}),Q5=x.createContext(void 0);function pie(){const t=x.useContext(Q5);if(t===void 0)throw new Error(Wi(45));return t}const eF=x.forwardRef(function(e,n){const{keepMounted:r=!1,...i}=e,{store:s}=jp();return s.useState("mounted")||r?p.jsx(Q5.Provider,{value:r,children:p.jsx(wE,{ref:n,...i,renderGuards:!1})}):null}),tF=x.createContext(void 0);function mie(){const t=x.useContext(tF);if(!t)throw new Error(Wi(46));return t}const nF=x.forwardRef(function(e,n){const{render:r,className:i,anchor:s,positionMethod:a="absolute",side:o="bottom",align:c="center",sideOffset:u=0,alignOffset:f=0,collisionBoundary:h="clipping-ancestors",collisionPadding:m=5,arrowPadding:g=5,sticky:v=!1,disableAnchorTracking:w=!1,collisionAvoidance:b=uee,..._}=e,{store:E}=jp(),M=pie(),T=iee(),R=E.useState("floatingRootContext"),A=E.useState("mounted"),P=E.useState("open"),k=E.useState("openChangeReason"),N=E.useState("activeTriggerElement"),B=E.useState("modal"),L=E.useState("positionerElement"),z=E.useState("instantType"),I=E.useState("transitionStatus"),V=E.useState("hasViewport"),W=x.useRef(null),X=s5(L,!1,!1),J=M5({anchor:s,floatingRootContext:R,positionMethod:a,mounted:A,side:o,sideOffset:u,align:c,alignOffset:f,arrowPadding:g,collisionBoundary:h,collisionPadding:m,sticky:v,disableAnchorTracking:w,keepMounted:M,nodeId:T,collisionAvoidance:b,adaptiveOrigin:V?zne:void 0}),F=x.useMemo(()=>{const ue={};return P||(ue.pointerEvents="none"),{role:"presentation",hidden:!A,style:{...J.positionerStyles,...ue}}},[P,A,J.positionerStyles]),G=x.useMemo(()=>({props:F,...J}),[F,J]),Y=R?.select("domReferenceElement");Yt(()=>{const ue=Y,ce=W.current;if(ue&&(W.current=ue),ce&&ue&&ue!==ce){E.set("instantType",void 0);const ee=new AbortController;return X(()=>{E.set("instantType","trigger-change")},ee.signal),()=>{ee.abort()}}},[Y,X,E]);const H=x.useMemo(()=>({open:P,side:G.side,align:G.align,anchorHidden:G.anchorHidden,instant:z}),[P,G.side,G.align,G.anchorHidden,z]),te=x.useCallback(ue=>{E.set("positionerElement",ue)},[E]),re=Xr("div",e,{state:H,props:[G.props,IE(I),_],ref:[n,te],stateAttributesMapping:hu});return p.jsxs(tF.Provider,{value:G,children:[A&&B===!0&&k!==ss&&p.jsx(DE,{ref:E.context.internalBackdropRef,inert:PE(!P),cutout:N}),p.jsx(see,{id:T,children:re})]})}),gie={...hu,...df},rF=x.forwardRef(function(e,n){const{className:r,render:i,initialFocus:s,finalFocus:a,...o}=e,{store:c}=jp(),u=mie(),f=A5()!=null,h=c.useState("open"),m=c.useState("openMethod"),g=c.useState("instantType"),v=c.useState("transitionStatus"),w=c.useState("popupProps"),b=c.useState("titleElementId"),_=c.useState("descriptionElementId"),E=c.useState("modal"),M=c.useState("mounted"),T=c.useState("openChangeReason"),R=c.useState("activeTriggerElement"),A=c.useState("floatingRootContext");ff({open:h,ref:c.context.popupRef,onComplete(){h&&c.context.onOpenChangeComplete?.(!0)}});const P=c.useState("disabled"),k=c.useState("openOnHover"),N=c.useState("closeDelay");Lte(A,{enabled:k&&!P,closeDelay:N});function B(W){return W==="touch"?c.context.popupRef.current:!0}const L=s===void 0?B:s,z=x.useMemo(()=>({open:h,side:u.side,align:u.align,instant:g,transitionStatus:v}),[h,u.side,u.align,g,v]),I=x.useCallback(W=>{c.set("popupElement",W)},[c]),V=Xr("div",e,{state:z,ref:[n,c.context.popupRef,I],props:[w,{"aria-labelledby":b,"aria-describedby":_,onKeyDown(W){f&&LE.has(W.key)&&W.stopPropagation()}},IE(v),o],stateAttributesMapping:gie});return p.jsx(kE,{context:A,openInteractionType:m,modal:E==="trap-focus",disabled:!M||T===ss,initialFocus:L,returnFocus:a,restoreFocus:"popup",previousFocusableElement:Ar(R)?R:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:V})});function yie(t,e,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:t,timeZoneName:n}).format(e).split(/\s/g).slice(2).join(" ")}const vie={},Ah={};function Dc(t,e){try{const r=(vie[t]||=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"longOffset"}).format)(e).split("GMT")[1];return r in Ah?Ah[r]:pP(r,r.split(":"))}catch{if(t in Ah)return Ah[t];const n=t?.match(xie);return n?pP(t,n.slice(1)):NaN}}const xie=/([+-]\d\d):?(\d\d)?/;function pP(t,e){const n=+(e[0]||0),r=+(e[1]||0),i=+(e[2]||0)/60;return Ah[t]=n*60+r>0?n*60+r+i:n*60-r-i}class Pa extends Date{constructor(...e){super(),e.length>1&&typeof e[e.length-1]=="string"&&(this.timeZone=e.pop()),this.internal=new Date,isNaN(Dc(this.timeZone,this))?this.setTime(NaN):e.length?typeof e[0]=="number"&&(e.length===1||e.length===2&&typeof e[1]!="number")?this.setTime(e[0]):typeof e[0]=="string"?this.setTime(+new Date(e[0])):e[0]instanceof Date?this.setTime(+e[0]):(this.setTime(+new Date(...e)),iF(this),N1(this)):this.setTime(Date.now())}static tz(e,...n){return n.length?new Pa(...n,e):new Pa(Date.now(),e)}withTimeZone(e){return new Pa(+this,e)}getTimezoneOffset(){const e=-Dc(this.timeZone,this);return e>0?Math.floor(e):Math.ceil(e)}setTime(e){return Date.prototype.setTime.apply(this,arguments),N1(this),+this}[Symbol.for("constructDateFrom")](e){return new Pa(+new Date(e),this.timeZone)}}const mP=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(t=>{if(!mP.test(t))return;const e=t.replace(mP,"$1UTC");Pa.prototype[e]&&(t.startsWith("get")?Pa.prototype[t]=function(){return this.internal[e]()}:(Pa.prototype[t]=function(){return Date.prototype[e].apply(this.internal,arguments),bie(this),+this},Pa.prototype[e]=function(){return Date.prototype[e].apply(this,arguments),N1(this),+this}))});function N1(t){t.internal.setTime(+t),t.internal.setUTCSeconds(t.internal.getUTCSeconds()-Math.round(-Dc(t.timeZone,t)*60))}function bie(t){Date.prototype.setFullYear.call(t,t.internal.getUTCFullYear(),t.internal.getUTCMonth(),t.internal.getUTCDate()),Date.prototype.setHours.call(t,t.internal.getUTCHours(),t.internal.getUTCMinutes(),t.internal.getUTCSeconds(),t.internal.getUTCMilliseconds()),iF(t)}function iF(t){const e=Dc(t.timeZone,t),n=e>0?Math.floor(e):Math.ceil(e),r=new Date(+t);r.setUTCHours(r.getUTCHours()-1);const i=-new Date(+t).getTimezoneOffset(),s=-new Date(+r).getTimezoneOffset(),a=i-s,o=Date.prototype.getHours.apply(t)!==t.internal.getUTCHours();a&&o&&t.internal.setUTCMinutes(t.internal.getUTCMinutes()+a);const c=i-n;c&&Date.prototype.setUTCMinutes.call(t,Date.prototype.getUTCMinutes.call(t)+c);const u=new Date(+t);u.setUTCSeconds(0);const f=i>0?u.getSeconds():(u.getSeconds()-60)%60,h=Math.round(-(Dc(t.timeZone,t)*60))%60;(h||f)&&(t.internal.setUTCSeconds(t.internal.getUTCSeconds()+h),Date.prototype.setUTCSeconds.call(t,Date.prototype.getUTCSeconds.call(t)+h+f));const m=Dc(t.timeZone,t),g=m>0?Math.floor(m):Math.ceil(m),w=-new Date(+t).getTimezoneOffset()-g,b=g!==n,_=w-c;if(b&&_){Date.prototype.setUTCMinutes.call(t,Date.prototype.getUTCMinutes.call(t)+_);const E=Dc(t.timeZone,t),M=E>0?Math.floor(E):Math.ceil(E),T=g-M;T&&(t.internal.setUTCMinutes(t.internal.getUTCMinutes()+T),Date.prototype.setUTCMinutes.call(t,Date.prototype.getUTCMinutes.call(t)+T))}}class mi extends Pa{static tz(e,...n){return n.length?new mi(...n,e):new mi(Date.now(),e)}toISOString(){const[e,n,r]=this.tzComponents(),i=`${e}${n}:${r}`;return this.internal.toISOString().slice(0,-1)+i}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[e,n,r,i]=this.internal.toUTCString().split(" ");return`${e?.slice(0,-1)} ${r} ${n} ${i}`}toTimeString(){const e=this.internal.toUTCString().split(" ")[4],[n,r,i]=this.tzComponents();return`${e} GMT${n}${r}${i} (${yie(this.timeZone,this)})`}toLocaleString(e,n){return Date.prototype.toLocaleString.call(this,e,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleDateString(e,n){return Date.prototype.toLocaleDateString.call(this,e,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleTimeString(e,n){return Date.prototype.toLocaleTimeString.call(this,e,{...n,timeZone:n?.timeZone||this.timeZone})}tzComponents(){const e=this.getTimezoneOffset(),n=e>0?"-":"+",r=String(Math.floor(Math.abs(e)/60)).padStart(2,"0"),i=String(Math.abs(e)%60).padStart(2,"0");return[n,r,i]}withTimeZone(e){return new mi(+this,e)}[Symbol.for("constructDateFrom")](e){return new mi(+new Date(e),this.timeZone)}}const sF=6048e5,_ie=864e5,gP=Symbol.for("constructDateFrom");function Dr(t,e){return typeof t=="function"?t(e):t&&typeof t=="object"&&gP in t?t[gP](e):t instanceof Date?new t.constructor(e):new Date(e)}function Jn(t,e){return Dr(e||t,t)}function aF(t,e,n){const r=Jn(t,n?.in);return isNaN(e)?Dr(t,NaN):(e&&r.setDate(r.getDate()+e),r)}function oF(t,e,n){const r=Jn(t,n?.in);if(isNaN(e))return Dr(t,NaN);if(!e)return r;const i=r.getDate(),s=Dr(t,r.getTime());s.setMonth(r.getMonth()+e+1,0);const a=s.getDate();return i>=a?s:(r.setFullYear(s.getFullYear(),s.getMonth(),i),r)}let wie={};function Bp(){return wie}function Yd(t,e){const n=Bp(),r=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Jn(t,e?.in),s=i.getDay(),a=(s<r?7:0)+s-r;return i.setDate(i.getDate()-a),i.setHours(0,0,0,0),i}function cp(t,e){return Yd(t,{...e,weekStartsOn:1})}function lF(t,e){const n=Jn(t,e?.in),r=n.getFullYear(),i=Dr(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);const s=cp(i),a=Dr(n,0);a.setFullYear(r,0,4),a.setHours(0,0,0,0);const o=cp(a);return n.getTime()>=s.getTime()?r+1:n.getTime()>=o.getTime()?r:r-1}function yP(t){const e=Jn(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function hf(t,...e){const n=Dr.bind(null,e.find(r=>typeof r=="object"));return e.map(n)}function up(t,e){const n=Jn(t,e?.in);return n.setHours(0,0,0,0),n}function UE(t,e,n){const[r,i]=hf(n?.in,t,e),s=up(r),a=up(i),o=+s-yP(s),c=+a-yP(a);return Math.round((o-c)/_ie)}function Sie(t,e){const n=lF(t,e),r=Dr(t,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),cp(r)}function kie(t,e,n){return aF(t,e*7,n)}function Eie(t,e,n){return oF(t,e*12,n)}function Mie(t,e){let n,r=e?.in;return t.forEach(i=>{!r&&typeof i=="object"&&(r=Dr.bind(null,i));const s=Jn(i,r);(!n||n<s||isNaN(+s))&&(n=s)}),Dr(r,n||NaN)}function Tie(t,e){let n,r=e?.in;return t.forEach(i=>{!r&&typeof i=="object"&&(r=Dr.bind(null,i));const s=Jn(i,r);(!n||n>s||isNaN(+s))&&(n=s)}),Dr(r,n||NaN)}function Cie(t,e,n){const[r,i]=hf(n?.in,t,e);return+up(r)==+up(i)}function cF(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function Aie(t){return!(!cF(t)&&typeof t!="number"||isNaN(+Jn(t)))}function uF(t,e,n){const[r,i]=hf(n?.in,t,e),s=r.getFullYear()-i.getFullYear(),a=r.getMonth()-i.getMonth();return s*12+a}function Rie(t,e){const n=Jn(t,e?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function dF(t,e){const[n,r]=hf(t,e.start,e.end);return{start:n,end:r}}function Pie(t,e){const{start:n,end:r}=dF(e?.in,t);let i=+n>+r;const s=i?+n:+r,a=i?r:n;a.setHours(0,0,0,0),a.setDate(1);let o=1;const c=[];for(;+a<=s;)c.push(Dr(n,a)),a.setMonth(a.getMonth()+o);return i?c.reverse():c}function Nie(t,e){const n=Jn(t,e?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function Die(t,e){const n=Jn(t,e?.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function fF(t,e){const n=Jn(t,e?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Lie(t,e){const{start:n,end:r}=dF(e?.in,t);let i=+n>+r;const s=i?+n:+r,a=i?r:n;a.setHours(0,0,0,0),a.setMonth(0,1);let o=1;const c=[];for(;+a<=s;)c.push(Dr(n,a)),a.setFullYear(a.getFullYear()+o);return i?c.reverse():c}function hF(t,e){const n=Bp(),r=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Jn(t,e?.in),s=i.getDay(),a=(s<r?-7:0)+6-(s-r);return i.setDate(i.getDate()+a),i.setHours(23,59,59,999),i}function Iie(t,e){return hF(t,{...e,weekStartsOn:1})}const Oie={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Fie=(t,e,n)=>{let r;const i=Oie[t];return typeof i=="string"?r=i:e===1?r=i.one:r=i.other.replace("{{count}}",e.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function m_(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const Uie={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},jie={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Bie={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},zie={date:m_({formats:Uie,defaultWidth:"full"}),time:m_({formats:jie,defaultWidth:"full"}),dateTime:m_({formats:Bie,defaultWidth:"full"})},Vie={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Hie=(t,e,n,r)=>Vie[t];function dh(t){return(e,n)=>{const r=n?.context?String(n.context):"standalone";let i;if(r==="formatting"&&t.formattingValues){const a=t.defaultFormattingWidth||t.defaultWidth,o=n?.width?String(n.width):a;i=t.formattingValues[o]||t.formattingValues[a]}else{const a=t.defaultWidth,o=n?.width?String(n.width):t.defaultWidth;i=t.values[o]||t.values[a]}const s=t.argumentCallback?t.argumentCallback(e):e;return i[s]}}const Wie={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Gie={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},$ie={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Yie={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},qie={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Xie={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Kie=(t,e)=>{const n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},Zie={ordinalNumber:Kie,era:dh({values:Wie,defaultWidth:"wide"}),quarter:dh({values:Gie,defaultWidth:"wide",argumentCallback:t=>t-1}),month:dh({values:$ie,defaultWidth:"wide"}),day:dh({values:Yie,defaultWidth:"wide"}),dayPeriod:dh({values:qie,defaultWidth:"wide",formattingValues:Xie,defaultFormattingWidth:"wide"})};function fh(t){return(e,n={})=>{const r=n.width,i=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],s=e.match(i);if(!s)return null;const a=s[0],o=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],c=Array.isArray(o)?Qie(o,h=>h.test(a)):Jie(o,h=>h.test(a));let u;u=t.valueCallback?t.valueCallback(c):c,u=n.valueCallback?n.valueCallback(u):u;const f=e.slice(a.length);return{value:u,rest:f}}}function Jie(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function Qie(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function ese(t){return(e,n={})=>{const r=e.match(t.matchPattern);if(!r)return null;const i=r[0],s=e.match(t.parsePattern);if(!s)return null;let a=t.valueCallback?t.valueCallback(s[0]):s[0];a=n.valueCallback?n.valueCallback(a):a;const o=e.slice(i.length);return{value:a,rest:o}}}const tse=/^(\d+)(th|st|nd|rd)?/i,nse=/\d+/i,rse={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},ise={any:[/^b/i,/^(a|c)/i]},sse={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ase={any:[/1/i,/2/i,/3/i,/4/i]},ose={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},lse={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},cse={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},use={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},dse={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},fse={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},hse={ordinalNumber:ese({matchPattern:tse,parsePattern:nse,valueCallback:t=>parseInt(t,10)}),era:fh({matchPatterns:rse,defaultMatchWidth:"wide",parsePatterns:ise,defaultParseWidth:"any"}),quarter:fh({matchPatterns:sse,defaultMatchWidth:"wide",parsePatterns:ase,defaultParseWidth:"any",valueCallback:t=>t+1}),month:fh({matchPatterns:ose,defaultMatchWidth:"wide",parsePatterns:lse,defaultParseWidth:"any"}),day:fh({matchPatterns:cse,defaultMatchWidth:"wide",parsePatterns:use,defaultParseWidth:"any"}),dayPeriod:fh({matchPatterns:dse,defaultMatchWidth:"any",parsePatterns:fse,defaultParseWidth:"any"})},vd={code:"en-US",formatDistance:Fie,formatLong:zie,formatRelative:Hie,localize:Zie,match:hse,options:{weekStartsOn:0,firstWeekContainsDate:1}};function pse(t,e){const n=Jn(t,e?.in);return UE(n,fF(n))+1}function jE(t,e){const n=Jn(t,e?.in),r=+cp(n)-+Sie(n);return Math.round(r/sF)+1}function pF(t,e){const n=Jn(t,e?.in),r=n.getFullYear(),i=Bp(),s=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,a=Dr(e?.in||t,0);a.setFullYear(r+1,0,s),a.setHours(0,0,0,0);const o=Yd(a,e),c=Dr(e?.in||t,0);c.setFullYear(r,0,s),c.setHours(0,0,0,0);const u=Yd(c,e);return+n>=+o?r+1:+n>=+u?r:r-1}function mse(t,e){const n=Bp(),r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=pF(t,e),s=Dr(e?.in||t,0);return s.setFullYear(i,0,r),s.setHours(0,0,0,0),Yd(s,e)}function BE(t,e){const n=Jn(t,e?.in),r=+Yd(n,e)-+mse(n,e);return Math.round(r/sF)+1}function Xn(t,e){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(e,"0");return n+r}const ol={y(t,e){const n=t.getFullYear(),r=n>0?n:1-n;return Xn(e==="yy"?r%100:r,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):Xn(n+1,2)},d(t,e){return Xn(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return n==="am"?"a.m.":"p.m."}},h(t,e){return Xn(t.getHours()%12||12,e.length)},H(t,e){return Xn(t.getHours(),e.length)},m(t,e){return Xn(t.getMinutes(),e.length)},s(t,e){return Xn(t.getSeconds(),e.length)},S(t,e){const n=e.length,r=t.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return Xn(i,e.length)}},Zu={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},vP={G:function(t,e,n){const r=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});default:return n.era(r,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const r=t.getFullYear(),i=r>0?r:1-r;return n.ordinalNumber(i,{unit:"year"})}return ol.y(t,e)},Y:function(t,e,n,r){const i=pF(t,r),s=i>0?i:1-i;if(e==="YY"){const a=s%100;return Xn(a,2)}return e==="Yo"?n.ordinalNumber(s,{unit:"year"}):Xn(s,e.length)},R:function(t,e){const n=lF(t);return Xn(n,e.length)},u:function(t,e){const n=t.getFullYear();return Xn(n,e.length)},Q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return Xn(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return Xn(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(t,e,n){const r=t.getMonth();switch(e){case"M":case"MM":return ol.M(t,e);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(t,e,n){const r=t.getMonth();switch(e){case"L":return String(r+1);case"LL":return Xn(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(t,e,n,r){const i=BE(t,r);return e==="wo"?n.ordinalNumber(i,{unit:"week"}):Xn(i,e.length)},I:function(t,e,n){const r=jE(t);return e==="Io"?n.ordinalNumber(r,{unit:"week"}):Xn(r,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):ol.d(t,e)},D:function(t,e,n){const r=pse(t);return e==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):Xn(r,e.length)},E:function(t,e,n){const r=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,e,n,r){const i=t.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(s);case"ee":return Xn(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(t,e,n,r){const i=t.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(s);case"cc":return Xn(s,e.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(t,e,n){const r=t.getDay(),i=r===0?7:r;switch(e){case"i":return String(i);case"ii":return Xn(i,e.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(t,e,n){const i=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(t,e,n){const r=t.getHours();let i;switch(r===12?i=Zu.noon:r===0?i=Zu.midnight:i=r/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(t,e,n){const r=t.getHours();let i;switch(r>=17?i=Zu.evening:r>=12?i=Zu.afternoon:r>=4?i=Zu.morning:i=Zu.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let r=t.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return ol.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):ol.H(t,e)},K:function(t,e,n){const r=t.getHours()%12;return e==="Ko"?n.ordinalNumber(r,{unit:"hour"}):Xn(r,e.length)},k:function(t,e,n){let r=t.getHours();return r===0&&(r=24),e==="ko"?n.ordinalNumber(r,{unit:"hour"}):Xn(r,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):ol.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):ol.s(t,e)},S:function(t,e){return ol.S(t,e)},X:function(t,e,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(e){case"X":return bP(r);case"XXXX":case"XX":return kc(r);default:return kc(r,":")}},x:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"x":return bP(r);case"xxxx":case"xx":return kc(r);default:return kc(r,":")}},O:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+xP(r,":");default:return"GMT"+kc(r,":")}},z:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+xP(r,":");default:return"GMT"+kc(r,":")}},t:function(t,e,n){const r=Math.trunc(+t/1e3);return Xn(r,e.length)},T:function(t,e,n){return Xn(+t,e.length)}};function xP(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),i=Math.trunc(r/60),s=r%60;return s===0?n+String(i):n+String(i)+e+Xn(s,2)}function bP(t,e){return t%60===0?(t>0?"-":"+")+Xn(Math.abs(t)/60,2):kc(t,e)}function kc(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),i=Xn(Math.trunc(r/60),2),s=Xn(r%60,2);return n+i+e+s}const _P=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});default:return e.date({width:"full"})}},mF=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});default:return e.time({width:"full"})}},gse=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return _P(t,e);let s;switch(r){case"P":s=e.dateTime({width:"short"});break;case"PP":s=e.dateTime({width:"medium"});break;case"PPP":s=e.dateTime({width:"long"});break;default:s=e.dateTime({width:"full"});break}return s.replace("{{date}}",_P(r,e)).replace("{{time}}",mF(i,e))},yse={p:mF,P:gse},vse=/^D+$/,xse=/^Y+$/,bse=["D","DD","YY","YYYY"];function _se(t){return vse.test(t)}function wse(t){return xse.test(t)}function Sse(t,e,n){const r=kse(t,e,n);if(console.warn(r),bse.includes(t))throw new RangeError(r)}function kse(t,e,n){const r=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Ese=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Mse=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Tse=/^'([^]*?)'?$/,Cse=/''/g,Ase=/[a-zA-Z]/;function Na(t,e,n){const r=Bp(),i=n?.locale??r.locale??vd,s=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,o=Jn(t,n?.in);if(!Aie(o))throw new RangeError("Invalid time value");let c=e.match(Mse).map(f=>{const h=f[0];if(h==="p"||h==="P"){const m=yse[h];return m(f,i.formatLong)}return f}).join("").match(Ese).map(f=>{if(f==="''")return{isToken:!1,value:"'"};const h=f[0];if(h==="'")return{isToken:!1,value:Rse(f)};if(vP[h])return{isToken:!0,value:f};if(h.match(Ase))throw new RangeError("Format string contains an unescaped latin alphabet character `"+h+"`");return{isToken:!1,value:f}});i.localize.preprocessor&&(c=i.localize.preprocessor(o,c));const u={firstWeekContainsDate:s,weekStartsOn:a,locale:i};return c.map(f=>{if(!f.isToken)return f.value;const h=f.value;(!n?.useAdditionalWeekYearTokens&&wse(h)||!n?.useAdditionalDayOfYearTokens&&_se(h))&&Sse(h,e,String(t));const m=vP[h[0]];return m(o,h,i.localize,u)}).join("")}function Rse(t){const e=t.match(Tse);return e?e[1].replace(Cse,"'"):t}function Pse(t,e){const n=Jn(t,e?.in),r=n.getFullYear(),i=n.getMonth(),s=Dr(n,0);return s.setFullYear(r,i+1,0),s.setHours(0,0,0,0),s.getDate()}function Nse(t,e){return Jn(t,e?.in).getMonth()}function Dse(t,e){return Jn(t,e?.in).getFullYear()}function Lse(t,e){return+Jn(t)>+Jn(e)}function Ise(t,e){return+Jn(t)<+Jn(e)}function Ose(t,e,n){const[r,i]=hf(n?.in,t,e);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()}function Fse(t,e,n){const[r,i]=hf(n?.in,t,e);return r.getFullYear()===i.getFullYear()}function Use(t,e,n){const r=Jn(t,n?.in),i=r.getFullYear(),s=r.getDate(),a=Dr(t,0);a.setFullYear(i,e,15),a.setHours(0,0,0,0);const o=Pse(a);return r.setMonth(e,Math.min(s,o)),r}function jse(t,e,n){const r=Jn(t,n?.in);return isNaN(+r)?Dr(t,NaN):(r.setFullYear(e),r)}const wP=5,Bse=4;function zse(t,e){const n=e.startOfMonth(t),r=n.getDay()>0?n.getDay():7,i=e.addDays(t,-r+1),s=e.addDays(i,wP*7-1);return e.getMonth(t)===e.getMonth(s)?wP:Bse}function gF(t,e){const n=e.startOfMonth(t),r=n.getDay();return r===1?n:r===0?e.addDays(n,-6):e.addDays(n,-1*(r-1))}function Vse(t,e){const n=gF(t,e),r=zse(t,e);return e.addDays(n,r*7-1)}const yF={...vd,labels:{labelDayButton:(t,e,n,r)=>{let i;r&&typeof r.format=="function"?i=r.format.bind(r):i=(a,o)=>Na(a,o,{locale:vd,...n});let s=i(t,"PPPP");return e.today&&(s=`Today, ${s}`),e.selected&&(s=`${s}, selected`),s},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:t=>`Week ${t}`,labelYearDropdown:"Choose the Year",labelGrid:(t,e,n)=>{let r;return n&&typeof n.format=="function"?r=n.format.bind(n):r=(i,s)=>Na(i,s,{locale:vd,...e}),r(t,"LLLL yyyy")},labelGridcell:(t,e,n,r)=>{let i;r&&typeof r.format=="function"?i=r.format.bind(r):i=(a,o)=>Na(a,o,{locale:vd,...n});let s=i(t,"PPPP");return e?.today&&(s=`Today, ${s}`),s},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(t,e,n)=>{let r;return n&&typeof n.format=="function"?r=n.format.bind(n):r=(i,s)=>Na(i,s,{locale:vd,...e}),r(t,"cccc")}}};class us{constructor(e,n){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?mi.tz(this.options.timeZone):new this.Date,this.newDate=(r,i,s)=>this.overrides?.newDate?this.overrides.newDate(r,i,s):this.options.timeZone?new mi(r,i,s,this.options.timeZone):new Date(r,i,s),this.addDays=(r,i)=>this.overrides?.addDays?this.overrides.addDays(r,i):aF(r,i),this.addMonths=(r,i)=>this.overrides?.addMonths?this.overrides.addMonths(r,i):oF(r,i),this.addWeeks=(r,i)=>this.overrides?.addWeeks?this.overrides.addWeeks(r,i):kie(r,i),this.addYears=(r,i)=>this.overrides?.addYears?this.overrides.addYears(r,i):Eie(r,i),this.differenceInCalendarDays=(r,i)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(r,i):UE(r,i),this.differenceInCalendarMonths=(r,i)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(r,i):uF(r,i),this.eachMonthOfInterval=r=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(r):Pie(r),this.eachYearOfInterval=r=>{const i=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(r):Lie(r),s=new Set(i.map(o=>this.getYear(o)));if(s.size===i.length)return i;const a=[];return s.forEach(o=>{a.push(new Date(o,0,1))}),a},this.endOfBroadcastWeek=r=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(r):Vse(r,this),this.endOfISOWeek=r=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(r):Iie(r),this.endOfMonth=r=>this.overrides?.endOfMonth?this.overrides.endOfMonth(r):Rie(r),this.endOfWeek=(r,i)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(r,i):hF(r,this.options),this.endOfYear=r=>this.overrides?.endOfYear?this.overrides.endOfYear(r):Die(r),this.format=(r,i,s)=>{const a=this.overrides?.format?this.overrides.format(r,i,this.options):Na(r,i,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(a):a},this.getISOWeek=r=>this.overrides?.getISOWeek?this.overrides.getISOWeek(r):jE(r),this.getMonth=(r,i)=>this.overrides?.getMonth?this.overrides.getMonth(r,this.options):Nse(r,this.options),this.getYear=(r,i)=>this.overrides?.getYear?this.overrides.getYear(r,this.options):Dse(r,this.options),this.getWeek=(r,i)=>this.overrides?.getWeek?this.overrides.getWeek(r,this.options):BE(r,this.options),this.isAfter=(r,i)=>this.overrides?.isAfter?this.overrides.isAfter(r,i):Lse(r,i),this.isBefore=(r,i)=>this.overrides?.isBefore?this.overrides.isBefore(r,i):Ise(r,i),this.isDate=r=>this.overrides?.isDate?this.overrides.isDate(r):cF(r),this.isSameDay=(r,i)=>this.overrides?.isSameDay?this.overrides.isSameDay(r,i):Cie(r,i),this.isSameMonth=(r,i)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(r,i):Ose(r,i),this.isSameYear=(r,i)=>this.overrides?.isSameYear?this.overrides.isSameYear(r,i):Fse(r,i),this.max=r=>this.overrides?.max?this.overrides.max(r):Mie(r),this.min=r=>this.overrides?.min?this.overrides.min(r):Tie(r),this.setMonth=(r,i)=>this.overrides?.setMonth?this.overrides.setMonth(r,i):Use(r,i),this.setYear=(r,i)=>this.overrides?.setYear?this.overrides.setYear(r,i):jse(r,i),this.startOfBroadcastWeek=(r,i)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(r,this):gF(r,this),this.startOfDay=r=>this.overrides?.startOfDay?this.overrides.startOfDay(r):up(r),this.startOfISOWeek=r=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(r):cp(r),this.startOfMonth=r=>this.overrides?.startOfMonth?this.overrides.startOfMonth(r):Nie(r),this.startOfWeek=(r,i)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(r,this.options):Yd(r,this.options),this.startOfYear=r=>this.overrides?.startOfYear?this.overrides.startOfYear(r):fF(r),this.options={locale:yF,...e},this.overrides=n}getDigitMap(){const{numerals:e="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:e}),r={};for(let i=0;i<10;i++)r[i.toString()]=n.format(i);return r}replaceDigits(e){const n=this.getDigitMap();return e.replace(/\d/g,r=>n[r]||r)}formatNumber(e){return this.replaceDigits(e.toString())}getMonthYearOrder(){const e=this.options.locale?.code;return e&&us.yearFirstLocales.has(e)?"year-first":"month-first"}formatMonthYear(e){const{locale:n,timeZone:r,numerals:i}=this.options,s=n?.code;if(s&&us.yearFirstLocales.has(s))try{return new Intl.DateTimeFormat(s,{month:"long",year:"numeric",timeZone:r,numberingSystem:i}).format(e)}catch{}const a=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(e,a)}}us.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const Qa=new us;class vF{constructor(e,n,r=Qa){this.date=e,this.displayMonth=n,this.outside=!!(n&&!r.isSameMonth(e,n)),this.dateLib=r,this.isoDate=r.format(e,"yyyy-MM-dd"),this.displayMonthId=r.format(n,"yyyy-MM"),this.dateMonthId=r.format(e,"yyyy-MM")}isEqualTo(e){return this.dateLib.isSameDay(e.date,this.date)&&this.dateLib.isSameMonth(e.displayMonth,this.displayMonth)}}class Hse{constructor(e,n){this.date=e,this.weeks=n}}class Wse{constructor(e,n){this.days=n,this.weekNumber=e}}function Gse(t){return ot.createElement("button",{...t})}function $se(t){return ot.createElement("span",{...t})}function Yse(t){const{size:e=24,orientation:n="left",className:r}=t;return ot.createElement("svg",{className:r,width:e,height:e,viewBox:"0 0 24 24"},n==="up"&&ot.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&ot.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&ot.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&ot.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function qse(t){const{day:e,modifiers:n,...r}=t;return ot.createElement("td",{...r})}function Xse(t){const{day:e,modifiers:n,...r}=t,i=ot.useRef(null);return ot.useEffect(()=>{n.focused&&i.current?.focus()},[n.focused]),ot.createElement("button",{ref:i,...r})}var Zt;(function(t){t.Root="root",t.Chevron="chevron",t.Day="day",t.DayButton="day_button",t.CaptionLabel="caption_label",t.Dropdowns="dropdowns",t.Dropdown="dropdown",t.DropdownRoot="dropdown_root",t.Footer="footer",t.MonthGrid="month_grid",t.MonthCaption="month_caption",t.MonthsDropdown="months_dropdown",t.Month="month",t.Months="months",t.Nav="nav",t.NextMonthButton="button_next",t.PreviousMonthButton="button_previous",t.Week="week",t.Weeks="weeks",t.Weekday="weekday",t.Weekdays="weekdays",t.WeekNumber="week_number",t.WeekNumberHeader="week_number_header",t.YearsDropdown="years_dropdown"})(Zt||(Zt={}));var fr;(function(t){t.disabled="disabled",t.hidden="hidden",t.outside="outside",t.focused="focused",t.today="today"})(fr||(fr={}));var ea;(function(t){t.range_end="range_end",t.range_middle="range_middle",t.range_start="range_start",t.selected="selected"})(ea||(ea={}));var ns;(function(t){t.weeks_before_enter="weeks_before_enter",t.weeks_before_exit="weeks_before_exit",t.weeks_after_enter="weeks_after_enter",t.weeks_after_exit="weeks_after_exit",t.caption_after_enter="caption_after_enter",t.caption_after_exit="caption_after_exit",t.caption_before_enter="caption_before_enter",t.caption_before_exit="caption_before_exit"})(ns||(ns={}));function Kse(t){const{options:e,className:n,components:r,classNames:i,...s}=t,a=[i[Zt.Dropdown],n].join(" "),o=e?.find(({value:c})=>c===s.value);return ot.createElement("span",{"data-disabled":s.disabled,className:i[Zt.DropdownRoot]},ot.createElement(r.Select,{className:a,...s},e?.map(({value:c,label:u,disabled:f})=>ot.createElement(r.Option,{key:c,value:c,disabled:f},u))),ot.createElement("span",{className:i[Zt.CaptionLabel],"aria-hidden":!0},o?.label,ot.createElement(r.Chevron,{orientation:"down",size:18,className:i[Zt.Chevron]})))}function Zse(t){return ot.createElement("div",{...t})}function Jse(t){return ot.createElement("div",{...t})}function Qse(t){const{calendarMonth:e,displayIndex:n,...r}=t;return ot.createElement("div",{...r},t.children)}function eae(t){const{calendarMonth:e,displayIndex:n,...r}=t;return ot.createElement("div",{...r})}function tae(t){return ot.createElement("table",{...t})}function nae(t){return ot.createElement("div",{...t})}const xF=x.createContext(void 0);function zp(){const t=x.useContext(xF);if(t===void 0)throw new Error("useDayPicker() must be used within a custom component.");return t}function rae(t){const{components:e}=zp();return ot.createElement(e.Dropdown,{...t})}function iae(t){const{onPreviousClick:e,onNextClick:n,previousMonth:r,nextMonth:i,...s}=t,{components:a,classNames:o,labels:{labelPrevious:c,labelNext:u}}=zp(),f=x.useCallback(m=>{i&&n?.(m)},[i,n]),h=x.useCallback(m=>{r&&e?.(m)},[r,e]);return ot.createElement("nav",{...s},ot.createElement(a.PreviousMonthButton,{type:"button",className:o[Zt.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":c(r),onClick:h},ot.createElement(a.Chevron,{disabled:r?void 0:!0,className:o[Zt.Chevron],orientation:"left"})),ot.createElement(a.NextMonthButton,{type:"button",className:o[Zt.NextMonthButton],tabIndex:i?void 0:-1,"aria-disabled":i?void 0:!0,"aria-label":u(i),onClick:f},ot.createElement(a.Chevron,{disabled:i?void 0:!0,orientation:"right",className:o[Zt.Chevron]})))}function sae(t){const{components:e}=zp();return ot.createElement(e.Button,{...t})}function aae(t){return ot.createElement("option",{...t})}function oae(t){const{components:e}=zp();return ot.createElement(e.Button,{...t})}function lae(t){const{rootRef:e,...n}=t;return ot.createElement("div",{...n,ref:e})}function cae(t){return ot.createElement("select",{...t})}function uae(t){const{week:e,...n}=t;return ot.createElement("tr",{...n})}function dae(t){return ot.createElement("th",{...t})}function fae(t){return ot.createElement("thead",{"aria-hidden":!0},ot.createElement("tr",{...t}))}function hae(t){const{week:e,...n}=t;return ot.createElement("th",{...n})}function pae(t){return ot.createElement("th",{...t})}function mae(t){return ot.createElement("tbody",{...t})}function gae(t){const{components:e}=zp();return ot.createElement(e.Dropdown,{...t})}const yae=Object.freeze(Object.defineProperty({__proto__:null,Button:Gse,CaptionLabel:$se,Chevron:Yse,Day:qse,DayButton:Xse,Dropdown:Kse,DropdownNav:Zse,Footer:Jse,Month:Qse,MonthCaption:eae,MonthGrid:tae,Months:nae,MonthsDropdown:rae,Nav:iae,NextMonthButton:sae,Option:aae,PreviousMonthButton:oae,Root:lae,Select:cae,Week:uae,WeekNumber:hae,WeekNumberHeader:pae,Weekday:dae,Weekdays:fae,Weeks:mae,YearsDropdown:gae},Symbol.toStringTag,{value:"Module"}));function ko(t,e,n=!1,r=Qa){let{from:i,to:s}=t;const{differenceInCalendarDays:a,isSameDay:o}=r;return i&&s?(a(s,i)<0&&([i,s]=[s,i]),a(e,i)>=(n?1:0)&&a(s,e)>=(n?1:0)):!n&&s?o(s,e):!n&&i?o(i,e):!1}function zE(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function uv(t){return!!(t&&typeof t=="object"&&"from"in t)}function VE(t){return!!(t&&typeof t=="object"&&"after"in t)}function HE(t){return!!(t&&typeof t=="object"&&"before"in t)}function bF(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function _F(t,e){return Array.isArray(t)&&t.every(e.isDate)}function Eo(t,e,n=Qa){const r=Array.isArray(e)?e:[e],{isSameDay:i,differenceInCalendarDays:s,isAfter:a}=n;return r.some(o=>{if(typeof o=="boolean")return o;if(n.isDate(o))return i(t,o);if(_F(o,n))return o.some(c=>i(t,c));if(uv(o))return ko(o,t,!1,n);if(bF(o))return Array.isArray(o.dayOfWeek)?o.dayOfWeek.includes(t.getDay()):o.dayOfWeek===t.getDay();if(zE(o)){const c=s(o.before,t),u=s(o.after,t),f=c>0,h=u<0;return a(o.before,o.after)?h&&f:f||h}return VE(o)?s(t,o.after)>0:HE(o)?s(o.before,t)>0:typeof o=="function"?o(t):!1})}function vae(t,e,n,r,i){const{disabled:s,hidden:a,modifiers:o,showOutsideDays:c,broadcastCalendar:u,today:f=i.today()}=e,{isSameDay:h,isSameMonth:m,startOfMonth:g,isBefore:v,endOfMonth:w,isAfter:b}=i,_=n&&g(n),E=r&&w(r),M={[fr.focused]:[],[fr.outside]:[],[fr.disabled]:[],[fr.hidden]:[],[fr.today]:[]},T={};for(const R of t){const{date:A,displayMonth:P}=R,k=!!(P&&!m(A,P)),N=!!(_&&v(A,_)),B=!!(E&&b(A,E)),L=!!(s&&Eo(A,s,i)),z=!!(a&&Eo(A,a,i))||N||B||!u&&!c&&k||u&&c===!1&&k,I=h(A,f);k&&M.outside.push(R),L&&M.disabled.push(R),z&&M.hidden.push(R),I&&M.today.push(R),o&&Object.keys(o).forEach(V=>{const W=o?.[V];W&&Eo(A,W,i)&&(T[V]?T[V].push(R):T[V]=[R])})}return R=>{const A={[fr.focused]:!1,[fr.disabled]:!1,[fr.hidden]:!1,[fr.outside]:!1,[fr.today]:!1},P={};for(const k in M){const N=M[k];A[k]=N.some(B=>B===R)}for(const k in T)P[k]=T[k].some(N=>N===R);return{...A,...P}}}function xae(t,e,n={}){return Object.entries(t).filter(([,i])=>i===!0).reduce((i,[s])=>(n[s]?i.push(n[s]):e[fr[s]]?i.push(e[fr[s]]):e[ea[s]]&&i.push(e[ea[s]]),i),[e[Zt.Day]])}function bae(t){return{...yae,...t}}function _ae(t){const e={"data-mode":t.mode??void 0,"data-required":"required"in t?t.required:void 0,"data-multiple-months":t.numberOfMonths&&t.numberOfMonths>1||void 0,"data-week-numbers":t.showWeekNumber||void 0,"data-broadcast-calendar":t.broadcastCalendar||void 0,"data-nav-layout":t.navLayout||void 0};return Object.entries(t).forEach(([n,r])=>{n.startsWith("data-")&&(e[n]=r)}),e}function wae(){const t={};for(const e in Zt)t[Zt[e]]=`rdp-${Zt[e]}`;for(const e in fr)t[fr[e]]=`rdp-${fr[e]}`;for(const e in ea)t[ea[e]]=`rdp-${ea[e]}`;for(const e in ns)t[ns[e]]=`rdp-${ns[e]}`;return t}function wF(t,e,n){return(n??new us(e)).formatMonthYear(t)}const Sae=wF;function kae(t,e,n){return(n??new us(e)).format(t,"d")}function Eae(t,e=Qa){return e.format(t,"LLLL")}function Mae(t,e,n){return(n??new us(e)).format(t,"cccccc")}function Tae(t,e=Qa){return t<10?e.formatNumber(`0${t.toLocaleString()}`):e.formatNumber(`${t.toLocaleString()}`)}function Cae(){return""}function SF(t,e=Qa){return e.format(t,"yyyy")}const Aae=SF,Rae=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:wF,formatDay:kae,formatMonthCaption:Sae,formatMonthDropdown:Eae,formatWeekNumber:Tae,formatWeekNumberHeader:Cae,formatWeekdayName:Mae,formatYearCaption:Aae,formatYearDropdown:SF},Symbol.toStringTag,{value:"Module"}));function Pae(t){return t?.formatMonthCaption&&!t.formatCaption&&(t.formatCaption=t.formatMonthCaption),t?.formatYearCaption&&!t.formatYearDropdown&&(t.formatYearDropdown=t.formatYearCaption),{...Rae,...t}}function WE(t,e,n,r){let i=(r??new us(n)).format(t,"PPPP");return e.today&&(i=`Today, ${i}`),e.selected&&(i=`${i}, selected`),i}const Nae=WE;function GE(t,e,n){return(n??new us(e)).formatMonthYear(t)}const Dae=GE;function kF(t,e,n,r){let i=(r??new us(n)).format(t,"PPPP");return e?.today&&(i=`Today, ${i}`),i}function EF(t){return"Choose the Month"}function MF(){return""}const Lae="Go to the Next Month";function TF(t,e){return Lae}function CF(t){return"Go to the Previous Month"}function AF(t,e,n){return(n??new us(e)).format(t,"cccc")}function RF(t,e){return`Week ${t}`}function PF(t){return"Week Number"}function NF(t){return"Choose the Year"}const Iae=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:Dae,labelDay:Nae,labelDayButton:WE,labelGrid:GE,labelGridcell:kF,labelMonthDropdown:EF,labelNav:MF,labelNext:TF,labelPrevious:CF,labelWeekNumber:RF,labelWeekNumberHeader:PF,labelWeekday:AF,labelYearDropdown:NF},Symbol.toStringTag,{value:"Module"})),Ws=(t,e,n)=>e||(n?typeof n=="function"?n:(...r)=>n:t);function Oae(t,e){const n=e.locale?.labels??{};return{...Iae,...t??{},labelDayButton:Ws(WE,t?.labelDayButton,n.labelDayButton),labelMonthDropdown:Ws(EF,t?.labelMonthDropdown,n.labelMonthDropdown),labelNext:Ws(TF,t?.labelNext,n.labelNext),labelPrevious:Ws(CF,t?.labelPrevious,n.labelPrevious),labelWeekNumber:Ws(RF,t?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:Ws(NF,t?.labelYearDropdown,n.labelYearDropdown),labelGrid:Ws(GE,t?.labelGrid,n.labelGrid),labelGridcell:Ws(kF,t?.labelGridcell,n.labelGridcell),labelNav:Ws(MF,t?.labelNav,n.labelNav),labelWeekNumberHeader:Ws(PF,t?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:Ws(AF,t?.labelWeekday,n.labelWeekday)}}function Fae(t,e,n,r,i){const{startOfMonth:s,startOfYear:a,endOfYear:o,eachMonthOfInterval:c,getMonth:u}=i;return c({start:a(t),end:o(t)}).map(m=>{const g=r.formatMonthDropdown(m,i),v=u(m),w=e&&m<s(e)||n&&m>s(n)||!1;return{value:v,label:g,disabled:w}})}function Uae(t,e={},n={}){let r={...e?.[Zt.Day]};return Object.entries(t).filter(([,i])=>i===!0).forEach(([i])=>{r={...r,...n?.[i]}}),r}function jae(t,e,n,r){const i=r??t.today(),s=n?t.startOfBroadcastWeek(i,t):e?t.startOfISOWeek(i):t.startOfWeek(i),a=[];for(let o=0;o<7;o++){const c=t.addDays(s,o);a.push(c)}return a}function Bae(t,e,n,r,i=!1){if(!t||!e)return;const{startOfYear:s,endOfYear:a,eachYearOfInterval:o,getYear:c}=r,u=s(t),f=a(e),h=o({start:u,end:f});return i&&h.reverse(),h.map(m=>{const g=n.formatYearDropdown(m,r);return{value:c(m),label:g,disabled:!1}})}function zae(t,e={}){const{weekStartsOn:n,locale:r}=e,i=n??r?.options?.weekStartsOn??0,s=o=>{const c=typeof o=="number"||typeof o=="string"?new Date(o):o;return new mi(c.getFullYear(),c.getMonth(),c.getDate(),12,0,0,t)},a=o=>{const c=s(o);return new Date(c.getFullYear(),c.getMonth(),c.getDate(),0,0,0,0)};return{today:()=>s(mi.tz(t)),newDate:(o,c,u)=>new mi(o,c,u,12,0,0,t),startOfDay:o=>s(o),startOfWeek:(o,c)=>{const u=s(o),f=c?.weekStartsOn??i,h=(u.getDay()-f+7)%7;return u.setDate(u.getDate()-h),u},startOfISOWeek:o=>{const c=s(o),u=(c.getDay()-1+7)%7;return c.setDate(c.getDate()-u),c},startOfMonth:o=>{const c=s(o);return c.setDate(1),c},startOfYear:o=>{const c=s(o);return c.setMonth(0,1),c},endOfWeek:(o,c)=>{const u=s(o),m=(((c?.weekStartsOn??i)+6)%7-u.getDay()+7)%7;return u.setDate(u.getDate()+m),u},endOfISOWeek:o=>{const c=s(o),u=(7-c.getDay())%7;return c.setDate(c.getDate()+u),c},endOfMonth:o=>{const c=s(o);return c.setMonth(c.getMonth()+1,0),c},endOfYear:o=>{const c=s(o);return c.setMonth(11,31),c},eachMonthOfInterval:o=>{const c=s(o.start),u=s(o.end),f=[],h=new mi(c.getFullYear(),c.getMonth(),1,12,0,0,t),m=u.getFullYear()*12+u.getMonth();for(;h.getFullYear()*12+h.getMonth()<=m;)f.push(new mi(h,t)),h.setMonth(h.getMonth()+1,1);return f},addDays:(o,c)=>{const u=s(o);return u.setDate(u.getDate()+c),u},addWeeks:(o,c)=>{const u=s(o);return u.setDate(u.getDate()+c*7),u},addMonths:(o,c)=>{const u=s(o);return u.setMonth(u.getMonth()+c),u},addYears:(o,c)=>{const u=s(o);return u.setFullYear(u.getFullYear()+c),u},eachYearOfInterval:o=>{const c=s(o.start),u=s(o.end),f=[],h=new mi(c.getFullYear(),0,1,12,0,0,t);for(;h.getFullYear()<=u.getFullYear();)f.push(new mi(h,t)),h.setFullYear(h.getFullYear()+1,0,1);return f},getWeek:(o,c)=>{const u=a(o);return BE(u,{weekStartsOn:c?.weekStartsOn??i,firstWeekContainsDate:c?.firstWeekContainsDate??r?.options?.firstWeekContainsDate??1})},getISOWeek:o=>{const c=a(o);return jE(c)},differenceInCalendarDays:(o,c)=>{const u=a(o),f=a(c);return UE(u,f)},differenceInCalendarMonths:(o,c)=>{const u=a(o),f=a(c);return uF(u,f)}}}const Vp=t=>t instanceof HTMLElement?t:null,g_=t=>[...t.querySelectorAll("[data-animated-month]")??[]],Vae=t=>Vp(t.querySelector("[data-animated-month]")),y_=t=>Vp(t.querySelector("[data-animated-caption]")),v_=t=>Vp(t.querySelector("[data-animated-weeks]")),Hae=t=>Vp(t.querySelector("[data-animated-nav]")),Wae=t=>Vp(t.querySelector("[data-animated-weekdays]"));function Gae(t,e,{classNames:n,months:r,focused:i,dateLib:s}){const a=x.useRef(null),o=x.useRef(r),c=x.useRef(!1);x.useLayoutEffect(()=>{const u=o.current;if(o.current=r,!e||!t.current||!(t.current instanceof HTMLElement)||r.length===0||u.length===0||r.length!==u.length)return;const f=s.isSameMonth(r[0].date,u[0].date),h=s.isAfter(r[0].date,u[0].date),m=h?n[ns.caption_after_enter]:n[ns.caption_before_enter],g=h?n[ns.weeks_after_enter]:n[ns.weeks_before_enter],v=a.current,w=t.current.cloneNode(!0);if(w instanceof HTMLElement?(g_(w).forEach(M=>{if(!(M instanceof HTMLElement))return;const T=Vae(M);T&&M.contains(T)&&M.removeChild(T);const R=y_(M);R&&R.classList.remove(m);const A=v_(M);A&&A.classList.remove(g)}),a.current=w):a.current=null,c.current||f||i)return;const b=v instanceof HTMLElement?g_(v):[],_=g_(t.current);if(_?.every(E=>E instanceof HTMLElement)&&b&&b.every(E=>E instanceof HTMLElement)){c.current=!0,t.current.style.isolation="isolate";const E=Hae(t.current);E&&(E.style.zIndex="1"),_.forEach((M,T)=>{const R=b[T];if(!R)return;M.style.position="relative",M.style.overflow="hidden";const A=y_(M);A&&A.classList.add(m);const P=v_(M);P&&P.classList.add(g);const k=()=>{c.current=!1,t.current&&(t.current.style.isolation=""),E&&(E.style.zIndex=""),A&&A.classList.remove(m),P&&P.classList.remove(g),M.style.position="",M.style.overflow="",M.contains(R)&&M.removeChild(R)};R.style.pointerEvents="none",R.style.position="absolute",R.style.overflow="hidden",R.setAttribute("aria-hidden","true");const N=Wae(R);N&&(N.style.opacity="0");const B=y_(R);B&&(B.classList.add(h?n[ns.caption_before_exit]:n[ns.caption_after_exit]),B.addEventListener("animationend",k));const L=v_(R);L&&L.classList.add(h?n[ns.weeks_before_exit]:n[ns.weeks_after_exit]),M.insertBefore(R,M.firstChild)})}})}function $ae(t,e,n,r){const i=t[0],s=t[t.length-1],{ISOWeek:a,fixedWeeks:o,broadcastCalendar:c}=n??{},{addDays:u,differenceInCalendarDays:f,differenceInCalendarMonths:h,endOfBroadcastWeek:m,endOfISOWeek:g,endOfMonth:v,endOfWeek:w,isAfter:b,startOfBroadcastWeek:_,startOfISOWeek:E,startOfWeek:M}=r,T=c?_(i,r):a?E(i):M(i),R=c?m(s):a?g(v(s)):w(v(s)),A=e&&(c?m(e):a?g(e):w(e)),P=A&&b(R,A)?A:R,k=f(P,T),N=h(s,i)+1,B=[];for(let I=0;I<=k;I++){const V=u(T,I);B.push(V)}const z=(c?35:42)*N;if(o&&B.length<z){const I=z-B.length;for(let V=0;V<I;V++){const W=u(B[B.length-1],1);B.push(W)}}return B}function Yae(t){const e=[];return t.reduce((n,r)=>{const i=r.weeks.reduce((s,a)=>s.concat(a.days.slice()),e.slice());return n.concat(i.slice())},e.slice())}function qae(t,e,n,r){const{numberOfMonths:i=1}=n,s=[];for(let a=0;a<i;a++){const o=r.addMonths(t,a);if(e&&o>e)break;s.push(o)}return s}function SP(t,e,n,r){const{month:i,defaultMonth:s,today:a=r.today(),numberOfMonths:o=1}=t;let c=i||s||a;const{differenceInCalendarMonths:u,addMonths:f,startOfMonth:h}=r;if(n&&u(n,c)<o-1){const m=-1*(o-1);c=f(n,m)}return e&&u(c,e)<0&&(c=e),h(c)}function Xae(t,e,n,r){const{addDays:i,endOfBroadcastWeek:s,endOfISOWeek:a,endOfMonth:o,endOfWeek:c,getISOWeek:u,getWeek:f,startOfBroadcastWeek:h,startOfISOWeek:m,startOfWeek:g}=r,v=t.reduce((w,b)=>{const _=n.broadcastCalendar?h(b,r):n.ISOWeek?m(b):g(b),E=n.broadcastCalendar?s(b):n.ISOWeek?a(o(b)):c(o(b)),M=e.filter(P=>P>=_&&P<=E),T=n.broadcastCalendar?35:42;if(n.fixedWeeks&&M.length<T){const P=e.filter(k=>{const N=T-M.length;return k>E&&k<=i(E,N)});M.push(...P)}const R=M.reduce((P,k)=>{const N=n.ISOWeek?u(k):f(k),B=P.find(z=>z.weekNumber===N),L=new vF(k,b,r);return B?B.days.push(L):P.push(new Wse(N,[L])),P},[]),A=new Hse(b,R);return w.push(A),w},[]);return n.reverseMonths?v.reverse():v}function Kae(t,e){let{startMonth:n,endMonth:r}=t;const{startOfYear:i,startOfDay:s,startOfMonth:a,endOfMonth:o,addYears:c,endOfYear:u,newDate:f,today:h}=e,{fromYear:m,toYear:g,fromMonth:v,toMonth:w}=t;!n&&v&&(n=v),!n&&m&&(n=e.newDate(m,0,1)),!r&&w&&(r=w),!r&&g&&(r=f(g,11,31));const b=t.captionLayout==="dropdown"||t.captionLayout==="dropdown-years";return n?n=a(n):m?n=f(m,0,1):!n&&b&&(n=i(c(t.today??h(),-100))),r?r=o(r):g?r=f(g,11,31):!r&&b&&(r=u(t.today??h())),[n&&s(n),r&&s(r)]}function Zae(t,e,n,r){if(n.disableNavigation)return;const{pagedNavigation:i,numberOfMonths:s=1}=n,{startOfMonth:a,addMonths:o,differenceInCalendarMonths:c}=r,u=i?s:1,f=a(t);if(!e)return o(f,u);if(!(c(e,t)<s))return o(f,u)}function Jae(t,e,n,r){if(n.disableNavigation)return;const{pagedNavigation:i,numberOfMonths:s}=n,{startOfMonth:a,addMonths:o,differenceInCalendarMonths:c}=r,u=i?s??1:1,f=a(t);if(!e)return o(f,-u);if(!(c(f,e)<=0))return o(f,-u)}function Qae(t){const e=[];return t.reduce((n,r)=>n.concat(r.weeks.slice()),e.slice())}function dv(t,e){const[n,r]=x.useState(t);return[e===void 0?n:e,r]}function eoe(t,e){const[n,r]=Kae(t,e),{startOfMonth:i,endOfMonth:s}=e,a=SP(t,n,r,e),[o,c]=dv(a,t.month?a:void 0);x.useEffect(()=>{const T=SP(t,n,r,e);c(T)},[t.timeZone]);const{months:u,weeks:f,days:h,previousMonth:m,nextMonth:g}=x.useMemo(()=>{const T=qae(o,r,{numberOfMonths:t.numberOfMonths},e),R=$ae(T,t.endMonth?s(t.endMonth):void 0,{ISOWeek:t.ISOWeek,fixedWeeks:t.fixedWeeks,broadcastCalendar:t.broadcastCalendar},e),A=Xae(T,R,{broadcastCalendar:t.broadcastCalendar,fixedWeeks:t.fixedWeeks,ISOWeek:t.ISOWeek,reverseMonths:t.reverseMonths},e),P=Qae(A),k=Yae(A),N=Jae(o,n,t,e),B=Zae(o,r,t,e);return{months:A,weeks:P,days:k,previousMonth:N,nextMonth:B}},[e,o.getTime(),r?.getTime(),n?.getTime(),t.disableNavigation,t.broadcastCalendar,t.endMonth?.getTime(),t.fixedWeeks,t.ISOWeek,t.numberOfMonths,t.pagedNavigation,t.reverseMonths]),{disableNavigation:v,onMonthChange:w}=t,b=T=>f.some(R=>R.days.some(A=>A.isEqualTo(T))),_=T=>{if(v)return;let R=i(T);n&&R<i(n)&&(R=i(n)),r&&R>i(r)&&(R=i(r)),c(R),w?.(R)};return{months:u,weeks:f,days:h,navStart:n,navEnd:r,previousMonth:m,nextMonth:g,goToMonth:_,goToDay:T=>{b(T)||_(T.date)}}}var Ea;(function(t){t[t.Today=0]="Today",t[t.Selected=1]="Selected",t[t.LastFocused=2]="LastFocused",t[t.FocusedModifier=3]="FocusedModifier"})(Ea||(Ea={}));function kP(t){return!t[fr.disabled]&&!t[fr.hidden]&&!t[fr.outside]}function toe(t,e,n,r){let i,s=-1;for(const a of t){const o=e(a);kP(o)&&(o[fr.focused]&&s<Ea.FocusedModifier?(i=a,s=Ea.FocusedModifier):r?.isEqualTo(a)&&s<Ea.LastFocused?(i=a,s=Ea.LastFocused):n(a.date)&&s<Ea.Selected?(i=a,s=Ea.Selected):o[fr.today]&&s<Ea.Today&&(i=a,s=Ea.Today))}return i||(i=t.find(a=>kP(e(a)))),i}function noe(t,e,n,r,i,s,a){const{ISOWeek:o,broadcastCalendar:c}=s,{addDays:u,addMonths:f,addWeeks:h,addYears:m,endOfBroadcastWeek:g,endOfISOWeek:v,endOfWeek:w,max:b,min:_,startOfBroadcastWeek:E,startOfISOWeek:M,startOfWeek:T}=a;let A={day:u,week:h,month:f,year:m,startOfWeek:P=>c?E(P,a):o?M(P):T(P),endOfWeek:P=>c?g(P):o?v(P):w(P)}[t](n,e==="after"?1:-1);return e==="before"&&r?A=b([r,A]):e==="after"&&i&&(A=_([i,A])),A}function DF(t,e,n,r,i,s,a,o=0){if(o>365)return;const c=noe(t,e,n.date,r,i,s,a),u=!!(s.disabled&&Eo(c,s.disabled,a)),f=!!(s.hidden&&Eo(c,s.hidden,a)),h=c,m=new vF(c,h,a);return!u&&!f?m:DF(t,e,m,r,i,s,a,o+1)}function roe(t,e,n,r,i){const{autoFocus:s}=t,[a,o]=x.useState(),c=toe(e.days,n,r||(()=>!1),a),[u,f]=x.useState(s?c:void 0);return{isFocusTarget:w=>!!c?.isEqualTo(w),setFocused:f,focused:u,blur:()=>{o(u),f(void 0)},moveFocus:(w,b)=>{if(!u)return;const _=DF(w,b,u,e.navStart,e.navEnd,t,i);_&&(t.disableNavigation&&!e.days.some(M=>M.isEqualTo(_))||(e.goToDay(_),f(_)))}}}function ioe(t,e){const{selected:n,required:r,onSelect:i}=t,[s,a]=dv(n,i?n:void 0),o=i?n:s,{isSameDay:c}=e,u=g=>o?.some(v=>c(v,g))??!1,{min:f,max:h}=t;return{selected:o,select:(g,v,w)=>{let b=[...o??[]];if(u(g)){if(o?.length===f||r&&o?.length===1)return;b=o?.filter(_=>!c(_,g))}else o?.length===h?b=[g]:b=[...b,g];return i||a(b),i?.(b,g,v,w),b},isSelected:u}}function soe(t,e,n=0,r=0,i=!1,s=Qa){const{from:a,to:o}=e||{},{isSameDay:c,isAfter:u,isBefore:f}=s;let h;if(!a&&!o)h={from:t,to:n>0?void 0:t};else if(a&&!o)c(a,t)?n===0?h={from:a,to:t}:i?h={from:a,to:void 0}:h=void 0:f(t,a)?h={from:t,to:a}:h={from:a,to:t};else if(a&&o)if(c(a,t)&&c(o,t))i?h={from:a,to:o}:h=void 0;else if(c(a,t))h={from:a,to:n>0?void 0:t};else if(c(o,t))h={from:t,to:n>0?void 0:t};else if(f(t,a))h={from:t,to:o};else if(u(t,a))h={from:a,to:t};else if(u(t,o))h={from:a,to:t};else throw new Error("Invalid range");if(h?.from&&h?.to){const m=s.differenceInCalendarDays(h.to,h.from);r>0&&m>r?h={from:t,to:void 0}:n>1&&m<n&&(h={from:t,to:void 0})}return h}function aoe(t,e,n=Qa){const r=Array.isArray(e)?e:[e];let i=t.from;const s=n.differenceInCalendarDays(t.to,t.from),a=Math.min(s,6);for(let o=0;o<=a;o++){if(r.includes(i.getDay()))return!0;i=n.addDays(i,1)}return!1}function EP(t,e,n=Qa){return ko(t,e.from,!1,n)||ko(t,e.to,!1,n)||ko(e,t.from,!1,n)||ko(e,t.to,!1,n)}function ooe(t,e,n=Qa){const r=Array.isArray(e)?e:[e];if(r.filter(o=>typeof o!="function").some(o=>typeof o=="boolean"?o:n.isDate(o)?ko(t,o,!1,n):_F(o,n)?o.some(c=>ko(t,c,!1,n)):uv(o)?o.from&&o.to?EP(t,{from:o.from,to:o.to},n):!1:bF(o)?aoe(t,o.dayOfWeek,n):zE(o)?n.isAfter(o.before,o.after)?EP(t,{from:n.addDays(o.after,1),to:n.addDays(o.before,-1)},n):Eo(t.from,o,n)||Eo(t.to,o,n):VE(o)||HE(o)?Eo(t.from,o,n)||Eo(t.to,o,n):!1))return!0;const a=r.filter(o=>typeof o=="function");if(a.length){let o=t.from;const c=n.differenceInCalendarDays(t.to,t.from);for(let u=0;u<=c;u++){if(a.some(f=>f(o)))return!0;o=n.addDays(o,1)}}return!1}function loe(t,e){const{disabled:n,excludeDisabled:r,resetOnSelect:i,selected:s,required:a,onSelect:o}=t,[c,u]=dv(s,o?s:void 0),f=o?s:c;return{selected:f,select:(g,v,w)=>{const{min:b,max:_}=t;let E;if(g){const M=f?.from,T=f?.to,R=!!M&&!!T,A=!!M&&!!T&&e.isSameDay(M,T)&&e.isSameDay(g,M);i&&(R||!f?.from)?!a&&A?E=void 0:E={from:g,to:void 0}:E=soe(g,f,b,_,a,e)}return r&&n&&E?.from&&E.to&&ooe({from:E.from,to:E.to},n,e)&&(E.from=g,E.to=void 0),o||u(E),o?.(E,g,v,w),E},isSelected:g=>f&&ko(f,g,!1,e)}}function coe(t,e){const{selected:n,required:r,onSelect:i}=t,[s,a]=dv(n,i?n:void 0),o=i?n:s,{isSameDay:c}=e;return{selected:o,select:(h,m,g)=>{let v=h;return!r&&o&&o&&c(h,o)&&(v=void 0),i||a(v),i?.(v,h,m,g),v},isSelected:h=>o?c(o,h):!1}}function uoe(t,e){const n=coe(t,e),r=ioe(t,e),i=loe(t,e);switch(t.mode){case"single":return n;case"multiple":return r;case"range":return i;default:return}}function bs(t,e){return t instanceof mi&&t.timeZone===e?t:new mi(t,e)}function Ju(t,e,n){return bs(t,e)}function MP(t,e,n){return typeof t=="boolean"||typeof t=="function"?t:t instanceof Date?Ju(t,e):Array.isArray(t)?t.map(r=>r instanceof Date?Ju(r,e):r):uv(t)?{...t,from:t.from?bs(t.from,e):t.from,to:t.to?bs(t.to,e):t.to}:zE(t)?{before:Ju(t.before,e),after:Ju(t.after,e)}:VE(t)?{after:Ju(t.after,e)}:HE(t)?{before:Ju(t.before,e)}:t}function x_(t,e,n){return t&&(Array.isArray(t)?t.map(r=>MP(r,e)):MP(t,e))}function doe(t){let e=t;const n=e.timeZone;if(n&&(e={...t,timeZone:n},e.today&&(e.today=bs(e.today,n)),e.month&&(e.month=bs(e.month,n)),e.defaultMonth&&(e.defaultMonth=bs(e.defaultMonth,n)),e.startMonth&&(e.startMonth=bs(e.startMonth,n)),e.endMonth&&(e.endMonth=bs(e.endMonth,n)),e.mode==="single"&&e.selected?e.selected=bs(e.selected,n):e.mode==="multiple"&&e.selected?e.selected=e.selected?.map(ne=>bs(ne,n)):e.mode==="range"&&e.selected&&(e.selected={from:e.selected.from?bs(e.selected.from,n):e.selected.from,to:e.selected.to?bs(e.selected.to,n):e.selected.to}),e.disabled!==void 0&&(e.disabled=x_(e.disabled,n)),e.hidden!==void 0&&(e.hidden=x_(e.hidden,n)),e.modifiers)){const ne={};Object.keys(e.modifiers).forEach(Be=>{ne[Be]=x_(e.modifiers?.[Be],n)}),e.modifiers=ne}const{components:r,formatters:i,labels:s,dateLib:a,locale:o,classNames:c}=x.useMemo(()=>{const ne={...yF,...e.locale},Be=e.broadcastCalendar?1:e.weekStartsOn,ke=e.noonSafe&&e.timeZone?zae(e.timeZone,{weekStartsOn:Be,locale:ne}):void 0,Ae=e.dateLib&&ke?{...ke,...e.dateLib}:e.dateLib??ke,Ve=new us({locale:ne,weekStartsOn:Be,firstWeekContainsDate:e.firstWeekContainsDate,useAdditionalWeekYearTokens:e.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:e.useAdditionalDayOfYearTokens,timeZone:e.timeZone,numerals:e.numerals},Ae);return{dateLib:Ve,components:bae(e.components),formatters:Pae(e.formatters),labels:Oae(e.labels,Ve.options),locale:ne,classNames:{...wae(),...e.classNames}}},[e.locale,e.broadcastCalendar,e.weekStartsOn,e.firstWeekContainsDate,e.useAdditionalWeekYearTokens,e.useAdditionalDayOfYearTokens,e.timeZone,e.numerals,e.dateLib,e.noonSafe,e.components,e.formatters,e.labels,e.classNames]);e.today||(e={...e,today:a.today()});const{captionLayout:u,mode:f,navLayout:h,numberOfMonths:m=1,onDayBlur:g,onDayClick:v,onDayFocus:w,onDayKeyDown:b,onDayMouseEnter:_,onDayMouseLeave:E,onNextClick:M,onPrevClick:T,showWeekNumber:R,styles:A}=e,{formatCaption:P,formatDay:k,formatMonthDropdown:N,formatWeekNumber:B,formatWeekNumberHeader:L,formatWeekdayName:z,formatYearDropdown:I}=i,V=eoe(e,a),{days:W,months:X,navStart:J,navEnd:F,previousMonth:G,nextMonth:Y,goToMonth:H}=V,te=vae(W,e,J,F,a),{isSelected:re,select:ue,selected:ce}=uoe(e,a)??{},{blur:ee,focused:le,isFocusTarget:ve,moveFocus:Ne,setFocused:be}=roe(e,V,te,re??(()=>!1),a),{labelDayButton:qe,labelGridcell:he,labelGrid:Ue,labelMonthDropdown:je,labelNav:et,labelPrevious:_e,labelNext:oe,labelWeekday:Q,labelWeekNumber:ze,labelWeekNumberHeader:Re,labelYearDropdown:De}=s,Le=x.useMemo(()=>jae(a,e.ISOWeek,e.broadcastCalendar,e.today),[a,e.ISOWeek,e.broadcastCalendar,e.today]),$=f!==void 0||v!==void 0,U=x.useCallback(()=>{G&&(H(G),T?.(G))},[G,H,T]),Z=x.useCallback(()=>{Y&&(H(Y),M?.(Y))},[H,Y,M]),pe=x.useCallback((ne,Be)=>ke=>{ke.preventDefault(),ke.stopPropagation(),be(ne),!Be.disabled&&(ue?.(ne.date,Be,ke),v?.(ne.date,Be,ke))},[ue,v,be]),Se=x.useCallback((ne,Be)=>ke=>{be(ne),w?.(ne.date,Be,ke)},[w,be]),xe=x.useCallback((ne,Be)=>ke=>{ee(),g?.(ne.date,Be,ke)},[ee,g]),Ie=x.useCallback((ne,Be)=>ke=>{const Ae={ArrowLeft:[ke.shiftKey?"month":"day",e.dir==="rtl"?"after":"before"],ArrowRight:[ke.shiftKey?"month":"day",e.dir==="rtl"?"before":"after"],ArrowDown:[ke.shiftKey?"year":"week","after"],ArrowUp:[ke.shiftKey?"year":"week","before"],PageUp:[ke.shiftKey?"year":"month","before"],PageDown:[ke.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(Ae[ke.key]){ke.preventDefault(),ke.stopPropagation();const[Ve,ge]=Ae[ke.key];Ne(Ve,ge)}b?.(ne.date,Be,ke)},[Ne,b,e.dir]),He=x.useCallback((ne,Be)=>ke=>{_?.(ne.date,Be,ke)},[_]),Ye=x.useCallback((ne,Be)=>ke=>{E?.(ne.date,Be,ke)},[E]),ft=x.useCallback(ne=>Be=>{const ke=Number(Be.target.value),Ae=a.setMonth(a.startOfMonth(ne),ke);H(Ae)},[a,H]),We=x.useCallback(ne=>Be=>{const ke=Number(Be.target.value),Ae=a.setYear(a.startOfMonth(ne),ke);H(Ae)},[a,H]),{className:Xe,style:nt}=x.useMemo(()=>({className:[c[Zt.Root],e.className].filter(Boolean).join(" "),style:{...A?.[Zt.Root],...e.style}}),[c,e.className,e.style,A]),ct=_ae(e),Ke=x.useRef(null);Gae(Ke,!!e.animate,{classNames:c,months:X,focused:le,dateLib:a});const gt={dayPickerProps:e,selected:ce,select:ue,isSelected:re,months:X,nextMonth:Y,previousMonth:G,goToMonth:H,getModifiers:te,components:r,classNames:c,styles:A,labels:s,formatters:i};return ot.createElement(xF.Provider,{value:gt},ot.createElement(r.Root,{rootRef:e.animate?Ke:void 0,className:Xe,style:nt,dir:e.dir,id:e.id,lang:e.lang??o.code,nonce:e.nonce,title:e.title,role:e.role,"aria-label":e["aria-label"],"aria-labelledby":e["aria-labelledby"],...ct},ot.createElement(r.Months,{className:c[Zt.Months],style:A?.[Zt.Months]},!e.hideNavigation&&!h&&ot.createElement(r.Nav,{"data-animated-nav":e.animate?"true":void 0,className:c[Zt.Nav],style:A?.[Zt.Nav],"aria-label":et(),onPreviousClick:U,onNextClick:Z,previousMonth:G,nextMonth:Y}),X.map((ne,Be)=>ot.createElement(r.Month,{"data-animated-month":e.animate?"true":void 0,className:c[Zt.Month],style:A?.[Zt.Month],key:Be,displayIndex:Be,calendarMonth:ne},h==="around"&&!e.hideNavigation&&Be===0&&ot.createElement(r.PreviousMonthButton,{type:"button",className:c[Zt.PreviousMonthButton],tabIndex:G?void 0:-1,"aria-disabled":G?void 0:!0,"aria-label":_e(G),onClick:U,"data-animated-button":e.animate?"true":void 0},ot.createElement(r.Chevron,{disabled:G?void 0:!0,className:c[Zt.Chevron],orientation:e.dir==="rtl"?"right":"left"})),ot.createElement(r.MonthCaption,{"data-animated-caption":e.animate?"true":void 0,className:c[Zt.MonthCaption],style:A?.[Zt.MonthCaption],calendarMonth:ne,displayIndex:Be},u?.startsWith("dropdown")?ot.createElement(r.DropdownNav,{className:c[Zt.Dropdowns],style:A?.[Zt.Dropdowns]},(()=>{const ke=u==="dropdown"||u==="dropdown-months"?ot.createElement(r.MonthsDropdown,{key:"month",className:c[Zt.MonthsDropdown],"aria-label":je(),classNames:c,components:r,disabled:!!e.disableNavigation,onChange:ft(ne.date),options:Fae(ne.date,J,F,i,a),style:A?.[Zt.Dropdown],value:a.getMonth(ne.date)}):ot.createElement("span",{key:"month"},N(ne.date,a)),Ae=u==="dropdown"||u==="dropdown-years"?ot.createElement(r.YearsDropdown,{key:"year",className:c[Zt.YearsDropdown],"aria-label":De(a.options),classNames:c,components:r,disabled:!!e.disableNavigation,onChange:We(ne.date),options:Bae(J,F,i,a,!!e.reverseYears),style:A?.[Zt.Dropdown],value:a.getYear(ne.date)}):ot.createElement("span",{key:"year"},I(ne.date,a));return a.getMonthYearOrder()==="year-first"?[Ae,ke]:[ke,Ae]})(),ot.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},P(ne.date,a.options,a))):ot.createElement(r.CaptionLabel,{className:c[Zt.CaptionLabel],role:"status","aria-live":"polite"},P(ne.date,a.options,a))),h==="around"&&!e.hideNavigation&&Be===m-1&&ot.createElement(r.NextMonthButton,{type:"button",className:c[Zt.NextMonthButton],tabIndex:Y?void 0:-1,"aria-disabled":Y?void 0:!0,"aria-label":oe(Y),onClick:Z,"data-animated-button":e.animate?"true":void 0},ot.createElement(r.Chevron,{disabled:Y?void 0:!0,className:c[Zt.Chevron],orientation:e.dir==="rtl"?"left":"right"})),Be===m-1&&h==="after"&&!e.hideNavigation&&ot.createElement(r.Nav,{"data-animated-nav":e.animate?"true":void 0,className:c[Zt.Nav],style:A?.[Zt.Nav],"aria-label":et(),onPreviousClick:U,onNextClick:Z,previousMonth:G,nextMonth:Y}),ot.createElement(r.MonthGrid,{role:"grid","aria-multiselectable":f==="multiple"||f==="range","aria-label":Ue(ne.date,a.options,a)||void 0,className:c[Zt.MonthGrid],style:A?.[Zt.MonthGrid]},!e.hideWeekdays&&ot.createElement(r.Weekdays,{"data-animated-weekdays":e.animate?"true":void 0,className:c[Zt.Weekdays],style:A?.[Zt.Weekdays]},R&&ot.createElement(r.WeekNumberHeader,{"aria-label":Re(a.options),className:c[Zt.WeekNumberHeader],style:A?.[Zt.WeekNumberHeader],scope:"col"},L()),Le.map(ke=>ot.createElement(r.Weekday,{"aria-label":Q(ke,a.options,a),className:c[Zt.Weekday],key:String(ke),style:A?.[Zt.Weekday],scope:"col"},z(ke,a.options,a)))),ot.createElement(r.Weeks,{"data-animated-weeks":e.animate?"true":void 0,className:c[Zt.Weeks],style:A?.[Zt.Weeks]},ne.weeks.map(ke=>ot.createElement(r.Week,{className:c[Zt.Week],key:ke.weekNumber,style:A?.[Zt.Week],week:ke},R&&ot.createElement(r.WeekNumber,{week:ke,style:A?.[Zt.WeekNumber],"aria-label":ze(ke.weekNumber,{locale:o}),className:c[Zt.WeekNumber],scope:"row",role:"rowheader"},B(ke.weekNumber,a)),ke.days.map(Ae=>{const{date:Ve}=Ae,ge=te(Ae);if(ge[fr.focused]=!ge.hidden&&!!le?.isEqualTo(Ae),ge[ea.selected]=re?.(Ve)||ge.selected,uv(ce)){const{from:Lt,to:_t}=ce;ge[ea.range_start]=!!(Lt&&_t&&a.isSameDay(Ve,Lt)),ge[ea.range_end]=!!(Lt&&_t&&a.isSameDay(Ve,_t)),ge[ea.range_middle]=ko(ce,Ve,!0,a)}const ut=Uae(ge,A,e.modifiersStyles),yt=xae(ge,c,e.modifiersClassNames),qt=!$&&!ge.hidden?he(Ve,ge,a.options,a):void 0;return ot.createElement(r.Day,{key:`${Ae.isoDate}_${Ae.displayMonthId}`,day:Ae,modifiers:ge,className:yt.join(" "),style:ut,role:"gridcell","aria-selected":ge.selected||void 0,"aria-label":qt,"data-day":Ae.isoDate,"data-month":Ae.outside?Ae.dateMonthId:void 0,"data-selected":ge.selected||void 0,"data-disabled":ge.disabled||void 0,"data-hidden":ge.hidden||void 0,"data-outside":Ae.outside||void 0,"data-focused":ge.focused||void 0,"data-today":ge.today||void 0},!ge.hidden&&$?ot.createElement(r.DayButton,{className:c[Zt.DayButton],style:A?.[Zt.DayButton],type:"button",day:Ae,modifiers:ge,disabled:!ge.focused&&ge.disabled||void 0,"aria-disabled":ge.focused&&ge.disabled||void 0,tabIndex:ve(Ae)?0:-1,"aria-label":qe(Ve,ge,a.options,a),onClick:pe(Ae,ge),onBlur:xe(Ae,ge),onFocus:Se(Ae,ge),onKeyDown:Ie(Ae,ge),onMouseEnter:He(Ae,ge),onMouseLeave:Ye(Ae,ge)},k(Ve,a.options,a)):!ge.hidden&&k(Ae.date,a.options,a))})))))))),e.footer&&ot.createElement(r.Footer,{className:c[Zt.Footer],style:A?.[Zt.Footer],role:"status","aria-live":"polite"},e.footer)))}function TP(t){if(!t)return"";const e=t.split("-");if(e.length!==3)return t;const n=new Date(Number(e[0]),Number(e[1])-1,Number(e[2]));return Number.isFinite(n.getTime())?Na(n,"MMM d"):t}function foe({from:t,to:e,onApply:n,onCancel:r}){const i=x.useMemo(()=>{const u={from:void 0,to:void 0};if(t){const f=t.split("-");u.from=new Date(Number(f[0]),Number(f[1])-1,Number(f[2]))}if(e){const f=e.split("-");u.to=new Date(Number(f[0]),Number(f[1])-1,Number(f[2]))}return u},[t,e]),[s,a]=x.useState(i),o=()=>{if(!s?.from)return;const u=Na(s.from,"yyyy-MM-dd"),f=s.to?Na(s.to,"yyyy-MM-dd"):u;n?.(u,f)},c=!!s?.from;return p.jsxs("div",{className:"p-4",children:[p.jsx(doe,{mode:"range",selected:s,onSelect:a,numberOfMonths:2,showOutsideDays:!1,classNames:{root:"rdp-oai",months:"flex gap-4",month:"space-y-3",month_caption:"flex justify-center items-center h-8",caption_label:"text-sm font-medium text-oai-black dark:text-oai-white",nav:"flex items-center justify-between absolute inset-x-0 top-0 px-2",button_previous:"inline-flex items-center justify-center w-7 h-7 rounded-md text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-oai-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",button_next:"inline-flex items-center justify-center w-7 h-7 rounded-md text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-oai-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",chevron:"w-4 h-4",month_grid:"border-collapse",weekdays:"flex",weekday:"w-9 text-center text-xs font-medium text-oai-gray-400 dark:text-oai-gray-500 py-1",week:"flex",day:"w-9 h-9 text-center text-sm p-0 relative",day_button:"w-full h-full inline-flex items-center justify-center rounded-md transition-colors hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 text-oai-black dark:text-oai-white cursor-pointer rdp-day-btn",today:"font-bold",selected:"rdp-selected",range_start:"rdp-selected rdp-range-start",range_end:"rdp-selected rdp-range-end",range_middle:"rdp-range-mid",outside:"text-oai-gray-300 dark:text-oai-gray-600",disabled:"text-oai-gray-300 dark:text-oai-gray-600 cursor-not-allowed",hidden:"invisible"},styles:{months:{position:"relative"}}}),p.jsxs("div",{className:"flex items-center justify-end gap-2 mt-4 pt-3 border-t border-oai-gray-200 dark:border-oai-gray-700",children:[c&&s.from&&p.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mr-auto",children:[Na(s.from,"MMM d, yyyy"),s.to&&s.to.getTime()!==s.from.getTime()?` — ${Na(s.to,"MMM d, yyyy")}`:""]}),p.jsx(Ui,{variant:"secondary",size:"sm",onClick:r,children:"Cancel"}),p.jsx(Ui,{variant:"primary",size:"sm",onClick:o,disabled:!c,children:"Apply"})]})]})}const CP={claude:290,codex:165},AP={system_prompt:{l:.55,c:.05},messages:{l:.65,c:.18},tool_calls:{l:.6,c:.14},custom_agents:{l:.55,c:.1},reasoning:{l:.7,c:.08}};function hoe(t,e){const n=CP[e]??CP.claude,r=AP[t]||AP.system_prompt;return`oklch(${r.l} ${r.c} ${n})`}const poe=[{key:"system_prompt",from:["system_prefix"]},{key:"messages",from:["user_input","conversation_history","assistant_response"]},{key:"tool_calls",from:["tool_calls"]},{key:"custom_agents",from:["subagents"]},{key:"reasoning",from:["reasoning"]}],moe=[["by_type","dashboard.context_breakdown.exec_details.group_by_type"],["by_executable","dashboard.context_breakdown.exec_details.group_by_executable"],["by_command","dashboard.context_breakdown.exec_details.group_by_command"],["by_duration","dashboard.context_breakdown.exec_details.group_by_duration"],["by_output","dashboard.context_breakdown.exec_details.group_by_output"],["by_exit","dashboard.context_breakdown.exec_details.group_by_exit"]],goe={duration:.18,ease:[.4,0,.2,1]},yoe={height:0,opacity:0},voe={height:"auto",opacity:1},xoe={height:0,opacity:0};function boe(t){const e=Number(t||0);return Number.isFinite(e)&&e>0?e:0}function _oe(t,e){const n={};for(const r of["input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens","total_tokens"])n[r]=Math.round(Number(t?.[r]||0)*e);return n}function LF(t,e=null){const n=t.reduce((a,o)=>a+Number(o.totals.total_tokens||0),0),r=boe(e),i=r||n,s=r&&n>0?r/n:1;return t.map(a=>{const o=s===1?a.totals:_oe(a.totals,s);return{...a,totals:o,percent:i>0?Number((o.total_tokens/i*100).toFixed(2)):0}}).sort((a,o)=>o.totals.total_tokens-a.totals.total_tokens)}function woe(t,e=null){const n=new Map;for(const i of t||[])n.set(i.key,i);const r=poe.map(i=>{const s={input_tokens:0,cached_input_tokens:0,cache_creation_input_tokens:0,output_tokens:0,reasoning_output_tokens:0,total_tokens:0};for(const a of i.from){const o=n.get(a);if(!o)continue;const c=o.totals||{};s.input_tokens+=c.input_tokens||0,s.cached_input_tokens+=c.cached_input_tokens||0,s.cache_creation_input_tokens+=c.cache_creation_input_tokens||0,s.output_tokens+=c.output_tokens||0,s.reasoning_output_tokens+=c.reasoning_output_tokens||0,s.total_tokens+=c.total_tokens||0}return{key:i.key,totals:s}});return LF(r,e)}function Soe(t,e=null){const n=t?.totals||{},r=Number(n.reasoning_output_tokens||0),i=(t?.tool_calls_breakdown?.categories||[]).reduce((u,f)=>f?.name==="Text Response"?u:u+Number(f?.totals?.total_tokens||0),0),s=Number(n.total_tokens||0),a=Math.min(Math.max(0,i),Math.max(0,s-r)),c=[{key:"messages",totals:{total_tokens:Math.max(0,s-r-a)}},{key:"tool_calls",totals:{total_tokens:a}},{key:"reasoning",totals:{total_tokens:r}}];return LF(c,e)}function RP(t){return O(`dashboard.context_breakdown.category.${t}`)}function Lc(t){return!Number.isFinite(Number(t))||Number(t)<=0?"0":Ms(Number(t),{decimals:1})}function koe(t){return typeof t!="string"?"":t.startsWith("mcp__")?t.split("__").slice(2).join("__")||t:t.includes("/")&&t.split("/").pop()||t}function Eoe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||null,r=Number(n?n.input_tokens||0:e?.input_tokens||0),i=Number(n?n.output_tokens||0:e?.output_tokens||0),s=Number(n?n.cached_input_tokens||0:e?.cache_read||0),a=Number(n?n.cache_creation_input_tokens||0:e?.cache_creation||0),o=Number(n?n.total_tokens||r+i:e?.total_tokens||i);return{name:koe(e?.name?String(e.name):""),calls:Number(e?.calls||0),input_tokens:r,output_tokens:i,cache_read:s,cache_creation:a,total_tokens:Number(o||0)}}).filter(e=>e.name).sort((e,n)=>(n.total_tokens||0)-(e.total_tokens||0))}function Moe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||{},r=Array.isArray(e?.tools)?e.tools:[],i=Number(n.input_tokens||0),s=Number(n.output_tokens||0),a=Number(n.cached_input_tokens||0),o=Number(n.cache_creation_input_tokens||0);return{name:e?.name?String(e.name):"",calls:Number(e?.calls||0),totals:{input_tokens:i,output_tokens:s,cached_input_tokens:a,cache_creation_input_tokens:o,total_tokens:Number(n.total_tokens||i+s)},tools:Eoe(r),toolCount:r.length}}).filter(e=>e.name).sort((e,n)=>(n.totals.total_tokens||0)-(e.totals.total_tokens||0))}function Toe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||{},r=Number(n.input_tokens||0),i=Number(n.output_tokens||0),s=Number(n.cached_input_tokens||0),a=Number(n.cache_creation_input_tokens||0);return{key:e?.key?String(e.key):"",name:e?.name?String(e.name):"",totals:{input_tokens:r,output_tokens:i,cached_input_tokens:s,cache_creation_input_tokens:a,total_tokens:Number(n.total_tokens||r+i+s+a)}}}).filter(e=>e.key||e.name).sort((e,n)=>(n.totals.total_tokens||0)-(e.totals.total_tokens||0))}function Coe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||{};return{name:e?.name?String(e.name):"",calls:Number(e?.calls||0),total_tokens:Number(n.total_tokens||0)}}).filter(e=>e.name).sort((e,n)=>Number(n.total_tokens||0)-Number(e.total_tokens||0))}function Aoe(t){if(t?.key){const e=O(`dashboard.context_breakdown.message_details.${t.key}`);if(e&&!e.includes("dashboard.context_breakdown"))return e}return t?.name||""}function Roe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||{},r=Number(n.input_tokens||0),i=Number(n.output_tokens||0),s=Number(n.cached_input_tokens||0),a=Number(n.cache_creation_input_tokens||0);return{name:e?.name?String(e.name):"",calls:Number(e?.calls||0),failures:Number(e?.failures||0),duration_ms:Number(e?.duration_ms||0),max_duration_ms:Number(e?.max_duration_ms||0),output_chars:Number(e?.output_chars||0),output_lines:Number(e?.output_lines||0),totals:{input_tokens:r,output_tokens:i,cached_input_tokens:s,cache_creation_input_tokens:a,total_tokens:Number(n.total_tokens||r+i)}}}).filter(e=>e.name).sort((e,n)=>Number(n.totals.total_tokens||0)-Number(e.totals.total_tokens||0))}function PP(t){const e=Number(t||0);return!Number.isFinite(e)||e<=0?"0ms":e<1e3?`${Math.round(e)}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.round(e/1e3)}s`}function Poe(t,e){return t?e==="by_executable"?t.by_executable||[]:e==="by_command"?t.by_command||[]:e==="by_duration"?t.by_duration||[]:e==="by_output"?t.by_output||[]:e==="by_exit"?t.by_exit||[]:t.by_type||[]:[]}function NP(t){return t==="exec_command"||t==="Bash"}function IF(t){return t==="codex"?"dashboard.context_breakdown.empty_codex":"dashboard.context_breakdown.empty"}function Noe(t){return t==="codex"?"dashboard.context_breakdown.error_codex":"dashboard.context_breakdown.error"}function Doe(t){return t==="codex"?"dashboard.context_breakdown.footnote_codex":"dashboard.context_breakdown.footnote"}const Loe=10;function Md({level:t=0,colorSquare:e=null,label:n,labelSuffix:r=null,labelTone:i="default",hasChevron:s=!1,open:a=!1,onToggle:o,tokens:c,percent:u=null,children:f,share:h=null,fillColor:m=null}){const g=i==="accent"?"text-oai-brand truncate":i==="muted"?"text-oai-gray-500 dark:text-oai-gray-400 truncate":i==="strong"?"font-medium text-oai-black dark:text-oai-white truncate":"text-oai-gray-700 dark:text-oai-gray-300 truncate",v=p.jsx("span",{className:"shrink-0 flex items-center justify-start",style:{width:Loe},"aria-hidden":!e,children:e}),w=p.jsxs(p.Fragment,{children:[v,p.jsx("span",{className:g,children:n}),r,s&&p.jsx(tr.span,{animate:{rotate:a?90:0},transition:{duration:.15},className:"shrink-0 text-oai-gray-400 dark:text-oai-gray-500 flex items-center","aria-hidden":"true",children:p.jsx(BW,{size:11})})]}),b=m&&h!=null&&h>0,_=b?Math.max(0,Math.min(100,h)):0;return p.jsxs("li",{className:"min-w-0 group/row",children:[p.jsxs("div",{className:"relative grid grid-cols-[minmax(0,1fr)_64px_48px] items-center gap-2 text-xs py-1 px-1 rounded-sm transition-colors duration-150",style:b?{backgroundImage:`linear-gradient(to right, ${m.replace(/\)\s*$/," / 0.10)")} 0%, ${m.replace(/\)\s*$/," / 0.10)")} ${_}%, transparent ${_}%)`}:void 0,children:[s?p.jsx("button",{type:"button",onClick:o,"aria-expanded":a,className:"relative flex items-center gap-1.5 min-w-0 text-left cursor-pointer focus-visible:outline-none focus-visible:ring-inset focus-visible:ring-2 focus-visible:ring-oai-brand/40 rounded-sm",children:w}):p.jsx("div",{className:"relative flex items-center gap-1.5 min-w-0",children:w}),p.jsx("span",{className:"relative text-right tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:c||""}),p.jsx("span",{className:"relative text-right tabular-nums text-[10px] text-oai-gray-400 dark:text-oai-gray-500 font-normal",children:u||""})]}),s&&f?p.jsx(Lp,{initial:!1,children:a&&p.jsx(tr.div,{initial:yoe,animate:voe,exit:xoe,transition:goe,style:{overflow:"hidden"},children:f},"content")}):null]})}function DP({execDetails:t,source:e="claude"}){const[n,r]=x.useState("by_type"),i=Roe(Poe(t,n)),s=e==="codex",a=s?"grid-cols-[minmax(0,1fr)_48px_48px_72px_72px_60px_60px]":"grid-cols-[minmax(0,1fr)_56px_60px]";return p.jsxs("div",{className:"mt-2 ml-4",children:[p.jsx("div",{className:"flex flex-wrap items-center gap-1 rounded-md bg-oai-gray-100 dark:bg-oai-gray-900 p-1 w-fit max-w-full",children:moe.map(([o,c])=>p.jsx("button",{type:"button",onClick:()=>r(o),className:"h-7 px-2 rounded-md text-[10px] font-medium transition-colors "+(n===o?"bg-oai-white dark:bg-oai-gray-800 text-oai-black dark:text-oai-white shadow-sm":"text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-white/70 dark:hover:bg-oai-gray-800/70"),children:O(c)},o))}),i.length===0?p.jsx("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:"—"}):p.jsx("div",{className:"mt-2 overflow-x-auto",children:p.jsxs("div",{role:"table","aria-label":O("dashboard.context_breakdown.exec_details.title"),className:s?"min-w-[420px]":"min-w-[260px]",children:[p.jsxs("div",{role:"row",className:`grid ${a} gap-2 py-1.5 mb-1 border-b border-oai-gray-200 dark:border-oai-gray-800 text-label uppercase text-oai-gray-500 dark:text-oai-gray-400`,children:[p.jsx("span",{role:"columnheader",children:O("dashboard.context_breakdown.exec_details.kind_column")}),p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.calls_column")}),s&&p.jsxs(p.Fragment,{children:[p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.failures_column")}),p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.duration_column")}),p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.max_duration_column")})]}),p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.tool_details.total_column")}),s&&p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.output_column")})]}),i.map((o,c)=>p.jsxs(tr.div,{role:"row",className:`grid ${a} gap-2 py-1.5`,title:o.name,initial:{opacity:0},animate:{opacity:1},transition:{duration:.18,delay:c*.02},children:[p.jsx("span",{role:"cell",className:"min-w-0 text-body-sm font-medium text-oai-black dark:text-oai-white truncate",children:o.name}),p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ms(o.calls||0)}),s&&p.jsxs(p.Fragment,{children:[p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ms(o.failures||0)}),p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:PP(o.duration_ms||0)}),p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:PP(o.max_duration_ms||0)})]}),p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Lc(o.totals.total_tokens||0)}),s&&p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ms(o.output_lines||0)})]},o.name))]})})]})}function LP({toolSet:t,execDetails:e,source:n,codexQueueFallback:r}){const[i,s]=x.useState({}),[a,o]=x.useState(!1),c=Moe(t?.categories||[]);function u(f){s(h=>({...h,[f]:!h[f]}))}return c.length===0?p.jsx("p",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500 py-0.5",children:O(n==="codex"&&r?"dashboard.context_breakdown.tool_details.unavailable_codex":IF(n))}):p.jsx("ul",{className:"mt-0.5 mb-0.5 space-y-0.5",children:c.map(f=>{const h=f.toolCount>0,m=f.name==="Execution"&&e,g=m&&f.tools.some(w=>NP(w.name)),v=!!i[f.name];return p.jsxs(Md,{level:1,label:f.name,labelTone:"strong",hasChevron:h||m&&!g,open:v||m&&!g&&a,onToggle:()=>{h?u(f.name):m&&!g&&o(w=>!w)},tokens:Lc(f.totals.total_tokens||0),percent:null,children:[h&&p.jsx("ul",{className:"space-y-0.5",children:f.tools.map(w=>{const b=m&&NP(w.name);return p.jsx(Md,{level:2,label:w.name,labelTone:b?"accent":"default",hasChevron:b,open:a,onToggle:()=>o(_=>!_),tokens:Lc(w.total_tokens||0),percent:null,children:b&&p.jsx(DP,{execDetails:e,source:n})},w.name)})}),m&&!g&&p.jsx(DP,{execDetails:e,source:n})]},f.name)})})}function Ioe({from:t,to:e,source:n="claude",referenceTotalTokens:r=null,onLoadingChange:i=null}){const[s,a]=x.useState(null),[o,c]=x.useState(!1),[u,f]=x.useState(null),[h,m]=x.useState({});function g(L){m(z=>({...z,[L]:!z[L]}))}if(x.useEffect(()=>{let L=!1;return c(!0),i?.(!0),f(null),k7({from:t,to:e,source:n,timeZone:bL(),tzOffsetMinutes:_L()}).then(z=>{L||a(z)}).catch(z=>{L||f(z?.message||String(z))}).finally(()=>{L||(c(!1),i?.(!1))}),()=>{L=!0}},[t,e,n]),o&&!s)return p.jsxs("div",{children:[p.jsx("div",{className:"h-1 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden animate-pulse"}),p.jsx("div",{className:"mt-3 grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-2",children:[0,1,2,3,4].map(L=>p.jsx("div",{className:"h-3 rounded bg-oai-gray-100 dark:bg-oai-gray-800 animate-pulse",style:{animationDelay:`${L*80}ms`}},L))}),p.jsx("p",{className:"mt-3 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:O("dashboard.context_breakdown.loading_hint")})]});if(u)return p.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:O(Noe(n))});if(!s||s.scope!=="supported"||!s.totals?.total_tokens)return p.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:O(IF(n))});const v=n==="claude"?woe(s.categories||[],r):Soe(s,r),w=s.tool_calls_breakdown||null,b=s.skills_breakdown||null,_=s.message_breakdown||null,E=s.configured_resources||null,M=s.exec_command_breakdown||null,T=Coe(b?.skills||[]),R=Toe(_?.categories||[]),A=n==="codex"&&(s?.breakdown_status==="queue_fallback"||s?.fallback==="queue_totals"),P=n==="claude"?w?.tool_calls||null:w||null,k=n==="claude"&&w?.subagents||null,N=k?.categories?.length>0||(E?.custom_agents_count||0)>0,B=[...v].sort((L,z)=>(z.totals?.total_tokens||0)-(L.totals?.total_tokens||0));return p.jsxs("div",{role:"region","aria-label":O("dashboard.context_breakdown.bar_aria",{summary:v.filter(L=>L.percent>0).map(L=>`${RP(L.key)} ${L.percent}%`).join(",")}),children:[p.jsxs("ul",{className:"space-y-0.5",children:[B.map(L=>{const z=L.key==="system_prompt",I=L.key==="messages",V=L.key==="tool_calls",W=L.key==="custom_agents";L.key;const X=I&&R.length>0||V&&(P?.categories?.length>0||A)||W&&N&&k,J=!!h[L.key],F=hoe(L.key,n),G=p.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0",style:{backgroundColor:F},"aria-hidden":"true"}),Y=z?p.jsxs("span",{className:"relative inline-flex shrink-0 group",children:[p.jsx(VL,{size:11,className:"text-oai-gray-400 dark:text-oai-gray-500 cursor-help","aria-hidden":"true"}),p.jsx("span",{role:"tooltip",className:"pointer-events-none absolute left-1/2 bottom-full z-20 mb-1.5 -translate-x-1/2 w-64 rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-white dark:bg-oai-gray-900 px-2.5 py-1.5 text-[11px] leading-snug text-oai-gray-700 dark:text-oai-gray-200 shadow-md opacity-0 group-hover:opacity-100 transition-opacity",children:O("dashboard.context_breakdown.system_prefix_tooltip")})]}):null,H=L.percent>0?`${L.percent.toFixed(L.percent<.1&&L.percent>0?2:1)}%`:"0.0%";return p.jsxs(Md,{level:0,colorSquare:G,label:RP(L.key),labelSuffix:Y,tokens:Lc(L.totals?.total_tokens||0),percent:H,hasChevron:X,open:J,onToggle:()=>g(L.key),share:L.percent,fillColor:F,children:[I&&p.jsx("ul",{className:"space-y-0.5",children:R.map(te=>p.jsx(Md,{level:1,label:Aoe(te),tokens:Lc(te.totals.total_tokens||0),percent:null},te.key||te.name))}),V&&P&&p.jsx(LP,{toolSet:P,execDetails:M,source:n,codexQueueFallback:A}),V&&A&&!P&&p.jsx("p",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500 py-0.5",children:O("dashboard.context_breakdown.tool_details.unavailable_codex")}),W&&k&&p.jsx(LP,{toolSet:k,execDetails:null,source:n,codexQueueFallback:!1})]},L.key)}),T.length>0&&p.jsx(Md,{level:0,colorSquare:p.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:O("dashboard.context_breakdown.category.skills"),tokens:Lc(T.reduce((L,z)=>L+(z.total_tokens||0),0)),percent:null,hasChevron:!0,open:!!h.skills,onToggle:()=>g("skills"),children:p.jsx("ul",{className:"space-y-0.5",children:T.slice(0,12).map(L=>p.jsx(Md,{level:1,label:L.name,tokens:Lc(L.total_tokens),percent:null},L.name))})})]}),p.jsx("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:O(Doe(n))}),A?p.jsx("p",{className:"mt-2 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:O("dashboard.context_breakdown.tool_details.unavailable_codex")}):null,E?p.jsxs("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:[Ms(E.skills_count||0)," skills ·"," ",Ms(E.mcp_servers_count||0)," MCP servers ·"," ",Ms(E.custom_agents_count||0)," agents ·"," ",Ms(E.memory_files_count||0)," memory files"]}):null]})}function OF(t){if(!Number.isFinite(Number(t)))return null;const e=Number(t);return e<=0?null:Ms(e,{decimals:1})}function FF(t){const e=Number(t);return!Number.isFinite(e)||e<=0?null:e<.01?"<$0.01":Uy(e.toFixed(2),{decimals:2})}function Ooe(t){return Array.isArray(t)?t.map(e=>typeof e=="string"?{key:e,label:IP(e)}:{key:e.key,label:e.label||IP(e.key)}):[]}function Foe(t){if(typeof t!="string")return null;const e=t.replace(/,/g,"").match(/-?\d+(?:\.\d+)?/);if(!e)return null;const n=Number(e[0]);return Number.isFinite(n)?n:null}const Uoe={CODEX:"#10b981",CLAUDE:"#8b5cf6",OPENCODE:"#f59e0b",GEMINI:"#3b82f6",KIMI:"#a78bfa"};function b_(t,e){const n=t?.toUpperCase?.()||"";return Uoe[n]||`hsl(${150+e*40}, 60%, 45%)`}function joe(t){const e=String(t?.source||"").trim().toLowerCase(),n=String(t?.label||"").trim().toLowerCase();return e==="claude"||n==="claude"?"claude":e==="codex"||n==="codex"?"codex":null}const Boe={day:"usage.period.day",week:"usage.period.week",month:"usage.period.month",total:"usage.period.total",custom:"usage.period.custom"};function IP(t){const e=Boe[t];return e?O(e):String(t).toUpperCase()}function zoe({loading:t,onClick:e}){const n=cu();return p.jsx(Ui,{variant:"secondary",size:"sm",disabled:t,onClick:e,"aria-label":O("usage.button.refresh"),className:"w-8 p-0",children:p.jsx(tr.span,{"aria-hidden":"true",animate:t?{rotate:360}:{rotate:0},transition:t&&!n?{duration:1,repeat:1/0,ease:"linear"}:{duration:.3},style:{display:"inline-block"},children:"↻"})})}function Voe({period:t,periods:e,onPeriodChange:n,summaryValue:r,summaryLabel:i,summaryCostValue:s,onCostInfo:a,fleetData:o=[],onRefresh:c,loading:u,className:f="",customFrom:h,customTo:m,onCustomRangeApply:g,customRangeOpen:v,onCustomRangeOpenChange:w,onOpenShare:b,from:_,to:E}){const M=Ooe(e),T=Foe(String(r??"")),R=T!=null,[A,P]=x.useState(null),{resolvedTheme:k}=Op(),N=k==="dark",B=N?"rgba(10,10,10,0.98)":"rgba(255,255,255,0.96)",L=N?"rgba(10,10,10,0)":"rgba(255,255,255,0)",z=o.filter(I=>I.models?.length>0);return p.jsxs(pu,{className:f,children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 mb-6",children:[p.jsx("div",{role:"tablist","aria-label":O("usage.overview.tablist_aria"),className:"flex gap-1",children:M.map(I=>{const V=t===I.key,W=`text-xs font-medium px-3 py-1.5 rounded-md transition-colors ${V?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800"}`;if(I.key==="custom"){const X=V&&h&&m?`${TP(h)} — ${TP(m)}`:I.label;return p.jsxs(Z5,{open:v,onOpenChange:J=>{J?n?.("custom"):w?.(J)},children:[p.jsx(J5,{render:p.jsx("button",{role:"tab","aria-selected":V,type:"button",className:W}),children:X}),p.jsx(eF,{children:p.jsx(nF,{sideOffset:8,side:"bottom",align:"start",className:"!z-[9999]",children:p.jsx(rF,{className:"bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded-xl shadow-lg",children:p.jsx(foe,{from:h,to:m,onApply:g,onCancel:()=>w?.(!1)})})})})]},"custom")}return p.jsx("button",{role:"tab","aria-selected":V,type:"button",className:W,onClick:()=>n?.(I.key),children:I.label},I.key)})}),p.jsxs("div",{className:"flex items-center gap-1.5",children:[b?p.jsxs("button",{type:"button",onClick:b,"aria-label":O("share.button.aria"),className:"inline-flex items-center justify-center gap-1.5 h-8 px-3 text-xs font-medium rounded-md border border-oai-gray-300 dark:border-oai-gray-700 bg-oai-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white hover:border-oai-brand hover:text-oai-brand transition-colors duration-200",children:[p.jsx(vG,{className:"h-3.5 w-3.5",strokeWidth:2}),O("share.button.label")]}):null,c&&p.jsx(zoe,{loading:u,onClick:c})]})]}),p.jsxs("div",{className:"text-center mb-8",children:[p.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wider mb-3",children:i}),p.jsx("div",{className:"text-6xl md:text-7xl font-bold text-oai-black dark:text-oai-white tracking-tight tabular-nums",children:R?p.jsx(sie,{value:T,displayValue:r,fontSize:72,padding:6,gap:1,textColor:"var(--oai-black, #111827)",fontWeight:700,gradientHeight:N?0:8,gradientFrom:B,gradientTo:L,counterStyle:{paddingLeft:0,paddingRight:0,gap:0},digitStyle:{width:"0.88ch"}}):r}),s&&p.jsx("div",{className:"flex items-center justify-center gap-2 mt-4",children:a?p.jsxs("button",{type:"button",onClick:a,className:"inline-flex items-center gap-1.5 text-xl font-bold text-oai-brand hover:text-oai-brand-dark dark:hover:text-oai-brand-light transition-colors cursor-pointer","aria-label":O("usage.overview.cost_breakdown_aria"),children:[s,p.jsx(VL,{size:16,strokeWidth:2,className:"opacity-80"})]}):p.jsx("span",{className:"text-xl font-bold text-oai-brand",children:s})})]}),z.length>0&&p.jsxs("div",{className:"space-y-6",children:[p.jsx("div",{role:"img","aria-label":O("usage.overview.distribution_aria",{items:z.map(I=>O("usage.overview.distribution_item",{label:I.label,percent:I.totalPercent})).join(",")}),className:"h-1.5 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden flex",children:z.map((I,V)=>{const W=b_(I.label,V);return p.jsx(tr.div,{initial:{width:0},animate:{width:`${I.totalPercent}%`},transition:{duration:.5,delay:.45+V*.04,ease:[.16,1,.3,1]},className:"h-full",style:{backgroundColor:W},title:`${I.label}: ${I.totalPercent}%`},I.label)})}),p.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 xl:grid-cols-5 gap-3",children:z.map((I,V)=>{const W=b_(I.label,V),X=A===I.label;return p.jsxs("button",{"aria-expanded":X,"aria-controls":`provider-details-${I.label}`,"aria-label":O("usage.overview.provider_card_aria",{provider:I.label,percent:I.totalPercent,tokens:OF(I.usage)||"0",cost:FF(I.usd)||"$0",action:O(X?"usage.overview.collapse":"usage.overview.expand")}),onClick:()=>P(X?null:I.label),className:`min-w-0 text-left p-3 rounded-lg border transition-colors duration-200 ${X?"border-oai-gray-300 dark:border-oai-gray-600 bg-oai-gray-50 dark:bg-oai-gray-800":"border-oai-gray-200 dark:border-oai-gray-700 hover:border-oai-gray-300 dark:hover:border-oai-gray-600"}`,children:[p.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[p.jsx(nu,{provider:I.label,size:15,color:W,className:"text-oai-gray-700 dark:text-oai-gray-300 shrink-0"}),p.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:I.label})]}),p.jsxs("div",{className:"text-lg font-semibold text-oai-black dark:text-oai-white tabular-nums",children:[I.totalPercent,"%"]}),p.jsx("div",{className:"mt-0.5 text-[11px] text-oai-gray-400 dark:text-oai-gray-400 tabular-nums",children:O("usage.overview.model_count",{count:I.models.length})})]},I.label)})}),A&&p.jsx("div",{id:`provider-details-${A}`,role:"region","aria-label":O("usage.overview.model_details_aria",{provider:A}),className:"mt-2",children:z.filter(I=>I.label===A).map(I=>{const V=b_(I.label,0),W=joe(I),X=[...I.models].sort((F,G)=>(G.share||0)-(F.share||0)),J=W?`${W==="claude"?"Claude":"Codex"} Context Breakdown`:I.label;return p.jsx(Hoe,{provider:I,color:V,providerHeading:J,contextSource:W,from:_,to:E,sortedModels:X},I.label)})})]})]})}function Hoe({provider:t,color:e,providerHeading:n,contextSource:r,from:i,to:s,sortedModels:a}){const[o,c]=x.useState(!1);return p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-1.5 mb-3",children:[p.jsx(nu,{provider:t.label,size:14,color:e,className:"shrink-0"}),p.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:n}),r&&o&&p.jsx(Ao,{size:12,className:"text-oai-gray-400 dark:text-oai-gray-500 animate-spin shrink-0","aria-label":O("dashboard.context_breakdown.loading_aria")})]}),r?p.jsx("div",{className:"mb-4 pb-4 border-b border-oai-gray-200 dark:border-oai-gray-700",children:p.jsx(Ioe,{from:i,to:s,source:r,referenceTotalTokens:t.usage,onLoadingChange:c})}):null,p.jsx("div",{className:"space-y-3",children:a.map(u=>{const f=OF(u.usage),h=FF(u.cost),m=Math.max(0,Math.min(100,Number(u.share)||0));return p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-baseline gap-4 mb-1.5",children:[p.jsx("span",{className:"flex-1 min-w-0 text-sm text-oai-gray-700 dark:text-oai-gray-300 truncate",title:u.name,children:u.name}),p.jsx("span",{className:"shrink-0 w-16 text-right text-sm text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:f}),p.jsx("span",{className:"shrink-0 w-16 text-right text-sm text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:h}),p.jsxs("span",{className:"shrink-0 w-12 text-right text-sm text-oai-black dark:text-oai-white tabular-nums",children:[u.share,"%"]})]}),p.jsx("div",{className:"h-[3px] bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden",role:"progressbar","aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100,children:p.jsx("div",{className:"h-full transition-[width] duration-500 ease-out",style:{width:`${m}%`,backgroundColor:e,opacity:.45}})})]},u.id||u.name)})})]})}function OP(t,e){if(!Array.isArray(t)||t.length===0)return 0;if(t.length===1)return t[0];const n=(t.length-1)*e,r=Math.floor(n),i=Math.ceil(n);if(r===i)return t[r];const s=n-r;return t[r]+(t[i]-t[r])*s}function Woe(t){const e=Array.isArray(t)?t.filter(i=>Number.isFinite(i)&&i>0).sort((i,s)=>i-s):[];if(e.length===0)return{rawMax:0,effectiveMax:1,clippedValues:Array.isArray(t)?t.map(()=>0):[]};const n=e.at(-1)??0;let r=n;if(e.length>=4){const i=OP(e,.25),s=OP(e,.75),a=Math.max(s-i,0),o=s+a*1.5;n>o&&(r=Math.max(o,s,1))}return{rawMax:n,effectiveMax:Math.max(r,1),clippedValues:Array.isArray(t)?t.map(i=>!Number.isFinite(i)||i<=0?0:Math.min(i,Math.max(r,1))):[]}}function Goe({value:t,displayValue:e,scale:n,index:r,row:i,totalBars:s}){const a=cu(),o=n.effectiveMax>0?e/n.effectiveMax*100:0,c=`${Math.max(o,2)}%`,u=i?.missing,f=i?.future,h=s<=7?"6px":s<=14?"4px":"3px";return p.jsx(tr.div,{className:"group relative flex-1 self-stretch",initial:{opacity:0,scaleY:0},animate:{opacity:1,scaleY:1},transition:{duration:a?0:.3,delay:a?0:.4+r*.008,ease:[.16,1,.3,1]},style:{originY:1},children:p.jsxs("div",{className:"absolute inset-x-0 bottom-0",style:{height:c},children:[p.jsx("div",{"data-trend-bar":"true",className:"h-full w-full cursor-pointer transition-all duration-200 group-hover:brightness-110",style:{minHeight:t>0?"4px":"2px",opacity:u||f?.2:1,borderRadius:`${h} ${h} 0 0`,background:t>0?"#10b981":"var(--oai-gray-100)"},title:`${t.toLocaleString()}`}),p.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-oai-black text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-20",children:t.toLocaleString()})]})})}function $oe({rows:t,from:e,to:n,period:r,timeZoneLabel:i,showTimeZoneLabel:s=!0,className:a=""}){const o=Array.isArray(t)&&t.length?t:[],c=o.map(f=>{if(f?.missing||f?.future)return 0;const h=f?.billable_total_tokens??f?.total_tokens??f?.value;if(h==null)return 0;const m=Number(h);return Number.isFinite(m)?m:0}),u=Woe(c);return p.jsxs("div",{className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5 ${a}`,children:[p.jsxs("div",{className:"mb-3",children:[p.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:O("trend.monitor.label")}),s&&i&&p.jsx("p",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:i})]}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"relative",children:[p.jsx("div",{className:"absolute inset-0 flex flex-col justify-between pointer-events-none",children:[0,25,50,75,100].map(f=>p.jsx("div",{className:"w-full border-t border-oai-gray-100 dark:border-oai-gray-800",style:{top:`${100-f}%`}},f))}),p.jsx("div",{className:"h-40 flex items-end gap-1 relative z-0",children:c.length>0?c.map((f,h)=>p.jsx(Goe,{value:f,displayValue:u.clippedValues[h]??0,scale:u,index:h,row:o[h],totalBars:c.length},h)):p.jsx("div",{className:"flex-1 h-full flex items-center justify-center",children:p.jsx("p",{className:"text-sm text-oai-gray-400 dark:text-oai-gray-400",children:"No data yet"})})})]}),e&&n&&p.jsxs("div",{className:"flex justify-between text-xs text-oai-gray-500 dark:text-oai-gray-300 font-medium pt-2 border-t border-oai-gray-100 dark:border-oai-gray-800",children:[p.jsx("span",{children:e}),p.jsx("span",{children:n})]})]})]})}function _o({children:t,delay:e=0,duration:n=.35,y:r=12,className:i="",once:s=!0}){return cu()?p.jsx("div",{className:i,children:t}):p.jsx(tr.div,{initial:{opacity:0,y:r},animate:{opacity:1,y:0},transition:{duration:n,delay:e,ease:[.16,1,.3,1]},className:i,children:t})}function Yoe({children:t,staggerDelay:e=.1,initialDelay:n=0,className:r=""}){return cu()?p.jsx("div",{className:r,children:t}):p.jsx(tr.div,{initial:"hidden",animate:"visible",variants:{hidden:{},visible:{transition:{staggerChildren:e,delayChildren:n}}},className:r,children:t})}function qoe({children:t,className:e="",y:n=12}){return cu()?p.jsx("div",{className:e,children:t}):p.jsx(tr.div,{variants:{hidden:{opacity:0,y:n},visible:{opacity:1,y:0,transition:{duration:.35,ease:[.16,1,.3,1]}}},className:e,children:t})}const FP={"idle-living":"idle/living.svg","idle-doze":"idle/doze.svg","idle-follow":"idle/follow.svg","idle-look":"idle/look.svg","idle-yawn":"idle/yawn.svg","idle-collapse":"idle/collapse.svg","working-building":"working/building.svg","working-carrying":"working/carrying.svg","working-conducting":"working/conducting.svg","working-confused":"working/confused.svg","working-debugger":"working/debugger.svg","working-juggling":"working/juggling.svg","working-overheated":"working/overheated.svg","working-pushing":"working/pushing.svg","working-sweeping":"working/sweeping.svg","working-thinking":"working/thinking.svg","working-typing":"working/typing.svg","working-ultrathink":"working/ultrathink.svg","working-wizard":"working/wizard.svg","mini-alert":"mini/alert.svg","mini-crabwalk":"mini/crabwalk.svg","mini-enter":"mini/enter.svg","mini-enter-sleep":"mini/enter-sleep.svg","mini-happy":"mini/happy.svg","mini-idle":"mini/idle.svg","mini-peek":"mini/peek.svg","mini-sleep":"mini/sleep.svg","react-double":"react/double.svg","react-drag":"react/drag.svg","react-left":"react/left.svg","react-right":"react/right.svg","collapse-sleep":"sleep/collapse-sleep.svg",sleeping:"sleep/sleeping.svg",wake:"sleep/wake.svg",disconnected:"status/disconnected.svg",error:"status/error.svg",notification:"status/notification.svg",happy:"happy.svg","static-base":"static-base.svg"},__=new Map;async function Xoe(t){if(__.has(t))return __.get(t);const e=await fetch(`/clawd/${t}`);if(!e.ok)return null;const r=(await e.text()).replace(/<svg([^>]*)>/,(i,s)=>`<svg${s.replace(/\s+width="[^"]*"/g,"").replace(/\s+height="[^"]*"/g,"")} width="100%" height="100%">`);return __.set(t,r),r}function Koe({state:t="idle-living",size:e=48,className:n=""}){const[r,i]=x.useState(""),s=x.useRef(null),o=Zoe()?"static-base":t,c=FP[o]||FP["static-base"];return x.useEffect(()=>{let u=!1;return Xoe(c).then(f=>{!u&&f&&i(f)}),()=>{u=!0}},[c]),x.useEffect(()=>{const u=s.current?.querySelector("svg");if(u)try{const f=u.getBBox();f.width>0&&f.height>0&&u.setAttribute("viewBox",`${f.x-2} ${f.y-2} ${f.width+4} ${f.height+4}`)}catch{}},[r]),p.jsx("div",{ref:s,className:`clawd-animated ${n}`,style:{width:e,height:e,display:"inline-flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},dangerouslySetInnerHTML:{__html:r}})}function Zoe(){const[t,e]=x.useState(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return x.useEffect(()=>{const n=window.matchMedia("(prefers-reduced-motion: reduce)"),r=i=>e(i.matches);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}function Joe({todayTokens:t=0,isSyncing:e=!1,hasError:n=!1,isDisconnected:r=!1}={}){return x.useMemo(()=>n?"error":r?"disconnected":e?"working-typing":t===0?"sleeping":t<5e4?"idle-living":t<2e5?"idle-look":t<5e5?"working-ultrathink":t<2e6?"working-typing":"working-ultrathink",[t,e,n,r])}const UP="macAppBannerDismissed",Qoe="leaderboardBannerDismissed",ele="https://github.com/mm7894215/TokenTracker/releases/latest",jP="tokentracker_native_app",Tg=(()=>{try{return new URLSearchParams(window.location.search).get("app")==="1"?(localStorage.setItem(jP,"1"),!0):localStorage.getItem(jP)==="1"}catch{return!1}})();function tle({todayTokens:t=0,isSyncing:e=!1,enterDelay:n=0}){const{openLoginModal:r}=Cp(),{signedIn:i}=la(),s=Joe({todayTokens:t,isSyncing:e}),a=Tg?Qoe:UP,[o,c]=x.useState(()=>{try{return localStorage.getItem(a)==="1"?!0:!Tg&&new URLSearchParams(window.location.search).get("from")==="menubar"?(localStorage.setItem(UP,"1"),!0):!1}catch{return!1}}),u=x.useCallback(()=>{c(!0);try{localStorage.setItem(a,"1")}catch{}},[a]);if(o)return null;let f,h,m,g,v,w;Tg&&i?(f="View the Leaderboard",h="Compare your usage globally",m="Leaderboard",g=p.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:p.jsx("path",{d:"M2 8.5V10h8V8.5M6 1.5v6m0 0L3.5 5M6 7.5l2.5-2.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(180 6 6)"})}),v=()=>{window.location.pathname="/leaderboard"}):Tg?(f="Join the Leaderboard",h="Log in to compare your usage with others",m="Log In",g=p.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:p.jsx("path",{d:"M6.5 1.5h3a1 1 0 011 1v7a1 1 0 01-1 1h-3M5 8.5L7.5 6 5 3.5M7.5 6H1.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),v=r):(f="Try the Menu Bar App",h="Always-on stats with Clawd companion",m="Download",g=p.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:p.jsx("path",{d:"M6 2v6m0 0L3.5 5.5M6 8l2.5-2.5M2 10h8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),w=ele);const b=w?tr.a:tr.button,_=w?{href:w,target:"_blank",rel:"noopener noreferrer"}:{onClick:v};return p.jsx(tr.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.35,delay:n,ease:[.16,1,.3,1]},className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-4",children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:"flex-shrink-0",children:p.jsx(Koe,{state:s,size:56})}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("div",{className:"text-sm font-medium text-oai-gray-900 dark:text-oai-white",children:f}),p.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-0.5",children:h})]}),p.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[p.jsxs(b,{..._,whileHover:{scale:1.03},whileTap:{scale:.97},className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-white bg-oai-gray-900 dark:bg-oai-white dark:text-oai-gray-900 rounded-md hover:opacity-90 transition-opacity",children:[m,g]}),p.jsx("button",{onClick:u,className:"p-1 text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-300 transition-colors","aria-label":"Dismiss",children:p.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:p.jsx("path",{d:"M4 4l6 6m0-6L4 10",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})})]})]})})}const BP="widgetOnboardingDismissed",zP="tokentracker_native_app",nle=(()=>{try{return new URLSearchParams(window.location.search).get("app")==="1"?(localStorage.setItem(zP,"1"),!0):localStorage.getItem(zP)==="1"}catch{return!1}})();function rle({enterDelay:t=0}){const[e,n]=x.useState(()=>{try{return localStorage.getItem(BP)==="1"}catch{return!1}}),r=x.useCallback(()=>{n(!0);try{localStorage.setItem(BP,"1")}catch{}},[]);return nle?p.jsx(Lp,{initial:!1,children:!e&&p.jsxs(tr.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-8,transition:{duration:.2,ease:[.4,0,.2,1]}},transition:{duration:.35,delay:t,ease:[.16,1,.3,1]},className:"relative rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-4",children:[p.jsx("button",{type:"button",onClick:r,"aria-label":O("dashboard.widgets.dismiss_aria"),className:"absolute top-2.5 right-2.5 z-10 inline-flex items-center justify-center w-7 h-7 rounded-md text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-300 dark:focus-visible:ring-oai-gray-600 transition-colors",children:p.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:p.jsx("path",{d:"M4 4l6 6m0-6L4 10",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}),p.jsx("div",{className:"rounded-lg overflow-hidden ring-1 ring-black/5 dark:ring-white/10 shadow-sm",children:p.jsx("img",{src:"/widgets-overview.png",alt:O("dashboard.widgets.title"),width:734,height:552,className:"w-full h-auto block",loading:"lazy",decoding:"async"})}),p.jsxs("div",{className:"mt-4",children:[p.jsx("div",{className:"text-sm font-medium tracking-tight text-oai-gray-900 dark:text-oai-white",children:O("dashboard.widgets.title")}),p.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1 leading-snug",children:O("dashboard.widgets.hint")})]})]},"widget-onboarding-card")}):null}function ile(t){const{copy:e,onOpenShare:n,screenshotMode:r,showExpiredGate:i,showAuthGate:s,screenshotTitleLine1:a,screenshotTitleLine2:o,identityDisplayName:c,identityStartDate:u,activeDays:f,identitySubscriptions:h,identityScrambleDurationMs:m,projectUsageEntries:g,projectUsageLimit:v,setProjectUsageLimit:w,topModels:b,signedIn:_,publicMode:E,isLocalMode:M,shouldShowInstall:T,installPrompt:R,handleCopyInstall:A,installCopied:P,installInitCmdDisplay:k,trendRowsForDisplay:N,trendFromForDisplay:B,trendToForDisplay:L,usageFrom:z,usageTo:I,period:V,trendTimeZoneLabel:W,activityHeatmapBlock:X,isCapturing:J,handleShareToX:F,screenshotTwitterButton:G,screenshotTwitterHint:Y,periodsForDisplay:H,setSelectedPeriod:te,customFrom:re,customTo:ue,onCustomRangeApply:ce,customRangeOpen:ee,onCustomRangeOpenChange:le,summaryLabel:ve,summaryValue:Ne,summaryTotalTokensRaw:be,summaryCostValue:qe,summaryConversationsValue:he,rollingUsage:Ue,costInfoEnabled:je,openCostModal:et,costModalOpen:_e,closeCostModal:oe,allowBreakdownToggle:Q,refreshAll:ze,usageLoadingState:Re,fleetData:De,hasDetailsActual:Le,dailyEmptyPrefix:$,installSyncCmd:U,dailyEmptySuffix:Z,detailsColumns:pe,ariaSortFor:Se,toggleSort:xe,sortIconFor:Ie,pagedDetails:He,dailyBreakdownRows:Ye,dailyBreakdownColumns:ft,dailyBreakdownAriaSortFor:We,dailyBreakdownSortIconFor:Xe,dailyBreakdownDateKey:nt,detailsDateKey:ct,renderDetailDate:Ke,renderDailyBreakdownDate:gt,renderDetailCell:ne,DETAILS_PAGED_PERIODS:Be,detailsPageCount:ke,detailsPage:Ae,setDetailsPage:Ve}=t,ge=null,ut=null,yt=.06,qt=.05,Lt=.11;let _t=0;const wt=()=>Lt+yt*_t++,un=Lt+yt*5;return p.jsxs(p.Fragment,{children:[p.jsx(Sre,{bare:!r,hideHeader:r,header:ge,footer:r?null:ut,className:r?"screenshot-mode":"",children:i||s?null:p.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-4",children:[p.jsxs("div",{className:"lg:col-span-4 flex flex-col gap-4 min-w-0 order-2 lg:order-1",children:[r?p.jsx("div",{className:"flex items-start justify-between gap-4",children:p.jsxs("div",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-3xl md:text-4xl font-semibold text-oai-black dark:text-oai-white tracking-tight leading-none",children:a}),p.jsx("span",{className:"text-2xl md:text-3xl font-semibold text-oai-black dark:text-oai-white tracking-tight leading-none",children:o})]})}):null,M?p.jsx(tle,{todayTokens:be,isSyncing:Re,enterDelay:wt()}):null,p.jsx(_o,{delay:wt(),children:p.jsx(uie,{title:e("dashboard.identity.title"),subtitle:e("dashboard.identity.subtitle"),period:V,rankLabel:u??e("identity_card.rank_placeholder"),streakDays:f,subscriptions:h,periodConversations:he,rolling:Ue,topModels:b})}),M?p.jsx(rle,{enterDelay:wt()}):null,T?p.jsx(_o,{delay:wt(),children:p.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-3",children:[p.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-300 mb-1.5",children:R}),p.jsxs(tr.button,{onClick:A,whileHover:{scale:1.01},whileTap:{scale:.99},className:"w-full flex items-center justify-between px-3 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-700 rounded-lg transition-colors",children:[p.jsx("code",{className:"text-xs font-mono text-oai-gray-700 dark:text-oai-gray-300",children:k}),p.jsx(tr.span,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},className:"text-xs text-oai-brand",children:P?"Copied ✓":"Copy"},P?"copied":"copy")]})]})}):null,X&&p.jsx(_o,{delay:wt(),children:X}),r?null:p.jsx(_o,{delay:wt(),children:p.jsx($oe,{rows:N,from:B,to:L,period:V,timeZoneLabel:W,showTimeZoneLabel:!1})}),r?p.jsxs("div",{className:"mt-4 flex flex-col items-center gap-2","data-screenshot-exclude":"true",style:J?{display:"none"}:void 0,children:[p.jsx(Ui,{type:"button",onClick:F,variant:"primary",size:"lg",disabled:J,children:G}),p.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300",children:Y})]}):null]}),p.jsxs("div",{className:"lg:col-span-8 flex flex-col gap-4 min-w-0 order-1 lg:order-2",children:[p.jsx(_o,{delay:qt,children:p.jsx(Voe,{period:V,periods:H,onPeriodChange:te,summaryLabel:ve,summaryValue:Ne,summaryCostValue:qe,onCostInfo:je?et:null,fleetData:De,onRefresh:r?null:ze,loading:Re,onOpenShare:r?null:n,customFrom:re,customTo:ue,onCustomRangeApply:ce,customRangeOpen:ee,onCustomRangeOpenChange:le,from:z,to:I})}),r?null:p.jsx(_o,{delay:un,children:p.jsx(lie,{projectEntries:g,projectLimit:v,onProjectLimitChange:w,copy:e,hasDetailsActual:Le,dailyEmptyPrefix:$,installSyncCmd:U,dailyEmptySuffix:Z,detailsColumns:pe,ariaSortFor:Se,toggleSort:xe,sortIconFor:Ie,pagedDetails:He,dailyBreakdownRows:Ye,dailyBreakdownColumns:ft,dailyBreakdownAriaSortFor:We,dailyBreakdownSortIconFor:Xe,dailyBreakdownDateKey:nt,detailsDateKey:ct,renderDetailDate:Ke,renderDailyBreakdownDate:gt,renderDetailCell:ne,DETAILS_PAGED_PERIODS:Be,period:V,detailsPageCount:ke,detailsPage:Ae,setDetailsPage:Ve})})]})]})}),p.jsx(oie,{isOpen:_e,onClose:oe,fleetData:De})]})}function UF(){return typeof window>"u"?!1:!!window?.webkit?.messageHandlers?.nativeBridge}const Ic=new Map,Oc=new Map;function jF(){typeof window>"u"||window.__tokentrackerNativeSaveListener||(window.__tokentrackerNativeSaveListener=!0,window.addEventListener("native:saveImageResult",t=>{const e=t?.detail||{},n=typeof e.requestId=="string"?e.requestId:null;if(!n||!Ic.has(n))return;const r=Ic.get(n);Ic.delete(n),r({ok:!!e.ok,path:typeof e.path=="string"?e.path:void 0,error:typeof e.error=="string"?e.error:void 0})}),window.addEventListener("native:copyImageResult",t=>{const e=t?.detail||{},n=typeof e.requestId=="string"?e.requestId:null;if(!n||!Oc.has(n))return;const r=Oc.get(n);Oc.delete(n),r({ok:!!e.ok,error:typeof e.error=="string"?e.error:void 0})}))}async function sle(t){if(!UF()||typeof window>"u")return{ok:!1,error:"native bridge unavailable"};const e=window?.webkit?.messageHandlers?.nativeBridge;if(!e)return{ok:!1,error:"native bridge unavailable"};jF();const n=`copy_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return new Promise(r=>{const i=window.setTimeout(()=>{Oc.has(n)&&(Oc.delete(n),r({ok:!1,error:"timeout"}))},8e3);Oc.set(n,s=>{window.clearTimeout(i),r(s)});try{e.postMessage({type:"action",name:"copyImageToClipboard",requestId:n,dataUrl:t})}catch(s){Oc.delete(n),window.clearTimeout(i),r({ok:!1,error:s?.message||String(s)})}})}async function VP(t,e){if(!UF()||typeof window>"u")return{ok:!1,error:"native bridge unavailable"};const n=window?.webkit?.messageHandlers?.nativeBridge;if(!n)return{ok:!1,error:"native bridge unavailable"};jF();const r=`save_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return new Promise(i=>{const s=window.setTimeout(()=>{Ic.has(r)&&(Ic.delete(r),i({ok:!1,error:"timeout"}))},8e3);Ic.set(r,a=>{window.clearTimeout(s),i(a)});try{n.postMessage({type:"action",name:"saveImageToDownloads",requestId:r,filename:e,dataUrl:t})}catch(a){Ic.delete(r),window.clearTimeout(s),i({ok:!1,error:a?.message||String(a)})}})}const BF=1200,zF=1630,VF={broadsheet:{width:1200,height:1630},"annual-report":{width:1080,height:1865}},ale="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Inter+Tight:wght@400;500;600;700&family=IBM+Plex+Serif:ital,wght@0,400;0,500;0,600;1,400&family=IBM+Plex+Mono:wght@400;500&family=Space+Grotesk:wght@500;600;700&display=swap";let w_=!1;function ole(){if(typeof document>"u"||w_)return;if(document.querySelector('link[data-share-card-fonts="true"]')){w_=!0;return}const e=document.createElement("link");e.rel="stylesheet",e.href=ale,e.dataset.shareCardFonts="true",e.crossOrigin="anonymous",document.head.appendChild(e),w_=!0}async function lle(){if(typeof document>"u")return;const t=document.fonts;if(!(!t||typeof t.ready?.then!="function"))try{await t.ready}catch{}}async function cle(t,e={}){if(typeof window>"u"||!t)return null;ole(),await lle(),await new Promise(c=>requestAnimationFrame(()=>c(null)));const{toBlob:n,toPng:r}=await n4(async()=>{const{toBlob:c,toPng:u}=await import("./index-BeoRn2gJ.js");return{toBlob:c,toPng:u}},[]),i=e.pixelRatio??2,s=t.offsetWidth||BF,a=t.offsetHeight||zF,o={pixelRatio:i,cacheBust:!0,width:s,height:a,style:{width:`${s}px`,height:`${a}px`},skipFonts:!1,filter:c=>!(c instanceof HTMLElement)||c.dataset?.screenshotExclude!=="true"};try{const c=await n(t,o);if(c)return c}catch{}try{const c=await r(t,o);return c?await(await fetch(c)).blob():null}catch{return null}}async function S_(t){return new Promise(e=>{const n=new FileReader;n.onload=()=>{const r=typeof n.result=="string"?n.result:null;e(r)},n.onerror=()=>e(null),n.readAsDataURL(t)})}function HP(t,e){if(typeof window>"u"||!t)return!1;try{const n=URL.createObjectURL(t),r=document.createElement("a");return r.href=n,r.download=e,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3),!0}catch{return!1}}function D1(t){const e=ti(t);return Number.isFinite(e)?e:0}function ule(t){return t?D1(t.billable_total_tokens??t.total_tokens):0}function dle(t){const e=Array.isArray(t?.weeks)?t.weeks:[];if(!e.length)return{weeks:[],totalDays:0,activeDays:0};let n=0,r=0;return{weeks:e.map(s=>(Array.isArray(s)?s:[]).slice(0,7).map(o=>{const c=!!o?.future,u=Number.isFinite(o?.level)?Math.max(0,Math.min(4,Math.round(o.level))):0;o?.day&&!c&&(n+=1,u>0&&(r+=1));const f=o?.billable_total_tokens??o?.total_tokens??o?.value??0,h=Number.isFinite(f)?Math.max(0,f):0;return{day:typeof o?.day=="string"?o.day:"",level:u,value:h,future:c}})),totalDays:n,activeDays:r}}function fle(t){const{handle:e,startDate:n,activeDays:r,summary:i,topModels:s,rank:a,period:o,periodFrom:c,periodTo:u,heatmap:f,capturedAt:h}=t,m=ule(i),g=D1(i?.total_cost_usd),v=Array.isArray(s)?s.slice(0,3).map(b=>({id:b?.id??null,name:typeof b?.name=="string"&&b.name?b.name:"—",tokens:D1(b?.tokens),percent:typeof b?.percent=="string"&&b.percent?b.percent:"0.0"})):[],w=dle(f);return{handle:e||"—",startDate:n||null,activeDays:Number.isFinite(r)&&r>0?Math.floor(r):0,totalTokens:m,totalCost:g,period:o,periodFrom:c,periodTo:u,topModels:v,rank:typeof a=="number"&&Number.isFinite(a)&&a>0?Math.floor(a):null,heatmapWeeks:w.weeks,heatmapTotalDays:w.totalDays,heatmapActiveDays:w.activeDays,capturedAt:h||new Date().toISOString()}}const hle=["share.month_short.jan","share.month_short.feb","share.month_short.mar","share.month_short.apr","share.month_short.may","share.month_short.jun","share.month_short.jul","share.month_short.aug","share.month_short.sep","share.month_short.oct","share.month_short.nov","share.month_short.dec"];function ple(t){const e=hle[t];return e?O(e):"—"}function HF(t,e){return O("share.date.month_year",{month:ple(t),year:e})}function mle(t){if(!t)return"—";const e=t.split("-");if(e.length!==3)return t;const[n,r]=e,i=Number(r)-1;return i<0||i>11?t:HF(i,n)}function gle(t){if(t.period==="total")return O("share.issue.all_time");if(t.period==="day"&&t.periodTo)return t.periodTo.replace(/-/g,".");if(t.period==="custom"&&t.periodFrom&&t.periodTo)return`${t.periodFrom.replace(/-/g,".")} — ${t.periodTo.replace(/-/g,".")}`;if(t.periodTo){const e=new Date(`${t.periodTo}T00:00:00Z`);if(!Number.isNaN(e.getTime()))return HF(e.getUTCMonth(),e.getUTCFullYear())}return O(`usage.period.${t.period}`)}function L1(t){return Number.isFinite(t)?Math.round(t).toLocaleString("en-US"):"—"}function WF(t){return!Number.isFinite(t)||t<=0?"$0.00":t>=1e3?`$${Math.round(t).toLocaleString("en-US")}`:`$${t.toFixed(2)}`}function yle(t){const e=t.topModels[0];if(e){const n=parseFloat(e.percent);return Number.isFinite(n)&&n>=60?O("share.hook.top_loyal",{percent:Math.round(n),name:e.name}):t.activeDays>=60?O("share.hook.days_record",{days:t.activeDays}):Number.isFinite(n)&&n>=30?O("share.hook.top_led",{name:e.name,percent:Math.round(n)}):t.topModels.length>1?O("share.hook.multi_models",{count:t.topModels.length,days:t.activeDays}):O("share.hook.days_with_model",{days:t.activeDays,name:e.name})}return t.activeDays>0?O("share.hook.days_record",{days:t.activeDays}):O("share.hook.new_chapter")}function vle(t,e){const n=(t||"").length;if(n<=e.baseChars)return e.baseSize;const r=e.baseSize-(n-e.baseChars)*e.shrinkPerChar;return Math.max(e.minSize,r)}function xle(t){if(!t||t.future)return null;const e=typeof t.level=="number"?t.level:0;return e<0?0:e>4?4:Math.round(e)}function ble({weeks:t,palette:e,width:n,gap:r=3,radius:i=2,emptyColor:s}){if(!Array.isArray(t)||t.length===0||!n||n<=0)return null;const a=e||["#eee","#ccc","#999","#666","#333"],o=s||a[0],c=t.length,u=(c-1)*r,f=Math.max(4,(n-u)/c),h=7*f+6*r;return p.jsx("svg",{width:n,height:h,viewBox:`0 0 ${n} ${h}`,xmlns:"http://www.w3.org/2000/svg","aria-hidden":!0,style:{display:"block"},children:t.map((m,g)=>(Array.isArray(m)?m:[]).map((w,b)=>{if(b>=7)return null;const _=xle(w),E=g*(f+r),M=b*(f+r),T=_===null?o:a[_];return p.jsx("rect",{x:E,y:M,width:f,height:f,rx:i,ry:i,fill:T},`${g}-${b}`)}))})}const _le="oklch(0.97 0.01 85)",Ji="oklch(0.18 0.02 85)",ll="oklch(0.38 0.015 85)",WP="oklch(0.55 0.012 85)",mc="oklch(0.55 0.22 25)",gc='"Instrument Serif", "Times New Roman", Georgia, serif',wle='"Inter Tight", "Helvetica Neue", Arial, sans-serif',Sle=["oklch(0.93 0.013 80)","oklch(0.87 0.04 55)","oklch(0.78 0.09 45)","oklch(0.67 0.16 35)","oklch(0.55 0.22 25)"];function GF({data:t}){const e=gle(t),n=L1(t.totalTokens),r=WF(t.totalCost),i=mle(t.startDate),s=vle(n,{baseSize:188,baseChars:9,shrinkPerChar:14,minSize:104}),a=yle(t),o=Array.isArray(t.heatmapWeeks)&&t.heatmapWeeks.length>0;return p.jsxs("div",{style:{width:"100%",height:"100%",background:_le,color:Ji,fontFamily:wle,padding:"80px 88px 68px 88px",boxSizing:"border-box",display:"flex",flexDirection:"column",position:"relative"},children:[p.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:24,paddingBottom:14,borderBottom:`1px solid ${WP}`},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,fontSize:14,fontWeight:500,letterSpacing:"0.22em",textTransform:"uppercase",color:Ji},children:[p.jsx("div",{style:{width:10,height:10,borderRadius:"50%",background:mc}}),"The Token Tracker"]}),p.jsxs("div",{style:{fontSize:12,letterSpacing:"0.22em",textTransform:"uppercase",color:ll,textAlign:"right"},children:[O("share.card.broadsheet.issue")," № ",e]})]}),p.jsxs("div",{style:{marginTop:24,display:"flex",justifyContent:"space-between",alignItems:"flex-end",gap:24},children:[p.jsxs("div",{children:[p.jsx("div",{style:{fontSize:12,letterSpacing:"0.2em",textTransform:"uppercase",color:ll,marginBottom:6},children:O("share.card.broadsheet.by")}),p.jsx("div",{style:{fontFamily:gc,fontSize:52,fontStyle:"italic",lineHeight:1,color:Ji,letterSpacing:"-0.01em"},children:t.handle})]}),p.jsxs("div",{style:{fontSize:12,letterSpacing:"0.18em",textTransform:"uppercase",color:ll,textAlign:"right",lineHeight:1.6},children:[O("share.card.broadsheet.tracked_since"),p.jsx("br",{}),p.jsx("span",{style:{color:Ji},children:i})]})]}),p.jsxs("div",{style:{marginTop:40,display:"flex",flexDirection:"column"},children:[p.jsx("div",{style:{fontSize:13,letterSpacing:"0.3em",textTransform:"uppercase",color:mc,marginBottom:10},children:O("share.card.broadsheet.total_tokens")}),p.jsx("div",{style:{fontFamily:gc,fontSize:s,fontWeight:400,lineHeight:.86,letterSpacing:"-0.032em",color:Ji,fontFeatureSettings:'"lnum" 1, "tnum" 1',whiteSpace:"nowrap",overflow:"hidden"},children:n}),p.jsxs("div",{style:{marginTop:14,fontFamily:gc,fontStyle:"italic",fontSize:34,lineHeight:1.15,color:Ji,letterSpacing:"-0.005em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:["“",a,"”"]}),p.jsx("div",{style:{marginTop:14,height:1,background:mc,width:"100%"}}),p.jsxs("div",{style:{marginTop:10,display:"flex",justifyContent:"space-between",fontSize:13,letterSpacing:"0.16em",textTransform:"uppercase",color:ll},children:[p.jsxs("span",{children:[O("share.card.broadsheet.estimated_spend")," · ",r]}),p.jsx("span",{children:O("share.card.broadsheet.billable_days",{days:t.activeDays})})]})]}),o?p.jsxs("section",{style:{marginTop:40},children:[p.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",marginBottom:12},children:[p.jsx("div",{style:{fontSize:12,letterSpacing:"0.3em",textTransform:"uppercase",color:Ji,fontWeight:600},children:O("share.card.broadsheet.heatmap_title")}),p.jsx("div",{style:{fontSize:11,letterSpacing:"0.18em",textTransform:"uppercase",color:ll},children:O("share.card.broadsheet.heatmap_days_on_record",{active:t.heatmapActiveDays,total:t.heatmapTotalDays})})]}),p.jsx(ble,{weeks:t.heatmapWeeks,palette:Sle,width:1024,gap:3,radius:2})]}):null,p.jsxs("section",{style:{marginTop:30,flex:1},children:[p.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",borderBottom:`1px solid ${Ji}`,paddingBottom:10,marginBottom:6},children:[p.jsx("div",{style:{fontSize:12,letterSpacing:"0.3em",textTransform:"uppercase",color:Ji,fontWeight:600},children:O("share.card.broadsheet.roster_title")}),p.jsx("div",{style:{fontSize:11,letterSpacing:"0.18em",textTransform:"uppercase",color:ll},children:O("share.card.broadsheet.roster_subtitle")})]}),t.topModels.length===0?p.jsx("div",{style:{fontFamily:gc,fontStyle:"italic",fontSize:26,color:ll,paddingTop:14},children:O("share.card.broadsheet.empty")}):t.topModels.map((c,u)=>p.jsxs("div",{style:{display:"grid",gridTemplateColumns:"52px 1fr auto 68px",alignItems:"baseline",gap:16,padding:"13px 0",borderBottom:`1px solid ${WP}`},children:[p.jsx("div",{style:{fontFamily:gc,fontSize:34,fontStyle:"italic",color:mc,lineHeight:1},children:String(u+1).padStart(2,"0")}),p.jsx("div",{style:{fontFamily:gc,fontSize:32,color:Ji,lineHeight:1.1,letterSpacing:"-0.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:c.name}),p.jsx("div",{style:{fontFamily:gc,fontSize:28,color:Ji,fontFeatureSettings:'"lnum" 1, "tnum" 1',whiteSpace:"nowrap"},children:L1(c.tokens)}),p.jsxs("div",{style:{fontSize:13,letterSpacing:"0.1em",color:ll,textAlign:"right",fontFeatureSettings:'"tnum" 1'},children:[c.percent,"%"]})]},c.id||c.name))]}),p.jsxs("footer",{style:{marginTop:18,paddingTop:12,borderTop:`1px solid ${Ji}`,display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:12,letterSpacing:"0.22em",textTransform:"uppercase",color:Ji},children:[p.jsxs("div",{style:{display:"flex",gap:28},children:[p.jsxs("span",{children:[O("share.card.broadsheet.global_rank")," ",p.jsxs("span",{style:{color:mc},children:["№ ",t.rank!=null?t.rank:"—"]})]}),p.jsxs("span",{children:[O("share.card.broadsheet.active_days")," ",p.jsx("span",{style:{color:mc},children:O("share.card.broadsheet.days_count",{days:t.activeDays})})]})]}),p.jsxs("div",{children:[O("share.card.broadsheet.track_yours")," ",p.jsx("span",{style:{color:mc},children:"→ tokentracker.cc"})]})]})]})}const kle=VF["annual-report"].width,Ele="#0a0820",cl="#ffffffee",Ec="rgba(255,255,255,0.45)",k_="#a78bfa",Mle={background:"rgba(20,15,50,0.38)",backdropFilter:"blur(40px)",WebkitBackdropFilter:"blur(40px)",border:"1px solid rgba(255,255,255,0.05)",boxShadow:["0 39px 56px -36px rgba(255,255,255,0.10) inset","0 7px 11px -4px rgba(255,255,255,0.06) inset","0 -82px 68px -64px rgba(101,67,149,0.08) inset","0 98px 100px -48px rgba(208,171,255,0.06) inset","0 4px 18px 0 rgba(156,146,215,0.06) inset","0 1px 40px 0 rgba(228,222,255,0.04) inset"].join(", ")},Cg={background:"rgba(20,15,50,0.38)",backdropFilter:"blur(32px)",WebkitBackdropFilter:"blur(32px)",border:"1px solid rgba(255,255,255,0.06)",boxShadow:"0 1px 8px 0 rgba(228,222,255,0.06) inset"},I1='"Space Grotesk", "Inter Tight", sans-serif',E_='"Inter Tight", sans-serif',Tle="rgba(255,255,255,0.06)",$F=[Tle,"#4a3d8f","#6b5cbe","#9060e0","#d946ef"],YF=48,qF=28,vy=4,XF=20,Cle=kle-YF*2-qF*2,Ale=(Cle-XF*2)/3,O1=Math.min(Math.floor((Ale-vy*6)/7),40),Rle=O1*7+vy*6;function Ple(t){if(!Array.isArray(t))return t;const e=[];for(const o of t)if(Array.isArray(o))for(const c of o)c?.day&&!c.future&&c.value>0&&e.push(c.value);if(!e.length)return t;e.sort((o,c)=>o-c);const n=o=>{const c=e.length,u=(c-1)*o,f=Math.floor(u);return Math.round((e[f]??0)+((e[Math.min(c-1,f+1)]??0)-(e[f]??0))*(u-f))},r=n(.5),i=n(.75),s=n(.9),a=o=>!o||o<=0?0:o<=r?1:o<=i?2:o<=s?3:4;return t.map(o=>Array.isArray(o)?o.map(c=>c?.day&&!c.future&&typeof c.value=="number"?{...c,level:a(c.value)}:c):o)}function Nle(t){if(!Array.isArray(t))return[];const e={},n=Ple(t);for(const r of n)if(Array.isArray(r))for(const i of r){if(!i?.day||i.future)continue;const s=i.day.split("-");if(s.length<2)continue;const a=`${s[0]}-${s[1]}`;(e[a]??=[]).push(i)}return Object.entries(e).sort(([r],[i])=>r.localeCompare(i)).slice(-12).map(([r,i])=>({month:parseInt(r.split("-")[1],10),cells:i}))}function Dle(t){if(!t.length)return[];const e=[...t].sort((a,o)=>a.day.localeCompare(o.day));let n=new Date(`${e[0].day}T00:00:00Z`).getUTCDay();const r=Array(n).fill(null).concat(e),i=[];for(let a=0;a<r.length;a+=7)i.push(r.slice(a,a+7));const s=i[i.length-1];for(;s&&s.length<7;)s.push(null);return i.slice(0,6)}const Lle=["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ile(t){if(!Array.isArray(t))return 0;const e=[];for(const i of t)if(Array.isArray(i))for(const s of i)s?.day&&!s.future&&e.push(s);e.sort((i,s)=>i.day.localeCompare(s.day));let n=0,r=0;for(const i of e)(i.level||0)>0?(r++,r>n&&(n=r)):r=0;return n}function GP(t){const[e,n]=x.useState(null);return x.useEffect(()=>{if(!t){n(null);return}let r=!1;const i=new Image;return i.crossOrigin="anonymous",i.onload=()=>{if(!r)try{const s=document.createElement("canvas");s.width=i.naturalWidth,s.height=i.naturalHeight,s.getContext("2d").drawImage(i,0,0),n(s.toDataURL("image/png"))}catch{n(null)}},i.onerror=()=>{r||n(null)},i.src=t,()=>{r=!0}},[t]),e}function Ole({data:t}){const e=Dle(t.cells);return p.jsxs("div",{children:[p.jsx("div",{style:{fontSize:16,fontWeight:600,color:Ec,fontFamily:I1,marginBottom:4},children:Lle[t.month]}),p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:vy},children:e.map((n,r)=>p.jsx("div",{style:{display:"flex",gap:vy},children:n.map((i,s)=>{const a=i?Math.min(4,Math.max(0,i.level||0)):-1;return p.jsx("div",{style:{width:O1,height:O1,borderRadius:4,background:a<0?"transparent":$F[a]}},s)})},r))})]})}function Fle({data:t}){const e=Nle(t.heatmapWeeks),n=Ile(t.heatmapWeeks),r=t.topModels[0],i=t.avatarUrl||null,s=GP(i),a=GP("/neon_bg.png"),o=(t.handle||"?")[0].toUpperCase(),c=16;return p.jsxs("div",{style:{width:"100%",height:"100%",background:Ele,fontFamily:I1,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[p.jsx("img",{src:a||"/neon_bg.png",alt:"",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",pointerEvents:"none"}}),p.jsxs("div",{style:{position:"relative",zIndex:1,display:"flex",flexDirection:"column",height:"100%",padding:YF,boxSizing:"border-box"},children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:c*3},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[p.jsx("img",{src:"/app-icon.png",alt:"",width:64,height:64,style:{width:64,height:64,borderRadius:16,display:"block"}}),p.jsxs("div",{children:[p.jsx("div",{style:{fontSize:20,fontWeight:500,color:Ec,lineHeight:1.2},children:"Token Tracker"}),p.jsx("div",{style:{fontSize:36,fontWeight:700,lineHeight:1.15,color:cl},children:O("share.card.annual.report_title")})]})]}),p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[p.jsx("div",{style:{width:48,height:48,borderRadius:"50%",background:"linear-gradient(135deg,#4c1d95,#7c3aed)",display:"flex",alignItems:"center",justifyContent:"center",border:"2px solid rgba(255,255,255,0.15)",overflow:"hidden",flexShrink:0},children:s?p.jsx("img",{src:s,alt:"",width:48,height:48,style:{width:48,height:48,objectFit:"cover",display:"block"},crossOrigin:"anonymous",referrerPolicy:"no-referrer"}):p.jsx("span",{style:{fontSize:20,fontWeight:700,color:cl},children:o})}),p.jsx("div",{style:{fontSize:32,fontWeight:700,color:cl},children:t.handle})]})]}),p.jsxs("div",{style:{...Mle,borderRadius:22,padding:qF,marginBottom:c},children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:14,color:Ec},children:[p.jsx("span",{children:O("share.card.annual.less")}),$F.map((u,f)=>p.jsx("div",{style:{width:16,height:16,borderRadius:3,background:u}},f)),p.jsx("span",{children:O("share.card.annual.more")})]}),p.jsx("div",{style:{fontSize:16,fontWeight:700,letterSpacing:"0.14em",color:"rgba(255,255,255,0.22)",textTransform:"uppercase"},children:O("share.card.annual.heatmap_title")})]}),p.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(3,${Rle}px)`,gap:`8px ${XF}px`,justifyContent:"center"},children:e.map(u=>p.jsx(Ole,{data:u},u.month))})]}),p.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:c,marginBottom:c},children:[p.jsxs("div",{style:{...Cg,borderRadius:22,padding:"28px 16px",textAlign:"center"},children:[p.jsx("div",{style:{fontFamily:E_,fontSize:52,fontWeight:700,color:cl,letterSpacing:"-0.02em",lineHeight:1},children:L1(t.totalTokens)}),p.jsx("div",{style:{fontSize:22,color:Ec,marginTop:12},children:O("share.card.annual.total_tokens")})]}),p.jsxs("div",{style:{...Cg,borderRadius:22,padding:"28px 16px",textAlign:"center"},children:[p.jsx("div",{style:{fontFamily:E_,fontSize:52,fontWeight:700,color:cl,letterSpacing:"-0.02em",lineHeight:1},children:WF(t.totalCost)}),p.jsx("div",{style:{fontSize:22,color:Ec,marginTop:12},children:O("share.card.annual.estimated_cost")})]})]}),p.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:c},children:[p.jsxs("div",{style:{...Cg,borderRadius:22,padding:"18px 24px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[p.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:k_,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("path",{d:"M12 2v4m0 12v4M4.93 4.93l2.83 2.83m8.48 8.48 2.83 2.83M2 12h4m12 0h4M4.93 19.07l2.83-2.83m8.48-8.48 2.83-2.83"}),p.jsx("circle",{cx:"12",cy:"12",r:"4"})]}),p.jsx("span",{style:{fontSize:20,color:Ec},children:O("share.card.annual.longest_streak")})]}),p.jsx("span",{style:{fontFamily:E_,fontSize:28,fontWeight:700,color:cl},children:O("share.card.annual.days_count",{days:n})})]}),p.jsxs("div",{style:{...Cg,borderRadius:22,padding:"18px 24px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[p.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:k_,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),p.jsx("circle",{cx:"12",cy:"12",r:"4"})]}),p.jsx("span",{style:{fontSize:20,color:Ec},children:O("share.card.annual.top_model")})]}),p.jsx("span",{style:{fontFamily:I1,fontSize:28,fontWeight:700,color:cl},children:r?r.name:"—"})]})]}),p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"auto"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[p.jsx("img",{src:"/app-icon.png",alt:"",width:44,height:44,style:{width:44,height:44,borderRadius:8,display:"block"}}),p.jsx("span",{style:{fontSize:22,fontWeight:600,color:cl},children:"Token Tracker"})]}),p.jsx("span",{style:{fontSize:22,fontWeight:600,color:k_},children:"tokentracker.cc"})]})]})]})}const KF=[{id:"annual-report",labelKey:"share.variant.neon"},{id:"broadsheet",labelKey:"share.variant.broadsheet"}],Ule={broadsheet:GF,"annual-report":Fle};function ZF(t){return VF[t]||{width:BF,height:zF}}function jle(t){const e=KF.find(n=>n.id===t);return e?.labelKey?O(e.labelKey):t}const $P=x.forwardRef(function({data:e,variant:n},r){const i=Ule[n]||GF,{width:s,height:a}=ZF(n);return p.jsx("div",{ref:r,"data-share-card":"true",style:{width:s,height:a,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:p.jsx(i,{data:e})})});function Ag(){return typeof window>"u"?!1:!!window?.webkit?.messageHandlers?.nativeBridge}const Ble=440;function zle(){const[t,e]=x.useState(null),n=x.useRef(null),r=x.useCallback((i,s="info")=>{n.current&&window.clearTimeout(n.current),e({id:Date.now(),kind:s,text:i}),n.current=window.setTimeout(()=>e(null),2800)},[]);return x.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{toast:t,push:r}}function M_({onClick:t,disabled:e,children:n,emphasis:r,ariaLabel:i}){return p.jsx("button",{type:"button",onClick:t,disabled:e,"aria-label":i,className:["group relative flex items-center justify-between gap-3 w-full px-4 py-3 text-left","rounded-lg border transition-colors",r?"border-oai-black dark:border-oai-white bg-oai-black dark:bg-oai-white text-oai-white dark:text-oai-black hover:opacity-90":"border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600",e?"opacity-60 cursor-not-allowed":"cursor-pointer"].join(" "),children:n})}function Vle({open:t,onClose:e,data:n,twitterText:r}){const[i,s]=x.useState(null),[a,o]=x.useState(""),[c,u]=x.useState("annual-report"),f=x.useRef(null),{toast:h,push:m}=zle(),g=la(),v=x.useMemo(()=>{const k=g?.user;if(!k||typeof k!="object")return null;const N=k.user_metadata||{},B=k.profile||{},L=N.avatar_url||N.picture||B.avatar_url||k.avatar_url;return typeof L=="string"&&L.trim()?L.trim():null},[g?.user]);x.useEffect(()=>{t&&(s(null),o(n?.handle||""))},[t,n?.handle]);const w=n&&{...n,handle:a||n.handle,avatarUrl:v},{width:b,height:_}=ZF(c),E=Ble/b;x.useEffect(()=>{if(!t)return;const k=N=>{N.key==="Escape"&&e?.()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[t,e]);const M=x.useCallback(async()=>{const k=f.current;if(!k)return null;try{return await cle(k)}catch(N){return console.warn("[share] capture failed",N),null}},[]),T=x.useCallback(async()=>{if(i)return;s("copy");const k=await M();if(!k){m(O("share.toast.failed"),"error"),s(null);return}let N=!1;if(Ag()){const B=await S_(k);B&&(N=(await sle(B)).ok)}else N=await Bw(k);m(O(N?"share.toast.copied":"share.toast.failed"),N?"success":"error"),s(null)},[i,M,m]),R=x.useCallback(()=>`tokentracker-share-${Date.now()}.png`,[]),A=x.useCallback(async()=>{if(i)return;s("download");const k=await M();if(!k){m(O("share.toast.failed"),"error"),s(null);return}if(Ag()){const B=await S_(k);if(B&&(await VP(B,R())).ok){m(O("share.toast.downloaded"),"success"),s(null);return}}const N=HP(k,R());m(O(N?"share.toast.downloaded":"share.toast.failed"),N?"success":"error"),s(null)},[i,M,R,m]),P=x.useCallback(async()=>{if(i)return;s("x");const k=await M();if(!k){m(O("share.toast.failed"),"error"),s(null);return}if(Ag()){const B=await S_(k);B&&(await VP(B,R()),m(O("share.toast.downloaded"),"success"))}else await Bw(k)?m(O("share.toast.copied"),"success"):HP(k,R());const N=new URL("https://twitter.com/intent/tweet");if(r&&N.searchParams.set("text",r),Ag())try{window.webkit?.messageHandlers?.nativeBridge?.postMessage({type:"action",name:"openURL",value:N.toString()})}catch{window.open(N.toString(),"_blank","noopener,noreferrer")}else window.open(N.toString(),"_blank","noopener,noreferrer");s(null)},[i,M,m,r,R]);return t?p.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":O("share.modal.title"),"data-screenshot-exclude":"true",className:"fixed inset-0 z-[9999] flex items-center justify-center p-4 sm:p-6",style:{background:"rgba(10,10,10,0.72)"},onClick:k=>{k.target===k.currentTarget&&e?.()},children:[p.jsx("div",{"aria-hidden":!0,style:{position:"fixed",left:0,top:0,width:b,height:_,pointerEvents:"none",opacity:0,zIndex:-1,clip:"rect(0,0,0,0)",overflow:"hidden"},children:p.jsx($P,{ref:f,data:w,variant:c})}),p.jsxs(tr.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:12},transition:{duration:.18,ease:[.2,.8,.2,1]},className:"relative w-full max-w-[1040px] max-h-[92vh] overflow-hidden rounded-2xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-black shadow-oai-lg",children:[p.jsxs("div",{className:"flex flex-col lg:flex-row max-h-[92vh]",children:[p.jsx("div",{className:"flex-1 min-w-0 p-4 sm:p-7 bg-oai-gray-50 dark:bg-oai-gray-950 flex items-center justify-center overflow-auto",children:p.jsxs("div",{style:{width:b*E,height:_*E,flexShrink:0,position:"relative"},className:"rounded-xl overflow-hidden shadow-oai-md ring-1 ring-black/5",children:[i?p.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-white/70 dark:bg-black/50",children:p.jsxs("svg",{className:"animate-spin h-6 w-6 text-oai-gray-500",viewBox:"0 0 24 24",fill:"none",children:[p.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),p.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}):null,p.jsx("div",{style:{width:b,height:_,transform:`scale(${E})`,transformOrigin:"top left"},children:p.jsx($P,{data:w,variant:c})})]})}),p.jsxs("div",{className:"w-full lg:w-[340px] flex-shrink-0 border-t lg:border-t-0 lg:border-l border-oai-gray-200 dark:border-oai-gray-800 p-5 sm:p-6 flex flex-col gap-5 overflow-y-auto",children:[p.jsxs("div",{className:"flex items-start justify-between gap-2",children:[p.jsxs("div",{children:[p.jsx("h2",{className:"text-lg font-semibold text-oai-black dark:text-oai-white",children:O("share.modal.title")}),p.jsx("p",{className:"mt-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:O("share.modal.subtitle")})]}),p.jsx("button",{type:"button",onClick:e,"aria-label":O("share.modal.close"),className:"p-1.5 -mt-1 -mr-1 rounded-md text-oai-gray-500 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:p.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),p.jsxs("div",{children:[p.jsx("label",{htmlFor:"share-handle",className:"text-[11px] tracking-[0.18em] uppercase text-oai-gray-500 dark:text-oai-gray-400 mb-1.5 block",children:O("share.modal.name_label")}),p.jsx("input",{id:"share-handle",type:"text",value:a,onChange:k=>o(k.target.value),placeholder:O("share.modal.name_placeholder"),className:"w-full px-3 py-2 text-sm rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white placeholder:text-oai-gray-400 dark:placeholder:text-oai-gray-600 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-oai-brand transition-colors"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"text-[11px] tracking-[0.18em] uppercase text-oai-gray-500 dark:text-oai-gray-400 mb-1.5 block",children:O("share.modal.style_label")}),p.jsx("div",{className:"flex gap-2",children:KF.map(k=>p.jsx("button",{type:"button",onClick:()=>u(k.id),className:["flex-1 px-3 py-2 text-sm rounded-lg border transition-colors",c===k.id?"border-oai-black dark:border-oai-white bg-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white font-medium":"border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 text-oai-gray-500 dark:text-oai-gray-400 hover:border-oai-gray-400 dark:hover:border-oai-gray-600"].join(" "),children:jle(k.id)},k.id))})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[p.jsxs(M_,{onClick:P,disabled:!!i,emphasis:!0,children:[p.jsxs("span",{className:"flex items-center gap-3",children:[p.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:p.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),p.jsx("span",{className:"font-medium text-sm",children:O("share.modal.action.x")})]}),p.jsx("span",{className:"text-[11px] opacity-70",children:O(i==="x"?"share.toast.working":"share.modal.hint.x")})]}),p.jsxs(M_,{onClick:A,disabled:!!i,children:[p.jsxs("span",{className:"flex items-center gap-3",children:[p.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[p.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),p.jsx("polyline",{points:"7 10 12 15 17 10"}),p.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),p.jsx("span",{className:"font-medium text-sm",children:O("share.modal.action.download")})]}),p.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:"PNG"})]}),p.jsxs(M_,{onClick:T,disabled:!!i,children:[p.jsxs("span",{className:"flex items-center gap-3",children:[p.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[p.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),p.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),p.jsx("span",{className:"font-medium text-sm",children:O("share.modal.action.copy")})]}),p.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:O("share.modal.hint.copy")})]})]}),p.jsx("div",{className:"mt-auto pt-4 border-t border-oai-gray-200 dark:border-oai-gray-800",children:p.jsx("p",{className:"text-[11px] leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:O("share.modal.footer")})})]})]}),p.jsx(Lp,{children:h?p.jsx(tr.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},className:"pointer-events-none absolute left-1/2 bottom-4 -translate-x-1/2",children:p.jsx("div",{className:["px-4 py-2 rounded-full text-xs font-medium shadow-oai-md",h.kind==="error"?"bg-red-600 text-white":h.kind==="success"?"bg-oai-black dark:bg-oai-white text-oai-white dark:text-oai-black":"bg-oai-gray-800 text-white"].join(" "),children:h.text})},h.id):null})]})]}):null}function Hle(t){const{enabled:e,handle:n,startDate:r,activeDays:i,summary:s,topModels:a,period:o,periodFrom:c,periodTo:u,heatmap:f,accessToken:h,userId:m}=t,[g,v]=x.useState(null);return x.useEffect(()=>{if(!e||!m&&!vr())return;let w=!1;return(async()=>{try{const _=await TL({accessToken:h,userId:m,period:o==="day"||o==="custom"?"week":o,metric:"all",limit:100,offset:0});if(w)return;const M=(Array.isArray(_?.entries)?_.entries:Array.isArray(_)?_:[]).find(R=>R?.is_me===!0),T=typeof M?.rank=="number"?M.rank:null;v(T)}catch{w||v(null)}})(),()=>{w=!0}},[e,h,m,o]),x.useMemo(()=>fle({handle:n,startDate:r,activeDays:i,summary:s,topModels:a,rank:g,period:o,periodFrom:c,periodTo:u,heatmap:f}),[n,r,i,s,a,g,o,c,u,f])}const Wle=["day","week","month","total","custom"],T_=new Set(["day","hour","month"]),hh=new Set(["day","total","custom"]);function C_(t,e){if(typeof e=="number"&&e>0)return!0;if(typeof t=="bigint")return t>0n;if(typeof t=="number")return Number.isFinite(t)&&t>0;if(typeof t=="string"){const n=t.trim();if(!n)return!1;if(/^[0-9]+$/.test(n))try{return BigInt(n)>0n}catch{return!1}const r=Number(n);return Number.isFinite(r)&&r>0}return!1}function Rg(t){return t?t?.billable_total_tokens??t?.total_tokens:null}function YP(t){return t?t?.billable_total_tokens??t?.value??t?.total_tokens:null}function Gle(t){if(typeof t!="string"||!t)return null;const e=t.split("-");if(e.length!==3)return null;const n=Number(e[0]),r=Number(e[1])-1,i=Number(e[2]);if(!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i))return null;const s=new Date(Date.UTC(n,r,i));return Number.isFinite(s.getTime())?s:null}function $le(t,e){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()+e))}function Yle(t){return t?t==="www.tokentracker.cc"||t==="tokentracker.cc":!1}function qle(){if(typeof window>"u")return!1;const t=new URLSearchParams(window.location.search),e=String(t.get("force_install")||"").toLowerCase();return e!=="1"&&e!=="true"?!1:!Yle(window.location.hostname)}function Xle({baseUrl:t,auth:e,signedIn:n,sessionSoftExpired:r,signOut:i,publicMode:s=!1,publicToken:a=null,signInUrl:o="/sign-in",signUpUrl:c="/sign-up"}){const{resolvedLocale:u}=lu(),[f,h]=x.useState(!1),[m,g]=x.useState(null),[v,w]=x.useState(null),[b,_]=x.useState(!1),[E,M]=x.useState(null),[T,R]=x.useState(0),[A,P]=x.useState(0),[k,N]=x.useState(null),[B,L]=x.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(max-width: 640px)").matches),z=x.useMemo(()=>typeof window>"u"?!1:lE(window.location.search),[]),I=x.useMemo(()=>qle(),[]),[V,W]=x.useState(!1),[X,J]=x.useState(!1),F=2200,[G,Y]=x.useState(!0),[H,te]=x.useState(!1),[re,ue]=x.useState(!1),[ce,ee]=x.useState(!1),le=vr(),ve=n&&!r,Ne=x.useMemo(()=>ve&&(typeof e=="function"||typeof e=="string"||e&&typeof e=="object")?e:null,[e,ve]),be=ve?Ne:null,qe=s?wo(a):be,he=n||le||s,Ue=ve&&Fl(be),je=n&&r&&!s;x.useEffect(()=>{if(!n||le){g(null),w(null),_(!1),M(null);return}if(s)return;if(!Ue){g(null),w(null),_(!1),M(null);return}let Ge=!0;const Wt=()=>{g(null),w(null),_(!1),M(null)};return _(!0),M(null),(async()=>{let Kt=null;try{Kt=await Dl(be)}catch{Kt=null}if(Ge){if(!Kt){Wt();return}try{const tn={link_code:null,expires_at:null};if(!Ge)return;g(typeof tn?.link_code=="string"?tn.link_code:null),w(typeof tn?.expires_at=="string"?tn.expires_at:null)}catch(tn){if(!Ge)return;g(null),w(null),M(tn?.message||"Failed to load link code")}finally{if(!Ge)return;_(!1)}}})(),()=>{Ge=!1}},[t,le,n,s,Ue,be,A]);const et=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");x.useEffect(()=>{if(!et&&(!n||le||s)){N(null);return}if(!et&&!Ue){N(null);return}let Ge=!0;return(async()=>{let Wt=null;try{Wt=await Dl(be)}catch{Wt=null}if(Ge){if(!Wt&&!et){N(null);return}try{const Kt=await _7({baseUrl:t,accessToken:Wt});if(!Ge)return;N(Kt&&typeof Kt=="object"?Kt:null)}catch{if(!Ge)return;N(null)}}})(),()=>{Ge=!1}},[Ue,t,be,le,s,n]);const _e=x.useMemo(()=>{if(!v)return!1;const Ge=Date.parse(v);if(!Number.isFinite(Ge))return!1;const Wt=T||Date.now();return Ge<=Wt},[v,T]);x.useEffect(()=>{!n||le||s||!v||!_e||b||(g(null),w(null),M(null),P(Ge=>Ge+1))},[_e,v,b,le,n]),x.useEffect(()=>{if(!v||s)return;const Ge=Date.parse(v);if(!Number.isFinite(Ge))return;const Wt=Date.now();if(R(Wt),Ge<=Wt)return;const Kt=window.setTimeout(()=>R(Date.now()),Ge-Wt),tn=()=>{typeof document>"u"||document.visibilityState==="visible"&&R(Date.now())};return typeof document<"u"&&document.addEventListener("visibilitychange",tn),window.addEventListener("focus",tn),()=>{window.clearTimeout(Kt),typeof document<"u"&&document.removeEventListener("visibilitychange",tn),window.removeEventListener("focus",tn)}},[v]),x.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const Ge=window.matchMedia("(max-width: 640px)"),Wt=()=>L(Ge.matches);return Wt(),Ge.addEventListener?(Ge.addEventListener("change",Wt),()=>Ge.removeEventListener("change",Wt)):(Ge.addListener(Wt),()=>Ge.removeListener(Wt))},[]);const oe=x.useMemo(()=>bL(),[]),Q=x.useMemo(()=>_L(),[]),ze=x.useMemo(()=>JH(),[]),Re=s?null:e?.userId||e?.email||"default",[De,Le]=x.useState("month"),[$,U]=x.useState(null),[Z,pe]=x.useState(null),[Se,xe]=x.useState(!1),Ie=z?"total":De,He=x.useMemo(()=>Ie==="custom"&&$&&Z?{from:$,to:Z}:SL(Ie,{timeZone:oe,offsetMinutes:Q,now:ze}),[ze,Ie,oe,Q,$,Z]),Ye=He.from,ft=He.to,We=x.useMemo(()=>BH({timeZone:oe,offsetMinutes:Q}),[oe,Q]),Xe=x.useMemo(()=>zH({timeZone:oe,offsetMinutes:Q}),[oe,Q]),nt=x.useMemo(()=>`Local time (${Xe})`,[Xe]),ct=oe,Ke=Q,gt=We,ne=x.useMemo(()=>bk({timeZone:oe,offsetMinutes:Q,date:ze||new Date}),[ze,oe,Q]),Be=x.useMemo(()=>{const Ge=Gle(ne)||new Date,Wt=$le(Ge,-29);return{from:Hn(Wt),to:Hn(Ge)}},[ne]),{daily:ke,summary:Ae,rolling:Ve,source:ge,loading:ut,error:yt,refresh:qt}=pR({baseUrl:t,accessToken:qe,guestAllowed:je,from:Ye,to:ft,includeDaily:Ie!=="total",cacheKey:Re,timeZone:oe,tzOffsetMinutes:Q,now:ze}),{daily:Lt,loading:_t,refresh:wt}=pR({baseUrl:t,accessToken:qe,guestAllowed:je,from:Be.from,to:Be.to,includeDaily:!0,cacheKey:Re?`${Re}.daily-breakdown`:"daily-breakdown",timeZone:oe,tzOffsetMinutes:Q,now:ze}),{breakdown:un,loading:xn,refresh:ie}=nJ({baseUrl:t,accessToken:qe,guestAllowed:je,from:Ye,to:ft,cacheKey:Re,timeZone:oe,tzOffsetMinutes:Q}),[fe,Te]=x.useState(3),{entries:$e,loading:Ze,refresh:At}=YZ({baseUrl:t,accessToken:qe,limit:fe,from:Ye,to:ft,timeZone:oe,tzOffsetMinutes:Q}),St=Ie==="week"||Ie==="month",Pt=Ie==="week"||Ie==="month",xt=x.useMemo(()=>ke.filter(Ge=>Ge?.future?!1:!Ge?.day||!ne?!0:String(Ge.day)<=String(ne)),[ke,ne]),{rows:Tt,from:Xt,to:zt,loading:En,refresh:yn}=XZ({baseUrl:t,accessToken:qe,guestAllowed:je,period:Ie,from:Ye,to:ft,months:24,cacheKey:Re,timeZone:ct,tzOffsetMinutes:Ke,now:ze,sharedRows:St?ke:null,sharedRange:St?{from:Ye,to:ft}:null}),{daily:Cn,heatmap:In,loading:hr,refresh:An}=$Z({baseUrl:t,accessToken:qe,guestAllowed:je,weeks:52,cacheKey:Re,timeZone:oe,tzOffsetMinutes:Q,now:ze}),{refresh:K}=i4(),me=x.useMemo(()=>Ie==="day"?"hour":Ie==="total"?"month":"day",[Ie]),Pe=x.useMemo(()=>gR(me),[me]),Ee="day",we=x.useMemo(()=>gR(Ee),[]),[at,mt]=x.useState(()=>({key:"day",dir:"desc"}));x.useEffect(()=>{mt(Ge=>!T_.has(Ge.key)||Ge.key===me?Ge:{key:me,dir:Ge.dir})},[me]);const it=x.useMemo(()=>T_.has(at.key)&&at.key!==me?{...at,key:me}:at,[me,at]),pt=x.useMemo(()=>{if(Ie==="day")return Array.isArray(Tt)?Tt.filter(Kt=>Kt?.hour&&!Kt?.future):[];if(Ie==="total"){const Kt=Array.isArray(Tt)?Tt.filter(tn=>tn?.month&&!tn?.future):[];return mJ(Kt)}const Ge=xt;return!Ge.some(Kt=>!Kt?.missing&&!Kt?.future)&&ke.length>0?ke.filter(Kt=>!Kt?.future).slice(-30).filter(Kt=>Kt?.day):Ge},[Ie,Tt,xt,ke]),Et=x.useMemo(()=>yR(pt,it),[pt,it]),dt=x.useMemo(()=>pt.some(Ge=>!Ge?.missing&&!Ge?.future),[pt]),Vt=x.useMemo(()=>{if(!hh.has(Ie))return 1;const Ge=Math.ceil(Et.length/ay);return Ge>0?Ge:1},[Ie,Et.length]),[Ct,dn]=x.useState(0);x.useEffect(()=>{if(!hh.has(Ie)){dn(0);return}dn(Ge=>Math.min(Ge,Vt-1))},[Vt,Ie]),x.useEffect(()=>{hh.has(Ie)&&dn(0)},[Ie,at.dir,at.key]);const en=x.useMemo(()=>hh.has(Ie)?gJ(Et,Ct,ay):Et,[Ct,Ie,Et]),Rn=x.useMemo(()=>Lt.filter(Ge=>!Ge?.future&&Ge?.day).slice(-30),[Lt]),cn=x.useMemo(()=>T_.has(at.key)?{...at,key:Ee}:at,[at]),nr=x.useMemo(()=>yR(Rn,cn),[Rn,cn]),Ut=x.useMemo(()=>Pt?ke:Ie==="day"?Array.isArray(Tt)?Tt.filter(Ge=>Ge?.hour):[]:Tt,[ke,Ie,Tt,Pt]),Kr=Pt?Ye:Xt,wn=Pt?ft:zt;function ri(Ge,Wt){return Ge?.future?"—":Ge?.missing?O("shared.status.unsynced"):Oi(Wt==="total_tokens"?Rg(Ge):Ge?.[Wt])}function ii(Ge){const Wt=Ge?.[me];if(Wt==null)return"";const Kt=String(Wt);if(me==="hour"){const[tn,pr]=Kt.split("T");if(tn&&pr)return`${tn} ${pr.slice(0,5)}`}return Kt}function xi(Ge){const Wt=Ge?.[Ee];return Wt==null?"":String(Wt)}function ca(Ge){mt(Wt=>Wt.key===Ge?{key:Ge,dir:Wt.dir==="asc"?"desc":"asc"}:{key:Ge,dir:"desc"})}function Fn(Ge){return it.key!==Ge?"none":it.dir==="asc"?"ascending":"descending"}function nn(Ge){return it.key!==Ge?"":it.dir==="asc"?"▲":"▼"}function $i(Ge){return cn.key!==Ge?"none":cn.dir==="asc"?"ascending":"descending"}function cr(Ge){return cn.key!==Ge?"":cn.dir==="asc"?"▲":"▼"}const si=x.useMemo(()=>{if(!n&&!le&&!s&&!et)return 0;const Ge=Number(In?.active_days);if(Number.isFinite(Ge))return Ge;let Wt=0;const Kt=new Set,tn=(Yn,rr,Qn)=>{typeof Yn!="string"||!Yn||Kt.has(Yn)||C_(rr,Qn)&&(Kt.add(Yn),Wt+=1)};if(Array.isArray(Cn))for(const Yn of Cn)tn(Yn?.day,Rg(Yn));const pr=Array.isArray(In?.weeks)?In.weeks:[];for(const Yn of pr)for(const rr of Array.isArray(Yn)?Yn:[]){const Qn=YP(rr);tn(rr?.day,Qn,rr?.level)}return Wt},[n,le,In?.active_days,In?.weeks,Cn]),[ds,Vo]=x.useState("month"),Kp=x.useCallback(Ge=>{Ge==="custom"?(Vo(Wt=>Wt==="custom"?"month":Wt),Le(Wt=>$&&Z?"custom":Wt),xe(!0)):(Le(Ge),Vo(Ge),xe(!1))},[$,Z]),_f=x.useCallback((Ge,Wt)=>{U(Ge),pe(Wt),Le("custom"),xe(!1)},[]),mu=x.useCallback(Ge=>{xe(Ge),!Ge&&De==="custom"&&!$&&Le(ds)},[De,$,ds]),Ls=x.useCallback(async()=>{await Promise.all([qt(),An(),yn(),ie(),At(),wt(),K()])},[wt,An,ie,At,yn,qt,K]),ua=x.useCallback(async()=>{ee(!0);try{et&&await w7(),await Ls()}catch(Ge){console.error("[DashboardPage] Refresh failed:",Ge)}finally{ee(!1)}},[et,Ls]),da=ce||ut||_t||hr||En||xn||Ze,Yl=x.useMemo(()=>O("shared.data_source",{source:String(ge||"edge").toUpperCase()}),[ge,u]),fa=x.useMemo(()=>typeof e?.name!="string"?"":e.name.trim(),[e?.name]),ha="",Zp=x.useMemo(()=>!fa||fa.includes("@")?O("dashboard.identity.fallback"):fa,[fa]),wf=x.useMemo(()=>Zp.replace(/[^a-zA-Z0-9._-]/g,"_"),[Zp]),Ho=x.useMemo(()=>s?O("dashboard.identity.fallback"):wf,[wf,ha,s]),Jp=x.useMemo(()=>{let Ge=null;const Wt=tn=>{typeof tn!="string"||!tn||(!Ge||tn<Ge)&&(Ge=tn)};if(Array.isArray(Cn))for(const tn of Cn)tn?.day&&C_(Rg(tn))&&Wt(tn.day);const Kt=Array.isArray(In?.weeks)?In.weeks:[];for(const tn of Kt)for(const pr of Array.isArray(tn)?tn:[]){if(!pr?.day)continue;const Yn=YP(pr),rr=pr?.level;C_(Yn,rr)&&Wt(pr.day)}return Ge},[In?.weeks,Cn]),Qp=x.useMemo(()=>s?[]:(Array.isArray(k?.subscriptions?.items)?k.subscriptions.items:[]).map(Kt=>{const tn=typeof Kt?.tool=="string"?Kt.tool.trim():"",Yn=(typeof Kt?.plan_type=="string"?Kt.plan_type:typeof Kt?.planType=="string"?Kt.planType:"").trim();return!tn||!Yn?null:{tool:tn,planType:Yn,provider:typeof Kt?.provider=="string"?Kt.provider.trim():"",product:typeof Kt?.product=="string"?Kt.product.trim():"",rateLimitTier:typeof Kt?.rate_limit_tier=="string"?Kt.rate_limit_tier.trim():typeof Kt?.rateLimitTier=="string"?Kt.rateLimitTier.trim():""}}).filter(Boolean).slice(0,6),[s,k]),gu=p.jsx(AJ,{heatmap:In,timeZoneLabel:We,timeZoneShortLabel:Xe,hideLegend:z,defaultToLatestMonth:z}),em=x.useMemo(()=>`${Ye}..${ft}`,[Ye,Ie,ft]),Sv=O("usage.summary.total"),Yi=Rg(Ae),Wo=O("shared.unit.thousand_abbrev"),to=O("shared.unit.million_abbrev"),ql=O("shared.unit.billion_abbrev"),yu=ti(Yi),tm=B&&yu!=null&&Math.abs(yu)>=1e9,Sf=x.useMemo(()=>tm?Ms(yu,{thousandSuffix:Wo,millionSuffix:to,billionSuffix:ql,decimals:1}):Oi(Yi),[ql,to,Yi,yu,Wo,tm]),vu=O("dashboard.core_index.collapse_label"),kf=O("dashboard.core_index.expand_label"),nm=O("dashboard.core_index.collapse_aria"),pa=O("dashboard.core_index.expand_aria"),Ef=!z,xu=O("dashboard.screenshot.title_line1"),rm=O("dashboard.screenshot.title_line2"),bu=O("dashboard.screenshot.twitter_label"),_u=O("dashboard.screenshot.twitter_button"),im=O("dashboard.screenshot.twitter_hint"),Sr=O("shared.placeholder.short"),ma=x.useMemo(()=>{const Ge=Array.isArray(un?.sources)?un.sources:[];let Wt=null,Kt=0;for(const rr of Ge){const Qn=ti(rr?.totals?.billable_total_tokens??rr?.totals?.total_tokens);!Number.isFinite(Qn)||Qn<=0||Qn>Kt&&(Kt=Qn,Wt=rr)}let tn=Sr,pr=Sr,Yn="0.0";if(Wt&&Kt>0){tn=Wt?.source?String(Wt.source).toUpperCase():Sr;const rr=Array.isArray(Wt?.models)?Wt.models:[];let Qn=0;for(const Is of rr){const Jl=ti(Is?.totals?.billable_total_tokens??Is?.totals?.total_tokens);!Number.isFinite(Jl)||Jl<=0||Jl>Qn&&(Qn=Jl,pr=Is?.model?String(Is.model):Sr)}Qn>0&&(Yn=(Qn/Kt*100).toFixed(1))}return{agentName:tn,modelName:pr,modelPercent:Yn}},[un,Sr]),wu=Oi(Yi),Mf=O("dashboard.screenshot.twitter_text",{total_tokens:wu==="-"?Sr:wu,agent_name:ma.agentName,model_name:ma.modelName,model_percent:ma.modelPercent}),Xl=x.useMemo(()=>{if(typeof window>"u")return"";const Ge=new URL("https://twitter.com/intent/tweet");return Ge.searchParams.set("text",Mf),Ge.toString()},[Mf]),ku=x.useCallback(async()=>{if(typeof window>"u")return null;const Ge=async()=>{const rr=performance.now();for(;performance.now()-rr<2e3;){const Qn=document.querySelector("[data-heatmap-scroll='true']");if(!Qn||Qn.dataset.latestMonthReady==="true")return;await new Promise(Is=>requestAnimationFrame(Is))}},Wt=document.querySelector("#root")||document.body,Kt=document.documentElement,{scrollWidth:tn,scrollHeight:pr}=document.documentElement;Kt?.classList.add("screenshot-capture"),document.body?.classList.add("screenshot-capture"),await new Promise(Yn=>requestAnimationFrame(Yn)),await Ge();try{const{toBlob:Yn,toPng:rr}=await n4(async()=>{const{toBlob:no,toPng:cm}=await import("./index-BeoRn2gJ.js");return{toBlob:no,toPng:cm}},[]),Qn=await Yn(Wt,{backgroundColor:"#050505",pixelRatio:2,cacheBust:!0,width:tn,height:pr,style:{width:`${tn}px`,height:`${pr}px`},filter:no=>!(no instanceof HTMLElement)||no.dataset?.screenshotExclude!=="true"});if(Qn)return Qn;const Is=await rr(Wt,{backgroundColor:"#050505",pixelRatio:2,cacheBust:!0,width:tn,height:pr,style:{width:`${tn}px`,height:`${pr}px`},filter:no=>!(no instanceof HTMLElement)||no.dataset?.screenshotExclude!=="true"});return Is?await(await fetch(Is)).blob():null}finally{Kt?.classList.remove("screenshot-capture"),document.body?.classList.remove("screenshot-capture")}},[]),Kl=x.useCallback(async()=>{if(typeof window>"u"||V)return;W(!0);const Ge=navigator?.userAgent||"",Wt=/iP(hone|od|ad)/i.test(Ge),Kt=/Safari/i.test(Ge)&&!/Chrome|Chromium|Edg|OPR|CriOS|FxiOS/i.test(Ge),tn=typeof navigator<"u"&&!!navigator.clipboard?.write&&typeof window<"u"&&!!window.ClipboardItem;let Yn=!tn||Wt||Kt;try{const rr=await ku();rr&&tn&&(typeof document<"u"&&!document.hasFocus()&&window.focus?.(),Yn=await Bw(rr))}catch(rr){console.error("Failed to capture screenshot",rr)}finally{if(W(!1),!Yn){console.warn("Failed to write screenshot to clipboard.");return}Xl&&(window.location.href=Xl)}},[ku,V,Xl]),Eu=x.useMemo(()=>z?[]:Wle,[z]),sm=x.useMemo(()=>[{label:O("usage.metric.total"),value:Oi(Yi),valueClassName:"text-white"},{label:O("usage.metric.input"),value:Oi(Ae?.input_tokens)},{label:O("usage.metric.output"),value:Oi(Ae?.output_tokens)},{label:O("usage.metric.cached_input"),value:Oi(Ae?.cached_input_tokens)},{label:O("usage.metric.reasoning_output"),value:Oi(Ae?.reasoning_output_tokens)}],[Ae?.cached_input_tokens,Ae?.input_tokens,Ae?.output_tokens,Ae?.reasoning_output_tokens,Yi]),Tf=x.useMemo(()=>{const Ge=Uy(Ae?.total_cost_usd);return!Ge||Ge==="-"||Ge.startsWith("$")?Ge:`$${Ge}`},[Ae?.total_cost_usd]),kv=x.useMemo(()=>Ae?.conversation_count??null,[Ae?.conversation_count]),am=x.useMemo(()=>xJ(un,{copyFn:O}),[un]),Mu=x.useMemo(()=>bJ(un,{limit:3,copyFn:O}),[un]),Ev=Hle({enabled:X,handle:Ho,startDate:Jp,activeDays:si,summary:Ae,topModels:Mu,period:Ie,periodFrom:Ye,periodTo:ft,heatmap:In,accessToken:typeof qe=="string"?qe:null,userId:e?.userId||null}),Mv=x.useCallback(()=>J(!0),[]),Tv=x.useCallback(()=>J(!1),[]),Cv=x.useCallback(()=>h(!0),[]),Av=x.useCallback(()=>h(!1),[]),om=Tf&&Tf!=="-"&&am.length>0,Zl=O("dashboard.install.cmd.init"),Cf=_e?null:m,Af=Cf?O("dashboard.install.cmd.init_link_code",{link_code:Cf}):Zl,Rv=Zl,Rf=O("dashboard.install.cmd.sync"),Pv=O(Cf?"dashboard.install.copy":"dashboard.install.copy_base"),Nv=O("dashboard.install.copied");O("dashboard.session_expired.copy_label"),O("dashboard.session_expired.copied");const Dv=!!(k?.install?.has_active_device_token??k?.install?.hasActiveDeviceToken),lm=yJ({publicMode:s,screenshotMode:z,forceInstall:I,accessEnabled:he,heatmapLoading:hr,activeDays:si,hasActiveDeviceToken:Dv}),Lv=O("dashboard.install.prompt"),Iv=x.useCallback(async()=>{!Af||!await jw(Af)||(te(!0),window.setTimeout(()=>te(!1),2e3))},[Af]);x.useCallback(async()=>{!Zl||!await jw(Zl)||(ue(!0),window.setTimeout(()=>ue(!1),2e3))},[Zl]);const Pf=x.useMemo(()=>O("dashboard.daily.empty",{cmd:"{{cmd}}"}),[u]),[Ov,Fv]=x.useMemo(()=>{const Ge=Pf.split("{{cmd}}");return Ge.length===1?[Pf,""]:[Ge[0],Ge.slice(1).join("{{cmd}}")]},[Pf]),Uv=r&&!s,Nf=!n&&!le&&!r&&!et&&!s;return p.jsxs(p.Fragment,{children:[p.jsx(ile,{copy:O,onOpenShare:Mv,screenshotMode:z,showExpiredGate:Uv,showAuthGate:Nf,screenshotTitleLine1:xu,screenshotTitleLine2:rm,identityDisplayName:Ho,identityStartDate:Jp,activeDays:si,identitySubscriptions:Qp,identityScrambleDurationMs:F,projectUsageEntries:$e,projectUsageLimit:fe,setProjectUsageLimit:Te,topModels:Mu,signedIn:n,publicMode:s,isLocalMode:et,shouldShowInstall:lm,installPrompt:Lv,handleCopyInstall:Iv,installCopied:H,installCopiedLabel:Nv,installCopyLabel:Pv,installInitCmdDisplay:Rv,linkCodeLoading:b,linkCodeError:E,trendRowsForDisplay:Ut,trendFromForDisplay:Kr,trendToForDisplay:wn,usageFrom:Ye,usageTo:ft,period:Ie,trendTimeZoneLabel:gt,activityHeatmapBlock:gu,isCapturing:V,handleShareToX:Kl,screenshotTwitterLabel:bu,screenshotTwitterButton:_u,screenshotTwitterHint:im,periodsForDisplay:Eu,setSelectedPeriod:Kp,customFrom:$,customTo:Z,onCustomRangeApply:_f,customRangeOpen:Se,onCustomRangeOpenChange:mu,metricsRows:sm,summaryLabel:Sv,summaryValue:Sf,summaryTotalTokensRaw:ti(Yi)||0,summaryCostValue:Tf,summaryConversationsValue:kv,rollingUsage:Ve,costInfoEnabled:om,openCostModal:Cv,allowBreakdownToggle:Ef,coreIndexCollapsed:G,setCoreIndexCollapsed:Y,coreIndexCollapseLabel:vu,coreIndexExpandLabel:kf,coreIndexCollapseAria:nm,coreIndexExpandAria:pa,refreshAll:ua,usageLoadingState:da,usageError:yt,rangeLabel:em,timeZoneRangeLabel:nt,usageSourceLabel:Yl,fleetData:am,hasDetailsActual:dt,dailyEmptyPrefix:Ov,installSyncCmd:Rf,dailyEmptySuffix:Fv,detailsColumns:Pe,ariaSortFor:Fn,toggleSort:ca,sortIconFor:nn,pagedDetails:en,dailyBreakdownRows:nr,dailyBreakdownColumns:we,dailyBreakdownAriaSortFor:$i,dailyBreakdownSortIconFor:cr,dailyBreakdownDateKey:Ee,detailsDateKey:me,renderDetailDate:ii,renderDailyBreakdownDate:xi,renderDetailCell:ri,DETAILS_PAGED_PERIODS:hh,detailsPageCount:Vt,detailsPage:Ct,setDetailsPage:dn,costModalOpen:f,closeCostModal:Av}),p.jsx(Vle,{open:X,onClose:Tv,data:Ev,twitterText:Mf})]})}function Kle(){const[t,e]=x.useState(!1);return p.jsxs("div",{className:"h-full relative dark:bg-[#050505]",children:[!t&&p.jsxs("div",{className:"absolute inset-0 p-6 space-y-5 animate-pulse",children:[p.jsx("div",{className:"flex gap-4 justify-center",children:Array.from({length:6}).map((n,r)=>p.jsx("div",{className:"h-4 w-20 rounded bg-oai-gray-200 dark:bg-oai-gray-800"},r))}),p.jsxs("div",{className:"space-y-2 pt-2",children:[p.jsx("div",{className:"h-7 w-72 rounded bg-oai-gray-200 dark:bg-oai-gray-800"}),p.jsx("div",{className:"h-4 w-96 rounded bg-oai-gray-200 dark:bg-oai-gray-800"})]}),p.jsx("div",{className:"grid grid-cols-3 gap-4",children:Array.from({length:3}).map((n,r)=>p.jsx("div",{className:"h-24 rounded-xl bg-oai-gray-200 dark:bg-oai-gray-800"},r))}),p.jsx("div",{className:"grid grid-cols-3 gap-4",children:Array.from({length:3}).map((n,r)=>p.jsx("div",{className:"h-40 rounded-xl bg-oai-gray-200 dark:bg-oai-gray-800"},r))}),p.jsx("div",{className:"grid grid-cols-3 gap-4",children:Array.from({length:3}).map((n,r)=>p.jsx("div",{className:"h-32 rounded-xl bg-oai-gray-200 dark:bg-oai-gray-800"},r))})]}),p.jsx("iframe",{src:"https://ip.net.coffee/claude/",title:"Cloud AI IP Check",className:`w-full h-full dark:invert dark:hue-rotate-180 transition-opacity duration-300 ${t?"opacity-100":"opacity-0"}`,style:{border:"none"},onLoad:()=>e(!0)})]})}function Zle(){if(typeof window>"u")return!1;const t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"||t==="::1"}function Jle(){return Zle()?"/":"/dashboard"}function JF({repo:t="mm7894215/TokenTracker"}){const[e,n]=x.useState(null);return x.useEffect(()=>{if(typeof window>"u")return;const r=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,i=typeof document<"u"&&(document.documentElement?.classList.contains("screenshot-capture")||document.body?.classList.contains("screenshot-capture"));U5({prefersReducedMotion:r,screenshotCapture:i})&&fetch(`https://api.github.com/repos/${t}`).then(s=>s.json()).then(s=>{s&&typeof s.stargazers_count=="number"&&n(s.stargazers_count)}).catch(()=>{})},[t]),p.jsxs("a",{href:`https://github.com/${t}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex shrink-0 items-center gap-2 px-3 py-1.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-700 transition-colors no-underline",children:[p.jsx("svg",{height:"16",viewBox:"0 0 16 16",width:"16",className:"shrink-0 fill-oai-gray-700 dark:fill-oai-gray-300",children:p.jsx("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})}),p.jsx("span",{className:"text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300 whitespace-nowrap",children:"Star"}),e!==null&&p.jsx("span",{className:"text-xs font-semibold text-oai-gray-900 dark:text-oai-white tabular-nums whitespace-nowrap",children:e})]})}const $E="183",Qle=0,qP=1,ece=2,E0=1,tce=2,Rh=3,Ol=0,zi=1,So=2,Po=0,Hc=1,XP=2,KP=3,ZP=4,nce=5,Tc=100,rce=101,ice=102,sce=103,ace=104,oce=200,lce=201,cce=202,uce=203,F1=204,U1=205,dce=206,fce=207,hce=208,pce=209,mce=210,gce=211,yce=212,vce=213,xce=214,j1=0,B1=1,z1=2,qd=3,V1=4,H1=5,W1=6,G1=7,QF=0,bce=1,_ce=2,Ua=0,eU=1,tU=2,nU=3,rU=4,iU=5,sU=6,aU=7,oU=300,ru=301,Xd=302,A_=303,R_=304,fv=306,$1=1e3,Mo=1001,Y1=1002,ni=1003,wce=1004,Pg=1005,yi=1006,P_=1007,Fc=1008,Es=1009,lU=1010,cU=1011,dp=1012,YE=1013,$a=1014,Da=1015,Uo=1016,qE=1017,XE=1018,fp=1020,uU=35902,dU=35899,fU=1021,hU=1022,ta=1023,jo=1026,Uc=1027,pU=1028,KE=1029,Kd=1030,ZE=1031,JE=1033,M0=33776,T0=33777,C0=33778,A0=33779,q1=35840,X1=35841,K1=35842,Z1=35843,J1=36196,Q1=37492,eS=37496,tS=37488,nS=37489,rS=37490,iS=37491,sS=37808,aS=37809,oS=37810,lS=37811,cS=37812,uS=37813,dS=37814,fS=37815,hS=37816,pS=37817,mS=37818,gS=37819,yS=37820,vS=37821,xS=36492,bS=36494,_S=36495,wS=36283,SS=36284,kS=36285,ES=36286,Sce=3200,kce=0,Ece=1,wl="",ws="srgb",iu="srgb-linear",xy="linear",qn="srgb",Qu=7680,JP=519,Mce=512,Tce=513,Cce=514,QE=515,Ace=516,Rce=517,eM=518,Pce=519,QP=35044,eN="300 es",La=2e3,by=2001;function Nce(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function _y(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Dce(){const t=_y("canvas");return t.style.display="block",t}const tN={};function nN(...t){const e="THREE."+t.shift();console.log(e,...t)}function mU(t){const e=t[0];if(typeof e=="string"&&e.startsWith("TSL:")){const n=t[1];n&&n.isStackTrace?t[0]+=" "+n.getLocation():t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}function ln(...t){t=mU(t);const e="THREE."+t.shift();{const n=t[0];n&&n.isStackTrace?console.warn(n.getError(e)):console.warn(e,...t)}}function Vn(...t){t=mU(t);const e="THREE."+t.shift();{const n=t[0];n&&n.isStackTrace?console.error(n.getError(e)):console.error(e,...t)}}function wy(...t){const e=t.join(" ");e in tN||(tN[e]=!0,ln(...t))}function Lce(t,e,n){return new Promise(function(r,i){function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:r()}}setTimeout(s,n)})}const Ice={[j1]:B1,[z1]:W1,[V1]:G1,[qd]:H1,[B1]:j1,[W1]:z1,[G1]:V1,[H1]:qd};class pf{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const s=i.indexOf(n);s!==-1&&i.splice(s,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let s=0,a=i.length;s<a;s++)i[s].call(this,e);e.target=null}}}const ui=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],N_=Math.PI/180,MS=180/Math.PI;function Hp(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(ui[t&255]+ui[t>>8&255]+ui[t>>16&255]+ui[t>>24&255]+"-"+ui[e&255]+ui[e>>8&255]+"-"+ui[e>>16&15|64]+ui[e>>24&255]+"-"+ui[n&63|128]+ui[n>>8&255]+"-"+ui[n>>16&255]+ui[n>>24&255]+ui[r&255]+ui[r>>8&255]+ui[r>>16&255]+ui[r>>24&255]).toLowerCase()}function Dn(t,e,n){return Math.max(e,Math.min(n,t))}function Oce(t,e){return(t%e+e)%e}function D_(t,e,n){return(1-n)*t+n*e}function ph(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Ii(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}class $n{constructor(e=0,n=0){$n.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Dn(this.x,e.x,n.x),this.y=Dn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=Dn(this.x,e,n),this.y=Dn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Dn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Dn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),s=this.x-e.x,a=this.y-e.y;return this.x=s*r-a*i+e.x,this.y=s*i+a*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class mf{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,s,a,o){let c=r[i+0],u=r[i+1],f=r[i+2],h=r[i+3],m=s[a+0],g=s[a+1],v=s[a+2],w=s[a+3];if(h!==w||c!==m||u!==g||f!==v){let b=c*m+u*g+f*v+h*w;b<0&&(m=-m,g=-g,v=-v,w=-w,b=-b);let _=1-o;if(b<.9995){const E=Math.acos(b),M=Math.sin(E);_=Math.sin(_*E)/M,o=Math.sin(o*E)/M,c=c*_+m*o,u=u*_+g*o,f=f*_+v*o,h=h*_+w*o}else{c=c*_+m*o,u=u*_+g*o,f=f*_+v*o,h=h*_+w*o;const E=1/Math.sqrt(c*c+u*u+f*f+h*h);c*=E,u*=E,f*=E,h*=E}}e[n]=c,e[n+1]=u,e[n+2]=f,e[n+3]=h}static multiplyQuaternionsFlat(e,n,r,i,s,a){const o=r[i],c=r[i+1],u=r[i+2],f=r[i+3],h=s[a],m=s[a+1],g=s[a+2],v=s[a+3];return e[n]=o*v+f*h+c*g-u*m,e[n+1]=c*v+f*m+u*h-o*g,e[n+2]=u*v+f*g+o*m-c*h,e[n+3]=f*v-o*h-c*m-u*g,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,c=Math.sin,u=o(r/2),f=o(i/2),h=o(s/2),m=c(r/2),g=c(i/2),v=c(s/2);switch(a){case"XYZ":this._x=m*f*h+u*g*v,this._y=u*g*h-m*f*v,this._z=u*f*v+m*g*h,this._w=u*f*h-m*g*v;break;case"YXZ":this._x=m*f*h+u*g*v,this._y=u*g*h-m*f*v,this._z=u*f*v-m*g*h,this._w=u*f*h+m*g*v;break;case"ZXY":this._x=m*f*h-u*g*v,this._y=u*g*h+m*f*v,this._z=u*f*v+m*g*h,this._w=u*f*h-m*g*v;break;case"ZYX":this._x=m*f*h-u*g*v,this._y=u*g*h+m*f*v,this._z=u*f*v-m*g*h,this._w=u*f*h+m*g*v;break;case"YZX":this._x=m*f*h+u*g*v,this._y=u*g*h+m*f*v,this._z=u*f*v-m*g*h,this._w=u*f*h-m*g*v;break;case"XZY":this._x=m*f*h-u*g*v,this._y=u*g*h-m*f*v,this._z=u*f*v+m*g*h,this._w=u*f*h+m*g*v;break;default:ln("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],s=n[8],a=n[1],o=n[5],c=n[9],u=n[2],f=n[6],h=n[10],m=r+o+h;if(m>0){const g=.5/Math.sqrt(m+1);this._w=.25/g,this._x=(f-c)*g,this._y=(s-u)*g,this._z=(a-i)*g}else if(r>o&&r>h){const g=2*Math.sqrt(1+r-o-h);this._w=(f-c)/g,this._x=.25*g,this._y=(i+a)/g,this._z=(s+u)/g}else if(o>h){const g=2*Math.sqrt(1+o-r-h);this._w=(s-u)/g,this._x=(i+a)/g,this._y=.25*g,this._z=(c+f)/g}else{const g=2*Math.sqrt(1+h-r-o);this._w=(a-i)/g,this._x=(s+u)/g,this._y=(c+f)/g,this._z=.25*g}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Dn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,s=e._z,a=e._w,o=n._x,c=n._y,u=n._z,f=n._w;return this._x=r*f+a*o+i*u-s*c,this._y=i*f+a*c+s*o-r*u,this._z=s*f+a*u+r*c-i*o,this._w=a*f-r*o-i*c-s*u,this._onChangeCallback(),this}slerp(e,n){let r=e._x,i=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(r=-r,i=-i,s=-s,a=-a,o=-o);let c=1-n;if(o<.9995){const u=Math.acos(o),f=Math.sin(u);c=Math.sin(c*u)/f,n=Math.sin(n*u)/f,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+s*n,this._w=this._w*c+a*n,this._onChangeCallback()}else this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+s*n,this._w=this._w*c+a*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(n),s*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Oe{constructor(e=0,n=0,r=0){Oe.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(rN.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(rN.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[3]*r+s[6]*i,this.y=s[1]*n+s[4]*r+s[7]*i,this.z=s[2]*n+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=e.elements,a=1/(s[3]*n+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*n+s[4]*r+s[8]*i+s[12])*a,this.y=(s[1]*n+s[5]*r+s[9]*i+s[13])*a,this.z=(s[2]*n+s[6]*r+s[10]*i+s[14])*a,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,s=e.x,a=e.y,o=e.z,c=e.w,u=2*(a*i-o*r),f=2*(o*n-s*i),h=2*(s*r-a*n);return this.x=n+c*u+a*h-o*f,this.y=r+c*f+o*u-s*h,this.z=i+c*h+s*f-a*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i,this.y=s[1]*n+s[5]*r+s[9]*i,this.z=s[2]*n+s[6]*r+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Dn(this.x,e.x,n.x),this.y=Dn(this.y,e.y,n.y),this.z=Dn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=Dn(this.x,e,n),this.y=Dn(this.y,e,n),this.z=Dn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Dn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,s=e.z,a=n.x,o=n.y,c=n.z;return this.x=i*c-s*o,this.y=s*a-r*c,this.z=r*o-i*a,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return L_.copy(this).projectOnVector(e),this.sub(L_)}reflect(e){return this.sub(L_.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Dn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,r=Math.sqrt(1-n*n);return this.x=r*Math.cos(e),this.y=n,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const L_=new Oe,rN=new mf;class pn{constructor(e,n,r,i,s,a,o,c,u){pn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,a,o,c,u)}set(e,n,r,i,s,a,o,c,u){const f=this.elements;return f[0]=e,f[1]=i,f[2]=o,f[3]=n,f[4]=s,f[5]=c,f[6]=r,f[7]=a,f[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,a=r[0],o=r[3],c=r[6],u=r[1],f=r[4],h=r[7],m=r[2],g=r[5],v=r[8],w=i[0],b=i[3],_=i[6],E=i[1],M=i[4],T=i[7],R=i[2],A=i[5],P=i[8];return s[0]=a*w+o*E+c*R,s[3]=a*b+o*M+c*A,s[6]=a*_+o*T+c*P,s[1]=u*w+f*E+h*R,s[4]=u*b+f*M+h*A,s[7]=u*_+f*T+h*P,s[2]=m*w+g*E+v*R,s[5]=m*b+g*M+v*A,s[8]=m*_+g*T+v*P,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],u=e[7],f=e[8];return n*a*f-n*o*u-r*s*f+r*o*c+i*s*u-i*a*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],u=e[7],f=e[8],h=f*a-o*u,m=o*c-f*s,g=u*s-a*c,v=n*h+r*m+i*g;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const w=1/v;return e[0]=h*w,e[1]=(i*u-f*r)*w,e[2]=(o*r-i*a)*w,e[3]=m*w,e[4]=(f*n-i*c)*w,e[5]=(i*s-o*n)*w,e[6]=g*w,e[7]=(r*c-u*n)*w,e[8]=(a*n-r*s)*w,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,s,a,o){const c=Math.cos(s),u=Math.sin(s);return this.set(r*c,r*u,-r*(c*a+u*o)+a+e,-i*u,i*c,-i*(-u*a+c*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(I_.makeScale(e,n)),this}rotate(e){return this.premultiply(I_.makeRotation(-e)),this}translate(e,n){return this.premultiply(I_.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,r,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<9;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<9;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const I_=new pn,iN=new pn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),sN=new pn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Fce(){const t={enabled:!0,workingColorSpace:iu,spaces:{},convert:function(i,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===qn&&(i.r=No(i.r),i.g=No(i.g),i.b=No(i.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===qn&&(i.r=Dd(i.r),i.g=Dd(i.g),i.b=Dd(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===wl?xy:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,a){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return wy("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return wy("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,s)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[iu]:{primaries:e,whitePoint:r,transfer:xy,toXYZ:iN,fromXYZ:sN,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:ws},outputColorSpaceConfig:{drawingBufferColorSpace:ws}},[ws]:{primaries:e,whitePoint:r,transfer:qn,toXYZ:iN,fromXYZ:sN,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:ws}}}),t}const jn=Fce();function No(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Dd(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let ed;class Uce{static getDataURL(e,n="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let r;if(e instanceof HTMLCanvasElement)r=e;else{ed===void 0&&(ed=_y("canvas")),ed.width=e.width,ed.height=e.height;const i=ed.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=ed}return r.toDataURL(n)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=_y("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let a=0;a<s.length;a++)s[a]=No(s[a]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(No(n[r]/255)*255):n[r]=No(n[r]);return{data:n,width:e.width,height:e.height}}else return ln("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let jce=0;class tM{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:jce++}),this.uuid=Hp(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):typeof VideoFrame<"u"&&n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?s.push(O_(i[a].image)):s.push(O_(i[a]))}else s=O_(i);r.url=s}return n||(e.images[this.uuid]=r),r}}function O_(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Uce.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(ln("Texture: Unable to serialize Texture."),{})}let Bce=0;const F_=new Oe;class Ti extends pf{constructor(e=Ti.DEFAULT_IMAGE,n=Ti.DEFAULT_MAPPING,r=Mo,i=Mo,s=yi,a=Fc,o=ta,c=Es,u=Ti.DEFAULT_ANISOTROPY,f=wl){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Bce++}),this.uuid=Hp(),this.name="",this.source=new tM(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=u,this.format=o,this.internalFormat=null,this.type=c,this.offset=new $n(0,0),this.repeat=new $n(1,1),this.center=new $n(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new pn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=f,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(F_).x}get height(){return this.source.getSize(F_).y}get depth(){return this.source.getSize(F_).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const n in e){const r=e[n];if(r===void 0){ln(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){ln(`Texture.setValues(): property '${n}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==oU)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case $1:e.x=e.x-Math.floor(e.x);break;case Mo:e.x=e.x<0?0:1;break;case Y1:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case $1:e.y=e.y-Math.floor(e.y);break;case Mo:e.y=e.y<0?0:1;break;case Y1:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Ti.DEFAULT_IMAGE=null;Ti.DEFAULT_MAPPING=oU;Ti.DEFAULT_ANISOTROPY=1;class yr{constructor(e=0,n=0,r=0,i=1){yr.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i+a[12]*s,this.y=a[1]*n+a[5]*r+a[9]*i+a[13]*s,this.z=a[2]*n+a[6]*r+a[10]*i+a[14]*s,this.w=a[3]*n+a[7]*r+a[11]*i+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,s;const c=e.elements,u=c[0],f=c[4],h=c[8],m=c[1],g=c[5],v=c[9],w=c[2],b=c[6],_=c[10];if(Math.abs(f-m)<.01&&Math.abs(h-w)<.01&&Math.abs(v-b)<.01){if(Math.abs(f+m)<.1&&Math.abs(h+w)<.1&&Math.abs(v+b)<.1&&Math.abs(u+g+_-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const M=(u+1)/2,T=(g+1)/2,R=(_+1)/2,A=(f+m)/4,P=(h+w)/4,k=(v+b)/4;return M>T&&M>R?M<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(M),i=A/r,s=P/r):T>R?T<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(T),r=A/i,s=k/i):R<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(R),r=P/s,i=k/s),this.set(r,i,s,n),this}let E=Math.sqrt((b-v)*(b-v)+(h-w)*(h-w)+(m-f)*(m-f));return Math.abs(E)<.001&&(E=1),this.x=(b-v)/E,this.y=(h-w)/E,this.z=(m-f)/E,this.w=Math.acos((u+g+_-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Dn(this.x,e.x,n.x),this.y=Dn(this.y,e.y,n.y),this.z=Dn(this.z,e.z,n.z),this.w=Dn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=Dn(this.x,e,n),this.y=Dn(this.y,e,n),this.z=Dn(this.z,e,n),this.w=Dn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Dn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class zce extends pf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:yi,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},r),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=r.depth,this.scissor=new yr(0,0,e,n),this.scissorTest=!1,this.viewport=new yr(0,0,e,n),this.textures=[];const i={width:e,height:n,depth:r.depth},s=new Ti(i),a=r.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:yi,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(n)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,n,r=1){if(this.width!==e||this.height!==n||this.depth!==r){this.width=e,this.height=n,this.depth=r;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const i=Object.assign({},e.textures[n].image);this.textures[n].source=new tM(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ja extends zce{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class gU extends Ti{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=ni,this.minFilter=ni,this.wrapR=Mo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Vce extends Ti{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=ni,this.minFilter=ni,this.wrapR=Mo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Nr{constructor(e,n,r,i,s,a,o,c,u,f,h,m,g,v,w,b){Nr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,a,o,c,u,f,h,m,g,v,w,b)}set(e,n,r,i,s,a,o,c,u,f,h,m,g,v,w,b){const _=this.elements;return _[0]=e,_[4]=n,_[8]=r,_[12]=i,_[1]=s,_[5]=a,_[9]=o,_[13]=c,_[2]=u,_[6]=f,_[10]=h,_[14]=m,_[3]=g,_[7]=v,_[11]=w,_[15]=b,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Nr().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,r){return this.determinant()===0?(e.set(1,0,0),n.set(0,1,0),r.set(0,0,1),this):(e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this)}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const n=this.elements,r=e.elements,i=1/td.setFromMatrixColumn(e,0).length(),s=1/td.setFromMatrixColumn(e,1).length(),a=1/td.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*s,n[5]=r[5]*s,n[6]=r[6]*s,n[7]=0,n[8]=r[8]*a,n[9]=r[9]*a,n[10]=r[10]*a,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,s=e.z,a=Math.cos(r),o=Math.sin(r),c=Math.cos(i),u=Math.sin(i),f=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const m=a*f,g=a*h,v=o*f,w=o*h;n[0]=c*f,n[4]=-c*h,n[8]=u,n[1]=g+v*u,n[5]=m-w*u,n[9]=-o*c,n[2]=w-m*u,n[6]=v+g*u,n[10]=a*c}else if(e.order==="YXZ"){const m=c*f,g=c*h,v=u*f,w=u*h;n[0]=m+w*o,n[4]=v*o-g,n[8]=a*u,n[1]=a*h,n[5]=a*f,n[9]=-o,n[2]=g*o-v,n[6]=w+m*o,n[10]=a*c}else if(e.order==="ZXY"){const m=c*f,g=c*h,v=u*f,w=u*h;n[0]=m-w*o,n[4]=-a*h,n[8]=v+g*o,n[1]=g+v*o,n[5]=a*f,n[9]=w-m*o,n[2]=-a*u,n[6]=o,n[10]=a*c}else if(e.order==="ZYX"){const m=a*f,g=a*h,v=o*f,w=o*h;n[0]=c*f,n[4]=v*u-g,n[8]=m*u+w,n[1]=c*h,n[5]=w*u+m,n[9]=g*u-v,n[2]=-u,n[6]=o*c,n[10]=a*c}else if(e.order==="YZX"){const m=a*c,g=a*u,v=o*c,w=o*u;n[0]=c*f,n[4]=w-m*h,n[8]=v*h+g,n[1]=h,n[5]=a*f,n[9]=-o*f,n[2]=-u*f,n[6]=g*h+v,n[10]=m-w*h}else if(e.order==="XZY"){const m=a*c,g=a*u,v=o*c,w=o*u;n[0]=c*f,n[4]=-h,n[8]=u*f,n[1]=m*h+w,n[5]=a*f,n[9]=g*h-v,n[2]=v*h-g,n[6]=o*f,n[10]=w*h+m}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Hce,e,Wce)}lookAt(e,n,r){const i=this.elements;return Qi.subVectors(e,n),Qi.lengthSq()===0&&(Qi.z=1),Qi.normalize(),ul.crossVectors(r,Qi),ul.lengthSq()===0&&(Math.abs(r.z)===1?Qi.x+=1e-4:Qi.z+=1e-4,Qi.normalize(),ul.crossVectors(r,Qi)),ul.normalize(),Ng.crossVectors(Qi,ul),i[0]=ul.x,i[4]=Ng.x,i[8]=Qi.x,i[1]=ul.y,i[5]=Ng.y,i[9]=Qi.y,i[2]=ul.z,i[6]=Ng.z,i[10]=Qi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,a=r[0],o=r[4],c=r[8],u=r[12],f=r[1],h=r[5],m=r[9],g=r[13],v=r[2],w=r[6],b=r[10],_=r[14],E=r[3],M=r[7],T=r[11],R=r[15],A=i[0],P=i[4],k=i[8],N=i[12],B=i[1],L=i[5],z=i[9],I=i[13],V=i[2],W=i[6],X=i[10],J=i[14],F=i[3],G=i[7],Y=i[11],H=i[15];return s[0]=a*A+o*B+c*V+u*F,s[4]=a*P+o*L+c*W+u*G,s[8]=a*k+o*z+c*X+u*Y,s[12]=a*N+o*I+c*J+u*H,s[1]=f*A+h*B+m*V+g*F,s[5]=f*P+h*L+m*W+g*G,s[9]=f*k+h*z+m*X+g*Y,s[13]=f*N+h*I+m*J+g*H,s[2]=v*A+w*B+b*V+_*F,s[6]=v*P+w*L+b*W+_*G,s[10]=v*k+w*z+b*X+_*Y,s[14]=v*N+w*I+b*J+_*H,s[3]=E*A+M*B+T*V+R*F,s[7]=E*P+M*L+T*W+R*G,s[11]=E*k+M*z+T*X+R*Y,s[15]=E*N+M*I+T*J+R*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],s=e[12],a=e[1],o=e[5],c=e[9],u=e[13],f=e[2],h=e[6],m=e[10],g=e[14],v=e[3],w=e[7],b=e[11],_=e[15],E=c*g-u*m,M=o*g-u*h,T=o*m-c*h,R=a*g-u*f,A=a*m-c*f,P=a*h-o*f;return n*(w*E-b*M+_*T)-r*(v*E-b*R+_*A)+i*(v*M-w*R+_*P)-s*(v*T-w*A+b*P)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],u=e[7],f=e[8],h=e[9],m=e[10],g=e[11],v=e[12],w=e[13],b=e[14],_=e[15],E=n*o-r*a,M=n*c-i*a,T=n*u-s*a,R=r*c-i*o,A=r*u-s*o,P=i*u-s*c,k=f*w-h*v,N=f*b-m*v,B=f*_-g*v,L=h*b-m*w,z=h*_-g*w,I=m*_-g*b,V=E*I-M*z+T*L+R*B-A*N+P*k;if(V===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const W=1/V;return e[0]=(o*I-c*z+u*L)*W,e[1]=(i*z-r*I-s*L)*W,e[2]=(w*P-b*A+_*R)*W,e[3]=(m*A-h*P-g*R)*W,e[4]=(c*B-a*I-u*N)*W,e[5]=(n*I-i*B+s*N)*W,e[6]=(b*T-v*P-_*M)*W,e[7]=(f*P-m*T+g*M)*W,e[8]=(a*z-o*B+u*k)*W,e[9]=(r*B-n*z-s*k)*W,e[10]=(v*A-w*T+_*E)*W,e[11]=(h*T-f*A-g*E)*W,e[12]=(o*N-a*L-c*k)*W,e[13]=(n*L-r*N+i*k)*W,e[14]=(w*M-v*R-b*E)*W,e[15]=(f*R-h*M+m*E)*W,this}scale(e){const n=this.elements,r=e.x,i=e.y,s=e.z;return n[0]*=r,n[4]*=i,n[8]*=s,n[1]*=r,n[5]*=i,n[9]*=s,n[2]*=r,n[6]*=i,n[10]*=s,n[3]*=r,n[7]*=i,n[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),s=1-r,a=e.x,o=e.y,c=e.z,u=s*a,f=s*o;return this.set(u*a+r,u*o-i*c,u*c+i*o,0,u*o+i*c,f*o+r,f*c-i*a,0,u*c-i*o,f*c+i*a,s*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,s,a){return this.set(1,r,s,0,e,1,a,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,a=n._y,o=n._z,c=n._w,u=s+s,f=a+a,h=o+o,m=s*u,g=s*f,v=s*h,w=a*f,b=a*h,_=o*h,E=c*u,M=c*f,T=c*h,R=r.x,A=r.y,P=r.z;return i[0]=(1-(w+_))*R,i[1]=(g+T)*R,i[2]=(v-M)*R,i[3]=0,i[4]=(g-T)*A,i[5]=(1-(m+_))*A,i[6]=(b+E)*A,i[7]=0,i[8]=(v+M)*P,i[9]=(b-E)*P,i[10]=(1-(m+w))*P,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];const s=this.determinant();if(s===0)return r.set(1,1,1),n.identity(),this;let a=td.set(i[0],i[1],i[2]).length();const o=td.set(i[4],i[5],i[6]).length(),c=td.set(i[8],i[9],i[10]).length();s<0&&(a=-a),Gs.copy(this);const u=1/a,f=1/o,h=1/c;return Gs.elements[0]*=u,Gs.elements[1]*=u,Gs.elements[2]*=u,Gs.elements[4]*=f,Gs.elements[5]*=f,Gs.elements[6]*=f,Gs.elements[8]*=h,Gs.elements[9]*=h,Gs.elements[10]*=h,n.setFromRotationMatrix(Gs),r.x=a,r.y=o,r.z=c,this}makePerspective(e,n,r,i,s,a,o=La,c=!1){const u=this.elements,f=2*s/(n-e),h=2*s/(r-i),m=(n+e)/(n-e),g=(r+i)/(r-i);let v,w;if(c)v=s/(a-s),w=a*s/(a-s);else if(o===La)v=-(a+s)/(a-s),w=-2*a*s/(a-s);else if(o===by)v=-a/(a-s),w=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return u[0]=f,u[4]=0,u[8]=m,u[12]=0,u[1]=0,u[5]=h,u[9]=g,u[13]=0,u[2]=0,u[6]=0,u[10]=v,u[14]=w,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,s,a,o=La,c=!1){const u=this.elements,f=2/(n-e),h=2/(r-i),m=-(n+e)/(n-e),g=-(r+i)/(r-i);let v,w;if(c)v=1/(a-s),w=a/(a-s);else if(o===La)v=-2/(a-s),w=-(a+s)/(a-s);else if(o===by)v=-1/(a-s),w=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return u[0]=f,u[4]=0,u[8]=0,u[12]=m,u[1]=0,u[5]=h,u[9]=0,u[13]=g,u[2]=0,u[6]=0,u[10]=v,u[14]=w,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const td=new Oe,Gs=new Nr,Hce=new Oe(0,0,0),Wce=new Oe(1,1,1),ul=new Oe,Ng=new Oe,Qi=new Oe,aN=new Nr,oN=new mf;let su=class yU{constructor(e=0,n=0,r=0,i=yU.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,s=i[0],a=i[4],o=i[8],c=i[1],u=i[5],f=i[9],h=i[2],m=i[6],g=i[10];switch(n){case"XYZ":this._y=Math.asin(Dn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-f,g),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(m,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Dn(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(o,g),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Dn(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-h,g),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Dn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(m,g),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,u));break;case"YZX":this._z=Math.asin(Dn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-f,u),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,g));break;case"XZY":this._z=Math.asin(-Dn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(m,u),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-f,g),this._y=0);break;default:ln("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return aN.makeRotationFromQuaternion(e),this.setFromRotationMatrix(aN,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return oN.setFromEuler(this),this.setFromQuaternion(oN,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};su.DEFAULT_ORDER="XYZ";class vU{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Gce=0;const lN=new Oe,nd=new mf,ho=new Nr,Dg=new Oe,mh=new Oe,$ce=new Oe,Yce=new mf,cN=new Oe(1,0,0),uN=new Oe(0,1,0),dN=new Oe(0,0,1),fN={type:"added"},qce={type:"removed"},rd={type:"childadded",child:null},U_={type:"childremoved",child:null};class ls extends pf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Gce++}),this.uuid=Hp(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ls.DEFAULT_UP.clone();const e=new Oe,n=new su,r=new mf,i=new Oe(1,1,1);function s(){r.setFromEuler(n,!1)}function a(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),r._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Nr},normalMatrix:{value:new pn}}),this.matrix=new Nr,this.matrixWorld=new Nr,this.matrixAutoUpdate=ls.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ls.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new vU,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,n){this.quaternion.setFromAxisAngle(e,n)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,n){return nd.setFromAxisAngle(e,n),this.quaternion.multiply(nd),this}rotateOnWorldAxis(e,n){return nd.setFromAxisAngle(e,n),this.quaternion.premultiply(nd),this}rotateX(e){return this.rotateOnAxis(cN,e)}rotateY(e){return this.rotateOnAxis(uN,e)}rotateZ(e){return this.rotateOnAxis(dN,e)}translateOnAxis(e,n){return lN.copy(e).applyQuaternion(this.quaternion),this.position.add(lN.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(cN,e)}translateY(e){return this.translateOnAxis(uN,e)}translateZ(e){return this.translateOnAxis(dN,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ho.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?Dg.copy(e):Dg.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),mh.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ho.lookAt(mh,Dg,this.up):ho.lookAt(Dg,mh,this.up),this.quaternion.setFromRotationMatrix(ho),i&&(ho.extractRotation(i.matrixWorld),nd.setFromRotationMatrix(ho),this.quaternion.premultiply(nd.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Vn("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(fN),rd.child=e,this.dispatchEvent(rd),rd.child=null):Vn("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(qce),U_.child=e,this.dispatchEvent(U_),U_.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ho.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ho.multiply(e.parent.matrixWorld)),e.applyMatrix4(ho),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(fN),rd.child=e,this.dispatchEvent(rd),rd.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const a=this.children[r].getObjectByProperty(e,n);if(a!==void 0)return a}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mh,e,$ce),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mh,Yce,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const n=e.x,r=e.y,i=e.z,s=this.matrix.elements;s[12]+=n-s[0]*n-s[4]*r-s[8]*i,s[13]+=r-s[1]*n-s[5]*r-s[9]*i,s[14]+=i-s[2]*n-s[6]*r-s[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let u=0,f=c.length;u<f;u++){const h=c[u];s(e.shapes,h)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,u=this.material.length;c<u;c++)o.push(s(e.materials,this.material[c]));i.material=o}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];i.animations.push(s(e.animations,c))}}if(n){const o=a(e.geometries),c=a(e.materials),u=a(e.textures),f=a(e.images),h=a(e.shapes),m=a(e.skeletons),g=a(e.animations),v=a(e.nodes);o.length>0&&(r.geometries=o),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),f.length>0&&(r.images=f),h.length>0&&(r.shapes=h),m.length>0&&(r.skeletons=m),g.length>0&&(r.animations=g),v.length>0&&(r.nodes=v)}return r.object=i,r;function a(o){const c=[];for(const u in o){const f=o[u];delete f.metadata,c.push(f)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}ls.DEFAULT_UP=new Oe(0,1,0);ls.DEFAULT_MATRIX_AUTO_UPDATE=!0;ls.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Lg extends ls{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Xce={type:"move"};class j_{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Lg,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Lg,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Oe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Oe),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Lg,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Oe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Oe),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,s=null,a=null;const o=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){a=!0;for(const w of e.hand.values()){const b=n.getJointPose(w,r),_=this._getHandJoint(u,w);b!==null&&(_.matrix.fromArray(b.transform.matrix),_.matrix.decompose(_.position,_.rotation,_.scale),_.matrixWorldNeedsUpdate=!0,_.jointRadius=b.radius),_.visible=b!==null}const f=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],m=f.position.distanceTo(h.position),g=.02,v=.005;u.inputState.pinching&&m>g+v?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=g-v&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Xce)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=s!==null),u!==null&&(u.visible=a!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Lg;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}const xU={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},dl={h:0,s:0,l:0},Ig={h:0,s:0,l:0};function B_(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}class Zn{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=ws){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,jn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=jn.workingColorSpace){return this.r=e,this.g=n,this.b=r,jn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=jn.workingColorSpace){if(e=Oce(e,1),n=Dn(n,0,1),r=Dn(r,0,1),n===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+n):r+n-r*n,a=2*r-s;this.r=B_(a,s,e+1/3),this.g=B_(a,s,e),this.b=B_(a,s,e-1/3)}return jn.colorSpaceToWorking(this,i),this}setStyle(e,n=ws){function r(s){s!==void 0&&parseFloat(s)<1&&ln("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:ln("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(a===6)return this.setHex(parseInt(s,16),n);ln("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=ws){const r=xU[e.toLowerCase()];return r!==void 0?this.setHex(r,n):ln("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=No(e.r),this.g=No(e.g),this.b=No(e.b),this}copyLinearToSRGB(e){return this.r=Dd(e.r),this.g=Dd(e.g),this.b=Dd(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ws){return jn.workingToColorSpace(di.copy(this),e),Math.round(Dn(di.r*255,0,255))*65536+Math.round(Dn(di.g*255,0,255))*256+Math.round(Dn(di.b*255,0,255))}getHexString(e=ws){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=jn.workingColorSpace){jn.workingToColorSpace(di.copy(this),n);const r=di.r,i=di.g,s=di.b,a=Math.max(r,i,s),o=Math.min(r,i,s);let c,u;const f=(o+a)/2;if(o===a)c=0,u=0;else{const h=a-o;switch(u=f<=.5?h/(a+o):h/(2-a-o),a){case r:c=(i-s)/h+(i<s?6:0);break;case i:c=(s-r)/h+2;break;case s:c=(r-i)/h+4;break}c/=6}return e.h=c,e.s=u,e.l=f,e}getRGB(e,n=jn.workingColorSpace){return jn.workingToColorSpace(di.copy(this),n),e.r=di.r,e.g=di.g,e.b=di.b,e}getStyle(e=ws){jn.workingToColorSpace(di.copy(this),e);const n=di.r,r=di.g,i=di.b;return e!==ws?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(dl),this.setHSL(dl.h+e,dl.s+n,dl.l+r)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this}lerpColors(e,n,r){return this.r=e.r+(n.r-e.r)*r,this.g=e.g+(n.g-e.g)*r,this.b=e.b+(n.b-e.b)*r,this}lerpHSL(e,n){this.getHSL(dl),e.getHSL(Ig);const r=D_(dl.h,Ig.h,n),i=D_(dl.s,Ig.s,n),s=D_(dl.l,Ig.l,n);return this.setHSL(r,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,s=e.elements;return this.r=s[0]*n+s[3]*r+s[6]*i,this.g=s[1]*n+s[4]*r+s[7]*i,this.b=s[2]*n+s[5]*r+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const di=new Zn;Zn.NAMES=xU;class Kce extends ls{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new su,this.environmentIntensity=1,this.environmentRotation=new su,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const n=super.toJSON(e);return this.fog!==null&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(n.object.backgroundIntensity=this.backgroundIntensity),n.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(n.object.environmentIntensity=this.environmentIntensity),n.object.environmentRotation=this.environmentRotation.toArray(),n}}const $s=new Oe,po=new Oe,z_=new Oe,mo=new Oe,id=new Oe,sd=new Oe,hN=new Oe,V_=new Oe,H_=new Oe,W_=new Oe,G_=new yr,$_=new yr,Y_=new yr;let gh=class xd{constructor(e=new Oe,n=new Oe,r=new Oe){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),$s.subVectors(e,n),i.cross($s);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,n,r,i,s){$s.subVectors(i,n),po.subVectors(r,n),z_.subVectors(e,n);const a=$s.dot($s),o=$s.dot(po),c=$s.dot(z_),u=po.dot(po),f=po.dot(z_),h=a*u-o*o;if(h===0)return s.set(0,0,0),null;const m=1/h,g=(u*c-o*f)*m,v=(a*f-o*c)*m;return s.set(1-g-v,v,g)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,mo)===null?!1:mo.x>=0&&mo.y>=0&&mo.x+mo.y<=1}static getInterpolation(e,n,r,i,s,a,o,c){return this.getBarycoord(e,n,r,i,mo)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,mo.x),c.addScaledVector(a,mo.y),c.addScaledVector(o,mo.z),c)}static getInterpolatedAttribute(e,n,r,i,s,a){return G_.setScalar(0),$_.setScalar(0),Y_.setScalar(0),G_.fromBufferAttribute(e,n),$_.fromBufferAttribute(e,r),Y_.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(G_,s.x),a.addScaledVector($_,s.y),a.addScaledVector(Y_,s.z),a}static isFrontFacing(e,n,r,i){return $s.subVectors(r,n),po.subVectors(e,n),$s.cross(po).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return $s.subVectors(this.c,this.b),po.subVectors(this.a,this.b),$s.cross(po).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return xd.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return xd.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,s){return xd.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return xd.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return xd.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,s=this.c;let a,o;id.subVectors(i,r),sd.subVectors(s,r),V_.subVectors(e,r);const c=id.dot(V_),u=sd.dot(V_);if(c<=0&&u<=0)return n.copy(r);H_.subVectors(e,i);const f=id.dot(H_),h=sd.dot(H_);if(f>=0&&h<=f)return n.copy(i);const m=c*h-f*u;if(m<=0&&c>=0&&f<=0)return a=c/(c-f),n.copy(r).addScaledVector(id,a);W_.subVectors(e,s);const g=id.dot(W_),v=sd.dot(W_);if(v>=0&&g<=v)return n.copy(s);const w=g*u-c*v;if(w<=0&&u>=0&&v<=0)return o=u/(u-v),n.copy(r).addScaledVector(sd,o);const b=f*v-g*h;if(b<=0&&h-f>=0&&g-v>=0)return hN.subVectors(s,i),o=(h-f)/(h-f+(g-v)),n.copy(i).addScaledVector(hN,o);const _=1/(b+w+m);return a=w*_,o=m*_,n.copy(r).addScaledVector(id,a).addScaledVector(sd,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};class Wp{constructor(e=new Oe(1/0,1/0,1/0),n=new Oe(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(Ys.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Ys.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=Ys.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const s=r.getAttribute("position");if(n===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Ys):Ys.fromBufferAttribute(s,a),Ys.applyMatrix4(e.matrixWorld),this.expandByPoint(Ys);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Og.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Og.copy(r.boundingBox)),Og.applyMatrix4(e.matrixWorld),this.union(Og)}const i=e.children;for(let s=0,a=i.length;s<a;s++)this.expandByObject(i[s],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ys),Ys.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(yh),Fg.subVectors(this.max,yh),ad.subVectors(e.a,yh),od.subVectors(e.b,yh),ld.subVectors(e.c,yh),fl.subVectors(od,ad),hl.subVectors(ld,od),yc.subVectors(ad,ld);let n=[0,-fl.z,fl.y,0,-hl.z,hl.y,0,-yc.z,yc.y,fl.z,0,-fl.x,hl.z,0,-hl.x,yc.z,0,-yc.x,-fl.y,fl.x,0,-hl.y,hl.x,0,-yc.y,yc.x,0];return!q_(n,ad,od,ld,Fg)||(n=[1,0,0,0,1,0,0,0,1],!q_(n,ad,od,ld,Fg))?!1:(Ug.crossVectors(fl,hl),n=[Ug.x,Ug.y,Ug.z],q_(n,ad,od,ld,Fg))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ys).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ys).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(go[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),go[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),go[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),go[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),go[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),go[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),go[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),go[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(go),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const go=[new Oe,new Oe,new Oe,new Oe,new Oe,new Oe,new Oe,new Oe],Ys=new Oe,Og=new Wp,ad=new Oe,od=new Oe,ld=new Oe,fl=new Oe,hl=new Oe,yc=new Oe,yh=new Oe,Fg=new Oe,Ug=new Oe,vc=new Oe;function q_(t,e,n,r,i){for(let s=0,a=t.length-3;s<=a;s+=3){vc.fromArray(t,s);const o=i.x*Math.abs(vc.x)+i.y*Math.abs(vc.y)+i.z*Math.abs(vc.z),c=e.dot(vc),u=n.dot(vc),f=r.dot(vc);if(Math.max(-Math.max(c,u,f),Math.min(c,u,f))>o)return!1}return!0}const Er=new Oe,jg=new $n;let Zce=0;class sa{constructor(e,n,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Zce++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=QP,this.updateRanges=[],this.gpuType=Da,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)jg.fromBufferAttribute(this,n),jg.applyMatrix3(e),this.setXY(n,jg.x,jg.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Er.fromBufferAttribute(this,n),Er.applyMatrix3(e),this.setXYZ(n,Er.x,Er.y,Er.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Er.fromBufferAttribute(this,n),Er.applyMatrix4(e),this.setXYZ(n,Er.x,Er.y,Er.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Er.fromBufferAttribute(this,n),Er.applyNormalMatrix(e),this.setXYZ(n,Er.x,Er.y,Er.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Er.fromBufferAttribute(this,n),Er.transformDirection(e),this.setXYZ(n,Er.x,Er.y,Er.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=ph(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Ii(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=ph(n,this.array)),n}setX(e,n){return this.normalized&&(n=Ii(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=ph(n,this.array)),n}setY(e,n){return this.normalized&&(n=Ii(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=ph(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Ii(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=ph(n,this.array)),n}setW(e,n){return this.normalized&&(n=Ii(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Ii(n,this.array),r=Ii(r,this.array)),this.array[e+0]=n,this.array[e+1]=r,this}setXYZ(e,n,r,i){return e*=this.itemSize,this.normalized&&(n=Ii(n,this.array),r=Ii(r,this.array),i=Ii(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e*=this.itemSize,this.normalized&&(n=Ii(n,this.array),r=Ii(r,this.array),i=Ii(i,this.array),s=Ii(s,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==QP&&(e.usage=this.usage),e}}class bU extends sa{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class _U extends sa{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Do extends sa{constructor(e,n,r){super(new Float32Array(e),n,r)}}const Jce=new Wp,vh=new Oe,X_=new Oe;class nM{constructor(e=new Oe,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):Jce.setFromPoints(e).getCenter(r);let i=0;for(let s=0,a=e.length;s<a;s++)i=Math.max(i,r.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;vh.subVectors(e,this.center);const n=vh.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(vh,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(X_.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(vh.copy(e.center).add(X_)),this.expandByPoint(vh.copy(e.center).sub(X_))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let Qce=0;const vs=new Nr,K_=new ls,cd=new Oe,es=new Wp,xh=new Wp,Yr=new Oe;class eo extends pf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Qce++}),this.uuid=Hp(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Nce(e)?_U:bU)(e,1):this.index=e,this}setIndirect(e,n=0){return this.indirect=e,this.indirectOffset=n,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new pn().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return vs.makeRotationFromQuaternion(e),this.applyMatrix4(vs),this}rotateX(e){return vs.makeRotationX(e),this.applyMatrix4(vs),this}rotateY(e){return vs.makeRotationY(e),this.applyMatrix4(vs),this}rotateZ(e){return vs.makeRotationZ(e),this.applyMatrix4(vs),this}translate(e,n,r){return vs.makeTranslation(e,n,r),this.applyMatrix4(vs),this}scale(e,n,r){return vs.makeScale(e,n,r),this.applyMatrix4(vs),this}lookAt(e){return K_.lookAt(e),K_.updateMatrix(),this.applyMatrix4(K_.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(cd).negate(),this.translate(cd.x,cd.y,cd.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,s=e.length;i<s;i++){const a=e[i];r.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Do(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const s=e[i];n.setXYZ(i,s.x,s.y,s.z||0)}e.length>n.count&&ln("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),n.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Wp);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Vn("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Oe(-1/0,-1/0,-1/0),new Oe(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const s=n[r];es.setFromBufferAttribute(s),this.morphTargetsRelative?(Yr.addVectors(this.boundingBox.min,es.min),this.boundingBox.expandByPoint(Yr),Yr.addVectors(this.boundingBox.max,es.max),this.boundingBox.expandByPoint(Yr)):(this.boundingBox.expandByPoint(es.min),this.boundingBox.expandByPoint(es.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Vn('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new nM);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Vn("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Oe,1/0);return}if(e){const r=this.boundingSphere.center;if(es.setFromBufferAttribute(e),n)for(let s=0,a=n.length;s<a;s++){const o=n[s];xh.setFromBufferAttribute(o),this.morphTargetsRelative?(Yr.addVectors(es.min,xh.min),es.expandByPoint(Yr),Yr.addVectors(es.max,xh.max),es.expandByPoint(Yr)):(es.expandByPoint(xh.min),es.expandByPoint(xh.max))}es.getCenter(r);let i=0;for(let s=0,a=e.count;s<a;s++)Yr.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Yr));if(n)for(let s=0,a=n.length;s<a;s++){const o=n[s],c=this.morphTargetsRelative;for(let u=0,f=o.count;u<f;u++)Yr.fromBufferAttribute(o,u),c&&(cd.fromBufferAttribute(e,u),Yr.add(cd)),i=Math.max(i,r.distanceToSquared(Yr))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Vn('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){Vn("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,s=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new sa(new Float32Array(4*r.count),4));const a=this.getAttribute("tangent"),o=[],c=[];for(let k=0;k<r.count;k++)o[k]=new Oe,c[k]=new Oe;const u=new Oe,f=new Oe,h=new Oe,m=new $n,g=new $n,v=new $n,w=new Oe,b=new Oe;function _(k,N,B){u.fromBufferAttribute(r,k),f.fromBufferAttribute(r,N),h.fromBufferAttribute(r,B),m.fromBufferAttribute(s,k),g.fromBufferAttribute(s,N),v.fromBufferAttribute(s,B),f.sub(u),h.sub(u),g.sub(m),v.sub(m);const L=1/(g.x*v.y-v.x*g.y);isFinite(L)&&(w.copy(f).multiplyScalar(v.y).addScaledVector(h,-g.y).multiplyScalar(L),b.copy(h).multiplyScalar(g.x).addScaledVector(f,-v.x).multiplyScalar(L),o[k].add(w),o[N].add(w),o[B].add(w),c[k].add(b),c[N].add(b),c[B].add(b))}let E=this.groups;E.length===0&&(E=[{start:0,count:e.count}]);for(let k=0,N=E.length;k<N;++k){const B=E[k],L=B.start,z=B.count;for(let I=L,V=L+z;I<V;I+=3)_(e.getX(I+0),e.getX(I+1),e.getX(I+2))}const M=new Oe,T=new Oe,R=new Oe,A=new Oe;function P(k){R.fromBufferAttribute(i,k),A.copy(R);const N=o[k];M.copy(N),M.sub(R.multiplyScalar(R.dot(N))).normalize(),T.crossVectors(A,N);const L=T.dot(c[k])<0?-1:1;a.setXYZW(k,M.x,M.y,M.z,L)}for(let k=0,N=E.length;k<N;++k){const B=E[k],L=B.start,z=B.count;for(let I=L,V=L+z;I<V;I+=3)P(e.getX(I+0)),P(e.getX(I+1)),P(e.getX(I+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new sa(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,g=r.count;m<g;m++)r.setXYZ(m,0,0,0);const i=new Oe,s=new Oe,a=new Oe,o=new Oe,c=new Oe,u=new Oe,f=new Oe,h=new Oe;if(e)for(let m=0,g=e.count;m<g;m+=3){const v=e.getX(m+0),w=e.getX(m+1),b=e.getX(m+2);i.fromBufferAttribute(n,v),s.fromBufferAttribute(n,w),a.fromBufferAttribute(n,b),f.subVectors(a,s),h.subVectors(i,s),f.cross(h),o.fromBufferAttribute(r,v),c.fromBufferAttribute(r,w),u.fromBufferAttribute(r,b),o.add(f),c.add(f),u.add(f),r.setXYZ(v,o.x,o.y,o.z),r.setXYZ(w,c.x,c.y,c.z),r.setXYZ(b,u.x,u.y,u.z)}else for(let m=0,g=n.count;m<g;m+=3)i.fromBufferAttribute(n,m+0),s.fromBufferAttribute(n,m+1),a.fromBufferAttribute(n,m+2),f.subVectors(a,s),h.subVectors(i,s),f.cross(h),r.setXYZ(m+0,f.x,f.y,f.z),r.setXYZ(m+1,f.x,f.y,f.z),r.setXYZ(m+2,f.x,f.y,f.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Yr.fromBufferAttribute(e,n),Yr.normalize(),e.setXYZ(n,Yr.x,Yr.y,Yr.z)}toNonIndexed(){function e(o,c){const u=o.array,f=o.itemSize,h=o.normalized,m=new u.constructor(c.length*f);let g=0,v=0;for(let w=0,b=c.length;w<b;w++){o.isInterleavedBufferAttribute?g=c[w]*o.data.stride+o.offset:g=c[w]*f;for(let _=0;_<f;_++)m[v++]=u[g++]}return new sa(m,f,h)}if(this.index===null)return ln("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new eo,r=this.index.array,i=this.attributes;for(const o in i){const c=i[o],u=e(c,r);n.setAttribute(o,u)}const s=this.morphAttributes;for(const o in s){const c=[],u=s[o];for(let f=0,h=u.length;f<h;f++){const m=u[f],g=e(m,r);c.push(g)}n.morphAttributes[o]=c}n.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const u=a[o];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],f=[];for(let h=0,m=u.length;h<m;h++){const g=u[h];f.push(g.toJSON(e.data))}f.length>0&&(i[c]=f,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const f=i[u];this.setAttribute(u,f.clone(n))}const s=e.morphAttributes;for(const u in s){const f=[],h=s[u];for(let m=0,g=h.length;m<g;m++)f.push(h[m].clone(n));this.morphAttributes[u]=f}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let u=0,f=a.length;u<f;u++){const h=a[u];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}let eue=0;class hv extends pf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:eue++}),this.uuid=Hp(),this.name="",this.type="Material",this.blending=Hc,this.side=Ol,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=F1,this.blendDst=U1,this.blendEquation=Tc,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Zn(0,0,0),this.blendAlpha=0,this.depthFunc=qd,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=JP,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Qu,this.stencilZFail=Qu,this.stencilZPass=Qu,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const r=e[n];if(r===void 0){ln(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){ln(`Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Hc&&(r.blending=this.blending),this.side!==Ol&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==F1&&(r.blendSrc=this.blendSrc),this.blendDst!==U1&&(r.blendDst=this.blendDst),this.blendEquation!==Tc&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==qd&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==JP&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Qu&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Qu&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Qu&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.allowOverride===!1&&(r.allowOverride=!1),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const a=[];for(const o in s){const c=s[o];delete c.metadata,a.push(c)}return a}if(n){const s=i(e.textures),a=i(e.images);s.length>0&&(r.textures=s),a.length>0&&(r.images=a)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=n[s].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}const yo=new Oe,Z_=new Oe,Bg=new Oe,pl=new Oe,J_=new Oe,zg=new Oe,Q_=new Oe;class tue{constructor(e=new Oe,n=new Oe(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,yo)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=yo.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(yo.copy(this.origin).addScaledVector(this.direction,n),yo.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){Z_.copy(e).add(n).multiplyScalar(.5),Bg.copy(n).sub(e).normalize(),pl.copy(this.origin).sub(Z_);const s=e.distanceTo(n)*.5,a=-this.direction.dot(Bg),o=pl.dot(this.direction),c=-pl.dot(Bg),u=pl.lengthSq(),f=Math.abs(1-a*a);let h,m,g,v;if(f>0)if(h=a*c-o,m=a*o-c,v=s*f,h>=0)if(m>=-v)if(m<=v){const w=1/f;h*=w,m*=w,g=h*(h+a*m+2*o)+m*(a*h+m+2*c)+u}else m=s,h=Math.max(0,-(a*m+o)),g=-h*h+m*(m+2*c)+u;else m=-s,h=Math.max(0,-(a*m+o)),g=-h*h+m*(m+2*c)+u;else m<=-v?(h=Math.max(0,-(-a*s+o)),m=h>0?-s:Math.min(Math.max(-s,-c),s),g=-h*h+m*(m+2*c)+u):m<=v?(h=0,m=Math.min(Math.max(-s,-c),s),g=m*(m+2*c)+u):(h=Math.max(0,-(a*s+o)),m=h>0?s:Math.min(Math.max(-s,-c),s),g=-h*h+m*(m+2*c)+u);else m=a>0?-s:s,h=Math.max(0,-(a*m+o)),g=-h*h+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(Z_).addScaledVector(Bg,m),g}intersectSphere(e,n){yo.subVectors(e.center,this.origin);const r=yo.dot(this.direction),i=yo.dot(yo)-r*r,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=r-a,c=r+a;return c<0?null:o<0?this.at(c,n):this.at(o,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,s,a,o,c;const u=1/this.direction.x,f=1/this.direction.y,h=1/this.direction.z,m=this.origin;return u>=0?(r=(e.min.x-m.x)*u,i=(e.max.x-m.x)*u):(r=(e.max.x-m.x)*u,i=(e.min.x-m.x)*u),f>=0?(s=(e.min.y-m.y)*f,a=(e.max.y-m.y)*f):(s=(e.max.y-m.y)*f,a=(e.min.y-m.y)*f),r>a||s>i||((s>r||isNaN(r))&&(r=s),(a<i||isNaN(i))&&(i=a),h>=0?(o=(e.min.z-m.z)*h,c=(e.max.z-m.z)*h):(o=(e.max.z-m.z)*h,c=(e.min.z-m.z)*h),r>c||o>i)||((o>r||r!==r)&&(r=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,yo)!==null}intersectTriangle(e,n,r,i,s){J_.subVectors(n,e),zg.subVectors(r,e),Q_.crossVectors(J_,zg);let a=this.direction.dot(Q_),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;pl.subVectors(this.origin,e);const c=o*this.direction.dot(zg.crossVectors(pl,zg));if(c<0)return null;const u=o*this.direction.dot(J_.cross(pl));if(u<0||c+u>a)return null;const f=-o*pl.dot(Q_);return f<0?null:this.at(f/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class wU extends hv{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Zn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new su,this.combine=QF,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const pN=new Nr,xc=new tue,Vg=new nM,mN=new Oe,Hg=new Oe,Wg=new Oe,Gg=new Oe,ew=new Oe,$g=new Oe,gN=new Oe,Yg=new Oe;let Ya=class extends ls{constructor(e=new eo,n=new wU){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,a=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(s&&o){$g.set(0,0,0);for(let c=0,u=s.length;c<u;c++){const f=o[c],h=s[c];f!==0&&(ew.fromBufferAttribute(h,e),a?$g.addScaledVector(ew,f):$g.addScaledVector(ew.sub(n),f))}n.add($g)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),Vg.copy(r.boundingSphere),Vg.applyMatrix4(s),xc.copy(e.ray).recast(e.near),!(Vg.containsPoint(xc.origin)===!1&&(xc.intersectSphere(Vg,mN)===null||xc.origin.distanceToSquared(mN)>(e.far-e.near)**2))&&(pN.copy(s).invert(),xc.copy(e.ray).applyMatrix4(pN),!(r.boundingBox!==null&&xc.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,xc)))}_computeIntersections(e,n,r){let i;const s=this.geometry,a=this.material,o=s.index,c=s.attributes.position,u=s.attributes.uv,f=s.attributes.uv1,h=s.attributes.normal,m=s.groups,g=s.drawRange;if(o!==null)if(Array.isArray(a))for(let v=0,w=m.length;v<w;v++){const b=m[v],_=a[b.materialIndex],E=Math.max(b.start,g.start),M=Math.min(o.count,Math.min(b.start+b.count,g.start+g.count));for(let T=E,R=M;T<R;T+=3){const A=o.getX(T),P=o.getX(T+1),k=o.getX(T+2);i=qg(this,_,e,r,u,f,h,A,P,k),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const v=Math.max(0,g.start),w=Math.min(o.count,g.start+g.count);for(let b=v,_=w;b<_;b+=3){const E=o.getX(b),M=o.getX(b+1),T=o.getX(b+2);i=qg(this,a,e,r,u,f,h,E,M,T),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(a))for(let v=0,w=m.length;v<w;v++){const b=m[v],_=a[b.materialIndex],E=Math.max(b.start,g.start),M=Math.min(c.count,Math.min(b.start+b.count,g.start+g.count));for(let T=E,R=M;T<R;T+=3){const A=T,P=T+1,k=T+2;i=qg(this,_,e,r,u,f,h,A,P,k),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const v=Math.max(0,g.start),w=Math.min(c.count,g.start+g.count);for(let b=v,_=w;b<_;b+=3){const E=b,M=b+1,T=b+2;i=qg(this,a,e,r,u,f,h,E,M,T),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}};function nue(t,e,n,r,i,s,a,o){let c;if(e.side===zi?c=r.intersectTriangle(a,s,i,!0,o):c=r.intersectTriangle(i,s,a,e.side===Ol,o),c===null)return null;Yg.copy(o),Yg.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(Yg);return u<n.near||u>n.far?null:{distance:u,point:Yg.clone(),object:t}}function qg(t,e,n,r,i,s,a,o,c,u){t.getVertexPosition(o,Hg),t.getVertexPosition(c,Wg),t.getVertexPosition(u,Gg);const f=nue(t,e,n,r,Hg,Wg,Gg,gN);if(f){const h=new Oe;gh.getBarycoord(gN,Hg,Wg,Gg,h),i&&(f.uv=gh.getInterpolatedAttribute(i,o,c,u,h,new $n)),s&&(f.uv1=gh.getInterpolatedAttribute(s,o,c,u,h,new $n)),a&&(f.normal=gh.getInterpolatedAttribute(a,o,c,u,h,new Oe),f.normal.dot(r.direction)>0&&f.normal.multiplyScalar(-1));const m={a:o,b:c,c:u,normal:new Oe,materialIndex:0};gh.getNormal(Hg,Wg,Gg,m.normal),f.face=m,f.barycoord=h}return f}class rue extends Ti{constructor(e=null,n=1,r=1,i,s,a,o,c,u=ni,f=ni,h,m){super(null,a,o,c,u,f,i,s,h,m),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const tw=new Oe,iue=new Oe,sue=new pn;class Mc{constructor(e=new Oe(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=tw.subVectors(r,n).cross(iue.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,n){return n.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,n){const r=e.delta(tw),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:n.copy(e.start).addScaledVector(r,s)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||sue.getNormalMatrix(e),i=this.coplanarPoint(tw).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const bc=new nM,aue=new $n(.5,.5),Xg=new Oe;class SU{constructor(e=new Mc,n=new Mc,r=new Mc,i=new Mc,s=new Mc,a=new Mc){this.planes=[e,n,r,i,s,a]}set(e,n,r,i,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=La,r=!1){const i=this.planes,s=e.elements,a=s[0],o=s[1],c=s[2],u=s[3],f=s[4],h=s[5],m=s[6],g=s[7],v=s[8],w=s[9],b=s[10],_=s[11],E=s[12],M=s[13],T=s[14],R=s[15];if(i[0].setComponents(u-a,g-f,_-v,R-E).normalize(),i[1].setComponents(u+a,g+f,_+v,R+E).normalize(),i[2].setComponents(u+o,g+h,_+w,R+M).normalize(),i[3].setComponents(u-o,g-h,_-w,R-M).normalize(),r)i[4].setComponents(c,m,b,T).normalize(),i[5].setComponents(u-c,g-m,_-b,R-T).normalize();else if(i[4].setComponents(u-c,g-m,_-b,R-T).normalize(),n===La)i[5].setComponents(u+c,g+m,_+b,R+T).normalize();else if(n===by)i[5].setComponents(c,m,b,T).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),bc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),bc.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(bc)}intersectsSprite(e){bc.center.set(0,0,0);const n=aue.distanceTo(e.center);return bc.radius=.7071067811865476+n,bc.applyMatrix4(e.matrixWorld),this.intersectsSphere(bc)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(n[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(Xg.x=i.normal.x>0?e.max.x:e.min.x,Xg.y=i.normal.y>0?e.max.y:e.min.y,Xg.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Xg)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let r=0;r<6;r++)if(n[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class kU extends Ti{constructor(e=[],n=ru,r,i,s,a,o,c,u,f){super(e,n,r,i,s,a,o,c,u,f),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class hp extends Ti{constructor(e,n,r=$a,i,s,a,o=ni,c=ni,u,f=jo,h=1){if(f!==jo&&f!==Uc)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const m={width:e,height:n,depth:h};super(m,i,s,a,o,c,f,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new tM(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const n=super.toJSON(e);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}}class oue extends hp{constructor(e,n=$a,r=ru,i,s,a=ni,o=ni,c,u=jo){const f={width:e,height:e,depth:1},h=[f,f,f,f,f,f];super(e,e,n,r,i,s,a,o,c,u),this.image=h,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class EU extends Ti{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Gp extends eo{constructor(e=1,n=1,r=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const c=[],u=[],f=[],h=[];let m=0,g=0;v("z","y","x",-1,-1,r,n,e,a,s,0),v("z","y","x",1,-1,r,n,-e,a,s,1),v("x","z","y",1,1,e,r,n,i,a,2),v("x","z","y",1,-1,e,r,-n,i,a,3),v("x","y","z",1,-1,e,n,r,i,s,4),v("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(c),this.setAttribute("position",new Do(u,3)),this.setAttribute("normal",new Do(f,3)),this.setAttribute("uv",new Do(h,2));function v(w,b,_,E,M,T,R,A,P,k,N){const B=T/P,L=R/k,z=T/2,I=R/2,V=A/2,W=P+1,X=k+1;let J=0,F=0;const G=new Oe;for(let Y=0;Y<X;Y++){const H=Y*L-I;for(let te=0;te<W;te++){const re=te*B-z;G[w]=re*E,G[b]=H*M,G[_]=V,u.push(G.x,G.y,G.z),G[w]=0,G[b]=0,G[_]=A>0?1:-1,f.push(G.x,G.y,G.z),h.push(te/P),h.push(1-Y/k),J+=1}}for(let Y=0;Y<k;Y++)for(let H=0;H<P;H++){const te=m+H+W*Y,re=m+H+W*(Y+1),ue=m+(H+1)+W*(Y+1),ce=m+(H+1)+W*Y;c.push(te,re,ce),c.push(re,ue,ce),F+=6}o.addGroup(g,F,N),g+=F,m+=J}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Gp(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class pv extends eo{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const s=e/2,a=n/2,o=Math.floor(r),c=Math.floor(i),u=o+1,f=c+1,h=e/o,m=n/c,g=[],v=[],w=[],b=[];for(let _=0;_<f;_++){const E=_*m-a;for(let M=0;M<u;M++){const T=M*h-s;v.push(T,-E,0),w.push(0,0,1),b.push(M/o),b.push(1-_/c)}}for(let _=0;_<c;_++)for(let E=0;E<o;E++){const M=E+u*_,T=E+u*(_+1),R=E+1+u*(_+1),A=E+1+u*_;g.push(M,T,A),g.push(T,R,A)}this.setIndex(g),this.setAttribute("position",new Do(v,3)),this.setAttribute("normal",new Do(w,3)),this.setAttribute("uv",new Do(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new pv(e.width,e.height,e.widthSegments,e.heightSegments)}}function Zd(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(ln("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function wi(t){const e={};for(let n=0;n<t.length;n++){const r=Zd(t[n]);for(const i in r)e[i]=r[i]}return e}function lue(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function MU(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:jn.workingColorSpace}const cue={clone:Zd,merge:wi};var uue=`void main() {
|
|
622
|
+
)`}return p.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...i,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:s}})});function gy(t,e){t&&Object.assign(t.style,e)}const Hne={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},Wne={position:"fixed"},Gne=x.forwardRef(function(e,n){const{anchor:r,positionMethod:i="absolute",className:s,render:a,side:o="bottom",align:c="center",sideOffset:u=0,alignOffset:f=0,collisionBoundary:h="clipping-ancestors",collisionPadding:m,arrowPadding:g=5,sticky:v=!1,disableAnchorTracking:w,alignItemWithTrigger:b=!0,collisionAvoidance:_=cee,...E}=e,{store:M,listRef:T,labelsRef:R,alignItemWithTriggerActiveRef:A,selectedItemTextRef:P,valuesRef:k,initialValueRef:N,popupRef:B,setValue:L}=Wl(),z=g5(),I=mn(M,hn.open),V=mn(M,hn.mounted),W=mn(M,hn.modal),X=mn(M,hn.value),J=mn(M,hn.openMethod),F=mn(M,hn.positionerElement),G=mn(M,hn.triggerElement),Y=mn(M,hn.isItemEqualToValue),H=x.useRef(null),te=x.useRef(null),[re,ue]=x.useState(b),ce=V&&re&&J!=="touch";!V&&re!==b&&ue(b),Yt(()=>{V||(hn.scrollUpArrowVisible(M.state)&&M.set("scrollUpArrowVisible",!1),hn.scrollDownArrowVisible(M.state)&&M.set("scrollDownArrowVisible",!1))},[M,V]),x.useImperativeHandle(A,()=>ce),NE((ce||W)&&I&&J!=="touch",G);const ee=M5({anchor:r,floatingRootContext:z,positionMethod:i,mounted:V,side:o,sideOffset:u,align:c,alignOffset:f,arrowPadding:g,collisionBoundary:h,collisionPadding:m,sticky:v,disableAnchorTracking:w??ce,collisionAvoidance:_,keepMounted:!0}),le=ce?"none":ee.side,ve=ce?Wne:ee.positionerStyles,Ne=x.useMemo(()=>{const _e={};return I||(_e.pointerEvents="none"),{role:"presentation",hidden:!V,style:{...ve,..._e}}},[I,V,ve]),be=x.useMemo(()=>({open:I,side:le,align:ee.align,anchorHidden:ee.anchorHidden}),[I,le,ee.align,ee.anchorHidden]),qe=Bt(_e=>{M.set("positionerElement",_e)}),he=Xr("div",e,{ref:[n,qe],state:be,stateAttributesMapping:hu,props:[Ne,E]}),Ue=x.useRef(0),je=Bt(_e=>{if(_e.size===0&&Ue.current===0||k.current.length===0)return;const oe=Ue.current;if(Ue.current=_e.size,_e.size===oe)return;const Q=Mn(nv);if(oe!==0&&!M.state.multiple&&X!==null&&C1(k.current,X,Y)===-1){const Re=N.current,Le=Re!=null&&p_(k.current,Re,Y)?Re:null;L(Le,Q),Le===null&&(M.set("selectedIndex",null),P.current=null)}if(oe!==0&&M.state.multiple&&Array.isArray(X)){const ze=X.filter(Re=>p_(k.current,Re,Y));(ze.length!==X.length||ze.some(Re=>!p_(X,Re,Y)))&&(L(ze,Q),ze.length===0&&(M.set("selectedIndex",null),P.current=null))}if(I&&ce){M.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const ze={height:""};gy(F,ze),gy(B.current,ze)}}),et=x.useMemo(()=>({...ee,side:le,alignItemWithTriggerActive:ce,setControlledAlignItemWithTrigger:ue,scrollUpArrowRef:H,scrollDownArrowRef:te}),[ee,le,ce,ue]);return p.jsx(Nne,{elementsRef:T,labelsRef:R,onMapChange:je,children:p.jsxs(T5.Provider,{value:et,children:[V&&W&&p.jsx(DE,{inert:PE(!I),cutout:G}),he]})})});function C5(t){const e=t.currentTarget.getBoundingClientRect();return e.top+1<=t.clientY&&t.clientY<=e.bottom-1&&e.left+1<=t.clientX&&t.clientX<=e.right-1}const Mg="base-ui-disable-scrollbar",nP={className:Mg,getElement(t){return p.jsx("style",{nonce:t,href:Mg,precedence:"base-ui:low",children:`.${Mg}{scrollbar-width:none}.${Mg}::-webkit-scrollbar{display:none}`})}},$ne=x.createContext(void 0);function A5(t){return x.useContext($ne)}const R5="ArrowUp",P5="ArrowDown",N5="ArrowLeft",D5="ArrowRight",L5="Home",I5="End",Yne=new Set([N5,D5]),qne=new Set([R5,P5]),Xne=new Set([...Yne,...qne]);[...Xne];const LE=new Set([R5,P5,N5,D5,L5,I5]);function IE(t){return t==="starting"?lee:ei}function Kne(t,e=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(e,Math.min(t,n))}const Zne=x.createContext(void 0),Jne={disableStyleElements:!1};function Qne(){return x.useContext(Zne)??Jne}const ere={...hu,...df},tre=x.forwardRef(function(e,n){const{render:r,className:i,...s}=e,{store:a,popupRef:o,onOpenChangeComplete:c,setOpen:u,valueRef:f,selectedItemTextRef:h,keyboardActiveRef:m,multiple:g,handleScrollArrowVisibility:v,scrollHandlerRef:w,highlightItemOnHover:b}=Wl(),{side:_,align:E,alignItemWithTriggerActive:M,setControlledAlignItemWithTrigger:T,scrollDownArrowRef:R,scrollUpArrowRef:A}=Vne(),P=A5()!=null,k=g5(),{nonce:N,disableStyleElements:B}=Qne(),L=ji(),z=mn(a,hn.id),I=mn(a,hn.open),V=mn(a,hn.mounted),W=mn(a,hn.popupProps),X=mn(a,hn.transitionStatus),J=mn(a,hn.triggerElement),F=mn(a,hn.positionerElement),G=mn(a,hn.listElement),Y=x.useRef(0),H=x.useRef(!1),te=x.useRef(0),re=x.useRef(!1),ue=x.useRef({}),ce=Zy(),ee=Bt(be=>{if(!F||!o.current||!re.current)return;if(H.current||!M){v();return}const qe=F.style.top==="0px",he=F.style.bottom==="0px",Ue=F.getBoundingClientRect().height,je=Ga(F),et=getComputedStyle(F),_e=parseFloat(et.marginTop),oe=parseFloat(et.marginBottom),Q=rP(getComputedStyle(o.current)),ze=je.documentElement.clientHeight-_e-oe,Re=be.scrollTop,De=be.scrollHeight,Le=be.clientHeight,$=De-Le;let U=0,Z=null,pe=!1;if(qe){const Se=$-Re,xe=Ue+Se,Ie=Math.min(xe,ze);U=Ie,Ie!==ze?Z=$:pe=!0}else if(he){const Se=Re-0,xe=Ue+Se,Ie=Math.min(xe,ze),He=xe-ze;U=Ie,Ie!==ze?Z=0:(pe=!0,Re<$&&(Z=Re-(Se-He)))}U!==0&&(F.style.height=`${U}px`),Z!=null&&(be.scrollTop=Z),(pe||U>=Q)&&(H.current=!0),v()});x.useImperativeHandle(w,()=>ee,[ee]),ff({open:I,ref:o,onComplete(){I&&c?.(!0)}});const le=x.useMemo(()=>({open:I,transitionStatus:X,side:_,align:E}),[I,X,_,E]);Yt(()=>{!F||!o.current||Object.keys(ue.current).length||(ue.current={top:F.style.top||"0",left:F.style.left||"0",right:F.style.right,height:F.style.height,bottom:F.style.bottom,minHeight:F.style.minHeight,maxHeight:F.style.maxHeight,marginTop:F.style.marginTop,marginBottom:F.style.marginBottom})},[o,F]),Yt(()=>{I||M||(re.current=!1,H.current=!1,Y.current=0,te.current=0,gy(F,ue.current))},[I,M,F,o]),Yt(()=>{const be=o.current;if(!(!I||!J||!F||!be||a.state.transitionStatus==="ending")){if(!M){re.current=!0,ce.request(v),be.style.removeProperty("--transform-origin");return}queueMicrotask(()=>{const qe=rre(be);be.style.removeProperty("--transform-origin");try{const he=getComputedStyle(F),Ue=getComputedStyle(be),je=Ga(J),et=Pr(F),_e=J.getBoundingClientRect(),oe=F.getBoundingClientRect(),Q=_e.left,ze=_e.height,Re=G||be,De=Re.scrollHeight,Le=parseFloat(Ue.borderBottomWidth),$=parseFloat(he.marginTop)||10,U=parseFloat(he.marginBottom)||10,Z=parseFloat(he.minHeight)||100,pe=rP(Ue),Se=5,xe=5,Ie=20,He=je.documentElement.clientHeight-$-U,Ye=je.documentElement.clientWidth,ft=He-_e.bottom+ze,We=h.current,Xe=f.current;let nt,ct=0,Ke=0;if(We&&Xe){const _t=Xe.getBoundingClientRect();nt=We.getBoundingClientRect();const wt=_t.left-Q,un=nt.left-oe.left,xn=_t.top-_e.top+_t.height/2,ie=nt.top-oe.top+nt.height/2;ct=wt-un,Ke=ie-xn}const gt=ft+Ke+U+Le;let ne=Math.min(He,gt);const Be=He-$-U,ke=gt-ne,Ae=Math.max(Se,Q+ct),Ve=Ye-xe,ge=Math.max(0,Ae+oe.width-Ve);F.style.left=`${Ae-ge}px`,F.style.height=`${ne}px`,F.style.maxHeight="auto",F.style.marginTop=`${$}px`,F.style.marginBottom=`${U}px`,be.style.height="100%";const ut=Re.scrollHeight-Re.clientHeight,yt=ke>=ut;yt&&(ne=Math.min(He,oe.height)-(ke-ut));const qt=_e.top<Ie||_e.bottom>He-Ie||ne<Math.min(De,Z),Lt=(et.visualViewport?.scale??1)!==1&&x4;if(qt||Lt){re.current=!0,gy(F,ue.current),gi.flushSync(()=>T(!1));return}if(yt){const _t=Math.max(0,He-gt);F.style.top=oe.height>=Be?"0":`${_t}px`,F.style.height=`${ne}px`,Re.scrollTop=Re.scrollHeight-Re.clientHeight,Y.current=Math.max(Z,ne)}else F.style.bottom="0",Y.current=Math.max(Z,ne),Re.scrollTop=ke;if(nt){const _t=oe.top,wt=oe.height,un=nt.top+nt.height/2,xn=wt>0?(un-_t)/wt*100:50,ie=Kne(xn,0,100);be.style.setProperty("--transform-origin",`50% ${ie}%`)}(Y.current===He||ne>=pe)&&(H.current=!0),v(),setTimeout(()=>{re.current=!0})}finally{qe()}})}},[a,I,F,J,f,h,o,v,M,T,ce,R,A,G]),x.useEffect(()=>{if(!M||!F||!I)return;const be=Pr(F);function qe(he){u(!1,Mn(pee,he))}return be.addEventListener("resize",qe),()=>{be.removeEventListener("resize",qe)}},[u,M,F,I]);const ve={...G?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":g||void 0,id:`${z}-list`},onKeyDown(be){m.current=!0,P&&LE.has(be.key)&&be.stopPropagation()},onMouseMove(){m.current=!1},onPointerLeave(be){if(!b||C5(be)||be.pointerType==="touch")return;const qe=be.currentTarget;L.start(0,()=>{a.set("activeIndex",null),qe.focus({preventScroll:!0})})},onScroll(be){G||w.current?.(be.currentTarget)},...M&&{style:G?{height:"100%"}:Hne}},Ne=Xr("div",e,{ref:[n,o],state:le,stateAttributesMapping:ere,props:[W,ve,IE(X),{className:!G&&M?nP.className:void 0},s]});return p.jsxs(x.Fragment,{children:[!B&&nP.getElement(N),p.jsx(kE,{context:k,modal:!1,disabled:!V,restoreFocus:!0,children:Ne})]})});function rP(t){const e=t.maxHeight||"";return e.endsWith("px")&&parseFloat(e)||1/0}const iP={transform:"none",scale:"1",translate:"0 0"};function nre(t,e,n){n?t.setProperty(e,n):t.removeProperty(e)}function rre(t){const{style:e}=t,n={},r=Object.keys(iP);for(const i of r)n[i]=e.getPropertyValue(i),e.setProperty(i,iP[i]);return()=>{for(const i of r)nre(e,i,n[i])}}let O5=(function(t){return t[t.None=0]="None",t[t.GuessFromOrder=1]="GuessFromOrder",t})({});function ire(t={}){const{label:e,metadata:n,textRef:r,indexGuessBehavior:i,index:s}=t,{register:a,unregister:o,subscribeMapChange:c,elementsRef:u,labelsRef:f,nextIndexRef:h}=Pne(),m=x.useRef(-1),[g,v]=x.useState(s??(i===O5.GuessFromOrder?()=>{if(m.current===-1){const _=h.current;h.current+=1,m.current=_}return m.current}:-1)),w=x.useRef(null),b=x.useCallback(_=>{if(w.current=_,g!==-1&&_!==null&&(u.current[g]=_,f)){const E=e!==void 0;f.current[g]=E?e:r?.current?.textContent??_.textContent}},[g,u,f,e,r]);return Yt(()=>{if(s!=null)return;const _=w.current;if(_)return a(_,n),()=>{o(_)}},[s,a,o,n]),Yt(()=>{if(s==null)return c(_=>{const E=w.current?_.get(w.current)?.index:null;E!=null&&v(E)})},[s,c,v]),x.useMemo(()=>({ref:b,index:g}),[g,b])}const F5=x.createContext(void 0);function OE(){const t=x.useContext(F5);if(!t)throw new Error(Wi(57));return t}const sP=x.memo(x.forwardRef(function(e,n){const{render:r,className:i,value:s=null,label:a,disabled:o=!1,nativeButton:c=!1,...u}=e,f=x.useRef(null),h=ire({label:a,textRef:f,indexGuessBehavior:O5.GuessFromOrder}),{store:m,getItemProps:g,setOpen:v,setValue:w,selectionRef:b,typingRef:_,valuesRef:E,keyboardActiveRef:M,multiple:T,highlightItemOnHover:R}=Wl(),A=ji(),P=mn(m,hn.isActive,h.index),k=mn(m,hn.isSelected,h.index,s),N=mn(m,hn.isSelectedByFocus,h.index),B=mn(m,hn.isItemEqualToValue),L=h.index,z=L!==-1,I=x.useRef(null),V=jr(L);Yt(()=>{if(!z)return;const ee=E.current;return ee[L]=s,()=>{delete ee[L]}},[z,L,s,E]),Yt(()=>{if(!z)return;const ee=m.state.value;let le=ee;T&&Array.isArray(ee)&&ee.length>0&&(le=ee[ee.length-1]),le!==void 0&&$d(le,s,B)&&m.set("selectedIndex",L)},[z,L,T,B,m,s]);const W=x.useMemo(()=>({disabled:o,selected:k,highlighted:P}),[o,k,P]),X=g({active:P,selected:k});X.onFocus=void 0,X.id=void 0;const J=x.useRef(null),F=x.useRef("mouse"),G=x.useRef(!1),{getButtonProps:Y,buttonRef:H}=cv({disabled:o,focusableWhenDisabled:!0,native:c});function te(ee){const le=m.state.value;if(T){const ve=Array.isArray(le)?le:[],Ne=k?Zte(ve,s,B):[...ve,s];w(Ne,Mn(s_,ee))}else w(s,Mn(s_,ee)),v(!1,Mn(s_,ee))}const re={role:"option","aria-selected":k,tabIndex:P?0:-1,onFocus(){m.set("activeIndex",L)},onMouseEnter(){!M.current&&m.state.selectedIndex===null&&m.set("activeIndex",L)},onMouseMove(){R&&m.set("activeIndex",L)},onMouseLeave(ee){!R||M.current||C5(ee)||A.start(0,()=>{m.state.activeIndex===L&&m.set("activeIndex",null)})},onTouchStart(){b.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(ee){J.current=ee.key,m.set("activeIndex",L)},onClick(ee){G.current=!1,!(ee.type==="keydown"&&J.current===null)&&(o||J.current===" "&&_.current||F.current!=="touch"&&!P||(J.current=null,te(ee.nativeEvent)))},onPointerEnter(ee){F.current=ee.pointerType},onPointerDown(ee){F.current=ee.pointerType,G.current=!0},onMouseUp(ee){if(o)return;if(G.current){G.current=!1;return}const le=!b.current.allowSelectedMouseUp&&k,ve=!b.current.allowUnselectedMouseUp&&!k;le||ve||F.current!=="touch"&&!P||te(ee.nativeEvent)}},ue=Xr("div",e,{ref:[H,n,h.ref,I],state:W,props:[X,re,u,Y]}),ce=x.useMemo(()=>({selected:k,indexRef:V,textRef:f,selectedByFocus:N,hasRegistered:z}),[k,V,f,N,z]);return p.jsx(F5.Provider,{value:ce,children:ue})})),aP=x.forwardRef(function(e,n){const r=e.keepMounted??!1,{selected:i}=OE();return r||i?p.jsx(sre,{...e,ref:n}):null}),sre=x.memo(x.forwardRef((t,e)=>{const{render:n,className:r,keepMounted:i,...s}=t,{selected:a}=OE(),o=x.useRef(null),{transitionStatus:c,setMounted:u}=CE(a),f=x.useMemo(()=>({selected:a,transitionStatus:c}),[a,c]),h=Xr("span",t,{ref:[e,o],state:f,props:[{"aria-hidden":!0,children:"✔️"},s],stateAttributesMapping:df});return ff({open:a,ref:o,onComplete(){a||u(!1)}}),h})),oP=x.memo(x.forwardRef(function(e,n){const{indexRef:r,textRef:i,selectedByFocus:s,hasRegistered:a}=OE(),{selectedItemTextRef:o}=Wl(),{className:c,render:u,...f}=e,h=x.useCallback(g=>{if(!g||!a)return;const v=o.current===null||!o.current.isConnected;(s||v&&r.current===0)&&(o.current=g)},[o,r,s,a]);return Xr("div",e,{ref:[h,n,i],props:f})}));function U5({prefersReducedMotion:t,screenshotCapture:e}){return!(e||t)}function are({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z"})})}function ore({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",className:e,children:p.jsx("path",{d:"M8.086.457a6.105 6.105 0 013.046-.415c1.333.153 2.521.72 3.564 1.7a.117.117 0 00.107.029c1.408-.346 2.762-.224 4.061.366l.063.03.154.076c1.357.703 2.33 1.77 2.918 3.198.278.679.418 1.388.421 2.126a5.655 5.655 0 01-.18 1.631.167.167 0 00.04.155 5.982 5.982 0 011.578 2.891c.385 1.901-.01 3.615-1.183 5.14l-.182.22a6.063 6.063 0 01-2.934 1.851.162.162 0 00-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451-1.583-.008-2.986-.587-4.21-1.736a.145.145 0 00-.14-.032c-.518.167-1.04.191-1.604.185a5.924 5.924 0 01-2.595-.622 6.058 6.058 0 01-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74 7.74 0 01-.495-1.283 6.11 6.11 0 01-.017-3.064.166.166 0 00.008-.074.115.115 0 00-.037-.064 5.958 5.958 0 01-1.38-2.202 5.196 5.196 0 01-.333-1.589 6.915 6.915 0 01.188-2.132c.45-1.484 1.309-2.648 2.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129 0 00.087-.087A6.016 6.016 0 015.635 2.31C6.315 1.464 7.132.846 8.086.457zm-.804 7.85a.848.848 0 00-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 001.46.864l1.94-3.272a.849.849 0 00.007-.854l-1.94-3.393zm5.446 6.24a.849.849 0 000 1.695h4.848a.849.849 0 000-1.696h-4.848z"})})}function lre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M22.106 5.68L12.5.135a.998.998 0 00-.998 0L1.893 5.68a.84.84 0 00-.419.726v11.186c0 .3.16.577.42.727l9.607 5.547a.999.999 0 00.998 0l9.608-5.547a.84.84 0 00.42-.727V6.407a.84.84 0 00-.42-.726zm-.603 1.176L12.228 22.92c-.063.108-.228.064-.228-.061V12.34a.59.59 0 00-.295-.51l-9.11-5.26c-.107-.062-.063-.228.062-.228h18.55c.264 0 .428.286.296.514z"})})}function cre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z"})})}function ure({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 -1 22 28",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M4.125 20.149c-2.69 5.959 3.036 7.453 7.26 3.966 1.24 3.91 5.898.993 7.569-2.036 3.682-6.678 2.195-13.49 1.813-14.895-2.617-9.582-15.699-9.592-17.95.049-.526 1.687-.535 3.606-.833 5.598-.15 1.005-.256 1.646-.645 2.703-.223.607-.53 1.147-1.014 2.056-.75 1.412-.434 4.138 3.434 2.724v.001ZM11.895 11.332c-1.073 0-1.234-1.283-1.234-2.048 0-.69.124-1.239.358-1.586a1 1 0 0 1 .876-.462c.375 0 .697.158.924.47.259.354.395.9.395 1.578 0 1.283-.493 2.048-1.319 2.048Zm4.416 0c-1.073 0-1.234-1.283-1.234-2.048 0-.69.124-1.239.358-1.586a1 1 0 0 1 .876-.462c.375 0 .697.158.924.47.259.354.396.9.396 1.578 0 1.283-.494 2.048-1.32 2.048Z"})})}function dre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M16 6H8v12h8V6zm4 16H4V2h16v20z"})})}function fre({size:t=16,className:e=""}){return p.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:[p.jsx("path",{d:"M21.846 0a1.923 1.923 0 110 3.846H20.15a.226.226 0 01-.227-.226V1.923C19.923.861 20.784 0 21.846 0z"}),p.jsx("path",{d:"M11.065 11.199l7.257-7.2c.137-.136.06-.41-.116-.41H14.3a.164.164 0 00-.117.051l-7.82 7.756c-.122.12-.302.013-.302-.179V3.82c0-.127-.083-.23-.185-.23H3.186c-.103 0-.186.103-.186.23V19.77c0 .128.083.23.186.23h2.69c.103 0 .186-.102.186-.23v-3.25c0-.069.025-.135.069-.178l2.424-2.406a.158.158 0 01.205-.023l6.484 4.772a7.677 7.677 0 003.453 1.283c.108.012.2-.095.2-.23v-3.06c0-.117-.07-.212-.164-.227a5.028 5.028 0 01-2.027-.807l-5.613-4.064c-.117-.078-.132-.279-.028-.381z"})]})}function hre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",className:e,children:p.jsx("path",{d:"M19.245 5.364c1.322 1.36 1.877 3.216 2.11 5.817.622 0 1.2.135 1.592.654l.73.964c.21.278.323.61.323.955v2.62c0 .339-.173.669-.453.868C20.239 19.602 16.157 21.5 12 21.5c-4.6 0-9.205-2.583-11.547-4.258-.28-.2-.452-.53-.453-.868v-2.62c0-.345.113-.679.321-.956l.73-.963c.392-.517.974-.654 1.593-.654l.029-.297c.25-2.446.81-4.213 2.082-5.52 2.461-2.54 5.71-2.851 7.146-2.864h.198c1.436.013 4.685.323 7.146 2.864zm-7.244 4.328c-.284 0-.613.016-.962.05-.123.447-.305.85-.57 1.108-1.05 1.023-2.316 1.18-2.994 1.18-.638 0-1.306-.13-1.851-.464-.516.165-1.012.403-1.044.996a65.882 65.882 0 00-.063 2.884l-.002.48c-.002.563-.005 1.126-.013 1.69.002.326.204.63.51.765 2.482 1.102 4.83 1.657 6.99 1.657 2.156 0 4.504-.555 6.985-1.657a.854.854 0 00.51-.766c.03-1.682.006-3.372-.076-5.053-.031-.596-.528-.83-1.046-.996-.546.333-1.212.464-1.85.464-.677 0-1.942-.157-2.993-1.18-.266-.258-.447-.661-.57-1.108-.32-.032-.64-.049-.96-.05zm-2.525 4.013c.539 0 .976.426.976.95v1.753c0 .525-.437.95-.976.95a.964.964 0 01-.976-.95v-1.752c0-.525.437-.951.976-.951zm5 0c.539 0 .976.426.976.95v1.753c0 .525-.437.95-.976.95a.964.964 0 01-.976-.95v-1.752c0-.525.437-.951.976-.951zM7.635 5.087c-1.05.102-1.935.438-2.385.906-.975 1.037-.765 3.668-.21 4.224.405.394 1.17.657 1.995.657h.09c.649-.013 1.785-.176 2.73-1.11.435-.41.705-1.433.675-2.47-.03-.834-.27-1.52-.63-1.813-.39-.336-1.275-.482-2.265-.394zm6.465.394c-.36.292-.6.98-.63 1.813-.03 1.037.24 2.06.675 2.47.968.957 2.136 1.104 2.776 1.11h.044c.825 0 1.59-.263 1.995-.657.555-.556.765-3.187-.21-4.224-.45-.468-1.335-.804-2.385-.906-.99-.088-1.875.058-2.265.394zM12 7.615c-.24 0-.525.015-.84.044.03.16.045.336.06.526l-.001.159a2.94 2.94 0 01-.014.25c.225-.022.425-.027.612-.028h.366c.187 0 .387.006.612.028-.015-.146-.015-.277-.015-.409.015-.19.03-.365.06-.526a9.29 9.29 0 00-.84-.044z"})})}function pre({size:t=16,className:e=""}){return p.jsxs("svg",{width:t,height:t,viewBox:"0 0 64 60",fill:"none",className:e,"aria-hidden":"true",children:[p.jsx("path",{fill:"currentColor",d:"M37.2114 3.75318C37.6821 3.33106 37.7106 3.31457 38.0558 3.29385C38.6149 3.2531 39.1272 3.52199 39.9989 4.31564C42.0356 6.16652 44.8714 9.97183 46.6346 13.2212L47.3163 14.4819L48.2782 14.9605C49.2072 15.4299 50.7308 16.3923 51.3672 16.9085C51.655 17.1464 51.6956 17.1508 51.9947 17.0344C53.3454 16.5084 55.2803 17.206 56.9869 18.8432C58.5231 20.3155 59.9943 22.8312 60.558 24.9308C60.6403 25.2687 60.7493 25.9952 60.7891 26.5362C60.9177 28.4358 60.3092 29.9532 59.1362 30.64C58.8965 30.7784 58.8801 30.8158 58.8868 31.4132C58.9409 34.2583 58.1741 37.0985 56.6335 39.8679C54.8946 42.9773 51.7981 46.1938 47.6074 49.2243C45.357 50.8619 40.0323 53.964 37.6248 55.0532C31.8578 57.6496 27.2346 58.646 23.2188 58.154C20.8236 57.8638 18.1124 56.9287 16.5082 55.8433C16.086 55.5515 16.0191 55.5329 15.6966 55.6251C13.9793 56.1185 11.73 55.1053 9.81931 52.9844C9.05725 52.1366 7.82714 50.0548 7.42839 48.9409C6.50606 46.3339 6.68976 43.9816 7.91836 42.5767C8.23573 42.2149 8.2453 42.1995 8.17598 41.5912C8.06148 40.5951 8.00971 39.1206 8.06202 38.1692L8.10361 37.2803L6.76977 34.9212C4.70378 31.2451 3.3912 28.1582 2.88489 25.7998C2.61762 24.5066 2.63385 23.9324 2.96214 23.5078C3.16198 23.2515 3.81796 22.9866 4.60785 22.8407C6.59665 22.4917 10.9334 22.8076 15.7581 23.6595L16.259 23.7458L17.3608 22.7713C19.1891 21.1519 20.4038 20.244 22.6429 18.8478C24.9768 17.3876 27.6108 16.1858 30.577 15.2346L31.5295 14.9294L32.0526 13.5561C33.9257 8.61146 35.8437 4.96584 37.2114 3.75318ZM21.5208 29.0919C19.404 30.314 18.3453 30.9251 17.5676 31.6099C14.4179 34.3835 13.2414 38.777 14.5823 42.7537C14.9135 43.7357 15.5247 44.7942 16.7469 46.9111C17.9691 49.0279 18.5801 50.0865 19.2649 50.8643C22.0385 54.014 26.4316 55.1918 30.4084 53.8509C31.3904 53.5198 32.4489 52.9085 34.5657 51.6863L46.7442 44.6551C48.8613 43.4328 49.9205 42.8214 50.6983 42.1365C53.8479 39.363 55.0245 34.9695 53.6835 30.9927C53.3524 30.0107 52.7412 28.9522 51.519 26.8354C50.2968 24.7185 49.6858 23.66 49.0009 22.8822C46.2274 19.7325 41.8342 18.5547 37.8575 19.8956C36.8754 20.2267 35.8163 20.8383 33.6993 22.0606L21.5208 29.0919Z"}),p.jsx("g",{transform:"rotate(-30 22.6953 37.6011)",children:p.jsx("rect",{x:"22.6953",y:"37.6011",width:"4.81084",height:"9.99175",rx:"2.40542",fill:"currentColor"})}),p.jsx("g",{transform:"rotate(-30 35.6748 30.1074)",children:p.jsx("rect",{x:"35.6748",y:"30.1074",width:"4.81084",height:"9.99175",rx:"2.40542",fill:"currentColor"})})]})}function mre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",className:e,children:p.jsx("path",{d:"M7 2h10a5 5 0 015 5v10a5 5 0 01-5 5H7a5 5 0 01-5-5V7a5 5 0 015-5zm0 4.5v11h2.35v-4.55h5.3V17.5H17v-11h-2.35v4.1h-5.3V6.5H7z"})})}function gre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"currentColor",className:e,children:p.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"})})}function yre({size:t=16,className:e=""}){return p.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,"aria-hidden":"true",children:p.jsx("g",{transform:"translate(3.4502, 3)",fill:"#9570BE",children:p.jsx("path",{d:"M3.17890888,3.6 L3.17890888,0 L16,0 L16,3.6 L3.17890888,3.6 Z M9.642,7.2 L9.64218223,10.8 L0,10.8 L0,3.6 L16,3.6 L16,7.2 L9.642,7.2 Z M3.17890888,18 L3.178,14.4 L0,14.4 L0,10.8 L16,10.8 L16,18 L3.17890888,18 Z",fillRule:"nonzero"})})})}function vre({size:t=16,className:e=""}){return p.jsxs("svg",{width:t,height:t,viewBox:"0 0 120 90",fill:"currentColor",className:e,children:[p.jsx("rect",{x:"10",y:"8",width:"100",height:"12",rx:"2"}),p.jsx("rect",{x:"25",y:"20",width:"12",height:"62",rx:"2"}),p.jsx("rect",{x:"75",y:"20",width:"12",height:"45",rx:"2"}),p.jsx("rect",{x:"71",y:"55",width:"20",height:"16",rx:"3"}),p.jsx("rect",{x:"76",y:"71",width:"3",height:"8",rx:"1"}),p.jsx("rect",{x:"82",y:"71",width:"3",height:"8",rx:"1"})]})}function xre({size:t=16,className:e=""}){return p.jsxs("svg",{width:t,height:t,viewBox:"0 0 120 90",fill:"currentColor",className:e,children:[p.jsx("rect",{x:"10",y:"8",width:"100",height:"12",rx:"2"}),p.jsx("rect",{x:"25",y:"20",width:"12",height:"62",rx:"2"}),p.jsx("rect",{x:"83",y:"20",width:"12",height:"62",rx:"2"})]})}const bre={CLAUDE:are,CODEBUDDY:pre,CODEX:ore,COPILOT:hre,CRAFT:yre,CURSOR:lre,GEMINI:cre,GITHUB:gre,HERMES:mre,KIMI:fre,KIRO:ure,OPENCODE:dre,OMP:vre,PI:xre},_re={ANTIGRAVITY:"/brand-logos/antigravity.svg",CLAUDE:"/brand-logos/claude-code.svg",CODEX:"/brand-logos/codex.svg",GEMINI:"/brand-logos/gemini.svg",HERMES:"/brand-logos/hermes.svg","KILO-CLI":"/brand-logos/kilo.svg","KILO-CODE":"/brand-logos/kilo.svg",OPENCLAW:"/brand-logos/openclaw.svg",OPENCODE:"/brand-logos/opencode.svg"};function nu({provider:t,size:e=16,color:n,className:r=""}){const i=t?.toUpperCase?.()||"",s=_re[i];if(s)return p.jsx("img",{src:s,alt:"",width:e,height:e,className:r,style:{width:e,height:e,objectFit:"contain"},"aria-hidden":!0});const a=bre[i];return a?p.jsx(a,{size:e,className:r}):p.jsx("div",{className:"rounded-full shrink-0",style:{width:e*.5,height:e*.5,backgroundColor:n}})}function pu({children:t,title:e,subtitle:n,className:r="",bodyClassName:i=""}){return p.jsxs("div",{className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 transition-colors duration-200 ${r}`,children:[(e||n)&&p.jsxs("div",{className:"px-5 py-4 border-b border-oai-gray-200 dark:border-oai-gray-800 transition-colors duration-200",children:[e&&p.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide transition-colors duration-200",children:e}),n&&p.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300 mt-1 transition-colors duration-200",children:n})]}),p.jsx("div",{className:`p-5 ${i}`,children:t})]})}function wre(){return p.jsxs(Ei,{to:"/landing",className:"flex items-center gap-2.5 no-underline hover:opacity-80 transition-opacity",children:[p.jsx("img",{src:"/app-icon.png",alt:"Token Tracker",width:28,height:28,className:"rounded-md"}),p.jsx("span",{className:"text-base font-semibold text-oai-black dark:text-oai-white leading-tight",children:"Token Tracker"})]})}function Sre({children:t,header:e,footer:n,className:r="",hideHeader:i=!1,hideFooter:s=!1,bare:a=!1}){return a?p.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${r}`,children:[p.jsx("main",{className:"flex-1 px-6 py-6",children:t}),!s&&n&&p.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 mt-auto transition-colors duration-200",children:n})]}):p.jsxs("div",{className:`min-h-screen bg-oai-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-white font-sans flex flex-col transition-colors duration-200 ${r}`,children:[!i&&p.jsxs("header",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 flex items-center justify-between transition-colors duration-200",children:[p.jsx(wre,{}),p.jsx("div",{className:"flex-1 flex justify-center",children:e})]}),p.jsx("main",{className:"flex-1 px-6 py-6",children:t}),!s&&n&&p.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-800 px-6 py-4 mt-auto transition-colors duration-200",children:n})]})}function kre(t){if(!t||typeof t!="object")return null;const e=t.user_metadata&&typeof t.user_metadata=="object"?t.user_metadata:{},n=t.profile&&typeof t.profile=="object"?t.profile:{},r=e.avatar_url||e.picture||n.avatar_url||t.avatar_url;return typeof r=="string"&&r.trim()?r.trim():null}function lP(t){const e=String(t||"").trim();if(!e)return"?";const n=e.split(/\s+/).filter(Boolean);return n.length>=2?(n[0][0]+n[n.length-1][0]).toUpperCase():e.slice(0,2).toUpperCase()}function yy({className:t,variant:e="header",collapsed:n=!1,onAfterAction:r}){lu();const i=e==="sidebar",{enabled:s,loading:a,signedIn:o,user:c,displayName:u}=la(),{openLoginModal:f}=Cp(),h=tf(),m=x.useMemo(()=>kre(c),[c]);if(!s)return null;if(a)return p.jsx("div",{className:vt("h-9 w-9 shrink-0 rounded-full bg-oai-gray-200 dark:bg-oai-gray-800 animate-pulse",t),"aria-hidden":!0});if(!o)return i?p.jsxs("button",{type:"button",onClick:()=>{f(),r?.()},className:vt("flex items-center gap-2 rounded-md px-2 py-1.5 text-[13px] font-medium text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 min-w-0",n?"h-8 w-8 justify-center px-0":"w-full",t),"aria-label":O("header.auth.sign_in_aria"),title:n?O("header.auth.sign_in_aria"):void 0,children:[p.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center",children:p.jsx("img",{src:"/app-icon.png",alt:"",width:18,height:18,className:"h-[18px] w-[18px] rounded"})}),!n&&p.jsx("span",{className:"truncate flex-1 text-left",children:O("header.auth.sign_in_aria")})]}):p.jsx("button",{type:"button",onClick:f,className:vt("shrink-0 inline-flex h-9 items-center justify-center gap-1.5 rounded-full px-5 text-sm font-medium transition-colors duration-200 ease-out shadow-sm ring-1 ring-oai-gray-200 dark:ring-white/10 bg-oai-gray-900 text-white hover:bg-oai-gray-800 active:bg-oai-gray-950 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 dark:active:bg-oai-gray-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-oai-gray-950",t),"aria-label":O("header.auth.sign_in_aria"),children:O("header.auth.sign_in_aria")});const g=()=>{h("/settings"),r?.()};return p.jsx("div",{className:vt(i?"relative flex w-full shrink-0 items-center":"relative flex shrink-0 items-center",t),children:p.jsxs("button",{type:"button",onClick:g,className:vt(i?vt("flex w-full items-center gap-2 rounded-md px-2 py-1.5 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 transition-colors min-w-0",n&&"justify-center px-0 py-0 h-9 w-9"):"flex items-center gap-2 rounded-full pl-1 pr-2 py-1 border border-transparent hover:bg-oai-gray-100 dark:hover:bg-oai-gray-900/80 hover:border-oai-gray-200 dark:hover:border-oai-gray-800 transition-colors"),"aria-label":O("header.auth.open_settings"),title:i&&n?u:void 0,children:[i?p.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center",children:m?p.jsx("img",{src:m,alt:"",width:20,height:20,className:"h-5 w-5 rounded-full object-cover ring-1 ring-oai-gray-300 dark:ring-oai-gray-700",referrerPolicy:"no-referrer"}):p.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-oai-brand-600 text-[9px] font-semibold text-white ring-1 ring-oai-brand-500/50",children:lP(u)})}):m?p.jsx("img",{src:m,alt:"",width:32,height:32,className:"h-8 w-8 rounded-full object-cover ring-1 ring-oai-gray-300 dark:ring-oai-gray-700 shrink-0",referrerPolicy:"no-referrer"}):p.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-oai-brand-600 text-xs font-semibold text-white ring-1 ring-oai-brand-500/50",children:lP(u)}),i?!n&&p.jsx("span",{className:"truncate text-[13px] font-medium text-oai-gray-900 dark:text-oai-gray-200 flex-1 text-left min-w-0",children:u}):p.jsx("span",{className:"hidden sm:inline truncate text-sm font-medium text-oai-gray-900 dark:text-oai-gray-200 max-w-[120px]",children:u})]})})}const P1="tt.sidebarCollapsed";function Ere(){return[{id:"general",label:O("nav.group.general"),items:[{id:"usage",to:"/dashboard",icon:OW,label:O("nav.usage")},{id:"limits",to:"/limits",icon:GW,label:O("nav.limits")},{id:"leaderboard",to:"/leaderboard",icon:kG,label:O("nav.leaderboard")}]},{id:"tools",label:O("nav.group.tools"),items:[{id:"widgets",to:"/widgets",icon:QW,label:O("nav.widgets")},{id:"skills",to:"/skills",icon:hG,label:O("nav.skills")},{id:"ip-check",to:"/ip-check",icon:YW,label:O("nav.ip_check")}]},{id:"account",label:O("nav.group.account"),items:[{id:"settings",to:"/settings",icon:WL,label:O("nav.settings")}]}]}function Mre(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(P1)==="1"}catch{return!1}}function Tre(){const[t,e]=x.useState(Mre),n=x.useCallback(()=>{e(r=>{const i=!r;try{typeof window<"u"&&window.localStorage.setItem(P1,i?"1":"0")}catch{}return i})},[]);return x.useEffect(()=>{if(typeof window>"u")return;const r=i=>{i.key===P1&&e(i.newValue==="1")};return window.addEventListener("storage",r),()=>window.removeEventListener("storage",r)},[]),{collapsed:t,toggle:n}}function Cre(t,e){const n=t.replace(/\/+$/,"")||"/";return e==="/dashboard"?n==="/dashboard"||n==="/":e==="/leaderboard"?n==="/leaderboard"||n.startsWith("/leaderboard/"):n===e}function Are({label:t,collapsed:e,first:n}){return e?n?null:p.jsx("div",{className:"mx-2 my-2 h-px bg-oai-gray-200/70 dark:bg-oai-gray-800/70","aria-hidden":!0}):p.jsx("div",{className:vt("px-3 pb-1 text-[10px] uppercase tracking-wider text-oai-gray-500 dark:text-oai-gray-500",n?"pt-2":"pt-4"),children:t})}function Rre({item:t,collapsed:e,active:n,onClick:r}){const i=t.icon;return p.jsxs(Ei,{to:t.to,onClick:r,title:e?t.label:void 0,"aria-current":n?"page":void 0,className:vt("flex items-center gap-2 rounded-md px-2 py-1.5 text-[13px] no-underline transition-colors",e&&"justify-center px-0 py-2",n?"bg-oai-gray-200/70 text-oai-black font-medium dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/50 hover:text-oai-black dark:hover:bg-oai-gray-800/60 dark:hover:text-white"),children:[p.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center",children:p.jsx(i,{className:"h-[15px] w-[15px]","aria-hidden":!0})}),!e&&p.jsx("span",{className:"truncate",children:t.label})]})}function Pre({as:t="button",title:e,onClick:n,href:r,children:i,className:s,...a}){const o=vt("flex h-10 w-10 items-center justify-center rounded-lg text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",s);return t==="a"?p.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",title:e,"aria-label":e,className:o,...a,children:i}):p.jsx("button",{type:"button",title:e,"aria-label":e,onClick:n,className:o,...a,children:i})}function Nre({repo:t="mm7894215/TokenTracker",glassChrome:e=!1}){const[n,r]=x.useState(null);return x.useEffect(()=>{if(typeof window>"u")return;const i=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;U5({prefersReducedMotion:i,screenshotCapture:!1})&&fetch(`https://api.github.com/repos/${t}`).then(s=>s.json()).then(s=>{s&&typeof s.stargazers_count=="number"&&r(s.stargazers_count)}).catch(()=>{})},[t]),p.jsxs("a",{href:`https://github.com/${t}`,target:"_blank",rel:"noopener noreferrer","aria-label":n!==null?`Star on GitHub (${n})`:"Star on GitHub",className:vt("inline-flex h-7 items-center gap-1.5 rounded-full px-2.5 text-xs font-medium transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"border border-gray-500/20 dark:border-gray-500/30 bg-gray-500/[0.04] dark:bg-gray-500/[0.06] backdrop-blur-[2px] text-oai-gray-700 dark:text-oai-gray-300 hover:bg-gray-500/10 dark:hover:bg-gray-500/12 hover:border-gray-500/30 dark:hover:border-gray-500/40 hover:text-oai-black dark:hover:text-white":"border border-oai-gray-200 dark:border-oai-gray-700 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white hover:border-oai-gray-300 dark:hover:border-oai-gray-600"),children:[p.jsx("svg",{height:"12",viewBox:"0 0 16 16",width:"12",className:"shrink-0 fill-current",children:p.jsx("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})}),p.jsx("span",{children:"Star"}),n!==null&&p.jsx("span",{className:"text-[10px] text-oai-gray-500 dark:text-oai-gray-500 tabular-nums",children:n})]})}const Dre=[{value:"light",label:"Light",Icon:Rk},{value:"dark",label:"Dark",Icon:Ck},{value:"system",label:"System",Icon:Wy}];function Lre({theme:t,resolvedTheme:e,onSetTheme:n,glassChrome:r=!1}){const[i,s]=x.useState(!1),a=x.useRef(null),o=e==="dark"?Ck:Rk;return x.useEffect(()=>{if(!i)return;const c=f=>{a.current&&!a.current.contains(f.target)&&s(!1)},u=f=>{f.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",c),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",u)}},[i]),p.jsxs("div",{ref:a,className:"relative",children:[p.jsx("button",{type:"button","aria-label":"Theme","aria-expanded":i,"aria-haspopup":"menu",title:"Theme",onClick:()=>s(c=>!c),className:vt("inline-flex h-7 w-7 items-center justify-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",r?"border border-gray-500/20 dark:border-gray-500/30 bg-gray-500/[0.04] dark:bg-gray-500/[0.06] backdrop-blur-[2px] text-oai-gray-700 dark:text-oai-gray-300 hover:bg-gray-500/10 dark:hover:bg-gray-500/12 hover:border-gray-500/30 dark:hover:border-gray-500/40 hover:text-oai-black dark:hover:text-white":"border border-oai-gray-200 dark:border-oai-gray-700 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white hover:border-oai-gray-300 dark:hover:border-oai-gray-600"),children:p.jsx(o,{className:"h-3.5 w-3.5","aria-hidden":!0})}),i&&p.jsx("div",{role:"menu",className:"absolute bottom-full left-0 mb-2 z-50 min-w-[140px] py-1 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 shadow-lg",children:Dre.map(({value:c,label:u,Icon:f})=>{const h=t===c;return p.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{n(c),s(!1)},className:vt("flex w-full items-center gap-2.5 px-3 py-1.5 text-[13px] transition-colors",h?"text-oai-black dark:text-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/60 hover:text-oai-black dark:hover:text-white"),children:[p.jsx(f,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),p.jsx("span",{children:u})]},c)})})]})}function j5({collapsed:t,onToggleCollapsed:e,onItemClick:n,showCloseButton:r=!1,onClose:i,glassChrome:s=!1}){const o=Hi()?.pathname||"/",{theme:c,resolvedTheme:u,setTheme:f}=Op(),{resolvedLocale:h}=lu(),m=x.useMemo(()=>Ere(),[h]);return p.jsxs(p.Fragment,{children:[p.jsx("div",{className:vt("px-2 pt-2 pb-2",t&&"flex justify-center"),children:r?p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("div",{className:"flex-1 min-w-0",children:p.jsx(yy,{variant:"sidebar",collapsed:t,onAfterAction:n})}),p.jsx("button",{type:"button",onClick:i,"aria-label":O("nav.close_menu"),title:O("nav.close_menu"),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-oai-gray-500 dark:text-oai-gray-500 hover:bg-oai-gray-200/60 dark:hover:bg-oai-gray-800 hover:text-oai-gray-900 dark:hover:text-oai-gray-200 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:p.jsx(Pk,{className:"h-4 w-4",strokeWidth:1.75,"aria-hidden":!0})})]}):p.jsx(yy,{variant:"sidebar",collapsed:t,onAfterAction:n})}),p.jsx("nav",{"aria-label":O("nav.nav_label"),className:"flex-1 px-2 pb-2 flex flex-col overflow-y-auto",children:m.map((g,v)=>p.jsxs("div",{className:"flex flex-col",children:[p.jsx(Are,{label:g.label,collapsed:t,first:v===0}),p.jsx("div",{className:"flex flex-col gap-0.5",children:g.items.map(w=>p.jsx(Rre,{item:w,collapsed:t,active:Cre(o,w.to),onClick:n},w.id))})]},g.id))}),p.jsxs("div",{className:vt("flex items-center px-2 py-3",t?"flex-col justify-center gap-2":"justify-between gap-2"),children:[p.jsx(Lre,{theme:c,resolvedTheme:u,onSetTheme:f,glassChrome:s}),p.jsx("div",{className:"flex items-center gap-1.5",children:!t&&p.jsx(Nre,{glassChrome:s})})]})]})}function Ire({collapsed:t,onToggleCollapsed:e}){const n=x.useMemo(()=>typeof window>"u"?!1:Js()||Ek(),[]);return p.jsx("aside",{"aria-label":O("nav.aside_label"),className:vt("hidden lg:flex flex-col shrink-0 h-full min-h-0 transition-[width] duration-200",t?"w-[72px]":"w-[220px]"),children:p.jsx(j5,{collapsed:t,onToggleCollapsed:e,glassChrome:n})})}function Ore({open:t,onClose:e}){return x.useEffect(()=>{if(!t)return;const n=r=>{r.key==="Escape"&&e()};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[t,e]),x.useEffect(()=>{if(!t)return;const n=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=n}},[t]),t?p.jsxs("div",{className:"lg:hidden fixed inset-0 z-[80] flex",children:[p.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:e,"aria-hidden":!0}),p.jsx("aside",{"aria-label":O("nav.aside_label"),className:"relative w-[260px] max-w-[80vw] flex flex-col bg-oai-white dark:bg-oai-gray-900 border-r border-oai-gray-200 dark:border-oai-gray-800 shadow-2xl",children:p.jsx(j5,{collapsed:!1,showCloseButton:!0,onClose:e,onItemClick:e})})]}):null}function Fre({onOpenDrawer:t}){return p.jsxs("div",{className:"lg:hidden flex items-center justify-between gap-2 px-3 h-14 border-b border-oai-gray-200 dark:border-oai-gray-800",children:[p.jsx(Pre,{title:O("nav.menu"),onClick:t,children:p.jsx(aG,{className:"h-5 w-5","aria-hidden":!0})}),p.jsxs(Ei,{to:"/landing",className:"flex items-center gap-2 no-underline hover:opacity-80 transition-opacity","aria-label":"Token Tracker",children:[p.jsx("img",{src:"/app-icon.png",alt:"",width:24,height:24,className:"rounded-md"}),p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white",children:"Token Tracker"})]}),p.jsx("div",{className:"w-10 shrink-0","aria-hidden":!0})]})}function Ure({children:t}){const{collapsed:e,toggle:n}=Tre(),[r,i]=x.useState(!1),s=x.useCallback(()=>i(!0),[]),a=x.useCallback(()=>i(!1),[]),o=x.useMemo(()=>typeof window>"u"?!1:Js()||Ek(),[]);return p.jsxs("div",{className:vt("fixed inset-0 flex flex-col text-oai-black dark:text-oai-white font-sans overflow-hidden",o?"bg-transparent":"bg-oai-gray-100 dark:bg-oai-gray-950"),children:[o&&p.jsx("div",{className:"h-7 shrink-0",style:{WebkitAppRegion:"drag"},"aria-hidden":!0}),p.jsxs("div",{className:"flex-1 min-h-0 flex",children:[p.jsx(Ire,{collapsed:e,onToggleCollapsed:n}),p.jsx(Ore,{open:r,onClose:a}),p.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-2 lg:pl-0 lg:pr-3 lg:pb-3 flex flex-col",children:p.jsxs("div",{className:vt("flex-1 min-h-0 flex flex-col bg-oai-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-800 overflow-hidden",o?"tt-native-main-card":"rounded-2xl",!o&&"shadow-sm"),children:[p.jsx(Fre,{onOpenDrawer:s}),p.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:t})]})})]})]})}function jre({children:t,variant:e="info",size:n="md",className:r=""}){const i="inline-flex items-center font-medium",s={success:"bg-oai-brand-100 dark:bg-oai-brand-900/30 text-oai-brand-700 dark:text-oai-brand-400 rounded-full",warning:"bg-oai-amber-50 dark:bg-oai-amber-900/30 text-oai-amber-dark dark:text-oai-amber-400 rounded-full",error:"bg-red-50 dark:bg-red-900/30 text-red-600 dark:text-red-400 rounded-full",info:"bg-oai-gray-100 dark:bg-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-300 rounded-full",secondary:"bg-oai-gray-100 dark:bg-oai-gray-800 text-oai-gray-500 dark:text-oai-gray-300 rounded-md"},a={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm"},o=`${i} ${s[e]} ${a[n]} ${r}`.trim();return p.jsx("span",{className:o,children:t})}const B5=x.createContext(void 0);function Gl(t){const e=x.useContext(B5);if(t===!1&&e===void 0)throw new Error(Wi(27));return e}const Bre={...hu,...df},z5=x.forwardRef(function(e,n){const{render:r,className:i,forceRender:s=!1,...a}=e,{store:o}=Gl(),c=o.useState("open"),u=o.useState("nested"),f=o.useState("mounted"),h=o.useState("transitionStatus"),m=x.useMemo(()=>({open:c,transitionStatus:h}),[c,h]);return Xr("div",e,{state:m,ref:[o.context.backdropRef,n],stateAttributesMapping:Bre,props:[{role:"presentation",hidden:!f,style:{userSelect:"none",WebkitUserSelect:"none"}},a],enabled:s||!u})}),zre=x.forwardRef(function(e,n){const{render:r,className:i,disabled:s=!1,nativeButton:a=!0,...o}=e,{store:c}=Gl(),u=c.useState("open");function f(v){u&&c.setOpen(!1,Mn(fee,v.nativeEvent))}const{getButtonProps:h,buttonRef:m}=cv({disabled:s,native:a}),g=x.useMemo(()=>({disabled:s}),[s]);return Xr("button",e,{state:g,ref:[n,m],props:[{onClick:f},o,h]})}),Vre=x.forwardRef(function(e,n){const{render:r,className:i,id:s,...a}=e,{store:o}=Gl(),c=lv(s);return o.useSyncedValueWithCleanup("descriptionElementId",c),Xr("p",e,{ref:n,props:[{id:c},a]})});let Hre=(function(t){return t.nestedDialogs="--nested-dialogs",t})({}),Wre=(function(t){return t[t.open=Qs.open]="open",t[t.closed=Qs.closed]="closed",t[t.startingStyle=Qs.startingStyle]="startingStyle",t[t.endingStyle=Qs.endingStyle]="endingStyle",t.nested="data-nested",t.nestedDialogOpen="data-nested-dialog-open",t})({});const V5=x.createContext(void 0);function H5(){const t=x.useContext(V5);if(t===void 0)throw new Error(Wi(26));return t}const Gre={...hu,...df,nestedDialogOpen(t){return t?{[Wre.nestedDialogOpen]:""}:null}},W5=x.forwardRef(function(e,n){const{className:r,finalFocus:i,initialFocus:s,render:a,...o}=e,{store:c}=Gl(),u=c.useState("descriptionElementId"),f=c.useState("disablePointerDismissal"),h=c.useState("floatingRootContext"),m=c.useState("popupProps"),g=c.useState("modal"),v=c.useState("mounted"),w=c.useState("nested"),b=c.useState("nestedOpenDialogCount"),_=c.useState("open"),E=c.useState("openMethod"),M=c.useState("titleElementId"),T=c.useState("transitionStatus"),R=c.useState("role");H5(),ff({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});function A(L){return L==="touch"?c.context.popupRef.current:!0}const P=s===void 0?A:s,k=b>0,N=x.useMemo(()=>({open:_,nested:w,transitionStatus:T,nestedDialogOpen:k}),[_,w,T,k]),B=Xr("div",e,{state:N,props:[m,{"aria-labelledby":M??void 0,"aria-describedby":u??void 0,role:R,tabIndex:-1,hidden:!v,onKeyDown(L){LE.has(L.key)&&L.stopPropagation()},style:{[Hre.nestedDialogs]:b}},o],ref:[n,c.context.popupRef,c.useStateSetter("popupElement")],stateAttributesMapping:Gre});return p.jsx(kE,{context:h,openInteractionType:E,disabled:!v,closeOnFocusOut:!f,initialFocus:P,returnFocus:i,modal:g!==!1,restoreFocus:"popup",children:B})}),G5=x.forwardRef(function(e,n){const{keepMounted:r=!1,...i}=e,{store:s}=Gl(),a=s.useState("mounted"),o=s.useState("modal"),c=s.useState("open");return a||r?p.jsx(V5.Provider,{value:r,children:p.jsxs(wE,{ref:n,...i,children:[a&&o===!0&&p.jsx(DE,{ref:s.context.internalBackdropRef,inert:PE(!c)}),e.children]})}):null});function $re(t){const{store:e,parentContext:n,actionsRef:r}=t,i=e.useState("open"),s=e.useState("disablePointerDismissal"),a=e.useState("modal"),o=e.useState("popupElement"),{openMethod:c,triggerProps:u,reset:f}=RE(i);a5(e);const{forceUnmount:h}=o5(i,e,()=>{f()}),m=Bt(B=>{const L=Mn(B);return L.preventUnmountOnClose=()=>{e.set("preventUnmountingOnClose",!0)},L}),g=x.useCallback(()=>{e.setOpen(!1,m(W4))},[e,m]);x.useImperativeHandle(r,()=>({unmount:h,close:g}),[h,g]);const v=d5({popupStore:e,onOpenChange:e.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[w,b]=x.useState(0),_=w===0,E=h5(v),M=ME(v,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?"intentional":{mouse:a==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(B){if("button"in B&&B.button!==0||"touches"in B&&B.touches.length!==1)return!1;const L=Fi(B);if(_&&!s){const z=L;return a&&(e.context.internalBackdropRef.current||e.context.backdropRef.current)?e.context.internalBackdropRef.current===z||e.context.backdropRef.current===z||On(z,o)&&!z?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:_});NE(i&&a===!0,o);const{getReferenceProps:T,getFloatingProps:R,getTriggerProps:A}=av([E,M]);e.useContextCallback("onNestedDialogOpen",B=>{b(B+1)}),e.useContextCallback("onNestedDialogClose",()=>{b(0)}),x.useEffect(()=>(n?.onNestedDialogOpen&&i&&n.onNestedDialogOpen(w),n?.onNestedDialogClose&&!i&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&i&&n.onNestedDialogClose()}),[i,n,w]);const P=x.useMemo(()=>T(u),[T,u]),k=x.useMemo(()=>A(u),[A,u]),N=x.useMemo(()=>R(),[R]);e.useSyncedValues({openMethod:c,activeTriggerProps:P,inactiveTriggerProps:k,popupProps:N,floatingRootContext:v,nestedOpenDialogCount:w})}const Yre={...c5,modal:Rt(t=>t.modal),nested:Rt(t=>t.nested),nestedOpenDialogCount:Rt(t=>t.nestedOpenDialogCount),disablePointerDismissal:Rt(t=>t.disablePointerDismissal),openMethod:Rt(t=>t.openMethod),descriptionElementId:Rt(t=>t.descriptionElementId),titleElementId:Rt(t=>t.titleElementId),viewportElement:Rt(t=>t.viewportElement),role:Rt(t=>t.role)};class qre extends fE{constructor(e){super(Xre(e),{popupRef:x.createRef(),backdropRef:x.createRef(),internalBackdropRef:x.createRef(),triggerElements:new sv,onOpenChange:void 0,onOpenChangeComplete:void 0},Yre)}setOpen=(e,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!e&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,n),n.isCanceled)return;const r={open:e,nativeEvent:n.event,reason:n.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit("openchange",r);const i={open:e},s=n.trigger?.id??null;(s||e)&&(i.activeTriggerId=s,i.activeTriggerElement=n.trigger??null),this.update(i)}}function Xre(t={}){return{...l5(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...t}}function $5(t){const{children:e,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:s,disablePointerDismissal:a=!1,modal:o=!0,actionsRef:c,handle:u,triggerId:f,defaultTriggerId:h=null}=t,m=Gl(!0),g=!!m,v=Vi(()=>u?.store??new qre({open:n??r,activeTriggerId:f!==void 0?f:h,modal:o,disablePointerDismissal:a,nested:g})).current;v.useControlledProp("open",n,r),v.useControlledProp("activeTriggerId",f,h),v.useSyncedValues({disablePointerDismissal:a,nested:g,modal:o}),v.useContextCallback("onOpenChange",i),v.useContextCallback("onOpenChangeComplete",s);const w=v.useState("payload");$re({store:v,actionsRef:c,parentContext:m?.store.context});const b=x.useMemo(()=>({store:v}),[v]);return p.jsx(B5.Provider,{value:b,children:typeof e=="function"?e({payload:w}):e})}let cP=(function(t){return t[t.open=Qs.open]="open",t[t.closed=Qs.closed]="closed",t[t.startingStyle=Qs.startingStyle]="startingStyle",t[t.endingStyle=Qs.endingStyle]="endingStyle",t.nested="data-nested",t.nestedDialogOpen="data-nested-dialog-open",t})({});const Kre={...hu,...df,nested(t){return t?{[cP.nested]:""}:null},nestedDialogOpen(t){return t?{[cP.nestedDialogOpen]:""}:null}},Y5=x.forwardRef(function(e,n){const{className:r,render:i,children:s,...a}=e,o=H5(),{store:c}=Gl(),u=c.useState("open"),f=c.useState("nested"),h=c.useState("transitionStatus"),m=c.useState("nestedOpenDialogCount"),g=c.useState("mounted"),v=m>0,w=x.useMemo(()=>({open:u,nested:f,transitionStatus:h,nestedDialogOpen:v}),[u,f,h,v]);return Xr("div",e,{enabled:o||g,state:w,ref:[n,c.useStateSetter("viewportElement")],stateAttributesMapping:Kre,props:[{role:"presentation",hidden:!g,children:s},a]})}),q5=x.forwardRef(function(e,n){const{render:r,className:i,id:s,...a}=e,{store:o}=Gl(),c=lv(s);return o.useSyncedValueWithCleanup("titleElementId",c),Xr("h2",e,{ref:n,props:[{id:c},a]})});function Zre({open:t,title:e,description:n,confirmLabel:r,cancelLabel:i,destructive:s=!1,busy:a=!1,onConfirm:o,onCancel:c}){return p.jsx($5,{open:t,onOpenChange:u=>{!u&&!a&&c?.()},children:p.jsxs(G5,{children:[p.jsx(z5,{className:"fixed inset-0 z-[100] bg-black/40 backdrop-blur-[2px] transition-opacity duration-200 ease-out data-[ending-style]:opacity-0 data-[starting-style]:opacity-0"}),p.jsx(Y5,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:p.jsxs(W5,{className:"relative w-full max-w-md rounded-2xl bg-white p-6 shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] ring-1 ring-oai-gray-200 transition-[opacity,transform] duration-[220ms] ease-[cubic-bezier(0.16,1,0.3,1)] data-[ending-style]:translate-y-2 data-[ending-style]:scale-[0.96] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-2 data-[starting-style]:scale-[0.96] data-[starting-style]:opacity-0 dark:bg-oai-gray-950 dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)] dark:ring-oai-gray-800",children:[p.jsx(q5,{className:"text-base font-semibold text-oai-black dark:text-white",children:e}),n?p.jsx(Vre,{className:"mt-2 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:n}):null,p.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[p.jsx(Ui,{type:"button",variant:"secondary",size:"sm",disabled:a,onClick:()=>c?.(),children:i}),p.jsx(Ui,{type:"button",size:"sm",disabled:a,onClick:()=>o?.(),className:vt(s&&"!bg-red-600 hover:!bg-red-700 focus-visible:!outline-red-600 dark:!bg-red-600 dark:hover:!bg-red-500"),children:r})]})]})})]})})}function X5({value:t,onChange:e,placeholder:n,disabled:r=!1,type:i="text",label:s,error:a,className:o="",...c}){const m=`w-full bg-oai-white dark:bg-oai-gray-900 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md text-oai-black dark:text-oai-white placeholder-oai-gray-400 dark:placeholder-oai-gray-500 transition-all duration-200 focus:outline-none focus:border-oai-brand dark:focus:border-oai-brand focus:ring-1 focus:ring-oai-brand/30 ${r?"bg-oai-gray-50 dark:bg-oai-gray-800 text-oai-gray-400 dark:text-oai-gray-400 cursor-not-allowed":""} ${a?"border-oai-error focus:border-oai-error focus:ring-oai-error/30":""} h-10 px-3 text-sm ${o}`;return p.jsxs("div",{className:"w-full",children:[s&&p.jsx("label",{className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5 transition-colors duration-200",children:s}),p.jsx("input",{type:i,value:t,onChange:e,placeholder:n,disabled:r,className:m,...c}),a&&p.jsx("p",{className:"mt-1.5 text-sm text-oai-error",children:a})]})}var Jre={};function Qre(t,e){return t==="."?{width:"0.34ch",justifyContent:"center",marginInline:"-0.04ch"}:t===","?{width:"0.08ch",justifyContent:"center",marginInline:"-0.30ch"}:{width:"0.72ch",justifyContent:"flex-start",paddingLeft:"0.04ch",height:e}}function eie({mv:t,digit:e,height:n}){const r=OO(t,i=>{const s=(i%10+10)%10,a=(10+e-s)%10;let o=a*n;return a>5&&(o-=10*n),o});return p.jsx(tr.span,{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",y:r},children:e})}function tie(t){const e=Math.round(t),n=1e-9*Math.max(1,Math.abs(t));return Math.abs(t-e)<n?e:t}function nie(t,e){const n=t/e;return Math.floor(tie(n))}function rie(t){const e=String(t??""),n=Array.from(e),r=n.indexOf(".");let i=n.filter((o,c)=>/\d/.test(o)&&(r===-1||c<r)).length,s=0,a=!1;return n.map(o=>{if(!/\d/.test(o))return o==="."&&(a=!0),o;if(!a){const c=10**Math.max(i-1,0);return i-=1,c}return s+=1,10**-s})}function iie({place:t,value:e,height:n,digitStyle:r,shouldReduceMotion:i}){if(typeof t!="number"){const c=Qre(t,n);return p.jsx("span",{"data-counter-token":"static",className:"relative inline-flex items-center justify-center",style:{height:n,...c,...r},children:t})}const s=nie(e,t),a=sE(0),o=FK(a,{stiffness:220,damping:26,mass:.8});return x.useEffect(()=>{a.set(s)},[a,s]),i?p.jsx("span",{"data-counter-token":"digit",className:"relative inline-flex items-center justify-center overflow-hidden",style:{height:n,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...r},children:Math.abs(s)%10}):p.jsx("span",{"data-counter-token":"digit",className:"relative inline-flex overflow-hidden",style:{height:n,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...r},children:Array.from({length:10},(c,u)=>p.jsx(eie,{mv:o,digit:u,height:n},u))})}function sie({value:t,displayValue:e,fontSize:n=72,padding:r=0,places:i,gap:s=6,borderRadius:a=4,horizontalPadding:o=0,textColor:c="inherit",fontWeight:u="inherit",containerStyle:f,counterStyle:h,digitStyle:m,gradientHeight:g=14,gradientFrom:v="rgba(255,255,255,0.95)",gradientTo:w="rgba(255,255,255,0)",topGradientStyle:b,bottomGradientStyle:_}){const E=String(e??t??""),M=x.useMemo(()=>Array.isArray(i)&&i.length?i:rie(E),[i,E]),T=typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent||"")||typeof process<"u"&&Jre?.VITEST==="true",R=cu()||T,A=Number.isFinite(Number(t))?Math.abs(Number(t)):0,P=n+r;return R?p.jsx("span",{"data-counter-root":"true",style:{display:"inline-flex",alignItems:"center",color:c,fontSize:n,fontWeight:u,lineHeight:1,...f,...h},children:E}):p.jsxs("span",{"data-counter-root":"true",style:{position:"relative",display:"inline-block",...f},children:[p.jsx("span",{style:{fontSize:n,display:"flex",gap:s,overflow:"hidden",borderRadius:a,paddingLeft:o,paddingRight:o,lineHeight:1,color:c,fontWeight:u,...h},children:M.map((k,N)=>p.jsx(iie,{place:k,value:A,height:P,digitStyle:m,shouldReduceMotion:R},`${String(k)}-${N}`))}),p.jsxs("span",{style:{pointerEvents:"none",position:"absolute",inset:0,display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[p.jsx("span",{style:b??{height:g,background:`linear-gradient(to bottom, ${v}, ${w})`}}),p.jsx("span",{style:_??{height:g,background:`linear-gradient(to top, ${v}, ${w})`}})]})]})}function aie(t){if(!Number.isFinite(t))return O("shared.placeholder.short");const e=Uy(t.toFixed(2),{decimals:2});return e==="-"?O("shared.placeholder.short"):e}function uP(t){return!Number.isFinite(t)||t<=0?null:t<.01?"<$0.01":Uy(t.toFixed(2),{decimals:2})}function dP(t){const e=Number(t);return!Number.isFinite(e)||e<=0?null:Ms(e,{decimals:1})}const oie=ot.memo(function({isOpen:e,onClose:n,fleetData:r=[]}){const i=x.useMemo(()=>(Array.isArray(r)?r:[]).map(a=>{const o=ti(a?.usd)??0,c=ti(a?.usage)??0,u=Array.isArray(a?.models)?a.models:[];return{label:a?.label?String(a.label):"",usdValue:o,usdLabel:uP(o),tokensLabel:dP(c),models:u.map(f=>{const h=ti(f?.usage)??0,m=ti(f?.cost)??0;return{id:f?.id?String(f.id):"",name:f?.name?String(f.name):"",tokensLabel:dP(h),costLabel:uP(m),sortCost:m}}).filter(f=>f.costLabel||f.tokensLabel).sort((f,h)=>h.sortCost-f.sortCost)}}).filter(a=>a.usdValue>0||a.models.length>0).sort((a,o)=>o.usdValue-a.usdValue),[r]),s=x.useMemo(()=>{const a=i.reduce((o,c)=>o+c.usdValue,0);return aie(a)},[i]);return p.jsx($5,{open:e,onOpenChange:a=>{a||n?.()},children:p.jsxs(G5,{children:[p.jsx(z5,{className:"cost-modal-backdrop","data-cost-analysis-backdrop":"true"}),p.jsx(Y5,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:p.jsxs(W5,{className:"cost-modal-popup relative w-full max-w-[460px] max-h-[calc(100vh-2rem)] flex flex-col rounded-2xl bg-white dark:bg-oai-gray-950 shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)] ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 overflow-hidden",children:[p.jsx(q5,{render:p.jsx("h2",{className:"sr-only"}),children:O("dashboard.cost_breakdown.title")}),p.jsx(zre,{type:"button",className:"absolute top-3 right-3 flex h-9 w-9 items-center justify-center rounded-md text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-800 dark:hover:text-oai-gray-100 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/50 transition-colors z-10","aria-label":O("dashboard.cost_breakdown.close"),children:p.jsx(Pk,{size:16,strokeWidth:2,"aria-hidden":!0})}),p.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto oai-scrollbar",children:p.jsxs("div",{className:"px-3 py-6",children:[p.jsx("p",{className:"text-label uppercase tracking-[0.12em] text-oai-gray-500 dark:text-oai-gray-400 mb-2",children:O("dashboard.cost_breakdown.total_label")}),p.jsx("p",{className:"font-bold text-oai-brand tabular-nums tracking-tight leading-none mb-6",style:{fontSize:"clamp(24px, 6.5vw, 32px)"},children:s}),i.length===0?p.jsx("p",{className:"text-body-sm text-oai-gray-500 dark:text-oai-gray-400",children:"No spend recorded."}):p.jsxs("div",{role:"table","aria-label":O("dashboard.cost_breakdown.title"),children:[p.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-2 mb-2 border-b border-oai-gray-200 dark:border-oai-gray-800 text-label uppercase text-oai-gray-500 dark:text-oai-gray-400",children:[p.jsx("span",{role:"columnheader",children:"Model"}),p.jsx("span",{role:"columnheader",children:"Cost"})]}),i.map((a,o)=>{const c=`fleet-${o}`;return p.jsxs("div",{role:"rowgroup","aria-labelledby":c,className:o>0?"mt-5":"mt-2",children:[p.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-2",children:[p.jsx("span",{id:c,role:"rowheader",className:"flex-1 min-w-0 text-body-sm font-semibold text-oai-black dark:text-oai-white truncate leading-none",children:a.label}),p.jsx("span",{role:"cell",className:"shrink-0 text-body-sm font-semibold text-oai-black dark:text-oai-white tabular-nums leading-none",children:a.usdLabel||"—"})]}),a.models.map((u,f)=>p.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-[5px]",children:[p.jsx("span",{role:"cell",className:"flex-1 min-w-0 text-caption text-oai-gray-500 dark:text-oai-gray-400 truncate leading-none",title:u.name,children:u.name}),p.jsx("span",{role:"cell",className:"shrink-0 text-caption text-oai-gray-700 dark:text-oai-gray-300 tabular-nums leading-none",children:u.costLabel||""})]},u.id||`${u.name}-${f}`))]},`${a.label}-${o}`)})]})]})})]})})]})})});function lie({projectEntries:t=[],projectLimit:e=3,onProjectLimitChange:n,copy:r,hasDetailsActual:i,dailyEmptyPrefix:s,installSyncCmd:a,dailyEmptySuffix:o,detailsColumns:c,ariaSortFor:u,toggleSort:f,sortIconFor:h,pagedDetails:m,dailyBreakdownRows:g=[],dailyBreakdownColumns:v=[],dailyBreakdownAriaSortFor:w,dailyBreakdownSortIconFor:b,dailyBreakdownDateKey:_="day",detailsDateKey:E,renderDetailDate:M,renderDailyBreakdownDate:T,renderDetailCell:R,DETAILS_PAGED_PERIODS:A,period:P,detailsPageCount:k,detailsPage:N,setDetailsPage:B}){const[L,z]=x.useState("daily");return p.jsxs(pu,{children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[p.jsxs("div",{role:"tablist","aria-label":"Data view",className:"flex gap-1",children:[p.jsx("button",{role:"tab","aria-selected":L==="daily",type:"button",onClick:()=>z("daily"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${L==="daily"?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/50"}`,children:r("dashboard.daily.title")}),p.jsx("button",{role:"tab","aria-selected":L==="projects",type:"button",onClick:()=>z("projects"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${L==="projects"?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/50"}`,children:r("dashboard.projects.title")})]}),L==="projects"&&p.jsxs("select",{"aria-label":"Number of projects to display",value:e,onChange:I=>n?.(Number(I.target.value)),className:"text-xs text-oai-gray-600 dark:text-oai-gray-300 bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded px-2 py-1 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 focus:border-oai-brand dark:focus:border-oai-brand focus:outline-none transition-colors",children:[p.jsx("option",{value:3,children:r("dashboard.projects.limit_top_3")}),p.jsx("option",{value:6,children:r("dashboard.projects.limit_top_6")}),p.jsx("option",{value:10,children:r("dashboard.projects.limit_top_10")})]})]}),L==="projects"&&p.jsx("div",{className:"space-y-1",children:t.slice(0,e).map(I=>p.jsxs("a",{href:I?.project_ref||"#",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-2 rounded-lg hover:oai-bg-elevated transition-colors",children:[p.jsx("div",{className:"w-8 h-8 rounded-md oai-bg-elevated flex items-center justify-center oai-text-caption font-medium text-oai-gray-500 dark:text-oai-gray-300",children:(I?.project_key?.[0]||"?").toUpperCase()}),p.jsx("div",{className:"min-w-0 flex-1",children:p.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white truncate",children:I?.project_key||I?.project_ref?.split("/")?.pop()||"—"})}),p.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",children:(()=>{const V=I?.billable_total_tokens??I?.total_tokens,W=Number(V);return Number.isFinite(W)?W.toLocaleString():"—"})()})]},I?.project_key||I?.project_ref))}),L==="daily"&&p.jsxs("div",{children:[g?.length===0?p.jsxs("div",{className:"oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300 mb-4",children:[s,p.jsx("code",{className:"mx-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 oai-bg-elevated px-1.5 py-0.5 font-mono oai-text-caption",children:a}),o]}):p.jsx("div",{className:"overflow-auto max-h-[384px] -mx-4 oai-scrollbar",children:p.jsxs("table",{className:"w-full border-collapse",children:[p.jsx("thead",{className:"sticky top-0 z-10",children:p.jsx("tr",{className:"border-b border-oai-gray-200 dark:border-oai-gray-700",children:v.map(I=>p.jsx("th",{"aria-sort":w?.(I.key)||"none",className:"text-left p-0 bg-white dark:bg-oai-gray-900",children:p.jsx("button",{type:"button",onClick:()=>f(I.key),className:"flex w-full items-center justify-start px-4 py-2 text-left oai-text-caption font-semibold text-oai-gray-600 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white transition-colors",children:p.jsxs("span",{className:"inline-flex items-center gap-1",children:[p.jsx("span",{children:I.label}),p.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-400",children:b?.(I.key)||""})]})})},I.key))})}),p.jsx("tbody",{children:g.map(I=>p.jsxs("tr",{className:`border-b border-oai-gray-100 dark:border-oai-gray-800 last:border-b-0 hover:bg-oai-gray-50/50 dark:hover:bg-oai-gray-800/50 transition-colors ${I.missing?"text-oai-gray-400 dark:text-oai-gray-400":I.future?"text-oai-gray-300 dark:text-oai-gray-600":"text-oai-black dark:text-oai-white"}`,children:[p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300",children:T?T(I):M(I)}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",children:R(I,"total_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:R(I,"input_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:R(I,"output_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:R(I,"cached_input_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:R(I,"reasoning_output_tokens")}),p.jsx("td",{className:"px-4 py-2 oai-text-body-sm text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:R(I,"conversation_count")})]},String(I?.[_]||I?.day||I?.hour||I?.month||"")))})]})}),L!=="daily"&&A.has(P)&&k>1?p.jsxs("div",{className:"mt-3 flex items-center justify-between oai-text-caption",children:[p.jsx("button",{type:"button",onClick:()=>B(I=>Math.max(0,I-1)),disabled:N===0,className:"px-3 py-1.5 text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 rounded-md disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("details.pagination.prev")}),p.jsxs("span",{className:"oai-text-muted",children:[N+1," / ",k]}),p.jsx("button",{type:"button",onClick:()=>B(I=>Math.min(k-1,I+1)),disabled:N+1>=k,className:"px-3 py-1.5 text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 rounded-md disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("details.pagination.next")})]}):null]})]})}function k0(t){return typeof t!="string"?"":t.trim()}function fP(t){const e=k0(t);return e?e.split(/[_\-\s]+/).filter(Boolean).map(n=>n.slice(0,1).toUpperCase()+n.slice(1).toLowerCase()).join(" "):""}function cie(t){if(!Array.isArray(t))return[];const e=new Map;for(const n of t){if(!n||typeof n!="object")continue;const r=k0(n.tool),i=k0(n.planType)||k0(n.plan_type);if(!r||!i)continue;const s=fP(r)||r,a=fP(i)||i;e.set(`${r.toLowerCase()}::${i.toLowerCase()}`,{tool:s,plan:a})}return Array.from(e.values())}function uie({period:t="month",rankLabel:e,streakDays:n,subscriptions:r=[],periodConversations:i,rolling:s,topModels:a=[],className:o=""}){const c=O("shared.placeholder.short"),u=O("shared.unit.percent"),f=e??O("identity_card.rank_placeholder"),h=Number.isFinite(Number(n))?Number(n):0,m=h?O("identity_card.streak_value",{days:h}):O("identity_card.rank_placeholder"),g=cie(r),v={thousandSuffix:O("shared.unit.thousand_abbrev"),millionSuffix:O("shared.unit.million_abbrev"),billionSuffix:O("shared.unit.billion_abbrev")},w=E=>{if(E==null)return c;const M=Ms(E,v);return M==="-"?c:M},b=(()=>{switch(t){case"day":return O("stats.period.today");case"week":return O("stats.period.week");case"month":return O("stats.period.month");case"total":return O("stats.period.all");default:return O("stats.period.convs")}})(),_=a.slice(0,3);return p.jsxs(pu,{className:`h-full ${o}`,children:[p.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[p.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:w(s?.last_7d?.totals?.billable_total_tokens)}),p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:"7d"})]}),p.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:w(s?.last_30d?.totals?.billable_total_tokens)}),p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:"30d"})]}),p.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:w(s?.last_30d?.avg_per_active_day)}),p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:"avg"})]}),p.jsxs("div",{className:"flex flex-col items-center justify-center px-2 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 rounded-lg",children:[p.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums",children:w(i)}),p.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400 mt-0.5 whitespace-nowrap",children:b})]})]}),_.length>0&&p.jsx("div",{className:"mt-4 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800",children:_.map((E,M)=>{const T=E?.name?String(E.name):c,R=E?.percent?String(E.percent):"",A=M===_.length-1,P=M+1;return p.jsxs("div",{className:`flex items-center py-2 ${A?"":"border-b border-oai-gray-50 dark:border-oai-gray-800"}`,children:[p.jsx("span",{className:"w-5 h-5 flex items-center justify-center rounded-full bg-oai-gray-100 dark:bg-oai-gray-800 text-[10px] font-semibold text-oai-gray-500 dark:text-oai-gray-300 flex-shrink-0",children:P}),p.jsx("span",{className:"flex-1 text-sm text-oai-gray-700 dark:text-oai-gray-300 truncate px-2.5",title:T,children:T}),p.jsxs("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white tabular-nums flex-shrink-0",children:[R,u]})]},E.id||T)})}),g.length>0&&p.jsx("div",{className:"mt-3 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800 flex flex-wrap gap-1.5",children:g.map((E,M)=>p.jsxs(jre,{variant:"secondary",size:"sm",children:[E.tool," ",E.plan]},`${E.tool}:${E.plan}:${M}`))}),p.jsxs("div",{className:"mt-4 pt-3 border-t border-oai-gray-100 dark:border-oai-gray-800 flex items-center justify-between text-xs text-oai-gray-400 dark:text-oai-gray-400",children:[p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx("span",{children:O("identity_card.rank_label")}),p.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:f})]}),p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("span",{children:O("identity_card.streak_label")}),p.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:m})]})]})]})}const K5=x.createContext(void 0);function jp(t){const e=x.useContext(K5);if(e===void 0&&!t)throw new Error(Wi(47));return e}function die(){return{...l5(),disabled:!1,modal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1}}const fie={...c5,disabled:Rt(t=>t.disabled),instantType:Rt(t=>t.instantType),openMethod:Rt(t=>t.openMethod),openChangeReason:Rt(t=>t.openChangeReason),modal:Rt(t=>t.modal),stickIfOpen:Rt(t=>t.stickIfOpen),titleElementId:Rt(t=>t.titleElementId),descriptionElementId:Rt(t=>t.descriptionElementId),openOnHover:Rt(t=>t.openOnHover),closeDelay:Rt(t=>t.closeDelay),hasViewport:Rt(t=>t.hasViewport)};class FE extends fE{constructor(e){const n={...die(),...e};n.open&&e?.mounted===void 0&&(n.mounted=!0),super(n,{popupRef:x.createRef(),backdropRef:x.createRef(),internalBackdropRef:x.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:x.createRef(),beforeContentFocusGuardRef:x.createRef(),stickIfOpenTimeout:new Il,triggerElements:new sv},fie)}setOpen=(e,n)=>{const r=n.reason===ss,i=n.reason===Pl&&n.event.detail===0,s=!e&&(n.reason===H4||n.reason==null);if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},this.context.onOpenChange?.(e,n),n.isCanceled)return;const a={open:e,nativeEvent:n.event,reason:n.reason,nested:this.state.nested,triggerElement:n.trigger};this.state.floatingRootContext.context.events?.emit("openchange",a);const c=()=>{const u={open:e,openChangeReason:n.reason},f=n.trigger?.id??null;(f||e)&&(u.activeTriggerId=f,u.activeTriggerElement=n.trigger??null),this.update(u)};r?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(oee,()=>{this.set("stickIfOpen",!1)}),gi.flushSync(c)):c(),i||s?this.set("instantType",i?"click":"dismiss"):n.reason===eu?this.set("instantType","focus"):this.set("instantType",void 0)};static useStore(e,n){const r=Vi(()=>new FE(n)).current,i=e??r;return hE(r.disposeEffect),i}disposeEffect=()=>this.context.stickIfOpenTimeout.disposeEffect()}function hP({props:t}){const{children:e,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:s,modal:a=!1,handle:o,triggerId:c,defaultTriggerId:u=null}=t,f=FE.useStore(o?.store,{open:n??r,modal:a,activeTriggerId:c!==void 0?c:u});f.useControlledProp("open",n,r),f.useControlledProp("activeTriggerId",c,u);const h=f.useState("open"),m=f.useState("positionerElement"),g=f.useState("payload"),v=f.useState("openChangeReason");f.useContextCallback("onOpenChange",i),f.useContextCallback("onOpenChangeComplete",s);const{openMethod:w,triggerProps:b,reset:_}=RE(h);a5(f);const{forceUnmount:E}=o5(h,f,()=>{f.update({stickIfOpen:!0,openChangeReason:null}),_()});NE(h&&a===!0&&v!==ss&&w!=="touch",m),x.useEffect(()=>{h||f.context.stickIfOpenTimeout.clear()},[f,h]);const M=x.useCallback(W=>{const X=Mn(W);return X.preventUnmountOnClose=()=>{f.set("preventUnmountingOnClose",!0)},X},[f]),T=x.useCallback(()=>{f.setOpen(!1,M(W4))},[f,M]);x.useImperativeHandle(t.actionsRef,()=>({unmount:E,close:T}),[E,T]);const R=d5({popupStore:f,onOpenChange:f.setOpen}),A=ME(R,{outsidePressEvent:{mouse:a==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),P=h5(R),{getReferenceProps:k,getFloatingProps:N,getTriggerProps:B}=av([A,P]),L=x.useMemo(()=>k(b),[k,b]),z=x.useMemo(()=>B(b),[B,b]),I=x.useMemo(()=>N(),[N]);f.useSyncedValues({modal:a,openMethod:w,activeTriggerProps:L,inactiveTriggerProps:z,popupProps:I,floatingRootContext:R,nested:Hl()!=null});const V=x.useMemo(()=>({store:f}),[f]);return p.jsx(K5.Provider,{value:V,children:typeof e=="function"?e({payload:g}):e})}function Z5(t){return jp(!0)?p.jsx(hP,{props:t}):p.jsx(aee,{children:p.jsx(hP,{props:t})})}const hie=300,J5=x.forwardRef(function(e,n){const{render:r,className:i,disabled:s=!1,nativeButton:a=!0,handle:o,payload:c,openOnHover:u=!1,delay:f=hie,closeDelay:h=0,id:m,...g}=e,v=jp(!0),w=o?.store??v?.store;if(!w)throw new Error(Wi(74));const b=lv(m),_=w.useState("isTriggerActive",b),E=w.useState("floatingRootContext"),M=w.useState("isOpenedByTrigger",b),T=x.useRef(null),{registerTrigger:R,isMountedByThisTrigger:A}=Cte(b,T,w,{payload:c,disabled:s,openOnHover:u,closeDelay:h}),P=w.useState("openChangeReason"),k=w.useState("stickIfOpen"),N=w.useState("openMethod"),B=Fte(E,{enabled:E!=null&&u&&(N!=="touch"||P!==Pl),mouseOnly:!0,move:!1,handleClose:Gte(),restMs:f,delay:{close:h},triggerElementRef:T,isActiveTrigger:_}),L=K4(E,{enabled:E!=null,stickIfOpen:k}),z=av([L]),I=w.useState("triggerProps",A),V=x.useMemo(()=>({disabled:s,open:M}),[s,M]),{getButtonProps:W,buttonRef:X}=cv({disabled:s,native:a}),J=x.useMemo(()=>({open(te){return te&&P===Pl?S5.open(te):w5.open(te)}}),[P]),F=Xr("button",e,{state:V,ref:[X,n,R,T],props:[z.getReferenceProps(),B,I,{[V4]:"",id:b},g,W],stateAttributesMapping:J}),G=x.useRef(null),Y=Bt(te=>{gi.flushSync(()=>{w.setOpen(!1,Mn(eu,te.nativeEvent,te.currentTarget))}),QQ(G.current)?.focus()}),H=Bt(te=>{const re=w.select("positionerElement");if(re&&Rd(te,re))w.context.beforeContentFocusGuardRef.current?.focus();else{gi.flushSync(()=>{w.setOpen(!1,Mn(eu,te.nativeEvent,te.currentTarget))});let ue=JQ(w.context.triggerFocusTargetRef.current||T.current);for(;ue!==null&&On(re,ue);){const ce=ue;if(ue=bE(ue),ue===ce)break}ue?.focus()}});return _?p.jsxs(x.Fragment,{children:[p.jsx(Gd,{ref:G,onFocus:Y}),p.jsx(x.Fragment,{children:F},b),p.jsx(Gd,{ref:w.context.triggerFocusTargetRef,onFocus:H})]}):p.jsx(x.Fragment,{children:F},b)}),Q5=x.createContext(void 0);function pie(){const t=x.useContext(Q5);if(t===void 0)throw new Error(Wi(45));return t}const eF=x.forwardRef(function(e,n){const{keepMounted:r=!1,...i}=e,{store:s}=jp();return s.useState("mounted")||r?p.jsx(Q5.Provider,{value:r,children:p.jsx(wE,{ref:n,...i,renderGuards:!1})}):null}),tF=x.createContext(void 0);function mie(){const t=x.useContext(tF);if(!t)throw new Error(Wi(46));return t}const nF=x.forwardRef(function(e,n){const{render:r,className:i,anchor:s,positionMethod:a="absolute",side:o="bottom",align:c="center",sideOffset:u=0,alignOffset:f=0,collisionBoundary:h="clipping-ancestors",collisionPadding:m=5,arrowPadding:g=5,sticky:v=!1,disableAnchorTracking:w=!1,collisionAvoidance:b=uee,..._}=e,{store:E}=jp(),M=pie(),T=iee(),R=E.useState("floatingRootContext"),A=E.useState("mounted"),P=E.useState("open"),k=E.useState("openChangeReason"),N=E.useState("activeTriggerElement"),B=E.useState("modal"),L=E.useState("positionerElement"),z=E.useState("instantType"),I=E.useState("transitionStatus"),V=E.useState("hasViewport"),W=x.useRef(null),X=s5(L,!1,!1),J=M5({anchor:s,floatingRootContext:R,positionMethod:a,mounted:A,side:o,sideOffset:u,align:c,alignOffset:f,arrowPadding:g,collisionBoundary:h,collisionPadding:m,sticky:v,disableAnchorTracking:w,keepMounted:M,nodeId:T,collisionAvoidance:b,adaptiveOrigin:V?zne:void 0}),F=x.useMemo(()=>{const ue={};return P||(ue.pointerEvents="none"),{role:"presentation",hidden:!A,style:{...J.positionerStyles,...ue}}},[P,A,J.positionerStyles]),G=x.useMemo(()=>({props:F,...J}),[F,J]),Y=R?.select("domReferenceElement");Yt(()=>{const ue=Y,ce=W.current;if(ue&&(W.current=ue),ce&&ue&&ue!==ce){E.set("instantType",void 0);const ee=new AbortController;return X(()=>{E.set("instantType","trigger-change")},ee.signal),()=>{ee.abort()}}},[Y,X,E]);const H=x.useMemo(()=>({open:P,side:G.side,align:G.align,anchorHidden:G.anchorHidden,instant:z}),[P,G.side,G.align,G.anchorHidden,z]),te=x.useCallback(ue=>{E.set("positionerElement",ue)},[E]),re=Xr("div",e,{state:H,props:[G.props,IE(I),_],ref:[n,te],stateAttributesMapping:hu});return p.jsxs(tF.Provider,{value:G,children:[A&&B===!0&&k!==ss&&p.jsx(DE,{ref:E.context.internalBackdropRef,inert:PE(!P),cutout:N}),p.jsx(see,{id:T,children:re})]})}),gie={...hu,...df},rF=x.forwardRef(function(e,n){const{className:r,render:i,initialFocus:s,finalFocus:a,...o}=e,{store:c}=jp(),u=mie(),f=A5()!=null,h=c.useState("open"),m=c.useState("openMethod"),g=c.useState("instantType"),v=c.useState("transitionStatus"),w=c.useState("popupProps"),b=c.useState("titleElementId"),_=c.useState("descriptionElementId"),E=c.useState("modal"),M=c.useState("mounted"),T=c.useState("openChangeReason"),R=c.useState("activeTriggerElement"),A=c.useState("floatingRootContext");ff({open:h,ref:c.context.popupRef,onComplete(){h&&c.context.onOpenChangeComplete?.(!0)}});const P=c.useState("disabled"),k=c.useState("openOnHover"),N=c.useState("closeDelay");Lte(A,{enabled:k&&!P,closeDelay:N});function B(W){return W==="touch"?c.context.popupRef.current:!0}const L=s===void 0?B:s,z=x.useMemo(()=>({open:h,side:u.side,align:u.align,instant:g,transitionStatus:v}),[h,u.side,u.align,g,v]),I=x.useCallback(W=>{c.set("popupElement",W)},[c]),V=Xr("div",e,{state:z,ref:[n,c.context.popupRef,I],props:[w,{"aria-labelledby":b,"aria-describedby":_,onKeyDown(W){f&&LE.has(W.key)&&W.stopPropagation()}},IE(v),o],stateAttributesMapping:gie});return p.jsx(kE,{context:A,openInteractionType:m,modal:E==="trap-focus",disabled:!M||T===ss,initialFocus:L,returnFocus:a,restoreFocus:"popup",previousFocusableElement:Ar(R)?R:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:V})});function yie(t,e,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:t,timeZoneName:n}).format(e).split(/\s/g).slice(2).join(" ")}const vie={},Ah={};function Dc(t,e){try{const r=(vie[t]||=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"longOffset"}).format)(e).split("GMT")[1];return r in Ah?Ah[r]:pP(r,r.split(":"))}catch{if(t in Ah)return Ah[t];const n=t?.match(xie);return n?pP(t,n.slice(1)):NaN}}const xie=/([+-]\d\d):?(\d\d)?/;function pP(t,e){const n=+(e[0]||0),r=+(e[1]||0),i=+(e[2]||0)/60;return Ah[t]=n*60+r>0?n*60+r+i:n*60-r-i}class Pa extends Date{constructor(...e){super(),e.length>1&&typeof e[e.length-1]=="string"&&(this.timeZone=e.pop()),this.internal=new Date,isNaN(Dc(this.timeZone,this))?this.setTime(NaN):e.length?typeof e[0]=="number"&&(e.length===1||e.length===2&&typeof e[1]!="number")?this.setTime(e[0]):typeof e[0]=="string"?this.setTime(+new Date(e[0])):e[0]instanceof Date?this.setTime(+e[0]):(this.setTime(+new Date(...e)),iF(this),N1(this)):this.setTime(Date.now())}static tz(e,...n){return n.length?new Pa(...n,e):new Pa(Date.now(),e)}withTimeZone(e){return new Pa(+this,e)}getTimezoneOffset(){const e=-Dc(this.timeZone,this);return e>0?Math.floor(e):Math.ceil(e)}setTime(e){return Date.prototype.setTime.apply(this,arguments),N1(this),+this}[Symbol.for("constructDateFrom")](e){return new Pa(+new Date(e),this.timeZone)}}const mP=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(t=>{if(!mP.test(t))return;const e=t.replace(mP,"$1UTC");Pa.prototype[e]&&(t.startsWith("get")?Pa.prototype[t]=function(){return this.internal[e]()}:(Pa.prototype[t]=function(){return Date.prototype[e].apply(this.internal,arguments),bie(this),+this},Pa.prototype[e]=function(){return Date.prototype[e].apply(this,arguments),N1(this),+this}))});function N1(t){t.internal.setTime(+t),t.internal.setUTCSeconds(t.internal.getUTCSeconds()-Math.round(-Dc(t.timeZone,t)*60))}function bie(t){Date.prototype.setFullYear.call(t,t.internal.getUTCFullYear(),t.internal.getUTCMonth(),t.internal.getUTCDate()),Date.prototype.setHours.call(t,t.internal.getUTCHours(),t.internal.getUTCMinutes(),t.internal.getUTCSeconds(),t.internal.getUTCMilliseconds()),iF(t)}function iF(t){const e=Dc(t.timeZone,t),n=e>0?Math.floor(e):Math.ceil(e),r=new Date(+t);r.setUTCHours(r.getUTCHours()-1);const i=-new Date(+t).getTimezoneOffset(),s=-new Date(+r).getTimezoneOffset(),a=i-s,o=Date.prototype.getHours.apply(t)!==t.internal.getUTCHours();a&&o&&t.internal.setUTCMinutes(t.internal.getUTCMinutes()+a);const c=i-n;c&&Date.prototype.setUTCMinutes.call(t,Date.prototype.getUTCMinutes.call(t)+c);const u=new Date(+t);u.setUTCSeconds(0);const f=i>0?u.getSeconds():(u.getSeconds()-60)%60,h=Math.round(-(Dc(t.timeZone,t)*60))%60;(h||f)&&(t.internal.setUTCSeconds(t.internal.getUTCSeconds()+h),Date.prototype.setUTCSeconds.call(t,Date.prototype.getUTCSeconds.call(t)+h+f));const m=Dc(t.timeZone,t),g=m>0?Math.floor(m):Math.ceil(m),w=-new Date(+t).getTimezoneOffset()-g,b=g!==n,_=w-c;if(b&&_){Date.prototype.setUTCMinutes.call(t,Date.prototype.getUTCMinutes.call(t)+_);const E=Dc(t.timeZone,t),M=E>0?Math.floor(E):Math.ceil(E),T=g-M;T&&(t.internal.setUTCMinutes(t.internal.getUTCMinutes()+T),Date.prototype.setUTCMinutes.call(t,Date.prototype.getUTCMinutes.call(t)+T))}}class mi extends Pa{static tz(e,...n){return n.length?new mi(...n,e):new mi(Date.now(),e)}toISOString(){const[e,n,r]=this.tzComponents(),i=`${e}${n}:${r}`;return this.internal.toISOString().slice(0,-1)+i}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[e,n,r,i]=this.internal.toUTCString().split(" ");return`${e?.slice(0,-1)} ${r} ${n} ${i}`}toTimeString(){const e=this.internal.toUTCString().split(" ")[4],[n,r,i]=this.tzComponents();return`${e} GMT${n}${r}${i} (${yie(this.timeZone,this)})`}toLocaleString(e,n){return Date.prototype.toLocaleString.call(this,e,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleDateString(e,n){return Date.prototype.toLocaleDateString.call(this,e,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleTimeString(e,n){return Date.prototype.toLocaleTimeString.call(this,e,{...n,timeZone:n?.timeZone||this.timeZone})}tzComponents(){const e=this.getTimezoneOffset(),n=e>0?"-":"+",r=String(Math.floor(Math.abs(e)/60)).padStart(2,"0"),i=String(Math.abs(e)%60).padStart(2,"0");return[n,r,i]}withTimeZone(e){return new mi(+this,e)}[Symbol.for("constructDateFrom")](e){return new mi(+new Date(e),this.timeZone)}}const sF=6048e5,_ie=864e5,gP=Symbol.for("constructDateFrom");function Dr(t,e){return typeof t=="function"?t(e):t&&typeof t=="object"&&gP in t?t[gP](e):t instanceof Date?new t.constructor(e):new Date(e)}function Jn(t,e){return Dr(e||t,t)}function aF(t,e,n){const r=Jn(t,n?.in);return isNaN(e)?Dr(t,NaN):(e&&r.setDate(r.getDate()+e),r)}function oF(t,e,n){const r=Jn(t,n?.in);if(isNaN(e))return Dr(t,NaN);if(!e)return r;const i=r.getDate(),s=Dr(t,r.getTime());s.setMonth(r.getMonth()+e+1,0);const a=s.getDate();return i>=a?s:(r.setFullYear(s.getFullYear(),s.getMonth(),i),r)}let wie={};function Bp(){return wie}function Yd(t,e){const n=Bp(),r=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Jn(t,e?.in),s=i.getDay(),a=(s<r?7:0)+s-r;return i.setDate(i.getDate()-a),i.setHours(0,0,0,0),i}function cp(t,e){return Yd(t,{...e,weekStartsOn:1})}function lF(t,e){const n=Jn(t,e?.in),r=n.getFullYear(),i=Dr(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);const s=cp(i),a=Dr(n,0);a.setFullYear(r,0,4),a.setHours(0,0,0,0);const o=cp(a);return n.getTime()>=s.getTime()?r+1:n.getTime()>=o.getTime()?r:r-1}function yP(t){const e=Jn(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function hf(t,...e){const n=Dr.bind(null,e.find(r=>typeof r=="object"));return e.map(n)}function up(t,e){const n=Jn(t,e?.in);return n.setHours(0,0,0,0),n}function UE(t,e,n){const[r,i]=hf(n?.in,t,e),s=up(r),a=up(i),o=+s-yP(s),c=+a-yP(a);return Math.round((o-c)/_ie)}function Sie(t,e){const n=lF(t,e),r=Dr(t,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),cp(r)}function kie(t,e,n){return aF(t,e*7,n)}function Eie(t,e,n){return oF(t,e*12,n)}function Mie(t,e){let n,r=e?.in;return t.forEach(i=>{!r&&typeof i=="object"&&(r=Dr.bind(null,i));const s=Jn(i,r);(!n||n<s||isNaN(+s))&&(n=s)}),Dr(r,n||NaN)}function Tie(t,e){let n,r=e?.in;return t.forEach(i=>{!r&&typeof i=="object"&&(r=Dr.bind(null,i));const s=Jn(i,r);(!n||n>s||isNaN(+s))&&(n=s)}),Dr(r,n||NaN)}function Cie(t,e,n){const[r,i]=hf(n?.in,t,e);return+up(r)==+up(i)}function cF(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function Aie(t){return!(!cF(t)&&typeof t!="number"||isNaN(+Jn(t)))}function uF(t,e,n){const[r,i]=hf(n?.in,t,e),s=r.getFullYear()-i.getFullYear(),a=r.getMonth()-i.getMonth();return s*12+a}function Rie(t,e){const n=Jn(t,e?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function dF(t,e){const[n,r]=hf(t,e.start,e.end);return{start:n,end:r}}function Pie(t,e){const{start:n,end:r}=dF(e?.in,t);let i=+n>+r;const s=i?+n:+r,a=i?r:n;a.setHours(0,0,0,0),a.setDate(1);let o=1;const c=[];for(;+a<=s;)c.push(Dr(n,a)),a.setMonth(a.getMonth()+o);return i?c.reverse():c}function Nie(t,e){const n=Jn(t,e?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function Die(t,e){const n=Jn(t,e?.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function fF(t,e){const n=Jn(t,e?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Lie(t,e){const{start:n,end:r}=dF(e?.in,t);let i=+n>+r;const s=i?+n:+r,a=i?r:n;a.setHours(0,0,0,0),a.setMonth(0,1);let o=1;const c=[];for(;+a<=s;)c.push(Dr(n,a)),a.setFullYear(a.getFullYear()+o);return i?c.reverse():c}function hF(t,e){const n=Bp(),r=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Jn(t,e?.in),s=i.getDay(),a=(s<r?-7:0)+6-(s-r);return i.setDate(i.getDate()+a),i.setHours(23,59,59,999),i}function Iie(t,e){return hF(t,{...e,weekStartsOn:1})}const Oie={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Fie=(t,e,n)=>{let r;const i=Oie[t];return typeof i=="string"?r=i:e===1?r=i.one:r=i.other.replace("{{count}}",e.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function m_(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const Uie={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},jie={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Bie={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},zie={date:m_({formats:Uie,defaultWidth:"full"}),time:m_({formats:jie,defaultWidth:"full"}),dateTime:m_({formats:Bie,defaultWidth:"full"})},Vie={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Hie=(t,e,n,r)=>Vie[t];function dh(t){return(e,n)=>{const r=n?.context?String(n.context):"standalone";let i;if(r==="formatting"&&t.formattingValues){const a=t.defaultFormattingWidth||t.defaultWidth,o=n?.width?String(n.width):a;i=t.formattingValues[o]||t.formattingValues[a]}else{const a=t.defaultWidth,o=n?.width?String(n.width):t.defaultWidth;i=t.values[o]||t.values[a]}const s=t.argumentCallback?t.argumentCallback(e):e;return i[s]}}const Wie={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Gie={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},$ie={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Yie={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},qie={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Xie={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Kie=(t,e)=>{const n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},Zie={ordinalNumber:Kie,era:dh({values:Wie,defaultWidth:"wide"}),quarter:dh({values:Gie,defaultWidth:"wide",argumentCallback:t=>t-1}),month:dh({values:$ie,defaultWidth:"wide"}),day:dh({values:Yie,defaultWidth:"wide"}),dayPeriod:dh({values:qie,defaultWidth:"wide",formattingValues:Xie,defaultFormattingWidth:"wide"})};function fh(t){return(e,n={})=>{const r=n.width,i=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],s=e.match(i);if(!s)return null;const a=s[0],o=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],c=Array.isArray(o)?Qie(o,h=>h.test(a)):Jie(o,h=>h.test(a));let u;u=t.valueCallback?t.valueCallback(c):c,u=n.valueCallback?n.valueCallback(u):u;const f=e.slice(a.length);return{value:u,rest:f}}}function Jie(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function Qie(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function ese(t){return(e,n={})=>{const r=e.match(t.matchPattern);if(!r)return null;const i=r[0],s=e.match(t.parsePattern);if(!s)return null;let a=t.valueCallback?t.valueCallback(s[0]):s[0];a=n.valueCallback?n.valueCallback(a):a;const o=e.slice(i.length);return{value:a,rest:o}}}const tse=/^(\d+)(th|st|nd|rd)?/i,nse=/\d+/i,rse={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},ise={any:[/^b/i,/^(a|c)/i]},sse={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ase={any:[/1/i,/2/i,/3/i,/4/i]},ose={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},lse={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},cse={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},use={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},dse={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},fse={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},hse={ordinalNumber:ese({matchPattern:tse,parsePattern:nse,valueCallback:t=>parseInt(t,10)}),era:fh({matchPatterns:rse,defaultMatchWidth:"wide",parsePatterns:ise,defaultParseWidth:"any"}),quarter:fh({matchPatterns:sse,defaultMatchWidth:"wide",parsePatterns:ase,defaultParseWidth:"any",valueCallback:t=>t+1}),month:fh({matchPatterns:ose,defaultMatchWidth:"wide",parsePatterns:lse,defaultParseWidth:"any"}),day:fh({matchPatterns:cse,defaultMatchWidth:"wide",parsePatterns:use,defaultParseWidth:"any"}),dayPeriod:fh({matchPatterns:dse,defaultMatchWidth:"any",parsePatterns:fse,defaultParseWidth:"any"})},vd={code:"en-US",formatDistance:Fie,formatLong:zie,formatRelative:Hie,localize:Zie,match:hse,options:{weekStartsOn:0,firstWeekContainsDate:1}};function pse(t,e){const n=Jn(t,e?.in);return UE(n,fF(n))+1}function jE(t,e){const n=Jn(t,e?.in),r=+cp(n)-+Sie(n);return Math.round(r/sF)+1}function pF(t,e){const n=Jn(t,e?.in),r=n.getFullYear(),i=Bp(),s=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,a=Dr(e?.in||t,0);a.setFullYear(r+1,0,s),a.setHours(0,0,0,0);const o=Yd(a,e),c=Dr(e?.in||t,0);c.setFullYear(r,0,s),c.setHours(0,0,0,0);const u=Yd(c,e);return+n>=+o?r+1:+n>=+u?r:r-1}function mse(t,e){const n=Bp(),r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=pF(t,e),s=Dr(e?.in||t,0);return s.setFullYear(i,0,r),s.setHours(0,0,0,0),Yd(s,e)}function BE(t,e){const n=Jn(t,e?.in),r=+Yd(n,e)-+mse(n,e);return Math.round(r/sF)+1}function Xn(t,e){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(e,"0");return n+r}const ol={y(t,e){const n=t.getFullYear(),r=n>0?n:1-n;return Xn(e==="yy"?r%100:r,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):Xn(n+1,2)},d(t,e){return Xn(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return n==="am"?"a.m.":"p.m."}},h(t,e){return Xn(t.getHours()%12||12,e.length)},H(t,e){return Xn(t.getHours(),e.length)},m(t,e){return Xn(t.getMinutes(),e.length)},s(t,e){return Xn(t.getSeconds(),e.length)},S(t,e){const n=e.length,r=t.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return Xn(i,e.length)}},Zu={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},vP={G:function(t,e,n){const r=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});default:return n.era(r,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const r=t.getFullYear(),i=r>0?r:1-r;return n.ordinalNumber(i,{unit:"year"})}return ol.y(t,e)},Y:function(t,e,n,r){const i=pF(t,r),s=i>0?i:1-i;if(e==="YY"){const a=s%100;return Xn(a,2)}return e==="Yo"?n.ordinalNumber(s,{unit:"year"}):Xn(s,e.length)},R:function(t,e){const n=lF(t);return Xn(n,e.length)},u:function(t,e){const n=t.getFullYear();return Xn(n,e.length)},Q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return Xn(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return Xn(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(t,e,n){const r=t.getMonth();switch(e){case"M":case"MM":return ol.M(t,e);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(t,e,n){const r=t.getMonth();switch(e){case"L":return String(r+1);case"LL":return Xn(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(t,e,n,r){const i=BE(t,r);return e==="wo"?n.ordinalNumber(i,{unit:"week"}):Xn(i,e.length)},I:function(t,e,n){const r=jE(t);return e==="Io"?n.ordinalNumber(r,{unit:"week"}):Xn(r,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):ol.d(t,e)},D:function(t,e,n){const r=pse(t);return e==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):Xn(r,e.length)},E:function(t,e,n){const r=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,e,n,r){const i=t.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(s);case"ee":return Xn(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(t,e,n,r){const i=t.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(s);case"cc":return Xn(s,e.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(t,e,n){const r=t.getDay(),i=r===0?7:r;switch(e){case"i":return String(i);case"ii":return Xn(i,e.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(t,e,n){const i=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(t,e,n){const r=t.getHours();let i;switch(r===12?i=Zu.noon:r===0?i=Zu.midnight:i=r/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(t,e,n){const r=t.getHours();let i;switch(r>=17?i=Zu.evening:r>=12?i=Zu.afternoon:r>=4?i=Zu.morning:i=Zu.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let r=t.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return ol.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):ol.H(t,e)},K:function(t,e,n){const r=t.getHours()%12;return e==="Ko"?n.ordinalNumber(r,{unit:"hour"}):Xn(r,e.length)},k:function(t,e,n){let r=t.getHours();return r===0&&(r=24),e==="ko"?n.ordinalNumber(r,{unit:"hour"}):Xn(r,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):ol.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):ol.s(t,e)},S:function(t,e){return ol.S(t,e)},X:function(t,e,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(e){case"X":return bP(r);case"XXXX":case"XX":return kc(r);default:return kc(r,":")}},x:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"x":return bP(r);case"xxxx":case"xx":return kc(r);default:return kc(r,":")}},O:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+xP(r,":");default:return"GMT"+kc(r,":")}},z:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+xP(r,":");default:return"GMT"+kc(r,":")}},t:function(t,e,n){const r=Math.trunc(+t/1e3);return Xn(r,e.length)},T:function(t,e,n){return Xn(+t,e.length)}};function xP(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),i=Math.trunc(r/60),s=r%60;return s===0?n+String(i):n+String(i)+e+Xn(s,2)}function bP(t,e){return t%60===0?(t>0?"-":"+")+Xn(Math.abs(t)/60,2):kc(t,e)}function kc(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),i=Xn(Math.trunc(r/60),2),s=Xn(r%60,2);return n+i+e+s}const _P=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});default:return e.date({width:"full"})}},mF=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});default:return e.time({width:"full"})}},gse=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return _P(t,e);let s;switch(r){case"P":s=e.dateTime({width:"short"});break;case"PP":s=e.dateTime({width:"medium"});break;case"PPP":s=e.dateTime({width:"long"});break;default:s=e.dateTime({width:"full"});break}return s.replace("{{date}}",_P(r,e)).replace("{{time}}",mF(i,e))},yse={p:mF,P:gse},vse=/^D+$/,xse=/^Y+$/,bse=["D","DD","YY","YYYY"];function _se(t){return vse.test(t)}function wse(t){return xse.test(t)}function Sse(t,e,n){const r=kse(t,e,n);if(console.warn(r),bse.includes(t))throw new RangeError(r)}function kse(t,e,n){const r=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Ese=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Mse=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Tse=/^'([^]*?)'?$/,Cse=/''/g,Ase=/[a-zA-Z]/;function Na(t,e,n){const r=Bp(),i=n?.locale??r.locale??vd,s=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,o=Jn(t,n?.in);if(!Aie(o))throw new RangeError("Invalid time value");let c=e.match(Mse).map(f=>{const h=f[0];if(h==="p"||h==="P"){const m=yse[h];return m(f,i.formatLong)}return f}).join("").match(Ese).map(f=>{if(f==="''")return{isToken:!1,value:"'"};const h=f[0];if(h==="'")return{isToken:!1,value:Rse(f)};if(vP[h])return{isToken:!0,value:f};if(h.match(Ase))throw new RangeError("Format string contains an unescaped latin alphabet character `"+h+"`");return{isToken:!1,value:f}});i.localize.preprocessor&&(c=i.localize.preprocessor(o,c));const u={firstWeekContainsDate:s,weekStartsOn:a,locale:i};return c.map(f=>{if(!f.isToken)return f.value;const h=f.value;(!n?.useAdditionalWeekYearTokens&&wse(h)||!n?.useAdditionalDayOfYearTokens&&_se(h))&&Sse(h,e,String(t));const m=vP[h[0]];return m(o,h,i.localize,u)}).join("")}function Rse(t){const e=t.match(Tse);return e?e[1].replace(Cse,"'"):t}function Pse(t,e){const n=Jn(t,e?.in),r=n.getFullYear(),i=n.getMonth(),s=Dr(n,0);return s.setFullYear(r,i+1,0),s.setHours(0,0,0,0),s.getDate()}function Nse(t,e){return Jn(t,e?.in).getMonth()}function Dse(t,e){return Jn(t,e?.in).getFullYear()}function Lse(t,e){return+Jn(t)>+Jn(e)}function Ise(t,e){return+Jn(t)<+Jn(e)}function Ose(t,e,n){const[r,i]=hf(n?.in,t,e);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()}function Fse(t,e,n){const[r,i]=hf(n?.in,t,e);return r.getFullYear()===i.getFullYear()}function Use(t,e,n){const r=Jn(t,n?.in),i=r.getFullYear(),s=r.getDate(),a=Dr(t,0);a.setFullYear(i,e,15),a.setHours(0,0,0,0);const o=Pse(a);return r.setMonth(e,Math.min(s,o)),r}function jse(t,e,n){const r=Jn(t,n?.in);return isNaN(+r)?Dr(t,NaN):(r.setFullYear(e),r)}const wP=5,Bse=4;function zse(t,e){const n=e.startOfMonth(t),r=n.getDay()>0?n.getDay():7,i=e.addDays(t,-r+1),s=e.addDays(i,wP*7-1);return e.getMonth(t)===e.getMonth(s)?wP:Bse}function gF(t,e){const n=e.startOfMonth(t),r=n.getDay();return r===1?n:r===0?e.addDays(n,-6):e.addDays(n,-1*(r-1))}function Vse(t,e){const n=gF(t,e),r=zse(t,e);return e.addDays(n,r*7-1)}const yF={...vd,labels:{labelDayButton:(t,e,n,r)=>{let i;r&&typeof r.format=="function"?i=r.format.bind(r):i=(a,o)=>Na(a,o,{locale:vd,...n});let s=i(t,"PPPP");return e.today&&(s=`Today, ${s}`),e.selected&&(s=`${s}, selected`),s},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:t=>`Week ${t}`,labelYearDropdown:"Choose the Year",labelGrid:(t,e,n)=>{let r;return n&&typeof n.format=="function"?r=n.format.bind(n):r=(i,s)=>Na(i,s,{locale:vd,...e}),r(t,"LLLL yyyy")},labelGridcell:(t,e,n,r)=>{let i;r&&typeof r.format=="function"?i=r.format.bind(r):i=(a,o)=>Na(a,o,{locale:vd,...n});let s=i(t,"PPPP");return e?.today&&(s=`Today, ${s}`),s},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(t,e,n)=>{let r;return n&&typeof n.format=="function"?r=n.format.bind(n):r=(i,s)=>Na(i,s,{locale:vd,...e}),r(t,"cccc")}}};class us{constructor(e,n){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?mi.tz(this.options.timeZone):new this.Date,this.newDate=(r,i,s)=>this.overrides?.newDate?this.overrides.newDate(r,i,s):this.options.timeZone?new mi(r,i,s,this.options.timeZone):new Date(r,i,s),this.addDays=(r,i)=>this.overrides?.addDays?this.overrides.addDays(r,i):aF(r,i),this.addMonths=(r,i)=>this.overrides?.addMonths?this.overrides.addMonths(r,i):oF(r,i),this.addWeeks=(r,i)=>this.overrides?.addWeeks?this.overrides.addWeeks(r,i):kie(r,i),this.addYears=(r,i)=>this.overrides?.addYears?this.overrides.addYears(r,i):Eie(r,i),this.differenceInCalendarDays=(r,i)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(r,i):UE(r,i),this.differenceInCalendarMonths=(r,i)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(r,i):uF(r,i),this.eachMonthOfInterval=r=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(r):Pie(r),this.eachYearOfInterval=r=>{const i=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(r):Lie(r),s=new Set(i.map(o=>this.getYear(o)));if(s.size===i.length)return i;const a=[];return s.forEach(o=>{a.push(new Date(o,0,1))}),a},this.endOfBroadcastWeek=r=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(r):Vse(r,this),this.endOfISOWeek=r=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(r):Iie(r),this.endOfMonth=r=>this.overrides?.endOfMonth?this.overrides.endOfMonth(r):Rie(r),this.endOfWeek=(r,i)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(r,i):hF(r,this.options),this.endOfYear=r=>this.overrides?.endOfYear?this.overrides.endOfYear(r):Die(r),this.format=(r,i,s)=>{const a=this.overrides?.format?this.overrides.format(r,i,this.options):Na(r,i,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(a):a},this.getISOWeek=r=>this.overrides?.getISOWeek?this.overrides.getISOWeek(r):jE(r),this.getMonth=(r,i)=>this.overrides?.getMonth?this.overrides.getMonth(r,this.options):Nse(r,this.options),this.getYear=(r,i)=>this.overrides?.getYear?this.overrides.getYear(r,this.options):Dse(r,this.options),this.getWeek=(r,i)=>this.overrides?.getWeek?this.overrides.getWeek(r,this.options):BE(r,this.options),this.isAfter=(r,i)=>this.overrides?.isAfter?this.overrides.isAfter(r,i):Lse(r,i),this.isBefore=(r,i)=>this.overrides?.isBefore?this.overrides.isBefore(r,i):Ise(r,i),this.isDate=r=>this.overrides?.isDate?this.overrides.isDate(r):cF(r),this.isSameDay=(r,i)=>this.overrides?.isSameDay?this.overrides.isSameDay(r,i):Cie(r,i),this.isSameMonth=(r,i)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(r,i):Ose(r,i),this.isSameYear=(r,i)=>this.overrides?.isSameYear?this.overrides.isSameYear(r,i):Fse(r,i),this.max=r=>this.overrides?.max?this.overrides.max(r):Mie(r),this.min=r=>this.overrides?.min?this.overrides.min(r):Tie(r),this.setMonth=(r,i)=>this.overrides?.setMonth?this.overrides.setMonth(r,i):Use(r,i),this.setYear=(r,i)=>this.overrides?.setYear?this.overrides.setYear(r,i):jse(r,i),this.startOfBroadcastWeek=(r,i)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(r,this):gF(r,this),this.startOfDay=r=>this.overrides?.startOfDay?this.overrides.startOfDay(r):up(r),this.startOfISOWeek=r=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(r):cp(r),this.startOfMonth=r=>this.overrides?.startOfMonth?this.overrides.startOfMonth(r):Nie(r),this.startOfWeek=(r,i)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(r,this.options):Yd(r,this.options),this.startOfYear=r=>this.overrides?.startOfYear?this.overrides.startOfYear(r):fF(r),this.options={locale:yF,...e},this.overrides=n}getDigitMap(){const{numerals:e="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:e}),r={};for(let i=0;i<10;i++)r[i.toString()]=n.format(i);return r}replaceDigits(e){const n=this.getDigitMap();return e.replace(/\d/g,r=>n[r]||r)}formatNumber(e){return this.replaceDigits(e.toString())}getMonthYearOrder(){const e=this.options.locale?.code;return e&&us.yearFirstLocales.has(e)?"year-first":"month-first"}formatMonthYear(e){const{locale:n,timeZone:r,numerals:i}=this.options,s=n?.code;if(s&&us.yearFirstLocales.has(s))try{return new Intl.DateTimeFormat(s,{month:"long",year:"numeric",timeZone:r,numberingSystem:i}).format(e)}catch{}const a=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(e,a)}}us.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const Qa=new us;class vF{constructor(e,n,r=Qa){this.date=e,this.displayMonth=n,this.outside=!!(n&&!r.isSameMonth(e,n)),this.dateLib=r,this.isoDate=r.format(e,"yyyy-MM-dd"),this.displayMonthId=r.format(n,"yyyy-MM"),this.dateMonthId=r.format(e,"yyyy-MM")}isEqualTo(e){return this.dateLib.isSameDay(e.date,this.date)&&this.dateLib.isSameMonth(e.displayMonth,this.displayMonth)}}class Hse{constructor(e,n){this.date=e,this.weeks=n}}class Wse{constructor(e,n){this.days=n,this.weekNumber=e}}function Gse(t){return ot.createElement("button",{...t})}function $se(t){return ot.createElement("span",{...t})}function Yse(t){const{size:e=24,orientation:n="left",className:r}=t;return ot.createElement("svg",{className:r,width:e,height:e,viewBox:"0 0 24 24"},n==="up"&&ot.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&ot.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&ot.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&ot.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function qse(t){const{day:e,modifiers:n,...r}=t;return ot.createElement("td",{...r})}function Xse(t){const{day:e,modifiers:n,...r}=t,i=ot.useRef(null);return ot.useEffect(()=>{n.focused&&i.current?.focus()},[n.focused]),ot.createElement("button",{ref:i,...r})}var Zt;(function(t){t.Root="root",t.Chevron="chevron",t.Day="day",t.DayButton="day_button",t.CaptionLabel="caption_label",t.Dropdowns="dropdowns",t.Dropdown="dropdown",t.DropdownRoot="dropdown_root",t.Footer="footer",t.MonthGrid="month_grid",t.MonthCaption="month_caption",t.MonthsDropdown="months_dropdown",t.Month="month",t.Months="months",t.Nav="nav",t.NextMonthButton="button_next",t.PreviousMonthButton="button_previous",t.Week="week",t.Weeks="weeks",t.Weekday="weekday",t.Weekdays="weekdays",t.WeekNumber="week_number",t.WeekNumberHeader="week_number_header",t.YearsDropdown="years_dropdown"})(Zt||(Zt={}));var fr;(function(t){t.disabled="disabled",t.hidden="hidden",t.outside="outside",t.focused="focused",t.today="today"})(fr||(fr={}));var ea;(function(t){t.range_end="range_end",t.range_middle="range_middle",t.range_start="range_start",t.selected="selected"})(ea||(ea={}));var ns;(function(t){t.weeks_before_enter="weeks_before_enter",t.weeks_before_exit="weeks_before_exit",t.weeks_after_enter="weeks_after_enter",t.weeks_after_exit="weeks_after_exit",t.caption_after_enter="caption_after_enter",t.caption_after_exit="caption_after_exit",t.caption_before_enter="caption_before_enter",t.caption_before_exit="caption_before_exit"})(ns||(ns={}));function Kse(t){const{options:e,className:n,components:r,classNames:i,...s}=t,a=[i[Zt.Dropdown],n].join(" "),o=e?.find(({value:c})=>c===s.value);return ot.createElement("span",{"data-disabled":s.disabled,className:i[Zt.DropdownRoot]},ot.createElement(r.Select,{className:a,...s},e?.map(({value:c,label:u,disabled:f})=>ot.createElement(r.Option,{key:c,value:c,disabled:f},u))),ot.createElement("span",{className:i[Zt.CaptionLabel],"aria-hidden":!0},o?.label,ot.createElement(r.Chevron,{orientation:"down",size:18,className:i[Zt.Chevron]})))}function Zse(t){return ot.createElement("div",{...t})}function Jse(t){return ot.createElement("div",{...t})}function Qse(t){const{calendarMonth:e,displayIndex:n,...r}=t;return ot.createElement("div",{...r},t.children)}function eae(t){const{calendarMonth:e,displayIndex:n,...r}=t;return ot.createElement("div",{...r})}function tae(t){return ot.createElement("table",{...t})}function nae(t){return ot.createElement("div",{...t})}const xF=x.createContext(void 0);function zp(){const t=x.useContext(xF);if(t===void 0)throw new Error("useDayPicker() must be used within a custom component.");return t}function rae(t){const{components:e}=zp();return ot.createElement(e.Dropdown,{...t})}function iae(t){const{onPreviousClick:e,onNextClick:n,previousMonth:r,nextMonth:i,...s}=t,{components:a,classNames:o,labels:{labelPrevious:c,labelNext:u}}=zp(),f=x.useCallback(m=>{i&&n?.(m)},[i,n]),h=x.useCallback(m=>{r&&e?.(m)},[r,e]);return ot.createElement("nav",{...s},ot.createElement(a.PreviousMonthButton,{type:"button",className:o[Zt.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":c(r),onClick:h},ot.createElement(a.Chevron,{disabled:r?void 0:!0,className:o[Zt.Chevron],orientation:"left"})),ot.createElement(a.NextMonthButton,{type:"button",className:o[Zt.NextMonthButton],tabIndex:i?void 0:-1,"aria-disabled":i?void 0:!0,"aria-label":u(i),onClick:f},ot.createElement(a.Chevron,{disabled:i?void 0:!0,orientation:"right",className:o[Zt.Chevron]})))}function sae(t){const{components:e}=zp();return ot.createElement(e.Button,{...t})}function aae(t){return ot.createElement("option",{...t})}function oae(t){const{components:e}=zp();return ot.createElement(e.Button,{...t})}function lae(t){const{rootRef:e,...n}=t;return ot.createElement("div",{...n,ref:e})}function cae(t){return ot.createElement("select",{...t})}function uae(t){const{week:e,...n}=t;return ot.createElement("tr",{...n})}function dae(t){return ot.createElement("th",{...t})}function fae(t){return ot.createElement("thead",{"aria-hidden":!0},ot.createElement("tr",{...t}))}function hae(t){const{week:e,...n}=t;return ot.createElement("th",{...n})}function pae(t){return ot.createElement("th",{...t})}function mae(t){return ot.createElement("tbody",{...t})}function gae(t){const{components:e}=zp();return ot.createElement(e.Dropdown,{...t})}const yae=Object.freeze(Object.defineProperty({__proto__:null,Button:Gse,CaptionLabel:$se,Chevron:Yse,Day:qse,DayButton:Xse,Dropdown:Kse,DropdownNav:Zse,Footer:Jse,Month:Qse,MonthCaption:eae,MonthGrid:tae,Months:nae,MonthsDropdown:rae,Nav:iae,NextMonthButton:sae,Option:aae,PreviousMonthButton:oae,Root:lae,Select:cae,Week:uae,WeekNumber:hae,WeekNumberHeader:pae,Weekday:dae,Weekdays:fae,Weeks:mae,YearsDropdown:gae},Symbol.toStringTag,{value:"Module"}));function ko(t,e,n=!1,r=Qa){let{from:i,to:s}=t;const{differenceInCalendarDays:a,isSameDay:o}=r;return i&&s?(a(s,i)<0&&([i,s]=[s,i]),a(e,i)>=(n?1:0)&&a(s,e)>=(n?1:0)):!n&&s?o(s,e):!n&&i?o(i,e):!1}function zE(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function uv(t){return!!(t&&typeof t=="object"&&"from"in t)}function VE(t){return!!(t&&typeof t=="object"&&"after"in t)}function HE(t){return!!(t&&typeof t=="object"&&"before"in t)}function bF(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function _F(t,e){return Array.isArray(t)&&t.every(e.isDate)}function Eo(t,e,n=Qa){const r=Array.isArray(e)?e:[e],{isSameDay:i,differenceInCalendarDays:s,isAfter:a}=n;return r.some(o=>{if(typeof o=="boolean")return o;if(n.isDate(o))return i(t,o);if(_F(o,n))return o.some(c=>i(t,c));if(uv(o))return ko(o,t,!1,n);if(bF(o))return Array.isArray(o.dayOfWeek)?o.dayOfWeek.includes(t.getDay()):o.dayOfWeek===t.getDay();if(zE(o)){const c=s(o.before,t),u=s(o.after,t),f=c>0,h=u<0;return a(o.before,o.after)?h&&f:f||h}return VE(o)?s(t,o.after)>0:HE(o)?s(o.before,t)>0:typeof o=="function"?o(t):!1})}function vae(t,e,n,r,i){const{disabled:s,hidden:a,modifiers:o,showOutsideDays:c,broadcastCalendar:u,today:f=i.today()}=e,{isSameDay:h,isSameMonth:m,startOfMonth:g,isBefore:v,endOfMonth:w,isAfter:b}=i,_=n&&g(n),E=r&&w(r),M={[fr.focused]:[],[fr.outside]:[],[fr.disabled]:[],[fr.hidden]:[],[fr.today]:[]},T={};for(const R of t){const{date:A,displayMonth:P}=R,k=!!(P&&!m(A,P)),N=!!(_&&v(A,_)),B=!!(E&&b(A,E)),L=!!(s&&Eo(A,s,i)),z=!!(a&&Eo(A,a,i))||N||B||!u&&!c&&k||u&&c===!1&&k,I=h(A,f);k&&M.outside.push(R),L&&M.disabled.push(R),z&&M.hidden.push(R),I&&M.today.push(R),o&&Object.keys(o).forEach(V=>{const W=o?.[V];W&&Eo(A,W,i)&&(T[V]?T[V].push(R):T[V]=[R])})}return R=>{const A={[fr.focused]:!1,[fr.disabled]:!1,[fr.hidden]:!1,[fr.outside]:!1,[fr.today]:!1},P={};for(const k in M){const N=M[k];A[k]=N.some(B=>B===R)}for(const k in T)P[k]=T[k].some(N=>N===R);return{...A,...P}}}function xae(t,e,n={}){return Object.entries(t).filter(([,i])=>i===!0).reduce((i,[s])=>(n[s]?i.push(n[s]):e[fr[s]]?i.push(e[fr[s]]):e[ea[s]]&&i.push(e[ea[s]]),i),[e[Zt.Day]])}function bae(t){return{...yae,...t}}function _ae(t){const e={"data-mode":t.mode??void 0,"data-required":"required"in t?t.required:void 0,"data-multiple-months":t.numberOfMonths&&t.numberOfMonths>1||void 0,"data-week-numbers":t.showWeekNumber||void 0,"data-broadcast-calendar":t.broadcastCalendar||void 0,"data-nav-layout":t.navLayout||void 0};return Object.entries(t).forEach(([n,r])=>{n.startsWith("data-")&&(e[n]=r)}),e}function wae(){const t={};for(const e in Zt)t[Zt[e]]=`rdp-${Zt[e]}`;for(const e in fr)t[fr[e]]=`rdp-${fr[e]}`;for(const e in ea)t[ea[e]]=`rdp-${ea[e]}`;for(const e in ns)t[ns[e]]=`rdp-${ns[e]}`;return t}function wF(t,e,n){return(n??new us(e)).formatMonthYear(t)}const Sae=wF;function kae(t,e,n){return(n??new us(e)).format(t,"d")}function Eae(t,e=Qa){return e.format(t,"LLLL")}function Mae(t,e,n){return(n??new us(e)).format(t,"cccccc")}function Tae(t,e=Qa){return t<10?e.formatNumber(`0${t.toLocaleString()}`):e.formatNumber(`${t.toLocaleString()}`)}function Cae(){return""}function SF(t,e=Qa){return e.format(t,"yyyy")}const Aae=SF,Rae=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:wF,formatDay:kae,formatMonthCaption:Sae,formatMonthDropdown:Eae,formatWeekNumber:Tae,formatWeekNumberHeader:Cae,formatWeekdayName:Mae,formatYearCaption:Aae,formatYearDropdown:SF},Symbol.toStringTag,{value:"Module"}));function Pae(t){return t?.formatMonthCaption&&!t.formatCaption&&(t.formatCaption=t.formatMonthCaption),t?.formatYearCaption&&!t.formatYearDropdown&&(t.formatYearDropdown=t.formatYearCaption),{...Rae,...t}}function WE(t,e,n,r){let i=(r??new us(n)).format(t,"PPPP");return e.today&&(i=`Today, ${i}`),e.selected&&(i=`${i}, selected`),i}const Nae=WE;function GE(t,e,n){return(n??new us(e)).formatMonthYear(t)}const Dae=GE;function kF(t,e,n,r){let i=(r??new us(n)).format(t,"PPPP");return e?.today&&(i=`Today, ${i}`),i}function EF(t){return"Choose the Month"}function MF(){return""}const Lae="Go to the Next Month";function TF(t,e){return Lae}function CF(t){return"Go to the Previous Month"}function AF(t,e,n){return(n??new us(e)).format(t,"cccc")}function RF(t,e){return`Week ${t}`}function PF(t){return"Week Number"}function NF(t){return"Choose the Year"}const Iae=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:Dae,labelDay:Nae,labelDayButton:WE,labelGrid:GE,labelGridcell:kF,labelMonthDropdown:EF,labelNav:MF,labelNext:TF,labelPrevious:CF,labelWeekNumber:RF,labelWeekNumberHeader:PF,labelWeekday:AF,labelYearDropdown:NF},Symbol.toStringTag,{value:"Module"})),Ws=(t,e,n)=>e||(n?typeof n=="function"?n:(...r)=>n:t);function Oae(t,e){const n=e.locale?.labels??{};return{...Iae,...t??{},labelDayButton:Ws(WE,t?.labelDayButton,n.labelDayButton),labelMonthDropdown:Ws(EF,t?.labelMonthDropdown,n.labelMonthDropdown),labelNext:Ws(TF,t?.labelNext,n.labelNext),labelPrevious:Ws(CF,t?.labelPrevious,n.labelPrevious),labelWeekNumber:Ws(RF,t?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:Ws(NF,t?.labelYearDropdown,n.labelYearDropdown),labelGrid:Ws(GE,t?.labelGrid,n.labelGrid),labelGridcell:Ws(kF,t?.labelGridcell,n.labelGridcell),labelNav:Ws(MF,t?.labelNav,n.labelNav),labelWeekNumberHeader:Ws(PF,t?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:Ws(AF,t?.labelWeekday,n.labelWeekday)}}function Fae(t,e,n,r,i){const{startOfMonth:s,startOfYear:a,endOfYear:o,eachMonthOfInterval:c,getMonth:u}=i;return c({start:a(t),end:o(t)}).map(m=>{const g=r.formatMonthDropdown(m,i),v=u(m),w=e&&m<s(e)||n&&m>s(n)||!1;return{value:v,label:g,disabled:w}})}function Uae(t,e={},n={}){let r={...e?.[Zt.Day]};return Object.entries(t).filter(([,i])=>i===!0).forEach(([i])=>{r={...r,...n?.[i]}}),r}function jae(t,e,n,r){const i=r??t.today(),s=n?t.startOfBroadcastWeek(i,t):e?t.startOfISOWeek(i):t.startOfWeek(i),a=[];for(let o=0;o<7;o++){const c=t.addDays(s,o);a.push(c)}return a}function Bae(t,e,n,r,i=!1){if(!t||!e)return;const{startOfYear:s,endOfYear:a,eachYearOfInterval:o,getYear:c}=r,u=s(t),f=a(e),h=o({start:u,end:f});return i&&h.reverse(),h.map(m=>{const g=n.formatYearDropdown(m,r);return{value:c(m),label:g,disabled:!1}})}function zae(t,e={}){const{weekStartsOn:n,locale:r}=e,i=n??r?.options?.weekStartsOn??0,s=o=>{const c=typeof o=="number"||typeof o=="string"?new Date(o):o;return new mi(c.getFullYear(),c.getMonth(),c.getDate(),12,0,0,t)},a=o=>{const c=s(o);return new Date(c.getFullYear(),c.getMonth(),c.getDate(),0,0,0,0)};return{today:()=>s(mi.tz(t)),newDate:(o,c,u)=>new mi(o,c,u,12,0,0,t),startOfDay:o=>s(o),startOfWeek:(o,c)=>{const u=s(o),f=c?.weekStartsOn??i,h=(u.getDay()-f+7)%7;return u.setDate(u.getDate()-h),u},startOfISOWeek:o=>{const c=s(o),u=(c.getDay()-1+7)%7;return c.setDate(c.getDate()-u),c},startOfMonth:o=>{const c=s(o);return c.setDate(1),c},startOfYear:o=>{const c=s(o);return c.setMonth(0,1),c},endOfWeek:(o,c)=>{const u=s(o),m=(((c?.weekStartsOn??i)+6)%7-u.getDay()+7)%7;return u.setDate(u.getDate()+m),u},endOfISOWeek:o=>{const c=s(o),u=(7-c.getDay())%7;return c.setDate(c.getDate()+u),c},endOfMonth:o=>{const c=s(o);return c.setMonth(c.getMonth()+1,0),c},endOfYear:o=>{const c=s(o);return c.setMonth(11,31),c},eachMonthOfInterval:o=>{const c=s(o.start),u=s(o.end),f=[],h=new mi(c.getFullYear(),c.getMonth(),1,12,0,0,t),m=u.getFullYear()*12+u.getMonth();for(;h.getFullYear()*12+h.getMonth()<=m;)f.push(new mi(h,t)),h.setMonth(h.getMonth()+1,1);return f},addDays:(o,c)=>{const u=s(o);return u.setDate(u.getDate()+c),u},addWeeks:(o,c)=>{const u=s(o);return u.setDate(u.getDate()+c*7),u},addMonths:(o,c)=>{const u=s(o);return u.setMonth(u.getMonth()+c),u},addYears:(o,c)=>{const u=s(o);return u.setFullYear(u.getFullYear()+c),u},eachYearOfInterval:o=>{const c=s(o.start),u=s(o.end),f=[],h=new mi(c.getFullYear(),0,1,12,0,0,t);for(;h.getFullYear()<=u.getFullYear();)f.push(new mi(h,t)),h.setFullYear(h.getFullYear()+1,0,1);return f},getWeek:(o,c)=>{const u=a(o);return BE(u,{weekStartsOn:c?.weekStartsOn??i,firstWeekContainsDate:c?.firstWeekContainsDate??r?.options?.firstWeekContainsDate??1})},getISOWeek:o=>{const c=a(o);return jE(c)},differenceInCalendarDays:(o,c)=>{const u=a(o),f=a(c);return UE(u,f)},differenceInCalendarMonths:(o,c)=>{const u=a(o),f=a(c);return uF(u,f)}}}const Vp=t=>t instanceof HTMLElement?t:null,g_=t=>[...t.querySelectorAll("[data-animated-month]")??[]],Vae=t=>Vp(t.querySelector("[data-animated-month]")),y_=t=>Vp(t.querySelector("[data-animated-caption]")),v_=t=>Vp(t.querySelector("[data-animated-weeks]")),Hae=t=>Vp(t.querySelector("[data-animated-nav]")),Wae=t=>Vp(t.querySelector("[data-animated-weekdays]"));function Gae(t,e,{classNames:n,months:r,focused:i,dateLib:s}){const a=x.useRef(null),o=x.useRef(r),c=x.useRef(!1);x.useLayoutEffect(()=>{const u=o.current;if(o.current=r,!e||!t.current||!(t.current instanceof HTMLElement)||r.length===0||u.length===0||r.length!==u.length)return;const f=s.isSameMonth(r[0].date,u[0].date),h=s.isAfter(r[0].date,u[0].date),m=h?n[ns.caption_after_enter]:n[ns.caption_before_enter],g=h?n[ns.weeks_after_enter]:n[ns.weeks_before_enter],v=a.current,w=t.current.cloneNode(!0);if(w instanceof HTMLElement?(g_(w).forEach(M=>{if(!(M instanceof HTMLElement))return;const T=Vae(M);T&&M.contains(T)&&M.removeChild(T);const R=y_(M);R&&R.classList.remove(m);const A=v_(M);A&&A.classList.remove(g)}),a.current=w):a.current=null,c.current||f||i)return;const b=v instanceof HTMLElement?g_(v):[],_=g_(t.current);if(_?.every(E=>E instanceof HTMLElement)&&b&&b.every(E=>E instanceof HTMLElement)){c.current=!0,t.current.style.isolation="isolate";const E=Hae(t.current);E&&(E.style.zIndex="1"),_.forEach((M,T)=>{const R=b[T];if(!R)return;M.style.position="relative",M.style.overflow="hidden";const A=y_(M);A&&A.classList.add(m);const P=v_(M);P&&P.classList.add(g);const k=()=>{c.current=!1,t.current&&(t.current.style.isolation=""),E&&(E.style.zIndex=""),A&&A.classList.remove(m),P&&P.classList.remove(g),M.style.position="",M.style.overflow="",M.contains(R)&&M.removeChild(R)};R.style.pointerEvents="none",R.style.position="absolute",R.style.overflow="hidden",R.setAttribute("aria-hidden","true");const N=Wae(R);N&&(N.style.opacity="0");const B=y_(R);B&&(B.classList.add(h?n[ns.caption_before_exit]:n[ns.caption_after_exit]),B.addEventListener("animationend",k));const L=v_(R);L&&L.classList.add(h?n[ns.weeks_before_exit]:n[ns.weeks_after_exit]),M.insertBefore(R,M.firstChild)})}})}function $ae(t,e,n,r){const i=t[0],s=t[t.length-1],{ISOWeek:a,fixedWeeks:o,broadcastCalendar:c}=n??{},{addDays:u,differenceInCalendarDays:f,differenceInCalendarMonths:h,endOfBroadcastWeek:m,endOfISOWeek:g,endOfMonth:v,endOfWeek:w,isAfter:b,startOfBroadcastWeek:_,startOfISOWeek:E,startOfWeek:M}=r,T=c?_(i,r):a?E(i):M(i),R=c?m(s):a?g(v(s)):w(v(s)),A=e&&(c?m(e):a?g(e):w(e)),P=A&&b(R,A)?A:R,k=f(P,T),N=h(s,i)+1,B=[];for(let I=0;I<=k;I++){const V=u(T,I);B.push(V)}const z=(c?35:42)*N;if(o&&B.length<z){const I=z-B.length;for(let V=0;V<I;V++){const W=u(B[B.length-1],1);B.push(W)}}return B}function Yae(t){const e=[];return t.reduce((n,r)=>{const i=r.weeks.reduce((s,a)=>s.concat(a.days.slice()),e.slice());return n.concat(i.slice())},e.slice())}function qae(t,e,n,r){const{numberOfMonths:i=1}=n,s=[];for(let a=0;a<i;a++){const o=r.addMonths(t,a);if(e&&o>e)break;s.push(o)}return s}function SP(t,e,n,r){const{month:i,defaultMonth:s,today:a=r.today(),numberOfMonths:o=1}=t;let c=i||s||a;const{differenceInCalendarMonths:u,addMonths:f,startOfMonth:h}=r;if(n&&u(n,c)<o-1){const m=-1*(o-1);c=f(n,m)}return e&&u(c,e)<0&&(c=e),h(c)}function Xae(t,e,n,r){const{addDays:i,endOfBroadcastWeek:s,endOfISOWeek:a,endOfMonth:o,endOfWeek:c,getISOWeek:u,getWeek:f,startOfBroadcastWeek:h,startOfISOWeek:m,startOfWeek:g}=r,v=t.reduce((w,b)=>{const _=n.broadcastCalendar?h(b,r):n.ISOWeek?m(b):g(b),E=n.broadcastCalendar?s(b):n.ISOWeek?a(o(b)):c(o(b)),M=e.filter(P=>P>=_&&P<=E),T=n.broadcastCalendar?35:42;if(n.fixedWeeks&&M.length<T){const P=e.filter(k=>{const N=T-M.length;return k>E&&k<=i(E,N)});M.push(...P)}const R=M.reduce((P,k)=>{const N=n.ISOWeek?u(k):f(k),B=P.find(z=>z.weekNumber===N),L=new vF(k,b,r);return B?B.days.push(L):P.push(new Wse(N,[L])),P},[]),A=new Hse(b,R);return w.push(A),w},[]);return n.reverseMonths?v.reverse():v}function Kae(t,e){let{startMonth:n,endMonth:r}=t;const{startOfYear:i,startOfDay:s,startOfMonth:a,endOfMonth:o,addYears:c,endOfYear:u,newDate:f,today:h}=e,{fromYear:m,toYear:g,fromMonth:v,toMonth:w}=t;!n&&v&&(n=v),!n&&m&&(n=e.newDate(m,0,1)),!r&&w&&(r=w),!r&&g&&(r=f(g,11,31));const b=t.captionLayout==="dropdown"||t.captionLayout==="dropdown-years";return n?n=a(n):m?n=f(m,0,1):!n&&b&&(n=i(c(t.today??h(),-100))),r?r=o(r):g?r=f(g,11,31):!r&&b&&(r=u(t.today??h())),[n&&s(n),r&&s(r)]}function Zae(t,e,n,r){if(n.disableNavigation)return;const{pagedNavigation:i,numberOfMonths:s=1}=n,{startOfMonth:a,addMonths:o,differenceInCalendarMonths:c}=r,u=i?s:1,f=a(t);if(!e)return o(f,u);if(!(c(e,t)<s))return o(f,u)}function Jae(t,e,n,r){if(n.disableNavigation)return;const{pagedNavigation:i,numberOfMonths:s}=n,{startOfMonth:a,addMonths:o,differenceInCalendarMonths:c}=r,u=i?s??1:1,f=a(t);if(!e)return o(f,-u);if(!(c(f,e)<=0))return o(f,-u)}function Qae(t){const e=[];return t.reduce((n,r)=>n.concat(r.weeks.slice()),e.slice())}function dv(t,e){const[n,r]=x.useState(t);return[e===void 0?n:e,r]}function eoe(t,e){const[n,r]=Kae(t,e),{startOfMonth:i,endOfMonth:s}=e,a=SP(t,n,r,e),[o,c]=dv(a,t.month?a:void 0);x.useEffect(()=>{const T=SP(t,n,r,e);c(T)},[t.timeZone]);const{months:u,weeks:f,days:h,previousMonth:m,nextMonth:g}=x.useMemo(()=>{const T=qae(o,r,{numberOfMonths:t.numberOfMonths},e),R=$ae(T,t.endMonth?s(t.endMonth):void 0,{ISOWeek:t.ISOWeek,fixedWeeks:t.fixedWeeks,broadcastCalendar:t.broadcastCalendar},e),A=Xae(T,R,{broadcastCalendar:t.broadcastCalendar,fixedWeeks:t.fixedWeeks,ISOWeek:t.ISOWeek,reverseMonths:t.reverseMonths},e),P=Qae(A),k=Yae(A),N=Jae(o,n,t,e),B=Zae(o,r,t,e);return{months:A,weeks:P,days:k,previousMonth:N,nextMonth:B}},[e,o.getTime(),r?.getTime(),n?.getTime(),t.disableNavigation,t.broadcastCalendar,t.endMonth?.getTime(),t.fixedWeeks,t.ISOWeek,t.numberOfMonths,t.pagedNavigation,t.reverseMonths]),{disableNavigation:v,onMonthChange:w}=t,b=T=>f.some(R=>R.days.some(A=>A.isEqualTo(T))),_=T=>{if(v)return;let R=i(T);n&&R<i(n)&&(R=i(n)),r&&R>i(r)&&(R=i(r)),c(R),w?.(R)};return{months:u,weeks:f,days:h,navStart:n,navEnd:r,previousMonth:m,nextMonth:g,goToMonth:_,goToDay:T=>{b(T)||_(T.date)}}}var Ea;(function(t){t[t.Today=0]="Today",t[t.Selected=1]="Selected",t[t.LastFocused=2]="LastFocused",t[t.FocusedModifier=3]="FocusedModifier"})(Ea||(Ea={}));function kP(t){return!t[fr.disabled]&&!t[fr.hidden]&&!t[fr.outside]}function toe(t,e,n,r){let i,s=-1;for(const a of t){const o=e(a);kP(o)&&(o[fr.focused]&&s<Ea.FocusedModifier?(i=a,s=Ea.FocusedModifier):r?.isEqualTo(a)&&s<Ea.LastFocused?(i=a,s=Ea.LastFocused):n(a.date)&&s<Ea.Selected?(i=a,s=Ea.Selected):o[fr.today]&&s<Ea.Today&&(i=a,s=Ea.Today))}return i||(i=t.find(a=>kP(e(a)))),i}function noe(t,e,n,r,i,s,a){const{ISOWeek:o,broadcastCalendar:c}=s,{addDays:u,addMonths:f,addWeeks:h,addYears:m,endOfBroadcastWeek:g,endOfISOWeek:v,endOfWeek:w,max:b,min:_,startOfBroadcastWeek:E,startOfISOWeek:M,startOfWeek:T}=a;let A={day:u,week:h,month:f,year:m,startOfWeek:P=>c?E(P,a):o?M(P):T(P),endOfWeek:P=>c?g(P):o?v(P):w(P)}[t](n,e==="after"?1:-1);return e==="before"&&r?A=b([r,A]):e==="after"&&i&&(A=_([i,A])),A}function DF(t,e,n,r,i,s,a,o=0){if(o>365)return;const c=noe(t,e,n.date,r,i,s,a),u=!!(s.disabled&&Eo(c,s.disabled,a)),f=!!(s.hidden&&Eo(c,s.hidden,a)),h=c,m=new vF(c,h,a);return!u&&!f?m:DF(t,e,m,r,i,s,a,o+1)}function roe(t,e,n,r,i){const{autoFocus:s}=t,[a,o]=x.useState(),c=toe(e.days,n,r||(()=>!1),a),[u,f]=x.useState(s?c:void 0);return{isFocusTarget:w=>!!c?.isEqualTo(w),setFocused:f,focused:u,blur:()=>{o(u),f(void 0)},moveFocus:(w,b)=>{if(!u)return;const _=DF(w,b,u,e.navStart,e.navEnd,t,i);_&&(t.disableNavigation&&!e.days.some(M=>M.isEqualTo(_))||(e.goToDay(_),f(_)))}}}function ioe(t,e){const{selected:n,required:r,onSelect:i}=t,[s,a]=dv(n,i?n:void 0),o=i?n:s,{isSameDay:c}=e,u=g=>o?.some(v=>c(v,g))??!1,{min:f,max:h}=t;return{selected:o,select:(g,v,w)=>{let b=[...o??[]];if(u(g)){if(o?.length===f||r&&o?.length===1)return;b=o?.filter(_=>!c(_,g))}else o?.length===h?b=[g]:b=[...b,g];return i||a(b),i?.(b,g,v,w),b},isSelected:u}}function soe(t,e,n=0,r=0,i=!1,s=Qa){const{from:a,to:o}=e||{},{isSameDay:c,isAfter:u,isBefore:f}=s;let h;if(!a&&!o)h={from:t,to:n>0?void 0:t};else if(a&&!o)c(a,t)?n===0?h={from:a,to:t}:i?h={from:a,to:void 0}:h=void 0:f(t,a)?h={from:t,to:a}:h={from:a,to:t};else if(a&&o)if(c(a,t)&&c(o,t))i?h={from:a,to:o}:h=void 0;else if(c(a,t))h={from:a,to:n>0?void 0:t};else if(c(o,t))h={from:t,to:n>0?void 0:t};else if(f(t,a))h={from:t,to:o};else if(u(t,a))h={from:a,to:t};else if(u(t,o))h={from:a,to:t};else throw new Error("Invalid range");if(h?.from&&h?.to){const m=s.differenceInCalendarDays(h.to,h.from);r>0&&m>r?h={from:t,to:void 0}:n>1&&m<n&&(h={from:t,to:void 0})}return h}function aoe(t,e,n=Qa){const r=Array.isArray(e)?e:[e];let i=t.from;const s=n.differenceInCalendarDays(t.to,t.from),a=Math.min(s,6);for(let o=0;o<=a;o++){if(r.includes(i.getDay()))return!0;i=n.addDays(i,1)}return!1}function EP(t,e,n=Qa){return ko(t,e.from,!1,n)||ko(t,e.to,!1,n)||ko(e,t.from,!1,n)||ko(e,t.to,!1,n)}function ooe(t,e,n=Qa){const r=Array.isArray(e)?e:[e];if(r.filter(o=>typeof o!="function").some(o=>typeof o=="boolean"?o:n.isDate(o)?ko(t,o,!1,n):_F(o,n)?o.some(c=>ko(t,c,!1,n)):uv(o)?o.from&&o.to?EP(t,{from:o.from,to:o.to},n):!1:bF(o)?aoe(t,o.dayOfWeek,n):zE(o)?n.isAfter(o.before,o.after)?EP(t,{from:n.addDays(o.after,1),to:n.addDays(o.before,-1)},n):Eo(t.from,o,n)||Eo(t.to,o,n):VE(o)||HE(o)?Eo(t.from,o,n)||Eo(t.to,o,n):!1))return!0;const a=r.filter(o=>typeof o=="function");if(a.length){let o=t.from;const c=n.differenceInCalendarDays(t.to,t.from);for(let u=0;u<=c;u++){if(a.some(f=>f(o)))return!0;o=n.addDays(o,1)}}return!1}function loe(t,e){const{disabled:n,excludeDisabled:r,resetOnSelect:i,selected:s,required:a,onSelect:o}=t,[c,u]=dv(s,o?s:void 0),f=o?s:c;return{selected:f,select:(g,v,w)=>{const{min:b,max:_}=t;let E;if(g){const M=f?.from,T=f?.to,R=!!M&&!!T,A=!!M&&!!T&&e.isSameDay(M,T)&&e.isSameDay(g,M);i&&(R||!f?.from)?!a&&A?E=void 0:E={from:g,to:void 0}:E=soe(g,f,b,_,a,e)}return r&&n&&E?.from&&E.to&&ooe({from:E.from,to:E.to},n,e)&&(E.from=g,E.to=void 0),o||u(E),o?.(E,g,v,w),E},isSelected:g=>f&&ko(f,g,!1,e)}}function coe(t,e){const{selected:n,required:r,onSelect:i}=t,[s,a]=dv(n,i?n:void 0),o=i?n:s,{isSameDay:c}=e;return{selected:o,select:(h,m,g)=>{let v=h;return!r&&o&&o&&c(h,o)&&(v=void 0),i||a(v),i?.(v,h,m,g),v},isSelected:h=>o?c(o,h):!1}}function uoe(t,e){const n=coe(t,e),r=ioe(t,e),i=loe(t,e);switch(t.mode){case"single":return n;case"multiple":return r;case"range":return i;default:return}}function bs(t,e){return t instanceof mi&&t.timeZone===e?t:new mi(t,e)}function Ju(t,e,n){return bs(t,e)}function MP(t,e,n){return typeof t=="boolean"||typeof t=="function"?t:t instanceof Date?Ju(t,e):Array.isArray(t)?t.map(r=>r instanceof Date?Ju(r,e):r):uv(t)?{...t,from:t.from?bs(t.from,e):t.from,to:t.to?bs(t.to,e):t.to}:zE(t)?{before:Ju(t.before,e),after:Ju(t.after,e)}:VE(t)?{after:Ju(t.after,e)}:HE(t)?{before:Ju(t.before,e)}:t}function x_(t,e,n){return t&&(Array.isArray(t)?t.map(r=>MP(r,e)):MP(t,e))}function doe(t){let e=t;const n=e.timeZone;if(n&&(e={...t,timeZone:n},e.today&&(e.today=bs(e.today,n)),e.month&&(e.month=bs(e.month,n)),e.defaultMonth&&(e.defaultMonth=bs(e.defaultMonth,n)),e.startMonth&&(e.startMonth=bs(e.startMonth,n)),e.endMonth&&(e.endMonth=bs(e.endMonth,n)),e.mode==="single"&&e.selected?e.selected=bs(e.selected,n):e.mode==="multiple"&&e.selected?e.selected=e.selected?.map(ne=>bs(ne,n)):e.mode==="range"&&e.selected&&(e.selected={from:e.selected.from?bs(e.selected.from,n):e.selected.from,to:e.selected.to?bs(e.selected.to,n):e.selected.to}),e.disabled!==void 0&&(e.disabled=x_(e.disabled,n)),e.hidden!==void 0&&(e.hidden=x_(e.hidden,n)),e.modifiers)){const ne={};Object.keys(e.modifiers).forEach(Be=>{ne[Be]=x_(e.modifiers?.[Be],n)}),e.modifiers=ne}const{components:r,formatters:i,labels:s,dateLib:a,locale:o,classNames:c}=x.useMemo(()=>{const ne={...yF,...e.locale},Be=e.broadcastCalendar?1:e.weekStartsOn,ke=e.noonSafe&&e.timeZone?zae(e.timeZone,{weekStartsOn:Be,locale:ne}):void 0,Ae=e.dateLib&&ke?{...ke,...e.dateLib}:e.dateLib??ke,Ve=new us({locale:ne,weekStartsOn:Be,firstWeekContainsDate:e.firstWeekContainsDate,useAdditionalWeekYearTokens:e.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:e.useAdditionalDayOfYearTokens,timeZone:e.timeZone,numerals:e.numerals},Ae);return{dateLib:Ve,components:bae(e.components),formatters:Pae(e.formatters),labels:Oae(e.labels,Ve.options),locale:ne,classNames:{...wae(),...e.classNames}}},[e.locale,e.broadcastCalendar,e.weekStartsOn,e.firstWeekContainsDate,e.useAdditionalWeekYearTokens,e.useAdditionalDayOfYearTokens,e.timeZone,e.numerals,e.dateLib,e.noonSafe,e.components,e.formatters,e.labels,e.classNames]);e.today||(e={...e,today:a.today()});const{captionLayout:u,mode:f,navLayout:h,numberOfMonths:m=1,onDayBlur:g,onDayClick:v,onDayFocus:w,onDayKeyDown:b,onDayMouseEnter:_,onDayMouseLeave:E,onNextClick:M,onPrevClick:T,showWeekNumber:R,styles:A}=e,{formatCaption:P,formatDay:k,formatMonthDropdown:N,formatWeekNumber:B,formatWeekNumberHeader:L,formatWeekdayName:z,formatYearDropdown:I}=i,V=eoe(e,a),{days:W,months:X,navStart:J,navEnd:F,previousMonth:G,nextMonth:Y,goToMonth:H}=V,te=vae(W,e,J,F,a),{isSelected:re,select:ue,selected:ce}=uoe(e,a)??{},{blur:ee,focused:le,isFocusTarget:ve,moveFocus:Ne,setFocused:be}=roe(e,V,te,re??(()=>!1),a),{labelDayButton:qe,labelGridcell:he,labelGrid:Ue,labelMonthDropdown:je,labelNav:et,labelPrevious:_e,labelNext:oe,labelWeekday:Q,labelWeekNumber:ze,labelWeekNumberHeader:Re,labelYearDropdown:De}=s,Le=x.useMemo(()=>jae(a,e.ISOWeek,e.broadcastCalendar,e.today),[a,e.ISOWeek,e.broadcastCalendar,e.today]),$=f!==void 0||v!==void 0,U=x.useCallback(()=>{G&&(H(G),T?.(G))},[G,H,T]),Z=x.useCallback(()=>{Y&&(H(Y),M?.(Y))},[H,Y,M]),pe=x.useCallback((ne,Be)=>ke=>{ke.preventDefault(),ke.stopPropagation(),be(ne),!Be.disabled&&(ue?.(ne.date,Be,ke),v?.(ne.date,Be,ke))},[ue,v,be]),Se=x.useCallback((ne,Be)=>ke=>{be(ne),w?.(ne.date,Be,ke)},[w,be]),xe=x.useCallback((ne,Be)=>ke=>{ee(),g?.(ne.date,Be,ke)},[ee,g]),Ie=x.useCallback((ne,Be)=>ke=>{const Ae={ArrowLeft:[ke.shiftKey?"month":"day",e.dir==="rtl"?"after":"before"],ArrowRight:[ke.shiftKey?"month":"day",e.dir==="rtl"?"before":"after"],ArrowDown:[ke.shiftKey?"year":"week","after"],ArrowUp:[ke.shiftKey?"year":"week","before"],PageUp:[ke.shiftKey?"year":"month","before"],PageDown:[ke.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(Ae[ke.key]){ke.preventDefault(),ke.stopPropagation();const[Ve,ge]=Ae[ke.key];Ne(Ve,ge)}b?.(ne.date,Be,ke)},[Ne,b,e.dir]),He=x.useCallback((ne,Be)=>ke=>{_?.(ne.date,Be,ke)},[_]),Ye=x.useCallback((ne,Be)=>ke=>{E?.(ne.date,Be,ke)},[E]),ft=x.useCallback(ne=>Be=>{const ke=Number(Be.target.value),Ae=a.setMonth(a.startOfMonth(ne),ke);H(Ae)},[a,H]),We=x.useCallback(ne=>Be=>{const ke=Number(Be.target.value),Ae=a.setYear(a.startOfMonth(ne),ke);H(Ae)},[a,H]),{className:Xe,style:nt}=x.useMemo(()=>({className:[c[Zt.Root],e.className].filter(Boolean).join(" "),style:{...A?.[Zt.Root],...e.style}}),[c,e.className,e.style,A]),ct=_ae(e),Ke=x.useRef(null);Gae(Ke,!!e.animate,{classNames:c,months:X,focused:le,dateLib:a});const gt={dayPickerProps:e,selected:ce,select:ue,isSelected:re,months:X,nextMonth:Y,previousMonth:G,goToMonth:H,getModifiers:te,components:r,classNames:c,styles:A,labels:s,formatters:i};return ot.createElement(xF.Provider,{value:gt},ot.createElement(r.Root,{rootRef:e.animate?Ke:void 0,className:Xe,style:nt,dir:e.dir,id:e.id,lang:e.lang??o.code,nonce:e.nonce,title:e.title,role:e.role,"aria-label":e["aria-label"],"aria-labelledby":e["aria-labelledby"],...ct},ot.createElement(r.Months,{className:c[Zt.Months],style:A?.[Zt.Months]},!e.hideNavigation&&!h&&ot.createElement(r.Nav,{"data-animated-nav":e.animate?"true":void 0,className:c[Zt.Nav],style:A?.[Zt.Nav],"aria-label":et(),onPreviousClick:U,onNextClick:Z,previousMonth:G,nextMonth:Y}),X.map((ne,Be)=>ot.createElement(r.Month,{"data-animated-month":e.animate?"true":void 0,className:c[Zt.Month],style:A?.[Zt.Month],key:Be,displayIndex:Be,calendarMonth:ne},h==="around"&&!e.hideNavigation&&Be===0&&ot.createElement(r.PreviousMonthButton,{type:"button",className:c[Zt.PreviousMonthButton],tabIndex:G?void 0:-1,"aria-disabled":G?void 0:!0,"aria-label":_e(G),onClick:U,"data-animated-button":e.animate?"true":void 0},ot.createElement(r.Chevron,{disabled:G?void 0:!0,className:c[Zt.Chevron],orientation:e.dir==="rtl"?"right":"left"})),ot.createElement(r.MonthCaption,{"data-animated-caption":e.animate?"true":void 0,className:c[Zt.MonthCaption],style:A?.[Zt.MonthCaption],calendarMonth:ne,displayIndex:Be},u?.startsWith("dropdown")?ot.createElement(r.DropdownNav,{className:c[Zt.Dropdowns],style:A?.[Zt.Dropdowns]},(()=>{const ke=u==="dropdown"||u==="dropdown-months"?ot.createElement(r.MonthsDropdown,{key:"month",className:c[Zt.MonthsDropdown],"aria-label":je(),classNames:c,components:r,disabled:!!e.disableNavigation,onChange:ft(ne.date),options:Fae(ne.date,J,F,i,a),style:A?.[Zt.Dropdown],value:a.getMonth(ne.date)}):ot.createElement("span",{key:"month"},N(ne.date,a)),Ae=u==="dropdown"||u==="dropdown-years"?ot.createElement(r.YearsDropdown,{key:"year",className:c[Zt.YearsDropdown],"aria-label":De(a.options),classNames:c,components:r,disabled:!!e.disableNavigation,onChange:We(ne.date),options:Bae(J,F,i,a,!!e.reverseYears),style:A?.[Zt.Dropdown],value:a.getYear(ne.date)}):ot.createElement("span",{key:"year"},I(ne.date,a));return a.getMonthYearOrder()==="year-first"?[Ae,ke]:[ke,Ae]})(),ot.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},P(ne.date,a.options,a))):ot.createElement(r.CaptionLabel,{className:c[Zt.CaptionLabel],role:"status","aria-live":"polite"},P(ne.date,a.options,a))),h==="around"&&!e.hideNavigation&&Be===m-1&&ot.createElement(r.NextMonthButton,{type:"button",className:c[Zt.NextMonthButton],tabIndex:Y?void 0:-1,"aria-disabled":Y?void 0:!0,"aria-label":oe(Y),onClick:Z,"data-animated-button":e.animate?"true":void 0},ot.createElement(r.Chevron,{disabled:Y?void 0:!0,className:c[Zt.Chevron],orientation:e.dir==="rtl"?"left":"right"})),Be===m-1&&h==="after"&&!e.hideNavigation&&ot.createElement(r.Nav,{"data-animated-nav":e.animate?"true":void 0,className:c[Zt.Nav],style:A?.[Zt.Nav],"aria-label":et(),onPreviousClick:U,onNextClick:Z,previousMonth:G,nextMonth:Y}),ot.createElement(r.MonthGrid,{role:"grid","aria-multiselectable":f==="multiple"||f==="range","aria-label":Ue(ne.date,a.options,a)||void 0,className:c[Zt.MonthGrid],style:A?.[Zt.MonthGrid]},!e.hideWeekdays&&ot.createElement(r.Weekdays,{"data-animated-weekdays":e.animate?"true":void 0,className:c[Zt.Weekdays],style:A?.[Zt.Weekdays]},R&&ot.createElement(r.WeekNumberHeader,{"aria-label":Re(a.options),className:c[Zt.WeekNumberHeader],style:A?.[Zt.WeekNumberHeader],scope:"col"},L()),Le.map(ke=>ot.createElement(r.Weekday,{"aria-label":Q(ke,a.options,a),className:c[Zt.Weekday],key:String(ke),style:A?.[Zt.Weekday],scope:"col"},z(ke,a.options,a)))),ot.createElement(r.Weeks,{"data-animated-weeks":e.animate?"true":void 0,className:c[Zt.Weeks],style:A?.[Zt.Weeks]},ne.weeks.map(ke=>ot.createElement(r.Week,{className:c[Zt.Week],key:ke.weekNumber,style:A?.[Zt.Week],week:ke},R&&ot.createElement(r.WeekNumber,{week:ke,style:A?.[Zt.WeekNumber],"aria-label":ze(ke.weekNumber,{locale:o}),className:c[Zt.WeekNumber],scope:"row",role:"rowheader"},B(ke.weekNumber,a)),ke.days.map(Ae=>{const{date:Ve}=Ae,ge=te(Ae);if(ge[fr.focused]=!ge.hidden&&!!le?.isEqualTo(Ae),ge[ea.selected]=re?.(Ve)||ge.selected,uv(ce)){const{from:Lt,to:_t}=ce;ge[ea.range_start]=!!(Lt&&_t&&a.isSameDay(Ve,Lt)),ge[ea.range_end]=!!(Lt&&_t&&a.isSameDay(Ve,_t)),ge[ea.range_middle]=ko(ce,Ve,!0,a)}const ut=Uae(ge,A,e.modifiersStyles),yt=xae(ge,c,e.modifiersClassNames),qt=!$&&!ge.hidden?he(Ve,ge,a.options,a):void 0;return ot.createElement(r.Day,{key:`${Ae.isoDate}_${Ae.displayMonthId}`,day:Ae,modifiers:ge,className:yt.join(" "),style:ut,role:"gridcell","aria-selected":ge.selected||void 0,"aria-label":qt,"data-day":Ae.isoDate,"data-month":Ae.outside?Ae.dateMonthId:void 0,"data-selected":ge.selected||void 0,"data-disabled":ge.disabled||void 0,"data-hidden":ge.hidden||void 0,"data-outside":Ae.outside||void 0,"data-focused":ge.focused||void 0,"data-today":ge.today||void 0},!ge.hidden&&$?ot.createElement(r.DayButton,{className:c[Zt.DayButton],style:A?.[Zt.DayButton],type:"button",day:Ae,modifiers:ge,disabled:!ge.focused&&ge.disabled||void 0,"aria-disabled":ge.focused&&ge.disabled||void 0,tabIndex:ve(Ae)?0:-1,"aria-label":qe(Ve,ge,a.options,a),onClick:pe(Ae,ge),onBlur:xe(Ae,ge),onFocus:Se(Ae,ge),onKeyDown:Ie(Ae,ge),onMouseEnter:He(Ae,ge),onMouseLeave:Ye(Ae,ge)},k(Ve,a.options,a)):!ge.hidden&&k(Ae.date,a.options,a))})))))))),e.footer&&ot.createElement(r.Footer,{className:c[Zt.Footer],style:A?.[Zt.Footer],role:"status","aria-live":"polite"},e.footer)))}function TP(t){if(!t)return"";const e=t.split("-");if(e.length!==3)return t;const n=new Date(Number(e[0]),Number(e[1])-1,Number(e[2]));return Number.isFinite(n.getTime())?Na(n,"MMM d"):t}function foe({from:t,to:e,onApply:n,onCancel:r}){const i=x.useMemo(()=>{const u={from:void 0,to:void 0};if(t){const f=t.split("-");u.from=new Date(Number(f[0]),Number(f[1])-1,Number(f[2]))}if(e){const f=e.split("-");u.to=new Date(Number(f[0]),Number(f[1])-1,Number(f[2]))}return u},[t,e]),[s,a]=x.useState(i),o=()=>{if(!s?.from)return;const u=Na(s.from,"yyyy-MM-dd"),f=s.to?Na(s.to,"yyyy-MM-dd"):u;n?.(u,f)},c=!!s?.from;return p.jsxs("div",{className:"p-4",children:[p.jsx(doe,{mode:"range",selected:s,onSelect:a,numberOfMonths:2,showOutsideDays:!1,classNames:{root:"rdp-oai",months:"flex gap-4",month:"space-y-3",month_caption:"flex justify-center items-center h-8",caption_label:"text-sm font-medium text-oai-black dark:text-oai-white",nav:"flex items-center justify-between absolute inset-x-0 top-0 px-2",button_previous:"inline-flex items-center justify-center w-7 h-7 rounded-md text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-oai-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",button_next:"inline-flex items-center justify-center w-7 h-7 rounded-md text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-oai-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",chevron:"w-4 h-4",month_grid:"border-collapse",weekdays:"flex",weekday:"w-9 text-center text-xs font-medium text-oai-gray-400 dark:text-oai-gray-500 py-1",week:"flex",day:"w-9 h-9 text-center text-sm p-0 relative",day_button:"w-full h-full inline-flex items-center justify-center rounded-md transition-colors hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 text-oai-black dark:text-oai-white cursor-pointer rdp-day-btn",today:"font-bold",selected:"rdp-selected",range_start:"rdp-selected rdp-range-start",range_end:"rdp-selected rdp-range-end",range_middle:"rdp-range-mid",outside:"text-oai-gray-300 dark:text-oai-gray-600",disabled:"text-oai-gray-300 dark:text-oai-gray-600 cursor-not-allowed",hidden:"invisible"},styles:{months:{position:"relative"}}}),p.jsxs("div",{className:"flex items-center justify-end gap-2 mt-4 pt-3 border-t border-oai-gray-200 dark:border-oai-gray-700",children:[c&&s.from&&p.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mr-auto",children:[Na(s.from,"MMM d, yyyy"),s.to&&s.to.getTime()!==s.from.getTime()?` — ${Na(s.to,"MMM d, yyyy")}`:""]}),p.jsx(Ui,{variant:"secondary",size:"sm",onClick:r,children:"Cancel"}),p.jsx(Ui,{variant:"primary",size:"sm",onClick:o,disabled:!c,children:"Apply"})]})]})}const CP={claude:290,codex:165},AP={system_prompt:{l:.55,c:.05},messages:{l:.65,c:.18},tool_calls:{l:.6,c:.14},custom_agents:{l:.55,c:.1},reasoning:{l:.7,c:.08}};function hoe(t,e){const n=CP[e]??CP.claude,r=AP[t]||AP.system_prompt;return`oklch(${r.l} ${r.c} ${n})`}const poe=[{key:"system_prompt",from:["system_prefix"]},{key:"messages",from:["user_input","conversation_history","assistant_response"]},{key:"tool_calls",from:["tool_calls"]},{key:"custom_agents",from:["subagents"]},{key:"reasoning",from:["reasoning"]}],moe=[["by_type","dashboard.context_breakdown.exec_details.group_by_type"],["by_executable","dashboard.context_breakdown.exec_details.group_by_executable"],["by_command","dashboard.context_breakdown.exec_details.group_by_command"],["by_duration","dashboard.context_breakdown.exec_details.group_by_duration"],["by_output","dashboard.context_breakdown.exec_details.group_by_output"],["by_exit","dashboard.context_breakdown.exec_details.group_by_exit"]],goe={duration:.18,ease:[.4,0,.2,1]},yoe={height:0,opacity:0},voe={height:"auto",opacity:1},xoe={height:0,opacity:0};function boe(t){const e=Number(t||0);return Number.isFinite(e)&&e>0?e:0}function _oe(t,e){const n={};for(const r of["input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens","total_tokens"])n[r]=Math.round(Number(t?.[r]||0)*e);return n}function LF(t,e=null){const n=t.reduce((a,o)=>a+Number(o.totals.total_tokens||0),0),r=boe(e),i=r||n,s=r&&n>0?r/n:1;return t.map(a=>{const o=s===1?a.totals:_oe(a.totals,s);return{...a,totals:o,percent:i>0?Number((o.total_tokens/i*100).toFixed(2)):0}}).sort((a,o)=>o.totals.total_tokens-a.totals.total_tokens)}function woe(t,e=null){const n=new Map;for(const i of t||[])n.set(i.key,i);const r=poe.map(i=>{const s={input_tokens:0,cached_input_tokens:0,cache_creation_input_tokens:0,output_tokens:0,reasoning_output_tokens:0,total_tokens:0};for(const a of i.from){const o=n.get(a);if(!o)continue;const c=o.totals||{};s.input_tokens+=c.input_tokens||0,s.cached_input_tokens+=c.cached_input_tokens||0,s.cache_creation_input_tokens+=c.cache_creation_input_tokens||0,s.output_tokens+=c.output_tokens||0,s.reasoning_output_tokens+=c.reasoning_output_tokens||0,s.total_tokens+=c.total_tokens||0}return{key:i.key,totals:s}});return LF(r,e)}function Soe(t,e=null){const n=t?.totals||{},r=Number(n.reasoning_output_tokens||0),i=(t?.tool_calls_breakdown?.categories||[]).reduce((u,f)=>f?.name==="Text Response"?u:u+Number(f?.totals?.total_tokens||0),0),s=Number(n.total_tokens||0),a=Math.min(Math.max(0,i),Math.max(0,s-r)),c=[{key:"messages",totals:{total_tokens:Math.max(0,s-r-a)}},{key:"tool_calls",totals:{total_tokens:a}},{key:"reasoning",totals:{total_tokens:r}}];return LF(c,e)}function RP(t){return O(`dashboard.context_breakdown.category.${t}`)}function Lc(t){return!Number.isFinite(Number(t))||Number(t)<=0?"0":Ms(Number(t),{decimals:1})}function koe(t){return typeof t!="string"?"":t.startsWith("mcp__")?t.split("__").slice(2).join("__")||t:t.includes("/")&&t.split("/").pop()||t}function Eoe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||null,r=Number(n?n.input_tokens||0:e?.input_tokens||0),i=Number(n?n.output_tokens||0:e?.output_tokens||0),s=Number(n?n.cached_input_tokens||0:e?.cache_read||0),a=Number(n?n.cache_creation_input_tokens||0:e?.cache_creation||0),o=Number(n?n.total_tokens||r+i:e?.total_tokens||i);return{name:koe(e?.name?String(e.name):""),calls:Number(e?.calls||0),input_tokens:r,output_tokens:i,cache_read:s,cache_creation:a,total_tokens:Number(o||0)}}).filter(e=>e.name).sort((e,n)=>(n.total_tokens||0)-(e.total_tokens||0))}function Moe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||{},r=Array.isArray(e?.tools)?e.tools:[],i=Number(n.input_tokens||0),s=Number(n.output_tokens||0),a=Number(n.cached_input_tokens||0),o=Number(n.cache_creation_input_tokens||0);return{name:e?.name?String(e.name):"",calls:Number(e?.calls||0),totals:{input_tokens:i,output_tokens:s,cached_input_tokens:a,cache_creation_input_tokens:o,total_tokens:Number(n.total_tokens||i+s)},tools:Eoe(r),toolCount:r.length}}).filter(e=>e.name).sort((e,n)=>(n.totals.total_tokens||0)-(e.totals.total_tokens||0))}function Toe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||{},r=Number(n.input_tokens||0),i=Number(n.output_tokens||0),s=Number(n.cached_input_tokens||0),a=Number(n.cache_creation_input_tokens||0);return{key:e?.key?String(e.key):"",name:e?.name?String(e.name):"",totals:{input_tokens:r,output_tokens:i,cached_input_tokens:s,cache_creation_input_tokens:a,total_tokens:Number(n.total_tokens||r+i+s+a)}}}).filter(e=>e.key||e.name).sort((e,n)=>(n.totals.total_tokens||0)-(e.totals.total_tokens||0))}function Coe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||{};return{name:e?.name?String(e.name):"",calls:Number(e?.calls||0),total_tokens:Number(n.total_tokens||0)}}).filter(e=>e.name).sort((e,n)=>Number(n.total_tokens||0)-Number(e.total_tokens||0))}function Aoe(t){if(t?.key){const e=O(`dashboard.context_breakdown.message_details.${t.key}`);if(e&&!e.includes("dashboard.context_breakdown"))return e}return t?.name||""}function Roe(t){return(Array.isArray(t)?t:[]).map(e=>{const n=e?.totals||{},r=Number(n.input_tokens||0),i=Number(n.output_tokens||0),s=Number(n.cached_input_tokens||0),a=Number(n.cache_creation_input_tokens||0);return{name:e?.name?String(e.name):"",calls:Number(e?.calls||0),failures:Number(e?.failures||0),duration_ms:Number(e?.duration_ms||0),max_duration_ms:Number(e?.max_duration_ms||0),output_chars:Number(e?.output_chars||0),output_lines:Number(e?.output_lines||0),totals:{input_tokens:r,output_tokens:i,cached_input_tokens:s,cache_creation_input_tokens:a,total_tokens:Number(n.total_tokens||r+i)}}}).filter(e=>e.name).sort((e,n)=>Number(n.totals.total_tokens||0)-Number(e.totals.total_tokens||0))}function PP(t){const e=Number(t||0);return!Number.isFinite(e)||e<=0?"0ms":e<1e3?`${Math.round(e)}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.round(e/1e3)}s`}function Poe(t,e){return t?e==="by_executable"?t.by_executable||[]:e==="by_command"?t.by_command||[]:e==="by_duration"?t.by_duration||[]:e==="by_output"?t.by_output||[]:e==="by_exit"?t.by_exit||[]:t.by_type||[]:[]}function NP(t){return t==="exec_command"||t==="Bash"}function IF(t){return t==="codex"?"dashboard.context_breakdown.empty_codex":"dashboard.context_breakdown.empty"}function Noe(t){return t==="codex"?"dashboard.context_breakdown.error_codex":"dashboard.context_breakdown.error"}function Doe(t){return t==="codex"?"dashboard.context_breakdown.footnote_codex":"dashboard.context_breakdown.footnote"}const Loe=10;function Md({level:t=0,colorSquare:e=null,label:n,labelSuffix:r=null,labelTone:i="default",hasChevron:s=!1,open:a=!1,onToggle:o,tokens:c,percent:u=null,children:f,share:h=null,fillColor:m=null}){const g=i==="accent"?"text-oai-brand truncate":i==="muted"?"text-oai-gray-500 dark:text-oai-gray-400 truncate":i==="strong"?"font-medium text-oai-black dark:text-oai-white truncate":"text-oai-gray-700 dark:text-oai-gray-300 truncate",v=p.jsx("span",{className:"shrink-0 flex items-center justify-start",style:{width:Loe},"aria-hidden":!e,children:e}),w=p.jsxs(p.Fragment,{children:[v,p.jsx("span",{className:g,children:n}),r,s&&p.jsx(tr.span,{animate:{rotate:a?90:0},transition:{duration:.15},className:"shrink-0 text-oai-gray-400 dark:text-oai-gray-500 flex items-center","aria-hidden":"true",children:p.jsx(BW,{size:11})})]}),b=m&&h!=null&&h>0,_=b?Math.max(0,Math.min(100,h)):0;return p.jsxs("li",{className:"min-w-0 group/row",children:[p.jsxs("div",{className:"relative grid grid-cols-[minmax(0,1fr)_64px_48px] items-center gap-2 text-xs py-1 px-1 rounded-sm transition-colors duration-150",style:b?{backgroundImage:`linear-gradient(to right, ${m.replace(/\)\s*$/," / 0.10)")} 0%, ${m.replace(/\)\s*$/," / 0.10)")} ${_}%, transparent ${_}%)`}:void 0,children:[s?p.jsx("button",{type:"button",onClick:o,"aria-expanded":a,className:"relative flex items-center gap-1.5 min-w-0 text-left cursor-pointer focus-visible:outline-none focus-visible:ring-inset focus-visible:ring-2 focus-visible:ring-oai-brand/40 rounded-sm",children:w}):p.jsx("div",{className:"relative flex items-center gap-1.5 min-w-0",children:w}),p.jsx("span",{className:"relative text-right tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:c||""}),p.jsx("span",{className:"relative text-right tabular-nums text-[10px] text-oai-gray-400 dark:text-oai-gray-500 font-normal",children:u||""})]}),s&&f?p.jsx(Lp,{initial:!1,children:a&&p.jsx(tr.div,{initial:yoe,animate:voe,exit:xoe,transition:goe,style:{overflow:"hidden"},children:f},"content")}):null]})}function DP({execDetails:t,source:e="claude"}){const[n,r]=x.useState("by_type"),i=Roe(Poe(t,n)),s=e==="codex",a=s?"grid-cols-[minmax(0,1fr)_48px_48px_72px_72px_60px_60px]":"grid-cols-[minmax(0,1fr)_56px_60px]";return p.jsxs("div",{className:"mt-2 ml-4",children:[p.jsx("div",{className:"flex flex-wrap items-center gap-1 rounded-md bg-oai-gray-100 dark:bg-oai-gray-900 p-1 w-fit max-w-full",children:moe.map(([o,c])=>p.jsx("button",{type:"button",onClick:()=>r(o),className:"h-7 px-2 rounded-md text-[10px] font-medium transition-colors "+(n===o?"bg-oai-white dark:bg-oai-gray-800 text-oai-black dark:text-oai-white shadow-sm":"text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-white/70 dark:hover:bg-oai-gray-800/70"),children:O(c)},o))}),i.length===0?p.jsx("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:"—"}):p.jsx("div",{className:"mt-2 overflow-x-auto",children:p.jsxs("div",{role:"table","aria-label":O("dashboard.context_breakdown.exec_details.title"),className:s?"min-w-[420px]":"min-w-[260px]",children:[p.jsxs("div",{role:"row",className:`grid ${a} gap-2 py-1.5 mb-1 border-b border-oai-gray-200 dark:border-oai-gray-800 text-label uppercase text-oai-gray-500 dark:text-oai-gray-400`,children:[p.jsx("span",{role:"columnheader",children:O("dashboard.context_breakdown.exec_details.kind_column")}),p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.calls_column")}),s&&p.jsxs(p.Fragment,{children:[p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.failures_column")}),p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.duration_column")}),p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.max_duration_column")})]}),p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.tool_details.total_column")}),s&&p.jsx("span",{role:"columnheader",className:"text-right",children:O("dashboard.context_breakdown.exec_details.output_column")})]}),i.map((o,c)=>p.jsxs(tr.div,{role:"row",className:`grid ${a} gap-2 py-1.5`,title:o.name,initial:{opacity:0},animate:{opacity:1},transition:{duration:.18,delay:c*.02},children:[p.jsx("span",{role:"cell",className:"min-w-0 text-body-sm font-medium text-oai-black dark:text-oai-white truncate",children:o.name}),p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ms(o.calls||0)}),s&&p.jsxs(p.Fragment,{children:[p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ms(o.failures||0)}),p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:PP(o.duration_ms||0)}),p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:PP(o.max_duration_ms||0)})]}),p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Lc(o.totals.total_tokens||0)}),s&&p.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ms(o.output_lines||0)})]},o.name))]})})]})}function LP({toolSet:t,execDetails:e,source:n,codexQueueFallback:r}){const[i,s]=x.useState({}),[a,o]=x.useState(!1),c=Moe(t?.categories||[]);function u(f){s(h=>({...h,[f]:!h[f]}))}return c.length===0?p.jsx("p",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500 py-0.5",children:O(n==="codex"&&r?"dashboard.context_breakdown.tool_details.unavailable_codex":IF(n))}):p.jsx("ul",{className:"mt-0.5 mb-0.5 space-y-0.5",children:c.map(f=>{const h=f.toolCount>0,m=f.name==="Execution"&&e,g=m&&f.tools.some(w=>NP(w.name)),v=!!i[f.name];return p.jsxs(Md,{level:1,label:f.name,labelTone:"strong",hasChevron:h||m&&!g,open:v||m&&!g&&a,onToggle:()=>{h?u(f.name):m&&!g&&o(w=>!w)},tokens:Lc(f.totals.total_tokens||0),percent:null,children:[h&&p.jsx("ul",{className:"space-y-0.5",children:f.tools.map(w=>{const b=m&&NP(w.name);return p.jsx(Md,{level:2,label:w.name,labelTone:b?"accent":"default",hasChevron:b,open:a,onToggle:()=>o(_=>!_),tokens:Lc(w.total_tokens||0),percent:null,children:b&&p.jsx(DP,{execDetails:e,source:n})},w.name)})}),m&&!g&&p.jsx(DP,{execDetails:e,source:n})]},f.name)})})}function Ioe({from:t,to:e,source:n="claude",referenceTotalTokens:r=null,onLoadingChange:i=null}){const[s,a]=x.useState(null),[o,c]=x.useState(!1),[u,f]=x.useState(null),[h,m]=x.useState({});function g(L){m(z=>({...z,[L]:!z[L]}))}if(x.useEffect(()=>{let L=!1;return c(!0),i?.(!0),f(null),k7({from:t,to:e,source:n,timeZone:bL(),tzOffsetMinutes:_L()}).then(z=>{L||a(z)}).catch(z=>{L||f(z?.message||String(z))}).finally(()=>{L||(c(!1),i?.(!1))}),()=>{L=!0}},[t,e,n]),o&&!s)return p.jsxs("div",{children:[p.jsx("div",{className:"h-1 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden animate-pulse"}),p.jsx("div",{className:"mt-3 grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-2",children:[0,1,2,3,4].map(L=>p.jsx("div",{className:"h-3 rounded bg-oai-gray-100 dark:bg-oai-gray-800 animate-pulse",style:{animationDelay:`${L*80}ms`}},L))}),p.jsx("p",{className:"mt-3 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:O("dashboard.context_breakdown.loading_hint")})]});if(u)return p.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:O(Noe(n))});if(!s||s.scope!=="supported"||!s.totals?.total_tokens)return p.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:O(IF(n))});const v=n==="claude"?woe(s.categories||[],r):Soe(s,r),w=s.tool_calls_breakdown||null,b=s.skills_breakdown||null,_=s.message_breakdown||null,E=s.configured_resources||null,M=s.exec_command_breakdown||null,T=Coe(b?.skills||[]),R=Toe(_?.categories||[]),A=n==="codex"&&(s?.breakdown_status==="queue_fallback"||s?.fallback==="queue_totals"),P=n==="claude"?w?.tool_calls||null:w||null,k=n==="claude"&&w?.subagents||null,N=k?.categories?.length>0||(E?.custom_agents_count||0)>0,B=[...v].sort((L,z)=>(z.totals?.total_tokens||0)-(L.totals?.total_tokens||0));return p.jsxs("div",{role:"region","aria-label":O("dashboard.context_breakdown.bar_aria",{summary:v.filter(L=>L.percent>0).map(L=>`${RP(L.key)} ${L.percent}%`).join(",")}),children:[p.jsxs("ul",{className:"space-y-0.5",children:[B.map(L=>{const z=L.key==="system_prompt",I=L.key==="messages",V=L.key==="tool_calls",W=L.key==="custom_agents";L.key;const X=I&&R.length>0||V&&(P?.categories?.length>0||A)||W&&N&&k,J=!!h[L.key],F=hoe(L.key,n),G=p.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0",style:{backgroundColor:F},"aria-hidden":"true"}),Y=z?p.jsxs("span",{className:"relative inline-flex shrink-0 group",children:[p.jsx(VL,{size:11,className:"text-oai-gray-400 dark:text-oai-gray-500 cursor-help","aria-hidden":"true"}),p.jsx("span",{role:"tooltip",className:"pointer-events-none absolute left-1/2 bottom-full z-20 mb-1.5 -translate-x-1/2 w-64 rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-white dark:bg-oai-gray-900 px-2.5 py-1.5 text-[11px] leading-snug text-oai-gray-700 dark:text-oai-gray-200 shadow-md opacity-0 group-hover:opacity-100 transition-opacity",children:O("dashboard.context_breakdown.system_prefix_tooltip")})]}):null,H=L.percent>0?`${L.percent.toFixed(L.percent<.1&&L.percent>0?2:1)}%`:"0.0%";return p.jsxs(Md,{level:0,colorSquare:G,label:RP(L.key),labelSuffix:Y,tokens:Lc(L.totals?.total_tokens||0),percent:H,hasChevron:X,open:J,onToggle:()=>g(L.key),share:L.percent,fillColor:F,children:[I&&p.jsx("ul",{className:"space-y-0.5",children:R.map(te=>p.jsx(Md,{level:1,label:Aoe(te),tokens:Lc(te.totals.total_tokens||0),percent:null},te.key||te.name))}),V&&P&&p.jsx(LP,{toolSet:P,execDetails:M,source:n,codexQueueFallback:A}),V&&A&&!P&&p.jsx("p",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500 py-0.5",children:O("dashboard.context_breakdown.tool_details.unavailable_codex")}),W&&k&&p.jsx(LP,{toolSet:k,execDetails:null,source:n,codexQueueFallback:!1})]},L.key)}),T.length>0&&p.jsx(Md,{level:0,colorSquare:p.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:O("dashboard.context_breakdown.category.skills"),tokens:Lc(T.reduce((L,z)=>L+(z.total_tokens||0),0)),percent:null,hasChevron:!0,open:!!h.skills,onToggle:()=>g("skills"),children:p.jsx("ul",{className:"space-y-0.5",children:T.slice(0,12).map(L=>p.jsx(Md,{level:1,label:L.name,tokens:Lc(L.total_tokens),percent:null},L.name))})})]}),p.jsx("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:O(Doe(n))}),A?p.jsx("p",{className:"mt-2 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:O("dashboard.context_breakdown.tool_details.unavailable_codex")}):null,E?p.jsxs("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:[Ms(E.skills_count||0)," skills ·"," ",Ms(E.mcp_servers_count||0)," MCP servers ·"," ",Ms(E.custom_agents_count||0)," agents ·"," ",Ms(E.memory_files_count||0)," memory files"]}):null]})}function OF(t){if(!Number.isFinite(Number(t)))return null;const e=Number(t);return e<=0?null:Ms(e,{decimals:1})}function FF(t){const e=Number(t);return!Number.isFinite(e)||e<=0?null:e<.01?"<$0.01":Uy(e.toFixed(2),{decimals:2})}function Ooe(t){return Array.isArray(t)?t.map(e=>typeof e=="string"?{key:e,label:IP(e)}:{key:e.key,label:e.label||IP(e.key)}):[]}function Foe(t){if(typeof t!="string")return null;const e=t.replace(/,/g,"").match(/-?\d+(?:\.\d+)?/);if(!e)return null;const n=Number(e[0]);return Number.isFinite(n)?n:null}const Uoe={CODEX:"#10b981",CLAUDE:"#8b5cf6",OPENCODE:"#f59e0b",GEMINI:"#3b82f6",KIMI:"#a78bfa","KILO-CLI":"#facc15","KILO-CODE":"#facc15"};function b_(t,e){const n=t?.toUpperCase?.()||"";return Uoe[n]||`hsl(${150+e*40}, 60%, 45%)`}function joe(t){const e=String(t?.source||"").trim().toLowerCase(),n=String(t?.label||"").trim().toLowerCase();return e==="claude"||n==="claude"?"claude":e==="codex"||n==="codex"?"codex":null}const Boe={day:"usage.period.day",week:"usage.period.week",month:"usage.period.month",total:"usage.period.total",custom:"usage.period.custom"};function IP(t){const e=Boe[t];return e?O(e):String(t).toUpperCase()}function zoe({loading:t,onClick:e}){const n=cu();return p.jsx(Ui,{variant:"secondary",size:"sm",disabled:t,onClick:e,"aria-label":O("usage.button.refresh"),className:"w-8 p-0",children:p.jsx(tr.span,{"aria-hidden":"true",animate:t?{rotate:360}:{rotate:0},transition:t&&!n?{duration:1,repeat:1/0,ease:"linear"}:{duration:.3},style:{display:"inline-block"},children:"↻"})})}function Voe({period:t,periods:e,onPeriodChange:n,summaryValue:r,summaryLabel:i,summaryCostValue:s,onCostInfo:a,fleetData:o=[],onRefresh:c,loading:u,className:f="",customFrom:h,customTo:m,onCustomRangeApply:g,customRangeOpen:v,onCustomRangeOpenChange:w,onOpenShare:b,from:_,to:E}){const M=Ooe(e),T=Foe(String(r??"")),R=T!=null,[A,P]=x.useState(null),{resolvedTheme:k}=Op(),N=k==="dark",B=N?"rgba(10,10,10,0.98)":"rgba(255,255,255,0.96)",L=N?"rgba(10,10,10,0)":"rgba(255,255,255,0)",z=o.filter(I=>I.models?.length>0);return p.jsxs(pu,{className:f,children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 mb-6",children:[p.jsx("div",{role:"tablist","aria-label":O("usage.overview.tablist_aria"),className:"flex gap-1",children:M.map(I=>{const V=t===I.key,W=`text-xs font-medium px-3 py-1.5 rounded-md transition-colors ${V?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800"}`;if(I.key==="custom"){const X=V&&h&&m?`${TP(h)} — ${TP(m)}`:I.label;return p.jsxs(Z5,{open:v,onOpenChange:J=>{J?n?.("custom"):w?.(J)},children:[p.jsx(J5,{render:p.jsx("button",{role:"tab","aria-selected":V,type:"button",className:W}),children:X}),p.jsx(eF,{children:p.jsx(nF,{sideOffset:8,side:"bottom",align:"start",className:"!z-[9999]",children:p.jsx(rF,{className:"bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded-xl shadow-lg",children:p.jsx(foe,{from:h,to:m,onApply:g,onCancel:()=>w?.(!1)})})})})]},"custom")}return p.jsx("button",{role:"tab","aria-selected":V,type:"button",className:W,onClick:()=>n?.(I.key),children:I.label},I.key)})}),p.jsxs("div",{className:"flex items-center gap-1.5",children:[b?p.jsxs("button",{type:"button",onClick:b,"aria-label":O("share.button.aria"),className:"inline-flex items-center justify-center gap-1.5 h-8 px-3 text-xs font-medium rounded-md border border-oai-gray-300 dark:border-oai-gray-700 bg-oai-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white hover:border-oai-brand hover:text-oai-brand transition-colors duration-200",children:[p.jsx(vG,{className:"h-3.5 w-3.5",strokeWidth:2}),O("share.button.label")]}):null,c&&p.jsx(zoe,{loading:u,onClick:c})]})]}),p.jsxs("div",{className:"text-center mb-8",children:[p.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wider mb-3",children:i}),p.jsx("div",{className:"text-6xl md:text-7xl font-bold text-oai-black dark:text-oai-white tracking-tight tabular-nums",children:R?p.jsx(sie,{value:T,displayValue:r,fontSize:72,padding:6,gap:1,textColor:"var(--oai-black, #111827)",fontWeight:700,gradientHeight:N?0:8,gradientFrom:B,gradientTo:L,counterStyle:{paddingLeft:0,paddingRight:0,gap:0},digitStyle:{width:"0.88ch"}}):r}),s&&p.jsx("div",{className:"flex items-center justify-center gap-2 mt-4",children:a?p.jsxs("button",{type:"button",onClick:a,className:"inline-flex items-center gap-1.5 text-xl font-bold text-oai-brand hover:text-oai-brand-dark dark:hover:text-oai-brand-light transition-colors cursor-pointer","aria-label":O("usage.overview.cost_breakdown_aria"),children:[s,p.jsx(VL,{size:16,strokeWidth:2,className:"opacity-80"})]}):p.jsx("span",{className:"text-xl font-bold text-oai-brand",children:s})})]}),z.length>0&&p.jsxs("div",{className:"space-y-6",children:[p.jsx("div",{role:"img","aria-label":O("usage.overview.distribution_aria",{items:z.map(I=>O("usage.overview.distribution_item",{label:I.label,percent:I.totalPercent})).join(",")}),className:"h-1.5 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden flex",children:z.map((I,V)=>{const W=b_(I.label,V);return p.jsx(tr.div,{initial:{width:0},animate:{width:`${I.totalPercent}%`},transition:{duration:.5,delay:.45+V*.04,ease:[.16,1,.3,1]},className:"h-full",style:{backgroundColor:W},title:`${I.label}: ${I.totalPercent}%`},I.label)})}),p.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 xl:grid-cols-5 gap-3",children:z.map((I,V)=>{const W=b_(I.label,V),X=A===I.label;return p.jsxs("button",{"aria-expanded":X,"aria-controls":`provider-details-${I.label}`,"aria-label":O("usage.overview.provider_card_aria",{provider:I.label,percent:I.totalPercent,tokens:OF(I.usage)||"0",cost:FF(I.usd)||"$0",action:O(X?"usage.overview.collapse":"usage.overview.expand")}),onClick:()=>P(X?null:I.label),className:`min-w-0 text-left p-3 rounded-lg border transition-colors duration-200 ${X?"border-oai-gray-300 dark:border-oai-gray-600 bg-oai-gray-50 dark:bg-oai-gray-800":"border-oai-gray-200 dark:border-oai-gray-700 hover:border-oai-gray-300 dark:hover:border-oai-gray-600"}`,children:[p.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[p.jsx(nu,{provider:I.label,size:15,color:W,className:"text-oai-gray-700 dark:text-oai-gray-300 shrink-0"}),p.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:I.label})]}),p.jsxs("div",{className:"text-lg font-semibold text-oai-black dark:text-oai-white tabular-nums",children:[I.totalPercent,"%"]}),p.jsx("div",{className:"mt-0.5 text-[11px] text-oai-gray-400 dark:text-oai-gray-400 tabular-nums",children:O("usage.overview.model_count",{count:I.models.length})})]},I.label)})}),A&&p.jsx("div",{id:`provider-details-${A}`,role:"region","aria-label":O("usage.overview.model_details_aria",{provider:A}),className:"mt-2",children:z.filter(I=>I.label===A).map(I=>{const V=b_(I.label,0),W=joe(I),X=[...I.models].sort((F,G)=>(G.share||0)-(F.share||0)),J=W?`${W==="claude"?"Claude":"Codex"} Context Breakdown`:I.label;return p.jsx(Hoe,{provider:I,color:V,providerHeading:J,contextSource:W,from:_,to:E,sortedModels:X},I.label)})})]})]})}function Hoe({provider:t,color:e,providerHeading:n,contextSource:r,from:i,to:s,sortedModels:a}){const[o,c]=x.useState(!1);return p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-1.5 mb-3",children:[p.jsx(nu,{provider:t.label,size:14,color:e,className:"shrink-0"}),p.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:n}),r&&o&&p.jsx(Ao,{size:12,className:"text-oai-gray-400 dark:text-oai-gray-500 animate-spin shrink-0","aria-label":O("dashboard.context_breakdown.loading_aria")})]}),r?p.jsx("div",{className:"mb-4 pb-4 border-b border-oai-gray-200 dark:border-oai-gray-700",children:p.jsx(Ioe,{from:i,to:s,source:r,referenceTotalTokens:t.usage,onLoadingChange:c})}):null,p.jsx("div",{className:"space-y-3",children:a.map(u=>{const f=OF(u.usage),h=FF(u.cost),m=Math.max(0,Math.min(100,Number(u.share)||0));return p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-baseline gap-4 mb-1.5",children:[p.jsx("span",{className:"flex-1 min-w-0 text-sm text-oai-gray-700 dark:text-oai-gray-300 truncate",title:u.name,children:u.name}),p.jsx("span",{className:"shrink-0 w-16 text-right text-sm text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:f}),p.jsx("span",{className:"shrink-0 w-16 text-right text-sm text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:h}),p.jsxs("span",{className:"shrink-0 w-12 text-right text-sm text-oai-black dark:text-oai-white tabular-nums",children:[u.share,"%"]})]}),p.jsx("div",{className:"h-[3px] bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden",role:"progressbar","aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100,children:p.jsx("div",{className:"h-full transition-[width] duration-500 ease-out",style:{width:`${m}%`,backgroundColor:e,opacity:.45}})})]},u.id||u.name)})})]})}function OP(t,e){if(!Array.isArray(t)||t.length===0)return 0;if(t.length===1)return t[0];const n=(t.length-1)*e,r=Math.floor(n),i=Math.ceil(n);if(r===i)return t[r];const s=n-r;return t[r]+(t[i]-t[r])*s}function Woe(t){const e=Array.isArray(t)?t.filter(i=>Number.isFinite(i)&&i>0).sort((i,s)=>i-s):[];if(e.length===0)return{rawMax:0,effectiveMax:1,clippedValues:Array.isArray(t)?t.map(()=>0):[]};const n=e.at(-1)??0;let r=n;if(e.length>=4){const i=OP(e,.25),s=OP(e,.75),a=Math.max(s-i,0),o=s+a*1.5;n>o&&(r=Math.max(o,s,1))}return{rawMax:n,effectiveMax:Math.max(r,1),clippedValues:Array.isArray(t)?t.map(i=>!Number.isFinite(i)||i<=0?0:Math.min(i,Math.max(r,1))):[]}}function Goe({value:t,displayValue:e,scale:n,index:r,row:i,totalBars:s}){const a=cu(),o=n.effectiveMax>0?e/n.effectiveMax*100:0,c=`${Math.max(o,2)}%`,u=i?.missing,f=i?.future,h=s<=7?"6px":s<=14?"4px":"3px";return p.jsx(tr.div,{className:"group relative flex-1 self-stretch",initial:{opacity:0,scaleY:0},animate:{opacity:1,scaleY:1},transition:{duration:a?0:.3,delay:a?0:.4+r*.008,ease:[.16,1,.3,1]},style:{originY:1},children:p.jsxs("div",{className:"absolute inset-x-0 bottom-0",style:{height:c},children:[p.jsx("div",{"data-trend-bar":"true",className:"h-full w-full cursor-pointer transition-all duration-200 group-hover:brightness-110",style:{minHeight:t>0?"4px":"2px",opacity:u||f?.2:1,borderRadius:`${h} ${h} 0 0`,background:t>0?"#10b981":"var(--oai-gray-100)"},title:`${t.toLocaleString()}`}),p.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-oai-black text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-20",children:t.toLocaleString()})]})})}function $oe({rows:t,from:e,to:n,period:r,timeZoneLabel:i,showTimeZoneLabel:s=!0,className:a=""}){const o=Array.isArray(t)&&t.length?t:[],c=o.map(f=>{if(f?.missing||f?.future)return 0;const h=f?.billable_total_tokens??f?.total_tokens??f?.value;if(h==null)return 0;const m=Number(h);return Number.isFinite(m)?m:0}),u=Woe(c);return p.jsxs("div",{className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5 ${a}`,children:[p.jsxs("div",{className:"mb-3",children:[p.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:O("trend.monitor.label")}),s&&i&&p.jsx("p",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:i})]}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"relative",children:[p.jsx("div",{className:"absolute inset-0 flex flex-col justify-between pointer-events-none",children:[0,25,50,75,100].map(f=>p.jsx("div",{className:"w-full border-t border-oai-gray-100 dark:border-oai-gray-800",style:{top:`${100-f}%`}},f))}),p.jsx("div",{className:"h-40 flex items-end gap-1 relative z-0",children:c.length>0?c.map((f,h)=>p.jsx(Goe,{value:f,displayValue:u.clippedValues[h]??0,scale:u,index:h,row:o[h],totalBars:c.length},h)):p.jsx("div",{className:"flex-1 h-full flex items-center justify-center",children:p.jsx("p",{className:"text-sm text-oai-gray-400 dark:text-oai-gray-400",children:"No data yet"})})})]}),e&&n&&p.jsxs("div",{className:"flex justify-between text-xs text-oai-gray-500 dark:text-oai-gray-300 font-medium pt-2 border-t border-oai-gray-100 dark:border-oai-gray-800",children:[p.jsx("span",{children:e}),p.jsx("span",{children:n})]})]})]})}function _o({children:t,delay:e=0,duration:n=.35,y:r=12,className:i="",once:s=!0}){return cu()?p.jsx("div",{className:i,children:t}):p.jsx(tr.div,{initial:{opacity:0,y:r},animate:{opacity:1,y:0},transition:{duration:n,delay:e,ease:[.16,1,.3,1]},className:i,children:t})}function Yoe({children:t,staggerDelay:e=.1,initialDelay:n=0,className:r=""}){return cu()?p.jsx("div",{className:r,children:t}):p.jsx(tr.div,{initial:"hidden",animate:"visible",variants:{hidden:{},visible:{transition:{staggerChildren:e,delayChildren:n}}},className:r,children:t})}function qoe({children:t,className:e="",y:n=12}){return cu()?p.jsx("div",{className:e,children:t}):p.jsx(tr.div,{variants:{hidden:{opacity:0,y:n},visible:{opacity:1,y:0,transition:{duration:.35,ease:[.16,1,.3,1]}}},className:e,children:t})}const FP={"idle-living":"idle/living.svg","idle-doze":"idle/doze.svg","idle-follow":"idle/follow.svg","idle-look":"idle/look.svg","idle-yawn":"idle/yawn.svg","idle-collapse":"idle/collapse.svg","working-building":"working/building.svg","working-carrying":"working/carrying.svg","working-conducting":"working/conducting.svg","working-confused":"working/confused.svg","working-debugger":"working/debugger.svg","working-juggling":"working/juggling.svg","working-overheated":"working/overheated.svg","working-pushing":"working/pushing.svg","working-sweeping":"working/sweeping.svg","working-thinking":"working/thinking.svg","working-typing":"working/typing.svg","working-ultrathink":"working/ultrathink.svg","working-wizard":"working/wizard.svg","mini-alert":"mini/alert.svg","mini-crabwalk":"mini/crabwalk.svg","mini-enter":"mini/enter.svg","mini-enter-sleep":"mini/enter-sleep.svg","mini-happy":"mini/happy.svg","mini-idle":"mini/idle.svg","mini-peek":"mini/peek.svg","mini-sleep":"mini/sleep.svg","react-double":"react/double.svg","react-drag":"react/drag.svg","react-left":"react/left.svg","react-right":"react/right.svg","collapse-sleep":"sleep/collapse-sleep.svg",sleeping:"sleep/sleeping.svg",wake:"sleep/wake.svg",disconnected:"status/disconnected.svg",error:"status/error.svg",notification:"status/notification.svg",happy:"happy.svg","static-base":"static-base.svg"},__=new Map;async function Xoe(t){if(__.has(t))return __.get(t);const e=await fetch(`/clawd/${t}`);if(!e.ok)return null;const r=(await e.text()).replace(/<svg([^>]*)>/,(i,s)=>`<svg${s.replace(/\s+width="[^"]*"/g,"").replace(/\s+height="[^"]*"/g,"")} width="100%" height="100%">`);return __.set(t,r),r}function Koe({state:t="idle-living",size:e=48,className:n=""}){const[r,i]=x.useState(""),s=x.useRef(null),o=Zoe()?"static-base":t,c=FP[o]||FP["static-base"];return x.useEffect(()=>{let u=!1;return Xoe(c).then(f=>{!u&&f&&i(f)}),()=>{u=!0}},[c]),x.useEffect(()=>{const u=s.current?.querySelector("svg");if(u)try{const f=u.getBBox();f.width>0&&f.height>0&&u.setAttribute("viewBox",`${f.x-2} ${f.y-2} ${f.width+4} ${f.height+4}`)}catch{}},[r]),p.jsx("div",{ref:s,className:`clawd-animated ${n}`,style:{width:e,height:e,display:"inline-flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},dangerouslySetInnerHTML:{__html:r}})}function Zoe(){const[t,e]=x.useState(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return x.useEffect(()=>{const n=window.matchMedia("(prefers-reduced-motion: reduce)"),r=i=>e(i.matches);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}function Joe({todayTokens:t=0,isSyncing:e=!1,hasError:n=!1,isDisconnected:r=!1}={}){return x.useMemo(()=>n?"error":r?"disconnected":e?"working-typing":t===0?"sleeping":t<5e4?"idle-living":t<2e5?"idle-look":t<5e5?"working-ultrathink":t<2e6?"working-typing":"working-ultrathink",[t,e,n,r])}const UP="macAppBannerDismissed",Qoe="leaderboardBannerDismissed",ele="https://github.com/mm7894215/TokenTracker/releases/latest",jP="tokentracker_native_app",Tg=(()=>{try{return new URLSearchParams(window.location.search).get("app")==="1"?(localStorage.setItem(jP,"1"),!0):localStorage.getItem(jP)==="1"}catch{return!1}})();function tle({todayTokens:t=0,isSyncing:e=!1,enterDelay:n=0}){const{openLoginModal:r}=Cp(),{signedIn:i}=la(),s=Joe({todayTokens:t,isSyncing:e}),a=Tg?Qoe:UP,[o,c]=x.useState(()=>{try{return localStorage.getItem(a)==="1"?!0:!Tg&&new URLSearchParams(window.location.search).get("from")==="menubar"?(localStorage.setItem(UP,"1"),!0):!1}catch{return!1}}),u=x.useCallback(()=>{c(!0);try{localStorage.setItem(a,"1")}catch{}},[a]);if(o)return null;let f,h,m,g,v,w;Tg&&i?(f="View the Leaderboard",h="Compare your usage globally",m="Leaderboard",g=p.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:p.jsx("path",{d:"M2 8.5V10h8V8.5M6 1.5v6m0 0L3.5 5M6 7.5l2.5-2.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(180 6 6)"})}),v=()=>{window.location.pathname="/leaderboard"}):Tg?(f="Join the Leaderboard",h="Log in to compare your usage with others",m="Log In",g=p.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:p.jsx("path",{d:"M6.5 1.5h3a1 1 0 011 1v7a1 1 0 01-1 1h-3M5 8.5L7.5 6 5 3.5M7.5 6H1.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),v=r):(f="Try the Menu Bar App",h="Always-on stats with Clawd companion",m="Download",g=p.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"opacity-70",children:p.jsx("path",{d:"M6 2v6m0 0L3.5 5.5M6 8l2.5-2.5M2 10h8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),w=ele);const b=w?tr.a:tr.button,_=w?{href:w,target:"_blank",rel:"noopener noreferrer"}:{onClick:v};return p.jsx(tr.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.35,delay:n,ease:[.16,1,.3,1]},className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-4",children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:"flex-shrink-0",children:p.jsx(Koe,{state:s,size:56})}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("div",{className:"text-sm font-medium text-oai-gray-900 dark:text-oai-white",children:f}),p.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-0.5",children:h})]}),p.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[p.jsxs(b,{..._,whileHover:{scale:1.03},whileTap:{scale:.97},className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-white bg-oai-gray-900 dark:bg-oai-white dark:text-oai-gray-900 rounded-md hover:opacity-90 transition-opacity",children:[m,g]}),p.jsx("button",{onClick:u,className:"p-1 text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-300 transition-colors","aria-label":"Dismiss",children:p.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:p.jsx("path",{d:"M4 4l6 6m0-6L4 10",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})})]})]})})}const BP="widgetOnboardingDismissed",zP="tokentracker_native_app",nle=(()=>{try{return new URLSearchParams(window.location.search).get("app")==="1"?(localStorage.setItem(zP,"1"),!0):localStorage.getItem(zP)==="1"}catch{return!1}})();function rle({enterDelay:t=0}){const[e,n]=x.useState(()=>{try{return localStorage.getItem(BP)==="1"}catch{return!1}}),r=x.useCallback(()=>{n(!0);try{localStorage.setItem(BP,"1")}catch{}},[]);return nle?p.jsx(Lp,{initial:!1,children:!e&&p.jsxs(tr.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-8,transition:{duration:.2,ease:[.4,0,.2,1]}},transition:{duration:.35,delay:t,ease:[.16,1,.3,1]},className:"relative rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-4",children:[p.jsx("button",{type:"button",onClick:r,"aria-label":O("dashboard.widgets.dismiss_aria"),className:"absolute top-2.5 right-2.5 z-10 inline-flex items-center justify-center w-7 h-7 rounded-md text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-300 dark:focus-visible:ring-oai-gray-600 transition-colors",children:p.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:p.jsx("path",{d:"M4 4l6 6m0-6L4 10",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}),p.jsx("div",{className:"rounded-lg overflow-hidden ring-1 ring-black/5 dark:ring-white/10 shadow-sm",children:p.jsx("img",{src:"/widgets-overview.png",alt:O("dashboard.widgets.title"),width:734,height:552,className:"w-full h-auto block",loading:"lazy",decoding:"async"})}),p.jsxs("div",{className:"mt-4",children:[p.jsx("div",{className:"text-sm font-medium tracking-tight text-oai-gray-900 dark:text-oai-white",children:O("dashboard.widgets.title")}),p.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1 leading-snug",children:O("dashboard.widgets.hint")})]})]},"widget-onboarding-card")}):null}function ile(t){const{copy:e,onOpenShare:n,screenshotMode:r,showExpiredGate:i,showAuthGate:s,screenshotTitleLine1:a,screenshotTitleLine2:o,identityDisplayName:c,identityStartDate:u,activeDays:f,identitySubscriptions:h,identityScrambleDurationMs:m,projectUsageEntries:g,projectUsageLimit:v,setProjectUsageLimit:w,topModels:b,signedIn:_,publicMode:E,isLocalMode:M,shouldShowInstall:T,installPrompt:R,handleCopyInstall:A,installCopied:P,installInitCmdDisplay:k,trendRowsForDisplay:N,trendFromForDisplay:B,trendToForDisplay:L,usageFrom:z,usageTo:I,period:V,trendTimeZoneLabel:W,activityHeatmapBlock:X,isCapturing:J,handleShareToX:F,screenshotTwitterButton:G,screenshotTwitterHint:Y,periodsForDisplay:H,setSelectedPeriod:te,customFrom:re,customTo:ue,onCustomRangeApply:ce,customRangeOpen:ee,onCustomRangeOpenChange:le,summaryLabel:ve,summaryValue:Ne,summaryTotalTokensRaw:be,summaryCostValue:qe,summaryConversationsValue:he,rollingUsage:Ue,costInfoEnabled:je,openCostModal:et,costModalOpen:_e,closeCostModal:oe,allowBreakdownToggle:Q,refreshAll:ze,usageLoadingState:Re,fleetData:De,hasDetailsActual:Le,dailyEmptyPrefix:$,installSyncCmd:U,dailyEmptySuffix:Z,detailsColumns:pe,ariaSortFor:Se,toggleSort:xe,sortIconFor:Ie,pagedDetails:He,dailyBreakdownRows:Ye,dailyBreakdownColumns:ft,dailyBreakdownAriaSortFor:We,dailyBreakdownSortIconFor:Xe,dailyBreakdownDateKey:nt,detailsDateKey:ct,renderDetailDate:Ke,renderDailyBreakdownDate:gt,renderDetailCell:ne,DETAILS_PAGED_PERIODS:Be,detailsPageCount:ke,detailsPage:Ae,setDetailsPage:Ve}=t,ge=null,ut=null,yt=.06,qt=.05,Lt=.11;let _t=0;const wt=()=>Lt+yt*_t++,un=Lt+yt*5;return p.jsxs(p.Fragment,{children:[p.jsx(Sre,{bare:!r,hideHeader:r,header:ge,footer:r?null:ut,className:r?"screenshot-mode":"",children:i||s?null:p.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-4",children:[p.jsxs("div",{className:"lg:col-span-4 flex flex-col gap-4 min-w-0 order-2 lg:order-1",children:[r?p.jsx("div",{className:"flex items-start justify-between gap-4",children:p.jsxs("div",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-3xl md:text-4xl font-semibold text-oai-black dark:text-oai-white tracking-tight leading-none",children:a}),p.jsx("span",{className:"text-2xl md:text-3xl font-semibold text-oai-black dark:text-oai-white tracking-tight leading-none",children:o})]})}):null,M?p.jsx(tle,{todayTokens:be,isSyncing:Re,enterDelay:wt()}):null,p.jsx(_o,{delay:wt(),children:p.jsx(uie,{title:e("dashboard.identity.title"),subtitle:e("dashboard.identity.subtitle"),period:V,rankLabel:u??e("identity_card.rank_placeholder"),streakDays:f,subscriptions:h,periodConversations:he,rolling:Ue,topModels:b})}),M?p.jsx(rle,{enterDelay:wt()}):null,T?p.jsx(_o,{delay:wt(),children:p.jsxs("div",{className:"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-3",children:[p.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-300 mb-1.5",children:R}),p.jsxs(tr.button,{onClick:A,whileHover:{scale:1.01},whileTap:{scale:.99},className:"w-full flex items-center justify-between px-3 py-2 bg-oai-gray-50 dark:bg-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-700 rounded-lg transition-colors",children:[p.jsx("code",{className:"text-xs font-mono text-oai-gray-700 dark:text-oai-gray-300",children:k}),p.jsx(tr.span,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},className:"text-xs text-oai-brand",children:P?"Copied ✓":"Copy"},P?"copied":"copy")]})]})}):null,X&&p.jsx(_o,{delay:wt(),children:X}),r?null:p.jsx(_o,{delay:wt(),children:p.jsx($oe,{rows:N,from:B,to:L,period:V,timeZoneLabel:W,showTimeZoneLabel:!1})}),r?p.jsxs("div",{className:"mt-4 flex flex-col items-center gap-2","data-screenshot-exclude":"true",style:J?{display:"none"}:void 0,children:[p.jsx(Ui,{type:"button",onClick:F,variant:"primary",size:"lg",disabled:J,children:G}),p.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300",children:Y})]}):null]}),p.jsxs("div",{className:"lg:col-span-8 flex flex-col gap-4 min-w-0 order-1 lg:order-2",children:[p.jsx(_o,{delay:qt,children:p.jsx(Voe,{period:V,periods:H,onPeriodChange:te,summaryLabel:ve,summaryValue:Ne,summaryCostValue:qe,onCostInfo:je?et:null,fleetData:De,onRefresh:r?null:ze,loading:Re,onOpenShare:r?null:n,customFrom:re,customTo:ue,onCustomRangeApply:ce,customRangeOpen:ee,onCustomRangeOpenChange:le,from:z,to:I})}),r?null:p.jsx(_o,{delay:un,children:p.jsx(lie,{projectEntries:g,projectLimit:v,onProjectLimitChange:w,copy:e,hasDetailsActual:Le,dailyEmptyPrefix:$,installSyncCmd:U,dailyEmptySuffix:Z,detailsColumns:pe,ariaSortFor:Se,toggleSort:xe,sortIconFor:Ie,pagedDetails:He,dailyBreakdownRows:Ye,dailyBreakdownColumns:ft,dailyBreakdownAriaSortFor:We,dailyBreakdownSortIconFor:Xe,dailyBreakdownDateKey:nt,detailsDateKey:ct,renderDetailDate:Ke,renderDailyBreakdownDate:gt,renderDetailCell:ne,DETAILS_PAGED_PERIODS:Be,period:V,detailsPageCount:ke,detailsPage:Ae,setDetailsPage:Ve})})]})]})}),p.jsx(oie,{isOpen:_e,onClose:oe,fleetData:De})]})}function UF(){return typeof window>"u"?!1:!!window?.webkit?.messageHandlers?.nativeBridge}const Ic=new Map,Oc=new Map;function jF(){typeof window>"u"||window.__tokentrackerNativeSaveListener||(window.__tokentrackerNativeSaveListener=!0,window.addEventListener("native:saveImageResult",t=>{const e=t?.detail||{},n=typeof e.requestId=="string"?e.requestId:null;if(!n||!Ic.has(n))return;const r=Ic.get(n);Ic.delete(n),r({ok:!!e.ok,path:typeof e.path=="string"?e.path:void 0,error:typeof e.error=="string"?e.error:void 0})}),window.addEventListener("native:copyImageResult",t=>{const e=t?.detail||{},n=typeof e.requestId=="string"?e.requestId:null;if(!n||!Oc.has(n))return;const r=Oc.get(n);Oc.delete(n),r({ok:!!e.ok,error:typeof e.error=="string"?e.error:void 0})}))}async function sle(t){if(!UF()||typeof window>"u")return{ok:!1,error:"native bridge unavailable"};const e=window?.webkit?.messageHandlers?.nativeBridge;if(!e)return{ok:!1,error:"native bridge unavailable"};jF();const n=`copy_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return new Promise(r=>{const i=window.setTimeout(()=>{Oc.has(n)&&(Oc.delete(n),r({ok:!1,error:"timeout"}))},8e3);Oc.set(n,s=>{window.clearTimeout(i),r(s)});try{e.postMessage({type:"action",name:"copyImageToClipboard",requestId:n,dataUrl:t})}catch(s){Oc.delete(n),window.clearTimeout(i),r({ok:!1,error:s?.message||String(s)})}})}async function VP(t,e){if(!UF()||typeof window>"u")return{ok:!1,error:"native bridge unavailable"};const n=window?.webkit?.messageHandlers?.nativeBridge;if(!n)return{ok:!1,error:"native bridge unavailable"};jF();const r=`save_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return new Promise(i=>{const s=window.setTimeout(()=>{Ic.has(r)&&(Ic.delete(r),i({ok:!1,error:"timeout"}))},8e3);Ic.set(r,a=>{window.clearTimeout(s),i(a)});try{n.postMessage({type:"action",name:"saveImageToDownloads",requestId:r,filename:e,dataUrl:t})}catch(a){Ic.delete(r),window.clearTimeout(s),i({ok:!1,error:a?.message||String(a)})}})}const BF=1200,zF=1630,VF={broadsheet:{width:1200,height:1630},"annual-report":{width:1080,height:1865}},ale="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Inter+Tight:wght@400;500;600;700&family=IBM+Plex+Serif:ital,wght@0,400;0,500;0,600;1,400&family=IBM+Plex+Mono:wght@400;500&family=Space+Grotesk:wght@500;600;700&display=swap";let w_=!1;function ole(){if(typeof document>"u"||w_)return;if(document.querySelector('link[data-share-card-fonts="true"]')){w_=!0;return}const e=document.createElement("link");e.rel="stylesheet",e.href=ale,e.dataset.shareCardFonts="true",e.crossOrigin="anonymous",document.head.appendChild(e),w_=!0}async function lle(){if(typeof document>"u")return;const t=document.fonts;if(!(!t||typeof t.ready?.then!="function"))try{await t.ready}catch{}}async function cle(t,e={}){if(typeof window>"u"||!t)return null;ole(),await lle(),await new Promise(c=>requestAnimationFrame(()=>c(null)));const{toBlob:n,toPng:r}=await n4(async()=>{const{toBlob:c,toPng:u}=await import("./index-BeoRn2gJ.js");return{toBlob:c,toPng:u}},[]),i=e.pixelRatio??2,s=t.offsetWidth||BF,a=t.offsetHeight||zF,o={pixelRatio:i,cacheBust:!0,width:s,height:a,style:{width:`${s}px`,height:`${a}px`},skipFonts:!1,filter:c=>!(c instanceof HTMLElement)||c.dataset?.screenshotExclude!=="true"};try{const c=await n(t,o);if(c)return c}catch{}try{const c=await r(t,o);return c?await(await fetch(c)).blob():null}catch{return null}}async function S_(t){return new Promise(e=>{const n=new FileReader;n.onload=()=>{const r=typeof n.result=="string"?n.result:null;e(r)},n.onerror=()=>e(null),n.readAsDataURL(t)})}function HP(t,e){if(typeof window>"u"||!t)return!1;try{const n=URL.createObjectURL(t),r=document.createElement("a");return r.href=n,r.download=e,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3),!0}catch{return!1}}function D1(t){const e=ti(t);return Number.isFinite(e)?e:0}function ule(t){return t?D1(t.billable_total_tokens??t.total_tokens):0}function dle(t){const e=Array.isArray(t?.weeks)?t.weeks:[];if(!e.length)return{weeks:[],totalDays:0,activeDays:0};let n=0,r=0;return{weeks:e.map(s=>(Array.isArray(s)?s:[]).slice(0,7).map(o=>{const c=!!o?.future,u=Number.isFinite(o?.level)?Math.max(0,Math.min(4,Math.round(o.level))):0;o?.day&&!c&&(n+=1,u>0&&(r+=1));const f=o?.billable_total_tokens??o?.total_tokens??o?.value??0,h=Number.isFinite(f)?Math.max(0,f):0;return{day:typeof o?.day=="string"?o.day:"",level:u,value:h,future:c}})),totalDays:n,activeDays:r}}function fle(t){const{handle:e,startDate:n,activeDays:r,summary:i,topModels:s,rank:a,period:o,periodFrom:c,periodTo:u,heatmap:f,capturedAt:h}=t,m=ule(i),g=D1(i?.total_cost_usd),v=Array.isArray(s)?s.slice(0,3).map(b=>({id:b?.id??null,name:typeof b?.name=="string"&&b.name?b.name:"—",tokens:D1(b?.tokens),percent:typeof b?.percent=="string"&&b.percent?b.percent:"0.0"})):[],w=dle(f);return{handle:e||"—",startDate:n||null,activeDays:Number.isFinite(r)&&r>0?Math.floor(r):0,totalTokens:m,totalCost:g,period:o,periodFrom:c,periodTo:u,topModels:v,rank:typeof a=="number"&&Number.isFinite(a)&&a>0?Math.floor(a):null,heatmapWeeks:w.weeks,heatmapTotalDays:w.totalDays,heatmapActiveDays:w.activeDays,capturedAt:h||new Date().toISOString()}}const hle=["share.month_short.jan","share.month_short.feb","share.month_short.mar","share.month_short.apr","share.month_short.may","share.month_short.jun","share.month_short.jul","share.month_short.aug","share.month_short.sep","share.month_short.oct","share.month_short.nov","share.month_short.dec"];function ple(t){const e=hle[t];return e?O(e):"—"}function HF(t,e){return O("share.date.month_year",{month:ple(t),year:e})}function mle(t){if(!t)return"—";const e=t.split("-");if(e.length!==3)return t;const[n,r]=e,i=Number(r)-1;return i<0||i>11?t:HF(i,n)}function gle(t){if(t.period==="total")return O("share.issue.all_time");if(t.period==="day"&&t.periodTo)return t.periodTo.replace(/-/g,".");if(t.period==="custom"&&t.periodFrom&&t.periodTo)return`${t.periodFrom.replace(/-/g,".")} — ${t.periodTo.replace(/-/g,".")}`;if(t.periodTo){const e=new Date(`${t.periodTo}T00:00:00Z`);if(!Number.isNaN(e.getTime()))return HF(e.getUTCMonth(),e.getUTCFullYear())}return O(`usage.period.${t.period}`)}function L1(t){return Number.isFinite(t)?Math.round(t).toLocaleString("en-US"):"—"}function WF(t){return!Number.isFinite(t)||t<=0?"$0.00":t>=1e3?`$${Math.round(t).toLocaleString("en-US")}`:`$${t.toFixed(2)}`}function yle(t){const e=t.topModels[0];if(e){const n=parseFloat(e.percent);return Number.isFinite(n)&&n>=60?O("share.hook.top_loyal",{percent:Math.round(n),name:e.name}):t.activeDays>=60?O("share.hook.days_record",{days:t.activeDays}):Number.isFinite(n)&&n>=30?O("share.hook.top_led",{name:e.name,percent:Math.round(n)}):t.topModels.length>1?O("share.hook.multi_models",{count:t.topModels.length,days:t.activeDays}):O("share.hook.days_with_model",{days:t.activeDays,name:e.name})}return t.activeDays>0?O("share.hook.days_record",{days:t.activeDays}):O("share.hook.new_chapter")}function vle(t,e){const n=(t||"").length;if(n<=e.baseChars)return e.baseSize;const r=e.baseSize-(n-e.baseChars)*e.shrinkPerChar;return Math.max(e.minSize,r)}function xle(t){if(!t||t.future)return null;const e=typeof t.level=="number"?t.level:0;return e<0?0:e>4?4:Math.round(e)}function ble({weeks:t,palette:e,width:n,gap:r=3,radius:i=2,emptyColor:s}){if(!Array.isArray(t)||t.length===0||!n||n<=0)return null;const a=e||["#eee","#ccc","#999","#666","#333"],o=s||a[0],c=t.length,u=(c-1)*r,f=Math.max(4,(n-u)/c),h=7*f+6*r;return p.jsx("svg",{width:n,height:h,viewBox:`0 0 ${n} ${h}`,xmlns:"http://www.w3.org/2000/svg","aria-hidden":!0,style:{display:"block"},children:t.map((m,g)=>(Array.isArray(m)?m:[]).map((w,b)=>{if(b>=7)return null;const _=xle(w),E=g*(f+r),M=b*(f+r),T=_===null?o:a[_];return p.jsx("rect",{x:E,y:M,width:f,height:f,rx:i,ry:i,fill:T},`${g}-${b}`)}))})}const _le="oklch(0.97 0.01 85)",Ji="oklch(0.18 0.02 85)",ll="oklch(0.38 0.015 85)",WP="oklch(0.55 0.012 85)",mc="oklch(0.55 0.22 25)",gc='"Instrument Serif", "Times New Roman", Georgia, serif',wle='"Inter Tight", "Helvetica Neue", Arial, sans-serif',Sle=["oklch(0.93 0.013 80)","oklch(0.87 0.04 55)","oklch(0.78 0.09 45)","oklch(0.67 0.16 35)","oklch(0.55 0.22 25)"];function GF({data:t}){const e=gle(t),n=L1(t.totalTokens),r=WF(t.totalCost),i=mle(t.startDate),s=vle(n,{baseSize:188,baseChars:9,shrinkPerChar:14,minSize:104}),a=yle(t),o=Array.isArray(t.heatmapWeeks)&&t.heatmapWeeks.length>0;return p.jsxs("div",{style:{width:"100%",height:"100%",background:_le,color:Ji,fontFamily:wle,padding:"80px 88px 68px 88px",boxSizing:"border-box",display:"flex",flexDirection:"column",position:"relative"},children:[p.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:24,paddingBottom:14,borderBottom:`1px solid ${WP}`},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,fontSize:14,fontWeight:500,letterSpacing:"0.22em",textTransform:"uppercase",color:Ji},children:[p.jsx("div",{style:{width:10,height:10,borderRadius:"50%",background:mc}}),"The Token Tracker"]}),p.jsxs("div",{style:{fontSize:12,letterSpacing:"0.22em",textTransform:"uppercase",color:ll,textAlign:"right"},children:[O("share.card.broadsheet.issue")," № ",e]})]}),p.jsxs("div",{style:{marginTop:24,display:"flex",justifyContent:"space-between",alignItems:"flex-end",gap:24},children:[p.jsxs("div",{children:[p.jsx("div",{style:{fontSize:12,letterSpacing:"0.2em",textTransform:"uppercase",color:ll,marginBottom:6},children:O("share.card.broadsheet.by")}),p.jsx("div",{style:{fontFamily:gc,fontSize:52,fontStyle:"italic",lineHeight:1,color:Ji,letterSpacing:"-0.01em"},children:t.handle})]}),p.jsxs("div",{style:{fontSize:12,letterSpacing:"0.18em",textTransform:"uppercase",color:ll,textAlign:"right",lineHeight:1.6},children:[O("share.card.broadsheet.tracked_since"),p.jsx("br",{}),p.jsx("span",{style:{color:Ji},children:i})]})]}),p.jsxs("div",{style:{marginTop:40,display:"flex",flexDirection:"column"},children:[p.jsx("div",{style:{fontSize:13,letterSpacing:"0.3em",textTransform:"uppercase",color:mc,marginBottom:10},children:O("share.card.broadsheet.total_tokens")}),p.jsx("div",{style:{fontFamily:gc,fontSize:s,fontWeight:400,lineHeight:.86,letterSpacing:"-0.032em",color:Ji,fontFeatureSettings:'"lnum" 1, "tnum" 1',whiteSpace:"nowrap",overflow:"hidden"},children:n}),p.jsxs("div",{style:{marginTop:14,fontFamily:gc,fontStyle:"italic",fontSize:34,lineHeight:1.15,color:Ji,letterSpacing:"-0.005em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:["“",a,"”"]}),p.jsx("div",{style:{marginTop:14,height:1,background:mc,width:"100%"}}),p.jsxs("div",{style:{marginTop:10,display:"flex",justifyContent:"space-between",fontSize:13,letterSpacing:"0.16em",textTransform:"uppercase",color:ll},children:[p.jsxs("span",{children:[O("share.card.broadsheet.estimated_spend")," · ",r]}),p.jsx("span",{children:O("share.card.broadsheet.billable_days",{days:t.activeDays})})]})]}),o?p.jsxs("section",{style:{marginTop:40},children:[p.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",marginBottom:12},children:[p.jsx("div",{style:{fontSize:12,letterSpacing:"0.3em",textTransform:"uppercase",color:Ji,fontWeight:600},children:O("share.card.broadsheet.heatmap_title")}),p.jsx("div",{style:{fontSize:11,letterSpacing:"0.18em",textTransform:"uppercase",color:ll},children:O("share.card.broadsheet.heatmap_days_on_record",{active:t.heatmapActiveDays,total:t.heatmapTotalDays})})]}),p.jsx(ble,{weeks:t.heatmapWeeks,palette:Sle,width:1024,gap:3,radius:2})]}):null,p.jsxs("section",{style:{marginTop:30,flex:1},children:[p.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",borderBottom:`1px solid ${Ji}`,paddingBottom:10,marginBottom:6},children:[p.jsx("div",{style:{fontSize:12,letterSpacing:"0.3em",textTransform:"uppercase",color:Ji,fontWeight:600},children:O("share.card.broadsheet.roster_title")}),p.jsx("div",{style:{fontSize:11,letterSpacing:"0.18em",textTransform:"uppercase",color:ll},children:O("share.card.broadsheet.roster_subtitle")})]}),t.topModels.length===0?p.jsx("div",{style:{fontFamily:gc,fontStyle:"italic",fontSize:26,color:ll,paddingTop:14},children:O("share.card.broadsheet.empty")}):t.topModels.map((c,u)=>p.jsxs("div",{style:{display:"grid",gridTemplateColumns:"52px 1fr auto 68px",alignItems:"baseline",gap:16,padding:"13px 0",borderBottom:`1px solid ${WP}`},children:[p.jsx("div",{style:{fontFamily:gc,fontSize:34,fontStyle:"italic",color:mc,lineHeight:1},children:String(u+1).padStart(2,"0")}),p.jsx("div",{style:{fontFamily:gc,fontSize:32,color:Ji,lineHeight:1.1,letterSpacing:"-0.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:c.name}),p.jsx("div",{style:{fontFamily:gc,fontSize:28,color:Ji,fontFeatureSettings:'"lnum" 1, "tnum" 1',whiteSpace:"nowrap"},children:L1(c.tokens)}),p.jsxs("div",{style:{fontSize:13,letterSpacing:"0.1em",color:ll,textAlign:"right",fontFeatureSettings:'"tnum" 1'},children:[c.percent,"%"]})]},c.id||c.name))]}),p.jsxs("footer",{style:{marginTop:18,paddingTop:12,borderTop:`1px solid ${Ji}`,display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:12,letterSpacing:"0.22em",textTransform:"uppercase",color:Ji},children:[p.jsxs("div",{style:{display:"flex",gap:28},children:[p.jsxs("span",{children:[O("share.card.broadsheet.global_rank")," ",p.jsxs("span",{style:{color:mc},children:["№ ",t.rank!=null?t.rank:"—"]})]}),p.jsxs("span",{children:[O("share.card.broadsheet.active_days")," ",p.jsx("span",{style:{color:mc},children:O("share.card.broadsheet.days_count",{days:t.activeDays})})]})]}),p.jsxs("div",{children:[O("share.card.broadsheet.track_yours")," ",p.jsx("span",{style:{color:mc},children:"→ tokentracker.cc"})]})]})]})}const kle=VF["annual-report"].width,Ele="#0a0820",cl="#ffffffee",Ec="rgba(255,255,255,0.45)",k_="#a78bfa",Mle={background:"rgba(20,15,50,0.38)",backdropFilter:"blur(40px)",WebkitBackdropFilter:"blur(40px)",border:"1px solid rgba(255,255,255,0.05)",boxShadow:["0 39px 56px -36px rgba(255,255,255,0.10) inset","0 7px 11px -4px rgba(255,255,255,0.06) inset","0 -82px 68px -64px rgba(101,67,149,0.08) inset","0 98px 100px -48px rgba(208,171,255,0.06) inset","0 4px 18px 0 rgba(156,146,215,0.06) inset","0 1px 40px 0 rgba(228,222,255,0.04) inset"].join(", ")},Cg={background:"rgba(20,15,50,0.38)",backdropFilter:"blur(32px)",WebkitBackdropFilter:"blur(32px)",border:"1px solid rgba(255,255,255,0.06)",boxShadow:"0 1px 8px 0 rgba(228,222,255,0.06) inset"},I1='"Space Grotesk", "Inter Tight", sans-serif',E_='"Inter Tight", sans-serif',Tle="rgba(255,255,255,0.06)",$F=[Tle,"#4a3d8f","#6b5cbe","#9060e0","#d946ef"],YF=48,qF=28,vy=4,XF=20,Cle=kle-YF*2-qF*2,Ale=(Cle-XF*2)/3,O1=Math.min(Math.floor((Ale-vy*6)/7),40),Rle=O1*7+vy*6;function Ple(t){if(!Array.isArray(t))return t;const e=[];for(const o of t)if(Array.isArray(o))for(const c of o)c?.day&&!c.future&&c.value>0&&e.push(c.value);if(!e.length)return t;e.sort((o,c)=>o-c);const n=o=>{const c=e.length,u=(c-1)*o,f=Math.floor(u);return Math.round((e[f]??0)+((e[Math.min(c-1,f+1)]??0)-(e[f]??0))*(u-f))},r=n(.5),i=n(.75),s=n(.9),a=o=>!o||o<=0?0:o<=r?1:o<=i?2:o<=s?3:4;return t.map(o=>Array.isArray(o)?o.map(c=>c?.day&&!c.future&&typeof c.value=="number"?{...c,level:a(c.value)}:c):o)}function Nle(t){if(!Array.isArray(t))return[];const e={},n=Ple(t);for(const r of n)if(Array.isArray(r))for(const i of r){if(!i?.day||i.future)continue;const s=i.day.split("-");if(s.length<2)continue;const a=`${s[0]}-${s[1]}`;(e[a]??=[]).push(i)}return Object.entries(e).sort(([r],[i])=>r.localeCompare(i)).slice(-12).map(([r,i])=>({month:parseInt(r.split("-")[1],10),cells:i}))}function Dle(t){if(!t.length)return[];const e=[...t].sort((a,o)=>a.day.localeCompare(o.day));let n=new Date(`${e[0].day}T00:00:00Z`).getUTCDay();const r=Array(n).fill(null).concat(e),i=[];for(let a=0;a<r.length;a+=7)i.push(r.slice(a,a+7));const s=i[i.length-1];for(;s&&s.length<7;)s.push(null);return i.slice(0,6)}const Lle=["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ile(t){if(!Array.isArray(t))return 0;const e=[];for(const i of t)if(Array.isArray(i))for(const s of i)s?.day&&!s.future&&e.push(s);e.sort((i,s)=>i.day.localeCompare(s.day));let n=0,r=0;for(const i of e)(i.level||0)>0?(r++,r>n&&(n=r)):r=0;return n}function GP(t){const[e,n]=x.useState(null);return x.useEffect(()=>{if(!t){n(null);return}let r=!1;const i=new Image;return i.crossOrigin="anonymous",i.onload=()=>{if(!r)try{const s=document.createElement("canvas");s.width=i.naturalWidth,s.height=i.naturalHeight,s.getContext("2d").drawImage(i,0,0),n(s.toDataURL("image/png"))}catch{n(null)}},i.onerror=()=>{r||n(null)},i.src=t,()=>{r=!0}},[t]),e}function Ole({data:t}){const e=Dle(t.cells);return p.jsxs("div",{children:[p.jsx("div",{style:{fontSize:16,fontWeight:600,color:Ec,fontFamily:I1,marginBottom:4},children:Lle[t.month]}),p.jsx("div",{style:{display:"flex",flexDirection:"column",gap:vy},children:e.map((n,r)=>p.jsx("div",{style:{display:"flex",gap:vy},children:n.map((i,s)=>{const a=i?Math.min(4,Math.max(0,i.level||0)):-1;return p.jsx("div",{style:{width:O1,height:O1,borderRadius:4,background:a<0?"transparent":$F[a]}},s)})},r))})]})}function Fle({data:t}){const e=Nle(t.heatmapWeeks),n=Ile(t.heatmapWeeks),r=t.topModels[0],i=t.avatarUrl||null,s=GP(i),a=GP("/neon_bg.png"),o=(t.handle||"?")[0].toUpperCase(),c=16;return p.jsxs("div",{style:{width:"100%",height:"100%",background:Ele,fontFamily:I1,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[p.jsx("img",{src:a||"/neon_bg.png",alt:"",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",pointerEvents:"none"}}),p.jsxs("div",{style:{position:"relative",zIndex:1,display:"flex",flexDirection:"column",height:"100%",padding:YF,boxSizing:"border-box"},children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:c*3},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[p.jsx("img",{src:"/app-icon.png",alt:"",width:64,height:64,style:{width:64,height:64,borderRadius:16,display:"block"}}),p.jsxs("div",{children:[p.jsx("div",{style:{fontSize:20,fontWeight:500,color:Ec,lineHeight:1.2},children:"Token Tracker"}),p.jsx("div",{style:{fontSize:36,fontWeight:700,lineHeight:1.15,color:cl},children:O("share.card.annual.report_title")})]})]}),p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[p.jsx("div",{style:{width:48,height:48,borderRadius:"50%",background:"linear-gradient(135deg,#4c1d95,#7c3aed)",display:"flex",alignItems:"center",justifyContent:"center",border:"2px solid rgba(255,255,255,0.15)",overflow:"hidden",flexShrink:0},children:s?p.jsx("img",{src:s,alt:"",width:48,height:48,style:{width:48,height:48,objectFit:"cover",display:"block"},crossOrigin:"anonymous",referrerPolicy:"no-referrer"}):p.jsx("span",{style:{fontSize:20,fontWeight:700,color:cl},children:o})}),p.jsx("div",{style:{fontSize:32,fontWeight:700,color:cl},children:t.handle})]})]}),p.jsxs("div",{style:{...Mle,borderRadius:22,padding:qF,marginBottom:c},children:[p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:14,color:Ec},children:[p.jsx("span",{children:O("share.card.annual.less")}),$F.map((u,f)=>p.jsx("div",{style:{width:16,height:16,borderRadius:3,background:u}},f)),p.jsx("span",{children:O("share.card.annual.more")})]}),p.jsx("div",{style:{fontSize:16,fontWeight:700,letterSpacing:"0.14em",color:"rgba(255,255,255,0.22)",textTransform:"uppercase"},children:O("share.card.annual.heatmap_title")})]}),p.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(3,${Rle}px)`,gap:`8px ${XF}px`,justifyContent:"center"},children:e.map(u=>p.jsx(Ole,{data:u},u.month))})]}),p.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:c,marginBottom:c},children:[p.jsxs("div",{style:{...Cg,borderRadius:22,padding:"28px 16px",textAlign:"center"},children:[p.jsx("div",{style:{fontFamily:E_,fontSize:52,fontWeight:700,color:cl,letterSpacing:"-0.02em",lineHeight:1},children:L1(t.totalTokens)}),p.jsx("div",{style:{fontSize:22,color:Ec,marginTop:12},children:O("share.card.annual.total_tokens")})]}),p.jsxs("div",{style:{...Cg,borderRadius:22,padding:"28px 16px",textAlign:"center"},children:[p.jsx("div",{style:{fontFamily:E_,fontSize:52,fontWeight:700,color:cl,letterSpacing:"-0.02em",lineHeight:1},children:WF(t.totalCost)}),p.jsx("div",{style:{fontSize:22,color:Ec,marginTop:12},children:O("share.card.annual.estimated_cost")})]})]}),p.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:c},children:[p.jsxs("div",{style:{...Cg,borderRadius:22,padding:"18px 24px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[p.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:k_,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("path",{d:"M12 2v4m0 12v4M4.93 4.93l2.83 2.83m8.48 8.48 2.83 2.83M2 12h4m12 0h4M4.93 19.07l2.83-2.83m8.48-8.48 2.83-2.83"}),p.jsx("circle",{cx:"12",cy:"12",r:"4"})]}),p.jsx("span",{style:{fontSize:20,color:Ec},children:O("share.card.annual.longest_streak")})]}),p.jsx("span",{style:{fontFamily:E_,fontSize:28,fontWeight:700,color:cl},children:O("share.card.annual.days_count",{days:n})})]}),p.jsxs("div",{style:{...Cg,borderRadius:22,padding:"18px 24px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[p.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:k_,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),p.jsx("circle",{cx:"12",cy:"12",r:"4"})]}),p.jsx("span",{style:{fontSize:20,color:Ec},children:O("share.card.annual.top_model")})]}),p.jsx("span",{style:{fontFamily:I1,fontSize:28,fontWeight:700,color:cl},children:r?r.name:"—"})]})]}),p.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"auto"},children:[p.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[p.jsx("img",{src:"/app-icon.png",alt:"",width:44,height:44,style:{width:44,height:44,borderRadius:8,display:"block"}}),p.jsx("span",{style:{fontSize:22,fontWeight:600,color:cl},children:"Token Tracker"})]}),p.jsx("span",{style:{fontSize:22,fontWeight:600,color:k_},children:"tokentracker.cc"})]})]})]})}const KF=[{id:"annual-report",labelKey:"share.variant.neon"},{id:"broadsheet",labelKey:"share.variant.broadsheet"}],Ule={broadsheet:GF,"annual-report":Fle};function ZF(t){return VF[t]||{width:BF,height:zF}}function jle(t){const e=KF.find(n=>n.id===t);return e?.labelKey?O(e.labelKey):t}const $P=x.forwardRef(function({data:e,variant:n},r){const i=Ule[n]||GF,{width:s,height:a}=ZF(n);return p.jsx("div",{ref:r,"data-share-card":"true",style:{width:s,height:a,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:p.jsx(i,{data:e})})});function Ag(){return typeof window>"u"?!1:!!window?.webkit?.messageHandlers?.nativeBridge}const Ble=440;function zle(){const[t,e]=x.useState(null),n=x.useRef(null),r=x.useCallback((i,s="info")=>{n.current&&window.clearTimeout(n.current),e({id:Date.now(),kind:s,text:i}),n.current=window.setTimeout(()=>e(null),2800)},[]);return x.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{toast:t,push:r}}function M_({onClick:t,disabled:e,children:n,emphasis:r,ariaLabel:i}){return p.jsx("button",{type:"button",onClick:t,disabled:e,"aria-label":i,className:["group relative flex items-center justify-between gap-3 w-full px-4 py-3 text-left","rounded-lg border transition-colors",r?"border-oai-black dark:border-oai-white bg-oai-black dark:bg-oai-white text-oai-white dark:text-oai-black hover:opacity-90":"border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600",e?"opacity-60 cursor-not-allowed":"cursor-pointer"].join(" "),children:n})}function Vle({open:t,onClose:e,data:n,twitterText:r}){const[i,s]=x.useState(null),[a,o]=x.useState(""),[c,u]=x.useState("annual-report"),f=x.useRef(null),{toast:h,push:m}=zle(),g=la(),v=x.useMemo(()=>{const k=g?.user;if(!k||typeof k!="object")return null;const N=k.user_metadata||{},B=k.profile||{},L=N.avatar_url||N.picture||B.avatar_url||k.avatar_url;return typeof L=="string"&&L.trim()?L.trim():null},[g?.user]);x.useEffect(()=>{t&&(s(null),o(n?.handle||""))},[t,n?.handle]);const w=n&&{...n,handle:a||n.handle,avatarUrl:v},{width:b,height:_}=ZF(c),E=Ble/b;x.useEffect(()=>{if(!t)return;const k=N=>{N.key==="Escape"&&e?.()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[t,e]);const M=x.useCallback(async()=>{const k=f.current;if(!k)return null;try{return await cle(k)}catch(N){return console.warn("[share] capture failed",N),null}},[]),T=x.useCallback(async()=>{if(i)return;s("copy");const k=await M();if(!k){m(O("share.toast.failed"),"error"),s(null);return}let N=!1;if(Ag()){const B=await S_(k);B&&(N=(await sle(B)).ok)}else N=await Bw(k);m(O(N?"share.toast.copied":"share.toast.failed"),N?"success":"error"),s(null)},[i,M,m]),R=x.useCallback(()=>`tokentracker-share-${Date.now()}.png`,[]),A=x.useCallback(async()=>{if(i)return;s("download");const k=await M();if(!k){m(O("share.toast.failed"),"error"),s(null);return}if(Ag()){const B=await S_(k);if(B&&(await VP(B,R())).ok){m(O("share.toast.downloaded"),"success"),s(null);return}}const N=HP(k,R());m(O(N?"share.toast.downloaded":"share.toast.failed"),N?"success":"error"),s(null)},[i,M,R,m]),P=x.useCallback(async()=>{if(i)return;s("x");const k=await M();if(!k){m(O("share.toast.failed"),"error"),s(null);return}if(Ag()){const B=await S_(k);B&&(await VP(B,R()),m(O("share.toast.downloaded"),"success"))}else await Bw(k)?m(O("share.toast.copied"),"success"):HP(k,R());const N=new URL("https://twitter.com/intent/tweet");if(r&&N.searchParams.set("text",r),Ag())try{window.webkit?.messageHandlers?.nativeBridge?.postMessage({type:"action",name:"openURL",value:N.toString()})}catch{window.open(N.toString(),"_blank","noopener,noreferrer")}else window.open(N.toString(),"_blank","noopener,noreferrer");s(null)},[i,M,m,r,R]);return t?p.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":O("share.modal.title"),"data-screenshot-exclude":"true",className:"fixed inset-0 z-[9999] flex items-center justify-center p-4 sm:p-6",style:{background:"rgba(10,10,10,0.72)"},onClick:k=>{k.target===k.currentTarget&&e?.()},children:[p.jsx("div",{"aria-hidden":!0,style:{position:"fixed",left:0,top:0,width:b,height:_,pointerEvents:"none",opacity:0,zIndex:-1,clip:"rect(0,0,0,0)",overflow:"hidden"},children:p.jsx($P,{ref:f,data:w,variant:c})}),p.jsxs(tr.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:12},transition:{duration:.18,ease:[.2,.8,.2,1]},className:"relative w-full max-w-[1040px] max-h-[92vh] overflow-hidden rounded-2xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-black shadow-oai-lg",children:[p.jsxs("div",{className:"flex flex-col lg:flex-row max-h-[92vh]",children:[p.jsx("div",{className:"flex-1 min-w-0 p-4 sm:p-7 bg-oai-gray-50 dark:bg-oai-gray-950 flex items-center justify-center overflow-auto",children:p.jsxs("div",{style:{width:b*E,height:_*E,flexShrink:0,position:"relative"},className:"rounded-xl overflow-hidden shadow-oai-md ring-1 ring-black/5",children:[i?p.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-white/70 dark:bg-black/50",children:p.jsxs("svg",{className:"animate-spin h-6 w-6 text-oai-gray-500",viewBox:"0 0 24 24",fill:"none",children:[p.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),p.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}):null,p.jsx("div",{style:{width:b,height:_,transform:`scale(${E})`,transformOrigin:"top left"},children:p.jsx($P,{data:w,variant:c})})]})}),p.jsxs("div",{className:"w-full lg:w-[340px] flex-shrink-0 border-t lg:border-t-0 lg:border-l border-oai-gray-200 dark:border-oai-gray-800 p-5 sm:p-6 flex flex-col gap-5 overflow-y-auto",children:[p.jsxs("div",{className:"flex items-start justify-between gap-2",children:[p.jsxs("div",{children:[p.jsx("h2",{className:"text-lg font-semibold text-oai-black dark:text-oai-white",children:O("share.modal.title")}),p.jsx("p",{className:"mt-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:O("share.modal.subtitle")})]}),p.jsx("button",{type:"button",onClick:e,"aria-label":O("share.modal.close"),className:"p-1.5 -mt-1 -mr-1 rounded-md text-oai-gray-500 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:p.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),p.jsxs("div",{children:[p.jsx("label",{htmlFor:"share-handle",className:"text-[11px] tracking-[0.18em] uppercase text-oai-gray-500 dark:text-oai-gray-400 mb-1.5 block",children:O("share.modal.name_label")}),p.jsx("input",{id:"share-handle",type:"text",value:a,onChange:k=>o(k.target.value),placeholder:O("share.modal.name_placeholder"),className:"w-full px-3 py-2 text-sm rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white placeholder:text-oai-gray-400 dark:placeholder:text-oai-gray-600 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-oai-brand transition-colors"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"text-[11px] tracking-[0.18em] uppercase text-oai-gray-500 dark:text-oai-gray-400 mb-1.5 block",children:O("share.modal.style_label")}),p.jsx("div",{className:"flex gap-2",children:KF.map(k=>p.jsx("button",{type:"button",onClick:()=>u(k.id),className:["flex-1 px-3 py-2 text-sm rounded-lg border transition-colors",c===k.id?"border-oai-black dark:border-oai-white bg-white dark:bg-oai-gray-900 text-oai-black dark:text-oai-white font-medium":"border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 text-oai-gray-500 dark:text-oai-gray-400 hover:border-oai-gray-400 dark:hover:border-oai-gray-600"].join(" "),children:jle(k.id)},k.id))})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[p.jsxs(M_,{onClick:P,disabled:!!i,emphasis:!0,children:[p.jsxs("span",{className:"flex items-center gap-3",children:[p.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:p.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),p.jsx("span",{className:"font-medium text-sm",children:O("share.modal.action.x")})]}),p.jsx("span",{className:"text-[11px] opacity-70",children:O(i==="x"?"share.toast.working":"share.modal.hint.x")})]}),p.jsxs(M_,{onClick:A,disabled:!!i,children:[p.jsxs("span",{className:"flex items-center gap-3",children:[p.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[p.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),p.jsx("polyline",{points:"7 10 12 15 17 10"}),p.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),p.jsx("span",{className:"font-medium text-sm",children:O("share.modal.action.download")})]}),p.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:"PNG"})]}),p.jsxs(M_,{onClick:T,disabled:!!i,children:[p.jsxs("span",{className:"flex items-center gap-3",children:[p.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[p.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),p.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),p.jsx("span",{className:"font-medium text-sm",children:O("share.modal.action.copy")})]}),p.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:O("share.modal.hint.copy")})]})]}),p.jsx("div",{className:"mt-auto pt-4 border-t border-oai-gray-200 dark:border-oai-gray-800",children:p.jsx("p",{className:"text-[11px] leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:O("share.modal.footer")})})]})]}),p.jsx(Lp,{children:h?p.jsx(tr.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},className:"pointer-events-none absolute left-1/2 bottom-4 -translate-x-1/2",children:p.jsx("div",{className:["px-4 py-2 rounded-full text-xs font-medium shadow-oai-md",h.kind==="error"?"bg-red-600 text-white":h.kind==="success"?"bg-oai-black dark:bg-oai-white text-oai-white dark:text-oai-black":"bg-oai-gray-800 text-white"].join(" "),children:h.text})},h.id):null})]})]}):null}function Hle(t){const{enabled:e,handle:n,startDate:r,activeDays:i,summary:s,topModels:a,period:o,periodFrom:c,periodTo:u,heatmap:f,accessToken:h,userId:m}=t,[g,v]=x.useState(null);return x.useEffect(()=>{if(!e||!m&&!vr())return;let w=!1;return(async()=>{try{const _=await TL({accessToken:h,userId:m,period:o==="day"||o==="custom"?"week":o,metric:"all",limit:100,offset:0});if(w)return;const M=(Array.isArray(_?.entries)?_.entries:Array.isArray(_)?_:[]).find(R=>R?.is_me===!0),T=typeof M?.rank=="number"?M.rank:null;v(T)}catch{w||v(null)}})(),()=>{w=!0}},[e,h,m,o]),x.useMemo(()=>fle({handle:n,startDate:r,activeDays:i,summary:s,topModels:a,rank:g,period:o,periodFrom:c,periodTo:u,heatmap:f}),[n,r,i,s,a,g,o,c,u,f])}const Wle=["day","week","month","total","custom"],T_=new Set(["day","hour","month"]),hh=new Set(["day","total","custom"]);function C_(t,e){if(typeof e=="number"&&e>0)return!0;if(typeof t=="bigint")return t>0n;if(typeof t=="number")return Number.isFinite(t)&&t>0;if(typeof t=="string"){const n=t.trim();if(!n)return!1;if(/^[0-9]+$/.test(n))try{return BigInt(n)>0n}catch{return!1}const r=Number(n);return Number.isFinite(r)&&r>0}return!1}function Rg(t){return t?t?.billable_total_tokens??t?.total_tokens:null}function YP(t){return t?t?.billable_total_tokens??t?.value??t?.total_tokens:null}function Gle(t){if(typeof t!="string"||!t)return null;const e=t.split("-");if(e.length!==3)return null;const n=Number(e[0]),r=Number(e[1])-1,i=Number(e[2]);if(!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i))return null;const s=new Date(Date.UTC(n,r,i));return Number.isFinite(s.getTime())?s:null}function $le(t,e){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()+e))}function Yle(t){return t?t==="www.tokentracker.cc"||t==="tokentracker.cc":!1}function qle(){if(typeof window>"u")return!1;const t=new URLSearchParams(window.location.search),e=String(t.get("force_install")||"").toLowerCase();return e!=="1"&&e!=="true"?!1:!Yle(window.location.hostname)}function Xle({baseUrl:t,auth:e,signedIn:n,sessionSoftExpired:r,signOut:i,publicMode:s=!1,publicToken:a=null,signInUrl:o="/sign-in",signUpUrl:c="/sign-up"}){const{resolvedLocale:u}=lu(),[f,h]=x.useState(!1),[m,g]=x.useState(null),[v,w]=x.useState(null),[b,_]=x.useState(!1),[E,M]=x.useState(null),[T,R]=x.useState(0),[A,P]=x.useState(0),[k,N]=x.useState(null),[B,L]=x.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(max-width: 640px)").matches),z=x.useMemo(()=>typeof window>"u"?!1:lE(window.location.search),[]),I=x.useMemo(()=>qle(),[]),[V,W]=x.useState(!1),[X,J]=x.useState(!1),F=2200,[G,Y]=x.useState(!0),[H,te]=x.useState(!1),[re,ue]=x.useState(!1),[ce,ee]=x.useState(!1),le=vr(),ve=n&&!r,Ne=x.useMemo(()=>ve&&(typeof e=="function"||typeof e=="string"||e&&typeof e=="object")?e:null,[e,ve]),be=ve?Ne:null,qe=s?wo(a):be,he=n||le||s,Ue=ve&&Fl(be),je=n&&r&&!s;x.useEffect(()=>{if(!n||le){g(null),w(null),_(!1),M(null);return}if(s)return;if(!Ue){g(null),w(null),_(!1),M(null);return}let Ge=!0;const Wt=()=>{g(null),w(null),_(!1),M(null)};return _(!0),M(null),(async()=>{let Kt=null;try{Kt=await Dl(be)}catch{Kt=null}if(Ge){if(!Kt){Wt();return}try{const tn={link_code:null,expires_at:null};if(!Ge)return;g(typeof tn?.link_code=="string"?tn.link_code:null),w(typeof tn?.expires_at=="string"?tn.expires_at:null)}catch(tn){if(!Ge)return;g(null),w(null),M(tn?.message||"Failed to load link code")}finally{if(!Ge)return;_(!1)}}})(),()=>{Ge=!1}},[t,le,n,s,Ue,be,A]);const et=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");x.useEffect(()=>{if(!et&&(!n||le||s)){N(null);return}if(!et&&!Ue){N(null);return}let Ge=!0;return(async()=>{let Wt=null;try{Wt=await Dl(be)}catch{Wt=null}if(Ge){if(!Wt&&!et){N(null);return}try{const Kt=await _7({baseUrl:t,accessToken:Wt});if(!Ge)return;N(Kt&&typeof Kt=="object"?Kt:null)}catch{if(!Ge)return;N(null)}}})(),()=>{Ge=!1}},[Ue,t,be,le,s,n]);const _e=x.useMemo(()=>{if(!v)return!1;const Ge=Date.parse(v);if(!Number.isFinite(Ge))return!1;const Wt=T||Date.now();return Ge<=Wt},[v,T]);x.useEffect(()=>{!n||le||s||!v||!_e||b||(g(null),w(null),M(null),P(Ge=>Ge+1))},[_e,v,b,le,n]),x.useEffect(()=>{if(!v||s)return;const Ge=Date.parse(v);if(!Number.isFinite(Ge))return;const Wt=Date.now();if(R(Wt),Ge<=Wt)return;const Kt=window.setTimeout(()=>R(Date.now()),Ge-Wt),tn=()=>{typeof document>"u"||document.visibilityState==="visible"&&R(Date.now())};return typeof document<"u"&&document.addEventListener("visibilitychange",tn),window.addEventListener("focus",tn),()=>{window.clearTimeout(Kt),typeof document<"u"&&document.removeEventListener("visibilitychange",tn),window.removeEventListener("focus",tn)}},[v]),x.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const Ge=window.matchMedia("(max-width: 640px)"),Wt=()=>L(Ge.matches);return Wt(),Ge.addEventListener?(Ge.addEventListener("change",Wt),()=>Ge.removeEventListener("change",Wt)):(Ge.addListener(Wt),()=>Ge.removeListener(Wt))},[]);const oe=x.useMemo(()=>bL(),[]),Q=x.useMemo(()=>_L(),[]),ze=x.useMemo(()=>JH(),[]),Re=s?null:e?.userId||e?.email||"default",[De,Le]=x.useState("month"),[$,U]=x.useState(null),[Z,pe]=x.useState(null),[Se,xe]=x.useState(!1),Ie=z?"total":De,He=x.useMemo(()=>Ie==="custom"&&$&&Z?{from:$,to:Z}:SL(Ie,{timeZone:oe,offsetMinutes:Q,now:ze}),[ze,Ie,oe,Q,$,Z]),Ye=He.from,ft=He.to,We=x.useMemo(()=>BH({timeZone:oe,offsetMinutes:Q}),[oe,Q]),Xe=x.useMemo(()=>zH({timeZone:oe,offsetMinutes:Q}),[oe,Q]),nt=x.useMemo(()=>`Local time (${Xe})`,[Xe]),ct=oe,Ke=Q,gt=We,ne=x.useMemo(()=>bk({timeZone:oe,offsetMinutes:Q,date:ze||new Date}),[ze,oe,Q]),Be=x.useMemo(()=>{const Ge=Gle(ne)||new Date,Wt=$le(Ge,-29);return{from:Hn(Wt),to:Hn(Ge)}},[ne]),{daily:ke,summary:Ae,rolling:Ve,source:ge,loading:ut,error:yt,refresh:qt}=pR({baseUrl:t,accessToken:qe,guestAllowed:je,from:Ye,to:ft,includeDaily:Ie!=="total",cacheKey:Re,timeZone:oe,tzOffsetMinutes:Q,now:ze}),{daily:Lt,loading:_t,refresh:wt}=pR({baseUrl:t,accessToken:qe,guestAllowed:je,from:Be.from,to:Be.to,includeDaily:!0,cacheKey:Re?`${Re}.daily-breakdown`:"daily-breakdown",timeZone:oe,tzOffsetMinutes:Q,now:ze}),{breakdown:un,loading:xn,refresh:ie}=nJ({baseUrl:t,accessToken:qe,guestAllowed:je,from:Ye,to:ft,cacheKey:Re,timeZone:oe,tzOffsetMinutes:Q}),[fe,Te]=x.useState(3),{entries:$e,loading:Ze,refresh:At}=YZ({baseUrl:t,accessToken:qe,limit:fe,from:Ye,to:ft,timeZone:oe,tzOffsetMinutes:Q}),St=Ie==="week"||Ie==="month",Pt=Ie==="week"||Ie==="month",xt=x.useMemo(()=>ke.filter(Ge=>Ge?.future?!1:!Ge?.day||!ne?!0:String(Ge.day)<=String(ne)),[ke,ne]),{rows:Tt,from:Xt,to:zt,loading:En,refresh:yn}=XZ({baseUrl:t,accessToken:qe,guestAllowed:je,period:Ie,from:Ye,to:ft,months:24,cacheKey:Re,timeZone:ct,tzOffsetMinutes:Ke,now:ze,sharedRows:St?ke:null,sharedRange:St?{from:Ye,to:ft}:null}),{daily:Cn,heatmap:In,loading:hr,refresh:An}=$Z({baseUrl:t,accessToken:qe,guestAllowed:je,weeks:52,cacheKey:Re,timeZone:oe,tzOffsetMinutes:Q,now:ze}),{refresh:K}=i4(),me=x.useMemo(()=>Ie==="day"?"hour":Ie==="total"?"month":"day",[Ie]),Pe=x.useMemo(()=>gR(me),[me]),Ee="day",we=x.useMemo(()=>gR(Ee),[]),[at,mt]=x.useState(()=>({key:"day",dir:"desc"}));x.useEffect(()=>{mt(Ge=>!T_.has(Ge.key)||Ge.key===me?Ge:{key:me,dir:Ge.dir})},[me]);const it=x.useMemo(()=>T_.has(at.key)&&at.key!==me?{...at,key:me}:at,[me,at]),pt=x.useMemo(()=>{if(Ie==="day")return Array.isArray(Tt)?Tt.filter(Kt=>Kt?.hour&&!Kt?.future):[];if(Ie==="total"){const Kt=Array.isArray(Tt)?Tt.filter(tn=>tn?.month&&!tn?.future):[];return mJ(Kt)}const Ge=xt;return!Ge.some(Kt=>!Kt?.missing&&!Kt?.future)&&ke.length>0?ke.filter(Kt=>!Kt?.future).slice(-30).filter(Kt=>Kt?.day):Ge},[Ie,Tt,xt,ke]),Et=x.useMemo(()=>yR(pt,it),[pt,it]),dt=x.useMemo(()=>pt.some(Ge=>!Ge?.missing&&!Ge?.future),[pt]),Vt=x.useMemo(()=>{if(!hh.has(Ie))return 1;const Ge=Math.ceil(Et.length/ay);return Ge>0?Ge:1},[Ie,Et.length]),[Ct,dn]=x.useState(0);x.useEffect(()=>{if(!hh.has(Ie)){dn(0);return}dn(Ge=>Math.min(Ge,Vt-1))},[Vt,Ie]),x.useEffect(()=>{hh.has(Ie)&&dn(0)},[Ie,at.dir,at.key]);const en=x.useMemo(()=>hh.has(Ie)?gJ(Et,Ct,ay):Et,[Ct,Ie,Et]),Rn=x.useMemo(()=>Lt.filter(Ge=>!Ge?.future&&Ge?.day).slice(-30),[Lt]),cn=x.useMemo(()=>T_.has(at.key)?{...at,key:Ee}:at,[at]),nr=x.useMemo(()=>yR(Rn,cn),[Rn,cn]),Ut=x.useMemo(()=>Pt?ke:Ie==="day"?Array.isArray(Tt)?Tt.filter(Ge=>Ge?.hour):[]:Tt,[ke,Ie,Tt,Pt]),Kr=Pt?Ye:Xt,wn=Pt?ft:zt;function ri(Ge,Wt){return Ge?.future?"—":Ge?.missing?O("shared.status.unsynced"):Oi(Wt==="total_tokens"?Rg(Ge):Ge?.[Wt])}function ii(Ge){const Wt=Ge?.[me];if(Wt==null)return"";const Kt=String(Wt);if(me==="hour"){const[tn,pr]=Kt.split("T");if(tn&&pr)return`${tn} ${pr.slice(0,5)}`}return Kt}function xi(Ge){const Wt=Ge?.[Ee];return Wt==null?"":String(Wt)}function ca(Ge){mt(Wt=>Wt.key===Ge?{key:Ge,dir:Wt.dir==="asc"?"desc":"asc"}:{key:Ge,dir:"desc"})}function Fn(Ge){return it.key!==Ge?"none":it.dir==="asc"?"ascending":"descending"}function nn(Ge){return it.key!==Ge?"":it.dir==="asc"?"▲":"▼"}function $i(Ge){return cn.key!==Ge?"none":cn.dir==="asc"?"ascending":"descending"}function cr(Ge){return cn.key!==Ge?"":cn.dir==="asc"?"▲":"▼"}const si=x.useMemo(()=>{if(!n&&!le&&!s&&!et)return 0;const Ge=Number(In?.active_days);if(Number.isFinite(Ge))return Ge;let Wt=0;const Kt=new Set,tn=(Yn,rr,Qn)=>{typeof Yn!="string"||!Yn||Kt.has(Yn)||C_(rr,Qn)&&(Kt.add(Yn),Wt+=1)};if(Array.isArray(Cn))for(const Yn of Cn)tn(Yn?.day,Rg(Yn));const pr=Array.isArray(In?.weeks)?In.weeks:[];for(const Yn of pr)for(const rr of Array.isArray(Yn)?Yn:[]){const Qn=YP(rr);tn(rr?.day,Qn,rr?.level)}return Wt},[n,le,In?.active_days,In?.weeks,Cn]),[ds,Vo]=x.useState("month"),Kp=x.useCallback(Ge=>{Ge==="custom"?(Vo(Wt=>Wt==="custom"?"month":Wt),Le(Wt=>$&&Z?"custom":Wt),xe(!0)):(Le(Ge),Vo(Ge),xe(!1))},[$,Z]),_f=x.useCallback((Ge,Wt)=>{U(Ge),pe(Wt),Le("custom"),xe(!1)},[]),mu=x.useCallback(Ge=>{xe(Ge),!Ge&&De==="custom"&&!$&&Le(ds)},[De,$,ds]),Ls=x.useCallback(async()=>{await Promise.all([qt(),An(),yn(),ie(),At(),wt(),K()])},[wt,An,ie,At,yn,qt,K]),ua=x.useCallback(async()=>{ee(!0);try{et&&await w7(),await Ls()}catch(Ge){console.error("[DashboardPage] Refresh failed:",Ge)}finally{ee(!1)}},[et,Ls]),da=ce||ut||_t||hr||En||xn||Ze,Yl=x.useMemo(()=>O("shared.data_source",{source:String(ge||"edge").toUpperCase()}),[ge,u]),fa=x.useMemo(()=>typeof e?.name!="string"?"":e.name.trim(),[e?.name]),ha="",Zp=x.useMemo(()=>!fa||fa.includes("@")?O("dashboard.identity.fallback"):fa,[fa]),wf=x.useMemo(()=>Zp.replace(/[^a-zA-Z0-9._-]/g,"_"),[Zp]),Ho=x.useMemo(()=>s?O("dashboard.identity.fallback"):wf,[wf,ha,s]),Jp=x.useMemo(()=>{let Ge=null;const Wt=tn=>{typeof tn!="string"||!tn||(!Ge||tn<Ge)&&(Ge=tn)};if(Array.isArray(Cn))for(const tn of Cn)tn?.day&&C_(Rg(tn))&&Wt(tn.day);const Kt=Array.isArray(In?.weeks)?In.weeks:[];for(const tn of Kt)for(const pr of Array.isArray(tn)?tn:[]){if(!pr?.day)continue;const Yn=YP(pr),rr=pr?.level;C_(Yn,rr)&&Wt(pr.day)}return Ge},[In?.weeks,Cn]),Qp=x.useMemo(()=>s?[]:(Array.isArray(k?.subscriptions?.items)?k.subscriptions.items:[]).map(Kt=>{const tn=typeof Kt?.tool=="string"?Kt.tool.trim():"",Yn=(typeof Kt?.plan_type=="string"?Kt.plan_type:typeof Kt?.planType=="string"?Kt.planType:"").trim();return!tn||!Yn?null:{tool:tn,planType:Yn,provider:typeof Kt?.provider=="string"?Kt.provider.trim():"",product:typeof Kt?.product=="string"?Kt.product.trim():"",rateLimitTier:typeof Kt?.rate_limit_tier=="string"?Kt.rate_limit_tier.trim():typeof Kt?.rateLimitTier=="string"?Kt.rateLimitTier.trim():""}}).filter(Boolean).slice(0,6),[s,k]),gu=p.jsx(AJ,{heatmap:In,timeZoneLabel:We,timeZoneShortLabel:Xe,hideLegend:z,defaultToLatestMonth:z}),em=x.useMemo(()=>`${Ye}..${ft}`,[Ye,Ie,ft]),Sv=O("usage.summary.total"),Yi=Rg(Ae),Wo=O("shared.unit.thousand_abbrev"),to=O("shared.unit.million_abbrev"),ql=O("shared.unit.billion_abbrev"),yu=ti(Yi),tm=B&&yu!=null&&Math.abs(yu)>=1e9,Sf=x.useMemo(()=>tm?Ms(yu,{thousandSuffix:Wo,millionSuffix:to,billionSuffix:ql,decimals:1}):Oi(Yi),[ql,to,Yi,yu,Wo,tm]),vu=O("dashboard.core_index.collapse_label"),kf=O("dashboard.core_index.expand_label"),nm=O("dashboard.core_index.collapse_aria"),pa=O("dashboard.core_index.expand_aria"),Ef=!z,xu=O("dashboard.screenshot.title_line1"),rm=O("dashboard.screenshot.title_line2"),bu=O("dashboard.screenshot.twitter_label"),_u=O("dashboard.screenshot.twitter_button"),im=O("dashboard.screenshot.twitter_hint"),Sr=O("shared.placeholder.short"),ma=x.useMemo(()=>{const Ge=Array.isArray(un?.sources)?un.sources:[];let Wt=null,Kt=0;for(const rr of Ge){const Qn=ti(rr?.totals?.billable_total_tokens??rr?.totals?.total_tokens);!Number.isFinite(Qn)||Qn<=0||Qn>Kt&&(Kt=Qn,Wt=rr)}let tn=Sr,pr=Sr,Yn="0.0";if(Wt&&Kt>0){tn=Wt?.source?String(Wt.source).toUpperCase():Sr;const rr=Array.isArray(Wt?.models)?Wt.models:[];let Qn=0;for(const Is of rr){const Jl=ti(Is?.totals?.billable_total_tokens??Is?.totals?.total_tokens);!Number.isFinite(Jl)||Jl<=0||Jl>Qn&&(Qn=Jl,pr=Is?.model?String(Is.model):Sr)}Qn>0&&(Yn=(Qn/Kt*100).toFixed(1))}return{agentName:tn,modelName:pr,modelPercent:Yn}},[un,Sr]),wu=Oi(Yi),Mf=O("dashboard.screenshot.twitter_text",{total_tokens:wu==="-"?Sr:wu,agent_name:ma.agentName,model_name:ma.modelName,model_percent:ma.modelPercent}),Xl=x.useMemo(()=>{if(typeof window>"u")return"";const Ge=new URL("https://twitter.com/intent/tweet");return Ge.searchParams.set("text",Mf),Ge.toString()},[Mf]),ku=x.useCallback(async()=>{if(typeof window>"u")return null;const Ge=async()=>{const rr=performance.now();for(;performance.now()-rr<2e3;){const Qn=document.querySelector("[data-heatmap-scroll='true']");if(!Qn||Qn.dataset.latestMonthReady==="true")return;await new Promise(Is=>requestAnimationFrame(Is))}},Wt=document.querySelector("#root")||document.body,Kt=document.documentElement,{scrollWidth:tn,scrollHeight:pr}=document.documentElement;Kt?.classList.add("screenshot-capture"),document.body?.classList.add("screenshot-capture"),await new Promise(Yn=>requestAnimationFrame(Yn)),await Ge();try{const{toBlob:Yn,toPng:rr}=await n4(async()=>{const{toBlob:no,toPng:cm}=await import("./index-BeoRn2gJ.js");return{toBlob:no,toPng:cm}},[]),Qn=await Yn(Wt,{backgroundColor:"#050505",pixelRatio:2,cacheBust:!0,width:tn,height:pr,style:{width:`${tn}px`,height:`${pr}px`},filter:no=>!(no instanceof HTMLElement)||no.dataset?.screenshotExclude!=="true"});if(Qn)return Qn;const Is=await rr(Wt,{backgroundColor:"#050505",pixelRatio:2,cacheBust:!0,width:tn,height:pr,style:{width:`${tn}px`,height:`${pr}px`},filter:no=>!(no instanceof HTMLElement)||no.dataset?.screenshotExclude!=="true"});return Is?await(await fetch(Is)).blob():null}finally{Kt?.classList.remove("screenshot-capture"),document.body?.classList.remove("screenshot-capture")}},[]),Kl=x.useCallback(async()=>{if(typeof window>"u"||V)return;W(!0);const Ge=navigator?.userAgent||"",Wt=/iP(hone|od|ad)/i.test(Ge),Kt=/Safari/i.test(Ge)&&!/Chrome|Chromium|Edg|OPR|CriOS|FxiOS/i.test(Ge),tn=typeof navigator<"u"&&!!navigator.clipboard?.write&&typeof window<"u"&&!!window.ClipboardItem;let Yn=!tn||Wt||Kt;try{const rr=await ku();rr&&tn&&(typeof document<"u"&&!document.hasFocus()&&window.focus?.(),Yn=await Bw(rr))}catch(rr){console.error("Failed to capture screenshot",rr)}finally{if(W(!1),!Yn){console.warn("Failed to write screenshot to clipboard.");return}Xl&&(window.location.href=Xl)}},[ku,V,Xl]),Eu=x.useMemo(()=>z?[]:Wle,[z]),sm=x.useMemo(()=>[{label:O("usage.metric.total"),value:Oi(Yi),valueClassName:"text-white"},{label:O("usage.metric.input"),value:Oi(Ae?.input_tokens)},{label:O("usage.metric.output"),value:Oi(Ae?.output_tokens)},{label:O("usage.metric.cached_input"),value:Oi(Ae?.cached_input_tokens)},{label:O("usage.metric.reasoning_output"),value:Oi(Ae?.reasoning_output_tokens)}],[Ae?.cached_input_tokens,Ae?.input_tokens,Ae?.output_tokens,Ae?.reasoning_output_tokens,Yi]),Tf=x.useMemo(()=>{const Ge=Uy(Ae?.total_cost_usd);return!Ge||Ge==="-"||Ge.startsWith("$")?Ge:`$${Ge}`},[Ae?.total_cost_usd]),kv=x.useMemo(()=>Ae?.conversation_count??null,[Ae?.conversation_count]),am=x.useMemo(()=>xJ(un,{copyFn:O}),[un]),Mu=x.useMemo(()=>bJ(un,{limit:3,copyFn:O}),[un]),Ev=Hle({enabled:X,handle:Ho,startDate:Jp,activeDays:si,summary:Ae,topModels:Mu,period:Ie,periodFrom:Ye,periodTo:ft,heatmap:In,accessToken:typeof qe=="string"?qe:null,userId:e?.userId||null}),Mv=x.useCallback(()=>J(!0),[]),Tv=x.useCallback(()=>J(!1),[]),Cv=x.useCallback(()=>h(!0),[]),Av=x.useCallback(()=>h(!1),[]),om=Tf&&Tf!=="-"&&am.length>0,Zl=O("dashboard.install.cmd.init"),Cf=_e?null:m,Af=Cf?O("dashboard.install.cmd.init_link_code",{link_code:Cf}):Zl,Rv=Zl,Rf=O("dashboard.install.cmd.sync"),Pv=O(Cf?"dashboard.install.copy":"dashboard.install.copy_base"),Nv=O("dashboard.install.copied");O("dashboard.session_expired.copy_label"),O("dashboard.session_expired.copied");const Dv=!!(k?.install?.has_active_device_token??k?.install?.hasActiveDeviceToken),lm=yJ({publicMode:s,screenshotMode:z,forceInstall:I,accessEnabled:he,heatmapLoading:hr,activeDays:si,hasActiveDeviceToken:Dv}),Lv=O("dashboard.install.prompt"),Iv=x.useCallback(async()=>{!Af||!await jw(Af)||(te(!0),window.setTimeout(()=>te(!1),2e3))},[Af]);x.useCallback(async()=>{!Zl||!await jw(Zl)||(ue(!0),window.setTimeout(()=>ue(!1),2e3))},[Zl]);const Pf=x.useMemo(()=>O("dashboard.daily.empty",{cmd:"{{cmd}}"}),[u]),[Ov,Fv]=x.useMemo(()=>{const Ge=Pf.split("{{cmd}}");return Ge.length===1?[Pf,""]:[Ge[0],Ge.slice(1).join("{{cmd}}")]},[Pf]),Uv=r&&!s,Nf=!n&&!le&&!r&&!et&&!s;return p.jsxs(p.Fragment,{children:[p.jsx(ile,{copy:O,onOpenShare:Mv,screenshotMode:z,showExpiredGate:Uv,showAuthGate:Nf,screenshotTitleLine1:xu,screenshotTitleLine2:rm,identityDisplayName:Ho,identityStartDate:Jp,activeDays:si,identitySubscriptions:Qp,identityScrambleDurationMs:F,projectUsageEntries:$e,projectUsageLimit:fe,setProjectUsageLimit:Te,topModels:Mu,signedIn:n,publicMode:s,isLocalMode:et,shouldShowInstall:lm,installPrompt:Lv,handleCopyInstall:Iv,installCopied:H,installCopiedLabel:Nv,installCopyLabel:Pv,installInitCmdDisplay:Rv,linkCodeLoading:b,linkCodeError:E,trendRowsForDisplay:Ut,trendFromForDisplay:Kr,trendToForDisplay:wn,usageFrom:Ye,usageTo:ft,period:Ie,trendTimeZoneLabel:gt,activityHeatmapBlock:gu,isCapturing:V,handleShareToX:Kl,screenshotTwitterLabel:bu,screenshotTwitterButton:_u,screenshotTwitterHint:im,periodsForDisplay:Eu,setSelectedPeriod:Kp,customFrom:$,customTo:Z,onCustomRangeApply:_f,customRangeOpen:Se,onCustomRangeOpenChange:mu,metricsRows:sm,summaryLabel:Sv,summaryValue:Sf,summaryTotalTokensRaw:ti(Yi)||0,summaryCostValue:Tf,summaryConversationsValue:kv,rollingUsage:Ve,costInfoEnabled:om,openCostModal:Cv,allowBreakdownToggle:Ef,coreIndexCollapsed:G,setCoreIndexCollapsed:Y,coreIndexCollapseLabel:vu,coreIndexExpandLabel:kf,coreIndexCollapseAria:nm,coreIndexExpandAria:pa,refreshAll:ua,usageLoadingState:da,usageError:yt,rangeLabel:em,timeZoneRangeLabel:nt,usageSourceLabel:Yl,fleetData:am,hasDetailsActual:dt,dailyEmptyPrefix:Ov,installSyncCmd:Rf,dailyEmptySuffix:Fv,detailsColumns:Pe,ariaSortFor:Fn,toggleSort:ca,sortIconFor:nn,pagedDetails:en,dailyBreakdownRows:nr,dailyBreakdownColumns:we,dailyBreakdownAriaSortFor:$i,dailyBreakdownSortIconFor:cr,dailyBreakdownDateKey:Ee,detailsDateKey:me,renderDetailDate:ii,renderDailyBreakdownDate:xi,renderDetailCell:ri,DETAILS_PAGED_PERIODS:hh,detailsPageCount:Vt,detailsPage:Ct,setDetailsPage:dn,costModalOpen:f,closeCostModal:Av}),p.jsx(Vle,{open:X,onClose:Tv,data:Ev,twitterText:Mf})]})}function Kle(){const[t,e]=x.useState(!1);return p.jsxs("div",{className:"h-full relative dark:bg-[#050505]",children:[!t&&p.jsxs("div",{className:"absolute inset-0 p-6 space-y-5 animate-pulse",children:[p.jsx("div",{className:"flex gap-4 justify-center",children:Array.from({length:6}).map((n,r)=>p.jsx("div",{className:"h-4 w-20 rounded bg-oai-gray-200 dark:bg-oai-gray-800"},r))}),p.jsxs("div",{className:"space-y-2 pt-2",children:[p.jsx("div",{className:"h-7 w-72 rounded bg-oai-gray-200 dark:bg-oai-gray-800"}),p.jsx("div",{className:"h-4 w-96 rounded bg-oai-gray-200 dark:bg-oai-gray-800"})]}),p.jsx("div",{className:"grid grid-cols-3 gap-4",children:Array.from({length:3}).map((n,r)=>p.jsx("div",{className:"h-24 rounded-xl bg-oai-gray-200 dark:bg-oai-gray-800"},r))}),p.jsx("div",{className:"grid grid-cols-3 gap-4",children:Array.from({length:3}).map((n,r)=>p.jsx("div",{className:"h-40 rounded-xl bg-oai-gray-200 dark:bg-oai-gray-800"},r))}),p.jsx("div",{className:"grid grid-cols-3 gap-4",children:Array.from({length:3}).map((n,r)=>p.jsx("div",{className:"h-32 rounded-xl bg-oai-gray-200 dark:bg-oai-gray-800"},r))})]}),p.jsx("iframe",{src:"https://ip.net.coffee/claude/",title:"Cloud AI IP Check",className:`w-full h-full dark:invert dark:hue-rotate-180 transition-opacity duration-300 ${t?"opacity-100":"opacity-0"}`,style:{border:"none"},onLoad:()=>e(!0)})]})}function Zle(){if(typeof window>"u")return!1;const t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"||t==="::1"}function Jle(){return Zle()?"/":"/dashboard"}function JF({repo:t="mm7894215/TokenTracker"}){const[e,n]=x.useState(null);return x.useEffect(()=>{if(typeof window>"u")return;const r=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,i=typeof document<"u"&&(document.documentElement?.classList.contains("screenshot-capture")||document.body?.classList.contains("screenshot-capture"));U5({prefersReducedMotion:r,screenshotCapture:i})&&fetch(`https://api.github.com/repos/${t}`).then(s=>s.json()).then(s=>{s&&typeof s.stargazers_count=="number"&&n(s.stargazers_count)}).catch(()=>{})},[t]),p.jsxs("a",{href:`https://github.com/${t}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex shrink-0 items-center gap-2 px-3 py-1.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-700 transition-colors no-underline",children:[p.jsx("svg",{height:"16",viewBox:"0 0 16 16",width:"16",className:"shrink-0 fill-oai-gray-700 dark:fill-oai-gray-300",children:p.jsx("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})}),p.jsx("span",{className:"text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300 whitespace-nowrap",children:"Star"}),e!==null&&p.jsx("span",{className:"text-xs font-semibold text-oai-gray-900 dark:text-oai-white tabular-nums whitespace-nowrap",children:e})]})}const $E="183",Qle=0,qP=1,ece=2,E0=1,tce=2,Rh=3,Ol=0,zi=1,So=2,Po=0,Hc=1,XP=2,KP=3,ZP=4,nce=5,Tc=100,rce=101,ice=102,sce=103,ace=104,oce=200,lce=201,cce=202,uce=203,F1=204,U1=205,dce=206,fce=207,hce=208,pce=209,mce=210,gce=211,yce=212,vce=213,xce=214,j1=0,B1=1,z1=2,qd=3,V1=4,H1=5,W1=6,G1=7,QF=0,bce=1,_ce=2,Ua=0,eU=1,tU=2,nU=3,rU=4,iU=5,sU=6,aU=7,oU=300,ru=301,Xd=302,A_=303,R_=304,fv=306,$1=1e3,Mo=1001,Y1=1002,ni=1003,wce=1004,Pg=1005,yi=1006,P_=1007,Fc=1008,Es=1009,lU=1010,cU=1011,dp=1012,YE=1013,$a=1014,Da=1015,Uo=1016,qE=1017,XE=1018,fp=1020,uU=35902,dU=35899,fU=1021,hU=1022,ta=1023,jo=1026,Uc=1027,pU=1028,KE=1029,Kd=1030,ZE=1031,JE=1033,M0=33776,T0=33777,C0=33778,A0=33779,q1=35840,X1=35841,K1=35842,Z1=35843,J1=36196,Q1=37492,eS=37496,tS=37488,nS=37489,rS=37490,iS=37491,sS=37808,aS=37809,oS=37810,lS=37811,cS=37812,uS=37813,dS=37814,fS=37815,hS=37816,pS=37817,mS=37818,gS=37819,yS=37820,vS=37821,xS=36492,bS=36494,_S=36495,wS=36283,SS=36284,kS=36285,ES=36286,Sce=3200,kce=0,Ece=1,wl="",ws="srgb",iu="srgb-linear",xy="linear",qn="srgb",Qu=7680,JP=519,Mce=512,Tce=513,Cce=514,QE=515,Ace=516,Rce=517,eM=518,Pce=519,QP=35044,eN="300 es",La=2e3,by=2001;function Nce(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function _y(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Dce(){const t=_y("canvas");return t.style.display="block",t}const tN={};function nN(...t){const e="THREE."+t.shift();console.log(e,...t)}function mU(t){const e=t[0];if(typeof e=="string"&&e.startsWith("TSL:")){const n=t[1];n&&n.isStackTrace?t[0]+=" "+n.getLocation():t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}function ln(...t){t=mU(t);const e="THREE."+t.shift();{const n=t[0];n&&n.isStackTrace?console.warn(n.getError(e)):console.warn(e,...t)}}function Vn(...t){t=mU(t);const e="THREE."+t.shift();{const n=t[0];n&&n.isStackTrace?console.error(n.getError(e)):console.error(e,...t)}}function wy(...t){const e=t.join(" ");e in tN||(tN[e]=!0,ln(...t))}function Lce(t,e,n){return new Promise(function(r,i){function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:r()}}setTimeout(s,n)})}const Ice={[j1]:B1,[z1]:W1,[V1]:G1,[qd]:H1,[B1]:j1,[W1]:z1,[G1]:V1,[H1]:qd};class pf{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const s=i.indexOf(n);s!==-1&&i.splice(s,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let s=0,a=i.length;s<a;s++)i[s].call(this,e);e.target=null}}}const ui=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],N_=Math.PI/180,MS=180/Math.PI;function Hp(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(ui[t&255]+ui[t>>8&255]+ui[t>>16&255]+ui[t>>24&255]+"-"+ui[e&255]+ui[e>>8&255]+"-"+ui[e>>16&15|64]+ui[e>>24&255]+"-"+ui[n&63|128]+ui[n>>8&255]+"-"+ui[n>>16&255]+ui[n>>24&255]+ui[r&255]+ui[r>>8&255]+ui[r>>16&255]+ui[r>>24&255]).toLowerCase()}function Dn(t,e,n){return Math.max(e,Math.min(n,t))}function Oce(t,e){return(t%e+e)%e}function D_(t,e,n){return(1-n)*t+n*e}function ph(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Ii(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}class $n{constructor(e=0,n=0){$n.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Dn(this.x,e.x,n.x),this.y=Dn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=Dn(this.x,e,n),this.y=Dn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Dn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Dn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),s=this.x-e.x,a=this.y-e.y;return this.x=s*r-a*i+e.x,this.y=s*i+a*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class mf{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,s,a,o){let c=r[i+0],u=r[i+1],f=r[i+2],h=r[i+3],m=s[a+0],g=s[a+1],v=s[a+2],w=s[a+3];if(h!==w||c!==m||u!==g||f!==v){let b=c*m+u*g+f*v+h*w;b<0&&(m=-m,g=-g,v=-v,w=-w,b=-b);let _=1-o;if(b<.9995){const E=Math.acos(b),M=Math.sin(E);_=Math.sin(_*E)/M,o=Math.sin(o*E)/M,c=c*_+m*o,u=u*_+g*o,f=f*_+v*o,h=h*_+w*o}else{c=c*_+m*o,u=u*_+g*o,f=f*_+v*o,h=h*_+w*o;const E=1/Math.sqrt(c*c+u*u+f*f+h*h);c*=E,u*=E,f*=E,h*=E}}e[n]=c,e[n+1]=u,e[n+2]=f,e[n+3]=h}static multiplyQuaternionsFlat(e,n,r,i,s,a){const o=r[i],c=r[i+1],u=r[i+2],f=r[i+3],h=s[a],m=s[a+1],g=s[a+2],v=s[a+3];return e[n]=o*v+f*h+c*g-u*m,e[n+1]=c*v+f*m+u*h-o*g,e[n+2]=u*v+f*g+o*m-c*h,e[n+3]=f*v-o*h-c*m-u*g,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,c=Math.sin,u=o(r/2),f=o(i/2),h=o(s/2),m=c(r/2),g=c(i/2),v=c(s/2);switch(a){case"XYZ":this._x=m*f*h+u*g*v,this._y=u*g*h-m*f*v,this._z=u*f*v+m*g*h,this._w=u*f*h-m*g*v;break;case"YXZ":this._x=m*f*h+u*g*v,this._y=u*g*h-m*f*v,this._z=u*f*v-m*g*h,this._w=u*f*h+m*g*v;break;case"ZXY":this._x=m*f*h-u*g*v,this._y=u*g*h+m*f*v,this._z=u*f*v+m*g*h,this._w=u*f*h-m*g*v;break;case"ZYX":this._x=m*f*h-u*g*v,this._y=u*g*h+m*f*v,this._z=u*f*v-m*g*h,this._w=u*f*h+m*g*v;break;case"YZX":this._x=m*f*h+u*g*v,this._y=u*g*h+m*f*v,this._z=u*f*v-m*g*h,this._w=u*f*h-m*g*v;break;case"XZY":this._x=m*f*h-u*g*v,this._y=u*g*h-m*f*v,this._z=u*f*v+m*g*h,this._w=u*f*h+m*g*v;break;default:ln("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],s=n[8],a=n[1],o=n[5],c=n[9],u=n[2],f=n[6],h=n[10],m=r+o+h;if(m>0){const g=.5/Math.sqrt(m+1);this._w=.25/g,this._x=(f-c)*g,this._y=(s-u)*g,this._z=(a-i)*g}else if(r>o&&r>h){const g=2*Math.sqrt(1+r-o-h);this._w=(f-c)/g,this._x=.25*g,this._y=(i+a)/g,this._z=(s+u)/g}else if(o>h){const g=2*Math.sqrt(1+o-r-h);this._w=(s-u)/g,this._x=(i+a)/g,this._y=.25*g,this._z=(c+f)/g}else{const g=2*Math.sqrt(1+h-r-o);this._w=(a-i)/g,this._x=(s+u)/g,this._y=(c+f)/g,this._z=.25*g}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Dn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,s=e._z,a=e._w,o=n._x,c=n._y,u=n._z,f=n._w;return this._x=r*f+a*o+i*u-s*c,this._y=i*f+a*c+s*o-r*u,this._z=s*f+a*u+r*c-i*o,this._w=a*f-r*o-i*c-s*u,this._onChangeCallback(),this}slerp(e,n){let r=e._x,i=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(r=-r,i=-i,s=-s,a=-a,o=-o);let c=1-n;if(o<.9995){const u=Math.acos(o),f=Math.sin(u);c=Math.sin(c*u)/f,n=Math.sin(n*u)/f,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+s*n,this._w=this._w*c+a*n,this._onChangeCallback()}else this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+s*n,this._w=this._w*c+a*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(n),s*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Oe{constructor(e=0,n=0,r=0){Oe.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(rN.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(rN.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[3]*r+s[6]*i,this.y=s[1]*n+s[4]*r+s[7]*i,this.z=s[2]*n+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=e.elements,a=1/(s[3]*n+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*n+s[4]*r+s[8]*i+s[12])*a,this.y=(s[1]*n+s[5]*r+s[9]*i+s[13])*a,this.z=(s[2]*n+s[6]*r+s[10]*i+s[14])*a,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,s=e.x,a=e.y,o=e.z,c=e.w,u=2*(a*i-o*r),f=2*(o*n-s*i),h=2*(s*r-a*n);return this.x=n+c*u+a*h-o*f,this.y=r+c*f+o*u-s*h,this.z=i+c*h+s*f-a*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i,this.y=s[1]*n+s[5]*r+s[9]*i,this.z=s[2]*n+s[6]*r+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Dn(this.x,e.x,n.x),this.y=Dn(this.y,e.y,n.y),this.z=Dn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=Dn(this.x,e,n),this.y=Dn(this.y,e,n),this.z=Dn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Dn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,s=e.z,a=n.x,o=n.y,c=n.z;return this.x=i*c-s*o,this.y=s*a-r*c,this.z=r*o-i*a,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return L_.copy(this).projectOnVector(e),this.sub(L_)}reflect(e){return this.sub(L_.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Dn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,r=Math.sqrt(1-n*n);return this.x=r*Math.cos(e),this.y=n,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const L_=new Oe,rN=new mf;class pn{constructor(e,n,r,i,s,a,o,c,u){pn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,a,o,c,u)}set(e,n,r,i,s,a,o,c,u){const f=this.elements;return f[0]=e,f[1]=i,f[2]=o,f[3]=n,f[4]=s,f[5]=c,f[6]=r,f[7]=a,f[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,a=r[0],o=r[3],c=r[6],u=r[1],f=r[4],h=r[7],m=r[2],g=r[5],v=r[8],w=i[0],b=i[3],_=i[6],E=i[1],M=i[4],T=i[7],R=i[2],A=i[5],P=i[8];return s[0]=a*w+o*E+c*R,s[3]=a*b+o*M+c*A,s[6]=a*_+o*T+c*P,s[1]=u*w+f*E+h*R,s[4]=u*b+f*M+h*A,s[7]=u*_+f*T+h*P,s[2]=m*w+g*E+v*R,s[5]=m*b+g*M+v*A,s[8]=m*_+g*T+v*P,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],u=e[7],f=e[8];return n*a*f-n*o*u-r*s*f+r*o*c+i*s*u-i*a*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],u=e[7],f=e[8],h=f*a-o*u,m=o*c-f*s,g=u*s-a*c,v=n*h+r*m+i*g;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const w=1/v;return e[0]=h*w,e[1]=(i*u-f*r)*w,e[2]=(o*r-i*a)*w,e[3]=m*w,e[4]=(f*n-i*c)*w,e[5]=(i*s-o*n)*w,e[6]=g*w,e[7]=(r*c-u*n)*w,e[8]=(a*n-r*s)*w,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,s,a,o){const c=Math.cos(s),u=Math.sin(s);return this.set(r*c,r*u,-r*(c*a+u*o)+a+e,-i*u,i*c,-i*(-u*a+c*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(I_.makeScale(e,n)),this}rotate(e){return this.premultiply(I_.makeRotation(-e)),this}translate(e,n){return this.premultiply(I_.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,r,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<9;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<9;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const I_=new pn,iN=new pn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),sN=new pn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Fce(){const t={enabled:!0,workingColorSpace:iu,spaces:{},convert:function(i,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===qn&&(i.r=No(i.r),i.g=No(i.g),i.b=No(i.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===qn&&(i.r=Dd(i.r),i.g=Dd(i.g),i.b=Dd(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===wl?xy:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,a){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return wy("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return wy("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,s)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[iu]:{primaries:e,whitePoint:r,transfer:xy,toXYZ:iN,fromXYZ:sN,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:ws},outputColorSpaceConfig:{drawingBufferColorSpace:ws}},[ws]:{primaries:e,whitePoint:r,transfer:qn,toXYZ:iN,fromXYZ:sN,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:ws}}}),t}const jn=Fce();function No(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Dd(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let ed;class Uce{static getDataURL(e,n="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let r;if(e instanceof HTMLCanvasElement)r=e;else{ed===void 0&&(ed=_y("canvas")),ed.width=e.width,ed.height=e.height;const i=ed.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=ed}return r.toDataURL(n)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=_y("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let a=0;a<s.length;a++)s[a]=No(s[a]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(No(n[r]/255)*255):n[r]=No(n[r]);return{data:n,width:e.width,height:e.height}}else return ln("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let jce=0;class tM{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:jce++}),this.uuid=Hp(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):typeof VideoFrame<"u"&&n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?s.push(O_(i[a].image)):s.push(O_(i[a]))}else s=O_(i);r.url=s}return n||(e.images[this.uuid]=r),r}}function O_(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Uce.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(ln("Texture: Unable to serialize Texture."),{})}let Bce=0;const F_=new Oe;class Ti extends pf{constructor(e=Ti.DEFAULT_IMAGE,n=Ti.DEFAULT_MAPPING,r=Mo,i=Mo,s=yi,a=Fc,o=ta,c=Es,u=Ti.DEFAULT_ANISOTROPY,f=wl){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Bce++}),this.uuid=Hp(),this.name="",this.source=new tM(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=u,this.format=o,this.internalFormat=null,this.type=c,this.offset=new $n(0,0),this.repeat=new $n(1,1),this.center=new $n(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new pn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=f,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(F_).x}get height(){return this.source.getSize(F_).y}get depth(){return this.source.getSize(F_).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const n in e){const r=e[n];if(r===void 0){ln(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){ln(`Texture.setValues(): property '${n}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==oU)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case $1:e.x=e.x-Math.floor(e.x);break;case Mo:e.x=e.x<0?0:1;break;case Y1:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case $1:e.y=e.y-Math.floor(e.y);break;case Mo:e.y=e.y<0?0:1;break;case Y1:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Ti.DEFAULT_IMAGE=null;Ti.DEFAULT_MAPPING=oU;Ti.DEFAULT_ANISOTROPY=1;class yr{constructor(e=0,n=0,r=0,i=1){yr.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i+a[12]*s,this.y=a[1]*n+a[5]*r+a[9]*i+a[13]*s,this.z=a[2]*n+a[6]*r+a[10]*i+a[14]*s,this.w=a[3]*n+a[7]*r+a[11]*i+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,s;const c=e.elements,u=c[0],f=c[4],h=c[8],m=c[1],g=c[5],v=c[9],w=c[2],b=c[6],_=c[10];if(Math.abs(f-m)<.01&&Math.abs(h-w)<.01&&Math.abs(v-b)<.01){if(Math.abs(f+m)<.1&&Math.abs(h+w)<.1&&Math.abs(v+b)<.1&&Math.abs(u+g+_-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const M=(u+1)/2,T=(g+1)/2,R=(_+1)/2,A=(f+m)/4,P=(h+w)/4,k=(v+b)/4;return M>T&&M>R?M<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(M),i=A/r,s=P/r):T>R?T<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(T),r=A/i,s=k/i):R<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(R),r=P/s,i=k/s),this.set(r,i,s,n),this}let E=Math.sqrt((b-v)*(b-v)+(h-w)*(h-w)+(m-f)*(m-f));return Math.abs(E)<.001&&(E=1),this.x=(b-v)/E,this.y=(h-w)/E,this.z=(m-f)/E,this.w=Math.acos((u+g+_-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Dn(this.x,e.x,n.x),this.y=Dn(this.y,e.y,n.y),this.z=Dn(this.z,e.z,n.z),this.w=Dn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=Dn(this.x,e,n),this.y=Dn(this.y,e,n),this.z=Dn(this.z,e,n),this.w=Dn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Dn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class zce extends pf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:yi,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},r),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=r.depth,this.scissor=new yr(0,0,e,n),this.scissorTest=!1,this.viewport=new yr(0,0,e,n),this.textures=[];const i={width:e,height:n,depth:r.depth},s=new Ti(i),a=r.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:yi,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(n)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,n,r=1){if(this.width!==e||this.height!==n||this.depth!==r){this.width=e,this.height=n,this.depth=r;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const i=Object.assign({},e.textures[n].image);this.textures[n].source=new tM(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ja extends zce{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class gU extends Ti{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=ni,this.minFilter=ni,this.wrapR=Mo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Vce extends Ti{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=ni,this.minFilter=ni,this.wrapR=Mo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Nr{constructor(e,n,r,i,s,a,o,c,u,f,h,m,g,v,w,b){Nr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,a,o,c,u,f,h,m,g,v,w,b)}set(e,n,r,i,s,a,o,c,u,f,h,m,g,v,w,b){const _=this.elements;return _[0]=e,_[4]=n,_[8]=r,_[12]=i,_[1]=s,_[5]=a,_[9]=o,_[13]=c,_[2]=u,_[6]=f,_[10]=h,_[14]=m,_[3]=g,_[7]=v,_[11]=w,_[15]=b,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Nr().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,r){return this.determinant()===0?(e.set(1,0,0),n.set(0,1,0),r.set(0,0,1),this):(e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this)}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const n=this.elements,r=e.elements,i=1/td.setFromMatrixColumn(e,0).length(),s=1/td.setFromMatrixColumn(e,1).length(),a=1/td.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*s,n[5]=r[5]*s,n[6]=r[6]*s,n[7]=0,n[8]=r[8]*a,n[9]=r[9]*a,n[10]=r[10]*a,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,s=e.z,a=Math.cos(r),o=Math.sin(r),c=Math.cos(i),u=Math.sin(i),f=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const m=a*f,g=a*h,v=o*f,w=o*h;n[0]=c*f,n[4]=-c*h,n[8]=u,n[1]=g+v*u,n[5]=m-w*u,n[9]=-o*c,n[2]=w-m*u,n[6]=v+g*u,n[10]=a*c}else if(e.order==="YXZ"){const m=c*f,g=c*h,v=u*f,w=u*h;n[0]=m+w*o,n[4]=v*o-g,n[8]=a*u,n[1]=a*h,n[5]=a*f,n[9]=-o,n[2]=g*o-v,n[6]=w+m*o,n[10]=a*c}else if(e.order==="ZXY"){const m=c*f,g=c*h,v=u*f,w=u*h;n[0]=m-w*o,n[4]=-a*h,n[8]=v+g*o,n[1]=g+v*o,n[5]=a*f,n[9]=w-m*o,n[2]=-a*u,n[6]=o,n[10]=a*c}else if(e.order==="ZYX"){const m=a*f,g=a*h,v=o*f,w=o*h;n[0]=c*f,n[4]=v*u-g,n[8]=m*u+w,n[1]=c*h,n[5]=w*u+m,n[9]=g*u-v,n[2]=-u,n[6]=o*c,n[10]=a*c}else if(e.order==="YZX"){const m=a*c,g=a*u,v=o*c,w=o*u;n[0]=c*f,n[4]=w-m*h,n[8]=v*h+g,n[1]=h,n[5]=a*f,n[9]=-o*f,n[2]=-u*f,n[6]=g*h+v,n[10]=m-w*h}else if(e.order==="XZY"){const m=a*c,g=a*u,v=o*c,w=o*u;n[0]=c*f,n[4]=-h,n[8]=u*f,n[1]=m*h+w,n[5]=a*f,n[9]=g*h-v,n[2]=v*h-g,n[6]=o*f,n[10]=w*h+m}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Hce,e,Wce)}lookAt(e,n,r){const i=this.elements;return Qi.subVectors(e,n),Qi.lengthSq()===0&&(Qi.z=1),Qi.normalize(),ul.crossVectors(r,Qi),ul.lengthSq()===0&&(Math.abs(r.z)===1?Qi.x+=1e-4:Qi.z+=1e-4,Qi.normalize(),ul.crossVectors(r,Qi)),ul.normalize(),Ng.crossVectors(Qi,ul),i[0]=ul.x,i[4]=Ng.x,i[8]=Qi.x,i[1]=ul.y,i[5]=Ng.y,i[9]=Qi.y,i[2]=ul.z,i[6]=Ng.z,i[10]=Qi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,a=r[0],o=r[4],c=r[8],u=r[12],f=r[1],h=r[5],m=r[9],g=r[13],v=r[2],w=r[6],b=r[10],_=r[14],E=r[3],M=r[7],T=r[11],R=r[15],A=i[0],P=i[4],k=i[8],N=i[12],B=i[1],L=i[5],z=i[9],I=i[13],V=i[2],W=i[6],X=i[10],J=i[14],F=i[3],G=i[7],Y=i[11],H=i[15];return s[0]=a*A+o*B+c*V+u*F,s[4]=a*P+o*L+c*W+u*G,s[8]=a*k+o*z+c*X+u*Y,s[12]=a*N+o*I+c*J+u*H,s[1]=f*A+h*B+m*V+g*F,s[5]=f*P+h*L+m*W+g*G,s[9]=f*k+h*z+m*X+g*Y,s[13]=f*N+h*I+m*J+g*H,s[2]=v*A+w*B+b*V+_*F,s[6]=v*P+w*L+b*W+_*G,s[10]=v*k+w*z+b*X+_*Y,s[14]=v*N+w*I+b*J+_*H,s[3]=E*A+M*B+T*V+R*F,s[7]=E*P+M*L+T*W+R*G,s[11]=E*k+M*z+T*X+R*Y,s[15]=E*N+M*I+T*J+R*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],s=e[12],a=e[1],o=e[5],c=e[9],u=e[13],f=e[2],h=e[6],m=e[10],g=e[14],v=e[3],w=e[7],b=e[11],_=e[15],E=c*g-u*m,M=o*g-u*h,T=o*m-c*h,R=a*g-u*f,A=a*m-c*f,P=a*h-o*f;return n*(w*E-b*M+_*T)-r*(v*E-b*R+_*A)+i*(v*M-w*R+_*P)-s*(v*T-w*A+b*P)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],u=e[7],f=e[8],h=e[9],m=e[10],g=e[11],v=e[12],w=e[13],b=e[14],_=e[15],E=n*o-r*a,M=n*c-i*a,T=n*u-s*a,R=r*c-i*o,A=r*u-s*o,P=i*u-s*c,k=f*w-h*v,N=f*b-m*v,B=f*_-g*v,L=h*b-m*w,z=h*_-g*w,I=m*_-g*b,V=E*I-M*z+T*L+R*B-A*N+P*k;if(V===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const W=1/V;return e[0]=(o*I-c*z+u*L)*W,e[1]=(i*z-r*I-s*L)*W,e[2]=(w*P-b*A+_*R)*W,e[3]=(m*A-h*P-g*R)*W,e[4]=(c*B-a*I-u*N)*W,e[5]=(n*I-i*B+s*N)*W,e[6]=(b*T-v*P-_*M)*W,e[7]=(f*P-m*T+g*M)*W,e[8]=(a*z-o*B+u*k)*W,e[9]=(r*B-n*z-s*k)*W,e[10]=(v*A-w*T+_*E)*W,e[11]=(h*T-f*A-g*E)*W,e[12]=(o*N-a*L-c*k)*W,e[13]=(n*L-r*N+i*k)*W,e[14]=(w*M-v*R-b*E)*W,e[15]=(f*R-h*M+m*E)*W,this}scale(e){const n=this.elements,r=e.x,i=e.y,s=e.z;return n[0]*=r,n[4]*=i,n[8]*=s,n[1]*=r,n[5]*=i,n[9]*=s,n[2]*=r,n[6]*=i,n[10]*=s,n[3]*=r,n[7]*=i,n[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),s=1-r,a=e.x,o=e.y,c=e.z,u=s*a,f=s*o;return this.set(u*a+r,u*o-i*c,u*c+i*o,0,u*o+i*c,f*o+r,f*c-i*a,0,u*c-i*o,f*c+i*a,s*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,s,a){return this.set(1,r,s,0,e,1,a,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,a=n._y,o=n._z,c=n._w,u=s+s,f=a+a,h=o+o,m=s*u,g=s*f,v=s*h,w=a*f,b=a*h,_=o*h,E=c*u,M=c*f,T=c*h,R=r.x,A=r.y,P=r.z;return i[0]=(1-(w+_))*R,i[1]=(g+T)*R,i[2]=(v-M)*R,i[3]=0,i[4]=(g-T)*A,i[5]=(1-(m+_))*A,i[6]=(b+E)*A,i[7]=0,i[8]=(v+M)*P,i[9]=(b-E)*P,i[10]=(1-(m+w))*P,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];const s=this.determinant();if(s===0)return r.set(1,1,1),n.identity(),this;let a=td.set(i[0],i[1],i[2]).length();const o=td.set(i[4],i[5],i[6]).length(),c=td.set(i[8],i[9],i[10]).length();s<0&&(a=-a),Gs.copy(this);const u=1/a,f=1/o,h=1/c;return Gs.elements[0]*=u,Gs.elements[1]*=u,Gs.elements[2]*=u,Gs.elements[4]*=f,Gs.elements[5]*=f,Gs.elements[6]*=f,Gs.elements[8]*=h,Gs.elements[9]*=h,Gs.elements[10]*=h,n.setFromRotationMatrix(Gs),r.x=a,r.y=o,r.z=c,this}makePerspective(e,n,r,i,s,a,o=La,c=!1){const u=this.elements,f=2*s/(n-e),h=2*s/(r-i),m=(n+e)/(n-e),g=(r+i)/(r-i);let v,w;if(c)v=s/(a-s),w=a*s/(a-s);else if(o===La)v=-(a+s)/(a-s),w=-2*a*s/(a-s);else if(o===by)v=-a/(a-s),w=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return u[0]=f,u[4]=0,u[8]=m,u[12]=0,u[1]=0,u[5]=h,u[9]=g,u[13]=0,u[2]=0,u[6]=0,u[10]=v,u[14]=w,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,s,a,o=La,c=!1){const u=this.elements,f=2/(n-e),h=2/(r-i),m=-(n+e)/(n-e),g=-(r+i)/(r-i);let v,w;if(c)v=1/(a-s),w=a/(a-s);else if(o===La)v=-2/(a-s),w=-(a+s)/(a-s);else if(o===by)v=-1/(a-s),w=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return u[0]=f,u[4]=0,u[8]=0,u[12]=m,u[1]=0,u[5]=h,u[9]=0,u[13]=g,u[2]=0,u[6]=0,u[10]=v,u[14]=w,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const td=new Oe,Gs=new Nr,Hce=new Oe(0,0,0),Wce=new Oe(1,1,1),ul=new Oe,Ng=new Oe,Qi=new Oe,aN=new Nr,oN=new mf;let su=class yU{constructor(e=0,n=0,r=0,i=yU.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,s=i[0],a=i[4],o=i[8],c=i[1],u=i[5],f=i[9],h=i[2],m=i[6],g=i[10];switch(n){case"XYZ":this._y=Math.asin(Dn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-f,g),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(m,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Dn(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(o,g),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Dn(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-h,g),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Dn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(m,g),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,u));break;case"YZX":this._z=Math.asin(Dn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-f,u),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,g));break;case"XZY":this._z=Math.asin(-Dn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(m,u),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-f,g),this._y=0);break;default:ln("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return aN.makeRotationFromQuaternion(e),this.setFromRotationMatrix(aN,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return oN.setFromEuler(this),this.setFromQuaternion(oN,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};su.DEFAULT_ORDER="XYZ";class vU{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Gce=0;const lN=new Oe,nd=new mf,ho=new Nr,Dg=new Oe,mh=new Oe,$ce=new Oe,Yce=new mf,cN=new Oe(1,0,0),uN=new Oe(0,1,0),dN=new Oe(0,0,1),fN={type:"added"},qce={type:"removed"},rd={type:"childadded",child:null},U_={type:"childremoved",child:null};class ls extends pf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Gce++}),this.uuid=Hp(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ls.DEFAULT_UP.clone();const e=new Oe,n=new su,r=new mf,i=new Oe(1,1,1);function s(){r.setFromEuler(n,!1)}function a(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),r._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Nr},normalMatrix:{value:new pn}}),this.matrix=new Nr,this.matrixWorld=new Nr,this.matrixAutoUpdate=ls.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ls.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new vU,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,n){this.quaternion.setFromAxisAngle(e,n)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,n){return nd.setFromAxisAngle(e,n),this.quaternion.multiply(nd),this}rotateOnWorldAxis(e,n){return nd.setFromAxisAngle(e,n),this.quaternion.premultiply(nd),this}rotateX(e){return this.rotateOnAxis(cN,e)}rotateY(e){return this.rotateOnAxis(uN,e)}rotateZ(e){return this.rotateOnAxis(dN,e)}translateOnAxis(e,n){return lN.copy(e).applyQuaternion(this.quaternion),this.position.add(lN.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(cN,e)}translateY(e){return this.translateOnAxis(uN,e)}translateZ(e){return this.translateOnAxis(dN,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ho.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?Dg.copy(e):Dg.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),mh.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ho.lookAt(mh,Dg,this.up):ho.lookAt(Dg,mh,this.up),this.quaternion.setFromRotationMatrix(ho),i&&(ho.extractRotation(i.matrixWorld),nd.setFromRotationMatrix(ho),this.quaternion.premultiply(nd.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Vn("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(fN),rd.child=e,this.dispatchEvent(rd),rd.child=null):Vn("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(qce),U_.child=e,this.dispatchEvent(U_),U_.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),ho.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ho.multiply(e.parent.matrixWorld)),e.applyMatrix4(ho),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(fN),rd.child=e,this.dispatchEvent(rd),rd.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const a=this.children[r].getObjectByProperty(e,n);if(a!==void 0)return a}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mh,e,$ce),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mh,Yce,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const n=e.x,r=e.y,i=e.z,s=this.matrix.elements;s[12]+=n-s[0]*n-s[4]*r-s[8]*i,s[13]+=r-s[1]*n-s[5]*r-s[9]*i,s[14]+=i-s[2]*n-s[6]*r-s[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let u=0,f=c.length;u<f;u++){const h=c[u];s(e.shapes,h)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,u=this.material.length;c<u;c++)o.push(s(e.materials,this.material[c]));i.material=o}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];i.animations.push(s(e.animations,c))}}if(n){const o=a(e.geometries),c=a(e.materials),u=a(e.textures),f=a(e.images),h=a(e.shapes),m=a(e.skeletons),g=a(e.animations),v=a(e.nodes);o.length>0&&(r.geometries=o),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),f.length>0&&(r.images=f),h.length>0&&(r.shapes=h),m.length>0&&(r.skeletons=m),g.length>0&&(r.animations=g),v.length>0&&(r.nodes=v)}return r.object=i,r;function a(o){const c=[];for(const u in o){const f=o[u];delete f.metadata,c.push(f)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),e.pivot!==null&&(this.pivot=e.pivot.clone()),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}ls.DEFAULT_UP=new Oe(0,1,0);ls.DEFAULT_MATRIX_AUTO_UPDATE=!0;ls.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Lg extends ls{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Xce={type:"move"};class j_{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Lg,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Lg,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Oe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Oe),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Lg,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Oe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Oe),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,s=null,a=null;const o=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){a=!0;for(const w of e.hand.values()){const b=n.getJointPose(w,r),_=this._getHandJoint(u,w);b!==null&&(_.matrix.fromArray(b.transform.matrix),_.matrix.decompose(_.position,_.rotation,_.scale),_.matrixWorldNeedsUpdate=!0,_.jointRadius=b.radius),_.visible=b!==null}const f=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],m=f.position.distanceTo(h.position),g=.02,v=.005;u.inputState.pinching&&m>g+v?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=g-v&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Xce)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=s!==null),u!==null&&(u.visible=a!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Lg;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}const xU={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},dl={h:0,s:0,l:0},Ig={h:0,s:0,l:0};function B_(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}class Zn{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=ws){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,jn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=jn.workingColorSpace){return this.r=e,this.g=n,this.b=r,jn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=jn.workingColorSpace){if(e=Oce(e,1),n=Dn(n,0,1),r=Dn(r,0,1),n===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+n):r+n-r*n,a=2*r-s;this.r=B_(a,s,e+1/3),this.g=B_(a,s,e),this.b=B_(a,s,e-1/3)}return jn.colorSpaceToWorking(this,i),this}setStyle(e,n=ws){function r(s){s!==void 0&&parseFloat(s)<1&&ln("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:ln("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(a===6)return this.setHex(parseInt(s,16),n);ln("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=ws){const r=xU[e.toLowerCase()];return r!==void 0?this.setHex(r,n):ln("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=No(e.r),this.g=No(e.g),this.b=No(e.b),this}copyLinearToSRGB(e){return this.r=Dd(e.r),this.g=Dd(e.g),this.b=Dd(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ws){return jn.workingToColorSpace(di.copy(this),e),Math.round(Dn(di.r*255,0,255))*65536+Math.round(Dn(di.g*255,0,255))*256+Math.round(Dn(di.b*255,0,255))}getHexString(e=ws){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=jn.workingColorSpace){jn.workingToColorSpace(di.copy(this),n);const r=di.r,i=di.g,s=di.b,a=Math.max(r,i,s),o=Math.min(r,i,s);let c,u;const f=(o+a)/2;if(o===a)c=0,u=0;else{const h=a-o;switch(u=f<=.5?h/(a+o):h/(2-a-o),a){case r:c=(i-s)/h+(i<s?6:0);break;case i:c=(s-r)/h+2;break;case s:c=(r-i)/h+4;break}c/=6}return e.h=c,e.s=u,e.l=f,e}getRGB(e,n=jn.workingColorSpace){return jn.workingToColorSpace(di.copy(this),n),e.r=di.r,e.g=di.g,e.b=di.b,e}getStyle(e=ws){jn.workingToColorSpace(di.copy(this),e);const n=di.r,r=di.g,i=di.b;return e!==ws?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(dl),this.setHSL(dl.h+e,dl.s+n,dl.l+r)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this}lerpColors(e,n,r){return this.r=e.r+(n.r-e.r)*r,this.g=e.g+(n.g-e.g)*r,this.b=e.b+(n.b-e.b)*r,this}lerpHSL(e,n){this.getHSL(dl),e.getHSL(Ig);const r=D_(dl.h,Ig.h,n),i=D_(dl.s,Ig.s,n),s=D_(dl.l,Ig.l,n);return this.setHSL(r,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,s=e.elements;return this.r=s[0]*n+s[3]*r+s[6]*i,this.g=s[1]*n+s[4]*r+s[7]*i,this.b=s[2]*n+s[5]*r+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const di=new Zn;Zn.NAMES=xU;class Kce extends ls{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new su,this.environmentIntensity=1,this.environmentRotation=new su,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const n=super.toJSON(e);return this.fog!==null&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(n.object.backgroundIntensity=this.backgroundIntensity),n.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(n.object.environmentIntensity=this.environmentIntensity),n.object.environmentRotation=this.environmentRotation.toArray(),n}}const $s=new Oe,po=new Oe,z_=new Oe,mo=new Oe,id=new Oe,sd=new Oe,hN=new Oe,V_=new Oe,H_=new Oe,W_=new Oe,G_=new yr,$_=new yr,Y_=new yr;let gh=class xd{constructor(e=new Oe,n=new Oe,r=new Oe){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),$s.subVectors(e,n),i.cross($s);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,n,r,i,s){$s.subVectors(i,n),po.subVectors(r,n),z_.subVectors(e,n);const a=$s.dot($s),o=$s.dot(po),c=$s.dot(z_),u=po.dot(po),f=po.dot(z_),h=a*u-o*o;if(h===0)return s.set(0,0,0),null;const m=1/h,g=(u*c-o*f)*m,v=(a*f-o*c)*m;return s.set(1-g-v,v,g)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,mo)===null?!1:mo.x>=0&&mo.y>=0&&mo.x+mo.y<=1}static getInterpolation(e,n,r,i,s,a,o,c){return this.getBarycoord(e,n,r,i,mo)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,mo.x),c.addScaledVector(a,mo.y),c.addScaledVector(o,mo.z),c)}static getInterpolatedAttribute(e,n,r,i,s,a){return G_.setScalar(0),$_.setScalar(0),Y_.setScalar(0),G_.fromBufferAttribute(e,n),$_.fromBufferAttribute(e,r),Y_.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(G_,s.x),a.addScaledVector($_,s.y),a.addScaledVector(Y_,s.z),a}static isFrontFacing(e,n,r,i){return $s.subVectors(r,n),po.subVectors(e,n),$s.cross(po).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return $s.subVectors(this.c,this.b),po.subVectors(this.a,this.b),$s.cross(po).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return xd.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return xd.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,s){return xd.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return xd.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return xd.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,s=this.c;let a,o;id.subVectors(i,r),sd.subVectors(s,r),V_.subVectors(e,r);const c=id.dot(V_),u=sd.dot(V_);if(c<=0&&u<=0)return n.copy(r);H_.subVectors(e,i);const f=id.dot(H_),h=sd.dot(H_);if(f>=0&&h<=f)return n.copy(i);const m=c*h-f*u;if(m<=0&&c>=0&&f<=0)return a=c/(c-f),n.copy(r).addScaledVector(id,a);W_.subVectors(e,s);const g=id.dot(W_),v=sd.dot(W_);if(v>=0&&g<=v)return n.copy(s);const w=g*u-c*v;if(w<=0&&u>=0&&v<=0)return o=u/(u-v),n.copy(r).addScaledVector(sd,o);const b=f*v-g*h;if(b<=0&&h-f>=0&&g-v>=0)return hN.subVectors(s,i),o=(h-f)/(h-f+(g-v)),n.copy(i).addScaledVector(hN,o);const _=1/(b+w+m);return a=w*_,o=m*_,n.copy(r).addScaledVector(id,a).addScaledVector(sd,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};class Wp{constructor(e=new Oe(1/0,1/0,1/0),n=new Oe(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(Ys.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Ys.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=Ys.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const s=r.getAttribute("position");if(n===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Ys):Ys.fromBufferAttribute(s,a),Ys.applyMatrix4(e.matrixWorld),this.expandByPoint(Ys);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Og.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Og.copy(r.boundingBox)),Og.applyMatrix4(e.matrixWorld),this.union(Og)}const i=e.children;for(let s=0,a=i.length;s<a;s++)this.expandByObject(i[s],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ys),Ys.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(yh),Fg.subVectors(this.max,yh),ad.subVectors(e.a,yh),od.subVectors(e.b,yh),ld.subVectors(e.c,yh),fl.subVectors(od,ad),hl.subVectors(ld,od),yc.subVectors(ad,ld);let n=[0,-fl.z,fl.y,0,-hl.z,hl.y,0,-yc.z,yc.y,fl.z,0,-fl.x,hl.z,0,-hl.x,yc.z,0,-yc.x,-fl.y,fl.x,0,-hl.y,hl.x,0,-yc.y,yc.x,0];return!q_(n,ad,od,ld,Fg)||(n=[1,0,0,0,1,0,0,0,1],!q_(n,ad,od,ld,Fg))?!1:(Ug.crossVectors(fl,hl),n=[Ug.x,Ug.y,Ug.z],q_(n,ad,od,ld,Fg))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ys).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ys).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(go[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),go[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),go[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),go[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),go[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),go[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),go[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),go[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(go),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const go=[new Oe,new Oe,new Oe,new Oe,new Oe,new Oe,new Oe,new Oe],Ys=new Oe,Og=new Wp,ad=new Oe,od=new Oe,ld=new Oe,fl=new Oe,hl=new Oe,yc=new Oe,yh=new Oe,Fg=new Oe,Ug=new Oe,vc=new Oe;function q_(t,e,n,r,i){for(let s=0,a=t.length-3;s<=a;s+=3){vc.fromArray(t,s);const o=i.x*Math.abs(vc.x)+i.y*Math.abs(vc.y)+i.z*Math.abs(vc.z),c=e.dot(vc),u=n.dot(vc),f=r.dot(vc);if(Math.max(-Math.max(c,u,f),Math.min(c,u,f))>o)return!1}return!0}const Er=new Oe,jg=new $n;let Zce=0;class sa{constructor(e,n,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Zce++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=QP,this.updateRanges=[],this.gpuType=Da,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)jg.fromBufferAttribute(this,n),jg.applyMatrix3(e),this.setXY(n,jg.x,jg.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Er.fromBufferAttribute(this,n),Er.applyMatrix3(e),this.setXYZ(n,Er.x,Er.y,Er.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Er.fromBufferAttribute(this,n),Er.applyMatrix4(e),this.setXYZ(n,Er.x,Er.y,Er.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Er.fromBufferAttribute(this,n),Er.applyNormalMatrix(e),this.setXYZ(n,Er.x,Er.y,Er.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Er.fromBufferAttribute(this,n),Er.transformDirection(e),this.setXYZ(n,Er.x,Er.y,Er.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=ph(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Ii(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=ph(n,this.array)),n}setX(e,n){return this.normalized&&(n=Ii(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=ph(n,this.array)),n}setY(e,n){return this.normalized&&(n=Ii(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=ph(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Ii(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=ph(n,this.array)),n}setW(e,n){return this.normalized&&(n=Ii(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Ii(n,this.array),r=Ii(r,this.array)),this.array[e+0]=n,this.array[e+1]=r,this}setXYZ(e,n,r,i){return e*=this.itemSize,this.normalized&&(n=Ii(n,this.array),r=Ii(r,this.array),i=Ii(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e*=this.itemSize,this.normalized&&(n=Ii(n,this.array),r=Ii(r,this.array),i=Ii(i,this.array),s=Ii(s,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==QP&&(e.usage=this.usage),e}}class bU extends sa{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class _U extends sa{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Do extends sa{constructor(e,n,r){super(new Float32Array(e),n,r)}}const Jce=new Wp,vh=new Oe,X_=new Oe;class nM{constructor(e=new Oe,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):Jce.setFromPoints(e).getCenter(r);let i=0;for(let s=0,a=e.length;s<a;s++)i=Math.max(i,r.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;vh.subVectors(e,this.center);const n=vh.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(vh,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(X_.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(vh.copy(e.center).add(X_)),this.expandByPoint(vh.copy(e.center).sub(X_))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let Qce=0;const vs=new Nr,K_=new ls,cd=new Oe,es=new Wp,xh=new Wp,Yr=new Oe;class eo extends pf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Qce++}),this.uuid=Hp(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Nce(e)?_U:bU)(e,1):this.index=e,this}setIndirect(e,n=0){return this.indirect=e,this.indirectOffset=n,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new pn().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return vs.makeRotationFromQuaternion(e),this.applyMatrix4(vs),this}rotateX(e){return vs.makeRotationX(e),this.applyMatrix4(vs),this}rotateY(e){return vs.makeRotationY(e),this.applyMatrix4(vs),this}rotateZ(e){return vs.makeRotationZ(e),this.applyMatrix4(vs),this}translate(e,n,r){return vs.makeTranslation(e,n,r),this.applyMatrix4(vs),this}scale(e,n,r){return vs.makeScale(e,n,r),this.applyMatrix4(vs),this}lookAt(e){return K_.lookAt(e),K_.updateMatrix(),this.applyMatrix4(K_.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(cd).negate(),this.translate(cd.x,cd.y,cd.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,s=e.length;i<s;i++){const a=e[i];r.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Do(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const s=e[i];n.setXYZ(i,s.x,s.y,s.z||0)}e.length>n.count&&ln("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),n.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Wp);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Vn("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Oe(-1/0,-1/0,-1/0),new Oe(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const s=n[r];es.setFromBufferAttribute(s),this.morphTargetsRelative?(Yr.addVectors(this.boundingBox.min,es.min),this.boundingBox.expandByPoint(Yr),Yr.addVectors(this.boundingBox.max,es.max),this.boundingBox.expandByPoint(Yr)):(this.boundingBox.expandByPoint(es.min),this.boundingBox.expandByPoint(es.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Vn('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new nM);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Vn("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Oe,1/0);return}if(e){const r=this.boundingSphere.center;if(es.setFromBufferAttribute(e),n)for(let s=0,a=n.length;s<a;s++){const o=n[s];xh.setFromBufferAttribute(o),this.morphTargetsRelative?(Yr.addVectors(es.min,xh.min),es.expandByPoint(Yr),Yr.addVectors(es.max,xh.max),es.expandByPoint(Yr)):(es.expandByPoint(xh.min),es.expandByPoint(xh.max))}es.getCenter(r);let i=0;for(let s=0,a=e.count;s<a;s++)Yr.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Yr));if(n)for(let s=0,a=n.length;s<a;s++){const o=n[s],c=this.morphTargetsRelative;for(let u=0,f=o.count;u<f;u++)Yr.fromBufferAttribute(o,u),c&&(cd.fromBufferAttribute(e,u),Yr.add(cd)),i=Math.max(i,r.distanceToSquared(Yr))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Vn('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){Vn("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,s=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new sa(new Float32Array(4*r.count),4));const a=this.getAttribute("tangent"),o=[],c=[];for(let k=0;k<r.count;k++)o[k]=new Oe,c[k]=new Oe;const u=new Oe,f=new Oe,h=new Oe,m=new $n,g=new $n,v=new $n,w=new Oe,b=new Oe;function _(k,N,B){u.fromBufferAttribute(r,k),f.fromBufferAttribute(r,N),h.fromBufferAttribute(r,B),m.fromBufferAttribute(s,k),g.fromBufferAttribute(s,N),v.fromBufferAttribute(s,B),f.sub(u),h.sub(u),g.sub(m),v.sub(m);const L=1/(g.x*v.y-v.x*g.y);isFinite(L)&&(w.copy(f).multiplyScalar(v.y).addScaledVector(h,-g.y).multiplyScalar(L),b.copy(h).multiplyScalar(g.x).addScaledVector(f,-v.x).multiplyScalar(L),o[k].add(w),o[N].add(w),o[B].add(w),c[k].add(b),c[N].add(b),c[B].add(b))}let E=this.groups;E.length===0&&(E=[{start:0,count:e.count}]);for(let k=0,N=E.length;k<N;++k){const B=E[k],L=B.start,z=B.count;for(let I=L,V=L+z;I<V;I+=3)_(e.getX(I+0),e.getX(I+1),e.getX(I+2))}const M=new Oe,T=new Oe,R=new Oe,A=new Oe;function P(k){R.fromBufferAttribute(i,k),A.copy(R);const N=o[k];M.copy(N),M.sub(R.multiplyScalar(R.dot(N))).normalize(),T.crossVectors(A,N);const L=T.dot(c[k])<0?-1:1;a.setXYZW(k,M.x,M.y,M.z,L)}for(let k=0,N=E.length;k<N;++k){const B=E[k],L=B.start,z=B.count;for(let I=L,V=L+z;I<V;I+=3)P(e.getX(I+0)),P(e.getX(I+1)),P(e.getX(I+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new sa(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,g=r.count;m<g;m++)r.setXYZ(m,0,0,0);const i=new Oe,s=new Oe,a=new Oe,o=new Oe,c=new Oe,u=new Oe,f=new Oe,h=new Oe;if(e)for(let m=0,g=e.count;m<g;m+=3){const v=e.getX(m+0),w=e.getX(m+1),b=e.getX(m+2);i.fromBufferAttribute(n,v),s.fromBufferAttribute(n,w),a.fromBufferAttribute(n,b),f.subVectors(a,s),h.subVectors(i,s),f.cross(h),o.fromBufferAttribute(r,v),c.fromBufferAttribute(r,w),u.fromBufferAttribute(r,b),o.add(f),c.add(f),u.add(f),r.setXYZ(v,o.x,o.y,o.z),r.setXYZ(w,c.x,c.y,c.z),r.setXYZ(b,u.x,u.y,u.z)}else for(let m=0,g=n.count;m<g;m+=3)i.fromBufferAttribute(n,m+0),s.fromBufferAttribute(n,m+1),a.fromBufferAttribute(n,m+2),f.subVectors(a,s),h.subVectors(i,s),f.cross(h),r.setXYZ(m+0,f.x,f.y,f.z),r.setXYZ(m+1,f.x,f.y,f.z),r.setXYZ(m+2,f.x,f.y,f.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Yr.fromBufferAttribute(e,n),Yr.normalize(),e.setXYZ(n,Yr.x,Yr.y,Yr.z)}toNonIndexed(){function e(o,c){const u=o.array,f=o.itemSize,h=o.normalized,m=new u.constructor(c.length*f);let g=0,v=0;for(let w=0,b=c.length;w<b;w++){o.isInterleavedBufferAttribute?g=c[w]*o.data.stride+o.offset:g=c[w]*f;for(let _=0;_<f;_++)m[v++]=u[g++]}return new sa(m,f,h)}if(this.index===null)return ln("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new eo,r=this.index.array,i=this.attributes;for(const o in i){const c=i[o],u=e(c,r);n.setAttribute(o,u)}const s=this.morphAttributes;for(const o in s){const c=[],u=s[o];for(let f=0,h=u.length;f<h;f++){const m=u[f],g=e(m,r);c.push(g)}n.morphAttributes[o]=c}n.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const u=a[o];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],f=[];for(let h=0,m=u.length;h<m;h++){const g=u[h];f.push(g.toJSON(e.data))}f.length>0&&(i[c]=f,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const f=i[u];this.setAttribute(u,f.clone(n))}const s=e.morphAttributes;for(const u in s){const f=[],h=s[u];for(let m=0,g=h.length;m<g;m++)f.push(h[m].clone(n));this.morphAttributes[u]=f}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let u=0,f=a.length;u<f;u++){const h=a[u];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}let eue=0;class hv extends pf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:eue++}),this.uuid=Hp(),this.name="",this.type="Material",this.blending=Hc,this.side=Ol,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=F1,this.blendDst=U1,this.blendEquation=Tc,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Zn(0,0,0),this.blendAlpha=0,this.depthFunc=qd,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=JP,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Qu,this.stencilZFail=Qu,this.stencilZPass=Qu,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const r=e[n];if(r===void 0){ln(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){ln(`Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Hc&&(r.blending=this.blending),this.side!==Ol&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==F1&&(r.blendSrc=this.blendSrc),this.blendDst!==U1&&(r.blendDst=this.blendDst),this.blendEquation!==Tc&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==qd&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==JP&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Qu&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Qu&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Qu&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.allowOverride===!1&&(r.allowOverride=!1),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const a=[];for(const o in s){const c=s[o];delete c.metadata,a.push(c)}return a}if(n){const s=i(e.textures),a=i(e.images);s.length>0&&(r.textures=s),a.length>0&&(r.images=a)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=n[s].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}const yo=new Oe,Z_=new Oe,Bg=new Oe,pl=new Oe,J_=new Oe,zg=new Oe,Q_=new Oe;class tue{constructor(e=new Oe,n=new Oe(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,yo)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=yo.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(yo.copy(this.origin).addScaledVector(this.direction,n),yo.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){Z_.copy(e).add(n).multiplyScalar(.5),Bg.copy(n).sub(e).normalize(),pl.copy(this.origin).sub(Z_);const s=e.distanceTo(n)*.5,a=-this.direction.dot(Bg),o=pl.dot(this.direction),c=-pl.dot(Bg),u=pl.lengthSq(),f=Math.abs(1-a*a);let h,m,g,v;if(f>0)if(h=a*c-o,m=a*o-c,v=s*f,h>=0)if(m>=-v)if(m<=v){const w=1/f;h*=w,m*=w,g=h*(h+a*m+2*o)+m*(a*h+m+2*c)+u}else m=s,h=Math.max(0,-(a*m+o)),g=-h*h+m*(m+2*c)+u;else m=-s,h=Math.max(0,-(a*m+o)),g=-h*h+m*(m+2*c)+u;else m<=-v?(h=Math.max(0,-(-a*s+o)),m=h>0?-s:Math.min(Math.max(-s,-c),s),g=-h*h+m*(m+2*c)+u):m<=v?(h=0,m=Math.min(Math.max(-s,-c),s),g=m*(m+2*c)+u):(h=Math.max(0,-(a*s+o)),m=h>0?s:Math.min(Math.max(-s,-c),s),g=-h*h+m*(m+2*c)+u);else m=a>0?-s:s,h=Math.max(0,-(a*m+o)),g=-h*h+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(Z_).addScaledVector(Bg,m),g}intersectSphere(e,n){yo.subVectors(e.center,this.origin);const r=yo.dot(this.direction),i=yo.dot(yo)-r*r,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=r-a,c=r+a;return c<0?null:o<0?this.at(c,n):this.at(o,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,s,a,o,c;const u=1/this.direction.x,f=1/this.direction.y,h=1/this.direction.z,m=this.origin;return u>=0?(r=(e.min.x-m.x)*u,i=(e.max.x-m.x)*u):(r=(e.max.x-m.x)*u,i=(e.min.x-m.x)*u),f>=0?(s=(e.min.y-m.y)*f,a=(e.max.y-m.y)*f):(s=(e.max.y-m.y)*f,a=(e.min.y-m.y)*f),r>a||s>i||((s>r||isNaN(r))&&(r=s),(a<i||isNaN(i))&&(i=a),h>=0?(o=(e.min.z-m.z)*h,c=(e.max.z-m.z)*h):(o=(e.max.z-m.z)*h,c=(e.min.z-m.z)*h),r>c||o>i)||((o>r||r!==r)&&(r=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,yo)!==null}intersectTriangle(e,n,r,i,s){J_.subVectors(n,e),zg.subVectors(r,e),Q_.crossVectors(J_,zg);let a=this.direction.dot(Q_),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;pl.subVectors(this.origin,e);const c=o*this.direction.dot(zg.crossVectors(pl,zg));if(c<0)return null;const u=o*this.direction.dot(J_.cross(pl));if(u<0||c+u>a)return null;const f=-o*pl.dot(Q_);return f<0?null:this.at(f/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class wU extends hv{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Zn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new su,this.combine=QF,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const pN=new Nr,xc=new tue,Vg=new nM,mN=new Oe,Hg=new Oe,Wg=new Oe,Gg=new Oe,ew=new Oe,$g=new Oe,gN=new Oe,Yg=new Oe;let Ya=class extends ls{constructor(e=new eo,n=new wU){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,a=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(s&&o){$g.set(0,0,0);for(let c=0,u=s.length;c<u;c++){const f=o[c],h=s[c];f!==0&&(ew.fromBufferAttribute(h,e),a?$g.addScaledVector(ew,f):$g.addScaledVector(ew.sub(n),f))}n.add($g)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),Vg.copy(r.boundingSphere),Vg.applyMatrix4(s),xc.copy(e.ray).recast(e.near),!(Vg.containsPoint(xc.origin)===!1&&(xc.intersectSphere(Vg,mN)===null||xc.origin.distanceToSquared(mN)>(e.far-e.near)**2))&&(pN.copy(s).invert(),xc.copy(e.ray).applyMatrix4(pN),!(r.boundingBox!==null&&xc.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,xc)))}_computeIntersections(e,n,r){let i;const s=this.geometry,a=this.material,o=s.index,c=s.attributes.position,u=s.attributes.uv,f=s.attributes.uv1,h=s.attributes.normal,m=s.groups,g=s.drawRange;if(o!==null)if(Array.isArray(a))for(let v=0,w=m.length;v<w;v++){const b=m[v],_=a[b.materialIndex],E=Math.max(b.start,g.start),M=Math.min(o.count,Math.min(b.start+b.count,g.start+g.count));for(let T=E,R=M;T<R;T+=3){const A=o.getX(T),P=o.getX(T+1),k=o.getX(T+2);i=qg(this,_,e,r,u,f,h,A,P,k),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const v=Math.max(0,g.start),w=Math.min(o.count,g.start+g.count);for(let b=v,_=w;b<_;b+=3){const E=o.getX(b),M=o.getX(b+1),T=o.getX(b+2);i=qg(this,a,e,r,u,f,h,E,M,T),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(a))for(let v=0,w=m.length;v<w;v++){const b=m[v],_=a[b.materialIndex],E=Math.max(b.start,g.start),M=Math.min(c.count,Math.min(b.start+b.count,g.start+g.count));for(let T=E,R=M;T<R;T+=3){const A=T,P=T+1,k=T+2;i=qg(this,_,e,r,u,f,h,A,P,k),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const v=Math.max(0,g.start),w=Math.min(c.count,g.start+g.count);for(let b=v,_=w;b<_;b+=3){const E=b,M=b+1,T=b+2;i=qg(this,a,e,r,u,f,h,E,M,T),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}};function nue(t,e,n,r,i,s,a,o){let c;if(e.side===zi?c=r.intersectTriangle(a,s,i,!0,o):c=r.intersectTriangle(i,s,a,e.side===Ol,o),c===null)return null;Yg.copy(o),Yg.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(Yg);return u<n.near||u>n.far?null:{distance:u,point:Yg.clone(),object:t}}function qg(t,e,n,r,i,s,a,o,c,u){t.getVertexPosition(o,Hg),t.getVertexPosition(c,Wg),t.getVertexPosition(u,Gg);const f=nue(t,e,n,r,Hg,Wg,Gg,gN);if(f){const h=new Oe;gh.getBarycoord(gN,Hg,Wg,Gg,h),i&&(f.uv=gh.getInterpolatedAttribute(i,o,c,u,h,new $n)),s&&(f.uv1=gh.getInterpolatedAttribute(s,o,c,u,h,new $n)),a&&(f.normal=gh.getInterpolatedAttribute(a,o,c,u,h,new Oe),f.normal.dot(r.direction)>0&&f.normal.multiplyScalar(-1));const m={a:o,b:c,c:u,normal:new Oe,materialIndex:0};gh.getNormal(Hg,Wg,Gg,m.normal),f.face=m,f.barycoord=h}return f}class rue extends Ti{constructor(e=null,n=1,r=1,i,s,a,o,c,u=ni,f=ni,h,m){super(null,a,o,c,u,f,i,s,h,m),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const tw=new Oe,iue=new Oe,sue=new pn;class Mc{constructor(e=new Oe(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=tw.subVectors(r,n).cross(iue.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,n){return n.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,n){const r=e.delta(tw),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:n.copy(e.start).addScaledVector(r,s)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||sue.getNormalMatrix(e),i=this.coplanarPoint(tw).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const bc=new nM,aue=new $n(.5,.5),Xg=new Oe;class SU{constructor(e=new Mc,n=new Mc,r=new Mc,i=new Mc,s=new Mc,a=new Mc){this.planes=[e,n,r,i,s,a]}set(e,n,r,i,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=La,r=!1){const i=this.planes,s=e.elements,a=s[0],o=s[1],c=s[2],u=s[3],f=s[4],h=s[5],m=s[6],g=s[7],v=s[8],w=s[9],b=s[10],_=s[11],E=s[12],M=s[13],T=s[14],R=s[15];if(i[0].setComponents(u-a,g-f,_-v,R-E).normalize(),i[1].setComponents(u+a,g+f,_+v,R+E).normalize(),i[2].setComponents(u+o,g+h,_+w,R+M).normalize(),i[3].setComponents(u-o,g-h,_-w,R-M).normalize(),r)i[4].setComponents(c,m,b,T).normalize(),i[5].setComponents(u-c,g-m,_-b,R-T).normalize();else if(i[4].setComponents(u-c,g-m,_-b,R-T).normalize(),n===La)i[5].setComponents(u+c,g+m,_+b,R+T).normalize();else if(n===by)i[5].setComponents(c,m,b,T).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),bc.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),bc.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(bc)}intersectsSprite(e){bc.center.set(0,0,0);const n=aue.distanceTo(e.center);return bc.radius=.7071067811865476+n,bc.applyMatrix4(e.matrixWorld),this.intersectsSphere(bc)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(n[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(Xg.x=i.normal.x>0?e.max.x:e.min.x,Xg.y=i.normal.y>0?e.max.y:e.min.y,Xg.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Xg)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let r=0;r<6;r++)if(n[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class kU extends Ti{constructor(e=[],n=ru,r,i,s,a,o,c,u,f){super(e,n,r,i,s,a,o,c,u,f),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class hp extends Ti{constructor(e,n,r=$a,i,s,a,o=ni,c=ni,u,f=jo,h=1){if(f!==jo&&f!==Uc)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const m={width:e,height:n,depth:h};super(m,i,s,a,o,c,f,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new tM(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const n=super.toJSON(e);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}}class oue extends hp{constructor(e,n=$a,r=ru,i,s,a=ni,o=ni,c,u=jo){const f={width:e,height:e,depth:1},h=[f,f,f,f,f,f];super(e,e,n,r,i,s,a,o,c,u),this.image=h,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class EU extends Ti{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Gp extends eo{constructor(e=1,n=1,r=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const c=[],u=[],f=[],h=[];let m=0,g=0;v("z","y","x",-1,-1,r,n,e,a,s,0),v("z","y","x",1,-1,r,n,-e,a,s,1),v("x","z","y",1,1,e,r,n,i,a,2),v("x","z","y",1,-1,e,r,-n,i,a,3),v("x","y","z",1,-1,e,n,r,i,s,4),v("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(c),this.setAttribute("position",new Do(u,3)),this.setAttribute("normal",new Do(f,3)),this.setAttribute("uv",new Do(h,2));function v(w,b,_,E,M,T,R,A,P,k,N){const B=T/P,L=R/k,z=T/2,I=R/2,V=A/2,W=P+1,X=k+1;let J=0,F=0;const G=new Oe;for(let Y=0;Y<X;Y++){const H=Y*L-I;for(let te=0;te<W;te++){const re=te*B-z;G[w]=re*E,G[b]=H*M,G[_]=V,u.push(G.x,G.y,G.z),G[w]=0,G[b]=0,G[_]=A>0?1:-1,f.push(G.x,G.y,G.z),h.push(te/P),h.push(1-Y/k),J+=1}}for(let Y=0;Y<k;Y++)for(let H=0;H<P;H++){const te=m+H+W*Y,re=m+H+W*(Y+1),ue=m+(H+1)+W*(Y+1),ce=m+(H+1)+W*Y;c.push(te,re,ce),c.push(re,ue,ce),F+=6}o.addGroup(g,F,N),g+=F,m+=J}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Gp(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class pv extends eo{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const s=e/2,a=n/2,o=Math.floor(r),c=Math.floor(i),u=o+1,f=c+1,h=e/o,m=n/c,g=[],v=[],w=[],b=[];for(let _=0;_<f;_++){const E=_*m-a;for(let M=0;M<u;M++){const T=M*h-s;v.push(T,-E,0),w.push(0,0,1),b.push(M/o),b.push(1-_/c)}}for(let _=0;_<c;_++)for(let E=0;E<o;E++){const M=E+u*_,T=E+u*(_+1),R=E+1+u*(_+1),A=E+1+u*_;g.push(M,T,A),g.push(T,R,A)}this.setIndex(g),this.setAttribute("position",new Do(v,3)),this.setAttribute("normal",new Do(w,3)),this.setAttribute("uv",new Do(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new pv(e.width,e.height,e.widthSegments,e.heightSegments)}}function Zd(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(ln("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function wi(t){const e={};for(let n=0;n<t.length;n++){const r=Zd(t[n]);for(const i in r)e[i]=r[i]}return e}function lue(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function MU(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:jn.workingColorSpace}const cue={clone:Zd,merge:wi};var uue=`void main() {
|
|
621
623
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
622
624
|
}`,due=`void main() {
|
|
623
625
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|