tokentracker-cli 0.87.0 → 0.87.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 (103) hide show
  1. package/dashboard/dist/assets/{AchievementBadge-CU9m5POo.js → AchievementBadge-C468-Rsw.js} +1 -1
  2. package/dashboard/dist/assets/{AchievementsPage-ESzayVR5.js → AchievementsPage-CZWzSdiH.js} +2 -2
  3. package/dashboard/dist/assets/{AchievementsSection-DUVRqw19.js → AchievementsSection-DXt6VbwH.js} +1 -1
  4. package/dashboard/dist/assets/{BadgeDetailModal-CxNQcN6_.js → BadgeDetailModal-BtGvpqQm.js} +1 -1
  5. package/dashboard/dist/assets/{Card-DXIoSOtO.js → Card-DZ-_fXkw.js} +1 -1
  6. package/dashboard/dist/assets/{ClawdAnimated-BsuxMkNd.js → ClawdAnimated-9rXaHo1-.js} +1 -1
  7. package/dashboard/dist/assets/{CommandPalette-C-amBp21.js → CommandPalette-sqIvZNsH.js} +1 -1
  8. package/dashboard/dist/assets/{CommunityStatsModal-ByFOQube.js → CommunityStatsModal-c8VohIqQ.js} +1 -1
  9. package/dashboard/dist/assets/{ConfirmModal-BnUyidbn.js → ConfirmModal-Ct2HLdds.js} +1 -1
  10. package/dashboard/dist/assets/Controls-DPtXGUGi.js +1 -0
  11. package/dashboard/dist/assets/DashboardPage-C65hbl8o.js +1 -0
  12. package/dashboard/dist/assets/{DevicePage-B_o-jhku.js → DevicePage-Ds4GEuqY.js} +1 -1
  13. package/dashboard/dist/assets/{DialogClose-BSd7Jiag.js → DialogClose-B2IAbJG4.js} +1 -1
  14. package/dashboard/dist/assets/DialogDescription-DeRza-LI.js +1 -0
  15. package/dashboard/dist/assets/{DialogTitle-XBpneDtQ.js → DialogTitle-BIwLH6gA.js} +1 -1
  16. package/dashboard/dist/assets/{FadeIn-Dg0v4V9p.js → FadeIn-DPS7_DOB.js} +1 -1
  17. package/dashboard/dist/assets/{HeaderGithubStar-BIsQD1OK.js → HeaderGithubStar-CsSgr9Hd.js} +1 -1
  18. package/dashboard/dist/assets/{HoverTooltip-CtmRa8ne.js → HoverTooltip-CLGZW2d-.js} +1 -1
  19. package/dashboard/dist/assets/{IpCheckPage-BUoLz5sL.js → IpCheckPage-DEM_uk69.js} +1 -1
  20. package/dashboard/dist/assets/{LandingPage-BheA-lw8.js → LandingPage-BQ3YzZ68.js} +2 -2
  21. package/dashboard/dist/assets/{LeaderboardAvatar-DAy9SOdL.js → LeaderboardAvatar-ySznr4Ml.js} +1 -1
  22. package/dashboard/dist/assets/{LeaderboardPage-CwLqtEUN.js → LeaderboardPage-Br4JCoVE.js} +2 -2
  23. package/dashboard/dist/assets/{LeaderboardProfileModal-BZ9yGyjB.js → LeaderboardProfileModal-Drvsb5xF.js} +3 -3
  24. package/dashboard/dist/assets/{LeaderboardProfilePage-Cs-LTfvS.js → LeaderboardProfilePage-BD0P-zZF.js} +1 -1
  25. package/dashboard/dist/assets/{LimitsPage-BQle8e8N.js → LimitsPage-Mbn2mj6S.js} +1 -1
  26. package/dashboard/dist/assets/{LocalOnlyNotice-Bp4CqObQ.js → LocalOnlyNotice-BsKgtoVa.js} +1 -1
  27. package/dashboard/dist/assets/{LoginCard-BIXfWkR2.js → LoginCard-CTQDdHcx.js} +1 -1
  28. package/dashboard/dist/assets/{LoginModal-B-ubPXdr.js → LoginModal-BxCyLDEW.js} +1 -1
  29. package/dashboard/dist/assets/{LoginPage-9arjWT-s.js → LoginPage-ftxnX8g1.js} +1 -1
  30. package/dashboard/dist/assets/PetPage-CQsfqsm8.js +1 -0
  31. package/dashboard/dist/assets/{PopoverPopup-DMg7XE1h.js → PopoverPopup-C16r8jQC.js} +1 -1
  32. package/dashboard/dist/assets/{ProviderIcon-BG3oqeST.js → ProviderIcon-7Tkq9_m6.js} +1 -1
  33. package/dashboard/dist/assets/{ResetPasswordPage-LQ9rfcRE.js → ResetPasswordPage-D-MPpQd1.js} +1 -1
  34. package/dashboard/dist/assets/{SegmentedControl-GY2tRk1u.js → SegmentedControl-CYFrzu9w.js} +1 -1
  35. package/dashboard/dist/assets/{Select-CCngFwmz.js → Select-Dp4V9p6t.js} +1 -1
  36. package/dashboard/dist/assets/{SelectItemText-B9Zm8WTR.js → SelectItemText-CxhBeoxx.js} +1 -1
  37. package/dashboard/dist/assets/{ServiceStatusPage-BxPvk1-W.js → ServiceStatusPage-BT6hvvLW.js} +1 -1
  38. package/dashboard/dist/assets/{SessionsPage-DGo6yAwP.js → SessionsPage-BopeZBiH.js} +1 -1
  39. package/dashboard/dist/assets/SettingsPage-D03GJJBd.js +1 -0
  40. package/dashboard/dist/assets/{SkillsPage-D0PB3WR5.js → SkillsPage-Cr8O6eOH.js} +1 -1
  41. package/dashboard/dist/assets/{TokenGalaxy-Chh_fPIv.js → TokenGalaxy-BoUsrUEs.js} +1 -1
  42. package/dashboard/dist/assets/{ToolbarRootContext-BXacVvrF.js → ToolbarRootContext-CwRaHhMN.js} +1 -1
  43. package/dashboard/dist/assets/{TrendMonitor-CjiCwNmO.js → TrendMonitor-BV2ugEsw.js} +1 -1
  44. package/dashboard/dist/assets/WidgetsPage-B7r4mvrw.js +1 -0
  45. package/dashboard/dist/assets/{WrappedPage-CEpBAMZR.js → WrappedPage-CFU9l22i.js} +1 -1
  46. package/dashboard/dist/assets/__vite-browser-external-CzQk3FUc.css +1 -0
  47. package/dashboard/dist/assets/{__vite-browser-external-Dyag-P6u.js → __vite-browser-external-Db9onipF.js} +10 -3
  48. package/dashboard/dist/assets/{agent-logos-CLQGE0AM.js → agent-logos-DSSn_SPi.js} +1 -1
  49. package/dashboard/dist/assets/{arrow-up-right-CU2HDjoG.js → arrow-up-right-COvrArNz.js} +1 -1
  50. package/dashboard/dist/assets/{check-CucGM5lh.js → check-CasSqiev.js} +1 -1
  51. package/dashboard/dist/assets/{chevron-right-DYzUvcID.js → chevron-right-B1PMeNoD.js} +1 -1
  52. package/dashboard/dist/assets/{copy-BFeQ31Tr.js → copy-D67vycfp.js} +1 -1
  53. package/dashboard/dist/assets/{download-Coq_llCX.js → download-adOCFO2v.js} +1 -1
  54. package/dashboard/dist/assets/{external-link-BJiDBW3d.js → external-link-DVanKEuy.js} +1 -1
  55. package/dashboard/dist/assets/{flame-5stsnhc0.js → flame-RbiHZM9b.js} +1 -1
  56. package/dashboard/dist/assets/{format-tokens-CpTJbo-2.js → format-tokens-DhMp1e1L.js} +1 -1
  57. package/dashboard/dist/assets/{icons-jsuvmnnO.js → icons-BC0p_aGr.js} +1 -1
  58. package/dashboard/dist/assets/{index-DSD3RLQ4.js → index-A41xjc83.js} +1 -1
  59. package/dashboard/dist/assets/{index-BU6GsTbx.js → index-CaRyTJ6K.js} +1 -1
  60. package/dashboard/dist/assets/{index-Bs97feNM.js → index-DrgBqR3o.js} +1 -1
  61. package/dashboard/dist/assets/{info-DNNUzeV_.js → info-D9LwqlnC.js} +1 -1
  62. package/dashboard/dist/assets/{limits-providers-DKTqNO55.js → limits-providers-CRHpXhmW.js} +1 -1
  63. package/dashboard/dist/assets/{link-2-DC1hnQcE.js → link-2-B5f4qFR0.js} +1 -1
  64. package/dashboard/dist/assets/{loader-circle-DtInM4Io.js → loader-circle-DCmwZEdS.js} +1 -1
  65. package/dashboard/dist/assets/{maximize-2-DxpsaYXp.js → maximize-2-BMalEDCZ.js} +1 -1
  66. package/dashboard/dist/assets/{provider-display-hkyvfEJF.js → provider-display-qMFRUZHm.js} +1 -1
  67. package/dashboard/dist/assets/{react-TbJoDSP4.js → react-BnaPNGj8.js} +1 -1
  68. package/dashboard/dist/assets/{search-C7bnqB9b.js → search-BrqBkLs2.js} +1 -1
  69. package/dashboard/dist/assets/{skills-api-D7glOWg7.js → skills-api-vo3iM6yD.js} +1 -1
  70. package/dashboard/dist/assets/{store-CCVlzuqv.js → store-BwMVXuz3.js} +1 -1
  71. package/dashboard/dist/assets/{terminal-uQlsmzGi.js → terminal-BiyUh_8k.js} +1 -1
  72. package/dashboard/dist/assets/{trash-2-B1yuX-oD.js → trash-2-DAr4sqkX.js} +1 -1
  73. package/dashboard/dist/assets/{use-community-stats-0Fs5nY1G.js → use-community-stats-Cg48Zphy.js} +1 -1
  74. package/dashboard/dist/assets/{use-limits-display-prefs-CrftAn62.js → use-limits-display-prefs-DfKtH1Zn.js} +1 -1
  75. package/dashboard/dist/assets/{use-ordered-list-DAdPjLb5.js → use-ordered-list-CnXfrWeF.js} +1 -1
  76. package/dashboard/dist/assets/use-reduced-motion-BIgYrbON.js +1 -0
  77. package/dashboard/dist/assets/{use-session-efficiency-pref-Cc52HiK0.js → use-session-efficiency-pref-CMDTCAAd.js} +1 -1
  78. package/dashboard/dist/assets/{use-transform-D76wHhX0.js → use-transform-B2d9Txt5.js} +1 -1
  79. package/dashboard/dist/assets/{use-usage-limits-B7Prb8rk.js → use-usage-limits-CJbTUl9W.js} +1 -1
  80. package/dashboard/dist/assets/{useCurrency-DWoM_A3s.js → useCurrency-B0hJte5f.js} +1 -1
  81. package/dashboard/dist/assets/{useScrollLock-Bp6ddiQo.js → useScrollLock-DuosKdSB.js} +1 -1
  82. package/dashboard/dist/assets/{useTokenFormat-DZOYz5HT.js → useTokenFormat-DB8pKLFM.js} +1 -1
  83. package/dashboard/dist/assets/{zap-DyeAeO8l.js → zap-rbzC4XgP.js} +1 -1
  84. package/dashboard/dist/index.html +2 -2
  85. package/dashboard/dist/ip-check.html +2 -2
  86. package/dashboard/dist/leaderboard.html +2 -2
  87. package/dashboard/dist/share.html +2 -2
  88. package/package.json +1 -1
  89. package/src/commands/device-login.js +12 -7
  90. package/src/commands/init.js +3 -0
  91. package/src/commands/sync.js +115 -20
  92. package/src/lib/grok-context-breakdown.js +124 -19
  93. package/src/lib/grok-limits.js +374 -9
  94. package/src/lib/pricing/seed-snapshot.json +1 -1
  95. package/src/lib/runtime-config.js +23 -3
  96. package/dashboard/dist/assets/DashboardPage-GyXkKYW0.js +0 -1
  97. package/dashboard/dist/assets/DialogDescription-BFBVGbUT.js +0 -1
  98. package/dashboard/dist/assets/PetPage-BzAVsvh6.js +0 -1
  99. package/dashboard/dist/assets/SettingsPage-ConPEiwO.js +0 -1
  100. package/dashboard/dist/assets/WidgetsPage-CBw9uBCO.js +0 -1
  101. package/dashboard/dist/assets/__vite-browser-external-hXV_ZYTG.css +0 -1
  102. package/dashboard/dist/assets/use-native-settings-CVqB9eoO.js +0 -1
  103. package/dashboard/dist/assets/use-reduced-motion-DVGYs3-k.js +0 -1
