tokentracker-cli 0.97.1 → 0.98.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/README.de.md +3 -3
  2. package/README.ja.md +3 -3
  3. package/README.ko.md +3 -3
  4. package/README.md +7 -5
  5. package/README.zh-CN.md +3 -3
  6. package/dashboard/dist/assets/AchievementBadge-DlZklawB.js +1 -0
  7. package/dashboard/dist/assets/{AchievementsPage-CrqvRxnb.js → AchievementsPage-CprbOKnt.js} +2 -2
  8. package/dashboard/dist/assets/AchievementsSection-BKLJBRKw.js +1 -0
  9. package/dashboard/dist/assets/{BadgeDetailModal-CquST3dj.js → BadgeDetailModal-CfVXLh_t.js} +1 -1
  10. package/dashboard/dist/assets/{BotAnimated-EXhdUHSg.js → BotAnimated-wzqeGbEY.js} +1 -1
  11. package/dashboard/dist/assets/{Card-Il2WWgOG.js → Card-B-gcOAn7.js} +1 -1
  12. package/dashboard/dist/assets/{ClawdAnimated-DioF5wa-.js → ClawdAnimated-1c5ezBBN.js} +2 -2
  13. package/dashboard/dist/assets/CommandPalette-CD8ggEF6.js +1 -0
  14. package/dashboard/dist/assets/CommunityStatsModal-b2fPhi1E.js +1 -0
  15. package/dashboard/dist/assets/{ConfirmModal-BHWQLUCM.js → ConfirmModal-ARBkT8AC.js} +1 -1
  16. package/dashboard/dist/assets/{Controls--LFhExZX.js → Controls-WFXDjIYG.js} +1 -1
  17. package/dashboard/dist/assets/DashboardPage-XtiZa2JN.js +1 -0
  18. package/dashboard/dist/assets/{DevicePage-RKTirqz0.js → DevicePage-BCwSpNXa.js} +1 -1
  19. package/dashboard/dist/assets/{DialogClose-DPFsTKmJ.js → DialogClose-D2PE0TAc.js} +1 -1
  20. package/dashboard/dist/assets/DialogDescription-5LunWukT.js +1 -0
  21. package/dashboard/dist/assets/{DialogTitle-DolLpmFL.js → DialogTitle-Bby0zSCw.js} +1 -1
  22. package/dashboard/dist/assets/{FadeIn-92GGNCPe.js → FadeIn-Cx1hl4so.js} +1 -1
  23. package/dashboard/dist/assets/{HeaderGithubStar-GfXudotT.js → HeaderGithubStar-my4zR6Pp.js} +1 -1
  24. package/dashboard/dist/assets/{HoverTooltip-n7gbPEsq.js → HoverTooltip-DOiGAPLE.js} +1 -1
  25. package/dashboard/dist/assets/{IpCheckPage-BaQOTbXi.js → IpCheckPage-4SdHlFuA.js} +1 -1
  26. package/dashboard/dist/assets/{LandingPage-D3JcvxW_.js → LandingPage-bSWc9xiS.js} +2 -2
  27. package/dashboard/dist/assets/{LeaderboardAvatar-tVaWJXZ3.js → LeaderboardAvatar-EN4117E5.js} +1 -1
  28. package/dashboard/dist/assets/LeaderboardPage-Bwjf-xZl.js +2 -0
  29. package/dashboard/dist/assets/{LeaderboardProfileModal-DmvcCVS7.js → LeaderboardProfileModal-B1mgVtfP.js} +4 -4
  30. package/dashboard/dist/assets/{LeaderboardProfilePage-VSv3IlzS.js → LeaderboardProfilePage-DVt5S3lY.js} +1 -1
  31. package/dashboard/dist/assets/{LimitsPage-CtxgT20z.js → LimitsPage-BCXjJE1B.js} +5 -5
  32. package/dashboard/dist/assets/{LocalOnlyNotice-O9o586G8.js → LocalOnlyNotice-CzeH4OoJ.js} +1 -1
  33. package/dashboard/dist/assets/LoginCard-aiqSQInP.js +1 -0
  34. package/dashboard/dist/assets/{LoginModal-CJ3g7tBc.js → LoginModal-DdGKIi8h.js} +1 -1
  35. package/dashboard/dist/assets/{LoginPage-DPWzPywx.js → LoginPage-D7xGSoMn.js} +1 -1
  36. package/dashboard/dist/assets/PetPage-Dlb6rNpF.js +1 -0
  37. package/dashboard/dist/assets/{PopoverPopup-nL3YOLPO.js → PopoverPopup-Xbruj7Zi.js} +1 -1
  38. package/dashboard/dist/assets/{ProviderIcon-C5RX_xPk.js → ProviderIcon-BPxacBzj.js} +1 -1
  39. package/dashboard/dist/assets/{ResetPasswordPage-DW_NCwA_.js → ResetPasswordPage-9wgPnLRj.js} +1 -1
  40. package/dashboard/dist/assets/{SegmentedControl-CS6wQtck.js → SegmentedControl-CYFcZFNE.js} +1 -1
  41. package/dashboard/dist/assets/{Select-YqlqvbT5.js → Select-zpFEMqpk.js} +1 -1
  42. package/dashboard/dist/assets/{SelectItemText-BahqsiIc.js → SelectItemText-Bldm5Y0C.js} +1 -1
  43. package/dashboard/dist/assets/{ServiceStatusPage-DyhutLUy.js → ServiceStatusPage-dgtwFazV.js} +1 -1
  44. package/dashboard/dist/assets/{SessionsPage-wbvi4EHi.js → SessionsPage-DHfpv53M.js} +2 -2
  45. package/dashboard/dist/assets/SettingsPage-DcGToOT7.js +2 -0
  46. package/dashboard/dist/assets/SkillsPage-DiQDLw2l.js +1 -0
  47. package/dashboard/dist/assets/TokenGalaxy-GDx7ftMU.js +4426 -0
  48. package/dashboard/dist/assets/ToolbarRootContext-PoCcP2AV.js +1 -0
  49. package/dashboard/dist/assets/{TrendMonitor-BtBcCjx-.js → TrendMonitor-CIfq_yk8.js} +1 -1
  50. package/dashboard/dist/assets/{WidgetsPage-BSNl2WIL.js → WidgetsPage-Dwy-E3Lf.js} +1 -1
  51. package/dashboard/dist/assets/{WrappedPage-d5oiNV4T.js → WrappedPage-Ce7NV6Ij.js} +1 -1
  52. package/dashboard/dist/assets/__vite-browser-external-D-WLjvZW.js +45 -0
  53. package/dashboard/dist/assets/{agent-logos-CCVzO3uU.js → agent-logos-BY8n7b9g.js} +1 -1
  54. package/dashboard/dist/assets/arrow-up-right-BDiV6Wlk.js +1 -0
  55. package/dashboard/dist/assets/check-Chyo6ujc.js +1 -0
  56. package/dashboard/dist/assets/{composite-CWz1s64R.js → composite-DgBqMs_Z.js} +1 -1
  57. package/dashboard/dist/assets/copy-ENRv4pAy.js +1 -0
  58. package/dashboard/dist/assets/download-D3y3gd-z.js +1 -0
  59. package/dashboard/dist/assets/external-link-VxSAxWnH.js +1 -0
  60. package/dashboard/dist/assets/flame-CPdTWeRo.js +1 -0
  61. package/dashboard/dist/assets/{format-tokens-Bs2YotMr.js → format-tokens-BF2G89Q7.js} +1 -1
  62. package/dashboard/dist/assets/{icons-OKyij2y_.js → icons-D6rfdVyV.js} +1 -1
  63. package/dashboard/dist/assets/{index-CN7xY7j_.js → index-4bHcp2Ep.js} +1 -1
  64. package/dashboard/dist/assets/{index-C8nY1OaT.js → index-CgmpxGym.js} +1 -1
  65. package/dashboard/dist/assets/{index-DOwPCQx2.js → index-mzMCUT_4.js} +1 -1
  66. package/dashboard/dist/assets/info-BMso9PcY.js +1 -0
  67. package/dashboard/dist/assets/link-2-Bg34XOcd.js +1 -0
  68. package/dashboard/dist/assets/loader-circle-C4Vul1Yx.js +1 -0
  69. package/dashboard/dist/assets/maximize-2-BBqcwFFo.js +1 -0
  70. package/dashboard/dist/assets/{modifiers.esm-D_aVVjx5.js → modifiers.esm-B2F4Iiey.js} +1 -1
  71. package/dashboard/dist/assets/module-B5tW98jG.js +3 -0
  72. package/dashboard/dist/assets/monitor-smartphone-k1Ja3ngF.js +1 -0
  73. package/dashboard/dist/assets/plus-BaCIejxc.js +1 -0
  74. package/dashboard/dist/assets/provider-display-BYxmO9Bu.js +42 -0
  75. package/dashboard/dist/assets/{react-jS0-5kwE.js → react-xGx5RIqz.js} +1 -1
  76. package/dashboard/dist/assets/search-LZQC7j6a.js +1 -0
  77. package/dashboard/dist/assets/{skills-api-PwUMTdmV.js → skills-api-yLfQkApo.js} +1 -1
  78. package/dashboard/dist/assets/{sortable.esm-BDdw7tkz.js → sortable.esm-B8XRHrmA.js} +1 -1
  79. package/dashboard/dist/assets/{store-CFdu9yv_.js → store-DfUIKvz3.js} +1 -1
  80. package/dashboard/dist/assets/terminal-CsFh6eZS.js +1 -0
  81. package/dashboard/dist/assets/trash-CVk10mDa.js +1 -0
  82. package/dashboard/dist/assets/{use-community-stats-D55oU9bu.js → use-community-stats-DP7lJyDV.js} +1 -1
  83. package/dashboard/dist/assets/{use-latest-request-guard-BO89yQ3n.js → use-latest-request-guard-B7uLArxV.js} +1 -1
  84. package/dashboard/dist/assets/{use-limits-display-prefs-C358N7B0.js → use-limits-display-prefs-DG97cWcv.js} +1 -1
  85. package/dashboard/dist/assets/{use-ordered-list-B9ZYDS1K.js → use-ordered-list-ChQc2v-Q.js} +1 -1
  86. package/dashboard/dist/assets/use-reduced-motion-BoFF1l9U.js +1 -0
  87. package/dashboard/dist/assets/use-session-efficiency-pref-CtF9JAlF.js +1 -0
  88. package/dashboard/dist/assets/{use-transform-9S4Ruq_s.js → use-transform-DVIBk7FO.js} +1 -1
  89. package/dashboard/dist/assets/{use-usage-limits-CpnM5V06.js → use-usage-limits-BYQuJ9Ud.js} +1 -1
  90. package/dashboard/dist/assets/{useCurrency-BKJGW_4l.js → useCurrency-CNkzJCP9.js} +1 -1
  91. package/dashboard/dist/assets/{useTokenFormat-CTB5svOB.js → useTokenFormat-CU3MtXtS.js} +1 -1
  92. package/dashboard/dist/assets/zap-D5k595AR.js +1 -0
  93. package/dashboard/dist/index.html +13 -11
  94. package/dashboard/dist/ip-check.html +1 -1
  95. package/dashboard/dist/leaderboard.html +1 -1
  96. package/dashboard/dist/llms.txt +3 -2
  97. package/dashboard/dist/share.html +1 -1
  98. package/package.json +2 -2
  99. package/src/commands/init.js +1 -0
  100. package/src/commands/status.js +13 -0
  101. package/src/commands/sync.js +61 -4
  102. package/src/lib/cloud-account.js +108 -0
  103. package/src/lib/grok-limits.js +37 -0
  104. package/src/lib/opencode-config.js +20 -1
  105. package/src/lib/pricing/curated-overrides.json +22 -0
  106. package/src/lib/pricing/index.js +9 -1
  107. package/src/lib/pricing/seed-snapshot.json +1 -1
  108. package/src/lib/rollout.js +1244 -168
  109. package/src/lib/usage-limits.js +7 -1
  110. package/dashboard/dist/assets/AchievementBadge-BdvqY4Qb.js +0 -1
  111. package/dashboard/dist/assets/AchievementsSection-wyLAM9N7.js +0 -1
  112. package/dashboard/dist/assets/CommandPalette-CaDx06tM.js +0 -1
  113. package/dashboard/dist/assets/CommunityStatsModal-BbYWzM07.js +0 -1
  114. package/dashboard/dist/assets/DashboardPage-DuqJOpHL.js +0 -1
  115. package/dashboard/dist/assets/DialogDescription-DgaV8Gtk.js +0 -1
  116. package/dashboard/dist/assets/LeaderboardPage-NqHcStnk.js +0 -2
  117. package/dashboard/dist/assets/LoginCard-JCejigVu.js +0 -1
  118. package/dashboard/dist/assets/PetPage-MSJ3jseK.js +0 -1
  119. package/dashboard/dist/assets/SettingsPage-HGSwpV1O.js +0 -2
  120. package/dashboard/dist/assets/SkillsPage-BbVT9oyh.js +0 -1
  121. package/dashboard/dist/assets/TokenGalaxy-Cej6MLu6.js +0 -4314
  122. package/dashboard/dist/assets/ToolbarRootContext-D9pPY73U.js +0 -1
  123. package/dashboard/dist/assets/__vite-browser-external-CjrP5KfC.js +0 -45
  124. package/dashboard/dist/assets/arrow-up-right-AKItXMyh.js +0 -1
  125. package/dashboard/dist/assets/check-BQw5n0V0.js +0 -1
  126. package/dashboard/dist/assets/copy-CF8XNmv3.js +0 -1
  127. package/dashboard/dist/assets/download-BZvLU_hD.js +0 -1
  128. package/dashboard/dist/assets/external-link-bZrcVkeE.js +0 -1
  129. package/dashboard/dist/assets/flame-CMHolW1z.js +0 -1
  130. package/dashboard/dist/assets/info-CU7bMBhU.js +0 -1
  131. package/dashboard/dist/assets/link-2-wwoUOujz.js +0 -1
  132. package/dashboard/dist/assets/loader-circle-BK3Ltc-j.js +0 -1
  133. package/dashboard/dist/assets/maximize-2-DIPnLqR8.js +0 -1
  134. package/dashboard/dist/assets/module-DUSXqJtA.js +0 -3
  135. package/dashboard/dist/assets/monitor-smartphone-4NOM9BHb.js +0 -1
  136. package/dashboard/dist/assets/plus-JqSTJ28Y.js +0 -1
  137. package/dashboard/dist/assets/provider-display-CEFlg9ho.js +0 -42
  138. package/dashboard/dist/assets/search-CbBetPN7.js +0 -1
  139. package/dashboard/dist/assets/terminal-Dh7Sh6IG.js +0 -1
  140. package/dashboard/dist/assets/trash-B6_OaEVL.js +0 -1
  141. package/dashboard/dist/assets/use-reduced-motion-DWHVI51t.js +0 -1
  142. package/dashboard/dist/assets/use-session-efficiency-pref-CwGRDyVq.js +0 -1
  143. package/dashboard/dist/assets/zap-DGdBuT6m.js +0 -1
