tokentracker-cli 0.5.82 → 0.5.84

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 (22) hide show
  1. package/dashboard/dist/assets/{Card-D89QXio1.js → Card-D9qs5F6a.js} +1 -1
  2. package/dashboard/dist/assets/DashboardPage-D6rRASfb.js +12 -0
  3. package/dashboard/dist/assets/{FadeIn-Je-IKTCi.js → FadeIn-58ii1scI.js} +1 -1
  4. package/dashboard/dist/assets/{IpCheckPage-CmkmxYbi.js → IpCheckPage-D_oSEAJv.js} +1 -1
  5. package/dashboard/dist/assets/{LeaderboardPage-k6ZhKD8v.js → LeaderboardPage-y-xpxCOw.js} +2 -2
  6. package/dashboard/dist/assets/{LeaderboardProfilePage-BnGBEWSR.js → LeaderboardProfilePage-D2Pg7C2E.js} +1 -1
  7. package/dashboard/dist/assets/LimitsPage-BGqjHAiJ.js +2 -0
  8. package/dashboard/dist/assets/{ProviderIcon-W5bQlVZy.js → ProviderIcon-DZe_sc0f.js} +1 -1
  9. package/dashboard/dist/assets/SettingsPage-CKqGPzGp.js +1 -0
  10. package/dashboard/dist/assets/{WidgetsPage-DJLzhtO0.js → WidgetsPage-BKlifAwP.js} +1 -1
  11. package/dashboard/dist/assets/{download-DcBCxxpH.js → download-CIOju6TK.js} +1 -1
  12. package/dashboard/dist/assets/{leaderboard-columns-BCCXSWB7.js → leaderboard-columns-C2HnsCRa.js} +1 -1
  13. package/dashboard/dist/assets/main-CT6BPeer.js +5051 -0
  14. package/dashboard/dist/assets/{use-limits-display-prefs-CUKlkCzX.js → use-limits-display-prefs-BCGcgZmr.js} +1 -1
  15. package/dashboard/dist/assets/{use-usage-limits-CDoWAIkh.js → use-usage-limits-DosliezS.js} +1 -1
  16. package/dashboard/dist/index.html +1 -1
  17. package/dashboard/dist/share.html +1 -1
  18. package/package.json +1 -1
  19. package/dashboard/dist/assets/DashboardPage-QTEFpkGt.js +0 -12
  20. package/dashboard/dist/assets/LimitsPage-J7QkP-Qk.js +0 -2
  21. package/dashboard/dist/assets/SettingsPage-D78h8ssI.js +0 -1
  22. package/dashboard/dist/assets/main-CtQnmeNT.js +0 -4975
