tokentracker-cli 1.3.10 → 1.3.13
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-vU4Dwu_p.js → AchievementBadge-DkNsd5tj.js} +1 -1
- package/dashboard/dist/assets/{AchievementsPage-C8LspyPK.js → AchievementsPage-Dr72Hcog.js} +2 -2
- package/dashboard/dist/assets/{AchievementsSection-CP8J07fV.js → AchievementsSection-CkOdGlnD.js} +1 -1
- package/dashboard/dist/assets/{BadgeDetailModal-Ci1egHvR.js → BadgeDetailModal-DADLfBsK.js} +1 -1
- package/dashboard/dist/assets/{BotAnimated-CMXILM_h.js → BotAnimated-k6u1GRzw.js} +1 -1
- package/dashboard/dist/assets/{Card-BHHCCnqR.js → Card-Dk6s3h-P.js} +1 -1
- package/dashboard/dist/assets/{CloudCheckoutPage-BY9Hsbix.js → CloudCheckoutPage-DL0pvok0.js} +1 -1
- package/dashboard/dist/assets/{CloudPage-Y6JgOXcJ.js → CloudPage-BizN1MZL.js} +2 -2
- package/dashboard/dist/assets/{CommandPalette-BRWQFJwy.js → CommandPalette-B2crDNlV.js} +1 -1
- package/dashboard/dist/assets/{CommunityStatsModal-krT4ZZX9.js → CommunityStatsModal-C6Rc5NME.js} +1 -1
- package/dashboard/dist/assets/{ConfirmModal-ZvPOJ0he.js → ConfirmModal-BrxBQn4n.js} +1 -1
- package/dashboard/dist/assets/{Controls-CQlxw03i.js → Controls-C2mEPI72.js} +1 -1
- package/dashboard/dist/assets/{DashboardPage-Dbi0d2JY.js → DashboardPage-BomPd7nt.js} +1 -1
- package/dashboard/dist/assets/{DateRangePopover-DJ8RpQfV.js → DateRangePopover-Gz-N_D7O.js} +1 -1
- package/dashboard/dist/assets/{DevicePage-C4_cbw3M.js → DevicePage-wmnNx9bd.js} +1 -1
- package/dashboard/dist/assets/{DialogClose-Dx5AqmUG.js → DialogClose-D1dzj_on.js} +1 -1
- package/dashboard/dist/assets/DialogDescription-ChbOGLc_.js +1 -0
- package/dashboard/dist/assets/{DialogTitle-Cro2S8s8.js → DialogTitle-BBxNf3O8.js} +1 -1
- package/dashboard/dist/assets/{ElectricLogo-gqnBCtSG.js → ElectricLogo-DCopeDc8.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-B9oATcDZ.js → FadeIn-DSndojVd.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-CYa94wna.js → HeaderGithubStar-BBAGbevf.js} +1 -1
- package/dashboard/dist/assets/{HoverTooltip-BJ4qLyuS.js → HoverTooltip-COD3xE9E.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-Clpq3jdY.js → IpCheckPage-BtMWefop.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-CuazuOAo.js → LandingPage-DN2IVBw7.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardPage-BSF1Lbtq.js → LeaderboardPage-DkJowsRI.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardProBadge-K32gY52s.js → LeaderboardProBadge-CRRphJNs.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardProfileModal-D5gpn7pP.js → LeaderboardProfileModal-WmZAsZx5.js} +3 -3
- package/dashboard/dist/assets/{LeaderboardProfilePage-BmO9nIi-.js → LeaderboardProfilePage-DWHu-eOp.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-D9ZJ1TeK.js → LimitsPage-BRFAWm-1.js} +1 -1
- package/dashboard/dist/assets/{LocalOnlyNotice-BkzysTS7.js → LocalOnlyNotice-BjJ8N4Zc.js} +1 -1
- package/dashboard/dist/assets/{LoginCard-Do3SNJFU.js → LoginCard-CYmjHoYK.js} +1 -1
- package/dashboard/dist/assets/{LoginModal-hph1i_YK.js → LoginModal-DX1D9F8b.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-DXYAaFjJ.js → LoginPage-D7Ok7HiZ.js} +1 -1
- package/dashboard/dist/assets/{PetPage-D1Pk4OKI.js → PetPage-BYISPev2.js} +2 -2
- package/dashboard/dist/assets/{PopoverPopup-CAIuP_a5.js → PopoverPopup-BlzqlKqF.js} +1 -1
- package/dashboard/dist/assets/{ProviderIcon-R6Bsj81X.js → ProviderIcon-BuLwtYjj.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-BR3GTF-3.js → ResetPasswordPage-BJRKclq9.js} +1 -1
- package/dashboard/dist/assets/{Select-38Dh-OWv.js → Select-0YyBw95W.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-90n7jKbI.js → SelectItemText-CZKyxUjE.js} +1 -1
- package/dashboard/dist/assets/{SelfHostPage-BKVYkHI6.js → SelfHostPage-C_Afofs-.js} +1 -1
- package/dashboard/dist/assets/{ServiceStatusPage-PBmBn29J.js → ServiceStatusPage-0KpLdpon.js} +1 -1
- package/dashboard/dist/assets/{SessionsPage-58MfDHhe.js → SessionsPage-YtSyWMd0.js} +1 -1
- package/dashboard/dist/assets/{SettingsPage-BNLHbZUQ.js → SettingsPage-Bm641_AH.js} +3 -3
- package/dashboard/dist/assets/{SkillsPage-DMMTk4jD.js → SkillsPage-DNg-I2g_.js} +1 -1
- package/dashboard/dist/assets/{TokenGalaxy-BdPETjru.js → TokenGalaxy-BMN7WiRH.js} +1 -1
- package/dashboard/dist/assets/{TooltipPopup-BXl-vM4L.js → TooltipPopup-BF56BHfc.js} +1 -1
- package/dashboard/dist/assets/{TrendMonitor-wPfTlX-7.js → TrendMonitor-D0ea5xMA.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-CuwRMWka.js → WidgetsPage-CIAoHmJG.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-DOpA9kkg.js → WrappedPage-CC_57Zr2.js} +1 -1
- package/dashboard/dist/assets/{__vite-browser-external-Go6WKt6Z.js → __vite-browser-external-CPskAZuH.js} +2 -2
- package/dashboard/dist/assets/{agent-logos-D7eMvAlk.js → agent-logos-CcJUaB75.js} +1 -1
- package/dashboard/dist/assets/{arrow-left--eOVP_Dk.js → arrow-left-CUiT31ZF.js} +1 -1
- package/dashboard/dist/assets/{arrow-right-DJYhwBMz.js → arrow-right-Tds6Mert.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-DhDvpd-S.js → arrow-up-right-CGSxdyzM.js} +1 -1
- package/dashboard/dist/assets/{calendar-days-BuOFlNcJ.js → calendar-days-Cc8AtMa3.js} +1 -1
- package/dashboard/dist/assets/{check-UztXSVYi.js → check-CzJylQ9j.js} +1 -1
- package/dashboard/dist/assets/{chevron-down-CbJ2QGDU.js → chevron-down-DyG9JVDO.js} +1 -1
- package/dashboard/dist/assets/{cloud-checkout-CoRQjKEu.js → cloud-checkout-DP5zddOq.js} +1 -1
- package/dashboard/dist/assets/{composite-PlKvZfdM.js → composite-I_1t6PMI.js} +1 -1
- package/dashboard/dist/assets/{download-McE9gFto.js → download-B_LvkErh.js} +1 -1
- package/dashboard/dist/assets/{external-link-DZWnR9gS.js → external-link-DDA3ObBn.js} +1 -1
- package/dashboard/dist/assets/{flame-0xjueXt4.js → flame-BqpVWH_1.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-CZoG68uJ.js → format-tokens-D6QEOnGq.js} +1 -1
- package/dashboard/dist/assets/{gift-pKc80Nqb.js → gift-BxbKo3W6.js} +1 -1
- package/dashboard/dist/assets/{host-mode-99_v1j5J.js → host-mode-o3qQY7tz.js} +1 -1
- package/dashboard/dist/assets/{icons-BtfYKSGC.js → icons-oGPZPj2n.js} +1 -1
- package/dashboard/dist/assets/{index-CyZxN1O0.js → index-BxtvQ1J7.js} +1 -1
- package/dashboard/dist/assets/{index-DuaQmNZo.js → index-Byukv2Nu.js} +1 -1
- package/dashboard/dist/assets/{index-Cgthm7BO.js → index-DX--5z1g.js} +1 -1
- package/dashboard/dist/assets/{info-C8vkxwsO.js → info-BoTz1AGZ.js} +1 -1
- package/dashboard/dist/assets/{link-2-CQzIW5b6.js → link-2-C09a122s.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-B9GqzQyC.js → loader-circle--9U0axVe.js} +1 -1
- package/dashboard/dist/assets/{modifiers.esm-ChkCUrZp.js → modifiers.esm-Cra0I6RP.js} +1 -1
- package/dashboard/dist/assets/{monitor-smartphone-DQjBY1W3.js → monitor-smartphone-C1ENjmOu.js} +1 -1
- package/dashboard/dist/assets/{play-qC6xc6fe.js → play-NqPqbW59.js} +1 -1
- package/dashboard/dist/assets/{plus-CoNHx5Og.js → plus-DZP82JeP.js} +1 -1
- package/dashboard/dist/assets/{provider-display-x2EG6zAY.js → provider-display-BLo4k0bi.js} +1 -1
- package/dashboard/dist/assets/{react-EctmAw3f.js → react-CTLavVze.js} +1 -1
- package/dashboard/dist/assets/{safePolygon-DlSbLtZC.js → safePolygon-Yw5w5Nw8.js} +1 -1
- package/dashboard/dist/assets/{search-CBcpAj9I.js → search-DgV6mpMO.js} +1 -1
- package/dashboard/dist/assets/{server-DtMUoEq0.js → server-BybwAQjW.js} +1 -1
- package/dashboard/dist/assets/{shield-check-ByUPtUmu.js → shield-check-BiTYwWdT.js} +1 -1
- package/dashboard/dist/assets/{skills-api-BD9VNRej.js → skills-api-Dx_Z8_SO.js} +1 -1
- package/dashboard/dist/assets/{sortable.esm-B6qEViGJ.js → sortable.esm-CmJnBLcr.js} +1 -1
- package/dashboard/dist/assets/{store-BgW2uBRe.js → store-DzNIKGzf.js} +1 -1
- package/dashboard/dist/assets/{terminal-DWPNkr2L.js → terminal-DPly-UPW.js} +1 -1
- package/dashboard/dist/assets/{trash-DdbRpgD1.js → trash-DsL2ZAN5.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-43ySv9uM.js → use-community-stats-CSTkXFed.js} +1 -1
- package/dashboard/dist/assets/{use-latest-request-guard-BuezAv4k.js → use-latest-request-guard-CbAXXNlU.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-Yi0Hznar.js → use-limits-display-prefs-mDl6Yv_-.js} +1 -1
- package/dashboard/dist/assets/{use-native-settings-BaSrhrM8.js → use-native-settings-Bu2C3b20.js} +1 -1
- package/dashboard/dist/assets/{use-ordered-list-CBD-EIBf.js → use-ordered-list-DkGSfMTv.js} +1 -1
- package/dashboard/dist/assets/use-reduced-motion-6nBw3cR5.js +1 -0
- package/dashboard/dist/assets/{use-session-efficiency-pref-CwaFIkE5.js → use-session-efficiency-pref-B2GDf83h.js} +1 -1
- package/dashboard/dist/assets/{use-transform-Dea4uz8K.js → use-transform-BVVduBPJ.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-DxkYcUIR.js → use-usage-limits-fuzpbbVh.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-CcZktkbA.js → useCurrency-CdDQzroJ.js} +1 -1
- package/dashboard/dist/assets/{usePositioner-BLGIGihf.js → usePositioner-b6XXJtxE.js} +1 -1
- package/dashboard/dist/assets/{useTokenFormat--dhm3nNf.js → useTokenFormat-90RoMQgI.js} +1 -1
- package/dashboard/dist/assets/{zap-CWTmP6Zw.js → zap-xEHzTW-T.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/lib/async-queue-reader.js +117 -0
- package/src/lib/local-api.js +88 -226
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/dashboard/dist/assets/DialogDescription-LvhfT1Ox.js +0 -1
- package/dashboard/dist/assets/use-reduced-motion-ObUuoXUE.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-
|
|
2
|
-
import{o as ne,by as Dt,bm as Ut,r as o,M as zt,K as Gt,bz as Mt,j as e,c as a,y as le,a as lt,cK as $t,cL as Ft,cM as Bt,cN as Ht,a7 as me,cO as Be,bi as Vt,cP as qt,bh as He,cQ as we,aP as ct,cR as Kt,cS as Wt,ag as dt,u as ut,B as A,V as Pe,aM as mt,X as Yt,x as Oe,a8 as H,cT as Zt,a9 as ee,ar as gt,cU as Ne,a5 as ce,aB as pt,ai as Ve,cV as Jt,ak as Xt,aj as Qt,ah as ea,cW as qe,cX as ta,a1 as aa,af as sa,au as fe,av as Ae,cY as na,R as De,L as ye,al as ia,am as Ue,ac as ra,d as ht,aa as Le,ab as ft,cZ as Ke,c_ as We,c$ as Ye,d0 as oa,d1 as la,ao as ca,Z as xt,l as Se,d2 as Ze,k as Je,d3 as da,d4 as ua,d5 as ma,z as ga,d6 as pa,d7 as ha,d8 as fa,d9 as xa,da as ba,db as ya,dc as va,v as bt,cn as ja,dd as ka,bj as Xe,_ as _a,e as wa,de as Na,df as Sa,bl as Ca}from"./__vite-browser-external-Go6WKt6Z.js";import{a as Ea,b as Qe,s as Pa,K as Oa,P as Aa,D as La,c as Ta,S as Ra,v as Ia,u as Da,C as Ua}from"./sortable.esm-B6qEViGJ.js";import{a as za}from"./modifiers.esm-ChkCUrZp.js";import{d as et,l as tt,u as Ga,b as at}from"./use-limits-display-prefs-Yi0Hznar.js";import{P as Ma}from"./ProviderIcon-R6Bsj81X.js";import{a as R,S as se,T as z,b as Z,c as ve}from"./Controls-CQlxw03i.js";import{m as yt}from"./react-EctmAw3f.js";import{P as $a,u as Fa,a as Ba}from"./use-session-efficiency-pref-CwaFIkE5.js";import{C as Ha}from"./check-UztXSVYi.js";import{C as Va,i as qa}from"./host-mode-99_v1j5J.js";import{A as vt}from"./index-DuaQmNZo.js";import{r as Ka,C as Ce,o as Wa}from"./cloud-checkout-CoRQjKEu.js";import{u as Ya,D as Za,a as Ja,b as Xa,c as Qa,d as es,e as ts}from"./DialogTitle-Cro2S8s8.js";import{u as as,p as ss,t as ns}from"./composite-PlKvZfdM.js";import{k as is,l as rs}from"./SelectItemText-90n7jKbI.js";import{u as os}from"./safePolygon-DlSbLtZC.js";import{D as ls}from"./DialogClose-Dx5AqmUG.js";import{G as Te}from"./gift-pKc80Nqb.js";import{C as Re}from"./chevron-down-CbJ2QGDU.js";import{D as cs}from"./DateRangePopover-DJ8RpQfV.js";import{C as ds}from"./calendar-days-BuOFlNcJ.js";import{D as Ie}from"./download-McE9gFto.js";import{P as us,a as ms,b as gs,c as ps,d as hs}from"./PopoverPopup-CAIuP_a5.js";import{C as st}from"./Card-BHHCCnqR.js";import{E as nt}from"./external-link-DZWnR9gS.js";import{a as fs,P as xs}from"./play-qC6xc6fe.js";import{I as jt}from"./info-C8vkxwsO.js";import{a as bs,b as ys,c as vs,d as js,e as ks}from"./TooltipPopup-BXl-vM4L.js";import{L as xe}from"./loader-circle-B9GqzQyC.js";import{u as _s}from"./useCurrency-CcZktkbA.js";import{u as ws}from"./useTokenFormat--dhm3nNf.js";import{S as ze}from"./Select-38Dh-OWv.js";import{u as je}from"./use-native-settings-BaSrhrM8.js";import{C as Ns}from"./ConfirmModal-ZvPOJ0he.js";import{A as Ss}from"./arrow-up-right-DhDvpd-S.js";import"./store-BgW2uBRe.js";import"./usePositioner-BLGIGihf.js";import"./DialogDescription-LvhfT1Ox.js";const kt={name:"credit-card",size:24,node:[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}],["path",{d:"M6 14h2",key:"mk7k0u"}]]};kt.node;const Cs=ne(kt);const _t={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"}]]};_t.node;const Es=ne(_t);const wt={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"}]]};wt.node;const Ps=ne(wt);const Nt={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"}]]};Nt.node;const Os=ne(Nt);const St={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"}]]};St.node;const As=ne(St);const Ct={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"}]]};Ct.node;const Ls=ne(Ct);const Et={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"]};Et.node;const Ts=ne(Et),Rs=Dt(function(s,n){const{render:r,className:i,style:c,disabled:g=!1,nativeButton:l=!0,id:d,payload:p,handle:h,...m}=s,j=Ya(!0),x=os(h)??j;if(!x)throw new Error(Ut(79));const _=as(d),b=x.useState("floatingRootContext"),u=x.useState("isOpenedByTrigger",_),y=x.useState("triggerPopupId",_),k=o.useRef(null),{registerTrigger:f,isMountedByThisTrigger:N}=ss(_,k,x,{payload:p}),{getButtonProps:E,buttonRef:v}=zt({disabled:g,native:l}),C=is(b),O=rs(()=>x.select("open"),M=>{x.set("openMethod",M)}),S={disabled:g,open:u},P=x.useState("triggerProps",N);return Gt("button",s,{state:S,ref:[v,n,f,k],props:[C.reference,P,O,{[Mt]:"",id:_,"aria-haspopup":"dialog","aria-expanded":u,"aria-controls":y},m,E],stateAttributesMapping:ns})}),Is="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function Ds({id:t,visible:s,onToggle:n}){const{attributes:r,listeners:i,setNodeRef:c,transform:g,transition:l,isDragging:d}=Da({id:t}),p={transform:Ua.Transform.toString(g)||void 0,transition:l,zIndex:d?20:void 0};return e.jsxs("div",{ref:c,style:p,className:le("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"),...r,...i,children:[e.jsx(Ps,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),et(t)?e.jsx(Ma,{provider:et(t),size:18,className:le("pointer-events-none",Is)}):null,e.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200",children:tt(t)}),e.jsx("div",{onPointerDown:h=>h.stopPropagation(),children:e.jsx(z,{checked:s,onChange:n,ariaLabel:`${a("limits.settings.toggle_visible")}: ${tt(t)}`})})]})}function Us({prefs:t}){const{order:s,visibility:n,toggle:r,setAllVisible:i,moveToward:c}=t,g=s.every(m=>n[m]!==!1),l=s.every(m=>n[m]===!1),d=s.filter(m=>n[m]!==!1).length,p=Ea(Qe(Aa,{activationConstraint:{distance:6}}),Qe(Oa,{coordinateGetter:Pa})),h=({active:m,over:j})=>{j&&m.id!==j.id&&c(m.id,j.id)};return e.jsxs(e.Fragment,{children:[e.jsx(R,{label:a("limits.settings.bulk_visibility"),hint:a("limits.settings.enabled_count",{enabled:d,total:s.length}),control:e.jsx(se,{options:[{value:"enabled",label:a("limits.settings.enable_all")},{value:"disabled",label:a("limits.settings.disable_all")}],value:g?"enabled":l?"disabled":null,onChange:m=>i(m==="enabled")})}),e.jsx(La,{sensors:p,collisionDetection:Ta,modifiers:[za],onDragEnd:h,children:e.jsx(Ra,{items:s,strategy:Ia,children:e.jsx("div",{className:"flex flex-col",children:s.map(m=>e.jsx(Ds,{id:m,visible:n[m]!==!1,onToggle:()=>r(m)},m))})})})]})}function zs(t){if(!t||typeof t!="object")return"";const s=t.user_metadata&&typeof t.user_metadata=="object"?t.user_metadata:{},n=t.profile&&typeof t.profile=="object"?t.profile:{},r=s.full_name||s.name||n.name||s.user_name||s.preferred_username;return typeof r=="string"&&r.trim()?r.trim():typeof t.email=="string"&&t.email.includes("@")?t.email.split("@")[0].trim()||t.email.trim():typeof t.email=="string"?t.email.trim():""}function Gs(t){return!t||typeof t!="object"?"":typeof t.email=="string"?t.email.trim():""}function Ms(t){const s=typeof t=="string"?t.trim():"";if(!s)return null;const n=s.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),r=s.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),i=n?.[1]||r?.[1];return i?`https://github.com/${i}`:null}function Ge(t,s){console.warn(`[tokentracker] settings ${t}:`,s)}function $s(t,s,n,r){const[i,c]=o.useState(()=>me()),g=s&&n&&dt(),l=o.useMemo(()=>({active:!0,busy:!1}),[t,s,n,r]),d=o.useRef(l);d.current=l;const[p,h]=o.useState(null),m=p?.scope===l?p:null;o.useEffect(()=>{l.active=!0;const _=()=>{const u=me();c(u),u||h(y=>y?.scope===l?{...y,error:null}:y)},b=()=>{h(u=>u?.scope===l?{...u,error:null}:u),we(r,"cloud-sync")};return _(),window.addEventListener("tt.cloudSyncChanged",_),window.addEventListener("storage",_),window.addEventListener(Be,b),()=>{l.active=!1,window.removeEventListener("tt.cloudSyncChanged",_),window.removeEventListener("storage",_),window.removeEventListener(Be,b)}},[l,r]);const j=o.useCallback(async()=>{if(!g||!me()||l.busy||!l.active||d.current!==l)return;l.busy=!0,h({scope:l,pending:!0,error:null});const _=()=>l.active&&d.current===l&&me();try{await Vt(()=>t())}catch(b){if(!_())return;["cloud_membership_required","cloud_read_only_expired","cloud_history_window_exceeded","cloud_machine_limit","machine_limit_exceeded","cloud_machine_paused"].includes(b?.code)?qt(r,b.code,b.membership,"cloud-sync"):h({scope:l,pending:!0,error:{code:"billing_network_error"}}),Ge("cloud sync",b)}finally{l.busy=!1,l.active&&d.current===l&&h(b=>b?.scope===l?{...b,pending:!1}:b)}},[g,l,t,r]),w=o.useCallback(async()=>{if(!g||l.busy||!l.active||d.current!==l)return;const _=!me();h({scope:l,pending:!1,error:null}),He(_),c(_),_?await j():we(r,"cloud-sync")},[g,l,j,r]),x=o.useCallback(()=>{!g||!l.active||d.current!==l||(He(!1),c(!1),h(_=>_?.scope===l?{..._,error:null}:_),we(r,"cloud-sync"))},[g,l,r]);return{cloudSyncOn:i,cloudSyncPending:!!m?.pending,cloudSyncError:m?.error,handleCloudSyncToggle:w,handleCloudSyncRetry:j,handleCloudSyncDisable:x,showLocalCloudSync:g}}function Fs(t){const[s,n]=o.useState(!1),[r,i]=o.useState(!1),[c,g]=o.useState(!1),[l,d]=o.useState(!1),[p,h]=o.useState(null),[m,j]=o.useState(!1),[w,x]=o.useState(""),[_,b]=o.useState(!1),[u,y]=o.useState(""),[k,f]=o.useState(""),[N,E]=o.useState(!1),[v,C]=o.useState(null),O=o.useMemo(()=>zs(t),[t]),S=o.useMemo(()=>Gs(t),[t]),P=o.useMemo(()=>typeof t?.id=="string"?t.id.trim():"",[t]),M=o.useMemo(()=>({setAnonymousOn:i,setCustomDisplayName:h,setGithubUrl:y,setProfileLoading:g,setPublicProfileOn:n,setShowGithubOn:b}),[]);return{anonymousOn:r,customDisplayName:p,displayName:O,editingGithub:N,editingName:m,email:S,githubError:v,githubInput:k,githubUrl:u,loadSetters:M,nameInput:w,profileLoading:c,profileSaving:l,publicProfileOn:s,setAnonymousOn:i,setCustomDisplayName:h,setEditingGithub:E,setEditingName:j,setGithubError:C,setGithubInput:f,setGithubUrl:y,setNameInput:x,setProfileLoading:g,setProfileSaving:d,setPublicProfileOn:n,setShowGithubOn:b,showGithubOn:_,userId:P}}function Bs(t,s,n){o.useEffect(()=>{if(!s)return;let r=!0;return n.setProfileLoading(!0),(async()=>{try{const i=await ct({getAccessToken:t});if(!r||!i)return;const c=await Kt({accessToken:i});if(!r)return;n.setPublicProfileOn(!!c?.enabled),n.setAnonymousOn(!!c?.anonymous),c?.display_name&&n.setCustomDisplayName(c.display_name),n.setShowGithubOn(!!c?.show_github_url),n.setGithubUrl(c?.github_url||"")}catch(i){Ge("load public profile",i)}finally{r&&n.setProfileLoading(!1)}})(),()=>{r=!1}},[t,s,n])}function Hs(t,s,n){return o.useCallback(async(r,{label:i,onError:c,onSuccess:g}={})=>{if(!n||s.profileSaving)return!1;s.setProfileSaving(!0);try{const l=await ct({getAccessToken:t});if(!l)return!1;const d=await Wt({accessToken:l,...r});return g?.(d),!0}catch(l){return c?c(l):Ge(i||"mutate profile",l),!1}finally{s.setProfileSaving(!1)}},[t,s,n])}function Vs(t,s){return{anonymousOn:t.anonymousOn,customDisplayName:t.customDisplayName,displayName:t.displayName,editingName:t.editingName,handleAnonymousToggle:s.handleAnonymousToggle,handleSaveName:s.handleSaveName,nameInput:t.nameInput,profileLoading:t.profileLoading,profileSaving:t.profileSaving,setEditingName:t.setEditingName,setNameInput:t.setNameInput,startEditingName:s.startEditingName}}function qs(t,s){return{editingGithub:t.editingGithub,githubError:t.githubError,githubInput:t.githubInput,githubUrl:t.githubUrl,handleSaveGithub:s.handleSaveGithub,handleShowGithubToggle:s.handleShowGithubToggle,profileLoading:t.profileLoading,profileSaving:t.profileSaving,setEditingGithub:t.setEditingGithub,setGithubError:t.setGithubError,setGithubInput:t.setGithubInput,showGithubOn:t.showGithubOn,startEditingGithub:s.startEditingGithub}}function Ks(t,s){const n=o.useCallback(async()=>{const i=!t.publicProfileOn;await s({enabled:i},{label:"toggle public profile",onSuccess:()=>t.setPublicProfileOn(i)})},[s,t]);return{handleAnonymousToggle:o.useCallback(async()=>{const i=!t.anonymousOn;await s({anonymous:i},{label:"toggle anonymous",onSuccess:()=>t.setAnonymousOn(i)})},[s,t]),handlePublicProfileToggle:n}}function Ws(t,s,n){const r=o.useCallback(async()=>{const c=t.nameInput.trim().slice(0,50);c&&await s({display_name:c},{label:"save display name",onSuccess:()=>{t.setCustomDisplayName(c),t.setEditingName(!1),n?.()}})},[s,t,n]),i=o.useCallback(()=>{t.setNameInput(t.customDisplayName||t.displayName),t.setEditingName(!0)},[t]);return{handleSaveName:r,startEditingName:i}}function Ys(t,s){const n=o.useCallback(async()=>{if(!t.showGithubOn&&!t.githubUrl){t.setEditingGithub(!0),t.setGithubInput(""),t.setGithubError(null);return}const c=!t.showGithubOn;await s({show_github_url:c},{label:"toggle GitHub profile",onSuccess:()=>t.setShowGithubOn(c)})},[s,t]),r=o.useCallback(async()=>{const c=Ms(t.githubInput);if(t.githubInput.trim()&&!c){t.setGithubError(a("settings.account.githubUrlInvalid"));return}t.setGithubError(null),await s({github_url:c,show_github_url:!!c},{label:"save GitHub profile",onError:g=>t.setGithubError(g?.message||a("settings.account.githubUrlInvalid")),onSuccess:g=>{t.setGithubUrl(g?.github_url||c||""),t.setShowGithubOn(!!c),t.setEditingGithub(!1)}})},[s,t]),i=o.useCallback(()=>{t.setGithubInput(t.githubUrl),t.setGithubError(null),t.setEditingGithub(!0)},[t]);return{handleSaveGithub:r,handleShowGithubToggle:n,startEditingGithub:i}}function Me(){const t=lt();o.useSyncExternalStore($t,Ft,()=>0);const s=Bt(t.user?.id),r=!(s.membership?.status==="self_hosted"||s.catalog?.policy?.hosting_mode==="self_hosted")&&(Ht()||s.membership?.hosting_mode==="hosted"),i=Fs(t.user),c=$s(t.getAccessToken,t.enabled,t.signedIn,t.user?.id);Bs(t.getAccessToken,t.signedIn&&r,i.loadSetters);const g=Hs(t.getAccessToken,i,r),l=Ks(i,g),d=Ws(i,g,t.refreshDisplayName),p=Ys(i,g);return{...t,...c,email:i.email,handlePublicProfileToggle:l.handlePublicProfileToggle,userId:i.userId,name:Vs(i,{...l,...d}),github:qs(i,p),profileLoading:i.profileLoading,profileSaving:i.profileSaving,publicProfileOn:r&&i.publicProfileOn,publicProfileAvailable:r}}function Pt({disabled:t,onCancel:s,onSave:n,saveLabel:r=a("settings.account.save")}){return e.jsxs(e.Fragment,{children:[e.jsx(A,{variant:"primary",size:"sm",onClick:n,disabled:t,children:r}),e.jsx(A,{variant:"ghost",size:"sm",onClick:s,className:"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:a("settings.account.cancel")})]})}function Zs({nameInput:t,setEditingName:s,setNameInput:n,profileSaving:r,handleSaveName:i}){return e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:c=>n(c.target.value),onKeyDown:c=>{c.key==="Enter"&&i(),c.key==="Escape"&&s(!1)},maxLength:50,autoFocus:!0,className:`flex-1 ${ve}`,placeholder:a("settings.account.displayName")}),e.jsx(Pt,{disabled:r||!t.trim(),onCancel:()=>s(!1),onSave:i,saveLabel:r?a("settings.account.saving"):void 0})]})}function Js({githubError:t,githubInput:s,handleSaveGithub:n,profileSaving:r,setEditingGithub:i,setGithubError:c,setGithubInput:g}){return e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:s,onChange:l=>{g(l.target.value),t&&c(null)},onKeyDown:l=>{l.key==="Enter"&&n(),l.key==="Escape"&&(i(!1),c(null))},maxLength:100,autoFocus:!0,className:`flex-1 ${ve}`,placeholder:a("settings.account.githubUrlPlaceholder")}),e.jsx(Pt,{disabled:r,onCancel:()=>{i(!1),c(null)},onSave:n,saveLabel:r?a("settings.account.saving"):void 0})]}),t?e.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:t}):null]})}function Ot({disabled:t=!1,label:s,onClick:n,title:r}){return e.jsxs(A,{variant:"secondary",size:"sm",onClick:n,disabled:t,title:r,className:"gap-1.5",children:[e.jsx($a,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{children:s})]})}function At({actions:t,editing:s,editor:n,hint:r,label:i}){return 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:i}),s?n:e.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r})]}),s?null:t]})})}function Xs({name:t}){const s=t.anonymousOn?a("settings.account.displayNameDisabledWhileAnon"):void 0;return e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(Ot,{disabled:t.anonymousOn,label:a("settings.account.edit"),onClick:t.startEditingName,title:s}),e.jsx(z,{checked:!t.anonymousOn,onChange:t.handleAnonymousToggle,disabled:t.profileLoading||t.profileSaving,ariaLabel:a("settings.account.displayName")})]})}function Qs({name:t}){const{anonymousOn:s,customDisplayName:n,displayName:r,editingName:i,handleAnonymousToggle:c,handleSaveName:g,nameInput:l,profileLoading:d,profileSaving:p,setEditingName:h,setNameInput:m,startEditingName:j}=t,w=s?a("settings.account.displayNameAnonymousHint"):n||r;return e.jsx(At,{label:a("settings.account.displayName"),editing:i,hint:w,editor:e.jsx(Zs,{nameInput:l,setEditingName:h,setNameInput:m,profileSaving:p,handleSaveName:g}),actions:e.jsx(Xs,{name:t})})}function en({github:t}){const{editingGithub:s,githubError:n,githubInput:r,githubUrl:i,handleSaveGithub:c,handleShowGithubToggle:g,profileLoading:l,profileSaving:d,setEditingGithub:p,setGithubError:h,setGithubInput:m,showGithubOn:j,startEditingGithub:w}=t;return e.jsx(e.Fragment,{children:e.jsx(At,{label:a("settings.account.githubUrl"),editing:s,hint:i||a("settings.account.githubUrlHint"),editor:e.jsx(Js,{githubError:n,githubInput:r,handleSaveGithub:c,profileSaving:d,setEditingGithub:p,setGithubError:h,setGithubInput:m}),actions:e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(Ot,{label:a("settings.account.edit"),onClick:w}),e.jsx(z,{checked:j,onChange:g,disabled:l||d,ariaLabel:a("settings.account.githubUrl")})]})})})}function tn(){const{openLoginModal:t}=ut();return e.jsx(Z,{title:a("settings.section.account"),children:e.jsxs("div",{className:"flex flex-col gap-3 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("settings.account.signedOutHint")}),e.jsx(A,{variant:"primary",size:"sm",onClick:t,children:a("settings.account.signIn")})]})})}function an({name:t,github:s}){return e.jsxs(e.Fragment,{children:[e.jsx(Qs,{name:t}),e.jsx(en,{github:s})]})}function sn({settings:t}={}){return t?e.jsx(Lt,{settings:t}):e.jsx(nn,{})}function nn(){const t=Me();return e.jsx(Lt,{settings:t})}function Lt({settings:t}){return t.enabled?t.signedIn?e.jsxs(Z,{title:a("settings.section.account"),subtitle:t.email||t.name.customDisplayName||t.name.displayName,action:e.jsx(on,{onSignOut:t.signOut}),children:[e.jsx(rn,{userId:t.userId}),e.jsx(ln,{checked:t.publicProfileOn,disabled:t.profileLoading||t.profileSaving||t.publicProfileAvailable===!1,onChange:t.handlePublicProfileToggle,unavailable:t.publicProfileAvailable===!1}),e.jsx(cn,{visible:t.publicProfileOn,name:t.name,github:t.github})]}):e.jsx(tn,{}):null}function rn({userId:t}){const[s,n]=Pe.useState(!1);if(!t)return null;const r=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(t),n(!0),globalThis.setTimeout(()=>n(!1),1200)}catch{n(!1)}};return e.jsx(R,{label:a("settings.account.userId"),hint:e.jsx("span",{className:"font-mono",children:t}),control:e.jsxs(A,{variant:"secondary",size:"sm",onClick:r,"aria-label":a("settings.account.copyUserId"),className:"gap-1.5",children:[s?e.jsx(Ha,{className:"h-3.5 w-3.5","aria-hidden":!0}):e.jsx(Va,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{children:s?a("settings.account.copied"):a("settings.account.copy")})]})})}function on({onSignOut:t}){return e.jsxs(A,{variant:"ghost",size:"sm",onClick:()=>t(),className:"!h-7 !px-2 text-xs text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:[e.jsx(As,{className:"h-3.5 w-3.5 mr-1.5","aria-hidden":!0}),e.jsx("span",{children:a("settings.account.signOut")})]})}function ln({checked:t,disabled:s,onChange:n,unavailable:r}){return e.jsx(R,{label:a("settings.account.publicProfile"),hint:a(r?"cloud.self_host.public_profile_disabled":"settings.account.publicProfileHint"),control:e.jsx(z,{checked:t,onChange:n,disabled:s,ariaLabel:a("settings.account.publicProfile")})})}function cn({visible:t,name:s,github:n}){return e.jsx(vt,{initial:!1,children:t?e.jsx(yt.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(an,{name:s,github:n})},"public-profile-fields"):null})}function $e({open:t,onOpenChange:s,title:n,triggerLabel:r=n,icon:i,wide:c=!1,preventClose:g=!1,initialFocus:l,children:d}){return e.jsxs(Za,{open:t,onOpenChange:(p,h)=>{if(!p&&g){h.cancel();return}s(p)},children:[e.jsxs(Rs,{className:"inline-flex h-11 w-full items-center gap-3 rounded-md border-0 bg-transparent p-0 text-left text-sm font-medium text-oai-black transition-colors hover:bg-oai-gray-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-oai-gray-500 dark:text-oai-white dark:hover:bg-oai-gray-800",children:[i?e.jsx(i,{size:16,className:"shrink-0","aria-hidden":!0}):null,e.jsx("span",{className:"min-w-0 flex-1",children:r}),e.jsx(mt,{size:16,className:"shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})]}),e.jsxs(Ja,{children:[e.jsx(Xa,{className:"tt-cloud-action-backdrop fixed inset-0 z-[100] bg-black/40 dark:bg-black/60"}),e.jsx(Qa,{className:"tt-cloud-settings fixed inset-0 z-[101] flex items-center justify-center overflow-y-auto overscroll-contain p-4",children:e.jsxs(es,{initialFocus:l,"aria-modal":"true",className:`tt-cloud-action-popup tt-cloud-theme relative max-h-[calc(100dvh-2rem)] w-full ${c?"max-w-2xl":"max-w-lg"} overflow-y-auto overscroll-contain rounded-xl bg-white p-5 shadow-xl outline-none dark:bg-oai-gray-900`,children:[e.jsxs("div",{className:"mb-3 flex min-h-11 items-center justify-between gap-4",children:[e.jsx(ts,{className:"min-w-0 text-lg font-semibold text-oai-black dark:text-oai-white",children:n}),e.jsx(ls,{disabled:g,"aria-label":a("shared.dialog.close"),className:"inline-flex size-11 min-h-11 min-w-11 shrink-0 items-center justify-center rounded-md border-0 bg-transparent p-0 text-oai-gray-500 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-oai-gray-500 disabled:cursor-wait disabled:opacity-40 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-oai-white",children:e.jsx(Yt,{size:18,"aria-hidden":!0})})]}),e.jsx("div",{"data-settings-panel":"cloud",className:"min-w-0",children:d})]})})]})]})}function he(t){return t.replace(/[\t\n\r\f\v -]/g,"").toUpperCase()}function dn({account:t,auth:s,refresh:n,compact:r=!1,panelContainer:i=null,layout:c="default",dialogOpen:g,onDialogOpenChange:l}){const d=c==="settings-row",[p,h]=o.useState(!1),m=d&&typeof g=="boolean"?g:p,[j,w]=o.useState(""),[x,_]=o.useState(!1),[b,u]=o.useState(null),[y,k]=o.useState(null),[f,N]=o.useState(!1),E=o.useId(),v=o.useRef(null),C=o.useRef(null),O=o.useRef(!1),S=o.useRef(!1),P=o.useRef(0),M=`${Oe()}.${t?.environment||"unknown"}.${s?.signedIn?s.user?.id:""}`,G=o.useRef(M);G.current=M,o.useEffect(()=>(S.current=!0,P.current+=1,C.current=null,O.current=!1,h(!1),w(""),_(!1),u(null),k(null),N(!1),()=>{S.current=!1,P.current+=1}),[M]);const J=t?.membership?.status==="self_hosted"||t?.membership?.hosting_mode==="self_hosted",V=t?.gift_redemption_available===!0,te=d?t?.gifts||[]:[];if(!s?.signedIn||J||!V&&!te.length)return null;const $=t.redemption_restriction,F=T=>{!T&&O.current||(typeof g!="boolean"&&h(T),l?.(T))},K=async(T,ie)=>{const re=await n();ie()&&N(!!re?.gifts?.some(W=>W.id===T?.id))},q=async T=>{if(O.current||T&&(!V||!j.trim()))return;if(T&&$&&$!=="gift_checkout_pending"){u(new Ne($));return}O.current=!0;const ie=++P.current,re=M,W=()=>S.current&&P.current===ie&&G.current===re;_(!0),u(null);try{if(T){const ae=j.trim();(!C.current||he(C.current.code)!==he(ae))&&(C.current={code:ae,request_id:crypto.randomUUID()});const oe=await ce("redeem-gift",{auth:async()=>{const de=await pt(s.getAccessToken);if(!W())throw new Ne("authentication_required",401);return de},body:C.current});if(!W())return;if(!oe?.gift?.id)throw new Ne("billing_operation_failed");k(oe),N(!1),w(""),C.current=null,await K(oe.gift,W)}else await K(y?.gift,W)}catch(ae){W()&&u(ae)}finally{W()&&(O.current=!1,_(!1))}};let L=null;return(d||m)&&(L=e.jsxs("div",{id:`${E}-panel`,className:d?"space-y-3":r?"w-full space-y-3 rounded-lg bg-oai-gray-50 p-4 dark:bg-oai-gray-950/50":"mt-3 space-y-3",children:[V?e.jsxs(e.Fragment,{children:[e.jsx("p",{id:`${E}-detail`,className:d?"sr-only":"text-xs leading-5 text-oai-gray-600 dark:text-oai-gray-300",children:a("cloud.gift.detail")}),y?e.jsxs("div",{role:"status",className:"space-y-2 text-sm leading-6",children:[d&&f?null:e.jsx("p",{children:a(f?y.already_redeemed?"cloud.gift.already_redeemed":"cloud.gift.redeemed":"cloud.gift.refresh_needed")}),y.gift?d&&f?e.jsxs("div",{className:"py-1",children:[e.jsx("p",{className:"text-base font-medium text-oai-black dark:text-oai-white",children:a("cloud.gift.duration",{days:y.gift.duration_days})}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.history.term",{start:H(y.gift.starts_at),end:H(y.gift.ends_at)})})]}):e.jsx("p",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",children:a("cloud.gift.term",{days:y.gift.duration_days,start:H(y.gift.starts_at),end:H(y.gift.ends_at)})}):null,f?e.jsxs("div",{className:"flex flex-wrap justify-end gap-2 pt-3",children:[e.jsx(A,{type:"button",variant:"secondary",size:"sm",onClick:()=>{k(null),N(!1),requestAnimationFrame(()=>v.current?.focus())},children:a("cloud.gift.redeem_another")}),d?e.jsx(A,{type:"button",size:"sm",className:"min-w-20",disabled:x,onClick:()=>F(!1),children:a("cloud.gift.done")}):null]}):e.jsx(A,{type:"button",variant:"secondary",disabled:x,onClick:()=>{q(!1)},children:a("cloud.action.refresh_membership")})]}):e.jsxs("form",{onSubmit:T=>{T.preventDefault(),q(!0)},"aria-busy":x,children:[e.jsx("label",{htmlFor:E,className:d?"sr-only":"text-sm font-medium",children:a("cloud.gift.code_label")}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row",children:[e.jsx("input",{id:E,ref:v,value:j,disabled:x,maxLength:128,autoComplete:"off",spellCheck:!1,autoCapitalize:"characters","data-ph-no-capture":"true","aria-describedby":`${E}-detail${b?` ${E}-error`:""}`,"aria-invalid":!!b,onChange:T=>{he(T.target.value)!==he(j)&&(C.current=null),w(T.target.value),u(null)},className:"min-h-10 min-w-0 flex-1 rounded-md border border-oai-gray-300 bg-transparent px-3 font-mono text-sm outline-none focus:border-oai-brand focus:ring-2 focus:ring-inset focus:ring-oai-brand/30 dark:border-oai-gray-700"}),e.jsx(A,{type:"submit",variant:"secondary",disabled:x||!j.trim(),children:a(x?"cloud.gift.redeeming":"cloud.gift.confirm")})]})]}),b?e.jsx("div",{id:`${E}-error`,children:["gift_checkout_pending","gift_requires_renewal_cancel"].includes(b.code)?e.jsx("p",{role:"alert",className:"text-xs leading-5 text-oai-gray-600 dark:text-oai-gray-300",children:Zt(b,"gift")}):e.jsx(ee,{error:b,context:"gift"})}):null]}):null,te.length&&!y?e.jsx("ul",{"aria-label":a("cloud.gift.history_title"),className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800",children:te.map(T=>e.jsxs("li",{className:"py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[e.jsx("span",{children:a("cloud.gift.duration",{days:T.duration_days})}),e.jsx("span",{children:a(["active","pending","expired","revoked"].includes(T.state)?`cloud.gift.state_${T.state}`:"cloud.status.unknown")})]}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-oai-gray-600 dark:text-oai-gray-300",children:a("cloud.history.term",{start:H(T.starts_at),end:H(T.ends_at)})})]},T.id))}):null]})),d?e.jsx($e,{open:m,onOpenChange:F,title:a(y&&f?"cloud.gift.redeemed":V?"cloud.gift.redeem_action":"cloud.gift.history_title"),triggerLabel:a(V?"cloud.gift.redeem_action":"cloud.gift.history_title"),icon:Te,preventClose:x,initialFocus:V&&!y?v:void 0,children:L}):e.jsxs("div",{className:d?void 0:r?"contents":"mt-4",children:[e.jsxs(A,{type:"button",variant:"ghost",size:r||d?"sm":"md",className:d?"!h-11 !w-full !justify-start !px-0 !text-oai-black dark:!text-oai-white hover:!bg-oai-gray-100 dark:hover:!bg-oai-gray-800 active:!scale-100":r?"!h-10 !px-0":void 0,"aria-expanded":m,"aria-controls":d||m?`${E}-panel`:void 0,onClick:()=>h(T=>!T),disabled:x,children:[r||d?e.jsx(Te,{size:16,className:`${d?"mr-3":"mr-2"} shrink-0`,"aria-hidden":!0}):null,a(V?"cloud.gift.redeem_action":"cloud.gift.history_title"),d?e.jsx(Re,{size:16,className:`ml-auto shrink-0 transition-transform motion-reduce:transition-none ${m?"rotate-180":""}`,"aria-hidden":!0}):null]}),!d&&i&&L?gt.createPortal(L,i):L]})}const be=["total_tokens","billable_total_tokens","input_tokens","output_tokens","cached_input_tokens","cache_creation_input_tokens","reasoning_output_tokens","conversation_count","total_cost_usd"];class U extends Error{constructor(s,n=0){super(s),this.code=s,this.status=n}code;status}function ge(t){return typeof t=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t)&&Number.isFinite(Date.parse(t+"T00:00:00Z"))&&new Date(t+"T00:00:00Z").toISOString().slice(0,10)===t}function un(t,s){if(!ea(t))throw new U("export_auth_required",401);try{const n=t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r=JSON.parse(atob(n.padEnd(Math.ceil(n.length/4)*4,"=")));if((r.sub||r.user_id)!==s||r.role!=="authenticated"||!Number.isFinite(r.exp)||r.exp*1e3<=Date.now())throw Error()}catch{throw new U("export_auth_required",401)}}function it(t){if(typeof t?.membership?.can_read_cloud!="boolean")throw new U("export_invalid_data",503);if(!t.membership.can_read_cloud)throw new U("export_access_denied",402);const s=t.membership;return JSON.stringify([t.environment,s.phase,s.status,s.hosting_mode,s.expires_at,s.trial_ends_at,s.transition_ends_at,s.read_only_until])}async function mn({userId:t,auth:s,from:n,to:r,deviceId:i=null,signal:c,assertCurrent:g=()=>{},fetchImpl:l=fetch}){if(!ge(n)||!ge(r)||n>r)throw new U("export_invalid_dates",400);if(typeof s!="function")throw new U("export_auth_required",401);if(!t||i&&!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(i))throw new U("export_invalid_scope",400);const d=Oe(),p=Ve();if(!d)throw new U("export_instance_changed",409);const h=()=>{if(c?.aborted)throw new U("export_cancelled",409);if(g(),d!==Oe()||p!==Ve())throw new U("export_instance_changed",409)};async function m(u,y){h();const k=await pt(s);h(),un(k||"",t);const f=new URL(Xt(d,u));for(const[C,O]of Object.entries(y))f.searchParams.set(C,O);const N=new AbortController,E=()=>N.abort();c?.addEventListener("abort",E,{once:!0});const v=setTimeout(E,25e3);try{const C=await Qt(f.toString(),{method:"GET",cache:"no-store",redirect:"error",signal:N.signal,headers:{Accept:"application/json",Authorization:"Bearer "+k,...p?{apikey:p}:{}}},l);if(h(),!C.ok)throw new U(C.status===401?"export_auth_required":C.status===402||C.status===403?"export_access_denied":"export_failed",C.status);const O=await C.json();return h(),O}finally{clearTimeout(v),c?.removeEventListener("abort",E)}}const j=it(await m("tokentracker-billing",{action:"account"})),w={from:n,to:r,tz_offset_minutes:"0",...i?{device_id:i}:{}};if(await m("tokentracker-account-daily",w),it(await m("tokentracker-billing",{action:"account"}))!==j)throw new U("export_access_changed",409);const x=await m("tokentracker-account-daily",w);if(!ge(x?.from)||!ge(x?.to)||x.from<n||x.to>r||x.from>x.to||!Array.isArray(x.data)||x.data.length>1096)throw new U("export_invalid_data",503);const _=new Set,b=x.data.map(u=>{if(!ge(u?.day)||u.day<x.from||u.day>x.to||_.has(u.day))throw new U("export_invalid_data",503);_.add(u.day);const y={day:u.day};for(const k of be){const f=u[k];if(typeof f!="number"||!Number.isFinite(f)||f<0||k!=="total_cost_usd"&&!Number.isSafeInteger(f))throw new U("export_invalid_data",503);y[k==="total_cost_usd"?"estimated_cost_usd":k]=f}return y}).sort((u,y)=>u.day.localeCompare(y.day));return h(),{schema:"tokentracker.cloud-usage.v1",metadata:{source:"cloud",backend_origin:new URL(d).origin,exported_at:new Date().toISOString(),timezone:"UTC",requested_range:{from:n,to:r},effective_range:{from:x.from,to:x.to},device_scope:i?"selected":"all",aggregation:"daily_all_providers",cost_currency:"USD",cost_basis:"estimated",row_count:b.length},rows:b}}function gn(t){const s=String(t??"");return'"'+(/^[\s]*[=+\-@]/.test(s)?"'"+s:s).replace(/"/g,'""')+'"'}function pn(t,s){if(s==="json")return JSON.stringify(t,null,2)+`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-CPskAZuH.js","assets/__vite-browser-external-kAUz3kFs.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as ne,by as Dt,bm as Ut,r as o,M as zt,K as Gt,bz as Mt,j as e,c as a,y as le,a as lt,cK as $t,cL as Ft,cM as Bt,cN as Ht,a7 as me,cO as Be,bi as Vt,cP as qt,bh as He,cQ as we,aP as ct,cR as Kt,cS as Wt,ag as dt,u as ut,B as A,V as Pe,aM as mt,X as Yt,x as Oe,a8 as H,cT as Zt,a9 as ee,ar as gt,cU as Ne,a5 as ce,aB as pt,ai as Ve,cV as Jt,ak as Xt,aj as Qt,ah as ea,cW as qe,cX as ta,a1 as aa,af as sa,au as fe,av as Ae,cY as na,R as De,L as ye,al as ia,am as Ue,ac as ra,d as ht,aa as Le,ab as ft,cZ as Ke,c_ as We,c$ as Ye,d0 as oa,d1 as la,ao as ca,Z as xt,l as Se,d2 as Ze,k as Je,d3 as da,d4 as ua,d5 as ma,z as ga,d6 as pa,d7 as ha,d8 as fa,d9 as xa,da as ba,db as ya,dc as va,v as bt,cn as ja,dd as ka,bj as Xe,_ as _a,e as wa,de as Na,df as Sa,bl as Ca}from"./__vite-browser-external-CPskAZuH.js";import{a as Ea,b as Qe,s as Pa,K as Oa,P as Aa,D as La,c as Ta,S as Ra,v as Ia,u as Da,C as Ua}from"./sortable.esm-CmJnBLcr.js";import{a as za}from"./modifiers.esm-Cra0I6RP.js";import{d as et,l as tt,u as Ga,b as at}from"./use-limits-display-prefs-mDl6Yv_-.js";import{P as Ma}from"./ProviderIcon-BuLwtYjj.js";import{a as R,S as se,T as z,b as Z,c as ve}from"./Controls-C2mEPI72.js";import{m as yt}from"./react-CTLavVze.js";import{P as $a,u as Fa,a as Ba}from"./use-session-efficiency-pref-B2GDf83h.js";import{C as Ha}from"./check-CzJylQ9j.js";import{C as Va,i as qa}from"./host-mode-o3qQY7tz.js";import{A as vt}from"./index-Byukv2Nu.js";import{r as Ka,C as Ce,o as Wa}from"./cloud-checkout-DP5zddOq.js";import{u as Ya,D as Za,a as Ja,b as Xa,c as Qa,d as es,e as ts}from"./DialogTitle-BBxNf3O8.js";import{u as as,p as ss,t as ns}from"./composite-I_1t6PMI.js";import{k as is,l as rs}from"./SelectItemText-CZKyxUjE.js";import{u as os}from"./safePolygon-Yw5w5Nw8.js";import{D as ls}from"./DialogClose-D1dzj_on.js";import{G as Te}from"./gift-BxbKo3W6.js";import{C as Re}from"./chevron-down-DyG9JVDO.js";import{D as cs}from"./DateRangePopover-Gz-N_D7O.js";import{C as ds}from"./calendar-days-Cc8AtMa3.js";import{D as Ie}from"./download-B_LvkErh.js";import{P as us,a as ms,b as gs,c as ps,d as hs}from"./PopoverPopup-BlzqlKqF.js";import{C as st}from"./Card-Dk6s3h-P.js";import{E as nt}from"./external-link-DDA3ObBn.js";import{a as fs,P as xs}from"./play-NqPqbW59.js";import{I as jt}from"./info-BoTz1AGZ.js";import{a as bs,b as ys,c as vs,d as js,e as ks}from"./TooltipPopup-BF56BHfc.js";import{L as xe}from"./loader-circle--9U0axVe.js";import{u as _s}from"./useCurrency-CdDQzroJ.js";import{u as ws}from"./useTokenFormat-90RoMQgI.js";import{S as ze}from"./Select-0YyBw95W.js";import{u as je}from"./use-native-settings-Bu2C3b20.js";import{C as Ns}from"./ConfirmModal-BrxBQn4n.js";import{A as Ss}from"./arrow-up-right-CGSxdyzM.js";import"./store-DzNIKGzf.js";import"./usePositioner-b6XXJtxE.js";import"./DialogDescription-ChbOGLc_.js";const kt={name:"credit-card",size:24,node:[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}],["path",{d:"M6 14h2",key:"mk7k0u"}]]};kt.node;const Cs=ne(kt);const _t={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"}]]};_t.node;const Es=ne(_t);const wt={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"}]]};wt.node;const Ps=ne(wt);const Nt={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"}]]};Nt.node;const Os=ne(Nt);const St={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"}]]};St.node;const As=ne(St);const Ct={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"}]]};Ct.node;const Ls=ne(Ct);const Et={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"]};Et.node;const Ts=ne(Et),Rs=Dt(function(s,n){const{render:r,className:i,style:c,disabled:g=!1,nativeButton:l=!0,id:d,payload:p,handle:h,...m}=s,j=Ya(!0),x=os(h)??j;if(!x)throw new Error(Ut(79));const _=as(d),b=x.useState("floatingRootContext"),u=x.useState("isOpenedByTrigger",_),y=x.useState("triggerPopupId",_),k=o.useRef(null),{registerTrigger:f,isMountedByThisTrigger:N}=ss(_,k,x,{payload:p}),{getButtonProps:E,buttonRef:v}=zt({disabled:g,native:l}),C=is(b),O=rs(()=>x.select("open"),M=>{x.set("openMethod",M)}),S={disabled:g,open:u},P=x.useState("triggerProps",N);return Gt("button",s,{state:S,ref:[v,n,f,k],props:[C.reference,P,O,{[Mt]:"",id:_,"aria-haspopup":"dialog","aria-expanded":u,"aria-controls":y},m,E],stateAttributesMapping:ns})}),Is="shrink-0 text-oai-gray-900 dark:text-oai-gray-200";function Ds({id:t,visible:s,onToggle:n}){const{attributes:r,listeners:i,setNodeRef:c,transform:g,transition:l,isDragging:d}=Da({id:t}),p={transform:Ua.Transform.toString(g)||void 0,transition:l,zIndex:d?20:void 0};return e.jsxs("div",{ref:c,style:p,className:le("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"),...r,...i,children:[e.jsx(Ps,{className:"h-4 w-4 shrink-0 text-oai-gray-400 dark:text-oai-gray-500",strokeWidth:1.75,"aria-hidden":!0}),et(t)?e.jsx(Ma,{provider:et(t),size:18,className:le("pointer-events-none",Is)}):null,e.jsx("span",{className:"flex-1 text-sm text-oai-gray-900 dark:text-oai-gray-200",children:tt(t)}),e.jsx("div",{onPointerDown:h=>h.stopPropagation(),children:e.jsx(z,{checked:s,onChange:n,ariaLabel:`${a("limits.settings.toggle_visible")}: ${tt(t)}`})})]})}function Us({prefs:t}){const{order:s,visibility:n,toggle:r,setAllVisible:i,moveToward:c}=t,g=s.every(m=>n[m]!==!1),l=s.every(m=>n[m]===!1),d=s.filter(m=>n[m]!==!1).length,p=Ea(Qe(Aa,{activationConstraint:{distance:6}}),Qe(Oa,{coordinateGetter:Pa})),h=({active:m,over:j})=>{j&&m.id!==j.id&&c(m.id,j.id)};return e.jsxs(e.Fragment,{children:[e.jsx(R,{label:a("limits.settings.bulk_visibility"),hint:a("limits.settings.enabled_count",{enabled:d,total:s.length}),control:e.jsx(se,{options:[{value:"enabled",label:a("limits.settings.enable_all")},{value:"disabled",label:a("limits.settings.disable_all")}],value:g?"enabled":l?"disabled":null,onChange:m=>i(m==="enabled")})}),e.jsx(La,{sensors:p,collisionDetection:Ta,modifiers:[za],onDragEnd:h,children:e.jsx(Ra,{items:s,strategy:Ia,children:e.jsx("div",{className:"flex flex-col",children:s.map(m=>e.jsx(Ds,{id:m,visible:n[m]!==!1,onToggle:()=>r(m)},m))})})})]})}function zs(t){if(!t||typeof t!="object")return"";const s=t.user_metadata&&typeof t.user_metadata=="object"?t.user_metadata:{},n=t.profile&&typeof t.profile=="object"?t.profile:{},r=s.full_name||s.name||n.name||s.user_name||s.preferred_username;return typeof r=="string"&&r.trim()?r.trim():typeof t.email=="string"&&t.email.includes("@")?t.email.split("@")[0].trim()||t.email.trim():typeof t.email=="string"?t.email.trim():""}function Gs(t){return!t||typeof t!="object"?"":typeof t.email=="string"?t.email.trim():""}function Ms(t){const s=typeof t=="string"?t.trim():"";if(!s)return null;const n=s.match(/^@?([A-Za-z0-9][A-Za-z0-9-]{0,38})$/),r=s.match(/^https:\/\/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})\/?$/i),i=n?.[1]||r?.[1];return i?`https://github.com/${i}`:null}function Ge(t,s){console.warn(`[tokentracker] settings ${t}:`,s)}function $s(t,s,n,r){const[i,c]=o.useState(()=>me()),g=s&&n&&dt(),l=o.useMemo(()=>({active:!0,busy:!1}),[t,s,n,r]),d=o.useRef(l);d.current=l;const[p,h]=o.useState(null),m=p?.scope===l?p:null;o.useEffect(()=>{l.active=!0;const _=()=>{const u=me();c(u),u||h(y=>y?.scope===l?{...y,error:null}:y)},b=()=>{h(u=>u?.scope===l?{...u,error:null}:u),we(r,"cloud-sync")};return _(),window.addEventListener("tt.cloudSyncChanged",_),window.addEventListener("storage",_),window.addEventListener(Be,b),()=>{l.active=!1,window.removeEventListener("tt.cloudSyncChanged",_),window.removeEventListener("storage",_),window.removeEventListener(Be,b)}},[l,r]);const j=o.useCallback(async()=>{if(!g||!me()||l.busy||!l.active||d.current!==l)return;l.busy=!0,h({scope:l,pending:!0,error:null});const _=()=>l.active&&d.current===l&&me();try{await Vt(()=>t())}catch(b){if(!_())return;["cloud_membership_required","cloud_read_only_expired","cloud_history_window_exceeded","cloud_machine_limit","machine_limit_exceeded","cloud_machine_paused"].includes(b?.code)?qt(r,b.code,b.membership,"cloud-sync"):h({scope:l,pending:!0,error:{code:"billing_network_error"}}),Ge("cloud sync",b)}finally{l.busy=!1,l.active&&d.current===l&&h(b=>b?.scope===l?{...b,pending:!1}:b)}},[g,l,t,r]),w=o.useCallback(async()=>{if(!g||l.busy||!l.active||d.current!==l)return;const _=!me();h({scope:l,pending:!1,error:null}),He(_),c(_),_?await j():we(r,"cloud-sync")},[g,l,j,r]),x=o.useCallback(()=>{!g||!l.active||d.current!==l||(He(!1),c(!1),h(_=>_?.scope===l?{..._,error:null}:_),we(r,"cloud-sync"))},[g,l,r]);return{cloudSyncOn:i,cloudSyncPending:!!m?.pending,cloudSyncError:m?.error,handleCloudSyncToggle:w,handleCloudSyncRetry:j,handleCloudSyncDisable:x,showLocalCloudSync:g}}function Fs(t){const[s,n]=o.useState(!1),[r,i]=o.useState(!1),[c,g]=o.useState(!1),[l,d]=o.useState(!1),[p,h]=o.useState(null),[m,j]=o.useState(!1),[w,x]=o.useState(""),[_,b]=o.useState(!1),[u,y]=o.useState(""),[k,f]=o.useState(""),[N,E]=o.useState(!1),[v,C]=o.useState(null),O=o.useMemo(()=>zs(t),[t]),S=o.useMemo(()=>Gs(t),[t]),P=o.useMemo(()=>typeof t?.id=="string"?t.id.trim():"",[t]),M=o.useMemo(()=>({setAnonymousOn:i,setCustomDisplayName:h,setGithubUrl:y,setProfileLoading:g,setPublicProfileOn:n,setShowGithubOn:b}),[]);return{anonymousOn:r,customDisplayName:p,displayName:O,editingGithub:N,editingName:m,email:S,githubError:v,githubInput:k,githubUrl:u,loadSetters:M,nameInput:w,profileLoading:c,profileSaving:l,publicProfileOn:s,setAnonymousOn:i,setCustomDisplayName:h,setEditingGithub:E,setEditingName:j,setGithubError:C,setGithubInput:f,setGithubUrl:y,setNameInput:x,setProfileLoading:g,setProfileSaving:d,setPublicProfileOn:n,setShowGithubOn:b,showGithubOn:_,userId:P}}function Bs(t,s,n){o.useEffect(()=>{if(!s)return;let r=!0;return n.setProfileLoading(!0),(async()=>{try{const i=await ct({getAccessToken:t});if(!r||!i)return;const c=await Kt({accessToken:i});if(!r)return;n.setPublicProfileOn(!!c?.enabled),n.setAnonymousOn(!!c?.anonymous),c?.display_name&&n.setCustomDisplayName(c.display_name),n.setShowGithubOn(!!c?.show_github_url),n.setGithubUrl(c?.github_url||"")}catch(i){Ge("load public profile",i)}finally{r&&n.setProfileLoading(!1)}})(),()=>{r=!1}},[t,s,n])}function Hs(t,s,n){return o.useCallback(async(r,{label:i,onError:c,onSuccess:g}={})=>{if(!n||s.profileSaving)return!1;s.setProfileSaving(!0);try{const l=await ct({getAccessToken:t});if(!l)return!1;const d=await Wt({accessToken:l,...r});return g?.(d),!0}catch(l){return c?c(l):Ge(i||"mutate profile",l),!1}finally{s.setProfileSaving(!1)}},[t,s,n])}function Vs(t,s){return{anonymousOn:t.anonymousOn,customDisplayName:t.customDisplayName,displayName:t.displayName,editingName:t.editingName,handleAnonymousToggle:s.handleAnonymousToggle,handleSaveName:s.handleSaveName,nameInput:t.nameInput,profileLoading:t.profileLoading,profileSaving:t.profileSaving,setEditingName:t.setEditingName,setNameInput:t.setNameInput,startEditingName:s.startEditingName}}function qs(t,s){return{editingGithub:t.editingGithub,githubError:t.githubError,githubInput:t.githubInput,githubUrl:t.githubUrl,handleSaveGithub:s.handleSaveGithub,handleShowGithubToggle:s.handleShowGithubToggle,profileLoading:t.profileLoading,profileSaving:t.profileSaving,setEditingGithub:t.setEditingGithub,setGithubError:t.setGithubError,setGithubInput:t.setGithubInput,showGithubOn:t.showGithubOn,startEditingGithub:s.startEditingGithub}}function Ks(t,s){const n=o.useCallback(async()=>{const i=!t.publicProfileOn;await s({enabled:i},{label:"toggle public profile",onSuccess:()=>t.setPublicProfileOn(i)})},[s,t]);return{handleAnonymousToggle:o.useCallback(async()=>{const i=!t.anonymousOn;await s({anonymous:i},{label:"toggle anonymous",onSuccess:()=>t.setAnonymousOn(i)})},[s,t]),handlePublicProfileToggle:n}}function Ws(t,s,n){const r=o.useCallback(async()=>{const c=t.nameInput.trim().slice(0,50);c&&await s({display_name:c},{label:"save display name",onSuccess:()=>{t.setCustomDisplayName(c),t.setEditingName(!1),n?.()}})},[s,t,n]),i=o.useCallback(()=>{t.setNameInput(t.customDisplayName||t.displayName),t.setEditingName(!0)},[t]);return{handleSaveName:r,startEditingName:i}}function Ys(t,s){const n=o.useCallback(async()=>{if(!t.showGithubOn&&!t.githubUrl){t.setEditingGithub(!0),t.setGithubInput(""),t.setGithubError(null);return}const c=!t.showGithubOn;await s({show_github_url:c},{label:"toggle GitHub profile",onSuccess:()=>t.setShowGithubOn(c)})},[s,t]),r=o.useCallback(async()=>{const c=Ms(t.githubInput);if(t.githubInput.trim()&&!c){t.setGithubError(a("settings.account.githubUrlInvalid"));return}t.setGithubError(null),await s({github_url:c,show_github_url:!!c},{label:"save GitHub profile",onError:g=>t.setGithubError(g?.message||a("settings.account.githubUrlInvalid")),onSuccess:g=>{t.setGithubUrl(g?.github_url||c||""),t.setShowGithubOn(!!c),t.setEditingGithub(!1)}})},[s,t]),i=o.useCallback(()=>{t.setGithubInput(t.githubUrl),t.setGithubError(null),t.setEditingGithub(!0)},[t]);return{handleSaveGithub:r,handleShowGithubToggle:n,startEditingGithub:i}}function Me(){const t=lt();o.useSyncExternalStore($t,Ft,()=>0);const s=Bt(t.user?.id),r=!(s.membership?.status==="self_hosted"||s.catalog?.policy?.hosting_mode==="self_hosted")&&(Ht()||s.membership?.hosting_mode==="hosted"),i=Fs(t.user),c=$s(t.getAccessToken,t.enabled,t.signedIn,t.user?.id);Bs(t.getAccessToken,t.signedIn&&r,i.loadSetters);const g=Hs(t.getAccessToken,i,r),l=Ks(i,g),d=Ws(i,g,t.refreshDisplayName),p=Ys(i,g);return{...t,...c,email:i.email,handlePublicProfileToggle:l.handlePublicProfileToggle,userId:i.userId,name:Vs(i,{...l,...d}),github:qs(i,p),profileLoading:i.profileLoading,profileSaving:i.profileSaving,publicProfileOn:r&&i.publicProfileOn,publicProfileAvailable:r}}function Pt({disabled:t,onCancel:s,onSave:n,saveLabel:r=a("settings.account.save")}){return e.jsxs(e.Fragment,{children:[e.jsx(A,{variant:"primary",size:"sm",onClick:n,disabled:t,children:r}),e.jsx(A,{variant:"ghost",size:"sm",onClick:s,className:"text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:a("settings.account.cancel")})]})}function Zs({nameInput:t,setEditingName:s,setNameInput:n,profileSaving:r,handleSaveName:i}){return e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:c=>n(c.target.value),onKeyDown:c=>{c.key==="Enter"&&i(),c.key==="Escape"&&s(!1)},maxLength:50,autoFocus:!0,className:`flex-1 ${ve}`,placeholder:a("settings.account.displayName")}),e.jsx(Pt,{disabled:r||!t.trim(),onCancel:()=>s(!1),onSave:i,saveLabel:r?a("settings.account.saving"):void 0})]})}function Js({githubError:t,githubInput:s,handleSaveGithub:n,profileSaving:r,setEditingGithub:i,setGithubError:c,setGithubInput:g}){return e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:s,onChange:l=>{g(l.target.value),t&&c(null)},onKeyDown:l=>{l.key==="Enter"&&n(),l.key==="Escape"&&(i(!1),c(null))},maxLength:100,autoFocus:!0,className:`flex-1 ${ve}`,placeholder:a("settings.account.githubUrlPlaceholder")}),e.jsx(Pt,{disabled:r,onCancel:()=>{i(!1),c(null)},onSave:n,saveLabel:r?a("settings.account.saving"):void 0})]}),t?e.jsx("div",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:t}):null]})}function Ot({disabled:t=!1,label:s,onClick:n,title:r}){return e.jsxs(A,{variant:"secondary",size:"sm",onClick:n,disabled:t,title:r,className:"gap-1.5",children:[e.jsx($a,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{children:s})]})}function At({actions:t,editing:s,editor:n,hint:r,label:i}){return 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:i}),s?n:e.jsx("div",{className:"mt-0.5 truncate text-xs text-oai-gray-500 dark:text-oai-gray-400",children:r})]}),s?null:t]})})}function Xs({name:t}){const s=t.anonymousOn?a("settings.account.displayNameDisabledWhileAnon"):void 0;return e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(Ot,{disabled:t.anonymousOn,label:a("settings.account.edit"),onClick:t.startEditingName,title:s}),e.jsx(z,{checked:!t.anonymousOn,onChange:t.handleAnonymousToggle,disabled:t.profileLoading||t.profileSaving,ariaLabel:a("settings.account.displayName")})]})}function Qs({name:t}){const{anonymousOn:s,customDisplayName:n,displayName:r,editingName:i,handleAnonymousToggle:c,handleSaveName:g,nameInput:l,profileLoading:d,profileSaving:p,setEditingName:h,setNameInput:m,startEditingName:j}=t,w=s?a("settings.account.displayNameAnonymousHint"):n||r;return e.jsx(At,{label:a("settings.account.displayName"),editing:i,hint:w,editor:e.jsx(Zs,{nameInput:l,setEditingName:h,setNameInput:m,profileSaving:p,handleSaveName:g}),actions:e.jsx(Xs,{name:t})})}function en({github:t}){const{editingGithub:s,githubError:n,githubInput:r,githubUrl:i,handleSaveGithub:c,handleShowGithubToggle:g,profileLoading:l,profileSaving:d,setEditingGithub:p,setGithubError:h,setGithubInput:m,showGithubOn:j,startEditingGithub:w}=t;return e.jsx(e.Fragment,{children:e.jsx(At,{label:a("settings.account.githubUrl"),editing:s,hint:i||a("settings.account.githubUrlHint"),editor:e.jsx(Js,{githubError:n,githubInput:r,handleSaveGithub:c,profileSaving:d,setEditingGithub:p,setGithubError:h,setGithubInput:m}),actions:e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(Ot,{label:a("settings.account.edit"),onClick:w}),e.jsx(z,{checked:j,onChange:g,disabled:l||d,ariaLabel:a("settings.account.githubUrl")})]})})})}function tn(){const{openLoginModal:t}=ut();return e.jsx(Z,{title:a("settings.section.account"),children:e.jsxs("div",{className:"flex flex-col gap-3 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("settings.account.signedOutHint")}),e.jsx(A,{variant:"primary",size:"sm",onClick:t,children:a("settings.account.signIn")})]})})}function an({name:t,github:s}){return e.jsxs(e.Fragment,{children:[e.jsx(Qs,{name:t}),e.jsx(en,{github:s})]})}function sn({settings:t}={}){return t?e.jsx(Lt,{settings:t}):e.jsx(nn,{})}function nn(){const t=Me();return e.jsx(Lt,{settings:t})}function Lt({settings:t}){return t.enabled?t.signedIn?e.jsxs(Z,{title:a("settings.section.account"),subtitle:t.email||t.name.customDisplayName||t.name.displayName,action:e.jsx(on,{onSignOut:t.signOut}),children:[e.jsx(rn,{userId:t.userId}),e.jsx(ln,{checked:t.publicProfileOn,disabled:t.profileLoading||t.profileSaving||t.publicProfileAvailable===!1,onChange:t.handlePublicProfileToggle,unavailable:t.publicProfileAvailable===!1}),e.jsx(cn,{visible:t.publicProfileOn,name:t.name,github:t.github})]}):e.jsx(tn,{}):null}function rn({userId:t}){const[s,n]=Pe.useState(!1);if(!t)return null;const r=async()=>{try{if(typeof navigator>"u"||!navigator.clipboard?.writeText)return;await navigator.clipboard.writeText(t),n(!0),globalThis.setTimeout(()=>n(!1),1200)}catch{n(!1)}};return e.jsx(R,{label:a("settings.account.userId"),hint:e.jsx("span",{className:"font-mono",children:t}),control:e.jsxs(A,{variant:"secondary",size:"sm",onClick:r,"aria-label":a("settings.account.copyUserId"),className:"gap-1.5",children:[s?e.jsx(Ha,{className:"h-3.5 w-3.5","aria-hidden":!0}):e.jsx(Va,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{children:s?a("settings.account.copied"):a("settings.account.copy")})]})})}function on({onSignOut:t}){return e.jsxs(A,{variant:"ghost",size:"sm",onClick:()=>t(),className:"!h-7 !px-2 text-xs text-oai-gray-500 hover:text-oai-gray-700 dark:hover:text-oai-gray-300",children:[e.jsx(As,{className:"h-3.5 w-3.5 mr-1.5","aria-hidden":!0}),e.jsx("span",{children:a("settings.account.signOut")})]})}function ln({checked:t,disabled:s,onChange:n,unavailable:r}){return e.jsx(R,{label:a("settings.account.publicProfile"),hint:a(r?"cloud.self_host.public_profile_disabled":"settings.account.publicProfileHint"),control:e.jsx(z,{checked:t,onChange:n,disabled:s,ariaLabel:a("settings.account.publicProfile")})})}function cn({visible:t,name:s,github:n}){return e.jsx(vt,{initial:!1,children:t?e.jsx(yt.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(an,{name:s,github:n})},"public-profile-fields"):null})}function $e({open:t,onOpenChange:s,title:n,triggerLabel:r=n,icon:i,wide:c=!1,preventClose:g=!1,initialFocus:l,children:d}){return e.jsxs(Za,{open:t,onOpenChange:(p,h)=>{if(!p&&g){h.cancel();return}s(p)},children:[e.jsxs(Rs,{className:"inline-flex h-11 w-full items-center gap-3 rounded-md border-0 bg-transparent p-0 text-left text-sm font-medium text-oai-black transition-colors hover:bg-oai-gray-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-oai-gray-500 dark:text-oai-white dark:hover:bg-oai-gray-800",children:[i?e.jsx(i,{size:16,className:"shrink-0","aria-hidden":!0}):null,e.jsx("span",{className:"min-w-0 flex-1",children:r}),e.jsx(mt,{size:16,className:"shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})]}),e.jsxs(Ja,{children:[e.jsx(Xa,{className:"tt-cloud-action-backdrop fixed inset-0 z-[100] bg-black/40 dark:bg-black/60"}),e.jsx(Qa,{className:"tt-cloud-settings fixed inset-0 z-[101] flex items-center justify-center overflow-y-auto overscroll-contain p-4",children:e.jsxs(es,{initialFocus:l,"aria-modal":"true",className:`tt-cloud-action-popup tt-cloud-theme relative max-h-[calc(100dvh-2rem)] w-full ${c?"max-w-2xl":"max-w-lg"} overflow-y-auto overscroll-contain rounded-xl bg-white p-5 shadow-xl outline-none dark:bg-oai-gray-900`,children:[e.jsxs("div",{className:"mb-3 flex min-h-11 items-center justify-between gap-4",children:[e.jsx(ts,{className:"min-w-0 text-lg font-semibold text-oai-black dark:text-oai-white",children:n}),e.jsx(ls,{disabled:g,"aria-label":a("shared.dialog.close"),className:"inline-flex size-11 min-h-11 min-w-11 shrink-0 items-center justify-center rounded-md border-0 bg-transparent p-0 text-oai-gray-500 transition-colors hover:bg-oai-gray-100 hover:text-oai-black focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-oai-gray-500 disabled:cursor-wait disabled:opacity-40 dark:text-oai-gray-400 dark:hover:bg-oai-gray-800 dark:hover:text-oai-white",children:e.jsx(Yt,{size:18,"aria-hidden":!0})})]}),e.jsx("div",{"data-settings-panel":"cloud",className:"min-w-0",children:d})]})})]})]})}function he(t){return t.replace(/[\t\n\r\f\v -]/g,"").toUpperCase()}function dn({account:t,auth:s,refresh:n,compact:r=!1,panelContainer:i=null,layout:c="default",dialogOpen:g,onDialogOpenChange:l}){const d=c==="settings-row",[p,h]=o.useState(!1),m=d&&typeof g=="boolean"?g:p,[j,w]=o.useState(""),[x,_]=o.useState(!1),[b,u]=o.useState(null),[y,k]=o.useState(null),[f,N]=o.useState(!1),E=o.useId(),v=o.useRef(null),C=o.useRef(null),O=o.useRef(!1),S=o.useRef(!1),P=o.useRef(0),M=`${Oe()}.${t?.environment||"unknown"}.${s?.signedIn?s.user?.id:""}`,G=o.useRef(M);G.current=M,o.useEffect(()=>(S.current=!0,P.current+=1,C.current=null,O.current=!1,h(!1),w(""),_(!1),u(null),k(null),N(!1),()=>{S.current=!1,P.current+=1}),[M]);const J=t?.membership?.status==="self_hosted"||t?.membership?.hosting_mode==="self_hosted",V=t?.gift_redemption_available===!0,te=d?t?.gifts||[]:[];if(!s?.signedIn||J||!V&&!te.length)return null;const $=t.redemption_restriction,F=T=>{!T&&O.current||(typeof g!="boolean"&&h(T),l?.(T))},K=async(T,ie)=>{const re=await n();ie()&&N(!!re?.gifts?.some(W=>W.id===T?.id))},q=async T=>{if(O.current||T&&(!V||!j.trim()))return;if(T&&$&&$!=="gift_checkout_pending"){u(new Ne($));return}O.current=!0;const ie=++P.current,re=M,W=()=>S.current&&P.current===ie&&G.current===re;_(!0),u(null);try{if(T){const ae=j.trim();(!C.current||he(C.current.code)!==he(ae))&&(C.current={code:ae,request_id:crypto.randomUUID()});const oe=await ce("redeem-gift",{auth:async()=>{const de=await pt(s.getAccessToken);if(!W())throw new Ne("authentication_required",401);return de},body:C.current});if(!W())return;if(!oe?.gift?.id)throw new Ne("billing_operation_failed");k(oe),N(!1),w(""),C.current=null,await K(oe.gift,W)}else await K(y?.gift,W)}catch(ae){W()&&u(ae)}finally{W()&&(O.current=!1,_(!1))}};let L=null;return(d||m)&&(L=e.jsxs("div",{id:`${E}-panel`,className:d?"space-y-3":r?"w-full space-y-3 rounded-lg bg-oai-gray-50 p-4 dark:bg-oai-gray-950/50":"mt-3 space-y-3",children:[V?e.jsxs(e.Fragment,{children:[e.jsx("p",{id:`${E}-detail`,className:d?"sr-only":"text-xs leading-5 text-oai-gray-600 dark:text-oai-gray-300",children:a("cloud.gift.detail")}),y?e.jsxs("div",{role:"status",className:"space-y-2 text-sm leading-6",children:[d&&f?null:e.jsx("p",{children:a(f?y.already_redeemed?"cloud.gift.already_redeemed":"cloud.gift.redeemed":"cloud.gift.refresh_needed")}),y.gift?d&&f?e.jsxs("div",{className:"py-1",children:[e.jsx("p",{className:"text-base font-medium text-oai-black dark:text-oai-white",children:a("cloud.gift.duration",{days:y.gift.duration_days})}),e.jsx("p",{className:"mt-1 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.history.term",{start:H(y.gift.starts_at),end:H(y.gift.ends_at)})})]}):e.jsx("p",{className:"text-xs text-oai-gray-600 dark:text-oai-gray-300",children:a("cloud.gift.term",{days:y.gift.duration_days,start:H(y.gift.starts_at),end:H(y.gift.ends_at)})}):null,f?e.jsxs("div",{className:"flex flex-wrap justify-end gap-2 pt-3",children:[e.jsx(A,{type:"button",variant:"secondary",size:"sm",onClick:()=>{k(null),N(!1),requestAnimationFrame(()=>v.current?.focus())},children:a("cloud.gift.redeem_another")}),d?e.jsx(A,{type:"button",size:"sm",className:"min-w-20",disabled:x,onClick:()=>F(!1),children:a("cloud.gift.done")}):null]}):e.jsx(A,{type:"button",variant:"secondary",disabled:x,onClick:()=>{q(!1)},children:a("cloud.action.refresh_membership")})]}):e.jsxs("form",{onSubmit:T=>{T.preventDefault(),q(!0)},"aria-busy":x,children:[e.jsx("label",{htmlFor:E,className:d?"sr-only":"text-sm font-medium",children:a("cloud.gift.code_label")}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row",children:[e.jsx("input",{id:E,ref:v,value:j,disabled:x,maxLength:128,autoComplete:"off",spellCheck:!1,autoCapitalize:"characters","data-ph-no-capture":"true","aria-describedby":`${E}-detail${b?` ${E}-error`:""}`,"aria-invalid":!!b,onChange:T=>{he(T.target.value)!==he(j)&&(C.current=null),w(T.target.value),u(null)},className:"min-h-10 min-w-0 flex-1 rounded-md border border-oai-gray-300 bg-transparent px-3 font-mono text-sm outline-none focus:border-oai-brand focus:ring-2 focus:ring-inset focus:ring-oai-brand/30 dark:border-oai-gray-700"}),e.jsx(A,{type:"submit",variant:"secondary",disabled:x||!j.trim(),children:a(x?"cloud.gift.redeeming":"cloud.gift.confirm")})]})]}),b?e.jsx("div",{id:`${E}-error`,children:["gift_checkout_pending","gift_requires_renewal_cancel"].includes(b.code)?e.jsx("p",{role:"alert",className:"text-xs leading-5 text-oai-gray-600 dark:text-oai-gray-300",children:Zt(b,"gift")}):e.jsx(ee,{error:b,context:"gift"})}):null]}):null,te.length&&!y?e.jsx("ul",{"aria-label":a("cloud.gift.history_title"),className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800",children:te.map(T=>e.jsxs("li",{className:"py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[e.jsx("span",{children:a("cloud.gift.duration",{days:T.duration_days})}),e.jsx("span",{children:a(["active","pending","expired","revoked"].includes(T.state)?`cloud.gift.state_${T.state}`:"cloud.status.unknown")})]}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-oai-gray-600 dark:text-oai-gray-300",children:a("cloud.history.term",{start:H(T.starts_at),end:H(T.ends_at)})})]},T.id))}):null]})),d?e.jsx($e,{open:m,onOpenChange:F,title:a(y&&f?"cloud.gift.redeemed":V?"cloud.gift.redeem_action":"cloud.gift.history_title"),triggerLabel:a(V?"cloud.gift.redeem_action":"cloud.gift.history_title"),icon:Te,preventClose:x,initialFocus:V&&!y?v:void 0,children:L}):e.jsxs("div",{className:d?void 0:r?"contents":"mt-4",children:[e.jsxs(A,{type:"button",variant:"ghost",size:r||d?"sm":"md",className:d?"!h-11 !w-full !justify-start !px-0 !text-oai-black dark:!text-oai-white hover:!bg-oai-gray-100 dark:hover:!bg-oai-gray-800 active:!scale-100":r?"!h-10 !px-0":void 0,"aria-expanded":m,"aria-controls":d||m?`${E}-panel`:void 0,onClick:()=>h(T=>!T),disabled:x,children:[r||d?e.jsx(Te,{size:16,className:`${d?"mr-3":"mr-2"} shrink-0`,"aria-hidden":!0}):null,a(V?"cloud.gift.redeem_action":"cloud.gift.history_title"),d?e.jsx(Re,{size:16,className:`ml-auto shrink-0 transition-transform motion-reduce:transition-none ${m?"rotate-180":""}`,"aria-hidden":!0}):null]}),!d&&i&&L?gt.createPortal(L,i):L]})}const be=["total_tokens","billable_total_tokens","input_tokens","output_tokens","cached_input_tokens","cache_creation_input_tokens","reasoning_output_tokens","conversation_count","total_cost_usd"];class U extends Error{constructor(s,n=0){super(s),this.code=s,this.status=n}code;status}function ge(t){return typeof t=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(t)&&Number.isFinite(Date.parse(t+"T00:00:00Z"))&&new Date(t+"T00:00:00Z").toISOString().slice(0,10)===t}function un(t,s){if(!ea(t))throw new U("export_auth_required",401);try{const n=t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r=JSON.parse(atob(n.padEnd(Math.ceil(n.length/4)*4,"=")));if((r.sub||r.user_id)!==s||r.role!=="authenticated"||!Number.isFinite(r.exp)||r.exp*1e3<=Date.now())throw Error()}catch{throw new U("export_auth_required",401)}}function it(t){if(typeof t?.membership?.can_read_cloud!="boolean")throw new U("export_invalid_data",503);if(!t.membership.can_read_cloud)throw new U("export_access_denied",402);const s=t.membership;return JSON.stringify([t.environment,s.phase,s.status,s.hosting_mode,s.expires_at,s.trial_ends_at,s.transition_ends_at,s.read_only_until])}async function mn({userId:t,auth:s,from:n,to:r,deviceId:i=null,signal:c,assertCurrent:g=()=>{},fetchImpl:l=fetch}){if(!ge(n)||!ge(r)||n>r)throw new U("export_invalid_dates",400);if(typeof s!="function")throw new U("export_auth_required",401);if(!t||i&&!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(i))throw new U("export_invalid_scope",400);const d=Oe(),p=Ve();if(!d)throw new U("export_instance_changed",409);const h=()=>{if(c?.aborted)throw new U("export_cancelled",409);if(g(),d!==Oe()||p!==Ve())throw new U("export_instance_changed",409)};async function m(u,y){h();const k=await pt(s);h(),un(k||"",t);const f=new URL(Xt(d,u));for(const[C,O]of Object.entries(y))f.searchParams.set(C,O);const N=new AbortController,E=()=>N.abort();c?.addEventListener("abort",E,{once:!0});const v=setTimeout(E,25e3);try{const C=await Qt(f.toString(),{method:"GET",cache:"no-store",redirect:"error",signal:N.signal,headers:{Accept:"application/json",Authorization:"Bearer "+k,...p?{apikey:p}:{}}},l);if(h(),!C.ok)throw new U(C.status===401?"export_auth_required":C.status===402||C.status===403?"export_access_denied":"export_failed",C.status);const O=await C.json();return h(),O}finally{clearTimeout(v),c?.removeEventListener("abort",E)}}const j=it(await m("tokentracker-billing",{action:"account"})),w={from:n,to:r,tz_offset_minutes:"0",...i?{device_id:i}:{}};if(await m("tokentracker-account-daily",w),it(await m("tokentracker-billing",{action:"account"}))!==j)throw new U("export_access_changed",409);const x=await m("tokentracker-account-daily",w);if(!ge(x?.from)||!ge(x?.to)||x.from<n||x.to>r||x.from>x.to||!Array.isArray(x.data)||x.data.length>1096)throw new U("export_invalid_data",503);const _=new Set,b=x.data.map(u=>{if(!ge(u?.day)||u.day<x.from||u.day>x.to||_.has(u.day))throw new U("export_invalid_data",503);_.add(u.day);const y={day:u.day};for(const k of be){const f=u[k];if(typeof f!="number"||!Number.isFinite(f)||f<0||k!=="total_cost_usd"&&!Number.isSafeInteger(f))throw new U("export_invalid_data",503);y[k==="total_cost_usd"?"estimated_cost_usd":k]=f}return y}).sort((u,y)=>u.day.localeCompare(y.day));return h(),{schema:"tokentracker.cloud-usage.v1",metadata:{source:"cloud",backend_origin:new URL(d).origin,exported_at:new Date().toISOString(),timezone:"UTC",requested_range:{from:n,to:r},effective_range:{from:x.from,to:x.to},device_scope:i?"selected":"all",aggregation:"daily_all_providers",cost_currency:"USD",cost_basis:"estimated",row_count:b.length},rows:b}}function gn(t){const s=String(t??"");return'"'+(/^[\s]*[=+\-@]/.test(s)?"'"+s:s).replace(/"/g,'""')+'"'}function pn(t,s){if(s==="json")return JSON.stringify(t,null,2)+`
|
|
3
3
|
`;const n=t.metadata,r=["row_type","source","backend_origin","exported_at","timezone","cost_currency","cost_basis","requested_from","requested_to","effective_from","effective_to","device_scope","aggregation","row_count","day",...be.map(c=>c==="total_cost_usd"?"estimated_cost_usd":c)],i=[n.source,n.backend_origin,n.exported_at,n.timezone,n.cost_currency,n.cost_basis,n.requested_range.from,n.requested_range.to,n.effective_range.from,n.effective_range.to,n.device_scope,n.aggregation,n.row_count];return[r,["metadata",...i,"",...be.map(()=>"")],...t.rows.map(c=>["usage",...i,c.day,...be.map(g=>c[g==="total_cost_usd"?"estimated_cost_usd":g])])].map(c=>c.map(gn).join(",")).join(`\r
|
|
4
4
|
`)+`\r
|
|
5
|
-
`}async function hn(t,s,{signal:n,assertCurrent:r=()=>{}}={}){const i=pn(t,s),c=`tokentracker-cloud-usage-${t.metadata.effective_range.from}-${t.metadata.effective_range.to}.${s}`,g=()=>{if(n?.aborted)throw new U("export_cancelled",409);r()};g();const l=await Jt({filename:c,content:i,format:s,signal:n});if(g(),l?.saved===!0)return;if(l!==null)throw new U("export_failed",503);const d=new Blob([i],{type:s==="csv"?"text/csv;charset=utf-8":"application/json;charset=utf-8"}),p=URL.createObjectURL(d);try{const h=document.createElement("a");h.href=p,h.download=c,document.body.appendChild(h);try{h.click()}finally{h.remove()}}finally{setTimeout(()=>URL.revokeObjectURL(p),1e3)}}function fn(t){return t?.status===401?a("cloud.export.error_auth"):t?.status===402||t?.status===403?a("cloud.export.error_access"):t?.code==="export_invalid_dates"?a("cloud.export.error_dates"):t?.status===409?a("cloud.export.error_changed"):a("cloud.export.error_failed")}function xn({from:t,to:s,deviceId:n=null,auth:r,compact:i=!1,panelContainer:c=null,layout:g="default",dialogOpen:l,onDialogOpenChange:d}){const p=g==="settings-row",h=lt(),m=r||h,j=m?.signedIn?m.user?.id:null,w=new Date().toISOString().slice(0,10),x=new Date(Date.now()-29*864e5).toISOString().slice(0,10),[_,b]=o.useState(t||x),[u,y]=o.useState(s||w),[k,f]=o.useState(!1),N=p&&typeof l=="boolean"?l:k,[E,v]=o.useState(!1),[C,O]=o.useState(null),[S,P]=o.useState(null),[M,G]=o.useState(!1),[J,V]=o.useState(2),te=o.useId(),$=o.useRef(null),F=o.useRef(0),K=o.useRef(null),q=o.useRef(!1),L=o.useRef(!1),T=o.useRef(N);T.current=N;const ie=o.useRef(N);if($.current={userId:j,client:m?.client,start:_,end:u,deviceId:n,from:t,to:s},o.useEffect(()=>{L.current=!0;const I=()=>{++F.current,K.current?.abort(),q.current=!1,v(!1),P(null),O(null),G(!1)};return window.addEventListener(qe,I),()=>{L.current=!1,++F.current,K.current?.abort(),window.removeEventListener(qe,I)}},[]),o.useEffect(()=>{++F.current,K.current?.abort(),q.current=!1,v(!1),O(null),P(null),G(!1),t&&b(t),s&&y(s)},[j,m?.client,t,s,n]),o.useEffect(()=>{p&&ie.current&&!N&&re(),ie.current=N},[N,p]),o.useEffect(()=>{const I=window.matchMedia?.("(max-width: 639px)");if(!I)return;const D=()=>V(I.matches?1:2);return D(),I.addEventListener("change",D),()=>I.removeEventListener("change",D)},[]),!j||m?.enabled===!1)return null;function re(){++F.current,K.current?.abort(),q.current=!1,v(!1),O(null),P(null),G(!1)}function W(I){I||re(),typeof l!="boolean"&&f(I),d?.(I)}function ae(I,D){++F.current,K.current?.abort(),q.current=!1,v(!1),O(null),P(null),I(D)}async function oe(I){if(q.current)return;q.current=!0;const D=$.current,ke=++F.current,_e=new AbortController;K.current=_e,v(!0),O(null),P(null);const pe=()=>{const X=$.current;if(!L.current||ke!==F.current||p&&!T.current||!X||Object.keys(D).some(Q=>D[Q]!==X[Q])||D.client&&!ta(D.client))throw new U("export_cancelled",409)};try{const X=await mn({userId:D.userId,auth:m.getAccessToken,from:D.start,to:D.end,deviceId:D.deviceId,signal:_e.signal,assertCurrent:pe});pe(),await hn(X,I,{signal:_e.signal,assertCurrent:pe}),pe();const Q=X.metadata.effective_range,Fe=X.rows.length?a("cloud.export.success",{count:X.rows.length,from:Q.from,to:Q.to}):a("cloud.export.empty");P(Q.from!==D.start||Q.to!==D.end?`${Fe} ${a("cloud.export.truncated",{from:Q.from,to:Q.to})}`:Fe)}catch(X){L.current&&ke===F.current&&O(fn(X))}finally{ke===F.current&&(q.current=!1,L.current&&v(!1))}}const de="hover:!text-oai-black dark:hover:!text-oai-white hover:!bg-oai-gray-100 dark:hover:!bg-oai-gray-800 focus:!ring-oai-gray-500/40";let ue=null;return(p||N)&&(ue=e.jsxs("div",{id:te,className:p?void 0:i?"w-full rounded-lg bg-oai-gray-50 p-4 dark:bg-oai-gray-950/50":"mt-2 border-l-2 border-oai-gray-200 pl-3 dark:border-oai-gray-700","aria-busy":E,children:[p?null:e.jsx("p",{className:"text-xs leading-5 text-oai-gray-600 dark:text-oai-gray-300",children:a("cloud.export.description")}),e.jsxs("div",{className:p?"space-y-4":"mt-3 flex flex-wrap items-end gap-3",children:[p?e.jsxs(us,{open:M,onOpenChange:G,children:[e.jsxs(ms,{disabled:E,"aria-label":a("trend.zoom.pick_range"),className:"inline-flex h-10 min-h-10 w-full items-center gap-2 rounded-md border border-oai-gray-300 bg-transparent px-3 text-sm text-oai-black transition-colors hover:bg-oai-gray-50 focus-visible:outline focus-visible:outline-2 focus-visible:outline-oai-gray-500 disabled:opacity-50 dark:border-oai-gray-700 dark:text-oai-white dark:hover:bg-oai-gray-800",children:[e.jsx(ds,{size:16,className:"shrink-0 text-oai-gray-500","aria-hidden":!0}),e.jsxs("span",{className:"flex-1 text-left tabular-nums",children:[_," → ",u]}),e.jsx(Re,{size:14,className:"shrink-0 text-oai-gray-500","aria-hidden":!0})]}),e.jsx(gs,{children:e.jsx(ps,{sideOffset:8,side:"bottom",align:"start",className:"z-[110]",children:e.jsx(hs,{className:"max-w-[calc(100vw-2rem)] rounded-xl border border-oai-gray-200 bg-white shadow-lg outline-none dark:border-oai-gray-700 dark:bg-oai-gray-900",children:e.jsx(cs,{from:_,to:u,numberOfMonths:J,onApply:(I,D)=>{ae(b,I),y(D),G(!1)},onCancel:()=>G(!1)})})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"min-w-0 text-xs text-oai-gray-700 dark:text-oai-gray-200",children:[a("cloud.export.from"),e.jsx("input",{type:"date",value:_,onChange:I=>ae(b,I.target.value),className:`${p?"min-h-10 min-w-0 w-full ":""}mt-1 block rounded-md border border-oai-gray-300 bg-white px-2 py-1.5 text-sm text-oai-black focus:outline-none focus:ring-2 focus:ring-inset focus:ring-oai-gray-500/40 dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:text-oai-white`})]}),e.jsxs("label",{className:"min-w-0 text-xs text-oai-gray-700 dark:text-oai-gray-200",children:[a("cloud.export.to"),e.jsx("input",{type:"date",value:u,onChange:I=>ae(y,I.target.value),className:`${p?"min-h-10 min-w-0 w-full ":""}mt-1 block rounded-md border border-oai-gray-300 bg-white px-2 py-1.5 text-sm text-oai-black focus:outline-none focus:ring-2 focus:ring-inset focus:ring-oai-gray-500/40 dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:text-oai-white`})]})]}),e.jsxs("div",{className:p?"flex justify-end gap-2":"flex gap-2",children:[e.jsx(A,{type:"button",variant:p?"secondary":"ghost",size:"sm",className:`${de} ${p?"!min-h-8 !h-8":""}`,disabled:E,onClick:()=>oe("csv"),children:a("cloud.export.csv")}),e.jsx(A,{type:"button",variant:p?"secondary":"ghost",size:"sm",className:`${de} ${p?"!min-h-8 !h-8":""}`,disabled:E,onClick:()=>oe("json"),children:a("cloud.export.json")})]})]}),E?e.jsx("p",{role:"status",className:"mt-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:a("cloud.export.busy")}):null,C?e.jsx("p",{role:"alert",className:"mt-2 text-xs text-red-700 dark:text-red-300",children:C}):null,S?e.jsx("p",{role:"status",className:"mt-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:S}):null]})),p?e.jsx($e,{open:N,onOpenChange:W,title:a("cloud.export.open"),icon:Ie,children:ue}):e.jsxs("section",{className:i&&!p?"tt-cloud-theme contents":"tt-cloud-theme","aria-label":a("cloud.export.open"),children:[e.jsxs(A,{type:"button",variant:"ghost",size:"sm",className:`${de} ${p?"!h-11 !w-full !justify-start !px-0 !text-oai-black dark:!text-oai-white active:!scale-100":i?"!h-10 !px-0":""}`,"aria-expanded":N,"aria-controls":te,onClick:()=>f(I=>!I),children:[e.jsx(Ie,{className:`${p?"mr-3":"mr-2"} h-4 w-4 shrink-0`,"aria-hidden":"true"}),a("cloud.export.open"),p?e.jsx(Re,{size:16,className:`ml-auto shrink-0 transition-transform motion-reduce:transition-none ${N?"rotate-180":""}`,"aria-hidden":!0}):null]}),!p&&c&&ue?gt.createPortal(ue,c):ue]})}function bn({text:t,label:s}){const[n,r]=o.useState(!1);return e.jsxs(bs,{open:n,onOpenChange:r,children:[e.jsx(ys,{delay:0,closeOnClick:!1,"aria-label":s,onClick:()=>r(!0),className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md text-oai-gray-400 transition-colors hover:bg-oai-gray-100 hover:text-oai-gray-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-500/40 dark:hover:bg-oai-gray-800 dark:hover:text-oai-gray-200",children:e.jsx(jt,{size:14,"aria-hidden":!0})}),e.jsx(vs,{children:e.jsx(js,{side:"bottom",sideOffset:6,className:"z-[110]",children:e.jsx(ks,{role:"tooltip",className:"max-w-[min(320px,calc(100vw-2rem))] rounded-lg border border-oai-gray-200 bg-white px-3 py-2 text-xs leading-5 text-oai-gray-600 shadow-lg dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:text-oai-gray-300",children:t})})})]})}function yn(t){return typeof t!="string"||!t.trim()?a("cloud.devices.platform_unknown"):/^(mac|darwin)/i.test(t)?a("leaderboard.community.modal.platform.darwin"):/^win/i.test(t)?a("leaderboard.community.modal.platform.win32"):/^linux/i.test(t)?a("leaderboard.community.modal.platform.linux"):t}function vn(t,s){if(!t)return null;const n=t.status==="active"&&t.access_source==="gift";if(s&&Number.isFinite(Date.parse(s))){const r=t.status==="transition"?"cloud.membership.transition_until":t.status==="trial"?"cloud.membership.trial_until":t.status==="active"?n?"cloud.membership.gift_until":"cloud.membership.active_until":t.status==="expired"&&Date.parse(s)<=Date.now()?"cloud.membership.expired_on":null;if(r)return a(r,{date:H(s)})}return n?a("cloud.gift.membership_label"):Ae(t.status)}function jn({auth:t,machineLimit:s,accountRevision:n,selfHosted:r=!1}){const[i,c]=o.useState(null),[g,l]=o.useState(null),[d,p]=o.useState(null),[h,m]=o.useState(!1),[j,w]=o.useState(null),x=o.useRef(!1),_=o.useRef(0),b=o.useRef(!0),u=t?.user?.id,y=t?.getAccessToken,k=o.useCallback(async()=>{const S=++_.current;try{let P;if(dt())try{const G=await ia(),J=await fetch("/functions/tokentracker-machine-id",{headers:G});J.ok&&(P=(await J.json())?.machineId)}catch{}const M=await ce("devices",{auth:y,params:P?{current_machine_id:P}:{}});S===_.current&&(c(M),l(null))}catch(P){S===_.current&&l({...P,code:"billing_devices_unavailable"})}},[y,u]);o.useEffect(()=>(b.current=!0,k(),()=>{b.current=!1,_.current+=1}),[k,n]);const f=async S=>{if(!x.current){x.current=!0,m(!0),l(null),w(null);try{if(await ce("remove-device",{auth:y,body:{machine_id:S}}),!b.current)return;i?.machines?.find(P=>P.machine_id===S)?.is_current&&We(),p(null),await k()}catch(P){b.current&&l(P)}finally{x.current=!1,m(!1)}}},N=async S=>{if(!x.current){x.current=!0,m(!0),l(null),w(null);try{if(await ce("resume-device",{auth:y,body:{machine_id:S.machine_id}}),!b.current)return;S.is_current&&We(),w(a("cloud.devices.resumed")),await k()}catch(P){b.current&&l(P)}finally{x.current=!1,m(!1)}}},E=i?.machines||[],v=i?.machine_count??E.filter(S=>S.status!=="paused").length,C=i?.machine_limit??s,O=C==null||v<C;return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx("h3",{className:"text-sm font-semibold",children:a("cloud.devices.title")}),e.jsx(bn,{label:a("cloud.devices.detail"),text:a("cloud.devices.detail")})]}),e.jsx("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:i?C==null?a(r?"cloud.devices.unlimited_self_hosted":"cloud.devices.unlimited",{count:v}):a("cloud.devices.count",{count:v,limit:C}):g?a("cloud.devices.count_unknown"):a("cloud.catalog.loading")})]}),i?.over_machine_limit||C!=null&&C<v?e.jsx("div",{className:"mb-4",children:e.jsx(ee,{children:a("cloud.devices.over_limit")})}):null,g?e.jsx(ee,{error:g,onRetry:k,context:"account"}):null,j?e.jsx("div",{className:"mb-3",children:e.jsx(ee,{children:j})}):null,!g&&i&&E.length===0?e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.devices.empty")}):null,E.length!==0?e.jsx("ul",{className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800",children:E.map(S=>e.jsxs("li",{className:"py-1.5",children:[e.jsxs("div",{className:"grid grid-cols-[17px_minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1",children:[e.jsx(Ue,{size:17,className:"col-start-1 row-start-1 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0}),e.jsx("p",{title:S.name||a("cloud.devices.unnamed"),className:"col-start-2 row-start-1 min-w-0 truncate text-sm font-medium",children:S.name||a("cloud.devices.unnamed")}),e.jsxs("div",{className:"col-span-2 col-start-2 row-start-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-oai-gray-500 dark:text-oai-gray-400 sm:col-span-1 sm:col-start-2",children:[e.jsx("span",{children:yn(S.platform)}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:S.last_seen_at?a("cloud.devices.last_seen",{date:ra(S.last_seen_at)}):a("cloud.devices.last_seen_unknown")}),S.is_current?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:a("cloud.devices.current")})]}):null,S.status==="paused"?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:a("cloud.devices.paused")})]}):null]}),S.status==="paused"&&!O?e.jsx("p",{className:"col-start-2 row-start-3 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.devices.no_slot")}):null,e.jsxs(A,{variant:"ghost",size:"sm",className:"col-start-3 row-start-1 !min-h-10 !px-2 sm:row-span-2","aria-expanded":S.status!=="paused"?d===S.machine_id:void 0,"aria-controls":d===S.machine_id?`cloud-machine-confirm-${S.machine_id}`:void 0,onClick:()=>S.status==="paused"?N(S):p(P=>P===S.machine_id?null:S.machine_id),disabled:h||S.status==="paused"&&!O,children:[S.status==="paused"?e.jsx(fs,{size:14,className:"mr-1.5 shrink-0","aria-hidden":!0}):e.jsx(xs,{size:14,className:"mr-1.5 shrink-0","aria-hidden":!0}),S.status==="paused"?a("cloud.devices.resume"):a("cloud.devices.remove")]})]}),d===S.machine_id?e.jsxs("div",{id:`cloud-machine-confirm-${S.machine_id}`,className:"mt-3 rounded-lg bg-oai-gray-50 p-3 dark:bg-oai-gray-800",children:[e.jsx("p",{className:"text-xs leading-5",children:a("cloud.devices.remove_detail")}),e.jsxs("div",{className:"mt-3 flex gap-2",children:[e.jsx(A,{variant:"secondary",onClick:()=>f(S.machine_id),disabled:h,children:a("cloud.devices.confirm_remove")}),e.jsx(A,{variant:"ghost",onClick:()=>p(null),disabled:h,children:a("cloud.action.keep")})]})]}):null]},S.machine_id))}):null]})}function kn({recent:t,pendingOrders:s,conflictOrders:n,userId:r,payments:i=[],footerActions:c}){const g=ht(),[l,d]=o.useState(t?.order_id&&Ce.test(t.order_id)?t.order_id:""),[p,h]=o.useState(!1),[m,j]=o.useState(!1),w=o.useId(),x=o.useRef(null);o.useEffect(()=>{m&&x.current?.focus()},[m]);const _=new Set([...i.map(u=>u.order_id).filter(u=>typeof u=="string"),...(s||[]).filter(u=>u.status==="paid"||["paid","partially_refunded","refunded"].includes(u.payment_state)).map(u=>u.id)].map(u=>u.toLowerCase())),b=[...n||[],...(s||[]).filter(u=>u.retry_payment_conflict_at||!_.has(u.id.toLowerCase()))].filter((u,y,k)=>k.findIndex(f=>f.id===u.id)===y);return e.jsxs("div",{className:"mt-2 space-y-3",children:[t?.request_id&&!t.order_id?e.jsx(ye,{to:`/billing/checkout?sku=${encodeURIComponent(t.sku)}`,className:"mt-3 inline-flex min-h-10 items-center text-sm text-oai-brand underline underline-offset-4",children:a("cloud.action.resume_purchase")}):null,b.length||i.length?e.jsxs("div",{className:"sm:grid sm:grid-cols-[minmax(0,1fr)_auto_minmax(7rem,auto)] sm:gap-x-4",children:[e.jsxs("div",{"aria-hidden":!0,className:"hidden gap-x-4 pb-1 text-xs text-oai-gray-500 dark:text-oai-gray-400 sm:col-span-3 sm:grid sm:grid-cols-subgrid",children:[e.jsx("span",{children:a("cloud.history.date")}),e.jsx("span",{className:"text-right",children:a("cloud.history.amount")}),e.jsx("span",{className:"text-right",children:a("cloud.history.status")})]}),e.jsxs("ul",{className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800 sm:col-span-3 sm:grid sm:grid-cols-subgrid",children:[b.map(u=>{const y=typeof u.created_at=="string"&&Number.isFinite(Date.parse(u.created_at))?H(u.created_at):null;let k=null;Number.isInteger(u.amount_cents)&&u.amount_cents>=0&&["USD","CNY"].includes(u.currency)&&(k=Le(u.amount_cents,u.currency));const f=a(u.retry_payment_conflict_at?"cloud.action.review_duplicate_payment":"cloud.history.pending");return e.jsxs("li",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-1 py-3 sm:col-span-3 sm:grid-cols-subgrid",children:[e.jsx("p",{className:"col-start-1 row-start-1 text-sm tabular-nums",children:y||f}),e.jsx("p",{className:"col-start-2 row-start-1 text-right text-sm font-medium tabular-nums",children:k}),u.provider||y?e.jsxs("div",{className:"col-start-1 row-start-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[u.provider?e.jsx("span",{children:ft(u.provider)}):null,y?e.jsxs(e.Fragment,{children:[u.provider?e.jsx("span",{"aria-hidden":!0,children:"·"}):null,e.jsx("span",{children:f})]}):null]}):null,e.jsx(ye,{to:`/billing/checkout?order=${encodeURIComponent(u.id)}`,onClick:N=>{u.retry_payment_conflict_at||N.button!==0||N.metaKey||N.ctrlKey||N.shiftKey||N.altKey||!Ce.test(u.id)||(N.preventDefault(),g(Ke({orderId:u.id,userId:r})))},className:"col-start-2 row-start-2 inline-flex min-h-10 items-center justify-end rounded-sm text-right text-sm underline-offset-4 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 sm:col-start-3 sm:row-span-2 sm:row-start-1 sm:self-start sm:items-start",children:e.jsx("span",{children:u.retry_payment_conflict_at?a("cloud.action.review_duplicate_payment"):a("cloud.action.resume_order")})})]},u.id)}),e.jsx(_n,{payments:i})]})]}):e.jsx(e.Fragment,{children:(!t?.request_id||t.order_id)&&e.jsx("p",{className:"py-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.history.empty")})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-1",children:[e.jsx(A,{variant:"ghost",size:"sm",className:"!h-10 !px-0","aria-expanded":m,"aria-controls":`${w}-panel`,onClick:()=>j(u=>!u),children:a("cloud.restore.title")}),c]}),m?e.jsxs("div",{id:`${w}-panel`,className:"mt-2",children:[e.jsx("p",{className:"text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.restore.detail")}),e.jsxs("form",{className:"mt-4",onSubmit:u=>{if(u.preventDefault(),!Ce.test(l.trim())){h(!0);return}const y=l.trim(),k=b.some(f=>f.id.toLowerCase()===y.toLowerCase()&&f.retry_payment_conflict_at);g(k?`/billing/checkout?order=${encodeURIComponent(y)}`:Ke({orderId:y,userId:r}))},children:[e.jsx("label",{htmlFor:`${w}-input`,className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.checkout.order_id")}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row",children:[e.jsx("input",{id:`${w}-input`,ref:x,value:l,onChange:u=>{d(u.target.value),h(!1)},placeholder:a("cloud.restore.placeholder"),className:"min-h-10 min-w-0 flex-1 rounded-md border border-oai-gray-300 bg-transparent px-3 text-sm outline-none focus:border-oai-brand focus:ring-2 focus:ring-inset focus:ring-oai-brand/30 dark:border-oai-gray-700","aria-invalid":p,"aria-describedby":p?`${w}-error`:void 0}),e.jsx(A,{type:"submit",variant:"secondary",children:a("cloud.action.restore")})]}),p?e.jsx("p",{id:`${w}-error`,role:"alert",className:"mt-2 text-xs text-red-600 dark:text-red-400",children:a("cloud.restore.invalid")}):null]})]}):null]})]})}function _n({payments:t}){return e.jsx(e.Fragment,{children:t.map(s=>e.jsxs("li",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-1 py-3 sm:col-span-3 sm:grid-cols-subgrid",children:[e.jsx("p",{className:"col-start-1 row-start-1 text-sm tabular-nums",children:H(s.paid_at)}),e.jsx("p",{className:"col-start-2 row-start-1 text-right text-sm font-medium tabular-nums",children:Le(s.amount_cents,s.currency)}),e.jsxs("div",{className:"col-start-1 row-start-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:ft(s.provider)}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:a("cloud.history.term",{start:H(s.starts_at),end:H(s.ends_at)})})]}),e.jsx("p",{className:`col-start-2 row-start-2 text-right text-sm font-medium sm:col-start-3 sm:row-span-1 sm:row-start-1 sm:self-start ${s.refunded_cents>0?"text-amber-700 dark:text-amber-400":"text-oai-gray-600 dark:text-oai-gray-300"}`,children:s.refunded_cents>0?a("cloud.history.refunded",{amount:Le(s.refunded_cents,s.currency)}):a("cloud.history.paid")})]},s.id))})}function wn({showTitle:t=!0,heading:s,syncControl:n,active:r=!0}){const i=aa();return e.jsx(Nn,{showTitle:t,heading:s,syncControl:n,active:r,...i},i.auth?.signedIn?i.auth.user?.id:"signed-out")}function Nn({account:t,auth:s,loading:n,error:r,refresh:i,showTitle:c,heading:g,syncControl:l,active:d=!0}){const{openLoginModal:p}=ut(),[h,m]=o.useState(null),[j,w]=o.useState(null),[x,_]=o.useState(!1),[b,u]=o.useState(null),y=o.useRef(!1),k=o.useRef(!0);o.useEffect(()=>{d||m(null)},[d]),o.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]);const f=t?.membership,N=f?.status==="self_hosted"||f?.hosting_mode==="self_hosted",E=[...t?.conflict_orders||[],...t?.pending_orders||[]].some(L=>L.retry_payment_conflict_at),v=!N&&t?.subscriptions?.find(L=>["active","trialing","past_due","paused","canceling"].includes(L.status)),C=!N&&(v?v.provider==="waffo":t?.payments?.some(L=>L.provider==="waffo")),O=v&&!v.cancel_at_period_end&&v.status!=="canceling",S=O&&v.status!=="paused",P=v?.next_billed_at,M=P&&Number.isFinite(Date.parse(P));o.useEffect(()=>{b&&t&&!O&&(u(null),w(null))},[t,b,O]);const G=N?null:f?.status==="trial"?f.trial_ends_at:f?.status==="transition"?f.transition_ends_at:f?.expires_at,J=async L=>{if(!y.current){y.current=!0,_(!0),w(null);try{await L()}catch(T){k.current&&w(T)}finally{y.current=!1,_(!1)}}},V=()=>J(async()=>{const L=await ce("portal",{auth:s.getAccessToken,body:v?{subscription_id:v.provider_subscription_id}:{}});k.current&&await Wa(L.url||L.portal_url)}),te=()=>J(async()=>{await ce("cancel",{auth:s.getAccessToken,body:{subscription_id:b}}),k.current&&(u(null),await i())}),$=vn(f,G),F=f?.status==="active"&&f?.access_source==="gift",K=C&&!v||f?.can_read_cloud||!N&&t?.gift_redemption_available===!0;if(!s?.signedIn)return e.jsx("div",{className:"space-y-4",children:e.jsx(Z,{title:g||(c?a("cloud.membership.title"):a("settings.section.cloud")),children:e.jsxs("div",{className:"flex flex-col gap-3 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.membership.signed_out")}),e.jsx(A,{variant:"primary",size:"sm",onClick:()=>p({subtitle:a("cloud.membership.signed_out")}),children:a("cloud.action.sign_in_continue")})]})})});const q=g||(c?a("cloud.membership.title"):a("settings.section.cloud"));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("section",{"aria-label":a("cloud.membership.title"),className:"tt-cloud-theme space-y-3",children:[t?.environment==="sandbox"?e.jsx(ee,{children:a("cloud.catalog.sandbox")}):null,E?e.jsx(sa,{showBillingLink:!1}):null,e.jsxs(Z,{title:q,action:e.jsx(A,{onClick:i,variant:"ghost",size:"sm",className:"!h-8 !w-8 shrink-0 !p-0 text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white",disabled:n,"aria-label":a("cloud.action.refresh_membership"),children:e.jsx(De,{size:14,className:n?"motion-safe:animate-spin":void 0,"aria-hidden":!0})}),children:[e.jsx("div",{className:"pt-0.5 pb-2.5",children:F?e.jsxs("div",{className:"flex items-center gap-3.5",children:[e.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg border border-oai-gray-200 bg-oai-gray-50 text-oai-gray-700 dark:border-oai-gray-800 dark:bg-oai-gray-800/60 dark:text-oai-gray-300",children:e.jsx(Te,{className:"h-[30px] w-[30px]","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-white",children:a("cloud.gift.membership_label")}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-oai-gray-200 bg-oai-gray-50 px-2 py-0.5 text-[11px] font-medium text-oai-gray-700 dark:border-oai-gray-800 dark:bg-oai-gray-800/60 dark:text-oai-gray-300",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400"}),a("cloud.gift.state_active")]})]}),$&&$!==a("cloud.gift.membership_label")?e.jsx("p",{className:"mt-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:$}):null]})]}):e.jsxs("div",{className:"flex items-center gap-3.5",children:[e.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg border border-oai-gray-200 bg-oai-gray-50 text-oai-gray-700 dark:border-oai-gray-800 dark:bg-oai-gray-800/60 dark:text-oai-gray-300",children:e.jsx(fe,{className:"h-[30px] w-[30px]","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-white",children:Ae(f?.status)}),f?.status==="active"?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-oai-gray-200 bg-oai-gray-50 px-2 py-0.5 text-[11px] font-medium text-oai-gray-700 dark:border-oai-gray-800 dark:bg-oai-gray-800/60 dark:text-oai-gray-300",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400"}),a("cloud.gift.state_active")]}):null]}),$&&$!==Ae(f?.status)?e.jsx("p",{className:"mt-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:$}):null]})]})}),f?.status==="expired"?e.jsx("p",{className:"py-2.5 text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:f.can_read_cloud?a("cloud.membership.read_only",{date:H(f.read_only_until)}):a("cloud.membership.expired_detail")}):null,f?e.jsx(na,{userId:s.user?.id,membership:f,subscriptions:t?.subscriptions,className:"py-2.5"}):null,!f&&n?e.jsx("p",{role:"status",className:"py-2.5 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.catalog.loading")}):null,v?e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3 py-2.5",children:e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("p",{className:"text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:v.status==="paused"?a("cloud.membership.renewal_paused"):v.status==="past_due"?a("cloud.membership.payment_due"):S?M?a("cloud.membership.renews",{date:H(P)}):a("cloud.membership.renewal_unknown"):a("cloud.membership.renewal_off")}),O?e.jsx(A,{"aria-expanded":!!b,"aria-controls":b?"cloud-cancel-confirm":void 0,onClick:()=>u(L=>L===v.provider_subscription_id?null:v.provider_subscription_id),variant:"ghost",size:"sm",className:"!h-8 !px-2 text-xs",disabled:x,children:a("cloud.action.cancel_renewal")}):null]})}):null,b?e.jsxs("div",{id:"cloud-cancel-confirm",className:"my-3 rounded-lg border border-oai-gray-200 p-4 dark:border-oai-gray-800",children:[e.jsx("p",{className:"text-sm leading-6",children:G?a("cloud.cancel.detail",{date:H(G)}):a("cloud.cancel.no_term")}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(A,{onClick:te,variant:"secondary",disabled:x,children:a("cloud.cancel.confirm")}),e.jsx(A,{onClick:()=>u(null),variant:"ghost",disabled:x,children:a("cloud.action.keep")})]})]}):null,r?e.jsx("div",{className:"py-2.5",children:e.jsx(ee,{error:r,onRetry:i,context:"account"})}):null,j&&h!=="billing"?e.jsx("div",{className:"py-2.5",children:e.jsx(ee,{error:j,context:"account"})}):null]})]}),f?e.jsx(st,{className:"tt-cloud-theme !rounded-lg",bodyClassName:"!py-3",children:e.jsx(jn,{auth:s,machineLimit:f.machine_limit,accountRevision:t,selfHosted:N})}):null,K||t&&!N||l?e.jsx(st,{className:"tt-cloud-theme !rounded-lg",bodyClassName:"!py-2",children:e.jsxs("section",{"aria-label":a("cloud.membership.tools_title"),className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800",children:[N?null:v?e.jsxs("button",{type:"button",onClick:V,disabled:x,className:"inline-flex h-11 w-full items-center gap-3 rounded-md border-0 bg-transparent p-0 text-left text-sm font-medium text-oai-black transition-colors hover:bg-oai-gray-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-oai-gray-500 disabled:opacity-50 dark:text-oai-white dark:hover:bg-oai-gray-800",children:[e.jsx(fe,{size:16,className:"shrink-0","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1",children:a("cloud.action.manage_subscription")}),e.jsx(nt,{size:16,className:"shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})]}):e.jsxs(ye,{to:"/cloud",className:"inline-flex h-11 w-full items-center gap-3 rounded-md border-0 bg-transparent p-0 text-left text-sm font-medium text-oai-black transition-colors hover:bg-oai-gray-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-oai-gray-500 dark:text-oai-white dark:hover:bg-oai-gray-800",children:[e.jsx(fe,{size:16,className:"shrink-0","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1",children:a("cloud.action.subscribe")}),e.jsx(mt,{size:16,className:"shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})]}),t&&!N?e.jsxs($e,{open:h==="billing",onOpenChange:L=>m(L?"billing":null),title:a("cloud.billing.title"),icon:Cs,wide:!0,children:[j?e.jsx("div",{className:"mb-3",children:e.jsx(ee,{error:j,context:"account"})}):null,e.jsx(kn,{userId:s.user?.id,recent:Ka(s.user?.id),pendingOrders:t?.pending_orders,conflictOrders:t?.conflict_orders,payments:t.payments,footerActions:C&&!v?e.jsx("div",{className:"flex items-center gap-0.5",children:e.jsxs(A,{onClick:V,variant:"ghost",size:"sm",className:"!h-10 !px-0",disabled:x,children:[a("cloud.action.view_bills"),e.jsx(nt,{size:14,className:"ml-2","aria-hidden":!0})]})}):null})]}):null,f?.can_read_cloud?e.jsx(xn,{auth:s,layout:"settings-row",dialogOpen:h==="export",onDialogOpenChange:L=>m(L?"export":null)}):null,e.jsx(dn,{account:t,auth:s,refresh:i,layout:"settings-row",dialogOpen:h==="redeem",onDialogOpenChange:L=>m(L?"redeem":null)}),l?e.jsx("section",{children:l}):null]})}):null]})}function Sn({settings:t,active:s=!0}={}){return t?e.jsx(Tt,{settings:t,active:s}):e.jsx(Cn,{active:s})}function Cn({active:t}){const s=Me();return e.jsx(Tt,{settings:s,active:t})}function Tt({settings:t,active:s}){return e.jsx(wn,{showTitle:!1,active:s,syncControl:t.showLocalCloudSync?e.jsx(En,{settings:t}):null})}function En({settings:t}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3",children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-3 text-sm font-medium",children:[e.jsx(De,{size:16,className:"shrink-0","aria-hidden":!0}),a("settings.account.cloudSync")]}),e.jsx("span",{className:"tt-cloud-theme tt-cloud-sync-control inline-flex","aria-busy":t.cloudSyncPending||void 0,children:e.jsx(z,{checked:t.cloudSyncOn,disabled:t.cloudSyncPending,onChange:()=>(t.cloudSyncOn?Ye(t.userId):oa(t.userId,"sync"),t.handleCloudSyncToggle()),ariaLabel:a("settings.account.cloudSync")})})]}),t.cloudSyncOn&&t.cloudSyncPending?e.jsxs("p",{role:"status",className:"flex items-center gap-2 py-3 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(xe,{size:14,className:"motion-safe:animate-spin","aria-hidden":!0}),a("settings.account.cloudSyncPending")]}):null,t.cloudSyncOn&&t.cloudSyncError&&!t.cloudSyncPending?e.jsx("div",{className:"tt-cloud-theme py-3",children:e.jsx(ee,{role:"alert",onRetry:t.handleCloudSyncRetry,children:a("settings.account.cloudSyncError")})}):null,e.jsx(la,{userId:t.userId,panel:"sync",localHost:!0,className:"py-3",onContinueLocal:()=>{Ye(t.userId),t.cloudSyncOn&&t.handleCloudSyncDisable()}})]})}function Pn(){return[{value:"light",label:a("settings.appearance.theme.light"),Icon:da},{value:"dark",label:a("settings.appearance.theme.dark"),Icon:ua},{value:"system",label:a("settings.appearance.theme.system"),Icon:Ue}]}function On(){return[{value:pa,label:a("settings.appearance.language.system")},{value:ha,label:a("settings.appearance.language.english")},{value:fa,label:a("settings.appearance.language.chinese")},{value:xa,label:a("settings.appearance.language.traditional_chinese")},{value:ba,label:a("settings.appearance.language.japanese")},{value:ya,label:a("settings.appearance.language.korean")},{value:va,label:a("settings.appearance.language.german")}]}function An(t){if(!t)return null;try{const s=new Date(t);return Number.isNaN(s.getTime())?null:s.toLocaleString()}catch{return null}}function Ln(t,s){const n=a(`settings.appearance.currency.rate_source.${t}`),r=An(s),i=r?a("settings.appearance.currency.rate_updated",{when:r}):a("settings.appearance.currency.rate_never");return`${n} · ${i}`}function Tn({locale:t,setLocale:s}){const n=On();return e.jsx(ze,{value:t,onValueChange:s,options:n,ariaLabel:a("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:e.jsx(Os,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function Rn({currency:t,setCurrency:s}){const n=ma().map(r=>({value:r.code,label:a(r.labelKey)}));return e.jsx(ze,{value:t,onValueChange:s,options:n,ariaLabel:a("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function In({currency:t,rate:s,rateSource:n,rateFetchedAt:r}){if(t===ga)return e.jsx(e.Fragment,{children:a("settings.appearance.currency.hint")});const i=Ln(n,r);return e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:`1 USD = ${s.toFixed(4)} ${t}`}),e.jsx("span",{role:"img","aria-label":i,title:i,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:e.jsx(jt,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function Dn(){const{theme:t,setTheme:s}=ca(),{locale:n,setLocale:r}=xt(),{currency:i,rate:c,rateSource:g,rateFetchedAt:l,setCurrency:d}=_s(),{mode:p,setMode:h,unitSystem:m,setUnitSystem:j,grouping:w,setGrouping:x}=ws();return e.jsxs(Z,{title:a("settings.section.appearance"),children:[e.jsx(R,{label:a("settings.appearance.theme.label"),hint:a("settings.appearance.theme.hint"),control:e.jsx(se,{options:Pn(),value:t,onChange:s})}),e.jsx(R,{label:a("settings.appearance.language.label"),hint:a("settings.appearance.language.hint"),control:e.jsx(Tn,{locale:n,setLocale:r})}),e.jsx(R,{label:a("settings.appearance.currency.label"),hint:e.jsx(In,{currency:i,rate:c,rateSource:g,rateFetchedAt:l}),control:e.jsx(Rn,{currency:i,setCurrency:d})}),e.jsx(R,{label:a("settings.appearance.token_format.label"),hint:a("settings.appearance.token_format.hint"),control:e.jsx(se,{options:[{value:Se.COMPACT,label:a("settings.appearance.token_format.compact")},{value:Se.FULL,label:a("settings.appearance.token_format.full")}],value:p,onChange:h})}),e.jsx(R,{label:a("settings.appearance.token_unit.label"),hint:a("settings.appearance.token_unit.hint"),control:e.jsx(se,{disabled:p!==Se.COMPACT,options:[{value:Ze.ENGLISH,label:a("settings.appearance.token_unit.english")},{value:Ze.CHINESE,label:a("settings.appearance.token_unit.chinese")}],value:m,onChange:j})}),e.jsx(R,{label:a("settings.appearance.token_grouping.label"),hint:a("settings.appearance.token_grouping.hint"),control:e.jsx(se,{options:[{value:Je.THOUSAND,label:a("settings.appearance.token_grouping.thousand")},{value:Je.WAN,label:a("settings.appearance.token_grouping.wan")}],value:w,onChange:x})})]})}function Ee({labelKey:t}){return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:a(t)}),e.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 Un(){const{enabled:t,toggle:s}=Fa(),{enabled:n,toggle:r}=Ba(),{available:i,settings:c,setSetting:g}=je(),l=i&&!!c?.dynamicIslandSupported,d=!!c?.dynamicIslandEnabled;return e.jsxs(Z,{title:a("settings.section.labs"),children:[l&&e.jsxs(e.Fragment,{children:[e.jsx(R,{label:e.jsx(Ee,{labelKey:"settings.labs.island.label"}),hint:a("settings.labs.island.hint"),control:e.jsx(z,{checked:d,onChange:()=>g("dynamicIslandEnabled",!d),ariaLabel:a("settings.labs.island.aria")})}),d&&e.jsx(R,{label:a("settings.labs.island_hide_menubar.label"),hint:a("settings.labs.island_hide_menubar.hint"),control:e.jsx(z,{checked:!!c?.hideMenuBarIcon,onChange:()=>g("hideMenuBarIcon",!c?.hideMenuBarIcon),ariaLabel:a("settings.labs.island_hide_menubar.aria")})})]}),e.jsx(R,{label:e.jsx(Ee,{labelKey:"settings.labs.qpd.label"}),hint:a("settings.labs.qpd.hint"),control:e.jsx(z,{checked:t,onChange:s,ariaLabel:a("settings.labs.qpd.aria")})}),e.jsx(R,{label:e.jsx(Ee,{labelKey:"settings.labs.sessions.label"}),hint:a("settings.labs.sessions.hint"),control:e.jsx(z,{checked:n,onChange:r,ariaLabel:a("settings.labs.sessions.aria")})})]})}function zn(){const{available:t,settings:s,setSetting:n,runAction:r}=je();if(!t)return null;const i=bt(),c=!!s?.launchAtLogin,g=s?.toastOnReset!==!1,l=s?.confettiOnReset!==!1,d=s?.launchAtLoginSupported!==!1,p=s?.autoUpdateEnabled!==!1,h=s?.updateStatus||null,m=!!s?.updateBusy,j=!!s?.isSyncing;return e.jsxs(Z,{title:a("settings.section.menubar"),children:[i?null:e.jsxs(e.Fragment,{children:[e.jsx(R,{label:a("settings.menubar.appearance"),hint:a("settings.menubar.appearanceHint"),control:e.jsxs(A,{as:ye,to:"/widgets",variant:"secondary",size:"sm",className:"gap-1.5 no-underline",children:[e.jsx("span",{children:a("settings.menubar.appearanceLink")}),e.jsx(Ss,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),e.jsx(R,{label:a("settings.menubar.toastOnReset"),hint:a("settings.menubar.toastOnResetHint"),control:e.jsx(z,{checked:g,onChange:()=>n("toastOnReset",!g),ariaLabel:a("settings.menubar.toastOnReset")})}),e.jsx(R,{label:a("settings.menubar.confettiOnReset"),hint:a("settings.menubar.confettiOnResetHint"),control:e.jsx(z,{checked:l,onChange:()=>n("confettiOnReset",!l),ariaLabel:a("settings.menubar.confettiOnReset")})})]}),d?e.jsx(R,{label:a("settings.menubar.launchAtLogin"),hint:a("settings.menubar.launchAtLoginHint"),control:e.jsx(z,{checked:c,onChange:()=>n("launchAtLogin",!c),ariaLabel:a("settings.menubar.launchAtLogin")})}):null,e.jsx(R,{label:a("settings.menubar.syncNow"),hint:a("settings.menubar.syncNowHint"),control:e.jsxs(A,{variant:"secondary",size:"sm",onClick:()=>r("syncNow"),disabled:j,className:"gap-1.5",children:[e.jsx(De,{className:le("h-3.5 w-3.5",j&&"animate-spin"),"aria-hidden":!0}),e.jsx("span",{children:j?a("settings.menubar.syncing"):a("settings.menubar.syncNow")})]})}),e.jsx(R,{label:a("settings.menubar.autoUpdate"),hint:a("settings.menubar.autoUpdateHint"),control:e.jsx(z,{checked:p,onChange:()=>n("autoUpdateEnabled",!p),ariaLabel:a("settings.menubar.autoUpdate")})}),e.jsx(R,{label:a("settings.menubar.updates"),hint:h||void 0,control:e.jsxs(A,{variant:"secondary",size:"sm",onClick:()=>r("checkForUpdates"),disabled:m,className:"gap-1.5",children:[e.jsx(Ie,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{children:a("settings.menubar.checkUpdates")})]})})]})}function Gn(t,s){function n(c){return c.replace(/^v/,"").split(".").map(Number)}const r=n(t),i=n(s);for(let c=0;c<Math.max(r.length,i.length);c++){const g=r[c]||0,l=i[c]||0;if(g<l)return!0;if(g>l)return!1}return!1}function Mn(){const{available:t,settings:s,runAction:n}=je(),r=t&&s?.version,i=s?.platform||"macos",[c,g]=Pe.useState(!1),[l,d]=Pe.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:p}=xt(),h="1.3.10",m=async()=>{g(!0);try{const b=await fetch("https://api.github.com/repos/xiufengsun/TokenTracker/releases/latest");if(!b.ok)throw new Error("Failed to fetch");const u=await b.json(),y=u.tag_name;Gn(h,y)?d({open:!0,latestVersion:y,htmlUrl:u.html_url}):Xe({title:a("settings.menubar.updates.upToDate")})}catch(b){console.error("Check updates failed:",b),Xe({title:a("settings.menubar.updates.failed")})}finally{g(!1)}},j=a("settings.menubar.updates.modalTitle"),w=a("settings.menubar.updates.modalDescription",{version:l.latestVersion}),x=a("settings.menubar.updates.modalConfirm"),_=a("settings.menubar.updates.modalCancel");return e.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:[e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[r?e.jsxs(e.Fragment,{children:[e.jsx("span",{children:i==="windows"?a("settings.menubar.updates.footerCore",{version:s.version}):a("settings.menubar.updates.footerCombined",{barVersion:s.version,coreVersion:h})}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("button",{type:"button",onClick:()=>n("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),e.jsx("span",{"aria-hidden":!0,children:"·"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:a("settings.menubar.updates.footerCore",{version:h})}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("button",{type:"button",onClick:m,disabled:c,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:c?a("settings.menubar.updates.checking"):a("settings.menubar.checkUpdates")}),e.jsx("span",{"aria-hidden":!0,children:"·"})]}),e.jsxs("a",{href:ja,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:[e.jsx(ka,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.footer.statusPage")]})]}),e.jsx(Ns,{open:l.open,title:j,description:w,confirmLabel:x,cancelLabel:_,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),d(b=>({...b,open:!1}))},onCancel:()=>d(b=>({...b,open:!1}))})]})}const $n=()=>[{value:"system",label:a("settings.network.mode.system")},{value:"manual",label:a("settings.network.mode.manual")},{value:"off",label:a("settings.network.mode.off")}],Fn=()=>[{value:"http",label:a("settings.network.protocol.http")},{value:"https",label:a("settings.network.protocol.https")},{value:"socks5",label:a("settings.network.protocol.socks5")}];function rt(t){const s={},n=String(t.host||"").trim();(!n||/:\/\//.test(n)||n.includes("/"))&&(s.host=a("settings.network.error.host"));const r=String(t.port??"").trim(),i=Number(r);return(!r||!/^\d+$/.test(r)||!Number.isInteger(i)||i<1||i>65535)&&(s.port=a("settings.network.error.port")),s}function Bn({proxySettings:t}){const{config:s,save:n,testConnection:r}=t,[i,c]=o.useState(()=>({mode:s.mode,protocol:s.protocol||"http",host:s.host||"",port:s.port||""})),[g,l]=o.useState({}),[d,p]=o.useState(!1),[h,m]=o.useState(""),[j,w]=o.useState(null),[x,_]=o.useState(!1),[b,u]=o.useState(null);o.useEffect(()=>{c({mode:s.mode,protocol:s.protocol||"http",host:s.host||"",port:s.port||""})},[s.mode,s.protocol,s.host,s.port]);const y=o.useMemo(()=>s.effective==="manual"?a("settings.network.effective.manual"):s.effective==="env"?a("settings.network.effective.env"):s.effective==="system"?a("settings.network.effective.system"):s.effective==="blocked"?a("settings.network.effective.blocked"):a("settings.network.effective.none"),[s.effective]),k=o.useMemo(()=>i.mode!==s.mode?!0:i.mode==="manual"?(i.protocol||"http")!==(s.protocol||"http")||(i.host||"")!==(s.host||"")||String(i.port??"")!==String(s.port??""):!1,[i,s]),f=v=>{c(C=>({...C,...v})),l({}),m(""),w(null),u(null)},N=async()=>{if(i.mode==="manual"){const v=rt(i);if(Object.keys(v).length){l(v);return}}p(!0),m(""),w(null);try{await n(i),m("saved")}catch(v){m("error"),w(v)}finally{p(!1)}},E=async()=>{const v=rt(i);if(Object.keys(v).length){l(v);return}_(!0),u(null);try{const C=await r(i);u(C)}catch(C){u({ok:!1,error:C?.message||String(C)})}finally{_(!1)}};return e.jsxs(Z,{title:a("settings.section.network"),subtitle:y,children:[s.applyError?e.jsx("p",{role:"alert",className:"mb-3 text-xs text-red-600 dark:text-red-400",children:a("settings.network.apply_error",{error:s.applyError})}):null,e.jsx(R,{label:a("settings.network.mode.label"),hint:a("settings.network.mode.hint"),control:e.jsx(se,{options:$n(),value:i.mode,onChange:v=>f({mode:v})})}),e.jsx(vt,{initial:!1,children:i.mode==="manual"?e.jsxs(yt.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(R,{label:a("settings.network.protocol.label"),control:e.jsx(ze,{value:i.protocol,onValueChange:v=>f({protocol:v}),options:Fn(),ariaLabel:a("settings.network.protocol.label"),className:"px-2.5 py-1.5 text-xs font-medium"})}),e.jsx(R,{label:a("settings.network.host.label"),hint:g.host,control:e.jsx("input",{type:"text",value:i.host,onChange:v=>f({host:v.target.value}),placeholder:a("settings.network.host.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":g.host?!0:void 0,"aria-label":a("settings.network.host.label"),className:ve})}),e.jsx(R,{label:a("settings.network.port.label"),hint:g.port,control:e.jsx("input",{type:"text",inputMode:"numeric",value:i.port,onChange:v=>f({port:v.target.value}),placeholder:a("settings.network.port.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":g.port?!0:void 0,"aria-label":a("settings.network.port.label"),className:ve})}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 py-3",children:[e.jsx(A,{variant:"secondary",size:"sm",onClick:E,disabled:x||d,className:"gap-1.5",children:x?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}),e.jsx("span",{children:a("settings.network.test.testing")})]}):a("settings.network.test")}),e.jsx(A,{variant:"primary",size:"sm",onClick:N,disabled:d||x,className:"gap-1.5",children:d?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}),e.jsx("span",{children:a("settings.network.saving")})]}):a("settings.network.save")})]}),b?e.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:b.ok?a("settings.network.test.ok",{status:String(b.status??"")}):a("settings.network.test.fail",{error:b.error||""})}):null]},"manual-proxy-fields"):null}),i.mode!=="manual"&&(k||d)?e.jsx("div",{className:"flex justify-end py-3",children:e.jsx(A,{variant:"primary",size:"sm",onClick:N,disabled:d,className:"gap-1.5",children:d?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}),e.jsx("span",{children:a("settings.network.saving")})]}):a("settings.network.save")})},"non-manual-save"):null,h==="saved"?e.jsx("p",{className:"py-2 text-xs text-emerald-600 dark:text-emerald-400",children:a("settings.network.saved")}):null,h==="error"?e.jsx("p",{role:"alert",className:"py-2 text-xs text-red-600 dark:text-red-400",children:j?.unprotected?a("settings.network.save_error_unprotected",{error:j?.message||String(j||"")}):a("settings.network.save_error",{error:j?.message||String(j||"")})}):null]})}const Rt="/functions/tokentracker-proxy-config",Hn="/functions/tokentracker-proxy-test",Vn={mode:"system",protocol:"http",host:"",port:"",effective:"none",applyError:null};function It(t){return!t||typeof t.mode!="string"?null:{mode:t.mode,protocol:typeof t.protocol=="string"?t.protocol:"http",host:typeof t.host=="string"?t.host:"",port:t.port==null||t.port===0?"":String(t.port),effective:typeof t.effective=="string"?t.effective:"none",applyError:typeof t.applyError=="string"&&t.applyError.trim()?t.applyError:null}}async function qn(){const t=await fetch(Rt,{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!t.ok)return null;const s=await t.json().catch(()=>null);return It(s)}async function ot(){const{getLocalApiAuthHeaders:t}=await _a(async()=>{const{getLocalApiAuthHeaders:s}=await import("./__vite-browser-external-Go6WKt6Z.js").then(n=>n.dY);return{getLocalApiAuthHeaders:s}},__vite__mapDeps([0,1]));return t()}function Kn(){const[t,s]=o.useState(!1),[n,r]=o.useState(!0),[i,c]=o.useState(Vn);o.useEffect(()=>{if(!qa()){s(!1),r(!1);return}let d=!1;return(async()=>{try{const p=await qn();if(d)return;if(!p){s(!1),r(!1);return}c(p),s(!0),r(!1)}catch{d||(s(!1),r(!1))}})(),()=>{d=!0}},[]);const g=o.useCallback(async d=>{const p=await ot(),h=await fetch(Rt,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...p},cache:"no-store",body:JSON.stringify({mode:d.mode,protocol:d.protocol,host:d.host,port:d.port===""?0:Number(d.port)})}),m=await h.json().catch(()=>null);if(!h.ok){const w=m&&typeof m.error=="string"?m.error:`HTTP ${h.status}`;throw new Error(w)}const j=It(m);if(j&&c(j),m&&m.ok===!1){const w=m&&typeof m.applyError=="string"&&m.applyError||m&&typeof m.error=="string"&&m.error||`HTTP ${h.status}`,x=new Error(w);throw m.unprotected===!0&&(x.unprotected=!0),x}return j||m},[]),l=o.useCallback(async d=>{const p=await ot(),h=await fetch(Hn,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...p},cache:"no-store",body:JSON.stringify({protocol:d.protocol,host:d.host,port:d.port===""?0:Number(d.port)})}),m=await h.json().catch(()=>null);if(!m||typeof m.ok!="boolean")throw new Error(m&&typeof m.error=="string"?m.error:`HTTP ${h.status}`);return m},[]);return{available:t,loading:n,config:i,save:g,testConnection:l}}const B={APPEARANCE:"appearance",NATIVE_APP:"native-app",NETWORK:"network",ACCOUNT:"account",CLOUD:"cloud",LIMITS:"limits",LABS:"labs"},Y={PERSONAL:"personal",APP:"app",DEVELOPER:"developer"};function Wn({prefs:t}){return e.jsx(se,{options:[{value:at.USED,label:a("limits.settings.display_mode_used")},{value:at.REMAINING,label:a("limits.settings.display_mode_remaining")}],value:t.displayMode,onChange:t.setDisplayMode})}function Ti(){const t=Me(),s=Ga(),{available:n,settings:r,setSetting:i}=je(),c=Kn(),{available:g}=c,l=r?.toastOnReset!==!1,d=r?.confettiOnReset!==!1,p=bt()||r?.platform==="windows",[h,m]=wa(),j=ht(),w=h.get("section"),_=Object.values(B).includes(w)&&(w!==B.NATIVE_APP||n)&&(w!==B.NETWORK||g)?w:B.APPEARANCE,b=k=>{const f=new URLSearchParams(h);k===B.APPEARANCE?f.delete("section"):f.set("section",k),m(f,{replace:!0})},u=[{id:B.APPEARANCE,label:a("settings.section.appearance"),description:a("settings.section.appearance.description"),group:Y.PERSONAL,Icon:Ls,content:e.jsx(Dn,{})},...n?[{id:B.NATIVE_APP,label:a("settings.section.menubar"),description:a("settings.section.menubar.description"),group:Y.APP,Icon:Ue,content:e.jsx(zn,{})}]:[],...g?[{id:B.NETWORK,label:a("settings.section.network"),description:a("settings.section.network.description"),group:Y.APP,Icon:Na,content:e.jsx(Bn,{proxySettings:c})}]:[],{id:B.ACCOUNT,label:a("settings.section.account"),description:a("settings.section.account.description"),group:Y.PERSONAL,Icon:Ts,content:e.jsx(sn,{settings:t})},{id:B.CLOUD,label:a("settings.section.cloud"),description:a("settings.section.cloud.description"),group:Y.PERSONAL,Icon:fe,content:e.jsx(Sn,{settings:t,active:_===B.CLOUD})},{id:B.LIMITS,label:a("settings.section.limits"),description:a("settings.section.limits.description"),group:Y.APP,Icon:Sa,content:e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Z,{title:a("settings.section.limits"),children:[e.jsx(R,{label:a("limits.settings.display_mode_label"),control:e.jsx(Wn,{prefs:s})}),p?null:e.jsxs(e.Fragment,{children:[e.jsx(R,{label:a("settings.menubar.toastOnReset"),hint:a("settings.menubar.toastOnResetHint"),control:e.jsx(z,{checked:l,disabled:!n,onChange:()=>i("toastOnReset",!l),ariaLabel:a("settings.menubar.toastOnReset")})}),e.jsx(R,{label:a("settings.menubar.confettiOnReset"),hint:a("settings.menubar.confettiOnResetHint"),control:e.jsx(z,{checked:d,disabled:!n,onChange:()=>i("confettiOnReset",!d),ariaLabel:a("settings.menubar.confettiOnReset")})})]}),e.jsx(R,{label:a("settings.limits.showSubscriptions"),hint:a("settings.limits.showSubscriptionsHint"),control:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(A,{variant:"secondary",size:"sm",onClick:()=>j("/limits?openSubscriptions=1"),"aria-label":a("limits.page.openSubscriptions"),title:a("limits.page.openSubscriptions"),className:"!h-7 !w-7 !p-0 text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white",children:e.jsx(Ca,{size:14,"aria-hidden":!0})}),e.jsx(z,{checked:s.showSubscriptions!==!1,onChange:()=>s.setShowSubscriptions(!s.showSubscriptions),ariaLabel:a("settings.limits.showSubscriptions")})]})})]}),e.jsx(Z,{title:a("settings.limits.providers"),children:e.jsx(Us,{prefs:s})})]})},{id:B.LABS,label:a("settings.section.labs"),description:a("settings.section.labs.description"),group:Y.DEVELOPER,Icon:Es,content:e.jsx(Un,{})}],y=[{id:Y.PERSONAL,label:a("settings.nav.group.personal")},{id:Y.APP,label:a("settings.nav.group.app")},{id:Y.DEVELOPER,label:a("settings.nav.group.developer")}].map(k=>({...k,sections:u.filter(f=>f.group===k.id)})).filter(k=>k.sections.length>0);return e.jsx("div",{className:le("flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",_===B.CLOUD&&"tt-cloud-settings"),children:e.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:e.jsxs("div",{className:"mx-auto w-full max-w-5xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-7 max-w-2xl",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("settings.page.title")}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:a("settings.page.subtitle")})]}),e.jsxs("div",{className:"tt-settings-sections grid min-w-0 gap-6 md:grid-cols-[11rem_minmax(0,1fr)] md:gap-8",children:[e.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:e.jsx("nav",{"aria-label":a("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:y.map(({id:k,label:f,sections:N})=>e.jsxs("div",{className:"flex shrink-0 gap-1 md:block",children:[e.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:f}),e.jsx("div",{className:"flex gap-1 md:flex-col",children:N.map(({id:E,label:v,Icon:C})=>{const O=_===E;return e.jsxs("button",{id:`settings-nav-${E}`,type:"button","aria-current":O?"page":void 0,"aria-controls":`settings-panel-${E}`,onClick:()=>b(E),className:le("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",O?"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:[e.jsx(C,{className:le("h-4 w-4 shrink-0",O?"text-oai-black dark:text-white":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),e.jsx("span",{className:"truncate",children:v})]},E)})})]},k))})}),e.jsxs("div",{className:"min-w-0",children:[u.map(({id:k,label:f,content:N})=>e.jsx("section",{id:`settings-panel-${k}`,"aria-labelledby":`settings-nav-${k}`,"aria-label":f,"data-settings-panel":k,hidden:_!==k,children:N},k)),e.jsx(Mn,{})]})]})]})})})}export{Ti as SettingsPage};
|
|
5
|
+
`}async function hn(t,s,{signal:n,assertCurrent:r=()=>{}}={}){const i=pn(t,s),c=`tokentracker-cloud-usage-${t.metadata.effective_range.from}-${t.metadata.effective_range.to}.${s}`,g=()=>{if(n?.aborted)throw new U("export_cancelled",409);r()};g();const l=await Jt({filename:c,content:i,format:s,signal:n});if(g(),l?.saved===!0)return;if(l!==null)throw new U("export_failed",503);const d=new Blob([i],{type:s==="csv"?"text/csv;charset=utf-8":"application/json;charset=utf-8"}),p=URL.createObjectURL(d);try{const h=document.createElement("a");h.href=p,h.download=c,document.body.appendChild(h);try{h.click()}finally{h.remove()}}finally{setTimeout(()=>URL.revokeObjectURL(p),1e3)}}function fn(t){return t?.status===401?a("cloud.export.error_auth"):t?.status===402||t?.status===403?a("cloud.export.error_access"):t?.code==="export_invalid_dates"?a("cloud.export.error_dates"):t?.status===409?a("cloud.export.error_changed"):a("cloud.export.error_failed")}function xn({from:t,to:s,deviceId:n=null,auth:r,compact:i=!1,panelContainer:c=null,layout:g="default",dialogOpen:l,onDialogOpenChange:d}){const p=g==="settings-row",h=lt(),m=r||h,j=m?.signedIn?m.user?.id:null,w=new Date().toISOString().slice(0,10),x=new Date(Date.now()-29*864e5).toISOString().slice(0,10),[_,b]=o.useState(t||x),[u,y]=o.useState(s||w),[k,f]=o.useState(!1),N=p&&typeof l=="boolean"?l:k,[E,v]=o.useState(!1),[C,O]=o.useState(null),[S,P]=o.useState(null),[M,G]=o.useState(!1),[J,V]=o.useState(2),te=o.useId(),$=o.useRef(null),F=o.useRef(0),K=o.useRef(null),q=o.useRef(!1),L=o.useRef(!1),T=o.useRef(N);T.current=N;const ie=o.useRef(N);if($.current={userId:j,client:m?.client,start:_,end:u,deviceId:n,from:t,to:s},o.useEffect(()=>{L.current=!0;const I=()=>{++F.current,K.current?.abort(),q.current=!1,v(!1),P(null),O(null),G(!1)};return window.addEventListener(qe,I),()=>{L.current=!1,++F.current,K.current?.abort(),window.removeEventListener(qe,I)}},[]),o.useEffect(()=>{++F.current,K.current?.abort(),q.current=!1,v(!1),O(null),P(null),G(!1),t&&b(t),s&&y(s)},[j,m?.client,t,s,n]),o.useEffect(()=>{p&&ie.current&&!N&&re(),ie.current=N},[N,p]),o.useEffect(()=>{const I=window.matchMedia?.("(max-width: 639px)");if(!I)return;const D=()=>V(I.matches?1:2);return D(),I.addEventListener("change",D),()=>I.removeEventListener("change",D)},[]),!j||m?.enabled===!1)return null;function re(){++F.current,K.current?.abort(),q.current=!1,v(!1),O(null),P(null),G(!1)}function W(I){I||re(),typeof l!="boolean"&&f(I),d?.(I)}function ae(I,D){++F.current,K.current?.abort(),q.current=!1,v(!1),O(null),P(null),I(D)}async function oe(I){if(q.current)return;q.current=!0;const D=$.current,ke=++F.current,_e=new AbortController;K.current=_e,v(!0),O(null),P(null);const pe=()=>{const X=$.current;if(!L.current||ke!==F.current||p&&!T.current||!X||Object.keys(D).some(Q=>D[Q]!==X[Q])||D.client&&!ta(D.client))throw new U("export_cancelled",409)};try{const X=await mn({userId:D.userId,auth:m.getAccessToken,from:D.start,to:D.end,deviceId:D.deviceId,signal:_e.signal,assertCurrent:pe});pe(),await hn(X,I,{signal:_e.signal,assertCurrent:pe}),pe();const Q=X.metadata.effective_range,Fe=X.rows.length?a("cloud.export.success",{count:X.rows.length,from:Q.from,to:Q.to}):a("cloud.export.empty");P(Q.from!==D.start||Q.to!==D.end?`${Fe} ${a("cloud.export.truncated",{from:Q.from,to:Q.to})}`:Fe)}catch(X){L.current&&ke===F.current&&O(fn(X))}finally{ke===F.current&&(q.current=!1,L.current&&v(!1))}}const de="hover:!text-oai-black dark:hover:!text-oai-white hover:!bg-oai-gray-100 dark:hover:!bg-oai-gray-800 focus:!ring-oai-gray-500/40";let ue=null;return(p||N)&&(ue=e.jsxs("div",{id:te,className:p?void 0:i?"w-full rounded-lg bg-oai-gray-50 p-4 dark:bg-oai-gray-950/50":"mt-2 border-l-2 border-oai-gray-200 pl-3 dark:border-oai-gray-700","aria-busy":E,children:[p?null:e.jsx("p",{className:"text-xs leading-5 text-oai-gray-600 dark:text-oai-gray-300",children:a("cloud.export.description")}),e.jsxs("div",{className:p?"space-y-4":"mt-3 flex flex-wrap items-end gap-3",children:[p?e.jsxs(us,{open:M,onOpenChange:G,children:[e.jsxs(ms,{disabled:E,"aria-label":a("trend.zoom.pick_range"),className:"inline-flex h-10 min-h-10 w-full items-center gap-2 rounded-md border border-oai-gray-300 bg-transparent px-3 text-sm text-oai-black transition-colors hover:bg-oai-gray-50 focus-visible:outline focus-visible:outline-2 focus-visible:outline-oai-gray-500 disabled:opacity-50 dark:border-oai-gray-700 dark:text-oai-white dark:hover:bg-oai-gray-800",children:[e.jsx(ds,{size:16,className:"shrink-0 text-oai-gray-500","aria-hidden":!0}),e.jsxs("span",{className:"flex-1 text-left tabular-nums",children:[_," → ",u]}),e.jsx(Re,{size:14,className:"shrink-0 text-oai-gray-500","aria-hidden":!0})]}),e.jsx(gs,{children:e.jsx(ps,{sideOffset:8,side:"bottom",align:"start",className:"z-[110]",children:e.jsx(hs,{className:"max-w-[calc(100vw-2rem)] rounded-xl border border-oai-gray-200 bg-white shadow-lg outline-none dark:border-oai-gray-700 dark:bg-oai-gray-900",children:e.jsx(cs,{from:_,to:u,numberOfMonths:J,onApply:(I,D)=>{ae(b,I),y(D),G(!1)},onCancel:()=>G(!1)})})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"min-w-0 text-xs text-oai-gray-700 dark:text-oai-gray-200",children:[a("cloud.export.from"),e.jsx("input",{type:"date",value:_,onChange:I=>ae(b,I.target.value),className:`${p?"min-h-10 min-w-0 w-full ":""}mt-1 block rounded-md border border-oai-gray-300 bg-white px-2 py-1.5 text-sm text-oai-black focus:outline-none focus:ring-2 focus:ring-inset focus:ring-oai-gray-500/40 dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:text-oai-white`})]}),e.jsxs("label",{className:"min-w-0 text-xs text-oai-gray-700 dark:text-oai-gray-200",children:[a("cloud.export.to"),e.jsx("input",{type:"date",value:u,onChange:I=>ae(y,I.target.value),className:`${p?"min-h-10 min-w-0 w-full ":""}mt-1 block rounded-md border border-oai-gray-300 bg-white px-2 py-1.5 text-sm text-oai-black focus:outline-none focus:ring-2 focus:ring-inset focus:ring-oai-gray-500/40 dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:text-oai-white`})]})]}),e.jsxs("div",{className:p?"flex justify-end gap-2":"flex gap-2",children:[e.jsx(A,{type:"button",variant:p?"secondary":"ghost",size:"sm",className:`${de} ${p?"!min-h-8 !h-8":""}`,disabled:E,onClick:()=>oe("csv"),children:a("cloud.export.csv")}),e.jsx(A,{type:"button",variant:p?"secondary":"ghost",size:"sm",className:`${de} ${p?"!min-h-8 !h-8":""}`,disabled:E,onClick:()=>oe("json"),children:a("cloud.export.json")})]})]}),E?e.jsx("p",{role:"status",className:"mt-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:a("cloud.export.busy")}):null,C?e.jsx("p",{role:"alert",className:"mt-2 text-xs text-red-700 dark:text-red-300",children:C}):null,S?e.jsx("p",{role:"status",className:"mt-2 text-xs text-oai-gray-600 dark:text-oai-gray-300",children:S}):null]})),p?e.jsx($e,{open:N,onOpenChange:W,title:a("cloud.export.open"),icon:Ie,children:ue}):e.jsxs("section",{className:i&&!p?"tt-cloud-theme contents":"tt-cloud-theme","aria-label":a("cloud.export.open"),children:[e.jsxs(A,{type:"button",variant:"ghost",size:"sm",className:`${de} ${p?"!h-11 !w-full !justify-start !px-0 !text-oai-black dark:!text-oai-white active:!scale-100":i?"!h-10 !px-0":""}`,"aria-expanded":N,"aria-controls":te,onClick:()=>f(I=>!I),children:[e.jsx(Ie,{className:`${p?"mr-3":"mr-2"} h-4 w-4 shrink-0`,"aria-hidden":"true"}),a("cloud.export.open"),p?e.jsx(Re,{size:16,className:`ml-auto shrink-0 transition-transform motion-reduce:transition-none ${N?"rotate-180":""}`,"aria-hidden":!0}):null]}),!p&&c&&ue?gt.createPortal(ue,c):ue]})}function bn({text:t,label:s}){const[n,r]=o.useState(!1);return e.jsxs(bs,{open:n,onOpenChange:r,children:[e.jsx(ys,{delay:0,closeOnClick:!1,"aria-label":s,onClick:()=>r(!0),className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md text-oai-gray-400 transition-colors hover:bg-oai-gray-100 hover:text-oai-gray-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-gray-500/40 dark:hover:bg-oai-gray-800 dark:hover:text-oai-gray-200",children:e.jsx(jt,{size:14,"aria-hidden":!0})}),e.jsx(vs,{children:e.jsx(js,{side:"bottom",sideOffset:6,className:"z-[110]",children:e.jsx(ks,{role:"tooltip",className:"max-w-[min(320px,calc(100vw-2rem))] rounded-lg border border-oai-gray-200 bg-white px-3 py-2 text-xs leading-5 text-oai-gray-600 shadow-lg dark:border-oai-gray-700 dark:bg-oai-gray-900 dark:text-oai-gray-300",children:t})})})]})}function yn(t){return typeof t!="string"||!t.trim()?a("cloud.devices.platform_unknown"):/^(mac|darwin)/i.test(t)?a("leaderboard.community.modal.platform.darwin"):/^win/i.test(t)?a("leaderboard.community.modal.platform.win32"):/^linux/i.test(t)?a("leaderboard.community.modal.platform.linux"):t}function vn(t,s){if(!t)return null;const n=t.status==="active"&&t.access_source==="gift";if(s&&Number.isFinite(Date.parse(s))){const r=t.status==="transition"?"cloud.membership.transition_until":t.status==="trial"?"cloud.membership.trial_until":t.status==="active"?n?"cloud.membership.gift_until":"cloud.membership.active_until":t.status==="expired"&&Date.parse(s)<=Date.now()?"cloud.membership.expired_on":null;if(r)return a(r,{date:H(s)})}return n?a("cloud.gift.membership_label"):Ae(t.status)}function jn({auth:t,machineLimit:s,accountRevision:n,selfHosted:r=!1}){const[i,c]=o.useState(null),[g,l]=o.useState(null),[d,p]=o.useState(null),[h,m]=o.useState(!1),[j,w]=o.useState(null),x=o.useRef(!1),_=o.useRef(0),b=o.useRef(!0),u=t?.user?.id,y=t?.getAccessToken,k=o.useCallback(async()=>{const S=++_.current;try{let P;if(dt())try{const G=await ia(),J=await fetch("/functions/tokentracker-machine-id",{headers:G});J.ok&&(P=(await J.json())?.machineId)}catch{}const M=await ce("devices",{auth:y,params:P?{current_machine_id:P}:{}});S===_.current&&(c(M),l(null))}catch(P){S===_.current&&l({...P,code:"billing_devices_unavailable"})}},[y,u]);o.useEffect(()=>(b.current=!0,k(),()=>{b.current=!1,_.current+=1}),[k,n]);const f=async S=>{if(!x.current){x.current=!0,m(!0),l(null),w(null);try{if(await ce("remove-device",{auth:y,body:{machine_id:S}}),!b.current)return;i?.machines?.find(P=>P.machine_id===S)?.is_current&&We(),p(null),await k()}catch(P){b.current&&l(P)}finally{x.current=!1,m(!1)}}},N=async S=>{if(!x.current){x.current=!0,m(!0),l(null),w(null);try{if(await ce("resume-device",{auth:y,body:{machine_id:S.machine_id}}),!b.current)return;S.is_current&&We(),w(a("cloud.devices.resumed")),await k()}catch(P){b.current&&l(P)}finally{x.current=!1,m(!1)}}},E=i?.machines||[],v=i?.machine_count??E.filter(S=>S.status!=="paused").length,C=i?.machine_limit??s,O=C==null||v<C;return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx("h3",{className:"text-sm font-semibold",children:a("cloud.devices.title")}),e.jsx(bn,{label:a("cloud.devices.detail"),text:a("cloud.devices.detail")})]}),e.jsx("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 tabular-nums",children:i?C==null?a(r?"cloud.devices.unlimited_self_hosted":"cloud.devices.unlimited",{count:v}):a("cloud.devices.count",{count:v,limit:C}):g?a("cloud.devices.count_unknown"):a("cloud.catalog.loading")})]}),i?.over_machine_limit||C!=null&&C<v?e.jsx("div",{className:"mb-4",children:e.jsx(ee,{children:a("cloud.devices.over_limit")})}):null,g?e.jsx(ee,{error:g,onRetry:k,context:"account"}):null,j?e.jsx("div",{className:"mb-3",children:e.jsx(ee,{children:j})}):null,!g&&i&&E.length===0?e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.devices.empty")}):null,E.length!==0?e.jsx("ul",{className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800",children:E.map(S=>e.jsxs("li",{className:"py-1.5",children:[e.jsxs("div",{className:"grid grid-cols-[17px_minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1",children:[e.jsx(Ue,{size:17,className:"col-start-1 row-start-1 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0}),e.jsx("p",{title:S.name||a("cloud.devices.unnamed"),className:"col-start-2 row-start-1 min-w-0 truncate text-sm font-medium",children:S.name||a("cloud.devices.unnamed")}),e.jsxs("div",{className:"col-span-2 col-start-2 row-start-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-oai-gray-500 dark:text-oai-gray-400 sm:col-span-1 sm:col-start-2",children:[e.jsx("span",{children:yn(S.platform)}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:S.last_seen_at?a("cloud.devices.last_seen",{date:ra(S.last_seen_at)}):a("cloud.devices.last_seen_unknown")}),S.is_current?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:a("cloud.devices.current")})]}):null,S.status==="paused"?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:a("cloud.devices.paused")})]}):null]}),S.status==="paused"&&!O?e.jsx("p",{className:"col-start-2 row-start-3 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.devices.no_slot")}):null,e.jsxs(A,{variant:"ghost",size:"sm",className:"col-start-3 row-start-1 !min-h-10 !px-2 sm:row-span-2","aria-expanded":S.status!=="paused"?d===S.machine_id:void 0,"aria-controls":d===S.machine_id?`cloud-machine-confirm-${S.machine_id}`:void 0,onClick:()=>S.status==="paused"?N(S):p(P=>P===S.machine_id?null:S.machine_id),disabled:h||S.status==="paused"&&!O,children:[S.status==="paused"?e.jsx(fs,{size:14,className:"mr-1.5 shrink-0","aria-hidden":!0}):e.jsx(xs,{size:14,className:"mr-1.5 shrink-0","aria-hidden":!0}),S.status==="paused"?a("cloud.devices.resume"):a("cloud.devices.remove")]})]}),d===S.machine_id?e.jsxs("div",{id:`cloud-machine-confirm-${S.machine_id}`,className:"mt-3 rounded-lg bg-oai-gray-50 p-3 dark:bg-oai-gray-800",children:[e.jsx("p",{className:"text-xs leading-5",children:a("cloud.devices.remove_detail")}),e.jsxs("div",{className:"mt-3 flex gap-2",children:[e.jsx(A,{variant:"secondary",onClick:()=>f(S.machine_id),disabled:h,children:a("cloud.devices.confirm_remove")}),e.jsx(A,{variant:"ghost",onClick:()=>p(null),disabled:h,children:a("cloud.action.keep")})]})]}):null]},S.machine_id))}):null]})}function kn({recent:t,pendingOrders:s,conflictOrders:n,userId:r,payments:i=[],footerActions:c}){const g=ht(),[l,d]=o.useState(t?.order_id&&Ce.test(t.order_id)?t.order_id:""),[p,h]=o.useState(!1),[m,j]=o.useState(!1),w=o.useId(),x=o.useRef(null);o.useEffect(()=>{m&&x.current?.focus()},[m]);const _=new Set([...i.map(u=>u.order_id).filter(u=>typeof u=="string"),...(s||[]).filter(u=>u.status==="paid"||["paid","partially_refunded","refunded"].includes(u.payment_state)).map(u=>u.id)].map(u=>u.toLowerCase())),b=[...n||[],...(s||[]).filter(u=>u.retry_payment_conflict_at||!_.has(u.id.toLowerCase()))].filter((u,y,k)=>k.findIndex(f=>f.id===u.id)===y);return e.jsxs("div",{className:"mt-2 space-y-3",children:[t?.request_id&&!t.order_id?e.jsx(ye,{to:`/billing/checkout?sku=${encodeURIComponent(t.sku)}`,className:"mt-3 inline-flex min-h-10 items-center text-sm text-oai-brand underline underline-offset-4",children:a("cloud.action.resume_purchase")}):null,b.length||i.length?e.jsxs("div",{className:"sm:grid sm:grid-cols-[minmax(0,1fr)_auto_minmax(7rem,auto)] sm:gap-x-4",children:[e.jsxs("div",{"aria-hidden":!0,className:"hidden gap-x-4 pb-1 text-xs text-oai-gray-500 dark:text-oai-gray-400 sm:col-span-3 sm:grid sm:grid-cols-subgrid",children:[e.jsx("span",{children:a("cloud.history.date")}),e.jsx("span",{className:"text-right",children:a("cloud.history.amount")}),e.jsx("span",{className:"text-right",children:a("cloud.history.status")})]}),e.jsxs("ul",{className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800 sm:col-span-3 sm:grid sm:grid-cols-subgrid",children:[b.map(u=>{const y=typeof u.created_at=="string"&&Number.isFinite(Date.parse(u.created_at))?H(u.created_at):null;let k=null;Number.isInteger(u.amount_cents)&&u.amount_cents>=0&&["USD","CNY"].includes(u.currency)&&(k=Le(u.amount_cents,u.currency));const f=a(u.retry_payment_conflict_at?"cloud.action.review_duplicate_payment":"cloud.history.pending");return e.jsxs("li",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-1 py-3 sm:col-span-3 sm:grid-cols-subgrid",children:[e.jsx("p",{className:"col-start-1 row-start-1 text-sm tabular-nums",children:y||f}),e.jsx("p",{className:"col-start-2 row-start-1 text-right text-sm font-medium tabular-nums",children:k}),u.provider||y?e.jsxs("div",{className:"col-start-1 row-start-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[u.provider?e.jsx("span",{children:ft(u.provider)}):null,y?e.jsxs(e.Fragment,{children:[u.provider?e.jsx("span",{"aria-hidden":!0,children:"·"}):null,e.jsx("span",{children:f})]}):null]}):null,e.jsx(ye,{to:`/billing/checkout?order=${encodeURIComponent(u.id)}`,onClick:N=>{u.retry_payment_conflict_at||N.button!==0||N.metaKey||N.ctrlKey||N.shiftKey||N.altKey||!Ce.test(u.id)||(N.preventDefault(),g(Ke({orderId:u.id,userId:r})))},className:"col-start-2 row-start-2 inline-flex min-h-10 items-center justify-end rounded-sm text-right text-sm underline-offset-4 hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 sm:col-start-3 sm:row-span-2 sm:row-start-1 sm:self-start sm:items-start",children:e.jsx("span",{children:u.retry_payment_conflict_at?a("cloud.action.review_duplicate_payment"):a("cloud.action.resume_order")})})]},u.id)}),e.jsx(_n,{payments:i})]})]}):e.jsx(e.Fragment,{children:(!t?.request_id||t.order_id)&&e.jsx("p",{className:"py-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.history.empty")})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-1",children:[e.jsx(A,{variant:"ghost",size:"sm",className:"!h-10 !px-0","aria-expanded":m,"aria-controls":`${w}-panel`,onClick:()=>j(u=>!u),children:a("cloud.restore.title")}),c]}),m?e.jsxs("div",{id:`${w}-panel`,className:"mt-2",children:[e.jsx("p",{className:"text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.restore.detail")}),e.jsxs("form",{className:"mt-4",onSubmit:u=>{if(u.preventDefault(),!Ce.test(l.trim())){h(!0);return}const y=l.trim(),k=b.some(f=>f.id.toLowerCase()===y.toLowerCase()&&f.retry_payment_conflict_at);g(k?`/billing/checkout?order=${encodeURIComponent(y)}`:Ke({orderId:y,userId:r}))},children:[e.jsx("label",{htmlFor:`${w}-input`,className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.checkout.order_id")}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row",children:[e.jsx("input",{id:`${w}-input`,ref:x,value:l,onChange:u=>{d(u.target.value),h(!1)},placeholder:a("cloud.restore.placeholder"),className:"min-h-10 min-w-0 flex-1 rounded-md border border-oai-gray-300 bg-transparent px-3 text-sm outline-none focus:border-oai-brand focus:ring-2 focus:ring-inset focus:ring-oai-brand/30 dark:border-oai-gray-700","aria-invalid":p,"aria-describedby":p?`${w}-error`:void 0}),e.jsx(A,{type:"submit",variant:"secondary",children:a("cloud.action.restore")})]}),p?e.jsx("p",{id:`${w}-error`,role:"alert",className:"mt-2 text-xs text-red-600 dark:text-red-400",children:a("cloud.restore.invalid")}):null]})]}):null]})]})}function _n({payments:t}){return e.jsx(e.Fragment,{children:t.map(s=>e.jsxs("li",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-1 py-3 sm:col-span-3 sm:grid-cols-subgrid",children:[e.jsx("p",{className:"col-start-1 row-start-1 text-sm tabular-nums",children:H(s.paid_at)}),e.jsx("p",{className:"col-start-2 row-start-1 text-right text-sm font-medium tabular-nums",children:Le(s.amount_cents,s.currency)}),e.jsxs("div",{className:"col-start-1 row-start-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx("span",{children:ft(s.provider)}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{children:a("cloud.history.term",{start:H(s.starts_at),end:H(s.ends_at)})})]}),e.jsx("p",{className:`col-start-2 row-start-2 text-right text-sm font-medium sm:col-start-3 sm:row-span-1 sm:row-start-1 sm:self-start ${s.refunded_cents>0?"text-amber-700 dark:text-amber-400":"text-oai-gray-600 dark:text-oai-gray-300"}`,children:s.refunded_cents>0?a("cloud.history.refunded",{amount:Le(s.refunded_cents,s.currency)}):a("cloud.history.paid")})]},s.id))})}function wn({showTitle:t=!0,heading:s,syncControl:n,active:r=!0}){const i=aa();return e.jsx(Nn,{showTitle:t,heading:s,syncControl:n,active:r,...i},i.auth?.signedIn?i.auth.user?.id:"signed-out")}function Nn({account:t,auth:s,loading:n,error:r,refresh:i,showTitle:c,heading:g,syncControl:l,active:d=!0}){const{openLoginModal:p}=ut(),[h,m]=o.useState(null),[j,w]=o.useState(null),[x,_]=o.useState(!1),[b,u]=o.useState(null),y=o.useRef(!1),k=o.useRef(!0);o.useEffect(()=>{d||m(null)},[d]),o.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]);const f=t?.membership,N=f?.status==="self_hosted"||f?.hosting_mode==="self_hosted",E=[...t?.conflict_orders||[],...t?.pending_orders||[]].some(L=>L.retry_payment_conflict_at),v=!N&&t?.subscriptions?.find(L=>["active","trialing","past_due","paused","canceling"].includes(L.status)),C=!N&&(v?v.provider==="waffo":t?.payments?.some(L=>L.provider==="waffo")),O=v&&!v.cancel_at_period_end&&v.status!=="canceling",S=O&&v.status!=="paused",P=v?.next_billed_at,M=P&&Number.isFinite(Date.parse(P));o.useEffect(()=>{b&&t&&!O&&(u(null),w(null))},[t,b,O]);const G=N?null:f?.status==="trial"?f.trial_ends_at:f?.status==="transition"?f.transition_ends_at:f?.expires_at,J=async L=>{if(!y.current){y.current=!0,_(!0),w(null);try{await L()}catch(T){k.current&&w(T)}finally{y.current=!1,_(!1)}}},V=()=>J(async()=>{const L=await ce("portal",{auth:s.getAccessToken,body:v?{subscription_id:v.provider_subscription_id}:{}});k.current&&await Wa(L.url||L.portal_url)}),te=()=>J(async()=>{await ce("cancel",{auth:s.getAccessToken,body:{subscription_id:b}}),k.current&&(u(null),await i())}),$=vn(f,G),F=f?.status==="active"&&f?.access_source==="gift",K=C&&!v||f?.can_read_cloud||!N&&t?.gift_redemption_available===!0;if(!s?.signedIn)return e.jsx("div",{className:"space-y-4",children:e.jsx(Z,{title:g||(c?a("cloud.membership.title"):a("settings.section.cloud")),children:e.jsxs("div",{className:"flex flex-col gap-3 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4",children:[e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.membership.signed_out")}),e.jsx(A,{variant:"primary",size:"sm",onClick:()=>p({subtitle:a("cloud.membership.signed_out")}),children:a("cloud.action.sign_in_continue")})]})})});const q=g||(c?a("cloud.membership.title"):a("settings.section.cloud"));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("section",{"aria-label":a("cloud.membership.title"),className:"tt-cloud-theme space-y-3",children:[t?.environment==="sandbox"?e.jsx(ee,{children:a("cloud.catalog.sandbox")}):null,E?e.jsx(sa,{showBillingLink:!1}):null,e.jsxs(Z,{title:q,action:e.jsx(A,{onClick:i,variant:"ghost",size:"sm",className:"!h-8 !w-8 shrink-0 !p-0 text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white",disabled:n,"aria-label":a("cloud.action.refresh_membership"),children:e.jsx(De,{size:14,className:n?"motion-safe:animate-spin":void 0,"aria-hidden":!0})}),children:[e.jsx("div",{className:"pt-0.5 pb-2.5",children:F?e.jsxs("div",{className:"flex items-center gap-3.5",children:[e.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg border border-oai-gray-200 bg-oai-gray-50 text-oai-gray-700 dark:border-oai-gray-800 dark:bg-oai-gray-800/60 dark:text-oai-gray-300",children:e.jsx(Te,{className:"h-[30px] w-[30px]","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-white",children:a("cloud.gift.membership_label")}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-oai-gray-200 bg-oai-gray-50 px-2 py-0.5 text-[11px] font-medium text-oai-gray-700 dark:border-oai-gray-800 dark:bg-oai-gray-800/60 dark:text-oai-gray-300",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400"}),a("cloud.gift.state_active")]})]}),$&&$!==a("cloud.gift.membership_label")?e.jsx("p",{className:"mt-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:$}):null]})]}):e.jsxs("div",{className:"flex items-center gap-3.5",children:[e.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg border border-oai-gray-200 bg-oai-gray-50 text-oai-gray-700 dark:border-oai-gray-800 dark:bg-oai-gray-800/60 dark:text-oai-gray-300",children:e.jsx(fe,{className:"h-[30px] w-[30px]","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-oai-black dark:text-white",children:Ae(f?.status)}),f?.status==="active"?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-oai-gray-200 bg-oai-gray-50 px-2 py-0.5 text-[11px] font-medium text-oai-gray-700 dark:border-oai-gray-800 dark:bg-oai-gray-800/60 dark:text-oai-gray-300",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400"}),a("cloud.gift.state_active")]}):null]}),$&&$!==Ae(f?.status)?e.jsx("p",{className:"mt-1 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:$}):null]})]})}),f?.status==="expired"?e.jsx("p",{className:"py-2.5 text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:f.can_read_cloud?a("cloud.membership.read_only",{date:H(f.read_only_until)}):a("cloud.membership.expired_detail")}):null,f?e.jsx(na,{userId:s.user?.id,membership:f,subscriptions:t?.subscriptions,className:"py-2.5"}):null,!f&&n?e.jsx("p",{role:"status",className:"py-2.5 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:a("cloud.catalog.loading")}):null,v?e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3 py-2.5",children:e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("p",{className:"text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:v.status==="paused"?a("cloud.membership.renewal_paused"):v.status==="past_due"?a("cloud.membership.payment_due"):S?M?a("cloud.membership.renews",{date:H(P)}):a("cloud.membership.renewal_unknown"):a("cloud.membership.renewal_off")}),O?e.jsx(A,{"aria-expanded":!!b,"aria-controls":b?"cloud-cancel-confirm":void 0,onClick:()=>u(L=>L===v.provider_subscription_id?null:v.provider_subscription_id),variant:"ghost",size:"sm",className:"!h-8 !px-2 text-xs",disabled:x,children:a("cloud.action.cancel_renewal")}):null]})}):null,b?e.jsxs("div",{id:"cloud-cancel-confirm",className:"my-3 rounded-lg border border-oai-gray-200 p-4 dark:border-oai-gray-800",children:[e.jsx("p",{className:"text-sm leading-6",children:G?a("cloud.cancel.detail",{date:H(G)}):a("cloud.cancel.no_term")}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(A,{onClick:te,variant:"secondary",disabled:x,children:a("cloud.cancel.confirm")}),e.jsx(A,{onClick:()=>u(null),variant:"ghost",disabled:x,children:a("cloud.action.keep")})]})]}):null,r?e.jsx("div",{className:"py-2.5",children:e.jsx(ee,{error:r,onRetry:i,context:"account"})}):null,j&&h!=="billing"?e.jsx("div",{className:"py-2.5",children:e.jsx(ee,{error:j,context:"account"})}):null]})]}),f?e.jsx(st,{className:"tt-cloud-theme !rounded-lg",bodyClassName:"!py-3",children:e.jsx(jn,{auth:s,machineLimit:f.machine_limit,accountRevision:t,selfHosted:N})}):null,K||t&&!N||l?e.jsx(st,{className:"tt-cloud-theme !rounded-lg",bodyClassName:"!py-2",children:e.jsxs("section",{"aria-label":a("cloud.membership.tools_title"),className:"divide-y divide-oai-gray-200 dark:divide-oai-gray-800",children:[N?null:v?e.jsxs("button",{type:"button",onClick:V,disabled:x,className:"inline-flex h-11 w-full items-center gap-3 rounded-md border-0 bg-transparent p-0 text-left text-sm font-medium text-oai-black transition-colors hover:bg-oai-gray-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-oai-gray-500 disabled:opacity-50 dark:text-oai-white dark:hover:bg-oai-gray-800",children:[e.jsx(fe,{size:16,className:"shrink-0","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1",children:a("cloud.action.manage_subscription")}),e.jsx(nt,{size:16,className:"shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})]}):e.jsxs(ye,{to:"/cloud",className:"inline-flex h-11 w-full items-center gap-3 rounded-md border-0 bg-transparent p-0 text-left text-sm font-medium text-oai-black transition-colors hover:bg-oai-gray-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-oai-gray-500 dark:text-oai-white dark:hover:bg-oai-gray-800",children:[e.jsx(fe,{size:16,className:"shrink-0","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1",children:a("cloud.action.subscribe")}),e.jsx(mt,{size:16,className:"shrink-0 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})]}),t&&!N?e.jsxs($e,{open:h==="billing",onOpenChange:L=>m(L?"billing":null),title:a("cloud.billing.title"),icon:Cs,wide:!0,children:[j?e.jsx("div",{className:"mb-3",children:e.jsx(ee,{error:j,context:"account"})}):null,e.jsx(kn,{userId:s.user?.id,recent:Ka(s.user?.id),pendingOrders:t?.pending_orders,conflictOrders:t?.conflict_orders,payments:t.payments,footerActions:C&&!v?e.jsx("div",{className:"flex items-center gap-0.5",children:e.jsxs(A,{onClick:V,variant:"ghost",size:"sm",className:"!h-10 !px-0",disabled:x,children:[a("cloud.action.view_bills"),e.jsx(nt,{size:14,className:"ml-2","aria-hidden":!0})]})}):null})]}):null,f?.can_read_cloud?e.jsx(xn,{auth:s,layout:"settings-row",dialogOpen:h==="export",onDialogOpenChange:L=>m(L?"export":null)}):null,e.jsx(dn,{account:t,auth:s,refresh:i,layout:"settings-row",dialogOpen:h==="redeem",onDialogOpenChange:L=>m(L?"redeem":null)}),l?e.jsx("section",{children:l}):null]})}):null]})}function Sn({settings:t,active:s=!0}={}){return t?e.jsx(Tt,{settings:t,active:s}):e.jsx(Cn,{active:s})}function Cn({active:t}){const s=Me();return e.jsx(Tt,{settings:s,active:t})}function Tt({settings:t,active:s}){return e.jsx(wn,{showTitle:!1,active:s,syncControl:t.showLocalCloudSync?e.jsx(En,{settings:t}):null})}function En({settings:t}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3",children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-3 text-sm font-medium",children:[e.jsx(De,{size:16,className:"shrink-0","aria-hidden":!0}),a("settings.account.cloudSync")]}),e.jsx("span",{className:"tt-cloud-theme tt-cloud-sync-control inline-flex","aria-busy":t.cloudSyncPending||void 0,children:e.jsx(z,{checked:t.cloudSyncOn,disabled:t.cloudSyncPending,onChange:()=>(t.cloudSyncOn?Ye(t.userId):oa(t.userId,"sync"),t.handleCloudSyncToggle()),ariaLabel:a("settings.account.cloudSync")})})]}),t.cloudSyncOn&&t.cloudSyncPending?e.jsxs("p",{role:"status",className:"flex items-center gap-2 py-3 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(xe,{size:14,className:"motion-safe:animate-spin","aria-hidden":!0}),a("settings.account.cloudSyncPending")]}):null,t.cloudSyncOn&&t.cloudSyncError&&!t.cloudSyncPending?e.jsx("div",{className:"tt-cloud-theme py-3",children:e.jsx(ee,{role:"alert",onRetry:t.handleCloudSyncRetry,children:a("settings.account.cloudSyncError")})}):null,e.jsx(la,{userId:t.userId,panel:"sync",localHost:!0,className:"py-3",onContinueLocal:()=>{Ye(t.userId),t.cloudSyncOn&&t.handleCloudSyncDisable()}})]})}function Pn(){return[{value:"light",label:a("settings.appearance.theme.light"),Icon:da},{value:"dark",label:a("settings.appearance.theme.dark"),Icon:ua},{value:"system",label:a("settings.appearance.theme.system"),Icon:Ue}]}function On(){return[{value:pa,label:a("settings.appearance.language.system")},{value:ha,label:a("settings.appearance.language.english")},{value:fa,label:a("settings.appearance.language.chinese")},{value:xa,label:a("settings.appearance.language.traditional_chinese")},{value:ba,label:a("settings.appearance.language.japanese")},{value:ya,label:a("settings.appearance.language.korean")},{value:va,label:a("settings.appearance.language.german")}]}function An(t){if(!t)return null;try{const s=new Date(t);return Number.isNaN(s.getTime())?null:s.toLocaleString()}catch{return null}}function Ln(t,s){const n=a(`settings.appearance.currency.rate_source.${t}`),r=An(s),i=r?a("settings.appearance.currency.rate_updated",{when:r}):a("settings.appearance.currency.rate_never");return`${n} · ${i}`}function Tn({locale:t,setLocale:s}){const n=On();return e.jsx(ze,{value:t,onValueChange:s,options:n,ariaLabel:a("settings.appearance.language.label"),className:"px-2.5 py-1.5 text-xs font-medium",leadingIcon:e.jsx(Os,{className:"h-3.5 w-3.5 text-oai-gray-500 dark:text-oai-gray-400","aria-hidden":!0})})}function Rn({currency:t,setCurrency:s}){const n=ma().map(r=>({value:r.code,label:a(r.labelKey)}));return e.jsx(ze,{value:t,onValueChange:s,options:n,ariaLabel:a("settings.appearance.currency.label"),className:"px-3 py-1.5 text-xs font-medium"})}function In({currency:t,rate:s,rateSource:n,rateFetchedAt:r}){if(t===ga)return e.jsx(e.Fragment,{children:a("settings.appearance.currency.hint")});const i=Ln(n,r);return e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:`1 USD = ${s.toFixed(4)} ${t}`}),e.jsx("span",{role:"img","aria-label":i,title:i,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:e.jsx(jt,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})}function Dn(){const{theme:t,setTheme:s}=ca(),{locale:n,setLocale:r}=xt(),{currency:i,rate:c,rateSource:g,rateFetchedAt:l,setCurrency:d}=_s(),{mode:p,setMode:h,unitSystem:m,setUnitSystem:j,grouping:w,setGrouping:x}=ws();return e.jsxs(Z,{title:a("settings.section.appearance"),children:[e.jsx(R,{label:a("settings.appearance.theme.label"),hint:a("settings.appearance.theme.hint"),control:e.jsx(se,{options:Pn(),value:t,onChange:s})}),e.jsx(R,{label:a("settings.appearance.language.label"),hint:a("settings.appearance.language.hint"),control:e.jsx(Tn,{locale:n,setLocale:r})}),e.jsx(R,{label:a("settings.appearance.currency.label"),hint:e.jsx(In,{currency:i,rate:c,rateSource:g,rateFetchedAt:l}),control:e.jsx(Rn,{currency:i,setCurrency:d})}),e.jsx(R,{label:a("settings.appearance.token_format.label"),hint:a("settings.appearance.token_format.hint"),control:e.jsx(se,{options:[{value:Se.COMPACT,label:a("settings.appearance.token_format.compact")},{value:Se.FULL,label:a("settings.appearance.token_format.full")}],value:p,onChange:h})}),e.jsx(R,{label:a("settings.appearance.token_unit.label"),hint:a("settings.appearance.token_unit.hint"),control:e.jsx(se,{disabled:p!==Se.COMPACT,options:[{value:Ze.ENGLISH,label:a("settings.appearance.token_unit.english")},{value:Ze.CHINESE,label:a("settings.appearance.token_unit.chinese")}],value:m,onChange:j})}),e.jsx(R,{label:a("settings.appearance.token_grouping.label"),hint:a("settings.appearance.token_grouping.hint"),control:e.jsx(se,{options:[{value:Je.THOUSAND,label:a("settings.appearance.token_grouping.thousand")},{value:Je.WAN,label:a("settings.appearance.token_grouping.wan")}],value:w,onChange:x})})]})}function Ee({labelKey:t}){return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:a(t)}),e.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 Un(){const{enabled:t,toggle:s}=Fa(),{enabled:n,toggle:r}=Ba(),{available:i,settings:c,setSetting:g}=je(),l=i&&!!c?.dynamicIslandSupported,d=!!c?.dynamicIslandEnabled;return e.jsxs(Z,{title:a("settings.section.labs"),children:[l&&e.jsxs(e.Fragment,{children:[e.jsx(R,{label:e.jsx(Ee,{labelKey:"settings.labs.island.label"}),hint:a("settings.labs.island.hint"),control:e.jsx(z,{checked:d,onChange:()=>g("dynamicIslandEnabled",!d),ariaLabel:a("settings.labs.island.aria")})}),d&&e.jsx(R,{label:a("settings.labs.island_hide_menubar.label"),hint:a("settings.labs.island_hide_menubar.hint"),control:e.jsx(z,{checked:!!c?.hideMenuBarIcon,onChange:()=>g("hideMenuBarIcon",!c?.hideMenuBarIcon),ariaLabel:a("settings.labs.island_hide_menubar.aria")})})]}),e.jsx(R,{label:e.jsx(Ee,{labelKey:"settings.labs.qpd.label"}),hint:a("settings.labs.qpd.hint"),control:e.jsx(z,{checked:t,onChange:s,ariaLabel:a("settings.labs.qpd.aria")})}),e.jsx(R,{label:e.jsx(Ee,{labelKey:"settings.labs.sessions.label"}),hint:a("settings.labs.sessions.hint"),control:e.jsx(z,{checked:n,onChange:r,ariaLabel:a("settings.labs.sessions.aria")})})]})}function zn(){const{available:t,settings:s,setSetting:n,runAction:r}=je();if(!t)return null;const i=bt(),c=!!s?.launchAtLogin,g=s?.toastOnReset!==!1,l=s?.confettiOnReset!==!1,d=s?.launchAtLoginSupported!==!1,p=s?.autoUpdateEnabled!==!1,h=s?.updateStatus||null,m=!!s?.updateBusy,j=!!s?.isSyncing;return e.jsxs(Z,{title:a("settings.section.menubar"),children:[i?null:e.jsxs(e.Fragment,{children:[e.jsx(R,{label:a("settings.menubar.appearance"),hint:a("settings.menubar.appearanceHint"),control:e.jsxs(A,{as:ye,to:"/widgets",variant:"secondary",size:"sm",className:"gap-1.5 no-underline",children:[e.jsx("span",{children:a("settings.menubar.appearanceLink")}),e.jsx(Ss,{className:"h-3.5 w-3.5","aria-hidden":!0})]})}),e.jsx(R,{label:a("settings.menubar.toastOnReset"),hint:a("settings.menubar.toastOnResetHint"),control:e.jsx(z,{checked:g,onChange:()=>n("toastOnReset",!g),ariaLabel:a("settings.menubar.toastOnReset")})}),e.jsx(R,{label:a("settings.menubar.confettiOnReset"),hint:a("settings.menubar.confettiOnResetHint"),control:e.jsx(z,{checked:l,onChange:()=>n("confettiOnReset",!l),ariaLabel:a("settings.menubar.confettiOnReset")})})]}),d?e.jsx(R,{label:a("settings.menubar.launchAtLogin"),hint:a("settings.menubar.launchAtLoginHint"),control:e.jsx(z,{checked:c,onChange:()=>n("launchAtLogin",!c),ariaLabel:a("settings.menubar.launchAtLogin")})}):null,e.jsx(R,{label:a("settings.menubar.syncNow"),hint:a("settings.menubar.syncNowHint"),control:e.jsxs(A,{variant:"secondary",size:"sm",onClick:()=>r("syncNow"),disabled:j,className:"gap-1.5",children:[e.jsx(De,{className:le("h-3.5 w-3.5",j&&"animate-spin"),"aria-hidden":!0}),e.jsx("span",{children:j?a("settings.menubar.syncing"):a("settings.menubar.syncNow")})]})}),e.jsx(R,{label:a("settings.menubar.autoUpdate"),hint:a("settings.menubar.autoUpdateHint"),control:e.jsx(z,{checked:p,onChange:()=>n("autoUpdateEnabled",!p),ariaLabel:a("settings.menubar.autoUpdate")})}),e.jsx(R,{label:a("settings.menubar.updates"),hint:h||void 0,control:e.jsxs(A,{variant:"secondary",size:"sm",onClick:()=>r("checkForUpdates"),disabled:m,className:"gap-1.5",children:[e.jsx(Ie,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.jsx("span",{children:a("settings.menubar.checkUpdates")})]})})]})}function Gn(t,s){function n(c){return c.replace(/^v/,"").split(".").map(Number)}const r=n(t),i=n(s);for(let c=0;c<Math.max(r.length,i.length);c++){const g=r[c]||0,l=i[c]||0;if(g<l)return!0;if(g>l)return!1}return!1}function Mn(){const{available:t,settings:s,runAction:n}=je(),r=t&&s?.version,i=s?.platform||"macos",[c,g]=Pe.useState(!1),[l,d]=Pe.useState({open:!1,latestVersion:"",htmlUrl:""}),{resolvedLocale:p}=xt(),h="1.3.13",m=async()=>{g(!0);try{const b=await fetch("https://api.github.com/repos/xiufengsun/TokenTracker/releases/latest");if(!b.ok)throw new Error("Failed to fetch");const u=await b.json(),y=u.tag_name;Gn(h,y)?d({open:!0,latestVersion:y,htmlUrl:u.html_url}):Xe({title:a("settings.menubar.updates.upToDate")})}catch(b){console.error("Check updates failed:",b),Xe({title:a("settings.menubar.updates.failed")})}finally{g(!1)}},j=a("settings.menubar.updates.modalTitle"),w=a("settings.menubar.updates.modalDescription",{version:l.latestVersion}),x=a("settings.menubar.updates.modalConfirm"),_=a("settings.menubar.updates.modalCancel");return e.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:[e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[r?e.jsxs(e.Fragment,{children:[e.jsx("span",{children:i==="windows"?a("settings.menubar.updates.footerCore",{version:s.version}):a("settings.menubar.updates.footerCombined",{barVersion:s.version,coreVersion:h})}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("button",{type:"button",onClick:()=>n("openAbout"),className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300",children:"GitHub"}),e.jsx("span",{"aria-hidden":!0,children:"·"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:a("settings.menubar.updates.footerCore",{version:h})}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("button",{type:"button",onClick:m,disabled:c,className:"underline-offset-2 transition-colors hover:text-oai-gray-700 hover:underline dark:hover:text-oai-gray-300 disabled:opacity-50",children:c?a("settings.menubar.updates.checking"):a("settings.menubar.checkUpdates")}),e.jsx("span",{"aria-hidden":!0,children:"·"})]}),e.jsxs("a",{href:ja,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:[e.jsx(ka,{className:"h-3.5 w-3.5","aria-hidden":!0}),a("settings.footer.statusPage")]})]}),e.jsx(Ns,{open:l.open,title:j,description:w,confirmLabel:x,cancelLabel:_,onConfirm:()=>{window.open(l.htmlUrl,"_blank"),d(b=>({...b,open:!1}))},onCancel:()=>d(b=>({...b,open:!1}))})]})}const $n=()=>[{value:"system",label:a("settings.network.mode.system")},{value:"manual",label:a("settings.network.mode.manual")},{value:"off",label:a("settings.network.mode.off")}],Fn=()=>[{value:"http",label:a("settings.network.protocol.http")},{value:"https",label:a("settings.network.protocol.https")},{value:"socks5",label:a("settings.network.protocol.socks5")}];function rt(t){const s={},n=String(t.host||"").trim();(!n||/:\/\//.test(n)||n.includes("/"))&&(s.host=a("settings.network.error.host"));const r=String(t.port??"").trim(),i=Number(r);return(!r||!/^\d+$/.test(r)||!Number.isInteger(i)||i<1||i>65535)&&(s.port=a("settings.network.error.port")),s}function Bn({proxySettings:t}){const{config:s,save:n,testConnection:r}=t,[i,c]=o.useState(()=>({mode:s.mode,protocol:s.protocol||"http",host:s.host||"",port:s.port||""})),[g,l]=o.useState({}),[d,p]=o.useState(!1),[h,m]=o.useState(""),[j,w]=o.useState(null),[x,_]=o.useState(!1),[b,u]=o.useState(null);o.useEffect(()=>{c({mode:s.mode,protocol:s.protocol||"http",host:s.host||"",port:s.port||""})},[s.mode,s.protocol,s.host,s.port]);const y=o.useMemo(()=>s.effective==="manual"?a("settings.network.effective.manual"):s.effective==="env"?a("settings.network.effective.env"):s.effective==="system"?a("settings.network.effective.system"):s.effective==="blocked"?a("settings.network.effective.blocked"):a("settings.network.effective.none"),[s.effective]),k=o.useMemo(()=>i.mode!==s.mode?!0:i.mode==="manual"?(i.protocol||"http")!==(s.protocol||"http")||(i.host||"")!==(s.host||"")||String(i.port??"")!==String(s.port??""):!1,[i,s]),f=v=>{c(C=>({...C,...v})),l({}),m(""),w(null),u(null)},N=async()=>{if(i.mode==="manual"){const v=rt(i);if(Object.keys(v).length){l(v);return}}p(!0),m(""),w(null);try{await n(i),m("saved")}catch(v){m("error"),w(v)}finally{p(!1)}},E=async()=>{const v=rt(i);if(Object.keys(v).length){l(v);return}_(!0),u(null);try{const C=await r(i);u(C)}catch(C){u({ok:!1,error:C?.message||String(C)})}finally{_(!1)}};return e.jsxs(Z,{title:a("settings.section.network"),subtitle:y,children:[s.applyError?e.jsx("p",{role:"alert",className:"mb-3 text-xs text-red-600 dark:text-red-400",children:a("settings.network.apply_error",{error:s.applyError})}):null,e.jsx(R,{label:a("settings.network.mode.label"),hint:a("settings.network.mode.hint"),control:e.jsx(se,{options:$n(),value:i.mode,onChange:v=>f({mode:v})})}),e.jsx(vt,{initial:!1,children:i.mode==="manual"?e.jsxs(yt.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(R,{label:a("settings.network.protocol.label"),control:e.jsx(ze,{value:i.protocol,onValueChange:v=>f({protocol:v}),options:Fn(),ariaLabel:a("settings.network.protocol.label"),className:"px-2.5 py-1.5 text-xs font-medium"})}),e.jsx(R,{label:a("settings.network.host.label"),hint:g.host,control:e.jsx("input",{type:"text",value:i.host,onChange:v=>f({host:v.target.value}),placeholder:a("settings.network.host.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":g.host?!0:void 0,"aria-label":a("settings.network.host.label"),className:ve})}),e.jsx(R,{label:a("settings.network.port.label"),hint:g.port,control:e.jsx("input",{type:"text",inputMode:"numeric",value:i.port,onChange:v=>f({port:v.target.value}),placeholder:a("settings.network.port.placeholder"),autoComplete:"off",spellCheck:!1,"aria-invalid":g.port?!0:void 0,"aria-label":a("settings.network.port.label"),className:ve})}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 py-3",children:[e.jsx(A,{variant:"secondary",size:"sm",onClick:E,disabled:x||d,className:"gap-1.5",children:x?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}),e.jsx("span",{children:a("settings.network.test.testing")})]}):a("settings.network.test")}),e.jsx(A,{variant:"primary",size:"sm",onClick:N,disabled:d||x,className:"gap-1.5",children:d?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}),e.jsx("span",{children:a("settings.network.saving")})]}):a("settings.network.save")})]}),b?e.jsx("p",{className:"py-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:b.ok?a("settings.network.test.ok",{status:String(b.status??"")}):a("settings.network.test.fail",{error:b.error||""})}):null]},"manual-proxy-fields"):null}),i.mode!=="manual"&&(k||d)?e.jsx("div",{className:"flex justify-end py-3",children:e.jsx(A,{variant:"primary",size:"sm",onClick:N,disabled:d,className:"gap-1.5",children:d?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}),e.jsx("span",{children:a("settings.network.saving")})]}):a("settings.network.save")})},"non-manual-save"):null,h==="saved"?e.jsx("p",{className:"py-2 text-xs text-emerald-600 dark:text-emerald-400",children:a("settings.network.saved")}):null,h==="error"?e.jsx("p",{role:"alert",className:"py-2 text-xs text-red-600 dark:text-red-400",children:j?.unprotected?a("settings.network.save_error_unprotected",{error:j?.message||String(j||"")}):a("settings.network.save_error",{error:j?.message||String(j||"")})}):null]})}const Rt="/functions/tokentracker-proxy-config",Hn="/functions/tokentracker-proxy-test",Vn={mode:"system",protocol:"http",host:"",port:"",effective:"none",applyError:null};function It(t){return!t||typeof t.mode!="string"?null:{mode:t.mode,protocol:typeof t.protocol=="string"?t.protocol:"http",host:typeof t.host=="string"?t.host:"",port:t.port==null||t.port===0?"":String(t.port),effective:typeof t.effective=="string"?t.effective:"none",applyError:typeof t.applyError=="string"&&t.applyError.trim()?t.applyError:null}}async function qn(){const t=await fetch(Rt,{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!t.ok)return null;const s=await t.json().catch(()=>null);return It(s)}async function ot(){const{getLocalApiAuthHeaders:t}=await _a(async()=>{const{getLocalApiAuthHeaders:s}=await import("./__vite-browser-external-CPskAZuH.js").then(n=>n.dY);return{getLocalApiAuthHeaders:s}},__vite__mapDeps([0,1]));return t()}function Kn(){const[t,s]=o.useState(!1),[n,r]=o.useState(!0),[i,c]=o.useState(Vn);o.useEffect(()=>{if(!qa()){s(!1),r(!1);return}let d=!1;return(async()=>{try{const p=await qn();if(d)return;if(!p){s(!1),r(!1);return}c(p),s(!0),r(!1)}catch{d||(s(!1),r(!1))}})(),()=>{d=!0}},[]);const g=o.useCallback(async d=>{const p=await ot(),h=await fetch(Rt,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...p},cache:"no-store",body:JSON.stringify({mode:d.mode,protocol:d.protocol,host:d.host,port:d.port===""?0:Number(d.port)})}),m=await h.json().catch(()=>null);if(!h.ok){const w=m&&typeof m.error=="string"?m.error:`HTTP ${h.status}`;throw new Error(w)}const j=It(m);if(j&&c(j),m&&m.ok===!1){const w=m&&typeof m.applyError=="string"&&m.applyError||m&&typeof m.error=="string"&&m.error||`HTTP ${h.status}`,x=new Error(w);throw m.unprotected===!0&&(x.unprotected=!0),x}return j||m},[]),l=o.useCallback(async d=>{const p=await ot(),h=await fetch(Hn,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...p},cache:"no-store",body:JSON.stringify({protocol:d.protocol,host:d.host,port:d.port===""?0:Number(d.port)})}),m=await h.json().catch(()=>null);if(!m||typeof m.ok!="boolean")throw new Error(m&&typeof m.error=="string"?m.error:`HTTP ${h.status}`);return m},[]);return{available:t,loading:n,config:i,save:g,testConnection:l}}const B={APPEARANCE:"appearance",NATIVE_APP:"native-app",NETWORK:"network",ACCOUNT:"account",CLOUD:"cloud",LIMITS:"limits",LABS:"labs"},Y={PERSONAL:"personal",APP:"app",DEVELOPER:"developer"};function Wn({prefs:t}){return e.jsx(se,{options:[{value:at.USED,label:a("limits.settings.display_mode_used")},{value:at.REMAINING,label:a("limits.settings.display_mode_remaining")}],value:t.displayMode,onChange:t.setDisplayMode})}function Ti(){const t=Me(),s=Ga(),{available:n,settings:r,setSetting:i}=je(),c=Kn(),{available:g}=c,l=r?.toastOnReset!==!1,d=r?.confettiOnReset!==!1,p=bt()||r?.platform==="windows",[h,m]=wa(),j=ht(),w=h.get("section"),_=Object.values(B).includes(w)&&(w!==B.NATIVE_APP||n)&&(w!==B.NETWORK||g)?w:B.APPEARANCE,b=k=>{const f=new URLSearchParams(h);k===B.APPEARANCE?f.delete("section"):f.set("section",k),m(f,{replace:!0})},u=[{id:B.APPEARANCE,label:a("settings.section.appearance"),description:a("settings.section.appearance.description"),group:Y.PERSONAL,Icon:Ls,content:e.jsx(Dn,{})},...n?[{id:B.NATIVE_APP,label:a("settings.section.menubar"),description:a("settings.section.menubar.description"),group:Y.APP,Icon:Ue,content:e.jsx(zn,{})}]:[],...g?[{id:B.NETWORK,label:a("settings.section.network"),description:a("settings.section.network.description"),group:Y.APP,Icon:Na,content:e.jsx(Bn,{proxySettings:c})}]:[],{id:B.ACCOUNT,label:a("settings.section.account"),description:a("settings.section.account.description"),group:Y.PERSONAL,Icon:Ts,content:e.jsx(sn,{settings:t})},{id:B.CLOUD,label:a("settings.section.cloud"),description:a("settings.section.cloud.description"),group:Y.PERSONAL,Icon:fe,content:e.jsx(Sn,{settings:t,active:_===B.CLOUD})},{id:B.LIMITS,label:a("settings.section.limits"),description:a("settings.section.limits.description"),group:Y.APP,Icon:Sa,content:e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Z,{title:a("settings.section.limits"),children:[e.jsx(R,{label:a("limits.settings.display_mode_label"),control:e.jsx(Wn,{prefs:s})}),p?null:e.jsxs(e.Fragment,{children:[e.jsx(R,{label:a("settings.menubar.toastOnReset"),hint:a("settings.menubar.toastOnResetHint"),control:e.jsx(z,{checked:l,disabled:!n,onChange:()=>i("toastOnReset",!l),ariaLabel:a("settings.menubar.toastOnReset")})}),e.jsx(R,{label:a("settings.menubar.confettiOnReset"),hint:a("settings.menubar.confettiOnResetHint"),control:e.jsx(z,{checked:d,disabled:!n,onChange:()=>i("confettiOnReset",!d),ariaLabel:a("settings.menubar.confettiOnReset")})})]}),e.jsx(R,{label:a("settings.limits.showSubscriptions"),hint:a("settings.limits.showSubscriptionsHint"),control:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(A,{variant:"secondary",size:"sm",onClick:()=>j("/limits?openSubscriptions=1"),"aria-label":a("limits.page.openSubscriptions"),title:a("limits.page.openSubscriptions"),className:"!h-7 !w-7 !p-0 text-oai-gray-500 hover:text-oai-black dark:text-oai-gray-400 dark:hover:text-white",children:e.jsx(Ca,{size:14,"aria-hidden":!0})}),e.jsx(z,{checked:s.showSubscriptions!==!1,onChange:()=>s.setShowSubscriptions(!s.showSubscriptions),ariaLabel:a("settings.limits.showSubscriptions")})]})})]}),e.jsx(Z,{title:a("settings.limits.providers"),children:e.jsx(Us,{prefs:s})})]})},{id:B.LABS,label:a("settings.section.labs"),description:a("settings.section.labs.description"),group:Y.DEVELOPER,Icon:Es,content:e.jsx(Un,{})}],y=[{id:Y.PERSONAL,label:a("settings.nav.group.personal")},{id:Y.APP,label:a("settings.nav.group.app")},{id:Y.DEVELOPER,label:a("settings.nav.group.developer")}].map(k=>({...k,sections:u.filter(f=>f.group===k.id)})).filter(k=>k.sections.length>0);return e.jsx("div",{className:le("flex flex-1 flex-col font-oai text-oai-black antialiased dark:text-oai-white",_===B.CLOUD&&"tt-cloud-settings"),children:e.jsx("main",{className:"flex-1 pb-12 pt-8 sm:pb-16 sm:pt-10",children:e.jsxs("div",{className:"mx-auto w-full max-w-5xl px-4 sm:px-6",children:[e.jsxs("div",{className:"mb-7 max-w-2xl",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("settings.page.title")}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400 sm:text-base",children:a("settings.page.subtitle")})]}),e.jsxs("div",{className:"tt-settings-sections grid min-w-0 gap-6 md:grid-cols-[11rem_minmax(0,1fr)] md:gap-8",children:[e.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:e.jsx("nav",{"aria-label":a("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:y.map(({id:k,label:f,sections:N})=>e.jsxs("div",{className:"flex shrink-0 gap-1 md:block",children:[e.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:f}),e.jsx("div",{className:"flex gap-1 md:flex-col",children:N.map(({id:E,label:v,Icon:C})=>{const O=_===E;return e.jsxs("button",{id:`settings-nav-${E}`,type:"button","aria-current":O?"page":void 0,"aria-controls":`settings-panel-${E}`,onClick:()=>b(E),className:le("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",O?"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:[e.jsx(C,{className:le("h-4 w-4 shrink-0",O?"text-oai-black dark:text-white":"text-oai-gray-400 dark:text-oai-gray-500"),"aria-hidden":!0}),e.jsx("span",{className:"truncate",children:v})]},E)})})]},k))})}),e.jsxs("div",{className:"min-w-0",children:[u.map(({id:k,label:f,content:N})=>e.jsx("section",{id:`settings-panel-${k}`,"aria-labelledby":`settings-nav-${k}`,"aria-label":f,"data-settings-panel":k,hidden:_!==k,children:N},k)),e.jsx(Mn,{})]})]})]})})})}export{Ti as SettingsPage};
|