tokentracker-cli 0.96.0 → 0.96.2

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 (121) hide show
  1. package/README.de.md +2 -2
  2. package/README.ja.md +2 -2
  3. package/README.ko.md +2 -2
  4. package/README.md +4 -2
  5. package/README.zh-CN.md +3 -3
  6. package/dashboard/dist/assets/{AchievementBadge-Bb2ljquW.js → AchievementBadge-CgEitoX1.js} +1 -1
  7. package/dashboard/dist/assets/{AchievementsPage-ByUP2x8a.js → AchievementsPage-dnnea0JH.js} +2 -2
  8. package/dashboard/dist/assets/{AchievementsSection-_L6sCLTw.js → AchievementsSection-CJqG0UP7.js} +1 -1
  9. package/dashboard/dist/assets/{BadgeDetailModal-B9n_-45B.js → BadgeDetailModal-BLV6SJoI.js} +1 -1
  10. package/dashboard/dist/assets/{BotAnimated-lWmg-aZg.js → BotAnimated-Cm78yEbz.js} +1 -1
  11. package/dashboard/dist/assets/{Card-aSp259T0.js → Card-IPGSYT6O.js} +1 -1
  12. package/dashboard/dist/assets/{ClawdAnimated-Cy-XaTXW.js → ClawdAnimated-04w1U1sm.js} +2 -2
  13. package/dashboard/dist/assets/{CommandPalette-CNwtKCUm.js → CommandPalette-gSSa1V_s.js} +1 -1
  14. package/dashboard/dist/assets/{CommunityStatsModal-DJSezaPV.js → CommunityStatsModal-CICwUz14.js} +1 -1
  15. package/dashboard/dist/assets/{ConfirmModal-CVjmhZd6.js → ConfirmModal-DaWC0cY7.js} +1 -1
  16. package/dashboard/dist/assets/{Controls-BIj6yVxE.js → Controls-BDihA03F.js} +1 -1
  17. package/dashboard/dist/assets/DashboardPage-hV7wncKF.js +1 -0
  18. package/dashboard/dist/assets/{DevicePage-ptsI2fZc.js → DevicePage-BPpo_eiY.js} +1 -1
  19. package/dashboard/dist/assets/{DialogClose-D1pLoZ56.js → DialogClose-C_dF-r3s.js} +1 -1
  20. package/dashboard/dist/assets/DialogDescription-GClOSCaE.js +1 -0
  21. package/dashboard/dist/assets/{DialogTitle-DfSBUjWf.js → DialogTitle-Buh_5688.js} +1 -1
  22. package/dashboard/dist/assets/{FadeIn-DBn4L_BV.js → FadeIn-DmI9PRLa.js} +1 -1
  23. package/dashboard/dist/assets/{HeaderGithubStar-EJLBwEqp.js → HeaderGithubStar-CBO4cY7i.js} +1 -1
  24. package/dashboard/dist/assets/{HoverTooltip-DaSrZhYd.js → HoverTooltip-CPFGhi9K.js} +1 -1
  25. package/dashboard/dist/assets/{IpCheckPage-diQTVaYt.js → IpCheckPage-Do7w_6z6.js} +1 -1
  26. package/dashboard/dist/assets/{LandingPage-BqCxjwar.js → LandingPage-at_Ti1ZE.js} +2 -2
  27. package/dashboard/dist/assets/{LeaderboardAvatar-CQImCsPN.js → LeaderboardAvatar-BH1cnKPp.js} +1 -1
  28. package/dashboard/dist/assets/{LeaderboardPage-D2ZDUi_O.js → LeaderboardPage-Cd30aXwL.js} +2 -2
  29. package/dashboard/dist/assets/{LeaderboardProfileModal-DHvADX1d.js → LeaderboardProfileModal-CVsti_HN.js} +3 -3
  30. package/dashboard/dist/assets/{LeaderboardProfilePage-CJsedB28.js → LeaderboardProfilePage-BfSpDM9e.js} +1 -1
  31. package/dashboard/dist/assets/LimitsPage-_-BadDAj.js +8 -0
  32. package/dashboard/dist/assets/{LocalOnlyNotice-Cmnvu9tI.js → LocalOnlyNotice-9-vRgsdn.js} +1 -1
  33. package/dashboard/dist/assets/{LoginCard-BQmKkD7X.js → LoginCard-DM_ZdFNl.js} +1 -1
  34. package/dashboard/dist/assets/{LoginModal-2oPROePZ.js → LoginModal-BaNMznwh.js} +1 -1
  35. package/dashboard/dist/assets/{LoginPage-aqdUJoQK.js → LoginPage-BMMthUf4.js} +1 -1
  36. package/dashboard/dist/assets/{PetPage-Bn3p_o5r.js → PetPage-Iq8Hswai.js} +1 -1
  37. package/dashboard/dist/assets/{PopoverPopup-DXD_YdiB.js → PopoverPopup-DXr3JxVV.js} +1 -1
  38. package/dashboard/dist/assets/{ProviderIcon-BZZ45-gY.js → ProviderIcon-sb2keSY2.js} +1 -1
  39. package/dashboard/dist/assets/{ResetPasswordPage-Bn5ITiHQ.js → ResetPasswordPage-Ca4SULSV.js} +1 -1
  40. package/dashboard/dist/assets/{SegmentedControl-hGXboQZy.js → SegmentedControl-Bbsn-qvZ.js} +1 -1
  41. package/dashboard/dist/assets/{Select-BP8aVRZ1.js → Select-vD-yj-qa.js} +1 -1
  42. package/dashboard/dist/assets/{SelectItemText-Odx47kND.js → SelectItemText-CRtFEuvg.js} +1 -1
  43. package/dashboard/dist/assets/{ServiceStatusPage-DUueam0N.js → ServiceStatusPage-BPS8KJ3a.js} +1 -1
  44. package/dashboard/dist/assets/{SessionsPage-BA9IFqQ1.js → SessionsPage-C1yt3TMZ.js} +1 -1
  45. package/dashboard/dist/assets/SettingsPage-CWVHrMer.js +2 -0
  46. package/dashboard/dist/assets/{SkillsPage-Ds2vH_PG.js → SkillsPage-DGWEH1xm.js} +1 -1
  47. package/dashboard/dist/assets/{TokenGalaxy-CWBR4jnB.js → TokenGalaxy-DKvbJbnv.js} +1 -1
  48. package/dashboard/dist/assets/{ToolbarRootContext-Bmg56vYz.js → ToolbarRootContext-D8yov1dW.js} +1 -1
  49. package/dashboard/dist/assets/{TrendMonitor-BQzcllvg.js → TrendMonitor-YF5C_-L1.js} +1 -1
  50. package/dashboard/dist/assets/{WidgetsPage-Bu3tHDjO.js → WidgetsPage-BKV3DgXg.js} +1 -1
  51. package/dashboard/dist/assets/{WrappedPage-BrAMJhgy.js → WrappedPage-s4IRoLf7.js} +1 -1
  52. package/dashboard/dist/assets/__vite-browser-external-CvMMIjhi.css +1 -0
  53. package/dashboard/dist/assets/__vite-browser-external-_LUatzwU.js +45 -0
  54. package/dashboard/dist/assets/{agent-logos-B8lT-HcI.js → agent-logos-Hbt-wyl2.js} +1 -1
  55. package/dashboard/dist/assets/{arrow-up-right-rpBCOTg2.js → arrow-up-right-KeIpKlw3.js} +1 -1
  56. package/dashboard/dist/assets/{check-DIKw7TYH.js → check-_QKyY1v_.js} +1 -1
  57. package/dashboard/dist/assets/{composite-_NeXO0lv.js → composite-BidfcMeb.js} +1 -1
  58. package/dashboard/dist/assets/{copy-CsfAtL7P.js → copy-DpLM3QMD.js} +1 -1
  59. package/dashboard/dist/assets/{download-DM1W9pIW.js → download-C4NX-JnW.js} +1 -1
  60. package/dashboard/dist/assets/{external-link-CwbuMbeQ.js → external-link-CG-7FcOF.js} +1 -1
  61. package/dashboard/dist/assets/{flame-DcYbLdhE.js → flame-CkWid7Ji.js} +1 -1
  62. package/dashboard/dist/assets/{format-tokens-CEvr3dNy.js → format-tokens-CbwWhioZ.js} +1 -1
  63. package/dashboard/dist/assets/{icons-DaGMVsJ5.js → icons-BZq17rU3.js} +1 -1
  64. package/dashboard/dist/assets/{index-ChZkJjpk.js → index-CR9tDiiC.js} +1 -1
  65. package/dashboard/dist/assets/{index-BVVLPj3N.js → index-CSwEiUn4.js} +1 -1
  66. package/dashboard/dist/assets/{index-T7OjmEuX.js → index-DDGLE0dz.js} +1 -1
  67. package/dashboard/dist/assets/{info-CAjN3dX4.js → info-mkeRjzqc.js} +1 -1
  68. package/dashboard/dist/assets/limits-providers-DRkcWQup.js +1 -0
  69. package/dashboard/dist/assets/{link-2-DaWH2Tyc.js → link-2-BjMw8csC.js} +1 -1
  70. package/dashboard/dist/assets/{loader-circle-CnF8qPi1.js → loader-circle-cGWOJnWn.js} +1 -1
  71. package/dashboard/dist/assets/{maximize-2-B-2Pnj6g.js → maximize-2-Cg_S73tD.js} +1 -1
  72. package/dashboard/dist/assets/{modifiers.esm-BoDOvUKl.js → modifiers.esm-DNxTWxId.js} +1 -1
  73. package/dashboard/dist/assets/{monitor-smartphone-DDgwxG_E.js → monitor-smartphone-BvE9Tt2U.js} +1 -1
  74. package/dashboard/dist/assets/{plus-DIc1YUWB.js → plus-BC2wdPRr.js} +1 -1
  75. package/dashboard/dist/assets/{provider-display-yeNsVCO_.js → provider-display-B7GggHQy.js} +1 -1
  76. package/dashboard/dist/assets/{react-DZqS6YTX.js → react-D0kcslTz.js} +1 -1
  77. package/dashboard/dist/assets/{search-D6tEppYJ.js → search-BuBNF3E3.js} +1 -1
  78. package/dashboard/dist/assets/{skills-api-vsA1rc1Z.js → skills-api-DxAN5pNx.js} +1 -1
  79. package/dashboard/dist/assets/{sortable.esm-DDCnS1HI.js → sortable.esm-DoqMcEX-.js} +1 -1
  80. package/dashboard/dist/assets/{store-Crne4DqF.js → store-Cg1HeUFM.js} +1 -1
  81. package/dashboard/dist/assets/{terminal-Ca7dkLMF.js → terminal-COWFUJdU.js} +1 -1
  82. package/dashboard/dist/assets/{trash-2-CjEAS5ic.js → trash-2-Cqjki3RI.js} +1 -1
  83. package/dashboard/dist/assets/{use-community-stats-BHx2YxyK.js → use-community-stats-DsrlOPDM.js} +1 -1
  84. package/dashboard/dist/assets/{use-latest-request-guard-BLGbXQdf.js → use-latest-request-guard-ryRFL2gx.js} +1 -1
  85. package/dashboard/dist/assets/{use-limits-display-prefs-DBkAp6ob.js → use-limits-display-prefs-DkSuu12m.js} +1 -1
  86. package/dashboard/dist/assets/{use-ordered-list-BTfW5M9u.js → use-ordered-list-D-Q86R1b.js} +1 -1
  87. package/dashboard/dist/assets/use-reduced-motion-D7NNqavo.js +1 -0
  88. package/dashboard/dist/assets/{use-session-efficiency-pref-DBmd-MqH.js → use-session-efficiency-pref-CrNz45y7.js} +1 -1
  89. package/dashboard/dist/assets/{use-transform-Bp5XrwaQ.js → use-transform-CoGM21px.js} +1 -1
  90. package/dashboard/dist/assets/{use-usage-limits-BmqRcyhH.js → use-usage-limits-C_6L1sO5.js} +1 -1
  91. package/dashboard/dist/assets/{useCurrency-B0YsRDj-.js → useCurrency-CgCfDktb.js} +1 -1
  92. package/dashboard/dist/assets/{useTokenFormat-PP3D0Ket.js → useTokenFormat-QKtzCKTL.js} +1 -1
  93. package/dashboard/dist/assets/{zap-BVOm1aBH.js → zap-CTIobzgU.js} +1 -1
  94. package/dashboard/dist/brand-logos/commandcode.svg +1 -0
  95. package/dashboard/dist/index.html +5 -5
  96. package/dashboard/dist/ip-check.html +2 -2
  97. package/dashboard/dist/leaderboard.html +2 -2
  98. package/dashboard/dist/share.html +2 -2
  99. package/package.json +1 -1
  100. package/src/commands/status.js +4 -4
  101. package/src/commands/sync.js +5 -3
  102. package/src/lib/ark-agent-plan-limits.js +4 -3
  103. package/src/lib/ark-coding-plan-limits.js +6 -8
  104. package/src/lib/codex-rollout-parser.js +2 -2
  105. package/src/lib/command-runner.js +13 -0
  106. package/src/lib/commandcode-limits.js +317 -0
  107. package/src/lib/local-api.js +3 -0
  108. package/src/lib/pricing/curated-overrides.json +11 -0
  109. package/src/lib/pricing/index.js +6 -7
  110. package/src/lib/pricing/seed-snapshot.json +1 -1
  111. package/src/lib/rollout.js +183 -11
  112. package/src/lib/session-analytics.js +2 -2
  113. package/src/lib/usage-limits.js +153 -14
  114. package/dashboard/dist/assets/DashboardPage-BjYZLmqQ.js +0 -1
  115. package/dashboard/dist/assets/DialogDescription-KY7X94CG.js +0 -1
  116. package/dashboard/dist/assets/LimitsPage-CAwff24b.js +0 -6
  117. package/dashboard/dist/assets/SettingsPage-DLOHHB4f.js +0 -2
  118. package/dashboard/dist/assets/__vite-browser-external-4IGm4Djn.js +0 -45
  119. package/dashboard/dist/assets/__vite-browser-external-CCMdjCX2.css +0 -1
  120. package/dashboard/dist/assets/limits-providers-jn7Yln_V.js +0 -1
  121. package/dashboard/dist/assets/use-reduced-motion-D_kUnDs4.js +0 -1
