tokentracker-cli 1.1.11 → 1.1.12

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.
Files changed (118) hide show
  1. package/README.md +2 -1
  2. package/dashboard/dist/assets/{AchievementBadge-DuEuFaXg.js → AchievementBadge-bxsSwozZ.js} +1 -1
  3. package/dashboard/dist/assets/{AchievementsPage-BTTFtk_Z.js → AchievementsPage-CCGsTNky.js} +2 -2
  4. package/dashboard/dist/assets/{AchievementsSection-BZppKteZ.js → AchievementsSection-a-ucN3O9.js} +1 -1
  5. package/dashboard/dist/assets/{BadgeDetailModal-TzmxXy8k.js → BadgeDetailModal-CNCCgDRL.js} +1 -1
  6. package/dashboard/dist/assets/BotAnimated-DYrmIQt7.js +1 -0
  7. package/dashboard/dist/assets/{Card-HigkIm_b.js → Card-615UteEP.js} +1 -1
  8. package/dashboard/dist/assets/{CommandPalette-Bx_11gJk.js → CommandPalette-BzmRKASJ.js} +1 -1
  9. package/dashboard/dist/assets/{CommunityStatsModal-BjDPCBol.js → CommunityStatsModal-DdRpM1bD.js} +1 -1
  10. package/dashboard/dist/assets/{ConfirmModal-DTo93RpG.js → ConfirmModal-BQIPBiA5.js} +1 -1
  11. package/dashboard/dist/assets/Controls-Cup1Mj2U.js +1 -0
  12. package/dashboard/dist/assets/DashboardPage-DF1bFyHx.js +1 -0
  13. package/dashboard/dist/assets/{DevicePage-BVupGt9K.js → DevicePage-CC31pv5N.js} +1 -1
  14. package/dashboard/dist/assets/{DialogClose-BlQJpi7n.js → DialogClose-CaYoc9xQ.js} +1 -1
  15. package/dashboard/dist/assets/DialogDescription-DZLOEWil.js +1 -0
  16. package/dashboard/dist/assets/{DialogTitle-CDmxp9ap.js → DialogTitle-BViOiFtR.js} +1 -1
  17. package/dashboard/dist/assets/{FadeIn-DPercU5n.js → FadeIn-BQYqxLXW.js} +1 -1
  18. package/dashboard/dist/assets/{HeaderGithubStar-DeVzeBIo.js → HeaderGithubStar-CpGwcrZV.js} +1 -1
  19. package/dashboard/dist/assets/{HoverTooltip-Duo2Icus.js → HoverTooltip--hTrUe1c.js} +1 -1
  20. package/dashboard/dist/assets/{IpCheckPage-DgYiaRrT.js → IpCheckPage-gPQntnIE.js} +1 -1
  21. package/dashboard/dist/assets/{LandingPage-CYTR4PbQ.js → LandingPage-Cw72oDTD.js} +2 -2
  22. package/dashboard/dist/assets/{LeaderboardAvatar-B67pMaIl.js → LeaderboardAvatar-CnqlbA5v.js} +1 -1
  23. package/dashboard/dist/assets/{LeaderboardPage-2wIMkBgq.js → LeaderboardPage-CvdG-SGy.js} +2 -2
  24. package/dashboard/dist/assets/{LeaderboardProfileModal-D3VxkFlx.js → LeaderboardProfileModal-CqzEW_FY.js} +4 -4
  25. package/dashboard/dist/assets/{LeaderboardProfilePage-BS01jN5M.js → LeaderboardProfilePage-DCjJ7yF3.js} +3 -3
  26. package/dashboard/dist/assets/{LimitsPage-BGRZW-aH.js → LimitsPage-DMGI3mL9.js} +2 -2
  27. package/dashboard/dist/assets/{LocalOnlyNotice-Do9KUdi_.js → LocalOnlyNotice-CpGpv1oF.js} +1 -1
  28. package/dashboard/dist/assets/{LoginCard-CzAXLXfZ.js → LoginCard-B5W06Jrz.js} +1 -1
  29. package/dashboard/dist/assets/{LoginModal-D1J8zG0C.js → LoginModal-B4Y8XRkn.js} +1 -1
  30. package/dashboard/dist/assets/{LoginPage-DeZJNMLe.js → LoginPage-BLN-PdCh.js} +1 -1
  31. package/dashboard/dist/assets/PetPage-BvY7fR8_.js +1 -0
  32. package/dashboard/dist/assets/{PopoverPopup-BYzzQJTD.js → PopoverPopup-C4_m01Pc.js} +1 -1
  33. package/dashboard/dist/assets/{ProviderIcon-BfFkS-OF.js → ProviderIcon-LgUYzw52.js} +1 -1
  34. package/dashboard/dist/assets/{ResetPasswordPage-BFyYvG24.js → ResetPasswordPage-Dgzafk9_.js} +1 -1
  35. package/dashboard/dist/assets/{SegmentedControl-D5USR3JT.js → SegmentedControl-CMWf089j.js} +1 -1
  36. package/dashboard/dist/assets/{Select-DmFQdVA1.js → Select-BNFp1Pww.js} +1 -1
  37. package/dashboard/dist/assets/{SelectItemText-B5MXGLN-.js → SelectItemText-Jz-4OEyW.js} +1 -1
  38. package/dashboard/dist/assets/{ServiceStatusPage-Dvm5eUJK.js → ServiceStatusPage-AEW89tSP.js} +1 -1
  39. package/dashboard/dist/assets/{SessionsPage-DQKezzUW.js → SessionsPage-DTW1sFcW.js} +2 -2
  40. package/dashboard/dist/assets/SettingsPage-2z_a9T_C.js +2 -0
  41. package/dashboard/dist/assets/{SkillsPage-DyX_-dcr.js → SkillsPage-BkPEwhXO.js} +1 -1
  42. package/dashboard/dist/assets/{TokenGalaxy-aK3jhWW0.js → TokenGalaxy-Cs5wfOxe.js} +1 -1
  43. package/dashboard/dist/assets/{ToolbarRootContext-CY_SULMC.js → ToolbarRootContext-B3pyxVI-.js} +1 -1
  44. package/dashboard/dist/assets/TrendMonitor-BmSRt3h3.js +19 -0
  45. package/dashboard/dist/assets/{WidgetsPage-D8tzK-7m.js → WidgetsPage-BN5ePVqf.js} +1 -1
  46. package/dashboard/dist/assets/{WrappedPage-BjZPa_al.js → WrappedPage-DZTG3lCh.js} +1 -1
  47. package/dashboard/dist/assets/__vite-browser-external-4IDwIR3i.js +45 -0
  48. package/dashboard/dist/assets/__vite-browser-external-CAQ_i-1v.css +1 -0
  49. package/dashboard/dist/assets/{agent-logos-QSoXRwwJ.js → agent-logos-DQmv0J3b.js} +1 -1
  50. package/dashboard/dist/assets/{arrow-up-right-C3WUmTcI.js → arrow-up-right-BbkRcWv3.js} +1 -1
  51. package/dashboard/dist/assets/{check-Gz5mnj6f.js → check-Dz72GL-k.js} +1 -1
  52. package/dashboard/dist/assets/{composite-DJhoahpv.js → composite-COAFYYB2.js} +1 -1
  53. package/dashboard/dist/assets/{copy-C5RiL5JQ.js → copy-wEl0WhF0.js} +1 -1
  54. package/dashboard/dist/assets/{download-CccMGCc1.js → download-W7dmHuLF.js} +1 -1
  55. package/dashboard/dist/assets/{external-link-fdU7Lj6p.js → external-link-B-pvBbFP.js} +1 -1
  56. package/dashboard/dist/assets/{flame-CYEjossP.js → flame-y6R5Plz2.js} +1 -1
  57. package/dashboard/dist/assets/{format-tokens-xXCznLkf.js → format-tokens-CkWutEDc.js} +1 -1
  58. package/dashboard/dist/assets/{icons-CYNYszil.js → icons-C_ECRc6a.js} +1 -1
  59. package/dashboard/dist/assets/{index-Czz7x_MZ.js → index-B1Am3t0P.js} +1 -1
  60. package/dashboard/dist/assets/{index-CQ5GHXiW.js → index-BzmW4EmI.js} +1 -1
  61. package/dashboard/dist/assets/{index-Cgfb050k.js → index-Dtl4UhBX.js} +1 -1
  62. package/dashboard/dist/assets/{info-Zae50fSC.js → info-CCfzQ-S6.js} +1 -1
  63. package/dashboard/dist/assets/{link-2-DW_mHLzI.js → link-2-DvFi_t5y.js} +1 -1
  64. package/dashboard/dist/assets/{loader-circle-Bl7dBXh1.js → loader-circle-BglSN88W.js} +1 -1
  65. package/dashboard/dist/assets/{maximize-2-DTP25Fl_.js → maximize-2-B7Nzrb8n.js} +1 -1
  66. package/dashboard/dist/assets/{modifiers.esm-CYXpOF3i.js → modifiers.esm-CsJhvsvC.js} +1 -1
  67. package/dashboard/dist/assets/{monitor-smartphone--TLNLuLe.js → monitor-smartphone-DpicOpX8.js} +1 -1
  68. package/dashboard/dist/assets/{plus-DgeFv3Xc.js → plus-C40ubjK3.js} +1 -1
  69. package/dashboard/dist/assets/{provider-display-crAVn3qa.js → provider-display-E2soZfeg.js} +2 -2
  70. package/dashboard/dist/assets/{react-QPulAuJP.js → react-BseCgHfW.js} +1 -1
  71. package/dashboard/dist/assets/{search-DIUmGfar.js → search-Bu5sWW2G.js} +1 -1
  72. package/dashboard/dist/assets/{skills-api-09qiTRNb.js → skills-api-BBF6YhPQ.js} +1 -1
  73. package/dashboard/dist/assets/skins-Mc0sI20C.js +1 -0
  74. package/dashboard/dist/assets/{sortable.esm-BbsbmOc2.js → sortable.esm-CLXvOgJi.js} +1 -1
  75. package/dashboard/dist/assets/{store-DdyzwTsy.js → store-DdObzMvx.js} +1 -1
  76. package/dashboard/dist/assets/{terminal-JpDnkjVA.js → terminal-CRqmFLSX.js} +1 -1
  77. package/dashboard/dist/assets/{trash-CRsyysiP.js → trash-Dknznc_u.js} +1 -1
  78. package/dashboard/dist/assets/{use-community-stats-D3PwUyvR.js → use-community-stats-ZvEm6sF4.js} +1 -1
  79. package/dashboard/dist/assets/{use-latest-request-guard-DTCniVRw.js → use-latest-request-guard-QHLPnnSW.js} +1 -1
  80. package/dashboard/dist/assets/{use-limits-display-prefs-BbYcvoh_.js → use-limits-display-prefs-CRg1sYpO.js} +1 -1
  81. package/dashboard/dist/assets/{use-ordered-list-ypqFhcs4.js → use-ordered-list-NpIo40Y4.js} +1 -1
  82. package/dashboard/dist/assets/use-pet-settings-BUroRCzh.js +2 -0
  83. package/dashboard/dist/assets/use-reduced-motion-CDg8lAbR.js +1 -0
  84. package/dashboard/dist/assets/{use-session-efficiency-pref-C5BZmpkY.js → use-session-efficiency-pref-aQVRBt9R.js} +1 -1
  85. package/dashboard/dist/assets/{use-transform-C3bGaC_U.js → use-transform-BP8NiCzk.js} +1 -1
  86. package/dashboard/dist/assets/use-usage-limits-CvIocz6v.js +1 -0
  87. package/dashboard/dist/assets/{useCurrency-BianRgdW.js → useCurrency-CyksuFrj.js} +1 -1
  88. package/dashboard/dist/assets/useTokenFormat-CUwCluPw.js +1 -0
  89. package/dashboard/dist/assets/{zap-BJTChg1t.js → zap-BcWplbpF.js} +1 -1
  90. package/dashboard/dist/index.html +2 -2
  91. package/dashboard/dist/ip-check.html +2 -2
  92. package/dashboard/dist/leaderboard.html +2 -2
  93. package/dashboard/dist/share.html +2 -2
  94. package/package.json +3 -2
  95. package/src/commands/sync.js +57 -29
  96. package/src/lib/claude-categorizer.js +4 -7
  97. package/src/lib/claude-user-identity.js +56 -0
  98. package/src/lib/cursor-store.js +636 -57
  99. package/src/lib/grok-limits.js +17 -4
  100. package/src/lib/kimi-profile.js +61 -0
  101. package/src/lib/multi-install-parser.js +3 -1
  102. package/src/lib/pricing/seed-snapshot.json +1 -1
  103. package/src/lib/rollout.js +91 -39
  104. package/src/lib/usage-limits.js +128 -79
  105. package/dashboard/dist/assets/BotAnimated-4hWTFjwp.js +0 -1
  106. package/dashboard/dist/assets/ClawdAnimated-BRoihVSd.js +0 -2
  107. package/dashboard/dist/assets/Controls-BvWTXyfI.js +0 -1
  108. package/dashboard/dist/assets/DashboardPage--1_GuEr-.js +0 -1
  109. package/dashboard/dist/assets/DialogDescription-DE2BF-HX.js +0 -1
  110. package/dashboard/dist/assets/PetPage-D2oqJ05F.js +0 -1
  111. package/dashboard/dist/assets/SettingsPage-DbUDye5r.js +0 -2
  112. package/dashboard/dist/assets/TrendMonitor-BH6Jx8nS.js +0 -19
  113. package/dashboard/dist/assets/__vite-browser-external-Bg0J-a5P.css +0 -1
  114. package/dashboard/dist/assets/__vite-browser-external-VmN0WaC3.js +0 -45
  115. package/dashboard/dist/assets/skins-C8EyB85e.js +0 -1
  116. package/dashboard/dist/assets/use-reduced-motion-Cdn1VrG0.js +0 -1
  117. package/dashboard/dist/assets/use-usage-limits-BRLNaZEv.js +0 -1
  118. package/dashboard/dist/assets/useTokenFormat-DO4vxqhW.js +0 -1
