@ipv9/tokentracker-cli 0.39.39 → 0.39.40
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 +2 -2
- package/dashboard/dist/assets/{Card-BbRYRVXf.js → Card-JS4gjUZf.js} +1 -1
- package/dashboard/dist/assets/{DashboardPage-DYKHv0m3.js → DashboardPage-BoXhzJb1.js} +3 -3
- package/dashboard/dist/assets/{FadeIn-CjAacJ5t.js → FadeIn-DvLfvwys.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-BGALK8Vy.js → IpCheckPage-Dcfc0Uts.js} +1 -1
- package/dashboard/dist/assets/LimitsPage-Vz-GVdi9.js +2 -0
- package/dashboard/dist/assets/{LocalOnlyNotice-Dxo2vFMQ.js → LocalOnlyNotice-8xF5couh.js} +1 -1
- package/dashboard/dist/assets/{PopoverPopup-DP9fwdtl.js → PopoverPopup-7HrUzeRx.js} +1 -1
- package/dashboard/dist/assets/{Select-DPE53NmM.js → Select-9XDsaO_C.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-D69v77is.js → SelectItemText-DE5Fs9p6.js} +1 -1
- package/dashboard/dist/assets/{SettingsPage-Dxzqpi02.js → SettingsPage-CMnfAptE.js} +1 -1
- package/dashboard/dist/assets/{SkillsPage-Bo7e39AB.js → SkillsPage-CbvLHN0L.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-HHcIr_Eq.js → WidgetsPage-CeGQlyt7.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-C-_jLXXU.js → WrappedPage-Bux8qLUC.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-BJvJHUGj.js → arrow-up-right-B7rCoZdW.js} +1 -1
- package/dashboard/dist/assets/{download-CnzY_EgN.js → download-CtTYpbcx.js} +1 -1
- package/dashboard/dist/assets/{format-1w-q5n2f.js → format-BuQKK6kQ.js} +1 -1
- package/dashboard/dist/assets/limitDisplay-WwuTdS_a.js +1 -0
- package/dashboard/dist/assets/{main-3gBEI6Jl.js → main-Ck4SUH4m.js} +5 -3
- package/dashboard/dist/assets/main-ZrWkoMlr.css +1 -0
- package/dashboard/dist/assets/{mock-data-CJOMGcL9.js → mock-data-Bvbe8tYK.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-D1nT9-mr.js → use-limits-display-prefs-BKWYPgeA.js} +1 -1
- package/dashboard/dist/assets/{use-native-settings-Dh6NzqjY.js → use-native-settings-D7Nj1dXR.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-Hhs5jbWw.js → useCurrency-BX3pvyhh.js} +1 -1
- package/dashboard/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/dashboard/dist/assets/LimitsPage-LkZGPYvg.js +0 -2
- package/dashboard/dist/assets/main-1kxAVM3m.css +0 -1
- package/dashboard/dist/assets/use-usage-limits-BXR6lzGf.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as nn,i as Vs,f as Ar,a as Fr,J as qs,u as Rr,m as Xs,r as m,M as Ir,b as Ks,d as Gs,e as Wn,j as o,L as Qs,g as Js,h as Zs,k as ei,l as ti,n as Lt,o as ht,p as y,q as Lr,X as sa,s as ni,R,t as ia,C as Yr,P as la,B as Kn,v as zr,w as Br,A as Hr,x as Xe,y as ai,z as ri,D as oi,E as si,F as ii}from"./main-3gBEI6Jl.js";import{g as li,i as Yt,b as Gn,c as gn,a as an,d as Zt,f as mt,e as Ur,h as Vr,j as ci,k as di,l as ui,m as fi}from"./mock-data-CJOMGcL9.js";import{g as mi,a as Mn,b as hi,c as gi,d as qr,e as En,f as yi,h as pi,i as bi,u as xi,t as Fa}from"./use-usage-limits-BXR6lzGf.js";import{u as _t,I as ca}from"./useCurrency-Hhs5jbWw.js";import{t as Le,f as et,a as Ae,b as Qe}from"./format-1w-q5n2f.js";import{u as ki,D as wi,a as vi,b as Ni,c as _i,d as Mi,e as ji,P as Qn,f as Jn,g as Zn,h as ea,i as ta,L as Si}from"./PopoverPopup-DP9fwdtl.js";import{C as rn}from"./Card-BbRYRVXf.js";import{S as Ci}from"./Select-DPE53NmM.js";import{F as xt}from"./FadeIn-CjAacJ5t.js";import"./SelectItemText-D69v77is.js";const Di=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Xr=nn("maximize-2",Di);const Ti=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],Pi=nn("pause",Ti);const Oi=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],$i=nn("play",Oi);const Wi=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Ei=nn("rotate-ccw",Wi);const Ai=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Kr=nn("terminal",Ai);function Fi(...e){const t=!Array.isArray(e[0]),n=t?0:-1,a=e[0+n],r=e[1+n],s=e[2+n],l=e[3+n],i=Vs(r,s,l);return t?i(a):i}function Ri(e,t,n={}){const a=e.get();let r=null,s=a,l;const i=typeof a=="string"?a.replace(/[\d.-]/g,""):void 0,c=()=>{r&&(r.stop(),r=null),e.animation=void 0},u=()=>{const f=Ra(e.get()),h=Ra(s);if(f===h){c();return}const g=r?r.getGeneratorVelocity():e.getVelocity();c(),r=new qs({keyframes:[f,h],velocity:g,type:"spring",restDelta:.001,restSpeed:.01,...n,onUpdate:l})},d=()=>{u(),e.animation=r??void 0,e.events.animationStart?.notify(),r?.then(()=>{e.animation=void 0,e.events.animationComplete?.notify()})};if(e.attach((f,h)=>{s=f,l=g=>h(An(g,i)),Ar.postRender(d)},c),Fr(t)){let f=n.skipInitialAnimation===!0;const h=t.on("change",p=>{f?(f=!1,e.jump(An(p,i),!1)):e.set(An(p,i))}),g=e.on("destroy",h);return()=>{h(),g()}}return c}function An(e,t){return t?e+t:e}function Ra(e){return typeof e=="number"?e:parseFloat(e)}function da(e){const t=Rr(()=>Xs(e)),{isStatic:n}=m.useContext(Ir);if(n){const[,a]=m.useState(e);m.useEffect(()=>t.on("change",a),[])}return t}function Gr(e,t){const n=da(t()),a=()=>n.set(t());return a(),Ks(()=>{const r=()=>Ar.preRender(a,!1,!0),s=e.map(l=>l.on("change",r));return()=>{s.forEach(l=>l()),Gs(a)}}),n}function Ii(e){Wn.current=[],e();const t=Gr(Wn.current,e);return Wn.current=void 0,t}function Qr(e,t,n,a){if(typeof e=="function")return Ii(e);const s=typeof t=="function"?t:Fi(t,n,a),l=Array.isArray(e)?Ia(e,s):Ia([e],([c])=>s(c)),i=Array.isArray(e)?void 0:e.accelerate;return i&&!i.isTransformed&&typeof t!="function"&&Array.isArray(n)&&a?.clamp!==!1&&(l.accelerate={...i,times:t,keyframes:n,isTransformed:!0}),l}function Ia(e,t){const n=Rr(()=>[]);return Gr(e,()=>{n.length=0;const a=e.length;for(let r=0;r<a;r++)n[r]=e[r].get();return t(n)})}function Li(e,t={}){const{isStatic:n}=m.useContext(Ir),a=()=>Fr(e)?e.get():e;if(n)return Qr(a);const r=da(a());return m.useInsertionEffect(()=>Ri(r,e,t),[r,JSON.stringify(t)]),r}function Yi(e,t={}){return Li(e,{type:"spring",...t})}function zi(){return o.jsxs(Qs,{to:"/landing",className:"flex items-center gap-2.5 no-underline hover:opacity-80 transition-opacity",children:[o.jsx("img",{src:"/app-icon.png",alt:"Token Tracker",width:28,height:28,className:"rounded-md"}),o.jsx("span",{className:"text-base font-semibold text-oai-black dark:text-oai-white leading-tight",children:"Token Tracker"})]})}function Bi({children:e,header:t,footer:n,className:a="",hideHeader:r=!1,hideFooter:s=!1,bare:l=!1}){return l?o.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${a}`,children:[o.jsx("main",{className:"flex-1 px-6 py-6",children:e}),!s&&n&&o.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})]}):o.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 ${a}`,children:[!r&&o.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:[o.jsx(zi,{}),o.jsx("div",{className:"flex-1 flex justify-center",children:t})]}),o.jsx("main",{className:"flex-1 px-6 py-6",children:e}),!s&&n&&o.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 Hi({children:e,variant:t="info",size:n="md",className:a=""}){const r="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"},l={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm"},i=`${r} ${s[t]} ${l[n]} ${a}`.trim();return o.jsx("span",{className:i,children:e})}const Ui=m.forwardRef(function(t,n){const{render:a,className:r,disabled:s=!1,nativeButton:l=!0,...i}=t,{store:c}=ki(),u=c.useState("open");function d(p){u&&c.setOpen(!1,ei(ti,p.nativeEvent))}const{getButtonProps:f,buttonRef:h}=Js({disabled:s,native:l}),g=m.useMemo(()=>({disabled:s}),[s]);return Zs("button",t,{state:g,ref:[n,h],props:[{onClick:d},i,f]})});var Vi={};function qi(e,t){return e==="."?{width:"0.34ch",justifyContent:"center",marginInline:"-0.04ch"}:e===","?{width:"0.08ch",justifyContent:"center",marginInline:"-0.30ch"}:{width:"0.72ch",justifyContent:"flex-start",paddingLeft:"0.04ch",height:t}}function Xi({mv:e,digit:t,height:n}){const a=Qr(e,r=>{const s=(r%10+10)%10,l=(10+t-s)%10;let i=l*n;return l>5&&(i-=10*n),i});return o.jsx(ht.span,{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",y:a},children:t})}function Ki(e){const t=Math.round(e),n=1e-9*Math.max(1,Math.abs(e));return Math.abs(e-t)<n?t:e}function Gi(e,t){const n=e/t;return Math.floor(Ki(n))}function Qi(e){const t=String(e??""),n=Array.from(t),a=n.indexOf(".");let r=n.filter((i,c)=>/\d/.test(i)&&(a===-1||c<a)).length,s=0,l=!1;return n.map(i=>{if(!/\d/.test(i))return i==="."&&(l=!0),i;if(!l){const c=10**Math.max(r-1,0);return r-=1,c}return s+=1,10**-s})}function Ji({place:e,value:t,height:n,digitStyle:a,shouldReduceMotion:r,isLed:s}){if(typeof e!="number"){const u=qi(e,n);return o.jsx("span",{"data-counter-token":"static",className:`relative inline-flex items-center justify-center${s?" tt-lcd-sep":""}`,style:{height:n,...u,...a},children:e})}const l=Gi(t,e),i=da(0),c=Yi(i,{stiffness:220,damping:26,mass:.8});return m.useEffect(()=>{i.set(l)},[i,l]),r?o.jsx("span",{"data-counter-token":"digit",className:`relative inline-flex items-center justify-center overflow-hidden${s?" tt-lcd-cell":""}`,style:{height:n,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...a},children:Math.abs(l)%10}):o.jsx("span",{"data-counter-token":"digit",className:`relative inline-flex overflow-hidden${s?" tt-lcd-cell":""}`,style:{height:n,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...a},children:Array.from({length:10},(u,d)=>o.jsx(Xi,{mv:c,digit:d,height:n},d))})}function Zi({value:e,displayValue:t,fontSize:n=72,padding:a=0,places:r,gap:s=6,borderRadius:l=4,horizontalPadding:i=0,textColor:c="inherit",fontWeight:u="inherit",containerStyle:d,counterStyle:f,digitStyle:h,gradientHeight:g=14,gradientFrom:p="rgba(255,255,255,0.95)",gradientTo:k="rgba(255,255,255,0)",topGradientStyle:v,bottomGradientStyle:w,variant:N="default"}){const x=N==="led",M=String(t??e??""),T=m.useMemo(()=>Array.isArray(r)&&r.length?r:Qi(M),[r,M]),j=typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent||"")||typeof process<"u"&&Vi?.VITEST==="true",L=Lt()||j,P=Number.isFinite(Number(e))?Math.abs(Number(e)):0,C=n+a;return L?o.jsx("span",{"data-counter-root":"true",className:x?"tt-lcd":void 0,style:{display:"inline-flex",alignItems:"center",color:c,fontSize:n,fontWeight:u,lineHeight:1,...d,...f},children:x?o.jsx("span",{className:"tt-lcd-cell tt-lcd-cell--static",children:M}):M}):o.jsxs("span",{"data-counter-root":"true",style:{position:"relative",display:"inline-block",...d},children:[o.jsx("span",{className:x?"tt-lcd":void 0,style:{fontSize:n,...x?null:{display:"flex",gap:s,borderRadius:l,paddingLeft:i,paddingRight:i,color:c},overflow:"hidden",lineHeight:1,fontWeight:u,...f},children:T.map((I,K)=>o.jsx(Ji,{place:I,value:P,height:C,digitStyle:h,shouldReduceMotion:L,isLed:x},`${String(I)}-${K}`))}),o.jsxs("span",{style:{pointerEvents:"none",position:"absolute",inset:0,display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[o.jsx("span",{style:v??{height:g,background:`linear-gradient(to bottom, ${p}, ${k})`}}),o.jsx("span",{style:w??{height:g,background:`linear-gradient(to top, ${p}, ${k})`}})]})]})}var el={};const tl=new Set([",","."," "]),nl=typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent||"")||typeof process<"u"&&el?.VITEST==="true";function al({char:e,reduceMotion:t,index:n}){const[a,r]=m.useState(t?e:""),[s,l]=m.useState(!1),i=m.useRef(e),c=m.useRef(!1);return m.useEffect(()=>{if(!c.current){if(c.current=!0,i.current=e,t){r(e);return}const f=Math.min(n*45,520),h=setTimeout(()=>l(!0),f),g=setTimeout(()=>r(e),f+130),p=setTimeout(()=>l(!1),f+300);return()=>{clearTimeout(h),clearTimeout(g),clearTimeout(p)}}if(e===i.current)return;if(i.current=e,t){r(e);return}l(!0);const u=setTimeout(()=>r(e),130),d=setTimeout(()=>l(!1),300);return()=>{clearTimeout(u),clearTimeout(d)}},[e,t,n]),o.jsx("span",{className:`tt-flap${s?" tt-flap--flip":""}`,"aria-hidden":"true",children:o.jsx("span",{className:"tt-flap__glyph",children:a})})}function rl({value:e,fontSize:t=56,className:n=""}){const a=Lt()||nl,r=String(e??""),s=Array.from(r);return o.jsx("span",{className:`tt-flaprow ${n}`,style:{fontSize:`clamp(30px, 9cqi, ${t}px)`},role:"text","aria-label":r,children:s.map((l,i)=>tl.has(l)?o.jsx("span",{className:"tt-flap-sep","aria-hidden":"true",children:l},i):o.jsx(al,{char:l,reduceMotion:a,index:i},i))})}function ol({baseUrl:e,accessToken:t,guestAllowed:n=!1,weeks:a=52,weekStartsOn:r="sun",cacheKey:s,timeZone:l,tzOffsetMinutes:i,now:c}={}){const u=m.useMemo(()=>li({weeks:a,weekStartsOn:r,now:c}),[c,a,r]),[d,f]=m.useState([]),[h,g]=m.useState(null),[p,k]=m.useState("edge"),[v,w]=m.useState(!1),[N,x]=m.useState(null),M=Yt(),T=!n,j=m.useMemo(()=>{if(!s)return null;const V=an({timeZone:l,offsetMinutes:i});return`tokentracker.heatmap.${s}.${a}.${r}.${V}`},[s,l,i,a,r]),L=m.useCallback(()=>{if(!j||typeof window>"u")return null;try{const V=window.localStorage.getItem(j);if(!V)return null;const $=JSON.parse(V);return!$||!$.heatmap?null:$}catch{return null}},[j]),P=m.useCallback(V=>{if(!(!j||typeof window>"u"))try{window.localStorage.setItem(j,JSON.stringify(V))}catch{}},[j]),C=m.useCallback(()=>{if(!(!j||typeof window>"u"))try{window.localStorage.removeItem(j)}catch{}},[j]),I=m.useCallback(async()=>{w(!0),x(null);try{try{const D=await mi({baseUrl:e,accessToken:t,weeks:a,to:u.to,weekStartsOn:r,timeZone:l,tzOffsetMinutes:i}),b=Array.isArray(D?.weeks)?D.weeks:[];if(!b.length&&T){const H=L();if(H?.heatmap){g(H.heatmap),f(H.daily||[]),k("cache");return}}if(!b.some(H=>(Array.isArray(H)?H:[]).some(S=>S&&Number.isFinite(Number(S.level))))&&b.length){const H=[];for(const X of b)for(const F of Array.isArray(X)?X:[])F?.day&&H.push({day:F.day,conversation_count:F.conversation_count??0,total_tokens:F.total_tokens??F.value??0,billable_total_tokens:F.billable_total_tokens??F.value??F.total_tokens??0});const S=Gn({dailyRows:H,weeks:a,to:D?.to||u.to,weekStartsOn:r});f(H),g({...S,week_starts_on:r,active_days:H.filter(X=>Number(X?.billable_total_tokens??X?.total_tokens)>0).length,streak_days:gn({dailyRows:H,to:D?.to||u.to})}),k("client"),T?P({heatmap:{...S,week_starts_on:r,active_days:H.filter(X=>Number(X?.billable_total_tokens??X?.total_tokens)>0).length,streak_days:gn({dailyRows:H,to:D?.to||u.to})},daily:H,fetchedAt:new Date().toISOString()}):C();return}g(D||null),f([]),k("edge"),D&&T?P({heatmap:D,daily:[],fetchedAt:new Date().toISOString()}):T||C();return}catch(D){const b=D,_=b?.status??b?.statusCode;if(_===401||_===403)throw D}const V=await Mn({baseUrl:e,accessToken:t,from:u.from,to:u.to,timeZone:l,tzOffsetMinutes:i}),$=Array.isArray(V?.data)?V.data:[];f($);const E=Gn({dailyRows:$,weeks:a,to:u.to,weekStartsOn:r});g({...E,week_starts_on:r,active_days:$.filter(D=>Number(D?.billable_total_tokens??D?.total_tokens)>0).length,streak_days:gn({dailyRows:$,to:u.to})}),k("client"),T?P({heatmap:{...E,week_starts_on:r,active_days:$.filter(D=>Number(D?.billable_total_tokens??D?.total_tokens)>0).length,streak_days:gn({dailyRows:$,to:u.to})},daily:$,fetchedAt:new Date().toISOString()}):C()}catch(V){if(T){const $=L();if($?.heatmap)g($.heatmap),f($.daily||[]),k("cache"),x(null);else{const E=V;x(E?.message||String(E)),f([]),g(null),k("edge")}}else{const $=V;x($?.message||String($)),f([]),g(null),k("edge")}}finally{w(!1)}},[t,e,M,n,T,u.from,u.to,L,l,i,r,a,C,P]);return m.useEffect(()=>{if(!T)C(),f([]),x(null),g(null),k("edge");else{const V=L();V?.heatmap&&(g(V.heatmap),f(V.daily||[]),k("cache"))}I()},[t,M,L,I,n,T,C]),{range:u,daily:d,heatmap:h,source:M?"mock":p==="client"?"edge":p,loading:v,error:N,refresh:I}}function sl({baseUrl:e,accessToken:t,limit:n=3,from:a,to:r,source:s,timeZone:l,tzOffsetMinutes:i}={}){const[c,u]=m.useState([]),[d,f]=m.useState(!1),[h,g]=m.useState(null),p=m.useCallback(async()=>{f(!0),g(null);try{const k=await hi({baseUrl:e,accessToken:t,limit:n,from:a,to:r,source:s,timeZone:l,tzOffsetMinutes:i});u(Array.isArray(k?.entries)?k.entries:[])}catch(k){const v=k?.message||String(k);g(v),u([])}finally{f(!1)}},[t,e,a,n,s,l,r,i]);return m.useEffect(()=>{p()},[p]),{entries:c,loading:d,error:h,refresh:p}}const il=24;function Jr({baseUrl:e,accessToken:t,guestAllowed:n=!1,period:a,from:r,to:s,months:l=il,cacheKey:i,timeZone:c,tzOffsetMinutes:u,now:d,sharedRows:f,sharedRange:h}={}){const[g,p]=m.useState([]),[k,v]=m.useState(()=>({from:r,to:s})),[w,N]=m.useState("edge"),[x,M]=m.useState(null),[T,j]=m.useState(!1),[L,P]=m.useState(null),C=Yt(),I=!n&&!C,K=Array.isArray(f),V=h?.from||r,$=h?.to||s,E=m.useMemo(()=>a==="day"||a==="24h"?"hourly":a==="total"?"monthly":"daily",[a]),D=(()=>{if(!i)return null;const F=ll(e)||"default",z=an({timeZone:c,offsetMinutes:u});if(E==="hourly"){const Z=a==="24h"?`${r||""}.${s||""}`:s||r||"day";return`tokentracker.trend.${i}.${F}.hourly.${Z}.${z}`}if(E==="monthly")return`tokentracker.trend.${i}.${F}.monthly.${l}.${s||"today"}.${z}`;const B=`${r||""}.${s||""}`;return`tokentracker.trend.${i}.${F}.daily.${B}.${z}`})(),b=m.useCallback(()=>{if(!D||typeof window>"u")return null;try{const F=window.localStorage.getItem(D);if(!F)return null;const z=JSON.parse(F);return!z||!Array.isArray(z.rows)?null:z}catch{return null}},[D]),_=m.useCallback(F=>{if(!(!D||typeof window>"u"))try{window.localStorage.setItem(D,JSON.stringify(F))}catch{}},[D]),H=m.useCallback(()=>{if(!(!D||typeof window>"u"))try{window.localStorage.removeItem(D)}catch{}},[D]),S=m.useCallback(async()=>{if(K){p(Array.isArray(f)?f:[]),v({from:V,to:$}),N("shared"),M(null),j(!1),P(null);return}j(!0),P(null);try{let F;E==="hourly"?F=await cl({baseUrl:e,accessToken:t,from:r,to:s,period:a,timeZone:c,tzOffsetMinutes:u,now:d}):E==="monthly"?F=await gi({baseUrl:e,accessToken:t,months:l,to:s,timeZone:c,tzOffsetMinutes:u}):F=await Mn({baseUrl:e,accessToken:t,from:r,to:s,timeZone:c,tzOffsetMinutes:u});const z=F?.from||r||F?.day||null,B=F?.to||s||F?.day||null;let Z=Array.isArray(F?.data)?F.data:[];E==="daily"?Z=Fn(Z,z||r,B||s,{timeZone:c,offsetMinutes:u,now:d}):E==="hourly"?Z=bn(Z,z||r||F?.day,B||s,{period:a,timeZone:c,offsetMinutes:u,now:d}):E==="monthly"&&(Z=Rn(Z,{timeZone:c,offsetMinutes:u,now:d}));const xe=new Date().toISOString();p(Z),v({from:z,to:B}),N("edge"),M(xe),I?_({rows:Z,from:z,to:B,mode:E,fetchedAt:xe}):H()}catch(F){if(I){const z=b();if(z?.rows){let B=E==="daily"?Fn(z.rows||[],z.from||r,z.to||s,{timeZone:c,offsetMinutes:u,now:d}):E==="hourly"?bn(z.rows||[],z.from||r||z.day||s,z.to||s,{period:a,timeZone:c,offsetMinutes:u,now:d}):Array.isArray(z.rows)?z.rows:[];E==="monthly"&&(B=Rn(B,{timeZone:c,offsetMinutes:u,now:d})),p(B),v({from:z.from||r,to:z.to||s}),N("cache"),M(z.fetchedAt||null),P(null)}else{p([]),v({from:r,to:s}),N("edge"),M(null);const B=F;P(B?.message||String(B))}}else{p([]),v({from:r,to:s}),N("edge"),M(null);const z=F;P(z?.message||String(z))}}finally{j(!1)}},[t,e,r,C,n,I,E,l,a,b,K,V,f,$,c,s,u,d,H,_]);m.useEffect(()=>{if(K){p(Array.isArray(f)?f:[]),v({from:V,to:$}),N("shared"),M(null),j(!1),P(null);return}if(!I)H(),p([]),v({from:r,to:s}),P(null),N("edge"),M(null);else{const F=b();if(F?.rows){let z=E==="daily"?Fn(F.rows||[],F.from||r,F.to||s,{timeZone:c,offsetMinutes:u,now:d}):E==="hourly"?bn(F.rows||[],F.from||r||F.day||s,F.to||s,{period:a,timeZone:c,offsetMinutes:u,now:d}):Array.isArray(F.rows)?F.rows:[];E==="monthly"&&(z=Rn(z,{timeZone:c,offsetMinutes:u,now:d})),p(z),v({from:F.from||r,to:F.to||s}),N("cache"),M(F.fetchedAt||null)}}S()},[t,C,b,S,K,V,f,$,n,I,H,E,r,s,c,u,d,a]);const X=C?"mock":w;return{rows:g,from:k.from||r,to:k.to||s,source:X,fetchedAt:x,loading:T,error:L,refresh:S}}function ll(e){try{return new URL(e).host}catch{return null}}async function cl({baseUrl:e,accessToken:t,from:n,to:a,period:r,timeZone:s,tzOffsetMinutes:l,now:i}){const c=r==="24h"?Zr(n,a):[a||n].filter(Boolean),u=Array.from(new Set(c)),d=await Promise.all(u.map(p=>qr({accessToken:t,day:p,timeZone:s,tzOffsetMinutes:l}))),f=d.flatMap(p=>Array.isArray(p?.data)?p.data:[]),h=r==="24h"?u[0]||n||a:d[0]?.day||n||a,g=r==="24h"?u[u.length-1]||a||n:d[0]?.day||a||n;return{day:g,from:h,to:g,data:bn(f,h,g,{period:r,timeZone:s,offsetMinutes:l,now:i})}}function It(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const a=Number(n[0]),r=Number(n[1])-1,s=Number(n[2]);if(!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(s))return null;const l=new Date(Date.UTC(a,r,s));return Number.isFinite(l.getTime())&&mt(l)===t?l:null}function ua(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Zr(e,t){const n=It(e||t),a=It(t||e);if(!n||!a)return[e||t].filter(Boolean).map(String);if(a<n)return[mt(a),mt(n)];const r=[];for(let s=n;s<=a;s=ua(s,1))r.push(mt(s));return r}const eo=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens","conversation_count"];function Fn(e,t,n,{timeZone:a,offsetMinutes:r,now:s}={}){const l=It(t),i=It(n);if(!l||!i||i<l)return Array.isArray(e)?e:[];const c=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,u=Zt({timeZone:a,offsetMinutes:r,date:c}),d=It(u),f=d?d.getTime():c.getTime(),h=new Map;for(const p of e||[])p?.day&&h.set(p.day,p);const g=[];for(let p=l;p<=i;p=ua(p,1)){const k=mt(p),v=h.get(k),w=p.getTime()>f;if(v){g.push({...v,missing:!1,future:w});continue}g.push({day:k,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!w,future:w})}return g}function dl(e,t){const n=t?null:0;return{hour:e,total_tokens:n,billable_total_tokens:n,input_tokens:n,cached_input_tokens:n,cache_creation_input_tokens:n,output_tokens:n,reasoning_output_tokens:n,conversation_count:n,missing:!1,future:t}}function ul(e){if(!e||typeof e!="object")return!1;const t=e.models;return t&&typeof t=="object"&&Object.keys(t).length>0?!1:eo.every(n=>e[n]==null)}function fl(e,t,n){const a={...e,hour:t,missing:!1,future:n};if(!n&&ul(e))for(const r of eo)a[r]=0;return a}function ml(e,t){const n=t===30?48:24,a=[];for(let r=0;r<n;r++){const s=Math.floor(r*t/60),l=r*t%60;a.push(`${e}T${String(s).padStart(2,"0")}:${String(l).padStart(2,"0")}:00`)}return a}function hl(e,t,{timeZone:n,offsetMinutes:a}={}){const r=ml(e,t);if(!n||typeof Intl>"u"||!Intl.DateTimeFormat)return r;const s=It(e);if(!s)return r;const l=s.getUTCFullYear()*1e4+(s.getUTCMonth()+1)*100+s.getUTCDate(),i=s.getTime()-2160*60*1e3,c=ua(s,2).getTime()+2160*60*1e3,u=[],d=new Set;for(let f=i;f<=c;f+=1800*1e3){const h=on({timeZone:n,offsetMinutes:a,now:new Date(f)});if(!h||h.dayNum!==l||t===60&&h.minute!==0||t===30&&h.minute!==0&&h.minute!==30)continue;const g=`${e}T${String(h.hour).padStart(2,"0")}:${String(h.minute).padStart(2,"0")}:00`;d.has(g)||(d.add(g),u.push(g))}return u.length>0?u:r}function gl(e,t,{timeZone:n,offsetMinutes:a,now:r}={}){if(!t)return Array.isArray(e)?e:[];const s=t.trim().slice(0,10),l=on({timeZone:n,offsetMinutes:a,now:r}),i=l?l.dayNum:void 0;let c=!1;for(const g of e||[]){const p=g?.hour||g?.label||"",k=xn(p,i);if(k&&k.slot%2!==0){c=!0;break}}const u=c?30:60,d=new Map;for(const g of e||[]){const p=g?.hour||g?.label||"",k=xn(p,i);k&&d.set(k.slot,g)}const f=[],h=hl(s,u,{timeZone:n,offsetMinutes:a});for(let g=0;g<h.length;g++){const p=h[g],k=xn(p,i),v=k?k.slot:c?g:g*2,w=d.get(v);let N=!1;if(l){const x=l.year*1e4+l.month*100+l.day,M=k?.dayNum??Number(s.replace(/-/g,""));if(M>x)N=!0;else if(M===x){const T=l.hour*2+(l.minute>=30?1:0);N=v>T}}w?f.push(fl(w,p,N)):f.push(dl(p,N))}return f}function bn(e,t,n,{period:a,timeZone:r,offsetMinutes:s,now:l}={}){const i=a==="24h"?Zr(t,n):[n||t].filter(Boolean).map(String),u=Array.from(new Set(i)).flatMap(f=>gl(yl(e||[],f),f,{timeZone:r,offsetMinutes:s,now:l})),d=pl(u,{timeZone:r,offsetMinutes:s,now:l});return a!=="24h"?d:bl(d,{timeZone:r,offsetMinutes:s,now:l})}function yl(e,t){return e.filter(n=>{const a=n?.hour||n?.label||"",r=String(a).trim();return r.includes("T")?r.slice(0,10)===t:!0})}function pl(e,{timeZone:t,offsetMinutes:n,now:a}={}){if(!Array.isArray(e))return[];const r=on({timeZone:t,offsetMinutes:n,now:a});return r?e.map(s=>{const l=s?.hour||s?.label||"",i=xn(l,r.dayNum);if(!i)return{...s,future:!1};const c=i.dayNum!==null&&i.dayNum>r.dayNum||(i.dayNum===null||i.dayNum===r.dayNum)&&i.slot>r.slot;return{...s,future:!!c}}):e}function bl(e,{timeZone:t,offsetMinutes:n,now:a}={}){if(!Array.isArray(e))return[];const r=on({timeZone:t,offsetMinutes:n,now:a});if(!r)return e.filter(i=>!i?.future);const s=to({year:r.year,month:r.month,day:r.day,hour:r.hour,minute:r.minute}),l=s-1440*60*1e3;return e.filter(i=>{if(i?.future)return!1;const c=xl(i?.hour||i?.label);return c!=null&&c>=l&&c<=s})}function Rn(e,{timeZone:t,offsetMinutes:n,now:a}={}){if(!Array.isArray(e))return[];const r=on({timeZone:t,offsetMinutes:n,now:a});return r?e.map(s=>{const l=s?.month||s?.label||"",i=kl(l);if(!i)return{...s,future:!1};const c=i.year>r.year||i.year===r.year&&i.month>r.month;return{...s,future:c}}):e}function on({timeZone:e,offsetMinutes:t,now:n}={}){const a=n instanceof Date&&Number.isFinite(n.getTime())?n:new Date;if(e&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const h=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(a).reduce((N,x)=>(x.type&&x.value&&(N[x.type]=x.value),N),{}),g=Number(h.year),p=Number(h.month),k=Number(h.day),v=Number(h.hour),w=Number(h.minute);if(Number.isFinite(g)&&Number.isFinite(p)&&Number.isFinite(k)&&Number.isFinite(v)&&Number.isFinite(w)){const N=v*2+(w>=30?1:0);return{year:g,month:p,day:k,hour:v,minute:w,dayNum:g*1e4+p*100+k,slot:N}}}catch{}if(Number.isFinite(t)){const d=new Date(a.getTime()+t*60*1e3),f=d.getUTCFullYear(),h=d.getUTCMonth()+1,g=d.getUTCDate(),p=d.getUTCHours(),k=d.getUTCMinutes(),v=p*2+(k>=30?1:0);return{year:f,month:h,day:g,hour:p,minute:k,dayNum:f*1e4+h*100+g,slot:v}}const r=a.getFullYear(),s=a.getMonth()+1,l=a.getDate(),i=a.getHours(),c=a.getMinutes(),u=i*2+(c>=30?1:0);return{year:r,month:s,day:l,hour:i,minute:c,dayNum:r*1e4+s*100+l,slot:u}}function xn(e,t){if(!e)return null;const n=String(e).trim();if(n.includes("T")){const[a,r]=n.split("T");if(!a||!r)return null;const s=a.split("-");if(s.length!==3)return null;const l=Number(s[0]),i=Number(s[1]),c=Number(s[2]);if(!Number.isFinite(l)||!Number.isFinite(i)||!Number.isFinite(c))return null;const u=r.split(":"),d=Number(u[0]),f=Number(u[1]);if(!Number.isFinite(d)||d<0||d>23||!Number.isFinite(f)||f<0||f>59)return null;const h=d*2+(f>=30?1:0);return{dayNum:l*1e4+i*100+c,slot:h}}else{let a=NaN,r=0;if(/^\d{1,2}$/.test(n))a=Number(n);else if(/^\d{1,2}:\d{2}(:\d{2})?$/.test(n)){const l=n.split(":");a=Number(l[0]),r=Number(l[1])}if(!Number.isFinite(a)||a<0||a>23||!Number.isFinite(r)||r<0||r>59)return null;const s=a*2+(r>=30?1:0);return{dayNum:t||null,slot:s}}}function to({year:e,month:t,day:n,hour:a=0,minute:r=0}){return Date.UTC(Number(e),Number(t)-1,Number(n),Number(a),Number(r),0,0)}function xl(e){if(!e)return null;const t=String(e).trim();if(!t.includes("T"))return null;const[n,a]=t.split("T");if(!n||!a)return null;const r=n.split("-"),s=a.split(":");if(r.length!==3||s.length<2)return null;const[l,i,c]=r.map(Number),[u,d]=s.map(Number);return!Number.isFinite(l)||!Number.isFinite(i)||!Number.isFinite(c)||!Number.isFinite(u)||!Number.isFinite(d)?null:to({year:l,month:i,day:c,hour:u,minute:d})}function kl(e){if(!e)return null;const n=String(e).trim().split("-");if(n.length!==2)return null;const a=Number(n[0]),r=Number(n[1]);return!Number.isFinite(a)||!Number.isFinite(r)||r<1||r>12?null:{year:a,month:r}}function La({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:a,to:r,includeDaily:s=!0,cacheKey:l,timeZone:i,tzOffsetMinutes:c,now:u}={}){const[d,f]=m.useState([]),[h,g]=m.useState(null),[p,k]=m.useState(null),[v,w]=m.useState("edge"),[N,x]=m.useState(null),[M,T]=m.useState(!1),[j,L]=m.useState(null),P=Yt(),C=!n&&!P,I=(()=>{if(!l)return null;const b=wl(e)||"default",_=s?"daily":"summary",H=an({timeZone:i,offsetMinutes:c});return`tokentracker.usage.${l}.${b}.${a}.${r}.${_}.${H}`})(),K=m.useCallback(()=>{if(!I||typeof window>"u")return null;try{const b=window.localStorage.getItem(I);if(!b)return null;const _=JSON.parse(b);return!_||!_.summary?null:_}catch{return null}},[I]),V=m.useCallback(b=>{if(!(!I||typeof window>"u"))try{window.localStorage.setItem(I,JSON.stringify(b))}catch{}},[I]),$=m.useCallback(()=>{if(!(!I||typeof window>"u"))try{window.localStorage.removeItem(I)}catch{}},[I]),E=m.useCallback(async()=>{T(!0),L(null);try{let b=null,_=null;if(s){const[z,B]=await Promise.allSettled([Mn({baseUrl:e,accessToken:t,from:a,to:r,timeZone:i,tzOffsetMinutes:c}),En({baseUrl:e,accessToken:t,from:a,to:r,timeZone:i,tzOffsetMinutes:c,rolling:!0})]);if(z.status==="rejected")throw z.reason;b=z.value,_=B.status==="fulfilled"?B.value:null}else _=await En({baseUrl:e,accessToken:t,from:a,to:r,timeZone:i,tzOffsetMinutes:c,rolling:!0});let H=s&&Array.isArray(b?.data)?b.data:[];s&&(H=Ln(H,a,r,{timeZone:i,offsetMinutes:c,now:u}));let S=_?.totals||b?.summary?.totals||null,X=_?.rolling||b?.summary?.rolling||null;if(s&&!S&&!_)try{const z=await En({baseUrl:e,accessToken:t,from:a,to:r,timeZone:i,tzOffsetMinutes:c,rolling:!0});S=z?.totals||null,X=z?.rolling||X}catch{}const F=new Date().toISOString();f(H),g(S),k(X),w("edge"),x(F),S&&C?V({summary:S,rolling:X,daily:H,from:a,to:r,includeDaily:s,fetchedAt:F}):C||$()}catch(b){if(C){const _=K();if(_?.summary){g(_.summary),k(_.rolling||null);const H=Array.isArray(_.daily)?_.daily:[],S=s?Ln(H,_.from||a,_.to||r,{timeZone:i,offsetMinutes:c,now:u}):H;f(S),w("cache"),x(_.fetchedAt||null),L(null)}else{const H=b;L(H?.message||String(H)),f([]),g(null),k(null),w("edge"),x(null)}}else{const _=b;L(_?.message||String(_)),f([]),g(null),k(null),w("edge"),x(null)}}finally{T(!1)}},[t,e,a,s,P,n,C,u,K,i,r,c,$,V]);return m.useEffect(()=>{if(!C)$(),f([]),g(null),k(null),L(null),w("edge"),x(null);else{const b=K();if(b?.summary){g(b.summary),k(b.rolling||null);const _=Array.isArray(b.daily)?b.daily:[],H=s?Ln(_,b.from||a,b.to||r,{timeZone:i,offsetMinutes:c,now:u}):_;f(H),w("cache"),x(b.fetchedAt||null)}}E()},[t,P,K,E,n,C,$]),{daily:d,summary:h,rolling:p,source:P?"mock":v,fetchedAt:N,loading:M,error:j,refresh:E}}function wl(e){try{return new URL(e).host}catch{return null}}function In(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const a=Number(n[0]),r=Number(n[1])-1,s=Number(n[2]);if(!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(s))return null;const l=new Date(Date.UTC(a,r,s));return Number.isFinite(l.getTime())&&mt(l)===t?l:null}function vl(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Ln(e,t,n,{timeZone:a,offsetMinutes:r,now:s}={}){const l=In(t),i=In(n);if(!l||!i||i<l)return Array.isArray(e)?e:[];const c=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,u=Zt({timeZone:a,offsetMinutes:r,date:c}),d=In(u),f=d?d.getTime():c.getTime(),h=new Map;for(const p of e||[])p?.day&&h.set(p.day,p);const g=[];for(let p=l;p<=i;p=vl(p,1)){const k=mt(p),v=h.get(k),w=p.getTime()>f;if(v){g.push({...v,missing:!1,future:w});continue}g.push({day:k,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!w,future:w})}return g}function Nl({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:a,to:r,cacheKey:s,timeZone:l,tzOffsetMinutes:i}={}){const[c,u]=m.useState(null),[d,f]=m.useState("edge"),[h,g]=m.useState(!1),[p,k]=m.useState(null),v=Yt(),w=!n,N=m.useMemo(()=>{if(!s)return null;const P=_l(e)||"default",C=an({timeZone:l,offsetMinutes:i});return`tokentracker.modelBreakdown.${s}.${P}.${a}.${r}.${C}`},[e,s,a,l,r,i]),x=m.useCallback(()=>{if(!N||typeof window>"u")return null;try{const P=window.localStorage.getItem(N);if(!P)return null;const C=JSON.parse(P);return!C||!C.breakdown?null:C}catch{return null}},[N]),M=m.useCallback(P=>{if(!(!N||typeof window>"u"))try{window.localStorage.setItem(N,JSON.stringify(P))}catch{}},[N]),T=m.useCallback(()=>{if(!(!N||typeof window>"u"))try{window.localStorage.removeItem(N)}catch{}},[N]),j=m.useCallback(async()=>{g(!0),k(null);try{const P=await yi({baseUrl:e,accessToken:t,from:a,to:r,timeZone:l,tzOffsetMinutes:i});u(P||null),f("edge"),P&&w?M({breakdown:P,fetchedAt:new Date().toISOString()}):w||T()}catch(P){if(w){const C=x();if(C?.breakdown)u(C.breakdown),f("cache"),k(null);else{u(null),f("edge");const I=P;k(I?.message||String(I))}}else{u(null),f("edge");const C=P;k(C?.message||String(C))}}finally{g(!1)}},[t,e,a,v,n,w,x,l,r,i,T,M]);return m.useEffect(()=>{if(!w)T(),u(null),f("edge"),k(null);else{const P=x();P?.breakdown&&(u(P.breakdown),f("cache"))}j()},[t,v,x,j,n,w,T]),{breakdown:c,source:v?"mock":d,loading:h,error:p,refresh:j}}function _l(e){try{return new URL(e).host}catch{return null}}function Re(e){const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:0}function Ml(e){const t=String(e?.hour??""),n=t.indexOf("T");if(n<0)return null;const a=Number(t.slice(n+1,n+3));return Number.isFinite(a)?a:null}function Rt(e,t){let n=0,a=0;if(Array.isArray(e))for(const r of e){const s=Ml(r);s==null||s>t||(n+=Re(r.total_tokens),a+=Re(r.total_cost_usd))}return{tokens:n,cost:a}}function wn(...e){return e.reduce((t,n)=>({tokens:t.tokens+Re(n?.tokens),cost:t.cost+Re(n?.cost)}),{tokens:0,cost:0})}function Ya(e){if(!Array.isArray(e)||e.length===0)return null;const t=wn(...e);return{tokens:t.tokens/e.length,cost:t.cost/e.length}}function Yn(e){if(!e)return null;const t=Re(e.tokens);return t<=0?null:Re(e.cost)/(t/1e6)}function za(e,t){return e==null||t==null||!Number.isFinite(e)||!Number.isFinite(t)||t===0?null:(e-t)/t}function jl({current:e,prev:t=null,trailingAvg:n=null,trailingFull:a=null,period:r}){if(r==="total"||!e)return null;const s=(i,c)=>c==null||!(c>0)?null:i/c,l=(i,c,u,d)=>({value:i,deltaVsPrev:za(i,c),deltaVsAvg:n?za(i,u):null,progress:d});return{period:r,tokens:l(Re(e.tokens),t?Re(t.tokens):null,n?Re(n.tokens):null,a?s(Re(e.tokens),Re(a.tokens)):null),cost:l(Re(e.cost),t?Re(t.cost):null,n?Re(n.cost):null,a?s(Re(e.cost),Re(a.cost)):null),perMTok:l(Yn(e),Yn(t),Yn(n),null)}}const no=864e5;function na(e){const t=String(e).split("-").map(Number);return t.length!==3||t.some(n=>!Number.isFinite(n))?null:Date.UTC(t[0],t[1]-1,t[2])}function vn(e){const t=new Date(e),n=t.getUTCFullYear(),a=String(t.getUTCMonth()+1).padStart(2,"0"),r=String(t.getUTCDate()).padStart(2,"0");return`${n}-${a}-${r}`}function wt(e,t){const n=na(e);return n==null?null:vn(n+t*no)}function Sl(e,{timeZone:t,offsetMinutes:n}){const a=e instanceof Date?e:new Date(e);if(t&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const r=new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",hour12:!1});let s=Number(r.format(a).slice(0,2));if(s===24&&(s=0),Number.isFinite(s))return Math.min(23,Math.max(0,s))}catch{}return typeof n=="number"&&Number.isFinite(n)?new Date(a.getTime()+n*6e4).getUTCHours():a.getHours()}function Cl(e,{timeZone:t,offsetMinutes:n}){const a=e instanceof Date?e:new Date(e);if(t&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const s=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).format(a);if(/^\d{4}-\d{2}-\d{2}$/.test(s))return s}catch{}return typeof n=="number"&&Number.isFinite(n)?vn(a.getTime()+n*6e4):vn(a.getTime())}const Dl=e=>Number(e?.total_tokens??0)||0,Tl=e=>Number(e?.total_cost_usd??0)||0;function Ba(e,t,n){let a={tokens:0,cost:0};const r=t?na(t):null,s=n?na(n):null;if(r==null||s==null||r>s)return a;for(let l=r;l<=s;l+=no){const i=e.get(vn(l));i&&(a=wn(a,i))}return a}function Pl(e,t){if(!t||e==="total")return null;if(e==="day"||e==="24h"){const s=[];for(let l=1;l<=7;l++){const i=wt(t,-l);i&&s.push(i)}return{kind:"day",hourlyDays:[t,...s],dailyFrom:null,dailyTo:null,todayKey:t,prevKey:wt(t,-1),trailingKeys:s}}const n=e==="week"?6:e==="month"?29:null;if(n==null)return null;const a=n+1,r=wt(t,-a);return{kind:"window",hourlyDays:[t,r].filter(Boolean),dailyFrom:wt(t,-(a*2-1)),dailyTo:t,todayKey:t,curStartKey:wt(t,-n),prevBoundaryKey:r,prevStartKey:wt(t,-(a*2-1))}}function Ol(e,t){const n=new Map;return e.forEach((a,r)=>{n.set(a,Array.isArray(t[r]?.data)?t[r].data:[])}),n}function $l(e){const t=new Map;for(const n of Array.isArray(e?.data)?e.data:[])n?.day&&t.set(String(n.day),{tokens:Dl(n),cost:Tl(n)});return t}function Wl(e,t,n){return{current:Rt(t.get(e.todayKey),n),prev:e.prevKey?Rt(t.get(e.prevKey),n):null,trailingAvg:Ya(e.trailingKeys.map(a=>Rt(t.get(a),n))),trailingFull:Ya(e.trailingKeys.map(a=>Rt(t.get(a),23)))}}function El(e,t,n,a){const r=wn(Ba(n,e.curStartKey,wt(e.todayKey,-1)),Rt(t.get(e.todayKey),a)),s=wn(Ba(n,e.prevStartKey,e.prevBoundaryKey?wt(e.prevBoundaryKey,-1):null),e.prevBoundaryKey?Rt(t.get(e.prevBoundaryKey),a):{tokens:0,cost:0});return{current:r,prev:s,trailingAvg:null}}function Al(e){try{return new URL(e).host}catch{return null}}function Fl({baseUrl:e,accessToken:t,guestAllowed:n=!1,period:a,timeZone:r,tzOffsetMinutes:s,now:l,cacheKey:i}={}){const[c,u]=m.useState(null),[d,f]=m.useState(!1),[h,g]=m.useState(null),p=m.useRef(0),k=l instanceof Date?l:new Date(l||Date.now()),v=Cl(k,{timeZone:r,offsetMinutes:s}),w=Sl(k,{timeZone:r,offsetMinutes:s}),N=Yt(),x=!n&&!N,M=(()=>{if(!i)return null;const C=Al(e)||"default",I=an({timeZone:r,offsetMinutes:s});return`tokentracker.pulse.${i}.${C}.${a}.${v}.${I}`})(),T=m.useCallback(()=>{if(!M||typeof window>"u")return null;try{const C=window.localStorage.getItem(M);return C?JSON.parse(C):null}catch{return null}},[M]),j=m.useCallback(C=>{if(!(!M||typeof window>"u"))try{window.localStorage.setItem(M,JSON.stringify(C))}catch{}},[M]),L=m.useCallback(()=>{const C=T();return C&&C.cutoffHour===w?C:null},[T,w]),P=m.useCallback(async()=>{const C=Pl(a,v);if(!C){u(null),g(null);return}const I=++p.current;f(!0),g(null);try{const K=await Promise.all(C.hourlyDays.map(D=>qr({baseUrl:e,accessToken:t,day:D,timeZone:r,tzOffsetMinutes:s}))),V=Ol(C.hourlyDays,K);let $;if(C.kind==="day")$=Wl(C,V,w);else{const D=await Mn({baseUrl:e,accessToken:t,from:C.dailyFrom,to:C.dailyTo,timeZone:r,tzOffsetMinutes:s});$=El(C,V,$l(D),w)}const E=jl({...$,period:a});if(I!==p.current)return;u(E),x&&E&&j({pulse:E,todayKey:v,cutoffHour:w,fetchedAt:new Date().toISOString()})}catch(K){if(I!==p.current)return;const V=L();V?.pulse&&u(V.pulse),g(K?.message?String(K.message):"Failed to load pulse")}finally{I===p.current&&f(!1)}},[e,t,n,a,r,s,v,w,x,N,L,j]);return m.useEffect(()=>{if(a==="total"||a==="custom"){u(null);return}const C=L();C?.pulse&&u(C.pulse)},[M,a,w]),m.useEffect(()=>{P()},[P]),{pulse:c,loading:d,error:h,refresh:P}}const ao=new Set(["day","hour","month"]);function Rl(e){return ao.has(e)}function Ha(e){if(e==null)return null;const t=String(e).trim();if(!/^[0-9]+$/.test(t))return null;const n=t.replace(/^0+/,"");return n.length===0?"0":n}function Il(e,t){const n=Ha(e),a=Ha(t);if(n&&a)return n.length!==a.length?n.length<a.length?-1:1:n===a?0:n<a?-1:1;const r=Le(e),s=Le(t);return r==null&&s==null?0:r==null?1:s==null?-1:r===s?0:r<s?-1:1}function ro(e,t){const n=typeof e=="string"?e:String(e||""),a=typeof t=="string"?t:String(t||"");return n===a?0:n<a?-1:1}function Ll(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!n)return null;const a=Number(n[1]),r=Number(n[2]),s=Number(n[3]);if(!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(s))return null;const l=new Date(Date.UTC(a,r-1,s));return!Number.isFinite(l.getTime())||l.getUTCFullYear()!==a||l.getUTCMonth()+1!==r||l.getUTCDate()!==s?null:l.getTime()}function Yl(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})$/);if(!n)return null;const a=Number(n[1]),r=Number(n[2]);if(!Number.isFinite(a)||!Number.isFinite(r)||r<1||r>12)return null;const s=new Date(Date.UTC(a,r-1,1));return Number.isFinite(s.getTime())?s.getTime():null}function zl(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?Z?$/);if(!n)return null;const a=Number(n[1]),r=Number(n[2]),s=Number(n[3]),l=Number(n[4]),i=Number(n[5]),c=Number(n[6]||0);if(!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(s)||!Number.isFinite(l)||!Number.isFinite(i)||!Number.isFinite(c)||r<1||r>12||s<1||s>31||l<0||l>23||i<0||i>59||c<0||c>59)return null;const u=new Date(Date.UTC(a,r-1,s,l,i,c));return Number.isFinite(u.getTime())?u.getTime():null}function Bl(e,t,n){const a=n==="hour"?zl:n==="month"?Yl:Ll,r=a(e),s=a(t);return r!=null&&s!=null?r===s?0:r<s?-1:1:ro(e,t)}function oo(e,{key:t,dir:n}){const a=n==="asc"?1:-1,r=Array.isArray(e)?e:[],s=ao.has(t)?(i,c)=>Bl(i,c,t):t==="top_model"?ro:Il,l=i=>t==="total_tokens"&&i?.billable_total_tokens!=null?i.billable_total_tokens:i?.[t];return r.map((i,c)=>({row:i,index:c})).sort((i,c)=>{const u=l(i.row),d=l(c.row),f=u==null,h=d==null;if(f&&h)return i.index-c.index;if(f)return 1;if(h)return-1;const g=s(u,d);return g!==0?g*a:i.index-c.index}).map(i=>i.row)}function Hl(){return[{key:"day",label:y("daily.sort.date.label"),title:y("daily.sort.date.title")},{key:"total_tokens",label:y("daily.sort.total.label"),title:y("daily.sort.total.title")},{key:"input_tokens",label:y("daily.sort.input.label"),title:y("daily.sort.input.title")},{key:"output_tokens",label:y("daily.sort.output.label"),title:y("daily.sort.output.title")},{key:"cached_input_tokens",label:y("daily.sort.cached.label"),title:y("daily.sort.cached.title")},{key:"reasoning_output_tokens",label:y("daily.sort.reasoning.label"),title:y("daily.sort.reasoning.title")},{key:"conversation_count",label:y("daily.sort.conversations.label"),title:y("daily.sort.conversations.title")}]}function Ua(e){const t=Rl(e)?e:"day";return Hl().map((n,a)=>a===0?{...n,key:t}:n)}function Va(e,{key:t,dir:n}){return oo(e,{key:t,dir:n})}const Nn=12,Ul=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens"];function Vl(e){if(typeof e=="bigint")return e!==0n;if(typeof e=="number")return Number.isFinite(e)&&e!==0;if(e==null)return!1;const t=String(e).trim();if(!t||!/^-?\d+$/.test(t))return!1;const n=t.startsWith("-")?t.slice(1):t;return/[1-9]/.test(n)}function ql(e){return Ul.some(t=>Vl(e?.[t]))}function Xl(e){const t=Array.isArray(e)?e:[];if(!t.length)return[];const n=oo(t,{key:"month",dir:"asc"}),a=n.findIndex(r=>r?.month&&ql(r));return a===-1?t:n.slice(a)}function Kl(e,t,n=Nn){const a=Array.isArray(e)?e:[],r=Number.isFinite(n)&&n>0?n:Nn,l=(Number.isFinite(t)&&t>=0?Math.floor(t):0)*r;return a.slice(l,l+r)}function Gl(e){if(typeof e!="string")return null;const t=e.trim();return t?t.toLowerCase():null}function Ql(e){const t=Gl(e?.model_id);return t||null}function Jl(e,t){return e?.model?String(e.model):t}function Zl(e){const t=String(e||"").toLowerCase();return t.includes("free")||t.includes("hy3-preview")||/^glm-[\d.]+-flash(?![a-z])/.test(t)}function _n(e,t=0){const n=Le(e?.billable_total_tokens),a=Le(e?.total_tokens);return n!=null&&n>0?n:a!=null&&a>0?a:n??a??t}function so(e,{copyFn:t}={}){const n=typeof t=="function"?t:l=>l,r=(Array.isArray(e?.sources)?e.sources:[]).map(l=>{const i=_n(l?.totals),c=Le(l?.totals?.total_cost_usd)??0;return{source:l?.source,totalTokens:Number.isFinite(i)?i:0,totalCost:Number.isFinite(c)?c:0,models:Array.isArray(l?.models)?l.models:[]}}).filter(l=>l.totalTokens>0);if(!r.length)return[];const s=r.reduce((l,i)=>l+i.totalTokens,0);return typeof e?.pricing?.pricing_mode=="string"&&e.pricing.pricing_mode.toUpperCase(),r.slice().sort((l,i)=>i.totalTokens-l.totalTokens).map(l=>{const i=l.source?String(l.source).toUpperCase():n("shared.placeholder.short"),c=s>0?l.totalTokens/s*100:0,u=Number.isFinite(c)?c.toFixed(1):"0.0",d=l.models.map(g=>{const p=_n(g?.totals);if(!Number.isFinite(p)||p<=0)return null;const k=l.totalTokens>0?Math.round(p/l.totalTokens*1e3)/10:0,v=Jl(g,n("shared.placeholder.short")),w=Ql(g),N=Le(g?.totals?.total_cost_usd),x=N??(l.totalCost>0&&l.totalTokens>0?p/l.totalTokens*l.totalCost:null),M=p>0&&(x==null||x<=0)&&!Zl(v);return{id:w,name:v,share:k,usage:p,cost:x,pricingMissing:M}}).filter(Boolean),f=d.filter(g=>Number.isFinite(Number(g?.cost))&&Number(g.cost)>0).sort((g,p)=>Number(p.cost)-Number(g.cost))[0]||null,h=d.filter(g=>g?.pricingMissing);return{source:l.source,label:i,totalPercent:String(u),usd:l.totalCost,usage:l.totalTokens,topCostModel:f,missingPricingModels:h,models:d}})}function ec(e,{copyFn:t}={}){const a=so(e,{copyFn:typeof t=="function"?t:d=>d}),r=a.reduce((d,f)=>d+(Number(f?.usage)||0),0),s=a.reduce((d,f)=>d+(Number(f?.usd)||0),0),l=a.flatMap(d=>(d.models||[]).map(f=>({...f,source:d.label}))),i=l.filter(d=>Number.isFinite(Number(d?.cost))&&Number(d.cost)>0).sort((d,f)=>Number(f.cost)-Number(d.cost))[0]||null,c=l.filter(d=>Number.isFinite(Number(d?.usage))&&Number(d.usage)>0).sort((d,f)=>Number(f.usage)-Number(d.usage))[0]||null,u=l.filter(d=>d?.pricingMissing);return{totalTokens:r,totalCost:s,costPerMillionTokens:r>0?s/(r/1e6):null,topCostModel:i,topUsageModel:c,missingPricingModels:u}}function tc(e,t="—"){const n=Object.entries(e?.models||{});if(!n.length)return t;let a=null,r=-1;for(const[s,l]of n){const i=Number(l);!Number.isFinite(i)||i<=r||(a=s,r=i)}return a||t}function nc(e,{fallback:t="—"}={}){const n=(Array.isArray(e)?e:[]).map(s=>{const l=_n(s),i=Le(s?.total_cost_usd)??0,c=Number.isFinite(l)&&l>0?i/(l/1e6):null;return{...s,cost_per_million_tokens:c,top_model:tc(s,t)}}),a=n.reduce((s,l)=>{const i=Le(l?.cost_per_million_tokens);return i!=null&&i>0&&s.push(i),s},[]),r=a.length>0?a.reduce((s,l)=>s+l,0)/a.length:null;return n.map(s=>{const l=Le(s?.cost_per_million_tokens),i=l!=null&&r!=null&&r>0&&l>r*1.15;return{...s,cost_per_million_baseline:r,cost_per_million_status:i?"high":"normal"}})}const dt={emerald:{light:["#ebedf0","#a7f3d0","#6ee7b7","#34d399","#10b981"],dark:["#2d333b","#065f46","#059669","#10b981","#34d399"],gridColor:{light:"rgba(16, 185, 129, 0.12)",dark:"rgba(52, 211, 153, 0.08)"}},ocean:{light:["#f1f5f9","#93c5fd","#60a5fa","#3b82f6","#1d4ed8"],dark:["#1e293b","#1e3a8a","#2563eb","#3b82f6","#60a5fa"],gridColor:{light:"rgba(59, 130, 246, 0.12)",dark:"rgba(96, 165, 250, 0.08)"}},neon:{light:["#faf5ff","#ebd5ff","#c084fc","#a855f7","#7e22ce"],dark:["#2e1065","#581c87","#8b5cf6","#a855f7","#c084fc"],gridColor:{light:"rgba(168, 85, 247, 0.12)",dark:"rgba(192, 132, 252, 0.08)"}},amber:{light:["#fffbeb","#fde68a","#f59e0b","#d97706","#b45309"],dark:["#451a03","#78350f","#b45309","#d97706","#f59e0b"],gridColor:{light:"rgba(245, 158, 11, 0.12)",dark:"rgba(245, 158, 11, 0.08)"}}};function ac(e,t){const n=/^#([0-9a-f]{6})$/i.exec(e);if(!n)return e;const a=parseInt(n[1],16),r=a>>16&255,s=a>>8&255,l=a&255,i=c=>Math.max(0,Math.min(255,Math.round(c*t)));return`rgb(${i(r)}, ${i(s)}, ${i(l)})`}function nt(e,t,n,a,r){const s=Math.cos(a),l=Math.sin(a),i=e*s-t*l,c=e*l+t*s,u=n,d=Math.cos(r),f=Math.sin(r),h=i,g=c*d-u*f,p=c*f+u*d;return{x:h,y:g,z:p}}function rc(e,t,n,a,r){return nt(e,t,n,a,r)}function io(e,t){const n=Number(t).toLocaleString();if(e>=4){const a=Math.floor(Math.random()*3)+1;return y(`heatmap.3d.voxel.joke.${a}`,{value:n})}else return e===3?y("heatmap.3d.voxel.level3",{value:n}):e===2?y("heatmap.3d.voxel.level2",{value:n}):e===1?y("heatmap.3d.voxel.level1",{value:n}):y("heatmap.3d.voxel.level0")}function qa({weeks:e,palette:t="auto",isDark:n=!1,interactive:a=!1,autoRotateInit:r=!1,onResetViewRef:s=null}){const l=dt[t]||(t==="auto"?dt.emerald:null),i=l?n?l.dark:l.light:Array.isArray(t)?t:n?dt.emerald.dark:dt.emerald.light,c=l?n?l.gridColor.dark:l.gridColor.light:n?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)",u=-.2,d=.88,[f,h]=m.useState({yaw:u,pitch:d}),[g,p]=m.useState(r),[k,v]=m.useState(1),w=a?13:10.5,N=m.useMemo(()=>{const A=[],Y=e.length;if(Y===0||!a)return[];for(let U=0;U<=7;U++){const q=(U-3.5)*w,ne=nt(-Y/2*w,q,0,f.yaw,f.pitch),oe=nt(Y/2*w,q,0,f.yaw,f.pitch);A.push({d:`M${ne.x},${ne.y} L${oe.x},${oe.y}`,key:`horiz-${U}`})}for(let U=0;U<=Y;U+=4){const q=(U-Y/2)*w,ne=nt(q,-3.5*w,0,f.yaw,f.pitch),oe=nt(q,3.5*w,0,f.yaw,f.pitch);A.push({d:`M${ne.x},${ne.y} L${oe.x},${oe.y}`,key:`vert-${U}`})}if(Y%4!==0){const U=(Y-Y/2)*w,q=nt(U,-3.5*w,0,f.yaw,f.pitch),ne=nt(U,3.5*w,0,f.yaw,f.pitch);A.push({d:`M${q.x},${q.y} L${ne.x},${ne.y}`,key:"vert-last"})}return A},[e.length,f,w,a]);m.useEffect(()=>{s&&(s.current={reset:()=>{h({yaw:u,pitch:d}),p(!1),v(1),D()},toggleAutoRotate:A=>{p(A)}})},[s]);const x=m.useRef(null),M=m.useRef(null),T=m.useRef(!1),j=m.useRef({x:0,y:0}),L=m.useRef({yaw:u,pitch:d}),P=m.useRef({x:0,y:0}),C=m.useRef({x:0,y:0,time:0}),I=m.useRef(null),[K,V]=m.useState(0),$=m.useRef(null),E=m.useRef(!0);m.useEffect(()=>(E.current=!0,()=>{E.current=!1}),[]);const D=()=>{$.current&&cancelAnimationFrame($.current),V(0);const A=performance.now(),Y=1200,U=q=>{if(!E.current)return;const ne=q-A,oe=Math.min(1,ne/Y),ye=1-Math.pow(1-oe,3);V(ye),oe<1?$.current=requestAnimationFrame(U):$.current=null};$.current=requestAnimationFrame(U)};m.useEffect(()=>(D(),()=>{$.current&&cancelAnimationFrame($.current)}),[a]),m.useEffect(()=>{if(!g||T.current||typeof window>"u"||typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;let Y;const U=()=>{if(typeof document<"u"&&document.visibilityState==="hidden"){Y=requestAnimationFrame(U);return}h(q=>({yaw:q.yaw+.002,pitch:q.pitch})),Y=requestAnimationFrame(U)};return Y=requestAnimationFrame(U),()=>cancelAnimationFrame(Y)},[g]);const b=(A,Y)=>{a&&(T.current=!0,j.current={x:A,y:Y},L.current={yaw:f.yaw,pitch:f.pitch},P.current={x:0,y:0},C.current={x:A,y:Y,time:performance.now()},I.current&&cancelAnimationFrame(I.current))},_=(A,Y)=>{if(!T.current)return;const U=A-j.current.x,q=Y-j.current.y,ne=performance.now(),oe=ne-C.current.time;oe>0&&(P.current={x:(A-C.current.x)/oe,y:(Y-C.current.y)/oe}),C.current={x:A,y:Y,time:ne};const ye=.005,fe=L.current.yaw-U*ye,he=Math.PI/2.3,Pe=Math.max(-he,Math.min(he,L.current.pitch-q*ye));h({yaw:fe,pitch:Pe})},H=()=>{if(!T.current)return;T.current=!1;let A=-P.current.x*12,Y=-P.current.y*12;const U=.95,q=()=>{T.current||(A*=U,Y*=U,!(Math.abs(A)<.01&&Math.abs(Y)<.01)&&(h(ne=>{const oe=ne.yaw+A*.005,ye=Math.PI/2.3,fe=Math.max(-ye,Math.min(ye,ne.pitch+Y*.005));return{yaw:oe,pitch:fe}}),I.current=requestAnimationFrame(q)))};I.current=requestAnimationFrame(q)},[S,X]=m.useState(null),[F,z]=m.useState({x:0,y:0,shiftX:0}),B=m.useRef(null);m.useEffect(()=>()=>{B.current&&clearTimeout(B.current)},[]),m.useEffect(()=>{if(!a||!M.current)return;const A=U=>{U.preventDefault();const q=-U.deltaY*.0025;v(ne=>{const oe=ne+q;return Math.max(.5,Math.min(3,oe))})},Y=M.current;return Y.addEventListener("wheel",A,{passive:!1}),()=>{Y.removeEventListener("wheel",A)}},[a]);const Z=m.useMemo(()=>{const A=[];return e.forEach((Y,U)=>{(Array.isArray(Y)?Y:[]).forEach((q,ne)=>{q&&A.push({key:q.day||`${U}-${ne}`,col:U,row:ne,level:q.level||0,value:q.value||0,total_tokens:q.total_tokens||0,day:q.day,models:q.models||null})})}),A},[e]),je=w-(a?1.8:1.5),Me=a?38:28,Se=A=>Math.max(1.8,Number(A)/4*Me),J=m.useMemo(()=>{if(Z.length===0)return[];const A=e.length;return Z.map(Y=>{const U=Se(Y.level),q=Math.sqrt(Math.pow(Y.col-A/2,2)+Math.pow(Y.row-3.5,2)),ne=Math.sqrt(Math.pow(A/2,2)+Math.pow(3.5,2)),oe=q/ne*.4,ye=Math.min(1,Math.max(0,(K-oe)*(1/.6))),fe=U*ye,he=(Y.col-A/2)*w,Pe=(Y.row-3.5)*w,pe=je/2,Ee=[{x:he-pe,y:Pe-pe,z:0},{x:he+pe,y:Pe-pe,z:0},{x:he+pe,y:Pe+pe,z:0},{x:he-pe,y:Pe+pe,z:0},{x:he-pe,y:Pe-pe,z:fe},{x:he+pe,y:Pe-pe,z:fe},{x:he+pe,y:Pe+pe,z:fe},{x:he-pe,y:Pe+pe,z:fe}].map(re=>nt(re.x,re.y,re.z,f.yaw,f.pitch)),Be=nt(he,Pe,fe/2,f.yaw,f.pitch),Mt=[{name:"top",indices:[4,5,6,7],scale:1,normal:[0,0,1]},{name:"bottom",indices:[3,2,1,0],scale:.4,normal:[0,0,-1]},{name:"left",indices:[3,0,4,7],scale:.55,normal:[-1,0,0]},{name:"right",indices:[1,2,6,5],scale:.75,normal:[1,0,0]},{name:"front",indices:[0,1,5,4],scale:.85,normal:[0,-1,0]},{name:"back",indices:[2,3,7,6],scale:.65,normal:[0,1,0]}],gt=i[Math.min(4,Math.max(0,Number(Y.level)||0))],yt=[],tt=.35,pt=-.4,se=.83;return Mt.forEach(re=>{const ee=rc(re.normal[0],re.normal[1],re.normal[2],f.yaw,f.pitch);if(ee.z>.001){const ce=Ee[re.indices[0]],Ce=Ee[re.indices[1]],ie=Ee[re.indices[2]],ze=Ee[re.indices[3]],zt=`M${ce.x},${ce.y} L${Ce.x},${Ce.y} L${ie.x},${ie.y} L${ze.x},${ze.y} Z`,Bt=ee.x*tt+ee.y*pt+ee.z*se,jt=n?.18:0,bt=re.scale*(.82+.28*Math.max(0,Bt))+jt;yt.push({name:re.name,d:zt,fill:ac(gt,bt)})}}),{...Y,centerProj:Be,renderedFaces:yt}})},[Z,f,i,e.length,K,w,je,Me]),De=m.useMemo(()=>[...J].sort((A,Y)=>A.centerProj.z-Y.centerProj.z),[J]),le=m.useMemo(()=>{if(De.length===0)return{minX:-100,minY:-100,maxX:100,maxY:100};let A=1/0,Y=1/0,U=-1/0,q=-1/0;return De.forEach(ne=>{const oe=w*2,ye=ne.centerProj.x,fe=ne.centerProj.y;ye-oe<A&&(A=ye-oe),ye+oe>U&&(U=ye+oe),fe-oe<Y&&(Y=fe-oe),fe+oe>q&&(q=fe+oe)}),{minX:A,minY:Y,maxX:U,maxY:q}},[De,w]),de=12,W=le.maxX-le.minX+de*2,te=le.maxY-le.minY+de*2,ge=W/k,me=te/k,Ne=le.minX-de+(W-ge)/2,Fe=le.minY-de+(te-me)/2,Te=`${Ne} ${Fe} ${ge} ${me}`;return Z.length===0?o.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:y("heatmap.empty")}):o.jsxs("div",{ref:M,className:`relative select-none outline-none ${a?"cursor-grab active:cursor-grabbing w-full h-full flex items-center justify-center":"w-full overflow-hidden flex justify-center"}`,onMouseDown:A=>{if(!a)return;b(A.clientX,A.clientY);const Y=q=>_(q.clientX,q.clientY),U=()=>{H(),window.removeEventListener("mousemove",Y),window.removeEventListener("mouseup",U)};window.addEventListener("mousemove",Y),window.addEventListener("mouseup",U)},onTouchStart:A=>{!a||A.touches.length===0||b(A.touches[0].clientX,A.touches[0].clientY)},onTouchMove:A=>{!a||A.touches.length===0||_(A.touches[0].clientX,A.touches[0].clientY)},onTouchEnd:()=>{a&&H()},children:[o.jsxs("svg",{ref:x,viewBox:Te,width:a?"95%":"100%",height:a?"95%":"auto",role:"img","aria-label":y("heatmap.iso.aria")||"3D interactive activity heatmap",style:{display:"block",width:"100%",height:"auto",maxWidth:a?"none":`${W}px`,maxHeight:a?"78vh":"none"},className:"transition-transform duration-300 ease-out",children:[a&&N.map(A=>o.jsx("path",{d:A.d,fill:"none",stroke:c,strokeWidth:.25,strokeDasharray:"1.5 2.5",strokeLinecap:"round"},A.key)),De.map(A=>{const Y=S&&S.key===A.key;return o.jsxs("g",{onMouseEnter:U=>{if(B.current&&(clearTimeout(B.current),B.current=null),X(A),a&&x.current){const q=nt((A.col-e.length/2)*w,(A.row-3.5)*w,Se(A.level),f.yaw,f.pitch);let ne=0,oe=0;const ye=x.current;if(M.current&&typeof ye.createSVGPoint=="function"&&typeof ye.getScreenCTM=="function")try{const pe=ye.createSVGPoint();pe.x=q.x,pe.y=q.y;const We=ye.getScreenCTM();if(We){const Ee=pe.matrixTransform(We),Be=M.current.getBoundingClientRect();ne=Ee.x-Be.left,oe=Ee.y-Be.top}}catch{const We=ye.getBoundingClientRect(),Ee=le.maxX-le.minX+de*2,Be=le.maxY-le.minY+de*2;ne=(q.x-(le.minX-de))/Ee*We.width,oe=(q.y-(le.minY-de))/Be*We.height}else{const pe=ye.getBoundingClientRect(),We=le.maxX-le.minX+de*2,Ee=le.maxY-le.minY+de*2;ne=(q.x-(le.minX-de))/We*pe.width,oe=(q.y-(le.minY-de))/Ee*pe.height}const fe=140;let he=0;const Pe=M.current?M.current.getBoundingClientRect().width:ye.getBoundingClientRect().width;ne<fe?he=fe-ne:ne>Pe-fe&&(he=Pe-fe-ne),z({x:ne,y:oe,shiftX:he})}},onMouseLeave:()=>{B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{X(null)},150)},className:"transition-all duration-200",style:{filter:Y?"brightness(1.15) drop-shadow(0 4px 6px rgba(0,0,0,0.15))":"none",cursor:a?"pointer":"default"},children:[!a&&A.day&&o.jsx("title",{children:`${A.day}: ${Number(A.value).toLocaleString()} conversations`}),A.renderedFaces.map((U,q)=>o.jsx("path",{d:U.d,fill:U.fill,stroke:U.fill,strokeWidth:.25,strokeLinejoin:"round"},q))]},A.key)})]}),a&&S&&o.jsxs("div",{onMouseEnter:()=>{B.current&&(clearTimeout(B.current),B.current=null)},onMouseLeave:()=>{B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{X(null)},150)},className:"absolute z-[9999] w-0 h-0 transition-all duration-100 ease-out",style:{left:`${F.x}px`,top:`${F.y}px`},children:[o.jsxs("div",{className:"absolute left-0 bottom-[10px] backdrop-blur-md bg-white/90 dark:bg-oai-gray-900/90 border border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-xl rounded-xl p-3.5 max-w-[280px] min-w-[200px] flex flex-col gap-2 animate-in fade-in zoom-in-95 duration-100",style:{transform:`translateX(calc(-50% + ${F.shiftX}px))`},children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-oai-gray-100 dark:border-oai-gray-800/80 pb-1.5",children:[o.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400",children:S.day}),(()=>{const A=S.level===0?n?"#9ca3af":"#6b7280":i[S.level];return o.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:A+"22",color:A,border:`1px solid ${A}44`},children:["Level ",S.level]})})()]}),o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsxs("div",{className:"flex flex-col gap-0.5",children:[o.jsxs("div",{className:"flex items-baseline gap-1",children:[o.jsx("span",{className:"text-lg font-bold text-oai-gray-900 dark:text-white leading-none tabular-nums",children:Number(S.value??0).toLocaleString()}),o.jsx("span",{className:"text-[10px] text-oai-gray-400 uppercase tracking-wider font-semibold",children:"Conversations"})]}),o.jsxs("div",{className:"flex items-baseline gap-1",children:[o.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400 leading-none tabular-nums",children:Number(S.total_tokens??0).toLocaleString()}),o.jsx("span",{className:"text-[9px] text-oai-gray-400 uppercase tracking-wider",children:"tokens"})]})]}),S.models&&Object.keys(S.models).length>0?o.jsxs("div",{className:"mt-1.5 border-t border-oai-gray-100 dark:border-oai-gray-800/60 pt-2 flex flex-col gap-1.5",children:[o.jsx("div",{className:"text-[10px] font-semibold text-oai-gray-400 dark:text-oai-gray-500 uppercase tracking-wider",children:"Model Breakdown"}),o.jsx("div",{className:"flex flex-col gap-2 max-h-[150px] overflow-y-auto pr-1.5 scrollbar-thin",children:Object.entries(S.models).map(([A,Y])=>({name:A,val:Number(Y)})).sort((A,Y)=>Y.val-A.val).map(({name:A,val:Y})=>{const U=Number(S.total_tokens)||Object.values(S.models).reduce((ne,oe)=>ne+Number(oe||0),0)||1,q=Math.round(Y/U*100);return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center justify-between text-[11px] gap-3",children:[o.jsx("span",{className:"font-medium text-oai-gray-750 dark:text-oai-gray-200 truncate max-w-[120px]",title:A,children:A}),o.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[o.jsx("span",{className:"font-mono text-oai-gray-900 dark:text-oai-gray-100 font-semibold",children:Y.toLocaleString()}),o.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[q,"%"]})]})]}),o.jsx("div",{className:"w-full h-1 bg-oai-gray-100 dark:bg-oai-gray-800/85 rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${q}%`,backgroundColor:i[4],boxShadow:`0 0 4px ${i[4]}55`}})})]},A)})})]}):o.jsx("p",{className:"text-[11px] text-oai-gray-600 dark:text-oai-gray-300 leading-relaxed font-normal mt-1 border-t border-dashed border-oai-gray-100 dark:border-oai-gray-800/60 pt-1.5",children:io(S.level,S.value)})]})]}),o.jsx("div",{className:"absolute bottom-[6px] left-0 -translate-x-1/2 w-2.5 h-2.5 rotate-45 bg-white dark:bg-oai-gray-900 border-r border-b border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-sm",style:{marginBottom:"1px"}})]})]})}const oc=12,sc=3,ic=26,lc=["#ebedf0","#f7d08a","#f2b757","#eca02f","#d9861a"],cc=["#30363d","#7a4711","#bf7015","#eca02f","#f7c877"];function Xa(e){const t=Number(e);return Number.isFinite(t)?t<1e3?t.toLocaleString():Ae(t,{decimals:2}):"0"}function dc(e){if(typeof e!="string")return null;const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e.trim());if(!t)return null;const n=new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3])));return Number.isFinite(n.getTime())?n:null}function lo(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function uc(e,t){return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))/864e5)}function fc(e,t){const n=t==="mon"?1:0,a=e.getUTCDay();return lo(e,-((a-n+7)%7))}function mc(e,t,n,a){if(!e)return[];const r=dc(t)||new Date,s=[];for(let d=11;d>=0;d-=1)s.push(new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth()-d,1)));const l=fc(r,n),i=lo(l,-(e-1)*7),c=[],u=new Set;for(const d of s){const f=Math.floor(uc(i,d)/7);f<0||f>=e||u.has(f)||(u.add(f),c.push({label:a[d.getUTCMonth()],index:f}))}return c}function hc({heatmap:e,timeZoneLabel:t,timeZoneShortLabel:n,hideLegend:a=!1,embedded:r=!1}){const{resolvedTheme:s}=Lr(),{currency:l,rate:i}=_t(),c=s==="dark",u=c?cc:lc,d=m.useRef(null),f=m.useRef(null),[h,g]=m.useState(null),[p,k]=m.useState({x:0,y:0,shiftX:0}),v=m.useRef(null);m.useEffect(()=>()=>{v.current&&clearTimeout(v.current)},[]);const[w,N]=m.useState(!1),[x,M]=m.useState(!1),[T,j]=m.useState(!1),L=m.useRef(null),[P,C]=m.useState("amber"),I=[y("heatmap.month.jan"),y("heatmap.month.feb"),y("heatmap.month.mar"),y("heatmap.month.apr"),y("heatmap.month.may"),y("heatmap.month.jun"),y("heatmap.month.jul"),y("heatmap.month.aug"),y("heatmap.month.sep"),y("heatmap.month.oct"),y("heatmap.month.nov"),y("heatmap.month.dec")],K=(W,te)=>{if(!te||!te.day)return;v.current&&(clearTimeout(v.current),v.current=null),g(te);const ge=W.currentTarget.getBoundingClientRect(),me=typeof window<"u"?window.innerWidth:1024,Ne=ge.left+ge.width/2,Fe=ge.top,Te=140;let A=0;Ne<Te?A=Te-Ne:Ne>me-Te&&(A=me-Te-Ne),k({x:Ne,y:Fe,shiftX:A})},V=()=>{v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{g(null)},150)},$=()=>{M(!1),N(!0)},E=()=>{M(!0)},D=W=>{W.target===W.currentTarget&&x&&(N(!1),M(!1))};m.useEffect(()=>{if(!w||x)return;const W=te=>{te.key==="Escape"&&E()};return window.addEventListener("keydown",W),()=>{window.removeEventListener("keydown",W)}},[w,x]);const b=m.useMemo(()=>({emerald:{accentText:"text-emerald-500 dark:text-emerald-400",accentBg:"bg-emerald-500/10 dark:bg-emerald-400/10",accentBorder:"border-emerald-500/20 dark:border-emerald-400/15",hoverBorder:"hover:border-emerald-500/30 dark:hover:border-emerald-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(16,185,129,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(52,211,153,0.25)]",rawColor:"#10b981"},ocean:{accentText:"text-blue-500 dark:text-blue-400",accentBg:"bg-blue-500/10 dark:bg-blue-400/10",accentBorder:"border-blue-500/20 dark:border-blue-400/15",hoverBorder:"hover:border-blue-500/30 dark:hover:border-blue-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(59,130,246,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(96,165,250,0.25)]",rawColor:"#3b82f6"},neon:{accentText:"text-purple-500 dark:text-purple-400",accentBg:"bg-purple-500/10 dark:bg-purple-400/10",accentBorder:"border-purple-500/20 dark:border-purple-400/15",hoverBorder:"hover:border-purple-500/30 dark:hover:border-purple-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(168,85,247,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(192,132,252,0.25)]",rawColor:"#a855f7"},amber:{accentText:"text-amber-500 dark:text-amber-400",accentBg:"bg-amber-500/10 dark:bg-amber-400/10",accentBorder:"border-amber-500/20 dark:border-amber-400/15",hoverBorder:"hover:border-amber-500/30 dark:hover:border-amber-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(245,158,11,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(245,158,11,0.25)]",rawColor:"#f59e0b"}}),[]),_=b[P]||b.emerald,H=dt[P]?c?dt[P].dark:dt[P].light:c?dt.emerald.dark:dt.emerald.light,[S,X]=m.useState(()=>{if(r)return"2d";try{return window.localStorage?.getItem("tt:heatmap-view")==="3d"?"3d":"2d"}catch{return"2d"}});m.useEffect(()=>{if(!r)try{window.localStorage?.setItem("tt:heatmap-view",S)}catch{}},[S,r]),m.useEffect(()=>{if(S!=="2d")return;const W=d.current;W&&(W.scrollLeft=W.scrollWidth)},[e?.weeks,S]),m.useEffect(()=>{const W=d.current;if(!W)return;const te=()=>{v.current&&(clearTimeout(v.current),v.current=null),g(null)};return W.addEventListener("scroll",te),()=>W.removeEventListener("scroll",te)},[]);const F=e?.week_starts_on==="mon"?"mon":"sun",z=m.useMemo(()=>{const W=Array.isArray(e?.weeks)?e.weeks:[];if(!W.length)return{weeks:[]};const te=[];for(const ge of W)for(const me of Array.isArray(ge)?ge:[])me?.day&&te.push({day:me.day,conversation_count:me.conversation_count??0,total_tokens:me.total_tokens??0,billable_total_tokens:me.billable_total_tokens??me.total_tokens??0,models:me.models??null});return Gn({dailyRows:te,weeks:Math.max(52,W.length),to:e?.to,weekStartsOn:F})},[e?.to,e?.weeks,F]),B=z?.weeks||[],Z=m.useMemo(()=>{let W=0,te=0,ge={day:"无数据",value:0},me=0,Ne=0;const Fe=[];B.forEach(fe=>{(Array.isArray(fe)?fe:[]).forEach(he=>{he&&he.day&&Fe.push(he)})}),Fe.sort((fe,he)=>fe.day.localeCompare(he.day)),Fe.forEach(fe=>{const he=Number(fe.value)||0;W+=Number(fe.total_tokens)||0,he>0?(te++,me++,me>Ne&&(Ne=me)):me=0,he>ge.value&&(ge={day:fe.day,value:he})});const Te=Fe.length||365,A=(te/Te*100).toFixed(1);let Y="heatmap.3d.modal.ai.eval.default",U="heatmap.3d.modal.ai.title.default";W>=15e6?(U="heatmap.3d.modal.ai.title.peak",Y="heatmap.3d.modal.ai.eval.peak"):W>=5e6?(U="heatmap.3d.modal.ai.title.heavy",Y="heatmap.3d.modal.ai.eval.heavy"):W>=1e6?(U="heatmap.3d.modal.ai.title.core",Y="heatmap.3d.modal.ai.eval.core"):W>=2e4&&(U="heatmap.3d.modal.ai.title.steady",Y="heatmap.3d.modal.ai.eval.steady");const q=e?.total_cost_usd,ne=Number(q),ye=q!=null&&(typeof q!="string"||q.trim()!=="")&&Number.isFinite(ne)?ne:W/15e5;return{totalTokens:W,activeDays:te,activeRate:A,maxSingleDay:ge,maxStreak:Ne,aiEvaluationTitleKey:U,aiEvaluationKey:Y,totalCostUsd:ye}},[B,e?.total_cost_usd]),xe=m.useMemo(()=>et(Z.totalCostUsd,{currency:l,rate:i}),[Z.totalCostUsd,l,i]),je=F==="mon"?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(W=>y(`heatmap.day.${W.toLowerCase()}`)):["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(W=>y(`heatmap.day.${W.toLowerCase()}`)),Me=m.useMemo(()=>mc(B.length,z?.to,F,I),[z?.to,B.length,F,I]);if(!B.length)return o.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:y("heatmap.empty")});const Se=r?10:oc,J=r?2:sc,De=r?22:ic,le=De+B.length*Se+Math.max(0,B.length-1)*J,de=`${De}px repeat(${B.length}, ${Se}px)`;return o.jsxs("div",{ref:f,className:r?"relative":"relative rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5",children:[!r&&o.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[o.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:y("heatmap.title")}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{role:"tablist","aria-label":"Heatmap view",className:"flex rounded-md border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 text-[10px]",children:[o.jsx("button",{type:"button",role:"tab","aria-selected":S==="2d",onClick:()=>X("2d"),className:S==="2d"?"px-2 py-0.5 rounded bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-oai-white font-medium":"px-2 py-0.5 rounded text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200",children:y("heatmap.view.2d")}),o.jsx("button",{type:"button",role:"tab","aria-selected":S==="3d",onClick:()=>X("3d"),className:S==="3d"?"px-2 py-0.5 rounded bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-oai-white font-medium":"px-2 py-0.5 rounded text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200",children:y("heatmap.view.3d")})]}),o.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-450",children:n||y("heatmap.legend.utc")})]})]}),S==="3d"&&o.jsxs("div",{onClick:$,className:"cursor-pointer group relative overflow-hidden rounded-lg hover:border-oai-gray-350 dark:hover:border-oai-gray-700 border border-transparent transition-all",title:y("heatmap.3d.hover_tip"),children:[o.jsx(qa,{weeks:B,isDark:c,palette:P}),o.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-oai-gray-900/5 to-transparent pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity flex items-end justify-center pb-2",children:o.jsxs("span",{className:"text-[10px] bg-white/95 dark:bg-oai-gray-900/95 shadow border border-oai-gray-200/60 dark:border-oai-gray-800/80 px-2.5 py-1 rounded-full font-medium text-oai-gray-500 dark:text-oai-gray-400 flex items-center gap-1 transform translate-y-2 group-hover:translate-y-0 transition-transform duration-200",children:[o.jsx(Xr,{size:9}),y("heatmap.3d.hover_tip")]})})]}),S==="2d"&&o.jsx("div",{ref:d,className:"overflow-x-auto overflow-y-hidden heatmap-scroll-thin",children:o.jsxs("div",{style:{minWidth:le},children:[o.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:de,columnGap:J},children:[o.jsx("span",{}),Me.map(W=>o.jsx("span",{style:{gridColumnStart:W.index+2},className:"whitespace-nowrap",children:W.label},`${W.label}-${W.index}`))]}),o.jsxs("div",{className:"grid",style:{gridTemplateColumns:de,columnGap:J},children:[o.jsx("div",{className:"grid text-[10px] text-oai-gray-400 dark:text-oai-gray-400 sticky left-0 bg-white dark:bg-oai-gray-900 pr-2",style:{gridTemplateRows:`repeat(7, ${Se}px)`,rowGap:J},children:je.map(W=>o.jsx("span",{className:"leading-none",children:W},W))}),o.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${Se}px)`,gap:J},children:B.map((W,te)=>(Array.isArray(W)?W:[]).map((ge,me)=>{if(!ge)return null;const Ne=ge.day||`e-${te}-${me}`,Fe=Number(ge.level)||0,Te=u[Fe]||u[0];return o.jsx("span",{onMouseEnter:A=>K(A,ge),onMouseLeave:V,className:"rounded-[2px] transition-transform hover:scale-125 hover:z-10 cursor-pointer",style:{width:Se,height:Se,background:Te}},Ne)}))})]})]})}),!a&&o.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[o.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:y("heatmap.legend.less")}),o.jsx("div",{className:"flex gap-0.5",children:u.map((W,te)=>o.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:W}},te))}),o.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:y("heatmap.legend.more")})]}),w&&o.jsx("div",{onAnimationEnd:D,onClick:W=>{W.target===W.currentTarget&&E()},className:`fixed inset-0 z-50 flex items-center justify-center p-3 md:p-6 backdrop-blur-md bg-black/15 dark:bg-black/40 ${x?"animate-tt-fade-out":"animate-tt-fade-in"}`,children:o.jsxs("div",{className:`relative w-full max-w-6xl h-[88vh] backdrop-blur-2xl bg-white/90 dark:bg-oai-gray-900/90 border border-oai-gray-200/50 dark:border-white/10 shadow-2xl rounded-2xl flex flex-col md:flex-row overflow-hidden ${x?"animate-tt-modal-exit":"animate-tt-modal"}`,children:[o.jsx("button",{type:"button",onClick:E,className:"absolute top-4 right-4 z-50 p-2 rounded-full border border-oai-gray-200/60 dark:border-oai-gray-800/60 bg-white/50 dark:bg-oai-gray-900/50 text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white hover:rotate-90 hover:scale-105 active:scale-95 transition-all duration-300",children:o.jsx(sa,{size:16})}),o.jsxs("div",{className:"w-full md:w-[340px] border-b md:border-b-0 md:border-r border-zinc-200/50 dark:border-zinc-800/40 p-5 md:p-6 flex flex-col gap-6 overflow-y-auto backdrop-blur-md bg-zinc-50/50 dark:bg-zinc-950/50",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[o.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[o.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:_.rawColor}}),o.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5",style:{backgroundColor:_.rawColor}})]}),o.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono text-zinc-400 dark:text-zinc-500",children:"3D Insight"})]}),o.jsx("h4",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight leading-none mt-2 select-none",children:y("heatmap.3d.modal.title")}),o.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-400 dark:text-zinc-500 mt-2 font-normal select-none",children:y("heatmap.3d.modal.desc")})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-x-5 gap-y-5 border-y border-zinc-200/50 dark:border-zinc-800/50 py-5 select-none",children:[o.jsxs("div",{className:"flex flex-col gap-1 relative group cursor-help",children:[o.jsx("div",{className:"absolute left-0 bottom-full mb-2 pointer-events-none opacity-0 translate-y-1 group-hover:opacity-100 group-hover:translate-y-0 transition-all duration-200 z-50",children:o.jsxs("div",{className:"bg-white dark:bg-zinc-950 text-zinc-900 dark:text-zinc-50 text-[10px] font-semibold font-mono rounded-lg px-2.5 py-1.5 shadow-xl border border-zinc-200 dark:border-zinc-800/80 whitespace-nowrap flex flex-col",children:[o.jsx("span",{className:"text-[9px] text-zinc-400 dark:text-zinc-500",children:y("heatmap.3d.modal.stats.precision_total_tokens")}),o.jsxs("span",{className:"mt-0.5 font-bold text-zinc-900 dark:text-zinc-50",children:[Z.totalTokens.toLocaleString()," Tokens"]})]})}),o.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:y("heatmap.3d.modal.stats.total_tokens")}),o.jsxs("div",{className:"flex items-baseline gap-1.5",children:[o.jsx("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:Xa(Z.totalTokens)}),o.jsx("div",{className:"opacity-30 group-hover:opacity-60 transition-opacity",children:o.jsx("svg",{width:"24",height:"10",viewBox:"0 0 24 10",fill:"none",children:o.jsx("path",{d:"M1 9C3 7 5 7 7 4C9 1 11 0 13 2C15 4 17 0 23 0",stroke:_.rawColor,strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),o.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[o.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:y("heatmap.3d.modal.stats.estimated_cost")}),o.jsx("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:xe})]}),o.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[o.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:y("heatmap.3d.modal.stats.active_rate_days")}),o.jsxs("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[Z.activeRate,"% ",o.jsxs("span",{className:"text-[10px] font-bold text-zinc-400 dark:text-zinc-500 font-mono",children:["(",Z.activeDays,"D)"]})]})]}),o.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[o.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:y("heatmap.3d.modal.stats.max_streak")}),o.jsxs("span",{className:"text-xl font-black text-amber-500 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[Z.maxStreak," ",o.jsx("span",{className:"text-[10px] font-bold text-amber-500/80 font-mono",children:y("heatmap.3d.modal.stats.days_suffix")})]})]}),o.jsxs("div",{className:"flex flex-col gap-1 col-span-2 relative group cursor-help",children:[o.jsx("div",{className:"absolute left-0 bottom-full mb-2 pointer-events-none opacity-0 translate-y-1 group-hover:opacity-100 group-hover:translate-y-0 transition-all duration-200 z-50",children:o.jsxs("div",{className:"bg-white dark:bg-zinc-950 text-zinc-900 dark:text-zinc-50 text-[10px] font-semibold font-mono rounded-lg px-2.5 py-1.5 shadow-xl border border-zinc-200 dark:border-zinc-800/80 whitespace-nowrap flex flex-col",children:[o.jsx("span",{className:"text-[9px] text-zinc-400 dark:text-zinc-500",children:y("heatmap.3d.modal.stats.precision_peak_value")}),o.jsxs("span",{className:"mt-0.5 font-bold text-zinc-900 dark:text-zinc-50",children:[Z.maxSingleDay.value>0?Z.maxSingleDay.value.toLocaleString():y("heatmap.3d.modal.stats.no_data")," conversations"]}),o.jsx("span",{className:"text-[8px] text-zinc-400 dark:text-zinc-500 mt-0.5",children:Z.maxSingleDay.day!=="无数据"?Z.maxSingleDay.day:y("heatmap.3d.modal.stats.no_data")})]})}),o.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:y("heatmap.3d.modal.stats.peak_day")}),o.jsxs("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[Z.maxSingleDay.value>0?Xa(Z.maxSingleDay.value):y("heatmap.3d.modal.stats.no_data")," ",o.jsxs("span",{className:"text-[10px] font-bold text-zinc-400 dark:text-zinc-500 font-mono",children:["(",Z.maxSingleDay.day!=="无数据"?Z.maxSingleDay.day:y("heatmap.3d.modal.stats.no_data"),")"]})]})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5 py-1",children:[o.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[o.jsx(Kr,{size:11,style:{color:_.rawColor}}),o.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono",style:{color:_.rawColor},children:y(Z.aiEvaluationTitleKey)})]}),o.jsxs("div",{className:"pl-3.5 border-l-2 relative transition-all duration-300 group",style:{borderColor:_.rawColor},children:[o.jsx("div",{className:"absolute inset-y-0 left-0 w-[3px] blur-[2px] opacity-15 pointer-events-none rounded-full",style:{backgroundColor:_.rawColor}}),o.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-600 dark:text-zinc-400 font-normal",children:y(Z.aiEvaluationKey)})]})]}),o.jsx("div",{className:"mt-auto border-t border-zinc-200/50 dark:border-zinc-800/50 pt-4 select-none",children:o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:y("heatmap.3d.modal.legend.title")}),o.jsx("span",{className:"text-[10px] font-medium text-zinc-500 dark:text-zinc-400",children:y(`heatmap.3d.modal.palette.${P}`)})]}),o.jsx("div",{className:"flex gap-1",children:H.map((W,te)=>o.jsx("div",{className:"flex-1 h-1 rounded-[2px]",style:{backgroundColor:W},title:`Level ${te}`},te))})]})})]}),o.jsxs("div",{className:"flex-1 h-full relative flex items-center justify-center overflow-hidden p-4",children:[o.jsx("div",{className:"absolute top-1/4 left-1/3 w-96 h-96 rounded-full blur-[130px] pointer-events-none -translate-x-1/2 -translate-y-1/2 transition-all duration-500",style:{backgroundColor:_.rawColor+"15"}}),o.jsx("div",{className:"absolute bottom-1/4 right-1/3 w-80 h-80 rounded-full blur-[120px] pointer-events-none translate-x-1/2 translate-y-1/2 bg-purple-500/[0.04] dark:bg-purple-500/[0.08]"}),o.jsxs("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 flex items-center gap-3 p-1.5 backdrop-blur-md bg-white/70 dark:bg-oai-gray-900/75 border border-oai-gray-200/60 dark:border-oai-gray-800/80 rounded-full shadow-lg z-30 select-none",children:[o.jsx("div",{className:"flex items-center gap-1.5 px-2",children:Object.keys(b).map(W=>{const te=P===W;return o.jsx("button",{type:"button",onClick:()=>C(W),title:y(`heatmap.3d.modal.palette.${W}`),className:`w-3.5 h-3.5 rounded-full transition-all duration-200 relative hover:scale-125 ${W==="emerald"?"bg-[#10b981]":W==="ocean"?"bg-[#3b82f6]":W==="neon"?"bg-[#a855f7]":"bg-[#f59e0b]"}`,children:te&&o.jsx("span",{className:"absolute inset-0 rounded-full ring-2 ring-offset-1 ring-offset-white dark:ring-offset-oai-gray-900 ring-oai-gray-900 dark:ring-white scale-110"})},W)})}),o.jsx("div",{className:"w-[1px] h-4 bg-oai-gray-200 dark:bg-oai-gray-800"}),o.jsxs("div",{className:"flex items-center gap-1 pr-1",children:[o.jsx("button",{type:"button",onClick:()=>{const W=!T;j(W),L.current&&L.current.toggleAutoRotate(W)},title:T?y("heatmap.3d.modal.control.pause"):y("heatmap.3d.modal.control.play"),className:`p-1.5 rounded-full transition-all duration-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 ${T?_.accentText:"text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-250"}`,children:T?o.jsx(Pi,{size:12}):o.jsx($i,{size:12})}),o.jsx("button",{type:"button",onClick:()=>{j(!1),L.current&&L.current.reset()},title:y("heatmap.3d.modal.control.reset"),className:"p-1.5 rounded-full text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-250 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-all duration-200",children:o.jsx(Ei,{size:12})})]})]}),o.jsx(qa,{weeks:B,isDark:c,interactive:!0,palette:P,autoRotateInit:T,onResetViewRef:L}),o.jsxs("div",{className:"absolute bottom-4 right-4 flex items-center gap-1.5 text-[9px] font-bold text-oai-gray-400 bg-white/80 dark:bg-oai-gray-900/80 border border-oai-gray-200/50 dark:border-oai-gray-800/80 rounded-md px-2.5 py-1.5 select-none pointer-events-none backdrop-blur-md shadow-sm",children:[o.jsx(ca,{size:10,className:_.accentText}),o.jsx("span",{children:y("heatmap.3d.modal.footer.tip")})]})]})]})}),h&&!w&&typeof document<"u"&&ni.createPortal(o.jsxs("div",{className:"fixed z-[9999] w-0 h-0 transition-all duration-100 ease-out pointer-events-none",style:{left:`${p.x}px`,top:`${p.y}px`},children:[o.jsxs("div",{className:"absolute left-0 bottom-[10px] backdrop-blur-md bg-white/95 dark:bg-oai-gray-900/95 border border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-xl rounded-xl p-3.5 max-w-[280px] min-w-[200px] flex flex-col gap-2 animate-in fade-in zoom-in-95 duration-100",style:{transform:`translateX(calc(-50% + ${p.shiftX}px))`},children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-oai-gray-100 dark:border-oai-gray-800/80 pb-1.5",children:[o.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400",children:h.day}),(()=>{const W=h.level===0?c?"#9ca3af":"#6b7280":u[h.level];return o.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:W+"22",color:W,border:`1px solid ${W}44`},children:["Level ",h.level]})})()]}),o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsxs("div",{className:"flex flex-col gap-0.5",children:[o.jsxs("div",{className:"flex items-baseline gap-1",children:[o.jsx("span",{className:"text-lg font-bold text-oai-gray-900 dark:text-white leading-none tabular-nums",children:Number(h.value??0).toLocaleString()}),o.jsx("span",{className:"text-[10px] text-oai-gray-400 uppercase tracking-wider font-semibold",children:"Conversations"})]}),o.jsxs("div",{className:"flex items-baseline gap-1",children:[o.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400 leading-none tabular-nums",children:Number(h.total_tokens??0).toLocaleString()}),o.jsx("span",{className:"text-[9px] text-oai-gray-400 uppercase tracking-wider",children:"tokens"})]})]}),h.models&&Object.keys(h.models).length>0?o.jsxs("div",{className:"mt-1.5 border-t border-oai-gray-100 dark:border-oai-gray-800/60 pt-2 flex flex-col gap-1.5",children:[o.jsx("div",{className:"text-[10px] font-semibold text-oai-gray-400 dark:text-oai-gray-500 uppercase tracking-wider",children:"Model Breakdown"}),o.jsx("div",{className:"flex flex-col gap-2 max-h-[150px] overflow-y-auto pr-1.5 oai-scrollbar",children:Object.entries(h.models).map(([W,te])=>({name:W,val:Number(te)})).sort((W,te)=>te.val-W.val).map(({name:W,val:te})=>{const ge=Number(h.total_tokens??h.value)||1,me=Math.round(te/ge*100);return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center justify-between text-[11px] gap-3",children:[o.jsx("span",{className:"font-medium text-oai-gray-750 dark:text-oai-gray-200 truncate max-w-[120px]",title:W,children:W}),o.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[o.jsx("span",{className:"font-mono text-oai-gray-900 dark:text-oai-gray-100 font-semibold",children:te.toLocaleString()}),o.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[me,"%"]})]})]}),o.jsx("div",{className:"w-full h-1 bg-oai-gray-100 dark:bg-oai-gray-800/85 rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${me}%`,backgroundColor:u[4],boxShadow:`0 0 4px ${u[4]}55`}})})]},W)})})]}):o.jsx("p",{className:"text-[11px] text-oai-gray-600 dark:text-oai-gray-300 leading-relaxed font-normal mt-1 border-t border-dashed border-oai-gray-100 dark:border-oai-gray-800/60 pt-1.5",children:io(h.level,h.total_tokens??h.value)})]})]}),o.jsx("div",{className:"absolute bottom-[6px] left-0 -translate-x-1/2 w-2.5 h-2.5 rotate-45 bg-white dark:bg-oai-gray-900 border-r border-b border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-sm",style:{marginBottom:"1px"}})]}),document.body),o.jsx("style",{children:`
|
|
1
|
+
import{c as an,i as qs,f as Ar,a as Fr,J as Xs,u as Rr,m as Ks,r as m,M as Ir,b as Gs,d as Qs,e as Wn,j as o,L as Js,g as Zs,h as ei,k as ti,l as ni,n as Lt,o as ht,p as y,q as Lr,X as sa,s as ai,R,t as ia,C as Yr,P as la,B as Kn,v as zr,w as Br,A as Hr,x as Xe,y as ri,z as oi,D as si,E as ii,F as li}from"./main-Ck4SUH4m.js";import{g as ci,i as Yt,b as Gn,c as gn,a as rn,d as en,f as mt,e as Ur,h as Vr,j as di,k as ui,l as fi,m as mi}from"./mock-data-Bvbe8tYK.js";import{g as hi,a as Mn,b as gi,c as yi,d as qr,e as En,f as pi,h as bi,L as xi,i as ki,u as wi,t as Fa}from"./limitDisplay-WwuTdS_a.js";import{u as vi}from"./use-limits-display-prefs-BKWYPgeA.js";import{u as Nt,I as ca}from"./useCurrency-BX3pvyhh.js";import{t as Le,f as et,a as Ae,b as Qe}from"./format-BuQKK6kQ.js";import{u as Ni,D as _i,a as Mi,b as ji,c as Si,d as Ci,e as Di,P as Qn,f as Jn,g as Zn,h as ea,i as ta,L as Ti}from"./PopoverPopup-7HrUzeRx.js";import{C as on}from"./Card-JS4gjUZf.js";import{S as Pi}from"./Select-9XDsaO_C.js";import{F as bt}from"./FadeIn-DvLfvwys.js";import"./SelectItemText-DE5Fs9p6.js";const Oi=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Xr=an("maximize-2",Oi);const $i=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],Wi=an("pause",$i);const Ei=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Ai=an("play",Ei);const Fi=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Ri=an("rotate-ccw",Fi);const Ii=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Kr=an("terminal",Ii);function Li(...e){const t=!Array.isArray(e[0]),n=t?0:-1,a=e[0+n],r=e[1+n],s=e[2+n],l=e[3+n],i=qs(r,s,l);return t?i(a):i}function Yi(e,t,n={}){const a=e.get();let r=null,s=a,l;const i=typeof a=="string"?a.replace(/[\d.-]/g,""):void 0,c=()=>{r&&(r.stop(),r=null),e.animation=void 0},d=()=>{const u=Ra(e.get()),h=Ra(s);if(u===h){c();return}const g=r?r.getGeneratorVelocity():e.getVelocity();c(),r=new Xs({keyframes:[u,h],velocity:g,type:"spring",restDelta:.001,restSpeed:.01,...n,onUpdate:l})},f=()=>{d(),e.animation=r??void 0,e.events.animationStart?.notify(),r?.then(()=>{e.animation=void 0,e.events.animationComplete?.notify()})};if(e.attach((u,h)=>{s=u,l=g=>h(An(g,i)),Ar.postRender(f)},c),Fr(t)){let u=n.skipInitialAnimation===!0;const h=t.on("change",p=>{u?(u=!1,e.jump(An(p,i),!1)):e.set(An(p,i))}),g=e.on("destroy",h);return()=>{h(),g()}}return c}function An(e,t){return t?e+t:e}function Ra(e){return typeof e=="number"?e:parseFloat(e)}function da(e){const t=Rr(()=>Ks(e)),{isStatic:n}=m.useContext(Ir);if(n){const[,a]=m.useState(e);m.useEffect(()=>t.on("change",a),[])}return t}function Gr(e,t){const n=da(t()),a=()=>n.set(t());return a(),Gs(()=>{const r=()=>Ar.preRender(a,!1,!0),s=e.map(l=>l.on("change",r));return()=>{s.forEach(l=>l()),Qs(a)}}),n}function zi(e){Wn.current=[],e();const t=Gr(Wn.current,e);return Wn.current=void 0,t}function Qr(e,t,n,a){if(typeof e=="function")return zi(e);const s=typeof t=="function"?t:Li(t,n,a),l=Array.isArray(e)?Ia(e,s):Ia([e],([c])=>s(c)),i=Array.isArray(e)?void 0:e.accelerate;return i&&!i.isTransformed&&typeof t!="function"&&Array.isArray(n)&&a?.clamp!==!1&&(l.accelerate={...i,times:t,keyframes:n,isTransformed:!0}),l}function Ia(e,t){const n=Rr(()=>[]);return Gr(e,()=>{n.length=0;const a=e.length;for(let r=0;r<a;r++)n[r]=e[r].get();return t(n)})}function Bi(e,t={}){const{isStatic:n}=m.useContext(Ir),a=()=>Fr(e)?e.get():e;if(n)return Qr(a);const r=da(a());return m.useInsertionEffect(()=>Yi(r,e,t),[r,JSON.stringify(t)]),r}function Hi(e,t={}){return Bi(e,{type:"spring",...t})}function Ui(){return o.jsxs(Js,{to:"/landing",className:"flex items-center gap-2.5 no-underline hover:opacity-80 transition-opacity",children:[o.jsx("img",{src:"/app-icon.png",alt:"Token Tracker",width:28,height:28,className:"rounded-md"}),o.jsx("span",{className:"text-base font-semibold text-oai-black dark:text-oai-white leading-tight",children:"Token Tracker"})]})}function Vi({children:e,header:t,footer:n,className:a="",hideHeader:r=!1,hideFooter:s=!1,bare:l=!1}){return l?o.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${a}`,children:[o.jsx("main",{className:"flex-1 px-6 py-6",children:e}),!s&&n&&o.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})]}):o.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 ${a}`,children:[!r&&o.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:[o.jsx(Ui,{}),o.jsx("div",{className:"flex-1 flex justify-center",children:t})]}),o.jsx("main",{className:"flex-1 px-6 py-6",children:e}),!s&&n&&o.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 qi({children:e,variant:t="info",size:n="md",className:a=""}){const r="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"},l={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm"},i=`${r} ${s[t]} ${l[n]} ${a}`.trim();return o.jsx("span",{className:i,children:e})}const Xi=m.forwardRef(function(t,n){const{render:a,className:r,disabled:s=!1,nativeButton:l=!0,...i}=t,{store:c}=Ni(),d=c.useState("open");function f(p){d&&c.setOpen(!1,ti(ni,p.nativeEvent))}const{getButtonProps:u,buttonRef:h}=Zs({disabled:s,native:l}),g=m.useMemo(()=>({disabled:s}),[s]);return ei("button",t,{state:g,ref:[n,h],props:[{onClick:f},i,u]})});var Ki={};function Gi(e,t){return e==="."?{width:"0.34ch",justifyContent:"center",marginInline:"-0.04ch"}:e===","?{width:"0.08ch",justifyContent:"center",marginInline:"-0.30ch"}:{width:"0.72ch",justifyContent:"flex-start",paddingLeft:"0.04ch",height:t}}function Qi({mv:e,digit:t,height:n}){const a=Qr(e,r=>{const s=(r%10+10)%10,l=(10+t-s)%10;let i=l*n;return l>5&&(i-=10*n),i});return o.jsx(ht.span,{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",y:a},children:t})}function Ji(e){const t=Math.round(e),n=1e-9*Math.max(1,Math.abs(e));return Math.abs(e-t)<n?t:e}function Zi(e,t){const n=e/t;return Math.floor(Ji(n))}function el(e){const t=String(e??""),n=Array.from(t),a=n.indexOf(".");let r=n.filter((i,c)=>/\d/.test(i)&&(a===-1||c<a)).length,s=0,l=!1;return n.map(i=>{if(!/\d/.test(i))return i==="."&&(l=!0),i;if(!l){const c=10**Math.max(r-1,0);return r-=1,c}return s+=1,10**-s})}function tl({place:e,value:t,height:n,digitStyle:a,shouldReduceMotion:r,isLed:s}){if(typeof e!="number"){const d=Gi(e,n);return o.jsx("span",{"data-counter-token":"static",className:`relative inline-flex items-center justify-center${s?" tt-lcd-sep":""}`,style:{height:n,...d,...a},children:e})}const l=Zi(t,e),i=da(0),c=Hi(i,{stiffness:220,damping:26,mass:.8});return m.useEffect(()=>{i.set(l)},[i,l]),r?o.jsx("span",{"data-counter-token":"digit",className:`relative inline-flex items-center justify-center overflow-hidden${s?" tt-lcd-cell":""}`,style:{height:n,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...a},children:Math.abs(l)%10}):o.jsx("span",{"data-counter-token":"digit",className:`relative inline-flex overflow-hidden${s?" tt-lcd-cell":""}`,style:{height:n,position:"relative",width:"0.9ch",fontVariantNumeric:"tabular-nums",...a},children:Array.from({length:10},(d,f)=>o.jsx(Qi,{mv:c,digit:f,height:n},f))})}function nl({value:e,displayValue:t,fontSize:n=72,padding:a=0,places:r,gap:s=6,borderRadius:l=4,horizontalPadding:i=0,textColor:c="inherit",fontWeight:d="inherit",containerStyle:f,counterStyle:u,digitStyle:h,gradientHeight:g=14,gradientFrom:p="rgba(255,255,255,0.95)",gradientTo:x="rgba(255,255,255,0)",topGradientStyle:v,bottomGradientStyle:w,variant:_="default"}){const k=_==="led",N=String(t??e??""),D=m.useMemo(()=>Array.isArray(r)&&r.length?r:el(N),[r,N]),j=typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent||"")||typeof process<"u"&&Ki?.VITEST==="true",L=Lt()||j,P=Number.isFinite(Number(e))?Math.abs(Number(e)):0,C=n+a;return L?o.jsx("span",{"data-counter-root":"true",className:k?"tt-lcd":void 0,style:{display:"inline-flex",alignItems:"center",color:c,fontSize:n,fontWeight:d,lineHeight:1,...f,...u},children:k?o.jsx("span",{className:"tt-lcd-cell tt-lcd-cell--static",children:N}):N}):o.jsxs("span",{"data-counter-root":"true",style:{position:"relative",display:"inline-block",...f},children:[o.jsx("span",{className:k?"tt-lcd":void 0,style:{fontSize:n,...k?null:{display:"flex",gap:s,borderRadius:l,paddingLeft:i,paddingRight:i,color:c},overflow:"hidden",lineHeight:1,fontWeight:d,...u},children:D.map((I,K)=>o.jsx(tl,{place:I,value:P,height:C,digitStyle:h,shouldReduceMotion:L,isLed:k},`${String(I)}-${K}`))}),o.jsxs("span",{style:{pointerEvents:"none",position:"absolute",inset:0,display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[o.jsx("span",{style:v??{height:g,background:`linear-gradient(to bottom, ${p}, ${x})`}}),o.jsx("span",{style:w??{height:g,background:`linear-gradient(to top, ${p}, ${x})`}})]})]})}var al={};const rl=new Set([",","."," "]),ol=typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent||"")||typeof process<"u"&&al?.VITEST==="true";function sl({char:e,reduceMotion:t,index:n}){const[a,r]=m.useState(t?e:""),[s,l]=m.useState(!1),i=m.useRef(e),c=m.useRef(!1);return m.useEffect(()=>{if(!c.current){if(c.current=!0,i.current=e,t){r(e);return}const u=Math.min(n*45,520),h=setTimeout(()=>l(!0),u),g=setTimeout(()=>r(e),u+130),p=setTimeout(()=>l(!1),u+300);return()=>{clearTimeout(h),clearTimeout(g),clearTimeout(p)}}if(e===i.current)return;if(i.current=e,t){r(e);return}l(!0);const d=setTimeout(()=>r(e),130),f=setTimeout(()=>l(!1),300);return()=>{clearTimeout(d),clearTimeout(f)}},[e,t,n]),o.jsx("span",{className:`tt-flap${s?" tt-flap--flip":""}`,"aria-hidden":"true",children:o.jsx("span",{className:"tt-flap__glyph",children:a})})}function il({value:e,fontSize:t=56,className:n=""}){const a=Lt()||ol,r=String(e??""),s=Array.from(r);return o.jsx("span",{className:`tt-flaprow ${n}`,style:{fontSize:`clamp(30px, 9cqi, ${t}px)`},role:"text","aria-label":r,children:s.map((l,i)=>rl.has(l)?o.jsx("span",{className:"tt-flap-sep","aria-hidden":"true",children:l},i):o.jsx(sl,{char:l,reduceMotion:a,index:i},i))})}function ll({baseUrl:e,accessToken:t,guestAllowed:n=!1,weeks:a=52,weekStartsOn:r="sun",cacheKey:s,timeZone:l,tzOffsetMinutes:i,now:c}={}){const d=m.useMemo(()=>ci({weeks:a,weekStartsOn:r,now:c}),[c,a,r]),[f,u]=m.useState([]),[h,g]=m.useState(null),[p,x]=m.useState("edge"),[v,w]=m.useState(!1),[_,k]=m.useState(null),N=Yt(),D=!n,j=m.useMemo(()=>{if(!s)return null;const V=rn({timeZone:l,offsetMinutes:i});return`tokentracker.heatmap.${s}.${a}.${r}.${V}`},[s,l,i,a,r]),L=m.useCallback(()=>{if(!j||typeof window>"u")return null;try{const V=window.localStorage.getItem(j);if(!V)return null;const $=JSON.parse(V);return!$||!$.heatmap?null:$}catch{return null}},[j]),P=m.useCallback(V=>{if(!(!j||typeof window>"u"))try{window.localStorage.setItem(j,JSON.stringify(V))}catch{}},[j]),C=m.useCallback(()=>{if(!(!j||typeof window>"u"))try{window.localStorage.removeItem(j)}catch{}},[j]),I=m.useCallback(async()=>{w(!0),k(null);try{try{const T=await hi({baseUrl:e,accessToken:t,weeks:a,to:d.to,weekStartsOn:r,timeZone:l,tzOffsetMinutes:i}),b=Array.isArray(T?.weeks)?T.weeks:[];if(!b.length&&D){const H=L();if(H?.heatmap){g(H.heatmap),u(H.daily||[]),x("cache");return}}if(!b.some(H=>(Array.isArray(H)?H:[]).some(S=>S&&Number.isFinite(Number(S.level))))&&b.length){const H=[];for(const X of b)for(const F of Array.isArray(X)?X:[])F?.day&&H.push({day:F.day,conversation_count:F.conversation_count??0,total_tokens:F.total_tokens??F.value??0,billable_total_tokens:F.billable_total_tokens??F.value??F.total_tokens??0});const S=Gn({dailyRows:H,weeks:a,to:T?.to||d.to,weekStartsOn:r});u(H),g({...S,week_starts_on:r,active_days:H.filter(X=>Number(X?.billable_total_tokens??X?.total_tokens)>0).length,streak_days:gn({dailyRows:H,to:T?.to||d.to})}),x("client"),D?P({heatmap:{...S,week_starts_on:r,active_days:H.filter(X=>Number(X?.billable_total_tokens??X?.total_tokens)>0).length,streak_days:gn({dailyRows:H,to:T?.to||d.to})},daily:H,fetchedAt:new Date().toISOString()}):C();return}g(T||null),u([]),x("edge"),T&&D?P({heatmap:T,daily:[],fetchedAt:new Date().toISOString()}):D||C();return}catch(T){const b=T,M=b?.status??b?.statusCode;if(M===401||M===403)throw T}const V=await Mn({baseUrl:e,accessToken:t,from:d.from,to:d.to,timeZone:l,tzOffsetMinutes:i}),$=Array.isArray(V?.data)?V.data:[];u($);const E=Gn({dailyRows:$,weeks:a,to:d.to,weekStartsOn:r});g({...E,week_starts_on:r,active_days:$.filter(T=>Number(T?.billable_total_tokens??T?.total_tokens)>0).length,streak_days:gn({dailyRows:$,to:d.to})}),x("client"),D?P({heatmap:{...E,week_starts_on:r,active_days:$.filter(T=>Number(T?.billable_total_tokens??T?.total_tokens)>0).length,streak_days:gn({dailyRows:$,to:d.to})},daily:$,fetchedAt:new Date().toISOString()}):C()}catch(V){if(D){const $=L();if($?.heatmap)g($.heatmap),u($.daily||[]),x("cache"),k(null);else{const E=V;k(E?.message||String(E)),u([]),g(null),x("edge")}}else{const $=V;k($?.message||String($)),u([]),g(null),x("edge")}}finally{w(!1)}},[t,e,N,n,D,d.from,d.to,L,l,i,r,a,C,P]);return m.useEffect(()=>{if(!D)C(),u([]),k(null),g(null),x("edge");else{const V=L();V?.heatmap&&(g(V.heatmap),u(V.daily||[]),x("cache"))}I()},[t,N,L,I,n,D,C]),{range:d,daily:f,heatmap:h,source:N?"mock":p==="client"?"edge":p,loading:v,error:_,refresh:I}}function cl({baseUrl:e,accessToken:t,limit:n=3,from:a,to:r,source:s,timeZone:l,tzOffsetMinutes:i}={}){const[c,d]=m.useState([]),[f,u]=m.useState(!1),[h,g]=m.useState(null),p=m.useCallback(async()=>{u(!0),g(null);try{const x=await gi({baseUrl:e,accessToken:t,limit:n,from:a,to:r,source:s,timeZone:l,tzOffsetMinutes:i});d(Array.isArray(x?.entries)?x.entries:[])}catch(x){const v=x?.message||String(x);g(v),d([])}finally{u(!1)}},[t,e,a,n,s,l,r,i]);return m.useEffect(()=>{p()},[p]),{entries:c,loading:f,error:h,refresh:p}}const dl=24;function Jr({baseUrl:e,accessToken:t,guestAllowed:n=!1,period:a,from:r,to:s,months:l=dl,cacheKey:i,timeZone:c,tzOffsetMinutes:d,now:f,sharedRows:u,sharedRange:h}={}){const[g,p]=m.useState([]),[x,v]=m.useState(()=>({from:r,to:s})),[w,_]=m.useState("edge"),[k,N]=m.useState(null),[D,j]=m.useState(!1),[L,P]=m.useState(null),C=Yt(),I=!n&&!C,K=Array.isArray(u),V=h?.from||r,$=h?.to||s,E=m.useMemo(()=>a==="day"||a==="24h"?"hourly":a==="total"?"monthly":"daily",[a]),T=(()=>{if(!i)return null;const F=ul(e)||"default",z=rn({timeZone:c,offsetMinutes:d});if(E==="hourly"){const Z=a==="24h"?`${r||""}.${s||""}`:s||r||"day";return`tokentracker.trend.${i}.${F}.hourly.${Z}.${z}`}if(E==="monthly")return`tokentracker.trend.${i}.${F}.monthly.${l}.${s||"today"}.${z}`;const B=`${r||""}.${s||""}`;return`tokentracker.trend.${i}.${F}.daily.${B}.${z}`})(),b=m.useCallback(()=>{if(!T||typeof window>"u")return null;try{const F=window.localStorage.getItem(T);if(!F)return null;const z=JSON.parse(F);return!z||!Array.isArray(z.rows)?null:z}catch{return null}},[T]),M=m.useCallback(F=>{if(!(!T||typeof window>"u"))try{window.localStorage.setItem(T,JSON.stringify(F))}catch{}},[T]),H=m.useCallback(()=>{if(!(!T||typeof window>"u"))try{window.localStorage.removeItem(T)}catch{}},[T]),S=m.useCallback(async()=>{if(K){p(Array.isArray(u)?u:[]),v({from:V,to:$}),_("shared"),N(null),j(!1),P(null);return}j(!0),P(null);try{let F;E==="hourly"?F=await fl({baseUrl:e,accessToken:t,from:r,to:s,period:a,timeZone:c,tzOffsetMinutes:d,now:f}):E==="monthly"?F=await yi({baseUrl:e,accessToken:t,months:l,to:s,timeZone:c,tzOffsetMinutes:d}):F=await Mn({baseUrl:e,accessToken:t,from:r,to:s,timeZone:c,tzOffsetMinutes:d});const z=F?.from||r||F?.day||null,B=F?.to||s||F?.day||null;let Z=Array.isArray(F?.data)?F.data:[];E==="daily"?Z=Fn(Z,z||r,B||s,{timeZone:c,offsetMinutes:d,now:f}):E==="hourly"?Z=bn(Z,z||r||F?.day,B||s,{period:a,timeZone:c,offsetMinutes:d,now:f}):E==="monthly"&&(Z=Rn(Z,{timeZone:c,offsetMinutes:d,now:f}));const xe=new Date().toISOString();p(Z),v({from:z,to:B}),_("edge"),N(xe),I?M({rows:Z,from:z,to:B,mode:E,fetchedAt:xe}):H()}catch(F){if(I){const z=b();if(z?.rows){let B=E==="daily"?Fn(z.rows||[],z.from||r,z.to||s,{timeZone:c,offsetMinutes:d,now:f}):E==="hourly"?bn(z.rows||[],z.from||r||z.day||s,z.to||s,{period:a,timeZone:c,offsetMinutes:d,now:f}):Array.isArray(z.rows)?z.rows:[];E==="monthly"&&(B=Rn(B,{timeZone:c,offsetMinutes:d,now:f})),p(B),v({from:z.from||r,to:z.to||s}),_("cache"),N(z.fetchedAt||null),P(null)}else{p([]),v({from:r,to:s}),_("edge"),N(null);const B=F;P(B?.message||String(B))}}else{p([]),v({from:r,to:s}),_("edge"),N(null);const z=F;P(z?.message||String(z))}}finally{j(!1)}},[t,e,r,C,n,I,E,l,a,b,K,V,u,$,c,s,d,f,H,M]);m.useEffect(()=>{if(K){p(Array.isArray(u)?u:[]),v({from:V,to:$}),_("shared"),N(null),j(!1),P(null);return}if(!I)H(),p([]),v({from:r,to:s}),P(null),_("edge"),N(null);else{const F=b();if(F?.rows){let z=E==="daily"?Fn(F.rows||[],F.from||r,F.to||s,{timeZone:c,offsetMinutes:d,now:f}):E==="hourly"?bn(F.rows||[],F.from||r||F.day||s,F.to||s,{period:a,timeZone:c,offsetMinutes:d,now:f}):Array.isArray(F.rows)?F.rows:[];E==="monthly"&&(z=Rn(z,{timeZone:c,offsetMinutes:d,now:f})),p(z),v({from:F.from||r,to:F.to||s}),_("cache"),N(F.fetchedAt||null)}}S()},[t,C,b,S,K,V,u,$,n,I,H,E,r,s,c,d,f,a]);const X=C?"mock":w;return{rows:g,from:x.from||r,to:x.to||s,source:X,fetchedAt:k,loading:D,error:L,refresh:S}}function ul(e){try{return new URL(e).host}catch{return null}}async function fl({baseUrl:e,accessToken:t,from:n,to:a,period:r,timeZone:s,tzOffsetMinutes:l,now:i}){const c=r==="24h"?Zr(n,a):[a||n].filter(Boolean),d=Array.from(new Set(c)),f=await Promise.all(d.map(p=>qr({accessToken:t,day:p,timeZone:s,tzOffsetMinutes:l}))),u=f.flatMap(p=>Array.isArray(p?.data)?p.data:[]),h=r==="24h"?d[0]||n||a:f[0]?.day||n||a,g=r==="24h"?d[d.length-1]||a||n:f[0]?.day||a||n;return{day:g,from:h,to:g,data:bn(u,h,g,{period:r,timeZone:s,offsetMinutes:l,now:i})}}function It(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const a=Number(n[0]),r=Number(n[1])-1,s=Number(n[2]);if(!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(s))return null;const l=new Date(Date.UTC(a,r,s));return Number.isFinite(l.getTime())&&mt(l)===t?l:null}function ua(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Zr(e,t){const n=It(e||t),a=It(t||e);if(!n||!a)return[e||t].filter(Boolean).map(String);if(a<n)return[mt(a),mt(n)];const r=[];for(let s=n;s<=a;s=ua(s,1))r.push(mt(s));return r}const eo=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens","conversation_count"];function Fn(e,t,n,{timeZone:a,offsetMinutes:r,now:s}={}){const l=It(t),i=It(n);if(!l||!i||i<l)return Array.isArray(e)?e:[];const c=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,d=en({timeZone:a,offsetMinutes:r,date:c}),f=It(d),u=f?f.getTime():c.getTime(),h=new Map;for(const p of e||[])p?.day&&h.set(p.day,p);const g=[];for(let p=l;p<=i;p=ua(p,1)){const x=mt(p),v=h.get(x),w=p.getTime()>u;if(v){g.push({...v,missing:!1,future:w});continue}g.push({day:x,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!w,future:w})}return g}function ml(e,t){const n=t?null:0;return{hour:e,total_tokens:n,billable_total_tokens:n,input_tokens:n,cached_input_tokens:n,cache_creation_input_tokens:n,output_tokens:n,reasoning_output_tokens:n,conversation_count:n,missing:!1,future:t}}function hl(e){if(!e||typeof e!="object")return!1;const t=e.models;return t&&typeof t=="object"&&Object.keys(t).length>0?!1:eo.every(n=>e[n]==null)}function gl(e,t,n){const a={...e,hour:t,missing:!1,future:n};if(!n&&hl(e))for(const r of eo)a[r]=0;return a}function yl(e,t){const n=t===30?48:24,a=[];for(let r=0;r<n;r++){const s=Math.floor(r*t/60),l=r*t%60;a.push(`${e}T${String(s).padStart(2,"0")}:${String(l).padStart(2,"0")}:00`)}return a}function pl(e,t,{timeZone:n,offsetMinutes:a}={}){const r=yl(e,t);if(!n||typeof Intl>"u"||!Intl.DateTimeFormat)return r;const s=It(e);if(!s)return r;const l=s.getUTCFullYear()*1e4+(s.getUTCMonth()+1)*100+s.getUTCDate(),i=s.getTime()-2160*60*1e3,c=ua(s,2).getTime()+2160*60*1e3,d=[],f=new Set;for(let u=i;u<=c;u+=1800*1e3){const h=sn({timeZone:n,offsetMinutes:a,now:new Date(u)});if(!h||h.dayNum!==l||t===60&&h.minute!==0||t===30&&h.minute!==0&&h.minute!==30)continue;const g=`${e}T${String(h.hour).padStart(2,"0")}:${String(h.minute).padStart(2,"0")}:00`;f.has(g)||(f.add(g),d.push(g))}return d.length>0?d:r}function bl(e,t,{timeZone:n,offsetMinutes:a,now:r}={}){if(!t)return Array.isArray(e)?e:[];const s=t.trim().slice(0,10),l=sn({timeZone:n,offsetMinutes:a,now:r}),i=l?l.dayNum:void 0;let c=!1;for(const g of e||[]){const p=g?.hour||g?.label||"",x=xn(p,i);if(x&&x.slot%2!==0){c=!0;break}}const d=c?30:60,f=new Map;for(const g of e||[]){const p=g?.hour||g?.label||"",x=xn(p,i);x&&f.set(x.slot,g)}const u=[],h=pl(s,d,{timeZone:n,offsetMinutes:a});for(let g=0;g<h.length;g++){const p=h[g],x=xn(p,i),v=x?x.slot:c?g:g*2,w=f.get(v);let _=!1;if(l){const k=l.year*1e4+l.month*100+l.day,N=x?.dayNum??Number(s.replace(/-/g,""));if(N>k)_=!0;else if(N===k){const D=l.hour*2+(l.minute>=30?1:0);_=v>D}}w?u.push(gl(w,p,_)):u.push(ml(p,_))}return u}function bn(e,t,n,{period:a,timeZone:r,offsetMinutes:s,now:l}={}){const i=a==="24h"?Zr(t,n):[n||t].filter(Boolean).map(String),d=Array.from(new Set(i)).flatMap(u=>bl(xl(e||[],u),u,{timeZone:r,offsetMinutes:s,now:l})),f=kl(d,{timeZone:r,offsetMinutes:s,now:l});return a!=="24h"?f:wl(f,{timeZone:r,offsetMinutes:s,now:l})}function xl(e,t){return e.filter(n=>{const a=n?.hour||n?.label||"",r=String(a).trim();return r.includes("T")?r.slice(0,10)===t:!0})}function kl(e,{timeZone:t,offsetMinutes:n,now:a}={}){if(!Array.isArray(e))return[];const r=sn({timeZone:t,offsetMinutes:n,now:a});return r?e.map(s=>{const l=s?.hour||s?.label||"",i=xn(l,r.dayNum);if(!i)return{...s,future:!1};const c=i.dayNum!==null&&i.dayNum>r.dayNum||(i.dayNum===null||i.dayNum===r.dayNum)&&i.slot>r.slot;return{...s,future:!!c}}):e}function wl(e,{timeZone:t,offsetMinutes:n,now:a}={}){if(!Array.isArray(e))return[];const r=sn({timeZone:t,offsetMinutes:n,now:a});if(!r)return e.filter(i=>!i?.future);const s=to({year:r.year,month:r.month,day:r.day,hour:r.hour,minute:r.minute}),l=s-1440*60*1e3;return e.filter(i=>{if(i?.future)return!1;const c=vl(i?.hour||i?.label);return c!=null&&c>=l&&c<=s})}function Rn(e,{timeZone:t,offsetMinutes:n,now:a}={}){if(!Array.isArray(e))return[];const r=sn({timeZone:t,offsetMinutes:n,now:a});return r?e.map(s=>{const l=s?.month||s?.label||"",i=Nl(l);if(!i)return{...s,future:!1};const c=i.year>r.year||i.year===r.year&&i.month>r.month;return{...s,future:c}}):e}function sn({timeZone:e,offsetMinutes:t,now:n}={}){const a=n instanceof Date&&Number.isFinite(n.getTime())?n:new Date;if(e&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const h=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(a).reduce((_,k)=>(k.type&&k.value&&(_[k.type]=k.value),_),{}),g=Number(h.year),p=Number(h.month),x=Number(h.day),v=Number(h.hour),w=Number(h.minute);if(Number.isFinite(g)&&Number.isFinite(p)&&Number.isFinite(x)&&Number.isFinite(v)&&Number.isFinite(w)){const _=v*2+(w>=30?1:0);return{year:g,month:p,day:x,hour:v,minute:w,dayNum:g*1e4+p*100+x,slot:_}}}catch{}if(Number.isFinite(t)){const f=new Date(a.getTime()+t*60*1e3),u=f.getUTCFullYear(),h=f.getUTCMonth()+1,g=f.getUTCDate(),p=f.getUTCHours(),x=f.getUTCMinutes(),v=p*2+(x>=30?1:0);return{year:u,month:h,day:g,hour:p,minute:x,dayNum:u*1e4+h*100+g,slot:v}}const r=a.getFullYear(),s=a.getMonth()+1,l=a.getDate(),i=a.getHours(),c=a.getMinutes(),d=i*2+(c>=30?1:0);return{year:r,month:s,day:l,hour:i,minute:c,dayNum:r*1e4+s*100+l,slot:d}}function xn(e,t){if(!e)return null;const n=String(e).trim();if(n.includes("T")){const[a,r]=n.split("T");if(!a||!r)return null;const s=a.split("-");if(s.length!==3)return null;const l=Number(s[0]),i=Number(s[1]),c=Number(s[2]);if(!Number.isFinite(l)||!Number.isFinite(i)||!Number.isFinite(c))return null;const d=r.split(":"),f=Number(d[0]),u=Number(d[1]);if(!Number.isFinite(f)||f<0||f>23||!Number.isFinite(u)||u<0||u>59)return null;const h=f*2+(u>=30?1:0);return{dayNum:l*1e4+i*100+c,slot:h}}else{let a=NaN,r=0;if(/^\d{1,2}$/.test(n))a=Number(n);else if(/^\d{1,2}:\d{2}(:\d{2})?$/.test(n)){const l=n.split(":");a=Number(l[0]),r=Number(l[1])}if(!Number.isFinite(a)||a<0||a>23||!Number.isFinite(r)||r<0||r>59)return null;const s=a*2+(r>=30?1:0);return{dayNum:t||null,slot:s}}}function to({year:e,month:t,day:n,hour:a=0,minute:r=0}){return Date.UTC(Number(e),Number(t)-1,Number(n),Number(a),Number(r),0,0)}function vl(e){if(!e)return null;const t=String(e).trim();if(!t.includes("T"))return null;const[n,a]=t.split("T");if(!n||!a)return null;const r=n.split("-"),s=a.split(":");if(r.length!==3||s.length<2)return null;const[l,i,c]=r.map(Number),[d,f]=s.map(Number);return!Number.isFinite(l)||!Number.isFinite(i)||!Number.isFinite(c)||!Number.isFinite(d)||!Number.isFinite(f)?null:to({year:l,month:i,day:c,hour:d,minute:f})}function Nl(e){if(!e)return null;const n=String(e).trim().split("-");if(n.length!==2)return null;const a=Number(n[0]),r=Number(n[1]);return!Number.isFinite(a)||!Number.isFinite(r)||r<1||r>12?null:{year:a,month:r}}function La({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:a,to:r,includeDaily:s=!0,cacheKey:l,timeZone:i,tzOffsetMinutes:c,now:d}={}){const[f,u]=m.useState([]),[h,g]=m.useState(null),[p,x]=m.useState(null),[v,w]=m.useState("edge"),[_,k]=m.useState(null),[N,D]=m.useState(!1),[j,L]=m.useState(null),P=Yt(),C=!n&&!P,I=(()=>{if(!l)return null;const b=_l(e)||"default",M=s?"daily":"summary",H=rn({timeZone:i,offsetMinutes:c});return`tokentracker.usage.${l}.${b}.${a}.${r}.${M}.${H}`})(),K=m.useCallback(()=>{if(!I||typeof window>"u")return null;try{const b=window.localStorage.getItem(I);if(!b)return null;const M=JSON.parse(b);return!M||!M.summary?null:M}catch{return null}},[I]),V=m.useCallback(b=>{if(!(!I||typeof window>"u"))try{window.localStorage.setItem(I,JSON.stringify(b))}catch{}},[I]),$=m.useCallback(()=>{if(!(!I||typeof window>"u"))try{window.localStorage.removeItem(I)}catch{}},[I]),E=m.useCallback(async()=>{D(!0),L(null);try{let b=null,M=null;if(s){const[z,B]=await Promise.allSettled([Mn({baseUrl:e,accessToken:t,from:a,to:r,timeZone:i,tzOffsetMinutes:c}),En({baseUrl:e,accessToken:t,from:a,to:r,timeZone:i,tzOffsetMinutes:c,rolling:!0})]);if(z.status==="rejected")throw z.reason;b=z.value,M=B.status==="fulfilled"?B.value:null}else M=await En({baseUrl:e,accessToken:t,from:a,to:r,timeZone:i,tzOffsetMinutes:c,rolling:!0});let H=s&&Array.isArray(b?.data)?b.data:[];s&&(H=Ln(H,a,r,{timeZone:i,offsetMinutes:c,now:d}));let S=M?.totals||b?.summary?.totals||null,X=M?.rolling||b?.summary?.rolling||null;if(s&&!S&&!M)try{const z=await En({baseUrl:e,accessToken:t,from:a,to:r,timeZone:i,tzOffsetMinutes:c,rolling:!0});S=z?.totals||null,X=z?.rolling||X}catch{}const F=new Date().toISOString();u(H),g(S),x(X),w("edge"),k(F),S&&C?V({summary:S,rolling:X,daily:H,from:a,to:r,includeDaily:s,fetchedAt:F}):C||$()}catch(b){if(C){const M=K();if(M?.summary){g(M.summary),x(M.rolling||null);const H=Array.isArray(M.daily)?M.daily:[],S=s?Ln(H,M.from||a,M.to||r,{timeZone:i,offsetMinutes:c,now:d}):H;u(S),w("cache"),k(M.fetchedAt||null),L(null)}else{const H=b;L(H?.message||String(H)),u([]),g(null),x(null),w("edge"),k(null)}}else{const M=b;L(M?.message||String(M)),u([]),g(null),x(null),w("edge"),k(null)}}finally{D(!1)}},[t,e,a,s,P,n,C,d,K,i,r,c,$,V]);return m.useEffect(()=>{if(!C)$(),u([]),g(null),x(null),L(null),w("edge"),k(null);else{const b=K();if(b?.summary){g(b.summary),x(b.rolling||null);const M=Array.isArray(b.daily)?b.daily:[],H=s?Ln(M,b.from||a,b.to||r,{timeZone:i,offsetMinutes:c,now:d}):M;u(H),w("cache"),k(b.fetchedAt||null)}}E()},[t,P,K,E,n,C,$]),{daily:f,summary:h,rolling:p,source:P?"mock":v,fetchedAt:_,loading:N,error:j,refresh:E}}function _l(e){try{return new URL(e).host}catch{return null}}function In(e){if(!e)return null;const t=String(e).trim(),n=t.split("-");if(n.length!==3)return null;const a=Number(n[0]),r=Number(n[1])-1,s=Number(n[2]);if(!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(s))return null;const l=new Date(Date.UTC(a,r,s));return Number.isFinite(l.getTime())&&mt(l)===t?l:null}function Ml(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Ln(e,t,n,{timeZone:a,offsetMinutes:r,now:s}={}){const l=In(t),i=In(n);if(!l||!i||i<l)return Array.isArray(e)?e:[];const c=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,d=en({timeZone:a,offsetMinutes:r,date:c}),f=In(d),u=f?f.getTime():c.getTime(),h=new Map;for(const p of e||[])p?.day&&h.set(p.day,p);const g=[];for(let p=l;p<=i;p=Ml(p,1)){const x=mt(p),v=h.get(x),w=p.getTime()>u;if(v){g.push({...v,missing:!1,future:w});continue}g.push({day:x,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!w,future:w})}return g}function jl({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:a,to:r,cacheKey:s,timeZone:l,tzOffsetMinutes:i}={}){const[c,d]=m.useState(null),[f,u]=m.useState("edge"),[h,g]=m.useState(!1),[p,x]=m.useState(null),v=Yt(),w=!n,_=m.useMemo(()=>{if(!s)return null;const P=Sl(e)||"default",C=rn({timeZone:l,offsetMinutes:i});return`tokentracker.modelBreakdown.${s}.${P}.${a}.${r}.${C}`},[e,s,a,l,r,i]),k=m.useCallback(()=>{if(!_||typeof window>"u")return null;try{const P=window.localStorage.getItem(_);if(!P)return null;const C=JSON.parse(P);return!C||!C.breakdown?null:C}catch{return null}},[_]),N=m.useCallback(P=>{if(!(!_||typeof window>"u"))try{window.localStorage.setItem(_,JSON.stringify(P))}catch{}},[_]),D=m.useCallback(()=>{if(!(!_||typeof window>"u"))try{window.localStorage.removeItem(_)}catch{}},[_]),j=m.useCallback(async()=>{g(!0),x(null);try{const P=await pi({baseUrl:e,accessToken:t,from:a,to:r,timeZone:l,tzOffsetMinutes:i});d(P||null),u("edge"),P&&w?N({breakdown:P,fetchedAt:new Date().toISOString()}):w||D()}catch(P){if(w){const C=k();if(C?.breakdown)d(C.breakdown),u("cache"),x(null);else{d(null),u("edge");const I=P;x(I?.message||String(I))}}else{d(null),u("edge");const C=P;x(C?.message||String(C))}}finally{g(!1)}},[t,e,a,v,n,w,k,l,r,i,D,N]);return m.useEffect(()=>{if(!w)D(),d(null),u("edge"),x(null);else{const P=k();P?.breakdown&&(d(P.breakdown),u("cache"))}j()},[t,v,k,j,n,w,D]),{breakdown:c,source:v?"mock":f,loading:h,error:p,refresh:j}}function Sl(e){try{return new URL(e).host}catch{return null}}function Re(e){const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:0}function Cl(e){const t=String(e?.hour??""),n=t.indexOf("T");if(n<0)return null;const a=Number(t.slice(n+1,n+3));return Number.isFinite(a)?a:null}function Rt(e,t){let n=0,a=0;if(Array.isArray(e))for(const r of e){const s=Cl(r);s==null||s>t||(n+=Re(r.total_tokens),a+=Re(r.total_cost_usd))}return{tokens:n,cost:a}}function wn(...e){return e.reduce((t,n)=>({tokens:t.tokens+Re(n?.tokens),cost:t.cost+Re(n?.cost)}),{tokens:0,cost:0})}function Ya(e){if(!Array.isArray(e)||e.length===0)return null;const t=wn(...e);return{tokens:t.tokens/e.length,cost:t.cost/e.length}}function Yn(e){if(!e)return null;const t=Re(e.tokens);return t<=0?null:Re(e.cost)/(t/1e6)}function za(e,t){return e==null||t==null||!Number.isFinite(e)||!Number.isFinite(t)||t===0?null:(e-t)/t}function Dl({current:e,prev:t=null,trailingAvg:n=null,trailingFull:a=null,period:r}){if(r==="total"||!e)return null;const s=(i,c)=>c==null||!(c>0)?null:i/c,l=(i,c,d,f)=>({value:i,deltaVsPrev:za(i,c),deltaVsAvg:n?za(i,d):null,progress:f});return{period:r,tokens:l(Re(e.tokens),t?Re(t.tokens):null,n?Re(n.tokens):null,a?s(Re(e.tokens),Re(a.tokens)):null),cost:l(Re(e.cost),t?Re(t.cost):null,n?Re(n.cost):null,a?s(Re(e.cost),Re(a.cost)):null),perMTok:l(Yn(e),Yn(t),Yn(n),null)}}const no=864e5;function na(e){const t=String(e).split("-").map(Number);return t.length!==3||t.some(n=>!Number.isFinite(n))?null:Date.UTC(t[0],t[1]-1,t[2])}function vn(e){const t=new Date(e),n=t.getUTCFullYear(),a=String(t.getUTCMonth()+1).padStart(2,"0"),r=String(t.getUTCDate()).padStart(2,"0");return`${n}-${a}-${r}`}function kt(e,t){const n=na(e);return n==null?null:vn(n+t*no)}function Tl(e,{timeZone:t,offsetMinutes:n}){const a=e instanceof Date?e:new Date(e);if(t&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const r=new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",hour12:!1});let s=Number(r.format(a).slice(0,2));if(s===24&&(s=0),Number.isFinite(s))return Math.min(23,Math.max(0,s))}catch{}return typeof n=="number"&&Number.isFinite(n)?new Date(a.getTime()+n*6e4).getUTCHours():a.getHours()}function Pl(e,{timeZone:t,offsetMinutes:n}){const a=e instanceof Date?e:new Date(e);if(t&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const s=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).format(a);if(/^\d{4}-\d{2}-\d{2}$/.test(s))return s}catch{}return typeof n=="number"&&Number.isFinite(n)?vn(a.getTime()+n*6e4):vn(a.getTime())}const Ol=e=>Number(e?.total_tokens??0)||0,$l=e=>Number(e?.total_cost_usd??0)||0;function Ba(e,t,n){let a={tokens:0,cost:0};const r=t?na(t):null,s=n?na(n):null;if(r==null||s==null||r>s)return a;for(let l=r;l<=s;l+=no){const i=e.get(vn(l));i&&(a=wn(a,i))}return a}function Wl(e,t){if(!t||e==="total")return null;if(e==="day"||e==="24h"){const s=[];for(let l=1;l<=7;l++){const i=kt(t,-l);i&&s.push(i)}return{kind:"day",hourlyDays:[t,...s],dailyFrom:null,dailyTo:null,todayKey:t,prevKey:kt(t,-1),trailingKeys:s}}const n=e==="week"?6:e==="month"?29:null;if(n==null)return null;const a=n+1,r=kt(t,-a);return{kind:"window",hourlyDays:[t,r].filter(Boolean),dailyFrom:kt(t,-(a*2-1)),dailyTo:t,todayKey:t,curStartKey:kt(t,-n),prevBoundaryKey:r,prevStartKey:kt(t,-(a*2-1))}}function El(e,t){const n=new Map;return e.forEach((a,r)=>{n.set(a,Array.isArray(t[r]?.data)?t[r].data:[])}),n}function Al(e){const t=new Map;for(const n of Array.isArray(e?.data)?e.data:[])n?.day&&t.set(String(n.day),{tokens:Ol(n),cost:$l(n)});return t}function Fl(e,t,n){return{current:Rt(t.get(e.todayKey),n),prev:e.prevKey?Rt(t.get(e.prevKey),n):null,trailingAvg:Ya(e.trailingKeys.map(a=>Rt(t.get(a),n))),trailingFull:Ya(e.trailingKeys.map(a=>Rt(t.get(a),23)))}}function Rl(e,t,n,a){const r=wn(Ba(n,e.curStartKey,kt(e.todayKey,-1)),Rt(t.get(e.todayKey),a)),s=wn(Ba(n,e.prevStartKey,e.prevBoundaryKey?kt(e.prevBoundaryKey,-1):null),e.prevBoundaryKey?Rt(t.get(e.prevBoundaryKey),a):{tokens:0,cost:0});return{current:r,prev:s,trailingAvg:null}}function Il(e){try{return new URL(e).host}catch{return null}}function Ll({baseUrl:e,accessToken:t,guestAllowed:n=!1,period:a,timeZone:r,tzOffsetMinutes:s,now:l,cacheKey:i}={}){const[c,d]=m.useState(null),[f,u]=m.useState(!1),[h,g]=m.useState(null),p=m.useRef(0),x=l instanceof Date?l:new Date(l||Date.now()),v=Pl(x,{timeZone:r,offsetMinutes:s}),w=Tl(x,{timeZone:r,offsetMinutes:s}),_=Yt(),k=!n&&!_,N=(()=>{if(!i)return null;const C=Il(e)||"default",I=rn({timeZone:r,offsetMinutes:s});return`tokentracker.pulse.${i}.${C}.${a}.${v}.${I}`})(),D=m.useCallback(()=>{if(!N||typeof window>"u")return null;try{const C=window.localStorage.getItem(N);return C?JSON.parse(C):null}catch{return null}},[N]),j=m.useCallback(C=>{if(!(!N||typeof window>"u"))try{window.localStorage.setItem(N,JSON.stringify(C))}catch{}},[N]),L=m.useCallback(()=>{const C=D();return C&&C.cutoffHour===w?C:null},[D,w]),P=m.useCallback(async()=>{const C=Wl(a,v);if(!C){d(null),g(null);return}const I=++p.current;u(!0),g(null);try{const K=await Promise.all(C.hourlyDays.map(T=>qr({baseUrl:e,accessToken:t,day:T,timeZone:r,tzOffsetMinutes:s}))),V=El(C.hourlyDays,K);let $;if(C.kind==="day")$=Fl(C,V,w);else{const T=await Mn({baseUrl:e,accessToken:t,from:C.dailyFrom,to:C.dailyTo,timeZone:r,tzOffsetMinutes:s});$=Rl(C,V,Al(T),w)}const E=Dl({...$,period:a});if(I!==p.current)return;d(E),k&&E&&j({pulse:E,todayKey:v,cutoffHour:w,fetchedAt:new Date().toISOString()})}catch(K){if(I!==p.current)return;const V=L();V?.pulse&&d(V.pulse),g(K?.message?String(K.message):"Failed to load pulse")}finally{I===p.current&&u(!1)}},[e,t,n,a,r,s,v,w,k,_,L,j]);return m.useEffect(()=>{if(a==="total"||a==="custom"){d(null);return}const C=L();C?.pulse&&d(C.pulse)},[N,a,w]),m.useEffect(()=>{P()},[P]),{pulse:c,loading:f,error:h,refresh:P}}const ao=new Set(["day","hour","month"]);function Yl(e){return ao.has(e)}function Ha(e){if(e==null)return null;const t=String(e).trim();if(!/^[0-9]+$/.test(t))return null;const n=t.replace(/^0+/,"");return n.length===0?"0":n}function zl(e,t){const n=Ha(e),a=Ha(t);if(n&&a)return n.length!==a.length?n.length<a.length?-1:1:n===a?0:n<a?-1:1;const r=Le(e),s=Le(t);return r==null&&s==null?0:r==null?1:s==null?-1:r===s?0:r<s?-1:1}function ro(e,t){const n=typeof e=="string"?e:String(e||""),a=typeof t=="string"?t:String(t||"");return n===a?0:n<a?-1:1}function Bl(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!n)return null;const a=Number(n[1]),r=Number(n[2]),s=Number(n[3]);if(!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(s))return null;const l=new Date(Date.UTC(a,r-1,s));return!Number.isFinite(l.getTime())||l.getUTCFullYear()!==a||l.getUTCMonth()+1!==r||l.getUTCDate()!==s?null:l.getTime()}function Hl(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})$/);if(!n)return null;const a=Number(n[1]),r=Number(n[2]);if(!Number.isFinite(a)||!Number.isFinite(r)||r<1||r>12)return null;const s=new Date(Date.UTC(a,r-1,1));return Number.isFinite(s.getTime())?s.getTime():null}function Ul(e){if(!e)return null;const n=String(e).trim().match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?Z?$/);if(!n)return null;const a=Number(n[1]),r=Number(n[2]),s=Number(n[3]),l=Number(n[4]),i=Number(n[5]),c=Number(n[6]||0);if(!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(s)||!Number.isFinite(l)||!Number.isFinite(i)||!Number.isFinite(c)||r<1||r>12||s<1||s>31||l<0||l>23||i<0||i>59||c<0||c>59)return null;const d=new Date(Date.UTC(a,r-1,s,l,i,c));return Number.isFinite(d.getTime())?d.getTime():null}function Vl(e,t,n){const a=n==="hour"?Ul:n==="month"?Hl:Bl,r=a(e),s=a(t);return r!=null&&s!=null?r===s?0:r<s?-1:1:ro(e,t)}function oo(e,{key:t,dir:n}){const a=n==="asc"?1:-1,r=Array.isArray(e)?e:[],s=ao.has(t)?(i,c)=>Vl(i,c,t):t==="top_model"?ro:zl,l=i=>t==="total_tokens"&&i?.billable_total_tokens!=null?i.billable_total_tokens:i?.[t];return r.map((i,c)=>({row:i,index:c})).sort((i,c)=>{const d=l(i.row),f=l(c.row),u=d==null,h=f==null;if(u&&h)return i.index-c.index;if(u)return 1;if(h)return-1;const g=s(d,f);return g!==0?g*a:i.index-c.index}).map(i=>i.row)}function ql(){return[{key:"day",label:y("daily.sort.date.label"),title:y("daily.sort.date.title")},{key:"total_tokens",label:y("daily.sort.total.label"),title:y("daily.sort.total.title")},{key:"input_tokens",label:y("daily.sort.input.label"),title:y("daily.sort.input.title")},{key:"output_tokens",label:y("daily.sort.output.label"),title:y("daily.sort.output.title")},{key:"cached_input_tokens",label:y("daily.sort.cached.label"),title:y("daily.sort.cached.title")},{key:"reasoning_output_tokens",label:y("daily.sort.reasoning.label"),title:y("daily.sort.reasoning.title")},{key:"conversation_count",label:y("daily.sort.conversations.label"),title:y("daily.sort.conversations.title")}]}function Ua(e){const t=Yl(e)?e:"day";return ql().map((n,a)=>a===0?{...n,key:t}:n)}function Va(e,{key:t,dir:n}){return oo(e,{key:t,dir:n})}const Nn=12,Xl=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens"];function Kl(e){if(typeof e=="bigint")return e!==0n;if(typeof e=="number")return Number.isFinite(e)&&e!==0;if(e==null)return!1;const t=String(e).trim();if(!t||!/^-?\d+$/.test(t))return!1;const n=t.startsWith("-")?t.slice(1):t;return/[1-9]/.test(n)}function Gl(e){return Xl.some(t=>Kl(e?.[t]))}function Ql(e){const t=Array.isArray(e)?e:[];if(!t.length)return[];const n=oo(t,{key:"month",dir:"asc"}),a=n.findIndex(r=>r?.month&&Gl(r));return a===-1?t:n.slice(a)}function Jl(e,t,n=Nn){const a=Array.isArray(e)?e:[],r=Number.isFinite(n)&&n>0?n:Nn,l=(Number.isFinite(t)&&t>=0?Math.floor(t):0)*r;return a.slice(l,l+r)}function Zl(e){if(typeof e!="string")return null;const t=e.trim();return t?t.toLowerCase():null}function ec(e){const t=Zl(e?.model_id);return t||null}function tc(e,t){return e?.model?String(e.model):t}function nc(e){const t=String(e||"").toLowerCase();return t.includes("free")||t.includes("hy3-preview")||/^glm-[\d.]+-flash(?![a-z])/.test(t)}function _n(e,t=0){const n=Le(e?.billable_total_tokens),a=Le(e?.total_tokens);return n!=null&&n>0?n:a!=null&&a>0?a:n??a??t}function so(e,{copyFn:t}={}){const n=typeof t=="function"?t:l=>l,r=(Array.isArray(e?.sources)?e.sources:[]).map(l=>{const i=_n(l?.totals),c=Le(l?.totals?.total_cost_usd)??0;return{source:l?.source,totalTokens:Number.isFinite(i)?i:0,totalCost:Number.isFinite(c)?c:0,models:Array.isArray(l?.models)?l.models:[]}}).filter(l=>l.totalTokens>0);if(!r.length)return[];const s=r.reduce((l,i)=>l+i.totalTokens,0);return typeof e?.pricing?.pricing_mode=="string"&&e.pricing.pricing_mode.toUpperCase(),r.slice().sort((l,i)=>i.totalTokens-l.totalTokens).map(l=>{const i=l.source?String(l.source).toUpperCase():n("shared.placeholder.short"),c=s>0?l.totalTokens/s*100:0,d=Number.isFinite(c)?c.toFixed(1):"0.0",f=l.models.map(g=>{const p=_n(g?.totals);if(!Number.isFinite(p)||p<=0)return null;const x=l.totalTokens>0?Math.round(p/l.totalTokens*1e3)/10:0,v=tc(g,n("shared.placeholder.short")),w=ec(g),_=Le(g?.totals?.total_cost_usd),k=_??(l.totalCost>0&&l.totalTokens>0?p/l.totalTokens*l.totalCost:null),N=p>0&&(k==null||k<=0)&&!nc(v);return{id:w,name:v,share:x,usage:p,cost:k,pricingMissing:N}}).filter(Boolean),u=f.filter(g=>Number.isFinite(Number(g?.cost))&&Number(g.cost)>0).sort((g,p)=>Number(p.cost)-Number(g.cost))[0]||null,h=f.filter(g=>g?.pricingMissing);return{source:l.source,label:i,totalPercent:String(d),usd:l.totalCost,usage:l.totalTokens,topCostModel:u,missingPricingModels:h,models:f}})}function ac(e,{copyFn:t}={}){const a=so(e,{copyFn:typeof t=="function"?t:f=>f}),r=a.reduce((f,u)=>f+(Number(u?.usage)||0),0),s=a.reduce((f,u)=>f+(Number(u?.usd)||0),0),l=a.flatMap(f=>(f.models||[]).map(u=>({...u,source:f.label}))),i=l.filter(f=>Number.isFinite(Number(f?.cost))&&Number(f.cost)>0).sort((f,u)=>Number(u.cost)-Number(f.cost))[0]||null,c=l.filter(f=>Number.isFinite(Number(f?.usage))&&Number(f.usage)>0).sort((f,u)=>Number(u.usage)-Number(f.usage))[0]||null,d=l.filter(f=>f?.pricingMissing);return{totalTokens:r,totalCost:s,costPerMillionTokens:r>0?s/(r/1e6):null,topCostModel:i,topUsageModel:c,missingPricingModels:d}}function rc(e,t="—"){const n=Object.entries(e?.models||{});if(!n.length)return t;let a=null,r=-1;for(const[s,l]of n){const i=Number(l);!Number.isFinite(i)||i<=r||(a=s,r=i)}return a||t}function oc(e,{fallback:t="—"}={}){const n=(Array.isArray(e)?e:[]).map(s=>{const l=_n(s),i=Le(s?.total_cost_usd)??0,c=Number.isFinite(l)&&l>0?i/(l/1e6):null;return{...s,cost_per_million_tokens:c,top_model:rc(s,t)}}),a=n.reduce((s,l)=>{const i=Le(l?.cost_per_million_tokens);return i!=null&&i>0&&s.push(i),s},[]),r=a.length>0?a.reduce((s,l)=>s+l,0)/a.length:null;return n.map(s=>{const l=Le(s?.cost_per_million_tokens),i=l!=null&&r!=null&&r>0&&l>r*1.15;return{...s,cost_per_million_baseline:r,cost_per_million_status:i?"high":"normal"}})}const dt={emerald:{light:["#ebedf0","#a7f3d0","#6ee7b7","#34d399","#10b981"],dark:["#2d333b","#065f46","#059669","#10b981","#34d399"],gridColor:{light:"rgba(16, 185, 129, 0.12)",dark:"rgba(52, 211, 153, 0.08)"}},ocean:{light:["#f1f5f9","#93c5fd","#60a5fa","#3b82f6","#1d4ed8"],dark:["#1e293b","#1e3a8a","#2563eb","#3b82f6","#60a5fa"],gridColor:{light:"rgba(59, 130, 246, 0.12)",dark:"rgba(96, 165, 250, 0.08)"}},neon:{light:["#faf5ff","#ebd5ff","#c084fc","#a855f7","#7e22ce"],dark:["#2e1065","#581c87","#8b5cf6","#a855f7","#c084fc"],gridColor:{light:"rgba(168, 85, 247, 0.12)",dark:"rgba(192, 132, 252, 0.08)"}},amber:{light:["#fffbeb","#fde68a","#f59e0b","#d97706","#b45309"],dark:["#451a03","#78350f","#b45309","#d97706","#f59e0b"],gridColor:{light:"rgba(245, 158, 11, 0.12)",dark:"rgba(245, 158, 11, 0.08)"}}};function sc(e,t){const n=/^#([0-9a-f]{6})$/i.exec(e);if(!n)return e;const a=parseInt(n[1],16),r=a>>16&255,s=a>>8&255,l=a&255,i=c=>Math.max(0,Math.min(255,Math.round(c*t)));return`rgb(${i(r)}, ${i(s)}, ${i(l)})`}function tt(e,t,n,a,r){const s=Math.cos(a),l=Math.sin(a),i=e*s-t*l,c=e*l+t*s,d=n,f=Math.cos(r),u=Math.sin(r),h=i,g=c*f-d*u,p=c*u+d*f;return{x:h,y:g,z:p}}function ic(e,t,n,a,r){return tt(e,t,n,a,r)}function io(e,t){const n=Number(t).toLocaleString();if(e>=4){const a=Math.floor(Math.random()*3)+1;return y(`heatmap.3d.voxel.joke.${a}`,{value:n})}else return e===3?y("heatmap.3d.voxel.level3",{value:n}):e===2?y("heatmap.3d.voxel.level2",{value:n}):e===1?y("heatmap.3d.voxel.level1",{value:n}):y("heatmap.3d.voxel.level0")}function qa({weeks:e,palette:t="auto",isDark:n=!1,interactive:a=!1,autoRotateInit:r=!1,onResetViewRef:s=null}){const l=dt[t]||(t==="auto"?dt.emerald:null),i=l?n?l.dark:l.light:Array.isArray(t)?t:n?dt.emerald.dark:dt.emerald.light,c=l?n?l.gridColor.dark:l.gridColor.light:n?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)",d=-.2,f=.88,[u,h]=m.useState({yaw:d,pitch:f}),[g,p]=m.useState(r),[x,v]=m.useState(1),w=a?13:10.5,_=m.useMemo(()=>{const A=[],Y=e.length;if(Y===0||!a)return[];for(let U=0;U<=7;U++){const q=(U-3.5)*w,ne=tt(-Y/2*w,q,0,u.yaw,u.pitch),se=tt(Y/2*w,q,0,u.yaw,u.pitch);A.push({d:`M${ne.x},${ne.y} L${se.x},${se.y}`,key:`horiz-${U}`})}for(let U=0;U<=Y;U+=4){const q=(U-Y/2)*w,ne=tt(q,-3.5*w,0,u.yaw,u.pitch),se=tt(q,3.5*w,0,u.yaw,u.pitch);A.push({d:`M${ne.x},${ne.y} L${se.x},${se.y}`,key:`vert-${U}`})}if(Y%4!==0){const U=(Y-Y/2)*w,q=tt(U,-3.5*w,0,u.yaw,u.pitch),ne=tt(U,3.5*w,0,u.yaw,u.pitch);A.push({d:`M${q.x},${q.y} L${ne.x},${ne.y}`,key:"vert-last"})}return A},[e.length,u,w,a]);m.useEffect(()=>{s&&(s.current={reset:()=>{h({yaw:d,pitch:f}),p(!1),v(1),T()},toggleAutoRotate:A=>{p(A)}})},[s]);const k=m.useRef(null),N=m.useRef(null),D=m.useRef(!1),j=m.useRef({x:0,y:0}),L=m.useRef({yaw:d,pitch:f}),P=m.useRef({x:0,y:0}),C=m.useRef({x:0,y:0,time:0}),I=m.useRef(null),[K,V]=m.useState(0),$=m.useRef(null),E=m.useRef(!0);m.useEffect(()=>(E.current=!0,()=>{E.current=!1}),[]);const T=()=>{$.current&&cancelAnimationFrame($.current),V(0);const A=performance.now(),Y=1200,U=q=>{if(!E.current)return;const ne=q-A,se=Math.min(1,ne/Y),ye=1-Math.pow(1-se,3);V(ye),se<1?$.current=requestAnimationFrame(U):$.current=null};$.current=requestAnimationFrame(U)};m.useEffect(()=>(T(),()=>{$.current&&cancelAnimationFrame($.current)}),[a]),m.useEffect(()=>{if(!g||D.current||typeof window>"u"||typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;let Y;const U=()=>{if(typeof document<"u"&&document.visibilityState==="hidden"){Y=requestAnimationFrame(U);return}h(q=>({yaw:q.yaw+.002,pitch:q.pitch})),Y=requestAnimationFrame(U)};return Y=requestAnimationFrame(U),()=>cancelAnimationFrame(Y)},[g]);const b=(A,Y)=>{a&&(D.current=!0,j.current={x:A,y:Y},L.current={yaw:u.yaw,pitch:u.pitch},P.current={x:0,y:0},C.current={x:A,y:Y,time:performance.now()},I.current&&cancelAnimationFrame(I.current))},M=(A,Y)=>{if(!D.current)return;const U=A-j.current.x,q=Y-j.current.y,ne=performance.now(),se=ne-C.current.time;se>0&&(P.current={x:(A-C.current.x)/se,y:(Y-C.current.y)/se}),C.current={x:A,y:Y,time:ne};const ye=.005,fe=L.current.yaw-U*ye,he=Math.PI/2.3,Pe=Math.max(-he,Math.min(he,L.current.pitch-q*ye));h({yaw:fe,pitch:Pe})},H=()=>{if(!D.current)return;D.current=!1;let A=-P.current.x*12,Y=-P.current.y*12;const U=.95,q=()=>{D.current||(A*=U,Y*=U,!(Math.abs(A)<.01&&Math.abs(Y)<.01)&&(h(ne=>{const se=ne.yaw+A*.005,ye=Math.PI/2.3,fe=Math.max(-ye,Math.min(ye,ne.pitch+Y*.005));return{yaw:se,pitch:fe}}),I.current=requestAnimationFrame(q)))};I.current=requestAnimationFrame(q)},[S,X]=m.useState(null),[F,z]=m.useState({x:0,y:0,shiftX:0}),B=m.useRef(null);m.useEffect(()=>()=>{B.current&&clearTimeout(B.current)},[]),m.useEffect(()=>{if(!a||!N.current)return;const A=U=>{U.preventDefault();const q=-U.deltaY*.0025;v(ne=>{const se=ne+q;return Math.max(.5,Math.min(3,se))})},Y=N.current;return Y.addEventListener("wheel",A,{passive:!1}),()=>{Y.removeEventListener("wheel",A)}},[a]);const Z=m.useMemo(()=>{const A=[];return e.forEach((Y,U)=>{(Array.isArray(Y)?Y:[]).forEach((q,ne)=>{q&&A.push({key:q.day||`${U}-${ne}`,col:U,row:ne,level:q.level||0,value:q.value||0,total_tokens:q.total_tokens||0,day:q.day,models:q.models||null})})}),A},[e]),je=w-(a?1.8:1.5),Me=a?38:28,Se=A=>Math.max(1.8,Number(A)/4*Me),J=m.useMemo(()=>{if(Z.length===0)return[];const A=e.length;return Z.map(Y=>{const U=Se(Y.level),q=Math.sqrt(Math.pow(Y.col-A/2,2)+Math.pow(Y.row-3.5,2)),ne=Math.sqrt(Math.pow(A/2,2)+Math.pow(3.5,2)),se=q/ne*.4,ye=Math.min(1,Math.max(0,(K-se)*(1/.6))),fe=U*ye,he=(Y.col-A/2)*w,Pe=(Y.row-3.5)*w,pe=je/2,Ee=[{x:he-pe,y:Pe-pe,z:0},{x:he+pe,y:Pe-pe,z:0},{x:he+pe,y:Pe+pe,z:0},{x:he-pe,y:Pe+pe,z:0},{x:he-pe,y:Pe-pe,z:fe},{x:he+pe,y:Pe-pe,z:fe},{x:he+pe,y:Pe+pe,z:fe},{x:he-pe,y:Pe+pe,z:fe}].map(ae=>tt(ae.x,ae.y,ae.z,u.yaw,u.pitch)),Be=tt(he,Pe,fe/2,u.yaw,u.pitch),_t=[{name:"top",indices:[4,5,6,7],scale:1,normal:[0,0,1]},{name:"bottom",indices:[3,2,1,0],scale:.4,normal:[0,0,-1]},{name:"left",indices:[3,0,4,7],scale:.55,normal:[-1,0,0]},{name:"right",indices:[1,2,6,5],scale:.75,normal:[1,0,0]},{name:"front",indices:[0,1,5,4],scale:.85,normal:[0,-1,0]},{name:"back",indices:[2,3,7,6],scale:.65,normal:[0,1,0]}],gt=i[Math.min(4,Math.max(0,Number(Y.level)||0))],yt=[],it=.35,Mt=-.4,oe=.83;return _t.forEach(ae=>{const ee=ic(ae.normal[0],ae.normal[1],ae.normal[2],u.yaw,u.pitch);if(ee.z>.001){const ce=Ee[ae.indices[0]],Ce=Ee[ae.indices[1]],ie=Ee[ae.indices[2]],ze=Ee[ae.indices[3]],zt=`M${ce.x},${ce.y} L${Ce.x},${Ce.y} L${ie.x},${ie.y} L${ze.x},${ze.y} Z`,Bt=ee.x*it+ee.y*Mt+ee.z*oe,jt=n?.18:0,pt=ae.scale*(.82+.28*Math.max(0,Bt))+jt;yt.push({name:ae.name,d:zt,fill:sc(gt,pt)})}}),{...Y,centerProj:Be,renderedFaces:yt}})},[Z,u,i,e.length,K,w,je,Me]),De=m.useMemo(()=>[...J].sort((A,Y)=>A.centerProj.z-Y.centerProj.z),[J]),le=m.useMemo(()=>{if(De.length===0)return{minX:-100,minY:-100,maxX:100,maxY:100};let A=1/0,Y=1/0,U=-1/0,q=-1/0;return De.forEach(ne=>{const se=w*2,ye=ne.centerProj.x,fe=ne.centerProj.y;ye-se<A&&(A=ye-se),ye+se>U&&(U=ye+se),fe-se<Y&&(Y=fe-se),fe+se>q&&(q=fe+se)}),{minX:A,minY:Y,maxX:U,maxY:q}},[De,w]),de=12,W=le.maxX-le.minX+de*2,te=le.maxY-le.minY+de*2,ge=W/x,me=te/x,Ne=le.minX-de+(W-ge)/2,Fe=le.minY-de+(te-me)/2,Te=`${Ne} ${Fe} ${ge} ${me}`;return Z.length===0?o.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:y("heatmap.empty")}):o.jsxs("div",{ref:N,className:`relative select-none outline-none ${a?"cursor-grab active:cursor-grabbing w-full h-full flex items-center justify-center":"w-full overflow-hidden flex justify-center"}`,onMouseDown:A=>{if(!a)return;b(A.clientX,A.clientY);const Y=q=>M(q.clientX,q.clientY),U=()=>{H(),window.removeEventListener("mousemove",Y),window.removeEventListener("mouseup",U)};window.addEventListener("mousemove",Y),window.addEventListener("mouseup",U)},onTouchStart:A=>{!a||A.touches.length===0||b(A.touches[0].clientX,A.touches[0].clientY)},onTouchMove:A=>{!a||A.touches.length===0||M(A.touches[0].clientX,A.touches[0].clientY)},onTouchEnd:()=>{a&&H()},children:[o.jsxs("svg",{ref:k,viewBox:Te,width:a?"95%":"100%",height:a?"95%":"auto",role:"img","aria-label":y("heatmap.iso.aria")||"3D interactive activity heatmap",style:{display:"block",width:"100%",height:"auto",maxWidth:a?"none":`${W}px`,maxHeight:a?"78vh":"none"},className:"transition-transform duration-300 ease-out",children:[a&&_.map(A=>o.jsx("path",{d:A.d,fill:"none",stroke:c,strokeWidth:.25,strokeDasharray:"1.5 2.5",strokeLinecap:"round"},A.key)),De.map(A=>{const Y=S&&S.key===A.key;return o.jsxs("g",{onMouseEnter:U=>{if(B.current&&(clearTimeout(B.current),B.current=null),X(A),a&&k.current){const q=tt((A.col-e.length/2)*w,(A.row-3.5)*w,Se(A.level),u.yaw,u.pitch);let ne=0,se=0;const ye=k.current;if(N.current&&typeof ye.createSVGPoint=="function"&&typeof ye.getScreenCTM=="function")try{const pe=ye.createSVGPoint();pe.x=q.x,pe.y=q.y;const We=ye.getScreenCTM();if(We){const Ee=pe.matrixTransform(We),Be=N.current.getBoundingClientRect();ne=Ee.x-Be.left,se=Ee.y-Be.top}}catch{const We=ye.getBoundingClientRect(),Ee=le.maxX-le.minX+de*2,Be=le.maxY-le.minY+de*2;ne=(q.x-(le.minX-de))/Ee*We.width,se=(q.y-(le.minY-de))/Be*We.height}else{const pe=ye.getBoundingClientRect(),We=le.maxX-le.minX+de*2,Ee=le.maxY-le.minY+de*2;ne=(q.x-(le.minX-de))/We*pe.width,se=(q.y-(le.minY-de))/Ee*pe.height}const fe=140;let he=0;const Pe=N.current?N.current.getBoundingClientRect().width:ye.getBoundingClientRect().width;ne<fe?he=fe-ne:ne>Pe-fe&&(he=Pe-fe-ne),z({x:ne,y:se,shiftX:he})}},onMouseLeave:()=>{B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{X(null)},150)},className:"transition-all duration-200",style:{filter:Y?"brightness(1.15) drop-shadow(0 4px 6px rgba(0,0,0,0.15))":"none",cursor:a?"pointer":"default"},children:[!a&&A.day&&o.jsx("title",{children:`${A.day}: ${Number(A.value).toLocaleString()} conversations`}),A.renderedFaces.map((U,q)=>o.jsx("path",{d:U.d,fill:U.fill,stroke:U.fill,strokeWidth:.25,strokeLinejoin:"round"},q))]},A.key)})]}),a&&S&&o.jsxs("div",{onMouseEnter:()=>{B.current&&(clearTimeout(B.current),B.current=null)},onMouseLeave:()=>{B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{X(null)},150)},className:"absolute z-[9999] w-0 h-0 transition-all duration-100 ease-out",style:{left:`${F.x}px`,top:`${F.y}px`},children:[o.jsxs("div",{className:"absolute left-0 bottom-[10px] backdrop-blur-md bg-white/90 dark:bg-oai-gray-900/90 border border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-xl rounded-xl p-3.5 max-w-[280px] min-w-[200px] flex flex-col gap-2 animate-in fade-in zoom-in-95 duration-100",style:{transform:`translateX(calc(-50% + ${F.shiftX}px))`},children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-oai-gray-100 dark:border-oai-gray-800/80 pb-1.5",children:[o.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400",children:S.day}),(()=>{const A=S.level===0?n?"#9ca3af":"#6b7280":i[S.level];return o.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:A+"22",color:A,border:`1px solid ${A}44`},children:["Level ",S.level]})})()]}),o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsxs("div",{className:"flex flex-col gap-0.5",children:[o.jsxs("div",{className:"flex items-baseline gap-1",children:[o.jsx("span",{className:"text-lg font-bold text-oai-gray-900 dark:text-white leading-none tabular-nums",children:Number(S.value??0).toLocaleString()}),o.jsx("span",{className:"text-[10px] text-oai-gray-400 uppercase tracking-wider font-semibold",children:"Conversations"})]}),o.jsxs("div",{className:"flex items-baseline gap-1",children:[o.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400 leading-none tabular-nums",children:Number(S.total_tokens??0).toLocaleString()}),o.jsx("span",{className:"text-[9px] text-oai-gray-400 uppercase tracking-wider",children:"tokens"})]})]}),S.models&&Object.keys(S.models).length>0?o.jsxs("div",{className:"mt-1.5 border-t border-oai-gray-100 dark:border-oai-gray-800/60 pt-2 flex flex-col gap-1.5",children:[o.jsx("div",{className:"text-[10px] font-semibold text-oai-gray-400 dark:text-oai-gray-500 uppercase tracking-wider",children:"Model Breakdown"}),o.jsx("div",{className:"flex flex-col gap-2 max-h-[150px] overflow-y-auto pr-1.5 scrollbar-thin",children:Object.entries(S.models).map(([A,Y])=>({name:A,val:Number(Y)})).sort((A,Y)=>Y.val-A.val).map(({name:A,val:Y})=>{const U=Number(S.total_tokens)||Object.values(S.models).reduce((ne,se)=>ne+Number(se||0),0)||1,q=Math.round(Y/U*100);return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center justify-between text-[11px] gap-3",children:[o.jsx("span",{className:"font-medium text-oai-gray-750 dark:text-oai-gray-200 truncate max-w-[120px]",title:A,children:A}),o.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[o.jsx("span",{className:"font-mono text-oai-gray-900 dark:text-oai-gray-100 font-semibold",children:Y.toLocaleString()}),o.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[q,"%"]})]})]}),o.jsx("div",{className:"w-full h-1 bg-oai-gray-100 dark:bg-oai-gray-800/85 rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${q}%`,backgroundColor:i[4],boxShadow:`0 0 4px ${i[4]}55`}})})]},A)})})]}):o.jsx("p",{className:"text-[11px] text-oai-gray-600 dark:text-oai-gray-300 leading-relaxed font-normal mt-1 border-t border-dashed border-oai-gray-100 dark:border-oai-gray-800/60 pt-1.5",children:io(S.level,S.value)})]})]}),o.jsx("div",{className:"absolute bottom-[6px] left-0 -translate-x-1/2 w-2.5 h-2.5 rotate-45 bg-white dark:bg-oai-gray-900 border-r border-b border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-sm",style:{marginBottom:"1px"}})]})]})}const lc=12,cc=3,dc=26,uc=["#ebedf0","#f7d08a","#f2b757","#eca02f","#d9861a"],fc=["#30363d","#7a4711","#bf7015","#eca02f","#f7c877"];function Xa(e){const t=Number(e);return Number.isFinite(t)?t<1e3?t.toLocaleString():Ae(t,{decimals:2}):"0"}function mc(e){if(typeof e!="string")return null;const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e.trim());if(!t)return null;const n=new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3])));return Number.isFinite(n.getTime())?n:null}function lo(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function hc(e,t){return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))/864e5)}function gc(e,t){const n=t==="mon"?1:0,a=e.getUTCDay();return lo(e,-((a-n+7)%7))}function yc(e,t,n,a){if(!e)return[];const r=mc(t)||new Date,s=[];for(let f=11;f>=0;f-=1)s.push(new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth()-f,1)));const l=gc(r,n),i=lo(l,-(e-1)*7),c=[],d=new Set;for(const f of s){const u=Math.floor(hc(i,f)/7);u<0||u>=e||d.has(u)||(d.add(u),c.push({label:a[f.getUTCMonth()],index:u}))}return c}function pc({heatmap:e,timeZoneLabel:t,timeZoneShortLabel:n,hideLegend:a=!1,embedded:r=!1}){const{resolvedTheme:s}=Lr(),{currency:l,rate:i}=Nt(),c=s==="dark",d=c?fc:uc,f=m.useRef(null),u=m.useRef(null),[h,g]=m.useState(null),[p,x]=m.useState({x:0,y:0,shiftX:0}),v=m.useRef(null);m.useEffect(()=>()=>{v.current&&clearTimeout(v.current)},[]);const[w,_]=m.useState(!1),[k,N]=m.useState(!1),[D,j]=m.useState(!1),L=m.useRef(null),[P,C]=m.useState("amber"),I=[y("heatmap.month.jan"),y("heatmap.month.feb"),y("heatmap.month.mar"),y("heatmap.month.apr"),y("heatmap.month.may"),y("heatmap.month.jun"),y("heatmap.month.jul"),y("heatmap.month.aug"),y("heatmap.month.sep"),y("heatmap.month.oct"),y("heatmap.month.nov"),y("heatmap.month.dec")],K=(W,te)=>{if(!te||!te.day)return;v.current&&(clearTimeout(v.current),v.current=null),g(te);const ge=W.currentTarget.getBoundingClientRect(),me=typeof window<"u"?window.innerWidth:1024,Ne=ge.left+ge.width/2,Fe=ge.top,Te=140;let A=0;Ne<Te?A=Te-Ne:Ne>me-Te&&(A=me-Te-Ne),x({x:Ne,y:Fe,shiftX:A})},V=()=>{v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{g(null)},150)},$=()=>{N(!1),_(!0)},E=()=>{N(!0)},T=W=>{W.target===W.currentTarget&&k&&(_(!1),N(!1))};m.useEffect(()=>{if(!w||k)return;const W=te=>{te.key==="Escape"&&E()};return window.addEventListener("keydown",W),()=>{window.removeEventListener("keydown",W)}},[w,k]);const b=m.useMemo(()=>({emerald:{accentText:"text-emerald-500 dark:text-emerald-400",accentBg:"bg-emerald-500/10 dark:bg-emerald-400/10",accentBorder:"border-emerald-500/20 dark:border-emerald-400/15",hoverBorder:"hover:border-emerald-500/30 dark:hover:border-emerald-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(16,185,129,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(52,211,153,0.25)]",rawColor:"#10b981"},ocean:{accentText:"text-blue-500 dark:text-blue-400",accentBg:"bg-blue-500/10 dark:bg-blue-400/10",accentBorder:"border-blue-500/20 dark:border-blue-400/15",hoverBorder:"hover:border-blue-500/30 dark:hover:border-blue-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(59,130,246,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(96,165,250,0.25)]",rawColor:"#3b82f6"},neon:{accentText:"text-purple-500 dark:text-purple-400",accentBg:"bg-purple-500/10 dark:bg-purple-400/10",accentBorder:"border-purple-500/20 dark:border-purple-400/15",hoverBorder:"hover:border-purple-500/30 dark:hover:border-purple-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(168,85,247,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(192,132,252,0.25)]",rawColor:"#a855f7"},amber:{accentText:"text-amber-500 dark:text-amber-400",accentBg:"bg-amber-500/10 dark:bg-amber-400/10",accentBorder:"border-amber-500/20 dark:border-amber-400/15",hoverBorder:"hover:border-amber-500/30 dark:hover:border-amber-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(245,158,11,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(245,158,11,0.25)]",rawColor:"#f59e0b"}}),[]),M=b[P]||b.emerald,H=dt[P]?c?dt[P].dark:dt[P].light:c?dt.emerald.dark:dt.emerald.light,[S,X]=m.useState(()=>{if(r)return"2d";try{return window.localStorage?.getItem("tt:heatmap-view")==="3d"?"3d":"2d"}catch{return"2d"}});m.useEffect(()=>{if(!r)try{window.localStorage?.setItem("tt:heatmap-view",S)}catch{}},[S,r]),m.useEffect(()=>{if(S!=="2d")return;const W=f.current;W&&(W.scrollLeft=W.scrollWidth)},[e?.weeks,S]),m.useEffect(()=>{const W=f.current;if(!W)return;const te=()=>{v.current&&(clearTimeout(v.current),v.current=null),g(null)};return W.addEventListener("scroll",te),()=>W.removeEventListener("scroll",te)},[]);const F=e?.week_starts_on==="mon"?"mon":"sun",z=m.useMemo(()=>{const W=Array.isArray(e?.weeks)?e.weeks:[];if(!W.length)return{weeks:[]};const te=[];for(const ge of W)for(const me of Array.isArray(ge)?ge:[])me?.day&&te.push({day:me.day,conversation_count:me.conversation_count??0,total_tokens:me.total_tokens??0,billable_total_tokens:me.billable_total_tokens??me.total_tokens??0,models:me.models??null});return Gn({dailyRows:te,weeks:Math.max(52,W.length),to:e?.to,weekStartsOn:F})},[e?.to,e?.weeks,F]),B=z?.weeks||[],Z=m.useMemo(()=>{let W=0,te=0,ge={day:"无数据",value:0},me=0,Ne=0;const Fe=[];B.forEach(fe=>{(Array.isArray(fe)?fe:[]).forEach(he=>{he&&he.day&&Fe.push(he)})}),Fe.sort((fe,he)=>fe.day.localeCompare(he.day)),Fe.forEach(fe=>{const he=Number(fe.value)||0;W+=Number(fe.total_tokens)||0,he>0?(te++,me++,me>Ne&&(Ne=me)):me=0,he>ge.value&&(ge={day:fe.day,value:he})});const Te=Fe.length||365,A=(te/Te*100).toFixed(1);let Y="heatmap.3d.modal.ai.eval.default",U="heatmap.3d.modal.ai.title.default";W>=15e6?(U="heatmap.3d.modal.ai.title.peak",Y="heatmap.3d.modal.ai.eval.peak"):W>=5e6?(U="heatmap.3d.modal.ai.title.heavy",Y="heatmap.3d.modal.ai.eval.heavy"):W>=1e6?(U="heatmap.3d.modal.ai.title.core",Y="heatmap.3d.modal.ai.eval.core"):W>=2e4&&(U="heatmap.3d.modal.ai.title.steady",Y="heatmap.3d.modal.ai.eval.steady");const q=e?.total_cost_usd,ne=Number(q),ye=q!=null&&(typeof q!="string"||q.trim()!=="")&&Number.isFinite(ne)?ne:W/15e5;return{totalTokens:W,activeDays:te,activeRate:A,maxSingleDay:ge,maxStreak:Ne,aiEvaluationTitleKey:U,aiEvaluationKey:Y,totalCostUsd:ye}},[B,e?.total_cost_usd]),xe=m.useMemo(()=>et(Z.totalCostUsd,{currency:l,rate:i}),[Z.totalCostUsd,l,i]),je=F==="mon"?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(W=>y(`heatmap.day.${W.toLowerCase()}`)):["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(W=>y(`heatmap.day.${W.toLowerCase()}`)),Me=m.useMemo(()=>yc(B.length,z?.to,F,I),[z?.to,B.length,F,I]);if(!B.length)return o.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:y("heatmap.empty")});const Se=r?10:lc,J=r?2:cc,De=r?22:dc,le=De+B.length*Se+Math.max(0,B.length-1)*J,de=`${De}px repeat(${B.length}, ${Se}px)`;return o.jsxs("div",{ref:u,className:r?"relative":"relative rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5",children:[!r&&o.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[o.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:y("heatmap.title")}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{role:"tablist","aria-label":"Heatmap view",className:"flex rounded-md border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 text-[10px]",children:[o.jsx("button",{type:"button",role:"tab","aria-selected":S==="2d",onClick:()=>X("2d"),className:S==="2d"?"px-2 py-0.5 rounded bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-oai-white font-medium":"px-2 py-0.5 rounded text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200",children:y("heatmap.view.2d")}),o.jsx("button",{type:"button",role:"tab","aria-selected":S==="3d",onClick:()=>X("3d"),className:S==="3d"?"px-2 py-0.5 rounded bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-oai-white font-medium":"px-2 py-0.5 rounded text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200",children:y("heatmap.view.3d")})]}),o.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-450",children:n||y("heatmap.legend.utc")})]})]}),S==="3d"&&o.jsxs("div",{onClick:$,className:"cursor-pointer group relative overflow-hidden rounded-lg hover:border-oai-gray-350 dark:hover:border-oai-gray-700 border border-transparent transition-all",title:y("heatmap.3d.hover_tip"),children:[o.jsx(qa,{weeks:B,isDark:c,palette:P}),o.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-oai-gray-900/5 to-transparent pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity flex items-end justify-center pb-2",children:o.jsxs("span",{className:"text-[10px] bg-white/95 dark:bg-oai-gray-900/95 shadow border border-oai-gray-200/60 dark:border-oai-gray-800/80 px-2.5 py-1 rounded-full font-medium text-oai-gray-500 dark:text-oai-gray-400 flex items-center gap-1 transform translate-y-2 group-hover:translate-y-0 transition-transform duration-200",children:[o.jsx(Xr,{size:9}),y("heatmap.3d.hover_tip")]})})]}),S==="2d"&&o.jsx("div",{ref:f,className:"overflow-x-auto overflow-y-hidden heatmap-scroll-thin",children:o.jsxs("div",{style:{minWidth:le},children:[o.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:de,columnGap:J},children:[o.jsx("span",{}),Me.map(W=>o.jsx("span",{style:{gridColumnStart:W.index+2},className:"whitespace-nowrap",children:W.label},`${W.label}-${W.index}`))]}),o.jsxs("div",{className:"grid",style:{gridTemplateColumns:de,columnGap:J},children:[o.jsx("div",{className:"grid text-[10px] text-oai-gray-400 dark:text-oai-gray-400 sticky left-0 bg-white dark:bg-oai-gray-900 pr-2",style:{gridTemplateRows:`repeat(7, ${Se}px)`,rowGap:J},children:je.map(W=>o.jsx("span",{className:"leading-none",children:W},W))}),o.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${Se}px)`,gap:J},children:B.map((W,te)=>(Array.isArray(W)?W:[]).map((ge,me)=>{if(!ge)return null;const Ne=ge.day||`e-${te}-${me}`,Fe=Number(ge.level)||0,Te=d[Fe]||d[0];return o.jsx("span",{onMouseEnter:A=>K(A,ge),onMouseLeave:V,className:"rounded-[2px] transition-transform hover:scale-125 hover:z-10 cursor-pointer",style:{width:Se,height:Se,background:Te}},Ne)}))})]})]})}),!a&&o.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[o.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:y("heatmap.legend.less")}),o.jsx("div",{className:"flex gap-0.5",children:d.map((W,te)=>o.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:W}},te))}),o.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:y("heatmap.legend.more")})]}),w&&o.jsx("div",{onAnimationEnd:T,onClick:W=>{W.target===W.currentTarget&&E()},className:`fixed inset-0 z-50 flex items-center justify-center p-3 md:p-6 backdrop-blur-md bg-black/15 dark:bg-black/40 ${k?"animate-tt-fade-out":"animate-tt-fade-in"}`,children:o.jsxs("div",{className:`relative w-full max-w-6xl h-[88vh] backdrop-blur-2xl bg-white/90 dark:bg-oai-gray-900/90 border border-oai-gray-200/50 dark:border-white/10 shadow-2xl rounded-2xl flex flex-col md:flex-row overflow-hidden ${k?"animate-tt-modal-exit":"animate-tt-modal"}`,children:[o.jsx("button",{type:"button",onClick:E,className:"absolute top-4 right-4 z-50 p-2 rounded-full border border-oai-gray-200/60 dark:border-oai-gray-800/60 bg-white/50 dark:bg-oai-gray-900/50 text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white hover:rotate-90 hover:scale-105 active:scale-95 transition-all duration-300",children:o.jsx(sa,{size:16})}),o.jsxs("div",{className:"w-full md:w-[340px] border-b md:border-b-0 md:border-r border-zinc-200/50 dark:border-zinc-800/40 p-5 md:p-6 flex flex-col gap-6 overflow-y-auto backdrop-blur-md bg-zinc-50/50 dark:bg-zinc-950/50",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[o.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[o.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:M.rawColor}}),o.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5",style:{backgroundColor:M.rawColor}})]}),o.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono text-zinc-400 dark:text-zinc-500",children:"3D Insight"})]}),o.jsx("h4",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight leading-none mt-2 select-none",children:y("heatmap.3d.modal.title")}),o.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-400 dark:text-zinc-500 mt-2 font-normal select-none",children:y("heatmap.3d.modal.desc")})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-x-5 gap-y-5 border-y border-zinc-200/50 dark:border-zinc-800/50 py-5 select-none",children:[o.jsxs("div",{className:"flex flex-col gap-1 relative group cursor-help",children:[o.jsx("div",{className:"absolute left-0 bottom-full mb-2 pointer-events-none opacity-0 translate-y-1 group-hover:opacity-100 group-hover:translate-y-0 transition-all duration-200 z-50",children:o.jsxs("div",{className:"bg-white dark:bg-zinc-950 text-zinc-900 dark:text-zinc-50 text-[10px] font-semibold font-mono rounded-lg px-2.5 py-1.5 shadow-xl border border-zinc-200 dark:border-zinc-800/80 whitespace-nowrap flex flex-col",children:[o.jsx("span",{className:"text-[9px] text-zinc-400 dark:text-zinc-500",children:y("heatmap.3d.modal.stats.precision_total_tokens")}),o.jsxs("span",{className:"mt-0.5 font-bold text-zinc-900 dark:text-zinc-50",children:[Z.totalTokens.toLocaleString()," Tokens"]})]})}),o.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:y("heatmap.3d.modal.stats.total_tokens")}),o.jsxs("div",{className:"flex items-baseline gap-1.5",children:[o.jsx("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:Xa(Z.totalTokens)}),o.jsx("div",{className:"opacity-30 group-hover:opacity-60 transition-opacity",children:o.jsx("svg",{width:"24",height:"10",viewBox:"0 0 24 10",fill:"none",children:o.jsx("path",{d:"M1 9C3 7 5 7 7 4C9 1 11 0 13 2C15 4 17 0 23 0",stroke:M.rawColor,strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),o.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[o.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:y("heatmap.3d.modal.stats.estimated_cost")}),o.jsx("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:xe})]}),o.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[o.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:y("heatmap.3d.modal.stats.active_rate_days")}),o.jsxs("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[Z.activeRate,"% ",o.jsxs("span",{className:"text-[10px] font-bold text-zinc-400 dark:text-zinc-500 font-mono",children:["(",Z.activeDays,"D)"]})]})]}),o.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[o.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:y("heatmap.3d.modal.stats.max_streak")}),o.jsxs("span",{className:"text-xl font-black text-amber-500 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[Z.maxStreak," ",o.jsx("span",{className:"text-[10px] font-bold text-amber-500/80 font-mono",children:y("heatmap.3d.modal.stats.days_suffix")})]})]}),o.jsxs("div",{className:"flex flex-col gap-1 col-span-2 relative group cursor-help",children:[o.jsx("div",{className:"absolute left-0 bottom-full mb-2 pointer-events-none opacity-0 translate-y-1 group-hover:opacity-100 group-hover:translate-y-0 transition-all duration-200 z-50",children:o.jsxs("div",{className:"bg-white dark:bg-zinc-950 text-zinc-900 dark:text-zinc-50 text-[10px] font-semibold font-mono rounded-lg px-2.5 py-1.5 shadow-xl border border-zinc-200 dark:border-zinc-800/80 whitespace-nowrap flex flex-col",children:[o.jsx("span",{className:"text-[9px] text-zinc-400 dark:text-zinc-500",children:y("heatmap.3d.modal.stats.precision_peak_value")}),o.jsxs("span",{className:"mt-0.5 font-bold text-zinc-900 dark:text-zinc-50",children:[Z.maxSingleDay.value>0?Z.maxSingleDay.value.toLocaleString():y("heatmap.3d.modal.stats.no_data")," conversations"]}),o.jsx("span",{className:"text-[8px] text-zinc-400 dark:text-zinc-500 mt-0.5",children:Z.maxSingleDay.day!=="无数据"?Z.maxSingleDay.day:y("heatmap.3d.modal.stats.no_data")})]})}),o.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:y("heatmap.3d.modal.stats.peak_day")}),o.jsxs("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[Z.maxSingleDay.value>0?Xa(Z.maxSingleDay.value):y("heatmap.3d.modal.stats.no_data")," ",o.jsxs("span",{className:"text-[10px] font-bold text-zinc-400 dark:text-zinc-500 font-mono",children:["(",Z.maxSingleDay.day!=="无数据"?Z.maxSingleDay.day:y("heatmap.3d.modal.stats.no_data"),")"]})]})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5 py-1",children:[o.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[o.jsx(Kr,{size:11,style:{color:M.rawColor}}),o.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono",style:{color:M.rawColor},children:y(Z.aiEvaluationTitleKey)})]}),o.jsxs("div",{className:"pl-3.5 border-l-2 relative transition-all duration-300 group",style:{borderColor:M.rawColor},children:[o.jsx("div",{className:"absolute inset-y-0 left-0 w-[3px] blur-[2px] opacity-15 pointer-events-none rounded-full",style:{backgroundColor:M.rawColor}}),o.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-600 dark:text-zinc-400 font-normal",children:y(Z.aiEvaluationKey)})]})]}),o.jsx("div",{className:"mt-auto border-t border-zinc-200/50 dark:border-zinc-800/50 pt-4 select-none",children:o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:y("heatmap.3d.modal.legend.title")}),o.jsx("span",{className:"text-[10px] font-medium text-zinc-500 dark:text-zinc-400",children:y(`heatmap.3d.modal.palette.${P}`)})]}),o.jsx("div",{className:"flex gap-1",children:H.map((W,te)=>o.jsx("div",{className:"flex-1 h-1 rounded-[2px]",style:{backgroundColor:W},title:`Level ${te}`},te))})]})})]}),o.jsxs("div",{className:"flex-1 h-full relative flex items-center justify-center overflow-hidden p-4",children:[o.jsx("div",{className:"absolute top-1/4 left-1/3 w-96 h-96 rounded-full blur-[130px] pointer-events-none -translate-x-1/2 -translate-y-1/2 transition-all duration-500",style:{backgroundColor:M.rawColor+"15"}}),o.jsx("div",{className:"absolute bottom-1/4 right-1/3 w-80 h-80 rounded-full blur-[120px] pointer-events-none translate-x-1/2 translate-y-1/2 bg-purple-500/[0.04] dark:bg-purple-500/[0.08]"}),o.jsxs("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 flex items-center gap-3 p-1.5 backdrop-blur-md bg-white/70 dark:bg-oai-gray-900/75 border border-oai-gray-200/60 dark:border-oai-gray-800/80 rounded-full shadow-lg z-30 select-none",children:[o.jsx("div",{className:"flex items-center gap-1.5 px-2",children:Object.keys(b).map(W=>{const te=P===W;return o.jsx("button",{type:"button",onClick:()=>C(W),title:y(`heatmap.3d.modal.palette.${W}`),className:`w-3.5 h-3.5 rounded-full transition-all duration-200 relative hover:scale-125 ${W==="emerald"?"bg-[#10b981]":W==="ocean"?"bg-[#3b82f6]":W==="neon"?"bg-[#a855f7]":"bg-[#f59e0b]"}`,children:te&&o.jsx("span",{className:"absolute inset-0 rounded-full ring-2 ring-offset-1 ring-offset-white dark:ring-offset-oai-gray-900 ring-oai-gray-900 dark:ring-white scale-110"})},W)})}),o.jsx("div",{className:"w-[1px] h-4 bg-oai-gray-200 dark:bg-oai-gray-800"}),o.jsxs("div",{className:"flex items-center gap-1 pr-1",children:[o.jsx("button",{type:"button",onClick:()=>{const W=!D;j(W),L.current&&L.current.toggleAutoRotate(W)},title:D?y("heatmap.3d.modal.control.pause"):y("heatmap.3d.modal.control.play"),className:`p-1.5 rounded-full transition-all duration-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 ${D?M.accentText:"text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-250"}`,children:D?o.jsx(Wi,{size:12}):o.jsx(Ai,{size:12})}),o.jsx("button",{type:"button",onClick:()=>{j(!1),L.current&&L.current.reset()},title:y("heatmap.3d.modal.control.reset"),className:"p-1.5 rounded-full text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-250 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-all duration-200",children:o.jsx(Ri,{size:12})})]})]}),o.jsx(qa,{weeks:B,isDark:c,interactive:!0,palette:P,autoRotateInit:D,onResetViewRef:L}),o.jsxs("div",{className:"absolute bottom-4 right-4 flex items-center gap-1.5 text-[9px] font-bold text-oai-gray-400 bg-white/80 dark:bg-oai-gray-900/80 border border-oai-gray-200/50 dark:border-oai-gray-800/80 rounded-md px-2.5 py-1.5 select-none pointer-events-none backdrop-blur-md shadow-sm",children:[o.jsx(ca,{size:10,className:M.accentText}),o.jsx("span",{children:y("heatmap.3d.modal.footer.tip")})]})]})]})}),h&&!w&&typeof document<"u"&&ai.createPortal(o.jsxs("div",{className:"fixed z-[9999] w-0 h-0 transition-all duration-100 ease-out pointer-events-none",style:{left:`${p.x}px`,top:`${p.y}px`},children:[o.jsxs("div",{className:"absolute left-0 bottom-[10px] backdrop-blur-md bg-white/95 dark:bg-oai-gray-900/95 border border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-xl rounded-xl p-3.5 max-w-[280px] min-w-[200px] flex flex-col gap-2 animate-in fade-in zoom-in-95 duration-100",style:{transform:`translateX(calc(-50% + ${p.shiftX}px))`},children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-oai-gray-100 dark:border-oai-gray-800/80 pb-1.5",children:[o.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400",children:h.day}),(()=>{const W=h.level===0?c?"#9ca3af":"#6b7280":d[h.level];return o.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:W+"22",color:W,border:`1px solid ${W}44`},children:["Level ",h.level]})})()]}),o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsxs("div",{className:"flex flex-col gap-0.5",children:[o.jsxs("div",{className:"flex items-baseline gap-1",children:[o.jsx("span",{className:"text-lg font-bold text-oai-gray-900 dark:text-white leading-none tabular-nums",children:Number(h.value??0).toLocaleString()}),o.jsx("span",{className:"text-[10px] text-oai-gray-400 uppercase tracking-wider font-semibold",children:"Conversations"})]}),o.jsxs("div",{className:"flex items-baseline gap-1",children:[o.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400 leading-none tabular-nums",children:Number(h.total_tokens??0).toLocaleString()}),o.jsx("span",{className:"text-[9px] text-oai-gray-400 uppercase tracking-wider",children:"tokens"})]})]}),h.models&&Object.keys(h.models).length>0?o.jsxs("div",{className:"mt-1.5 border-t border-oai-gray-100 dark:border-oai-gray-800/60 pt-2 flex flex-col gap-1.5",children:[o.jsx("div",{className:"text-[10px] font-semibold text-oai-gray-400 dark:text-oai-gray-500 uppercase tracking-wider",children:"Model Breakdown"}),o.jsx("div",{className:"flex flex-col gap-2 max-h-[150px] overflow-y-auto pr-1.5 oai-scrollbar",children:Object.entries(h.models).map(([W,te])=>({name:W,val:Number(te)})).sort((W,te)=>te.val-W.val).map(({name:W,val:te})=>{const ge=Number(h.total_tokens??h.value)||1,me=Math.round(te/ge*100);return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center justify-between text-[11px] gap-3",children:[o.jsx("span",{className:"font-medium text-oai-gray-750 dark:text-oai-gray-200 truncate max-w-[120px]",title:W,children:W}),o.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[o.jsx("span",{className:"font-mono text-oai-gray-900 dark:text-oai-gray-100 font-semibold",children:te.toLocaleString()}),o.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[me,"%"]})]})]}),o.jsx("div",{className:"w-full h-1 bg-oai-gray-100 dark:bg-oai-gray-800/85 rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${me}%`,backgroundColor:d[4],boxShadow:`0 0 4px ${d[4]}55`}})})]},W)})})]}):o.jsx("p",{className:"text-[11px] text-oai-gray-600 dark:text-oai-gray-300 leading-relaxed font-normal mt-1 border-t border-dashed border-oai-gray-100 dark:border-oai-gray-800/60 pt-1.5",children:io(h.level,h.total_tokens??h.value)})]})]}),o.jsx("div",{className:"absolute bottom-[6px] left-0 -translate-x-1/2 w-2.5 h-2.5 rotate-45 bg-white dark:bg-oai-gray-900 border-r border-b border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-sm",style:{marginBottom:"1px"}})]}),document.body),o.jsx("style",{children:`
|
|
2
2
|
@keyframes tt-fade-in {
|
|
3
3
|
from { opacity: 0; }
|
|
4
4
|
to { opacity: 1; }
|
|
@@ -39,7 +39,7 @@ import{c as nn,i as Vs,f as Ar,a as Fr,J as qs,u as Rr,m as Xs,r as m,M as Ir,b
|
|
|
39
39
|
.animate-tt-modal-exit {
|
|
40
40
|
animation: tt-modal-exit 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
41
41
|
}
|
|
42
|
-
`})]})}function gc(e,t,n){if(!Number.isFinite(e))return y("shared.placeholder.short");const a=et(e,{decimals:2,currency:t,rate:n});return a==="-"?y("shared.placeholder.short"):a}function Ka(e,t,n){if(!Number.isFinite(e)||e<=0)return null;const a=ia(t);return(t===Yr?e:e*n)<.01?`<${a}0.01`:et(e,{decimals:2,currency:t,rate:n})}function Ga(e){const t=Number(e);return!Number.isFinite(t)||t<=0?null:Ae(t,{decimals:1})}const yc=R.memo(function({isOpen:t,onClose:n,fleetData:a=[]}){const{currency:r,rate:s}=_t(),l=m.useMemo(()=>(Array.isArray(a)?a:[]).map(c=>{const u=Le(c?.usd)??0,d=Le(c?.usage)??0,f=Array.isArray(c?.models)?c.models:[];return{label:c?.label?String(c.label):"",usdValue:u,costLabel:Ka(u,r,s),tokensLabel:Ga(d),models:f.map(h=>{const g=Le(h?.usage)??0,p=Le(h?.cost)??0;return{id:h?.id?String(h.id):"",name:h?.name?String(h.name):"",tokensLabel:Ga(g),costLabel:Ka(p,r,s),sortCost:p}}).filter(h=>h.costLabel||h.tokensLabel).sort((h,g)=>g.sortCost-h.sortCost)}}).filter(c=>c.usdValue>0||c.models.length>0).sort((c,u)=>u.usdValue-c.usdValue),[a,r,s]),i=m.useMemo(()=>{const c=l.reduce((u,d)=>u+d.usdValue,0);return gc(c,r,s)},[l,r,s]);return o.jsx(wi,{open:t,onOpenChange:c=>{c||n?.()},children:o.jsxs(vi,{children:[o.jsx(Ni,{className:"cost-modal-backdrop","data-cost-analysis-backdrop":"true"}),o.jsx(_i,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:o.jsxs(Mi,{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:[o.jsx(ji,{render:o.jsx("h2",{className:"sr-only"}),children:y("dashboard.cost_breakdown.title")}),o.jsx(Ui,{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":y("dashboard.cost_breakdown.close"),children:o.jsx(sa,{size:16,strokeWidth:2,"aria-hidden":!0})}),o.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto oai-scrollbar",children:o.jsxs("div",{className:"px-3 py-6",children:[o.jsx("p",{className:"text-label uppercase tracking-[0.12em] text-oai-gray-500 dark:text-oai-gray-400 mb-2",children:y("dashboard.cost_breakdown.total_label")}),o.jsx("p",{className:"font-bold text-oai-brand tabular-nums tracking-tight leading-none mb-6",style:{fontSize:"clamp(24px, 6.5vw, 32px)"},children:i}),l.length===0?o.jsx("p",{className:"text-body-sm text-oai-gray-500 dark:text-oai-gray-400",children:"No spend recorded."}):o.jsxs("div",{role:"table","aria-label":y("dashboard.cost_breakdown.title"),children:[o.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:[o.jsx("span",{role:"columnheader",children:"Model"}),o.jsx("span",{role:"columnheader",children:"Cost"})]}),l.map((c,u)=>{const d=`fleet-${u}`;return o.jsxs("div",{role:"rowgroup","aria-labelledby":d,className:u>0?"mt-5":"mt-2",children:[o.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-2",children:[o.jsx("span",{id:d,role:"rowheader",className:"flex-1 min-w-0 text-body-sm font-semibold text-oai-black dark:text-oai-white truncate leading-none",children:c.label}),o.jsx("span",{role:"cell",className:"shrink-0 text-body-sm font-semibold text-oai-black dark:text-oai-white tabular-nums leading-none",children:c.costLabel||"—"})]}),c.models.map((f,h)=>o.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-[5px]",children:[o.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:f.name,children:f.name}),o.jsx("span",{role:"cell",className:"shrink-0 text-caption text-oai-gray-700 dark:text-oai-gray-300 tabular-nums leading-none",children:f.costLabel||""})]},f.id||`${f.name}-${h}`))]},`${c.label}-${u}`)})]})]})})]})})]})})});function pc(e){if(typeof e!="string")return{owner:"",repo:""};const[t,n]=e.split("/");return{owner:t||"",repo:n||""}}function bc({projectKey:e,projectRef:t}){const[n,a]=m.useState(!1),r=typeof t=="string"?t.replace("https://github.com/",""):"",{owner:s,repo:l}=pc(e||r),i=s&&l?`${s}/${l}`:e,c=s&&!n?`https://github.com/${s}.png?size=80`:"";return c?o.jsx("img",{src:c,alt:"",className:"w-8 h-8 rounded-md oai-bg-elevated object-cover",onError:()=>a(!0)}):o.jsx("div",{className:"w-8 h-8 rounded-md oai-bg-elevated flex items-center justify-center text-oai-gray-500 dark:text-oai-gray-300",children:o.jsx(la,{provider:i,size:20})})}function xc({projectEntries:e=[],projectLimit:t=3,onProjectLimitChange:n,copy:a,hasDetailsActual:r,dailyEmptyPrefix:s,installSyncCmd:l,dailyEmptySuffix:i,detailsColumns:c,ariaSortFor:u,toggleSort:d,sortIconFor:f,pagedDetails:h,dailyBreakdownRows:g=[],dailyBreakdownColumns:p=[],dailyBreakdownAriaSortFor:k,dailyBreakdownSortIconFor:v,dailyBreakdownDateKey:w="day",detailsDateKey:N,renderDetailDate:x,renderDailyBreakdownDate:M,renderDetailCell:T,DETAILS_PAGED_PERIODS:j,period:L,detailsPageCount:P,detailsPage:C,setDetailsPage:I}){const[K,V]=m.useState("daily");function $(D,b,_){return _===0?"text-oai-gray-500 dark:text-oai-gray-300":b.key==="total_tokens"||b.key==="total_cost_usd"?"font-medium text-oai-black dark:text-oai-white tabular-nums":b.key==="cost_per_million_tokens"&&D?.cost_per_million_status==="high"?"font-semibold text-amber-700 dark:text-amber-300 tabular-nums":b.key==="top_model"?"text-oai-gray-600 dark:text-oai-gray-300":"text-oai-gray-600 dark:text-oai-gray-300 tabular-nums"}function E(D,b,_){return _===0?M?M(D):x(D):T(D,b.key)}return o.jsxs(rn,{children:[o.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[o.jsxs("div",{role:"tablist","aria-label":"Data view",className:"flex gap-1",children:[o.jsx("button",{role:"tab","aria-selected":K==="daily",type:"button",onClick:()=>V("daily"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${K==="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:a("dashboard.daily.title")}),o.jsx("button",{role:"tab","aria-selected":K==="projects",type:"button",onClick:()=>V("projects"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${K==="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:a("dashboard.projects.title")})]}),K==="projects"&&o.jsx(Ci,{ariaLabel:a("dashboard.projects.limit_aria"),value:t,onValueChange:D=>n?.(Number(D)),options:[{value:3,label:a("dashboard.projects.limit_top_3")},{value:6,label:a("dashboard.projects.limit_top_6")},{value:10,label:a("dashboard.projects.limit_top_10")}],align:"end",className:"px-2 py-1 text-xs text-oai-gray-600 dark:text-oai-gray-300"})]}),K==="projects"&&o.jsx("div",{className:"space-y-1",children:e.slice(0,t).map((D,b)=>{const _=typeof D?.project_ref=="string"?D.project_ref:"",H=D?.project_key||_||`entry-${b}`,S=D?.billable_total_tokens??D?.total_tokens,X=Number(S),F=Number.isFinite(X)?X.toLocaleString():"—",z=D?.project_key||_.split("/").pop()||"—";return o.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg",children:[o.jsx(bc,{projectKey:D?.project_key,projectRef:_}),o.jsx("div",{className:"min-w-0 flex-1",children:o.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white truncate",children:z})}),o.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",children:F})]},H)})}),K==="daily"&&o.jsxs("div",{children:[g?.length===0?o.jsxs("div",{className:"oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300 mb-4",children:[s,o.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:l}),i]}):o.jsx("div",{className:"overflow-auto max-h-[384px] -mx-4 oai-scrollbar",children:o.jsxs("table",{className:"w-full border-collapse",children:[o.jsx("thead",{className:"sticky top-0 z-10",children:o.jsx("tr",{className:"border-b border-oai-gray-200 dark:border-oai-gray-700",children:p.map((D,b)=>o.jsx("th",{...k?.(D.key)?{"aria-sort":k(D.key)}:{},className:"text-left p-0 bg-white dark:bg-oai-gray-900",children:o.jsx("button",{type:"button",onClick:()=>d(D.key),className:"flex w-full items-center justify-start px-2.5 sm: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:o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx("span",{children:D.label}),o.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-400",children:v?.(D.key)||""})]})})},D.key))})}),o.jsx("tbody",{children:g.map(D=>o.jsx("tr",{className:`border-b border-oai-gray-100 dark:border-oai-gray-800 last:border-b-0 odd:bg-transparent even:bg-oai-gray-50/55 dark:odd:bg-transparent dark:even:bg-white/[0.035] hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/70 transition-colors ${D.missing?"text-oai-gray-400 dark:text-oai-gray-400":D.future?"text-oai-gray-300 dark:text-oai-gray-600":"text-oai-black dark:text-oai-white"}`,children:p.map((b,_)=>o.jsx("td",{className:`px-2.5 sm:px-4 py-2 oai-text-body-sm whitespace-nowrap ${$(D,b,_)}`,children:E(D,b,_)},b.key))},String(D?.[w]||D?.day||D?.hour||D?.month||"")))})]})}),K!=="daily"&&j.has(L)&&P>1?o.jsxs("div",{className:"mt-3 flex items-center justify-between oai-text-caption",children:[o.jsx("button",{type:"button",onClick:()=>I(D=>Math.max(0,D-1)),disabled:C===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:a("details.pagination.prev")}),o.jsxs("span",{className:"oai-text-muted",children:[C+1," / ",P]}),o.jsx("button",{type:"button",onClick:()=>I(D=>Math.min(P-1,D+1)),disabled:C+1>=P,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:a("details.pagination.next")})]}):null]})]})}function kn(e){return typeof e!="string"?"":e.trim()}function Qa(e){const t=kn(e);return t?t.split(/[_\-\s]+/).filter(Boolean).map(n=>n.slice(0,1).toUpperCase()+n.slice(1).toLowerCase()).join(" "):""}function kc(e){if(!Array.isArray(e))return[];const t=new Map;for(const n of e){if(!n||typeof n!="object")continue;const a=kn(n.tool),r=kn(n.planType)||kn(n.plan_type);if(!a||!r)continue;const s=Qa(a)||a,l=Qa(r)||r;t.set(`${a.toLowerCase()}::${r.toLowerCase()}`,{tool:s,plan:l})}return Array.from(t.values())}function Ja({rankLabel:e,streakDays:t,subscriptions:n=[],className:a=""}){const r=e??y("identity_card.rank_placeholder"),s=Number.isFinite(Number(t))?Number(t):0,l=s?y("identity_card.streak_value",{days:s}):y("identity_card.rank_placeholder"),i=kc(n);return o.jsxs(rn,{className:`h-full ${a}`,children:[i.length>0&&o.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map((c,u)=>o.jsxs(Hi,{variant:"secondary",size:"sm",children:[c.tool," ",c.plan]},`${c.tool}:${c.plan}:${u}`))}),o.jsxs("div",{className:`${i.length>0?"mt-3 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:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{children:y("identity_card.rank_label")}),o.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:r})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{children:y("identity_card.streak_label")}),o.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:l})]})]})]})}const Za=2,wc=.75,vc=.005;function Nc(e,t){if(!(typeof e=="number"&&Number.isFinite(e)))return{hasBar:!1,side:null,widthPct:0,tone:null,labelText:"—",arrow:null};if(Math.abs(e)<vc)return{hasBar:!1,side:null,widthPct:0,tone:null,labelText:"0%",arrow:null};const a=e>0,r=Math.min(Math.abs(e),Za)/Za*50;let s;t==="price"?s=a?"bad":"good":s=Math.abs(e)>=wc?"neutral-strong":"neutral";const l=Math.abs(Math.round(e*100));return{hasBar:!0,side:a?"up":"down",widthPct:r,tone:s,labelText:`${a?"+":"−"}${l}%`,arrow:t==="price"?a?"▲":"▼":null}}function _c(e){switch(e){case"neutral":return"var(--pulse-neutral)";case"neutral-strong":return"var(--pulse-neutral-strong)";case"good":return"var(--pulse-good)";case"bad":return"var(--pulse-bad)";default:return null}}const Mc={thousandSuffix:"K",millionSuffix:"M",billionSuffix:"B"},jc=e=>e==null?"—":Ae(e,Mc),Sc=e=>e==null?"—":et(e,{decimals:e>=100?0:2}),Cc=e=>e==null?"—":et(e,{decimals:2}),Dc=[{key:"tokens",label:"Tokens",kind:"usage",format:jc},{key:"cost",label:"Cost",kind:"usage",format:Sc},{key:"perMTok",label:"$/MTok",kind:"price",format:Cc}];function Tc({label:e,delta:t,kind:n}){const a=Nc(t,n),r=_c(a.tone),s=a.side==="up"?{left:"50%",width:`${a.widthPct}%`,background:r}:{right:"50%",width:`${a.widthPct}%`,background:r};return o.jsxs("div",{className:"grid grid-cols-[2.3rem_1fr_3rem] items-center gap-2",children:[o.jsx("span",{className:"text-[8.5px] uppercase tracking-wide text-oai-gray-400 dark:text-oai-gray-400 text-right",children:e}),o.jsxs("span",{className:"pulse-devtrack",children:[o.jsx("span",{className:"pulse-devtick"}),a.hasBar?o.jsx("span",{className:"pulse-devbar",style:s}):null]}),o.jsxs("span",{className:"flex items-center justify-end gap-1 text-[10.5px] font-bold tabular-nums text-right text-oai-gray-600 dark:text-oai-gray-300",children:[a.arrow?o.jsx("span",{className:"text-[8px]",style:{color:r},children:a.arrow}):null,o.jsx("span",{children:a.labelText})]})]})}function Pc({ratio:e}){const t=Math.min(Math.max(e,0),2)/2*100;return o.jsxs("div",{className:"mt-2.5",children:[o.jsxs("div",{className:"flex items-baseline justify-between mb-1",children:[o.jsx("span",{className:"text-[8.5px] uppercase tracking-wide text-oai-gray-400 dark:text-oai-gray-400",children:"of a normal day"}),o.jsxs("span",{className:"text-[11px] font-bold tabular-nums text-oai-brand-600 dark:text-oai-brand-light",children:[e.toFixed(1),"×"]})]}),o.jsxs("div",{className:"relative h-[7px] rounded-full",style:{background:"var(--pulse-track)"},children:[o.jsx("div",{className:"absolute left-0 top-0 bottom-0 rounded-full bg-gradient-to-r from-oai-brand-500 to-oai-brand-light",style:{width:`${t}%`}}),o.jsx("div",{className:"absolute -top-[3px] -bottom-[3px] w-[2px] rounded-full",style:{left:"50%",background:"var(--pulse-tick)"},"aria-hidden":"true"})]})]})}function Oc({pulse:e,period:t,comparedAtLabel:n,className:a=""}){if(!e)return null;const r=t==="day"||t==="24h",s=t==="month"?"prev 30d":"prev 7d",l=r?[{label:"yest",field:"deltaVsPrev"},{label:"7d avg",field:"deltaVsAvg"}]:[{label:s,field:"deltaVsPrev"}],i=r?"vs yest · 7d avg":`vs ${s}`,c=r?`same time of day${n?` · ${n}`:""}`:`same elapsed vs ${s}`;return o.jsxs("div",{className:`pulse-card h-full flex flex-col gap-1.5 ${a}`,children:[o.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[o.jsx("span",{className:"text-[10.5px] font-bold uppercase tracking-[0.16em] text-oai-brand-600 dark:text-oai-brand-light",children:"Today's pulse"}),o.jsx("span",{className:"text-[9px] text-oai-gray-400 dark:text-oai-gray-400 tracking-wide",children:i})]}),Dc.map(u=>{const d=e[u.key]||{},f=typeof d.progress=="number"&&Number.isFinite(d.progress);return o.jsxs("div",{className:"py-2 border-b border-dashed border-oai-gray-200/40 dark:border-oai-gray-700/50 last:border-b-0",children:[o.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[o.jsx("span",{className:"text-[11px] uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:u.label}),o.jsx("span",{className:"text-xl font-bold text-oai-black dark:text-oai-white tabular-nums truncate",children:u.format(d.value)})]}),o.jsx("div",{className:"mt-2 flex flex-col gap-1.5",children:l.map(h=>o.jsx(Tc,{label:h.label,delta:d[h.field],kind:u.kind},h.field))}),f?o.jsx(Pc,{ratio:d.progress}):null]},u.key)}),o.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-oai-gray-400 dark:text-oai-gray-400 pt-0.5",children:[o.jsx("span",{"aria-hidden":"true",children:"⌚"}),o.jsx("span",{children:c})]})]})}function $c(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}const Wc={},Kt={};function Tt(e,t){try{const a=(Wc[e]||=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format)(t).split("GMT")[1];return a in Kt?Kt[a]:er(a,a.split(":"))}catch{if(e in Kt)return Kt[e];const n=e?.match(Ec);return n?er(e,n.slice(1)):NaN}}const Ec=/([+-]\d\d):?(\d\d)?/;function er(e,t){const n=+(t[0]||0),a=+(t[1]||0),r=+(t[2]||0)/60;return Kt[e]=n*60+a>0?n*60+a+r:n*60-a-r}class ot extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(Tt(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),co(this),aa(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new ot(...n,t):new ot(Date.now(),t)}withTimeZone(t){return new ot(+this,t)}getTimezoneOffset(){const t=-Tt(this.timeZone,this);return t>0?Math.floor(t):Math.ceil(t)}setTime(t){return Date.prototype.setTime.apply(this,arguments),aa(this),+this}[Symbol.for("constructDateFrom")](t){return new ot(+new Date(t),this.timeZone)}}const tr=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!tr.test(e))return;const t=e.replace(tr,"$1UTC");ot.prototype[t]&&(e.startsWith("get")?ot.prototype[e]=function(){return this.internal[t]()}:(ot.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),Ac(this),+this},ot.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),aa(this),+this}))});function aa(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-Tt(e.timeZone,e)*60))}function Ac(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),co(e)}function co(e){const t=Tt(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),a=new Date(+e);a.setUTCHours(a.getUTCHours()-1);const r=-new Date(+e).getTimezoneOffset(),s=-new Date(+a).getTimezoneOffset(),l=r-s,i=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();l&&i&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+l);const c=r-n;c&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+c);const u=new Date(+e);u.setUTCSeconds(0);const d=r>0?u.getSeconds():(u.getSeconds()-60)%60,f=Math.round(-(Tt(e.timeZone,e)*60))%60;(f||d)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+f),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+f+d));const h=Tt(e.timeZone,e),g=h>0?Math.floor(h):Math.ceil(h),k=-new Date(+e).getTimezoneOffset()-g,v=g!==n,w=k-c;if(v&&w){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+w);const N=Tt(e.timeZone,e),x=N>0?Math.floor(N):Math.ceil(N),M=g-x;M&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+M),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+M))}}class Ie extends ot{static tz(t,...n){return n.length?new Ie(...n,t):new Ie(Date.now(),t)}toISOString(){const[t,n,a]=this.tzComponents(),r=`${t}${n}:${a}`;return this.internal.toISOString().slice(0,-1)+r}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,n,a,r]=this.internal.toUTCString().split(" ");return`${t?.slice(0,-1)} ${a} ${n} ${r}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[n,a,r]=this.tzComponents();return`${t} GMT${n}${a}${r} (${$c(this.timeZone,this)})`}toLocaleString(t,n){return Date.prototype.toLocaleString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleDateString(t,n){return Date.prototype.toLocaleDateString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleTimeString(t,n){return Date.prototype.toLocaleTimeString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),n=t>0?"-":"+",a=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),r=String(Math.abs(t)%60).padStart(2,"0");return[n,a,r]}withTimeZone(t){return new Ie(+this,t)}[Symbol.for("constructDateFrom")](t){return new Ie(+new Date(t),this.timeZone)}}const uo=6048e5,Fc=864e5,nr=Symbol.for("constructDateFrom");function Oe(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&nr in e?e[nr](t):e instanceof Date?new e.constructor(t):new Date(t)}function ke(e,t){return Oe(t||e,e)}function fo(e,t,n){const a=ke(e,n?.in);return isNaN(t)?Oe(e,NaN):(t&&a.setDate(a.getDate()+t),a)}function mo(e,t,n){const a=ke(e,n?.in);if(isNaN(t))return Oe(e,NaN);if(!t)return a;const r=a.getDate(),s=Oe(e,a.getTime());s.setMonth(a.getMonth()+t+1,0);const l=s.getDate();return r>=l?s:(a.setFullYear(s.getFullYear(),s.getMonth(),r),a)}let Rc={};function sn(){return Rc}function Nt(e,t){const n=sn(),a=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=ke(e,t?.in),s=r.getDay(),l=(s<a?7:0)+s-a;return r.setDate(r.getDate()-l),r.setHours(0,0,0,0),r}function en(e,t){return Nt(e,{...t,weekStartsOn:1})}function ho(e,t){const n=ke(e,t?.in),a=n.getFullYear(),r=Oe(n,0);r.setFullYear(a+1,0,4),r.setHours(0,0,0,0);const s=en(r),l=Oe(n,0);l.setFullYear(a,0,4),l.setHours(0,0,0,0);const i=en(l);return n.getTime()>=s.getTime()?a+1:n.getTime()>=i.getTime()?a:a-1}function ar(e){const t=ke(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function Pt(e,...t){const n=Oe.bind(null,e||t.find(a=>typeof a=="object"));return t.map(n)}function tn(e,t){const n=ke(e,t?.in);return n.setHours(0,0,0,0),n}function fa(e,t,n){const[a,r]=Pt(n?.in,e,t),s=tn(a),l=tn(r),i=+s-ar(s),c=+l-ar(l);return Math.round((i-c)/Fc)}function Ic(e,t){const n=ho(e,t),a=Oe(e,0);return a.setFullYear(n,0,4),a.setHours(0,0,0,0),en(a)}function Lc(e,t,n){return fo(e,t*7,n)}function Yc(e,t,n){return mo(e,t*12,n)}function zc(e,t){let n,a=t?.in;return e.forEach(r=>{!a&&typeof r=="object"&&(a=Oe.bind(null,r));const s=ke(r,a);(!n||n<s||isNaN(+s))&&(n=s)}),Oe(a,n||NaN)}function Bc(e,t){let n,a=t?.in;return e.forEach(r=>{!a&&typeof r=="object"&&(a=Oe.bind(null,r));const s=ke(r,a);(!n||n>s||isNaN(+s))&&(n=s)}),Oe(a,n||NaN)}function Hc(e,t,n){const[a,r]=Pt(n?.in,e,t);return+tn(a)==+tn(r)}function go(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Uc(e){return!(!go(e)&&typeof e!="number"||isNaN(+ke(e)))}function yo(e,t,n){const[a,r]=Pt(n?.in,e,t),s=a.getFullYear()-r.getFullYear(),l=a.getMonth()-r.getMonth();return s*12+l}function Vc(e,t){const n=ke(e,t?.in),a=n.getMonth();return n.setFullYear(n.getFullYear(),a+1,0),n.setHours(23,59,59,999),n}function po(e,t){const[n,a]=Pt(e,t.start,t.end);return{start:n,end:a}}function qc(e,t){const{start:n,end:a}=po(t?.in,e);let r=+n>+a;const s=r?+n:+a,l=r?a:n;l.setHours(0,0,0,0),l.setDate(1);let i=1;const c=[];for(;+l<=s;)c.push(Oe(n,l)),l.setMonth(l.getMonth()+i);return r?c.reverse():c}function Xc(e,t){const n=ke(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function Kc(e,t){const n=ke(e,t?.in),a=n.getFullYear();return n.setFullYear(a+1,0,0),n.setHours(23,59,59,999),n}function bo(e,t){const n=ke(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Gc(e,t){const{start:n,end:a}=po(t?.in,e);let r=+n>+a;const s=r?+n:+a,l=r?a:n;l.setHours(0,0,0,0),l.setMonth(0,1);let i=1;const c=[];for(;+l<=s;)c.push(Oe(n,l)),l.setFullYear(l.getFullYear()+i);return r?c.reverse():c}function xo(e,t){const n=sn(),a=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=ke(e,t?.in),s=r.getDay(),l=(s<a?-7:0)+6-(s-a);return r.setDate(r.getDate()+l),r.setHours(23,59,59,999),r}function Qc(e,t){return xo(e,{...t,weekStartsOn:1})}const Jc={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"}},Zc=(e,t,n)=>{let a;const r=Jc[e];return typeof r=="string"?a=r:t===1?a=r.one:a=r.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+a:a+" ago":a};function Ye(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const ed={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},td={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},nd={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ad={date:Ye({formats:ed,defaultWidth:"full"}),time:Ye({formats:td,defaultWidth:"full"}),dateTime:Ye({formats:nd,defaultWidth:"full"})},rd={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},od=(e,t,n,a)=>rd[e];function we(e){return(t,n)=>{const a=n?.context?String(n.context):"standalone";let r;if(a==="formatting"&&e.formattingValues){const l=e.defaultFormattingWidth||e.defaultWidth,i=n?.width?String(n.width):l;r=e.formattingValues[i]||e.formattingValues[l]}else{const l=e.defaultWidth,i=n?.width?String(n.width):e.defaultWidth;r=e.values[i]||e.values[l]}const s=e.argumentCallback?e.argumentCallback(t):t;return r[s]}}const sd={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},id={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},ld={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"]},cd={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"]},dd={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"}},ud={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"}},fd=(e,t)=>{const n=Number(e),a=n%100;if(a>20||a<10)switch(a%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},md={ordinalNumber:fd,era:we({values:sd,defaultWidth:"wide"}),quarter:we({values:id,defaultWidth:"wide",argumentCallback:e=>e-1}),month:we({values:ld,defaultWidth:"wide"}),day:we({values:cd,defaultWidth:"wide"}),dayPeriod:we({values:dd,defaultWidth:"wide",formattingValues:ud,defaultFormattingWidth:"wide"})};function ve(e){return(t,n={})=>{const a=n.width,r=a&&e.matchPatterns[a]||e.matchPatterns[e.defaultMatchWidth],s=t.match(r);if(!s)return null;const l=s[0],i=a&&e.parsePatterns[a]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(i)?gd(i,f=>f.test(l)):hd(i,f=>f.test(l));let u;u=e.valueCallback?e.valueCallback(c):c,u=n.valueCallback?n.valueCallback(u):u;const d=t.slice(l.length);return{value:u,rest:d}}}function hd(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function gd(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function ln(e){return(t,n={})=>{const a=t.match(e.matchPattern);if(!a)return null;const r=a[0],s=t.match(e.parsePattern);if(!s)return null;let l=e.valueCallback?e.valueCallback(s[0]):s[0];l=n.valueCallback?n.valueCallback(l):l;const i=t.slice(r.length);return{value:l,rest:i}}}const yd=/^(\d+)(th|st|nd|rd)?/i,pd=/\d+/i,bd={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},xd={any:[/^b/i,/^(a|c)/i]},kd={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},wd={any:[/1/i,/2/i,/3/i,/4/i]},vd={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},Nd={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]},_d={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},Md={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]},jd={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},Sd={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}},Cd={ordinalNumber:ln({matchPattern:yd,parsePattern:pd,valueCallback:e=>parseInt(e,10)}),era:ve({matchPatterns:bd,defaultMatchWidth:"wide",parsePatterns:xd,defaultParseWidth:"any"}),quarter:ve({matchPatterns:kd,defaultMatchWidth:"wide",parsePatterns:wd,defaultParseWidth:"any",valueCallback:e=>e+1}),month:ve({matchPatterns:vd,defaultMatchWidth:"wide",parsePatterns:Nd,defaultParseWidth:"any"}),day:ve({matchPatterns:_d,defaultMatchWidth:"wide",parsePatterns:Md,defaultParseWidth:"any"}),dayPeriod:ve({matchPatterns:jd,defaultMatchWidth:"any",parsePatterns:Sd,defaultParseWidth:"any"})},vt={code:"en-US",formatDistance:Zc,formatLong:ad,formatRelative:od,localize:md,match:Cd,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Dd(e,t){const n=ke(e,t?.in);return fa(n,bo(n))+1}function ma(e,t){const n=ke(e,t?.in),a=+en(n)-+Ic(n);return Math.round(a/uo)+1}function ko(e,t){const n=ke(e,t?.in),a=n.getFullYear(),r=sn(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,l=Oe(t?.in||e,0);l.setFullYear(a+1,0,s),l.setHours(0,0,0,0);const i=Nt(l,t),c=Oe(t?.in||e,0);c.setFullYear(a,0,s),c.setHours(0,0,0,0);const u=Nt(c,t);return+n>=+i?a+1:+n>=+u?a:a-1}function Td(e,t){const n=sn(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,r=ko(e,t),s=Oe(t?.in||e,0);return s.setFullYear(r,0,a),s.setHours(0,0,0,0),Nt(s,t)}function ha(e,t){const n=ke(e,t?.in),a=+Nt(n,t)-+Td(n,t);return Math.round(a/uo)+1}function be(e,t){const n=e<0?"-":"",a=Math.abs(e).toString().padStart(t,"0");return n+a}const kt={y(e,t){const n=e.getFullYear(),a=n>0?n:1-n;return be(t==="yy"?a%100:a,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):be(n+1,2)},d(e,t){return be(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){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(e,t){return be(e.getHours()%12||12,t.length)},H(e,t){return be(e.getHours(),t.length)},m(e,t){return be(e.getMinutes(),t.length)},s(e,t){return be(e.getSeconds(),t.length)},S(e,t){const n=t.length,a=e.getMilliseconds(),r=Math.trunc(a*Math.pow(10,n-3));return be(r,t.length)}},Et={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},rr={G:function(e,t,n){const a=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(a,{width:"abbreviated"});case"GGGGG":return n.era(a,{width:"narrow"});default:return n.era(a,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const a=e.getFullYear(),r=a>0?a:1-a;return n.ordinalNumber(r,{unit:"year"})}return kt.y(e,t)},Y:function(e,t,n,a){const r=ko(e,a),s=r>0?r:1-r;if(t==="YY"){const l=s%100;return be(l,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):be(s,t.length)},R:function(e,t){const n=ho(e);return be(n,t.length)},u:function(e,t){const n=e.getFullYear();return be(n,t.length)},Q:function(e,t,n){const a=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(a);case"QQ":return be(a,2);case"Qo":return n.ordinalNumber(a,{unit:"quarter"});case"QQQ":return n.quarter(a,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(a,{width:"narrow",context:"formatting"});default:return n.quarter(a,{width:"wide",context:"formatting"})}},q:function(e,t,n){const a=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(a);case"qq":return be(a,2);case"qo":return n.ordinalNumber(a,{unit:"quarter"});case"qqq":return n.quarter(a,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(a,{width:"narrow",context:"standalone"});default:return n.quarter(a,{width:"wide",context:"standalone"})}},M:function(e,t,n){const a=e.getMonth();switch(t){case"M":case"MM":return kt.M(e,t);case"Mo":return n.ordinalNumber(a+1,{unit:"month"});case"MMM":return n.month(a,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(a,{width:"narrow",context:"formatting"});default:return n.month(a,{width:"wide",context:"formatting"})}},L:function(e,t,n){const a=e.getMonth();switch(t){case"L":return String(a+1);case"LL":return be(a+1,2);case"Lo":return n.ordinalNumber(a+1,{unit:"month"});case"LLL":return n.month(a,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(a,{width:"narrow",context:"standalone"});default:return n.month(a,{width:"wide",context:"standalone"})}},w:function(e,t,n,a){const r=ha(e,a);return t==="wo"?n.ordinalNumber(r,{unit:"week"}):be(r,t.length)},I:function(e,t,n){const a=ma(e);return t==="Io"?n.ordinalNumber(a,{unit:"week"}):be(a,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):kt.d(e,t)},D:function(e,t,n){const a=Dd(e);return t==="Do"?n.ordinalNumber(a,{unit:"dayOfYear"}):be(a,t.length)},E:function(e,t,n){const a=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(a,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(a,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(a,{width:"short",context:"formatting"});default:return n.day(a,{width:"wide",context:"formatting"})}},e:function(e,t,n,a){const r=e.getDay(),s=(r-a.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return be(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});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"})}},c:function(e,t,n,a){const r=e.getDay(),s=(r-a.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return be(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(r,{width:"narrow",context:"standalone"});case"cccccc":return n.day(r,{width:"short",context:"standalone"});default:return n.day(r,{width:"wide",context:"standalone"})}},i:function(e,t,n){const a=e.getDay(),r=a===0?7:a;switch(t){case"i":return String(r);case"ii":return be(r,t.length);case"io":return n.ordinalNumber(r,{unit:"day"});case"iii":return n.day(a,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(a,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(a,{width:"short",context:"formatting"});default:return n.day(a,{width:"wide",context:"formatting"})}},a:function(e,t,n){const r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},b:function(e,t,n){const a=e.getHours();let r;switch(a===12?r=Et.noon:a===0?r=Et.midnight:r=a/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(e,t,n){const a=e.getHours();let r;switch(a>=17?r=Et.evening:a>=12?r=Et.afternoon:a>=4?r=Et.morning:r=Et.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let a=e.getHours()%12;return a===0&&(a=12),n.ordinalNumber(a,{unit:"hour"})}return kt.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):kt.H(e,t)},K:function(e,t,n){const a=e.getHours()%12;return t==="Ko"?n.ordinalNumber(a,{unit:"hour"}):be(a,t.length)},k:function(e,t,n){let a=e.getHours();return a===0&&(a=24),t==="ko"?n.ordinalNumber(a,{unit:"hour"}):be(a,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):kt.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):kt.s(e,t)},S:function(e,t){return kt.S(e,t)},X:function(e,t,n){const a=e.getTimezoneOffset();if(a===0)return"Z";switch(t){case"X":return sr(a);case"XXXX":case"XX":return Dt(a);default:return Dt(a,":")}},x:function(e,t,n){const a=e.getTimezoneOffset();switch(t){case"x":return sr(a);case"xxxx":case"xx":return Dt(a);default:return Dt(a,":")}},O:function(e,t,n){const a=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+or(a,":");default:return"GMT"+Dt(a,":")}},z:function(e,t,n){const a=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+or(a,":");default:return"GMT"+Dt(a,":")}},t:function(e,t,n){const a=Math.trunc(+e/1e3);return be(a,t.length)},T:function(e,t,n){return be(+e,t.length)}};function or(e,t=""){const n=e>0?"-":"+",a=Math.abs(e),r=Math.trunc(a/60),s=a%60;return s===0?n+String(r):n+String(r)+t+be(s,2)}function sr(e,t){return e%60===0?(e>0?"-":"+")+be(Math.abs(e)/60,2):Dt(e,t)}function Dt(e,t=""){const n=e>0?"-":"+",a=Math.abs(e),r=be(Math.trunc(a/60),2),s=be(a%60,2);return n+r+t+s}const ir=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},wo=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},Pd=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],a=n[1],r=n[2];if(!r)return ir(e,t);let s;switch(a){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",ir(a,t)).replace("{{time}}",wo(r,t))},Od={p:wo,P:Pd},$d=/^D+$/,Wd=/^Y+$/,Ed=["D","DD","YY","YYYY"];function Ad(e){return $d.test(e)}function Fd(e){return Wd.test(e)}function Rd(e,t,n){const a=Id(e,t,n);if(console.warn(a),Ed.includes(e))throw new RangeError(a)}function Id(e,t,n){const a=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${a} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Ld=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Yd=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,zd=/^'([^]*?)'?$/,Bd=/''/g,Hd=/[a-zA-Z]/;function st(e,t,n){const a=sn(),r=n?.locale??a.locale??vt,s=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,l=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0,i=ke(e,n?.in);if(!Uc(i))throw new RangeError("Invalid time value");let c=t.match(Yd).map(d=>{const f=d[0];if(f==="p"||f==="P"){const h=Od[f];return h(d,r.formatLong)}return d}).join("").match(Ld).map(d=>{if(d==="''")return{isToken:!1,value:"'"};const f=d[0];if(f==="'")return{isToken:!1,value:Ud(d)};if(rr[f])return{isToken:!0,value:d};if(f.match(Hd))throw new RangeError("Format string contains an unescaped latin alphabet character `"+f+"`");return{isToken:!1,value:d}});r.localize.preprocessor&&(c=r.localize.preprocessor(i,c));const u={firstWeekContainsDate:s,weekStartsOn:l,locale:r};return c.map(d=>{if(!d.isToken)return d.value;const f=d.value;(!n?.useAdditionalWeekYearTokens&&Fd(f)||!n?.useAdditionalDayOfYearTokens&&Ad(f))&&Rd(f,t,String(e));const h=rr[f[0]];return h(i,f,r.localize,u)}).join("")}function Ud(e){const t=e.match(zd);return t?t[1].replace(Bd,"'"):e}function Vd(e,t){const n=ke(e,t?.in),a=n.getFullYear(),r=n.getMonth(),s=Oe(n,0);return s.setFullYear(a,r+1,0),s.setHours(0,0,0,0),s.getDate()}function qd(e,t){return ke(e,t?.in).getMonth()}function Xd(e,t){return ke(e,t?.in).getFullYear()}function Kd(e,t){return+ke(e)>+ke(t)}function Gd(e,t){return+ke(e)<+ke(t)}function Qd(e,t,n){const[a,r]=Pt(n?.in,e,t);return+Nt(a,n)==+Nt(r,n)}function Jd(e,t,n){const[a,r]=Pt(n?.in,e,t);return a.getFullYear()===r.getFullYear()&&a.getMonth()===r.getMonth()}function Zd(e,t,n){const[a,r]=Pt(n?.in,e,t);return a.getFullYear()===r.getFullYear()}function eu(e,t,n){const a=ke(e,n?.in),r=a.getFullYear(),s=a.getDate(),l=Oe(e,0);l.setFullYear(r,t,15),l.setHours(0,0,0,0);const i=Vd(l);return a.setMonth(t,Math.min(s,i)),a}function tu(e,t,n){const a=ke(e,n?.in);return isNaN(+a)?Oe(e,NaN):(a.setFullYear(t),a)}const lr=5,nu=4;function au(e,t){const n=t.startOfMonth(e),a=n.getDay()>0?n.getDay():7,r=t.addDays(e,-a+1),s=t.addDays(r,lr*7-1);return t.getMonth(e)===t.getMonth(s)?lr:nu}function vo(e,t){const n=t.startOfMonth(e),a=n.getDay();return a===1?n:a===0?t.addDays(n,-6):t.addDays(n,-1*(a-1))}function ru(e,t){const n=vo(e,t),a=au(e,t);return t.addDays(n,a*7-1)}const ou={lessThanXSeconds:{one:"1秒未満",other:"{{count}}秒未満",oneWithSuffix:"約1秒",otherWithSuffix:"約{{count}}秒"},xSeconds:{one:"1秒",other:"{{count}}秒"},halfAMinute:"30秒",lessThanXMinutes:{one:"1分未満",other:"{{count}}分未満",oneWithSuffix:"約1分",otherWithSuffix:"約{{count}}分"},xMinutes:{one:"1分",other:"{{count}}分"},aboutXHours:{one:"約1時間",other:"約{{count}}時間"},xHours:{one:"1時間",other:"{{count}}時間"},xDays:{one:"1日",other:"{{count}}日"},aboutXWeeks:{one:"約1週間",other:"約{{count}}週間"},xWeeks:{one:"1週間",other:"{{count}}週間"},aboutXMonths:{one:"約1か月",other:"約{{count}}か月"},xMonths:{one:"1か月",other:"{{count}}か月"},aboutXYears:{one:"約1年",other:"約{{count}}年"},xYears:{one:"1年",other:"{{count}}年"},overXYears:{one:"1年以上",other:"{{count}}年以上"},almostXYears:{one:"1年近く",other:"{{count}}年近く"}},su=(e,t,n)=>{n=n||{};let a;const r=ou[e];return typeof r=="string"?a=r:t===1?n.addSuffix&&r.oneWithSuffix?a=r.oneWithSuffix:a=r.one:n.addSuffix&&r.otherWithSuffix?a=r.otherWithSuffix.replace("{{count}}",String(t)):a=r.other.replace("{{count}}",String(t)),n.addSuffix?n.comparison&&n.comparison>0?a+"後":a+"前":a},iu={full:"y年M月d日EEEE",long:"y年M月d日",medium:"y/MM/dd",short:"y/MM/dd"},lu={full:"H時mm分ss秒 zzzz",long:"H:mm:ss z",medium:"H:mm:ss",short:"H:mm"},cu={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},du={date:Ye({formats:iu,defaultWidth:"full"}),time:Ye({formats:lu,defaultWidth:"full"}),dateTime:Ye({formats:cu,defaultWidth:"full"})},uu={lastWeek:"先週のeeeeのp",yesterday:"昨日のp",today:"今日のp",tomorrow:"明日のp",nextWeek:"翌週のeeeeのp",other:"P"},fu=(e,t,n,a)=>uu[e],mu={narrow:["BC","AC"],abbreviated:["紀元前","西暦"],wide:["紀元前","西暦"]},hu={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["第1四半期","第2四半期","第3四半期","第4四半期"]},gu={narrow:["1","2","3","4","5","6","7","8","9","10","11","12"],abbreviated:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],wide:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"]},yu={narrow:["日","月","火","水","木","金","土"],short:["日","月","火","水","木","金","土"],abbreviated:["日","月","火","水","木","金","土"],wide:["日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日"]},pu={narrow:{am:"午前",pm:"午後",midnight:"深夜",noon:"正午",morning:"朝",afternoon:"午後",evening:"夜",night:"深夜"},abbreviated:{am:"午前",pm:"午後",midnight:"深夜",noon:"正午",morning:"朝",afternoon:"午後",evening:"夜",night:"深夜"},wide:{am:"午前",pm:"午後",midnight:"深夜",noon:"正午",morning:"朝",afternoon:"午後",evening:"夜",night:"深夜"}},bu={narrow:{am:"午前",pm:"午後",midnight:"深夜",noon:"正午",morning:"朝",afternoon:"午後",evening:"夜",night:"深夜"},abbreviated:{am:"午前",pm:"午後",midnight:"深夜",noon:"正午",morning:"朝",afternoon:"午後",evening:"夜",night:"深夜"},wide:{am:"午前",pm:"午後",midnight:"深夜",noon:"正午",morning:"朝",afternoon:"午後",evening:"夜",night:"深夜"}},xu=(e,t)=>{const n=Number(e);switch(String(t?.unit)){case"year":return`${n}年`;case"quarter":return`第${n}四半期`;case"month":return`${n}月`;case"week":return`第${n}週`;case"date":return`${n}日`;case"hour":return`${n}時`;case"minute":return`${n}分`;case"second":return`${n}秒`;default:return`${n}`}},ku={ordinalNumber:xu,era:we({values:mu,defaultWidth:"wide"}),quarter:we({values:hu,defaultWidth:"wide",argumentCallback:e=>Number(e)-1}),month:we({values:gu,defaultWidth:"wide"}),day:we({values:yu,defaultWidth:"wide"}),dayPeriod:we({values:pu,defaultWidth:"wide",formattingValues:bu,defaultFormattingWidth:"wide"})},wu=/^第?\d+(年|四半期|月|週|日|時|分|秒)?/i,vu=/\d+/i,Nu={narrow:/^(B\.?C\.?|A\.?D\.?)/i,abbreviated:/^(紀元[前後]|西暦)/i,wide:/^(紀元[前後]|西暦)/i},_u={narrow:[/^B/i,/^A/i],any:[/^(紀元前)/i,/^(西暦|紀元後)/i]},Mu={narrow:/^[1234]/i,abbreviated:/^Q[1234]/i,wide:/^第[1234一二三四1234]四半期/i},ju={any:[/(1|一|1)/i,/(2|二|2)/i,/(3|三|3)/i,/(4|四|4)/i]},Su={narrow:/^([123456789]|1[012])/,abbreviated:/^([123456789]|1[012])月/i,wide:/^([123456789]|1[012])月/i},Cu={any:[/^1\D/,/^2/,/^3/,/^4/,/^5/,/^6/,/^7/,/^8/,/^9/,/^10/,/^11/,/^12/]},Du={narrow:/^[日月火水木金土]/,short:/^[日月火水木金土]/,abbreviated:/^[日月火水木金土]/,wide:/^[日月火水木金土]曜日/},Tu={any:[/^日/,/^月/,/^火/,/^水/,/^木/,/^金/,/^土/]},Pu={any:/^(AM|PM|午前|午後|正午|深夜|真夜中|夜|朝)/i},Ou={any:{am:/^(A|午前)/i,pm:/^(P|午後)/i,midnight:/^深夜|真夜中/i,noon:/^正午/i,morning:/^朝/i,afternoon:/^午後/i,evening:/^夜/i,night:/^深夜/i}},$u={ordinalNumber:ln({matchPattern:wu,parsePattern:vu,valueCallback:function(e){return parseInt(e,10)}}),era:ve({matchPatterns:Nu,defaultMatchWidth:"wide",parsePatterns:_u,defaultParseWidth:"any"}),quarter:ve({matchPatterns:Mu,defaultMatchWidth:"wide",parsePatterns:ju,defaultParseWidth:"any",valueCallback:e=>e+1}),month:ve({matchPatterns:Su,defaultMatchWidth:"wide",parsePatterns:Cu,defaultParseWidth:"any"}),day:ve({matchPatterns:Du,defaultMatchWidth:"wide",parsePatterns:Tu,defaultParseWidth:"any"}),dayPeriod:ve({matchPatterns:Pu,defaultMatchWidth:"any",parsePatterns:Ou,defaultParseWidth:"any"})},Wu={code:"ja",formatDistance:su,formatLong:du,formatRelative:fu,localize:ku,match:$u,options:{weekStartsOn:0,firstWeekContainsDate:1}},Eu={lessThanXSeconds:{one:"1초 미만",other:"{{count}}초 미만"},xSeconds:{one:"1초",other:"{{count}}초"},halfAMinute:"30초",lessThanXMinutes:{one:"1분 미만",other:"{{count}}분 미만"},xMinutes:{one:"1분",other:"{{count}}분"},aboutXHours:{one:"약 1시간",other:"약 {{count}}시간"},xHours:{one:"1시간",other:"{{count}}시간"},xDays:{one:"1일",other:"{{count}}일"},aboutXWeeks:{one:"약 1주",other:"약 {{count}}주"},xWeeks:{one:"1주",other:"{{count}}주"},aboutXMonths:{one:"약 1개월",other:"약 {{count}}개월"},xMonths:{one:"1개월",other:"{{count}}개월"},aboutXYears:{one:"약 1년",other:"약 {{count}}년"},xYears:{one:"1년",other:"{{count}}년"},overXYears:{one:"1년 이상",other:"{{count}}년 이상"},almostXYears:{one:"거의 1년",other:"거의 {{count}}년"}},Au=(e,t,n)=>{let a;const r=Eu[e];return typeof r=="string"?a=r:t===1?a=r.one:a=r.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?a+" 후":a+" 전":a},Fu={full:"y년 M월 d일 EEEE",long:"y년 M월 d일",medium:"y.MM.dd",short:"y.MM.dd"},Ru={full:"a H시 mm분 ss초 zzzz",long:"a H:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},Iu={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},Lu={date:Ye({formats:Fu,defaultWidth:"full"}),time:Ye({formats:Ru,defaultWidth:"full"}),dateTime:Ye({formats:Iu,defaultWidth:"full"})},Yu={lastWeek:"'지난' eeee p",yesterday:"'어제' p",today:"'오늘' p",tomorrow:"'내일' p",nextWeek:"'다음' eeee p",other:"P"},zu=(e,t,n,a)=>Yu[e],Bu={narrow:["BC","AD"],abbreviated:["BC","AD"],wide:["기원전","서기"]},Hu={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1분기","2분기","3분기","4분기"]},Uu={narrow:["1","2","3","4","5","6","7","8","9","10","11","12"],abbreviated:["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"],wide:["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"]},Vu={narrow:["일","월","화","수","목","금","토"],short:["일","월","화","수","목","금","토"],abbreviated:["일","월","화","수","목","금","토"],wide:["일요일","월요일","화요일","수요일","목요일","금요일","토요일"]},qu={narrow:{am:"오전",pm:"오후",midnight:"자정",noon:"정오",morning:"아침",afternoon:"오후",evening:"저녁",night:"밤"},abbreviated:{am:"오전",pm:"오후",midnight:"자정",noon:"정오",morning:"아침",afternoon:"오후",evening:"저녁",night:"밤"},wide:{am:"오전",pm:"오후",midnight:"자정",noon:"정오",morning:"아침",afternoon:"오후",evening:"저녁",night:"밤"}},Xu={narrow:{am:"오전",pm:"오후",midnight:"자정",noon:"정오",morning:"아침",afternoon:"오후",evening:"저녁",night:"밤"},abbreviated:{am:"오전",pm:"오후",midnight:"자정",noon:"정오",morning:"아침",afternoon:"오후",evening:"저녁",night:"밤"},wide:{am:"오전",pm:"오후",midnight:"자정",noon:"정오",morning:"아침",afternoon:"오후",evening:"저녁",night:"밤"}},Ku=(e,t)=>{const n=Number(e);switch(String(t?.unit)){case"minute":case"second":return String(n);case"date":return n+"일";default:return n+"번째"}},Gu={ordinalNumber:Ku,era:we({values:Bu,defaultWidth:"wide"}),quarter:we({values:Hu,defaultWidth:"wide",argumentCallback:e=>e-1}),month:we({values:Uu,defaultWidth:"wide"}),day:we({values:Vu,defaultWidth:"wide"}),dayPeriod:we({values:qu,defaultWidth:"wide",formattingValues:Xu,defaultFormattingWidth:"wide"})},Qu=/^(\d+)(일|번째)?/i,Ju=/\d+/i,Zu={narrow:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(기원전|서기)/i},ef={any:[/^(bc|기원전)/i,/^(ad|서기)/i]},tf={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234]사?분기/i},nf={any:[/1/i,/2/i,/3/i,/4/i]},af={narrow:/^(1[012]|[123456789])/,abbreviated:/^(1[012]|[123456789])월/i,wide:/^(1[012]|[123456789])월/i},rf={any:[/^1월?$/,/^2/,/^3/,/^4/,/^5/,/^6/,/^7/,/^8/,/^9/,/^10/,/^11/,/^12/]},of={narrow:/^[일월화수목금토]/,short:/^[일월화수목금토]/,abbreviated:/^[일월화수목금토]/,wide:/^[일월화수목금토]요일/},sf={any:[/^일/,/^월/,/^화/,/^수/,/^목/,/^금/,/^토/]},lf={any:/^(am|pm|오전|오후|자정|정오|아침|저녁|밤)/i},cf={any:{am:/^(am|오전)/i,pm:/^(pm|오후)/i,midnight:/^자정/i,noon:/^정오/i,morning:/^아침/i,afternoon:/^오후/i,evening:/^저녁/i,night:/^밤/i}},df={ordinalNumber:ln({matchPattern:Qu,parsePattern:Ju,valueCallback:e=>parseInt(e,10)}),era:ve({matchPatterns:Zu,defaultMatchWidth:"wide",parsePatterns:ef,defaultParseWidth:"any"}),quarter:ve({matchPatterns:tf,defaultMatchWidth:"wide",parsePatterns:nf,defaultParseWidth:"any",valueCallback:e=>e+1}),month:ve({matchPatterns:af,defaultMatchWidth:"wide",parsePatterns:rf,defaultParseWidth:"any"}),day:ve({matchPatterns:of,defaultMatchWidth:"wide",parsePatterns:sf,defaultParseWidth:"any"}),dayPeriod:ve({matchPatterns:lf,defaultMatchWidth:"any",parsePatterns:cf,defaultParseWidth:"any"})},uf={code:"ko",formatDistance:Au,formatLong:Lu,formatRelative:zu,localize:Gu,match:df,options:{weekStartsOn:0,firstWeekContainsDate:1}},ff={lessThanXSeconds:{one:"不到 1 秒",other:"不到 {{count}} 秒"},xSeconds:{one:"1 秒",other:"{{count}} 秒"},halfAMinute:"半分钟",lessThanXMinutes:{one:"不到 1 分钟",other:"不到 {{count}} 分钟"},xMinutes:{one:"1 分钟",other:"{{count}} 分钟"},xHours:{one:"1 小时",other:"{{count}} 小时"},aboutXHours:{one:"大约 1 小时",other:"大约 {{count}} 小时"},xDays:{one:"1 天",other:"{{count}} 天"},aboutXWeeks:{one:"大约 1 个星期",other:"大约 {{count}} 个星期"},xWeeks:{one:"1 个星期",other:"{{count}} 个星期"},aboutXMonths:{one:"大约 1 个月",other:"大约 {{count}} 个月"},xMonths:{one:"1 个月",other:"{{count}} 个月"},aboutXYears:{one:"大约 1 年",other:"大约 {{count}} 年"},xYears:{one:"1 年",other:"{{count}} 年"},overXYears:{one:"超过 1 年",other:"超过 {{count}} 年"},almostXYears:{one:"将近 1 年",other:"将近 {{count}} 年"}},mf=(e,t,n)=>{let a;const r=ff[e];return typeof r=="string"?a=r:t===1?a=r.one:a=r.other.replace("{{count}}",String(t)),n?.addSuffix?n.comparison&&n.comparison>0?a+"内":a+"前":a},hf={full:"y'年'M'月'd'日' EEEE",long:"y'年'M'月'd'日'",medium:"yyyy-MM-dd",short:"yy-MM-dd"},gf={full:"zzzz a h:mm:ss",long:"z a h:mm:ss",medium:"a h:mm:ss",short:"a h:mm"},yf={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},pf={date:Ye({formats:hf,defaultWidth:"full"}),time:Ye({formats:gf,defaultWidth:"full"}),dateTime:Ye({formats:yf,defaultWidth:"full"})};function cr(e,t,n){const a="eeee p";return Qd(e,t,n)?a:e.getTime()>t.getTime()?"'下个'"+a:"'上个'"+a}const bf={lastWeek:cr,yesterday:"'昨天' p",today:"'今天' p",tomorrow:"'明天' p",nextWeek:cr,other:"PP p"},xf=(e,t,n,a)=>{const r=bf[e];return typeof r=="function"?r(t,n,a):r},kf={narrow:["前","公元"],abbreviated:["前","公元"],wide:["公元前","公元"]},wf={narrow:["1","2","3","4"],abbreviated:["第一季","第二季","第三季","第四季"],wide:["第一季度","第二季度","第三季度","第四季度"]},vf={narrow:["一","二","三","四","五","六","七","八","九","十","十一","十二"],abbreviated:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],wide:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},Nf={narrow:["日","一","二","三","四","五","六"],short:["日","一","二","三","四","五","六"],abbreviated:["周日","周一","周二","周三","周四","周五","周六"],wide:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},_f={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},Mf={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},jf=(e,t)=>{const n=Number(e);switch(t?.unit){case"date":return n.toString()+"日";case"hour":return n.toString()+"时";case"minute":return n.toString()+"分";case"second":return n.toString()+"秒";default:return"第 "+n.toString()}},Sf={ordinalNumber:jf,era:we({values:kf,defaultWidth:"wide"}),quarter:we({values:wf,defaultWidth:"wide",argumentCallback:e=>e-1}),month:we({values:vf,defaultWidth:"wide"}),day:we({values:Nf,defaultWidth:"wide"}),dayPeriod:we({values:_f,defaultWidth:"wide",formattingValues:Mf,defaultFormattingWidth:"wide"})},Cf=/^(第\s*)?\d+(日|时|分|秒)?/i,Df=/\d+/i,Tf={narrow:/^(前)/i,abbreviated:/^(前)/i,wide:/^(公元前|公元)/i},Pf={any:[/^(前)/i,/^(公元)/i]},Of={narrow:/^[1234]/i,abbreviated:/^第[一二三四]刻/i,wide:/^第[一二三四]刻钟/i},$f={any:[/(1|一)/i,/(2|二)/i,/(3|三)/i,/(4|四)/i]},Wf={narrow:/^(一|二|三|四|五|六|七|八|九|十[二一])/i,abbreviated:/^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,wide:/^(一|二|三|四|五|六|七|八|九|十[二一])月/i},Ef={narrow:[/^一/i,/^二/i,/^三/i,/^四/i,/^五/i,/^六/i,/^七/i,/^八/i,/^九/i,/^十(?!(一|二))/i,/^十一/i,/^十二/i],any:[/^一|1/i,/^二|2/i,/^三|3/i,/^四|4/i,/^五|5/i,/^六|6/i,/^七|7/i,/^八|8/i,/^九|9/i,/^十(?!(一|二))|10/i,/^十一|11/i,/^十二|12/i]},Af={narrow:/^[一二三四五六日]/i,short:/^[一二三四五六日]/i,abbreviated:/^周[一二三四五六日]/i,wide:/^星期[一二三四五六日]/i},Ff={any:[/日/i,/一/i,/二/i,/三/i,/四/i,/五/i,/六/i]},Rf={any:/^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨|)/i},If={any:{am:/^上午?/i,pm:/^下午?/i,midnight:/^午夜/i,noon:/^[中正]午/i,morning:/^早上/i,afternoon:/^下午/i,evening:/^晚上?/i,night:/^凌晨/i}},Lf={ordinalNumber:ln({matchPattern:Cf,parsePattern:Df,valueCallback:e=>parseInt(e,10)}),era:ve({matchPatterns:Tf,defaultMatchWidth:"wide",parsePatterns:Pf,defaultParseWidth:"any"}),quarter:ve({matchPatterns:Of,defaultMatchWidth:"wide",parsePatterns:$f,defaultParseWidth:"any",valueCallback:e=>e+1}),month:ve({matchPatterns:Wf,defaultMatchWidth:"wide",parsePatterns:Ef,defaultParseWidth:"any"}),day:ve({matchPatterns:Af,defaultMatchWidth:"wide",parsePatterns:Ff,defaultParseWidth:"any"}),dayPeriod:ve({matchPatterns:Rf,defaultMatchWidth:"any",parsePatterns:If,defaultParseWidth:"any"})},Yf={code:"zh-CN",formatDistance:mf,formatLong:pf,formatRelative:xf,localize:Sf,match:Lf,options:{weekStartsOn:1,firstWeekContainsDate:4}},zf={lessThanXSeconds:{one:"少於 1 秒",other:"少於 {{count}} 秒"},xSeconds:{one:"1 秒",other:"{{count}} 秒"},halfAMinute:"半分鐘",lessThanXMinutes:{one:"少於 1 分鐘",other:"少於 {{count}} 分鐘"},xMinutes:{one:"1 分鐘",other:"{{count}} 分鐘"},xHours:{one:"1 小時",other:"{{count}} 小時"},aboutXHours:{one:"大約 1 小時",other:"大約 {{count}} 小時"},xDays:{one:"1 天",other:"{{count}} 天"},aboutXWeeks:{one:"大約 1 個星期",other:"大約 {{count}} 個星期"},xWeeks:{one:"1 個星期",other:"{{count}} 個星期"},aboutXMonths:{one:"大約 1 個月",other:"大約 {{count}} 個月"},xMonths:{one:"1 個月",other:"{{count}} 個月"},aboutXYears:{one:"大約 1 年",other:"大約 {{count}} 年"},xYears:{one:"1 年",other:"{{count}} 年"},overXYears:{one:"超過 1 年",other:"超過 {{count}} 年"},almostXYears:{one:"將近 1 年",other:"將近 {{count}} 年"}},Bf=(e,t,n)=>{let a;const r=zf[e];return typeof r=="string"?a=r:t===1?a=r.one:a=r.other.replace("{{count}}",String(t)),n?.addSuffix?n.comparison&&n.comparison>0?a+"內":a+"前":a},Hf={full:"y'年'M'月'd'日' EEEE",long:"y'年'M'月'd'日'",medium:"yyyy-MM-dd",short:"yy-MM-dd"},Uf={full:"zzzz a h:mm:ss",long:"z a h:mm:ss",medium:"a h:mm:ss",short:"a h:mm"},Vf={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},qf={date:Ye({formats:Hf,defaultWidth:"full"}),time:Ye({formats:Uf,defaultWidth:"full"}),dateTime:Ye({formats:Vf,defaultWidth:"full"})},Xf={lastWeek:"'上個'eeee p",yesterday:"'昨天' p",today:"'今天' p",tomorrow:"'明天' p",nextWeek:"'下個'eeee p",other:"P"},Kf=(e,t,n,a)=>Xf[e],Gf={narrow:["前","公元"],abbreviated:["前","公元"],wide:["公元前","公元"]},Qf={narrow:["1","2","3","4"],abbreviated:["第一刻","第二刻","第三刻","第四刻"],wide:["第一刻鐘","第二刻鐘","第三刻鐘","第四刻鐘"]},Jf={narrow:["一","二","三","四","五","六","七","八","九","十","十一","十二"],abbreviated:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],wide:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},Zf={narrow:["日","一","二","三","四","五","六"],short:["日","一","二","三","四","五","六"],abbreviated:["週日","週一","週二","週三","週四","週五","週六"],wide:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},em={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜間"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜間"}},tm={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜間"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜間"}},nm=(e,t)=>{const n=Number(e);switch(t?.unit){case"date":return n+"日";case"hour":return n+"時";case"minute":return n+"分";case"second":return n+"秒";default:return"第 "+n}},am={ordinalNumber:nm,era:we({values:Gf,defaultWidth:"wide"}),quarter:we({values:Qf,defaultWidth:"wide",argumentCallback:e=>e-1}),month:we({values:Jf,defaultWidth:"wide"}),day:we({values:Zf,defaultWidth:"wide"}),dayPeriod:we({values:em,defaultWidth:"wide",formattingValues:tm,defaultFormattingWidth:"wide"})},rm=/^(第\s*)?\d+(日|時|分|秒)?/i,om=/\d+/i,sm={narrow:/^(前)/i,abbreviated:/^(前)/i,wide:/^(公元前|公元)/i},im={any:[/^(前)/i,/^(公元)/i]},lm={narrow:/^[1234]/i,abbreviated:/^第[一二三四]刻/i,wide:/^第[一二三四]刻鐘/i},cm={any:[/(1|一)/i,/(2|二)/i,/(3|三)/i,/(4|四)/i]},dm={narrow:/^(一|二|三|四|五|六|七|八|九|十[二一])/i,abbreviated:/^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,wide:/^(一|二|三|四|五|六|七|八|九|十[二一])月/i},um={narrow:[/^一/i,/^二/i,/^三/i,/^四/i,/^五/i,/^六/i,/^七/i,/^八/i,/^九/i,/^十(?!(一|二))/i,/^十一/i,/^十二/i],any:[/^一|1/i,/^二|2/i,/^三|3/i,/^四|4/i,/^五|5/i,/^六|6/i,/^七|7/i,/^八|8/i,/^九|9/i,/^十(?!(一|二))|10/i,/^十一|11/i,/^十二|12/i]},fm={narrow:/^[一二三四五六日]/i,short:/^[一二三四五六日]/i,abbreviated:/^週[一二三四五六日]/i,wide:/^星期[一二三四五六日]/i},mm={any:[/日/i,/一/i,/二/i,/三/i,/四/i,/五/i,/六/i]},hm={any:/^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨)/i},gm={any:{am:/^上午?/i,pm:/^下午?/i,midnight:/^午夜/i,noon:/^[中正]午/i,morning:/^早上/i,afternoon:/^下午/i,evening:/^晚上?/i,night:/^凌晨/i}},ym={ordinalNumber:ln({matchPattern:rm,parsePattern:om,valueCallback:e=>parseInt(e,10)}),era:ve({matchPatterns:sm,defaultMatchWidth:"wide",parsePatterns:im,defaultParseWidth:"any"}),quarter:ve({matchPatterns:lm,defaultMatchWidth:"wide",parsePatterns:cm,defaultParseWidth:"any",valueCallback:e=>e+1}),month:ve({matchPatterns:dm,defaultMatchWidth:"wide",parsePatterns:um,defaultParseWidth:"any"}),day:ve({matchPatterns:fm,defaultMatchWidth:"wide",parsePatterns:mm,defaultParseWidth:"any"}),dayPeriod:ve({matchPatterns:hm,defaultMatchWidth:"any",parsePatterns:gm,defaultParseWidth:"any"})},pm={code:"zh-TW",formatDistance:Bf,formatLong:qf,formatRelative:Kf,localize:am,match:ym,options:{weekStartsOn:1,firstWeekContainsDate:4}},No={...vt,labels:{labelDayButton:(e,t,n,a)=>{let r;a&&typeof a.format=="function"?r=a.format.bind(a):r=(l,i)=>st(l,i,{locale:vt,...n});let s=r(e,"PPPP");return t.today&&(s=`Today, ${s}`),t.selected&&(s=`${s}, selected`),s},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:e=>`Week ${e}`,labelYearDropdown:"Choose the Year",labelGrid:(e,t,n)=>{let a;return n&&typeof n.format=="function"?a=n.format.bind(n):a=(r,s)=>st(r,s,{locale:vt,...t}),a(e,"LLLL yyyy")},labelGridcell:(e,t,n,a)=>{let r;a&&typeof a.format=="function"?r=a.format.bind(a):r=(l,i)=>st(l,i,{locale:vt,...n});let s=r(e,"PPPP");return t?.today&&(s=`Today, ${s}`),s},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(e,t,n)=>{let a;return n&&typeof n.format=="function"?a=n.format.bind(n):a=(r,s)=>st(r,s,{locale:vt,...t}),a(e,"cccc")}}};class Ue{constructor(t,n){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?Ie.tz(this.options.timeZone):new this.Date,this.newDate=(a,r,s)=>this.overrides?.newDate?this.overrides.newDate(a,r,s):this.options.timeZone?new Ie(a,r,s,this.options.timeZone):new Date(a,r,s),this.addDays=(a,r)=>this.overrides?.addDays?this.overrides.addDays(a,r):fo(a,r),this.addMonths=(a,r)=>this.overrides?.addMonths?this.overrides.addMonths(a,r):mo(a,r),this.addWeeks=(a,r)=>this.overrides?.addWeeks?this.overrides.addWeeks(a,r):Lc(a,r),this.addYears=(a,r)=>this.overrides?.addYears?this.overrides.addYears(a,r):Yc(a,r),this.differenceInCalendarDays=(a,r)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(a,r):fa(a,r),this.differenceInCalendarMonths=(a,r)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(a,r):yo(a,r),this.eachMonthOfInterval=a=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(a):qc(a),this.eachYearOfInterval=a=>{const r=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(a):Gc(a),s=new Set(r.map(i=>this.getYear(i)));if(s.size===r.length)return r;const l=[];return s.forEach(i=>{l.push(new Date(i,0,1))}),l},this.endOfBroadcastWeek=a=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(a):ru(a,this),this.endOfISOWeek=a=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(a):Qc(a),this.endOfMonth=a=>this.overrides?.endOfMonth?this.overrides.endOfMonth(a):Vc(a),this.endOfWeek=(a,r)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(a,r):xo(a,this.options),this.endOfYear=a=>this.overrides?.endOfYear?this.overrides.endOfYear(a):Kc(a),this.format=(a,r,s)=>{const l=this.overrides?.format?this.overrides.format(a,r,this.options):st(a,r,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(l):l},this.getISOWeek=a=>this.overrides?.getISOWeek?this.overrides.getISOWeek(a):ma(a),this.getMonth=(a,r)=>this.overrides?.getMonth?this.overrides.getMonth(a,this.options):qd(a,this.options),this.getYear=(a,r)=>this.overrides?.getYear?this.overrides.getYear(a,this.options):Xd(a,this.options),this.getWeek=(a,r)=>this.overrides?.getWeek?this.overrides.getWeek(a,this.options):ha(a,this.options),this.isAfter=(a,r)=>this.overrides?.isAfter?this.overrides.isAfter(a,r):Kd(a,r),this.isBefore=(a,r)=>this.overrides?.isBefore?this.overrides.isBefore(a,r):Gd(a,r),this.isDate=a=>this.overrides?.isDate?this.overrides.isDate(a):go(a),this.isSameDay=(a,r)=>this.overrides?.isSameDay?this.overrides.isSameDay(a,r):Hc(a,r),this.isSameMonth=(a,r)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(a,r):Jd(a,r),this.isSameYear=(a,r)=>this.overrides?.isSameYear?this.overrides.isSameYear(a,r):Zd(a,r),this.max=a=>this.overrides?.max?this.overrides.max(a):zc(a),this.min=a=>this.overrides?.min?this.overrides.min(a):Bc(a),this.setMonth=(a,r)=>this.overrides?.setMonth?this.overrides.setMonth(a,r):eu(a,r),this.setYear=(a,r)=>this.overrides?.setYear?this.overrides.setYear(a,r):tu(a,r),this.startOfBroadcastWeek=(a,r)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(a,this):vo(a,this),this.startOfDay=a=>this.overrides?.startOfDay?this.overrides.startOfDay(a):tn(a),this.startOfISOWeek=a=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(a):en(a),this.startOfMonth=a=>this.overrides?.startOfMonth?this.overrides.startOfMonth(a):Xc(a),this.startOfWeek=(a,r)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(a,this.options):Nt(a,this.options),this.startOfYear=a=>this.overrides?.startOfYear?this.overrides.startOfYear(a):bo(a),this.options={locale:No,...t},this.overrides=n}getDigitMap(){const{numerals:t="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:t}),a={};for(let r=0;r<10;r++)a[r.toString()]=n.format(r);return a}replaceDigits(t){const n=this.getDigitMap();return t.replace(/\d/g,a=>n[a]||a)}formatNumber(t){return this.replaceDigits(t.toString())}getMonthYearOrder(){const t=this.options.locale?.code;return t&&Ue.yearFirstLocales.has(t)?"year-first":"month-first"}formatMonthYear(t){const{locale:n,timeZone:a,numerals:r}=this.options,s=n?.code;if(s&&Ue.yearFirstLocales.has(s))try{return new Intl.DateTimeFormat(s,{month:"long",year:"numeric",timeZone:a,numberingSystem:r}).format(t)}catch{}const l=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(t,l)}}Ue.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 it=new Ue;class _o{constructor(t,n,a=it){this.date=t,this.displayMonth=n,this.outside=!!(n&&!a.isSameMonth(t,n)),this.dateLib=a,this.isoDate=a.format(t,"yyyy-MM-dd"),this.displayMonthId=a.format(n,"yyyy-MM"),this.dateMonthId=a.format(t,"yyyy-MM")}isEqualTo(t){return this.dateLib.isSameDay(t.date,this.date)&&this.dateLib.isSameMonth(t.displayMonth,this.displayMonth)}}class bm{constructor(t,n){this.date=t,this.weeks=n}}class xm{constructor(t,n){this.days=n,this.weekNumber=t}}function km(e){return R.createElement("button",{...e})}function wm(e){return R.createElement("span",{...e})}function vm(e){const{size:t=24,orientation:n="left",className:a}=e;return R.createElement("svg",{className:a,width:t,height:t,viewBox:"0 0 24 24"},n==="up"&&R.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&R.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&R.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&R.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function Nm(e){const{day:t,modifiers:n,...a}=e;return R.createElement("td",{...a})}function _m(e){const{day:t,modifiers:n,...a}=e,r=R.useRef(null);return R.useEffect(()=>{n.focused&&r.current?.focus()},[n.focused]),R.createElement("button",{ref:r,...a})}var Q;(function(e){e.Root="root",e.Chevron="chevron",e.Day="day",e.DayButton="day_button",e.CaptionLabel="caption_label",e.Dropdowns="dropdowns",e.Dropdown="dropdown",e.DropdownRoot="dropdown_root",e.Footer="footer",e.MonthGrid="month_grid",e.MonthCaption="month_caption",e.MonthsDropdown="months_dropdown",e.Month="month",e.Months="months",e.Nav="nav",e.NextMonthButton="button_next",e.PreviousMonthButton="button_previous",e.Week="week",e.Weeks="weeks",e.Weekday="weekday",e.Weekdays="weekdays",e.WeekNumber="week_number",e.WeekNumberHeader="week_number_header",e.YearsDropdown="years_dropdown"})(Q||(Q={}));var _e;(function(e){e.disabled="disabled",e.hidden="hidden",e.outside="outside",e.focused="focused",e.today="today"})(_e||(_e={}));var Ze;(function(e){e.range_end="range_end",e.range_middle="range_middle",e.range_start="range_start",e.selected="selected"})(Ze||(Ze={}));var He;(function(e){e.weeks_before_enter="weeks_before_enter",e.weeks_before_exit="weeks_before_exit",e.weeks_after_enter="weeks_after_enter",e.weeks_after_exit="weeks_after_exit",e.caption_after_enter="caption_after_enter",e.caption_after_exit="caption_after_exit",e.caption_before_enter="caption_before_enter",e.caption_before_exit="caption_before_exit"})(He||(He={}));function Mm(e){const{options:t,className:n,components:a,classNames:r,...s}=e,l=[r[Q.Dropdown],n].join(" "),i=t?.find(({value:c})=>c===s.value);return R.createElement("span",{"data-disabled":s.disabled,className:r[Q.DropdownRoot]},R.createElement(a.Select,{className:l,...s},t?.map(({value:c,label:u,disabled:d})=>R.createElement(a.Option,{key:c,value:c,disabled:d},u))),R.createElement("span",{className:r[Q.CaptionLabel],"aria-hidden":!0},i?.label,R.createElement(a.Chevron,{orientation:"down",size:18,className:r[Q.Chevron]})))}function jm(e){return R.createElement("div",{...e})}function Sm(e){return R.createElement("div",{...e})}function Cm(e){const{calendarMonth:t,displayIndex:n,...a}=e;return R.createElement("div",{...a},e.children)}function Dm(e){const{calendarMonth:t,displayIndex:n,...a}=e;return R.createElement("div",{...a})}function Tm(e){return R.createElement("table",{...e})}function Pm(e){return R.createElement("div",{...e})}const Mo=m.createContext(void 0);function cn(){const e=m.useContext(Mo);if(e===void 0)throw new Error("useDayPicker() must be used within a custom component.");return e}function Om(e){const{components:t}=cn();return R.createElement(t.Dropdown,{...e})}function $m(e){const{onPreviousClick:t,onNextClick:n,previousMonth:a,nextMonth:r,...s}=e,{components:l,classNames:i,labels:{labelPrevious:c,labelNext:u}}=cn(),d=m.useCallback(h=>{r&&n?.(h)},[r,n]),f=m.useCallback(h=>{a&&t?.(h)},[a,t]);return R.createElement("nav",{...s},R.createElement(l.PreviousMonthButton,{type:"button",className:i[Q.PreviousMonthButton],tabIndex:a?void 0:-1,"aria-disabled":a?void 0:!0,"aria-label":c(a),onClick:f},R.createElement(l.Chevron,{disabled:a?void 0:!0,className:i[Q.Chevron],orientation:"left"})),R.createElement(l.NextMonthButton,{type:"button",className:i[Q.NextMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":u(r),onClick:d},R.createElement(l.Chevron,{disabled:r?void 0:!0,orientation:"right",className:i[Q.Chevron]})))}function Wm(e){const{components:t}=cn();return R.createElement(t.Button,{...e})}function Em(e){return R.createElement("option",{...e})}function Am(e){const{components:t}=cn();return R.createElement(t.Button,{...e})}function Fm(e){const{rootRef:t,...n}=e;return R.createElement("div",{...n,ref:t})}function Rm(e){return R.createElement("select",{...e})}function Im(e){const{week:t,...n}=e;return R.createElement("tr",{...n})}function Lm(e){return R.createElement("th",{...e})}function Ym(e){return R.createElement("thead",{"aria-hidden":!0},R.createElement("tr",{...e}))}function zm(e){const{week:t,...n}=e;return R.createElement("th",{...n})}function Bm(e){return R.createElement("th",{...e})}function Hm(e){return R.createElement("tbody",{...e})}function Um(e){const{components:t}=cn();return R.createElement(t.Dropdown,{...e})}const Vm=Object.freeze(Object.defineProperty({__proto__:null,Button:km,CaptionLabel:wm,Chevron:vm,Day:Nm,DayButton:_m,Dropdown:Mm,DropdownNav:jm,Footer:Sm,Month:Cm,MonthCaption:Dm,MonthGrid:Tm,Months:Pm,MonthsDropdown:Om,Nav:$m,NextMonthButton:Wm,Option:Em,PreviousMonthButton:Am,Root:Fm,Select:Rm,Week:Im,WeekNumber:zm,WeekNumberHeader:Bm,Weekday:Lm,Weekdays:Ym,Weeks:Hm,YearsDropdown:Um},Symbol.toStringTag,{value:"Module"}));function ut(e,t,n=!1,a=it){let{from:r,to:s}=e;const{differenceInCalendarDays:l,isSameDay:i}=a;return r&&s?(l(s,r)<0&&([r,s]=[s,r]),l(t,r)>=(n?1:0)&&l(s,t)>=(n?1:0)):!n&&s?i(s,t):!n&&r?i(r,t):!1}function ga(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function jn(e){return!!(e&&typeof e=="object"&&"from"in e)}function ya(e){return!!(e&&typeof e=="object"&&"after"in e)}function pa(e){return!!(e&&typeof e=="object"&&"before"in e)}function jo(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function So(e,t){return Array.isArray(e)&&e.every(t.isDate)}function ft(e,t,n=it){const a=Array.isArray(t)?t:[t],{isSameDay:r,differenceInCalendarDays:s,isAfter:l}=n;return a.some(i=>{if(typeof i=="boolean")return i;if(n.isDate(i))return r(e,i);if(So(i,n))return i.some(c=>r(e,c));if(jn(i))return ut(i,e,!1,n);if(jo(i))return Array.isArray(i.dayOfWeek)?i.dayOfWeek.includes(e.getDay()):i.dayOfWeek===e.getDay();if(ga(i)){const c=s(i.before,e),u=s(i.after,e),d=c>0,f=u<0;return l(i.before,i.after)?f&&d:d||f}return ya(i)?s(e,i.after)>0:pa(i)?s(i.before,e)>0:typeof i=="function"?i(e):!1})}function qm(e,t,n,a,r){const{disabled:s,hidden:l,modifiers:i,showOutsideDays:c,broadcastCalendar:u,today:d=r.today()}=t,{isSameDay:f,isSameMonth:h,startOfMonth:g,isBefore:p,endOfMonth:k,isAfter:v}=r,w=n&&g(n),N=a&&k(a),x={[_e.focused]:[],[_e.outside]:[],[_e.disabled]:[],[_e.hidden]:[],[_e.today]:[]},M={};for(const T of e){const{date:j,displayMonth:L}=T,P=!!(L&&!h(j,L)),C=!!(w&&p(j,w)),I=!!(N&&v(j,N)),K=!!(s&&ft(j,s,r)),V=!!(l&&ft(j,l,r))||C||I||!u&&!c&&P||u&&c===!1&&P,$=f(j,d);P&&x.outside.push(T),K&&x.disabled.push(T),V&&x.hidden.push(T),$&&x.today.push(T),i&&Object.keys(i).forEach(E=>{const D=i?.[E];D&&ft(j,D,r)&&(M[E]?M[E].push(T):M[E]=[T])})}return T=>{const j={[_e.focused]:!1,[_e.disabled]:!1,[_e.hidden]:!1,[_e.outside]:!1,[_e.today]:!1},L={};for(const P in x){const C=x[P];j[P]=C.some(I=>I===T)}for(const P in M)L[P]=M[P].some(C=>C===T);return{...j,...L}}}function Xm(e,t,n={}){return Object.entries(e).filter(([,r])=>r===!0).reduce((r,[s])=>(n[s]?r.push(n[s]):t[_e[s]]?r.push(t[_e[s]]):t[Ze[s]]&&r.push(t[Ze[s]]),r),[t[Q.Day]])}function Km(e){return{...Vm,...e}}function Gm(e){const t={"data-mode":e.mode??void 0,"data-required":"required"in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([n,a])=>{n.startsWith("data-")&&(t[n]=a)}),t}function Qm(){const e={};for(const t in Q)e[Q[t]]=`rdp-${Q[t]}`;for(const t in _e)e[_e[t]]=`rdp-${_e[t]}`;for(const t in Ze)e[Ze[t]]=`rdp-${Ze[t]}`;for(const t in He)e[He[t]]=`rdp-${He[t]}`;return e}function Co(e,t,n){return(n??new Ue(t)).formatMonthYear(e)}const Jm=Co;function Zm(e,t,n){return(n??new Ue(t)).format(e,"d")}function eh(e,t=it){return t.format(e,"LLLL")}function th(e,t,n){return(n??new Ue(t)).format(e,"cccccc")}function nh(e,t=it){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function ah(){return""}function Do(e,t=it){return t.format(e,"yyyy")}const rh=Do,oh=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:Co,formatDay:Zm,formatMonthCaption:Jm,formatMonthDropdown:eh,formatWeekNumber:nh,formatWeekNumberHeader:ah,formatWeekdayName:th,formatYearCaption:rh,formatYearDropdown:Do},Symbol.toStringTag,{value:"Module"}));function sh(e){return e?.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e?.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{...oh,...e}}function ba(e,t,n,a){let r=(a??new Ue(n)).format(e,"PPPP");return t.today&&(r=`Today, ${r}`),t.selected&&(r=`${r}, selected`),r}const ih=ba;function xa(e,t,n){return(n??new Ue(t)).formatMonthYear(e)}const lh=xa;function To(e,t,n,a){let r=(a??new Ue(n)).format(e,"PPPP");return t?.today&&(r=`Today, ${r}`),r}function Po(e){return"Choose the Month"}function Oo(){return""}const ch="Go to the Next Month";function $o(e,t){return ch}function Wo(e){return"Go to the Previous Month"}function Eo(e,t,n){return(n??new Ue(t)).format(e,"cccc")}function Ao(e,t){return`Week ${e}`}function Fo(e){return"Week Number"}function Ro(e){return"Choose the Year"}const dh=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:lh,labelDay:ih,labelDayButton:ba,labelGrid:xa,labelGridcell:To,labelMonthDropdown:Po,labelNav:Oo,labelNext:$o,labelPrevious:Wo,labelWeekNumber:Ao,labelWeekNumberHeader:Fo,labelWeekday:Eo,labelYearDropdown:Ro},Symbol.toStringTag,{value:"Module"})),Je=(e,t,n)=>t||(n?typeof n=="function"?n:(...a)=>n:e);function uh(e,t){const n=t.locale?.labels??{};return{...dh,...e??{},labelDayButton:Je(ba,e?.labelDayButton,n.labelDayButton),labelMonthDropdown:Je(Po,e?.labelMonthDropdown,n.labelMonthDropdown),labelNext:Je($o,e?.labelNext,n.labelNext),labelPrevious:Je(Wo,e?.labelPrevious,n.labelPrevious),labelWeekNumber:Je(Ao,e?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:Je(Ro,e?.labelYearDropdown,n.labelYearDropdown),labelGrid:Je(xa,e?.labelGrid,n.labelGrid),labelGridcell:Je(To,e?.labelGridcell,n.labelGridcell),labelNav:Je(Oo,e?.labelNav,n.labelNav),labelWeekNumberHeader:Je(Fo,e?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:Je(Eo,e?.labelWeekday,n.labelWeekday)}}function fh(e,t,n,a,r){const{startOfMonth:s,startOfYear:l,endOfYear:i,eachMonthOfInterval:c,getMonth:u}=r;return c({start:l(e),end:i(e)}).map(h=>{const g=a.formatMonthDropdown(h,r),p=u(h),k=t&&h<s(t)||n&&h>s(n)||!1;return{value:p,label:g,disabled:k}})}function mh(e,t={},n={}){let a={...t?.[Q.Day]};return Object.entries(e).filter(([,r])=>r===!0).forEach(([r])=>{a={...a,...n?.[r]}}),a}function hh(e,t,n,a){const r=a??e.today(),s=n?e.startOfBroadcastWeek(r,e):t?e.startOfISOWeek(r):e.startOfWeek(r),l=[];for(let i=0;i<7;i++){const c=e.addDays(s,i);l.push(c)}return l}function gh(e,t,n,a,r=!1){if(!e||!t)return;const{startOfYear:s,endOfYear:l,eachYearOfInterval:i,getYear:c}=a,u=s(e),d=l(t),f=i({start:u,end:d});return r&&f.reverse(),f.map(h=>{const g=n.formatYearDropdown(h,a);return{value:c(h),label:g,disabled:!1}})}function yh(e,t={}){const{weekStartsOn:n,locale:a}=t,r=n??a?.options?.weekStartsOn??0,s=i=>{const c=typeof i=="number"||typeof i=="string"?new Date(i):i;return new Ie(c.getFullYear(),c.getMonth(),c.getDate(),12,0,0,e)},l=i=>{const c=s(i);return new Date(c.getFullYear(),c.getMonth(),c.getDate(),0,0,0,0)};return{today:()=>s(Ie.tz(e)),newDate:(i,c,u)=>new Ie(i,c,u,12,0,0,e),startOfDay:i=>s(i),startOfWeek:(i,c)=>{const u=s(i),d=c?.weekStartsOn??r,f=(u.getDay()-d+7)%7;return u.setDate(u.getDate()-f),u},startOfISOWeek:i=>{const c=s(i),u=(c.getDay()-1+7)%7;return c.setDate(c.getDate()-u),c},startOfMonth:i=>{const c=s(i);return c.setDate(1),c},startOfYear:i=>{const c=s(i);return c.setMonth(0,1),c},endOfWeek:(i,c)=>{const u=s(i),h=(((c?.weekStartsOn??r)+6)%7-u.getDay()+7)%7;return u.setDate(u.getDate()+h),u},endOfISOWeek:i=>{const c=s(i),u=(7-c.getDay())%7;return c.setDate(c.getDate()+u),c},endOfMonth:i=>{const c=s(i);return c.setMonth(c.getMonth()+1,0),c},endOfYear:i=>{const c=s(i);return c.setMonth(11,31),c},eachMonthOfInterval:i=>{const c=s(i.start),u=s(i.end),d=[],f=new Ie(c.getFullYear(),c.getMonth(),1,12,0,0,e),h=u.getFullYear()*12+u.getMonth();for(;f.getFullYear()*12+f.getMonth()<=h;)d.push(new Ie(f,e)),f.setMonth(f.getMonth()+1,1);return d},addDays:(i,c)=>{const u=s(i);return u.setDate(u.getDate()+c),u},addWeeks:(i,c)=>{const u=s(i);return u.setDate(u.getDate()+c*7),u},addMonths:(i,c)=>{const u=s(i);return u.setMonth(u.getMonth()+c),u},addYears:(i,c)=>{const u=s(i);return u.setFullYear(u.getFullYear()+c),u},eachYearOfInterval:i=>{const c=s(i.start),u=s(i.end),d=[],f=new Ie(c.getFullYear(),0,1,12,0,0,e);for(;f.getFullYear()<=u.getFullYear();)d.push(new Ie(f,e)),f.setFullYear(f.getFullYear()+1,0,1);return d},getWeek:(i,c)=>{const u=l(i);return ha(u,{weekStartsOn:c?.weekStartsOn??r,firstWeekContainsDate:c?.firstWeekContainsDate??a?.options?.firstWeekContainsDate??1})},getISOWeek:i=>{const c=l(i);return ma(c)},differenceInCalendarDays:(i,c)=>{const u=l(i),d=l(c);return fa(u,d)},differenceInCalendarMonths:(i,c)=>{const u=l(i),d=l(c);return yo(u,d)}}}const dn=e=>e instanceof HTMLElement?e:null,zn=e=>[...e.querySelectorAll("[data-animated-month]")??[]],ph=e=>dn(e.querySelector("[data-animated-month]")),Bn=e=>dn(e.querySelector("[data-animated-caption]")),Hn=e=>dn(e.querySelector("[data-animated-weeks]")),bh=e=>dn(e.querySelector("[data-animated-nav]")),xh=e=>dn(e.querySelector("[data-animated-weekdays]"));function kh(e,t,{classNames:n,months:a,focused:r,dateLib:s}){const l=m.useRef(null),i=m.useRef(a),c=m.useRef(!1);m.useLayoutEffect(()=>{const u=i.current;if(i.current=a,!t||!e.current||!(e.current instanceof HTMLElement)||a.length===0||u.length===0||a.length!==u.length)return;const d=s.isSameMonth(a[0].date,u[0].date),f=s.isAfter(a[0].date,u[0].date),h=f?n[He.caption_after_enter]:n[He.caption_before_enter],g=f?n[He.weeks_after_enter]:n[He.weeks_before_enter],p=l.current,k=e.current.cloneNode(!0);if(k instanceof HTMLElement?(zn(k).forEach(x=>{if(!(x instanceof HTMLElement))return;const M=ph(x);M&&x.contains(M)&&x.removeChild(M);const T=Bn(x);T&&T.classList.remove(h);const j=Hn(x);j&&j.classList.remove(g)}),l.current=k):l.current=null,c.current||d||r)return;const v=p instanceof HTMLElement?zn(p):[],w=zn(e.current);if(w?.every(N=>N instanceof HTMLElement)&&v&&v.every(N=>N instanceof HTMLElement)){c.current=!0,e.current.style.isolation="isolate";const N=bh(e.current);N&&(N.style.zIndex="1"),w.forEach((x,M)=>{const T=v[M];if(!T)return;x.style.position="relative",x.style.overflow="hidden";const j=Bn(x);j&&j.classList.add(h);const L=Hn(x);L&&L.classList.add(g);const P=()=>{c.current=!1,e.current&&(e.current.style.isolation=""),N&&(N.style.zIndex=""),j&&j.classList.remove(h),L&&L.classList.remove(g),x.style.position="",x.style.overflow="",x.contains(T)&&x.removeChild(T)};T.style.pointerEvents="none",T.style.position="absolute",T.style.overflow="hidden",T.setAttribute("aria-hidden","true");const C=xh(T);C&&(C.style.opacity="0");const I=Bn(T);I&&(I.classList.add(f?n[He.caption_before_exit]:n[He.caption_after_exit]),I.addEventListener("animationend",P));const K=Hn(T);K&&K.classList.add(f?n[He.weeks_before_exit]:n[He.weeks_after_exit]),x.insertBefore(T,x.firstChild)})}})}function wh(e,t,n,a){const r=e[0],s=e[e.length-1],{ISOWeek:l,fixedWeeks:i,broadcastCalendar:c}=n??{},{addDays:u,differenceInCalendarDays:d,differenceInCalendarMonths:f,endOfBroadcastWeek:h,endOfISOWeek:g,endOfMonth:p,endOfWeek:k,isAfter:v,startOfBroadcastWeek:w,startOfISOWeek:N,startOfWeek:x}=a,M=c?w(r,a):l?N(r):x(r),T=c?h(s):l?g(p(s)):k(p(s)),j=t&&(c?h(t):l?g(t):k(t)),L=j&&v(T,j)?j:T,P=d(L,M),C=f(s,r)+1,I=[];for(let $=0;$<=P;$++){const E=u(M,$);I.push(E)}const V=(c?35:42)*C;if(i&&I.length<V){const $=V-I.length;for(let E=0;E<$;E++){const D=u(I[I.length-1],1);I.push(D)}}return I}function vh(e){const t=[];return e.reduce((n,a)=>{const r=a.weeks.reduce((s,l)=>s.concat(l.days.slice()),t.slice());return n.concat(r.slice())},t.slice())}function Nh(e,t,n,a){const{numberOfMonths:r=1}=n,s=[];for(let l=0;l<r;l++){const i=a.addMonths(e,l);if(t&&i>t)break;s.push(i)}return s}function dr(e,t,n,a){const{month:r,defaultMonth:s,today:l=a.today(),numberOfMonths:i=1}=e;let c=r||s||l;const{differenceInCalendarMonths:u,addMonths:d,startOfMonth:f}=a;if(n&&u(n,c)<i-1){const h=-1*(i-1);c=d(n,h)}return t&&u(c,t)<0&&(c=t),f(c)}function _h(e,t,n,a){const{addDays:r,endOfBroadcastWeek:s,endOfISOWeek:l,endOfMonth:i,endOfWeek:c,getISOWeek:u,getWeek:d,startOfBroadcastWeek:f,startOfISOWeek:h,startOfWeek:g}=a,p=e.reduce((k,v)=>{const w=n.broadcastCalendar?f(v,a):n.ISOWeek?h(v):g(v),N=n.broadcastCalendar?s(v):n.ISOWeek?l(i(v)):c(i(v)),x=t.filter(L=>L>=w&&L<=N),M=n.broadcastCalendar?35:42;if(n.fixedWeeks&&x.length<M){const L=t.filter(P=>{const C=M-x.length;return P>N&&P<=r(N,C)});x.push(...L)}const T=x.reduce((L,P)=>{const C=n.ISOWeek?u(P):d(P),I=L.find(V=>V.weekNumber===C),K=new _o(P,v,a);return I?I.days.push(K):L.push(new xm(C,[K])),L},[]),j=new bm(v,T);return k.push(j),k},[]);return n.reverseMonths?p.reverse():p}function Mh(e,t){let{startMonth:n,endMonth:a}=e;const{startOfYear:r,startOfDay:s,startOfMonth:l,endOfMonth:i,addYears:c,endOfYear:u,newDate:d,today:f}=t,{fromYear:h,toYear:g,fromMonth:p,toMonth:k}=e;!n&&p&&(n=p),!n&&h&&(n=t.newDate(h,0,1)),!a&&k&&(a=k),!a&&g&&(a=d(g,11,31));const v=e.captionLayout==="dropdown"||e.captionLayout==="dropdown-years";return n?n=l(n):h?n=d(h,0,1):!n&&v&&(n=r(c(e.today??f(),-100))),a?a=i(a):g?a=d(g,11,31):!a&&v&&(a=u(e.today??f())),[n&&s(n),a&&s(a)]}function jh(e,t,n,a){if(n.disableNavigation)return;const{pagedNavigation:r,numberOfMonths:s=1}=n,{startOfMonth:l,addMonths:i,differenceInCalendarMonths:c}=a,u=r?s:1,d=l(e);if(!t)return i(d,u);if(!(c(t,e)<s))return i(d,u)}function Sh(e,t,n,a){if(n.disableNavigation)return;const{pagedNavigation:r,numberOfMonths:s}=n,{startOfMonth:l,addMonths:i,differenceInCalendarMonths:c}=a,u=r?s??1:1,d=l(e);if(!t)return i(d,-u);if(!(c(d,t)<=0))return i(d,-u)}function Ch(e){const t=[];return e.reduce((n,a)=>n.concat(a.weeks.slice()),t.slice())}function Sn(e,t){const[n,a]=m.useState(e);return[t===void 0?n:t,a]}function Dh(e,t){const[n,a]=Mh(e,t),{startOfMonth:r,endOfMonth:s}=t,l=dr(e,n,a,t),[i,c]=Sn(l,e.month?l:void 0);m.useEffect(()=>{const M=dr(e,n,a,t);c(M)},[e.timeZone]);const{months:u,weeks:d,days:f,previousMonth:h,nextMonth:g}=m.useMemo(()=>{const M=Nh(i,a,{numberOfMonths:e.numberOfMonths},t),T=wh(M,e.endMonth?s(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),j=_h(M,T,{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t),L=Ch(j),P=vh(j),C=Sh(i,n,e,t),I=jh(i,a,e,t);return{months:j,weeks:L,days:P,previousMonth:C,nextMonth:I}},[t,i.getTime(),a?.getTime(),n?.getTime(),e.disableNavigation,e.broadcastCalendar,e.endMonth?.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:p,onMonthChange:k}=e,v=M=>d.some(T=>T.days.some(j=>j.isEqualTo(M))),w=M=>{if(p)return;let T=r(M);n&&T<r(n)&&(T=r(n)),a&&T>r(a)&&(T=r(a)),c(T),k?.(T)};return{months:u,weeks:d,days:f,navStart:n,navEnd:a,previousMonth:h,nextMonth:g,goToMonth:w,goToDay:M=>{v(M)||w(M.date)}}}var at;(function(e){e[e.Today=0]="Today",e[e.Selected=1]="Selected",e[e.LastFocused=2]="LastFocused",e[e.FocusedModifier=3]="FocusedModifier"})(at||(at={}));function ur(e){return!e[_e.disabled]&&!e[_e.hidden]&&!e[_e.outside]}function Th(e,t,n,a){let r,s=-1;for(const l of e){const i=t(l);ur(i)&&(i[_e.focused]&&s<at.FocusedModifier?(r=l,s=at.FocusedModifier):a?.isEqualTo(l)&&s<at.LastFocused?(r=l,s=at.LastFocused):n(l.date)&&s<at.Selected?(r=l,s=at.Selected):i[_e.today]&&s<at.Today&&(r=l,s=at.Today))}return r||(r=e.find(l=>ur(t(l)))),r}function Ph(e,t,n,a,r,s,l){const{ISOWeek:i,broadcastCalendar:c}=s,{addDays:u,addMonths:d,addWeeks:f,addYears:h,endOfBroadcastWeek:g,endOfISOWeek:p,endOfWeek:k,max:v,min:w,startOfBroadcastWeek:N,startOfISOWeek:x,startOfWeek:M}=l;let j={day:u,week:f,month:d,year:h,startOfWeek:L=>c?N(L,l):i?x(L):M(L),endOfWeek:L=>c?g(L):i?p(L):k(L)}[e](n,t==="after"?1:-1);return t==="before"&&a?j=v([a,j]):t==="after"&&r&&(j=w([r,j])),j}function Io(e,t,n,a,r,s,l,i=0){if(i>365)return;const c=Ph(e,t,n.date,a,r,s,l),u=!!(s.disabled&&ft(c,s.disabled,l)),d=!!(s.hidden&&ft(c,s.hidden,l)),f=c,h=new _o(c,f,l);return!u&&!d?h:Io(e,t,h,a,r,s,l,i+1)}function Oh(e,t,n,a,r){const{autoFocus:s}=e,[l,i]=m.useState(),c=Th(t.days,n,a||(()=>!1),l),[u,d]=m.useState(s?c:void 0);return{isFocusTarget:k=>!!c?.isEqualTo(k),setFocused:d,focused:u,blur:()=>{i(u),d(void 0)},moveFocus:(k,v)=>{if(!u)return;const w=Io(k,v,u,t.navStart,t.navEnd,e,r);w&&(e.disableNavigation&&!t.days.some(x=>x.isEqualTo(w))||(t.goToDay(w),d(w)))}}}function $h(e,t){const{selected:n,required:a,onSelect:r}=e,[s,l]=Sn(n,r?n:void 0),i=r?n:s,{isSameDay:c}=t,u=g=>i?.some(p=>c(p,g))??!1,{min:d,max:f}=e;return{selected:i,select:(g,p,k)=>{let v=[...i??[]];if(u(g)){if(i?.length===d||a&&i?.length===1)return;v=i?.filter(w=>!c(w,g))}else i?.length===f?v=[g]:v=[...v,g];return r||l(v),r?.(v,g,p,k),v},isSelected:u}}function Wh(e,t,n=0,a=0,r=!1,s=it){const{from:l,to:i}=t||{},{isSameDay:c,isAfter:u,isBefore:d}=s;let f;if(!l&&!i)f={from:e,to:n>0?void 0:e};else if(l&&!i)c(l,e)?n===0?f={from:l,to:e}:r?f={from:l,to:void 0}:f=void 0:d(e,l)?f={from:e,to:l}:f={from:l,to:e};else if(l&&i)if(c(l,e)&&c(i,e))r?f={from:l,to:i}:f=void 0;else if(c(l,e))f={from:l,to:n>0?void 0:e};else if(c(i,e))f={from:e,to:n>0?void 0:e};else if(d(e,l))f={from:e,to:i};else if(u(e,l))f={from:l,to:e};else if(u(e,i))f={from:l,to:e};else throw new Error("Invalid range");if(f?.from&&f?.to){const h=s.differenceInCalendarDays(f.to,f.from);a>0&&h>a?f={from:e,to:void 0}:n>1&&h<n&&(f={from:e,to:void 0})}return f}function Eh(e,t,n=it){const a=Array.isArray(t)?t:[t];let r=e.from;const s=n.differenceInCalendarDays(e.to,e.from),l=Math.min(s,6);for(let i=0;i<=l;i++){if(a.includes(r.getDay()))return!0;r=n.addDays(r,1)}return!1}function fr(e,t,n=it){return ut(e,t.from,!1,n)||ut(e,t.to,!1,n)||ut(t,e.from,!1,n)||ut(t,e.to,!1,n)}function Ah(e,t,n=it){const a=Array.isArray(t)?t:[t];if(a.filter(i=>typeof i!="function").some(i=>typeof i=="boolean"?i:n.isDate(i)?ut(e,i,!1,n):So(i,n)?i.some(c=>ut(e,c,!1,n)):jn(i)?i.from&&i.to?fr(e,{from:i.from,to:i.to},n):!1:jo(i)?Eh(e,i.dayOfWeek,n):ga(i)?n.isAfter(i.before,i.after)?fr(e,{from:n.addDays(i.after,1),to:n.addDays(i.before,-1)},n):ft(e.from,i,n)||ft(e.to,i,n):ya(i)||pa(i)?ft(e.from,i,n)||ft(e.to,i,n):!1))return!0;const l=a.filter(i=>typeof i=="function");if(l.length){let i=e.from;const c=n.differenceInCalendarDays(e.to,e.from);for(let u=0;u<=c;u++){if(l.some(d=>d(i)))return!0;i=n.addDays(i,1)}}return!1}function Fh(e,t){const{disabled:n,excludeDisabled:a,resetOnSelect:r,selected:s,required:l,onSelect:i}=e,[c,u]=Sn(s,i?s:void 0),d=i?s:c;return{selected:d,select:(g,p,k)=>{const{min:v,max:w}=e;let N;if(g){const x=d?.from,M=d?.to,T=!!x&&!!M,j=!!x&&!!M&&t.isSameDay(x,M)&&t.isSameDay(g,x);r&&(T||!d?.from)?!l&&j?N=void 0:N={from:g,to:void 0}:N=Wh(g,d,v,w,l,t)}return a&&n&&N?.from&&N.to&&Ah({from:N.from,to:N.to},n,t)&&(N.from=g,N.to=void 0),i||u(N),i?.(N,g,p,k),N},isSelected:g=>d&&ut(d,g,!1,t)}}function Rh(e,t){const{selected:n,required:a,onSelect:r}=e,[s,l]=Sn(n,r?n:void 0),i=r?n:s,{isSameDay:c}=t;return{selected:i,select:(f,h,g)=>{let p=f;return!a&&i&&i&&c(f,i)&&(p=void 0),r||l(p),r?.(p,f,h,g),p},isSelected:f=>i?c(i,f):!1}}function Ih(e,t){const n=Rh(e,t),a=$h(e,t),r=Fh(e,t);switch(e.mode){case"single":return n;case"multiple":return a;case"range":return r;default:return}}function qe(e,t){return e instanceof Ie&&e.timeZone===t?e:new Ie(e,t)}function At(e,t,n){return qe(e,t)}function mr(e,t,n){return typeof e=="boolean"||typeof e=="function"?e:e instanceof Date?At(e,t):Array.isArray(e)?e.map(a=>a instanceof Date?At(a,t):a):jn(e)?{...e,from:e.from?qe(e.from,t):e.from,to:e.to?qe(e.to,t):e.to}:ga(e)?{before:At(e.before,t),after:At(e.after,t)}:ya(e)?{after:At(e.after,t)}:pa(e)?{before:At(e.before,t)}:e}function Un(e,t,n){return e&&(Array.isArray(e)?e.map(a=>mr(a,t)):mr(e,t))}function Lh(e){let t=e;const n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&(t.today=qe(t.today,n)),t.month&&(t.month=qe(t.month,n)),t.defaultMonth&&(t.defaultMonth=qe(t.defaultMonth,n)),t.startMonth&&(t.startMonth=qe(t.startMonth,n)),t.endMonth&&(t.endMonth=qe(t.endMonth,n)),t.mode==="single"&&t.selected?t.selected=qe(t.selected,n):t.mode==="multiple"&&t.selected?t.selected=t.selected?.map(se=>qe(se,n)):t.mode==="range"&&t.selected&&(t.selected={from:t.selected.from?qe(t.selected.from,n):t.selected.from,to:t.selected.to?qe(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=Un(t.disabled,n)),t.hidden!==void 0&&(t.hidden=Un(t.hidden,n)),t.modifiers)){const se={};Object.keys(t.modifiers).forEach(re=>{se[re]=Un(t.modifiers?.[re],n)}),t.modifiers=se}const{components:a,formatters:r,labels:s,dateLib:l,locale:i,classNames:c}=m.useMemo(()=>{const se={...No,...t.locale},re=t.broadcastCalendar?1:t.weekStartsOn,ee=t.noonSafe&&t.timeZone?yh(t.timeZone,{weekStartsOn:re,locale:se}):void 0,ce=t.dateLib&&ee?{...ee,...t.dateLib}:t.dateLib??ee,Ce=new Ue({locale:se,weekStartsOn:re,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},ce);return{dateLib:Ce,components:Km(t.components),formatters:sh(t.formatters),labels:uh(t.labels,Ce.options),locale:se,classNames:{...Qm(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.noonSafe,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:l.today()});const{captionLayout:u,mode:d,navLayout:f,numberOfMonths:h=1,onDayBlur:g,onDayClick:p,onDayFocus:k,onDayKeyDown:v,onDayMouseEnter:w,onDayMouseLeave:N,onNextClick:x,onPrevClick:M,showWeekNumber:T,styles:j}=t,{formatCaption:L,formatDay:P,formatMonthDropdown:C,formatWeekNumber:I,formatWeekNumberHeader:K,formatWeekdayName:V,formatYearDropdown:$}=r,E=Dh(t,l),{days:D,months:b,navStart:_,navEnd:H,previousMonth:S,nextMonth:X,goToMonth:F}=E,z=qm(D,t,_,H,l),{isSelected:B,select:Z,selected:xe}=Ih(t,l)??{},{blur:je,focused:Me,isFocusTarget:Se,moveFocus:J,setFocused:De}=Oh(t,E,z,B??(()=>!1),l),{labelDayButton:le,labelGridcell:de,labelGrid:W,labelMonthDropdown:te,labelNav:ge,labelPrevious:me,labelNext:Ne,labelWeekday:Fe,labelWeekNumber:Te,labelWeekNumberHeader:A,labelYearDropdown:Y}=s,U=m.useMemo(()=>hh(l,t.ISOWeek,t.broadcastCalendar,t.today),[l,t.ISOWeek,t.broadcastCalendar,t.today]),q=d!==void 0||p!==void 0,ne=m.useCallback(()=>{S&&(F(S),M?.(S))},[S,F,M]),oe=m.useCallback(()=>{X&&(F(X),x?.(X))},[F,X,x]),ye=m.useCallback((se,re)=>ee=>{ee.preventDefault(),ee.stopPropagation(),De(se),!re.disabled&&(Z?.(se.date,re,ee),p?.(se.date,re,ee))},[Z,p,De]),fe=m.useCallback((se,re)=>ee=>{De(se),k?.(se.date,re,ee)},[k,De]),he=m.useCallback((se,re)=>ee=>{je(),g?.(se.date,re,ee)},[je,g]),Pe=m.useCallback((se,re)=>ee=>{const ce={ArrowLeft:[ee.shiftKey?"month":"day",t.dir==="rtl"?"after":"before"],ArrowRight:[ee.shiftKey?"month":"day",t.dir==="rtl"?"before":"after"],ArrowDown:[ee.shiftKey?"year":"week","after"],ArrowUp:[ee.shiftKey?"year":"week","before"],PageUp:[ee.shiftKey?"year":"month","before"],PageDown:[ee.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(ce[ee.key]){ee.preventDefault(),ee.stopPropagation();const[Ce,ie]=ce[ee.key];J(Ce,ie)}v?.(se.date,re,ee)},[J,v,t.dir]),pe=m.useCallback((se,re)=>ee=>{w?.(se.date,re,ee)},[w]),We=m.useCallback((se,re)=>ee=>{N?.(se.date,re,ee)},[N]),Ee=m.useCallback(se=>re=>{const ee=Number(re.target.value),ce=l.setMonth(l.startOfMonth(se),ee);F(ce)},[l,F]),Be=m.useCallback(se=>re=>{const ee=Number(re.target.value),ce=l.setYear(l.startOfMonth(se),ee);F(ce)},[l,F]),{className:Mt,style:gt}=m.useMemo(()=>({className:[c[Q.Root],t.className].filter(Boolean).join(" "),style:{...j?.[Q.Root],...t.style}}),[c,t.className,t.style,j]),yt=Gm(t),tt=m.useRef(null);kh(tt,!!t.animate,{classNames:c,months:b,focused:Me,dateLib:l});const pt={dayPickerProps:t,selected:xe,select:Z,isSelected:B,months:b,nextMonth:X,previousMonth:S,goToMonth:F,getModifiers:z,components:a,classNames:c,styles:j,labels:s,formatters:r};return R.createElement(Mo.Provider,{value:pt},R.createElement(a.Root,{rootRef:t.animate?tt:void 0,className:Mt,style:gt,dir:t.dir,id:t.id,lang:t.lang??i.code,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t["aria-label"],"aria-labelledby":t["aria-labelledby"],...yt},R.createElement(a.Months,{className:c[Q.Months],style:j?.[Q.Months]},!t.hideNavigation&&!f&&R.createElement(a.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[Q.Nav],style:j?.[Q.Nav],"aria-label":ge(),onPreviousClick:ne,onNextClick:oe,previousMonth:S,nextMonth:X}),b.map((se,re)=>R.createElement(a.Month,{"data-animated-month":t.animate?"true":void 0,className:c[Q.Month],style:j?.[Q.Month],key:re,displayIndex:re,calendarMonth:se},f==="around"&&!t.hideNavigation&&re===0&&R.createElement(a.PreviousMonthButton,{type:"button",className:c[Q.PreviousMonthButton],tabIndex:S?void 0:-1,"aria-disabled":S?void 0:!0,"aria-label":me(S),onClick:ne,"data-animated-button":t.animate?"true":void 0},R.createElement(a.Chevron,{disabled:S?void 0:!0,className:c[Q.Chevron],orientation:t.dir==="rtl"?"right":"left"})),R.createElement(a.MonthCaption,{"data-animated-caption":t.animate?"true":void 0,className:c[Q.MonthCaption],style:j?.[Q.MonthCaption],calendarMonth:se,displayIndex:re},u?.startsWith("dropdown")?R.createElement(a.DropdownNav,{className:c[Q.Dropdowns],style:j?.[Q.Dropdowns]},(()=>{const ee=u==="dropdown"||u==="dropdown-months"?R.createElement(a.MonthsDropdown,{key:"month",className:c[Q.MonthsDropdown],"aria-label":te(),classNames:c,components:a,disabled:!!t.disableNavigation,onChange:Ee(se.date),options:fh(se.date,_,H,r,l),style:j?.[Q.Dropdown],value:l.getMonth(se.date)}):R.createElement("span",{key:"month"},C(se.date,l)),ce=u==="dropdown"||u==="dropdown-years"?R.createElement(a.YearsDropdown,{key:"year",className:c[Q.YearsDropdown],"aria-label":Y(l.options),classNames:c,components:a,disabled:!!t.disableNavigation,onChange:Be(se.date),options:gh(_,H,r,l,!!t.reverseYears),style:j?.[Q.Dropdown],value:l.getYear(se.date)}):R.createElement("span",{key:"year"},$(se.date,l));return l.getMonthYearOrder()==="year-first"?[ce,ee]:[ee,ce]})(),R.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"}},L(se.date,l.options,l))):R.createElement(a.CaptionLabel,{className:c[Q.CaptionLabel],role:"status","aria-live":"polite"},L(se.date,l.options,l))),f==="around"&&!t.hideNavigation&&re===h-1&&R.createElement(a.NextMonthButton,{type:"button",className:c[Q.NextMonthButton],tabIndex:X?void 0:-1,"aria-disabled":X?void 0:!0,"aria-label":Ne(X),onClick:oe,"data-animated-button":t.animate?"true":void 0},R.createElement(a.Chevron,{disabled:X?void 0:!0,className:c[Q.Chevron],orientation:t.dir==="rtl"?"left":"right"})),re===h-1&&f==="after"&&!t.hideNavigation&&R.createElement(a.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[Q.Nav],style:j?.[Q.Nav],"aria-label":ge(),onPreviousClick:ne,onNextClick:oe,previousMonth:S,nextMonth:X}),R.createElement(a.MonthGrid,{role:"grid","aria-multiselectable":d==="multiple"||d==="range","aria-label":W(se.date,l.options,l)||void 0,className:c[Q.MonthGrid],style:j?.[Q.MonthGrid]},!t.hideWeekdays&&R.createElement(a.Weekdays,{"data-animated-weekdays":t.animate?"true":void 0,className:c[Q.Weekdays],style:j?.[Q.Weekdays]},T&&R.createElement(a.WeekNumberHeader,{"aria-label":A(l.options),className:c[Q.WeekNumberHeader],style:j?.[Q.WeekNumberHeader],scope:"col"},K()),U.map(ee=>R.createElement(a.Weekday,{"aria-label":Fe(ee,l.options,l),className:c[Q.Weekday],key:String(ee),style:j?.[Q.Weekday],scope:"col"},V(ee,l.options,l)))),R.createElement(a.Weeks,{"data-animated-weeks":t.animate?"true":void 0,className:c[Q.Weeks],style:j?.[Q.Weeks]},se.weeks.map(ee=>R.createElement(a.Week,{className:c[Q.Week],key:ee.weekNumber,style:j?.[Q.Week],week:ee},T&&R.createElement(a.WeekNumber,{week:ee,style:j?.[Q.WeekNumber],"aria-label":Te(ee.weekNumber,{locale:i}),className:c[Q.WeekNumber],scope:"row",role:"rowheader"},I(ee.weekNumber,l)),ee.days.map(ce=>{const{date:Ce}=ce,ie=z(ce);if(ie[_e.focused]=!ie.hidden&&!!Me?.isEqualTo(ce),ie[Ze.selected]=B?.(Ce)||ie.selected,jn(xe)){const{from:jt,to:bt}=xe;ie[Ze.range_start]=!!(jt&&bt&&l.isSameDay(Ce,jt)),ie[Ze.range_end]=!!(jt&&bt&&l.isSameDay(Ce,bt)),ie[Ze.range_middle]=ut(xe,Ce,!0,l)}const ze=mh(ie,j,t.modifiersStyles),zt=Xm(ie,c,t.modifiersClassNames),Bt=!q&&!ie.hidden?de(Ce,ie,l.options,l):void 0;return R.createElement(a.Day,{key:`${ce.isoDate}_${ce.displayMonthId}`,day:ce,modifiers:ie,className:zt.join(" "),style:ze,role:"gridcell","aria-selected":ie.selected||void 0,"aria-label":Bt,"data-day":ce.isoDate,"data-month":ce.outside?ce.dateMonthId:void 0,"data-selected":ie.selected||void 0,"data-disabled":ie.disabled||void 0,"data-hidden":ie.hidden||void 0,"data-outside":ce.outside||void 0,"data-focused":ie.focused||void 0,"data-today":ie.today||void 0},!ie.hidden&&q?R.createElement(a.DayButton,{className:c[Q.DayButton],style:j?.[Q.DayButton],type:"button",day:ce,modifiers:ie,disabled:!ie.focused&&ie.disabled||void 0,"aria-disabled":ie.focused&&ie.disabled||void 0,tabIndex:Se(ce)?0:-1,"aria-label":le(Ce,ie,l.options,l),onClick:ye(ce,ie),onBlur:he(ce,ie),onFocus:fe(ce,ie),onKeyDown:Pe(ce,ie),onMouseEnter:pe(ce,ie),onMouseLeave:We(ce,ie)},P(Ce,l.options,l)):!ie.hidden&&P(ce.date,l.options,l))})))))))),t.footer&&R.createElement(a.Footer,{className:c[Q.Footer],style:j?.[Q.Footer],role:"status","aria-live":"polite"},t.footer)))}const Yh={en:vt,"zh-CN":Yf,"zh-TW":pm,ja:Wu,ko:uf};function Lo(e){return Yh[e]||vt}function hr(e,t){if(!e)return"";const n=e.split("-");if(n.length!==3)return e;const a=new Date(Number(n[0]),Number(n[1])-1,Number(n[2]));return Number.isFinite(a.getTime())?st(a,"MMM d",t?{locale:t}:void 0):e}function ra({from:e,to:t,onApply:n,onCancel:a}){const r=m.useMemo(()=>{const d={from:void 0,to:void 0};if(e){const f=e.split("-");d.from=new Date(Number(f[0]),Number(f[1])-1,Number(f[2]))}if(t){const f=t.split("-");d.to=new Date(Number(f[0]),Number(f[1])-1,Number(f[2]))}return d},[e,t]),[s,l]=m.useState(r),i=Lo(zr()),c=()=>{if(!s?.from)return;const d=st(s.from,"yyyy-MM-dd"),f=s.to?st(s.to,"yyyy-MM-dd"):d;n?.(d,f)},u=!!s?.from;return o.jsxs("div",{className:"p-4",children:[o.jsx(Lh,{mode:"range",locale:i,selected:s,onSelect:l,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"}}}),o.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:[u&&s.from&&o.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mr-auto",children:[st(s.from,"MMM d, yyyy",{locale:i}),s.to&&s.to.getTime()!==s.from.getTime()?` — ${st(s.to,"MMM d, yyyy",{locale:i})}`:""]}),o.jsx(Kn,{variant:"secondary",size:"sm",onClick:a,children:y("shared.action.cancel")}),o.jsx(Kn,{variant:"primary",size:"sm",onClick:c,disabled:!u,children:y("shared.action.apply")})]})]})}function ka(e){if(!Number.isFinite(Number(e)))return null;const t=Number(e);return t<=0?null:Ae(t,{decimals:1})}function wa(e,t,n){const a=Number(e);if(!Number.isFinite(a)||a<=0)return null;const r=ia(t);return(t===Yr?a:a*n)<.01?`<${r}0.01`:et(a,{decimals:2,currency:t,rate:n})}function zh(e,t,n){const a=wa(e,t,n);return a?`${a}/MTok`:null}function Gt(e){return e?String(e).replace(/^claude-/,""):""}function Bh(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?{key:t,label:gr(t)}:{key:t.key,label:t.label||gr(t.key)}):[]}function Hh(e){if(typeof e!="string")return null;const t=e.replace(/,/g,"").match(/-?\d+(?:\.\d+)?/);if(!t)return null;const n=Number(t[0]);return Number.isFinite(n)?n:null}const Uh={CODEX:"#3b82f6",CLAUDE:"#d97757",OPENCODE:"#f59e0b",GEMINI:"#2196f3",KIMI:"#a78bfa","KILO-CLI":"#facc15","KILO-CODE":"#facc15",DROID:"#ef4444"};function Vn(e,t){const n=e?.toUpperCase?.()||"";return Uh[n]||`hsl(${150+t*40}, 60%, 45%)`}function Qt(e){const t=String(e?.source||"").trim().toLowerCase(),n=String(e?.label||"").trim().toLowerCase();return t==="claude"||n==="claude"?"claude":t==="codex"||n==="codex"?"codex":null}function va(e){return!!e?.models?.length}function Vh(e){const t=Number(e);return!Number.isFinite(t)||t<=0?"0%":`${Math.min(100,Math.max(2,t))}%`}function qh(e,t){const n=String(e?.id||e?.name||"").trim().toLowerCase(),a=String(t?.id||t?.name||"").trim().toLowerCase();return!!(n&&a&&n===a)}function Xh(e,t=3){return[...e?.models||[]].sort((n,a)=>(Number(a.share)||0)-(Number(n.share)||0)).slice(0,t)}function Kh(e,t){return Math.max(0,(e?.models?.length||0)-t.length)}const Gh={day:"usage.period.day","24h":"usage.period.last24h",week:"usage.period.week",month:"usage.period.month",total:"usage.period.total",custom:"usage.period.custom"};function gr(e){const t=Gh[e];return t?y(t):String(e).toUpperCase()}function Qh({loading:e,onClick:t}){const n=Lt();return o.jsx(Kn,{variant:"secondary",size:"sm",disabled:e,onClick:t,"aria-label":y("usage.button.refresh"),className:"w-8 p-0",children:o.jsx(ht.span,{"aria-hidden":"true",animate:e?{rotate:360}:{rotate:0},transition:e&&!n?{duration:1,repeat:1/0,ease:"linear"}:{duration:.3},style:{display:"inline-block"},children:"↻"})})}function yr({period:e,periods:t,onPeriodChange:n,autoRefreshOptions:a=[],autoRefreshIntervalMs:r,onAutoRefreshIntervalChange:s,summaryValue:l,summaryLabel:i,summaryUpdatedAtLabel:c,summaryCostValue:u,usageInsights:d,onCostInfo:f,onRefresh:h,loading:g,customFrom:p,customTo:k,onCustomRangeApply:v,customRangeOpen:w,onCustomRangeOpenChange:N,emphasized:x=!1}){const M=Lt(),T=Bh(t),j=Array.isArray(a)&&a.length>0&&typeof s=="function",L=Lo(zr()),P=Hh(String(l??"")),C=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches,[I,K]=m.useState(C);m.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const W=window.matchMedia("(max-width: 639px)"),te=ge=>K(ge.matches);return W.addEventListener("change",te),()=>W.removeEventListener("change",te)},[]);const V=P!=null&&!I&&!g&&!M,$=x&&l!=null&&String(l)!=="",E=m.useRef(null);m.useEffect(()=>{const W=E.current?.querySelector('[aria-selected="true"]');W&&typeof W.scrollIntoView=="function"&&W.scrollIntoView({block:"nearest",inline:"center"})},[e]);const{resolvedTheme:D}=Lr(),{currency:b,rate:_}=_t(),H=D==="dark",S=H?"rgba(10,10,10,0.98)":"rgba(255,255,255,0.96)",X=H?"rgba(10,10,10,0)":"rgba(255,255,255,0)",F=zh(d?.costPerMillionTokens,b,_),z=d?.topCostModel?.name?Gt(d.topCostModel.name):"",B=d?.topUsageModel?.name?Gt(d.topUsageModel.name):"",Z=Array.isArray(d?.missingPricingModels)?d.missingPricingModels.length:0,xe=!!Z,je=!!(F||z||B||xe),Me=x?"h-full flex flex-col !bg-oai-brand-50 dark:!bg-oai-brand-950/40 !border-oai-brand-200 dark:!border-oai-brand-800":"",Se=x?"flex-1 flex flex-col":"",J=x?"flex flex-1 flex-col justify-center":"",De=x?"flex flex-col gap-3":"flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between",le=x?"flex flex-col gap-2":"flex flex-col gap-2 sm:items-end",de=x?"flex flex-wrap items-center gap-1.5 text-[11px] font-medium":"flex flex-wrap items-center gap-1.5 text-[11px] font-medium sm:justify-end";return o.jsxs(rn,{className:Me,bodyClassName:Se,children:[o.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[o.jsx("div",{ref:E,role:"tablist","aria-label":y("usage.overview.tablist_aria"),className:"flex flex-1 min-w-0 gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:T.map(W=>{const te=e===W.key,ge=`shrink-0 whitespace-nowrap text-xs font-medium px-3 py-1.5 rounded-md transition-colors ${te?"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(W.key==="custom"){const me=te&&p&&k?`${hr(p,L)} — ${hr(k,L)}`:W.label;return o.jsxs(Qn,{open:w,onOpenChange:Ne=>{Ne?n?.("custom"):N?.(Ne)},children:[o.jsx(Jn,{render:o.jsx("button",{role:"tab","aria-selected":te,type:"button",className:ge}),children:me}),o.jsx(Zn,{children:o.jsx(ea,{sideOffset:8,side:"bottom",align:"start",className:"!z-[9999]",children:o.jsx(ta,{className:"bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded-xl shadow-lg",children:o.jsx(ra,{from:p,to:k,onApply:v,onCancel:()=>N?.(!1)})})})})]},"custom")}return o.jsx("button",{role:"tab","aria-selected":te,type:"button",className:ge,onClick:()=>n?.(W.key),children:W.label},W.key)})}),o.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[j?o.jsx("select",{"aria-label":y("usage.auto_refresh.aria"),value:String(r),onChange:W=>s(W.target.value),className:"h-8 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 bg-oai-white dark:bg-oai-gray-900 px-2 text-xs font-medium text-oai-gray-700 dark:text-oai-gray-200 transition-colors hover:border-oai-gray-400 dark:hover:border-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand/25",children:a.map(W=>o.jsx("option",{value:String(W.value),children:y(W.labelKey)},W.value))}):null,h&&o.jsx(Qh,{loading:g,onClick:h})]})]}),o.jsx("div",{className:J,children:o.jsxs("div",{className:De,children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wider mb-2",children:i}),o.jsx("div",{className:"text-5xl sm:text-6xl md:text-7xl font-bold text-oai-black dark:text-oai-white tracking-tight tabular-nums leading-none [container-type:inline-size]",children:$?o.jsx(rl,{value:l,fontSize:58}):V?o.jsx(Zi,{value:P,displayValue:l,fontSize:72,padding:6,gap:1,textColor:"var(--oai-black, #111827)",fontWeight:700,gradientHeight:H?0:8,gradientFrom:S,gradientTo:X,counterStyle:{paddingLeft:0,paddingRight:0,gap:0},digitStyle:{width:"0.88ch"}}):l}),c?o.jsx("div",{className:"mt-2 text-[11px] font-medium text-oai-gray-400 dark:text-oai-gray-500 tabular-nums",children:c}):null]}),(u||je)&&o.jsxs("div",{className:le,children:[u&&o.jsx("div",{className:"flex items-center gap-2",children:f?o.jsxs("button",{type:"button",onClick:f,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":y("usage.overview.cost_breakdown_aria"),children:[u,o.jsx(ca,{size:16,strokeWidth:2,className:"opacity-80"})]}):o.jsx("span",{className:"text-xl font-bold text-oai-brand",children:u})}),je&&o.jsxs("div",{className:de,children:[F?o.jsx("span",{className:"rounded-md border border-oai-gray-200 dark:border-oai-gray-700 px-2 py-1 text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:y("usage.overview.cost_per_mtok",{value:F})}):null,z?o.jsx("span",{className:"rounded-md border border-oai-gray-200 dark:border-oai-gray-700 px-2 py-1 text-oai-gray-600 dark:text-oai-gray-300",children:y("usage.overview.top_cost_model",{model:z})}):null,B&&B!==z?o.jsx("span",{className:"rounded-md border border-oai-gray-200 dark:border-oai-gray-700 px-2 py-1 text-oai-gray-600 dark:text-oai-gray-300",children:y("usage.overview.top_usage_model",{model:B})}):null,xe?o.jsx("span",{className:"rounded-md border border-amber-200 bg-amber-50 px-2 py-1 text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200",children:y("usage.overview.missing_pricing_count",{count:Z})}):null]})]})]})})]})}const pr={claude:35,codex:250},br={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 Jh(e,t){const n=pr[t]??pr.claude,a=br[e]||br.system_prompt;return`oklch(${a.l} ${a.c} ${n})`}const Zh=[{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"]}],e0=[["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"]],t0={duration:.18,ease:[.4,0,.2,1]},n0={height:0,opacity:0},a0={height:"auto",opacity:1},r0={height:0,opacity:0};function o0(e){const t=Number(e||0);return Number.isFinite(t)&&t>0?t:0}function s0(e,t){const n={};for(const a of["input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens","total_tokens"])n[a]=Math.round(Number(e?.[a]||0)*t);return n}function Yo(e,t=null){const n=e.reduce((l,i)=>l+Number(i.totals.total_tokens||0),0),a=o0(t),r=a||n,s=a&&n>0?a/n:1;return e.map(l=>{const i=s===1?l.totals:s0(l.totals,s);return{...l,totals:i,percent:r>0?Number((i.total_tokens/r*100).toFixed(2)):0}}).sort((l,i)=>i.totals.total_tokens-l.totals.total_tokens)}function i0(e,t=null){const n=new Map;for(const r of e||[])n.set(r.key,r);const a=Zh.map(r=>{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 l of r.from){const i=n.get(l);if(!i)continue;const c=i.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:r.key,totals:s}});return Yo(a,t)}function l0(e,t=null){const n=e?.totals||{},a=Number(n.reasoning_output_tokens||0),r=(e?.tool_calls_breakdown?.categories||[]).reduce((u,d)=>d?.name==="Text Response"?u:u+Number(d?.totals?.total_tokens||0),0),s=Number(n.total_tokens||0),l=Math.min(Math.max(0,r),Math.max(0,s-a)),c=[{key:"messages",totals:{total_tokens:Math.max(0,s-a-l)}},{key:"tool_calls",totals:{total_tokens:l}},{key:"reasoning",totals:{total_tokens:a}}];return Yo(c,t)}const xr="MCP: ";function c0(e){if(!e?.categories?.length)return{mcpSet:null,residualSet:e,mcpTotalTokens:0};const t=[],n=[];let a=0;for(const r of e.categories){const s=String(r?.name||"");s.startsWith(xr)?(t.push({...r,name:s.slice(xr.length)}),a+=Number(r?.totals?.total_tokens||0)):n.push(r)}return t.length===0?{mcpSet:null,residualSet:e,mcpTotalTokens:0}:(t.sort((r,s)=>(s.totals?.total_tokens||0)-(r.totals?.total_tokens||0)),{mcpSet:{...e,categories:t},residualSet:{...e,categories:n},mcpTotalTokens:a})}function kr(e){return y(`dashboard.context_breakdown.category.${e}`)}function rt(e){return!Number.isFinite(Number(e))||Number(e)<=0?"0":Ae(Number(e),{decimals:1})}function d0(e){return typeof e!="string"?"":e.startsWith("mcp__")?e.split("__").slice(2).join("__")||e:e.includes("/")&&e.split("/").pop()||e}function u0(e){return(Array.isArray(e)?e:[]).map(t=>{const n=t?.totals||null,a=Number(n?n.input_tokens||0:t?.input_tokens||0),r=Number(n?n.output_tokens||0:t?.output_tokens||0),s=Number(n?n.cached_input_tokens||0:t?.cache_read||0),l=Number(n?n.cache_creation_input_tokens||0:t?.cache_creation||0),i=Number(n?n.total_tokens||a+r:t?.total_tokens||r);return{name:d0(t?.name?String(t.name):""),calls:Number(t?.calls||0),input_tokens:a,output_tokens:r,cache_read:s,cache_creation:l,total_tokens:Number(i||0)}}).filter(t=>t.name).sort((t,n)=>(n.total_tokens||0)-(t.total_tokens||0))}function f0(e){return(Array.isArray(e)?e:[]).map(t=>{const n=t?.totals||{},a=Array.isArray(t?.tools)?t.tools:[],r=Number(n.input_tokens||0),s=Number(n.output_tokens||0),l=Number(n.cached_input_tokens||0),i=Number(n.cache_creation_input_tokens||0);return{name:t?.name?String(t.name):"",calls:Number(t?.calls||0),totals:{input_tokens:r,output_tokens:s,cached_input_tokens:l,cache_creation_input_tokens:i,total_tokens:Number(n.total_tokens||r+s)},tools:u0(a),toolCount:a.length}}).filter(t=>t.name).sort((t,n)=>(n.totals.total_tokens||0)-(t.totals.total_tokens||0))}function m0(e){return(Array.isArray(e)?e:[]).map(t=>{const n=t?.totals||{},a=Number(n.input_tokens||0),r=Number(n.output_tokens||0),s=Number(n.cached_input_tokens||0),l=Number(n.cache_creation_input_tokens||0);return{key:t?.key?String(t.key):"",name:t?.name?String(t.name):"",totals:{input_tokens:a,output_tokens:r,cached_input_tokens:s,cache_creation_input_tokens:l,total_tokens:Number(n.total_tokens||a+r+s+l)}}}).filter(t=>t.key||t.name).sort((t,n)=>(n.totals.total_tokens||0)-(t.totals.total_tokens||0))}function h0(e){return(Array.isArray(e)?e:[]).map(t=>{const n=t?.totals||{};return{name:t?.name?String(t.name):"",calls:Number(t?.calls||0),total_tokens:Number(n.total_tokens||0)}}).filter(t=>t.name).sort((t,n)=>Number(n.total_tokens||0)-Number(t.total_tokens||0))}function g0(e){if(e?.key){const t=y(`dashboard.context_breakdown.message_details.${e.key}`);if(t&&!t.includes("dashboard.context_breakdown"))return t}return e?.name||""}function y0(e){return(Array.isArray(e)?e:[]).map(t=>{const n=t?.totals||{},a=Number(n.input_tokens||0),r=Number(n.output_tokens||0),s=Number(n.cached_input_tokens||0),l=Number(n.cache_creation_input_tokens||0);return{name:t?.name?String(t.name):"",calls:Number(t?.calls||0),failures:Number(t?.failures||0),duration_ms:Number(t?.duration_ms||0),max_duration_ms:Number(t?.max_duration_ms||0),output_chars:Number(t?.output_chars||0),output_lines:Number(t?.output_lines||0),totals:{input_tokens:a,output_tokens:r,cached_input_tokens:s,cache_creation_input_tokens:l,total_tokens:Number(n.total_tokens||a+r)}}}).filter(t=>t.name).sort((t,n)=>Number(n.totals.total_tokens||0)-Number(t.totals.total_tokens||0))}function wr(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"0ms":t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:`${Math.round(t/1e3)}s`}function p0(e,t){return e?t==="by_executable"?e.by_executable||[]:t==="by_command"?e.by_command||[]:t==="by_duration"?e.by_duration||[]:t==="by_output"?e.by_output||[]:t==="by_exit"?e.by_exit||[]:e.by_type||[]:[]}function vr(e){return e==="exec_command"||e==="Bash"}function zo(e){return e==="codex"?"dashboard.context_breakdown.empty_codex":"dashboard.context_breakdown.empty"}function b0(e){return e==="codex"?"dashboard.context_breakdown.error_codex":"dashboard.context_breakdown.error"}function x0(e){return e==="codex"?"dashboard.context_breakdown.footnote_codex":"dashboard.context_breakdown.footnote"}const k0=10;function ct({level:e=0,colorSquare:t=null,label:n,labelSuffix:a=null,labelTone:r="default",hasChevron:s=!1,open:l=!1,onToggle:i,tokens:c,percent:u=null,children:d,share:f=null,fillColor:h=null}){const g=r==="accent"?"text-oai-brand truncate":r==="muted"?"text-oai-gray-500 dark:text-oai-gray-400 truncate":r==="strong"?"font-medium text-oai-black dark:text-oai-white truncate":"text-oai-gray-700 dark:text-oai-gray-300 truncate",p=o.jsx("span",{className:"shrink-0 flex items-center justify-start",style:{width:k0},"aria-hidden":!t,children:t}),k=o.jsxs(o.Fragment,{children:[p,o.jsx("span",{className:g,children:n}),a,s&&o.jsx(ht.span,{animate:{rotate:l?90:0},transition:{duration:.15},className:"shrink-0 text-oai-gray-400 dark:text-oai-gray-500 flex items-center","aria-hidden":"true",children:o.jsx(Br,{size:11})})]}),v=h&&f!=null&&f>0,w=v?Math.max(0,Math.min(100,f)):0;return o.jsxs("li",{className:"min-w-0 group/row",children:[o.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:v?{backgroundImage:`linear-gradient(to right, ${h.replace(/\)\s*$/," / 0.10)")} 0%, ${h.replace(/\)\s*$/," / 0.10)")} ${w}%, transparent ${w}%)`}:void 0,children:[s?o.jsx("button",{type:"button",onClick:i,"aria-expanded":l,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:k}):o.jsx("div",{className:"relative flex items-center gap-1.5 min-w-0",children:k}),o.jsx("span",{className:"relative text-right tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:c||""}),o.jsx("span",{className:"relative text-right tabular-nums text-[10px] text-oai-gray-400 dark:text-oai-gray-500 font-normal",children:u||""})]}),s&&d?o.jsx(Hr,{initial:!1,children:l&&o.jsx(ht.div,{initial:n0,animate:a0,exit:r0,transition:t0,style:{overflow:"hidden"},children:d},"content")}):null]})}function Nr({execDetails:e,source:t="claude"}){const[n,a]=m.useState("by_type"),r=y0(p0(e,n)),s=t==="codex",l=s?"grid-cols-[minmax(0,1fr)_48px_48px_72px_72px_60px_60px]":"grid-cols-[minmax(0,1fr)_56px_60px]";return o.jsxs("div",{className:"mt-2 ml-4",children:[o.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:e0.map(([i,c])=>o.jsx("button",{type:"button",onClick:()=>a(i),className:"h-7 px-2 rounded-md text-[10px] font-medium transition-colors "+(n===i?"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:y(c)},i))}),r.length===0?o.jsx("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:"—"}):o.jsx("div",{className:"mt-2 overflow-x-auto",children:o.jsxs("div",{role:"table","aria-label":y("dashboard.context_breakdown.exec_details.title"),className:s?"min-w-[420px]":"min-w-[260px]",children:[o.jsxs("div",{role:"row",className:`grid ${l} 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:[o.jsx("span",{role:"columnheader",children:y("dashboard.context_breakdown.exec_details.kind_column")}),o.jsx("span",{role:"columnheader",className:"text-right",children:y("dashboard.context_breakdown.exec_details.calls_column")}),s&&o.jsxs(o.Fragment,{children:[o.jsx("span",{role:"columnheader",className:"text-right",children:y("dashboard.context_breakdown.exec_details.failures_column")}),o.jsx("span",{role:"columnheader",className:"text-right",children:y("dashboard.context_breakdown.exec_details.duration_column")}),o.jsx("span",{role:"columnheader",className:"text-right",children:y("dashboard.context_breakdown.exec_details.max_duration_column")})]}),o.jsx("span",{role:"columnheader",className:"text-right",children:y("dashboard.context_breakdown.tool_details.total_column")}),s&&o.jsx("span",{role:"columnheader",className:"text-right",children:y("dashboard.context_breakdown.exec_details.output_column")})]}),r.map((i,c)=>o.jsxs(ht.div,{role:"row",className:`grid ${l} gap-2 py-1.5`,title:i.name,initial:{opacity:0},animate:{opacity:1},transition:{duration:.18,delay:c*.02},children:[o.jsx("span",{role:"cell",className:"min-w-0 text-body-sm font-medium text-oai-black dark:text-oai-white truncate",children:i.name}),o.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ae(i.calls||0)}),s&&o.jsxs(o.Fragment,{children:[o.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ae(i.failures||0)}),o.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:wr(i.duration_ms||0)}),o.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:wr(i.max_duration_ms||0)})]}),o.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:rt(i.totals.total_tokens||0)}),s&&o.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ae(i.output_lines||0)})]},i.name))]})})]})}function qt({toolSet:e,execDetails:t,source:n,codexQueueFallback:a}){const[r,s]=m.useState({}),[l,i]=m.useState(!1),c=f0(e?.categories||[]);function u(d){s(f=>({...f,[d]:!f[d]}))}return c.length===0?o.jsx("p",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500 py-0.5",children:n==="codex"&&a?y("dashboard.context_breakdown.tool_details.unavailable_codex"):y(zo(n))}):o.jsx("ul",{className:"mt-0.5 mb-0.5 space-y-0.5",children:c.map(d=>{const f=d.toolCount>0,h=d.name==="Execution"&&t,g=h&&d.tools.some(k=>vr(k.name)),p=!!r[d.name];return o.jsxs(ct,{level:1,label:d.name,labelTone:"strong",hasChevron:f||h&&!g,open:p||h&&!g&&l,onToggle:()=>{f?u(d.name):h&&!g&&i(k=>!k)},tokens:rt(d.totals.total_tokens||0),percent:null,children:[f&&o.jsx("ul",{className:"space-y-0.5",children:d.tools.map(k=>{const v=h&&vr(k.name);return o.jsx(ct,{level:2,label:k.name,labelTone:v?"accent":"default",hasChevron:v,open:l,onToggle:()=>i(w=>!w),tokens:rt(k.total_tokens||0),percent:null,children:v&&o.jsx(Nr,{execDetails:t,source:n})},k.name)})}),h&&!g&&o.jsx(Nr,{execDetails:t,source:n})]},d.name)})})}function Bo({from:e,to:t,source:n="claude",referenceTotalTokens:a=null,onLoadingChange:r=null}){const[s,l]=m.useState(null),[i,c]=m.useState(!1),[u,d]=m.useState(null),[f,h]=m.useState({});function g(b){h(_=>({..._,[b]:!_[b]}))}if(m.useEffect(()=>{let b=!1;return c(!0),r?.(!0),d(null),pi({from:e,to:t,source:n,timeZone:Vr(),tzOffsetMinutes:Ur()}).then(_=>{b||l(_)}).catch(_=>{b||d(_?.message||String(_))}).finally(()=>{b||(c(!1),r?.(!1))}),()=>{b=!0}},[e,t,n]),i&&!s)return o.jsxs("div",{children:[o.jsx("div",{className:"h-1 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden animate-pulse"}),o.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(b=>o.jsx("div",{className:"h-3 rounded bg-oai-gray-100 dark:bg-oai-gray-800 animate-pulse",style:{animationDelay:`${b*80}ms`}},b))}),o.jsx("p",{className:"mt-3 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:y("dashboard.context_breakdown.loading_hint")})]});if(u)return o.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:y(b0(n))});if(!s||s.scope!=="supported"||!s.totals?.total_tokens)return o.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:y(zo(n))});const p=n==="claude"?i0(s.categories||[],a):l0(s,a),k=s.tool_calls_breakdown||null,v=s.skills_breakdown||null,w=s.message_breakdown||null,N=s.configured_resources||null,x=s.exec_command_breakdown||null,M=h0(v?.skills||[]),T=m0(w?.categories||[]),j=n==="codex"&&(s?.breakdown_status==="queue_fallback"||s?.fallback==="queue_totals"),L=n==="claude"?k?.tool_calls||null:k||null,{mcpSet:P,residualSet:C,mcpTotalTokens:I}=c0(L),K=n==="claude"&&k?.subagents||null,V=K?.categories?.length>0||(N?.custom_agents_count||0)>0,$=n==="claude"?(C?.categories||[]).reduce((b,_)=>b+Number(_?.totals?.total_tokens||0),0):0,E=n==="claude"?(K?.categories||[]).reduce((b,_)=>b+Number(_?.totals?.total_tokens||0),0):0,D=[...p].sort((b,_)=>(_.totals?.total_tokens||0)-(b.totals?.total_tokens||0));return o.jsxs("div",{role:"region","aria-label":y("dashboard.context_breakdown.bar_aria",{summary:p.filter(b=>b.percent>0).filter(b=>!(n==="claude"&&(b.key==="tool_calls"||b.key==="custom_agents"))).map(b=>`${kr(b.key)} ${b.percent}%`).join(",")}),children:[o.jsxs("ul",{className:"space-y-0.5",children:[D.map(b=>{const _=b.key==="system_prompt",H=b.key==="messages",S=b.key==="tool_calls",X=b.key==="custom_agents";if(b.key,n==="claude"&&(S||X))return null;const F=H&&T.length>0||S&&(C?.categories?.length>0||j)||X&&V&&K,z=!!f[b.key],B=Jh(b.key,n),Z=o.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0",style:{backgroundColor:B},"aria-hidden":"true"}),xe=_?o.jsxs("span",{className:"relative inline-flex shrink-0 group",children:[o.jsx(ca,{size:11,className:"text-oai-gray-400 dark:text-oai-gray-500 cursor-help","aria-hidden":"true"}),o.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:y("dashboard.context_breakdown.system_prefix_tooltip")})]}):null,je=b.percent>0?`${b.percent.toFixed(b.percent<.1&&b.percent>0?2:1)}%`:"0.0%";return o.jsxs(ct,{level:0,colorSquare:Z,label:kr(b.key),labelSuffix:xe,tokens:rt(b.totals?.total_tokens||0),percent:je,hasChevron:F,open:z,onToggle:()=>g(b.key),share:b.percent,fillColor:B,children:[H&&o.jsx("ul",{className:"space-y-0.5",children:T.map(Me=>o.jsx(ct,{level:1,label:g0(Me),tokens:rt(Me.totals.total_tokens||0),percent:null},Me.key||Me.name))}),S&&C&&o.jsx(qt,{toolSet:C,execDetails:x,source:n,codexQueueFallback:j}),S&&j&&!C&&o.jsx("p",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500 py-0.5",children:y("dashboard.context_breakdown.tool_details.unavailable_codex")}),X&&K&&o.jsx(qt,{toolSet:K,execDetails:null,source:n,codexQueueFallback:!1})]},b.key)}),n==="claude"&&C?.categories?.length>0&&o.jsx(ct,{level:0,colorSquare:o.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:y("dashboard.context_breakdown.category.tool_calls"),tokens:rt($),percent:null,hasChevron:!0,open:!!f.tool_calls_aux,onToggle:()=>g("tool_calls_aux"),children:o.jsx(qt,{toolSet:C,execDetails:x,source:n,codexQueueFallback:!1})}),n==="claude"&&K?.categories?.length>0&&o.jsx(ct,{level:0,colorSquare:o.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:y("dashboard.context_breakdown.category.custom_agents"),tokens:rt(E),percent:null,hasChevron:!0,open:!!f.custom_agents_aux,onToggle:()=>g("custom_agents_aux"),children:o.jsx(qt,{toolSet:K,execDetails:null,source:n,codexQueueFallback:!1})}),P?.categories?.length>0&&o.jsx(ct,{level:0,colorSquare:o.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:y("dashboard.context_breakdown.category.mcp_servers"),tokens:rt(I),percent:null,hasChevron:!0,open:!!f.mcp_servers,onToggle:()=>g("mcp_servers"),children:o.jsx(qt,{toolSet:P,execDetails:null,source:n,codexQueueFallback:!1})}),M.length>0&&o.jsx(ct,{level:0,colorSquare:o.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:y("dashboard.context_breakdown.category.skills"),tokens:rt(M.reduce((b,_)=>b+(_.total_tokens||0),0)),percent:null,hasChevron:!0,open:!!f.skills,onToggle:()=>g("skills"),children:o.jsx("ul",{className:"space-y-0.5",children:M.slice(0,12).map(b=>o.jsx(ct,{level:1,label:b.name,tokens:rt(b.total_tokens),percent:null},b.name))})})]}),o.jsx("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:y(x0(n))}),j?o.jsx("p",{className:"mt-2 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:y("dashboard.context_breakdown.tool_details.unavailable_codex")}):null,N?o.jsxs("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:[Ae(N.skills_count||0)," skills ·"," ",Ae(N.mcp_servers_count||0)," MCP servers ·"," ",Ae(N.custom_agents_count||0)," agents ·"," ",Ae(N.memory_files_count||0)," memory files"]}):null]})}function _r({fleetData:e=[],from:t,to:n,showInlineContext:a=!0}){const r=Lt(),[s,l]=m.useState(null),{currency:i,rate:c}=_t(),u=e.filter(va);return u.length===0?null:o.jsx(rn,{children:o.jsxs("div",{className:"space-y-6",children:[o.jsx("div",{role:"img","aria-label":y("usage.overview.distribution_aria",{items:u.map(d=>y("usage.overview.distribution_item",{label:d.label,percent:d.totalPercent})).join(",")}),className:"h-1.5 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden flex",children:u.map((d,f)=>{const h=Vn(d.label,f);return o.jsx(ht.div,{initial:{width:0},animate:{width:`${d.totalPercent}%`},transition:{duration:.5,delay:.45+f*.04,ease:[.16,1,.3,1]},className:"h-full",style:{backgroundColor:h},title:`${d.label}: ${d.totalPercent}%`},d.label)})}),o.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-3",children:u.map((d,f)=>{const h=Vn(d.label,f),g=s===d.label,p=d.missingPricingModels?.length||0,k=!!p,v=Xh(d),w=Kh(d,v);return o.jsxs("button",{"aria-expanded":g,"aria-controls":`provider-details-${d.label}`,"aria-label":y("usage.overview.provider_card_aria",{provider:d.label,percent:d.totalPercent,tokens:ka(d.usage)||"0",cost:wa(d.usd,i,c)||`${ia(i)}0`,action:y(g?"usage.overview.collapse":"usage.overview.expand")}),onClick:()=>l(g?null:d.label),className:`min-w-0 text-left p-3 rounded-lg border transition-colors duration-200 ${g?"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:[o.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[o.jsx(la,{provider:d.label,size:15,color:h,className:"text-oai-gray-700 dark:text-oai-gray-300 shrink-0"}),o.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:d.label})]}),o.jsxs("div",{className:"text-lg font-semibold text-oai-black dark:text-oai-white tabular-nums",children:[d.totalPercent,"%"]}),o.jsx("div",{className:"mt-0.5 text-[11px] text-oai-gray-400 dark:text-oai-gray-400 tabular-nums",children:y("usage.overview.model_count",{count:d.models.length})}),o.jsxs("div",{className:"mt-2 space-y-1.5",children:[v.map(N=>{const x=qh(N,d.topCostModel);return o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2 text-[10px] font-medium",children:[o.jsx("span",{className:`truncate ${x?"text-oai-black dark:text-oai-white":"text-oai-gray-600 dark:text-oai-gray-300"}`,title:N.name,children:Gt(N.name)}),o.jsx("span",{className:"shrink-0 text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:y("usage.overview.model_percent",{percent:N.share})})]}),o.jsx("div",{role:"progressbar","aria-label":y("usage.overview.model_chip",{model:Gt(N.name),percent:N.share}),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Number(N.share)||0,className:"mt-1 h-1.5 overflow-hidden rounded-full bg-oai-gray-100 dark:bg-oai-gray-800",children:o.jsx(ht.div,{initial:{width:0},animate:{width:Vh(N.share)},transition:{duration:r?0:.45,delay:r?0:.05,ease:[.16,1,.3,1]},className:"h-full rounded-full",style:{backgroundColor:x?h:`${h}99`}})})]},N.id||N.name)}),!!w&&o.jsx("div",{className:"text-[10px] font-medium text-oai-gray-400 dark:text-oai-gray-500",children:y("usage.overview.model_more",{count:w})})]}),d.topCostModel?.name?o.jsx("div",{className:"mt-1.5 truncate text-[10px] font-medium text-oai-gray-500 dark:text-oai-gray-400",children:y("usage.overview.provider_top_cost",{model:Gt(d.topCostModel.name)})}):null,k?o.jsx("div",{className:"mt-1.5 truncate text-[10px] font-semibold text-amber-700 dark:text-amber-300",children:y("usage.overview.provider_missing_pricing",{count:p})}):null]},d.label)})}),s&&o.jsx("div",{id:`provider-details-${s}`,role:"region","aria-label":y("usage.overview.model_details_aria",{provider:s}),className:"mt-2",children:u.filter(d=>d.label===s).map(d=>{const f=Vn(d.label,0),h=Qt(d),g=[...d.models].sort((v,w)=>(w.share||0)-(v.share||0)),p=!!h&&a,k=p?`${h==="claude"?"Claude":"Codex"} Context Breakdown`:d.label;return o.jsx(w0,{provider:d,color:f,providerHeading:k,contextSource:p?h:null,from:t,to:n,sortedModels:g},d.label)})})]})})}function w0({provider:e,color:t,providerHeading:n,contextSource:a,from:r,to:s,sortedModels:l}){const{currency:i,rate:c}=_t(),[u,d]=m.useState(!1),f=String(e?.source||e?.label||"").trim().toLowerCase()==="antigravity";return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-1.5 mb-3",children:[o.jsx(la,{provider:e.label,size:14,color:t,className:"shrink-0"}),o.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:n}),a&&u&&o.jsx(Si,{size:12,className:"text-oai-gray-400 dark:text-oai-gray-500 animate-spin shrink-0","aria-label":y("dashboard.context_breakdown.loading_aria")})]}),f&&o.jsxs("p",{className:"mb-3 text-[10px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",children:[o.jsxs("span",{className:"font-medium text-oai-gray-500 dark:text-oai-gray-400",children:[y("usage.overview.antigravity_notice_title"),"."]})," ",y("usage.overview.antigravity_notice_body")]}),a?o.jsx("div",{className:"mb-4 pb-4 border-b border-oai-gray-200 dark:border-oai-gray-700",children:o.jsx(Bo,{from:r,to:s,source:a,referenceTotalTokens:e.usage,onLoadingChange:d})}):null,o.jsx("div",{className:"space-y-3",children:l.map(h=>{const g=ka(h.usage),p=wa(h.cost,i,c),k=Math.max(0,Math.min(100,Number(h.share)||0));return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-baseline gap-4 mb-1.5",children:[o.jsx("span",{className:"flex-1 min-w-0 text-sm text-oai-gray-700 dark:text-oai-gray-300 truncate",title:h.name,children:h.name}),o.jsx("span",{className:"shrink-0 w-16 text-right text-sm text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:g}),o.jsx("span",{className:"shrink-0 w-16 text-right text-sm text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:p}),o.jsxs("span",{className:"shrink-0 w-12 text-right text-sm text-oai-black dark:text-oai-white tabular-nums",children:[h.share,"%"]})]}),o.jsx("div",{className:"h-[3px] bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden",role:"progressbar","aria-valuenow":k,"aria-valuemin":0,"aria-valuemax":100,children:o.jsx("div",{className:"h-full transition-[width] duration-500 ease-out",style:{width:`${k}%`,backgroundColor:t,opacity:.45}})})]},h.id||h.name)})})]})}const v0={claude:"Claude",codex:"Codex"};function N0({fleetData:e=[],from:t,to:n}){const a=e.filter(va).filter(i=>Qt(i)!==null);if(a.length===0)return null;const r=new Map;for(const i of a){const c=Qt(i),u=r.get(c);(!u||(Number(i.usage)||0)>(Number(u.usage)||0))&&r.set(c,i)}const s=Array.from(r.values()).sort((i,c)=>(Number(c.usage)||0)-(Number(i.usage)||0)),l=s.length>1;return o.jsx(rn,{title:y("dashboard.context_breakdown.card_title"),children:o.jsx("div",{className:l?"grid grid-cols-1 lg:grid-cols-2 gap-x-8 gap-y-6":"",children:s.map(i=>{const c=Qt(i);return o.jsxs("div",{className:"min-w-0",children:[l?o.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2 border-b border-oai-gray-200 pb-2 dark:border-oai-gray-800",children:[o.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white",children:v0[c]??c}),o.jsx("span",{className:"text-xs font-medium tabular-nums text-oai-gray-500 dark:text-oai-gray-300",children:ka(i.usage)})]}):null,o.jsx(Bo,{from:t,to:n,source:c,referenceTotalTokens:i.usage})]},c)})})})}function _0(e){return e==="day"?"hourly":e==="total"?"monthly":"daily"}function M0(e){return!!e&&!e.missing&&!e.future}function j0(e){const t=e?.billable_total_tokens??e?.total_tokens??e?.value,n=Number(t);return Number.isFinite(n)&&n>=0?n:0}function S0(e){const t=e?.total_tokens??e?.billable_total_tokens??e?.value,n=Number(t);return Number.isFinite(n)&&n>=0?n:0}function C0(e){const t=Array.isArray(e)?e.filter(M0):[];let n=0,a=0,r=0,s=0,l=!1,i=0,c=-1,u=null;for(const d of t){const f=S0(d),h=j0(d);n+=f,a+=h;const g=Number(d?.conversation_count);Number.isFinite(g)&&g>0&&(r+=g);const p=Number(d?.total_cost_usd);Number.isFinite(p)&&(l=!0,s+=p),h>0&&(i+=1),h>c&&(c=h,u=d)}return{totalTokens:n,billableTokens:a,conversationCount:r,totalCostUsd:l?s:null,bucketCount:t.length,activeBuckets:i,peak:u&&c>0?{value:c,label:u.hour||u.day||u.month||""}:null}}function Mr(e){return String(e).padStart(2,"0")}function D0(e,t){if(!e)return"";if(t==="hourly"){const n=String(e.hour||e.label||""),a=/^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2})/.exec(n);if(!a)return n;const[,r,s,l]=a,c=Number(s)*60+Number(l)+30,u=Math.floor(c/60)%24,d=c%60;return`${r} ${s}:${l}–${Mr(u)}:${Mr(d)}`}return String(t==="monthly"?e.month||e.label||"":e.day||e.label||"")}function T0(e){if(!e||e.activeBuckets===0)return"trend.zoom.insight.empty";const t=e.totalTokens||0;return t<1e7?"trend.zoom.insight.calm":t<5e8?"trend.zoom.insight.steady":t<5e9?"trend.zoom.insight.heavy":"trend.zoom.insight.massive"}function P0(e,t){if(!e)return"";if(t==="hourly"){const r=/T(\d{2}:\d{2})/.exec(String(e.hour||e.label||""));return r?r[1]:""}if(t==="monthly")return String(e.month||e.label||"");const n=String(e.day||e.label||""),a=/^\d{4}-(\d{2}-\d{2})$/.exec(n);return a?a[1]:n}const O0=[{period:"day",labelKey:"trend.zoom.gran.30min"},{period:"month",labelKey:"trend.zoom.gran.day"},{period:"total",labelKey:"trend.zoom.gran.month"}],$0=24,Ft="#10b981";function jr(e){return e==="day"?"day":e==="total"?"total":"month"}function oa(e,t){const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(e||""));if(!n)return e;const a=new Date(Date.UTC(Number(n[1]),Number(n[2])-1,Number(n[3])));a.setUTCDate(a.getUTCDate()+t);const r=a.getUTCFullYear(),s=String(a.getUTCMonth()+1).padStart(2,"0"),l=String(a.getUTCDate()).padStart(2,"0");return`${r}-${s}-${l}`}function W0(e,t){const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(e||""));if(!n)return e;const a=new Date(Date.UTC(Number(n[1]),Number(n[2])-1+t,Number(n[3]))),r=a.getUTCFullYear(),s=String(a.getUTCMonth()+1).padStart(2,"0"),l=String(a.getUTCDate()).padStart(2,"0");return`${r}-${s}-${l}`}function E0(e,t){const n=/^(\d{4})-(\d{2})/.exec(String(e||"")),a=/^(\d{4})-(\d{2})/.exec(String(t||""));if(!n||!a)return $0;const r=Number(a[1])*12+Number(a[2])-(Number(n[1])*12+Number(n[2]))+1;return Math.max(1,r)}function Sr(e,t){return t?e==="total"?{from:W0(t,-23),to:t}:{from:oa(t,-29),to:t}:{from:null,to:null}}function A0(e){const t=/^\d{4}-(\d{2}-\d{2})T(\d{2}:\d{2})/.exec(String(e||""));return t?`${t[1]} ${t[2]}`:e||""}function yn({label:e,value:t,sub:n}){return o.jsxs("div",{className:"flex flex-col gap-1.5 group",children:[o.jsx("span",{className:"text-[9px] font-bold uppercase tracking-widest font-mono text-zinc-400 dark:text-zinc-500",children:e}),o.jsx("span",{className:"text-xl font-black font-mono text-zinc-900 dark:text-zinc-50 tracking-tight leading-none tabular-nums transition-transform duration-200 group-hover:-translate-y-[1px]",children:t}),n?o.jsx("span",{className:"text-[10px] font-bold text-zinc-400 dark:text-zinc-500 font-mono tabular-nums",children:n}):null]})}function F0({zoomConfig:e,period:t,from:n,to:a,timeZoneLabel:r,onClose:s,renderChart:l}){const{currency:i,rate:c}=_t(),u=R.useMemo(()=>Zt({timeZone:e?.timeZone,offsetMinutes:e?.tzOffsetMinutes,date:e?.now||new Date})||a||n||null,[e?.timeZone,e?.tzOffsetMinutes,e?.now,a,n]),[d,f]=R.useState(()=>jr(t)),[h,g]=R.useState(u),[p,k]=R.useState(()=>Sr(jr(t),u)),[v,w]=R.useState(!1),[N,x]=R.useState(!1),[M,T]=R.useState(!1),j=u,L=S=>{f(S),S!=="day"&&k(Sr(S,u))},P=R.useMemo(()=>d==="day"?{from:h,to:h,months:void 0}:d==="total"?{from:void 0,to:p.to,months:E0(p.from,p.to)}:{from:p.from,to:p.to,months:void 0},[d,h,p]),{rows:C,from:I,to:K,loading:V}=Jr({...e,period:d,from:P.from,to:P.to,months:P.months}),$=R.useMemo(()=>C0(C),[C]),E=R.useCallback(()=>T(!0),[]),D=S=>{S.target===S.currentTarget&&M&&s()};if(R.useEffect(()=>{const S=X=>{X.key==="Escape"&&E()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[E]),typeof document>"u")return null;const b=d==="day"&&!!h,_=d==="day"&&!!h&&(!j||h<j),H=$.totalCostUsd!=null?et($.totalCostUsd,{currency:i,rate:c}):null;return o.jsxs("div",{onAnimationEnd:D,onClick:S=>{S.target===S.currentTarget&&E()},className:Xe("fixed inset-0 z-50 flex items-center justify-center p-3 md:p-6 backdrop-blur-md bg-black/15 dark:bg-black/40",M?"animate-tt-fade-out":"animate-tt-fade-in"),children:[o.jsx("style",{children:`
|
|
42
|
+
`})]})}function bc(e,t,n){if(!Number.isFinite(e))return y("shared.placeholder.short");const a=et(e,{decimals:2,currency:t,rate:n});return a==="-"?y("shared.placeholder.short"):a}function Ka(e,t,n){if(!Number.isFinite(e)||e<=0)return null;const a=ia(t);return(t===Yr?e:e*n)<.01?`<${a}0.01`:et(e,{decimals:2,currency:t,rate:n})}function Ga(e){const t=Number(e);return!Number.isFinite(t)||t<=0?null:Ae(t,{decimals:1})}const xc=R.memo(function({isOpen:t,onClose:n,fleetData:a=[]}){const{currency:r,rate:s}=Nt(),l=m.useMemo(()=>(Array.isArray(a)?a:[]).map(c=>{const d=Le(c?.usd)??0,f=Le(c?.usage)??0,u=Array.isArray(c?.models)?c.models:[];return{label:c?.label?String(c.label):"",usdValue:d,costLabel:Ka(d,r,s),tokensLabel:Ga(f),models:u.map(h=>{const g=Le(h?.usage)??0,p=Le(h?.cost)??0;return{id:h?.id?String(h.id):"",name:h?.name?String(h.name):"",tokensLabel:Ga(g),costLabel:Ka(p,r,s),sortCost:p}}).filter(h=>h.costLabel||h.tokensLabel).sort((h,g)=>g.sortCost-h.sortCost)}}).filter(c=>c.usdValue>0||c.models.length>0).sort((c,d)=>d.usdValue-c.usdValue),[a,r,s]),i=m.useMemo(()=>{const c=l.reduce((d,f)=>d+f.usdValue,0);return bc(c,r,s)},[l,r,s]);return o.jsx(_i,{open:t,onOpenChange:c=>{c||n?.()},children:o.jsxs(Mi,{children:[o.jsx(ji,{className:"cost-modal-backdrop","data-cost-analysis-backdrop":"true"}),o.jsx(Si,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:o.jsxs(Ci,{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:[o.jsx(Di,{render:o.jsx("h2",{className:"sr-only"}),children:y("dashboard.cost_breakdown.title")}),o.jsx(Xi,{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":y("dashboard.cost_breakdown.close"),children:o.jsx(sa,{size:16,strokeWidth:2,"aria-hidden":!0})}),o.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto oai-scrollbar",children:o.jsxs("div",{className:"px-3 py-6",children:[o.jsx("p",{className:"text-label uppercase tracking-[0.12em] text-oai-gray-500 dark:text-oai-gray-400 mb-2",children:y("dashboard.cost_breakdown.total_label")}),o.jsx("p",{className:"font-bold text-oai-brand tabular-nums tracking-tight leading-none mb-6",style:{fontSize:"clamp(24px, 6.5vw, 32px)"},children:i}),l.length===0?o.jsx("p",{className:"text-body-sm text-oai-gray-500 dark:text-oai-gray-400",children:"No spend recorded."}):o.jsxs("div",{role:"table","aria-label":y("dashboard.cost_breakdown.title"),children:[o.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:[o.jsx("span",{role:"columnheader",children:"Model"}),o.jsx("span",{role:"columnheader",children:"Cost"})]}),l.map((c,d)=>{const f=`fleet-${d}`;return o.jsxs("div",{role:"rowgroup","aria-labelledby":f,className:d>0?"mt-5":"mt-2",children:[o.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-2",children:[o.jsx("span",{id:f,role:"rowheader",className:"flex-1 min-w-0 text-body-sm font-semibold text-oai-black dark:text-oai-white truncate leading-none",children:c.label}),o.jsx("span",{role:"cell",className:"shrink-0 text-body-sm font-semibold text-oai-black dark:text-oai-white tabular-nums leading-none",children:c.costLabel||"—"})]}),c.models.map((u,h)=>o.jsxs("div",{role:"row",className:"flex items-center justify-between gap-4 py-[5px]",children:[o.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}),o.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}-${h}`))]},`${c.label}-${d}`)})]})]})})]})})]})})});function kc(e){if(typeof e!="string")return{owner:"",repo:""};const[t,n]=e.split("/");return{owner:t||"",repo:n||""}}function wc({projectKey:e,projectRef:t}){const[n,a]=m.useState(!1),r=typeof t=="string"?t.replace("https://github.com/",""):"",{owner:s,repo:l}=kc(e||r),i=s&&l?`${s}/${l}`:e,c=s&&!n?`https://github.com/${s}.png?size=80`:"";return c?o.jsx("img",{src:c,alt:"",className:"w-8 h-8 rounded-md oai-bg-elevated object-cover",onError:()=>a(!0)}):o.jsx("div",{className:"w-8 h-8 rounded-md oai-bg-elevated flex items-center justify-center text-oai-gray-500 dark:text-oai-gray-300",children:o.jsx(la,{provider:i,size:20})})}function vc({projectEntries:e=[],projectLimit:t=3,onProjectLimitChange:n,copy:a,hasDetailsActual:r,dailyEmptyPrefix:s,installSyncCmd:l,dailyEmptySuffix:i,detailsColumns:c,ariaSortFor:d,toggleSort:f,sortIconFor:u,pagedDetails:h,dailyBreakdownRows:g=[],dailyBreakdownColumns:p=[],dailyBreakdownAriaSortFor:x,dailyBreakdownSortIconFor:v,dailyBreakdownDateKey:w="day",detailsDateKey:_,renderDetailDate:k,renderDailyBreakdownDate:N,renderDetailCell:D,DETAILS_PAGED_PERIODS:j,period:L,detailsPageCount:P,detailsPage:C,setDetailsPage:I}){const[K,V]=m.useState("daily");function $(T,b,M){return M===0?"text-oai-gray-500 dark:text-oai-gray-300":b.key==="total_tokens"||b.key==="total_cost_usd"?"font-medium text-oai-black dark:text-oai-white tabular-nums":b.key==="cost_per_million_tokens"&&T?.cost_per_million_status==="high"?"font-semibold text-amber-700 dark:text-amber-300 tabular-nums":b.key==="top_model"?"text-oai-gray-600 dark:text-oai-gray-300":"text-oai-gray-600 dark:text-oai-gray-300 tabular-nums"}function E(T,b,M){return M===0?N?N(T):k(T):D(T,b.key)}return o.jsxs(on,{children:[o.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[o.jsxs("div",{role:"tablist","aria-label":"Data view",className:"flex gap-1",children:[o.jsx("button",{role:"tab","aria-selected":K==="daily",type:"button",onClick:()=>V("daily"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${K==="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:a("dashboard.daily.title")}),o.jsx("button",{role:"tab","aria-selected":K==="projects",type:"button",onClick:()=>V("projects"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${K==="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:a("dashboard.projects.title")})]}),K==="projects"&&o.jsx(Pi,{ariaLabel:a("dashboard.projects.limit_aria"),value:t,onValueChange:T=>n?.(Number(T)),options:[{value:3,label:a("dashboard.projects.limit_top_3")},{value:6,label:a("dashboard.projects.limit_top_6")},{value:10,label:a("dashboard.projects.limit_top_10")}],align:"end",className:"px-2 py-1 text-xs text-oai-gray-600 dark:text-oai-gray-300"})]}),K==="projects"&&o.jsx("div",{className:"space-y-1",children:e.slice(0,t).map((T,b)=>{const M=typeof T?.project_ref=="string"?T.project_ref:"",H=T?.project_key||M||`entry-${b}`,S=T?.billable_total_tokens??T?.total_tokens,X=Number(S),F=Number.isFinite(X)?X.toLocaleString():"—",z=T?.project_key||M.split("/").pop()||"—";return o.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg",children:[o.jsx(wc,{projectKey:T?.project_key,projectRef:M}),o.jsx("div",{className:"min-w-0 flex-1",children:o.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white truncate",children:z})}),o.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",children:F})]},H)})}),K==="daily"&&o.jsxs("div",{children:[g?.length===0?o.jsxs("div",{className:"oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300 mb-4",children:[s,o.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:l}),i]}):o.jsx("div",{className:"overflow-auto max-h-[384px] -mx-4 oai-scrollbar",children:o.jsxs("table",{className:"w-full border-collapse",children:[o.jsx("thead",{className:"sticky top-0 z-10",children:o.jsx("tr",{className:"border-b border-oai-gray-200 dark:border-oai-gray-700",children:p.map((T,b)=>o.jsx("th",{...x?.(T.key)?{"aria-sort":x(T.key)}:{},className:"text-left p-0 bg-white dark:bg-oai-gray-900",children:o.jsx("button",{type:"button",onClick:()=>f(T.key),className:"flex w-full items-center justify-start px-2.5 sm: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:o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx("span",{children:T.label}),o.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-400",children:v?.(T.key)||""})]})})},T.key))})}),o.jsx("tbody",{children:g.map(T=>o.jsx("tr",{className:`border-b border-oai-gray-100 dark:border-oai-gray-800 last:border-b-0 odd:bg-transparent even:bg-oai-gray-50/55 dark:odd:bg-transparent dark:even:bg-white/[0.035] hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/70 transition-colors ${T.missing?"text-oai-gray-400 dark:text-oai-gray-400":T.future?"text-oai-gray-300 dark:text-oai-gray-600":"text-oai-black dark:text-oai-white"}`,children:p.map((b,M)=>o.jsx("td",{className:`px-2.5 sm:px-4 py-2 oai-text-body-sm whitespace-nowrap ${$(T,b,M)}`,children:E(T,b,M)},b.key))},String(T?.[w]||T?.day||T?.hour||T?.month||"")))})]})}),K!=="daily"&&j.has(L)&&P>1?o.jsxs("div",{className:"mt-3 flex items-center justify-between oai-text-caption",children:[o.jsx("button",{type:"button",onClick:()=>I(T=>Math.max(0,T-1)),disabled:C===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:a("details.pagination.prev")}),o.jsxs("span",{className:"oai-text-muted",children:[C+1," / ",P]}),o.jsx("button",{type:"button",onClick:()=>I(T=>Math.min(P-1,T+1)),disabled:C+1>=P,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:a("details.pagination.next")})]}):null]})]})}function kn(e){return typeof e!="string"?"":e.trim()}function Qa(e){const t=kn(e);return t?t.split(/[_\-\s]+/).filter(Boolean).map(n=>n.slice(0,1).toUpperCase()+n.slice(1).toLowerCase()).join(" "):""}function Nc(e){if(!Array.isArray(e))return[];const t=new Map;for(const n of e){if(!n||typeof n!="object")continue;const a=kn(n.tool),r=kn(n.planType)||kn(n.plan_type);if(!a||!r)continue;const s=Qa(a)||a,l=Qa(r)||r;t.set(`${a.toLowerCase()}::${r.toLowerCase()}`,{tool:s,plan:l})}return Array.from(t.values())}function Ja({rankLabel:e,streakDays:t,subscriptions:n=[],className:a=""}){const r=e??y("identity_card.rank_placeholder"),s=Number.isFinite(Number(t))?Number(t):0,l=s?y("identity_card.streak_value",{days:s}):y("identity_card.rank_placeholder"),i=Nc(n);return o.jsxs(on,{className:`h-full ${a}`,children:[i.length>0&&o.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map((c,d)=>o.jsxs(qi,{variant:"secondary",size:"sm",children:[c.tool," ",c.plan]},`${c.tool}:${c.plan}:${d}`))}),o.jsxs("div",{className:`${i.length>0?"mt-3 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:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{children:y("identity_card.rank_label")}),o.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:r})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{children:y("identity_card.streak_label")}),o.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-300 tabular-nums",children:l})]})]})]})}const Za=2,_c=.75,Mc=.005;function jc(e,t){if(!(typeof e=="number"&&Number.isFinite(e)))return{hasBar:!1,side:null,widthPct:0,tone:null,labelText:"—",arrow:null};if(Math.abs(e)<Mc)return{hasBar:!1,side:null,widthPct:0,tone:null,labelText:"0%",arrow:null};const a=e>0,r=Math.min(Math.abs(e),Za)/Za*50;let s;t==="price"?s=a?"bad":"good":s=Math.abs(e)>=_c?"neutral-strong":"neutral";const l=Math.abs(Math.round(e*100));return{hasBar:!0,side:a?"up":"down",widthPct:r,tone:s,labelText:`${a?"+":"−"}${l}%`,arrow:t==="price"?a?"▲":"▼":null}}function Sc(e){switch(e){case"neutral":return"var(--pulse-neutral)";case"neutral-strong":return"var(--pulse-neutral-strong)";case"good":return"var(--pulse-good)";case"bad":return"var(--pulse-bad)";default:return null}}const Cc={thousandSuffix:"K",millionSuffix:"M",billionSuffix:"B"},Dc=e=>e==null?"—":Ae(e,Cc),Tc=e=>e==null?"—":et(e,{decimals:e>=100?0:2}),Pc=e=>e==null?"—":et(e,{decimals:2}),Oc=[{key:"tokens",label:"Tokens",kind:"usage",format:Dc},{key:"cost",label:"Cost",kind:"usage",format:Tc},{key:"perMTok",label:"$/MTok",kind:"price",format:Pc}];function $c({label:e,delta:t,kind:n}){const a=jc(t,n),r=Sc(a.tone),s=a.side==="up"?{left:"50%",width:`${a.widthPct}%`,background:r}:{right:"50%",width:`${a.widthPct}%`,background:r};return o.jsxs("div",{className:"grid grid-cols-[2.3rem_1fr_3rem] items-center gap-2",children:[o.jsx("span",{className:"text-[8.5px] uppercase tracking-wide text-oai-gray-400 dark:text-oai-gray-400 text-right",children:e}),o.jsxs("span",{className:"pulse-devtrack",children:[o.jsx("span",{className:"pulse-devtick"}),a.hasBar?o.jsx("span",{className:"pulse-devbar",style:s}):null]}),o.jsxs("span",{className:"flex items-center justify-end gap-1 text-[10.5px] font-bold tabular-nums text-right text-oai-gray-600 dark:text-oai-gray-300",children:[a.arrow?o.jsx("span",{className:"text-[8px]",style:{color:r},children:a.arrow}):null,o.jsx("span",{children:a.labelText})]})]})}function Wc({ratio:e}){const t=Math.min(Math.max(e,0),2)/2*100;return o.jsxs("div",{className:"mt-2.5",children:[o.jsxs("div",{className:"flex items-baseline justify-between mb-1",children:[o.jsx("span",{className:"text-[8.5px] uppercase tracking-wide text-oai-gray-400 dark:text-oai-gray-400",children:"of a normal day"}),o.jsxs("span",{className:"text-[11px] font-bold tabular-nums text-oai-brand-600 dark:text-oai-brand-light",children:[e.toFixed(1),"×"]})]}),o.jsxs("div",{className:"relative h-[7px] rounded-full",style:{background:"var(--pulse-track)"},children:[o.jsx("div",{className:"absolute left-0 top-0 bottom-0 rounded-full bg-gradient-to-r from-oai-brand-500 to-oai-brand-light",style:{width:`${t}%`}}),o.jsx("div",{className:"absolute -top-[3px] -bottom-[3px] w-[2px] rounded-full",style:{left:"50%",background:"var(--pulse-tick)"},"aria-hidden":"true"})]})]})}function Ec({pulse:e,period:t,comparedAtLabel:n,className:a=""}){if(!e)return null;const r=t==="day"||t==="24h",s=t==="month"?"prev 30d":"prev 7d",l=r?[{label:"yest",field:"deltaVsPrev"},{label:"7d avg",field:"deltaVsAvg"}]:[{label:s,field:"deltaVsPrev"}],i=r?"vs yest · 7d avg":`vs ${s}`,c=r?`same time of day${n?` · ${n}`:""}`:`same elapsed vs ${s}`;return o.jsxs("div",{className:`pulse-card h-full flex flex-col gap-1.5 ${a}`,children:[o.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[o.jsx("span",{className:"text-[10.5px] font-bold uppercase tracking-[0.16em] text-oai-brand-600 dark:text-oai-brand-light",children:"Today's pulse"}),o.jsx("span",{className:"text-[9px] text-oai-gray-400 dark:text-oai-gray-400 tracking-wide",children:i})]}),Oc.map(d=>{const f=e[d.key]||{},u=typeof f.progress=="number"&&Number.isFinite(f.progress);return o.jsxs("div",{className:"py-2 border-b border-dashed border-oai-gray-200/40 dark:border-oai-gray-700/50 last:border-b-0",children:[o.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[o.jsx("span",{className:"text-[11px] uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:d.label}),o.jsx("span",{className:"text-xl font-bold text-oai-black dark:text-oai-white tabular-nums truncate",children:d.format(f.value)})]}),o.jsx("div",{className:"mt-2 flex flex-col gap-1.5",children:l.map(h=>o.jsx($c,{label:h.label,delta:f[h.field],kind:d.kind},h.field))}),u?o.jsx(Wc,{ratio:f.progress}):null]},d.key)}),o.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-oai-gray-400 dark:text-oai-gray-400 pt-0.5",children:[o.jsx("span",{"aria-hidden":"true",children:"⌚"}),o.jsx("span",{children:c})]})]})}function Ac(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}const Fc={},Gt={};function Tt(e,t){try{const a=(Fc[e]||=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format)(t).split("GMT")[1];return a in Gt?Gt[a]:er(a,a.split(":"))}catch{if(e in Gt)return Gt[e];const n=e?.match(Rc);return n?er(e,n.slice(1)):NaN}}const Rc=/([+-]\d\d):?(\d\d)?/;function er(e,t){const n=+(t[0]||0),a=+(t[1]||0),r=+(t[2]||0)/60;return Gt[e]=n*60+a>0?n*60+a+r:n*60-a-r}class rt extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(Tt(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),co(this),aa(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new rt(...n,t):new rt(Date.now(),t)}withTimeZone(t){return new rt(+this,t)}getTimezoneOffset(){const t=-Tt(this.timeZone,this);return t>0?Math.floor(t):Math.ceil(t)}setTime(t){return Date.prototype.setTime.apply(this,arguments),aa(this),+this}[Symbol.for("constructDateFrom")](t){return new rt(+new Date(t),this.timeZone)}}const tr=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!tr.test(e))return;const t=e.replace(tr,"$1UTC");rt.prototype[t]&&(e.startsWith("get")?rt.prototype[e]=function(){return this.internal[t]()}:(rt.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),Ic(this),+this},rt.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),aa(this),+this}))});function aa(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-Tt(e.timeZone,e)*60))}function Ic(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),co(e)}function co(e){const t=Tt(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),a=new Date(+e);a.setUTCHours(a.getUTCHours()-1);const r=-new Date(+e).getTimezoneOffset(),s=-new Date(+a).getTimezoneOffset(),l=r-s,i=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();l&&i&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+l);const c=r-n;c&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+c);const d=new Date(+e);d.setUTCSeconds(0);const f=r>0?d.getSeconds():(d.getSeconds()-60)%60,u=Math.round(-(Tt(e.timeZone,e)*60))%60;(u||f)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+u),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+u+f));const h=Tt(e.timeZone,e),g=h>0?Math.floor(h):Math.ceil(h),x=-new Date(+e).getTimezoneOffset()-g,v=g!==n,w=x-c;if(v&&w){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+w);const _=Tt(e.timeZone,e),k=_>0?Math.floor(_):Math.ceil(_),N=g-k;N&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+N),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+N))}}class Ie extends rt{static tz(t,...n){return n.length?new Ie(...n,t):new Ie(Date.now(),t)}toISOString(){const[t,n,a]=this.tzComponents(),r=`${t}${n}:${a}`;return this.internal.toISOString().slice(0,-1)+r}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,n,a,r]=this.internal.toUTCString().split(" ");return`${t?.slice(0,-1)} ${a} ${n} ${r}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[n,a,r]=this.tzComponents();return`${t} GMT${n}${a}${r} (${Ac(this.timeZone,this)})`}toLocaleString(t,n){return Date.prototype.toLocaleString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleDateString(t,n){return Date.prototype.toLocaleDateString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleTimeString(t,n){return Date.prototype.toLocaleTimeString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),n=t>0?"-":"+",a=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),r=String(Math.abs(t)%60).padStart(2,"0");return[n,a,r]}withTimeZone(t){return new Ie(+this,t)}[Symbol.for("constructDateFrom")](t){return new Ie(+new Date(t),this.timeZone)}}const uo=6048e5,Lc=864e5,nr=Symbol.for("constructDateFrom");function Oe(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&nr in e?e[nr](t):e instanceof Date?new e.constructor(t):new Date(t)}function ke(e,t){return Oe(t||e,e)}function fo(e,t,n){const a=ke(e,n?.in);return isNaN(t)?Oe(e,NaN):(t&&a.setDate(a.getDate()+t),a)}function mo(e,t,n){const a=ke(e,n?.in);if(isNaN(t))return Oe(e,NaN);if(!t)return a;const r=a.getDate(),s=Oe(e,a.getTime());s.setMonth(a.getMonth()+t+1,0);const l=s.getDate();return r>=l?s:(a.setFullYear(s.getFullYear(),s.getMonth(),r),a)}let Yc={};function ln(){return Yc}function vt(e,t){const n=ln(),a=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=ke(e,t?.in),s=r.getDay(),l=(s<a?7:0)+s-a;return r.setDate(r.getDate()-l),r.setHours(0,0,0,0),r}function tn(e,t){return vt(e,{...t,weekStartsOn:1})}function ho(e,t){const n=ke(e,t?.in),a=n.getFullYear(),r=Oe(n,0);r.setFullYear(a+1,0,4),r.setHours(0,0,0,0);const s=tn(r),l=Oe(n,0);l.setFullYear(a,0,4),l.setHours(0,0,0,0);const i=tn(l);return n.getTime()>=s.getTime()?a+1:n.getTime()>=i.getTime()?a:a-1}function ar(e){const t=ke(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function Pt(e,...t){const n=Oe.bind(null,e||t.find(a=>typeof a=="object"));return t.map(n)}function nn(e,t){const n=ke(e,t?.in);return n.setHours(0,0,0,0),n}function fa(e,t,n){const[a,r]=Pt(n?.in,e,t),s=nn(a),l=nn(r),i=+s-ar(s),c=+l-ar(l);return Math.round((i-c)/Lc)}function zc(e,t){const n=ho(e,t),a=Oe(e,0);return a.setFullYear(n,0,4),a.setHours(0,0,0,0),tn(a)}function Bc(e,t,n){return fo(e,t*7,n)}function Hc(e,t,n){return mo(e,t*12,n)}function Uc(e,t){let n,a=t?.in;return e.forEach(r=>{!a&&typeof r=="object"&&(a=Oe.bind(null,r));const s=ke(r,a);(!n||n<s||isNaN(+s))&&(n=s)}),Oe(a,n||NaN)}function Vc(e,t){let n,a=t?.in;return e.forEach(r=>{!a&&typeof r=="object"&&(a=Oe.bind(null,r));const s=ke(r,a);(!n||n>s||isNaN(+s))&&(n=s)}),Oe(a,n||NaN)}function qc(e,t,n){const[a,r]=Pt(n?.in,e,t);return+nn(a)==+nn(r)}function go(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Xc(e){return!(!go(e)&&typeof e!="number"||isNaN(+ke(e)))}function yo(e,t,n){const[a,r]=Pt(n?.in,e,t),s=a.getFullYear()-r.getFullYear(),l=a.getMonth()-r.getMonth();return s*12+l}function Kc(e,t){const n=ke(e,t?.in),a=n.getMonth();return n.setFullYear(n.getFullYear(),a+1,0),n.setHours(23,59,59,999),n}function po(e,t){const[n,a]=Pt(e,t.start,t.end);return{start:n,end:a}}function Gc(e,t){const{start:n,end:a}=po(t?.in,e);let r=+n>+a;const s=r?+n:+a,l=r?a:n;l.setHours(0,0,0,0),l.setDate(1);let i=1;const c=[];for(;+l<=s;)c.push(Oe(n,l)),l.setMonth(l.getMonth()+i);return r?c.reverse():c}function Qc(e,t){const n=ke(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function Jc(e,t){const n=ke(e,t?.in),a=n.getFullYear();return n.setFullYear(a+1,0,0),n.setHours(23,59,59,999),n}function bo(e,t){const n=ke(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Zc(e,t){const{start:n,end:a}=po(t?.in,e);let r=+n>+a;const s=r?+n:+a,l=r?a:n;l.setHours(0,0,0,0),l.setMonth(0,1);let i=1;const c=[];for(;+l<=s;)c.push(Oe(n,l)),l.setFullYear(l.getFullYear()+i);return r?c.reverse():c}function xo(e,t){const n=ln(),a=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=ke(e,t?.in),s=r.getDay(),l=(s<a?-7:0)+6-(s-a);return r.setDate(r.getDate()+l),r.setHours(23,59,59,999),r}function ed(e,t){return xo(e,{...t,weekStartsOn:1})}const td={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"}},nd=(e,t,n)=>{let a;const r=td[e];return typeof r=="string"?a=r:t===1?a=r.one:a=r.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+a:a+" ago":a};function Ye(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const ad={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},rd={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},od={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},sd={date:Ye({formats:ad,defaultWidth:"full"}),time:Ye({formats:rd,defaultWidth:"full"}),dateTime:Ye({formats:od,defaultWidth:"full"})},id={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},ld=(e,t,n,a)=>id[e];function we(e){return(t,n)=>{const a=n?.context?String(n.context):"standalone";let r;if(a==="formatting"&&e.formattingValues){const l=e.defaultFormattingWidth||e.defaultWidth,i=n?.width?String(n.width):l;r=e.formattingValues[i]||e.formattingValues[l]}else{const l=e.defaultWidth,i=n?.width?String(n.width):e.defaultWidth;r=e.values[i]||e.values[l]}const s=e.argumentCallback?e.argumentCallback(t):t;return r[s]}}const cd={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},dd={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},ud={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"]},fd={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"]},md={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"}},hd={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"}},gd=(e,t)=>{const n=Number(e),a=n%100;if(a>20||a<10)switch(a%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},yd={ordinalNumber:gd,era:we({values:cd,defaultWidth:"wide"}),quarter:we({values:dd,defaultWidth:"wide",argumentCallback:e=>e-1}),month:we({values:ud,defaultWidth:"wide"}),day:we({values:fd,defaultWidth:"wide"}),dayPeriod:we({values:md,defaultWidth:"wide",formattingValues:hd,defaultFormattingWidth:"wide"})};function ve(e){return(t,n={})=>{const a=n.width,r=a&&e.matchPatterns[a]||e.matchPatterns[e.defaultMatchWidth],s=t.match(r);if(!s)return null;const l=s[0],i=a&&e.parsePatterns[a]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(i)?bd(i,u=>u.test(l)):pd(i,u=>u.test(l));let d;d=e.valueCallback?e.valueCallback(c):c,d=n.valueCallback?n.valueCallback(d):d;const f=t.slice(l.length);return{value:d,rest:f}}}function pd(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function bd(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function cn(e){return(t,n={})=>{const a=t.match(e.matchPattern);if(!a)return null;const r=a[0],s=t.match(e.parsePattern);if(!s)return null;let l=e.valueCallback?e.valueCallback(s[0]):s[0];l=n.valueCallback?n.valueCallback(l):l;const i=t.slice(r.length);return{value:l,rest:i}}}const xd=/^(\d+)(th|st|nd|rd)?/i,kd=/\d+/i,wd={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},vd={any:[/^b/i,/^(a|c)/i]},Nd={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},_d={any:[/1/i,/2/i,/3/i,/4/i]},Md={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},jd={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]},Sd={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},Cd={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]},Dd={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},Td={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}},Pd={ordinalNumber:cn({matchPattern:xd,parsePattern:kd,valueCallback:e=>parseInt(e,10)}),era:ve({matchPatterns:wd,defaultMatchWidth:"wide",parsePatterns:vd,defaultParseWidth:"any"}),quarter:ve({matchPatterns:Nd,defaultMatchWidth:"wide",parsePatterns:_d,defaultParseWidth:"any",valueCallback:e=>e+1}),month:ve({matchPatterns:Md,defaultMatchWidth:"wide",parsePatterns:jd,defaultParseWidth:"any"}),day:ve({matchPatterns:Sd,defaultMatchWidth:"wide",parsePatterns:Cd,defaultParseWidth:"any"}),dayPeriod:ve({matchPatterns:Dd,defaultMatchWidth:"any",parsePatterns:Td,defaultParseWidth:"any"})},wt={code:"en-US",formatDistance:nd,formatLong:sd,formatRelative:ld,localize:yd,match:Pd,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Od(e,t){const n=ke(e,t?.in);return fa(n,bo(n))+1}function ma(e,t){const n=ke(e,t?.in),a=+tn(n)-+zc(n);return Math.round(a/uo)+1}function ko(e,t){const n=ke(e,t?.in),a=n.getFullYear(),r=ln(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,l=Oe(t?.in||e,0);l.setFullYear(a+1,0,s),l.setHours(0,0,0,0);const i=vt(l,t),c=Oe(t?.in||e,0);c.setFullYear(a,0,s),c.setHours(0,0,0,0);const d=vt(c,t);return+n>=+i?a+1:+n>=+d?a:a-1}function $d(e,t){const n=ln(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,r=ko(e,t),s=Oe(t?.in||e,0);return s.setFullYear(r,0,a),s.setHours(0,0,0,0),vt(s,t)}function ha(e,t){const n=ke(e,t?.in),a=+vt(n,t)-+$d(n,t);return Math.round(a/uo)+1}function be(e,t){const n=e<0?"-":"",a=Math.abs(e).toString().padStart(t,"0");return n+a}const xt={y(e,t){const n=e.getFullYear(),a=n>0?n:1-n;return be(t==="yy"?a%100:a,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):be(n+1,2)},d(e,t){return be(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){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(e,t){return be(e.getHours()%12||12,t.length)},H(e,t){return be(e.getHours(),t.length)},m(e,t){return be(e.getMinutes(),t.length)},s(e,t){return be(e.getSeconds(),t.length)},S(e,t){const n=t.length,a=e.getMilliseconds(),r=Math.trunc(a*Math.pow(10,n-3));return be(r,t.length)}},Et={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},rr={G:function(e,t,n){const a=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(a,{width:"abbreviated"});case"GGGGG":return n.era(a,{width:"narrow"});default:return n.era(a,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const a=e.getFullYear(),r=a>0?a:1-a;return n.ordinalNumber(r,{unit:"year"})}return xt.y(e,t)},Y:function(e,t,n,a){const r=ko(e,a),s=r>0?r:1-r;if(t==="YY"){const l=s%100;return be(l,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):be(s,t.length)},R:function(e,t){const n=ho(e);return be(n,t.length)},u:function(e,t){const n=e.getFullYear();return be(n,t.length)},Q:function(e,t,n){const a=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(a);case"QQ":return be(a,2);case"Qo":return n.ordinalNumber(a,{unit:"quarter"});case"QQQ":return n.quarter(a,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(a,{width:"narrow",context:"formatting"});default:return n.quarter(a,{width:"wide",context:"formatting"})}},q:function(e,t,n){const a=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(a);case"qq":return be(a,2);case"qo":return n.ordinalNumber(a,{unit:"quarter"});case"qqq":return n.quarter(a,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(a,{width:"narrow",context:"standalone"});default:return n.quarter(a,{width:"wide",context:"standalone"})}},M:function(e,t,n){const a=e.getMonth();switch(t){case"M":case"MM":return xt.M(e,t);case"Mo":return n.ordinalNumber(a+1,{unit:"month"});case"MMM":return n.month(a,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(a,{width:"narrow",context:"formatting"});default:return n.month(a,{width:"wide",context:"formatting"})}},L:function(e,t,n){const a=e.getMonth();switch(t){case"L":return String(a+1);case"LL":return be(a+1,2);case"Lo":return n.ordinalNumber(a+1,{unit:"month"});case"LLL":return n.month(a,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(a,{width:"narrow",context:"standalone"});default:return n.month(a,{width:"wide",context:"standalone"})}},w:function(e,t,n,a){const r=ha(e,a);return t==="wo"?n.ordinalNumber(r,{unit:"week"}):be(r,t.length)},I:function(e,t,n){const a=ma(e);return t==="Io"?n.ordinalNumber(a,{unit:"week"}):be(a,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):xt.d(e,t)},D:function(e,t,n){const a=Od(e);return t==="Do"?n.ordinalNumber(a,{unit:"dayOfYear"}):be(a,t.length)},E:function(e,t,n){const a=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(a,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(a,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(a,{width:"short",context:"formatting"});default:return n.day(a,{width:"wide",context:"formatting"})}},e:function(e,t,n,a){const r=e.getDay(),s=(r-a.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return be(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});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"})}},c:function(e,t,n,a){const r=e.getDay(),s=(r-a.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return be(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(r,{width:"narrow",context:"standalone"});case"cccccc":return n.day(r,{width:"short",context:"standalone"});default:return n.day(r,{width:"wide",context:"standalone"})}},i:function(e,t,n){const a=e.getDay(),r=a===0?7:a;switch(t){case"i":return String(r);case"ii":return be(r,t.length);case"io":return n.ordinalNumber(r,{unit:"day"});case"iii":return n.day(a,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(a,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(a,{width:"short",context:"formatting"});default:return n.day(a,{width:"wide",context:"formatting"})}},a:function(e,t,n){const r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},b:function(e,t,n){const a=e.getHours();let r;switch(a===12?r=Et.noon:a===0?r=Et.midnight:r=a/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(e,t,n){const a=e.getHours();let r;switch(a>=17?r=Et.evening:a>=12?r=Et.afternoon:a>=4?r=Et.morning:r=Et.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let a=e.getHours()%12;return a===0&&(a=12),n.ordinalNumber(a,{unit:"hour"})}return xt.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):xt.H(e,t)},K:function(e,t,n){const a=e.getHours()%12;return t==="Ko"?n.ordinalNumber(a,{unit:"hour"}):be(a,t.length)},k:function(e,t,n){let a=e.getHours();return a===0&&(a=24),t==="ko"?n.ordinalNumber(a,{unit:"hour"}):be(a,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):xt.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):xt.s(e,t)},S:function(e,t){return xt.S(e,t)},X:function(e,t,n){const a=e.getTimezoneOffset();if(a===0)return"Z";switch(t){case"X":return sr(a);case"XXXX":case"XX":return Dt(a);default:return Dt(a,":")}},x:function(e,t,n){const a=e.getTimezoneOffset();switch(t){case"x":return sr(a);case"xxxx":case"xx":return Dt(a);default:return Dt(a,":")}},O:function(e,t,n){const a=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+or(a,":");default:return"GMT"+Dt(a,":")}},z:function(e,t,n){const a=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+or(a,":");default:return"GMT"+Dt(a,":")}},t:function(e,t,n){const a=Math.trunc(+e/1e3);return be(a,t.length)},T:function(e,t,n){return be(+e,t.length)}};function or(e,t=""){const n=e>0?"-":"+",a=Math.abs(e),r=Math.trunc(a/60),s=a%60;return s===0?n+String(r):n+String(r)+t+be(s,2)}function sr(e,t){return e%60===0?(e>0?"-":"+")+be(Math.abs(e)/60,2):Dt(e,t)}function Dt(e,t=""){const n=e>0?"-":"+",a=Math.abs(e),r=be(Math.trunc(a/60),2),s=be(a%60,2);return n+r+t+s}const ir=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},wo=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},Wd=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],a=n[1],r=n[2];if(!r)return ir(e,t);let s;switch(a){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",ir(a,t)).replace("{{time}}",wo(r,t))},Ed={p:wo,P:Wd},Ad=/^D+$/,Fd=/^Y+$/,Rd=["D","DD","YY","YYYY"];function Id(e){return Ad.test(e)}function Ld(e){return Fd.test(e)}function Yd(e,t,n){const a=zd(e,t,n);if(console.warn(a),Rd.includes(e))throw new RangeError(a)}function zd(e,t,n){const a=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${a} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Bd=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Hd=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Ud=/^'([^]*?)'?$/,Vd=/''/g,qd=/[a-zA-Z]/;function ot(e,t,n){const a=ln(),r=n?.locale??a.locale??wt,s=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,l=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0,i=ke(e,n?.in);if(!Xc(i))throw new RangeError("Invalid time value");let c=t.match(Hd).map(f=>{const u=f[0];if(u==="p"||u==="P"){const h=Ed[u];return h(f,r.formatLong)}return f}).join("").match(Bd).map(f=>{if(f==="''")return{isToken:!1,value:"'"};const u=f[0];if(u==="'")return{isToken:!1,value:Xd(f)};if(rr[u])return{isToken:!0,value:f};if(u.match(qd))throw new RangeError("Format string contains an unescaped latin alphabet character `"+u+"`");return{isToken:!1,value:f}});r.localize.preprocessor&&(c=r.localize.preprocessor(i,c));const d={firstWeekContainsDate:s,weekStartsOn:l,locale:r};return c.map(f=>{if(!f.isToken)return f.value;const u=f.value;(!n?.useAdditionalWeekYearTokens&&Ld(u)||!n?.useAdditionalDayOfYearTokens&&Id(u))&&Yd(u,t,String(e));const h=rr[u[0]];return h(i,u,r.localize,d)}).join("")}function Xd(e){const t=e.match(Ud);return t?t[1].replace(Vd,"'"):e}function Kd(e,t){const n=ke(e,t?.in),a=n.getFullYear(),r=n.getMonth(),s=Oe(n,0);return s.setFullYear(a,r+1,0),s.setHours(0,0,0,0),s.getDate()}function Gd(e,t){return ke(e,t?.in).getMonth()}function Qd(e,t){return ke(e,t?.in).getFullYear()}function Jd(e,t){return+ke(e)>+ke(t)}function Zd(e,t){return+ke(e)<+ke(t)}function eu(e,t,n){const[a,r]=Pt(n?.in,e,t);return+vt(a,n)==+vt(r,n)}function tu(e,t,n){const[a,r]=Pt(n?.in,e,t);return a.getFullYear()===r.getFullYear()&&a.getMonth()===r.getMonth()}function nu(e,t,n){const[a,r]=Pt(n?.in,e,t);return a.getFullYear()===r.getFullYear()}function au(e,t,n){const a=ke(e,n?.in),r=a.getFullYear(),s=a.getDate(),l=Oe(e,0);l.setFullYear(r,t,15),l.setHours(0,0,0,0);const i=Kd(l);return a.setMonth(t,Math.min(s,i)),a}function ru(e,t,n){const a=ke(e,n?.in);return isNaN(+a)?Oe(e,NaN):(a.setFullYear(t),a)}const lr=5,ou=4;function su(e,t){const n=t.startOfMonth(e),a=n.getDay()>0?n.getDay():7,r=t.addDays(e,-a+1),s=t.addDays(r,lr*7-1);return t.getMonth(e)===t.getMonth(s)?lr:ou}function vo(e,t){const n=t.startOfMonth(e),a=n.getDay();return a===1?n:a===0?t.addDays(n,-6):t.addDays(n,-1*(a-1))}function iu(e,t){const n=vo(e,t),a=su(e,t);return t.addDays(n,a*7-1)}const lu={lessThanXSeconds:{one:"1秒未満",other:"{{count}}秒未満",oneWithSuffix:"約1秒",otherWithSuffix:"約{{count}}秒"},xSeconds:{one:"1秒",other:"{{count}}秒"},halfAMinute:"30秒",lessThanXMinutes:{one:"1分未満",other:"{{count}}分未満",oneWithSuffix:"約1分",otherWithSuffix:"約{{count}}分"},xMinutes:{one:"1分",other:"{{count}}分"},aboutXHours:{one:"約1時間",other:"約{{count}}時間"},xHours:{one:"1時間",other:"{{count}}時間"},xDays:{one:"1日",other:"{{count}}日"},aboutXWeeks:{one:"約1週間",other:"約{{count}}週間"},xWeeks:{one:"1週間",other:"{{count}}週間"},aboutXMonths:{one:"約1か月",other:"約{{count}}か月"},xMonths:{one:"1か月",other:"{{count}}か月"},aboutXYears:{one:"約1年",other:"約{{count}}年"},xYears:{one:"1年",other:"{{count}}年"},overXYears:{one:"1年以上",other:"{{count}}年以上"},almostXYears:{one:"1年近く",other:"{{count}}年近く"}},cu=(e,t,n)=>{n=n||{};let a;const r=lu[e];return typeof r=="string"?a=r:t===1?n.addSuffix&&r.oneWithSuffix?a=r.oneWithSuffix:a=r.one:n.addSuffix&&r.otherWithSuffix?a=r.otherWithSuffix.replace("{{count}}",String(t)):a=r.other.replace("{{count}}",String(t)),n.addSuffix?n.comparison&&n.comparison>0?a+"後":a+"前":a},du={full:"y年M月d日EEEE",long:"y年M月d日",medium:"y/MM/dd",short:"y/MM/dd"},uu={full:"H時mm分ss秒 zzzz",long:"H:mm:ss z",medium:"H:mm:ss",short:"H:mm"},fu={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},mu={date:Ye({formats:du,defaultWidth:"full"}),time:Ye({formats:uu,defaultWidth:"full"}),dateTime:Ye({formats:fu,defaultWidth:"full"})},hu={lastWeek:"先週のeeeeのp",yesterday:"昨日のp",today:"今日のp",tomorrow:"明日のp",nextWeek:"翌週のeeeeのp",other:"P"},gu=(e,t,n,a)=>hu[e],yu={narrow:["BC","AC"],abbreviated:["紀元前","西暦"],wide:["紀元前","西暦"]},pu={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["第1四半期","第2四半期","第3四半期","第4四半期"]},bu={narrow:["1","2","3","4","5","6","7","8","9","10","11","12"],abbreviated:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],wide:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"]},xu={narrow:["日","月","火","水","木","金","土"],short:["日","月","火","水","木","金","土"],abbreviated:["日","月","火","水","木","金","土"],wide:["日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日"]},ku={narrow:{am:"午前",pm:"午後",midnight:"深夜",noon:"正午",morning:"朝",afternoon:"午後",evening:"夜",night:"深夜"},abbreviated:{am:"午前",pm:"午後",midnight:"深夜",noon:"正午",morning:"朝",afternoon:"午後",evening:"夜",night:"深夜"},wide:{am:"午前",pm:"午後",midnight:"深夜",noon:"正午",morning:"朝",afternoon:"午後",evening:"夜",night:"深夜"}},wu={narrow:{am:"午前",pm:"午後",midnight:"深夜",noon:"正午",morning:"朝",afternoon:"午後",evening:"夜",night:"深夜"},abbreviated:{am:"午前",pm:"午後",midnight:"深夜",noon:"正午",morning:"朝",afternoon:"午後",evening:"夜",night:"深夜"},wide:{am:"午前",pm:"午後",midnight:"深夜",noon:"正午",morning:"朝",afternoon:"午後",evening:"夜",night:"深夜"}},vu=(e,t)=>{const n=Number(e);switch(String(t?.unit)){case"year":return`${n}年`;case"quarter":return`第${n}四半期`;case"month":return`${n}月`;case"week":return`第${n}週`;case"date":return`${n}日`;case"hour":return`${n}時`;case"minute":return`${n}分`;case"second":return`${n}秒`;default:return`${n}`}},Nu={ordinalNumber:vu,era:we({values:yu,defaultWidth:"wide"}),quarter:we({values:pu,defaultWidth:"wide",argumentCallback:e=>Number(e)-1}),month:we({values:bu,defaultWidth:"wide"}),day:we({values:xu,defaultWidth:"wide"}),dayPeriod:we({values:ku,defaultWidth:"wide",formattingValues:wu,defaultFormattingWidth:"wide"})},_u=/^第?\d+(年|四半期|月|週|日|時|分|秒)?/i,Mu=/\d+/i,ju={narrow:/^(B\.?C\.?|A\.?D\.?)/i,abbreviated:/^(紀元[前後]|西暦)/i,wide:/^(紀元[前後]|西暦)/i},Su={narrow:[/^B/i,/^A/i],any:[/^(紀元前)/i,/^(西暦|紀元後)/i]},Cu={narrow:/^[1234]/i,abbreviated:/^Q[1234]/i,wide:/^第[1234一二三四1234]四半期/i},Du={any:[/(1|一|1)/i,/(2|二|2)/i,/(3|三|3)/i,/(4|四|4)/i]},Tu={narrow:/^([123456789]|1[012])/,abbreviated:/^([123456789]|1[012])月/i,wide:/^([123456789]|1[012])月/i},Pu={any:[/^1\D/,/^2/,/^3/,/^4/,/^5/,/^6/,/^7/,/^8/,/^9/,/^10/,/^11/,/^12/]},Ou={narrow:/^[日月火水木金土]/,short:/^[日月火水木金土]/,abbreviated:/^[日月火水木金土]/,wide:/^[日月火水木金土]曜日/},$u={any:[/^日/,/^月/,/^火/,/^水/,/^木/,/^金/,/^土/]},Wu={any:/^(AM|PM|午前|午後|正午|深夜|真夜中|夜|朝)/i},Eu={any:{am:/^(A|午前)/i,pm:/^(P|午後)/i,midnight:/^深夜|真夜中/i,noon:/^正午/i,morning:/^朝/i,afternoon:/^午後/i,evening:/^夜/i,night:/^深夜/i}},Au={ordinalNumber:cn({matchPattern:_u,parsePattern:Mu,valueCallback:function(e){return parseInt(e,10)}}),era:ve({matchPatterns:ju,defaultMatchWidth:"wide",parsePatterns:Su,defaultParseWidth:"any"}),quarter:ve({matchPatterns:Cu,defaultMatchWidth:"wide",parsePatterns:Du,defaultParseWidth:"any",valueCallback:e=>e+1}),month:ve({matchPatterns:Tu,defaultMatchWidth:"wide",parsePatterns:Pu,defaultParseWidth:"any"}),day:ve({matchPatterns:Ou,defaultMatchWidth:"wide",parsePatterns:$u,defaultParseWidth:"any"}),dayPeriod:ve({matchPatterns:Wu,defaultMatchWidth:"any",parsePatterns:Eu,defaultParseWidth:"any"})},Fu={code:"ja",formatDistance:cu,formatLong:mu,formatRelative:gu,localize:Nu,match:Au,options:{weekStartsOn:0,firstWeekContainsDate:1}},Ru={lessThanXSeconds:{one:"1초 미만",other:"{{count}}초 미만"},xSeconds:{one:"1초",other:"{{count}}초"},halfAMinute:"30초",lessThanXMinutes:{one:"1분 미만",other:"{{count}}분 미만"},xMinutes:{one:"1분",other:"{{count}}분"},aboutXHours:{one:"약 1시간",other:"약 {{count}}시간"},xHours:{one:"1시간",other:"{{count}}시간"},xDays:{one:"1일",other:"{{count}}일"},aboutXWeeks:{one:"약 1주",other:"약 {{count}}주"},xWeeks:{one:"1주",other:"{{count}}주"},aboutXMonths:{one:"약 1개월",other:"약 {{count}}개월"},xMonths:{one:"1개월",other:"{{count}}개월"},aboutXYears:{one:"약 1년",other:"약 {{count}}년"},xYears:{one:"1년",other:"{{count}}년"},overXYears:{one:"1년 이상",other:"{{count}}년 이상"},almostXYears:{one:"거의 1년",other:"거의 {{count}}년"}},Iu=(e,t,n)=>{let a;const r=Ru[e];return typeof r=="string"?a=r:t===1?a=r.one:a=r.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?a+" 후":a+" 전":a},Lu={full:"y년 M월 d일 EEEE",long:"y년 M월 d일",medium:"y.MM.dd",short:"y.MM.dd"},Yu={full:"a H시 mm분 ss초 zzzz",long:"a H:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},zu={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},Bu={date:Ye({formats:Lu,defaultWidth:"full"}),time:Ye({formats:Yu,defaultWidth:"full"}),dateTime:Ye({formats:zu,defaultWidth:"full"})},Hu={lastWeek:"'지난' eeee p",yesterday:"'어제' p",today:"'오늘' p",tomorrow:"'내일' p",nextWeek:"'다음' eeee p",other:"P"},Uu=(e,t,n,a)=>Hu[e],Vu={narrow:["BC","AD"],abbreviated:["BC","AD"],wide:["기원전","서기"]},qu={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1분기","2분기","3분기","4분기"]},Xu={narrow:["1","2","3","4","5","6","7","8","9","10","11","12"],abbreviated:["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"],wide:["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"]},Ku={narrow:["일","월","화","수","목","금","토"],short:["일","월","화","수","목","금","토"],abbreviated:["일","월","화","수","목","금","토"],wide:["일요일","월요일","화요일","수요일","목요일","금요일","토요일"]},Gu={narrow:{am:"오전",pm:"오후",midnight:"자정",noon:"정오",morning:"아침",afternoon:"오후",evening:"저녁",night:"밤"},abbreviated:{am:"오전",pm:"오후",midnight:"자정",noon:"정오",morning:"아침",afternoon:"오후",evening:"저녁",night:"밤"},wide:{am:"오전",pm:"오후",midnight:"자정",noon:"정오",morning:"아침",afternoon:"오후",evening:"저녁",night:"밤"}},Qu={narrow:{am:"오전",pm:"오후",midnight:"자정",noon:"정오",morning:"아침",afternoon:"오후",evening:"저녁",night:"밤"},abbreviated:{am:"오전",pm:"오후",midnight:"자정",noon:"정오",morning:"아침",afternoon:"오후",evening:"저녁",night:"밤"},wide:{am:"오전",pm:"오후",midnight:"자정",noon:"정오",morning:"아침",afternoon:"오후",evening:"저녁",night:"밤"}},Ju=(e,t)=>{const n=Number(e);switch(String(t?.unit)){case"minute":case"second":return String(n);case"date":return n+"일";default:return n+"번째"}},Zu={ordinalNumber:Ju,era:we({values:Vu,defaultWidth:"wide"}),quarter:we({values:qu,defaultWidth:"wide",argumentCallback:e=>e-1}),month:we({values:Xu,defaultWidth:"wide"}),day:we({values:Ku,defaultWidth:"wide"}),dayPeriod:we({values:Gu,defaultWidth:"wide",formattingValues:Qu,defaultFormattingWidth:"wide"})},ef=/^(\d+)(일|번째)?/i,tf=/\d+/i,nf={narrow:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(기원전|서기)/i},af={any:[/^(bc|기원전)/i,/^(ad|서기)/i]},rf={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234]사?분기/i},of={any:[/1/i,/2/i,/3/i,/4/i]},sf={narrow:/^(1[012]|[123456789])/,abbreviated:/^(1[012]|[123456789])월/i,wide:/^(1[012]|[123456789])월/i},lf={any:[/^1월?$/,/^2/,/^3/,/^4/,/^5/,/^6/,/^7/,/^8/,/^9/,/^10/,/^11/,/^12/]},cf={narrow:/^[일월화수목금토]/,short:/^[일월화수목금토]/,abbreviated:/^[일월화수목금토]/,wide:/^[일월화수목금토]요일/},df={any:[/^일/,/^월/,/^화/,/^수/,/^목/,/^금/,/^토/]},uf={any:/^(am|pm|오전|오후|자정|정오|아침|저녁|밤)/i},ff={any:{am:/^(am|오전)/i,pm:/^(pm|오후)/i,midnight:/^자정/i,noon:/^정오/i,morning:/^아침/i,afternoon:/^오후/i,evening:/^저녁/i,night:/^밤/i}},mf={ordinalNumber:cn({matchPattern:ef,parsePattern:tf,valueCallback:e=>parseInt(e,10)}),era:ve({matchPatterns:nf,defaultMatchWidth:"wide",parsePatterns:af,defaultParseWidth:"any"}),quarter:ve({matchPatterns:rf,defaultMatchWidth:"wide",parsePatterns:of,defaultParseWidth:"any",valueCallback:e=>e+1}),month:ve({matchPatterns:sf,defaultMatchWidth:"wide",parsePatterns:lf,defaultParseWidth:"any"}),day:ve({matchPatterns:cf,defaultMatchWidth:"wide",parsePatterns:df,defaultParseWidth:"any"}),dayPeriod:ve({matchPatterns:uf,defaultMatchWidth:"any",parsePatterns:ff,defaultParseWidth:"any"})},hf={code:"ko",formatDistance:Iu,formatLong:Bu,formatRelative:Uu,localize:Zu,match:mf,options:{weekStartsOn:0,firstWeekContainsDate:1}},gf={lessThanXSeconds:{one:"不到 1 秒",other:"不到 {{count}} 秒"},xSeconds:{one:"1 秒",other:"{{count}} 秒"},halfAMinute:"半分钟",lessThanXMinutes:{one:"不到 1 分钟",other:"不到 {{count}} 分钟"},xMinutes:{one:"1 分钟",other:"{{count}} 分钟"},xHours:{one:"1 小时",other:"{{count}} 小时"},aboutXHours:{one:"大约 1 小时",other:"大约 {{count}} 小时"},xDays:{one:"1 天",other:"{{count}} 天"},aboutXWeeks:{one:"大约 1 个星期",other:"大约 {{count}} 个星期"},xWeeks:{one:"1 个星期",other:"{{count}} 个星期"},aboutXMonths:{one:"大约 1 个月",other:"大约 {{count}} 个月"},xMonths:{one:"1 个月",other:"{{count}} 个月"},aboutXYears:{one:"大约 1 年",other:"大约 {{count}} 年"},xYears:{one:"1 年",other:"{{count}} 年"},overXYears:{one:"超过 1 年",other:"超过 {{count}} 年"},almostXYears:{one:"将近 1 年",other:"将近 {{count}} 年"}},yf=(e,t,n)=>{let a;const r=gf[e];return typeof r=="string"?a=r:t===1?a=r.one:a=r.other.replace("{{count}}",String(t)),n?.addSuffix?n.comparison&&n.comparison>0?a+"内":a+"前":a},pf={full:"y'年'M'月'd'日' EEEE",long:"y'年'M'月'd'日'",medium:"yyyy-MM-dd",short:"yy-MM-dd"},bf={full:"zzzz a h:mm:ss",long:"z a h:mm:ss",medium:"a h:mm:ss",short:"a h:mm"},xf={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},kf={date:Ye({formats:pf,defaultWidth:"full"}),time:Ye({formats:bf,defaultWidth:"full"}),dateTime:Ye({formats:xf,defaultWidth:"full"})};function cr(e,t,n){const a="eeee p";return eu(e,t,n)?a:e.getTime()>t.getTime()?"'下个'"+a:"'上个'"+a}const wf={lastWeek:cr,yesterday:"'昨天' p",today:"'今天' p",tomorrow:"'明天' p",nextWeek:cr,other:"PP p"},vf=(e,t,n,a)=>{const r=wf[e];return typeof r=="function"?r(t,n,a):r},Nf={narrow:["前","公元"],abbreviated:["前","公元"],wide:["公元前","公元"]},_f={narrow:["1","2","3","4"],abbreviated:["第一季","第二季","第三季","第四季"],wide:["第一季度","第二季度","第三季度","第四季度"]},Mf={narrow:["一","二","三","四","五","六","七","八","九","十","十一","十二"],abbreviated:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],wide:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},jf={narrow:["日","一","二","三","四","五","六"],short:["日","一","二","三","四","五","六"],abbreviated:["周日","周一","周二","周三","周四","周五","周六"],wide:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},Sf={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},Cf={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},Df=(e,t)=>{const n=Number(e);switch(t?.unit){case"date":return n.toString()+"日";case"hour":return n.toString()+"时";case"minute":return n.toString()+"分";case"second":return n.toString()+"秒";default:return"第 "+n.toString()}},Tf={ordinalNumber:Df,era:we({values:Nf,defaultWidth:"wide"}),quarter:we({values:_f,defaultWidth:"wide",argumentCallback:e=>e-1}),month:we({values:Mf,defaultWidth:"wide"}),day:we({values:jf,defaultWidth:"wide"}),dayPeriod:we({values:Sf,defaultWidth:"wide",formattingValues:Cf,defaultFormattingWidth:"wide"})},Pf=/^(第\s*)?\d+(日|时|分|秒)?/i,Of=/\d+/i,$f={narrow:/^(前)/i,abbreviated:/^(前)/i,wide:/^(公元前|公元)/i},Wf={any:[/^(前)/i,/^(公元)/i]},Ef={narrow:/^[1234]/i,abbreviated:/^第[一二三四]刻/i,wide:/^第[一二三四]刻钟/i},Af={any:[/(1|一)/i,/(2|二)/i,/(3|三)/i,/(4|四)/i]},Ff={narrow:/^(一|二|三|四|五|六|七|八|九|十[二一])/i,abbreviated:/^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,wide:/^(一|二|三|四|五|六|七|八|九|十[二一])月/i},Rf={narrow:[/^一/i,/^二/i,/^三/i,/^四/i,/^五/i,/^六/i,/^七/i,/^八/i,/^九/i,/^十(?!(一|二))/i,/^十一/i,/^十二/i],any:[/^一|1/i,/^二|2/i,/^三|3/i,/^四|4/i,/^五|5/i,/^六|6/i,/^七|7/i,/^八|8/i,/^九|9/i,/^十(?!(一|二))|10/i,/^十一|11/i,/^十二|12/i]},If={narrow:/^[一二三四五六日]/i,short:/^[一二三四五六日]/i,abbreviated:/^周[一二三四五六日]/i,wide:/^星期[一二三四五六日]/i},Lf={any:[/日/i,/一/i,/二/i,/三/i,/四/i,/五/i,/六/i]},Yf={any:/^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨|)/i},zf={any:{am:/^上午?/i,pm:/^下午?/i,midnight:/^午夜/i,noon:/^[中正]午/i,morning:/^早上/i,afternoon:/^下午/i,evening:/^晚上?/i,night:/^凌晨/i}},Bf={ordinalNumber:cn({matchPattern:Pf,parsePattern:Of,valueCallback:e=>parseInt(e,10)}),era:ve({matchPatterns:$f,defaultMatchWidth:"wide",parsePatterns:Wf,defaultParseWidth:"any"}),quarter:ve({matchPatterns:Ef,defaultMatchWidth:"wide",parsePatterns:Af,defaultParseWidth:"any",valueCallback:e=>e+1}),month:ve({matchPatterns:Ff,defaultMatchWidth:"wide",parsePatterns:Rf,defaultParseWidth:"any"}),day:ve({matchPatterns:If,defaultMatchWidth:"wide",parsePatterns:Lf,defaultParseWidth:"any"}),dayPeriod:ve({matchPatterns:Yf,defaultMatchWidth:"any",parsePatterns:zf,defaultParseWidth:"any"})},Hf={code:"zh-CN",formatDistance:yf,formatLong:kf,formatRelative:vf,localize:Tf,match:Bf,options:{weekStartsOn:1,firstWeekContainsDate:4}},Uf={lessThanXSeconds:{one:"少於 1 秒",other:"少於 {{count}} 秒"},xSeconds:{one:"1 秒",other:"{{count}} 秒"},halfAMinute:"半分鐘",lessThanXMinutes:{one:"少於 1 分鐘",other:"少於 {{count}} 分鐘"},xMinutes:{one:"1 分鐘",other:"{{count}} 分鐘"},xHours:{one:"1 小時",other:"{{count}} 小時"},aboutXHours:{one:"大約 1 小時",other:"大約 {{count}} 小時"},xDays:{one:"1 天",other:"{{count}} 天"},aboutXWeeks:{one:"大約 1 個星期",other:"大約 {{count}} 個星期"},xWeeks:{one:"1 個星期",other:"{{count}} 個星期"},aboutXMonths:{one:"大約 1 個月",other:"大約 {{count}} 個月"},xMonths:{one:"1 個月",other:"{{count}} 個月"},aboutXYears:{one:"大約 1 年",other:"大約 {{count}} 年"},xYears:{one:"1 年",other:"{{count}} 年"},overXYears:{one:"超過 1 年",other:"超過 {{count}} 年"},almostXYears:{one:"將近 1 年",other:"將近 {{count}} 年"}},Vf=(e,t,n)=>{let a;const r=Uf[e];return typeof r=="string"?a=r:t===1?a=r.one:a=r.other.replace("{{count}}",String(t)),n?.addSuffix?n.comparison&&n.comparison>0?a+"內":a+"前":a},qf={full:"y'年'M'月'd'日' EEEE",long:"y'年'M'月'd'日'",medium:"yyyy-MM-dd",short:"yy-MM-dd"},Xf={full:"zzzz a h:mm:ss",long:"z a h:mm:ss",medium:"a h:mm:ss",short:"a h:mm"},Kf={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},Gf={date:Ye({formats:qf,defaultWidth:"full"}),time:Ye({formats:Xf,defaultWidth:"full"}),dateTime:Ye({formats:Kf,defaultWidth:"full"})},Qf={lastWeek:"'上個'eeee p",yesterday:"'昨天' p",today:"'今天' p",tomorrow:"'明天' p",nextWeek:"'下個'eeee p",other:"P"},Jf=(e,t,n,a)=>Qf[e],Zf={narrow:["前","公元"],abbreviated:["前","公元"],wide:["公元前","公元"]},em={narrow:["1","2","3","4"],abbreviated:["第一刻","第二刻","第三刻","第四刻"],wide:["第一刻鐘","第二刻鐘","第三刻鐘","第四刻鐘"]},tm={narrow:["一","二","三","四","五","六","七","八","九","十","十一","十二"],abbreviated:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],wide:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},nm={narrow:["日","一","二","三","四","五","六"],short:["日","一","二","三","四","五","六"],abbreviated:["週日","週一","週二","週三","週四","週五","週六"],wide:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},am={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜間"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜間"}},rm={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜間"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜間"}},om=(e,t)=>{const n=Number(e);switch(t?.unit){case"date":return n+"日";case"hour":return n+"時";case"minute":return n+"分";case"second":return n+"秒";default:return"第 "+n}},sm={ordinalNumber:om,era:we({values:Zf,defaultWidth:"wide"}),quarter:we({values:em,defaultWidth:"wide",argumentCallback:e=>e-1}),month:we({values:tm,defaultWidth:"wide"}),day:we({values:nm,defaultWidth:"wide"}),dayPeriod:we({values:am,defaultWidth:"wide",formattingValues:rm,defaultFormattingWidth:"wide"})},im=/^(第\s*)?\d+(日|時|分|秒)?/i,lm=/\d+/i,cm={narrow:/^(前)/i,abbreviated:/^(前)/i,wide:/^(公元前|公元)/i},dm={any:[/^(前)/i,/^(公元)/i]},um={narrow:/^[1234]/i,abbreviated:/^第[一二三四]刻/i,wide:/^第[一二三四]刻鐘/i},fm={any:[/(1|一)/i,/(2|二)/i,/(3|三)/i,/(4|四)/i]},mm={narrow:/^(一|二|三|四|五|六|七|八|九|十[二一])/i,abbreviated:/^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,wide:/^(一|二|三|四|五|六|七|八|九|十[二一])月/i},hm={narrow:[/^一/i,/^二/i,/^三/i,/^四/i,/^五/i,/^六/i,/^七/i,/^八/i,/^九/i,/^十(?!(一|二))/i,/^十一/i,/^十二/i],any:[/^一|1/i,/^二|2/i,/^三|3/i,/^四|4/i,/^五|5/i,/^六|6/i,/^七|7/i,/^八|8/i,/^九|9/i,/^十(?!(一|二))|10/i,/^十一|11/i,/^十二|12/i]},gm={narrow:/^[一二三四五六日]/i,short:/^[一二三四五六日]/i,abbreviated:/^週[一二三四五六日]/i,wide:/^星期[一二三四五六日]/i},ym={any:[/日/i,/一/i,/二/i,/三/i,/四/i,/五/i,/六/i]},pm={any:/^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨)/i},bm={any:{am:/^上午?/i,pm:/^下午?/i,midnight:/^午夜/i,noon:/^[中正]午/i,morning:/^早上/i,afternoon:/^下午/i,evening:/^晚上?/i,night:/^凌晨/i}},xm={ordinalNumber:cn({matchPattern:im,parsePattern:lm,valueCallback:e=>parseInt(e,10)}),era:ve({matchPatterns:cm,defaultMatchWidth:"wide",parsePatterns:dm,defaultParseWidth:"any"}),quarter:ve({matchPatterns:um,defaultMatchWidth:"wide",parsePatterns:fm,defaultParseWidth:"any",valueCallback:e=>e+1}),month:ve({matchPatterns:mm,defaultMatchWidth:"wide",parsePatterns:hm,defaultParseWidth:"any"}),day:ve({matchPatterns:gm,defaultMatchWidth:"wide",parsePatterns:ym,defaultParseWidth:"any"}),dayPeriod:ve({matchPatterns:pm,defaultMatchWidth:"any",parsePatterns:bm,defaultParseWidth:"any"})},km={code:"zh-TW",formatDistance:Vf,formatLong:Gf,formatRelative:Jf,localize:sm,match:xm,options:{weekStartsOn:1,firstWeekContainsDate:4}},No={...wt,labels:{labelDayButton:(e,t,n,a)=>{let r;a&&typeof a.format=="function"?r=a.format.bind(a):r=(l,i)=>ot(l,i,{locale:wt,...n});let s=r(e,"PPPP");return t.today&&(s=`Today, ${s}`),t.selected&&(s=`${s}, selected`),s},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:e=>`Week ${e}`,labelYearDropdown:"Choose the Year",labelGrid:(e,t,n)=>{let a;return n&&typeof n.format=="function"?a=n.format.bind(n):a=(r,s)=>ot(r,s,{locale:wt,...t}),a(e,"LLLL yyyy")},labelGridcell:(e,t,n,a)=>{let r;a&&typeof a.format=="function"?r=a.format.bind(a):r=(l,i)=>ot(l,i,{locale:wt,...n});let s=r(e,"PPPP");return t?.today&&(s=`Today, ${s}`),s},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(e,t,n)=>{let a;return n&&typeof n.format=="function"?a=n.format.bind(n):a=(r,s)=>ot(r,s,{locale:wt,...t}),a(e,"cccc")}}};class Ue{constructor(t,n){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?Ie.tz(this.options.timeZone):new this.Date,this.newDate=(a,r,s)=>this.overrides?.newDate?this.overrides.newDate(a,r,s):this.options.timeZone?new Ie(a,r,s,this.options.timeZone):new Date(a,r,s),this.addDays=(a,r)=>this.overrides?.addDays?this.overrides.addDays(a,r):fo(a,r),this.addMonths=(a,r)=>this.overrides?.addMonths?this.overrides.addMonths(a,r):mo(a,r),this.addWeeks=(a,r)=>this.overrides?.addWeeks?this.overrides.addWeeks(a,r):Bc(a,r),this.addYears=(a,r)=>this.overrides?.addYears?this.overrides.addYears(a,r):Hc(a,r),this.differenceInCalendarDays=(a,r)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(a,r):fa(a,r),this.differenceInCalendarMonths=(a,r)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(a,r):yo(a,r),this.eachMonthOfInterval=a=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(a):Gc(a),this.eachYearOfInterval=a=>{const r=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(a):Zc(a),s=new Set(r.map(i=>this.getYear(i)));if(s.size===r.length)return r;const l=[];return s.forEach(i=>{l.push(new Date(i,0,1))}),l},this.endOfBroadcastWeek=a=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(a):iu(a,this),this.endOfISOWeek=a=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(a):ed(a),this.endOfMonth=a=>this.overrides?.endOfMonth?this.overrides.endOfMonth(a):Kc(a),this.endOfWeek=(a,r)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(a,r):xo(a,this.options),this.endOfYear=a=>this.overrides?.endOfYear?this.overrides.endOfYear(a):Jc(a),this.format=(a,r,s)=>{const l=this.overrides?.format?this.overrides.format(a,r,this.options):ot(a,r,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(l):l},this.getISOWeek=a=>this.overrides?.getISOWeek?this.overrides.getISOWeek(a):ma(a),this.getMonth=(a,r)=>this.overrides?.getMonth?this.overrides.getMonth(a,this.options):Gd(a,this.options),this.getYear=(a,r)=>this.overrides?.getYear?this.overrides.getYear(a,this.options):Qd(a,this.options),this.getWeek=(a,r)=>this.overrides?.getWeek?this.overrides.getWeek(a,this.options):ha(a,this.options),this.isAfter=(a,r)=>this.overrides?.isAfter?this.overrides.isAfter(a,r):Jd(a,r),this.isBefore=(a,r)=>this.overrides?.isBefore?this.overrides.isBefore(a,r):Zd(a,r),this.isDate=a=>this.overrides?.isDate?this.overrides.isDate(a):go(a),this.isSameDay=(a,r)=>this.overrides?.isSameDay?this.overrides.isSameDay(a,r):qc(a,r),this.isSameMonth=(a,r)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(a,r):tu(a,r),this.isSameYear=(a,r)=>this.overrides?.isSameYear?this.overrides.isSameYear(a,r):nu(a,r),this.max=a=>this.overrides?.max?this.overrides.max(a):Uc(a),this.min=a=>this.overrides?.min?this.overrides.min(a):Vc(a),this.setMonth=(a,r)=>this.overrides?.setMonth?this.overrides.setMonth(a,r):au(a,r),this.setYear=(a,r)=>this.overrides?.setYear?this.overrides.setYear(a,r):ru(a,r),this.startOfBroadcastWeek=(a,r)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(a,this):vo(a,this),this.startOfDay=a=>this.overrides?.startOfDay?this.overrides.startOfDay(a):nn(a),this.startOfISOWeek=a=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(a):tn(a),this.startOfMonth=a=>this.overrides?.startOfMonth?this.overrides.startOfMonth(a):Qc(a),this.startOfWeek=(a,r)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(a,this.options):vt(a,this.options),this.startOfYear=a=>this.overrides?.startOfYear?this.overrides.startOfYear(a):bo(a),this.options={locale:No,...t},this.overrides=n}getDigitMap(){const{numerals:t="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:t}),a={};for(let r=0;r<10;r++)a[r.toString()]=n.format(r);return a}replaceDigits(t){const n=this.getDigitMap();return t.replace(/\d/g,a=>n[a]||a)}formatNumber(t){return this.replaceDigits(t.toString())}getMonthYearOrder(){const t=this.options.locale?.code;return t&&Ue.yearFirstLocales.has(t)?"year-first":"month-first"}formatMonthYear(t){const{locale:n,timeZone:a,numerals:r}=this.options,s=n?.code;if(s&&Ue.yearFirstLocales.has(s))try{return new Intl.DateTimeFormat(s,{month:"long",year:"numeric",timeZone:a,numberingSystem:r}).format(t)}catch{}const l=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(t,l)}}Ue.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 st=new Ue;class _o{constructor(t,n,a=st){this.date=t,this.displayMonth=n,this.outside=!!(n&&!a.isSameMonth(t,n)),this.dateLib=a,this.isoDate=a.format(t,"yyyy-MM-dd"),this.displayMonthId=a.format(n,"yyyy-MM"),this.dateMonthId=a.format(t,"yyyy-MM")}isEqualTo(t){return this.dateLib.isSameDay(t.date,this.date)&&this.dateLib.isSameMonth(t.displayMonth,this.displayMonth)}}class wm{constructor(t,n){this.date=t,this.weeks=n}}class vm{constructor(t,n){this.days=n,this.weekNumber=t}}function Nm(e){return R.createElement("button",{...e})}function _m(e){return R.createElement("span",{...e})}function Mm(e){const{size:t=24,orientation:n="left",className:a}=e;return R.createElement("svg",{className:a,width:t,height:t,viewBox:"0 0 24 24"},n==="up"&&R.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&R.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&R.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&R.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function jm(e){const{day:t,modifiers:n,...a}=e;return R.createElement("td",{...a})}function Sm(e){const{day:t,modifiers:n,...a}=e,r=R.useRef(null);return R.useEffect(()=>{n.focused&&r.current?.focus()},[n.focused]),R.createElement("button",{ref:r,...a})}var Q;(function(e){e.Root="root",e.Chevron="chevron",e.Day="day",e.DayButton="day_button",e.CaptionLabel="caption_label",e.Dropdowns="dropdowns",e.Dropdown="dropdown",e.DropdownRoot="dropdown_root",e.Footer="footer",e.MonthGrid="month_grid",e.MonthCaption="month_caption",e.MonthsDropdown="months_dropdown",e.Month="month",e.Months="months",e.Nav="nav",e.NextMonthButton="button_next",e.PreviousMonthButton="button_previous",e.Week="week",e.Weeks="weeks",e.Weekday="weekday",e.Weekdays="weekdays",e.WeekNumber="week_number",e.WeekNumberHeader="week_number_header",e.YearsDropdown="years_dropdown"})(Q||(Q={}));var _e;(function(e){e.disabled="disabled",e.hidden="hidden",e.outside="outside",e.focused="focused",e.today="today"})(_e||(_e={}));var Ze;(function(e){e.range_end="range_end",e.range_middle="range_middle",e.range_start="range_start",e.selected="selected"})(Ze||(Ze={}));var He;(function(e){e.weeks_before_enter="weeks_before_enter",e.weeks_before_exit="weeks_before_exit",e.weeks_after_enter="weeks_after_enter",e.weeks_after_exit="weeks_after_exit",e.caption_after_enter="caption_after_enter",e.caption_after_exit="caption_after_exit",e.caption_before_enter="caption_before_enter",e.caption_before_exit="caption_before_exit"})(He||(He={}));function Cm(e){const{options:t,className:n,components:a,classNames:r,...s}=e,l=[r[Q.Dropdown],n].join(" "),i=t?.find(({value:c})=>c===s.value);return R.createElement("span",{"data-disabled":s.disabled,className:r[Q.DropdownRoot]},R.createElement(a.Select,{className:l,...s},t?.map(({value:c,label:d,disabled:f})=>R.createElement(a.Option,{key:c,value:c,disabled:f},d))),R.createElement("span",{className:r[Q.CaptionLabel],"aria-hidden":!0},i?.label,R.createElement(a.Chevron,{orientation:"down",size:18,className:r[Q.Chevron]})))}function Dm(e){return R.createElement("div",{...e})}function Tm(e){return R.createElement("div",{...e})}function Pm(e){const{calendarMonth:t,displayIndex:n,...a}=e;return R.createElement("div",{...a},e.children)}function Om(e){const{calendarMonth:t,displayIndex:n,...a}=e;return R.createElement("div",{...a})}function $m(e){return R.createElement("table",{...e})}function Wm(e){return R.createElement("div",{...e})}const Mo=m.createContext(void 0);function dn(){const e=m.useContext(Mo);if(e===void 0)throw new Error("useDayPicker() must be used within a custom component.");return e}function Em(e){const{components:t}=dn();return R.createElement(t.Dropdown,{...e})}function Am(e){const{onPreviousClick:t,onNextClick:n,previousMonth:a,nextMonth:r,...s}=e,{components:l,classNames:i,labels:{labelPrevious:c,labelNext:d}}=dn(),f=m.useCallback(h=>{r&&n?.(h)},[r,n]),u=m.useCallback(h=>{a&&t?.(h)},[a,t]);return R.createElement("nav",{...s},R.createElement(l.PreviousMonthButton,{type:"button",className:i[Q.PreviousMonthButton],tabIndex:a?void 0:-1,"aria-disabled":a?void 0:!0,"aria-label":c(a),onClick:u},R.createElement(l.Chevron,{disabled:a?void 0:!0,className:i[Q.Chevron],orientation:"left"})),R.createElement(l.NextMonthButton,{type:"button",className:i[Q.NextMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":d(r),onClick:f},R.createElement(l.Chevron,{disabled:r?void 0:!0,orientation:"right",className:i[Q.Chevron]})))}function Fm(e){const{components:t}=dn();return R.createElement(t.Button,{...e})}function Rm(e){return R.createElement("option",{...e})}function Im(e){const{components:t}=dn();return R.createElement(t.Button,{...e})}function Lm(e){const{rootRef:t,...n}=e;return R.createElement("div",{...n,ref:t})}function Ym(e){return R.createElement("select",{...e})}function zm(e){const{week:t,...n}=e;return R.createElement("tr",{...n})}function Bm(e){return R.createElement("th",{...e})}function Hm(e){return R.createElement("thead",{"aria-hidden":!0},R.createElement("tr",{...e}))}function Um(e){const{week:t,...n}=e;return R.createElement("th",{...n})}function Vm(e){return R.createElement("th",{...e})}function qm(e){return R.createElement("tbody",{...e})}function Xm(e){const{components:t}=dn();return R.createElement(t.Dropdown,{...e})}const Km=Object.freeze(Object.defineProperty({__proto__:null,Button:Nm,CaptionLabel:_m,Chevron:Mm,Day:jm,DayButton:Sm,Dropdown:Cm,DropdownNav:Dm,Footer:Tm,Month:Pm,MonthCaption:Om,MonthGrid:$m,Months:Wm,MonthsDropdown:Em,Nav:Am,NextMonthButton:Fm,Option:Rm,PreviousMonthButton:Im,Root:Lm,Select:Ym,Week:zm,WeekNumber:Um,WeekNumberHeader:Vm,Weekday:Bm,Weekdays:Hm,Weeks:qm,YearsDropdown:Xm},Symbol.toStringTag,{value:"Module"}));function ut(e,t,n=!1,a=st){let{from:r,to:s}=e;const{differenceInCalendarDays:l,isSameDay:i}=a;return r&&s?(l(s,r)<0&&([r,s]=[s,r]),l(t,r)>=(n?1:0)&&l(s,t)>=(n?1:0)):!n&&s?i(s,t):!n&&r?i(r,t):!1}function ga(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function jn(e){return!!(e&&typeof e=="object"&&"from"in e)}function ya(e){return!!(e&&typeof e=="object"&&"after"in e)}function pa(e){return!!(e&&typeof e=="object"&&"before"in e)}function jo(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function So(e,t){return Array.isArray(e)&&e.every(t.isDate)}function ft(e,t,n=st){const a=Array.isArray(t)?t:[t],{isSameDay:r,differenceInCalendarDays:s,isAfter:l}=n;return a.some(i=>{if(typeof i=="boolean")return i;if(n.isDate(i))return r(e,i);if(So(i,n))return i.some(c=>r(e,c));if(jn(i))return ut(i,e,!1,n);if(jo(i))return Array.isArray(i.dayOfWeek)?i.dayOfWeek.includes(e.getDay()):i.dayOfWeek===e.getDay();if(ga(i)){const c=s(i.before,e),d=s(i.after,e),f=c>0,u=d<0;return l(i.before,i.after)?u&&f:f||u}return ya(i)?s(e,i.after)>0:pa(i)?s(i.before,e)>0:typeof i=="function"?i(e):!1})}function Gm(e,t,n,a,r){const{disabled:s,hidden:l,modifiers:i,showOutsideDays:c,broadcastCalendar:d,today:f=r.today()}=t,{isSameDay:u,isSameMonth:h,startOfMonth:g,isBefore:p,endOfMonth:x,isAfter:v}=r,w=n&&g(n),_=a&&x(a),k={[_e.focused]:[],[_e.outside]:[],[_e.disabled]:[],[_e.hidden]:[],[_e.today]:[]},N={};for(const D of e){const{date:j,displayMonth:L}=D,P=!!(L&&!h(j,L)),C=!!(w&&p(j,w)),I=!!(_&&v(j,_)),K=!!(s&&ft(j,s,r)),V=!!(l&&ft(j,l,r))||C||I||!d&&!c&&P||d&&c===!1&&P,$=u(j,f);P&&k.outside.push(D),K&&k.disabled.push(D),V&&k.hidden.push(D),$&&k.today.push(D),i&&Object.keys(i).forEach(E=>{const T=i?.[E];T&&ft(j,T,r)&&(N[E]?N[E].push(D):N[E]=[D])})}return D=>{const j={[_e.focused]:!1,[_e.disabled]:!1,[_e.hidden]:!1,[_e.outside]:!1,[_e.today]:!1},L={};for(const P in k){const C=k[P];j[P]=C.some(I=>I===D)}for(const P in N)L[P]=N[P].some(C=>C===D);return{...j,...L}}}function Qm(e,t,n={}){return Object.entries(e).filter(([,r])=>r===!0).reduce((r,[s])=>(n[s]?r.push(n[s]):t[_e[s]]?r.push(t[_e[s]]):t[Ze[s]]&&r.push(t[Ze[s]]),r),[t[Q.Day]])}function Jm(e){return{...Km,...e}}function Zm(e){const t={"data-mode":e.mode??void 0,"data-required":"required"in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([n,a])=>{n.startsWith("data-")&&(t[n]=a)}),t}function eh(){const e={};for(const t in Q)e[Q[t]]=`rdp-${Q[t]}`;for(const t in _e)e[_e[t]]=`rdp-${_e[t]}`;for(const t in Ze)e[Ze[t]]=`rdp-${Ze[t]}`;for(const t in He)e[He[t]]=`rdp-${He[t]}`;return e}function Co(e,t,n){return(n??new Ue(t)).formatMonthYear(e)}const th=Co;function nh(e,t,n){return(n??new Ue(t)).format(e,"d")}function ah(e,t=st){return t.format(e,"LLLL")}function rh(e,t,n){return(n??new Ue(t)).format(e,"cccccc")}function oh(e,t=st){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function sh(){return""}function Do(e,t=st){return t.format(e,"yyyy")}const ih=Do,lh=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:Co,formatDay:nh,formatMonthCaption:th,formatMonthDropdown:ah,formatWeekNumber:oh,formatWeekNumberHeader:sh,formatWeekdayName:rh,formatYearCaption:ih,formatYearDropdown:Do},Symbol.toStringTag,{value:"Module"}));function ch(e){return e?.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e?.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{...lh,...e}}function ba(e,t,n,a){let r=(a??new Ue(n)).format(e,"PPPP");return t.today&&(r=`Today, ${r}`),t.selected&&(r=`${r}, selected`),r}const dh=ba;function xa(e,t,n){return(n??new Ue(t)).formatMonthYear(e)}const uh=xa;function To(e,t,n,a){let r=(a??new Ue(n)).format(e,"PPPP");return t?.today&&(r=`Today, ${r}`),r}function Po(e){return"Choose the Month"}function Oo(){return""}const fh="Go to the Next Month";function $o(e,t){return fh}function Wo(e){return"Go to the Previous Month"}function Eo(e,t,n){return(n??new Ue(t)).format(e,"cccc")}function Ao(e,t){return`Week ${e}`}function Fo(e){return"Week Number"}function Ro(e){return"Choose the Year"}const mh=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:uh,labelDay:dh,labelDayButton:ba,labelGrid:xa,labelGridcell:To,labelMonthDropdown:Po,labelNav:Oo,labelNext:$o,labelPrevious:Wo,labelWeekNumber:Ao,labelWeekNumberHeader:Fo,labelWeekday:Eo,labelYearDropdown:Ro},Symbol.toStringTag,{value:"Module"})),Je=(e,t,n)=>t||(n?typeof n=="function"?n:(...a)=>n:e);function hh(e,t){const n=t.locale?.labels??{};return{...mh,...e??{},labelDayButton:Je(ba,e?.labelDayButton,n.labelDayButton),labelMonthDropdown:Je(Po,e?.labelMonthDropdown,n.labelMonthDropdown),labelNext:Je($o,e?.labelNext,n.labelNext),labelPrevious:Je(Wo,e?.labelPrevious,n.labelPrevious),labelWeekNumber:Je(Ao,e?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:Je(Ro,e?.labelYearDropdown,n.labelYearDropdown),labelGrid:Je(xa,e?.labelGrid,n.labelGrid),labelGridcell:Je(To,e?.labelGridcell,n.labelGridcell),labelNav:Je(Oo,e?.labelNav,n.labelNav),labelWeekNumberHeader:Je(Fo,e?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:Je(Eo,e?.labelWeekday,n.labelWeekday)}}function gh(e,t,n,a,r){const{startOfMonth:s,startOfYear:l,endOfYear:i,eachMonthOfInterval:c,getMonth:d}=r;return c({start:l(e),end:i(e)}).map(h=>{const g=a.formatMonthDropdown(h,r),p=d(h),x=t&&h<s(t)||n&&h>s(n)||!1;return{value:p,label:g,disabled:x}})}function yh(e,t={},n={}){let a={...t?.[Q.Day]};return Object.entries(e).filter(([,r])=>r===!0).forEach(([r])=>{a={...a,...n?.[r]}}),a}function ph(e,t,n,a){const r=a??e.today(),s=n?e.startOfBroadcastWeek(r,e):t?e.startOfISOWeek(r):e.startOfWeek(r),l=[];for(let i=0;i<7;i++){const c=e.addDays(s,i);l.push(c)}return l}function bh(e,t,n,a,r=!1){if(!e||!t)return;const{startOfYear:s,endOfYear:l,eachYearOfInterval:i,getYear:c}=a,d=s(e),f=l(t),u=i({start:d,end:f});return r&&u.reverse(),u.map(h=>{const g=n.formatYearDropdown(h,a);return{value:c(h),label:g,disabled:!1}})}function xh(e,t={}){const{weekStartsOn:n,locale:a}=t,r=n??a?.options?.weekStartsOn??0,s=i=>{const c=typeof i=="number"||typeof i=="string"?new Date(i):i;return new Ie(c.getFullYear(),c.getMonth(),c.getDate(),12,0,0,e)},l=i=>{const c=s(i);return new Date(c.getFullYear(),c.getMonth(),c.getDate(),0,0,0,0)};return{today:()=>s(Ie.tz(e)),newDate:(i,c,d)=>new Ie(i,c,d,12,0,0,e),startOfDay:i=>s(i),startOfWeek:(i,c)=>{const d=s(i),f=c?.weekStartsOn??r,u=(d.getDay()-f+7)%7;return d.setDate(d.getDate()-u),d},startOfISOWeek:i=>{const c=s(i),d=(c.getDay()-1+7)%7;return c.setDate(c.getDate()-d),c},startOfMonth:i=>{const c=s(i);return c.setDate(1),c},startOfYear:i=>{const c=s(i);return c.setMonth(0,1),c},endOfWeek:(i,c)=>{const d=s(i),h=(((c?.weekStartsOn??r)+6)%7-d.getDay()+7)%7;return d.setDate(d.getDate()+h),d},endOfISOWeek:i=>{const c=s(i),d=(7-c.getDay())%7;return c.setDate(c.getDate()+d),c},endOfMonth:i=>{const c=s(i);return c.setMonth(c.getMonth()+1,0),c},endOfYear:i=>{const c=s(i);return c.setMonth(11,31),c},eachMonthOfInterval:i=>{const c=s(i.start),d=s(i.end),f=[],u=new Ie(c.getFullYear(),c.getMonth(),1,12,0,0,e),h=d.getFullYear()*12+d.getMonth();for(;u.getFullYear()*12+u.getMonth()<=h;)f.push(new Ie(u,e)),u.setMonth(u.getMonth()+1,1);return f},addDays:(i,c)=>{const d=s(i);return d.setDate(d.getDate()+c),d},addWeeks:(i,c)=>{const d=s(i);return d.setDate(d.getDate()+c*7),d},addMonths:(i,c)=>{const d=s(i);return d.setMonth(d.getMonth()+c),d},addYears:(i,c)=>{const d=s(i);return d.setFullYear(d.getFullYear()+c),d},eachYearOfInterval:i=>{const c=s(i.start),d=s(i.end),f=[],u=new Ie(c.getFullYear(),0,1,12,0,0,e);for(;u.getFullYear()<=d.getFullYear();)f.push(new Ie(u,e)),u.setFullYear(u.getFullYear()+1,0,1);return f},getWeek:(i,c)=>{const d=l(i);return ha(d,{weekStartsOn:c?.weekStartsOn??r,firstWeekContainsDate:c?.firstWeekContainsDate??a?.options?.firstWeekContainsDate??1})},getISOWeek:i=>{const c=l(i);return ma(c)},differenceInCalendarDays:(i,c)=>{const d=l(i),f=l(c);return fa(d,f)},differenceInCalendarMonths:(i,c)=>{const d=l(i),f=l(c);return yo(d,f)}}}const un=e=>e instanceof HTMLElement?e:null,zn=e=>[...e.querySelectorAll("[data-animated-month]")??[]],kh=e=>un(e.querySelector("[data-animated-month]")),Bn=e=>un(e.querySelector("[data-animated-caption]")),Hn=e=>un(e.querySelector("[data-animated-weeks]")),wh=e=>un(e.querySelector("[data-animated-nav]")),vh=e=>un(e.querySelector("[data-animated-weekdays]"));function Nh(e,t,{classNames:n,months:a,focused:r,dateLib:s}){const l=m.useRef(null),i=m.useRef(a),c=m.useRef(!1);m.useLayoutEffect(()=>{const d=i.current;if(i.current=a,!t||!e.current||!(e.current instanceof HTMLElement)||a.length===0||d.length===0||a.length!==d.length)return;const f=s.isSameMonth(a[0].date,d[0].date),u=s.isAfter(a[0].date,d[0].date),h=u?n[He.caption_after_enter]:n[He.caption_before_enter],g=u?n[He.weeks_after_enter]:n[He.weeks_before_enter],p=l.current,x=e.current.cloneNode(!0);if(x instanceof HTMLElement?(zn(x).forEach(k=>{if(!(k instanceof HTMLElement))return;const N=kh(k);N&&k.contains(N)&&k.removeChild(N);const D=Bn(k);D&&D.classList.remove(h);const j=Hn(k);j&&j.classList.remove(g)}),l.current=x):l.current=null,c.current||f||r)return;const v=p instanceof HTMLElement?zn(p):[],w=zn(e.current);if(w?.every(_=>_ instanceof HTMLElement)&&v&&v.every(_=>_ instanceof HTMLElement)){c.current=!0,e.current.style.isolation="isolate";const _=wh(e.current);_&&(_.style.zIndex="1"),w.forEach((k,N)=>{const D=v[N];if(!D)return;k.style.position="relative",k.style.overflow="hidden";const j=Bn(k);j&&j.classList.add(h);const L=Hn(k);L&&L.classList.add(g);const P=()=>{c.current=!1,e.current&&(e.current.style.isolation=""),_&&(_.style.zIndex=""),j&&j.classList.remove(h),L&&L.classList.remove(g),k.style.position="",k.style.overflow="",k.contains(D)&&k.removeChild(D)};D.style.pointerEvents="none",D.style.position="absolute",D.style.overflow="hidden",D.setAttribute("aria-hidden","true");const C=vh(D);C&&(C.style.opacity="0");const I=Bn(D);I&&(I.classList.add(u?n[He.caption_before_exit]:n[He.caption_after_exit]),I.addEventListener("animationend",P));const K=Hn(D);K&&K.classList.add(u?n[He.weeks_before_exit]:n[He.weeks_after_exit]),k.insertBefore(D,k.firstChild)})}})}function _h(e,t,n,a){const r=e[0],s=e[e.length-1],{ISOWeek:l,fixedWeeks:i,broadcastCalendar:c}=n??{},{addDays:d,differenceInCalendarDays:f,differenceInCalendarMonths:u,endOfBroadcastWeek:h,endOfISOWeek:g,endOfMonth:p,endOfWeek:x,isAfter:v,startOfBroadcastWeek:w,startOfISOWeek:_,startOfWeek:k}=a,N=c?w(r,a):l?_(r):k(r),D=c?h(s):l?g(p(s)):x(p(s)),j=t&&(c?h(t):l?g(t):x(t)),L=j&&v(D,j)?j:D,P=f(L,N),C=u(s,r)+1,I=[];for(let $=0;$<=P;$++){const E=d(N,$);I.push(E)}const V=(c?35:42)*C;if(i&&I.length<V){const $=V-I.length;for(let E=0;E<$;E++){const T=d(I[I.length-1],1);I.push(T)}}return I}function Mh(e){const t=[];return e.reduce((n,a)=>{const r=a.weeks.reduce((s,l)=>s.concat(l.days.slice()),t.slice());return n.concat(r.slice())},t.slice())}function jh(e,t,n,a){const{numberOfMonths:r=1}=n,s=[];for(let l=0;l<r;l++){const i=a.addMonths(e,l);if(t&&i>t)break;s.push(i)}return s}function dr(e,t,n,a){const{month:r,defaultMonth:s,today:l=a.today(),numberOfMonths:i=1}=e;let c=r||s||l;const{differenceInCalendarMonths:d,addMonths:f,startOfMonth:u}=a;if(n&&d(n,c)<i-1){const h=-1*(i-1);c=f(n,h)}return t&&d(c,t)<0&&(c=t),u(c)}function Sh(e,t,n,a){const{addDays:r,endOfBroadcastWeek:s,endOfISOWeek:l,endOfMonth:i,endOfWeek:c,getISOWeek:d,getWeek:f,startOfBroadcastWeek:u,startOfISOWeek:h,startOfWeek:g}=a,p=e.reduce((x,v)=>{const w=n.broadcastCalendar?u(v,a):n.ISOWeek?h(v):g(v),_=n.broadcastCalendar?s(v):n.ISOWeek?l(i(v)):c(i(v)),k=t.filter(L=>L>=w&&L<=_),N=n.broadcastCalendar?35:42;if(n.fixedWeeks&&k.length<N){const L=t.filter(P=>{const C=N-k.length;return P>_&&P<=r(_,C)});k.push(...L)}const D=k.reduce((L,P)=>{const C=n.ISOWeek?d(P):f(P),I=L.find(V=>V.weekNumber===C),K=new _o(P,v,a);return I?I.days.push(K):L.push(new vm(C,[K])),L},[]),j=new wm(v,D);return x.push(j),x},[]);return n.reverseMonths?p.reverse():p}function Ch(e,t){let{startMonth:n,endMonth:a}=e;const{startOfYear:r,startOfDay:s,startOfMonth:l,endOfMonth:i,addYears:c,endOfYear:d,newDate:f,today:u}=t,{fromYear:h,toYear:g,fromMonth:p,toMonth:x}=e;!n&&p&&(n=p),!n&&h&&(n=t.newDate(h,0,1)),!a&&x&&(a=x),!a&&g&&(a=f(g,11,31));const v=e.captionLayout==="dropdown"||e.captionLayout==="dropdown-years";return n?n=l(n):h?n=f(h,0,1):!n&&v&&(n=r(c(e.today??u(),-100))),a?a=i(a):g?a=f(g,11,31):!a&&v&&(a=d(e.today??u())),[n&&s(n),a&&s(a)]}function Dh(e,t,n,a){if(n.disableNavigation)return;const{pagedNavigation:r,numberOfMonths:s=1}=n,{startOfMonth:l,addMonths:i,differenceInCalendarMonths:c}=a,d=r?s:1,f=l(e);if(!t)return i(f,d);if(!(c(t,e)<s))return i(f,d)}function Th(e,t,n,a){if(n.disableNavigation)return;const{pagedNavigation:r,numberOfMonths:s}=n,{startOfMonth:l,addMonths:i,differenceInCalendarMonths:c}=a,d=r?s??1:1,f=l(e);if(!t)return i(f,-d);if(!(c(f,t)<=0))return i(f,-d)}function Ph(e){const t=[];return e.reduce((n,a)=>n.concat(a.weeks.slice()),t.slice())}function Sn(e,t){const[n,a]=m.useState(e);return[t===void 0?n:t,a]}function Oh(e,t){const[n,a]=Ch(e,t),{startOfMonth:r,endOfMonth:s}=t,l=dr(e,n,a,t),[i,c]=Sn(l,e.month?l:void 0);m.useEffect(()=>{const N=dr(e,n,a,t);c(N)},[e.timeZone]);const{months:d,weeks:f,days:u,previousMonth:h,nextMonth:g}=m.useMemo(()=>{const N=jh(i,a,{numberOfMonths:e.numberOfMonths},t),D=_h(N,e.endMonth?s(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),j=Sh(N,D,{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t),L=Ph(j),P=Mh(j),C=Th(i,n,e,t),I=Dh(i,a,e,t);return{months:j,weeks:L,days:P,previousMonth:C,nextMonth:I}},[t,i.getTime(),a?.getTime(),n?.getTime(),e.disableNavigation,e.broadcastCalendar,e.endMonth?.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:p,onMonthChange:x}=e,v=N=>f.some(D=>D.days.some(j=>j.isEqualTo(N))),w=N=>{if(p)return;let D=r(N);n&&D<r(n)&&(D=r(n)),a&&D>r(a)&&(D=r(a)),c(D),x?.(D)};return{months:d,weeks:f,days:u,navStart:n,navEnd:a,previousMonth:h,nextMonth:g,goToMonth:w,goToDay:N=>{v(N)||w(N.date)}}}var nt;(function(e){e[e.Today=0]="Today",e[e.Selected=1]="Selected",e[e.LastFocused=2]="LastFocused",e[e.FocusedModifier=3]="FocusedModifier"})(nt||(nt={}));function ur(e){return!e[_e.disabled]&&!e[_e.hidden]&&!e[_e.outside]}function $h(e,t,n,a){let r,s=-1;for(const l of e){const i=t(l);ur(i)&&(i[_e.focused]&&s<nt.FocusedModifier?(r=l,s=nt.FocusedModifier):a?.isEqualTo(l)&&s<nt.LastFocused?(r=l,s=nt.LastFocused):n(l.date)&&s<nt.Selected?(r=l,s=nt.Selected):i[_e.today]&&s<nt.Today&&(r=l,s=nt.Today))}return r||(r=e.find(l=>ur(t(l)))),r}function Wh(e,t,n,a,r,s,l){const{ISOWeek:i,broadcastCalendar:c}=s,{addDays:d,addMonths:f,addWeeks:u,addYears:h,endOfBroadcastWeek:g,endOfISOWeek:p,endOfWeek:x,max:v,min:w,startOfBroadcastWeek:_,startOfISOWeek:k,startOfWeek:N}=l;let j={day:d,week:u,month:f,year:h,startOfWeek:L=>c?_(L,l):i?k(L):N(L),endOfWeek:L=>c?g(L):i?p(L):x(L)}[e](n,t==="after"?1:-1);return t==="before"&&a?j=v([a,j]):t==="after"&&r&&(j=w([r,j])),j}function Io(e,t,n,a,r,s,l,i=0){if(i>365)return;const c=Wh(e,t,n.date,a,r,s,l),d=!!(s.disabled&&ft(c,s.disabled,l)),f=!!(s.hidden&&ft(c,s.hidden,l)),u=c,h=new _o(c,u,l);return!d&&!f?h:Io(e,t,h,a,r,s,l,i+1)}function Eh(e,t,n,a,r){const{autoFocus:s}=e,[l,i]=m.useState(),c=$h(t.days,n,a||(()=>!1),l),[d,f]=m.useState(s?c:void 0);return{isFocusTarget:x=>!!c?.isEqualTo(x),setFocused:f,focused:d,blur:()=>{i(d),f(void 0)},moveFocus:(x,v)=>{if(!d)return;const w=Io(x,v,d,t.navStart,t.navEnd,e,r);w&&(e.disableNavigation&&!t.days.some(k=>k.isEqualTo(w))||(t.goToDay(w),f(w)))}}}function Ah(e,t){const{selected:n,required:a,onSelect:r}=e,[s,l]=Sn(n,r?n:void 0),i=r?n:s,{isSameDay:c}=t,d=g=>i?.some(p=>c(p,g))??!1,{min:f,max:u}=e;return{selected:i,select:(g,p,x)=>{let v=[...i??[]];if(d(g)){if(i?.length===f||a&&i?.length===1)return;v=i?.filter(w=>!c(w,g))}else i?.length===u?v=[g]:v=[...v,g];return r||l(v),r?.(v,g,p,x),v},isSelected:d}}function Fh(e,t,n=0,a=0,r=!1,s=st){const{from:l,to:i}=t||{},{isSameDay:c,isAfter:d,isBefore:f}=s;let u;if(!l&&!i)u={from:e,to:n>0?void 0:e};else if(l&&!i)c(l,e)?n===0?u={from:l,to:e}:r?u={from:l,to:void 0}:u=void 0:f(e,l)?u={from:e,to:l}:u={from:l,to:e};else if(l&&i)if(c(l,e)&&c(i,e))r?u={from:l,to:i}:u=void 0;else if(c(l,e))u={from:l,to:n>0?void 0:e};else if(c(i,e))u={from:e,to:n>0?void 0:e};else if(f(e,l))u={from:e,to:i};else if(d(e,l))u={from:l,to:e};else if(d(e,i))u={from:l,to:e};else throw new Error("Invalid range");if(u?.from&&u?.to){const h=s.differenceInCalendarDays(u.to,u.from);a>0&&h>a?u={from:e,to:void 0}:n>1&&h<n&&(u={from:e,to:void 0})}return u}function Rh(e,t,n=st){const a=Array.isArray(t)?t:[t];let r=e.from;const s=n.differenceInCalendarDays(e.to,e.from),l=Math.min(s,6);for(let i=0;i<=l;i++){if(a.includes(r.getDay()))return!0;r=n.addDays(r,1)}return!1}function fr(e,t,n=st){return ut(e,t.from,!1,n)||ut(e,t.to,!1,n)||ut(t,e.from,!1,n)||ut(t,e.to,!1,n)}function Ih(e,t,n=st){const a=Array.isArray(t)?t:[t];if(a.filter(i=>typeof i!="function").some(i=>typeof i=="boolean"?i:n.isDate(i)?ut(e,i,!1,n):So(i,n)?i.some(c=>ut(e,c,!1,n)):jn(i)?i.from&&i.to?fr(e,{from:i.from,to:i.to},n):!1:jo(i)?Rh(e,i.dayOfWeek,n):ga(i)?n.isAfter(i.before,i.after)?fr(e,{from:n.addDays(i.after,1),to:n.addDays(i.before,-1)},n):ft(e.from,i,n)||ft(e.to,i,n):ya(i)||pa(i)?ft(e.from,i,n)||ft(e.to,i,n):!1))return!0;const l=a.filter(i=>typeof i=="function");if(l.length){let i=e.from;const c=n.differenceInCalendarDays(e.to,e.from);for(let d=0;d<=c;d++){if(l.some(f=>f(i)))return!0;i=n.addDays(i,1)}}return!1}function Lh(e,t){const{disabled:n,excludeDisabled:a,resetOnSelect:r,selected:s,required:l,onSelect:i}=e,[c,d]=Sn(s,i?s:void 0),f=i?s:c;return{selected:f,select:(g,p,x)=>{const{min:v,max:w}=e;let _;if(g){const k=f?.from,N=f?.to,D=!!k&&!!N,j=!!k&&!!N&&t.isSameDay(k,N)&&t.isSameDay(g,k);r&&(D||!f?.from)?!l&&j?_=void 0:_={from:g,to:void 0}:_=Fh(g,f,v,w,l,t)}return a&&n&&_?.from&&_.to&&Ih({from:_.from,to:_.to},n,t)&&(_.from=g,_.to=void 0),i||d(_),i?.(_,g,p,x),_},isSelected:g=>f&&ut(f,g,!1,t)}}function Yh(e,t){const{selected:n,required:a,onSelect:r}=e,[s,l]=Sn(n,r?n:void 0),i=r?n:s,{isSameDay:c}=t;return{selected:i,select:(u,h,g)=>{let p=u;return!a&&i&&i&&c(u,i)&&(p=void 0),r||l(p),r?.(p,u,h,g),p},isSelected:u=>i?c(i,u):!1}}function zh(e,t){const n=Yh(e,t),a=Ah(e,t),r=Lh(e,t);switch(e.mode){case"single":return n;case"multiple":return a;case"range":return r;default:return}}function qe(e,t){return e instanceof Ie&&e.timeZone===t?e:new Ie(e,t)}function At(e,t,n){return qe(e,t)}function mr(e,t,n){return typeof e=="boolean"||typeof e=="function"?e:e instanceof Date?At(e,t):Array.isArray(e)?e.map(a=>a instanceof Date?At(a,t):a):jn(e)?{...e,from:e.from?qe(e.from,t):e.from,to:e.to?qe(e.to,t):e.to}:ga(e)?{before:At(e.before,t),after:At(e.after,t)}:ya(e)?{after:At(e.after,t)}:pa(e)?{before:At(e.before,t)}:e}function Un(e,t,n){return e&&(Array.isArray(e)?e.map(a=>mr(a,t)):mr(e,t))}function Bh(e){let t=e;const n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&(t.today=qe(t.today,n)),t.month&&(t.month=qe(t.month,n)),t.defaultMonth&&(t.defaultMonth=qe(t.defaultMonth,n)),t.startMonth&&(t.startMonth=qe(t.startMonth,n)),t.endMonth&&(t.endMonth=qe(t.endMonth,n)),t.mode==="single"&&t.selected?t.selected=qe(t.selected,n):t.mode==="multiple"&&t.selected?t.selected=t.selected?.map(oe=>qe(oe,n)):t.mode==="range"&&t.selected&&(t.selected={from:t.selected.from?qe(t.selected.from,n):t.selected.from,to:t.selected.to?qe(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=Un(t.disabled,n)),t.hidden!==void 0&&(t.hidden=Un(t.hidden,n)),t.modifiers)){const oe={};Object.keys(t.modifiers).forEach(ae=>{oe[ae]=Un(t.modifiers?.[ae],n)}),t.modifiers=oe}const{components:a,formatters:r,labels:s,dateLib:l,locale:i,classNames:c}=m.useMemo(()=>{const oe={...No,...t.locale},ae=t.broadcastCalendar?1:t.weekStartsOn,ee=t.noonSafe&&t.timeZone?xh(t.timeZone,{weekStartsOn:ae,locale:oe}):void 0,ce=t.dateLib&&ee?{...ee,...t.dateLib}:t.dateLib??ee,Ce=new Ue({locale:oe,weekStartsOn:ae,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},ce);return{dateLib:Ce,components:Jm(t.components),formatters:ch(t.formatters),labels:hh(t.labels,Ce.options),locale:oe,classNames:{...eh(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.noonSafe,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:l.today()});const{captionLayout:d,mode:f,navLayout:u,numberOfMonths:h=1,onDayBlur:g,onDayClick:p,onDayFocus:x,onDayKeyDown:v,onDayMouseEnter:w,onDayMouseLeave:_,onNextClick:k,onPrevClick:N,showWeekNumber:D,styles:j}=t,{formatCaption:L,formatDay:P,formatMonthDropdown:C,formatWeekNumber:I,formatWeekNumberHeader:K,formatWeekdayName:V,formatYearDropdown:$}=r,E=Oh(t,l),{days:T,months:b,navStart:M,navEnd:H,previousMonth:S,nextMonth:X,goToMonth:F}=E,z=Gm(T,t,M,H,l),{isSelected:B,select:Z,selected:xe}=zh(t,l)??{},{blur:je,focused:Me,isFocusTarget:Se,moveFocus:J,setFocused:De}=Eh(t,E,z,B??(()=>!1),l),{labelDayButton:le,labelGridcell:de,labelGrid:W,labelMonthDropdown:te,labelNav:ge,labelPrevious:me,labelNext:Ne,labelWeekday:Fe,labelWeekNumber:Te,labelWeekNumberHeader:A,labelYearDropdown:Y}=s,U=m.useMemo(()=>ph(l,t.ISOWeek,t.broadcastCalendar,t.today),[l,t.ISOWeek,t.broadcastCalendar,t.today]),q=f!==void 0||p!==void 0,ne=m.useCallback(()=>{S&&(F(S),N?.(S))},[S,F,N]),se=m.useCallback(()=>{X&&(F(X),k?.(X))},[F,X,k]),ye=m.useCallback((oe,ae)=>ee=>{ee.preventDefault(),ee.stopPropagation(),De(oe),!ae.disabled&&(Z?.(oe.date,ae,ee),p?.(oe.date,ae,ee))},[Z,p,De]),fe=m.useCallback((oe,ae)=>ee=>{De(oe),x?.(oe.date,ae,ee)},[x,De]),he=m.useCallback((oe,ae)=>ee=>{je(),g?.(oe.date,ae,ee)},[je,g]),Pe=m.useCallback((oe,ae)=>ee=>{const ce={ArrowLeft:[ee.shiftKey?"month":"day",t.dir==="rtl"?"after":"before"],ArrowRight:[ee.shiftKey?"month":"day",t.dir==="rtl"?"before":"after"],ArrowDown:[ee.shiftKey?"year":"week","after"],ArrowUp:[ee.shiftKey?"year":"week","before"],PageUp:[ee.shiftKey?"year":"month","before"],PageDown:[ee.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(ce[ee.key]){ee.preventDefault(),ee.stopPropagation();const[Ce,ie]=ce[ee.key];J(Ce,ie)}v?.(oe.date,ae,ee)},[J,v,t.dir]),pe=m.useCallback((oe,ae)=>ee=>{w?.(oe.date,ae,ee)},[w]),We=m.useCallback((oe,ae)=>ee=>{_?.(oe.date,ae,ee)},[_]),Ee=m.useCallback(oe=>ae=>{const ee=Number(ae.target.value),ce=l.setMonth(l.startOfMonth(oe),ee);F(ce)},[l,F]),Be=m.useCallback(oe=>ae=>{const ee=Number(ae.target.value),ce=l.setYear(l.startOfMonth(oe),ee);F(ce)},[l,F]),{className:_t,style:gt}=m.useMemo(()=>({className:[c[Q.Root],t.className].filter(Boolean).join(" "),style:{...j?.[Q.Root],...t.style}}),[c,t.className,t.style,j]),yt=Zm(t),it=m.useRef(null);Nh(it,!!t.animate,{classNames:c,months:b,focused:Me,dateLib:l});const Mt={dayPickerProps:t,selected:xe,select:Z,isSelected:B,months:b,nextMonth:X,previousMonth:S,goToMonth:F,getModifiers:z,components:a,classNames:c,styles:j,labels:s,formatters:r};return R.createElement(Mo.Provider,{value:Mt},R.createElement(a.Root,{rootRef:t.animate?it:void 0,className:_t,style:gt,dir:t.dir,id:t.id,lang:t.lang??i.code,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t["aria-label"],"aria-labelledby":t["aria-labelledby"],...yt},R.createElement(a.Months,{className:c[Q.Months],style:j?.[Q.Months]},!t.hideNavigation&&!u&&R.createElement(a.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[Q.Nav],style:j?.[Q.Nav],"aria-label":ge(),onPreviousClick:ne,onNextClick:se,previousMonth:S,nextMonth:X}),b.map((oe,ae)=>R.createElement(a.Month,{"data-animated-month":t.animate?"true":void 0,className:c[Q.Month],style:j?.[Q.Month],key:ae,displayIndex:ae,calendarMonth:oe},u==="around"&&!t.hideNavigation&&ae===0&&R.createElement(a.PreviousMonthButton,{type:"button",className:c[Q.PreviousMonthButton],tabIndex:S?void 0:-1,"aria-disabled":S?void 0:!0,"aria-label":me(S),onClick:ne,"data-animated-button":t.animate?"true":void 0},R.createElement(a.Chevron,{disabled:S?void 0:!0,className:c[Q.Chevron],orientation:t.dir==="rtl"?"right":"left"})),R.createElement(a.MonthCaption,{"data-animated-caption":t.animate?"true":void 0,className:c[Q.MonthCaption],style:j?.[Q.MonthCaption],calendarMonth:oe,displayIndex:ae},d?.startsWith("dropdown")?R.createElement(a.DropdownNav,{className:c[Q.Dropdowns],style:j?.[Q.Dropdowns]},(()=>{const ee=d==="dropdown"||d==="dropdown-months"?R.createElement(a.MonthsDropdown,{key:"month",className:c[Q.MonthsDropdown],"aria-label":te(),classNames:c,components:a,disabled:!!t.disableNavigation,onChange:Ee(oe.date),options:gh(oe.date,M,H,r,l),style:j?.[Q.Dropdown],value:l.getMonth(oe.date)}):R.createElement("span",{key:"month"},C(oe.date,l)),ce=d==="dropdown"||d==="dropdown-years"?R.createElement(a.YearsDropdown,{key:"year",className:c[Q.YearsDropdown],"aria-label":Y(l.options),classNames:c,components:a,disabled:!!t.disableNavigation,onChange:Be(oe.date),options:bh(M,H,r,l,!!t.reverseYears),style:j?.[Q.Dropdown],value:l.getYear(oe.date)}):R.createElement("span",{key:"year"},$(oe.date,l));return l.getMonthYearOrder()==="year-first"?[ce,ee]:[ee,ce]})(),R.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"}},L(oe.date,l.options,l))):R.createElement(a.CaptionLabel,{className:c[Q.CaptionLabel],role:"status","aria-live":"polite"},L(oe.date,l.options,l))),u==="around"&&!t.hideNavigation&&ae===h-1&&R.createElement(a.NextMonthButton,{type:"button",className:c[Q.NextMonthButton],tabIndex:X?void 0:-1,"aria-disabled":X?void 0:!0,"aria-label":Ne(X),onClick:se,"data-animated-button":t.animate?"true":void 0},R.createElement(a.Chevron,{disabled:X?void 0:!0,className:c[Q.Chevron],orientation:t.dir==="rtl"?"left":"right"})),ae===h-1&&u==="after"&&!t.hideNavigation&&R.createElement(a.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[Q.Nav],style:j?.[Q.Nav],"aria-label":ge(),onPreviousClick:ne,onNextClick:se,previousMonth:S,nextMonth:X}),R.createElement(a.MonthGrid,{role:"grid","aria-multiselectable":f==="multiple"||f==="range","aria-label":W(oe.date,l.options,l)||void 0,className:c[Q.MonthGrid],style:j?.[Q.MonthGrid]},!t.hideWeekdays&&R.createElement(a.Weekdays,{"data-animated-weekdays":t.animate?"true":void 0,className:c[Q.Weekdays],style:j?.[Q.Weekdays]},D&&R.createElement(a.WeekNumberHeader,{"aria-label":A(l.options),className:c[Q.WeekNumberHeader],style:j?.[Q.WeekNumberHeader],scope:"col"},K()),U.map(ee=>R.createElement(a.Weekday,{"aria-label":Fe(ee,l.options,l),className:c[Q.Weekday],key:String(ee),style:j?.[Q.Weekday],scope:"col"},V(ee,l.options,l)))),R.createElement(a.Weeks,{"data-animated-weeks":t.animate?"true":void 0,className:c[Q.Weeks],style:j?.[Q.Weeks]},oe.weeks.map(ee=>R.createElement(a.Week,{className:c[Q.Week],key:ee.weekNumber,style:j?.[Q.Week],week:ee},D&&R.createElement(a.WeekNumber,{week:ee,style:j?.[Q.WeekNumber],"aria-label":Te(ee.weekNumber,{locale:i}),className:c[Q.WeekNumber],scope:"row",role:"rowheader"},I(ee.weekNumber,l)),ee.days.map(ce=>{const{date:Ce}=ce,ie=z(ce);if(ie[_e.focused]=!ie.hidden&&!!Me?.isEqualTo(ce),ie[Ze.selected]=B?.(Ce)||ie.selected,jn(xe)){const{from:jt,to:pt}=xe;ie[Ze.range_start]=!!(jt&&pt&&l.isSameDay(Ce,jt)),ie[Ze.range_end]=!!(jt&&pt&&l.isSameDay(Ce,pt)),ie[Ze.range_middle]=ut(xe,Ce,!0,l)}const ze=yh(ie,j,t.modifiersStyles),zt=Qm(ie,c,t.modifiersClassNames),Bt=!q&&!ie.hidden?de(Ce,ie,l.options,l):void 0;return R.createElement(a.Day,{key:`${ce.isoDate}_${ce.displayMonthId}`,day:ce,modifiers:ie,className:zt.join(" "),style:ze,role:"gridcell","aria-selected":ie.selected||void 0,"aria-label":Bt,"data-day":ce.isoDate,"data-month":ce.outside?ce.dateMonthId:void 0,"data-selected":ie.selected||void 0,"data-disabled":ie.disabled||void 0,"data-hidden":ie.hidden||void 0,"data-outside":ce.outside||void 0,"data-focused":ie.focused||void 0,"data-today":ie.today||void 0},!ie.hidden&&q?R.createElement(a.DayButton,{className:c[Q.DayButton],style:j?.[Q.DayButton],type:"button",day:ce,modifiers:ie,disabled:!ie.focused&&ie.disabled||void 0,"aria-disabled":ie.focused&&ie.disabled||void 0,tabIndex:Se(ce)?0:-1,"aria-label":le(Ce,ie,l.options,l),onClick:ye(ce,ie),onBlur:he(ce,ie),onFocus:fe(ce,ie),onKeyDown:Pe(ce,ie),onMouseEnter:pe(ce,ie),onMouseLeave:We(ce,ie)},P(Ce,l.options,l)):!ie.hidden&&P(ce.date,l.options,l))})))))))),t.footer&&R.createElement(a.Footer,{className:c[Q.Footer],style:j?.[Q.Footer],role:"status","aria-live":"polite"},t.footer)))}const Hh={en:wt,"zh-CN":Hf,"zh-TW":km,ja:Fu,ko:hf};function Lo(e){return Hh[e]||wt}function hr(e,t){if(!e)return"";const n=e.split("-");if(n.length!==3)return e;const a=new Date(Number(n[0]),Number(n[1])-1,Number(n[2]));return Number.isFinite(a.getTime())?ot(a,"MMM d",t?{locale:t}:void 0):e}function ra({from:e,to:t,onApply:n,onCancel:a}){const r=m.useMemo(()=>{const f={from:void 0,to:void 0};if(e){const u=e.split("-");f.from=new Date(Number(u[0]),Number(u[1])-1,Number(u[2]))}if(t){const u=t.split("-");f.to=new Date(Number(u[0]),Number(u[1])-1,Number(u[2]))}return f},[e,t]),[s,l]=m.useState(r),i=Lo(zr()),c=()=>{if(!s?.from)return;const f=ot(s.from,"yyyy-MM-dd"),u=s.to?ot(s.to,"yyyy-MM-dd"):f;n?.(f,u)},d=!!s?.from;return o.jsxs("div",{className:"p-4",children:[o.jsx(Bh,{mode:"range",locale:i,selected:s,onSelect:l,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"}}}),o.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:[d&&s.from&&o.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mr-auto",children:[ot(s.from,"MMM d, yyyy",{locale:i}),s.to&&s.to.getTime()!==s.from.getTime()?` — ${ot(s.to,"MMM d, yyyy",{locale:i})}`:""]}),o.jsx(Kn,{variant:"secondary",size:"sm",onClick:a,children:y("shared.action.cancel")}),o.jsx(Kn,{variant:"primary",size:"sm",onClick:c,disabled:!d,children:y("shared.action.apply")})]})]})}function ka(e){if(!Number.isFinite(Number(e)))return null;const t=Number(e);return t<=0?null:Ae(t,{decimals:1})}function wa(e,t,n){const a=Number(e);if(!Number.isFinite(a)||a<=0)return null;const r=ia(t);return(t===Yr?a:a*n)<.01?`<${r}0.01`:et(a,{decimals:2,currency:t,rate:n})}function Uh(e,t,n){const a=wa(e,t,n);return a?`${a}/MTok`:null}function Qt(e){return e?String(e).replace(/^claude-/,""):""}function Vh(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?{key:t,label:gr(t)}:{key:t.key,label:t.label||gr(t.key)}):[]}function qh(e){if(typeof e!="string")return null;const t=e.replace(/,/g,"").match(/-?\d+(?:\.\d+)?/);if(!t)return null;const n=Number(t[0]);return Number.isFinite(n)?n:null}const Xh={CODEX:"#3b82f6",CLAUDE:"#d97757",OPENCODE:"#f59e0b",GEMINI:"#2196f3",KIMI:"#a78bfa","KILO-CLI":"#facc15","KILO-CODE":"#facc15",DROID:"#ef4444"};function Vn(e,t){const n=e?.toUpperCase?.()||"";return Xh[n]||`hsl(${150+t*40}, 60%, 45%)`}function Jt(e){const t=String(e?.source||"").trim().toLowerCase(),n=String(e?.label||"").trim().toLowerCase();return t==="claude"||n==="claude"?"claude":t==="codex"||n==="codex"?"codex":null}function va(e){return!!e?.models?.length}function Kh(e){const t=Number(e);return!Number.isFinite(t)||t<=0?"0%":`${Math.min(100,Math.max(2,t))}%`}function Gh(e,t){const n=String(e?.id||e?.name||"").trim().toLowerCase(),a=String(t?.id||t?.name||"").trim().toLowerCase();return!!(n&&a&&n===a)}function Qh(e,t=3){return[...e?.models||[]].sort((n,a)=>(Number(a.share)||0)-(Number(n.share)||0)).slice(0,t)}function Jh(e,t){return Math.max(0,(e?.models?.length||0)-t.length)}const Zh={day:"usage.period.day","24h":"usage.period.last24h",week:"usage.period.week",month:"usage.period.month",total:"usage.period.total",custom:"usage.period.custom"};function gr(e){const t=Zh[e];return t?y(t):String(e).toUpperCase()}function e0({loading:e,onClick:t}){const n=Lt();return o.jsx(Kn,{variant:"secondary",size:"sm",disabled:e,onClick:t,"aria-label":y("usage.button.refresh"),className:"w-8 p-0",children:o.jsx(ht.span,{"aria-hidden":"true",animate:e?{rotate:360}:{rotate:0},transition:e&&!n?{duration:1,repeat:1/0,ease:"linear"}:{duration:.3},style:{display:"inline-block"},children:"↻"})})}function yr({period:e,periods:t,onPeriodChange:n,autoRefreshOptions:a=[],autoRefreshIntervalMs:r,onAutoRefreshIntervalChange:s,summaryValue:l,summaryLabel:i,summaryUpdatedAtLabel:c,summaryCostValue:d,usageInsights:f,onCostInfo:u,onRefresh:h,loading:g,customFrom:p,customTo:x,onCustomRangeApply:v,customRangeOpen:w,onCustomRangeOpenChange:_,emphasized:k=!1}){const N=Lt(),D=Vh(t),j=Array.isArray(a)&&a.length>0&&typeof s=="function",L=Lo(zr()),P=qh(String(l??"")),C=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches,[I,K]=m.useState(C);m.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const W=window.matchMedia("(max-width: 639px)"),te=ge=>K(ge.matches);return W.addEventListener("change",te),()=>W.removeEventListener("change",te)},[]);const V=P!=null&&!I&&!g&&!N,$=k&&l!=null&&String(l)!=="",E=m.useRef(null);m.useEffect(()=>{const W=E.current?.querySelector('[aria-selected="true"]');W&&typeof W.scrollIntoView=="function"&&W.scrollIntoView({block:"nearest",inline:"center"})},[e]);const{resolvedTheme:T}=Lr(),{currency:b,rate:M}=Nt(),H=T==="dark",S=H?"rgba(10,10,10,0.98)":"rgba(255,255,255,0.96)",X=H?"rgba(10,10,10,0)":"rgba(255,255,255,0)",F=Uh(f?.costPerMillionTokens,b,M),z=f?.topCostModel?.name?Qt(f.topCostModel.name):"",B=f?.topUsageModel?.name?Qt(f.topUsageModel.name):"",Z=Array.isArray(f?.missingPricingModels)?f.missingPricingModels.length:0,xe=!!Z,je=!!(F||z||B||xe),Me=k?"h-full flex flex-col !bg-oai-brand-50 dark:!bg-oai-brand-950/40 !border-oai-brand-200 dark:!border-oai-brand-800":"",Se=k?"flex-1 flex flex-col":"",J=k?"flex flex-1 flex-col justify-center":"",De=k?"flex flex-col gap-3":"flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between",le=k?"flex flex-col gap-2":"flex flex-col gap-2 sm:items-end",de=k?"flex flex-wrap items-center gap-1.5 text-[11px] font-medium":"flex flex-wrap items-center gap-1.5 text-[11px] font-medium sm:justify-end";return o.jsxs(on,{className:Me,bodyClassName:Se,children:[o.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[o.jsx("div",{ref:E,role:"tablist","aria-label":y("usage.overview.tablist_aria"),className:"flex flex-1 min-w-0 gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:D.map(W=>{const te=e===W.key,ge=`shrink-0 whitespace-nowrap text-xs font-medium px-3 py-1.5 rounded-md transition-colors ${te?"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(W.key==="custom"){const me=te&&p&&x?`${hr(p,L)} — ${hr(x,L)}`:W.label;return o.jsxs(Qn,{open:w,onOpenChange:Ne=>{Ne?n?.("custom"):_?.(Ne)},children:[o.jsx(Jn,{render:o.jsx("button",{role:"tab","aria-selected":te,type:"button",className:ge}),children:me}),o.jsx(Zn,{children:o.jsx(ea,{sideOffset:8,side:"bottom",align:"start",className:"!z-[9999]",children:o.jsx(ta,{className:"bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded-xl shadow-lg",children:o.jsx(ra,{from:p,to:x,onApply:v,onCancel:()=>_?.(!1)})})})})]},"custom")}return o.jsx("button",{role:"tab","aria-selected":te,type:"button",className:ge,onClick:()=>n?.(W.key),children:W.label},W.key)})}),o.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[j?o.jsx("select",{"aria-label":y("usage.auto_refresh.aria"),value:String(r),onChange:W=>s(W.target.value),className:"h-8 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 bg-oai-white dark:bg-oai-gray-900 px-2 text-xs font-medium text-oai-gray-700 dark:text-oai-gray-200 transition-colors hover:border-oai-gray-400 dark:hover:border-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand/25",children:a.map(W=>o.jsx("option",{value:String(W.value),children:y(W.labelKey)},W.value))}):null,h&&o.jsx(e0,{loading:g,onClick:h})]})]}),o.jsx("div",{className:J,children:o.jsxs("div",{className:De,children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wider mb-2",children:i}),o.jsx("div",{className:"text-5xl sm:text-6xl md:text-7xl font-bold text-oai-black dark:text-oai-white tracking-tight tabular-nums leading-none [container-type:inline-size]",children:$?o.jsx(il,{value:l,fontSize:58}):V?o.jsx(nl,{value:P,displayValue:l,fontSize:72,padding:6,gap:1,textColor:"var(--oai-black, #111827)",fontWeight:700,gradientHeight:H?0:8,gradientFrom:S,gradientTo:X,counterStyle:{paddingLeft:0,paddingRight:0,gap:0},digitStyle:{width:"0.88ch"}}):l}),c?o.jsx("div",{className:"mt-2 text-[11px] font-medium text-oai-gray-400 dark:text-oai-gray-500 tabular-nums",children:c}):null]}),(d||je)&&o.jsxs("div",{className:le,children:[d&&o.jsx("div",{className:"flex items-center gap-2",children:u?o.jsxs("button",{type:"button",onClick:u,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":y("usage.overview.cost_breakdown_aria"),children:[d,o.jsx(ca,{size:16,strokeWidth:2,className:"opacity-80"})]}):o.jsx("span",{className:"text-xl font-bold text-oai-brand",children:d})}),je&&o.jsxs("div",{className:de,children:[F?o.jsx("span",{className:"rounded-md border border-oai-gray-200 dark:border-oai-gray-700 px-2 py-1 text-oai-gray-600 dark:text-oai-gray-300 tabular-nums",children:y("usage.overview.cost_per_mtok",{value:F})}):null,z?o.jsx("span",{className:"rounded-md border border-oai-gray-200 dark:border-oai-gray-700 px-2 py-1 text-oai-gray-600 dark:text-oai-gray-300",children:y("usage.overview.top_cost_model",{model:z})}):null,B&&B!==z?o.jsx("span",{className:"rounded-md border border-oai-gray-200 dark:border-oai-gray-700 px-2 py-1 text-oai-gray-600 dark:text-oai-gray-300",children:y("usage.overview.top_usage_model",{model:B})}):null,xe?o.jsx("span",{className:"rounded-md border border-amber-200 bg-amber-50 px-2 py-1 text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200",children:y("usage.overview.missing_pricing_count",{count:Z})}):null]})]})]})})]})}const pr={claude:35,codex:250},br={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 t0(e,t){const n=pr[t]??pr.claude,a=br[e]||br.system_prompt;return`oklch(${a.l} ${a.c} ${n})`}const n0=[{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"]}],a0=[["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"]],r0={duration:.18,ease:[.4,0,.2,1]},o0={height:0,opacity:0},s0={height:"auto",opacity:1},i0={height:0,opacity:0};function l0(e){const t=Number(e||0);return Number.isFinite(t)&&t>0?t:0}function c0(e,t){const n={};for(const a of["input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens","total_tokens"])n[a]=Math.round(Number(e?.[a]||0)*t);return n}function Yo(e,t=null){const n=e.reduce((l,i)=>l+Number(i.totals.total_tokens||0),0),a=l0(t),r=a||n,s=a&&n>0?a/n:1;return e.map(l=>{const i=s===1?l.totals:c0(l.totals,s);return{...l,totals:i,percent:r>0?Number((i.total_tokens/r*100).toFixed(2)):0}}).sort((l,i)=>i.totals.total_tokens-l.totals.total_tokens)}function d0(e,t=null){const n=new Map;for(const r of e||[])n.set(r.key,r);const a=n0.map(r=>{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 l of r.from){const i=n.get(l);if(!i)continue;const c=i.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:r.key,totals:s}});return Yo(a,t)}function u0(e,t=null){const n=e?.totals||{},a=Number(n.reasoning_output_tokens||0),r=(e?.tool_calls_breakdown?.categories||[]).reduce((d,f)=>f?.name==="Text Response"?d:d+Number(f?.totals?.total_tokens||0),0),s=Number(n.total_tokens||0),l=Math.min(Math.max(0,r),Math.max(0,s-a)),c=[{key:"messages",totals:{total_tokens:Math.max(0,s-a-l)}},{key:"tool_calls",totals:{total_tokens:l}},{key:"reasoning",totals:{total_tokens:a}}];return Yo(c,t)}const xr="MCP: ";function f0(e){if(!e?.categories?.length)return{mcpSet:null,residualSet:e,mcpTotalTokens:0};const t=[],n=[];let a=0;for(const r of e.categories){const s=String(r?.name||"");s.startsWith(xr)?(t.push({...r,name:s.slice(xr.length)}),a+=Number(r?.totals?.total_tokens||0)):n.push(r)}return t.length===0?{mcpSet:null,residualSet:e,mcpTotalTokens:0}:(t.sort((r,s)=>(s.totals?.total_tokens||0)-(r.totals?.total_tokens||0)),{mcpSet:{...e,categories:t},residualSet:{...e,categories:n},mcpTotalTokens:a})}function kr(e){return y(`dashboard.context_breakdown.category.${e}`)}function at(e){return!Number.isFinite(Number(e))||Number(e)<=0?"0":Ae(Number(e),{decimals:1})}function m0(e){return typeof e!="string"?"":e.startsWith("mcp__")?e.split("__").slice(2).join("__")||e:e.includes("/")&&e.split("/").pop()||e}function h0(e){return(Array.isArray(e)?e:[]).map(t=>{const n=t?.totals||null,a=Number(n?n.input_tokens||0:t?.input_tokens||0),r=Number(n?n.output_tokens||0:t?.output_tokens||0),s=Number(n?n.cached_input_tokens||0:t?.cache_read||0),l=Number(n?n.cache_creation_input_tokens||0:t?.cache_creation||0),i=Number(n?n.total_tokens||a+r:t?.total_tokens||r);return{name:m0(t?.name?String(t.name):""),calls:Number(t?.calls||0),input_tokens:a,output_tokens:r,cache_read:s,cache_creation:l,total_tokens:Number(i||0)}}).filter(t=>t.name).sort((t,n)=>(n.total_tokens||0)-(t.total_tokens||0))}function g0(e){return(Array.isArray(e)?e:[]).map(t=>{const n=t?.totals||{},a=Array.isArray(t?.tools)?t.tools:[],r=Number(n.input_tokens||0),s=Number(n.output_tokens||0),l=Number(n.cached_input_tokens||0),i=Number(n.cache_creation_input_tokens||0);return{name:t?.name?String(t.name):"",calls:Number(t?.calls||0),totals:{input_tokens:r,output_tokens:s,cached_input_tokens:l,cache_creation_input_tokens:i,total_tokens:Number(n.total_tokens||r+s)},tools:h0(a),toolCount:a.length}}).filter(t=>t.name).sort((t,n)=>(n.totals.total_tokens||0)-(t.totals.total_tokens||0))}function y0(e){return(Array.isArray(e)?e:[]).map(t=>{const n=t?.totals||{},a=Number(n.input_tokens||0),r=Number(n.output_tokens||0),s=Number(n.cached_input_tokens||0),l=Number(n.cache_creation_input_tokens||0);return{key:t?.key?String(t.key):"",name:t?.name?String(t.name):"",totals:{input_tokens:a,output_tokens:r,cached_input_tokens:s,cache_creation_input_tokens:l,total_tokens:Number(n.total_tokens||a+r+s+l)}}}).filter(t=>t.key||t.name).sort((t,n)=>(n.totals.total_tokens||0)-(t.totals.total_tokens||0))}function p0(e){return(Array.isArray(e)?e:[]).map(t=>{const n=t?.totals||{};return{name:t?.name?String(t.name):"",calls:Number(t?.calls||0),total_tokens:Number(n.total_tokens||0)}}).filter(t=>t.name).sort((t,n)=>Number(n.total_tokens||0)-Number(t.total_tokens||0))}function b0(e){if(e?.key){const t=y(`dashboard.context_breakdown.message_details.${e.key}`);if(t&&!t.includes("dashboard.context_breakdown"))return t}return e?.name||""}function x0(e){return(Array.isArray(e)?e:[]).map(t=>{const n=t?.totals||{},a=Number(n.input_tokens||0),r=Number(n.output_tokens||0),s=Number(n.cached_input_tokens||0),l=Number(n.cache_creation_input_tokens||0);return{name:t?.name?String(t.name):"",calls:Number(t?.calls||0),failures:Number(t?.failures||0),duration_ms:Number(t?.duration_ms||0),max_duration_ms:Number(t?.max_duration_ms||0),output_chars:Number(t?.output_chars||0),output_lines:Number(t?.output_lines||0),totals:{input_tokens:a,output_tokens:r,cached_input_tokens:s,cache_creation_input_tokens:l,total_tokens:Number(n.total_tokens||a+r)}}}).filter(t=>t.name).sort((t,n)=>Number(n.totals.total_tokens||0)-Number(t.totals.total_tokens||0))}function wr(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"0ms":t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:`${Math.round(t/1e3)}s`}function k0(e,t){return e?t==="by_executable"?e.by_executable||[]:t==="by_command"?e.by_command||[]:t==="by_duration"?e.by_duration||[]:t==="by_output"?e.by_output||[]:t==="by_exit"?e.by_exit||[]:e.by_type||[]:[]}function vr(e){return e==="exec_command"||e==="Bash"}function zo(e){return e==="codex"?"dashboard.context_breakdown.empty_codex":"dashboard.context_breakdown.empty"}function w0(e){return e==="codex"?"dashboard.context_breakdown.error_codex":"dashboard.context_breakdown.error"}function v0(e){return e==="codex"?"dashboard.context_breakdown.footnote_codex":"dashboard.context_breakdown.footnote"}const N0=10;function ct({level:e=0,colorSquare:t=null,label:n,labelSuffix:a=null,labelTone:r="default",hasChevron:s=!1,open:l=!1,onToggle:i,tokens:c,percent:d=null,children:f,share:u=null,fillColor:h=null}){const g=r==="accent"?"text-oai-brand truncate":r==="muted"?"text-oai-gray-500 dark:text-oai-gray-400 truncate":r==="strong"?"font-medium text-oai-black dark:text-oai-white truncate":"text-oai-gray-700 dark:text-oai-gray-300 truncate",p=o.jsx("span",{className:"shrink-0 flex items-center justify-start",style:{width:N0},"aria-hidden":!t,children:t}),x=o.jsxs(o.Fragment,{children:[p,o.jsx("span",{className:g,children:n}),a,s&&o.jsx(ht.span,{animate:{rotate:l?90:0},transition:{duration:.15},className:"shrink-0 text-oai-gray-400 dark:text-oai-gray-500 flex items-center","aria-hidden":"true",children:o.jsx(Br,{size:11})})]}),v=h&&u!=null&&u>0,w=v?Math.max(0,Math.min(100,u)):0;return o.jsxs("li",{className:"min-w-0 group/row",children:[o.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:v?{backgroundImage:`linear-gradient(to right, ${h.replace(/\)\s*$/," / 0.10)")} 0%, ${h.replace(/\)\s*$/," / 0.10)")} ${w}%, transparent ${w}%)`}:void 0,children:[s?o.jsx("button",{type:"button",onClick:i,"aria-expanded":l,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:x}):o.jsx("div",{className:"relative flex items-center gap-1.5 min-w-0",children:x}),o.jsx("span",{className:"relative text-right tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:c||""}),o.jsx("span",{className:"relative text-right tabular-nums text-[10px] text-oai-gray-400 dark:text-oai-gray-500 font-normal",children:d||""})]}),s&&f?o.jsx(Hr,{initial:!1,children:l&&o.jsx(ht.div,{initial:o0,animate:s0,exit:i0,transition:r0,style:{overflow:"hidden"},children:f},"content")}):null]})}function Nr({execDetails:e,source:t="claude"}){const[n,a]=m.useState("by_type"),r=x0(k0(e,n)),s=t==="codex",l=s?"grid-cols-[minmax(0,1fr)_48px_48px_72px_72px_60px_60px]":"grid-cols-[minmax(0,1fr)_56px_60px]";return o.jsxs("div",{className:"mt-2 ml-4",children:[o.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:a0.map(([i,c])=>o.jsx("button",{type:"button",onClick:()=>a(i),className:"h-7 px-2 rounded-md text-[10px] font-medium transition-colors "+(n===i?"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:y(c)},i))}),r.length===0?o.jsx("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:"—"}):o.jsx("div",{className:"mt-2 overflow-x-auto",children:o.jsxs("div",{role:"table","aria-label":y("dashboard.context_breakdown.exec_details.title"),className:s?"min-w-[420px]":"min-w-[260px]",children:[o.jsxs("div",{role:"row",className:`grid ${l} 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:[o.jsx("span",{role:"columnheader",children:y("dashboard.context_breakdown.exec_details.kind_column")}),o.jsx("span",{role:"columnheader",className:"text-right",children:y("dashboard.context_breakdown.exec_details.calls_column")}),s&&o.jsxs(o.Fragment,{children:[o.jsx("span",{role:"columnheader",className:"text-right",children:y("dashboard.context_breakdown.exec_details.failures_column")}),o.jsx("span",{role:"columnheader",className:"text-right",children:y("dashboard.context_breakdown.exec_details.duration_column")}),o.jsx("span",{role:"columnheader",className:"text-right",children:y("dashboard.context_breakdown.exec_details.max_duration_column")})]}),o.jsx("span",{role:"columnheader",className:"text-right",children:y("dashboard.context_breakdown.tool_details.total_column")}),s&&o.jsx("span",{role:"columnheader",className:"text-right",children:y("dashboard.context_breakdown.exec_details.output_column")})]}),r.map((i,c)=>o.jsxs(ht.div,{role:"row",className:`grid ${l} gap-2 py-1.5`,title:i.name,initial:{opacity:0},animate:{opacity:1},transition:{duration:.18,delay:c*.02},children:[o.jsx("span",{role:"cell",className:"min-w-0 text-body-sm font-medium text-oai-black dark:text-oai-white truncate",children:i.name}),o.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ae(i.calls||0)}),s&&o.jsxs(o.Fragment,{children:[o.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ae(i.failures||0)}),o.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:wr(i.duration_ms||0)}),o.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:wr(i.max_duration_ms||0)})]}),o.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:at(i.totals.total_tokens||0)}),s&&o.jsx("span",{role:"cell",className:"text-right text-body-sm tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:Ae(i.output_lines||0)})]},i.name))]})})]})}function Xt({toolSet:e,execDetails:t,source:n,codexQueueFallback:a}){const[r,s]=m.useState({}),[l,i]=m.useState(!1),c=g0(e?.categories||[]);function d(f){s(u=>({...u,[f]:!u[f]}))}return c.length===0?o.jsx("p",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500 py-0.5",children:n==="codex"&&a?y("dashboard.context_breakdown.tool_details.unavailable_codex"):y(zo(n))}):o.jsx("ul",{className:"mt-0.5 mb-0.5 space-y-0.5",children:c.map(f=>{const u=f.toolCount>0,h=f.name==="Execution"&&t,g=h&&f.tools.some(x=>vr(x.name)),p=!!r[f.name];return o.jsxs(ct,{level:1,label:f.name,labelTone:"strong",hasChevron:u||h&&!g,open:p||h&&!g&&l,onToggle:()=>{u?d(f.name):h&&!g&&i(x=>!x)},tokens:at(f.totals.total_tokens||0),percent:null,children:[u&&o.jsx("ul",{className:"space-y-0.5",children:f.tools.map(x=>{const v=h&&vr(x.name);return o.jsx(ct,{level:2,label:x.name,labelTone:v?"accent":"default",hasChevron:v,open:l,onToggle:()=>i(w=>!w),tokens:at(x.total_tokens||0),percent:null,children:v&&o.jsx(Nr,{execDetails:t,source:n})},x.name)})}),h&&!g&&o.jsx(Nr,{execDetails:t,source:n})]},f.name)})})}function Bo({from:e,to:t,source:n="claude",referenceTotalTokens:a=null,onLoadingChange:r=null}){const[s,l]=m.useState(null),[i,c]=m.useState(!1),[d,f]=m.useState(null),[u,h]=m.useState({});function g(b){h(M=>({...M,[b]:!M[b]}))}if(m.useEffect(()=>{let b=!1;return c(!0),r?.(!0),f(null),bi({from:e,to:t,source:n,timeZone:Vr(),tzOffsetMinutes:Ur()}).then(M=>{b||l(M)}).catch(M=>{b||f(M?.message||String(M))}).finally(()=>{b||(c(!1),r?.(!1))}),()=>{b=!0}},[e,t,n]),i&&!s)return o.jsxs("div",{children:[o.jsx("div",{className:"h-1 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden animate-pulse"}),o.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(b=>o.jsx("div",{className:"h-3 rounded bg-oai-gray-100 dark:bg-oai-gray-800 animate-pulse",style:{animationDelay:`${b*80}ms`}},b))}),o.jsx("p",{className:"mt-3 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:y("dashboard.context_breakdown.loading_hint")})]});if(d)return o.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:y(w0(n))});if(!s||s.scope!=="supported"||!s.totals?.total_tokens)return o.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:y(zo(n))});const p=n==="claude"?d0(s.categories||[],a):u0(s,a),x=s.tool_calls_breakdown||null,v=s.skills_breakdown||null,w=s.message_breakdown||null,_=s.configured_resources||null,k=s.exec_command_breakdown||null,N=p0(v?.skills||[]),D=y0(w?.categories||[]),j=n==="codex"&&(s?.breakdown_status==="queue_fallback"||s?.fallback==="queue_totals"),L=n==="claude"?x?.tool_calls||null:x||null,{mcpSet:P,residualSet:C,mcpTotalTokens:I}=f0(L),K=n==="claude"&&x?.subagents||null,V=K?.categories?.length>0||(_?.custom_agents_count||0)>0,$=n==="claude"?(C?.categories||[]).reduce((b,M)=>b+Number(M?.totals?.total_tokens||0),0):0,E=n==="claude"?(K?.categories||[]).reduce((b,M)=>b+Number(M?.totals?.total_tokens||0),0):0,T=[...p].sort((b,M)=>(M.totals?.total_tokens||0)-(b.totals?.total_tokens||0));return o.jsxs("div",{role:"region","aria-label":y("dashboard.context_breakdown.bar_aria",{summary:p.filter(b=>b.percent>0).filter(b=>!(n==="claude"&&(b.key==="tool_calls"||b.key==="custom_agents"))).map(b=>`${kr(b.key)} ${b.percent}%`).join(",")}),children:[o.jsxs("ul",{className:"space-y-0.5",children:[T.map(b=>{const M=b.key==="system_prompt",H=b.key==="messages",S=b.key==="tool_calls",X=b.key==="custom_agents";if(b.key,n==="claude"&&(S||X))return null;const F=H&&D.length>0||S&&(C?.categories?.length>0||j)||X&&V&&K,z=!!u[b.key],B=t0(b.key,n),Z=o.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0",style:{backgroundColor:B},"aria-hidden":"true"}),xe=M?o.jsxs("span",{className:"relative inline-flex shrink-0 group",children:[o.jsx(ca,{size:11,className:"text-oai-gray-400 dark:text-oai-gray-500 cursor-help","aria-hidden":"true"}),o.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:y("dashboard.context_breakdown.system_prefix_tooltip")})]}):null,je=b.percent>0?`${b.percent.toFixed(b.percent<.1&&b.percent>0?2:1)}%`:"0.0%";return o.jsxs(ct,{level:0,colorSquare:Z,label:kr(b.key),labelSuffix:xe,tokens:at(b.totals?.total_tokens||0),percent:je,hasChevron:F,open:z,onToggle:()=>g(b.key),share:b.percent,fillColor:B,children:[H&&o.jsx("ul",{className:"space-y-0.5",children:D.map(Me=>o.jsx(ct,{level:1,label:b0(Me),tokens:at(Me.totals.total_tokens||0),percent:null},Me.key||Me.name))}),S&&C&&o.jsx(Xt,{toolSet:C,execDetails:k,source:n,codexQueueFallback:j}),S&&j&&!C&&o.jsx("p",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500 py-0.5",children:y("dashboard.context_breakdown.tool_details.unavailable_codex")}),X&&K&&o.jsx(Xt,{toolSet:K,execDetails:null,source:n,codexQueueFallback:!1})]},b.key)}),n==="claude"&&C?.categories?.length>0&&o.jsx(ct,{level:0,colorSquare:o.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:y("dashboard.context_breakdown.category.tool_calls"),tokens:at($),percent:null,hasChevron:!0,open:!!u.tool_calls_aux,onToggle:()=>g("tool_calls_aux"),children:o.jsx(Xt,{toolSet:C,execDetails:k,source:n,codexQueueFallback:!1})}),n==="claude"&&K?.categories?.length>0&&o.jsx(ct,{level:0,colorSquare:o.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:y("dashboard.context_breakdown.category.custom_agents"),tokens:at(E),percent:null,hasChevron:!0,open:!!u.custom_agents_aux,onToggle:()=>g("custom_agents_aux"),children:o.jsx(Xt,{toolSet:K,execDetails:null,source:n,codexQueueFallback:!1})}),P?.categories?.length>0&&o.jsx(ct,{level:0,colorSquare:o.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:y("dashboard.context_breakdown.category.mcp_servers"),tokens:at(I),percent:null,hasChevron:!0,open:!!u.mcp_servers,onToggle:()=>g("mcp_servers"),children:o.jsx(Xt,{toolSet:P,execDetails:null,source:n,codexQueueFallback:!1})}),N.length>0&&o.jsx(ct,{level:0,colorSquare:o.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0 bg-oai-gray-300 dark:bg-oai-gray-600","aria-hidden":"true"}),label:y("dashboard.context_breakdown.category.skills"),tokens:at(N.reduce((b,M)=>b+(M.total_tokens||0),0)),percent:null,hasChevron:!0,open:!!u.skills,onToggle:()=>g("skills"),children:o.jsx("ul",{className:"space-y-0.5",children:N.slice(0,12).map(b=>o.jsx(ct,{level:1,label:b.name,tokens:at(b.total_tokens),percent:null},b.name))})})]}),o.jsx("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:y(v0(n))}),j?o.jsx("p",{className:"mt-2 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:y("dashboard.context_breakdown.tool_details.unavailable_codex")}):null,_?o.jsxs("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:[Ae(_.skills_count||0)," skills ·"," ",Ae(_.mcp_servers_count||0)," MCP servers ·"," ",Ae(_.custom_agents_count||0)," agents ·"," ",Ae(_.memory_files_count||0)," memory files"]}):null]})}function _r({fleetData:e=[],from:t,to:n,showInlineContext:a=!0,usageLimits:r=null,limitDisplayMode:s}){const l=Lt(),[i,c]=m.useState(null),{currency:d,rate:f}=Nt(),u=e.filter(va);return u.length===0?null:o.jsx(on,{children:o.jsxs("div",{className:"space-y-6",children:[o.jsx("div",{role:"img","aria-label":y("usage.overview.distribution_aria",{items:u.map(h=>y("usage.overview.distribution_item",{label:h.label,percent:h.totalPercent})).join(",")}),className:"h-1.5 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden flex",children:u.map((h,g)=>{const p=Vn(h.label,g);return o.jsx(ht.div,{initial:{width:0},animate:{width:`${h.totalPercent}%`},transition:{duration:.5,delay:.45+g*.04,ease:[.16,1,.3,1]},className:"h-full",style:{backgroundColor:p},title:`${h.label}: ${h.totalPercent}%`},h.label)})}),o.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-3",children:u.map((h,g)=>{const p=Vn(h.label,g),x=i===h.label,v=h.missingPricingModels?.length||0,w=!!v,_=Qh(h),k=Jh(h,_);return o.jsxs("button",{"aria-expanded":x,"aria-controls":`provider-details-${h.label}`,"aria-label":y("usage.overview.provider_card_aria",{provider:h.label,percent:h.totalPercent,tokens:ka(h.usage)||"0",cost:wa(h.usd,d,f)||`${ia(d)}0`,action:y(x?"usage.overview.collapse":"usage.overview.expand")}),onClick:()=>c(x?null:h.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:[o.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[o.jsx(la,{provider:h.label,size:15,color:p,className:"text-oai-gray-700 dark:text-oai-gray-300 shrink-0"}),o.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:h.label})]}),o.jsxs("div",{className:"text-lg font-semibold text-oai-black dark:text-oai-white tabular-nums",children:[h.totalPercent,"%"]}),o.jsx("div",{className:"mt-0.5 text-[11px] text-oai-gray-400 dark:text-oai-gray-400 tabular-nums",children:y("usage.overview.model_count",{count:h.models.length})}),o.jsx(xi,{label:h.label,usageLimits:r,mode:s}),o.jsxs("div",{className:"mt-2 space-y-1.5",children:[_.map(N=>{const D=Gh(N,h.topCostModel);return o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2 text-[10px] font-medium",children:[o.jsx("span",{className:`truncate ${D?"text-oai-black dark:text-oai-white":"text-oai-gray-600 dark:text-oai-gray-300"}`,title:N.name,children:Qt(N.name)}),o.jsx("span",{className:"shrink-0 text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:y("usage.overview.model_percent",{percent:N.share})})]}),o.jsx("div",{role:"progressbar","aria-label":y("usage.overview.model_chip",{model:Qt(N.name),percent:N.share}),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Number(N.share)||0,className:"mt-1 h-1.5 overflow-hidden rounded-full bg-oai-gray-100 dark:bg-oai-gray-800",children:o.jsx(ht.div,{initial:{width:0},animate:{width:Kh(N.share)},transition:{duration:l?0:.45,delay:l?0:.05,ease:[.16,1,.3,1]},className:"h-full rounded-full",style:{backgroundColor:D?p:`${p}99`}})})]},N.id||N.name)}),!!k&&o.jsx("div",{className:"text-[10px] font-medium text-oai-gray-400 dark:text-oai-gray-500",children:y("usage.overview.model_more",{count:k})})]}),h.topCostModel?.name?o.jsx("div",{className:"mt-1.5 truncate text-[10px] font-medium text-oai-gray-500 dark:text-oai-gray-400",children:y("usage.overview.provider_top_cost",{model:Qt(h.topCostModel.name)})}):null,w?o.jsx("div",{className:"mt-1.5 truncate text-[10px] font-semibold text-amber-700 dark:text-amber-300",children:y("usage.overview.provider_missing_pricing",{count:v})}):null]},h.label)})}),i&&o.jsx("div",{id:`provider-details-${i}`,role:"region","aria-label":y("usage.overview.model_details_aria",{provider:i}),className:"mt-2",children:u.filter(h=>h.label===i).map(h=>{const g=Vn(h.label,0),p=Jt(h),x=[...h.models].sort((_,k)=>(k.share||0)-(_.share||0)),v=!!p&&a,w=v?`${p==="claude"?"Claude":"Codex"} Context Breakdown`:h.label;return o.jsx(_0,{provider:h,color:g,providerHeading:w,contextSource:v?p:null,from:t,to:n,sortedModels:x},h.label)})})]})})}function _0({provider:e,color:t,providerHeading:n,contextSource:a,from:r,to:s,sortedModels:l}){const{currency:i,rate:c}=Nt(),[d,f]=m.useState(!1),u=String(e?.source||e?.label||"").trim().toLowerCase()==="antigravity";return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-1.5 mb-3",children:[o.jsx(la,{provider:e.label,size:14,color:t,className:"shrink-0"}),o.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:n}),a&&d&&o.jsx(Ti,{size:12,className:"text-oai-gray-400 dark:text-oai-gray-500 animate-spin shrink-0","aria-label":y("dashboard.context_breakdown.loading_aria")})]}),u&&o.jsxs("p",{className:"mb-3 text-[10px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",children:[o.jsxs("span",{className:"font-medium text-oai-gray-500 dark:text-oai-gray-400",children:[y("usage.overview.antigravity_notice_title"),"."]})," ",y("usage.overview.antigravity_notice_body")]}),a?o.jsx("div",{className:"mb-4 pb-4 border-b border-oai-gray-200 dark:border-oai-gray-700",children:o.jsx(Bo,{from:r,to:s,source:a,referenceTotalTokens:e.usage,onLoadingChange:f})}):null,o.jsx("div",{className:"space-y-3",children:l.map(h=>{const g=ka(h.usage),p=wa(h.cost,i,c),x=Math.max(0,Math.min(100,Number(h.share)||0));return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-baseline gap-4 mb-1.5",children:[o.jsx("span",{className:"flex-1 min-w-0 text-sm text-oai-gray-700 dark:text-oai-gray-300 truncate",title:h.name,children:h.name}),o.jsx("span",{className:"shrink-0 w-16 text-right text-sm text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:g}),o.jsx("span",{className:"shrink-0 w-16 text-right text-sm text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:p}),o.jsxs("span",{className:"shrink-0 w-12 text-right text-sm text-oai-black dark:text-oai-white tabular-nums",children:[h.share,"%"]})]}),o.jsx("div",{className:"h-[3px] bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden",role:"progressbar","aria-valuenow":x,"aria-valuemin":0,"aria-valuemax":100,children:o.jsx("div",{className:"h-full transition-[width] duration-500 ease-out",style:{width:`${x}%`,backgroundColor:t,opacity:.45}})})]},h.id||h.name)})})]})}const M0={claude:"Claude",codex:"Codex"};function j0({fleetData:e=[],from:t,to:n}){const a=e.filter(va).filter(i=>Jt(i)!==null);if(a.length===0)return null;const r=new Map;for(const i of a){const c=Jt(i),d=r.get(c);(!d||(Number(i.usage)||0)>(Number(d.usage)||0))&&r.set(c,i)}const s=Array.from(r.values()).sort((i,c)=>(Number(c.usage)||0)-(Number(i.usage)||0)),l=s.length>1;return o.jsx(on,{title:y("dashboard.context_breakdown.card_title"),children:o.jsx("div",{className:l?"grid grid-cols-1 lg:grid-cols-2 gap-x-8 gap-y-6":"",children:s.map(i=>{const c=Jt(i);return o.jsxs("div",{className:"min-w-0",children:[l?o.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2 border-b border-oai-gray-200 pb-2 dark:border-oai-gray-800",children:[o.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-oai-white",children:M0[c]??c}),o.jsx("span",{className:"text-xs font-medium tabular-nums text-oai-gray-500 dark:text-oai-gray-300",children:ka(i.usage)})]}):null,o.jsx(Bo,{from:t,to:n,source:c,referenceTotalTokens:i.usage})]},c)})})})}function S0(e){return e==="day"?"hourly":e==="total"?"monthly":"daily"}function C0(e){return!!e&&!e.missing&&!e.future}function D0(e){const t=e?.billable_total_tokens??e?.total_tokens??e?.value,n=Number(t);return Number.isFinite(n)&&n>=0?n:0}function T0(e){const t=e?.total_tokens??e?.billable_total_tokens??e?.value,n=Number(t);return Number.isFinite(n)&&n>=0?n:0}function P0(e){const t=Array.isArray(e)?e.filter(C0):[];let n=0,a=0,r=0,s=0,l=!1,i=0,c=-1,d=null;for(const f of t){const u=T0(f),h=D0(f);n+=u,a+=h;const g=Number(f?.conversation_count);Number.isFinite(g)&&g>0&&(r+=g);const p=Number(f?.total_cost_usd);Number.isFinite(p)&&(l=!0,s+=p),h>0&&(i+=1),h>c&&(c=h,d=f)}return{totalTokens:n,billableTokens:a,conversationCount:r,totalCostUsd:l?s:null,bucketCount:t.length,activeBuckets:i,peak:d&&c>0?{value:c,label:d.hour||d.day||d.month||""}:null}}function Mr(e){return String(e).padStart(2,"0")}function O0(e,t){if(!e)return"";if(t==="hourly"){const n=String(e.hour||e.label||""),a=/^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2})/.exec(n);if(!a)return n;const[,r,s,l]=a,c=Number(s)*60+Number(l)+30,d=Math.floor(c/60)%24,f=c%60;return`${r} ${s}:${l}–${Mr(d)}:${Mr(f)}`}return String(t==="monthly"?e.month||e.label||"":e.day||e.label||"")}function $0(e){if(!e||e.activeBuckets===0)return"trend.zoom.insight.empty";const t=e.totalTokens||0;return t<1e7?"trend.zoom.insight.calm":t<5e8?"trend.zoom.insight.steady":t<5e9?"trend.zoom.insight.heavy":"trend.zoom.insight.massive"}function W0(e,t){if(!e)return"";if(t==="hourly"){const r=/T(\d{2}:\d{2})/.exec(String(e.hour||e.label||""));return r?r[1]:""}if(t==="monthly")return String(e.month||e.label||"");const n=String(e.day||e.label||""),a=/^\d{4}-(\d{2}-\d{2})$/.exec(n);return a?a[1]:n}const E0=[{period:"day",labelKey:"trend.zoom.gran.30min"},{period:"month",labelKey:"trend.zoom.gran.day"},{period:"total",labelKey:"trend.zoom.gran.month"}],A0=24,Ft="#10b981";function jr(e){return e==="day"?"day":e==="total"?"total":"month"}function oa(e,t){const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(e||""));if(!n)return e;const a=new Date(Date.UTC(Number(n[1]),Number(n[2])-1,Number(n[3])));a.setUTCDate(a.getUTCDate()+t);const r=a.getUTCFullYear(),s=String(a.getUTCMonth()+1).padStart(2,"0"),l=String(a.getUTCDate()).padStart(2,"0");return`${r}-${s}-${l}`}function F0(e,t){const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(e||""));if(!n)return e;const a=new Date(Date.UTC(Number(n[1]),Number(n[2])-1+t,Number(n[3]))),r=a.getUTCFullYear(),s=String(a.getUTCMonth()+1).padStart(2,"0"),l=String(a.getUTCDate()).padStart(2,"0");return`${r}-${s}-${l}`}function R0(e,t){const n=/^(\d{4})-(\d{2})/.exec(String(e||"")),a=/^(\d{4})-(\d{2})/.exec(String(t||""));if(!n||!a)return A0;const r=Number(a[1])*12+Number(a[2])-(Number(n[1])*12+Number(n[2]))+1;return Math.max(1,r)}function Sr(e,t){return t?e==="total"?{from:F0(t,-23),to:t}:{from:oa(t,-29),to:t}:{from:null,to:null}}function I0(e){const t=/^\d{4}-(\d{2}-\d{2})T(\d{2}:\d{2})/.exec(String(e||""));return t?`${t[1]} ${t[2]}`:e||""}function yn({label:e,value:t,sub:n}){return o.jsxs("div",{className:"flex flex-col gap-1.5 group",children:[o.jsx("span",{className:"text-[9px] font-bold uppercase tracking-widest font-mono text-zinc-400 dark:text-zinc-500",children:e}),o.jsx("span",{className:"text-xl font-black font-mono text-zinc-900 dark:text-zinc-50 tracking-tight leading-none tabular-nums transition-transform duration-200 group-hover:-translate-y-[1px]",children:t}),n?o.jsx("span",{className:"text-[10px] font-bold text-zinc-400 dark:text-zinc-500 font-mono tabular-nums",children:n}):null]})}function L0({zoomConfig:e,period:t,from:n,to:a,timeZoneLabel:r,onClose:s,renderChart:l}){const{currency:i,rate:c}=Nt(),d=R.useMemo(()=>en({timeZone:e?.timeZone,offsetMinutes:e?.tzOffsetMinutes,date:e?.now||new Date})||a||n||null,[e?.timeZone,e?.tzOffsetMinutes,e?.now,a,n]),[f,u]=R.useState(()=>jr(t)),[h,g]=R.useState(d),[p,x]=R.useState(()=>Sr(jr(t),d)),[v,w]=R.useState(!1),[_,k]=R.useState(!1),[N,D]=R.useState(!1),j=d,L=S=>{u(S),S!=="day"&&x(Sr(S,d))},P=R.useMemo(()=>f==="day"?{from:h,to:h,months:void 0}:f==="total"?{from:void 0,to:p.to,months:R0(p.from,p.to)}:{from:p.from,to:p.to,months:void 0},[f,h,p]),{rows:C,from:I,to:K,loading:V}=Jr({...e,period:f,from:P.from,to:P.to,months:P.months}),$=R.useMemo(()=>P0(C),[C]),E=R.useCallback(()=>D(!0),[]),T=S=>{S.target===S.currentTarget&&N&&s()};if(R.useEffect(()=>{const S=X=>{X.key==="Escape"&&E()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[E]),typeof document>"u")return null;const b=f==="day"&&!!h,M=f==="day"&&!!h&&(!j||h<j),H=$.totalCostUsd!=null?et($.totalCostUsd,{currency:i,rate:c}):null;return o.jsxs("div",{onAnimationEnd:T,onClick:S=>{S.target===S.currentTarget&&E()},className:Xe("fixed inset-0 z-50 flex items-center justify-center p-3 md:p-6 backdrop-blur-md bg-black/15 dark:bg-black/40",N?"animate-tt-fade-out":"animate-tt-fade-in"),children:[o.jsx("style",{children:`
|
|
43
43
|
@keyframes tt-fade-in { from { opacity: 0; } to { opacity: 1; } }
|
|
44
44
|
@keyframes tt-fade-out { from { opacity: 1; } to { opacity: 0; } }
|
|
45
45
|
@keyframes tt-modal-entrance {
|
|
@@ -57,4 +57,4 @@ import{c as nn,i as Vs,f as Ar,a as Fr,J as qs,u as Rr,m as Xs,r as m,M as Ir,b
|
|
|
57
57
|
@media (prefers-reduced-motion: reduce) {
|
|
58
58
|
.animate-tt-fade-in, .animate-tt-fade-out, .animate-tt-modal, .animate-tt-modal-exit { animation: none; }
|
|
59
59
|
}
|
|
60
|
-
`}),o.jsxs("div",{className:Xe("relative w-full max-w-6xl h-[88vh] backdrop-blur-2xl bg-white/90 dark:bg-oai-gray-900/90 border border-oai-gray-200/50 dark:border-white/10 shadow-2xl rounded-2xl flex flex-col md:flex-row overflow-hidden",M?"animate-tt-modal-exit":"animate-tt-modal"),children:[o.jsx("button",{type:"button",onClick:E,"aria-label":y("trend.zoom.close_aria"),className:"absolute top-4 right-4 z-50 p-2 rounded-full border border-oai-gray-200/60 dark:border-oai-gray-800/60 bg-white/50 dark:bg-oai-gray-900/50 text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white hover:rotate-90 hover:scale-105 active:scale-95 transition-all duration-300",children:o.jsx(sa,{size:16})}),o.jsxs("div",{className:"w-full md:w-[320px] shrink-0 border-b md:border-b-0 md:border-r border-zinc-200/50 dark:border-zinc-800/40 p-5 md:p-6 flex flex-col gap-6 overflow-y-auto backdrop-blur-md bg-zinc-50/50 dark:bg-zinc-950/50",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[o.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[o.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:Ft}}),o.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5",style:{backgroundColor:Ft}})]}),o.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono text-zinc-400 dark:text-zinc-500",children:y("trend.zoom.badge")})]}),o.jsx("h4",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight leading-none mt-2 select-none",children:y("trend.monitor.label")}),r?o.jsx("p",{className:"text-[10px] text-zinc-400 dark:text-zinc-500 mt-1.5 font-mono select-none",children:r}):null,o.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-400 dark:text-zinc-500 mt-2 font-normal select-none",children:y("trend.zoom.desc")})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-x-5 gap-y-5 border-y border-zinc-200/50 dark:border-zinc-800/50 py-5 select-none",children:[o.jsx(yn,{label:y("trend.zoom.stats.tokens"),value:Ae($.totalTokens)}),H?o.jsx(yn,{label:y("trend.zoom.stats.cost"),value:H}):null,o.jsx(yn,{label:y("trend.zoom.stats.conversations"),value:$.conversationCount.toLocaleString()}),$.peak?o.jsx(yn,{label:y("trend.zoom.stats.peak"),value:Ae($.peak.value),sub:A0($.peak.label)}):null]}),o.jsxs("div",{className:"flex flex-col gap-2 select-none",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(Kr,{size:11,style:{color:Ft}}),o.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono",style:{color:Ft},children:y("trend.zoom.insight_badge")})]}),o.jsxs("div",{className:"pl-3.5 border-l-2 relative",style:{borderColor:Ft},children:[o.jsx("div",{className:"absolute inset-y-0 left-0 w-[3px] blur-[2px] opacity-15 pointer-events-none rounded-full",style:{backgroundColor:Ft}}),o.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-600 dark:text-zinc-400 font-normal",children:y(T0($),{active:$.activeBuckets,peak:Ae($.peak?.value||0)})})]})]})]}),o.jsxs("div",{className:"flex-1 min-w-0 flex flex-col p-5 md:p-6 overflow-y-auto",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3 mb-6 pr-10",children:[o.jsx("div",{role:"tablist","aria-label":y("trend.zoom.gran.aria"),className:"flex rounded-md border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 text-[11px]",children:O0.map(S=>o.jsx("button",{type:"button",role:"tab","aria-selected":d===S.period,onClick:()=>L(S.period),className:Xe("px-2.5 py-1 rounded transition-colors",d===S.period?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-oai-white font-medium":"text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200"),children:y(S.labelKey)},S.period))}),d==="day"?o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("button",{type:"button",onClick:()=>b&&g(S=>oa(S,-1)),disabled:!b,"aria-label":y("trend.zoom.prev_day"),className:"p-1 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 disabled:opacity-30 disabled:pointer-events-none transition-colors",children:o.jsx(ai,{size:16})}),o.jsxs(Qn,{open:v,onOpenChange:w,children:[o.jsx(Jn,{"aria-label":y("trend.zoom.pick_day"),className:"text-[12px] font-medium text-oai-gray-700 dark:text-oai-gray-200 tabular-nums min-w-[100px] text-center px-2 py-0.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:h||"—"}),o.jsx(Zn,{children:o.jsx(ea,{sideOffset:8,side:"bottom",align:"center",className:"!z-[9999]",children:o.jsx(ta,{className:"bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded-xl shadow-lg",children:o.jsx(ra,{from:h,to:h,onApply:S=>{S&&g(S),w(!1)},onCancel:()=>w(!1)})})})})]}),o.jsx("button",{type:"button",onClick:()=>_&&g(S=>oa(S,1)),disabled:!_,"aria-label":y("trend.zoom.next_day"),className:"p-1 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 disabled:opacity-30 disabled:pointer-events-none transition-colors",children:o.jsx(Br,{size:16})})]}):o.jsxs(Qn,{open:N,onOpenChange:x,children:[o.jsx(Jn,{"aria-label":y("trend.zoom.pick_range"),className:"text-xs font-medium text-oai-gray-600 dark:text-oai-gray-300 tabular-nums px-2.5 py-1 rounded-md border border-oai-gray-200 dark:border-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors select-none",children:p.from&&p.to?p.from===p.to?p.from:`${p.from} → ${p.to}`:"—"}),o.jsx(Zn,{children:o.jsx(ea,{sideOffset:8,side:"bottom",align:"end",className:"!z-[9999]",children:o.jsx(ta,{className:"bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded-xl shadow-lg",children:o.jsx(ra,{from:p.from,to:p.to,onApply:(S,X)=>{S&&k({from:S,to:X||S}),x(!1)},onCancel:()=>x(!1)})})})})]})]}),o.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:V&&(!C||C.length===0)?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx("p",{className:"text-sm text-oai-gray-400 dark:text-oai-gray-400",children:y("trend.zoom.loading")})}):l({rows:C,from:I,to:K,period:d,timeZoneLabel:r})})]})]})]})}function Cr(e,t){if(!Array.isArray(e)||e.length===0)return 0;if(e.length===1)return e[0];const n=(e.length-1)*t,a=Math.floor(n),r=Math.ceil(n);if(a===r)return e[a];const s=n-a;return e[a]+(e[r]-e[a])*s}function R0(e){const t=Array.isArray(e)?e.filter(r=>Number.isFinite(r)&&r>0).sort((r,s)=>r-s):[];if(t.length===0)return{rawMax:0,effectiveMax:1,clippedValues:Array.isArray(e)?e.map(()=>0):[]};const n=t.at(-1)??0;let a=n;if(t.length>=4){const r=Cr(t,.25),s=Cr(t,.75),l=Math.max(s-r,0),i=s+l*1.5;n>i&&(a=Math.max(i,s,1))}return{rawMax:n,effectiveMax:Math.max(a,1),clippedValues:Array.isArray(e)?e.map(r=>!Number.isFinite(r)||r<=0?0:Math.min(r,Math.max(a,1))):[]}}const Dr=["#f472b6","#38bdf8","#34d399","#fbbf24","#a78bfa","#fb7185","#2dd4bf","#f97316","#6366f1","#ec4899","#14b8a6","#f59e0b"],Ho={Input:"#38bdf8","Cached Input":"#14b8a6",Output:"#a78bfa","Reasoning Output":"#fb7185"},I0={codex:"#3b82f6",gpt:"#10b981",openai:"#10b981",claude:"#d97757",anthropic:"#d97757",gemini:"#2196f3",google:"#2196f3",kimi:"#a78bfa",moonshot:"#a78bfa",opencode:"#f59e0b",deepseek:"#f59e0b",droid:"#ef4444",kilo:"#facc15"};function Uo(e){const t=e.toLowerCase();for(const[r,s]of Object.entries(I0))if(t.includes(r))return s;let n=0;for(let r=0;r<e.length;r++)n=e.charCodeAt(r)+((n<<5)-n);const a=Math.abs(n)%Dr.length;return Dr[a]}function L0(e){if(!e)return[];const t=[];if(e.models&&typeof e.models=="object")for(const[n,a]of Object.entries(e.models)){const r=Number(a);Number.isFinite(r)&&r>0&&t.push({type:"model",name:n,value:r})}if(t.length===0){const n=[{name:"Input",key:"input_tokens"},{name:"Cached Input",key:"cached_input_tokens"},{name:"Output",key:"output_tokens"},{name:"Reasoning Output",key:"reasoning_output_tokens"}];for(const a of n){const r=Number(e[a.key]);Number.isFinite(r)&&r>0&&t.push({type:"token_type",name:a.name,value:r})}}return t.sort((n,a)=>a.value-n.value)}function Y0(e,t){return e?.future?"predicted":e?.missing?"unsynced":t>0?"real":"real_zero"}const z0=.35,Tr=2,Pr=4;function B0({value:e,displayValue:t,scale:n,index:a,row:r,totalBars:s,onMouseEnter:l,onMouseLeave:i}){const c=Lt(),u=Y0(r,e),d=u==="predicted"||u==="unsynced",f=n.effectiveMax>0?t/n.effectiveMax*100:0;let h,g;u==="real"?(h=`${Math.max(f,2)}%`,g=`${Pr}px`):d&&f>0?(h=`${f}%`,g=`${Pr}px`):(h=`${Tr}px`,g=`${Tr}px`);const p=u==="real"?L0(r):[],k=p.reduce((w,N)=>w+N.value,0),v=u!=="real"||k<=0;return o.jsxs(ht.div,{className:"group relative flex-1 self-stretch",initial:{opacity:0,scaleY:0},animate:{opacity:1,scaleY:1},transition:{duration:c?0:.3,delay:c?0:.4+a*.008,ease:[.16,1,.3,1]},style:{originY:1},onMouseEnter:w=>l(w,r,e,p,u,t),onMouseLeave:i,children:[o.jsx("div",{className:"absolute inset-x-0 top-0 bottom-0 bg-oai-gray-100/70 dark:bg-white/[0.08] opacity-0 group-hover:opacity-100 transition-opacity duration-150 pointer-events-none"}),o.jsx("div",{className:"absolute inset-x-0 bottom-0 flex flex-col-reverse justify-start overflow-hidden rounded-t-[3px] cursor-pointer transition-all duration-200",style:{height:h,minHeight:g},children:v?o.jsx("div",{"data-trend-bar":"true",className:Xe("h-full w-full group-hover:brightness-110 transition-all",u==="real"?"":"bg-oai-gray-100 dark:bg-oai-gray-800"),style:{opacity:d?z0:1,background:u==="real"?"#10b981":void 0}}):p.map((w,N)=>{const x=w.type==="token_type"?Ho[w.name]:Uo(w.name),M=`${w.value/k*100}%`;return o.jsx("div",{"data-trend-bar":N===0?"true":void 0,className:"w-full group-hover:brightness-110 transition-all",style:{height:M,background:x}},N)})})]})}function H0(e){if(e?.missing||e?.future)return null;const t=e?.billable_total_tokens??e?.total_tokens??e?.value;if(t==null)return null;const n=Number(t);return Number.isFinite(n)&&n>=0?n:null}const Or=.98;function U0(e){if(!Array.isArray(e))return[];const t=new Array(e.length);for(let n=0;n<e.length;n++){if(e[n]!==null){t[n]=e[n];continue}let a=null,r=-1;for(let i=n-1;i>=0;i--)if(e[i]!==null){a=e[i],r=i;break}let s=null,l=-1;for(let i=n+1;i<e.length;i++)if(e[i]!==null){s=e[i],l=i;break}if(a!==null&&s!==null){const i=(n-r)/(l-r);t[n]=a+(s-a)*i}else if(a!==null){let i=0,c=0;for(let d=0;d<=r;d++)e[d]!==null&&(i+=e[d],c+=1);const u=c>0?i/c:a;t[n]=u*Math.pow(Or,n-r)}else if(s!==null){let i=0,c=0;for(let d=l;d<e.length;d++)e[d]!==null&&(i+=e[d],c+=1);const u=c>0?i/c:s;t[n]=u*Math.pow(Or,l-n)}else t[n]=0}return t}function Vo({rows:e,from:t,to:n,period:a,timeZoneLabel:r,showTimeZoneLabel:s=!0,className:l="",embedded:i=!1,chartHeightClass:c="h-40",isZoom:u=!1,zoomConfig:d=null}){const f=R.useMemo(()=>Array.isArray(e)&&e.length?e:[],[e]),{rawValues:h,seriesValues:g,scale:p,interpolatedValues:k}=R.useMemo(()=>{const $=f.map(H0),E=$.map(D=>D??0);return{rawValues:$,seriesValues:E,scale:R0(E),interpolatedValues:U0($)}},[f]),{currency:v,rate:w}=_t(),N=_0(a),[x,M]=R.useState(null),[T,j]=R.useState({x:0,y:0,shiftX:0,flipDown:!1}),[L,P]=R.useState(!1),C=R.useRef(null),I=R.useRef(null),K=($,E,D,b,_,H)=>{I.current&&(clearTimeout(I.current),I.current=null);const S=u?D0(E,N):E?.day||E?.hour||E?.month||"";M({row:E,value:D,segments:b,timeLabel:S,kind:_,displayValue:H});const X=$.currentTarget.querySelector('[data-trend-bar="true"]'),F=X&&X.parentElement?X.parentElement.getBoundingClientRect():$.currentTarget.getBoundingClientRect(),z=C.current;if(!z)return;const B=z.getBoundingClientRect(),Z=F.left-B.left+F.width/2,xe=F.top-B.top,je=140;let Me=0;Z<je?Me=je-Z:Z>B.width-je&&(Me=B.width-je-Z);const Se=96+(u?22:0)+(b.length?Math.min(b.length*30+24,174):0),J=xe<Se+12;j({x:Z,y:xe,shiftX:Me,flipDown:J})},V=()=>{I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{M(null)},150)};return o.jsxs("div",{ref:C,className:Xe("relative",!i&&"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5",u&&"flex h-full flex-col",l),children:[!i&&o.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:y("trend.monitor.label")}),s&&r&&o.jsx("p",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:r})]}),d&&o.jsx("button",{type:"button",onClick:()=>P(!0),"aria-label":y("trend.zoom.open_aria"),title:y("trend.zoom.open_aria"),className:"shrink-0 p-1.5 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 transition-colors",children:o.jsx(Xr,{size:14})})]}),o.jsxs("div",{className:Xe("space-y-3",u&&"flex flex-1 flex-col min-h-0 !space-y-0 gap-3"),children:[o.jsxs("div",{className:Xe("flex gap-2",u&&"flex-1 min-h-0"),children:[o.jsx("div",{className:"flex shrink-0 flex-col justify-between text-right text-[10px] leading-none text-oai-gray-400 dark:text-oai-gray-500 tabular-nums",children:[1,.75,.5,.25,0].map($=>o.jsx("span",{children:$===0?"0":Ae(p.effectiveMax*$,{decimals:0})},$))}),o.jsxs("div",{className:Xe("relative min-w-0 flex-1",u&&"min-h-0"),children:[o.jsx("div",{className:"absolute inset-0 flex flex-col justify-between pointer-events-none",children:[0,25,50,75,100].map($=>o.jsx("div",{className:"w-full border-t border-oai-gray-100 dark:border-oai-gray-800",style:{top:`${100-$}%`}},$))}),o.jsx("div",{className:Xe("flex items-end gap-0.5 relative z-0",c),children:g.length>0?g.map(($,E)=>{const D=f[E],_=D?.missing||D?.future?Math.min(k[E]??0,p.effectiveMax):p.clippedValues[E]??0;return o.jsx(B0,{value:$,displayValue:_,scale:p,index:E,row:D,totalBars:g.length,onMouseEnter:K,onMouseLeave:V},E)}):o.jsx("div",{className:"flex-1 h-full flex items-center justify-center",children:o.jsx("p",{className:"text-sm text-oai-gray-400 dark:text-oai-gray-400",children:"No data yet"})})})]})]}),u&&g.length>0&&o.jsx("div",{className:"flex gap-0.5 select-none",children:f.map(($,E)=>{const D=g.length-1,b=Math.max(1,Math.ceil(g.length/8)),_=E%b===0||E===D,H=E===0?"justify-start":E===D?"justify-end":"justify-center";return o.jsx("div",{className:Xe("flex-1 min-w-0 flex",H),children:_&&o.jsx("span",{className:"text-[9px] text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap font-mono",children:P0($,N)})},E)})}),t&&n&&o.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:[o.jsx("span",{children:t===n?`${t} 00:00`:t}),o.jsx("span",{children:t===n?`${n} 24:00`:n})]})]}),x&&o.jsxs("div",{className:"absolute z-[9999] w-0 h-0 transition-all duration-100 ease-out pointer-events-none",style:{left:`${T.x}px`,top:`${T.y}px`},children:[o.jsxs("div",{className:Xe("absolute left-0 backdrop-blur-md bg-white/95 dark:bg-oai-gray-900/95 border border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-xl rounded-xl p-3.5 max-w-[280px] min-w-[220px] flex flex-col gap-2 animate-in fade-in zoom-in-95 duration-100",T.flipDown?"top-[10px]":"bottom-[10px]"),style:{transform:`translateX(calc(-50% + ${T.shiftX}px))`},children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-oai-gray-100 dark:border-oai-gray-800/80 pb-1.5",children:[o.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400",children:x.timeLabel}),x.kind==="predicted"&&o.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500",children:"Predicted"}),x.kind==="unsynced"&&o.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500",children:"Unsynced"})]}),o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsxs("div",{className:"flex items-baseline gap-1",children:[o.jsx("span",{className:"text-lg font-bold text-oai-gray-900 dark:text-white leading-none",children:x.kind==="predicted"||x.kind==="unsynced"?`~${Math.round(x.displayValue??0).toLocaleString()}`:x.value.toLocaleString()}),o.jsx("span",{className:"text-[10px] text-oai-gray-400 uppercase tracking-wider font-semibold",children:"Tokens"})]}),u&&(x.row?.total_cost_usd!=null||Number(x.row?.conversation_count)>0)&&o.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:[x.row?.total_cost_usd!=null&&o.jsxs("span",{children:[o.jsx("span",{className:"font-semibold text-oai-gray-700 dark:text-oai-gray-200",children:et(x.row.total_cost_usd,{currency:v,rate:w})})," ",y("trend.zoom.tooltip.cost")]}),Number(x.row?.conversation_count)>0&&o.jsxs("span",{children:[o.jsx("span",{className:"font-semibold text-oai-gray-700 dark:text-oai-gray-200",children:Number(x.row.conversation_count).toLocaleString()})," ",y("trend.zoom.tooltip.conversations")]})]}),x.segments&&x.segments.length>0?o.jsxs("div",{className:"mt-1.5 border-t border-oai-gray-100 dark:border-oai-gray-800/60 pt-2 flex flex-col gap-1.5",children:[o.jsx("div",{className:"text-[10px] font-semibold text-oai-gray-400 dark:text-oai-gray-500 uppercase tracking-wider",children:x.segments[0].type==="model"?"Model Breakdown":"Token Breakdown"}),o.jsx("div",{className:"flex flex-col gap-2 max-h-[150px] overflow-y-auto pr-1.5 oai-scrollbar",children:x.segments.map(({name:$,value:E,type:D})=>{const b=x.value||1,_=Math.round(E/b*100),H=D==="token_type"?Ho[$]:Uo($);return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center justify-between text-[11px] gap-3",children:[o.jsx("span",{className:"font-medium text-oai-gray-750 dark:text-oai-gray-200 truncate max-w-[130px]",title:$,children:$}),o.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[o.jsx("span",{className:"font-mono text-oai-gray-900 dark:text-oai-gray-100 font-semibold",children:E.toLocaleString()}),o.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[_,"%"]})]})]}),o.jsx("div",{className:"w-full h-1 bg-oai-gray-100 dark:bg-oai-gray-800/85 rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${_}%`,backgroundColor:H,boxShadow:`0 0 4px ${H}55`}})})]},$)})})]}):null]})]}),o.jsx("div",{className:Xe("absolute left-0 -translate-x-1/2 w-2.5 h-2.5 rotate-45 bg-white dark:bg-oai-gray-900 border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-sm",T.flipDown?"top-[6px] border-l border-t":"bottom-[6px] border-r border-b"),style:T.flipDown?{marginTop:"1px"}:{marginBottom:"1px"}})]}),L&&d&&o.jsx(F0,{zoomConfig:d,period:a,from:t,to:n,timeZoneLabel:r,onClose:()=>P(!1),renderChart:$=>o.jsx(Vo,{embedded:!0,isZoom:!0,chartHeightClass:"h-full",...$})})]})}const $r="widgetOnboardingDismissed",Wr="tokentracker_native_app",V0=(()=>{try{return new URLSearchParams(window.location.search).get("app")==="1"?(localStorage.setItem(Wr,"1"),!0):localStorage.getItem(Wr)==="1"}catch{return!1}})();function q0({enterDelay:e=0}){const[t,n]=m.useState(()=>{try{return localStorage.getItem($r)==="1"}catch{return!1}}),a=m.useCallback(()=>{n(!0);try{localStorage.setItem($r,"1")}catch{}},[]);return!V0||ri()?null:o.jsx(Hr,{initial:!1,children:!t&&o.jsxs(ht.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:e,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:[o.jsx("button",{type:"button",onClick:a,"aria-label":y("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:o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:o.jsx("path",{d:"M4 4l6 6m0-6L4 10",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}),o.jsx("div",{className:"rounded-lg overflow-hidden ring-1 ring-black/5 dark:ring-white/10 shadow-sm",children:o.jsx("img",{src:"/widgets-overview.png",alt:y("dashboard.widgets.title"),width:734,height:552,className:"w-full h-auto block",loading:"lazy",decoding:"async"})}),o.jsxs("div",{className:"mt-4",children:[o.jsx("div",{className:"text-sm font-medium tracking-tight text-oai-gray-900 dark:text-oai-white",children:y("dashboard.widgets.title")}),o.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1 leading-snug",children:y("dashboard.widgets.hint")})]})]},"widget-onboarding-card")})}function X0(e){const{copy:t,screenshotMode:n,screenshotTitleLine1:a,screenshotTitleLine2:r,identityDisplayName:s,identityStartDate:l,activeDays:i,identitySubscriptions:c,identityScrambleDurationMs:u,projectUsageEntries:d,projectUsageLimit:f,setProjectUsageLimit:h,pulse:g,pulseComparedAtLabel:p,isLocalMode:k,trendRowsForDisplay:v,trendFromForDisplay:w,trendToForDisplay:N,trendZoomConfig:x,usageFrom:M,usageTo:T,period:j,trendTimeZoneLabel:L,activityHeatmapBlock:P,periodsForDisplay:C,setSelectedPeriod:I,autoRefreshOptions:K,autoRefreshIntervalMs:V,onAutoRefreshIntervalChange:$,customFrom:E,customTo:D,onCustomRangeApply:b,customRangeOpen:_,onCustomRangeOpenChange:H,summaryLabel:S,summaryValue:X,summaryUpdatedAtLabel:F,summaryCostValue:z,usageInsights:B,costInfoEnabled:Z,openCostModal:xe,costModalOpen:je,closeCostModal:Me,allowBreakdownToggle:Se,refreshAll:J,usageLoadingState:De,dataHealthMessage:le,fleetData:de,hasDetailsActual:W,dailyEmptyPrefix:te,installSyncCmd:ge,dailyEmptySuffix:me,detailsColumns:Ne,ariaSortFor:Fe,toggleSort:Te,sortIconFor:A,pagedDetails:Y,dailyBreakdownRows:U,dailyBreakdownColumns:q,dailyBreakdownAriaSortFor:ne,dailyBreakdownSortIconFor:oe,dailyBreakdownDateKey:ye,detailsDateKey:fe,renderDetailDate:he,renderDailyBreakdownDate:Pe,renderDetailCell:pe,DETAILS_PAGED_PERIODS:We,detailsPageCount:Ee,detailsPage:Be,setDetailsPage:Mt}=e,gt=null,yt=null,tt=Array.isArray(de)&&de.some(pt=>va(pt)&&Qt(pt)!==null);return o.jsxs(o.Fragment,{children:[o.jsx(Bi,{bare:!n,hideHeader:n,header:gt,footer:n?null:yt,className:n?"screenshot-mode":"",children:n?o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsx("div",{className:"flex items-start justify-between gap-4",children:o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:"text-3xl md:text-4xl font-semibold text-oai-black dark:text-oai-white tracking-tight leading-none",children:a}),o.jsx("span",{className:"text-2xl md:text-3xl font-semibold text-oai-black dark:text-oai-white tracking-tight leading-none",children:r})]})}),o.jsx(yr,{period:j,periods:C,onPeriodChange:I,autoRefreshOptions:K,autoRefreshIntervalMs:V,onAutoRefreshIntervalChange:$,summaryLabel:S,summaryValue:X,summaryUpdatedAtLabel:F,summaryCostValue:z,usageInsights:B,onCostInfo:Z?xe:null,onRefresh:n?null:J,loading:De,customFrom:E,customTo:D,onCustomRangeApply:b,customRangeOpen:_,onCustomRangeOpenChange:H}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-6 gap-4",children:[o.jsx("div",{className:"lg:col-span-2 min-w-0",children:o.jsx(Ja,{rankLabel:l??t("identity_card.rank_placeholder"),streakDays:i,subscriptions:c})}),P?o.jsx("div",{className:"lg:col-span-4 min-w-0",children:P}):null,o.jsx("div",{className:"lg:col-span-6 min-w-0",children:o.jsx(_r,{fleetData:de,from:M,to:T})})]})]}):o.jsxs("div",{className:"flex flex-col gap-4",children:[le?o.jsx(xt,{delay:.08,children:o.jsx("div",{className:"rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 py-3 text-sm text-oai-gray-700 dark:border-oai-gray-800 dark:bg-oai-gray-900/70 dark:text-oai-gray-300",children:le})}):null,o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-6 gap-4",children:[o.jsx("div",{className:"lg:col-span-3 min-w-0",children:o.jsx(xt,{delay:.05,className:"h-full",children:o.jsx(yr,{period:j,periods:C,onPeriodChange:I,autoRefreshOptions:K,autoRefreshIntervalMs:V,onAutoRefreshIntervalChange:$,summaryLabel:S,summaryValue:X,summaryUpdatedAtLabel:F,summaryCostValue:z,usageInsights:B,onCostInfo:Z?xe:null,onRefresh:n?null:J,loading:De,customFrom:E,customTo:D,onCustomRangeApply:b,customRangeOpen:_,onCustomRangeOpenChange:H,emphasized:!0})})}),o.jsx("div",{className:"lg:col-span-3 min-w-0",children:o.jsx(xt,{delay:.09,children:o.jsx(Vo,{rows:v,from:w,to:N,period:j,timeZoneLabel:L,showTimeZoneLabel:!1,zoomConfig:x})})}),o.jsx("div",{className:"lg:col-span-2 min-w-0",children:o.jsx(xt,{delay:.13,children:o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsx(Oc,{pulse:g,period:j,comparedAtLabel:p}),o.jsx(Ja,{rankLabel:l??t("identity_card.rank_placeholder"),streakDays:i,subscriptions:c})]})})}),o.jsx("div",{className:"lg:col-span-4 min-w-0",children:o.jsx(xt,{delay:.19,children:o.jsx(_r,{fleetData:de,from:M,to:T,showInlineContext:!1})})}),P?o.jsx("div",{className:tt?"lg:col-span-2 min-w-0":"lg:col-span-6 min-w-0",children:o.jsx(xt,{delay:.25,children:P})}):null,tt?o.jsx("div",{className:P?"lg:col-span-4 min-w-0":"lg:col-span-6 min-w-0",children:o.jsx(xt,{delay:.31,children:o.jsx(N0,{fleetData:de,from:M,to:T})})}):null,k?o.jsx("div",{className:"lg:col-span-6",children:o.jsx(q0,{enterDelay:.37})}):null]}),o.jsx(xt,{delay:.43,children:o.jsx(xc,{projectEntries:d,projectLimit:f,onProjectLimitChange:h,copy:t,hasDetailsActual:W,dailyEmptyPrefix:te,installSyncCmd:ge,dailyEmptySuffix:me,detailsColumns:Ne,ariaSortFor:Fe,toggleSort:Te,sortIconFor:A,pagedDetails:Y,dailyBreakdownRows:U,dailyBreakdownColumns:q,dailyBreakdownAriaSortFor:ne,dailyBreakdownSortIconFor:oe,dailyBreakdownDateKey:ye,detailsDateKey:fe,renderDetailDate:he,renderDailyBreakdownDate:Pe,renderDetailCell:pe,DETAILS_PAGED_PERIODS:We,period:j,detailsPageCount:Ee,detailsPage:Be,setDetailsPage:Mt})})]})}),o.jsx(yc,{isOpen:je,onClose:Me,fleetData:de})]})}const K0=["day","24h","week","month","total","custom"],qo="tt:dashboard-auto-refresh-ms",Jt=3e4,Xo=[{value:0,labelKey:"usage.auto_refresh.off"},{value:3e4,labelKey:"usage.auto_refresh.30s"},{value:6e4,labelKey:"usage.auto_refresh.60s"},{value:12e4,labelKey:"usage.auto_refresh.120s"}],G0=3e4,Q0=6e4,qn=new Set(["day","hour","month"]),Xt=new Set(["day","24h","total","custom"]),J0=new Set(Xo.map(e=>e.value));function Ko(e){if(e==null||e==="")return Jt;const t=Number(e);return Number.isFinite(t)&&J0.has(t)?t:Jt}function Z0(){if(typeof window>"u")return Jt;try{return Ko(window.localStorage?.getItem(qo))}catch{return Jt}}function eg(e){const n=(typeof e?.stdout=="string"?e.stdout:"").match(/New 30-min buckets queued:\s*(\d+)/i);return n?Number(n[1])>0:!0}function Xn(e,t){if(typeof t=="number"&&t>0)return!0;if(typeof e=="bigint")return e>0n;if(typeof e=="number")return Number.isFinite(e)&&e>0;if(typeof e=="string"){const n=e.trim();if(!n)return!1;if(/^[0-9]+$/.test(n))try{return BigInt(n)>0n}catch{return!1}const a=Number(n);return Number.isFinite(a)&&a>0}return!1}function pn(e){return e?_n(e,null):null}function Er(e){return e?e?.billable_total_tokens??e?.value??e?.total_tokens:null}function tg(e){if(typeof e!="string"||!e)return null;const t=e.split("-");if(t.length!==3)return null;const n=Number(t[0]),a=Number(t[1])-1,r=Number(t[2]);if(!Number.isFinite(n)||!Number.isFinite(a)||!Number.isFinite(r))return null;const s=new Date(Date.UTC(n,a,r));return Number.isFinite(s.getTime())?s:null}function ng(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function hg({baseUrl:e,onMainContentVisible:t}){const{resolvedLocale:n}=oi(),{currency:a,rate:r}=_t(),[s,l]=m.useState(!1),[i,c]=m.useState(null),[u,d]=m.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(max-width: 640px)").matches),f=m.useMemo(()=>typeof window>"u"?!1:si(window.location.search),[]),h=2200,[g,p]=m.useState(!0),[k,v]=m.useState(!1),[w,N]=m.useState(Z0),[x,M]=m.useState(()=>Date.now()),[T,j]=m.useState(()=>Date.now()),L=m.useRef(!1),P=m.useRef(!1),C=m.useRef(0),I=m.useRef(null),K=m.useRef(!1),V=Yt(),$=null,E=!1,D=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");m.useEffect(()=>{if(!D&&!V){c(null);return}let O=!0;return(async()=>{try{const G=await bi({baseUrl:e});if(!O)return;c(G&&typeof G=="object"?G:null)}catch{if(!O)return;c(null)}})(),()=>{O=!1}},[e,D,V]),m.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const O=window.matchMedia("(max-width: 640px)"),G=()=>d(O.matches);return G(),O.addEventListener?(O.addEventListener("change",G),()=>O.removeEventListener("change",G)):(O.addListener(G),()=>O.removeListener(G))},[]);const b=m.useMemo(()=>Vr(),[]),_=m.useMemo(()=>Ur(),[]),H=m.useMemo(()=>ci(),[]),S=m.useMemo(()=>H||new Date(x),[x,H]),X="default",[F,z]=m.useState("day"),[B,Z]=m.useState(null),[xe,je]=m.useState(null),[Me,Se]=m.useState(!1),J=f?"total":F,De=m.useMemo(()=>J==="custom"&&B&&xe?{from:B,to:xe}:di(J,{timeZone:b,offsetMinutes:_,now:S}),[S,J,b,_,B,xe]),le=De.from,de=De.to,W=m.useMemo(()=>ui({timeZone:b,offsetMinutes:_}),[b,_]),te=m.useMemo(()=>fi({timeZone:b,offsetMinutes:_}),[b,_]),ge=m.useMemo(()=>`Local time (${te})`,[te]),me=b,Ne=_,Fe=W,Te=m.useMemo(()=>Zt({timeZone:b,offsetMinutes:_,date:S}),[S,b,_]),A=m.useMemo(()=>{const O=tg(Te)||new Date,G=ng(O,-29);return{from:mt(G),to:mt(O)}},[Te]),{daily:Y,summary:U,rolling:q,source:ne,loading:oe,error:ye,refresh:fe}=La({baseUrl:e,accessToken:$,guestAllowed:E,from:le,to:de,includeDaily:J!=="total",cacheKey:X,timeZone:b,tzOffsetMinutes:_,now:S}),{daily:he,loading:Pe,refresh:pe}=La({baseUrl:e,accessToken:$,guestAllowed:E,from:A.from,to:A.to,includeDaily:!0,cacheKey:`${X}.daily-breakdown`,timeZone:b,tzOffsetMinutes:_,now:S}),{breakdown:We,loading:Ee,refresh:Be}=Nl({baseUrl:e,accessToken:$,guestAllowed:E,from:le,to:de,cacheKey:X,timeZone:b,tzOffsetMinutes:_}),{pulse:Mt,refresh:gt}=Fl({baseUrl:e,accessToken:$,guestAllowed:E,period:J,timeZone:b,tzOffsetMinutes:_,now:S,cacheKey:X}),yt=m.useMemo(()=>{try{return new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit",timeZone:b||void 0}).format(S)}catch{return null}},[S,b]),[tt,pt]=m.useState(10),{entries:se,loading:re,refresh:ee}=sl({baseUrl:e,accessToken:$,limit:tt,from:le,to:de,timeZone:b,tzOffsetMinutes:_}),ce=J==="week"||J==="month",Ce=J==="week"||J==="month",ie=m.useMemo(()=>Y.filter(O=>O?.future?!1:!O?.day||!Te?!0:String(O.day)<=String(Te)),[Y,Te]),{rows:ze,from:zt,to:Bt,loading:jt,refresh:bt}=Jr({baseUrl:e,accessToken:$,guestAllowed:E,period:J,from:le,to:de,months:24,cacheKey:X,timeZone:me,tzOffsetMinutes:Ne,now:S,sharedRows:ce?Y:null,sharedRange:ce?{from:le,to:de}:null}),Go=m.useMemo(()=>({baseUrl:e,accessToken:$,guestAllowed:E,cacheKey:X,timeZone:me,tzOffsetMinutes:Ne,now:S}),[e,$,E,X,me,Ne,S]),{daily:Ot,heatmap:lt,loading:Qo,refresh:Na}=ol({baseUrl:e,accessToken:$,guestAllowed:E,weeks:52,cacheKey:X,timeZone:b,tzOffsetMinutes:_,now:S}),{data:un,refresh:_a}=xi();m.useEffect(()=>{un&&typeof un=="object"&&ii(un)},[un]);const Ke=m.useMemo(()=>J==="day"||J==="24h"?"hour":J==="total"?"month":"day",[J]),Jo=m.useMemo(()=>Ua(Ke),[Ke]),fn="day",Zo=m.useMemo(()=>[...Ua(fn),{key:"total_cost_usd",label:y("daily.sort.cost.label"),title:y("daily.sort.cost.title")},{key:"cost_per_million_tokens",label:y("daily.sort.cost_per_mtok.label"),title:y("daily.sort.cost_per_mtok.title")},{key:"top_model",label:y("daily.sort.top_model.label"),title:y("daily.sort.top_model.title")}],[]),[Ge,Ma]=m.useState(()=>({key:"day",dir:"desc"}));m.useEffect(()=>{Ma(O=>!qn.has(O.key)||O.key===Ke?O:{key:Ke,dir:O.dir})},[Ke]);const $t=m.useMemo(()=>qn.has(Ge.key)&&Ge.key!==Ke?{...Ge,key:Ke}:Ge,[Ke,Ge]),mn=m.useMemo(()=>{if(J==="day"||J==="24h")return Array.isArray(ze)?ze.filter(ae=>ae?.hour&&!ae?.future):[];if(J==="total"){const ae=Array.isArray(ze)?ze.filter(ue=>ue?.month&&!ue?.future):[];return Xl(ae)}const O=ie;return!O.some(ae=>!ae?.missing&&!ae?.future)&&Y.length>0?Y.filter(ae=>!ae?.future).slice(-30).filter(ae=>ae?.day):O},[J,ze,ie,Y]),Ht=m.useMemo(()=>Va(mn,$t),[mn,$t]),es=m.useMemo(()=>mn.some(O=>!O?.missing&&!O?.future),[mn]),Cn=m.useMemo(()=>{if(!Xt.has(J))return 1;const O=Math.ceil(Ht.length/Nn);return O>0?O:1},[J,Ht.length]),[Dn,hn]=m.useState(0);m.useEffect(()=>{if(!Xt.has(J)){hn(0);return}hn(O=>Math.min(O,Cn-1))},[Cn,J]),m.useEffect(()=>{Xt.has(J)&&hn(0)},[J,Ge.dir,Ge.key]);const ts=m.useMemo(()=>Xt.has(J)?Kl(Ht,Dn,Nn):Ht,[Dn,J,Ht]),ja=m.useMemo(()=>nc(he.filter(O=>!O?.future&&O?.day).slice(-30),{fallback:y("shared.placeholder.short")}),[he]),Wt=m.useMemo(()=>qn.has(Ge.key)?{...Ge,key:fn}:Ge,[Ge]),ns=m.useMemo(()=>Va(ja,Wt),[ja,Wt]),as=m.useMemo(()=>Ce?Y:J==="day"||J==="24h"?Array.isArray(ze)?ze.filter(O=>O?.hour):[]:ze,[Y,J,ze,Ce]),rs=Ce?le:zt,os=Ce?de:Bt;function ss(O,G){if(O?.future)return"—";if(O?.missing)return y("shared.status.unsynced");if(G==="total_tokens")return Qe(pn(O));if(G==="total_cost_usd")return et(O?.total_cost_usd,{currency:a,rate:r});if(G==="cost_per_million_tokens"){const ae=Le(O?.cost_per_million_tokens);return ae==null?y("shared.placeholder.short"):et(ae,{currency:a,rate:r})}return G==="top_model"?O?.top_model||y("shared.placeholder.short"):Qe(O?.[G])}function is(O){const G=O?.[Ke];if(G==null)return"";const ae=String(G);if(Ke==="hour"){const[ue,Ve]=ae.split("T");if(ue&&Ve)return`${ue} ${Ve.slice(0,5)}`}return ae}function ls(O){const G=O?.[fn];return G==null?"":String(G)}function cs(O){Ma(G=>G.key===O?{key:O,dir:G.dir==="asc"?"desc":"asc"}:{key:O,dir:"desc"})}function ds(O){return $t.key!==O?null:$t.dir==="asc"?"ascending":"descending"}function us(O){return $t.key!==O?"":$t.dir==="asc"?"▲":"▼"}function fs(O){return Wt.key!==O?null:Wt.dir==="asc"?"ascending":"descending"}function ms(O){return Wt.key!==O?"":Wt.dir==="asc"?"▲":"▼"}const hs=m.useMemo(()=>{if(!V&&!D)return 0;const O=Number(lt?.active_days);if(Number.isFinite(O))return O;let G=0;const ae=new Set,ue=($e,Ct,$n)=>{typeof $e!="string"||!$e||ae.has($e)||Xn(Ct,$n)&&(ae.add($e),G+=1)};if(Array.isArray(Ot))for(const $e of Ot)ue($e?.day,pn($e));const Ve=Array.isArray(lt?.weeks)?lt.weeks:[];for(const $e of Ve)for(const Ct of Array.isArray($e)?$e:[]){const $n=Er(Ct);ue(Ct?.day,$n,Ct?.level)}return G},[V,D,lt?.active_days,lt?.weeks,Ot]),[Sa,Ca]=m.useState("month"),gs=m.useCallback(O=>{O==="custom"?(Ca(G=>G==="custom"?"month":G),z(G=>B&&xe?"custom":G),Se(!0)):(z(O),Ca(O),Se(!1))},[B,xe]),ys=m.useCallback((O,G)=>{Z(O),je(G),z("custom"),Se(!1)},[]),ps=m.useCallback(O=>{Se(O),!O&&F==="custom"&&!B&&z(Sa)},[F,B,Sa]),Ut=m.useCallback(async()=>{const O=Date.now();M(O),await Promise.all([fe(),Na(),bt(),Be(),ee(),pe(),_a(),gt()]),j(O)},[pe,Na,Be,ee,bt,fe,_a,gt]);m.useEffect(()=>{if(f||H||typeof window>"u")return;const O=()=>{const ae=new Date,ue=Zt({timeZone:b,offsetMinutes:_,date:ae});if(ue){if(I.current==null){I.current=ue;return}I.current!==ue&&(I.current=ue,M(ae.getTime()))}};O();const G=window.setInterval(O,Q0);return typeof document<"u"&&document.addEventListener("visibilitychange",O),window.addEventListener("focus",O),()=>{window.clearInterval(G),typeof document<"u"&&document.removeEventListener("visibilitychange",O),window.removeEventListener("focus",O)}},[H,f,b,_]);const bs=m.useCallback(async()=>{v(!0);try{D&&await Fa(),await Ut()}catch(O){console.error("[DashboardPage] Refresh failed:",O)}finally{v(!1)}},[D,Ut]),Da=m.useCallback(()=>!D||P.current?null:(P.current=!0,Fa().then(eg).catch(O=>(console.error("[DashboardPage] Auto sync failed:",O),!1)).finally(()=>{P.current=!1})),[D]),Ta=m.useCallback(async()=>{const O=Da();try{await Ut(),O&&O.then(G=>{if(G)return Ut()})}catch(G){console.error("[DashboardPage] Auto refresh failed:",G)}},[Ut,Da]),xs=m.useCallback(O=>{const G=Ko(O);N(G);try{window.localStorage?.setItem(qo,String(G))}catch{}},[]);m.useEffect(()=>{if(f||typeof window>"u"||w<=0)return;const O=()=>typeof document>"u"||document.visibilityState==="visible",G=async({throttle:Ve=!1}={})=>{if(!O())return;const $e=Date.now();if(!(Ve&&$e-C.current<G0)&&!L.current){L.current=!0,C.current=$e;try{await Ta()}finally{L.current=!1}}},ae=window.setInterval(()=>{G()},w),ue=()=>{G({throttle:!0})};return typeof document<"u"&&document.addEventListener("visibilitychange",ue),window.addEventListener("focus",ue),()=>{window.clearInterval(ae),typeof document<"u"&&document.removeEventListener("visibilitychange",ue),window.removeEventListener("focus",ue)}},[w,Ta,f]);const Tn=k||oe||Pe||Qo||jt||Ee||re,ks=m.useMemo(()=>y("shared.data_source",{source:String(ne||"edge").toUpperCase()}),[ne,n]),Pa=y("dashboard.identity.fallback"),ws=m.useMemo(()=>Pa.replace(/[^a-zA-Z0-9._-]/g,"_"),[Pa]),vs=m.useMemo(()=>{let O=null;const G=ue=>{typeof ue!="string"||!ue||(!O||ue<O)&&(O=ue)};if(Array.isArray(Ot))for(const ue of Ot)ue?.day&&Xn(pn(ue))&&G(ue.day);const ae=Array.isArray(lt?.weeks)?lt.weeks:[];for(const ue of ae)for(const Ve of Array.isArray(ue)?ue:[]){if(!Ve?.day)continue;const $e=Er(Ve),Ct=Ve?.level;Xn($e,Ct)&&G(Ve.day)}return O},[lt?.weeks,Ot]),Ns=m.useMemo(()=>(Array.isArray(i?.subscriptions?.items)?i.subscriptions.items:[]).map(ae=>{const ue=typeof ae?.tool=="string"?ae.tool.trim():"",$e=(typeof ae?.plan_type=="string"?ae.plan_type:typeof ae?.planType=="string"?ae.planType:"").trim();return!ue||!$e?null:{tool:ue,planType:$e,provider:typeof ae?.provider=="string"?ae.provider.trim():"",product:typeof ae?.product=="string"?ae.product.trim():"",rateLimitTier:typeof ae?.rate_limit_tier=="string"?ae.rate_limit_tier.trim():typeof ae?.rateLimitTier=="string"?ae.rateLimitTier.trim():""}}).filter(Boolean).slice(0,6),[i]),_s=o.jsx(hc,{heatmap:lt,timeZoneLabel:W,timeZoneShortLabel:te,hideLegend:f,defaultToLatestMonth:f}),Ms=m.useMemo(()=>`${le}..${de}`,[le,J,de]),js=y("usage.summary.total"),St=pn(U),Oa=y("shared.unit.thousand_abbrev"),$a=y("shared.unit.million_abbrev"),Wa=y("shared.unit.billion_abbrev"),Vt=Le(St),Ea=Vt!=null&&(u&&Math.abs(Vt)>=1e9||Math.abs(Vt)>=1e12),Ss=m.useMemo(()=>Ea?Ae(Vt,{thousandSuffix:Oa,millionSuffix:$a,billionSuffix:Wa,decimals:1}):Qe(St),[Wa,$a,St,Vt,Oa,Ea]),Cs=m.useMemo(()=>{const O=new Intl.DateTimeFormat(n||void 0,{timeZone:b,year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"short"}).format(new Date(T));return y("usage.summary.updated_at",{timestamp:O})},[T,n,b]),Ds=y("dashboard.core_index.collapse_label"),Ts=y("dashboard.core_index.expand_label"),Ps=y("dashboard.core_index.collapse_aria"),Os=y("dashboard.core_index.expand_aria"),$s=!f,Ws=y("dashboard.screenshot.title_line1"),Es=y("dashboard.screenshot.title_line2");y("shared.placeholder.short");const As=m.useMemo(()=>f?[]:K0,[f]),Fs=m.useMemo(()=>[{label:y("usage.metric.total"),value:Qe(St),valueClassName:"text-white"},{label:y("usage.metric.input"),value:Qe(U?.input_tokens)},{label:y("usage.metric.output"),value:Qe(U?.output_tokens)},{label:y("usage.metric.cached_input"),value:Qe(U?.cached_input_tokens)},{label:y("usage.metric.reasoning_output"),value:Qe(U?.reasoning_output_tokens)}],[U?.cached_input_tokens,U?.input_tokens,U?.output_tokens,U?.reasoning_output_tokens,St]),Pn=m.useMemo(()=>et(U?.total_cost_usd,{currency:a,rate:r}),[U?.total_cost_usd,a,r]),Rs=m.useMemo(()=>{if(Number(St||0)>0||oe||ye)return null;const G=Number(q?.current_month?.totals?.billable_total_tokens||0),ae=Number(q?.last_30d?.totals?.billable_total_tokens||0),ue=Number(q?.last_7d?.totals?.billable_total_tokens||0);return J==="day"&&ue>0?y("dashboard.data_health.day_empty_has_recent",{tokens:Qe(ue)}):(J==="week"||J==="custom")&&ae>0?y("dashboard.data_health.period_empty_has_30d",{tokens:Qe(ae)}):J==="month"&&G===0&&ae>0?y("dashboard.data_health.month_empty_has_30d",{tokens:Qe(ae)}):ae===0&&q?y("dashboard.data_health.no_recent_data"):null},[J,q,St,ye,oe]),Aa=m.useMemo(()=>so(We,{copyFn:y}),[We]),Is=m.useMemo(()=>ec(We,{copyFn:y}),[We]),Ls=m.useCallback(()=>l(!0),[]),Ys=m.useCallback(()=>l(!1),[]),zs=Pn&&Pn!=="-"&&Aa.length>0,Bs=y("dashboard.install.cmd.sync"),On=m.useMemo(()=>y("dashboard.daily.empty",{cmd:"{{cmd}}"}),[n]),[Hs,Us]=m.useMemo(()=>{const O=On.split("{{cmd}}");return O.length===1?[On,""]:[O[0],O.slice(1).join("{{cmd}}")]},[On]);return m.useEffect(()=>{K.current||Tn||(K.current=!0,t?.())},[t,Tn]),o.jsx(X0,{copy:y,screenshotMode:f,screenshotTitleLine1:Ws,screenshotTitleLine2:Es,identityDisplayName:ws,identityStartDate:vs,activeDays:hs,identitySubscriptions:Ns,identityScrambleDurationMs:h,projectUsageEntries:se,projectUsageLimit:tt,setProjectUsageLimit:pt,pulse:Mt,pulseComparedAtLabel:yt,isLocalMode:D,trendRowsForDisplay:as,trendFromForDisplay:rs,trendToForDisplay:os,trendZoomConfig:Go,usageFrom:le,usageTo:de,period:J,trendTimeZoneLabel:Fe,activityHeatmapBlock:_s,periodsForDisplay:As,setSelectedPeriod:gs,autoRefreshOptions:Xo,autoRefreshIntervalMs:w,onAutoRefreshIntervalChange:xs,customFrom:B,customTo:xe,onCustomRangeApply:ys,customRangeOpen:Me,onCustomRangeOpenChange:ps,metricsRows:Fs,summaryLabel:js,summaryValue:Ss,summaryUpdatedAtLabel:Cs,summaryCostValue:Pn,usageInsights:Is,costInfoEnabled:zs,openCostModal:Ls,allowBreakdownToggle:$s,coreIndexCollapsed:g,setCoreIndexCollapsed:p,coreIndexCollapseLabel:Ds,coreIndexExpandLabel:Ts,coreIndexCollapseAria:Ps,coreIndexExpandAria:Os,refreshAll:bs,usageLoadingState:Tn,usageError:ye,dataHealthMessage:Rs,rangeLabel:Ms,timeZoneRangeLabel:ge,usageSourceLabel:ks,fleetData:Aa,hasDetailsActual:es,dailyEmptyPrefix:Hs,installSyncCmd:Bs,dailyEmptySuffix:Us,detailsColumns:Jo,ariaSortFor:ds,toggleSort:cs,sortIconFor:us,pagedDetails:ts,dailyBreakdownRows:ns,dailyBreakdownColumns:Zo,dailyBreakdownAriaSortFor:fs,dailyBreakdownSortIconFor:ms,dailyBreakdownDateKey:fn,detailsDateKey:Ke,renderDetailDate:is,renderDailyBreakdownDate:ls,renderDetailCell:ss,DETAILS_PAGED_PERIODS:Xt,detailsPageCount:Cn,detailsPage:Dn,setDetailsPage:hn,costModalOpen:s,closeCostModal:Ys})}export{hg as DashboardPage};
|
|
60
|
+
`}),o.jsxs("div",{className:Xe("relative w-full max-w-6xl h-[88vh] backdrop-blur-2xl bg-white/90 dark:bg-oai-gray-900/90 border border-oai-gray-200/50 dark:border-white/10 shadow-2xl rounded-2xl flex flex-col md:flex-row overflow-hidden",N?"animate-tt-modal-exit":"animate-tt-modal"),children:[o.jsx("button",{type:"button",onClick:E,"aria-label":y("trend.zoom.close_aria"),className:"absolute top-4 right-4 z-50 p-2 rounded-full border border-oai-gray-200/60 dark:border-oai-gray-800/60 bg-white/50 dark:bg-oai-gray-900/50 text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white hover:rotate-90 hover:scale-105 active:scale-95 transition-all duration-300",children:o.jsx(sa,{size:16})}),o.jsxs("div",{className:"w-full md:w-[320px] shrink-0 border-b md:border-b-0 md:border-r border-zinc-200/50 dark:border-zinc-800/40 p-5 md:p-6 flex flex-col gap-6 overflow-y-auto backdrop-blur-md bg-zinc-50/50 dark:bg-zinc-950/50",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[o.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[o.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:Ft}}),o.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5",style:{backgroundColor:Ft}})]}),o.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono text-zinc-400 dark:text-zinc-500",children:y("trend.zoom.badge")})]}),o.jsx("h4",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight leading-none mt-2 select-none",children:y("trend.monitor.label")}),r?o.jsx("p",{className:"text-[10px] text-zinc-400 dark:text-zinc-500 mt-1.5 font-mono select-none",children:r}):null,o.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-400 dark:text-zinc-500 mt-2 font-normal select-none",children:y("trend.zoom.desc")})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-x-5 gap-y-5 border-y border-zinc-200/50 dark:border-zinc-800/50 py-5 select-none",children:[o.jsx(yn,{label:y("trend.zoom.stats.tokens"),value:Ae($.totalTokens)}),H?o.jsx(yn,{label:y("trend.zoom.stats.cost"),value:H}):null,o.jsx(yn,{label:y("trend.zoom.stats.conversations"),value:$.conversationCount.toLocaleString()}),$.peak?o.jsx(yn,{label:y("trend.zoom.stats.peak"),value:Ae($.peak.value),sub:I0($.peak.label)}):null]}),o.jsxs("div",{className:"flex flex-col gap-2 select-none",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(Kr,{size:11,style:{color:Ft}}),o.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono",style:{color:Ft},children:y("trend.zoom.insight_badge")})]}),o.jsxs("div",{className:"pl-3.5 border-l-2 relative",style:{borderColor:Ft},children:[o.jsx("div",{className:"absolute inset-y-0 left-0 w-[3px] blur-[2px] opacity-15 pointer-events-none rounded-full",style:{backgroundColor:Ft}}),o.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-600 dark:text-zinc-400 font-normal",children:y($0($),{active:$.activeBuckets,peak:Ae($.peak?.value||0)})})]})]})]}),o.jsxs("div",{className:"flex-1 min-w-0 flex flex-col p-5 md:p-6 overflow-y-auto",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3 mb-6 pr-10",children:[o.jsx("div",{role:"tablist","aria-label":y("trend.zoom.gran.aria"),className:"flex rounded-md border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 text-[11px]",children:E0.map(S=>o.jsx("button",{type:"button",role:"tab","aria-selected":f===S.period,onClick:()=>L(S.period),className:Xe("px-2.5 py-1 rounded transition-colors",f===S.period?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-oai-white font-medium":"text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200"),children:y(S.labelKey)},S.period))}),f==="day"?o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("button",{type:"button",onClick:()=>b&&g(S=>oa(S,-1)),disabled:!b,"aria-label":y("trend.zoom.prev_day"),className:"p-1 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 disabled:opacity-30 disabled:pointer-events-none transition-colors",children:o.jsx(ri,{size:16})}),o.jsxs(Qn,{open:v,onOpenChange:w,children:[o.jsx(Jn,{"aria-label":y("trend.zoom.pick_day"),className:"text-[12px] font-medium text-oai-gray-700 dark:text-oai-gray-200 tabular-nums min-w-[100px] text-center px-2 py-0.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:h||"—"}),o.jsx(Zn,{children:o.jsx(ea,{sideOffset:8,side:"bottom",align:"center",className:"!z-[9999]",children:o.jsx(ta,{className:"bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded-xl shadow-lg",children:o.jsx(ra,{from:h,to:h,onApply:S=>{S&&g(S),w(!1)},onCancel:()=>w(!1)})})})})]}),o.jsx("button",{type:"button",onClick:()=>M&&g(S=>oa(S,1)),disabled:!M,"aria-label":y("trend.zoom.next_day"),className:"p-1 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 disabled:opacity-30 disabled:pointer-events-none transition-colors",children:o.jsx(Br,{size:16})})]}):o.jsxs(Qn,{open:_,onOpenChange:k,children:[o.jsx(Jn,{"aria-label":y("trend.zoom.pick_range"),className:"text-xs font-medium text-oai-gray-600 dark:text-oai-gray-300 tabular-nums px-2.5 py-1 rounded-md border border-oai-gray-200 dark:border-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors select-none",children:p.from&&p.to?p.from===p.to?p.from:`${p.from} → ${p.to}`:"—"}),o.jsx(Zn,{children:o.jsx(ea,{sideOffset:8,side:"bottom",align:"end",className:"!z-[9999]",children:o.jsx(ta,{className:"bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded-xl shadow-lg",children:o.jsx(ra,{from:p.from,to:p.to,onApply:(S,X)=>{S&&x({from:S,to:X||S}),k(!1)},onCancel:()=>k(!1)})})})})]})]}),o.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:V&&(!C||C.length===0)?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx("p",{className:"text-sm text-oai-gray-400 dark:text-oai-gray-400",children:y("trend.zoom.loading")})}):l({rows:C,from:I,to:K,period:f,timeZoneLabel:r})})]})]})]})}function Cr(e,t){if(!Array.isArray(e)||e.length===0)return 0;if(e.length===1)return e[0];const n=(e.length-1)*t,a=Math.floor(n),r=Math.ceil(n);if(a===r)return e[a];const s=n-a;return e[a]+(e[r]-e[a])*s}function Y0(e){const t=Array.isArray(e)?e.filter(r=>Number.isFinite(r)&&r>0).sort((r,s)=>r-s):[];if(t.length===0)return{rawMax:0,effectiveMax:1,clippedValues:Array.isArray(e)?e.map(()=>0):[]};const n=t.at(-1)??0;let a=n;if(t.length>=4){const r=Cr(t,.25),s=Cr(t,.75),l=Math.max(s-r,0),i=s+l*1.5;n>i&&(a=Math.max(i,s,1))}return{rawMax:n,effectiveMax:Math.max(a,1),clippedValues:Array.isArray(e)?e.map(r=>!Number.isFinite(r)||r<=0?0:Math.min(r,Math.max(a,1))):[]}}const Dr=["#f472b6","#38bdf8","#34d399","#fbbf24","#a78bfa","#fb7185","#2dd4bf","#f97316","#6366f1","#ec4899","#14b8a6","#f59e0b"],Ho={Input:"#38bdf8","Cached Input":"#14b8a6",Output:"#a78bfa","Reasoning Output":"#fb7185"},z0={codex:"#3b82f6",gpt:"#10b981",openai:"#10b981",claude:"#d97757",anthropic:"#d97757",gemini:"#2196f3",google:"#2196f3",kimi:"#a78bfa",moonshot:"#a78bfa",opencode:"#f59e0b",deepseek:"#f59e0b",droid:"#ef4444",kilo:"#facc15"};function Uo(e){const t=e.toLowerCase();for(const[r,s]of Object.entries(z0))if(t.includes(r))return s;let n=0;for(let r=0;r<e.length;r++)n=e.charCodeAt(r)+((n<<5)-n);const a=Math.abs(n)%Dr.length;return Dr[a]}function B0(e){if(!e)return[];const t=[];if(e.models&&typeof e.models=="object")for(const[n,a]of Object.entries(e.models)){const r=Number(a);Number.isFinite(r)&&r>0&&t.push({type:"model",name:n,value:r})}if(t.length===0){const n=[{name:"Input",key:"input_tokens"},{name:"Cached Input",key:"cached_input_tokens"},{name:"Output",key:"output_tokens"},{name:"Reasoning Output",key:"reasoning_output_tokens"}];for(const a of n){const r=Number(e[a.key]);Number.isFinite(r)&&r>0&&t.push({type:"token_type",name:a.name,value:r})}}return t.sort((n,a)=>a.value-n.value)}function H0(e,t){return e?.future?"predicted":e?.missing?"unsynced":t>0?"real":"real_zero"}const U0=.35,Tr=2,Pr=4;function V0({value:e,displayValue:t,scale:n,index:a,row:r,totalBars:s,onMouseEnter:l,onMouseLeave:i}){const c=Lt(),d=H0(r,e),f=d==="predicted"||d==="unsynced",u=n.effectiveMax>0?t/n.effectiveMax*100:0;let h,g;d==="real"?(h=`${Math.max(u,2)}%`,g=`${Pr}px`):f&&u>0?(h=`${u}%`,g=`${Pr}px`):(h=`${Tr}px`,g=`${Tr}px`);const p=d==="real"?B0(r):[],x=p.reduce((w,_)=>w+_.value,0),v=d!=="real"||x<=0;return o.jsxs(ht.div,{className:"group relative flex-1 self-stretch",initial:{opacity:0,scaleY:0},animate:{opacity:1,scaleY:1},transition:{duration:c?0:.3,delay:c?0:.4+a*.008,ease:[.16,1,.3,1]},style:{originY:1},onMouseEnter:w=>l(w,r,e,p,d,t),onMouseLeave:i,children:[o.jsx("div",{className:"absolute inset-x-0 top-0 bottom-0 bg-oai-gray-100/70 dark:bg-white/[0.08] opacity-0 group-hover:opacity-100 transition-opacity duration-150 pointer-events-none"}),o.jsx("div",{className:"absolute inset-x-0 bottom-0 flex flex-col-reverse justify-start overflow-hidden rounded-t-[3px] cursor-pointer transition-all duration-200",style:{height:h,minHeight:g},children:v?o.jsx("div",{"data-trend-bar":"true",className:Xe("h-full w-full group-hover:brightness-110 transition-all",d==="real"?"":"bg-oai-gray-100 dark:bg-oai-gray-800"),style:{opacity:f?U0:1,background:d==="real"?"#10b981":void 0}}):p.map((w,_)=>{const k=w.type==="token_type"?Ho[w.name]:Uo(w.name),N=`${w.value/x*100}%`;return o.jsx("div",{"data-trend-bar":_===0?"true":void 0,className:"w-full group-hover:brightness-110 transition-all",style:{height:N,background:k}},_)})})]})}function q0(e){if(e?.missing||e?.future)return null;const t=e?.billable_total_tokens??e?.total_tokens??e?.value;if(t==null)return null;const n=Number(t);return Number.isFinite(n)&&n>=0?n:null}const Or=.98;function X0(e){if(!Array.isArray(e))return[];const t=new Array(e.length);for(let n=0;n<e.length;n++){if(e[n]!==null){t[n]=e[n];continue}let a=null,r=-1;for(let i=n-1;i>=0;i--)if(e[i]!==null){a=e[i],r=i;break}let s=null,l=-1;for(let i=n+1;i<e.length;i++)if(e[i]!==null){s=e[i],l=i;break}if(a!==null&&s!==null){const i=(n-r)/(l-r);t[n]=a+(s-a)*i}else if(a!==null){let i=0,c=0;for(let f=0;f<=r;f++)e[f]!==null&&(i+=e[f],c+=1);const d=c>0?i/c:a;t[n]=d*Math.pow(Or,n-r)}else if(s!==null){let i=0,c=0;for(let f=l;f<e.length;f++)e[f]!==null&&(i+=e[f],c+=1);const d=c>0?i/c:s;t[n]=d*Math.pow(Or,l-n)}else t[n]=0}return t}function Vo({rows:e,from:t,to:n,period:a,timeZoneLabel:r,showTimeZoneLabel:s=!0,className:l="",embedded:i=!1,chartHeightClass:c="h-40",isZoom:d=!1,zoomConfig:f=null}){const u=R.useMemo(()=>Array.isArray(e)&&e.length?e:[],[e]),{rawValues:h,seriesValues:g,scale:p,interpolatedValues:x}=R.useMemo(()=>{const $=u.map(q0),E=$.map(T=>T??0);return{rawValues:$,seriesValues:E,scale:Y0(E),interpolatedValues:X0($)}},[u]),{currency:v,rate:w}=Nt(),_=S0(a),[k,N]=R.useState(null),[D,j]=R.useState({x:0,y:0,shiftX:0,flipDown:!1}),[L,P]=R.useState(!1),C=R.useRef(null),I=R.useRef(null),K=($,E,T,b,M,H)=>{I.current&&(clearTimeout(I.current),I.current=null);const S=d?O0(E,_):E?.day||E?.hour||E?.month||"";N({row:E,value:T,segments:b,timeLabel:S,kind:M,displayValue:H});const X=$.currentTarget.querySelector('[data-trend-bar="true"]'),F=X&&X.parentElement?X.parentElement.getBoundingClientRect():$.currentTarget.getBoundingClientRect(),z=C.current;if(!z)return;const B=z.getBoundingClientRect(),Z=F.left-B.left+F.width/2,xe=F.top-B.top,je=140;let Me=0;Z<je?Me=je-Z:Z>B.width-je&&(Me=B.width-je-Z);const Se=96+(d?22:0)+(b.length?Math.min(b.length*30+24,174):0),J=xe<Se+12;j({x:Z,y:xe,shiftX:Me,flipDown:J})},V=()=>{I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{N(null)},150)};return o.jsxs("div",{ref:C,className:Xe("relative",!i&&"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5",d&&"flex h-full flex-col",l),children:[!i&&o.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:y("trend.monitor.label")}),s&&r&&o.jsx("p",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:r})]}),f&&o.jsx("button",{type:"button",onClick:()=>P(!0),"aria-label":y("trend.zoom.open_aria"),title:y("trend.zoom.open_aria"),className:"shrink-0 p-1.5 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 transition-colors",children:o.jsx(Xr,{size:14})})]}),o.jsxs("div",{className:Xe("space-y-3",d&&"flex flex-1 flex-col min-h-0 !space-y-0 gap-3"),children:[o.jsxs("div",{className:Xe("flex gap-2",d&&"flex-1 min-h-0"),children:[o.jsx("div",{className:"flex shrink-0 flex-col justify-between text-right text-[10px] leading-none text-oai-gray-400 dark:text-oai-gray-500 tabular-nums",children:[1,.75,.5,.25,0].map($=>o.jsx("span",{children:$===0?"0":Ae(p.effectiveMax*$,{decimals:0})},$))}),o.jsxs("div",{className:Xe("relative min-w-0 flex-1",d&&"min-h-0"),children:[o.jsx("div",{className:"absolute inset-0 flex flex-col justify-between pointer-events-none",children:[0,25,50,75,100].map($=>o.jsx("div",{className:"w-full border-t border-oai-gray-100 dark:border-oai-gray-800",style:{top:`${100-$}%`}},$))}),o.jsx("div",{className:Xe("flex items-end gap-0.5 relative z-0",c),children:g.length>0?g.map(($,E)=>{const T=u[E],M=T?.missing||T?.future?Math.min(x[E]??0,p.effectiveMax):p.clippedValues[E]??0;return o.jsx(V0,{value:$,displayValue:M,scale:p,index:E,row:T,totalBars:g.length,onMouseEnter:K,onMouseLeave:V},E)}):o.jsx("div",{className:"flex-1 h-full flex items-center justify-center",children:o.jsx("p",{className:"text-sm text-oai-gray-400 dark:text-oai-gray-400",children:"No data yet"})})})]})]}),d&&g.length>0&&o.jsx("div",{className:"flex gap-0.5 select-none",children:u.map(($,E)=>{const T=g.length-1,b=Math.max(1,Math.ceil(g.length/8)),M=E%b===0||E===T,H=E===0?"justify-start":E===T?"justify-end":"justify-center";return o.jsx("div",{className:Xe("flex-1 min-w-0 flex",H),children:M&&o.jsx("span",{className:"text-[9px] text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap font-mono",children:W0($,_)})},E)})}),t&&n&&o.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:[o.jsx("span",{children:t===n?`${t} 00:00`:t}),o.jsx("span",{children:t===n?`${n} 24:00`:n})]})]}),k&&o.jsxs("div",{className:"absolute z-[9999] w-0 h-0 transition-all duration-100 ease-out pointer-events-none",style:{left:`${D.x}px`,top:`${D.y}px`},children:[o.jsxs("div",{className:Xe("absolute left-0 backdrop-blur-md bg-white/95 dark:bg-oai-gray-900/95 border border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-xl rounded-xl p-3.5 max-w-[280px] min-w-[220px] flex flex-col gap-2 animate-in fade-in zoom-in-95 duration-100",D.flipDown?"top-[10px]":"bottom-[10px]"),style:{transform:`translateX(calc(-50% + ${D.shiftX}px))`},children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-oai-gray-100 dark:border-oai-gray-800/80 pb-1.5",children:[o.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400",children:k.timeLabel}),k.kind==="predicted"&&o.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500",children:"Predicted"}),k.kind==="unsynced"&&o.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500",children:"Unsynced"})]}),o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsxs("div",{className:"flex items-baseline gap-1",children:[o.jsx("span",{className:"text-lg font-bold text-oai-gray-900 dark:text-white leading-none",children:k.kind==="predicted"||k.kind==="unsynced"?`~${Math.round(k.displayValue??0).toLocaleString()}`:k.value.toLocaleString()}),o.jsx("span",{className:"text-[10px] text-oai-gray-400 uppercase tracking-wider font-semibold",children:"Tokens"})]}),d&&(k.row?.total_cost_usd!=null||Number(k.row?.conversation_count)>0)&&o.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:[k.row?.total_cost_usd!=null&&o.jsxs("span",{children:[o.jsx("span",{className:"font-semibold text-oai-gray-700 dark:text-oai-gray-200",children:et(k.row.total_cost_usd,{currency:v,rate:w})})," ",y("trend.zoom.tooltip.cost")]}),Number(k.row?.conversation_count)>0&&o.jsxs("span",{children:[o.jsx("span",{className:"font-semibold text-oai-gray-700 dark:text-oai-gray-200",children:Number(k.row.conversation_count).toLocaleString()})," ",y("trend.zoom.tooltip.conversations")]})]}),k.segments&&k.segments.length>0?o.jsxs("div",{className:"mt-1.5 border-t border-oai-gray-100 dark:border-oai-gray-800/60 pt-2 flex flex-col gap-1.5",children:[o.jsx("div",{className:"text-[10px] font-semibold text-oai-gray-400 dark:text-oai-gray-500 uppercase tracking-wider",children:k.segments[0].type==="model"?"Model Breakdown":"Token Breakdown"}),o.jsx("div",{className:"flex flex-col gap-2 max-h-[150px] overflow-y-auto pr-1.5 oai-scrollbar",children:k.segments.map(({name:$,value:E,type:T})=>{const b=k.value||1,M=Math.round(E/b*100),H=T==="token_type"?Ho[$]:Uo($);return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center justify-between text-[11px] gap-3",children:[o.jsx("span",{className:"font-medium text-oai-gray-750 dark:text-oai-gray-200 truncate max-w-[130px]",title:$,children:$}),o.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[o.jsx("span",{className:"font-mono text-oai-gray-900 dark:text-oai-gray-100 font-semibold",children:E.toLocaleString()}),o.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[M,"%"]})]})]}),o.jsx("div",{className:"w-full h-1 bg-oai-gray-100 dark:bg-oai-gray-800/85 rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${M}%`,backgroundColor:H,boxShadow:`0 0 4px ${H}55`}})})]},$)})})]}):null]})]}),o.jsx("div",{className:Xe("absolute left-0 -translate-x-1/2 w-2.5 h-2.5 rotate-45 bg-white dark:bg-oai-gray-900 border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-sm",D.flipDown?"top-[6px] border-l border-t":"bottom-[6px] border-r border-b"),style:D.flipDown?{marginTop:"1px"}:{marginBottom:"1px"}})]}),L&&f&&o.jsx(L0,{zoomConfig:f,period:a,from:t,to:n,timeZoneLabel:r,onClose:()=>P(!1),renderChart:$=>o.jsx(Vo,{embedded:!0,isZoom:!0,chartHeightClass:"h-full",...$})})]})}const $r="widgetOnboardingDismissed",Wr="tokentracker_native_app",K0=(()=>{try{return new URLSearchParams(window.location.search).get("app")==="1"?(localStorage.setItem(Wr,"1"),!0):localStorage.getItem(Wr)==="1"}catch{return!1}})();function G0({enterDelay:e=0}){const[t,n]=m.useState(()=>{try{return localStorage.getItem($r)==="1"}catch{return!1}}),a=m.useCallback(()=>{n(!0);try{localStorage.setItem($r,"1")}catch{}},[]);return!K0||oi()?null:o.jsx(Hr,{initial:!1,children:!t&&o.jsxs(ht.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:e,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:[o.jsx("button",{type:"button",onClick:a,"aria-label":y("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:o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:o.jsx("path",{d:"M4 4l6 6m0-6L4 10",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}),o.jsx("div",{className:"rounded-lg overflow-hidden ring-1 ring-black/5 dark:ring-white/10 shadow-sm",children:o.jsx("img",{src:"/widgets-overview.png",alt:y("dashboard.widgets.title"),width:734,height:552,className:"w-full h-auto block",loading:"lazy",decoding:"async"})}),o.jsxs("div",{className:"mt-4",children:[o.jsx("div",{className:"text-sm font-medium tracking-tight text-oai-gray-900 dark:text-oai-white",children:y("dashboard.widgets.title")}),o.jsx("div",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1 leading-snug",children:y("dashboard.widgets.hint")})]})]},"widget-onboarding-card")})}function Q0(e){const{copy:t,screenshotMode:n,screenshotTitleLine1:a,screenshotTitleLine2:r,identityDisplayName:s,identityStartDate:l,activeDays:i,identitySubscriptions:c,identityScrambleDurationMs:d,projectUsageEntries:f,projectUsageLimit:u,setProjectUsageLimit:h,pulse:g,pulseComparedAtLabel:p,isLocalMode:x,trendRowsForDisplay:v,trendFromForDisplay:w,trendToForDisplay:_,trendZoomConfig:k,usageFrom:N,usageTo:D,period:j,trendTimeZoneLabel:L,activityHeatmapBlock:P,periodsForDisplay:C,setSelectedPeriod:I,autoRefreshOptions:K,autoRefreshIntervalMs:V,onAutoRefreshIntervalChange:$,customFrom:E,customTo:T,onCustomRangeApply:b,customRangeOpen:M,onCustomRangeOpenChange:H,summaryLabel:S,summaryValue:X,summaryUpdatedAtLabel:F,summaryCostValue:z,usageInsights:B,costInfoEnabled:Z,openCostModal:xe,costModalOpen:je,closeCostModal:Me,allowBreakdownToggle:Se,refreshAll:J,usageLoadingState:De,dataHealthMessage:le,fleetData:de,usageLimits:W,limitDisplayMode:te,hasDetailsActual:ge,dailyEmptyPrefix:me,installSyncCmd:Ne,dailyEmptySuffix:Fe,detailsColumns:Te,ariaSortFor:A,toggleSort:Y,sortIconFor:U,pagedDetails:q,dailyBreakdownRows:ne,dailyBreakdownColumns:se,dailyBreakdownAriaSortFor:ye,dailyBreakdownSortIconFor:fe,dailyBreakdownDateKey:he,detailsDateKey:Pe,renderDetailDate:pe,renderDailyBreakdownDate:We,renderDetailCell:Ee,DETAILS_PAGED_PERIODS:Be,detailsPageCount:_t,detailsPage:gt,setDetailsPage:yt}=e,it=null,Mt=null,oe=Array.isArray(de)&&de.some(ae=>va(ae)&&Jt(ae)!==null);return o.jsxs(o.Fragment,{children:[o.jsx(Vi,{bare:!n,hideHeader:n,header:it,footer:n?null:Mt,className:n?"screenshot-mode":"",children:n?o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsx("div",{className:"flex items-start justify-between gap-4",children:o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:"text-3xl md:text-4xl font-semibold text-oai-black dark:text-oai-white tracking-tight leading-none",children:a}),o.jsx("span",{className:"text-2xl md:text-3xl font-semibold text-oai-black dark:text-oai-white tracking-tight leading-none",children:r})]})}),o.jsx(yr,{period:j,periods:C,onPeriodChange:I,autoRefreshOptions:K,autoRefreshIntervalMs:V,onAutoRefreshIntervalChange:$,summaryLabel:S,summaryValue:X,summaryUpdatedAtLabel:F,summaryCostValue:z,usageInsights:B,onCostInfo:Z?xe:null,onRefresh:n?null:J,loading:De,customFrom:E,customTo:T,onCustomRangeApply:b,customRangeOpen:M,onCustomRangeOpenChange:H}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-6 gap-4",children:[o.jsx("div",{className:"lg:col-span-2 min-w-0",children:o.jsx(Ja,{rankLabel:l??t("identity_card.rank_placeholder"),streakDays:i,subscriptions:c})}),P?o.jsx("div",{className:"lg:col-span-4 min-w-0",children:P}):null,o.jsx("div",{className:"lg:col-span-6 min-w-0",children:o.jsx(_r,{fleetData:de,from:N,to:D,usageLimits:W,limitDisplayMode:te})})]})]}):o.jsxs("div",{className:"flex flex-col gap-4",children:[le?o.jsx(bt,{delay:.08,children:o.jsx("div",{className:"rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 py-3 text-sm text-oai-gray-700 dark:border-oai-gray-800 dark:bg-oai-gray-900/70 dark:text-oai-gray-300",children:le})}):null,o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-6 gap-4",children:[o.jsx("div",{className:"lg:col-span-3 min-w-0",children:o.jsx(bt,{delay:.05,className:"h-full",children:o.jsx(yr,{period:j,periods:C,onPeriodChange:I,autoRefreshOptions:K,autoRefreshIntervalMs:V,onAutoRefreshIntervalChange:$,summaryLabel:S,summaryValue:X,summaryUpdatedAtLabel:F,summaryCostValue:z,usageInsights:B,onCostInfo:Z?xe:null,onRefresh:n?null:J,loading:De,customFrom:E,customTo:T,onCustomRangeApply:b,customRangeOpen:M,onCustomRangeOpenChange:H,emphasized:!0})})}),o.jsx("div",{className:"lg:col-span-3 min-w-0",children:o.jsx(bt,{delay:.09,children:o.jsx(Vo,{rows:v,from:w,to:_,period:j,timeZoneLabel:L,showTimeZoneLabel:!1,zoomConfig:k})})}),o.jsx("div",{className:"lg:col-span-2 min-w-0",children:o.jsx(bt,{delay:.13,children:o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsx(Ec,{pulse:g,period:j,comparedAtLabel:p}),o.jsx(Ja,{rankLabel:l??t("identity_card.rank_placeholder"),streakDays:i,subscriptions:c})]})})}),o.jsx("div",{className:"lg:col-span-4 min-w-0",children:o.jsx(bt,{delay:.19,children:o.jsx(_r,{fleetData:de,from:N,to:D,showInlineContext:!1,usageLimits:W,limitDisplayMode:te})})}),P?o.jsx("div",{className:oe?"lg:col-span-2 min-w-0":"lg:col-span-6 min-w-0",children:o.jsx(bt,{delay:.25,children:P})}):null,oe?o.jsx("div",{className:P?"lg:col-span-4 min-w-0":"lg:col-span-6 min-w-0",children:o.jsx(bt,{delay:.31,children:o.jsx(j0,{fleetData:de,from:N,to:D})})}):null,x?o.jsx("div",{className:"lg:col-span-6",children:o.jsx(G0,{enterDelay:.37})}):null]}),o.jsx(bt,{delay:.43,children:o.jsx(vc,{projectEntries:f,projectLimit:u,onProjectLimitChange:h,copy:t,hasDetailsActual:ge,dailyEmptyPrefix:me,installSyncCmd:Ne,dailyEmptySuffix:Fe,detailsColumns:Te,ariaSortFor:A,toggleSort:Y,sortIconFor:U,pagedDetails:q,dailyBreakdownRows:ne,dailyBreakdownColumns:se,dailyBreakdownAriaSortFor:ye,dailyBreakdownSortIconFor:fe,dailyBreakdownDateKey:he,detailsDateKey:Pe,renderDetailDate:pe,renderDailyBreakdownDate:We,renderDetailCell:Ee,DETAILS_PAGED_PERIODS:Be,period:j,detailsPageCount:_t,detailsPage:gt,setDetailsPage:yt})})]})}),o.jsx(xc,{isOpen:je,onClose:Me,fleetData:de})]})}const J0=["day","24h","week","month","total","custom"],qo="tt:dashboard-auto-refresh-ms",Zt=3e4,Xo=[{value:0,labelKey:"usage.auto_refresh.off"},{value:3e4,labelKey:"usage.auto_refresh.30s"},{value:6e4,labelKey:"usage.auto_refresh.60s"},{value:12e4,labelKey:"usage.auto_refresh.120s"}],Z0=3e4,eg=6e4,qn=new Set(["day","hour","month"]),Kt=new Set(["day","24h","total","custom"]),tg=new Set(Xo.map(e=>e.value));function Ko(e){if(e==null||e==="")return Zt;const t=Number(e);return Number.isFinite(t)&&tg.has(t)?t:Zt}function ng(){if(typeof window>"u")return Zt;try{return Ko(window.localStorage?.getItem(qo))}catch{return Zt}}function ag(e){const n=(typeof e?.stdout=="string"?e.stdout:"").match(/New 30-min buckets queued:\s*(\d+)/i);return n?Number(n[1])>0:!0}function Xn(e,t){if(typeof t=="number"&&t>0)return!0;if(typeof e=="bigint")return e>0n;if(typeof e=="number")return Number.isFinite(e)&&e>0;if(typeof e=="string"){const n=e.trim();if(!n)return!1;if(/^[0-9]+$/.test(n))try{return BigInt(n)>0n}catch{return!1}const a=Number(n);return Number.isFinite(a)&&a>0}return!1}function pn(e){return e?_n(e,null):null}function Er(e){return e?e?.billable_total_tokens??e?.value??e?.total_tokens:null}function rg(e){if(typeof e!="string"||!e)return null;const t=e.split("-");if(t.length!==3)return null;const n=Number(t[0]),a=Number(t[1])-1,r=Number(t[2]);if(!Number.isFinite(n)||!Number.isFinite(a)||!Number.isFinite(r))return null;const s=new Date(Date.UTC(n,a,r));return Number.isFinite(s.getTime())?s:null}function og(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function bg({baseUrl:e,onMainContentVisible:t}){const{resolvedLocale:n}=si(),{currency:a,rate:r}=Nt(),[s,l]=m.useState(!1),[i,c]=m.useState(null),[d,f]=m.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(max-width: 640px)").matches),u=m.useMemo(()=>typeof window>"u"?!1:ii(window.location.search),[]),h=2200,[g,p]=m.useState(!0),[x,v]=m.useState(!1),[w,_]=m.useState(ng),[k,N]=m.useState(()=>Date.now()),[D,j]=m.useState(()=>Date.now()),L=m.useRef(!1),P=m.useRef(!1),C=m.useRef(0),I=m.useRef(null),K=m.useRef(!1),V=Yt(),$=null,E=!1,T=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");m.useEffect(()=>{if(!T&&!V){c(null);return}let O=!0;return(async()=>{try{const G=await ki({baseUrl:e});if(!O)return;c(G&&typeof G=="object"?G:null)}catch{if(!O)return;c(null)}})(),()=>{O=!1}},[e,T,V]),m.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const O=window.matchMedia("(max-width: 640px)"),G=()=>f(O.matches);return G(),O.addEventListener?(O.addEventListener("change",G),()=>O.removeEventListener("change",G)):(O.addListener(G),()=>O.removeListener(G))},[]);const b=m.useMemo(()=>Vr(),[]),M=m.useMemo(()=>Ur(),[]),H=m.useMemo(()=>di(),[]),S=m.useMemo(()=>H||new Date(k),[k,H]),X="default",[F,z]=m.useState("day"),[B,Z]=m.useState(null),[xe,je]=m.useState(null),[Me,Se]=m.useState(!1),J=u?"total":F,De=m.useMemo(()=>J==="custom"&&B&&xe?{from:B,to:xe}:ui(J,{timeZone:b,offsetMinutes:M,now:S}),[S,J,b,M,B,xe]),le=De.from,de=De.to,W=m.useMemo(()=>fi({timeZone:b,offsetMinutes:M}),[b,M]),te=m.useMemo(()=>mi({timeZone:b,offsetMinutes:M}),[b,M]),ge=m.useMemo(()=>`Local time (${te})`,[te]),me=b,Ne=M,Fe=W,Te=m.useMemo(()=>en({timeZone:b,offsetMinutes:M,date:S}),[S,b,M]),A=m.useMemo(()=>{const O=rg(Te)||new Date,G=og(O,-29);return{from:mt(G),to:mt(O)}},[Te]),{daily:Y,summary:U,rolling:q,source:ne,loading:se,error:ye,refresh:fe}=La({baseUrl:e,accessToken:$,guestAllowed:E,from:le,to:de,includeDaily:J!=="total",cacheKey:X,timeZone:b,tzOffsetMinutes:M,now:S}),{daily:he,loading:Pe,refresh:pe}=La({baseUrl:e,accessToken:$,guestAllowed:E,from:A.from,to:A.to,includeDaily:!0,cacheKey:`${X}.daily-breakdown`,timeZone:b,tzOffsetMinutes:M,now:S}),{breakdown:We,loading:Ee,refresh:Be}=jl({baseUrl:e,accessToken:$,guestAllowed:E,from:le,to:de,cacheKey:X,timeZone:b,tzOffsetMinutes:M}),{pulse:_t,refresh:gt}=Ll({baseUrl:e,accessToken:$,guestAllowed:E,period:J,timeZone:b,tzOffsetMinutes:M,now:S,cacheKey:X}),yt=m.useMemo(()=>{try{return new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit",timeZone:b||void 0}).format(S)}catch{return null}},[S,b]),[it,Mt]=m.useState(10),{entries:oe,loading:ae,refresh:ee}=cl({baseUrl:e,accessToken:$,limit:it,from:le,to:de,timeZone:b,tzOffsetMinutes:M}),ce=J==="week"||J==="month",Ce=J==="week"||J==="month",ie=m.useMemo(()=>Y.filter(O=>O?.future?!1:!O?.day||!Te?!0:String(O.day)<=String(Te)),[Y,Te]),{rows:ze,from:zt,to:Bt,loading:jt,refresh:pt}=Jr({baseUrl:e,accessToken:$,guestAllowed:E,period:J,from:le,to:de,months:24,cacheKey:X,timeZone:me,tzOffsetMinutes:Ne,now:S,sharedRows:ce?Y:null,sharedRange:ce?{from:le,to:de}:null}),Go=m.useMemo(()=>({baseUrl:e,accessToken:$,guestAllowed:E,cacheKey:X,timeZone:me,tzOffsetMinutes:Ne,now:S}),[e,$,E,X,me,Ne,S]),{daily:Ot,heatmap:lt,loading:Qo,refresh:Na}=ll({baseUrl:e,accessToken:$,guestAllowed:E,weeks:52,cacheKey:X,timeZone:b,tzOffsetMinutes:M,now:S}),{data:Ht,refresh:_a}=wi(),{displayMode:Jo}=vi();m.useEffect(()=>{Ht&&typeof Ht=="object"&&li(Ht)},[Ht]);const Ke=m.useMemo(()=>J==="day"||J==="24h"?"hour":J==="total"?"month":"day",[J]),Zo=m.useMemo(()=>Ua(Ke),[Ke]),fn="day",es=m.useMemo(()=>[...Ua(fn),{key:"total_cost_usd",label:y("daily.sort.cost.label"),title:y("daily.sort.cost.title")},{key:"cost_per_million_tokens",label:y("daily.sort.cost_per_mtok.label"),title:y("daily.sort.cost_per_mtok.title")},{key:"top_model",label:y("daily.sort.top_model.label"),title:y("daily.sort.top_model.title")}],[]),[Ge,Ma]=m.useState(()=>({key:"day",dir:"desc"}));m.useEffect(()=>{Ma(O=>!qn.has(O.key)||O.key===Ke?O:{key:Ke,dir:O.dir})},[Ke]);const $t=m.useMemo(()=>qn.has(Ge.key)&&Ge.key!==Ke?{...Ge,key:Ke}:Ge,[Ke,Ge]),mn=m.useMemo(()=>{if(J==="day"||J==="24h")return Array.isArray(ze)?ze.filter(re=>re?.hour&&!re?.future):[];if(J==="total"){const re=Array.isArray(ze)?ze.filter(ue=>ue?.month&&!ue?.future):[];return Ql(re)}const O=ie;return!O.some(re=>!re?.missing&&!re?.future)&&Y.length>0?Y.filter(re=>!re?.future).slice(-30).filter(re=>re?.day):O},[J,ze,ie,Y]),Ut=m.useMemo(()=>Va(mn,$t),[mn,$t]),ts=m.useMemo(()=>mn.some(O=>!O?.missing&&!O?.future),[mn]),Cn=m.useMemo(()=>{if(!Kt.has(J))return 1;const O=Math.ceil(Ut.length/Nn);return O>0?O:1},[J,Ut.length]),[Dn,hn]=m.useState(0);m.useEffect(()=>{if(!Kt.has(J)){hn(0);return}hn(O=>Math.min(O,Cn-1))},[Cn,J]),m.useEffect(()=>{Kt.has(J)&&hn(0)},[J,Ge.dir,Ge.key]);const ns=m.useMemo(()=>Kt.has(J)?Jl(Ut,Dn,Nn):Ut,[Dn,J,Ut]),ja=m.useMemo(()=>oc(he.filter(O=>!O?.future&&O?.day).slice(-30),{fallback:y("shared.placeholder.short")}),[he]),Wt=m.useMemo(()=>qn.has(Ge.key)?{...Ge,key:fn}:Ge,[Ge]),as=m.useMemo(()=>Va(ja,Wt),[ja,Wt]),rs=m.useMemo(()=>Ce?Y:J==="day"||J==="24h"?Array.isArray(ze)?ze.filter(O=>O?.hour):[]:ze,[Y,J,ze,Ce]),os=Ce?le:zt,ss=Ce?de:Bt;function is(O,G){if(O?.future)return"—";if(O?.missing)return y("shared.status.unsynced");if(G==="total_tokens")return Qe(pn(O));if(G==="total_cost_usd")return et(O?.total_cost_usd,{currency:a,rate:r});if(G==="cost_per_million_tokens"){const re=Le(O?.cost_per_million_tokens);return re==null?y("shared.placeholder.short"):et(re,{currency:a,rate:r})}return G==="top_model"?O?.top_model||y("shared.placeholder.short"):Qe(O?.[G])}function ls(O){const G=O?.[Ke];if(G==null)return"";const re=String(G);if(Ke==="hour"){const[ue,Ve]=re.split("T");if(ue&&Ve)return`${ue} ${Ve.slice(0,5)}`}return re}function cs(O){const G=O?.[fn];return G==null?"":String(G)}function ds(O){Ma(G=>G.key===O?{key:O,dir:G.dir==="asc"?"desc":"asc"}:{key:O,dir:"desc"})}function us(O){return $t.key!==O?null:$t.dir==="asc"?"ascending":"descending"}function fs(O){return $t.key!==O?"":$t.dir==="asc"?"▲":"▼"}function ms(O){return Wt.key!==O?null:Wt.dir==="asc"?"ascending":"descending"}function hs(O){return Wt.key!==O?"":Wt.dir==="asc"?"▲":"▼"}const gs=m.useMemo(()=>{if(!V&&!T)return 0;const O=Number(lt?.active_days);if(Number.isFinite(O))return O;let G=0;const re=new Set,ue=($e,Ct,$n)=>{typeof $e!="string"||!$e||re.has($e)||Xn(Ct,$n)&&(re.add($e),G+=1)};if(Array.isArray(Ot))for(const $e of Ot)ue($e?.day,pn($e));const Ve=Array.isArray(lt?.weeks)?lt.weeks:[];for(const $e of Ve)for(const Ct of Array.isArray($e)?$e:[]){const $n=Er(Ct);ue(Ct?.day,$n,Ct?.level)}return G},[V,T,lt?.active_days,lt?.weeks,Ot]),[Sa,Ca]=m.useState("month"),ys=m.useCallback(O=>{O==="custom"?(Ca(G=>G==="custom"?"month":G),z(G=>B&&xe?"custom":G),Se(!0)):(z(O),Ca(O),Se(!1))},[B,xe]),ps=m.useCallback((O,G)=>{Z(O),je(G),z("custom"),Se(!1)},[]),bs=m.useCallback(O=>{Se(O),!O&&F==="custom"&&!B&&z(Sa)},[F,B,Sa]),Vt=m.useCallback(async()=>{const O=Date.now();N(O),await Promise.all([fe(),Na(),pt(),Be(),ee(),pe(),_a(),gt()]),j(O)},[pe,Na,Be,ee,pt,fe,_a,gt]);m.useEffect(()=>{if(u||H||typeof window>"u")return;const O=()=>{const re=new Date,ue=en({timeZone:b,offsetMinutes:M,date:re});if(ue){if(I.current==null){I.current=ue;return}I.current!==ue&&(I.current=ue,N(re.getTime()))}};O();const G=window.setInterval(O,eg);return typeof document<"u"&&document.addEventListener("visibilitychange",O),window.addEventListener("focus",O),()=>{window.clearInterval(G),typeof document<"u"&&document.removeEventListener("visibilitychange",O),window.removeEventListener("focus",O)}},[H,u,b,M]);const xs=m.useCallback(async()=>{v(!0);try{T&&await Fa(),await Vt()}catch(O){console.error("[DashboardPage] Refresh failed:",O)}finally{v(!1)}},[T,Vt]),Da=m.useCallback(()=>!T||P.current?null:(P.current=!0,Fa().then(ag).catch(O=>(console.error("[DashboardPage] Auto sync failed:",O),!1)).finally(()=>{P.current=!1})),[T]),Ta=m.useCallback(async()=>{const O=Da();try{await Vt(),O&&O.then(G=>{if(G)return Vt()})}catch(G){console.error("[DashboardPage] Auto refresh failed:",G)}},[Vt,Da]),ks=m.useCallback(O=>{const G=Ko(O);_(G);try{window.localStorage?.setItem(qo,String(G))}catch{}},[]);m.useEffect(()=>{if(u||typeof window>"u"||w<=0)return;const O=()=>typeof document>"u"||document.visibilityState==="visible",G=async({throttle:Ve=!1}={})=>{if(!O())return;const $e=Date.now();if(!(Ve&&$e-C.current<Z0)&&!L.current){L.current=!0,C.current=$e;try{await Ta()}finally{L.current=!1}}},re=window.setInterval(()=>{G()},w),ue=()=>{G({throttle:!0})};return typeof document<"u"&&document.addEventListener("visibilitychange",ue),window.addEventListener("focus",ue),()=>{window.clearInterval(re),typeof document<"u"&&document.removeEventListener("visibilitychange",ue),window.removeEventListener("focus",ue)}},[w,Ta,u]);const Tn=x||se||Pe||Qo||jt||Ee||ae,ws=m.useMemo(()=>y("shared.data_source",{source:String(ne||"edge").toUpperCase()}),[ne,n]),Pa=y("dashboard.identity.fallback"),vs=m.useMemo(()=>Pa.replace(/[^a-zA-Z0-9._-]/g,"_"),[Pa]),Ns=m.useMemo(()=>{let O=null;const G=ue=>{typeof ue!="string"||!ue||(!O||ue<O)&&(O=ue)};if(Array.isArray(Ot))for(const ue of Ot)ue?.day&&Xn(pn(ue))&&G(ue.day);const re=Array.isArray(lt?.weeks)?lt.weeks:[];for(const ue of re)for(const Ve of Array.isArray(ue)?ue:[]){if(!Ve?.day)continue;const $e=Er(Ve),Ct=Ve?.level;Xn($e,Ct)&&G(Ve.day)}return O},[lt?.weeks,Ot]),_s=m.useMemo(()=>(Array.isArray(i?.subscriptions?.items)?i.subscriptions.items:[]).map(re=>{const ue=typeof re?.tool=="string"?re.tool.trim():"",$e=(typeof re?.plan_type=="string"?re.plan_type:typeof re?.planType=="string"?re.planType:"").trim();return!ue||!$e?null:{tool:ue,planType:$e,provider:typeof re?.provider=="string"?re.provider.trim():"",product:typeof re?.product=="string"?re.product.trim():"",rateLimitTier:typeof re?.rate_limit_tier=="string"?re.rate_limit_tier.trim():typeof re?.rateLimitTier=="string"?re.rateLimitTier.trim():""}}).filter(Boolean).slice(0,6),[i]),Ms=o.jsx(pc,{heatmap:lt,timeZoneLabel:W,timeZoneShortLabel:te,hideLegend:u,defaultToLatestMonth:u}),js=m.useMemo(()=>`${le}..${de}`,[le,J,de]),Ss=y("usage.summary.total"),St=pn(U),Oa=y("shared.unit.thousand_abbrev"),$a=y("shared.unit.million_abbrev"),Wa=y("shared.unit.billion_abbrev"),qt=Le(St),Ea=qt!=null&&(d&&Math.abs(qt)>=1e9||Math.abs(qt)>=1e12),Cs=m.useMemo(()=>Ea?Ae(qt,{thousandSuffix:Oa,millionSuffix:$a,billionSuffix:Wa,decimals:1}):Qe(St),[Wa,$a,St,qt,Oa,Ea]),Ds=m.useMemo(()=>{const O=new Intl.DateTimeFormat(n||void 0,{timeZone:b,year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"short"}).format(new Date(D));return y("usage.summary.updated_at",{timestamp:O})},[D,n,b]),Ts=y("dashboard.core_index.collapse_label"),Ps=y("dashboard.core_index.expand_label"),Os=y("dashboard.core_index.collapse_aria"),$s=y("dashboard.core_index.expand_aria"),Ws=!u,Es=y("dashboard.screenshot.title_line1"),As=y("dashboard.screenshot.title_line2");y("shared.placeholder.short");const Fs=m.useMemo(()=>u?[]:J0,[u]),Rs=m.useMemo(()=>[{label:y("usage.metric.total"),value:Qe(St),valueClassName:"text-white"},{label:y("usage.metric.input"),value:Qe(U?.input_tokens)},{label:y("usage.metric.output"),value:Qe(U?.output_tokens)},{label:y("usage.metric.cached_input"),value:Qe(U?.cached_input_tokens)},{label:y("usage.metric.reasoning_output"),value:Qe(U?.reasoning_output_tokens)}],[U?.cached_input_tokens,U?.input_tokens,U?.output_tokens,U?.reasoning_output_tokens,St]),Pn=m.useMemo(()=>et(U?.total_cost_usd,{currency:a,rate:r}),[U?.total_cost_usd,a,r]),Is=m.useMemo(()=>{if(Number(St||0)>0||se||ye)return null;const G=Number(q?.current_month?.totals?.billable_total_tokens||0),re=Number(q?.last_30d?.totals?.billable_total_tokens||0),ue=Number(q?.last_7d?.totals?.billable_total_tokens||0);return J==="day"&&ue>0?y("dashboard.data_health.day_empty_has_recent",{tokens:Qe(ue)}):(J==="week"||J==="custom")&&re>0?y("dashboard.data_health.period_empty_has_30d",{tokens:Qe(re)}):J==="month"&&G===0&&re>0?y("dashboard.data_health.month_empty_has_30d",{tokens:Qe(re)}):re===0&&q?y("dashboard.data_health.no_recent_data"):null},[J,q,St,ye,se]),Aa=m.useMemo(()=>so(We,{copyFn:y}),[We]),Ls=m.useMemo(()=>ac(We,{copyFn:y}),[We]),Ys=m.useCallback(()=>l(!0),[]),zs=m.useCallback(()=>l(!1),[]),Bs=Pn&&Pn!=="-"&&Aa.length>0,Hs=y("dashboard.install.cmd.sync"),On=m.useMemo(()=>y("dashboard.daily.empty",{cmd:"{{cmd}}"}),[n]),[Us,Vs]=m.useMemo(()=>{const O=On.split("{{cmd}}");return O.length===1?[On,""]:[O[0],O.slice(1).join("{{cmd}}")]},[On]);return m.useEffect(()=>{K.current||Tn||(K.current=!0,t?.())},[t,Tn]),o.jsx(Q0,{copy:y,screenshotMode:u,screenshotTitleLine1:Es,screenshotTitleLine2:As,identityDisplayName:vs,identityStartDate:Ns,activeDays:gs,identitySubscriptions:_s,identityScrambleDurationMs:h,projectUsageEntries:oe,projectUsageLimit:it,setProjectUsageLimit:Mt,pulse:_t,pulseComparedAtLabel:yt,isLocalMode:T,trendRowsForDisplay:rs,trendFromForDisplay:os,trendToForDisplay:ss,trendZoomConfig:Go,usageFrom:le,usageTo:de,period:J,trendTimeZoneLabel:Fe,activityHeatmapBlock:Ms,periodsForDisplay:Fs,setSelectedPeriod:ys,autoRefreshOptions:Xo,autoRefreshIntervalMs:w,onAutoRefreshIntervalChange:ks,customFrom:B,customTo:xe,onCustomRangeApply:ps,customRangeOpen:Me,onCustomRangeOpenChange:bs,metricsRows:Rs,summaryLabel:Ss,summaryValue:Cs,summaryUpdatedAtLabel:Ds,summaryCostValue:Pn,usageInsights:Ls,costInfoEnabled:Bs,openCostModal:Ys,allowBreakdownToggle:Ws,coreIndexCollapsed:g,setCoreIndexCollapsed:p,coreIndexCollapseLabel:Ts,coreIndexExpandLabel:Ps,coreIndexCollapseAria:Os,coreIndexExpandAria:$s,refreshAll:xs,usageLoadingState:Tn,usageError:ye,dataHealthMessage:Is,rangeLabel:js,timeZoneRangeLabel:ge,usageSourceLabel:ws,fleetData:Aa,usageLimits:Ht,limitDisplayMode:Jo,hasDetailsActual:ts,dailyEmptyPrefix:Us,installSyncCmd:Hs,dailyEmptySuffix:Vs,detailsColumns:Zo,ariaSortFor:us,toggleSort:ds,sortIconFor:fs,pagedDetails:ns,dailyBreakdownRows:as,dailyBreakdownColumns:es,dailyBreakdownAriaSortFor:ms,dailyBreakdownSortIconFor:hs,dailyBreakdownDateKey:fn,detailsDateKey:Ke,renderDetailDate:ls,renderDailyBreakdownDate:cs,renderDetailCell:is,DETAILS_PAGED_PERIODS:Kt,detailsPageCount:Cn,detailsPage:Dn,setDetailsPage:hn,costModalOpen:s,closeCostModal:zs})}export{bg as DashboardPage};
|