@@ -1,6 +0,0 @@
1
- import{m as V,j as e,e as Ce,c as r,k as re,r as x,Q as Je,B as W,aw as Qe,d as C,h as Ze,J as ke,L as et,ax as tt,q as at,ac as rt}from"./__vite-browser-external-4IGm4Djn.js";import{m as ve}from"./react-DZqS6YTX.js";import{P as xe,c as it,r as ie,a as nt,u as st,b as ot,s as lt}from"./use-usage-limits-BmqRcyhH.js";import{L as j,u as ct}from"./use-limits-display-prefs-DBkAp6ob.js";import{C as Te}from"./Card-aSp259T0.js";import{F as dt}from"./FadeIn-DBn4L_BV.js";import{L as De,l as ee,a as Ee}from"./limits-providers-jn7Yln_V.js";import{P as Ie}from"./ProviderIcon-BZZ45-gY.js";import{H as ut}from"./HoverTooltip-DaSrZhYd.js";import{C as mt}from"./ConfirmModal-CVjmhZd6.js";import{I as je,L as xt}from"./LocalOnlyNotice-Cmnvu9tI.js";import{S as ce}from"./Select-BP8aVRZ1.js";import{P as pt}from"./plus-DIc1YUWB.js";import{P as gt,a as ht,b as ft,c as bt,d as yt}from"./PopoverPopup-DXD_YdiB.js";import{u as kt}from"./use-reduced-motion-D_kUnDs4.js";import"./use-latest-request-guard-BLGbXQdf.js";import"./DialogTitle-DfSBUjWf.js";import"./composite-_NeXO0lv.js";import"./store-Crne4DqF.js";import"./DialogDescription-KY7X94CG.js";import"./arrow-up-right-rpBCOTg2.js";import"./download-DM1W9pIW.js";import"./ToolbarRootContext-Bmg56vYz.js";import"./check-DIKw7TYH.js";import"./SelectItemText-Odx47kND.js";const vt=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]],jt=V("bell-off",vt);const wt=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Nt=V("bell",wt);const _t=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v3",key:"otl347"}],["path",{d:"M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338",key:"7hb8p4"}],["path",{d:"M3 9h5.859",key:"numkqi"}],["path",{d:"M8 2v3",key:"1ioesn"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],Re=V("calendar-clock",_t);const Mt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],Ae=V("clock",Mt);const Pt=[["path",{d:"M6 16c5 0 7-8 12-8a4 4 0 0 1 0 8c-5 0-7-8-12-8a4 4 0 1 0 0 8",key:"18ogeb"}]],Oe=V("infinity",Pt),St=[3,2,3,3,2,2,3];function R({className:t}){return e.jsx("div",{className:Ce("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function Ct(){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-3 w-12 shrink-0"}),e.jsx(R,{className:"flex-1 h-1.5 rounded-full min-w-0"}),e.jsx(R,{className:"h-3 w-[30px] shrink-0"}),e.jsx(R,{className:"h-3 w-6 shrink-0"})]})}function Tt({bars:t,index:a}){const i=a%3===0?"w-24":a%3===1?"w-20":"w-[4.5rem]";return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(R,{className:"h-[14px] w-[14px] rounded shrink-0"}),e.jsx(R,{className:Ce("h-4",i)})]}),Array.from({length:t},(s,n)=>e.jsx(Ct,{},n))]})}function Dt(){return e.jsx(Te,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(R,{className:"h-3.5 w-28"}),St.map((t,a)=>e.jsx(Tt,{bars:t,index:a},a))]})})}const pe=100;function we(t){const a=Date.parse(t);return Number.isFinite(a)?a:null}function Et(t){return Math.max(0,Math.min(pe,Math.round(t)))}function It(t){return new Intl.DateTimeFormat(re(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t))}function Rt(t,a,i){if(t==null||t>=a)return pe;const s=a-t,n=a-i;return Et(n/s*pe)}function At(t){const a=t.available_count;return a===null?null:Number.isInteger(a)&&a>=0?a:void 0}function Ot(t,{now:a}={}){if(!t||typeof t!="object")return null;const i=At(t);if(i===void 0)return null;const s=Array.isArray(t.credits)?t.credits:[],n=a instanceof Date?a.getTime():Number(a??Date.now()),o=[];for(const l of s){const c=we(l?.expires_at);if(c==null)continue;const d=o.length+1;o.push({key:`reset-${d}`,label:r("limits.codex_reset_bank.row_label",{index:d}),expiresAt:It(c),expiresMs:c,percent:Rt(we(l?.granted_at),c,n)})}return i===0?null:o.length>0?{kind:"rows",availableCount:i??o.length,rows:o}:i>0?{kind:"count_only",availableCount:i,rows:[]}:null}const z=864e5;function A(t,a){const i=new Date(t),s=i.getUTCDate(),n=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()+a,1,i.getUTCHours(),i.getUTCMinutes())),o=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,0)).getUTCDate();return n.setUTCDate(Math.min(s,o)),n.getTime()}function Fe(t,a){if(a==="weekly")return t-7*z;if(a==="yearly")return A(t,-12);const i=new Date(t),s=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),0)).getUTCDate(),n=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()-1,1,i.getUTCHours(),i.getUTCMinutes()));return n.setUTCDate(Math.min(i.getUTCDate(),s)),n.getTime()}function Le(t,a){return a==="weekly"?t+7*z:a==="yearly"?A(t,12):A(t,1)}function Ft(t){if(t.startedAt!=null){const a=new Date(t.startedAt).getTime();if(Number.isFinite(a))return a}return Fe(new Date(t.nextBillingAt).getTime(),t.cycle)}function Lt(t,a,i){if(t.startedAt!=null){const s=new Date(t.startedAt).getTime();if(Number.isFinite(s))return s}return Fe(i,a)}function Ht(t,a,i){if(a==="weekly"){const c=7*z,d=i<=t?0:Math.floor((i-t)/c);return{startMs:t+d*c,endMs:t+(d+1)*c}}const s=a==="yearly"?12:1,n=s*30.436875*z;let o=i<=t?0:Math.floor((i-t)/n);for(;o>0&&A(t,o*s)>i;)o-=1;let l=0;for(;A(t,(o+1)*s)<=i&&l<12e3;)o+=1,l+=1;return{startMs:A(t,o*s),endMs:A(t,(o+1)*s)}}function te(t,a){const i=new Date(t.nextBillingAt).getTime();if(!Number.isFinite(i))return null;const s=["weekly","monthly","yearly"].includes(t.cycle)?t.cycle:"monthly",n=Lt(t,s,i);if(!Number.isFinite(n))return null;let o,l,c=!1;t.autoRenew?{startMs:o,endMs:l}=Ht(n,s,a):t.startedAt!=null?(o=n,l=Le(n,s),c=l<=a):(o=n,l=i,c=l<=a);const d=Math.max(1,l-o),m=c?1:Math.max(0,Math.min(1,(a-o)/d));return{endMs:l,startMs:o,progress:m,cycleDays:Math.max(1,Math.round(d/z)),expired:c}}function He(t,a){const i=t-a;if(i<=0)return r("subscriptions.expired");const s=Math.ceil(i/6e4);if(s<60)return`${s}m`;const n=Math.floor(s/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function ge(t,a){const i=t-a;if(i<=0)return r("subscriptions.expired");const s=Math.floor(i/6e4),n=Math.floor(s/1440),o=Math.floor(s%1440/60),l=s%60;return r("subscriptions.countdown",{days:n,hours:o,minutes:l})}const $t="shrink-0 text-oai-black dark:text-oai-white";function Ut(t){const a=ie(t);if(!Number.isFinite(a))return null;const i=a-Date.now();if(i<=0)return r("shared.time.now");const s=Math.floor(i/6e4);if(s<60)return`${s}m`;const n=Math.floor(s/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function Bt(t,a){const i=a===j.REMAINING?100-t:t;return i>=90?"bg-red-500":i>=70?"bg-amber-500":"bg-emerald-500"}function ae(t,a="used_percent"){return t?a==="utilization"?t.utilization:t.used_percent:null}function ne(t,a="reset_at"){return t?a==="resets_at"?t.resets_at:t.reset_at:null}function de(t){const a=Math.max(0,Math.min(100,Number(t)||0)),i=Math.round(a);return a>0&&i===0?r("limits.bar.sub_one_percent"):String(i)}function Z(t,{useGrouping:a=!0,maximumFractionDigits:i}={}){const s=Number(t);return Number.isFinite(s)?new Intl.NumberFormat(void 0,{minimumFractionDigits:0,maximumFractionDigits:i??(s>=100?0:2),useGrouping:a}).format(s):null}function Gt(t){if(!t||typeof t!="object"||!(Number(t.limit_credits)>0))return null;const a={useGrouping:t.unit!=="calls"},i=Z(t.used_credits,a),s=Z(t.limit_credits,a),n=Z(t.remaining_credits,a);if(!i||!s||!n)return null;const o=t.unit==="calls"?"limits.qoder_calls.detail":"limits.codex_credits.detail";return r(o,{used:i,limit:s,remaining:n})}function Wt(t,a){return it({usedPercent:ae(t.window,t.pctField),windowSeconds:nt(t,t.window),resetMs:ie(ne(t.window,t.resetField)),mode:a})}function $e(t){return Number.isFinite(t)?new Intl.DateTimeFormat(re(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):null}function qt(t,a,i){const s=[Be(t,a,i)],n=ie(ne(t.window,t.resetField)),o=$e(n);o&&s.push(r(t.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:o}));const l=Gt(t.window);return l&&s.push(l),s.join(`
2
- `)}const Ue=ut;function zt({label:t,pct:a,reset:i,mode:s=j.USED,pacePercent:n=null,paceOver:o=!1,title:l=null}){const c=Math.max(0,Math.min(100,Number(a)||0)),d=s===j.REMAINING?100-c:c,m=Math.round(d),g=d>0&&m===0?Math.max(d,.35):d;let h=String(m);d>0&&m===0&&(h=r("limits.bar.sub_one_percent"));const b=n==null?null:Math.max(0,Math.min(100,n));return e.jsxs("div",{className:"group relative flex items-center gap-2",children:[e.jsx(Ue,{text:l}),e.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:t}),e.jsxs("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:[e.jsx("div",{className:`${Bt(d,s)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${g}%`,minWidth:d>0?"3px":0}}),b!=null&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute top-0 h-full bg-oai-gray-100 dark:bg-oai-gray-700/50",style:{left:`calc(${b}% - 3px)`,width:"6px"}}),e.jsx("div",{className:`absolute top-0 h-full ${o?"bg-red-500":"bg-emerald-500"}`,style:{left:`calc(${b}% - 1px)`,width:"2px"}})]})]}),e.jsxs("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-9 text-right shrink-0 whitespace-nowrap",children:[h,"%"]}),i&&e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500 w-6 text-right shrink-0",children:i})]})}function Be(t,a,i){const s=t.label??r(t.labelKey),n=i===j.REMAINING,o=d=>n?100-d:d;if(a.expectedPercent==null){const d=Math.max(0,Math.min(100,Number(ae(t.window,t.pctField))||0)),m=de(o(d));return n?r("limits.explain.remaining",{label:s,used:m}):r("limits.explain.used",{label:s,used:m})}if(a.paceOver){if(a.runsOutEta)return r("limits.explain.ahead_eta",{label:s,eta:a.runsOutEta});const d=de(o(a.projectedEnd??100));return r(n?"limits.explain.ahead_pct_remaining":"limits.explain.ahead_pct",{label:s,pct:d})}const l=Math.max(0,Math.min(100,Number(ae(t.window,t.pctField))||0)),c=de(o(a.projectedEnd??l));return r(n?"limits.explain.on_track_remaining":"limits.explain.on_track",{label:s,pct:c})}function Vt({pace:t}){return t.pacePercent!=null}function Yt({rows:t,mode:a,now:i=Date.now()}){if(t.length===0)return null;const s=a===j.REMAINING,n=t.some(Vt);return e.jsxs("div",{className:"mt-1 flex flex-col gap-1",children:[t.map(({spec:o,pace:l})=>{const c=$e(ie(ne(o.window,o.resetField)));return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-600 dark:text-oai-gray-300",children:[Be(o,l,a),c?e.jsxs("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:[" · ",r(o.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:c})]}):null]},o.key)}),n?e.jsx("div",{className:"mt-1 pt-1.5 border-t border-oai-gray-200/70 dark:border-oai-gray-700/50 text-[10.5px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",children:r(s?"limits.explain.body_remaining":"limits.explain.body")}):null]})}function q(t){if(!t)return null;const a=Date.now()-new Date(t).getTime();if(a<0)return null;const i=Math.floor(a/6e4);if(i<1)return r("shared.time.now");if(i<60)return r("shared.time.m_ago",{n:i});const s=Math.floor(i/60);if(s<24)return r("shared.time.h_ago",{n:s});const n=Math.floor(s/24);return r("shared.time.d_ago",{n})}const Ne={live:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-emerald-500",pulse:"bg-emerald-400"},stale:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-amber-500",pulse:"bg-amber-400"},cached:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-amber-500",pulse:"bg-amber-400"}},Kt={claude:"claude",codex:"codex"};function H({label:t,age:a=null,tone:i="live",tooltip:s=null}){const n=Ne[i]||Ne.live,o=i==="live";return e.jsxs("div",{className:"relative inline-flex items-center group cursor-help ml-1",onClick:l=>l.stopPropagation(),children:[e.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-semibold uppercase tracking-wider border leading-normal ${n.surface}`,children:[o?e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full ${n.pulse} opacity-75`}),e.jsx("span",{className:`relative inline-flex rounded-full h-1.5 w-1.5 ${n.dot}`})]}):e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${n.dot}`}),t,a?e.jsxs(e.Fragment,{children:[" · ",a]}):null]}),s?e.jsxs("span",{className:"pointer-events-none absolute left-1/2 bottom-full z-20 mb-2 -translate-x-1/2 w-48 rounded-md bg-oai-gray-900 dark:bg-oai-gray-800 px-2.5 py-1.5 text-[10px] font-normal text-white text-center opacity-0 scale-95 translate-y-1 group-hover:opacity-100 group-hover:scale-100 group-hover:translate-y-0 transition-all duration-200 cubic-bezier(0.16, 1, 0.3, 1) leading-normal shadow-lg origin-bottom border border-oai-gray-800 dark:border-oai-gray-700",children:[s,e.jsx("span",{className:"absolute left-1/2 top-full -translate-x-1/2 border-4 border-transparent border-t-oai-gray-900 dark:border-t-oai-gray-800"})]}):null]})}function Ge({name:t,providerId:a,children:i,expandable:s=!1,expanded:n=!1,onToggle:o,badge:l=null,rightAdornment:c=null}){const d=Ee(a),m=e.jsxs("div",{className:"flex items-center gap-1.5",children:[d?e.jsx(Ie,{provider:d,size:14,className:$t}):null,e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:t}),c?e.jsx("span",{className:"shrink-0",children:c}):null,l]});return s?e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":n,onClick:o,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),o?.())},className:"flex flex-col gap-1.5 -mx-1.5 px-1.5 py-1 rounded-lg cursor-pointer transition-colors hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/40 aria-expanded:bg-oai-gray-50 dark:aria-expanded:bg-oai-gray-800/40",children:[m,i]}):e.jsxs("div",{className:"flex flex-col gap-1.5",children:[m,i]})}function We({subscription:t}){const a=t.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),i=t.autoRenew?Oe:Ae;return e.jsx("span",{role:"img","aria-label":a,title:a,className:`inline-flex translate-y-px ${t.autoRenew?"text-oai-brand-600 dark:text-oai-brand-400":"text-blue-600 dark:text-blue-400"}`,children:e.jsx(i,{size:14,strokeWidth:2,"aria-hidden":!0})})}function qe({subscription:t,now:a,mode:i=j.USED}){const s=te(t,a);if(!s)return null;const{endMs:n,expired:o}=s,l=!o&&n-a<=3*864e5,c=o?100:s.progress*100,d=i===j.REMAINING?100-c:c,m=o?100:Math.max(0,Math.min(100,d)),g=Math.round(m),h=m>0&&g===0?r("limits.bar.sub_one_percent"):`${g}%`;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:r("subscriptions.inline.label")}),e.jsx("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:e.jsx("div",{className:`${o?"bg-red-500":l?"bg-amber-500":"bg-blue-500"} rounded-full h-full block motion-safe:transition-[width] motion-safe:duration-500 ease-out motion-reduce:transition-none`,style:{width:`${m}%`,minWidth:m>0?"3px":0}})}),e.jsx("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-9 text-right shrink-0 whitespace-nowrap",children:h}),e.jsx("span",{className:`text-[10px] tabular-nums shrink-0 whitespace-nowrap w-6 text-right ${o?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:He(n,a)})]})}function ze({subscription:t,now:a}){const i=te(t,a);if(!i)return null;const s=new Intl.DateTimeFormat(re(),{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:r("subscriptions.inline.label")}),e.jsx("span",{className:"text-oai-gray-300 dark:text-oai-gray-600",children:":"}),e.jsx("span",{children:t.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")}),e.jsx("span",{children:" "}),e.jsx("span",{className:"font-mono tabular-nums",children:s.format(new Date(i.endMs))}),e.jsx("span",{className:"text-oai-gray-300 dark:text-oai-gray-600",children:" · "}),e.jsx("span",{className:i.expired?"text-oai-error":void 0,children:ge(i.endMs,a)}),e.jsx("span",{className:"text-oai-gray-300 dark:text-oai-gray-600",children:" · "}),e.jsx("span",{children:t.autoRenew?r("subscriptions.status.auto_renew"):r("subscriptions.status.manual")})]})}const Xt=De;function O({children:t,tone:a="neutral"}){const i=a==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400";return e.jsx("div",{className:`text-[11px] leading-snug ${i}`,children:t})}function Jt({rows:t,mode:a,extra:i=null}){const s=t.length===0&&!i;return e.jsxs(e.Fragment,{children:[t.map(({spec:n,pace:o})=>e.jsx(zt,{label:n.label??r(n.labelKey),pct:ae(n.window,n.pctField),reset:Ut(ne(n.window,n.resetField)),mode:a,pacePercent:o.pacePercent,paceOver:o.paceOver,title:qt(n,o,a)},n.key)),s?e.jsx(O,{children:r("limits.status.no_data")}):null,i]})}function Qt(t){if(!Number.isFinite(t.expiresMs))return null;const a=Math.floor((t.expiresMs-Date.now())/864e5);return a<0?null:a===0?r("limits.reset_bank.hover_detail_today",{date:t.expiresAt}):r("limits.reset_bank.hover_detail",{date:t.expiresAt,days:a})}function Zt({row:t}){const a=Math.max(0,Math.min(100,Number(t.percent)||0));return e.jsxs("div",{className:"group relative flex items-center gap-2","data-reset-bank-row":"",children:[e.jsx(Ue,{text:Qt(t)}),e.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:t.label}),e.jsx("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:e.jsx("div",{className:"bg-oai-gray-400 dark:bg-oai-gray-500 rounded-full h-full transition-[width] duration-500 ease-out",style:{width:`${a}%`,minWidth:a>0?"3px":0}})}),e.jsx("span",{className:"text-[10px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500 w-[4.25rem] text-right shrink-0 whitespace-nowrap",children:t.expiresAt})]})}function ea({model:t}){const a=t.kind==="count_only"?r("limits.codex_reset_bank.count_only",{count:t.availableCount}):null;return e.jsxs("div",{className:"mt-1 flex flex-col gap-1","data-reset-bank-section":t.kind,children:[e.jsx("div",{className:"text-[10.5px] font-medium uppercase tracking-wide text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.codex_reset_bank.title")}),a?e.jsx("div",{className:"text-[11px] leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:a}):t.rows.map(i=>e.jsx(Zt,{row:i},i.key))]})}function Ve(t,a){if(t==="codex_meta"){const i=Ot(a.reset_credits);return i?e.jsx(ea,{model:i}):null}if(t==="kimi_parallel"&&a.parallel_limit)return e.jsx(O,{children:r("limits.label.kimi_parallel",{count:a.parallel_limit})});if(t==="kiro_credits"&&Number.isFinite(Number(a.tracked_credits))&&Number(a.tracked_credit_records)>0){const i=Z(a.tracked_credits,{maximumFractionDigits:2});return e.jsx(O,{children:r("limits.label.kiro_tracked_credits",{credits:i,count:Number(a.tracked_credit_records)})})}return t==="copilot_otel"&&!a.otel_has_files&&!a.otel_enabled?e.jsx(ra,{defaultDir:a.otel_default_dir}):null}function ta(t,a,i,s,n,o,l=null,c=null,d=Date.now()){const m=xe[t];if(!m)return null;const g=m.windows(a).filter(b=>b.window).map(b=>({spec:b,pace:Wt(b,s)})),h=Ve(m.extra,a);return e.jsxs(Ge,{name:i,providerId:t,expandable:g.length>0||!!c,expanded:n,onToggle:o,badge:l,rightAdornment:c?e.jsx(We,{subscription:c}):null,children:[e.jsx(Jt,{mode:s,rows:g,extra:h}),c?e.jsx(qe,{subscription:c,now:d,mode:s}):null,n?e.jsx(Yt,{rows:g,mode:s,now:d}):null,n&&c?e.jsx(ze,{subscription:c,now:d}):null]},t)}function ue(t,a,i,s,n=null,o=Date.now(),l=j.USED){const c=!!n;return e.jsxs(Ge,{name:ee(t),providerId:t,expandable:c,expanded:i,onToggle:s,rightAdornment:c?e.jsx(We,{subscription:n}):null,children:[a,c?e.jsx(qe,{subscription:n,now:o,mode:l}):null,c&&i?e.jsx("div",{className:"mt-1",children:e.jsx(ze,{subscription:n,now:o})}):null]},t)}function aa(t,a,i,s,n,o=null,l=Date.now()){if(!xe[t])return null;if(!a?.configured)return ue(t,e.jsxs(e.Fragment,{children:[e.jsx(O,{children:r("limits.status.not_connected")}),t==="opencodeGo"?e.jsx(_e,{}):null,t==="codingPlan"?e.jsx(Me,{}):null,t==="agentPlan"?e.jsx(Pe,{}):null]}),s,n,o,l,i);if(t==="opencodeGo"&&a.subscription_status==="inactive")return ue(t,e.jsx(O,{children:r("limits.opencodeGo.status.inactive")}),s,n,o,l,i);if(a.error)return ue(t,e.jsxs(e.Fragment,{children:[e.jsx(O,{tone:"error",children:r("shared.error.prefix",{error:a.error})}),t==="kiro"?Ve(xe.kiro.extra,a):null,t==="opencodeGo"?e.jsx(_e,{}):null,t==="codingPlan"?e.jsx(Me,{}):null,t==="agentPlan"?e.jsx(Pe,{}):null]}),s,n,o,l,i);const c=ee(t),d=a.plan_label?`${c} ${a.plan_label}`:c;let m=null;if(t==="antigravity")if(a.cached){const h=q(a.cached_at);m=e.jsx(H,{label:r("limits.label.antigravity_cached"),age:h,tone:"cached",tooltip:r("limits.tooltip.antigravity_cached")})}else m=e.jsx(H,{label:r("limits.label.antigravity_live"),tone:"live",tooltip:r("limits.tooltip.antigravity_live")});if((t==="qoder"||t==="qoderCn")&&a.cached&&(m=e.jsx(H,{label:r("limits.label.antigravity_cached"),age:q(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.qoder_cached")})),(t==="codingPlan"||t==="agentPlan")&&a.cached&&(m=e.jsx(H,{label:r("limits.label.antigravity_cached"),age:q(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.ark_cached")})),!m&&a.auth_action_required==="reauth"){const h=Kt[t];m=e.jsx(H,{label:r("limits.reauth.badge"),age:q(a.cached_at),tone:"stale",tooltip:h?r("limits.reauth.tooltip",{command:h}):null})}const g=a.provenance;return g?.stale&&!m&&(m=e.jsx(H,{label:r("limits.provenance.stale"),age:q(g.captured_at),tone:"stale",tooltip:r("limits.provenance.tooltip",{source:g.source,confidence:g.confidence})})),ta(t,a,d,i,s,n,m,o,l)}function ra({defaultDir:t}){const[a,i]=x.useState(!1),n=["export COPILOT_OTEL_ENABLED=true","export COPILOT_OTEL_EXPORTER_TYPE=file",`export COPILOT_OTEL_FILE_EXPORTER_PATH="${t||"$HOME/.copilot/otel"}/copilot-otel-$(date +%Y%m%d).jsonl"`].join(`
3
- `),o=async l=>{l.stopPropagation();try{await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1 rounded-md border border-amber-300/60 dark:border-amber-700/40 bg-amber-50/50 dark:bg-amber-900/10 px-2.5 py-2 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"font-medium text-oai-gray-700 dark:text-oai-gray-200",children:r("limits.copilot.otelHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug",children:r("limits.copilot.otelHint.body")}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-tight whitespace-pre",children:n}),e.jsx("button",{type:"button",onClick:o,className:"mt-1 inline-flex items-center gap-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 px-1.5 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:a?r("limits.copilot.otelHint.copied"):r("limits.copilot.otelHint.copy")})]})}function M({n:t,children:a}){return e.jsxs("li",{className:"flex gap-2.5",children:[e.jsx("span",{className:"mt-[1px] flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-oai-brand/15 text-[9px] font-semibold text-oai-brand",children:t}),e.jsx("div",{className:"min-w-0 flex-1 leading-snug",children:a})]})}function he(){return e.jsx("svg",{viewBox:"0 0 12 12","aria-hidden":"true",className:"h-2.5 w-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M4.5 2.75h4.75V7.5M9.25 2.75 3 9"})})}function _e(){const[t,a]=x.useState(!1),i=["read -r -s OPENCODE_GO_API_KEY","export OPENCODE_GO_API_KEY",'launchctl setenv OPENCODE_GO_API_KEY "$OPENCODE_GO_API_KEY"'].join(`
4
- `),s=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.opencodeGo.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.opencodeGo.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(M,{n:"1",children:[e.jsx("div",{children:r("limits.opencodeGo.setupHint.step1")}),e.jsxs("a",{href:"https://opencode.ai",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.opencodeGo.setupHint.cta"),e.jsx(he,{})]})]}),e.jsx(M,{n:"2",children:e.jsx("div",{children:r("limits.opencodeGo.setupHint.step2")})}),e.jsxs(M,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:r("limits.opencodeGo.setupHint.step3")}),e.jsx("button",{type:"button",onClick:s,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.opencodeGo.setupHint.copied"):r("limits.opencodeGo.setupHint.copy")})]}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.opencodeGo.setupHint.note_app")})]})]})]})}function Me(){const[t,a]=x.useState(!1),i=["npm install -g @volcengine/ark-cli","arkcli auth login volc-sso # browser SSO (recommended)","arkcli auth status # verify the session"].join(`
5
- `),s=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.codingPlan.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.codingPlan.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(M,{n:"1",children:[e.jsx("div",{children:r("limits.codingPlan.setupHint.step1")}),e.jsxs("a",{href:"https://www.volcengine.com/docs/82379/2536875",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.codingPlan.setupHint.cta"),e.jsx(he,{})]})]}),e.jsxs(M,{n:"2",children:[e.jsx("div",{children:r("limits.codingPlan.setupHint.step2")}),e.jsx("div",{className:"mt-0.5 text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.codingPlan.setupHint.step2_remote")})]}),e.jsxs(M,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:r("limits.codingPlan.setupHint.step3")}),e.jsx("button",{type:"button",onClick:s,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.codingPlan.setupHint.copied"):r("limits.codingPlan.setupHint.copy")})]}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.codingPlan.setupHint.note_app")})]})]})]})}function Pe(){const[t,a]=x.useState(!1),i=[r("limits.agentPlan.setupHint.snippet_install"),r("limits.agentPlan.setupHint.snippet_login"),r("limits.agentPlan.setupHint.snippet_status")].join(`
6
- `),s=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.agentPlan.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.agentPlan.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(M,{n:"1",children:[e.jsx("div",{children:r("limits.agentPlan.setupHint.step1")}),e.jsxs("a",{href:"https://www.volcengine.com/docs/82379/2536875",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.agentPlan.setupHint.cta"),e.jsx(he,{})]})]}),e.jsxs(M,{n:"2",children:[e.jsx("div",{children:r("limits.agentPlan.setupHint.step2")}),e.jsx("div",{className:"mt-0.5 text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.agentPlan.setupHint.step2_remote")})]}),e.jsxs(M,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:r("limits.agentPlan.setupHint.step3")}),e.jsx("button",{type:"button",onClick:s,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.agentPlan.setupHint.copied"):r("limits.agentPlan.setupHint.copy")})]}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.agentPlan.setupHint.note_app")})]})]})]})}function ia(t){const[a,i]=x.useState(0);return x.useLayoutEffect(()=>{const s=t.current;if(!s)return;const n=s.querySelectorAll("[data-limit-label]");let o=0,l=null;if(n.length>0)try{l=document.createElement("canvas").getContext("2d")}catch{l=null}if(l){const d=window.getComputedStyle(n[0]);l.font=`${d.fontStyle} ${d.fontWeight} ${d.fontSize} ${d.fontFamily}`;for(const m of n)o=Math.max(o,l.measureText(m.textContent).width)}const c=Math.ceil(o);i(d=>d===c?d:c)}),a}function na({claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:m,opencodeGo:g,qoder:h,qoderCn:b,codingPlan:N,agentPlan:T,order:w,visibility:k,displayMode:$,subscriptions:se=[],showSubscriptions:Y=!0}){const oe={claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:m,opencodeGo:g,qoder:h,qoderCn:b,codingPlan:N,agentPlan:T},F=x.useRef(null),K=ia(F),[be,P]=x.useState(null),[U,X]=x.useState(()=>Date.now()),D=Array.isArray(w)&&w.length>0?w:Xt,B=$===j.REMAINING?j.REMAINING:j.USED,le=B===j.REMAINING?r("limits.settings.display_mode_remaining"):r("limits.settings.display_mode_used");x.useEffect(()=>{const f=setInterval(()=>X(Date.now()),6e4);return()=>clearInterval(f)},[]);const E=new Map;if(Y)for(const f of se||[]){if(!f?.provider)continue;const _=new Date(f.nextBillingAt).getTime();if(!Number.isFinite(_))continue;const S=E.get(f.provider);if(!S){E.set(f.provider,f);continue}const G=new Date(S.nextBillingAt).getTime(),Q=_>U,I=G>U;(Q&&(!I||G>_)||!Q&&!I&&_>G)&&E.set(f.provider,f)}const J=D.filter(f=>!k||k[f]!==!1||E.has(f)).map(f=>aa(f,oe[f],B,be===f,()=>P(_=>_===f?null:f),E.get(f)||null,U)).filter(Boolean);return e.jsx(dt,{delay:.15,children:e.jsx(Te,{children:e.jsxs("div",{ref:F,className:"flex flex-col gap-3",style:K>0?{"--tt-limits-label-w":`${K}px`}:void 0,children:[e.jsxs("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:[r("limits.panel.title"),r("limits.panel.mode_separator"),le]}),J.length>0?J:e.jsx(O,{children:r("limits.status.all_hidden")})]})})})}async function Ye(t){const a=await t.json().catch(()=>null);if(!t.ok||a?.ok===!1)throw new Error(a?.error||`Subscription request failed with HTTP ${t.status}`);return a}async function sa(){const t=await fetch("/functions/tokentracker-subscription-manager",{headers:{Accept:"application/json"},cache:"no-store"}),a=await Ye(t);return Array.isArray(a.subscriptions)?a.subscriptions:[]}async function fe(t){const a=await Je();return Ye(await fetch("/functions/tokentracker-subscription-manager",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...a},cache:"no-store",body:JSON.stringify(t)}))}function oa(t){return fe({action:"create",subscription:t})}function la(t,a){return fe({action:"update",id:t,subscription:a})}function ca(t){return fe({action:"delete",id:t})}const me={plan:"",provider:"",cycle:"monthly",autoRenew:!0,startedAt:""};function da(t){const a=new Date(t);if(Number.isNaN(a.getTime()))return"";const i=s=>String(s).padStart(2,"0");return`${a.getFullYear()}-${i(a.getMonth()+1)}-${i(a.getDate())}T${i(a.getHours())}:${i(a.getMinutes())}`}function ua({subscriptions:t,onChanged:a}){const[i,s]=x.useState(!1),[n,o]=x.useState(null),[l,c]=x.useState(me),[d,m]=x.useState(!1),[g,h]=x.useState(!1),[b,N]=x.useState(!1),[T,w]=x.useState(!1),[k,$]=x.useState(null),[se,Y]=x.useState(!1),[oe,F]=x.useState(!1),[K,be]=x.useState(null),[P,U]=x.useState(()=>Date.now()),X=x.useRef(null),D=re(),B=x.useMemo(()=>new Intl.DateTimeFormat(D,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),[D]);x.useEffect(()=>{const u=setInterval(()=>U(Date.now()),6e4);return()=>clearInterval(u)},[]),x.useEffect(()=>{if(!i)return;const u=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;X.current?.scrollIntoView?.({behavior:u?"auto":"smooth",block:"nearest"})},[i,n]);const le=x.useMemo(()=>De.map(u=>{const v=(t||[]).some(y=>y.provider===u&&y.id!==n),p=ee(u);return{value:u,label:v?`${p} ${r("subscriptions.form.provider_taken_suffix")}`:p,disabled:v}}),[D,t,n]),E=x.useMemo(()=>[{value:"weekly",label:r("subscriptions.form.cycle_weekly")},{value:"monthly",label:r("subscriptions.form.cycle_monthly")},{value:"yearly",label:r("subscriptions.form.cycle_yearly")}],[D]),J=x.useMemo(()=>[{value:"true",label:r("subscriptions.form.auto_renew_on")},{value:"false",label:r("subscriptions.form.auto_renew_off")}],[D]),f=x.useCallback(()=>{c(me),o(null),h(!1),N(!1),w(!1),s(!0)},[]),_=x.useCallback(u=>{c({plan:u.plan||"",provider:u.provider||"",cycle:u.cycle||"monthly",autoRenew:u.autoRenew,startedAt:da(new Date(Ft(u)).toISOString())}),o(u.id),h(!1),N(!1),w(!1),s(!0)},[]),S=x.useCallback(()=>{s(!1),o(null),c(me),h(!1),N(!1),w(!1)},[]),G=x.useCallback(async u=>{if(u.preventDefault(),h(!1),!l.provider){N(!0);return}if((t||[]).some(L=>L.provider===l.provider&&L.id!==n)){w(!0);return}const p=new Date(l.startedAt).getTime();if(!Number.isFinite(p)){h(!0);return}const y={service:ee(l.provider),plan:l.plan,provider:l.provider||null,autoRenew:l.autoRenew,cycle:l.cycle,startedAt:p,nextBillingAt:Le(p,l.cycle)};m(!0);try{n?await la(n,y):await oa(y),S(),await a?.()}catch{h(!0)}finally{m(!1)}},[S,n,l,a,t]),Q=x.useCallback(async()=>{if(k){Y(!0),F(!1);try{await ca(k.id),k.id===n&&S(),$(null),await a?.()}catch{F(!0)}finally{Y(!1)}}},[S,n,a,k]),I=t||[],ye=()=>{const u=n?I.find(p=>p.id===n):null,v=u?te(u,P):null;return e.jsxs("form",{ref:X,onSubmit:G,className:"grid grid-cols-1 gap-3 px-3 py-3 text-left sm:grid-cols-2",children:[e.jsx("div",{className:"flex items-center justify-between sm:col-span-2",children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:n?r("subscriptions.edit"):r("subscriptions.add")})}),v?e.jsxs("div",{className:"sm:col-span-2 rounded-md bg-oai-gray-50 dark:bg-oai-gray-800/50 px-2.5 py-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:u.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:B.format(new Date(v.endMs))})," · ",e.jsx("span",{className:v.expired?"text-oai-error":void 0,children:ge(v.endMs,P)})]}):null,e.jsxs("div",{className:"flex flex-col sm:col-span-1",children:[e.jsx("label",{htmlFor:"subscription-provider",className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5",children:r("subscriptions.form.provider")}),e.jsx(ce,{id:"subscription-provider",value:l.provider,onValueChange:p=>c({...l,provider:String(p)}),options:le,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-1",children:e.jsx(je,{label:r("subscriptions.form.plan"),value:l.plan,maxLength:120,placeholder:r("subscriptions.form.plan_placeholder"),onChange:p=>c({...l,plan:p.target.value})})}),e.jsxs("div",{className:"flex flex-col sm:col-span-1",children:[e.jsx("label",{htmlFor:"subscription-cycle",className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5",children:r("subscriptions.form.cycle")}),e.jsx(ce,{id:"subscription-cycle",value:l.cycle,onValueChange:p=>c({...l,cycle:String(p)}),options:E,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsxs("div",{className:"flex flex-col sm:col-span-1",children:[e.jsx("label",{htmlFor:"subscription-auto-renew",className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5",children:r("subscriptions.form.auto_renew")}),e.jsx(ce,{id:"subscription-auto-renew",value:String(l.autoRenew),onValueChange:p=>c({...l,autoRenew:p==="true"}),options:J,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(je,{label:r("subscriptions.form.started_at"),type:"datetime-local",value:l.startedAt,required:!0,onChange:p=>c({...l,startedAt:p.target.value})})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 sm:col-span-2",children:[n?e.jsx(W,{type:"button",variant:"secondary",size:"sm",onClick:()=>{const p=I.find(y=>y.id===n);p&&$(p)},className:"!text-red-600 dark:!text-red-400 mr-auto",children:r("subscriptions.delete")}):null,b?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_required")}):null,T?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_taken")}):null,g?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.error")}):null,e.jsx(W,{type:"button",variant:"secondary",size:"sm",onClick:S,children:r("shared.action.cancel")}),e.jsx(W,{type:"submit",size:"sm",disabled:d,children:r("subscriptions.save")})]})]})};return e.jsxs("div",{className:"flex max-h-[min(80vh,42rem)] w-[min(92vw,32rem)] flex-col gap-3 overflow-y-auto rounded-xl border border-oai-gray-200 bg-white p-4 shadow-lg dark:border-oai-gray-700 dark:bg-oai-gray-900",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"min-w-0",children:e.jsx("span",{className:"block truncate text-sm font-semibold text-oai-black dark:text-white",children:r("limits.page.openSubscriptions")})}),e.jsxs(W,{type:"button",size:"sm",onClick:f,className:"shrink-0 gap-1.5",children:[e.jsx(pt,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:r("subscriptions.add")})]})]}),I.length===0&&!(i&&!n)?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-1 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center dark:border-oai-gray-700",children:[e.jsx(Re,{className:"h-6 w-6 text-oai-gray-300 dark:text-oai-gray-600 mb-2","aria-hidden":!0}),e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:r("subscriptions.empty.title")}),e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r("subscriptions.empty.body")})]}):e.jsxs("ul",{className:"flex flex-col gap-1.5",children:[I.map(u=>{const v=te(u,P);if(!v)return null;const{endMs:p,expired:y}=v,L=y?100:v.progress*100,Ke=!y&&p-P<=3*864e5,Xe=K===u.id;return e.jsxs("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:[e.jsxs("button",{type:"button",onClick:()=>_(u),"aria-label":`${r("subscriptions.edit")} ${u.service}`,"aria-expanded":n===u.id,className:"w-full flex flex-col gap-1.5 px-3 py-2.5 text-left cursor-pointer hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/40 rounded-lg transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[e.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Ie,{provider:Ee(u.provider)||"OTHER",size:14}),e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-white truncate",children:u.service}),e.jsx("span",{role:"img","aria-label":u.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),title:u.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),className:`inline-flex shrink-0 translate-y-px ${u.autoRenew?"text-oai-brand-600 dark:text-oai-brand-400":"text-blue-600 dark:text-blue-400"}`,children:u.autoRenew?e.jsx(Oe,{size:14,strokeWidth:2,"aria-hidden":!0}):e.jsx(Ae,{size:14,strokeWidth:2,"aria-hidden":!0})}),u.plan?e.jsx("span",{className:"text-xs rounded-full border border-oai-gray-200 dark:border-oai-gray-700 px-2 py-0.5 text-oai-gray-500 dark:text-oai-gray-400 shrink-0",children:u.plan}):null]}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0",children:r("subscriptions.inline.label")}),e.jsx("span",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1 overflow-hidden",children:e.jsx("span",{className:`${y?"bg-red-500":Ke?"bg-amber-500":"bg-blue-500"} rounded-full h-full block transition-[width] duration-500 ease-out`,style:{width:`${L}%`,minWidth:L>0?"3px":0}})}),e.jsx("span",{className:`text-[10px] tabular-nums shrink-0 ${y?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:He(p,P)})]})]}),n===u.id?e.jsx("div",{className:"border-t border-oai-gray-100 dark:border-oai-gray-800",children:ye()}):null,n!==u.id&&Xe?e.jsxs("div",{className:"px-3 pb-3 flex flex-col gap-2 border-t border-oai-gray-100 dark:border-oai-gray-800",children:[e.jsxs("p",{className:"pt-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:u.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:B.format(new Date(p))})," · ",e.jsx("span",{className:y?"text-oai-error":void 0,children:ge(p,P)})," · ",e.jsx("span",{children:u.autoRenew?r("subscriptions.status.auto_renew"):r("subscriptions.status.manual")})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(W,{type:"button",variant:"secondary",size:"sm",onClick:()=>_(u),children:r("subscriptions.edit")})})]}):null]},u.id)}),i&&!n?e.jsx("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:ye()}):null]}),e.jsx(mt,{open:!!k,title:r("subscriptions.confirm_delete_title"),description:k?.service||"",error:oe?r("subscriptions.delete_error"):null,confirmLabel:r("subscriptions.delete"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:se,onCancel:()=>{$(null),F(!1)},onConfirm:Q})]})}const Se=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),ma="x-apple.systempreferences:com.apple.preference.notifications";function xa(){const t=kt(),a=at(),i=r("limits.alert.blocked"),s=a?ve.button:ve.div;return e.jsxs(s,{type:a?"button":void 0,onClick:a?()=>rt({type:"action",name:"openURL",value:ma}):void 0,initial:t?!1:{opacity:0,x:14,scale:.9},animate:{opacity:1,x:0,scale:1},transition:{type:"spring",stiffness:320,damping:18},title:i,className:`relative hidden sm:inline-flex min-w-0 max-w-[360px] items-center gap-1.5 rounded-full border border-amber-300/70 bg-amber-50 px-3 py-1.5 text-xs text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-300 ${a?"cursor-pointer transition-colors hover:bg-amber-100 dark:hover:bg-amber-500/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/60":""}`,children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5 shrink-0",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-amber-500"})]}),e.jsx("span",{className:"truncate",children:i}),e.jsx("span",{"aria-hidden":!0,className:"absolute left-full top-1/2 -translate-y-1/2 border-[5px] border-transparent border-l-amber-300/80 dark:border-l-amber-500/40"})]})}function Ha(){const t=Qe(),{data:a,error:i,isLoading:s}=st(t?{initialRefresh:!0,initialState:t,publishToPreloadCache:!0}:{initialRefresh:!0,publishToPreloadCache:!0}),n=ct(),o=ot(),[l,c]=C.useState([]),[d,m]=C.useState(!1),[g,h]=C.useState(!1),[b]=Ze(),N=C.useRef(0),T=C.useCallback(async()=>{if(!Se&&!ke())return;const w=++N.current;try{const k=await sa();if(w!==N.current)return;c(k),m(!1)}catch{if(w!==N.current)return;m(!0)}},[]);return C.useEffect(()=>{T()},[T]),C.useEffect(()=>{b.get("openSubscriptions")==="1"&&h(!0)},[b]),C.useEffect(()=>{o.enabled&&a&&lt(a)},[o.enabled,a]),!Se&&!ke()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(xt,{})}):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:"flex flex-row items-start justify-between gap-4 mb-8",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:r("nav.limits")}),e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:r("limits.page.subtitle")})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[o.enabled&&o.permissionBlocked?e.jsx(xa,{}):null,e.jsxs(gt,{open:g,onOpenChange:h,children:[e.jsx(ht,{"aria-label":r("limits.page.openSubscriptions"),title:r("limits.page.openSubscriptions"),className:"shrink-0 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",children:e.jsx(Re,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(ft,{children:e.jsx(bt,{side:"bottom",align:"end",sideOffset:8,className:"z-50",children:e.jsx(yt,{children:e.jsx(ua,{subscriptions:l,onChanged:T})})})})]}),e.jsx("button",{type:"button",onClick:()=>{o.setEnabled(!o.enabled)},"aria-label":o.enabled?r("limits.alert.disable"):r("limits.alert.enable"),title:o.enabled?r("limits.alert.disable"):r("limits.alert.enable"),className:`inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 ${o.enabled&&o.permissionBlocked?"text-amber-600 dark:text-amber-400":"text-oai-gray-600 dark:text-oai-gray-400 hover:text-oai-black dark:hover:text-white"}`,children:o.enabled?e.jsx(Nt,{className:"h-4 w-4","aria-hidden":!0}):e.jsx(jt,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(et,{to:"/settings?section=limits","aria-label":r("limits.page.openSettings"),title:r("limits.page.openSettings"),className:"shrink-0 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 no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:e.jsx(tt,{className:"h-4 w-4","aria-hidden":!0})})]})]}),s?e.jsx(Dt,{}):e.jsxs(e.Fragment,{children:[i?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:r("shared.error.prefix",{error:i})}):null,d?e.jsx("p",{className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("subscriptions.load_error")}):null,e.jsx(na,{claude:a?.claude,codex:a?.codex,cursor:a?.cursor,gemini:a?.gemini,kimi:a?.kimi,kiro:a?.kiro,grok:a?.grok,antigravity:a?.antigravity,copilot:a?.copilot,zcode:a?.zcode,opencodeGo:a?.opencodeGo,qoder:a?.qoder,qoderCn:a?.qoderCn,codingPlan:a?.codingPlan,agentPlan:a?.agentPlan,order:n.order,visibility:n.visibility,displayMode:n.displayMode,subscriptions:l,showSubscriptions:n.showSubscriptions!==!1})]})]})})})}export{Ha as LimitsPage};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-4IGm4Djn.js","assets/__vite-browser-external-CCMdjCX2.css"])))=>i.map(i=>d[i]);
2
- import{m as O,j as t,e as L,c as n,a as ce,r as g,ao as ue,aU as de,au as ge,av as pe,a8 as W,aV as he,aW as me,u as be,d as R,a0 as fe,M as Z,n as M,aX as xe,aY as ye,U as Y,aZ as ve,x as ke,a_ as je,a$ as Se,b0 as we,b1 as Ne,b2 as Ce,b3 as Ee,b4 as Ae,L as Le,R as Oe,b5 as Pe,b6 as _e,a5 as H,_ as Te,h as Ie,f as Ge,b7 as Re,b8 as Ue,ax as De}from"./__vite-browser-external-4IGm4Djn.js";import{a as Me,b as F,s as He,K as Fe,P as $e,D as Be,c as Ve,S as Ke,v as ze,u as qe,C as We}from"./sortable.esm-DDCnS1HI.js";import{a as Ze}from"./modifiers.esm-BoDOvUKl.js";import{u as Ye,L as $}from"./use-limits-display-prefs-DBkAp6ob.js";import{P as Je}from"./ProviderIcon-BZZ45-gY.js";import{a as B,l as V}from"./limits-providers-jn7Yln_V.js";import{m as J}from"./react-DZqS6YTX.js";import{a as A,T as j,b,S as _,u as T}from"./Controls-BIj6yVxE.js";import{P as Xe,u as Qe,a as et}from"./use-session-efficiency-pref-DBmd-MqH.js";import{C as tt}from"./check-DIKw7TYH.js";import{C as nt}from"./copy-CsfAtL7P.js";import{A as X}from"./index-ChZkJjpk.js";import{u as at}from"./useCurrency-B0YsRDj-.js";import{u as st}from"./useTokenFormat-PP3D0Ket.js";import{S as U}from"./Select-BP8aVRZ1.js";import{I as it}from"./info-CAjN3dX4.js";import{C as ot}from"./ConfirmModal-CVjmhZd6.js";import{A as rt}from"./arrow-up-right-rpBCOTg2.js";import{D as lt}from"./download-DM1W9pIW.js";import{i as ct}from"./host-mode-Bc_iTzHk.js";import"./Card-aSp259T0.js";import"./ToolbarRootContext-Bmg56vYz.js";import"./composite-_NeXO0lv.js";import"./SelectItemText-Odx47kND.js";import"./DialogTitle-DfSBUjWf.js";import"./store-Crne4DqF.js";import"./DialogDescription-KY7X94CG.js";const ut=[["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"}]],dt=O("flask-conical",ut);const gt=[["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"}]],pt=O("grip-vertical",gt);const ht=[["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"}]],mt=O("languages",ht);const bt=[["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"}]],ft=O("log-out",bt);const xt=[["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"}]],yt=O("palette",xt);const vt=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],kt=O("user-round",vt),jt="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function St({checked:e,onChange:a,ariaLabel:s}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,onClick:a,className:L("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:L("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function wt({id:e,visible:a,onToggle:s}){const{attributes:i,listeners:o,setNodeRef:r,transform:l,transition:c,isDragging:u}=qe({id:e}),p={transform:We.Transform.toString(l)||void 0,transition:c,zIndex:u?20:void 0};return t.jsxs("div",{ref:r,style:p,className:L("flex items-center gap-3 py-2 rounded-md select-none touch-none","cursor-grab active:cursor-grabbing","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",u&&"relative bg-oai-gray-100 dark:bg-oai-gray-800"),...i,...o,children:[t.jsx(pt,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),B(e)?t.jsx(Je,{provider:B(e),size:18,className:L("pointer-events-none",jt)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200",children:V(e)}),t.jsx("div",{onPointerDown:h=>h.stopPropagation(),children:t.jsx(St,{checked:a,onChange:s,ariaLabel:`${n("limits.settings.toggle_visible")}: ${V(e)}`})})]})}function Nt({prefs:e}){const{order:a,visibility:s,toggle:i,moveToward:o}=e,r=Me(F($e,{activationConstraint:{distance:6}}),F(Fe,{coordinateGetter:He})),l=({active:c,over:u})=>{u&&c.id!==u.id&&o(c.id,u.id)};return t.jsx(Be,{sensors:r,collisionDetection:Ve,modifiers:[Ze],onDragEnd:l,children:t.jsx(Ke,{items:a,strategy:ze,children:t.jsx("div",{className:"flex flex-col",children:a.map(c=>t.jsx(wt,{id:c,visible:s[c]!==!1,onToggle:()=>i(c)},c))})})})}function Ct(e){if(!e||typeof e!="object")return"";const a=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},s=e.profile&&typeof e.profile=="object"?e.profile:{},i=a.full_name||a.name||s.name||a.user_name||a.preferred_username;return typeof i=="string"&&i.trim()?i.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function Et(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function At(e){const a=typeof e=="string"?e.trim():"";if(!a)return null;const s=a.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),i=a.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=s?.[1]||i?.[1];return o?`https://github.com/${o}`:null}function D(e,a){console.warn(`[tokentracker] settings ${e}:`,a)}function Lt(e,a,s){const[i,o]=g.useState(()=>ue()),r=a&&s&&de(),l=g.useCallback(async()=>{const c=!i;if(ge(c),o(c),!!c)try{await pe(()=>e())}catch(u){D("cloud sync",u)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:l,showLocalCloudSync:r}}function Ot(e){const[a,s]=g.useState(!1),[i,o]=g.useState(!1),[r,l]=g.useState(!1),[c,u]=g.useState(!1),[p,h]=g.useState(null),[d,y]=g.useState(!1),[x,S]=g.useState(""),[k,m]=g.useState(!1),[v,C]=g.useState(""),[N,P]=g.useState(""),[I,f]=g.useState(!1),[E,se]=g.useState(null),ie=g.useMemo(()=>Ct(e),[e]),oe=g.useMemo(()=>Et(e),[e]),re=g.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),le=g.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:h,setGithubUrl:C,setProfileLoading:l,setPublicProfileOn:s,setShowGithubOn:m}),[]);return{anonymousOn:i,customDisplayName:p,displayName:ie,editingGithub:I,editingName:d,email:oe,githubError:E,githubInput:N,githubUrl:v,loadSetters:le,nameInput:x,profileLoading:r,profileSaving:c,publicProfileOn:a,setAnonymousOn:o,setCustomDisplayName:h,setEditingGithub:f,setEditingName:y,setGithubError:se,setGithubInput:P,setGithubUrl:C,setNameInput:S,setProfileLoading:l,setProfileSaving:u,setPublicProfileOn:s,setShowGithubOn:m,showGithubOn:k,userId:re}}function Pt(e,a,s){g.useEffect(()=>{if(!a)return;let i=!0;return s.setProfileLoading(!0),(async()=>{try{const o=await W({getAccessToken:e});if(!i||!o)return;const r=await he({accessToken:o});if(!i)return;s.setPublicProfileOn(!!r?.enabled),s.setAnonymousOn(!!r?.anonymous),r?.display_name&&s.setCustomDisplayName(r.display_name),s.setShowGithubOn(!!r?.show_github_url),s.setGithubUrl(r?.github_url||"")}catch(o){D("load public profile",o)}finally{i&&s.setProfileLoading(!1)}})(),()=>{i=!1}},[e,a,s])}function _t(e,a){return g.useCallback(async(s,{label:i,onError:o,onSuccess:r}={})=>{if(a.profileSaving)return!1;a.setProfileSaving(!0);try{const l=await W({getAccessToken:e});if(!l)return!1;const c=await me({accessToken:l,...s});return r?.(c),!0}catch(l){return o?o(l):D(i||"mutate profile",l),!1}finally{a.setProfileSaving(!1)}},[e,a])}function Tt(e,a){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:a.handleAnonymousToggle,handleSaveName:a.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:a.startEditingName}}function It(e,a){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:a.handleSaveGithub,handleShowGithubToggle:a.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:a.startEditingGithub}}function Gt(e,a){const s=g.useCallback(async()=>{const o=!e.publicProfileOn;await a({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[a,e]);return{handleAnonymousToggle:g.useCallback(async()=>{const o=!e.anonymousOn;await a({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[a,e]),handlePublicProfileToggle:s}}function Rt(e,a,s){const i=g.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await a({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),s?.()}})},[a,e,s]),o=g.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function Ut(e,a){const s=g.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await a({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[a,e]),i=g.useCallback(async()=>{const r=At(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(n("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await a({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||n("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[a,e]),o=g.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:s,startEditingGithub:o}}function Dt(){const e=ce(),a=Ot(e.user),s=Lt(e.getAccessToken,e.enabled,e.signedIn);Pt(e.getAccessToken,e.signedIn,a.loadSetters);const i=_t(e.getAccessToken,a),o=Gt(a,i),r=Rt(a,i,e.refreshDisplayName),l=Ut(a,i);return{...e,...s,email:a.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:a.userId,name:Tt(a,{...o,...r}),github:It(a,l),profileLoading:a.profileLoading,profileSaving:a.profileSaving,publicProfileOn:a.publicProfileOn}}function Q({disabled:e,onCancel:a,onSave:s,saveLabel:i=n("settings.account.save")}){return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:s,disabled:e,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:i}),t.jsx("button",{type:"button",onClick:a,className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:n("settings.account.cancel")})]})}function Mt({nameInput:e,setEditingName:a,setNameInput:s,profileSaving:i,handleSaveName:o}){return t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"text",value:e,onChange:r=>s(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&a(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:n("settings.account.displayName")}),t.jsx(Q,{disabled:i||!e.trim(),onCancel:()=>a(!1),onSave:o,saveLabel:i?n("settings.account.saving"):void 0})]})}function Ht({githubError:e,githubInput:a,handleSaveGithub:s,profileSaving:i,setEditingGithub:o,setGithubError:r,setGithubInput:l}){return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:a,onChange:c=>{l(c.target.value),e&&r(null)},onKeyDown:c=>{c.key==="Enter"&&s(),c.key==="Escape"&&(o(!1),r(null))},maxLength:100,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:n("settings.account.githubUrlPlaceholder")}),t.jsx(Q,{disabled:i,onCancel:()=>{o(!1),r(null)},onSave:s,saveLabel:i?n("settings.account.saving"):void 0})]}),e?t.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:e}):null]})}function ee({disabled:e=!1,label:a,onClick:s,title:i}){return t.jsxs("button",{type:"button",onClick:s,disabled:e,title:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Xe,{className:"h-3.5 w-3.5","aria-hidden":!0}),a]})}function te({actions:e,editing:a,editor:s,hint:i,label:o}){return t.jsx("div",{className:"py-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:o}),a?s:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i})]}),a?null:e]})})}function Ft({name:e}){const a=e.anonymousOn?n("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ee,{disabled:e.anonymousOn,label:n("settings.account.edit"),onClick:e.startEditingName,title:a}),t.jsx(j,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:n("settings.account.displayName")})]})}function $t({name:e}){const{anonymousOn:a,customDisplayName:s,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:c,profileLoading:u,profileSaving:p,setEditingName:h,setNameInput:d,startEditingName:y}=e,x=a?n("settings.account.displayNameAnonymousHint"):s||i;return t.jsx(te,{label:n("settings.account.displayName"),editing:o,hint:x,editor:t.jsx(Mt,{nameInput:c,setEditingName:h,setNameInput:d,profileSaving:p,handleSaveName:l}),actions:t.jsx(Ft,{name:e})})}function Bt({github:e}){const{editingGithub:a,githubError:s,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:c,profileSaving:u,setEditingGithub:p,setGithubError:h,setGithubInput:d,showGithubOn:y,startEditingGithub:x}=e;return t.jsx(t.Fragment,{children:t.jsx(te,{label:n("settings.account.githubUrl"),editing:a,hint:o||n("settings.account.githubUrlHint"),editor:t.jsx(Ht,{githubError:s,githubInput:i,handleSaveGithub:r,profileSaving:u,setEditingGithub:p,setGithubError:h,setGithubInput:d}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ee,{label:n("settings.account.edit"),onClick:x}),t.jsx(j,{checked:y,onChange:l,disabled:c||u,ariaLabel:n("settings.account.githubUrl")})]})})})}function Vt(){const{openLoginModal:e}=be();return t.jsx(A,{title:n("settings.section.account"),children:t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.account.signedOutHint")}),t.jsx("button",{type:"button",onClick:e,className:"inline-flex h-8 shrink-0 items-center justify-center rounded-md bg-oai-gray-900 px-4 text-xs font-medium text-white transition-colors hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100",children:n("settings.account.signIn")})]})})}function Kt({name:e,github:a}){return t.jsxs(t.Fragment,{children:[t.jsx($t,{name:e}),t.jsx(Bt,{github:a})]})}function zt(){const e=Dt();return e.enabled?e.signedIn?t.jsxs(A,{title:n("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Wt,{onSignOut:e.signOut}),children:[t.jsx(qt,{userId:e.userId}),t.jsx(Zt,{settings:e}),t.jsx(Yt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(Jt,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(Vt,{}):null}function qt({userId:e}){const[a,s]=R.useState(!1);if(!e)return null;const i=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),s(!0),globalThis.setTimeout(()=>s(!1),1200)}catch{s(!1)}};return t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:n("settings.account.userId")}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e})]}),t.jsxs("button",{type:"button",onClick:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800","aria-label":n("settings.account.copyUserId"),children:[a?t.jsx(tt,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(nt,{className:"h-3.5 w-3.5","aria-hidden":!0}),a?n("settings.account.copied"):n("settings.account.copy")]})]})}function Wt({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(ft,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.account.signOut")]})}function Zt({settings:e}){return e.showLocalCloudSync?t.jsx(b,{label:n("settings.account.cloudSync"),hint:n("settings.account.cloudSyncHint"),control:t.jsx(j,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:n("settings.account.cloudSync")})}):null}function Yt({checked:e,disabled:a,onChange:s}){return t.jsx(b,{label:n("settings.account.publicProfile"),hint:n("settings.account.publicProfileHint"),control:t.jsx(j,{checked:e,onChange:s,disabled:a,ariaLabel:n("settings.account.publicProfile")})})}function Jt({visible:e,name:a,github:s}){return t.jsx(X,{initial:!1,children:e?t.jsx(J.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(Kt,{name:a,github:s})},"public-profile-fields"):null})}function Xt(){return[{value:"light",label:n("settings.appearance.theme.light"),Icon:xe},{value:"dark",label:n("settings.appearance.theme.dark"),Icon:ye},{value:"system",label:n("settings.appearance.theme.system"),Icon:Y}]}function Qt(){return[{value:je,label:n("settings.appearance.language.system")},{value:Se,label:n("settings.appearance.language.english")},{value:we,label:n("settings.appearance.language.chinese")},{value:Ne,label:n("settings.appearance.language.traditional_chinese")},{value:Ce,label:n("settings.appearance.language.japanese")},{value:Ee,label:n("settings.appearance.language.korean")},{value:Ae,label:n("settings.appearance.language.german")}]}function en(e){if(!e)return null;try{const a=new Date(e);return Number.isNaN(a.getTime())?null:a.toLocaleString()}catch{return null}}function tn(e,a){const s=n(`settings.appearance.currency.rate_source.${e}`),i=en(a),o=i?n("settings.appearance.currency.rate_updated",{when:i}):n("settings.appearance.currency.rate_never");return`${s} · ${o}`}function nn({locale:e,setLocale:a}){const s=Qt();return t.jsx(U,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx(mt,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function an({currency:e,setCurrency:a}){const s=ve().map(i=>({value:i.code,label:n(i.labelKey)}));return t.jsx(U,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function sn({currency:e,rate:a,rateSource:s,rateFetchedAt:i}){if(e===ke)return t.jsx(t.Fragment,{children:n("settings.appearance.currency.hint")});const o=tn(s,i);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${a.toFixed(4)} ${e}`}),t.jsx("span",{role:"img","aria-label":o,title:o,className:"inline-flex h-4 w-4 cursor-help items-center justify-center text-oai-gray-400 hover:text-oai-gray-600 dark:text-oai-gray-500 dark:hover:text-oai-gray-300",children:t.jsx(it,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function on(){const{theme:e,setTheme:a}=fe(),{locale:s,setLocale:i}=Z(),{currency:o,rate:r,rateSource:l,rateFetchedAt:c,setCurrency:u}=at(),{mode:p,setMode:h}=st();return t.jsxs(A,{title:n("settings.section.appearance"),children:[t.jsx(b,{label:n("settings.appearance.theme.label"),hint:n("settings.appearance.theme.hint"),control:t.jsx(_,{options:Xt(),value:e,onChange:a})}),t.jsx(b,{label:n("settings.appearance.language.label"),hint:n("settings.appearance.language.hint"),control:t.jsx(nn,{locale:s,setLocale:i})}),t.jsx(b,{label:n("settings.appearance.currency.label"),hint:t.jsx(sn,{currency:o,rate:r,rateSource:l,rateFetchedAt:c}),control:t.jsx(an,{currency:o,setCurrency:u})}),t.jsx(b,{label:n("settings.appearance.token_format.label"),hint:n("settings.appearance.token_format.hint"),control:t.jsx(_,{options:[{value:M.COMPACT,label:n("settings.appearance.token_format.compact")},{value:M.FULL,label:n("settings.appearance.token_format.full")}],value:p,onChange:h})})]})}function G({labelKey:e}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:n(e)}),t.jsx("span",{className:"px-1.5 py-0.5 text-[8px] font-semibold tracking-wider text-oai-gray-500 bg-oai-gray-100 dark:text-oai-gray-400 dark:bg-oai-gray-800/80 rounded uppercase scale-90 origin-left",children:n("qpd.card.badge")})]})}function rn(){const{enabled:e,toggle:a}=Qe(),{enabled:s,toggle:i}=et(),{available:o,settings:r,setSetting:l}=T(),c=o&&!!r?.dynamicIslandSupported,u=!!r?.dynamicIslandEnabled;return t.jsxs(A,{title:n("settings.section.labs"),children:[c&&t.jsxs(t.Fragment,{children:[t.jsx(b,{label:t.jsx(G,{labelKey:"settings.labs.island.label"}),hint:n("settings.labs.island.hint"),control:t.jsx(j,{checked:u,onChange:()=>l("dynamicIslandEnabled",!u),ariaLabel:n("settings.labs.island.aria")})}),u&&t.jsx(b,{label:n("settings.labs.island_hide_menubar.label"),hint:n("settings.labs.island_hide_menubar.hint"),control:t.jsx(j,{checked:!!r?.hideMenuBarIcon,onChange:()=>l("hideMenuBarIcon",!r?.hideMenuBarIcon),ariaLabel:n("settings.labs.island_hide_menubar.aria")})})]}),t.jsx(b,{label:t.jsx(G,{labelKey:"settings.labs.qpd.label"}),hint:n("settings.labs.qpd.hint"),control:t.jsx(j,{checked:e,onChange:a,ariaLabel:n("settings.labs.qpd.aria")})}),t.jsx(b,{label:t.jsx(G,{labelKey:"settings.labs.sessions.label"}),hint:n("settings.labs.sessions.hint"),control:t.jsx(j,{checked:s,onChange:i,ariaLabel:n("settings.labs.sessions.aria")})})]})}function ln(){const{available:e,settings:a,setSetting:s,runAction:i}=T();if(!e)return null;const o=!!a?.launchAtLogin,r=a?.toastOnReset!==!1,l=a?.confettiOnReset!==!1,c=a?.launchAtLoginSupported!==!1,u=a?.autoUpdateEnabled!==!1,p=a?.updateStatus||null,h=!!a?.updateBusy,d=!!a?.isSyncing;return t.jsxs(A,{title:n("settings.section.menubar"),children:[t.jsx(b,{label:n("settings.menubar.appearance"),hint:n("settings.menubar.appearanceHint"),control:t.jsxs(Le,{to:"/widgets",className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 no-underline transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[n("settings.menubar.appearanceLink"),t.jsx(rt,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(j,{checked:r,onChange:()=>s("toastOnReset",!r),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(j,{checked:l,onChange:()=>s("confettiOnReset",!l),ariaLabel:n("settings.menubar.confettiOnReset")})}),c?t.jsx(b,{label:n("settings.menubar.launchAtLogin"),hint:n("settings.menubar.launchAtLoginHint"),control:t.jsx(j,{checked:o,onChange:()=>s("launchAtLogin",!o),ariaLabel:n("settings.menubar.launchAtLogin")})}):null,t.jsx(b,{label:n("settings.menubar.syncNow"),hint:n("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>i("syncNow"),disabled:d,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(Oe,{className:L("h-3.5 w-3.5",d&&"animate-spin"),"aria-hidden":!0}),d?n("settings.menubar.syncing"):n("settings.menubar.syncNow")]})}),t.jsx(b,{label:n("settings.menubar.autoUpdate"),hint:n("settings.menubar.autoUpdateHint"),control:t.jsx(j,{checked:u,onChange:()=>s("autoUpdateEnabled",!u),ariaLabel:n("settings.menubar.autoUpdate")})}),t.jsx(b,{label:n("settings.menubar.updates"),hint:p||void 0,control:t.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:h,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(lt,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.menubar.checkUpdates")]})})]})}function cn(e,a){function s(r){return r.replace(/^v/,"").split(".").map(Number)}const i=s(e),o=s(a);for(let r=0;r<Math.max(i.length,o.length);r++){const l=i[r]||0,c=o[r]||0;if(l<c)return!0;if(l>c)return!1}return!1}function un(){const{available:e,settings:a,runAction:s}=T(),i=e&&a?.version,[o,r]=R.useState(!1),[l,c]=R.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:u}=Z(),p="0.96.0",h=async()=>{r(!0);try{const k=await fetch("https://api.github.com/repos/xiufengsun/TokenTracker/releases/latest");if(!k.ok)throw new Error("Failed to fetch");const m=await k.json(),v=m.tag_name;cn(p,v)?c({open:!0,latestVersion:v,htmlUrl:m.html_url}):H({title:n("settings.menubar.updates.upToDate")})}catch(k){console.error("Check updates failed:",k),H({title:n("settings.menubar.updates.failed")})}finally{r(!1)}},d=n("settings.menubar.updates.modalTitle"),y=n("settings.menubar.updates.modalDescription",{version:l.latestVersion}),x=n("settings.menubar.updates.modalConfirm"),S=n("settings.menubar.updates.modalCancel");return t.jsxs("div",{className:"mt-6 flex flex-col items-center justify-center gap-4 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[i?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n("settings.menubar.updates.footerCombined",{barVersion:a.version,coreVersion:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>s("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n("settings.menubar.updates.footerCore",{version:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:h,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?n("settings.menubar.updates.checking"):n("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Pe,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:[t.jsx(_e,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.footer.statusPage")]})]}),t.jsx(ot,{open:l.open,title:d,description:y,confirmLabel:x,cancelLabel:S,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),c(k=>({...k,open:!1}))},onCancel:()=>c(k=>({...k,open:!1}))})]})}const dn=()=>[{value:"system",label:n("settings.network.mode.system")},{value:"manual",label:n("settings.network.mode.manual")},{value:"off",label:n("settings.network.mode.off")}],gn=()=>[{value:"http",label:n("settings.network.protocol.http")},{value:"https",label:n("settings.network.protocol.https")},{value:"socks5",label:n("settings.network.protocol.socks5")}],K="w-full rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white";function z(e){const a={},s=String(e.host||"").trim();(!s||/:\/\//.test(s)||s.includes("/"))&&(a.host=n("settings.network.error.host"));const i=String(e.port??"").trim(),o=Number(i);return(!i||!/^\d+$/.test(i)||!Number.isInteger(o)||o<1||o>65535)&&(a.port=n("settings.network.error.port")),a}function pn({proxySettings:e}){const{config:a,save:s,testConnection:i}=e,[o,r]=g.useState(()=>({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})),[l,c]=g.useState({}),[u,p]=g.useState(!1),[h,d]=g.useState(""),[y,x]=g.useState(null),[S,k]=g.useState(!1),[m,v]=g.useState(null);g.useEffect(()=>{r({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})},[a.mode,a.protocol,a.host,a.port]);const C=g.useMemo(()=>a.effective==="manual"?n("settings.network.effective.manual"):a.effective==="env"?n("settings.network.effective.env"):a.effective==="system"?n("settings.network.effective.system"):a.effective==="blocked"?n("settings.network.effective.blocked"):n("settings.network.effective.none"),[a.effective]),N=f=>{r(E=>({...E,...f})),c({}),d(""),x(null),v(null)},P=async()=>{if(o.mode==="manual"){const f=z(o);if(Object.keys(f).length){c(f);return}}p(!0),d(""),x(null);try{await s(o),d("saved")}catch(f){d("error"),x(f)}finally{p(!1)}},I=async()=>{const f=z(o);if(Object.keys(f).length){c(f);return}k(!0),v(null);try{const E=await i(o);v(E)}catch(E){v({ok:!1,error:E?.message||String(E)})}finally{k(!1)}};return t.jsxs(A,{title:n("settings.section.network"),subtitle:C,children:[a.applyError?t.jsx("p",{role:"alert",className:"mb-3 text-xs text-red-600 dark:text-red-400",children:n("settings.network.apply_error",{error:a.applyError})}):null,t.jsx(b,{label:n("settings.network.mode.label"),hint:n("settings.network.mode.hint"),control:t.jsx(_,{options:dn(),value:o.mode,onChange:f=>N({mode:f})})}),t.jsx(X,{initial:!1,children:o.mode==="manual"?t.jsxs(J.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:[t.jsx(b,{label:n("settings.network.protocol.label"),control:t.jsx(U,{value:o.protocol,onValueChange:f=>N({protocol:f}),options:gn(),ariaLabel:n("settings.network.protocol.label"),className:"px-2.5 py-1.5 text-xs font-medium"})}),t.jsx(b,{label:n("settings.network.host.label"),hint:l.host,control:t.jsx("input",{type:"text",value:o.host,onChange:f=>N({host:f.target.value}),placeholder:n("settings.network.host.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":l.host?!0:void 0,"aria-label":n("settings.network.host.label"),className:K})}),t.jsx(b,{label:n("settings.network.port.label"),hint:l.port,control:t.jsx("input",{type:"text",inputMode:"numeric",value:o.port,onChange:f=>N({port:f.target.value}),placeholder:n("settings.network.port.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":l.port?!0:void 0,"aria-label":n("settings.network.port.label"),className:K})}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 py-3",children:[t.jsx("button",{type:"button",onClick:I,disabled:S||u,className:"rounded-md border border-oai-gray-200 px-3 py-1.5 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:S?n("settings.network.test.testing"):n("settings.network.test")}),t.jsx("button",{type:"button",onClick:P,disabled:u||S,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:u?n("settings.network.saving"):n("settings.network.save")})]}),m?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:m.ok?n("settings.network.test.ok",{status:String(m.status??"")}):n("settings.network.test.fail",{error:m.error||""})}):null]},"manual-proxy-fields"):t.jsx("div",{className:"flex justify-end py-3",children:t.jsx("button",{type:"button",onClick:P,disabled:u,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:u?n("settings.network.saving"):n("settings.network.save")})},"non-manual-save")}),h==="saved"?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.network.saved")}):null,h==="error"?t.jsx("p",{role:"alert",className:"py-2 text-xs text-red-600 dark:text-red-400",children:y?.unprotected?n("settings.network.save_error_unprotected",{error:y?.message||String(y||"")}):n("settings.network.save_error",{error:y?.message||String(y||"")})}):null]})}const ne="/functions/tokentracker-proxy-config",hn="/functions/tokentracker-proxy-test",mn={mode:"system",protocol:"http",host:"",port:"",effective:"none",applyError:null};function ae(e){return!e||typeof e.mode!="string"?null:{mode:e.mode,protocol:typeof e.protocol=="string"?e.protocol:"http",host:typeof e.host=="string"?e.host:"",port:e.port==null||e.port===0?"":String(e.port),effective:typeof e.effective=="string"?e.effective:"none",applyError:typeof e.applyError=="string"&&e.applyError.trim()?e.applyError:null}}async function bn(){const e=await fetch(ne,{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!e.ok)return null;const a=await e.json().catch(()=>null);return ae(a)}async function q(){const{getLocalApiAuthHeaders:e}=await Te(async()=>{const{getLocalApiAuthHeaders:a}=await import("./__vite-browser-external-4IGm4Djn.js").then(s=>s.d8);return{getLocalApiAuthHeaders:a}},__vite__mapDeps([0,1]));return e()}function fn(){const[e,a]=g.useState(!1),[s,i]=g.useState(!0),[o,r]=g.useState(mn);g.useEffect(()=>{if(!ct()){a(!1),i(!1);return}let u=!1;return(async()=>{try{const p=await bn();if(u)return;if(!p){a(!1),i(!1);return}r(p),a(!0),i(!1)}catch{u||(a(!1),i(!1))}})(),()=>{u=!0}},[]);const l=g.useCallback(async u=>{const p=await q(),h=await fetch(ne,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...p},cache:"no-store",body:JSON.stringify({mode:u.mode,protocol:u.protocol,host:u.host,port:u.port===""?0:Number(u.port)})}),d=await h.json().catch(()=>null);if(!h.ok){const x=d&&typeof d.error=="string"?d.error:`HTTP ${h.status}`;throw new Error(x)}const y=ae(d);if(y&&r(y),d&&d.ok===!1){const x=d&&typeof d.applyError=="string"&&d.applyError||d&&typeof d.error=="string"&&d.error||`HTTP ${h.status}`,S=new Error(x);throw d.unprotected===!0&&(S.unprotected=!0),S}return y||d},[]),c=g.useCallback(async u=>{const p=await q(),h=await fetch(hn,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...p},cache:"no-store",body:JSON.stringify({protocol:u.protocol,host:u.host,port:u.port===""?0:Number(u.port)})}),d=await h.json().catch(()=>null);if(!d||typeof d.ok!="boolean")throw new Error(d&&typeof d.error=="string"?d.error:`HTTP ${h.status}`);return d},[]);return{available:e,loading:s,config:o,save:l,testConnection:c}}const w={APPEARANCE:"appearance",NATIVE_APP:"native-app",NETWORK:"network",ACCOUNT:"account",LIMITS:"limits",LABS:"labs"};function xn({prefs:e}){return t.jsx(_,{options:[{value:$.USED,label:n("limits.settings.display_mode_used")},{value:$.REMAINING,label:n("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function zn(){const e=Ye(),{available:a,settings:s,setSetting:i}=T(),o=fn(),{available:r}=o,l=s?.toastOnReset!==!1,c=s?.confettiOnReset!==!1,[u,p]=Ie(),h=Ge(),d=u.get("section"),x=Object.values(w).includes(d)&&(d!==w.NATIVE_APP||a)&&(d!==w.NETWORK||r)?d:w.APPEARANCE,S=m=>{const v=new URLSearchParams(u);m===w.APPEARANCE?v.delete("section"):v.set("section",m),p(v,{replace:!0})},k=[{id:w.APPEARANCE,label:n("settings.section.appearance"),Icon:yt,content:t.jsx(on,{})},...a?[{id:w.NATIVE_APP,label:n("settings.section.menubar"),Icon:Y,content:t.jsx(ln,{})}]:[],...r?[{id:w.NETWORK,label:n("settings.section.network"),Icon:Re,content:t.jsx(pn,{proxySettings:o})}]:[],{id:w.ACCOUNT,label:n("settings.section.account"),Icon:kt,content:t.jsx(zt,{})},{id:w.LIMITS,label:n("settings.section.limits"),Icon:Ue,content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs(A,{title:n("settings.section.limits"),children:[t.jsx(b,{label:n("limits.settings.display_mode_label"),control:t.jsx(xn,{prefs:e})}),t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(j,{checked:l,disabled:!a,onChange:()=>i("toastOnReset",!l),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(j,{checked:c,disabled:!a,onChange:()=>i("confettiOnReset",!c),ariaLabel:n("settings.menubar.confettiOnReset")})}),t.jsx(b,{label:n("settings.limits.showSubscriptions"),hint:n("settings.limits.showSubscriptionsHint"),control:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>h("/limits?openSubscriptions=1"),"aria-label":n("limits.page.openSubscriptions"),title:n("limits.page.openSubscriptions"),className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-white dark:bg-oai-gray-900 text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:t.jsx(De,{size:14,"aria-hidden":!0})}),t.jsx(j,{checked:e.showSubscriptions!==!1,onChange:()=>e.setShowSubscriptions(!e.showSubscriptions),ariaLabel:n("settings.limits.showSubscriptions")})]})})]}),t.jsx(A,{title:n("settings.limits.providers"),children:t.jsx(Nt,{prefs:e})})]})},{id:w.LABS,label:n("settings.section.labs"),Icon:dt,content:t.jsx(rn,{})}];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:n("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":n("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:k.map(({id:m,label:v,Icon:C})=>{const N=x===m;return t.jsxs("button",{id:`settings-nav-${m}`,type:"button","aria-current":N?"page":void 0,"aria-controls":`settings-panel-${m}`,onClick:()=>S(m),className:L("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",N?"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(C,{className:L("h-4 w-4 shrink-0",N?"text-oai-black dark:text-white":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:v})]},m)})})}),t.jsxs("div",{className:"min-w-0",children:[k.map(({id:m,label:v,content:C})=>t.jsx("section",{id:`settings-panel-${m}`,"aria-labelledby":`settings-nav-${m}`,"aria-label":v,"data-settings-panel":m,hidden:x!==m,children:C},m)),t.jsx(un,{})]})]})]})})})}export{zn as SettingsPage};