tokentracker-cli 1.5.6 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dashboard/dist/assets/{AchievementBadge-NKpY___e.js → AchievementBadge-Ck1DmXtu.js} +1 -1
- package/dashboard/dist/assets/{AchievementsPage-9nXmSX72.js → AchievementsPage-DjvMoc2i.js} +2 -2
- package/dashboard/dist/assets/{AchievementsSection-DttQciSY.js → AchievementsSection-DvTHE8Vd.js} +1 -1
- package/dashboard/dist/assets/{BadgeDetailModal-bvWEdJbe.js → BadgeDetailModal-COa2Rd6M.js} +1 -1
- package/dashboard/dist/assets/{BotAnimated-ChuUfph8.js → BotAnimated-CeR3jSce.js} +1 -1
- package/dashboard/dist/assets/{Card-SWtLDXt1.js → Card-bQCEOe_K.js} +1 -1
- package/dashboard/dist/assets/{CloudCheckoutPage-c2fNl1Rl.js → CloudCheckoutPage-DDH-3QOd.js} +1 -1
- package/dashboard/dist/assets/{CloudPage-CfwDjZMS.js → CloudPage-RygH3R8b.js} +2 -2
- package/dashboard/dist/assets/{CommandPalette-tWgPa295.js → CommandPalette-E7YqsdAH.js} +1 -1
- package/dashboard/dist/assets/{CommunityStatsModal-D7UaaUdM.js → CommunityStatsModal-B5heTDUE.js} +1 -1
- package/dashboard/dist/assets/{ConfirmModal-BrBcKhfW.js → ConfirmModal-D3vd882N.js} +1 -1
- package/dashboard/dist/assets/{Controls-CcvBkk7W.js → Controls-CK74JkE8.js} +1 -1
- package/dashboard/dist/assets/DashboardPage-DwTrlQZQ.js +1 -0
- package/dashboard/dist/assets/{DateRangePopover-BkN_pird.js → DateRangePopover-BxVCPuEX.js} +1 -1
- package/dashboard/dist/assets/{DevicePage-BbUL7WwT.js → DevicePage-B6x5fBdU.js} +1 -1
- package/dashboard/dist/assets/{DialogClose-BXO8SBFr.js → DialogClose-teXmwU1d.js} +1 -1
- package/dashboard/dist/assets/DialogDescription-BSCcGkVT.js +1 -0
- package/dashboard/dist/assets/{DialogTitle-Du332auj.js → DialogTitle-B3m-31sy.js} +1 -1
- package/dashboard/dist/assets/{ElectricLogo-CXLYfOt7.js → ElectricLogo-0wyvks4K.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-HSQBOc8B.js → FadeIn-C60pLKXu.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-D5tyQDGE.js → HeaderGithubStar-CCEUzMqo.js} +1 -1
- package/dashboard/dist/assets/{HoverTooltip-BhidhbnD.js → HoverTooltip-D9RtbhSZ.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-WMEF1oS3.js → IpCheckPage-BCyW0SWY.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-BmO-59ZP.js → LandingPage-DCEofDST.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardPage-C2WyniEt.js → LeaderboardPage-CsTbalIm.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardProBadge-DAZnMRNn.js → LeaderboardProBadge-Crun5RUJ.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardProfileModal-D1BxcloV.js → LeaderboardProfileModal-Bim9cms6.js} +3 -3
- package/dashboard/dist/assets/{LeaderboardProfilePage-RPJDTwpG.js → LeaderboardProfilePage-D9pBE7f4.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-9ZOhKvn5.js → LimitsPage-CFhzwKzB.js} +6 -6
- package/dashboard/dist/assets/{LocalOnlyNotice-CH6w4hRw.js → LocalOnlyNotice-F_qczacX.js} +1 -1
- package/dashboard/dist/assets/{LoginCard-D24HsRjs.js → LoginCard-CQm_T5K2.js} +1 -1
- package/dashboard/dist/assets/{LoginModal-sLvHyi9U.js → LoginModal-BUf4mPCT.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-PIvLEw1Y.js → LoginPage-njdEUQEX.js} +1 -1
- package/dashboard/dist/assets/{PetPage-DYcw_4P1.js → PetPage-COczIU1k.js} +2 -2
- package/dashboard/dist/assets/{PopoverPopup-D7ZCWq5f.js → PopoverPopup-DxB1k4g7.js} +1 -1
- package/dashboard/dist/assets/{ProviderIcon-B0kB52K-.js → ProviderIcon-BQfkoaQE.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-B_NT4Xfl.js → ResetPasswordPage-PGRVaPTN.js} +1 -1
- package/dashboard/dist/assets/{Select-BtxjjP2Q.js → Select-CQVnpoBO.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-Co1M6XRC.js → SelectItemText-DmAn7osh.js} +1 -1
- package/dashboard/dist/assets/{SelfHostPage-XadfhFnd.js → SelfHostPage-BUURA-Vt.js} +1 -1
- package/dashboard/dist/assets/{ServiceStatusPage-ZEJyAxsQ.js → ServiceStatusPage-DuzSen0Q.js} +1 -1
- package/dashboard/dist/assets/SessionsPage-DndGq61W.js +3 -0
- package/dashboard/dist/assets/{SettingsPage-D4qHgIxn.js → SettingsPage-CHh0yqsZ.js} +3 -3
- package/dashboard/dist/assets/{SkillsPage-CkQCk2uF.js → SkillsPage-CCaYXQWN.js} +1 -1
- package/dashboard/dist/assets/{TokenGalaxy-Bx1vr4b0.js → TokenGalaxy-CGxUtq9x.js} +1 -1
- package/dashboard/dist/assets/{TooltipPopup-DQW8FWJO.js → TooltipPopup-B_B4qQD-.js} +1 -1
- package/dashboard/dist/assets/{TrendMonitor-BMNcY3N8.js → TrendMonitor-CdRQTLZL.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-luRTge7O.js → WidgetsPage-DP_w32wh.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-B1j3WgXx.js → WrappedPage-C_DCqHUH.js} +1 -1
- package/dashboard/dist/assets/{__vite-browser-external-CvvpsW-U.js → __vite-browser-external-Lw3ipvYF.js} +3 -3
- package/dashboard/dist/assets/{agent-logos-DL4fdks6.js → agent-logos-DlnSKc2A.js} +1 -1
- package/dashboard/dist/assets/{arrow-left-DiOsjgdu.js → arrow-left-CjLKt_5C.js} +1 -1
- package/dashboard/dist/assets/{arrow-right-DBFXV7GU.js → arrow-right-Bh-Ezs8y.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-BIvpDQHo.js → arrow-up-right-C87CvEJ5.js} +1 -1
- package/dashboard/dist/assets/{calendar-days--psnXUPW.js → calendar-days-B5VHwV9j.js} +1 -1
- package/dashboard/dist/assets/{check-DLqbsN00.js → check-D2uclldH.js} +1 -1
- package/dashboard/dist/assets/{chevron-down-C0P0oLzP.js → chevron-down-Beacyoub.js} +1 -1
- package/dashboard/dist/assets/{cloud-checkout-NSmb7QNy.js → cloud-checkout-3Y7NDSG1.js} +1 -1
- package/dashboard/dist/assets/{composite-D7ahPHYQ.js → composite-B28yORTL.js} +1 -1
- package/dashboard/dist/assets/{copy-COD7vwd6.js → copy-C8fZJwms.js} +1 -1
- package/dashboard/dist/assets/{download-CpSUX4U-.js → download-IIXYYmyo.js} +1 -1
- package/dashboard/dist/assets/{external-link-DXUjrooT.js → external-link-BEb0dms0.js} +1 -1
- package/dashboard/dist/assets/{flame-Dl3ZT9oo.js → flame-gmfpE-PO.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-Ci49THbK.js → format-tokens-CKwy7NXi.js} +1 -1
- package/dashboard/dist/assets/{gift-DTHCN1Of.js → gift-twpInP_O.js} +1 -1
- package/dashboard/dist/assets/{icons-CB9s1e1k.js → icons-DQfkB5-5.js} +1 -1
- package/dashboard/dist/assets/{index-DFdfNKJM.js → index-ChVgw-dM.js} +1 -1
- package/dashboard/dist/assets/{index-Dozwi-Se.js → index-ClwErGKW.js} +1 -1
- package/dashboard/dist/assets/{index-BGT8ZQyn.js → index-D2-6Msd9.js} +1 -1
- package/dashboard/dist/assets/{index-DeX4t_5p.js → index-DzUxfO5e.js} +1 -1
- package/dashboard/dist/assets/{info-CqM2wmSI.js → info-BvndJDmD.js} +1 -1
- package/dashboard/dist/assets/{link-2-Byo7Rj3t.js → link-2-BhU_5JKG.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-CMxd78Na.js → loader-circle-BR_62BDE.js} +1 -1
- package/dashboard/dist/assets/{local-usage-transfer-CBjnoeck.js → local-usage-transfer-CfoyR0hM.js} +1 -1
- package/dashboard/dist/assets/{modifiers.esm-Oowlk_FC.js → modifiers.esm-CnttlnRD.js} +1 -1
- package/dashboard/dist/assets/{monitor-smartphone-B2EgB_9q.js → monitor-smartphone-D4vzGxrq.js} +1 -1
- package/dashboard/dist/assets/{play-BSuP-UBL.js → play-BVWEKYTF.js} +1 -1
- package/dashboard/dist/assets/{plus-BWemSIuC.js → plus-B9GQ6VvV.js} +1 -1
- package/dashboard/dist/assets/{provider-display-BpzWuFDH.js → provider-display-DCFgR7FO.js} +1 -1
- package/dashboard/dist/assets/{react-cIJ4zx62.js → react-BKUD3UPr.js} +1 -1
- package/dashboard/dist/assets/{safePolygon-C_ZMtbgL.js → safePolygon-DPIi3FGf.js} +1 -1
- package/dashboard/dist/assets/{search-BK7eyNds.js → search-BBRJvYNz.js} +1 -1
- package/dashboard/dist/assets/{server-BqQHX-rd.js → server-Cg3zBK6a.js} +1 -1
- package/dashboard/dist/assets/{shield-check-CO5U6gRw.js → shield-check-BBzYplRb.js} +1 -1
- package/dashboard/dist/assets/{skills-api-CMye76ag.js → skills-api-CcAQ6fJX.js} +1 -1
- package/dashboard/dist/assets/{sortable.esm-Bvb61Lvj.js → sortable.esm-kNieGfR9.js} +1 -1
- package/dashboard/dist/assets/{store-CICV1KXb.js → store-DQpd_ZKv.js} +1 -1
- package/dashboard/dist/assets/{terminal-BKMWT1Ux.js → terminal-zj_c8_SG.js} +1 -1
- package/dashboard/dist/assets/{trash-D2Oqim4r.js → trash-Sl7eOlF7.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-CEqwmjct.js → use-community-stats-Bg-4yvQQ.js} +1 -1
- package/dashboard/dist/assets/{use-latest-request-guard-CTuzzu3F.js → use-latest-request-guard-COF23Bfs.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-CA2BLWkY.js → use-limits-display-prefs-QOlhCOgQ.js} +1 -1
- package/dashboard/dist/assets/{use-native-settings-B54wHSj9.js → use-native-settings-CKDqyirL.js} +1 -1
- package/dashboard/dist/assets/{use-ordered-list--PU9ekxY.js → use-ordered-list-mFHPMcF_.js} +1 -1
- package/dashboard/dist/assets/use-reduced-motion-B4rpC-Zt.js +1 -0
- package/dashboard/dist/assets/{use-transform-BRyR8szg.js → use-transform-CO5wZ0ML.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-sufKdfDY.js → use-usage-limits-CeKjW8jG.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-6oy7kSX8.js → useCurrency-WruYNKxG.js} +1 -1
- package/dashboard/dist/assets/{usePositioner-ZtDdVdJg.js → usePositioner-C3NGxtZa.js} +1 -1
- package/dashboard/dist/assets/{useTokenFormat-tiOJ-PeE.js → useTokenFormat-ObRZ_T9W.js} +1 -1
- package/dashboard/dist/assets/{zap-Dr1dXUjN.js → zap-CyZ3Tf1D.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dashboard/dist/ip-check.html +1 -1
- package/dashboard/dist/leaderboard.html +1 -1
- package/dashboard/dist/share.html +1 -1
- package/package.json +1 -1
- package/src/commands/init.js +9 -0
- package/src/commands/status.js +12 -6
- package/src/commands/sync.js +22 -4
- package/src/lib/claude-backend.js +291 -0
- package/src/lib/claude-config.js +1 -1
- package/src/lib/cursor-config.js +3 -1
- package/src/lib/devin-limits.js +65 -25
- package/src/lib/diagnostics.js +3 -0
- package/src/lib/doctor.js +13 -0
- package/src/lib/local-api.js +2 -0
- package/src/lib/local-usage-transfer.js +22 -1
- package/src/lib/pricing/index.js +12 -0
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +70 -15
- package/src/lib/session-analytics.js +20 -8
- package/src/lib/trae-cn-config.js +32 -2
- package/src/lib/usage-limits.js +601 -35
- package/dashboard/dist/assets/DashboardPage-DJSgRHGq.js +0 -1
- package/dashboard/dist/assets/DialogDescription-B1HyKP0x.js +0 -1
- package/dashboard/dist/assets/SessionsPage-Cte1taUu.js +0 -3
- package/dashboard/dist/assets/use-reduced-motion-CZ8_YWc2.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{o as ne,j as e,y as Ke,c as r,h as W,r as g,bm as Nt,V as w,bn as _t,bo as St,al as Pt,B as te,bp as Ct,e as Mt,W as
|
|
2
|
-
`)}const ut=Ut,He=[1,.65,.45,.3,.2];function _e(t){return He[Math.min(t,He.length-1)]}function Oe({paceX:t,paceOver:a}){return 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(${t}% - 3px)`,width:"6px"}}),e.jsx("div",{className:`absolute top-0 h-full ${a?"bg-red-500":"bg-emerald-500"}`,style:{left:`calc(${t}% - 1px)`,width:"2px"}})]})}function ba({label:t,pct:a,reset:i,mode:n=M.USED,pacePercent:s=null,paceOver:o=!1,title:c=null,segments:l=null}){const d=Math.max(0,Math.min(100,Number(a)||0)),m=n===M.REMAINING?100-d:d,u=ct(m,n),p=Math.round(m),h=m>0&&p===0?Math.max(m,.35):m;let y=String(p);m>0&&p===0&&(y=r("limits.bar.sub_one_percent"));const b=s==null?null:Math.max(0,Math.min(100,s)),k=l?.map(C=>Math.max(0,Math.min(100,Number(C.pct)||0))),S=k?.reduce((C,j)=>C+j,0)||0,E=l?Math.max(0,d-S):0,F=Math.max(0,100-S-E);return e.jsxs("div",{className:"group relative flex items-center gap-2",children:[e.jsx(ut,{text:c}),e.jsx("span",{"data-limit-label":"",className:"text-xs sm:text-sm text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:t}),l?e.jsxs("div",{"data-limit-segments":"",className:"relative flex min-w-0 flex-1 h-1.5 overflow-hidden",style:{gap:"min(2px, 1%)"},children:[l.map((C,j)=>e.jsx("div",{"data-limit-segment":C.key,className:`${u} min-w-0 rounded-full h-full transition-[flex-grow] duration-500 ease-out`,style:{flex:`${k[j]} 1 0px`,opacity:_e(j)}},C.key)),E?e.jsx("div",{"data-limit-unallocated-used":"",className:`${u} min-w-0 rounded-full h-full`,style:{flex:`${E} 1 0px`,opacity:_e(l.length)}}):null,F?e.jsx("div",{"data-limit-remainder":"",className:"min-w-0 rounded-full h-full bg-oai-gray-100 dark:bg-oai-gray-700/50",style:{flex:`${F} 1 0px`}}):null,b!=null&&e.jsx(Oe,{paceX:b,paceOver:o})]}):e.jsxs("div",{className:"relative min-w-0 flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:[e.jsx("div",{className:`${u} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${h}%`,minWidth:m>0?"3px":0}}),b!=null&&e.jsx(Oe,{paceX:b,paceOver:o})]}),e.jsxs("span",{className:"text-xs sm:text-sm tabular-nums text-oai-gray-600 dark:text-oai-gray-300 w-11 text-right shrink-0 whitespace-nowrap",children:[y,"%"]}),i&&e.jsx("span",{className:"text-xs tabular-nums text-oai-gray-400 dark:text-oai-gray-500 w-8 text-right shrink-0",children:i})]})}function ya({segments:t,fillColor:a}){return e.jsx("div",{"data-limit-legend":"",className:"-mt-0.5 flex flex-wrap gap-x-3 gap-y-0.5 text-[11px] leading-snug",style:{paddingLeft:"calc(var(--tt-limits-label-w, 0px) + 0.5rem)"},children:t.map((i,n)=>e.jsxs("span",{className:"inline-flex items-center gap-1 whitespace-nowrap",children:[e.jsx("span",{"aria-hidden":!0,className:`${a} inline-block h-1.5 w-1.5 shrink-0 rounded-full`,style:{opacity:_e(n)}}),e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:i.label??r(i.labelKey)}),e.jsxs("span",{className:"tabular-nums text-oai-gray-700 dark:text-oai-gray-200",children:[ce(i.pct),"%"]})]},i.key))})}function mt(t,a,i){const n=t.label??r(t.labelKey),s=i===M.REMAINING,o=d=>s?100-d:d;if(a.expectedPercent==null){const d=Math.max(0,Math.min(100,Number(me(t.window,t.pctField))||0)),m=ce(o(d));return s?r("limits.explain.remaining",{label:n,used:m}):r("limits.explain.used",{label:n,used:m})}if(a.paceOver){if(a.runsOutEta)return r("limits.explain.ahead_eta",{label:n,eta:a.runsOutEta});const d=ce(o(a.projectedEnd??100));return r(s?"limits.explain.ahead_pct_remaining":"limits.explain.ahead_pct",{label:n,pct:d})}const c=Math.max(0,Math.min(100,Number(me(t.window,t.pctField))||0)),l=ce(o(a.projectedEnd??c));return r(s?"limits.explain.on_track_remaining":"limits.explain.on_track",{label:n,pct:l})}function xt({pace:t}){return t.pacePercent!=null}function va(t,a){return t.some(i=>xt(i)&&(i.mode??a)===M.REMAINING)}function Ce({rows:t,mode:a,now:i=Date.now()}){if(t.length===0)return null;const n=va(t,a),s=t.some(xt);return e.jsxs("div",{className:"mt-1 flex flex-col gap-1",children:[t.map(({spec:o,pace:c,mode:l=a})=>{const d=X(xe(pe(o.window,o.resetField)));return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-600 dark:text-oai-gray-300",children:[mt(o,c,l),d?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:d})]}):null,o.showCreditDetail?e.jsx("div",{children:dt(o.window,o.creditPrecision)}):null]},o.key)}),s?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(n?"limits.explain.body_remaining":"limits.explain.body")}):null]})}function ae(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 n=Math.floor(i/60);if(n<24)return r("shared.time.h_ago",{n});const s=Math.floor(n/24);return r("shared.time.d_ago",{n:s})}const Fe={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"}},ka={claude:"claude",codex:"codex",antigravity:"agy"};function V({label:t,age:a=null,tone:i="live",tooltip:n=null}){const s=Fe[i]||Fe.live,o=i==="live";return e.jsxs("div",{className:"relative inline-flex items-center group cursor-help ml-1",onClick:c=>c.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 ${s.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 ${s.pulse} opacity-75`}),e.jsx("span",{className:`relative inline-flex rounded-full h-1.5 w-1.5 ${s.dot}`})]}):e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${s.dot}`}),t,a?e.jsxs(e.Fragment,{children:[" · ",a]}):null]}),n?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:[n,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 pt({name:t,providerId:a,children:i,expandable:n=!1,expanded:s=!1,onToggle:o,badge:c=null,rightAdornment:l=null,toggleOnHeader:d=!1}){const m=Ve(a),u=e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[m?e.jsx(Ye,{provider:m,size:22,className:xa}):null,e.jsx("span",{className:"text-base font-semibold text-oai-black dark:text-oai-white",children:t}),l?e.jsx("span",{className:"shrink-0",children:l}):null,c]}),p="rounded-xl border border-oai-gray-200 bg-white dark:border-oai-gray-800 dark:bg-oai-gray-900",h="flex w-full items-center justify-between gap-3 border-b border-oai-gray-200 px-4 py-4 text-left dark:border-oai-gray-800 sm:px-5",y=e.jsx("div",{className:"flex flex-col gap-2 px-4 py-4 sm:px-5",children:i});return n?d?e.jsxs("div",{className:p,children:[e.jsxs("button",{type:"button","aria-expanded":s,onClick:o,className:`${h} rounded-t-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500`,children:[u,e.jsx(ie,{size:16,"aria-hidden":!0,className:`shrink-0 text-oai-gray-400 transition-transform ${s?"rotate-180":""}`})]}),y]}):e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),o?.())},className:`${p} cursor-pointer transition-colors hover:border-oai-gray-300 dark:hover:border-oai-gray-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500`,children:[e.jsxs("div",{className:h,children:[u,e.jsx(ie,{size:16,"aria-hidden":!0,className:`shrink-0 text-oai-gray-400 transition-transform ${s?"rotate-180":""}`})]}),y]}):e.jsxs("div",{className:p,children:[e.jsx("div",{className:h,children:u}),y]})}function gt({subscription:t}){const a=t.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),i=t.autoRenew?at:Se;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 ht({subscription:t,now:a,mode:i=M.USED}){const n=ue(t,a);if(!n)return null;const{endMs:s,expired:o}=n,c=!o&&s-a<=3*864e5,l=o?100:n.progress*100,d=i===M.REMAINING?100-l:l,m=o?100:Math.max(0,Math.min(100,d)),u=Math.round(m),p=m>0&&u===0?r("limits.bar.sub_one_percent"):`${u}%`;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs sm:text-sm 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 min-w-0 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":c?"bg-amber-500":"bg-blue-500"} rounded-full h-full block motion-safe:transition-[width] motion-safe:duration-500 ease-out motion-reduce:transition-none`,style:{width:`${m}%`,minWidth:m>0?"3px":0}})}),e.jsx("span",{className:"text-xs sm:text-sm tabular-nums text-oai-gray-600 dark:text-oai-gray-300 w-11 text-right shrink-0 whitespace-nowrap",children:p}),e.jsx("span",{className:`text-xs tabular-nums shrink-0 whitespace-nowrap w-8 text-right ${o?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:st(s,a)})]})}function ft({subscription:t,now:a}){const i=ue(t,a);if(!i)return null;const n=new Intl.DateTimeFormat(W(),{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:n.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:Ne(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 ja=qe;function O({children:t,tone:a="neutral"}){return a==="error"?e.jsxs("div",{className:"flex items-start gap-2 text-xs leading-relaxed text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx(Nt,{size:15,"aria-hidden":!0,className:"mt-0.5 shrink-0 text-red-500 dark:text-red-400"}),e.jsx("span",{className:"min-w-0 break-words",children:t})]}):e.jsx("div",{className:"text-[11px] leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:t})}function Me({rows:t,mode:a,extra:i=null,expanded:n=!1}){const s=t.length===0&&!i;return e.jsxs(e.Fragment,{children:[t.map(({spec:o,pace:c,mode:l=a})=>{const d=me(o.window,o.pctField),u=n&&o.productPool&&Array.isArray(o.segments)&&o.segments.length!==0?o.segments:null,p=u&&l!==M.REMAINING?u:null;return e.jsxs(w.Fragment,{children:[e.jsx(ba,{label:o.label??r(o.labelKey),pct:d,reset:ha(pe(o.window,o.resetField)),mode:l,segments:p,pacePercent:c.pacePercent,paceOver:c.paceOver,title:fa(o,c,l)}),u?e.jsxs(e.Fragment,{children:[e.jsx(ya,{segments:u,fillColor:ct(d,M.USED)}),l===M.REMAINING?e.jsx("div",{"data-limit-share-note":"",className:"-mt-0.5 text-[11px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",style:{paddingLeft:"calc(var(--tt-limits-label-w, 0px) + 0.5rem)"},children:r("limits.grok.shares_are_used")}):null]}):null]},o.key)}),s?e.jsx(O,{children:r("limits.status.no_data")}):null,i]})}function wa(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 Na({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(ut,{text:wa(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 min-w-0 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 _a({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(Na,{row:i},i.key))]})}const Sa={five_hour:5*3600*1e3,weekly:168*3600*1e3};function bt(t,a){if(!t||typeof t!="object")return!1;if(t.error)return!0;for(const i of["five_hour","weekly"])for(const n of t[i]||[])if(Date.parse(n?.expires_at)>a)return!0;return!1}function Pa({data:t}){const[a,i]=g.useState(!1),n=Date.now();if(!bt(t,n))return null;const s=[{key:"five_hour",label:r("limits.label.zcode_5h")},{key:"weekly",label:r("limits.label.zcode_weekly")}].map(l=>{const d=(t[l.key]||[]).filter(b=>Date.parse(b.expires_at)>n).sort((b,k)=>Date.parse(b.expires_at)-Date.parse(k.expires_at)),m=new Map;for(const b of d){const k=Date.parse(b.expires_at);m.set(k,(m.get(k)||0)+1)}const p=[...m.entries()].sort((b,k)=>b[0]-k[0]).map(([b,k])=>k>1?r("limits.zcode.reset_bank.batch",{time:X(b),count:k}):X(b)).join(`
|
|
3
|
-
`),h=Sa[l.key]||0,y=d.length&&h?Math.max(0,Math.min(100,(Date.parse(d[0].expires_at)-n)/h*100)):0;return{...l,cards:d,batchTitle:p,countdownPercent:y}});let o=0;const c=[];for(const l of s)o+=l.cards.length,l.cards.length&&c.push(l);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":a,onClick:l=>{l.stopPropagation(),i(d=>!d)},onKeyDown:l=>l.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(Se,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",children:r("limits.zcode.reset_bank.title")}),o?e.jsx("span",{className:"rounded-full bg-oai-gray-100 px-2 py-0.5 text-[10px] tabular-nums text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-300",children:r("limits.zcode.reset_bank.count",{count:o})}):null,e.jsx(ie,{size:13,"aria-hidden":!0,className:`ml-auto transition-transform ${a?"rotate-180":""}`})]}),t.error?e.jsx(O,{tone:"error",children:t.error}):null,a&&!t.error?e.jsx("div",{className:"mt-2 flex flex-col gap-1.5",children:c.map(l=>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:l.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:l.cards.length})}),e.jsx("div",{className:"relative min-w-0 flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",title:l.batchTitle,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:`${l.countdownPercent}%`,minWidth:l.countdownPercent>0?"3px":0}})}),l.cards.length?e.jsx("span",{className:"ml-auto shrink-0 whitespace-nowrap text-right text-[10px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500",title:l.batchTitle,children:r("limits.zcode.reset_bank.earliest",{time:X(Date.parse(l.cards[0].expires_at))})}):null]},l.key))}):null]})}function Ca({data:t}){const a=Array.isArray(t?.balances)?t.balances:[];return e.jsxs("div",{className:"mt-1 space-y-1","data-deepseek-balance":"",children:[a.map(i=>{const n=String(i?.currency||"").toUpperCase(),s=Z(i?.total,{maximumFractionDigits:2}),o=Number(i?.granted)>0?Z(i.granted,{maximumFractionDigits:2}):null;return!n||!s?null:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{"data-limit-label":"",className:"text-xs sm:text-sm text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:r("limits.deepseek.balance_label",{currency:n})}),e.jsx("span",{className:"text-xs sm:text-sm tabular-nums text-oai-gray-600 dark:text-oai-gray-300",children:s}),o?e.jsx("span",{className:"text-[10.5px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.deepseek.granted_detail",{amount:o})}):null]},n)}),t?.is_available===!1?e.jsx("div",{className:"mt-1",children:e.jsx(O,{tone:"error",children:r("limits.deepseek.unavailable")})}):null]})}function yt(t,a){if(t==="deepseek_balance")return e.jsx(Ca,{data:a});if(t==="zcode_reset_bank")return bt(a.reset_credits,Date.now())?e.jsx(Pa,{data:a.reset_credits}):null;if(t==="codex_meta"){const i=ca(a.reset_credits);return i?e.jsx(_a,{model:i}):null}if(t==="kimi_parallel"&&a.parallel_limit)return e.jsx(O,{children:r("limits.label.kimi_parallel",{count:a.parallel_limit})});if(t==="kiro_credits"&&Number.isFinite(Number(a.tracked_credits))&&Number(a.tracked_credit_records)>0){const i=Z(a.tracked_credits,{maximumFractionDigits:2});return e.jsx(O,{children:r("limits.label.kiro_tracked_credits",{credits:i,count:Number(a.tracked_credit_records)})})}return t==="copilot_otel"&&!a.otel_has_files&&!a.otel_enabled?e.jsx(Ta,{defaultDir:a.otel_default_dir}):null}function Ma({data:t,mode:a,now:i}){const[n,s]=g.useState(!1),o=g.useRef(null),c=De(o),l=[...new Set((t.buckets||[]).map(u=>u.plan_name).filter(Boolean))],d=l.length?l.join(" · "):r("limits.zcode.start_grants"),m=re.zcode.windows(t).filter(u=>u.window).map(u=>({spec:u,pace:Pe(u,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":n,onClick:u=>{u.stopPropagation(),s(p=>!p)},onKeyDown:u=>u.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(Bt,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",title:d,children:d}),e.jsx(ie,{size:13,"aria-hidden":!0,className:`ml-auto transition-transform ${n?"rotate-180":""}`})]}),n?e.jsx("div",{ref:o,"data-limit-label-group":"",className:"mt-2 flex flex-col gap-1.5",style:c>0?{"--tt-limits-label-w":`${c}px`}:void 0,children:t.error?e.jsx(O,{tone:"error",children:t.error}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{rows:m,mode:a}),e.jsx(Ce,{rows:m,mode:a,now:i}),(t.buckets||[]).filter(u=>Number.isFinite(u.remaining_units)&&Number.isFinite(u.total_units)).map((u,p)=>e.jsx("div",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.zcode.grant_amount",{remaining:u.remaining_units.toLocaleString(W()),total:u.total_units.toLocaleString(W())})},u.entitlement_id||p))]})}):null]})}function Da({data:t,mode:a,now:i}){const[n,s]=g.useState(!1),o=g.useRef(null),c=De(o),l=r(t.region==="zai"?"limits.zcode.region.zai":"limits.zcode.region.bigmodel"),d=t.plan_label||r("limits.zcode.start_grants"),m=r("limits.zcode.other_region.title",{region:l,plan:d}),u=re.zcode.windows(t).filter(h=>h.window).map(h=>({spec:h,mode:a,pace:Pe(h,a,i)})),p=Date.parse(t.log_timestamp);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":n,onClick:h=>{h.stopPropagation(),s(y=>!y)},onKeyDown:h=>h.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(_t,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",title:m,children:m}),e.jsx(ie,{size:13,"aria-hidden":!0,className:`ml-auto transition-transform ${n?"rotate-180":""}`})]}),n?e.jsxs("div",{ref:o,"data-limit-label-group":"",className:"mt-2 flex flex-col gap-1.5",style:c>0?{"--tt-limits-label-w":`${c}px`}:void 0,children:[e.jsx(Me,{rows:u,mode:a}),e.jsx(Ce,{rows:u,mode:a,now:i}),Number.isFinite(p)?e.jsx(O,{children:r("limits.zcode.other_region.snapshot",{time:X(p)})}):null]}):null]})}function Ea(t,a,i,n,s,o,c=null,l=null,d=Date.now(),m=null){const u=re[t];if(!u)return null;const p=u.windows(a).filter(y=>y.window).map(y=>({spec:y,mode:n,pace:Pe(y,n,d)})),h=yt(u.extra,a);return e.jsxs(pt,{name:i,providerId:t,expandable:p.length>0||!!l,expanded:s,onToggle:o,badge:c,rightAdornment:l?e.jsx(gt,{subscription:l}):null,toggleOnHeader:t==="zcode",children:[e.jsx(Me,{mode:n,rows:p,extra:h,expanded:s}),t==="opencodeGo"||t==="commandCode"||t==="deepseek"?e.jsx(vt,{providerId:t,data:a,onSaved:m}):null,l?e.jsx(ht,{subscription:l,now:d,mode:n}):null,s?e.jsx(Ce,{rows:p,mode:n,now:d}):null,s&&l?e.jsx(ft,{subscription:l,now:d}):null,t==="zcode"&&a.start_plan?.configured?e.jsx(Ma,{data:a.start_plan,mode:n,now:d}):null,t==="zcode"&&a.other_region?e.jsx(Da,{data:a.other_region,mode:n,now:d}):null]},t)}function ve(t,a,i,n,s=null,o=Date.now(),c=M.USED){const l=!!s;return e.jsxs(pt,{name:de(t),providerId:t,expandable:l,expanded:i,onToggle:n,rightAdornment:l?e.jsx(gt,{subscription:s}):null,children:[a,l?e.jsx(ht,{subscription:s,now:o,mode:c}):null,l&&i?e.jsx("div",{className:"mt-1",children:e.jsx(ft,{subscription:s,now:o})}):null]},t)}function Ra(t,a,i,n,s,o=null,c=Date.now(),l=null){if(!re[t])return null;if(!a?.configured)return ve(t,e.jsxs(e.Fragment,{children:[e.jsx(O,{children:r("limits.status.not_connected")}),t==="opencodeGo"?e.jsx(I,{title:r("limits.opencodeGo.setupHint.title"),children:e.jsx(Le,{onSaved:l})}):null,t==="commandCode"?e.jsx(I,{title:r("limits.commandCode.setupHint.title"),children:e.jsx($e,{onSaved:l})}):null,t==="codingPlan"?e.jsx(I,{title:r("limits.codingPlan.setupHint.title"),children:e.jsx(Be,{})}):null,t==="agentPlan"?e.jsx(I,{title:r("limits.agentPlan.setupHint.title"),children:e.jsx(Ge,{})}):null,t==="devin"?e.jsx(I,{title:r("limits.devin.setupHint.title"),children:e.jsx(Ue,{})}):null,t==="deepseek"?e.jsx(I,{title:r("limits.deepseek.setupHint.title"),children:e.jsx(ze,{onSaved:l})}):null]}),n,s,o,c,i);if(t==="opencodeGo"&&a.subscription_status==="inactive")return ve(t,e.jsx(O,{children:r("limits.opencodeGo.status.inactive")}),n,s,o,c,i);if(a.error)return ve(t,e.jsxs(e.Fragment,{children:[e.jsx(O,{tone:"error",children:a.error}),t==="kiro"?yt(re.kiro.extra,a):null,t==="deepseek"?e.jsx(I,{title:r("limits.deepseek.setupHint.title"),children:e.jsx(ze,{onSaved:l})}):null,t==="deepseek"?e.jsx(vt,{providerId:t,data:a,onSaved:l}):null,t==="opencodeGo"?e.jsx(I,{title:r("limits.opencodeGo.setupHint.title"),children:e.jsx(Le,{onSaved:l})}):null,t==="commandCode"?e.jsx(I,{title:r("limits.commandCode.setupHint.title"),children:e.jsx($e,{onSaved:l})}):null,t==="codingPlan"?e.jsx(I,{title:r("limits.codingPlan.setupHint.title"),children:e.jsx(Be,{})}):null,t==="agentPlan"?e.jsx(I,{title:r("limits.agentPlan.setupHint.title"),children:e.jsx(Ge,{})}):null,t==="devin"?e.jsx(I,{title:r("limits.devin.setupHint.title"),children:e.jsx(Ue,{})}):null]}),n,s,o,c,i);const d=de(t),m=a.plan_label?`${d} ${a.plan_label}`:d;let u=null;if(a.auth_action_required==="reauth"){const h=t==="commandCode"?ot():t==="devin"?lt():ka[t];u=e.jsx(V,{label:r("limits.reauth.badge"),age:ae(a.cached_at),tone:"stale",tooltip:h?r("limits.reauth.tooltip",{command:h}):null})}if(!u&&t==="antigravity")if(a.cached){const h=ae(a.cached_at);u=e.jsx(V,{label:r("limits.label.antigravity_cached"),age:h,tone:"cached",tooltip:r("limits.tooltip.antigravity_cached")})}else u=e.jsx(V,{label:r("limits.label.antigravity_live"),tone:"live",tooltip:r("limits.tooltip.antigravity_live")});!u&&(t==="qoder"||t==="qoderCn")&&a.cached&&(u=e.jsx(V,{label:r("limits.label.antigravity_cached"),age:ae(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.qoder_cached")})),!u&&(t==="codingPlan"||t==="agentPlan")&&a.cached&&(u=e.jsx(V,{label:r("limits.label.antigravity_cached"),age:ae(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.ark_cached")}));const p=a.provenance;return p?.stale&&!u&&(u=e.jsx(V,{label:r("limits.provenance.stale"),age:ae(p.captured_at),tone:"stale",tooltip:r("limits.provenance.tooltip",{source:p.source,confidence:p.confidence})})),Ea(t,a,m,i,n,s,u,o,c,l)}function Ta({defaultDir:t}){const[a,i]=g.useState(!1),s=["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 c=>{c.stopPropagation();try{await navigator.clipboard.writeText(s),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:s}),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 D({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
|
|
5
|
-
`),n=async s=>{s.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[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(D,{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:s=>s.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(
|
|
6
|
-
`),n=async s=>{s.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[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(D,{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:s=>s.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(ge,{})]})]}),e.jsxs(D,{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(D,{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:n,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 De(t){const[a,i]=g.useState(0);return g.useLayoutEffect(()=>{const n=t.current;if(!n)return;const s=[...n.querySelectorAll("[data-limit-label]")].filter(d=>d.closest("[data-limit-label-group]")===n);let o=0,c=null;if(s.length>0)try{c=document.createElement("canvas").getContext("2d")}catch{c=null}if(c){const d=window.getComputedStyle(s[0]);c.font=`${d.fontStyle} ${d.fontWeight} ${d.fontSize} ${d.fontFamily}`;for(const m of s)o=Math.max(o,c.measureText(m.textContent).width)}const l=Math.ceil(o);i(d=>d===l?d:l)}),a}function Ia({claude:t,codex:a,cursor:i,gemini:n,kimi:s,kiro:o,grok:c,antigravity:l,copilot:d,zcode:m,opencodeGo:u,commandCode:p,qoder:h,qoderCn:y,codingPlan:b,agentPlan:k,devin:S,workbuddy:E,workbuddyAi:F,deepseek:C,order:j,visibility:L,displayMode:J,subscriptions:K=[],showSubscriptions:A=!0,onProviderKeySaved:R=null}){const T={claude:t,codex:a,cursor:i,gemini:n,kimi:s,kiro:o,grok:c,antigravity:l,copilot:d,zcode:m,opencodeGo:u,commandCode:p,qoder:h,qoderCn:y,codingPlan:b,agentPlan:k,devin:S,workbuddy:E,workbuddyAi:F,deepseek:C},P=g.useRef(null),$=De(P),[Q,ee]=g.useState(null),[H,fe]=g.useState(()=>Date.now()),oe=[...new Set(Array.isArray(j)&&j.length>0?j:ja)],U=J===M.REMAINING?M.REMAINING:M.USED;g.useEffect(()=>{const v=setInterval(()=>fe(Date.now()),6e4);return()=>clearInterval(v)},[]);const B=new Map;if(A)for(const v of K||[]){if(!v?.provider)continue;const z=new Date(v.nextBillingAt).getTime();if(!Number.isFinite(z))continue;const x=B.get(v.provider);if(!x){B.set(v.provider,v);continue}const N=new Date(x.nextBillingAt).getTime(),f=z>H,_=N>H;(f&&(!_||N>z)||!f&&!_&&z>N)&&B.set(v.provider,v)}const le=oe.filter(v=>!L||L[v]!==!1||B.has(v)).map(v=>Ra(v,T[v],U,Q===v,()=>ee(z=>z===v?null:v),B.get(v)||null,H,R)).filter(Boolean);return e.jsx(zt,{delay:.15,children:e.jsx("div",{ref:P,"data-limit-label-group":"",className:"flex flex-col gap-3",style:$>0?{"--tt-limits-label-w":`${$}px`}:void 0,children:le.length>0?le:e.jsx(O,{children:r("limits.status.all_hidden")})})})}async function kt(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 Aa(){const t=await fetch("/functions/tokentracker-subscription-manager",{headers:{Accept:"application/json"},cache:"no-store"}),a=await kt(t);return Array.isArray(a.subscriptions)?a.subscriptions:[]}async function Ee(t){const a=await Pt();return kt(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 Ha(t){return Ee({action:"create",subscription:t})}function Oa(t,a){return Ee({action:"update",id:t,subscription:a})}function Fa(t){return Ee({action:"delete",id:t})}const ke={plan:"",provider:"",cycle:"monthly",autoRenew:!0,startedAt:""};function La(t){const a=new Date(t);if(Number.isNaN(a.getTime()))return"";const i=n=>String(n).padStart(2,"0");return`${a.getFullYear()}-${i(a.getMonth()+1)}-${i(a.getDate())}T${i(a.getHours())}:${i(a.getMinutes())}`}function $a({subscriptions:t,onChanged:a}){const[i,n]=g.useState(!1),[s,o]=g.useState(null),[c,l]=g.useState(ke),[d,m]=g.useState(!1),[u,p]=g.useState(!1),[h,y]=g.useState(!1),[b,k]=g.useState(!1),[S,E]=g.useState(null),[F,C]=g.useState(!1),[j,L]=g.useState(!1),[J,K]=g.useState(null),[A,R]=g.useState(()=>Date.now()),T=g.useRef(null),P=W(),$=g.useMemo(()=>new Intl.DateTimeFormat(P,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),[P]);g.useEffect(()=>{const x=setInterval(()=>R(Date.now()),6e4);return()=>clearInterval(x)},[]),g.useEffect(()=>{if(!i)return;const x=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;T.current?.scrollIntoView?.({behavior:x?"auto":"smooth",block:"nearest"})},[i,s]);const Q=g.useMemo(()=>qe.map(x=>{const N=(t||[]).some(_=>_.provider===x&&_.id!==s),f=de(x);return{value:x,label:N?`${f} ${r("subscriptions.form.provider_taken_suffix")}`:f,disabled:N}}),[P,t,s]),ee=g.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")}],[P]),H=g.useMemo(()=>[{value:"true",label:r("subscriptions.form.auto_renew_on")},{value:"false",label:r("subscriptions.form.auto_renew_off")}],[P]),fe=g.useCallback(()=>{l(ke),o(null),p(!1),y(!1),k(!1),n(!0)},[]),oe=g.useCallback(x=>{l({plan:x.plan||"",provider:x.provider||"",cycle:x.cycle||"monthly",autoRenew:x.autoRenew,startedAt:La(new Date(da(x)).toISOString())}),o(x.id),p(!1),y(!1),k(!1),n(!0)},[]),U=g.useCallback(()=>{n(!1),o(null),l(ke),p(!1),y(!1),k(!1)},[]),B=g.useCallback(async x=>{if(x.preventDefault(),p(!1),!c.provider){y(!0);return}if((t||[]).some(q=>q.provider===c.provider&&q.id!==s)){k(!0);return}const f=new Date(c.startedAt).getTime();if(!Number.isFinite(f)){p(!0);return}const _={service:de(c.provider),plan:c.plan,provider:c.provider||null,autoRenew:c.autoRenew,cycle:c.cycle,startedAt:f,nextBillingAt:it(f,c.cycle)};m(!0);try{s?await Oa(s,_):await Ha(_),U(),await a?.()}catch{p(!0)}finally{m(!1)}},[U,s,c,a,t]),le=g.useCallback(async()=>{if(S){C(!0),L(!1);try{await Fa(S.id),S.id===s&&U(),E(null),await a?.()}catch{L(!0)}finally{C(!1)}}},[U,s,a,S]),v=t||[],z=()=>{const x=s?v.find(f=>f.id===s):null,N=x?ue(x,A):null;return e.jsxs("form",{ref:T,onSubmit:B,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:s?r("subscriptions.edit"):r("subscriptions.add")})}),N?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:x.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:$.format(new Date(N.endMs))})," · ",e.jsx("span",{className:N.expired?"text-oai-error":void 0,children:Ne(N.endMs,A)})]}):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(ye,{id:"subscription-provider",value:c.provider,onValueChange:f=>l({...c,provider:String(f)}),options:Q,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-1",children:e.jsx(Ie,{label:r("subscriptions.form.plan"),value:c.plan,maxLength:120,placeholder:r("subscriptions.form.plan_placeholder"),onChange:f=>l({...c,plan:f.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(ye,{id:"subscription-cycle",value:c.cycle,onValueChange:f=>l({...c,cycle:String(f)}),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(ye,{id:"subscription-auto-renew",value:String(c.autoRenew),onValueChange:f=>l({...c,autoRenew:f==="true"}),options:H,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(Ie,{label:r("subscriptions.form.started_at"),type:"datetime-local",value:c.startedAt,required:!0,onChange:f=>l({...c,startedAt:f.target.value})})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 sm:col-span-2",children:[s?e.jsx(te,{type:"button",variant:"secondary",size:"sm",onClick:()=>{const f=v.find(_=>_.id===s);f&&E(f)},className:"!text-red-600 dark:!text-red-400 mr-auto",children:r("subscriptions.delete")}):null,h?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_required")}):null,b?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_taken")}):null,u?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.error")}):null,e.jsx(te,{type:"button",variant:"secondary",size:"sm",onClick:U,children:r("shared.action.cancel")}),e.jsx(te,{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(te,{type:"button",size:"sm",onClick:fe,className:"shrink-0 gap-1.5",children:[e.jsx(Kt,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:r("subscriptions.add")})]})]}),v.length===0&&!(i&&!s)?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(Qe,{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:[v.map(x=>{const N=ue(x,A);if(!N)return null;const{endMs:f,expired:_}=N,q=_?100:N.progress*100,jt=!_&&f-A<=3*864e5,wt=J===x.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:()=>oe(x),"aria-label":`${r("subscriptions.edit")} ${x.service}`,"aria-expanded":s===x.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(Ye,{provider:Ve(x.provider)||"OTHER",size:14}),e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-white truncate",children:x.service}),e.jsx("span",{role:"img","aria-label":x.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),title:x.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),className:`inline-flex shrink-0 translate-y-px ${x.autoRenew?"text-oai-brand-600 dark:text-oai-brand-400":"text-blue-600 dark:text-blue-400"}`,children:x.autoRenew?e.jsx(at,{size:14,strokeWidth:2,"aria-hidden":!0}):e.jsx(Se,{size:14,strokeWidth:2,"aria-hidden":!0})}),x.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:x.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:`${_?"bg-red-500":jt?"bg-amber-500":"bg-blue-500"} rounded-full h-full block transition-[width] duration-500 ease-out`,style:{width:`${q}%`,minWidth:q>0?"3px":0}})}),e.jsx("span",{className:`text-[10px] tabular-nums shrink-0 ${_?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:st(f,A)})]})]}),s===x.id?e.jsx("div",{className:"border-t border-oai-gray-100 dark:border-oai-gray-800",children:z()}):null,s!==x.id&&wt?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:x.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:$.format(new Date(f))})," · ",e.jsx("span",{className:_?"text-oai-error":void 0,children:Ne(f,A)})," · ",e.jsx("span",{children:x.autoRenew?r("subscriptions.status.auto_renew"):r("subscriptions.status.manual")})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(te,{type:"button",variant:"secondary",size:"sm",onClick:()=>oe(x),children:r("subscriptions.edit")})})]}):null]},x.id)}),i&&!s?e.jsx("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:z()}):null]}),e.jsx(Gt,{open:!!S,title:r("subscriptions.confirm_delete_title"),description:S?.service||"",error:j?r("subscriptions.delete_error"):null,confirmLabel:r("subscriptions.delete"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:F,onCancel:()=>{E(null),L(!1)},onConfirm:le})]})}const je=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),za="x-apple.systempreferences:com.apple.preference.notifications";function We(t){const a=Date.parse(t);return Number.isFinite(a)?new Intl.DateTimeFormat(W(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(a)):String(t)}function Ua(t){const a=Object.entries(t||{}).filter(([o,c])=>o!=="fetched_at"&&c&&typeof c=="object"&&c.configured!==!1),i=a.filter(([,o])=>!!o.error),n=a.some(([,o])=>!!o.start_plan?.error||!!o.reset_credits?.error),s=a.filter(([,o])=>o.provenance?.stale===!0||o.provenance?.source==="disk-cache");return a.length&&i.length===0&&!n&&s.length===a.length?{kind:"stale"}:i.length||s.length||n?{kind:"partial",at:t.fetched_at}:{kind:"updated",at:t.fetched_at}}function Ba(){const t=Jt(),a=Tt(),i=r("limits.alert.blocked"),n=a?Re.button:Re.div;return e.jsxs(n,{type:a?"button":void 0,onClick:a?()=>It({type:"action",name:"openURL",value:za}):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 hr(){const t=Ct(),a=$t(),i=w.useRef(null),n=w.useCallback(()=>{const R=Te();if(!a.showSubscriptions)return R;const T=i.current;return!T||T.size===0?R:R.filter(P=>!T.has(P))},[a.showSubscriptions]),{data:s,error:o,isLoading:c,refresh:l}=Ot(t?{initialRefresh:!0,initialState:t,publishToPreloadCache:!0,getHiddenProviders:n}:{initialRefresh:!0,publishToPreloadCache:!0,getHiddenProviders:n}),d=Ft(),[m,u]=w.useState([]),[p,h]=w.useState(!1),[y,b]=w.useState(!1),[k]=Mt(),S=w.useRef(0),E=w.useRef(!1),[F,C]=w.useState(!1),[j,L]=w.useState(null),J=w.useCallback(async()=>{if(!E.current){E.current=!0,C(!0),L(null);try{const R=await l();L(R?Ua(R):{kind:"failed"})}finally{E.current=!1,C(!1)}}},[l]),K=w.useCallback(async()=>{if(!je&&!be())return;const R=++S.current;try{const T=await Aa();if(R!==S.current)return;u(T),h(!1);const P=new Set(T.map(H=>H?.provider).filter(Boolean)),$=i.current,Q=Te(),ee=$===null?a.showSubscriptions&&[...P].some(H=>Q.includes(H)):a.showSubscriptions&&($.size!==P.size||[...P].some(H=>!$.has(H)));i.current=P,ee&&l()}catch{if(R!==S.current)return;h(!0)}},[a.showSubscriptions,l]),A=w.useRef(a.showSubscriptions);return w.useEffect(()=>{A.current!==a.showSubscriptions&&(A.current=a.showSubscriptions,!(!je&&!be())&&l())},[a.showSubscriptions,l]),w.useEffect(()=>{K()},[K]),w.useEffect(()=>{k.get("openSubscriptions")==="1"&&b(!0)},[k]),w.useEffect(()=>{d.enabled&&s&&Lt(s)},[d.enabled,s]),!je&&!be()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(Wt,{})}):e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-6 grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-2 gap-y-2 sm:mb-8 sm:gap-x-4 sm:gap-y-3",children:[e.jsx("h1",{className:"min-w-0 text-2xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white",children:r("nav.limits")}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[d.enabled&&d.permissionBlocked?e.jsx(Ba,{}):null,e.jsx("button",{type:"button",onClick:()=>{J()},disabled:F,"aria-label":r("limits.page.refresh"),title:r("limits.page.refresh"),className:"shrink-0 inline-flex h-10 w-10 sm:h-9 sm: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(Dt,{className:`h-4 w-4 ${F?"animate-spin":""}`,"aria-hidden":!0})}),e.jsxs(qt,{open:y,onOpenChange:b,children:[e.jsx(Vt,{"aria-label":r("limits.page.openSubscriptions"),title:r("limits.page.openSubscriptions"),className:"shrink-0 inline-flex h-10 w-10 sm:h-9 sm: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(Qe,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(Yt,{children:e.jsx(Zt,{side:"bottom",align:"end",sideOffset:8,className:"z-50",children:e.jsx(Xt,{children:e.jsx($a,{subscriptions:m,onChanged:K})})})})]}),e.jsx("button",{type:"button",onClick:()=>{d.setEnabled(!d.enabled)},"aria-label":d.enabled?r("limits.alert.disable"):r("limits.alert.enable"),title:d.enabled?r("limits.alert.disable"):r("limits.alert.enable"),className:`inline-flex h-10 w-10 sm:h-9 sm: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 ${d.enabled&&d.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:d.enabled?e.jsx(ea,{className:"h-4 w-4","aria-hidden":!0}):e.jsx(Qt,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(Et,{to:"/settings?section=limits","aria-label":r("limits.page.openSettings"),title:r("limits.page.openSettings"),className:"shrink-0 inline-flex h-10 w-10 sm:h-9 sm: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(Rt,{className:"h-4 w-4","aria-hidden":!0})})]}),e.jsx("p",{className:"col-span-2 hidden sm:block sm:text-base text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.page.subtitle")})]}),e.jsx("span",{role:"status",className:"sr-only",children:F?r("limits.page.refresh_loading"):""}),j?.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:We(j.at)})}):null,j?.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:We(j.at)})}):null,j?.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,j?.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,c?e.jsx(ia,{}):e.jsxs(e.Fragment,{children:[o?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:o}):null,p?e.jsx("p",{className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("subscriptions.load_error")}):null,e.jsx(Ia,{claude:s?.claude,codex:s?.codex,cursor:s?.cursor,gemini:s?.gemini,kimi:s?.kimi,kiro:s?.kiro,grok:s?.grok,antigravity:s?.antigravity,copilot:s?.copilot,zcode:s?.zcode,opencodeGo:s?.opencodeGo,commandCode:s?.commandCode,qoder:s?.qoder,qoderCn:s?.qoderCn,codingPlan:s?.codingPlan,agentPlan:s?.agentPlan,devin:s?.devin,workbuddy:s?.workbuddy,workbuddyAi:s?.workbuddyAi,deepseek:s?.deepseek,order:a.order,visibility:a.visibility,displayMode:a.displayMode,subscriptions:m,showSubscriptions:a.showSubscriptions!==!1,onProviderKeySaved:()=>{l()}})]})]})})})}export{hr as LimitsPage};
|
|
1
|
+
import{o as ne,j as e,y as Ke,c as r,h as W,r as g,bm as Nt,V as w,bn as _t,bo as St,al as Pt,B as te,bp as Ct,e as Mt,W as ye,R as Dt,L as Et,bq as Rt,t as Tt,w as It}from"./__vite-browser-external-Lw3ipvYF.js";import{m as Re}from"./react-BKUD3UPr.js";import{P as re,c as At,r as pe,a as Ht,u as Ot,b as Ft,s as Lt}from"./use-usage-limits-CeKjW8jG.js";import{b as qe,c as M,l as ue,d as Ve,u as $t,h as Te}from"./use-limits-display-prefs-QOlhCOgQ.js";import{F as zt}from"./FadeIn-C60pLKXu.js";import{P as Ye}from"./ProviderIcon-BQfkoaQE.js";import{H as Ut}from"./HoverTooltip-D9RtbhSZ.js";import{C as ie}from"./chevron-down-Beacyoub.js";import{G as Bt}from"./gift-twpInP_O.js";import{C as Gt}from"./ConfirmModal-D3vd882N.js";import{I as Ie,L as Wt}from"./LocalOnlyNotice-F_qczacX.js";import{S as ve}from"./Select-CQVnpoBO.js";import{P as Kt}from"./plus-B9GQ6VvV.js";import{P as qt,a as Vt,b as Yt,c as Zt,d as Xt}from"./PopoverPopup-DxB1k4g7.js";import{u as Jt}from"./use-reduced-motion-B4rpC-Zt.js";import"./use-latest-request-guard-COF23Bfs.js";import"./DialogTitle-B3m-31sy.js";import"./composite-B28yORTL.js";import"./store-DQpd_ZKv.js";import"./DialogDescription-BSCcGkVT.js";import"./arrow-up-right-C87CvEJ5.js";import"./download-IIXYYmyo.js";import"./check-D2uclldH.js";import"./SelectItemText-DmAn7osh.js";import"./usePositioner-C3NGxtZa.js";import"./safePolygon-DPIi3FGf.js";const Ze={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"}]]};Ze.node;const Qt=ne(Ze);const Xe={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"}]]};Xe.node;const ea=ne(Xe);const Je={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"}]]};Je.node;const Qe=ne(Je);const et={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};et.node;const Se=ne(et);const tt={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"}]]};tt.node;const at=ne(tt),ta=[3,2,3,3,2,2,3];function Y({className:t}){return e.jsx("div",{className:Ke("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function aa(){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{className:"h-3 w-12 shrink-0"}),e.jsx(Y,{className:"flex-1 h-1.5 rounded-full min-w-0"}),e.jsx(Y,{className:"h-3 w-[30px] shrink-0"}),e.jsx(Y,{className:"h-3 w-6 shrink-0"})]})}function ra({bars:t,index:a}){const i=a%3===0?"w-24":a%3===1?"w-20":"w-[4.5rem]";return e.jsxs("div",{className:"rounded-xl border border-oai-gray-200 bg-white dark:border-oai-gray-800 dark:bg-oai-gray-900",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-oai-gray-200 px-4 py-4 dark:border-oai-gray-800 sm:px-5",children:[e.jsx(Y,{className:"h-[22px] w-[22px] shrink-0 rounded"}),e.jsx(Y,{className:Ke("h-4",i)})]}),e.jsx("div",{className:"flex flex-col gap-2 px-4 py-4 sm:px-5",children:Array.from({length:t},(n,s)=>e.jsx(aa,{},s))})]})}function ia(){return e.jsx("div",{className:"flex flex-col gap-3","aria-hidden":"true",children:ta.map((t,a)=>e.jsx(ra,{bars:t,index:a},a))})}const we=100;function Ae(t){const a=Date.parse(t);return Number.isFinite(a)?a:null}function sa(t){return Math.max(0,Math.min(we,Math.round(t)))}function na(t){return new Intl.DateTimeFormat(W(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t))}function oa(t,a,i){if(t==null||t>=a)return we;const n=a-t,s=a-i;return sa(s/n*we)}function la(t){const a=t.available_count;return a===null?null:Number.isInteger(a)&&a>=0?a:void 0}function ca(t,{now:a}={}){if(!t||typeof t!="object")return null;const i=la(t);if(i===void 0)return null;const n=Array.isArray(t.credits)?t.credits:[],s=a instanceof Date?a.getTime():Number(a??Date.now()),o=[];for(const c of n){const l=Ae(c?.expires_at);if(l==null)continue;const d=o.length+1;o.push({key:`reset-${d}`,label:r("limits.codex_reset_bank.row_label",{index:d}),expiresAt:na(l),expiresMs:l,percent:oa(Ae(c?.granted_at),l,s)})}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 se=864e5;function G(t,a){const i=new Date(t),n=i.getUTCDate(),s=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()+a,1,i.getUTCHours(),i.getUTCMinutes())),o=new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth()+1,0)).getUTCDate();return s.setUTCDate(Math.min(n,o)),s.getTime()}function rt(t,a){if(a==="weekly")return t-7*se;if(a==="yearly")return G(t,-12);const i=new Date(t),n=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),0)).getUTCDate(),s=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()-1,1,i.getUTCHours(),i.getUTCMinutes()));return s.setUTCDate(Math.min(i.getUTCDate(),n)),s.getTime()}function it(t,a){return a==="weekly"?t+7*se:a==="yearly"?G(t,12):G(t,1)}function da(t){if(t.startedAt!=null){const a=new Date(t.startedAt).getTime();if(Number.isFinite(a))return a}return rt(new Date(t.nextBillingAt).getTime(),t.cycle)}function ua(t,a,i){if(t.startedAt!=null){const n=new Date(t.startedAt).getTime();if(Number.isFinite(n))return n}return rt(i,a)}function ma(t,a,i){if(a==="weekly"){const l=7*se,d=i<=t?0:Math.floor((i-t)/l);return{startMs:t+d*l,endMs:t+(d+1)*l}}const n=a==="yearly"?12:1,s=n*30.436875*se;let o=i<=t?0:Math.floor((i-t)/s);for(;o>0&&G(t,o*n)>i;)o-=1;let c=0;for(;G(t,(o+1)*n)<=i&&c<12e3;)o+=1,c+=1;return{startMs:G(t,o*n),endMs:G(t,(o+1)*n)}}function me(t,a){const i=new Date(t.nextBillingAt).getTime();if(!Number.isFinite(i))return null;const n=["weekly","monthly","yearly"].includes(t.cycle)?t.cycle:"monthly",s=ua(t,n,i);if(!Number.isFinite(s))return null;let o,c,l=!1;t.autoRenew?{startMs:o,endMs:c}=ma(s,n,a):t.startedAt!=null?(o=s,c=it(s,n),l=c<=a):(o=s,c=i,l=c<=a);const d=Math.max(1,c-o),m=l?1:Math.max(0,Math.min(1,(a-o)/d));return{endMs:c,startMs:o,progress:m,cycleDays:Math.max(1,Math.round(d/se)),expired:l}}function st(t,a){const i=t-a;if(i<=0)return r("subscriptions.expired");const n=Math.ceil(i/6e4);if(n<60)return`${n}m`;const s=Math.floor(n/60);return s<24?`${s}h`:`${Math.floor(s/24)}d`}function Ne(t,a){const i=t-a;if(i<=0)return r("subscriptions.expired");const n=Math.floor(i/6e4),s=Math.floor(n/1440),o=Math.floor(n%1440/60),c=n%60;return r("subscriptions.countdown",{days:s,hours:o,minutes:c})}const xa="shrink-0 text-oai-black dark:text-oai-white",pa={opencodeGo:"OPENCODE_GO_API_KEY",commandCode:"COMMAND_CODE_API_KEY",deepseek:"DEEPSEEK_API_KEY"},ga={opencodeGo:"opencode-go",commandCode:"command-code",deepseek:"deepseek"};function nt(){const t=typeof navigator>"u"?"":navigator.userAgent||"";return/Windows/i.test(t)?"windows":/Linux/i.test(t)?"linux":"macos"}function ot(){return nt()==="windows"?r("limits.commandCode.setupHint.snippet_login_windows"):r("limits.commandCode.setupHint.snippet_login")}function lt(){return r("limits.devin.setupHint.snippet_login")}function ha(t){const a=pe(t);if(!Number.isFinite(a))return null;const i=a-Date.now();if(i<=0)return r("shared.time.now");const n=Math.floor(i/6e4);if(n<60)return`${n}m`;const s=Math.floor(n/60);return s<24?`${s}h`:`${Math.floor(s/24)}d`}function ct(t,a){const i=a===M.REMAINING?100-t:t;return i>=90?"bg-red-500":i>=70?"bg-amber-500":"bg-emerald-500"}function xe(t,a="used_percent"){return t?a==="utilization"?t.utilization:t.used_percent:null}function ge(t,a="reset_at"){return t?a==="resets_at"?t.resets_at:t.reset_at:null}function de(t){const a=Math.max(0,Math.min(100,Number(t)||0)),i=Math.round(a);return a>0&&i===0?r("limits.bar.sub_one_percent"):String(i)}function Z(t,{useGrouping:a=!0,maximumFractionDigits:i}={}){const n=Number(t);return Number.isFinite(n)?new Intl.NumberFormat(void 0,{minimumFractionDigits:0,maximumFractionDigits:i??(n>=100?0:2),useGrouping:a}).format(n):null}function dt(t,a){if(!t||typeof t!="object"||!(Number(t.limit_credits)>0))return null;const i={useGrouping:t.unit!=="calls",maximumFractionDigits:a},n=Z(t.used_credits,i),s=Z(t.limit_credits,i),o=Z(t.remaining_credits,i);if(!n||!s||!o)return null;const c=t.unit==="calls"?"limits.qoder_calls.detail":"limits.codex_credits.detail";return r(c,{used:n,limit:s,remaining:o})}function Pe(t,a,i){return At({usedPercent:xe(t.window,t.pctField),windowSeconds:Ht(t,t.window),resetMs:pe(ge(t.window,t.resetField)),mode:a,now:i})}function X(t){return Number.isFinite(t)?new Intl.DateTimeFormat(W(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):null}function fa(t,a,i){const n=[mt(t,a,i)],s=pe(ge(t.window,t.resetField)),o=X(s);o&&n.push(r(t.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:o}));const c=dt(t.window,t.creditPrecision);return c&&n.push(c),n.join(`
|
|
2
|
+
`)}const ut=Ut,He=[1,.65,.45,.3,.2];function _e(t){return He[Math.min(t,He.length-1)]}function Oe({paceX:t,paceOver:a}){return 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(${t}% - 3px)`,width:"6px"}}),e.jsx("div",{className:`absolute top-0 h-full ${a?"bg-red-500":"bg-emerald-500"}`,style:{left:`calc(${t}% - 1px)`,width:"2px"}})]})}function ba({label:t,pct:a,reset:i,mode:n=M.USED,pacePercent:s=null,paceOver:o=!1,title:c=null,segments:l=null}){const d=Math.max(0,Math.min(100,Number(a)||0)),m=n===M.REMAINING?100-d:d,u=ct(m,n),p=Math.round(m),h=m>0&&p===0?Math.max(m,.35):m;let y=String(p);m>0&&p===0&&(y=r("limits.bar.sub_one_percent"));const b=s==null?null:Math.max(0,Math.min(100,s)),k=l?.map(C=>Math.max(0,Math.min(100,Number(C.pct)||0))),S=k?.reduce((C,j)=>C+j,0)||0,E=l?Math.max(0,d-S):0,F=Math.max(0,100-S-E);return e.jsxs("div",{className:"group relative flex items-center gap-2",children:[e.jsx(ut,{text:c}),e.jsx("span",{"data-limit-label":"",className:"text-xs sm:text-sm text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:t}),l?e.jsxs("div",{"data-limit-segments":"",className:"relative flex min-w-0 flex-1 h-1.5 overflow-hidden",style:{gap:"min(2px, 1%)"},children:[l.map((C,j)=>e.jsx("div",{"data-limit-segment":C.key,className:`${u} min-w-0 rounded-full h-full transition-[flex-grow] duration-500 ease-out`,style:{flex:`${k[j]} 1 0px`,opacity:_e(j)}},C.key)),E?e.jsx("div",{"data-limit-unallocated-used":"",className:`${u} min-w-0 rounded-full h-full`,style:{flex:`${E} 1 0px`,opacity:_e(l.length)}}):null,F?e.jsx("div",{"data-limit-remainder":"",className:"min-w-0 rounded-full h-full bg-oai-gray-100 dark:bg-oai-gray-700/50",style:{flex:`${F} 1 0px`}}):null,b!=null&&e.jsx(Oe,{paceX:b,paceOver:o})]}):e.jsxs("div",{className:"relative min-w-0 flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:[e.jsx("div",{className:`${u} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${h}%`,minWidth:m>0?"3px":0}}),b!=null&&e.jsx(Oe,{paceX:b,paceOver:o})]}),e.jsxs("span",{className:"text-xs sm:text-sm tabular-nums text-oai-gray-600 dark:text-oai-gray-300 w-11 text-right shrink-0 whitespace-nowrap",children:[y,"%"]}),i&&e.jsx("span",{className:"text-xs tabular-nums text-oai-gray-400 dark:text-oai-gray-500 w-8 text-right shrink-0",children:i})]})}function ya({segments:t,fillColor:a}){return e.jsx("div",{"data-limit-legend":"",className:"-mt-0.5 flex flex-wrap gap-x-3 gap-y-0.5 text-[11px] leading-snug",style:{paddingLeft:"calc(var(--tt-limits-label-w, 0px) + 0.5rem)"},children:t.map((i,n)=>e.jsxs("span",{className:"inline-flex items-center gap-1 whitespace-nowrap",children:[e.jsx("span",{"aria-hidden":!0,className:`${a} inline-block h-1.5 w-1.5 shrink-0 rounded-full`,style:{opacity:_e(n)}}),e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:i.label??r(i.labelKey)}),e.jsxs("span",{className:"tabular-nums text-oai-gray-700 dark:text-oai-gray-200",children:[de(i.pct),"%"]})]},i.key))})}function mt(t,a,i){const n=t.label??r(t.labelKey),s=i===M.REMAINING,o=d=>s?100-d:d;if(a.expectedPercent==null){const d=Math.max(0,Math.min(100,Number(xe(t.window,t.pctField))||0)),m=de(o(d));return s?r("limits.explain.remaining",{label:n,used:m}):r("limits.explain.used",{label:n,used:m})}if(a.paceOver){if(a.runsOutEta)return r("limits.explain.ahead_eta",{label:n,eta:a.runsOutEta});const d=de(o(a.projectedEnd??100));return r(s?"limits.explain.ahead_pct_remaining":"limits.explain.ahead_pct",{label:n,pct:d})}const c=Math.max(0,Math.min(100,Number(xe(t.window,t.pctField))||0)),l=de(o(a.projectedEnd??c));return r(s?"limits.explain.on_track_remaining":"limits.explain.on_track",{label:n,pct:l})}function xt({pace:t}){return t.pacePercent!=null}function va(t,a){return t.some(i=>xt(i)&&(i.mode??a)===M.REMAINING)}function Ce({rows:t,mode:a,now:i=Date.now()}){if(t.length===0)return null;const n=va(t,a),s=t.some(xt);return e.jsxs("div",{className:"mt-1 flex flex-col gap-1",children:[t.map(({spec:o,pace:c,mode:l=a})=>{const d=X(pe(ge(o.window,o.resetField)));return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-600 dark:text-oai-gray-300",children:[mt(o,c,l),d?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:d})]}):null,o.showCreditDetail?e.jsx("div",{children:dt(o.window,o.creditPrecision)}):null]},o.key)}),s?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(n?"limits.explain.body_remaining":"limits.explain.body")}):null]})}function ae(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 n=Math.floor(i/60);if(n<24)return r("shared.time.h_ago",{n});const s=Math.floor(n/24);return r("shared.time.d_ago",{n:s})}const Fe={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"}},ka={claude:"claude",codex:"codex",antigravity:"agy"};function V({label:t,age:a=null,tone:i="live",tooltip:n=null}){const s=Fe[i]||Fe.live,o=i==="live";return e.jsxs("div",{className:"relative inline-flex items-center group cursor-help ml-1",onClick:c=>c.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 ${s.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 ${s.pulse} opacity-75`}),e.jsx("span",{className:`relative inline-flex rounded-full h-1.5 w-1.5 ${s.dot}`})]}):e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${s.dot}`}),t,a?e.jsxs(e.Fragment,{children:[" · ",a]}):null]}),n?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:[n,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 pt({name:t,providerId:a,children:i,expandable:n=!1,expanded:s=!1,onToggle:o,badge:c=null,rightAdornment:l=null,toggleOnHeader:d=!1}){const m=Ve(a),u=e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[m?e.jsx(Ye,{provider:m,size:22,className:xa}):null,e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:t}),l?e.jsx("span",{className:"shrink-0",children:l}):null,c]}),p="rounded-xl border border-oai-gray-200 bg-white dark:border-oai-gray-800 dark:bg-oai-gray-900",h="flex w-full items-center justify-between gap-3 border-b border-oai-gray-200 px-4 py-3 text-left dark:border-oai-gray-800 sm:px-5",y=e.jsx("div",{className:"flex flex-col gap-2 px-4 py-4 sm:px-5",children:i});return n?d?e.jsxs("div",{className:p,children:[e.jsxs("button",{type:"button","aria-expanded":s,onClick:o,className:`${h} rounded-t-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500`,children:[u,e.jsx(ie,{size:16,"aria-hidden":!0,className:`shrink-0 text-oai-gray-400 transition-transform ${s?"rotate-180":""}`})]}),y]}):e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),o?.())},className:`${p} cursor-pointer transition-colors hover:border-oai-gray-300 dark:hover:border-oai-gray-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500`,children:[e.jsxs("div",{className:h,children:[u,e.jsx(ie,{size:16,"aria-hidden":!0,className:`shrink-0 text-oai-gray-400 transition-transform ${s?"rotate-180":""}`})]}),y]}):e.jsxs("div",{className:p,children:[e.jsx("div",{className:h,children:u}),y]})}function gt({subscription:t}){const a=t.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),i=t.autoRenew?at:Se;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 ht({subscription:t,now:a,mode:i=M.USED}){const n=me(t,a);if(!n)return null;const{endMs:s,expired:o}=n,c=!o&&s-a<=3*864e5,l=o?100:n.progress*100,d=i===M.REMAINING?100-l:l,m=o?100:Math.max(0,Math.min(100,d)),u=Math.round(m),p=m>0&&u===0?r("limits.bar.sub_one_percent"):`${u}%`;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{"data-limit-label":"",className:"text-xs sm:text-sm 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 min-w-0 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":c?"bg-amber-500":"bg-blue-500"} rounded-full h-full block motion-safe:transition-[width] motion-safe:duration-500 ease-out motion-reduce:transition-none`,style:{width:`${m}%`,minWidth:m>0?"3px":0}})}),e.jsx("span",{className:"text-xs sm:text-sm tabular-nums text-oai-gray-600 dark:text-oai-gray-300 w-11 text-right shrink-0 whitespace-nowrap",children:p}),e.jsx("span",{className:`text-xs tabular-nums shrink-0 whitespace-nowrap w-8 text-right ${o?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:st(s,a)})]})}function ft({subscription:t,now:a}){const i=me(t,a);if(!i)return null;const n=new Intl.DateTimeFormat(W(),{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:n.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:Ne(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 ja=qe;function A({children:t,tone:a="neutral"}){return a==="error"?e.jsxs("div",{className:"flex items-start gap-2 text-xs leading-relaxed text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx(Nt,{size:15,"aria-hidden":!0,className:"mt-0.5 shrink-0 text-red-500 dark:text-red-400"}),e.jsx("span",{className:"min-w-0 break-words",children:t})]}):e.jsx("div",{className:"text-[11px] leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:t})}function Me({rows:t,mode:a,extra:i=null,expanded:n=!1}){const s=t.length===0&&!i;return e.jsxs(e.Fragment,{children:[t.map(({spec:o,pace:c,mode:l=a})=>{const d=xe(o.window,o.pctField),u=n&&o.productPool&&Array.isArray(o.segments)&&o.segments.length!==0?o.segments:null,p=u&&l!==M.REMAINING?u:null;return e.jsxs(w.Fragment,{children:[e.jsx(ba,{label:o.label??r(o.labelKey),pct:d,reset:ha(ge(o.window,o.resetField)),mode:l,segments:p,pacePercent:c.pacePercent,paceOver:c.paceOver,title:fa(o,c,l)}),u?e.jsxs(e.Fragment,{children:[e.jsx(ya,{segments:u,fillColor:ct(d,M.USED)}),l===M.REMAINING?e.jsx("div",{"data-limit-share-note":"",className:"-mt-0.5 text-[11px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",style:{paddingLeft:"calc(var(--tt-limits-label-w, 0px) + 0.5rem)"},children:r("limits.grok.shares_are_used")}):null]}):null]},o.key)}),s?e.jsx(A,{children:r("limits.status.no_data")}):null,i]})}function wa(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 Na({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(ut,{text:wa(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 min-w-0 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 _a({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(Na,{row:i},i.key))]})}const Sa={five_hour:5*3600*1e3,weekly:168*3600*1e3};function bt(t,a){if(!t||typeof t!="object")return!1;if(t.error)return!0;for(const i of["five_hour","weekly"])for(const n of t[i]||[])if(Date.parse(n?.expires_at)>a)return!0;return!1}function Pa({data:t}){const[a,i]=g.useState(!1),n=Date.now();if(!bt(t,n))return null;const s=[{key:"five_hour",label:r("limits.label.zcode_5h")},{key:"weekly",label:r("limits.label.zcode_weekly")}].map(l=>{const d=(t[l.key]||[]).filter(b=>Date.parse(b.expires_at)>n).sort((b,k)=>Date.parse(b.expires_at)-Date.parse(k.expires_at)),m=new Map;for(const b of d){const k=Date.parse(b.expires_at);m.set(k,(m.get(k)||0)+1)}const p=[...m.entries()].sort((b,k)=>b[0]-k[0]).map(([b,k])=>k>1?r("limits.zcode.reset_bank.batch",{time:X(b),count:k}):X(b)).join(`
|
|
3
|
+
`),h=Sa[l.key]||0,y=d.length&&h?Math.max(0,Math.min(100,(Date.parse(d[0].expires_at)-n)/h*100)):0;return{...l,cards:d,batchTitle:p,countdownPercent:y}});let o=0;const c=[];for(const l of s)o+=l.cards.length,l.cards.length&&c.push(l);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":a,onClick:l=>{l.stopPropagation(),i(d=>!d)},onKeyDown:l=>l.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(Se,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",children:r("limits.zcode.reset_bank.title")}),o?e.jsx("span",{className:"rounded-full bg-oai-gray-100 px-2 py-0.5 text-[10px] tabular-nums text-oai-gray-600 dark:bg-oai-gray-800 dark:text-oai-gray-300",children:r("limits.zcode.reset_bank.count",{count:o})}):null,e.jsx(ie,{size:13,"aria-hidden":!0,className:`ml-auto transition-transform ${a?"rotate-180":""}`})]}),t.error?e.jsx(A,{tone:"error",children:t.error}):null,a&&!t.error?e.jsx("div",{className:"mt-2 flex flex-col gap-1.5",children:c.map(l=>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:l.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:l.cards.length})}),e.jsx("div",{className:"relative min-w-0 flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",title:l.batchTitle,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:`${l.countdownPercent}%`,minWidth:l.countdownPercent>0?"3px":0}})}),l.cards.length?e.jsx("span",{className:"ml-auto shrink-0 whitespace-nowrap text-right text-[10px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500",title:l.batchTitle,children:r("limits.zcode.reset_bank.earliest",{time:X(Date.parse(l.cards[0].expires_at))})}):null]},l.key))}):null]})}function Ca({data:t}){const a=Array.isArray(t?.balances)?t.balances:[];return e.jsxs("div",{className:"mt-1 space-y-1","data-deepseek-balance":"",children:[a.map(i=>{const n=String(i?.currency||"").toUpperCase(),s=Z(i?.total,{maximumFractionDigits:2}),o=Number(i?.granted)>0?Z(i.granted,{maximumFractionDigits:2}):null;return!n||!s?null:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{"data-limit-label":"",className:"text-xs sm:text-sm text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:r("limits.deepseek.balance_label",{currency:n})}),e.jsx("span",{className:"text-xs sm:text-sm tabular-nums text-oai-gray-600 dark:text-oai-gray-300",children:s}),o?e.jsx("span",{className:"text-[10.5px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.deepseek.granted_detail",{amount:o})}):null]},n)}),t?.is_available===!1?e.jsx("div",{className:"mt-1",children:e.jsx(A,{tone:"error",children:r("limits.deepseek.unavailable")})}):null]})}function yt(t,a){if(t==="deepseek_balance")return e.jsx(Ca,{data:a});if(t==="zcode_reset_bank")return bt(a.reset_credits,Date.now())?e.jsx(Pa,{data:a.reset_credits}):null;if(t==="codex_meta"){const i=ca(a.reset_credits);return i?e.jsx(_a,{model:i}):null}if(t==="kimi_parallel"&&a.parallel_limit)return e.jsx(A,{children:r("limits.label.kimi_parallel",{count:a.parallel_limit})});if(t==="kiro_credits"&&Number.isFinite(Number(a.tracked_credits))&&Number(a.tracked_credit_records)>0){const i=Z(a.tracked_credits,{maximumFractionDigits:2});return e.jsx(A,{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(Ta,{defaultDir:a.otel_default_dir}):null}function Ma({data:t,mode:a,now:i}){const[n,s]=g.useState(!1),o=g.useRef(null),c=De(o),l=[...new Set((t.buckets||[]).map(u=>u.plan_name).filter(Boolean))],d=l.length?l.join(" · "):r("limits.zcode.start_grants"),m=re.zcode.windows(t).filter(u=>u.window).map(u=>({spec:u,pace:Pe(u,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":n,onClick:u=>{u.stopPropagation(),s(p=>!p)},onKeyDown:u=>u.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(Bt,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",title:d,children:d}),e.jsx(ie,{size:13,"aria-hidden":!0,className:`ml-auto transition-transform ${n?"rotate-180":""}`})]}),n?e.jsx("div",{ref:o,"data-limit-label-group":"",className:"mt-2 flex flex-col gap-1.5",style:c>0?{"--tt-limits-label-w":`${c}px`}:void 0,children:t.error?e.jsx(A,{tone:"error",children:t.error}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{rows:m,mode:a}),e.jsx(Ce,{rows:m,mode:a,now:i}),(t.buckets||[]).filter(u=>Number.isFinite(u.remaining_units)&&Number.isFinite(u.total_units)).map((u,p)=>e.jsx("div",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.zcode.grant_amount",{remaining:u.remaining_units.toLocaleString(W()),total:u.total_units.toLocaleString(W())})},u.entitlement_id||p))]})}):null]})}function Da({data:t,mode:a,now:i}){const[n,s]=g.useState(!1),o=g.useRef(null),c=De(o),l=r(t.region==="zai"?"limits.zcode.region.zai":"limits.zcode.region.bigmodel"),d=t.plan_label||r("limits.zcode.start_grants"),m=r("limits.zcode.other_region.title",{region:l,plan:d}),u=re.zcode.windows(t).filter(h=>h.window).map(h=>({spec:h,mode:a,pace:Pe(h,a,i)})),p=Date.parse(t.log_timestamp);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":n,onClick:h=>{h.stopPropagation(),s(y=>!y)},onKeyDown:h=>h.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(_t,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"min-w-0 truncate",title:m,children:m}),e.jsx(ie,{size:13,"aria-hidden":!0,className:`ml-auto transition-transform ${n?"rotate-180":""}`})]}),n?e.jsxs("div",{ref:o,"data-limit-label-group":"",className:"mt-2 flex flex-col gap-1.5",style:c>0?{"--tt-limits-label-w":`${c}px`}:void 0,children:[e.jsx(Me,{rows:u,mode:a}),e.jsx(Ce,{rows:u,mode:a,now:i}),Number.isFinite(p)?e.jsx(A,{children:r("limits.zcode.other_region.snapshot",{time:X(p)})}):null]}):null]})}function Ea(t,a,i,n,s,o,c=null,l=null,d=Date.now(),m=null){const u=re[t];if(!u)return null;const p=u.windows(a).filter(y=>y.window).map(y=>({spec:y,mode:n,pace:Pe(y,n,d)})),h=yt(u.extra,a);return e.jsxs(pt,{name:i,providerId:t,expandable:p.length>0||!!l,expanded:s,onToggle:o,badge:c,rightAdornment:l?e.jsx(gt,{subscription:l}):null,toggleOnHeader:t==="zcode",children:[e.jsx(Me,{mode:n,rows:p,extra:h,expanded:s}),t==="opencodeGo"||t==="commandCode"||t==="deepseek"?e.jsx(vt,{providerId:t,data:a,onSaved:m}):null,l?e.jsx(ht,{subscription:l,now:d,mode:n}):null,s?e.jsx(Ce,{rows:p,mode:n,now:d}):null,s&&l?e.jsx(ft,{subscription:l,now:d}):null,t==="zcode"&&a.start_plan?.configured?e.jsx(Ma,{data:a.start_plan,mode:n,now:d}):null,t==="zcode"&&a.other_region?e.jsx(Da,{data:a.other_region,mode:n,now:d}):null]},t)}function ce(t,a,i,n,s=null,o=Date.now(),c=M.USED){const l=!!s;return e.jsxs(pt,{name:ue(t),providerId:t,expandable:l,expanded:i,onToggle:n,rightAdornment:l?e.jsx(gt,{subscription:s}):null,children:[a,l?e.jsx(ht,{subscription:s,now:o,mode:c}):null,l&&i?e.jsx("div",{className:"mt-1",children:e.jsx(ft,{subscription:s,now:o})}):null]},t)}function Ra(t,a,i,n,s,o=null,c=Date.now(),l=null){if(!re[t])return null;if(t==="claude"&&a?.limits_status==="not_applicable")return ce(t,e.jsx(A,{children:r("limits.claude.custom_backend")}),n,s,o,c,i);if(!a?.configured)return ce(t,e.jsxs(e.Fragment,{children:[e.jsx(A,{children:r("limits.status.not_connected")}),t==="opencodeGo"?e.jsx(I,{title:r("limits.opencodeGo.setupHint.title"),children:e.jsx(Le,{onSaved:l})}):null,t==="commandCode"?e.jsx(I,{title:r("limits.commandCode.setupHint.title"),children:e.jsx($e,{onSaved:l})}):null,t==="codingPlan"?e.jsx(I,{title:r("limits.codingPlan.setupHint.title"),children:e.jsx(Be,{})}):null,t==="agentPlan"?e.jsx(I,{title:r("limits.agentPlan.setupHint.title"),children:e.jsx(Ge,{})}):null,t==="devin"?e.jsx(I,{title:r("limits.devin.setupHint.title"),children:e.jsx(Ue,{})}):null,t==="deepseek"?e.jsx(I,{title:r("limits.deepseek.setupHint.title"),children:e.jsx(ze,{onSaved:l})}):null]}),n,s,o,c,i);if(t==="opencodeGo"&&a.subscription_status==="inactive")return ce(t,e.jsx(A,{children:r("limits.opencodeGo.status.inactive")}),n,s,o,c,i);if(a.error)return ce(t,e.jsxs(e.Fragment,{children:[e.jsx(A,{tone:"error",children:a.error}),t==="kiro"?yt(re.kiro.extra,a):null,t==="deepseek"?e.jsx(I,{title:r("limits.deepseek.setupHint.title"),children:e.jsx(ze,{onSaved:l})}):null,t==="deepseek"?e.jsx(vt,{providerId:t,data:a,onSaved:l}):null,t==="opencodeGo"?e.jsx(I,{title:r("limits.opencodeGo.setupHint.title"),children:e.jsx(Le,{onSaved:l})}):null,t==="commandCode"?e.jsx(I,{title:r("limits.commandCode.setupHint.title"),children:e.jsx($e,{onSaved:l})}):null,t==="codingPlan"?e.jsx(I,{title:r("limits.codingPlan.setupHint.title"),children:e.jsx(Be,{})}):null,t==="agentPlan"?e.jsx(I,{title:r("limits.agentPlan.setupHint.title"),children:e.jsx(Ge,{})}):null,t==="devin"?e.jsx(I,{title:r("limits.devin.setupHint.title"),children:e.jsx(Ue,{})}):null]}),n,s,o,c,i);const d=ue(t),m=a.plan_label?`${d} ${a.plan_label}`:d;let u=null;if(a.auth_action_required==="reauth"){const h=t==="commandCode"?ot():t==="devin"?lt():ka[t];u=e.jsx(V,{label:r("limits.reauth.badge"),age:ae(a.cached_at),tone:"stale",tooltip:h?r("limits.reauth.tooltip",{command:h}):null})}if(!u&&t==="antigravity")if(a.cached){const h=ae(a.cached_at);u=e.jsx(V,{label:r("limits.label.antigravity_cached"),age:h,tone:"cached",tooltip:r("limits.tooltip.antigravity_cached")})}else u=e.jsx(V,{label:r("limits.label.antigravity_live"),tone:"live",tooltip:r("limits.tooltip.antigravity_live")});!u&&(t==="qoder"||t==="qoderCn")&&a.cached&&(u=e.jsx(V,{label:r("limits.label.antigravity_cached"),age:ae(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.qoder_cached")})),!u&&(t==="codingPlan"||t==="agentPlan")&&a.cached&&(u=e.jsx(V,{label:r("limits.label.antigravity_cached"),age:ae(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.ark_cached")}));const p=a.provenance;return p?.stale&&!u&&(u=e.jsx(V,{label:r("limits.provenance.stale"),age:ae(p.captured_at),tone:"stale",tooltip:r("limits.provenance.tooltip",{source:p.source,confidence:p.confidence})})),Ea(t,a,m,i,n,s,u,o,c,l)}function Ta({defaultDir:t}){const[a,i]=g.useState(!1),s=["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 c=>{c.stopPropagation();try{await navigator.clipboard.writeText(s),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:s}),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 D({n:t,children:a}){return e.jsxs("li",{className:"flex gap-2.5",children:[e.jsx("span",{className:"mt-[1px] flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-oai-brand/15 text-[9px] font-semibold text-oai-brand",children:t}),e.jsx("div",{className:"min-w-0 flex-1 leading-snug",children:a})]})}function he(){return e.jsx("svg",{viewBox:"0 0 12 12","aria-hidden":"true",className:"h-2.5 w-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M4.5 2.75h4.75V7.5M9.25 2.75 3 9"})})}function fe({provider:t,onSaved:a}){const[i,n]=g.useState(""),[s,o]=g.useState("idle"),[c,l]=g.useState(!1),d=async m=>{m.preventDefault(),m.stopPropagation();const u=i.trim();if(!(!u||s==="saving")){o("saving"),l(!1);try{await St(t,u),n(""),o("saved"),a?.()}catch{o("idle"),l(!0)}}};return e.jsxs("form",{className:"mt-1.5 space-y-1.5",onSubmit:d,onClick:m=>m.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"password",value:i,onChange:m=>{n(m.target.value),o("idle"),l(!1)},placeholder:r("limits.apiKey.placeholder"),"aria-label":r("limits.apiKey.placeholder"),autoComplete:"new-password",spellCheck:!1,className:"min-w-0 flex-1 rounded-md border border-oai-gray-300 bg-white px-2 py-1 font-mono text-[11px] text-oai-gray-800 outline-none focus:border-oai-brand dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:text-oai-gray-100"}),e.jsx("button",{type:"submit",disabled:!i.trim()||s==="saving",className:"shrink-0 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 disabled:opacity-50 transition-colors",children:s==="saving"?r("limits.apiKey.saving"):s==="saved"?r("limits.apiKey.saved"):r("limits.apiKey.save")})]}),e.jsx("div",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:c?r("limits.apiKey.save_failed"):r("limits.apiKey.local_note")})]})}function vt({providerId:t,data:a,onSaved:i}){if(a?.credential_source!=="env")return null;const n=pa[t],s=ga[t];return!n||!s?null:e.jsxs("div",{className:"mt-1.5 rounded-md border border-amber-300/60 bg-amber-50/60 px-2 py-1.5 text-[10.5px] leading-snug text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200",children:[e.jsx("div",{children:r("limits.apiKey.env_note",{env:n})}),e.jsx(fe,{provider:s,onSaved:i}),nt()==="macos"?e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e.jsx("code",{className:"rounded bg-white/70 px-1 py-0.5 font-mono text-[10px] dark:bg-oai-gray-900/60",children:r("limits.apiKey.env_unset_command",{env:n})}),e.jsx("span",{children:r("limits.apiKey.env_unset_note")})]}):null]})}function I({title:t,children:a}){return e.jsxs("div",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",onClick:i=>i.stopPropagation(),onKeyDown:i=>i.stopPropagation(),children:[e.jsx("div",{className:"font-medium text-oai-gray-800 dark:text-oai-gray-100",children:t}),a]})}function Le({onSaved:t}){return e.jsxs("div",{className:"mt-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[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(D,{n:"1",children:[e.jsx("div",{children:r("limits.opencodeGo.setupHint.step1")}),e.jsxs("a",{href:"https://opencode.ai",target:"_blank",rel:"noreferrer",onClick:a=>a.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.opencodeGo.setupHint.cta"),e.jsx(he,{})]})]}),e.jsx(D,{n:"2",children:e.jsx("div",{children:r("limits.opencodeGo.setupHint.step2")})}),e.jsxs(D,{n:"3",children:[e.jsx("div",{children:r("limits.opencodeGo.setupHint.step3")}),e.jsx(fe,{provider:"opencode-go",onSaved:t})]})]})]})}function $e({onSaved:t}){const a=ot();return e.jsxs("div",{className:"mt-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[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(D,{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:a})]}),e.jsxs(D,{n:"2",children:[e.jsx("div",{children:r("limits.commandCode.setupHint.step2")}),e.jsx(fe,{provider:"command-code",onSaved:t})]})]})]})}function ze({onSaved:t}){return e.jsxs("div",{className:"mt-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.deepseek.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(D,{n:"1",children:[e.jsx("div",{children:r("limits.deepseek.setupHint.step1")}),e.jsxs("a",{href:"https://platform.deepseek.com",target:"_blank",rel:"noreferrer",onClick:a=>a.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.deepseek.setupHint.cta"),e.jsx(he,{})]})]}),e.jsxs(D,{n:"2",children:[e.jsx("div",{children:r("limits.deepseek.setupHint.step2")}),e.jsx(fe,{provider:"deepseek",onSaved:t})]})]})]})}function Ue(){const t=lt();return e.jsxs("div",{className:"mt-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[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(D,{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 Be(){const[t,a]=g.useState(!1),i=["npm install -g @volcengine/ark-cli","arkcli auth login volc-sso # browser SSO (recommended)","arkcli auth status # verify the session"].join(`
|
|
5
|
+
`),n=async s=>{s.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[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(D,{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:s=>s.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.codingPlan.setupHint.cta"),e.jsx(he,{})]})]}),e.jsxs(D,{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(D,{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:n,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 Ge(){const[t,a]=g.useState(!1),i=[r("limits.agentPlan.setupHint.snippet_install"),r("limits.agentPlan.setupHint.snippet_login"),r("limits.agentPlan.setupHint.snippet_status")].join(`
|
|
6
|
+
`),n=async s=>{s.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[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(D,{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:s=>s.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.agentPlan.setupHint.cta"),e.jsx(he,{})]})]}),e.jsxs(D,{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(D,{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:n,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 De(t){const[a,i]=g.useState(0);return g.useLayoutEffect(()=>{const n=t.current;if(!n)return;const s=[...n.querySelectorAll("[data-limit-label]")].filter(d=>d.closest("[data-limit-label-group]")===n);let o=0,c=null;if(s.length>0)try{c=document.createElement("canvas").getContext("2d")}catch{c=null}if(c){const d=window.getComputedStyle(s[0]);c.font=`${d.fontStyle} ${d.fontWeight} ${d.fontSize} ${d.fontFamily}`;for(const m of s)o=Math.max(o,c.measureText(m.textContent).width)}const l=Math.ceil(o);i(d=>d===l?d:l)}),a}function Ia({claude:t,codex:a,cursor:i,gemini:n,kimi:s,kiro:o,grok:c,antigravity:l,copilot:d,zcode:m,opencodeGo:u,commandCode:p,qoder:h,qoderCn:y,codingPlan:b,agentPlan:k,devin:S,workbuddy:E,workbuddyAi:F,deepseek:C,order:j,visibility:L,displayMode:J,subscriptions:K=[],showSubscriptions:H=!0,onProviderKeySaved:R=null}){const T={claude:t,codex:a,cursor:i,gemini:n,kimi:s,kiro:o,grok:c,antigravity:l,copilot:d,zcode:m,opencodeGo:u,commandCode:p,qoder:h,qoderCn:y,codingPlan:b,agentPlan:k,devin:S,workbuddy:E,workbuddyAi:F,deepseek:C},P=g.useRef(null),$=De(P),[Q,ee]=g.useState(null),[O,be]=g.useState(()=>Date.now()),oe=[...new Set(Array.isArray(j)&&j.length>0?j:ja)],U=J===M.REMAINING?M.REMAINING:M.USED;g.useEffect(()=>{const v=setInterval(()=>be(Date.now()),6e4);return()=>clearInterval(v)},[]);const B=new Map;if(H)for(const v of K||[]){if(!v?.provider)continue;const z=new Date(v.nextBillingAt).getTime();if(!Number.isFinite(z))continue;const x=B.get(v.provider);if(!x){B.set(v.provider,v);continue}const N=new Date(x.nextBillingAt).getTime(),f=z>O,_=N>O;(f&&(!_||N>z)||!f&&!_&&z>N)&&B.set(v.provider,v)}const le=oe.filter(v=>!L||L[v]!==!1||B.has(v)).map(v=>Ra(v,T[v],U,Q===v,()=>ee(z=>z===v?null:v),B.get(v)||null,O,R)).filter(Boolean);return e.jsx(zt,{delay:.15,children:e.jsx("div",{ref:P,"data-limit-label-group":"",className:"flex flex-col gap-3",style:$>0?{"--tt-limits-label-w":`${$}px`}:void 0,children:le.length>0?le:e.jsx(A,{children:r("limits.status.all_hidden")})})})}async function kt(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 Aa(){const t=await fetch("/functions/tokentracker-subscription-manager",{headers:{Accept:"application/json"},cache:"no-store"}),a=await kt(t);return Array.isArray(a.subscriptions)?a.subscriptions:[]}async function Ee(t){const a=await Pt();return kt(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 Ha(t){return Ee({action:"create",subscription:t})}function Oa(t,a){return Ee({action:"update",id:t,subscription:a})}function Fa(t){return Ee({action:"delete",id:t})}const ke={plan:"",provider:"",cycle:"monthly",autoRenew:!0,startedAt:""};function La(t){const a=new Date(t);if(Number.isNaN(a.getTime()))return"";const i=n=>String(n).padStart(2,"0");return`${a.getFullYear()}-${i(a.getMonth()+1)}-${i(a.getDate())}T${i(a.getHours())}:${i(a.getMinutes())}`}function $a({subscriptions:t,onChanged:a}){const[i,n]=g.useState(!1),[s,o]=g.useState(null),[c,l]=g.useState(ke),[d,m]=g.useState(!1),[u,p]=g.useState(!1),[h,y]=g.useState(!1),[b,k]=g.useState(!1),[S,E]=g.useState(null),[F,C]=g.useState(!1),[j,L]=g.useState(!1),[J,K]=g.useState(null),[H,R]=g.useState(()=>Date.now()),T=g.useRef(null),P=W(),$=g.useMemo(()=>new Intl.DateTimeFormat(P,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),[P]);g.useEffect(()=>{const x=setInterval(()=>R(Date.now()),6e4);return()=>clearInterval(x)},[]),g.useEffect(()=>{if(!i)return;const x=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;T.current?.scrollIntoView?.({behavior:x?"auto":"smooth",block:"nearest"})},[i,s]);const Q=g.useMemo(()=>qe.map(x=>{const N=(t||[]).some(_=>_.provider===x&&_.id!==s),f=ue(x);return{value:x,label:N?`${f} ${r("subscriptions.form.provider_taken_suffix")}`:f,disabled:N}}),[P,t,s]),ee=g.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")}],[P]),O=g.useMemo(()=>[{value:"true",label:r("subscriptions.form.auto_renew_on")},{value:"false",label:r("subscriptions.form.auto_renew_off")}],[P]),be=g.useCallback(()=>{l(ke),o(null),p(!1),y(!1),k(!1),n(!0)},[]),oe=g.useCallback(x=>{l({plan:x.plan||"",provider:x.provider||"",cycle:x.cycle||"monthly",autoRenew:x.autoRenew,startedAt:La(new Date(da(x)).toISOString())}),o(x.id),p(!1),y(!1),k(!1),n(!0)},[]),U=g.useCallback(()=>{n(!1),o(null),l(ke),p(!1),y(!1),k(!1)},[]),B=g.useCallback(async x=>{if(x.preventDefault(),p(!1),!c.provider){y(!0);return}if((t||[]).some(q=>q.provider===c.provider&&q.id!==s)){k(!0);return}const f=new Date(c.startedAt).getTime();if(!Number.isFinite(f)){p(!0);return}const _={service:ue(c.provider),plan:c.plan,provider:c.provider||null,autoRenew:c.autoRenew,cycle:c.cycle,startedAt:f,nextBillingAt:it(f,c.cycle)};m(!0);try{s?await Oa(s,_):await Ha(_),U(),await a?.()}catch{p(!0)}finally{m(!1)}},[U,s,c,a,t]),le=g.useCallback(async()=>{if(S){C(!0),L(!1);try{await Fa(S.id),S.id===s&&U(),E(null),await a?.()}catch{L(!0)}finally{C(!1)}}},[U,s,a,S]),v=t||[],z=()=>{const x=s?v.find(f=>f.id===s):null,N=x?me(x,H):null;return e.jsxs("form",{ref:T,onSubmit:B,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:s?r("subscriptions.edit"):r("subscriptions.add")})}),N?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:x.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:$.format(new Date(N.endMs))})," · ",e.jsx("span",{className:N.expired?"text-oai-error":void 0,children:Ne(N.endMs,H)})]}):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(ve,{id:"subscription-provider",value:c.provider,onValueChange:f=>l({...c,provider:String(f)}),options:Q,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-1",children:e.jsx(Ie,{label:r("subscriptions.form.plan"),value:c.plan,maxLength:120,placeholder:r("subscriptions.form.plan_placeholder"),onChange:f=>l({...c,plan:f.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(ve,{id:"subscription-cycle",value:c.cycle,onValueChange:f=>l({...c,cycle:String(f)}),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(ve,{id:"subscription-auto-renew",value:String(c.autoRenew),onValueChange:f=>l({...c,autoRenew:f==="true"}),options:O,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(Ie,{label:r("subscriptions.form.started_at"),type:"datetime-local",value:c.startedAt,required:!0,onChange:f=>l({...c,startedAt:f.target.value})})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 sm:col-span-2",children:[s?e.jsx(te,{type:"button",variant:"secondary",size:"sm",onClick:()=>{const f=v.find(_=>_.id===s);f&&E(f)},className:"!text-red-600 dark:!text-red-400 mr-auto",children:r("subscriptions.delete")}):null,h?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_required")}):null,b?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_taken")}):null,u?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.error")}):null,e.jsx(te,{type:"button",variant:"secondary",size:"sm",onClick:U,children:r("shared.action.cancel")}),e.jsx(te,{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(te,{type:"button",size:"sm",onClick:be,className:"shrink-0 gap-1.5",children:[e.jsx(Kt,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:r("subscriptions.add")})]})]}),v.length===0&&!(i&&!s)?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(Qe,{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:[v.map(x=>{const N=me(x,H);if(!N)return null;const{endMs:f,expired:_}=N,q=_?100:N.progress*100,jt=!_&&f-H<=3*864e5,wt=J===x.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:()=>oe(x),"aria-label":`${r("subscriptions.edit")} ${x.service}`,"aria-expanded":s===x.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(Ye,{provider:Ve(x.provider)||"OTHER",size:14}),e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-white truncate",children:x.service}),e.jsx("span",{role:"img","aria-label":x.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),title:x.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),className:`inline-flex shrink-0 translate-y-px ${x.autoRenew?"text-oai-brand-600 dark:text-oai-brand-400":"text-blue-600 dark:text-blue-400"}`,children:x.autoRenew?e.jsx(at,{size:14,strokeWidth:2,"aria-hidden":!0}):e.jsx(Se,{size:14,strokeWidth:2,"aria-hidden":!0})}),x.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:x.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:`${_?"bg-red-500":jt?"bg-amber-500":"bg-blue-500"} rounded-full h-full block transition-[width] duration-500 ease-out`,style:{width:`${q}%`,minWidth:q>0?"3px":0}})}),e.jsx("span",{className:`text-[10px] tabular-nums shrink-0 ${_?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:st(f,H)})]})]}),s===x.id?e.jsx("div",{className:"border-t border-oai-gray-100 dark:border-oai-gray-800",children:z()}):null,s!==x.id&&wt?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:x.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:$.format(new Date(f))})," · ",e.jsx("span",{className:_?"text-oai-error":void 0,children:Ne(f,H)})," · ",e.jsx("span",{children:x.autoRenew?r("subscriptions.status.auto_renew"):r("subscriptions.status.manual")})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(te,{type:"button",variant:"secondary",size:"sm",onClick:()=>oe(x),children:r("subscriptions.edit")})})]}):null]},x.id)}),i&&!s?e.jsx("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:z()}):null]}),e.jsx(Gt,{open:!!S,title:r("subscriptions.confirm_delete_title"),description:S?.service||"",error:j?r("subscriptions.delete_error"):null,confirmLabel:r("subscriptions.delete"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:F,onCancel:()=>{E(null),L(!1)},onConfirm:le})]})}const je=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),za="x-apple.systempreferences:com.apple.preference.notifications";function We(t){const a=Date.parse(t);return Number.isFinite(a)?new Intl.DateTimeFormat(W(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(a)):String(t)}function Ua(t){const a=Object.entries(t||{}).filter(([o,c])=>o!=="fetched_at"&&c&&typeof c=="object"&&c.configured!==!1),i=a.filter(([,o])=>!!o.error),n=a.some(([,o])=>!!o.start_plan?.error||!!o.reset_credits?.error),s=a.filter(([,o])=>o.provenance?.stale===!0||o.provenance?.source==="disk-cache");return a.length&&i.length===0&&!n&&s.length===a.length?{kind:"stale"}:i.length||s.length||n?{kind:"partial",at:t.fetched_at}:{kind:"updated",at:t.fetched_at}}function Ba(){const t=Jt(),a=Tt(),i=r("limits.alert.blocked"),n=a?Re.button:Re.div;return e.jsxs(n,{type:a?"button":void 0,onClick:a?()=>It({type:"action",name:"openURL",value:za}):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 hr(){const t=Ct(),a=$t(),i=w.useRef(null),n=w.useCallback(()=>{const R=Te();if(!a.showSubscriptions)return R;const T=i.current;return!T||T.size===0?R:R.filter(P=>!T.has(P))},[a.showSubscriptions]),{data:s,error:o,isLoading:c,refresh:l}=Ot(t?{initialRefresh:!0,initialState:t,publishToPreloadCache:!0,getHiddenProviders:n}:{initialRefresh:!0,publishToPreloadCache:!0,getHiddenProviders:n}),d=Ft(),[m,u]=w.useState([]),[p,h]=w.useState(!1),[y,b]=w.useState(!1),[k]=Mt(),S=w.useRef(0),E=w.useRef(!1),[F,C]=w.useState(!1),[j,L]=w.useState(null),J=w.useCallback(async()=>{if(!E.current){E.current=!0,C(!0),L(null);try{const R=await l();L(R?Ua(R):{kind:"failed"})}finally{E.current=!1,C(!1)}}},[l]),K=w.useCallback(async()=>{if(!je&&!ye())return;const R=++S.current;try{const T=await Aa();if(R!==S.current)return;u(T),h(!1);const P=new Set(T.map(O=>O?.provider).filter(Boolean)),$=i.current,Q=Te(),ee=$===null?a.showSubscriptions&&[...P].some(O=>Q.includes(O)):a.showSubscriptions&&($.size!==P.size||[...P].some(O=>!$.has(O)));i.current=P,ee&&l()}catch{if(R!==S.current)return;h(!0)}},[a.showSubscriptions,l]),H=w.useRef(a.showSubscriptions);return w.useEffect(()=>{H.current!==a.showSubscriptions&&(H.current=a.showSubscriptions,!(!je&&!ye())&&l())},[a.showSubscriptions,l]),w.useEffect(()=>{K()},[K]),w.useEffect(()=>{k.get("openSubscriptions")==="1"&&b(!0)},[k]),w.useEffect(()=>{d.enabled&&s&&Lt(s)},[d.enabled,s]),!je&&!ye()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(Wt,{})}):e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-6 grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-2 gap-y-2 sm:mb-8 sm:gap-x-4 sm:gap-y-3",children:[e.jsx("h1",{className:"min-w-0 text-2xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white",children:r("nav.limits")}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[d.enabled&&d.permissionBlocked?e.jsx(Ba,{}):null,e.jsx("button",{type:"button",onClick:()=>{J()},disabled:F,"aria-label":r("limits.page.refresh"),title:r("limits.page.refresh"),className:"shrink-0 inline-flex h-10 w-10 sm:h-9 sm: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(Dt,{className:`h-4 w-4 ${F?"animate-spin":""}`,"aria-hidden":!0})}),e.jsxs(qt,{open:y,onOpenChange:b,children:[e.jsx(Vt,{"aria-label":r("limits.page.openSubscriptions"),title:r("limits.page.openSubscriptions"),className:"shrink-0 inline-flex h-10 w-10 sm:h-9 sm: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(Qe,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(Yt,{children:e.jsx(Zt,{side:"bottom",align:"end",sideOffset:8,className:"z-50",children:e.jsx(Xt,{children:e.jsx($a,{subscriptions:m,onChanged:K})})})})]}),e.jsx("button",{type:"button",onClick:()=>{d.setEnabled(!d.enabled)},"aria-label":d.enabled?r("limits.alert.disable"):r("limits.alert.enable"),title:d.enabled?r("limits.alert.disable"):r("limits.alert.enable"),className:`inline-flex h-10 w-10 sm:h-9 sm: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 ${d.enabled&&d.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:d.enabled?e.jsx(ea,{className:"h-4 w-4","aria-hidden":!0}):e.jsx(Qt,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(Et,{to:"/settings?section=limits","aria-label":r("limits.page.openSettings"),title:r("limits.page.openSettings"),className:"shrink-0 inline-flex h-10 w-10 sm:h-9 sm: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(Rt,{className:"h-4 w-4","aria-hidden":!0})})]}),e.jsx("p",{className:"col-span-2 hidden sm:block sm:text-base text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.page.subtitle")})]}),e.jsx("span",{role:"status",className:"sr-only",children:F?r("limits.page.refresh_loading"):""}),j?.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:We(j.at)})}):null,j?.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:We(j.at)})}):null,j?.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,j?.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,c?e.jsx(ia,{}):e.jsxs(e.Fragment,{children:[o?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:o}):null,p?e.jsx("p",{className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("subscriptions.load_error")}):null,e.jsx(Ia,{claude:s?.claude,codex:s?.codex,cursor:s?.cursor,gemini:s?.gemini,kimi:s?.kimi,kiro:s?.kiro,grok:s?.grok,antigravity:s?.antigravity,copilot:s?.copilot,zcode:s?.zcode,opencodeGo:s?.opencodeGo,commandCode:s?.commandCode,qoder:s?.qoder,qoderCn:s?.qoderCn,codingPlan:s?.codingPlan,agentPlan:s?.agentPlan,devin:s?.devin,workbuddy:s?.workbuddy,workbuddyAi:s?.workbuddyAi,deepseek:s?.deepseek,order:a.order,visibility:a.visibility,displayMode:a.displayMode,subscriptions:m,showSubscriptions:a.showSubscriptions!==!1,onProviderKeySaved:()=>{l()}})]})]})})})}export{hr as LimitsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as h,j as e,c as r}from"./__vite-browser-external-
|
|
1
|
+
import{r as h,j as e,c as r}from"./__vite-browser-external-Lw3ipvYF.js";import{A as p}from"./arrow-up-right-C87CvEJ5.js";import{D as b}from"./download-IIXYYmyo.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-CvvpsW-U.js";import{A as ke}from"./arrow-left-DiOsjgdu.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-Lw3ipvYF.js";import{A as ke}from"./arrow-left-CjLKt_5C.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-
|
|
1
|
+
import{u as p,a as x,r as l,j as a,c as o,X as y}from"./__vite-browser-external-Lw3ipvYF.js";import{L as m}from"./LoginCard-CQm_T5K2.js";import{D as h,a as b,b as f,c as j,d as k,e as v}from"./DialogTitle-B3m-31sy.js";import{D as w}from"./DialogDescription-BSCcGkVT.js";import"./arrow-left-CjLKt_5C.js";import"./composite-B28yORTL.js";import"./store-DQpd_ZKv.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-
|
|
1
|
+
import{d as j,e as N,a as _,r,c as s,j as e,L as p}from"./__vite-browser-external-Lw3ipvYF.js";import{L as k}from"./LoginCard-CQm_T5K2.js";import"./arrow-left-CjLKt_5C.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};
|