tokentracker-cli 0.87.12 → 0.87.13

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 (97) hide show
  1. package/dashboard/dist/assets/AchievementBadge-ea7qapyL.js +1 -0
  2. package/dashboard/dist/assets/{AchievementsPage-DdE-PvdD.js → AchievementsPage-DoOYRLD5.js} +2 -2
  3. package/dashboard/dist/assets/{AchievementsSection-j8gj_nYR.js → AchievementsSection-B7uvcdxK.js} +1 -1
  4. package/dashboard/dist/assets/{BadgeDetailModal-HtyWTb3Y.js → BadgeDetailModal-1KF-h3Cm.js} +1 -1
  5. package/dashboard/dist/assets/{Card-B7pwNMNG.js → Card-DQgKBViP.js} +1 -1
  6. package/dashboard/dist/assets/{ClawdAnimated-Bkh3Fjze.js → ClawdAnimated-CbKk5C9F.js} +1 -1
  7. package/dashboard/dist/assets/{CommandPalette-qwGrZiaK.js → CommandPalette-MIRqk8Dp.js} +1 -1
  8. package/dashboard/dist/assets/{CommunityStatsModal-xActA7oW.js → CommunityStatsModal-CgHWU_T1.js} +1 -1
  9. package/dashboard/dist/assets/{ConfirmModal-ce7m5kbY.js → ConfirmModal-D05J-QUB.js} +1 -1
  10. package/dashboard/dist/assets/{Controls-ZF7RAlv8.js → Controls-D5LSYH96.js} +1 -1
  11. package/dashboard/dist/assets/{DashboardPage-DjAqcPbt.js → DashboardPage-H2Bl3Bwo.js} +1 -1
  12. package/dashboard/dist/assets/{DevicePage-C5M18HP8.js → DevicePage-TtCdnGIm.js} +1 -1
  13. package/dashboard/dist/assets/{DialogClose-D9dEiIrM.js → DialogClose-BfCS-Ntd.js} +1 -1
  14. package/dashboard/dist/assets/DialogDescription-DVH6GzL7.js +1 -0
  15. package/dashboard/dist/assets/{DialogTitle-BzF6VDdV.js → DialogTitle-O5nTArna.js} +1 -1
  16. package/dashboard/dist/assets/{FadeIn-CDCRfuK2.js → FadeIn-CigBazQo.js} +1 -1
  17. package/dashboard/dist/assets/{HeaderGithubStar-B9pwWkZX.js → HeaderGithubStar-DeMyqNpO.js} +1 -1
  18. package/dashboard/dist/assets/{HoverTooltip-Syqp_rdT.js → HoverTooltip-tOIlqXjb.js} +1 -1
  19. package/dashboard/dist/assets/{IpCheckPage-DDCJs34b.js → IpCheckPage-CCeG4lE9.js} +1 -1
  20. package/dashboard/dist/assets/{LandingPage-B-BRXVvv.js → LandingPage-33uNffc7.js} +2 -2
  21. package/dashboard/dist/assets/{LeaderboardAvatar-SM1rZD0T.js → LeaderboardAvatar-BRJKEfhb.js} +1 -1
  22. package/dashboard/dist/assets/{LeaderboardPage-BVZW-aOv.js → LeaderboardPage-_Fs74yLu.js} +2 -2
  23. package/dashboard/dist/assets/{LeaderboardProfileModal-BMo8dmT4.js → LeaderboardProfileModal-CFt90SC6.js} +3 -3
  24. package/dashboard/dist/assets/{LeaderboardProfilePage-CMaoZz79.js → LeaderboardProfilePage-CC9315s4.js} +1 -1
  25. package/dashboard/dist/assets/{LimitsPage-Bz1p1fI8.js → LimitsPage-fNLiGJas.js} +1 -1
  26. package/dashboard/dist/assets/{LocalOnlyNotice-DVqqppGu.js → LocalOnlyNotice-DJWlZgug.js} +1 -1
  27. package/dashboard/dist/assets/{LoginCard-DSI5qiwZ.js → LoginCard-B6zjmb6m.js} +1 -1
  28. package/dashboard/dist/assets/{LoginModal-bZgy6vVi.js → LoginModal-D7VtT-pA.js} +1 -1
  29. package/dashboard/dist/assets/{LoginPage-BEnSdTSO.js → LoginPage-CmKUywl4.js} +1 -1
  30. package/dashboard/dist/assets/{PetPage-Dj2OPBJo.js → PetPage-U28hAlPp.js} +1 -1
  31. package/dashboard/dist/assets/{PopoverPopup-BhXFfaac.js → PopoverPopup-DREcMHrJ.js} +1 -1
  32. package/dashboard/dist/assets/{ProviderIcon-CBmpx1uF.js → ProviderIcon-CxpFegpD.js} +1 -1
  33. package/dashboard/dist/assets/{ResetPasswordPage-DfdzG02N.js → ResetPasswordPage-XjbWpa4B.js} +1 -1
  34. package/dashboard/dist/assets/{SegmentedControl-DFEBI9gn.js → SegmentedControl-BUZrG_65.js} +1 -1
  35. package/dashboard/dist/assets/{Select-Cg0q9TwB.js → Select-Coxp19gW.js} +1 -1
  36. package/dashboard/dist/assets/{SelectItemText-BIfAByNj.js → SelectItemText-Dw-zi_PN.js} +1 -1
  37. package/dashboard/dist/assets/{ServiceStatusPage-CbQ7EApL.js → ServiceStatusPage-c4Gz9ND_.js} +1 -1
  38. package/dashboard/dist/assets/{SessionsPage-3AD3xDBi.js → SessionsPage-CJUJDivQ.js} +1 -1
  39. package/dashboard/dist/assets/{SettingsPage-Di6egC3t.js → SettingsPage-BoUeuTQk.js} +1 -1
  40. package/dashboard/dist/assets/{SkillsPage-CiE7tmhj.js → SkillsPage-Chv4kDY_.js} +1 -1
  41. package/dashboard/dist/assets/{TokenGalaxy-CA8DtXji.js → TokenGalaxy-UtsDkqN-.js} +1 -1
  42. package/dashboard/dist/assets/{ToolbarRootContext-Def90ZdR.js → ToolbarRootContext-D3Xvbsmu.js} +1 -1
  43. package/dashboard/dist/assets/{TrendMonitor-D_KwleIY.js → TrendMonitor-hjyZhVhp.js} +1 -1
  44. package/dashboard/dist/assets/{WidgetsPage-B3TlH8la.js → WidgetsPage-BaJJOspc.js} +1 -1
  45. package/dashboard/dist/assets/{WrappedPage-aQUlSHgU.js → WrappedPage-BdBZXCyS.js} +1 -1
  46. package/dashboard/dist/assets/{__vite-browser-external-L2HadaWR.js → __vite-browser-external-CU0HL6hY.js} +2 -2
  47. package/dashboard/dist/assets/{agent-logos-Dd2epVvG.js → agent-logos-D15jo0lu.js} +1 -1
  48. package/dashboard/dist/assets/{arrow-up-right-BYW8TxaE.js → arrow-up-right-C6W_K-fZ.js} +1 -1
  49. package/dashboard/dist/assets/{check-DjA9wjvH.js → check-D1DIUZ3y.js} +1 -1
  50. package/dashboard/dist/assets/{chevron-right-ChdXf-I7.js → chevron-right-DaZ6r6U5.js} +1 -1
  51. package/dashboard/dist/assets/{copy-DMD9VvI7.js → copy-DGTadiXw.js} +1 -1
  52. package/dashboard/dist/assets/{download-AY9DU1FN.js → download-CBYnlCsF.js} +1 -1
  53. package/dashboard/dist/assets/{external-link-CSwc4MMQ.js → external-link-BDjUPxFn.js} +1 -1
  54. package/dashboard/dist/assets/{flame-C0H6XAnq.js → flame-BSTr9RX6.js} +1 -1
  55. package/dashboard/dist/assets/{format-tokens-Cu8Q9KUB.js → format-tokens-CxjDlh0r.js} +1 -1
  56. package/dashboard/dist/assets/{icons-BlhiKkjO.js → icons-pOJhx7lO.js} +1 -1
  57. package/dashboard/dist/assets/{index-DTHLk-aT.js → index-Bym1hEGy.js} +1 -1
  58. package/dashboard/dist/assets/{index-Ca6uzmWw.js → index-CbpwbfY1.js} +1 -1
  59. package/dashboard/dist/assets/{index-Ck60l_u8.js → index-XCZRFozo.js} +1 -1
  60. package/dashboard/dist/assets/{info-DfeZe41U.js → info-DlZkEw5y.js} +1 -1
  61. package/dashboard/dist/assets/{limits-providers-D7KHzRsf.js → limits-providers-DOW-oPEP.js} +1 -1
  62. package/dashboard/dist/assets/{link-2-DaC-FMcZ.js → link-2-BaAMrLia.js} +1 -1
  63. package/dashboard/dist/assets/{loader-circle-DMfnuZaq.js → loader-circle-BvEjzy5k.js} +1 -1
  64. package/dashboard/dist/assets/{maximize-2-BLYlrp5S.js → maximize-2-DNjgO_My.js} +1 -1
  65. package/dashboard/dist/assets/{modifiers.esm-DKWwsA47.js → modifiers.esm-DpXL6h3m.js} +1 -1
  66. package/dashboard/dist/assets/module-CzlIpkuW.js +2 -0
  67. package/dashboard/dist/assets/{monitor-smartphone-CoZaLWA1.js → monitor-smartphone-DPmp8gGF.js} +1 -1
  68. package/dashboard/dist/assets/{provider-display-kfWeaovO.js → provider-display-YTGYyKIU.js} +1 -1
  69. package/dashboard/dist/assets/{react-uUvzHQm5.js → react-CBi7M7dK.js} +1 -1
  70. package/dashboard/dist/assets/{search-CQo3iV6X.js → search-MLfdUv_4.js} +1 -1
  71. package/dashboard/dist/assets/{skills-api-LQd25VfD.js → skills-api-C4jX9Owj.js} +1 -1
  72. package/dashboard/dist/assets/{sortable.esm-CZtmM7Tp.js → sortable.esm-YyExnyg0.js} +1 -1
  73. package/dashboard/dist/assets/{store-Bl3-sCXx.js → store-PiuqLY56.js} +1 -1
  74. package/dashboard/dist/assets/{terminal-DlcACqJp.js → terminal-DQkiIx3c.js} +1 -1
  75. package/dashboard/dist/assets/{trash-2-CQo1tgFy.js → trash-2-qoXweL8H.js} +1 -1
  76. package/dashboard/dist/assets/{use-community-stats-BQCn4wL0.js → use-community-stats-ByIG8K-M.js} +1 -1
  77. package/dashboard/dist/assets/{use-limits-display-prefs-Bl4NPX34.js → use-limits-display-prefs-CpW6_ZBo.js} +1 -1
  78. package/dashboard/dist/assets/{use-ordered-list-D1wNYgOm.js → use-ordered-list--ijka38Z.js} +1 -1
  79. package/dashboard/dist/assets/use-reduced-motion-DW0-IRCM.js +1 -0
  80. package/dashboard/dist/assets/{use-session-efficiency-pref-Btxlws5g.js → use-session-efficiency-pref-Di41rY7h.js} +1 -1
  81. package/dashboard/dist/assets/{use-transform-COsyA62D.js → use-transform-CKw05one.js} +1 -1
  82. package/dashboard/dist/assets/{use-usage-limits-DufOQF6m.js → use-usage-limits-DxAyfksJ.js} +1 -1
  83. package/dashboard/dist/assets/{useCurrency-Dr4F-MZe.js → useCurrency-DKrZtU2Z.js} +1 -1
  84. package/dashboard/dist/assets/{useScrollLock-7UUKbtyh.js → useScrollLock-D2roJGoE.js} +1 -1
  85. package/dashboard/dist/assets/{useTokenFormat-BHmT3c4D.js → useTokenFormat-C8hwTvLr.js} +1 -1
  86. package/dashboard/dist/assets/{zap-hfkDgLPJ.js → zap-BcmVPhUG.js} +1 -1
  87. package/dashboard/dist/index.html +1 -1
  88. package/dashboard/dist/ip-check.html +1 -1
  89. package/dashboard/dist/leaderboard.html +1 -1
  90. package/dashboard/dist/share.html +1 -1
  91. package/package.json +1 -1
  92. package/src/lib/pricing/curated-overrides.json +11 -11
  93. package/src/lib/pricing/seed-snapshot.json +1 -1
  94. package/dashboard/dist/assets/AchievementBadge-CeJiDzOv.js +0 -1
  95. package/dashboard/dist/assets/DialogDescription-CRaQgXyp.js +0 -1
  96. package/dashboard/dist/assets/module-Ci-Lrj0I.js +0 -2
  97. package/dashboard/dist/assets/use-reduced-motion-mkOJFv1A.js +0 -1