@@ -1,2 +0,0 @@
1
- import{D as r,az as y,r as f,B as l,a9 as b,aL as j}from"./main-CtQnmeNT.js";import{u as v}from"./use-usage-limits-CDoWAIkh.js";import{u as k}from"./use-limits-display-prefs-CUKlkCzX.js";import{C as h}from"./Card-D89QXio1.js";import{F as N}from"./FadeIn-Je-IKTCi.js";const L=[3,2,3,3,2,2,3];function d({className:s}){return r.jsx("div",{className:y("rounded bg-oai-gray-200/70 dark:bg-oai-gray-800/70 animate-pulse",s)})}function P(){return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(d,{className:"h-3 w-12 shrink-0"}),r.jsx(d,{className:"flex-1 h-1.5 rounded-full min-w-0"}),r.jsx(d,{className:"h-3 w-[30px] shrink-0"}),r.jsx(d,{className:"h-3 w-6 shrink-0"})]})}function C({bars:s,index:e}){const o=e%3===0?"w-24":e%3===1?"w-20":"w-[4.5rem]";return r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(d,{className:"h-[14px] w-[14px] rounded shrink-0"}),r.jsx(d,{className:y("h-4",o)})]}),Array.from({length:s},(i,a)=>r.jsx(P,{},a))]})}function E(){return r.jsx(h,{children:r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx(d,{className:"h-3.5 w-28"}),L.map((s,e)=>r.jsx(C,{bars:s,index:e},e))]})})}function t(s){if(!s)return null;const e=typeof s=="number"?s*1e3:Date.parse(s);if(!Number.isFinite(e))return null;const o=e-Date.now();if(o<=0)return"now";const i=Math.floor(o/6e4);if(i<60)return`${i}m`;const a=Math.floor(i/60);return a<24?`${a}h`:`${Math.floor(a/24)}d`}function O(s){return s>=90?"bg-red-500":s>=70?"bg-amber-500":"bg-emerald-500"}function n({label:s,pct:e,reset:o}){const i=Math.max(0,Math.min(100,Number(e)||0)),a=Math.round(i),x=i>0&&a===0?Math.max(i,.35):i,u=i>0&&a===0?"<1":String(a);return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] text-oai-gray-500 dark:text-oai-gray-400 w-12 shrink-0",children:s}),r.jsx("div",{className:"flex-1 bg-oai-gray-100 dark:bg-oai-gray-700/50 rounded-full h-1.5 overflow-hidden",children:r.jsx("div",{className:`${O(a)} rounded-full h-full transition-[width] duration-500 ease-out`,style:{width:`${x}%`,minWidth:i>0?"3px":0}})}),r.jsxs("span",{className:"text-[11px] tabular-nums text-oai-gray-500 dark:text-oai-gray-400 w-[30px] text-right shrink-0",children:[u,"%"]}),o?r.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500 w-6 text-right shrink-0",children:o}):null]})}function c({name:s,icon:e,children:o}){const a=e==="/brand-logos/cursor.svg"||e==="/brand-logos/kiro.svg"?"w-[14px] h-[14px] dark:invert":"w-[14px] h-[14px]";return r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[e?r.jsx("img",{src:e,alt:"",className:a}):null,r.jsx("span",{className:"text-sm font-medium text-oai-black dark:text-oai-white",children:s})]}),o]})}const T=["claude","codex","cursor","gemini","kiro","copilot","antigravity"];function R(s,e){if(!(i=>i?.configured&&!i.error)(e))return null;switch(s){case"claude":return r.jsxs(c,{name:"Claude",icon:"/brand-logos/claude-code.svg",children:[e.five_hour?r.jsx(n,{label:"5h",pct:e.five_hour.utilization,reset:t(e.five_hour.resets_at)}):null,e.seven_day?r.jsx(n,{label:"7d",pct:e.seven_day.utilization,reset:t(e.seven_day.resets_at)}):null,e.seven_day_opus?r.jsx(n,{label:"Opus",pct:e.seven_day_opus.utilization,reset:t(e.seven_day_opus.resets_at)}):null]},"claude");case"codex":return r.jsxs(c,{name:"Codex",icon:"/brand-logos/codex.svg",children:[e.primary_window?r.jsx(n,{label:"5h",pct:e.primary_window.used_percent,reset:t(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(n,{label:"7d",pct:e.secondary_window.used_percent,reset:t(e.secondary_window.reset_at)}):null]},"codex");case"cursor":return r.jsxs(c,{name:"Cursor",icon:"/brand-logos/cursor.svg",children:[e.primary_window?r.jsx(n,{label:"Plan",pct:e.primary_window.used_percent,reset:t(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(n,{label:"Auto",pct:e.secondary_window.used_percent,reset:t(e.secondary_window.reset_at)}):null,e.tertiary_window?r.jsx(n,{label:"API",pct:e.tertiary_window.used_percent,reset:t(e.tertiary_window.reset_at)}):null]},"cursor");case"gemini":return r.jsxs(c,{name:"Gemini",icon:"/brand-logos/gemini.svg",children:[e.primary_window?r.jsx(n,{label:"Pro",pct:e.primary_window.used_percent,reset:t(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(n,{label:"Flash",pct:e.secondary_window.used_percent,reset:t(e.secondary_window.reset_at)}):null,e.tertiary_window?r.jsx(n,{label:"Lite",pct:e.tertiary_window.used_percent,reset:t(e.tertiary_window.reset_at)}):null]},"gemini");case"kiro":return r.jsxs(c,{name:"Kiro",icon:"/brand-logos/kiro.svg",children:[e.primary_window?r.jsx(n,{label:"Month",pct:e.primary_window.used_percent,reset:t(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(n,{label:"Bonus",pct:e.secondary_window.used_percent,reset:t(e.secondary_window.reset_at)}):null]},"kiro");case"antigravity":return r.jsxs(c,{name:"Antigravity",icon:"/brand-logos/antigravity.svg",children:[e.primary_window?r.jsx(n,{label:"Claude",pct:e.primary_window.used_percent,reset:t(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(n,{label:"G Pro",pct:e.secondary_window.used_percent,reset:t(e.secondary_window.reset_at)}):null,e.tertiary_window?r.jsx(n,{label:"Flash",pct:e.tertiary_window.used_percent,reset:t(e.tertiary_window.reset_at)}):null]},"antigravity");case"copilot":return r.jsxs(c,{name:"GitHub Copilot",icon:"/brand-logos/copilot.svg",children:[e.primary_window?r.jsx(n,{label:"Premium",pct:e.primary_window.used_percent,reset:t(e.primary_window.reset_at)}):null,e.secondary_window?r.jsx(n,{label:"Chat",pct:e.secondary_window.used_percent,reset:t(e.secondary_window.reset_at)}):null,e.otel_has_files||e.otel_enabled?null:r.jsx(A,{defaultDir:e.otel_default_dir})]},"copilot");default:return null}}function A({defaultDir:s}){const[e,o]=f.useState(!1),a=["export COPILOT_OTEL_ENABLED=true","export COPILOT_OTEL_EXPORTER_TYPE=file",`export COPILOT_OTEL_FILE_EXPORTER_PATH="${s||"$HOME/.copilot/otel"}/copilot-otel-$(date +%Y%m%d).jsonl"`].join(`
2
- `),x=async()=>{try{await navigator.clipboard.writeText(a),o(!0),setTimeout(()=>o(!1),1600)}catch{}};return r.jsxs("div",{className:"mt-1 rounded-md border border-amber-300/60 dark:border-amber-700/40 bg-amber-50/50 dark:bg-amber-900/10 px-2.5 py-2 text-[11px] text-oai-gray-600 dark:text-oai-gray-300",children:[r.jsx("div",{className:"font-medium text-oai-gray-700 dark:text-oai-gray-200",children:l("limits.copilot.otelHint.title")}),r.jsx("div",{className:"mt-0.5 leading-snug",children:l("limits.copilot.otelHint.body")}),r.jsx("pre",{className:"mt-1.5 overflow-x-auto rounded bg-oai-gray-100 dark:bg-oai-gray-900/60 px-2 py-1.5 font-mono text-[10.5px] leading-tight whitespace-pre",children:a}),r.jsx("button",{type:"button",onClick:x,className:"mt-1 inline-flex items-center gap-1 rounded border border-oai-gray-300 dark:border-oai-gray-700 px-1.5 py-0.5 text-[10.5px] text-oai-gray-700 dark:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:e?l("limits.copilot.otelHint.copied"):l("limits.copilot.otelHint.copy")})]})}function I({claude:s,codex:e,cursor:o,gemini:i,kiro:a,antigravity:x,copilot:u,order:p,visibility:w}){const _={claude:s,codex:e,cursor:o,gemini:i,kiro:a,antigravity:x,copilot:u},g=(Array.isArray(p)&&p.length>0?p:T).filter(m=>!w||w[m]!==!1).map(m=>R(m,_[m])).filter(Boolean);return g.length===0?null:r.jsx(N,{delay:.15,children:r.jsx(h,{children:r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:"Usage Limits"}),g]})})})}function $(){const{data:s,error:e,isLoading:o}=v({initialRefresh:!0}),i=k();return r.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:r.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:r.jsxs("div",{className:"mx-auto max-w-6xl px-4 sm:px-6",children:[r.jsxs("div",{className:"flex flex-row items-start justify-between gap-4 mb-8",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white mb-3",children:l("nav.limits")}),r.jsx("p",{className:"text-oai-gray-500 dark:text-oai-gray-400 text-sm sm:text-base",children:l("limits.page.subtitle")})]}),r.jsx(b,{to:"/settings","aria-label":l("limits.page.openSettings"),title:l("limits.page.openSettings"),className:"shrink-0 inline-flex h-9 w-9 items-center justify-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:r.jsx(j,{className:"h-4 w-4","aria-hidden":!0})})]}),o?r.jsx(E,{}):r.jsxs(r.Fragment,{children:[e?r.jsx("p",{className:"mb-4 text-sm text-red-500 dark:text-red-400",children:l("shared.error.prefix",{error:e})}):null,r.jsx(I,{claude:s?.claude,codex:s?.codex,cursor:s?.cursor,gemini:s?.gemini,kiro:s?.kiro,antigravity:s?.antigravity,copilot:s?.copilot,order:i.order,visibility:i.visibility})]})]})})})}export{$ as LimitsPage};
@@ -1 +0,0 @@
1
- import{r as i,b as xe,f as me,aN as X,D as e,e as R,aO as be,aP as ye,aQ as fe,aR as Y,aS as pe,aT as ke,ab as ae,B as n,az as S,C as ve,aU as je,aV as Ne,aW as we,ai as Se,ah as Ce,aD as Le,aG as j,aX as Ie,aE as _e,aF as Ae,aY as I,aj as De,aZ as Te}from"./main-CtQnmeNT.js";import{L as Ee,a as J,u as Me}from"./use-limits-display-prefs-CUKlkCzX.js";import{C as Pe}from"./Card-D89QXio1.js";import{D as Oe}from"./download-DcBCxxpH.js";const Ge=t=>!t.isLayoutDirty&&t.willUpdate(!1);function ee(){const t=new Set,a=new WeakMap,s=()=>t.forEach(Ge);return{add:o=>{t.add(o),a.set(o,o.addEventListener("willUpdate",s))},remove:o=>{t.delete(o);const c=a.get(o);c&&(c(),a.delete(o)),s()},dirty:s}}const Re=i.createContext(null);function He(){const t=i.useRef(!1);return xe(()=>(t.current=!0,()=>{t.current=!1}),[]),t}function Ue(){const t=He(),[a,s]=i.useState(0),o=i.useCallback(()=>{t.current&&s(a+1)},[a]);return[i.useCallback(()=>me.postRender(o),[o]),a]}const ne=t=>t===!0,Be=t=>ne(t===!0)||t==="id",Fe=({children:t,id:a,inherit:s=!0})=>{const o=i.useContext(X),c=i.useContext(Re),[x,u]=Ue(),b=i.useRef(null),g=o.id||c;b.current===null&&(Be(s)&&g&&(a=a?g+"-"+a:g),b.current={id:a,group:ne(s)&&o.group||ee()});const p=i.useMemo(()=>({...b.current,forceRender:x}),[u]);return e.jsx(X.Provider,{value:p,children:t})};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"}]],$e=R("grip-vertical",ze);const Ve=[["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"}]],Ke=R("log-out",Ve);const We=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],te=R("pencil",We);const Ze=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],qe=R("refresh-cw",Ze);function se(){const[t,a]=i.useState(null),s=be()&&ye();i.useEffect(()=>{if(!s)return;const u=fe(b=>a(b));return Y(),u},[s]);const o=i.useCallback((u,b)=>{s&&(a(g=>g&&{...g,[u]:b}),pe(u,b))},[s]),c=i.useCallback(u=>{s&&ke(u)},[s]),x=i.useCallback(()=>{s&&Y()},[s]);return{available:s,settings:t,setSetting:o,runAction:c,refresh:x}}function Qe({checked:t,onChange:a,ariaLabel:s}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":s,onClick:a,className:S("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",t?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:e.jsx("span",{className:S("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",t?"translate-x-[18px]":"translate-x-[3px]")})})}function Xe({prefs:t}){const{order:a,visibility:s,toggle:o,moveToward:c}=t,[x,u]=i.useState(null),[b,g]=i.useState(null),p=d=>l=>{u(d),l.dataTransfer.effectAllowed="move",l.dataTransfer.setData("text/plain",d)},y=d=>l=>{l.preventDefault(),l.dataTransfer.dropEffect="move",x&&x!==d&&b!==d&&(g(d),c(x,d))},D=()=>{u(null),g(null)},_=d=>{d.preventDefault(),u(null),g(null)};return e.jsx(Fe,{children:e.jsx("div",{className:"flex flex-col",children:a.map(d=>{const l=s[d]!==!1,m=x===d;return e.jsxs(ae.div,{layout:!0,transition:{duration:.28,ease:[.22,1,.36,1]},draggable:!0,onDragStart:p(d),onDragOver:y(d),onDragEnd:D,onDrop:_,className:S("flex items-center gap-3 py-2 rounded-md","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60",m&&"opacity-40"),style:{cursor:m?"grabbing":"grab"},children:[e.jsx($e,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),e.jsx("img",{src:Ee[d],alt:"",width:18,height:18,className:"h-[18px] w-[18px] shrink-0 pointer-events-none",draggable:!1}),e.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200 select-none",children:J[d]}),e.jsx("div",{onMouseDown:C=>C.stopPropagation(),draggable:!1,children:e.jsx(Qe,{checked:l,onChange:()=>o(d),ariaLabel:`${n("limits.settings.toggle_visible")}: ${J[d]}`})})]},d)})})})}function Ye(t){if(!t||typeof t!="object")return"";const a=t.user_metadata&&typeof t.user_metadata=="object"?t.user_metadata:{},s=t.profile&&typeof t.profile=="object"?t.profile:{},o=a.full_name||a.name||s.name||a.user_name||a.preferred_username;return typeof o=="string"&&o.trim()?o.trim():typeof t.email=="string"&&t.email.includes("@")?t.email.split("@")[0].trim()||t.email.trim():typeof t.email=="string"?t.email.trim():""}function Je(t){return!t||typeof t!="object"?"":typeof t.email=="string"?t.email.trim():""}function w({checked:t,onChange:a,disabled:s,ariaLabel:o}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":o,onClick:a,disabled:s,className:S("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 disabled:opacity-50 disabled:cursor-not-allowed",t?"bg-oai-brand-500":"bg-oai-gray-300 dark:bg-oai-gray-700"),children:e.jsx("span",{className:S("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",t?"translate-x-[18px]":"translate-x-[3px]")})})}function N({label:t,hint:a,control:s}){return e.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:t}),a&&e.jsx("div",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a})]}),e.jsx("div",{className:"shrink-0",children:s})]})}function G({title:t,subtitle:a,action:s,children:o}){return e.jsxs(Pe,{children:[e.jsxs("div",{className:"mb-3 flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:t}),a&&e.jsx("p",{className:"mt-1 text-xs text-oai-gray-500 dark:text-oai-gray-400 truncate",children:a})]}),s&&e.jsx("div",{className:"shrink-0",children:s})]}),e.jsx("div",{className:"-mb-3 divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:o})]})}const et=[{value:"light",labelKey:"settings.appearance.theme.light",Icon:je},{value:"dark",labelKey:"settings.appearance.theme.dark",Icon:Ne},{value:"system",labelKey:"settings.appearance.theme.system",Icon:we}];function tt({theme:t,onSetTheme:a}){return e.jsx("div",{className:"inline-flex items-center rounded-lg border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 bg-oai-gray-50 dark:bg-oai-gray-900",children:et.map(({value:s,labelKey:o,Icon:c})=>{const x=t===s;return e.jsxs("button",{type:"button",onClick:()=>a(s),className:S("inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors",x?"bg-white dark:bg-oai-gray-800 text-oai-black dark:text-white shadow-sm":"text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-black dark:hover:text-white"),"aria-pressed":x,children:[e.jsx(c,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{children:n(o)})]},s)})})}function at(){const{enabled:t,signedIn:a,user:s,signOut:o,getAccessToken:c}=Se(),{openLoginModal:x}=Ce(),[u,b]=i.useState(()=>Le()),[g,p]=i.useState(!1),[y,D]=i.useState(!1),[_,d]=i.useState(!1),[l,m]=i.useState(!1),[C,V]=i.useState(null),[H,T]=i.useState(!1),[E,K]=i.useState(""),[M,P]=i.useState(!1),[A,U]=i.useState(""),[B,F]=i.useState(""),[z,L]=i.useState(!1),[$,f]=i.useState(null),ie=t&&a&&Te(),O=i.useMemo(()=>Ye(s),[s]),re=i.useMemo(()=>Je(s),[s]);i.useEffect(()=>{if(!a)return;let r=!0;return d(!0),(async()=>{try{const h=await j({getAccessToken:c});if(!r||!h)return;const k=await Ie({accessToken:h});if(!r)return;p(!!k?.enabled),D(!!k?.anonymous),k?.display_name&&V(k.display_name),P(!!k?.show_github_url),U(k?.github_url||"")}catch{}finally{r&&d(!1)}})(),()=>{r=!1}},[a,c]);const oe=i.useCallback(async()=>{const r=!u;if(_e(r),b(r),r)try{await Ae(()=>c())}catch(h){console.warn("[tokentracker] cloud sync:",h)}},[u,c]),ce=i.useCallback(async()=>{if(!l){m(!0);try{const r=await j({getAccessToken:c});if(!r)return;const h=!g;await I({accessToken:r,enabled:h}),p(h)}catch{}finally{m(!1)}}},[g,l,c]),le=i.useCallback(async()=>{if(!l){m(!0);try{const r=await j({getAccessToken:c});if(!r)return;const h=!y;await I({accessToken:r,anonymous:h}),D(h)}catch{}finally{m(!1)}}},[y,l,c]),W=i.useCallback(async()=>{if(l)return;const r=E.trim().slice(0,50);if(r){m(!0);try{const h=await j({getAccessToken:c});if(!h)return;await I({accessToken:h,display_name:r}),V(r),T(!1)}catch{}finally{m(!1)}}},[E,l,c]),de=i.useCallback(()=>{K(C||O),T(!0)},[C,O]),ue=i.useCallback(async()=>{if(!l){if(!M&&!A){L(!0),F(""),f(null);return}m(!0);try{const r=await j({getAccessToken:c});if(!r)return;const h=!M;await I({accessToken:r,show_github_url:h}),P(h)}catch{}finally{m(!1)}}},[M,A,l,c]),Z=i.useCallback(async()=>{if(l)return;const r=B.trim();if(!r){m(!0);try{const v=await j({getAccessToken:c});if(!v)return;await I({accessToken:v,github_url:null,show_github_url:!1}),U(""),P(!1),L(!1),f(null)}finally{m(!1)}return}const h=r.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),k=r.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),q=h?.[1]||k?.[1];if(!q){f(n("settings.account.githubUrlInvalid"));return}const Q=`https://github.com/${q}`;m(!0),f(null);try{const v=await j({getAccessToken:c});if(!v)return;const he=await I({accessToken:v,github_url:Q,show_github_url:!0});U(he?.github_url||Q),P(!0),L(!1)}catch(v){f(v?.message||n("settings.account.githubUrlInvalid"))}finally{m(!1)}},[B,l,c]),ge=i.useCallback(()=>{F(A||""),f(null),L(!0)},[A]);return t?a?e.jsxs(G,{title:n("settings.section.account"),subtitle:re||C||O,action:e.jsxs("button",{type:"button",onClick:()=>o(),className:"inline-flex h-7 items-center gap-1.5 text-xs font-medium text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300 transition-colors",children:[e.jsx(Ke,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.account.signOut")]}),children:[ie&&e.jsx(N,{label:n("settings.account.cloudSync"),hint:n("settings.account.cloudSyncHint"),control:e.jsx(w,{checked:u,onChange:oe,ariaLabel:n("settings.account.cloudSync")})}),e.jsx(N,{label:n("settings.account.publicProfile"),hint:n("settings.account.publicProfileHint"),control:e.jsx(w,{checked:g,onChange:ce,disabled:_||l,ariaLabel:n("settings.account.publicProfile")})}),e.jsx(De,{initial:!1,children:g&&e.jsxs(ae.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:[e.jsx("div",{className:"py-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:n("settings.account.displayName")}),!H&&e.jsx("div",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400 truncate",children:y?n("settings.account.displayNameAnonymousHint"):C||O}),H&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("input",{type:"text",value:E,onChange:r=>K(r.target.value),onKeyDown:r=>{r.key==="Enter"&&W(),r.key==="Escape"&&T(!1)},maxLength:50,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 bg-transparent px-2.5 py-1.5 text-sm text-oai-black dark:text-white outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500",placeholder:n("settings.account.displayName")}),e.jsx("button",{type:"button",onClick:W,disabled:l||!E.trim(),className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white hover:bg-oai-brand-600 disabled:opacity-50 transition-colors",children:l?n("settings.account.saving"):n("settings.account.save")}),e.jsx("button",{type:"button",onClick:()=>T(!1),className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300 transition-colors",children:n("settings.account.cancel")})]})]}),!H&&e.jsxs("div",{className:"shrink-0 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:de,disabled:y,title:y?n("settings.account.displayNameDisabledWhileAnon"):void 0,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-800 px-3 text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[e.jsx(te,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.account.edit")]}),e.jsx(w,{checked:!y,onChange:le,disabled:_||l,ariaLabel:n("settings.account.displayName")})]})]})}),e.jsx("div",{className:"py-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm text-oai-gray-900 dark:text-oai-gray-200",children:n("settings.account.githubUrl")}),!z&&e.jsx("div",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400 truncate",children:A||n("settings.account.githubUrlHint")}),z&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("input",{type:"text",value:B,onChange:r=>{F(r.target.value),$&&f(null)},onKeyDown:r=>{r.key==="Enter"&&Z(),r.key==="Escape"&&(L(!1),f(null))},maxLength:100,autoFocus:!0,className:"flex-1 rounded-md border border-oai-gray-300 dark:border-oai-gray-700 bg-transparent px-2.5 py-1.5 text-sm text-oai-black dark:text-white outline-none focus:border-oai-brand-500 focus:ring-1 focus:ring-inset focus:ring-oai-brand-500",placeholder:n("settings.account.githubUrlPlaceholder")}),e.jsx("button",{type:"button",onClick:Z,disabled:l,className:"rounded-md bg-oai-brand-500 px-3 py-1.5 text-xs font-medium text-white hover:bg-oai-brand-600 disabled:opacity-50 transition-colors",children:l?n("settings.account.saving"):n("settings.account.save")}),e.jsx("button",{type:"button",onClick:()=>{L(!1),f(null)},className:"rounded-md px-2 py-1.5 text-xs text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300 transition-colors",children:n("settings.account.cancel")})]}),$&&e.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:$})]})]}),!z&&e.jsxs("div",{className:"shrink-0 flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:ge,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-800 px-3 text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:[e.jsx(te,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.account.edit")]}),e.jsx(w,{checked:M,onChange:ue,disabled:_||l,ariaLabel:n("settings.account.githubUrl")})]})]})})]},"public-profile-fields")})]}):e.jsx(G,{title:n("settings.section.account"),children:e.jsxs("div",{className:"flex items-center justify-between py-3 gap-4",children:[e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.account.signedOutHint")}),e.jsx("button",{type:"button",onClick:x,className:"shrink-0 inline-flex h-8 items-center justify-center rounded-md bg-oai-gray-900 text-white px-4 text-xs font-medium hover:bg-oai-gray-800 dark:bg-white dark:text-oai-gray-900 dark:hover:bg-oai-gray-100 transition-colors",children:n("settings.account.signIn")})]})}):null}function nt(){const{available:t,settings:a,setSetting:s,runAction:o}=se();if(!t)return null;const c=!!a?.showStats,x=a?.animatedIcon!==!1,u=!!a?.launchAtLogin,b=a?.launchAtLoginSupported!==!1;a?.version;const g=a?.updateStatus||null,p=!!a?.updateBusy,y=!!a?.isSyncing;return e.jsxs(G,{title:n("settings.section.menubar"),children:[e.jsx(N,{label:n("settings.menubar.showStats"),hint:n("settings.menubar.showStatsHint"),control:e.jsx(w,{checked:c,onChange:()=>s("showStats",!c),ariaLabel:n("settings.menubar.showStats")})}),e.jsx(N,{label:n("settings.menubar.animatedIcon"),hint:n("settings.menubar.animatedIconHint"),control:e.jsx(w,{checked:x,onChange:()=>s("animatedIcon",!x),ariaLabel:n("settings.menubar.animatedIcon")})}),b&&e.jsx(N,{label:n("settings.menubar.launchAtLogin"),hint:n("settings.menubar.launchAtLoginHint"),control:e.jsx(w,{checked:u,onChange:()=>s("launchAtLogin",!u),ariaLabel:n("settings.menubar.launchAtLogin")})}),e.jsx(N,{label:n("settings.menubar.syncNow"),hint:n("settings.menubar.syncNowHint"),control:e.jsxs("button",{type:"button",onClick:()=>o("syncNow"),disabled:y,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-800 px-3 text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(qe,{className:S("h-3.5 w-3.5",y&&"animate-spin"),"aria-hidden":!0}),y?n("settings.menubar.syncing"):n("settings.menubar.syncNow")]})}),e.jsx(N,{label:n("settings.menubar.updates"),hint:g||void 0,control:e.jsxs("button",{type:"button",onClick:()=>o("checkForUpdates"),disabled:p,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-800 px-3 text-xs font-medium text-oai-gray-700 dark:text-oai-gray-300 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(Oe,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.menubar.checkUpdates")]})})]})}function st(){const{available:t,settings:a,runAction:s}=se();return!t||!a?.version?null:e.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2 text-[11px] text-oai-gray-500 dark:text-oai-gray-500",children:[e.jsxs("span",{children:["TokenTrackerBar v",a.version]}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("button",{type:"button",onClick:()=>s("openAbout"),className:"hover:text-oai-gray-700 dark:hover:text-oai-gray-300 transition-colors underline-offset-2 hover:underline",children:"GitHub"})]})}function lt(){const{theme:t,setTheme:a}=ve(),s=Me();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-3xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-8 flex items-center justify-between gap-4",children:[e.jsx("h1",{className:"text-3xl sm:text-4xl font-semibold tracking-tight text-oai-black dark:text-white",children:n("settings.page.title")}),e.jsx(tt,{theme:t,onSetTheme:a})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(nt,{}),e.jsx(at,{}),e.jsx(G,{title:n("settings.section.limits"),children:e.jsx(Xe,{prefs:s})})]}),e.jsx(st,{})]})})})}export{lt as SettingsPage};