@@ -1,8 +1,8 @@
1
- import{m as q,j as e,e as De,c as r,k as ae,r as x,S as at,B,av as rt,d as T,h as it,G as ve,L as nt,aw as st,J as ot,ab as lt}from"./__vite-browser-external-CjrP5KfC.js";import{m as ke}from"./react-jS0-5kwE.js";import{P as ge,c as ct,r as re,a as dt,u as ut,b as mt,s as xt}from"./use-usage-limits-CpnM5V06.js";import{b as k,c as Ee,l as Z,d as He,u as pt}from"./use-limits-display-prefs-C358N7B0.js";import{C as Ie}from"./Card-Il2WWgOG.js";import{F as gt}from"./FadeIn-92GGNCPe.js";import{P as Ae}from"./ProviderIcon-C5RX_xPk.js";import{H as ht}from"./HoverTooltip-n7gbPEsq.js";import{C as ft}from"./ConfirmModal-BHWQLUCM.js";import{I as je,L as bt}from"./LocalOnlyNotice-O9o586G8.js";import{S as ue}from"./Select-YqlqvbT5.js";import{P as yt}from"./plus-JqSTJ28Y.js";import{P as vt,a as kt,b as jt,c as wt,d as Nt}from"./PopoverPopup-nL3YOLPO.js";import{u as _t}from"./use-reduced-motion-DWHVI51t.js";import"./use-latest-request-guard-BO89yQ3n.js";import"./DialogTitle-DolLpmFL.js";import"./composite-CWz1s64R.js";import"./store-CFdu9yv_.js";import"./DialogDescription-DgaV8Gtk.js";import"./arrow-up-right-AKItXMyh.js";import"./download-BZvLU_hD.js";import"./ToolbarRootContext-D9pPY73U.js";import"./check-BQw5n0V0.js";import"./SelectItemText-BahqsiIc.js";const Ct=[["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"}]],Pt=q("bell-off",Ct);const Mt=[["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"}]],St=q("bell",Mt);const Tt=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v3",key:"otl347"}],["path",{d:"M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338",key:"7hb8p4"}],["path",{d:"M3 9h5.859",key:"numkqi"}],["path",{d:"M8 2v3",key:"1ioesn"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],Re=q("calendar-clock",Tt);const Dt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],Oe=q("clock",Dt);const Et=[["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"}]],Le=q("infinity",Et),Ht=[3,2,3,3,2,2,3];function I({className:t}){return e.jsx("div",{className:De("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function It(){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{className:"h-3 w-12 shrink-0"}),e.jsx(I,{className:"flex-1 h-1.5 rounded-full min-w-0"}),e.jsx(I,{className:"h-3 w-[30px] shrink-0"}),e.jsx(I,{className:"h-3 w-6 shrink-0"})]})}function At({bars:t,index:a}){const i=a%3===0?"w-24":a%3===1?"w-20":"w-[4.5rem]";return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(I,{className:"h-[14px] w-[14px] rounded shrink-0"}),e.jsx(I,{className:De("h-4",i)})]}),Array.from({length:t},(s,n)=>e.jsx(It,{},n))]})}function Rt(){return e.jsx(Ie,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(I,{className:"h-3.5 w-28"}),Ht.map((t,a)=>e.jsx(At,{bars:t,index:a},a))]})})}const he=100;function we(t){const a=Date.parse(t);return Number.isFinite(a)?a:null}function Ot(t){return Math.max(0,Math.min(he,Math.round(t)))}function Lt(t){return new Intl.DateTimeFormat(ae(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t))}function Ft(t,a,i){if(t==null||t>=a)return he;const s=a-t,n=a-i;return Ot(n/s*he)}function $t(t){const a=t.available_count;return a===null?null:Number.isInteger(a)&&a>=0?a:void 0}function Ut(t,{now:a}={}){if(!t||typeof t!="object")return null;const i=$t(t);if(i===void 0)return null;const s=Array.isArray(t.credits)?t.credits:[],n=a instanceof Date?a.getTime():Number(a??Date.now()),o=[];for(const l of s){const c=we(l?.expires_at);if(c==null)continue;const d=o.length+1;o.push({key:`reset-${d}`,label:r("limits.codex_reset_bank.row_label",{index:d}),expiresAt:Lt(c),expiresMs:c,percent:Ft(we(l?.granted_at),c,n)})}return i===0?null:o.length>0?{kind:"rows",availableCount:i??o.length,rows:o}:i>0?{kind:"count_only",availableCount:i,rows:[]}:null}const W=864e5;function A(t,a){const i=new Date(t),s=i.getUTCDate(),n=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()+a,1,i.getUTCHours(),i.getUTCMinutes())),o=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,0)).getUTCDate();return n.setUTCDate(Math.min(s,o)),n.getTime()}function Fe(t,a){if(a==="weekly")return t-7*W;if(a==="yearly")return A(t,-12);const i=new Date(t),s=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),0)).getUTCDate(),n=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()-1,1,i.getUTCHours(),i.getUTCMinutes()));return n.setUTCDate(Math.min(i.getUTCDate(),s)),n.getTime()}function $e(t,a){return a==="weekly"?t+7*W:a==="yearly"?A(t,12):A(t,1)}function Bt(t){if(t.startedAt!=null){const a=new Date(t.startedAt).getTime();if(Number.isFinite(a))return a}return Fe(new Date(t.nextBillingAt).getTime(),t.cycle)}function Gt(t,a,i){if(t.startedAt!=null){const s=new Date(t.startedAt).getTime();if(Number.isFinite(s))return s}return Fe(i,a)}function Wt(t,a,i){if(a==="weekly"){const c=7*W,d=i<=t?0:Math.floor((i-t)/c);return{startMs:t+d*c,endMs:t+(d+1)*c}}const s=a==="yearly"?12:1,n=s*30.436875*W;let o=i<=t?0:Math.floor((i-t)/n);for(;o>0&&A(t,o*s)>i;)o-=1;let l=0;for(;A(t,(o+1)*s)<=i&&l<12e3;)o+=1,l+=1;return{startMs:A(t,o*s),endMs:A(t,(o+1)*s)}}function ee(t,a){const i=new Date(t.nextBillingAt).getTime();if(!Number.isFinite(i))return null;const s=["weekly","monthly","yearly"].includes(t.cycle)?t.cycle:"monthly",n=Gt(t,s,i);if(!Number.isFinite(n))return null;let o,l,c=!1;t.autoRenew?{startMs:o,endMs:l}=Wt(n,s,a):t.startedAt!=null?(o=n,l=$e(n,s),c=l<=a):(o=n,l=i,c=l<=a);const d=Math.max(1,l-o),m=c?1:Math.max(0,Math.min(1,(a-o)/d));return{endMs:l,startMs:o,progress:m,cycleDays:Math.max(1,Math.round(d/W)),expired:c}}function Ue(t,a){const i=t-a;if(i<=0)return r("subscriptions.expired");const s=Math.ceil(i/6e4);if(s<60)return`${s}m`;const n=Math.floor(s/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function fe(t,a){const i=t-a;if(i<=0)return r("subscriptions.expired");const s=Math.floor(i/6e4),n=Math.floor(s/1440),o=Math.floor(s%1440/60),l=s%60;return r("subscriptions.countdown",{days:n,hours:o,minutes:l})}const qt="shrink-0 text-oai-black dark:text-oai-white";function Be(){const t=typeof navigator>"u"?"":navigator.userAgent||"";return/Windows/i.test(t)?"windows":/Linux/i.test(t)?"linux":"macos"}function Ge(){return Be()==="windows"?r("limits.commandCode.setupHint.snippet_login_windows"):r("limits.commandCode.setupHint.snippet_login")}function We(){return r("limits.devin.setupHint.snippet_login")}function zt(t){const a=re(t);if(!Number.isFinite(a))return null;const i=a-Date.now();if(i<=0)return r("shared.time.now");const s=Math.floor(i/6e4);if(s<60)return`${s}m`;const n=Math.floor(s/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function Vt(t,a){const i=a===k.REMAINING?100-t:t;return i>=90?"bg-red-500":i>=70?"bg-amber-500":"bg-emerald-500"}function te(t,a="used_percent"){return t?a==="utilization"?t.utilization:t.used_percent:null}function ie(t,a="reset_at"){return t?a==="resets_at"?t.resets_at:t.reset_at:null}function me(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 Q(t,{useGrouping:a=!0,maximumFractionDigits:i}={}){const s=Number(t);return Number.isFinite(s)?new Intl.NumberFormat(void 0,{minimumFractionDigits:0,maximumFractionDigits:i??(s>=100?0:2),useGrouping:a}).format(s):null}function Yt(t){if(!t||typeof t!="object"||!(Number(t.limit_credits)>0))return null;const a={useGrouping:t.unit!=="calls"},i=Q(t.used_credits,a),s=Q(t.limit_credits,a),n=Q(t.remaining_credits,a);if(!i||!s||!n)return null;const o=t.unit==="calls"?"limits.qoder_calls.detail":"limits.codex_credits.detail";return r(o,{used:i,limit:s,remaining:n})}function Kt(t,a){return ct({usedPercent:te(t.window,t.pctField),windowSeconds:dt(t,t.window),resetMs:re(ie(t.window,t.resetField)),mode:a})}function qe(t){return Number.isFinite(t)?new Intl.DateTimeFormat(ae(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):null}function Xt(t,a,i){const s=[Ve(t,a,i)],n=re(ie(t.window,t.resetField)),o=qe(n);o&&s.push(r(t.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:o}));const l=Yt(t.window);return l&&s.push(l),s.join(`
2
- `)}const ze=ht;function Jt({label:t,pct:a,reset:i,mode:s=k.USED,pacePercent:n=null,paceOver:o=!1,title:l=null}){const c=Math.max(0,Math.min(100,Number(a)||0)),d=s===k.REMAINING?100-c:c,m=Math.round(d),h=d>0&&m===0?Math.max(d,.35):d;let f=String(m);d>0&&m===0&&(f=r("limits.bar.sub_one_percent"));const b=n==null?null:Math.max(0,Math.min(100,n));return e.jsxs("div",{className:"group relative flex items-center gap-2",children:[e.jsx(ze,{text:l}),e.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:t}),e.jsxs("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:[e.jsx("div",{className:`${Vt(d,s)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${h}%`,minWidth:d>0?"3px":0}}),b!=null&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute top-0 h-full bg-oai-gray-100 dark:bg-oai-gray-700/50",style:{left:`calc(${b}% - 3px)`,width:"6px"}}),e.jsx("div",{className:`absolute top-0 h-full ${o?"bg-red-500":"bg-emerald-500"}`,style:{left:`calc(${b}% - 1px)`,width:"2px"}})]})]}),e.jsxs("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-9 text-right shrink-0 whitespace-nowrap",children:[f,"%"]}),i&&e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500 w-6 text-right shrink-0",children:i})]})}function Ve(t,a,i){const s=t.label??r(t.labelKey),n=i===k.REMAINING,o=d=>n?100-d:d;if(a.expectedPercent==null){const d=Math.max(0,Math.min(100,Number(te(t.window,t.pctField))||0)),m=me(o(d));return n?r("limits.explain.remaining",{label:s,used:m}):r("limits.explain.used",{label:s,used:m})}if(a.paceOver){if(a.runsOutEta)return r("limits.explain.ahead_eta",{label:s,eta:a.runsOutEta});const d=me(o(a.projectedEnd??100));return r(n?"limits.explain.ahead_pct_remaining":"limits.explain.ahead_pct",{label:s,pct:d})}const l=Math.max(0,Math.min(100,Number(te(t.window,t.pctField))||0)),c=me(o(a.projectedEnd??l));return r(n?"limits.explain.on_track_remaining":"limits.explain.on_track",{label:s,pct:c})}function Qt({pace:t}){return t.pacePercent!=null}function Zt({rows:t,mode:a,now:i=Date.now()}){if(t.length===0)return null;const s=a===k.REMAINING,n=t.some(Qt);return e.jsxs("div",{className:"mt-1 flex flex-col gap-1",children:[t.map(({spec:o,pace:l})=>{const c=qe(re(ie(o.window,o.resetField)));return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-600 dark:text-oai-gray-300",children:[Ve(o,l,a),c?e.jsxs("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:[" · ",r(o.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:c})]}):null]},o.key)}),n?e.jsx("div",{className:"mt-1 pt-1.5 border-t border-oai-gray-200/70 dark:border-oai-gray-700/50 text-[10.5px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",children:r(s?"limits.explain.body_remaining":"limits.explain.body")}):null]})}function G(t){if(!t)return null;const a=Date.now()-new Date(t).getTime();if(a<0)return null;const i=Math.floor(a/6e4);if(i<1)return r("shared.time.now");if(i<60)return r("shared.time.m_ago",{n:i});const s=Math.floor(i/60);if(s<24)return r("shared.time.h_ago",{n:s});const n=Math.floor(s/24);return r("shared.time.d_ago",{n})}const Ne={live:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-emerald-500",pulse:"bg-emerald-400"},stale:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-amber-500",pulse:"bg-amber-400"},cached:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-amber-500",pulse:"bg-amber-400"}},ea={claude:"claude",codex:"codex",antigravity:"agy"};function L({label:t,age:a=null,tone:i="live",tooltip:s=null}){const n=Ne[i]||Ne.live,o=i==="live";return e.jsxs("div",{className:"relative inline-flex items-center group cursor-help ml-1",onClick:l=>l.stopPropagation(),children:[e.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-semibold uppercase tracking-wider border leading-normal ${n.surface}`,children:[o?e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full ${n.pulse} opacity-75`}),e.jsx("span",{className:`relative inline-flex rounded-full h-1.5 w-1.5 ${n.dot}`})]}):e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${n.dot}`}),t,a?e.jsxs(e.Fragment,{children:[" · ",a]}):null]}),s?e.jsxs("span",{className:"pointer-events-none absolute left-1/2 bottom-full z-20 mb-2 -translate-x-1/2 w-48 rounded-md bg-oai-gray-900 dark:bg-oai-gray-800 px-2.5 py-1.5 text-[10px] font-normal text-white text-center opacity-0 scale-95 translate-y-1 group-hover:opacity-100 group-hover:scale-100 group-hover:translate-y-0 transition-all duration-200 cubic-bezier(0.16, 1, 0.3, 1) leading-normal shadow-lg origin-bottom border border-oai-gray-800 dark:border-oai-gray-700",children:[s,e.jsx("span",{className:"absolute left-1/2 top-full -translate-x-1/2 border-4 border-transparent border-t-oai-gray-900 dark:border-t-oai-gray-800"})]}):null]})}function Ye({name:t,providerId:a,children:i,expandable:s=!1,expanded:n=!1,onToggle:o,badge:l=null,rightAdornment:c=null}){const d=He(a),m=e.jsxs("div",{className:"flex items-center gap-1.5",children:[d?e.jsx(Ae,{provider:d,size:14,className:qt}):null,e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:t}),c?e.jsx("span",{className:"shrink-0",children:c}):null,l]});return s?e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":n,onClick:o,onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),o?.())},className:"flex flex-col gap-1.5 -mx-1.5 px-1.5 py-1 rounded-lg cursor-pointer transition-colors hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/40 aria-expanded:bg-oai-gray-50 dark:aria-expanded:bg-oai-gray-800/40",children:[m,i]}):e.jsxs("div",{className:"flex flex-col gap-1.5",children:[m,i]})}function Ke({subscription:t}){const a=t.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),i=t.autoRenew?Le:Oe;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 Xe({subscription:t,now:a,mode:i=k.USED}){const s=ee(t,a);if(!s)return null;const{endMs:n,expired:o}=s,l=!o&&n-a<=3*864e5,c=o?100:s.progress*100,d=i===k.REMAINING?100-c:c,m=o?100:Math.max(0,Math.min(100,d)),h=Math.round(m),f=m>0&&h===0?r("limits.bar.sub_one_percent"):`${h}%`;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:r("subscriptions.inline.label")}),e.jsx("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:e.jsx("div",{className:`${o?"bg-red-500":l?"bg-amber-500":"bg-blue-500"} rounded-full h-full block motion-safe:transition-[width] motion-safe:duration-500 ease-out motion-reduce:transition-none`,style:{width:`${m}%`,minWidth:m>0?"3px":0}})}),e.jsx("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-9 text-right shrink-0 whitespace-nowrap",children:f}),e.jsx("span",{className:`text-[10px] tabular-nums shrink-0 whitespace-nowrap w-6 text-right ${o?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:Ue(n,a)})]})}function Je({subscription:t,now:a}){const i=ee(t,a);if(!i)return null;const s=new Intl.DateTimeFormat(ae(),{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:r("subscriptions.inline.label")}),e.jsx("span",{className:"text-oai-gray-300 dark:text-oai-gray-600",children:":"}),e.jsx("span",{children:t.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")}),e.jsx("span",{children:" "}),e.jsx("span",{className:"font-mono tabular-nums",children:s.format(new Date(i.endMs))}),e.jsx("span",{className:"text-oai-gray-300 dark:text-oai-gray-600",children:" · "}),e.jsx("span",{className:i.expired?"text-oai-error":void 0,children:fe(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 ta=Ee;function R({children:t,tone:a="neutral"}){const i=a==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400";return e.jsx("div",{className:`text-[11px] leading-snug ${i}`,children:t})}function aa({rows:t,mode:a,extra:i=null}){const s=t.length===0&&!i;return e.jsxs(e.Fragment,{children:[t.map(({spec:n,pace:o})=>e.jsx(Jt,{label:n.label??r(n.labelKey),pct:te(n.window,n.pctField),reset:zt(ie(n.window,n.resetField)),mode:a,pacePercent:o.pacePercent,paceOver:o.paceOver,title:Xt(n,o,a)},n.key)),s?e.jsx(R,{children:r("limits.status.no_data")}):null,i]})}function ra(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 ia({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(ze,{text:ra(t)}),e.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:t.label}),e.jsx("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:e.jsx("div",{className:"bg-oai-gray-400 dark:bg-oai-gray-500 rounded-full h-full transition-[width] duration-500 ease-out",style:{width:`${a}%`,minWidth:a>0?"3px":0}})}),e.jsx("span",{className:"text-[10px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500 w-[4.25rem] text-right shrink-0 whitespace-nowrap",children:t.expiresAt})]})}function na({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(ia,{row:i},i.key))]})}function Qe(t,a){if(t==="codex_meta"){const i=Ut(a.reset_credits);return i?e.jsx(na,{model:i}):null}if(t==="kimi_parallel"&&a.parallel_limit)return e.jsx(R,{children:r("limits.label.kimi_parallel",{count:a.parallel_limit})});if(t==="kiro_credits"&&Number.isFinite(Number(a.tracked_credits))&&Number(a.tracked_credit_records)>0){const i=Q(a.tracked_credits,{maximumFractionDigits:2});return e.jsx(R,{children:r("limits.label.kiro_tracked_credits",{credits:i,count:Number(a.tracked_credit_records)})})}return t==="copilot_otel"&&!a.otel_has_files&&!a.otel_enabled?e.jsx(la,{defaultDir:a.otel_default_dir}):null}function sa(t,a,i,s,n,o,l=null,c=null,d=Date.now()){const m=ge[t];if(!m)return null;const h=m.windows(a).filter(b=>b.window).map(b=>({spec:b,pace:Kt(b,s)})),f=Qe(m.extra,a);return e.jsxs(Ye,{name:i,providerId:t,expandable:h.length>0||!!c,expanded:n,onToggle:o,badge:l,rightAdornment:c?e.jsx(Ke,{subscription:c}):null,children:[e.jsx(aa,{mode:s,rows:h,extra:f}),c?e.jsx(Xe,{subscription:c,now:d,mode:s}):null,n?e.jsx(Zt,{rows:h,mode:s,now:d}):null,n&&c?e.jsx(Je,{subscription:c,now:d}):null]},t)}function xe(t,a,i,s,n=null,o=Date.now(),l=k.USED){const c=!!n;return e.jsxs(Ye,{name:Z(t),providerId:t,expandable:c,expanded:i,onToggle:s,rightAdornment:c?e.jsx(Ke,{subscription:n}):null,children:[a,c?e.jsx(Xe,{subscription:n,now:o,mode:l}):null,c&&i?e.jsx("div",{className:"mt-1",children:e.jsx(Je,{subscription:n,now:o})}):null]},t)}function oa(t,a,i,s,n,o=null,l=Date.now()){if(!ge[t])return null;if(!a?.configured)return xe(t,e.jsxs(e.Fragment,{children:[e.jsx(R,{children:r("limits.status.not_connected")}),t==="opencodeGo"?e.jsx(_e,{}):null,t==="commandCode"?e.jsx(Ce,{}):null,t==="codingPlan"?e.jsx(Me,{}):null,t==="agentPlan"?e.jsx(Se,{}):null,t==="devin"?e.jsx(Pe,{}):null]}),s,n,o,l,i);if(t==="opencodeGo"&&a.subscription_status==="inactive")return xe(t,e.jsx(R,{children:r("limits.opencodeGo.status.inactive")}),s,n,o,l,i);if(a.error)return xe(t,e.jsxs(e.Fragment,{children:[e.jsx(R,{tone:"error",children:r("shared.error.prefix",{error:a.error})}),t==="kiro"?Qe(ge.kiro.extra,a):null,t==="opencodeGo"?e.jsx(_e,{}):null,t==="commandCode"?e.jsx(Ce,{}):null,t==="codingPlan"?e.jsx(Me,{}):null,t==="agentPlan"?e.jsx(Se,{}):null,t==="devin"?e.jsx(Pe,{}):null]}),s,n,o,l,i);const c=Z(t),d=a.plan_label?`${c} ${a.plan_label}`:c;let m=null;if(a.auth_action_required==="reauth"){const f=t==="commandCode"?Ge():t==="devin"?We():ea[t];m=e.jsx(L,{label:r("limits.reauth.badge"),age:G(a.cached_at),tone:"stale",tooltip:f?r("limits.reauth.tooltip",{command:f}):null})}if(!m&&t==="antigravity")if(a.cached){const f=G(a.cached_at);m=e.jsx(L,{label:r("limits.label.antigravity_cached"),age:f,tone:"cached",tooltip:r("limits.tooltip.antigravity_cached")})}else m=e.jsx(L,{label:r("limits.label.antigravity_live"),tone:"live",tooltip:r("limits.tooltip.antigravity_live")});!m&&(t==="qoder"||t==="qoderCn")&&a.cached&&(m=e.jsx(L,{label:r("limits.label.antigravity_cached"),age:G(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.qoder_cached")})),!m&&(t==="codingPlan"||t==="agentPlan")&&a.cached&&(m=e.jsx(L,{label:r("limits.label.antigravity_cached"),age:G(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.ark_cached")}));const h=a.provenance;return h?.stale&&!m&&(m=e.jsx(L,{label:r("limits.provenance.stale"),age:G(h.captured_at),tone:"stale",tooltip:r("limits.provenance.tooltip",{source:h.source,confidence:h.confidence})})),sa(t,a,d,i,s,n,m,o,l)}function la({defaultDir:t}){const[a,i]=x.useState(!1),n=["export COPILOT_OTEL_ENABLED=true","export COPILOT_OTEL_EXPORTER_TYPE=file",`export COPILOT_OTEL_FILE_EXPORTER_PATH="${t||"$HOME/.copilot/otel"}/copilot-otel-$(date +%Y%m%d).jsonl"`].join(`
1
+ import{m as z,j as e,e as Te,c as r,k as ae,r as x,S as ot,B,av as lt,d as D,h as ct,G as ve,L as dt,aw as ut,J as mt,ab as xt}from"./__vite-browser-external-D-WLjvZW.js";import{m as ke}from"./react-xGx5RIqz.js";import{P as ge,c as pt,r as re,a as gt,u as ht,b as ft,s as bt}from"./use-usage-limits-BYQuJ9Ud.js";import{b as k,c as Ee,l as Z,d as He,u as yt}from"./use-limits-display-prefs-DG97cWcv.js";import{C as Ie}from"./Card-B-gcOAn7.js";import{F as vt}from"./FadeIn-Cx1hl4so.js";import{P as Ae}from"./ProviderIcon-BPxacBzj.js";import{H as kt}from"./HoverTooltip-DOiGAPLE.js";import{C as jt}from"./ConfirmModal-ARBkT8AC.js";import{I as je,L as wt}from"./LocalOnlyNotice-CzeH4OoJ.js";import{S as ue}from"./Select-zpFEMqpk.js";import{P as Nt}from"./plus-BaCIejxc.js";import{P as _t,a as Ct,b as Pt,c as Mt,d as St}from"./PopoverPopup-Xbruj7Zi.js";import{u as Dt}from"./use-reduced-motion-BoFF1l9U.js";import"./use-latest-request-guard-B7uLArxV.js";import"./DialogTitle-Bby0zSCw.js";import"./composite-DgBqMs_Z.js";import"./store-DfUIKvz3.js";import"./DialogDescription-5LunWukT.js";import"./arrow-up-right-BDiV6Wlk.js";import"./download-D3y3gd-z.js";import"./ToolbarRootContext-PoCcP2AV.js";import"./check-Chyo6ujc.js";import"./SelectItemText-Bldm5Y0C.js";const Re={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"}]]};Re.node;const Tt=z(Re);const Oe={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"}]]};Oe.node;const Et=z(Oe);const Le={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"}]]};Le.node;const Fe=z(Le);const $e={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};$e.node;const Ue=z($e);const Be={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"}]]};Be.node;const Ge=z(Be),Ht=[3,2,3,3,2,2,3];function I({className:t}){return e.jsx("div",{className:Te("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",t)})}function It(){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{className:"h-3 w-12 shrink-0"}),e.jsx(I,{className:"flex-1 h-1.5 rounded-full min-w-0"}),e.jsx(I,{className:"h-3 w-[30px] shrink-0"}),e.jsx(I,{className:"h-3 w-6 shrink-0"})]})}function At({bars:t,index:a}){const i=a%3===0?"w-24":a%3===1?"w-20":"w-[4.5rem]";return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(I,{className:"h-[14px] w-[14px] rounded shrink-0"}),e.jsx(I,{className:Te("h-4",i)})]}),Array.from({length:t},(s,n)=>e.jsx(It,{},n))]})}function Rt(){return e.jsx(Ie,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(I,{className:"h-3.5 w-28"}),Ht.map((t,a)=>e.jsx(At,{bars:t,index:a},a))]})})}const he=100;function we(t){const a=Date.parse(t);return Number.isFinite(a)?a:null}function Ot(t){return Math.max(0,Math.min(he,Math.round(t)))}function Lt(t){return new Intl.DateTimeFormat(ae(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t))}function Ft(t,a,i){if(t==null||t>=a)return he;const s=a-t,n=a-i;return Ot(n/s*he)}function $t(t){const a=t.available_count;return a===null?null:Number.isInteger(a)&&a>=0?a:void 0}function Ut(t,{now:a}={}){if(!t||typeof t!="object")return null;const i=$t(t);if(i===void 0)return null;const s=Array.isArray(t.credits)?t.credits:[],n=a instanceof Date?a.getTime():Number(a??Date.now()),o=[];for(const l of s){const c=we(l?.expires_at);if(c==null)continue;const d=o.length+1;o.push({key:`reset-${d}`,label:r("limits.codex_reset_bank.row_label",{index:d}),expiresAt:Lt(c),expiresMs:c,percent:Ft(we(l?.granted_at),c,n)})}return i===0?null:o.length>0?{kind:"rows",availableCount:i??o.length,rows:o}:i>0?{kind:"count_only",availableCount:i,rows:[]}:null}const W=864e5;function A(t,a){const i=new Date(t),s=i.getUTCDate(),n=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()+a,1,i.getUTCHours(),i.getUTCMinutes())),o=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,0)).getUTCDate();return n.setUTCDate(Math.min(s,o)),n.getTime()}function We(t,a){if(a==="weekly")return t-7*W;if(a==="yearly")return A(t,-12);const i=new Date(t),s=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),0)).getUTCDate(),n=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth()-1,1,i.getUTCHours(),i.getUTCMinutes()));return n.setUTCDate(Math.min(i.getUTCDate(),s)),n.getTime()}function ze(t,a){return a==="weekly"?t+7*W:a==="yearly"?A(t,12):A(t,1)}function Bt(t){if(t.startedAt!=null){const a=new Date(t.startedAt).getTime();if(Number.isFinite(a))return a}return We(new Date(t.nextBillingAt).getTime(),t.cycle)}function Gt(t,a,i){if(t.startedAt!=null){const s=new Date(t.startedAt).getTime();if(Number.isFinite(s))return s}return We(i,a)}function Wt(t,a,i){if(a==="weekly"){const c=7*W,d=i<=t?0:Math.floor((i-t)/c);return{startMs:t+d*c,endMs:t+(d+1)*c}}const s=a==="yearly"?12:1,n=s*30.436875*W;let o=i<=t?0:Math.floor((i-t)/n);for(;o>0&&A(t,o*s)>i;)o-=1;let l=0;for(;A(t,(o+1)*s)<=i&&l<12e3;)o+=1,l+=1;return{startMs:A(t,o*s),endMs:A(t,(o+1)*s)}}function ee(t,a){const i=new Date(t.nextBillingAt).getTime();if(!Number.isFinite(i))return null;const s=["weekly","monthly","yearly"].includes(t.cycle)?t.cycle:"monthly",n=Gt(t,s,i);if(!Number.isFinite(n))return null;let o,l,c=!1;t.autoRenew?{startMs:o,endMs:l}=Wt(n,s,a):t.startedAt!=null?(o=n,l=ze(n,s),c=l<=a):(o=n,l=i,c=l<=a);const d=Math.max(1,l-o),m=c?1:Math.max(0,Math.min(1,(a-o)/d));return{endMs:l,startMs:o,progress:m,cycleDays:Math.max(1,Math.round(d/W)),expired:c}}function qe(t,a){const i=t-a;if(i<=0)return r("subscriptions.expired");const s=Math.ceil(i/6e4);if(s<60)return`${s}m`;const n=Math.floor(s/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function fe(t,a){const i=t-a;if(i<=0)return r("subscriptions.expired");const s=Math.floor(i/6e4),n=Math.floor(s/1440),o=Math.floor(s%1440/60),l=s%60;return r("subscriptions.countdown",{days:n,hours:o,minutes:l})}const zt="shrink-0 text-oai-black dark:text-oai-white";function Ve(){const t=typeof navigator>"u"?"":navigator.userAgent||"";return/Windows/i.test(t)?"windows":/Linux/i.test(t)?"linux":"macos"}function Ye(){return Ve()==="windows"?r("limits.commandCode.setupHint.snippet_login_windows"):r("limits.commandCode.setupHint.snippet_login")}function Ke(){return r("limits.devin.setupHint.snippet_login")}function qt(t){const a=re(t);if(!Number.isFinite(a))return null;const i=a-Date.now();if(i<=0)return r("shared.time.now");const s=Math.floor(i/6e4);if(s<60)return`${s}m`;const n=Math.floor(s/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function Vt(t,a){const i=a===k.REMAINING?100-t:t;return i>=90?"bg-red-500":i>=70?"bg-amber-500":"bg-emerald-500"}function te(t,a="used_percent"){return t?a==="utilization"?t.utilization:t.used_percent:null}function ie(t,a="reset_at"){return t?a==="resets_at"?t.resets_at:t.reset_at:null}function me(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 Q(t,{useGrouping:a=!0,maximumFractionDigits:i}={}){const s=Number(t);return Number.isFinite(s)?new Intl.NumberFormat(void 0,{minimumFractionDigits:0,maximumFractionDigits:i??(s>=100?0:2),useGrouping:a}).format(s):null}function Yt(t){if(!t||typeof t!="object"||!(Number(t.limit_credits)>0))return null;const a={useGrouping:t.unit!=="calls"},i=Q(t.used_credits,a),s=Q(t.limit_credits,a),n=Q(t.remaining_credits,a);if(!i||!s||!n)return null;const o=t.unit==="calls"?"limits.qoder_calls.detail":"limits.codex_credits.detail";return r(o,{used:i,limit:s,remaining:n})}function Kt(t,a){return pt({usedPercent:te(t.window,t.pctField),windowSeconds:gt(t,t.window),resetMs:re(ie(t.window,t.resetField)),mode:a})}function Xe(t){return Number.isFinite(t)?new Intl.DateTimeFormat(ae(),{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):null}function Xt(t,a,i){const s=[Qe(t,a,i)],n=re(ie(t.window,t.resetField)),o=Xe(n);o&&s.push(r(t.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:o}));const l=Yt(t.window);return l&&s.push(l),s.join(`
2
+ `)}const Je=kt;function Jt({label:t,pct:a,reset:i,mode:s=k.USED,pacePercent:n=null,paceOver:o=!1,title:l=null}){const c=Math.max(0,Math.min(100,Number(a)||0)),d=s===k.REMAINING?100-c:c,m=Math.round(d),h=d>0&&m===0?Math.max(d,.35):d;let f=String(m);d>0&&m===0&&(f=r("limits.bar.sub_one_percent"));const b=n==null?null:Math.max(0,Math.min(100,n));return e.jsxs("div",{className:"group relative flex items-center gap-2",children:[e.jsx(Je,{text:l}),e.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:t}),e.jsxs("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:[e.jsx("div",{className:`${Vt(d,s)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${h}%`,minWidth:d>0?"3px":0}}),b!=null&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute top-0 h-full bg-oai-gray-100 dark:bg-oai-gray-700/50",style:{left:`calc(${b}% - 3px)`,width:"6px"}}),e.jsx("div",{className:`absolute top-0 h-full ${o?"bg-red-500":"bg-emerald-500"}`,style:{left:`calc(${b}% - 1px)`,width:"2px"}})]})]}),e.jsxs("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-9 text-right shrink-0 whitespace-nowrap",children:[f,"%"]}),i&&e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500 w-6 text-right shrink-0",children:i})]})}function Qe(t,a,i){const s=t.label??r(t.labelKey),n=i===k.REMAINING,o=d=>n?100-d:d;if(a.expectedPercent==null){const d=Math.max(0,Math.min(100,Number(te(t.window,t.pctField))||0)),m=me(o(d));return n?r("limits.explain.remaining",{label:s,used:m}):r("limits.explain.used",{label:s,used:m})}if(a.paceOver){if(a.runsOutEta)return r("limits.explain.ahead_eta",{label:s,eta:a.runsOutEta});const d=me(o(a.projectedEnd??100));return r(n?"limits.explain.ahead_pct_remaining":"limits.explain.ahead_pct",{label:s,pct:d})}const l=Math.max(0,Math.min(100,Number(te(t.window,t.pctField))||0)),c=me(o(a.projectedEnd??l));return r(n?"limits.explain.on_track_remaining":"limits.explain.on_track",{label:s,pct:c})}function Qt({pace:t}){return t.pacePercent!=null}function Zt({rows:t,mode:a,now:i=Date.now()}){if(t.length===0)return null;const s=a===k.REMAINING,n=t.some(Qt);return e.jsxs("div",{className:"mt-1 flex flex-col gap-1",children:[t.map(({spec:o,pace:l})=>{const c=Xe(re(ie(o.window,o.resetField)));return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-600 dark:text-oai-gray-300",children:[Qe(o,l,a),c?e.jsxs("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:[" · ",r(o.timeKind==="expiry"?"limits.hover.expires_at":"limits.hover.resets_at",{time:c})]}):null]},o.key)}),n?e.jsx("div",{className:"mt-1 pt-1.5 border-t border-oai-gray-200/70 dark:border-oai-gray-700/50 text-[10.5px] leading-snug text-oai-gray-400 dark:text-oai-gray-500",children:r(s?"limits.explain.body_remaining":"limits.explain.body")}):null]})}function G(t){if(!t)return null;const a=Date.now()-new Date(t).getTime();if(a<0)return null;const i=Math.floor(a/6e4);if(i<1)return r("shared.time.now");if(i<60)return r("shared.time.m_ago",{n:i});const s=Math.floor(i/60);if(s<24)return r("shared.time.h_ago",{n:s});const n=Math.floor(s/24);return r("shared.time.d_ago",{n})}const Ne={live:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-emerald-500",pulse:"bg-emerald-400"},stale:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-amber-500",pulse:"bg-amber-400"},cached:{surface:"bg-oai-gray-50 dark:bg-oai-gray-800 border-oai-gray-200/60 dark:border-oai-gray-700/60 text-oai-gray-500 dark:text-oai-gray-400",dot:"bg-amber-500",pulse:"bg-amber-400"}},ea={claude:"claude",codex:"codex",antigravity:"agy"};function L({label:t,age:a=null,tone:i="live",tooltip:s=null}){const n=Ne[i]||Ne.live,o=i==="live";return e.jsxs("div",{className:"relative inline-flex items-center group cursor-help ml-1",onClick:l=>l.stopPropagation(),children:[e.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-semibold uppercase tracking-wider border leading-normal ${n.surface}`,children:[o?e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full ${n.pulse} opacity-75`}),e.jsx("span",{className:`relative inline-flex rounded-full h-1.5 w-1.5 ${n.dot}`})]}):e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${n.dot}`}),t,a?e.jsxs(e.Fragment,{children:[" · ",a]}):null]}),s?e.jsxs("span",{className:"pointer-events-none absolute left-1/2 bottom-full z-20 mb-2 -translate-x-1/2 w-48 rounded-md bg-oai-gray-900 dark:bg-oai-gray-800 px-2.5 py-1.5 text-[10px] font-normal text-white text-center opacity-0 scale-95 translate-y-1 group-hover:opacity-100 group-hover:scale-100 group-hover:translate-y-0 transition-all duration-200 cubic-bezier(0.16, 1, 0.3, 1) leading-normal shadow-lg origin-bottom border border-oai-gray-800 dark:border-oai-gray-700",children:[s,e.jsx("span",{className:"absolute left-1/2 top-full -translate-x-1/2 border-4 border-transparent border-t-oai-gray-900 dark:border-t-oai-gray-800"})]}):null]})}function Ze({name:t,providerId:a,children:i,expandable:s=!1,expanded:n=!1,onToggle:o,badge:l=null,rightAdornment:c=null}){const d=He(a),m=e.jsxs("div",{className:"flex items-center gap-1.5",children:[d?e.jsx(Ae,{provider:d,size:14,className:zt}):null,e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:t}),c?e.jsx("span",{className:"shrink-0",children:c}):null,l]});return s?e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":n,onClick:o,onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),o?.())},className:"flex flex-col gap-1.5 -mx-1.5 px-1.5 py-1 rounded-lg cursor-pointer transition-colors hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/40 aria-expanded:bg-oai-gray-50 dark:aria-expanded:bg-oai-gray-800/40",children:[m,i]}):e.jsxs("div",{className:"flex flex-col gap-1.5",children:[m,i]})}function et({subscription:t}){const a=t.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),i=t.autoRenew?Ge:Ue;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 tt({subscription:t,now:a,mode:i=k.USED}){const s=ee(t,a);if(!s)return null;const{endMs:n,expired:o}=s,l=!o&&n-a<=3*864e5,c=o?100:s.progress*100,d=i===k.REMAINING?100-c:c,m=o?100:Math.max(0,Math.min(100,d)),h=Math.round(m),f=m>0&&h===0?r("limits.bar.sub_one_percent"):`${h}%`;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:r("subscriptions.inline.label")}),e.jsx("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:e.jsx("div",{className:`${o?"bg-red-500":l?"bg-amber-500":"bg-blue-500"} rounded-full h-full block motion-safe:transition-[width] motion-safe:duration-500 ease-out motion-reduce:transition-none`,style:{width:`${m}%`,minWidth:m>0?"3px":0}})}),e.jsx("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-9 text-right shrink-0 whitespace-nowrap",children:f}),e.jsx("span",{className:`text-[10px] tabular-nums shrink-0 whitespace-nowrap w-6 text-right ${o?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:qe(n,a)})]})}function at({subscription:t,now:a}){const i=ee(t,a);if(!i)return null;const s=new Intl.DateTimeFormat(ae(),{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:"text-[11px] leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:r("subscriptions.inline.label")}),e.jsx("span",{className:"text-oai-gray-300 dark:text-oai-gray-600",children:":"}),e.jsx("span",{children:t.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")}),e.jsx("span",{children:" "}),e.jsx("span",{className:"font-mono tabular-nums",children:s.format(new Date(i.endMs))}),e.jsx("span",{className:"text-oai-gray-300 dark:text-oai-gray-600",children:" · "}),e.jsx("span",{className:i.expired?"text-oai-error":void 0,children:fe(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 ta=Ee;function R({children:t,tone:a="neutral"}){const i=a==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400";return e.jsx("div",{className:`text-[11px] leading-snug ${i}`,children:t})}function aa({rows:t,mode:a,extra:i=null}){const s=t.length===0&&!i;return e.jsxs(e.Fragment,{children:[t.map(({spec:n,pace:o})=>e.jsx(Jt,{label:n.label??r(n.labelKey),pct:te(n.window,n.pctField),reset:qt(ie(n.window,n.resetField)),mode:a,pacePercent:o.pacePercent,paceOver:o.paceOver,title:Xt(n,o,a)},n.key)),s?e.jsx(R,{children:r("limits.status.no_data")}):null,i]})}function ra(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 ia({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(Je,{text:ra(t)}),e.jsx("span",{"data-limit-label":"",className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0 whitespace-nowrap",style:{width:"var(--tt-limits-label-w)"},children:t.label}),e.jsx("div",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:e.jsx("div",{className:"bg-oai-gray-400 dark:bg-oai-gray-500 rounded-full h-full transition-[width] duration-500 ease-out",style:{width:`${a}%`,minWidth:a>0?"3px":0}})}),e.jsx("span",{className:"text-[10px] tabular-nums text-oai-gray-400 dark:text-oai-gray-500 w-[4.25rem] text-right shrink-0 whitespace-nowrap",children:t.expiresAt})]})}function na({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(ia,{row:i},i.key))]})}function rt(t,a){if(t==="codex_meta"){const i=Ut(a.reset_credits);return i?e.jsx(na,{model:i}):null}if(t==="kimi_parallel"&&a.parallel_limit)return e.jsx(R,{children:r("limits.label.kimi_parallel",{count:a.parallel_limit})});if(t==="kiro_credits"&&Number.isFinite(Number(a.tracked_credits))&&Number(a.tracked_credit_records)>0){const i=Q(a.tracked_credits,{maximumFractionDigits:2});return e.jsx(R,{children:r("limits.label.kiro_tracked_credits",{credits:i,count:Number(a.tracked_credit_records)})})}return t==="copilot_otel"&&!a.otel_has_files&&!a.otel_enabled?e.jsx(la,{defaultDir:a.otel_default_dir}):null}function sa(t,a,i,s,n,o,l=null,c=null,d=Date.now()){const m=ge[t];if(!m)return null;const h=m.windows(a).filter(b=>b.window).map(b=>({spec:b,pace:Kt(b,s)})),f=rt(m.extra,a);return e.jsxs(Ze,{name:i,providerId:t,expandable:h.length>0||!!c,expanded:n,onToggle:o,badge:l,rightAdornment:c?e.jsx(et,{subscription:c}):null,children:[e.jsx(aa,{mode:s,rows:h,extra:f}),c?e.jsx(tt,{subscription:c,now:d,mode:s}):null,n?e.jsx(Zt,{rows:h,mode:s,now:d}):null,n&&c?e.jsx(at,{subscription:c,now:d}):null]},t)}function xe(t,a,i,s,n=null,o=Date.now(),l=k.USED){const c=!!n;return e.jsxs(Ze,{name:Z(t),providerId:t,expandable:c,expanded:i,onToggle:s,rightAdornment:c?e.jsx(et,{subscription:n}):null,children:[a,c?e.jsx(tt,{subscription:n,now:o,mode:l}):null,c&&i?e.jsx("div",{className:"mt-1",children:e.jsx(at,{subscription:n,now:o})}):null]},t)}function oa(t,a,i,s,n,o=null,l=Date.now()){if(!ge[t])return null;if(!a?.configured)return xe(t,e.jsxs(e.Fragment,{children:[e.jsx(R,{children:r("limits.status.not_connected")}),t==="opencodeGo"?e.jsx(_e,{}):null,t==="commandCode"?e.jsx(Ce,{}):null,t==="codingPlan"?e.jsx(Me,{}):null,t==="agentPlan"?e.jsx(Se,{}):null,t==="devin"?e.jsx(Pe,{}):null]}),s,n,o,l,i);if(t==="opencodeGo"&&a.subscription_status==="inactive")return xe(t,e.jsx(R,{children:r("limits.opencodeGo.status.inactive")}),s,n,o,l,i);if(a.error)return xe(t,e.jsxs(e.Fragment,{children:[e.jsx(R,{tone:"error",children:r("shared.error.prefix",{error:a.error})}),t==="kiro"?rt(ge.kiro.extra,a):null,t==="opencodeGo"?e.jsx(_e,{}):null,t==="commandCode"?e.jsx(Ce,{}):null,t==="codingPlan"?e.jsx(Me,{}):null,t==="agentPlan"?e.jsx(Se,{}):null,t==="devin"?e.jsx(Pe,{}):null]}),s,n,o,l,i);const c=Z(t),d=a.plan_label?`${c} ${a.plan_label}`:c;let m=null;if(a.auth_action_required==="reauth"){const f=t==="commandCode"?Ye():t==="devin"?Ke():ea[t];m=e.jsx(L,{label:r("limits.reauth.badge"),age:G(a.cached_at),tone:"stale",tooltip:f?r("limits.reauth.tooltip",{command:f}):null})}if(!m&&t==="antigravity")if(a.cached){const f=G(a.cached_at);m=e.jsx(L,{label:r("limits.label.antigravity_cached"),age:f,tone:"cached",tooltip:r("limits.tooltip.antigravity_cached")})}else m=e.jsx(L,{label:r("limits.label.antigravity_live"),tone:"live",tooltip:r("limits.tooltip.antigravity_live")});!m&&(t==="qoder"||t==="qoderCn")&&a.cached&&(m=e.jsx(L,{label:r("limits.label.antigravity_cached"),age:G(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.qoder_cached")})),!m&&(t==="codingPlan"||t==="agentPlan")&&a.cached&&(m=e.jsx(L,{label:r("limits.label.antigravity_cached"),age:G(a.cached_at),tone:"cached",tooltip:r("limits.tooltip.ark_cached")}));const h=a.provenance;return h?.stale&&!m&&(m=e.jsx(L,{label:r("limits.provenance.stale"),age:G(h.captured_at),tone:"stale",tooltip:r("limits.provenance.tooltip",{source:h.source,confidence:h.confidence})})),sa(t,a,d,i,s,n,m,o,l)}function la({defaultDir:t}){const[a,i]=x.useState(!1),n=["export COPILOT_OTEL_ENABLED=true","export COPILOT_OTEL_EXPORTER_TYPE=file",`export COPILOT_OTEL_FILE_EXPORTER_PATH="${t||"$HOME/.copilot/otel"}/copilot-otel-$(date +%Y%m%d).jsonl"`].join(`
3
3
  `),o=async l=>{l.stopPropagation();try{await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1 rounded-md border border-amber-300/60 dark:border-amber-700/40 bg-amber-50/50 dark:bg-amber-900/10 px-2.5 py-2 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"font-medium text-oai-gray-700 dark:text-oai-gray-200",children:r("limits.copilot.otelHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug",children:r("limits.copilot.otelHint.body")}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-tight whitespace-pre",children:n}),e.jsx("button",{type:"button",onClick:o,className:"mt-1 inline-flex items-center gap-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 px-1.5 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:a?r("limits.copilot.otelHint.copied"):r("limits.copilot.otelHint.copy")})]})}function j({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 be(){return e.jsx("svg",{viewBox:"0 0 12 12","aria-hidden":"true",className:"h-2.5 w-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M4.5 2.75h4.75V7.5M9.25 2.75 3 9"})})}function _e(){const[t,a]=x.useState(!1),i=["read -r -s OPENCODE_GO_API_KEY","export OPENCODE_GO_API_KEY",'launchctl setenv OPENCODE_GO_API_KEY "$OPENCODE_GO_API_KEY"'].join(`
4
- `),s=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.opencodeGo.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.opencodeGo.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(j,{n:"1",children:[e.jsx("div",{children:r("limits.opencodeGo.setupHint.step1")}),e.jsxs("a",{href:"https://opencode.ai",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.opencodeGo.setupHint.cta"),e.jsx(be,{})]})]}),e.jsx(j,{n:"2",children:e.jsx("div",{children:r("limits.opencodeGo.setupHint.step2")})}),e.jsxs(j,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:r("limits.opencodeGo.setupHint.step3")}),e.jsx("button",{type:"button",onClick:s,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.opencodeGo.setupHint.copied"):r("limits.opencodeGo.setupHint.copy")})]}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.opencodeGo.setupHint.note_app")})]})]})]})}function Ce(){const[t,a]=x.useState(!1),i=Be(),s=Ge(),n=i==="windows"?r("limits.commandCode.setupHint.snippet_env_windows").replaceAll("\\n",`
4
+ `),s=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.opencodeGo.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.opencodeGo.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(j,{n:"1",children:[e.jsx("div",{children:r("limits.opencodeGo.setupHint.step1")}),e.jsxs("a",{href:"https://opencode.ai",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.opencodeGo.setupHint.cta"),e.jsx(be,{})]})]}),e.jsx(j,{n:"2",children:e.jsx("div",{children:r("limits.opencodeGo.setupHint.step2")})}),e.jsxs(j,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:r("limits.opencodeGo.setupHint.step3")}),e.jsx("button",{type:"button",onClick:s,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.opencodeGo.setupHint.copied"):r("limits.opencodeGo.setupHint.copy")})]}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.opencodeGo.setupHint.note_app")})]})]})]})}function Ce(){const[t,a]=x.useState(!1),i=Ve(),s=Ye(),n=i==="windows"?r("limits.commandCode.setupHint.snippet_env_windows").replaceAll("\\n",`
5
5
  `):[r("limits.commandCode.setupHint.snippet_read"),r("limits.commandCode.setupHint.snippet_export"),...i==="macos"?[r("limits.commandCode.setupHint.snippet_setenv")]:[]].join(`
6
- `),o=async l=>{l.stopPropagation();try{await navigator.clipboard.writeText(n),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.commandCode.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.commandCode.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(j,{n:"1",children:[e.jsx("div",{children:r("limits.commandCode.setupHint.step1")}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:s})]}),e.jsxs(j,{n:"2",children:[e.jsx("div",{children:r("limits.commandCode.setupHint.step2")}),e.jsx("div",{className:"mt-1.5 flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:o,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.commandCode.setupHint.copied"):r("limits.commandCode.setupHint.copy")})}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:n}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:i==="windows"?r("limits.commandCode.setupHint.note_windows"):i==="linux"?r("limits.commandCode.setupHint.note_linux"):r("limits.commandCode.setupHint.note_app")})]})]})]})}function Pe(){const t=We();return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.devin.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.devin.setupHint.subtitle")}),e.jsx("ol",{className:"mt-2.5 space-y-2.5",children:e.jsxs(j,{n:"1",children:[e.jsx("div",{children:r("limits.devin.setupHint.step1")}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:t}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.devin.setupHint.note")})]})})]})}function Me(){const[t,a]=x.useState(!1),i=["npm install -g @volcengine/ark-cli","arkcli auth login volc-sso # browser SSO (recommended)","arkcli auth status # verify the session"].join(`
6
+ `),o=async l=>{l.stopPropagation();try{await navigator.clipboard.writeText(n),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.commandCode.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.commandCode.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(j,{n:"1",children:[e.jsx("div",{children:r("limits.commandCode.setupHint.step1")}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:s})]}),e.jsxs(j,{n:"2",children:[e.jsx("div",{children:r("limits.commandCode.setupHint.step2")}),e.jsx("div",{className:"mt-1.5 flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:o,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.commandCode.setupHint.copied"):r("limits.commandCode.setupHint.copy")})}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:n}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:i==="windows"?r("limits.commandCode.setupHint.note_windows"):i==="linux"?r("limits.commandCode.setupHint.note_linux"):r("limits.commandCode.setupHint.note_app")})]})]})]})}function Pe(){const t=Ke();return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.devin.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.devin.setupHint.subtitle")}),e.jsx("ol",{className:"mt-2.5 space-y-2.5",children:e.jsxs(j,{n:"1",children:[e.jsx("div",{children:r("limits.devin.setupHint.step1")}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:t}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.devin.setupHint.note")})]})})]})}function Me(){const[t,a]=x.useState(!1),i=["npm install -g @volcengine/ark-cli","arkcli auth login volc-sso # browser SSO (recommended)","arkcli auth status # verify the session"].join(`
7
7
  `),s=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.codingPlan.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.codingPlan.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(j,{n:"1",children:[e.jsx("div",{children:r("limits.codingPlan.setupHint.step1")}),e.jsxs("a",{href:"https://www.volcengine.com/docs/82379/2536875",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.codingPlan.setupHint.cta"),e.jsx(be,{})]})]}),e.jsxs(j,{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(j,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:r("limits.codingPlan.setupHint.step3")}),e.jsx("button",{type:"button",onClick:s,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.codingPlan.setupHint.copied"):r("limits.codingPlan.setupHint.copy")})]}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.codingPlan.setupHint.note_app")})]})]})]})}function Se(){const[t,a]=x.useState(!1),i=[r("limits.agentPlan.setupHint.snippet_install"),r("limits.agentPlan.setupHint.snippet_login"),r("limits.agentPlan.setupHint.snippet_status")].join(`
8
- `),s=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.agentPlan.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.agentPlan.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(j,{n:"1",children:[e.jsx("div",{children:r("limits.agentPlan.setupHint.step1")}),e.jsxs("a",{href:"https://www.volcengine.com/docs/82379/2536875",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.agentPlan.setupHint.cta"),e.jsx(be,{})]})]}),e.jsxs(j,{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(j,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:r("limits.agentPlan.setupHint.step3")}),e.jsx("button",{type:"button",onClick:s,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.agentPlan.setupHint.copied"):r("limits.agentPlan.setupHint.copy")})]}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.agentPlan.setupHint.note_app")})]})]})]})}function ca(t){const[a,i]=x.useState(0);return x.useLayoutEffect(()=>{const s=t.current;if(!s)return;const n=s.querySelectorAll("[data-limit-label]");let o=0,l=null;if(n.length>0)try{l=document.createElement("canvas").getContext("2d")}catch{l=null}if(l){const d=window.getComputedStyle(n[0]);l.font=`${d.fontStyle} ${d.fontWeight} ${d.fontSize} ${d.fontFamily}`;for(const m of n)o=Math.max(o,l.measureText(m.textContent).width)}const c=Math.ceil(o);i(d=>d===c?d:c)}),a}function da({claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:m,opencodeGo:h,commandCode:f,qoder:b,qoderCn:N,codingPlan:D,agentPlan:_,devin:w,order:E,visibility:z,displayMode:V,subscriptions:ne=[],showSubscriptions:F=!0}){const se={claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:m,opencodeGo:h,commandCode:f,qoder:b,qoderCn:N,codingPlan:D,agentPlan:_,devin:w},oe=x.useRef(null),C=ca(oe),[le,Y]=x.useState(null),[P,K]=x.useState(()=>Date.now()),ce=Array.isArray(E)&&E.length>0?E:ta,X=V===k.REMAINING?k.REMAINING:k.USED,de=X===k.REMAINING?r("limits.settings.display_mode_remaining"):r("limits.settings.display_mode_used");x.useEffect(()=>{const g=setInterval(()=>K(Date.now()),6e4);return()=>clearInterval(g)},[]);const H=new Map;if(F)for(const g of ne||[]){if(!g?.provider)continue;const M=new Date(g.nextBillingAt).getTime();if(!Number.isFinite(M))continue;const J=H.get(g.provider);if(!J){H.set(g.provider,g);continue}const S=new Date(J.nextBillingAt).getTime(),U=M>P,u=S>P;(U&&(!u||S>M)||!U&&!u&&M>S)&&H.set(g.provider,g)}const $=ce.filter(g=>!z||z[g]!==!1||H.has(g)).map(g=>oa(g,se[g],X,le===g,()=>Y(M=>M===g?null:g),H.get(g)||null,P)).filter(Boolean);return e.jsx(gt,{delay:.15,children:e.jsx(Ie,{children:e.jsxs("div",{ref:oe,className:"flex flex-col gap-3",style:C>0?{"--tt-limits-label-w":`${C}px`}:void 0,children:[e.jsxs("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:[r("limits.panel.title"),r("limits.panel.mode_separator"),de]}),$.length>0?$:e.jsx(R,{children:r("limits.status.all_hidden")})]})})})}async function Ze(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 ua(){const t=await fetch("/functions/tokentracker-subscription-manager",{headers:{Accept:"application/json"},cache:"no-store"}),a=await Ze(t);return Array.isArray(a.subscriptions)?a.subscriptions:[]}async function ye(t){const a=await at();return Ze(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 ma(t){return ye({action:"create",subscription:t})}function xa(t,a){return ye({action:"update",id:t,subscription:a})}function pa(t){return ye({action:"delete",id:t})}const pe={plan:"",provider:"",cycle:"monthly",autoRenew:!0,startedAt:""};function ga(t){const a=new Date(t);if(Number.isNaN(a.getTime()))return"";const i=s=>String(s).padStart(2,"0");return`${a.getFullYear()}-${i(a.getMonth()+1)}-${i(a.getDate())}T${i(a.getHours())}:${i(a.getMinutes())}`}function ha({subscriptions:t,onChanged:a}){const[i,s]=x.useState(!1),[n,o]=x.useState(null),[l,c]=x.useState(pe),[d,m]=x.useState(!1),[h,f]=x.useState(!1),[b,N]=x.useState(!1),[D,_]=x.useState(!1),[w,E]=x.useState(null),[z,V]=x.useState(!1),[ne,F]=x.useState(!1),[se,oe]=x.useState(null),[C,le]=x.useState(()=>Date.now()),Y=x.useRef(null),P=ae(),K=x.useMemo(()=>new Intl.DateTimeFormat(P,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),[P]);x.useEffect(()=>{const u=setInterval(()=>le(Date.now()),6e4);return()=>clearInterval(u)},[]),x.useEffect(()=>{if(!i)return;const u=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;Y.current?.scrollIntoView?.({behavior:u?"auto":"smooth",block:"nearest"})},[i,n]);const ce=x.useMemo(()=>Ee.map(u=>{const v=(t||[]).some(y=>y.provider===u&&y.id!==n),p=Z(u);return{value:u,label:v?`${p} ${r("subscriptions.form.provider_taken_suffix")}`:p,disabled:v}}),[P,t,n]),X=x.useMemo(()=>[{value:"weekly",label:r("subscriptions.form.cycle_weekly")},{value:"monthly",label:r("subscriptions.form.cycle_monthly")},{value:"yearly",label:r("subscriptions.form.cycle_yearly")}],[P]),de=x.useMemo(()=>[{value:"true",label:r("subscriptions.form.auto_renew_on")},{value:"false",label:r("subscriptions.form.auto_renew_off")}],[P]),H=x.useCallback(()=>{c(pe),o(null),f(!1),N(!1),_(!1),s(!0)},[]),$=x.useCallback(u=>{c({plan:u.plan||"",provider:u.provider||"",cycle:u.cycle||"monthly",autoRenew:u.autoRenew,startedAt:ga(new Date(Bt(u)).toISOString())}),o(u.id),f(!1),N(!1),_(!1),s(!0)},[]),g=x.useCallback(()=>{s(!1),o(null),c(pe),f(!1),N(!1),_(!1)},[]),M=x.useCallback(async u=>{if(u.preventDefault(),f(!1),!l.provider){N(!0);return}if((t||[]).some(O=>O.provider===l.provider&&O.id!==n)){_(!0);return}const p=new Date(l.startedAt).getTime();if(!Number.isFinite(p)){f(!0);return}const y={service:Z(l.provider),plan:l.plan,provider:l.provider||null,autoRenew:l.autoRenew,cycle:l.cycle,startedAt:p,nextBillingAt:$e(p,l.cycle)};m(!0);try{n?await xa(n,y):await ma(y),g(),await a?.()}catch{f(!0)}finally{m(!1)}},[g,n,l,a,t]),J=x.useCallback(async()=>{if(w){V(!0),F(!1);try{await pa(w.id),w.id===n&&g(),E(null),await a?.()}catch{F(!0)}finally{V(!1)}}},[g,n,a,w]),S=t||[],U=()=>{const u=n?S.find(p=>p.id===n):null,v=u?ee(u,C):null;return e.jsxs("form",{ref:Y,onSubmit:M,className:"grid grid-cols-1 gap-3 px-3 py-3 text-left sm:grid-cols-2",children:[e.jsx("div",{className:"flex items-center justify-between sm:col-span-2",children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:n?r("subscriptions.edit"):r("subscriptions.add")})}),v?e.jsxs("div",{className:"sm:col-span-2 rounded-md bg-oai-gray-50 dark:bg-oai-gray-800/50 px-2.5 py-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:u.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:K.format(new Date(v.endMs))})," · ",e.jsx("span",{className:v.expired?"text-oai-error":void 0,children:fe(v.endMs,C)})]}):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(ue,{id:"subscription-provider",value:l.provider,onValueChange:p=>c({...l,provider:String(p)}),options:ce,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-1",children:e.jsx(je,{label:r("subscriptions.form.plan"),value:l.plan,maxLength:120,placeholder:r("subscriptions.form.plan_placeholder"),onChange:p=>c({...l,plan:p.target.value})})}),e.jsxs("div",{className:"flex flex-col sm:col-span-1",children:[e.jsx("label",{htmlFor:"subscription-cycle",className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5",children:r("subscriptions.form.cycle")}),e.jsx(ue,{id:"subscription-cycle",value:l.cycle,onValueChange:p=>c({...l,cycle:String(p)}),options:X,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(ue,{id:"subscription-auto-renew",value:String(l.autoRenew),onValueChange:p=>c({...l,autoRenew:p==="true"}),options:de,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(je,{label:r("subscriptions.form.started_at"),type:"datetime-local",value:l.startedAt,required:!0,onChange:p=>c({...l,startedAt:p.target.value})})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 sm:col-span-2",children:[n?e.jsx(B,{type:"button",variant:"secondary",size:"sm",onClick:()=>{const p=S.find(y=>y.id===n);p&&E(p)},className:"!text-red-600 dark:!text-red-400 mr-auto",children:r("subscriptions.delete")}):null,b?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_required")}):null,D?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_taken")}):null,h?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.error")}):null,e.jsx(B,{type:"button",variant:"secondary",size:"sm",onClick:g,children:r("shared.action.cancel")}),e.jsx(B,{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(B,{type:"button",size:"sm",onClick:H,className:"shrink-0 gap-1.5",children:[e.jsx(yt,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:r("subscriptions.add")})]})]}),S.length===0&&!(i&&!n)?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-1 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center dark:border-oai-gray-700",children:[e.jsx(Re,{className:"h-6 w-6 text-oai-gray-300 dark:text-oai-gray-600 mb-2","aria-hidden":!0}),e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:r("subscriptions.empty.title")}),e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r("subscriptions.empty.body")})]}):e.jsxs("ul",{className:"flex flex-col gap-1.5",children:[S.map(u=>{const v=ee(u,C);if(!v)return null;const{endMs:p,expired:y}=v,O=y?100:v.progress*100,et=!y&&p-C<=3*864e5,tt=se===u.id;return e.jsxs("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:[e.jsxs("button",{type:"button",onClick:()=>$(u),"aria-label":`${r("subscriptions.edit")} ${u.service}`,"aria-expanded":n===u.id,className:"w-full flex flex-col gap-1.5 px-3 py-2.5 text-left cursor-pointer hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/40 rounded-lg transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[e.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Ae,{provider:He(u.provider)||"OTHER",size:14}),e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-white truncate",children:u.service}),e.jsx("span",{role:"img","aria-label":u.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),title:u.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),className:`inline-flex shrink-0 translate-y-px ${u.autoRenew?"text-oai-brand-600 dark:text-oai-brand-400":"text-blue-600 dark:text-blue-400"}`,children:u.autoRenew?e.jsx(Le,{size:14,strokeWidth:2,"aria-hidden":!0}):e.jsx(Oe,{size:14,strokeWidth:2,"aria-hidden":!0})}),u.plan?e.jsx("span",{className:"text-xs rounded-full border border-oai-gray-200 dark:border-oai-gray-700 px-2 py-0.5 text-oai-gray-500 dark:text-oai-gray-400 shrink-0",children:u.plan}):null]}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0",children:r("subscriptions.inline.label")}),e.jsx("span",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1 overflow-hidden",children:e.jsx("span",{className:`${y?"bg-red-500":et?"bg-amber-500":"bg-blue-500"} rounded-full h-full block transition-[width] duration-500 ease-out`,style:{width:`${O}%`,minWidth:O>0?"3px":0}})}),e.jsx("span",{className:`text-[10px] tabular-nums shrink-0 ${y?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:Ue(p,C)})]})]}),n===u.id?e.jsx("div",{className:"border-t border-oai-gray-100 dark:border-oai-gray-800",children:U()}):null,n!==u.id&&tt?e.jsxs("div",{className:"px-3 pb-3 flex flex-col gap-2 border-t border-oai-gray-100 dark:border-oai-gray-800",children:[e.jsxs("p",{className:"pt-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:u.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:K.format(new Date(p))})," · ",e.jsx("span",{className:y?"text-oai-error":void 0,children:fe(p,C)})," · ",e.jsx("span",{children:u.autoRenew?r("subscriptions.status.auto_renew"):r("subscriptions.status.manual")})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(B,{type:"button",variant:"secondary",size:"sm",onClick:()=>$(u),children:r("subscriptions.edit")})})]}):null]},u.id)}),i&&!n?e.jsx("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:U()}):null]}),e.jsx(ft,{open:!!w,title:r("subscriptions.confirm_delete_title"),description:w?.service||"",error:ne?r("subscriptions.delete_error"):null,confirmLabel:r("subscriptions.delete"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:z,onCancel:()=>{E(null),F(!1)},onConfirm:J})]})}const Te=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),fa="x-apple.systempreferences:com.apple.preference.notifications";function ba(){const t=_t(),a=ot(),i=r("limits.alert.blocked"),s=a?ke.button:ke.div;return e.jsxs(s,{type:a?"button":void 0,onClick:a?()=>lt({type:"action",name:"openURL",value:fa}):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 Ga(){const t=rt(),{data:a,error:i,isLoading:s}=ut(t?{initialRefresh:!0,initialState:t,publishToPreloadCache:!0}:{initialRefresh:!0,publishToPreloadCache:!0}),n=pt(),o=mt(),[l,c]=T.useState([]),[d,m]=T.useState(!1),[h,f]=T.useState(!1),[b]=it(),N=T.useRef(0),D=T.useCallback(async()=>{if(!Te&&!ve())return;const _=++N.current;try{const w=await ua();if(_!==N.current)return;c(w),m(!1)}catch{if(_!==N.current)return;m(!0)}},[]);return T.useEffect(()=>{D()},[D]),T.useEffect(()=>{b.get("openSubscriptions")==="1"&&f(!0)},[b]),T.useEffect(()=>{o.enabled&&a&&xt(a)},[o.enabled,a]),!Te&&!ve()?e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx(bt,{})}):e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:r("nav.limits")}),e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:r("limits.page.subtitle")})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[o.enabled&&o.permissionBlocked?e.jsx(ba,{}):null,e.jsxs(vt,{open:h,onOpenChange:f,children:[e.jsx(kt,{"aria-label":r("limits.page.openSubscriptions"),title:r("limits.page.openSubscriptions"),className:"shrink-0 inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:e.jsx(Re,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(jt,{children:e.jsx(wt,{side:"bottom",align:"end",sideOffset:8,className:"z-50",children:e.jsx(Nt,{children:e.jsx(ha,{subscriptions:l,onChanged:D})})})})]}),e.jsx("button",{type:"button",onClick:()=>{o.setEnabled(!o.enabled)},"aria-label":o.enabled?r("limits.alert.disable"):r("limits.alert.enable"),title:o.enabled?r("limits.alert.disable"):r("limits.alert.enable"),className:`inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 ${o.enabled&&o.permissionBlocked?"text-amber-600 dark:text-amber-400":"text-oai-gray-600 dark:text-oai-gray-400 hover:text-oai-black dark:hover:text-white"}`,children:o.enabled?e.jsx(St,{className:"h-4 w-4","aria-hidden":!0}):e.jsx(Pt,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(nt,{to:"/settings?section=limits","aria-label":r("limits.page.openSettings"),title:r("limits.page.openSettings"),className:"shrink-0 inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:e.jsx(st,{className:"h-4 w-4","aria-hidden":!0})})]})]}),s?e.jsx(Rt,{}):e.jsxs(e.Fragment,{children:[i?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:r("shared.error.prefix",{error:i})}):null,d?e.jsx("p",{className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("subscriptions.load_error")}):null,e.jsx(da,{claude:a?.claude,codex:a?.codex,cursor:a?.cursor,gemini:a?.gemini,kimi:a?.kimi,kiro:a?.kiro,grok:a?.grok,antigravity:a?.antigravity,copilot:a?.copilot,zcode:a?.zcode,opencodeGo:a?.opencodeGo,commandCode:a?.commandCode,qoder:a?.qoder,qoderCn:a?.qoderCn,codingPlan:a?.codingPlan,agentPlan:a?.agentPlan,devin:a?.devin,order:n.order,visibility:n.visibility,displayMode:n.displayMode,subscriptions:l,showSubscriptions:n.showSubscriptions!==!1})]})]})})})}export{Ga as LimitsPage};
8
+ `),s=async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(i),a(!0),setTimeout(()=>a(!1),1600)}catch{}};return e.jsxs("div",{className:"mt-1.5 rounded-lg border border-oai-gray-200 dark:border-oai-gray-700/60 bg-oai-gray-50/50 dark:bg-oai-gray-900/20 p-3 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("div",{className:"text-[12px] font-semibold text-oai-gray-800 dark:text-oai-gray-100",children:r("limits.agentPlan.setupHint.title")}),e.jsx("div",{className:"mt-0.5 leading-snug text-oai-gray-500 dark:text-oai-gray-400",children:r("limits.agentPlan.setupHint.subtitle")}),e.jsxs("ol",{className:"mt-2.5 space-y-2.5",children:[e.jsxs(j,{n:"1",children:[e.jsx("div",{children:r("limits.agentPlan.setupHint.step1")}),e.jsxs("a",{href:"https://www.volcengine.com/docs/82379/2536875",target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"mt-1 inline-flex items-center gap-1 rounded-md bg-oai-brand/10 px-2 py-1 font-medium text-oai-brand hover:bg-oai-brand/15 transition-colors",children:[r("limits.agentPlan.setupHint.cta"),e.jsx(be,{})]})]}),e.jsxs(j,{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(j,{n:"3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:r("limits.agentPlan.setupHint.step3")}),e.jsx("button",{type:"button",onClick:s,className:"shrink-0 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 px-2 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:t?r("limits.agentPlan.setupHint.copied"):r("limits.agentPlan.setupHint.copy")})]}),e.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded-md bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-relaxed whitespace-pre",children:i}),e.jsx("div",{className:"mt-1 text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:r("limits.agentPlan.setupHint.note_app")})]})]})]})}function ca(t){const[a,i]=x.useState(0);return x.useLayoutEffect(()=>{const s=t.current;if(!s)return;const n=s.querySelectorAll("[data-limit-label]");let o=0,l=null;if(n.length>0)try{l=document.createElement("canvas").getContext("2d")}catch{l=null}if(l){const d=window.getComputedStyle(n[0]);l.font=`${d.fontStyle} ${d.fontWeight} ${d.fontSize} ${d.fontFamily}`;for(const m of n)o=Math.max(o,l.measureText(m.textContent).width)}const c=Math.ceil(o);i(d=>d===c?d:c)}),a}function da({claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:m,opencodeGo:h,commandCode:f,qoder:b,qoderCn:N,codingPlan:T,agentPlan:_,devin:w,order:E,visibility:q,displayMode:V,subscriptions:ne=[],showSubscriptions:F=!0}){const se={claude:t,codex:a,cursor:i,gemini:s,kimi:n,kiro:o,grok:l,antigravity:c,copilot:d,zcode:m,opencodeGo:h,commandCode:f,qoder:b,qoderCn:N,codingPlan:T,agentPlan:_,devin:w},oe=x.useRef(null),C=ca(oe),[le,Y]=x.useState(null),[P,K]=x.useState(()=>Date.now()),ce=Array.isArray(E)&&E.length>0?E:ta,X=V===k.REMAINING?k.REMAINING:k.USED,de=X===k.REMAINING?r("limits.settings.display_mode_remaining"):r("limits.settings.display_mode_used");x.useEffect(()=>{const g=setInterval(()=>K(Date.now()),6e4);return()=>clearInterval(g)},[]);const H=new Map;if(F)for(const g of ne||[]){if(!g?.provider)continue;const M=new Date(g.nextBillingAt).getTime();if(!Number.isFinite(M))continue;const J=H.get(g.provider);if(!J){H.set(g.provider,g);continue}const S=new Date(J.nextBillingAt).getTime(),U=M>P,u=S>P;(U&&(!u||S>M)||!U&&!u&&M>S)&&H.set(g.provider,g)}const $=ce.filter(g=>!q||q[g]!==!1||H.has(g)).map(g=>oa(g,se[g],X,le===g,()=>Y(M=>M===g?null:g),H.get(g)||null,P)).filter(Boolean);return e.jsx(vt,{delay:.15,children:e.jsx(Ie,{children:e.jsxs("div",{ref:oe,className:"flex flex-col gap-3",style:C>0?{"--tt-limits-label-w":`${C}px`}:void 0,children:[e.jsxs("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:[r("limits.panel.title"),r("limits.panel.mode_separator"),de]}),$.length>0?$:e.jsx(R,{children:r("limits.status.all_hidden")})]})})})}async function it(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 ua(){const t=await fetch("/functions/tokentracker-subscription-manager",{headers:{Accept:"application/json"},cache:"no-store"}),a=await it(t);return Array.isArray(a.subscriptions)?a.subscriptions:[]}async function ye(t){const a=await ot();return it(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 ma(t){return ye({action:"create",subscription:t})}function xa(t,a){return ye({action:"update",id:t,subscription:a})}function pa(t){return ye({action:"delete",id:t})}const pe={plan:"",provider:"",cycle:"monthly",autoRenew:!0,startedAt:""};function ga(t){const a=new Date(t);if(Number.isNaN(a.getTime()))return"";const i=s=>String(s).padStart(2,"0");return`${a.getFullYear()}-${i(a.getMonth()+1)}-${i(a.getDate())}T${i(a.getHours())}:${i(a.getMinutes())}`}function ha({subscriptions:t,onChanged:a}){const[i,s]=x.useState(!1),[n,o]=x.useState(null),[l,c]=x.useState(pe),[d,m]=x.useState(!1),[h,f]=x.useState(!1),[b,N]=x.useState(!1),[T,_]=x.useState(!1),[w,E]=x.useState(null),[q,V]=x.useState(!1),[ne,F]=x.useState(!1),[se,oe]=x.useState(null),[C,le]=x.useState(()=>Date.now()),Y=x.useRef(null),P=ae(),K=x.useMemo(()=>new Intl.DateTimeFormat(P,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),[P]);x.useEffect(()=>{const u=setInterval(()=>le(Date.now()),6e4);return()=>clearInterval(u)},[]),x.useEffect(()=>{if(!i)return;const u=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;Y.current?.scrollIntoView?.({behavior:u?"auto":"smooth",block:"nearest"})},[i,n]);const ce=x.useMemo(()=>Ee.map(u=>{const v=(t||[]).some(y=>y.provider===u&&y.id!==n),p=Z(u);return{value:u,label:v?`${p} ${r("subscriptions.form.provider_taken_suffix")}`:p,disabled:v}}),[P,t,n]),X=x.useMemo(()=>[{value:"weekly",label:r("subscriptions.form.cycle_weekly")},{value:"monthly",label:r("subscriptions.form.cycle_monthly")},{value:"yearly",label:r("subscriptions.form.cycle_yearly")}],[P]),de=x.useMemo(()=>[{value:"true",label:r("subscriptions.form.auto_renew_on")},{value:"false",label:r("subscriptions.form.auto_renew_off")}],[P]),H=x.useCallback(()=>{c(pe),o(null),f(!1),N(!1),_(!1),s(!0)},[]),$=x.useCallback(u=>{c({plan:u.plan||"",provider:u.provider||"",cycle:u.cycle||"monthly",autoRenew:u.autoRenew,startedAt:ga(new Date(Bt(u)).toISOString())}),o(u.id),f(!1),N(!1),_(!1),s(!0)},[]),g=x.useCallback(()=>{s(!1),o(null),c(pe),f(!1),N(!1),_(!1)},[]),M=x.useCallback(async u=>{if(u.preventDefault(),f(!1),!l.provider){N(!0);return}if((t||[]).some(O=>O.provider===l.provider&&O.id!==n)){_(!0);return}const p=new Date(l.startedAt).getTime();if(!Number.isFinite(p)){f(!0);return}const y={service:Z(l.provider),plan:l.plan,provider:l.provider||null,autoRenew:l.autoRenew,cycle:l.cycle,startedAt:p,nextBillingAt:ze(p,l.cycle)};m(!0);try{n?await xa(n,y):await ma(y),g(),await a?.()}catch{f(!0)}finally{m(!1)}},[g,n,l,a,t]),J=x.useCallback(async()=>{if(w){V(!0),F(!1);try{await pa(w.id),w.id===n&&g(),E(null),await a?.()}catch{F(!0)}finally{V(!1)}}},[g,n,a,w]),S=t||[],U=()=>{const u=n?S.find(p=>p.id===n):null,v=u?ee(u,C):null;return e.jsxs("form",{ref:Y,onSubmit:M,className:"grid grid-cols-1 gap-3 px-3 py-3 text-left sm:grid-cols-2",children:[e.jsx("div",{className:"flex items-center justify-between sm:col-span-2",children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-oai-gray-500 dark:text-oai-gray-400",children:n?r("subscriptions.edit"):r("subscriptions.add")})}),v?e.jsxs("div",{className:"sm:col-span-2 rounded-md bg-oai-gray-50 dark:bg-oai-gray-800/50 px-2.5 py-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:u.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:K.format(new Date(v.endMs))})," · ",e.jsx("span",{className:v.expired?"text-oai-error":void 0,children:fe(v.endMs,C)})]}):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(ue,{id:"subscription-provider",value:l.provider,onValueChange:p=>c({...l,provider:String(p)}),options:ce,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-1",children:e.jsx(je,{label:r("subscriptions.form.plan"),value:l.plan,maxLength:120,placeholder:r("subscriptions.form.plan_placeholder"),onChange:p=>c({...l,plan:p.target.value})})}),e.jsxs("div",{className:"flex flex-col sm:col-span-1",children:[e.jsx("label",{htmlFor:"subscription-cycle",className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5",children:r("subscriptions.form.cycle")}),e.jsx(ue,{id:"subscription-cycle",value:l.cycle,onValueChange:p=>c({...l,cycle:String(p)}),options:X,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(ue,{id:"subscription-auto-renew",value:String(l.autoRenew),onValueChange:p=>c({...l,autoRenew:p==="true"}),options:de,matchTriggerWidth:!0,className:"h-10 w-full px-3 text-sm"})]}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(je,{label:r("subscriptions.form.started_at"),type:"datetime-local",value:l.startedAt,required:!0,onChange:p=>c({...l,startedAt:p.target.value})})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 sm:col-span-2",children:[n?e.jsx(B,{type:"button",variant:"secondary",size:"sm",onClick:()=>{const p=S.find(y=>y.id===n);p&&E(p)},className:"!text-red-600 dark:!text-red-400 mr-auto",children:r("subscriptions.delete")}):null,b?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_required")}):null,T?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.provider_taken")}):null,h?e.jsx("p",{className:"mr-auto text-sm text-oai-error",role:"alert",children:r("subscriptions.form.error")}):null,e.jsx(B,{type:"button",variant:"secondary",size:"sm",onClick:g,children:r("shared.action.cancel")}),e.jsx(B,{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(B,{type:"button",size:"sm",onClick:H,className:"shrink-0 gap-1.5",children:[e.jsx(Nt,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:r("subscriptions.add")})]})]}),S.length===0&&!(i&&!n)?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-1 rounded-lg border border-dashed border-oai-gray-200 px-4 py-10 text-center dark:border-oai-gray-700",children:[e.jsx(Fe,{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:[S.map(u=>{const v=ee(u,C);if(!v)return null;const{endMs:p,expired:y}=v,O=y?100:v.progress*100,nt=!y&&p-C<=3*864e5,st=se===u.id;return e.jsxs("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:[e.jsxs("button",{type:"button",onClick:()=>$(u),"aria-label":`${r("subscriptions.edit")} ${u.service}`,"aria-expanded":n===u.id,className:"w-full flex flex-col gap-1.5 px-3 py-2.5 text-left cursor-pointer hover:bg-oai-gray-50 dark:hover:bg-oai-gray-800/40 rounded-lg transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:[e.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Ae,{provider:He(u.provider)||"OTHER",size:14}),e.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-white truncate",children:u.service}),e.jsx("span",{role:"img","aria-label":u.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),title:u.autoRenew?r("subscriptions.badge.auto_renew"):r("subscriptions.badge.stops"),className:`inline-flex shrink-0 translate-y-px ${u.autoRenew?"text-oai-brand-600 dark:text-oai-brand-400":"text-blue-600 dark:text-blue-400"}`,children:u.autoRenew?e.jsx(Ge,{size:14,strokeWidth:2,"aria-hidden":!0}):e.jsx(Ue,{size:14,strokeWidth:2,"aria-hidden":!0})}),u.plan?e.jsx("span",{className:"text-xs rounded-full border border-oai-gray-200 dark:border-oai-gray-700 px-2 py-0.5 text-oai-gray-500 dark:text-oai-gray-400 shrink-0",children:u.plan}):null]}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-oai-gray-500 dark:text-oai-gray-400 shrink-0",children:r("subscriptions.inline.label")}),e.jsx("span",{className:"relative flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1 overflow-hidden",children:e.jsx("span",{className:`${y?"bg-red-500":nt?"bg-amber-500":"bg-blue-500"} rounded-full h-full block transition-[width] duration-500 ease-out`,style:{width:`${O}%`,minWidth:O>0?"3px":0}})}),e.jsx("span",{className:`text-[10px] tabular-nums shrink-0 ${y?"text-oai-error":"text-oai-gray-400 dark:text-oai-gray-500"}`,children:qe(p,C)})]})]}),n===u.id?e.jsx("div",{className:"border-t border-oai-gray-100 dark:border-oai-gray-800",children:U()}):null,n!==u.id&&st?e.jsxs("div",{className:"px-3 pb-3 flex flex-col gap-2 border-t border-oai-gray-100 dark:border-oai-gray-800",children:[e.jsxs("p",{className:"pt-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:[e.jsx("span",{className:"text-oai-gray-400 dark:text-oai-gray-500",children:u.autoRenew?r("subscriptions.label.renews_at"):r("subscriptions.label.expires_at")})," ",e.jsx("span",{className:"font-mono tabular-nums",children:K.format(new Date(p))})," · ",e.jsx("span",{className:y?"text-oai-error":void 0,children:fe(p,C)})," · ",e.jsx("span",{children:u.autoRenew?r("subscriptions.status.auto_renew"):r("subscriptions.status.manual")})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(B,{type:"button",variant:"secondary",size:"sm",onClick:()=>$(u),children:r("subscriptions.edit")})})]}):null]},u.id)}),i&&!n?e.jsx("li",{className:"rounded-lg border border-oai-gray-100 dark:border-oai-gray-800",children:U()}):null]}),e.jsx(jt,{open:!!w,title:r("subscriptions.confirm_delete_title"),description:w?.service||"",error:ne?r("subscriptions.delete_error"):null,confirmLabel:r("subscriptions.delete"),cancelLabel:r("shared.action.cancel"),destructive:!0,busy:q,onCancel:()=>{E(null),F(!1)},onConfirm:J})]})}const De=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),fa="x-apple.systempreferences:com.apple.preference.notifications";function ba(){const t=Dt(),a=mt(),i=r("limits.alert.blocked"),s=a?ke.button:ke.div;return e.jsxs(s,{type:a?"button":void 0,onClick:a?()=>xt({type:"action",name:"openURL",value:fa}):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 Ga(){const t=lt(),{data:a,error:i,isLoading:s}=ht(t?{initialRefresh:!0,initialState:t,publishToPreloadCache:!0}:{initialRefresh:!0,publishToPreloadCache:!0}),n=yt(),o=ft(),[l,c]=D.useState([]),[d,m]=D.useState(!1),[h,f]=D.useState(!1),[b]=ct(),N=D.useRef(0),T=D.useCallback(async()=>{if(!De&&!ve())return;const _=++N.current;try{const w=await ua();if(_!==N.current)return;c(w),m(!1)}catch{if(_!==N.current)return;m(!0)}},[]);return D.useEffect(()=>{T()},[T]),D.useEffect(()=>{b.get("openSubscriptions")==="1"&&f(!0)},[b]),D.useEffect(()=>{o.enabled&&a&&bt(a)},[o.enabled,a]),!De&&!ve()?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:"flex flex-row items-start justify-between gap-4 mb-8",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:r("nav.limits")}),e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:r("limits.page.subtitle")})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[o.enabled&&o.permissionBlocked?e.jsx(ba,{}):null,e.jsxs(_t,{open:h,onOpenChange:f,children:[e.jsx(Ct,{"aria-label":r("limits.page.openSubscriptions"),title:r("limits.page.openSubscriptions"),className:"shrink-0 inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:e.jsx(Fe,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(Pt,{children:e.jsx(Mt,{side:"bottom",align:"end",sideOffset:8,className:"z-50",children:e.jsx(St,{children:e.jsx(ha,{subscriptions:l,onChanged:T})})})})]}),e.jsx("button",{type:"button",onClick:()=>{o.setEnabled(!o.enabled)},"aria-label":o.enabled?r("limits.alert.disable"):r("limits.alert.enable"),title:o.enabled?r("limits.alert.disable"):r("limits.alert.enable"),className:`inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 ${o.enabled&&o.permissionBlocked?"text-amber-600 dark:text-amber-400":"text-oai-gray-600 dark:text-oai-gray-400 hover:text-oai-black dark:hover:text-white"}`,children:o.enabled?e.jsx(Et,{className:"h-4 w-4","aria-hidden":!0}):e.jsx(Tt,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx(dt,{to:"/settings?section=limits","aria-label":r("limits.page.openSettings"),title:r("limits.page.openSettings"),className:"shrink-0 inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:e.jsx(ut,{className:"h-4 w-4","aria-hidden":!0})})]})]}),s?e.jsx(Rt,{}):e.jsxs(e.Fragment,{children:[i?e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:r("shared.error.prefix",{error:i})}):null,d?e.jsx("p",{className:"mb-4 text-sm text-amber-600 dark:text-amber-400",children:r("subscriptions.load_error")}):null,e.jsx(da,{claude:a?.claude,codex:a?.codex,cursor:a?.cursor,gemini:a?.gemini,kimi:a?.kimi,kiro:a?.kiro,grok:a?.grok,antigravity:a?.antigravity,copilot:a?.copilot,zcode:a?.zcode,opencodeGo:a?.opencodeGo,commandCode:a?.commandCode,qoder:a?.qoder,qoderCn:a?.qoderCn,codingPlan:a?.codingPlan,agentPlan:a?.agentPlan,devin:a?.devin,order:n.order,visibility:n.visibility,displayMode:n.displayMode,subscriptions:l,showSubscriptions:n.showSubscriptions!==!1})]})]})})})}export{Ga as LimitsPage};
@@ -1 +1 @@
1
- import{r as h,j as e,c as r}from"./__vite-browser-external-CjrP5KfC.js";import{A as p}from"./arrow-up-right-AKItXMyh.js";import{D as b}from"./download-BZvLU_hD.js";function I({id:t,value:l,onChange:d,placeholder:c,disabled:i=!1,type:x="text",label:s,error:a,className:g="",...m}){const y=h.useId(),o=t||y,n=a?`${o}-error`:void 0,u=`w-full bg-oai-white dark:bg-oai-gray-900 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md text-oai-black dark:text-oai-white placeholder-oai-gray-400 dark:placeholder-oai-gray-500 transition-all duration-200 focus:outline-none focus:border-oai-brand dark:focus:border-oai-brand focus:ring-1 focus:ring-oai-brand/30 ${i?"bg-oai-gray-50 dark:bg-oai-gray-800 text-oai-gray-400 dark:text-oai-gray-400 cursor-not-allowed":""} ${a?"border-oai-error focus:border-oai-error focus:ring-oai-error/30":""} h-10 px-3 text-sm ${g}`;return e.jsxs("div",{className:"w-full",children:[s&&e.jsx("label",{htmlFor:o,className:"block text-sm font-medium text-oai-gray-700 dark:text-oai-gray-300 mb-1.5 transition-colors duration-200",children:s}),e.jsx("input",{id:o,type:x,value:l,onChange:d,placeholder:c,disabled:i,"aria-invalid":a?!0:void 0,"aria-describedby":n,className:u,...m}),a&&e.jsx("p",{id:n,className:"mt-1.5 text-sm text-oai-error",children:a})]})}const f="https://github.com/xiufengsun/TokenTracker/releases/latest";function _(){const t=()=>{try{window.location.href="tokentracker://open"}catch{}};return e.jsx("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-20 text-center",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("h2",{className:"text-lg font-semibold text-oai-black dark:text-white",children:r("local_only.title")}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r("local_only.body")}),e.jsxs("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-3",children:[e.jsxs("button",{type:"button",onClick:t,className:"inline-flex h-9 items-center gap-1.5 rounded-full px-4 text-sm font-medium bg-oai-gray-900 text-white hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 transition-colors",children:[e.jsx("span",{children:r("local_only.open_app")}),e.jsx(p,{size:14,strokeWidth:2,"aria-hidden":!0})]}),e.jsxs("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-9 items-center gap-1.5 rounded-full px-4 text-sm font-medium ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-900 transition-colors",children:[e.jsx(b,{size:14,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:r("local_only.download")})]})]})]})})}export{I,_ as L};
1
+ import{r as h,j as e,c as r}from"./__vite-browser-external-D-WLjvZW.js";import{A as p}from"./arrow-up-right-BDiV6Wlk.js";import{D as b}from"./download-D3y3gd-z.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};
@@ -0,0 +1 @@
1
+ import{m as re,I as ue,a as me,r as o,c as a,j as e,e as h}from"./__vite-browser-external-D-WLjvZW.js";const ae={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};ae.node;const xe=re(ae);const te={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"}]]};te.node;const he=re(te),be=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"})]}),fe=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"})}),pe={google:be,github:fe},ye={google:"Google",github:"GitHub",microsoft:"Microsoft",discord:"Discord",apple:"Apple"};function we(i){return ye[i]||String(i||"").replace(/-/g," ")}function ke(i){if(typeof i=="string"&&i.trim())return i.trim();if(i&&typeof i=="object"){if(typeof i.token=="string"&&i.token.trim())return i.token.trim();if(typeof i.otp=="string"&&i.otp.trim())return i.otp.trim()}return""}function je({title:i,subtitle:D,className:oe="",onSuccess:S,hideLogo:H=!1,initialMode:p="signin",tokenFromUrl:P="",initialEmail:y="",initialCode:v=""}){ue();const{enabled:w,signedIn:j,refreshUser:E,signInWithPassword:G,signUp:Z,signInWithOAuth:z,getPublicAuthConfig:T,sendResetPasswordEmail:V,exchangeResetPasswordToken:$,resetPassword:U}=me(),[n,u]=o.useState(p),[c,k]=o.useState(y),[m,N]=o.useState(""),[A,L]=o.useState(""),[M,se]=o.useState(""),[q,W]=o.useState(v),[_,x]=o.useState(!1),[J,s]=o.useState(null),[C,b]=o.useState(null),[F,O]=o.useState(!1),[ie,ne]=o.useState(!!(p!=="signin"||y)),[I,K]=o.useState(!0),[R,Q]=o.useState([]),[X,le]=o.useState(8);o.useEffect(()=>{p&&u(p)},[p]),o.useEffect(()=>{y&&k(y)},[y]),o.useEffect(()=>{v&&W(v)},[v]),o.useEffect(()=>{if(!w)return;let r=!0;return K(!0),(async()=>{const{data:t,error:l}=await T();if(r){if(l||!t)Q(["google","github"]);else{const d=Array.isArray(t.oAuthProviders)?t.oAuthProviders:[],f=Array.isArray(t.customOAuthProviders)?t.customOAuthProviders:[];Q([...d,...f]),typeof t.passwordMinLength=="number"&&t.passwordMinLength>0&&le(t.passwordMinLength)}K(!1)}})(),()=>{r=!1}},[w,T]),o.useEffect(()=>{j&&S&&S()},[j,S]);const Y=o.useMemo(()=>typeof window>"u"?"":!!window.webkit?.messageHandlers?.nativeOAuth?`${window.location.origin}/auth/callback`:`${window.location.origin}/`,[]),ee=o.useMemo(()=>typeof window>"u"?"/reset-password":`${window.location.origin}/reset-password`,[]),B=o.useCallback(async r=>{s(null),x(!0);try{const{error:t}=await z(r,Y);t&&s(t.message||String(t))}finally{x(!1)}},[z,Y]);o.useEffect(()=>{if(!w||I||j||typeof window>"u")return;const r=window.location.search;if(!r)return;const t=new URLSearchParams(r),l=t.get("native")==="1",d=t.get("provider");l&&d&&[...R].includes(d)&&B(d)},[w,I,j,R,B]);const de=o.useCallback(async r=>{r.preventDefault(),s(null),x(!0);try{if(n==="signup"){const{data:l,error:d}=await Z({email:c.trim(),password:m,name:M.trim()||void 0});if(d){s(d.message||String(d));return}if(l?.requireEmailVerification){b(a("login.verify_email_pending")),u("signin");return}await E();return}const{error:t}=await G({email:c.trim(),password:m});if(t){s(t.message||String(t));return}await E()}finally{x(!1)}},[n,c,m,M,Z,G,E]),ce=o.useCallback(async r=>{r.preventDefault(),s(null),x(!0);try{const t=c.trim(),{error:l}=await V({email:t,redirectTo:ee});if(l){s(l.message||String(l));return}k(t),b(a("reset_password.request.sent")),u("reset_confirm")}finally{x(!1)}},[c,ee,V]),ge=o.useCallback(async r=>{if(r.preventDefault(),s(null),m!==A){s(a("reset_password.error.password_mismatch"));return}x(!0);try{let t=P;if(!t){const{data:d,error:f}=await $({email:c.trim(),code:q.trim()});if(f){s(f.message||String(f));return}if(t=ke(d),!t){s(a("reset_password.error.missing_token"));return}}const{error:l}=await U({newPassword:m,otp:t});if(l){s(l.message||String(l));return}O(!0),b(a("reset_password.success"))}finally{x(!1)}},[q,A,c,$,m,U,P]);if(!w)return null;const g=n==="reset_email"||n==="reset_confirm";return e.jsxs("div",{className:h("w-full bg-white dark:bg-oai-gray-950 p-6 transition-colors duration-200",oe),children:[g&&e.jsxs("button",{type:"button",onClick:()=>{u("signin"),b(null),s(null),O(!1),N(""),L("")},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(xe,{className:"h-3.5 w-3.5"}),a("reset_password.back_to_sign_in")]}),e.jsxs("div",{className:h("mb-6",g?"text-left":"text-center"),children:[!H&&!g&&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")})]}),e.jsx("h2",{className:h("text-sm font-semibold text-oai-black dark:text-white tracking-tight mb-1",(H||g)&&"text-base font-bold md:text-lg"),children:g?a("reset_password.title"):i||a("login_modal.subtitle")}),!g&&D&&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:D}),g&&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&&n==="reset_confirm"&&!F?C:a("reset_password.subtitle")})]}),C&&(!g||F)&&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}),J&&e.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400 text-center",role:"alert",children:J}),n==="reset_email"&&e.jsxs("form",{onSubmit:ce,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:c,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")})]}),n==="reset_confirm"&&(F?e.jsx("button",{type:"button",onClick:()=>{u("signin"),O(!1),b(null),s(null),N(""),L("")},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:ge,className:"space-y-3",children:[!P&&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:c,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:q,onChange:r=>W(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:m,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:A,onChange:r=>L(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")})]})),!g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2.5 mb-5",children:I?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"})]}):R.map(r=>e.jsxs("button",{type:"button",disabled:_,onClick:()=>B(r),className:h("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:[pe[r]||null,a("login.oauth.continue",{provider:we(r)})]},r))}),ie?e.jsxs(e.Fragment,{children:[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")})})]}),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:h("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",n==="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:()=>{u("signin"),s(null)},children:a("login.tab.sign_in")}),e.jsx("button",{type:"button",className:h("flex-1 py-1.5 text-xs font-medium rounded-md transition-colors",n==="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:()=>{u("signup"),s(null)},children:a("login.tab.sign_up")})]}),e.jsxs("form",{onSubmit:de,className:"space-y-3",children:[n==="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:M,onChange:r=>se(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:c,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:n==="signup"?"new-password":"current-password",required:!0,minLength:n==="signup"?X:void 0,value:m,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"}),n==="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(X)})}),n==="signin"&&e.jsx("div",{className:"mt-1 text-right",children:e.jsx("button",{type:"button",onClick:()=>{u("reset_email"),s(null),b(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:n==="signup"?a("login.submit.sign_up"):a("login.submit.sign_in")})]})]}):e.jsxs(e.Fragment,{children:[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")})})]}),e.jsxs("button",{type:"button",onClick:()=>ne(!0),className:h("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(he,{className:"h-[18px] w-[18px] text-oai-gray-500 dark:text-oai-gray-400",strokeWidth:1.75}),a("login_modal.continue_email")]})]})]})]})}export{je as L};
@@ -1 +1 @@
1
- import{u as s,a as c,r as l,j as e,X as d}from"./__vite-browser-external-CjrP5KfC.js";import{m as o}from"./react-jS0-5kwE.js";import{L as m}from"./LoginCard-JCejigVu.js";import{A as p}from"./index-CN7xY7j_.js";function b(){const{isOpen:i,closeLoginModal:a}=s(),{enabled:r}=c();return l.useEffect(()=>{if(!i)return;const t=n=>{n.key==="Escape"&&a()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[i,a]),r?e.jsx(p,{children:i&&e.jsxs(o.div,{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:[e.jsx(o.div,{className:"absolute inset-0 bg-black/40 dark:bg-black/60",onClick:a,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}}),e.jsxs(o.div,{className:"relative w-full max-w-[420px] rounded-2xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 shadow-2xl overflow-hidden",initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},transition:{duration:.2},onClick:t=>t.stopPropagation(),children:[e.jsx("button",{type:"button",onClick:a,className:"absolute right-4 top-4 z-10 text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors",children:e.jsx(d,{className:"h-5 w-5"})}),e.jsx(m,{onSuccess:a,className:"p-6 bg-transparent"})]})]})}):null}export{b as LoginModal};
1
+ import{u as s,a as c,r as l,j as e,X as d}from"./__vite-browser-external-D-WLjvZW.js";import{m as o}from"./react-xGx5RIqz.js";import{L as m}from"./LoginCard-aiqSQInP.js";import{A as p}from"./index-4bHcp2Ep.js";function b(){const{isOpen:i,closeLoginModal:a}=s(),{enabled:r}=c();return l.useEffect(()=>{if(!i)return;const t=n=>{n.key==="Escape"&&a()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[i,a]),r?e.jsx(p,{children:i&&e.jsxs(o.div,{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},children:[e.jsx(o.div,{className:"absolute inset-0 bg-black/40 dark:bg-black/60",onClick:a,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}}),e.jsxs(o.div,{className:"relative w-full max-w-[420px] rounded-2xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 shadow-2xl overflow-hidden",initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},transition:{duration:.2},onClick:t=>t.stopPropagation(),children:[e.jsx("button",{type:"button",onClick:a,className:"absolute right-4 top-4 z-10 text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors",children:e.jsx(d,{className:"h-5 w-5"})}),e.jsx(m,{onSuccess:a,className:"p-6 bg-transparent"})]})]})}):null}export{b as LoginModal};
@@ -1 +1 @@
1
- import{f as p,h as w,a as v,r,c as s,j as e,L as y}from"./__vite-browser-external-CjrP5KfC.js";import{L as j}from"./LoginCard-JCejigVu.js";function N(i){const t=new URLSearchParams(i).get("next");return typeof t!="string"||t.length===0||!t.startsWith("/")||t.startsWith("//")?"/dashboard":t}function L(){const i=p(),[t,f]=w(),{enabled:n,loading:u,signedIn:x,refreshUser:g}=v(),c=r.useMemo(()=>N(t.toString()),[t]),[h,d]=r.useState(null);r.useEffect(()=>{const l=t.get("insforge_status"),a=t.get("insforge_type"),m=t.get("insforge_error");l==="success"&&a==="verify_email"?d(s("login.verify_email_success")):l==="error"&&a==="verify_email"&&m&&d(s("shared.error.prefix",{error:m}))},[t]);const o=r.useMemo(()=>t.get("native")==="1",[t]);r.useEffect(()=>{if(!(!n||u)&&x){if(o){window.location.href="/auth/native-callback";return}i(c,{replace:!0})}},[n,u,x,i,c,o]),r.useEffect(()=>{n&&g()},[n,g]),r.useEffect(()=>{if(o&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[o]);const b=r.useCallback(()=>{f(l=>{const a=new URLSearchParams(l);return a.delete("insforge_status"),a.delete("insforge_type"),a.delete("insforge_error"),a},{replace:!0}),d(null)},[f]);return n?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(y,{to:"/",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("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:[h?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:h}),e.jsx("button",{type:"button",onClick:b,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(j,{hideLogo:!0,title:s("login.title"),subtitle:s("login.subtitle"),className:"p-8 bg-transparent",onSuccess:()=>{o?window.location.href="/auth/native-callback":i(c,{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(y,{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",children:s("login.cloud_only")})})]})}export{L as LoginPage};
1
+ import{f as p,h as w,a as v,r,c as s,j as e,L as y}from"./__vite-browser-external-D-WLjvZW.js";import{L as j}from"./LoginCard-aiqSQInP.js";function N(i){const t=new URLSearchParams(i).get("next");return typeof t!="string"||t.length===0||!t.startsWith("/")||t.startsWith("//")?"/dashboard":t}function L(){const i=p(),[t,f]=w(),{enabled:n,loading:u,signedIn:x,refreshUser:g}=v(),c=r.useMemo(()=>N(t.toString()),[t]),[h,d]=r.useState(null);r.useEffect(()=>{const l=t.get("insforge_status"),a=t.get("insforge_type"),m=t.get("insforge_error");l==="success"&&a==="verify_email"?d(s("login.verify_email_success")):l==="error"&&a==="verify_email"&&m&&d(s("shared.error.prefix",{error:m}))},[t]);const o=r.useMemo(()=>t.get("native")==="1",[t]);r.useEffect(()=>{if(!(!n||u)&&x){if(o){window.location.href="/auth/native-callback";return}i(c,{replace:!0})}},[n,u,x,i,c,o]),r.useEffect(()=>{n&&g()},[n,g]),r.useEffect(()=>{if(o&&typeof window<"u")try{window.sessionStorage.setItem("tokentracker_native_login","1")}catch{}},[o]);const b=r.useCallback(()=>{f(l=>{const a=new URLSearchParams(l);return a.delete("insforge_status"),a.delete("insforge_type"),a.delete("insforge_error"),a},{replace:!0}),d(null)},[f]);return n?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(y,{to:"/",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("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:[h?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:h}),e.jsx("button",{type:"button",onClick:b,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(j,{hideLogo:!0,title:s("login.title"),subtitle:s("login.subtitle"),className:"p-8 bg-transparent",onSuccess:()=>{o?window.location.href="/auth/native-callback":i(c,{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(y,{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",children:s("login.cloud_only")})})]})}export{L as LoginPage};
@@ -0,0 +1 @@
1
+ import{m as L,W as ne,af as de,r as n,ag as ce,ah as pe,ai as me,S as q,c as r,j as e,e as g,aj as xe,a4 as V,X as be}from"./__vite-browser-external-D-WLjvZW.js";import{u as ue,T as F,S as ge}from"./Controls-WFXDjIYG.js";import{P as he}from"./ProviderIcon-BPxacBzj.js";import{B as W,C as _,a as fe,b as ye}from"./skins-C8EyB85e.js";import{n as ke,p as ve,C as X}from"./ClawdAnimated-1c5ezBBN.js";import{F as $}from"./FadeIn-Cx1hl4so.js";import{L as je}from"./link-2-Bg34XOcd.js";import{L as Y}from"./loader-circle-C4Vul1Yx.js";import{Z as we}from"./zap-D5k595AR.js";import{T as Ne}from"./trash-CVk10mDa.js";import{D as Ce,a as Se,b as Pe,c as Ie,d as ze,e as De}from"./DialogTitle-Bby0zSCw.js";import{D as Ae}from"./DialogDescription-5LunWukT.js";import{D as Te}from"./DialogClose-D2PE0TAc.js";import"./Card-B-gcOAn7.js";import"./react-xGx5RIqz.js";import"./use-reduced-motion-BoFF1l9U.js";import"./composite-DgBqMs_Z.js";import"./store-DfUIKvz3.js";const Z={name:"file-archive",size:24,node:[["path",{d:"M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5",key:"4pqfef"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 12v-1",key:"1ej8lb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M8 7V6",key:"1nbb54"}],["circle",{cx:"8",cy:"20",r:"2",key:"ckkr5m"}]]};Z.node;const _e=L(Z);const G={name:"monitor-up",size:24,node:[["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"M12 13V7",key:"h0r20n"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]};G.node;const Be=L(G);const J={name:"upload",size:24,node:[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]};J.node;const Le=L(J),Ee={visible:!1,character:"clawd",size:"medium",botColor:"auto"};function Oe(){const t=ne()&&de(),[a,o]=n.useState(Ee);n.useEffect(()=>{if(!t)return;const c=ce(l=>{o({visible:!!l.visible,character:ke(l.character),size:["small","medium","large"].includes(l.size)?l.size:"medium",botColor:W.includes(l.botColor)?l.botColor:"auto"})});return pe(),c},[t]);const s=n.useCallback((c,l)=>{o(x=>({...x,[c]:l})),t&&me(c,l)},[t]);return{available:t,settings:a,setSetting:s}}const v=[{id:"clawd",displayName:"Clawd",nameKey:"pet.character.clawd",spriteVersionNumber:1,custom:!1},{id:"bot",displayName:"Bot",nameKey:"pet.character.bot",spriteVersionNumber:1,custom:!1},{id:"sprout",displayName:"Sprout",nameKey:"pet.character.sprout",spriteVersionNumber:1,custom:!1,assetUrl:"/pets/sprout/spritesheet.webp"},{id:"byte",displayName:"Byte",nameKey:"pet.character.byte",spriteVersionNumber:1,custom:!1,assetUrl:"/pets/byte/spritesheet.webp"},{id:"ember",displayName:"Ember",nameKey:"pet.character.ember",spriteVersionNumber:1,custom:!1,assetUrl:"/pets/ember/spritesheet.webp"}];async function I(t){const a=await t.json().catch(()=>null);if(!t.ok||a?.ok===!1)throw new Error(a?.error||`Pet request failed with HTTP ${t.status}`);return a}async function Me(){const t=await fetch("/functions/tokentracker-pets",{headers:{Accept:"application/json"},cache:"no-store"}),a=await I(t),o=new Set(Array.isArray(a.hiddenBuiltinIds)?a.hiddenBuiltinIds:[]);return[...v.filter(s=>!s.assetUrl||!o.has(s.id)),...Array.isArray(a.pets)?a.pets:[]]}async function E(t){const a=await q();return I(await fetch("/functions/tokentracker-pets",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...a},cache:"no-store",body:JSON.stringify(t)}))}function Ke(t){return E({action:"install_url",url:t})}async function H(t){const a=await q();return I(await fetch("/api/pets/import",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/zip",...a},cache:"no-store",body:t}))}function Re(t){return E({action:"remove",id:t})}async function Ue(){const t=await fetch("/functions/tokentracker-pets?scope=codex",{headers:{Accept:"application/json"},cache:"no-store"}),a=await I(t);return{importable:Array.isArray(a.importable)?a.importable:[],codexDetected:a.codexDetected===!0}}function Ve(t){return E({action:"import_codex",ids:t})}let B=v;function Fe(){const[t,a]=n.useState(B),[o,s]=n.useState(!0),[c,l]=n.useState(!1),x=n.useCallback(async()=>{s(!0);try{const b=await Me();return B=b,a(b),l(!0),b}catch{return B=v,a(v),l(!1),v}finally{s(!1)}},[]);return n.useEffect(()=>{x()},[x]),{pets:t,loading:o,available:c,refresh:x}}const $e={clawd:"from-oai-amber-50 dark:from-orange-950/70",bot:"from-oai-brand-50 dark:from-teal-950/70",sprout:"from-oai-brand-100 dark:from-emerald-950/70",byte:"from-oai-gray-200 dark:from-slate-800/70",ember:"from-orange-100 dark:from-orange-950/80"};function He(){const t=r("pet.import.subtitle"),a="codex-pets.net",o=t.indexOf(a);return o<0?t:e.jsxs(e.Fragment,{children:[t.slice(0,o),e.jsx("a",{href:"https://codex-pets.net",target:"_blank",rel:"noreferrer",className:"underline decoration-oai-gray-400 underline-offset-2 transition-colors hover:text-oai-black dark:decoration-oai-gray-500 dark:hover:text-white",children:a}),t.slice(o+a.length)]})}const j=[{id:"idle-living",labelKey:"pet.state.calm"},{id:"working-thinking",labelKey:"pet.state.focus"},{id:"working-juggling",labelKey:"pet.state.multitask"},{id:"working-wizard",labelKey:"pet.state.streak"},{id:"happy",labelKey:"pet.state.celebrate"},{id:"sleeping",labelKey:"pet.state.rest"}];function Q({character:t,selected:a,onSelect:o,onRemove:s,removeDisabled:c}){const l=t.nameKey?r(t.nameKey):t.displayName;return e.jsxs("div",{className:"group relative",children:[e.jsxs("button",{type:"button",onClick:o,"aria-pressed":a,className:g("relative w-full overflow-hidden rounded-xl border p-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",a?"border-oai-brand-500/40 bg-white dark:border-oai-brand-500/25 dark:bg-oai-gray-900/80":"border-oai-gray-200/80 bg-white/55 hover:border-oai-gray-400 dark:border-oai-gray-800 dark:bg-oai-gray-950/55 dark:hover:border-oai-gray-600"),children:[e.jsx("div",{className:g("absolute inset-0 bg-gradient-to-br to-transparent opacity-80 dark:opacity-55",$e[t.id]||"from-oai-gray-200/80 dark:from-oai-gray-800/70")}),e.jsxs("div",{className:"relative flex items-center gap-2.5",children:[e.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center",children:e.jsx(X,{state:"idle-living",character:t.id,pet:t,size:44})}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-semibold text-oai-black dark:text-white",children:l}),t.spriteVersionNumber===2?e.jsx("span",{className:"shrink-0 rounded border border-oai-gray-300/80 px-1 text-[9px] font-semibold text-oai-gray-500 dark:border-oai-gray-600 dark:text-oai-gray-400",children:r("pet.format.v2")}):null,a?e.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-oai-brand-500","aria-hidden":!0}):null]})]})]}),s?e.jsx("button",{type:"button",disabled:c,onClick:s,"aria-label":`${r("pet.import.remove")} · ${l}`,className:g("absolute right-1.5 top-1.5 flex h-6 w-6 items-center justify-center rounded-md border border-oai-gray-200/90 bg-white/95 text-oai-gray-500 transition-opacity hover:text-red-600 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-40 dark:border-oai-gray-700 dark:bg-oai-gray-900/95 dark:text-oai-gray-400 dark:hover:text-red-400","opacity-0 group-hover:opacity-100"),children:e.jsx(Ne,{className:"h-3 w-3","aria-hidden":!0})}):null]})}function qe({value:t,onChange:a}){const o={auto:r("pet.bot.color.auto"),bleu:r("pet.bot.color.bleu"),turquoise:r("pet.bot.color.turquoise"),vert:r("pet.bot.color.vert"),ambre:r("pet.bot.color.ambre"),rose:r("pet.bot.color.rose"),violet:r("pet.bot.color.violet")};return e.jsx("div",{className:"flex flex-wrap items-center justify-end gap-1.5 rounded-full border border-black/5 bg-white/65 px-2.5 py-1.5 backdrop-blur-md dark:border-white/10 dark:bg-black/20",role:"radiogroup","aria-label":r("pet.bot.color"),children:W.map(s=>{const c=(t||"auto")===s;return e.jsx("button",{type:"button",role:"radio","aria-checked":c,"aria-label":o[s],title:o[s],onClick:()=>a(s),className:g("h-4 w-4 rounded-full border transition-transform duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",c?"scale-125 border-oai-black shadow-sm dark:border-white":"border-black/15 hover:scale-110 dark:border-white/25"),style:s==="auto"?{background:`linear-gradient(135deg, ${_.get(fe).hex} 0 50%, ${_.get(ye).hex} 50% 100%)`}:{background:_.get(s)?.hex}},s)})})}function We({pet:t,state:a,onStateChange:o,botColor:s,onBotColorChange:c}){const[l,x]=n.useState(null),b=n.useRef(null),h=j.find(function(d){return d.id===a}),p=r(h?.labelKey||"pet.state.calm");return e.jsxs("section",{className:"relative flex min-h-[400px] flex-col overflow-hidden bg-oai-gray-50 dark:bg-oai-gray-950 sm:min-h-[440px] lg:min-h-[480px]",onPointerMove:m=>{if(t?.spriteVersionNumber!==2||!b.current)return;const d=b.current.getBoundingClientRect(),w=m.clientX-(d.left+d.width/2),N=m.clientY-(d.top+d.height/2),y=(Math.atan2(w,-N)*180/Math.PI+360)%360;x(Math.round(y/22.5)%16)},onPointerLeave:()=>x(null),children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.16] dark:opacity-[0.12]",style:{backgroundImage:"radial-gradient(currentColor 0.7px, transparent 0.7px)",backgroundSize:"14px 14px"},"aria-hidden":!0}),e.jsxs("div",{className:"relative flex items-center justify-between gap-3 px-5 pt-5",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-oai-gray-500 dark:text-oai-gray-400",children:r("pet.preview.states")}),e.jsxs("div",{className:"flex items-center gap-2",children:[ve(t?.id)==="vector"?e.jsx(qe,{value:s,onChange:c}):null,e.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-black/5 bg-white/65 px-3 py-1.5 text-[11px] font-medium text-oai-gray-600 backdrop-blur-md dark:border-white/10 dark:bg-black/20 dark:text-oai-gray-300",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500","aria-hidden":!0}),p]})]})]}),e.jsx("div",{className:"relative flex flex-1 items-center justify-center px-6 py-5",children:e.jsx("div",{ref:b,className:"relative flex h-52 w-52 items-center justify-center sm:h-56 sm:w-56 lg:h-64 lg:w-64",children:e.jsx("div",{className:"origin-bottom lg:scale-[1.18]",children:e.jsx(X,{state:a,character:t?.id||"clawd",pet:t,size:190,lookDirectionIndex:l,botColor:s})})})}),e.jsx("div",{className:"relative border-t border-oai-gray-200/70 bg-white/85 px-3 py-2 dark:border-oai-gray-800 dark:bg-oai-gray-950/85",children:e.jsx("div",{className:"grid grid-cols-3 gap-1","aria-label":r("pet.preview.states"),children:j.map(m=>e.jsxs("button",{type:"button",onClick:()=>o(m.id),"aria-pressed":a===m.id,className:g("flex min-h-10 flex-col items-center justify-center gap-1 rounded-lg px-1.5 text-xs transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500",a===m.id?"font-semibold text-oai-black dark:text-white":"font-medium text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white"),children:[e.jsx("span",{children:r(m.labelKey)}),e.jsx("span",{className:g("h-1 w-1 rounded-full transition-colors duration-200",a===m.id?"bg-oai-black dark:bg-white":"bg-transparent"),"aria-hidden":!0})]},m.id))})})]})}function Xe({pets:t,busy:a,error:o,onImport:s,onClose:c}){const[l,x]=n.useState(()=>new Set),b=p=>x(m=>{const d=new Set(m);return d.has(p)?d.delete(p):d.add(p),d}),h=t.length!==0&&l.size===t.length;return e.jsx(Ce,{open:!0,onOpenChange:p=>{!p&&!a&&c()},children:e.jsxs(Se,{children:[e.jsx(Pe,{className:"fixed inset-0 z-50 bg-black/15 backdrop-blur-md dark:bg-black/40 animate-tt-fade-in"}),e.jsx(Ie,{className:"fixed inset-0 z-50 flex items-center justify-center p-3 md:p-6",children:e.jsxs(ze,{className:"relative flex max-h-[86vh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-oai-gray-200/50 bg-white/95 shadow-2xl backdrop-blur-2xl dark:border-white/10 dark:bg-oai-gray-900/95 animate-tt-modal",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-oai-gray-200/70 px-5 py-4 dark:border-oai-gray-800",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(De,{className:"text-base font-semibold",children:r("pet.codex.title")}),e.jsx(Ae,{className:"mt-0.5 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r("pet.codex.subtitle")})]}),e.jsx(Te,{type:"button",disabled:a,"aria-label":r("pet.codex.close"),className:"shrink-0 rounded-full border border-oai-gray-200/60 p-1.5 text-oai-gray-500 transition-colors hover:text-oai-black disabled:opacity-40 dark:border-oai-gray-800/60 dark:text-oai-gray-400 dark:hover:text-white",children:e.jsx(be,{size:16})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-4",children:[t.length===0?e.jsx("p",{className:"py-8 text-center text-sm text-oai-gray-400 dark:text-oai-gray-500",children:r("pet.codex.empty")}):e.jsx("div",{className:"grid grid-cols-2 gap-2.5 sm:grid-cols-3",children:t.map(p=>e.jsx(Q,{character:p,selected:l.has(p.id),onSelect:()=>b(p.id)},p.id))}),o?e.jsx("p",{role:"alert",className:"mt-3 text-xs text-red-600 dark:text-red-400",children:o}):null]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-oai-gray-200/70 px-5 py-3 dark:border-oai-gray-800",children:[e.jsx("button",{type:"button",disabled:a||t.length===0,onClick:()=>x(h?new Set:new Set(t.map(p=>p.id))),className:"text-xs font-medium text-oai-gray-500 underline-offset-2 hover:underline disabled:opacity-40 dark:text-oai-gray-400",children:r("pet.codex.select_all")}),e.jsxs("button",{type:"button",disabled:a||l.size===0,onClick:()=>s([...l]),className:"flex h-9 items-center gap-1.5 rounded-lg bg-oai-black px-4 text-xs font-semibold text-white transition-colors disabled:bg-oai-gray-200 disabled:text-oai-gray-400 dark:bg-white dark:text-black dark:disabled:bg-oai-gray-800 dark:disabled:text-oai-gray-500",children:[a?e.jsx(Y,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):null,l.size>0?`${r("pet.codex.import")} · ${l.size}`:r("pet.codex.import")]})]})]})})]})})}function xt(){const{available:t,settings:a,setSetting:o}=Oe(),{pets:s,loading:c,available:l,refresh:x}=Fe(),[b,h]=n.useState(""),[p,m]=n.useState(""),[d,w]=n.useState(!1),[N,y]=n.useState([]),[ee,z]=n.useState(!1),[C,O]=n.useState(!1),[te,D]=n.useState(""),[ae,M]=n.useState("idle-living"),[K,re]=n.useState(!0),k=a.character||"clawd",A=ue(),R=A.settings?.menuBarIconStyle==="pet",ie=s.find(i=>i.id===k)||s[0],S=d?{kind:"busy",text:r("pet.import.busy")}:p?{kind:"error",text:p}:null,U=N.length!==0;n.useEffect(()=>{!c&&s.length>0&&!s.some(i=>i.id===k)&&o("character","clawd")},[c,s,k,o]);async function P(i,u=r("pet.import.success")){w(!0),m("");try{const f=await i();await x(),xe(),f?.pet?.id&&o("character",f.pet.id),V({title:u,timeout:4e3}),h("")}catch(f){m(f?.message||r("pet.import.failed"))}finally{w(!1)}}const T=n.useCallback(async()=>{if(!l){y([]);return}try{const i=await Ue();y(i.importable)}catch{y([])}},[l]);n.useEffect(()=>{T()},[T]);async function se(i){O(!0),D("");try{return await Ve(i),await x(),await T(),V({title:r("pet.codex.imported"),timeout:4e3}),!0}catch(u){return D(u?.message||r("pet.import.failed")),!1}finally{O(!1)}}n.useEffect(()=>{if(!K)return;const i=window.setInterval(()=>{M(u=>{const f=j.findIndex(le=>le.id===u);return j[(f+1)%j.length].id})},5e3);return()=>window.clearInterval(i)},[K]);const oe=[{value:"small",label:r("pet.size.small")},{value:"medium",label:r("pet.size.medium")},{value:"large",label:r("pet.size.large")}];return e.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:e.jsx("main",{className:"flex-1 pb-14 pt-8 sm:pt-10",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-4 sm:px-6",children:[e.jsx($,{y:12,children:e.jsxs("header",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight sm:text-4xl",children:r("pet.page.title")}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r("pet.page.subtitle")})]})}),e.jsx($,{y:12,delay:.04,children:e.jsxs("div",{className:"overflow-hidden rounded-[28px] border border-oai-gray-200 bg-white/75 dark:border-oai-gray-800 dark:bg-oai-gray-900/60 lg:grid lg:grid-cols-[1.12fr_0.88fr]",children:[e.jsx(We,{pet:ie,state:ae,onStateChange:i=>{re(!1),M(i)},botColor:a.botColor,onBotColorChange:i=>o("botColor",i)}),e.jsxs("aside",{className:"flex flex-col border-t border-oai-gray-200 p-5 dark:border-oai-gray-800 lg:min-h-[480px] lg:border-l lg:border-t-0",children:[e.jsxs("section",{"aria-labelledby":"pet-character-title",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"pet-character-title",className:"text-sm font-semibold",children:r("pet.characters.title")}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r("pet.characters.subtitle")})]}),e.jsx("div",{className:"mt-4 grid max-h-72 grid-cols-2 gap-2 overflow-y-auto pr-1 -mr-1",children:s.map(i=>e.jsx(Q,{character:i,selected:k===i.id,onSelect:()=>o("character",i.id),removeDisabled:d,onRemove:l&&i.id!=="clawd"&&i.id!=="bot"?()=>P(async()=>(await Re(i.id),k===i.id&&o("character","clawd"),null),r("pet.import.removed")):void 0},i.id))}),A.available?e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 rounded-xl border border-oai-gray-200/70 bg-oai-gray-50/60 px-3 py-2.5 dark:border-oai-gray-800 dark:bg-oai-gray-900/40",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold",children:r("pet.menubar.title")}),e.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r("pet.menubar.hint")})]}),e.jsx(F,{checked:R,onChange:()=>A.setSetting("menuBarIconStyle",R?"clawd":"pet"),ariaLabel:r("pet.menubar.title")})]}):null]}),l?e.jsxs("section",{className:"mt-6 border-t border-oai-gray-200/70 pt-5 dark:border-oai-gray-800","aria-labelledby":"pet-import-title",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{className:"h-4 w-4 shrink-0 text-oai-gray-500","aria-hidden":!0}),e.jsx("h2",{id:"pet-import-title",className:"text-sm font-semibold",children:r("pet.import.title")})]}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:e.jsx(He,{})}),e.jsxs("form",{className:"mt-3 flex gap-2",onSubmit:i=>{i.preventDefault(),!d&&b.trim()&&P(()=>Ke(b))},children:[e.jsxs("label",{className:"relative flex min-w-0 flex-1 items-center",children:[e.jsx(je,{className:"pointer-events-none absolute left-3 h-3.5 w-3.5 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{value:b,onChange:i=>h(i.target.value),"aria-label":r("pet.import.url_label"),placeholder:"codex-pets.net/#/pets/…",className:"h-9 w-full rounded-lg border border-oai-gray-200 bg-white pl-9 pr-3 text-xs outline-none focus:border-oai-brand-500 dark:border-oai-gray-700 dark:bg-oai-gray-950"})]}),e.jsxs("button",{type:"submit",disabled:d||!b.trim(),className:"flex h-9 shrink-0 items-center gap-1.5 rounded-lg bg-oai-black px-3.5 text-xs font-semibold text-white transition-colors disabled:bg-oai-gray-200 disabled:text-oai-gray-400 dark:bg-white dark:text-black dark:disabled:bg-oai-gray-800 dark:disabled:text-oai-gray-500",children:[d?e.jsx(Y,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):null,r("pet.import.add")]})]}),e.jsxs("div",{className:g("mt-2 grid gap-2",U?"grid-cols-2":"grid-cols-1"),children:[U?e.jsxs("button",{type:"button",disabled:d||C,onClick:()=>{D(""),z(!0)},className:g("flex h-9 cursor-pointer items-center justify-center gap-1.5 rounded-lg border border-dashed border-oai-gray-300 text-xs font-medium text-oai-gray-500 transition-colors hover:border-oai-gray-500 hover:text-oai-black dark:border-oai-gray-600 dark:text-oai-gray-400 dark:hover:border-oai-gray-400 dark:hover:text-white",(d||C)&&"pointer-events-none opacity-40"),children:[e.jsx(he,{provider:"codex",size:14,className:"fill-current"}),r("pet.codex.browse")]}):null,e.jsxs("label",{onDragOver:i=>i.preventDefault(),onDrop:i=>{if(i.preventDefault(),d)return;const u=i.dataTransfer?.files?.[0];u&&P(()=>H(u))},className:g("flex h-9 cursor-pointer items-center justify-center gap-1.5 rounded-lg border border-dashed border-oai-gray-300 text-xs font-medium text-oai-gray-500 transition-colors hover:border-oai-gray-500 hover:text-oai-black dark:border-oai-gray-600 dark:text-oai-gray-400 dark:hover:border-oai-gray-400 dark:hover:text-white",d&&"pointer-events-none opacity-40"),children:[e.jsx(_e,{className:"h-3.5 w-3.5","aria-hidden":!0}),r("pet.import.zip"),e.jsx("input",{type:"file",accept:".zip,.codex-pet.zip,application/zip",className:"sr-only",disabled:d,onChange:i=>{const u=i.target.files?.[0];u&&P(()=>H(u)),i.target.value=""}})]})]}),S?e.jsx("p",{role:S.kind==="error"?"alert":"status",className:g("mt-2 text-xs",S.kind==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400"),children:S.text}):null,ee?e.jsx(Xe,{pets:N,busy:C,error:te,onClose:()=>{C||z(!1)},onImport:async i=>{await se(i)&&z(!1)}}):null]}):null,e.jsxs("section",{className:"mt-6 border-t border-oai-gray-200/70 pt-5 dark:border-oai-gray-800",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4 text-oai-gray-500 dark:text-oai-gray-400",strokeWidth:1.75,"aria-hidden":!0}),e.jsx("h2",{className:"text-sm font-semibold",children:r("pet.controls.title")})]}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("div",{className:"text-sm font-medium",children:r("pet.controls.show")}),e.jsx(F,{checked:a.visible,onChange:()=>o("visible",!a.visible),disabled:!t,ariaLabel:r("pet.controls.show")})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("div",{className:"text-sm font-medium",children:r("pet.controls.size")}),e.jsx("div",{className:"shrink-0",children:e.jsx(ge,{options:oe,value:a.size,onChange:i=>o("size",i),disabled:!t})})]})]})]}),t?null:e.jsxs("div",{className:"mt-6 flex gap-2 rounded-xl bg-oai-gray-100 p-3 text-xs leading-relaxed text-oai-gray-500 dark:bg-oai-gray-800/70 dark:text-oai-gray-400",children:[e.jsx(we,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),r("pet.controls.native_only")]})]})]})})]})})})}export{xt as PetPage};
@@ -1 +1 @@
1
- import{r as S,b9 as Ye,ba as Xe,bb as Ue,bc as Ve,bd as ce,be as Ke,bf as ne,ax as pe,bg as Z,bh as ge,bi as me,bj as te,w as J,bk as z,aN as Ce,bl as We,bm as Fe,aO as Q,a2 as le,ay as de,aP as qe,bn as he,bo as Qe,x as ze,bp as $e,bq as Ee,j as X,aR as Je,aQ as Ze,br as et,bs as tt,bt as nt,bu as ot,bv as st,t as rt,v as ke,bw as it,bx as Ie,aL as at,by as ct,bz as lt,aM as ut,aG as ft,bA as dt}from"./__vite-browser-external-CjrP5KfC.js";import{p as pt,c as gt}from"./store-CFdu9yv_.js";import{o as Te,q as we,r as mt,s as Pe,v as oe,w as ht,i as Et,P as Tt,x as Pt,k as vt,l as Ct,m as St,n as bt,j as Rt,f as Ot,h as It,u as Mt,y as yt,z as xt,t as Ft,A as kt,I as wt,B as Ht,c as Lt,d as At,e as Dt,C as Bt,p as Nt}from"./composite-CWz1s64R.js";import{a as jt,b as _t,c as Gt,d as Yt,e as Xt,f as Ut,g as Vt}from"./ToolbarRootContext-D9pPY73U.js";function Kt(e,n){return n!=null&&!Te(n)?0:typeof e=="function"?e():e}function ve(e,n,t){const a=Kt(e,t);return typeof a=="number"?a:a?.[n]}function Me(e){return typeof e=="function"?e():e}function He(e,n){return n||e==="click"||e==="mousedown"}function Wt(e){return e?.includes("mouse")&&e!=="mousedown"}function qt(e){const n=S.useCallback(a=>e===void 0?Ye:e.subscribeStore(a),[e]),t=S.useCallback(()=>e===void 0?void 0:e.store,[e]);return Xe.useSyncExternalStore(n,t,()=>e?.serverStore)}class Se{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new ce,this.restTimeout=new ce,this.handleCloseOptions=void 0}static create(){return new Se}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose}const ue=new WeakMap;function fe(e){if(!e.performedPointerEventsMutation)return;const n=e.pointerEventsScopeElement;n&&ue.get(n)===e&&(e.pointerEventsScopeElement?.style.removeProperty("pointer-events"),e.pointerEventsReferenceElement?.style.removeProperty("pointer-events"),e.pointerEventsFloatingElement?.style.removeProperty("pointer-events"),ue.delete(n)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function Le(e,n){const{scopeElement:t,referenceElement:a,floatingElement:r}=n,s=ue.get(t);s&&s!==e&&fe(s),fe(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=t,e.pointerEventsReferenceElement=a,e.pointerEventsFloatingElement=r,ue.set(t,e),t.style.pointerEvents="none",a.style.pointerEvents="auto",r.style.pointerEvents="auto"}function Ae(e){const n=e.context.dataRef.current,t=Ue(()=>n.hoverInteractionState??Se.create()).current;return n.hoverInteractionState||(n.hoverInteractionState=t),Ve(n.hoverInteractionState.disposeEffect),n.hoverInteractionState}function Qt(e,n={}){const{enabled:t=!0,closeDelay:a=0,nodeId:r}=n,s="rootStore"in e?e.rootStore:e,T=s.useState("open"),g=s.useState("floatingElement"),R=s.useState("domReferenceElement"),{dataRef:c}=s.context,u=we(),f=mt(),d=Ae(s),N=Ke(),B=ne(()=>He(c.current.openEvent?.type,d.interactedInside)),l=ne(()=>Wt(c.current.openEvent?.type)),A=ne(()=>{fe(d)});pe(()=>{T||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,A())},[T,d,A]),S.useEffect(()=>A,[A]),pe(()=>{if(t&&T&&d.handleCloseOptions?.blockPointerEvents&&l()&&Z(R)&&g){const P=R,x=g,o=ge(g),k=u?.nodesRef.current.find(C=>C.id===f)?.context?.elements.floating;k&&(k.style.pointerEvents="");const L=d.pointerEventsScopeElement!==x?d.pointerEventsScopeElement:null,b=k!==x?k:null,m=d.handleCloseOptions?.getScope?.()??L??b??P.closest("[data-rootownerid]")??o.body;return Le(d,{scopeElement:m,referenceElement:P,floatingElement:x}),()=>{A()}}},[t,T,R,g,d,l,u,f,A]),S.useEffect(()=>{if(!t)return;function P(){return!!(u&&f&&Pe(u.nodesRef.current,f).length>0)}function x(C){const F=ve(a,"close",d.pointerType),j=()=>{s.setOpen(!1,J(z,C)),u?.events.emit("floating.closed",C)};F?d.openChangeTimeout.start(F,j):(d.openChangeTimeout.clear(),j())}function o(C){const F=Ce(C);if(!We(F)){d.interactedInside=!1;return}d.interactedInside=F?.closest("[aria-haspopup]")!=null}function k(){d.openChangeTimeout.clear(),N.clear(),u?.events.off("floating.closed",b),A()}function L(C){if(P()&&u){u.events.on("floating.closed",b);return}if(Fe(C.relatedTarget,s.context.triggerElements))return;const F=c.current.floatingContext?.nodeId??r,j=C.relatedTarget;if(!(u&&F&&Z(j)&&Pe(u.nodesRef.current,F,!1).some(_=>Q(_.context?.elements.floating,j)))){if(d.handler){d.handler(C);return}A(),l()&&!B()&&x(C)}}function b(C){!u||!f||P()||N.start(0,()=>{u.events.off("floating.closed",b),s.setOpen(!1,J(z,C)),u.events.emit("floating.closed",C)})}const m=g;return me(m&&te(m,"mouseenter",k),m&&te(m,"mouseleave",L),m&&te(m,"pointerdown",o,!0),()=>{u?.events.off("floating.closed",b)})},[t,g,s,c,a,r,l,B,A,d,u,f,N])}const zt={current:null};function $t(e,n={}){const{enabled:t=!0,delay:a=0,handleClose:r=null,mouseOnly:s=!1,restMs:T=0,move:g=!0,triggerElementRef:R=zt,externalTree:c,isActiveTrigger:u=!0,getHandleCloseContext:f,isClosing:d,shouldOpen:N,guardStaleOpen:B=!1}=n,l="rootStore"in e?e.rootStore:e,{dataRef:A,events:P}=l.context,x=we(c),o=Ae(l),k=S.useRef(!1),L=oe(r),b=oe(a),m=oe(T),C=oe(t),F=oe(N),j=oe(d),W=ne(()=>He(A.current.openEvent?.type,o.interactedInside)),_=ne(()=>F.current?.()!==!1),G=ne((I,h,M)=>{const E=l.context.triggerElements;if(E.hasElement(h))return!I||!Q(I,h);if(!Z(M))return!1;const q=M;return E.hasMatchingElement(U=>Q(U,q))&&(!I||!Q(I,q))}),O=ne(()=>{if(!o.handler)return;ge(l.select("domReferenceElement")).removeEventListener("mousemove",o.handler),o.handler=void 0}),i=ne(()=>{fe(o)});return u&&(o.handleCloseOptions=r?.__options),S.useEffect(()=>O,[O]),S.useEffect(()=>{if(!t)return;function I(h){h.open?k.current=!1:(k.current=h.reason===z,O(),o.openChangeTimeout.clear(),o.restTimeout.clear(),o.blockMouseMove=!0,o.restTimeoutPending=!1)}return P.on("openchange",I),()=>{P.off("openchange",I)}},[t,P,o,O]),S.useEffect(()=>{if(!t)return;function I(v,V=!0){const D=ve(b.current,"close",o.pointerType);D?o.openChangeTimeout.start(D,()=>{l.setOpen(!1,J(z,v)),x?.events.emit("floating.closed",v)}):V&&(o.openChangeTimeout.clear(),l.setOpen(!1,J(z,v)),x?.events.emit("floating.closed",v))}const h=R.current??(u?l.select("domReferenceElement"):null);if(!Z(h))return;function M(v){if(o.openChangeTimeout.clear(),o.blockMouseMove=!1,s&&!Te(o.pointerType))return;const V=Me(m.current),D=ve(b.current,"open",o.pointerType),w=Ce(v),p=v.currentTarget??null,H=l.select("domReferenceElement");let Y=p;if(Z(w)&&!l.context.triggerElements.hasElement(w)){for(const Oe of l.context.triggerElements.elements())if(Q(Oe,w)){Y=Oe;break}}Z(p)&&Z(H)&&!l.context.triggerElements.hasElement(p)&&Q(p,H)&&(Y=H);const K=Y==null?!1:G(H,Y,w),$=l.select("open"),ee=j.current?.()??l.select("transitionStatus")==="ending",be=!$&&ee&&k.current,je=!K&&Z(Y)&&Z(H)&&Q(H,Y)&&be,_e=V>0&&!D,Ge=K&&($||be)||je,Re=!$||K;if(Ge){_()&&l.setOpen(!0,J(z,v,Y));return}_e||(D?o.openChangeTimeout.start(D,()=>{Re&&_()&&l.setOpen(!0,J(z,v,Y))}):Re&&_()&&l.setOpen(!0,J(z,v,Y)))}function E(v){if(W()){i();return}O();const V=l.select("domReferenceElement"),D=ge(V);o.restTimeout.clear(),o.restTimeoutPending=!1;const w=A.current.floatingContext??f?.();if(Fe(v.relatedTarget,l.context.triggerElements))return;if(L.current&&w){l.select("open")||o.openChangeTimeout.clear();const H=R.current;o.handler=L.current({...w,tree:x,x:v.clientX,y:v.clientY,onClose(){i(),O(),C.current&&!W()&&H===l.select("domReferenceElement")&&I(v,!0)}}),D.addEventListener("mousemove",o.handler),o.handler(v);return}(o.pointerType!=="touch"||!Q(l.select("floatingElement"),v.relatedTarget))&&I(v)}function q(v){Q(h,v.relatedTarget)||(o.openChangeTimeout.clear(),o.restTimeout.clear(),o.restTimeoutPending=!1)}const U=B?te(h,"mouseout",q):void 0;return g?me(te(h,"mousemove",M,{once:!0}),te(h,"mouseenter",M),te(h,"mouseleave",E),U):me(te(h,"mouseenter",M),te(h,"mouseleave",E),U)},[O,i,A,b,l,t,L,o,u,G,W,s,g,m,R,x,C,f,j,_,B]),S.useMemo(()=>{if(!t)return;function I(h){o.pointerType=h.pointerType}return{onPointerDown:I,onPointerEnter:I,onMouseMove(h){const{nativeEvent:M}=h,E=h.currentTarget,q=l.select("domReferenceElement"),U=l.select("open"),v=G(q,E,h.target);if(s&&!Te(o.pointerType))return;if(U&&v&&o.handleCloseOptions?.blockPointerEvents){const w=l.select("floatingElement");if(w){const p=o.handleCloseOptions?.getScope?.()??E.ownerDocument.body;Le(o,{scopeElement:p,referenceElement:E,floatingElement:w})}}const V=Me(m.current);if(U&&!v||V===0||!v&&o.restTimeoutPending&&h.movementX**2+h.movementY**2<2)return;o.restTimeout.clear();function D(){if(o.restTimeoutPending=!1,W())return;const w=l.select("open");!o.blockMouseMove&&(!w||v)&&_()&&l.setOpen(!0,J(z,M,E))}o.pointerType==="touch"?le.flushSync(()=>{D()}):v&&U?D():(o.restTimeoutPending=!0,o.restTimeout.start(V,D))}}},[t,o,W,G,s,l,m,_])}const ye=.1,Jt=ye*ye,y=.5;function re(e,n,t,a,r,s){return a>=n!=s>=n&&e<=(r-t)*(n-a)/(s-a)+t}function ie(e,n,t,a,r,s,T,g,R,c){let u=!1;return re(e,n,t,a,r,s)&&(u=!u),re(e,n,r,s,T,g)&&(u=!u),re(e,n,T,g,R,c)&&(u=!u),re(e,n,R,c,t,a)&&(u=!u),u}function Zt(e,n,t){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height}function ae(e,n,t,a,r,s){const T=Math.min(t,r),g=Math.max(t,r),R=Math.min(a,s),c=Math.max(a,s);return e>=T&&e<=g&&n>=R&&n<=c}function en(e={}){const{blockPointerEvents:n=!1}=e,t=new ce,a=({x:r,y:s,placement:T,elements:g,onClose:R,nodeId:c,tree:u})=>{const f=T?.split("-")[0];let d=!1,N=null,B=null,l=typeof performance<"u"?performance.now():0;function A(x,o){const k=performance.now(),L=k-l;if(N===null||B===null||L===0)return N=x,B=o,l=k,!1;const b=x-N,m=o-B,C=b*b+m*m,F=L*L*Jt;return N=x,B=o,l=k,C<F}function P(){t.clear(),R()}return function(o){t.clear();const k=g.domReference,L=g.floating;if(!k||!L||f==null||r==null||s==null)return;const{clientX:b,clientY:m}=o,C=Ce(o),F=o.type==="mouseleave",j=Q(L,C),W=Q(k,C);if(j&&(d=!0,!F))return;if(W&&(d=!1,!F)){d=!0;return}if(F&&Z(o.relatedTarget)&&Q(L,o.relatedTarget))return;function _(){return!!(u&&Pe(u.nodesRef.current,c).length>0)}function G(){_()||P()}if(_())return;const O=k.getBoundingClientRect(),i=L.getBoundingClientRect(),I=r>i.right-i.width/2,h=s>i.bottom-i.height/2,M=i.width>O.width,E=i.height>O.height,q=(M?O:i).left,U=(M?O:i).right,v=(E?O:i).top,V=(E?O:i).bottom;if(f==="top"&&s>=O.bottom-1||f==="bottom"&&s<=O.top+1||f==="left"&&r>=O.right-1||f==="right"&&r<=O.left+1){G();return}let D=!1;switch(f){case"top":D=ae(b,m,q,O.top+1,U,i.bottom-1);break;case"bottom":D=ae(b,m,q,i.top+1,U,O.bottom-1);break;case"left":D=ae(b,m,i.right-1,V,O.left+1,v);break;case"right":D=ae(b,m,O.right-1,V,i.left+1,v);break}if(D)return;if(d&&!Zt(b,m,O)){G();return}if(!F&&A(b,m)){G();return}let w=!1;switch(f){case"top":{const p=M?y/2:y*4,H=M||I?r+p:r-p,Y=M?r-p:I?r+p:r-p,K=s+y+1,$=I||M?i.bottom-y:i.top,ee=I?M?i.bottom-y:i.top:i.bottom-y;w=ie(b,m,H,K,Y,K,i.left,$,i.right,ee);break}case"bottom":{const p=M?y/2:y*4,H=M||I?r+p:r-p,Y=M?r-p:I?r+p:r-p,K=s-y,$=I||M?i.top+y:i.bottom,ee=I?M?i.top+y:i.bottom:i.top+y;w=ie(b,m,H,K,Y,K,i.left,$,i.right,ee);break}case"left":{const p=E?y/2:y*4,H=E||h?s+p:s-p,Y=E?s-p:h?s+p:s-p,K=r+y+1,$=h||E?i.right-y:i.left,ee=h?E?i.right-y:i.left:i.right-y;w=ie(b,m,$,i.top,ee,i.bottom,K,H,K,Y);break}case"right":{const p=E?y/2:y*4,H=E||h?s+p:s-p,Y=E?s-p:h?s+p:s-p,K=r-y,$=h||E?i.left+y:i.right,ee=h?E?i.left+y:i.right:i.left+y;w=ie(b,m,K,H,K,Y,$,i.top,ee,i.bottom);break}}w?d||t.start(40,G):G()}};return a.__options={...e,blockPointerEvents:n},a}const De=S.createContext(void 0);function se(e){const n=S.useContext(De);if(n===void 0&&!e)throw new Error(de(47));return n}const tn={...pt,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};class nn extends qe{constructor(n,t,a){const r=new Tt;super(on(n,r,t,a),sn(r),tn)}setOpen=(n,t)=>{const a=t.reason===z,r=t.reason===he&&t.event.detail===0,s=!n&&(t.reason===Qe||t.reason==null),T=ht(t),g=this.select("activeTriggerId");if(!n&&t.reason===ze&&t.trigger==null&&g!=null&&(t.trigger=this.context.triggerElements.getById(g)??this.select("activeTriggerElement")??void 0),this.context.onOpenChange?.(n,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(n,t);const R=()=>{const u=Et(this.state,n,t.trigger,T());u.openChangeReason=t.reason,this.update(u)};a?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start($e,()=>{this.set("stickIfOpen",!1)}),le.flushSync(R)):R();let c;r?c="click":s?c="dismiss":t.reason===Ee&&(c="focus"),this.set("instantType",c)}}function on(e,n,t,a=!1){const r={...gt(n,t,a),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return r.open&&e?.mounted===void 0&&(r.mounted=!0),r}function sn(e){return{popupRef:S.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:S.createRef(),beforeContentFocusGuardRef:S.createRef(),stickIfOpenTimeout:new ce,triggerElements:e}}const xe=Je(function({props:n}){const{children:t,open:a,defaultOpen:r=!1,onOpenChange:s,onOpenChangeComplete:T,modal:g=!1,handle:R,triggerId:c,defaultTriggerId:u=null}=n,f=rn(R,{modal:g,open:r,openProp:a,activeTriggerId:u,triggerIdProp:c});f.useControlledProp("openProp",a),f.useControlledProp("triggerIdProp",c);const d=f.useState("open"),N=f.useState("mounted"),B=f.useState("payload");f.useContextCallback("onOpenChange",s),f.useContextCallback("onOpenChangeComplete",T),vt(f,d),Ct(f);const{forceUnmount:l}=St(d,f,()=>{f.update({stickIfOpen:!0,openChangeReason:null})});f.useSyncedValues({modal:g}),S.useEffect(()=>{d||f.context.stickIfOpenTimeout.clear()},[f,d]),S.useImperativeHandle(n.actionsRef,()=>({unmount:l,close:()=>f.setOpen(!1,J(Ze))}),[l,f]);const A=d||N;return X.jsxs(De.Provider,{value:f,children:[R&&X.jsx(bt,{handle:R,store:f}),A&&X.jsx(an,{store:f,modal:g}),typeof t=="function"?t({payload:B}):t]})});function Tn(e){return se(!0)?X.jsx(xe,{props:e}):X.jsx(Pt,{children:X.jsx(xe,{props:e})})}function rn(e,n){const t=Rt((a,r)=>new nn(n,a,r));return S.useEffect(()=>t.context.stickIfOpenTimeout.disposeEffect(),[t]),t}function an({store:e,modal:n}){const t=e.useState("floatingRootContext"),a=Ot(t,{outsidePressEvent:{mouse:n==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),r=a.reference,s=a.floating;return It(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:s}),null}const cn=300;function ln(e,n){const t=S.useRef(null);function a(s){le.flushSync(()=>{e.setOpen(!1,J(Ee,s.nativeEvent,s.currentTarget))}),ot(t.current)?.focus()}function r(s){const T=e.select("positionerElement");if(T&&et(s,T))e.context.beforeContentFocusGuardRef.current?.focus();else{le.flushSync(()=>{e.setOpen(!1,J(Ee,s.nativeEvent,s.currentTarget))});let g=tt(e.context.triggerFocusTargetRef.current||n.current);for(;g!==null&&Q(T,g);){const R=g;if(g=nt(g),g===R)break}g?.focus()}}return{preFocusGuardRef:t,handlePreFocusGuardFocus:a,handleFocusTargetFocus:r}}const Pn=st(function(n,t){const{render:a,className:r,style:s,disabled:T=!1,nativeButton:g=!0,handle:R,payload:c,openOnHover:u=!1,delay:f=cn,closeDelay:d=0,id:N,...B}=n,l=se(!0),P=qt(R)??l;if(!P)throw new Error(de(74));const x=Mt(N),o=P.useState("isTriggerActive",x),k=P.useState("floatingRootContext"),L=P.useState("isOpenedByTrigger",x),b=P.useState("triggerPopupId",x),m=S.useRef(null),{registerTrigger:C,isMountedByThisTrigger:F}=yt(x,m,P,{payload:c,disabled:T,openOnHover:u,closeDelay:d}),j=P.useState("openChangeReason"),W=P.useState("stickIfOpen"),_=P.useState("openMethod"),G=P.useState("focusManagerModal"),O=$t(k,{enabled:!T&&u&&(_!=="touch"||j!==he),mouseOnly:!0,move:!1,handleClose:en(),restMs:f,delay:{close:d},triggerElementRef:m,isActiveTrigger:o,isClosing:()=>P.select("transitionStatus")==="ending"}),i=jt(k,{stickIfOpen:W}),I=_t(()=>P.select("open"),H=>{P.set("openMethod",H)}),h=P.useState("triggerProps",F),{getButtonProps:M,buttonRef:E}=rt({disabled:T,native:g}),q={open(H){return H&&j===he?xt.open(H):Ft.open(H)}},{preFocusGuardRef:U,handlePreFocusGuardFocus:v,handleFocusTargetFocus:V}=ln(P,m),w=ke("button",n,{state:{disabled:T,open:L},ref:[E,t,C,m],props:[i.reference,O,h,I,{[it]:"",id:x,"aria-haspopup":"dialog","aria-expanded":L,"aria-controls":b},B,M],stateAttributesMapping:q}),p=X.jsx(S.Fragment,{children:w},x);return F&&!G?X.jsxs(S.Fragment,{children:[X.jsx(Ie,{ref:U,onFocus:v}),p,X.jsx(Ie,{ref:P.context.triggerFocusTargetRef,onFocus:V})]}):p}),Be=S.createContext(void 0);function un(){const e=S.useContext(Be);if(e===void 0)throw new Error(de(45));return e}const vn=S.forwardRef(function(n,t){const{keepMounted:a=!1,...r}=n;return se().useState("mounted")||a?X.jsx(Be.Provider,{value:a,children:X.jsx(at,{ref:t,...r})}):null}),Ne=S.createContext(void 0);function fn(){const e=S.useContext(Ne);if(!e)throw new Error(de(46));return e}const Cn=S.forwardRef(function(n,t){const{render:a,className:r,style:s,anchor:T,positionMethod:g,side:R,align:c,sideOffset:u,alignOffset:f,collisionBoundary:d="clipping-ancestors",collisionPadding:N,arrowPadding:B,sticky:l,disableAnchorTracking:A=!1,collisionAvoidance:P=ct,...x}=n,o=se(),k=un(),L=kt(),b=o.useState("floatingRootContext"),m=o.useState("mounted"),C=o.useState("open"),F=o.useState("openChangeReason"),j=o.useState("activeTriggerElement"),W=o.useState("modal"),_=o.useState("openMethod"),G=o.useState("positionerElement"),O=o.useState("instantType"),i=o.useState("transitionStatus"),I=o.useState("adaptiveOrigin"),h=S.useRef(null),M=lt(G),E=Gt({anchor:T,floatingRootContext:b,positionMethod:g,mounted:m,side:R,sideOffset:u,align:c,alignOffset:f,arrowPadding:B,collisionBoundary:d,collisionPadding:N,sticky:l,disableAnchorTracking:A,keepMounted:k,nodeId:L,collisionAvoidance:P,adaptiveOrigin:I}),q=b.useState("domReferenceElement");pe(()=>{const w=q,p=h.current;if(w&&(h.current=w),p&&w&&w!==p){o.set("instantType",void 0);const H=new AbortController;return M(()=>{o.set("instantType","trigger-change")},H.signal),()=>{H.abort()}}},[q,M,o]);const U=W===!0&&F!==z;Yt(C&&U,_==="touch",G,j);const v=o.useStateSetter("positionerElement"),V={open:C,side:E.side,align:E.align,anchorHidden:E.anchorHidden,instant:O},D=Xt(n,V,{styles:E.positionerStyles,transitionStatus:i,props:x,refs:[t,v],hidden:!m,inert:!C});return X.jsxs(Ne.Provider,{value:E,children:[m&&U&&X.jsx(wt,{inert:ut(!C),cutout:j}),X.jsx(Ht,{id:L,children:D})]})}),dn=S.createContext(void 0);function pn(){const[e,n]=S.useState(0),t=ne(()=>(n(r=>r+1),()=>{n(r=>Math.max(0,r-1))}));return{context:S.useMemo(()=>({register:t}),[t]),hasClosePart:e>0}}const Sn=S.forwardRef(function(n,t){const{render:a,className:r,style:s,initialFocus:T,finalFocus:g,...R}=n,c=se(),u=fn(),f=Ut()!=null,{context:d,hasClosePart:N}=pn(),B=c.useState("open"),l=c.useState("openMethod"),A=c.useState("instantType"),P=c.useState("transitionStatus"),x=c.useState("popupProps"),o=c.useState("titleElementId"),k=c.useState("descriptionElementId"),L=c.useState("modal"),b=c.useState("mounted"),m=c.useState("openChangeReason"),C=c.useState("activeTriggerElement"),F=c.useState("floatingRootContext"),j=F.useState("floatingId"),W=c.useState("disabled"),_=c.useState("openOnHover"),G=c.useState("closeDelay");ft({open:B,ref:c.context.popupRef,onComplete(){B&&c.context.onOpenChangeComplete?.(!0)}}),Qt(F,{enabled:_&&!W,closeDelay:G});const O=T===void 0?Lt(c.context.popupRef):T,i=L!==!1&&N;c.useSyncedValue("focusManagerModal",i);const I=c.useStateSetter("popupElement"),h={open:B,side:u.side,align:u.align,instant:A,transitionStatus:P},M=ke("div",n,{state:h,ref:[t,c.context.popupRef,I],props:[x,{id:j,role:"dialog",...Dt,"aria-labelledby":o,"aria-describedby":k,onKeyDown(E){f&&Bt.has(E.key)&&E.stopPropagation()}},Vt(P),R],stateAttributesMapping:Nt});return X.jsx(At,{context:F,openInteractionType:l,modal:i,disabled:!b||m===z,initialFocus:O,returnFocus:g,restoreFocus:"popup",previousFocusableElement:dt(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:X.jsx(dn.Provider,{value:d,children:M})})});export{Tn as P,Pn as a,vn as b,Cn as c,Sn as d};
1
+ import{r as S,b9 as Ye,ba as Xe,bb as Ue,bc as Ve,bd as ce,be as Ke,bf as ne,ax as pe,bg as Z,bh as ge,bi as me,bj as te,w as J,bk as z,aN as Ce,bl as We,bm as Fe,aO as Q,a2 as le,ay as de,aP as qe,bn as he,bo as Qe,x as ze,bp as $e,bq as Ee,j as X,aR as Je,aQ as Ze,br as et,bs as tt,bt as nt,bu as ot,bv as st,t as rt,v as ke,bw as it,bx as Ie,aL as at,by as ct,bz as lt,aM as ut,aG as ft,bA as dt}from"./__vite-browser-external-D-WLjvZW.js";import{p as pt,c as gt}from"./store-DfUIKvz3.js";import{o as Te,q as we,r as mt,s as Pe,v as oe,w as ht,i as Et,P as Tt,x as Pt,k as vt,l as Ct,m as St,n as bt,j as Rt,f as Ot,h as It,u as Mt,y as yt,z as xt,t as Ft,A as kt,I as wt,B as Ht,c as Lt,d as At,e as Dt,C as Bt,p as Nt}from"./composite-DgBqMs_Z.js";import{a as jt,b as _t,c as Gt,d as Yt,e as Xt,f as Ut,g as Vt}from"./ToolbarRootContext-PoCcP2AV.js";function Kt(e,n){return n!=null&&!Te(n)?0:typeof e=="function"?e():e}function ve(e,n,t){const a=Kt(e,t);return typeof a=="number"?a:a?.[n]}function Me(e){return typeof e=="function"?e():e}function He(e,n){return n||e==="click"||e==="mousedown"}function Wt(e){return e?.includes("mouse")&&e!=="mousedown"}function qt(e){const n=S.useCallback(a=>e===void 0?Ye:e.subscribeStore(a),[e]),t=S.useCallback(()=>e===void 0?void 0:e.store,[e]);return Xe.useSyncExternalStore(n,t,()=>e?.serverStore)}class Se{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new ce,this.restTimeout=new ce,this.handleCloseOptions=void 0}static create(){return new Se}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose}const ue=new WeakMap;function fe(e){if(!e.performedPointerEventsMutation)return;const n=e.pointerEventsScopeElement;n&&ue.get(n)===e&&(e.pointerEventsScopeElement?.style.removeProperty("pointer-events"),e.pointerEventsReferenceElement?.style.removeProperty("pointer-events"),e.pointerEventsFloatingElement?.style.removeProperty("pointer-events"),ue.delete(n)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function Le(e,n){const{scopeElement:t,referenceElement:a,floatingElement:r}=n,s=ue.get(t);s&&s!==e&&fe(s),fe(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=t,e.pointerEventsReferenceElement=a,e.pointerEventsFloatingElement=r,ue.set(t,e),t.style.pointerEvents="none",a.style.pointerEvents="auto",r.style.pointerEvents="auto"}function Ae(e){const n=e.context.dataRef.current,t=Ue(()=>n.hoverInteractionState??Se.create()).current;return n.hoverInteractionState||(n.hoverInteractionState=t),Ve(n.hoverInteractionState.disposeEffect),n.hoverInteractionState}function Qt(e,n={}){const{enabled:t=!0,closeDelay:a=0,nodeId:r}=n,s="rootStore"in e?e.rootStore:e,T=s.useState("open"),g=s.useState("floatingElement"),R=s.useState("domReferenceElement"),{dataRef:c}=s.context,u=we(),f=mt(),d=Ae(s),N=Ke(),B=ne(()=>He(c.current.openEvent?.type,d.interactedInside)),l=ne(()=>Wt(c.current.openEvent?.type)),A=ne(()=>{fe(d)});pe(()=>{T||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,A())},[T,d,A]),S.useEffect(()=>A,[A]),pe(()=>{if(t&&T&&d.handleCloseOptions?.blockPointerEvents&&l()&&Z(R)&&g){const P=R,x=g,o=ge(g),k=u?.nodesRef.current.find(C=>C.id===f)?.context?.elements.floating;k&&(k.style.pointerEvents="");const L=d.pointerEventsScopeElement!==x?d.pointerEventsScopeElement:null,b=k!==x?k:null,m=d.handleCloseOptions?.getScope?.()??L??b??P.closest("[data-rootownerid]")??o.body;return Le(d,{scopeElement:m,referenceElement:P,floatingElement:x}),()=>{A()}}},[t,T,R,g,d,l,u,f,A]),S.useEffect(()=>{if(!t)return;function P(){return!!(u&&f&&Pe(u.nodesRef.current,f).length>0)}function x(C){const F=ve(a,"close",d.pointerType),j=()=>{s.setOpen(!1,J(z,C)),u?.events.emit("floating.closed",C)};F?d.openChangeTimeout.start(F,j):(d.openChangeTimeout.clear(),j())}function o(C){const F=Ce(C);if(!We(F)){d.interactedInside=!1;return}d.interactedInside=F?.closest("[aria-haspopup]")!=null}function k(){d.openChangeTimeout.clear(),N.clear(),u?.events.off("floating.closed",b),A()}function L(C){if(P()&&u){u.events.on("floating.closed",b);return}if(Fe(C.relatedTarget,s.context.triggerElements))return;const F=c.current.floatingContext?.nodeId??r,j=C.relatedTarget;if(!(u&&F&&Z(j)&&Pe(u.nodesRef.current,F,!1).some(_=>Q(_.context?.elements.floating,j)))){if(d.handler){d.handler(C);return}A(),l()&&!B()&&x(C)}}function b(C){!u||!f||P()||N.start(0,()=>{u.events.off("floating.closed",b),s.setOpen(!1,J(z,C)),u.events.emit("floating.closed",C)})}const m=g;return me(m&&te(m,"mouseenter",k),m&&te(m,"mouseleave",L),m&&te(m,"pointerdown",o,!0),()=>{u?.events.off("floating.closed",b)})},[t,g,s,c,a,r,l,B,A,d,u,f,N])}const zt={current:null};function $t(e,n={}){const{enabled:t=!0,delay:a=0,handleClose:r=null,mouseOnly:s=!1,restMs:T=0,move:g=!0,triggerElementRef:R=zt,externalTree:c,isActiveTrigger:u=!0,getHandleCloseContext:f,isClosing:d,shouldOpen:N,guardStaleOpen:B=!1}=n,l="rootStore"in e?e.rootStore:e,{dataRef:A,events:P}=l.context,x=we(c),o=Ae(l),k=S.useRef(!1),L=oe(r),b=oe(a),m=oe(T),C=oe(t),F=oe(N),j=oe(d),W=ne(()=>He(A.current.openEvent?.type,o.interactedInside)),_=ne(()=>F.current?.()!==!1),G=ne((I,h,M)=>{const E=l.context.triggerElements;if(E.hasElement(h))return!I||!Q(I,h);if(!Z(M))return!1;const q=M;return E.hasMatchingElement(U=>Q(U,q))&&(!I||!Q(I,q))}),O=ne(()=>{if(!o.handler)return;ge(l.select("domReferenceElement")).removeEventListener("mousemove",o.handler),o.handler=void 0}),i=ne(()=>{fe(o)});return u&&(o.handleCloseOptions=r?.__options),S.useEffect(()=>O,[O]),S.useEffect(()=>{if(!t)return;function I(h){h.open?k.current=!1:(k.current=h.reason===z,O(),o.openChangeTimeout.clear(),o.restTimeout.clear(),o.blockMouseMove=!0,o.restTimeoutPending=!1)}return P.on("openchange",I),()=>{P.off("openchange",I)}},[t,P,o,O]),S.useEffect(()=>{if(!t)return;function I(v,V=!0){const D=ve(b.current,"close",o.pointerType);D?o.openChangeTimeout.start(D,()=>{l.setOpen(!1,J(z,v)),x?.events.emit("floating.closed",v)}):V&&(o.openChangeTimeout.clear(),l.setOpen(!1,J(z,v)),x?.events.emit("floating.closed",v))}const h=R.current??(u?l.select("domReferenceElement"):null);if(!Z(h))return;function M(v){if(o.openChangeTimeout.clear(),o.blockMouseMove=!1,s&&!Te(o.pointerType))return;const V=Me(m.current),D=ve(b.current,"open",o.pointerType),w=Ce(v),p=v.currentTarget??null,H=l.select("domReferenceElement");let Y=p;if(Z(w)&&!l.context.triggerElements.hasElement(w)){for(const Oe of l.context.triggerElements.elements())if(Q(Oe,w)){Y=Oe;break}}Z(p)&&Z(H)&&!l.context.triggerElements.hasElement(p)&&Q(p,H)&&(Y=H);const K=Y==null?!1:G(H,Y,w),$=l.select("open"),ee=j.current?.()??l.select("transitionStatus")==="ending",be=!$&&ee&&k.current,je=!K&&Z(Y)&&Z(H)&&Q(H,Y)&&be,_e=V>0&&!D,Ge=K&&($||be)||je,Re=!$||K;if(Ge){_()&&l.setOpen(!0,J(z,v,Y));return}_e||(D?o.openChangeTimeout.start(D,()=>{Re&&_()&&l.setOpen(!0,J(z,v,Y))}):Re&&_()&&l.setOpen(!0,J(z,v,Y)))}function E(v){if(W()){i();return}O();const V=l.select("domReferenceElement"),D=ge(V);o.restTimeout.clear(),o.restTimeoutPending=!1;const w=A.current.floatingContext??f?.();if(Fe(v.relatedTarget,l.context.triggerElements))return;if(L.current&&w){l.select("open")||o.openChangeTimeout.clear();const H=R.current;o.handler=L.current({...w,tree:x,x:v.clientX,y:v.clientY,onClose(){i(),O(),C.current&&!W()&&H===l.select("domReferenceElement")&&I(v,!0)}}),D.addEventListener("mousemove",o.handler),o.handler(v);return}(o.pointerType!=="touch"||!Q(l.select("floatingElement"),v.relatedTarget))&&I(v)}function q(v){Q(h,v.relatedTarget)||(o.openChangeTimeout.clear(),o.restTimeout.clear(),o.restTimeoutPending=!1)}const U=B?te(h,"mouseout",q):void 0;return g?me(te(h,"mousemove",M,{once:!0}),te(h,"mouseenter",M),te(h,"mouseleave",E),U):me(te(h,"mouseenter",M),te(h,"mouseleave",E),U)},[O,i,A,b,l,t,L,o,u,G,W,s,g,m,R,x,C,f,j,_,B]),S.useMemo(()=>{if(!t)return;function I(h){o.pointerType=h.pointerType}return{onPointerDown:I,onPointerEnter:I,onMouseMove(h){const{nativeEvent:M}=h,E=h.currentTarget,q=l.select("domReferenceElement"),U=l.select("open"),v=G(q,E,h.target);if(s&&!Te(o.pointerType))return;if(U&&v&&o.handleCloseOptions?.blockPointerEvents){const w=l.select("floatingElement");if(w){const p=o.handleCloseOptions?.getScope?.()??E.ownerDocument.body;Le(o,{scopeElement:p,referenceElement:E,floatingElement:w})}}const V=Me(m.current);if(U&&!v||V===0||!v&&o.restTimeoutPending&&h.movementX**2+h.movementY**2<2)return;o.restTimeout.clear();function D(){if(o.restTimeoutPending=!1,W())return;const w=l.select("open");!o.blockMouseMove&&(!w||v)&&_()&&l.setOpen(!0,J(z,M,E))}o.pointerType==="touch"?le.flushSync(()=>{D()}):v&&U?D():(o.restTimeoutPending=!0,o.restTimeout.start(V,D))}}},[t,o,W,G,s,l,m,_])}const ye=.1,Jt=ye*ye,y=.5;function re(e,n,t,a,r,s){return a>=n!=s>=n&&e<=(r-t)*(n-a)/(s-a)+t}function ie(e,n,t,a,r,s,T,g,R,c){let u=!1;return re(e,n,t,a,r,s)&&(u=!u),re(e,n,r,s,T,g)&&(u=!u),re(e,n,T,g,R,c)&&(u=!u),re(e,n,R,c,t,a)&&(u=!u),u}function Zt(e,n,t){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height}function ae(e,n,t,a,r,s){const T=Math.min(t,r),g=Math.max(t,r),R=Math.min(a,s),c=Math.max(a,s);return e>=T&&e<=g&&n>=R&&n<=c}function en(e={}){const{blockPointerEvents:n=!1}=e,t=new ce,a=({x:r,y:s,placement:T,elements:g,onClose:R,nodeId:c,tree:u})=>{const f=T?.split("-")[0];let d=!1,N=null,B=null,l=typeof performance<"u"?performance.now():0;function A(x,o){const k=performance.now(),L=k-l;if(N===null||B===null||L===0)return N=x,B=o,l=k,!1;const b=x-N,m=o-B,C=b*b+m*m,F=L*L*Jt;return N=x,B=o,l=k,C<F}function P(){t.clear(),R()}return function(o){t.clear();const k=g.domReference,L=g.floating;if(!k||!L||f==null||r==null||s==null)return;const{clientX:b,clientY:m}=o,C=Ce(o),F=o.type==="mouseleave",j=Q(L,C),W=Q(k,C);if(j&&(d=!0,!F))return;if(W&&(d=!1,!F)){d=!0;return}if(F&&Z(o.relatedTarget)&&Q(L,o.relatedTarget))return;function _(){return!!(u&&Pe(u.nodesRef.current,c).length>0)}function G(){_()||P()}if(_())return;const O=k.getBoundingClientRect(),i=L.getBoundingClientRect(),I=r>i.right-i.width/2,h=s>i.bottom-i.height/2,M=i.width>O.width,E=i.height>O.height,q=(M?O:i).left,U=(M?O:i).right,v=(E?O:i).top,V=(E?O:i).bottom;if(f==="top"&&s>=O.bottom-1||f==="bottom"&&s<=O.top+1||f==="left"&&r>=O.right-1||f==="right"&&r<=O.left+1){G();return}let D=!1;switch(f){case"top":D=ae(b,m,q,O.top+1,U,i.bottom-1);break;case"bottom":D=ae(b,m,q,i.top+1,U,O.bottom-1);break;case"left":D=ae(b,m,i.right-1,V,O.left+1,v);break;case"right":D=ae(b,m,O.right-1,V,i.left+1,v);break}if(D)return;if(d&&!Zt(b,m,O)){G();return}if(!F&&A(b,m)){G();return}let w=!1;switch(f){case"top":{const p=M?y/2:y*4,H=M||I?r+p:r-p,Y=M?r-p:I?r+p:r-p,K=s+y+1,$=I||M?i.bottom-y:i.top,ee=I?M?i.bottom-y:i.top:i.bottom-y;w=ie(b,m,H,K,Y,K,i.left,$,i.right,ee);break}case"bottom":{const p=M?y/2:y*4,H=M||I?r+p:r-p,Y=M?r-p:I?r+p:r-p,K=s-y,$=I||M?i.top+y:i.bottom,ee=I?M?i.top+y:i.bottom:i.top+y;w=ie(b,m,H,K,Y,K,i.left,$,i.right,ee);break}case"left":{const p=E?y/2:y*4,H=E||h?s+p:s-p,Y=E?s-p:h?s+p:s-p,K=r+y+1,$=h||E?i.right-y:i.left,ee=h?E?i.right-y:i.left:i.right-y;w=ie(b,m,$,i.top,ee,i.bottom,K,H,K,Y);break}case"right":{const p=E?y/2:y*4,H=E||h?s+p:s-p,Y=E?s-p:h?s+p:s-p,K=r-y,$=h||E?i.left+y:i.right,ee=h?E?i.left+y:i.right:i.left+y;w=ie(b,m,K,H,K,Y,$,i.top,ee,i.bottom);break}}w?d||t.start(40,G):G()}};return a.__options={...e,blockPointerEvents:n},a}const De=S.createContext(void 0);function se(e){const n=S.useContext(De);if(n===void 0&&!e)throw new Error(de(47));return n}const tn={...pt,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};class nn extends qe{constructor(n,t,a){const r=new Tt;super(on(n,r,t,a),sn(r),tn)}setOpen=(n,t)=>{const a=t.reason===z,r=t.reason===he&&t.event.detail===0,s=!n&&(t.reason===Qe||t.reason==null),T=ht(t),g=this.select("activeTriggerId");if(!n&&t.reason===ze&&t.trigger==null&&g!=null&&(t.trigger=this.context.triggerElements.getById(g)??this.select("activeTriggerElement")??void 0),this.context.onOpenChange?.(n,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(n,t);const R=()=>{const u=Et(this.state,n,t.trigger,T());u.openChangeReason=t.reason,this.update(u)};a?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start($e,()=>{this.set("stickIfOpen",!1)}),le.flushSync(R)):R();let c;r?c="click":s?c="dismiss":t.reason===Ee&&(c="focus"),this.set("instantType",c)}}function on(e,n,t,a=!1){const r={...gt(n,t,a),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return r.open&&e?.mounted===void 0&&(r.mounted=!0),r}function sn(e){return{popupRef:S.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:S.createRef(),beforeContentFocusGuardRef:S.createRef(),stickIfOpenTimeout:new ce,triggerElements:e}}const xe=Je(function({props:n}){const{children:t,open:a,defaultOpen:r=!1,onOpenChange:s,onOpenChangeComplete:T,modal:g=!1,handle:R,triggerId:c,defaultTriggerId:u=null}=n,f=rn(R,{modal:g,open:r,openProp:a,activeTriggerId:u,triggerIdProp:c});f.useControlledProp("openProp",a),f.useControlledProp("triggerIdProp",c);const d=f.useState("open"),N=f.useState("mounted"),B=f.useState("payload");f.useContextCallback("onOpenChange",s),f.useContextCallback("onOpenChangeComplete",T),vt(f,d),Ct(f);const{forceUnmount:l}=St(d,f,()=>{f.update({stickIfOpen:!0,openChangeReason:null})});f.useSyncedValues({modal:g}),S.useEffect(()=>{d||f.context.stickIfOpenTimeout.clear()},[f,d]),S.useImperativeHandle(n.actionsRef,()=>({unmount:l,close:()=>f.setOpen(!1,J(Ze))}),[l,f]);const A=d||N;return X.jsxs(De.Provider,{value:f,children:[R&&X.jsx(bt,{handle:R,store:f}),A&&X.jsx(an,{store:f,modal:g}),typeof t=="function"?t({payload:B}):t]})});function Tn(e){return se(!0)?X.jsx(xe,{props:e}):X.jsx(Pt,{children:X.jsx(xe,{props:e})})}function rn(e,n){const t=Rt((a,r)=>new nn(n,a,r));return S.useEffect(()=>t.context.stickIfOpenTimeout.disposeEffect(),[t]),t}function an({store:e,modal:n}){const t=e.useState("floatingRootContext"),a=Ot(t,{outsidePressEvent:{mouse:n==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),r=a.reference,s=a.floating;return It(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:s}),null}const cn=300;function ln(e,n){const t=S.useRef(null);function a(s){le.flushSync(()=>{e.setOpen(!1,J(Ee,s.nativeEvent,s.currentTarget))}),ot(t.current)?.focus()}function r(s){const T=e.select("positionerElement");if(T&&et(s,T))e.context.beforeContentFocusGuardRef.current?.focus();else{le.flushSync(()=>{e.setOpen(!1,J(Ee,s.nativeEvent,s.currentTarget))});let g=tt(e.context.triggerFocusTargetRef.current||n.current);for(;g!==null&&Q(T,g);){const R=g;if(g=nt(g),g===R)break}g?.focus()}}return{preFocusGuardRef:t,handlePreFocusGuardFocus:a,handleFocusTargetFocus:r}}const Pn=st(function(n,t){const{render:a,className:r,style:s,disabled:T=!1,nativeButton:g=!0,handle:R,payload:c,openOnHover:u=!1,delay:f=cn,closeDelay:d=0,id:N,...B}=n,l=se(!0),P=qt(R)??l;if(!P)throw new Error(de(74));const x=Mt(N),o=P.useState("isTriggerActive",x),k=P.useState("floatingRootContext"),L=P.useState("isOpenedByTrigger",x),b=P.useState("triggerPopupId",x),m=S.useRef(null),{registerTrigger:C,isMountedByThisTrigger:F}=yt(x,m,P,{payload:c,disabled:T,openOnHover:u,closeDelay:d}),j=P.useState("openChangeReason"),W=P.useState("stickIfOpen"),_=P.useState("openMethod"),G=P.useState("focusManagerModal"),O=$t(k,{enabled:!T&&u&&(_!=="touch"||j!==he),mouseOnly:!0,move:!1,handleClose:en(),restMs:f,delay:{close:d},triggerElementRef:m,isActiveTrigger:o,isClosing:()=>P.select("transitionStatus")==="ending"}),i=jt(k,{stickIfOpen:W}),I=_t(()=>P.select("open"),H=>{P.set("openMethod",H)}),h=P.useState("triggerProps",F),{getButtonProps:M,buttonRef:E}=rt({disabled:T,native:g}),q={open(H){return H&&j===he?xt.open(H):Ft.open(H)}},{preFocusGuardRef:U,handlePreFocusGuardFocus:v,handleFocusTargetFocus:V}=ln(P,m),w=ke("button",n,{state:{disabled:T,open:L},ref:[E,t,C,m],props:[i.reference,O,h,I,{[it]:"",id:x,"aria-haspopup":"dialog","aria-expanded":L,"aria-controls":b},B,M],stateAttributesMapping:q}),p=X.jsx(S.Fragment,{children:w},x);return F&&!G?X.jsxs(S.Fragment,{children:[X.jsx(Ie,{ref:U,onFocus:v}),p,X.jsx(Ie,{ref:P.context.triggerFocusTargetRef,onFocus:V})]}):p}),Be=S.createContext(void 0);function un(){const e=S.useContext(Be);if(e===void 0)throw new Error(de(45));return e}const vn=S.forwardRef(function(n,t){const{keepMounted:a=!1,...r}=n;return se().useState("mounted")||a?X.jsx(Be.Provider,{value:a,children:X.jsx(at,{ref:t,...r})}):null}),Ne=S.createContext(void 0);function fn(){const e=S.useContext(Ne);if(!e)throw new Error(de(46));return e}const Cn=S.forwardRef(function(n,t){const{render:a,className:r,style:s,anchor:T,positionMethod:g,side:R,align:c,sideOffset:u,alignOffset:f,collisionBoundary:d="clipping-ancestors",collisionPadding:N,arrowPadding:B,sticky:l,disableAnchorTracking:A=!1,collisionAvoidance:P=ct,...x}=n,o=se(),k=un(),L=kt(),b=o.useState("floatingRootContext"),m=o.useState("mounted"),C=o.useState("open"),F=o.useState("openChangeReason"),j=o.useState("activeTriggerElement"),W=o.useState("modal"),_=o.useState("openMethod"),G=o.useState("positionerElement"),O=o.useState("instantType"),i=o.useState("transitionStatus"),I=o.useState("adaptiveOrigin"),h=S.useRef(null),M=lt(G),E=Gt({anchor:T,floatingRootContext:b,positionMethod:g,mounted:m,side:R,sideOffset:u,align:c,alignOffset:f,arrowPadding:B,collisionBoundary:d,collisionPadding:N,sticky:l,disableAnchorTracking:A,keepMounted:k,nodeId:L,collisionAvoidance:P,adaptiveOrigin:I}),q=b.useState("domReferenceElement");pe(()=>{const w=q,p=h.current;if(w&&(h.current=w),p&&w&&w!==p){o.set("instantType",void 0);const H=new AbortController;return M(()=>{o.set("instantType","trigger-change")},H.signal),()=>{H.abort()}}},[q,M,o]);const U=W===!0&&F!==z;Yt(C&&U,_==="touch",G,j);const v=o.useStateSetter("positionerElement"),V={open:C,side:E.side,align:E.align,anchorHidden:E.anchorHidden,instant:O},D=Xt(n,V,{styles:E.positionerStyles,transitionStatus:i,props:x,refs:[t,v],hidden:!m,inert:!C});return X.jsxs(Ne.Provider,{value:E,children:[m&&U&&X.jsx(wt,{inert:ut(!C),cutout:j}),X.jsx(Ht,{id:L,children:D})]})}),dn=S.createContext(void 0);function pn(){const[e,n]=S.useState(0),t=ne(()=>(n(r=>r+1),()=>{n(r=>Math.max(0,r-1))}));return{context:S.useMemo(()=>({register:t}),[t]),hasClosePart:e>0}}const Sn=S.forwardRef(function(n,t){const{render:a,className:r,style:s,initialFocus:T,finalFocus:g,...R}=n,c=se(),u=fn(),f=Ut()!=null,{context:d,hasClosePart:N}=pn(),B=c.useState("open"),l=c.useState("openMethod"),A=c.useState("instantType"),P=c.useState("transitionStatus"),x=c.useState("popupProps"),o=c.useState("titleElementId"),k=c.useState("descriptionElementId"),L=c.useState("modal"),b=c.useState("mounted"),m=c.useState("openChangeReason"),C=c.useState("activeTriggerElement"),F=c.useState("floatingRootContext"),j=F.useState("floatingId"),W=c.useState("disabled"),_=c.useState("openOnHover"),G=c.useState("closeDelay");ft({open:B,ref:c.context.popupRef,onComplete(){B&&c.context.onOpenChangeComplete?.(!0)}}),Qt(F,{enabled:_&&!W,closeDelay:G});const O=T===void 0?Lt(c.context.popupRef):T,i=L!==!1&&N;c.useSyncedValue("focusManagerModal",i);const I=c.useStateSetter("popupElement"),h={open:B,side:u.side,align:u.align,instant:A,transitionStatus:P},M=ke("div",n,{state:h,ref:[t,c.context.popupRef,I],props:[x,{id:j,role:"dialog",...Dt,"aria-labelledby":o,"aria-describedby":k,onKeyDown(E){f&&Bt.has(E.key)&&E.stopPropagation()}},Vt(P),R],stateAttributesMapping:Nt});return X.jsx(At,{context:F,openInteractionType:l,modal:i,disabled:!b||m===z,initialFocus:O,returnFocus:g,restoreFocus:"popup",previousFocusableElement:dt(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:X.jsx(dn.Provider,{value:d,children:M})})});export{Tn as P,Pn as a,vn as b,Cn as c,Sn as d};