tokentracker-cli 0.83.1 → 0.83.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dashboard/dist/assets/{AchievementBadge-tMxPvIPA.js → AchievementBadge-BrSr5pjk.js} +1 -1
  2. package/dashboard/dist/assets/AchievementsPage-za-wqAO2.js +2 -0
  3. package/dashboard/dist/assets/AchievementsSection-CGRVm1uS.js +1 -0
  4. package/dashboard/dist/assets/BadgeDetailModal-D1XDT2dG.js +1 -0
  5. package/dashboard/dist/assets/{Card-D479hjUR.js → Card-DX2Wwm9U.js} +1 -1
  6. package/dashboard/dist/assets/{ClawdAnimated-ChoWfPva.js → ClawdAnimated-D6JzFu8y.js} +1 -1
  7. package/dashboard/dist/assets/CommandPalette-NWiETwtS.js +1 -0
  8. package/dashboard/dist/assets/CommunityStatsModal-D4FdxAWd.js +1 -0
  9. package/dashboard/dist/assets/{ConfirmModal-CCFe2duP.js → ConfirmModal-SAheZUAv.js} +1 -1
  10. package/dashboard/dist/assets/DashboardPage-CjnBsm3Q.js +1 -0
  11. package/dashboard/dist/assets/{DevicePage-Bk9mryIp.js → DevicePage-Cf-PHRlL.js} +1 -1
  12. package/dashboard/dist/assets/DialogClose-pg5pVOeD.js +1 -0
  13. package/dashboard/dist/assets/DialogDescription-CVuGFYFU.js +1 -0
  14. package/dashboard/dist/assets/{DialogTitle-vIrqSKer.js → DialogTitle-Im7ESzoS.js} +1 -1
  15. package/dashboard/dist/assets/FadeIn-CGGFraHR.js +1 -0
  16. package/dashboard/dist/assets/{HeaderGithubStar-CFt_WMjW.js → HeaderGithubStar-DRTZXRsx.js} +1 -1
  17. package/dashboard/dist/assets/{IpCheckPage-CSWXPm3B.js → IpCheckPage-Dn62HUZu.js} +1 -1
  18. package/dashboard/dist/assets/LandingPage-CLsljoir.js +2 -0
  19. package/dashboard/dist/assets/{LeaderboardAvatar-CQkIM_Gb.js → LeaderboardAvatar-DktI_89h.js} +1 -1
  20. package/dashboard/dist/assets/LeaderboardPage-t87ElnDI.js +2 -0
  21. package/dashboard/dist/assets/{LeaderboardProfileModal-DRPXqVvC.js → LeaderboardProfileModal-DN7HurS3.js} +4 -4
  22. package/dashboard/dist/assets/{LeaderboardProfilePage-Bef_4_ug.js → LeaderboardProfilePage-CprOXLXX.js} +3 -3
  23. package/dashboard/dist/assets/{LimitsPage-bSZCJNkv.js → LimitsPage-DRX3XMYx.js} +3 -3
  24. package/dashboard/dist/assets/{LocalOnlyNotice-CIEE7t0-.js → LocalOnlyNotice-B8BtIdAA.js} +1 -1
  25. package/dashboard/dist/assets/LoginCard-OoduGJmK.js +1 -0
  26. package/dashboard/dist/assets/LoginModal-DoDoCpr6.js +1 -0
  27. package/dashboard/dist/assets/LoginPage-Dn2KMisI.js +1 -0
  28. package/dashboard/dist/assets/PetPage-CVaG5H3O.js +1 -0
  29. package/dashboard/dist/assets/PopoverPopup-B2HqJNaq.js +1 -0
  30. package/dashboard/dist/assets/ProviderIcon-BYl1Yyf3.js +1 -0
  31. package/dashboard/dist/assets/ResetPasswordPage-DWfgvuvR.js +1 -0
  32. package/dashboard/dist/assets/{Select-Ch5kjPZu.js → Select-ClnnGJY1.js} +1 -1
  33. package/dashboard/dist/assets/SelectItemText-iaFWq7GD.js +1 -0
  34. package/dashboard/dist/assets/SettingsPage-zwAOWRur.js +1 -0
  35. package/dashboard/dist/assets/SkillsPage-BB96nB2i.js +1 -0
  36. package/dashboard/dist/assets/TokenGalaxy-9_VJKdPr.js +4314 -0
  37. package/dashboard/dist/assets/TrendMonitor-D9RHcQgH.js +19 -0
  38. package/dashboard/dist/assets/WidgetsPage-CjAT6p0C.js +1 -0
  39. package/dashboard/dist/assets/{WrappedPage-CPAtRfkp.js → WrappedPage-ba6teG1N.js} +1 -1
  40. package/dashboard/dist/assets/__vite-browser-external-DWKjPxnU.js +1350 -0
  41. package/dashboard/dist/assets/__vite-browser-external-D_0JUhT7.css +1 -0
  42. package/dashboard/dist/assets/agent-logos-HCzl7U8i.js +1 -0
  43. package/dashboard/dist/assets/{arrow-up-right-Bm0oL1jH.js → arrow-up-right-TvEj8NTT.js} +1 -1
  44. package/dashboard/dist/assets/{check-DR7E_A1J.js → check-Cz3lYRiR.js} +1 -1
  45. package/dashboard/dist/assets/{copy-BtstNk2s.js → copy-CTtF84H9.js} +1 -1
  46. package/dashboard/dist/assets/{download-zOVMvQXI.js → download-B5WAY6Nh.js} +1 -1
  47. package/dashboard/dist/assets/{flame-DQaixlOI.js → flame-Cja4F8Mj.js} +1 -1
  48. package/dashboard/dist/assets/{format-tokens-Cbac-ZGw.js → format-tokens-UavRPN4W.js} +1 -1
  49. package/dashboard/dist/assets/{icons-iL7TjE7A.js → icons-BW2vjmu_.js} +1 -1
  50. package/dashboard/dist/assets/index-0w19KMWl.js +9 -0
  51. package/dashboard/dist/assets/index-Bfxr6erc.js +1 -0
  52. package/dashboard/dist/assets/index-BnzrUY9J.js +1 -0
  53. package/dashboard/dist/assets/{info-BtnxfCu0.js → info-F-75j15K.js} +1 -1
  54. package/dashboard/dist/assets/{limits-providers-DkoPB8B2.js → limits-providers-8NsMiLNP.js} +1 -1
  55. package/dashboard/dist/assets/{link-2-Bh0vUBU6.js → link-2-C_eJlLvb.js} +1 -1
  56. package/dashboard/dist/assets/{loader-circle-BVF4Sglg.js → loader-circle-BjzQhjhO.js} +1 -1
  57. package/dashboard/dist/assets/module-kH5GsDis.js +2 -0
  58. package/dashboard/dist/assets/provider-display-D1zp03ID.js +42 -0
  59. package/dashboard/dist/assets/react-Nv3-bJyw.js +1 -0
  60. package/dashboard/dist/assets/skills-api-DazKXxME.js +1 -0
  61. package/dashboard/dist/assets/{terminal-BUoPNPs5.js → terminal-DBXjwlTm.js} +1 -1
  62. package/dashboard/dist/assets/{trash-2-DrGpFJsR.js → trash-2-DLG8hKJm.js} +1 -1
  63. package/dashboard/dist/assets/{use-community-stats-D6Kxm_DN.js → use-community-stats-BQB72xAN.js} +1 -1
  64. package/dashboard/dist/assets/{use-limits-display-prefs-BCh-4-Bo.js → use-limits-display-prefs-CH8MmjYf.js} +1 -1
  65. package/dashboard/dist/assets/{use-native-settings-o-TL7MGQ.js → use-native-settings-__RhxrW5.js} +1 -1
  66. package/dashboard/dist/assets/{use-ordered-list-sMvpJjOK.js → use-ordered-list-AhnqpdnT.js} +1 -1
  67. package/dashboard/dist/assets/use-reduced-motion-CA2IXeeO.js +1 -0
  68. package/dashboard/dist/assets/{use-session-efficiency-pref-BsG2CJqB.js → use-session-efficiency-pref-CCYtJ_cN.js} +1 -1
  69. package/dashboard/dist/assets/use-transform-BhcppNI4.js +1 -0
  70. package/dashboard/dist/assets/{use-usage-limits-DVhgZkTD.js → use-usage-limits-CbA095lv.js} +1 -1
  71. package/dashboard/dist/assets/{useCurrency-DqxQMZty.js → useCurrency-Dt2GqkDm.js} +1 -1
  72. package/dashboard/dist/assets/{useScrollLock-DZpDnNt6.js → useScrollLock-C5d53j7C.js} +1 -1
  73. package/dashboard/dist/assets/{useTokenFormat-CdYh0d_c.js → useTokenFormat-dnqZK7Z-.js} +1 -1
  74. package/dashboard/dist/assets/{zap-9gvAtu1o.js → zap-Bw5OO91s.js} +1 -1
  75. package/dashboard/dist/index.html +2 -2
  76. package/dashboard/dist/share.html +2 -2
  77. package/package.json +1 -1
  78. package/src/commands/serve.js +21 -4
  79. package/src/commands/sync.js +142 -73
  80. package/src/lib/cursor-store.js +52 -2
  81. package/src/lib/local-api.js +143 -35
  82. package/src/lib/pricing/seed-snapshot.json +1 -1
  83. package/src/lib/runtime-config.js +19 -1
  84. package/dashboard/dist/assets/AchievementsPage-qqu8DWOa.js +0 -2
  85. package/dashboard/dist/assets/AchievementsSection-iRzgGWeO.js +0 -1
  86. package/dashboard/dist/assets/BadgeDetailModal-D3lYNgOJ.js +0 -1
  87. package/dashboard/dist/assets/CommunityStatsModal-CR-VAT3e.js +0 -1
  88. package/dashboard/dist/assets/DashboardPage-DGzKf5-y.js +0 -1
  89. package/dashboard/dist/assets/DialogClose-8Fw7R9Ma.js +0 -1
  90. package/dashboard/dist/assets/DialogDescription-DDeAH6I9.js +0 -1
  91. package/dashboard/dist/assets/FadeIn-DdYC9vT8.js +0 -1
  92. package/dashboard/dist/assets/LandingPage-D7WEaged.js +0 -4314
  93. package/dashboard/dist/assets/LeaderboardPage-nRXBc0bw.js +0 -2
  94. package/dashboard/dist/assets/LoginPage-2c5mYQJ1.js +0 -1
  95. package/dashboard/dist/assets/PetPage-BMi50Olg.js +0 -1
  96. package/dashboard/dist/assets/PopoverPopup-ByOC1OEv.js +0 -1
  97. package/dashboard/dist/assets/ResetPasswordPage-CNeptbJw.js +0 -1
  98. package/dashboard/dist/assets/SelectItemText-D4laqPg3.js +0 -1
  99. package/dashboard/dist/assets/SettingsPage-DlFD5hy9.js +0 -1
  100. package/dashboard/dist/assets/SkillsPage-ChdsShAm.js +0 -1
  101. package/dashboard/dist/assets/TrendMonitor-ueTTQIih.js +0 -19
  102. package/dashboard/dist/assets/WidgetsPage-a6S6gqVf.js +0 -1
  103. package/dashboard/dist/assets/__vite-browser-external-C44tPAD-.css +0 -1
  104. package/dashboard/dist/assets/__vite-browser-external-Djkun5S2.js +0 -1354
  105. package/dashboard/dist/assets/agent-logos-CwuIej9M.js +0 -1
  106. package/dashboard/dist/assets/provider-display-BgCflQrF.js +0 -42
  107. package/dashboard/dist/assets/use-transform-Bjy8uQ3M.js +0 -1
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LeaderboardProfileModal-DRPXqVvC.js","assets/__vite-browser-external-Djkun5S2.js","assets/__vite-browser-external-C44tPAD-.css","assets/provider-display-BgCflQrF.js","assets/useCurrency-DqxQMZty.js","assets/useTokenFormat-CdYh0d_c.js","assets/terminal-BUoPNPs5.js","assets/info-BtnxfCu0.js","assets/LeaderboardAvatar-CQkIM_Gb.js","assets/AchievementBadge-tMxPvIPA.js","assets/zap-9gvAtu1o.js","assets/flame-DQaixlOI.js","assets/AchievementsSection-iRzgGWeO.js","assets/format-tokens-Cbac-ZGw.js","assets/arrow-up-right-Bm0oL1jH.js","assets/link-2-Bh0vUBU6.js","assets/check-DR7E_A1J.js","assets/DialogTitle-vIrqSKer.js","assets/useScrollLock-DZpDnNt6.js","assets/CommunityStatsModal-CR-VAT3e.js","assets/icons-iL7TjE7A.js","assets/TrendMonitor-ueTTQIih.js","assets/PopoverPopup-ByOC1OEv.js","assets/SelectItemText-D4laqPg3.js","assets/DialogDescription-DDeAH6I9.js","assets/DialogClose-8Fw7R9Ma.js"])))=>i.map(i=>d[i]);
2
- import{k as ma,j as e,R as ua,c as n,b as d,r as c,au as xa,u as ga,Y as ba,e as pa,av as ha,I as fa,aw as ya,ax as ka,ay as Ie,az as wa,aA as se,g as va,aB as ja,x as Na,P as pe,L as _a,aC as Sa,i as Ca,aD as Ea,aE as La,ab as Aa,_ as Fe,v as Ma}from"./__vite-browser-external-Djkun5S2.js";import{S as Ta}from"./Select-Ch5kjPZu.js";import{u as Pa,C as Ka,a as Ra,b as za,c as Be,D as Ia,d as Ba,S as $a,h as Da,s as Ua,K as Oa,P as Fa}from"./use-ordered-list-sMvpJjOK.js";import{u as Ga}from"./useCurrency-DqxQMZty.js";import{u as X}from"./useTokenFormat-CdYh0d_c.js";import{L as Z}from"./LeaderboardAvatar-CQkIM_Gb.js";import{s as Ha,c as Ya,A as Wa,t as Va,b as Ja}from"./AchievementBadge-tMxPvIPA.js";import{u as Za}from"./use-community-stats-D6Kxm_DN.js";import"./SelectItemText-D4laqPg3.js";import"./useScrollLock-DZpDnNt6.js";import"./check-DR7E_A1J.js";import"./zap-9gvAtu1o.js";import"./flame-DQaixlOI.js";const qa=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Xa=ma("arrow-right",qa),Qa=a=>{let{transform:r}=a;return{...r,y:0}};function H(a,{min:r,max:o,fallback:s}){const l=Number(a);if(!Number.isFinite(l))return s;const i=Math.floor(l);return i<r?r:i>o?o:i}function er(a,r){const o=H(r,{min:0,max:1e6,fallback:0}),s=H(a,{min:1,max:Math.max(1,o||1),fallback:1});if(o<=1)return[1];const l=new Set([1,o,s-2,s-1,s,s+1,s+2]),i=Array.from(l).filter(x=>Number.isInteger(x)&&x>=1&&x<=o).sort((x,p)=>x-p),m=[];let b=null;for(const x of i)b!=null&&x-b>1&&m.push(null),m.push(x),b=x;return m}function ar({page:a,totalPages:r}){const o=typeof r=="number"&&Number.isFinite(r)&&r>=0,s=o?H(r,{min:0,max:1e6,fallback:0}):null,l=H(a,{min:1,max:o?Math.max(1,s||1):1e6,fallback:1}),i=l>1,m=o?l<s:!0;return{canPrev:i,canNext:m,safePage:l,safeTotal:s}}function rr({entries:a,me:r,meLabel:o}){const s=Array.isArray(a)?a:[],l=r&&typeof r.rank=="number"?r.rank:null;return!l||s.some(m=>!!m?.is_me)?s:[{rank:l,is_me:!0,is_pinned:!0,user_id:r?.user_id??null,display_name:o,avatar_url:r?.avatar_url??null,github_url:null,is_public:!1,gpt_tokens:r?.gpt_tokens??"0",claude_tokens:r?.claude_tokens??"0",gemini_tokens:r?.gemini_tokens??"0",cursor_tokens:r?.cursor_tokens??"0",opencode_tokens:r?.opencode_tokens??"0",openclaw_tokens:r?.openclaw_tokens??"0",hermes_tokens:r?.hermes_tokens??"0",kiro_tokens:r?.kiro_tokens??"0",copilot_tokens:r?.copilot_tokens??"0",kimi_tokens:r?.kimi_tokens??"0",other_tokens:r?.other_tokens??"0",total_tokens:r?.total_tokens??"0",estimated_cost_usd:r?.estimated_cost_usd??null,badges:Array.isArray(r?.badges)?r.badges:[]},...s]}function tr(a,r){const o=Number(a),s=Number(r);return!Number.isFinite(o)||o<1||!Number.isFinite(s)||s<1?null:Math.ceil(o/s)}const or=new Set(["/brand-logos/cursor.svg","/brand-logos/kimi.svg","/brand-logos/kiro.svg","/brand-logos/copilot.svg","/brand-logos/hermes.svg"]);function sr({iconSrc:a,label:r}){return e.jsxs("span",{className:"inline-flex items-center gap-3",children:[a?e.jsx("img",{src:a,alt:"",width:16,height:16,className:`h-4 w-4 shrink-0 object-contain opacity-90 ${or.has(a)?"dark:invert":""}`}):null,e.jsx("span",{className:"whitespace-nowrap",children:r})]})}const ne=ua.memo(function({badges:r,max:o=3,className:s=""}){const l=Ha((r||[]).filter(i=>i&&Ya.has(i.id)&&(i.tier||0)>=1)).slice(0,o);return l.length===0?null:e.jsx("span",{className:`pointer-events-none inline-flex shrink-0 items-center ${s}`,children:l.map((i,m)=>e.jsx("span",{title:n("achievements.mini.tooltip",{name:n(Ja(i.id,"name")),tier:n(`achievements.tier.${Va(i.tier)}`)}),style:{zIndex:l.length-m},className:`pointer-events-auto relative inline-flex ${m>0?"-ml-1.5":""}`,children:e.jsx(Wa,{badgeId:i.id,tier:i.tier,size:"xs",className:"rounded-full ring-[1.5px] ring-white dark:ring-oai-gray-950"})},i.id))})}),q=[{key:"gpt_tokens",copyKey:"leaderboard.column.codex",icon:"/brand-logos/codex.svg"},{key:"claude_tokens",copyKey:"leaderboard.column.claude",icon:"/brand-logos/claude-code.svg"},{key:"gemini_tokens",copyKey:"leaderboard.column.gemini",icon:"/brand-logos/gemini.svg"},{key:"cursor_tokens",copyKey:"leaderboard.column.cursor",icon:"/brand-logos/cursor.svg"},{key:"kiro_tokens",copyKey:"leaderboard.column.kiro",icon:"/brand-logos/kiro.svg"},{key:"copilot_tokens",copyKey:"leaderboard.column.copilot",icon:"/brand-logos/copilot.svg"},{key:"kimi_tokens",copyKey:"leaderboard.column.kimi",icon:"/brand-logos/kimi.svg"},{key:"opencode_tokens",copyKey:"leaderboard.column.opencode",icon:"/brand-logos/opencode.svg"},{key:"openclaw_tokens",copyKey:"leaderboard.column.openclaw",icon:"/brand-logos/openclaw.svg"},{key:"hermes_tokens",copyKey:"leaderboard.column.hermes",icon:"/brand-logos/hermes.svg"},{key:"other_tokens",copyKey:"leaderboard.column.supplemental",icon:null}],Ge="sticky left-0 z-40 w-14 min-w-14 max-w-14 sm:w-[72px] sm:min-w-[72px] sm:max-w-[72px] bg-white dark:bg-oai-gray-950 px-2.5 sm:px-4 py-4 align-middle",He="sticky left-[55px] sm:left-[71px] z-40 min-w-[96px] sm:min-w-[200px] max-w-[170px] sm:max-w-[min(260px,45vw)] border-l border-r border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-950 px-3 sm:px-4 py-4 align-middle";function ie(a){return d("sticky left-0 z-30 w-14 min-w-14 max-w-14 sm:w-[72px] sm:min-w-[72px] sm:max-w-[72px] px-2.5 sm:px-4 py-4 whitespace-nowrap",a?"bg-oai-brand-50 dark:bg-emerald-950":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900")}function le(a){return d("sticky left-[55px] sm:left-[71px] z-30 hover:z-50 min-w-[96px] sm:min-w-[200px] max-w-[170px] sm:max-w-[min(260px,45vw)] border-l border-r border-oai-gray-200 dark:border-oai-gray-800 px-3 sm:px-4 py-4 min-w-0",a?"bg-oai-brand-50 dark:bg-emerald-950":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900")}function y({className:a}){return e.jsx("div",{className:d("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",a)})}function nr({index:a}){const r=a<3?"w-24":a<8?"w-20":"w-16",o=a<3?"w-16":"w-12",s=a<5?"w-14":"w-10";return e.jsxs("tr",{className:"group",children:[e.jsx("td",{className:d(ie(!1),"!group-hover:bg-transparent"),children:e.jsx(y,{className:"h-4 w-6"})}),e.jsx("td",{className:d(le(!1),"!group-hover:bg-transparent"),children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(y,{className:"h-8 w-8 min-w-8 rounded-full"}),e.jsx(y,{className:d("h-4",r)})]})}),e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(y,{className:d("h-4",o)})}),e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(y,{className:"h-4 w-12"})}),q.map(l=>e.jsx("td",{className:"px-4 py-4 bg-white dark:bg-oai-gray-950",children:e.jsx(y,{className:d("h-4",s)})},l.key))]})}function ir({index:a}){const r=a<3?"w-24":a<8?"w-20":"w-16",o=a%3===0?3:a%3===1?2:1;return e.jsxs("div",{className:"mx-0 my-1 rounded-xl bg-white dark:bg-oai-gray-950 border border-oai-gray-100 dark:border-oai-gray-800/60 px-3.5 py-3 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(y,{className:"h-4 w-3 shrink-0 rounded"}),e.jsx(y,{className:"h-9 w-9 shrink-0 rounded-full"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(y,{className:d("h-4",r)}),e.jsx(y,{className:"mt-2 h-3.5 w-20"})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx(y,{className:"ml-auto h-3 w-8"}),e.jsx(y,{className:"mt-1.5 ml-auto h-4 w-14"})]})]}),e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-2 border-t border-oai-gray-100 pt-2.5 dark:border-oai-gray-800/70",children:Array.from({length:o},(s,l)=>e.jsx(y,{className:"h-5 w-12 rounded-full"},l))})]})}function lr({rows:a=10}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden w-full overflow-x-auto sm:block",children:e.jsxs("table",{className:"min-w-max w-full text-left text-sm",children:[e.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:d(Ge,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(y,{className:"h-3.5 w-6"})}),e.jsx("th",{className:d(He,"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(y,{className:"h-3.5 w-12"})}),e.jsx("th",{className:"px-4 py-4",children:e.jsx(y,{className:"h-3.5 w-10"})}),e.jsx("th",{className:"px-4 py-4",children:e.jsx(y,{className:"h-3.5 w-14"})}),q.map(r=>e.jsx("th",{className:"px-4 py-4",children:e.jsx(y,{className:"h-3.5 w-12"})},r.key))]})}),e.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:Array.from({length:a},(r,o)=>e.jsx(nr,{index:o},o))})]})}),e.jsx("div",{className:"flex flex-col py-1 sm:hidden",children:Array.from({length:a},(r,o)=>e.jsx(ir,{index:o},o))})]})}function dr({id:a,thClassName:r,children:o}){const{attributes:s,listeners:l,setNodeRef:i,transform:m,transition:b,isDragging:x}=Pa({id:a}),p=Ka.Transform.toString(m)||"";c.useLayoutEffect(()=>{const f=document.querySelectorAll(`td[data-column-key="${a}"]`),h="0 2px 10px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06)";return f.forEach(g=>{g.style.transform=p,g.style.transition=b||"",g.style.zIndex=x?"20":"",g.style.position=p?"relative":"",g.style.boxShadow=x?h:""}),()=>{f.forEach(g=>{g.style.transform="",g.style.transition="",g.style.zIndex="",g.style.position="",g.style.boxShadow=""})}},[a,p,b,x]);const v={transform:p,transition:b,position:p?"relative":void 0,zIndex:x?20:void 0,boxShadow:x?"0 2px 10px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06)":void 0};return e.jsx("th",{ref:i,style:v,className:d(r,"group/col select-none cursor-grab active:cursor-grabbing touch-none"),...s,...l,children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("span",{"aria-hidden":"true",className:d("-mr-1 inline-flex h-4 w-3 shrink-0 items-center justify-center text-oai-gray-400 dark:text-oai-gray-600","opacity-0 transition-opacity duration-150 group-hover/col:opacity-100",x&&"opacity-100"),children:e.jsxs("svg",{viewBox:"0 0 8 14",width:"8",height:"14",fill:"currentColor","aria-hidden":"true",children:[e.jsx("circle",{cx:"2",cy:"2",r:"1"}),e.jsx("circle",{cx:"6",cy:"2",r:"1"}),e.jsx("circle",{cx:"2",cy:"7",r:"1"}),e.jsx("circle",{cx:"6",cy:"7",r:"1"}),e.jsx("circle",{cx:"2",cy:"12",r:"1"}),e.jsx("circle",{cx:"6",cy:"12",r:"1"})]})}),o]})})}const cr="tokentracker.leaderboard.columnOrder.v1";function mr(a){return Ra(cr,a)}const ur=50;function xr(a,r){const o=Number(a),s=Number(r);return!Number.isFinite(o)||o<1||!Number.isFinite(s)||s<1?null:Math.min(100,Math.max(1,Math.ceil(o/s*100)))}function Ye(a){return typeof a=="string"?a.trim():""}function gr(a){const r=Ye(a);return r?r.toLowerCase()==="anonymous":!0}function br({me:a,totalEntries:r,meLabel:o,onOpenProfile:s,onJumpToMe:l,canJump:i,className:m}){const b=a&&typeof a.rank=="number"?a.rank:null;if(!b)return null;const x=Number(r)||0,p=xr(b,x),v=Ye(a?.display_name),f=!v||gr(v)?o||"You":v,h=a?.user_id||f,g=s||(i?l:null),A=typeof g=="function",C=A?"button":"div",Q=A?{type:"button",onClick:g,"aria-label":n(s?"leaderboard.summary.view_profile":"leaderboard.summary.jump_to_me")}:{};return e.jsxs(C,{...Q,className:d("group inline-flex h-9 items-center gap-2.5 rounded-full border pl-1 pr-3.5 transition-all duration-300 select-none",A?"border-oai-gray-200 hover:border-oai-brand-400 dark:border-oai-gray-800 dark:hover:border-oai-brand-500/80 bg-oai-gray-50/50 dark:bg-white/[0.02] backdrop-blur-md hover:bg-oai-brand-50/40 dark:hover:bg-oai-brand-950/20 active:scale-[0.97] dark:ring-1 dark:ring-white/[0.04] dark:hover:ring-white/[0.08]":"border-oai-gray-100 dark:border-oai-gray-800/60 bg-oai-gray-50/20 dark:bg-white/[0.01] backdrop-blur-sm dark:ring-1 dark:ring-white/[0.02]",m),children:[e.jsx(Z,{size:"sm",avatarUrl:a?.avatar_url,displayName:f,seed:h}),e.jsx("span",{className:"hidden sm:inline max-w-[120px] truncate text-xs font-semibold text-oai-black dark:text-oai-gray-200 group-hover:text-oai-brand-600 dark:group-hover:text-oai-brand-400 transition-colors",children:f}),e.jsxs("span",{className:"text-xs font-bold tabular-nums text-oai-gray-800 dark:text-white",children:["#",b.toLocaleString()]}),p!=null&&p<=ur&&e.jsx("span",{className:d("hidden sm:inline-flex items-center rounded-full px-2 py-0.5 text-[9px] font-extrabold tracking-wider tabular-nums uppercase transition-colors duration-300 ring-1",p<=10?"bg-amber-500/10 text-amber-600 dark:bg-amber-500/15 dark:text-amber-400 ring-amber-500/20":"bg-oai-brand-100/50 text-oai-brand-700 dark:bg-oai-brand-500/10 dark:text-oai-brand-400 ring-oai-brand-500/10"),children:n("leaderboard.summary.percentile",{p:String(p)})}),A?e.jsx(Xa,{"aria-hidden":!0,className:"size-3 text-oai-gray-400 transition-all duration-300 group-hover:text-oai-brand-500 dark:text-oai-gray-500 group-hover:translate-x-0.5 group-hover:scale-110"}):e.jsxs("span",{className:"relative flex h-1.5 w-1.5 shrink-0 items-center justify-center ml-1",title:"You are here",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75 duration-1000"}),e.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-emerald-500"})]})]})}const pr=c.lazy(()=>Fe(()=>import("./LeaderboardProfileModal-DRPXqVvC.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])).then(a=>({default:a.LeaderboardProfileModal}))),hr=c.lazy(()=>Fe(()=>import("./CommunityStatsModal-CR-VAT3e.js"),__vite__mapDeps([19,1,2,20,5,21,4,6,22,18,17,23,9,10,11,24,25])).then(a=>({default:a.CommunityStatsModal}))),de=[10,20,50,100],ce=20,We="tokentracker:leaderboard:pageSize";function fr(){if(typeof window>"u")return ce;try{const a=window.localStorage.getItem(We),r=Number(a);if(de.includes(r))return r}catch{}return ce}function me(a,r,o){const s=Number(a);if(!Number.isFinite(s)||s<=0)return"-";const l=Sa(r),i=r===Ma?s:s*o;return i>=1e3?`${l}${Math.round(i).toLocaleString()}`:i>=10?`${l}${Math.round(i)}`:`${l}${i.toFixed(2)}`}function ue({value:a}){const{formatTokens:r,formatTokensTooltip:o}=X();return e.jsx("span",{title:o(a),children:r(a)})}function yr({communityStats:a,onClick:r}){const{formatTokens:o,formatTokensTooltip:s}=X();return a.status!=="ready"?null:e.jsxs("button",{type:"button",onClick:r,className:"inline-flex min-w-0 max-w-full flex-1 items-center gap-1.5 whitespace-nowrap rounded-xl border border-oai-gray-200 bg-oai-gray-50/50 px-2.5 py-2 text-xs text-oai-gray-500 backdrop-blur-md transition-all duration-300 hover:border-oai-brand-400 hover:bg-oai-brand-50/40 active:scale-[0.97] dark:border-oai-gray-800 dark:bg-white/[0.02] dark:text-oai-gray-400 dark:hover:border-oai-brand-500/80 dark:hover:bg-oai-brand-950/20 sm:h-9 sm:flex-none sm:gap-2.5 sm:rounded-full sm:px-3.5 sm:py-0",title:n("leaderboard.community.view_stats"),children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5 shrink-0","aria-hidden":"true",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-500/80 opacity-75 duration-1000"}),e.jsx("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-semibold text-oai-black dark:text-white tabular-nums",children:e.jsx("span",{title:s(a.tokenFloor),children:o(a.tokenFloor)})}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:n("leaderboard.community.tokens_chip")})]}),e.jsx("span",{className:"text-oai-gray-200 dark:text-oai-gray-800 select-none",children:"·"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsxs("span",{className:"font-semibold text-oai-black dark:text-white tabular-nums",children:[e.jsx("span",{className:"sm:hidden",children:Ca(a.totalEntries)}),e.jsx("span",{className:"hidden sm:inline",children:(Number(a.totalEntries)||0).toLocaleString("en-US")})]}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:n("leaderboard.community.devs_chip")})]})]})}function $e({entry:a,isMe:r,orderedColumns:o}){const{formatTokens:s,formatTokensTooltip:l}=X(),i=r?"text-oai-gray-700 dark:text-oai-gray-300":"text-oai-gray-500 dark:text-oai-gray-400",m=r?"bg-oai-brand-50 dark:bg-oai-brand-900/10":"bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900";return o.map(b=>e.jsx("td",{"data-column-key":b.key,title:l(a?.[b.key]),className:d("hidden sm:table-cell px-3 sm:px-4 py-4 whitespace-nowrap text-right tabular-nums",i,m),children:s(a?.[b.key])},b.key))}function kr(a){return a?.key==="gpt_tokens"?"CODEX":a?.key==="claude_tokens"?"CLAUDE":(a?.icon?.split("/").pop()||"").replace(/\.svg$/i,"").toUpperCase()||"OTHER"}const wr={1:"ring-2 ring-amber-400 dark:ring-amber-500/80 shadow-[0_0_8px_rgba(245,158,11,0.25)]",2:"ring-2 ring-slate-350 dark:ring-slate-450 shadow-[0_0_8px_rgba(148,163,184,0.2)]",3:"ring-2 ring-orange-400 dark:ring-orange-500/70 shadow-[0_0_8px_rgba(249,115,22,0.25)]"};function vr({rank:a,placeholder:r}){return a===1?e.jsx("span",{className:"text-base font-extrabold italic text-amber-500 dark:text-amber-400 tracking-tighter",children:"1"}):a===2?e.jsx("span",{className:"text-base font-extrabold italic text-slate-400 dark:text-slate-350 tracking-tighter",children:"2"}):a===3?e.jsx("span",{className:"text-base font-extrabold italic text-orange-500 dark:text-orange-400 tracking-tighter",children:"3"}):e.jsx("span",{className:"text-[13px] font-bold tabular-nums text-oai-gray-400 dark:text-oai-gray-500",children:a==null?r:`#${a}`})}function jr({githubUrl:a}){return e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),"aria-label":"GitHub profile",className:"absolute bottom-0 right-0 translate-x-1 translate-y-1 flex h-4.5 w-4.5 items-center justify-center rounded-full bg-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-gray-100 shadow border border-oai-gray-100 dark:border-oai-gray-800 transition-transform active:scale-110",children:e.jsx(pe,{provider:"GITHUB",size:11})})}function Nr({entry:a,orderedColumns:r}){const{formatTokens:o,formatTokensTooltip:s}=X(),l=r.filter(i=>{const m=Number(a?.[i.key]);return Number.isFinite(m)&&m>0});return l.length===0?null:e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-x-1.5 gap-y-2 border-t border-oai-gray-100/70 pt-3 dark:border-oai-gray-800/60",children:l.map(i=>{const m=n(i.copyKey);return e.jsxs("span",{title:m,"aria-label":`${m}: ${s(a?.[i.key])}`,className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-oai-gray-50/80 dark:bg-oai-gray-900/60 px-2 py-0.5 border border-oai-gray-100/80 dark:border-oai-gray-800/40 text-[10px] font-medium text-oai-gray-600 dark:text-oai-gray-300 transition-colors",children:[e.jsx(pe,{provider:kr(i),size:12,className:"shrink-0 opacity-90"}),e.jsx("span",{className:"tabular-nums",children:o(a?.[i.key])})]},i.key)})})}function _r({entry:a,entryIdx:r,name:o,meLabel:s,currency:l,rate:i,orderedColumns:m,placeholder:b,onOpenProfile:x}){if(a?.is_ellipsis)return e.jsx("div",{"aria-hidden":"true",className:"px-4 py-2 text-center text-xs tracking-[0.4em] text-oai-gray-400 dark:text-oai-gray-600",children:"···"},`mobile-ellipsis-${r}`);const p=!!a?.is_me,v=!p&&ge(a?.display_name),f=typeof a?.user_id=="string"?a.user_id:null,h=!!f,g=p?s:o,A=C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),x(f))};return e.jsxs("div",{role:h?"button":void 0,tabIndex:h?0:void 0,onClick:h?()=>x(f):void 0,onKeyDown:h?A:void 0,"aria-label":h?n("leaderboard.profile_modal.row_aria",{name:g}):void 0,className:d("relative mx-0 my-1 rounded-xl px-3.5 py-3 transition-all duration-200 border shadow-sm select-none",p?"bg-gradient-to-br from-oai-brand-50/70 via-oai-brand-50/20 to-transparent dark:from-oai-brand-950/20 dark:via-oai-brand-950/5 dark:to-transparent border-oai-brand-200/60 dark:border-oai-brand-500/25":v?"bg-white/90 dark:bg-oai-gray-950/90 border-oai-gray-100/70 dark:border-oai-gray-800/40":"bg-white dark:bg-oai-gray-950 border-oai-gray-100 dark:border-oai-gray-800/60",h&&"cursor-pointer hover:border-oai-gray-200 dark:hover:border-oai-gray-700/80 active:scale-[0.985] active:bg-oai-gray-50/60 dark:active:bg-oai-gray-900/40 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-oai-brand-500/60"),children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("span",{className:"flex w-5 shrink-0 items-center justify-center",children:e.jsx(vr,{rank:a?.rank,placeholder:b})}),e.jsxs("span",{className:"relative inline-flex shrink-0",children:[e.jsx("span",{className:d("inline-flex rounded-full p-0.5 transition-all duration-300",wr[a?.rank]||"ring-1 ring-oai-gray-200 dark:ring-oai-gray-800/80",v&&"opacity-60 grayscale-[15%]"),children:e.jsx(Z,{size:"md",avatarUrl:a?.avatar_url,displayName:g,seed:be(a,g)})}),a?.github_url&&e.jsx(jr,{githubUrl:a.github_url})]}),e.jsxs("div",{className:"min-w-0 flex-1 pl-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:d("min-w-0 truncate text-sm tracking-tight",p?"font-semibold text-oai-black dark:text-oai-white":v?"font-normal text-oai-gray-400 dark:text-oai-gray-500":"font-medium text-oai-gray-800 dark:text-oai-gray-200"),children:g}),e.jsx(ne,{badges:a?.badges,className:"shrink-0 scale-95"})]}),e.jsxs("div",{className:"mt-1 text-[11px] text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("span",{children:n("leaderboard.column.est_cost")}),e.jsx("span",{className:d("ml-1 tabular-nums font-medium",v?"text-oai-gray-400/80 dark:text-oai-gray-500/80":"text-oai-gray-600 dark:text-oai-gray-300"),children:me(a?.estimated_cost_usd,l,i)})]})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-[0.08em] text-oai-gray-400 dark:text-oai-gray-500",children:n("leaderboard.column.total")}),e.jsx("div",{className:d("mt-0.5 text-sm font-semibold tabular-nums tracking-tight",p?"text-oai-black dark:text-oai-white":v?"text-oai-gray-400 dark:text-oai-gray-500":"text-oai-gray-800 dark:text-oai-gray-200"),children:e.jsx(ue,{value:a?.total_tokens})})]})]}),e.jsx(Nr,{entry:a,orderedColumns:m})]},`mobile-row-${a?.rank}-${g}`)}const Sr={1:{text:"text-amber-600 dark:text-amber-400",badge:"bg-amber-50 dark:bg-amber-900/20"},2:{text:"text-gray-500 dark:text-gray-300",badge:"bg-gray-50 dark:bg-gray-800/40"},3:{text:"text-orange-700 dark:text-orange-400",badge:"bg-orange-50 dark:bg-orange-900/20"}};function De({rank:a,placeholder:r}){const o=Sr[a];return o?e.jsx("span",{className:d("inline-flex items-center justify-center h-7 w-7 rounded-full text-xs font-bold",o.text,o.badge),children:a}):e.jsx("span",{className:"inline-flex items-center justify-center h-7 w-7 text-sm",children:a??r})}function Ue(a){if(typeof a!="string")return null;const r=a.trim().toLowerCase();return r==="week"||r==="month"||r==="total"?r:null}function Cr(a){if(!a)return n("shared.error.prefix",{error:n("leaderboard.error.unknown")});const r=a?.message||String(a),o=String(r||"").trim()||n("leaderboard.error.unknown");return n("shared.error.prefix",{error:o})}function xe(a){return typeof a!="string"?"":a.trim()}function ge(a){const r=xe(a);return r?r.toLowerCase()==="anonymous":!0}function be(a,r){const o=typeof a?.user_id=="string"?a.user_id.trim():"";return o||`${a?.rank??""}:${r}`}function Oe({githubUrl:a}){return e.jsxs("span",{className:"absolute left-1/2 top-full -translate-x-1/2 -translate-y-1/2 inline-flex group/gh",children:[e.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),"aria-label":n("leaderboard.github.aria"),className:"flex h-4 w-4 items-center justify-center rounded-full bg-white dark:bg-oai-gray-950 text-oai-black dark:text-oai-gray-100 transition-transform hover:scale-110",children:e.jsx(pe,{provider:"GITHUB",size:14})}),e.jsxs("span",{role:"tooltip",className:"invisible opacity-0 group-hover/gh:visible group-hover/gh:opacity-100 absolute left-0 bottom-full mb-2 whitespace-nowrap rounded-md bg-oai-black dark:bg-oai-gray-700 px-2.5 py-1.5 text-[11px] leading-relaxed text-white shadow-lg transition-opacity duration-150 z-50 before:content-[''] before:absolute before:inset-x-0 before:top-full before:h-2.5",children:[e.jsx("span",{className:"block",children:n("leaderboard.github.tooltipAction")}),e.jsxs("span",{className:"block text-oai-gray-300 dark:text-oai-gray-400",children:[n("leaderboard.github.tooltipPrefix")," ",e.jsx(_a,{to:"/settings",onClick:r=>r.stopPropagation(),className:"text-white underline underline-offset-2 decoration-oai-gray-400 hover:text-oai-brand-300 hover:decoration-oai-brand-300",children:n("leaderboard.github.tooltipSettingsLink")})," ",n("leaderboard.github.tooltipSuffix")]})]})]})}function Fr({auth:a,signedIn:r,sessionSoftExpired:o}){const s=xa(),l=ga(),{openLoginModal:i}=ba(),{signedIn:m,loading:b,user:x}=pa(),{currency:p,rate:v}=Ga(),f=c.useMemo(()=>ha(),[]),h=fa(),g=r&&!o,A=c.useMemo(()=>g&&(typeof a=="function"||typeof a=="string"||a&&typeof a=="object")?a:null,[a,g]),C=g?A:null,Q=g&&ya(C),ee=n("shared.placeholder.short"),Ve=c.useMemo(()=>q.map(t=>t.key),[]),{order:ae,reorder:he}=mr(Ve),fe=c.useMemo(()=>{const t=new Map;for(const u of q)t.set(u.key,u);return t},[]),B=c.useMemo(()=>ae.map(t=>fe.get(t)).filter(Boolean),[ae,fe]),Je=za(Be(Fa,{activationConstraint:{distance:6}}),Be(Oa,{coordinateGetter:Ua})),Ze=c.useCallback(t=>{const{active:u,over:w}=t;!w||u.id===w.id||he(String(u.id),String(w.id))},[he]),[re,T]=c.useState(1),[_,qe]=c.useState(fr),[ye,ke]=c.useState(null),[Xe,we]=c.useState(!1),Y=c.useCallback(t=>{typeof t=="string"&&t.trim()&&ke(t.trim())},[]),Qe=c.useCallback(()=>ke(null),[]),ea=c.useCallback(t=>{const u=de.includes(t)?t:ce;qe(u),T(1);try{window.localStorage.setItem(We,String(u))}catch{}},[]),[ve,aa]=c.useState(0),[ra,ta]=c.useState(()=>ka()),[je,Ne]=c.useState(!1);c.useEffect(()=>{if(typeof window>"u")return;const t=()=>{aa(u=>u+1)};return window.addEventListener(Ie,t),()=>{window.removeEventListener(Ie,t)}},[]);const N=c.useMemo(()=>{const t=new URLSearchParams(s?.search||"");return Ue(t.get("period"))||"total"},[s?.search]),oa=t=>{const u=Ue(t);if(!u||u===N)return;const w=new URLSearchParams(s?.search||"");w.set("period",u),T(1),l(`${s?.pathname||"/leaderboard"}?${w.toString()}`,{replace:!0})};c.useEffect(()=>{b||h||m||i()},[m,b,h,i]),c.useEffect(()=>{T(1)},[N]);const W=c.useMemo(()=>(H(re,{min:1,max:1e6,fallback:1})-1)*_,[re,_]),R=c.useMemo(()=>h?"mock":b?"unavailable":m?"cloud":r?"local":f?"public":"unavailable",[b,m,f,h,r]),k=c.useMemo(()=>wa({accessMode:R,baseUrl:f,mockEnabled:h,userId:x?.id||null,period:N,pageSize:_,offset:W}),[x?.id,R,f,W,h,_,N]),[$,D]=c.useState(()=>{const t=se(k);return t?{loading:!1,error:null,data:t.data,contextKey:k}:{loading:!1,error:null,data:null,contextKey:null}});c.useEffect(()=>{if(!f&&!h||!h&&R==="unavailable"){D({loading:!1,error:null,data:null,contextKey:null});return}const t=se(k);let u=!0;return D(t?{loading:!1,error:null,data:t.data,contextKey:k}:{loading:!0,error:null,data:null,contextKey:null}),(async()=>{const w=await va({userId:x?.id||null,period:N,limit:_,offset:W});u&&(ja(w,{activeContextKey:k,contextKey:k,source:ve>0?"manual-refresh":"page-load"}),D({loading:!1,error:null,data:w,contextKey:k}))})().catch(w=>{if(!u)return;const M=Cr(w);D(F=>F.contextKey===k?{...F,loading:!1,error:M}:{loading:!1,error:M,data:null,contextKey:k})}),()=>{u=!1}},[f,R,x?.id,k,W,ve,h,N,_]);const te=c.useMemo(()=>$.contextKey===k?null:se(k),[k,$.contextKey]),j=c.useMemo(()=>$.contextKey===k?$:te?{loading:!1,error:null,data:te.data,contextKey:k}:{loading:!!(f||h)&&R!=="unavailable",error:null,data:null,contextKey:k},[R,f,k,$,h,te]),S=j.data,U=S?.total_pages??null,sa=S?.total_entries??0,P=S?.page??re,na=c.useMemo(()=>er(P,U),[P,U]),_e=S?.from||null,Se=S?.to||null,Ce=S?.generated_at||null,Ee=Za(),K=S?.me||null,z=n("leaderboard.me_label"),Le=n("leaderboard.anon_label"),Ae=n("leaderboard.period.week"),Me=n("leaderboard.period.month"),Te=n("leaderboard.period.total"),Pe=N==="month"?Me:N==="total"?Te:Ae,V=c.useMemo(()=>{const t=Array.isArray(S?.entries)?S.entries:[];return rr({entries:t,me:K,meLabel:z})},[S?.entries,K,z]),I=c.useMemo(()=>tr(K?.rank,_),[K?.rank,_]),ia=I!=null&&I===P,la=c.useCallback(()=>{I!=null&&T(I)},[I]),da=async()=>{Ne(!0);try{Ea(!0),ta(!0),await La(()=>Aa(C))}catch(t){console.warn("[tokentracker] sync:",t)}finally{Ne(!1)}},{canPrev:Ke,canNext:Re}=ar({page:P,totalPages:U}),J=Array.isArray(V)&&V.length!==0;let O=null;j.loading&&!J?O=e.jsx(lr,{rows:_}):j.error&&!J?O=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:j.error})}):J?O=e.jsxs(Ia,{sensors:Je,collisionDetection:Ba,modifiers:[Qa],onDragEnd:Ze,children:[e.jsx("div",{className:"hidden w-full overflow-x-auto sm:block",children:e.jsxs("table",{className:"min-w-full w-full text-left text-sm sm:min-w-max",children:[e.jsx("thead",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:d(Ge,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:n("leaderboard.column.rank")}),e.jsx("th",{className:d(He,"text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500"),children:n("leaderboard.column.user")}),e.jsx("th",{className:"px-3 sm:px-4 py-4 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap text-right align-middle",children:n("leaderboard.column.total")}),e.jsx("th",{className:"hidden sm:table-cell px-3 sm:px-4 py-4 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap text-right align-middle",title:"Based on estimated API pricing, not actual billing",children:n("leaderboard.column.est_cost")}),e.jsx($a,{items:ae,strategy:Da,children:B.map(t=>e.jsx(dr,{id:t.key,thClassName:"hidden sm:table-cell px-3 sm:px-4 py-4 text-[11px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap align-middle",children:e.jsx(sr,{iconSrc:t.icon,label:n(t.copyKey)})},t.key))})]})}),e.jsx("tbody",{className:"divide-y divide-oai-gray-100 dark:divide-oai-gray-800/50",children:V.map((t,u)=>{if(t?.is_ellipsis){const L=4+B.length;return e.jsx("tr",{"aria-hidden":"true",children:e.jsx("td",{colSpan:L,className:"px-4 py-2 text-center text-oai-gray-400 dark:text-oai-gray-600 bg-white dark:bg-oai-gray-950 select-none tracking-[0.4em] text-xs",children:"···"})},`ellipsis-${u}`)}const w=!!t?.is_me,M=typeof t?.user_id=="string"?t.user_id:null,F=xe(t?.display_name),ca=ge(F)?Le:F,E=w?z:ca,G=!!M,ze=G?{role:"button",tabIndex:0,onClick:G?()=>Y(M):void 0,onKeyDown:G?L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),Y(M))}:void 0,"aria-label":n("leaderboard.profile_modal.row_aria",{name:E})}:{};if(w){const L=!!t?.is_pinned;return e.jsxs("tr",{...ze,className:d("bg-oai-brand-50 dark:bg-oai-brand-900/10 transition-colors",L?"border-t border-b border-oai-brand-300/40 dark:border-oai-brand-500/20":"border-y border-oai-brand-300/40 dark:border-oai-brand-500/30",G&&"cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500/60"),children:[e.jsx("td",{className:d(ie(!0),"font-semibold text-oai-brand-600 dark:text-oai-brand-400",L&&"before:absolute before:left-0 before:top-[15%] before:h-[70%] before:w-[3px] before:rounded-r before:bg-oai-brand-500 dark:before:bg-oai-brand-400"),children:e.jsx(De,{rank:t?.rank,placeholder:ee})}),e.jsx("td",{className:le(!0),children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsxs("span",{className:d("relative inline-flex shrink-0 rounded-full p-[2px]",t?.github_url&&"gh-avatar-frame"),children:[e.jsx("span",{className:d("inline-flex rounded-full p-px",t?.github_url&&"bg-white dark:bg-oai-gray-950"),children:e.jsx(Z,{avatarUrl:t?.avatar_url,displayName:E,seed:be(t,E)})}),t?.github_url&&e.jsx(Oe,{githubUrl:t.github_url})]}),e.jsx("span",{className:"truncate font-semibold text-oai-black dark:text-oai-white",children:E}),e.jsx(ne,{badges:t?.badges,className:"hidden sm:inline-flex"})]})}),e.jsx("td",{className:"px-3 sm:px-4 py-4 font-medium text-oai-black dark:text-oai-white whitespace-nowrap text-right tabular-nums bg-oai-brand-50 dark:bg-oai-brand-900/10",children:e.jsx(ue,{value:t?.total_tokens})}),e.jsx("td",{className:"hidden sm:table-cell px-3 sm:px-4 py-4 font-medium text-oai-brand-600 dark:text-oai-brand-400 whitespace-nowrap text-right tabular-nums bg-oai-brand-50 dark:bg-oai-brand-900/10",title:"Based on estimated API pricing, not actual billing",children:me(t?.estimated_cost_usd,p,v)}),e.jsx($e,{entry:t,isMe:!0,orderedColumns:B})]},`row-${t?.rank}-${E}${L?"-pin":""}`)}return e.jsxs("tr",{...ze,className:d("group transition-colors",G&&"cursor-pointer hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/60 focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500/60"),children:[e.jsx("td",{className:d(ie(!1),"font-medium text-oai-gray-500 dark:text-oai-gray-400"),children:e.jsx(De,{rank:t?.rank,placeholder:ee})}),e.jsx("td",{className:le(!1),children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsxs("span",{className:d("relative inline-flex shrink-0 rounded-full p-[2px]",t?.github_url&&"gh-avatar-frame"),children:[e.jsx("span",{className:d("inline-flex rounded-full p-px",t?.github_url&&"bg-white dark:bg-oai-gray-950"),children:e.jsx(Z,{avatarUrl:t?.avatar_url,displayName:E,seed:be(t,E)})}),t?.github_url&&e.jsx(Oe,{githubUrl:t.github_url})]}),e.jsx("span",{className:"truncate font-medium text-oai-gray-800 dark:text-oai-gray-200",children:E}),e.jsx(ne,{badges:t?.badges,className:"hidden sm:inline-flex"})]})}),e.jsx("td",{className:"px-3 sm:px-4 py-4 font-semibold text-oai-gray-800 dark:text-oai-gray-200 whitespace-nowrap text-right tabular-nums bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60",children:e.jsx(ue,{value:t?.total_tokens})}),e.jsx("td",{className:"hidden sm:table-cell px-3 sm:px-4 py-4 text-oai-gray-500 dark:text-oai-gray-400 whitespace-nowrap text-right tabular-nums bg-white dark:bg-oai-gray-950 group-hover:bg-oai-gray-50 dark:group-hover:bg-oai-gray-900/60",title:"Based on estimated API pricing, not actual billing",children:me(t?.estimated_cost_usd,p,v)}),e.jsx($e,{entry:t,isMe:!1,orderedColumns:B})]},`row-${t?.rank}-${E}`)})})]})}),e.jsx("div",{className:"flex flex-col py-1.5 sm:hidden",children:V.map((t,u)=>{const w=xe(t?.display_name),M=ge(w)?Le:w;return e.jsx(_r,{entry:t,entryIdx:u,name:t?.is_me?z:M,meLabel:z,currency:p,rate:v,orderedColumns:B,placeholder:ee,onOpenProfile:Y},`mobile-${t?.rank??"ellipsis"}-${u}`)})})]}):O=e.jsx("div",{className:"px-6 py-12 text-center",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.empty")})});let oe=null;return typeof U=="number"?oe=na.map((t,u)=>t==null?e.jsx("span",{className:"px-2 text-oai-gray-400 dark:text-oai-gray-500",children:n("leaderboard.pagination.ellipsis")},`ellipsis-${u}`):e.jsx("button",{className:d("flex h-8 w-8 items-center justify-center rounded-md text-sm font-medium transition-colors",t===P?"bg-oai-gray-200 dark:bg-oai-gray-800 text-oai-black dark:text-white":"text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white"),onClick:()=>T(t),disabled:j.loading,children:String(t)},`page-${t}`)):oe=e.jsx("span",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.pagination.page_unknown",{page:String(P)})}),e.jsxs("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:[e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-4 grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-3.5 sm:mb-8 sm:grid-cols-[minmax(0,1fr)_auto] sm:gap-4",children:[e.jsx("h1",{className:"col-start-1 row-start-1 min-w-0 whitespace-nowrap text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:col-span-2 sm:row-start-1 sm:text-4xl",children:n("leaderboard.title")}),e.jsxs("p",{className:"col-span-2 row-start-2 hidden text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:block sm:row-start-2 sm:text-base",children:[N==="total"?n("leaderboard.range.total"):_e&&Se?n("leaderboard.range",{period:Pe,from:_e,to:Se}):n("leaderboard.range_loading",{period:Pe}),Ce&&e.jsx("span",{className:"ml-2 hidden border-l border-oai-gray-200 pl-2 text-xs text-oai-gray-400 dark:border-oai-gray-800 dark:text-oai-gray-500 sm:inline-block",children:n("leaderboard.generated_at",{ts:Ce})})]}),e.jsx("div",{className:"col-start-2 row-start-1 inline-flex h-9 shrink-0 items-center rounded-full border border-oai-gray-200 p-1 dark:border-oai-gray-800 sm:col-start-1 sm:row-start-3 sm:justify-self-start",children:["week","month","total"].map(t=>{const u=N===t;return e.jsxs("button",{onClick:()=>oa(t),disabled:j.loading,className:d("px-3 sm:px-4 h-7 text-sm font-medium rounded-full flex items-center justify-center transition-colors relative",u?"text-oai-black dark:text-white":"text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-800 dark:hover:text-oai-gray-200"),children:[e.jsx("span",{className:"relative z-10",children:t==="week"?Ae:t==="month"?Me:Te}),u&&e.jsx(Na.div,{layoutId:"leaderboard-period-active-bg",className:"absolute inset-0 bg-oai-gray-200 dark:bg-oai-gray-800 rounded-full z-0",transition:{type:"spring",stiffness:380,damping:30}})]},t)})}),e.jsxs("div",{className:"col-span-2 row-start-2 mb-0 flex w-full min-w-0 items-center justify-between sm:justify-end gap-2.5 sm:col-span-1 sm:col-start-2 sm:row-start-3 sm:mb-0 sm:w-auto sm:shrink-0",children:[e.jsx(yr,{communityStats:Ee,onClick:()=>we(!0)}),e.jsx(br,{me:K,totalEntries:sa,meLabel:z,onOpenProfile:K?.user_id?()=>Y(K.user_id):void 0,onJumpToMe:la,canJump:I!=null&&!ia&&!j.loading,className:"shrink-0"})]})]}),!r&&e.jsxs("div",{className:"mb-6 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between text-sm",children:[e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.signin_prompt")}),e.jsx("button",{onClick:i,className:"shrink-0 whitespace-nowrap self-start sm:self-auto px-3 py-1.5 text-sm font-medium text-oai-gray-600 dark:text-oai-gray-300 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md hover:text-oai-black dark:hover:text-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600 transition-colors",children:n("leaderboard.signin_button")})]}),g&&Q&&!ra&&e.jsxs("div",{className:"mb-6 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between text-sm",children:[e.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.sync_prompt")}),e.jsx("button",{onClick:da,disabled:je,className:"shrink-0 whitespace-nowrap self-start sm:self-auto px-3 py-1.5 text-sm font-medium text-oai-gray-600 dark:text-oai-gray-300 border border-oai-gray-300 dark:border-oai-gray-700 rounded-md hover:text-oai-black dark:hover:text-white hover:border-oai-gray-400 dark:hover:border-oai-gray-600 disabled:opacity-50 transition-colors",children:je?n("leaderboard.sync_button.busy"):n("leaderboard.sync_button.idle")})]}),e.jsxs("div",{className:"sm:rounded-xl sm:border sm:border-oai-gray-200 sm:dark:border-oai-gray-800 sm:overflow-hidden border-none bg-transparent",children:[j.error&&J?e.jsx("div",{className:"border-b border-oai-gray-200 dark:border-oai-gray-800 px-6 py-3",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:j.error})}):null,O,e.jsxs("div",{className:"flex flex-col gap-3 sm:border-t border-oai-gray-200 px-4 py-3 sm:flex-row sm:items-center sm:justify-end sm:gap-x-4 sm:px-6 dark:border-oai-gray-800 border-none mt-2.5 sm:mt-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-sm text-oai-gray-500 dark:text-oai-gray-400 sm:justify-start",children:[e.jsx("label",{htmlFor:"leaderboard-page-size",className:"whitespace-nowrap",children:n("leaderboard.pagination.page_size_label")}),e.jsx(Ta,{id:"leaderboard-page-size",value:_,onValueChange:t=>ea(Number(t)),disabled:j.loading,ariaLabel:n("leaderboard.pagination.page_size_label"),options:de.map(t=>({value:t,label:String(t)})),align:"end",className:"px-3 py-1 text-oai-gray-700 dark:text-oai-gray-300"})]}),e.jsx("div",{className:"hidden h-5 w-px bg-oai-gray-200 dark:bg-oai-gray-800 sm:block","aria-hidden":"true"}),e.jsxs("div",{className:"flex w-full items-center justify-between sm:w-auto sm:justify-end gap-1.5",children:[e.jsx("button",{className:d("whitespace-nowrap rounded-xl border border-oai-gray-100 bg-oai-gray-50/50 px-3.5 py-2 text-xs font-medium text-oai-gray-500 dark:border-oai-gray-800/80 dark:bg-white/[0.01] dark:text-oai-gray-400 transition-all duration-200 active:scale-[0.97] sm:rounded-md sm:border-0 sm:bg-transparent sm:px-3 sm:py-1.5 sm:text-sm sm:font-medium sm:active:scale-100",Ke&&!j.loading?"hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white":"opacity-50 cursor-not-allowed"),onClick:()=>T(t=>Math.max(1,t-1)),disabled:!Ke||j.loading,children:n("leaderboard.pagination.prev")}),e.jsxs("span",{className:"text-xs font-semibold tabular-nums text-oai-gray-500 dark:text-oai-gray-455 px-2 sm:hidden",children:[P," / ",U||"?"]}),e.jsx("div",{className:"hidden sm:flex items-center gap-1",children:oe}),e.jsx("button",{className:d("whitespace-nowrap rounded-xl border border-oai-gray-100 bg-oai-gray-50/50 px-3.5 py-2 text-xs font-medium text-oai-gray-500 dark:border-oai-gray-800/80 dark:bg-white/[0.01] dark:text-oai-gray-400 transition-all duration-200 active:scale-[0.97] sm:rounded-md sm:border-0 sm:bg-transparent sm:px-3 sm:py-1.5 sm:text-sm sm:font-medium sm:active:scale-100",Re&&!j.loading?"hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white":"opacity-50 cursor-not-allowed"),onClick:()=>T(t=>t+1),disabled:!Re||j.loading,children:n("leaderboard.pagination.next")})]})]})]})]})}),e.jsx("footer",{className:"border-t border-oai-gray-200 dark:border-oai-gray-900 py-8 transition-colors duration-200",children:e.jsxs("div",{className:"mx-auto flex max-w-6xl items-center justify-between px-4 sm:px-6 text-sm text-oai-gray-400 dark:text-oai-gray-500",children:[e.jsx("p",{children:n("landing.v2.footer.line")}),e.jsx("a",{href:"https://github.com/mm7894215/TokenTracker",className:"text-oai-gray-400 dark:text-oai-gray-500 hover:text-oai-black dark:hover:text-white transition-colors",target:"_blank",rel:"noopener noreferrer",children:n("landing.v2.nav.github")})]})}),e.jsxs(c.Suspense,{fallback:null,children:[e.jsx(pr,{isOpen:!!ye,userId:ye,period:N,accessToken:C,onClose:Qe}),e.jsx(hr,{isOpen:Xe,onClose:()=>we(!1),communityStats:Ee})]})]})}export{Fr as LeaderboardPage};
@@ -1 +0,0 @@
1
- import{u as p,d as w,e as v,r,c as s,j as e,L as y,f as j}from"./__vite-browser-external-Djkun5S2.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 k(){const i=p(),[t,u]=w(),{enabled:n,loading:f,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||f)&&x){if(o){window.location.href="/auth/native-callback";return}i(c,{replace:!0})}},[n,f,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(()=>{u(l=>{const a=new URLSearchParams(l);return a.delete("insforge_status"),a.delete("insforge_type"),a.delete("insforge_error"),a},{replace:!0}),d(null)},[u]);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{k as LoginPage};
@@ -1 +0,0 @@
1
- import{k as E,S as re,ao as ie,r as o,ap as se,aq as oe,ar as le,as as q,c as r,j as e,P as ne,b,at as U,X as de}from"./__vite-browser-external-Djkun5S2.js";import{u as ce,T as O,S as pe}from"./use-native-settings-o-TL7MGQ.js";import{n as xe,C as H}from"./ClawdAnimated-ChoWfPva.js";import{F}from"./FadeIn-DdYC9vT8.js";import{L as me}from"./link-2-Bh0vUBU6.js";import{L as W}from"./loader-circle-BVF4Sglg.js";import{Z as ue}from"./zap-9gvAtu1o.js";import{T as ge}from"./trash-2-DrGpFJsR.js";import{D as be,a as he,b as fe,c as ye,d as ke,e as ve}from"./DialogTitle-vIrqSKer.js";import{D as je}from"./DialogDescription-DDeAH6I9.js";import{D as we}from"./DialogClose-8Fw7R9Ma.js";import"./Card-D479hjUR.js";import"./useScrollLock-DZpDnNt6.js";const Ne=[["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"}]],Se=E("file-archive",Ne);const Ce=[["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"}]],Pe=E("monitor-up",Ce);const ze=[["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"}]],Ie=E("upload",ze),Ae={visible:!1,character:"clawd",size:"medium"};function De(){const t=re()&&ie(),[a,l]=o.useState(Ae);o.useEffect(()=>{if(!t)return;const p=se(s=>{l({visible:!!s.visible,character:xe(s.character),size:["small","medium","large"].includes(s.size)?s.size:"medium"})});return oe(),p},[t]);const d=o.useCallback((p,s)=>{l(m=>({...m,[p]:s})),t&&le(p,s)},[t]);return{available:t,settings:a,setSetting:d}}const k=[{id:"clawd",displayName:"Clawd",nameKey:"pet.character.clawd",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 C(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 Te(){const t=await fetch("/functions/tokentracker-pets",{headers:{Accept:"application/json"},cache:"no-store"}),a=await C(t);return[...k,...Array.isArray(a.pets)?a.pets:[]]}async function M(t){const a=await q();return C(await fetch("/functions/tokentracker-pets",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...a},cache:"no-store",body:JSON.stringify(t)}))}function Ee(t){return M({action:"install_url",url:t})}async function $(t){const a=await q();return C(await fetch("/api/pets/import",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/zip",...a},cache:"no-store",body:t}))}function Me(t){return M({action:"remove",id:t})}async function Le(){const t=await fetch("/functions/tokentracker-pets?scope=codex",{headers:{Accept:"application/json"},cache:"no-store"}),a=await C(t);return{importable:Array.isArray(a.importable)?a.importable:[],codexDetected:a.codexDetected===!0}}function _e(t){return M({action:"import_codex",ids:t})}let T=k;function Ke(){const[t,a]=o.useState(T),[l,d]=o.useState(!0),[p,s]=o.useState(!1),m=o.useCallback(async()=>{d(!0);try{const u=await Te();return T=u,a(u),s(!0),u}catch{return T=k,a(k),s(!1),k}finally{d(!1)}},[]);return o.useEffect(()=>{m()},[m]),{pets:t,loading:l,available:p,refresh:m}}const Be={clawd:"from-oai-amber-50 dark:from-orange-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 Ve(){const t=r("pet.import.subtitle"),a="codex-pets.net",l=t.indexOf(a);return l<0?t:e.jsxs(e.Fragment,{children:[t.slice(0,l),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(l+a.length)]})}const v=[{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 X({character:t,selected:a,onSelect:l,onRemove:d,removeDisabled:p}){const s=t.nameKey?r(t.nameKey):t.displayName;return e.jsxs("div",{className:"group relative",children:[e.jsxs("button",{type:"button",onClick:l,"aria-pressed":a,className:b("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:b("absolute inset-0 bg-gradient-to-br to-transparent opacity-80 dark:opacity-55",Be[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(H,{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:s}),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]})]})]}),d?e.jsx("button",{type:"button",disabled:p,onClick:d,"aria-label":`${r("pet.import.remove")} · ${s}`,className:b("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",a?"opacity-100":"opacity-0 group-hover:opacity-100"),children:e.jsx(ge,{className:"h-3 w-3","aria-hidden":!0})}):null]})}function Re({pet:t,state:a,onStateChange:l}){const[d,p]=o.useState(null),s=o.useRef(null),m=v.find(function(n){return n.id===a}),u=r(m?.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:x=>{if(t?.spriteVersionNumber!==2||!s.current)return;const n=s.current.getBoundingClientRect(),h=x.clientX-(n.left+n.width/2),c=x.clientY-(n.top+n.height/2),j=(Math.atan2(h,-c)*180/Math.PI+360)%360;p(Math.round(j/22.5)%16)},onPointerLeave:()=>p(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 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}),u]})]}),e.jsx("div",{className:"relative flex flex-1 items-center justify-center px-6 py-5",children:e.jsx("div",{ref:s,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(H,{state:a,character:t?.id||"clawd",pet:t,size:190,lookDirectionIndex:d})})})}),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:v.map(x=>e.jsxs("button",{type:"button",onClick:()=>l(x.id),"aria-pressed":a===x.id,className:b("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===x.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(x.labelKey)}),e.jsx("span",{className:b("h-1 w-1 rounded-full transition-colors duration-200",a===x.id?"bg-oai-black dark:bg-white":"bg-transparent"),"aria-hidden":!0})]},x.id))})})]})}function Ue({pets:t,busy:a,error:l,onImport:d,onClose:p}){const[s,m]=o.useState(()=>new Set),u=n=>m(h=>{const c=new Set(h);return c.has(n)?c.delete(n):c.add(n),c}),x=t.length!==0&&s.size===t.length;return e.jsx(be,{open:!0,onOpenChange:n=>{!n&&!a&&p()},children:e.jsxs(he,{children:[e.jsx(fe,{className:"fixed inset-0 z-50 bg-black/15 backdrop-blur-md dark:bg-black/40 animate-tt-fade-in"}),e.jsx(ye,{className:"fixed inset-0 z-50 flex items-center justify-center p-3 md:p-6",children:e.jsxs(ke,{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(ve,{className:"text-base font-semibold",children:r("pet.codex.title")}),e.jsx(je,{className:"mt-0.5 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r("pet.codex.subtitle")})]}),e.jsx(we,{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(de,{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(n=>e.jsx(X,{character:n,selected:s.has(n.id),onSelect:()=>u(n.id)},n.id))}),l?e.jsx("p",{role:"alert",className:"mt-3 text-xs text-red-600 dark:text-red-400",children:l}):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:()=>m(x?new Set:new Set(t.map(n=>n.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||s.size===0,onClick:()=>d([...s]),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(W,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):null,s.size>0?`${r("pet.codex.import")} · ${s.size}`:r("pet.codex.import")]})]})]})})]})})}function tt(){const{available:t,settings:a,setSetting:l}=De(),{pets:d,loading:p,available:s,refresh:m}=Ke(),[u,x]=o.useState(""),[n,h]=o.useState(""),[c,j]=o.useState(!1),[L,P]=o.useState([]),[Z,z]=o.useState(!1),[w,_]=o.useState(!1),[J,I]=o.useState(""),[Y,K]=o.useState("idle-living"),[B,G]=o.useState(!0),y=a.character||"clawd",A=ce(),V=A.settings?.menuBarIconStyle==="pet",Q=d.find(i=>i.id===y)||d[0],N=c?{kind:"busy",text:r("pet.import.busy")}:n?{kind:"error",text:n}:null,R=L.length!==0;o.useEffect(()=>{!p&&d.length>0&&!d.some(i=>i.id===y)&&l("character","clawd")},[p,d,y,l]);async function S(i,g=r("pet.import.success")){j(!0),h("");try{const f=await i();await m(),f?.pet?.id&&l("character",f.pet.id),U({title:g,timeout:4e3}),x("")}catch(f){h(f?.message||r("pet.import.failed"))}finally{j(!1)}}const D=o.useCallback(async()=>{if(!s){P([]);return}try{const i=await Le();P(i.importable)}catch{P([])}},[s]);o.useEffect(()=>{D()},[D]);async function ee(i){_(!0),I("");try{return await _e(i),await m(),await D(),U({title:r("pet.codex.imported"),timeout:4e3}),!0}catch(g){return I(g?.message||r("pet.import.failed")),!1}finally{_(!1)}}o.useEffect(()=>{if(!B)return;const i=window.setInterval(()=>{K(g=>{const f=v.findIndex(ae=>ae.id===g);return v[(f+1)%v.length].id})},5e3);return()=>window.clearInterval(i)},[B]);const te=[{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(F,{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(F,{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(Re,{pet:Q,state:Y,onStateChange:i=>{G(!1),K(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:d.map(i=>e.jsx(X,{character:i,selected:y===i.id,onSelect:()=>l("character",i.id),removeDisabled:c,onRemove:s&&i.custom?()=>S(async()=>(await Me(i.id),y===i.id&&l("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(O,{checked:V,onChange:()=>A.setSetting("menuBarIconStyle",V?"clawd":"pet"),ariaLabel:r("pet.menubar.title")})]}):null]}),s?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(Ie,{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(Ve,{})}),e.jsxs("form",{className:"mt-3 flex gap-2",onSubmit:i=>{i.preventDefault(),!c&&u.trim()&&S(()=>Ee(u))},children:[e.jsxs("label",{className:"relative flex min-w-0 flex-1 items-center",children:[e.jsx(me,{className:"pointer-events-none absolute left-3 h-3.5 w-3.5 text-oai-gray-400","aria-hidden":!0}),e.jsx("input",{value:u,onChange:i=>x(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:c||!u.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:[c?e.jsx(W,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):null,r("pet.import.add")]})]}),e.jsxs("div",{className:b("mt-2 grid gap-2",R?"grid-cols-2":"grid-cols-1"),children:[R?e.jsxs("button",{type:"button",disabled:c||w,onClick:()=>{I(""),z(!0)},className:b("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",(c||w)&&"pointer-events-none opacity-40"),children:[e.jsx(ne,{provider:"codex",size:14,className:"fill-current"}),r("pet.codex.browse")]}):null,e.jsxs("label",{onDragOver:i=>i.preventDefault(),onDrop:i=>{if(i.preventDefault(),c)return;const g=i.dataTransfer?.files?.[0];g&&S(()=>$(g))},className:b("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",c&&"pointer-events-none opacity-40"),children:[e.jsx(Se,{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:c,onChange:i=>{const g=i.target.files?.[0];g&&S(()=>$(g)),i.target.value=""}})]})]}),N?e.jsx("p",{role:N.kind==="error"?"alert":"status",className:b("mt-2 text-xs",N.kind==="error"?"text-red-600 dark:text-red-400":"text-oai-gray-500 dark:text-oai-gray-400"),children:N.text}):null,Z?e.jsx(Ue,{pets:L,busy:w,error:J,onClose:()=>{w||z(!1)},onImport:async i=>{await ee(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(Pe,{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(O,{checked:a.visible,onChange:()=>l("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(pe,{options:te,value:a.size,onChange:i=>l("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(ue,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),r("pet.controls.native_only")]})]})]})})]})})})}export{tt as PetPage};
@@ -1 +0,0 @@
1
- import{k as Ue,aR as Xe,bv as Ke,bw as le,bx as Qe,Q as ne,aQ as ge,r as m,by as $,bz as me,bA as he,bB as oe,aN as Re,bC as We,bD as we,aO as q,A as J,bE as Q,a0 as ue,aH as pe,aP as qe,bF as Ee,bG as ze,E as Je,bH as $e,bI as Te,aF as W,j as G,aM as Ze,aG as Me,aU as et,bJ as tt,bK as nt,bL as ot,bM as st,y as rt,z as Le,bN as it,bO as ye,aK as at,bP as ct,bQ as lt,aL as ut,aJ as ft,bR as dt,aI as pt}from"./__vite-browser-external-Djkun5S2.js";import{n as Pe,o as Ae,q as He,r as ve,v as se,P as gt,w as mt,k as ht,s as Et,x as Tt,y as Pt,e as vt,f as Ct,g as Rt,h as bt,a as Be,j as St,u as Ot,z as It,A as Mt,t as yt,B as xt,I as Ft,D as kt,c as wt,d as Lt,b as At,p as Ht}from"./useScrollLock-DZpDnNt6.js";import{f as Bt,p as Dt,g as Nt}from"./DialogTitle-vIrqSKer.js";import{r as _t,t as jt,v as Gt,w as Yt,x as Vt,y as Ut,z as Xt,A as Kt}from"./SelectItemText-D4laqPg3.js";const Qt=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Tn=Ue("chevron-right",Qt);function Wt(e,n){return n!=null&&!Pe(n)?0:typeof e=="function"?e():e}function Ce(e,n,t){const l=Wt(e,t);return typeof l=="number"?l:l?.[n]}function xe(e){return typeof e=="function"?e():e}function De(e,n){return n||e==="click"||e==="mousedown"}function qt(e){return e?.includes("mouse")&&e!=="mousedown"}class be{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 le,this.restTimeout=new le,this.handleCloseOptions=void 0}static create(){return new be}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose}const fe=new WeakMap;function de(e){if(!e.performedPointerEventsMutation)return;const n=e.pointerEventsScopeElement;n&&fe.get(n)===e&&(e.pointerEventsScopeElement?.style.removeProperty("pointer-events"),e.pointerEventsReferenceElement?.style.removeProperty("pointer-events"),e.pointerEventsFloatingElement?.style.removeProperty("pointer-events"),fe.delete(n)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function Ne(e,n){const{scopeElement:t,referenceElement:l,floatingElement:i}=n,o=fe.get(t);o&&o!==e&&de(o),de(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=t,e.pointerEventsReferenceElement=l,e.pointerEventsFloatingElement=i,fe.set(t,e),t.style.pointerEvents="none",l.style.pointerEvents="auto",i.style.pointerEvents="auto"}function _e(e){const n=e.context.dataRef.current,t=Xe(()=>n.hoverInteractionState??be.create()).current;return n.hoverInteractionState||(n.hoverInteractionState=t),Ke(n.hoverInteractionState.disposeEffect),n.hoverInteractionState}function zt(e,n={}){const{enabled:t=!0,closeDelay:l=0,nodeId:i}=n,o="rootStore"in e?e.rootStore:e,p=o.useState("open"),E=o.useState("floatingElement"),S=o.useState("domReferenceElement"),{dataRef:c}=o.context,r=Ae(),O=He(),h=_e(o),j=Qe(),u=ne(()=>De(c.current.openEvent?.type,h.interactedInside)),B=ne(()=>qt(c.current.openEvent?.type)),g=ne(()=>{de(h)});ge(()=>{p||(h.pointerType=void 0,h.restTimeoutPending=!1,h.interactedInside=!1,g())},[p,h,g]),m.useEffect(()=>g,[g]),ge(()=>{if(t&&p&&h.handleCloseOptions?.blockPointerEvents&&B()&&$(S)&&E){const x=S,a=E,d=me(E),F=r?.nodesRef.current.find(R=>R.id===O)?.context?.elements.floating;F&&(F.style.pointerEvents="");const H=h.pointerEventsScopeElement!==a?h.pointerEventsScopeElement:null,P=F!==a?F:null,C=h.handleCloseOptions?.getScope?.()??H??P??x.closest("[data-rootownerid]")??d.body;return Ne(h,{scopeElement:C,referenceElement:x,floatingElement:a}),()=>{g()}}},[t,p,S,E,h,B,r,O,g]),m.useEffect(()=>{if(!t)return;function x(){return!!(r&&O&&ve(r.nodesRef.current,O).length>0)}function a(R){const M=Ce(l,"close",h.pointerType),N=()=>{o.setOpen(!1,J(Q,R)),r?.events.emit("floating.closed",R)};M?h.openChangeTimeout.start(M,N):(h.openChangeTimeout.clear(),N())}function d(R){const M=Re(R);if(!We(M)){h.interactedInside=!1;return}h.interactedInside=M?.closest("[aria-haspopup]")!=null}function F(){h.openChangeTimeout.clear(),j.clear(),r?.events.off("floating.closed",P),g()}function H(R){if(x()&&r){r.events.on("floating.closed",P);return}if(we(R.relatedTarget,o.context.triggerElements))return;const M=c.current.floatingContext?.nodeId??i,N=R.relatedTarget;if(!(r&&M&&$(N)&&ve(r.nodesRef.current,M,!1).some(U=>q(U.context?.elements.floating,N)))){if(h.handler){h.handler(R);return}g(),B()&&!u()&&a(R)}}function P(R){!r||!O||x()||j.start(0,()=>{r.events.off("floating.closed",P),o.setOpen(!1,J(Q,R)),r.events.emit("floating.closed",R)})}const C=E;return he(C&&oe(C,"mouseenter",F),C&&oe(C,"mouseleave",H),C&&oe(C,"pointerdown",d,!0),()=>{r?.events.off("floating.closed",P)})},[t,E,o,c,l,i,B,u,g,h,r,O,j])}const Jt={current:null};function $t(e,n={}){const{enabled:t=!0,delay:l=0,handleClose:i=null,mouseOnly:o=!1,restMs:p=0,move:E=!0,triggerElementRef:S=Jt,externalTree:c,isActiveTrigger:r=!0,getHandleCloseContext:O,isClosing:h,shouldOpen:j}=n,u="rootStore"in e?e.rootStore:e,{dataRef:B,events:g}=u.context,x=Ae(c),a=_e(u),d=m.useRef(!1),F=se(i),H=se(l),P=se(p),C=se(t),R=se(j),M=se(h),N=ne(()=>De(B.current.openEvent?.type,a.interactedInside)),V=ne(()=>R.current?.()!==!1),U=ne((s,T,L)=>{const b=u.context.triggerElements;if(b.hasElement(T))return!s||!q(s,T);if(!$(L))return!1;const f=L;return b.hasMatchingElement(A=>q(A,f))&&(!s||!q(s,f))}),_=ne(()=>{if(!a.handler)return;me(u.select("domReferenceElement")).removeEventListener("mousemove",a.handler),a.handler=void 0}),w=ne(()=>{de(a)});return r&&(a.handleCloseOptions=F.current?.__options),m.useEffect(()=>_,[_]),m.useEffect(()=>{if(!t)return;function s(T){T.open?d.current=!1:(d.current=T.reason===Q,_(),a.openChangeTimeout.clear(),a.restTimeout.clear(),a.blockMouseMove=!0,a.restTimeoutPending=!1)}return g.on("openchange",s),()=>{g.off("openchange",s)}},[t,g,a,_]),m.useEffect(()=>{if(!t)return;function s(f,A=!0){const D=Ce(H.current,"close",a.pointerType);D?a.openChangeTimeout.start(D,()=>{u.setOpen(!1,J(Q,f)),x?.events.emit("floating.closed",f)}):A&&(a.openChangeTimeout.clear(),u.setOpen(!1,J(Q,f)),x?.events.emit("floating.closed",f))}const T=S.current??(r?u.select("domReferenceElement"):null);if(!$(T))return;function L(f){if(a.openChangeTimeout.clear(),a.blockMouseMove=!1,o&&!Pe(a.pointerType))return;const A=xe(P.current),D=Ce(H.current,"open",a.pointerType),Y=Re(f),X=f.currentTarget??null,I=u.select("domReferenceElement");let k=X;if($(Y)&&!u.context.triggerElements.hasElement(Y)){for(const Ie of u.context.triggerElements.elements())if(q(Ie,Y)){k=Ie;break}}$(X)&&$(I)&&!u.context.triggerElements.hasElement(X)&&q(X,I)&&(k=I);const v=k==null?!1:U(I,k,Y),z=u.select("open"),Z=M.current?.()??u.select("transitionStatus")==="ending",K=!z&&Z&&d.current,ee=!v&&$(k)&&$(I)&&q(I,k)&&K,te=A>0&&!D,Ve=v&&(z||K)||ee,Oe=!z||v;if(Ve){V()&&u.setOpen(!0,J(Q,f,k));return}te||(D?a.openChangeTimeout.start(D,()=>{Oe&&V()&&u.setOpen(!0,J(Q,f,k))}):Oe&&V()&&u.setOpen(!0,J(Q,f,k)))}function b(f){if(N()){w();return}_();const A=u.select("domReferenceElement"),D=me(A);a.restTimeout.clear(),a.restTimeoutPending=!1;const Y=B.current.floatingContext??O?.();if(we(f.relatedTarget,u.context.triggerElements))return;if(F.current&&Y){u.select("open")||a.openChangeTimeout.clear();const I=S.current;a.handler=F.current({...Y,tree:x,x:f.clientX,y:f.clientY,onClose(){w(),_(),C.current&&!N()&&I===u.select("domReferenceElement")&&s(f,!0)}}),D.addEventListener("mousemove",a.handler),a.handler(f);return}(a.pointerType!=="touch"||!q(u.select("floatingElement"),f.relatedTarget))&&s(f)}return E?he(oe(T,"mousemove",L,{once:!0}),oe(T,"mouseenter",L),oe(T,"mouseleave",b)):he(oe(T,"mouseenter",L),oe(T,"mouseleave",b))},[_,w,B,H,u,t,F,a,r,U,N,o,E,P,S,x,C,O,M,V]),m.useMemo(()=>{if(!t)return;function s(T){a.pointerType=T.pointerType}return{onPointerDown:s,onPointerEnter:s,onMouseMove(T){const{nativeEvent:L}=T,b=T.currentTarget,f=u.select("domReferenceElement"),A=u.select("open"),D=U(f,b,T.target);if(o&&!Pe(a.pointerType))return;if(A&&D&&a.handleCloseOptions?.blockPointerEvents){const I=u.select("floatingElement");if(I){const k=a.handleCloseOptions?.getScope?.()??b.ownerDocument.body;Ne(a,{scopeElement:k,referenceElement:b,floatingElement:I})}}const Y=xe(P.current);if(A&&!D||Y===0||!D&&a.restTimeoutPending&&T.movementX**2+T.movementY**2<2)return;a.restTimeout.clear();function X(){if(a.restTimeoutPending=!1,N())return;const I=u.select("open");!a.blockMouseMove&&(!I||D)&&V()&&u.setOpen(!0,J(Q,L,b))}a.pointerType==="touch"?ue.flushSync(()=>{X()}):D&&A?X():(a.restTimeoutPending=!0,a.restTimeout.start(Y,X))}}},[t,a,N,U,o,u,P,V])}const Fe=.1,Zt=Fe*Fe,y=.5;function ie(e,n,t,l,i,o){return l>=n!=o>=n&&e<=(i-t)*(n-l)/(o-l)+t}function ae(e,n,t,l,i,o,p,E,S,c){let r=!1;return ie(e,n,t,l,i,o)&&(r=!r),ie(e,n,i,o,p,E)&&(r=!r),ie(e,n,p,E,S,c)&&(r=!r),ie(e,n,S,c,t,l)&&(r=!r),r}function en(e,n,t){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height}function ce(e,n,t,l,i,o){const p=Math.min(t,i),E=Math.max(t,i),S=Math.min(l,o),c=Math.max(l,o);return e>=p&&e<=E&&n>=S&&n<=c}function tn(e={}){const{blockPointerEvents:n=!1}=e,t=new le,l=({x:i,y:o,placement:p,elements:E,onClose:S,nodeId:c,tree:r})=>{const O=p?.split("-")[0];let h=!1,j=null,u=null,B=typeof performance<"u"?performance.now():0;function g(a,d){const F=performance.now(),H=F-B;if(j===null||u===null||H===0)return j=a,u=d,B=F,!1;const P=a-j,C=d-u,R=P*P+C*C,M=H*H*Zt;return j=a,u=d,B=F,R<M}function x(){t.clear(),S()}return function(d){t.clear();const F=E.domReference,H=E.floating;if(!F||!H||O==null||i==null||o==null)return;const{clientX:P,clientY:C}=d,R=Re(d),M=d.type==="mouseleave",N=q(H,R),V=q(F,R);if(N&&(h=!0,!M))return;if(V&&(h=!1,!M)){h=!0;return}if(M&&$(d.relatedTarget)&&q(H,d.relatedTarget))return;function U(){return!!(r&&ve(r.nodesRef.current,c).length>0)}function _(){U()||x()}if(U())return;const w=F.getBoundingClientRect(),s=H.getBoundingClientRect(),T=i>s.right-s.width/2,L=o>s.bottom-s.height/2,b=s.width>w.width,f=s.height>w.height,A=(b?w:s).left,D=(b?w:s).right,Y=(f?w:s).top,X=(f?w:s).bottom;if(O==="top"&&o>=w.bottom-1||O==="bottom"&&o<=w.top+1||O==="left"&&i>=w.right-1||O==="right"&&i<=w.left+1){_();return}let I=!1;switch(O){case"top":I=ce(P,C,A,w.top+1,D,s.bottom-1);break;case"bottom":I=ce(P,C,A,s.top+1,D,w.bottom-1);break;case"left":I=ce(P,C,s.right-1,X,w.left+1,Y);break;case"right":I=ce(P,C,w.right-1,X,s.left+1,Y);break}if(I)return;if(h&&!en(P,C,w)){_();return}if(!M&&g(P,C)){_();return}let k=!1;switch(O){case"top":{const v=b?y/2:y*4,z=b||T?i+v:i-v,Z=b?i-v:T?i+v:i-v,K=o+y+1,ee=T||b?s.bottom-y:s.top,te=T?b?s.bottom-y:s.top:s.bottom-y;k=ae(P,C,z,K,Z,K,s.left,ee,s.right,te);break}case"bottom":{const v=b?y/2:y*4,z=b||T?i+v:i-v,Z=b?i-v:T?i+v:i-v,K=o-y,ee=T||b?s.top+y:s.bottom,te=T?b?s.top+y:s.bottom:s.top+y;k=ae(P,C,z,K,Z,K,s.left,ee,s.right,te);break}case"left":{const v=f?y/2:y*4,z=f||L?o+v:o-v,Z=f?o-v:L?o+v:o-v,K=i+y+1,ee=L||f?s.right-y:s.left,te=L?f?s.right-y:s.left:s.right-y;k=ae(P,C,ee,s.top,te,s.bottom,K,z,K,Z);break}case"right":{const v=f?y/2:y*4,z=f||L?o+v:o-v,Z=f?o-v:L?o+v:o-v,K=i-y,ee=L||f?s.left+y:s.right,te=L?f?s.left+y:s.right:s.left+y;k=ae(P,C,K,z,K,Z,ee,s.top,te,s.bottom);break}}k?h||t.start(40,_):_()}};return l.__options={...e,blockPointerEvents:n},l}const je=m.createContext(void 0);function re(e){const n=m.useContext(je);if(n===void 0&&!e)throw new Error(pe(47));return n}function nn(){return{...Nt(),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1}}const on={...Dt,disabled:W(e=>e.disabled),instantType:W(e=>e.instantType),openMethod:W(e=>e.openMethod),openChangeReason:W(e=>e.openChangeReason),modal:W(e=>e.modal),focusManagerModal:W(e=>e.focusManagerModal),stickIfOpen:W(e=>e.stickIfOpen),titleElementId:W(e=>e.titleElementId),descriptionElementId:W(e=>e.descriptionElementId),openOnHover:W(e=>e.openOnHover),closeDelay:W(e=>e.closeDelay),hasViewport:W(e=>e.hasViewport)};class Se extends qe{constructor(n,t,l=!1){const i={...nn(),...n},o=new gt;i.open&&n?.mounted===void 0&&(i.mounted=!0),i.floatingRootContext=Bt(o,t,l),super(i,{popupRef:m.createRef(),backdropRef:m.createRef(),internalBackdropRef:m.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:m.createRef(),beforeContentFocusGuardRef:m.createRef(),stickIfOpenTimeout:new le,triggerElements:o},on)}setOpen=(n,t)=>{const l=t.reason===Q,i=t.reason===Ee&&t.event.detail===0,o=!n&&(t.reason===ze||t.reason==null),p=mt(t),E=this.select("activeTriggerId");if(!n&&t.reason===Je&&t.trigger==null&&E!=null&&(t.trigger=this.context.triggerElements.getById(E)??this.select("activeTriggerElement")??void 0),this.context.onOpenChange?.(n,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(n,t);const S=()=>{const c={open:n,openChangeReason:t.reason};Et(c,n,t.trigger,p()),this.update(c)};l?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start($e,()=>{this.set("stickIfOpen",!1)}),ue.flushSync(S)):S(),i||o?this.set("instantType",i?"click":"dismiss"):t.reason===Te?this.set("instantType","focus"):this.set("instantType",void 0)};static useStore(n,t){const{store:l,internalStore:i}=ht(n,(o,p)=>new Se(t,o,p));return m.useEffect(()=>i?.disposeEffect(),[i]),l}disposeEffect=()=>this.context.stickIfOpenTimeout.disposeEffect()}function ke({props:e}){const{children:n,open:t,defaultOpen:l=!1,onOpenChange:i,onOpenChangeComplete:o,modal:p=!1,handle:E,triggerId:S,defaultTriggerId:c=null}=e,r=Se.useStore(E?.store,{modal:p,open:l,openProp:t,activeTriggerId:c,triggerIdProp:S});Pt(r,t,l,c),r.useControlledProp("openProp",t),r.useControlledProp("triggerIdProp",S);const O=r.useState("open"),h=r.useState("mounted"),j=r.useState("payload"),u=He()!=null;r.useContextCallback("onOpenChange",i),r.useContextCallback("onOpenChangeComplete",o),vt(r,O),Ct(r);const{forceUnmount:B}=Rt(O,r,()=>{r.update({stickIfOpen:!0,openChangeReason:null})});r.useSyncedValues({modal:p,nested:u}),m.useEffect(()=>{O||r.context.stickIfOpenTimeout.clear()},[r,O]);const g=m.useCallback(()=>{r.setOpen(!1,J(Ze))},[r]);m.useImperativeHandle(e.actionsRef,()=>({unmount:B,close:g}),[B,g]);const x=O||h,a=m.useMemo(()=>({store:r}),[r]);return G.jsxs(je.Provider,{value:a,children:[x&&G.jsx(sn,{store:r,modal:p}),typeof n=="function"?n({payload:j}):n]})}function Pn(e){return re(!0)?G.jsx(ke,{props:e}):G.jsx(Tt,{children:G.jsx(ke,{props:e})})}function sn({store:e,modal:n}){const t=e.useState("floatingRootContext"),l=bt(t,{outsidePressEvent:{mouse:n==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),i=l.reference??Me,o=l.trigger??Me,p=m.useMemo(()=>et(Be,l.floating),[l.floating]);return St(e,{activeTriggerProps:i,inactiveTriggerProps:o,popupProps:p}),null}const rn=300;function an(e,n){const t=m.useRef(null);function l(o){ue.flushSync(()=>{e.setOpen(!1,J(Te,o.nativeEvent,o.currentTarget))}),st(t.current)?.focus()}function i(o){const p=e.select("positionerElement");if(p&&tt(o,p))e.context.beforeContentFocusGuardRef.current?.focus();else{ue.flushSync(()=>{e.setOpen(!1,J(Te,o.nativeEvent,o.currentTarget))});let E=nt(e.context.triggerFocusTargetRef.current||n.current);for(;E!==null&&q(p,E);){const S=E;if(E=ot(E),E===S)break}E?.focus()}}return{preFocusGuardRef:t,handlePreFocusGuardFocus:l,handleFocusTargetFocus:i}}const vn=m.forwardRef(function(n,t){const{render:l,className:i,style:o,disabled:p=!1,nativeButton:E=!0,handle:S,payload:c,openOnHover:r=!1,delay:O=rn,closeDelay:h=0,id:j,...u}=n,B=re(!0),g=S?.store??B?.store;if(!g)throw new Error(pe(74));const x=Ot(j),a=g.useState("isTriggerActive",x),d=g.useState("floatingRootContext"),F=g.useState("isOpenedByTrigger",x),H=g.useState("triggerPopupId",x),P=m.useRef(null),{registerTrigger:C,isMountedByThisTrigger:R}=It(x,P,g,{payload:c,disabled:p,openOnHover:r,closeDelay:h}),M=g.useState("openChangeReason"),N=g.useState("stickIfOpen"),V=g.useState("openMethod"),U=g.useState("focusManagerModal"),_=$t(d,{enabled:!p&&d!=null&&r&&(V!=="touch"||M!==Ee),mouseOnly:!0,move:!1,handleClose:tn(),restMs:O,delay:{close:h},triggerElementRef:P,isActiveTrigger:a,isClosing:()=>g.select("transitionStatus")==="ending"}),w=_t(d,{enabled:d!=null,stickIfOpen:N}),s=jt(()=>g.select("open"),k=>{g.set("openMethod",k)}),T=g.useState("triggerProps",R),{getButtonProps:L,buttonRef:b}=rt({disabled:p,native:E}),f={open(k){return k&&M===Ee?Mt.open(k):yt.open(k)}},{preFocusGuardRef:A,handlePreFocusGuardFocus:D,handleFocusTargetFocus:Y}=an(g,P),I=Le("button",n,{state:{disabled:p,open:F},ref:[b,t,C,P],props:[w.reference,_,T,s,{[it]:"",id:x,"aria-haspopup":"dialog","aria-expanded":F,"aria-controls":H},u,L],stateAttributesMapping:f});return R&&!U?G.jsxs(m.Fragment,{children:[G.jsx(ye,{ref:A,onFocus:D}),G.jsx(m.Fragment,{children:I},x),G.jsx(ye,{ref:g.context.triggerFocusTargetRef,onFocus:Y})]}):G.jsx(m.Fragment,{children:I},x)}),Ge=m.createContext(void 0);function cn(){const e=m.useContext(Ge);if(e===void 0)throw new Error(pe(45));return e}const Cn=m.forwardRef(function(n,t){const{keepMounted:l=!1,...i}=n,{store:o}=re();return o.useState("mounted")||l?G.jsx(Ge.Provider,{value:l,children:G.jsx(at,{ref:t,...i})}):null}),Ye=m.createContext(void 0);function ln(){const e=m.useContext(Ye);if(!e)throw new Error(pe(46));return e}const Rn=m.forwardRef(function(n,t){const{render:l,className:i,style:o,anchor:p,positionMethod:E="absolute",side:S="bottom",align:c="center",sideOffset:r=0,alignOffset:O=0,collisionBoundary:h="clipping-ancestors",collisionPadding:j=5,arrowPadding:u=5,sticky:B=!1,disableAnchorTracking:g=!1,collisionAvoidance:x=ct,...a}=n,{store:d}=re(),F=cn(),H=xt(),P=d.useState("floatingRootContext"),C=d.useState("mounted"),R=d.useState("open"),M=d.useState("openChangeReason"),N=d.useState("activeTriggerElement"),V=d.useState("modal"),U=d.useState("openMethod"),_=d.useState("positionerElement"),w=d.useState("instantType"),s=d.useState("transitionStatus"),T=d.useState("hasViewport"),L=m.useRef(null),b=lt(_,!1,!1),f=Gt({anchor:p,floatingRootContext:P,positionMethod:E,mounted:C,side:S,sideOffset:r,align:c,alignOffset:O,arrowPadding:u,collisionBoundary:h,collisionPadding:j,sticky:B,disableAnchorTracking:g,keepMounted:F,nodeId:H,collisionAvoidance:x,adaptiveOrigin:T?Ut:void 0}),A=P.useState("domReferenceElement");ge(()=>{const I=A,k=L.current;if(I&&(L.current=I),k&&I&&I!==k){d.set("instantType",void 0);const v=new AbortController;return b(()=>{d.set("instantType","trigger-change")},v.signal),()=>{v.abort()}}},[A,b,d]),Yt(R&&V===!0&&M!==Q,U==="touch",_,N);const D=m.useCallback(I=>{d.set("positionerElement",I)},[d]),Y={open:R,side:f.side,align:f.align,anchorHidden:f.anchorHidden,instant:w},X=Vt(n,Y,{styles:f.positionerStyles,transitionStatus:s,props:a,refs:[t,D],hidden:!C,inert:!R});return G.jsxs(Ye.Provider,{value:f,children:[C&&V===!0&&M!==Q&&G.jsx(Ft,{ref:d.context.internalBackdropRef,inert:ut(!R),cutout:N}),G.jsx(kt,{id:H,children:X})]})}),un=m.createContext(void 0);function fn(){const[e,n]=m.useState(0),t=ne(()=>(n(i=>i+1),()=>{n(i=>Math.max(0,i-1))}));return{context:m.useMemo(()=>({register:t}),[t]),hasClosePart:e>0}}function dn(e){const{value:n,children:t}=e;return G.jsx(un.Provider,{value:n,children:t})}const pn={...Ht,...pt},bn=m.forwardRef(function(n,t){const{render:l,className:i,style:o,initialFocus:p,finalFocus:E,...S}=n,{store:c}=re(),r=ln(),O=Xt()!=null,{context:h,hasClosePart:j}=fn(),u=c.useState("open"),B=c.useState("openMethod"),g=c.useState("instantType"),x=c.useState("transitionStatus"),a=c.useState("popupProps"),d=c.useState("titleElementId"),F=c.useState("descriptionElementId"),H=c.useState("modal"),P=c.useState("mounted"),C=c.useState("openChangeReason"),R=c.useState("activeTriggerElement"),M=c.useState("floatingRootContext"),N=M.useState("floatingId"),V=c.useState("disabled"),U=c.useState("openOnHover"),_=c.useState("closeDelay"),w=S.id??N;ft({open:u,ref:c.context.popupRef,onComplete(){u&&c.context.onOpenChangeComplete?.(!0)}}),zt(M,{enabled:U&&!V,closeDelay:_});const s=p===void 0?wt(c.context.popupRef):p,T=H!==!1&&j;c.useSyncedValue("focusManagerModal",T);const L=m.useCallback(A=>{c.set("popupElement",A)},[c]),b={open:u,side:r.side,align:r.align,instant:g,transitionStatus:x},f=Le("div",n,{state:b,ref:[t,c.context.popupRef,L],props:[a,{id:w,role:"dialog",...Be,"aria-labelledby":d,"aria-describedby":F,onKeyDown(A){O&&At.has(A.key)&&A.stopPropagation()}},Kt(x),S],stateAttributesMapping:pn});return G.jsx(Lt,{context:M,openInteractionType:B,modal:T,disabled:!P||C===Q,initialFocus:s,returnFocus:E,restoreFocus:"popup",previousFocusableElement:dt(R)?R:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:G.jsx(dn,{value:h,children:f})})});export{Tn as C,Pn as P,vn as a,Cn as b,Rn as c,bn as d};
@@ -1 +0,0 @@
1
- import{d,e as m,r as t,j as e,L as l,c as o,f as x}from"./__vite-browser-external-Djkun5S2.js";function n(s,a){for(const r of a){const i=s.get(r);if(typeof i=="string"&&i.trim())return i.trim()}return""}function u(){const[s]=d(),{enabled:a}=m(),r=t.useMemo(()=>n(s,["otp","token","reset_token","insforge_token"]),[s]),i=t.useMemo(()=>n(s,["email"]),[s]),c=t.useMemo(()=>n(s,["code"]),[s]);return a?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(l,{to:"/login",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:o("reset_password.back_to_sign_in")})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-12",children:e.jsx("div",{className:"w-full max-w-md border border-oai-gray-900 bg-oai-gray-950 rounded-2xl overflow-hidden shadow-2xl",children:e.jsx(x,{hideLogo:!0,initialMode:r?"reset_confirm":"reset_email",tokenFromUrl:r,initialEmail:i,initialCode:c})})})]}):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(l,{to:"/login",className:"text-sm font-medium text-oai-gray-400 hover:text-white no-underline",children:o("reset_password.back_to_sign_in")})}),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:o("login.cloud_only")})})]})}export{u as ResetPasswordPage};
@@ -1 +0,0 @@
1
- import{k as Vr,bF as kr,r as l,ck as Nt,bx as vt,aN as qn,cs as Hr,aG as zt,A as _e,by as Ae,dj as it,dk as rn,bR as nt,cB as rt,aV as Be,dl as un,cz as Ct,cy as _t,dm as Nr,dn as Kn,dp as _r,cg as fn,cG as dn,dq as jt,dr as En,ds as Xn,a0 as Br,ch as Wr,aR as Tt,aQ as J,cl as Gn,ci as Ur,Q as ue,dt as Cn,du as Jt,dv as Tn,cp as Qt,bz as ot,aO as at,dw as An,dx as Mt,bI as Jn,dy as Yt,dz as qt,dA as Qn,dB as pn,dC as $r,cu as zr,dD as on,dE as jr,z as gt,cF as Yr,aH as It,aS as Le,j as Ie,aF as oe,O as z,aJ as gn,aU as sn,aT as qr,aW as Kr,aX as Xr,aY as mn,dF as Gr,cq as Jr,ce as Qr,y as Zn,dG as Zr,aK as eo,dH as to,aL as no,cr as ro,bB as oo,dI as so,aI as er,dJ as Zt}from"./__vite-browser-external-Djkun5S2.js";import{n as In,q as tr,F as io,P as co,o as nr,v as Ye,E as lo,G as et,H as rr,J as ao,p as or,u as uo,m as sr,h as fo,a as po,l as go,A as mo,i as ho,I as xo,d as yo,b as wo}from"./useScrollLock-DZpDnNt6.js";const Ro=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ei=Vr("chevron-down",Ro),bo=["top","right","bottom","left"],wt=Math.min,Ne=Math.max,Bt=Math.round,Ot=Math.floor,Ge=e=>({x:e,y:e}),So={left:"right",right:"left",bottom:"top",top:"bottom"};function cn(e,t,n){return Ne(e,wt(t,n))}function st(e,t){return typeof e=="function"?e(t):e}function Ve(e){return e.split("-")[0]}function ut(e){return e.split("-")[1]}function hn(e){return e==="x"?"y":"x"}function xn(e){return e==="y"?"height":"width"}function je(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function yn(e){return hn(je(e))}function vo(e,t,n){n===void 0&&(n=!1);const r=ut(e),o=yn(e),s=xn(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Wt(i)),[i,Wt(i)]}function Eo(e){const t=Wt(e);return[ln(e),t,ln(t)]}function ln(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Mn=["left","right"],On=["right","left"],Co=["top","bottom"],To=["bottom","top"];function Ao(e,t,n){switch(e){case"top":case"bottom":return n?t?On:Mn:t?Mn:On;case"left":case"right":return t?Co:To;default:return[]}}function Io(e,t,n,r){const o=ut(e);let s=Ao(Ve(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(ln)))),s}function Wt(e){const t=Ve(e);return So[t]+e.slice(t.length)}function Mo(e){return{top:0,right:0,bottom:0,left:0,...e}}function ir(e){return typeof e!="number"?Mo(e):{top:e,right:e,bottom:e,left:e}}function At(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Rt(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function Oo(e,t={}){const{enabled:n=!0,event:r="click",toggle:o=!0,ignoreMouse:s=!1,stickIfOpen:i=!0,touchOpenDelay:c=0,reason:a=kr}=t,f="rootStore"in e?e.rootStore:e,g=f.context.dataRef,u=l.useRef(void 0),d=Nt(),p=vt(),m=l.useMemo(()=>{function y(h,b,x,w){const S=_e(a,b,x);h&&w==="touch"&&c>0?p.start(c,()=>{f.setOpen(!0,S)}):f.setOpen(h,S)}function R(h,b,x){const w=g.current.openEvent,S=f.select("domReferenceElement")!==b;return h&&S||!h||!o?!0:w&&i?!x(w.type):!1}return{onPointerDown(h){u.current=h.pointerType},onMouseDown(h){const b=u.current,x=h.nativeEvent,w=f.select("open");if(h.button!==0||r==="click"||In(b,!0)&&s)return;const S=R(w,h.currentTarget,T=>T==="click"||T==="mousedown"),C=qn(x);if(Hr(C)){y(S,x,C,b);return}const P=h.currentTarget;d.request(()=>{y(S,x,P,b)})},onClick(h){if(r==="mousedown-only")return;const b=u.current;if(r==="mousedown"&&b){u.current=void 0;return}if(In(b,!0)&&s)return;const x=f.select("open"),w=R(x,h.currentTarget,S=>S==="click"||S==="mousedown"||S==="keydown"||S==="keyup");y(w,h.nativeEvent,h.currentTarget,b)},onKeyDown(){u.current=void 0}}},[g,r,s,a,f,i,o,d,p,c]);return l.useMemo(()=>n?{reference:m}:zt,[n,m])}function Pn(e,t,n){let{reference:r,floating:o}=e;const s=je(t),i=yn(t),c=xn(i),a=Ve(t),f=s==="y",g=r.x+r.width/2-o.width/2,u=r.y+r.height/2-o.height/2,d=r[c]/2-o[c]/2;let p;switch(a){case"top":p={x:g,y:r.y-o.height};break;case"bottom":p={x:g,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:u};break;case"left":p={x:r.x-o.width,y:u};break;default:p={x:r.x,y:r.y}}switch(ut(t)){case"start":p[i]-=d*(n&&f?-1:1);break;case"end":p[i]+=d*(n&&f?-1:1);break}return p}async function Po(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:c,strategy:a}=e,{boundary:f="clippingAncestors",rootBoundary:g="viewport",elementContext:u="floating",altBoundary:d=!1,padding:p=0}=st(t,e),m=ir(p),R=c[d?u==="floating"?"reference":"floating":u],h=At(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(R)))==null||n?R:R.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(c.floating)),boundary:f,rootBoundary:g,strategy:a})),b=u==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c.floating)),w=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},S=At(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:b,offsetParent:x,strategy:a}):b);return{top:(h.top-S.top+m.top)/w.y,bottom:(S.bottom-h.bottom+m.bottom)/w.y,left:(h.left-S.left+m.left)/w.x,right:(S.right-h.right+m.right)/w.x}}const Do=50,Lo=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,c=i.detectOverflow?i:{...i,detectOverflow:Po},a=await(i.isRTL==null?void 0:i.isRTL(t));let f=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:g,y:u}=Pn(f,r,a),d=r,p=0;const m={};for(let y=0;y<s.length;y++){const R=s[y];if(!R)continue;const{name:h,fn:b}=R,{x,y:w,data:S,reset:C}=await b({x:g,y:u,initialPlacement:r,placement:d,strategy:o,middlewareData:m,rects:f,platform:c,elements:{reference:e,floating:t}});g=x??g,u=w??u,m[h]={...m[h],...S},C&&p<Do&&(p++,typeof C=="object"&&(C.placement&&(d=C.placement),C.rects&&(f=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:g,y:u}=Pn(f,d,a)),y=-1)}return{x:g,y:u,placement:d,strategy:o,middlewareData:m}},Fo=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:c,platform:a,elements:f}=t,{mainAxis:g=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:y=!0,...R}=st(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const h=Ve(o),b=je(c),x=Ve(c)===c,w=await(a.isRTL==null?void 0:a.isRTL(f.floating)),S=d||(x||!y?[Wt(c)]:Eo(c)),C=m!=="none";!d&&C&&S.push(...Io(c,y,m,w));const P=[c,...S],T=await a.detectOverflow(t,R),L=[];let _=((r=s.flip)==null?void 0:r.overflows)||[];if(g&&L.push(T[h]),u){const I=vo(o,i,w);L.push(T[I[0]],T[I[1]])}if(_=[..._,{placement:o,overflows:L}],!L.every(I=>I<=0)){var X,B;const I=(((X=s.flip)==null?void 0:X.index)||0)+1,H=P[I];if(H&&(!(u==="alignment"?b!==je(H):!1)||_.every(E=>je(E.placement)===b?E.overflows[0]>0:!0)))return{data:{index:I,overflows:_},reset:{placement:H}};let Y=(B=_.filter(F=>F.overflows[0]<=0).sort((F,E)=>F.overflows[1]-E.overflows[1])[0])==null?void 0:B.placement;if(!Y)switch(p){case"bestFit":{var k;const F=(k=_.filter(E=>{if(C){const W=je(E.placement);return W===b||W==="y"}return!0}).map(E=>[E.placement,E.overflows.filter(W=>W>0).reduce((W,A)=>W+A,0)]).sort((E,W)=>E[1]-W[1])[0])==null?void 0:k[0];F&&(Y=F);break}case"initialPlacement":Y=c;break}if(o!==Y)return{reset:{placement:Y}}}return{}}}};function Dn(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ln(e){return bo.some(t=>e[t]>=0)}const Vo=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...s}=st(e,t);switch(o){case"referenceHidden":{const i=await r.detectOverflow(t,{...s,elementContext:"reference"}),c=Dn(i,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:Ln(c)}}}case"escaped":{const i=await r.detectOverflow(t,{...s,altBoundary:!0}),c=Dn(i,n.floating);return{data:{escapedOffsets:c,escaped:Ln(c)}}}default:return{}}}}},cr=new Set(["left","top"]);async function ko(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Ve(n),c=ut(n),a=je(n)==="y",f=cr.has(i)?-1:1,g=s&&a?-1:1,u=st(t,e);let{mainAxis:d,crossAxis:p,alignmentAxis:m}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return c&&typeof m=="number"&&(p=c==="end"?m*-1:m),a?{x:p*g,y:d*f}:{x:d*f,y:p*g}}const Ho=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:c}=t,a=await ko(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:o+a.x,y:s+a.y,data:{...a,placement:i}}}}},No=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:s}=t,{mainAxis:i=!0,crossAxis:c=!1,limiter:a={fn:h=>{let{x:b,y:x}=h;return{x:b,y:x}}},...f}=st(e,t),g={x:n,y:r},u=await s.detectOverflow(t,f),d=je(Ve(o)),p=hn(d);let m=g[p],y=g[d];if(i){const h=p==="y"?"top":"left",b=p==="y"?"bottom":"right",x=m+u[h],w=m-u[b];m=cn(x,m,w)}if(c){const h=d==="y"?"top":"left",b=d==="y"?"bottom":"right",x=y+u[h],w=y-u[b];y=cn(x,y,w)}const R=a.fn({...t,[p]:m,[d]:y});return{...R,data:{x:R.x-n,y:R.y-r,enabled:{[p]:i,[d]:c}}}}}},_o=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:c=0,mainAxis:a=!0,crossAxis:f=!0}=st(e,t),g={x:n,y:r},u=je(o),d=hn(u);let p=g[d],m=g[u];const y=st(c,t),R=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(a){const x=d==="y"?"height":"width",w=s.reference[d]-s.floating[x]+R.mainAxis,S=s.reference[d]+s.reference[x]-R.mainAxis;p<w?p=w:p>S&&(p=S)}if(f){var h,b;const x=d==="y"?"width":"height",w=cr.has(Ve(o)),S=s.reference[u]-s.floating[x]+(w&&((h=i.offset)==null?void 0:h[u])||0)+(w?0:R.crossAxis),C=s.reference[u]+s.reference[x]+(w?0:((b=i.offset)==null?void 0:b[u])||0)-(w?R.crossAxis:0);m<S?m=S:m>C&&(m=C)}return{[d]:p,[u]:m}}}},Bo=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:c}=t,{apply:a=()=>{},...f}=st(e,t),g=await i.detectOverflow(t,f),u=Ve(o),d=ut(o),p=je(o)==="y",{width:m,height:y}=s.floating;let R,h;u==="top"||u==="bottom"?(R=u,h=d===(await(i.isRTL==null?void 0:i.isRTL(c.floating))?"start":"end")?"left":"right"):(h=u,R=d==="end"?"top":"bottom");const b=y-g.top-g.bottom,x=m-g.left-g.right,w=wt(y-g[R],b),S=wt(m-g[h],x),C=!t.middlewareData.shift;let P=w,T=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(T=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(P=b),C&&!d){const _=Ne(g.left,0),X=Ne(g.right,0),B=Ne(g.top,0),k=Ne(g.bottom,0);p?T=m-2*(_!==0||X!==0?_+X:Ne(g.left,g.right)):P=y-2*(B!==0||k!==0?B+k:Ne(g.top,g.bottom))}await a({...t,availableWidth:T,availableHeight:P});const L=await i.getDimensions(c.floating);return m!==L.width||y!==L.height?{reset:{rects:!0}}:{}}}};function lr(e){const t=rt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=nt(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,c=Bt(n)!==s||Bt(r)!==i;return c&&(n=s,r=i),{width:n,height:r,$:c}}function wn(e){return Ae(e)?e:e.contextElement}function yt(e){const t=wn(e);if(!nt(t))return Ge(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=lr(t);let i=(s?Bt(n.width):n.width)/r,c=(s?Bt(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const Wo=Ge(0);function ar(e){const t=Be(e);return!Xn()||!t.visualViewport?Wo:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Uo(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Be(e)?!1:t}function dt(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=wn(e);let i=Ge(1);t&&(r?Ae(r)&&(i=yt(r)):i=yt(e));const c=Uo(s,n,r)?ar(s):Ge(0);let a=(o.left+c.x)/i.x,f=(o.top+c.y)/i.y,g=o.width/i.x,u=o.height/i.y;if(s){const d=Be(s),p=r&&Ae(r)?Be(r):r;let m=d,y=En(m);for(;y&&r&&p!==m;){const R=yt(y),h=y.getBoundingClientRect(),b=rt(y),x=h.left+(y.clientLeft+parseFloat(b.paddingLeft))*R.x,w=h.top+(y.clientTop+parseFloat(b.paddingTop))*R.y;a*=R.x,f*=R.y,g*=R.x,u*=R.y,a+=x,f+=w,m=Be(y),y=En(m)}}return At({width:g,height:u,x:a,y:f})}function Kt(e,t){const n=jt(e).scrollLeft;return t?t.left+n:dt(it(e)).left+n}function ur(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Kt(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function $o(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=it(r),c=t?un(t.floating):!1;if(r===i||c&&s)return n;let a={scrollLeft:0,scrollTop:0},f=Ge(1);const g=Ge(0),u=nt(r);if((u||!u&&!s)&&((fn(r)!=="body"||dn(i))&&(a=jt(r)),u)){const p=dt(r);f=yt(r),g.x=p.x+r.clientLeft,g.y=p.y+r.clientTop}const d=i&&!u&&!s?ur(i,a):Ge(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-a.scrollLeft*f.x+g.x+d.x,y:n.y*f.y-a.scrollTop*f.y+g.y+d.y}}function zo(e){return Array.from(e.getClientRects())}function jo(e){const t=it(e),n=jt(e),r=e.ownerDocument.body,o=Ne(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ne(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Kt(e);const c=-n.scrollTop;return rt(r).direction==="rtl"&&(i+=Ne(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:c}}const Fn=25;function Yo(e,t){const n=Be(e),r=it(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,c=0,a=0;if(o){s=o.width,i=o.height;const g=Xn();(!g||g&&t==="fixed")&&(c=o.offsetLeft,a=o.offsetTop)}const f=Kt(r);if(f<=0){const g=r.ownerDocument,u=g.body,d=getComputedStyle(u),p=g.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,m=Math.abs(r.clientWidth-u.clientWidth-p);m<=Fn&&(s-=m)}else f<=Fn&&(s+=f);return{width:s,height:i,x:c,y:a}}function qo(e,t){const n=dt(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=nt(e)?yt(e):Ge(1),i=e.clientWidth*s.x,c=e.clientHeight*s.y,a=o*s.x,f=r*s.y;return{width:i,height:c,x:a,y:f}}function Vn(e,t,n){let r;if(t==="viewport")r=Yo(e,n);else if(t==="document")r=jo(it(e));else if(Ae(t))r=qo(t,n);else{const o=ar(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return At(r)}function fr(e,t){const n=Ct(e);return n===t||!Ae(n)||_t(n)?!1:rt(n).position==="fixed"||fr(n,t)}function Ko(e,t){const n=t.get(e);if(n)return n;let r=rn(e,[],!1).filter(c=>Ae(c)&&fn(c)!=="body"),o=null;const s=rt(e).position==="fixed";let i=s?Ct(e):e;for(;Ae(i)&&!_t(i);){const c=rt(i),a=Kn(i);!a&&c.position==="fixed"&&(o=null),(s?!a&&!o:!a&&c.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||dn(i)&&!a&&fr(e,i))?r=r.filter(g=>g!==i):o=c,i=Ct(i)}return t.set(e,r),r}function Xo(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?un(t)?[]:Ko(t,this._c):[].concat(n),r],c=Vn(t,i[0],o);let a=c.top,f=c.right,g=c.bottom,u=c.left;for(let d=1;d<i.length;d++){const p=Vn(t,i[d],o);a=Ne(p.top,a),f=wt(p.right,f),g=wt(p.bottom,g),u=Ne(p.left,u)}return{width:f-u,height:g-a,x:u,y:a}}function Go(e){const{width:t,height:n}=lr(e);return{width:t,height:n}}function Jo(e,t,n){const r=nt(t),o=it(t),s=n==="fixed",i=dt(e,!0,s,t);let c={scrollLeft:0,scrollTop:0};const a=Ge(0);function f(){a.x=Kt(o)}if(r||!r&&!s)if((fn(t)!=="body"||dn(o))&&(c=jt(t)),r){const p=dt(t,!0,s,t);a.x=p.x+t.clientLeft,a.y=p.y+t.clientTop}else o&&f();s&&!r&&o&&f();const g=o&&!r&&!s?ur(o,c):Ge(0),u=i.left+c.scrollLeft-a.x-g.x,d=i.top+c.scrollTop-a.y-g.y;return{x:u,y:d,width:i.width,height:i.height}}function en(e){return rt(e).position==="static"}function kn(e,t){if(!nt(e)||rt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return it(e)===n&&(n=n.ownerDocument.body),n}function dr(e,t){const n=Be(e);if(un(e))return n;if(!nt(e)){let o=Ct(e);for(;o&&!_t(o);){if(Ae(o)&&!en(o))return o;o=Ct(o)}return n}let r=kn(e,t);for(;r&&Nr(r)&&en(r);)r=kn(r,t);return r&&_t(r)&&en(r)&&!Kn(r)?n:r||_r(e)||n}const Qo=async function(e){const t=this.getOffsetParent||dr,n=this.getDimensions,r=await n(e.floating);return{reference:Jo(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Zo(e){return rt(e).direction==="rtl"}const pr={convertOffsetParentRelativeRectToViewportRelativeRect:$o,getDocumentElement:it,getClippingRect:Xo,getOffsetParent:dr,getElementRects:Qo,getClientRects:zo,getDimensions:Go,getScale:yt,isElement:Ae,isRTL:Zo};function gr(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function es(e,t){let n=null,r;const o=it(e);function s(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function i(c,a){c===void 0&&(c=!1),a===void 0&&(a=1),s();const f=e.getBoundingClientRect(),{left:g,top:u,width:d,height:p}=f;if(c||t(),!d||!p)return;const m=Ot(u),y=Ot(o.clientWidth-(g+d)),R=Ot(o.clientHeight-(u+p)),h=Ot(g),x={rootMargin:-m+"px "+-y+"px "+-R+"px "+-h+"px",threshold:Ne(0,wt(1,a))||1};let w=!0;function S(C){const P=C[0].intersectionRatio;if(P!==a){if(!w)return i();P?i(!1,P):r=setTimeout(()=>{i(!1,1e-7)},1e3)}P===1&&!gr(f,e.getBoundingClientRect())&&i(),w=!1}try{n=new IntersectionObserver(S,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,x)}n.observe(e)}return i(!0),s}function Hn(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,f=wn(e),g=o||s?[...f?rn(f):[],...t?rn(t):[]]:[];g.forEach(h=>{o&&h.addEventListener("scroll",n,{passive:!0}),s&&h.addEventListener("resize",n)});const u=f&&c?es(f,n):null;let d=-1,p=null;i&&(p=new ResizeObserver(h=>{let[b]=h;b&&b.target===f&&p&&t&&(p.unobserve(t),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var x;(x=p)==null||x.observe(t)})),n()}),f&&!a&&p.observe(f),t&&p.observe(t));let m,y=a?dt(e):null;a&&R();function R(){const h=dt(e);y&&!gr(y,h)&&n(),y=h,m=requestAnimationFrame(R)}return n(),()=>{var h;g.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),u?.(),(h=p)==null||h.disconnect(),p=null,a&&cancelAnimationFrame(m)}}const ts=Ho,ns=No,rs=Fo,os=Bo,ss=Vo,is=_o,cs=(e,t,n)=>{const r=new Map,o={platform:pr,...n},s={...o.platform,_c:r};return Lo(e,t,{...o,platform:s})};var ls=typeof document<"u",as=function(){},kt=ls?l.useLayoutEffect:as;function Ut(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Ut(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Ut(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function mr(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Nn(e,t){const n=mr(e);return Math.round(t*n)/n}function tn(e){const t=l.useRef(e);return kt(()=>{t.current=e}),t}function us(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:c=!0,whileElementsMounted:a,open:f}=e,[g,u]=l.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[d,p]=l.useState(r);Ut(d,r)||p(r);const[m,y]=l.useState(null),[R,h]=l.useState(null),b=l.useCallback(E=>{E!==C.current&&(C.current=E,y(E))},[]),x=l.useCallback(E=>{E!==P.current&&(P.current=E,h(E))},[]),w=s||m,S=i||R,C=l.useRef(null),P=l.useRef(null),T=l.useRef(g),L=a!=null,_=tn(a),X=tn(o),B=tn(f),k=l.useCallback(()=>{if(!C.current||!P.current)return;const E={placement:t,strategy:n,middleware:d};X.current&&(E.platform=X.current),cs(C.current,P.current,E).then(W=>{const A={...W,isPositioned:B.current!==!1};I.current&&!Ut(T.current,A)&&(T.current=A,Br.flushSync(()=>{u(A)}))})},[d,t,n,X,B]);kt(()=>{f===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,u(E=>({...E,isPositioned:!1})))},[f]);const I=l.useRef(!1);kt(()=>(I.current=!0,()=>{I.current=!1}),[]),kt(()=>{if(w&&(C.current=w),S&&(P.current=S),w&&S){if(_.current)return _.current(w,S,k);k()}},[w,S,k,_,L]);const H=l.useMemo(()=>({reference:C,floating:P,setReference:b,setFloating:x}),[b,x]),Y=l.useMemo(()=>({reference:w,floating:S}),[w,S]),F=l.useMemo(()=>{const E={position:n,left:0,top:0};if(!Y.floating)return E;const W=Nn(Y.floating,g.x),A=Nn(Y.floating,g.y);return c?{...E,transform:"translate("+W+"px, "+A+"px)",...mr(Y.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:W,top:A}},[n,c,Y.floating,g.x,g.y]);return l.useMemo(()=>({...g,update:k,refs:H,elements:Y,floatingStyles:F}),[g,k,H,Y,F])}const fs=(e,t)=>{const n=ts(e);return{name:n.name,fn:n.fn,options:[e,t]}},ds=(e,t)=>{const n=ns(e);return{name:n.name,fn:n.fn,options:[e,t]}},ps=(e,t)=>({fn:is(e).fn,options:[e,t]}),gs=(e,t)=>{const n=rs(e);return{name:n.name,fn:n.fn,options:[e,t]}},ms=(e,t)=>{const n=os(e);return{name:n.name,fn:n.fn,options:[e,t]}},hs=(e,t)=>{const n=ss(e);return{name:n.name,fn:n.fn,options:[e,t]}};function hr(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,o=Wr(),s=tr()!=null,i=Tt(()=>new io({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new co,floatingId:o,syncOnly:!1,nested:s})).current;return J(()=>{const c={open:t,floatingId:o};r.reference!==void 0&&(c.referenceElement=r.reference,c.domReferenceElement=Ae(r.reference)?r.reference:null),r.floating!==void 0&&(c.floatingElement=r.floating),i.update(c)},[t,o,r.reference,r.floating,i]),i.context.onOpenChange=n,i.context.nested=s,i}function xs(e={}){const{nodeId:t,externalTree:n}=e,r=hr(e),o=e.rootContext||r,s=o.useState("referenceElement"),i=o.useState("floatingElement"),c=o.useState("domReferenceElement"),a=o.useState("open"),f=o.useState("floatingId"),[g,u]=l.useState(null),[d,p]=l.useState(void 0),[m,y]=l.useState(void 0),R=l.useRef(null),h=nr(n),b=l.useMemo(()=>({reference:s,floating:i,domReference:c}),[s,i,c]),x=us({...e,elements:{...b,...g&&{reference:g}}}),w=Ae(d)?d:null,S=m===void 0?o.state.floatingElement:m;o.useSyncedValue("referenceElement",d??null),o.useSyncedValue("domReferenceElement",d===void 0?c:w),o.useSyncedValue("floatingElement",S);const C=l.useCallback(B=>{const k=Ae(B)?{getBoundingClientRect:()=>B.getBoundingClientRect(),getClientRects:()=>B.getClientRects(),contextElement:B}:B;u(k),x.refs.setReference(k)},[x.refs]),P=l.useCallback(B=>{(Ae(B)||B===null)&&(R.current=B,p(B)),(Ae(x.refs.reference.current)||x.refs.reference.current===null||B!==null&&!Ae(B))&&x.refs.setReference(B)},[x.refs,p]),T=l.useCallback(B=>{y(B),x.refs.setFloating(B)},[x.refs]),L=l.useMemo(()=>({...x.refs,setReference:P,setFloating:T,setPositionReference:C,domReference:R}),[x.refs,P,T,C]),_=l.useMemo(()=>({...x.elements,domReference:c}),[x.elements,c]),X=l.useMemo(()=>({...x,dataRef:o.context.dataRef,open:a,onOpenChange:o.setOpen,events:o.context.events,floatingId:f,refs:L,elements:_,nodeId:t,rootStore:o}),[x,L,_,t,o,a,f]);return J(()=>{c&&(R.current=c)},[c]),J(()=>{o.context.dataRef.current.floatingContext=X;const B=h?.nodesRef.current.find(k=>k.id===t);B&&(B.context=X)}),l.useMemo(()=>({...x,context:X,refs:L,elements:_,rootStore:o}),[x,L,_,X,o])}const ys="Escape";function Xt(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Pt(e,t){return Xt(t,e===Qn||e===pn,e===Yt||e===qt)}function nn(e,t,n){return Xt(t,e===pn,n?e===Yt:e===qt)||e==="Enter"||e===" "||e===""}function ws(e,t,n){return Xt(t,n?e===Yt:e===qt,e===pn)}function Rs(e,t,n,r){const o=n?e===qt:e===Yt,s=e===Qn;return t==="both"||t==="horizontal"&&r?e===ys:Xt(t,o,s)}function bs(e,t){const{listRef:n,activeIndex:r,onNavigate:o=()=>{},enabled:s=!0,selectedIndex:i=null,allowEscape:c=!1,loopFocus:a=!1,nested:f=!1,rtl:g=!1,virtual:u=!1,focusItemOnOpen:d="auto",focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:y=void 0,orientation:R="vertical",parentOrientation:h,id:b,resetOnPointerLeave:x=!0,externalTree:w,grid:S}=t,C=S!=null,P="rootStore"in e?e.rootStore:e,T=P.useState("open"),L=P.useState("floatingElement"),_=P.useState("domReferenceElement"),X=P.context.dataRef,B=Gn(L),k=Ur(_),I=Ye(B),H=tr(),Y=nr(w),F=l.useRef(d),E=l.useRef(i??-1),W=l.useRef(null),A=l.useRef(!0),v=ue(M=>{o(E.current===-1?null:E.current,M)}),N=l.useRef(!!L),me=l.useRef(T),q=l.useRef(!1),ye=l.useRef(!1),he=l.useRef(null),O=Ye(y),j=Ye(T),le=Ye(i),Ce=Ye(x),Q=Nt(),ne=Nt(),se=ue(()=>{function M(G){u?Y?.events.emit("virtualfocus",G):he.current=lo(G,{sync:q.current,preventScroll:!0})}const D=n.current[E.current],Z=ye.current;D&&M(D),(q.current?G=>G():G=>Q.request(G))(()=>{const G=n.current[E.current]||D;if(!G)return;D||M(G),we&&(Z||!A.current)&&G.scrollIntoView?.({block:"nearest",inline:"nearest"})})});J(()=>{X.current.orientation=R},[X,R]),J(()=>{s&&(T&&L?(E.current=i??-1,F.current&&i!=null&&(ye.current=!0,v())):N.current&&(E.current=-1,v()))},[s,T,L,i,v]),J(()=>{if(s){if(!T){q.current=!1;return}if(L)if(r==null){if(q.current=!1,le.current!=null)return;if(N.current&&(E.current=-1,se()),(!me.current||!N.current)&&F.current&&(W.current!=null||F.current===!0&&W.current==null)){let M=0;const D=()=>{n.current[0]==null?(M<2&&(M?V=>ne.request(V):queueMicrotask)(D),M+=1):(E.current=W.current==null||nn(W.current,R,g)||f?Jt(n):Tn(n),W.current=null,v())};D()}}else Cn(n.current,r)||(E.current=r,se(),ye.current=!1)}},[s,T,L,r,le,f,n,R,g,v,se,ne]),J(()=>{if(!s||L||!Y||u||!N.current)return;const M=Y.nodesRef.current,D=M.find(G=>G.id===H)?.context?.elements.floating,Z=Qt(ot(_??D??null)),V=M.some(G=>G.context&&at(G.context.elements.floating,Z));D&&!V&&A.current&&D.focus({preventScroll:!0})},[s,L,_,Y,H,u]),J(()=>{me.current=T,N.current=!!L}),J(()=>{T||(W.current=null,F.current=d)},[T,d]);const Se=r!=null,fe=ue(M=>{if(!j.current)return;const D=n.current.indexOf(M.currentTarget);D!==-1&&(E.current!==D||r!==D)&&(E.current=D,v(M))}),de=ue(()=>h??Y?.nodesRef.current.find(M=>M.id===H)?.context?.dataRef?.current.orientation),xe=ue(()=>Jt(n,O.current)),te=ue(M=>{if(A.current=!1,q.current=!0,M.which===229||!j.current&&M.currentTarget===I.current)return;if(f&&Rs(M.key,R,g,C)){Pt(M.key,de())||et(M),P.setOpen(!1,_e(An,M.nativeEvent)),nt(_)&&(u?Y?.events.emit("virtualfocus",_):_.focus());return}const D=E.current,Z=Jt(n,y),V=Tn(n,y);if(k||(M.key==="Home"&&(et(M),E.current=Z,v(M)),M.key==="End"&&(et(M),E.current=V,v(M))),S!=null){const G=S(M,E.current,n,R,a,g,y,Z,V);if(G!=null&&(E.current=G,v(M)),R==="both")return}if(Pt(M.key,R)){if(et(M),T&&!u&&Qt(M.currentTarget.ownerDocument)===M.currentTarget){E.current=nn(M.key,R,g)?Z:V,v(M);return}nn(M.key,R,g)?a?D>=V?c&&D!==n.current.length?E.current=-1:(q.current=!1,E.current=Z):E.current=Mt(n.current,{startingIndex:D,disabledIndices:y}):E.current=Math.min(V,Mt(n.current,{startingIndex:D,disabledIndices:y})):a?D<=Z?c&&D!==-1?E.current=n.current.length:(q.current=!1,E.current=V):E.current=Mt(n.current,{startingIndex:D,decrement:!0,disabledIndices:y}):E.current=Math.max(Z,Mt(n.current,{startingIndex:D,decrement:!0,disabledIndices:y})),Cn(n.current,E.current)&&(E.current=-1),v(M)}}),we=l.useMemo(()=>({onFocus(D){q.current=!0,fe(D)},onClick:({currentTarget:D})=>D.focus({preventScroll:!0}),onMouseMove(D){q.current=!0,ye.current=!1,p&&fe(D)},onPointerLeave(D){if(!j.current||!A.current||D.pointerType==="touch")return;q.current=!0;const Z=D.relatedTarget;if(!(!p||n.current.includes(Z))&&Ce.current&&(he.current?.(),he.current=null,E.current=-1,v(D),!u)){const V=I.current,G=Qt(ot(V));V&&at(V,G)&&V.focus({preventScroll:!0})}}}),[fe,j,I,p,n,v,Ce,u]),ce=l.useMemo(()=>u&&T&&Se&&{"aria-activedescendant":`${b}-${r}`},[u,T,Se,b,r]),ie=l.useMemo(()=>({"aria-orientation":R==="both"?void 0:R,...k?{}:ce,onKeyDown(M){if(M.key==="Tab"&&M.shiftKey&&T&&!u){const D=qn(M.nativeEvent);if(D&&!at(I.current,D))return;et(M),P.setOpen(!1,_e(Jn,M.nativeEvent)),nt(_)&&_.focus();return}te(M)},onPointerMove(){A.current=!0}}),[ce,te,I,R,k,P,T,u,_]),re=l.useMemo(()=>{function M(V){P.setOpen(!0,_e(An,V.nativeEvent,V.currentTarget))}function D(V){d==="auto"&&rr(V.nativeEvent)&&(F.current=!u)}function Z(V){F.current=d,d==="auto"&&ao(V.nativeEvent)&&(F.current=!0)}return{onKeyDown(V){const G=P.select("open");A.current=!1;const ke=V.key.startsWith("Arrow"),We=ws(V.key,de(),g),Me=Pt(V.key,R),Fe=(f?We:Me)||V.key==="Enter"||V.key.trim()==="";if(u&&G)return te(V);if(!(!G&&!m&&ke)){if(Fe){const ae=Pt(V.key,de());W.current=f&&ae?null:V.key}if(f){We&&(et(V),G?(E.current=xe(),v(V)):M(V));return}Me&&(le.current!=null&&(E.current=le.current),et(V),!G&&m?M(V):te(V),G&&v(V))}},onFocus(V){P.select("open")&&!u&&(E.current=-1,v(V))},onPointerDown:Z,onPointerEnter:Z,onMouseDown:D,onClick:D}},[te,d,xe,f,v,P,m,R,de,g,le,u]),$=l.useMemo(()=>({...ce,...re}),[ce,re]);return l.useMemo(()=>s?{reference:$,floating:ie,item:we,trigger:re}:{},[s,$,ie,re,we])}function Ss(e,t){const{listRef:n,elementsRef:r,activeIndex:o,onMatch:s,disabledIndices:i,onTyping:c,enabled:a=!0,resetMs:f=750,selectedIndex:g=null}=t,u="rootStore"in e?e.rootStore:e,d=u.useState("open"),p=vt(),m=l.useRef(""),y=l.useRef(g??o??-1),R=l.useRef(null),h=ue(w=>{function S(I){const H=r?.current[I];return!H||zr(H)}function C(I){return S(I)?i==null||!$r(on,I,i):!1}function P(I,H,Y=0){if(I.length===0)return-1;const F=(Y%I.length+I.length)%I.length,E=H.toLowerCase();for(let W=0;W<I.length;W+=1){const A=(F+W)%I.length;if(!(!I[A]?.toLowerCase().startsWith(E)||!C(A)))return A}return-1}const T=n.current;if(m.current.length>0&&w.key===" "&&(et(w),c?.(!0)),m.current.length>0&&m.current[0]!==" "&&P(T,m.current)===-1&&w.key!==" "&&c?.(!1),T==null||w.key.length!==1||w.ctrlKey||w.metaKey||w.altKey)return;d&&w.key!==" "&&(et(w),c?.(!0));const L=m.current==="";L&&(y.current=g??o??-1),T.every((I,H)=>I&&C(H)?I[0]?.toLowerCase()!==I[1]?.toLowerCase():!0)&&m.current===w.key&&(m.current="",y.current=R.current),m.current+=w.key,p.start(f,()=>{m.current="",y.current=R.current,c?.(!1)});const B=((L?g??o??-1:y.current)??0)+1,k=P(T,m.current,B);k!==-1?(s?.(k),R.current=k):w.key!==" "&&(m.current="",c?.(!1))}),b=ue(w=>{const S=w.relatedTarget,C=u.select("domReferenceElement"),P=u.select("floatingElement");at(C,S)||at(P,S)||(p.clear(),m.current="",y.current=R.current,c?.(!1))});J(()=>{!d&&g!==null||(p.clear(),R.current=null,m.current!==""&&(m.current=""))},[d,g,p]),J(()=>{d&&m.current===""&&(y.current=g??o??-1)},[d,g,o]);const x=l.useMemo(()=>({onKeyDown:h,onBlur:b}),[h,b]);return l.useMemo(()=>a?{reference:x,floating:x}:{},[a,x])}const vs=l.createContext(void 0);function xr(){return l.useContext(vs)?.direction??"ltr"}const Es=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:c,middlewareData:a}=t,{element:f,padding:g=0,offsetParent:u="real"}=st(e,t)||{};if(f==null)return{};const d=ir(g),p={x:n,y:r},m=yn(o),y=xn(m),R=await i.getDimensions(f),h=m==="y",b=h?"top":"left",x=h?"bottom":"right",w=h?"clientHeight":"clientWidth",S=s.reference[y]+s.reference[m]-p[m]-s.floating[y],C=p[m]-s.reference[m],P=u==="real"?await i.getOffsetParent?.(f):c.floating;let T=c.floating[w]||s.floating[y];(!T||!await i.isElement?.(P))&&(T=c.floating[w]||s.floating[y]);const L=S/2-C/2,_=T/2-R[y]/2-1,X=Math.min(d[b],_),B=Math.min(d[x],_),k=X,I=T-R[y]-B,H=T/2-R[y]/2+L,Y=cn(k,H,I),F=!a.arrow&&ut(o)!=null&&H!==Y&&s.reference[y]/2-(H<k?X:B)-R[y]/2<0,E=F?H<k?H-k:H-I:0;return{[m]:p[m]+E,data:{[m]:Y,centerOffset:H-Y-E,...F&&{alignmentOffset:E}},reset:F}}}),Cs=(e,t)=>({...Es(e),options:[e,t]}),Ts=hs().fn,As={name:"hide",async fn(e){const{width:t,height:n,x:r,y:o}=e.rects.reference,s=t===0&&n===0&&r===0&&o===0;return{data:{referenceHidden:(await Ts(e)).data?.referenceHidden||s}}}},Ht={sideX:"left",sideY:"top"},Ci={name:"adaptiveOrigin",async fn(e){const{x:t,y:n,rects:{floating:r},elements:{floating:o},platform:s,strategy:i,placement:c}=e,a=Be(o),f=a.getComputedStyle(o);if(!(f.transitionDuration!=="0s"&&f.transitionDuration!==""))return{x:t,y:n,data:Ht};const u=await s.getOffsetParent?.(o);let d={width:0,height:0};if(i==="fixed"&&a?.visualViewport)d={width:a.visualViewport.width,height:a.visualViewport.height};else if(u===a){const b=ot(o);d={width:b.documentElement.clientWidth,height:b.documentElement.clientHeight}}else await s.isElement?.(u)&&(d=await s.getDimensions(u));const p=Ve(c);let m=t,y=n;p==="left"&&(m=d.width-(t+r.width)),p==="top"&&(y=d.height-(n+r.height));const R=p==="left"?"right":Ht.sideX,h=p==="top"?"bottom":Ht.sideY;return{x:m,y,data:{sideX:R,sideY:h}}}};function yr(e,t,n){const r=e==="inline-start"||e==="inline-end";return{top:"top",right:r?n?"inline-start":"inline-end":"right",bottom:"bottom",left:r?n?"inline-end":"inline-start":"left"}[t]}function _n(e,t,n){const{rects:r,placement:o}=e;return{side:yr(t,Ve(o),n),align:ut(o)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function Is(e){const{anchor:t,positionMethod:n="absolute",side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,collisionBoundary:c,collisionPadding:a=5,sticky:f=!1,arrowPadding:g=5,disableAnchorTracking:u=!1,inline:d,keepMounted:p=!1,floatingRootContext:m,mounted:y,collisionAvoidance:R,shiftCrossAxis:h=!1,nodeId:b,adaptiveOrigin:x,lazyFlip:w=!1,externalTree:S}=e,[C,P]=l.useState(null);!y&&C!==null&&P(null);const T=R.side||"flip",L=R.align||"flip",_=R.fallbackAxisSide||"end",X=typeof t=="function"?t:void 0,B=ue(X),k=X?B:t,I=Ye(t),H=Ye(y),F=xr()==="rtl",E=C||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":F?"left":"right","inline-start":F?"right":"left"}[r],W=s==="center"?E:`${E}-${s}`;let A=a;const v=1,N=r==="bottom"?v:0,me=r==="top"?v:0,q=r==="right"?v:0,ye=r==="left"?v:0;typeof A=="number"?A={top:A+N,right:A+ye,bottom:A+me,left:A+q}:A&&(A={top:(A.top||0)+N,right:(A.right||0)+ye,bottom:(A.bottom||0)+me,left:(A.left||0)+q});const he={boundary:c==="clipping-ancestors"?"clippingAncestors":c,padding:A},O=l.useRef(null),j=Ye(o),le=Ye(i),Ce=typeof o!="function"?o:0,Q=typeof i!="function"?i:0,ne=[];d&&ne.push(d),ne.push(fs(ee=>{const pe=_n(ee,r,F),ve=typeof j.current=="function"?j.current(pe):j.current,be=typeof le.current=="function"?le.current(pe):le.current;return{mainAxis:ve,crossAxis:be,alignmentAxis:be}},[Ce,Q,F,r]));const se=L==="none"&&T!=="shift",Se=!se&&(f||h||T==="shift"),fe=T==="none"?null:gs({...he,padding:{top:A.top+v,right:A.right+v,bottom:A.bottom+v,left:A.left+v},mainAxis:!h&&T==="flip",crossAxis:L==="flip"?"alignment":!1,fallbackAxisSideDirection:_}),de=se?null:ds(ee=>{const pe=ot(ee.elements.floating).documentElement;return{...he,rootBoundary:h?{x:0,y:0,width:pe.clientWidth,height:pe.clientHeight}:void 0,mainAxis:L!=="none",crossAxis:Se,limiter:f||h?void 0:ps(ve=>{if(!O.current)return{};const{width:be,height:Te}=O.current.getBoundingClientRect(),Re=je(Ve(ve.placement)),Oe=Re==="y"?be:Te,ze=Re==="y"?A.left+A.right:A.top+A.bottom;return{offset:Oe/2+ze/2}})}},[he,f,h,A,L]);T==="shift"||L==="shift"||s==="center"?ne.push(de,fe):ne.push(fe,de),ne.push(ms({...he,apply({elements:{floating:ee},availableWidth:pe,availableHeight:ve,rects:be}){if(!H.current)return;const Te=ee.style;Te.setProperty("--available-width",`${pe}px`),Te.setProperty("--available-height",`${ve}px`);const Re=Be(ee).devicePixelRatio||1,{x:Oe,y:ze,width:qe,height:ct}=be.reference,Pe=(Math.round((Oe+qe)*Re)-Math.round(Oe*Re))/Re,Ke=(Math.round((ze+ct)*Re)-Math.round(ze*Re))/Re;Te.setProperty("--anchor-width",`${Pe}px`),Te.setProperty("--anchor-height",`${Ke}px`)}}),Cs(ee=>({element:O.current||ot(ee.elements.floating).createElement("div"),padding:g,offsetParent:"floating"}),[g]),{name:"transformOrigin",fn(ee){const{elements:pe,middlewareData:ve,placement:be,rects:Te,y:Re}=ee,Oe=Ve(be),ze=je(Oe),qe=O.current,ct=ve.arrow?.x||0,Pe=ve.arrow?.y||0,Ke=qe?.clientWidth||0,ht=qe?.clientHeight||0,lt=ct+Ke/2,xt=Pe+ht/2,K=Math.abs(ve.shift?.y||0),ge=Te.reference.height/2,Ee=typeof o=="function"?o(_n(ee,r,F)):o,De=K>Ee,Xe={top:`${lt}px calc(100% + ${Ee}px)`,bottom:`${lt}px ${-Ee}px`,left:`calc(100% + ${Ee}px) ${xt}px`,right:`${-Ee}px ${xt}px`}[Oe],Ze=`${lt}px ${Te.reference.y+ge-Re}px`;return pe.floating.style.setProperty("--transform-origin",Se&&ze==="y"&&De?Ze:Xe),{}}},As,x),J(()=>{!y&&m&&m.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[y,m]);const xe=l.useMemo(()=>({elementResize:!u&&typeof ResizeObserver<"u",layoutShift:!u&&typeof IntersectionObserver<"u"}),[u]),{refs:te,elements:we,x:ce,y:ie,middlewareData:re,update:$,placement:M,context:D,isPositioned:Z,floatingStyles:V}=xs({rootContext:m,open:p?y:void 0,placement:W,middleware:ne,strategy:n,whileElementsMounted:p?void 0:(...ee)=>Hn(...ee,xe),nodeId:b,externalTree:S}),{sideX:G,sideY:ke}=re.adaptiveOrigin||Ht,We=Z?n:"fixed",Me=l.useMemo(()=>{const ee=x?{position:We,[G]:ce,[ke]:ie}:{position:We,...V};return Z||(ee.opacity=0),ee},[x,We,G,ce,ke,ie,V,Z]),Fe=l.useRef(null);J(()=>{if(!y)return;const ee=I.current,pe=typeof ee=="function"?ee():ee,be=(Bn(pe)?pe.current:pe)||null||null;be!==Fe.current&&(te.setPositionReference(be),Fe.current=be)},[y,te,k,I]),l.useEffect(()=>{if(!y)return;const ee=I.current;typeof ee!="function"&&Bn(ee)&&ee.current!==Fe.current&&(te.setPositionReference(ee.current),Fe.current=ee.current)},[y,te,k,I]),l.useEffect(()=>{if(p&&y&&we.reference&&we.floating)return Hn(we.reference,we.floating,$,xe)},[p,y,we,$,xe]);const ae=Ve(M),Ue=yr(r,ae,F),$e=ut(M)||"center",He=!!re.hide?.referenceHidden;J(()=>{w&&y&&Z&&P(ae)},[w,y,Z,ae]);const Je=l.useMemo(()=>({position:"absolute",top:re.arrow?.y,left:re.arrow?.x}),[re.arrow]),Qe=re.arrow?.centerOffset!==0;return l.useMemo(()=>({positionerStyles:Me,arrowStyles:Je,arrowRef:O,arrowUncentered:Qe,side:Ue,align:$e,physicalSide:ae,anchorHidden:He,refs:te,context:D,isPositioned:Z,update:$}),[Me,Je,O,Qe,Ue,$e,ae,He,te,D,Z,$])}function Bn(e){return e!=null&&"current"in e}function wr(e){return e==="starting"?jr:zt}function Ms(e,t,{styles:n,transitionStatus:r,props:o,refs:s,hidden:i,inert:c=!1}){const a={...n};return c&&(a.pointerEvents="none"),gt("div",e,{state:t,ref:s,props:[{role:"presentation",hidden:i,style:a},wr(r),o],stateAttributesMapping:or})}function Os(e){const t=l.useRef(""),n=l.useCallback(o=>{o.defaultPrevented||(t.current=o.pointerType,e(o,o.pointerType))},[e]);return{onClick:l.useCallback(o=>{if(o.detail===0){e(o,"keyboard");return}"pointerType"in o?e(o,o.pointerType):e(o,t.current),t.current=""},[e]),onPointerDown:n}}function Rr(e,t){const n=l.useRef(e),r=ue(t);J(()=>{n.current!==e&&r(n.current)},[e,r]),J(()=>{n.current=e},[e])}function Ps(e,t){const n=ue((s,i)=>{(typeof e=="function"?e():e)||t(i||(Yr?"touch":""))}),{onClick:r,onPointerDown:o}=Os(n);return l.useMemo(()=>({onClick:r,onPointerDown:o}),[r,o])}function Ds(e){const[t,n]=l.useState(null),r=Ps(e,n);return Rr(e,o=>{o&&!e&&n(null)}),l.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}function Ls(e){const[t,n]=l.useState({current:e,previous:null});return e!==t.current&&n({current:e,previous:t.current}),t.previous}function Fs(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function Wn({controlled:e,default:t,name:n,state:r="value"}){const{current:o}=l.useRef(e!==void 0),[s,i]=l.useState(t),c=o?e:s,a=l.useCallback(f=>{o||i(f)},[]);return[c,a]}const br=l.createContext(null),Sr=l.createContext(null);function mt(){const e=l.useContext(br);if(e===null)throw new Error(It(60));return e}function vr(){const e=l.useContext(Sr);if(e===null)throw new Error(It(61));return e}let Un=(function(e){return e.disabled="data-disabled",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const Vs={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},bt={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},ks={disabled:!1,...bt},Hs={valid(e){return e===null?null:e?{[Un.valid]:""}:{[Un.invalid]:""}}},Ns={invalid:void 0,name:void 0,validityData:{state:Vs,errors:[],error:"",value:"",initialValue:null},setValidityData:Le,disabled:void 0,touched:bt.touched,setTouched:Le,dirty:bt.dirty,setDirty:Le,filled:bt.filled,setFilled:Le,focused:bt.focused,setFocused:Le,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:ks,markedDirtyRef:{current:!1},registerFieldControl:Le,validation:{getValidationProps:(e,t=zt)=>t,inputRef:{current:null},registerInput:Le,commit:async()=>{},change:Le}},_s=l.createContext(Ns);function Rn(e=!0){const t=l.useContext(_s);if(t.setValidityData===Le&&!e)throw new Error(It(28));return t}function Bs(e,t,n,r,o=!0,s){const{registerFieldControl:i}=Rn(),c=l.useRef(null);c.current||(c.current=Symbol()),J(()=>{const a=c.current;return!a||!o?void 0:(i(a,{controlRef:e,getValue:r,id:t,name:s,value:n}),()=>{i(a,void 0)})},[e,o,r,t,s,i,n])}const Ws=l.createContext({controlId:void 0,registerControlId:Le,labelId:void 0,setLabelId:Le,messageIds:[],setMessageIds:Le,getDescriptionProps:e=>e});function Er(){return l.useContext(Ws)}function Cr(e={}){const{id:t,implicit:n=!1,controlRef:r}=e,{controlId:o,registerControlId:s}=Er(),i=uo(t),c=n?o:void 0,a=Tt(()=>Symbol("labelable-control")),f=l.useRef(!1),g=l.useRef(t!=null),u=ue(()=>{!f.current||s===Le||(f.current=!1,s(a.current,void 0))});return J(()=>{if(s===Le)return;let d;if(n){const p=r?.current;Ae(p)&&p.closest("label")!=null?d=t??null:d=c??i}else if(t!=null)g.current=!0,d=t;else if(g.current)d=i;else{u();return}if(d===void 0){u();return}f.current=!0,s(a.current,d)},[t,r,c,s,n,i,a,u]),l.useEffect(()=>u,[u]),o??i}const Us=(e,t)=>Object.is(e,t);function pt(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function $s(e,t,n){return!e||e.length===0?!1:e.some(r=>r===void 0?!1:pt(t,r,n))}function Et(e,t,n){return!e||e.length===0?-1:e.findIndex(r=>r===void 0?!1:pt(r,t,n))}function zs(e,t,n){return e.filter(r=>!pt(t,r,n))}function an(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Tr(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function js(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(Tr(t)){for(const n of t)for(const r of n.items)if(r&&r.value==null&&r.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function Ar(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return an(e)}function ft(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?an(e.value):an(e)}function Ir(e,t,n){function r(){return Ar(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return t[e]??r();if(Array.isArray(t)){const o=t,s=Tr(o)?o.flatMap(i=>i.items):o;if(e==null||typeof e!="object"){const i=s.find(c=>c.value===e);return i&&i.label!=null?i.label:r()}if("value"in e){const i=s.find(c=>c&&c.value===e.value);if(i&&i.label!=null)return i.label}}return r()}function Ys(e,t,n){return e.reduce((r,o,s)=>(s>0&&r.push(", "),r.push(Ie.jsx(l.Fragment,{children:Ir(o,t,n)},s)),r),[])}const U={id:oe(e=>e.id),labelId:oe(e=>e.labelId),modal:oe(e=>e.modal),multiple:oe(e=>e.multiple),items:oe(e=>e.items),itemToStringLabel:oe(e=>e.itemToStringLabel),itemToStringValue:oe(e=>e.itemToStringValue),isItemEqualToValue:oe(e=>e.isItemEqualToValue),value:oe(e=>e.value),hasSelectedValue:oe(e=>{const{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:ft(t,r)!==""}),hasNullItemLabel:oe((e,t)=>t?js(e.items):!1),open:oe(e=>e.open),mounted:oe(e=>e.mounted),forceMount:oe(e=>e.forceMount),transitionStatus:oe(e=>e.transitionStatus),openMethod:oe(e=>e.openMethod),activeIndex:oe(e=>e.activeIndex),selectedIndex:oe(e=>e.selectedIndex),isActive:oe((e,t)=>e.activeIndex===t),isSelected:oe((e,t)=>{const n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(o=>pt(t,o,n)):pt(t,r,n)}),isSelectedByFocus:oe((e,t)=>e.selectedIndex===t),popupProps:oe(e=>e.popupProps),triggerProps:oe(e=>e.triggerProps),triggerElement:oe(e=>e.triggerElement),positionerElement:oe(e=>e.positionerElement),listElement:oe(e=>e.listElement),popupSide:oe(e=>e.popupSide),scrollUpArrowVisible:oe(e=>e.scrollUpArrowVisible),scrollDownArrowVisible:oe(e=>e.scrollDownArrowVisible),hasScrollArrows:oe(e=>e.hasScrollArrows)},qs=l.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:Le,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function Ks(){return l.useContext(qs)}function Xs(e,t,n=(r,o)=>r===o){return e.length===t.length&&e.every((r,o)=>n(r,t[o]))}const tt=1;function Mr(e,t){return Math.max(0,e-t)}function Gs(e,t){if(t<=0)return 0;const n=Rt(e,0,t),r=n,o=t-n,s=r<=tt,i=o<=tt;return s&&i?r<=o?0:t:s?0:i?t:n}function Ti(e){const{id:t,value:n,defaultValue:r=null,onValueChange:o,open:s,defaultOpen:i=!1,onOpenChange:c,name:a,form:f,autoComplete:g,disabled:u=!1,readOnly:d=!1,required:p=!1,modal:m=!0,actionsRef:y,inputRef:R,onOpenChangeComplete:h,items:b,multiple:x=!1,itemToStringLabel:w,itemToStringValue:S,isItemEqualToValue:C=Us,highlightItemOnHover:P=!0,children:T}=e,{clearErrors:L}=Ks(),{setDirty:_,setTouched:X,setFocused:B,validityData:k,setFilled:I,name:H,disabled:Y,validation:F,validationMode:E}=Rn(),W=Cr({id:t}),A=Y||u,v=H??a,[N,me]=Wn({controlled:n,default:x?r??on:r,name:"Select",state:"value"}),[q,ye]=Wn({controlled:s,default:i,name:"Select",state:"open"}),he=l.useRef([]),O=l.useRef([]),j=l.useRef(null),le=l.useRef(null),Ce=l.useRef(0),Q=l.useRef(null),ne=l.useRef([]),se=l.useRef(!1),Se=l.useRef(null),fe=l.useRef(null),de=l.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),xe=l.useRef(!1),{mounted:te,setMounted:we,transitionStatus:ce}=sr(q),{openMethod:ie,triggerProps:re}=Ds(q),$=Tt(()=>new Gr({id:W,labelId:void 0,modal:m,multiple:x,itemToStringLabel:w,itemToStringValue:S,isItemEqualToValue:C,value:N,open:q,mounted:te,transitionStatus:ce,items:b,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,M=z($,U.activeIndex),D=z($,U.selectedIndex),Z=z($,U.triggerElement),V=z($,U.positionerElement),G=Ls(ie),ke=ie??G??null,We=l.useMemo(()=>x?"":ft(N,S),[x,N,S]),Me=l.useMemo(()=>x&&Array.isArray(N)?N.map(K=>ft(K,S)):ft(N,S),[x,N,S]),Fe=Ye($.state.triggerElement),ae=ue(()=>Me);Bs(Fe,W,N,ae,!A,a);const Ue=l.useRef(N),$e=x?Array.isArray(N)&&N.length>0:N!=null&&ft(N,S)!=="";J(()=>{N!==Ue.current&&$.set("forceMount",!0)},[$,N]),J(()=>{I($e)},[$e,I]),J(function(){const ge=ne.current;let Ee;if(x){const De=Array.isArray(N)?N:[];if(De.length===0)Ee=null;else{const Xe=De[De.length-1],Ze=Et(ge,Xe,C);Ee=Ze===-1?null:Ze}}else{const De=Et(ge,N,C);Ee=De===-1?null:De}Ee===null&&(fe.current=null),!q&&$.set("selectedIndex",Ee)},[$e,x,q,N,ne,C,$,fe]);function He(K){const ge=k.initialValue;return Array.isArray(K)&&Array.isArray(ge)?!Xs(K,ge,(Ee,De)=>pt(Ee,De,C)):K!==ge}Rr(N,()=>{L(v),_(He(N)),F.change(N)});const Je=ue((K,ge)=>{c?.(K,ge),!ge.isCanceled&&(ye(K),!K&&(ge.reason===Jn||ge.reason===Jr)&&(X(!0),B(!1),E==="onBlur"&&F.commit(N)))}),Qe=ue(()=>{we(!1),$.update({activeIndex:null,openMethod:null}),h?.(!1)});gn({enabled:!y,open:q,ref:j,onComplete(){q||Qe()}}),l.useImperativeHandle(y,()=>({unmount:Qe}),[Qe]);const ee=ue((K,ge)=>{o?.(K,ge),!ge.isCanceled&&me(K)}),pe=ue(()=>{const K=$.state.listElement||j.current;if(!K)return;const ge=Mr(K.scrollHeight,K.clientHeight),Ee=Gs(K.scrollTop,ge),De=Ee>0,Xe=Ee<ge;$.state.scrollUpArrowVisible!==De&&$.set("scrollUpArrowVisible",De),$.state.scrollDownArrowVisible!==Xe&&$.set("scrollDownArrowVisible",Xe)}),ve=hr({open:q,onOpenChange:Je,elements:{reference:Z,floating:V}}),be=Oo(ve,{enabled:!d&&!A,event:"mousedown"}),Te=fo(ve),Re=bs(ve,{enabled:!d&&!A,listRef:he,activeIndex:M,selectedIndex:D,disabledIndices:on,onNavigate(K){K===null&&!q||$.set("activeIndex",K)},focusItemOnHover:P}),Oe=Ss(ve,{enabled:!d&&!A&&(q||!x),listRef:O,activeIndex:M,selectedIndex:D,disabledIndices:K=>Fs(he.current[K]),onMatch(K){q?$.set("activeIndex",K):ee(ne.current[K],_e("none"))},onTyping(K){se.current=K}}),ze=l.useMemo(()=>{const K=sn(Oe.reference,Re.reference,Te.reference,be.reference,re);return W&&(K.id=W),K},[be.reference,Oe.reference,Re.reference,Te.reference,re,W]),qe=l.useMemo(()=>sn(po,Oe.floating,Re.floating,Te.floating),[Oe.floating,Re.floating,Te.floating]),ct=Re.item??zt;go(()=>{$.update({popupProps:qe,triggerProps:ze})}),J(()=>{$.update({id:W,modal:m,multiple:x,value:N,open:q,mounted:te,transitionStatus:ce,popupProps:qe,triggerProps:ze,items:b,itemToStringLabel:w,itemToStringValue:S,isItemEqualToValue:C,openMethod:ke})},[$,W,m,x,N,q,te,ce,qe,ze,b,w,S,C,ke]);const Pe=l.useMemo(()=>({store:$,name:v,required:p,disabled:A,readOnly:d,multiple:x,highlightItemOnHover:P,setValue:ee,setOpen:Je,listRef:he,popupRef:j,scrollHandlerRef:le,handleScrollArrowVisibility:pe,scrollArrowsMountedCountRef:Ce,itemProps:ct,valueRef:Q,valuesRef:ne,labelsRef:O,typingRef:se,selectionRef:de,firstItemTextRef:Se,selectedItemTextRef:fe,validation:F,onOpenChangeComplete:h,alignItemWithTriggerActiveRef:xe,initialValueRef:Ue}),[$,v,p,A,d,x,P,ee,Je,ct,F,h,pe]),Ke=qr(R,F.inputRef),ht=x&&Array.isArray(N)&&N.length>0,lt=x?void 0:v,xt=l.useMemo(()=>!x||!Array.isArray(N)||!v?null:N.map(K=>{const ge=ft(K,S);return Ie.jsx("input",{type:"hidden",form:f,name:v,value:ge,disabled:A},ge)}),[x,N,f,v,S,A]);return Ie.jsx(br.Provider,{value:Pe,children:Ie.jsxs(Sr.Provider,{value:ve,children:[T,Ie.jsx("input",{...F.getValidationProps(A,{onFocus(){$.state.triggerElement?.focus({focusVisible:!0})},onChange(K){if(K.nativeEvent.defaultPrevented||A||d)return;const ge=K.currentTarget.value,Ee=_e(mn,K.nativeEvent);function De(){if(x)return;const Xe=ge.toLowerCase();let Ze=ne.current.findIndex(Gt=>ft(Gt,S).toLowerCase()===Xe||Ar(Gt,w).toLowerCase()===Xe);Ze===-1&&(Ze=ne.current.findIndex((Gt,Fr)=>{const vn=O.current[Fr];return vn!=null&&vn.toLowerCase()===Xe}));const Sn=Ze===-1?void 0:ne.current[Ze];Sn!=null&&ee(Sn,Ee)}$.set("forceMount",!0),queueMicrotask(De)}}),id:W&&lt==null?`${W}-hidden-input`:void 0,form:f,name:lt,autoComplete:g,value:We,disabled:A,required:p&&!ht,readOnly:d,ref:Ke,style:v?Kr:Xr,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),xt]})})}function Js(e,t){return e??t}function Qs(e){const t=e.getBoundingClientRect(),n=Be(e);if(Qr)return t;const r=n.getComputedStyle(e,"::before"),o=n.getComputedStyle(e,"::after");if(!(r.content!=="none"||o.content!=="none"))return t;const i=parseFloat(r.width)||0,c=parseFloat(r.height)||0,a=parseFloat(o.width)||0,f=parseFloat(o.height)||0,g=Math.max(t.width,i,a),u=Math.max(t.height,c,f),d=g-t.width,p=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-p/2,bottom:t.bottom+p/2}}const Dt=2,Zs=400,ei={...mo,...Hs,popupSide:e=>e?{"data-popup-side":e}:null,value:()=>null},Ai=l.forwardRef(function(t,n){const{render:r,className:o,id:s,disabled:i=!1,nativeButton:c=!0,style:a,...f}=t,{setTouched:g,setFocused:u,validationMode:d,state:p,disabled:m}=Rn(),{labelId:y}=Er(),{store:R,setOpen:h,selectionRef:b,validation:x,readOnly:w,required:S,alignItemWithTriggerActiveRef:C,disabled:P}=mt(),T=m||P||i,L=z(R,U.open),_=z(R,U.mounted),X=z(R,U.value),B=z(R,U.triggerProps),k=z(R,U.positionerElement),I=z(R,U.listElement),H=z(R,U.popupSide),Y=z(R,U.id),F=z(R,U.labelId),E=z(R,U.hasSelectedValue),W=_&&k?H:null,A=s??Y,v=Js(y,F);Cr({id:A});const N=Ye(k),me=l.useRef(null),{getButtonProps:q,buttonRef:ye}=Zn({disabled:T,native:c}),he=ue(se=>{R.set("triggerElement",se)}),O=vt(),j=vt(),le=vt();l.useEffect(()=>{if(L)return le.start(Zs,()=>{b.current.allowUnselectedMouseUp=!0,b.current.allowSelectedMouseUp=!0}),()=>{le.clear()};b.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},j.clear()},[L,b,j,le]);const Ce=sn(B,{id:A,role:"combobox","aria-expanded":L?"true":"false","aria-haspopup":"listbox","aria-controls":L?I?.id??Gn(k)?.id:void 0,"aria-labelledby":v,"aria-readonly":w||void 0,"aria-required":S||void 0,tabIndex:T?-1:0,onFocus(se){u(!0),L&&C.current&&h(!1,_e(mn,se.nativeEvent)),O.start(0,()=>{R.set("forceMount",!0)})},onBlur(se){at(k,se.relatedTarget)||(g(!0),u(!1),d==="onBlur"&&x.commit(X))},onMouseDown(se){if(L)return;const Se=ot(se.currentTarget);function fe(de){if(!me.current)return;const xe=de.target;if(at(me.current,xe)||at(N.current,xe))return;const te=Qs(me.current);de.clientX>=te.left-Dt&&de.clientX<=te.right+Dt&&de.clientY>=te.top-Dt&&de.clientY<=te.bottom+Dt||h(!1,_e(Zr,de))}j.start(0,()=>{Se.addEventListener("mouseup",fe,{once:!0})})}},f,q),Q=x.getValidationProps(T,Ce);Q.role="combobox";const ne={...p,open:L,disabled:T,value:X,readOnly:w,popupSide:W,placeholder:!E};return gt("button",t,{ref:[n,me,ye,he],state:ne,stateAttributesMapping:ei,props:Q})}),ti={value:()=>null},Ii=l.forwardRef(function(t,n){const{className:r,render:o,children:s,placeholder:i,style:c,...a}=t,{store:f,valueRef:g}=mt(),u=z(f,U.value),d=z(f,U.items),p=z(f,U.itemToStringLabel),m=z(f,U.hasSelectedValue),y=!m&&i!=null&&s==null,R=z(f,U.hasNullItemLabel,y),h={value:u,placeholder:!m};let b=null;return typeof s=="function"?b=s(u):s!=null?b=s:!m&&i!=null&&!R?b=i:Array.isArray(u)?b=Ys(u,d,p):b=Ir(u,d,p),gt("span",t,{state:h,ref:[n,g],props:[{children:b},a],stateAttributesMapping:ti})}),ni=l.createContext(void 0),Mi=l.forwardRef(function(t,n){const{store:r}=mt(),o=z(r,U.mounted),s=z(r,U.forceMount);return o||s?Ie.jsx(ni.Provider,{value:!0,children:Ie.jsx(eo,{ref:n,...t})}):null}),Or=l.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function ri(){return l.useContext(Or)}function oi(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:o}=e,s=ue(o),i=l.useRef(0),c=Tt(ii).current,a=Tt(si).current,[f,g]=l.useState(0),u=l.useRef(f),d=ue((h,b)=>{a.set(h,b??null),u.current+=1,g(u.current)}),p=ue(h=>{a.delete(h),u.current+=1,g(u.current)}),m=l.useMemo(()=>{const h=new Map;return Array.from(a.keys()).filter(x=>x.isConnected).sort(ci).forEach((x,w)=>{const S=a.get(x)??{};h.set(x,{...S,index:w})}),h},[a,f]);J(()=>{if(typeof MutationObserver!="function"||m.size===0)return;const h=new MutationObserver(b=>{const x=new Set,w=S=>x.has(S)?x.delete(S):x.add(S);b.forEach(S=>{S.removedNodes.forEach(w),S.addedNodes.forEach(w)}),x.size===0&&(u.current+=1,g(u.current))});return m.forEach((b,x)=>{x.parentElement&&h.observe(x.parentElement,{childList:!0})}),()=>{h.disconnect()}},[m]),J(()=>{u.current===f&&(n.current.length!==m.size&&(n.current.length=m.size),r&&r.current.length!==m.size&&(r.current.length=m.size),i.current=m.size),s(m)},[s,m,n,r,f]),J(()=>()=>{n.current=[]},[n]),J(()=>()=>{r&&(r.current=[])},[r]);const y=ue(h=>(c.add(h),()=>{c.delete(h)}));J(()=>{c.forEach(h=>h(m))},[c,m]);const R=l.useMemo(()=>({register:d,unregister:p,subscribeMapChange:y,elementsRef:n,labelsRef:r,nextIndexRef:i}),[d,p,y,n,r,i]);return Ie.jsx(Or.Provider,{value:R,children:t})}function si(){return new Map}function ii(){return new Set}function ci(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const Pr=l.createContext(void 0);function li(){const e=l.useContext(Pr);if(!e)throw new Error(It(59));return e}function $t(e,t){e&&Object.assign(e.style,t)}const ai={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},ui=20;function fi(e,t,n,r){const[o,s]=l.useState(!1);J(()=>{if(!e||!t||n==null){s(!1);return}const i=ot(n).documentElement.clientWidth,c=n.offsetWidth;s(i>0&&c>0&&c>=i-ui)},[e,t,n]),ho(e&&(!t||o),r)}const di={position:"fixed"},Oi=l.forwardRef(function(t,n){const{anchor:r,positionMethod:o="absolute",className:s,render:i,side:c="bottom",align:a="center",sideOffset:f=0,alignOffset:g=0,collisionBoundary:u="clipping-ancestors",collisionPadding:d,arrowPadding:p=5,sticky:m=!1,disableAnchorTracking:y,alignItemWithTrigger:R=!0,collisionAvoidance:h=to,style:b,...x}=t,{store:w,listRef:S,labelsRef:C,alignItemWithTriggerActiveRef:P,selectedItemTextRef:T,valuesRef:L,initialValueRef:_,popupRef:X,setValue:B}=mt(),k=vr(),I=z(w,U.open),H=z(w,U.mounted),Y=z(w,U.modal),F=z(w,U.value),E=z(w,U.openMethod),W=z(w,U.positionerElement),A=z(w,U.triggerElement),v=z(w,U.isItemEqualToValue),N=z(w,U.transitionStatus),me=l.useRef(null),q=l.useRef(null),[ye,he]=l.useState(R),O=H&&ye&&E!=="touch";!H&&ye!==R&&he(R),J(()=>{H||(U.scrollUpArrowVisible(w.state)&&w.set("scrollUpArrowVisible",!1),U.scrollDownArrowVisible(w.state)&&w.set("scrollDownArrowVisible",!1))},[w,H]),l.useImperativeHandle(P,()=>O),fi((O||Y)&&I,E==="touch",W,A);const j=Is({anchor:r,floatingRootContext:k,positionMethod:o,mounted:H,side:c,sideOffset:f,align:a,alignOffset:g,arrowPadding:p,collisionBoundary:u,collisionPadding:d,sticky:m,disableAnchorTracking:y??O,collisionAvoidance:h,keepMounted:!0}),le=O?"none":j.side,Ce=O?di:j.positionerStyles,Q={open:I,side:le,align:j.align,anchorHidden:j.anchorHidden};J(()=>{w.set("popupSide",j.side)},[w,j.side]);const ne=ue(xe=>{w.set("positionerElement",xe)}),se=Ms(t,Q,{styles:Ce,transitionStatus:N,props:x,refs:[n,ne],hidden:!H,inert:!I}),Se=l.useRef(0),fe=ue(xe=>{if(xe.size===0&&Se.current===0||L.current.length===0)return;const te=Se.current;if(Se.current=xe.size,xe.size===te)return;const we=_e(mn);if(te!==0&&!w.state.multiple&&F!==null&&Et(L.current,F,v)===-1){const ie=_.current,$=ie!=null&&Et(L.current,ie,v)!==-1?ie:null;B($,we),$===null&&(w.set("selectedIndex",null),T.current=null)}if(te!==0&&w.state.multiple&&Array.isArray(F)){const ce=re=>Et(L.current,re,v)!==-1,ie=F.filter(re=>ce(re));(ie.length!==F.length||ie.some(re=>!$s(F,re,v)))&&(B(ie,we),ie.length===0&&(w.set("selectedIndex",null),T.current=null))}if(I&&O){w.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const ce={height:""};$t(W,ce),$t(X.current,ce)}}),de=l.useMemo(()=>({...j,side:le,alignItemWithTriggerActive:O,setControlledAlignItemWithTrigger:he,scrollUpArrowRef:me,scrollDownArrowRef:q}),[j,le,O,he]);return Ie.jsx(oi,{elementsRef:S,labelsRef:C,onMapChange:fe,children:Ie.jsxs(Pr.Provider,{value:de,children:[H&&Y&&Ie.jsx(xo,{inert:no(!I),cutout:A}),se]})})}),Lt="base-ui-disable-scrollbar",$n={className:Lt,getElement(e){return Ie.jsx("style",{nonce:e,href:Lt,precedence:"base-ui:low",children:`.${Lt}{scrollbar-width:none}.${Lt}::-webkit-scrollbar{display:none}`})}},pi=l.createContext(void 0);function gi(e){return l.useContext(pi)}const mi=l.createContext(void 0),hi={disableStyleElements:!1};function xi(){return l.useContext(mi)??hi}const yi={...or,...er},Pi=l.forwardRef(function(t,n){const{render:r,className:o,style:s,finalFocus:i,...c}=t,{store:a,popupRef:f,onOpenChangeComplete:g,setOpen:u,valueRef:d,firstItemTextRef:p,selectedItemTextRef:m,multiple:y,handleScrollArrowVisibility:R,scrollHandlerRef:h,listRef:b,highlightItemOnHover:x}=mt(),{side:w,align:S,alignItemWithTriggerActive:C,isPositioned:P,setControlledAlignItemWithTrigger:T}=li(),L=gi()!=null,_=vr(),X=xr(),{nonce:B,disableStyleElements:k}=xi(),I=z(a,U.id),H=z(a,U.open),Y=z(a,U.openMethod),F=z(a,U.mounted),E=z(a,U.popupProps),W=z(a,U.transitionStatus),A=z(a,U.triggerElement),v=z(a,U.positionerElement),N=z(a,U.listElement),me=l.useRef(!1),q=l.useRef(!1),ye=l.useRef({}),he=Nt(),O=ue(Q=>{if(!v||!f.current||!q.current)return;if(me.current||!C){R();return}const ne=v.style.top==="0px",se=v.style.bottom==="0px";if(!ne&&!se){R();return}const Se=jn(v),fe=St(v.getBoundingClientRect().height,"y",Se),de=ot(v),xe=Be(v),te=xe.getComputedStyle(v),we=parseFloat(te.marginTop),ce=parseFloat(te.marginBottom),ie=zn(xe.getComputedStyle(f.current)),re=Math.min(de.documentElement.clientHeight-we-ce,ie),$=Q.scrollTop,M=Ft(Q);let D=0,Z=null,V=!1,G=!1;const ke=ae=>{v.style.height=`${ae}px`},We=(ae,Ue)=>{const $e=Rt(ae,0,re-fe);$e>0&&ke(fe+$e),Q.scrollTop=Ue,re-(fe+$e)<=tt&&(me.current=!0),R()},Me=ne?M-$:$,Fe=Math.min(fe+Me,re);if(D=Fe,Me<=tt){We(Me,ne?M:0);return}if(re-Fe>tt)ne?G=!0:Z=0;else if(V=!0,se&&$<M){const ae=fe+Me-re;Z=$-(Me-ae)}if(D=Math.ceil(D),D!==0&&ke(D),G||Z!=null){const ae=Ft(Q),Ue=G?ae:Rt(Z,0,ae);Math.abs(Q.scrollTop-Ue)>tt&&(Q.scrollTop=Ue)}(V||D>=re-tt)&&(me.current=!0),R()});l.useImperativeHandle(h,()=>O,[O]),gn({open:H,ref:f,onComplete(){H&&g?.(!0)}});const j={open:H,transitionStatus:W,side:w,align:S};J(()=>{!v||!f.current||Object.keys(ye.current).length||(ye.current={top:v.style.top||"0",left:v.style.left||"0",right:v.style.right,height:v.style.height,bottom:v.style.bottom,minHeight:v.style.minHeight,maxHeight:v.style.maxHeight,marginTop:v.style.marginTop,marginBottom:v.style.marginBottom})},[f,v]),J(()=>{H||C||(q.current=!1,me.current=!1,$t(v,ye.current))},[H,C,v,f]),J(()=>{const Q=f.current;if(!H||!A||!v||!Q||C&&!P||a.state.transitionStatus==="ending")return;if(!C){q.current=!0,he.request(R),Q.style.removeProperty("--transform-origin");return}const ne=wi(Q);Q.style.removeProperty("--transform-origin");try{let se=m.current;se?.isConnected||(se=!U.hasSelectedValue(a.state)&&p.current?.isConnected?p.current:null);const Se=d.current,fe=Be(v),de=fe.getComputedStyle(v),xe=fe.getComputedStyle(Q),te=ot(A),we=jn(A),ce=Vt(A.getBoundingClientRect(),we),ie=Vt(v.getBoundingClientRect(),we),re=ce.height,$=N||Q,M=$.scrollHeight,D=parseFloat(xe.borderBottomWidth),Z=parseFloat(de.marginTop)||10,V=parseFloat(de.marginBottom)||10,G=parseFloat(de.minHeight)||100,ke=zn(xe),We=5,Me=5,Fe=20,ae=te.documentElement.clientHeight-Z-V,Ue=te.documentElement.clientWidth,$e=ae-ce.bottom+re;let He,Je=X==="rtl"?ce.right-ie.width:ce.left,Qe=0;if(se&&Se){const Pe=Vt(Se.getBoundingClientRect(),we);He=Vt(se.getBoundingClientRect(),we),Je=ie.left+(X==="rtl"?Pe.right-He.right:Pe.left-He.left);const Ke=Pe.top-ce.top+Pe.height/2;Qe=He.top-ie.top+He.height/2-Ke}const ee=$e+Qe+V+D;let pe=Math.min(ae,ee);const ve=ae-Z-V,be=ee-pe,Te=Ue-Me;v.style.left=`${Rt(Je,We,Te-ie.width)}px`,v.style.height=`${pe}px`,v.style.maxHeight="none",v.style.marginTop=`${Z}px`,v.style.marginBottom=`${V}px`,Q.style.height="100%";const Re=Ft($),Oe=be>=Re-tt;Oe&&(pe=Math.min(ae,ie.height)-(be-Re));const ze=ce.top<Fe||ce.bottom>ae-Fe||Math.ceil(pe)+tt<Math.min(M,G),qe=(fe.visualViewport?.scale??1)!==1&&ro;if(ze||qe){q.current=!0,$t(v,ye.current),T(!1);return}const ct=Math.max(G,pe);if(Oe){const Pe=Math.max(0,ae-ee);v.style.top=ie.height>=ve?"0":`${Pe}px`,v.style.height=`${pe}px`,$.scrollTop=Ft($)}else v.style.bottom="0",$.scrollTop=be;if(He){const Pe=ie.top,Ke=ie.height,ht=He.top+He.height/2,lt=Ke>0?(ht-Pe)/Ke*100:50,xt=Rt(lt,0,100);Q.style.setProperty("--transform-origin",`50% ${xt}%`)}(ct===ae||pe>=ke)&&(me.current=!0),R(),x&&a.state.selectedIndex===null&&a.state.activeIndex===null&&b.current[0]!=null&&a.set("activeIndex",0),q.current=!0}finally{ne()}},[a,H,v,A,d,p,m,f,R,C,T,he,N,b,x,X,P]),l.useEffect(()=>{if(!C||!v||!H)return;const Q=Be(v);function ne(se){u(!1,_e(so,se))}return oo(Q,"resize",ne)},[u,C,v,H]);const le={...N?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":y||void 0,id:`${I}-list`},onKeyDown(Q){L&&wo.has(Q.key)&&Q.stopPropagation()},onScroll(Q){N||O(Q.currentTarget)},...C&&{style:N?{height:"100%"}:ai}},Ce=gt("div",t,{ref:[n,f],state:j,stateAttributesMapping:yi,props:[E,le,wr(W),{className:!N&&C?$n.className:void 0},c]});return Ie.jsxs(l.Fragment,{children:[!k&&$n.getElement(B),Ie.jsx(yo,{context:_,modal:!1,disabled:!F,openInteractionType:Y,returnFocus:i,restoreFocus:!0,children:Ce})]})});function zn(e){const t=e.maxHeight||"";return t.endsWith("px")&&parseFloat(t)||1/0}function Ft(e){return Mr(e.scrollHeight,e.clientHeight)}function jn(e){return pr.getScale(e)}function St(e,t,n){return e/n[t]}function Vt(e,t){return At({x:St(e.x,"x",t),y:St(e.y,"y",t),width:St(e.width,"x",t),height:St(e.height,"y",t)})}const Yn=[["transform","none"],["scale","1"],["translate","0 0"]];function wi(e){const{style:t}=e,n={};for(const[r,o]of Yn)n[r]=t.getPropertyValue(r),t.setProperty(r,o,"important");return()=>{for(const[r]of Yn){const o=n[r];o?t.setProperty(r,o):t.removeProperty(r)}}}let Dr=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function Ri(e={}){const{label:t,metadata:n,textRef:r,indexGuessBehavior:o,index:s}=e,{register:i,unregister:c,subscribeMapChange:a,elementsRef:f,labelsRef:g,nextIndexRef:u}=ri(),d=l.useRef(-1),[p,m]=l.useState(s??(o===Dr.GuessFromOrder?()=>{if(d.current===-1){const h=u.current;u.current+=1,d.current=h}return d.current}:-1)),y=l.useRef(null),R=l.useCallback(h=>{if(y.current=h,p!==-1&&h!==null&&(f.current[p]=h,g)){const b=t!==void 0;g.current[p]=b?t:r?.current?.textContent??h.textContent}},[p,f,g,t,r]);return J(()=>{if(s!=null)return;const h=y.current;if(h)return i(h,n),()=>{c(h)}},[s,i,c,n]),J(()=>{if(s==null)return a(h=>{const b=y.current?h.get(y.current)?.index:null;b!=null&&m(b)})},[s,a,m]),{ref:R,index:p}}const Lr=l.createContext(void 0);function bn(){const e=l.useContext(Lr);if(!e)throw new Error(It(57));return e}const Di=l.memo(l.forwardRef(function(t,n){const{render:r,className:o,style:s,value:i=null,label:c,disabled:a=!1,nativeButton:f=!1,...g}=t,u=l.useRef(null),d=Ri({label:c,textRef:u,indexGuessBehavior:Dr.GuessFromOrder}),{store:p,itemProps:m,setOpen:y,setValue:R,selectionRef:h,typingRef:b,valuesRef:x,multiple:w,selectedItemTextRef:S,disabled:C,readOnly:P}=mt(),T=z(p,U.isActive,d.index),L=z(p,U.open),_=z(p,U.isSelected,i),X=z(p,U.isSelectedByFocus,d.index),B=z(p,U.isItemEqualToValue),k=d.index,I=k!==-1,H=l.useRef(null);J(()=>{if(!I)return;const O=x.current;return O[k]=i,()=>{delete O[k]}},[I,k,i,x]),J(()=>{if(!I)return;const O=p.state.value;let j=O;w&&Array.isArray(O)&&(j=O.length>0?O[O.length-1]:void 0),j!==void 0&&pt(i,j,B)&&(p.set("selectedIndex",k),u.current&&(S.current=u.current))},[I,k,w,B,p,i,S]);const Y=l.useRef(null),F=l.useRef("mouse"),E=l.useRef(!1),{getButtonProps:W,buttonRef:A}=Zn({disabled:a,focusableWhenDisabled:!0,native:f,composite:!0}),v={disabled:a,selected:_,highlighted:T};function N(O){if(C||P)return;const j=p.state.value;if(w){const le=Array.isArray(j)?j:[],Ce=_?zs(le,i,B):[...le,i];R(Ce,_e(Zt,O))}else R(i,_e(Zt,O)),y(!1,_e(Zt,O))}function me(){h.current.dragY=0}const q={role:"option","aria-selected":_,tabIndex:L&&T?0:-1,onKeyDown(O){Y.current=O.key,p.set("activeIndex",k),O.key===" "&&b.current&&O.preventDefault()},onClick(O){const j=O.type==="click"&&F.current!=="touch",le=O.nativeEvent.pointerType,Ce=j&&rr(O.nativeEvent)&&(le!==void 0||T),Q=j&&!Ce&&!E.current;E.current=!1,!(O.type==="keydown"&&Y.current===null)&&(a||O.type==="keydown"&&Y.current===" "&&b.current||Q||(Y.current=null,N(O.nativeEvent)))},onPointerEnter(O){F.current=O.pointerType},onPointerMove(O){if(O.pointerType==="mouse"&&O.buttons===1){const j=h.current;j.dragY+=O.movementY,j.dragY**2>=64&&(j.allowUnselectedMouseUp=!0)}},onPointerDown(O){F.current=O.pointerType,E.current=!0,me()},onMouseUp(){if(me(),a||F.current==="touch"||E.current)return;const O=!h.current.allowSelectedMouseUp&&_,j=!h.current.allowUnselectedMouseUp&&!_;O||j||(E.current=!0,H.current?.click(),E.current=!1)}},ye=gt("div",t,{ref:[A,n,d.ref,H],state:v,props:[m,q,g,W]}),he=l.useMemo(()=>({selected:_,index:k,textRef:u,selectedByFocus:X,hasRegistered:I}),[_,k,u,X,I]);return Ie.jsx(Lr.Provider,{value:he,children:ye})})),Li=l.forwardRef(function(t,n){const r=t.keepMounted??!1,{selected:o}=bn();return r||o?Ie.jsx(bi,{...t,ref:n}):null}),bi=l.memo(l.forwardRef((e,t)=>{const{render:n,className:r,style:o,keepMounted:s,...i}=e,{selected:c}=bn(),a=l.useRef(null),{transitionStatus:f,setMounted:g}=sr(c),d=gt("span",e,{ref:[t,a],state:{selected:c,transitionStatus:f},props:[{"aria-hidden":!0,children:"✔️"},i],stateAttributesMapping:er});return gn({open:c,ref:a,onComplete(){c||g(!1)}}),d})),Fi=l.memo(l.forwardRef(function(t,n){const{index:r,textRef:o,selectedByFocus:s,hasRegistered:i}=bn(),{firstItemTextRef:c,selectedItemTextRef:a}=mt(),{render:f,className:g,style:u,...d}=t,p=l.useCallback(y=>{y&&(i&&r===0&&(c.current=y),i&&s&&(a.current=y))},[c,a,r,s,i]);return gt("div",t,{ref:[p,n,o],props:d})}));export{wr as A,Ei as C,ai as L,Ti as S,li as a,$n as b,Ai as c,Ii as d,Mi as e,Oi as f,Pi as g,Di as h,Li as i,Fi as j,Hs as k,Ks as l,Rn as m,Er as n,Wn as o,Bs as p,Rr as q,Oo as r,U as s,Ps as t,mt as u,Is as v,fi as w,Ms as x,Ci as y,gi as z};
@@ -1 +0,0 @@
1
- import{k as w,r as c,a5 as ae,a7 as ie,bf as G,j as t,x as U,P as se,b as N,c as a,e as oe,ax as re,bg as le,aD as ce,aE as ue,ab as F,bh as de,bi as ge,Y as he,R as C,K as pe,W as me,bj as R,l as I,bk as be,bl as fe,N as xe,bm as ye,v as ve,bn as je,bo as ke,bp as Ne,bq as Se,br as we,bs as Ce,bt as Le,L as Ee,b4 as Ae,bu as Ge,at as P}from"./__vite-browser-external-Djkun5S2.js";import{u as Ie,L as _}from"./use-limits-display-prefs-BCh-4-Bo.js";import{a as O,l as T}from"./limits-providers-DkoPB8B2.js";import{a as k,T as j,b,S as L,u as H}from"./use-native-settings-o-TL7MGQ.js";import{P as Pe,u as _e,a as Oe}from"./use-session-efficiency-pref-BsG2CJqB.js";import{C as Te}from"./check-DR7E_A1J.js";import{C as De}from"./copy-BtstNk2s.js";import{u as Me}from"./useCurrency-DqxQMZty.js";import{u as Ue}from"./useTokenFormat-CdYh0d_c.js";import{S as $}from"./Select-Ch5kjPZu.js";import{I as Fe}from"./info-BtnxfCu0.js";import{C as Re}from"./ConfirmModal-CCFe2duP.js";import{A as He}from"./arrow-up-right-Bm0oL1jH.js";import{D as $e}from"./download-zOVMvQXI.js";import"./Card-D479hjUR.js";import"./SelectItemText-D4laqPg3.js";import"./useScrollLock-DZpDnNt6.js";import"./DialogTitle-vIrqSKer.js";import"./DialogDescription-DDeAH6I9.js";const Be=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ve=w("activity",Be);const ze=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Ke=w("grip-vertical",ze);const qe=[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]],We=w("languages",qe);const Ze=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Ye=w("log-out",Ze),Qe=e=>!e.isLayoutDirty&&e.willUpdate(!1);function D(){const e=new Set,n=new WeakMap,i=()=>e.forEach(Qe);return{add:s=>{e.add(s),n.set(s,s.addEventListener("willUpdate",i))},remove:s=>{e.delete(s);const o=n.get(s);o&&(o(),n.delete(s)),i()},dirty:i}}const Je=c.createContext(null);function Xe(){const e=c.useRef(!1);return ae(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function et(){const e=Xe(),[n,i]=c.useState(0),s=c.useCallback(()=>{e.current&&i(n+1)},[n]);return[c.useCallback(()=>ie.postRender(s),[s]),n]}const B=e=>e===!0,tt=e=>B(e===!0)||e==="id",nt=({children:e,id:n,inherit:i=!0})=>{const s=c.useContext(G),o=c.useContext(Je),[r,l]=et(),u=c.useRef(null),g=s.id||o;u.current===null&&(tt(i)&&g&&(n=n?g+"-"+n:g),u.current={id:n,group:B(i)&&s.group||D()});const h=c.useMemo(()=>({...u.current,forceRender:r}),[l]);return t.jsx(G.Provider,{value:h,children:e})},at="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function it({checked:e,onChange:n,ariaLabel:i}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":i,onClick:n,className:N("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",e?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:t.jsx("span",{className:N("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function st({prefs:e}){const{order:n,visibility:i,toggle:s,moveToward:o}=e,[r,l]=c.useState(null),[u,g]=c.useState(null),h=d=>f=>{l(d),f.dataTransfer.effectAllowed="move",f.dataTransfer.setData("text/plain",d)},m=d=>f=>{f.preventDefault(),f.dataTransfer.dropEffect="move",r&&r!==d&&u!==d&&(g(d),o(r,d))},x=()=>{l(null),g(null)},y=d=>{d.preventDefault(),l(null),g(null)};return t.jsx(nt,{children:t.jsx("div",{className:"flex flex-col",children:n.map(d=>{const f=i[d]!==!1,p=r===d;return t.jsxs(U.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:h(d),onDragOver:m(d),onDragEnd:x,onDrop:y,className:N("flex items-center gap-3 py-2 rounded-md","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60",p&&"opacity-40"),style:{cursor:p?"grabbing":"grab"},children:[t.jsx(Ke,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),O(d)?t.jsx(se,{provider:O(d),size:18,className:N("pointer-events-none",at)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:T(d)}),t.jsx("div",{onMouseDown:v=>v.stopPropagation(),draggable:!1,children:t.jsx(it,{checked:f,onChange:()=>s(d),ariaLabel:`${a("limits.settings.toggle_visible")}: ${T(d)}`})})]},d)})})})}function ot(e){if(!e||typeof e!="object")return"";const n=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},i=e.profile&&typeof e.profile=="object"?e.profile:{},s=n.full_name||n.name||i.name||n.user_name||n.preferred_username;return typeof s=="string"&&s.trim()?s.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function rt(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function lt(e){const n=typeof e=="string"?e.trim():"";if(!n)return null;const i=n.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),s=n.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=i?.[1]||s?.[1];return o?`https://github.com/${o}`:null}function E(e,n){console.warn(`[tokentracker] settings ${e}:`,n)}function ct(e,n,i){const[s,o]=c.useState(()=>re()),r=n&&i&&le(),l=c.useCallback(async()=>{const u=!s;if(ce(u),o(u),!!u)try{await ue(()=>e())}catch(g){E("cloud sync",g)}},[s,e]);return{cloudSyncOn:s,handleCloudSyncToggle:l,showLocalCloudSync:r}}function ut(e){const[n,i]=c.useState(!1),[s,o]=c.useState(!1),[r,l]=c.useState(!1),[u,g]=c.useState(!1),[h,m]=c.useState(null),[x,y]=c.useState(!1),[d,f]=c.useState(""),[p,v]=c.useState(!1),[S,A]=c.useState(""),[q,W]=c.useState(""),[Z,Y]=c.useState(!1),[Q,J]=c.useState(null),X=c.useMemo(()=>ot(e),[e]),ee=c.useMemo(()=>rt(e),[e]),te=c.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),ne=c.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:m,setGithubUrl:A,setProfileLoading:l,setPublicProfileOn:i,setShowGithubOn:v}),[]);return{anonymousOn:s,customDisplayName:h,displayName:X,editingGithub:Z,editingName:x,email:ee,githubError:Q,githubInput:q,githubUrl:S,loadSetters:ne,nameInput:d,profileLoading:r,profileSaving:u,publicProfileOn:n,setAnonymousOn:o,setCustomDisplayName:m,setEditingGithub:Y,setEditingName:y,setGithubError:J,setGithubInput:W,setGithubUrl:A,setNameInput:f,setProfileLoading:l,setProfileSaving:g,setPublicProfileOn:i,setShowGithubOn:v,showGithubOn:p,userId:te}}function dt(e,n,i){c.useEffect(()=>{if(!n)return;let s=!0;return i.setProfileLoading(!0),(async()=>{try{const o=await F({getAccessToken:e});if(!s||!o)return;const r=await de({accessToken:o});if(!s)return;i.setPublicProfileOn(!!r?.enabled),i.setAnonymousOn(!!r?.anonymous),r?.display_name&&i.setCustomDisplayName(r.display_name),i.setShowGithubOn(!!r?.show_github_url),i.setGithubUrl(r?.github_url||"")}catch(o){E("load public profile",o)}finally{s&&i.setProfileLoading(!1)}})(),()=>{s=!1}},[e,n,i])}function gt(e,n){return c.useCallback(async(i,{label:s,onError:o,onSuccess:r}={})=>{if(n.profileSaving)return!1;n.setProfileSaving(!0);try{const l=await F({getAccessToken:e});if(!l)return!1;const u=await ge({accessToken:l,...i});return r?.(u),!0}catch(l){return o?o(l):E(s||"mutate profile",l),!1}finally{n.setProfileSaving(!1)}},[e,n])}function ht(e,n){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:n.handleAnonymousToggle,handleSaveName:n.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:n.startEditingName}}function pt(e,n){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:n.handleSaveGithub,handleShowGithubToggle:n.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:n.startEditingGithub}}function mt(e,n){const i=c.useCallback(async()=>{const o=!e.publicProfileOn;await n({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[n,e]);return{handleAnonymousToggle:c.useCallback(async()=>{const o=!e.anonymousOn;await n({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[n,e]),handlePublicProfileToggle:i}}function bt(e,n,i){const s=c.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await n({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),i?.()}})},[n,e,i]),o=c.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:s,startEditingName:o}}function ft(e,n){const i=c.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await n({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[n,e]),s=c.useCallback(async()=>{const r=lt(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(a("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await n({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||a("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[n,e]),o=c.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:s,handleShowGithubToggle:i,startEditingGithub:o}}function xt(){const e=oe(),n=ut(e.user),i=ct(e.getAccessToken,e.enabled,e.signedIn);dt(e.getAccessToken,e.signedIn,n.loadSetters);const s=gt(e.getAccessToken,n),o=mt(n,s),r=bt(n,s,e.refreshDisplayName),l=ft(n,s);return{...e,...i,email:n.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:n.userId,name:ht(n,{...o,...r}),github:pt(n,l),profileLoading:n.profileLoading,profileSaving:n.profileSaving,publicProfileOn:n.publicProfileOn}}function V({disabled:e,onCancel:n,onSave:i,saveLabel:s=a("settings.account.save")}){return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:i,disabled:e,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:s}),t.jsx("button",{type:"button",onClick:n,className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:a("settings.account.cancel")})]})}function yt({nameInput:e,setEditingName:n,setNameInput:i,profileSaving:s,handleSaveName:o}){return t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"text",value:e,onChange:r=>i(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&n(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:a("settings.account.displayName")}),t.jsx(V,{disabled:s||!e.trim(),onCancel:()=>n(!1),onSave:o,saveLabel:s?a("settings.account.saving"):void 0})]})}function vt({githubError:e,githubInput:n,handleSaveGithub:i,profileSaving:s,setEditingGithub:o,setGithubError:r,setGithubInput:l}){return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:n,onChange:u=>{l(u.target.value),e&&r(null)},onKeyDown:u=>{u.key==="Enter"&&i(),u.key==="Escape"&&(o(!1),r(null))},maxLength:100,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 bg-transparent px-2.5 py-1.5 text-sm text-oai-black outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500 dark:border-oai-gray-700 dark:text-white",placeholder:a("settings.account.githubUrlPlaceholder")}),t.jsx(V,{disabled:s,onCancel:()=>{o(!1),r(null)},onSave:i,saveLabel:s?a("settings.account.saving"):void 0})]}),e?t.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:e}):null]})}function z({disabled:e=!1,label:n,onClick:i,title:s}){return t.jsxs("button",{type:"button",onClick:i,disabled:e,title:s,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Pe,{className:"h-3.5 w-3.5","aria-hidden":!0}),n]})}function K({actions:e,editing:n,editor:i,hint:s,label:o}){return t.jsx("div",{className:"py-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:o}),n?i:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:s})]}),n?null:e]})})}function jt({name:e}){const n=e.anonymousOn?a("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(z,{disabled:e.anonymousOn,label:a("settings.account.edit"),onClick:e.startEditingName,title:n}),t.jsx(j,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:a("settings.account.displayName")})]})}function kt({name:e}){const{anonymousOn:n,customDisplayName:i,displayName:s,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:u,profileLoading:g,profileSaving:h,setEditingName:m,setNameInput:x,startEditingName:y}=e,d=n?a("settings.account.displayNameAnonymousHint"):i||s;return t.jsx(K,{label:a("settings.account.displayName"),editing:o,hint:d,editor:t.jsx(yt,{nameInput:u,setEditingName:m,setNameInput:x,profileSaving:h,handleSaveName:l}),actions:t.jsx(jt,{name:e})})}function Nt({github:e}){const{editingGithub:n,githubError:i,githubInput:s,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:u,profileSaving:g,setEditingGithub:h,setGithubError:m,setGithubInput:x,showGithubOn:y,startEditingGithub:d}=e;return t.jsx(t.Fragment,{children:t.jsx(K,{label:a("settings.account.githubUrl"),editing:n,hint:o||a("settings.account.githubUrlHint"),editor:t.jsx(vt,{githubError:i,githubInput:s,handleSaveGithub:r,profileSaving:g,setEditingGithub:h,setGithubError:m,setGithubInput:x}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(z,{label:a("settings.account.edit"),onClick:d}),t.jsx(j,{checked:y,onChange:l,disabled:u||g,ariaLabel:a("settings.account.githubUrl")})]})})})}function St(){const{openLoginModal:e}=he();return t.jsx(k,{title:a("settings.section.account"),children:t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("settings.account.signedOutHint")}),t.jsx("button",{type:"button",onClick:e,className:"inline-flex h-8 shrink-0 items-center justify-center rounded-md bg-oai-gray-900 px-4 text-xs font-medium text-white transition-colors hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100",children:a("settings.account.signIn")})]})})}function wt({name:e,github:n}){return t.jsxs(t.Fragment,{children:[t.jsx(kt,{name:e}),t.jsx(Nt,{github:n})]})}function Ct(){const e=xt();return e.enabled?e.signedIn?t.jsxs(k,{title:a("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Et,{onSignOut:e.signOut}),children:[t.jsx(Lt,{userId:e.userId}),t.jsx(At,{settings:e}),t.jsx(Gt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(It,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(St,{}):null}function Lt({userId:e}){const[n,i]=C.useState(!1);if(!e)return null;const s=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),i(!0),globalThis.setTimeout(()=>i(!1),1200)}catch{i(!1)}};return t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:a("settings.account.userId")}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-oai-gray-500 dark:text-oai-gray-400",children:e})]}),t.jsxs("button",{type:"button",onClick:s,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800","aria-label":a("settings.account.copyUserId"),children:[n?t.jsx(Te,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(De,{className:"h-3.5 w-3.5","aria-hidden":!0}),n?a("settings.account.copied"):a("settings.account.copy")]})]})}function Et({onSignOut:e}){return t.jsxs("button",{type:"button",onClick:()=>e(),className:"inline-flex h-7 items-center gap-1.5 text-xs font-medium text-oai-gray-500 transition-colors hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:[t.jsx(Ye,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.account.signOut")]})}function At({settings:e}){return e.showLocalCloudSync?t.jsx(b,{label:a("settings.account.cloudSync"),hint:a("settings.account.cloudSyncHint"),control:t.jsx(j,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:a("settings.account.cloudSync")})}):null}function Gt({checked:e,disabled:n,onChange:i}){return t.jsx(b,{label:a("settings.account.publicProfile"),hint:a("settings.account.publicProfileHint"),control:t.jsx(j,{checked:e,onChange:i,disabled:n,ariaLabel:a("settings.account.publicProfile")})})}function It({visible:e,name:n,github:i}){return t.jsx(pe,{initial:!1,children:e?t.jsx(U.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:t.jsx(wt,{name:n,github:i})},"public-profile-fields"):null})}function Pt(){return[{value:"light",label:a("settings.appearance.theme.light"),Icon:be},{value:"dark",label:a("settings.appearance.theme.dark"),Icon:fe},{value:"system",label:a("settings.appearance.theme.system"),Icon:xe}]}function _t(){return[{value:je,label:a("settings.appearance.language.system")},{value:ke,label:a("settings.appearance.language.english")},{value:Ne,label:a("settings.appearance.language.chinese")},{value:Se,label:a("settings.appearance.language.traditional_chinese")},{value:we,label:a("settings.appearance.language.japanese")},{value:Ce,label:a("settings.appearance.language.korean")},{value:Le,label:a("settings.appearance.language.german")}]}function Ot(e){if(!e)return null;try{const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toLocaleString()}catch{return null}}function Tt(e,n){const i=a(`settings.appearance.currency.rate_source.${e}`),s=Ot(n),o=s?a("settings.appearance.currency.rate_updated",{when:s}):a("settings.appearance.currency.rate_never");return`${i} · ${o}`}function Dt({locale:e,setLocale:n}){const i=_t();return t.jsx($,{value:e,onValueChange:n,options:i,ariaLabel:a("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx(We,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function Mt({currency:e,setCurrency:n}){const i=ye().map(s=>({value:s.code,label:a(s.labelKey)}));return t.jsx($,{value:e,onValueChange:n,options:i,ariaLabel:a("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function Ut({currency:e,rate:n,rateSource:i,rateFetchedAt:s}){if(e===ve)return t.jsx(t.Fragment,{children:a("settings.appearance.currency.hint")});const o=Tt(i,s);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${n.toFixed(4)} ${e}`}),t.jsx("span",{role:"img","aria-label":o,title:o,className:"inline-flex h-4 w-4 cursor-help items-center justify-center text-oai-gray-400 hover:text-oai-gray-600 dark:text-oai-gray-500 dark:hover:text-oai-gray-300",children:t.jsx(Fe,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function Ft(){const{theme:e,setTheme:n}=me(),{locale:i,setLocale:s}=R(),{currency:o,rate:r,rateSource:l,rateFetchedAt:u,setCurrency:g}=Me(),{mode:h,setMode:m}=Ue();return t.jsxs(k,{title:a("settings.section.appearance"),children:[t.jsx(b,{label:a("settings.appearance.theme.label"),hint:a("settings.appearance.theme.hint"),control:t.jsx(L,{options:Pt(),value:e,onChange:n})}),t.jsx(b,{label:a("settings.appearance.language.label"),hint:a("settings.appearance.language.hint"),control:t.jsx(Dt,{locale:i,setLocale:s})}),t.jsx(b,{label:a("settings.appearance.currency.label"),hint:t.jsx(Ut,{currency:o,rate:r,rateSource:l,rateFetchedAt:u}),control:t.jsx(Mt,{currency:o,setCurrency:g})}),t.jsx(b,{label:a("settings.appearance.token_format.label"),hint:a("settings.appearance.token_format.hint"),control:t.jsx(L,{options:[{value:I.COMPACT,label:a("settings.appearance.token_format.compact")},{value:I.FULL,label:a("settings.appearance.token_format.full")}],value:h,onChange:m})})]})}function M({labelKey:e}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:a(e)}),t.jsx("span",{className:"px-1.5 py-0.5 text-[8px] font-semibold tracking-wider text-oai-gray-500 bg-oai-gray-100 dark:text-oai-gray-400 dark:bg-oai-gray-800/80 rounded uppercase scale-90 origin-left",children:a("qpd.card.badge")})]})}function Rt(){const{enabled:e,toggle:n}=_e(),{enabled:i,toggle:s}=Oe();return t.jsxs(k,{title:a("settings.section.labs"),children:[t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.qpd.label"}),hint:a("settings.labs.qpd.hint"),control:t.jsx(j,{checked:e,onChange:n,ariaLabel:a("settings.labs.qpd.aria")})}),t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.sessions.label"}),hint:a("settings.labs.sessions.hint"),control:t.jsx(j,{checked:i,onChange:s,ariaLabel:a("settings.labs.sessions.aria")})})]})}function Ht(){const{available:e,settings:n,setSetting:i,runAction:s}=H();if(!e)return null;const o=!!n?.launchAtLogin,r=n?.launchAtLoginSupported!==!1,l=n?.updateStatus||null,u=!!n?.updateBusy,g=!!n?.isSyncing;return t.jsxs(k,{title:a("settings.section.menubar"),children:[t.jsx(b,{label:a("settings.menubar.appearance"),hint:a("settings.menubar.appearanceHint"),control:t.jsxs(Ee,{to:"/widgets",className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 no-underline transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[a("settings.menubar.appearanceLink"),t.jsx(He,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),r?t.jsx(b,{label:a("settings.menubar.launchAtLogin"),hint:a("settings.menubar.launchAtLoginHint"),control:t.jsx(j,{checked:o,onChange:()=>i("launchAtLogin",!o),ariaLabel:a("settings.menubar.launchAtLogin")})}):null,t.jsx(b,{label:a("settings.menubar.syncNow"),hint:a("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>s("syncNow"),disabled:g,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Ae,{className:N("h-3.5 w-3.5",g&&"animate-spin"),"aria-hidden":!0}),g?a("settings.menubar.syncing"):a("settings.menubar.syncNow")]})}),t.jsx(b,{label:a("settings.menubar.updates"),hint:l||void 0,control:t.jsxs("button",{type:"button",onClick:()=>s("checkForUpdates"),disabled:u,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx($e,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.menubar.checkUpdates")]})})]})}function $t(e,n){function i(r){return r.replace(/^v/,"").split(".").map(Number)}const s=i(e),o=i(n);for(let r=0;r<Math.max(s.length,o.length);r++){const l=s[r]||0,u=o[r]||0;if(l<u)return!0;if(l>u)return!1}return!1}function Bt(){const{available:e,settings:n,runAction:i}=H(),s=e&&n?.version,[o,r]=C.useState(!1),[l,u]=C.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:g}=R(),h="0.83.1",m=async()=>{r(!0);try{const p=await fetch("https://api.github.com/repos/mm7894215/TokenTracker/releases/latest");if(!p.ok)throw new Error("Failed to fetch");const v=await p.json(),S=v.tag_name;$t(h,S)?u({open:!0,latestVersion:S,htmlUrl:v.html_url}):P({title:a("settings.menubar.updates.upToDate")})}catch(p){console.error("Check updates failed:",p),P({title:a("settings.menubar.updates.failed")})}finally{r(!1)}},x=a("settings.menubar.updates.modalTitle"),y=a("settings.menubar.updates.modalDescription",{version:l.latestVersion}),d=a("settings.menubar.updates.modalConfirm"),f=a("settings.menubar.updates.modalCancel");return t.jsxs("div",{className:"mt-6 flex flex-col items-center justify-center gap-4 text-xs text-oai-gray-500 dark:text-oai-gray-500",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[s?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:a("settings.menubar.updates.footerCombined",{barVersion:n.version,coreVersion:h})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>i("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:a("settings.menubar.updates.footerCore",{version:h})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:m,disabled:o,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:o?a("settings.menubar.updates.checking"):a("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Ge,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:[t.jsx(Ve,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.footer.statusPage")]})]}),t.jsx(Re,{open:l.open,title:x,description:y,confirmLabel:d,cancelLabel:f,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),u(p=>({...p,open:!1}))},onCancel:()=>u(p=>({...p,open:!1}))})]})}function Vt({prefs:e}){return t.jsx(L,{options:[{value:_.USED,label:a("limits.settings.display_mode_used")},{value:_.REMAINING,label:a("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function dn(){const e=Ie();return t.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:t.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:t.jsxs("div",{className:"mx-auto max-w-3xl px-4 sm:px-6",children:[t.jsxs("div",{className:"mb-8",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("settings.page.title")}),t.jsx("p",{className:"mt-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("settings.page.subtitle")})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(Ft,{}),t.jsx(Ht,{}),t.jsx(Ct,{}),t.jsx(Rt,{}),t.jsx(k,{title:a("settings.section.limits"),action:t.jsx(Vt,{prefs:e}),children:t.jsx(st,{prefs:e})})]}),t.jsx(Bt,{})]})})})}export{dn as SettingsPage};