@@ -1 +0,0 @@
1
- import{m as E,S as re,ai as ie,r as l,aj as se,ak as oe,al as le,x as H,c as r,j as e,e as b,am as ne,a4 as U,X as de}from"./__vite-browser-external-Dyag-P6u.js";import{u as ce,T as O,S as me}from"./use-native-settings-CVqB9eoO.js";import{P as pe}from"./ProviderIcon-BG3oqeST.js";import{n as xe,C as q}from"./ClawdAnimated-BsuxMkNd.js";import{F}from"./FadeIn-Dg0v4V9p.js";import{L as ue}from"./link-2-DC1hnQcE.js";import{L as W}from"./loader-circle-DtInM4Io.js";import{Z as ge}from"./zap-DyeAeO8l.js";import{T as be}from"./trash-2-B1yuX-oD.js";import{D as he,a as fe,b as ye,c as ke,d as ve,e as je}from"./DialogTitle-XBpneDtQ.js";import{D as we}from"./DialogDescription-BFBVGbUT.js";import{D as Ne}from"./DialogClose-BSd7Jiag.js";import"./Card-DXIoSOtO.js";import"./react-TbJoDSP4.js";import"./use-reduced-motion-DVGYs3-k.js";import"./useScrollLock-Bp6ddiQo.js";import"./store-CCVlzuqv.js";const Se=[["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"}]],Ce=E("file-archive",Se);const Pe=[["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"}]],Ie=E("monitor-up",Pe);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"}]],Ae=E("upload",ze),De={visible:!1,character:"clawd",size:"medium"};function Te(){const t=re()&&ie(),[a,o]=l.useState(De);l.useEffect(()=>{if(!t)return;const m=se(s=>{o({visible:!!s.visible,character:xe(s.character),size:["small","medium","large"].includes(s.size)?s.size:"medium"})});return oe(),m},[t]);const d=l.useCallback((m,s)=>{o(x=>({...x,[m]:s})),t&&le(m,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 Ee(){const t=await fetch("/functions/tokentracker-pets",{headers:{Accept:"application/json"},cache:"no-store"}),a=await C(t),o=new Set(Array.isArray(a.hiddenBuiltinIds)?a.hiddenBuiltinIds:[]);return[...k.filter(d=>d.id==="clawd"||!o.has(d.id)),...Array.isArray(a.pets)?a.pets:[]]}async function M(t){const a=await H();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 Me(t){return M({action:"install_url",url:t})}async function $(t){const a=await H();return C(await fetch("/api/pets/import",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/zip",...a},cache:"no-store",body:t}))}function Be(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]=l.useState(T),[o,d]=l.useState(!0),[m,s]=l.useState(!1),x=l.useCallback(async()=>{d(!0);try{const u=await Ee();return T=u,a(u),s(!0),u}catch{return T=k,a(k),s(!1),k}finally{d(!1)}},[]);return l.useEffect(()=>{x()},[x]),{pets:t,loading:o,available:m,refresh:x}}const Ve={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 Re(){const t=r("pet.import.subtitle"),a="codex-pets.net",o=t.indexOf(a);return o<0?t:e.jsxs(e.Fragment,{children:[t.slice(0,o),e.jsx("a",{href:"https://codex-pets.net",target:"_blank",rel:"noreferrer",className:"underline decoration-oai-gray-400 underline-offset-2 transition-colors hover:text-oai-black dark:decoration-oai-gray-500 dark:hover:text-white",children:a}),t.slice(o+a.length)]})}const 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:o,onRemove:d,removeDisabled:m}){const s=t.nameKey?r(t.nameKey):t.displayName;return e.jsxs("div",{className:"group relative",children:[e.jsxs("button",{type:"button",onClick:o,"aria-pressed":a,className: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",Ve[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(q,{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:m,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","opacity-0 group-hover:opacity-100"),children:e.jsx(be,{className:"h-3 w-3","aria-hidden":!0})}):null]})}function Ue({pet:t,state:a,onStateChange:o}){const[d,m]=l.useState(null),s=l.useRef(null),x=v.find(function(n){return n.id===a}),u=r(x?.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:p=>{if(t?.spriteVersionNumber!==2||!s.current)return;const n=s.current.getBoundingClientRect(),h=p.clientX-(n.left+n.width/2),c=p.clientY-(n.top+n.height/2),j=(Math.atan2(h,-c)*180/Math.PI+360)%360;m(Math.round(j/22.5)%16)},onPointerLeave:()=>m(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(q,{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(p=>e.jsxs("button",{type:"button",onClick:()=>o(p.id),"aria-pressed":a===p.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===p.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(p.labelKey)}),e.jsx("span",{className:b("h-1 w-1 rounded-full transition-colors duration-200",a===p.id?"bg-oai-black dark:bg-white":"bg-transparent"),"aria-hidden":!0})]},p.id))})})]})}function Oe({pets:t,busy:a,error:o,onImport:d,onClose:m}){const[s,x]=l.useState(()=>new Set),u=n=>x(h=>{const c=new Set(h);return c.has(n)?c.delete(n):c.add(n),c}),p=t.length!==0&&s.size===t.length;return e.jsx(he,{open:!0,onOpenChange:n=>{!n&&!a&&m()},children:e.jsxs(fe,{children:[e.jsx(ye,{className:"fixed inset-0 z-50 bg-black/15 backdrop-blur-md dark:bg-black/40 animate-tt-fade-in"}),e.jsx(ke,{className:"fixed inset-0 z-50 flex items-center justify-center p-3 md:p-6",children:e.jsxs(ve,{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(je,{className:"text-base font-semibold",children:r("pet.codex.title")}),e.jsx(we,{className:"mt-0.5 text-xs leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r("pet.codex.subtitle")})]}),e.jsx(Ne,{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))}),o?e.jsx("p",{role:"alert",className:"mt-3 text-xs text-red-600 dark:text-red-400",children:o}):null]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-oai-gray-200/70 px-5 py-3 dark:border-oai-gray-800",children:[e.jsx("button",{type:"button",disabled:a||t.length===0,onClick:()=>x(p?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 ot(){const{available:t,settings:a,setSetting:o}=Te(),{pets:d,loading:m,available:s,refresh:x}=Ke(),[u,p]=l.useState(""),[n,h]=l.useState(""),[c,j]=l.useState(!1),[B,P]=l.useState([]),[Z,I]=l.useState(!1),[w,L]=l.useState(!1),[J,z]=l.useState(""),[Y,_]=l.useState("idle-living"),[K,G]=l.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=B.length!==0;l.useEffect(()=>{!m&&d.length>0&&!d.some(i=>i.id===y)&&o("character","clawd")},[m,d,y,o]);async function S(i,g=r("pet.import.success")){j(!0),h("");try{const f=await i();await x(),ne(),f?.pet?.id&&o("character",f.pet.id),U({title:g,timeout:4e3}),p("")}catch(f){h(f?.message||r("pet.import.failed"))}finally{j(!1)}}const D=l.useCallback(async()=>{if(!s){P([]);return}try{const i=await Le();P(i.importable)}catch{P([])}},[s]);l.useEffect(()=>{D()},[D]);async function ee(i){L(!0),z("");try{return await _e(i),await x(),await D(),U({title:r("pet.codex.imported"),timeout:4e3}),!0}catch(g){return z(g?.message||r("pet.import.failed")),!1}finally{L(!1)}}l.useEffect(()=>{if(!K)return;const i=window.setInterval(()=>{_(g=>{const f=v.findIndex(ae=>ae.id===g);return v[(f+1)%v.length].id})},5e3);return()=>window.clearInterval(i)},[K]);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(Ue,{pet:Q,state:Y,onStateChange:i=>{G(!1),_(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:()=>o("character",i.id),removeDisabled:c,onRemove:s&&i.id!=="clawd"?()=>S(async()=>(await Be(i.id),y===i.id&&o("character","clawd"),null),r("pet.import.removed")):void 0},i.id))}),A.available?e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 rounded-xl border border-oai-gray-200/70 bg-oai-gray-50/60 px-3 py-2.5 dark:border-oai-gray-800 dark:bg-oai-gray-900/40",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold",children:r("pet.menubar.title")}),e.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:r("pet.menubar.hint")})]}),e.jsx(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(Ae,{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(Re,{})}),e.jsxs("form",{className:"mt-3 flex gap-2",onSubmit:i=>{i.preventDefault(),!c&&u.trim()&&S(()=>Me(u))},children:[e.jsxs("label",{className:"relative flex min-w-0 flex-1 items-center",children:[e.jsx(ue,{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=>p(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:()=>{z(""),I(!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(pe,{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(Ce,{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(Oe,{pets:B,busy:w,error:J,onClose:()=>{w||I(!1)},onImport:async i=>{await ee(i)&&I(!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(Ie,{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:()=>o("visible",!a.visible),disabled:!t,ariaLabel:r("pet.controls.show")})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("div",{className:"text-sm font-medium",children:r("pet.controls.size")}),e.jsx("div",{className:"shrink-0",children:e.jsx(me,{options:te,value:a.size,onChange:i=>o("size",i),disabled:!t})})]})]})]}),t?null:e.jsxs("div",{className:"mt-6 flex gap-2 rounded-xl bg-oai-gray-100 p-3 text-xs leading-relaxed text-oai-gray-500 dark:bg-oai-gray-800/70 dark:text-oai-gray-400",children:[e.jsx(ge,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":!0}),r("pet.controls.native_only")]})]})]})})]})})})}export{ot as PetPage};
@@ -1 +0,0 @@
1
- import{m as C,r as u,j as t,e as N,c as a,a as ie,aq as oe,bd as re,aw as le,ax as ce,a7 as F,be as ue,bf as de,u as ge,d as O,Z as he,a1 as B,n as _,bg as me,bh as be,O as H,bi as pe,y as fe,bj as xe,bk as ye,bl as ve,bm as je,bn as ke,bo as Ne,bp as Se,L as Ce,R as we,bq as Le,br as Ae,a4 as G,h as Oe,bs as Ee}from"./__vite-browser-external-Dyag-P6u.js";import{b as Ie,g as Pe,L as T,m as $}from"./react-TbJoDSP4.js";import{u as _e,L as D}from"./use-limits-display-prefs-CrftAn62.js";import{P as Ge}from"./ProviderIcon-BG3oqeST.js";import{a as R,l as M}from"./limits-providers-DKTqNO55.js";import{a as S,T as x,b,S as E,u as L}from"./use-native-settings-CVqB9eoO.js";import{P as Te,u as De,a as Re}from"./use-session-efficiency-pref-Cc52HiK0.js";import{C as Me}from"./check-CucGM5lh.js";import{C as Ue}from"./copy-BFeQ31Tr.js";import{A as Fe}from"./index-BU6GsTbx.js";import{u as Be}from"./useCurrency-DWoM_A3s.js";import{u as He}from"./useTokenFormat-DZOYz5HT.js";import{S as V}from"./Select-CCngFwmz.js";import{I as $e}from"./info-DNNUzeV_.js";import{C as Ve}from"./ConfirmModal-BnUyidbn.js";import{A as qe}from"./arrow-up-right-CU2HDjoG.js";import{D as ze}from"./download-Coq_llCX.js";import"./Card-DXIoSOtO.js";import"./ToolbarRootContext-BXacVvrF.js";import"./useScrollLock-Bp6ddiQo.js";import"./SelectItemText-B9Zm8WTR.js";import"./DialogTitle-XBpneDtQ.js";import"./store-CCVlzuqv.js";import"./DialogDescription-BFBVGbUT.js";const Ke=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],Ze=C("flask-conical",Ke);const We=[["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"}]],Ye=C("grip-vertical",We);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"}]],Je=C("languages",Qe);const Xe=[["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"}]],et=C("log-out",Xe);const tt=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],nt=C("palette",tt);const at=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],st=C("user-round",at),it=e=>!e.isLayoutDirty&&e.willUpdate(!1);function U(){const e=new Set,n=new WeakMap,s=()=>e.forEach(it);return{add:i=>{e.add(i),n.set(i,i.addEventListener("willUpdate",s))},remove:i=>{e.delete(i);const o=n.get(i);o&&(o(),n.delete(i)),s()},dirty:s}}const ot=u.createContext(null);function rt(){const e=u.useRef(!1);return Ie(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function lt(){const e=rt(),[n,s]=u.useState(0),i=u.useCallback(()=>{e.current&&s(n+1)},[n]);return[u.useCallback(()=>Pe.postRender(i),[i]),n]}const q=e=>e===!0,ct=e=>q(e===!0)||e==="id",ut=({children:e,id:n,inherit:s=!0})=>{const i=u.useContext(T),o=u.useContext(ot),[r,l]=lt(),d=u.useRef(null),g=i.id||o;d.current===null&&(ct(s)&&g&&(n=n?g+"-"+n:g),d.current={id:n,group:q(s)&&i.group||U()});const p=u.useMemo(()=>({...d.current,forceRender:r}),[l]);return t.jsx(T.Provider,{value:p,children:e})},dt="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function gt({checked:e,onChange:n,ariaLabel:s}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,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 ht({prefs:e}){const{order:n,visibility:s,toggle:i,moveToward:o}=e,[r,l]=u.useState(null),[d,g]=u.useState(null),p=c=>m=>{l(c),m.dataTransfer.effectAllowed="move",m.dataTransfer.setData("text/plain",c)},h=c=>m=>{m.preventDefault(),m.dataTransfer.dropEffect="move",r&&r!==c&&d!==c&&(g(c),o(r,c))},y=()=>{l(null),g(null)},v=c=>{c.preventDefault(),l(null),g(null)};return t.jsx(ut,{children:t.jsx("div",{className:"flex flex-col",children:n.map(c=>{const m=s[c]!==!1,f=r===c;return t.jsxs($.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:p(c),onDragOver:h(c),onDragEnd:y,onDrop:v,className:N("flex items-center gap-3 py-2 rounded-md","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60",f&&"opacity-40"),style:{cursor:f?"grabbing":"grab"},children:[t.jsx(Ye,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),R(c)?t.jsx(Ge,{provider:R(c),size:18,className:N("pointer-events-none",dt)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:M(c)}),t.jsx("div",{onMouseDown:j=>j.stopPropagation(),draggable:!1,children:t.jsx(gt,{checked:m,onChange:()=>i(c),ariaLabel:`${a("limits.settings.toggle_visible")}: ${M(c)}`})})]},c)})})})}function mt(e){if(!e||typeof e!="object")return"";const n=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},s=e.profile&&typeof e.profile=="object"?e.profile:{},i=n.full_name||n.name||s.name||n.user_name||n.preferred_username;return typeof i=="string"&&i.trim()?i.trim():typeof e.email=="string"&&e.email.includes("@")?e.email.split("@")[0].trim()||e.email.trim():typeof e.email=="string"?e.email.trim():""}function bt(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function pt(e){const n=typeof e=="string"?e.trim():"";if(!n)return null;const s=n.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),i=n.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),o=s?.[1]||i?.[1];return o?`https://github.com/${o}`:null}function I(e,n){console.warn(`[tokentracker] settings ${e}:`,n)}function ft(e,n,s){const[i,o]=u.useState(()=>oe()),r=n&&s&&re(),l=u.useCallback(async()=>{const d=!i;if(le(d),o(d),!!d)try{await ce(()=>e())}catch(g){I("cloud sync",g)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:l,showLocalCloudSync:r}}function xt(e){const[n,s]=u.useState(!1),[i,o]=u.useState(!1),[r,l]=u.useState(!1),[d,g]=u.useState(!1),[p,h]=u.useState(null),[y,v]=u.useState(!1),[c,m]=u.useState(""),[f,j]=u.useState(!1),[w,P]=u.useState(""),[W,Y]=u.useState(""),[Q,J]=u.useState(!1),[X,ee]=u.useState(null),te=u.useMemo(()=>mt(e),[e]),ne=u.useMemo(()=>bt(e),[e]),ae=u.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),se=u.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:h,setGithubUrl:P,setProfileLoading:l,setPublicProfileOn:s,setShowGithubOn:j}),[]);return{anonymousOn:i,customDisplayName:p,displayName:te,editingGithub:Q,editingName:y,email:ne,githubError:X,githubInput:W,githubUrl:w,loadSetters:se,nameInput:c,profileLoading:r,profileSaving:d,publicProfileOn:n,setAnonymousOn:o,setCustomDisplayName:h,setEditingGithub:J,setEditingName:v,setGithubError:ee,setGithubInput:Y,setGithubUrl:P,setNameInput:m,setProfileLoading:l,setProfileSaving:g,setPublicProfileOn:s,setShowGithubOn:j,showGithubOn:f,userId:ae}}function yt(e,n,s){u.useEffect(()=>{if(!n)return;let i=!0;return s.setProfileLoading(!0),(async()=>{try{const o=await F({getAccessToken:e});if(!i||!o)return;const r=await ue({accessToken:o});if(!i)return;s.setPublicProfileOn(!!r?.enabled),s.setAnonymousOn(!!r?.anonymous),r?.display_name&&s.setCustomDisplayName(r.display_name),s.setShowGithubOn(!!r?.show_github_url),s.setGithubUrl(r?.github_url||"")}catch(o){I("load public profile",o)}finally{i&&s.setProfileLoading(!1)}})(),()=>{i=!1}},[e,n,s])}function vt(e,n){return u.useCallback(async(s,{label:i,onError:o,onSuccess:r}={})=>{if(n.profileSaving)return!1;n.setProfileSaving(!0);try{const l=await F({getAccessToken:e});if(!l)return!1;const d=await de({accessToken:l,...s});return r?.(d),!0}catch(l){return o?o(l):I(i||"mutate profile",l),!1}finally{n.setProfileSaving(!1)}},[e,n])}function jt(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 kt(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 Nt(e,n){const s=u.useCallback(async()=>{const o=!e.publicProfileOn;await n({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[n,e]);return{handleAnonymousToggle:u.useCallback(async()=>{const o=!e.anonymousOn;await n({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[n,e]),handlePublicProfileToggle:s}}function St(e,n,s){const i=u.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),s?.()}})},[n,e,s]),o=u.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function Ct(e,n){const s=u.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]),i=u.useCallback(async()=>{const r=pt(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=u.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:s,startEditingGithub:o}}function wt(){const e=ie(),n=xt(e.user),s=ft(e.getAccessToken,e.enabled,e.signedIn);yt(e.getAccessToken,e.signedIn,n.loadSetters);const i=vt(e.getAccessToken,n),o=Nt(n,i),r=St(n,i,e.refreshDisplayName),l=Ct(n,i);return{...e,...s,email:n.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:n.userId,name:jt(n,{...o,...r}),github:kt(n,l),profileLoading:n.profileLoading,profileSaving:n.profileSaving,publicProfileOn:n.publicProfileOn}}function z({disabled:e,onCancel:n,onSave:s,saveLabel:i=a("settings.account.save")}){return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:s,disabled:e,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-oai-brand-600 disabled:opacity-50",children:i}),t.jsx("button",{type:"button",onClick: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 Lt({nameInput:e,setEditingName:n,setNameInput:s,profileSaving:i,handleSaveName:o}){return t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("input",{type:"text",value:e,onChange:r=>s(r.target.value),onKeyDown:r=>{r.key==="Enter"&&o(),r.key==="Escape"&&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(z,{disabled:i||!e.trim(),onCancel:()=>n(!1),onSave:o,saveLabel:i?a("settings.account.saving"):void 0})]})}function At({githubError:e,githubInput:n,handleSaveGithub:s,profileSaving:i,setEditingGithub:o,setGithubError:r,setGithubInput:l}){return t.jsxs("div",{className:"mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"text",value:n,onChange:d=>{l(d.target.value),e&&r(null)},onKeyDown:d=>{d.key==="Enter"&&s(),d.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(z,{disabled:i,onCancel:()=>{o(!1),r(null)},onSave:s,saveLabel:i?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 K({disabled:e=!1,label:n,onClick:s,title:i}){return t.jsxs("button",{type:"button",onClick:s,disabled:e,title:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-40 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(Te,{className:"h-3.5 w-3.5","aria-hidden":!0}),n]})}function Z({actions:e,editing:n,editor:s,hint:i,label:o}){return t.jsx("div",{className:"py-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:o}),n?s:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i})]}),n?null:e]})})}function Ot({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(K,{disabled:e.anonymousOn,label:a("settings.account.edit"),onClick:e.startEditingName,title:n}),t.jsx(x,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:a("settings.account.displayName")})]})}function Et({name:e}){const{anonymousOn:n,customDisplayName:s,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:d,profileLoading:g,profileSaving:p,setEditingName:h,setNameInput:y,startEditingName:v}=e,c=n?a("settings.account.displayNameAnonymousHint"):s||i;return t.jsx(Z,{label:a("settings.account.displayName"),editing:o,hint:c,editor:t.jsx(Lt,{nameInput:d,setEditingName:h,setNameInput:y,profileSaving:p,handleSaveName:l}),actions:t.jsx(Ot,{name:e})})}function It({github:e}){const{editingGithub:n,githubError:s,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:d,profileSaving:g,setEditingGithub:p,setGithubError:h,setGithubInput:y,showGithubOn:v,startEditingGithub:c}=e;return t.jsx(t.Fragment,{children:t.jsx(Z,{label:a("settings.account.githubUrl"),editing:n,hint:o||a("settings.account.githubUrlHint"),editor:t.jsx(At,{githubError:s,githubInput:i,handleSaveGithub:r,profileSaving:g,setEditingGithub:p,setGithubError:h,setGithubInput:y}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(K,{label:a("settings.account.edit"),onClick:c}),t.jsx(x,{checked:v,onChange:l,disabled:d||g,ariaLabel:a("settings.account.githubUrl")})]})})})}function Pt(){const{openLoginModal:e}=ge();return t.jsx(S,{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 _t({name:e,github:n}){return t.jsxs(t.Fragment,{children:[t.jsx(Et,{name:e}),t.jsx(It,{github:n})]})}function Gt(){const e=wt();return e.enabled?e.signedIn?t.jsxs(S,{title:a("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Dt,{onSignOut:e.signOut}),children:[t.jsx(Tt,{userId:e.userId}),t.jsx(Rt,{settings:e}),t.jsx(Mt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(Ut,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(Pt,{}):null}function Tt({userId:e}){const[n,s]=O.useState(!1);if(!e)return null;const i=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(e),s(!0),globalThis.setTimeout(()=>s(!1),1200)}catch{s(!1)}};return t.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children: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:i,className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800","aria-label":a("settings.account.copyUserId"),children:[n?t.jsx(Me,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(Ue,{className:"h-3.5 w-3.5","aria-hidden":!0}),n?a("settings.account.copied"):a("settings.account.copy")]})]})}function Dt({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(et,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.account.signOut")]})}function Rt({settings:e}){return e.showLocalCloudSync?t.jsx(b,{label:a("settings.account.cloudSync"),hint:a("settings.account.cloudSyncHint"),control:t.jsx(x,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:a("settings.account.cloudSync")})}):null}function Mt({checked:e,disabled:n,onChange:s}){return t.jsx(b,{label:a("settings.account.publicProfile"),hint:a("settings.account.publicProfileHint"),control:t.jsx(x,{checked:e,onChange:s,disabled:n,ariaLabel:a("settings.account.publicProfile")})})}function Ut({visible:e,name:n,github:s}){return t.jsx(Fe,{initial:!1,children:e?t.jsx($.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(_t,{name:n,github:s})},"public-profile-fields"):null})}function Ft(){return[{value:"light",label:a("settings.appearance.theme.light"),Icon:me},{value:"dark",label:a("settings.appearance.theme.dark"),Icon:be},{value:"system",label:a("settings.appearance.theme.system"),Icon:H}]}function Bt(){return[{value:xe,label:a("settings.appearance.language.system")},{value:ye,label:a("settings.appearance.language.english")},{value:ve,label:a("settings.appearance.language.chinese")},{value:je,label:a("settings.appearance.language.traditional_chinese")},{value:ke,label:a("settings.appearance.language.japanese")},{value:Ne,label:a("settings.appearance.language.korean")},{value:Se,label:a("settings.appearance.language.german")}]}function Ht(e){if(!e)return null;try{const n=new Date(e);return Number.isNaN(n.getTime())?null:n.toLocaleString()}catch{return null}}function $t(e,n){const s=a(`settings.appearance.currency.rate_source.${e}`),i=Ht(n),o=i?a("settings.appearance.currency.rate_updated",{when:i}):a("settings.appearance.currency.rate_never");return`${s} · ${o}`}function Vt({locale:e,setLocale:n}){const s=Bt();return t.jsx(V,{value:e,onValueChange:n,options:s,ariaLabel:a("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx(Je,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function qt({currency:e,setCurrency:n}){const s=pe().map(i=>({value:i.code,label:a(i.labelKey)}));return t.jsx(V,{value:e,onValueChange:n,options:s,ariaLabel:a("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function zt({currency:e,rate:n,rateSource:s,rateFetchedAt:i}){if(e===fe)return t.jsx(t.Fragment,{children:a("settings.appearance.currency.hint")});const o=$t(s,i);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($e,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function Kt(){const{theme:e,setTheme:n}=he(),{locale:s,setLocale:i}=B(),{currency:o,rate:r,rateSource:l,rateFetchedAt:d,setCurrency:g}=Be(),{mode:p,setMode:h}=He();return t.jsxs(S,{title:a("settings.section.appearance"),children:[t.jsx(b,{label:a("settings.appearance.theme.label"),hint:a("settings.appearance.theme.hint"),control:t.jsx(E,{options:Ft(),value:e,onChange:n})}),t.jsx(b,{label:a("settings.appearance.language.label"),hint:a("settings.appearance.language.hint"),control:t.jsx(Vt,{locale:s,setLocale:i})}),t.jsx(b,{label:a("settings.appearance.currency.label"),hint:t.jsx(zt,{currency:o,rate:r,rateSource:l,rateFetchedAt:d}),control:t.jsx(qt,{currency:o,setCurrency:g})}),t.jsx(b,{label:a("settings.appearance.token_format.label"),hint:a("settings.appearance.token_format.hint"),control:t.jsx(E,{options:[{value:_.COMPACT,label:a("settings.appearance.token_format.compact")},{value:_.FULL,label:a("settings.appearance.token_format.full")}],value:p,onChange:h})})]})}function A({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 Zt(){const{enabled:e,toggle:n}=De(),{enabled:s,toggle:i}=Re(),{available:o,settings:r,setSetting:l}=L(),d=o&&!!r?.dynamicIslandSupported,g=!!r?.dynamicIslandEnabled;return t.jsxs(S,{title:a("settings.section.labs"),children:[d&&t.jsxs(t.Fragment,{children:[t.jsx(b,{label:t.jsx(A,{labelKey:"settings.labs.island.label"}),hint:a("settings.labs.island.hint"),control:t.jsx(x,{checked:g,onChange:()=>l("dynamicIslandEnabled",!g),ariaLabel:a("settings.labs.island.aria")})}),g&&t.jsx(b,{label:a("settings.labs.island_hide_menubar.label"),hint:a("settings.labs.island_hide_menubar.hint"),control:t.jsx(x,{checked:!!r?.hideMenuBarIcon,onChange:()=>l("hideMenuBarIcon",!r?.hideMenuBarIcon),ariaLabel:a("settings.labs.island_hide_menubar.aria")})})]}),t.jsx(b,{label:t.jsx(A,{labelKey:"settings.labs.qpd.label"}),hint:a("settings.labs.qpd.hint"),control:t.jsx(x,{checked:e,onChange:n,ariaLabel:a("settings.labs.qpd.aria")})}),t.jsx(b,{label:t.jsx(A,{labelKey:"settings.labs.sessions.label"}),hint:a("settings.labs.sessions.hint"),control:t.jsx(x,{checked:s,onChange:i,ariaLabel:a("settings.labs.sessions.aria")})})]})}function Wt(){const{available:e,settings:n,setSetting:s,runAction:i}=L();if(!e)return null;const o=!!n?.launchAtLogin,r=n?.toastOnReset!==!1,l=n?.confettiOnReset!==!1,d=n?.launchAtLoginSupported!==!1,g=n?.updateStatus||null,p=!!n?.updateBusy,h=!!n?.isSyncing;return t.jsxs(S,{title:a("settings.section.menubar"),children:[t.jsx(b,{label:a("settings.menubar.appearance"),hint:a("settings.menubar.appearanceHint"),control:t.jsxs(Ce,{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(qe,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),t.jsx(b,{label:a("settings.menubar.toastOnReset"),hint:a("settings.menubar.toastOnResetHint"),control:t.jsx(x,{checked:r,onChange:()=>s("toastOnReset",!r),ariaLabel:a("settings.menubar.toastOnReset")})}),t.jsx(b,{label:a("settings.menubar.confettiOnReset"),hint:a("settings.menubar.confettiOnResetHint"),control:t.jsx(x,{checked:l,onChange:()=>s("confettiOnReset",!l),ariaLabel:a("settings.menubar.confettiOnReset")})}),d?t.jsx(b,{label:a("settings.menubar.launchAtLogin"),hint:a("settings.menubar.launchAtLoginHint"),control:t.jsx(x,{checked:o,onChange:()=>s("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:()=>i("syncNow"),disabled:h,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(we,{className:N("h-3.5 w-3.5",h&&"animate-spin"),"aria-hidden":!0}),h?a("settings.menubar.syncing"):a("settings.menubar.syncNow")]})}),t.jsx(b,{label:a("settings.menubar.updates"),hint:g||void 0,control:t.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:p,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(ze,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.menubar.checkUpdates")]})})]})}function Yt(e,n){function s(r){return r.replace(/^v/,"").split(".").map(Number)}const i=s(e),o=s(n);for(let r=0;r<Math.max(i.length,o.length);r++){const l=i[r]||0,d=o[r]||0;if(l<d)return!0;if(l>d)return!1}return!1}function Qt(){const{available:e,settings:n,runAction:s}=L(),i=e&&n?.version,[o,r]=O.useState(!1),[l,d]=O.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:g}=B(),p="0.87.0",h=async()=>{r(!0);try{const f=await fetch("https://api.github.com/repos/mm7894215/TokenTracker/releases/latest");if(!f.ok)throw new Error("Failed to fetch");const j=await f.json(),w=j.tag_name;Yt(p,w)?d({open:!0,latestVersion:w,htmlUrl:j.html_url}):G({title:a("settings.menubar.updates.upToDate")})}catch(f){console.error("Check updates failed:",f),G({title:a("settings.menubar.updates.failed")})}finally{r(!1)}},y=a("settings.menubar.updates.modalTitle"),v=a("settings.menubar.updates.modalDescription",{version:l.latestVersion}),c=a("settings.menubar.updates.modalConfirm"),m=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:[i?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:a("settings.menubar.updates.footerCombined",{barVersion:n.version,coreVersion:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:()=>s("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:a("settings.menubar.updates.footerCore",{version:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:h,disabled:o,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:o?a("settings.menubar.updates.checking"):a("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:Le,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(Ae,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.footer.statusPage")]})]}),t.jsx(Ve,{open:l.open,title:y,description:v,confirmLabel:c,cancelLabel:m,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),d(f=>({...f,open:!1}))},onCancel:()=>d(f=>({...f,open:!1}))})]})}const k={APPEARANCE:"appearance",NATIVE_APP:"native-app",ACCOUNT:"account",LIMITS:"limits",LABS:"labs"};function Jt({prefs:e}){return t.jsx(E,{options:[{value:D.USED,label:a("limits.settings.display_mode_used")},{value:D.REMAINING,label:a("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function Sn(){const e=_e(),{available:n,settings:s,setSetting:i}=L(),o=s?.toastOnReset!==!1,r=s?.confettiOnReset!==!1,[l,d]=Oe(),g=l.get("section"),h=Object.values(k).includes(g)&&(g!==k.NATIVE_APP||n)?g:k.APPEARANCE,y=c=>{const m=new URLSearchParams(l);c===k.APPEARANCE?m.delete("section"):m.set("section",c),d(m,{replace:!0})},v=[{id:k.APPEARANCE,label:a("settings.section.appearance"),Icon:nt,content:t.jsx(Kt,{})},...n?[{id:k.NATIVE_APP,label:a("settings.section.menubar"),Icon:H,content:t.jsx(Wt,{})}]:[],{id:k.ACCOUNT,label:a("settings.section.account"),Icon:st,content:t.jsx(Gt,{})},{id:k.LIMITS,label:a("settings.section.limits"),Icon:Ee,content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs(S,{title:a("settings.section.limits"),children:[t.jsx(b,{label:a("limits.settings.display_mode_label"),control:t.jsx(Jt,{prefs:e})}),t.jsx(b,{label:a("settings.menubar.toastOnReset"),hint:a("settings.menubar.toastOnResetHint"),control:t.jsx(x,{checked:o,disabled:!n,onChange:()=>i("toastOnReset",!o),ariaLabel:a("settings.menubar.toastOnReset")})}),t.jsx(b,{label:a("settings.menubar.confettiOnReset"),hint:a("settings.menubar.confettiOnResetHint"),control:t.jsx(x,{checked:r,disabled:!n,onChange:()=>i("confettiOnReset",!r),ariaLabel:a("settings.menubar.confettiOnReset")})})]}),t.jsx(S,{title:a("settings.limits.providers"),children:t.jsx(ht,{prefs:e})})]})},{id:k.LABS,label:a("settings.section.labs"),Icon:Ze,content:t.jsx(Zt,{})}];return t.jsx("div",{className:"flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",children:t.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:t.jsxs("div",{className:"mx-auto w-full max-w-5xl px-4 sm:px-6",children:[t.jsx("div",{className:"mb-7",children:t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("settings.page.title")})}),t.jsxs("div",{className:"grid min-w-0 gap-6 md:grid-cols-[12rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[13.5rem_minmax(0,1fr)]",children:[t.jsx("aside",{className:"min-w-0 border-b border-oai-gray-200 pb-3 dark:border-oai-gray-800 md:border-b-0 md:border-r md:pb-0 md:pr-5",children:t.jsx("nav",{"aria-label":a("settings.page.title"),className:"flex gap-0 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden md:sticky md:top-6 md:flex-col md:gap-1 md:overflow-visible",children:v.map(({id:c,label:m,Icon:f})=>{const j=h===c;return t.jsxs("button",{id:`settings-nav-${c}`,type:"button","aria-current":j?"page":void 0,"aria-controls":`settings-panel-${c}`,onClick:()=>y(c),className:N("inline-flex min-h-10 min-w-max shrink-0 items-center gap-1.5 rounded-md px-2 py-2 text-left text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-oai-brand-500 md:w-full md:min-w-0 md:gap-2 md:px-3",j?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-white":"text-oai-gray-500 hover:bg-oai-gray-50 hover:text-oai-gray-900 dark:text-oai-gray-400 dark:hover:bg-oai-gray-900 dark:hover:text-oai-gray-200"),children:[t.jsx(f,{className:N("h-4 w-4 shrink-0",j?"text-oai-black dark:text-white":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:m})]},c)})})}),t.jsxs("div",{className:"min-w-0",children:[v.map(({id:c,label:m,content:f})=>t.jsx("section",{id:`settings-panel-${c}`,"aria-labelledby":`settings-nav-${c}`,"aria-label":m,"data-settings-panel":c,hidden:h!==c,children:f},c)),t.jsx(Qt,{})]})]})]})})})}export{Sn as SettingsPage};
@@ -1 +0,0 @@
1
- import{j as e,c as a,N as I,O as R,r as u,q as $,d as O,e as M}from"./__vite-browser-external-Dyag-P6u.js";import{S as W}from"./Select-CCngFwmz.js";import{u as E,T as K}from"./use-native-settings-CVqB9eoO.js";import{F as L,S as D,a as G}from"./FadeIn-Dg0v4V9p.js";import{A as z}from"./arrow-up-right-CU2HDjoG.js";import{D as H}from"./download-Coq_llCX.js";import"./ToolbarRootContext-BXacVvrF.js";import"./useScrollLock-Bp6ddiQo.js";import"./check-CucGM5lh.js";import"./SelectItemText-B9Zm8WTR.js";import"./Card-DXIoSOtO.js";import"./react-TbJoDSP4.js";import"./use-reduced-motion-DVGYs3-k.js";const U=["todayTokens","todayCost"],F=[{id:"todayTokens",label:"Today Tokens",shortLabel:"Tokens",category:"tokens"},{id:"todayCost",label:"Today Cost",shortLabel:"Cost",category:"cost"},{id:"last7dTokens",label:"Last 7 Days",shortLabel:"7d",category:"tokens"},{id:"totalTokens",label:"Total Tokens",shortLabel:"Total",category:"tokens"},{id:"totalCost",label:"Total Cost",shortLabel:"All $",category:"cost"},{id:"claude5h",label:"Claude 5h Limit",shortLabel:"Cl 5h",category:"limits"},{id:"claude7d",label:"Claude 7d Limit",shortLabel:"Cl 7d",category:"limits"},{id:"codex5h",label:"Codex 5h Limit",shortLabel:"Cx 5h",category:"limits"},{id:"codex7d",label:"Codex 7d Limit",shortLabel:"Cx 7d",category:"limits"},{id:"codexCredits",label:"Codex Credit Limit",shortLabel:"Cx Cred",category:"limits"},{id:"codexSpark5h",label:"Codex Spark 5h Limit",shortLabel:"Cx Spark 5h",category:"limits"},{id:"codexSpark7d",label:"Codex Spark 7d Limit",shortLabel:"Cx Spark 7d",category:"limits"},{id:"cursorPlan",label:"Cursor Plan Limit",shortLabel:"Cu Plan",category:"limits"},{id:"cursorAuto",label:"Cursor Auto Limit",shortLabel:"Cu Auto",category:"limits"},{id:"cursorAPI",label:"Cursor API Limit",shortLabel:"Cu API",category:"limits"},{id:"geminiPro",label:"Gemini Pro Limit",shortLabel:"Gm Pro",category:"limits"},{id:"geminiFlash",label:"Gemini Flash Limit",shortLabel:"Gm Flash",category:"limits"},{id:"geminiLite",label:"Gemini Lite Limit",shortLabel:"Gm Lite",category:"limits"},{id:"kimiWeekly",label:"Kimi Weekly Limit",shortLabel:"Km Wk",category:"limits"},{id:"kimi5h",label:"Kimi 5h Limit",shortLabel:"Km 5h",category:"limits"},{id:"kimiTotal",label:"Kimi Total Limit",shortLabel:"Km Tot",category:"limits"},{id:"kiroMonth",label:"Kiro Monthly Limit",shortLabel:"Kr Mo",category:"limits"},{id:"kiroBonus",label:"Kiro Bonus Limit",shortLabel:"Kr Bn",category:"limits"},{id:"copilotPremium",label:"Copilot Premium Limit",shortLabel:"Co Prem",category:"limits"},{id:"copilotChat",label:"Copilot Chat Limit",shortLabel:"Co Chat",category:"limits"},{id:"antigravityClaudeWeekly",label:"Antigravity Claude 7d Limit",shortLabel:"Ag Cl 7d",category:"limits"},{id:"antigravityClaude5h",label:"Antigravity Claude 5h Limit",shortLabel:"Ag Cl 5h",category:"limits"},{id:"antigravityGeminiWeekly",label:"Antigravity Gemini 7d Limit",shortLabel:"Ag Gm 7d",category:"limits"},{id:"antigravityGemini5h",label:"Antigravity Gemini 5h Limit",shortLabel:"Ag Gm 5h",category:"limits"}];function N(t,i=F,l=2){const s=new Set(i.map(n=>n.id)),o=new Set,r=Array.isArray(t)?t.filter(n=>!s.has(n)||o.has(n)?!1:(o.add(n),!0)):[];return(r.length>0?r:U).slice(0,Math.max(1,Number(l)||2))}const V=264,X=124,g="ui-rounded, -apple-system, system-ui",S=["#5A8CF2","#9973E6","#4DB8A6","#E68C59"],Y={claude:"#C77DFF",codex:"#34C759",cursor:"#FFCC00",gemini:"#0A84FF"};function q(t){return t>=.9?"#E64D4D":t>=.7?"#D9A633":"#33B866"}function b({size:t="sm",children:i}){const l=t==="lg",s=l?560:264,o=l?32:22;return e.jsx("div",{className:M("flex w-full items-center justify-center rounded-xl bg-oai-gray-100 dark:bg-oai-gray-950/60",l?"py-10 sm:py-14 px-6":"py-6 px-4"),children:e.jsx("div",{className:"overflow-hidden bg-white dark:bg-oai-gray-800 shadow-oai-md dark:shadow-[0_2px_4px_rgba(0,0,0,0.4),0_8px_24px_rgba(0,0,0,0.5)]",style:{width:"100%",maxWidth:s,aspectRatio:`${V} / ${X}`,borderRadius:o},children:i})})}function Z({size:t="sm"}){const i="M0,104 L14,104 C26,98 34,100 44,96 S58,88 68,92 80,100 90,94 102,80 112,82 126,92 136,88 150,74 162,76 178,88 188,86 204,72 216,74 236,84 250,80 L264,80",l=`${i} L264,124 L0,124 Z`,s=`sparkArea-${t}`;return e.jsx(b,{size:t,children:e.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:s,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#0A84FF",stopOpacity:"0.18"}),e.jsx("stop",{offset:"100%",stopColor:"#0A84FF",stopOpacity:"0"})]})}),e.jsx("text",{x:"14",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:a("widgets.preview.today")}),e.jsx("text",{x:"14",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:g,children:"203.2M"}),e.jsx("text",{x:"14",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:g,children:"$129.56 ±0%"}),e.jsx("text",{x:"134",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:a("widgets.preview.seven_days")}),e.jsx("text",{x:"134",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:g,children:"880.9M"}),e.jsx("text",{x:"134",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:g,children:"$673.61"}),e.jsx("path",{d:l,fill:`url(#${s})`,stroke:"none"}),e.jsx("path",{d:i,fill:"none",stroke:"#0A84FF",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const C=(()=>{const l=[];for(let s=0;s<26;s++)for(let o=0;o<7;o++){const r=Math.sin((s+1)*12.9898+(o+1)*78.233+17)*43758.5453,c=Math.floor(Math.abs(r-Math.floor(r))*100);l.push({w:s,d:o,v:c})}return l})();function _(t,i){return t<18?i?"#262626":"#e5e5e5":t<38?"rgba(10, 132, 255, 0.28)":t<58?"rgba(10, 132, 255, 0.50)":t<80?"rgba(10, 132, 255, 0.75)":"#0A84FF"}function J(){return e.jsx(b,{children:e.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[e.jsx("g",{transform:`translate(${19.5}, 10)`,className:"hidden dark:inline",children:C.map(r=>e.jsx("rect",{x:r.w*(7.5+1.2),y:r.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:_(r.v,!0)},`d-${r.w}-${r.d}`))}),e.jsx("g",{transform:`translate(${19.5}, 10)`,className:"dark:hidden",children:C.map(r=>e.jsx("rect",{x:r.w*(7.5+1.2),y:r.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:_(r.v,!1)},`l-${r.w}-${r.d}`))}),e.jsx("text",{x:19.5,y:"102",className:"fill-oai-black dark:fill-white",fontSize:"10",fontWeight:"700",fontFamily:g,children:"10.3B"}),e.jsx("text",{x:19.5+30,y:"102",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"500",children:a("widgets.preview.heatmap_summary",{days:202})})]})})}function Q(){const t=[{name:"claude-opus-4-6",value:"586.4M",pct:59},{name:"claude-sonnet-4-5-20250929",value:"218.7M",pct:22},{name:"gpt-5.4",value:"80.6M",pct:8},{name:"composer-2-fast",value:"52.1M",pct:5}],i=22,l=28,s=14,o=236;return e.jsx(b,{children:e.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:t.map((r,c)=>{const n=l+c*i,h=S[c%S.length];return e.jsxs("g",{children:[e.jsx("circle",{cx:"18",cy:n-3,r:"2.5",fill:h}),e.jsx("text",{x:"26",y:n,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:r.name}),e.jsx("text",{x:"218",y:n,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"600",fontFamily:g,children:r.value}),e.jsxs("text",{x:"250",y:n,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"600",fontFamily:g,children:[r.pct,"%"]}),e.jsx("rect",{x:s,y:n+4,width:o,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),e.jsx("rect",{x:s,y:n+4,width:Math.max(o*(r.pct/100),4),height:"2.8",rx:"1.4",fill:h})]},r.name)})})})}function ee(){const t=[{label:`${a("limits.provider.claude")} · ${a("limits.label.claude_7d")}`,source:"claude",reset:a("widgets.preview.reset_days",{days:1}),pct:61},{label:`${a("limits.provider.claude")} · ${a("limits.label.claude_5h")}`,source:"claude",reset:a("widgets.preview.reset_hours_minutes",{hours:4,minutes:28}),pct:4},{label:a("limits.provider.cursor"),source:"cursor",reset:a("widgets.preview.reset_days",{days:25}),pct:51},{label:`${a("limits.provider.codex")} · ${a("limits.label.codex_7d")}`,source:"codex",reset:a("widgets.preview.reset_days",{days:1}),pct:32}],i=22,l=28,s=14,o=236;return e.jsx(b,{children:e.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:t.map((r,c)=>{const n=l+c*i,h=Y[r.source],y=q(r.pct/100);return e.jsxs("g",{children:[e.jsx("circle",{cx:"18",cy:n-3,r:"2.5",fill:h}),e.jsx("text",{x:"26",y:n,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:r.label}),e.jsx("text",{x:"218",y:n,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:g,children:r.reset}),e.jsxs("text",{x:"250",y:n,textAnchor:"end",className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"700",fontFamily:g,children:[r.pct,"%"]}),e.jsx("rect",{x:s,y:n+4,width:o,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),e.jsx("rect",{x:s,y:n+4,width:Math.max(o*(r.pct/100),4),height:"2.8",rx:"1.4",fill:y})]},r.label)})})})}function te(t){switch(t.category){case"cost":return"$8.42";case"limits":return"62%";default:return t.id==="last7dTokens"?"1.8B":"203M"}}function ae(t,i){switch(t){case"todayTokens":return a("menubar.metric.today_tokens");case"todayCost":return a("menubar.metric.today_cost");case"last7dTokens":return a("menubar.metric.last_7d_tokens");case"totalTokens":return a("menubar.metric.total_tokens");case"totalCost":return a("menubar.metric.total_cost");case"claude5h":return a("menubar.metric.claude_5h");case"claude7d":return a("menubar.metric.claude_7d");case"codex5h":return a("menubar.metric.codex_5h");case"codex7d":return a("menubar.metric.codex_7d");case"codexCredits":return a("menubar.metric.codex_credits");case"codexSpark5h":return a("menubar.metric.codex_spark_5h");case"codexSpark7d":return a("menubar.metric.codex_spark_7d");default:return i}}function ie(t,i){const l=new Set(i.map(o=>o.id)),s=t.filter(o=>l.has(o));for(const o of i){if(s.length>=2)break;s.includes(o.id)||s.push(o.id)}return s.slice(0,2)}function se({slotConfigs:t,showStats:i}){return e.jsx("div",{className:"flex justify-center rounded-xl bg-gradient-to-b from-oai-gray-100 to-oai-gray-200 px-6 py-8 dark:from-oai-gray-950/80 dark:to-oai-gray-900/80",children:e.jsxs("div",{className:"inline-flex items-stretch rounded-md shadow-[0_1px_3px_rgba(0,0,0,0.18)] ring-1 ring-black/10 dark:ring-white/10 px-3",style:{background:"linear-gradient(180deg, #2c2c2e 0%, #1c1c1e 100%)"},children:[e.jsx("div",{className:"flex items-center pl-2 pr-1 py-2.5",children:e.jsx("img",{src:"/clawd/mini/idle-tight.svg",alt:"","aria-hidden":"true",className:"block shrink-0",style:{height:22,width:"auto"},draggable:"false"})}),i?t.map(({slot:l,item:s},o)=>e.jsxs(O.Fragment,{children:[o>0?e.jsx("span",{className:"my-1 w-px bg-white/20","aria-hidden":"true"}):null,e.jsxs("div",{className:M("flex min-w-[52px] flex-col items-center justify-center py-1.5",o===0?"pl-1 pr-2":"px-2"),children:[e.jsx("span",{className:"text-[13px] font-semibold leading-none tabular-nums text-white",children:s?.previewValue||"--"}),e.jsx("span",{className:"mt-[2px] text-[6px] font-semibold uppercase leading-none text-white/75",children:s?.shortLabel||a("widgets.preview.metric")})]})]},l)):null]})})}function re({slot:t,value:i,options:l,disabled:s,onChange:o}){const r=t===0?a("menubar.slot.primary"):a("menubar.slot.secondary");return e.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-oai-gray-500 dark:text-oai-gray-400",children:r}),e.jsx(W,{value:i,disabled:s,ariaLabel:r,onValueChange:c=>o(t,c),options:l.map(c=>({value:c.id,label:c.displayLabel})),matchTriggerWidth:!0,className:"w-full px-3 py-2 text-sm font-medium"})]})}function p({label:t,hint:i,checked:l,disabled:s,onChange:o}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:t}),i?e.jsx("p",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i}):null]}),e.jsx(K,{checked:l,disabled:s,onChange:o,ariaLabel:t})]})}function le({label:t,hint:i,value:l,options:s,disabled:o,onChange:r}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:t}),i?e.jsx("p",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i}):null]}),e.jsx(W,{value:l,disabled:o,ariaLabel:t,onValueChange:r,options:s,className:"shrink-0 px-3 py-2 text-sm font-medium"})]})}function oe(){const{available:t,settings:i,setSetting:l}=E(),s=u.useMemo(()=>(Array.isArray(i?.menuBarAvailableItems)?i.menuBarAvailableItems:F).map(m=>({...m,displayLabel:ae(m.id,m.label),previewValue:te(m)})),[i?.menuBarAvailableItems]),o=Number(i?.menuBarMaxItems)||2,r=u.useMemo(()=>N(i?.menuBarItems,s,o),[s,o,i?.menuBarItems]),c=u.useMemo(()=>ie(r,s),[s,r]),n=i?.showStats!==!1,h=d=>{l("menuBarItems",N(d,s,o))},y=(d,m)=>{const x=[...c];x[d===0?1:0]!==m&&(x[d]=m,h(x))},w=[0,1].map(d=>{const m=c[d]||s[d]?.id||"",v=c[d===0?1:0],B=s.filter(f=>f.id===m||f.id!==v),P=s.find(f=>f.id===m);return{slot:d,currentValue:m,options:B,item:P}}),T=["clawd","cat","pet","static"].includes(i?.menuBarIconStyle)?i.menuBarIconStyle:"clawd",k=i?.toastOnReset!==!1,j=i?.confettiOnReset!==!1;return e.jsxs("article",{className:"rounded-xl border border-oai-gray-200 bg-white p-5 transition-colors duration-200 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:p-6",children:[e.jsx(se,{slotConfigs:w,showStats:n}),e.jsx("div",{className:"mt-5 grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4",children:w.map(({slot:d,currentValue:m,options:x})=>e.jsx(re,{slot:d,value:m,options:x,disabled:!t||!n,onChange:y},d))}),e.jsxs("div",{className:"mt-5 divide-y divide-oai-gray-100 border-t border-oai-gray-100 dark:divide-oai-gray-800 dark:border-oai-gray-800",children:[e.jsx(p,{label:a("settings.menubar.showStats"),hint:t?a("settings.menubar.showStatsHint"):a("menubar.native_only"),checked:n,disabled:!t,onChange:()=>l("showStats",!n)}),e.jsx(le,{label:a("settings.menubar.iconStyle"),hint:a("settings.menubar.iconStyleHint"),value:T,disabled:!t,options:[{value:"clawd",label:a("settings.menubar.iconStyle.clawd")},{value:"cat",label:a("settings.menubar.iconStyle.cat")},{value:"pet",label:a("settings.menubar.iconStyle.pet")},{value:"static",label:a("settings.menubar.iconStyle.static")}],onChange:d=>l("menuBarIconStyle",d)}),e.jsx(p,{label:a("settings.menubar.toastOnReset"),hint:a("settings.menubar.toastOnResetHint"),checked:k,disabled:!t,onChange:()=>l("toastOnReset",!k)}),e.jsx(p,{label:a("settings.menubar.confettiOnReset"),hint:a("settings.menubar.confettiOnResetHint"),checked:j,disabled:!t,onChange:()=>l("confettiOnReset",!j)})]})]})}function ne(){const[t,i]=u.useState("loading");return u.useEffect(()=>{if(typeof window>"u")return;if($()){i("native");return}const l=(navigator.userAgent||"").toLowerCase(),s=/mac/.test(l)&&!/iphone|ipad/.test(l);i(s?"mac-web":"other")},[]),t}function ce(){const t=ne();return t==="loading"?e.jsx("div",{className:"h-10 w-40","aria-hidden":"true"}):t==="native"?e.jsxs("button",{type:"button",onClick:()=>I("openWidgetGallery"),className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[a("widgets.cta.open_gallery"),e.jsx(z,{className:"h-4 w-4","aria-hidden":"true"})]}):t==="mac-web"?e.jsxs("a",{href:"https://github.com/mm7894215/TokenTracker/releases/latest",target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white no-underline transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[e.jsx(H,{className:"h-4 w-4","aria-hidden":"true"}),a("widgets.cta.download")]}):e.jsxs("span",{className:"inline-flex h-10 items-center gap-2 rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 text-sm font-medium text-oai-gray-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-400",children:[e.jsx(R,{className:"h-4 w-4","aria-hidden":"true"}),a("widgets.cta.macos_only")]})}const de=[{id:"summary",Preview:Z,nameKey:"widgets.summary.name",descKey:"widgets.summary.description"},{id:"heatmap",Preview:J,nameKey:"widgets.heatmap.name",descKey:"widgets.heatmap.description"},{id:"topModels",Preview:Q,nameKey:"widgets.topModels.name",descKey:"widgets.topModels.description"},{id:"limits",Preview:ee,nameKey:"widgets.limits.name",descKey:"widgets.limits.description"}];function me({Preview:t,nameKey:i,descKey:l}){return e.jsxs("article",{className:"flex h-full flex-col rounded-xl border border-oai-gray-200 bg-white p-4 transition-colors duration-200 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:p-5",children:[e.jsx(t,{}),e.jsxs("div",{className:"mt-4",children:[e.jsx("h3",{className:"text-[15px] font-semibold text-oai-black dark:text-white",children:a(i)}),e.jsx("p",{className:"mt-1.5 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:a(l)})]})]})}function A({titleKey:t}){return e.jsx("h2",{className:"mb-4 text-xl font-semibold tracking-tight text-oai-black dark:text-white sm:mb-5 sm:text-2xl",children:a(t)})}function Se(){return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-4 sm:px-6",children:[e.jsx(L,{y:12,children:e.jsxs("header",{className:"mb-10 flex items-start justify-between gap-4 sm:mb-12",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("widgets.page.title")}),e.jsx("div",{className:"shrink-0",children:e.jsx(ce,{})})]})}),e.jsx(L,{y:12,delay:.06,children:e.jsxs("section",{"aria-label":a("widgets.menubar.section.title"),className:"mb-12 sm:mb-14",children:[e.jsx(A,{titleKey:"widgets.menubar.section.title"}),e.jsx(oe,{})]})}),e.jsxs("section",{"aria-label":a("widgets.gallery.section.title"),children:[e.jsx(A,{titleKey:"widgets.gallery.section.title"}),e.jsx(D,{staggerDelay:.08,initialDelay:.04,children:e.jsx("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2 lg:gap-5",children:de.map(({id:t,Preview:i,nameKey:l,descKey:s})=>e.jsx(G,{children:e.jsx(me,{Preview:i,nameKey:l,descKey:s})},t))})})]})]})})})}export{Se as WidgetsPage};