@@ -1 +1 @@
1
- import{bU as Xt,bS as xn,r,V as le,bw as Pt,aZ as G,ce as _t,cf as Mt,cg as Bt,bY as Ct,bc as st,aH as He,A as Me,ch as zt,bu as jt,ci as at,aG as Rn,bl as Jt,cj as Rt,ck as St,cl as Zt,cm as Lt,ba as ht,cn as Sn,c0 as In,co as At,aA as it,a$ as Re,a0 as Qt,a_ as yt,bb as En,j as be,$ as q,U as w,aC as Ft,b1 as Ot,b0 as Tn,b3 as Mn,b4 as Cn,b5 as Dt,cp as vn,bZ as wn,b2 as bt,bQ as Pn,y as en,z as Ze,cq as An,aD as On,cr as Vn,aE as Ln,b_ as Fn,be as Dn,cs as Nn,aB as tn,ct as vt}from"./__vite-browser-external-L2HadaWR.js";import{v as We,q as kn,o as Un,E as Hn,G as Le,H as nn,J as _n,u as Bn,m as rn,h as zn,a as jn,l as Wn,A as Yn,I as qn,d as Kn,p as $n,b as Gn}from"./useScrollLock-7UUKbtyh.js";import{i as Xn,u as Jn,j as Zn,a as Qn,d as er,c as tr,e as nr,g as rr,k as or,p as sr,r as ir,h as lr}from"./ToolbarRootContext-Def90ZdR.js";function tt(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}const cr="Escape";function It(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function ft(e,t){return It(t,e===Zt||e===Lt,e===Rt||e===St)}function wt(e,t,n){return It(t,e===Lt,n?e===Rt:e===St)||e==="Enter"||e===" "||e===""}function ur(e,t,n){return It(t,n?e===Rt:e===St,e===Lt)}function ar(e,t,n,o){const l=n?e===St:e===Rt,c=e===Zt;return t==="both"||t==="horizontal"&&o?e===cr:It(t,l,c)}function fr(e,t){const{listRef:n,activeIndex:o,onNavigate:l=()=>{},enabled:c=!0,selectedIndex:i=null,allowEscape:x=!1,loopFocus:u=!1,nested:m=!1,rtl:v=!1,virtual:a=!1,focusItemOnOpen:p="auto",focusItemOnHover:R=!0,openOnArrowKeyDown:b=!0,disabledIndices:O=void 0,orientation:g="vertical",parentOrientation:S,id:V,resetOnPointerLeave:E=!0,externalTree:d,grid:L}=t,j=L!=null,K="rootStore"in e?e.rootStore:e,D=K.useState("open"),W=K.useState("floatingElement"),J=K.useState("domReferenceElement"),me=K.context.dataRef,he=Xt(W),$=xn(J),P=We(he),H=kn(),oe=Un(d),z=r.useRef(p),T=r.useRef(i??-1),Y=r.useRef(null),k=r.useRef(!0),s=le(f=>{l(T.current===-1?null:T.current,f)}),M=r.useRef(!!W),ae=r.useRef(D),U=r.useRef(!1),pe=r.useRef(!1),ge=r.useRef(null),h=We(O),F=We(D),se=We(i),Se=We(E),B=Pt(),ne=Pt(),Z=le(()=>{function f(_){a?oe?.events.emit("virtualfocus",_):ge.current=Hn(_,{sync:U.current,preventScroll:!0})}const y=n.current[T.current],X=pe.current;y&&f(y),(U.current?_=>_():_=>B.request(_))(()=>{const _=n.current[T.current]||y;if(!_)return;y||f(_),xe&&(X||!k.current)&&_.scrollIntoView?.({block:"nearest",inline:"nearest"})})});G(()=>{me.current.orientation=g},[me,g]),G(()=>{c&&(D&&W?(T.current=i??-1,z.current&&i!=null&&(pe.current=!0,s())):M.current&&(T.current=-1,s()))},[c,D,W,i,s]),G(()=>{if(c){if(!D){U.current=!1;return}if(W)if(o==null){if(U.current=!1,se.current!=null)return;if(M.current&&(T.current=-1,Z()),(!ae.current||!M.current)&&z.current&&(Y.current!=null||z.current===!0&&Y.current==null)){let f=0;const y=()=>{n.current[0]==null?(f<2&&(f?I=>ne.request(I):queueMicrotask)(y),f+=1):(T.current=Y.current==null||wt(Y.current,g,v)||m?Mt(n):Bt(n),Y.current=null,s())};y()}}else _t(n.current,o)||(T.current=o,Z(),pe.current=!1)}},[c,D,W,o,se,m,n,g,v,s,Z,ne]),G(()=>{if(!c||W||!oe||a||!M.current)return;const f=oe.nodesRef.current,y=f.find(_=>_.id===H)?.context?.elements.floating,X=Ct(st(J??y??null)),I=f.some(_=>_.context&&He(_.context.elements.floating,X));y&&!I&&k.current&&y.focus({preventScroll:!0})},[c,W,J,oe,H,a]),G(()=>{ae.current=D,M.current=!!W}),G(()=>{D||(Y.current=null,z.current=p)},[D,p]);const ye=o!=null,ce=le(f=>{if(!F.current)return;const y=n.current.indexOf(f.currentTarget);y!==-1&&(T.current!==y||o!==y)&&(T.current=y,s(f))}),ue=le(()=>S??oe?.nodesRef.current.find(f=>f.id===H)?.context?.dataRef?.current.orientation),de=le(()=>Mt(n,h.current)),ee=le(f=>{if(k.current=!1,U.current=!0,f.which===229||!F.current&&f.currentTarget===P.current)return;if(m&&ar(f.key,g,v,j)){ft(f.key,ue())||Le(f),K.setOpen(!1,Me(zt,f.nativeEvent)),jt(J)&&(a?oe?.events.emit("virtualfocus",J):J.focus());return}const y=T.current,X=Mt(n,O),I=Bt(n,O);if($||(f.key==="Home"&&(Le(f),T.current=X,s(f)),f.key==="End"&&(Le(f),T.current=I,s(f))),L!=null){const _=L(f,T.current,n,g,u,v,O,X,I);if(_!=null&&(T.current=_,s(f)),g==="both")return}if(ft(f.key,g)){if(Le(f),D&&!a&&Ct(f.currentTarget.ownerDocument)===f.currentTarget){T.current=wt(f.key,g,v)?X:I,s(f);return}wt(f.key,g,v)?u?y>=I?x&&y!==n.current.length?T.current=-1:(U.current=!1,T.current=X):T.current=at(n.current,{startingIndex:y,disabledIndices:O}):T.current=Math.min(I,at(n.current,{startingIndex:y,disabledIndices:O})):u?y<=X?x&&y!==-1?T.current=n.current.length:(U.current=!1,T.current=I):T.current=at(n.current,{startingIndex:y,decrement:!0,disabledIndices:O}):T.current=Math.max(X,at(n.current,{startingIndex:y,decrement:!0,disabledIndices:O})),_t(n.current,T.current)&&(T.current=-1),s(f)}}),xe=r.useMemo(()=>({onFocus(y){U.current=!0,ce(y)},onClick:({currentTarget:y})=>y.focus({preventScroll:!0}),onMouseMove(y){U.current=!0,pe.current=!1,R&&ce(y)},onPointerLeave(y){if(!F.current||!k.current||y.pointerType==="touch")return;U.current=!0;const X=y.relatedTarget;if(!(!R||n.current.includes(X))&&Se.current&&(ge.current?.(),ge.current=null,T.current=-1,s(y),!a)){const I=P.current,_=Ct(st(I));I&&He(I,_)&&I.focus({preventScroll:!0})}}}),[ce,F,P,R,n,s,Se,a]),te=r.useMemo(()=>a&&D&&ye&&{"aria-activedescendant":`${V}-${o}`},[a,D,ye,V,o]),Q=r.useMemo(()=>({"aria-orientation":g==="both"?void 0:g,...$?{}:te,onKeyDown(f){if(f.key==="Tab"&&f.shiftKey&&D&&!a){const y=Rn(f.nativeEvent);if(y&&!He(P.current,y))return;Le(f),K.setOpen(!1,Me(Jt,f.nativeEvent)),jt(J)&&J.focus();return}ee(f)},onPointerMove(){k.current=!0}}),[te,ee,P,g,$,K,D,a,J]),re=r.useMemo(()=>{function f(I){K.setOpen(!0,Me(zt,I.nativeEvent,I.currentTarget))}function y(I){p==="auto"&&nn(I.nativeEvent)&&(z.current=!a)}function X(I){z.current=p,p==="auto"&&_n(I.nativeEvent)&&(z.current=!0)}return{onKeyDown(I){const _=K.select("open");k.current=!1;const ve=I.key.startsWith("Arrow"),De=ur(I.key,ue(),v),Ee=ft(I.key,g),Ae=(m?De:Ee)||I.key==="Enter"||I.key.trim()==="";if(a&&_)return ee(I);if(!(!_&&!b&&ve)){if(Ae){const fe=ft(I.key,ue());Y.current=m&&fe?null:I.key}if(m){De&&(Le(I),_?(T.current=de(),s(I)):f(I));return}Ee&&(se.current!=null&&(T.current=se.current),Le(I),!_&&b?f(I):ee(I),_&&s(I))}},onFocus(I){K.select("open")&&!a&&(T.current=-1,s(I))},onPointerDown:X,onPointerEnter:X,onMouseDown:y,onClick:y}},[ee,p,de,m,s,K,b,g,ue,v,se,a]),A=r.useMemo(()=>({...te,...re}),[te,re]);return r.useMemo(()=>c?{reference:A,floating:Q,item:xe,trigger:re}:{},[c,A,Q,re,xe])}function dr(e,t){const{listRef:n,elementsRef:o,activeIndex:l,onMatch:c,disabledIndices:i,onTyping:x,enabled:u=!0,resetMs:m=750,selectedIndex:v=null}=t,a="rootStore"in e?e.rootStore:e,p=a.useState("open"),R=ht(),b=r.useRef(""),O=r.useRef(v??l??-1),g=r.useRef(null),S=le(d=>{function L(P){const H=o?.current[P];return!H||In(H)}function j(P){return L(P)?i==null||!Sn(At,P,i):!1}function K(P,H,oe=0){if(P.length===0)return-1;const z=(oe%P.length+P.length)%P.length,T=H.toLowerCase();for(let Y=0;Y<P.length;Y+=1){const k=(z+Y)%P.length;if(!(!P[k]?.toLowerCase().startsWith(T)||!j(k)))return k}return-1}const D=n.current;if(b.current.length>0&&d.key===" "&&(Le(d),x?.(!0)),b.current.length>0&&b.current[0]!==" "&&K(D,b.current)===-1&&d.key!==" "&&x?.(!1),D==null||d.key.length!==1||d.ctrlKey||d.metaKey||d.altKey)return;p&&d.key!==" "&&(Le(d),x?.(!0));const W=b.current==="";W&&(O.current=v??l??-1),D.every((P,H)=>P&&j(H)?P[0]?.toLowerCase()!==P[1]?.toLowerCase():!0)&&b.current===d.key&&(b.current="",O.current=g.current),b.current+=d.key,R.start(m,()=>{b.current="",O.current=g.current,x?.(!1)});const he=((W?v??l??-1:O.current)??0)+1,$=K(D,b.current,he);$!==-1?(c?.($),g.current=$):d.key!==" "&&(b.current="",x?.(!1))}),V=le(d=>{const L=d.relatedTarget,j=a.select("domReferenceElement"),K=a.select("floatingElement");He(j,L)||He(K,L)||(R.clear(),b.current="",O.current=g.current,x?.(!1))});G(()=>{!p&&v!==null||(R.clear(),g.current=null,b.current!==""&&(b.current=""))},[p,v,R]),G(()=>{p&&b.current===""&&(O.current=v??l??-1)},[p,v,l]);const E=r.useMemo(()=>({onKeyDown:S,onBlur:V}),[S,V]);return r.useMemo(()=>u?{reference:E,floating:E}:{},[u,E])}function pr(e){const[t,n]=r.useState({current:e,previous:null});return e!==t.current&&n({current:e,previous:t.current}),t.previous}function gr(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function Wt({controlled:e,default:t,name:n,state:o="value"}){const{current:l}=r.useRef(e!==void 0),[c,i]=r.useState(t),x=l?e:c,u=r.useCallback(m=>{l||i(m)},[]);return[x,u]}const on=r.createContext(null),sn=r.createContext(null);function qe(){const e=r.useContext(on);if(e===null)throw new Error(it(60));return e}function ln(){const e=r.useContext(sn);if(e===null)throw new Error(it(61));return e}let Yt=(function(e){return e.disabled="data-disabled",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const mr={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},nt={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},hr={disabled:!1,...nt},br={valid(e){return e===null?null:e?{[Yt.valid]:""}:{[Yt.invalid]:""}}},yr={invalid:void 0,name:void 0,validityData:{state:mr,errors:[],error:"",value:"",initialValue:null},setValidityData:Re,disabled:void 0,touched:nt.touched,setTouched:Re,dirty:nt.dirty,setDirty:Re,filled:nt.filled,setFilled:Re,focused:nt.focused,setFocused:Re,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:hr,markedDirtyRef:{current:!1},registerFieldControl:Re,validation:{getValidationProps:(e,t=Qt)=>t,inputRef:{current:null},registerInput:Re,commit:async()=>{},change:Re}},xr=r.createContext(yr);function Nt(e=!0){const t=r.useContext(xr);if(t.setValidityData===Re&&!e)throw new Error(it(28));return t}function Rr(e,t,n,o,l=!0,c){const{registerFieldControl:i}=Nt(),x=r.useRef(null);x.current||(x.current=Symbol()),G(()=>{const u=x.current;return!u||!l?void 0:(i(u,{controlRef:e,getValue:o,id:t,name:c,value:n}),()=>{i(u,void 0)})},[e,l,o,t,c,i,n])}const Sr=r.createContext({controlId:void 0,registerControlId:Re,labelId:void 0,setLabelId:Re,messageIds:[],setMessageIds:Re,getDescriptionProps:e=>e});function cn(){return r.useContext(Sr)}function un(e={}){const{id:t,implicit:n=!1,controlRef:o}=e,{controlId:l,registerControlId:c}=cn(),i=Bn(t),x=n?l:void 0,u=yt(()=>Symbol("labelable-control")),m=r.useRef(!1),v=r.useRef(t!=null),a=le(()=>{!m.current||c===Re||(m.current=!1,c(u.current,void 0))});return G(()=>{if(c===Re)return;let p;if(n){const R=o?.current;En(R)&&R.closest("label")!=null?p=t??null:p=x??i}else if(t!=null)v.current=!0,p=t;else if(v.current)p=i;else{a();return}if(p===void 0){a();return}m.current=!0,c(u.current,p)},[t,o,x,c,n,i,u,a]),r.useEffect(()=>a,[a]),l??i}const Ir=(e,t)=>Object.is(e,t);function Ye(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Er(e,t,n){return!e||e.length===0?!1:e.some(o=>o===void 0?!1:Ye(t,o,n))}function ot(e,t,n){return!e||e.length===0?-1:e.findIndex(o=>o===void 0?!1:Ye(o,t,n))}function Tr(e,t,n){return e.filter(o=>!Ye(t,o,n))}function Vt(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function an(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function Mr(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(an(t)){for(const n of t)for(const o of n.items)if(o&&o.value==null&&o.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function fn(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 Vt(e)}function je(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?Vt(e.value):Vt(e)}function dn(e,t,n){function o(){return fn(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 t[e]??o();if(Array.isArray(t)){const l=t,c=an(l)?l.flatMap(i=>i.items):l;if(e==null||typeof e!="object"){const i=c.find(x=>x.value===e);return i&&i.label!=null?i.label:o()}if("value"in e){const i=c.find(x=>x&&x.value===e.value);if(i&&i.label!=null)return i.label}}return o()}function Cr(e,t,n){return e.reduce((o,l,c)=>(c>0&&o.push(", "),o.push(be.jsx(r.Fragment,{children:dn(l,t,n)},c)),o),[])}const C={id:q(e=>e.id),labelId:q(e=>e.labelId),modal:q(e=>e.modal),multiple:q(e=>e.multiple),items:q(e=>e.items),itemToStringLabel:q(e=>e.itemToStringLabel),itemToStringValue:q(e=>e.itemToStringValue),isItemEqualToValue:q(e=>e.isItemEqualToValue),value:q(e=>e.value),hasSelectedValue:q(e=>{const{value:t,multiple:n,itemToStringValue:o}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:je(t,o)!==""}),hasNullItemLabel:q((e,t)=>t?Mr(e.items):!1),open:q(e=>e.open),mounted:q(e=>e.mounted),forceMount:q(e=>e.forceMount),transitionStatus:q(e=>e.transitionStatus),openMethod:q(e=>e.openMethod),activeIndex:q(e=>e.activeIndex),selectedIndex:q(e=>e.selectedIndex),isActive:q((e,t)=>e.activeIndex===t),isSelected:q((e,t)=>{const n=e.isItemEqualToValue,o=e.value;return e.multiple?Array.isArray(o)&&o.some(l=>Ye(t,l,n)):Ye(t,o,n)}),isSelectedByFocus:q((e,t)=>e.selectedIndex===t),popupProps:q(e=>e.popupProps),triggerProps:q(e=>e.triggerProps),triggerElement:q(e=>e.triggerElement),positionerElement:q(e=>e.positionerElement),listElement:q(e=>e.listElement),popupSide:q(e=>e.popupSide),scrollUpArrowVisible:q(e=>e.scrollUpArrowVisible),scrollDownArrowVisible:q(e=>e.scrollDownArrowVisible),hasScrollArrows:q(e=>e.hasScrollArrows)},vr=r.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:Re,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function wr(){return r.useContext(vr)}function Pr(e,t,n=(o,l)=>o===l){return e.length===t.length&&e.every((o,l)=>n(o,t[l]))}const Fe=1;function pn(e,t){return Math.max(0,e-t)}function Ar(e,t){if(t<=0)return 0;const n=tt(e,0,t),o=n,l=t-n,c=o<=Fe,i=l<=Fe;return c&&i?o<=l?0:t:c?0:i?t:n}function to(e){const{id:t,value:n,defaultValue:o=null,onValueChange:l,open:c,defaultOpen:i=!1,onOpenChange:x,name:u,form:m,autoComplete:v,disabled:a=!1,readOnly:p=!1,required:R=!1,modal:b=!0,actionsRef:O,inputRef:g,onOpenChangeComplete:S,items:V,multiple:E=!1,itemToStringLabel:d,itemToStringValue:L,isItemEqualToValue:j=Ir,highlightItemOnHover:K=!0,children:D}=e,{clearErrors:W}=wr(),{setDirty:J,setTouched:me,setFocused:he,validityData:$,setFilled:P,name:H,disabled:oe,validation:z,validationMode:T}=Nt(),Y=un({id:t}),k=oe||a,s=H??u,[M,ae]=Wt({controlled:n,default:E?o??At:o,name:"Select",state:"value"}),[U,pe]=Wt({controlled:c,default:i,name:"Select",state:"open"}),ge=r.useRef([]),h=r.useRef([]),F=r.useRef(null),se=r.useRef(null),Se=r.useRef(0),B=r.useRef(null),ne=r.useRef([]),Z=r.useRef(!1),ye=r.useRef(null),ce=r.useRef(null),ue=r.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),de=r.useRef(!1),{mounted:ee,setMounted:xe,transitionStatus:te}=rn(U),{openMethod:Q,triggerProps:re}=Xn(U),A=yt(()=>new vn({id:Y,labelId:void 0,modal:b,multiple:E,itemToStringLabel:d,itemToStringValue:L,isItemEqualToValue:j,value:M,open:U,mounted:ee,transitionStatus:te,items:V,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,f=w(A,C.activeIndex),y=w(A,C.selectedIndex),X=w(A,C.triggerElement),I=w(A,C.positionerElement),_=pr(Q),ve=Q??_??null,De=r.useMemo(()=>E?"":je(M,L),[E,M,L]),Ee=r.useMemo(()=>E&&Array.isArray(M)?M.map(N=>je(N,L)):je(M,L),[E,M,L]),Ae=We(A.state.triggerElement),fe=le(()=>Ee);Rr(Ae,Y,M,fe,!k,u);const Oe=r.useRef(M),Ve=E?Array.isArray(M)&&M.length>0:M!=null&&je(M,L)!=="";G(()=>{M!==Oe.current&&A.set("forceMount",!0)},[A,M]),G(()=>{P(Ve)},[Ve,P]),G(function(){const ie=ne.current;let Te;if(E){const Ie=Array.isArray(M)?M:[];if(Ie.length===0)Te=null;else{const Ue=Ie[Ie.length-1],ze=ot(ie,Ue,j);Te=ze===-1?null:ze}}else{const Ie=ot(ie,M,j);Te=Ie===-1?null:Ie}Te===null&&(ce.current=null),!U&&A.set("selectedIndex",Te)},[Ve,E,U,M,ne,j,A,ce]);function we(N){const ie=$.initialValue;return Array.isArray(N)&&Array.isArray(ie)?!Pr(N,ie,(Te,Ie)=>Ye(Te,Ie,j)):N!==ie}Jn(M,()=>{W(s),J(we(M)),z.change(M)});const Ke=le((N,ie)=>{x?.(N,ie),!ie.isCanceled&&(pe(N),!N&&(ie.reason===Jt||ie.reason===wn)&&(me(!0),he(!1),T==="onBlur"&&z.commit(M)))}),$e=le(()=>{xe(!1),A.update({activeIndex:null,openMethod:null}),S?.(!1)});Ft({enabled:!O,open:U,ref:F,onComplete(){U||$e()}}),r.useImperativeHandle(O,()=>({unmount:$e}),[$e]);const Ne=le((N,ie)=>{l?.(N,ie),!ie.isCanceled&&ae(N)}),Pe=le(()=>{const N=A.state.listElement||F.current;if(!N)return;const ie=pn(N.scrollHeight,N.clientHeight),Te=Ar(N.scrollTop,ie),Ie=Te>0,Ue=Te<ie;A.state.scrollUpArrowVisible!==Ie&&A.set("scrollUpArrowVisible",Ie),A.state.scrollDownArrowVisible!==Ue&&A.set("scrollDownArrowVisible",Ue)}),_e=Zn({open:U,onOpenChange:Ke,elements:{reference:X,floating:I}}),Ge=Qn(_e,{enabled:!p&&!k,event:"mousedown"}),Xe=zn(_e),ke=fr(_e,{enabled:!p&&!k,listRef:ge,activeIndex:f,selectedIndex:y,disabledIndices:At,onNavigate(N){N===null&&!U||A.set("activeIndex",N)},focusItemOnHover:K}),Be=dr(_e,{enabled:!p&&!k&&(U||!E),listRef:h,activeIndex:f,selectedIndex:y,disabledIndices:N=>gr(ge.current[N]),onMatch(N){U?A.set("activeIndex",N):Ne(ne.current[N],Me("none"))},onTyping(N){Z.current=N}}),Qe=r.useMemo(()=>{const N=Ot(Be.reference,ke.reference,Xe.reference,Ge.reference,re);return Y&&(N.id=Y),N},[Ge.reference,Be.reference,ke.reference,Xe.reference,re,Y]),et=r.useMemo(()=>Ot(jn,Be.floating,ke.floating,Xe.floating),[Be.floating,ke.floating,Xe.floating]),lt=ke.item??Qt;Wn(()=>{A.update({popupProps:et,triggerProps:Qe})}),G(()=>{A.update({id:Y,modal:b,multiple:E,value:M,open:U,mounted:ee,transitionStatus:te,popupProps:et,triggerProps:Qe,items:V,itemToStringLabel:d,itemToStringValue:L,isItemEqualToValue:j,openMethod:ve})},[A,Y,b,E,M,U,ee,te,et,Qe,V,d,L,j,ve]);const Ce=r.useMemo(()=>({store:A,name:s,required:R,disabled:k,readOnly:p,multiple:E,highlightItemOnHover:K,setValue:Ne,setOpen:Ke,listRef:ge,popupRef:F,scrollHandlerRef:se,handleScrollArrowVisibility:Pe,scrollArrowsMountedCountRef:Se,itemProps:lt,valueRef:B,valuesRef:ne,labelsRef:h,typingRef:Z,selectionRef:ue,firstItemTextRef:ye,selectedItemTextRef:ce,validation:z,onOpenChangeComplete:S,alignItemWithTriggerActiveRef:de,initialValueRef:Oe}),[A,s,R,k,p,E,K,Ne,Ke,lt,z,S,Pe]),Je=Tn(g,z.inputRef),ct=E&&Array.isArray(M)&&M.length>0,ut=E?void 0:s,Et=r.useMemo(()=>!E||!Array.isArray(M)||!s?null:M.map(N=>{const ie=je(N,L);return be.jsx("input",{type:"hidden",form:m,name:s,value:ie,disabled:k},ie)}),[E,M,m,s,L,k]);return be.jsx(on.Provider,{value:Ce,children:be.jsxs(sn.Provider,{value:_e,children:[D,be.jsx("input",{...z.getValidationProps(k,{onFocus(){A.state.triggerElement?.focus({focusVisible:!0})},onChange(N){if(N.nativeEvent.defaultPrevented||k||p)return;const ie=N.currentTarget.value,Te=Me(Dt,N.nativeEvent);function Ie(){if(E)return;const Ue=ie.toLowerCase();let ze=ne.current.findIndex(Tt=>je(Tt,L).toLowerCase()===Ue||fn(Tt,d).toLowerCase()===Ue);ze===-1&&(ze=ne.current.findIndex((Tt,yn)=>{const Ht=h.current[yn];return Ht!=null&&Ht.toLowerCase()===Ue}));const Ut=ze===-1?void 0:ne.current[ze];Ut!=null&&Ne(Ut,Te)}A.set("forceMount",!0),queueMicrotask(Ie)}}),id:Y&&ut==null?`${Y}-hidden-input`:void 0,form:m,name:ut,autoComplete:v,value:De,disabled:k,required:R&&!ct,readOnly:p,ref:Je,style:s?Mn:Cn,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Et]})})}function Or(e,t){return e??t}function Vr(e){const t=e.getBoundingClientRect(),n=bt(e);if(Pn)return t;const o=n.getComputedStyle(e,"::before"),l=n.getComputedStyle(e,"::after");if(!(o.content!=="none"||l.content!=="none"))return t;const i=parseFloat(o.width)||0,x=parseFloat(o.height)||0,u=parseFloat(l.width)||0,m=parseFloat(l.height)||0,v=Math.max(t.width,i,u),a=Math.max(t.height,x,m),p=v-t.width,R=a-t.height;return{left:t.left-p/2,right:t.right+p/2,top:t.top-R/2,bottom:t.bottom+R/2}}const dt=2,Lr=400,Fr={...Yn,...br,popupSide:e=>e?{"data-popup-side":e}:null,value:()=>null},no=r.forwardRef(function(t,n){const{render:o,className:l,id:c,disabled:i=!1,nativeButton:x=!0,style:u,...m}=t,{setTouched:v,setFocused:a,validationMode:p,state:R,disabled:b}=Nt(),{labelId:O}=cn(),{store:g,setOpen:S,selectionRef:V,validation:E,readOnly:d,required:L,alignItemWithTriggerActiveRef:j,disabled:K}=qe(),D=b||K||i,W=w(g,C.open),J=w(g,C.mounted),me=w(g,C.value),he=w(g,C.triggerProps),$=w(g,C.positionerElement),P=w(g,C.listElement),H=w(g,C.popupSide),oe=w(g,C.id),z=w(g,C.labelId),T=w(g,C.hasSelectedValue),Y=J&&$?H:null,k=c??oe,s=Or(O,z);un({id:k});const M=We($),ae=r.useRef(null),{getButtonProps:U,buttonRef:pe}=en({disabled:D,native:x}),ge=le(Z=>{g.set("triggerElement",Z)}),h=ht(),F=ht(),se=ht();r.useEffect(()=>{if(W)return se.start(Lr,()=>{V.current.allowUnselectedMouseUp=!0,V.current.allowSelectedMouseUp=!0}),()=>{se.clear()};V.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},F.clear()},[W,V,F,se]);const Se=Ot(he,{id:k,role:"combobox","aria-expanded":W?"true":"false","aria-haspopup":"listbox","aria-controls":W?P?.id??Xt($)?.id:void 0,"aria-labelledby":s,"aria-readonly":d||void 0,"aria-required":L||void 0,tabIndex:D?-1:0,onFocus(Z){a(!0),W&&j.current&&S(!1,Me(Dt,Z.nativeEvent)),h.start(0,()=>{g.set("forceMount",!0)})},onBlur(Z){He($,Z.relatedTarget)||(v(!0),a(!1),p==="onBlur"&&E.commit(me))},onMouseDown(Z){if(W)return;const ye=st(Z.currentTarget);function ce(ue){if(!ae.current)return;const de=ue.target;if(He(ae.current,de)||He(M.current,de))return;const ee=Vr(ae.current);ue.clientX>=ee.left-dt&&ue.clientX<=ee.right+dt&&ue.clientY>=ee.top-dt&&ue.clientY<=ee.bottom+dt||S(!1,Me(An,ue))}F.start(0,()=>{ye.addEventListener("mouseup",ce,{once:!0})})}},m,U),B=E.getValidationProps(D,Se);B.role="combobox";const ne={...R,open:W,disabled:D,value:me,readOnly:d,popupSide:Y,placeholder:!T};return Ze("button",t,{ref:[n,ae,pe,ge],state:ne,stateAttributesMapping:Fr,props:B})}),Dr={value:()=>null},ro=r.forwardRef(function(t,n){const{className:o,render:l,children:c,placeholder:i,style:x,...u}=t,{store:m,valueRef:v}=qe(),a=w(m,C.value),p=w(m,C.items),R=w(m,C.itemToStringLabel),b=w(m,C.hasSelectedValue),O=!b&&i!=null&&c==null,g=w(m,C.hasNullItemLabel,O),S={value:a,placeholder:!b};let V=null;return typeof c=="function"?V=c(a):c!=null?V=c:!b&&i!=null&&!g?V=i:Array.isArray(a)?V=Cr(a,p,R):V=dn(a,p,R),Ze("span",t,{state:S,ref:[n,v],props:[{children:V},u],stateAttributesMapping:Dr})}),Nr=r.createContext(void 0),oo=r.forwardRef(function(t,n){const{store:o}=qe(),l=w(o,C.mounted),c=w(o,C.forceMount);return l||c?be.jsx(Nr.Provider,{value:!0,children:be.jsx(On,{ref:n,...t})}):null}),gn=r.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function kr(){return r.useContext(gn)}function Ur(e){const{children:t,elementsRef:n,labelsRef:o,onMapChange:l}=e,c=le(l),i=r.useRef(0),x=yt(_r).current,u=yt(Hr).current,[m,v]=r.useState(0),a=r.useRef(m),p=le((S,V)=>{u.set(S,V??null),a.current+=1,v(a.current)}),R=le(S=>{u.delete(S),a.current+=1,v(a.current)}),b=r.useMemo(()=>{const S=new Map;return Array.from(u.keys()).filter(E=>E.isConnected).sort(Br).forEach((E,d)=>{const L=u.get(E)??{};S.set(E,{...L,index:d})}),S},[u,m]);G(()=>{if(typeof MutationObserver!="function"||b.size===0)return;const S=new MutationObserver(V=>{const E=new Set,d=L=>E.has(L)?E.delete(L):E.add(L);V.forEach(L=>{L.removedNodes.forEach(d),L.addedNodes.forEach(d)}),E.size===0&&(a.current+=1,v(a.current))});return b.forEach((V,E)=>{E.parentElement&&S.observe(E.parentElement,{childList:!0})}),()=>{S.disconnect()}},[b]),G(()=>{a.current===m&&(n.current.length!==b.size&&(n.current.length=b.size),o&&o.current.length!==b.size&&(o.current.length=b.size),i.current=b.size),c(b)},[c,b,n,o,m]),G(()=>()=>{n.current=[]},[n]),G(()=>()=>{o&&(o.current=[])},[o]);const O=le(S=>(x.add(S),()=>{x.delete(S)}));G(()=>{x.forEach(S=>S(b))},[x,b]);const g=r.useMemo(()=>({register:p,unregister:R,subscribeMapChange:O,elementsRef:n,labelsRef:o,nextIndexRef:i}),[p,R,O,n,o,i]);return be.jsx(gn.Provider,{value:g,children:t})}function Hr(){return new Map}function _r(){return new Set}function Br(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const mn=r.createContext(void 0);function zr(){const e=r.useContext(mn);if(!e)throw new Error(it(59));return e}function xt(e,t){e&&Object.assign(e.style,t)}const jr={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},Wr={position:"fixed"},so=r.forwardRef(function(t,n){const{anchor:o,positionMethod:l="absolute",className:c,render:i,side:x="bottom",align:u="center",sideOffset:m=0,alignOffset:v=0,collisionBoundary:a="clipping-ancestors",collisionPadding:p,arrowPadding:R=5,sticky:b=!1,disableAnchorTracking:O,alignItemWithTrigger:g=!0,collisionAvoidance:S=Vn,style:V,...E}=t,{store:d,listRef:L,labelsRef:j,alignItemWithTriggerActiveRef:K,selectedItemTextRef:D,valuesRef:W,initialValueRef:J,popupRef:me,setValue:he}=qe(),$=ln(),P=w(d,C.open),H=w(d,C.mounted),oe=w(d,C.modal),z=w(d,C.value),T=w(d,C.openMethod),Y=w(d,C.positionerElement),k=w(d,C.triggerElement),s=w(d,C.isItemEqualToValue),M=w(d,C.transitionStatus),ae=r.useRef(null),U=r.useRef(null),[pe,ge]=r.useState(g),h=H&&pe&&T!=="touch";!H&&pe!==g&&ge(g),G(()=>{H||(C.scrollUpArrowVisible(d.state)&&d.set("scrollUpArrowVisible",!1),C.scrollDownArrowVisible(d.state)&&d.set("scrollDownArrowVisible",!1))},[d,H]),r.useImperativeHandle(K,()=>h),er((h||oe)&&P,T==="touch",Y,k);const F=tr({anchor:o,floatingRootContext:$,positionMethod:l,mounted:H,side:x,sideOffset:m,align:u,alignOffset:v,arrowPadding:R,collisionBoundary:a,collisionPadding:p,sticky:b,disableAnchorTracking:O??h,collisionAvoidance:S,keepMounted:!0}),se=h?"none":F.side,Se=h?Wr:F.positionerStyles,B={open:P,side:se,align:F.align,anchorHidden:F.anchorHidden};G(()=>{d.set("popupSide",F.side)},[d,F.side]);const ne=le(de=>{d.set("positionerElement",de)}),Z=nr(t,B,{styles:Se,transitionStatus:M,props:E,refs:[n,ne],hidden:!H,inert:!P}),ye=r.useRef(0),ce=le(de=>{if(de.size===0&&ye.current===0||W.current.length===0)return;const ee=ye.current;if(ye.current=de.size,de.size===ee)return;const xe=Me(Dt);if(ee!==0&&!d.state.multiple&&z!==null&&ot(W.current,z,s)===-1){const Q=J.current,A=Q!=null&&ot(W.current,Q,s)!==-1?Q:null;he(A,xe),A===null&&(d.set("selectedIndex",null),D.current=null)}if(ee!==0&&d.state.multiple&&Array.isArray(z)){const te=re=>ot(W.current,re,s)!==-1,Q=z.filter(re=>te(re));(Q.length!==z.length||Q.some(re=>!Er(z,re,s)))&&(he(Q,xe),Q.length===0&&(d.set("selectedIndex",null),D.current=null))}if(P&&h){d.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const te={height:""};xt(Y,te),xt(me.current,te)}}),ue=r.useMemo(()=>({...F,side:se,alignItemWithTriggerActive:h,setControlledAlignItemWithTrigger:ge,scrollUpArrowRef:ae,scrollDownArrowRef:U}),[F,se,h,ge]);return be.jsx(Ur,{elementsRef:L,labelsRef:j,onMapChange:ce,children:be.jsxs(mn.Provider,{value:ue,children:[H&&oe&&be.jsx(qn,{inert:Ln(!P),cutout:k}),Z]})})}),pt="base-ui-disable-scrollbar",qt={className:pt,getElement(e){return be.jsx("style",{nonce:e,href:pt,precedence:"base-ui:low",children:`.${pt}{scrollbar-width:none}.${pt}::-webkit-scrollbar{display:none}`})}},Yr=r.createContext(void 0),qr={disableStyleElements:!1};function Kr(){return r.useContext(Yr)??qr}const $r={...$n,...tn},io=r.forwardRef(function(t,n){const{render:o,className:l,style:c,finalFocus:i,...x}=t,{store:u,popupRef:m,onOpenChangeComplete:v,setOpen:a,valueRef:p,firstItemTextRef:R,selectedItemTextRef:b,multiple:O,handleScrollArrowVisibility:g,scrollHandlerRef:S,listRef:V,highlightItemOnHover:E}=qe(),{side:d,align:L,alignItemWithTriggerActive:j,isPositioned:K,setControlledAlignItemWithTrigger:D}=zr(),W=rr()!=null,J=ln(),me=or(),{nonce:he,disableStyleElements:$}=Kr(),P=w(u,C.id),H=w(u,C.open),oe=w(u,C.openMethod),z=w(u,C.mounted),T=w(u,C.popupProps),Y=w(u,C.transitionStatus),k=w(u,C.triggerElement),s=w(u,C.positionerElement),M=w(u,C.listElement),ae=r.useRef(!1),U=r.useRef(!1),pe=r.useRef({}),ge=Pt(),h=le(B=>{if(!s||!m.current||!U.current)return;if(ae.current||!j){g();return}const ne=s.style.top==="0px",Z=s.style.bottom==="0px";if(!ne&&!Z){g();return}const ye=$t(s),ce=rt(s.getBoundingClientRect().height,"y",ye),ue=st(s),de=bt(s),ee=de.getComputedStyle(s),xe=parseFloat(ee.marginTop),te=parseFloat(ee.marginBottom),Q=Kt(de.getComputedStyle(m.current)),re=Math.min(ue.documentElement.clientHeight-xe-te,Q),A=B.scrollTop,f=gt(B);let y=0,X=null,I=!1,_=!1;const ve=fe=>{s.style.height=`${fe}px`},De=(fe,Oe)=>{const Ve=tt(fe,0,re-ce);Ve>0&&ve(ce+Ve),B.scrollTop=Oe,re-(ce+Ve)<=Fe&&(ae.current=!0),g()},Ee=ne?f-A:A,Ae=Math.min(ce+Ee,re);if(y=Ae,Ee<=Fe){De(Ee,ne?f:0);return}if(re-Ae>Fe)ne?_=!0:X=0;else if(I=!0,Z&&A<f){const fe=ce+Ee-re;X=A-(Ee-fe)}if(y=Math.ceil(y),y!==0&&ve(y),_||X!=null){const fe=gt(B),Oe=_?fe:tt(X,0,fe);Math.abs(B.scrollTop-Oe)>Fe&&(B.scrollTop=Oe)}(I||y>=re-Fe)&&(ae.current=!0),g()});r.useImperativeHandle(S,()=>h,[h]),Ft({open:H,ref:m,onComplete(){H&&v?.(!0)}});const F={open:H,transitionStatus:Y,side:d,align:L};G(()=>{!s||!m.current||Object.keys(pe.current).length||(pe.current={top:s.style.top||"0",left:s.style.left||"0",right:s.style.right,height:s.style.height,bottom:s.style.bottom,minHeight:s.style.minHeight,maxHeight:s.style.maxHeight,marginTop:s.style.marginTop,marginBottom:s.style.marginBottom})},[m,s]),G(()=>{H||j||(U.current=!1,ae.current=!1,xt(s,pe.current))},[H,j,s,m]),G(()=>{const B=m.current;if(!H||!k||!s||!B||j&&!K||u.state.transitionStatus==="ending")return;if(!j){U.current=!0,ge.request(g),B.style.removeProperty("--transform-origin");return}const ne=Gr(B);B.style.removeProperty("--transform-origin");try{let Z=b.current;Z?.isConnected||(Z=!C.hasSelectedValue(u.state)&&R.current?.isConnected?R.current:null);const ye=p.current,ce=bt(s),ue=ce.getComputedStyle(s),de=ce.getComputedStyle(B),ee=st(k),xe=$t(k),te=mt(k.getBoundingClientRect(),xe),Q=mt(s.getBoundingClientRect(),xe),re=te.height,A=M||B,f=A.scrollHeight,y=parseFloat(de.borderBottomWidth),X=parseFloat(ue.marginTop)||10,I=parseFloat(ue.marginBottom)||10,_=parseFloat(ue.minHeight)||100,ve=Kt(de),De=5,Ee=5,Ae=20,fe=ee.documentElement.clientHeight-X-I,Oe=ee.documentElement.clientWidth,Ve=fe-te.bottom+re;let we,Ke=me==="rtl"?te.right-Q.width:te.left,$e=0;if(Z&&ye){const Ce=mt(ye.getBoundingClientRect(),xe);we=mt(Z.getBoundingClientRect(),xe),Ke=Q.left+(me==="rtl"?Ce.right-we.right:Ce.left-we.left);const Je=Ce.top-te.top+Ce.height/2;$e=we.top-Q.top+we.height/2-Je}const Ne=Ve+$e+I+y;let Pe=Math.min(fe,Ne);const _e=fe-X-I,Ge=Ne-Pe,Xe=Oe-Ee;s.style.left=`${tt(Ke,De,Xe-Q.width)}px`,s.style.height=`${Pe}px`,s.style.maxHeight="none",s.style.marginTop=`${X}px`,s.style.marginBottom=`${I}px`,B.style.height="100%";const ke=gt(A),Be=Ge>=ke-Fe;Be&&(Pe=Math.min(fe,Q.height)-(Ge-ke));const Qe=te.top<Ae||te.bottom>fe-Ae||Math.ceil(Pe)+Fe<Math.min(f,_),et=(ce.visualViewport?.scale??1)!==1&&Fn;if(Qe||et){U.current=!0,xt(s,pe.current),D(!1);return}const lt=Math.max(_,Pe);if(Be){const Ce=Math.max(0,fe-Ne);s.style.top=Q.height>=_e?"0":`${Ce}px`,s.style.height=`${Pe}px`,A.scrollTop=gt(A)}else s.style.bottom="0",A.scrollTop=Ge;if(we){const Ce=Q.top,Je=Q.height,ct=we.top+we.height/2,ut=Je>0?(ct-Ce)/Je*100:50,Et=tt(ut,0,100);B.style.setProperty("--transform-origin",`50% ${Et}%`)}(lt===fe||Pe>=ve)&&(ae.current=!0),g(),E&&u.state.selectedIndex===null&&u.state.activeIndex===null&&V.current[0]!=null&&u.set("activeIndex",0),U.current=!0}finally{ne()}},[u,H,s,k,p,R,b,m,g,j,D,ge,M,V,E,me,K]),r.useEffect(()=>{if(!j||!s||!H)return;const B=bt(s);function ne(Z){a(!1,Me(Nn,Z))}return Dn(B,"resize",ne)},[a,j,s,H]);const se={...M?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":O||void 0,id:`${P}-list`},onKeyDown(B){W&&Gn.has(B.key)&&B.stopPropagation()},onScroll(B){M||h(B.currentTarget)},...j&&{style:M?{height:"100%"}:jr}},Se=Ze("div",t,{ref:[n,m],state:F,stateAttributesMapping:$r,props:[T,se,lr(Y),{className:!M&&j?qt.className:void 0},x]});return be.jsxs(r.Fragment,{children:[!$&&qt.getElement(he),be.jsx(Kn,{context:J,modal:!1,disabled:!z,openInteractionType:oe,returnFocus:i,restoreFocus:!0,children:Se})]})});function Kt(e){const t=e.maxHeight||"";return t.endsWith("px")&&parseFloat(t)||1/0}function gt(e){return pn(e.scrollHeight,e.clientHeight)}function $t(e){return sr.getScale(e)}function rt(e,t,n){return e/n[t]}function mt(e,t){return ir({x:rt(e.x,"x",t),y:rt(e.y,"y",t),width:rt(e.width,"x",t),height:rt(e.height,"y",t)})}const Gt=[["transform","none"],["scale","1"],["translate","0 0"]];function Gr(e){const{style:t}=e,n={};for(const[o,l]of Gt)n[o]=t.getPropertyValue(o),t.setProperty(o,l,"important");return()=>{for(const[o]of Gt){const l=n[o];l?t.setProperty(o,l):t.removeProperty(o)}}}let hn=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function Xr(e={}){const{label:t,metadata:n,textRef:o,indexGuessBehavior:l,index:c}=e,{register:i,unregister:x,subscribeMapChange:u,elementsRef:m,labelsRef:v,nextIndexRef:a}=kr(),p=r.useRef(-1),[R,b]=r.useState(c??(l===hn.GuessFromOrder?()=>{if(p.current===-1){const S=a.current;a.current+=1,p.current=S}return p.current}:-1)),O=r.useRef(null),g=r.useCallback(S=>{if(O.current=S,R!==-1&&S!==null&&(m.current[R]=S,v)){const V=t!==void 0;v.current[R]=V?t:o?.current?.textContent??S.textContent}},[R,m,v,t,o]);return G(()=>{if(c!=null)return;const S=O.current;if(S)return i(S,n),()=>{x(S)}},[c,i,x,n]),G(()=>{if(c==null)return u(S=>{const V=O.current?S.get(O.current)?.index:null;V!=null&&b(V)})},[c,u,b]),{ref:g,index:R}}const bn=r.createContext(void 0);function kt(){const e=r.useContext(bn);if(!e)throw new Error(it(57));return e}const lo=r.memo(r.forwardRef(function(t,n){const{render:o,className:l,style:c,value:i=null,label:x,disabled:u=!1,nativeButton:m=!1,...v}=t,a=r.useRef(null),p=Xr({label:x,textRef:a,indexGuessBehavior:hn.GuessFromOrder}),{store:R,itemProps:b,setOpen:O,setValue:g,selectionRef:S,typingRef:V,valuesRef:E,multiple:d,selectedItemTextRef:L,disabled:j,readOnly:K}=qe(),D=w(R,C.isActive,p.index),W=w(R,C.open),J=w(R,C.isSelected,i),me=w(R,C.isSelectedByFocus,p.index),he=w(R,C.isItemEqualToValue),$=p.index,P=$!==-1,H=r.useRef(null);G(()=>{if(!P)return;const h=E.current;return h[$]=i,()=>{delete h[$]}},[P,$,i,E]),G(()=>{if(!P)return;const h=R.state.value;let F=h;d&&Array.isArray(h)&&(F=h.length>0?h[h.length-1]:void 0),F!==void 0&&Ye(i,F,he)&&(R.set("selectedIndex",$),a.current&&(L.current=a.current))},[P,$,d,he,R,i,L]);const oe=r.useRef(null),z=r.useRef("mouse"),T=r.useRef(!1),{getButtonProps:Y,buttonRef:k}=en({disabled:u,focusableWhenDisabled:!0,native:m,composite:!0}),s={disabled:u,selected:J,highlighted:D};function M(h){if(j||K)return;const F=R.state.value;if(d){const se=Array.isArray(F)?F:[],Se=J?Tr(se,i,he):[...se,i];g(Se,Me(vt,h))}else g(i,Me(vt,h)),O(!1,Me(vt,h))}function ae(){S.current.dragY=0}const U={role:"option","aria-selected":J,tabIndex:W&&D?0:-1,onKeyDown(h){oe.current=h.key,R.set("activeIndex",$),h.key===" "&&V.current&&h.preventDefault()},onClick(h){const F=h.type==="click"&&z.current!=="touch",se=h.nativeEvent.pointerType,Se=F&&nn(h.nativeEvent)&&(se!==void 0||D),B=F&&!Se&&!T.current;T.current=!1,!(h.type==="keydown"&&oe.current===null)&&(u||h.type==="keydown"&&oe.current===" "&&V.current||B||(oe.current=null,M(h.nativeEvent)))},onPointerEnter(h){z.current=h.pointerType},onPointerMove(h){if(h.pointerType==="mouse"&&h.buttons===1){const F=S.current;F.dragY+=h.movementY,F.dragY**2>=64&&(F.allowUnselectedMouseUp=!0)}},onPointerDown(h){z.current=h.pointerType,T.current=!0,ae()},onMouseUp(){if(ae(),u||z.current==="touch"||T.current)return;const h=!S.current.allowSelectedMouseUp&&J,F=!S.current.allowUnselectedMouseUp&&!J;h||F||(T.current=!0,H.current?.click(),T.current=!1)}},pe=Ze("div",t,{ref:[k,n,p.ref,H],state:s,props:[b,U,v,Y]}),ge=r.useMemo(()=>({selected:J,index:$,textRef:a,selectedByFocus:me,hasRegistered:P}),[J,$,a,me,P]);return be.jsx(bn.Provider,{value:ge,children:pe})})),co=r.forwardRef(function(t,n){const o=t.keepMounted??!1,{selected:l}=kt();return o||l?be.jsx(Jr,{...t,ref:n}):null}),Jr=r.memo(r.forwardRef((e,t)=>{const{render:n,className:o,style:l,keepMounted:c,...i}=e,{selected:x}=kt(),u=r.useRef(null),{transitionStatus:m,setMounted:v}=rn(x),p=Ze("span",e,{ref:[t,u],state:{selected:x,transitionStatus:m},props:[{"aria-hidden":!0,children:"✔️"},i],stateAttributesMapping:tn});return Ft({open:x,ref:u,onComplete(){x||v(!1)}}),p})),uo=r.memo(r.forwardRef(function(t,n){const{index:o,textRef:l,selectedByFocus:c,hasRegistered:i}=kt(),{firstItemTextRef:x,selectedItemTextRef:u}=qe(),{render:m,className:v,style:a,...p}=t,R=r.useCallback(O=>{O&&(i&&o===0&&(x.current=O),i&&c&&(u.current=O))},[x,u,o,c,i]);return Ze("div",t,{ref:[R,n,l],props:p})}));export{jr as L,to as S,zr as a,qt as b,no as c,ro as d,oo as e,so as f,io as g,lo as h,co as i,uo as j,br as k,wr as l,Nt as m,cn as n,Wt as o,Rr as p,C as s,qe as u};
1
+ import{bU as Xt,bS as xn,r,V as le,bw as Pt,aZ as G,ce as _t,cf as Mt,cg as Bt,bY as Ct,bc as st,aH as He,A as Me,ch as zt,bu as jt,ci as at,aG as Rn,bl as Jt,cj as Rt,ck as St,cl as Zt,cm as Lt,ba as ht,cn as Sn,c0 as In,co as At,aA as it,a$ as Re,a0 as Qt,a_ as yt,bb as En,j as be,$ as q,U as w,aC as Ft,b1 as Ot,b0 as Tn,b3 as Mn,b4 as Cn,b5 as Dt,cp as vn,bZ as wn,b2 as bt,bQ as Pn,y as en,z as Ze,cq as An,aD as On,cr as Vn,aE as Ln,b_ as Fn,be as Dn,cs as Nn,aB as tn,ct as vt}from"./__vite-browser-external-CU0HL6hY.js";import{v as We,q as kn,o as Un,E as Hn,G as Le,H as nn,J as _n,u as Bn,m as rn,h as zn,a as jn,l as Wn,A as Yn,I as qn,d as Kn,p as $n,b as Gn}from"./useScrollLock-D2roJGoE.js";import{i as Xn,u as Jn,j as Zn,a as Qn,d as er,c as tr,e as nr,g as rr,k as or,p as sr,r as ir,h as lr}from"./ToolbarRootContext-D3Xvbsmu.js";function tt(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}const cr="Escape";function It(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function ft(e,t){return It(t,e===Zt||e===Lt,e===Rt||e===St)}function wt(e,t,n){return It(t,e===Lt,n?e===Rt:e===St)||e==="Enter"||e===" "||e===""}function ur(e,t,n){return It(t,n?e===Rt:e===St,e===Lt)}function ar(e,t,n,o){const l=n?e===St:e===Rt,c=e===Zt;return t==="both"||t==="horizontal"&&o?e===cr:It(t,l,c)}function fr(e,t){const{listRef:n,activeIndex:o,onNavigate:l=()=>{},enabled:c=!0,selectedIndex:i=null,allowEscape:x=!1,loopFocus:u=!1,nested:m=!1,rtl:v=!1,virtual:a=!1,focusItemOnOpen:p="auto",focusItemOnHover:R=!0,openOnArrowKeyDown:b=!0,disabledIndices:O=void 0,orientation:g="vertical",parentOrientation:S,id:V,resetOnPointerLeave:E=!0,externalTree:d,grid:L}=t,j=L!=null,K="rootStore"in e?e.rootStore:e,D=K.useState("open"),W=K.useState("floatingElement"),J=K.useState("domReferenceElement"),me=K.context.dataRef,he=Xt(W),$=xn(J),P=We(he),H=kn(),oe=Un(d),z=r.useRef(p),T=r.useRef(i??-1),Y=r.useRef(null),k=r.useRef(!0),s=le(f=>{l(T.current===-1?null:T.current,f)}),M=r.useRef(!!W),ae=r.useRef(D),U=r.useRef(!1),pe=r.useRef(!1),ge=r.useRef(null),h=We(O),F=We(D),se=We(i),Se=We(E),B=Pt(),ne=Pt(),Z=le(()=>{function f(_){a?oe?.events.emit("virtualfocus",_):ge.current=Hn(_,{sync:U.current,preventScroll:!0})}const y=n.current[T.current],X=pe.current;y&&f(y),(U.current?_=>_():_=>B.request(_))(()=>{const _=n.current[T.current]||y;if(!_)return;y||f(_),xe&&(X||!k.current)&&_.scrollIntoView?.({block:"nearest",inline:"nearest"})})});G(()=>{me.current.orientation=g},[me,g]),G(()=>{c&&(D&&W?(T.current=i??-1,z.current&&i!=null&&(pe.current=!0,s())):M.current&&(T.current=-1,s()))},[c,D,W,i,s]),G(()=>{if(c){if(!D){U.current=!1;return}if(W)if(o==null){if(U.current=!1,se.current!=null)return;if(M.current&&(T.current=-1,Z()),(!ae.current||!M.current)&&z.current&&(Y.current!=null||z.current===!0&&Y.current==null)){let f=0;const y=()=>{n.current[0]==null?(f<2&&(f?I=>ne.request(I):queueMicrotask)(y),f+=1):(T.current=Y.current==null||wt(Y.current,g,v)||m?Mt(n):Bt(n),Y.current=null,s())};y()}}else _t(n.current,o)||(T.current=o,Z(),pe.current=!1)}},[c,D,W,o,se,m,n,g,v,s,Z,ne]),G(()=>{if(!c||W||!oe||a||!M.current)return;const f=oe.nodesRef.current,y=f.find(_=>_.id===H)?.context?.elements.floating,X=Ct(st(J??y??null)),I=f.some(_=>_.context&&He(_.context.elements.floating,X));y&&!I&&k.current&&y.focus({preventScroll:!0})},[c,W,J,oe,H,a]),G(()=>{ae.current=D,M.current=!!W}),G(()=>{D||(Y.current=null,z.current=p)},[D,p]);const ye=o!=null,ce=le(f=>{if(!F.current)return;const y=n.current.indexOf(f.currentTarget);y!==-1&&(T.current!==y||o!==y)&&(T.current=y,s(f))}),ue=le(()=>S??oe?.nodesRef.current.find(f=>f.id===H)?.context?.dataRef?.current.orientation),de=le(()=>Mt(n,h.current)),ee=le(f=>{if(k.current=!1,U.current=!0,f.which===229||!F.current&&f.currentTarget===P.current)return;if(m&&ar(f.key,g,v,j)){ft(f.key,ue())||Le(f),K.setOpen(!1,Me(zt,f.nativeEvent)),jt(J)&&(a?oe?.events.emit("virtualfocus",J):J.focus());return}const y=T.current,X=Mt(n,O),I=Bt(n,O);if($||(f.key==="Home"&&(Le(f),T.current=X,s(f)),f.key==="End"&&(Le(f),T.current=I,s(f))),L!=null){const _=L(f,T.current,n,g,u,v,O,X,I);if(_!=null&&(T.current=_,s(f)),g==="both")return}if(ft(f.key,g)){if(Le(f),D&&!a&&Ct(f.currentTarget.ownerDocument)===f.currentTarget){T.current=wt(f.key,g,v)?X:I,s(f);return}wt(f.key,g,v)?u?y>=I?x&&y!==n.current.length?T.current=-1:(U.current=!1,T.current=X):T.current=at(n.current,{startingIndex:y,disabledIndices:O}):T.current=Math.min(I,at(n.current,{startingIndex:y,disabledIndices:O})):u?y<=X?x&&y!==-1?T.current=n.current.length:(U.current=!1,T.current=I):T.current=at(n.current,{startingIndex:y,decrement:!0,disabledIndices:O}):T.current=Math.max(X,at(n.current,{startingIndex:y,decrement:!0,disabledIndices:O})),_t(n.current,T.current)&&(T.current=-1),s(f)}}),xe=r.useMemo(()=>({onFocus(y){U.current=!0,ce(y)},onClick:({currentTarget:y})=>y.focus({preventScroll:!0}),onMouseMove(y){U.current=!0,pe.current=!1,R&&ce(y)},onPointerLeave(y){if(!F.current||!k.current||y.pointerType==="touch")return;U.current=!0;const X=y.relatedTarget;if(!(!R||n.current.includes(X))&&Se.current&&(ge.current?.(),ge.current=null,T.current=-1,s(y),!a)){const I=P.current,_=Ct(st(I));I&&He(I,_)&&I.focus({preventScroll:!0})}}}),[ce,F,P,R,n,s,Se,a]),te=r.useMemo(()=>a&&D&&ye&&{"aria-activedescendant":`${V}-${o}`},[a,D,ye,V,o]),Q=r.useMemo(()=>({"aria-orientation":g==="both"?void 0:g,...$?{}:te,onKeyDown(f){if(f.key==="Tab"&&f.shiftKey&&D&&!a){const y=Rn(f.nativeEvent);if(y&&!He(P.current,y))return;Le(f),K.setOpen(!1,Me(Jt,f.nativeEvent)),jt(J)&&J.focus();return}ee(f)},onPointerMove(){k.current=!0}}),[te,ee,P,g,$,K,D,a,J]),re=r.useMemo(()=>{function f(I){K.setOpen(!0,Me(zt,I.nativeEvent,I.currentTarget))}function y(I){p==="auto"&&nn(I.nativeEvent)&&(z.current=!a)}function X(I){z.current=p,p==="auto"&&_n(I.nativeEvent)&&(z.current=!0)}return{onKeyDown(I){const _=K.select("open");k.current=!1;const ve=I.key.startsWith("Arrow"),De=ur(I.key,ue(),v),Ee=ft(I.key,g),Ae=(m?De:Ee)||I.key==="Enter"||I.key.trim()==="";if(a&&_)return ee(I);if(!(!_&&!b&&ve)){if(Ae){const fe=ft(I.key,ue());Y.current=m&&fe?null:I.key}if(m){De&&(Le(I),_?(T.current=de(),s(I)):f(I));return}Ee&&(se.current!=null&&(T.current=se.current),Le(I),!_&&b?f(I):ee(I),_&&s(I))}},onFocus(I){K.select("open")&&!a&&(T.current=-1,s(I))},onPointerDown:X,onPointerEnter:X,onMouseDown:y,onClick:y}},[ee,p,de,m,s,K,b,g,ue,v,se,a]),A=r.useMemo(()=>({...te,...re}),[te,re]);return r.useMemo(()=>c?{reference:A,floating:Q,item:xe,trigger:re}:{},[c,A,Q,re,xe])}function dr(e,t){const{listRef:n,elementsRef:o,activeIndex:l,onMatch:c,disabledIndices:i,onTyping:x,enabled:u=!0,resetMs:m=750,selectedIndex:v=null}=t,a="rootStore"in e?e.rootStore:e,p=a.useState("open"),R=ht(),b=r.useRef(""),O=r.useRef(v??l??-1),g=r.useRef(null),S=le(d=>{function L(P){const H=o?.current[P];return!H||In(H)}function j(P){return L(P)?i==null||!Sn(At,P,i):!1}function K(P,H,oe=0){if(P.length===0)return-1;const z=(oe%P.length+P.length)%P.length,T=H.toLowerCase();for(let Y=0;Y<P.length;Y+=1){const k=(z+Y)%P.length;if(!(!P[k]?.toLowerCase().startsWith(T)||!j(k)))return k}return-1}const D=n.current;if(b.current.length>0&&d.key===" "&&(Le(d),x?.(!0)),b.current.length>0&&b.current[0]!==" "&&K(D,b.current)===-1&&d.key!==" "&&x?.(!1),D==null||d.key.length!==1||d.ctrlKey||d.metaKey||d.altKey)return;p&&d.key!==" "&&(Le(d),x?.(!0));const W=b.current==="";W&&(O.current=v??l??-1),D.every((P,H)=>P&&j(H)?P[0]?.toLowerCase()!==P[1]?.toLowerCase():!0)&&b.current===d.key&&(b.current="",O.current=g.current),b.current+=d.key,R.start(m,()=>{b.current="",O.current=g.current,x?.(!1)});const he=((W?v??l??-1:O.current)??0)+1,$=K(D,b.current,he);$!==-1?(c?.($),g.current=$):d.key!==" "&&(b.current="",x?.(!1))}),V=le(d=>{const L=d.relatedTarget,j=a.select("domReferenceElement"),K=a.select("floatingElement");He(j,L)||He(K,L)||(R.clear(),b.current="",O.current=g.current,x?.(!1))});G(()=>{!p&&v!==null||(R.clear(),g.current=null,b.current!==""&&(b.current=""))},[p,v,R]),G(()=>{p&&b.current===""&&(O.current=v??l??-1)},[p,v,l]);const E=r.useMemo(()=>({onKeyDown:S,onBlur:V}),[S,V]);return r.useMemo(()=>u?{reference:E,floating:E}:{},[u,E])}function pr(e){const[t,n]=r.useState({current:e,previous:null});return e!==t.current&&n({current:e,previous:t.current}),t.previous}function gr(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function Wt({controlled:e,default:t,name:n,state:o="value"}){const{current:l}=r.useRef(e!==void 0),[c,i]=r.useState(t),x=l?e:c,u=r.useCallback(m=>{l||i(m)},[]);return[x,u]}const on=r.createContext(null),sn=r.createContext(null);function qe(){const e=r.useContext(on);if(e===null)throw new Error(it(60));return e}function ln(){const e=r.useContext(sn);if(e===null)throw new Error(it(61));return e}let Yt=(function(e){return e.disabled="data-disabled",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const mr={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},nt={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},hr={disabled:!1,...nt},br={valid(e){return e===null?null:e?{[Yt.valid]:""}:{[Yt.invalid]:""}}},yr={invalid:void 0,name:void 0,validityData:{state:mr,errors:[],error:"",value:"",initialValue:null},setValidityData:Re,disabled:void 0,touched:nt.touched,setTouched:Re,dirty:nt.dirty,setDirty:Re,filled:nt.filled,setFilled:Re,focused:nt.focused,setFocused:Re,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:hr,markedDirtyRef:{current:!1},registerFieldControl:Re,validation:{getValidationProps:(e,t=Qt)=>t,inputRef:{current:null},registerInput:Re,commit:async()=>{},change:Re}},xr=r.createContext(yr);function Nt(e=!0){const t=r.useContext(xr);if(t.setValidityData===Re&&!e)throw new Error(it(28));return t}function Rr(e,t,n,o,l=!0,c){const{registerFieldControl:i}=Nt(),x=r.useRef(null);x.current||(x.current=Symbol()),G(()=>{const u=x.current;return!u||!l?void 0:(i(u,{controlRef:e,getValue:o,id:t,name:c,value:n}),()=>{i(u,void 0)})},[e,l,o,t,c,i,n])}const Sr=r.createContext({controlId:void 0,registerControlId:Re,labelId:void 0,setLabelId:Re,messageIds:[],setMessageIds:Re,getDescriptionProps:e=>e});function cn(){return r.useContext(Sr)}function un(e={}){const{id:t,implicit:n=!1,controlRef:o}=e,{controlId:l,registerControlId:c}=cn(),i=Bn(t),x=n?l:void 0,u=yt(()=>Symbol("labelable-control")),m=r.useRef(!1),v=r.useRef(t!=null),a=le(()=>{!m.current||c===Re||(m.current=!1,c(u.current,void 0))});return G(()=>{if(c===Re)return;let p;if(n){const R=o?.current;En(R)&&R.closest("label")!=null?p=t??null:p=x??i}else if(t!=null)v.current=!0,p=t;else if(v.current)p=i;else{a();return}if(p===void 0){a();return}m.current=!0,c(u.current,p)},[t,o,x,c,n,i,u,a]),r.useEffect(()=>a,[a]),l??i}const Ir=(e,t)=>Object.is(e,t);function Ye(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Er(e,t,n){return!e||e.length===0?!1:e.some(o=>o===void 0?!1:Ye(t,o,n))}function ot(e,t,n){return!e||e.length===0?-1:e.findIndex(o=>o===void 0?!1:Ye(o,t,n))}function Tr(e,t,n){return e.filter(o=>!Ye(t,o,n))}function Vt(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function an(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function Mr(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(an(t)){for(const n of t)for(const o of n.items)if(o&&o.value==null&&o.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function fn(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 Vt(e)}function je(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?Vt(e.value):Vt(e)}function dn(e,t,n){function o(){return fn(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 t[e]??o();if(Array.isArray(t)){const l=t,c=an(l)?l.flatMap(i=>i.items):l;if(e==null||typeof e!="object"){const i=c.find(x=>x.value===e);return i&&i.label!=null?i.label:o()}if("value"in e){const i=c.find(x=>x&&x.value===e.value);if(i&&i.label!=null)return i.label}}return o()}function Cr(e,t,n){return e.reduce((o,l,c)=>(c>0&&o.push(", "),o.push(be.jsx(r.Fragment,{children:dn(l,t,n)},c)),o),[])}const C={id:q(e=>e.id),labelId:q(e=>e.labelId),modal:q(e=>e.modal),multiple:q(e=>e.multiple),items:q(e=>e.items),itemToStringLabel:q(e=>e.itemToStringLabel),itemToStringValue:q(e=>e.itemToStringValue),isItemEqualToValue:q(e=>e.isItemEqualToValue),value:q(e=>e.value),hasSelectedValue:q(e=>{const{value:t,multiple:n,itemToStringValue:o}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:je(t,o)!==""}),hasNullItemLabel:q((e,t)=>t?Mr(e.items):!1),open:q(e=>e.open),mounted:q(e=>e.mounted),forceMount:q(e=>e.forceMount),transitionStatus:q(e=>e.transitionStatus),openMethod:q(e=>e.openMethod),activeIndex:q(e=>e.activeIndex),selectedIndex:q(e=>e.selectedIndex),isActive:q((e,t)=>e.activeIndex===t),isSelected:q((e,t)=>{const n=e.isItemEqualToValue,o=e.value;return e.multiple?Array.isArray(o)&&o.some(l=>Ye(t,l,n)):Ye(t,o,n)}),isSelectedByFocus:q((e,t)=>e.selectedIndex===t),popupProps:q(e=>e.popupProps),triggerProps:q(e=>e.triggerProps),triggerElement:q(e=>e.triggerElement),positionerElement:q(e=>e.positionerElement),listElement:q(e=>e.listElement),popupSide:q(e=>e.popupSide),scrollUpArrowVisible:q(e=>e.scrollUpArrowVisible),scrollDownArrowVisible:q(e=>e.scrollDownArrowVisible),hasScrollArrows:q(e=>e.hasScrollArrows)},vr=r.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:Re,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function wr(){return r.useContext(vr)}function Pr(e,t,n=(o,l)=>o===l){return e.length===t.length&&e.every((o,l)=>n(o,t[l]))}const Fe=1;function pn(e,t){return Math.max(0,e-t)}function Ar(e,t){if(t<=0)return 0;const n=tt(e,0,t),o=n,l=t-n,c=o<=Fe,i=l<=Fe;return c&&i?o<=l?0:t:c?0:i?t:n}function to(e){const{id:t,value:n,defaultValue:o=null,onValueChange:l,open:c,defaultOpen:i=!1,onOpenChange:x,name:u,form:m,autoComplete:v,disabled:a=!1,readOnly:p=!1,required:R=!1,modal:b=!0,actionsRef:O,inputRef:g,onOpenChangeComplete:S,items:V,multiple:E=!1,itemToStringLabel:d,itemToStringValue:L,isItemEqualToValue:j=Ir,highlightItemOnHover:K=!0,children:D}=e,{clearErrors:W}=wr(),{setDirty:J,setTouched:me,setFocused:he,validityData:$,setFilled:P,name:H,disabled:oe,validation:z,validationMode:T}=Nt(),Y=un({id:t}),k=oe||a,s=H??u,[M,ae]=Wt({controlled:n,default:E?o??At:o,name:"Select",state:"value"}),[U,pe]=Wt({controlled:c,default:i,name:"Select",state:"open"}),ge=r.useRef([]),h=r.useRef([]),F=r.useRef(null),se=r.useRef(null),Se=r.useRef(0),B=r.useRef(null),ne=r.useRef([]),Z=r.useRef(!1),ye=r.useRef(null),ce=r.useRef(null),ue=r.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),de=r.useRef(!1),{mounted:ee,setMounted:xe,transitionStatus:te}=rn(U),{openMethod:Q,triggerProps:re}=Xn(U),A=yt(()=>new vn({id:Y,labelId:void 0,modal:b,multiple:E,itemToStringLabel:d,itemToStringValue:L,isItemEqualToValue:j,value:M,open:U,mounted:ee,transitionStatus:te,items:V,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,f=w(A,C.activeIndex),y=w(A,C.selectedIndex),X=w(A,C.triggerElement),I=w(A,C.positionerElement),_=pr(Q),ve=Q??_??null,De=r.useMemo(()=>E?"":je(M,L),[E,M,L]),Ee=r.useMemo(()=>E&&Array.isArray(M)?M.map(N=>je(N,L)):je(M,L),[E,M,L]),Ae=We(A.state.triggerElement),fe=le(()=>Ee);Rr(Ae,Y,M,fe,!k,u);const Oe=r.useRef(M),Ve=E?Array.isArray(M)&&M.length>0:M!=null&&je(M,L)!=="";G(()=>{M!==Oe.current&&A.set("forceMount",!0)},[A,M]),G(()=>{P(Ve)},[Ve,P]),G(function(){const ie=ne.current;let Te;if(E){const Ie=Array.isArray(M)?M:[];if(Ie.length===0)Te=null;else{const Ue=Ie[Ie.length-1],ze=ot(ie,Ue,j);Te=ze===-1?null:ze}}else{const Ie=ot(ie,M,j);Te=Ie===-1?null:Ie}Te===null&&(ce.current=null),!U&&A.set("selectedIndex",Te)},[Ve,E,U,M,ne,j,A,ce]);function we(N){const ie=$.initialValue;return Array.isArray(N)&&Array.isArray(ie)?!Pr(N,ie,(Te,Ie)=>Ye(Te,Ie,j)):N!==ie}Jn(M,()=>{W(s),J(we(M)),z.change(M)});const Ke=le((N,ie)=>{x?.(N,ie),!ie.isCanceled&&(pe(N),!N&&(ie.reason===Jt||ie.reason===wn)&&(me(!0),he(!1),T==="onBlur"&&z.commit(M)))}),$e=le(()=>{xe(!1),A.update({activeIndex:null,openMethod:null}),S?.(!1)});Ft({enabled:!O,open:U,ref:F,onComplete(){U||$e()}}),r.useImperativeHandle(O,()=>({unmount:$e}),[$e]);const Ne=le((N,ie)=>{l?.(N,ie),!ie.isCanceled&&ae(N)}),Pe=le(()=>{const N=A.state.listElement||F.current;if(!N)return;const ie=pn(N.scrollHeight,N.clientHeight),Te=Ar(N.scrollTop,ie),Ie=Te>0,Ue=Te<ie;A.state.scrollUpArrowVisible!==Ie&&A.set("scrollUpArrowVisible",Ie),A.state.scrollDownArrowVisible!==Ue&&A.set("scrollDownArrowVisible",Ue)}),_e=Zn({open:U,onOpenChange:Ke,elements:{reference:X,floating:I}}),Ge=Qn(_e,{enabled:!p&&!k,event:"mousedown"}),Xe=zn(_e),ke=fr(_e,{enabled:!p&&!k,listRef:ge,activeIndex:f,selectedIndex:y,disabledIndices:At,onNavigate(N){N===null&&!U||A.set("activeIndex",N)},focusItemOnHover:K}),Be=dr(_e,{enabled:!p&&!k&&(U||!E),listRef:h,activeIndex:f,selectedIndex:y,disabledIndices:N=>gr(ge.current[N]),onMatch(N){U?A.set("activeIndex",N):Ne(ne.current[N],Me("none"))},onTyping(N){Z.current=N}}),Qe=r.useMemo(()=>{const N=Ot(Be.reference,ke.reference,Xe.reference,Ge.reference,re);return Y&&(N.id=Y),N},[Ge.reference,Be.reference,ke.reference,Xe.reference,re,Y]),et=r.useMemo(()=>Ot(jn,Be.floating,ke.floating,Xe.floating),[Be.floating,ke.floating,Xe.floating]),lt=ke.item??Qt;Wn(()=>{A.update({popupProps:et,triggerProps:Qe})}),G(()=>{A.update({id:Y,modal:b,multiple:E,value:M,open:U,mounted:ee,transitionStatus:te,popupProps:et,triggerProps:Qe,items:V,itemToStringLabel:d,itemToStringValue:L,isItemEqualToValue:j,openMethod:ve})},[A,Y,b,E,M,U,ee,te,et,Qe,V,d,L,j,ve]);const Ce=r.useMemo(()=>({store:A,name:s,required:R,disabled:k,readOnly:p,multiple:E,highlightItemOnHover:K,setValue:Ne,setOpen:Ke,listRef:ge,popupRef:F,scrollHandlerRef:se,handleScrollArrowVisibility:Pe,scrollArrowsMountedCountRef:Se,itemProps:lt,valueRef:B,valuesRef:ne,labelsRef:h,typingRef:Z,selectionRef:ue,firstItemTextRef:ye,selectedItemTextRef:ce,validation:z,onOpenChangeComplete:S,alignItemWithTriggerActiveRef:de,initialValueRef:Oe}),[A,s,R,k,p,E,K,Ne,Ke,lt,z,S,Pe]),Je=Tn(g,z.inputRef),ct=E&&Array.isArray(M)&&M.length>0,ut=E?void 0:s,Et=r.useMemo(()=>!E||!Array.isArray(M)||!s?null:M.map(N=>{const ie=je(N,L);return be.jsx("input",{type:"hidden",form:m,name:s,value:ie,disabled:k},ie)}),[E,M,m,s,L,k]);return be.jsx(on.Provider,{value:Ce,children:be.jsxs(sn.Provider,{value:_e,children:[D,be.jsx("input",{...z.getValidationProps(k,{onFocus(){A.state.triggerElement?.focus({focusVisible:!0})},onChange(N){if(N.nativeEvent.defaultPrevented||k||p)return;const ie=N.currentTarget.value,Te=Me(Dt,N.nativeEvent);function Ie(){if(E)return;const Ue=ie.toLowerCase();let ze=ne.current.findIndex(Tt=>je(Tt,L).toLowerCase()===Ue||fn(Tt,d).toLowerCase()===Ue);ze===-1&&(ze=ne.current.findIndex((Tt,yn)=>{const Ht=h.current[yn];return Ht!=null&&Ht.toLowerCase()===Ue}));const Ut=ze===-1?void 0:ne.current[ze];Ut!=null&&Ne(Ut,Te)}A.set("forceMount",!0),queueMicrotask(Ie)}}),id:Y&&ut==null?`${Y}-hidden-input`:void 0,form:m,name:ut,autoComplete:v,value:De,disabled:k,required:R&&!ct,readOnly:p,ref:Je,style:s?Mn:Cn,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Et]})})}function Or(e,t){return e??t}function Vr(e){const t=e.getBoundingClientRect(),n=bt(e);if(Pn)return t;const o=n.getComputedStyle(e,"::before"),l=n.getComputedStyle(e,"::after");if(!(o.content!=="none"||l.content!=="none"))return t;const i=parseFloat(o.width)||0,x=parseFloat(o.height)||0,u=parseFloat(l.width)||0,m=parseFloat(l.height)||0,v=Math.max(t.width,i,u),a=Math.max(t.height,x,m),p=v-t.width,R=a-t.height;return{left:t.left-p/2,right:t.right+p/2,top:t.top-R/2,bottom:t.bottom+R/2}}const dt=2,Lr=400,Fr={...Yn,...br,popupSide:e=>e?{"data-popup-side":e}:null,value:()=>null},no=r.forwardRef(function(t,n){const{render:o,className:l,id:c,disabled:i=!1,nativeButton:x=!0,style:u,...m}=t,{setTouched:v,setFocused:a,validationMode:p,state:R,disabled:b}=Nt(),{labelId:O}=cn(),{store:g,setOpen:S,selectionRef:V,validation:E,readOnly:d,required:L,alignItemWithTriggerActiveRef:j,disabled:K}=qe(),D=b||K||i,W=w(g,C.open),J=w(g,C.mounted),me=w(g,C.value),he=w(g,C.triggerProps),$=w(g,C.positionerElement),P=w(g,C.listElement),H=w(g,C.popupSide),oe=w(g,C.id),z=w(g,C.labelId),T=w(g,C.hasSelectedValue),Y=J&&$?H:null,k=c??oe,s=Or(O,z);un({id:k});const M=We($),ae=r.useRef(null),{getButtonProps:U,buttonRef:pe}=en({disabled:D,native:x}),ge=le(Z=>{g.set("triggerElement",Z)}),h=ht(),F=ht(),se=ht();r.useEffect(()=>{if(W)return se.start(Lr,()=>{V.current.allowUnselectedMouseUp=!0,V.current.allowSelectedMouseUp=!0}),()=>{se.clear()};V.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},F.clear()},[W,V,F,se]);const Se=Ot(he,{id:k,role:"combobox","aria-expanded":W?"true":"false","aria-haspopup":"listbox","aria-controls":W?P?.id??Xt($)?.id:void 0,"aria-labelledby":s,"aria-readonly":d||void 0,"aria-required":L||void 0,tabIndex:D?-1:0,onFocus(Z){a(!0),W&&j.current&&S(!1,Me(Dt,Z.nativeEvent)),h.start(0,()=>{g.set("forceMount",!0)})},onBlur(Z){He($,Z.relatedTarget)||(v(!0),a(!1),p==="onBlur"&&E.commit(me))},onMouseDown(Z){if(W)return;const ye=st(Z.currentTarget);function ce(ue){if(!ae.current)return;const de=ue.target;if(He(ae.current,de)||He(M.current,de))return;const ee=Vr(ae.current);ue.clientX>=ee.left-dt&&ue.clientX<=ee.right+dt&&ue.clientY>=ee.top-dt&&ue.clientY<=ee.bottom+dt||S(!1,Me(An,ue))}F.start(0,()=>{ye.addEventListener("mouseup",ce,{once:!0})})}},m,U),B=E.getValidationProps(D,Se);B.role="combobox";const ne={...R,open:W,disabled:D,value:me,readOnly:d,popupSide:Y,placeholder:!T};return Ze("button",t,{ref:[n,ae,pe,ge],state:ne,stateAttributesMapping:Fr,props:B})}),Dr={value:()=>null},ro=r.forwardRef(function(t,n){const{className:o,render:l,children:c,placeholder:i,style:x,...u}=t,{store:m,valueRef:v}=qe(),a=w(m,C.value),p=w(m,C.items),R=w(m,C.itemToStringLabel),b=w(m,C.hasSelectedValue),O=!b&&i!=null&&c==null,g=w(m,C.hasNullItemLabel,O),S={value:a,placeholder:!b};let V=null;return typeof c=="function"?V=c(a):c!=null?V=c:!b&&i!=null&&!g?V=i:Array.isArray(a)?V=Cr(a,p,R):V=dn(a,p,R),Ze("span",t,{state:S,ref:[n,v],props:[{children:V},u],stateAttributesMapping:Dr})}),Nr=r.createContext(void 0),oo=r.forwardRef(function(t,n){const{store:o}=qe(),l=w(o,C.mounted),c=w(o,C.forceMount);return l||c?be.jsx(Nr.Provider,{value:!0,children:be.jsx(On,{ref:n,...t})}):null}),gn=r.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function kr(){return r.useContext(gn)}function Ur(e){const{children:t,elementsRef:n,labelsRef:o,onMapChange:l}=e,c=le(l),i=r.useRef(0),x=yt(_r).current,u=yt(Hr).current,[m,v]=r.useState(0),a=r.useRef(m),p=le((S,V)=>{u.set(S,V??null),a.current+=1,v(a.current)}),R=le(S=>{u.delete(S),a.current+=1,v(a.current)}),b=r.useMemo(()=>{const S=new Map;return Array.from(u.keys()).filter(E=>E.isConnected).sort(Br).forEach((E,d)=>{const L=u.get(E)??{};S.set(E,{...L,index:d})}),S},[u,m]);G(()=>{if(typeof MutationObserver!="function"||b.size===0)return;const S=new MutationObserver(V=>{const E=new Set,d=L=>E.has(L)?E.delete(L):E.add(L);V.forEach(L=>{L.removedNodes.forEach(d),L.addedNodes.forEach(d)}),E.size===0&&(a.current+=1,v(a.current))});return b.forEach((V,E)=>{E.parentElement&&S.observe(E.parentElement,{childList:!0})}),()=>{S.disconnect()}},[b]),G(()=>{a.current===m&&(n.current.length!==b.size&&(n.current.length=b.size),o&&o.current.length!==b.size&&(o.current.length=b.size),i.current=b.size),c(b)},[c,b,n,o,m]),G(()=>()=>{n.current=[]},[n]),G(()=>()=>{o&&(o.current=[])},[o]);const O=le(S=>(x.add(S),()=>{x.delete(S)}));G(()=>{x.forEach(S=>S(b))},[x,b]);const g=r.useMemo(()=>({register:p,unregister:R,subscribeMapChange:O,elementsRef:n,labelsRef:o,nextIndexRef:i}),[p,R,O,n,o,i]);return be.jsx(gn.Provider,{value:g,children:t})}function Hr(){return new Map}function _r(){return new Set}function Br(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const mn=r.createContext(void 0);function zr(){const e=r.useContext(mn);if(!e)throw new Error(it(59));return e}function xt(e,t){e&&Object.assign(e.style,t)}const jr={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},Wr={position:"fixed"},so=r.forwardRef(function(t,n){const{anchor:o,positionMethod:l="absolute",className:c,render:i,side:x="bottom",align:u="center",sideOffset:m=0,alignOffset:v=0,collisionBoundary:a="clipping-ancestors",collisionPadding:p,arrowPadding:R=5,sticky:b=!1,disableAnchorTracking:O,alignItemWithTrigger:g=!0,collisionAvoidance:S=Vn,style:V,...E}=t,{store:d,listRef:L,labelsRef:j,alignItemWithTriggerActiveRef:K,selectedItemTextRef:D,valuesRef:W,initialValueRef:J,popupRef:me,setValue:he}=qe(),$=ln(),P=w(d,C.open),H=w(d,C.mounted),oe=w(d,C.modal),z=w(d,C.value),T=w(d,C.openMethod),Y=w(d,C.positionerElement),k=w(d,C.triggerElement),s=w(d,C.isItemEqualToValue),M=w(d,C.transitionStatus),ae=r.useRef(null),U=r.useRef(null),[pe,ge]=r.useState(g),h=H&&pe&&T!=="touch";!H&&pe!==g&&ge(g),G(()=>{H||(C.scrollUpArrowVisible(d.state)&&d.set("scrollUpArrowVisible",!1),C.scrollDownArrowVisible(d.state)&&d.set("scrollDownArrowVisible",!1))},[d,H]),r.useImperativeHandle(K,()=>h),er((h||oe)&&P,T==="touch",Y,k);const F=tr({anchor:o,floatingRootContext:$,positionMethod:l,mounted:H,side:x,sideOffset:m,align:u,alignOffset:v,arrowPadding:R,collisionBoundary:a,collisionPadding:p,sticky:b,disableAnchorTracking:O??h,collisionAvoidance:S,keepMounted:!0}),se=h?"none":F.side,Se=h?Wr:F.positionerStyles,B={open:P,side:se,align:F.align,anchorHidden:F.anchorHidden};G(()=>{d.set("popupSide",F.side)},[d,F.side]);const ne=le(de=>{d.set("positionerElement",de)}),Z=nr(t,B,{styles:Se,transitionStatus:M,props:E,refs:[n,ne],hidden:!H,inert:!P}),ye=r.useRef(0),ce=le(de=>{if(de.size===0&&ye.current===0||W.current.length===0)return;const ee=ye.current;if(ye.current=de.size,de.size===ee)return;const xe=Me(Dt);if(ee!==0&&!d.state.multiple&&z!==null&&ot(W.current,z,s)===-1){const Q=J.current,A=Q!=null&&ot(W.current,Q,s)!==-1?Q:null;he(A,xe),A===null&&(d.set("selectedIndex",null),D.current=null)}if(ee!==0&&d.state.multiple&&Array.isArray(z)){const te=re=>ot(W.current,re,s)!==-1,Q=z.filter(re=>te(re));(Q.length!==z.length||Q.some(re=>!Er(z,re,s)))&&(he(Q,xe),Q.length===0&&(d.set("selectedIndex",null),D.current=null))}if(P&&h){d.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const te={height:""};xt(Y,te),xt(me.current,te)}}),ue=r.useMemo(()=>({...F,side:se,alignItemWithTriggerActive:h,setControlledAlignItemWithTrigger:ge,scrollUpArrowRef:ae,scrollDownArrowRef:U}),[F,se,h,ge]);return be.jsx(Ur,{elementsRef:L,labelsRef:j,onMapChange:ce,children:be.jsxs(mn.Provider,{value:ue,children:[H&&oe&&be.jsx(qn,{inert:Ln(!P),cutout:k}),Z]})})}),pt="base-ui-disable-scrollbar",qt={className:pt,getElement(e){return be.jsx("style",{nonce:e,href:pt,precedence:"base-ui:low",children:`.${pt}{scrollbar-width:none}.${pt}::-webkit-scrollbar{display:none}`})}},Yr=r.createContext(void 0),qr={disableStyleElements:!1};function Kr(){return r.useContext(Yr)??qr}const $r={...$n,...tn},io=r.forwardRef(function(t,n){const{render:o,className:l,style:c,finalFocus:i,...x}=t,{store:u,popupRef:m,onOpenChangeComplete:v,setOpen:a,valueRef:p,firstItemTextRef:R,selectedItemTextRef:b,multiple:O,handleScrollArrowVisibility:g,scrollHandlerRef:S,listRef:V,highlightItemOnHover:E}=qe(),{side:d,align:L,alignItemWithTriggerActive:j,isPositioned:K,setControlledAlignItemWithTrigger:D}=zr(),W=rr()!=null,J=ln(),me=or(),{nonce:he,disableStyleElements:$}=Kr(),P=w(u,C.id),H=w(u,C.open),oe=w(u,C.openMethod),z=w(u,C.mounted),T=w(u,C.popupProps),Y=w(u,C.transitionStatus),k=w(u,C.triggerElement),s=w(u,C.positionerElement),M=w(u,C.listElement),ae=r.useRef(!1),U=r.useRef(!1),pe=r.useRef({}),ge=Pt(),h=le(B=>{if(!s||!m.current||!U.current)return;if(ae.current||!j){g();return}const ne=s.style.top==="0px",Z=s.style.bottom==="0px";if(!ne&&!Z){g();return}const ye=$t(s),ce=rt(s.getBoundingClientRect().height,"y",ye),ue=st(s),de=bt(s),ee=de.getComputedStyle(s),xe=parseFloat(ee.marginTop),te=parseFloat(ee.marginBottom),Q=Kt(de.getComputedStyle(m.current)),re=Math.min(ue.documentElement.clientHeight-xe-te,Q),A=B.scrollTop,f=gt(B);let y=0,X=null,I=!1,_=!1;const ve=fe=>{s.style.height=`${fe}px`},De=(fe,Oe)=>{const Ve=tt(fe,0,re-ce);Ve>0&&ve(ce+Ve),B.scrollTop=Oe,re-(ce+Ve)<=Fe&&(ae.current=!0),g()},Ee=ne?f-A:A,Ae=Math.min(ce+Ee,re);if(y=Ae,Ee<=Fe){De(Ee,ne?f:0);return}if(re-Ae>Fe)ne?_=!0:X=0;else if(I=!0,Z&&A<f){const fe=ce+Ee-re;X=A-(Ee-fe)}if(y=Math.ceil(y),y!==0&&ve(y),_||X!=null){const fe=gt(B),Oe=_?fe:tt(X,0,fe);Math.abs(B.scrollTop-Oe)>Fe&&(B.scrollTop=Oe)}(I||y>=re-Fe)&&(ae.current=!0),g()});r.useImperativeHandle(S,()=>h,[h]),Ft({open:H,ref:m,onComplete(){H&&v?.(!0)}});const F={open:H,transitionStatus:Y,side:d,align:L};G(()=>{!s||!m.current||Object.keys(pe.current).length||(pe.current={top:s.style.top||"0",left:s.style.left||"0",right:s.style.right,height:s.style.height,bottom:s.style.bottom,minHeight:s.style.minHeight,maxHeight:s.style.maxHeight,marginTop:s.style.marginTop,marginBottom:s.style.marginBottom})},[m,s]),G(()=>{H||j||(U.current=!1,ae.current=!1,xt(s,pe.current))},[H,j,s,m]),G(()=>{const B=m.current;if(!H||!k||!s||!B||j&&!K||u.state.transitionStatus==="ending")return;if(!j){U.current=!0,ge.request(g),B.style.removeProperty("--transform-origin");return}const ne=Gr(B);B.style.removeProperty("--transform-origin");try{let Z=b.current;Z?.isConnected||(Z=!C.hasSelectedValue(u.state)&&R.current?.isConnected?R.current:null);const ye=p.current,ce=bt(s),ue=ce.getComputedStyle(s),de=ce.getComputedStyle(B),ee=st(k),xe=$t(k),te=mt(k.getBoundingClientRect(),xe),Q=mt(s.getBoundingClientRect(),xe),re=te.height,A=M||B,f=A.scrollHeight,y=parseFloat(de.borderBottomWidth),X=parseFloat(ue.marginTop)||10,I=parseFloat(ue.marginBottom)||10,_=parseFloat(ue.minHeight)||100,ve=Kt(de),De=5,Ee=5,Ae=20,fe=ee.documentElement.clientHeight-X-I,Oe=ee.documentElement.clientWidth,Ve=fe-te.bottom+re;let we,Ke=me==="rtl"?te.right-Q.width:te.left,$e=0;if(Z&&ye){const Ce=mt(ye.getBoundingClientRect(),xe);we=mt(Z.getBoundingClientRect(),xe),Ke=Q.left+(me==="rtl"?Ce.right-we.right:Ce.left-we.left);const Je=Ce.top-te.top+Ce.height/2;$e=we.top-Q.top+we.height/2-Je}const Ne=Ve+$e+I+y;let Pe=Math.min(fe,Ne);const _e=fe-X-I,Ge=Ne-Pe,Xe=Oe-Ee;s.style.left=`${tt(Ke,De,Xe-Q.width)}px`,s.style.height=`${Pe}px`,s.style.maxHeight="none",s.style.marginTop=`${X}px`,s.style.marginBottom=`${I}px`,B.style.height="100%";const ke=gt(A),Be=Ge>=ke-Fe;Be&&(Pe=Math.min(fe,Q.height)-(Ge-ke));const Qe=te.top<Ae||te.bottom>fe-Ae||Math.ceil(Pe)+Fe<Math.min(f,_),et=(ce.visualViewport?.scale??1)!==1&&Fn;if(Qe||et){U.current=!0,xt(s,pe.current),D(!1);return}const lt=Math.max(_,Pe);if(Be){const Ce=Math.max(0,fe-Ne);s.style.top=Q.height>=_e?"0":`${Ce}px`,s.style.height=`${Pe}px`,A.scrollTop=gt(A)}else s.style.bottom="0",A.scrollTop=Ge;if(we){const Ce=Q.top,Je=Q.height,ct=we.top+we.height/2,ut=Je>0?(ct-Ce)/Je*100:50,Et=tt(ut,0,100);B.style.setProperty("--transform-origin",`50% ${Et}%`)}(lt===fe||Pe>=ve)&&(ae.current=!0),g(),E&&u.state.selectedIndex===null&&u.state.activeIndex===null&&V.current[0]!=null&&u.set("activeIndex",0),U.current=!0}finally{ne()}},[u,H,s,k,p,R,b,m,g,j,D,ge,M,V,E,me,K]),r.useEffect(()=>{if(!j||!s||!H)return;const B=bt(s);function ne(Z){a(!1,Me(Nn,Z))}return Dn(B,"resize",ne)},[a,j,s,H]);const se={...M?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":O||void 0,id:`${P}-list`},onKeyDown(B){W&&Gn.has(B.key)&&B.stopPropagation()},onScroll(B){M||h(B.currentTarget)},...j&&{style:M?{height:"100%"}:jr}},Se=Ze("div",t,{ref:[n,m],state:F,stateAttributesMapping:$r,props:[T,se,lr(Y),{className:!M&&j?qt.className:void 0},x]});return be.jsxs(r.Fragment,{children:[!$&&qt.getElement(he),be.jsx(Kn,{context:J,modal:!1,disabled:!z,openInteractionType:oe,returnFocus:i,restoreFocus:!0,children:Se})]})});function Kt(e){const t=e.maxHeight||"";return t.endsWith("px")&&parseFloat(t)||1/0}function gt(e){return pn(e.scrollHeight,e.clientHeight)}function $t(e){return sr.getScale(e)}function rt(e,t,n){return e/n[t]}function mt(e,t){return ir({x:rt(e.x,"x",t),y:rt(e.y,"y",t),width:rt(e.width,"x",t),height:rt(e.height,"y",t)})}const Gt=[["transform","none"],["scale","1"],["translate","0 0"]];function Gr(e){const{style:t}=e,n={};for(const[o,l]of Gt)n[o]=t.getPropertyValue(o),t.setProperty(o,l,"important");return()=>{for(const[o]of Gt){const l=n[o];l?t.setProperty(o,l):t.removeProperty(o)}}}let hn=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function Xr(e={}){const{label:t,metadata:n,textRef:o,indexGuessBehavior:l,index:c}=e,{register:i,unregister:x,subscribeMapChange:u,elementsRef:m,labelsRef:v,nextIndexRef:a}=kr(),p=r.useRef(-1),[R,b]=r.useState(c??(l===hn.GuessFromOrder?()=>{if(p.current===-1){const S=a.current;a.current+=1,p.current=S}return p.current}:-1)),O=r.useRef(null),g=r.useCallback(S=>{if(O.current=S,R!==-1&&S!==null&&(m.current[R]=S,v)){const V=t!==void 0;v.current[R]=V?t:o?.current?.textContent??S.textContent}},[R,m,v,t,o]);return G(()=>{if(c!=null)return;const S=O.current;if(S)return i(S,n),()=>{x(S)}},[c,i,x,n]),G(()=>{if(c==null)return u(S=>{const V=O.current?S.get(O.current)?.index:null;V!=null&&b(V)})},[c,u,b]),{ref:g,index:R}}const bn=r.createContext(void 0);function kt(){const e=r.useContext(bn);if(!e)throw new Error(it(57));return e}const lo=r.memo(r.forwardRef(function(t,n){const{render:o,className:l,style:c,value:i=null,label:x,disabled:u=!1,nativeButton:m=!1,...v}=t,a=r.useRef(null),p=Xr({label:x,textRef:a,indexGuessBehavior:hn.GuessFromOrder}),{store:R,itemProps:b,setOpen:O,setValue:g,selectionRef:S,typingRef:V,valuesRef:E,multiple:d,selectedItemTextRef:L,disabled:j,readOnly:K}=qe(),D=w(R,C.isActive,p.index),W=w(R,C.open),J=w(R,C.isSelected,i),me=w(R,C.isSelectedByFocus,p.index),he=w(R,C.isItemEqualToValue),$=p.index,P=$!==-1,H=r.useRef(null);G(()=>{if(!P)return;const h=E.current;return h[$]=i,()=>{delete h[$]}},[P,$,i,E]),G(()=>{if(!P)return;const h=R.state.value;let F=h;d&&Array.isArray(h)&&(F=h.length>0?h[h.length-1]:void 0),F!==void 0&&Ye(i,F,he)&&(R.set("selectedIndex",$),a.current&&(L.current=a.current))},[P,$,d,he,R,i,L]);const oe=r.useRef(null),z=r.useRef("mouse"),T=r.useRef(!1),{getButtonProps:Y,buttonRef:k}=en({disabled:u,focusableWhenDisabled:!0,native:m,composite:!0}),s={disabled:u,selected:J,highlighted:D};function M(h){if(j||K)return;const F=R.state.value;if(d){const se=Array.isArray(F)?F:[],Se=J?Tr(se,i,he):[...se,i];g(Se,Me(vt,h))}else g(i,Me(vt,h)),O(!1,Me(vt,h))}function ae(){S.current.dragY=0}const U={role:"option","aria-selected":J,tabIndex:W&&D?0:-1,onKeyDown(h){oe.current=h.key,R.set("activeIndex",$),h.key===" "&&V.current&&h.preventDefault()},onClick(h){const F=h.type==="click"&&z.current!=="touch",se=h.nativeEvent.pointerType,Se=F&&nn(h.nativeEvent)&&(se!==void 0||D),B=F&&!Se&&!T.current;T.current=!1,!(h.type==="keydown"&&oe.current===null)&&(u||h.type==="keydown"&&oe.current===" "&&V.current||B||(oe.current=null,M(h.nativeEvent)))},onPointerEnter(h){z.current=h.pointerType},onPointerMove(h){if(h.pointerType==="mouse"&&h.buttons===1){const F=S.current;F.dragY+=h.movementY,F.dragY**2>=64&&(F.allowUnselectedMouseUp=!0)}},onPointerDown(h){z.current=h.pointerType,T.current=!0,ae()},onMouseUp(){if(ae(),u||z.current==="touch"||T.current)return;const h=!S.current.allowSelectedMouseUp&&J,F=!S.current.allowUnselectedMouseUp&&!J;h||F||(T.current=!0,H.current?.click(),T.current=!1)}},pe=Ze("div",t,{ref:[k,n,p.ref,H],state:s,props:[b,U,v,Y]}),ge=r.useMemo(()=>({selected:J,index:$,textRef:a,selectedByFocus:me,hasRegistered:P}),[J,$,a,me,P]);return be.jsx(bn.Provider,{value:ge,children:pe})})),co=r.forwardRef(function(t,n){const o=t.keepMounted??!1,{selected:l}=kt();return o||l?be.jsx(Jr,{...t,ref:n}):null}),Jr=r.memo(r.forwardRef((e,t)=>{const{render:n,className:o,style:l,keepMounted:c,...i}=e,{selected:x}=kt(),u=r.useRef(null),{transitionStatus:m,setMounted:v}=rn(x),p=Ze("span",e,{ref:[t,u],state:{selected:x,transitionStatus:m},props:[{"aria-hidden":!0,children:"✔️"},i],stateAttributesMapping:tn});return Ft({open:x,ref:u,onComplete(){x||v(!1)}}),p})),uo=r.memo(r.forwardRef(function(t,n){const{index:o,textRef:l,selectedByFocus:c,hasRegistered:i}=kt(),{firstItemTextRef:x,selectedItemTextRef:u}=qe(),{render:m,className:v,style:a,...p}=t,R=r.useCallback(O=>{O&&(i&&o===0&&(x.current=O),i&&c&&(u.current=O))},[x,u,o,c,i]);return Ze("div",t,{ref:[R,n,l],props:p})}));export{jr as L,to as S,zr as a,qt as b,no as c,ro as d,oo as e,so as f,io as g,lo as h,co as i,uo as j,br as k,wr as l,Nt as m,cn as n,Wt as o,Rr as p,C as s,qe as u};
@@ -1 +1 @@
1
- import{r as d,c as n,j as t,R as h}from"./__vite-browser-external-L2HadaWR.js";import{P as f}from"./ProviderIcon-CBmpx1uF.js";import{E as b}from"./external-link-CSwc4MMQ.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-CU0HL6hY.js";import{P as f}from"./ProviderIcon-CxpFegpD.js";import{E as b}from"./external-link-BDjUPxFn.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 K,r as o,j as e,e as E,c as a,a4 as W,J as H,R as X,X as Y,d as ee,l as $,a6 as te,a7 as R}from"./__vite-browser-external-L2HadaWR.js";import{S as U,I as ae}from"./SegmentedControl-DFEBI9gn.js";import{C as re}from"./ToolbarRootContext-Def90ZdR.js";import{S as z}from"./search-CQo3iV6X.js";import{C as se}from"./check-DjA9wjvH.js";import{P as oe,a as ie,b as ne,c as le,d as ce}from"./PopoverPopup-BhXFfaac.js";import{P as de}from"./ProviderIcon-CBmpx1uF.js";import{H as ue}from"./HoverTooltip-Syqp_rdT.js";import{L as xe}from"./LocalOnlyNotice-DVqqppGu.js";import{u as me}from"./useCurrency-Dr4F-MZe.js";import{i as he}from"./host-mode-Bc_iTzHk.js";import{L as fe}from"./loader-circle-DMfnuZaq.js";import{T as pe}from"./terminal-DlcACqJp.js";import"./useScrollLock-7UUKbtyh.js";import"./store-Bl3-sCXx.js";import"./arrow-up-right-BYW8TxaE.js";import"./download-AY9DU1FN.js";const ge=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],ye=K("calendar",ge);const be=[["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"}]],ke=K("folder",be),ve="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 je({options:r,value:t,onChange:s,allValue:d="all",allLabel:h,searchPlaceholder:k,emptyLabel:S,ariaLabel:u,disabled:x=!1,className:T=""}){const[p,I]=o.useState(!1),[g,w]=o.useState(""),[c,m]=o.useState(-1),F=o.useRef(null),C=`${o.useId()}-listbox`,M=t===d?h:r.find(n=>n.value===t)?.label??t,N=g.trim().toLowerCase(),v=o.useMemo(()=>N?r.filter(n=>n.label.toLowerCase().includes(N)):r,[r,N]),y=o.useMemo(()=>[{value:d,label:h},...v],[d,h,v]),O=c>=0&&c<y.length?y[c]:null,P=n=>{s(n),I(!1),w(""),m(-1)};o.useEffect(()=>{p&&F.current?.querySelector('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[p,c]);const L=n=>{if(n.key==="ArrowDown"||n.key==="ArrowUp"){n.preventDefault();const f=n.key==="ArrowDown";m(_=>{const D=y.length;return D?f?_>=D-1?0:_+1:_<=0?D-1:_-1:-1});return}if(n.key==="Enter"){const f=O||(N&&v.length?v[0]:null);if(!f)return;n.preventDefault(),P(f.value)}};return e.jsxs(oe,{open:p,onOpenChange:n=>{I(n),m(-1),n||w("")},children:[e.jsxs(ie,{disabled:x,"aria-label":u,className:E("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!==d?"text-oai-black dark:text-white":"text-oai-gray-700 dark:text-oai-gray-200",T),children:[e.jsx(ke,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:M}),e.jsx(re,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0})]}),e.jsx(ne,{children:e.jsx(le,{sideOffset:4,side:"bottom",align:"start",className:"z-[60]",children:e.jsxs(ce,{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(z,{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":O?`${C}-${c}`:void 0,value:g,onChange:n=>{w(n.target.value),m(-1)},onKeyDown:L,placeholder:k,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:F,id:C,role:"listbox","aria-label":u,className:"max-h-64 overflow-y-auto",children:[y.map((n,f)=>e.jsxs("button",{id:`${C}-${f}`,type:"button",role:"option","aria-selected":t===n.value,"data-active":f===c?"true":void 0,onMouseEnter:()=>m(f),onClick:()=>P(n.value),className:E(ve,t===n.value&&"bg-oai-gray-100 dark:bg-oai-gray-800",f===c&&"ring-1 ring-inset ring-oai-gray-300 dark:ring-oai-gray-600"),children:[e.jsx("span",{className:"flex-1 truncate",children:n.label}),t===n.value?e.jsx(se,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null]},n.value)),v.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-oai-gray-400 dark:text-oai-gray-500",children:S}):null]})]})})})]})}const we="tokentracker-sessions";async function Ne(r={}){const t=new URL(`/functions/${we}`,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"}),d=await s.json().catch(()=>null);if(!s.ok){const h=s.status===404?a("sessions.error.outdated_app"):`Request failed with HTTP ${s.status}`,k=new Error(d?.error||h);throw k.status=s.status,k}return d}const G=he(),_e=[],A=100,Se=[{id:"all",label:()=>a("sessions.filter.source_all")},{id:"claude",label:()=>"Claude Code"},{id:"codex",label:()=>"Codex"},{id:"grok",label:()=>"Grok"}],Z=[{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 Ce(r){const t=Z.find(d=>d.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 Le(r,t){if(!t)return!0;const s=Date.parse(r.ended_at||r.started_at||"");return Number.isFinite(s)?s>=t:!0}function De(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 Ie(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 d=Math.floor(s/60),h=s%60;return a("sessions.duration.hours",{hours:d,minutes:h})}async function Q(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 Me=ee.memo(function({session:t,locale:s}){const{currency:d,rate:h}=me(),k=String(t.source||"").toUpperCase(),S=Ie(t.duration_ms),u=t.resume_command,x=t.project_key||a("sessions.project.unknown"),T=t.title||x,p=!!(t.title&&t.project_key),I=t.project_ref?`${t.project_ref}
1
+ import{m as K,r as o,j as e,e as E,c as a,a4 as W,J as H,R as X,X as Y,d as ee,l as $,a6 as te,a7 as R}from"./__vite-browser-external-CU0HL6hY.js";import{S as U,I as ae}from"./SegmentedControl-BUZrG_65.js";import{C as re}from"./ToolbarRootContext-D3Xvbsmu.js";import{S as z}from"./search-MLfdUv_4.js";import{C as se}from"./check-D1DIUZ3y.js";import{P as oe,a as ie,b as ne,c as le,d as ce}from"./PopoverPopup-DREcMHrJ.js";import{P as de}from"./ProviderIcon-CxpFegpD.js";import{H as ue}from"./HoverTooltip-tOIlqXjb.js";import{L as xe}from"./LocalOnlyNotice-DJWlZgug.js";import{u as me}from"./useCurrency-DKrZtU2Z.js";import{i as he}from"./host-mode-Bc_iTzHk.js";import{L as fe}from"./loader-circle-BvEjzy5k.js";import{T as pe}from"./terminal-DQkiIx3c.js";import"./useScrollLock-D2roJGoE.js";import"./store-PiuqLY56.js";import"./arrow-up-right-C6W_K-fZ.js";import"./download-CBYnlCsF.js";const ge=[["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"}]],ye=K("calendar",ge);const be=[["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"}]],ke=K("folder",be),ve="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 je({options:r,value:t,onChange:s,allValue:d="all",allLabel:h,searchPlaceholder:k,emptyLabel:S,ariaLabel:u,disabled:x=!1,className:T=""}){const[p,I]=o.useState(!1),[g,w]=o.useState(""),[c,m]=o.useState(-1),F=o.useRef(null),C=`${o.useId()}-listbox`,M=t===d?h:r.find(n=>n.value===t)?.label??t,N=g.trim().toLowerCase(),v=o.useMemo(()=>N?r.filter(n=>n.label.toLowerCase().includes(N)):r,[r,N]),y=o.useMemo(()=>[{value:d,label:h},...v],[d,h,v]),O=c>=0&&c<y.length?y[c]:null,P=n=>{s(n),I(!1),w(""),m(-1)};o.useEffect(()=>{p&&F.current?.querySelector('[data-active="true"]')?.scrollIntoView?.({block:"nearest"})},[p,c]);const L=n=>{if(n.key==="ArrowDown"||n.key==="ArrowUp"){n.preventDefault();const f=n.key==="ArrowDown";m(_=>{const D=y.length;return D?f?_>=D-1?0:_+1:_<=0?D-1:_-1:-1});return}if(n.key==="Enter"){const f=O||(N&&v.length?v[0]:null);if(!f)return;n.preventDefault(),P(f.value)}};return e.jsxs(oe,{open:p,onOpenChange:n=>{I(n),m(-1),n||w("")},children:[e.jsxs(ie,{disabled:x,"aria-label":u,className:E("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!==d?"text-oai-black dark:text-white":"text-oai-gray-700 dark:text-oai-gray-200",T),children:[e.jsx(ke,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:M}),e.jsx(re,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0})]}),e.jsx(ne,{children:e.jsx(le,{sideOffset:4,side:"bottom",align:"start",className:"z-[60]",children:e.jsxs(ce,{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(z,{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":O?`${C}-${c}`:void 0,value:g,onChange:n=>{w(n.target.value),m(-1)},onKeyDown:L,placeholder:k,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:F,id:C,role:"listbox","aria-label":u,className:"max-h-64 overflow-y-auto",children:[y.map((n,f)=>e.jsxs("button",{id:`${C}-${f}`,type:"button",role:"option","aria-selected":t===n.value,"data-active":f===c?"true":void 0,onMouseEnter:()=>m(f),onClick:()=>P(n.value),className:E(ve,t===n.value&&"bg-oai-gray-100 dark:bg-oai-gray-800",f===c&&"ring-1 ring-inset ring-oai-gray-300 dark:ring-oai-gray-600"),children:[e.jsx("span",{className:"flex-1 truncate",children:n.label}),t===n.value?e.jsx(se,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null]},n.value)),v.length===0?e.jsx("div",{className:"px-2 py-3 text-center text-xs text-oai-gray-400 dark:text-oai-gray-500",children:S}):null]})]})})})]})}const we="tokentracker-sessions";async function Ne(r={}){const t=new URL(`/functions/${we}`,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"}),d=await s.json().catch(()=>null);if(!s.ok){const h=s.status===404?a("sessions.error.outdated_app"):`Request failed with HTTP ${s.status}`,k=new Error(d?.error||h);throw k.status=s.status,k}return d}const G=he(),_e=[],A=100,Se=[{id:"all",label:()=>a("sessions.filter.source_all")},{id:"claude",label:()=>"Claude Code"},{id:"codex",label:()=>"Codex"},{id:"grok",label:()=>"Grok"}],Z=[{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 Ce(r){const t=Z.find(d=>d.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 Le(r,t){if(!t)return!0;const s=Date.parse(r.ended_at||r.started_at||"");return Number.isFinite(s)?s>=t:!0}function De(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 Ie(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 d=Math.floor(s/60),h=s%60;return a("sessions.duration.hours",{hours:d,minutes:h})}async function Q(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 Me=ee.memo(function({session:t,locale:s}){const{currency:d,rate:h}=me(),k=String(t.source||"").toUpperCase(),S=Ie(t.duration_ms),u=t.resume_command,x=t.project_key||a("sessions.project.unknown"),T=t.title||x,p=!!(t.title&&t.project_key),I=t.project_ref?`${t.project_ref}
2
2
  ${a("sessions.project.copy_hint")}`:void 0,g=async()=>{if(t.project_ref)try{await Q(t.project_ref)?R({title:a("sessions.project.copied")}):R({title:a("sessions.project.copy_failed")})}catch{R({title:a("sessions.project.copy_failed")})}},w=m=>e.jsxs("span",{className:"group relative inline-flex min-w-0 max-w-full",children:[e.jsx(ue,{text:I,placement:"bottom"}),e.jsx("button",{type:"button",onClick:g,"aria-label":a("sessions.project.copy_aria",{project:x}),className:E("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",m),children:x})]}),c=async()=>{if(u)try{await Q(u)?R({title:a("sessions.resume.copied")}):R({title:a("sessions.resume.copy_failed")})}catch{R({title:a("sessions.resume.copy_failed")})}};return e.jsxs("li",{className:"flex flex-col gap-3 py-4 sm:flex-row sm:items-start",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(de,{provider:k,size:20})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[!t.title&&t.project_ref?w("font-medium text-oai-black dark:text-white"):e.jsx("span",{className:"truncate font-medium text-oai-black dark:text-white",children:T}),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]}),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:[p?e.jsxs(e.Fragment,{children:[t.project_ref?w("hover:text-oai-black dark:hover:text-white"):e.jsx("span",{className:"truncate",children:x}),e.jsx("span",{"aria-hidden":!0,children:"·"})]}):null,e.jsx("span",{className:"truncate",children:t.model||a("sessions.model.unknown")}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:De(t.started_at,s)}),S?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:S})]}):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.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:$(t.total_tokens)})]}),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.jsx("dd",{className:"tabular-nums text-sm font-medium text-oai-black dark:text-white",children:te(t.cost_usd,{currency:d,rate:h})})]}),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:$(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:$(t.edit_turns)})]})]}),e.jsxs("button",{type:"button",onClick:c,disabled:!u,title:u||a("sessions.resume.unavailable"),"aria-label":u?a("sessions.resume.copy_aria",{command:u}):a("sessions.resume.unavailable"),className:E("-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",u?"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(pe,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{className:"hidden sm:inline",children:a("sessions.resume.copy")})]})]})]})});function Je(){const[r,t]=o.useState(null),[s,d]=o.useState(null),[h,k]=o.useState(!0),[S,u]=o.useState(!1),[x,T]=o.useState("all"),[p,I]=o.useState("all"),[g,w]=o.useState("all"),[c,m]=o.useState(""),[F,C]=o.useState(A),M=o.useRef(0),{resolvedLocale:N}=W(),v=o.useCallback(async(i=!1)=>{const b=++M.current;i?u(!0):k(!0),d(null);try{const l=await Ne({refresh:i});b===M.current&&t(l)}catch(l){b===M.current&&d(l?.message||String(l))}finally{b===M.current&&(k(!1),u(!1))}},[]);o.useEffect(()=>{G||H()?v(!1):k(!1)},[v]);const y=r?.sessions||_e,O=o.useMemo(()=>{const i=new Set,b=[];for(const l of y){const j=l.project_key;!j||i.has(j)||(i.add(j),b.push({value:j,label:j}))}return b.sort((l,j)=>l.label.localeCompare(j.label))},[y]),P=o.useDeferredValue(c),L=o.useMemo(()=>{const i=P.trim().toLowerCase(),b=Ce(p);return y.filter(l=>x!=="all"&&l.source!==x||g!=="all"&&l.project_key!==g||!Le(l,b)?!1:i?`${l.title||""} ${l.project_key||""} ${l.model||""} ${l.project_ref||""} ${l.session_id||""}`.toLowerCase().includes(i):!0)},[y,x,g,p,P]),n=x!=="all"||p!=="all"||g!=="all"||c.trim()!=="";o.useEffect(()=>{C(A)},[x,g,p,P,y]);const f=o.useMemo(()=>L.slice(0,F),[L,F]),_=L.length>f.length,D=o.useCallback(()=>C(i=>i+A),[]),q=o.useRef(null);o.useEffect(()=>{if(!_||typeof IntersectionObserver>"u")return;const i=q.current;if(!i)return;const b=new IntersectionObserver(l=>{l.some(j=>j.isIntersecting)&&D()},{rootMargin:"400px"});return b.observe(i),()=>b.disconnect()},[_,D]);const B=o.useMemo(()=>Se.map(i=>({id:i.id,label:i.label()})),[N]),J=o.useMemo(()=>Z.map(i=>({id:i.id,label:i.label()})),[N]),V=Number(r?.session_count)>Number(r?.returned_count);return!G&&!H()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(xe,{})}):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:()=>{v(!0)},disabled:S||h,"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(X,{className:E("h-4 w-4",S&&"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(U,{ariaLabel:a("sessions.filter.source_aria"),options:B,value:x,onChange:T}),e.jsx(U,{className:"pl-2",ariaLabel:a("sessions.filter.range_aria"),leading:e.jsx(ye,{className:"h-3.5 w-3.5 shrink-0 text-oai-gray-400","aria-hidden":!0}),options:J,value:p,onChange:I}),e.jsx(je,{options:O,value:g,onChange:w,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(z,{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(ae,{type:"search",value:c,onChange:i=>m(i.target.value),onKeyDown:i=>{i.key==="Escape"&&c&&(i.preventDefault(),m(""))},"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:i=>i.preventDefault(),onClick:()=>m(""),"aria-label":a("sessions.action.search_clear"),"aria-hidden":!c,tabIndex:c?0:-1,className:E("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",c?"scale-100 opacity-100":"pointer-events-none scale-90 opacity-0"),children:e.jsx(Y,{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:a("sessions.filter.result_count",{filtered:L.length,total:y.length})})]}),V?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:()=>{v(!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")})]}):h?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(fe,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),a("sessions.loading")]}):L.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:n?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:n?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:f.map(i=>e.jsx(Me,{session:i,locale:N},i.session_hash))}),_?e.jsx("div",{ref:q,className:"flex justify-center pt-6",children:e.jsx("button",{type:"button",onClick:D,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{Je as SessionsPage};
@@ -1 +1 @@
1
- import{m as C,j as t,e as N,c as a,a as ne,r as d,as as ae,aJ as ie,ay as se,az as oe,aa as U,aK as re,aL as le,u as ce,d as P,a1 as ue,a4 as F,n as I,aM as de,aN as ge,S as B,aO as me,x as he,aP as be,aQ as pe,aR as xe,aS as fe,aT as ye,aU as ve,aV as je,L as ke,R as Ne,aW as Se,aX as Ce,a7 as T,h as we,aY as Le}from"./__vite-browser-external-L2HadaWR.js";import{a as Ae,b as G,s as Pe,K as Oe,P as Ee,D as _e,c as Ie,S as Te,v as Ge,u as Re,C as Me}from"./sortable.esm-CZtmM7Tp.js";import{a as De}from"./modifiers.esm-DKWwsA47.js";import{u as Ue,L as R}from"./use-limits-display-prefs-Bl4NPX34.js";import{P as Fe}from"./ProviderIcon-CBmpx1uF.js";import{a as M,l as D}from"./limits-providers-D7KHzRsf.js";import{m as Be}from"./react-uUvzHQm5.js";import{a as S,T as x,b as h,S as O,u as L}from"./Controls-ZF7RAlv8.js";import{P as He,u as $e,a as Ve}from"./use-session-efficiency-pref-Btxlws5g.js";import{C as ze}from"./check-DjA9wjvH.js";import{C as Ke}from"./copy-DMD9VvI7.js";import{A as qe}from"./index-Ca6uzmWw.js";import{u as Ze}from"./useCurrency-Dr4F-MZe.js";import{u as We}from"./useTokenFormat-BHmT3c4D.js";import{S as H}from"./Select-Cg0q9TwB.js";import{I as Ye}from"./info-DfeZe41U.js";import{C as Qe}from"./ConfirmModal-ce7m5kbY.js";import{A as Je}from"./arrow-up-right-BYW8TxaE.js";import{D as Xe}from"./download-AY9DU1FN.js";import"./Card-B7pwNMNG.js";import"./ToolbarRootContext-Def90ZdR.js";import"./useScrollLock-7UUKbtyh.js";import"./SelectItemText-BIfAByNj.js";import"./DialogTitle-BzF6VDdV.js";import"./store-Bl3-sCXx.js";import"./DialogDescription-CRaQgXyp.js";const et=[["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"}]],tt=C("flask-conical",et);const nt=[["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"}]],at=C("grip-vertical",nt);const it=[["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"}]],st=C("languages",it);const ot=[["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"}]],rt=C("log-out",ot);const lt=[["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"}]],ct=C("palette",lt);const ut=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],dt=C("user-round",ut),gt="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function mt({checked:e,onChange:n,ariaLabel:i}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":i,onClick:n,className:N("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:N("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function ht({id:e,visible:n,onToggle:i}){const{attributes:s,listeners:o,setNodeRef:r,transform:l,transition:c,isDragging:u}=Re({id:e}),b={transform:Me.Transform.toString(l)||void 0,transition:c,zIndex:u?20:void 0};return t.jsxs("div",{ref:r,style:b,className:N("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"),...s,...o,children:[t.jsx(at,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),M(e)?t.jsx(Fe,{provider:M(e),size:18,className:N("pointer-events-none",gt)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200",children:D(e)}),t.jsx("div",{onPointerDown:m=>m.stopPropagation(),children:t.jsx(mt,{checked:n,onChange:i,ariaLabel:`${a("limits.settings.toggle_visible")}: ${D(e)}`})})]})}function bt({prefs:e}){const{order:n,visibility:i,toggle:s,moveToward:o}=e,r=Ae(G(Ee,{activationConstraint:{distance:6}}),G(Oe,{coordinateGetter:Pe})),l=({active:c,over:u})=>{u&&c.id!==u.id&&o(c.id,u.id)};return t.jsx(_e,{sensors:r,collisionDetection:Ie,modifiers:[De],onDragEnd:l,children:t.jsx(Te,{items:n,strategy:Ge,children:t.jsx("div",{className:"flex flex-col",children:n.map(c=>t.jsx(ht,{id:c,visible:i[c]!==!1,onToggle:()=>s(c)},c))})})})}function pt(e){if(!e||typeof e!="object")return"";const n=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},i=e.profile&&typeof e.profile=="object"?e.profile:{},s=n.full_name||n.name||i.name||n.user_name||n.preferred_username;return typeof s=="string"&&s.trim()?s.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function xt(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function ft(e){const n=typeof e=="string"?e.trim():"";if(!n)return null;const i=n.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),s=n.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=i?.[1]||s?.[1];return o?`https://github.com/${o}`:null}function E(e,n){console.warn(`[tokentracker] settings ${e}:`,n)}function yt(e,n,i){const[s,o]=d.useState(()=>ae()),r=n&&i&&ie(),l=d.useCallback(async()=>{const c=!s;if(se(c),o(c),!!c)try{await oe(()=>e())}catch(u){E("cloud sync",u)}},[s,e]);return{cloudSyncOn:s,handleCloudSyncToggle:l,showLocalCloudSync:r}}function vt(e){const[n,i]=d.useState(!1),[s,o]=d.useState(!1),[r,l]=d.useState(!1),[c,u]=d.useState(!1),[b,m]=d.useState(null),[y,v]=d.useState(!1),[g,f]=d.useState(""),[p,j]=d.useState(!1),[w,_]=d.useState(""),[K,q]=d.useState(""),[Z,W]=d.useState(!1),[Y,Q]=d.useState(null),J=d.useMemo(()=>pt(e),[e]),X=d.useMemo(()=>xt(e),[e]),ee=d.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),te=d.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:m,setGithubUrl:_,setProfileLoading:l,setPublicProfileOn:i,setShowGithubOn:j}),[]);return{anonymousOn:s,customDisplayName:b,displayName:J,editingGithub:Z,editingName:y,email:X,githubError:Y,githubInput:K,githubUrl:w,loadSetters:te,nameInput:g,profileLoading:r,profileSaving:c,publicProfileOn:n,setAnonymousOn:o,setCustomDisplayName:m,setEditingGithub:W,setEditingName:v,setGithubError:Q,setGithubInput:q,setGithubUrl:_,setNameInput:f,setProfileLoading:l,setProfileSaving:u,setPublicProfileOn:i,setShowGithubOn:j,showGithubOn:p,userId:ee}}function jt(e,n,i){d.useEffect(()=>{if(!n)return;let s=!0;return i.setProfileLoading(!0),(async()=>{try{const o=await U({getAccessToken:e});if(!s||!o)return;const r=await re({accessToken:o});if(!s)return;i.setPublicProfileOn(!!r?.enabled),i.setAnonymousOn(!!r?.anonymous),r?.display_name&&i.setCustomDisplayName(r.display_name),i.setShowGithubOn(!!r?.show_github_url),i.setGithubUrl(r?.github_url||"")}catch(o){E("load public profile",o)}finally{s&&i.setProfileLoading(!1)}})(),()=>{s=!1}},[e,n,i])}function kt(e,n){return d.useCallback(async(i,{label:s,onError:o,onSuccess:r}={})=>{if(n.profileSaving)return!1;n.setProfileSaving(!0);try{const l=await U({getAccessToken:e});if(!l)return!1;const c=await le({accessToken:l,...i});return r?.(c),!0}catch(l){return o?o(l):E(s||"mutate profile",l),!1}finally{n.setProfileSaving(!1)}},[e,n])}function Nt(e,n){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:n.handleAnonymousToggle,handleSaveName:n.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:n.startEditingName}}function St(e,n){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:n.handleSaveGithub,handleShowGithubToggle:n.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:n.startEditingGithub}}function Ct(e,n){const i=d.useCallback(async()=>{const o=!e.publicProfileOn;await n({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[n,e]);return{handleAnonymousToggle:d.useCallback(async()=>{const o=!e.anonymousOn;await n({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[n,e]),handlePublicProfileToggle:i}}function wt(e,n,i){const s=d.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await n({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),i?.()}})},[n,e,i]),o=d.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:s,startEditingName:o}}function Lt(e,n){const i=d.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await n({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[n,e]),s=d.useCallback(async()=>{const r=ft(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(a("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await n({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||a("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[n,e]),o=d.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:s,handleShowGithubToggle:i,startEditingGithub:o}}function At(){const e=ne(),n=vt(e.user),i=yt(e.getAccessToken,e.enabled,e.signedIn);jt(e.getAccessToken,e.signedIn,n.loadSetters);const s=kt(e.getAccessToken,n),o=Ct(n,s),r=wt(n,s,e.refreshDisplayName),l=Lt(n,s);return{...e,...i,email:n.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:n.userId,name:Nt(n,{...o,...r}),github:St(n,l),profileLoading:n.profileLoading,profileSaving:n.profileSaving,publicProfileOn:n.publicProfileOn}}function $({disabled:e,onCancel:n,onSave:i,saveLabel:s=a("settings.account.save")}){return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:i,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:s}),t.jsx("button",{type:"button",onClick:n,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:a("settings.account.cancel")})]})}function Pt({nameInput:e,setEditingName:n,setNameInput:i,profileSaving:s,handleSaveName:o}){return t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"text",value:e,onChange:r=>i(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&n(!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:a("settings.account.displayName")}),t.jsx($,{disabled:s||!e.trim(),onCancel:()=>n(!1),onSave:o,saveLabel:s?a("settings.account.saving"):void 0})]})}function Ot({githubError:e,githubInput:n,handleSaveGithub:i,profileSaving:s,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:n,onChange:c=>{l(c.target.value),e&&r(null)},onKeyDown:c=>{c.key==="Enter"&&i(),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:a("settings.account.githubUrlPlaceholder")}),t.jsx($,{disabled:s,onCancel:()=>{o(!1),r(null)},onSave:i,saveLabel:s?a("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 V({disabled:e=!1,label:n,onClick:i,title:s}){return t.jsxs("button",{type:"button",onClick:i,disabled:e,title:s,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(He,{className:"h-3.5 w-3.5","aria-hidden":!0}),n]})}function z({actions:e,editing:n,editor:i,hint:s,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}),n?i:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s})]}),n?null:e]})})}function Et({name:e}){const n=e.anonymousOn?a("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(V,{disabled:e.anonymousOn,label:a("settings.account.edit"),onClick:e.startEditingName,title:n}),t.jsx(x,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:a("settings.account.displayName")})]})}function _t({name:e}){const{anonymousOn:n,customDisplayName:i,displayName:s,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:c,profileLoading:u,profileSaving:b,setEditingName:m,setNameInput:y,startEditingName:v}=e,g=n?a("settings.account.displayNameAnonymousHint"):i||s;return t.jsx(z,{label:a("settings.account.displayName"),editing:o,hint:g,editor:t.jsx(Pt,{nameInput:c,setEditingName:m,setNameInput:y,profileSaving:b,handleSaveName:l}),actions:t.jsx(Et,{name:e})})}function It({github:e}){const{editingGithub:n,githubError:i,githubInput:s,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:c,profileSaving:u,setEditingGithub:b,setGithubError:m,setGithubInput:y,showGithubOn:v,startEditingGithub:g}=e;return t.jsx(t.Fragment,{children:t.jsx(z,{label:a("settings.account.githubUrl"),editing:n,hint:o||a("settings.account.githubUrlHint"),editor:t.jsx(Ot,{githubError:i,githubInput:s,handleSaveGithub:r,profileSaving:u,setEditingGithub:b,setGithubError:m,setGithubInput:y}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(V,{label:a("settings.account.edit"),onClick:g}),t.jsx(x,{checked:v,onChange:l,disabled:c||u,ariaLabel:a("settings.account.githubUrl")})]})})})}function Tt(){const{openLoginModal:e}=ce();return t.jsx(S,{title:a("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:a("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:a("settings.account.signIn")})]})})}function Gt({name:e,github:n}){return t.jsxs(t.Fragment,{children:[t.jsx(_t,{name:e}),t.jsx(It,{github:n})]})}function Rt(){const e=At();return e.enabled?e.signedIn?t.jsxs(S,{title:a("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Dt,{onSignOut:e.signOut}),children:[t.jsx(Mt,{userId:e.userId}),t.jsx(Ut,{settings:e}),t.jsx(Ft,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(Bt,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(Tt,{}):null}function Mt({userId:e}){const[n,i]=P.useState(!1);if(!e)return null;const s=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),i(!0),globalThis.setTimeout(()=>i(!1),1200)}catch{i(!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:a("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:s,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":a("settings.account.copyUserId"),children:[n?t.jsx(ze,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(Ke,{className:"h-3.5 w-3.5","aria-hidden":!0}),n?a("settings.account.copied"):a("settings.account.copy")]})]})}function Dt({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(rt,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.account.signOut")]})}function Ut({settings:e}){return e.showLocalCloudSync?t.jsx(h,{label:a("settings.account.cloudSync"),hint:a("settings.account.cloudSyncHint"),control:t.jsx(x,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:a("settings.account.cloudSync")})}):null}function Ft({checked:e,disabled:n,onChange:i}){return t.jsx(h,{label:a("settings.account.publicProfile"),hint:a("settings.account.publicProfileHint"),control:t.jsx(x,{checked:e,onChange:i,disabled:n,ariaLabel:a("settings.account.publicProfile")})})}function Bt({visible:e,name:n,github:i}){return t.jsx(qe,{initial:!1,children:e?t.jsx(Be.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(Gt,{name:n,github:i})},"public-profile-fields"):null})}function Ht(){return[{value:"light",label:a("settings.appearance.theme.light"),Icon:de},{value:"dark",label:a("settings.appearance.theme.dark"),Icon:ge},{value:"system",label:a("settings.appearance.theme.system"),Icon:B}]}function $t(){return[{value:be,label:a("settings.appearance.language.system")},{value:pe,label:a("settings.appearance.language.english")},{value:xe,label:a("settings.appearance.language.chinese")},{value:fe,label:a("settings.appearance.language.traditional_chinese")},{value:ye,label:a("settings.appearance.language.japanese")},{value:ve,label:a("settings.appearance.language.korean")},{value:je,label:a("settings.appearance.language.german")}]}function Vt(e){if(!e)return null;try{const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toLocaleString()}catch{return null}}function zt(e,n){const i=a(`settings.appearance.currency.rate_source.${e}`),s=Vt(n),o=s?a("settings.appearance.currency.rate_updated",{when:s}):a("settings.appearance.currency.rate_never");return`${i} · ${o}`}function Kt({locale:e,setLocale:n}){const i=$t();return t.jsx(H,{value:e,onValueChange:n,options:i,ariaLabel:a("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx(st,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function qt({currency:e,setCurrency:n}){const i=me().map(s=>({value:s.code,label:a(s.labelKey)}));return t.jsx(H,{value:e,onValueChange:n,options:i,ariaLabel:a("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function Zt({currency:e,rate:n,rateSource:i,rateFetchedAt:s}){if(e===he)return t.jsx(t.Fragment,{children:a("settings.appearance.currency.hint")});const o=zt(i,s);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${n.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(Ye,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function Wt(){const{theme:e,setTheme:n}=ue(),{locale:i,setLocale:s}=F(),{currency:o,rate:r,rateSource:l,rateFetchedAt:c,setCurrency:u}=Ze(),{mode:b,setMode:m}=We();return t.jsxs(S,{title:a("settings.section.appearance"),children:[t.jsx(h,{label:a("settings.appearance.theme.label"),hint:a("settings.appearance.theme.hint"),control:t.jsx(O,{options:Ht(),value:e,onChange:n})}),t.jsx(h,{label:a("settings.appearance.language.label"),hint:a("settings.appearance.language.hint"),control:t.jsx(Kt,{locale:i,setLocale:s})}),t.jsx(h,{label:a("settings.appearance.currency.label"),hint:t.jsx(Zt,{currency:o,rate:r,rateSource:l,rateFetchedAt:c}),control:t.jsx(qt,{currency:o,setCurrency:u})}),t.jsx(h,{label:a("settings.appearance.token_format.label"),hint:a("settings.appearance.token_format.hint"),control:t.jsx(O,{options:[{value:I.COMPACT,label:a("settings.appearance.token_format.compact")},{value:I.FULL,label:a("settings.appearance.token_format.full")}],value:b,onChange:m})})]})}function A({labelKey:e}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:a(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:a("qpd.card.badge")})]})}function Yt(){const{enabled:e,toggle:n}=$e(),{enabled:i,toggle:s}=Ve(),{available:o,settings:r,setSetting:l}=L(),c=o&&!!r?.dynamicIslandSupported,u=!!r?.dynamicIslandEnabled;return t.jsxs(S,{title:a("settings.section.labs"),children:[c&&t.jsxs(t.Fragment,{children:[t.jsx(h,{label:t.jsx(A,{labelKey:"settings.labs.island.label"}),hint:a("settings.labs.island.hint"),control:t.jsx(x,{checked:u,onChange:()=>l("dynamicIslandEnabled",!u),ariaLabel:a("settings.labs.island.aria")})}),u&&t.jsx(h,{label:a("settings.labs.island_hide_menubar.label"),hint:a("settings.labs.island_hide_menubar.hint"),control:t.jsx(x,{checked:!!r?.hideMenuBarIcon,onChange:()=>l("hideMenuBarIcon",!r?.hideMenuBarIcon),ariaLabel:a("settings.labs.island_hide_menubar.aria")})})]}),t.jsx(h,{label:t.jsx(A,{labelKey:"settings.labs.qpd.label"}),hint:a("settings.labs.qpd.hint"),control:t.jsx(x,{checked:e,onChange:n,ariaLabel:a("settings.labs.qpd.aria")})}),t.jsx(h,{label:t.jsx(A,{labelKey:"settings.labs.sessions.label"}),hint:a("settings.labs.sessions.hint"),control:t.jsx(x,{checked:i,onChange:s,ariaLabel:a("settings.labs.sessions.aria")})})]})}function Qt(){const{available:e,settings:n,setSetting:i,runAction:s}=L();if(!e)return null;const o=!!n?.launchAtLogin,r=n?.toastOnReset!==!1,l=n?.confettiOnReset!==!1,c=n?.launchAtLoginSupported!==!1,u=n?.updateStatus||null,b=!!n?.updateBusy,m=!!n?.isSyncing;return t.jsxs(S,{title:a("settings.section.menubar"),children:[t.jsx(h,{label:a("settings.menubar.appearance"),hint:a("settings.menubar.appearanceHint"),control:t.jsxs(ke,{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:[a("settings.menubar.appearanceLink"),t.jsx(Je,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),t.jsx(h,{label:a("settings.menubar.toastOnReset"),hint:a("settings.menubar.toastOnResetHint"),control:t.jsx(x,{checked:r,onChange:()=>i("toastOnReset",!r),ariaLabel:a("settings.menubar.toastOnReset")})}),t.jsx(h,{label:a("settings.menubar.confettiOnReset"),hint:a("settings.menubar.confettiOnResetHint"),control:t.jsx(x,{checked:l,onChange:()=>i("confettiOnReset",!l),ariaLabel:a("settings.menubar.confettiOnReset")})}),c?t.jsx(h,{label:a("settings.menubar.launchAtLogin"),hint:a("settings.menubar.launchAtLoginHint"),control:t.jsx(x,{checked:o,onChange:()=>i("launchAtLogin",!o),ariaLabel:a("settings.menubar.launchAtLogin")})}):null,t.jsx(h,{label:a("settings.menubar.syncNow"),hint:a("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>s("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(Ne,{className:N("h-3.5 w-3.5",m&&"animate-spin"),"aria-hidden":!0}),m?a("settings.menubar.syncing"):a("settings.menubar.syncNow")]})}),t.jsx(h,{label:a("settings.menubar.updates"),hint:u||void 0,control:t.jsxs("button",{type:"button",onClick:()=>s("checkForUpdates"),disabled:b,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(Xe,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.menubar.checkUpdates")]})})]})}function Jt(e,n){function i(r){return r.replace(/^v/,"").split(".").map(Number)}const s=i(e),o=i(n);for(let r=0;r<Math.max(s.length,o.length);r++){const l=s[r]||0,c=o[r]||0;if(l<c)return!0;if(l>c)return!1}return!1}function Xt(){const{available:e,settings:n,runAction:i}=L(),s=e&&n?.version,[o,r]=P.useState(!1),[l,c]=P.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:u}=F(),b="0.87.12",m=async()=>{r(!0);try{const p=await fetch("https://api.github.com/repos/xiufengsun/TokenTracker/releases/latest");if(!p.ok)throw new Error("Failed to fetch");const j=await p.json(),w=j.tag_name;Jt(b,w)?c({open:!0,latestVersion:w,htmlUrl:j.html_url}):T({title:a("settings.menubar.updates.upToDate")})}catch(p){console.error("Check updates failed:",p),T({title:a("settings.menubar.updates.failed")})}finally{r(!1)}},y=a("settings.menubar.updates.modalTitle"),v=a("settings.menubar.updates.modalDescription",{version:l.latestVersion}),g=a("settings.menubar.updates.modalConfirm"),f=a("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:[s?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:a("settings.menubar.updates.footerCombined",{barVersion:n.version,coreVersion:b})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>i("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:a("settings.menubar.updates.footerCore",{version:b})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:m,disabled:o,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:o?a("settings.menubar.updates.checking"):a("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Se,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(Ce,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.footer.statusPage")]})]}),t.jsx(Qe,{open:l.open,title:y,description:v,confirmLabel:g,cancelLabel:f,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),c(p=>({...p,open:!1}))},onCancel:()=>c(p=>({...p,open:!1}))})]})}const k={APPEARANCE:"appearance",NATIVE_APP:"native-app",ACCOUNT:"account",LIMITS:"limits",LABS:"labs"};function en({prefs:e}){return t.jsx(O,{options:[{value:R.USED,label:a("limits.settings.display_mode_used")},{value:R.REMAINING,label:a("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function An(){const e=Ue(),{available:n,settings:i,setSetting:s}=L(),o=i?.toastOnReset!==!1,r=i?.confettiOnReset!==!1,[l,c]=we(),u=l.get("section"),m=Object.values(k).includes(u)&&(u!==k.NATIVE_APP||n)?u:k.APPEARANCE,y=g=>{const f=new URLSearchParams(l);g===k.APPEARANCE?f.delete("section"):f.set("section",g),c(f,{replace:!0})},v=[{id:k.APPEARANCE,label:a("settings.section.appearance"),Icon:ct,content:t.jsx(Wt,{})},...n?[{id:k.NATIVE_APP,label:a("settings.section.menubar"),Icon:B,content:t.jsx(Qt,{})}]:[],{id:k.ACCOUNT,label:a("settings.section.account"),Icon:dt,content:t.jsx(Rt,{})},{id:k.LIMITS,label:a("settings.section.limits"),Icon:Le,content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs(S,{title:a("settings.section.limits"),children:[t.jsx(h,{label:a("limits.settings.display_mode_label"),control:t.jsx(en,{prefs:e})}),t.jsx(h,{label:a("settings.menubar.toastOnReset"),hint:a("settings.menubar.toastOnResetHint"),control:t.jsx(x,{checked:o,disabled:!n,onChange:()=>s("toastOnReset",!o),ariaLabel:a("settings.menubar.toastOnReset")})}),t.jsx(h,{label:a("settings.menubar.confettiOnReset"),hint:a("settings.menubar.confettiOnResetHint"),control:t.jsx(x,{checked:r,disabled:!n,onChange:()=>s("confettiOnReset",!r),ariaLabel:a("settings.menubar.confettiOnReset")})})]}),t.jsx(S,{title:a("settings.limits.providers"),children:t.jsx(bt,{prefs:e})})]})},{id:k.LABS,label:a("settings.section.labs"),Icon:tt,content:t.jsx(Yt,{})}];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.jsx("div",{className:"mb-7",children:t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("settings.page.title")})}),t.jsxs("div",{className:"grid min-w-0 gap-6 md:grid-cols-[12rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[13.5rem_minmax(0,1fr)]",children:[t.jsx("aside",{className:"min-w-0 border-b border-oai-gray-200 pb-3 dark:border-oai-gray-800 md:border-b-0 md:border-r md:pb-0 md:pr-5",children:t.jsx("nav",{"aria-label":a("settings.page.title"),className:"flex gap-0 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden md:sticky md:top-6 md:flex-col md:gap-1 md:overflow-visible",children:v.map(({id:g,label:f,Icon:p})=>{const j=m===g;return t.jsxs("button",{id:`settings-nav-${g}`,type:"button","aria-current":j?"page":void 0,"aria-controls":`settings-panel-${g}`,onClick:()=>y(g),className:N("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",j?"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(p,{className:N("h-4 w-4 shrink-0",j?"text-oai-black dark:text-white":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:f})]},g)})})}),t.jsxs("div",{className:"min-w-0",children:[v.map(({id:g,label:f,content:p})=>t.jsx("section",{id:`settings-panel-${g}`,"aria-labelledby":`settings-nav-${g}`,"aria-label":f,"data-settings-panel":g,hidden:m!==g,children:p},g)),t.jsx(Xt,{})]})]})]})})})}export{An as SettingsPage};
1
+ import{m as C,j as t,e as N,c as a,a as ne,r as d,as as ae,aJ as ie,ay as se,az as oe,aa as U,aK as re,aL as le,u as ce,d as P,a1 as ue,a4 as F,n as I,aM as de,aN as ge,S as B,aO as me,x as he,aP as be,aQ as pe,aR as xe,aS as fe,aT as ye,aU as ve,aV as je,L as ke,R as Ne,aW as Se,aX as Ce,a7 as T,h as we,aY as Le}from"./__vite-browser-external-CU0HL6hY.js";import{a as Ae,b as G,s as Pe,K as Oe,P as Ee,D as _e,c as Ie,S as Te,v as Ge,u as Re,C as Me}from"./sortable.esm-YyExnyg0.js";import{a as De}from"./modifiers.esm-DpXL6h3m.js";import{u as Ue,L as R}from"./use-limits-display-prefs-CpW6_ZBo.js";import{P as Fe}from"./ProviderIcon-CxpFegpD.js";import{a as M,l as D}from"./limits-providers-DOW-oPEP.js";import{m as Be}from"./react-CBi7M7dK.js";import{a as S,T as x,b as h,S as O,u as L}from"./Controls-D5LSYH96.js";import{P as He,u as $e,a as Ve}from"./use-session-efficiency-pref-Di41rY7h.js";import{C as ze}from"./check-D1DIUZ3y.js";import{C as Ke}from"./copy-DGTadiXw.js";import{A as qe}from"./index-CbpwbfY1.js";import{u as Ze}from"./useCurrency-DKrZtU2Z.js";import{u as We}from"./useTokenFormat-C8hwTvLr.js";import{S as H}from"./Select-Coxp19gW.js";import{I as Ye}from"./info-DlZkEw5y.js";import{C as Qe}from"./ConfirmModal-D05J-QUB.js";import{A as Je}from"./arrow-up-right-C6W_K-fZ.js";import{D as Xe}from"./download-CBYnlCsF.js";import"./Card-DQgKBViP.js";import"./ToolbarRootContext-D3Xvbsmu.js";import"./useScrollLock-D2roJGoE.js";import"./SelectItemText-Dw-zi_PN.js";import"./DialogTitle-O5nTArna.js";import"./store-PiuqLY56.js";import"./DialogDescription-DVH6GzL7.js";const et=[["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"}]],tt=C("flask-conical",et);const nt=[["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"}]],at=C("grip-vertical",nt);const it=[["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"}]],st=C("languages",it);const ot=[["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"}]],rt=C("log-out",ot);const lt=[["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"}]],ct=C("palette",lt);const ut=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],dt=C("user-round",ut),gt="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function mt({checked:e,onChange:n,ariaLabel:i}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":i,onClick:n,className:N("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:N("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function ht({id:e,visible:n,onToggle:i}){const{attributes:s,listeners:o,setNodeRef:r,transform:l,transition:c,isDragging:u}=Re({id:e}),b={transform:Me.Transform.toString(l)||void 0,transition:c,zIndex:u?20:void 0};return t.jsxs("div",{ref:r,style:b,className:N("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"),...s,...o,children:[t.jsx(at,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),M(e)?t.jsx(Fe,{provider:M(e),size:18,className:N("pointer-events-none",gt)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200",children:D(e)}),t.jsx("div",{onPointerDown:m=>m.stopPropagation(),children:t.jsx(mt,{checked:n,onChange:i,ariaLabel:`${a("limits.settings.toggle_visible")}: ${D(e)}`})})]})}function bt({prefs:e}){const{order:n,visibility:i,toggle:s,moveToward:o}=e,r=Ae(G(Ee,{activationConstraint:{distance:6}}),G(Oe,{coordinateGetter:Pe})),l=({active:c,over:u})=>{u&&c.id!==u.id&&o(c.id,u.id)};return t.jsx(_e,{sensors:r,collisionDetection:Ie,modifiers:[De],onDragEnd:l,children:t.jsx(Te,{items:n,strategy:Ge,children:t.jsx("div",{className:"flex flex-col",children:n.map(c=>t.jsx(ht,{id:c,visible:i[c]!==!1,onToggle:()=>s(c)},c))})})})}function pt(e){if(!e||typeof e!="object")return"";const n=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},i=e.profile&&typeof e.profile=="object"?e.profile:{},s=n.full_name||n.name||i.name||n.user_name||n.preferred_username;return typeof s=="string"&&s.trim()?s.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function xt(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function ft(e){const n=typeof e=="string"?e.trim():"";if(!n)return null;const i=n.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),s=n.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=i?.[1]||s?.[1];return o?`https://github.com/${o}`:null}function E(e,n){console.warn(`[tokentracker] settings ${e}:`,n)}function yt(e,n,i){const[s,o]=d.useState(()=>ae()),r=n&&i&&ie(),l=d.useCallback(async()=>{const c=!s;if(se(c),o(c),!!c)try{await oe(()=>e())}catch(u){E("cloud sync",u)}},[s,e]);return{cloudSyncOn:s,handleCloudSyncToggle:l,showLocalCloudSync:r}}function vt(e){const[n,i]=d.useState(!1),[s,o]=d.useState(!1),[r,l]=d.useState(!1),[c,u]=d.useState(!1),[b,m]=d.useState(null),[y,v]=d.useState(!1),[g,f]=d.useState(""),[p,j]=d.useState(!1),[w,_]=d.useState(""),[K,q]=d.useState(""),[Z,W]=d.useState(!1),[Y,Q]=d.useState(null),J=d.useMemo(()=>pt(e),[e]),X=d.useMemo(()=>xt(e),[e]),ee=d.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),te=d.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:m,setGithubUrl:_,setProfileLoading:l,setPublicProfileOn:i,setShowGithubOn:j}),[]);return{anonymousOn:s,customDisplayName:b,displayName:J,editingGithub:Z,editingName:y,email:X,githubError:Y,githubInput:K,githubUrl:w,loadSetters:te,nameInput:g,profileLoading:r,profileSaving:c,publicProfileOn:n,setAnonymousOn:o,setCustomDisplayName:m,setEditingGithub:W,setEditingName:v,setGithubError:Q,setGithubInput:q,setGithubUrl:_,setNameInput:f,setProfileLoading:l,setProfileSaving:u,setPublicProfileOn:i,setShowGithubOn:j,showGithubOn:p,userId:ee}}function jt(e,n,i){d.useEffect(()=>{if(!n)return;let s=!0;return i.setProfileLoading(!0),(async()=>{try{const o=await U({getAccessToken:e});if(!s||!o)return;const r=await re({accessToken:o});if(!s)return;i.setPublicProfileOn(!!r?.enabled),i.setAnonymousOn(!!r?.anonymous),r?.display_name&&i.setCustomDisplayName(r.display_name),i.setShowGithubOn(!!r?.show_github_url),i.setGithubUrl(r?.github_url||"")}catch(o){E("load public profile",o)}finally{s&&i.setProfileLoading(!1)}})(),()=>{s=!1}},[e,n,i])}function kt(e,n){return d.useCallback(async(i,{label:s,onError:o,onSuccess:r}={})=>{if(n.profileSaving)return!1;n.setProfileSaving(!0);try{const l=await U({getAccessToken:e});if(!l)return!1;const c=await le({accessToken:l,...i});return r?.(c),!0}catch(l){return o?o(l):E(s||"mutate profile",l),!1}finally{n.setProfileSaving(!1)}},[e,n])}function Nt(e,n){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:n.handleAnonymousToggle,handleSaveName:n.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:n.startEditingName}}function St(e,n){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:n.handleSaveGithub,handleShowGithubToggle:n.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:n.startEditingGithub}}function Ct(e,n){const i=d.useCallback(async()=>{const o=!e.publicProfileOn;await n({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[n,e]);return{handleAnonymousToggle:d.useCallback(async()=>{const o=!e.anonymousOn;await n({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[n,e]),handlePublicProfileToggle:i}}function wt(e,n,i){const s=d.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await n({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),i?.()}})},[n,e,i]),o=d.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:s,startEditingName:o}}function Lt(e,n){const i=d.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await n({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[n,e]),s=d.useCallback(async()=>{const r=ft(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(a("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await n({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||a("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[n,e]),o=d.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:s,handleShowGithubToggle:i,startEditingGithub:o}}function At(){const e=ne(),n=vt(e.user),i=yt(e.getAccessToken,e.enabled,e.signedIn);jt(e.getAccessToken,e.signedIn,n.loadSetters);const s=kt(e.getAccessToken,n),o=Ct(n,s),r=wt(n,s,e.refreshDisplayName),l=Lt(n,s);return{...e,...i,email:n.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:n.userId,name:Nt(n,{...o,...r}),github:St(n,l),profileLoading:n.profileLoading,profileSaving:n.profileSaving,publicProfileOn:n.publicProfileOn}}function $({disabled:e,onCancel:n,onSave:i,saveLabel:s=a("settings.account.save")}){return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:i,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:s}),t.jsx("button",{type:"button",onClick:n,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:a("settings.account.cancel")})]})}function Pt({nameInput:e,setEditingName:n,setNameInput:i,profileSaving:s,handleSaveName:o}){return t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"text",value:e,onChange:r=>i(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&n(!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:a("settings.account.displayName")}),t.jsx($,{disabled:s||!e.trim(),onCancel:()=>n(!1),onSave:o,saveLabel:s?a("settings.account.saving"):void 0})]})}function Ot({githubError:e,githubInput:n,handleSaveGithub:i,profileSaving:s,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:n,onChange:c=>{l(c.target.value),e&&r(null)},onKeyDown:c=>{c.key==="Enter"&&i(),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:a("settings.account.githubUrlPlaceholder")}),t.jsx($,{disabled:s,onCancel:()=>{o(!1),r(null)},onSave:i,saveLabel:s?a("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 V({disabled:e=!1,label:n,onClick:i,title:s}){return t.jsxs("button",{type:"button",onClick:i,disabled:e,title:s,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(He,{className:"h-3.5 w-3.5","aria-hidden":!0}),n]})}function z({actions:e,editing:n,editor:i,hint:s,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}),n?i:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s})]}),n?null:e]})})}function Et({name:e}){const n=e.anonymousOn?a("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(V,{disabled:e.anonymousOn,label:a("settings.account.edit"),onClick:e.startEditingName,title:n}),t.jsx(x,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:a("settings.account.displayName")})]})}function _t({name:e}){const{anonymousOn:n,customDisplayName:i,displayName:s,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:c,profileLoading:u,profileSaving:b,setEditingName:m,setNameInput:y,startEditingName:v}=e,g=n?a("settings.account.displayNameAnonymousHint"):i||s;return t.jsx(z,{label:a("settings.account.displayName"),editing:o,hint:g,editor:t.jsx(Pt,{nameInput:c,setEditingName:m,setNameInput:y,profileSaving:b,handleSaveName:l}),actions:t.jsx(Et,{name:e})})}function It({github:e}){const{editingGithub:n,githubError:i,githubInput:s,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:c,profileSaving:u,setEditingGithub:b,setGithubError:m,setGithubInput:y,showGithubOn:v,startEditingGithub:g}=e;return t.jsx(t.Fragment,{children:t.jsx(z,{label:a("settings.account.githubUrl"),editing:n,hint:o||a("settings.account.githubUrlHint"),editor:t.jsx(Ot,{githubError:i,githubInput:s,handleSaveGithub:r,profileSaving:u,setEditingGithub:b,setGithubError:m,setGithubInput:y}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(V,{label:a("settings.account.edit"),onClick:g}),t.jsx(x,{checked:v,onChange:l,disabled:c||u,ariaLabel:a("settings.account.githubUrl")})]})})})}function Tt(){const{openLoginModal:e}=ce();return t.jsx(S,{title:a("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:a("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:a("settings.account.signIn")})]})})}function Gt({name:e,github:n}){return t.jsxs(t.Fragment,{children:[t.jsx(_t,{name:e}),t.jsx(It,{github:n})]})}function Rt(){const e=At();return e.enabled?e.signedIn?t.jsxs(S,{title:a("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Dt,{onSignOut:e.signOut}),children:[t.jsx(Mt,{userId:e.userId}),t.jsx(Ut,{settings:e}),t.jsx(Ft,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(Bt,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(Tt,{}):null}function Mt({userId:e}){const[n,i]=P.useState(!1);if(!e)return null;const s=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),i(!0),globalThis.setTimeout(()=>i(!1),1200)}catch{i(!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:a("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:s,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":a("settings.account.copyUserId"),children:[n?t.jsx(ze,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(Ke,{className:"h-3.5 w-3.5","aria-hidden":!0}),n?a("settings.account.copied"):a("settings.account.copy")]})]})}function Dt({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(rt,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.account.signOut")]})}function Ut({settings:e}){return e.showLocalCloudSync?t.jsx(h,{label:a("settings.account.cloudSync"),hint:a("settings.account.cloudSyncHint"),control:t.jsx(x,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:a("settings.account.cloudSync")})}):null}function Ft({checked:e,disabled:n,onChange:i}){return t.jsx(h,{label:a("settings.account.publicProfile"),hint:a("settings.account.publicProfileHint"),control:t.jsx(x,{checked:e,onChange:i,disabled:n,ariaLabel:a("settings.account.publicProfile")})})}function Bt({visible:e,name:n,github:i}){return t.jsx(qe,{initial:!1,children:e?t.jsx(Be.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(Gt,{name:n,github:i})},"public-profile-fields"):null})}function Ht(){return[{value:"light",label:a("settings.appearance.theme.light"),Icon:de},{value:"dark",label:a("settings.appearance.theme.dark"),Icon:ge},{value:"system",label:a("settings.appearance.theme.system"),Icon:B}]}function $t(){return[{value:be,label:a("settings.appearance.language.system")},{value:pe,label:a("settings.appearance.language.english")},{value:xe,label:a("settings.appearance.language.chinese")},{value:fe,label:a("settings.appearance.language.traditional_chinese")},{value:ye,label:a("settings.appearance.language.japanese")},{value:ve,label:a("settings.appearance.language.korean")},{value:je,label:a("settings.appearance.language.german")}]}function Vt(e){if(!e)return null;try{const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toLocaleString()}catch{return null}}function zt(e,n){const i=a(`settings.appearance.currency.rate_source.${e}`),s=Vt(n),o=s?a("settings.appearance.currency.rate_updated",{when:s}):a("settings.appearance.currency.rate_never");return`${i} · ${o}`}function Kt({locale:e,setLocale:n}){const i=$t();return t.jsx(H,{value:e,onValueChange:n,options:i,ariaLabel:a("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx(st,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function qt({currency:e,setCurrency:n}){const i=me().map(s=>({value:s.code,label:a(s.labelKey)}));return t.jsx(H,{value:e,onValueChange:n,options:i,ariaLabel:a("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function Zt({currency:e,rate:n,rateSource:i,rateFetchedAt:s}){if(e===he)return t.jsx(t.Fragment,{children:a("settings.appearance.currency.hint")});const o=zt(i,s);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${n.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(Ye,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function Wt(){const{theme:e,setTheme:n}=ue(),{locale:i,setLocale:s}=F(),{currency:o,rate:r,rateSource:l,rateFetchedAt:c,setCurrency:u}=Ze(),{mode:b,setMode:m}=We();return t.jsxs(S,{title:a("settings.section.appearance"),children:[t.jsx(h,{label:a("settings.appearance.theme.label"),hint:a("settings.appearance.theme.hint"),control:t.jsx(O,{options:Ht(),value:e,onChange:n})}),t.jsx(h,{label:a("settings.appearance.language.label"),hint:a("settings.appearance.language.hint"),control:t.jsx(Kt,{locale:i,setLocale:s})}),t.jsx(h,{label:a("settings.appearance.currency.label"),hint:t.jsx(Zt,{currency:o,rate:r,rateSource:l,rateFetchedAt:c}),control:t.jsx(qt,{currency:o,setCurrency:u})}),t.jsx(h,{label:a("settings.appearance.token_format.label"),hint:a("settings.appearance.token_format.hint"),control:t.jsx(O,{options:[{value:I.COMPACT,label:a("settings.appearance.token_format.compact")},{value:I.FULL,label:a("settings.appearance.token_format.full")}],value:b,onChange:m})})]})}function A({labelKey:e}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:a(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:a("qpd.card.badge")})]})}function Yt(){const{enabled:e,toggle:n}=$e(),{enabled:i,toggle:s}=Ve(),{available:o,settings:r,setSetting:l}=L(),c=o&&!!r?.dynamicIslandSupported,u=!!r?.dynamicIslandEnabled;return t.jsxs(S,{title:a("settings.section.labs"),children:[c&&t.jsxs(t.Fragment,{children:[t.jsx(h,{label:t.jsx(A,{labelKey:"settings.labs.island.label"}),hint:a("settings.labs.island.hint"),control:t.jsx(x,{checked:u,onChange:()=>l("dynamicIslandEnabled",!u),ariaLabel:a("settings.labs.island.aria")})}),u&&t.jsx(h,{label:a("settings.labs.island_hide_menubar.label"),hint:a("settings.labs.island_hide_menubar.hint"),control:t.jsx(x,{checked:!!r?.hideMenuBarIcon,onChange:()=>l("hideMenuBarIcon",!r?.hideMenuBarIcon),ariaLabel:a("settings.labs.island_hide_menubar.aria")})})]}),t.jsx(h,{label:t.jsx(A,{labelKey:"settings.labs.qpd.label"}),hint:a("settings.labs.qpd.hint"),control:t.jsx(x,{checked:e,onChange:n,ariaLabel:a("settings.labs.qpd.aria")})}),t.jsx(h,{label:t.jsx(A,{labelKey:"settings.labs.sessions.label"}),hint:a("settings.labs.sessions.hint"),control:t.jsx(x,{checked:i,onChange:s,ariaLabel:a("settings.labs.sessions.aria")})})]})}function Qt(){const{available:e,settings:n,setSetting:i,runAction:s}=L();if(!e)return null;const o=!!n?.launchAtLogin,r=n?.toastOnReset!==!1,l=n?.confettiOnReset!==!1,c=n?.launchAtLoginSupported!==!1,u=n?.updateStatus||null,b=!!n?.updateBusy,m=!!n?.isSyncing;return t.jsxs(S,{title:a("settings.section.menubar"),children:[t.jsx(h,{label:a("settings.menubar.appearance"),hint:a("settings.menubar.appearanceHint"),control:t.jsxs(ke,{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:[a("settings.menubar.appearanceLink"),t.jsx(Je,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),t.jsx(h,{label:a("settings.menubar.toastOnReset"),hint:a("settings.menubar.toastOnResetHint"),control:t.jsx(x,{checked:r,onChange:()=>i("toastOnReset",!r),ariaLabel:a("settings.menubar.toastOnReset")})}),t.jsx(h,{label:a("settings.menubar.confettiOnReset"),hint:a("settings.menubar.confettiOnResetHint"),control:t.jsx(x,{checked:l,onChange:()=>i("confettiOnReset",!l),ariaLabel:a("settings.menubar.confettiOnReset")})}),c?t.jsx(h,{label:a("settings.menubar.launchAtLogin"),hint:a("settings.menubar.launchAtLoginHint"),control:t.jsx(x,{checked:o,onChange:()=>i("launchAtLogin",!o),ariaLabel:a("settings.menubar.launchAtLogin")})}):null,t.jsx(h,{label:a("settings.menubar.syncNow"),hint:a("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>s("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(Ne,{className:N("h-3.5 w-3.5",m&&"animate-spin"),"aria-hidden":!0}),m?a("settings.menubar.syncing"):a("settings.menubar.syncNow")]})}),t.jsx(h,{label:a("settings.menubar.updates"),hint:u||void 0,control:t.jsxs("button",{type:"button",onClick:()=>s("checkForUpdates"),disabled:b,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(Xe,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.menubar.checkUpdates")]})})]})}function Jt(e,n){function i(r){return r.replace(/^v/,"").split(".").map(Number)}const s=i(e),o=i(n);for(let r=0;r<Math.max(s.length,o.length);r++){const l=s[r]||0,c=o[r]||0;if(l<c)return!0;if(l>c)return!1}return!1}function Xt(){const{available:e,settings:n,runAction:i}=L(),s=e&&n?.version,[o,r]=P.useState(!1),[l,c]=P.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:u}=F(),b="0.87.13",m=async()=>{r(!0);try{const p=await fetch("https://api.github.com/repos/xiufengsun/TokenTracker/releases/latest");if(!p.ok)throw new Error("Failed to fetch");const j=await p.json(),w=j.tag_name;Jt(b,w)?c({open:!0,latestVersion:w,htmlUrl:j.html_url}):T({title:a("settings.menubar.updates.upToDate")})}catch(p){console.error("Check updates failed:",p),T({title:a("settings.menubar.updates.failed")})}finally{r(!1)}},y=a("settings.menubar.updates.modalTitle"),v=a("settings.menubar.updates.modalDescription",{version:l.latestVersion}),g=a("settings.menubar.updates.modalConfirm"),f=a("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:[s?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:a("settings.menubar.updates.footerCombined",{barVersion:n.version,coreVersion:b})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>i("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:a("settings.menubar.updates.footerCore",{version:b})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:m,disabled:o,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:o?a("settings.menubar.updates.checking"):a("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Se,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(Ce,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.footer.statusPage")]})]}),t.jsx(Qe,{open:l.open,title:y,description:v,confirmLabel:g,cancelLabel:f,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),c(p=>({...p,open:!1}))},onCancel:()=>c(p=>({...p,open:!1}))})]})}const k={APPEARANCE:"appearance",NATIVE_APP:"native-app",ACCOUNT:"account",LIMITS:"limits",LABS:"labs"};function en({prefs:e}){return t.jsx(O,{options:[{value:R.USED,label:a("limits.settings.display_mode_used")},{value:R.REMAINING,label:a("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function An(){const e=Ue(),{available:n,settings:i,setSetting:s}=L(),o=i?.toastOnReset!==!1,r=i?.confettiOnReset!==!1,[l,c]=we(),u=l.get("section"),m=Object.values(k).includes(u)&&(u!==k.NATIVE_APP||n)?u:k.APPEARANCE,y=g=>{const f=new URLSearchParams(l);g===k.APPEARANCE?f.delete("section"):f.set("section",g),c(f,{replace:!0})},v=[{id:k.APPEARANCE,label:a("settings.section.appearance"),Icon:ct,content:t.jsx(Wt,{})},...n?[{id:k.NATIVE_APP,label:a("settings.section.menubar"),Icon:B,content:t.jsx(Qt,{})}]:[],{id:k.ACCOUNT,label:a("settings.section.account"),Icon:dt,content:t.jsx(Rt,{})},{id:k.LIMITS,label:a("settings.section.limits"),Icon:Le,content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs(S,{title:a("settings.section.limits"),children:[t.jsx(h,{label:a("limits.settings.display_mode_label"),control:t.jsx(en,{prefs:e})}),t.jsx(h,{label:a("settings.menubar.toastOnReset"),hint:a("settings.menubar.toastOnResetHint"),control:t.jsx(x,{checked:o,disabled:!n,onChange:()=>s("toastOnReset",!o),ariaLabel:a("settings.menubar.toastOnReset")})}),t.jsx(h,{label:a("settings.menubar.confettiOnReset"),hint:a("settings.menubar.confettiOnResetHint"),control:t.jsx(x,{checked:r,disabled:!n,onChange:()=>s("confettiOnReset",!r),ariaLabel:a("settings.menubar.confettiOnReset")})})]}),t.jsx(S,{title:a("settings.limits.providers"),children:t.jsx(bt,{prefs:e})})]})},{id:k.LABS,label:a("settings.section.labs"),Icon:tt,content:t.jsx(Yt,{})}];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.jsx("div",{className:"mb-7",children:t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("settings.page.title")})}),t.jsxs("div",{className:"grid min-w-0 gap-6 md:grid-cols-[12rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[13.5rem_minmax(0,1fr)]",children:[t.jsx("aside",{className:"min-w-0 border-b border-oai-gray-200 pb-3 dark:border-oai-gray-800 md:border-b-0 md:border-r md:pb-0 md:pr-5",children:t.jsx("nav",{"aria-label":a("settings.page.title"),className:"flex gap-0 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden md:sticky md:top-6 md:flex-col md:gap-1 md:overflow-visible",children:v.map(({id:g,label:f,Icon:p})=>{const j=m===g;return t.jsxs("button",{id:`settings-nav-${g}`,type:"button","aria-current":j?"page":void 0,"aria-controls":`settings-panel-${g}`,onClick:()=>y(g),className:N("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",j?"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(p,{className:N("h-4 w-4 shrink-0",j?"text-oai-black dark:text-white":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:f})]},g)})})}),t.jsxs("div",{className:"min-w-0",children:[v.map(({id:g,label:f,content:p})=>t.jsx("section",{id:`settings-panel-${g}`,"aria-labelledby":`settings-nav-${g}`,"aria-label":f,"data-settings-panel":g,hidden:m!==g,children:p},g)),t.jsx(Xt,{})]})]})]})})})}export{An as SettingsPage};