@@ -1 +1 @@
1
- import{b_ as yn,bf as He,aB as q,bk as In,c1 as qt,b$ as Cn,r as o,bj as Y,bF as St,cm as Lt,cn as gt,co as Dt,c4 as mt,bl as Ye,aS as ve,w as he,cp as Ht,bE as Nt,cq as Ge,aR as En,bu as Kt,c6 as Yt,cr as lt,cs as ct,ct as $t,cu as Ct,bi as tt,cb as vn,cv as Tn,cw as Rt,aC as Ne,bd as te,E as nt,j as ae,aK as Et,aE as bt,aD as wn,aH as Mn,aI as Pn,aJ as st,aT as An,c5 as On,aG as rt,bY as Fn,t as Gt,v as ke,cx as Vn,aP as Ln,cy as Dn,aQ as Hn,bn as Nn,cz as kn,aL as Xt,cA as ht}from"./__vite-browser-external-VmN0WaC3.js";import{r as Jt,F as Un,P as Bn,v as Ae,q as _n,E as jn,G as Ie,H as Qt,D as Wn,u as zn,a as Zt,f as qn,e as Kn,z as Yn,I as $n,d as Gn,b as Xn,C as Jn}from"./composite-DJhoahpv.js";import{h as Qn,u as Zn,a as er,d as tr,c as nr,e as rr,f as or,i as sr,p as ir,r as lr,g as cr}from"./ToolbarRootContext-CY_SULMC.js";function qe(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function ur(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,s=yn(),i=Jt()!=null,c=He(()=>new Un({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new Bn,floatingId:s,syncOnly:!1,nested:i})).current;return q(()=>{const f={open:t,floatingId:s};r.reference!==void 0&&(f.referenceElement=r.reference,f.domReferenceElement=In(r.reference)?r.reference:null),r.floating!==void 0&&(f.floatingElement=r.floating),c.update(f)},[t,s,r.reference,r.floating,c]),c.context.onOpenChange=n,c.context.nested=i,c}const ar="Escape";function kt(e){return Yt&&e.movementX===0&&e.movementY===0}function ut(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Xe(e,t){return ut(t,e===$t||e===Ct,e===lt||e===ct)}function xt(e,t,n){return ut(t,e===Ct,n?e===lt:e===ct)||e==="Enter"||e===" "||e===""}function fr(e,t,n){return ut(t,n?e===lt:e===ct,e===Ct)}function dr(e,t,n,r){const s=n?e===ct:e===lt,i=e===$t;return t==="both"||t==="horizontal"&&r?e===ar:ut(t,s,i)}function pr(e,t){const{listRef:n,activeIndex:r,onNavigate:s=()=>{},enabled:i=!0,selectedIndex:c=null,allowEscape:f=!1,loopFocus:l=!1,nested:C=!1,rtl:R=!1,virtual:x=!1,focusItemOnOpen:w="auto",focusItemOnHover:d=!0,openOnArrowKeyDown:F=!0,disabledIndices:A=void 0,orientation:E="vertical",parentOrientation:y,id:$,resetOnPointerLeave:V=!0,externalTree:g,grid:m}=t,O=m!=null,p="rootStore"in e?e.rootStore:e,S=p.useState("open"),k=p.useState("floatingElement"),D=p.useState("domReferenceElement"),G=p.context.dataRef,K=qt(k),h=Cn(D),L=Ae(K),z=Jt(),J=_n(g),W=o.useRef(w),v=o.useRef(c??-1),U=o.useRef(null),a=o.useRef(!0),I=Y(u=>{s(v.current===-1?null:v.current,u)}),M=o.useRef(!!k),P=o.useRef(S),H=o.useRef(!1),X=o.useRef(!1),ne=o.useRef(null),re=Ae(A),se=Ae(S),le=Ae(c),oe=Ae(V),fe=St(),B=St(),j=Y(()=>{function u(N){x?J?.events.emit("virtualfocus",N):ne.current=jn(N,{sync:H.current,preventScroll:!0})}const b=n.current[v.current],Z=X.current;b&&u(b),(H.current?N=>N():N=>fe.request(N))(()=>{const N=n.current[v.current]||b;if(!N)return;b||u(N),ue&&(Z||!a.current)&&N.scrollIntoView?.({block:"nearest",inline:"nearest"})})});q(()=>{G.current.orientation=E},[G,E]),q(()=>{i&&(S&&k?(v.current=c??-1,W.current&&c!=null&&(X.current=!0,I())):M.current&&(v.current=-1,I()))},[i,S,k,c,I]),q(()=>{if(i){if(!S){H.current=!1;return}if(k)if(r==null){if(H.current=!1,le.current!=null)return;if(M.current&&(v.current=-1,j()),(!P.current||!M.current)&&W.current&&(U.current!=null||W.current===!0&&U.current==null)){let u=0;const b=()=>{n.current[0]==null?(u<2&&(u?T=>B.request(T):queueMicrotask)(b),u+=1):(v.current=U.current==null||xt(U.current,E,R)||C?gt(n):Dt(n),U.current=null,I())};b()}}else Lt(n.current,r)||(v.current=r,j(),X.current=!1)}},[i,S,k,r,le,C,n,E,R,I,j,B]),q(()=>{if(!i||k||!J||x||!M.current)return;const u=J.nodesRef.current,b=u.find(N=>N.id===z)?.context?.elements.floating,Z=mt(Ye(D??b??null)),T=u.some(N=>N.context&&ve(N.context.elements.floating,Z));b&&!T&&a.current&&b.focus({preventScroll:!0})},[i,k,D,J,z,x]),q(()=>{P.current=S,M.current=!!k}),q(()=>{S||(U.current=null,W.current=w)},[S,w]);const ce=r!=null,Q=Y(u=>{if(!se.current)return;const b=n.current.indexOf(u.currentTarget);b!==-1&&(v.current!==b||r!==b)&&(v.current=b,I(u))}),pe=Y(()=>y??J?.nodesRef.current.find(u=>u.id===z)?.context?.dataRef?.current.orientation),xe=Y(()=>gt(n,re.current)),de=Y(u=>{if(a.current=!1,H.current=!0,u.which===229||!se.current&&u.currentTarget===L.current)return;if(C&&dr(u.key,E,R,O)){Xe(u.key,pe())||Ie(u),p.setOpen(!1,he(Ht,u.nativeEvent)),Nt(D)&&(x?J?.events.emit("virtualfocus",D):D.focus());return}const b=v.current,Z=gt(n,A),T=Dt(n,A);if(h||(u.key==="Home"&&(Ie(u),v.current=Z,I(u)),u.key==="End"&&(Ie(u),v.current=T,I(u))),m!=null){const N=m(u,v.current,n,E,l,R,A,Z,T);if(N!=null&&(v.current=N,I(u)),E==="both")return}if(Xe(u.key,E)){if(Ie(u),S&&!x&&mt(u.currentTarget.ownerDocument)===u.currentTarget){v.current=xt(u.key,E,R)?Z:T,I(u);return}xt(u.key,E,R)?l?b>=T?f&&b!==n.current.length?v.current=-1:(H.current=!1,v.current=Z):v.current=Ge(n.current,{startingIndex:b,disabledIndices:A}):v.current=Math.min(T,Ge(n.current,{startingIndex:b,disabledIndices:A})):l?b<=Z?f&&b!==-1?v.current=n.current.length:(H.current=!1,v.current=T):v.current=Ge(n.current,{startingIndex:b,decrement:!0,disabledIndices:A}):v.current=Math.max(Z,Ge(n.current,{startingIndex:b,decrement:!0,disabledIndices:A})),Lt(n.current,v.current)&&(v.current=-1),I(u)}}),ue=o.useMemo(()=>({onFocus(b){H.current=!0,Q(b)},onClick:({currentTarget:b})=>b.focus({preventScroll:!0}),onMouseMove(b){kt(b)||(H.current=!0,X.current=!1,d&&Q(b))},onPointerLeave(b){if(!se.current||!a.current||b.pointerType==="touch")return;H.current=!0;const Z=b.relatedTarget;if(!(!d||n.current.includes(Z))&&oe.current&&(ne.current?.(),ne.current=null,v.current=-1,I(b),!x)){const T=L.current,N=mt(Ye(T));T&&ve(T,N)&&T.focus({preventScroll:!0})}}}),[Q,se,L,d,n,I,oe,x]),ge=o.useMemo(()=>x&&S&&ce&&{"aria-activedescendant":`${$}-${r}`},[x,S,ce,$,r]),Se=o.useMemo(()=>({...h?{}:ge,onKeyDown(u){if(u.key==="Tab"&&u.shiftKey&&S&&!x){const b=En(u.nativeEvent);if(b&&!ve(L.current,b))return;Ie(u),p.setOpen(!1,he(Kt,u.nativeEvent)),Nt(D)&&D.focus();return}de(u)},onPointerMove(u){kt(u)||(a.current=!0)}}),[ge,de,L,h,p,S,x,D]),ee=o.useMemo(()=>{function u(T){p.setOpen(!0,he(Ht,T.nativeEvent,T.currentTarget))}function b(T){w==="auto"&&Qt(T.nativeEvent)&&(W.current=!x)}function Z(T){W.current=w,w==="auto"&&Wn(T.nativeEvent)&&(W.current=!0)}return{onKeyDown(T){const N=p.select("open");a.current=!1;const we=T.key.startsWith("Arrow"),Me=fr(T.key,pe(),R),be=Xe(T.key,E),Re=(C?Me:be)||T.key==="Enter"||T.key.trim()==="";if(x&&N)return de(T);if(!(!N&&!F&&we)){if(Re){const Ue=Xe(T.key,pe());U.current=C&&Ue?null:T.key}if(C){Me&&(Ie(T),N?(v.current=xe(),I(T)):u(T));return}be&&(le.current!=null&&(v.current=le.current),Ie(T),!N&&F?u(T):de(T),N&&I(T))}},onFocus(T){p.select("open")&&!x&&(v.current=-1,I(T))},onPointerDown:Z,onPointerEnter:Z,onMouseDown:b,onClick:b}},[de,w,xe,C,I,p,F,E,pe,R,le,x]),Te=o.useMemo(()=>({...ge,...ee}),[ge,ee]);return o.useMemo(()=>i?{reference:Te,floating:Se,item:ue,trigger:ee}:{},[i,Te,Se,ee,ue])}function gr(e,t){const{listRef:n,elementsRef:r,activeIndex:s,onMatch:i,disabledIndices:c,onTyping:f,enabled:l=!0,resetMs:C=750,selectedIndex:R=null}=t,x="rootStore"in e?e.rootStore:e,w=x.useState("open"),d=tt(),F=o.useRef(""),A=o.useRef(R??s??-1),E=o.useRef(null),y=Y(g=>{function m(L){return r?.current[L]}function O(L){const z=m(L);return z&&!vn(z)||z?.matches(":disabled")?!1:c==null||!Tn(Rt,L,c)}function p(L,z,J=0){if(L.length===0)return-1;const W=(J%L.length+L.length)%L.length,v=z.toLowerCase();for(let U=0;U<L.length;U+=1){const a=(W+U)%L.length;if(!(!L[a]?.toLowerCase().startsWith(v)||!O(a)))return a}return-1}const S=n.current;if(F.current.length>0&&g.key===" "&&(Ie(g),f?.(!0)),F.current.length>0&&F.current[0]!==" "&&p(S,F.current)===-1&&g.key!==" "&&f?.(!1),S==null||g.key.length!==1||g.ctrlKey||g.metaKey||g.altKey)return;w&&g.key!==" "&&(Ie(g),f?.(!0));const k=F.current==="";k&&(A.current=R??s??-1),S.every((L,z)=>L&&O(z)?L[0]?.toLowerCase()!==L[1]?.toLowerCase():!0)&&F.current===g.key&&(F.current="",A.current=E.current),F.current+=g.key,d.start(C,()=>{F.current="",A.current=E.current,f?.(!1)});const K=((k?R??s??-1:A.current)??0)+1,h=p(S,F.current,K);h!==-1?(i?.(h),E.current=h):g.key!==" "&&(F.current="",f?.(!1))}),$=Y(g=>{const m=g.relatedTarget,O=x.select("domReferenceElement"),p=x.select("floatingElement");ve(O,m)||ve(p,m)||(d.clear(),F.current="",A.current=E.current,f?.(!1))});q(()=>{!w&&R!==null||(d.clear(),E.current=null,F.current!==""&&(F.current=""))},[w,R,d]);const V=o.useMemo(()=>({onKeyDown:y,onBlur:$}),[y,$]);return o.useMemo(()=>l?{reference:V,floating:V}:{},[l,V])}function mr(e){const[t,n]=o.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}function hr(e){const t=o.useRef(!0);t.current&&(t.current=!1,e())}function xr(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function Ut({controlled:e,default:t,name:n,state:r="value"}){const{current:s}=o.useRef(e!==void 0),[i,c]=o.useState(t),f=s&&e!==void 0?e:i,l=o.useCallback(C=>{s||c(C)},[]);return[f,l]}const en=o.createContext(void 0),tn=o.createContext(void 0),nn=o.createContext(void 0);function Fe(){const e=o.useContext(en);if(e===void 0)throw new Error(Ne(60));return e}function vt(){const e=o.useContext(tn);if(e===void 0)throw new Error(Ne(101));return e}function rn(){const e=o.useContext(nn);if(e===void 0)throw new Error(Ne(61));return e}const Sr="data-valid",Rr="data-invalid",br={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},yr={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Ir={disabled:!1,...yr},Cr={valid(e){return e===null?null:e?{[Sr]:""}:{[Rr]:""}}},Er={invalid:void 0,name:void 0,validityData:{state:br,errors:[],error:"",value:"",initialValue:null},setValidityData:te,disabled:void 0,setTouched:te,setDirty:te,setFilled:te,setFocused:te,validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:Ir,registerFieldControl:te,validation:{getValidationProps:(e,t=nt)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:te,getInputControl:()=>null,commit:async()=>{},change:te}},vr=o.createContext(Er);function Tt(e=!0){const t=o.useContext(vr);if(t.setValidityData===te&&!e)throw new Error(Ne(28));return t}function Tr(e,t,n,r,s=!0,i){const{registerFieldControl:c}=Tt(),f=He(()=>Symbol());q(()=>{const l=f.current;if(!s){c(l,void 0);return}c(l,{controlRef:e,getValue:r,id:t,name:i,value:n})},[e,s,r,t,i,c,f,n]),q(()=>{const l=f.current;return()=>{c(l,void 0)}},[c,f])}const wr=o.createContext({controlId:void 0,registerControlId:te,resetControlId:te,labelId:void 0,setLabelId:te,messageIds:[],setMessageIds:te,getDescriptionProps:e=>e});function on(){return o.useContext(wr)}function sn(e={}){const{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:s,resetControlId:i}=on(),c=zn(),f=He(()=>Symbol()),l=o.useRef(!1),C=o.useRef(!1),R=Y(()=>{!l.current||s===te||(l.current=!1,s(f.current,void 0))});return q(()=>{if(!n||s===te){R();return}let x;if(t!==void 0)C.current=!0,x=t;else if(C.current)x=c;else{i();return}if(x===void 0){R();return}l.current=!0,s(f.current,x)},[t,n,s,i,c,f,R]),q(()=>R,[R]),(n?r:void 0)??t??c}function Mr(e,t,n=Object.is){const{length:r}=e;if(r!==t.length)return!1;for(let s=0;s<r;s+=1)if(!n(e[s],t[s]))return!1;return!0}const ln=(e,t)=>Object.is(e,t);function Oe(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Pr(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!Mr(e,t,(r,s)=>Oe(r,s,n)):e!==t}function yt(e,t,n){return e?e.some(r=>r===void 0?!1:Oe(t,r,n)):!1}function ot(e,t,n){return e?e.findIndex(r=>r===void 0?!1:Oe(r,t,n)):-1}function Ar(e,t){if(t!==ln)return r=>yt(e,r,t);const n=new Set(e);return n.delete(void 0),r=>n.has(r)&&(r!==0||e.some(s=>Object.is(r,s)))}function cn(e,t,n,r){const s=r&&Array.isArray(t)?e.findIndex(Ar(t,n)):ot(e,t,n);return s===-1?null:s}function Or(e,t,n,r,s,i){return yt(r,t,s)?i!=null&&e>i&&yt(r,n[i],s)?i:e:e===i?cn(n,r,s,!0):i}function Fr(e,t,n){return e.filter(r=>!Oe(t,r,n))}function It(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Vr(e){return typeof e=="object"&&e!=null&&Array.isArray(e.items)}function un(e){return Vr(e?.[0])}function Lr(e){return un(e)?e.flatMap(t=>t.items):e}function Dr(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(un(t)){for(const n of t)for(const r of n.items)if(r&&r.value==null&&r.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function an(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return It(e)}function De(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?It(e.value):It(e)}function fn(e,t,n){function r(){return an(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){const i=Lr(t);if(e==null||typeof e!="object"){const c=i.find(f=>f.value===e);return c&&c.label!=null?c.label:r()}if("value"in e){const c=i.find(f=>f&&f.value===e.value);if(c&&c.label!=null)return c.label}}return r()}function Hr(e,t,n){return e.reduce((r,s,i)=>(i>0&&r.push(", "),r.push(ae.jsx(o.Fragment,{children:fn(s,t,n)},i)),r),[])}const Nr={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{const{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:De(t,r)!==""},hasNullItemLabel:(e,t)=>t?Dr(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{const n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(s=>Oe(t,s,n)):Oe(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows},kr=o.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:te,validationMode:"onSubmit",submitCountRef:{current:0}});function Ur(){return o.useContext(kr)}const Ce=1;function dn(e,t){return Math.max(0,e-t)}function Br(e,t){if(t<=0)return 0;const n=qe(e,0,t),r=n,s=t-n,i=r<=Ce,c=s<=Ce;return i&&c?r<=s?0:t:i?0:c?t:n}function mo(e){const{id:t,value:n,defaultValue:r=null,onValueChange:s,open:i,defaultOpen:c=!1,onOpenChange:f,name:l,form:C,autoComplete:R,disabled:x=!1,readOnly:w=!1,required:d=!1,modal:F=!0,actionsRef:A,inputRef:E,onOpenChangeComplete:y,items:$,multiple:V=!1,itemToStringLabel:g,itemToStringValue:m,isItemEqualToValue:O=ln,highlightItemOnHover:p=!0,children:S}=e,{clearErrors:k}=Ur(),{setDirty:D,setTouched:G,setFocused:K,validityData:h,setFilled:L,name:z,disabled:J,validation:W,validationMode:v}=Tt(),U=sn({id:t}),a=J||x,I=z??l,[M,P]=Ut({controlled:n,default:V?r??Rt:r,name:"Select",state:"value"}),[H,X]=Ut({controlled:i,default:c,name:"Select",state:"open"}),ne=o.useRef([]),re=o.useRef([]),se=o.useRef(null),le=o.useRef(null),oe=o.useRef(0),fe=o.useRef(null),B=o.useRef([]),j=o.useRef(!1),ce=o.useRef(null),Q=o.useRef(null),pe=o.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),xe=o.useRef(!1),de=o.useRef(M),{mounted:ue,setMounted:ge,transitionStatus:Se}=Zt(H),{openMethod:ee,triggerProps:Te}=Qn(H),u=He(()=>new An({id:U,labelId:void 0,modal:F,multiple:V,itemToStringLabel:g,itemToStringValue:m,isItemEqualToValue:O,value:M,open:H,mounted:ue,transitionStatus:Se,items:$,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:nt,triggerProps:nt,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:te,setOpen:te,handleScrollArrowVisibility:te,onOpenChangeComplete:te,listRef:ne,popupRef:se,scrollHandlerRef:le,scrollArrowsMountedCountRef:oe,valueRef:fe,valuesRef:B,labelsRef:re,typingRef:j,selectionRef:pe,firstItemTextRef:ce,selectedItemTextRef:Q,alignItemWithTriggerActiveRef:xe,initialValueRef:de},Nr)).current,b=u.useState("activeIndex"),Z=u.useState("selectedIndex"),T=u.useState("triggerElement"),N=u.useState("positionerElement"),we=mr(ee),Me=ee??we,be=o.useMemo(()=>V?"":De(M,m),[V,M,m]),Re=o.useMemo(()=>V&&Array.isArray(M)?M.map(_=>De(_,m)):De(M,m),[V,M,m]),Ue=Ae(T),Be=Y(()=>Re);Tr(Ue,U,M,Be,!a,l);const _e=V?Array.isArray(M)&&M.length>0:M!=null&&be!=="";q(()=>{L(_e)},[_e,L]),q(function(){const ie=cn(B.current,M,O,V);ie===null&&(Q.current=null),!H&&u.set("selectedIndex",ie)},[V,H,M,O,u]),Zn(M,()=>{k(I),D(Pr(M,h.initialValue,O)),W.change(M)});const je=Y((_,ie)=>{f?.(_,ie),!ie.isCanceled&&(X(_),!_&&(ie.reason===Kt||ie.reason===On)&&(G(!0),K(!1),v==="onBlur"&&W.commit(M)))}),Ve=Y(()=>{ge(!1),u.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),y?.(!1)});Et({enabled:!A,open:H,ref:se,onComplete(){H||Ve()}}),o.useImperativeHandle(A,()=>({unmount:Ve}),[Ve]);const We=Y((_,ie)=>{s?.(_,ie),!ie.isCanceled&&P(_)}),at=Y(_=>{const ie=dn(_.scrollHeight,_.clientHeight),$e=Br(_.scrollTop,ie),ft=$e>0,ze=$e<ie;u.set("scrollUpArrowVisible",ft),u.set("scrollDownArrowVisible",ze)}),Pe=ur({open:H,onOpenChange:je,elements:{reference:T,floating:N}}),me=er(Pe,{enabled:!a,event:"mousedown"}),ye=qn(Pe),Ee=pr(Pe,{enabled:!a,listRef:ne,activeIndex:b,selectedIndex:Z,disabledIndices:Rt,onNavigate(_){_===null&&!H||u.set("activeIndex",_)},focusItemOnHover:p}),Le=gr(Pe,{enabled:!a&&(H||!w&&!V),listRef:re,activeIndex:b,selectedIndex:Z,disabledIndices:_=>xr(ne.current[_]),onMatch(_){H?u.set("activeIndex",_):We(B.current[_],he(st))},onTyping(_){j.current=_}}),Mt=o.useMemo(()=>bt(Le.reference,Ee.reference,ye.reference,me.reference,Te),[me.reference,Le.reference,Ee.reference,ye.reference,Te]),Pt=o.useMemo(()=>bt(Kn,Le.floating,Ee.floating,ye.floating),[Le.floating,Ee.floating,ye.floating]),At=Ee.item??nt;u.useContextCallback("setValue",We),u.useContextCallback("setOpen",je),u.useContextCallback("handleScrollArrowVisibility",at),u.useContextCallback("onOpenChangeComplete",y),hr(()=>{u.update({popupProps:Pt,triggerProps:Mt})}),u.useSyncedValues({id:U,modal:F,multiple:V,value:M,open:H,mounted:ue,transitionStatus:Se,popupProps:Pt,triggerProps:Mt,items:$,itemToStringLabel:g,itemToStringValue:m,isItemEqualToValue:O,openMethod:Me});const xn=o.useMemo(()=>({disabled:a,readOnly:w,required:d,multiple:V,highlightItemOnHover:p,itemProps:At}),[a,w,d,V,p,At]),Sn=wn(E,W.inputRef),Ot=V?void 0:I,Rn=o.useMemo(()=>!V||!Array.isArray(M)||!I?null:M.map(_=>{const ie=De(_,m);return ae.jsx("input",{type:"hidden",form:C,name:I,value:ie,disabled:a},ie)}),[V,M,C,I,m,a]);return ae.jsxs(en.Provider,{value:u,children:[ae.jsx(tn.Provider,{value:xn,children:ae.jsx(nn.Provider,{value:Pe,children:S})}),ae.jsx("input",{...W.getValidationProps(a,{onFocus(){u.state.triggerElement?.focus({focusVisible:!0})},onChange(_){if(_.nativeEvent.defaultPrevented||a||w)return;const ie=_.currentTarget.value,$e=he(st,_.nativeEvent);function ft(){if(V)return;const ze=ie.toLowerCase();let dt=B.current.findIndex(pt=>De(pt,m).toLowerCase()===ze||an(pt,g).toLowerCase()===ze);dt===-1&&(dt=B.current.findIndex((pt,bn)=>{const Vt=re.current[bn];return Vt!=null&&Vt.toLowerCase()===ze}));const Ft=B.current[dt];Ft!=null&&We(Ft,$e)}u.set("forceMount",!0),queueMicrotask(ft)}}),id:U&&Ot==null?`${U}-hidden-input`:void 0,form:C,name:Ot,autoComplete:R,value:be,disabled:a,required:d&&!(V&&_e),readOnly:w,ref:Sn,style:I?Mn:Pn,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Rn]})}function _r(e,t){return e??t}const Je=5;function jr(e,t){const n=Wr(t);return e.clientX>=n.left-Je&&e.clientX<=n.right+Je&&e.clientY>=n.top-Je&&e.clientY<=n.bottom+Je}function Wr(e){const t=e.getBoundingClientRect(),n=rt(e);if(Fn)return t;const r=n.getComputedStyle(e,"::before"),s=n.getComputedStyle(e,"::after");if(!(r.content!=="none"||s.content!=="none"))return t;const c=parseFloat(r.width)||0,f=parseFloat(r.height)||0,l=parseFloat(s.width)||0,C=parseFloat(s.height)||0,R=Math.max(t.width,c,l),x=Math.max(t.height,f,C),w=R-t.width,d=x-t.height;return{left:t.left-w/2,right:t.right+w/2,top:t.top-d/2,bottom:t.bottom+d/2}}const zr="data-popup-side",qr=400,Kr={...Yn,...Cr,popupSide:e=>e?{[zr]:e}:null,value:()=>null},ho=o.forwardRef(function(t,n){const{render:r,className:s,id:i,disabled:c=!1,nativeButton:f=!0,style:l,...C}=t,{setTouched:R,setFocused:x,validationMode:w,validation:d,state:F,disabled:A}=Tt(),{labelId:E}=on(),y=Fe(),{readOnly:$,required:V,disabled:g}=vt(),m=A||g||c,O=y.useState("open"),p=y.useState("mounted"),S=y.useState("value"),k=y.useState("triggerProps"),D=y.useState("positionerElement"),G=y.useState("listElement"),K=y.useState("popupSide"),h=y.useState("id"),L=y.useState("labelId"),z=y.useState("hasSelectedValue"),J=p&&D?K:null,W=i??h,v=_r(E,L);sn({id:i});const U=Ae(D),a=o.useRef(null),{getButtonProps:I,buttonRef:M}=Gt({disabled:m,native:f}),P=y.useStateSetter("triggerElement"),H=tt(),X=tt(),ne=tt();o.useEffect(()=>{if(O)return ne.start(qr,()=>{y.context.selectionRef.current.allowUnselectedMouseUp=!0,y.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{ne.clear()};y.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},X.clear()},[O,y,X,ne]);const re=bt(k,{id:W,role:"combobox","aria-expanded":O,"aria-haspopup":"listbox","aria-controls":O?G?.id??qt(D)?.id:void 0,"aria-labelledby":v,"aria-readonly":$||void 0,"aria-required":V||void 0,tabIndex:m?-1:0,onFocus(oe){x(!0),O&&y.context.alignItemWithTriggerActiveRef.current&&y.context.setOpen(!1,he(st,oe.nativeEvent)),H.start(0,()=>{y.set("forceMount",!0)})},onBlur(oe){ve(D,oe.relatedTarget)||(R(!0),x(!1),w==="onBlur"&&d.commit(S))},onMouseDown(oe){if(O)return;const fe=Ye(oe.currentTarget);function B(j){if(!a.current)return;const ce=j.target;ve(a.current,ce)||ve(U.current,ce)||jr(j,a.current)||y.context.setOpen(!1,he(Vn,j))}X.start(0,()=>{fe.addEventListener("mouseup",B,{once:!0})})}},C,I),se=d.getValidationProps(m,re);se.role="combobox";const le={...F,open:O,disabled:m,value:S,readOnly:$,popupSide:J,placeholder:!z};return ke("button",t,{ref:[n,a,M,P],state:le,stateAttributesMapping:Kr,props:se})}),Yr={value:()=>null},xo=o.forwardRef(function(t,n){const{className:r,render:s,children:i,placeholder:c,style:f,...l}=t,C=Fe(),R=C.useState("value"),x=C.useState("items"),w=C.useState("itemToStringLabel"),d=C.useState("hasSelectedValue"),F=!d&&c!=null&&i==null,A=C.useState("hasNullItemLabel",F),E={value:R,placeholder:!d};let y=null;return typeof i=="function"?y=i(R):i!=null?y=i:F&&!A?y=c:Array.isArray(R)?y=Hr(R,x,w):y=fn(R,x,w),ke("span",t,{state:E,ref:[n,C.context.valueRef],props:[{children:y},l],stateAttributesMapping:Yr})}),So=o.forwardRef(function(t,n){const r=Fe(),s=r.useState("mounted"),i=r.useState("forceMount");return s||i?ae.jsx(Ln,{ref:n,...t}):null}),pn=o.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function $r(){return o.useContext(pn)}function Gr(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:s}=e,i=Y(s),[,c]=o.useState(!1),f=He(Jr).current,l=He(Xr).current,C=o.useRef(0),R=o.useRef(!0),x=o.useRef(null),w=o.useRef(null),d=Y(()=>{R.current||(R.current=!0,c(m=>!m))}),F=Y((m,O)=>{l.set(m,O),d()}),A=Y(m=>{l.delete(m),d()}),E=Y(m=>{const O=new Map;return n.current.length=0,r&&(r.current.length=0),m.forEach(p=>{O.set(p.element,{...p.registration.metadata??{},index:p.index}),n.current[p.index]=p.element,r&&(r.current[p.index]=p.registration.label!==void 0?p.registration.label:p.registration.textRef?.current?.textContent??p.element.textContent)}),C.current=n.current.length,O});function y(m){if(w.current?.disconnect(),w.current=null,typeof MutationObserver!="function"||m.length<2)return;const O=new MutationObserver(S=>{if(!eo(S))return;let k=null;for(const D of m)if(D.isConnected){if(k&&gn(k,D)>0){O.disconnect(),d();return}k=D}});w.current=O;const p=new Set;for(let S=1;S<m.length;S+=1){const k=Zr(m[S-1],m[S]);k&&p.add(k)}p.forEach(S=>O.observe(S,{childList:!0}))}const $=Y(()=>{const[m,O]=Qr(l),p=E(m),S=x.current,k=!S||S.length!==m.length||m.some((D,G)=>{const K=S[G];return D.index!==K.index||D.element!==K.element||D.registration.index!==K.registration.index||D.registration.metadata!==K.registration.metadata});y(O),x.current=m,R.current=!1,k&&(f.forEach(D=>D(p)),i(p))});q(()=>(!R.current&&x.current&&E(x.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,E]),q(()=>{R.current&&$()}),q(()=>()=>{w.current?.disconnect(),R.current=!0},[]);const V=Y(m=>(f.add(m),()=>{f.delete(m)})),g=o.useMemo(()=>({register:F,unregister:A,subscribeMapChange:V,nextIndexRef:C}),[F,A,V,C]);return ae.jsx(pn.Provider,{value:g,children:t})}function Xr(){return new Map}function Jr(){return new Set}function Qr(e){const t=new Set,n=[],r=[];e.forEach((i,c)=>{if(!c.isConnected)return;const f=i.index,l={index:f??-1,element:c,registration:i};f===null?r.push(l):f>=0&&(t.add(f),n.push(l))});let s=0;return r.sort((i,c)=>gn(i.element,c.element)),r.forEach(i=>{for(;t.has(s);)s+=1;i.index=s,n.push(i),s+=1}),t.size>0&&n.sort((i,c)=>i.index-c.index),[n,r.map(i=>i.element)]}function Zr(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function eo(e){for(const t of e)for(let n=0;n<t.removedNodes.length;n+=1)if(t.removedNodes[n].isConnected)return!0;return!1}function gn(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}const mn=o.createContext(void 0);function to(){const e=o.useContext(mn);if(!e)throw new Error(Ne(59));return e}function it(e,t){e&&Object.assign(e.style,t)}const no={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},ro={position:"fixed"},Ro=o.forwardRef(function(t,n){const{anchor:r,className:s,render:i,positionMethod:c,side:f,align:l,sideOffset:C,alignOffset:R,collisionBoundary:x="clipping-ancestors",collisionPadding:w,arrowPadding:d,sticky:F,disableAnchorTracking:A,alignItemWithTrigger:E=!0,collisionAvoidance:y=Dn,style:$,...V}=t,g=Fe(),m=rn(),O=g.useState("open"),p=g.useState("mounted"),S=g.useState("modal"),k=g.useState("value"),D=g.useState("openMethod"),G=g.useState("positionerElement"),K=g.useState("triggerElement"),h=g.useState("isItemEqualToValue"),L=g.useState("transitionStatus"),z=o.useRef(null),J=o.useRef(null),[W,v]=o.useState(E),U=p&&W&&D!=="touch";!p&&W!==E&&v(E),o.useImperativeHandle(g.context.alignItemWithTriggerActiveRef,()=>U),tr((U||S)&&O,D==="touch",G,K);const a=nr({anchor:r,floatingRootContext:m,positionMethod:c,mounted:p,side:f,sideOffset:C,align:l,alignOffset:R,arrowPadding:d,collisionBoundary:x,collisionPadding:w,sticky:F,disableAnchorTracking:A??U,collisionAvoidance:y,keepMounted:!0}),I=U?"none":a.side,M=U?ro:a.positionerStyles,P={open:O,side:I,align:a.align,anchorHidden:a.anchorHidden};q(()=>{g.set("popupSide",a.side)},[g,a.side]);const H=g.useStateSetter("positionerElement"),X=rr(t,P,{styles:M,transitionStatus:L,props:V,refs:[n,H],hidden:!p,inert:!O}),ne=o.useRef(0),re=Y(le=>{if(g.context.valuesRef.current.length===0)return;const oe=ne.current;ne.current=le.size;const fe=he(st);if(oe!==0&&!g.state.multiple&&k!==null&&ot(g.context.valuesRef.current,k,h)===-1){const j=g.context.initialValueRef.current,Q=j!=null&&ot(g.context.valuesRef.current,j,h)!==-1?j:null;g.context.setValue(Q,fe),Q===null&&(g.set("selectedIndex",null),g.context.selectedItemTextRef.current=null)}if(oe!==0&&g.state.multiple&&Array.isArray(k)){const B=k.filter(j=>ot(g.context.valuesRef.current,j,h)!==-1);B.length!==k.length&&(g.context.setValue(B,fe),B.length===0&&(g.set("selectedIndex",null),g.context.selectedItemTextRef.current=null))}if(O&&U){g.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const B={height:""};it(G,B),it(g.context.popupRef.current,B)}}),se=o.useMemo(()=>({...a,side:I,alignItemWithTriggerActive:U,setControlledAlignItemWithTrigger:v,scrollUpArrowRef:z,scrollDownArrowRef:J}),[a,I,U,v]);return ae.jsx(Gr,{elementsRef:g.context.listRef,labelsRef:g.context.labelsRef,onMapChange:re,children:ae.jsxs(mn.Provider,{value:se,children:[p&&S&&ae.jsx($n,{inert:Hn(!O),cutout:K}),X]})})}),Qe="base-ui-disable-scrollbar",Bt={className:Qe,getElement(e){return ae.jsx("style",{nonce:e,href:Qe,precedence:"base-ui:low",children:`.${Qe}{scrollbar-width:none}.${Qe}::-webkit-scrollbar{display:none}`})}},oo=o.createContext(void 0),so={disableStyleElements:!1};function io(){return o.useContext(oo)??so}const _t="--transform-origin",lo={...Xn,...Xt},bo=o.forwardRef(function(t,n){const{render:r,className:s,style:i,finalFocus:c,...f}=t,l=Fe(),{multiple:C,readOnly:R,highlightItemOnHover:x}=vt(),w=rn(),{side:d,align:F,alignItemWithTriggerActive:A,isPositioned:E,setControlledAlignItemWithTrigger:y}=to(),$=or()!=null,V=sr(),{nonce:g,disableStyleElements:m}=io(),O=l.useState("id"),p=l.useState("open"),S=l.useState("openMethod"),k=l.useState("mounted"),D=l.useState("popupProps"),G=l.useState("transitionStatus"),K=l.useState("triggerElement"),h=l.useState("positionerElement"),L=l.useState("listElement"),z=o.useRef(!1),J=o.useRef(!1),W=o.useRef({}),v=St(),U=Y(P=>{if(!h||!l.context.popupRef.current||!J.current)return;const H=h.style.top==="0px",X=h.style.bottom==="0px";if(z.current||!A||!H&&!X){l.context.handleScrollArrowVisibility(P);return}const ne=Wt(h),re=Ke(h.getBoundingClientRect().height,"y",ne),se=Ye(h),le=rt(h),oe=le.getComputedStyle(h),fe=parseFloat(oe.marginTop),B=parseFloat(oe.marginBottom),j=jt(le.getComputedStyle(l.context.popupRef.current)),ce=Math.min(se.documentElement.clientHeight-fe-B,j),Q=P.scrollTop,pe=Ze(P);let xe=null;const de=ee=>{h.style.height=`${ee}px`},ue=H?pe-Q:Q,ge=Math.min(re+ue,ce);if(ue<=Ce){const ee=qe(ue,0,ce-re);ee>0&&de(re+ee),P.scrollTop=H?pe:0,ce-(re+ee)<=Ce&&(z.current=!0),l.context.handleScrollArrowVisibility(P);return}if(ce-ge>Ce)xe=H?1/0:0;else if(X&&Q<pe){const ee=re+ue-ce;xe=Q-(ue-ee)}const Se=Math.ceil(ge);if(Se!==0&&de(Se),xe!=null){const ee=qe(xe,0,Ze(P));Math.abs(P.scrollTop-ee)>Ce&&(P.scrollTop=ee)}Se>=ce-Ce&&(z.current=!0),l.context.handleScrollArrowVisibility(P)});o.useImperativeHandle(l.context.scrollHandlerRef,()=>U,[U]),Et({open:p,ref:l.context.popupRef,onComplete(){p&&l.context.onOpenChangeComplete(!0)}});const a={open:p,transitionStatus:G,side:d,align:F};q(()=>{!h||!l.context.popupRef.current||Object.keys(W.current).length||(W.current={top:h.style.top||"0",left:h.style.left||"0",right:h.style.right,height:h.style.height,bottom:h.style.bottom,minHeight:h.style.minHeight,maxHeight:h.style.maxHeight,marginTop:h.style.marginTop,marginBottom:h.style.marginBottom})},[l,h]),q(()=>{p||A||(J.current=!1,z.current=!1,it(h,W.current))},[p,A,h]),q(()=>{const P=l.context.popupRef.current;if(!p||!K||!h||!P||A&&!E||l.state.transitionStatus==="ending")return;if(J.current=!0,P.style.removeProperty(_t),!A){v.request(()=>l.context.handleScrollArrowVisibility(L||P));return}const H=co(P);try{let X=l.context.selectedItemTextRef.current;X?.isConnected||(X=!l.select("hasSelectedValue")&&l.context.firstItemTextRef.current?.isConnected?l.context.firstItemTextRef.current:null);const ne=l.context.valueRef.current,re=rt(h),se=re.getComputedStyle(h),le=re.getComputedStyle(P),oe=Ye(K),fe=Wt(K),B=et(K.getBoundingClientRect(),fe),j=et(h.getBoundingClientRect(),fe),ce=B.height,Q=L||P,pe=Q.scrollHeight,xe=parseFloat(le.borderBottomWidth),de=parseFloat(se.marginTop)||10,ue=parseFloat(se.marginBottom)||10,ge=parseFloat(se.minHeight)||100,Se=jt(le),ee=5,Te=5,u=20,b=oe.documentElement.clientHeight-de-ue,Z=oe.documentElement.clientWidth,T=b-B.bottom+ce;let N,we=V==="rtl"?B.right-j.width:B.left,Me=0;if(X&&ne){const me=et(ne.getBoundingClientRect(),fe);N=et(X.getBoundingClientRect(),fe),we=j.left+(V==="rtl"?me.right-N.right:me.left-N.left);const ye=me.top-B.top+me.height/2;Me=N.top-j.top+N.height/2-ye}const be=T+Me+ue+xe;let Re=Math.min(b,be);const Ue=b-de-ue,Be=be-Re,_e=Z-Te;h.style.left=`${qe(we,ee,_e-j.width)}px`,h.style.height=`${Re}px`,h.style.maxHeight="none",h.style.marginTop=`${de}px`,h.style.marginBottom=`${ue}px`,P.style.height="100%";const je=Ze(Q),Ve=Be>=je-Ce;Ve&&(Re=Math.min(b,j.height)-(Be-je));const We=B.top<u||B.bottom>b-u||Math.ceil(Re)+Ce<Math.min(pe,ge),at=(re.visualViewport?.scale??1)!==1&&Yt;if(We||at){it(h,W.current),y(!1);return}const Pe=Math.max(ge,Re);if(Ve){const me=Math.max(0,b-be);h.style.top=j.height>=Ue?"0":`${me}px`,h.style.height=`${Re}px`,Q.scrollTop=Ze(Q)}else h.style.bottom="0",Q.scrollTop=Be;if(N){const me=j.top,ye=j.height,Ee=N.top+N.height/2,Le=qe(ye>0?(Ee-me)/ye*100:50,0,100);P.style.setProperty(_t,`50% ${Le}%`)}(Pe===b||Re>=Se)&&(z.current=!0),l.context.handleScrollArrowVisibility(Q),x&&l.state.selectedIndex===null&&l.state.activeIndex===null&&l.context.listRef.current[0]!=null&&l.set("activeIndex",0)}finally{H()}},[l,p,h,K,A,y,v,L,x,V,E]),o.useEffect(()=>{if(!A||!h||!p)return;const P=rt(h);function H(X){l.context.setOpen(!1,he(kn,X))}return Nn(P,"resize",H)},[l,A,h,p]);const I={...L?{role:"presentation"}:{role:"listbox","aria-multiselectable":C||void 0,"aria-readonly":R||void 0,id:`${O}-list`},onKeyDown(P){$&&Jn.has(P.key)&&P.stopPropagation()},onScroll(P){L||U(P.currentTarget)},...A&&{style:L?{height:"100%"}:no},className:!L&&A?Bt.className:void 0},M=ke("div",t,{ref:[n,l.context.popupRef],state:a,stateAttributesMapping:lo,props:[D,I,cr(G),f]});return ae.jsxs(o.Fragment,{children:[!m&&Bt.getElement(g),ae.jsx(Gn,{context:w,modal:!1,disabled:!k,openInteractionType:S,returnFocus:c,restoreFocus:!0,children:M})]})});function jt(e){const t=e.maxHeight;return t.endsWith("px")&&parseFloat(t)||1/0}function Ze(e){return dn(e.scrollHeight,e.clientHeight)}function Wt(e){return ir.getScale(e)}function Ke(e,t,n){return e/n[t]}function et(e,t){return lr({x:Ke(e.x,"x",t),y:Ke(e.y,"y",t),width:Ke(e.width,"x",t),height:Ke(e.height,"y",t)})}const zt=[["transform","none"],["scale","1"],["translate","0 0"]];function co(e){const{style:t}=e,n={};for(const[r,s]of zt)n[r]=t.getPropertyValue(r),t.setProperty(r,s,"important");return()=>{for(const[r]of zt){const s=n[r];s?t.setProperty(r,s):t.removeProperty(r)}}}function uo(e={}){const{guess:t,label:n,metadata:r,textRef:s,index:i}=e,{register:c,unregister:f,subscribeMapChange:l,nextIndexRef:C}=$r(),R=o.useRef(-1),[x,w]=o.useState(i==null&&t?()=>{if(R.current===-1){const E=C.current;C.current+=1,R.current=E}return R.current}:-1),d=i??x,F=o.useRef(null),A=o.useCallback(E=>{const y=F.current;y&&f(y),F.current=E,E&&c(E,{metadata:r??null,index:i??null,label:n,textRef:s})},[i,c,f,r,n,s]);return q(()=>{if(i==null)return l(E=>{const y=F.current?E.get(F.current)?.index:null;y!=null&&w(y)})},[i,l]),{ref:A,index:d}}const hn=o.createContext(void 0);function wt(){const e=o.useContext(hn);if(!e)throw new Error(Ne(57));return e}const yo=o.memo(o.forwardRef(function(t,n){const{render:r,className:s,style:i,value:c=null,label:f,disabled:l=!1,nativeButton:C=!1,...R}=t,x=o.useRef(null),w=uo({guess:!0,label:f,textRef:x}),d=Fe(),{itemProps:F,multiple:A,disabled:E,readOnly:y}=vt(),$=E||l,V=d.useState("isActive",w.index),g=d.useState("open"),m=d.useState("isSelected",c),O=d.useState("isSelectedByFocus",w.index),p=d.useState("isItemEqualToValue"),S=w.index,k=o.useRef(null);q(()=>{const a=d.context.valuesRef.current;return a[S]=c,()=>{delete a[S]}},[S,c,d]),q(()=>{const a=d.state.value,I=d.state.selectedIndex;let M=I,P;A&&Array.isArray(a)?(M=Or(S,c,d.context.valuesRef.current,a,p,I),P=M===S,S===I&&!P&&(d.context.selectedItemTextRef.current=null)):(P=a!==void 0&&Oe(c,a,p),P&&(M=S)),d.set("selectedIndex",M),P&&x.current&&(d.context.selectedItemTextRef.current=x.current)},[S,A,p,d,c]);const D=o.useRef("mouse"),G=o.useRef(!1),{getButtonProps:K,buttonRef:h}=Gt({disabled:$,focusableWhenDisabled:!0,native:C,composite:!0}),L={disabled:$,selected:m,highlighted:V};function z(a){if(E||y)return;const I=d.state.value;if(A){const M=Array.isArray(I)?I:[],P=m?Fr(M,c,p):[...M,c];d.context.setValue(P,he(ht,a))}else d.context.setValue(c,he(ht,a)),d.context.setOpen(!1,he(ht,a))}function J(){d.context.selectionRef.current.dragY=0}const W={role:"option","aria-selected":m,tabIndex:g&&V?0:-1,onKeyDown(a){d.set("activeIndex",S),a.key===" "&&d.context.typingRef.current&&a.preventDefault()},onClick(a){const I=D.current!=="touch",M=a.nativeEvent.pointerType,P=I&&Qt(a.nativeEvent)&&(M!==void 0||V),H=I&&!P&&!G.current;G.current=!1,!($||H)&&z(a.nativeEvent)},onPointerEnter(a){D.current=a.pointerType},onPointerMove(a){if(a.pointerType==="mouse"&&a.buttons===1){const I=d.context.selectionRef.current;I.dragY+=a.movementY,I.dragY**2>=64&&(I.allowUnselectedMouseUp=!0)}},onPointerDown(a){D.current=a.pointerType,G.current=!0,J()},onMouseUp(){if(J(),$||D.current==="touch"||G.current)return;const a=!d.context.selectionRef.current.allowSelectedMouseUp&&m,I=!d.context.selectionRef.current.allowUnselectedMouseUp&&!m;a||I||(G.current=!0,k.current?.click(),G.current=!1)}},v=ke("div",t,{ref:[h,n,w.ref,k],state:L,props:[F,W,R,K]}),U=o.useMemo(()=>({selected:m,index:S,textRef:x,selectedByFocus:O}),[m,S,x,O]);return ae.jsx(hn.Provider,{value:U,children:v})})),Io=o.forwardRef(function(t,n){const{selected:r}=wt();return t.keepMounted||r?ae.jsx(ao,{...t,ref:n}):null}),ao=o.memo(o.forwardRef((e,t)=>{const{render:n,className:r,style:s,keepMounted:i,...c}=e,{selected:f}=wt(),l=o.useRef(null),{transitionStatus:C,setMounted:R}=Zt(f),w=ke("span",e,{ref:[t,l],state:{selected:f,transitionStatus:C},props:[{"aria-hidden":!0,children:"✔️"},c],stateAttributesMapping:Xt});return Et({batch:!0,enabled:!f,open:f,ref:l,onComplete(){f||R(!1)}}),w})),Co=o.memo(o.forwardRef(function(t,n){const{index:r,textRef:s,selectedByFocus:i}=wt(),c=Fe(),{render:f,className:l,style:C,...R}=t,x=o.useCallback(d=>{d&&(r===0&&(c.context.firstItemTextRef.current=d),i&&(c.context.selectedItemTextRef.current=d))},[c,r,i]);return ke("div",t,{ref:[x,n,s],props:R})}));export{no as L,mo as S,vt as a,to as b,ho as c,xo as d,So as e,Ro as f,bo as g,yo as h,Io as i,Co as j,Cr as k,Ur as l,Tt as m,on as n,sn as o,Ut as p,Tr as q,Bt as s,Fe as u};
1
+ import{c0 as yn,bh as He,aD as q,bm as In,c3 as qt,c1 as Cn,r as o,bl as Y,bH as St,co as Lt,cp as gt,cq as Dt,c6 as mt,bn as Ye,aU as ve,x as he,cr as Ht,bG as Nt,cs as Ge,aT as En,bw as Kt,c8 as Yt,ct as lt,cu as ct,cv as $t,cw as Ct,bk as tt,cd as vn,cx as wn,cy as Rt,aE as Ne,bf as te,E as nt,j as ae,aM as Et,aG as bt,aF as Tn,aJ as Mn,aK as Pn,aL as st,aV as An,c7 as On,aI as rt,b_ as Vn,v as Gt,w as ke,cz as Fn,aR as Ln,cA as Dn,aS as Hn,bp as Nn,cB as kn,aN as Xt,cC as ht}from"./__vite-browser-external-4IDwIR3i.js";import{r as Jt,F as Un,P as Bn,v as Ae,q as _n,E as jn,G as Ie,H as Qt,D as Wn,u as zn,a as Zt,f as qn,e as Kn,z as Yn,I as $n,d as Gn,b as Xn,C as Jn}from"./composite-COAFYYB2.js";import{h as Qn,u as Zn,a as er,d as tr,c as nr,e as rr,f as or,i as sr,p as ir,r as lr,g as cr}from"./ToolbarRootContext-B3pyxVI-.js";function qe(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function ur(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,s=yn(),i=Jt()!=null,c=He(()=>new Un({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new Bn,floatingId:s,syncOnly:!1,nested:i})).current;return q(()=>{const f={open:t,floatingId:s};r.reference!==void 0&&(f.referenceElement=r.reference,f.domReferenceElement=In(r.reference)?r.reference:null),r.floating!==void 0&&(f.floatingElement=r.floating),c.update(f)},[t,s,r.reference,r.floating,c]),c.context.onOpenChange=n,c.context.nested=i,c}const ar="Escape";function kt(e){return Yt&&e.movementX===0&&e.movementY===0}function ut(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Xe(e,t){return ut(t,e===$t||e===Ct,e===lt||e===ct)}function xt(e,t,n){return ut(t,e===Ct,n?e===lt:e===ct)||e==="Enter"||e===" "||e===""}function fr(e,t,n){return ut(t,n?e===lt:e===ct,e===Ct)}function dr(e,t,n,r){const s=n?e===ct:e===lt,i=e===$t;return t==="both"||t==="horizontal"&&r?e===ar:ut(t,s,i)}function pr(e,t){const{listRef:n,activeIndex:r,onNavigate:s=()=>{},enabled:i=!0,selectedIndex:c=null,allowEscape:f=!1,loopFocus:l=!1,nested:C=!1,rtl:R=!1,virtual:x=!1,focusItemOnOpen:T="auto",focusItemOnHover:d=!0,openOnArrowKeyDown:V=!0,disabledIndices:A=void 0,orientation:E="vertical",parentOrientation:y,id:$,resetOnPointerLeave:F=!0,externalTree:g,grid:m}=t,O=m!=null,p="rootStore"in e?e.rootStore:e,S=p.useState("open"),k=p.useState("floatingElement"),D=p.useState("domReferenceElement"),G=p.context.dataRef,K=qt(k),h=Cn(D),L=Ae(K),z=Jt(),J=_n(g),W=o.useRef(T),v=o.useRef(c??-1),U=o.useRef(null),a=o.useRef(!0),I=Y(u=>{s(v.current===-1?null:v.current,u)}),M=o.useRef(!!k),P=o.useRef(S),H=o.useRef(!1),X=o.useRef(!1),ne=o.useRef(null),re=Ae(A),se=Ae(S),le=Ae(c),oe=Ae(F),fe=St(),B=St(),j=Y(()=>{function u(N){x?J?.events.emit("virtualfocus",N):ne.current=jn(N,{sync:H.current,preventScroll:!0})}const b=n.current[v.current],Z=X.current;b&&u(b),(H.current?N=>N():N=>fe.request(N))(()=>{const N=n.current[v.current]||b;if(!N)return;b||u(N),ue&&(Z||!a.current)&&N.scrollIntoView?.({block:"nearest",inline:"nearest"})})});q(()=>{G.current.orientation=E},[G,E]),q(()=>{i&&(S&&k?(v.current=c??-1,W.current&&c!=null&&(X.current=!0,I())):M.current&&(v.current=-1,I()))},[i,S,k,c,I]),q(()=>{if(i){if(!S){H.current=!1;return}if(k)if(r==null){if(H.current=!1,le.current!=null)return;if(M.current&&(v.current=-1,j()),(!P.current||!M.current)&&W.current&&(U.current!=null||W.current===!0&&U.current==null)){let u=0;const b=()=>{n.current[0]==null?(u<2&&(u?w=>B.request(w):queueMicrotask)(b),u+=1):(v.current=U.current==null||xt(U.current,E,R)||C?gt(n):Dt(n),U.current=null,I())};b()}}else Lt(n.current,r)||(v.current=r,j(),X.current=!1)}},[i,S,k,r,le,C,n,E,R,I,j,B]),q(()=>{if(!i||k||!J||x||!M.current)return;const u=J.nodesRef.current,b=u.find(N=>N.id===z)?.context?.elements.floating,Z=mt(Ye(D??b??null)),w=u.some(N=>N.context&&ve(N.context.elements.floating,Z));b&&!w&&a.current&&b.focus({preventScroll:!0})},[i,k,D,J,z,x]),q(()=>{P.current=S,M.current=!!k}),q(()=>{S||(U.current=null,W.current=T)},[S,T]);const ce=r!=null,Q=Y(u=>{if(!se.current)return;const b=n.current.indexOf(u.currentTarget);b!==-1&&(v.current!==b||r!==b)&&(v.current=b,I(u))}),pe=Y(()=>y??J?.nodesRef.current.find(u=>u.id===z)?.context?.dataRef?.current.orientation),xe=Y(()=>gt(n,re.current)),de=Y(u=>{if(a.current=!1,H.current=!0,u.which===229||!se.current&&u.currentTarget===L.current)return;if(C&&dr(u.key,E,R,O)){Xe(u.key,pe())||Ie(u),p.setOpen(!1,he(Ht,u.nativeEvent)),Nt(D)&&(x?J?.events.emit("virtualfocus",D):D.focus());return}const b=v.current,Z=gt(n,A),w=Dt(n,A);if(h||(u.key==="Home"&&(Ie(u),v.current=Z,I(u)),u.key==="End"&&(Ie(u),v.current=w,I(u))),m!=null){const N=m(u,v.current,n,E,l,R,A,Z,w);if(N!=null&&(v.current=N,I(u)),E==="both")return}if(Xe(u.key,E)){if(Ie(u),S&&!x&&mt(u.currentTarget.ownerDocument)===u.currentTarget){v.current=xt(u.key,E,R)?Z:w,I(u);return}xt(u.key,E,R)?l?b>=w?f&&b!==n.current.length?v.current=-1:(H.current=!1,v.current=Z):v.current=Ge(n.current,{startingIndex:b,disabledIndices:A}):v.current=Math.min(w,Ge(n.current,{startingIndex:b,disabledIndices:A})):l?b<=Z?f&&b!==-1?v.current=n.current.length:(H.current=!1,v.current=w):v.current=Ge(n.current,{startingIndex:b,decrement:!0,disabledIndices:A}):v.current=Math.max(Z,Ge(n.current,{startingIndex:b,decrement:!0,disabledIndices:A})),Lt(n.current,v.current)&&(v.current=-1),I(u)}}),ue=o.useMemo(()=>({onFocus(b){H.current=!0,Q(b)},onClick:({currentTarget:b})=>b.focus({preventScroll:!0}),onMouseMove(b){kt(b)||(H.current=!0,X.current=!1,d&&Q(b))},onPointerLeave(b){if(!se.current||!a.current||b.pointerType==="touch")return;H.current=!0;const Z=b.relatedTarget;if(!(!d||n.current.includes(Z))&&oe.current&&(ne.current?.(),ne.current=null,v.current=-1,I(b),!x)){const w=L.current,N=mt(Ye(w));w&&ve(w,N)&&w.focus({preventScroll:!0})}}}),[Q,se,L,d,n,I,oe,x]),ge=o.useMemo(()=>x&&S&&ce&&{"aria-activedescendant":`${$}-${r}`},[x,S,ce,$,r]),Se=o.useMemo(()=>({...h?{}:ge,onKeyDown(u){if(u.key==="Tab"&&u.shiftKey&&S&&!x){const b=En(u.nativeEvent);if(b&&!ve(L.current,b))return;Ie(u),p.setOpen(!1,he(Kt,u.nativeEvent)),Nt(D)&&D.focus();return}de(u)},onPointerMove(u){kt(u)||(a.current=!0)}}),[ge,de,L,h,p,S,x,D]),ee=o.useMemo(()=>{function u(w){p.setOpen(!0,he(Ht,w.nativeEvent,w.currentTarget))}function b(w){T==="auto"&&Qt(w.nativeEvent)&&(W.current=!x)}function Z(w){W.current=T,T==="auto"&&Wn(w.nativeEvent)&&(W.current=!0)}return{onKeyDown(w){const N=p.select("open");a.current=!1;const Te=w.key.startsWith("Arrow"),Me=fr(w.key,pe(),R),be=Xe(w.key,E),Re=(C?Me:be)||w.key==="Enter"||w.key.trim()==="";if(x&&N)return de(w);if(!(!N&&!V&&Te)){if(Re){const Ue=Xe(w.key,pe());U.current=C&&Ue?null:w.key}if(C){Me&&(Ie(w),N?(v.current=xe(),I(w)):u(w));return}be&&(le.current!=null&&(v.current=le.current),Ie(w),!N&&V?u(w):de(w),N&&I(w))}},onFocus(w){p.select("open")&&!x&&(v.current=-1,I(w))},onPointerDown:Z,onPointerEnter:Z,onMouseDown:b,onClick:b}},[de,T,xe,C,I,p,V,E,pe,R,le,x]),we=o.useMemo(()=>({...ge,...ee}),[ge,ee]);return o.useMemo(()=>i?{reference:we,floating:Se,item:ue,trigger:ee}:{},[i,we,Se,ee,ue])}function gr(e,t){const{listRef:n,elementsRef:r,activeIndex:s,onMatch:i,disabledIndices:c,onTyping:f,enabled:l=!0,resetMs:C=750,selectedIndex:R=null}=t,x="rootStore"in e?e.rootStore:e,T=x.useState("open"),d=tt(),V=o.useRef(""),A=o.useRef(R??s??-1),E=o.useRef(null),y=Y(g=>{function m(L){return r?.current[L]}function O(L){const z=m(L);return z&&!vn(z)||z?.matches(":disabled")?!1:c==null||!wn(Rt,L,c)}function p(L,z,J=0){if(L.length===0)return-1;const W=(J%L.length+L.length)%L.length,v=z.toLowerCase();for(let U=0;U<L.length;U+=1){const a=(W+U)%L.length;if(!(!L[a]?.toLowerCase().startsWith(v)||!O(a)))return a}return-1}const S=n.current;if(V.current.length>0&&g.key===" "&&(Ie(g),f?.(!0)),V.current.length>0&&V.current[0]!==" "&&p(S,V.current)===-1&&g.key!==" "&&f?.(!1),S==null||g.key.length!==1||g.ctrlKey||g.metaKey||g.altKey)return;T&&g.key!==" "&&(Ie(g),f?.(!0));const k=V.current==="";k&&(A.current=R??s??-1),S.every((L,z)=>L&&O(z)?L[0]?.toLowerCase()!==L[1]?.toLowerCase():!0)&&V.current===g.key&&(V.current="",A.current=E.current),V.current+=g.key,d.start(C,()=>{V.current="",A.current=E.current,f?.(!1)});const K=((k?R??s??-1:A.current)??0)+1,h=p(S,V.current,K);h!==-1?(i?.(h),E.current=h):g.key!==" "&&(V.current="",f?.(!1))}),$=Y(g=>{const m=g.relatedTarget,O=x.select("domReferenceElement"),p=x.select("floatingElement");ve(O,m)||ve(p,m)||(d.clear(),V.current="",A.current=E.current,f?.(!1))});q(()=>{!T&&R!==null||(d.clear(),E.current=null,V.current!==""&&(V.current=""))},[T,R,d]);const F=o.useMemo(()=>({onKeyDown:y,onBlur:$}),[y,$]);return o.useMemo(()=>l?{reference:F,floating:F}:{},[l,F])}function mr(e){const[t,n]=o.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}function hr(e){const t=o.useRef(!0);t.current&&(t.current=!1,e())}function xr(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function Ut({controlled:e,default:t,name:n,state:r="value"}){const{current:s}=o.useRef(e!==void 0),[i,c]=o.useState(t),f=s&&e!==void 0?e:i,l=o.useCallback(C=>{s||c(C)},[]);return[f,l]}const en=o.createContext(void 0),tn=o.createContext(void 0),nn=o.createContext(void 0);function Ve(){const e=o.useContext(en);if(e===void 0)throw new Error(Ne(60));return e}function vt(){const e=o.useContext(tn);if(e===void 0)throw new Error(Ne(101));return e}function rn(){const e=o.useContext(nn);if(e===void 0)throw new Error(Ne(61));return e}const Sr="data-valid",Rr="data-invalid",br={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},yr={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Ir={disabled:!1,...yr},Cr={valid(e){return e===null?null:e?{[Sr]:""}:{[Rr]:""}}},Er={invalid:void 0,name:void 0,validityData:{state:br,errors:[],error:"",value:"",initialValue:null},setValidityData:te,disabled:void 0,setTouched:te,setDirty:te,setFilled:te,setFocused:te,validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:Ir,registerFieldControl:te,validation:{getValidationProps:(e,t=nt)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:te,getInputControl:()=>null,commit:async()=>{},change:te}},vr=o.createContext(Er);function wt(e=!0){const t=o.useContext(vr);if(t.setValidityData===te&&!e)throw new Error(Ne(28));return t}function wr(e,t,n,r,s=!0,i){const{registerFieldControl:c}=wt(),f=He(()=>Symbol());q(()=>{const l=f.current;if(!s){c(l,void 0);return}c(l,{controlRef:e,getValue:r,id:t,name:i,value:n})},[e,s,r,t,i,c,f,n]),q(()=>{const l=f.current;return()=>{c(l,void 0)}},[c,f])}const Tr=o.createContext({controlId:void 0,registerControlId:te,resetControlId:te,labelId:void 0,setLabelId:te,messageIds:[],setMessageIds:te,getDescriptionProps:e=>e});function on(){return o.useContext(Tr)}function sn(e={}){const{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:s,resetControlId:i}=on(),c=zn(),f=He(()=>Symbol()),l=o.useRef(!1),C=o.useRef(!1),R=Y(()=>{!l.current||s===te||(l.current=!1,s(f.current,void 0))});return q(()=>{if(!n||s===te){R();return}let x;if(t!==void 0)C.current=!0,x=t;else if(C.current)x=c;else{i();return}if(x===void 0){R();return}l.current=!0,s(f.current,x)},[t,n,s,i,c,f,R]),q(()=>R,[R]),(n?r:void 0)??t??c}function Mr(e,t,n=Object.is){const{length:r}=e;if(r!==t.length)return!1;for(let s=0;s<r;s+=1)if(!n(e[s],t[s]))return!1;return!0}const ln=(e,t)=>Object.is(e,t);function Oe(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Pr(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!Mr(e,t,(r,s)=>Oe(r,s,n)):e!==t}function yt(e,t,n){return e?e.some(r=>r===void 0?!1:Oe(t,r,n)):!1}function ot(e,t,n){return e?e.findIndex(r=>r===void 0?!1:Oe(r,t,n)):-1}function Ar(e,t){if(t!==ln)return r=>yt(e,r,t);const n=new Set(e);return n.delete(void 0),r=>n.has(r)&&(r!==0||e.some(s=>Object.is(r,s)))}function cn(e,t,n,r){const s=r&&Array.isArray(t)?e.findIndex(Ar(t,n)):ot(e,t,n);return s===-1?null:s}function Or(e,t,n,r,s,i){return yt(r,t,s)?i!=null&&e>i&&yt(r,n[i],s)?i:e:e===i?cn(n,r,s,!0):i}function Vr(e,t,n){return e.filter(r=>!Oe(t,r,n))}function It(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Fr(e){return typeof e=="object"&&e!=null&&Array.isArray(e.items)}function un(e){return Fr(e?.[0])}function Lr(e){return un(e)?e.flatMap(t=>t.items):e}function Dr(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(un(t)){for(const n of t)for(const r of n.items)if(r&&r.value==null&&r.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function an(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return It(e)}function De(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?It(e.value):It(e)}function fn(e,t,n){function r(){return an(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){const i=Lr(t);if(e==null||typeof e!="object"){const c=i.find(f=>f.value===e);return c&&c.label!=null?c.label:r()}if("value"in e){const c=i.find(f=>f&&f.value===e.value);if(c&&c.label!=null)return c.label}}return r()}function Hr(e,t,n){return e.reduce((r,s,i)=>(i>0&&r.push(", "),r.push(ae.jsx(o.Fragment,{children:fn(s,t,n)},i)),r),[])}const Nr={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{const{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:De(t,r)!==""},hasNullItemLabel:(e,t)=>t?Dr(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{const n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(s=>Oe(t,s,n)):Oe(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows},kr=o.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:te,validationMode:"onSubmit",submitCountRef:{current:0}});function Ur(){return o.useContext(kr)}const Ce=1;function dn(e,t){return Math.max(0,e-t)}function Br(e,t){if(t<=0)return 0;const n=qe(e,0,t),r=n,s=t-n,i=r<=Ce,c=s<=Ce;return i&&c?r<=s?0:t:i?0:c?t:n}function mo(e){const{id:t,value:n,defaultValue:r=null,onValueChange:s,open:i,defaultOpen:c=!1,onOpenChange:f,name:l,form:C,autoComplete:R,disabled:x=!1,readOnly:T=!1,required:d=!1,modal:V=!0,actionsRef:A,inputRef:E,onOpenChangeComplete:y,items:$,multiple:F=!1,itemToStringLabel:g,itemToStringValue:m,isItemEqualToValue:O=ln,highlightItemOnHover:p=!0,children:S}=e,{clearErrors:k}=Ur(),{setDirty:D,setTouched:G,setFocused:K,validityData:h,setFilled:L,name:z,disabled:J,validation:W,validationMode:v}=wt(),U=sn({id:t}),a=J||x,I=z??l,[M,P]=Ut({controlled:n,default:F?r??Rt:r,name:"Select",state:"value"}),[H,X]=Ut({controlled:i,default:c,name:"Select",state:"open"}),ne=o.useRef([]),re=o.useRef([]),se=o.useRef(null),le=o.useRef(null),oe=o.useRef(0),fe=o.useRef(null),B=o.useRef([]),j=o.useRef(!1),ce=o.useRef(null),Q=o.useRef(null),pe=o.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),xe=o.useRef(!1),de=o.useRef(M),{mounted:ue,setMounted:ge,transitionStatus:Se}=Zt(H),{openMethod:ee,triggerProps:we}=Qn(H),u=He(()=>new An({id:U,labelId:void 0,modal:V,multiple:F,itemToStringLabel:g,itemToStringValue:m,isItemEqualToValue:O,value:M,open:H,mounted:ue,transitionStatus:Se,items:$,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:nt,triggerProps:nt,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:te,setOpen:te,handleScrollArrowVisibility:te,onOpenChangeComplete:te,listRef:ne,popupRef:se,scrollHandlerRef:le,scrollArrowsMountedCountRef:oe,valueRef:fe,valuesRef:B,labelsRef:re,typingRef:j,selectionRef:pe,firstItemTextRef:ce,selectedItemTextRef:Q,alignItemWithTriggerActiveRef:xe,initialValueRef:de},Nr)).current,b=u.useState("activeIndex"),Z=u.useState("selectedIndex"),w=u.useState("triggerElement"),N=u.useState("positionerElement"),Te=mr(ee),Me=ee??Te,be=o.useMemo(()=>F?"":De(M,m),[F,M,m]),Re=o.useMemo(()=>F&&Array.isArray(M)?M.map(_=>De(_,m)):De(M,m),[F,M,m]),Ue=Ae(w),Be=Y(()=>Re);wr(Ue,U,M,Be,!a,l);const _e=F?Array.isArray(M)&&M.length>0:M!=null&&be!=="";q(()=>{L(_e)},[_e,L]),q(function(){const ie=cn(B.current,M,O,F);ie===null&&(Q.current=null),!H&&u.set("selectedIndex",ie)},[F,H,M,O,u]),Zn(M,()=>{k(I),D(Pr(M,h.initialValue,O)),W.change(M)});const je=Y((_,ie)=>{f?.(_,ie),!ie.isCanceled&&(X(_),!_&&(ie.reason===Kt||ie.reason===On)&&(G(!0),K(!1),v==="onBlur"&&W.commit(M)))}),Fe=Y(()=>{ge(!1),u.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),y?.(!1)});Et({enabled:!A,open:H,ref:se,onComplete(){H||Fe()}}),o.useImperativeHandle(A,()=>({unmount:Fe}),[Fe]);const We=Y((_,ie)=>{s?.(_,ie),!ie.isCanceled&&P(_)}),at=Y(_=>{const ie=dn(_.scrollHeight,_.clientHeight),$e=Br(_.scrollTop,ie),ft=$e>0,ze=$e<ie;u.set("scrollUpArrowVisible",ft),u.set("scrollDownArrowVisible",ze)}),Pe=ur({open:H,onOpenChange:je,elements:{reference:w,floating:N}}),me=er(Pe,{enabled:!a,event:"mousedown"}),ye=qn(Pe),Ee=pr(Pe,{enabled:!a,listRef:ne,activeIndex:b,selectedIndex:Z,disabledIndices:Rt,onNavigate(_){_===null&&!H||u.set("activeIndex",_)},focusItemOnHover:p}),Le=gr(Pe,{enabled:!a&&(H||!T&&!F),listRef:re,activeIndex:b,selectedIndex:Z,disabledIndices:_=>xr(ne.current[_]),onMatch(_){H?u.set("activeIndex",_):We(B.current[_],he(st))},onTyping(_){j.current=_}}),Mt=o.useMemo(()=>bt(Le.reference,Ee.reference,ye.reference,me.reference,we),[me.reference,Le.reference,Ee.reference,ye.reference,we]),Pt=o.useMemo(()=>bt(Kn,Le.floating,Ee.floating,ye.floating),[Le.floating,Ee.floating,ye.floating]),At=Ee.item??nt;u.useContextCallback("setValue",We),u.useContextCallback("setOpen",je),u.useContextCallback("handleScrollArrowVisibility",at),u.useContextCallback("onOpenChangeComplete",y),hr(()=>{u.update({popupProps:Pt,triggerProps:Mt})}),u.useSyncedValues({id:U,modal:V,multiple:F,value:M,open:H,mounted:ue,transitionStatus:Se,popupProps:Pt,triggerProps:Mt,items:$,itemToStringLabel:g,itemToStringValue:m,isItemEqualToValue:O,openMethod:Me});const xn=o.useMemo(()=>({disabled:a,readOnly:T,required:d,multiple:F,highlightItemOnHover:p,itemProps:At}),[a,T,d,F,p,At]),Sn=Tn(E,W.inputRef),Ot=F?void 0:I,Rn=o.useMemo(()=>!F||!Array.isArray(M)||!I?null:M.map(_=>{const ie=De(_,m);return ae.jsx("input",{type:"hidden",form:C,name:I,value:ie,disabled:a},ie)}),[F,M,C,I,m,a]);return ae.jsxs(en.Provider,{value:u,children:[ae.jsx(tn.Provider,{value:xn,children:ae.jsx(nn.Provider,{value:Pe,children:S})}),ae.jsx("input",{...W.getValidationProps(a,{onFocus(){u.state.triggerElement?.focus({focusVisible:!0})},onChange(_){if(_.nativeEvent.defaultPrevented||a||T)return;const ie=_.currentTarget.value,$e=he(st,_.nativeEvent);function ft(){if(F)return;const ze=ie.toLowerCase();let dt=B.current.findIndex(pt=>De(pt,m).toLowerCase()===ze||an(pt,g).toLowerCase()===ze);dt===-1&&(dt=B.current.findIndex((pt,bn)=>{const Ft=re.current[bn];return Ft!=null&&Ft.toLowerCase()===ze}));const Vt=B.current[dt];Vt!=null&&We(Vt,$e)}u.set("forceMount",!0),queueMicrotask(ft)}}),id:U&&Ot==null?`${U}-hidden-input`:void 0,form:C,name:Ot,autoComplete:R,value:be,disabled:a,required:d&&!(F&&_e),readOnly:T,ref:Sn,style:I?Mn:Pn,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Rn]})}function _r(e,t){return e??t}const Je=5;function jr(e,t){const n=Wr(t);return e.clientX>=n.left-Je&&e.clientX<=n.right+Je&&e.clientY>=n.top-Je&&e.clientY<=n.bottom+Je}function Wr(e){const t=e.getBoundingClientRect(),n=rt(e);if(Vn)return t;const r=n.getComputedStyle(e,"::before"),s=n.getComputedStyle(e,"::after");if(!(r.content!=="none"||s.content!=="none"))return t;const c=parseFloat(r.width)||0,f=parseFloat(r.height)||0,l=parseFloat(s.width)||0,C=parseFloat(s.height)||0,R=Math.max(t.width,c,l),x=Math.max(t.height,f,C),T=R-t.width,d=x-t.height;return{left:t.left-T/2,right:t.right+T/2,top:t.top-d/2,bottom:t.bottom+d/2}}const zr="data-popup-side",qr=400,Kr={...Yn,...Cr,popupSide:e=>e?{[zr]:e}:null,value:()=>null},ho=o.forwardRef(function(t,n){const{render:r,className:s,id:i,disabled:c=!1,nativeButton:f=!0,style:l,...C}=t,{setTouched:R,setFocused:x,validationMode:T,validation:d,state:V,disabled:A}=wt(),{labelId:E}=on(),y=Ve(),{readOnly:$,required:F,disabled:g}=vt(),m=A||g||c,O=y.useState("open"),p=y.useState("mounted"),S=y.useState("value"),k=y.useState("triggerProps"),D=y.useState("positionerElement"),G=y.useState("listElement"),K=y.useState("popupSide"),h=y.useState("id"),L=y.useState("labelId"),z=y.useState("hasSelectedValue"),J=p&&D?K:null,W=i??h,v=_r(E,L);sn({id:i});const U=Ae(D),a=o.useRef(null),{getButtonProps:I,buttonRef:M}=Gt({disabled:m,native:f}),P=y.useStateSetter("triggerElement"),H=tt(),X=tt(),ne=tt();o.useEffect(()=>{if(O)return ne.start(qr,()=>{y.context.selectionRef.current.allowUnselectedMouseUp=!0,y.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{ne.clear()};y.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},X.clear()},[O,y,X,ne]);const re=bt(k,{id:W,role:"combobox","aria-expanded":O,"aria-haspopup":"listbox","aria-controls":O?G?.id??qt(D)?.id:void 0,"aria-labelledby":v,"aria-readonly":$||void 0,"aria-required":F||void 0,tabIndex:m?-1:0,onFocus(oe){x(!0),O&&y.context.alignItemWithTriggerActiveRef.current&&y.context.setOpen(!1,he(st,oe.nativeEvent)),H.start(0,()=>{y.set("forceMount",!0)})},onBlur(oe){ve(D,oe.relatedTarget)||(R(!0),x(!1),T==="onBlur"&&d.commit(S))},onMouseDown(oe){if(O)return;const fe=Ye(oe.currentTarget);function B(j){if(!a.current)return;const ce=j.target;ve(a.current,ce)||ve(U.current,ce)||jr(j,a.current)||y.context.setOpen(!1,he(Fn,j))}X.start(0,()=>{fe.addEventListener("mouseup",B,{once:!0})})}},C,I),se=d.getValidationProps(m,re);se.role="combobox";const le={...V,open:O,disabled:m,value:S,readOnly:$,popupSide:J,placeholder:!z};return ke("button",t,{ref:[n,a,M,P],state:le,stateAttributesMapping:Kr,props:se})}),Yr={value:()=>null},xo=o.forwardRef(function(t,n){const{className:r,render:s,children:i,placeholder:c,style:f,...l}=t,C=Ve(),R=C.useState("value"),x=C.useState("items"),T=C.useState("itemToStringLabel"),d=C.useState("hasSelectedValue"),V=!d&&c!=null&&i==null,A=C.useState("hasNullItemLabel",V),E={value:R,placeholder:!d};let y=null;return typeof i=="function"?y=i(R):i!=null?y=i:V&&!A?y=c:Array.isArray(R)?y=Hr(R,x,T):y=fn(R,x,T),ke("span",t,{state:E,ref:[n,C.context.valueRef],props:[{children:y},l],stateAttributesMapping:Yr})}),So=o.forwardRef(function(t,n){const r=Ve(),s=r.useState("mounted"),i=r.useState("forceMount");return s||i?ae.jsx(Ln,{ref:n,...t}):null}),pn=o.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function $r(){return o.useContext(pn)}function Gr(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:s}=e,i=Y(s),[,c]=o.useState(!1),f=He(Jr).current,l=He(Xr).current,C=o.useRef(0),R=o.useRef(!0),x=o.useRef(null),T=o.useRef(null),d=Y(()=>{R.current||(R.current=!0,c(m=>!m))}),V=Y((m,O)=>{l.set(m,O),d()}),A=Y(m=>{l.delete(m),d()}),E=Y(m=>{const O=new Map;return n.current.length=0,r&&(r.current.length=0),m.forEach(p=>{O.set(p.element,{...p.registration.metadata??{},index:p.index}),n.current[p.index]=p.element,r&&(r.current[p.index]=p.registration.label!==void 0?p.registration.label:p.registration.textRef?.current?.textContent??p.element.textContent)}),C.current=n.current.length,O});function y(m){if(T.current?.disconnect(),T.current=null,typeof MutationObserver!="function"||m.length<2)return;const O=new MutationObserver(S=>{if(!eo(S))return;let k=null;for(const D of m)if(D.isConnected){if(k&&gn(k,D)>0){O.disconnect(),d();return}k=D}});T.current=O;const p=new Set;for(let S=1;S<m.length;S+=1){const k=Zr(m[S-1],m[S]);k&&p.add(k)}p.forEach(S=>O.observe(S,{childList:!0}))}const $=Y(()=>{const[m,O]=Qr(l),p=E(m),S=x.current,k=!S||S.length!==m.length||m.some((D,G)=>{const K=S[G];return D.index!==K.index||D.element!==K.element||D.registration.index!==K.registration.index||D.registration.metadata!==K.registration.metadata});y(O),x.current=m,R.current=!1,k&&(f.forEach(D=>D(p)),i(p))});q(()=>(!R.current&&x.current&&E(x.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,E]),q(()=>{R.current&&$()}),q(()=>()=>{T.current?.disconnect(),R.current=!0},[]);const F=Y(m=>(f.add(m),()=>{f.delete(m)})),g=o.useMemo(()=>({register:V,unregister:A,subscribeMapChange:F,nextIndexRef:C}),[V,A,F,C]);return ae.jsx(pn.Provider,{value:g,children:t})}function Xr(){return new Map}function Jr(){return new Set}function Qr(e){const t=new Set,n=[],r=[];e.forEach((i,c)=>{if(!c.isConnected)return;const f=i.index,l={index:f??-1,element:c,registration:i};f===null?r.push(l):f>=0&&(t.add(f),n.push(l))});let s=0;return r.sort((i,c)=>gn(i.element,c.element)),r.forEach(i=>{for(;t.has(s);)s+=1;i.index=s,n.push(i),s+=1}),t.size>0&&n.sort((i,c)=>i.index-c.index),[n,r.map(i=>i.element)]}function Zr(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function eo(e){for(const t of e)for(let n=0;n<t.removedNodes.length;n+=1)if(t.removedNodes[n].isConnected)return!0;return!1}function gn(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}const mn=o.createContext(void 0);function to(){const e=o.useContext(mn);if(!e)throw new Error(Ne(59));return e}function it(e,t){e&&Object.assign(e.style,t)}const no={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},ro={position:"fixed"},Ro=o.forwardRef(function(t,n){const{anchor:r,className:s,render:i,positionMethod:c,side:f,align:l,sideOffset:C,alignOffset:R,collisionBoundary:x="clipping-ancestors",collisionPadding:T,arrowPadding:d,sticky:V,disableAnchorTracking:A,alignItemWithTrigger:E=!0,collisionAvoidance:y=Dn,style:$,...F}=t,g=Ve(),m=rn(),O=g.useState("open"),p=g.useState("mounted"),S=g.useState("modal"),k=g.useState("value"),D=g.useState("openMethod"),G=g.useState("positionerElement"),K=g.useState("triggerElement"),h=g.useState("isItemEqualToValue"),L=g.useState("transitionStatus"),z=o.useRef(null),J=o.useRef(null),[W,v]=o.useState(E),U=p&&W&&D!=="touch";!p&&W!==E&&v(E),o.useImperativeHandle(g.context.alignItemWithTriggerActiveRef,()=>U),tr((U||S)&&O,D==="touch",G,K);const a=nr({anchor:r,floatingRootContext:m,positionMethod:c,mounted:p,side:f,sideOffset:C,align:l,alignOffset:R,arrowPadding:d,collisionBoundary:x,collisionPadding:T,sticky:V,disableAnchorTracking:A??U,collisionAvoidance:y,keepMounted:!0}),I=U?"none":a.side,M=U?ro:a.positionerStyles,P={open:O,side:I,align:a.align,anchorHidden:a.anchorHidden};q(()=>{g.set("popupSide",a.side)},[g,a.side]);const H=g.useStateSetter("positionerElement"),X=rr(t,P,{styles:M,transitionStatus:L,props:F,refs:[n,H],hidden:!p,inert:!O}),ne=o.useRef(0),re=Y(le=>{if(g.context.valuesRef.current.length===0)return;const oe=ne.current;ne.current=le.size;const fe=he(st);if(oe!==0&&!g.state.multiple&&k!==null&&ot(g.context.valuesRef.current,k,h)===-1){const j=g.context.initialValueRef.current,Q=j!=null&&ot(g.context.valuesRef.current,j,h)!==-1?j:null;g.context.setValue(Q,fe),Q===null&&(g.set("selectedIndex",null),g.context.selectedItemTextRef.current=null)}if(oe!==0&&g.state.multiple&&Array.isArray(k)){const B=k.filter(j=>ot(g.context.valuesRef.current,j,h)!==-1);B.length!==k.length&&(g.context.setValue(B,fe),B.length===0&&(g.set("selectedIndex",null),g.context.selectedItemTextRef.current=null))}if(O&&U){g.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const B={height:""};it(G,B),it(g.context.popupRef.current,B)}}),se=o.useMemo(()=>({...a,side:I,alignItemWithTriggerActive:U,setControlledAlignItemWithTrigger:v,scrollUpArrowRef:z,scrollDownArrowRef:J}),[a,I,U,v]);return ae.jsx(Gr,{elementsRef:g.context.listRef,labelsRef:g.context.labelsRef,onMapChange:re,children:ae.jsxs(mn.Provider,{value:se,children:[p&&S&&ae.jsx($n,{inert:Hn(!O),cutout:K}),X]})})}),Qe="base-ui-disable-scrollbar",Bt={className:Qe,getElement(e){return ae.jsx("style",{nonce:e,href:Qe,precedence:"base-ui:low",children:`.${Qe}{scrollbar-width:none}.${Qe}::-webkit-scrollbar{display:none}`})}},oo=o.createContext(void 0),so={disableStyleElements:!1};function io(){return o.useContext(oo)??so}const _t="--transform-origin",lo={...Xn,...Xt},bo=o.forwardRef(function(t,n){const{render:r,className:s,style:i,finalFocus:c,...f}=t,l=Ve(),{multiple:C,readOnly:R,highlightItemOnHover:x}=vt(),T=rn(),{side:d,align:V,alignItemWithTriggerActive:A,isPositioned:E,setControlledAlignItemWithTrigger:y}=to(),$=or()!=null,F=sr(),{nonce:g,disableStyleElements:m}=io(),O=l.useState("id"),p=l.useState("open"),S=l.useState("openMethod"),k=l.useState("mounted"),D=l.useState("popupProps"),G=l.useState("transitionStatus"),K=l.useState("triggerElement"),h=l.useState("positionerElement"),L=l.useState("listElement"),z=o.useRef(!1),J=o.useRef(!1),W=o.useRef({}),v=St(),U=Y(P=>{if(!h||!l.context.popupRef.current||!J.current)return;const H=h.style.top==="0px",X=h.style.bottom==="0px";if(z.current||!A||!H&&!X){l.context.handleScrollArrowVisibility(P);return}const ne=Wt(h),re=Ke(h.getBoundingClientRect().height,"y",ne),se=Ye(h),le=rt(h),oe=le.getComputedStyle(h),fe=parseFloat(oe.marginTop),B=parseFloat(oe.marginBottom),j=jt(le.getComputedStyle(l.context.popupRef.current)),ce=Math.min(se.documentElement.clientHeight-fe-B,j),Q=P.scrollTop,pe=Ze(P);let xe=null;const de=ee=>{h.style.height=`${ee}px`},ue=H?pe-Q:Q,ge=Math.min(re+ue,ce);if(ue<=Ce){const ee=qe(ue,0,ce-re);ee>0&&de(re+ee),P.scrollTop=H?pe:0,ce-(re+ee)<=Ce&&(z.current=!0),l.context.handleScrollArrowVisibility(P);return}if(ce-ge>Ce)xe=H?1/0:0;else if(X&&Q<pe){const ee=re+ue-ce;xe=Q-(ue-ee)}const Se=Math.ceil(ge);if(Se!==0&&de(Se),xe!=null){const ee=qe(xe,0,Ze(P));Math.abs(P.scrollTop-ee)>Ce&&(P.scrollTop=ee)}Se>=ce-Ce&&(z.current=!0),l.context.handleScrollArrowVisibility(P)});o.useImperativeHandle(l.context.scrollHandlerRef,()=>U,[U]),Et({open:p,ref:l.context.popupRef,onComplete(){p&&l.context.onOpenChangeComplete(!0)}});const a={open:p,transitionStatus:G,side:d,align:V};q(()=>{!h||!l.context.popupRef.current||Object.keys(W.current).length||(W.current={top:h.style.top||"0",left:h.style.left||"0",right:h.style.right,height:h.style.height,bottom:h.style.bottom,minHeight:h.style.minHeight,maxHeight:h.style.maxHeight,marginTop:h.style.marginTop,marginBottom:h.style.marginBottom})},[l,h]),q(()=>{p||A||(J.current=!1,z.current=!1,it(h,W.current))},[p,A,h]),q(()=>{const P=l.context.popupRef.current;if(!p||!K||!h||!P||A&&!E||l.state.transitionStatus==="ending")return;if(J.current=!0,P.style.removeProperty(_t),!A){v.request(()=>l.context.handleScrollArrowVisibility(L||P));return}const H=co(P);try{let X=l.context.selectedItemTextRef.current;X?.isConnected||(X=!l.select("hasSelectedValue")&&l.context.firstItemTextRef.current?.isConnected?l.context.firstItemTextRef.current:null);const ne=l.context.valueRef.current,re=rt(h),se=re.getComputedStyle(h),le=re.getComputedStyle(P),oe=Ye(K),fe=Wt(K),B=et(K.getBoundingClientRect(),fe),j=et(h.getBoundingClientRect(),fe),ce=B.height,Q=L||P,pe=Q.scrollHeight,xe=parseFloat(le.borderBottomWidth),de=parseFloat(se.marginTop)||10,ue=parseFloat(se.marginBottom)||10,ge=parseFloat(se.minHeight)||100,Se=jt(le),ee=5,we=5,u=20,b=oe.documentElement.clientHeight-de-ue,Z=oe.documentElement.clientWidth,w=b-B.bottom+ce;let N,Te=F==="rtl"?B.right-j.width:B.left,Me=0;if(X&&ne){const me=et(ne.getBoundingClientRect(),fe);N=et(X.getBoundingClientRect(),fe),Te=j.left+(F==="rtl"?me.right-N.right:me.left-N.left);const ye=me.top-B.top+me.height/2;Me=N.top-j.top+N.height/2-ye}const be=w+Me+ue+xe;let Re=Math.min(b,be);const Ue=b-de-ue,Be=be-Re,_e=Z-we;h.style.left=`${qe(Te,ee,_e-j.width)}px`,h.style.height=`${Re}px`,h.style.maxHeight="none",h.style.marginTop=`${de}px`,h.style.marginBottom=`${ue}px`,P.style.height="100%";const je=Ze(Q),Fe=Be>=je-Ce;Fe&&(Re=Math.min(b,j.height)-(Be-je));const We=B.top<u||B.bottom>b-u||Math.ceil(Re)+Ce<Math.min(pe,ge),at=(re.visualViewport?.scale??1)!==1&&Yt;if(We||at){it(h,W.current),y(!1);return}const Pe=Math.max(ge,Re);if(Fe){const me=Math.max(0,b-be);h.style.top=j.height>=Ue?"0":`${me}px`,h.style.height=`${Re}px`,Q.scrollTop=Ze(Q)}else h.style.bottom="0",Q.scrollTop=Be;if(N){const me=j.top,ye=j.height,Ee=N.top+N.height/2,Le=qe(ye>0?(Ee-me)/ye*100:50,0,100);P.style.setProperty(_t,`50% ${Le}%`)}(Pe===b||Re>=Se)&&(z.current=!0),l.context.handleScrollArrowVisibility(Q),x&&l.state.selectedIndex===null&&l.state.activeIndex===null&&l.context.listRef.current[0]!=null&&l.set("activeIndex",0)}finally{H()}},[l,p,h,K,A,y,v,L,x,F,E]),o.useEffect(()=>{if(!A||!h||!p)return;const P=rt(h);function H(X){l.context.setOpen(!1,he(kn,X))}return Nn(P,"resize",H)},[l,A,h,p]);const I={...L?{role:"presentation"}:{role:"listbox","aria-multiselectable":C||void 0,"aria-readonly":R||void 0,id:`${O}-list`},onKeyDown(P){$&&Jn.has(P.key)&&P.stopPropagation()},onScroll(P){L||U(P.currentTarget)},...A&&{style:L?{height:"100%"}:no},className:!L&&A?Bt.className:void 0},M=ke("div",t,{ref:[n,l.context.popupRef],state:a,stateAttributesMapping:lo,props:[D,I,cr(G),f]});return ae.jsxs(o.Fragment,{children:[!m&&Bt.getElement(g),ae.jsx(Gn,{context:T,modal:!1,disabled:!k,openInteractionType:S,returnFocus:c,restoreFocus:!0,children:M})]})});function jt(e){const t=e.maxHeight;return t.endsWith("px")&&parseFloat(t)||1/0}function Ze(e){return dn(e.scrollHeight,e.clientHeight)}function Wt(e){return ir.getScale(e)}function Ke(e,t,n){return e/n[t]}function et(e,t){return lr({x:Ke(e.x,"x",t),y:Ke(e.y,"y",t),width:Ke(e.width,"x",t),height:Ke(e.height,"y",t)})}const zt=[["transform","none"],["scale","1"],["translate","0 0"]];function co(e){const{style:t}=e,n={};for(const[r,s]of zt)n[r]=t.getPropertyValue(r),t.setProperty(r,s,"important");return()=>{for(const[r]of zt){const s=n[r];s?t.setProperty(r,s):t.removeProperty(r)}}}function uo(e={}){const{guess:t,label:n,metadata:r,textRef:s,index:i}=e,{register:c,unregister:f,subscribeMapChange:l,nextIndexRef:C}=$r(),R=o.useRef(-1),[x,T]=o.useState(i==null&&t?()=>{if(R.current===-1){const E=C.current;C.current+=1,R.current=E}return R.current}:-1),d=i??x,V=o.useRef(null),A=o.useCallback(E=>{const y=V.current;y&&f(y),V.current=E,E&&c(E,{metadata:r??null,index:i??null,label:n,textRef:s})},[i,c,f,r,n,s]);return q(()=>{if(i==null)return l(E=>{const y=V.current?E.get(V.current)?.index:null;y!=null&&T(y)})},[i,l]),{ref:A,index:d}}const hn=o.createContext(void 0);function Tt(){const e=o.useContext(hn);if(!e)throw new Error(Ne(57));return e}const yo=o.memo(o.forwardRef(function(t,n){const{render:r,className:s,style:i,value:c=null,label:f,disabled:l=!1,nativeButton:C=!1,...R}=t,x=o.useRef(null),T=uo({guess:!0,label:f,textRef:x}),d=Ve(),{itemProps:V,multiple:A,disabled:E,readOnly:y}=vt(),$=E||l,F=d.useState("isActive",T.index),g=d.useState("open"),m=d.useState("isSelected",c),O=d.useState("isSelectedByFocus",T.index),p=d.useState("isItemEqualToValue"),S=T.index,k=o.useRef(null);q(()=>{const a=d.context.valuesRef.current;return a[S]=c,()=>{delete a[S]}},[S,c,d]),q(()=>{const a=d.state.value,I=d.state.selectedIndex;let M=I,P;A&&Array.isArray(a)?(M=Or(S,c,d.context.valuesRef.current,a,p,I),P=M===S,S===I&&!P&&(d.context.selectedItemTextRef.current=null)):(P=a!==void 0&&Oe(c,a,p),P&&(M=S)),d.set("selectedIndex",M),P&&x.current&&(d.context.selectedItemTextRef.current=x.current)},[S,A,p,d,c]);const D=o.useRef("mouse"),G=o.useRef(!1),{getButtonProps:K,buttonRef:h}=Gt({disabled:$,focusableWhenDisabled:!0,native:C,composite:!0}),L={disabled:$,selected:m,highlighted:F};function z(a){if(E||y)return;const I=d.state.value;if(A){const M=Array.isArray(I)?I:[],P=m?Vr(M,c,p):[...M,c];d.context.setValue(P,he(ht,a))}else d.context.setValue(c,he(ht,a)),d.context.setOpen(!1,he(ht,a))}function J(){d.context.selectionRef.current.dragY=0}const W={role:"option","aria-selected":m,tabIndex:g&&F?0:-1,onKeyDown(a){d.set("activeIndex",S),a.key===" "&&d.context.typingRef.current&&a.preventDefault()},onClick(a){const I=D.current!=="touch",M=a.nativeEvent.pointerType,P=I&&Qt(a.nativeEvent)&&(M!==void 0||F),H=I&&!P&&!G.current;G.current=!1,!($||H)&&z(a.nativeEvent)},onPointerEnter(a){D.current=a.pointerType},onPointerMove(a){if(a.pointerType==="mouse"&&a.buttons===1){const I=d.context.selectionRef.current;I.dragY+=a.movementY,I.dragY**2>=64&&(I.allowUnselectedMouseUp=!0)}},onPointerDown(a){D.current=a.pointerType,G.current=!0,J()},onMouseUp(){if(J(),$||D.current==="touch"||G.current)return;const a=!d.context.selectionRef.current.allowSelectedMouseUp&&m,I=!d.context.selectionRef.current.allowUnselectedMouseUp&&!m;a||I||(G.current=!0,k.current?.click(),G.current=!1)}},v=ke("div",t,{ref:[h,n,T.ref,k],state:L,props:[V,W,R,K]}),U=o.useMemo(()=>({selected:m,index:S,textRef:x,selectedByFocus:O}),[m,S,x,O]);return ae.jsx(hn.Provider,{value:U,children:v})})),Io=o.forwardRef(function(t,n){const{selected:r}=Tt();return t.keepMounted||r?ae.jsx(ao,{...t,ref:n}):null}),ao=o.memo(o.forwardRef((e,t)=>{const{render:n,className:r,style:s,keepMounted:i,...c}=e,{selected:f}=Tt(),l=o.useRef(null),{transitionStatus:C,setMounted:R}=Zt(f),T=ke("span",e,{ref:[t,l],state:{selected:f,transitionStatus:C},props:[{"aria-hidden":!0,children:"✔️"},c],stateAttributesMapping:Xt});return Et({batch:!0,enabled:!f,open:f,ref:l,onComplete(){f||R(!1)}}),T})),Co=o.memo(o.forwardRef(function(t,n){const{index:r,textRef:s,selectedByFocus:i}=Tt(),c=Ve(),{render:f,className:l,style:C,...R}=t,x=o.useCallback(d=>{d&&(r===0&&(c.context.firstItemTextRef.current=d),i&&(c.context.selectedItemTextRef.current=d))},[c,r,i]);return ke("div",t,{ref:[x,n,s],props:R})}));export{no as L,mo as S,vt as a,to as b,ho as c,xo as d,So as e,Ro as f,bo as g,yo as h,Io as i,Co as j,Cr as k,Ur as l,wt as m,on as n,sn as o,Ut as p,wr as q,Bt as s,Ve as u};
@@ -1 +1 @@
1
- import{r as d,c as n,j as t,R as h}from"./__vite-browser-external-VmN0WaC3.js";import{P as f}from"./ProviderIcon-BfFkS-OF.js";import{E as b}from"./external-link-fdU7Lj6p.js";const x=[{id:"claude",name:"Claude",icon:"CLAUDE",apiUrl:"https://status.claude.com/api/v2/status.json",pageUrl:"https://status.claude.com"},{id:"openai",name:"OpenAI / Codex",icon:"CODEX",apiUrl:"https://status.openai.com/api/v2/status.json",pageUrl:"https://status.openai.com"},{id:"cursor",name:"Cursor",icon:"CURSOR",apiUrl:"https://status.cursor.com/api/v2/status.json",pageUrl:"https://status.cursor.com"},{id:"github",name:"GitHub / Copilot",icon:"GITHUB",apiUrl:"https://www.githubstatus.com/api/v2/status.json",pageUrl:"https://www.githubstatus.com"},{id:"gemini",name:"Gemini",icon:"GEMINI",kind:"google",serviceName:"Gemini",apiUrl:"https://www.google.com/appsstatus/dashboard/incidents.json",pageUrl:"https://www.google.com/appsstatus/dashboard"},{id:"kimi",name:"Kimi / Moonshot",icon:"KIMI",apiUrl:"https://status.moonshot.cn/api/v2/status.json",pageUrl:"https://status.moonshot.cn"},{id:"minimax",name:"MiniMax",icon:"MINIMAX",apiUrl:"https://status.minimaxi.com/api/v2/status.json",pageUrl:"https://status.minimaxi.com"},{id:"zed",name:"Zed",icon:"ZED",kind:"instatus",apiUrl:"https://status.zed.dev/summary.json",pageUrl:"https://status.zed.dev"}],w=6e4,y=8e3,j=new Set(["none","minor","major","critical"]),g={none:{dot:"bg-emerald-500",text:"text-emerald-600 dark:text-emerald-400"},minor:{dot:"bg-yellow-500",text:"text-yellow-600 dark:text-yellow-400"},major:{dot:"bg-orange-500",text:"text-orange-600 dark:text-orange-400"},critical:{dot:"bg-red-500",text:"text-red-600 dark:text-red-400"},unknown:{dot:"bg-oai-gray-400",text:"text-oai-gray-500 dark:text-oai-gray-400"}};function k(e){switch(e){case"none":return n("status.state.none");case"minor":return n("status.state.minor");case"major":return n("status.state.major");case"critical":return n("status.state.critical");default:return n("status.state.unknown")}}const v={low:"minor",medium:"major",high:"critical"},N={MAJOROUTAGE:"critical",PARTIALOUTAGE:"major",DEGRADEDPERFORMANCE:"minor"};function A(e){const a=e?.page?.status;if(typeof a!="string")throw new Error("Unexpected payload");if(a==="UP")return{indicator:"none",description:"",updatedAt:null};const s=Array.isArray(e?.activeIncidents)?e.activeIncidents:[],r={critical:3,major:2,minor:1};let o=null;for(const i of s){const c=N[i?.impact]||"minor";(!o||r[c]>r[o.indicator])&&(o={indicator:c,description:i?.name||"",updatedAt:i?.updated||null})}return o||{indicator:"minor",description:"",updatedAt:null}}function I(e,a){if(!Array.isArray(e))throw new Error("Unexpected payload");const s=e.filter(i=>i&&!i.end&&(i.service_name===a||Array.isArray(i.affected_products)&&i.affected_products.some(c=>c?.title===a)));if(s.length===0)return{indicator:"none",description:"",updatedAt:null};const r={critical:3,major:2,minor:1};let o=null;for(const i of s){const c=v[i.severity]||"minor";(!o||r[c]>r[o.indicator])&&(o={indicator:c,description:i.external_desc||"",updatedAt:i.modified||null})}return o}async function E(e){try{const a=await fetch(e.apiUrl,{cache:"no-store",signal:AbortSignal.timeout(y)});if(!a.ok)throw new Error(`HTTP ${a.status}`);const s=await a.json();if(e.kind==="google")return I(s,e.serviceName);if(e.kind==="instatus")return A(s);const r=s?.status?.indicator;if(!j.has(r))throw new Error("Unexpected payload");return{indicator:r,description:typeof s?.status?.description=="string"?s.status.description:"",updatedAt:typeof s?.page?.updated_at=="string"?s.page.updated_at:null}}catch{return{indicator:"unknown",description:"",updatedAt:null}}}function U({provider:e,result:a}){const s=g[a?.indicator]||g.unknown,r=a==null;return t.jsxs("a",{href:e.pageUrl,target:"_blank",rel:"noreferrer","aria-label":n("status.open_page",{provider:e.name}),title:n("status.open_page",{provider:e.name}),className:"group block no-underline text-inherit rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-4 sm:p-5 transition-colors hover:border-oai-gray-300 dark:hover:border-oai-gray-700 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[t.jsx(f,{provider:e.icon,size:20}),t.jsx("span",{className:"font-medium text-sm sm:text-base truncate",children:e.name})]}),t.jsx("span",{"aria-hidden":!0,className:"shrink-0 inline-flex h-8 w-8 items-center justify-center rounded-lg text-oai-gray-400 transition-colors group-hover:text-oai-black dark:group-hover:text-white",children:t.jsx(b,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[r?t.jsx("span",{className:"h-2 w-2 rounded-full bg-oai-gray-300 dark:bg-oai-gray-700 animate-pulse","aria-hidden":!0}):t.jsxs("span",{className:"relative flex h-2 w-2","aria-hidden":!0,children:[a.indicator!=="none"&&a.indicator!=="unknown"?t.jsx("span",{className:`absolute inline-flex h-full w-full animate-ping rounded-full opacity-75 ${s.dot}`}):null,t.jsx("span",{className:`relative inline-flex h-2 w-2 rounded-full ${s.dot}`})]}),t.jsx("span",{className:`text-sm font-medium ${r?"text-oai-gray-400":s.text}`,children:r?n("status.state.checking"):k(a.indicator)})]}),!r&&a.description&&a.indicator!=="none"?t.jsx("p",{className:"mt-2 text-xs text-oai-gray-500 dark:text-oai-gray-400 break-words",children:a.description}):null]})}function T(){const[e,a]=d.useState({}),[s,r]=d.useState(null),[o,i]=d.useState(!1),c=d.useRef(!0),u=d.useCallback(async()=>{i(!0);const l=await Promise.all(x.map(async p=>[p.id,await E(p)]));c.current&&(a(Object.fromEntries(l)),r(new Date),i(!1))},[]);d.useEffect(()=>{c.current=!0,u();const l=setInterval(()=>{u()},w);return()=>{c.current=!1,clearInterval(l)}},[u]);const m=d.useMemo(()=>s?n("status.last_checked",{time:s.toLocaleTimeString()}):null,[s]);return t.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:t.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:t.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[t.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:n("nav.service_status")}),t.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:n("status.page.subtitle")})]}),t.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[m?t.jsx("span",{className:"hidden sm:inline text-xs text-oai-gray-400 dark:text-oai-gray-500",children:m}):null,t.jsx("button",{type:"button",onClick:()=>{u()},disabled:o,"aria-label":n("status.refresh"),title:n("status.refresh"),className:"inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50",children:t.jsx(h,{className:`h-4 w-4 ${o?"animate-spin":""}`,"aria-hidden":!0})})]})]}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:x.map(l=>t.jsx(U,{provider:l,result:e[l.id]??null},l.id))}),t.jsx("p",{className:"mt-6 text-xs text-oai-gray-400 dark:text-oai-gray-500",children:n("status.page.source_note")})]})})})}export{x as STATUS_PROVIDERS,T as ServiceStatusPage,T as default};
1
+ import{r as d,c as n,j as t,R as h}from"./__vite-browser-external-4IDwIR3i.js";import{P as f}from"./ProviderIcon-LgUYzw52.js";import{E as b}from"./external-link-B-pvBbFP.js";const x=[{id:"claude",name:"Claude",icon:"CLAUDE",apiUrl:"https://status.claude.com/api/v2/status.json",pageUrl:"https://status.claude.com"},{id:"openai",name:"OpenAI / Codex",icon:"CODEX",apiUrl:"https://status.openai.com/api/v2/status.json",pageUrl:"https://status.openai.com"},{id:"cursor",name:"Cursor",icon:"CURSOR",apiUrl:"https://status.cursor.com/api/v2/status.json",pageUrl:"https://status.cursor.com"},{id:"github",name:"GitHub / Copilot",icon:"GITHUB",apiUrl:"https://www.githubstatus.com/api/v2/status.json",pageUrl:"https://www.githubstatus.com"},{id:"gemini",name:"Gemini",icon:"GEMINI",kind:"google",serviceName:"Gemini",apiUrl:"https://www.google.com/appsstatus/dashboard/incidents.json",pageUrl:"https://www.google.com/appsstatus/dashboard"},{id:"kimi",name:"Kimi / Moonshot",icon:"KIMI",apiUrl:"https://status.moonshot.cn/api/v2/status.json",pageUrl:"https://status.moonshot.cn"},{id:"minimax",name:"MiniMax",icon:"MINIMAX",apiUrl:"https://status.minimaxi.com/api/v2/status.json",pageUrl:"https://status.minimaxi.com"},{id:"zed",name:"Zed",icon:"ZED",kind:"instatus",apiUrl:"https://status.zed.dev/summary.json",pageUrl:"https://status.zed.dev"}],w=6e4,y=8e3,j=new Set(["none","minor","major","critical"]),g={none:{dot:"bg-emerald-500",text:"text-emerald-600 dark:text-emerald-400"},minor:{dot:"bg-yellow-500",text:"text-yellow-600 dark:text-yellow-400"},major:{dot:"bg-orange-500",text:"text-orange-600 dark:text-orange-400"},critical:{dot:"bg-red-500",text:"text-red-600 dark:text-red-400"},unknown:{dot:"bg-oai-gray-400",text:"text-oai-gray-500 dark:text-oai-gray-400"}};function k(e){switch(e){case"none":return n("status.state.none");case"minor":return n("status.state.minor");case"major":return n("status.state.major");case"critical":return n("status.state.critical");default:return n("status.state.unknown")}}const v={low:"minor",medium:"major",high:"critical"},N={MAJOROUTAGE:"critical",PARTIALOUTAGE:"major",DEGRADEDPERFORMANCE:"minor"};function A(e){const a=e?.page?.status;if(typeof a!="string")throw new Error("Unexpected payload");if(a==="UP")return{indicator:"none",description:"",updatedAt:null};const s=Array.isArray(e?.activeIncidents)?e.activeIncidents:[],r={critical:3,major:2,minor:1};let o=null;for(const i of s){const c=N[i?.impact]||"minor";(!o||r[c]>r[o.indicator])&&(o={indicator:c,description:i?.name||"",updatedAt:i?.updated||null})}return o||{indicator:"minor",description:"",updatedAt:null}}function I(e,a){if(!Array.isArray(e))throw new Error("Unexpected payload");const s=e.filter(i=>i&&!i.end&&(i.service_name===a||Array.isArray(i.affected_products)&&i.affected_products.some(c=>c?.title===a)));if(s.length===0)return{indicator:"none",description:"",updatedAt:null};const r={critical:3,major:2,minor:1};let o=null;for(const i of s){const c=v[i.severity]||"minor";(!o||r[c]>r[o.indicator])&&(o={indicator:c,description:i.external_desc||"",updatedAt:i.modified||null})}return o}async function E(e){try{const a=await fetch(e.apiUrl,{cache:"no-store",signal:AbortSignal.timeout(y)});if(!a.ok)throw new Error(`HTTP ${a.status}`);const s=await a.json();if(e.kind==="google")return I(s,e.serviceName);if(e.kind==="instatus")return A(s);const r=s?.status?.indicator;if(!j.has(r))throw new Error("Unexpected payload");return{indicator:r,description:typeof s?.status?.description=="string"?s.status.description:"",updatedAt:typeof s?.page?.updated_at=="string"?s.page.updated_at:null}}catch{return{indicator:"unknown",description:"",updatedAt:null}}}function U({provider:e,result:a}){const s=g[a?.indicator]||g.unknown,r=a==null;return t.jsxs("a",{href:e.pageUrl,target:"_blank",rel:"noreferrer","aria-label":n("status.open_page",{provider:e.name}),title:n("status.open_page",{provider:e.name}),className:"group block no-underline text-inherit rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-4 sm:p-5 transition-colors hover:border-oai-gray-300 dark:hover:border-oai-gray-700 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[t.jsx(f,{provider:e.icon,size:20}),t.jsx("span",{className:"font-medium text-sm sm:text-base truncate",children:e.name})]}),t.jsx("span",{"aria-hidden":!0,className:"shrink-0 inline-flex h-8 w-8 items-center justify-center rounded-lg text-oai-gray-400 transition-colors group-hover:text-oai-black dark:group-hover:text-white",children:t.jsx(b,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[r?t.jsx("span",{className:"h-2 w-2 rounded-full bg-oai-gray-300 dark:bg-oai-gray-700 animate-pulse","aria-hidden":!0}):t.jsxs("span",{className:"relative flex h-2 w-2","aria-hidden":!0,children:[a.indicator!=="none"&&a.indicator!=="unknown"?t.jsx("span",{className:`absolute inline-flex h-full w-full animate-ping rounded-full opacity-75 ${s.dot}`}):null,t.jsx("span",{className:`relative inline-flex h-2 w-2 rounded-full ${s.dot}`})]}),t.jsx("span",{className:`text-sm font-medium ${r?"text-oai-gray-400":s.text}`,children:r?n("status.state.checking"):k(a.indicator)})]}),!r&&a.description&&a.indicator!=="none"?t.jsx("p",{className:"mt-2 text-xs text-oai-gray-500 dark:text-oai-gray-400 break-words",children:a.description}):null]})}function T(){const[e,a]=d.useState({}),[s,r]=d.useState(null),[o,i]=d.useState(!1),c=d.useRef(!0),u=d.useCallback(async()=>{i(!0);const l=await Promise.all(x.map(async p=>[p.id,await E(p)]));c.current&&(a(Object.fromEntries(l)),r(new Date),i(!1))},[]);d.useEffect(()=>{c.current=!0,u();const l=setInterval(()=>{u()},w);return()=>{c.current=!1,clearInterval(l)}},[u]);const m=d.useMemo(()=>s?n("status.last_checked",{time:s.toLocaleTimeString()}):null,[s]);return t.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:t.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:t.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[t.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:n("nav.service_status")}),t.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:n("status.page.subtitle")})]}),t.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[m?t.jsx("span",{className:"hidden sm:inline text-xs text-oai-gray-400 dark:text-oai-gray-500",children:m}):null,t.jsx("button",{type:"button",onClick:()=>{u()},disabled:o,"aria-label":n("status.refresh"),title:n("status.refresh"),className:"inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50",children:t.jsx(h,{className:`h-4 w-4 ${o?"animate-spin":""}`,"aria-hidden":!0})})]})]}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:x.map(l=>t.jsx(U,{provider:l,result:e[l.id]??null},l.id))}),t.jsx("p",{className:"mt-6 text-xs text-oai-gray-400 dark:text-oai-gray-500",children:n("status.page.source_note")})]})})})}export{x as STATUS_PROVIDERS,T as ServiceStatusPage,T as default};
@@ -1,2 +1,2 @@
1
- import{m as ee,r as i,j as e,e as F,c as a,I as me,G as Z,R as he,X as ge,d as te,l as x,a6 as pe,a7 as q}from"./__vite-browser-external-VmN0WaC3.js";import{L as fe,I as be}from"./LocalOnlyNotice-Do9KUdi_.js";import{S as V}from"./SegmentedControl-D5USR3JT.js";import{C as ye}from"./ToolbarRootContext-CY_SULMC.js";import{S as ae}from"./search-DIUmGfar.js";import{C as ke}from"./check-Gz5mnj6f.js";import{P as _e,a as ve,b as je,c as we,d as Ne}from"./PopoverPopup-BYzzQJTD.js";import{P as Ce}from"./ProviderIcon-BfFkS-OF.js";import{H as Se}from"./HoverTooltip-Duo2Icus.js";import{u as Me}from"./useCurrency-BianRgdW.js";import{i as Le}from"./host-mode-Bc_iTzHk.js";import{L as Re}from"./loader-circle-Bl7dBXh1.js";import{T as Te}from"./terminal-JpDnkjVA.js";import"./arrow-up-right-C3WUmTcI.js";import"./download-CccMGCc1.js";import"./composite-DJhoahpv.js";import"./store-DdyzwTsy.js";const re={name:"calendar",size:24,node:[["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M16 2v3",key:"otl347"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M3 9h18",key:"1pudct"}]]};re.node;const De=ee(re);const se={name:"folder",size:24,node:[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]};se.node;const Ie=ee(se),Ee="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm text-oai-black outline-none hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800";function Pe({options:r,value:t,onChange:s,allValue:m="all",allLabel:p,searchPlaceholder:y,emptyLabel:u,ariaLabel:j,disabled:k=!1,className:w=""}){const[f,b]=i.useState(!1),[h,D]=i.useState(""),[g,_]=i.useState(-1),N=i.useRef(null),C=`${i.useId()}-listbox`,U=t===m?p:r.find(l=>l.value===t)?.label??t,S=h.trim().toLowerCase(),I=i.useMemo(()=>S?r.filter(l=>l.label.toLowerCase().includes(S)):r,[r,S]),E=i.useMemo(()=>[{value:m,label:p},...I],[m,p,I]),M=g>=0&&g<E.length?E[g]:null,P=l=>{s(l),b(!1),D(""),_(-1)};i.useEffect(()=>{f&&N.current?.querySelector('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[f,g]);const L=l=>{if(l.key==="ArrowDown"||l.key==="ArrowUp"){l.preventDefault();const v=l.key==="ArrowDown";_($=>{const R=E.length;return R?v?$>=R-1?0:$+1:$<=0?R-1:$-1:-1});return}if(l.key==="Enter"){const v=M||(S&&I.length?I[0]:null);if(!v)return;l.preventDefault(),P(v.value)}};return e.jsxs(_e,{open:f,onOpenChange:l=>{b(l),_(-1),l||D("")},children:[e.jsxs(ve,{disabled:k,"aria-label":j,className:F("inline-flex h-8 max-w-[12rem] shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:hover:border-oai-gray-700",t!==m?"text-oai-black dark:text-white":"text-oai-gray-700 dark:text-oai-gray-200",w),children:[e.jsx(Ie,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:U}),e.jsx(ye,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0})]}),e.jsx(je,{children:e.jsx(we,{sideOffset:4,side:"bottom",align:"start",className:"z-[60]",children:e.jsxs(Ne,{className:"w-56 overflow-hidden rounded-md border border-oai-gray-200 bg-white p-1 shadow-[0_12px_32px_-12px_rgba(0,0,0,0.18)] outline-none dark:border-oai-gray-800 dark:bg-oai-gray-950 dark:shadow-[0_12px_32px_-12px_rgba(0,0,0,0.6)]",children:[e.jsxs("div",{className:"relative mb-1",children:[e.jsx(ae,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{type:"text",role:"combobox","aria-expanded":!0,"aria-controls":C,"aria-activedescendant":M?`${C}-${g}`:void 0,value:h,onChange:l=>{D(l.target.value),_(-1)},onKeyDown:L,placeholder:y,className:"h-8 w-full rounded border border-oai-gray-200 bg-transparent pl-8 pr-2 text-xs text-oai-black outline-none placeholder:text-oai-gray-400 focus:border-oai-gray-400 dark:border-oai-gray-800 dark:text-white dark:focus:border-oai-gray-500"})]}),e.jsxs("div",{ref:N,id:C,role:"listbox","aria-label":j,className:"max-h-64 overflow-y-auto",children:[E.map((l,v)=>e.jsxs("button",{id:`${C}-${v}`,type:"button",role:"option","aria-selected":t===l.value,"data-active":v===g?"true":void 0,onMouseEnter:()=>_(v),onClick:()=>P(l.value),className:F(Ee,t===l.value&&"bg-oai-gray-100 dark:bg-oai-gray-800",v===g&&"ring-1 ring-inset ring-oai-gray-300 dark:ring-oai-gray-600"),children:[e.jsx("span",{className:"flex-1 truncate",children:l.label}),t===l.value?e.jsx(ke,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null]},l.value)),I.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-oai-gray-400 dark:text-oai-gray-500",children:u}):null]})]})})})]})}const Fe="tokentracker-sessions";async function $e(r={}){const t=new URL(`/functions/${Fe}`,window.location.origin);r.from&&t.searchParams.set("from",r.from),r.to&&t.searchParams.set("to",r.to),r.limit&&t.searchParams.set("limit",String(r.limit)),r.refresh&&t.searchParams.set("refresh","1");const s=await fetch(t.toString(),{headers:{Accept:"application/json"},cache:"no-store"}),m=await s.json().catch(()=>null);if(!s.ok){const p=s.status===404?a("sessions.error.outdated_app"):`Request failed with HTTP ${s.status}`,y=new Error(m?.error||p);throw y.status=s.status,y}return m}const X=Le(),Oe=[],z=100,Ae=[{id:"all",label:()=>a("sessions.filter.source_all")},{id:"claude",label:()=>"Claude Code"},{id:"codex",label:()=>"Codex"},{id:"grok",label:()=>"Grok"}],oe=[{id:"all",days:0,label:()=>a("sessions.filter.range_all")},{id:"7d",days:7,label:()=>a("sessions.filter.range_7d")},{id:"30d",days:30,label:()=>a("sessions.filter.range_30d")},{id:"90d",days:90,label:()=>a("sessions.filter.range_90d")}];function Ue(r){const t=oe.find(m=>m.id===r)?.days||0;if(!t)return 0;const s=new Date;return s.setDate(s.getDate()-(t-1)),s.setHours(0,0,0,0),s.getTime()}function qe(r,t){if(!t)return!0;const s=Date.parse(r.ended_at||r.started_at||"");return Number.isFinite(s)?s>=t:!0}function B(r){const t=Array.isArray(r?.model_usage)?r.model_usage.filter(s=>s&&typeof s.model=="string"&&s.model):[];return t.length?t:[{model:r?.model||a("sessions.model.unknown"),total_tokens:Number(r?.own_total_tokens||r?.total_tokens||0)}]}function Be(r){const t=B(r);return t.length===1?t[0].model:t.map(s=>`${s.model} ${x(Number(s.total_tokens||0))}`).join(" · ")}function Ge(r,t){if(!r)return"—";const s=Date.parse(r);if(!Number.isFinite(s))return"—";try{return new Date(s).toLocaleString(t||void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return new Date(s).toISOString().slice(0,16).replace("T"," ")}}function He(r){const t=Number(r);if(!Number.isFinite(t)||t<=0)return null;const s=Math.round(t/6e4);if(s<60)return a("sessions.duration.minutes",{minutes:s});const m=Math.floor(s/60),p=s%60;return a("sessions.duration.hours",{hours:m,minutes:p})}async function J(r){if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(r),!0;const t=document.createElement("textarea");t.value=r,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const s=document.execCommand("copy");return document.body.removeChild(t),s}const Y=te.memo(function({session:t,locale:s,nested:m=!1,childCount:p=0,expanded:y=!1,onToggle:u}){const{currency:j,rate:k}=Me(),w=String(t.source||"").toUpperCase(),f=He(t.duration_ms),b=t.resume_command,h=t.project_key||a("sessions.project.unknown"),D=m||t.thread_kind==="subagent",g=D?t.agent_nickname||t.agent_role||t.title||h:t.title||h,_=!!(t.title&&t.project_key),N=String(t.source||"").toLowerCase()==="grok",C=N&&t.usage_precision?a("sessions.grok.token_breakdown",{input:x(t.input_tokens),cacheRead:x(t.cached_input_tokens),cacheWrite:x(t.cache_creation_input_tokens),output:x(t.output_tokens),reasoning:x(t.reasoning_output_tokens)}):null,U=N&&t.usage_precision?a("sessions.grok.runtime_breakdown",{calls:x(t.model_calls),seconds:(Number(t.api_duration_ms||0)/1e3).toFixed(1),tools:x(t.tool_calls),errors:x(t.error_count)}):null,S=N&&Number(t.context_window_tokens)>0?a("sessions.grok.context_breakdown",{used:x(t.context_tokens_used),window:x(t.context_window_tokens),percent:Number(t.context_usage_percent||0).toFixed(0)}):null,I=t.project_ref?`${t.project_ref}
2
- ${a("sessions.project.copy_hint")}`:void 0,E=async()=>{if(t.project_ref)try{await J(t.project_ref)?q({title:a("sessions.project.copied")}):q({title:a("sessions.project.copy_failed")})}catch{q({title:a("sessions.project.copy_failed")})}},M=L=>e.jsxs("span",{className:"group relative inline-flex min-w-0 max-w-full",children:[e.jsx(Se,{text:I,placement:"bottom"}),e.jsx("button",{type:"button",onClick:E,"aria-label":a("sessions.project.copy_aria",{project:h}),className:F("max-w-full truncate rounded text-left underline decoration-dotted decoration-oai-gray-300 underline-offset-4 hover:decoration-oai-gray-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:decoration-oai-gray-600 dark:hover:decoration-oai-gray-400",L),children:h})]}),P=async()=>{if(b)try{await J(b)?q({title:a("sessions.resume.copied")}):q({title:a("sessions.resume.copy_failed")})}catch{q({title:a("sessions.resume.copy_failed")})}};return e.jsxs("li",{className:F("flex flex-col gap-3 py-4 sm:flex-row sm:items-start",m&&"ml-6 border-l-2 border-oai-gray-200 pl-4 dark:border-oai-gray-800"),children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2.5",children:[e.jsx("span",{className:"mt-0.5 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",children:e.jsx(Ce,{provider:w,size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[!D&&!t.title&&t.project_ref?M("font-medium text-oai-black dark:text-white"):e.jsx("span",{className:"truncate font-medium text-oai-black dark:text-white",children:g}),D?e.jsxs("span",{className:"inline-flex items-center rounded-full bg-sky-50 px-2 py-0.5 text-[11px] font-medium text-sky-700 dark:bg-sky-500/10 dark:text-sky-300",children:[a("sessions.badge.subagent"),t.agent_role?` · ${t.agent_role}`:""]}):null,t.first_pass?e.jsx("span",{className:"inline-flex items-center rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-300",children:a("sessions.badge.first_pass")}):null,N&&t.usage_precision||t.cost_is_partial?e.jsx("span",{className:F("inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium",t.usage_is_incomplete||t.cost_is_partial?"bg-amber-50 text-amber-700 dark:bg-amber-500/10 dark:text-amber-300":"bg-sky-50 text-sky-700 dark:bg-sky-500/10 dark:text-sky-300"),children:t.usage_is_incomplete?a("sessions.badge.partial_usage"):t.cost_is_partial?a("sessions.badge.partial_cost"):t.cost_source==="provider_reported"?a("sessions.badge.reported_cost"):a("sessions.badge.reported_usage")}):null,p?e.jsx("button",{type:"button",onClick:u,"aria-expanded":y,className:"inline-flex items-center rounded-full border border-oai-gray-200 px-2 py-0.5 text-[11px] font-medium text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:y?a("sessions.thread.collapse",{count:p}):a("sessions.thread.expand",{count:p})}):null]}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[_?e.jsxs(e.Fragment,{children:[t.project_ref?M("hover:text-oai-black dark:hover:text-white"):e.jsx("span",{className:"truncate",children:h}),e.jsx("span",{"aria-hidden":!0,children:"·"})]}):null,e.jsx("span",{className:"truncate",children:Be(t)}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:Ge(t.started_at,s)}),f?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:f})]}):null]}),C?e.jsx("div",{className:"mt-1 text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:C}):null,U?e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 text-[11px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("span",{children:U}),S?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:S})]}):null]}):null]})]}),e.jsxs("div",{className:"flex items-start gap-5 pl-[30px] sm:pl-0",children:[e.jsxs("dl",{className:"flex items-start gap-6 text-right",children:[e.jsxs("div",{className:"flex w-16 flex-col-reverse",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.tokens")}),e.jsxs("dd",{title:Number(t.subagent_total_tokens)?a("sessions.thread.tokens_summary",{own:x(t.own_total_tokens),subagents:x(t.subagent_total_tokens),combined:x(t.combined_total_tokens)}):void 0,className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:[x(t.total_tokens),Number(t.subagent_total_tokens)?e.jsxs("span",{className:"block text-[9px] font-normal text-oai-gray-400 dark:text-oai-gray-500",children:["Σ ",x(t.combined_total_tokens)]}):null]})]}),e.jsxs("div",{className:"flex w-16 flex-col-reverse",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.cost")}),e.jsxs("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",title:t.cost_is_partial?a("sessions.cost.partial_title"):void 0,children:[t.cost_is_partial?"≥":"",pe(t.cost_usd,{currency:j,rate:k})]})]}),e.jsxs("div",{className:"hidden w-10 flex-col-reverse sm:flex",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.turns")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:x(t.turns)})]}),e.jsxs("div",{className:"hidden w-10 flex-col-reverse sm:flex",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.edits")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:x(t.edit_turns)})]})]}),e.jsxs("button",{type:"button",onClick:P,disabled:!b,title:b||a("sessions.resume.unavailable"),"aria-label":b?a("sessions.resume.copy_aria",{command:b}):a("sessions.resume.unavailable"),className:F("-mt-0.5 inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",b?"text-oai-gray-500 hover:bg-oai-gray-100 hover:text-oai-black dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white":"cursor-not-allowed text-oai-gray-300 dark:text-oai-gray-600"),children:[e.jsx(Te,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"hidden sm:inline",children:a("sessions.resume.copy")})]})]})]})});function ze({sessions:r,selectedModel:t,onSelect:s}){const{groups:m,totalTokens:p}=i.useMemo(()=>{const u=new Map;let j=0;for(const k of r)for(const w of B(k)){const f=w.model||a("sessions.model.unknown"),b=Number(w.total_tokens||0),h=u.get(f)||{model:f,count:0,tokens:0};h.count+=1,h.tokens+=b,j+=b,u.set(f,h)}return{groups:[...u.values()].sort((k,w)=>w.tokens-k.tokens),totalTokens:j}},[r]);function y(u){return F("rounded-full border px-2.5 py-1 text-xs tabular-nums transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",u?"border-oai-brand-500 bg-oai-brand-50 text-oai-brand-700 dark:bg-oai-brand-500/10 dark:text-oai-brand-300":"border-oai-gray-200 text-oai-gray-600 hover:bg-oai-gray-100 dark:border-oai-gray-700 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800")}return e.jsx("li",{className:"ml-6 border-l-2 border-oai-gray-200 py-3 pl-4 dark:border-oai-gray-800",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"mr-1 text-xs font-medium text-oai-gray-500 dark:text-oai-gray-400",children:a("sessions.thread.model_usage")}),e.jsx("button",{type:"button","aria-pressed":t==="all",onClick:()=>s("all"),className:y(t==="all"),children:a("sessions.thread.model_all",{count:r.length,tokens:x(p)})}),m.map(u=>e.jsx("button",{type:"button","aria-pressed":t===u.model,onClick:()=>s(u.model),className:y(t===u.model),children:a("sessions.thread.model_item",{model:u.model,count:u.count,tokens:x(u.tokens)})},u.model))]})})}function ct(){const[r,t]=i.useState(null),[s,m]=i.useState(null),[p,y]=i.useState(!0),[u,j]=i.useState(!1),[k,w]=i.useState("all"),[f,b]=i.useState("all"),[h,D]=i.useState("all"),[g,_]=i.useState(""),[N,C]=i.useState(z),[U,S]=i.useState(()=>new Set),[I,E]=i.useState(()=>new Map),M=i.useRef(0),{resolvedLocale:P}=me(),L=i.useCallback(async(o=!1)=>{const d=++M.current;o?j(!0):y(!0),m(null);try{const n=await $e({refresh:o});d===M.current&&t(n)}catch(n){d===M.current&&m(n?.message||String(n))}finally{d===M.current&&(y(!1),j(!1))}},[]);i.useEffect(()=>{X||Z()?L(!1):y(!1)},[L]);const l=r?.sessions||Oe,v=i.useMemo(()=>{const o=new Set,d=[];for(const n of l){const c=n.project_key;!c||o.has(c)||(o.add(c),d.push({value:c,label:c}))}return d.sort((n,c)=>n.label.localeCompare(c.label))},[l]),$=i.useDeferredValue(g),R=i.useMemo(()=>{const o=$.trim().toLowerCase(),d=Ue(f);return l.filter(n=>{if(k!=="all"&&n.source!==k||h!=="all"&&n.project_key!==h||!qe(n,d))return!1;if(!o)return!0;const c=B(n).map(T=>T.model).join(" ");return`${n.title||""} ${n.project_key||""} ${c} ${n.agent_nickname||""} ${n.agent_role||""} ${n.project_ref||""} ${n.session_id||""}`.toLowerCase().includes(o)})},[l,k,h,f,$]),O=i.useMemo(()=>{const o=new Set(R.map(c=>c.session_hash)),d=new Map,n=[];for(const c of R){const A=c.root_session_hash||c.parent_session_hash;if(c.parent_session_hash&&A&&o.has(A)){const T=d.get(A)||[];T.push(c),d.set(A,T)}else n.push(c)}return{roots:n,childrenByRoot:d,foldedCount:R.length-n.length}},[R]),Q=k!=="all"||f!=="all"||h!=="all"||g.trim()!=="";i.useEffect(()=>{C(z),S(new Set),E(new Map)},[k,h,f,$,l]);const K=i.useMemo(()=>O.roots.slice(0,N),[O.roots,N]),G=O.roots.length>K.length,H=i.useCallback(()=>C(o=>o+z),[]),ne=i.useCallback(o=>{S(d=>{const n=new Set(d);return n.has(o)?n.delete(o):n.add(o),n})},[]),ie=i.useCallback((o,d)=>{E(n=>{const c=new Map(n);return d==="all"?c.delete(o):c.set(o,d),c})},[]),W=i.useRef(null);i.useEffect(()=>{if(!G||typeof IntersectionObserver>"u")return;const o=W.current;if(!o)return;const d=new IntersectionObserver(n=>{n.some(c=>c.isIntersecting)&&H()},{rootMargin:"400px"});return d.observe(o),()=>d.disconnect()},[G,H]);const le=i.useMemo(()=>Ae.map(o=>({id:o.id,label:o.label()})),[P]),ce=i.useMemo(()=>oe.map(o=>({id:o.id,label:o.label()})),[P]),de=Number(r?.session_count)>Number(r?.returned_count);return!X&&!Z()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(fe,{})}):e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-8 flex flex-row items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"mb-3 text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("nav.sessions")}),e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:a("sessions.page.subtitle")})]}),e.jsx("button",{type:"button",onClick:()=>{L(!0)},disabled:u||p,"aria-label":a("sessions.page.refresh"),title:a("sessions.page.refresh"),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-oai-gray-200 text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:e.jsx(he,{className:F("h-4 w-4",u&&"animate-spin"),"aria-hidden":!0})})]}),e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 pt-1 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx(V,{ariaLabel:a("sessions.filter.source_aria"),options:le,value:k,onChange:w}),e.jsx(V,{className:"pl-2",ariaLabel:a("sessions.filter.range_aria"),leading:e.jsx(De,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),options:ce,value:f,onChange:b}),e.jsx(Pe,{options:v,value:h,onChange:D,allLabel:a("sessions.filter.project_all"),searchPlaceholder:a("sessions.filter.project_search"),emptyLabel:a("sessions.filter.project_empty"),ariaLabel:a("sessions.filter.project_aria")}),e.jsxs("div",{className:"relative w-72 max-w-full",children:[e.jsx(ae,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx(be,{type:"search",value:g,onChange:o=>_(o.target.value),onKeyDown:o=>{o.key==="Escape"&&g&&(o.preventDefault(),_(""))},"aria-label":a("sessions.action.search_aria"),placeholder:a("sessions.search.placeholder"),className:"h-8 pl-9 pr-8 !border-oai-gray-200 dark:!border-oai-gray-800 focus:!border-oai-gray-400 focus:!ring-oai-gray-400/20 dark:focus:!border-oai-gray-500 dark:focus:!ring-oai-gray-500/20 [&::-webkit-search-cancel-button]:appearance-none"}),e.jsx("button",{type:"button",onMouseDown:o=>o.preventDefault(),onClick:()=>_(""),"aria-label":a("sessions.action.search_clear"),"aria-hidden":!g,tabIndex:g?0:-1,className:F("absolute right-2 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-full text-oai-gray-400 transition duration-150 ease-out hover:bg-oai-gray-100 hover:text-oai-gray-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-400/40 dark:hover:bg-oai-gray-800 dark:hover:text-oai-gray-200",g?"scale-100 opacity-100":"pointer-events-none scale-90 opacity-0"),children:e.jsx(ge,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:O.foldedCount>0?a("sessions.thread.result_count",{roots:O.roots.length,subagents:O.foldedCount}):a("sessions.filter.result_count",{filtered:R.length,total:l.length})})]}),de?e.jsx("p",{className:"mb-4 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a("sessions.truncated",{shown:r.returned_count,total:r.session_count})}):null,s&&!r?e.jsxs("div",{className:"rounded-xl border border-dashed border-red-300 py-16 text-center dark:border-red-500/40",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:a("sessions.error.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s}),e.jsx("button",{type:"button",onClick:()=>{L(!1)},className:"mt-4 inline-flex h-8 items-center rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:text-oai-gray-200 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:a("sessions.error.retry")})]}):p?e.jsxs("div",{className:"flex items-center gap-2 py-16 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(Re,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),a("sessions.loading")]}):R.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-oai-gray-200 py-16 text-center dark:border-oai-gray-800",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:Q?a("sessions.empty.filtered_title"):a("sessions.empty.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:Q?a("sessions.empty.filtered_body"):a("sessions.empty.body")})]}):e.jsxs(e.Fragment,{children:[s?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:a("shared.error.prefix",{error:s})}):null,e.jsx("ul",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:K.map(o=>{const d=O.childrenByRoot.get(o.session_hash)||[],n=U.has(o.session_hash),c=I.get(o.session_hash)||"all",A=c==="all"?d:d.filter(function(ue){return B(ue).some(xe=>xe.model===c)});return e.jsxs(te.Fragment,{children:[e.jsx(Y,{session:o,locale:P,childCount:d.length,expanded:n,onToggle:()=>ne(o.session_hash)}),n&&d.length?e.jsx(ze,{sessions:d,selectedModel:c,onSelect:T=>ie(o.session_hash,T)}):null,n?A.map(T=>e.jsx(Y,{session:T,locale:P,nested:!0},T.session_hash)):null]},o.session_hash)})}),G?e.jsx("div",{ref:W,className:"flex justify-center pt-6",children:e.jsx("button",{type:"button",onClick:H,className:"inline-flex h-8 items-center rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:a("sessions.action.load_more")})}):null]}),e.jsx("p",{className:"mt-6 text-xs text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.privacy")})]})})})}export{ct as SessionsPage};
1
+ import{m as ee,r as i,j as e,e as F,c as a,J as me,H as Z,R as he,X as ge,d as te,l as x,a7 as pe,a8 as q}from"./__vite-browser-external-4IDwIR3i.js";import{L as fe,I as be}from"./LocalOnlyNotice-CpGpv1oF.js";import{S as J}from"./SegmentedControl-CMWf089j.js";import{C as ye}from"./ToolbarRootContext-B3pyxVI-.js";import{S as ae}from"./search-Bu5sWW2G.js";import{C as ke}from"./check-Dz72GL-k.js";import{P as _e,a as ve,b as je,c as we,d as Ne}from"./PopoverPopup-C4_m01Pc.js";import{P as Ce}from"./ProviderIcon-LgUYzw52.js";import{H as Se}from"./HoverTooltip--hTrUe1c.js";import{u as Me}from"./useCurrency-CyksuFrj.js";import{i as Le}from"./host-mode-Bc_iTzHk.js";import{L as Re}from"./loader-circle-BglSN88W.js";import{T as Te}from"./terminal-CRqmFLSX.js";import"./arrow-up-right-BbkRcWv3.js";import"./download-W7dmHuLF.js";import"./composite-COAFYYB2.js";import"./store-DdObzMvx.js";const re={name:"calendar",size:24,node:[["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M16 2v3",key:"otl347"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M3 9h18",key:"1pudct"}]]};re.node;const De=ee(re);const se={name:"folder",size:24,node:[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]};se.node;const Ie=ee(se),Ee="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-sm text-oai-black outline-none hover:bg-oai-gray-100 dark:text-white dark:hover:bg-oai-gray-800";function Pe({options:r,value:t,onChange:s,allValue:m="all",allLabel:p,searchPlaceholder:y,emptyLabel:u,ariaLabel:j,disabled:k=!1,className:w=""}){const[f,b]=i.useState(!1),[h,D]=i.useState(""),[g,_]=i.useState(-1),N=i.useRef(null),C=`${i.useId()}-listbox`,U=t===m?p:r.find(l=>l.value===t)?.label??t,S=h.trim().toLowerCase(),I=i.useMemo(()=>S?r.filter(l=>l.label.toLowerCase().includes(S)):r,[r,S]),E=i.useMemo(()=>[{value:m,label:p},...I],[m,p,I]),M=g>=0&&g<E.length?E[g]:null,P=l=>{s(l),b(!1),D(""),_(-1)};i.useEffect(()=>{f&&N.current?.querySelector('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[f,g]);const L=l=>{if(l.key==="ArrowDown"||l.key==="ArrowUp"){l.preventDefault();const v=l.key==="ArrowDown";_($=>{const R=E.length;return R?v?$>=R-1?0:$+1:$<=0?R-1:$-1:-1});return}if(l.key==="Enter"){const v=M||(S&&I.length?I[0]:null);if(!v)return;l.preventDefault(),P(v.value)}};return e.jsxs(_e,{open:f,onOpenChange:l=>{b(l),_(-1),l||D("")},children:[e.jsxs(ve,{disabled:k,"aria-label":j,className:F("inline-flex h-8 max-w-[12rem] shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 bg-oai-white px-2.5 text-xs font-medium transition hover:border-oai-gray-300 focus:outline-none focus:ring-2 focus:ring-oai-gray-400/30 disabled:opacity-60 data-[popup-open]:border-oai-gray-300 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:hover:border-oai-gray-700",t!==m?"text-oai-black dark:text-white":"text-oai-gray-700 dark:text-oai-gray-200",w),children:[e.jsx(Ie,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:U}),e.jsx(ye,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0})]}),e.jsx(je,{children:e.jsx(we,{sideOffset:4,side:"bottom",align:"start",className:"z-[60]",children:e.jsxs(Ne,{className:"w-56 overflow-hidden rounded-md border border-oai-gray-200 bg-white p-1 shadow-[0_12px_32px_-12px_rgba(0,0,0,0.18)] outline-none dark:border-oai-gray-800 dark:bg-oai-gray-950 dark:shadow-[0_12px_32px_-12px_rgba(0,0,0,0.6)]",children:[e.jsxs("div",{className:"relative mb-1",children:[e.jsx(ae,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{type:"text",role:"combobox","aria-expanded":!0,"aria-controls":C,"aria-activedescendant":M?`${C}-${g}`:void 0,value:h,onChange:l=>{D(l.target.value),_(-1)},onKeyDown:L,placeholder:y,className:"h-8 w-full rounded border border-oai-gray-200 bg-transparent pl-8 pr-2 text-xs text-oai-black outline-none placeholder:text-oai-gray-400 focus:border-oai-gray-400 dark:border-oai-gray-800 dark:text-white dark:focus:border-oai-gray-500"})]}),e.jsxs("div",{ref:N,id:C,role:"listbox","aria-label":j,className:"max-h-64 overflow-y-auto",children:[E.map((l,v)=>e.jsxs("button",{id:`${C}-${v}`,type:"button",role:"option","aria-selected":t===l.value,"data-active":v===g?"true":void 0,onMouseEnter:()=>_(v),onClick:()=>P(l.value),className:F(Ee,t===l.value&&"bg-oai-gray-100 dark:bg-oai-gray-800",v===g&&"ring-1 ring-inset ring-oai-gray-300 dark:ring-oai-gray-600"),children:[e.jsx("span",{className:"flex-1 truncate",children:l.label}),t===l.value?e.jsx(ke,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null]},l.value)),I.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-oai-gray-400 dark:text-oai-gray-500",children:u}):null]})]})})})]})}const Fe="tokentracker-sessions";async function $e(r={}){const t=new URL(`/functions/${Fe}`,window.location.origin);r.from&&t.searchParams.set("from",r.from),r.to&&t.searchParams.set("to",r.to),r.limit&&t.searchParams.set("limit",String(r.limit)),r.refresh&&t.searchParams.set("refresh","1");const s=await fetch(t.toString(),{headers:{Accept:"application/json"},cache:"no-store"}),m=await s.json().catch(()=>null);if(!s.ok){const p=s.status===404?a("sessions.error.outdated_app"):`Request failed with HTTP ${s.status}`,y=new Error(m?.error||p);throw y.status=s.status,y}return m}const V=Le(),Oe=[],z=100,Ae=[{id:"all",label:()=>a("sessions.filter.source_all")},{id:"claude",label:()=>"Claude Code"},{id:"codex",label:()=>"Codex"},{id:"grok",label:()=>"Grok"}],oe=[{id:"all",days:0,label:()=>a("sessions.filter.range_all")},{id:"7d",days:7,label:()=>a("sessions.filter.range_7d")},{id:"30d",days:30,label:()=>a("sessions.filter.range_30d")},{id:"90d",days:90,label:()=>a("sessions.filter.range_90d")}];function Ue(r){const t=oe.find(m=>m.id===r)?.days||0;if(!t)return 0;const s=new Date;return s.setDate(s.getDate()-(t-1)),s.setHours(0,0,0,0),s.getTime()}function qe(r,t){if(!t)return!0;const s=Date.parse(r.ended_at||r.started_at||"");return Number.isFinite(s)?s>=t:!0}function H(r){const t=Array.isArray(r?.model_usage)?r.model_usage.filter(s=>s&&typeof s.model=="string"&&s.model):[];return t.length?t:[{model:r?.model||a("sessions.model.unknown"),total_tokens:Number(r?.own_total_tokens||r?.total_tokens||0)}]}function He(r){const t=H(r);return t.length===1?t[0].model:t.map(s=>`${s.model} ${x(Number(s.total_tokens||0))}`).join(" · ")}function Be(r,t){if(!r)return"—";const s=Date.parse(r);if(!Number.isFinite(s))return"—";try{return new Date(s).toLocaleString(t||void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return new Date(s).toISOString().slice(0,16).replace("T"," ")}}function Ge(r){const t=Number(r);if(!Number.isFinite(t)||t<=0)return null;const s=Math.round(t/6e4);if(s<60)return a("sessions.duration.minutes",{minutes:s});const m=Math.floor(s/60),p=s%60;return a("sessions.duration.hours",{hours:m,minutes:p})}async function X(r){if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(r),!0;const t=document.createElement("textarea");t.value=r,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const s=document.execCommand("copy");return document.body.removeChild(t),s}const Y=te.memo(function({session:t,locale:s,nested:m=!1,childCount:p=0,expanded:y=!1,onToggle:u}){const{currency:j,rate:k}=Me(),w=String(t.source||"").toUpperCase(),f=Ge(t.duration_ms),b=t.resume_command,h=t.project_key||a("sessions.project.unknown"),D=m||t.thread_kind==="subagent",g=D?t.agent_nickname||t.agent_role||t.title||h:t.title||h,_=!!(t.title&&t.project_key),N=String(t.source||"").toLowerCase()==="grok",C=N&&t.usage_precision?a("sessions.grok.token_breakdown",{input:x(t.input_tokens),cacheRead:x(t.cached_input_tokens),cacheWrite:x(t.cache_creation_input_tokens),output:x(t.output_tokens),reasoning:x(t.reasoning_output_tokens)}):null,U=N&&t.usage_precision?a("sessions.grok.runtime_breakdown",{calls:x(t.model_calls),seconds:(Number(t.api_duration_ms||0)/1e3).toFixed(1),tools:x(t.tool_calls),errors:x(t.error_count)}):null,S=N&&Number(t.context_window_tokens)>0?a("sessions.grok.context_breakdown",{used:x(t.context_tokens_used),window:x(t.context_window_tokens),percent:Number(t.context_usage_percent||0).toFixed(0)}):null,I=t.project_ref?`${t.project_ref}
2
+ ${a("sessions.project.copy_hint")}`:void 0,E=async()=>{if(t.project_ref)try{await X(t.project_ref)?q({title:a("sessions.project.copied")}):q({title:a("sessions.project.copy_failed")})}catch{q({title:a("sessions.project.copy_failed")})}},M=L=>e.jsxs("span",{className:"group relative inline-flex min-w-0 max-w-full",children:[e.jsx(Se,{text:I,placement:"bottom"}),e.jsx("button",{type:"button",onClick:E,"aria-label":a("sessions.project.copy_aria",{project:h}),className:F("max-w-full truncate rounded text-left underline decoration-dotted decoration-oai-gray-300 underline-offset-4 hover:decoration-oai-gray-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:decoration-oai-gray-600 dark:hover:decoration-oai-gray-400",L),children:h})]}),P=async()=>{if(b)try{await X(b)?q({title:a("sessions.resume.copied")}):q({title:a("sessions.resume.copy_failed")})}catch{q({title:a("sessions.resume.copy_failed")})}};return e.jsxs("li",{className:F("flex flex-col gap-3 py-4 sm:flex-row sm:items-start",m&&"ml-6 border-l-2 border-oai-gray-200 pl-4 dark:border-oai-gray-800"),children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2.5",children:[e.jsx("span",{className:"mt-0.5 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",children:e.jsx(Ce,{provider:w,size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[!D&&!t.title&&t.project_ref?M("font-medium text-oai-black dark:text-white"):e.jsx("span",{className:"truncate font-medium text-oai-black dark:text-white",children:g}),D?e.jsxs("span",{className:"inline-flex items-center rounded-full bg-sky-50 px-2 py-0.5 text-[11px] font-medium text-sky-700 dark:bg-sky-500/10 dark:text-sky-300",children:[a("sessions.badge.subagent"),t.agent_role?` · ${t.agent_role}`:""]}):null,t.first_pass?e.jsx("span",{className:"inline-flex items-center rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-300",children:a("sessions.badge.first_pass")}):null,N&&t.usage_precision||t.cost_is_partial?e.jsx("span",{className:F("inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium",t.usage_is_incomplete||t.cost_is_partial?"bg-amber-50 text-amber-700 dark:bg-amber-500/10 dark:text-amber-300":"bg-sky-50 text-sky-700 dark:bg-sky-500/10 dark:text-sky-300"),children:t.usage_is_incomplete?a("sessions.badge.partial_usage"):t.cost_is_partial?a("sessions.badge.partial_cost"):t.cost_source==="provider_reported"?a("sessions.badge.reported_cost"):a("sessions.badge.reported_usage")}):null,p?e.jsx("button",{type:"button",onClick:u,"aria-expanded":y,className:"inline-flex items-center rounded-full border border-oai-gray-200 px-2 py-0.5 text-[11px] font-medium text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:y?a("sessions.thread.collapse",{count:p}):a("sessions.thread.expand",{count:p})}):null]}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[_?e.jsxs(e.Fragment,{children:[t.project_ref?M("hover:text-oai-black dark:hover:text-white"):e.jsx("span",{className:"truncate",children:h}),e.jsx("span",{"aria-hidden":!0,children:"·"})]}):null,e.jsx("span",{className:"truncate",children:He(t)}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:Be(t.started_at,s)}),f?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:f})]}):null]}),C?e.jsx("div",{className:"mt-1 text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:C}):null,U?e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 text-[11px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("span",{children:U}),S?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:S})]}):null]}):null]})]}),e.jsxs("div",{className:"flex items-start gap-5 pl-[30px] sm:pl-0",children:[e.jsxs("dl",{className:"flex items-start gap-6 text-right",children:[e.jsxs("div",{className:"flex w-16 flex-col-reverse",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.tokens")}),e.jsxs("dd",{title:Number(t.subagent_total_tokens)?a("sessions.thread.tokens_summary",{own:x(t.own_total_tokens),subagents:x(t.subagent_total_tokens),combined:x(t.combined_total_tokens)}):void 0,className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:[x(t.total_tokens),Number(t.subagent_total_tokens)?e.jsxs("span",{className:"block text-[9px] font-normal text-oai-gray-400 dark:text-oai-gray-500",children:["Σ ",x(t.combined_total_tokens)]}):null]})]}),e.jsxs("div",{className:"flex w-16 flex-col-reverse",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.cost")}),e.jsxs("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",title:t.cost_is_partial?a("sessions.cost.partial_title"):void 0,children:[t.cost_is_partial?"≥":"",pe(t.cost_usd,{currency:j,rate:k})]})]}),e.jsxs("div",{className:"hidden w-10 flex-col-reverse sm:flex",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.turns")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:x(t.turns)})]}),e.jsxs("div",{className:"hidden w-10 flex-col-reverse sm:flex",children:[e.jsx("dt",{className:"text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.col.edits")}),e.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:x(t.edit_turns)})]})]}),e.jsxs("button",{type:"button",onClick:P,disabled:!b,title:b||a("sessions.resume.unavailable"),"aria-label":b?a("sessions.resume.copy_aria",{command:b}):a("sessions.resume.unavailable"),className:F("-mt-0.5 inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",b?"text-oai-gray-500 hover:bg-oai-gray-100 hover:text-oai-black dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white":"cursor-not-allowed text-oai-gray-300 dark:text-oai-gray-600"),children:[e.jsx(Te,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"hidden sm:inline",children:a("sessions.resume.copy")})]})]})]})});function ze({sessions:r,selectedModel:t,onSelect:s}){const{groups:m,totalTokens:p}=i.useMemo(()=>{const u=new Map;let j=0;for(const k of r)for(const w of H(k)){const f=w.model||a("sessions.model.unknown"),b=Number(w.total_tokens||0),h=u.get(f)||{model:f,count:0,tokens:0};h.count+=1,h.tokens+=b,j+=b,u.set(f,h)}return{groups:[...u.values()].sort((k,w)=>w.tokens-k.tokens),totalTokens:j}},[r]);function y(u){return F("rounded-full border px-2.5 py-1 text-xs tabular-nums transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",u?"border-oai-brand-500 bg-oai-brand-50 text-oai-brand-700 dark:bg-oai-brand-500/10 dark:text-oai-brand-300":"border-oai-gray-200 text-oai-gray-600 hover:bg-oai-gray-100 dark:border-oai-gray-700 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800")}return e.jsx("li",{className:"ml-6 border-l-2 border-oai-gray-200 py-3 pl-4 dark:border-oai-gray-800",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"mr-1 text-xs font-medium text-oai-gray-500 dark:text-oai-gray-400",children:a("sessions.thread.model_usage")}),e.jsx("button",{type:"button","aria-pressed":t==="all",onClick:()=>s("all"),className:y(t==="all"),children:a("sessions.thread.model_all",{count:r.length,tokens:x(p)})}),m.map(u=>e.jsx("button",{type:"button","aria-pressed":t===u.model,onClick:()=>s(u.model),className:y(t===u.model),children:a("sessions.thread.model_item",{model:u.model,count:u.count,tokens:x(u.tokens)})},u.model))]})})}function ct(){const[r,t]=i.useState(null),[s,m]=i.useState(null),[p,y]=i.useState(!0),[u,j]=i.useState(!1),[k,w]=i.useState("all"),[f,b]=i.useState("all"),[h,D]=i.useState("all"),[g,_]=i.useState(""),[N,C]=i.useState(z),[U,S]=i.useState(()=>new Set),[I,E]=i.useState(()=>new Map),M=i.useRef(0),{resolvedLocale:P}=me(),L=i.useCallback(async(o=!1)=>{const d=++M.current;o?j(!0):y(!0),m(null);try{const n=await $e({refresh:o});d===M.current&&t(n)}catch(n){d===M.current&&m(n?.message||String(n))}finally{d===M.current&&(y(!1),j(!1))}},[]);i.useEffect(()=>{V||Z()?L(!1):y(!1)},[L]);const l=r?.sessions||Oe,v=i.useMemo(()=>{const o=new Set,d=[];for(const n of l){const c=n.project_key;!c||o.has(c)||(o.add(c),d.push({value:c,label:c}))}return d.sort((n,c)=>n.label.localeCompare(c.label))},[l]),$=i.useDeferredValue(g),R=i.useMemo(()=>{const o=$.trim().toLowerCase(),d=Ue(f);return l.filter(n=>{if(k!=="all"&&n.source!==k||h!=="all"&&n.project_key!==h||!qe(n,d))return!1;if(!o)return!0;const c=H(n).map(T=>T.model).join(" ");return`${n.title||""} ${n.project_key||""} ${c} ${n.agent_nickname||""} ${n.agent_role||""} ${n.project_ref||""} ${n.session_id||""}`.toLowerCase().includes(o)})},[l,k,h,f,$]),O=i.useMemo(()=>{const o=new Set(R.map(c=>c.session_hash)),d=new Map,n=[];for(const c of R){const A=c.root_session_hash||c.parent_session_hash;if(c.parent_session_hash&&A&&o.has(A)){const T=d.get(A)||[];T.push(c),d.set(A,T)}else n.push(c)}return{roots:n,childrenByRoot:d,foldedCount:R.length-n.length}},[R]),Q=k!=="all"||f!=="all"||h!=="all"||g.trim()!=="";i.useEffect(()=>{C(z),S(new Set),E(new Map)},[k,h,f,$,l]);const K=i.useMemo(()=>O.roots.slice(0,N),[O.roots,N]),B=O.roots.length>K.length,G=i.useCallback(()=>C(o=>o+z),[]),ne=i.useCallback(o=>{S(d=>{const n=new Set(d);return n.has(o)?n.delete(o):n.add(o),n})},[]),ie=i.useCallback((o,d)=>{E(n=>{const c=new Map(n);return d==="all"?c.delete(o):c.set(o,d),c})},[]),W=i.useRef(null);i.useEffect(()=>{if(!B||typeof IntersectionObserver>"u")return;const o=W.current;if(!o)return;const d=new IntersectionObserver(n=>{n.some(c=>c.isIntersecting)&&G()},{rootMargin:"400px"});return d.observe(o),()=>d.disconnect()},[B,G]);const le=i.useMemo(()=>Ae.map(o=>({id:o.id,label:o.label()})),[P]),ce=i.useMemo(()=>oe.map(o=>({id:o.id,label:o.label()})),[P]),de=Number(r?.session_count)>Number(r?.returned_count);return!V&&!Z()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(fe,{})}):e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-8 flex flex-row items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"mb-3 text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("nav.sessions")}),e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:a("sessions.page.subtitle")})]}),e.jsx("button",{type:"button",onClick:()=>{L(!0)},disabled:u||p,"aria-label":a("sessions.page.refresh"),title:a("sessions.page.refresh"),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-oai-gray-200 text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:e.jsx(he,{className:F("h-4 w-4",u&&"animate-spin"),"aria-hidden":!0})})]}),e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 pt-1 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx(J,{ariaLabel:a("sessions.filter.source_aria"),options:le,value:k,onChange:w}),e.jsx(J,{className:"pl-2",ariaLabel:a("sessions.filter.range_aria"),leading:e.jsx(De,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),options:ce,value:f,onChange:b}),e.jsx(Pe,{options:v,value:h,onChange:D,allLabel:a("sessions.filter.project_all"),searchPlaceholder:a("sessions.filter.project_search"),emptyLabel:a("sessions.filter.project_empty"),ariaLabel:a("sessions.filter.project_aria")}),e.jsxs("div",{className:"relative w-72 max-w-full",children:[e.jsx(ae,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-oai-gray-400","aria-hidden":!0}),e.jsx(be,{type:"search",value:g,onChange:o=>_(o.target.value),onKeyDown:o=>{o.key==="Escape"&&g&&(o.preventDefault(),_(""))},"aria-label":a("sessions.action.search_aria"),placeholder:a("sessions.search.placeholder"),className:"h-8 pl-9 pr-8 !border-oai-gray-200 dark:!border-oai-gray-800 focus:!border-oai-gray-400 focus:!ring-oai-gray-400/20 dark:focus:!border-oai-gray-500 dark:focus:!ring-oai-gray-500/20 [&::-webkit-search-cancel-button]:appearance-none"}),e.jsx("button",{type:"button",onMouseDown:o=>o.preventDefault(),onClick:()=>_(""),"aria-label":a("sessions.action.search_clear"),"aria-hidden":!g,tabIndex:g?0:-1,className:F("absolute right-2 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-full text-oai-gray-400 transition duration-150 ease-out hover:bg-oai-gray-100 hover:text-oai-gray-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-400/40 dark:hover:bg-oai-gray-800 dark:hover:text-oai-gray-200",g?"scale-100 opacity-100":"pointer-events-none scale-90 opacity-0"),children:e.jsx(ge,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:O.foldedCount>0?a("sessions.thread.result_count",{roots:O.roots.length,subagents:O.foldedCount}):a("sessions.filter.result_count",{filtered:R.length,total:l.length})})]}),de?e.jsx("p",{className:"mb-4 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a("sessions.truncated",{shown:r.returned_count,total:r.session_count})}):null,s&&!r?e.jsxs("div",{className:"rounded-xl border border-dashed border-red-300 py-16 text-center dark:border-red-500/40",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:a("sessions.error.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:s}),e.jsx("button",{type:"button",onClick:()=>{L(!1)},className:"mt-4 inline-flex h-8 items-center rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:text-oai-gray-200 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:a("sessions.error.retry")})]}):p?e.jsxs("div",{className:"flex items-center gap-2 py-16 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(Re,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),a("sessions.loading")]}):R.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-oai-gray-200 py-16 text-center dark:border-oai-gray-800",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:Q?a("sessions.empty.filtered_title"):a("sessions.empty.title")}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:Q?a("sessions.empty.filtered_body"):a("sessions.empty.body")})]}):e.jsxs(e.Fragment,{children:[s?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:a("shared.error.prefix",{error:s})}):null,e.jsx("ul",{className:"divide-y divide-oai-gray-200/70 dark:divide-oai-gray-800/70",children:K.map(o=>{const d=O.childrenByRoot.get(o.session_hash)||[],n=U.has(o.session_hash),c=I.get(o.session_hash)||"all",A=c==="all"?d:d.filter(function(ue){return H(ue).some(xe=>xe.model===c)});return e.jsxs(te.Fragment,{children:[e.jsx(Y,{session:o,locale:P,childCount:d.length,expanded:n,onToggle:()=>ne(o.session_hash)}),n&&d.length?e.jsx(ze,{sessions:d,selectedModel:c,onSelect:T=>ie(o.session_hash,T)}):null,n?A.map(T=>e.jsx(Y,{session:T,locale:P,nested:!0},T.session_hash)):null]},o.session_hash)})}),B?e.jsx("div",{ref:W,className:"flex justify-center pt-6",children:e.jsx("button",{type:"button",onClick:G,className:"inline-flex h-8 items-center rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-600 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800 dark:hover:text-white",children:a("sessions.action.load_more")})}):null]}),e.jsx("p",{className:"mt-6 text-xs text-oai-gray-400 dark:text-oai-gray-500",children:a("sessions.privacy")})]})})})}export{ct as SessionsPage};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-4IDwIR3i.js","assets/__vite-browser-external-CAQ_i-1v.css"])))=>i.map(i=>d[i]);
2
+ import{m as I,j as t,e as _,c as n,a as ye,r as d,at as ve,az as ke,aA as je,ab as X,aY as Se,aZ as we,a_ as Ne,u as Ce,d as H,a2 as Ee,J as ee,o as U,a$ as V,n as B,b0 as Ae,b1 as Pe,Z as te,b2 as Oe,t as Le,b3 as _e,b4 as Te,b5 as Ie,b6 as Ge,b7 as Re,b8 as De,b9 as Ue,ba as ne,L as Me,R as He,bb as Fe,bc as $e,a8 as z,_ as Ve,h as Be,f as ze,bd as Ke,be as qe,aC as We}from"./__vite-browser-external-4IDwIR3i.js";import{a as Ze,b as K,s as Ye,K as Je,P as Qe,D as Xe,c as et,S as tt,v as nt,u as at,C as st}from"./sortable.esm-CLXvOgJi.js";import{a as it}from"./modifiers.esm-CsJhvsvC.js";import{d as q,l as W,u as ot,b as Z}from"./use-limits-display-prefs-CRg1sYpO.js";import{P as rt}from"./ProviderIcon-LgUYzw52.js";import{m as ae}from"./react-BseCgHfW.js";import{a as O,T as j,b,S as T,u as R}from"./Controls-Cup1Mj2U.js";import{P as lt,u as ct,a as ut}from"./use-session-efficiency-pref-aQVRBt9R.js";import{C as dt}from"./check-Dz72GL-k.js";import{C as gt}from"./copy-wEl0WhF0.js";import{A as se}from"./index-B1Am3t0P.js";import{u as pt}from"./useCurrency-CyksuFrj.js";import{u as ht}from"./useTokenFormat-CUwCluPw.js";import{S as F}from"./Select-BNFp1Pww.js";import{I as mt}from"./info-CCfzQ-S6.js";import{C as bt}from"./ConfirmModal-BQIPBiA5.js";import{A as ft}from"./arrow-up-right-BbkRcWv3.js";import{D as xt}from"./download-W7dmHuLF.js";import{i as yt}from"./host-mode-Bc_iTzHk.js";import"./Card-615UteEP.js";import"./ToolbarRootContext-B3pyxVI-.js";import"./composite-COAFYYB2.js";import"./SelectItemText-Jz-4OEyW.js";import"./DialogTitle-BViOiFtR.js";import"./store-DdObzMvx.js";import"./DialogDescription-DZLOEWil.js";const ie={name:"flask-conical",size:24,node:[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]};ie.node;const vt=I(ie);const oe={name:"grip-vertical",size:24,node:[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]};oe.node;const kt=I(oe);const re={name:"languages",size:24,node:[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]};re.node;const jt=I(re);const le={name:"log-out",size:24,node:[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]};le.node;const St=I(le);const ce={name:"palette",size:24,node:[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]]};ce.node;const wt=I(ce);const ue={name:"user-round",size:24,node:[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],aliases:["user-2"]};ue.node;const Nt=I(ue),Ct="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function Et({checked:e,onChange:a,ariaLabel:s}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,onClick:a,className:_("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:t.jsx("span",{className:_("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function At({id:e,visible:a,onToggle:s}){const{attributes:i,listeners:o,setNodeRef:r,transform:l,transition:c,isDragging:u}=at({id:e}),h={transform:st.Transform.toString(l)||void 0,transition:c,zIndex:u?20:void 0};return t.jsxs("div",{ref:r,style:h,className:_("flex items-center gap-3 py-2 rounded-md select-none touch-none","cursor-grab active:cursor-grabbing","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",u&&"relative bg-oai-gray-100 dark:bg-oai-gray-800"),...i,...o,children:[t.jsx(kt,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),q(e)?t.jsx(rt,{provider:q(e),size:18,className:_("pointer-events-none",Ct)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200",children:W(e)}),t.jsx("div",{onPointerDown:p=>p.stopPropagation(),children:t.jsx(Et,{checked:a,onChange:s,ariaLabel:`${n("limits.settings.toggle_visible")}: ${W(e)}`})})]})}function Pt({prefs:e}){const{order:a,visibility:s,toggle:i,moveToward:o}=e,r=Ze(K(Qe,{activationConstraint:{distance:6}}),K(Je,{coordinateGetter:Ye})),l=({active:c,over:u})=>{u&&c.id!==u.id&&o(c.id,u.id)};return t.jsx(Xe,{sensors:r,collisionDetection:et,modifiers:[it],onDragEnd:l,children:t.jsx(tt,{items:a,strategy:nt,children:t.jsx("div",{className:"flex flex-col",children:a.map(c=>t.jsx(At,{id:c,visible:s[c]!==!1,onToggle:()=>i(c)},c))})})})}function Ot(e){if(!e||typeof e!="object")return"";const a=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},s=e.profile&&typeof e.profile=="object"?e.profile:{},i=a.full_name||a.name||s.name||a.user_name||a.preferred_username;return typeof i=="string"&&i.trim()?i.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function Lt(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function _t(e){const a=typeof e=="string"?e.trim():"";if(!a)return null;const s=a.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),i=a.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=s?.[1]||i?.[1];return o?`https://github.com/${o}`:null}function $(e,a){console.warn(`[tokentracker] settings ${e}:`,a)}function Tt(e,a,s){const[i,o]=d.useState(()=>ve()),r=a&&s&&Ne(),l=d.useCallback(async()=>{const c=!i;if(ke(c),o(c),!!c)try{await je(()=>e())}catch(u){$("cloud sync",u)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:l,showLocalCloudSync:r}}function It(e){const[a,s]=d.useState(!1),[i,o]=d.useState(!1),[r,l]=d.useState(!1),[c,u]=d.useState(!1),[h,p]=d.useState(null),[g,m]=d.useState(!1),[v,k]=d.useState(""),[P,y]=d.useState(!1),[w,N]=d.useState(""),[f,S]=d.useState(""),[L,x]=d.useState(!1),[E,D]=d.useState(null),G=d.useMemo(()=>Ot(e),[e]),be=d.useMemo(()=>Lt(e),[e]),fe=d.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),xe=d.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:p,setGithubUrl:N,setProfileLoading:l,setPublicProfileOn:s,setShowGithubOn:y}),[]);return{anonymousOn:i,customDisplayName:h,displayName:G,editingGithub:L,editingName:g,email:be,githubError:E,githubInput:f,githubUrl:w,loadSetters:xe,nameInput:v,profileLoading:r,profileSaving:c,publicProfileOn:a,setAnonymousOn:o,setCustomDisplayName:p,setEditingGithub:x,setEditingName:m,setGithubError:D,setGithubInput:S,setGithubUrl:N,setNameInput:k,setProfileLoading:l,setProfileSaving:u,setPublicProfileOn:s,setShowGithubOn:y,showGithubOn:P,userId:fe}}function Gt(e,a,s){d.useEffect(()=>{if(!a)return;let i=!0;return s.setProfileLoading(!0),(async()=>{try{const o=await X({getAccessToken:e});if(!i||!o)return;const r=await Se({accessToken:o});if(!i)return;s.setPublicProfileOn(!!r?.enabled),s.setAnonymousOn(!!r?.anonymous),r?.display_name&&s.setCustomDisplayName(r.display_name),s.setShowGithubOn(!!r?.show_github_url),s.setGithubUrl(r?.github_url||"")}catch(o){$("load public profile",o)}finally{i&&s.setProfileLoading(!1)}})(),()=>{i=!1}},[e,a,s])}function Rt(e,a){return d.useCallback(async(s,{label:i,onError:o,onSuccess:r}={})=>{if(a.profileSaving)return!1;a.setProfileSaving(!0);try{const l=await X({getAccessToken:e});if(!l)return!1;const c=await we({accessToken:l,...s});return r?.(c),!0}catch(l){return o?o(l):$(i||"mutate profile",l),!1}finally{a.setProfileSaving(!1)}},[e,a])}function Dt(e,a){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:a.handleAnonymousToggle,handleSaveName:a.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:a.startEditingName}}function Ut(e,a){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:a.handleSaveGithub,handleShowGithubToggle:a.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:a.startEditingGithub}}function Mt(e,a){const s=d.useCallback(async()=>{const o=!e.publicProfileOn;await a({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[a,e]);return{handleAnonymousToggle:d.useCallback(async()=>{const o=!e.anonymousOn;await a({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[a,e]),handlePublicProfileToggle:s}}function Ht(e,a,s){const i=d.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await a({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),s?.()}})},[a,e,s]),o=d.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function Ft(e,a){const s=d.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await a({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[a,e]),i=d.useCallback(async()=>{const r=_t(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(n("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await a({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||n("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[a,e]),o=d.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:s,startEditingGithub:o}}function $t(){const e=ye(),a=It(e.user),s=Tt(e.getAccessToken,e.enabled,e.signedIn);Gt(e.getAccessToken,e.signedIn,a.loadSetters);const i=Rt(e.getAccessToken,a),o=Mt(a,i),r=Ht(a,i,e.refreshDisplayName),l=Ft(a,i);return{...e,...s,email:a.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:a.userId,name:Dt(a,{...o,...r}),github:Ut(a,l),profileLoading:a.profileLoading,profileSaving:a.profileSaving,publicProfileOn:a.publicProfileOn}}function de({disabled:e,onCancel:a,onSave:s,saveLabel:i=n("settings.account.save")}){return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:s,disabled:e,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:i}),t.jsx("button",{type:"button",onClick:a,className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:n("settings.account.cancel")})]})}function Vt({nameInput:e,setEditingName:a,setNameInput:s,profileSaving:i,handleSaveName:o}){return t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"text",value:e,onChange:r=>s(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&a(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:n("settings.account.displayName")}),t.jsx(de,{disabled:i||!e.trim(),onCancel:()=>a(!1),onSave:o,saveLabel:i?n("settings.account.saving"):void 0})]})}function Bt({githubError:e,githubInput:a,handleSaveGithub:s,profileSaving:i,setEditingGithub:o,setGithubError:r,setGithubInput:l}){return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:a,onChange:c=>{l(c.target.value),e&&r(null)},onKeyDown:c=>{c.key==="Enter"&&s(),c.key==="Escape"&&(o(!1),r(null))},maxLength:100,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:n("settings.account.githubUrlPlaceholder")}),t.jsx(de,{disabled:i,onCancel:()=>{o(!1),r(null)},onSave:s,saveLabel:i?n("settings.account.saving"):void 0})]}),e?t.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:e}):null]})}function ge({disabled:e=!1,label:a,onClick:s,title:i}){return t.jsxs("button",{type:"button",onClick:s,disabled:e,title:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(lt,{className:"h-3.5 w-3.5","aria-hidden":!0}),a]})}function pe({actions:e,editing:a,editor:s,hint:i,label:o}){return t.jsx("div",{className:"py-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:o}),a?s:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i})]}),a?null:e]})})}function zt({name:e}){const a=e.anonymousOn?n("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ge,{disabled:e.anonymousOn,label:n("settings.account.edit"),onClick:e.startEditingName,title:a}),t.jsx(j,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:n("settings.account.displayName")})]})}function Kt({name:e}){const{anonymousOn:a,customDisplayName:s,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:c,profileLoading:u,profileSaving:h,setEditingName:p,setNameInput:g,startEditingName:m}=e,v=a?n("settings.account.displayNameAnonymousHint"):s||i;return t.jsx(pe,{label:n("settings.account.displayName"),editing:o,hint:v,editor:t.jsx(Vt,{nameInput:c,setEditingName:p,setNameInput:g,profileSaving:h,handleSaveName:l}),actions:t.jsx(zt,{name:e})})}function qt({github:e}){const{editingGithub:a,githubError:s,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:c,profileSaving:u,setEditingGithub:h,setGithubError:p,setGithubInput:g,showGithubOn:m,startEditingGithub:v}=e;return t.jsx(t.Fragment,{children:t.jsx(pe,{label:n("settings.account.githubUrl"),editing:a,hint:o||n("settings.account.githubUrlHint"),editor:t.jsx(Bt,{githubError:s,githubInput:i,handleSaveGithub:r,profileSaving:u,setEditingGithub:h,setGithubError:p,setGithubInput:g}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ge,{label:n("settings.account.edit"),onClick:v}),t.jsx(j,{checked:m,onChange:l,disabled:c||u,ariaLabel:n("settings.account.githubUrl")})]})})})}function Wt(){const{openLoginModal:e}=Ce();return t.jsx(O,{title:n("settings.section.account"),children:t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.account.signedOutHint")}),t.jsx("button",{type:"button",onClick:e,className:"inline-flex h-8 shrink-0 items-center justify-center rounded-md bg-oai-gray-900 px-4 text-xs font-medium text-white transition-colors hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100",children:n("settings.account.signIn")})]})})}function Zt({name:e,github:a}){return t.jsxs(t.Fragment,{children:[t.jsx(Kt,{name:e}),t.jsx(qt,{github:a})]})}function Yt(){const e=$t();return e.enabled?e.signedIn?t.jsxs(O,{title:n("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Qt,{onSignOut:e.signOut}),children:[t.jsx(Jt,{userId:e.userId}),t.jsx(Xt,{settings:e}),t.jsx(en,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(tn,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(Wt,{}):null}function Jt({userId:e}){const[a,s]=H.useState(!1);if(!e)return null;const i=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),s(!0),globalThis.setTimeout(()=>s(!1),1200)}catch{s(!1)}};return t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:n("settings.account.userId")}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e})]}),t.jsxs("button",{type:"button",onClick:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800","aria-label":n("settings.account.copyUserId"),children:[a?t.jsx(dt,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(gt,{className:"h-3.5 w-3.5","aria-hidden":!0}),a?n("settings.account.copied"):n("settings.account.copy")]})]})}function Qt({onSignOut:e}){return t.jsxs("button",{type:"button",onClick:()=>e(),className:"inline-flex h-7 items-center gap-1.5 text-xs font-medium text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:[t.jsx(St,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.account.signOut")]})}function Xt({settings:e}){return e.showLocalCloudSync?t.jsx(b,{label:n("settings.account.cloudSync"),hint:n("settings.account.cloudSyncHint"),control:t.jsx(j,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:n("settings.account.cloudSync")})}):null}function en({checked:e,disabled:a,onChange:s}){return t.jsx(b,{label:n("settings.account.publicProfile"),hint:n("settings.account.publicProfileHint"),control:t.jsx(j,{checked:e,onChange:s,disabled:a,ariaLabel:n("settings.account.publicProfile")})})}function tn({visible:e,name:a,github:s}){return t.jsx(se,{initial:!1,children:e?t.jsx(ae.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:t.jsx(Zt,{name:a,github:s})},"public-profile-fields"):null})}function nn(){return[{value:"light",label:n("settings.appearance.theme.light"),Icon:Ae},{value:"dark",label:n("settings.appearance.theme.dark"),Icon:Pe},{value:"system",label:n("settings.appearance.theme.system"),Icon:te}]}function an(){return[{value:_e,label:n("settings.appearance.language.system")},{value:Te,label:n("settings.appearance.language.english")},{value:Ie,label:n("settings.appearance.language.chinese")},{value:Ge,label:n("settings.appearance.language.traditional_chinese")},{value:Re,label:n("settings.appearance.language.japanese")},{value:De,label:n("settings.appearance.language.korean")},{value:Ue,label:n("settings.appearance.language.german")}]}function sn(e){if(!e)return null;try{const a=new Date(e);return Number.isNaN(a.getTime())?null:a.toLocaleString()}catch{return null}}function on(e,a){const s=n(`settings.appearance.currency.rate_source.${e}`),i=sn(a),o=i?n("settings.appearance.currency.rate_updated",{when:i}):n("settings.appearance.currency.rate_never");return`${s} · ${o}`}function rn({locale:e,setLocale:a}){const s=an();return t.jsx(F,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx(jt,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function ln({currency:e,setCurrency:a}){const s=Oe().map(i=>({value:i.code,label:n(i.labelKey)}));return t.jsx(F,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function cn({currency:e,rate:a,rateSource:s,rateFetchedAt:i}){if(e===Le)return t.jsx(t.Fragment,{children:n("settings.appearance.currency.hint")});const o=on(s,i);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${a.toFixed(4)} ${e}`}),t.jsx("span",{role:"img","aria-label":o,title:o,className:"inline-flex h-4 w-4 cursor-help items-center justify-center text-oai-gray-400 hover:text-oai-gray-600 dark:text-oai-gray-500 dark:hover:text-oai-gray-300",children:t.jsx(mt,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function un(){const{theme:e,setTheme:a}=Ee(),{locale:s,setLocale:i}=ee(),{currency:o,rate:r,rateSource:l,rateFetchedAt:c,setCurrency:u}=pt(),{mode:h,setMode:p,unitSystem:g,setUnitSystem:m,grouping:v,setGrouping:k}=ht();return t.jsxs(O,{title:n("settings.section.appearance"),children:[t.jsx(b,{label:n("settings.appearance.theme.label"),hint:n("settings.appearance.theme.hint"),control:t.jsx(T,{options:nn(),value:e,onChange:a})}),t.jsx(b,{label:n("settings.appearance.language.label"),hint:n("settings.appearance.language.hint"),control:t.jsx(rn,{locale:s,setLocale:i})}),t.jsx(b,{label:n("settings.appearance.currency.label"),hint:t.jsx(cn,{currency:o,rate:r,rateSource:l,rateFetchedAt:c}),control:t.jsx(ln,{currency:o,setCurrency:u})}),t.jsx(b,{label:n("settings.appearance.token_format.label"),hint:n("settings.appearance.token_format.hint"),control:t.jsx(T,{options:[{value:U.COMPACT,label:n("settings.appearance.token_format.compact")},{value:U.FULL,label:n("settings.appearance.token_format.full")}],value:h,onChange:p})}),t.jsx(b,{label:n("settings.appearance.token_unit.label"),hint:n("settings.appearance.token_unit.hint"),control:t.jsx(T,{disabled:h!==U.COMPACT,options:[{value:V.ENGLISH,label:n("settings.appearance.token_unit.english")},{value:V.CHINESE,label:n("settings.appearance.token_unit.chinese")}],value:g,onChange:m})}),t.jsx(b,{label:n("settings.appearance.token_grouping.label"),hint:n("settings.appearance.token_grouping.hint"),control:t.jsx(T,{options:[{value:B.THOUSAND,label:n("settings.appearance.token_grouping.thousand")},{value:B.WAN,label:n("settings.appearance.token_grouping.wan")}],value:v,onChange:k})})]})}function M({labelKey:e}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:n(e)}),t.jsx("span",{className:"px-1.5 py-0.5 text-[8px] font-semibold tracking-wider text-oai-gray-500 bg-oai-gray-100 dark:text-oai-gray-400 dark:bg-oai-gray-800/80 rounded uppercase scale-90 origin-left",children:n("qpd.card.badge")})]})}function dn(){const{enabled:e,toggle:a}=ct(),{enabled:s,toggle:i}=ut(),{available:o,settings:r,setSetting:l}=R(),c=o&&!!r?.dynamicIslandSupported,u=!!r?.dynamicIslandEnabled;return t.jsxs(O,{title:n("settings.section.labs"),children:[c&&t.jsxs(t.Fragment,{children:[t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.island.label"}),hint:n("settings.labs.island.hint"),control:t.jsx(j,{checked:u,onChange:()=>l("dynamicIslandEnabled",!u),ariaLabel:n("settings.labs.island.aria")})}),u&&t.jsx(b,{label:n("settings.labs.island_hide_menubar.label"),hint:n("settings.labs.island_hide_menubar.hint"),control:t.jsx(j,{checked:!!r?.hideMenuBarIcon,onChange:()=>l("hideMenuBarIcon",!r?.hideMenuBarIcon),ariaLabel:n("settings.labs.island_hide_menubar.aria")})})]}),t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.qpd.label"}),hint:n("settings.labs.qpd.hint"),control:t.jsx(j,{checked:e,onChange:a,ariaLabel:n("settings.labs.qpd.aria")})}),t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.sessions.label"}),hint:n("settings.labs.sessions.hint"),control:t.jsx(j,{checked:s,onChange:i,ariaLabel:n("settings.labs.sessions.aria")})})]})}function gn(){const{available:e,settings:a,setSetting:s,runAction:i}=R();if(!e)return null;const o=ne(),r=!!a?.launchAtLogin,l=a?.toastOnReset!==!1,c=a?.confettiOnReset!==!1,u=a?.launchAtLoginSupported!==!1,h=a?.autoUpdateEnabled!==!1,p=a?.updateStatus||null,g=!!a?.updateBusy,m=!!a?.isSyncing;return t.jsxs(O,{title:n("settings.section.menubar"),children:[o?null:t.jsxs(t.Fragment,{children:[t.jsx(b,{label:n("settings.menubar.appearance"),hint:n("settings.menubar.appearanceHint"),control:t.jsxs(Me,{to:"/widgets",className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 no-underline transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[n("settings.menubar.appearanceLink"),t.jsx(ft,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(j,{checked:l,onChange:()=>s("toastOnReset",!l),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(j,{checked:c,onChange:()=>s("confettiOnReset",!c),ariaLabel:n("settings.menubar.confettiOnReset")})})]}),u?t.jsx(b,{label:n("settings.menubar.launchAtLogin"),hint:n("settings.menubar.launchAtLoginHint"),control:t.jsx(j,{checked:r,onChange:()=>s("launchAtLogin",!r),ariaLabel:n("settings.menubar.launchAtLogin")})}):null,t.jsx(b,{label:n("settings.menubar.syncNow"),hint:n("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>i("syncNow"),disabled:m,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(He,{className:_("h-3.5 w-3.5",m&&"animate-spin"),"aria-hidden":!0}),m?n("settings.menubar.syncing"):n("settings.menubar.syncNow")]})}),t.jsx(b,{label:n("settings.menubar.autoUpdate"),hint:n("settings.menubar.autoUpdateHint"),control:t.jsx(j,{checked:h,onChange:()=>s("autoUpdateEnabled",!h),ariaLabel:n("settings.menubar.autoUpdate")})}),t.jsx(b,{label:n("settings.menubar.updates"),hint:p||void 0,control:t.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:g,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(xt,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.menubar.checkUpdates")]})})]})}function pn(e,a){function s(r){return r.replace(/^v/,"").split(".").map(Number)}const i=s(e),o=s(a);for(let r=0;r<Math.max(i.length,o.length);r++){const l=i[r]||0,c=o[r]||0;if(l<c)return!0;if(l>c)return!1}return!1}function hn(){const{available:e,settings:a,runAction:s}=R(),i=e&&a?.version,o=a?.platform||"macos",[r,l]=H.useState(!1),[c,u]=H.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:h}=ee(),p="1.1.12",g=async()=>{l(!0);try{const y=await fetch("https://api.github.com/repos/xiufengsun/TokenTracker/releases/latest");if(!y.ok)throw new Error("Failed to fetch");const w=await y.json(),N=w.tag_name;pn(p,N)?u({open:!0,latestVersion:N,htmlUrl:w.html_url}):z({title:n("settings.menubar.updates.upToDate")})}catch(y){console.error("Check updates failed:",y),z({title:n("settings.menubar.updates.failed")})}finally{l(!1)}},m=n("settings.menubar.updates.modalTitle"),v=n("settings.menubar.updates.modalDescription",{version:c.latestVersion}),k=n("settings.menubar.updates.modalConfirm"),P=n("settings.menubar.updates.modalCancel");return t.jsxs("div",{className:"mt-6 flex flex-col items-center justify-center gap-4 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[i?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:o==="windows"?n("settings.menubar.updates.footerCore",{version:a.version}):n("settings.menubar.updates.footerCombined",{barVersion:a.version,coreVersion:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>s("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n("settings.menubar.updates.footerCore",{version:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:g,disabled:r,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:r?n("settings.menubar.updates.checking"):n("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Fe,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:[t.jsx($e,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.footer.statusPage")]})]}),t.jsx(bt,{open:c.open,title:m,description:v,confirmLabel:k,cancelLabel:P,onConfirm:()=>{window.open(c.htmlUrl,"_blank"),u(y=>({...y,open:!1}))},onCancel:()=>u(y=>({...y,open:!1}))})]})}const mn=()=>[{value:"system",label:n("settings.network.mode.system")},{value:"manual",label:n("settings.network.mode.manual")},{value:"off",label:n("settings.network.mode.off")}],bn=()=>[{value:"http",label:n("settings.network.protocol.http")},{value:"https",label:n("settings.network.protocol.https")},{value:"socks5",label:n("settings.network.protocol.socks5")}],Y="w-full rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white";function J(e){const a={},s=String(e.host||"").trim();(!s||/:\/\//.test(s)||s.includes("/"))&&(a.host=n("settings.network.error.host"));const i=String(e.port??"").trim(),o=Number(i);return(!i||!/^\d+$/.test(i)||!Number.isInteger(o)||o<1||o>65535)&&(a.port=n("settings.network.error.port")),a}function fn({proxySettings:e}){const{config:a,save:s,testConnection:i}=e,[o,r]=d.useState(()=>({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})),[l,c]=d.useState({}),[u,h]=d.useState(!1),[p,g]=d.useState(""),[m,v]=d.useState(null),[k,P]=d.useState(!1),[y,w]=d.useState(null);d.useEffect(()=>{r({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})},[a.mode,a.protocol,a.host,a.port]);const N=d.useMemo(()=>a.effective==="manual"?n("settings.network.effective.manual"):a.effective==="env"?n("settings.network.effective.env"):a.effective==="system"?n("settings.network.effective.system"):a.effective==="blocked"?n("settings.network.effective.blocked"):n("settings.network.effective.none"),[a.effective]),f=x=>{r(E=>({...E,...x})),c({}),g(""),v(null),w(null)},S=async()=>{if(o.mode==="manual"){const x=J(o);if(Object.keys(x).length){c(x);return}}h(!0),g(""),v(null);try{await s(o),g("saved")}catch(x){g("error"),v(x)}finally{h(!1)}},L=async()=>{const x=J(o);if(Object.keys(x).length){c(x);return}P(!0),w(null);try{const E=await i(o);w(E)}catch(E){w({ok:!1,error:E?.message||String(E)})}finally{P(!1)}};return t.jsxs(O,{title:n("settings.section.network"),subtitle:N,children:[a.applyError?t.jsx("p",{role:"alert",className:"mb-3 text-xs text-red-600 dark:text-red-400",children:n("settings.network.apply_error",{error:a.applyError})}):null,t.jsx(b,{label:n("settings.network.mode.label"),hint:n("settings.network.mode.hint"),control:t.jsx(T,{options:mn(),value:o.mode,onChange:x=>f({mode:x})})}),t.jsx(se,{initial:!1,children:o.mode==="manual"?t.jsxs(ae.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:[t.jsx(b,{label:n("settings.network.protocol.label"),control:t.jsx(F,{value:o.protocol,onValueChange:x=>f({protocol:x}),options:bn(),ariaLabel:n("settings.network.protocol.label"),className:"px-2.5 py-1.5 text-xs font-medium"})}),t.jsx(b,{label:n("settings.network.host.label"),hint:l.host,control:t.jsx("input",{type:"text",value:o.host,onChange:x=>f({host:x.target.value}),placeholder:n("settings.network.host.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":l.host?!0:void 0,"aria-label":n("settings.network.host.label"),className:Y})}),t.jsx(b,{label:n("settings.network.port.label"),hint:l.port,control:t.jsx("input",{type:"text",inputMode:"numeric",value:o.port,onChange:x=>f({port:x.target.value}),placeholder:n("settings.network.port.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":l.port?!0:void 0,"aria-label":n("settings.network.port.label"),className:Y})}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 py-3",children:[t.jsx("button",{type:"button",onClick:L,disabled:k||u,className:"rounded-md border border-oai-gray-200 px-3 py-1.5 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:k?n("settings.network.test.testing"):n("settings.network.test")}),t.jsx("button",{type:"button",onClick:S,disabled:u||k,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:u?n("settings.network.saving"):n("settings.network.save")})]}),y?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:y.ok?n("settings.network.test.ok",{status:String(y.status??"")}):n("settings.network.test.fail",{error:y.error||""})}):null]},"manual-proxy-fields"):t.jsx("div",{className:"flex justify-end py-3",children:t.jsx("button",{type:"button",onClick:S,disabled:u,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:u?n("settings.network.saving"):n("settings.network.save")})},"non-manual-save")}),p==="saved"?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.network.saved")}):null,p==="error"?t.jsx("p",{role:"alert",className:"py-2 text-xs text-red-600 dark:text-red-400",children:m?.unprotected?n("settings.network.save_error_unprotected",{error:m?.message||String(m||"")}):n("settings.network.save_error",{error:m?.message||String(m||"")})}):null]})}const he="/functions/tokentracker-proxy-config",xn="/functions/tokentracker-proxy-test",yn={mode:"system",protocol:"http",host:"",port:"",effective:"none",applyError:null};function me(e){return!e||typeof e.mode!="string"?null:{mode:e.mode,protocol:typeof e.protocol=="string"?e.protocol:"http",host:typeof e.host=="string"?e.host:"",port:e.port==null||e.port===0?"":String(e.port),effective:typeof e.effective=="string"?e.effective:"none",applyError:typeof e.applyError=="string"&&e.applyError.trim()?e.applyError:null}}async function vn(){const e=await fetch(he,{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!e.ok)return null;const a=await e.json().catch(()=>null);return me(a)}async function Q(){const{getLocalApiAuthHeaders:e}=await Ve(async()=>{const{getLocalApiAuthHeaders:a}=await import("./__vite-browser-external-4IDwIR3i.js").then(s=>s.dg);return{getLocalApiAuthHeaders:a}},__vite__mapDeps([0,1]));return e()}function kn(){const[e,a]=d.useState(!1),[s,i]=d.useState(!0),[o,r]=d.useState(yn);d.useEffect(()=>{if(!yt()){a(!1),i(!1);return}let u=!1;return(async()=>{try{const h=await vn();if(u)return;if(!h){a(!1),i(!1);return}r(h),a(!0),i(!1)}catch{u||(a(!1),i(!1))}})(),()=>{u=!0}},[]);const l=d.useCallback(async u=>{const h=await Q(),p=await fetch(he,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...h},cache:"no-store",body:JSON.stringify({mode:u.mode,protocol:u.protocol,host:u.host,port:u.port===""?0:Number(u.port)})}),g=await p.json().catch(()=>null);if(!p.ok){const v=g&&typeof g.error=="string"?g.error:`HTTP ${p.status}`;throw new Error(v)}const m=me(g);if(m&&r(m),g&&g.ok===!1){const v=g&&typeof g.applyError=="string"&&g.applyError||g&&typeof g.error=="string"&&g.error||`HTTP ${p.status}`,k=new Error(v);throw g.unprotected===!0&&(k.unprotected=!0),k}return m||g},[]),c=d.useCallback(async u=>{const h=await Q(),p=await fetch(xn,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...h},cache:"no-store",body:JSON.stringify({protocol:u.protocol,host:u.host,port:u.port===""?0:Number(u.port)})}),g=await p.json().catch(()=>null);if(!g||typeof g.ok!="boolean")throw new Error(g&&typeof g.error=="string"?g.error:`HTTP ${p.status}`);return g},[]);return{available:e,loading:s,config:o,save:l,testConnection:c}}const C={APPEARANCE:"appearance",NATIVE_APP:"native-app",NETWORK:"network",ACCOUNT:"account",LIMITS:"limits",LABS:"labs"},A={PERSONAL:"personal",APP:"app",DEVELOPER:"developer"};function jn({prefs:e}){return t.jsx(T,{options:[{value:Z.USED,label:n("limits.settings.display_mode_used")},{value:Z.REMAINING,label:n("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function Zn(){const e=ot(),{available:a,settings:s,setSetting:i}=R(),o=kn(),{available:r}=o,l=s?.toastOnReset!==!1,c=s?.confettiOnReset!==!1,u=ne()||s?.platform==="windows",[h,p]=Be(),g=ze(),m=h.get("section"),k=Object.values(C).includes(m)&&(m!==C.NATIVE_APP||a)&&(m!==C.NETWORK||r)?m:C.APPEARANCE,P=f=>{const S=new URLSearchParams(h);f===C.APPEARANCE?S.delete("section"):S.set("section",f),p(S,{replace:!0})},y=[{id:C.APPEARANCE,label:n("settings.section.appearance"),description:n("settings.section.appearance.description"),group:A.PERSONAL,Icon:wt,content:t.jsx(un,{})},...a?[{id:C.NATIVE_APP,label:n("settings.section.menubar"),description:n("settings.section.menubar.description"),group:A.APP,Icon:te,content:t.jsx(gn,{})}]:[],...r?[{id:C.NETWORK,label:n("settings.section.network"),description:n("settings.section.network.description"),group:A.APP,Icon:Ke,content:t.jsx(fn,{proxySettings:o})}]:[],{id:C.ACCOUNT,label:n("settings.section.account"),description:n("settings.section.account.description"),group:A.PERSONAL,Icon:Nt,content:t.jsx(Yt,{})},{id:C.LIMITS,label:n("settings.section.limits"),description:n("settings.section.limits.description"),group:A.APP,Icon:qe,content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs(O,{title:n("settings.section.limits"),children:[t.jsx(b,{label:n("limits.settings.display_mode_label"),control:t.jsx(jn,{prefs:e})}),u?null:t.jsxs(t.Fragment,{children:[t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(j,{checked:l,disabled:!a,onChange:()=>i("toastOnReset",!l),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(j,{checked:c,disabled:!a,onChange:()=>i("confettiOnReset",!c),ariaLabel:n("settings.menubar.confettiOnReset")})})]}),t.jsx(b,{label:n("settings.limits.showSubscriptions"),hint:n("settings.limits.showSubscriptionsHint"),control:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>g("/limits?openSubscriptions=1"),"aria-label":n("limits.page.openSubscriptions"),title:n("limits.page.openSubscriptions"),className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-white dark:bg-oai-gray-900 text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:t.jsx(We,{size:14,"aria-hidden":!0})}),t.jsx(j,{checked:e.showSubscriptions!==!1,onChange:()=>e.setShowSubscriptions(!e.showSubscriptions),ariaLabel:n("settings.limits.showSubscriptions")})]})})]}),t.jsx(O,{title:n("settings.limits.providers"),children:t.jsx(Pt,{prefs:e})})]})},{id:C.LABS,label:n("settings.section.labs"),description:n("settings.section.labs.description"),group:A.DEVELOPER,Icon:vt,content:t.jsx(dn,{})}],w=[{id:A.PERSONAL,label:n("settings.nav.group.personal")},{id:A.APP,label:n("settings.nav.group.app")},{id:A.DEVELOPER,label:n("settings.nav.group.developer")}].map(f=>({...f,sections:y.filter(S=>S.group===f.id)})).filter(f=>f.sections.length>0);let N=y[0];for(const f of y)if(f.id===k){N=f;break}return t.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:t.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:t.jsxs("div",{className:"mx-auto w-full max-w-5xl px-4 sm:px-6",children:[t.jsxs("div",{className:"mb-7 max-w-2xl",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:n("settings.page.title")}),t.jsx("p",{className:"mt-2 text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:n("settings.page.subtitle")})]}),t.jsxs("div",{className:"grid min-w-0 gap-6 md:grid-cols-[14rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[15rem_minmax(0,1fr)]",children:[t.jsx("aside",{className:"min-w-0 rounded-xl border border-oai-gray-200 bg-oai-gray-50/70 p-2 dark:border-oai-gray-800 dark:bg-oai-gray-900/60 md:border-0 md:bg-transparent md:p-0 md:dark:bg-transparent",children:t.jsx("nav",{"aria-label":n("settings.page.title"),className:"flex gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden md:sticky md:top-6 md:flex-col md:gap-4 md:overflow-visible",children:w.map(({id:f,label:S,sections:L})=>t.jsxs("div",{className:"flex shrink-0 gap-1 md:block",children:[t.jsx("div",{className:"hidden px-3 pb-1 text-[10px] font-semibold uppercase tracking-[0.16em] text-oai-gray-400 dark:text-oai-gray-500 md:block",children:S}),t.jsx("div",{className:"flex gap-1 md:flex-col",children:L.map(({id:x,label:E,Icon:D})=>{const G=k===x;return t.jsxs("button",{id:`settings-nav-${x}`,type:"button","aria-current":G?"page":void 0,"aria-controls":`settings-panel-${x}`,onClick:()=>P(x),className:_("inline-flex min-h-10 min-w-max shrink-0 items-center gap-1.5 rounded-md px-2 py-2 text-left text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500 md:w-full md:min-w-0 md:gap-2 md:px-3",G?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-500 hover:bg-oai-gray-50 hover:text-oai-gray-900 dark:text-oai-gray-400 dark:hover:bg-oai-gray-900 dark:hover:text-oai-gray-200"),children:[t.jsx(D,{className:_("h-4 w-4 shrink-0",G?"text-oai-black dark:text-white":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:E})]},x)})})]},f))})}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"mb-4 border-b border-oai-gray-200 pb-4 dark:border-oai-gray-800",children:[t.jsx("h2",{className:"text-xl font-semibold tracking-tight text-oai-black dark:text-white",children:N.label}),t.jsx("p",{className:"mt-1 text-sm leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:N.description})]}),y.map(({id:f,label:S,content:L})=>t.jsx("section",{id:`settings-panel-${f}`,"aria-labelledby":`settings-nav-${f}`,"aria-label":S,"data-settings-panel":f,hidden:k!==f,children:L},f)),t.jsx(hn,{})]})]})]})})})}export{Zn as SettingsPage};