tokentracker-cli 1.4.4 → 1.4.6

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 (122) hide show
  1. package/README.de.md +1 -0
  2. package/README.ja.md +1 -0
  3. package/README.ko.md +1 -0
  4. package/README.md +1 -0
  5. package/README.zh-CN.md +1 -0
  6. package/dashboard/dist/assets/{AchievementBadge-slL-XBCu.js → AchievementBadge-BmWRsZMx.js} +1 -1
  7. package/dashboard/dist/assets/{AchievementsPage-BeFkGc5M.js → AchievementsPage-CyIP2nck.js} +2 -2
  8. package/dashboard/dist/assets/{AchievementsSection-BrGUIipD.js → AchievementsSection-BeNyJ0LW.js} +1 -1
  9. package/dashboard/dist/assets/{BadgeDetailModal-avmK1ODc.js → BadgeDetailModal-DIFnFzkv.js} +1 -1
  10. package/dashboard/dist/assets/{BotAnimated-DaEPdEZi.js → BotAnimated-CKVeJHit.js} +1 -1
  11. package/dashboard/dist/assets/{Card-CIZCccTA.js → Card-lQmyKbh4.js} +1 -1
  12. package/dashboard/dist/assets/{CloudCheckoutPage-BhRj0SYO.js → CloudCheckoutPage-B_8y6dyX.js} +1 -1
  13. package/dashboard/dist/assets/{CloudPage-CvaN8a54.js → CloudPage-BOQjUGAt.js} +2 -2
  14. package/dashboard/dist/assets/{CommandPalette-BUNuXmYF.js → CommandPalette-BV9LqokI.js} +1 -1
  15. package/dashboard/dist/assets/{CommunityStatsModal-BCI0WHPr.js → CommunityStatsModal-WELxKEFc.js} +1 -1
  16. package/dashboard/dist/assets/{ConfirmModal-CT7IwtLR.js → ConfirmModal-B8H5o8c_.js} +1 -1
  17. package/dashboard/dist/assets/{Controls-CtnMyxNH.js → Controls-9ynPx9rF.js} +1 -1
  18. package/dashboard/dist/assets/{DashboardPage-BuzyITeL.js → DashboardPage-B8z-U63p.js} +1 -1
  19. package/dashboard/dist/assets/{DateRangePopover-1Ps1-1dw.js → DateRangePopover-DEqWsV_8.js} +1 -1
  20. package/dashboard/dist/assets/{DevicePage-Dt-dVQAG.js → DevicePage-CUOlUySM.js} +1 -1
  21. package/dashboard/dist/assets/{DialogClose-D-DRTF1u.js → DialogClose-Dlg52bL6.js} +1 -1
  22. package/dashboard/dist/assets/DialogDescription-vuQFBlM_.js +1 -0
  23. package/dashboard/dist/assets/{DialogTitle-CiiRTn3_.js → DialogTitle-CduwXjqH.js} +1 -1
  24. package/dashboard/dist/assets/{ElectricLogo-k6RFJ2qC.js → ElectricLogo-DFt7_F2f.js} +1 -1
  25. package/dashboard/dist/assets/{FadeIn-CNHg83aK.js → FadeIn-DlyusE6n.js} +1 -1
  26. package/dashboard/dist/assets/{HeaderGithubStar-CIYW5dc3.js → HeaderGithubStar-tUtJoFHh.js} +1 -1
  27. package/dashboard/dist/assets/{HoverTooltip-Dn80DyPM.js → HoverTooltip-v-zkCqsX.js} +1 -1
  28. package/dashboard/dist/assets/{IpCheckPage-B29dYfoI.js → IpCheckPage-C5Y1uVEr.js} +1 -1
  29. package/dashboard/dist/assets/{LandingPage-Dzc8_QyW.js → LandingPage-DzOJOAj7.js} +2 -2
  30. package/dashboard/dist/assets/{LeaderboardPage-DXPcIhyQ.js → LeaderboardPage-BBZ_6tCw.js} +2 -2
  31. package/dashboard/dist/assets/{LeaderboardProBadge-DxEdj2Zq.js → LeaderboardProBadge-DakoXIQn.js} +1 -1
  32. package/dashboard/dist/assets/{LeaderboardProfileModal-DnKY2223.js → LeaderboardProfileModal-CINpES_x.js} +3 -3
  33. package/dashboard/dist/assets/{LeaderboardProfilePage-CY94ngqy.js → LeaderboardProfilePage-B6ISf-1l.js} +1 -1
  34. package/dashboard/dist/assets/{LimitsPage-AlvnAPCD.js → LimitsPage-UVX730CQ.js} +8 -8
  35. package/dashboard/dist/assets/{LocalOnlyNotice-EHw7BeYS.js → LocalOnlyNotice-BJSsmXF1.js} +1 -1
  36. package/dashboard/dist/assets/{LoginCard-E5E3i2kj.js → LoginCard-Dggv2aGv.js} +1 -1
  37. package/dashboard/dist/assets/{LoginModal-DxhQI9kh.js → LoginModal-B8qDd2kY.js} +1 -1
  38. package/dashboard/dist/assets/{LoginPage-DRwJn-Fw.js → LoginPage-Dv66U8yJ.js} +1 -1
  39. package/dashboard/dist/assets/{PetPage-DIpVTdiC.js → PetPage-CNwrQdKM.js} +2 -2
  40. package/dashboard/dist/assets/{PopoverPopup-Bjs7E91g.js → PopoverPopup-CqmvpYOi.js} +1 -1
  41. package/dashboard/dist/assets/{ProviderIcon-DqXIjym-.js → ProviderIcon-BF2Ch7wi.js} +1 -1
  42. package/dashboard/dist/assets/{ResetPasswordPage-DxSRYQgP.js → ResetPasswordPage-B0R8VUU3.js} +1 -1
  43. package/dashboard/dist/assets/{Select-BfjrcaiM.js → Select-idAiBnJG.js} +1 -1
  44. package/dashboard/dist/assets/{SelectItemText-Dpdlb0cU.js → SelectItemText-DPmmPY_D.js} +1 -1
  45. package/dashboard/dist/assets/{SelfHostPage-Cnp_PMaD.js → SelfHostPage-oR9cPK02.js} +1 -1
  46. package/dashboard/dist/assets/{ServiceStatusPage-fBwG-qXq.js → ServiceStatusPage-CdV9gfGF.js} +1 -1
  47. package/dashboard/dist/assets/{SessionsPage-BEk7AHdq.js → SessionsPage-BkD34VlL.js} +1 -1
  48. package/dashboard/dist/assets/{SettingsPage-BgML2jQR.js → SettingsPage-DsthWCyM.js} +3 -3
  49. package/dashboard/dist/assets/{SkillsPage-DcvVZ3Wn.js → SkillsPage-CzMk9s3x.js} +1 -1
  50. package/dashboard/dist/assets/{TokenGalaxy-D29yX2Hb.js → TokenGalaxy-DQ6o8YBp.js} +1 -1
  51. package/dashboard/dist/assets/{TooltipPopup-CjzmNK2l.js → TooltipPopup-CMQjA-HE.js} +1 -1
  52. package/dashboard/dist/assets/{TrendMonitor-DfnQrsrx.js → TrendMonitor-DrV1m8E7.js} +1 -1
  53. package/dashboard/dist/assets/{WidgetsPage-CRYomYfk.js → WidgetsPage-Cc16WM0Y.js} +1 -1
  54. package/dashboard/dist/assets/{WrappedPage-CvQI5zUw.js → WrappedPage-pMwbM4R7.js} +1 -1
  55. package/dashboard/dist/assets/{__vite-browser-external-BZ-i40Kf.js → __vite-browser-external-DCy_YLfe.js} +3 -3
  56. package/dashboard/dist/assets/{agent-logos-CvOX7WXW.js → agent-logos-Zw7LNkMO.js} +1 -1
  57. package/dashboard/dist/assets/{arrow-left-BrQrZJtW.js → arrow-left-DycYjE-k.js} +1 -1
  58. package/dashboard/dist/assets/{arrow-right-fC11gmFY.js → arrow-right-uNxLHoJ0.js} +1 -1
  59. package/dashboard/dist/assets/{arrow-up-right-CCMEqQQp.js → arrow-up-right-CmdJ7gd7.js} +1 -1
  60. package/dashboard/dist/assets/{calendar-days-OaIQ06qD.js → calendar-days-CJ33_t5O.js} +1 -1
  61. package/dashboard/dist/assets/{check-D888uFpx.js → check-Dbubk4Il.js} +1 -1
  62. package/dashboard/dist/assets/{chevron-down-BJ0BpS_w.js → chevron-down-BwvBVAOs.js} +1 -1
  63. package/dashboard/dist/assets/{cloud-checkout-BeOpEJTZ.js → cloud-checkout-IG-IOpeP.js} +1 -1
  64. package/dashboard/dist/assets/{composite-CUuXvKos.js → composite-IIgJPPIw.js} +1 -1
  65. package/dashboard/dist/assets/{download-BJ7CKwx5.js → download-DxtH7w6a.js} +1 -1
  66. package/dashboard/dist/assets/{external-link-CDaZwJVN.js → external-link-evKf3mnD.js} +1 -1
  67. package/dashboard/dist/assets/{flame-ChyUKs-9.js → flame-D2qOE_W4.js} +1 -1
  68. package/dashboard/dist/assets/{format-tokens-B6WX7zcH.js → format-tokens-CqDmm-sK.js} +1 -1
  69. package/dashboard/dist/assets/{gift-CQlAZUJ5.js → gift-Ge11HK1x.js} +1 -1
  70. package/dashboard/dist/assets/{host-mode-Gw6KD5OJ.js → host-mode-8_TNh7yE.js} +1 -1
  71. package/dashboard/dist/assets/{icons-C7gGTMuQ.js → icons-OmfWvE5K.js} +1 -1
  72. package/dashboard/dist/assets/{index-Bm2dDAVL.js → index-BYuEzP9p.js} +1 -1
  73. package/dashboard/dist/assets/{index-CLb64Tlj.js → index-BsYtyo4U.js} +1 -1
  74. package/dashboard/dist/assets/{index-C0pbymQa.js → index-tbe1aERA.js} +1 -1
  75. package/dashboard/dist/assets/{info-CvOmd88O.js → info-xhrso9aO.js} +1 -1
  76. package/dashboard/dist/assets/{link-2-BNEPxvlF.js → link-2-BgNpTaO4.js} +1 -1
  77. package/dashboard/dist/assets/{loader-circle-bRHxCgY3.js → loader-circle-DRooZ0e5.js} +1 -1
  78. package/dashboard/dist/assets/{modifiers.esm-D-X0-uvt.js → modifiers.esm-D-QAEpOZ.js} +1 -1
  79. package/dashboard/dist/assets/{monitor-smartphone-Bo7d-q73.js → monitor-smartphone-Bwu7__2B.js} +1 -1
  80. package/dashboard/dist/assets/{play-DqpGELN5.js → play-CBPvTiWM.js} +1 -1
  81. package/dashboard/dist/assets/{plus-2fA1tz7S.js → plus-B4lFIyP8.js} +1 -1
  82. package/dashboard/dist/assets/{provider-display-B1KigDYZ.js → provider-display-CQlWusXH.js} +1 -1
  83. package/dashboard/dist/assets/{react-DYja9tZG.js → react-DDOtS4Bd.js} +1 -1
  84. package/dashboard/dist/assets/{safePolygon-BerB8y-A.js → safePolygon-BGfBVKoy.js} +1 -1
  85. package/dashboard/dist/assets/{search-CU6UVI1L.js → search-DVyNq72J.js} +1 -1
  86. package/dashboard/dist/assets/{server-CZR4PTdb.js → server-EpUTEsOf.js} +1 -1
  87. package/dashboard/dist/assets/{shield-check-BGbNmrMP.js → shield-check-DRg8cPKV.js} +1 -1
  88. package/dashboard/dist/assets/{skills-api-CJLEzxDf.js → skills-api-y42dEF96.js} +1 -1
  89. package/dashboard/dist/assets/{sortable.esm-CJ1NZWER.js → sortable.esm-D2S1gXCK.js} +1 -1
  90. package/dashboard/dist/assets/{store-CJFdru_6.js → store-DfGPS2IR.js} +1 -1
  91. package/dashboard/dist/assets/{terminal-ClyQ8tvQ.js → terminal-hXIrrL2b.js} +1 -1
  92. package/dashboard/dist/assets/{trash-Dg2PWl5-.js → trash-cjaASRQl.js} +1 -1
  93. package/dashboard/dist/assets/{use-community-stats-Ca995kap.js → use-community-stats-B-nipjWt.js} +1 -1
  94. package/dashboard/dist/assets/{use-latest-request-guard-BKbMGVji.js → use-latest-request-guard-DIEYrSzn.js} +1 -1
  95. package/dashboard/dist/assets/{use-limits-display-prefs-CGyd8lvc.js → use-limits-display-prefs-BdHDwBBC.js} +1 -1
  96. package/dashboard/dist/assets/{use-native-settings-Dqeuqm9O.js → use-native-settings-7w71_h44.js} +1 -1
  97. package/dashboard/dist/assets/{use-ordered-list-Nj7R1iUu.js → use-ordered-list-CSMpK4ar.js} +1 -1
  98. package/dashboard/dist/assets/use-reduced-motion-HUGf223R.js +1 -0
  99. package/dashboard/dist/assets/{use-session-efficiency-pref-C_H5BaGV.js → use-session-efficiency-pref-BagBVWW6.js} +1 -1
  100. package/dashboard/dist/assets/{use-transform-CC90hurD.js → use-transform-sjGGXCNn.js} +1 -1
  101. package/dashboard/dist/assets/use-usage-limits-Nml-wUB-.js +1 -0
  102. package/dashboard/dist/assets/{useCurrency-CMHIL39_.js → useCurrency-DAKIY1nR.js} +1 -1
  103. package/dashboard/dist/assets/{usePositioner-CRSfrGQq.js → usePositioner-B7vVQ7th.js} +1 -1
  104. package/dashboard/dist/assets/{useTokenFormat-B5jhM_Kb.js → useTokenFormat-gtgw8k2Z.js} +1 -1
  105. package/dashboard/dist/assets/{zap-CKx8ySZs.js → zap-DFWOiTJ1.js} +1 -1
  106. package/dashboard/dist/index.html +1 -1
  107. package/dashboard/dist/ip-check.html +1 -1
  108. package/dashboard/dist/leaderboard.html +1 -1
  109. package/dashboard/dist/share.html +1 -1
  110. package/package.json +1 -1
  111. package/src/commands/sync.js +546 -31
  112. package/src/lib/async-queue-reader.js +37 -16
  113. package/src/lib/codex-context-breakdown.js +8 -1
  114. package/src/lib/codex-rollout-parser.js +65 -5
  115. package/src/lib/grok-limits.js +56 -0
  116. package/src/lib/pricing/seed-snapshot.json +1 -1
  117. package/src/lib/rollout.js +356 -8
  118. package/src/lib/session-analytics.js +1 -1
  119. package/src/lib/usage-limits.js +33 -1
  120. package/dashboard/dist/assets/DialogDescription-BOYDS1mM.js +0 -1
  121. package/dashboard/dist/assets/use-reduced-motion-CGMbDpHQ.js +0 -1
  122. package/dashboard/dist/assets/use-usage-limits-DtaaE7D8.js +0 -1
