tokmon 0.29.4 → 0.29.5
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/dist/{bootstrap-ink-MPWICEIJ.js → bootstrap-ink-VORCPVK4.js} +38 -21
- package/dist/{chunk-AUUBRLBG.js → chunk-3SXVUTV2.js} +2 -2
- package/dist/{chunk-BLUQGJKM.js → chunk-6NJLM5IZ.js} +2 -2
- package/dist/{chunk-BYLWQ46U.js → chunk-6RPYSOBA.js} +6 -3
- package/dist/{chunk-WPZTPMBX.js → chunk-EZHV4R74.js} +20 -8
- package/dist/{chunk-G2A3DVPU.js → chunk-GQCFGAQ6.js} +40 -10
- package/dist/{chunk-5Q5HUOP4.js → chunk-LAJV5JMV.js} +160 -133
- package/dist/{chunk-3D6TO5TS.js → chunk-U2FQXNIU.js} +98 -66
- package/dist/{chunk-YWDMEU3L.js → chunk-UD2IPQK3.js} +1 -1
- package/dist/{cli-command-WL2K5WWR.js → cli-command-X75NGQON.js} +6 -6
- package/dist/cli.js +6 -6
- package/dist/{config-B7QJQTU2.js → config-4JC6X5QT.js} +3 -1
- package/dist/{daemon-A3WGDRFT.js → daemon-O7TOISBH.js} +6 -6
- package/dist/daemon-handle-NBGZUDKE.js +11 -0
- package/dist/server-VWBW53QU.js +12 -0
- package/dist/web/assets/{Area-CEpf7_6d.js → Area-B3FdWS80.js} +1 -1
- package/dist/web/assets/{analytics-CdjcYtmK.js → analytics-DSLBg5Lx.js} +2 -2
- package/dist/web/assets/{breakdown-DM6g0evr.js → breakdown-B1vg0Xn1.js} +1 -1
- package/dist/web/assets/{button-Cu4co7ZR.js → button-CDipMD0w.js} +1 -1
- package/dist/web/assets/{chart-YlnVH1If.js → chart-BRXIwVtE.js} +1 -1
- package/dist/web/assets/{explore-kLpZWR-_.js → explore-DyJiyG0m.js} +1 -1
- package/dist/web/assets/index-CEXpTvdh.js +83 -0
- package/dist/web/assets/{models-XKfoWTDv.js → models-_DeHctpR.js} +2 -2
- package/dist/web/assets/{overview-DC-WVKZ6.js → overview-CmPN-0w3.js} +2 -2
- package/dist/web/assets/{panel-B_U9oe1x.js → panel-DzILyYlc.js} +1 -1
- package/dist/web/assets/settings-sheet-AfoLwoCy.js +1 -0
- package/dist/web/assets/{share-sheet-BaEXe1m9.js → share-sheet-Cfl7PIrk.js} +1 -1
- package/dist/web/assets/{timeline-ar9mdhcb.js → timeline-D_JPTxAw.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/daemon-handle-4E7RSSDB.js +0 -11
- package/dist/server-P6BRXBZ5.js +0 -12
- package/dist/web/assets/index-Dd37pBKy.js +0 -83
- package/dist/web/assets/settings-sheet-B7BuJ3j8.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{O as ae,Q as he,U as q,V as oe,j as e,r as x,F as f,n as C,W as K,Y as ge,Z as fe,$ as ve,a0 as F,a1 as W,a2 as je,a3 as ye,a4 as ke,e as Ne,P as we,a5 as ce,a6 as de,a7 as re,a8 as Ce,a9 as Se,aa as le,X as ue,ab as De,ac as Ie,ad as Ae,ae as Q,af as X,ag as $e,ah as Ee,ai as Pe,aj as xe,ak as me,al as G,am as ze,an as H,ao as Z,ap as Re,aq as Te,u as Be,ar as Le,as as Me,at as Fe,au as Oe,av as _e}from"./index-Dd37pBKy.js";import{B as L,D as pe}from"./button-Cu4co7ZR.js";function ie(t,a={}){return{mode:"add",editingId:null,providerId:a.providerId??ae[0],name:a.name??"",homeDir:a.homeDir??"~",color:a.color??he(t.accounts)}}function Ge(t){return{mode:"edit",editingId:t.id,providerId:t.providerId,name:t.name,homeDir:t.homeDir,color:t.color||q[t.providerId].color}}function Ue(t,a){const n=t.mode==="edit"?a.filter(s=>s.id!==t.editingId):a;return t.mode==="edit"?t.editingId??"":oe(t.name.trim()||"account",n)}function He(t,a){const n=t.name.trim(),s=t.homeDir.trim()||"~";return n?t.mode==="add"?{ok:!0,account:{id:oe(n,a),providerId:t.providerId,name:n,homeDir:s,color:t.color},mode:"add",editingId:null}:{ok:!0,account:{id:t.editingId,providerId:t.providerId,name:n,homeDir:s,color:t.color},mode:"edit",editingId:t.editingId}:{ok:!1,error:"Name required"}}function P({title:t,right:a,children:n}){return e.jsxs("section",{className:"mb-6 last:mb-0",children:[e.jsxs("div",{className:"mb-2.5 flex items-center gap-2 border-b border-line pb-1.5",children:[e.jsx("h3",{className:"font-display text-[11px] uppercase tracking-wider text-fg-dim",children:t}),a&&e.jsx("div",{className:"ml-auto",children:a})]}),n]})}function y({label:t,hint:a,children:n}){return e.jsxs("div",{className:"flex items-center gap-3 py-1.5",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm text-fg",children:t}),a&&e.jsx("div",{className:"text-[11px] text-fg-faint",children:a})]}),e.jsx("div",{className:"shrink-0",children:n})]})}function U({label:t,hint:a,children:n}){return e.jsxs("div",{children:[e.jsx("div",{className:"mb-1.5 text-xs font-medium text-fg",children:t}),n,a&&e.jsx("div",{className:"mt-1 text-[11px] text-fg-faint",children:a})]})}function te({label:t,value:a,min:n,unit:s,onChange:u}){const o=r=>u(Math.max(n,Math.round(r))),[b,g]=x.useState(null),v=()=>{if(b===null)return;const r=Number(b);o(Number.isFinite(r)&&b.trim()!==""?r:n),g(null)};return e.jsxs("div",{className:"flex items-center overflow-hidden rounded border border-line",children:[e.jsx("button",{type:"button","aria-label":"decrease",onClick:()=>o(a-1),className:`px-2 py-1 text-xs text-fg-dim transition hover:bg-bg-3 hover:text-fg ${f}`,children:"−"}),e.jsx("input",{type:"number",name:t.toLowerCase().replace(/\s+/g,"-"),autoComplete:"off",inputMode:"numeric",min:n,value:b??a,onChange:r=>{const l=r.target.value;g(l);const d=Number(l);l.trim()!==""&&Number.isFinite(d)&&d>=n&&o(d)},onBlur:v,"aria-label":`${t} (${s})`,className:`tnum w-12 border-x border-line bg-bg-2 px-1 py-1 text-center text-xs text-fg ${f} [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none`}),e.jsx("span",{className:"px-1.5 text-[10px] text-fg-faint",children:s}),e.jsx("button",{type:"button","aria-label":"increase",onClick:()=>o(a+1),className:`px-2 py-1 text-xs text-fg-dim transition hover:bg-bg-3 hover:text-fg ${f}`,children:"+"})]})}function R({label:t,onClick:a,disabled:n,danger:s,children:u}){return e.jsx("button",{type:"button","aria-label":t,title:t,disabled:n,onClick:a,className:`rounded p-1 text-fg-faint transition disabled:opacity-30 ${f} ${s?"hover:bg-critical/15 hover:text-critical":"hover:bg-bg-3 hover:text-fg"} disabled:hover:bg-transparent disabled:hover:text-fg-faint`,children:u})}function Ve({draft:t,patch:a}){return e.jsxs(P,{title:"General",children:[e.jsx(y,{label:"Refresh interval",hint:"dashboard poll, seconds",children:e.jsx(te,{label:"Refresh interval",value:t.interval,min:1,unit:"s",onChange:n=>a(s=>({...s,interval:n}))})}),e.jsx(y,{label:"Billing poll",hint:"billing refresh, minutes",children:e.jsx(te,{label:"Billing poll",value:t.billingInterval,min:1,unit:"m",onChange:n=>a(s=>({...s,billingInterval:n}))})}),e.jsx(y,{label:"Clear screen",hint:"redraw on each refresh",children:e.jsx(C,{size:"xs",ariaLabel:"clear screen",options:[{value:"on",label:"on"},{value:"off",label:"off"}],value:t.clearScreen?"on":"off",onChange:n=>a(s=>({...s,clearScreen:n==="on"}))})}),e.jsx(y,{label:"Timezone",hint:"IANA name · empty = System",children:e.jsx(Ke,{value:t.timezone,onChange:n=>a(s=>({...s,timezone:n}))})}),e.jsx(y,{label:"Dashboard",hint:"grid shows all · single cycles",children:e.jsx(C,{size:"xs",ariaLabel:"dashboard layout",options:[{value:"grid",label:"grid"},{value:"single",label:"single"}],value:t.dashboardLayout,onChange:n=>a(s=>({...s,dashboardLayout:n}))})}),e.jsx(y,{label:"Default focus",hint:"on open",children:e.jsx(C,{size:"xs",ariaLabel:"default focus",options:[{value:"all",label:"all"},{value:"last",label:"last"}],value:t.defaultFocus,onChange:n=>a(s=>({...s,defaultFocus:n}))})}),e.jsx(y,{label:"ASCII mode",hint:"glyph fallback",children:e.jsx(C,{size:"xs",ariaLabel:"ascii mode",options:[{value:"auto",label:"auto"},{value:"on",label:"on"},{value:"off",label:"off"}],value:t.ascii,onChange:n=>a(s=>({...s,ascii:n}))})}),e.jsx(y,{label:"Network access",hint:"applies on daemon restart",children:e.jsx(C,{size:"xs",ariaLabel:"network access",options:[{value:"local",label:"local only"},{value:"network",label:"LAN"}],value:t.allowNetworkAccess?"network":"local",onChange:n=>a(s=>({...s,allowNetworkAccess:n==="network"}))})}),t.allowNetworkAccess&&e.jsxs(e.Fragment,{children:[e.jsx(y,{label:"Allowed hosts",hint:"exact DNS names · comma separated",children:e.jsx(qe,{value:t.allowedHosts,onChange:n=>a(s=>({...s,allowedHosts:n}))})}),e.jsx("p",{className:"rounded border border-critical/50 bg-critical/10 px-3 py-2 text-xs text-critical",role:"alert",children:"Unsafe: after the daemon restarts, usage data and settings will be reachable from your local network."})]}),e.jsx(y,{label:"Reset times",hint:"quota and peak changes",children:e.jsx(C,{size:"xs",ariaLabel:"reset time display",options:[{value:"relative",label:"remaining"},{value:"absolute",label:"date/time"}],value:t.resetDisplay,onChange:n=>a(s=>({...s,resetDisplay:n}))})})]})}function qe({value:t,onChange:a}){const[n,s]=x.useState(t.join(", ")),[u,o]=x.useState(!1),b=x.useId(),g=x.useRef(null),v=t.join(", ");x.useEffect(()=>{if(g.current===v){g.current=null;return}s(v),o(!1)},[v]);const r=l=>{const d=K(l);s(d);const h=d.split(",").map(p=>p.trim()).filter(Boolean).map(fe),i=h.some(p=>p===null);if(o(i),!i){const p=[...new Set(h)];g.current=p.join(", "),a(p)}};return e.jsxs("div",{className:"flex flex-col items-end gap-0.5",children:[e.jsx("input",{type:"text",name:"allowed-hosts",value:n,placeholder:"tokmon.example.com","aria-label":"Allowed hosts","aria-describedby":u?b:void 0,autoComplete:"off",spellCheck:!1,"aria-invalid":u,onChange:l=>r(l.target.value),className:`w-64 rounded border bg-bg-2 px-2 py-1 text-xs text-fg ${f} ${u?"border-critical":"border-line"}`}),u&&e.jsx("span",{id:b,className:"text-[10px] text-critical",role:"alert",children:"Use exact hostnames without a scheme, port, path, or wildcard."})]})}function Ke({value:t,onChange:a}){const[n,s]=x.useState(t??""),[u,o]=x.useState(!1),b=x.useId();x.useEffect(()=>{s(t??""),o(!1)},[t]);const g=v=>{const r=K(v);s(r);const l=r.trim();if(!l){o(!1),a(null);return}ge(l)?(o(!1),a(l)):o(!0)};return e.jsxs("div",{className:"flex flex-col items-end gap-0.5",children:[e.jsx("input",{type:"text",name:"timezone",value:n,placeholder:"e.g. Europe/Bucharest…","aria-label":"Timezone","aria-describedby":u?b:void 0,autoComplete:"off",spellCheck:!1,"aria-invalid":u,onChange:v=>g(v.target.value),className:`w-44 rounded border bg-bg-2 px-2 py-1 text-xs text-fg ${f} ${u?"border-critical":"border-line"}`}),u&&e.jsx("span",{id:b,className:"text-[10px] text-critical",role:"alert",children:"Use an IANA zone such as Europe/Bucharest."})]})}function We({draft:t,patch:a}){const n=(s,u)=>a(o=>ye(o,s,u));return e.jsxs(P,{title:"Providers",right:e.jsxs("button",{type:"button",role:"switch","aria-checked":t.accountDetection.enabled,onClick:()=>a(s=>({...s,accountDetection:{...s.accountDetection,enabled:!s.accountDetection.enabled}})),className:`rounded border px-2 py-1 text-[10px] uppercase tracking-wide transition ${f} ${t.accountDetection.enabled?"border-accent/50 bg-accent/10 text-accent":"border-line text-fg-faint"}`,children:["Auto-detect ",t.accountDetection.enabled?"on":"off"]}),children:[e.jsx("p",{className:"mb-2.5 text-[11px] text-fg-faint",children:"Tracking controls all provider data. Auto-detect only finds accounts; manual accounts keep working when it is off."}),e.jsx("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:ae.map(s=>{const u=!t.disabledProviders.includes(s),o=ve(t.accountDetection,s),b=q[s];return e.jsxs("div",{className:`flex items-center gap-2 rounded border px-2.5 py-2 text-left text-xs transition ${u?"border-line-2 bg-bg-2 text-fg":"border-line bg-bg-1 text-fg-faint hover:border-line-2"}`,children:[e.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{background:F(b.color)},"aria-hidden":!0}),e.jsx("span",{className:`font-medium ${u?"text-fg":"text-fg-faint"}`,children:b.name}),e.jsxs("span",{className:"ml-auto flex items-center gap-1",children:[e.jsxs("button",{type:"button",role:"switch","aria-checked":u,"aria-label":`${u?"Stop":"Start"} tracking ${b.name}`,onClick:()=>n(s,!u),className:`inline-flex items-center gap-1 rounded border px-1.5 py-1 text-[10px] ${f} ${u?"border-line-2 text-fg":"border-line text-fg-faint"}`,children:[u&&e.jsx(W,{className:"size-3"})," Track"]}),e.jsx("button",{type:"button",role:"switch","aria-checked":o,disabled:!t.accountDetection.enabled,"aria-label":`${o?"Disable":"Enable"} ${b.name} account discovery`,onClick:()=>a(g=>({...g,accountDetection:je(g.accountDetection,s,!o)})),className:`rounded border px-1.5 py-1 text-[10px] disabled:opacity-40 ${f} ${o?"border-accent/50 text-accent":"border-line text-fg-faint"}`,children:"Auto"})]})]},s)})})]})}function Ye(t,a){return a?a.accounts.find(n=>n.id===t.id)??null:null}function Qe({draft:t,patch:a,snapshot:n,onEdit:s,onConfigure:u,onAdd:o}){const b=ke(t,void 0,(n==null?void 0:n.accounts)??void 0),[g,v]=x.useState(null),r=c=>a(h=>({...h,activeAccountId:c})),l=c=>{if(g!==c){v(c);return}a(h=>({...h,accounts:h.accounts.filter(i=>i.id!==c),activeAccountId:h.activeAccountId===c?null:h.activeAccountId})),v(null)},d=(c,h)=>a(i=>{const p=[...i.accounts],w=c+h;return w<0||w>=p.length?i:([p[c],p[w]]=[p[w],p[c]],{...i,accounts:p})});return e.jsx(P,{title:"Accounts",right:e.jsxs(L,{variant:"primary",size:"xs",onClick:o,children:[e.jsx(De,{className:"size-3"})," Add account"]}),children:b.length===0?e.jsx("p",{className:"rounded border border-line bg-bg-2/50 px-3 py-3 text-xs text-fg-faint",children:"None configured — enabled providers track automatically."}):e.jsx("ul",{className:"flex flex-col gap-1.5",role:"radiogroup","aria-label":"Active account",children:b.map(c=>{var I;const h=q[c.providerId],i=Ye(c,n),p=i?Ne(i,h.name):c.name||h.name,w=(i==null?void 0:i.plan)??((I=i==null?void 0:i.billing)==null?void 0:I.plan)??null,A=F(c.color||h.color),S=c.id===t.activeAccountId,D=c.source==="configured",N=c.source==="ignored";return e.jsxs("li",{className:`flex items-center gap-2.5 rounded border border-line px-2.5 py-2 ${N?"bg-bg-1 opacity-75":"bg-bg-2/60"}`,children:[e.jsx("button",{type:"button",role:"radio","aria-checked":S,disabled:N,"aria-label":`Set ${c.name} active`,title:S?"Active account (click to clear)":"Set active",onClick:()=>r(S?null:c.id),className:`relative inline-flex size-4 shrink-0 items-center justify-center rounded-full border transition ${f}`,style:{borderColor:A},children:S&&e.jsx("span",{className:"size-2 rounded-full",style:{background:A}})}),e.jsx("span",{className:"size-2.5 shrink-0 rounded-full",style:{background:A},"aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{value:p,privacyMode:t.privacyMode,className:"truncate text-sm text-fg-bright"}),e.jsx("span",{className:"shrink-0 rounded bg-bg-3 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-fg-dim",children:h.name}),w&&e.jsx("span",{className:"shrink-0 rounded border border-line px-1.5 py-0.5 text-[10px] text-fg-dim",children:w}),e.jsx("span",{className:"shrink-0 rounded border border-line px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-fg-faint",children:c.source==="auto"?"detected":N?"ignored":"manual"})]}),e.jsx("div",{className:"truncate font-mono text-[11px] text-fg-faint",children:t.privacyMode?"path hidden":c.homeDir})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[g===c.id?e.jsx("span",{className:"mr-1 text-[10px] text-critical",role:"alert",children:"Delete?"}):null,D&&c.explicitIndex!==void 0?e.jsxs(e.Fragment,{children:[e.jsx(R,{label:"Move up",disabled:c.explicitIndex===0,onClick:()=>d(c.explicitIndex,-1),children:e.jsx(ce,{className:"size-3.5"})}),e.jsx(R,{label:"Move down",disabled:c.explicitIndex===t.accounts.length-1,onClick:()=>d(c.explicitIndex,1),children:e.jsx(de,{className:"size-3.5"})}),e.jsx(R,{label:"Edit account",onClick:()=>s(c),children:e.jsx(re,{className:"size-3.5"})}),e.jsx(R,{label:g===c.id?"Confirm delete account":"Delete account",danger:!0,onClick:()=>l(c.id),children:e.jsx(Ce,{className:"size-3.5"})})]}):N?e.jsx(R,{label:"Turn detected account on",onClick:()=>c.excludedRef&&a(j=>({...j,accountDetection:le(j.accountDetection,c.excludedRef,!1)})),children:e.jsx(Se,{className:"size-3.5"})}):e.jsxs(e.Fragment,{children:[e.jsx(R,{label:"Configure as manual account",onClick:()=>u(c),children:e.jsx(re,{className:"size-3.5"})}),e.jsx(R,{label:"Turn detected account off",onClick:()=>a(j=>({...j,activeAccountId:j.activeAccountId===c.id?null:j.activeAccountId,accountDetection:le(j.accountDetection,{providerId:c.providerId,homeDir:c.homeDir},!0)})),children:e.jsx(ue,{className:"size-3.5"})})]})]})]},`${c.source}:${c.id}`)})})})}function Xe(t){const a=(t??"").trim();return a.length>0?a:"~"}function J(t){const a=(t??"").trim();return a.length>0?a:"~"}function Ze(t){const a=[];t.parent!==null&&a.push({kind:"parent",key:"..",label:"..",path:t.parent});for(const n of[...t.entries].filter(s=>s.dir).sort((s,u)=>s.name.localeCompare(u.name)))a.push({kind:"entry",key:n.path,label:n.name,path:n.path});return a}function Je({editor:t,accounts:a,onChange:n,onCancel:s,onSubmit:u}){const o=x.useRef(null),[b,g]=x.useState(null),v=F(t.color),r=Ue(t,a),l=()=>{const d=He(t,a);if(!d.ok){g(d.error);return}u(d.account,d.mode,d.editingId)};return e.jsxs(pe,{onClose:s,labelledBy:"account-editor-title",initialFocusRef:o,showClose:!1,className:"my-8 w-full max-w-[460px] border-l-2",panelStyle:{borderLeftColor:v},children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-line px-4 py-3",children:[e.jsx("span",{className:"size-2.5 rounded-full",style:{background:v},"aria-hidden":!0}),e.jsx("h2",{id:"account-editor-title",className:"font-display text-xs uppercase tracking-wider text-fg-bright",children:t.mode==="add"?"New account":"Edit account"})]}),e.jsxs("div",{className:"flex flex-col gap-4 px-4 py-4",children:[e.jsx(U,{label:"Provider",hint:"which tool this account tracks",children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:ae.map(d=>{const c=d===t.providerId,h=q[d];return e.jsxs("button",{type:"button",onClick:()=>n({...t,providerId:d}),"aria-pressed":c,className:`flex items-center gap-1.5 rounded border px-2 py-1 text-xs transition ${f} ${c?"border-line-2 bg-bg-3 text-fg-bright":"border-line text-fg-dim hover:text-fg"}`,children:[e.jsx("span",{className:"size-2 rounded-full",style:{background:F(h.color)},"aria-hidden":!0}),h.name]},d)})})}),e.jsx(U,{label:"Name",hint:"display name for this account",children:e.jsx("input",{ref:o,type:"text",name:"account-name",value:t.name,placeholder:"e.g. Work…","aria-label":"Account name",autoComplete:"off",spellCheck:!1,onChange:d=>{g(null),n({...t,name:K(d.target.value)})},onKeyDown:d=>{d.key==="Enter"&&l()},className:`w-full rounded border border-line bg-bg-2 px-2.5 py-1.5 text-sm text-fg ${f}`})}),e.jsx(U,{label:"Home directory",hint:"path containing the tool's data dir · ~ for default",children:e.jsx(et,{value:t.homeDir,onChange:d=>n({...t,homeDir:d}),onEnter:l})}),e.jsx(U,{label:"Accent color",hint:"shows on dashboard, account strip, borders",children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Ie.map(d=>{const c=d===t.color;return e.jsx("button",{type:"button","aria-label":d,"aria-pressed":c,title:d,onClick:()=>n({...t,color:d}),className:`size-6 rounded-full border-2 transition ${f} ${c?"scale-110":"border-transparent hover:scale-105"}`,style:{background:F(d),borderColor:c?"var(--color-fg-bright)":"transparent"}},d)})})}),e.jsxs("div",{className:"flex items-center gap-2 rounded border border-line bg-bg-2/50 px-2.5 py-1.5 text-xs",children:[e.jsx("span",{className:"text-fg-faint",children:"id"}),e.jsx("span",{className:"font-mono text-fg",style:{color:v},children:r||"account"}),e.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:t.mode==="add"?"auto-generated from name":"fixed"})]}),b&&e.jsxs("p",{className:"text-xs text-critical",role:"alert",children:[b,". Check the highlighted account fields and try again."]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-line px-4 py-3",children:[e.jsx(L,{variant:"secondary",onClick:s,children:"cancel"}),e.jsxs(L,{variant:"primary",onClick:l,children:[e.jsx(W,{className:"size-3.5"})," ",t.mode==="add"?"Add account":"Save account"]})]})]})}function et({value:t,onChange:a,onEnter:n}){const[s,u]=x.useState(!1),[o,b]=x.useState(null),[g,v]=x.useState("~"),[r,l]=x.useState(!1),[d,c]=x.useState(null),h=x.useRef(0),i=x.useCallback(async j=>{const $=++h.current,T=Xe(j);v(T),l(!0),c(null);try{const E=await Ae(T);if($!==h.current)return;b(E)}catch(E){if($!==h.current)return;b(null),c(E instanceof Error?E.message:"cannot read folder")}finally{$===h.current&&l(!1)}},[]);x.useEffect(()=>()=>{h.current++},[]);const p=()=>{u(!0),i(t)},w=()=>{h.current++,u(!1),l(!1),c(null)},A=j=>{r||i(j)},S=()=>{!o||r||(a(J(o.path)),w())},D=o?Ze(o):[],N=D.filter(j=>j.kind==="entry"),I=J((o==null?void 0:o.path)??g);return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex overflow-hidden rounded border border-line bg-bg-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-2.5",children:[e.jsx(Q,{className:"size-4 shrink-0 text-fg-faint"}),e.jsx("input",{type:"text",name:"account-home-directory",value:t,placeholder:"e.g. ~/work…","aria-label":"Account home directory",autoComplete:"off",spellCheck:!1,onChange:j=>{w(),a(K(j.target.value))},onKeyDown:j=>{j.key==="Enter"&&n()},className:`min-w-0 flex-1 bg-transparent py-1.5 font-mono text-sm text-fg ${f}`})]}),e.jsxs("button",{type:"button",onClick:p,disabled:r,className:`flex shrink-0 items-center gap-1 border-l border-line bg-bg-1 px-2.5 py-1.5 text-xs text-fg-dim transition hover:bg-bg-3 hover:text-fg disabled:opacity-50 ${f}`,children:[e.jsx(de,{className:"size-3.5"})," Browse"]})]}),s&&e.jsxs("div",{className:"mt-2 overflow-hidden rounded border border-line-2 bg-bg-1 shadow-[0_18px_60px_rgba(0,0,0,0.35)]",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-line bg-bg-2 px-2.5 py-2",children:[e.jsx(Q,{className:"size-4 shrink-0 text-accent"}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-xs text-fg-bright",title:I,children:I}),r&&e.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-wide text-fg-faint",children:"loading"}),e.jsx("button",{type:"button",onClick:w,"aria-label":"Close folder picker",className:`rounded p-1 text-fg-faint transition hover:text-fg ${f}`,children:e.jsx(ue,{className:"size-3.5"})})]}),d?e.jsxs("div",{className:"px-2.5 py-3",children:[e.jsxs("div",{className:"text-xs text-critical",children:["can't read ",J(g)]}),e.jsx("button",{type:"button",onClick:()=>{r||i(g)},disabled:r,className:`mt-2 rounded border border-line bg-bg-2 px-2 py-1 text-[11px] text-fg-dim transition hover:border-line-2 hover:text-fg disabled:opacity-50 ${f}`,children:"retry"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"max-h-56 overflow-y-auto py-1",children:[D.map(j=>e.jsxs("button",{type:"button",onClick:()=>A(j.path),disabled:r,className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-xs transition hover:bg-bg-3 hover:text-fg disabled:opacity-50 ${f} ${j.kind==="parent"?"text-fg-dim":"text-fg"}`,children:[j.kind==="parent"?e.jsx(ce,{className:"size-3.5 shrink-0"}):e.jsx(Q,{className:"size-3.5 shrink-0 text-fg-faint"}),e.jsx("span",{className:"min-w-0 truncate font-mono",children:j.label})]},j.key)),!r&&N.length===0&&e.jsx("div",{className:"px-2.5 py-3 text-xs text-fg-faint",children:"no subdirectories"}),r&&!o&&e.jsx("div",{className:"px-2.5 py-3 text-xs text-fg-faint",role:"status","aria-live":"polite",children:"loading folders…"})]}),e.jsx("div",{className:"flex items-center justify-end gap-2 border-t border-line px-2.5 py-2",children:e.jsxs(L,{variant:"primary",onClick:S,disabled:!o||r,children:[e.jsx(W,{className:"size-3.5"})," Select this folder"]})})]})]})]})}function tt(t,a){return t[a]&&Object.values(t).filter(Boolean).length===1?t:{...t,[a]:!t[a]}}function at(){return{...X,elements:{...X.elements},customSpacing:{...X.customSpacing}}}function nt({draft:t,patch:a,snapshot:n}){const s=(n==null?void 0:n.providers)??[],u=new Set(s.map(r=>r.id)),o=$e(t.desktop.expandedProviders,u),b=r=>a(l=>({...l,desktop:{...l.desktop,expandedProviders:Pe(l.desktop.expandedProviders,r,u)}})),g=r=>a(l=>{const d=tt(l.tray.menuBar.elements,r);return{...l,tray:{...l.tray,showMenuBarText:d.value,menuBar:{...l.tray.menuBar,elements:d}}}}),v=(r,l)=>a(d=>({...d,tray:{...d.tray,menuBar:{...d.tray.menuBar,customSpacing:{...d.tray.menuBar.customSpacing,[r]:l}}}}));return e.jsxs(e.Fragment,{children:[e.jsxs(P,{title:"App",children:[e.jsx(y,{label:"Privacy mode",hint:`global identity masking · ${t.privacyToggleKey.toUpperCase()} shortcut`,children:e.jsx(C,{size:"xs",ariaLabel:"privacy mode",options:[{value:"on",label:"on"},{value:"off",label:"off"}],value:t.privacyMode?"on":"off",onChange:r=>a(l=>({...l,privacyMode:r==="on"}))})}),e.jsx(y,{label:"Provider summary",hint:"smart pools account capacity · tightest shows the highest single usage",children:e.jsx(C,{size:"xs",ariaLabel:"menu bar value",options:[{value:"smartHeadroom",label:"smart"},{value:"tightestRemaining",label:"tightest"}],value:t.tray.displayMetric,onChange:r=>a(l=>({...l,tray:{...l.tray,displayMetric:r}}))})}),e.jsx(y,{label:"Active window",hint:"recent activity used by smart headroom",children:e.jsx(te,{label:"Active window",value:t.tray.activeTimeoutMin,min:1,unit:"min",onChange:r=>a(l=>({...l,tray:{...l.tray,activeTimeoutMin:Math.min(1440,r)}}))})}),e.jsx(y,{label:"Graph range",hint:"trailing spend activity in the desktop popover",children:e.jsx(C,{size:"xs",ariaLabel:"desktop graph range",options:Ee.map(r=>({value:String(r),label:`${r}d`})),value:String(t.desktop.graphRangeDays),onChange:r=>a(l=>({...l,desktop:{...l.desktop,graphRangeDays:Number(r)}}))})}),e.jsx(y,{label:"Launch at login",hint:"start the desktop menu bar app automatically",children:e.jsx(C,{size:"xs",ariaLabel:"launch desktop app at login",options:[{value:"on",label:"on"},{value:"off",label:"off"}],value:t.tray.launchAtLogin?"on":"off",onChange:r=>a(l=>({...l,tray:{...l.tray,launchAtLogin:r==="on"}}))})})]}),e.jsxs(P,{title:"macOS menu bar",right:e.jsx("button",{type:"button",onClick:()=>a(r=>{const l=at();return{...r,tray:{...r.tray,menuBar:l,showMenuBarText:l.elements.value}}}),className:`rounded border border-line px-2 py-1 text-[10px] text-fg-faint transition hover:border-line-2 hover:text-fg ${f}`,children:"Reset presentation"}),children:[e.jsx("p",{className:"mb-2.5 text-[11px] text-fg-faint",children:"Controls the native menu-bar item. Pin providers from their cards in the desktop overview."}),e.jsx(y,{label:"Layout",hint:"auto tightens spacing on smaller displays",children:e.jsx(C,{size:"xs",ariaLabel:"menu bar layout mode",options:[{value:"auto",label:"auto"},{value:"custom",label:"custom"}],value:t.tray.menuBar.mode,onChange:r=>a(l=>({...l,tray:{...l.tray,menuBar:{...l.tray.menuBar,mode:r}}}))})}),e.jsx(y,{label:"Elements",hint:"choose at least one",children:e.jsx("div",{className:"flex items-center overflow-hidden rounded border border-line",role:"group","aria-label":"menu bar elements",children:[["providerMark","provider mark"],["value","value"],["progress","progress"]].map(([r,l])=>{const d=t.tray.menuBar.elements[r],c=d&&Object.values(t.tray.menuBar.elements).filter(Boolean).length===1;return e.jsx("button",{type:"button","aria-pressed":d,disabled:c,onClick:()=>g(r),className:`px-1.5 py-0.5 text-[10px] transition disabled:cursor-not-allowed ${f} ${d?"bg-bg-3 text-accent":"text-fg-faint hover:text-fg"}`,children:l},r)})})}),e.jsx(y,{label:"Value",hint:"usage percentage or today's local tokens",children:e.jsx(C,{size:"xs",ariaLabel:"menu bar value",options:[{value:"usage",label:"usage"},{value:"todayTokens",label:"tokens today"}],value:t.tray.menuBarValue,onChange:r=>a(l=>({...l,tray:{...l.tray,menuBarValue:r}}))})}),e.jsx(y,{label:"Density",hint:"sets the baseline space between providers",children:e.jsx(C,{size:"xs",ariaLabel:"menu bar density",options:[{value:"comfortable",label:"comfortable"},{value:"compact",label:"compact"},{value:"tight",label:"tight"}],value:t.tray.menuBar.density,onChange:r=>a(l=>({...l,tray:{...l.tray,menuBar:{...l.tray.menuBar,density:r}}}))})}),t.tray.menuBar.mode==="custom"?e.jsxs("div",{className:"mt-1 border-t border-line pt-1",children:[e.jsx(y,{label:"Edge padding",hint:"inside Tokmon's rendered menu-bar item",children:e.jsx(ee,{label:"Edge padding",value:t.tray.menuBar.customSpacing.edgePaddingPt,max:6,onChange:r=>v("edgePaddingPt",r)})}),e.jsx(y,{label:"Mark to value",hint:"space between provider mark and value",children:e.jsx(ee,{label:"Mark to value gap",value:t.tray.menuBar.customSpacing.markValueGapPt,max:8,onChange:r=>v("markValueGapPt",r)})}),e.jsx(y,{label:"Provider gap",hint:"space between pinned providers",children:e.jsx(ee,{label:"Provider gap",value:t.tray.menuBar.customSpacing.providerGapPt,max:16,onChange:r=>v("providerGapPt",r)})})]}):null]}),e.jsxs(P,{title:"Popover defaults",children:[e.jsx("p",{className:"mb-2 text-[11px] text-fg-faint",children:"Choose which provider cards start expanded. You can still open or close any card in the app."}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map(r=>{const l=o.includes(r.id);return e.jsxs("button",{type:"button","aria-pressed":l,onClick:()=>b(r.id),className:`flex items-center gap-1.5 rounded border px-2 py-1 text-xs transition ${f} ${l?"border-line-2 bg-bg-2 text-fg":"border-line bg-bg-1 text-fg-faint hover:text-fg"}`,children:[e.jsx("span",{style:{color:r.color},"aria-hidden":!0,children:l?"●":"○"}),r.name]},r.id)})})]})]})}function ee({label:t,value:a,max:n,onChange:s}){const u=o=>s(Math.min(n,Math.max(0,Math.round(o*2)/2)));return e.jsxs("div",{className:"flex items-center overflow-hidden rounded border border-line",children:[e.jsx("button",{type:"button","aria-label":`Decrease ${t}`,disabled:a<=0,onClick:()=>u(a-.5),className:`px-2 py-0.5 text-xs text-fg-dim transition hover:bg-bg-3 hover:text-fg disabled:cursor-not-allowed disabled:opacity-35 ${f}`,children:"−"}),e.jsxs("output",{"aria-label":`${t} in points`,className:"tnum min-w-12 border-x border-line bg-bg-2 px-1.5 py-0.5 text-center text-[10px] text-fg",children:[a.toFixed(1),"pt"]}),e.jsx("button",{type:"button","aria-label":`Increase ${t}`,disabled:a>=n,onClick:()=>u(a+.5),className:`px-2 py-0.5 text-xs text-fg-dim transition hover:bg-bg-3 hover:text-fg disabled:cursor-not-allowed disabled:opacity-35 ${f}`,children:"+"})]})}const st=[{label:"surfaces",keys:[{key:"canvas",label:"Canvas"},{key:"panel",label:"Panel"},{key:"inset",label:"Inset"},{key:"insetStrong",label:"Raised inset"},{key:"chrome",label:"Desktop chrome"},{key:"line",label:"Line"},{key:"lineStrong",label:"Strong line"},{key:"lineFaint",label:"Faint line"}]},{label:"type",keys:[{key:"text",label:"Text"},{key:"textDim",label:"Dim text"},{key:"textFaint",label:"Faint text"},{key:"textStrong",label:"Strong text"}]},{label:"signals",keys:[{key:"accent",label:"Accent"},{key:"cost",label:"Cost"},{key:"positive",label:"Savings"}]}],rt=[{value:"auto",label:"Auto"},{value:"light",label:"Light"},{value:"dark",label:"Dark"}],lt=[{value:"ansi",label:"Terminal"},{value:"dark",label:"Dark"},{value:"light",label:"Light"},{value:"off",label:"Off"}];function V(t){return t.custom??{base:"tokmon",light:{},dark:{}}}function M(t,a){return{...t,appearance:{...t.appearance,...a}}}function it({preset:t,selected:a,appearance:n,onSelect:s}){const u=t==="custom"?{...n,preset:t,custom:V(n),mode:"dark"}:{...n,preset:t,mode:"dark"},o=xe(u,"dark").tokens;return e.jsxs("button",{type:"button","aria-pressed":a,onClick:s,className:`min-w-0 rounded border p-2 text-left transition ${f} ${a?"border-accent":"border-line hover:border-line-2"}`,style:{background:o.panel,color:o.text},children:[e.jsxs("span",{className:"mb-2 flex items-center gap-1.5 text-[11px] font-medium",children:[e.jsx("span",{className:"size-2 rounded-full",style:{background:o.accent},"aria-hidden":!0}),e.jsx("span",{className:"truncate",children:H(t).name})]}),e.jsx("span",{className:"flex h-5 items-end gap-1","aria-hidden":!0,children:[o.textFaint,o.textDim,o.cost,o.accent].map((b,g)=>e.jsx("span",{className:"flex-1 rounded-sm",style:{height:`${7+g*3}px`,background:b}},b))})]})}function ot({draft:t,patch:a}){const n=t.appearance,[s,u]=x.useState("dark"),o=V(n),b=x.useMemo(()=>xe({...n,preset:"custom",custom:o,mode:s},s),[n,o,s]),g=x.useMemo(()=>me(n),[n]),v=g.filter(i=>i.mode===s),r=new Set(v.flatMap(i=>i.keys)),l=g.length===0,d=i=>a(p=>M(p,{preset:i,...i==="custom"?{custom:V(p.appearance)}:{},...G(i)?{mode:"dark"}:{}})),c=(i=n.preset)=>{Z(i)&&a(p=>M(p,{preset:"custom",custom:{base:i,light:{},dark:{}}}))},h=i=>a(p=>M(p,{preset:"custom",custom:i(V(p.appearance))}));return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(P,{title:"appearance",children:[e.jsx(y,{label:"Mode",hint:"Auto follows the operating system live.",children:e.jsx(C,{options:G(n.preset)?[{value:"dark",label:"Dark"}]:[...rt],value:G(n.preset)?"dark":n.mode,onChange:i=>a(p=>M(p,{mode:i})),ariaLabel:"graphical color mode"})}),e.jsx(y,{label:"Terminal colors",hint:"Keep ANSI to preserve the classic Tokmon CLI.",children:e.jsx(C,{options:[...lt],value:n.terminal,onChange:i=>a(p=>M(p,{terminal:i})),ariaLabel:"terminal theme policy",size:"xs"})})]}),e.jsxs(P,{title:"preset",children:[e.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3",children:ze.map(i=>e.jsx(it,{preset:i.id,selected:n.preset===i.id,appearance:n,onSelect:()=>d(i.id)},i.id))}),e.jsxs("div",{className:"mt-3 flex min-h-7 items-center justify-between gap-3",children:[e.jsx("p",{className:"text-[11px] text-fg-faint",children:G(n.preset)?"Phosphor is intentionally dark-only.":H(n.preset).hint}),Z(n.preset)&&e.jsxs("button",{type:"button",onClick:()=>c(),className:`shrink-0 rounded border border-line px-2.5 py-1 text-[11px] text-fg-dim transition hover:border-line-2 hover:text-fg ${f}`,children:["customize ",H(n.preset).name]})]})]}),n.preset==="custom"&&e.jsxs(P,{title:"custom palette",right:e.jsx(C,{options:[{value:"light",label:"Light"},{value:"dark",label:"Dark"}],value:s,onChange:u,size:"xs",ariaLabel:"custom palette variant"}),children:[e.jsx(y,{label:"Starting point",hint:"Changing the base resets both variants.",children:e.jsx("select",{value:o.base,onChange:i=>{const p=i.target.value;Z(p)&&h(()=>({base:p,light:{},dark:{}}))},"aria-label":"custom theme base",className:`min-h-8 rounded border border-line bg-bg-2 px-2 text-xs text-fg ${f}`,children:Re.map(i=>e.jsx("option",{value:i,children:H(i).name},i))})}),e.jsx("div",{className:"mt-4 grid gap-x-5 gap-y-4 sm:grid-cols-2",children:st.flatMap(i=>i.keys.map(p=>({...p,group:i.label}))).map(({key:i,label:p,group:w})=>{const A=o[s][i]??b.tokens[i],S=r.has(i);return e.jsxs("label",{className:"min-w-0",children:[e.jsxs("span",{className:"mb-1 flex items-baseline justify-between gap-2 text-xs text-fg",children:[p,e.jsx("span",{className:"text-[9px] uppercase tracking-wider text-fg-faint",children:w})]}),e.jsxs("span",{className:`flex items-center gap-2 rounded border bg-bg-2 p-1 ${S?"border-critical":"border-line"}`,children:[e.jsx("input",{type:"color","aria-label":`${s} ${p} color`,value:Te(A)??b.tokens[i],onChange:D=>h(N=>({...N,[s]:{...N[s],[i]:D.target.value}})),className:"size-7 cursor-pointer border-0 bg-transparent p-0"}),e.jsx("input",{type:"text",spellCheck:!1,maxLength:7,pattern:"#[0-9A-Fa-f]{6}",value:A,"aria-invalid":S,onChange:D=>h(N=>({...N,[s]:{...N[s],[i]:D.target.value}})),className:`tnum min-w-0 flex-1 bg-transparent px-1 text-xs text-fg outline-none ${f}`})]}),S&&e.jsx("span",{className:"mt-1 block text-[10px] text-critical",children:"Use #RRGGBB with readable contrast."})]},i)})}),e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 border-t border-line pt-3",children:[e.jsx("span",{className:`text-[11px] ${l?"text-positive":"text-critical"}`,role:"status",children:l?"Light and dark palettes pass contrast checks":`${g.length} palette issue${g.length===1?"":"s"}`}),e.jsxs("button",{type:"button",onClick:()=>h(i=>({...i,[s]:{}})),className:`rounded border border-line px-2.5 py-1 text-[11px] text-fg-dim transition hover:border-line-2 hover:text-fg ${f}`,children:["reset ",s]})]})]})]})}const ct=[{value:"general",label:"General"},{value:"theme",label:"Theme"},{value:"app",label:"Desktop App"},{value:"providers",label:"Providers"},{value:"accounts",label:"Accounts"}];function xt({onClose:t,snapshot:a}){const n=Be(),s=x.useRef(null),u=x.useRef(null),[o,b]=x.useState(null),[g,v]=x.useState(null),[r,l]=x.useState(null),[d,c]=x.useState(!1),[h,i]=x.useState(null),[p,w]=x.useState(!1),[A,S]=x.useState(!1),[D,N]=x.useState(null),[I,j]=x.useState("general"),$=x.useRef(!1),T=x.useRef(!1),E=x.useRef(null),Y=x.useRef(null),O=x.useCallback(m=>{l(null);const k=Le(E.current,Y.current,$.current,m);$.current||(E.current=k.draft,Y.current=k.revision,b(k.draft),v(k.revision)),k.conflict&&i("settings changed elsewhere; close and reopen settings before saving")},[]);x.useEffect(()=>{let m=!0;return Me().then(k=>{m&&O(k)}).catch(k=>{m&&l(k instanceof Error?k.message:"load failed")}),()=>{m=!1}},[O]),x.useEffect(()=>{const m=k=>{$.current&&k.preventDefault()};return window.addEventListener("beforeunload",m),()=>window.removeEventListener("beforeunload",m)},[]),x.useEffect(()=>{let m=!0;const k=Fe(z=>{m&&O(z)});return()=>{m=!1,k()}},[O]);const ne=()=>{if(!$.current||T.current){n.setPreview(null),t();return}T.current=!0,S(!0),i("unsaved changes; choose discard to close settings")};x.useEffect(()=>{const m=s.current;m&&(D?m.setAttribute("inert",""):m.removeAttribute("inert"))},[D]);const B=m=>{const k=E.current;if(!k)return;const z={...m(k),revision:k.revision};n.setPreview(z.appearance),$.current=!0,E.current=z,w(!0),T.current=!1,S(!1),i(null),b(z)},be=async()=>{if(o){c(!0),i(null);try{if(g===null)throw new Error("config revision is unavailable");const m=await Oe(o,g);E.current=m.config,Y.current=m.config.revision,$.current=!1,b(m.config),v(m.config.revision),w(!1),n.commit(m),t()}catch(m){n.setPreview(null);const k=_e(m);i(k.conflictState?`${k.message}; close and reopen settings before saving`:k.message)}finally{c(!1)}}};return e.jsxs(e.Fragment,{children:[e.jsxs(pe,{onClose:ne,labelledBy:"settings-title",initialFocusRef:u,panelRef:s,className:"my-6 flex w-full max-w-[900px] flex-col",children:[e.jsx("h2",{ref:u,tabIndex:-1,id:"settings-title",className:"pointer-events-none absolute left-3 top-2 font-display text-[11px] uppercase tracking-wider text-fg-dim focus:outline-none",children:"settings"}),e.jsx("div",{className:"max-h-[78vh] overflow-y-auto px-4 pb-4 pt-9 sm:px-5",children:r&&!o?e.jsxs("div",{className:"rounded border border-critical/50 bg-bg-2 p-4 text-sm text-critical",role:"alert",children:["Could not load settings: ",r,". Close settings and try again."]}):o?e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex min-w-0 flex-col gap-5 sm:flex-row sm:items-start",children:[e.jsx("nav",{className:"-mx-1 flex shrink-0 gap-1 overflow-x-auto px-1 pb-2 sm:mx-0 sm:w-32 sm:flex-col sm:overflow-visible sm:px-0 sm:pb-0","aria-label":"Settings sections",children:ct.map(m=>e.jsx("button",{type:"button","aria-current":I===m.value?"page":void 0,onClick:()=>j(m.value),className:`shrink-0 rounded px-2.5 py-2 text-left text-[11px] transition ${f} ${I===m.value?"bg-bg-3 text-accent":"text-fg-dim hover:bg-bg-2 hover:text-fg"}`,children:m.label},m.value))}),e.jsxs("div",{className:"min-w-0 flex-1 border-t border-line pt-4 sm:border-l sm:border-t-0 sm:pl-5 sm:pt-0",children:[I==="general"&&e.jsx(Ve,{draft:o,patch:B}),I==="theme"&&e.jsx(ot,{draft:o,patch:B}),I==="app"&&e.jsx(nt,{draft:o,patch:B,snapshot:a}),I==="providers"&&e.jsx(We,{draft:o,patch:B}),I==="accounts"&&e.jsx(Qe,{draft:o,patch:B,snapshot:a,onEdit:m=>N(Ge(m)),onConfigure:m=>N(ie(o,{providerId:m.providerId,name:m.name,homeDir:m.homeDir,color:m.color})),onAdd:()=>N(ie(o))})]})]})}):e.jsx("div",{className:"py-10 text-center text-sm text-fg-dim",children:"loading config…"})}),e.jsxs("div",{className:"flex items-center justify-end gap-3 border-t border-line px-5 py-3",children:[h&&e.jsx("span",{className:"mr-auto text-xs text-critical",role:"alert",children:h}),p&&!h&&e.jsx("span",{className:"mr-auto text-xs text-fg-faint",role:"status","aria-live":"polite",children:"unsaved changes"}),e.jsx(L,{variant:"secondary",onClick:ne,children:A?"discard":"cancel"}),e.jsxs(L,{variant:"primary",onClick:be,disabled:!o||d||!p||me(o.appearance).length>0,children:[e.jsx(W,{className:"size-3.5"})," ",d?"saving…":"save"]})]})]}),D&&o&&e.jsx(Je,{editor:D,accounts:o.accounts,onChange:N,onCancel:()=>N(null),onSubmit:(m,k,z)=>{B(_=>k==="add"?{..._,accounts:[..._.accounts,m]}:{..._,accounts:_.accounts.map(se=>se.id===z?m:se)}),N(null)}})]})}export{xt as SettingsSheet};
|