tokentracker-cli 1.1.7 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dashboard/dist/assets/{AchievementBadge-BvHgbiVw.js → AchievementBadge-xbiBA5i9.js} +1 -1
- package/dashboard/dist/assets/{AchievementsPage-Bfp4s86S.js → AchievementsPage-Bas-dACH.js} +2 -2
- package/dashboard/dist/assets/{AchievementsSection-D_0d-wue.js → AchievementsSection-NIkQkv1K.js} +1 -1
- package/dashboard/dist/assets/{BadgeDetailModal-CswBdrxR.js → BadgeDetailModal-D3UgBwf8.js} +1 -1
- package/dashboard/dist/assets/{BotAnimated-CiHx0-39.js → BotAnimated-BNyhe5RX.js} +1 -1
- package/dashboard/dist/assets/{Card-D_P_GpGV.js → Card-B4qMgo_P.js} +1 -1
- package/dashboard/dist/assets/{ClawdAnimated-DF8C0aFU.js → ClawdAnimated-B_6oXLru.js} +2 -2
- package/dashboard/dist/assets/{CommandPalette-AO3PXq3L.js → CommandPalette-DR50aykL.js} +1 -1
- package/dashboard/dist/assets/CommunityStatsModal-DbWZ2hX1.js +1 -0
- package/dashboard/dist/assets/{ConfirmModal-Dkes9XSh.js → ConfirmModal-CApD9tLe.js} +1 -1
- package/dashboard/dist/assets/{Controls-DanVQOJL.js → Controls-UQr6lc0S.js} +1 -1
- package/dashboard/dist/assets/DashboardPage-38JMPZYD.js +1 -0
- package/dashboard/dist/assets/{DevicePage-DqHfz-mA.js → DevicePage-B7n5TS6A.js} +1 -1
- package/dashboard/dist/assets/{DialogClose-bTErbUan.js → DialogClose-BVYAi_Mb.js} +1 -1
- package/dashboard/dist/assets/DialogDescription-CD1rCYqD.js +1 -0
- package/dashboard/dist/assets/{DialogTitle-wJu8XVdR.js → DialogTitle-_gEgVrEF.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-BKwC8Giy.js → FadeIn-CqWPKBtn.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-Dc0pFvj1.js → HeaderGithubStar-nJV8kqj7.js} +1 -1
- package/dashboard/dist/assets/{HoverTooltip-B9vlFH-p.js → HoverTooltip-CkPO2nyc.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-CsJ1PgvF.js → IpCheckPage-CBPPbv12.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-eF1J1hC5.js → LandingPage-B3kHRjIL.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardAvatar-CFI7peYE.js → LeaderboardAvatar-C9UJap02.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardPage-PP4US4yQ.js → LeaderboardPage-BaxbbkZ4.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardProfileModal-C5QWkQji.js → LeaderboardProfileModal-CSCpQGtj.js} +3 -3
- package/dashboard/dist/assets/{LeaderboardProfilePage-BJURGX8H.js → LeaderboardProfilePage-Cr4oGPW3.js} +3 -3
- package/dashboard/dist/assets/{LimitsPage-DUngDTwb.js → LimitsPage-D80H3CN6.js} +1 -1
- package/dashboard/dist/assets/{LocalOnlyNotice-CYguu0fl.js → LocalOnlyNotice-B-IFH3nt.js} +1 -1
- package/dashboard/dist/assets/{LoginCard-DXuCwYWd.js → LoginCard-D28bk46z.js} +1 -1
- package/dashboard/dist/assets/{LoginModal-Dz0m0fxu.js → LoginModal-B3OIZlRl.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-jOLmSJtM.js → LoginPage-BUZcOhur.js} +1 -1
- package/dashboard/dist/assets/{PetPage-BrC2Vlkx.js → PetPage-B1ID7Hn_.js} +1 -1
- package/dashboard/dist/assets/{PopoverPopup-D1ZuZ6qF.js → PopoverPopup-C4y60FZN.js} +1 -1
- package/dashboard/dist/assets/{ProviderIcon-D6fA334Z.js → ProviderIcon-DINSm4-U.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-K8qjox3z.js → ResetPasswordPage-DuT61PlK.js} +1 -1
- package/dashboard/dist/assets/{SegmentedControl-D0lZmjJp.js → SegmentedControl-CI97Hzlt.js} +1 -1
- package/dashboard/dist/assets/{Select-DnXhoIcT.js → Select-Br0lETb5.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-DaLHPEaI.js → SelectItemText-DkwRyFhO.js} +1 -1
- package/dashboard/dist/assets/{ServiceStatusPage-B2Jwo3q0.js → ServiceStatusPage-CXmaHXok.js} +1 -1
- package/dashboard/dist/assets/{SessionsPage-CqscAu03.js → SessionsPage-D4QNmkZK.js} +1 -1
- package/dashboard/dist/assets/SettingsPage-B2m9w6u2.js +2 -0
- package/dashboard/dist/assets/{SkillsPage-XbU2V_2F.js → SkillsPage-BgwQrJN5.js} +1 -1
- package/dashboard/dist/assets/{TokenGalaxy-yPB_tjQb.js → TokenGalaxy-Gu8Ow73w.js} +1 -1
- package/dashboard/dist/assets/{ToolbarRootContext-CVe7ayLE.js → ToolbarRootContext-BQ1me9_q.js} +1 -1
- package/dashboard/dist/assets/{TrendMonitor-CPGG-jEV.js → TrendMonitor-CvgRQWnP.js} +2 -2
- package/dashboard/dist/assets/{WidgetsPage-DWRry8La.js → WidgetsPage-CUqcWQRH.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-BQNXcJsy.js → WrappedPage-C3UN0ODa.js} +1 -1
- package/dashboard/dist/assets/__vite-browser-external-CU61PE6P.js +45 -0
- package/dashboard/dist/assets/{agent-logos-ClPaafqy.js → agent-logos-CqHJCc4t.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-D9iXcTSi.js → arrow-up-right-DOj31845.js} +1 -1
- package/dashboard/dist/assets/{check-ClpRkox0.js → check-B3DcIhj-.js} +1 -1
- package/dashboard/dist/assets/{composite-BeLJ-eoZ.js → composite-84597ykh.js} +1 -1
- package/dashboard/dist/assets/{copy-SgX3AIm3.js → copy-DHKp6LiG.js} +1 -1
- package/dashboard/dist/assets/{download-nN_fUpW9.js → download-8BXZUZ5E.js} +1 -1
- package/dashboard/dist/assets/{external-link-C_KAZYfd.js → external-link-MMLkzpJo.js} +1 -1
- package/dashboard/dist/assets/{flame-Y4jft3cb.js → flame-CS31bpav.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-DgHV0o-Z.js → format-tokens-Db794xGj.js} +1 -1
- package/dashboard/dist/assets/{icons-OfFaXJDp.js → icons-DbJFxYam.js} +1 -1
- package/dashboard/dist/assets/{index-7QPrFzyL.js → index-C43slbyq.js} +1 -1
- package/dashboard/dist/assets/{index-BKJfXEXA.js → index-DxRNZBk8.js} +1 -1
- package/dashboard/dist/assets/{index-BWdBrNhr.js → index-zvktTnpL.js} +1 -1
- package/dashboard/dist/assets/{info-lrIngAOG.js → info-BBYVrlZQ.js} +1 -1
- package/dashboard/dist/assets/{link-2-CX_TTpam.js → link-2-BAkJwRS7.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-DAt8Rl6H.js → loader-circle-qmDffs-C.js} +1 -1
- package/dashboard/dist/assets/{maximize-2-BhF9GJwe.js → maximize-2-DsglOasI.js} +1 -1
- package/dashboard/dist/assets/{modifiers.esm-Ozg3867-.js → modifiers.esm-EKtyGFrY.js} +1 -1
- package/dashboard/dist/assets/{monitor-smartphone-AjSSS90b.js → monitor-smartphone-i1wfcnRb.js} +1 -1
- package/dashboard/dist/assets/{plus-BW8P8uiQ.js → plus-Cu09y-uC.js} +1 -1
- package/dashboard/dist/assets/provider-display-CqsH0Sl4.js +42 -0
- package/dashboard/dist/assets/{react-DwTWkLQf.js → react-BhNxIPTw.js} +1 -1
- package/dashboard/dist/assets/{search-DbwR9JhN.js → search-CnD0oNqF.js} +1 -1
- package/dashboard/dist/assets/skills-api-BZjW22xy.js +1 -0
- package/dashboard/dist/assets/{sortable.esm-DSWAIKHA.js → sortable.esm-DKZHcMD3.js} +1 -1
- package/dashboard/dist/assets/{store-BPfJGR9z.js → store-DtFmZUKU.js} +1 -1
- package/dashboard/dist/assets/{terminal-U-gMhjaN.js → terminal-Ci6VJSXB.js} +1 -1
- package/dashboard/dist/assets/{trash-Bu1AqpoX.js → trash-DFtauQXa.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-DfSn2jNt.js → use-community-stats-CtiK0rE3.js} +1 -1
- package/dashboard/dist/assets/{use-latest-request-guard-7m4DXn4B.js → use-latest-request-guard-AUvY3uHN.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-mRd0OnhT.js → use-limits-display-prefs-BB8SjBZP.js} +1 -1
- package/dashboard/dist/assets/{use-ordered-list-CBae4AuZ.js → use-ordered-list-CKNhZ510.js} +1 -1
- package/dashboard/dist/assets/use-reduced-motion-BXh1HaOk.js +1 -0
- package/dashboard/dist/assets/{use-session-efficiency-pref-DCweltax.js → use-session-efficiency-pref-C0qtk6TK.js} +1 -1
- package/dashboard/dist/assets/{use-transform-BPegjDim.js → use-transform-DYicUvFj.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-DKO2kwUE.js → use-usage-limits-CWRjxEix.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-5h4sZ7c9.js → useCurrency-LH_2wEBf.js} +1 -1
- package/dashboard/dist/assets/{useTokenFormat-BELg6Qla.js → useTokenFormat-DKsWnBvy.js} +1 -1
- package/dashboard/dist/assets/{zap-q4Z6ZRMI.js → zap-CAoJCLuz.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dashboard/dist/ip-check.html +1 -1
- package/dashboard/dist/leaderboard.html +1 -1
- package/dashboard/dist/share.html +1 -1
- package/package.json +1 -1
- package/src/commands/device-login.js +3 -2
- package/src/commands/sync.js +34 -12
- package/src/lib/cloud-account.js +93 -39
- package/src/lib/function-url.js +27 -0
- package/src/lib/local-api.js +141 -31
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/telemetry.js +3 -2
- package/src/lib/upload-throttle.js +6 -0
- package/dashboard/dist/assets/CommunityStatsModal-Dhx0AXIU.js +0 -1
- package/dashboard/dist/assets/DashboardPage-CtrTRoRf.js +0 -1
- package/dashboard/dist/assets/DialogDescription-HFssj1J8.js +0 -1
- package/dashboard/dist/assets/SettingsPage-CL2euJqr.js +0 -2
- package/dashboard/dist/assets/__vite-browser-external-CAVICAeZ.js +0 -45
- package/dashboard/dist/assets/provider-display-Dmqqa8F4.js +0 -42
- package/dashboard/dist/assets/skills-api-CdNR4QHm.js +0 -1
- package/dashboard/dist/assets/use-reduced-motion-uScStq9r.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-CAVICAeZ.js","assets/__vite-browser-external-Bg0J-a5P.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{m as T,j as t,e as _,c as n,a as xe,r as u,ao as ye,aT as ve,au as ke,av as je,a8 as X,aU as Se,aV as we,u as Ne,d as H,$ as Ce,I as Q,n as U,aW as V,aX as Ee,aY as Pe,V as ee,aZ as Ae,q as Oe,a_ as Le,a$ as _e,b0 as Te,b1 as Ie,b2 as Ge,b3 as Re,b4 as De,b5 as te,L as Ue,R as Me,b6 as He,b7 as Fe,a5 as B,_ as $e,h as Ve,f as Be,b8 as ze,b9 as Ke,ax as qe}from"./__vite-browser-external-CAVICAeZ.js";import{a as We,b as z,s as Ye,K as Ze,P as Je,D as Xe,c as Qe,S as et,v as tt,u as nt,C as at}from"./sortable.esm-DSWAIKHA.js";import{a as st}from"./modifiers.esm-Ozg3867-.js";import{d as K,l as q,u as it,b as W}from"./use-limits-display-prefs-mRd0OnhT.js";import{P as ot}from"./ProviderIcon-D6fA334Z.js";import{m as ne}from"./react-DwTWkLQf.js";import{a as O,T as k,b,S as G,u as R}from"./Controls-DanVQOJL.js";import{P as rt,u as lt,a as ct}from"./use-session-efficiency-pref-DCweltax.js";import{C as dt}from"./check-ClpRkox0.js";import{C as ut}from"./copy-SgX3AIm3.js";import{A as ae}from"./index-7QPrFzyL.js";import{u as gt}from"./useCurrency-5h4sZ7c9.js";import{u as pt}from"./useTokenFormat-BELg6Qla.js";import{S as F}from"./Select-DnXhoIcT.js";import{I as ht}from"./info-lrIngAOG.js";import{C as mt}from"./ConfirmModal-Dkes9XSh.js";import{A as bt}from"./arrow-up-right-D9iXcTSi.js";import{D as ft}from"./download-nN_fUpW9.js";import{i as xt}from"./host-mode-Bc_iTzHk.js";import"./Card-D_P_GpGV.js";import"./ToolbarRootContext-CVe7ayLE.js";import"./composite-BeLJ-eoZ.js";import"./SelectItemText-DaLHPEaI.js";import"./DialogTitle-wJu8XVdR.js";import"./store-BPfJGR9z.js";import"./DialogDescription-HFssj1J8.js";const se={name:"flask-conical",size:24,node:[["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"}]]};se.node;const yt=T(se);const ie={name:"grip-vertical",size:24,node:[["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"}]]};ie.node;const vt=T(ie);const oe={name:"languages",size:24,node:[["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"}]]};oe.node;const kt=T(oe);const re={name:"log-out",size:24,node:[["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"}]]};re.node;const jt=T(re);const le={name:"palette",size:24,node:[["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"}]]};le.node;const St=T(le);const ce={name:"user-round",size:24,node:[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],aliases:["user-2"]};ce.node;const wt=T(ce),Nt="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function Ct({checked:e,onChange:a,ariaLabel:s}){return t.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":s,onClick:a,className:_("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:_("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-[3px]")})})}function Et({id:e,visible:a,onToggle:s}){const{attributes:i,listeners:o,setNodeRef:r,transform:l,transition:c,isDragging:d}=nt({id:e}),h={transform:at.Transform.toString(l)||void 0,transition:c,zIndex:d?20:void 0};return t.jsxs("div",{ref:r,style:h,className:_("flex items-center gap-3 py-2 rounded-md select-none touch-none","cursor-grab active:cursor-grabbing","hover:bg-oai-gray-100/60 dark:hover:bg-oai-gray-800/60","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",d&&"relative bg-oai-gray-100 dark:bg-oai-gray-800"),...i,...o,children:[t.jsx(vt,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),K(e)?t.jsx(ot,{provider:K(e),size:18,className:_("pointer-events-none",Nt)}):null,t.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200",children:q(e)}),t.jsx("div",{onPointerDown:p=>p.stopPropagation(),children:t.jsx(Ct,{checked:a,onChange:s,ariaLabel:`${n("limits.settings.toggle_visible")}: ${q(e)}`})})]})}function Pt({prefs:e}){const{order:a,visibility:s,toggle:i,moveToward:o}=e,r=We(z(Je,{activationConstraint:{distance:6}}),z(Ze,{coordinateGetter:Ye})),l=({active:c,over:d})=>{d&&c.id!==d.id&&o(c.id,d.id)};return t.jsx(Xe,{sensors:r,collisionDetection:Qe,modifiers:[st],onDragEnd:l,children:t.jsx(et,{items:a,strategy:tt,children:t.jsx("div",{className:"flex flex-col",children:a.map(c=>t.jsx(Et,{id:c,visible:s[c]!==!1,onToggle:()=>i(c)},c))})})})}function At(e){if(!e||typeof e!="object")return"";const a=e.user_metadata&&typeof e.user_metadata=="object"?e.user_metadata:{},s=e.profile&&typeof e.profile=="object"?e.profile:{},i=a.full_name||a.name||s.name||a.user_name||a.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 Ot(e){return!e||typeof e!="object"?"":typeof e.email=="string"?e.email.trim():""}function Lt(e){const a=typeof e=="string"?e.trim():"";if(!a)return null;const s=a.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),i=a.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 $(e,a){console.warn(`[tokentracker] settings ${e}:`,a)}function _t(e,a,s){const[i,o]=u.useState(()=>ye()),r=a&&s&&ve(),l=u.useCallback(async()=>{const c=!i;if(ke(c),o(c),!!c)try{await je(()=>e())}catch(d){$("cloud sync",d)}},[i,e]);return{cloudSyncOn:i,handleCloudSyncToggle:l,showLocalCloudSync:r}}function Tt(e){const[a,s]=u.useState(!1),[i,o]=u.useState(!1),[r,l]=u.useState(!1),[c,d]=u.useState(!1),[h,p]=u.useState(null),[g,m]=u.useState(!1),[v,j]=u.useState(""),[A,y]=u.useState(!1),[w,N]=u.useState(""),[f,S]=u.useState(""),[L,x]=u.useState(!1),[E,D]=u.useState(null),I=u.useMemo(()=>At(e),[e]),me=u.useMemo(()=>Ot(e),[e]),be=u.useMemo(()=>typeof e?.id=="string"?e.id.trim():"",[e]),fe=u.useMemo(()=>({setAnonymousOn:o,setCustomDisplayName:p,setGithubUrl:N,setProfileLoading:l,setPublicProfileOn:s,setShowGithubOn:y}),[]);return{anonymousOn:i,customDisplayName:h,displayName:I,editingGithub:L,editingName:g,email:me,githubError:E,githubInput:f,githubUrl:w,loadSetters:fe,nameInput:v,profileLoading:r,profileSaving:c,publicProfileOn:a,setAnonymousOn:o,setCustomDisplayName:p,setEditingGithub:x,setEditingName:m,setGithubError:D,setGithubInput:S,setGithubUrl:N,setNameInput:j,setProfileLoading:l,setProfileSaving:d,setPublicProfileOn:s,setShowGithubOn:y,showGithubOn:A,userId:be}}function It(e,a,s){u.useEffect(()=>{if(!a)return;let i=!0;return s.setProfileLoading(!0),(async()=>{try{const o=await X({getAccessToken:e});if(!i||!o)return;const r=await Se({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){$("load public profile",o)}finally{i&&s.setProfileLoading(!1)}})(),()=>{i=!1}},[e,a,s])}function Gt(e,a){return u.useCallback(async(s,{label:i,onError:o,onSuccess:r}={})=>{if(a.profileSaving)return!1;a.setProfileSaving(!0);try{const l=await X({getAccessToken:e});if(!l)return!1;const c=await we({accessToken:l,...s});return r?.(c),!0}catch(l){return o?o(l):$(i||"mutate profile",l),!1}finally{a.setProfileSaving(!1)}},[e,a])}function Rt(e,a){return{anonymousOn:e.anonymousOn,customDisplayName:e.customDisplayName,displayName:e.displayName,editingName:e.editingName,handleAnonymousToggle:a.handleAnonymousToggle,handleSaveName:a.handleSaveName,nameInput:e.nameInput,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingName:e.setEditingName,setNameInput:e.setNameInput,startEditingName:a.startEditingName}}function Dt(e,a){return{editingGithub:e.editingGithub,githubError:e.githubError,githubInput:e.githubInput,githubUrl:e.githubUrl,handleSaveGithub:a.handleSaveGithub,handleShowGithubToggle:a.handleShowGithubToggle,profileLoading:e.profileLoading,profileSaving:e.profileSaving,setEditingGithub:e.setEditingGithub,setGithubError:e.setGithubError,setGithubInput:e.setGithubInput,showGithubOn:e.showGithubOn,startEditingGithub:a.startEditingGithub}}function Ut(e,a){const s=u.useCallback(async()=>{const o=!e.publicProfileOn;await a({enabled:o},{label:"toggle public profile",onSuccess:()=>e.setPublicProfileOn(o)})},[a,e]);return{handleAnonymousToggle:u.useCallback(async()=>{const o=!e.anonymousOn;await a({anonymous:o},{label:"toggle anonymous",onSuccess:()=>e.setAnonymousOn(o)})},[a,e]),handlePublicProfileToggle:s}}function Mt(e,a,s){const i=u.useCallback(async()=>{const r=e.nameInput.trim().slice(0,50);r&&await a({display_name:r},{label:"save display name",onSuccess:()=>{e.setCustomDisplayName(r),e.setEditingName(!1),s?.()}})},[a,e,s]),o=u.useCallback(()=>{e.setNameInput(e.customDisplayName||e.displayName),e.setEditingName(!0)},[e]);return{handleSaveName:i,startEditingName:o}}function Ht(e,a){const s=u.useCallback(async()=>{if(!e.showGithubOn&&!e.githubUrl){e.setEditingGithub(!0),e.setGithubInput(""),e.setGithubError(null);return}const r=!e.showGithubOn;await a({show_github_url:r},{label:"toggle GitHub profile",onSuccess:()=>e.setShowGithubOn(r)})},[a,e]),i=u.useCallback(async()=>{const r=Lt(e.githubInput);if(e.githubInput.trim()&&!r){e.setGithubError(n("settings.account.githubUrlInvalid"));return}e.setGithubError(null),await a({github_url:r,show_github_url:!!r},{label:"save GitHub profile",onError:l=>e.setGithubError(l?.message||n("settings.account.githubUrlInvalid")),onSuccess:l=>{e.setGithubUrl(l?.github_url||r||""),e.setShowGithubOn(!!r),e.setEditingGithub(!1)}})},[a,e]),o=u.useCallback(()=>{e.setGithubInput(e.githubUrl),e.setGithubError(null),e.setEditingGithub(!0)},[e]);return{handleSaveGithub:i,handleShowGithubToggle:s,startEditingGithub:o}}function Ft(){const e=xe(),a=Tt(e.user),s=_t(e.getAccessToken,e.enabled,e.signedIn);It(e.getAccessToken,e.signedIn,a.loadSetters);const i=Gt(e.getAccessToken,a),o=Ut(a,i),r=Mt(a,i,e.refreshDisplayName),l=Ht(a,i);return{...e,...s,email:a.email,handlePublicProfileToggle:o.handlePublicProfileToggle,userId:a.userId,name:Rt(a,{...o,...r}),github:Dt(a,l),profileLoading:a.profileLoading,profileSaving:a.profileSaving,publicProfileOn:a.publicProfileOn}}function de({disabled:e,onCancel:a,onSave:s,saveLabel:i=n("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:a,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:n("settings.account.cancel")})]})}function $t({nameInput:e,setEditingName:a,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"&&a(!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:n("settings.account.displayName")}),t.jsx(de,{disabled:i||!e.trim(),onCancel:()=>a(!1),onSave:o,saveLabel:i?n("settings.account.saving"):void 0})]})}function Vt({githubError:e,githubInput:a,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:a,onChange:c=>{l(c.target.value),e&&r(null)},onKeyDown:c=>{c.key==="Enter"&&s(),c.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:n("settings.account.githubUrlPlaceholder")}),t.jsx(de,{disabled:i,onCancel:()=>{o(!1),r(null)},onSave:s,saveLabel:i?n("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 ue({disabled:e=!1,label:a,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(rt,{className:"h-3.5 w-3.5","aria-hidden":!0}),a]})}function ge({actions:e,editing:a,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}),a?s:t.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i})]}),a?null:e]})})}function Bt({name:e}){const a=e.anonymousOn?n("settings.account.displayNameDisabledWhileAnon"):void 0;return t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ue,{disabled:e.anonymousOn,label:n("settings.account.edit"),onClick:e.startEditingName,title:a}),t.jsx(k,{checked:!e.anonymousOn,onChange:e.handleAnonymousToggle,disabled:e.profileLoading||e.profileSaving,ariaLabel:n("settings.account.displayName")})]})}function zt({name:e}){const{anonymousOn:a,customDisplayName:s,displayName:i,editingName:o,handleAnonymousToggle:r,handleSaveName:l,nameInput:c,profileLoading:d,profileSaving:h,setEditingName:p,setNameInput:g,startEditingName:m}=e,v=a?n("settings.account.displayNameAnonymousHint"):s||i;return t.jsx(ge,{label:n("settings.account.displayName"),editing:o,hint:v,editor:t.jsx($t,{nameInput:c,setEditingName:p,setNameInput:g,profileSaving:h,handleSaveName:l}),actions:t.jsx(Bt,{name:e})})}function Kt({github:e}){const{editingGithub:a,githubError:s,githubInput:i,githubUrl:o,handleSaveGithub:r,handleShowGithubToggle:l,profileLoading:c,profileSaving:d,setEditingGithub:h,setGithubError:p,setGithubInput:g,showGithubOn:m,startEditingGithub:v}=e;return t.jsx(t.Fragment,{children:t.jsx(ge,{label:n("settings.account.githubUrl"),editing:a,hint:o||n("settings.account.githubUrlHint"),editor:t.jsx(Vt,{githubError:s,githubInput:i,handleSaveGithub:r,profileSaving:d,setEditingGithub:h,setGithubError:p,setGithubInput:g}),actions:t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ue,{label:n("settings.account.edit"),onClick:v}),t.jsx(k,{checked:m,onChange:l,disabled:c||d,ariaLabel:n("settings.account.githubUrl")})]})})})}function qt(){const{openLoginModal:e}=Ne();return t.jsx(O,{title:n("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:n("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:n("settings.account.signIn")})]})})}function Wt({name:e,github:a}){return t.jsxs(t.Fragment,{children:[t.jsx(zt,{name:e}),t.jsx(Kt,{github:a})]})}function Yt(){const e=Ft();return e.enabled?e.signedIn?t.jsxs(O,{title:n("settings.section.account"),subtitle:e.email||e.name.customDisplayName||e.name.displayName,action:t.jsx(Jt,{onSignOut:e.signOut}),children:[t.jsx(Zt,{userId:e.userId}),t.jsx(Xt,{settings:e}),t.jsx(Qt,{checked:e.publicProfileOn,disabled:e.profileLoading||e.profileSaving,onChange:e.handlePublicProfileToggle}),t.jsx(en,{visible:e.publicProfileOn,name:e.name,github:e.github})]}):t.jsx(qt,{}):null}function Zt({userId:e}){const[a,s]=H.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:n("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":n("settings.account.copyUserId"),children:[a?t.jsx(dt,{className:"h-3.5 w-3.5","aria-hidden":!0}):t.jsx(ut,{className:"h-3.5 w-3.5","aria-hidden":!0}),a?n("settings.account.copied"):n("settings.account.copy")]})]})}function Jt({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(jt,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.account.signOut")]})}function Xt({settings:e}){return e.showLocalCloudSync?t.jsx(b,{label:n("settings.account.cloudSync"),hint:n("settings.account.cloudSyncHint"),control:t.jsx(k,{checked:e.cloudSyncOn,onChange:e.handleCloudSyncToggle,ariaLabel:n("settings.account.cloudSync")})}):null}function Qt({checked:e,disabled:a,onChange:s}){return t.jsx(b,{label:n("settings.account.publicProfile"),hint:n("settings.account.publicProfileHint"),control:t.jsx(k,{checked:e,onChange:s,disabled:a,ariaLabel:n("settings.account.publicProfile")})})}function en({visible:e,name:a,github:s}){return t.jsx(ae,{initial:!1,children:e?t.jsx(ne.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.28,ease:[.22,1,.36,1]},opacity:{duration:.2,ease:[.22,1,.36,1]}},style:{overflow:"hidden"},className:"divide-y divide-oai-gray-200/60 dark:divide-oai-gray-800/60",children:t.jsx(Wt,{name:a,github:s})},"public-profile-fields"):null})}function tn(){return[{value:"light",label:n("settings.appearance.theme.light"),Icon:Ee},{value:"dark",label:n("settings.appearance.theme.dark"),Icon:Pe},{value:"system",label:n("settings.appearance.theme.system"),Icon:ee}]}function nn(){return[{value:Le,label:n("settings.appearance.language.system")},{value:_e,label:n("settings.appearance.language.english")},{value:Te,label:n("settings.appearance.language.chinese")},{value:Ie,label:n("settings.appearance.language.traditional_chinese")},{value:Ge,label:n("settings.appearance.language.japanese")},{value:Re,label:n("settings.appearance.language.korean")},{value:De,label:n("settings.appearance.language.german")}]}function an(e){if(!e)return null;try{const a=new Date(e);return Number.isNaN(a.getTime())?null:a.toLocaleString()}catch{return null}}function sn(e,a){const s=n(`settings.appearance.currency.rate_source.${e}`),i=an(a),o=i?n("settings.appearance.currency.rate_updated",{when:i}):n("settings.appearance.currency.rate_never");return`${s} · ${o}`}function on({locale:e,setLocale:a}){const s=nn();return t.jsx(F,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:t.jsx(kt,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function rn({currency:e,setCurrency:a}){const s=Ae().map(i=>({value:i.code,label:n(i.labelKey)}));return t.jsx(F,{value:e,onValueChange:a,options:s,ariaLabel:n("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function ln({currency:e,rate:a,rateSource:s,rateFetchedAt:i}){if(e===Oe)return t.jsx(t.Fragment,{children:n("settings.appearance.currency.hint")});const o=sn(s,i);return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{children:`1 USD = ${a.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(ht,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function cn(){const{theme:e,setTheme:a}=Ce(),{locale:s,setLocale:i}=Q(),{currency:o,rate:r,rateSource:l,rateFetchedAt:c,setCurrency:d}=gt(),{mode:h,setMode:p,unitSystem:g,setUnitSystem:m}=pt();return t.jsxs(O,{title:n("settings.section.appearance"),children:[t.jsx(b,{label:n("settings.appearance.theme.label"),hint:n("settings.appearance.theme.hint"),control:t.jsx(G,{options:tn(),value:e,onChange:a})}),t.jsx(b,{label:n("settings.appearance.language.label"),hint:n("settings.appearance.language.hint"),control:t.jsx(on,{locale:s,setLocale:i})}),t.jsx(b,{label:n("settings.appearance.currency.label"),hint:t.jsx(ln,{currency:o,rate:r,rateSource:l,rateFetchedAt:c}),control:t.jsx(rn,{currency:o,setCurrency:d})}),t.jsx(b,{label:n("settings.appearance.token_format.label"),hint:n("settings.appearance.token_format.hint"),control:t.jsx(G,{options:[{value:U.COMPACT,label:n("settings.appearance.token_format.compact")},{value:U.FULL,label:n("settings.appearance.token_format.full")}],value:h,onChange:p})}),t.jsx(b,{label:n("settings.appearance.token_unit.label"),hint:n("settings.appearance.token_unit.hint"),control:t.jsx(G,{disabled:h!==U.COMPACT,options:[{value:V.ENGLISH,label:n("settings.appearance.token_unit.english")},{value:V.CHINESE,label:n("settings.appearance.token_unit.chinese")}],value:g,onChange:m})})]})}function M({labelKey:e}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{children:n(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:n("qpd.card.badge")})]})}function dn(){const{enabled:e,toggle:a}=lt(),{enabled:s,toggle:i}=ct(),{available:o,settings:r,setSetting:l}=R(),c=o&&!!r?.dynamicIslandSupported,d=!!r?.dynamicIslandEnabled;return t.jsxs(O,{title:n("settings.section.labs"),children:[c&&t.jsxs(t.Fragment,{children:[t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.island.label"}),hint:n("settings.labs.island.hint"),control:t.jsx(k,{checked:d,onChange:()=>l("dynamicIslandEnabled",!d),ariaLabel:n("settings.labs.island.aria")})}),d&&t.jsx(b,{label:n("settings.labs.island_hide_menubar.label"),hint:n("settings.labs.island_hide_menubar.hint"),control:t.jsx(k,{checked:!!r?.hideMenuBarIcon,onChange:()=>l("hideMenuBarIcon",!r?.hideMenuBarIcon),ariaLabel:n("settings.labs.island_hide_menubar.aria")})})]}),t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.qpd.label"}),hint:n("settings.labs.qpd.hint"),control:t.jsx(k,{checked:e,onChange:a,ariaLabel:n("settings.labs.qpd.aria")})}),t.jsx(b,{label:t.jsx(M,{labelKey:"settings.labs.sessions.label"}),hint:n("settings.labs.sessions.hint"),control:t.jsx(k,{checked:s,onChange:i,ariaLabel:n("settings.labs.sessions.aria")})})]})}function un(){const{available:e,settings:a,setSetting:s,runAction:i}=R();if(!e)return null;const o=te(),r=!!a?.launchAtLogin,l=a?.toastOnReset!==!1,c=a?.confettiOnReset!==!1,d=a?.launchAtLoginSupported!==!1,h=a?.autoUpdateEnabled!==!1,p=a?.updateStatus||null,g=!!a?.updateBusy,m=!!a?.isSyncing;return t.jsxs(O,{title:n("settings.section.menubar"),children:[o?null:t.jsxs(t.Fragment,{children:[t.jsx(b,{label:n("settings.menubar.appearance"),hint:n("settings.menubar.appearanceHint"),control:t.jsxs(Ue,{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:[n("settings.menubar.appearanceLink"),t.jsx(bt,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(k,{checked:l,onChange:()=>s("toastOnReset",!l),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(k,{checked:c,onChange:()=>s("confettiOnReset",!c),ariaLabel:n("settings.menubar.confettiOnReset")})})]}),d?t.jsx(b,{label:n("settings.menubar.launchAtLogin"),hint:n("settings.menubar.launchAtLoginHint"),control:t.jsx(k,{checked:r,onChange:()=>s("launchAtLogin",!r),ariaLabel:n("settings.menubar.launchAtLogin")})}):null,t.jsx(b,{label:n("settings.menubar.syncNow"),hint:n("settings.menubar.syncNowHint"),control:t.jsxs("button",{type:"button",onClick:()=>i("syncNow"),disabled:m,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(Me,{className:_("h-3.5 w-3.5",m&&"animate-spin"),"aria-hidden":!0}),m?n("settings.menubar.syncing"):n("settings.menubar.syncNow")]})}),t.jsx(b,{label:n("settings.menubar.autoUpdate"),hint:n("settings.menubar.autoUpdateHint"),control:t.jsx(k,{checked:h,onChange:()=>s("autoUpdateEnabled",!h),ariaLabel:n("settings.menubar.autoUpdate")})}),t.jsx(b,{label:n("settings.menubar.updates"),hint:p||void 0,control:t.jsxs("button",{type:"button",onClick:()=>i("checkForUpdates"),disabled:g,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-oai-gray-200 px-3 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:[t.jsx(ft,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.menubar.checkUpdates")]})})]})}function gn(e,a){function s(r){return r.replace(/^v/,"").split(".").map(Number)}const i=s(e),o=s(a);for(let r=0;r<Math.max(i.length,o.length);r++){const l=i[r]||0,c=o[r]||0;if(l<c)return!0;if(l>c)return!1}return!1}function pn(){const{available:e,settings:a,runAction:s}=R(),i=e&&a?.version,o=a?.platform||"macos",[r,l]=H.useState(!1),[c,d]=H.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:h}=Q(),p="1.1.7",g=async()=>{l(!0);try{const y=await fetch("https://api.github.com/repos/xiufengsun/TokenTracker/releases/latest");if(!y.ok)throw new Error("Failed to fetch");const w=await y.json(),N=w.tag_name;gn(p,N)?d({open:!0,latestVersion:N,htmlUrl:w.html_url}):B({title:n("settings.menubar.updates.upToDate")})}catch(y){console.error("Check updates failed:",y),B({title:n("settings.menubar.updates.failed")})}finally{l(!1)}},m=n("settings.menubar.updates.modalTitle"),v=n("settings.menubar.updates.modalDescription",{version:c.latestVersion}),j=n("settings.menubar.updates.modalConfirm"),A=n("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:o==="windows"?n("settings.menubar.updates.footerCore",{version:a.version}):n("settings.menubar.updates.footerCombined",{barVersion:a.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:n("settings.menubar.updates.footerCore",{version:p})}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsx("button",{type:"button",onClick:g,disabled:r,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:r?n("settings.menubar.updates.checking"):n("settings.menubar.checkUpdates")}),t.jsx("span",{"aria-hidden":!0,children:"·"})]}),t.jsxs("a",{href:He,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(Fe,{className:"h-3.5 w-3.5","aria-hidden":!0}),n("settings.footer.statusPage")]})]}),t.jsx(mt,{open:c.open,title:m,description:v,confirmLabel:j,cancelLabel:A,onConfirm:()=>{window.open(c.htmlUrl,"_blank"),d(y=>({...y,open:!1}))},onCancel:()=>d(y=>({...y,open:!1}))})]})}const hn=()=>[{value:"system",label:n("settings.network.mode.system")},{value:"manual",label:n("settings.network.mode.manual")},{value:"off",label:n("settings.network.mode.off")}],mn=()=>[{value:"http",label:n("settings.network.protocol.http")},{value:"https",label:n("settings.network.protocol.https")},{value:"socks5",label:n("settings.network.protocol.socks5")}],Y="w-full 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";function Z(e){const a={},s=String(e.host||"").trim();(!s||/:\/\//.test(s)||s.includes("/"))&&(a.host=n("settings.network.error.host"));const i=String(e.port??"").trim(),o=Number(i);return(!i||!/^\d+$/.test(i)||!Number.isInteger(o)||o<1||o>65535)&&(a.port=n("settings.network.error.port")),a}function bn({proxySettings:e}){const{config:a,save:s,testConnection:i}=e,[o,r]=u.useState(()=>({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})),[l,c]=u.useState({}),[d,h]=u.useState(!1),[p,g]=u.useState(""),[m,v]=u.useState(null),[j,A]=u.useState(!1),[y,w]=u.useState(null);u.useEffect(()=>{r({mode:a.mode,protocol:a.protocol||"http",host:a.host||"",port:a.port||""})},[a.mode,a.protocol,a.host,a.port]);const N=u.useMemo(()=>a.effective==="manual"?n("settings.network.effective.manual"):a.effective==="env"?n("settings.network.effective.env"):a.effective==="system"?n("settings.network.effective.system"):a.effective==="blocked"?n("settings.network.effective.blocked"):n("settings.network.effective.none"),[a.effective]),f=x=>{r(E=>({...E,...x})),c({}),g(""),v(null),w(null)},S=async()=>{if(o.mode==="manual"){const x=Z(o);if(Object.keys(x).length){c(x);return}}h(!0),g(""),v(null);try{await s(o),g("saved")}catch(x){g("error"),v(x)}finally{h(!1)}},L=async()=>{const x=Z(o);if(Object.keys(x).length){c(x);return}A(!0),w(null);try{const E=await i(o);w(E)}catch(E){w({ok:!1,error:E?.message||String(E)})}finally{A(!1)}};return t.jsxs(O,{title:n("settings.section.network"),subtitle:N,children:[a.applyError?t.jsx("p",{role:"alert",className:"mb-3 text-xs text-red-600 dark:text-red-400",children:n("settings.network.apply_error",{error:a.applyError})}):null,t.jsx(b,{label:n("settings.network.mode.label"),hint:n("settings.network.mode.hint"),control:t.jsx(G,{options:hn(),value:o.mode,onChange:x=>f({mode:x})})}),t.jsx(ae,{initial:!1,children:o.mode==="manual"?t.jsxs(ne.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(b,{label:n("settings.network.protocol.label"),control:t.jsx(F,{value:o.protocol,onValueChange:x=>f({protocol:x}),options:mn(),ariaLabel:n("settings.network.protocol.label"),className:"px-2.5 py-1.5 text-xs font-medium"})}),t.jsx(b,{label:n("settings.network.host.label"),hint:l.host,control:t.jsx("input",{type:"text",value:o.host,onChange:x=>f({host:x.target.value}),placeholder:n("settings.network.host.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":l.host?!0:void 0,"aria-label":n("settings.network.host.label"),className:Y})}),t.jsx(b,{label:n("settings.network.port.label"),hint:l.port,control:t.jsx("input",{type:"text",inputMode:"numeric",value:o.port,onChange:x=>f({port:x.target.value}),placeholder:n("settings.network.port.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":l.port?!0:void 0,"aria-label":n("settings.network.port.label"),className:Y})}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 py-3",children:[t.jsx("button",{type:"button",onClick:L,disabled:j||d,className:"rounded-md border border-oai-gray-200 px-3 py-1.5 text-xs font-medium text-oai-gray-700 transition-colors hover:bg-oai-gray-100 disabled:opacity-50 dark:border-oai-gray-800 dark:text-oai-gray-300 dark:hover:bg-oai-gray-800",children:j?n("settings.network.test.testing"):n("settings.network.test")}),t.jsx("button",{type:"button",onClick:S,disabled:d||j,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:d?n("settings.network.saving"):n("settings.network.save")})]}),y?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:y.ok?n("settings.network.test.ok",{status:String(y.status??"")}):n("settings.network.test.fail",{error:y.error||""})}):null]},"manual-proxy-fields"):t.jsx("div",{className:"flex justify-end py-3",children:t.jsx("button",{type:"button",onClick:S,disabled:d,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:d?n("settings.network.saving"):n("settings.network.save")})},"non-manual-save")}),p==="saved"?t.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:n("settings.network.saved")}):null,p==="error"?t.jsx("p",{role:"alert",className:"py-2 text-xs text-red-600 dark:text-red-400",children:m?.unprotected?n("settings.network.save_error_unprotected",{error:m?.message||String(m||"")}):n("settings.network.save_error",{error:m?.message||String(m||"")})}):null]})}const pe="/functions/tokentracker-proxy-config",fn="/functions/tokentracker-proxy-test",xn={mode:"system",protocol:"http",host:"",port:"",effective:"none",applyError:null};function he(e){return!e||typeof e.mode!="string"?null:{mode:e.mode,protocol:typeof e.protocol=="string"?e.protocol:"http",host:typeof e.host=="string"?e.host:"",port:e.port==null||e.port===0?"":String(e.port),effective:typeof e.effective=="string"?e.effective:"none",applyError:typeof e.applyError=="string"&&e.applyError.trim()?e.applyError:null}}async function yn(){const e=await fetch(pe,{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!e.ok)return null;const a=await e.json().catch(()=>null);return he(a)}async function J(){const{getLocalApiAuthHeaders:e}=await $e(async()=>{const{getLocalApiAuthHeaders:a}=await import("./__vite-browser-external-CAVICAeZ.js").then(s=>s.db);return{getLocalApiAuthHeaders:a}},__vite__mapDeps([0,1]));return e()}function vn(){const[e,a]=u.useState(!1),[s,i]=u.useState(!0),[o,r]=u.useState(xn);u.useEffect(()=>{if(!xt()){a(!1),i(!1);return}let d=!1;return(async()=>{try{const h=await yn();if(d)return;if(!h){a(!1),i(!1);return}r(h),a(!0),i(!1)}catch{d||(a(!1),i(!1))}})(),()=>{d=!0}},[]);const l=u.useCallback(async d=>{const h=await J(),p=await fetch(pe,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...h},cache:"no-store",body:JSON.stringify({mode:d.mode,protocol:d.protocol,host:d.host,port:d.port===""?0:Number(d.port)})}),g=await p.json().catch(()=>null);if(!p.ok){const v=g&&typeof g.error=="string"?g.error:`HTTP ${p.status}`;throw new Error(v)}const m=he(g);if(m&&r(m),g&&g.ok===!1){const v=g&&typeof g.applyError=="string"&&g.applyError||g&&typeof g.error=="string"&&g.error||`HTTP ${p.status}`,j=new Error(v);throw g.unprotected===!0&&(j.unprotected=!0),j}return m||g},[]),c=u.useCallback(async d=>{const h=await J(),p=await fetch(fn,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...h},cache:"no-store",body:JSON.stringify({protocol:d.protocol,host:d.host,port:d.port===""?0:Number(d.port)})}),g=await p.json().catch(()=>null);if(!g||typeof g.ok!="boolean")throw new Error(g&&typeof g.error=="string"?g.error:`HTTP ${p.status}`);return g},[]);return{available:e,loading:s,config:o,save:l,testConnection:c}}const C={APPEARANCE:"appearance",NATIVE_APP:"native-app",NETWORK:"network",ACCOUNT:"account",LIMITS:"limits",LABS:"labs"},P={PERSONAL:"personal",APP:"app",DEVELOPER:"developer"};function kn({prefs:e}){return t.jsx(G,{options:[{value:W.USED,label:n("limits.settings.display_mode_used")},{value:W.REMAINING,label:n("limits.settings.display_mode_remaining")}],value:e.displayMode,onChange:e.setDisplayMode})}function Wn(){const e=it(),{available:a,settings:s,setSetting:i}=R(),o=vn(),{available:r}=o,l=s?.toastOnReset!==!1,c=s?.confettiOnReset!==!1,d=te()||s?.platform==="windows",[h,p]=Ve(),g=Be(),m=h.get("section"),j=Object.values(C).includes(m)&&(m!==C.NATIVE_APP||a)&&(m!==C.NETWORK||r)?m:C.APPEARANCE,A=f=>{const S=new URLSearchParams(h);f===C.APPEARANCE?S.delete("section"):S.set("section",f),p(S,{replace:!0})},y=[{id:C.APPEARANCE,label:n("settings.section.appearance"),description:n("settings.section.appearance.description"),group:P.PERSONAL,Icon:St,content:t.jsx(cn,{})},...a?[{id:C.NATIVE_APP,label:n("settings.section.menubar"),description:n("settings.section.menubar.description"),group:P.APP,Icon:ee,content:t.jsx(un,{})}]:[],...r?[{id:C.NETWORK,label:n("settings.section.network"),description:n("settings.section.network.description"),group:P.APP,Icon:ze,content:t.jsx(bn,{proxySettings:o})}]:[],{id:C.ACCOUNT,label:n("settings.section.account"),description:n("settings.section.account.description"),group:P.PERSONAL,Icon:wt,content:t.jsx(Yt,{})},{id:C.LIMITS,label:n("settings.section.limits"),description:n("settings.section.limits.description"),group:P.APP,Icon:Ke,content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs(O,{title:n("settings.section.limits"),children:[t.jsx(b,{label:n("limits.settings.display_mode_label"),control:t.jsx(kn,{prefs:e})}),d?null:t.jsxs(t.Fragment,{children:[t.jsx(b,{label:n("settings.menubar.toastOnReset"),hint:n("settings.menubar.toastOnResetHint"),control:t.jsx(k,{checked:l,disabled:!a,onChange:()=>i("toastOnReset",!l),ariaLabel:n("settings.menubar.toastOnReset")})}),t.jsx(b,{label:n("settings.menubar.confettiOnReset"),hint:n("settings.menubar.confettiOnResetHint"),control:t.jsx(k,{checked:c,disabled:!a,onChange:()=>i("confettiOnReset",!c),ariaLabel:n("settings.menubar.confettiOnReset")})})]}),t.jsx(b,{label:n("settings.limits.showSubscriptions"),hint:n("settings.limits.showSubscriptionsHint"),control:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>g("/limits?openSubscriptions=1"),"aria-label":n("limits.page.openSubscriptions"),title:n("limits.page.openSubscriptions"),className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-oai-gray-200 dark:border-oai-gray-700 bg-white dark:bg-oai-gray-900 text-oai-gray-500 dark:text-oai-gray-400 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500",children:t.jsx(qe,{size:14,"aria-hidden":!0})}),t.jsx(k,{checked:e.showSubscriptions!==!1,onChange:()=>e.setShowSubscriptions(!e.showSubscriptions),ariaLabel:n("settings.limits.showSubscriptions")})]})})]}),t.jsx(O,{title:n("settings.limits.providers"),children:t.jsx(Pt,{prefs:e})})]})},{id:C.LABS,label:n("settings.section.labs"),description:n("settings.section.labs.description"),group:P.DEVELOPER,Icon:yt,content:t.jsx(dn,{})}],w=[{id:P.PERSONAL,label:n("settings.nav.group.personal")},{id:P.APP,label:n("settings.nav.group.app")},{id:P.DEVELOPER,label:n("settings.nav.group.developer")}].map(f=>({...f,sections:y.filter(S=>S.group===f.id)})).filter(f=>f.sections.length>0);let N=y[0];for(const f of y)if(f.id===j){N=f;break}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.jsxs("div",{className:"mb-7 max-w-2xl",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:n("settings.page.title")}),t.jsx("p",{className:"mt-2 text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:n("settings.page.subtitle")})]}),t.jsxs("div",{className:"grid min-w-0 gap-6 md:grid-cols-[14rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[15rem_minmax(0,1fr)]",children:[t.jsx("aside",{className:"min-w-0 rounded-xl border border-oai-gray-200 bg-oai-gray-50/70 p-2 dark:border-oai-gray-800 dark:bg-oai-gray-900/60 md:border-0 md:bg-transparent md:p-0 md:dark:bg-transparent",children:t.jsx("nav",{"aria-label":n("settings.page.title"),className:"flex gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden md:sticky md:top-6 md:flex-col md:gap-4 md:overflow-visible",children:w.map(({id:f,label:S,sections:L})=>t.jsxs("div",{className:"flex shrink-0 gap-1 md:block",children:[t.jsx("div",{className:"hidden px-3 pb-1 text-[10px] font-semibold uppercase tracking-[0.16em] text-oai-gray-400 dark:text-oai-gray-500 md:block",children:S}),t.jsx("div",{className:"flex gap-1 md:flex-col",children:L.map(({id:x,label:E,Icon:D})=>{const I=j===x;return t.jsxs("button",{id:`settings-nav-${x}`,type:"button","aria-current":I?"page":void 0,"aria-controls":`settings-panel-${x}`,onClick:()=>A(x),className:_("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",I?"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(D,{className:_("h-4 w-4 shrink-0",I?"text-oai-black dark:text-white":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),t.jsx("span",{className:"truncate",children:E})]},x)})})]},f))})}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"mb-4 border-b border-oai-gray-200 pb-4 dark:border-oai-gray-800",children:[t.jsx("h2",{className:"text-xl font-semibold tracking-tight text-oai-black dark:text-white",children:N.label}),t.jsx("p",{className:"mt-1 text-sm leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:N.description})]}),y.map(({id:f,label:S,content:L})=>t.jsx("section",{id:`settings-panel-${f}`,"aria-labelledby":`settings-nav-${f}`,"aria-label":S,"data-settings-panel":f,hidden:j!==f,children:L},f)),t.jsx(pn,{})]})]})]})})})}export{Wn as SettingsPage};
|