@@ -1,9 +1,9 @@
1
- import{o as Z,j as e,y as Re,c as r,h as U,r as p,al as xt,B as Y,bl as pt,V as j,e as gt,W as ve,R as ht,L as ft,bm as bt,t as yt,w as kt}from"./__vite-browser-external-BZ-i40Kf.js";import{m as je}from"./react-DYja9tZG.js";import{P as re,c as vt,r as le,a as jt,u as wt,b as Nt,s as _t}from"./use-usage-limits-DtaaE7D8.js";import{b as w,c as He,l as ie,d as Ie,u as Ct}from"./use-limits-display-prefs-CGyd8lvc.js";import{C as Ae}from"./Card-CIZCccTA.js";import{F as St}from"./FadeIn-CNHg83aK.js";import{P as Oe}from"./ProviderIcon-DqXIjym-.js";import{H as Pt}from"./HoverTooltip-Dn80DyPM.js";import{C as Fe}from"./chevron-down-BJ0BpS_w.js";import{G as Mt}from"./gift-CQlAZUJ5.js";import{C as Dt}from"./ConfirmModal-CT7IwtLR.js";import{I as we,L as Tt}from"./LocalOnlyNotice-EHw7BeYS.js";import{S as xe}from"./Select-BfjrcaiM.js";import{P as Et}from"./plus-2fA1tz7S.js";import{P as Rt,a as Ht,b as It,c as At,d as Ot}from"./PopoverPopup-Bjs7E91g.js";import{u as Ft}from"./use-reduced-motion-CGMbDpHQ.js";import"./use-latest-request-guard-BKbMGVji.js";import"./DialogTitle-CiiRTn3_.js";import"./composite-CUuXvKos.js";import"./store-CJFdru_6.js";import"./DialogDescription-BOYDS1mM.js";import"./arrow-up-right-CCMEqQQp.js";import"./download-BJ7CKwx5.js";import"./check-D888uFpx.js";import"./SelectItemText-Dpdlb0cU.js";import"./usePositioner-CRSfrGQq.js";import"./safePolygon-BerB8y-A.js";const Le={name:"bell-off",size:24,node:[["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"}]]};Le.node;const Lt=Z(Le);const $e={name:"bell",size:24,node:[["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"}]]};$e.node;const $t=Z($e);const Ue={name:"calendar-clock",size:24,node:[["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"}]]};Ue.node;const Be=Z(Ue);const ze={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};ze.node;const Ge=Z(ze);const We={name:"infinity",size:24,node:[["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"}]]};We.node;const qe=Z(We),Ut=[3,2,3,3,2,2,3];function L({className:t}){return e.jsx("div",{className:Re("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function Bt(){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-3 w-12 shrink-0"}),e.jsx(L,{className:"flex-1 h-1.5 rounded-full min-w-0"}),e.jsx(L,{className:"h-3 w-[30px] shrink-0"}),e.jsx(L,{className:"h-3 w-6 shrink-0"})]})}function zt({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(L,{className:"h-[14px] w-[14px] rounded shrink-0"}),e.jsx(L,{className:Re("h-4",i)})]}),Array.from({length:t},(s,n)=>e.jsx(Bt,{},n))]})}function Gt(){return e.jsx(Ae,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(L,{className:"h-3.5 w-28"}),Ut.map((t,a)=>e.jsx(zt,{bars:t,index:a},a))]})})}const fe=100;function Ne(t){const a=Date.parse(t);return Number.isFinite(a)?a:null}function Wt(t){return Math.max(0,Math.min(fe,Math.round(t)))}function qt(t){return new Intl.DateTimeFormat(U(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t))}function Vt(t,a,i){if(t==null||t>=a)return fe;const s=a-t,n=a-i;return Wt(n/s*fe)}function Yt(t){const a=t.available_count;return a===null?null:Number.isInteger(a)&&a>=0?a:void 0}function Kt(t,{now:a}={}){if(!t||typeof t!="object")return null;const i=Yt(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=Ne(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:qt(c),expiresMs:c,percent:Vt(Ne(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 X=864e5;function $(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 Ve(t,a){if(a==="weekly")return t-7*X;if(a==="yearly")return $(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 Ye(t,a){return a==="weekly"?t+7*X:a==="yearly"?$(t,12):$(t,1)}function Xt(t){if(t.startedAt!=null){const a=new Date(t.startedAt).getTime();if(Number.isFinite(a))return a}return Ve(new Date(t.nextBillingAt).getTime(),t.cycle)}function Zt(t,a,i){if(t.startedAt!=null){const s=new Date(t.startedAt).getTime();if(Number.isFinite(s))return s}return Ve(i,a)}function Jt(t,a,i){if(a==="weekly"){const c=7*X,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*X;let o=i<=t?0:Math.floor((i-t)/n);for(;o>0&&$(t,o*s)>i;)o-=1;let l=0;for(;$(t,(o+1)*s)<=i&&l<12e3;)o+=1,l+=1;return{startMs:$(t,o*s),endMs:$(t,(o+1)*s)}}function ne(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=Zt(t,s,i);if(!Number.isFinite(n))return null;let o,l,c=!1;t.autoRenew?{startMs:o,endMs:l}=Jt(n,s,a):t.startedAt!=null?(o=n,l=Ye(n,s),c=l<=a):(o=n,l=i,c=l<=a);const d=Math.max(1,l-o),u=c?1:Math.max(0,Math.min(1,(a-o)/d));return{endMs:l,startMs:o,progress:u,cycleDays:Math.max(1,Math.round(d/X)),expired:c}}function Ke(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 be(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 Qt="shrink-0 text-oai-black dark:text-oai-white";function Xe(){const t=typeof navigator>"u"?"":navigator.userAgent||"";return/Windows/i.test(t)?"windows":/Linux/i.test(t)?"linux":"macos"}function Ze(){return Xe()==="windows"?r("limits.commandCode.setupHint.snippet_login_windows"):r("limits.commandCode.setupHint.snippet_login")}function Je(){return r("limits.devin.setupHint.snippet_login")}function ea(t){const a=le(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 ta(t,a){const i=a===w.REMAINING?100-t:t;return i>=90?"bg-red-500":i>=70?"bg-amber-500":"bg-emerald-500"}function se(t,a="used_percent"){return t?a==="utilization"?t.utilization:t.used_percent:null}function ce(t,a="reset_at"){return t?a==="resets_at"?t.resets_at:t.reset_at:null}function pe(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 ae(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 aa(t){if(!t||typeof t!="object"||!(Number(t.limit_credits)>0))return null;const a={useGrouping:t.unit!=="calls"},i=ae(t.used_credits,a),s=ae(t.limit_credits,a),n=ae(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 Qe(t,a,i){return vt({usedPercent:se(t.window,t.pctField),windowSeconds:jt(t,t.window),resetMs:le(ce(t.window,t.resetField)),mode:a,now:i})}function oe(t){return Number.isFinite(t)?new Intl.DateTimeFormat(U(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):null}function ra(t,a,i){const s=[tt(t,a,i)],n=le(ce(t.window,t.resetField)),o=oe(n);o&&s.push(r(t.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:o}));const l=aa(t.window);return l&&s.push(l),s.join(`
2
- `)}const et=Pt;function ia({label:t,pct:a,reset:i,mode:s=w.USED,pacePercent:n=null,paceOver:o=!1,title:l=null}){const c=Math.max(0,Math.min(100,Number(a)||0)),d=s===w.REMAINING?100-c:c,u=Math.round(d),x=d>0&&u===0?Math.max(d,.35):d;let g=String(u);d>0&&u===0&&(g=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(et,{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:`${ta(d,s)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${x}%`,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:[g,"%"]}),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 tt(t,a,i){const s=t.label??r(t.labelKey),n=i===w.REMAINING,o=d=>n?100-d:d;if(a.expectedPercent==null){const d=Math.max(0,Math.min(100,Number(se(t.window,t.pctField))||0)),u=pe(o(d));return n?r("limits.explain.remaining",{label:s,used:u}):r("limits.explain.used",{label:s,used:u})}if(a.paceOver){if(a.runsOutEta)return r("limits.explain.ahead_eta",{label:s,eta:a.runsOutEta});const d=pe(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(se(t.window,t.pctField))||0)),c=pe(o(a.projectedEnd??l));return r(n?"limits.explain.on_track_remaining":"limits.explain.on_track",{label:s,pct:c})}function na({pace:t}){return t.pacePercent!=null}function at({rows:t,mode:a,now:i=Date.now()}){if(t.length===0)return null;const s=a===w.REMAINING,n=t.some(na);return e.jsxs("div",{className:"mt-1 flex flex-col gap-1",children:[t.map(({spec:o,pace:l})=>{const c=oe(le(ce(o.window,o.resetField)));return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-600 dark:text-oai-gray-300",children:[tt(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 K(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 _e={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"}},sa={claude:"claude",codex:"codex",antigravity:"agy"};function G({label:t,age:a=null,tone:i="live",tooltip:s=null}){const n=_e[i]||_e.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 rt({name:t,providerId:a,children:i,expandable:s=!1,expanded:n=!1,onToggle:o,badge:l=null,rightAdornment:c=null,toggleOnHeader:d=!1}){const u=Ie(a),x=e.jsxs("div",{className:"flex items-center gap-1.5",children:[u?e.jsx(Oe,{provider:u,size:14,className:Qt}):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?d?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("button",{type:"button","aria-expanded":n,onClick:o,className:"flex w-full items-center justify-between rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[x,e.jsx(Fe,{size:13,"aria-hidden":!0,className:`text-oai-gray-400 transition-transform ${n?"rotate-180":""}`})]}),i]}):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:[x,i]}):e.jsxs("div",{className:"flex flex-col gap-1.5",children:[x,i]})}function it({subscription:t}){const a=t.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),i=t.autoRenew?qe:Ge;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 nt({subscription:t,now:a,mode:i=w.USED}){const s=ne(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===w.REMAINING?100-c:c,u=o?100:Math.max(0,Math.min(100,d)),x=Math.round(u),g=u>0&&x===0?r("limits.bar.sub_one_percent"):`${x}%`;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:`${u}%`,minWidth:u>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:g}),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:Ke(n,a)})]})}function st({subscription:t,now:a}){const i=ne(t,a);if(!i)return null;const s=new Intl.DateTimeFormat(U(),{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:be(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 oa=He;function R({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 ot({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(ia,{label:n.label??r(n.labelKey),pct:se(n.window,n.pctField),reset:ea(ce(n.window,n.resetField)),mode:a,pacePercent:o.pacePercent,paceOver:o.paceOver,title:ra(n,o,a)},n.key)),s?e.jsx(R,{children:r("limits.status.no_data")}):null,i]})}function la(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 ca({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(et,{text:la(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 da({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(ca,{row:i},i.key))]})}function ua({data:t}){const a=Date.now(),i=[{key:"five_hour",label:r("limits.label.zcode_5h")},{key:"weekly",label:r("limits.label.zcode_weekly")}].map(s=>({...s,cards:(t[s.key]||[]).filter(n=>Date.parse(n.expires_at)>a).slice().sort((n,o)=>Date.parse(n.expires_at)-Date.parse(o.expires_at))}));return e.jsxs("div",{className:"mt-1 flex flex-col gap-1.5",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.zcode.reset_bank.title")}),t.error?e.jsx(R,{tone:"error",children:r("shared.error.prefix",{error:t.error})}):i.map(s=>e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{"data-limit-label":"",className:"shrink-0 whitespace-nowrap text-oai-gray-500 dark:text-oai-gray-400",style:{width:"var(--tt-limits-label-w)"},children:s.label}),e.jsx("span",{className:"rounded-full bg-oai-gray-100 px-2 py-0.5 tabular-nums text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-300",children:r("limits.zcode.reset_bank.count",{count:s.cards.length})}),s.cards.length?e.jsx("span",{className:"ml-auto text-right text-[10px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500",title:s.cards.map(n=>oe(Date.parse(n.expires_at))).join(`
3
- `),children:r("limits.zcode.reset_bank.earliest",{time:oe(Date.parse(s.cards[0].expires_at))})}):null]},s.key))]})}function lt(t,a){if(t==="zcode_reset_bank")return a.reset_credits?e.jsx(ua,{data:a.reset_credits}):null;if(t==="codex_meta"){const i=Kt(a.reset_credits);return i?e.jsx(da,{model:i}):null}if(t==="kimi_parallel"&&a.parallel_limit)return e.jsx(R,{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=ae(a.tracked_credits,{maximumFractionDigits:2});return e.jsx(R,{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(ga,{defaultDir:a.otel_default_dir}):null}function ma({data:t,mode:a,now:i}){const[s,n]=p.useState(!1),o=p.useRef(null),l=ct(o),c=[...new Set((t.buckets||[]).map(x=>x.plan_name).filter(Boolean))],d=c.length?c.join(" · "):r("limits.zcode.start_grants"),u=re.zcode.windows(t).filter(x=>x.window).map(x=>({spec:x,pace:Qe(x,a,i)}));return e.jsxs("div",{className:"mt-2 border-t border-oai-gray-200/60 pt-2 dark:border-oai-gray-800",children:[e.jsxs("button",{type:"button","aria-expanded":s,onClick:x=>{x.stopPropagation(),n(g=>!g)},onKeyDown:x=>x.stopPropagation(),className:"flex w-full items-center gap-1.5 rounded text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-800 dark:text-oai-gray-400 dark:hover:text-oai-gray-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[e.jsx(Mt,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",title:d,children:d}),e.jsx(Fe,{size:13,"aria-hidden":!0,className:`ml-auto transition-transform ${s?"rotate-180":""}`})]}),s?e.jsx("div",{ref:o,"data-limit-label-group":"",className:"mt-2 flex flex-col gap-1.5",style:l>0?{"--tt-limits-label-w":`${l}px`}:void 0,children:t.error?e.jsx(R,{tone:"error",children:r("shared.error.prefix",{error:t.error})}):e.jsxs(e.Fragment,{children:[e.jsx(ot,{rows:u,mode:a}),e.jsx(at,{rows:u,mode:a,now:i}),(t.buckets||[]).filter(x=>Number.isFinite(x.remaining_units)&&Number.isFinite(x.total_units)).map((x,g)=>e.jsx("div",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.zcode.grant_amount",{remaining:x.remaining_units.toLocaleString(U()),total:x.total_units.toLocaleString(U())})},x.entitlement_id||g))]})}):null]})}function xa(t,a,i,s,n,o,l=null,c=null,d=Date.now()){const u=re[t];if(!u)return null;const x=u.windows(a).filter(b=>b.window).map(b=>({spec:b,pace:Qe(b,s,d)})),g=lt(u.extra,a);return e.jsxs(rt,{name:i,providerId:t,expandable:x.length>0||!!c,expanded:n,onToggle:o,badge:l,rightAdornment:c?e.jsx(it,{subscription:c}):null,toggleOnHeader:t==="zcode",children:[e.jsx(ot,{mode:s,rows:x,extra:g}),c?e.jsx(nt,{subscription:c,now:d,mode:s}):null,n?e.jsx(at,{rows:x,mode:s,now:d}):null,n&&c?e.jsx(st,{subscription:c,now:d}):null,t==="zcode"&&a.start_plan?.configured?e.jsx(ma,{data:a.start_plan,mode:s,now:d}):null]},t)}function ge(t,a,i,s,n=null,o=Date.now(),l=w.USED){const c=!!n;return e.jsxs(rt,{name:ie(t),providerId:t,expandable:c,expanded:i,onToggle:s,rightAdornment:c?e.jsx(it,{subscription:n}):null,children:[a,c?e.jsx(nt,{subscription:n,now:o,mode:l}):null,c&&i?e.jsx("div",{className:"mt-1",children:e.jsx(st,{subscription:n,now:o})}):null]},t)}function pa(t,a,i,s,n,o=null,l=Date.now()){if(!re[t])return null;if(!a?.configured)return ge(t,e.jsxs(e.Fragment,{children:[e.jsx(R,{children:r("limits.status.not_connected")}),t==="opencodeGo"?e.jsx(Ce,{}):null,t==="commandCode"?e.jsx(Se,{}):null,t==="codingPlan"?e.jsx(Me,{}):null,t==="agentPlan"?e.jsx(De,{}):null,t==="devin"?e.jsx(Pe,{}):null]}),s,n,o,l,i);if(t==="opencodeGo"&&a.subscription_status==="inactive")return ge(t,e.jsx(R,{children:r("limits.opencodeGo.status.inactive")}),s,n,o,l,i);if(a.error)return ge(t,e.jsxs(e.Fragment,{children:[e.jsx(R,{tone:"error",children:r("shared.error.prefix",{error:a.error})}),t==="kiro"?lt(re.kiro.extra,a):null,t==="opencodeGo"?e.jsx(Ce,{}):null,t==="commandCode"?e.jsx(Se,{}):null,t==="codingPlan"?e.jsx(Me,{}):null,t==="agentPlan"?e.jsx(De,{}):null,t==="devin"?e.jsx(Pe,{}):null]}),s,n,o,l,i);const c=ie(t),d=a.plan_label?`${c} ${a.plan_label}`:c;let u=null;if(a.auth_action_required==="reauth"){const g=t==="commandCode"?Ze():t==="devin"?Je():sa[t];u=e.jsx(G,{label:r("limits.reauth.badge"),age:K(a.cached_at),tone:"stale",tooltip:g?r("limits.reauth.tooltip",{command:g}):null})}if(!u&&t==="antigravity")if(a.cached){const g=K(a.cached_at);u=e.jsx(G,{label:r("limits.label.antigravity_cached"),age:g,tone:"cached",tooltip:r("limits.tooltip.antigravity_cached")})}else u=e.jsx(G,{label:r("limits.label.antigravity_live"),tone:"live",tooltip:r("limits.tooltip.antigravity_live")});!u&&(t==="qoder"||t==="qoderCn")&&a.cached&&(u=e.jsx(G,{label:r("limits.label.antigravity_cached"),age:K(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.qoder_cached")})),!u&&(t==="codingPlan"||t==="agentPlan")&&a.cached&&(u=e.jsx(G,{label:r("limits.label.antigravity_cached"),age:K(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.ark_cached")}));const x=a.provenance;return x?.stale&&!u&&(u=e.jsx(G,{label:r("limits.provenance.stale"),age:K(x.captured_at),tone:"stale",tooltip:r("limits.provenance.tooltip",{source:x.source,confidence:x.confidence})})),xa(t,a,d,i,s,n,u,o,l)}function ga({defaultDir:t}){const[a,i]=p.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(`
4
- `),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 N({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 ye(){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 Ce(){const[t,a]=p.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(`
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.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(N,{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(ye,{})]})]}),e.jsx(N,{n:"2",children:e.jsx("div",{children:r("limits.opencodeGo.setupHint.step2")})}),e.jsxs(N,{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 Se(){const[t,a]=p.useState(!1),i=Xe(),s=Ze(),n=i==="windows"?r("limits.commandCode.setupHint.snippet_env_windows").replaceAll("\\n",`
1
+ import{o as Z,j as e,y as Re,c as r,h as U,r as p,al as xt,B as Y,bl as pt,V as N,e as gt,W as ve,R as ht,L as ft,bm as bt,t as yt,w as kt}from"./__vite-browser-external-DCy_YLfe.js";import{m as je}from"./react-DDOtS4Bd.js";import{P as re,c as vt,r as le,a as jt,u as wt,b as Nt,s as _t}from"./use-usage-limits-Nml-wUB-.js";import{b as k,c as He,l as ie,d as Ie,u as Ct}from"./use-limits-display-prefs-BdHDwBBC.js";import{C as Ae}from"./Card-lQmyKbh4.js";import{F as St}from"./FadeIn-DlyusE6n.js";import{P as Oe}from"./ProviderIcon-BF2Ch7wi.js";import{H as Pt}from"./HoverTooltip-v-zkCqsX.js";import{C as Fe}from"./chevron-down-BwvBVAOs.js";import{G as Mt}from"./gift-Ge11HK1x.js";import{C as Dt}from"./ConfirmModal-B8H5o8c_.js";import{I as we,L as Tt}from"./LocalOnlyNotice-BJSsmXF1.js";import{S as xe}from"./Select-idAiBnJG.js";import{P as Et}from"./plus-B4lFIyP8.js";import{P as Rt,a as Ht,b as It,c as At,d as Ot}from"./PopoverPopup-CqmvpYOi.js";import{u as Ft}from"./use-reduced-motion-HUGf223R.js";import"./use-latest-request-guard-DIEYrSzn.js";import"./DialogTitle-CduwXjqH.js";import"./composite-IIgJPPIw.js";import"./store-DfGPS2IR.js";import"./DialogDescription-vuQFBlM_.js";import"./arrow-up-right-CmdJ7gd7.js";import"./download-DxtH7w6a.js";import"./check-Dbubk4Il.js";import"./SelectItemText-DPmmPY_D.js";import"./usePositioner-B7vVQ7th.js";import"./safePolygon-BGfBVKoy.js";const Le={name:"bell-off",size:24,node:[["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"}]]};Le.node;const Lt=Z(Le);const $e={name:"bell",size:24,node:[["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"}]]};$e.node;const $t=Z($e);const Ue={name:"calendar-clock",size:24,node:[["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"}]]};Ue.node;const Be=Z(Ue);const ze={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};ze.node;const Ge=Z(ze);const We={name:"infinity",size:24,node:[["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"}]]};We.node;const qe=Z(We),Ut=[3,2,3,3,2,2,3];function L({className:t}){return e.jsx("div",{className:Re("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function Bt(){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-3 w-12 shrink-0"}),e.jsx(L,{className:"flex-1 h-1.5 rounded-full min-w-0"}),e.jsx(L,{className:"h-3 w-[30px] shrink-0"}),e.jsx(L,{className:"h-3 w-6 shrink-0"})]})}function zt({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(L,{className:"h-[14px] w-[14px] rounded shrink-0"}),e.jsx(L,{className:Re("h-4",i)})]}),Array.from({length:t},(s,n)=>e.jsx(Bt,{},n))]})}function Gt(){return e.jsx(Ae,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(L,{className:"h-3.5 w-28"}),Ut.map((t,a)=>e.jsx(zt,{bars:t,index:a},a))]})})}const fe=100;function Ne(t){const a=Date.parse(t);return Number.isFinite(a)?a:null}function Wt(t){return Math.max(0,Math.min(fe,Math.round(t)))}function qt(t){return new Intl.DateTimeFormat(U(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t))}function Vt(t,a,i){if(t==null||t>=a)return fe;const s=a-t,n=a-i;return Wt(n/s*fe)}function Yt(t){const a=t.available_count;return a===null?null:Number.isInteger(a)&&a>=0?a:void 0}function Kt(t,{now:a}={}){if(!t||typeof t!="object")return null;const i=Yt(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=Ne(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:qt(c),expiresMs:c,percent:Vt(Ne(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 X=864e5;function $(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 Ve(t,a){if(a==="weekly")return t-7*X;if(a==="yearly")return $(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 Ye(t,a){return a==="weekly"?t+7*X:a==="yearly"?$(t,12):$(t,1)}function Xt(t){if(t.startedAt!=null){const a=new Date(t.startedAt).getTime();if(Number.isFinite(a))return a}return Ve(new Date(t.nextBillingAt).getTime(),t.cycle)}function Zt(t,a,i){if(t.startedAt!=null){const s=new Date(t.startedAt).getTime();if(Number.isFinite(s))return s}return Ve(i,a)}function Jt(t,a,i){if(a==="weekly"){const c=7*X,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*X;let o=i<=t?0:Math.floor((i-t)/n);for(;o>0&&$(t,o*s)>i;)o-=1;let l=0;for(;$(t,(o+1)*s)<=i&&l<12e3;)o+=1,l+=1;return{startMs:$(t,o*s),endMs:$(t,(o+1)*s)}}function ne(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=Zt(t,s,i);if(!Number.isFinite(n))return null;let o,l,c=!1;t.autoRenew?{startMs:o,endMs:l}=Jt(n,s,a):t.startedAt!=null?(o=n,l=Ye(n,s),c=l<=a):(o=n,l=i,c=l<=a);const d=Math.max(1,l-o),u=c?1:Math.max(0,Math.min(1,(a-o)/d));return{endMs:l,startMs:o,progress:u,cycleDays:Math.max(1,Math.round(d/X)),expired:c}}function Ke(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 be(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 Qt="shrink-0 text-oai-black dark:text-oai-white";function Xe(){const t=typeof navigator>"u"?"":navigator.userAgent||"";return/Windows/i.test(t)?"windows":/Linux/i.test(t)?"linux":"macos"}function Ze(){return Xe()==="windows"?r("limits.commandCode.setupHint.snippet_login_windows"):r("limits.commandCode.setupHint.snippet_login")}function Je(){return r("limits.devin.setupHint.snippet_login")}function ea(t){const a=le(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 ta(t,a){const i=a===k.REMAINING?100-t:t;return i>=90?"bg-red-500":i>=70?"bg-amber-500":"bg-emerald-500"}function se(t,a="used_percent"){return t?a==="utilization"?t.utilization:t.used_percent:null}function ce(t,a="reset_at"){return t?a==="resets_at"?t.resets_at:t.reset_at:null}function pe(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 ae(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 aa(t){if(!t||typeof t!="object"||!(Number(t.limit_credits)>0))return null;const a={useGrouping:t.unit!=="calls"},i=ae(t.used_credits,a),s=ae(t.limit_credits,a),n=ae(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 Qe(t,a,i){return vt({usedPercent:se(t.window,t.pctField),windowSeconds:jt(t,t.window),resetMs:le(ce(t.window,t.resetField)),mode:a,now:i})}function oe(t){return Number.isFinite(t)?new Intl.DateTimeFormat(U(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):null}function ra(t,a,i){const s=[tt(t,a,i)],n=le(ce(t.window,t.resetField)),o=oe(n);o&&s.push(r(t.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:o}));const l=aa(t.window);return l&&s.push(l),s.join(`
2
+ `)}const et=Pt;function ia({label:t,pct:a,reset:i,mode:s=k.USED,pacePercent:n=null,paceOver:o=!1,title:l=null,share:c=!1}){const d=Math.max(0,Math.min(100,Number(a)||0)),u=!c&&s===k.REMAINING?100-d:d,x=c?k.USED:s,g=Math.round(u),b=u>0&&g===0?Math.max(u,.35):u;let v=String(g);u>0&&g===0&&(v=r("limits.bar.sub_one_percent"));const C=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(et,{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:`${ta(u,x)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${b}%`,minWidth:u>0?"3px":0}}),C!=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(${C}% - 3px)`,width:"6px"}}),e.jsx("div",{className:`absolute top-0 h-full ${o?"bg-red-500":"bg-emerald-500"}`,style:{left:`calc(${C}% - 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:[v,"%"]}),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 tt(t,a,i){const s=t.label??r(t.labelKey),n=i===k.REMAINING&&t.share!==!0,o=d=>n?100-d:d;if(a.expectedPercent==null){const d=Math.max(0,Math.min(100,Number(se(t.window,t.pctField))||0)),u=pe(o(d));return n?r("limits.explain.remaining",{label:s,used:u}):r("limits.explain.used",{label:s,used:u})}if(a.paceOver){if(a.runsOutEta)return r("limits.explain.ahead_eta",{label:s,eta:a.runsOutEta});const d=pe(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(se(t.window,t.pctField))||0)),c=pe(o(a.projectedEnd??l));return r(n?"limits.explain.on_track_remaining":"limits.explain.on_track",{label:s,pct:c})}function na({pace:t}){return t.pacePercent!=null}function at({rows:t,mode:a,now:i=Date.now()}){if(t.length===0)return null;const s=a===k.REMAINING,n=t.some(na);return e.jsxs("div",{className:"mt-1 flex flex-col gap-1",children:[t.map(({spec:o,pace:l})=>{const c=oe(le(ce(o.window,o.resetField)));return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-600 dark:text-oai-gray-300",children:[tt(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 K(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 _e={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"}},sa={claude:"claude",codex:"codex",antigravity:"agy"};function G({label:t,age:a=null,tone:i="live",tooltip:s=null}){const n=_e[i]||_e.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 rt({name:t,providerId:a,children:i,expandable:s=!1,expanded:n=!1,onToggle:o,badge:l=null,rightAdornment:c=null,toggleOnHeader:d=!1}){const u=Ie(a),x=e.jsxs("div",{className:"flex items-center gap-1.5",children:[u?e.jsx(Oe,{provider:u,size:14,className:Qt}):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?d?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("button",{type:"button","aria-expanded":n,onClick:o,className:"flex w-full items-center justify-between rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[x,e.jsx(Fe,{size:13,"aria-hidden":!0,className:`text-oai-gray-400 transition-transform ${n?"rotate-180":""}`})]}),i]}):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:[x,i]}):e.jsxs("div",{className:"flex flex-col gap-1.5",children:[x,i]})}function it({subscription:t}){const a=t.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),i=t.autoRenew?qe:Ge;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 nt({subscription:t,now:a,mode:i=k.USED}){const s=ne(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===k.REMAINING?100-c:c,u=o?100:Math.max(0,Math.min(100,d)),x=Math.round(u),g=u>0&&x===0?r("limits.bar.sub_one_percent"):`${x}%`;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:`${u}%`,minWidth:u>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:g}),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:Ke(n,a)})]})}function st({subscription:t,now:a}){const i=ne(t,a);if(!i)return null;const s=new Intl.DateTimeFormat(U(),{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:be(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 oa=He;function H({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 ot({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(ia,{label:n.label??r(n.labelKey),pct:se(n.window,n.pctField),reset:ea(ce(n.window,n.resetField)),mode:a,share:n.share===!0,pacePercent:o.pacePercent,paceOver:o.paceOver,title:ra(n,o,a)},n.key)),s?e.jsx(H,{children:r("limits.status.no_data")}):null,i]})}function la(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 ca({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(et,{text:la(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 da({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(ca,{row:i},i.key))]})}function ua({data:t}){const a=Date.now(),i=[{key:"five_hour",label:r("limits.label.zcode_5h")},{key:"weekly",label:r("limits.label.zcode_weekly")}].map(s=>({...s,cards:(t[s.key]||[]).filter(n=>Date.parse(n.expires_at)>a).slice().sort((n,o)=>Date.parse(n.expires_at)-Date.parse(o.expires_at))}));return e.jsxs("div",{className:"mt-1 flex flex-col gap-1.5",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.zcode.reset_bank.title")}),t.error?e.jsx(H,{tone:"error",children:r("shared.error.prefix",{error:t.error})}):i.map(s=>e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{"data-limit-label":"",className:"shrink-0 whitespace-nowrap text-oai-gray-500 dark:text-oai-gray-400",style:{width:"var(--tt-limits-label-w)"},children:s.label}),e.jsx("span",{className:"rounded-full bg-oai-gray-100 px-2 py-0.5 tabular-nums text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-300",children:r("limits.zcode.reset_bank.count",{count:s.cards.length})}),s.cards.length?e.jsx("span",{className:"ml-auto text-right text-[10px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500",title:s.cards.map(n=>oe(Date.parse(n.expires_at))).join(`
3
+ `),children:r("limits.zcode.reset_bank.earliest",{time:oe(Date.parse(s.cards[0].expires_at))})}):null]},s.key))]})}function lt(t,a){if(t==="zcode_reset_bank")return a.reset_credits?e.jsx(ua,{data:a.reset_credits}):null;if(t==="codex_meta"){const i=Kt(a.reset_credits);return i?e.jsx(da,{model:i}):null}if(t==="kimi_parallel"&&a.parallel_limit)return e.jsx(H,{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=ae(a.tracked_credits,{maximumFractionDigits:2});return e.jsx(H,{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(ga,{defaultDir:a.otel_default_dir}):null}function ma({data:t,mode:a,now:i}){const[s,n]=p.useState(!1),o=p.useRef(null),l=ct(o),c=[...new Set((t.buckets||[]).map(x=>x.plan_name).filter(Boolean))],d=c.length?c.join(" · "):r("limits.zcode.start_grants"),u=re.zcode.windows(t).filter(x=>x.window).map(x=>({spec:x,pace:Qe(x,a,i)}));return e.jsxs("div",{className:"mt-2 border-t border-oai-gray-200/60 pt-2 dark:border-oai-gray-800",children:[e.jsxs("button",{type:"button","aria-expanded":s,onClick:x=>{x.stopPropagation(),n(g=>!g)},onKeyDown:x=>x.stopPropagation(),className:"flex w-full items-center gap-1.5 rounded text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-800 dark:text-oai-gray-400 dark:hover:text-oai-gray-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[e.jsx(Mt,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",title:d,children:d}),e.jsx(Fe,{size:13,"aria-hidden":!0,className:`ml-auto transition-transform ${s?"rotate-180":""}`})]}),s?e.jsx("div",{ref:o,"data-limit-label-group":"",className:"mt-2 flex flex-col gap-1.5",style:l>0?{"--tt-limits-label-w":`${l}px`}:void 0,children:t.error?e.jsx(H,{tone:"error",children:r("shared.error.prefix",{error:t.error})}):e.jsxs(e.Fragment,{children:[e.jsx(ot,{rows:u,mode:a}),e.jsx(at,{rows:u,mode:a,now:i}),(t.buckets||[]).filter(x=>Number.isFinite(x.remaining_units)&&Number.isFinite(x.total_units)).map((x,g)=>e.jsx("div",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.zcode.grant_amount",{remaining:x.remaining_units.toLocaleString(U()),total:x.total_units.toLocaleString(U())})},x.entitlement_id||g))]})}):null]})}function xa(t,a,i,s,n,o,l=null,c=null,d=Date.now()){const u=re[t];if(!u)return null;const x=u.windows(a).filter(b=>b.window).map(b=>({spec:b,pace:Qe(b,s,d)})),g=lt(u.extra,a);return e.jsxs(rt,{name:i,providerId:t,expandable:x.length>0||!!c,expanded:n,onToggle:o,badge:l,rightAdornment:c?e.jsx(it,{subscription:c}):null,toggleOnHeader:t==="zcode",children:[e.jsx(ot,{mode:s,rows:x,extra:g}),c?e.jsx(nt,{subscription:c,now:d,mode:s}):null,n?e.jsx(at,{rows:x,mode:s,now:d}):null,n&&c?e.jsx(st,{subscription:c,now:d}):null,t==="zcode"&&a.start_plan?.configured?e.jsx(ma,{data:a.start_plan,mode:s,now:d}):null]},t)}function ge(t,a,i,s,n=null,o=Date.now(),l=k.USED){const c=!!n;return e.jsxs(rt,{name:ie(t),providerId:t,expandable:c,expanded:i,onToggle:s,rightAdornment:c?e.jsx(it,{subscription:n}):null,children:[a,c?e.jsx(nt,{subscription:n,now:o,mode:l}):null,c&&i?e.jsx("div",{className:"mt-1",children:e.jsx(st,{subscription:n,now:o})}):null]},t)}function pa(t,a,i,s,n,o=null,l=Date.now()){if(!re[t])return null;if(!a?.configured)return ge(t,e.jsxs(e.Fragment,{children:[e.jsx(H,{children:r("limits.status.not_connected")}),t==="opencodeGo"?e.jsx(Ce,{}):null,t==="commandCode"?e.jsx(Se,{}):null,t==="codingPlan"?e.jsx(Me,{}):null,t==="agentPlan"?e.jsx(De,{}):null,t==="devin"?e.jsx(Pe,{}):null]}),s,n,o,l,i);if(t==="opencodeGo"&&a.subscription_status==="inactive")return ge(t,e.jsx(H,{children:r("limits.opencodeGo.status.inactive")}),s,n,o,l,i);if(a.error)return ge(t,e.jsxs(e.Fragment,{children:[e.jsx(H,{tone:"error",children:r("shared.error.prefix",{error:a.error})}),t==="kiro"?lt(re.kiro.extra,a):null,t==="opencodeGo"?e.jsx(Ce,{}):null,t==="commandCode"?e.jsx(Se,{}):null,t==="codingPlan"?e.jsx(Me,{}):null,t==="agentPlan"?e.jsx(De,{}):null,t==="devin"?e.jsx(Pe,{}):null]}),s,n,o,l,i);const c=ie(t),d=a.plan_label?`${c} ${a.plan_label}`:c;let u=null;if(a.auth_action_required==="reauth"){const g=t==="commandCode"?Ze():t==="devin"?Je():sa[t];u=e.jsx(G,{label:r("limits.reauth.badge"),age:K(a.cached_at),tone:"stale",tooltip:g?r("limits.reauth.tooltip",{command:g}):null})}if(!u&&t==="antigravity")if(a.cached){const g=K(a.cached_at);u=e.jsx(G,{label:r("limits.label.antigravity_cached"),age:g,tone:"cached",tooltip:r("limits.tooltip.antigravity_cached")})}else u=e.jsx(G,{label:r("limits.label.antigravity_live"),tone:"live",tooltip:r("limits.tooltip.antigravity_live")});!u&&(t==="qoder"||t==="qoderCn")&&a.cached&&(u=e.jsx(G,{label:r("limits.label.antigravity_cached"),age:K(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.qoder_cached")})),!u&&(t==="codingPlan"||t==="agentPlan")&&a.cached&&(u=e.jsx(G,{label:r("limits.label.antigravity_cached"),age:K(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.ark_cached")}));const x=a.provenance;return x?.stale&&!u&&(u=e.jsx(G,{label:r("limits.provenance.stale"),age:K(x.captured_at),tone:"stale",tooltip:r("limits.provenance.tooltip",{source:x.source,confidence:x.confidence})})),xa(t,a,d,i,s,n,u,o,l)}function ga({defaultDir:t}){const[a,i]=p.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(`
4
+ `),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 _({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 ye(){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 Ce(){const[t,a]=p.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(`
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.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(_,{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(ye,{})]})]}),e.jsx(_,{n:"2",children:e.jsx("div",{children:r("limits.opencodeGo.setupHint.step2")})}),e.jsxs(_,{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 Se(){const[t,a]=p.useState(!1),i=Xe(),s=Ze(),n=i==="windows"?r("limits.commandCode.setupHint.snippet_env_windows").replaceAll("\\n",`
6
6
  `):[r("limits.commandCode.setupHint.snippet_read"),r("limits.commandCode.setupHint.snippet_export"),...i==="macos"?[r("limits.commandCode.setupHint.snippet_setenv")]:[]].join(`
7
- `),o=async l=>{l.stopPropagation();try{await navigator.clipboard.writeText(n),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.commandCode.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.commandCode.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(N,{n:"1",children:[e.jsx("div",{children:r("limits.commandCode.setupHint.step1")}),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:s})]}),e.jsxs(N,{n:"2",children:[e.jsx("div",{children:r("limits.commandCode.setupHint.step2")}),e.jsx("div",{className:"mt-1.5 flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:o,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.commandCode.setupHint.copied"):r("limits.commandCode.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:n}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:i==="windows"?r("limits.commandCode.setupHint.note_windows"):i==="linux"?r("limits.commandCode.setupHint.note_linux"):r("limits.commandCode.setupHint.note_app")})]})]})]})}function Pe(){const t=Je();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.devin.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.devin.setupHint.subtitle")}),e.jsx("ol",{className:"mt-2.5 space-y-2.5",children:e.jsxs(N,{n:"1",children:[e.jsx("div",{children:r("limits.devin.setupHint.step1")}),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:t}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.devin.setupHint.note")})]})})]})}function Me(){const[t,a]=p.useState(!1),i=["npm install -g @volcengine/ark-cli","arkcli auth login volc-sso # browser SSO (recommended)","arkcli auth status # verify the session"].join(`
8
- `),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(N,{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(ye,{})]})]}),e.jsxs(N,{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(N,{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 De(){const[t,a]=p.useState(!1),i=[r("limits.agentPlan.setupHint.snippet_install"),r("limits.agentPlan.setupHint.snippet_login"),r("limits.agentPlan.setupHint.snippet_status")].join(`
9
- `),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(N,{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(ye,{})]})]}),e.jsxs(N,{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(N,{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 ct(t){const[a,i]=p.useState(0);return p.useLayoutEffect(()=>{const s=t.current;if(!s)return;const n=[...s.querySelectorAll("[data-limit-label]")].filter(d=>d.closest("[data-limit-label-group]")===s);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 u of n)o=Math.max(o,l.measureText(u.textContent).width)}const c=Math.ceil(o);i(d=>d===c?d:c)}),a}function ha({claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:u,opencodeGo:x,commandCode:g,qoder:b,qoderCn:P,codingPlan:A,agentPlan:C,devin:k,order:S,visibility:_,displayMode:O,subscriptions:W=[],showSubscriptions:M=!0}){const D={claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:u,opencodeGo:x,commandCode:g,qoder:b,qoderCn:P,codingPlan:A,agentPlan:C,devin:k},B=p.useRef(null),T=ct(B),[de,J]=p.useState(null),[E,Q]=p.useState(()=>Date.now()),ue=Array.isArray(S)&&S.length>0?S:oa,ee=O===w.REMAINING?w.REMAINING:w.USED,me=ee===w.REMAINING?r("limits.settings.display_mode_remaining"):r("limits.settings.display_mode_used");p.useEffect(()=>{const f=setInterval(()=>Q(Date.now()),6e4);return()=>clearInterval(f)},[]);const F=new Map;if(M)for(const f of W||[]){if(!f?.provider)continue;const H=new Date(f.nextBillingAt).getTime();if(!Number.isFinite(H))continue;const te=F.get(f.provider);if(!te){F.set(f.provider,f);continue}const I=new Date(te.nextBillingAt).getTime(),V=H>E,m=I>E;(V&&(!m||I>H)||!V&&!m&&H>I)&&F.set(f.provider,f)}const q=ue.filter(f=>!_||_[f]!==!1||F.has(f)).map(f=>pa(f,D[f],ee,de===f,()=>J(H=>H===f?null:f),F.get(f)||null,E)).filter(Boolean);return e.jsx(St,{delay:.15,children:e.jsx(Ae,{children:e.jsxs("div",{ref:B,"data-limit-label-group":"",className:"flex flex-col gap-3",style:T>0?{"--tt-limits-label-w":`${T}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"),me]}),q.length>0?q:e.jsx(R,{children:r("limits.status.all_hidden")})]})})})}async function dt(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 fa(){const t=await fetch("/functions/tokentracker-subscription-manager",{headers:{Accept:"application/json"},cache:"no-store"}),a=await dt(t);return Array.isArray(a.subscriptions)?a.subscriptions:[]}async function ke(t){const a=await xt();return dt(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 ba(t){return ke({action:"create",subscription:t})}function ya(t,a){return ke({action:"update",id:t,subscription:a})}function ka(t){return ke({action:"delete",id:t})}const he={plan:"",provider:"",cycle:"monthly",autoRenew:!0,startedAt:""};function va(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 ja({subscriptions:t,onChanged:a}){const[i,s]=p.useState(!1),[n,o]=p.useState(null),[l,c]=p.useState(he),[d,u]=p.useState(!1),[x,g]=p.useState(!1),[b,P]=p.useState(!1),[A,C]=p.useState(!1),[k,S]=p.useState(null),[_,O]=p.useState(!1),[W,M]=p.useState(!1),[D,B]=p.useState(null),[T,de]=p.useState(()=>Date.now()),J=p.useRef(null),E=U(),Q=p.useMemo(()=>new Intl.DateTimeFormat(E,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),[E]);p.useEffect(()=>{const m=setInterval(()=>de(Date.now()),6e4);return()=>clearInterval(m)},[]),p.useEffect(()=>{if(!i)return;const m=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;J.current?.scrollIntoView?.({behavior:m?"auto":"smooth",block:"nearest"})},[i,n]);const ue=p.useMemo(()=>He.map(m=>{const v=(t||[]).some(y=>y.provider===m&&y.id!==n),h=ie(m);return{value:m,label:v?`${h} ${r("subscriptions.form.provider_taken_suffix")}`:h,disabled:v}}),[E,t,n]),ee=p.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")}],[E]),me=p.useMemo(()=>[{value:"true",label:r("subscriptions.form.auto_renew_on")},{value:"false",label:r("subscriptions.form.auto_renew_off")}],[E]),F=p.useCallback(()=>{c(he),o(null),g(!1),P(!1),C(!1),s(!0)},[]),q=p.useCallback(m=>{c({plan:m.plan||"",provider:m.provider||"",cycle:m.cycle||"monthly",autoRenew:m.autoRenew,startedAt:va(new Date(Xt(m)).toISOString())}),o(m.id),g(!1),P(!1),C(!1),s(!0)},[]),f=p.useCallback(()=>{s(!1),o(null),c(he),g(!1),P(!1),C(!1)},[]),H=p.useCallback(async m=>{if(m.preventDefault(),g(!1),!l.provider){P(!0);return}if((t||[]).some(z=>z.provider===l.provider&&z.id!==n)){C(!0);return}const h=new Date(l.startedAt).getTime();if(!Number.isFinite(h)){g(!0);return}const y={service:ie(l.provider),plan:l.plan,provider:l.provider||null,autoRenew:l.autoRenew,cycle:l.cycle,startedAt:h,nextBillingAt:Ye(h,l.cycle)};u(!0);try{n?await ya(n,y):await ba(y),f(),await a?.()}catch{g(!0)}finally{u(!1)}},[f,n,l,a,t]),te=p.useCallback(async()=>{if(k){O(!0),M(!1);try{await ka(k.id),k.id===n&&f(),S(null),await a?.()}catch{M(!0)}finally{O(!1)}}},[f,n,a,k]),I=t||[],V=()=>{const m=n?I.find(h=>h.id===n):null,v=m?ne(m,T):null;return e.jsxs("form",{ref:J,onSubmit:H,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:m.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:Q.format(new Date(v.endMs))})," · ",e.jsx("span",{className:v.expired?"text-oai-error":void 0,children:be(v.endMs,T)})]}):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(xe,{id:"subscription-provider",value:l.provider,onValueChange:h=>c({...l,provider:String(h)}),options:ue,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-1",children:e.jsx(we,{label:r("subscriptions.form.plan"),value:l.plan,maxLength:120,placeholder:r("subscriptions.form.plan_placeholder"),onChange:h=>c({...l,plan:h.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(xe,{id:"subscription-cycle",value:l.cycle,onValueChange:h=>c({...l,cycle:String(h)}),options:ee,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(xe,{id:"subscription-auto-renew",value:String(l.autoRenew),onValueChange:h=>c({...l,autoRenew:h==="true"}),options:me,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(we,{label:r("subscriptions.form.started_at"),type:"datetime-local",value:l.startedAt,required:!0,onChange:h=>c({...l,startedAt:h.target.value})})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 sm:col-span-2",children:[n?e.jsx(Y,{type:"button",variant:"secondary",size:"sm",onClick:()=>{const h=I.find(y=>y.id===n);h&&S(h)},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,A?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_taken")}):null,x?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.error")}):null,e.jsx(Y,{type:"button",variant:"secondary",size:"sm",onClick:f,children:r("shared.action.cancel")}),e.jsx(Y,{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(Y,{type:"button",size:"sm",onClick:F,className:"shrink-0 gap-1.5",children:[e.jsx(Et,{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(Be,{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(m=>{const v=ne(m,T);if(!v)return null;const{endMs:h,expired:y}=v,z=y?100:v.progress*100,ut=!y&&h-T<=3*864e5,mt=D===m.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:()=>q(m),"aria-label":`${r("subscriptions.edit")} ${m.service}`,"aria-expanded":n===m.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(Oe,{provider:Ie(m.provider)||"OTHER",size:14}),e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-white truncate",children:m.service}),e.jsx("span",{role:"img","aria-label":m.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),title:m.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),className:`inline-flex shrink-0 translate-y-px ${m.autoRenew?"text-oai-brand-600 dark:text-oai-brand-400":"text-blue-600 dark:text-blue-400"}`,children:m.autoRenew?e.jsx(qe,{size:14,strokeWidth:2,"aria-hidden":!0}):e.jsx(Ge,{size:14,strokeWidth:2,"aria-hidden":!0})}),m.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:m.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":ut?"bg-amber-500":"bg-blue-500"} rounded-full h-full block transition-[width] duration-500 ease-out`,style:{width:`${z}%`,minWidth:z>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:Ke(h,T)})]})]}),n===m.id?e.jsx("div",{className:"border-t border-oai-gray-100 dark:border-oai-gray-800",children:V()}):null,n!==m.id&&mt?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:m.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:Q.format(new Date(h))})," · ",e.jsx("span",{className:y?"text-oai-error":void 0,children:be(h,T)})," · ",e.jsx("span",{children:m.autoRenew?r("subscriptions.status.auto_renew"):r("subscriptions.status.manual")})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(Y,{type:"button",variant:"secondary",size:"sm",onClick:()=>q(m),children:r("subscriptions.edit")})})]}):null]},m.id)}),i&&!n?e.jsx("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:V()}):null]}),e.jsx(Dt,{open:!!k,title:r("subscriptions.confirm_delete_title"),description:k?.service||"",error:W?r("subscriptions.delete_error"):null,confirmLabel:r("subscriptions.delete"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:_,onCancel:()=>{S(null),M(!1)},onConfirm:te})]})}const Te=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),wa="x-apple.systempreferences:com.apple.preference.notifications";function Ee(t){const a=Date.parse(t);return Number.isFinite(a)?new Intl.DateTimeFormat(U(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(a)):String(t)}function Na(t){const a=Object.entries(t||{}).filter(([o,l])=>o!=="fetched_at"&&l&&typeof l=="object"&&l.configured!==!1),i=a.filter(([,o])=>!!o.error),s=a.some(([,o])=>!!o.start_plan?.error||!!o.reset_credits?.error),n=a.filter(([,o])=>o.provenance?.stale===!0||o.provenance?.source==="disk-cache");return a.length&&i.length===0&&!s&&n.length===a.length?{kind:"stale"}:i.length||n.length||s?{kind:"partial",at:t.fetched_at}:{kind:"updated",at:t.fetched_at}}function _a(){const t=Ft(),a=yt(),i=r("limits.alert.blocked"),s=a?je.button:je.div;return e.jsxs(s,{type:a?"button":void 0,onClick:a?()=>kt({type:"action",name:"openURL",value:wa}):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 Qa(){const t=pt(),{data:a,error:i,isLoading:s,refresh:n}=wt(t?{initialRefresh:!0,initialState:t,publishToPreloadCache:!0}:{initialRefresh:!0,publishToPreloadCache:!0}),o=Ct(),l=Nt(),[c,d]=j.useState([]),[u,x]=j.useState(!1),[g,b]=j.useState(!1),[P]=gt(),A=j.useRef(0),C=j.useRef(!1),[k,S]=j.useState(!1),[_,O]=j.useState(null),W=j.useCallback(async()=>{if(!C.current){C.current=!0,S(!0),O(null);try{const D=await n();O(D?Na(D):{kind:"failed"})}finally{C.current=!1,S(!1)}}},[n]),M=j.useCallback(async()=>{if(!Te&&!ve())return;const D=++A.current;try{const B=await fa();if(D!==A.current)return;d(B),x(!1)}catch{if(D!==A.current)return;x(!0)}},[]);return j.useEffect(()=>{M()},[M]),j.useEffect(()=>{P.get("openSubscriptions")==="1"&&b(!0)},[P]),j.useEffect(()=>{l.enabled&&a&&_t(a)},[l.enabled,a]),!Te&&!ve()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(Tt,{})}):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:[l.enabled&&l.permissionBlocked?e.jsx(_a,{}):null,e.jsx("button",{type:"button",onClick:()=>{W()},disabled:k,"aria-label":r("limits.page.refresh"),title:r("limits.page.refresh"),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 disabled:opacity-50",children:e.jsx(ht,{className:`h-4 w-4 ${k?"animate-spin":""}`,"aria-hidden":!0})}),e.jsxs(Rt,{open:g,onOpenChange:b,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(Be,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(It,{children:e.jsx(At,{side:"bottom",align:"end",sideOffset:8,className:"z-50",children:e.jsx(Ot,{children:e.jsx(ja,{subscriptions:c,onChanged:M})})})})]}),e.jsx("button",{type:"button",onClick:()=>{l.setEnabled(!l.enabled)},"aria-label":l.enabled?r("limits.alert.disable"):r("limits.alert.enable"),title:l.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 ${l.enabled&&l.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:l.enabled?e.jsx($t,{className:"h-4 w-4","aria-hidden":!0}):e.jsx(Lt,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(ft,{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(bt,{className:"h-4 w-4","aria-hidden":!0})})]})]}),e.jsx("span",{role:"status",className:"sr-only",children:k?r("limits.page.refresh_loading"):""}),_?.kind==="updated"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-emerald-700 dark:text-emerald-300",children:r("limits.page.refreshed_at",{time:Ee(_.at)})}):null,_?.kind==="partial"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("limits.page.refresh_partial",{time:Ee(_.at)})}):null,_?.kind==="stale"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("limits.page.refresh_stale")}):null,_?.kind==="failed"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("limits.page.refresh_failed")}):null,s?e.jsx(Gt,{}):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,u?e.jsx("p",{className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("subscriptions.load_error")}):null,e.jsx(ha,{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,commandCode:a?.commandCode,qoder:a?.qoder,qoderCn:a?.qoderCn,codingPlan:a?.codingPlan,agentPlan:a?.agentPlan,devin:a?.devin,order:o.order,visibility:o.visibility,displayMode:o.displayMode,subscriptions:c,showSubscriptions:o.showSubscriptions!==!1})]})]})})})}export{Qa as LimitsPage};
7
+ `),o=async l=>{l.stopPropagation();try{await navigator.clipboard.writeText(n),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.commandCode.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.commandCode.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(_,{n:"1",children:[e.jsx("div",{children:r("limits.commandCode.setupHint.step1")}),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:s})]}),e.jsxs(_,{n:"2",children:[e.jsx("div",{children:r("limits.commandCode.setupHint.step2")}),e.jsx("div",{className:"mt-1.5 flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:o,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.commandCode.setupHint.copied"):r("limits.commandCode.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:n}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:i==="windows"?r("limits.commandCode.setupHint.note_windows"):i==="linux"?r("limits.commandCode.setupHint.note_linux"):r("limits.commandCode.setupHint.note_app")})]})]})]})}function Pe(){const t=Je();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.devin.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.devin.setupHint.subtitle")}),e.jsx("ol",{className:"mt-2.5 space-y-2.5",children:e.jsxs(_,{n:"1",children:[e.jsx("div",{children:r("limits.devin.setupHint.step1")}),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:t}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.devin.setupHint.note")})]})})]})}function Me(){const[t,a]=p.useState(!1),i=["npm install -g @volcengine/ark-cli","arkcli auth login volc-sso # browser SSO (recommended)","arkcli auth status # verify the session"].join(`
8
+ `),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(_,{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(ye,{})]})]}),e.jsxs(_,{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(_,{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 De(){const[t,a]=p.useState(!1),i=[r("limits.agentPlan.setupHint.snippet_install"),r("limits.agentPlan.setupHint.snippet_login"),r("limits.agentPlan.setupHint.snippet_status")].join(`
9
+ `),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(_,{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(ye,{})]})]}),e.jsxs(_,{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(_,{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 ct(t){const[a,i]=p.useState(0);return p.useLayoutEffect(()=>{const s=t.current;if(!s)return;const n=[...s.querySelectorAll("[data-limit-label]")].filter(d=>d.closest("[data-limit-label-group]")===s);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 u of n)o=Math.max(o,l.measureText(u.textContent).width)}const c=Math.ceil(o);i(d=>d===c?d:c)}),a}function ha({claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:u,opencodeGo:x,commandCode:g,qoder:b,qoderCn:v,codingPlan:C,agentPlan:P,devin:j,order:M,visibility:S,displayMode:O,subscriptions:W=[],showSubscriptions:D=!0}){const T={claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:u,opencodeGo:x,commandCode:g,qoder:b,qoderCn:v,codingPlan:C,agentPlan:P,devin:j},B=p.useRef(null),E=ct(B),[de,J]=p.useState(null),[R,Q]=p.useState(()=>Date.now()),ue=Array.isArray(M)&&M.length>0?M:oa,ee=O===k.REMAINING?k.REMAINING:k.USED,me=ee===k.REMAINING?r("limits.settings.display_mode_remaining"):r("limits.settings.display_mode_used");p.useEffect(()=>{const f=setInterval(()=>Q(Date.now()),6e4);return()=>clearInterval(f)},[]);const F=new Map;if(D)for(const f of W||[]){if(!f?.provider)continue;const I=new Date(f.nextBillingAt).getTime();if(!Number.isFinite(I))continue;const te=F.get(f.provider);if(!te){F.set(f.provider,f);continue}const A=new Date(te.nextBillingAt).getTime(),V=I>R,m=A>R;(V&&(!m||A>I)||!V&&!m&&I>A)&&F.set(f.provider,f)}const q=ue.filter(f=>!S||S[f]!==!1||F.has(f)).map(f=>pa(f,T[f],ee,de===f,()=>J(I=>I===f?null:f),F.get(f)||null,R)).filter(Boolean);return e.jsx(St,{delay:.15,children:e.jsx(Ae,{children:e.jsxs("div",{ref:B,"data-limit-label-group":"",className:"flex flex-col gap-3",style:E>0?{"--tt-limits-label-w":`${E}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"),me]}),q.length>0?q:e.jsx(H,{children:r("limits.status.all_hidden")})]})})})}async function dt(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 fa(){const t=await fetch("/functions/tokentracker-subscription-manager",{headers:{Accept:"application/json"},cache:"no-store"}),a=await dt(t);return Array.isArray(a.subscriptions)?a.subscriptions:[]}async function ke(t){const a=await xt();return dt(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 ba(t){return ke({action:"create",subscription:t})}function ya(t,a){return ke({action:"update",id:t,subscription:a})}function ka(t){return ke({action:"delete",id:t})}const he={plan:"",provider:"",cycle:"monthly",autoRenew:!0,startedAt:""};function va(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 ja({subscriptions:t,onChanged:a}){const[i,s]=p.useState(!1),[n,o]=p.useState(null),[l,c]=p.useState(he),[d,u]=p.useState(!1),[x,g]=p.useState(!1),[b,v]=p.useState(!1),[C,P]=p.useState(!1),[j,M]=p.useState(null),[S,O]=p.useState(!1),[W,D]=p.useState(!1),[T,B]=p.useState(null),[E,de]=p.useState(()=>Date.now()),J=p.useRef(null),R=U(),Q=p.useMemo(()=>new Intl.DateTimeFormat(R,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),[R]);p.useEffect(()=>{const m=setInterval(()=>de(Date.now()),6e4);return()=>clearInterval(m)},[]),p.useEffect(()=>{if(!i)return;const m=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;J.current?.scrollIntoView?.({behavior:m?"auto":"smooth",block:"nearest"})},[i,n]);const ue=p.useMemo(()=>He.map(m=>{const w=(t||[]).some(y=>y.provider===m&&y.id!==n),h=ie(m);return{value:m,label:w?`${h} ${r("subscriptions.form.provider_taken_suffix")}`:h,disabled:w}}),[R,t,n]),ee=p.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")}],[R]),me=p.useMemo(()=>[{value:"true",label:r("subscriptions.form.auto_renew_on")},{value:"false",label:r("subscriptions.form.auto_renew_off")}],[R]),F=p.useCallback(()=>{c(he),o(null),g(!1),v(!1),P(!1),s(!0)},[]),q=p.useCallback(m=>{c({plan:m.plan||"",provider:m.provider||"",cycle:m.cycle||"monthly",autoRenew:m.autoRenew,startedAt:va(new Date(Xt(m)).toISOString())}),o(m.id),g(!1),v(!1),P(!1),s(!0)},[]),f=p.useCallback(()=>{s(!1),o(null),c(he),g(!1),v(!1),P(!1)},[]),I=p.useCallback(async m=>{if(m.preventDefault(),g(!1),!l.provider){v(!0);return}if((t||[]).some(z=>z.provider===l.provider&&z.id!==n)){P(!0);return}const h=new Date(l.startedAt).getTime();if(!Number.isFinite(h)){g(!0);return}const y={service:ie(l.provider),plan:l.plan,provider:l.provider||null,autoRenew:l.autoRenew,cycle:l.cycle,startedAt:h,nextBillingAt:Ye(h,l.cycle)};u(!0);try{n?await ya(n,y):await ba(y),f(),await a?.()}catch{g(!0)}finally{u(!1)}},[f,n,l,a,t]),te=p.useCallback(async()=>{if(j){O(!0),D(!1);try{await ka(j.id),j.id===n&&f(),M(null),await a?.()}catch{D(!0)}finally{O(!1)}}},[f,n,a,j]),A=t||[],V=()=>{const m=n?A.find(h=>h.id===n):null,w=m?ne(m,E):null;return e.jsxs("form",{ref:J,onSubmit:I,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")})}),w?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:m.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:Q.format(new Date(w.endMs))})," · ",e.jsx("span",{className:w.expired?"text-oai-error":void 0,children:be(w.endMs,E)})]}):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(xe,{id:"subscription-provider",value:l.provider,onValueChange:h=>c({...l,provider:String(h)}),options:ue,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-1",children:e.jsx(we,{label:r("subscriptions.form.plan"),value:l.plan,maxLength:120,placeholder:r("subscriptions.form.plan_placeholder"),onChange:h=>c({...l,plan:h.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(xe,{id:"subscription-cycle",value:l.cycle,onValueChange:h=>c({...l,cycle:String(h)}),options:ee,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(xe,{id:"subscription-auto-renew",value:String(l.autoRenew),onValueChange:h=>c({...l,autoRenew:h==="true"}),options:me,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(we,{label:r("subscriptions.form.started_at"),type:"datetime-local",value:l.startedAt,required:!0,onChange:h=>c({...l,startedAt:h.target.value})})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 sm:col-span-2",children:[n?e.jsx(Y,{type:"button",variant:"secondary",size:"sm",onClick:()=>{const h=A.find(y=>y.id===n);h&&M(h)},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,C?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_taken")}):null,x?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.error")}):null,e.jsx(Y,{type:"button",variant:"secondary",size:"sm",onClick:f,children:r("shared.action.cancel")}),e.jsx(Y,{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(Y,{type:"button",size:"sm",onClick:F,className:"shrink-0 gap-1.5",children:[e.jsx(Et,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:r("subscriptions.add")})]})]}),A.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(Be,{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:[A.map(m=>{const w=ne(m,E);if(!w)return null;const{endMs:h,expired:y}=w,z=y?100:w.progress*100,ut=!y&&h-E<=3*864e5,mt=T===m.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:()=>q(m),"aria-label":`${r("subscriptions.edit")} ${m.service}`,"aria-expanded":n===m.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(Oe,{provider:Ie(m.provider)||"OTHER",size:14}),e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-white truncate",children:m.service}),e.jsx("span",{role:"img","aria-label":m.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),title:m.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),className:`inline-flex shrink-0 translate-y-px ${m.autoRenew?"text-oai-brand-600 dark:text-oai-brand-400":"text-blue-600 dark:text-blue-400"}`,children:m.autoRenew?e.jsx(qe,{size:14,strokeWidth:2,"aria-hidden":!0}):e.jsx(Ge,{size:14,strokeWidth:2,"aria-hidden":!0})}),m.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:m.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":ut?"bg-amber-500":"bg-blue-500"} rounded-full h-full block transition-[width] duration-500 ease-out`,style:{width:`${z}%`,minWidth:z>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:Ke(h,E)})]})]}),n===m.id?e.jsx("div",{className:"border-t border-oai-gray-100 dark:border-oai-gray-800",children:V()}):null,n!==m.id&&mt?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:m.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:Q.format(new Date(h))})," · ",e.jsx("span",{className:y?"text-oai-error":void 0,children:be(h,E)})," · ",e.jsx("span",{children:m.autoRenew?r("subscriptions.status.auto_renew"):r("subscriptions.status.manual")})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(Y,{type:"button",variant:"secondary",size:"sm",onClick:()=>q(m),children:r("subscriptions.edit")})})]}):null]},m.id)}),i&&!n?e.jsx("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:V()}):null]}),e.jsx(Dt,{open:!!j,title:r("subscriptions.confirm_delete_title"),description:j?.service||"",error:W?r("subscriptions.delete_error"):null,confirmLabel:r("subscriptions.delete"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:S,onCancel:()=>{M(null),D(!1)},onConfirm:te})]})}const Te=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),wa="x-apple.systempreferences:com.apple.preference.notifications";function Ee(t){const a=Date.parse(t);return Number.isFinite(a)?new Intl.DateTimeFormat(U(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(a)):String(t)}function Na(t){const a=Object.entries(t||{}).filter(([o,l])=>o!=="fetched_at"&&l&&typeof l=="object"&&l.configured!==!1),i=a.filter(([,o])=>!!o.error),s=a.some(([,o])=>!!o.start_plan?.error||!!o.reset_credits?.error),n=a.filter(([,o])=>o.provenance?.stale===!0||o.provenance?.source==="disk-cache");return a.length&&i.length===0&&!s&&n.length===a.length?{kind:"stale"}:i.length||n.length||s?{kind:"partial",at:t.fetched_at}:{kind:"updated",at:t.fetched_at}}function _a(){const t=Ft(),a=yt(),i=r("limits.alert.blocked"),s=a?je.button:je.div;return e.jsxs(s,{type:a?"button":void 0,onClick:a?()=>kt({type:"action",name:"openURL",value:wa}):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 Qa(){const t=pt(),{data:a,error:i,isLoading:s,refresh:n}=wt(t?{initialRefresh:!0,initialState:t,publishToPreloadCache:!0}:{initialRefresh:!0,publishToPreloadCache:!0}),o=Ct(),l=Nt(),[c,d]=N.useState([]),[u,x]=N.useState(!1),[g,b]=N.useState(!1),[v]=gt(),C=N.useRef(0),P=N.useRef(!1),[j,M]=N.useState(!1),[S,O]=N.useState(null),W=N.useCallback(async()=>{if(!P.current){P.current=!0,M(!0),O(null);try{const T=await n();O(T?Na(T):{kind:"failed"})}finally{P.current=!1,M(!1)}}},[n]),D=N.useCallback(async()=>{if(!Te&&!ve())return;const T=++C.current;try{const B=await fa();if(T!==C.current)return;d(B),x(!1)}catch{if(T!==C.current)return;x(!0)}},[]);return N.useEffect(()=>{D()},[D]),N.useEffect(()=>{v.get("openSubscriptions")==="1"&&b(!0)},[v]),N.useEffect(()=>{l.enabled&&a&&_t(a)},[l.enabled,a]),!Te&&!ve()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(Tt,{})}):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:[l.enabled&&l.permissionBlocked?e.jsx(_a,{}):null,e.jsx("button",{type:"button",onClick:()=>{W()},disabled:j,"aria-label":r("limits.page.refresh"),title:r("limits.page.refresh"),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 disabled:opacity-50",children:e.jsx(ht,{className:`h-4 w-4 ${j?"animate-spin":""}`,"aria-hidden":!0})}),e.jsxs(Rt,{open:g,onOpenChange:b,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(Be,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(It,{children:e.jsx(At,{side:"bottom",align:"end",sideOffset:8,className:"z-50",children:e.jsx(Ot,{children:e.jsx(ja,{subscriptions:c,onChanged:D})})})})]}),e.jsx("button",{type:"button",onClick:()=>{l.setEnabled(!l.enabled)},"aria-label":l.enabled?r("limits.alert.disable"):r("limits.alert.enable"),title:l.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 ${l.enabled&&l.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:l.enabled?e.jsx($t,{className:"h-4 w-4","aria-hidden":!0}):e.jsx(Lt,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(ft,{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(bt,{className:"h-4 w-4","aria-hidden":!0})})]})]}),e.jsx("span",{role:"status",className:"sr-only",children:j?r("limits.page.refresh_loading"):""}),S?.kind==="updated"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-emerald-700 dark:text-emerald-300",children:r("limits.page.refreshed_at",{time:Ee(S.at)})}):null,S?.kind==="partial"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("limits.page.refresh_partial",{time:Ee(S.at)})}):null,S?.kind==="stale"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("limits.page.refresh_stale")}):null,S?.kind==="failed"?e.jsx("p",{role:"status",className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("limits.page.refresh_failed")}):null,s?e.jsx(Gt,{}):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,u?e.jsx("p",{className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("subscriptions.load_error")}):null,e.jsx(ha,{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,commandCode:a?.commandCode,qoder:a?.qoder,qoderCn:a?.qoderCn,codingPlan:a?.codingPlan,agentPlan:a?.agentPlan,devin:a?.devin,order:o.order,visibility:o.visibility,displayMode:o.displayMode,subscriptions:c,showSubscriptions:o.showSubscriptions!==!1})]})]})})})}export{Qa as LimitsPage};
@@ -1 +1 @@
1
- import{r as h,j as e,c as r}from"./__vite-browser-external-BZ-i40Kf.js";import{A as p}from"./arrow-up-right-CCMEqQQp.js";import{D as b}from"./download-BJ7CKwx5.js";function I({id:t,value:l,onChange:d,placeholder:c,disabled:i=!1,type:x="text",label:s,error:a,className:g="",...m}){const y=h.useId(),o=t||y,n=a?`${o}-error`:void 0,u=`w-full bg-oai-white dark:bg-oai-gray-900 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md text-oai-black dark:text-oai-white placeholder-oai-gray-400 dark:placeholder-oai-gray-500 transition-all duration-200 focus:outline-none focus:border-oai-brand dark:focus:border-oai-brand focus:ring-1 focus:ring-oai-brand/30 ${i?"bg-oai-gray-50 dark:bg-oai-gray-800 text-oai-gray-400 dark:text-oai-gray-400 cursor-not-allowed":""} ${a?"border-oai-error focus:border-oai-error focus:ring-oai-error/30":""} h-10 px-3 text-sm ${g}`;return e.jsxs("div",{className:"w-full",children:[s&&e.jsx("label",{htmlFor:o,className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5 transition-colors duration-200",children:s}),e.jsx("input",{id:o,type:x,value:l,onChange:d,placeholder:c,disabled:i,"aria-invalid":a?!0:void 0,"aria-describedby":n,className:u,...m}),a&&e.jsx("p",{id:n,className:"mt-1.5 text-sm text-oai-error",children:a})]})}const f="https://github.com/xiufengsun/TokenTracker/releases/latest";function _(){const t=()=>{try{window.location.href="tokentracker://open"}catch{}};return e.jsx("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-20 text-center",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("h2",{className:"text-lg font-semibold text-oai-black dark:text-white",children:r("local_only.title")}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r("local_only.body")}),e.jsxs("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-3",children:[e.jsxs("button",{type:"button",onClick:t,className:"inline-flex h-9 items-center gap-1.5 rounded-full px-4 text-sm font-medium bg-oai-gray-900 text-white hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 transition-colors",children:[e.jsx("span",{children:r("local_only.open_app")}),e.jsx(p,{size:14,strokeWidth:2,"aria-hidden":!0})]}),e.jsxs("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-9 items-center gap-1.5 rounded-full px-4 text-sm font-medium ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-900 transition-colors",children:[e.jsx(b,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:r("local_only.download")})]})]})]})})}export{I,_ as L};
1
+ import{r as h,j as e,c as r}from"./__vite-browser-external-DCy_YLfe.js";import{A as p}from"./arrow-up-right-CmdJ7gd7.js";import{D as b}from"./download-DxtH7w6a.js";function I({id:t,value:l,onChange:d,placeholder:c,disabled:i=!1,type:x="text",label:s,error:a,className:g="",...m}){const y=h.useId(),o=t||y,n=a?`${o}-error`:void 0,u=`w-full bg-oai-white dark:bg-oai-gray-900 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md text-oai-black dark:text-oai-white placeholder-oai-gray-400 dark:placeholder-oai-gray-500 transition-all duration-200 focus:outline-none focus:border-oai-brand dark:focus:border-oai-brand focus:ring-1 focus:ring-oai-brand/30 ${i?"bg-oai-gray-50 dark:bg-oai-gray-800 text-oai-gray-400 dark:text-oai-gray-400 cursor-not-allowed":""} ${a?"border-oai-error focus:border-oai-error focus:ring-oai-error/30":""} h-10 px-3 text-sm ${g}`;return e.jsxs("div",{className:"w-full",children:[s&&e.jsx("label",{htmlFor:o,className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5 transition-colors duration-200",children:s}),e.jsx("input",{id:o,type:x,value:l,onChange:d,placeholder:c,disabled:i,"aria-invalid":a?!0:void 0,"aria-describedby":n,className:u,...m}),a&&e.jsx("p",{id:n,className:"mt-1.5 text-sm text-oai-error",children:a})]})}const f="https://github.com/xiufengsun/TokenTracker/releases/latest";function _(){const t=()=>{try{window.location.href="tokentracker://open"}catch{}};return e.jsx("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-20 text-center",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("h2",{className:"text-lg font-semibold text-oai-black dark:text-white",children:r("local_only.title")}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r("local_only.body")}),e.jsxs("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-3",children:[e.jsxs("button",{type:"button",onClick:t,className:"inline-flex h-9 items-center gap-1.5 rounded-full px-4 text-sm font-medium bg-oai-gray-900 text-white hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 transition-colors",children:[e.jsx("span",{children:r("local_only.open_app")}),e.jsx(p,{size:14,strokeWidth:2,"aria-hidden":!0})]}),e.jsxs("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-9 items-center gap-1.5 rounded-full px-4 text-sm font-medium ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-900 transition-colors",children:[e.jsx(b,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:r("local_only.download")})]})]})]})})}export{I,_ as L};
@@ -1 +1 @@
1
- import{o as be,Z as ye,a as fe,r as o,q as pe,$ as we,c as a,j as e,y as b}from"./__vite-browser-external-BZ-i40Kf.js";import{A as ke}from"./arrow-left-BrQrZJtW.js";const oe={name:"mail",size:24,node:[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]};oe.node;const ve=be(oe),je=e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1Z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23Z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18A10.96 10.96 0 0 0 1 12c0 1.77.42 3.44 1.18 4.93l3.66-2.84Z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53Z",fill:"#EA4335"})]}),Ne=e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12Z"})}),_e={google:je,github:Ne},Ce={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",apple:"Apple"};function Ae(n){return Ce[n]||String(n||"").replace(/-/g," ")}function Pe(n){if(typeof n=="string"&&n.trim())return n.trim();if(n&&typeof n=="object"){if(typeof n.token=="string"&&n.token.trim())return n.token.trim();if(typeof n.otp=="string"&&n.otp.trim())return n.otp.trim()}return""}function Le({title:n,subtitle:H,className:se="",onSuccess:S,oauthReturnPath:Z,hideTitle:ie=!1,hideLogo:G=!1,initialMode:f="signin",tokenFromUrl:E="",initialEmail:p="",initialCode:v=""}){ye();const{enabled:w,configurationError:ne,connectionHost:T,signedIn:j,refreshUser:L,signInWithPassword:V,signUp:U,signInWithOAuth:W,getPublicAuthConfig:$,sendResetPasswordEmail:z,exchangeResetPasswordToken:J,resetPassword:K}=fe(),[l,m]=o.useState(f),[g,k]=o.useState(p),[x,N]=o.useState(""),[O,q]=o.useState(""),[F,le]=o.useState(""),[I,Q]=o.useState(v),[_,h]=o.useState(!1),[X,s]=o.useState(null),[C,y]=o.useState(null),[M,R]=o.useState(!1),[de,ce]=o.useState(!!(f!=="signin"||p)),[A,Y]=o.useState(!0),[P,ee]=o.useState([]),[re,ge]=o.useState(8);o.useEffect(()=>{f&&m(f)},[f]),o.useEffect(()=>{p&&k(p)},[p]),o.useEffect(()=>{v&&Q(v)},[v]),o.useEffect(()=>{if(!w)return;let r=!0;return Y(!0),(async()=>{const{data:t,error:i}=await $();if(!r)return;const c=t&&typeof t=="object"&&!Array.isArray(t)&&Array.isArray(t.oAuthProviders)&&t.oAuthProviders.every(d=>typeof d=="string"&&d.length>0)&&(t.customOAuthProviders===void 0||Array.isArray(t.customOAuthProviders)&&t.customOAuthProviders.every(d=>typeof d=="string"&&d.length>0));if(i||!c)ee(["google","github"]);else{const d=t.oAuthProviders,he=Array.isArray(t.customOAuthProviders)?t.customOAuthProviders:[];ee([...d,...he]),typeof t.passwordMinLength=="number"&&t.passwordMinLength>0&&ge(t.passwordMinLength)}Y(!1)})(),()=>{r=!1}},[w,$]),o.useEffect(()=>{j&&S&&S()},[j,S]);const ae=o.useCallback(()=>typeof window>"u"?"":pe()?"tokentracker://auth/callback":`${window.location.origin}/`,[]),te=o.useMemo(()=>typeof window>"u"?"/reset-password":`${window.location.origin}/reset-password`,[]),B=o.useCallback(async r=>{s(null),h(!0);try{const t=we(Z);if(t)try{window.sessionStorage.setItem("tt.cloud.return",t)}catch{}const{error:i}=await W(r,ae());i&&s(i.message||String(i))}finally{h(!1)}},[W,ae,Z]);o.useEffect(()=>{if(!w||A||j||typeof window>"u")return;const r=window.location.search;if(!r)return;const t=new URLSearchParams(r),i=t.get("native")==="1",c=t.get("provider");i&&c&&[...P].includes(c)&&B(c)},[w,A,j,P,B]);const ue=o.useCallback(async r=>{r.preventDefault(),s(null),h(!0);try{if(l==="signup"){const{data:i,error:c}=await U({email:g.trim(),password:x,name:F.trim()||void 0});if(c){s(c.message||String(c));return}if(i?.requireEmailVerification){y(a("login.verify_email_pending")),m("signin");return}await L();return}const{error:t}=await V({email:g.trim(),password:x});if(t){s(t.message||String(t));return}await L()}finally{h(!1)}},[l,g,x,F,U,V,L]),me=o.useCallback(async r=>{r.preventDefault(),s(null),h(!0);try{const t=g.trim(),{error:i}=await z({email:t,redirectTo:te});if(i){s(i.message||String(i));return}k(t),y(a("reset_password.request.sent")),m("reset_confirm")}finally{h(!1)}},[g,te,z]),xe=o.useCallback(async r=>{if(r.preventDefault(),s(null),x!==O){s(a("reset_password.error.password_mismatch"));return}h(!0);try{let t=E;if(!t){const{data:c,error:d}=await J({email:g.trim(),code:I.trim()});if(d){s(d.message||String(d));return}if(t=Pe(c),!t){s(a("reset_password.error.missing_token"));return}}const{error:i}=await K({newPassword:x,otp:t});if(i){s(i.message||String(i));return}R(!0),y(a("reset_password.success"))}finally{h(!1)}},[I,O,g,J,x,K,E]);if(!w)return ne?e.jsx("p",{role:"alert",className:"p-4 text-sm leading-6 text-oai-gray-700 dark:text-oai-gray-300",children:a("instance.configuration.invalid")}):null;const u=l==="reset_email"||l==="reset_confirm",D=A||!!P.length;return e.jsxs("div",{className:b("w-full bg-white dark:bg-oai-gray-950 p-6 transition-colors duration-200",se),children:[u&&e.jsxs("button",{type:"button",onClick:()=>{m("signin"),y(null),s(null),R(!1),N(""),q("")},className:"flex items-center gap-1.5 text-xs font-medium text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors mb-4 focus:outline-none",children:[e.jsx(ke,{className:"h-3.5 w-3.5"}),a("reset_password.back_to_sign_in")]}),e.jsxs("div",{className:b("mb-6",u?"text-left":"text-center"),children:[!G&&!u&&e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx("img",{src:"/app-icon.png",alt:"",width:28,height:28,className:"rounded-md"}),e.jsx("span",{className:"text-lg font-semibold text-oai-black dark:text-white font-oai tracking-tight",children:a("shared.app_name")})]}),!ie||u?e.jsx("h2",{className:b("text-sm font-semibold text-oai-black dark:text-white tracking-tight mb-1",(G||u)&&"text-base font-bold md:text-lg"),children:u?a("reset_password.title"):n||a("login_modal.subtitle")}):null,!u&&H&&e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1.5 leading-relaxed max-w-[320px] mx-auto",children:H}),u&&e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1.5 leading-relaxed max-w-[320px]",children:C&&l==="reset_confirm"&&!M?C:a("reset_password.subtitle")})]}),T?e.jsx("p",{className:"mb-4 text-center text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:a("instance.connection.destination",{host:T})}):null,C&&(!u||M)&&e.jsx("div",{className:"mb-4 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900/50 px-3 py-2 text-xs text-oai-gray-700 dark:text-oai-gray-300",children:C}),X&&e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400 text-center",role:"alert",children:X}),l==="reset_email"&&e.jsxs("form",{onSubmit:me,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-reset-email",type:"email",autoComplete:"email",required:!0,value:g,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:a("reset_password.request.submit")})]}),l==="reset_confirm"&&(M?e.jsx("button",{type:"button",onClick:()=>{m("signin"),R(!1),y(null),s(null),N(""),q("")},className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors text-center shadow-sm",children:a("reset_password.success_cta")}):e.jsxs("form",{onSubmit:xe,className:"space-y-3",children:[!E&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-email-confirm",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-reset-email-confirm",type:"email",autoComplete:"email",required:!0,value:g,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-code",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.code")}),e.jsx("input",{id:"card-reset-code",type:"text",inputMode:"numeric",autoComplete:"one-time-code",required:!0,value:I,onChange:r=>Q(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.new_password")}),e.jsx("input",{id:"card-reset-password",type:"password",autoComplete:"new-password",required:!0,minLength:8,value:x,onChange:r=>N(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-password-confirm",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.confirm_password")}),e.jsx("input",{id:"card-reset-password-confirm",type:"password",autoComplete:"new-password",required:!0,minLength:8,value:O,onChange:r=>q(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:a("reset_password.reset.submit")})]})),!u&&e.jsxs(e.Fragment,{children:[D?e.jsx("div",{className:"space-y-2.5 mb-5",children:A?e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900/50 animate-pulse"}),e.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900/50 animate-pulse"})]}):P.map(r=>e.jsxs("button",{type:"button",disabled:_,onClick:()=>B(r),className:b("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors disabled:opacity-50","flex items-center justify-center gap-2.5"),children:[_e[r]||null,a("login.oauth.continue",{provider:Ae(r)})]},r))}):null,de?e.jsxs(e.Fragment,{children:[D?e.jsxs("div",{className:"relative mb-5",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:a("login_modal.divider_email")})})]}):null,e.jsxs("div",{className:"flex rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 bg-oai-gray-50 dark:bg-oai-gray-900/50 mb-4",children:[e.jsx("button",{type:"button",className:b("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",l==="signin"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{m("signin"),s(null)},children:a("login.tab.sign_in")}),e.jsx("button",{type:"button",className:b("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",l==="signup"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{m("signup"),s(null)},children:a("login.tab.sign_up")})]}),e.jsxs("form",{onSubmit:ue,className:"space-y-3",children:[l==="signup"&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.name")}),e.jsx("input",{id:"card-name",type:"text",autoComplete:"name",value:F,onChange:r=>le(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500",placeholder:a("login.field.name_placeholder")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-email",type:"email",autoComplete:"email",required:!0,value:g,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.password")}),e.jsx("input",{id:"card-password",type:"password",autoComplete:l==="signup"?"new-password":"current-password",required:!0,minLength:l==="signup"?re:void 0,value:x,onChange:r=>N(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"}),l==="signup"&&e.jsx("p",{className:"mt-1 text-xs text-oai-gray-400 dark:text-oai-gray-600",children:a("login.password_hint",{min:String(re)})}),l==="signin"&&e.jsx("div",{className:"mt-1 text-right",children:e.jsx("button",{type:"button",onClick:()=>{m("reset_email"),s(null),y(null)},className:"text-xs font-medium text-oai-gray-500 hover:text-oai-black dark:hover:text-white no-underline bg-transparent border-0 p-0 cursor-pointer focus:outline-none",children:a("login.forgot_password")})})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:l==="signup"?a("login.submit.sign_up"):a("login.submit.sign_in")})]})]}):e.jsxs(e.Fragment,{children:[D?e.jsxs("div",{className:"relative mb-5",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:a("login.divider")})})]}):null,e.jsxs("button",{type:"button",onClick:()=>ce(!0),className:b("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors","flex items-center justify-center gap-2.5"),children:[e.jsx(ve,{className:"h-[18px] w-[18px] text-oai-gray-500 dark:text-oai-gray-400",strokeWidth:1.75}),a("login_modal.continue_email")]})]})]})]})}export{Le as L};
1
+ import{o as be,Z as ye,a as fe,r as o,q as pe,$ as we,c as a,j as e,y as b}from"./__vite-browser-external-DCy_YLfe.js";import{A as ke}from"./arrow-left-DycYjE-k.js";const oe={name:"mail",size:24,node:[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]};oe.node;const ve=be(oe),je=e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1Z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23Z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18A10.96 10.96 0 0 0 1 12c0 1.77.42 3.44 1.18 4.93l3.66-2.84Z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53Z",fill:"#EA4335"})]}),Ne=e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12Z"})}),_e={google:je,github:Ne},Ce={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",apple:"Apple"};function Ae(n){return Ce[n]||String(n||"").replace(/-/g," ")}function Pe(n){if(typeof n=="string"&&n.trim())return n.trim();if(n&&typeof n=="object"){if(typeof n.token=="string"&&n.token.trim())return n.token.trim();if(typeof n.otp=="string"&&n.otp.trim())return n.otp.trim()}return""}function Le({title:n,subtitle:H,className:se="",onSuccess:S,oauthReturnPath:Z,hideTitle:ie=!1,hideLogo:G=!1,initialMode:f="signin",tokenFromUrl:E="",initialEmail:p="",initialCode:v=""}){ye();const{enabled:w,configurationError:ne,connectionHost:T,signedIn:j,refreshUser:L,signInWithPassword:V,signUp:U,signInWithOAuth:W,getPublicAuthConfig:$,sendResetPasswordEmail:z,exchangeResetPasswordToken:J,resetPassword:K}=fe(),[l,m]=o.useState(f),[g,k]=o.useState(p),[x,N]=o.useState(""),[O,q]=o.useState(""),[F,le]=o.useState(""),[I,Q]=o.useState(v),[_,h]=o.useState(!1),[X,s]=o.useState(null),[C,y]=o.useState(null),[M,R]=o.useState(!1),[de,ce]=o.useState(!!(f!=="signin"||p)),[A,Y]=o.useState(!0),[P,ee]=o.useState([]),[re,ge]=o.useState(8);o.useEffect(()=>{f&&m(f)},[f]),o.useEffect(()=>{p&&k(p)},[p]),o.useEffect(()=>{v&&Q(v)},[v]),o.useEffect(()=>{if(!w)return;let r=!0;return Y(!0),(async()=>{const{data:t,error:i}=await $();if(!r)return;const c=t&&typeof t=="object"&&!Array.isArray(t)&&Array.isArray(t.oAuthProviders)&&t.oAuthProviders.every(d=>typeof d=="string"&&d.length>0)&&(t.customOAuthProviders===void 0||Array.isArray(t.customOAuthProviders)&&t.customOAuthProviders.every(d=>typeof d=="string"&&d.length>0));if(i||!c)ee(["google","github"]);else{const d=t.oAuthProviders,he=Array.isArray(t.customOAuthProviders)?t.customOAuthProviders:[];ee([...d,...he]),typeof t.passwordMinLength=="number"&&t.passwordMinLength>0&&ge(t.passwordMinLength)}Y(!1)})(),()=>{r=!1}},[w,$]),o.useEffect(()=>{j&&S&&S()},[j,S]);const ae=o.useCallback(()=>typeof window>"u"?"":pe()?"tokentracker://auth/callback":`${window.location.origin}/`,[]),te=o.useMemo(()=>typeof window>"u"?"/reset-password":`${window.location.origin}/reset-password`,[]),B=o.useCallback(async r=>{s(null),h(!0);try{const t=we(Z);if(t)try{window.sessionStorage.setItem("tt.cloud.return",t)}catch{}const{error:i}=await W(r,ae());i&&s(i.message||String(i))}finally{h(!1)}},[W,ae,Z]);o.useEffect(()=>{if(!w||A||j||typeof window>"u")return;const r=window.location.search;if(!r)return;const t=new URLSearchParams(r),i=t.get("native")==="1",c=t.get("provider");i&&c&&[...P].includes(c)&&B(c)},[w,A,j,P,B]);const ue=o.useCallback(async r=>{r.preventDefault(),s(null),h(!0);try{if(l==="signup"){const{data:i,error:c}=await U({email:g.trim(),password:x,name:F.trim()||void 0});if(c){s(c.message||String(c));return}if(i?.requireEmailVerification){y(a("login.verify_email_pending")),m("signin");return}await L();return}const{error:t}=await V({email:g.trim(),password:x});if(t){s(t.message||String(t));return}await L()}finally{h(!1)}},[l,g,x,F,U,V,L]),me=o.useCallback(async r=>{r.preventDefault(),s(null),h(!0);try{const t=g.trim(),{error:i}=await z({email:t,redirectTo:te});if(i){s(i.message||String(i));return}k(t),y(a("reset_password.request.sent")),m("reset_confirm")}finally{h(!1)}},[g,te,z]),xe=o.useCallback(async r=>{if(r.preventDefault(),s(null),x!==O){s(a("reset_password.error.password_mismatch"));return}h(!0);try{let t=E;if(!t){const{data:c,error:d}=await J({email:g.trim(),code:I.trim()});if(d){s(d.message||String(d));return}if(t=Pe(c),!t){s(a("reset_password.error.missing_token"));return}}const{error:i}=await K({newPassword:x,otp:t});if(i){s(i.message||String(i));return}R(!0),y(a("reset_password.success"))}finally{h(!1)}},[I,O,g,J,x,K,E]);if(!w)return ne?e.jsx("p",{role:"alert",className:"p-4 text-sm leading-6 text-oai-gray-700 dark:text-oai-gray-300",children:a("instance.configuration.invalid")}):null;const u=l==="reset_email"||l==="reset_confirm",D=A||!!P.length;return e.jsxs("div",{className:b("w-full bg-white dark:bg-oai-gray-950 p-6 transition-colors duration-200",se),children:[u&&e.jsxs("button",{type:"button",onClick:()=>{m("signin"),y(null),s(null),R(!1),N(""),q("")},className:"flex items-center gap-1.5 text-xs font-medium text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors mb-4 focus:outline-none",children:[e.jsx(ke,{className:"h-3.5 w-3.5"}),a("reset_password.back_to_sign_in")]}),e.jsxs("div",{className:b("mb-6",u?"text-left":"text-center"),children:[!G&&!u&&e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx("img",{src:"/app-icon.png",alt:"",width:28,height:28,className:"rounded-md"}),e.jsx("span",{className:"text-lg font-semibold text-oai-black dark:text-white font-oai tracking-tight",children:a("shared.app_name")})]}),!ie||u?e.jsx("h2",{className:b("text-sm font-semibold text-oai-black dark:text-white tracking-tight mb-1",(G||u)&&"text-base font-bold md:text-lg"),children:u?a("reset_password.title"):n||a("login_modal.subtitle")}):null,!u&&H&&e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1.5 leading-relaxed max-w-[320px] mx-auto",children:H}),u&&e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 mt-1.5 leading-relaxed max-w-[320px]",children:C&&l==="reset_confirm"&&!M?C:a("reset_password.subtitle")})]}),T?e.jsx("p",{className:"mb-4 text-center text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:a("instance.connection.destination",{host:T})}):null,C&&(!u||M)&&e.jsx("div",{className:"mb-4 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900/50 px-3 py-2 text-xs text-oai-gray-700 dark:text-oai-gray-300",children:C}),X&&e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400 text-center",role:"alert",children:X}),l==="reset_email"&&e.jsxs("form",{onSubmit:me,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-reset-email",type:"email",autoComplete:"email",required:!0,value:g,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:a("reset_password.request.submit")})]}),l==="reset_confirm"&&(M?e.jsx("button",{type:"button",onClick:()=>{m("signin"),R(!1),y(null),s(null),N(""),q("")},className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors text-center shadow-sm",children:a("reset_password.success_cta")}):e.jsxs("form",{onSubmit:xe,className:"space-y-3",children:[!E&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-email-confirm",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-reset-email-confirm",type:"email",autoComplete:"email",required:!0,value:g,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-code",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.code")}),e.jsx("input",{id:"card-reset-code",type:"text",inputMode:"numeric",autoComplete:"one-time-code",required:!0,value:I,onChange:r=>Q(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.new_password")}),e.jsx("input",{id:"card-reset-password",type:"password",autoComplete:"new-password",required:!0,minLength:8,value:x,onChange:r=>N(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-reset-password-confirm",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("reset_password.field.confirm_password")}),e.jsx("input",{id:"card-reset-password-confirm",type:"password",autoComplete:"new-password",required:!0,minLength:8,value:O,onChange:r=>q(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:a("reset_password.reset.submit")})]})),!u&&e.jsxs(e.Fragment,{children:[D?e.jsx("div",{className:"space-y-2.5 mb-5",children:A?e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900/50 animate-pulse"}),e.jsx("div",{className:"h-10 rounded-lg bg-oai-gray-100 dark:bg-oai-gray-900/50 animate-pulse"})]}):P.map(r=>e.jsxs("button",{type:"button",disabled:_,onClick:()=>B(r),className:b("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors disabled:opacity-50","flex items-center justify-center gap-2.5"),children:[_e[r]||null,a("login.oauth.continue",{provider:Ae(r)})]},r))}):null,de?e.jsxs(e.Fragment,{children:[D?e.jsxs("div",{className:"relative mb-5",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:a("login_modal.divider_email")})})]}):null,e.jsxs("div",{className:"flex rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 bg-oai-gray-50 dark:bg-oai-gray-900/50 mb-4",children:[e.jsx("button",{type:"button",className:b("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",l==="signin"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{m("signin"),s(null)},children:a("login.tab.sign_in")}),e.jsx("button",{type:"button",className:b("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",l==="signup"?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300"),onClick:()=>{m("signup"),s(null)},children:a("login.tab.sign_up")})]}),e.jsxs("form",{onSubmit:ue,className:"space-y-3",children:[l==="signup"&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-name",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.name")}),e.jsx("input",{id:"card-name",type:"text",autoComplete:"name",value:F,onChange:r=>le(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500",placeholder:a("login.field.name_placeholder")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-email",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.email")}),e.jsx("input",{id:"card-email",type:"email",autoComplete:"email",required:!0,value:g,onChange:r=>k(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"card-password",className:"block text-xs font-medium text-oai-gray-500 mb-1",children:a("login.field.password")}),e.jsx("input",{id:"card-password",type:"password",autoComplete:l==="signup"?"new-password":"current-password",required:!0,minLength:l==="signup"?re:void 0,value:x,onChange:r=>N(r.target.value),className:"w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 bg-oai-gray-50 dark:bg-oai-gray-900 px-3 text-sm text-oai-black dark:text-white placeholder-oai-gray-400 dark:placeholder-oai-gray-600 focus:outline-none focus:ring-2 focus:ring-oai-brand-500"}),l==="signup"&&e.jsx("p",{className:"mt-1 text-xs text-oai-gray-400 dark:text-oai-gray-600",children:a("login.password_hint",{min:String(re)})}),l==="signin"&&e.jsx("div",{className:"mt-1 text-right",children:e.jsx("button",{type:"button",onClick:()=>{m("reset_email"),s(null),y(null)},className:"text-xs font-medium text-oai-gray-500 hover:text-oai-black dark:hover:text-white no-underline bg-transparent border-0 p-0 cursor-pointer focus:outline-none",children:a("login.forgot_password")})})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full h-10 rounded-lg bg-oai-gray-900 dark:bg-white text-white dark:text-oai-gray-950 text-sm font-semibold hover:bg-oai-gray-800 dark:hover:bg-oai-gray-100 transition-colors disabled:opacity-50",children:l==="signup"?a("login.submit.sign_up"):a("login.submit.sign_in")})]})]}):e.jsxs(e.Fragment,{children:[D?e.jsxs("div",{className:"relative mb-5",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t border-oai-gray-200 dark:border-oai-gray-800"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase tracking-wider",children:e.jsx("span",{className:"bg-white dark:bg-oai-gray-950 px-3 text-oai-gray-400 dark:text-oai-gray-600",children:a("login.divider")})})]}):null,e.jsxs("button",{type:"button",onClick:()=>ce(!0),className:b("w-full h-10 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700 bg-oai-gray-50 dark:bg-oai-gray-900 text-sm font-medium text-oai-black dark:text-white","hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:border-oai-gray-300 dark:hover:border-oai-gray-600 transition-colors","flex items-center justify-center gap-2.5"),children:[e.jsx(ve,{className:"h-[18px] w-[18px] text-oai-gray-500 dark:text-oai-gray-400",strokeWidth:1.75}),a("login_modal.continue_email")]})]})]})]})}export{Le as L};
@@ -1 +1 @@
1
- import{u as p,a as x,r as l,j as a,c as o,X as y}from"./__vite-browser-external-BZ-i40Kf.js";import{L as m}from"./LoginCard-E5E3i2kj.js";import{D as h,a as b,b as f,c as j,d as k,e as v}from"./DialogTitle-CiiRTn3_.js";import{D as w}from"./DialogDescription-BOYDS1mM.js";import"./arrow-left-BrQrZJtW.js";import"./composite-CUuXvKos.js";import"./store-CJFdru_6.js";function E(){const{isOpen:c,request:t,closeLoginModal:i,completeLoginModal:s}=p(),{enabled:d,configurationError:r}=x(),e=t?.id,n=l.useCallback(()=>i(e),[i,e]),g=l.useCallback(()=>{s(e)},[s,e]);return a.jsx(h,{open:c,onOpenChange:u=>{u||n()},children:a.jsxs(b,{children:[a.jsx(f,{className:"fixed inset-0 z-[100] bg-black/40 transition-opacity duration-200 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0 dark:bg-black/60"}),a.jsx(j,{className:"fixed inset-0 z-[101] flex items-center justify-center overflow-y-auto overscroll-contain p-4",children:a.jsxs(k,{className:"relative max-h-[calc(100dvh-2rem)] w-full max-w-[420px] overflow-y-auto overscroll-contain rounded-2xl border border-oai-gray-200 bg-white shadow-2xl transition-[opacity,transform] duration-200 data-[ending-style]:translate-y-2 data-[ending-style]:scale-[0.95] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-2 data-[starting-style]:scale-[0.95] data-[starting-style]:opacity-0 motion-reduce:transition-none dark:border-oai-gray-800 dark:bg-oai-gray-950",children:[a.jsx(v,{className:"sr-only",children:o("login.title")}),t?.subtitle?a.jsx(w,{className:"sr-only",children:t.subtitle}):null,a.jsx("button",{type:"button",onClick:n,"aria-label":o("shared.dialog.close"),className:"absolute right-2 top-2 z-10 flex h-11 w-11 items-center justify-center rounded-md text-oai-gray-400 transition-colors hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-500 dark:hover:text-white",children:a.jsx(y,{className:"h-5 w-5","aria-hidden":!0})}),d?a.jsx(m,{title:t?.nextPath?o("login.title"):void 0,hideTitle:!0,subtitle:t?.subtitle,oauthReturnPath:t?.nextPath,onSuccess:g,className:"p-6 bg-transparent"},e):a.jsx("p",{role:r?"alert":"status",className:"p-6 pt-14 text-sm leading-6 text-oai-gray-700 dark:text-oai-gray-300",children:o(r?"instance.configuration.invalid":"login.cloud_only")})]})})]})})}export{E as LoginModal};
1
+ import{u as p,a as x,r as l,j as a,c as o,X as y}from"./__vite-browser-external-DCy_YLfe.js";import{L as m}from"./LoginCard-Dggv2aGv.js";import{D as h,a as b,b as f,c as j,d as k,e as v}from"./DialogTitle-CduwXjqH.js";import{D as w}from"./DialogDescription-vuQFBlM_.js";import"./arrow-left-DycYjE-k.js";import"./composite-IIgJPPIw.js";import"./store-DfGPS2IR.js";function E(){const{isOpen:c,request:t,closeLoginModal:i,completeLoginModal:s}=p(),{enabled:d,configurationError:r}=x(),e=t?.id,n=l.useCallback(()=>i(e),[i,e]),g=l.useCallback(()=>{s(e)},[s,e]);return a.jsx(h,{open:c,onOpenChange:u=>{u||n()},children:a.jsxs(b,{children:[a.jsx(f,{className:"fixed inset-0 z-[100] bg-black/40 transition-opacity duration-200 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0 dark:bg-black/60"}),a.jsx(j,{className:"fixed inset-0 z-[101] flex items-center justify-center overflow-y-auto overscroll-contain p-4",children:a.jsxs(k,{className:"relative max-h-[calc(100dvh-2rem)] w-full max-w-[420px] overflow-y-auto overscroll-contain rounded-2xl border border-oai-gray-200 bg-white shadow-2xl transition-[opacity,transform] duration-200 data-[ending-style]:translate-y-2 data-[ending-style]:scale-[0.95] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-2 data-[starting-style]:scale-[0.95] data-[starting-style]:opacity-0 motion-reduce:transition-none dark:border-oai-gray-800 dark:bg-oai-gray-950",children:[a.jsx(v,{className:"sr-only",children:o("login.title")}),t?.subtitle?a.jsx(w,{className:"sr-only",children:t.subtitle}):null,a.jsx("button",{type:"button",onClick:n,"aria-label":o("shared.dialog.close"),className:"absolute right-2 top-2 z-10 flex h-11 w-11 items-center justify-center rounded-md text-oai-gray-400 transition-colors hover:text-oai-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 dark:text-oai-gray-500 dark:hover:text-white",children:a.jsx(y,{className:"h-5 w-5","aria-hidden":!0})}),d?a.jsx(m,{title:t?.nextPath?o("login.title"):void 0,hideTitle:!0,subtitle:t?.subtitle,oauthReturnPath:t?.nextPath,onSuccess:g,className:"p-6 bg-transparent"},e):a.jsx("p",{role:r?"alert":"status",className:"p-6 pt-14 text-sm leading-6 text-oai-gray-700 dark:text-oai-gray-300",children:o(r?"instance.configuration.invalid":"login.cloud_only")})]})})]})})}export{E as LoginModal};
@@ -1 +1 @@
1
- import{d as j,e as N,a as _,r,c as s,j as e,L as p}from"./__vite-browser-external-BZ-i40Kf.js";import{L as k}from"./LoginCard-E5E3i2kj.js";import"./arrow-left-BrQrZJtW.js";function L(n){const t=new URLSearchParams(n).get("next");return typeof t!="string"||t.length===0||!t.startsWith("/")||t.startsWith("//")?"/dashboard":t}function I(){const n=j(),[t,f]=N(),{enabled:o,configurationError:g,loading:x,signedIn:h,refreshUser:m}=_(),a=r.useMemo(()=>L(t.toString()),[t]),l=/^\/(cloud|billing\/checkout)(\?|$)/.test(a),w=l&&new URLSearchParams(a.split("?")[1]).get("intent")==="trial",[y,u]=r.useState(null);r.useEffect(()=>{if(/^\/(cloud|billing\/checkout)(\?|$)/.test(a))try{window.sessionStorage.setItem("tt.cloud.return",a)}catch{}},[a]),r.useEffect(()=>{const d=t.get("insforge_status"),i=t.get("insforge_type"),b=t.get("insforge_error");d==="success"&&i==="verify_email"?u(s("login.verify_email_success")):d==="error"&&i==="verify_email"&&b&&u(s("shared.error.prefix",{error:b}))},[t]);const c=r.useMemo(()=>t.get("native")==="1",[t]);r.useEffect(()=>{if(!(!o||x)&&h){if(c){window.location.href="/auth/native-callback";return}try{window.sessionStorage.removeItem("tt.cloud.return")}catch{}n(a,{replace:!0})}},[o,x,h,n,a,c]),r.useEffect(()=>{o&&m()},[o,m]),r.useEffect(()=>{if(c&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[c]);const v=r.useCallback(()=>{f(d=>{const i=new URLSearchParams(d);return i.delete("insforge_status"),i.delete("insforge_type"),i.delete("insforge_error"),i},{replace:!0}),u(null)},[f]);return o?e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:e.jsx(p,{to:l?"/cloud":"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 rounded",children:s(l?"cloud.checkout.back":"login.back_home")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[y?e.jsxs("div",{className:"rounded-lg border border-oai-gray-800 bg-oai-gray-900/50 px-4 py-3 text-sm text-oai-gray-300 flex justify-between gap-3 items-start",role:"status",children:[e.jsx("span",{children:y}),e.jsx("button",{type:"button",onClick:v,className:"shrink-0 text-oai-gray-500 hover:text-white text-xs",children:s("login.dismiss")})]}):null,e.jsx("div",{className:"border border-oai-gray-900 bg-oai-gray-950 rounded-2xl overflow-hidden shadow-2xl",children:e.jsx(k,{hideLogo:!0,title:s("login.title"),subtitle:s(l?w?"cloud.login.trial_context":"cloud.login.purchase_context":"login.subtitle"),className:"p-8 bg-transparent",onSuccess:()=>{if(c)window.location.href="/auth/native-callback";else{try{window.sessionStorage.removeItem("tt.cloud.return")}catch{}n(a,{replace:!0})}}})})]})})]}):e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:e.jsx(p,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:s("login.back_home")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:e.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",role:g?"alert":void 0,children:g?s("instance.configuration.invalid"):s("login.cloud_only")})})]})}export{I as LoginPage};
1
+ import{d as j,e as N,a as _,r,c as s,j as e,L as p}from"./__vite-browser-external-DCy_YLfe.js";import{L as k}from"./LoginCard-Dggv2aGv.js";import"./arrow-left-DycYjE-k.js";function L(n){const t=new URLSearchParams(n).get("next");return typeof t!="string"||t.length===0||!t.startsWith("/")||t.startsWith("//")?"/dashboard":t}function I(){const n=j(),[t,f]=N(),{enabled:o,configurationError:g,loading:x,signedIn:h,refreshUser:m}=_(),a=r.useMemo(()=>L(t.toString()),[t]),l=/^\/(cloud|billing\/checkout)(\?|$)/.test(a),w=l&&new URLSearchParams(a.split("?")[1]).get("intent")==="trial",[y,u]=r.useState(null);r.useEffect(()=>{if(/^\/(cloud|billing\/checkout)(\?|$)/.test(a))try{window.sessionStorage.setItem("tt.cloud.return",a)}catch{}},[a]),r.useEffect(()=>{const d=t.get("insforge_status"),i=t.get("insforge_type"),b=t.get("insforge_error");d==="success"&&i==="verify_email"?u(s("login.verify_email_success")):d==="error"&&i==="verify_email"&&b&&u(s("shared.error.prefix",{error:b}))},[t]);const c=r.useMemo(()=>t.get("native")==="1",[t]);r.useEffect(()=>{if(!(!o||x)&&h){if(c){window.location.href="/auth/native-callback";return}try{window.sessionStorage.removeItem("tt.cloud.return")}catch{}n(a,{replace:!0})}},[o,x,h,n,a,c]),r.useEffect(()=>{o&&m()},[o,m]),r.useEffect(()=>{if(c&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[c]);const v=r.useCallback(()=>{f(d=>{const i=new URLSearchParams(d);return i.delete("insforge_status"),i.delete("insforge_type"),i.delete("insforge_error"),i},{replace:!0}),u(null)},[f]);return o?e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 h-16 flex items-center justify-between",children:e.jsx(p,{to:l?"/cloud":"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 rounded",children:s(l?"cloud.checkout.back":"login.back_home")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[y?e.jsxs("div",{className:"rounded-lg border border-oai-gray-800 bg-oai-gray-900/50 px-4 py-3 text-sm text-oai-gray-300 flex justify-between gap-3 items-start",role:"status",children:[e.jsx("span",{children:y}),e.jsx("button",{type:"button",onClick:v,className:"shrink-0 text-oai-gray-500 hover:text-white text-xs",children:s("login.dismiss")})]}):null,e.jsx("div",{className:"border border-oai-gray-900 bg-oai-gray-950 rounded-2xl overflow-hidden shadow-2xl",children:e.jsx(k,{hideLogo:!0,title:s("login.title"),subtitle:s(l?w?"cloud.login.trial_context":"cloud.login.purchase_context":"login.subtitle"),className:"p-8 bg-transparent",onSuccess:()=>{if(c)window.location.href="/auth/native-callback";else{try{window.sessionStorage.removeItem("tt.cloud.return")}catch{}n(a,{replace:!0})}}})})]})})]}):e.jsxs("div",{className:"min-h-screen bg-oai-gray-950 text-oai-white font-oai antialiased dark flex flex-col",children:[e.jsx("header",{className:"border-b border-oai-gray-900 px-4 sm:px-6 py-4",children:e.jsx(p,{to:"/",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:s("login.back_home")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:e.jsx("p",{className:"text-oai-gray-400 text-center max-w-md",role:g?"alert":void 0,children:g?s("instance.configuration.invalid"):s("login.cloud_only")})})]})}export{I as LoginPage};