@ipv9/tokentracker-cli 0.39.44 → 0.39.45
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/dashboard/dist/assets/{Card-C_H8B1rI.js → Card-2-TQg7P7.js} +1 -1
- package/dashboard/dist/assets/DashboardPage-yb9ss9uE.js +60 -0
- package/dashboard/dist/assets/{FadeIn-BE8I9B4-.js → FadeIn-BOc6XtOK.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-DQ9gR343.js → IpCheckPage-C2tIb68P.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-Balfhw3-.js → LimitsPage-BsuLQ9co.js} +1 -1
- package/dashboard/dist/assets/{LocalOnlyNotice-hxi161Wl.js → LocalOnlyNotice-C8R9KLef.js} +1 -1
- package/dashboard/dist/assets/{PopoverPopup-B4zbh-jA.js → PopoverPopup-BpfseoI7.js} +1 -1
- package/dashboard/dist/assets/{Select-DLYT4NCO.js → Select-Ctk8zze5.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-DUyZrDnS.js → SelectItemText-BKZlFyFs.js} +1 -1
- package/dashboard/dist/assets/{SettingsPage-BySJoulk.js → SettingsPage-CQXM8qGU.js} +1 -1
- package/dashboard/dist/assets/{SkillsPage-DpiMLTPo.js → SkillsPage-4EMm0eBX.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-C6je8upG.js → WidgetsPage-C2sdX5g6.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-ByarX-vY.js → WrappedPage-CLiuEcQZ.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-C-WAJGZ8.js → arrow-up-right-BDkp93DX.js} +1 -1
- package/dashboard/dist/assets/{download-BhOg_qb4.js → download-DZ6SoCSn.js} +1 -1
- package/dashboard/dist/assets/{format-Co2okzG-.js → format-CaW9kvsA.js} +1 -1
- package/dashboard/dist/assets/limitDisplay-DNU_w4O7.js +1 -0
- package/dashboard/dist/assets/{main-q9UoIq7C.js → main-DgyymGht.js} +7 -3
- package/dashboard/dist/assets/{mock-data-0XiGBeUV.js → mock-data-D6C7Fba3.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-DmEIJPtg.js → use-limits-display-prefs-B7cHBa7Y.js} +1 -1
- package/dashboard/dist/assets/{use-native-settings-QLM3Sd2C.js → use-native-settings-BKAzGuxw.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-Dtize6Tx.js → useCurrency-BVr6Ajuu.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/commands/doctor.js +6 -0
- package/src/lib/doctor.js +164 -10
- package/src/lib/local-api.js +79 -20
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/process-list.js +91 -0
- package/src/lib/rollout.js +5 -2
- package/src/lib/single-flight.js +59 -0
- package/src/lib/transcript-suppression.js +133 -0
- package/src/lib/usage-limits.js +79 -19
- package/dashboard/dist/assets/DashboardPage-DOa3N76u.js +0 -60
- package/dashboard/dist/assets/limitDisplay-CPMQA7lm.js +0 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import{c as rn,i as oi,f as Ur,a as Vr,J as si,u as qr,m as ii,r as h,M as Xr,b as li,d as ci,e as Fn,j as o,L as di,g as ui,h as fi,k as mi,l as hi,n as zt,o as gt,p as y,q as Gr,X as da,s as gi,R,t as ua,C as Kr,P as fa,B as Jn,v as Qr,w as Jr,A as Zr,x as Xe,y as yi,z as pi,D as bi,E as xi,F as ki}from"./main-DgyymGht.js";import{g as wi,i as Yt,b as Zn,c as pn,a as on,d as tn,f as ht,e as eo,h as to,j as vi,k as Ni,l as _i,m as Mi}from"./mock-data-D6C7Fba3.js";import{g as ji,a as Cn,b as Si,c as Ci,d as no,e as Rn,f as Di,h as Ti,L as Pi,i as Oi,j as $i,u as Ei,t as Ua}from"./limitDisplay-DNU_w4O7.js";import{u as Wi}from"./use-limits-display-prefs-B7cHBa7Y.js";import{u as _t,I as ma}from"./useCurrency-BVr6Ajuu.js";import{t as Le,f as et,a as Ae,b as Qe}from"./format-CaW9kvsA.js";import{u as Ai,D as Fi,a as Ri,b as Ii,c as Li,d as zi,e as Yi,P as ea,f as ta,g as na,h as aa,i as ra,L as Bi}from"./PopoverPopup-BpfseoI7.js";import{C as sn}from"./Card-2-TQg7P7.js";import{S as Hi}from"./Select-Ctk8zze5.js";import{F as ct}from"./FadeIn-BOc6XtOK.js";import"./SelectItemText-BKZlFyFs.js";const Ui=[["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"}]],ao=rn("maximize-2",Ui);const Vi=[["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"}]],qi=rn("pause",Vi);const Xi=[["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"}]],Gi=rn("play",Xi);const Ki=[["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"}]],Qi=rn("rotate-ccw",Ki);const Ji=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],ro=rn("terminal",Ji);function Zi(...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=oi(r,s,l);return t?i(a):i}function el(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 d=Va(e.get()),m=Va(s);if(d===m){c();return}const g=r?r.getGeneratorVelocity():e.getVelocity();c(),r=new si({keyframes:[d,m],velocity:g,type:"spring",restDelta:.001,restSpeed:.01,...n,onUpdate:l})},f=()=>{u(),e.animation=r??void 0,e.events.animationStart?.notify(),r?.then(()=>{e.animation=void 0,e.events.animationComplete?.notify()})};if(e.attach((d,m)=>{s=d,l=g=>m(In(g,i)),Ur.postRender(f)},c),Vr(t)){let d=n.skipInitialAnimation===!0;const m=t.on("change",p=>{d?(d=!1,e.jump(In(p,i),!1)):e.set(In(p,i))}),g=e.on("destroy",m);return()=>{m(),g()}}return c}function In(e,t){return t?e+t:e}function Va(e){return typeof e=="number"?e:parseFloat(e)}function ha(e){const t=qr(()=>ii(e)),{isStatic:n}=h.useContext(Xr);if(n){const[,a]=h.useState(e);h.useEffect(()=>t.on("change",a),[])}return t}function oo(e,t){const n=ha(t()),a=()=>n.set(t());return a(),li(()=>{const r=()=>Ur.preRender(a,!1,!0),s=e.map(l=>l.on("change",r));return()=>{s.forEach(l=>l()),ci(a)}}),n}function tl(e){Fn.current=[],e();const t=oo(Fn.current,e);return Fn.current=void 0,t}function so(e,t,n,a){if(typeof e=="function")return tl(e);const s=typeof t=="function"?t:Zi(t,n,a),l=Array.isArray(e)?qa(e,s):qa([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 qa(e,t){const n=qr(()=>[]);return oo(e,()=>{n.length=0;const a=e.length;for(let r=0;r<a;r++)n[r]=e[r].get();return t(n)})}function nl(e,t={}){const{isStatic:n}=h.useContext(Xr),a=()=>Vr(e)?e.get():e;if(n)return so(a);const r=ha(a());return h.useInsertionEffect(()=>el(r,e,t),[r,JSON.stringify(t)]),r}function al(e,t={}){return nl(e,{type:"spring",...t})}function rl(){return o.jsxs(di,{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 ol({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(rl,{}),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 sl({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 il=h.forwardRef(function(t,n){const{render:a,className:r,disabled:s=!1,nativeButton:l=!0,...i}=t,{store:c}=Ai(),u=c.useState("open");function f(p){u&&c.setOpen(!1,mi(hi,p.nativeEvent))}const{getButtonProps:d,buttonRef:m}=ui({disabled:s,native:l}),g=h.useMemo(()=>({disabled:s}),[s]);return fi("button",t,{state:g,ref:[n,m],props:[{onClick:f},i,d]})});var ll={};function cl(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 dl({mv:e,digit:t,height:n}){const a=so(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(gt.span,{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",y:a},children:t})}function ul(e){const t=Math.round(e),n=1e-9*Math.max(1,Math.abs(e));return Math.abs(e-t)<n?t:e}function fl(e,t){const n=e/t;return Math.floor(ul(n))}function ml(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 hl({place:e,value:t,height:n,digitStyle:a,shouldReduceMotion:r,isLed:s}){if(typeof e!="number"){const u=cl(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=fl(t,e),i=ha(0),c=al(i,{stiffness:220,damping:26,mass:.8});return h.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,f)=>o.jsx(dl,{mv:c,digit:f,height:n},f))})}function gl({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:f,counterStyle:d,digitStyle:m,gradientHeight:g=14,gradientFrom:p="rgba(255,255,255,0.95)",gradientTo:b="rgba(255,255,255,0)",topGradientStyle:v,bottomGradientStyle:k,variant:j="default"}){const x=j==="led",N=String(t??e??""),C=h.useMemo(()=>Array.isArray(r)&&r.length?r:ml(N),[r,N]),T=typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent||"")||typeof process<"u"&&ll?.VITEST==="true",z=zt()||T,$=Number.isFinite(Number(e))?Math.abs(Number(e)):0,D=n+a;return z?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,...f,...d},children:x?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: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,...d},children:C.map((A,K)=>o.jsx(hl,{place:A,value:$,height:D,digitStyle:m,shouldReduceMotion:z,isLed:x},`${String(A)}-${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}, ${b})`}}),o.jsx("span",{style:k??{height:g,background:`linear-gradient(to top, ${p}, ${b})`}})]})]})}var yl={};const pl=new Set([",","."," "]),bl=typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent||"")||typeof process<"u"&&yl?.VITEST==="true";function xl({char:e,reduceMotion:t,index:n}){const[a,r]=h.useState(t?e:""),[s,l]=h.useState(!1),i=h.useRef(e),c=h.useRef(!1);return h.useEffect(()=>{if(!c.current){if(c.current=!0,i.current=e,t){r(e);return}const d=Math.min(n*45,520),m=setTimeout(()=>l(!0),d),g=setTimeout(()=>r(e),d+130),p=setTimeout(()=>l(!1),d+300);return()=>{clearTimeout(m),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),f=setTimeout(()=>l(!1),300);return()=>{clearTimeout(u),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 kl({value:e,fontSize:t=56,className:n=""}){const a=zt()||bl,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)=>pl.has(l)?o.jsx("span",{className:"tt-flap-sep","aria-hidden":"true",children:l},i):o.jsx(xl,{char:l,reduceMotion:a,index:i},i))})}function wl({baseUrl:e,accessToken:t,guestAllowed:n=!1,weeks:a=52,weekStartsOn:r="sun",cacheKey:s,timeZone:l,tzOffsetMinutes:i,now:c}={}){const u=h.useMemo(()=>wi({weeks:a,weekStartsOn:r,now:c}),[c,a,r]),[f,d]=h.useState([]),[m,g]=h.useState(null),[p,b]=h.useState("edge"),[v,k]=h.useState(!1),[j,x]=h.useState(null),N=Yt(),C=!n,T=h.useMemo(()=>{if(!s)return null;const B=on({timeZone:l,offsetMinutes:i});return`tokentracker.heatmap.${s}.${a}.${r}.${B}`},[s,l,i,a,r]),z=h.useCallback(()=>{if(!T||typeof window>"u")return null;try{const B=window.localStorage.getItem(T);if(!B)return null;const E=JSON.parse(B);return!E||!E.heatmap?null:E}catch{return null}},[T]),$=h.useCallback(B=>{if(!(!T||typeof window>"u"))try{window.localStorage.setItem(T,JSON.stringify(B))}catch{}},[T]),D=h.useCallback(()=>{if(!(!T||typeof window>"u"))try{window.localStorage.removeItem(T)}catch{}},[T]),A=h.useCallback(async()=>{k(!0),x(null);try{try{const H=await ji({baseUrl:e,accessToken:t,weeks:a,to:u.to,weekStartsOn:r,timeZone:l,tzOffsetMinutes:i}),_=Array.isArray(H?.weeks)?H.weeks:[];if(!_.length&&C){const I=z();if(I?.heatmap){g(I.heatmap),d(I.daily||[]),b("cache");return}}if(!_.some(I=>(Array.isArray(I)?I:[]).some(M=>M&&Number.isFinite(Number(M.level))))&&_.length){const I=[];for(const J of _)for(const P of Array.isArray(J)?J:[])P?.day&&I.push({day:P.day,conversation_count:P.conversation_count??0,total_tokens:P.total_tokens??P.value??0,billable_total_tokens:P.billable_total_tokens??P.value??P.total_tokens??0});const M=Zn({dailyRows:I,weeks:a,to:H?.to||u.to,weekStartsOn:r});d(I),g({...M,week_starts_on:r,active_days:I.filter(J=>Number(J?.billable_total_tokens??J?.total_tokens)>0).length,streak_days:pn({dailyRows:I,to:H?.to||u.to})}),b("client"),C?$({heatmap:{...M,week_starts_on:r,active_days:I.filter(J=>Number(J?.billable_total_tokens??J?.total_tokens)>0).length,streak_days:pn({dailyRows:I,to:H?.to||u.to})},daily:I,fetchedAt:new Date().toISOString()}):D();return}g(H||null),d([]),b("edge"),H&&C?$({heatmap:H,daily:[],fetchedAt:new Date().toISOString()}):C||D();return}catch(H){const _=H,w=_?.status??_?.statusCode;if(w===401||w===403)throw H}const B=await Cn({baseUrl:e,accessToken:t,from:u.from,to:u.to,timeZone:l,tzOffsetMinutes:i}),E=Array.isArray(B?.data)?B.data:[];d(E);const W=Zn({dailyRows:E,weeks:a,to:u.to,weekStartsOn:r});g({...W,week_starts_on:r,active_days:E.filter(H=>Number(H?.billable_total_tokens??H?.total_tokens)>0).length,streak_days:pn({dailyRows:E,to:u.to})}),b("client"),C?$({heatmap:{...W,week_starts_on:r,active_days:E.filter(H=>Number(H?.billable_total_tokens??H?.total_tokens)>0).length,streak_days:pn({dailyRows:E,to:u.to})},daily:E,fetchedAt:new Date().toISOString()}):D()}catch(B){if(C){const E=z();if(E?.heatmap)g(E.heatmap),d(E.daily||[]),b("cache"),x(null);else{const W=B;x(W?.message||String(W)),d([]),g(null),b("edge")}}else{const E=B;x(E?.message||String(E)),d([]),g(null),b("edge")}}finally{k(!1)}},[t,e,N,n,C,u.from,u.to,z,l,i,r,a,D,$]);return h.useEffect(()=>{if(!C)D(),d([]),x(null),g(null),b("edge");else{const B=z();B?.heatmap&&(g(B.heatmap),d(B.daily||[]),b("cache"))}A()},[t,N,z,A,n,C,D]),{range:u,daily:f,heatmap:m,source:N?"mock":p==="client"?"edge":p,loading:v,error:j,refresh:A}}function vl({baseUrl:e,accessToken:t,limit:n=3,from:a,to:r,source:s,timeZone:l,tzOffsetMinutes:i}={}){const[c,u]=h.useState([]),[f,d]=h.useState([]),[m,g]=h.useState(!1),[p,b]=h.useState(null),v=h.useCallback(async()=>{g(!0),b(null);try{const k=await Si({baseUrl:e,accessToken:t,limit:n,from:a,to:r,source:s,timeZone:l,tzOffsetMinutes:i});u(Array.isArray(k?.entries)?k.entries:[]),d(Array.isArray(k?.unattributed_sources)?k.unattributed_sources:[])}catch(k){const j=k?.message||String(k);b(j),u([]),d([])}finally{g(!1)}},[t,e,a,n,s,l,r,i]);return h.useEffect(()=>{v()},[v]),{entries:c,unattributedSources:f,loading:m,error:p,refresh:v}}const Nl=24;function io({baseUrl:e,accessToken:t,guestAllowed:n=!1,period:a,from:r,to:s,months:l=Nl,cacheKey:i,timeZone:c,tzOffsetMinutes:u,now:f,sharedRows:d,sharedRange:m}={}){const[g,p]=h.useState([]),[b,v]=h.useState(()=>({from:r,to:s})),[k,j]=h.useState("edge"),[x,N]=h.useState(null),[C,T]=h.useState(!1),[z,$]=h.useState(null),D=Yt(),A=!n&&!D,K=Array.isArray(d),B=m?.from||r,E=m?.to||s,W=h.useMemo(()=>a==="day"||a==="24h"?"hourly":a==="total"?"monthly":"daily",[a]),H=(()=>{if(!i)return null;const P=_l(e)||"default",L=on({timeZone:c,offsetMinutes:u});if(W==="hourly"){const q=a==="24h"?`${r||""}.${s||""}`:s||r||"day";return`tokentracker.trend.${i}.${P}.hourly.${q}.${L}`}if(W==="monthly")return`tokentracker.trend.${i}.${P}.monthly.${l}.${s||"today"}.${L}`;const V=`${r||""}.${s||""}`;return`tokentracker.trend.${i}.${P}.daily.${V}.${L}`})(),_=h.useCallback(()=>{if(!H||typeof window>"u")return null;try{const P=window.localStorage.getItem(H);if(!P)return null;const L=JSON.parse(P);return!L||!Array.isArray(L.rows)?null:L}catch{return null}},[H]),w=h.useCallback(P=>{if(!(!H||typeof window>"u"))try{window.localStorage.setItem(H,JSON.stringify(P))}catch{}},[H]),I=h.useCallback(()=>{if(!(!H||typeof window>"u"))try{window.localStorage.removeItem(H)}catch{}},[H]),M=h.useCallback(async()=>{if(K){p(Array.isArray(d)?d:[]),v({from:B,to:E}),j("shared"),N(null),T(!1),$(null);return}T(!0),$(null);try{let P;W==="hourly"?P=await Ml({baseUrl:e,accessToken:t,from:r,to:s,period:a,timeZone:c,tzOffsetMinutes:u,now:f}):W==="monthly"?P=await Ci({baseUrl:e,accessToken:t,months:l,to:s,timeZone:c,tzOffsetMinutes:u}):P=await Cn({baseUrl:e,accessToken:t,from:r,to:s,timeZone:c,tzOffsetMinutes:u});const L=P?.from||r||P?.day||null,V=P?.to||s||P?.day||null;let q=Array.isArray(P?.data)?P.data:[];W==="daily"?q=Ln(q,L||r,V||s,{timeZone:c,offsetMinutes:u,now:f}):W==="hourly"?q=wn(q,L||r||P?.day,V||s,{period:a,timeZone:c,offsetMinutes:u,now:f}):W==="monthly"&&(q=zn(q,{timeZone:c,offsetMinutes:u,now:f}));const fe=new Date().toISOString();p(q),v({from:L,to:V}),j("edge"),N(fe),A?w({rows:q,from:L,to:V,mode:W,fetchedAt:fe}):I()}catch(P){if(A){const L=_();if(L?.rows){let V=W==="daily"?Ln(L.rows||[],L.from||r,L.to||s,{timeZone:c,offsetMinutes:u,now:f}):W==="hourly"?wn(L.rows||[],L.from||r||L.day||s,L.to||s,{period:a,timeZone:c,offsetMinutes:u,now:f}):Array.isArray(L.rows)?L.rows:[];W==="monthly"&&(V=zn(V,{timeZone:c,offsetMinutes:u,now:f})),p(V),v({from:L.from||r,to:L.to||s}),j("cache"),N(L.fetchedAt||null),$(null)}else{p([]),v({from:r,to:s}),j("edge"),N(null);const V=P;$(V?.message||String(V))}}else{p([]),v({from:r,to:s}),j("edge"),N(null);const L=P;$(L?.message||String(L))}}finally{T(!1)}},[t,e,r,D,n,A,W,l,a,_,K,B,d,E,c,s,u,f,I,w]);h.useEffect(()=>{if(K){p(Array.isArray(d)?d:[]),v({from:B,to:E}),j("shared"),N(null),T(!1),$(null);return}if(!A)I(),p([]),v({from:r,to:s}),$(null),j("edge"),N(null);else{const P=_();if(P?.rows){let L=W==="daily"?Ln(P.rows||[],P.from||r,P.to||s,{timeZone:c,offsetMinutes:u,now:f}):W==="hourly"?wn(P.rows||[],P.from||r||P.day||s,P.to||s,{period:a,timeZone:c,offsetMinutes:u,now:f}):Array.isArray(P.rows)?P.rows:[];W==="monthly"&&(L=zn(L,{timeZone:c,offsetMinutes:u,now:f})),p(L),v({from:P.from||r,to:P.to||s}),j("cache"),N(P.fetchedAt||null)}}M()},[t,D,_,M,K,B,d,E,n,A,I,W,r,s,c,u,f,a]);const J=D?"mock":k;return{rows:g,from:b.from||r,to:b.to||s,source:J,fetchedAt:x,loading:C,error:z,refresh:M}}function _l(e){try{return new URL(e).host}catch{return null}}async function Ml({baseUrl:e,accessToken:t,from:n,to:a,period:r,timeZone:s,tzOffsetMinutes:l,now:i}){const c=r==="24h"?lo(n,a):[a||n].filter(Boolean),u=Array.from(new Set(c)),f=await Promise.all(u.map(p=>no({accessToken:t,day:p,timeZone:s,tzOffsetMinutes:l}))),d=f.flatMap(p=>Array.isArray(p?.data)?p.data:[]),m=r==="24h"?u[0]||n||a:f[0]?.day||n||a,g=r==="24h"?u[u.length-1]||a||n:f[0]?.day||a||n;return{day:g,from:m,to:g,data:wn(d,m,g,{period:r,timeZone:s,offsetMinutes:l,now:i})}}function Lt(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())&&ht(l)===t?l:null}function ga(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function lo(e,t){const n=Lt(e||t),a=Lt(t||e);if(!n||!a)return[e||t].filter(Boolean).map(String);if(a<n)return[ht(a),ht(n)];const r=[];for(let s=n;s<=a;s=ga(s,1))r.push(ht(s));return r}const co=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens","conversation_count"];function Ln(e,t,n,{timeZone:a,offsetMinutes:r,now:s}={}){const l=Lt(t),i=Lt(n);if(!l||!i||i<l)return Array.isArray(e)?e:[];const c=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,u=tn({timeZone:a,offsetMinutes:r,date:c}),f=Lt(u),d=f?f.getTime():c.getTime(),m=new Map;for(const p of e||[])p?.day&&m.set(p.day,p);const g=[];for(let p=l;p<=i;p=ga(p,1)){const b=ht(p),v=m.get(b),k=p.getTime()>d;if(v){g.push({...v,missing:!1,future:k});continue}g.push({day:b,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!k,future:k})}return g}function jl(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 Sl(e){if(!e||typeof e!="object")return!1;const t=e.models;return t&&typeof t=="object"&&Object.keys(t).length>0?!1:co.every(n=>e[n]==null)}function Cl(e,t,n){const a={...e,hour:t,missing:!1,future:n};if(!n&&Sl(e))for(const r of co)a[r]=0;return a}function Dl(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 Tl(e,t,{timeZone:n,offsetMinutes:a}={}){const r=Dl(e,t);if(!n||typeof Intl>"u"||!Intl.DateTimeFormat)return r;const s=Lt(e);if(!s)return r;const l=s.getUTCFullYear()*1e4+(s.getUTCMonth()+1)*100+s.getUTCDate(),i=s.getTime()-2160*60*1e3,c=ga(s,2).getTime()+2160*60*1e3,u=[],f=new Set;for(let d=i;d<=c;d+=1800*1e3){const m=ln({timeZone:n,offsetMinutes:a,now:new Date(d)});if(!m||m.dayNum!==l||t===60&&m.minute!==0||t===30&&m.minute!==0&&m.minute!==30)continue;const g=`${e}T${String(m.hour).padStart(2,"0")}:${String(m.minute).padStart(2,"0")}:00`;f.has(g)||(f.add(g),u.push(g))}return u.length>0?u:r}function Pl(e,t,{timeZone:n,offsetMinutes:a,now:r}={}){if(!t)return Array.isArray(e)?e:[];const s=t.trim().slice(0,10),l=ln({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||"",b=vn(p,i);if(b&&b.slot%2!==0){c=!0;break}}const u=c?30:60,f=new Map;for(const g of e||[]){const p=g?.hour||g?.label||"",b=vn(p,i);b&&f.set(b.slot,g)}const d=[],m=Tl(s,u,{timeZone:n,offsetMinutes:a});for(let g=0;g<m.length;g++){const p=m[g],b=vn(p,i),v=b?b.slot:c?g:g*2,k=f.get(v);let j=!1;if(l){const x=l.year*1e4+l.month*100+l.day,N=b?.dayNum??Number(s.replace(/-/g,""));if(N>x)j=!0;else if(N===x){const C=l.hour*2+(l.minute>=30?1:0);j=v>C}}k?d.push(Cl(k,p,j)):d.push(jl(p,j))}return d}function wn(e,t,n,{period:a,timeZone:r,offsetMinutes:s,now:l}={}){const i=a==="24h"?lo(t,n):[n||t].filter(Boolean).map(String),u=Array.from(new Set(i)).flatMap(d=>Pl(Ol(e||[],d),d,{timeZone:r,offsetMinutes:s,now:l})),f=$l(u,{timeZone:r,offsetMinutes:s,now:l});return a!=="24h"?f:El(f,{timeZone:r,offsetMinutes:s,now:l})}function Ol(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 $l(e,{timeZone:t,offsetMinutes:n,now:a}={}){if(!Array.isArray(e))return[];const r=ln({timeZone:t,offsetMinutes:n,now:a});return r?e.map(s=>{const l=s?.hour||s?.label||"",i=vn(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 El(e,{timeZone:t,offsetMinutes:n,now:a}={}){if(!Array.isArray(e))return[];const r=ln({timeZone:t,offsetMinutes:n,now:a});if(!r)return e.filter(i=>!i?.future);const s=uo({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=Wl(i?.hour||i?.label);return c!=null&&c>=l&&c<=s})}function zn(e,{timeZone:t,offsetMinutes:n,now:a}={}){if(!Array.isArray(e))return[];const r=ln({timeZone:t,offsetMinutes:n,now:a});return r?e.map(s=>{const l=s?.month||s?.label||"",i=Al(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 ln({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 m=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((j,x)=>(x.type&&x.value&&(j[x.type]=x.value),j),{}),g=Number(m.year),p=Number(m.month),b=Number(m.day),v=Number(m.hour),k=Number(m.minute);if(Number.isFinite(g)&&Number.isFinite(p)&&Number.isFinite(b)&&Number.isFinite(v)&&Number.isFinite(k)){const j=v*2+(k>=30?1:0);return{year:g,month:p,day:b,hour:v,minute:k,dayNum:g*1e4+p*100+b,slot:j}}}catch{}if(Number.isFinite(t)){const f=new Date(a.getTime()+t*60*1e3),d=f.getUTCFullYear(),m=f.getUTCMonth()+1,g=f.getUTCDate(),p=f.getUTCHours(),b=f.getUTCMinutes(),v=p*2+(b>=30?1:0);return{year:d,month:m,day:g,hour:p,minute:b,dayNum:d*1e4+m*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 vn(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(":"),f=Number(u[0]),d=Number(u[1]);if(!Number.isFinite(f)||f<0||f>23||!Number.isFinite(d)||d<0||d>59)return null;const m=f*2+(d>=30?1:0);return{dayNum:l*1e4+i*100+c,slot:m}}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 uo({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 Wl(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,f]=s.map(Number);return!Number.isFinite(l)||!Number.isFinite(i)||!Number.isFinite(c)||!Number.isFinite(u)||!Number.isFinite(f)?null:uo({year:l,month:i,day:c,hour:u,minute:f})}function Al(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 Xa({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:a,to:r,includeDaily:s=!0,cacheKey:l,timeZone:i,tzOffsetMinutes:c,now:u}={}){const[f,d]=h.useState([]),[m,g]=h.useState(null),[p,b]=h.useState(null),[v,k]=h.useState("edge"),[j,x]=h.useState(null),[N,C]=h.useState(!1),[T,z]=h.useState(null),$=Yt(),D=!n&&!$,A=(()=>{if(!l)return null;const _=Fl(e)||"default",w=s?"daily":"summary",I=on({timeZone:i,offsetMinutes:c});return`tokentracker.usage.${l}.${_}.${a}.${r}.${w}.${I}`})(),K=h.useCallback(()=>{if(!A||typeof window>"u")return null;try{const _=window.localStorage.getItem(A);if(!_)return null;const w=JSON.parse(_);return!w||!w.summary?null:w}catch{return null}},[A]),B=h.useCallback(_=>{if(!(!A||typeof window>"u"))try{window.localStorage.setItem(A,JSON.stringify(_))}catch{}},[A]),E=h.useCallback(()=>{if(!(!A||typeof window>"u"))try{window.localStorage.removeItem(A)}catch{}},[A]),W=h.useCallback(async()=>{C(!0),z(null);try{let _=null,w=null;if(s){const[L,V]=await Promise.allSettled([Cn({baseUrl:e,accessToken:t,from:a,to:r,timeZone:i,tzOffsetMinutes:c}),Rn({baseUrl:e,accessToken:t,from:a,to:r,timeZone:i,tzOffsetMinutes:c,rolling:!0})]);if(L.status==="rejected")throw L.reason;_=L.value,w=V.status==="fulfilled"?V.value:null}else w=await Rn({baseUrl:e,accessToken:t,from:a,to:r,timeZone:i,tzOffsetMinutes:c,rolling:!0});let I=s&&Array.isArray(_?.data)?_.data:[];s&&(I=Bn(I,a,r,{timeZone:i,offsetMinutes:c,now:u}));let M=w?.totals||_?.summary?.totals||null,J=w?.rolling||_?.summary?.rolling||null;if(s&&!M&&!w)try{const L=await Rn({baseUrl:e,accessToken:t,from:a,to:r,timeZone:i,tzOffsetMinutes:c,rolling:!0});M=L?.totals||null,J=L?.rolling||J}catch{}const P=new Date().toISOString();d(I),g(M),b(J),k("edge"),x(P),M&&D?B({summary:M,rolling:J,daily:I,from:a,to:r,includeDaily:s,fetchedAt:P}):D||E()}catch(_){if(D){const w=K();if(w?.summary){g(w.summary),b(w.rolling||null);const I=Array.isArray(w.daily)?w.daily:[],M=s?Bn(I,w.from||a,w.to||r,{timeZone:i,offsetMinutes:c,now:u}):I;d(M),k("cache"),x(w.fetchedAt||null),z(null)}else{const I=_;z(I?.message||String(I)),d([]),g(null),b(null),k("edge"),x(null)}}else{const w=_;z(w?.message||String(w)),d([]),g(null),b(null),k("edge"),x(null)}}finally{C(!1)}},[t,e,a,s,$,n,D,u,K,i,r,c,E,B]);return h.useEffect(()=>{if(!D)E(),d([]),g(null),b(null),z(null),k("edge"),x(null);else{const _=K();if(_?.summary){g(_.summary),b(_.rolling||null);const w=Array.isArray(_.daily)?_.daily:[],I=s?Bn(w,_.from||a,_.to||r,{timeZone:i,offsetMinutes:c,now:u}):w;d(I),k("cache"),x(_.fetchedAt||null)}}W()},[t,$,K,W,n,D,E]),{daily:f,summary:m,rolling:p,source:$?"mock":v,fetchedAt:j,loading:N,error:T,refresh:W}}function Fl(e){try{return new URL(e).host}catch{return null}}function Yn(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())&&ht(l)===t?l:null}function Rl(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Bn(e,t,n,{timeZone:a,offsetMinutes:r,now:s}={}){const l=Yn(t),i=Yn(n);if(!l||!i||i<l)return Array.isArray(e)?e:[];const c=s instanceof Date&&Number.isFinite(s.getTime())?s:new Date,u=tn({timeZone:a,offsetMinutes:r,date:c}),f=Yn(u),d=f?f.getTime():c.getTime(),m=new Map;for(const p of e||[])p?.day&&m.set(p.day,p);const g=[];for(let p=l;p<=i;p=Rl(p,1)){const b=ht(p),v=m.get(b),k=p.getTime()>d;if(v){g.push({...v,missing:!1,future:k});continue}g.push({day:b,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!k,future:k})}return g}function Il({baseUrl:e,accessToken:t,guestAllowed:n=!1,from:a,to:r,cacheKey:s,timeZone:l,tzOffsetMinutes:i}={}){const[c,u]=h.useState(null),[f,d]=h.useState("edge"),[m,g]=h.useState(!1),[p,b]=h.useState(null),v=Yt(),k=!n,j=h.useMemo(()=>{if(!s)return null;const $=Ll(e)||"default",D=on({timeZone:l,offsetMinutes:i});return`tokentracker.modelBreakdown.${s}.${$}.${a}.${r}.${D}`},[e,s,a,l,r,i]),x=h.useCallback(()=>{if(!j||typeof window>"u")return null;try{const $=window.localStorage.getItem(j);if(!$)return null;const D=JSON.parse($);return!D||!D.breakdown?null:D}catch{return null}},[j]),N=h.useCallback($=>{if(!(!j||typeof window>"u"))try{window.localStorage.setItem(j,JSON.stringify($))}catch{}},[j]),C=h.useCallback(()=>{if(!(!j||typeof window>"u"))try{window.localStorage.removeItem(j)}catch{}},[j]),T=h.useCallback(async()=>{g(!0),b(null);try{const $=await Di({baseUrl:e,accessToken:t,from:a,to:r,timeZone:l,tzOffsetMinutes:i});u($||null),d("edge"),$&&k?N({breakdown:$,fetchedAt:new Date().toISOString()}):k||C()}catch($){if(k){const D=x();if(D?.breakdown)u(D.breakdown),d("cache"),b(null);else{u(null),d("edge");const A=$;b(A?.message||String(A))}}else{u(null),d("edge");const D=$;b(D?.message||String(D))}}finally{g(!1)}},[t,e,a,v,n,k,x,l,r,i,C,N]);return h.useEffect(()=>{if(!k)C(),u(null),d("edge"),b(null);else{const $=x();$?.breakdown&&(u($.breakdown),d("cache"))}T()},[t,v,x,T,n,k,C]),{breakdown:c,source:v?"mock":f,loading:m,error:p,refresh:T}}function Ll(e){try{return new URL(e).host}catch{return null}}const oa="tokentracker.plan_prices.v1";function zl(){if(typeof window>"u")return{};try{const e=window.localStorage.getItem(oa);if(!e)return{};const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[a,r]of Object.entries(t)){const s=Number(r);Number.isFinite(s)&&s>0&&(n[String(a).toLowerCase()]=s)}return n}catch{return{}}}function Yl(){const[e,t]=h.useState({});h.useEffect(()=>{t(zl())},[]);const n=h.useCallback((a,r)=>{t(s=>{const l=String(a||"").toLowerCase();if(!l)return s;const i={...s},c=Number(r);Number.isFinite(c)&&c>0?i[l]=c:delete i[l];try{window.localStorage.setItem(oa,JSON.stringify(i))}catch{}return i})},[]);return{planPrices:e,setPlanPrice:n,PLAN_PRICES_STORAGE_KEY:oa}}function Re(e){const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:0}function Bl(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 It(e,t){let n=0,a=0;if(Array.isArray(e))for(const r of e){const s=Bl(r);s==null||s>t||(n+=Re(r.total_tokens),a+=Re(r.total_cost_usd))}return{tokens:n,cost:a}}function _n(...e){return e.reduce((t,n)=>({tokens:t.tokens+Re(n?.tokens),cost:t.cost+Re(n?.cost)}),{tokens:0,cost:0})}function Ga(e){if(!Array.isArray(e)||e.length===0)return null;const t=_n(...e);return{tokens:t.tokens/e.length,cost:t.cost/e.length}}function Hn(e){if(!e)return null;const t=Re(e.tokens);return t<=0?null:Re(e.cost)/(t/1e6)}function Ka(e,t){return e==null||t==null||!Number.isFinite(e)||!Number.isFinite(t)||t===0?null:(e-t)/t}function Hl({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,f)=>({value:i,deltaVsPrev:Ka(i,c),deltaVsAvg:n?Ka(i,u):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(Hn(e),Hn(t),Hn(n),null)}}const fo=864e5;function sa(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 Mn(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=sa(e);return n==null?null:Mn(n+t*fo)}function Ul(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 Vl(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)?Mn(a.getTime()+n*6e4):Mn(a.getTime())}const ql=e=>Number(e?.total_tokens??0)||0,Xl=e=>Number(e?.total_cost_usd??0)||0;function Qa(e,t,n){let a={tokens:0,cost:0};const r=t?sa(t):null,s=n?sa(n):null;if(r==null||s==null||r>s)return a;for(let l=r;l<=s;l+=fo){const i=e.get(Mn(l));i&&(a=_n(a,i))}return a}function Gl(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 Kl(e,t){const n=new Map;return e.forEach((a,r)=>{n.set(a,Array.isArray(t[r]?.data)?t[r].data:[])}),n}function Ql(e){const t=new Map;for(const n of Array.isArray(e?.data)?e.data:[])n?.day&&t.set(String(n.day),{tokens:ql(n),cost:Xl(n)});return t}function Jl(e,t,n){return{current:It(t.get(e.todayKey),n),prev:e.prevKey?It(t.get(e.prevKey),n):null,trailingAvg:Ga(e.trailingKeys.map(a=>It(t.get(a),n))),trailingFull:Ga(e.trailingKeys.map(a=>It(t.get(a),23)))}}function Zl(e,t,n,a){const r=_n(Qa(n,e.curStartKey,wt(e.todayKey,-1)),It(t.get(e.todayKey),a)),s=_n(Qa(n,e.prevStartKey,e.prevBoundaryKey?wt(e.prevBoundaryKey,-1):null),e.prevBoundaryKey?It(t.get(e.prevBoundaryKey),a):{tokens:0,cost:0});return{current:r,prev:s,trailingAvg:null}}function ec(e){try{return new URL(e).host}catch{return null}}function tc({baseUrl:e,accessToken:t,guestAllowed:n=!1,period:a,timeZone:r,tzOffsetMinutes:s,now:l,cacheKey:i}={}){const[c,u]=h.useState(null),[f,d]=h.useState(!1),[m,g]=h.useState(null),p=h.useRef(0),b=l instanceof Date?l:new Date(l||Date.now()),v=Vl(b,{timeZone:r,offsetMinutes:s}),k=Ul(b,{timeZone:r,offsetMinutes:s}),j=Yt(),x=!n&&!j,N=(()=>{if(!i)return null;const D=ec(e)||"default",A=on({timeZone:r,offsetMinutes:s});return`tokentracker.pulse.${i}.${D}.${a}.${v}.${A}`})(),C=h.useCallback(()=>{if(!N||typeof window>"u")return null;try{const D=window.localStorage.getItem(N);return D?JSON.parse(D):null}catch{return null}},[N]),T=h.useCallback(D=>{if(!(!N||typeof window>"u"))try{window.localStorage.setItem(N,JSON.stringify(D))}catch{}},[N]),z=h.useCallback(()=>{const D=C();return D&&D.cutoffHour===k?D:null},[C,k]),$=h.useCallback(async()=>{const D=Gl(a,v);if(!D){u(null),g(null);return}const A=++p.current;d(!0),g(null);try{const K=await Promise.all(D.hourlyDays.map(H=>no({baseUrl:e,accessToken:t,day:H,timeZone:r,tzOffsetMinutes:s}))),B=Kl(D.hourlyDays,K);let E;if(D.kind==="day")E=Jl(D,B,k);else{const H=await Cn({baseUrl:e,accessToken:t,from:D.dailyFrom,to:D.dailyTo,timeZone:r,tzOffsetMinutes:s});E=Zl(D,B,Ql(H),k)}const W=Hl({...E,period:a});if(A!==p.current)return;u(W),x&&W&&T({pulse:W,todayKey:v,cutoffHour:k,fetchedAt:new Date().toISOString()})}catch(K){if(A!==p.current)return;const B=z();B?.pulse&&u(B.pulse),g(K?.message?String(K.message):"Failed to load pulse")}finally{A===p.current&&d(!1)}},[e,t,n,a,r,s,v,k,x,j,z,T]);return h.useEffect(()=>{if(a==="total"||a==="custom"){u(null);return}const D=z();D?.pulse&&u(D.pulse)},[N,a,k]),h.useEffect(()=>{$()},[$]),{pulse:c,loading:f,error:m,refresh:$}}const mo=new Set(["day","hour","month"]);function nc(e){return mo.has(e)}function Ja(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 ac(e,t){const n=Ja(e),a=Ja(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 ho(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 rc(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 oc(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 sc(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 ic(e,t,n){const a=n==="hour"?sc:n==="month"?oc:rc,r=a(e),s=a(t);return r!=null&&s!=null?r===s?0:r<s?-1:1:ho(e,t)}function go(e,{key:t,dir:n}){const a=n==="asc"?1:-1,r=Array.isArray(e)?e:[],s=mo.has(t)?(i,c)=>ic(i,c,t):t==="top_model"?ho:ac,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),f=l(c.row),d=u==null,m=f==null;if(d&&m)return i.index-c.index;if(d)return 1;if(m)return-1;const g=s(u,f);return g!==0?g*a:i.index-c.index}).map(i=>i.row)}function lc(){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 Za(e){const t=nc(e)?e:"day";return lc().map((n,a)=>a===0?{...n,key:t}:n)}function er(e,{key:t,dir:n}){return go(e,{key:t,dir:n})}const jn=12,cc=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens"];function dc(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 uc(e){return cc.some(t=>dc(e?.[t]))}function fc(e){const t=Array.isArray(e)?e:[];if(!t.length)return[];const n=go(t,{key:"month",dir:"asc"}),a=n.findIndex(r=>r?.month&&uc(r));return a===-1?t:n.slice(a)}function mc(e,t,n=jn){const a=Array.isArray(e)?e:[],r=Number.isFinite(n)&&n>0?n:jn,l=(Number.isFinite(t)&&t>=0?Math.floor(t):0)*r;return a.slice(l,l+r)}function hc(e){if(typeof e!="string")return null;const t=e.trim();return t?t.toLowerCase():null}function gc(e){const t=hc(e?.model_id);return t||null}function yc(e,t){return e?.model?String(e.model):t}const pc=new Set(["curated:fuzzy","litellm:fuzzy","litellm:prefix-strip"]),bc=new Set(["miss","unattributed","empty"]);function xc(e){const t=String(e||"").toLowerCase();return t.includes("free")||t.includes("hy3-preview")||/^glm-[\d.]+-flash(?![a-z])/.test(t)}function Sn(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 yo(e,{copyFn:t}={}){const n=typeof t=="function"?t:l=>l,r=(Array.isArray(e?.sources)?e.sources:[]).map(l=>{const i=Sn(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",f=l.models.map(p=>{const b=Sn(p?.totals);if(!Number.isFinite(b)||b<=0)return null;const v=l.totalTokens>0?Math.round(b/l.totalTokens*1e3)/10:0,k=yc(p,n("shared.placeholder.short")),j=gc(p),x=Le(p?.totals?.total_cost_usd),N=x??(l.totalCost>0&&l.totalTokens>0?b/l.totalTokens*l.totalCost:null),C=typeof p?.pricing_tier=="string"?p.pricing_tier:null,T=C?bc.has(C)&&b>0:b>0&&(N==null||N<=0)&&!xc(k),z=!!(C&&pc.has(C));return{id:j,name:k,share:v,usage:b,cost:N,pricingTier:C,pricingMissing:T,pricingFuzzy:z}}).filter(Boolean),d=f.filter(p=>Number.isFinite(Number(p?.cost))&&Number(p.cost)>0).sort((p,b)=>Number(b.cost)-Number(p.cost))[0]||null,m=f.filter(p=>p?.pricingMissing),g=f.filter(p=>p?.pricingFuzzy);return{source:l.source,label:i,totalPercent:String(u),usd:l.totalCost,usage:l.totalTokens,topCostModel:d,missingPricingModels:m,fuzzyPricingModels:g,models:f}})}function kc(e,{copyFn:t}={}){const a=yo(e,{copyFn:typeof t=="function"?t:d=>d}),r=a.reduce((d,m)=>d+(Number(m?.usage)||0),0),s=a.reduce((d,m)=>d+(Number(m?.usd)||0),0),l=a.flatMap(d=>(d.models||[]).map(m=>({...m,source:d.label}))),i=l.filter(d=>Number.isFinite(Number(d?.cost))&&Number(d.cost)>0).sort((d,m)=>Number(m.cost)-Number(d.cost))[0]||null,c=l.filter(d=>Number.isFinite(Number(d?.usage))&&Number(d.usage)>0).sort((d,m)=>Number(m.usage)-Number(d.usage))[0]||null,u=l.filter(d=>d?.pricingMissing);return{fuzzyPricingModels:l.filter(d=>d?.pricingFuzzy),totalTokens:r,totalCost:s,costPerMillionTokens:r>0?s/(r/1e6):null,topCostModel:i,topUsageModel:c,missingPricingModels:u}}function wc(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 vc(e,{fallback:t="—"}={}){const n=(Array.isArray(e)?e:[]).map(s=>{const l=Sn(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:wc(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 ut={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 Nc(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,u=n,f=Math.cos(r),d=Math.sin(r),m=i,g=c*f-u*d,p=c*d+u*f;return{x:m,y:g,z:p}}function _c(e,t,n,a,r){return tt(e,t,n,a,r)}function po(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 tr({weeks:e,palette:t="auto",isDark:n=!1,interactive:a=!1,autoRotateInit:r=!1,onResetViewRef:s=null}){const l=ut[t]||(t==="auto"?ut.emerald:null),i=l?n?l.dark:l.light:Array.isArray(t)?t:n?ut.emerald.dark:ut.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,f=.88,[d,m]=h.useState({yaw:u,pitch:f}),[g,p]=h.useState(r),[b,v]=h.useState(1),k=a?13:10.5,j=h.useMemo(()=>{const F=[],U=e.length;if(U===0||!a)return[];for(let Q=0;Q<=7;Q++){const G=(Q-3.5)*k,ne=tt(-U/2*k,G,0,d.yaw,d.pitch),se=tt(U/2*k,G,0,d.yaw,d.pitch);F.push({d:`M${ne.x},${ne.y} L${se.x},${se.y}`,key:`horiz-${Q}`})}for(let Q=0;Q<=U;Q+=4){const G=(Q-U/2)*k,ne=tt(G,-3.5*k,0,d.yaw,d.pitch),se=tt(G,3.5*k,0,d.yaw,d.pitch);F.push({d:`M${ne.x},${ne.y} L${se.x},${se.y}`,key:`vert-${Q}`})}if(U%4!==0){const Q=(U-U/2)*k,G=tt(Q,-3.5*k,0,d.yaw,d.pitch),ne=tt(Q,3.5*k,0,d.yaw,d.pitch);F.push({d:`M${G.x},${G.y} L${ne.x},${ne.y}`,key:"vert-last"})}return F},[e.length,d,k,a]);h.useEffect(()=>{s&&(s.current={reset:()=>{m({yaw:u,pitch:f}),p(!1),v(1),H()},toggleAutoRotate:F=>{p(F)}})},[s]);const x=h.useRef(null),N=h.useRef(null),C=h.useRef(!1),T=h.useRef({x:0,y:0}),z=h.useRef({yaw:u,pitch:f}),$=h.useRef({x:0,y:0}),D=h.useRef({x:0,y:0,time:0}),A=h.useRef(null),[K,B]=h.useState(0),E=h.useRef(null),W=h.useRef(!0);h.useEffect(()=>(W.current=!0,()=>{W.current=!1}),[]);const H=()=>{E.current&&cancelAnimationFrame(E.current),B(0);const F=performance.now(),U=1200,Q=G=>{if(!W.current)return;const ne=G-F,se=Math.min(1,ne/U),ue=1-Math.pow(1-se,3);B(ue),se<1?E.current=requestAnimationFrame(Q):E.current=null};E.current=requestAnimationFrame(Q)};h.useEffect(()=>(H(),()=>{E.current&&cancelAnimationFrame(E.current)}),[a]),h.useEffect(()=>{if(!g||C.current||typeof window>"u"||typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;let U;const Q=()=>{if(typeof document<"u"&&document.visibilityState==="hidden"){U=requestAnimationFrame(Q);return}m(G=>({yaw:G.yaw+.002,pitch:G.pitch})),U=requestAnimationFrame(Q)};return U=requestAnimationFrame(Q),()=>cancelAnimationFrame(U)},[g]);const _=(F,U)=>{a&&(C.current=!0,T.current={x:F,y:U},z.current={yaw:d.yaw,pitch:d.pitch},$.current={x:0,y:0},D.current={x:F,y:U,time:performance.now()},A.current&&cancelAnimationFrame(A.current))},w=(F,U)=>{if(!C.current)return;const Q=F-T.current.x,G=U-T.current.y,ne=performance.now(),se=ne-D.current.time;se>0&&($.current={x:(F-D.current.x)/se,y:(U-D.current.y)/se}),D.current={x:F,y:U,time:ne};const ue=.005,ie=z.current.yaw-Q*ue,me=Math.PI/2.3,De=Math.max(-me,Math.min(me,z.current.pitch-G*ue));m({yaw:ie,pitch:De})},I=()=>{if(!C.current)return;C.current=!1;let F=-$.current.x*12,U=-$.current.y*12;const Q=.95,G=()=>{C.current||(F*=Q,U*=Q,!(Math.abs(F)<.01&&Math.abs(U)<.01)&&(m(ne=>{const se=ne.yaw+F*.005,ue=Math.PI/2.3,ie=Math.max(-ue,Math.min(ue,ne.pitch+U*.005));return{yaw:se,pitch:ie}}),A.current=requestAnimationFrame(G)))};A.current=requestAnimationFrame(G)},[M,J]=h.useState(null),[P,L]=h.useState({x:0,y:0,shiftX:0}),V=h.useRef(null);h.useEffect(()=>()=>{V.current&&clearTimeout(V.current)},[]),h.useEffect(()=>{if(!a||!N.current)return;const F=Q=>{Q.preventDefault();const G=-Q.deltaY*.0025;v(ne=>{const se=ne+G;return Math.max(.5,Math.min(3,se))})},U=N.current;return U.addEventListener("wheel",F,{passive:!1}),()=>{U.removeEventListener("wheel",F)}},[a]);const q=h.useMemo(()=>{const F=[];return e.forEach((U,Q)=>{(Array.isArray(U)?U:[]).forEach((G,ne)=>{G&&F.push({key:G.day||`${Q}-${ne}`,col:Q,row:ne,level:G.level||0,value:G.value||0,total_tokens:G.total_tokens||0,day:G.day,models:G.models||null})})}),F},[e]),ve=k-(a?1.8:1.5),xe=a?38:28,pe=F=>Math.max(1.8,Number(F)/4*xe),Me=h.useMemo(()=>{if(q.length===0)return[];const F=e.length;return q.map(U=>{const Q=pe(U.level),G=Math.sqrt(Math.pow(U.col-F/2,2)+Math.pow(U.row-3.5,2)),ne=Math.sqrt(Math.pow(F/2,2)+Math.pow(3.5,2)),se=G/ne*.4,ue=Math.min(1,Math.max(0,(K-se)*(1/.6))),ie=Q*ue,me=(U.col-F/2)*k,De=(U.row-3.5)*k,ge=ve/2,Ee=[{x:me-ge,y:De-ge,z:0},{x:me+ge,y:De-ge,z:0},{x:me+ge,y:De+ge,z:0},{x:me-ge,y:De+ge,z:0},{x:me-ge,y:De-ge,z:ie},{x:me+ge,y:De-ge,z:ie},{x:me+ge,y:De+ge,z:ie},{x:me-ge,y:De+ge,z:ie}].map(ae=>tt(ae.x,ae.y,ae.z,d.yaw,d.pitch)),Ye=tt(me,De,ie/2,d.yaw,d.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]}],yt=i[Math.min(4,Math.max(0,Number(U.level)||0))],Ue=[],pt=.35,bt=-.4,re=.83;return Mt.forEach(ae=>{const ee=_c(ae.normal[0],ae.normal[1],ae.normal[2],d.yaw,d.pitch);if(ee.z>.001){const de=Ee[ae.indices[0]],Te=Ee[ae.indices[1]],le=Ee[ae.indices[2]],Ot=Ee[ae.indices[3]],Bt=`M${de.x},${de.y} L${Te.x},${Te.y} L${le.x},${le.y} L${Ot.x},${Ot.y} Z`,Ht=ee.x*pt+ee.y*bt+ee.z*re,jt=n?.18:0,xt=ae.scale*(.82+.28*Math.max(0,Ht))+jt;Ue.push({name:ae.name,d:Bt,fill:Nc(yt,xt)})}}),{...U,centerProj:Ye,renderedFaces:Ue}})},[q,d,i,e.length,K,k,ve,xe]),je=h.useMemo(()=>[...Me].sort((F,U)=>F.centerProj.z-U.centerProj.z),[Me]),ke=h.useMemo(()=>{if(je.length===0)return{minX:-100,minY:-100,maxX:100,maxY:100};let F=1/0,U=1/0,Q=-1/0,G=-1/0;return je.forEach(ne=>{const se=k*2,ue=ne.centerProj.x,ie=ne.centerProj.y;ue-se<F&&(F=ue-se),ue+se>Q&&(Q=ue+se),ie-se<U&&(U=ie-se),ie+se>G&&(G=ie+se)}),{minX:F,minY:U,maxX:Q,maxY:G}},[je,k]),Ce=12,O=ke.maxX-ke.minX+Ce*2,Y=ke.maxY-ke.minY+Ce*2,he=O/b,oe=Y/b,ye=ke.minX-Ce+(O-he)/2,Oe=ke.minY-Ce+(Y-oe)/2,$e=`${ye} ${Oe} ${he} ${oe}`;return q.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:F=>{if(!a)return;_(F.clientX,F.clientY);const U=G=>w(G.clientX,G.clientY),Q=()=>{I(),window.removeEventListener("mousemove",U),window.removeEventListener("mouseup",Q)};window.addEventListener("mousemove",U),window.addEventListener("mouseup",Q)},onTouchStart:F=>{!a||F.touches.length===0||_(F.touches[0].clientX,F.touches[0].clientY)},onTouchMove:F=>{!a||F.touches.length===0||w(F.touches[0].clientX,F.touches[0].clientY)},onTouchEnd:()=>{a&&I()},children:[o.jsxs("svg",{ref:x,viewBox:$e,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":`${O}px`,maxHeight:a?"78vh":"none"},className:"transition-transform duration-300 ease-out",children:[a&&j.map(F=>o.jsx("path",{d:F.d,fill:"none",stroke:c,strokeWidth:.25,strokeDasharray:"1.5 2.5",strokeLinecap:"round"},F.key)),je.map(F=>{const U=M&&M.key===F.key;return o.jsxs("g",{onMouseEnter:Q=>{if(V.current&&(clearTimeout(V.current),V.current=null),J(F),a&&x.current){const G=tt((F.col-e.length/2)*k,(F.row-3.5)*k,pe(F.level),d.yaw,d.pitch);let ne=0,se=0;const ue=x.current;if(N.current&&typeof ue.createSVGPoint=="function"&&typeof ue.getScreenCTM=="function")try{const ge=ue.createSVGPoint();ge.x=G.x,ge.y=G.y;const Fe=ue.getScreenCTM();if(Fe){const Ee=ge.matrixTransform(Fe),Ye=N.current.getBoundingClientRect();ne=Ee.x-Ye.left,se=Ee.y-Ye.top}}catch{const Fe=ue.getBoundingClientRect(),Ee=ke.maxX-ke.minX+Ce*2,Ye=ke.maxY-ke.minY+Ce*2;ne=(G.x-(ke.minX-Ce))/Ee*Fe.width,se=(G.y-(ke.minY-Ce))/Ye*Fe.height}else{const ge=ue.getBoundingClientRect(),Fe=ke.maxX-ke.minX+Ce*2,Ee=ke.maxY-ke.minY+Ce*2;ne=(G.x-(ke.minX-Ce))/Fe*ge.width,se=(G.y-(ke.minY-Ce))/Ee*ge.height}const ie=140;let me=0;const De=N.current?N.current.getBoundingClientRect().width:ue.getBoundingClientRect().width;ne<ie?me=ie-ne:ne>De-ie&&(me=De-ie-ne),L({x:ne,y:se,shiftX:me})}},onMouseLeave:()=>{V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{J(null)},150)},className:"transition-all duration-200",style:{filter:U?"brightness(1.15) drop-shadow(0 4px 6px rgba(0,0,0,0.15))":"none",cursor:a?"pointer":"default"},children:[!a&&F.day&&o.jsx("title",{children:`${F.day}: ${Number(F.value).toLocaleString()} conversations`}),F.renderedFaces.map((Q,G)=>o.jsx("path",{d:Q.d,fill:Q.fill,stroke:Q.fill,strokeWidth:.25,strokeLinejoin:"round"},G))]},F.key)})]}),a&&M&&o.jsxs("div",{onMouseEnter:()=>{V.current&&(clearTimeout(V.current),V.current=null)},onMouseLeave:()=>{V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{J(null)},150)},className:"absolute z-[9999] w-0 h-0 transition-all duration-100 ease-out",style:{left:`${P.x}px`,top:`${P.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% + ${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:M.day}),(()=>{const F=M.level===0?n?"#9ca3af":"#6b7280":i[M.level];return o.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:F+"22",color:F,border:`1px solid ${F}44`},children:["Level ",M.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(M.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(M.total_tokens??0).toLocaleString()}),o.jsx("span",{className:"text-[9px] text-oai-gray-400 uppercase tracking-wider",children:"tokens"})]})]}),M.models&&Object.keys(M.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(M.models).map(([F,U])=>({name:F,val:Number(U)})).sort((F,U)=>U.val-F.val).map(({name:F,val:U})=>{const Q=Number(M.total_tokens)||Object.values(M.models).reduce((ne,se)=>ne+Number(se||0),0)||1,G=Math.round(U/Q*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:F,children:F}),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:U.toLocaleString()}),o.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[G,"%"]})]})]}),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:`${G}%`,backgroundColor:i[4],boxShadow:`0 0 4px ${i[4]}55`}})})]},F)})})]}):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:po(M.level,M.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 Mc=12,jc=3,Sc=26,Cc=["#ebedf0","#f7d08a","#f2b757","#eca02f","#d9861a"],Dc=["#30363d","#7a4711","#bf7015","#eca02f","#f7c877"];function nr(e){const t=Number(e);return Number.isFinite(t)?t<1e3?t.toLocaleString():Ae(t,{decimals:2}):"0"}function Tc(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 bo(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Pc(e,t){return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))/864e5)}function Oc(e,t){const n=t==="mon"?1:0,a=e.getUTCDay();return bo(e,-((a-n+7)%7))}function $c(e,t,n,a){if(!e)return[];const r=Tc(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=Oc(r,n),i=bo(l,-(e-1)*7),c=[],u=new Set;for(const f of s){const d=Math.floor(Pc(i,f)/7);d<0||d>=e||u.has(d)||(u.add(d),c.push({label:a[f.getUTCMonth()],index:d}))}return c}function Ec({heatmap:e,timeZoneLabel:t,timeZoneShortLabel:n,hideLegend:a=!1,embedded:r=!1}){const{resolvedTheme:s}=Gr(),{currency:l,rate:i}=_t(),c=s==="dark",u=c?Dc:Cc,f=h.useRef(null),d=h.useRef(null),[m,g]=h.useState(null),[p,b]=h.useState({x:0,y:0,shiftX:0}),v=h.useRef(null);h.useEffect(()=>()=>{v.current&&clearTimeout(v.current)},[]);const[k,j]=h.useState(!1),[x,N]=h.useState(!1),[C,T]=h.useState(!1),z=h.useRef(null),[$,D]=h.useState("amber"),A=[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=(O,Y)=>{if(!Y||!Y.day)return;v.current&&(clearTimeout(v.current),v.current=null),g(Y);const he=O.currentTarget.getBoundingClientRect(),oe=typeof window<"u"?window.innerWidth:1024,ye=he.left+he.width/2,Oe=he.top,$e=140;let F=0;ye<$e?F=$e-ye:ye>oe-$e&&(F=oe-$e-ye),b({x:ye,y:Oe,shiftX:F})},B=()=>{v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{g(null)},150)},E=()=>{N(!1),j(!0)},W=()=>{N(!0)},H=O=>{O.target===O.currentTarget&&x&&(j(!1),N(!1))};h.useEffect(()=>{if(!k||x)return;const O=Y=>{Y.key==="Escape"&&W()};return window.addEventListener("keydown",O),()=>{window.removeEventListener("keydown",O)}},[k,x]);const _=h.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"}}),[]),w=_[$]||_.emerald,I=ut[$]?c?ut[$].dark:ut[$].light:c?ut.emerald.dark:ut.emerald.light,[M,J]=h.useState(()=>{if(r)return"2d";try{return window.localStorage?.getItem("tt:heatmap-view")==="3d"?"3d":"2d"}catch{return"2d"}});h.useEffect(()=>{if(!r)try{window.localStorage?.setItem("tt:heatmap-view",M)}catch{}},[M,r]),h.useEffect(()=>{if(M!=="2d")return;const O=f.current;O&&(O.scrollLeft=O.scrollWidth)},[e?.weeks,M]),h.useEffect(()=>{const O=f.current;if(!O)return;const Y=()=>{v.current&&(clearTimeout(v.current),v.current=null),g(null)};return O.addEventListener("scroll",Y),()=>O.removeEventListener("scroll",Y)},[]);const P=e?.week_starts_on==="mon"?"mon":"sun",L=h.useMemo(()=>{const O=Array.isArray(e?.weeks)?e.weeks:[];if(!O.length)return{weeks:[]};const Y=[];for(const he of O)for(const oe of Array.isArray(he)?he:[])oe?.day&&Y.push({day:oe.day,conversation_count:oe.conversation_count??0,total_tokens:oe.total_tokens??0,billable_total_tokens:oe.billable_total_tokens??oe.total_tokens??0,models:oe.models??null});return Zn({dailyRows:Y,weeks:Math.max(52,O.length),to:e?.to,weekStartsOn:P})},[e?.to,e?.weeks,P]),V=L?.weeks||[],q=h.useMemo(()=>{let O=0,Y=0,he={day:"无数据",value:0},oe=0,ye=0;const Oe=[];V.forEach(ie=>{(Array.isArray(ie)?ie:[]).forEach(me=>{me&&me.day&&Oe.push(me)})}),Oe.sort((ie,me)=>ie.day.localeCompare(me.day)),Oe.forEach(ie=>{const me=Number(ie.value)||0;O+=Number(ie.total_tokens)||0,me>0?(Y++,oe++,oe>ye&&(ye=oe)):oe=0,me>he.value&&(he={day:ie.day,value:me})});const $e=Oe.length||365,F=(Y/$e*100).toFixed(1);let U="heatmap.3d.modal.ai.eval.default",Q="heatmap.3d.modal.ai.title.default";O>=15e6?(Q="heatmap.3d.modal.ai.title.peak",U="heatmap.3d.modal.ai.eval.peak"):O>=5e6?(Q="heatmap.3d.modal.ai.title.heavy",U="heatmap.3d.modal.ai.eval.heavy"):O>=1e6?(Q="heatmap.3d.modal.ai.title.core",U="heatmap.3d.modal.ai.eval.core"):O>=2e4&&(Q="heatmap.3d.modal.ai.title.steady",U="heatmap.3d.modal.ai.eval.steady");const G=e?.total_cost_usd,ne=Number(G),ue=G!=null&&(typeof G!="string"||G.trim()!=="")&&Number.isFinite(ne)?ne:O/15e5;return{totalTokens:O,activeDays:Y,activeRate:F,maxSingleDay:he,maxStreak:ye,aiEvaluationTitleKey:Q,aiEvaluationKey:U,totalCostUsd:ue}},[V,e?.total_cost_usd]),fe=h.useMemo(()=>et(q.totalCostUsd,{currency:l,rate:i}),[q.totalCostUsd,l,i]),ve=P==="mon"?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(O=>y(`heatmap.day.${O.toLowerCase()}`)):["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(O=>y(`heatmap.day.${O.toLowerCase()}`)),xe=h.useMemo(()=>$c(V.length,L?.to,P,A),[L?.to,V.length,P,A]);if(!V.length)return o.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:y("heatmap.empty")});const pe=r?10:Mc,Me=r?2:jc,je=r?22:Sc,ke=je+V.length*pe+Math.max(0,V.length-1)*Me,Ce=`${je}px repeat(${V.length}, ${pe}px)`;return o.jsxs("div",{ref:d,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":M==="2d",onClick:()=>J("2d"),className:M==="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":M==="3d",onClick:()=>J("3d"),className:M==="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")})]})]}),M==="3d"&&o.jsxs("div",{onClick:E,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(tr,{weeks:V,isDark:c,palette:$}),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(ao,{size:9}),y("heatmap.3d.hover_tip")]})})]}),M==="2d"&&o.jsx("div",{ref:f,className:"overflow-x-auto overflow-y-hidden heatmap-scroll-thin",children:o.jsxs("div",{style:{minWidth:ke},children:[o.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:Ce,columnGap:Me},children:[o.jsx("span",{}),xe.map(O=>o.jsx("span",{style:{gridColumnStart:O.index+2},className:"whitespace-nowrap",children:O.label},`${O.label}-${O.index}`))]}),o.jsxs("div",{className:"grid",style:{gridTemplateColumns:Ce,columnGap:Me},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, ${pe}px)`,rowGap:Me},children:ve.map(O=>o.jsx("span",{className:"leading-none",children:O},O))}),o.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${pe}px)`,gap:Me},children:V.map((O,Y)=>(Array.isArray(O)?O:[]).map((he,oe)=>{if(!he)return null;const ye=he.day||`e-${Y}-${oe}`,Oe=Number(he.level)||0,$e=u[Oe]||u[0];return o.jsx("span",{onMouseEnter:F=>K(F,he),onMouseLeave:B,className:"rounded-[2px] transition-transform hover:scale-125 hover:z-10 cursor-pointer",style:{width:pe,height:pe,background:$e}},ye)}))})]})]})}),!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((O,Y)=>o.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:O}},Y))}),o.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:y("heatmap.legend.more")})]}),k&&o.jsx("div",{onAnimationEnd:H,onClick:O=>{O.target===O.currentTarget&&W()},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:W,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(da,{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:w.rawColor}}),o.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5",style:{backgroundColor:w.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:[q.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:nr(q.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:w.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:fe})]}),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:[q.activeRate,"% ",o.jsxs("span",{className:"text-[10px] font-bold text-zinc-400 dark:text-zinc-500 font-mono",children:["(",q.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:[q.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:[q.maxSingleDay.value>0?q.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:q.maxSingleDay.day!=="无数据"?q.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:[q.maxSingleDay.value>0?nr(q.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:["(",q.maxSingleDay.day!=="无数据"?q.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(ro,{size:11,style:{color:w.rawColor}}),o.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono",style:{color:w.rawColor},children:y(q.aiEvaluationTitleKey)})]}),o.jsxs("div",{className:"pl-3.5 border-l-2 relative transition-all duration-300 group",style:{borderColor:w.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:w.rawColor}}),o.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-600 dark:text-zinc-400 font-normal",children:y(q.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.${$}`)})]}),o.jsx("div",{className:"flex gap-1",children:I.map((O,Y)=>o.jsx("div",{className:"flex-1 h-1 rounded-[2px]",style:{backgroundColor:O},title:`Level ${Y}`},Y))})]})})]}),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:w.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(_).map(O=>{const Y=$===O;return o.jsx("button",{type:"button",onClick:()=>D(O),title:y(`heatmap.3d.modal.palette.${O}`),className:`w-3.5 h-3.5 rounded-full transition-all duration-200 relative hover:scale-125 ${O==="emerald"?"bg-[#10b981]":O==="ocean"?"bg-[#3b82f6]":O==="neon"?"bg-[#a855f7]":"bg-[#f59e0b]"}`,children:Y&&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"})},O)})}),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 O=!C;T(O),z.current&&z.current.toggleAutoRotate(O)},title:C?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 ${C?w.accentText:"text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-250"}`,children:C?o.jsx(qi,{size:12}):o.jsx(Gi,{size:12})}),o.jsx("button",{type:"button",onClick:()=>{T(!1),z.current&&z.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(Qi,{size:12})})]})]}),o.jsx(tr,{weeks:V,isDark:c,interactive:!0,palette:$,autoRotateInit:C,onResetViewRef:z}),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(ma,{size:10,className:w.accentText}),o.jsx("span",{children:y("heatmap.3d.modal.footer.tip")})]})]})]})}),m&&!k&&typeof document<"u"&&gi.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:m.day}),(()=>{const O=m.level===0?c?"#9ca3af":"#6b7280":u[m.level];return o.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:O+"22",color:O,border:`1px solid ${O}44`},children:["Level ",m.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(m.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(m.total_tokens??0).toLocaleString()}),o.jsx("span",{className:"text-[9px] text-oai-gray-400 uppercase tracking-wider",children:"tokens"})]})]}),m.models&&Object.keys(m.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(m.models).map(([O,Y])=>({name:O,val:Number(Y)})).sort((O,Y)=>Y.val-O.val).map(({name:O,val:Y})=>{const he=Number(m.total_tokens??m.value)||1,oe=Math.round(Y/he*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:O,children:O}),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:[oe,"%"]})]})]}),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:`${oe}%`,backgroundColor:u[4],boxShadow:`0 0 4px ${u[4]}55`}})})]},O)})})]}):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:po(m.level,m.total_tokens??m.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
|
+
@keyframes tt-fade-in {
|
|
3
|
+
from { opacity: 0; }
|
|
4
|
+
to { opacity: 1; }
|
|
5
|
+
}
|
|
6
|
+
@keyframes tt-fade-out {
|
|
7
|
+
from { opacity: 1; }
|
|
8
|
+
to { opacity: 0; }
|
|
9
|
+
}
|
|
10
|
+
@keyframes tt-modal-entrance {
|
|
11
|
+
from {
|
|
12
|
+
opacity: 0;
|
|
13
|
+
transform: scale(0.96) translateY(10px);
|
|
14
|
+
}
|
|
15
|
+
to {
|
|
16
|
+
opacity: 1;
|
|
17
|
+
transform: scale(1) translateY(0);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
@keyframes tt-modal-exit {
|
|
21
|
+
from {
|
|
22
|
+
opacity: 1;
|
|
23
|
+
transform: scale(1) translateY(0);
|
|
24
|
+
}
|
|
25
|
+
to {
|
|
26
|
+
opacity: 0;
|
|
27
|
+
transform: scale(0.96) translateY(10px);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
.animate-tt-fade-in {
|
|
31
|
+
animation: tt-fade-in 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
32
|
+
}
|
|
33
|
+
.animate-tt-fade-out {
|
|
34
|
+
animation: tt-fade-out 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
35
|
+
}
|
|
36
|
+
.animate-tt-modal {
|
|
37
|
+
animation: tt-modal-entrance 0.3s cubic-bezier(0.34, 1.3, 0.64, 1) forwards;
|
|
38
|
+
}
|
|
39
|
+
.animate-tt-modal-exit {
|
|
40
|
+
animation: tt-modal-exit 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
41
|
+
}
|
|
42
|
+
`})]})}function Wc({ingestHealth:e}){const t=e?.transcript_suppressed;if(!t||t.checked!==!0)return null;const n=Number(t.count)||0;if(n<=0)return null;const a=Array.isArray(t.models)?t.models.join(", "):"",r=a?y("dashboard.ingestHealth.suppressed.body",{count:n,models:a}):y("dashboard.ingestHealth.suppressed.bodyNoModel",{count:n});return o.jsxs("div",{role:"status","aria-live":"polite",className:"mt-1 rounded-md border border-amber-300/60 dark:border-amber-700/40 bg-amber-50/50 dark:bg-amber-900/10 px-2.5 py-2 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[o.jsx("div",{className:"font-medium text-oai-gray-700 dark:text-oai-gray-200",children:y("dashboard.ingestHealth.suppressed.title")}),o.jsx("div",{className:"mt-0.5 leading-snug",children:r}),o.jsx("div",{className:"mt-0.5 leading-snug",children:y("dashboard.ingestHealth.suppressed.remedy")})]})}function Ac(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 ar(e,t,n){if(!Number.isFinite(e)||e<=0)return null;const a=ua(t);return(t===Kr?e:e*n)<.01?`<${a}0.01`:et(e,{decimals:2,currency:t,rate:n})}function rr(e){const t=Number(e);return!Number.isFinite(t)||t<=0?null:Ae(t,{decimals:1})}const Fc=R.memo(function({isOpen:t,onClose:n,fleetData:a=[]}){const{currency:r,rate:s}=_t(),l=h.useMemo(()=>(Array.isArray(a)?a:[]).map(c=>{const u=Le(c?.usd)??0,f=Le(c?.usage)??0,d=Array.isArray(c?.models)?c.models:[];return{label:c?.label?String(c.label):"",usdValue:u,costLabel:ar(u,r,s),tokensLabel:rr(f),models:d.map(m=>{const g=Le(m?.usage)??0,p=Le(m?.cost)??0;return{id:m?.id?String(m.id):"",name:m?.name?String(m.name):"",tokensLabel:rr(g),costLabel:ar(p,r,s),sortCost:p}}).filter(m=>m.costLabel||m.tokensLabel).sort((m,g)=>g.sortCost-m.sortCost)}}).filter(c=>c.usdValue>0||c.models.length>0).sort((c,u)=>u.usdValue-c.usdValue),[a,r,s]),i=h.useMemo(()=>{const c=l.reduce((u,f)=>u+f.usdValue,0);return Ac(c,r,s)},[l,r,s]);return o.jsx(Fi,{open:t,onOpenChange:c=>{c||n?.()},children:o.jsxs(Ri,{children:[o.jsx(Ii,{className:"cost-modal-backdrop","data-cost-analysis-backdrop":"true"}),o.jsx(Li,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:o.jsxs(zi,{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(Yi,{render:o.jsx("h2",{className:"sr-only"}),children:y("dashboard.cost_breakdown.title")}),o.jsx(il,{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(da,{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 f=`fleet-${u}`;return o.jsxs("div",{role:"rowgroup","aria-labelledby":f,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: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((d,m)=>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:d.name,children:d.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:d.costLabel||""})]},d.id||`${d.name}-${m}`))]},`${c.label}-${u}`)})]})]})})]})})]})})});function Rc(e){if(typeof e!="string")return{owner:"",repo:""};const[t,n]=e.split("/");return{owner:t||"",repo:n||""}}function Ic({projectKey:e,projectRef:t}){const n=typeof t=="string"?t.replace("https://github.com/",""):"",{owner:a,repo:r}=Rc(e||n),s=a&&r?`${a}/${r}`:e;return 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(fa,{provider:s,size:20})})}function Lc({projectEntries:e=[],projectUnattributedSources:t=[],projectLimit:n=3,onProjectLimitChange:a,copy:r,hasDetailsActual:s,dailyEmptyPrefix:l,installSyncCmd:i,dailyEmptySuffix:c,detailsColumns:u,ariaSortFor:f,toggleSort:d,sortIconFor:m,pagedDetails:g,dailyBreakdownRows:p=[],dailyBreakdownColumns:b=[],dailyBreakdownAriaSortFor:v,dailyBreakdownSortIconFor:k,dailyBreakdownDateKey:j="day",detailsDateKey:x,renderDetailDate:N,renderDailyBreakdownDate:C,renderDetailCell:T,DETAILS_PAGED_PERIODS:z,period:$,detailsPageCount:D,detailsPage:A,setDetailsPage:K}){const[B,E]=h.useState("daily"),W=t.length>0;function H(w,I,M){return M===0?"text-oai-gray-500 dark:text-oai-gray-300":I.key==="total_tokens"||I.key==="total_cost_usd"?"font-medium text-oai-black dark:text-oai-white tabular-nums":I.key==="cost_per_million_tokens"&&w?.cost_per_million_status==="high"?"font-semibold text-amber-700 dark:text-amber-300 tabular-nums":I.key==="top_model"?"text-oai-gray-600 dark:text-oai-gray-300":"text-oai-gray-600 dark:text-oai-gray-300 tabular-nums"}function _(w,I,M){return M===0?C?C(w):N(w):T(w,I.key)}return o.jsxs(sn,{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":B==="daily",type:"button",onClick:()=>E("daily"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${B==="daily"?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/50"}`,children:r("dashboard.daily.title")}),o.jsx("button",{role:"tab","aria-selected":B==="projects",type:"button",onClick:()=>E("projects"),className:`text-xs font-medium px-3 py-1.5 rounded transition-colors ${B==="projects"?"text-oai-black dark:text-oai-white bg-oai-gray-100 dark:bg-oai-gray-800":"text-oai-gray-500 dark:text-oai-gray-300 hover:text-oai-black dark:hover:text-oai-white hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/50"}`,children:r("dashboard.projects.title")})]}),B==="projects"&&o.jsx(Hi,{ariaLabel:r("dashboard.projects.limit_aria"),value:n,onValueChange:w=>a?.(Number(w)),options:[{value:3,label:r("dashboard.projects.limit_top_3")},{value:6,label:r("dashboard.projects.limit_top_6")},{value:10,label:r("dashboard.projects.limit_top_10")}],align:"end",className:"px-2 py-1 text-xs text-oai-gray-600 dark:text-oai-gray-300"})]}),B==="projects"&&o.jsxs("div",{className:"space-y-1",children:[e.length===0?o.jsx("div",{className:"oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300",children:r("dashboard.projects.empty")}):null,e.slice(0,n).map((w,I)=>{const M=typeof w?.project_ref=="string"?w.project_ref:"",J=w?.project_key||M||`entry-${I}`,P=w?.billable_total_tokens??w?.total_tokens,L=Number(P),V=Number.isFinite(L)?L.toLocaleString():"—",q=w?.project_key||M.split("/").pop()||"—",fe=Number(w?.total_cost_usd),ve=Number(w?.unattributed_tokens),xe=Number.isFinite(fe)&&fe>0,pe=Number.isFinite(ve)&&ve>0,Me=xe?`$${fe<.01?fe.toFixed(4):fe.toFixed(2)}${pe?"+":""}`:pe?r("dashboard.projects.unpriced"):"";return o.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg",children:[o.jsx(Ic,{projectKey:w?.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:q})}),o.jsxs("div",{className:"text-right",children:[o.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white tabular-nums",children:V}),Me?o.jsx("div",{className:"oai-text-caption text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:Me}):null]})]},J)}),W?o.jsx("div",{className:"pt-2 oai-text-caption text-oai-gray-500 dark:text-oai-gray-400",children:`${r("dashboard.projects.unattributed")} ${t.join(", ")}`}):null]}),B==="daily"&&o.jsxs("div",{children:[p?.length===0?o.jsxs("div",{className:"oai-text-body-sm text-oai-gray-500 dark:text-oai-gray-300 mb-4",children:[l,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:i}),c]}):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:b.map((w,I)=>o.jsx("th",{...v?.(w.key)?{"aria-sort":v(w.key)}:{},className:"text-left p-0 bg-white dark:bg-oai-gray-900",children:o.jsx("button",{type:"button",onClick:()=>d(w.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:w.label}),o.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-400",children:k?.(w.key)||""})]})})},w.key))})}),o.jsx("tbody",{children:p.map(w=>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 ${w.missing?"text-oai-gray-400 dark:text-oai-gray-400":w.future?"text-oai-gray-300 dark:text-oai-gray-600":"text-oai-black dark:text-oai-white"}`,children:b.map((I,M)=>o.jsx("td",{className:`px-2.5 sm:px-4 py-2 oai-text-body-sm whitespace-nowrap ${H(w,I,M)}`,children:_(w,I,M)},I.key))},String(w?.[j]||w?.day||w?.hour||w?.month||"")))})]})}),B!=="daily"&&z.has($)&&D>1?o.jsxs("div",{className:"mt-3 flex items-center justify-between oai-text-caption",children:[o.jsx("button",{type:"button",onClick:()=>K(w=>Math.max(0,w-1)),disabled:A===0,className:"px-3 py-1.5 text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 rounded-md disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("details.pagination.prev")}),o.jsxs("span",{className:"oai-text-muted",children:[A+1," / ",D]}),o.jsx("button",{type:"button",onClick:()=>K(w=>Math.min(D-1,w+1)),disabled:A+1>=D,className:"px-3 py-1.5 text-oai-gray-600 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 rounded-md disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("details.pagination.next")})]}):null]})]})}const zc=e=>{const t=Number(e);return Number.isFinite(t)?t:0},Yc=new Set(["miss","empty","unattributed"]),Bc=new Set(["curated:fuzzy","litellm:fuzzy","litellm:prefix-strip","litellm:strip"]);function or(e){return String(e.model||e.model_id||"").trim()}function Hc(e,t){const n=Number(t);if(!Number.isFinite(n)||n<=0)return null;const a=zc(e?.totals?.total_cost_usd),r=Array.isArray(e?.models)?e.models:[],s=r.filter(u=>Yc.has(String(u.pricing_tier||""))).map(or).filter(Boolean),l=r.filter(u=>Bc.has(String(u.pricing_tier||""))).map(or).filter(Boolean),i=a/n,c=i>1?"above":i<1?"below":"even";return{source:String(e?.source||""),planPriceUsd:n,listPriceUsd:a,direction:c,ratio:i,confidence:s.length>0||l.length>0?"floor":"exact",unpricedModels:[...new Set(s)].sort(),fuzzyModels:[...new Set(l)].sort()}}function Uc(e){const t=e.filter(Boolean);if(t.length===0)return null;const n=t.reduce((r,s)=>r+s.planPriceUsd,0),a=t.reduce((r,s)=>r+s.listPriceUsd,0);return{planPriceUsd:n,listPriceUsd:a,direction:a>n?"above":a<n?"below":"even",confidence:t.some(r=>r.confidence==="floor")?"floor":"exact",providerCount:t.length}}function bn(e){const t=Number.isFinite(e)?e:0;return t>0&&t<.01?`$${t.toFixed(4)}`:`$${t.toFixed(2)}`}function Vc(e){const t=new Set;for(const n of e){for(const a of n.unpricedModels)t.add(a);for(const a of n.fuzzyModels)t.add(a)}return Array.from(t).sort().join(", ")}function qc({sources:e=[],planPrices:t={},onPlanPriceChange:n,copy:a,className:r=""}){const s=(Array.isArray(e)?e:[]).map(d=>String(d?.source||"").toLowerCase()).filter(Boolean),{values:l,rollup:i}=h.useMemo(()=>{const d=(Array.isArray(e)?e:[]).map(m=>Hc(m,t?.[String(m?.source||"").toLowerCase()])).filter(Boolean);return{values:d,rollup:Uc(d)}},[e,t]),c=a("dashboard.plan_value.title"),u=n?o.jsx("div",{className:"mt-2 space-y-1",children:s.map(d=>o.jsxs("label",{className:"flex items-baseline justify-between gap-3 oai-text-caption text-oai-gray-500 dark:text-oai-gray-400",children:[o.jsx("span",{className:"truncate",children:d}),o.jsx("input",{type:"number",min:"0",step:"1",inputMode:"decimal","aria-label":a("dashboard.plan_value.input_aria",{source:d}),value:t?.[d]??"",onChange:m=>{const g=m.target.value;n(d,g===""?null:Number(g))},className:"w-20 rounded border border-oai-gray-300 dark:border-oai-gray-700 oai-bg-elevated px-1.5 py-0.5 text-right tabular-nums"})]},d))}):null;if(!i)return o.jsxs("div",{className:r,children:[o.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white",children:c}),o.jsx("div",{className:"mt-1 oai-text-caption text-oai-gray-500 dark:text-oai-gray-400",children:a("dashboard.plan_value.empty")}),u]});const f=Vc(l);return o.jsxs("div",{className:r,children:[o.jsx("div",{className:"oai-text-body-sm font-medium text-oai-black dark:text-oai-white",children:c}),o.jsx("div",{className:"mt-1 oai-text-body-sm text-oai-black dark:text-oai-white tabular-nums",children:a("dashboard.plan_value.headline",{plan:bn(i.planPriceUsd),list:bn(i.listPriceUsd)})}),o.jsx("div",{className:"mt-2 space-y-1",children:l.map(d=>o.jsxs("div",{className:"flex items-baseline justify-between gap-3 oai-text-caption text-oai-gray-500 dark:text-oai-gray-400",children:[o.jsx("span",{className:"truncate",children:d.source}),o.jsx("span",{className:"tabular-nums whitespace-nowrap",children:a("dashboard.plan_value.row",{plan:bn(d.planPriceUsd),list:bn(d.listPriceUsd)})})]},d.source))}),u,i.confidence==="floor"?o.jsx("div",{className:"mt-2 oai-text-caption text-oai-gray-500 dark:text-oai-gray-400",children:a("dashboard.plan_value.floor_note",{models:f})}):null,o.jsx("div",{className:"mt-1 oai-text-caption text-oai-gray-500 dark:text-oai-gray-400",children:a("dashboard.plan_value.disclaimer")})]})}function Nn(e){return typeof e!="string"?"":e.trim()}function sr(e){const t=Nn(e);return t?t.split(/[_\-\s]+/).filter(Boolean).map(n=>n.slice(0,1).toUpperCase()+n.slice(1).toLowerCase()).join(" "):""}function Xc(e){if(!Array.isArray(e))return[];const t=new Map;for(const n of e){if(!n||typeof n!="object")continue;const a=Nn(n.tool),r=Nn(n.planType)||Nn(n.plan_type);if(!a||!r)continue;const s=sr(a)||a,l=sr(r)||r;t.set(`${a.toLowerCase()}::${r.toLowerCase()}`,{tool:s,plan:l})}return Array.from(t.values())}function ir({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=Xc(n);return o.jsxs(sn,{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(sl,{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 lr=2,Gc=.75,Kc=.005;function Qc(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)<Kc)return{hasBar:!1,side:null,widthPct:0,tone:null,labelText:"0%",arrow:null};const a=e>0,r=Math.min(Math.abs(e),lr)/lr*50;let s;t==="price"?s=a?"bad":"good":s=Math.abs(e)>=Gc?"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 Jc(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 Zc={thousandSuffix:"K",millionSuffix:"M",billionSuffix:"B"},ed=e=>e==null?"—":Ae(e,Zc),td=e=>e==null?"—":et(e,{decimals:e>=100?0:2}),nd=e=>e==null?"—":et(e,{decimals:2}),ad=[{key:"tokens",label:"Tokens",kind:"usage",format:ed},{key:"cost",label:"Cost",kind:"usage",format:td},{key:"perMTok",label:"$/MTok",kind:"price",format:nd}];function rd({label:e,delta:t,kind:n}){const a=Qc(t,n),r=Jc(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 od({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 sd({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})]}),ad.map(u=>{const f=e[u.key]||{},d=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:u.label}),o.jsx("span",{className:"text-xl font-bold text-oai-black dark:text-oai-white tabular-nums truncate",children:u.format(f.value)})]}),o.jsx("div",{className:"mt-2 flex flex-col gap-1.5",children:l.map(m=>o.jsx(rd,{label:m.label,delta:f[m.field],kind:u.kind},m.field))}),d?o.jsx(od,{ratio:f.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 id(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 ld={},Qt={};function Tt(e,t){try{const a=(ld[e]||=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format)(t).split("GMT")[1];return a in Qt?Qt[a]:cr(a,a.split(":"))}catch{if(e in Qt)return Qt[e];const n=e?.match(cd);return n?cr(e,n.slice(1)):NaN}}const cd=/([+-]\d\d):?(\d\d)?/;function cr(e,t){const n=+(t[0]||0),a=+(t[1]||0),r=+(t[2]||0)/60;return Qt[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)),xo(this),ia(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),ia(this),+this}[Symbol.for("constructDateFrom")](t){return new rt(+new Date(t),this.timeZone)}}const dr=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!dr.test(e))return;const t=e.replace(dr,"$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),dd(this),+this},rt.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),ia(this),+this}))});function ia(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-Tt(e.timeZone,e)*60))}function dd(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()),xo(e)}function xo(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 f=r>0?u.getSeconds():(u.getSeconds()-60)%60,d=Math.round(-(Tt(e.timeZone,e)*60))%60;(d||f)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+d),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+d+f));const m=Tt(e.timeZone,e),g=m>0?Math.floor(m):Math.ceil(m),b=-new Date(+e).getTimezoneOffset()-g,v=g!==n,k=b-c;if(v&&k){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+k);const j=Tt(e.timeZone,e),x=j>0?Math.floor(j):Math.ceil(j),N=g-x;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} (${id(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 ko=6048e5,ud=864e5,ur=Symbol.for("constructDateFrom");function Pe(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&ur in e?e[ur](t):e instanceof Date?new e.constructor(t):new Date(t)}function we(e,t){return Pe(t||e,e)}function wo(e,t,n){const a=we(e,n?.in);return isNaN(t)?Pe(e,NaN):(t&&a.setDate(a.getDate()+t),a)}function vo(e,t,n){const a=we(e,n?.in);if(isNaN(t))return Pe(e,NaN);if(!t)return a;const r=a.getDate(),s=Pe(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 fd={};function cn(){return fd}function Nt(e,t){const n=cn(),a=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=we(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 nn(e,t){return Nt(e,{...t,weekStartsOn:1})}function No(e,t){const n=we(e,t?.in),a=n.getFullYear(),r=Pe(n,0);r.setFullYear(a+1,0,4),r.setHours(0,0,0,0);const s=nn(r),l=Pe(n,0);l.setFullYear(a,0,4),l.setHours(0,0,0,0);const i=nn(l);return n.getTime()>=s.getTime()?a+1:n.getTime()>=i.getTime()?a:a-1}function fr(e){const t=we(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=Pe.bind(null,e||t.find(a=>typeof a=="object"));return t.map(n)}function an(e,t){const n=we(e,t?.in);return n.setHours(0,0,0,0),n}function ya(e,t,n){const[a,r]=Pt(n?.in,e,t),s=an(a),l=an(r),i=+s-fr(s),c=+l-fr(l);return Math.round((i-c)/ud)}function md(e,t){const n=No(e,t),a=Pe(e,0);return a.setFullYear(n,0,4),a.setHours(0,0,0,0),nn(a)}function hd(e,t,n){return wo(e,t*7,n)}function gd(e,t,n){return vo(e,t*12,n)}function yd(e,t){let n,a=t?.in;return e.forEach(r=>{!a&&typeof r=="object"&&(a=Pe.bind(null,r));const s=we(r,a);(!n||n<s||isNaN(+s))&&(n=s)}),Pe(a,n||NaN)}function pd(e,t){let n,a=t?.in;return e.forEach(r=>{!a&&typeof r=="object"&&(a=Pe.bind(null,r));const s=we(r,a);(!n||n>s||isNaN(+s))&&(n=s)}),Pe(a,n||NaN)}function bd(e,t,n){const[a,r]=Pt(n?.in,e,t);return+an(a)==+an(r)}function _o(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function xd(e){return!(!_o(e)&&typeof e!="number"||isNaN(+we(e)))}function Mo(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 kd(e,t){const n=we(e,t?.in),a=n.getMonth();return n.setFullYear(n.getFullYear(),a+1,0),n.setHours(23,59,59,999),n}function jo(e,t){const[n,a]=Pt(e,t.start,t.end);return{start:n,end:a}}function wd(e,t){const{start:n,end:a}=jo(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(Pe(n,l)),l.setMonth(l.getMonth()+i);return r?c.reverse():c}function vd(e,t){const n=we(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function Nd(e,t){const n=we(e,t?.in),a=n.getFullYear();return n.setFullYear(a+1,0,0),n.setHours(23,59,59,999),n}function So(e,t){const n=we(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function _d(e,t){const{start:n,end:a}=jo(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(Pe(n,l)),l.setFullYear(l.getFullYear()+i);return r?c.reverse():c}function Co(e,t){const n=cn(),a=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=we(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 Md(e,t){return Co(e,{...t,weekStartsOn:1})}const jd={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"}},Sd=(e,t,n)=>{let a;const r=jd[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 ze(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const Cd={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Dd={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Td={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Pd={date:ze({formats:Cd,defaultWidth:"full"}),time:ze({formats:Dd,defaultWidth:"full"}),dateTime:ze({formats:Td,defaultWidth:"full"})},Od={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},$d=(e,t,n,a)=>Od[e];function Ne(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 Ed={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Wd={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Ad={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"]},Rd={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"}},Id={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"}},Ld=(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"},zd={ordinalNumber:Ld,era:Ne({values:Ed,defaultWidth:"wide"}),quarter:Ne({values:Wd,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Ne({values:Ad,defaultWidth:"wide"}),day:Ne({values:Fd,defaultWidth:"wide"}),dayPeriod:Ne({values:Rd,defaultWidth:"wide",formattingValues:Id,defaultFormattingWidth:"wide"})};function _e(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,d=>d.test(l)):Yd(i,d=>d.test(l));let u;u=e.valueCallback?e.valueCallback(c):c,u=n.valueCallback?n.valueCallback(u):u;const f=t.slice(l.length);return{value:u,rest:f}}}function Yd(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 dn(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 Hd=/^(\d+)(th|st|nd|rd)?/i,Ud=/\d+/i,Vd={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},qd={any:[/^b/i,/^(a|c)/i]},Xd={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Gd={any:[/1/i,/2/i,/3/i,/4/i]},Kd={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},Qd={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]},Jd={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},Zd={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]},eu={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},tu={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}},nu={ordinalNumber:dn({matchPattern:Hd,parsePattern:Ud,valueCallback:e=>parseInt(e,10)}),era:_e({matchPatterns:Vd,defaultMatchWidth:"wide",parsePatterns:qd,defaultParseWidth:"any"}),quarter:_e({matchPatterns:Xd,defaultMatchWidth:"wide",parsePatterns:Gd,defaultParseWidth:"any",valueCallback:e=>e+1}),month:_e({matchPatterns:Kd,defaultMatchWidth:"wide",parsePatterns:Qd,defaultParseWidth:"any"}),day:_e({matchPatterns:Jd,defaultMatchWidth:"wide",parsePatterns:Zd,defaultParseWidth:"any"}),dayPeriod:_e({matchPatterns:eu,defaultMatchWidth:"any",parsePatterns:tu,defaultParseWidth:"any"})},vt={code:"en-US",formatDistance:Sd,formatLong:Pd,formatRelative:$d,localize:zd,match:nu,options:{weekStartsOn:0,firstWeekContainsDate:1}};function au(e,t){const n=we(e,t?.in);return ya(n,So(n))+1}function pa(e,t){const n=we(e,t?.in),a=+nn(n)-+md(n);return Math.round(a/ko)+1}function Do(e,t){const n=we(e,t?.in),a=n.getFullYear(),r=cn(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,l=Pe(t?.in||e,0);l.setFullYear(a+1,0,s),l.setHours(0,0,0,0);const i=Nt(l,t),c=Pe(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 ru(e,t){const n=cn(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,r=Do(e,t),s=Pe(t?.in||e,0);return s.setFullYear(r,0,a),s.setHours(0,0,0,0),Nt(s,t)}function ba(e,t){const n=we(e,t?.in),a=+Nt(n,t)-+ru(n,t);return Math.round(a/ko)+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)}},At={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},mr={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=Do(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=No(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=ba(e,a);return t==="wo"?n.ordinalNumber(r,{unit:"week"}):be(r,t.length)},I:function(e,t,n){const a=pa(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=au(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=At.noon:a===0?r=At.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=At.evening:a>=12?r=At.afternoon:a>=4?r=At.morning:r=At.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 gr(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 gr(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"+hr(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"+hr(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 hr(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 gr(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 yr=(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"})}},To=(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"})}},ou=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],a=n[1],r=n[2];if(!r)return yr(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}}",yr(a,t)).replace("{{time}}",To(r,t))},su={p:To,P:ou},iu=/^D+$/,lu=/^Y+$/,cu=["D","DD","YY","YYYY"];function du(e){return iu.test(e)}function uu(e){return lu.test(e)}function fu(e,t,n){const a=mu(e,t,n);if(console.warn(a),cu.includes(e))throw new RangeError(a)}function mu(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 hu=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,gu=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,yu=/^'([^]*?)'?$/,pu=/''/g,bu=/[a-zA-Z]/;function ot(e,t,n){const a=cn(),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=we(e,n?.in);if(!xd(i))throw new RangeError("Invalid time value");let c=t.match(gu).map(f=>{const d=f[0];if(d==="p"||d==="P"){const m=su[d];return m(f,r.formatLong)}return f}).join("").match(hu).map(f=>{if(f==="''")return{isToken:!1,value:"'"};const d=f[0];if(d==="'")return{isToken:!1,value:xu(f)};if(mr[d])return{isToken:!0,value:f};if(d.match(bu))throw new RangeError("Format string contains an unescaped latin alphabet character `"+d+"`");return{isToken:!1,value:f}});r.localize.preprocessor&&(c=r.localize.preprocessor(i,c));const u={firstWeekContainsDate:s,weekStartsOn:l,locale:r};return c.map(f=>{if(!f.isToken)return f.value;const d=f.value;(!n?.useAdditionalWeekYearTokens&&uu(d)||!n?.useAdditionalDayOfYearTokens&&du(d))&&fu(d,t,String(e));const m=mr[d[0]];return m(i,d,r.localize,u)}).join("")}function xu(e){const t=e.match(yu);return t?t[1].replace(pu,"'"):e}function ku(e,t){const n=we(e,t?.in),a=n.getFullYear(),r=n.getMonth(),s=Pe(n,0);return s.setFullYear(a,r+1,0),s.setHours(0,0,0,0),s.getDate()}function wu(e,t){return we(e,t?.in).getMonth()}function vu(e,t){return we(e,t?.in).getFullYear()}function Nu(e,t){return+we(e)>+we(t)}function _u(e,t){return+we(e)<+we(t)}function Mu(e,t,n){const[a,r]=Pt(n?.in,e,t);return+Nt(a,n)==+Nt(r,n)}function ju(e,t,n){const[a,r]=Pt(n?.in,e,t);return a.getFullYear()===r.getFullYear()&&a.getMonth()===r.getMonth()}function Su(e,t,n){const[a,r]=Pt(n?.in,e,t);return a.getFullYear()===r.getFullYear()}function Cu(e,t,n){const a=we(e,n?.in),r=a.getFullYear(),s=a.getDate(),l=Pe(e,0);l.setFullYear(r,t,15),l.setHours(0,0,0,0);const i=ku(l);return a.setMonth(t,Math.min(s,i)),a}function Du(e,t,n){const a=we(e,n?.in);return isNaN(+a)?Pe(e,NaN):(a.setFullYear(t),a)}const pr=5,Tu=4;function Pu(e,t){const n=t.startOfMonth(e),a=n.getDay()>0?n.getDay():7,r=t.addDays(e,-a+1),s=t.addDays(r,pr*7-1);return t.getMonth(e)===t.getMonth(s)?pr:Tu}function Po(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 Ou(e,t){const n=Po(e,t),a=Pu(e,t);return t.addDays(n,a*7-1)}const $u={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}}年近く"}},Eu=(e,t,n)=>{n=n||{};let a;const r=$u[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},Wu={full:"y年M月d日EEEE",long:"y年M月d日",medium:"y/MM/dd",short:"y/MM/dd"},Au={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}}"},Ru={date:ze({formats:Wu,defaultWidth:"full"}),time:ze({formats:Au,defaultWidth:"full"}),dateTime:ze({formats:Fu,defaultWidth:"full"})},Iu={lastWeek:"先週のeeeeのp",yesterday:"昨日のp",today:"今日のp",tomorrow:"明日のp",nextWeek:"翌週のeeeeのp",other:"P"},Lu=(e,t,n,a)=>Iu[e],zu={narrow:["BC","AC"],abbreviated:["紀元前","西暦"],wide:["紀元前","西暦"]},Yu={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月"]},Hu={narrow:["日","月","火","水","木","金","土"],short:["日","月","火","水","木","金","土"],abbreviated:["日","月","火","水","木","金","土"],wide:["日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日"]},Uu={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={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=(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}`}},Xu={ordinalNumber:qu,era:Ne({values:zu,defaultWidth:"wide"}),quarter:Ne({values:Yu,defaultWidth:"wide",argumentCallback:e=>Number(e)-1}),month:Ne({values:Bu,defaultWidth:"wide"}),day:Ne({values:Hu,defaultWidth:"wide"}),dayPeriod:Ne({values:Uu,defaultWidth:"wide",formattingValues:Vu,defaultFormattingWidth:"wide"})},Gu=/^第?\d+(年|四半期|月|週|日|時|分|秒)?/i,Ku=/\d+/i,Qu={narrow:/^(B\.?C\.?|A\.?D\.?)/i,abbreviated:/^(紀元[前後]|西暦)/i,wide:/^(紀元[前後]|西暦)/i},Ju={narrow:[/^B/i,/^A/i],any:[/^(紀元前)/i,/^(西暦|紀元後)/i]},Zu={narrow:/^[1234]/i,abbreviated:/^Q[1234]/i,wide:/^第[1234一二三四1234]四半期/i},ef={any:[/(1|一|1)/i,/(2|二|2)/i,/(3|三|3)/i,/(4|四|4)/i]},tf={narrow:/^([123456789]|1[012])/,abbreviated:/^([123456789]|1[012])月/i,wide:/^([123456789]|1[012])月/i},nf={any:[/^1\D/,/^2/,/^3/,/^4/,/^5/,/^6/,/^7/,/^8/,/^9/,/^10/,/^11/,/^12/]},af={narrow:/^[日月火水木金土]/,short:/^[日月火水木金土]/,abbreviated:/^[日月火水木金土]/,wide:/^[日月火水木金土]曜日/},rf={any:[/^日/,/^月/,/^火/,/^水/,/^木/,/^金/,/^土/]},of={any:/^(AM|PM|午前|午後|正午|深夜|真夜中|夜|朝)/i},sf={any:{am:/^(A|午前)/i,pm:/^(P|午後)/i,midnight:/^深夜|真夜中/i,noon:/^正午/i,morning:/^朝/i,afternoon:/^午後/i,evening:/^夜/i,night:/^深夜/i}},lf={ordinalNumber:dn({matchPattern:Gu,parsePattern:Ku,valueCallback:function(e){return parseInt(e,10)}}),era:_e({matchPatterns:Qu,defaultMatchWidth:"wide",parsePatterns:Ju,defaultParseWidth:"any"}),quarter:_e({matchPatterns:Zu,defaultMatchWidth:"wide",parsePatterns:ef,defaultParseWidth:"any",valueCallback:e=>e+1}),month:_e({matchPatterns:tf,defaultMatchWidth:"wide",parsePatterns:nf,defaultParseWidth:"any"}),day:_e({matchPatterns:af,defaultMatchWidth:"wide",parsePatterns:rf,defaultParseWidth:"any"}),dayPeriod:_e({matchPatterns:of,defaultMatchWidth:"any",parsePatterns:sf,defaultParseWidth:"any"})},cf={code:"ja",formatDistance:Eu,formatLong:Ru,formatRelative:Lu,localize:Xu,match:lf,options:{weekStartsOn:0,firstWeekContainsDate:1}},df={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}}년"}},uf=(e,t,n)=>{let a;const r=df[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},ff={full:"y년 M월 d일 EEEE",long:"y년 M월 d일",medium:"y.MM.dd",short:"y.MM.dd"},mf={full:"a H시 mm분 ss초 zzzz",long:"a H:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},hf={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},gf={date:ze({formats:ff,defaultWidth:"full"}),time:ze({formats:mf,defaultWidth:"full"}),dateTime:ze({formats:hf,defaultWidth:"full"})},yf={lastWeek:"'지난' eeee p",yesterday:"'어제' p",today:"'오늘' p",tomorrow:"'내일' p",nextWeek:"'다음' eeee p",other:"P"},pf=(e,t,n,a)=>yf[e],bf={narrow:["BC","AD"],abbreviated:["BC","AD"],wide:["기원전","서기"]},xf={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1분기","2분기","3분기","4분기"]},kf={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월"]},wf={narrow:["일","월","화","수","목","금","토"],short:["일","월","화","수","목","금","토"],abbreviated:["일","월","화","수","목","금","토"],wide:["일요일","월요일","화요일","수요일","목요일","금요일","토요일"]},vf={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:"밤"}},Nf={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:"밤"}},_f=(e,t)=>{const n=Number(e);switch(String(t?.unit)){case"minute":case"second":return String(n);case"date":return n+"일";default:return n+"번째"}},Mf={ordinalNumber:_f,era:Ne({values:bf,defaultWidth:"wide"}),quarter:Ne({values:xf,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Ne({values:kf,defaultWidth:"wide"}),day:Ne({values:wf,defaultWidth:"wide"}),dayPeriod:Ne({values:vf,defaultWidth:"wide",formattingValues:Nf,defaultFormattingWidth:"wide"})},jf=/^(\d+)(일|번째)?/i,Sf=/\d+/i,Cf={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},Df={any:[/^(bc|기원전)/i,/^(ad|서기)/i]},Tf={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234]사?분기/i},Pf={any:[/1/i,/2/i,/3/i,/4/i]},Of={narrow:/^(1[012]|[123456789])/,abbreviated:/^(1[012]|[123456789])월/i,wide:/^(1[012]|[123456789])월/i},$f={any:[/^1월?$/,/^2/,/^3/,/^4/,/^5/,/^6/,/^7/,/^8/,/^9/,/^10/,/^11/,/^12/]},Ef={narrow:/^[일월화수목금토]/,short:/^[일월화수목금토]/,abbreviated:/^[일월화수목금토]/,wide:/^[일월화수목금토]요일/},Wf={any:[/^일/,/^월/,/^화/,/^수/,/^목/,/^금/,/^토/]},Af={any:/^(am|pm|오전|오후|자정|정오|아침|저녁|밤)/i},Ff={any:{am:/^(am|오전)/i,pm:/^(pm|오후)/i,midnight:/^자정/i,noon:/^정오/i,morning:/^아침/i,afternoon:/^오후/i,evening:/^저녁/i,night:/^밤/i}},Rf={ordinalNumber:dn({matchPattern:jf,parsePattern:Sf,valueCallback:e=>parseInt(e,10)}),era:_e({matchPatterns:Cf,defaultMatchWidth:"wide",parsePatterns:Df,defaultParseWidth:"any"}),quarter:_e({matchPatterns:Tf,defaultMatchWidth:"wide",parsePatterns:Pf,defaultParseWidth:"any",valueCallback:e=>e+1}),month:_e({matchPatterns:Of,defaultMatchWidth:"wide",parsePatterns:$f,defaultParseWidth:"any"}),day:_e({matchPatterns:Ef,defaultMatchWidth:"wide",parsePatterns:Wf,defaultParseWidth:"any"}),dayPeriod:_e({matchPatterns:Af,defaultMatchWidth:"any",parsePatterns:Ff,defaultParseWidth:"any"})},If={code:"ko",formatDistance:uf,formatLong:gf,formatRelative:pf,localize:Mf,match:Rf,options:{weekStartsOn:0,firstWeekContainsDate:1}},Lf={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}} 年"}},zf=(e,t,n)=>{let a;const r=Lf[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},Yf={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"},Hf={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},Uf={date:ze({formats:Yf,defaultWidth:"full"}),time:ze({formats:Bf,defaultWidth:"full"}),dateTime:ze({formats:Hf,defaultWidth:"full"})};function br(e,t,n){const a="eeee p";return Mu(e,t,n)?a:e.getTime()>t.getTime()?"'下个'"+a:"'上个'"+a}const Vf={lastWeek:br,yesterday:"'昨天' p",today:"'今天' p",tomorrow:"'明天' p",nextWeek:br,other:"PP p"},qf=(e,t,n,a)=>{const r=Vf[e];return typeof r=="function"?r(t,n,a):r},Xf={narrow:["前","公元"],abbreviated:["前","公元"],wide:["公元前","公元"]},Gf={narrow:["1","2","3","4"],abbreviated:["第一季","第二季","第三季","第四季"],wide:["第一季度","第二季度","第三季度","第四季度"]},Kf={narrow:["一","二","三","四","五","六","七","八","九","十","十一","十二"],abbreviated:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],wide:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},Qf={narrow:["日","一","二","三","四","五","六"],short:["日","一","二","三","四","五","六"],abbreviated:["周日","周一","周二","周三","周四","周五","周六"],wide:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},Jf={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:"夜间"}},Zf={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:"夜间"}},em=(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()}},tm={ordinalNumber:em,era:Ne({values:Xf,defaultWidth:"wide"}),quarter:Ne({values:Gf,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Ne({values:Kf,defaultWidth:"wide"}),day:Ne({values:Qf,defaultWidth:"wide"}),dayPeriod:Ne({values:Jf,defaultWidth:"wide",formattingValues:Zf,defaultFormattingWidth:"wide"})},nm=/^(第\s*)?\d+(日|时|分|秒)?/i,am=/\d+/i,rm={narrow:/^(前)/i,abbreviated:/^(前)/i,wide:/^(公元前|公元)/i},om={any:[/^(前)/i,/^(公元)/i]},sm={narrow:/^[1234]/i,abbreviated:/^第[一二三四]刻/i,wide:/^第[一二三四]刻钟/i},im={any:[/(1|一)/i,/(2|二)/i,/(3|三)/i,/(4|四)/i]},lm={narrow:/^(一|二|三|四|五|六|七|八|九|十[二一])/i,abbreviated:/^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,wide:/^(一|二|三|四|五|六|七|八|九|十[二一])月/i},cm={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]},dm={narrow:/^[一二三四五六日]/i,short:/^[一二三四五六日]/i,abbreviated:/^周[一二三四五六日]/i,wide:/^星期[一二三四五六日]/i},um={any:[/日/i,/一/i,/二/i,/三/i,/四/i,/五/i,/六/i]},fm={any:/^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨|)/i},mm={any:{am:/^上午?/i,pm:/^下午?/i,midnight:/^午夜/i,noon:/^[中正]午/i,morning:/^早上/i,afternoon:/^下午/i,evening:/^晚上?/i,night:/^凌晨/i}},hm={ordinalNumber:dn({matchPattern:nm,parsePattern:am,valueCallback:e=>parseInt(e,10)}),era:_e({matchPatterns:rm,defaultMatchWidth:"wide",parsePatterns:om,defaultParseWidth:"any"}),quarter:_e({matchPatterns:sm,defaultMatchWidth:"wide",parsePatterns:im,defaultParseWidth:"any",valueCallback:e=>e+1}),month:_e({matchPatterns:lm,defaultMatchWidth:"wide",parsePatterns:cm,defaultParseWidth:"any"}),day:_e({matchPatterns:dm,defaultMatchWidth:"wide",parsePatterns:um,defaultParseWidth:"any"}),dayPeriod:_e({matchPatterns:fm,defaultMatchWidth:"any",parsePatterns:mm,defaultParseWidth:"any"})},gm={code:"zh-CN",formatDistance:zf,formatLong:Uf,formatRelative:qf,localize:tm,match:hm,options:{weekStartsOn:1,firstWeekContainsDate:4}},ym={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}} 年"}},pm=(e,t,n)=>{let a;const r=ym[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},bm={full:"y'年'M'月'd'日' EEEE",long:"y'年'M'月'd'日'",medium:"yyyy-MM-dd",short:"yy-MM-dd"},xm={full:"zzzz a h:mm:ss",long:"z a h:mm:ss",medium:"a h:mm:ss",short:"a h:mm"},km={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},wm={date:ze({formats:bm,defaultWidth:"full"}),time:ze({formats:xm,defaultWidth:"full"}),dateTime:ze({formats:km,defaultWidth:"full"})},vm={lastWeek:"'上個'eeee p",yesterday:"'昨天' p",today:"'今天' p",tomorrow:"'明天' p",nextWeek:"'下個'eeee p",other:"P"},Nm=(e,t,n,a)=>vm[e],_m={narrow:["前","公元"],abbreviated:["前","公元"],wide:["公元前","公元"]},Mm={narrow:["1","2","3","4"],abbreviated:["第一刻","第二刻","第三刻","第四刻"],wide:["第一刻鐘","第二刻鐘","第三刻鐘","第四刻鐘"]},jm={narrow:["一","二","三","四","五","六","七","八","九","十","十一","十二"],abbreviated:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],wide:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},Sm={narrow:["日","一","二","三","四","五","六"],short:["日","一","二","三","四","五","六"],abbreviated:["週日","週一","週二","週三","週四","週五","週六"],wide:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},Cm={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:"夜間"}},Dm={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=(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}},Pm={ordinalNumber:Tm,era:Ne({values:_m,defaultWidth:"wide"}),quarter:Ne({values:Mm,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Ne({values:jm,defaultWidth:"wide"}),day:Ne({values:Sm,defaultWidth:"wide"}),dayPeriod:Ne({values:Cm,defaultWidth:"wide",formattingValues:Dm,defaultFormattingWidth:"wide"})},Om=/^(第\s*)?\d+(日|時|分|秒)?/i,$m=/\d+/i,Em={narrow:/^(前)/i,abbreviated:/^(前)/i,wide:/^(公元前|公元)/i},Wm={any:[/^(前)/i,/^(公元)/i]},Am={narrow:/^[1234]/i,abbreviated:/^第[一二三四]刻/i,wide:/^第[一二三四]刻鐘/i},Fm={any:[/(1|一)/i,/(2|二)/i,/(3|三)/i,/(4|四)/i]},Rm={narrow:/^(一|二|三|四|五|六|七|八|九|十[二一])/i,abbreviated:/^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,wide:/^(一|二|三|四|五|六|七|八|九|十[二一])月/i},Im={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]},Lm={narrow:/^[一二三四五六日]/i,short:/^[一二三四五六日]/i,abbreviated:/^週[一二三四五六日]/i,wide:/^星期[一二三四五六日]/i},zm={any:[/日/i,/一/i,/二/i,/三/i,/四/i,/五/i,/六/i]},Ym={any:/^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨)/i},Bm={any:{am:/^上午?/i,pm:/^下午?/i,midnight:/^午夜/i,noon:/^[中正]午/i,morning:/^早上/i,afternoon:/^下午/i,evening:/^晚上?/i,night:/^凌晨/i}},Hm={ordinalNumber:dn({matchPattern:Om,parsePattern:$m,valueCallback:e=>parseInt(e,10)}),era:_e({matchPatterns:Em,defaultMatchWidth:"wide",parsePatterns:Wm,defaultParseWidth:"any"}),quarter:_e({matchPatterns:Am,defaultMatchWidth:"wide",parsePatterns:Fm,defaultParseWidth:"any",valueCallback:e=>e+1}),month:_e({matchPatterns:Rm,defaultMatchWidth:"wide",parsePatterns:Im,defaultParseWidth:"any"}),day:_e({matchPatterns:Lm,defaultMatchWidth:"wide",parsePatterns:zm,defaultParseWidth:"any"}),dayPeriod:_e({matchPatterns:Ym,defaultMatchWidth:"any",parsePatterns:Bm,defaultParseWidth:"any"})},Um={code:"zh-TW",formatDistance:pm,formatLong:wm,formatRelative:Nm,localize:Pm,match:Hm,options:{weekStartsOn:1,firstWeekContainsDate:4}},Oo={...vt,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: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)=>ot(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)=>ot(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)=>ot(r,s,{locale:vt,...t}),a(e,"cccc")}}};class He{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):wo(a,r),this.addMonths=(a,r)=>this.overrides?.addMonths?this.overrides.addMonths(a,r):vo(a,r),this.addWeeks=(a,r)=>this.overrides?.addWeeks?this.overrides.addWeeks(a,r):hd(a,r),this.addYears=(a,r)=>this.overrides?.addYears?this.overrides.addYears(a,r):gd(a,r),this.differenceInCalendarDays=(a,r)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(a,r):ya(a,r),this.differenceInCalendarMonths=(a,r)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(a,r):Mo(a,r),this.eachMonthOfInterval=a=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(a):wd(a),this.eachYearOfInterval=a=>{const r=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(a):_d(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):Ou(a,this),this.endOfISOWeek=a=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(a):Md(a),this.endOfMonth=a=>this.overrides?.endOfMonth?this.overrides.endOfMonth(a):kd(a),this.endOfWeek=(a,r)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(a,r):Co(a,this.options),this.endOfYear=a=>this.overrides?.endOfYear?this.overrides.endOfYear(a):Nd(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):pa(a),this.getMonth=(a,r)=>this.overrides?.getMonth?this.overrides.getMonth(a,this.options):wu(a,this.options),this.getYear=(a,r)=>this.overrides?.getYear?this.overrides.getYear(a,this.options):vu(a,this.options),this.getWeek=(a,r)=>this.overrides?.getWeek?this.overrides.getWeek(a,this.options):ba(a,this.options),this.isAfter=(a,r)=>this.overrides?.isAfter?this.overrides.isAfter(a,r):Nu(a,r),this.isBefore=(a,r)=>this.overrides?.isBefore?this.overrides.isBefore(a,r):_u(a,r),this.isDate=a=>this.overrides?.isDate?this.overrides.isDate(a):_o(a),this.isSameDay=(a,r)=>this.overrides?.isSameDay?this.overrides.isSameDay(a,r):bd(a,r),this.isSameMonth=(a,r)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(a,r):ju(a,r),this.isSameYear=(a,r)=>this.overrides?.isSameYear?this.overrides.isSameYear(a,r):Su(a,r),this.max=a=>this.overrides?.max?this.overrides.max(a):yd(a),this.min=a=>this.overrides?.min?this.overrides.min(a):pd(a),this.setMonth=(a,r)=>this.overrides?.setMonth?this.overrides.setMonth(a,r):Cu(a,r),this.setYear=(a,r)=>this.overrides?.setYear?this.overrides.setYear(a,r):Du(a,r),this.startOfBroadcastWeek=(a,r)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(a,this):Po(a,this),this.startOfDay=a=>this.overrides?.startOfDay?this.overrides.startOfDay(a):an(a),this.startOfISOWeek=a=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(a):nn(a),this.startOfMonth=a=>this.overrides?.startOfMonth?this.overrides.startOfMonth(a):vd(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):So(a),this.options={locale:Oo,...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&&He.yearFirstLocales.has(t)?"year-first":"month-first"}formatMonthYear(t){const{locale:n,timeZone:a,numerals:r}=this.options,s=n?.code;if(s&&He.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)}}He.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 He;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 Vm{constructor(t,n){this.date=t,this.weeks=n}}class qm{constructor(t,n){this.days=n,this.weekNumber=t}}function Xm(e){return R.createElement("button",{...e})}function Gm(e){return R.createElement("span",{...e})}function Km(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 Qm(e){const{day:t,modifiers:n,...a}=e;return R.createElement("td",{...a})}function Jm(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 Z;(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"})(Z||(Z={}));var Se;(function(e){e.disabled="disabled",e.hidden="hidden",e.outside="outside",e.focused="focused",e.today="today"})(Se||(Se={}));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 Be;(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"})(Be||(Be={}));function Zm(e){const{options:t,className:n,components:a,classNames:r,...s}=e,l=[r[Z.Dropdown],n].join(" "),i=t?.find(({value:c})=>c===s.value);return R.createElement("span",{"data-disabled":s.disabled,className:r[Z.DropdownRoot]},R.createElement(a.Select,{className:l,...s},t?.map(({value:c,label:u,disabled:f})=>R.createElement(a.Option,{key:c,value:c,disabled:f},u))),R.createElement("span",{className:r[Z.CaptionLabel],"aria-hidden":!0},i?.label,R.createElement(a.Chevron,{orientation:"down",size:18,className:r[Z.Chevron]})))}function eh(e){return R.createElement("div",{...e})}function th(e){return R.createElement("div",{...e})}function nh(e){const{calendarMonth:t,displayIndex:n,...a}=e;return R.createElement("div",{...a},e.children)}function ah(e){const{calendarMonth:t,displayIndex:n,...a}=e;return R.createElement("div",{...a})}function rh(e){return R.createElement("table",{...e})}function oh(e){return R.createElement("div",{...e})}const Eo=h.createContext(void 0);function un(){const e=h.useContext(Eo);if(e===void 0)throw new Error("useDayPicker() must be used within a custom component.");return e}function sh(e){const{components:t}=un();return R.createElement(t.Dropdown,{...e})}function ih(e){const{onPreviousClick:t,onNextClick:n,previousMonth:a,nextMonth:r,...s}=e,{components:l,classNames:i,labels:{labelPrevious:c,labelNext:u}}=un(),f=h.useCallback(m=>{r&&n?.(m)},[r,n]),d=h.useCallback(m=>{a&&t?.(m)},[a,t]);return R.createElement("nav",{...s},R.createElement(l.PreviousMonthButton,{type:"button",className:i[Z.PreviousMonthButton],tabIndex:a?void 0:-1,"aria-disabled":a?void 0:!0,"aria-label":c(a),onClick:d},R.createElement(l.Chevron,{disabled:a?void 0:!0,className:i[Z.Chevron],orientation:"left"})),R.createElement(l.NextMonthButton,{type:"button",className:i[Z.NextMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":u(r),onClick:f},R.createElement(l.Chevron,{disabled:r?void 0:!0,orientation:"right",className:i[Z.Chevron]})))}function lh(e){const{components:t}=un();return R.createElement(t.Button,{...e})}function ch(e){return R.createElement("option",{...e})}function dh(e){const{components:t}=un();return R.createElement(t.Button,{...e})}function uh(e){const{rootRef:t,...n}=e;return R.createElement("div",{...n,ref:t})}function fh(e){return R.createElement("select",{...e})}function mh(e){const{week:t,...n}=e;return R.createElement("tr",{...n})}function hh(e){return R.createElement("th",{...e})}function gh(e){return R.createElement("thead",{"aria-hidden":!0},R.createElement("tr",{...e}))}function yh(e){const{week:t,...n}=e;return R.createElement("th",{...n})}function ph(e){return R.createElement("th",{...e})}function bh(e){return R.createElement("tbody",{...e})}function xh(e){const{components:t}=un();return R.createElement(t.Dropdown,{...e})}const kh=Object.freeze(Object.defineProperty({__proto__:null,Button:Xm,CaptionLabel:Gm,Chevron:Km,Day:Qm,DayButton:Jm,Dropdown:Zm,DropdownNav:eh,Footer:th,Month:nh,MonthCaption:ah,MonthGrid:rh,Months:oh,MonthsDropdown:sh,Nav:ih,NextMonthButton:lh,Option:ch,PreviousMonthButton:dh,Root:uh,Select:fh,Week:mh,WeekNumber:yh,WeekNumberHeader:ph,Weekday:hh,Weekdays:gh,Weeks:bh,YearsDropdown:xh},Symbol.toStringTag,{value:"Module"}));function ft(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 xa(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function Dn(e){return!!(e&&typeof e=="object"&&"from"in e)}function ka(e){return!!(e&&typeof e=="object"&&"after"in e)}function wa(e){return!!(e&&typeof e=="object"&&"before"in e)}function Wo(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function Ao(e,t){return Array.isArray(e)&&e.every(t.isDate)}function mt(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(Ao(i,n))return i.some(c=>r(e,c));if(Dn(i))return ft(i,e,!1,n);if(Wo(i))return Array.isArray(i.dayOfWeek)?i.dayOfWeek.includes(e.getDay()):i.dayOfWeek===e.getDay();if(xa(i)){const c=s(i.before,e),u=s(i.after,e),f=c>0,d=u<0;return l(i.before,i.after)?d&&f:f||d}return ka(i)?s(e,i.after)>0:wa(i)?s(i.before,e)>0:typeof i=="function"?i(e):!1})}function wh(e,t,n,a,r){const{disabled:s,hidden:l,modifiers:i,showOutsideDays:c,broadcastCalendar:u,today:f=r.today()}=t,{isSameDay:d,isSameMonth:m,startOfMonth:g,isBefore:p,endOfMonth:b,isAfter:v}=r,k=n&&g(n),j=a&&b(a),x={[Se.focused]:[],[Se.outside]:[],[Se.disabled]:[],[Se.hidden]:[],[Se.today]:[]},N={};for(const C of e){const{date:T,displayMonth:z}=C,$=!!(z&&!m(T,z)),D=!!(k&&p(T,k)),A=!!(j&&v(T,j)),K=!!(s&&mt(T,s,r)),B=!!(l&&mt(T,l,r))||D||A||!u&&!c&&$||u&&c===!1&&$,E=d(T,f);$&&x.outside.push(C),K&&x.disabled.push(C),B&&x.hidden.push(C),E&&x.today.push(C),i&&Object.keys(i).forEach(W=>{const H=i?.[W];H&&mt(T,H,r)&&(N[W]?N[W].push(C):N[W]=[C])})}return C=>{const T={[Se.focused]:!1,[Se.disabled]:!1,[Se.hidden]:!1,[Se.outside]:!1,[Se.today]:!1},z={};for(const $ in x){const D=x[$];T[$]=D.some(A=>A===C)}for(const $ in N)z[$]=N[$].some(D=>D===C);return{...T,...z}}}function vh(e,t,n={}){return Object.entries(e).filter(([,r])=>r===!0).reduce((r,[s])=>(n[s]?r.push(n[s]):t[Se[s]]?r.push(t[Se[s]]):t[Ze[s]]&&r.push(t[Ze[s]]),r),[t[Z.Day]])}function Nh(e){return{...kh,...e}}function _h(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 Mh(){const e={};for(const t in Z)e[Z[t]]=`rdp-${Z[t]}`;for(const t in Se)e[Se[t]]=`rdp-${Se[t]}`;for(const t in Ze)e[Ze[t]]=`rdp-${Ze[t]}`;for(const t in Be)e[Be[t]]=`rdp-${Be[t]}`;return e}function Fo(e,t,n){return(n??new He(t)).formatMonthYear(e)}const jh=Fo;function Sh(e,t,n){return(n??new He(t)).format(e,"d")}function Ch(e,t=st){return t.format(e,"LLLL")}function Dh(e,t,n){return(n??new He(t)).format(e,"cccccc")}function Th(e,t=st){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function Ph(){return""}function Ro(e,t=st){return t.format(e,"yyyy")}const Oh=Ro,$h=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:Fo,formatDay:Sh,formatMonthCaption:jh,formatMonthDropdown:Ch,formatWeekNumber:Th,formatWeekNumberHeader:Ph,formatWeekdayName:Dh,formatYearCaption:Oh,formatYearDropdown:Ro},Symbol.toStringTag,{value:"Module"}));function Eh(e){return e?.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e?.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{...$h,...e}}function va(e,t,n,a){let r=(a??new He(n)).format(e,"PPPP");return t.today&&(r=`Today, ${r}`),t.selected&&(r=`${r}, selected`),r}const Wh=va;function Na(e,t,n){return(n??new He(t)).formatMonthYear(e)}const Ah=Na;function Io(e,t,n,a){let r=(a??new He(n)).format(e,"PPPP");return t?.today&&(r=`Today, ${r}`),r}function Lo(e){return"Choose the Month"}function zo(){return""}const Fh="Go to the Next Month";function Yo(e,t){return Fh}function Bo(e){return"Go to the Previous Month"}function Ho(e,t,n){return(n??new He(t)).format(e,"cccc")}function Uo(e,t){return`Week ${e}`}function Vo(e){return"Week Number"}function qo(e){return"Choose the Year"}const Rh=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:Ah,labelDay:Wh,labelDayButton:va,labelGrid:Na,labelGridcell:Io,labelMonthDropdown:Lo,labelNav:zo,labelNext:Yo,labelPrevious:Bo,labelWeekNumber:Uo,labelWeekNumberHeader:Vo,labelWeekday:Ho,labelYearDropdown:qo},Symbol.toStringTag,{value:"Module"})),Je=(e,t,n)=>t||(n?typeof n=="function"?n:(...a)=>n:e);function Ih(e,t){const n=t.locale?.labels??{};return{...Rh,...e??{},labelDayButton:Je(va,e?.labelDayButton,n.labelDayButton),labelMonthDropdown:Je(Lo,e?.labelMonthDropdown,n.labelMonthDropdown),labelNext:Je(Yo,e?.labelNext,n.labelNext),labelPrevious:Je(Bo,e?.labelPrevious,n.labelPrevious),labelWeekNumber:Je(Uo,e?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:Je(qo,e?.labelYearDropdown,n.labelYearDropdown),labelGrid:Je(Na,e?.labelGrid,n.labelGrid),labelGridcell:Je(Io,e?.labelGridcell,n.labelGridcell),labelNav:Je(zo,e?.labelNav,n.labelNav),labelWeekNumberHeader:Je(Vo,e?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:Je(Ho,e?.labelWeekday,n.labelWeekday)}}function Lh(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(m=>{const g=a.formatMonthDropdown(m,r),p=u(m),b=t&&m<s(t)||n&&m>s(n)||!1;return{value:p,label:g,disabled:b}})}function zh(e,t={},n={}){let a={...t?.[Z.Day]};return Object.entries(e).filter(([,r])=>r===!0).forEach(([r])=>{a={...a,...n?.[r]}}),a}function Yh(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,u=s(e),f=l(t),d=i({start:u,end:f});return r&&d.reverse(),d.map(m=>{const g=n.formatYearDropdown(m,a);return{value:c(m),label:g,disabled:!1}})}function Hh(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),f=c?.weekStartsOn??r,d=(u.getDay()-f+7)%7;return u.setDate(u.getDate()-d),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),m=(((c?.weekStartsOn??r)+6)%7-u.getDay()+7)%7;return u.setDate(u.getDate()+m),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),f=[],d=new Ie(c.getFullYear(),c.getMonth(),1,12,0,0,e),m=u.getFullYear()*12+u.getMonth();for(;d.getFullYear()*12+d.getMonth()<=m;)f.push(new Ie(d,e)),d.setMonth(d.getMonth()+1,1);return f},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),f=[],d=new Ie(c.getFullYear(),0,1,12,0,0,e);for(;d.getFullYear()<=u.getFullYear();)f.push(new Ie(d,e)),d.setFullYear(d.getFullYear()+1,0,1);return f},getWeek:(i,c)=>{const u=l(i);return ba(u,{weekStartsOn:c?.weekStartsOn??r,firstWeekContainsDate:c?.firstWeekContainsDate??a?.options?.firstWeekContainsDate??1})},getISOWeek:i=>{const c=l(i);return pa(c)},differenceInCalendarDays:(i,c)=>{const u=l(i),f=l(c);return ya(u,f)},differenceInCalendarMonths:(i,c)=>{const u=l(i),f=l(c);return Mo(u,f)}}}const fn=e=>e instanceof HTMLElement?e:null,Un=e=>[...e.querySelectorAll("[data-animated-month]")??[]],Uh=e=>fn(e.querySelector("[data-animated-month]")),Vn=e=>fn(e.querySelector("[data-animated-caption]")),qn=e=>fn(e.querySelector("[data-animated-weeks]")),Vh=e=>fn(e.querySelector("[data-animated-nav]")),qh=e=>fn(e.querySelector("[data-animated-weekdays]"));function Xh(e,t,{classNames:n,months:a,focused:r,dateLib:s}){const l=h.useRef(null),i=h.useRef(a),c=h.useRef(!1);h.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 f=s.isSameMonth(a[0].date,u[0].date),d=s.isAfter(a[0].date,u[0].date),m=d?n[Be.caption_after_enter]:n[Be.caption_before_enter],g=d?n[Be.weeks_after_enter]:n[Be.weeks_before_enter],p=l.current,b=e.current.cloneNode(!0);if(b instanceof HTMLElement?(Un(b).forEach(x=>{if(!(x instanceof HTMLElement))return;const N=Uh(x);N&&x.contains(N)&&x.removeChild(N);const C=Vn(x);C&&C.classList.remove(m);const T=qn(x);T&&T.classList.remove(g)}),l.current=b):l.current=null,c.current||f||r)return;const v=p instanceof HTMLElement?Un(p):[],k=Un(e.current);if(k?.every(j=>j instanceof HTMLElement)&&v&&v.every(j=>j instanceof HTMLElement)){c.current=!0,e.current.style.isolation="isolate";const j=Vh(e.current);j&&(j.style.zIndex="1"),k.forEach((x,N)=>{const C=v[N];if(!C)return;x.style.position="relative",x.style.overflow="hidden";const T=Vn(x);T&&T.classList.add(m);const z=qn(x);z&&z.classList.add(g);const $=()=>{c.current=!1,e.current&&(e.current.style.isolation=""),j&&(j.style.zIndex=""),T&&T.classList.remove(m),z&&z.classList.remove(g),x.style.position="",x.style.overflow="",x.contains(C)&&x.removeChild(C)};C.style.pointerEvents="none",C.style.position="absolute",C.style.overflow="hidden",C.setAttribute("aria-hidden","true");const D=qh(C);D&&(D.style.opacity="0");const A=Vn(C);A&&(A.classList.add(d?n[Be.caption_before_exit]:n[Be.caption_after_exit]),A.addEventListener("animationend",$));const K=qn(C);K&&K.classList.add(d?n[Be.weeks_before_exit]:n[Be.weeks_after_exit]),x.insertBefore(C,x.firstChild)})}})}function Gh(e,t,n,a){const r=e[0],s=e[e.length-1],{ISOWeek:l,fixedWeeks:i,broadcastCalendar:c}=n??{},{addDays:u,differenceInCalendarDays:f,differenceInCalendarMonths:d,endOfBroadcastWeek:m,endOfISOWeek:g,endOfMonth:p,endOfWeek:b,isAfter:v,startOfBroadcastWeek:k,startOfISOWeek:j,startOfWeek:x}=a,N=c?k(r,a):l?j(r):x(r),C=c?m(s):l?g(p(s)):b(p(s)),T=t&&(c?m(t):l?g(t):b(t)),z=T&&v(C,T)?T:C,$=f(z,N),D=d(s,r)+1,A=[];for(let E=0;E<=$;E++){const W=u(N,E);A.push(W)}const B=(c?35:42)*D;if(i&&A.length<B){const E=B-A.length;for(let W=0;W<E;W++){const H=u(A[A.length-1],1);A.push(H)}}return A}function Kh(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 Qh(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 xr(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:f,startOfMonth:d}=a;if(n&&u(n,c)<i-1){const m=-1*(i-1);c=f(n,m)}return t&&u(c,t)<0&&(c=t),d(c)}function Jh(e,t,n,a){const{addDays:r,endOfBroadcastWeek:s,endOfISOWeek:l,endOfMonth:i,endOfWeek:c,getISOWeek:u,getWeek:f,startOfBroadcastWeek:d,startOfISOWeek:m,startOfWeek:g}=a,p=e.reduce((b,v)=>{const k=n.broadcastCalendar?d(v,a):n.ISOWeek?m(v):g(v),j=n.broadcastCalendar?s(v):n.ISOWeek?l(i(v)):c(i(v)),x=t.filter(z=>z>=k&&z<=j),N=n.broadcastCalendar?35:42;if(n.fixedWeeks&&x.length<N){const z=t.filter($=>{const D=N-x.length;return $>j&&$<=r(j,D)});x.push(...z)}const C=x.reduce((z,$)=>{const D=n.ISOWeek?u($):f($),A=z.find(B=>B.weekNumber===D),K=new $o($,v,a);return A?A.days.push(K):z.push(new qm(D,[K])),z},[]),T=new Vm(v,C);return b.push(T),b},[]);return n.reverseMonths?p.reverse():p}function Zh(e,t){let{startMonth:n,endMonth:a}=e;const{startOfYear:r,startOfDay:s,startOfMonth:l,endOfMonth:i,addYears:c,endOfYear:u,newDate:f,today:d}=t,{fromYear:m,toYear:g,fromMonth:p,toMonth:b}=e;!n&&p&&(n=p),!n&&m&&(n=t.newDate(m,0,1)),!a&&b&&(a=b),!a&&g&&(a=f(g,11,31));const v=e.captionLayout==="dropdown"||e.captionLayout==="dropdown-years";return n?n=l(n):m?n=f(m,0,1):!n&&v&&(n=r(c(e.today??d(),-100))),a?a=i(a):g?a=f(g,11,31):!a&&v&&(a=u(e.today??d())),[n&&s(n),a&&s(a)]}function e0(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,f=l(e);if(!t)return i(f,u);if(!(c(t,e)<s))return i(f,u)}function t0(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,f=l(e);if(!t)return i(f,-u);if(!(c(f,t)<=0))return i(f,-u)}function n0(e){const t=[];return e.reduce((n,a)=>n.concat(a.weeks.slice()),t.slice())}function Tn(e,t){const[n,a]=h.useState(e);return[t===void 0?n:t,a]}function a0(e,t){const[n,a]=Zh(e,t),{startOfMonth:r,endOfMonth:s}=t,l=xr(e,n,a,t),[i,c]=Tn(l,e.month?l:void 0);h.useEffect(()=>{const N=xr(e,n,a,t);c(N)},[e.timeZone]);const{months:u,weeks:f,days:d,previousMonth:m,nextMonth:g}=h.useMemo(()=>{const N=Qh(i,a,{numberOfMonths:e.numberOfMonths},t),C=Gh(N,e.endMonth?s(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),T=Jh(N,C,{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t),z=n0(T),$=Kh(T),D=t0(i,n,e,t),A=e0(i,a,e,t);return{months:T,weeks:z,days:$,previousMonth:D,nextMonth:A}},[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:b}=e,v=N=>f.some(C=>C.days.some(T=>T.isEqualTo(N))),k=N=>{if(p)return;let C=r(N);n&&C<r(n)&&(C=r(n)),a&&C>r(a)&&(C=r(a)),c(C),b?.(C)};return{months:u,weeks:f,days:d,navStart:n,navEnd:a,previousMonth:m,nextMonth:g,goToMonth:k,goToDay:N=>{v(N)||k(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 kr(e){return!e[Se.disabled]&&!e[Se.hidden]&&!e[Se.outside]}function r0(e,t,n,a){let r,s=-1;for(const l of e){const i=t(l);kr(i)&&(i[Se.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[Se.today]&&s<nt.Today&&(r=l,s=nt.Today))}return r||(r=e.find(l=>kr(t(l)))),r}function o0(e,t,n,a,r,s,l){const{ISOWeek:i,broadcastCalendar:c}=s,{addDays:u,addMonths:f,addWeeks:d,addYears:m,endOfBroadcastWeek:g,endOfISOWeek:p,endOfWeek:b,max:v,min:k,startOfBroadcastWeek:j,startOfISOWeek:x,startOfWeek:N}=l;let T={day:u,week:d,month:f,year:m,startOfWeek:z=>c?j(z,l):i?x(z):N(z),endOfWeek:z=>c?g(z):i?p(z):b(z)}[e](n,t==="after"?1:-1);return t==="before"&&a?T=v([a,T]):t==="after"&&r&&(T=k([r,T])),T}function Xo(e,t,n,a,r,s,l,i=0){if(i>365)return;const c=o0(e,t,n.date,a,r,s,l),u=!!(s.disabled&&mt(c,s.disabled,l)),f=!!(s.hidden&&mt(c,s.hidden,l)),d=c,m=new $o(c,d,l);return!u&&!f?m:Xo(e,t,m,a,r,s,l,i+1)}function s0(e,t,n,a,r){const{autoFocus:s}=e,[l,i]=h.useState(),c=r0(t.days,n,a||(()=>!1),l),[u,f]=h.useState(s?c:void 0);return{isFocusTarget:b=>!!c?.isEqualTo(b),setFocused:f,focused:u,blur:()=>{i(u),f(void 0)},moveFocus:(b,v)=>{if(!u)return;const k=Xo(b,v,u,t.navStart,t.navEnd,e,r);k&&(e.disableNavigation&&!t.days.some(x=>x.isEqualTo(k))||(t.goToDay(k),f(k)))}}}function i0(e,t){const{selected:n,required:a,onSelect:r}=e,[s,l]=Tn(n,r?n:void 0),i=r?n:s,{isSameDay:c}=t,u=g=>i?.some(p=>c(p,g))??!1,{min:f,max:d}=e;return{selected:i,select:(g,p,b)=>{let v=[...i??[]];if(u(g)){if(i?.length===f||a&&i?.length===1)return;v=i?.filter(k=>!c(k,g))}else i?.length===d?v=[g]:v=[...v,g];return r||l(v),r?.(v,g,p,b),v},isSelected:u}}function l0(e,t,n=0,a=0,r=!1,s=st){const{from:l,to:i}=t||{},{isSameDay:c,isAfter:u,isBefore:f}=s;let d;if(!l&&!i)d={from:e,to:n>0?void 0:e};else if(l&&!i)c(l,e)?n===0?d={from:l,to:e}:r?d={from:l,to:void 0}:d=void 0:f(e,l)?d={from:e,to:l}:d={from:l,to:e};else if(l&&i)if(c(l,e)&&c(i,e))r?d={from:l,to:i}:d=void 0;else if(c(l,e))d={from:l,to:n>0?void 0:e};else if(c(i,e))d={from:e,to:n>0?void 0:e};else if(f(e,l))d={from:e,to:i};else if(u(e,l))d={from:l,to:e};else if(u(e,i))d={from:l,to:e};else throw new Error("Invalid range");if(d?.from&&d?.to){const m=s.differenceInCalendarDays(d.to,d.from);a>0&&m>a?d={from:e,to:void 0}:n>1&&m<n&&(d={from:e,to:void 0})}return d}function c0(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 wr(e,t,n=st){return ft(e,t.from,!1,n)||ft(e,t.to,!1,n)||ft(t,e.from,!1,n)||ft(t,e.to,!1,n)}function d0(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)?ft(e,i,!1,n):Ao(i,n)?i.some(c=>ft(e,c,!1,n)):Dn(i)?i.from&&i.to?wr(e,{from:i.from,to:i.to},n):!1:Wo(i)?c0(e,i.dayOfWeek,n):xa(i)?n.isAfter(i.before,i.after)?wr(e,{from:n.addDays(i.after,1),to:n.addDays(i.before,-1)},n):mt(e.from,i,n)||mt(e.to,i,n):ka(i)||wa(i)?mt(e.from,i,n)||mt(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(f=>f(i)))return!0;i=n.addDays(i,1)}}return!1}function u0(e,t){const{disabled:n,excludeDisabled:a,resetOnSelect:r,selected:s,required:l,onSelect:i}=e,[c,u]=Tn(s,i?s:void 0),f=i?s:c;return{selected:f,select:(g,p,b)=>{const{min:v,max:k}=e;let j;if(g){const x=f?.from,N=f?.to,C=!!x&&!!N,T=!!x&&!!N&&t.isSameDay(x,N)&&t.isSameDay(g,x);r&&(C||!f?.from)?!l&&T?j=void 0:j={from:g,to:void 0}:j=l0(g,f,v,k,l,t)}return a&&n&&j?.from&&j.to&&d0({from:j.from,to:j.to},n,t)&&(j.from=g,j.to=void 0),i||u(j),i?.(j,g,p,b),j},isSelected:g=>f&&ft(f,g,!1,t)}}function f0(e,t){const{selected:n,required:a,onSelect:r}=e,[s,l]=Tn(n,r?n:void 0),i=r?n:s,{isSameDay:c}=t;return{selected:i,select:(d,m,g)=>{let p=d;return!a&&i&&i&&c(d,i)&&(p=void 0),r||l(p),r?.(p,d,m,g),p},isSelected:d=>i?c(i,d):!1}}function m0(e,t){const n=f0(e,t),a=i0(e,t),r=u0(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 Ft(e,t,n){return qe(e,t)}function vr(e,t,n){return typeof e=="boolean"||typeof e=="function"?e:e instanceof Date?Ft(e,t):Array.isArray(e)?e.map(a=>a instanceof Date?Ft(a,t):a):Dn(e)?{...e,from:e.from?qe(e.from,t):e.from,to:e.to?qe(e.to,t):e.to}:xa(e)?{before:Ft(e.before,t),after:Ft(e.after,t)}:ka(e)?{after:Ft(e.after,t)}:wa(e)?{before:Ft(e.before,t)}:e}function Xn(e,t,n){return e&&(Array.isArray(e)?e.map(a=>vr(a,t)):vr(e,t))}function h0(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(re=>qe(re,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=Xn(t.disabled,n)),t.hidden!==void 0&&(t.hidden=Xn(t.hidden,n)),t.modifiers)){const re={};Object.keys(t.modifiers).forEach(ae=>{re[ae]=Xn(t.modifiers?.[ae],n)}),t.modifiers=re}const{components:a,formatters:r,labels:s,dateLib:l,locale:i,classNames:c}=h.useMemo(()=>{const re={...Oo,...t.locale},ae=t.broadcastCalendar?1:t.weekStartsOn,ee=t.noonSafe&&t.timeZone?Hh(t.timeZone,{weekStartsOn:ae,locale:re}):void 0,de=t.dateLib&&ee?{...ee,...t.dateLib}:t.dateLib??ee,Te=new He({locale:re,weekStartsOn:ae,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},de);return{dateLib:Te,components:Nh(t.components),formatters:Eh(t.formatters),labels:Ih(t.labels,Te.options),locale:re,classNames:{...Mh(),...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:f,navLayout:d,numberOfMonths:m=1,onDayBlur:g,onDayClick:p,onDayFocus:b,onDayKeyDown:v,onDayMouseEnter:k,onDayMouseLeave:j,onNextClick:x,onPrevClick:N,showWeekNumber:C,styles:T}=t,{formatCaption:z,formatDay:$,formatMonthDropdown:D,formatWeekNumber:A,formatWeekNumberHeader:K,formatWeekdayName:B,formatYearDropdown:E}=r,W=a0(t,l),{days:H,months:_,navStart:w,navEnd:I,previousMonth:M,nextMonth:J,goToMonth:P}=W,L=wh(H,t,w,I,l),{isSelected:V,select:q,selected:fe}=m0(t,l)??{},{blur:ve,focused:xe,isFocusTarget:pe,moveFocus:Me,setFocused:je}=s0(t,W,L,V??(()=>!1),l),{labelDayButton:ke,labelGridcell:Ce,labelGrid:O,labelMonthDropdown:Y,labelNav:he,labelPrevious:oe,labelNext:ye,labelWeekday:Oe,labelWeekNumber:$e,labelWeekNumberHeader:F,labelYearDropdown:U}=s,Q=h.useMemo(()=>Yh(l,t.ISOWeek,t.broadcastCalendar,t.today),[l,t.ISOWeek,t.broadcastCalendar,t.today]),G=f!==void 0||p!==void 0,ne=h.useCallback(()=>{M&&(P(M),N?.(M))},[M,P,N]),se=h.useCallback(()=>{J&&(P(J),x?.(J))},[P,J,x]),ue=h.useCallback((re,ae)=>ee=>{ee.preventDefault(),ee.stopPropagation(),je(re),!ae.disabled&&(q?.(re.date,ae,ee),p?.(re.date,ae,ee))},[q,p,je]),ie=h.useCallback((re,ae)=>ee=>{je(re),b?.(re.date,ae,ee)},[b,je]),me=h.useCallback((re,ae)=>ee=>{ve(),g?.(re.date,ae,ee)},[ve,g]),De=h.useCallback((re,ae)=>ee=>{const de={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(de[ee.key]){ee.preventDefault(),ee.stopPropagation();const[Te,le]=de[ee.key];Me(Te,le)}v?.(re.date,ae,ee)},[Me,v,t.dir]),ge=h.useCallback((re,ae)=>ee=>{k?.(re.date,ae,ee)},[k]),Fe=h.useCallback((re,ae)=>ee=>{j?.(re.date,ae,ee)},[j]),Ee=h.useCallback(re=>ae=>{const ee=Number(ae.target.value),de=l.setMonth(l.startOfMonth(re),ee);P(de)},[l,P]),Ye=h.useCallback(re=>ae=>{const ee=Number(ae.target.value),de=l.setYear(l.startOfMonth(re),ee);P(de)},[l,P]),{className:Mt,style:yt}=h.useMemo(()=>({className:[c[Z.Root],t.className].filter(Boolean).join(" "),style:{...T?.[Z.Root],...t.style}}),[c,t.className,t.style,T]),Ue=_h(t),pt=h.useRef(null);Xh(pt,!!t.animate,{classNames:c,months:_,focused:xe,dateLib:l});const bt={dayPickerProps:t,selected:fe,select:q,isSelected:V,months:_,nextMonth:J,previousMonth:M,goToMonth:P,getModifiers:L,components:a,classNames:c,styles:T,labels:s,formatters:r};return R.createElement(Eo.Provider,{value:bt},R.createElement(a.Root,{rootRef:t.animate?pt:void 0,className:Mt,style:yt,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"],...Ue},R.createElement(a.Months,{className:c[Z.Months],style:T?.[Z.Months]},!t.hideNavigation&&!d&&R.createElement(a.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[Z.Nav],style:T?.[Z.Nav],"aria-label":he(),onPreviousClick:ne,onNextClick:se,previousMonth:M,nextMonth:J}),_.map((re,ae)=>R.createElement(a.Month,{"data-animated-month":t.animate?"true":void 0,className:c[Z.Month],style:T?.[Z.Month],key:ae,displayIndex:ae,calendarMonth:re},d==="around"&&!t.hideNavigation&&ae===0&&R.createElement(a.PreviousMonthButton,{type:"button",className:c[Z.PreviousMonthButton],tabIndex:M?void 0:-1,"aria-disabled":M?void 0:!0,"aria-label":oe(M),onClick:ne,"data-animated-button":t.animate?"true":void 0},R.createElement(a.Chevron,{disabled:M?void 0:!0,className:c[Z.Chevron],orientation:t.dir==="rtl"?"right":"left"})),R.createElement(a.MonthCaption,{"data-animated-caption":t.animate?"true":void 0,className:c[Z.MonthCaption],style:T?.[Z.MonthCaption],calendarMonth:re,displayIndex:ae},u?.startsWith("dropdown")?R.createElement(a.DropdownNav,{className:c[Z.Dropdowns],style:T?.[Z.Dropdowns]},(()=>{const ee=u==="dropdown"||u==="dropdown-months"?R.createElement(a.MonthsDropdown,{key:"month",className:c[Z.MonthsDropdown],"aria-label":Y(),classNames:c,components:a,disabled:!!t.disableNavigation,onChange:Ee(re.date),options:Lh(re.date,w,I,r,l),style:T?.[Z.Dropdown],value:l.getMonth(re.date)}):R.createElement("span",{key:"month"},D(re.date,l)),de=u==="dropdown"||u==="dropdown-years"?R.createElement(a.YearsDropdown,{key:"year",className:c[Z.YearsDropdown],"aria-label":U(l.options),classNames:c,components:a,disabled:!!t.disableNavigation,onChange:Ye(re.date),options:Bh(w,I,r,l,!!t.reverseYears),style:T?.[Z.Dropdown],value:l.getYear(re.date)}):R.createElement("span",{key:"year"},E(re.date,l));return l.getMonthYearOrder()==="year-first"?[de,ee]:[ee,de]})(),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"}},z(re.date,l.options,l))):R.createElement(a.CaptionLabel,{className:c[Z.CaptionLabel],role:"status","aria-live":"polite"},z(re.date,l.options,l))),d==="around"&&!t.hideNavigation&&ae===m-1&&R.createElement(a.NextMonthButton,{type:"button",className:c[Z.NextMonthButton],tabIndex:J?void 0:-1,"aria-disabled":J?void 0:!0,"aria-label":ye(J),onClick:se,"data-animated-button":t.animate?"true":void 0},R.createElement(a.Chevron,{disabled:J?void 0:!0,className:c[Z.Chevron],orientation:t.dir==="rtl"?"left":"right"})),ae===m-1&&d==="after"&&!t.hideNavigation&&R.createElement(a.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[Z.Nav],style:T?.[Z.Nav],"aria-label":he(),onPreviousClick:ne,onNextClick:se,previousMonth:M,nextMonth:J}),R.createElement(a.MonthGrid,{role:"grid","aria-multiselectable":f==="multiple"||f==="range","aria-label":O(re.date,l.options,l)||void 0,className:c[Z.MonthGrid],style:T?.[Z.MonthGrid]},!t.hideWeekdays&&R.createElement(a.Weekdays,{"data-animated-weekdays":t.animate?"true":void 0,className:c[Z.Weekdays],style:T?.[Z.Weekdays]},C&&R.createElement(a.WeekNumberHeader,{"aria-label":F(l.options),className:c[Z.WeekNumberHeader],style:T?.[Z.WeekNumberHeader],scope:"col"},K()),Q.map(ee=>R.createElement(a.Weekday,{"aria-label":Oe(ee,l.options,l),className:c[Z.Weekday],key:String(ee),style:T?.[Z.Weekday],scope:"col"},B(ee,l.options,l)))),R.createElement(a.Weeks,{"data-animated-weeks":t.animate?"true":void 0,className:c[Z.Weeks],style:T?.[Z.Weeks]},re.weeks.map(ee=>R.createElement(a.Week,{className:c[Z.Week],key:ee.weekNumber,style:T?.[Z.Week],week:ee},C&&R.createElement(a.WeekNumber,{week:ee,style:T?.[Z.WeekNumber],"aria-label":$e(ee.weekNumber,{locale:i}),className:c[Z.WeekNumber],scope:"row",role:"rowheader"},A(ee.weekNumber,l)),ee.days.map(de=>{const{date:Te}=de,le=L(de);if(le[Se.focused]=!le.hidden&&!!xe?.isEqualTo(de),le[Ze.selected]=V?.(Te)||le.selected,Dn(fe)){const{from:jt,to:xt}=fe;le[Ze.range_start]=!!(jt&&xt&&l.isSameDay(Te,jt)),le[Ze.range_end]=!!(jt&&xt&&l.isSameDay(Te,xt)),le[Ze.range_middle]=ft(fe,Te,!0,l)}const Ot=zh(le,T,t.modifiersStyles),Bt=vh(le,c,t.modifiersClassNames),Ht=!G&&!le.hidden?Ce(Te,le,l.options,l):void 0;return R.createElement(a.Day,{key:`${de.isoDate}_${de.displayMonthId}`,day:de,modifiers:le,className:Bt.join(" "),style:Ot,role:"gridcell","aria-selected":le.selected||void 0,"aria-label":Ht,"data-day":de.isoDate,"data-month":de.outside?de.dateMonthId:void 0,"data-selected":le.selected||void 0,"data-disabled":le.disabled||void 0,"data-hidden":le.hidden||void 0,"data-outside":de.outside||void 0,"data-focused":le.focused||void 0,"data-today":le.today||void 0},!le.hidden&&G?R.createElement(a.DayButton,{className:c[Z.DayButton],style:T?.[Z.DayButton],type:"button",day:de,modifiers:le,disabled:!le.focused&&le.disabled||void 0,"aria-disabled":le.focused&&le.disabled||void 0,tabIndex:pe(de)?0:-1,"aria-label":ke(Te,le,l.options,l),onClick:ue(de,le),onBlur:me(de,le),onFocus:ie(de,le),onKeyDown:De(de,le),onMouseEnter:ge(de,le),onMouseLeave:Fe(de,le)},$(Te,l.options,l)):!le.hidden&&$(de.date,l.options,l))})))))))),t.footer&&R.createElement(a.Footer,{className:c[Z.Footer],style:T?.[Z.Footer],role:"status","aria-live":"polite"},t.footer)))}const g0={en:vt,"zh-CN":gm,"zh-TW":Um,ja:cf,ko:If};function Go(e){return g0[e]||vt}function Nr(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 la({from:e,to:t,onApply:n,onCancel:a}){const r=h.useMemo(()=>{const f={from:void 0,to:void 0};if(e){const d=e.split("-");f.from=new Date(Number(d[0]),Number(d[1])-1,Number(d[2]))}if(t){const d=t.split("-");f.to=new Date(Number(d[0]),Number(d[1])-1,Number(d[2]))}return f},[e,t]),[s,l]=h.useState(r),i=Go(Qr()),c=()=>{if(!s?.from)return;const f=ot(s.from,"yyyy-MM-dd"),d=s.to?ot(s.to,"yyyy-MM-dd"):f;n?.(f,d)},u=!!s?.from;return o.jsxs("div",{className:"p-4",children:[o.jsx(h0,{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:[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(Jn,{variant:"secondary",size:"sm",onClick:a,children:y("shared.action.cancel")}),o.jsx(Jn,{variant:"primary",size:"sm",onClick:c,disabled:!u,children:y("shared.action.apply")})]})]})}function _a(e){if(!Number.isFinite(Number(e)))return null;const t=Number(e);return t<=0?null:Ae(t,{decimals:1})}function Ma(e,t,n){const a=Number(e);if(!Number.isFinite(a)||a<=0)return null;const r=ua(t);return(t===Kr?a:a*n)<.01?`<${r}0.01`:et(a,{decimals:2,currency:t,rate:n})}function y0(e,t,n){const a=Ma(e,t,n);return a?`${a}/MTok`:null}function Jt(e){return e?String(e).replace(/^claude-/,""):""}function p0(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?{key:t,label:_r(t)}:{key:t.key,label:t.label||_r(t.key)}):[]}function b0(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 x0={CODEX:"#3b82f6",CLAUDE:"#d97757",OPENCODE:"#f59e0b",GEMINI:"#2196f3",KIMI:"#a78bfa","KILO-CLI":"#facc15","KILO-CODE":"#facc15",DROID:"#ef4444"};function Gn(e,t){const n=e?.toUpperCase?.()||"";return x0[n]||`hsl(${150+t*40}, 60%, 45%)`}function Zt(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 ja(e){return!!e?.models?.length}function k0(e){const t=Number(e);return!Number.isFinite(t)||t<=0?"0%":`${Math.min(100,Math.max(2,t))}%`}function w0(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 v0(e,t=3){return[...e?.models||[]].sort((n,a)=>(Number(a.share)||0)-(Number(n.share)||0)).slice(0,t)}function N0(e,t){return Math.max(0,(e?.models?.length||0)-t.length)}const _0={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 _r(e){const t=_0[e];return t?y(t):String(e).toUpperCase()}function M0({loading:e,onClick:t}){const n=zt();return o.jsx(Jn,{variant:"secondary",size:"sm",disabled:e,onClick:t,"aria-label":y("usage.button.refresh"),className:"w-8 p-0",children:o.jsx(gt.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 Mr({period:e,periods:t,onPeriodChange:n,autoRefreshOptions:a=[],autoRefreshIntervalMs:r,onAutoRefreshIntervalChange:s,summaryValue:l,summaryLabel:i,summaryUpdatedAtLabel:c,summaryCostValue:u,usageInsights:f,onCostInfo:d,onRefresh:m,loading:g,customFrom:p,customTo:b,onCustomRangeApply:v,customRangeOpen:k,onCustomRangeOpenChange:j,emphasized:x=!1}){const N=zt(),C=p0(t),T=Array.isArray(a)&&a.length>0&&typeof s=="function",z=Go(Qr()),$=b0(String(l??"")),D=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches,[A,K]=h.useState(D);h.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const O=window.matchMedia("(max-width: 639px)"),Y=he=>K(he.matches);return O.addEventListener("change",Y),()=>O.removeEventListener("change",Y)},[]);const B=$!=null&&!A&&!g&&!N,E=x&&l!=null&&String(l)!=="",W=h.useRef(null);h.useEffect(()=>{const O=W.current?.querySelector('[aria-selected="true"]');O&&typeof O.scrollIntoView=="function"&&O.scrollIntoView({block:"nearest",inline:"center"})},[e]);const{resolvedTheme:H}=Gr(),{currency:_,rate:w}=_t(),I=H==="dark",M=I?"rgba(10,10,10,0.98)":"rgba(255,255,255,0.96)",J=I?"rgba(10,10,10,0)":"rgba(255,255,255,0)",P=y0(f?.costPerMillionTokens,_,w),L=f?.topCostModel?.name?Jt(f.topCostModel.name):"",V=f?.topUsageModel?.name?Jt(f.topUsageModel.name):"",q=Array.isArray(f?.missingPricingModels)?f.missingPricingModels.length:0,fe=!!q,ve=!!(P||L||V||fe),xe=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":"",pe=x?"flex-1 flex flex-col":"",Me=x?"flex flex-1 flex-col justify-center":"",je=x?"flex flex-col gap-3":"flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between",ke=x?"flex flex-col gap-2":"flex flex-col gap-2 sm:items-end",Ce=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(sn,{className:xe,bodyClassName:pe,children:[o.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[o.jsx("div",{ref:W,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:C.map(O=>{const Y=e===O.key,he=`shrink-0 whitespace-nowrap text-xs font-medium px-3 py-1.5 rounded-md transition-colors ${Y?"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(O.key==="custom"){const oe=Y&&p&&b?`${Nr(p,z)} — ${Nr(b,z)}`:O.label;return o.jsxs(ea,{open:k,onOpenChange:ye=>{ye?n?.("custom"):j?.(ye)},children:[o.jsx(ta,{render:o.jsx("button",{role:"tab","aria-selected":Y,type:"button",className:he}),children:oe}),o.jsx(na,{children:o.jsx(aa,{sideOffset:8,side:"bottom",align:"start",className:"!z-[9999]",children:o.jsx(ra,{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(la,{from:p,to:b,onApply:v,onCancel:()=>j?.(!1)})})})})]},"custom")}return o.jsx("button",{role:"tab","aria-selected":Y,type:"button",className:he,onClick:()=>n?.(O.key),children:O.label},O.key)})}),o.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[T?o.jsx("select",{"aria-label":y("usage.auto_refresh.aria"),value:String(r),onChange:O=>s(O.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(O=>o.jsx("option",{value:String(O.value),children:y(O.labelKey)},O.value))}):null,m&&o.jsx(M0,{loading:g,onClick:m})]})]}),o.jsx("div",{className:Me,children:o.jsxs("div",{className:je,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:E?o.jsx(kl,{value:l,fontSize:58}):B?o.jsx(gl,{value:$,displayValue:l,fontSize:72,padding:6,gap:1,textColor:"var(--oai-black, #111827)",fontWeight:700,gradientHeight:I?0:8,gradientFrom:M,gradientTo:J,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||ve)&&o.jsxs("div",{className:ke,children:[u&&o.jsx("div",{className:"flex items-center gap-2",children:d?o.jsxs("button",{type:"button",onClick:d,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(ma,{size:16,strokeWidth:2,className:"opacity-80"})]}):o.jsx("span",{className:"text-xl font-bold text-oai-brand",children:u})}),ve&&o.jsxs("div",{className:Ce,children:[P?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:P})}):null,L?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:L})}):null,V&&V!==L?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:V})}):null,fe?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:q})}):null]})]})]})})]})}const jr={claude:35,codex:250},Sr={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 j0(e,t){const n=jr[t]??jr.claude,a=Sr[e]||Sr.system_prompt;return`oklch(${a.l} ${a.c} ${n})`}const S0=[{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"]}],C0=[["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"]],D0={duration:.18,ease:[.4,0,.2,1]},T0={height:0,opacity:0},P0={height:"auto",opacity:1},O0={height:0,opacity:0};function $0(e){const t=Number(e||0);return Number.isFinite(t)&&t>0?t:0}function E0(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 Ko(e,t=null){const n=e.reduce((l,i)=>l+Number(i.totals.total_tokens||0),0),a=$0(t),r=a||n,s=a&&n>0?a/n:1;return e.map(l=>{const i=s===1?l.totals:E0(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 W0(e,t=null){const n=new Map;for(const r of e||[])n.set(r.key,r);const a=S0.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 Ko(a,t)}function A0(e,t=null){const n=e?.totals||{},a=Number(n.reasoning_output_tokens||0),r=(e?.tool_calls_breakdown?.categories||[]).reduce((u,f)=>f?.name==="Text Response"?u:u+Number(f?.totals?.total_tokens||0),0),s=Number(n.total_tokens||0),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 Ko(c,t)}const Cr="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(Cr)?(t.push({...r,name:s.slice(Cr.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 Dr(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 R0(e){return typeof e!="string"?"":e.startsWith("mcp__")?e.split("__").slice(2).join("__")||e:e.includes("/")&&e.split("/").pop()||e}function I0(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:R0(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 L0(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:I0(a),toolCount:a.length}}).filter(t=>t.name).sort((t,n)=>(n.totals.total_tokens||0)-(t.totals.total_tokens||0))}function z0(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 Y0(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 H0(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 Tr(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 U0(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 Pr(e){return e==="exec_command"||e==="Bash"}function Qo(e){return e==="codex"?"dashboard.context_breakdown.empty_codex":"dashboard.context_breakdown.empty"}function V0(e){return e==="codex"?"dashboard.context_breakdown.error_codex":"dashboard.context_breakdown.error"}function q0(e){return e==="codex"?"dashboard.context_breakdown.footnote_codex":"dashboard.context_breakdown.footnote"}const X0=10;function dt({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:f,share:d=null,fillColor:m=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:X0},"aria-hidden":!t,children:t}),b=o.jsxs(o.Fragment,{children:[p,o.jsx("span",{className:g,children:n}),a,s&&o.jsx(gt.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(Jr,{size:11})})]}),v=m&&d!=null&&d>0,k=v?Math.max(0,Math.min(100,d)):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, ${m.replace(/\)\s*$/," / 0.10)")} 0%, ${m.replace(/\)\s*$/," / 0.10)")} ${k}%, transparent ${k}%)`}: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:b}):o.jsx("div",{className:"relative flex items-center gap-1.5 min-w-0",children:b}),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&&f?o.jsx(Zr,{initial:!1,children:l&&o.jsx(gt.div,{initial:T0,animate:P0,exit:O0,transition:D0,style:{overflow:"hidden"},children:f},"content")}):null]})}function Or({execDetails:e,source:t="claude"}){const[n,a]=h.useState("by_type"),r=H0(U0(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:C0.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(gt.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:Tr(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:Tr(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 Gt({toolSet:e,execDetails:t,source:n,codexQueueFallback:a}){const[r,s]=h.useState({}),[l,i]=h.useState(!1),c=L0(e?.categories||[]);function u(f){s(d=>({...d,[f]:!d[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(Qo(n))}):o.jsx("ul",{className:"mt-0.5 mb-0.5 space-y-0.5",children:c.map(f=>{const d=f.toolCount>0,m=f.name==="Execution"&&t,g=m&&f.tools.some(b=>Pr(b.name)),p=!!r[f.name];return o.jsxs(dt,{level:1,label:f.name,labelTone:"strong",hasChevron:d||m&&!g,open:p||m&&!g&&l,onToggle:()=>{d?u(f.name):m&&!g&&i(b=>!b)},tokens:at(f.totals.total_tokens||0),percent:null,children:[d&&o.jsx("ul",{className:"space-y-0.5",children:f.tools.map(b=>{const v=m&&Pr(b.name);return o.jsx(dt,{level:2,label:b.name,labelTone:v?"accent":"default",hasChevron:v,open:l,onToggle:()=>i(k=>!k),tokens:at(b.total_tokens||0),percent:null,children:v&&o.jsx(Or,{execDetails:t,source:n})},b.name)})}),m&&!g&&o.jsx(Or,{execDetails:t,source:n})]},f.name)})})}function Jo({from:e,to:t,source:n="claude",referenceTotalTokens:a=null,onLoadingChange:r=null}){const[s,l]=h.useState(null),[i,c]=h.useState(!1),[u,f]=h.useState(null),[d,m]=h.useState({});function g(_){m(w=>({...w,[_]:!w[_]}))}if(h.useEffect(()=>{let _=!1;return c(!0),r?.(!0),f(null),Ti({from:e,to:t,source:n,timeZone:to(),tzOffsetMinutes:eo()}).then(w=>{_||l(w)}).catch(w=>{_||f(w?.message||String(w))}).finally(()=>{_||(c(!1),r?.(!1))}),()=>{_=!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(_=>o.jsx("div",{className:"h-3 rounded bg-oai-gray-100 dark:bg-oai-gray-800 animate-pulse",style:{animationDelay:`${_*80}ms`}},_))}),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(V0(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(Qo(n))});const p=n==="claude"?W0(s.categories||[],a):A0(s,a),b=s.tool_calls_breakdown||null,v=s.skills_breakdown||null,k=s.message_breakdown||null,j=s.configured_resources||null,x=s.exec_command_breakdown||null,N=Y0(v?.skills||[]),C=z0(k?.categories||[]),T=n==="codex"&&(s?.breakdown_status==="queue_fallback"||s?.fallback==="queue_totals"),z=n==="claude"?b?.tool_calls||null:b||null,{mcpSet:$,residualSet:D,mcpTotalTokens:A}=F0(z),K=n==="claude"&&b?.subagents||null,B=K?.categories?.length>0||(j?.custom_agents_count||0)>0,E=n==="claude"?(D?.categories||[]).reduce((_,w)=>_+Number(w?.totals?.total_tokens||0),0):0,W=n==="claude"?(K?.categories||[]).reduce((_,w)=>_+Number(w?.totals?.total_tokens||0),0):0,H=[...p].sort((_,w)=>(w.totals?.total_tokens||0)-(_.totals?.total_tokens||0));return o.jsxs("div",{role:"region","aria-label":y("dashboard.context_breakdown.bar_aria",{summary:p.filter(_=>_.percent>0).filter(_=>!(n==="claude"&&(_.key==="tool_calls"||_.key==="custom_agents"))).map(_=>`${Dr(_.key)} ${_.percent}%`).join(",")}),children:[o.jsxs("ul",{className:"space-y-0.5",children:[H.map(_=>{const w=_.key==="system_prompt",I=_.key==="messages",M=_.key==="tool_calls",J=_.key==="custom_agents";if(_.key,n==="claude"&&(M||J))return null;const P=I&&C.length>0||M&&(D?.categories?.length>0||T)||J&&B&&K,L=!!d[_.key],V=j0(_.key,n),q=o.jsx("span",{className:"h-2 w-2 rounded-sm shrink-0",style:{backgroundColor:V},"aria-hidden":"true"}),fe=w?o.jsxs("span",{className:"relative inline-flex shrink-0 group",children:[o.jsx(ma,{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,ve=_.percent>0?`${_.percent.toFixed(_.percent<.1&&_.percent>0?2:1)}%`:"0.0%";return o.jsxs(dt,{level:0,colorSquare:q,label:Dr(_.key),labelSuffix:fe,tokens:at(_.totals?.total_tokens||0),percent:ve,hasChevron:P,open:L,onToggle:()=>g(_.key),share:_.percent,fillColor:V,children:[I&&o.jsx("ul",{className:"space-y-0.5",children:C.map(xe=>o.jsx(dt,{level:1,label:B0(xe),tokens:at(xe.totals.total_tokens||0),percent:null},xe.key||xe.name))}),M&&D&&o.jsx(Gt,{toolSet:D,execDetails:x,source:n,codexQueueFallback:T}),M&&T&&!D&&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")}),J&&K&&o.jsx(Gt,{toolSet:K,execDetails:null,source:n,codexQueueFallback:!1})]},_.key)}),n==="claude"&&D?.categories?.length>0&&o.jsx(dt,{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(E),percent:null,hasChevron:!0,open:!!d.tool_calls_aux,onToggle:()=>g("tool_calls_aux"),children:o.jsx(Gt,{toolSet:D,execDetails:x,source:n,codexQueueFallback:!1})}),n==="claude"&&K?.categories?.length>0&&o.jsx(dt,{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(W),percent:null,hasChevron:!0,open:!!d.custom_agents_aux,onToggle:()=>g("custom_agents_aux"),children:o.jsx(Gt,{toolSet:K,execDetails:null,source:n,codexQueueFallback:!1})}),$?.categories?.length>0&&o.jsx(dt,{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(A),percent:null,hasChevron:!0,open:!!d.mcp_servers,onToggle:()=>g("mcp_servers"),children:o.jsx(Gt,{toolSet:$,execDetails:null,source:n,codexQueueFallback:!1})}),N.length>0&&o.jsx(dt,{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((_,w)=>_+(w.total_tokens||0),0)),percent:null,hasChevron:!0,open:!!d.skills,onToggle:()=>g("skills"),children:o.jsx("ul",{className:"space-y-0.5",children:N.slice(0,12).map(_=>o.jsx(dt,{level:1,label:_.name,tokens:at(_.total_tokens),percent:null},_.name))})})]}),o.jsx("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:y(q0(n))}),T?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,j?o.jsxs("p",{className:"mt-2 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:[Ae(j.skills_count||0)," skills ·"," ",Ae(j.mcp_servers_count||0)," MCP servers ·"," ",Ae(j.custom_agents_count||0)," agents ·"," ",Ae(j.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=zt(),[i,c]=h.useState(null),{currency:u,rate:f}=_t(),d=e.filter(ja);return d.length===0?null:o.jsx(sn,{children:o.jsxs("div",{className:"space-y-6",children:[o.jsx("div",{role:"img","aria-label":y("usage.overview.distribution_aria",{items:d.map(m=>y("usage.overview.distribution_item",{label:m.label,percent:m.totalPercent})).join(",")}),className:"h-1.5 w-full bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden flex",children:d.map((m,g)=>{const p=Gn(m.label,g);return o.jsx(gt.div,{initial:{width:0},animate:{width:`${m.totalPercent}%`},transition:{duration:.5,delay:.45+g*.04,ease:[.16,1,.3,1]},className:"h-full",style:{backgroundColor:p},title:`${m.label}: ${m.totalPercent}%`},m.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:d.map((m,g)=>{const p=Gn(m.label,g),b=i===m.label,v=m.missingPricingModels?.length||0,k=!!v,j=v0(m),x=N0(m,j);return o.jsxs("button",{"aria-expanded":b,"aria-controls":`provider-details-${m.label}`,"aria-label":y("usage.overview.provider_card_aria",{provider:m.label,percent:m.totalPercent,tokens:_a(m.usage)||"0",cost:Ma(m.usd,u,f)||`${ua(u)}0`,action:y(b?"usage.overview.collapse":"usage.overview.expand")}),onClick:()=>c(b?null:m.label),className:`min-w-0 text-left p-3 rounded-lg border transition-colors duration-200 ${b?"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(fa,{provider:m.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:m.label})]}),o.jsxs("div",{className:"text-lg font-semibold text-oai-black dark:text-oai-white tabular-nums",children:[m.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:m.models.length})}),o.jsx(Pi,{label:m.label,usageLimits:r,mode:s}),o.jsxs("div",{className:"mt-2 space-y-1.5",children:[j.map(N=>{const C=w0(N,m.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 ${C?"text-oai-black dark:text-oai-white":"text-oai-gray-600 dark:text-oai-gray-300"}`,title:N.name,children:Jt(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:Jt(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(gt.div,{initial:{width:0},animate:{width:k0(N.share)},transition:{duration:l?0:.45,delay:l?0:.05,ease:[.16,1,.3,1]},className:"h-full rounded-full",style:{backgroundColor:C?p:`${p}99`}})})]},N.id||N.name)}),!!x&&o.jsx("div",{className:"text-[10px] font-medium text-oai-gray-400 dark:text-oai-gray-500",children:y("usage.overview.model_more",{count:x})})]}),m.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:Jt(m.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:v})}):null]},m.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:d.filter(m=>m.label===i).map(m=>{const g=Gn(m.label,0),p=Zt(m),b=[...m.models].sort((j,x)=>(x.share||0)-(j.share||0)),v=!!p&&a,k=v?`${p==="claude"?"Claude":"Codex"} Context Breakdown`:m.label;return o.jsx(G0,{provider:m,color:g,providerHeading:k,contextSource:v?p:null,from:t,to:n,sortedModels:b},m.label)})})]})})}function G0({provider:e,color:t,providerHeading:n,contextSource:a,from:r,to:s,sortedModels:l}){const{currency:i,rate:c}=_t(),[u,f]=h.useState(!1),d=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(fa,{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(Bi,{size:12,className:"text-oai-gray-400 dark:text-oai-gray-500 animate-spin shrink-0","aria-label":y("dashboard.context_breakdown.loading_aria")})]}),d&&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(Jo,{from:r,to:s,source:a,referenceTotalTokens:e.usage,onLoadingChange:f})}):null,o.jsx("div",{className:"space-y-3",children:l.map(m=>{const g=_a(m.usage),p=Ma(m.cost,i,c),b=Math.max(0,Math.min(100,Number(m.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:m.name,children:m.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:[m.share,"%"]})]}),o.jsx("div",{className:"h-[3px] bg-oai-gray-100 dark:bg-oai-gray-800 rounded-full overflow-hidden",role:"progressbar","aria-valuenow":b,"aria-valuemin":0,"aria-valuemax":100,children:o.jsx("div",{className:"h-full transition-[width] duration-500 ease-out",style:{width:`${b}%`,backgroundColor:t,opacity:.45}})})]},m.id||m.name)})})]})}const K0={claude:"Claude",codex:"Codex"};function Q0({fleetData:e=[],from:t,to:n}){const a=e.filter(ja).filter(i=>Zt(i)!==null);if(a.length===0)return null;const r=new Map;for(const i of a){const c=Zt(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(sn,{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=Zt(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:K0[c]??c}),o.jsx("span",{className:"text-xs font-medium tabular-nums text-oai-gray-500 dark:text-oai-gray-300",children:_a(i.usage)})]}):null,o.jsx(Jo,{from:t,to:n,source:c,referenceTotalTokens:i.usage})]},c)})})})}function J0(e){return e==="day"?"hourly":e==="total"?"monthly":"daily"}function Z0(e){return!!e&&!e.missing&&!e.future}function eg(e){const t=e?.billable_total_tokens??e?.total_tokens??e?.value,n=Number(t);return Number.isFinite(n)&&n>=0?n:0}function tg(e){const t=e?.total_tokens??e?.billable_total_tokens??e?.value,n=Number(t);return Number.isFinite(n)&&n>=0?n:0}function ng(e){const t=Array.isArray(e)?e.filter(Z0):[];let n=0,a=0,r=0,s=0,l=!1,i=0,c=-1,u=null;for(const f of t){const d=tg(f),m=eg(f);n+=d,a+=m;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),m>0&&(i+=1),m>c&&(c=m,u=f)}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 Er(e){return String(e).padStart(2,"0")}function ag(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,f=c%60;return`${r} ${s}:${l}–${Er(u)}:${Er(f)}`}return String(t==="monthly"?e.month||e.label||"":e.day||e.label||"")}function rg(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 og(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 sg=[{period:"day",labelKey:"trend.zoom.gran.30min"},{period:"month",labelKey:"trend.zoom.gran.day"},{period:"total",labelKey:"trend.zoom.gran.month"}],ig=24,Rt="#10b981";function Wr(e){return e==="day"?"day":e==="total"?"total":"month"}function ca(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 lg(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 cg(e,t){const n=/^(\d{4})-(\d{2})/.exec(String(e||"")),a=/^(\d{4})-(\d{2})/.exec(String(t||""));if(!n||!a)return ig;const r=Number(a[1])*12+Number(a[2])-(Number(n[1])*12+Number(n[2]))+1;return Math.max(1,r)}function Ar(e,t){return t?e==="total"?{from:lg(t,-23),to:t}:{from:ca(t,-29),to:t}:{from:null,to:null}}function dg(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 xn({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 ug({zoomConfig:e,period:t,from:n,to:a,timeZoneLabel:r,onClose:s,renderChart:l}){const{currency:i,rate:c}=_t(),u=R.useMemo(()=>tn({timeZone:e?.timeZone,offsetMinutes:e?.tzOffsetMinutes,date:e?.now||new Date})||a||n||null,[e?.timeZone,e?.tzOffsetMinutes,e?.now,a,n]),[f,d]=R.useState(()=>Wr(t)),[m,g]=R.useState(u),[p,b]=R.useState(()=>Ar(Wr(t),u)),[v,k]=R.useState(!1),[j,x]=R.useState(!1),[N,C]=R.useState(!1),T=u,z=M=>{d(M),M!=="day"&&b(Ar(M,u))},$=R.useMemo(()=>f==="day"?{from:m,to:m,months:void 0}:f==="total"?{from:void 0,to:p.to,months:cg(p.from,p.to)}:{from:p.from,to:p.to,months:void 0},[f,m,p]),{rows:D,from:A,to:K,loading:B}=io({...e,period:f,from:$.from,to:$.to,months:$.months}),E=R.useMemo(()=>ng(D),[D]),W=R.useCallback(()=>C(!0),[]),H=M=>{M.target===M.currentTarget&&N&&s()};if(R.useEffect(()=>{const M=J=>{J.key==="Escape"&&W()};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[W]),typeof document>"u")return null;const _=f==="day"&&!!m,w=f==="day"&&!!m&&(!T||m<T),I=E.totalCostUsd!=null?et(E.totalCostUsd,{currency:i,rate:c}):null;return o.jsxs("div",{onAnimationEnd:H,onClick:M=>{M.target===M.currentTarget&&W()},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
|
+
@keyframes tt-fade-in { from { opacity: 0; } to { opacity: 1; } }
|
|
44
|
+
@keyframes tt-fade-out { from { opacity: 1; } to { opacity: 0; } }
|
|
45
|
+
@keyframes tt-modal-entrance {
|
|
46
|
+
from { opacity: 0; transform: scale(0.96) translateY(10px); }
|
|
47
|
+
to { opacity: 1; transform: scale(1) translateY(0); }
|
|
48
|
+
}
|
|
49
|
+
@keyframes tt-modal-exit {
|
|
50
|
+
from { opacity: 1; transform: scale(1) translateY(0); }
|
|
51
|
+
to { opacity: 0; transform: scale(0.96) translateY(10px); }
|
|
52
|
+
}
|
|
53
|
+
.animate-tt-fade-in { animation: tt-fade-in 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
|
|
54
|
+
.animate-tt-fade-out { animation: tt-fade-out 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
|
|
55
|
+
.animate-tt-modal { animation: tt-modal-entrance 0.3s cubic-bezier(0.34, 1.3, 0.64, 1) forwards; }
|
|
56
|
+
.animate-tt-modal-exit { animation: tt-modal-exit 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
|
|
57
|
+
@media (prefers-reduced-motion: reduce) {
|
|
58
|
+
.animate-tt-fade-in, .animate-tt-fade-out, .animate-tt-modal, .animate-tt-modal-exit { animation: none; }
|
|
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",N?"animate-tt-modal-exit":"animate-tt-modal"),children:[o.jsx("button",{type:"button",onClick:W,"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(da,{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:Rt}}),o.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5",style:{backgroundColor:Rt}})]}),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(xn,{label:y("trend.zoom.stats.tokens"),value:Ae(E.totalTokens)}),I?o.jsx(xn,{label:y("trend.zoom.stats.cost"),value:I}):null,o.jsx(xn,{label:y("trend.zoom.stats.conversations"),value:E.conversationCount.toLocaleString()}),E.peak?o.jsx(xn,{label:y("trend.zoom.stats.peak"),value:Ae(E.peak.value),sub:dg(E.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(ro,{size:11,style:{color:Rt}}),o.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono",style:{color:Rt},children:y("trend.zoom.insight_badge")})]}),o.jsxs("div",{className:"pl-3.5 border-l-2 relative",style:{borderColor:Rt},children:[o.jsx("div",{className:"absolute inset-y-0 left-0 w-[3px] blur-[2px] opacity-15 pointer-events-none rounded-full",style:{backgroundColor:Rt}}),o.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-600 dark:text-zinc-400 font-normal",children:y(rg(E),{active:E.activeBuckets,peak:Ae(E.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:sg.map(M=>o.jsx("button",{type:"button",role:"tab","aria-selected":f===M.period,onClick:()=>z(M.period),className:Xe("px-2.5 py-1 rounded transition-colors",f===M.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(M.labelKey)},M.period))}),f==="day"?o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("button",{type:"button",onClick:()=>_&&g(M=>ca(M,-1)),disabled:!_,"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(yi,{size:16})}),o.jsxs(ea,{open:v,onOpenChange:k,children:[o.jsx(ta,{"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:m||"—"}),o.jsx(na,{children:o.jsx(aa,{sideOffset:8,side:"bottom",align:"center",className:"!z-[9999]",children:o.jsx(ra,{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(la,{from:m,to:m,onApply:M=>{M&&g(M),k(!1)},onCancel:()=>k(!1)})})})})]}),o.jsx("button",{type:"button",onClick:()=>w&&g(M=>ca(M,1)),disabled:!w,"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(Jr,{size:16})})]}):o.jsxs(ea,{open:j,onOpenChange:x,children:[o.jsx(ta,{"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(na,{children:o.jsx(aa,{sideOffset:8,side:"bottom",align:"end",className:"!z-[9999]",children:o.jsx(ra,{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(la,{from:p.from,to:p.to,onApply:(M,J)=>{M&&b({from:M,to:J||M}),x(!1)},onCancel:()=>x(!1)})})})})]})]}),o.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:B&&(!D||D.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:D,from:A,to:K,period:f,timeZoneLabel:r})})]})]})]})}function Fr(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 fg(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=Fr(t,.25),s=Fr(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 Rr=["#f472b6","#38bdf8","#34d399","#fbbf24","#a78bfa","#fb7185","#2dd4bf","#f97316","#6366f1","#ec4899","#14b8a6","#f59e0b"],Zo={Input:"#38bdf8","Cached Input":"#14b8a6",Output:"#a78bfa","Reasoning Output":"#fb7185"},mg={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 es(e){const t=e.toLowerCase();for(const[r,s]of Object.entries(mg))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)%Rr.length;return Rr[a]}function hg(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 gg(e,t){return e?.future?"predicted":e?.missing?"unsynced":t>0?"real":"real_zero"}const yg=.35,Ir=2,Lr=4;function pg({value:e,displayValue:t,scale:n,index:a,row:r,totalBars:s,onMouseEnter:l,onMouseLeave:i}){const c=zt(),u=gg(r,e),f=u==="predicted"||u==="unsynced",d=n.effectiveMax>0?t/n.effectiveMax*100:0;let m,g;u==="real"?(m=`${Math.max(d,2)}%`,g=`${Lr}px`):f&&d>0?(m=`${d}%`,g=`${Lr}px`):(m=`${Ir}px`,g=`${Ir}px`);const p=u==="real"?hg(r):[],b=p.reduce((k,j)=>k+j.value,0),v=u!=="real"||b<=0;return o.jsxs(gt.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:k=>l(k,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:m,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:f?yg:1,background:u==="real"?"#10b981":void 0}}):p.map((k,j)=>{const x=k.type==="token_type"?Zo[k.name]:es(k.name),N=`${k.value/b*100}%`;return o.jsx("div",{"data-trend-bar":j===0?"true":void 0,className:"w-full group-hover:brightness-110 transition-all",style:{height:N,background:x}},j)})})]})}function bg(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 zr=.98;function xg(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 u=c>0?i/c:a;t[n]=u*Math.pow(zr,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 u=c>0?i/c:s;t[n]=u*Math.pow(zr,l-n)}else t[n]=0}return t}function ts({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:f=null}){const d=R.useMemo(()=>Array.isArray(e)&&e.length?e:[],[e]),{rawValues:m,seriesValues:g,scale:p,interpolatedValues:b}=R.useMemo(()=>{const E=d.map(bg),W=E.map(H=>H??0);return{rawValues:E,seriesValues:W,scale:fg(W),interpolatedValues:xg(E)}},[d]),{currency:v,rate:k}=_t(),j=J0(a),[x,N]=R.useState(null),[C,T]=R.useState({x:0,y:0,shiftX:0,flipDown:!1}),[z,$]=R.useState(!1),D=R.useRef(null),A=R.useRef(null),K=(E,W,H,_,w,I)=>{A.current&&(clearTimeout(A.current),A.current=null);const M=u?ag(W,j):W?.day||W?.hour||W?.month||"";N({row:W,value:H,segments:_,timeLabel:M,kind:w,displayValue:I});const J=E.currentTarget.querySelector('[data-trend-bar="true"]'),P=J&&J.parentElement?J.parentElement.getBoundingClientRect():E.currentTarget.getBoundingClientRect(),L=D.current;if(!L)return;const V=L.getBoundingClientRect(),q=P.left-V.left+P.width/2,fe=P.top-V.top,ve=140;let xe=0;q<ve?xe=ve-q:q>V.width-ve&&(xe=V.width-ve-q);const pe=96+(u?22:0)+(_.length?Math.min(_.length*30+24,174):0),Me=fe<pe+12;T({x:q,y:fe,shiftX:xe,flipDown:Me})},B=()=>{A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{N(null)},150)};return o.jsxs("div",{ref:D,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})]}),f&&o.jsx("button",{type:"button",onClick:()=>$(!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(ao,{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(E=>o.jsx("span",{children:E===0?"0":Ae(p.effectiveMax*E,{decimals:0})},E))}),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(E=>o.jsx("div",{className:"w-full border-t border-oai-gray-100 dark:border-oai-gray-800",style:{top:`${100-E}%`}},E))}),o.jsx("div",{className:Xe("flex items-end gap-0.5 relative z-0",c),children:g.length>0?g.map((E,W)=>{const H=d[W],w=H?.missing||H?.future?Math.min(b[W]??0,p.effectiveMax):p.clippedValues[W]??0;return o.jsx(pg,{value:E,displayValue:w,scale:p,index:W,row:H,totalBars:g.length,onMouseEnter:K,onMouseLeave:B},W)}):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:d.map((E,W)=>{const H=g.length-1,_=Math.max(1,Math.ceil(g.length/8)),w=W%_===0||W===H,I=W===0?"justify-start":W===H?"justify-end":"justify-center";return o.jsx("div",{className:Xe("flex-1 min-w-0 flex",I),children:w&&o.jsx("span",{className:"text-[9px] text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap font-mono",children:og(E,j)})},W)})}),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:`${C.x}px`,top:`${C.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",C.flipDown?"top-[10px]":"bottom-[10px]"),style:{transform:`translateX(calc(-50% + ${C.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:k})})," ",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:E,value:W,type:H})=>{const _=x.value||1,w=Math.round(W/_*100),I=H==="token_type"?Zo[E]:es(E);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:E,children:E}),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:W.toLocaleString()}),o.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[w,"%"]})]})]}),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:`${w}%`,backgroundColor:I,boxShadow:`0 0 4px ${I}55`}})})]},E)})})]}):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",C.flipDown?"top-[6px] border-l border-t":"bottom-[6px] border-r border-b"),style:C.flipDown?{marginTop:"1px"}:{marginBottom:"1px"}})]}),z&&f&&o.jsx(ug,{zoomConfig:f,period:a,from:t,to:n,timeZoneLabel:r,onClose:()=>$(!1),renderChart:E=>o.jsx(ts,{embedded:!0,isZoom:!0,chartHeightClass:"h-full",...E})})]})}const Yr="widgetOnboardingDismissed",Br="tokentracker_native_app",kg=(()=>{try{return new URLSearchParams(window.location.search).get("app")==="1"?(localStorage.setItem(Br,"1"),!0):localStorage.getItem(Br)==="1"}catch{return!1}})();function wg({enterDelay:e=0}){const[t,n]=h.useState(()=>{try{return localStorage.getItem(Yr)==="1"}catch{return!1}}),a=h.useCallback(()=>{n(!0);try{localStorage.setItem(Yr,"1")}catch{}},[]);return!kg||pi()?null:o.jsx(Zr,{initial:!1,children:!t&&o.jsxs(gt.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 vg(e){const{copy:t,screenshotMode:n,screenshotTitleLine1:a,screenshotTitleLine2:r,identityDisplayName:s,identityStartDate:l,activeDays:i,identitySubscriptions:c,identityScrambleDurationMs:u,projectUsageEntries:f,planPrices:d={},onPlanPriceChange:m,modelBreakdown:g=null,projectUnattributedSources:p=[],projectUsageLimit:b,setProjectUsageLimit:v,pulse:k,pulseComparedAtLabel:j,isLocalMode:x,trendRowsForDisplay:N,trendFromForDisplay:C,trendToForDisplay:T,trendZoomConfig:z,usageFrom:$,usageTo:D,period:A,trendTimeZoneLabel:K,activityHeatmapBlock:B,periodsForDisplay:E,setSelectedPeriod:W,autoRefreshOptions:H,autoRefreshIntervalMs:_,onAutoRefreshIntervalChange:w,customFrom:I,customTo:M,onCustomRangeApply:J,customRangeOpen:P,onCustomRangeOpenChange:L,summaryLabel:V,summaryValue:q,summaryUpdatedAtLabel:fe,summaryCostValue:ve,usageInsights:xe,costInfoEnabled:pe,openCostModal:Me,costModalOpen:je,closeCostModal:ke,allowBreakdownToggle:Ce,refreshAll:O,usageLoadingState:Y,dataHealthMessage:he,fleetData:oe,usageLimits:ye,limitDisplayMode:Oe,hasDetailsActual:$e,dailyEmptyPrefix:F,installSyncCmd:U,dailyEmptySuffix:Q,detailsColumns:G,ariaSortFor:ne,toggleSort:se,sortIconFor:ue,pagedDetails:ie,dailyBreakdownRows:me,dailyBreakdownColumns:De,dailyBreakdownAriaSortFor:ge,dailyBreakdownSortIconFor:Fe,dailyBreakdownDateKey:Ee,detailsDateKey:Ye,renderDetailDate:Mt,renderDailyBreakdownDate:yt,renderDetailCell:Ue,DETAILS_PAGED_PERIODS:pt,detailsPageCount:bt,detailsPage:re,setDetailsPage:ae}=e,ee=null,de=null,Te=Array.isArray(oe)&&oe.some(le=>ja(le)&&Zt(le)!==null);return o.jsxs(o.Fragment,{children:[o.jsx(ol,{bare:!n,hideHeader:n,header:ee,footer:n?null:de,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(Mr,{period:A,periods:E,onPeriodChange:W,autoRefreshOptions:H,autoRefreshIntervalMs:_,onAutoRefreshIntervalChange:w,summaryLabel:V,summaryValue:q,summaryUpdatedAtLabel:fe,summaryCostValue:ve,usageInsights:xe,onCostInfo:pe?Me:null,onRefresh:n?null:O,loading:Y,customFrom:I,customTo:M,onCustomRangeApply:J,customRangeOpen:P,onCustomRangeOpenChange:L}),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(ir,{rankLabel:l??t("identity_card.rank_placeholder"),streakDays:i,subscriptions:c})}),B?o.jsx("div",{className:"lg:col-span-4 min-w-0",children:B}):null,o.jsx("div",{className:"lg:col-span-6 min-w-0",children:o.jsx($r,{fleetData:oe,from:$,to:D,usageLimits:ye,limitDisplayMode:Oe})})]})]}):o.jsxs("div",{className:"flex flex-col gap-4",children:[he?o.jsx(ct,{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:he})}):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(ct,{delay:.05,className:"h-full",children:o.jsx(Mr,{period:A,periods:E,onPeriodChange:W,autoRefreshOptions:H,autoRefreshIntervalMs:_,onAutoRefreshIntervalChange:w,summaryLabel:V,summaryValue:q,summaryUpdatedAtLabel:fe,summaryCostValue:ve,usageInsights:xe,onCostInfo:pe?Me:null,onRefresh:n?null:O,loading:Y,customFrom:I,customTo:M,onCustomRangeApply:J,customRangeOpen:P,onCustomRangeOpenChange:L,emphasized:!0})})}),o.jsx("div",{className:"lg:col-span-3 min-w-0",children:o.jsx(ct,{delay:.09,children:o.jsx(ts,{rows:N,from:C,to:T,period:A,timeZoneLabel:K,showTimeZoneLabel:!1,zoomConfig:z})})}),o.jsx("div",{className:"lg:col-span-2 min-w-0",children:o.jsx(ct,{delay:.13,children:o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsx(sd,{pulse:k,period:A,comparedAtLabel:j}),o.jsx(ir,{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(ct,{delay:.19,children:o.jsx($r,{fleetData:oe,from:$,to:D,showInlineContext:!1,usageLimits:ye,limitDisplayMode:Oe})})}),B?o.jsx("div",{className:Te?"lg:col-span-2 min-w-0":"lg:col-span-6 min-w-0",children:o.jsx(ct,{delay:.25,children:B})}):null,Te?o.jsx("div",{className:B?"lg:col-span-4 min-w-0":"lg:col-span-6 min-w-0",children:o.jsx(ct,{delay:.31,children:o.jsx(Q0,{fleetData:oe,from:$,to:D})})}):null,x?o.jsx("div",{className:"lg:col-span-6",children:o.jsx(wg,{enterDelay:.37})}):null]}),o.jsx(ct,{delay:.42,children:o.jsx(qc,{sources:g?.sources,planPrices:d,onPlanPriceChange:m,copy:t,className:"oai-card p-4"})}),o.jsx(ct,{delay:.43,children:o.jsx(Lc,{projectEntries:f,projectUnattributedSources:p,projectLimit:b,onProjectLimitChange:v,copy:t,hasDetailsActual:$e,dailyEmptyPrefix:F,installSyncCmd:U,dailyEmptySuffix:Q,detailsColumns:G,ariaSortFor:ne,toggleSort:se,sortIconFor:ue,pagedDetails:ie,dailyBreakdownRows:me,dailyBreakdownColumns:De,dailyBreakdownAriaSortFor:ge,dailyBreakdownSortIconFor:Fe,dailyBreakdownDateKey:Ee,detailsDateKey:Ye,renderDetailDate:Mt,renderDailyBreakdownDate:yt,renderDetailCell:Ue,DETAILS_PAGED_PERIODS:pt,period:A,detailsPageCount:bt,detailsPage:re,setDetailsPage:ae})})]})}),o.jsx(Fc,{isOpen:je,onClose:ke,fleetData:oe})]})}const Ng=["day","24h","week","month","total","custom"],ns="tt:dashboard-auto-refresh-ms",en=3e4,as=[{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"}],_g=3e4,Mg=6e4,Kn=new Set(["day","hour","month"]),Kt=new Set(["day","24h","total","custom"]),jg=new Set(as.map(e=>e.value));function rs(e){if(e==null||e==="")return en;const t=Number(e);return Number.isFinite(t)&&jg.has(t)?t:en}function Sg(){if(typeof window>"u")return en;try{return rs(window.localStorage?.getItem(ns))}catch{return en}}function Cg(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 Qn(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 kn(e){return e?Sn(e,null):null}function Hr(e){return e?e?.billable_total_tokens??e?.value??e?.total_tokens:null}function Dg(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 Tg(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function Bg({baseUrl:e,onMainContentVisible:t}){const{resolvedLocale:n}=bi(),{currency:a,rate:r}=_t(),[s,l]=h.useState(!1),[i,c]=h.useState(null),[u,f]=h.useState(null),[d,m]=h.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(max-width: 640px)").matches),g=h.useMemo(()=>typeof window>"u"?!1:xi(window.location.search),[]),p=2200,[b,v]=h.useState(!0),[k,j]=h.useState(!1),[x,N]=h.useState(Sg),[C,T]=h.useState(()=>Date.now()),[z,$]=h.useState(()=>Date.now()),D=h.useRef(!1),A=h.useRef(!1),K=h.useRef(0),B=h.useRef(null),E=h.useRef(0),W=h.useRef(null),H=h.useRef(!1),_=Yt(),w=null,I=!1,M=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");h.useEffect(()=>{if(!M&&!_){c(null);return}let S=!0;return(async()=>{try{const X=await Oi({baseUrl:e});if(!S)return;c(X&&typeof X=="object"?X:null)}catch{if(!S)return;c(null)}})(),()=>{S=!1}},[e,M,_]);const J=h.useCallback(async()=>{if(!M){f(null);return}const S=K.current,X=B.current;if(X?.generation===S)return X.promise;const te=(async()=>{try{const ce=await $i();if(K.current!==S)return;f(ce&&typeof ce=="object"?ce:null)}catch{if(K.current!==S)return;f(null)}finally{B.current?.promise===te&&(B.current=null)}})();return B.current={generation:S,promise:te},te},[M]);h.useEffect(()=>{const S=K.current+1;return K.current=S,J(),()=>{K.current===S&&(K.current+=1)}},[e,J]),h.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const S=window.matchMedia("(max-width: 640px)"),X=()=>m(S.matches);return X(),S.addEventListener?(S.addEventListener("change",X),()=>S.removeEventListener("change",X)):(S.addListener(X),()=>S.removeListener(X))},[]);const P=h.useMemo(()=>to(),[]),L=h.useMemo(()=>eo(),[]),V=h.useMemo(()=>vi(),[]),q=h.useMemo(()=>V||new Date(C),[C,V]),fe="default",[ve,xe]=h.useState("day"),[pe,Me]=h.useState(null),[je,ke]=h.useState(null),[Ce,O]=h.useState(!1),Y=g?"total":ve,he=h.useMemo(()=>Y==="custom"&&pe&&je?{from:pe,to:je}:Ni(Y,{timeZone:P,offsetMinutes:L,now:q}),[q,Y,P,L,pe,je]),oe=he.from,ye=he.to,Oe=h.useMemo(()=>_i({timeZone:P,offsetMinutes:L}),[P,L]),$e=h.useMemo(()=>Mi({timeZone:P,offsetMinutes:L}),[P,L]),F=h.useMemo(()=>`Local time (${$e})`,[$e]),U=P,Q=L,G=Oe,ne=h.useMemo(()=>tn({timeZone:P,offsetMinutes:L,date:q}),[q,P,L]),se=h.useMemo(()=>{const S=Dg(ne)||new Date,X=Tg(S,-29);return{from:ht(X),to:ht(S)}},[ne]),{daily:ue,summary:ie,rolling:me,source:De,loading:ge,error:Fe,refresh:Ee}=Xa({baseUrl:e,accessToken:w,guestAllowed:I,from:oe,to:ye,includeDaily:Y!=="total",cacheKey:fe,timeZone:P,tzOffsetMinutes:L,now:q}),{daily:Ye,loading:Mt,refresh:yt}=Xa({baseUrl:e,accessToken:w,guestAllowed:I,from:se.from,to:se.to,includeDaily:!0,cacheKey:`${fe}.daily-breakdown`,timeZone:P,tzOffsetMinutes:L,now:q}),{breakdown:Ue,loading:pt,refresh:bt}=Il({baseUrl:e,accessToken:w,guestAllowed:I,from:oe,to:ye,cacheKey:fe,timeZone:P,tzOffsetMinutes:L}),{pulse:re,refresh:ae}=tc({baseUrl:e,accessToken:w,guestAllowed:I,period:Y,timeZone:P,tzOffsetMinutes:L,now:q,cacheKey:fe}),ee=h.useMemo(()=>{try{return new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit",timeZone:P||void 0}).format(q)}catch{return null}},[q,P]),{planPrices:de,setPlanPrice:Te}=Yl(),[le,Ot]=h.useState(10),{entries:Bt,unattributedSources:Ht,loading:jt,refresh:xt}=vl({baseUrl:e,accessToken:w,limit:le,from:oe,to:ye,timeZone:P,tzOffsetMinutes:L}),Sa=Y==="week"||Y==="month",mn=Y==="week"||Y==="month",Ca=h.useMemo(()=>ue.filter(S=>S?.future?!1:!S?.day||!ne?!0:String(S.day)<=String(ne)),[ue,ne]),{rows:it,from:os,to:ss,loading:is,refresh:Da}=io({baseUrl:e,accessToken:w,guestAllowed:I,period:Y,from:oe,to:ye,months:24,cacheKey:fe,timeZone:U,tzOffsetMinutes:Q,now:q,sharedRows:Sa?ue:null,sharedRange:Sa?{from:oe,to:ye}:null}),ls=h.useMemo(()=>({baseUrl:e,accessToken:w,guestAllowed:I,cacheKey:fe,timeZone:U,tzOffsetMinutes:Q,now:q}),[e,w,I,fe,U,Q,q]),{daily:$t,heatmap:lt,loading:cs,refresh:Ta}=wl({baseUrl:e,accessToken:w,guestAllowed:I,weeks:52,cacheKey:fe,timeZone:P,tzOffsetMinutes:L,now:q}),{data:Ut,refresh:Pa,revalidate:Oa}=Ei(),{displayMode:ds}=Wi();h.useEffect(()=>{Ut&&typeof Ut=="object"&&ki(Ut)},[Ut]);const Ge=h.useMemo(()=>Y==="day"||Y==="24h"?"hour":Y==="total"?"month":"day",[Y]),us=h.useMemo(()=>Za(Ge),[Ge]),hn="day",fs=h.useMemo(()=>[...Za(hn),{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")}],[]),[Ke,$a]=h.useState(()=>({key:"day",dir:"desc"}));h.useEffect(()=>{$a(S=>!Kn.has(S.key)||S.key===Ge?S:{key:Ge,dir:S.dir})},[Ge]);const Et=h.useMemo(()=>Kn.has(Ke.key)&&Ke.key!==Ge?{...Ke,key:Ge}:Ke,[Ge,Ke]),gn=h.useMemo(()=>{if(Y==="day"||Y==="24h")return Array.isArray(it)?it.filter(te=>te?.hour&&!te?.future):[];if(Y==="total"){const te=Array.isArray(it)?it.filter(ce=>ce?.month&&!ce?.future):[];return fc(te)}const S=Ca;return!S.some(te=>!te?.missing&&!te?.future)&&ue.length>0?ue.filter(te=>!te?.future).slice(-30).filter(te=>te?.day):S},[Y,it,Ca,ue]),Vt=h.useMemo(()=>er(gn,Et),[gn,Et]),ms=h.useMemo(()=>gn.some(S=>!S?.missing&&!S?.future),[gn]),Pn=h.useMemo(()=>{if(!Kt.has(Y))return 1;const S=Math.ceil(Vt.length/jn);return S>0?S:1},[Y,Vt.length]),[On,yn]=h.useState(0);h.useEffect(()=>{if(!Kt.has(Y)){yn(0);return}yn(S=>Math.min(S,Pn-1))},[Pn,Y]),h.useEffect(()=>{Kt.has(Y)&&yn(0)},[Y,Ke.dir,Ke.key]);const hs=h.useMemo(()=>Kt.has(Y)?mc(Vt,On,jn):Vt,[On,Y,Vt]),Ea=h.useMemo(()=>vc(Ye.filter(S=>!S?.future&&S?.day).slice(-30),{fallback:y("shared.placeholder.short")}),[Ye]),Wt=h.useMemo(()=>Kn.has(Ke.key)?{...Ke,key:hn}:Ke,[Ke]),gs=h.useMemo(()=>er(Ea,Wt),[Ea,Wt]),ys=h.useMemo(()=>mn?ue:Y==="day"||Y==="24h"?Array.isArray(it)?it.filter(S=>S?.hour):[]:it,[ue,Y,it,mn]),ps=mn?oe:os,bs=mn?ye:ss;function xs(S,X){if(S?.future)return"—";if(S?.missing)return y("shared.status.unsynced");if(X==="total_tokens")return Qe(kn(S));if(X==="total_cost_usd")return et(S?.total_cost_usd,{currency:a,rate:r});if(X==="cost_per_million_tokens"){const te=Le(S?.cost_per_million_tokens);return te==null?y("shared.placeholder.short"):et(te,{currency:a,rate:r})}return X==="top_model"?S?.top_model||y("shared.placeholder.short"):Qe(S?.[X])}function ks(S){const X=S?.[Ge];if(X==null)return"";const te=String(X);if(Ge==="hour"){const[ce,Ve]=te.split("T");if(ce&&Ve)return`${ce} ${Ve.slice(0,5)}`}return te}function ws(S){const X=S?.[hn];return X==null?"":String(X)}function vs(S){$a(X=>X.key===S?{key:S,dir:X.dir==="asc"?"desc":"asc"}:{key:S,dir:"desc"})}function Ns(S){return Et.key!==S?null:Et.dir==="asc"?"ascending":"descending"}function _s(S){return Et.key!==S?"":Et.dir==="asc"?"▲":"▼"}function Ms(S){return Wt.key!==S?null:Wt.dir==="asc"?"ascending":"descending"}function js(S){return Wt.key!==S?"":Wt.dir==="asc"?"▲":"▼"}const Ss=h.useMemo(()=>{if(!_&&!M)return 0;const S=Number(lt?.active_days);if(Number.isFinite(S))return S;let X=0;const te=new Set,ce=(We,Ct,An)=>{typeof We!="string"||!We||te.has(We)||Qn(Ct,An)&&(te.add(We),X+=1)};if(Array.isArray($t))for(const We of $t)ce(We?.day,kn(We));const Ve=Array.isArray(lt?.weeks)?lt.weeks:[];for(const We of Ve)for(const Ct of Array.isArray(We)?We:[]){const An=Hr(Ct);ce(Ct?.day,An,Ct?.level)}return X},[_,M,lt?.active_days,lt?.weeks,$t]),[Wa,Aa]=h.useState("month"),Cs=h.useCallback(S=>{S==="custom"?(Aa(X=>X==="custom"?"month":X),xe(X=>pe&&je?"custom":X),O(!0)):(xe(S),Aa(S),O(!1))},[pe,je]),Ds=h.useCallback((S,X)=>{Me(S),ke(X),xe("custom"),O(!1)},[]),Ts=h.useCallback(S=>{O(S),!S&&ve==="custom"&&!pe&&xe(Wa)},[ve,pe,Wa]),qt=h.useCallback(async({forceUsageLimits:S=!0}={})=>{const X=Date.now();T(X),await Promise.all([Ee(),Ta(),Da(),bt(),xt(),yt(),J(),S?Pa():Oa(),ae()]),$(X)},[yt,Ta,J,bt,xt,Da,Ee,Pa,Oa,ae]);h.useEffect(()=>{if(g||V||typeof window>"u")return;const S=()=>{const te=new Date,ce=tn({timeZone:P,offsetMinutes:L,date:te});if(ce){if(W.current==null){W.current=ce;return}W.current!==ce&&(W.current=ce,T(te.getTime()))}};S();const X=window.setInterval(S,Mg);return typeof document<"u"&&document.addEventListener("visibilitychange",S),window.addEventListener("focus",S),()=>{window.clearInterval(X),typeof document<"u"&&document.removeEventListener("visibilitychange",S),window.removeEventListener("focus",S)}},[V,g,P,L]);const Ps=h.useCallback(async()=>{j(!0);try{if(M)try{await Ua()}catch(S){console.error("[DashboardPage] Manual sync failed:",S)}await qt({forceUsageLimits:!0})}catch(S){console.error("[DashboardPage] Refresh failed:",S)}finally{j(!1)}},[M,qt]),Fa=h.useCallback(()=>!M||A.current?null:(A.current=!0,Ua().then(Cg).catch(S=>(console.error("[DashboardPage] Auto sync failed:",S),!1)).finally(()=>{A.current=!1})),[M]),Ra=h.useCallback(async()=>{const S=Fa();try{await qt({forceUsageLimits:!1}),S&&S.then(X=>{if(X)return qt({forceUsageLimits:!1})})}catch(X){console.error("[DashboardPage] Auto refresh failed:",X)}},[qt,Fa]),Os=h.useCallback(S=>{const X=rs(S);N(X);try{window.localStorage?.setItem(ns,String(X))}catch{}},[]);h.useEffect(()=>{if(g||typeof window>"u"||x<=0)return;const S=()=>typeof document>"u"||document.visibilityState==="visible",X=async({throttle:Ve=!1}={})=>{if(!S())return;const We=Date.now();if(!(Ve&&We-E.current<_g)&&!D.current){D.current=!0,E.current=We;try{await Ra()}finally{D.current=!1}}},te=window.setInterval(()=>{X()},x),ce=()=>{X({throttle:!0})};return typeof document<"u"&&document.addEventListener("visibilitychange",ce),window.addEventListener("focus",ce),()=>{window.clearInterval(te),typeof document<"u"&&document.removeEventListener("visibilitychange",ce),window.removeEventListener("focus",ce)}},[x,Ra,g]);const $n=k||ge||Mt||cs||is||pt||jt,$s=h.useMemo(()=>y("shared.data_source",{source:String(De||"edge").toUpperCase()}),[De,n]),Ia=y("dashboard.identity.fallback"),Es=h.useMemo(()=>Ia.replace(/[^a-zA-Z0-9._-]/g,"_"),[Ia]),Ws=h.useMemo(()=>{let S=null;const X=ce=>{typeof ce!="string"||!ce||(!S||ce<S)&&(S=ce)};if(Array.isArray($t))for(const ce of $t)ce?.day&&Qn(kn(ce))&&X(ce.day);const te=Array.isArray(lt?.weeks)?lt.weeks:[];for(const ce of te)for(const Ve of Array.isArray(ce)?ce:[]){if(!Ve?.day)continue;const We=Hr(Ve),Ct=Ve?.level;Qn(We,Ct)&&X(Ve.day)}return S},[lt?.weeks,$t]),As=h.useMemo(()=>(Array.isArray(i?.subscriptions?.items)?i.subscriptions.items:[]).map(te=>{const ce=typeof te?.tool=="string"?te.tool.trim():"",We=(typeof te?.plan_type=="string"?te.plan_type:typeof te?.planType=="string"?te.planType:"").trim();return!ce||!We?null:{tool:ce,planType:We,provider:typeof te?.provider=="string"?te.provider.trim():"",product:typeof te?.product=="string"?te.product.trim():"",rateLimitTier:typeof te?.rate_limit_tier=="string"?te.rate_limit_tier.trim():typeof te?.rateLimitTier=="string"?te.rateLimitTier.trim():""}}).filter(Boolean).slice(0,6),[i]),Fs=o.jsx(Ec,{heatmap:lt,timeZoneLabel:Oe,timeZoneShortLabel:$e,hideLegend:g,defaultToLatestMonth:g}),Rs=h.useMemo(()=>`${oe}..${ye}`,[oe,Y,ye]),Is=y("usage.summary.total"),St=kn(ie),La=y("shared.unit.thousand_abbrev"),za=y("shared.unit.million_abbrev"),Ya=y("shared.unit.billion_abbrev"),Xt=Le(St),Ba=Xt!=null&&(d&&Math.abs(Xt)>=1e9||Math.abs(Xt)>=1e12),Ls=h.useMemo(()=>Ba?Ae(Xt,{thousandSuffix:La,millionSuffix:za,billionSuffix:Ya,decimals:1}):Qe(St),[Ya,za,St,Xt,La,Ba]),zs=h.useMemo(()=>{const S=new Intl.DateTimeFormat(n||void 0,{timeZone:P,year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"short"}).format(new Date(z));return y("usage.summary.updated_at",{timestamp:S})},[z,n,P]),Ys=y("dashboard.core_index.collapse_label"),Bs=y("dashboard.core_index.expand_label"),Hs=y("dashboard.core_index.collapse_aria"),Us=y("dashboard.core_index.expand_aria"),Vs=!g,qs=y("dashboard.screenshot.title_line1"),Xs=y("dashboard.screenshot.title_line2");y("shared.placeholder.short");const Gs=h.useMemo(()=>g?[]:Ng,[g]),Ks=h.useMemo(()=>[{label:y("usage.metric.total"),value:Qe(St),valueClassName:"text-white"},{label:y("usage.metric.input"),value:Qe(ie?.input_tokens)},{label:y("usage.metric.output"),value:Qe(ie?.output_tokens)},{label:y("usage.metric.cached_input"),value:Qe(ie?.cached_input_tokens)},{label:y("usage.metric.reasoning_output"),value:Qe(ie?.reasoning_output_tokens)}],[ie?.cached_input_tokens,ie?.input_tokens,ie?.output_tokens,ie?.reasoning_output_tokens,St]),En=h.useMemo(()=>et(ie?.total_cost_usd,{currency:a,rate:r}),[ie?.total_cost_usd,a,r]),Qs=h.useMemo(()=>{if(Number(St||0)>0||ge||Fe)return null;const X=Number(me?.current_month?.totals?.billable_total_tokens||0),te=Number(me?.last_30d?.totals?.billable_total_tokens||0),ce=Number(me?.last_7d?.totals?.billable_total_tokens||0);return Y==="day"&&ce>0?y("dashboard.data_health.day_empty_has_recent",{tokens:Qe(ce)}):(Y==="week"||Y==="custom")&&te>0?y("dashboard.data_health.period_empty_has_30d",{tokens:Qe(te)}):Y==="month"&&X===0&&te>0?y("dashboard.data_health.month_empty_has_30d",{tokens:Qe(te)}):te===0&&me?y("dashboard.data_health.no_recent_data"):null},[Y,me,St,Fe,ge]),Ha=h.useMemo(()=>yo(Ue,{copyFn:y}),[Ue]),Js=h.useMemo(()=>kc(Ue,{copyFn:y}),[Ue]),Zs=h.useCallback(()=>l(!0),[]),ei=h.useCallback(()=>l(!1),[]),ti=En&&En!=="-"&&Ha.length>0,ni=y("dashboard.install.cmd.sync"),Wn=h.useMemo(()=>y("dashboard.daily.empty",{cmd:"{{cmd}}"}),[n]),[ai,ri]=h.useMemo(()=>{const S=Wn.split("{{cmd}}");return S.length===1?[Wn,""]:[S[0],S.slice(1).join("{{cmd}}")]},[Wn]);return h.useEffect(()=>{H.current||$n||(H.current=!0,t?.())},[t,$n]),o.jsxs(o.Fragment,{children:[o.jsx(Wc,{ingestHealth:u}),o.jsx(vg,{copy:y,screenshotMode:g,screenshotTitleLine1:qs,screenshotTitleLine2:Xs,identityDisplayName:Es,identityStartDate:Ws,activeDays:Ss,identitySubscriptions:As,identityScrambleDurationMs:p,projectUsageEntries:Bt,planPrices:de,onPlanPriceChange:Te,modelBreakdown:Ue,projectUnattributedSources:Ht,projectUsageLimit:le,setProjectUsageLimit:Ot,pulse:re,pulseComparedAtLabel:ee,isLocalMode:M,trendRowsForDisplay:ys,trendFromForDisplay:ps,trendToForDisplay:bs,trendZoomConfig:ls,usageFrom:oe,usageTo:ye,period:Y,trendTimeZoneLabel:G,activityHeatmapBlock:Fs,periodsForDisplay:Gs,setSelectedPeriod:Cs,autoRefreshOptions:as,autoRefreshIntervalMs:x,onAutoRefreshIntervalChange:Os,customFrom:pe,customTo:je,onCustomRangeApply:Ds,customRangeOpen:Ce,onCustomRangeOpenChange:Ts,metricsRows:Ks,summaryLabel:Is,summaryValue:Ls,summaryUpdatedAtLabel:zs,summaryCostValue:En,usageInsights:Js,costInfoEnabled:ti,openCostModal:Zs,allowBreakdownToggle:Vs,coreIndexCollapsed:b,setCoreIndexCollapsed:v,coreIndexCollapseLabel:Ys,coreIndexExpandLabel:Bs,coreIndexCollapseAria:Hs,coreIndexExpandAria:Us,refreshAll:Ps,usageLoadingState:$n,usageError:Fe,dataHealthMessage:Qs,rangeLabel:Rs,timeZoneRangeLabel:F,usageSourceLabel:$s,fleetData:Ha,usageLimits:Ut,limitDisplayMode:ds,hasDetailsActual:ms,dailyEmptyPrefix:ai,installSyncCmd:ni,dailyEmptySuffix:ri,detailsColumns:us,ariaSortFor:Ns,toggleSort:vs,sortIconFor:_s,pagedDetails:hs,dailyBreakdownRows:gs,dailyBreakdownColumns:fs,dailyBreakdownAriaSortFor:Ms,dailyBreakdownSortIconFor:js,dailyBreakdownDateKey:hn,detailsDateKey:Ge,renderDetailDate:ks,renderDailyBreakdownDate:ws,renderDetailCell:xs,DETAILS_PAGED_PERIODS:Kt,detailsPageCount:Pn,detailsPage:On,setDetailsPage:yn,costModalOpen:s,closeCostModal:ei})]})}export{Bg as DashboardPage};
|