ccdeck 3.27.6 → 3.27.7
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/web/assets/{BrowserWatchModal-Co4YHA59.js → BrowserWatchModal-DiMnzuse.js} +1 -1
- package/dist/web/assets/{UsageHistoryModal-DuvLGQcU.js → UsageHistoryModal-6HRc9h9q.js} +1 -1
- package/dist/web/assets/{index-CZPbELsO.js → index-CfHvDuGc.js} +2 -2
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/release-notes.json +2 -1
|
@@ -89,7 +89,7 @@ ${Me.sessionId}`:Me.sessionId,children:Me.label??Me.sessionId.slice(0,8)}),o.jsx
|
|
|
89
89
|
|
|
90
90
|
${n}`:`Sort by ${t}`,onClick:()=>a(Uq(r,e)),children:[t,o.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:l==="none"?"":l==="ascending"?"↑":"↓"})]})})}const Qq=3e3;function Jq(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function e8(e,t,n=Date.now()){const r=Math.max(0,Math.min(100,100-e));return{pct:r,value:`${r}%`,tone:r===0?"calm":r>=30?"hot":"warn",note:r>0?`CPU held to ${e}% of full speed to cool down`:t?`at full speed · held to ${100-t.peak}% ${t8(t.lastMs,n)}`:"running at full speed, and never held back"}}function t8(e,t=Date.now()){const n=Math.max(0,Math.floor((t-e)/6e4));if(n<2)return"just now";if(n<60)return`${n} minutes ago`;const r=Math.floor(n/60);return r===1?"an hour ago":`${r} hours ago`}function mc(e){return e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} KB`}function n8(e){const t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h`:n>0?`${n}h ${r}m`:`${r}m`}function r8(e){var n,r,a;const t=(r=(n=e.thermal)==null?void 0:n.throttle)==null?void 0:r.speedLimit;return t!=null&&t<100?`throttled to ${t}% of full speed`:e.memory&&e.memory.usedPct>=90?`physical memory ${Math.round(e.memory.usedPct)}% full`:(a=e.network)!=null&&a.api&&e.network.api.ms==null?"the Claude API is not answering":null}function s8(){const[e,t]=x.useState(null),n=x.useRef(null);return x.useEffect(()=>{let r=!0;const a=async()=>{if(document.visibilityState!=="hidden")try{const f=await fetch("/api/system");if(!f.ok)return;const p=await f.json();r&&(p!=null&&p.ok)&&t(p)}catch{}},l=()=>{n.current==null&&(a(),n.current=window.setInterval(a,Qq))},c=()=>{n.current!=null&&(window.clearInterval(n.current),n.current=null)},u=()=>{if(document.visibilityState==="hidden"){c();return}l(),a()};return l(),document.addEventListener("visibilitychange",u),()=>{r=!1,c(),document.removeEventListener("visibilitychange",u)}},[]),e}function JN({usageOpen:e,leaving:t,sub:n,flag:r,onClose:a,children:l}){return o.jsxs("aside",{className:`sysdetail${e?" shifted":""}${t?" leaving":""}`,id:"system-panel","aria-labelledby":"sd-title",children:[o.jsxs("div",{className:"sd-top",children:[o.jsxs("div",{className:"sd-head",children:[o.jsx("h2",{className:"sd-title",id:"sd-title",children:"This machine"}),n&&o.jsx("span",{className:"sd-sub",children:n}),o.jsx("button",{type:"button",className:"glyph-btn sd-close",onClick:a,"aria-label":"Close",title:"Close",children:"×"})]}),r&&o.jsx("p",{className:"sd-flag",children:r})]}),l]})}function a8({usageOpen:e,leaving:t,onClose:n}){const r=s8();if(!r||r.cpu==null||!r.memory)return o.jsx(JN,{usageOpen:e,leaving:t,onClose:n,children:o.jsx("div",{className:"sd-note",children:"reading this machine…"})});const{memory:a,swap:l,perCore:c,loadavg:u,cores:f,uptimeSec:p,platform:h,thermal:m,network:y,cpu:w}=r;return o.jsxs(JN,{usageOpen:e,leaving:t,sub:`up ${n8(p)} · ${f} cores`,flag:r8(r),onClose:n,children:[o.jsx(o8,{cpu:w,perCore:c,loadavg:u,cores:f}),o.jsx(i8,{memory:a,swap:l,platform:h}),y&&o.jsx(l8,{network:y}),o.jsx(d8,{thermal:m}),o.jsx(h8,{sys:r})]})}function o8({cpu:e,perCore:t,loadavg:n,cores:r}){const a=!!t&&t.length>0;return!a&&!n?null:o.jsxs("div",{className:"sd-section sd-cpu",role:"group","aria-label":"CPU",children:[a&&o.jsx(qc,{group:"cores",title:"Core history",action:"Show core history",label:"CPU",value:e==null?null:`${Math.round(e)}%`,children:o.jsx("div",{className:"sd-cores",role:"img","aria-label":`${t.length} logical cores, busiest at ${Math.round(Math.max(...t))}%`,children:t.map((l,c)=>o.jsx("span",{className:"sd-core",title:`logical core ${c+1} · ${l}% busy`,children:o.jsx("span",{className:"sd-core-fill",style:{transform:`scaleY(${Math.max(2,l)/100})`}})},c))})}),n&&o.jsxs(qc,{group:"load",title:"Load history",action:"Show load history",label:"Load average",hint:"the queue for the cores, counted in tasks rather than as a share of them",children:[o.jsx("div",{className:"sd-figs",title:"The queue for this machine's cores, averaged over one, five and fifteen minutes. A count of tasks, not a share of the CPU.",children:n.map((l,c)=>o.jsx(Yx,{value:l.toFixed(2),cap:["1m","5m","15m"][c]},c))}),n[0]>r&&o.jsx("div",{className:"sd-note",children:`${(n[0]/r).toFixed(1)}× more work queued than cores to run it`})]})]})}function i8({memory:e,swap:t,platform:n}){const r=e.total-e.available,a=n==="win32"?"Commit":"Swap",l=t&&t.total>0?t.used/t.total*100:0;return o.jsx("div",{className:"sd-section",role:"group","aria-label":"Memory",children:o.jsxs(qc,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[o.jsx(dh,{label:"Physical",value:o.jsxs(o.Fragment,{children:[o.jsx("b",{children:mc(r)})," of ",mc(e.total)]}),pct:e.usedPct,tone:e.usedPct>=90?"warn":"calm",note:`${mc(e.available)} available`}),t&&t.total>0&&o.jsx(dh,{label:a,value:o.jsxs(o.Fragment,{children:[o.jsx("b",{children:mc(t.used)})," of ",mc(t.total)]}),pct:l,tone:l>=90?"warn":"calm"})]})})}function l8({network:e}){const{down:t,up:n,api:r,route:a}=e,[l,c]=x.useState(!1),u=r&&r.ms!=null?Lh(r.ms):null,f=t!=null&&n!=null;return o.jsxs("div",{className:"sd-section",role:"group","aria-label":"Network",children:[o.jsxs(qc,{group:"network",title:"Network history",action:"Show network history",label:"Network",children:[(f||u)&&o.jsxs("div",{className:"sd-figs sd-figs-named",children:[f&&[["Download",t],["Upload",n]].map(([p,h])=>{const m=z0(h);return o.jsx(Yx,{value:m.value,unit:m.unit,cap:p},p)}),u&&o.jsx(Yx,{value:u.value,unit:u.unit,cap:"Claude API"})]}),!f&&o.jsx("div",{className:"sd-note",children:"measuring…"}),r&&r.ms==null&&o.jsx("div",{className:"sd-note sd-note-warn",children:"Can’t reach Claude"})]}),a&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"sd-detail",id:"sd-conn","aria-expanded":l,"aria-haspopup":"dialog",onClick:()=>c(p=>!p),children:["Connection details",a.relay&&o.jsx("span",{className:"sd-route-relay",children:" · relayed"}),o.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),l&&o.jsx(u8,{route:a,api:r,onClose:()=>c(!1)})]})]})}function Yx({value:e,unit:t,cap:n}){return t?o.jsxs("span",{className:"sd-fig",children:[o.jsx("span",{className:"sd-fig-cap",children:n}),o.jsxs("span",{className:"sd-fig-read",children:[o.jsx("b",{children:e})," ",o.jsx("span",{className:"sd-fig-unit",children:t})]})]}):o.jsxs("span",{className:"sd-fig",children:[o.jsx("b",{children:e}),o.jsx("span",{className:"sd-fig-cap",children:n})]})}function c8(e){return e.kind==="tailscale-exit"?e.node?`Tailscale exit node ${e.node}`:"a Tailscale exit node":e.kind==="tailscale"?"Tailscale":`${e.name?`${e.name} `:""}VPN${e.iface?` (${e.iface})`:""}`}function u8({route:e,api:t,onClose:n}){return o.jsxs(Kx,{anchorId:"sd-conn",boundaryId:"system-panel",id:"sd-conn-pop",className:"sd-pop",role:"dialog",labelledBy:"sd-conn-title",onClose:n,children:[o.jsx("p",{className:"sd-pop-title",id:"sd-conn-title",children:"Connection"}),o.jsxs("dl",{className:"sd-pop-rows",children:[o.jsxs("div",{className:"sd-pop-row",children:[o.jsx("dt",{children:e.to==="claude"?"Traffic to Claude":"Internet traffic"}),o.jsxs("dd",{children:["through ",c8(e)]})]}),e.relay&&o.jsxs("div",{className:"sd-pop-row",children:[o.jsx("dt",{children:"Relay"}),o.jsxs("dd",{children:[o.jsx("span",{className:"sd-route-relay",children:e.relay})," — not a direct path, so every packet carries one more round trip than it has to"]})]}),t&&o.jsxs("div",{className:"sd-pop-row",children:[o.jsx("dt",{children:"Round trip"}),o.jsx("dd",{children:t.ms==null?`${t.host} did not answer`:`${Fc(Lh(t.ms))} to open a connection to ${t.host}`})]}),o.jsxs("div",{className:"sd-pop-row",children:[o.jsx("dt",{children:"Throughput"}),o.jsx("dd",{children:"every interface on this machine, not this path alone"})]})]})]})}function qc({group:e,title:t,action:n,label:r,value:a,hint:l,children:c}){const[u,f]=x.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"sd-open",onClick:()=>f(!0),title:n,"aria-label":a==null?n:`${n}, now ${a}`,"aria-describedby":l?`sd-hint-${e}`:void 0,children:[o.jsxs("div",{className:"sd-h","aria-hidden":!0,children:[r," ",o.jsx("i",{className:"sd-row-more",children:"›"}),a!=null&&o.jsx("span",{className:"sd-h-val",children:a})]}),c]}),l&&o.jsx("span",{id:`sd-hint-${e}`,className:"vis-hidden",children:l}),u&&o.jsx(Aq,{group:e,title:t,onClose:()=>f(!1)})]})}function d8({thermal:e}){if(!e)return null;const t=e.throttle?e8(e.throttle.speedLimit,e.heldBack):null;return o.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:o.jsxs(qc,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>o.jsx(dh,{label:n.label,value:o.jsxs(o.Fragment,{children:[o.jsx("b",{children:n.celsius})," °C"]}),pct:n.celsius/n.critAt*100,mark:n.warnAt/n.critAt*100,tone:Jq(n.celsius,n.warnAt,n.critAt),title:`bar runs 0–${n.critAt} °C · amber from ${n.warnAt} °C, red at ${n.critAt} °C`,trackLabel:`${n.celsius} °C on a bar that runs to ${n.critAt} °C, amber from ${n.warnAt} °C`},n.label)),t&&o.jsx(dh,{label:"Throttling",value:o.jsx("b",{children:t.value}),pct:t.pct,tone:t.tone,note:t.note})]})})}function h8({sys:e}){const[t,n]=x.useState(!1);return o.jsxs("div",{className:"sd-section sd-door-section",children:[o.jsx("button",{type:"button",className:"sd-open sd-door",onClick:()=>n(!0),"aria-label":"Show every process the deck is watching",children:o.jsxs("span",{className:"sd-door-plate",children:[o.jsxs("span",{className:"sd-door-name",children:["Busiest processes",o.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),o.jsx("span",{className:"sd-door-sub",children:"every process, with its command line"})]})}),t&&o.jsx(Zq,{sys:e,onClose:()=>n(!1)})]})}function dh({label:e,value:t,pct:n,tone:r="calm",note:a,mark:l,title:c,trackLabel:u}){return o.jsxs("div",{className:"sd-row",title:c,children:[o.jsxs("div",{className:"sd-row-head",children:[o.jsx("span",{className:"sd-row-label",children:e}),o.jsx("span",{className:"sd-row-val",children:t})]}),o.jsxs("span",{className:"sd-track",role:u?"img":void 0,"aria-label":u,children:[o.jsx("span",{className:`sd-fill${r==="calm"?"":` ${r}`}`,style:{transform:`scaleX(${n<=0?0:Math.max(1,Math.min(100,n))/100})`}}),l!=null&&l>0&&l<100&&o.jsx("span",{className:"sd-mark",style:{left:`${l}%`},"aria-hidden":!0})]}),a&&o.jsx("div",{className:"sd-note",children:a})]})}function e_(e){return{inputTokens:e.i,outputTokens:e.o,cacheReadTokens:e.cr,cacheCreateTokens:e.cc,cacheCreate1hTokens:e.c1h,cacheCreate5mTokens:e.c5m}}function t_(e){let t=0;for(const n of Object.values(e))t+=n.i+n.o+n.cr+n.cc;return t}function f8(e,t,n,r=Date.now()){const a=n.size>0,l=new Map;for(const[E,C]of n){const T=E.indexOf("|"),A=E.slice(0,T),I=E.slice(T+1),B=To(C.usage,I,r).total,q=B>0?C.cost/B:1;let L=l.get(A);L||(L=new Map,l.set(A,L)),L.set(I,q)}const c=(E,C)=>{const T=l.get(E);return(T==null?void 0:T.get(C))??(T==null?void 0:T.get(cl(C)))??1},u=(E,C)=>{let T=0;for(const[A,I]of Object.entries(E))T+=To(e_(I),A,r).total*c(C,A);return T},f=new Map,p=[];for(const E of e){const C=new Map;let T=0;for(const A of E.projects){const I=u(A.models,E.day);C.set(A.path,(C.get(A.path)??0)+I),T+=I;let B=f.get(A.path);B||(B={path:A.path,cost:0,tokens:0},f.set(A.path,B)),B.cost+=I,B.tokens+=t_(A.models)}p.push({day:E.day,total:T,byPath:C})}const h=[...f.values()].sort((E,C)=>C.cost-E.cost||C.tokens-E.tokens),m=h.reduce((E,C)=>E+C.cost,0),y=h.reduce((E,C)=>E+C.tokens,0);let w=0,j=0;for(const E of n.values())w+=E.cost;for(const[E,C]of n)j+=To(C.usage,E.slice(E.indexOf("|")+1),r).total;const k=j>0?w/j:1,S=t?t_(t):0;let b=0;if(t)for(const[E,C]of Object.entries(t))b+=To(e_(C),E,r).total*k;const N=b>0||S>0?{cost:b,tokens:S}:null;return{projects:h,totalCost:m,totalTokens:y,perDay:p,unattributed:N,reconciled:a}}const p8=[{days:7,label:"7d"},{days:30,label:"30d"},{days:0,label:"All"}],$i=["var(--usage-blue)","var(--usage-green)","var(--usage-amber)","var(--usage-purple)","var(--usage-indigo)","var(--usage-red)","var(--usage-orange)","var(--usage-zinc)"],m8="var(--usage-zinc)",Hp=6;function n_(e){return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}`}function g8(e){const t=lt(e),n=/^\$(\d{4,})$/.exec(t);return n?`$${Number(n[1]).toLocaleString("en-US")}`:t}function r_(e,t){if(t<=0||e<=0)return"0%";const n=e/t*100;return n<.01?"<0.01%":n<1?`${n.toFixed(2)}%`:n<10?`${n.toFixed(1)}%`:`${Math.round(n)}%`}function y8(e){const t=/^\d{4}-(\d{2})-(\d{2})$/.exec(e);return t?`${Number(t[1])}/${Number(t[2])}`:e}function w8(e){const t=Math.max(1,Math.ceil(e/6));return n=>n===0||n===e-1||n%t===0}function Up(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function v8({num:e,name:t,onClose:n}){const[r,a]=x.useState(7),[l,c]=x.useState(null),[u,f]=x.useState(null),[p,h]=x.useState(null),[m,y]=x.useState(!0),[w,j]=x.useState(null),k=x.useRef(null),S=sn(n,{focusRef:k}),b=x.useRef(0);x.useEffect(()=>{const T=++b.current;y(!0),j(null),h(null);const A=r===0?60:r,I=n_(new Date(Date.now()-(A-1)*864e5)),B=n_(new Date),q=fetch(`/api/account-projects?num=${e}&days=${r}`,{credentials:"same-origin"}).then(U=>U.ok?U.json():Promise.reject(new Error(`HTTP ${U.status}`))),L=fetch(`/api/ccusage?since=${I}&until=${B}`,{credentials:"same-origin"}).then(U=>U.ok?U.json():null).catch(()=>null);Promise.all([q,L]).then(([U,X])=>{if(T!==b.current)return;c(U);const Y=X;f(Y&&Y.ok!==!1?Y:null),y(!1)}).catch(U=>{T===b.current&&(j(U.message||"Could not load"),y(!1))})},[e,r]);const N=x.useMemo(()=>{const T=Date.now();if(!l)return null;const A=H=>typeof H=="number"&&Number.isFinite(H)?H:0,I=new Map;if(u){const H=Array.isArray(u.days)?u.days:[];for(const Q of H){const O=typeof Q.period=="string"?Q.period:"",te=Array.isArray(Q.modelBreakdowns)?Q.modelBreakdowns:[];for(const ae of te){const he=typeof ae.modelName=="string"?ae.modelName:"";if(!O||!/claude/i.test(he))continue;const ge=`${O}|${he}`,Te=I.get(ge),De=Te?Te.usage:{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,cacheCreate1hTokens:0,cacheCreate5mTokens:0};De.inputTokens+=A(ae.inputTokens),De.outputTokens+=A(ae.outputTokens),De.cacheReadTokens+=A(ae.cacheReadTokens),De.cacheCreateTokens+=A(ae.cacheCreationTokens),Te?Te.cost+=A(ae.cost):I.set(ge,{cost:A(ae.cost),usage:De})}}}const B=f8(l.daily??[],l.unattributed,I,T),q=H=>H.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||H||"(unknown)",L=new Map;for(const H of B.projects)L.set(q(H.path),(L.get(q(H.path))??0)+1);const U=H=>{const Q=q(H);if((L.get(Q)??0)<=1)return Q;const O=H.replace(/[\\/]+$/,"").split(/[\\/]/).slice(-2,-1)[0];return O?`${O}/${Q}`:Q},X=$i[Hp%$i.length],Y=new Map,M=[],J=B.projects.slice(0,Hp),V=B.projects.slice(Hp);J.forEach((H,Q)=>{Y.set(H.path,$i[Q%$i.length]),M.push({key:H.path,label:U(H.path),title:H.path,cost:H.cost,tokens:H.tokens,color:$i[Q%$i.length]})}),V.length&&M.push({key:"__other__",label:`Other · ${V.length} project${V.length>1?"s":""}`,title:V.map(H=>q(H.path)).join(", "),cost:V.reduce((H,Q)=>H+Q.cost,0),tokens:V.reduce((H,Q)=>H+Q.tokens,0),color:X,muted:!0});const $=B.totalCost,z=B.totalTokens,W=$>0?"cost":"tokens",G=W==="cost"?$:z,F=M.map(H=>H.color),K=B.perDay.map(H=>{const Q=new Map;for(const[O,te]of H.byPath){const ae=Y.get(O)??X;Q.set(ae,(Q.get(ae)??0)+te)}return{day:H.day,total:H.total,costByColor:Q}}),de=K.reduce((H,Q)=>Math.max(H,Q.total),0);return{rows:M,totalCost:$,totalTokens:z,basis:W,denom:G,un:B.unattributed,reconciled:B.reconciled,chart:K,maxDay:de,colorOrder:F}},[l,u]),E=l!=null&&l.trackedSince?`Tracked since ${Up(l.trackedSince)}`:"Tracking starts with this version",C=r===0?"all time":`the last ${r} days`;return Sn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:o.jsxs("div",{ref:S,className:"modal ap-proj-modal",onClick:T=>T.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-proj-title ap-proj-sub",children:[o.jsxs("header",{className:"ap-proj-head",children:[o.jsxs("div",{className:"ap-proj-titlewrap",children:[o.jsx("div",{className:"ap-proj-title",id:"ap-proj-title",children:"Projects"}),o.jsx("div",{className:"ap-proj-sub",id:"ap-proj-sub",title:t,children:t})]}),o.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:p8.map(T=>o.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":r===T.days,onClick:()=>a(T.days),children:T.label},T.days))}),o.jsx("button",{ref:k,className:"glyph-btn ap-proj-close",onClick:n,"aria-label":"Close",children:"×"})]}),o.jsxs("div",{className:"ap-proj-body",children:[m&&o.jsx("div",{className:"ap-proj-state",children:"Loading…"}),!m&&w&&o.jsxs("div",{className:"ap-proj-state ap-proj-error",children:["Couldn’t load this report: ",w]}),!m&&!w&&N&&o.jsx(o.Fragment,{children:N.rows.length===0?o.jsxs("div",{className:"ap-proj-state",children:["No work attributed to this account in ",C,".",o.jsxs("div",{className:"ap-proj-note",children:[E,". Only work from this version onward can be tied to an account."]})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"ap-proj-bar",role:"img","aria-label":`Share of ${lt(N.totalCost)} across ${N.rows.length} projects`,children:N.rows.map(T=>{const A=N.basis==="cost"?T.cost:T.tokens,I=N.denom>0?A/N.denom*100:0;return I<=0?null:o.jsx("span",{className:"ap-proj-seg",style:{width:`${I}%`,background:T.color},title:`${T.label} · ${lt(T.cost)} · ${r_(T.cost,N.totalCost)}${T.tokens?` · ${Ut(T.tokens)} tokens`:""}`},T.key)})}),o.jsxs("div",{className:"ap-proj-totals",children:[o.jsx("span",{className:"ap-proj-total-cost",children:lt(N.totalCost)}),o.jsxs("span",{className:"ap-proj-total-tok",children:[Ut(N.totalTokens)," tokens"]}),o.jsxs("span",{className:"ap-proj-total-win",children:["· ",C]})]}),N.chart.length>0&&o.jsxs("div",{className:"ap-proj-days",children:[o.jsxs("div",{className:"ap-proj-days-cap",children:["By day",N.chart.length>1?" · click a bar":""]}),o.jsx("div",{className:"ap-proj-days-plot",role:"img","aria-label":`Spend across ${N.chart.length} day${N.chart.length>1?"s":""}`,children:N.chart.map(T=>{const A=N.maxDay>0?T.total/N.maxDay*100:0,I=p===T.day,B=N.rows.map(L=>({label:L.label,c:T.costByColor.get(L.color)??0})).filter(L=>L.c>0),q=`${Up(Date.parse(`${T.day}T00:00:00`))}, ${lt(T.total)}. ${B.map(L=>`${L.label} ${lt(L.c)}`).join(", ")}`;return o.jsx("button",{type:"button",className:`ap-proj-day${I?" selected":""}`,"aria-pressed":I,"aria-label":q,title:`${T.day} · ${lt(T.total)}`,onClick:()=>h(L=>L===T.day?null:T.day),children:o.jsx("span",{className:"ap-proj-col",style:{height:`${A}%`},children:N.colorOrder.map((L,U)=>{const X=T.costByColor.get(L)??0;return X<=0||T.total<=0?null:o.jsx("span",{className:"ap-proj-colseg",style:{height:`${X/T.total*100}%`,background:L}},U)})})},T.day)})}),(()=>{const T=w8(N.chart.length);return o.jsx("div",{className:"ap-proj-days-axis","aria-hidden":"true",children:N.chart.map((A,I)=>o.jsx("div",{className:"ap-proj-axis-cell",children:T(I)?y8(A.day):""},A.day))})})(),(()=>{const T=p?N.chart.find(I=>I.day===p):null;if(!T)return null;const A=N.rows.map(I=>({r:I,c:T.costByColor.get(I.color)??0})).filter(I=>I.c>0);return o.jsxs("div",{className:"ap-proj-day-detail",children:[o.jsxs("div",{className:"ap-proj-day-detail-head",children:[o.jsx("span",{children:Up(Date.parse(`${T.day}T00:00:00`))}),o.jsx("span",{className:"ap-proj-day-detail-total",children:lt(T.total)})]}),A.map(({r:I,c:B})=>o.jsxs("div",{className:"ap-proj-day-detail-row",children:[o.jsx("span",{className:"ap-proj-dot",style:{background:I.color},"aria-hidden":"true"}),o.jsx("span",{className:"ap-proj-day-detail-name",children:I.label}),o.jsx("span",{className:"ap-proj-day-detail-cost",children:lt(B)})]},I.key))]})})()]}),o.jsx("ul",{className:"ap-proj-list",children:N.rows.map(T=>{const A=N.basis==="cost"?T.cost:T.tokens,I=N.denom>0?A/N.denom*100:0;return o.jsxs("li",{className:`ap-proj-row${T.muted?" muted":""}`,children:[o.jsx("span",{className:"ap-proj-dot",style:{background:T.color},"aria-hidden":"true"}),o.jsx("span",{className:"ap-proj-name",title:T.title??T.label,children:T.label}),o.jsx("span",{className:"ap-proj-track",title:`${r_(T.cost,N.totalCost)} of tracked cost`,children:o.jsx("span",{className:"ap-proj-fill",style:{width:`${I}%`,background:T.color}})}),o.jsx("span",{className:"ap-proj-cost",children:lt(T.cost)}),o.jsx("span",{className:"ap-proj-tok",children:Ut(T.tokens)})]},T.key)})}),N.un&&o.jsxs("div",{className:"ap-proj-unattributed",children:[o.jsx("span",{className:"ap-proj-dot",style:{background:m8},"aria-hidden":"true"}),o.jsxs("div",{className:"ap-proj-un-labels",children:[o.jsx("span",{className:"ap-proj-un-title",children:"Unattributed usage"}),o.jsx("span",{className:"ap-proj-un-tag",children:"Excluded from the project totals"})]}),o.jsx("span",{className:"ap-proj-un-cost",children:g8(N.un.cost)}),o.jsx("span",{className:"ap-proj-un-tok",children:Ut(N.un.tokens)}),o.jsx("div",{className:"ap-proj-note",children:"Work no account could be tied to — from before tracking, or a gap."})]}),o.jsxs("div",{className:"ap-proj-foot",children:[N.reconciled?"Dollars from ccusage · split by activity":"Dollars estimated · ccusage unavailable"," · ",E]})]})})]})]})}),document.body)}const s_=18,x8=1100,Oi=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},b8=Array.from({length:s_},(e,t)=>{const n=-72+144*t/(s_-1)+(Oi(t,1)-.5)*9,r=(n-90)*(Math.PI/180),a=(54+32*Math.cos(n*Math.PI/180))*(.74+Oi(t,2)*.52);return{dx:Math.cos(r)*a,dy:Math.sin(r)*a,rot:(t%2?1:-1)*(100+Oi(t,3)*260),delay:Math.round(Oi(t,4)*90),dur:760+Math.round(Oi(t,5)*260),scale:.8+Oi(t,6)*.45,hue:t%4,round:t%3===0}});function a_({anchor:e}){var a;const[t,n]=x.useState(null),r=typeof window<"u"&&((a=window.matchMedia)==null?void 0:a.call(window,"(prefers-reduced-motion: reduce)").matches);return x.useEffect(()=>{if(r)return;const l=e.current;if(!l)return;const c=l.getBoundingClientRect();n({x:c.left+c.width/2,y:c.top+c.height/2});const u=window.setTimeout(()=>n(null),x8);return()=>window.clearTimeout(u)},[e,r]),r||!t?null:Sn.createPortal(o.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:b8.map((l,c)=>o.jsx("span",{className:`confetti-bit${l.round?" round":""}`,"data-hue":l.hue,style:{"--dx":`${l.dx.toFixed(1)}px`,"--dy":`${l.dy.toFixed(1)}px`,"--rot":`${l.rot}deg`,"--s":l.scale.toFixed(2),animationDelay:`${l.delay}ms`,animationDuration:`${l.dur}ms, ${l.dur}ms`}},c))}),document.body)}const UR=new Set(["awaiting_url","awaiting_code","registering"]);function k8(e){return e!=null&&UR.has(e)}function WR(e){return e!=null&&e!=="done"&&!UR.has(e)}const N8="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",_8="the sign-in did not complete";function S8({state:e,serverError:t,localError:n}){const r=e==="idle";return{title:r?"Sign-in ended":"Sign-in failed",message:n||t||(r?N8:_8)}}function j8({restored:e,activeAccount:t}){if(e!==!1)return null;const n=(t==null?void 0:t.email)||((t==null?void 0:t.num)!=null?`account ${t.num}`:null);return n?`This machine is now signed in as ${n} — the account you were using could not be put back. Switch back from the accounts panel.`:"The account you were using could not be put back — check which account this machine is signed in as from the accounts panel."}function E8({started:e,state:t}){return!e||t==="done"?null:{action:"login-cancel"}}const C8="done";function T8(){let e=!1;return{shouldAnnounce(t){return t!==C8?(e=!1,!1):e?!1:(e=!0,!0)}}}function W0(e,t){return t&&Object.hasOwn(e,t)?e[t]:void 0}const A8={already_running:"a sign-in is already in progress",no_url:"the claude CLI did not offer a sign-in link — is it installed?",not_waiting:"that sign-in is no longer waiting for a code",not_prompted:"the CLI has not asked for a code yet",code_rejected:"that code was not accepted — copy it again from the browser",no_verdict:"the claude CLI has not answered — try the code again",empty_code:"paste the code from the browser first",login_failed:"the code was not accepted",no_identity:"signed in, but the CLI still reports nobody logged in",add_failed:"signed in, but claude-swap could not record the account",not_a_share:"that does not look like a shared account — it should start with ccdeck2:",corrupt:"that share is incomplete — copy the whole thing",wrong_version:`that share was made by a newer ${nn}`,expired:"that share has expired — make a new one",import_failed:"claude-swap refused the import",unreadable_export:"claude-swap wrote something this deck could not read — try again, and upgrade it if this repeats",mixed_versions:"claude-swap changed format part-way through — try again",nothing_to_share:"none of those accounts could be exported",too_many:"that is more accounts than one share can carry",not_in_bundle:"that account is not in this share",bad_value:"an alias can only use letters, numbers, spaces, dots, dashes and underscores, up to 64 characters, and cannot start with a dash",bad_email:"that does not look like an email address — it cannot contain spaces or start with a dash"},R8={no_cswap:"claude-swap could not be run — it is not on this deck's PATH. Set AGENTS_DECK_CSWAP to its full path",timeout:"claude-swap took too long and was stopped — try again",switch_failed:"claude-swap refused the switch",bad_account:"that is not an account claude-swap has",unknown_setting:"claude-swap has no such setting",out_of_range:"that value is outside what the setting allows",bad_value:"claude-swap does not accept that value",set_failed:"claude-swap refused the change",command_failed:"claude-swap refused the command"},M8=`claude-swap could not read the login keychain — start ${nn} from a Terminal window rather than a background service`,VR={401:"this deck did not accept the page as its own, so nothing was changed",403:"this deck refused a change from this address — open it on the address the deck prints, not through a proxy"};function Xx(e,t,n){const r=n==null?null:VR[n];if(r)return r;if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(Bc(e)))return M8;const a=W0(R8,e==null?void 0:e.reason);return a||(e==null?void 0:e.reason)||t}function Bc(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const I8={no_install:"ccusage is not installed, and AGENTS_DECK_NO_INSTALL=1 forbids fetching it — unset that variable and restart the deck, or install ccusage yourself so it is on this deck's PATH",bad_override:"AGENTS_DECK_CCUSAGE names a file that is not there — correct it to the full path of your ccusage, or unset it to let the deck find its own",timeout:"ccusage took more than 90 seconds and was stopped — a narrower range usually finishes",bad_output:"ccusage ran but printed no usage data — try again, and run ccusage daily --json in a terminal if it keeps happening",run_failed:"ccusage could not report usage — try again",bad_range:"that date range is not a YYYYMMDD date — reopen the modal and pick one of the presets",unreachable:"the deck did not answer — check it is still running, then try again"},$8="ccusage could not be started — npx is not on this deck's PATH. Install Node's npm/npx, or put ccusage on PATH yourself";function O8(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const L8="ccusage could not be started — the deck launched npx and Node could not load the npm script it points at. An older deck asked cmd.exe for a bare npx.cmd, which made the shim look for that script under the deck's working directory instead of beside itself; update the deck and reopen this modal",P8="ccusage could not be started — the copy npx fetched will not load: Node could not resolve a file inside it. That copy is in npx's own cache, which the deck never rewrites, so clear it with `npm cache clean --force` and reopen this modal",D8=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),F8=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,q8=/[\\/]_npx[\\/]/i,B8=`the copy of ccusage ${nn} installed for itself`;function z8(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function VK(e,t){const n=H8(e,t),r=z8(e);switch(e==null?void 0:e.stage){case"npx":return r?`ccusage failed on both of its paths. The managed install failed first — ${r} — and the deck then fell back to npx, where ${gc(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${gc(n)}`;case"managed":return`${B8} failed to run: ${gc(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${gc(n)}`:`the ccusage this deck found on your PATH failed to run: ${gc(n)}`;default:return n}}const gc=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function H8(e,t){const n=Bc(e);if(D8(n)){if(q8.test(n))return P8;if(F8.test(n))return L8}if(O8(n))return $8;const r=W0(I8,e==null?void 0:e.reason);return r||(e==null?void 0:e.reason)||t}function zi(e,t,n){const r=n==null?null:VR[n];if(r)return r;if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&WR(e.state))return e.error;const a=W0(A8,e==null?void 0:e.reason);return a||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function U8(e,t,n){if(n<=0||Mh(e))return{kind:"pass"};const r=t>=0&&t<n?t:-1;switch(e.key){case"ArrowRight":return{kind:"select",index:r===-1?0:(r+1)%n};case"ArrowLeft":return{kind:"select",index:r===-1?n-1:(r-1+n)%n};case"Home":return{kind:"select",index:0};case"End":return{kind:"select",index:n-1};default:return{kind:"pass"}}}function GR(e,t){const n=Math.round(e/1e3)-t;return n<=0?{text:"expired",tone:"gone"}:n<60?{text:`expires in ${n}s`,tone:"soon"}:{text:`expires in ${Math.round(n/60)}m`,tone:"ok"}}function W8(e){const t=new Map;for(const n of e){const r=(n.email??"").trim().toLowerCase();r&&t.set(r,(t.get(r)??0)+1)}return e.map(n=>{const r=(n.email??"").trim(),a=n.alias||r||`account ${n.num}`,l=[];return n.alias&&r&&l.push(r),r&&(t.get(r.toLowerCase())??0)>1&&l.push(n.org||`slot ${n.num}`),{num:n.num,label:a,sub:l.length?l.join(" · "):null}})}function V8(e,t){return e.filter(n=>!t.includes(n.num)).map(n=>n.num)}function G8(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function K8(e){return e.length?{action:"share",accounts:[...e]}:null}function Y8(e){return e<=0?"Nothing picked yet.":e===1?"1 account — its sign-in token will be on your clipboard.":`${e} accounts — ${e} sign-in tokens will be on your clipboard.`}function Zx(e){return`${e.email}|${e.org??""}`}function X8(e,t,n){return e&&e.map(r=>Zx(r)===t?n:r)}function Z8(e){switch(e){case"imported":return"imported";case"healed":return"dead token replaced";case"updated":return"updated";case"present":return"already here";default:return"not imported"}}function Q8(e){const t=e.length;if(!t)return"Nothing to import.";const n=p=>e.filter(h=>h.state===p).length,r=[],a=n("imported");a&&r.push(`${a} of ${t} imported`);const l=n("healed");l&&r.push(`${l} had a dead token replaced`);const c=n("updated");c&&r.push(`${c} updated`);const u=n("present");u&&r.push(`${u} already here`);const f=n("failed");return f&&r.push(`${f} did not arrive`),`${r.join(", ")}.`}const J8=1500,Rd=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],o_="aa-panel",i_=e=>`aa-tab-${e}`;async function yc(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const Qx=me.forwardRef((e,t)=>o.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[o.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),o.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));Qx.displayName="SuccessMark";function eB({onClose:e,onChanged:t}){const[n,r]=x.useState("login"),[a,l]=x.useState(null),[c,u]=x.useState(""),[f,p]=x.useState(""),[h,m]=x.useState(!1),[y,w]=x.useState(null),[j,k]=x.useState(null),[S,b]=x.useState(null),[N,E]=x.useState(null),C=x.useRef(""),T=x.useRef(!1),A=x.useRef(!1),I=x.useRef(null),B=x.useRef(null),q=x.useRef(null),L=x.useRef(null),U=x.useRef([]),X=x.useRef(!1),Y=x.useCallback(()=>{const O=E8({started:T.current,state:a==null?void 0:a.state});O&&yc(O).catch(()=>{}),e()},[e,a==null?void 0:a.state]),M=sn(Y,{focusRef:q}),J=x.useCallback(async()=>{if(!Ks(A.current))return;A.current=!0,m(!0),w(null),T.current=!0;const O=await yc({action:"login"}).catch(()=>null);if(A.current=!1,m(!1),!(O!=null&&O.ok)){w(zi(O,"could not start the sign-in"));return}l(O)},[]);x.useEffect(()=>{if(!k8(a==null?void 0:a.state))return;const O=window.setInterval(async()=>{try{const te=await fetch("/api/claude-accounts/login");te.ok&&l(await te.json())}catch{}},J8);return()=>window.clearInterval(O)},[a]);const V=x.useRef(t);V.current=t;const $=x.useState(T8)[0];x.useEffect(()=>{var O;(a==null?void 0:a.state)==="awaiting_code"&&((O=I.current)==null||O.focus()),$.shouldAnnounce(a==null?void 0:a.state)&&V.current()},[a==null?void 0:a.state,$]),x.useEffect(()=>{var O;n==="paste"&&!X.current&&((O=B.current)==null||O.focus()),X.current=!1},[n]);const z=x.useCallback(O=>{var ae;const te=U8(O,Rd.findIndex(he=>he.id===n),Rd.length);te.kind!=="pass"&&(O.preventDefault(),X.current=!0,r(Rd[te.index].id),(ae=U.current[te.index])==null||ae.focus())},[n]),W=x.useCallback(async()=>{var te;if(!Ks(A.current))return;A.current=!0,m(!0),w(null);const O=await yc({action:"login-code",code:c}).catch(()=>null);if(A.current=!1,m(!1),!(O!=null&&O.ok)){w(zi(O,"the code was not accepted")),O!=null&&O.state&&l(O),(te=I.current)==null||te.select();return}u(""),l(O)},[c,a]),G=x.useCallback(async()=>{if(!Ks(A.current))return;A.current=!0,m(!0),w(null);const O=await yc({action:"import",blob:f}).catch(()=>null);if(A.current=!1,m(!1),!(O!=null&&O.ok)){w(zi(O,"the import failed"));return}C.current=f,p(""),E(null),k(O.results??[]),t()},[f,t]),F=x.useCallback(async O=>{const te=Zx(O);if(!Ks(A.current)||!C.current)return;A.current=!0,m(!0),b(te),E(null);const ae=await yc({action:"import",blob:C.current,force:!0,only:{email:O.email,org:O.org??""}}).catch(()=>null);if(A.current=!1,m(!1),b(null),!(ae!=null&&ae.ok)){E({key:te,text:zi(ae,"that account could not be updated")});return}const he=(ae.results??[])[0];he&&k(ge=>X8(ge,te,he)),t()},[t]),K=(a==null?void 0:a.state)==="done"?a.account:null,de=j8({restored:a==null?void 0:a.restored,activeAccount:a==null?void 0:a.activeAccount}),H=WR(a==null?void 0:a.state)||!!(y&&T.current&&!h),Q=S8({state:a==null?void 0:a.state,serverError:a==null?void 0:a.error,localError:y});return Sn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:Y,role:"presentation",children:o.jsxs("div",{ref:M,className:"modal aa-modal",onClick:O=>O.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[o.jsxs("header",{className:"modal-head",children:[o.jsx("div",{className:"modal-title",children:o.jsx("span",{className:"aa-tabs",role:"tablist","aria-label":"How to add the account",onKeyDown:z,children:Rd.map((O,te)=>o.jsx("button",{type:"button",role:"tab",id:i_(O.id),ref:ae=>{U.current[te]=ae},"aria-selected":n===O.id,"aria-controls":o_,tabIndex:n===O.id?0:-1,className:`aa-tab${n===O.id?" on":""}`,onClick:()=>{X.current=!1,r(O.id)},children:O.label},O.id))})}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{type:"button",className:"glyph-btn",onClick:Y,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsx("section",{className:"modal-body aa-body",id:o_,role:"tabpanel","aria-labelledby":i_(n),children:n==="login"?K?o.jsxs("div",{className:"aa-done",children:[o.jsx(Qx,{ref:L}),o.jsx(a_,{anchor:L}),o.jsx("h4",{children:K.added?`Account ${K.num} added`:"Credentials refreshed"}),o.jsxs("p",{className:"aa-note",children:[o.jsx("strong",{children:K.email}),K.added?de?" is in the rotation.":" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),de?o.jsx("p",{className:"aa-note aa-warn",role:"status",children:de}):null,o.jsx("button",{type:"button",className:"btn primary",onClick:Y,children:"Done"})]}):(a==null?void 0:a.state)==="awaiting_code"||(a==null?void 0:a.state)==="registering"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"aa-step",children:[o.jsx("h4",{children:"1 · Approve in the browser"}),o.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),o.jsx("a",{className:"aa-link",href:a.url??"#",target:"_blank",rel:"noreferrer noopener",children:a.url})]}),o.jsxs("div",{className:"aa-step",children:[o.jsx("h4",{children:"2 · Paste a code, if the page shows one"}),o.jsx("p",{className:"aa-note",children:"It usually finishes on its own — if the page says you are all set, there is nothing to do here."}),o.jsxs("div",{className:"aa-field",children:[o.jsx("input",{ref:I,type:"text",value:c,onChange:O=>u(O.target.value),onKeyDown:O=>{O.key==="Enter"&&c.trim()&&!h&&W()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:a.state==="registering"}),o.jsx("button",{type:"button",className:"btn primary",...Ma(h,!c.trim()||a.state==="registering"),onClick:W,children:a.state==="registering"?"registering…":"Continue"})]}),(y||a.error)&&o.jsx("p",{className:"aa-err",children:y??a.error}),o.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):H?o.jsxs("div",{className:"aa-step",children:[o.jsx("h4",{children:Q.title}),o.jsx("p",{className:"aa-err",children:Q.message}),o.jsx("button",{type:"button",className:"btn",onClick:()=>{T.current=!1,l(null),w(null),J()},children:"Try again"})]}):h||T.current?o.jsx("div",{className:"aa-step",children:o.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):o.jsxs("div",{className:"aa-step aa-primer",children:[o.jsx("h4",{children:"Sign in to Anthropic"}),o.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in. It normally completes by itself; only if the page hands you a code does it need pasting back here. claude-swap records the account when it completes, and the account you are using now stays active."}),o.jsx("div",{className:"aa-actions",children:o.jsx("button",{type:"button",ref:q,className:"btn primary",onClick:J,children:"Open the sign-in page"})})]}):j?(()=>{const O=j.filter(te=>te.state==="imported").length;return o.jsxs("div",{className:"aa-done",children:[o.jsx(Qx,{ref:L}),O>0&&o.jsx(a_,{anchor:L}),o.jsx("h4",{children:Q8(j)}),j.length>0&&o.jsx("ul",{className:"aa-results",children:j.map(te=>{const ae=Zx(te);return o.jsxs("li",{className:`aa-result ${te.state}`,children:[o.jsx("span",{className:"aa-result-who",children:te.email||(te.num?`slot ${te.num}`:"an account")}),o.jsx("span",{className:"aa-result-what",children:Z8(te.state)}),te.state==="present"&&o.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":S===ae,title:`Overwrite the stored login for ${te.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>F(te),children:S===ae?"updating…":"update anyway"}),(N==null?void 0:N.key)===ae&&o.jsx("span",{className:"aa-result-err",children:N.text})]},ae)})}),o.jsxs("p",{className:"aa-note",children:["Nothing changed on the deck you copied this from. An account already here is left as it is, unless its stored login was dead or you pressed",o.jsx("strong",{children:" update anyway"}),"."]}),o.jsxs("div",{className:"aa-actions",children:[o.jsx("button",{type:"button",className:"btn primary",onClick:Y,children:"Done"}),o.jsx("button",{type:"button",className:"btn",onClick:()=>{C.current="",E(null),k(null)},children:"Import another"})]})]})})():o.jsxs("div",{className:"aa-step",children:[o.jsx("h4",{children:"Paste an account shared from another deck"}),o.jsxs("div",{className:"aa-field",children:[o.jsx("input",{ref:B,type:"text",value:f,onChange:O=>p(O.target.value),onKeyDown:O=>{O.key==="Enter"&&f.trim()&&!h&&G()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),o.jsx("button",{type:"button",className:"btn primary",...Ma(h,!f.trim()),onClick:G,children:h?"importing…":"Import"})]}),y&&o.jsx("p",{className:"aa-err",children:y}),o.jsxs("p",{className:"aa-note",children:["Use ",o.jsx("strong",{children:"share"})," on one account in the other deck, or ",o.jsx("strong",{children:"↗"})," above its list to send several at once. A share carries a live login for every account in it and expires ten minutes after it is made."]})]})})]})}),document.body)}const tB=6;function nB(e,t){const n=e.filter(u=>u.ready);if(t.armed&&e.length>0&&n.length===0)return{text:"Auto-switch has nowhere to go",tone:"bad",free:null};const r=n.length===e.length?`${e.length} ready`:n.length===0?e.length===1?"not ready":`none of ${e.length} ready`:`${n.length} of ${e.length} ready`,a=n.length?"ok":"idle",l=t.strained&&!t.armed?rB(n):null,c=[r];return l!=null&&c.push(`${l}% free`),c.push(t.armed?`auto ${t.threshold??"on"}${t.threshold?"%":""}`:"auto off"),{text:c.join(" · "),tone:a,free:l}}function rB(e){const t=e.map(n=>n.headroom).filter(n=>typeof n=="number");return t.length?Math.max(...t):null}function sB(e){const t=[...e].sort((a,l)=>{if(a.ready!==l.ready)return a.ready?-1:1;if(!a.ready)return a.name.localeCompare(l.name);const c=a.headroom,u=l.headroom;return c==null&&u==null?a.name.localeCompare(l.name):c==null?1:u==null?-1:u-c}),n=t.slice(0,tB),r=t.length-n.length;return{title:e.some(a=>a.ready)?"Where you could switch":"Nothing to switch to",shown:n,rest:r>0?`and ${r} more`:null}}function KR({title:e,steps:t,finish:n,aside:r,onClose:a}){const l=x.useRef(null),c=sn(a,{focusRef:l}),[u,f]=x.useState(0),p=u===t.length-1,h=t[u],m=j=>f(Math.max(0,Math.min(t.length-1,j))),y=j=>{j.key!=="ArrowRight"&&j.key!=="ArrowLeft"||(j.preventDefault(),j.stopPropagation(),m(j.key==="ArrowRight"?u+1:u-1))},w=()=>{if(!p){m(u+1);return}n?n.act():a()};return Sn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:a,role:"presentation",children:o.jsxs("div",{ref:c,className:"modal guide",onClick:j=>j.stopPropagation(),onKeyDown:y,role:"dialog","aria-modal":"true","aria-labelledby":"guide-title",children:[o.jsxs("header",{className:"modal-head",children:[o.jsxs("div",{className:"modal-title",children:[o.jsx("span",{id:"guide-title",className:"modal-tool-name",children:e}),o.jsxs("span",{className:"modal-tool-id",children:[u+1," / ",t.length]})]}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{type:"button",className:"glyph-btn",onClick:a,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body",children:[o.jsx("div",{className:"guide-stage",children:h.art},u),o.jsx("p",{className:"guide-line","aria-live":"polite",children:h.line}),o.jsx("p",{className:"guide-tip",children:h.tip??""}),o.jsxs("div",{className:"guide-foot",children:[o.jsx("div",{className:"guide-dots",children:t.map((j,k)=>o.jsx("button",{type:"button",className:"glyph-btn guide-dot","aria-label":`Step ${k+1} of ${t.length}`,"aria-current":k===u?"step":void 0,onClick:()=>m(k)},k))}),p&&r&&o.jsx("button",{type:"button",className:"ap-lan-word guide-aside",onClick:r.act,children:r.label}),u>0&&o.jsx("button",{type:"button",className:"btn",onClick:()=>m(u-1),children:"Back"}),o.jsx("button",{ref:l,type:"button",className:"btn primary",onClick:w,children:p?(n==null?void 0:n.label)??"Done":"Next"})]})]})]})}),document.body)}const Jx={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function Er({children:e}){return o.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function jr({x:e,y:t=34,w:n=176,h:r=132,label:a}){return o.jsxs(o.Fragment,{children:[a&&o.jsx("text",{x:e+2,y:t-9,className:"ga-cap",children:a}),o.jsx("rect",{x:e,y:t,width:n,height:r,rx:10,className:"ga-screen"})]})}function Qr({x:e,y:t,email:n,state:r,tone:a,bars:l}){return o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:e+3,cy:t-4,r:3,className:Jx[a]}),o.jsx("text",{x:e+12,y:t,className:"ga-t ga-mono",children:n}),o.jsx("text",{x:e+12,y:t+16,className:`ga-s ${Jx[a]}`,children:r}),l==null?void 0:l.map((c,u)=>o.jsxs("g",{children:[o.jsx("text",{x:e,y:t+40+u*18,className:"ga-s",children:u?"7d":"5h"}),o.jsx("rect",{x:e+22,y:t+35+u*18,width:96,height:4,rx:2,className:"ga-track"}),o.jsx("rect",{x:e+22,y:t+35+u*18,width:96*c/100,height:4,rx:2,className:"ga-accent"}),o.jsxs("text",{x:e+148,y:t+40+u*18,className:"ga-s ga-accent",textAnchor:"end",children:[c,"%"]})]},u))]})}function YR({x:e,y:t,on:n}){return o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:e,y:t,width:30,height:18,rx:9,className:n?"ga-switch-on":"ga-switch"}),o.jsx("circle",{cx:n?e+21:e+9,cy:t+9,r:6,className:n?"ga-knob-on":"ga-knob"})]})}function Md({x:e,y:t,name:n,here:r=!0}){return o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:e+3,cy:t-4,r:3,className:r?"ga-ok":"ga-dim"}),o.jsx("text",{x:e+12,y:t,className:r?"ga-t":"ga-s",children:n})]})}function l_({x:e,y:t,on:n}){return n?o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:e,y:t,width:12,height:12,rx:3,className:"ga-accent"}),o.jsx("path",{d:`M${e+3} ${t+6.2}l2.3 2.3 4-4.6`,className:"ga-tick"})]}):o.jsx("rect",{x:e+.5,y:t+.5,width:11,height:11,rx:3,className:"ga-box"})}function c_({x:e,y:t,d:n}){return o.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function V0({x:e,y:t}){return o.jsx("path",{d:`M${e} ${t}l0 13 3.4-3 2.4 5.2 2-.9-2.4-5.1 4.6-.2z`,className:"ga-pointer"})}function G0(){return o.jsxs(o.Fragment,{children:[o.jsx("circle",{r:9,className:"ga-key-bed"}),o.jsxs("g",{transform:"translate(-6 -6) scale(0.857)",className:"ga-key",children:[o.jsx("circle",{cx:4.6,cy:7,r:2.6}),o.jsx("path",{d:"M7.2 7h5.2M10.6 7v2.2M12.4 7v1.6"})]})]})}function Hi({x:e,y:t,w:n,title:r,sub:a,tone:l}){return o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:e,y:t,width:n,height:40,rx:8,className:"ga-screen"}),o.jsx("rect",{x:e+6,y:t+10,width:3,height:20,rx:1.5,className:Jx[l]}),o.jsx("text",{x:e+16,y:t+17,className:"ga-t ga-strong",children:r}),o.jsx("text",{x:e+16,y:t+31,className:"ga-s",children:a})]})}function Ki({x:e,y:t,label:n,live:r}){return o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:e,y:t,width:46,height:20,rx:10,className:r?"ga-chip-live":"ga-chip"}),o.jsx("text",{x:e+23,y:t+14,className:"ga-s ga-mono",textAnchor:"middle",children:n})]})}function hh({x:e,y:t}){return o.jsxs(o.Fragment,{children:[o.jsx("text",{x:e,y:t,className:"ga-cap",children:"LOCAL NETWORK"}),o.jsx(YR,{x:e+118,y:t-13,on:!0})]})}function aB(){return o.jsxs(Er,{children:[o.jsx("rect",{x:14,y:14,width:206,height:172,rx:10,className:"ga-screen"}),o.jsx("text",{x:28,y:38,className:"ga-t ga-strong",children:"Sessions"}),o.jsx("text",{x:206,y:38,className:"ga-s ga-warn",textAnchor:"end",children:"1 waiting"}),o.jsx("rect",{x:20,y:50,width:194,height:42,rx:6,className:"ga-bed-warn"}),o.jsx("circle",{cx:33,cy:64,r:7,className:"ga-ring-warn ga-ping"}),o.jsx("circle",{cx:33,cy:64,r:3.5,className:"ga-warn"}),o.jsx("text",{x:44,y:68,className:"ga-t",children:"api-server"}),o.jsx("text",{x:44,y:83,className:"ga-s ga-warn",children:"waiting 6m · Bash"}),o.jsx("circle",{cx:33,cy:108,r:3.5,className:"ga-flight"}),o.jsx("text",{x:44,y:112,className:"ga-t",children:"docs-site"}),o.jsx("text",{x:44,y:127,className:"ga-s",children:"running · 12 tools"}),o.jsx("circle",{cx:33,cy:150,r:3.5,className:"ga-ok"}),o.jsx("text",{x:44,y:154,className:"ga-t",children:"billing"}),o.jsx("text",{x:44,y:169,className:"ga-s",children:"done · $0.84"}),o.jsx("path",{d:"M216 71C234 71 230 100 244 100",className:"ga-arc"}),o.jsx("path",{d:"M239 96l5 4-5 4",className:"ga-arrow"}),o.jsx("rect",{x:248,y:44,width:178,height:112,rx:10,className:"ga-screen"}),o.jsx("text",{x:262,y:64,className:"ga-cap",children:"API-SERVER"}),o.jsx("line",{x1:248,y1:74,x2:426,y2:74,className:"ga-line"}),o.jsx("text",{x:262,y:96,className:"ga-s ga-mono",children:"Bash(npm test)"}),o.jsx("text",{x:262,y:116,className:"ga-t ga-mono ga-warn",children:"Allow this command?"}),o.jsx("text",{x:262,y:136,className:"ga-s ga-mono",children:"> 1. Yes 2. No"})]})}function oB(){return o.jsxs(Er,{children:[o.jsx("path",{d:"M136 100C166 100 166 38 196 38",className:"ga-edge ga-flow"}),o.jsx("path",{d:"M136 100H196",className:"ga-edge ga-flow"}),o.jsx("path",{d:"M136 100C166 100 166 162 196 162",className:"ga-edge-done"}),o.jsx("path",{d:"M308 38H326M308 100H326",className:"ga-edge"}),o.jsx(Hi,{x:20,y:80,w:116,title:"main",sub:"Opus 5 · 9 tools",tone:"accent"}),o.jsx(Hi,{x:196,y:18,w:112,title:"explore",sub:"Haiku · 14 tools",tone:"flight"}),o.jsx(Hi,{x:196,y:80,w:112,title:"tests",sub:"Sonnet · 6 tools",tone:"flight"}),o.jsx(Hi,{x:196,y:142,w:112,title:"review",sub:"done · 38s",tone:"ok"}),o.jsx(Ki,{x:326,y:28,label:"Read"}),o.jsx(Ki,{x:380,y:28,label:"Grep",live:!0}),o.jsx(Ki,{x:326,y:90,label:"Bash",live:!0})]})}function u_({x:e,y:t,label:n,pct:r,note:a}){return o.jsxs(o.Fragment,{children:[o.jsx("text",{x:e,y:t,className:"ga-s",children:n}),o.jsxs("text",{x:e+194,y:t,className:"ga-s ga-accent",textAnchor:"end",children:[r,"%"]}),o.jsx("rect",{x:e,y:t+7,width:194,height:5,rx:2.5,className:"ga-track"}),o.jsx("rect",{x:e,y:t+7,width:194*r/100,height:5,rx:2.5,className:"ga-accent"}),o.jsx("text",{x:e,y:t+26,className:"ga-s",children:a})]})}function iB(){return o.jsxs(Er,{children:[o.jsx("rect",{x:14,y:30,width:172,height:140,rx:10,className:"ga-screen"}),o.jsx("text",{x:30,y:56,className:"ga-cap",children:"THIS SESSION"}),o.jsx("text",{x:30,y:98,className:"ga-big",children:"$3.66"}),o.jsx("text",{x:30,y:122,className:"ga-s",children:"Opus 5 · 1.2M tokens"}),o.jsx("text",{x:30,y:150,className:"ga-s",children:"$21.40 today"}),o.jsx("rect",{x:200,y:30,width:226,height:140,rx:10,className:"ga-screen"}),o.jsx("text",{x:216,y:56,className:"ga-cap",children:"CLAUDE QUOTA"}),o.jsx(u_,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),o.jsx(u_,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function lB(){return o.jsxs(Er,{children:[o.jsx("rect",{x:14,y:40,width:172,height:120,rx:10,className:"ga-canvas"}),o.jsx(Hi,{x:30,y:80,w:140,title:"tests",sub:"Sonnet 5 · 6 tools",tone:"flight"}),o.jsx(V0,{x:156,y:106}),o.jsx("path",{d:"M170 92C186 92 184 60 200 60",className:"ga-arc"}),o.jsx("path",{d:"M195 56l5 4-5 4",className:"ga-arrow"}),o.jsx(jr,{x:200,y:22,w:226,h:160}),o.jsx("text",{x:214,y:46,className:"ga-t ga-strong",children:"tests"}),o.jsx("text",{x:412,y:46,className:"ga-s",textAnchor:"end",children:"Sonnet 5 · 38s"}),o.jsx("line",{x1:200,y1:56,x2:426,y2:56,className:"ga-line"}),o.jsx("text",{x:214,y:76,className:"ga-cap",children:"PROMPT"}),o.jsx("text",{x:214,y:92,className:"ga-t",children:"Run the suite and fix what fails"}),o.jsx("text",{x:214,y:116,className:"ga-cap",children:"TOOLS · 6"}),o.jsx(Ki,{x:214,y:122,label:"Read"}),o.jsx(Ki,{x:266,y:122,label:"Edit"}),o.jsx(Ki,{x:318,y:122,label:"Bash",live:!0}),o.jsx("text",{x:214,y:164,className:"ga-cap",children:"TOKENS"}),o.jsx("text",{x:214,y:178,className:"ga-s ga-mono",children:"41k in · 2.1k out · $0.12"})]})}function cB(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return o.jsxs(Er,{children:[o.jsx(jr,{x:14,y:20,w:412,h:160}),o.jsx("text",{x:28,y:44,className:"ga-t ga-strong",children:"This machine"}),o.jsx("text",{x:412,y:44,className:"ga-s",textAnchor:"end",children:"12 cores · up 10d"}),o.jsx("line",{x1:14,y1:56,x2:426,y2:56,className:"ga-line"}),o.jsx("text",{x:28,y:76,className:"ga-cap",children:"CORES"}),e.map((t,n)=>o.jsxs("g",{children:[o.jsx("rect",{x:28+n*15,y:82,width:10,height:30,rx:2,className:"ga-track"}),o.jsx("rect",{x:28+n*15,y:112-t,width:10,height:t,rx:2,className:"ga-accent"})]},n)),o.jsx("text",{x:28,y:136,className:"ga-cap",children:"MEMORY"}),o.jsx("rect",{x:28,y:143,width:178,height:5,rx:2.5,className:"ga-track"}),o.jsx("rect",{x:28,y:143,width:105,height:5,rx:2.5,className:"ga-accent"}),o.jsx("text",{x:28,y:165,className:"ga-s",children:"18.9 GB of 32.0 GB"}),o.jsx("text",{x:240,y:76,className:"ga-cap",children:"THERMAL"}),o.jsx("text",{x:240,y:100,className:"ga-big",children:"66 °C"}),o.jsx("text",{x:240,y:118,className:"ga-s ga-ok",children:"running at full speed"}),o.jsx("text",{x:240,y:142,className:"ga-cap",children:"BUSIEST PROCESSES"}),o.jsx("text",{x:240,y:160,className:"ga-s ga-mono",children:"node · claude"}),o.jsx("text",{x:412,y:160,className:"ga-s ga-mono",textAnchor:"end",children:"38%"}),o.jsx("text",{x:240,y:176,className:"ga-s ga-mono",children:"esbuild"}),o.jsx("text",{x:412,y:176,className:"ga-s ga-mono",textAnchor:"end",children:"21%"})]})}function uB(){return o.jsxs(Er,{children:[o.jsx("rect",{x:14,y:40,width:188,height:120,rx:10,className:"ga-screen"}),o.jsx("text",{x:28,y:60,className:"ga-cap",children:"~/MY-PROJECT"}),o.jsx("line",{x1:14,y1:70,x2:202,y2:70,className:"ga-line"}),o.jsxs("text",{x:28,y:100,className:"ga-t ga-mono",children:[o.jsx("tspan",{className:"ga-accent",children:"$"})," claude"]}),o.jsx("rect",{x:86,y:90,width:7,height:13,className:"ga-caret ga-blink"}),o.jsx("text",{x:28,y:130,className:"ga-s ga-mono",children:"or: codex"}),o.jsx("path",{d:"M210 100H238",className:"ga-arc"}),o.jsx("path",{d:"M233 95l6 5-6 5",className:"ga-arrow"}),o.jsx("rect",{x:250,y:40,width:176,height:120,rx:10,className:"ga-canvas"}),o.jsx("g",{className:"ga-pop",children:o.jsx(Hi,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function dB(){return o.jsxs(Er,{children:[o.jsx(jr,{x:14,y:16,w:232,h:170}),o.jsx("text",{x:28,y:40,className:"ga-t ga-strong",children:"Claude accounts"}),o.jsx(c_,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),o.jsx(c_,{x:220,y:33,d:"M3.3 10.7L10.7 3.3M5.2 3.3h5.5v5.5"}),o.jsx("line",{x1:14,y1:52,x2:246,y2:52,className:"ga-line"}),o.jsx(Qr,{x:28,y:74,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),o.jsx("rect",{x:190,y:62,width:44,height:18,rx:9,className:"ga-accent"}),o.jsx("text",{x:212,y:74,className:"ga-s ga-on-accent",textAnchor:"middle",children:"active"}),o.jsx("line",{x1:14,y1:140,x2:246,y2:140,className:"ga-line"}),o.jsx(Qr,{x:28,y:160,email:"personal@me.dev",state:"signed in",tone:"ok"}),o.jsx("rect",{x:188,y:148,width:46,height:18,rx:9,className:"ga-chip"}),o.jsx("text",{x:211,y:160,className:"ga-s",textAnchor:"middle",children:"switch"}),o.jsx(V0,{x:221,y:161}),o.jsx("path",{d:"M250 40C270 40 262 78 282 78",className:"ga-arc"}),o.jsx("path",{d:"M277 74l5 4-5 4",className:"ga-arrow"}),o.jsx(jr,{x:282,y:62,w:144,h:64,label:"ANOTHER MACHINE"}),o.jsx("g",{className:"ga-pop",children:o.jsx(Qr,{x:296,y:92,email:"work@team.dev",state:"shared here",tone:"ok"})})]})}function hB(){return o.jsxs(Er,{children:[o.jsx(jr,{x:14,label:"THIS MACHINE"}),o.jsx(hh,{x:28,y:60}),o.jsx("g",{className:"ga-swap-out",children:o.jsx(Qr,{x:28,y:98,email:"work@team.dev",state:"login expired",tone:"warn"})}),o.jsx("g",{className:"ga-swap-in",children:o.jsx(Qr,{x:28,y:98,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),o.jsx(jr,{x:250,label:"ANOTHER MACHINE"}),o.jsx(hh,{x:264,y:60}),o.jsx(Qr,{x:264,y:98,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),o.jsx("path",{d:"M246 120C234 80 206 80 194 120",className:"ga-arc"}),o.jsx("g",{className:"ga-travel ga-travel-low",transform:"translate(220 90)",children:o.jsx(G0,{})})]})}const fB=[{art:o.jsx(aB,{}),line:"Sessions waiting on you top the session list, longest wait first.",tip:"A tone and a system notification when one stops to ask. The speaker in the topbar."},{art:o.jsx(oB,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:o.jsx(lB,{}),line:"Double-click any node: its prompt, every tool call, tokens and timing."},{art:o.jsx(iB,{}),line:"What each session costs, and how much quota is left."},{art:o.jsx(cB,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:o.jsx(dB,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:o.jsx(hB,{}),line:"Your machines repair each other's expired logins over the local network.",tip:"Open it from the row at the foot of the Claude accounts panel."},{art:o.jsx(uB,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function pB(){return o.jsxs(Er,{children:[o.jsx(jr,{x:14,label:"THIS MACHINE"}),o.jsx(Qr,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"}),o.jsx("rect",{x:40,y:94,width:86,height:20,rx:10,className:"ga-pill-warn"}),o.jsx("text",{x:83,y:108,className:"ga-s ga-warn",textAnchor:"middle",children:"sign in again"}),o.jsx("line",{x1:198,y1:100,x2:242,y2:100,className:"ga-off"}),o.jsx(jr,{x:250,label:"ANOTHER MACHINE"}),o.jsx(Qr,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function mB(){return o.jsxs(Er,{children:[o.jsx(jr,{x:14,label:"THIS MACHINE"}),o.jsx(hh,{x:28,y:60}),o.jsx(Md,{x:28,y:92,name:"Ana's MacBook"}),o.jsx(Md,{x:28,y:114,name:"Dorin's PC"}),o.jsx(jr,{x:250,label:"ANOTHER MACHINE"}),o.jsx(hh,{x:264,y:60}),o.jsx(Md,{x:264,y:92,name:"Your MacBook"}),o.jsx(Md,{x:264,y:114,name:"Dorin's PC"}),o.jsx("line",{x1:196,y1:100,x2:244,y2:100,className:"ga-arc"}),o.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping"}),o.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping ga-ping-2"}),o.jsx("circle",{cx:220,cy:100,r:3,className:"ga-accent"})]})}function gB(){return o.jsxs(Er,{children:[o.jsx("rect",{x:90,y:18,width:260,height:164,rx:10,className:"ga-screen"}),o.jsx("text",{x:106,y:42,className:"ga-t ga-strong",children:"This deck on the network"}),o.jsx("line",{x1:90,y1:54,x2:350,y2:54,className:"ga-line"}),o.jsx("text",{x:106,y:76,className:"ga-cap",children:"SHARE THESE ACCOUNTS"}),o.jsx(l_,{x:106,y:88,on:!0}),o.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),o.jsx(l_,{x:106,y:112}),o.jsx("text",{x:126,y:122,className:"ga-s ga-mono",children:"personal@me.dev"}),o.jsx("text",{x:106,y:150,className:"ga-cap",children:"PAIRING"}),o.jsx("text",{x:106,y:168,className:"ga-s",children:"Say yes to every deck that asks"}),o.jsx(YR,{x:304,y:157,on:!0}),o.jsx(V0,{x:115,y:97})]})}function yB(){return o.jsxs(Er,{children:[o.jsx(jr,{x:14,label:"THIS MACHINE"}),o.jsx("g",{className:"ga-swap-out",children:o.jsx(Qr,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"})}),o.jsx("g",{className:"ga-swap-in",children:o.jsx(Qr,{x:28,y:64,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),o.jsx(jr,{x:250,label:"ANOTHER MACHINE"}),o.jsx(Qr,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),o.jsx("path",{d:"M246 96C234 56 206 56 194 96",className:"ga-arc"}),o.jsx("g",{className:"ga-travel",transform:"translate(220 66)",children:o.jsx(G0,{})})]})}const wB=[{art:o.jsx(pB,{}),line:"A login can expire on one machine while it still works on another."},{art:o.jsx(mB,{}),line:"Both decks are on. They find each other and ask to pair.",tip:"Not showing up? The + in the section reaches a machine by address or invite."},{art:o.jsx(gB,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:o.jsx(yB,{}),line:"An expired login is copied from a paired machine within a minute."}];function vB(){return o.jsxs("svg",{className:"guide-art",viewBox:"0 0 232 60","aria-hidden":!0,focusable:"false",children:[o.jsx("rect",{x:1,y:14,width:78,height:42,rx:7,className:"ga-screen"}),o.jsx("circle",{cx:13,cy:29,r:3,className:"ga-warn"}),o.jsx("rect",{x:21,y:27,width:46,height:4,rx:2,className:"ga-track"}),o.jsx("rect",{x:13,y:39,width:40,height:3,rx:1.5,className:"ga-track"}),o.jsx("rect",{x:153,y:14,width:78,height:42,rx:7,className:"ga-screen"}),o.jsx("circle",{cx:165,cy:29,r:3,className:"ga-ok"}),o.jsx("rect",{x:173,y:27,width:46,height:4,rx:2,className:"ga-track"}),o.jsx("rect",{x:165,y:39,width:40,height:3,rx:1.5,className:"ga-accent"}),o.jsx("path",{d:"M150 36C138 6 94 6 82 36",className:"ga-arc"}),o.jsx("g",{transform:"translate(116 13)",children:o.jsx(G0,{})})]})}const xB={panel:"Nothing here is stuck: whoever pastes an invite is the one dialling out. Ask them for one and paste it behind the + above, where an address can be typed too.",dialog:"Nothing here is stuck: whoever pastes an invite is the one dialling out. Ask them for one and paste it below, or type their address."},bB=1600;function XR({reach:e,where:t}){const[n,r]=x.useState(!1),a=x.useRef(!0);x.useEffect(()=>()=>{a.current=!1},[]);const l=(e==null?void 0:e.steps)??[],c=x.useCallback(async()=>{await sl(l.join(`
|
|
91
91
|
`))&&a.current&&(r(!0),window.setTimeout(()=>{a.current&&r(!1)},bB))},[l]);if(!(e!=null&&e.blocked))return null;const u=e.shell==="sh";return o.jsxs("div",{className:"ap-lan-reach",children:[o.jsx("p",{className:"lan-warn",children:e.text}),o.jsx("p",{className:"lan-note",children:xB[t]}),l.length>0&&o.jsxs("details",{className:"ap-lan-reach-fix",children:[o.jsx("summary",{children:"or let them find this deck on their own"}),o.jsxs("p",{className:"lan-note",children:[u?o.jsx(o.Fragment,{children:"Run this in a terminal on this machine, then restart the deck."}):o.jsxs(o.Fragment,{children:["Run this in PowerShell ",o.jsx("strong",{children:"as Administrator"}),", then restart the deck."]}),e.category==="Public"&&o.jsx(o.Fragment,{children:" The first line marks this network as a home or office one — leave it out on a network you do not trust."}),e.unsure&&o.jsxs(o.Fragment,{children:[" ",e.unsure]})]}),o.jsx("pre",{className:"ap-lan-cmd",children:o.jsx("code",{children:l.join(`
|
|
92
|
-
`)})}),o.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>void c(),title:u?"Copy these lines, then paste them into a terminal":"Copy these lines, then paste them into an elevated PowerShell",children:n?"copied":"copy command"})]})]})}async function Wp(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const kB={not_an_invite:"That is not an invite — paste the whole line they sent you.",expired:"That invite has run out. Ask them for a fresh one.",not_running:"This deck is not on the network yet. Turn Local network on, then try again."},NB={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function d_(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||tn(n,t)}function _B({status:e,manual:t,onClose:n,onChanged:r}){const a=x.useRef(null),l=sn(n,{focusRef:a}),[c,u]=x.useState(""),[f,p]=x.useState(""),[h,m]=x.useState(null),[y,w]=x.useState(null),[j,k]=x.useState(null),[S,b]=x.useState(null),[N,E]=x.useState(()=>Date.now());x.useEffect(()=>{const $=window.setInterval(()=>E(Date.now()),1e3);return()=>window.clearInterval($)},[]);const C=x.useRef(!0);x.useEffect(()=>()=>{C.current=!1},[]);const T=x.useRef(null),A=x.useCallback($=>Oh(T.current)?(T.current=$,k($),!0):!1,[]),I=x.useCallback(()=>{T.current=null,C.current&&k(null)},[]),B=$=>{const z=Fa(j,$);return{disabled:z.disabled,"aria-busy":z.busy}},q=$=>(h==null?void 0:h.field)===$?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},L=$=>m(z=>z&&z.field===$?null:z),U=x.useCallback(async()=>{const $=qB(c);if(!$){m({text:SB(c),field:"addr"});return}const z=`${$.addr}:${$.port}`,W=e.peers.find(G=>G.addr===$.addr&&G.port===$.port&&G.paired);if(W){m({text:`Already paired with ${W.name} at that address.`,field:"addr"});return}if(t.includes(z)){m({text:"This deck already calls that address.",field:"addr"});return}if(A("add"))try{const G=await Wp("/api/prefs",{lan:{manual:[...t,z]}});if(!C.current)return;G!=null&&G.ok?(m(null),u(""),r(),n()):m({text:tn("add that address",G),field:"addr"})}catch{C.current&&m({text:tn("add that address",null),field:"addr"})}finally{I()}},[c,t,e.peers,r,n,A,I]),X=x.useCallback(async $=>{if(!A(`invite:${$}`))return;const z=$==="make"?"make an invite":"cancel that invite";try{const W=await Wp("/api/lan/invite",{action:$});if(!C.current)return;W!=null&&W.ok?(m(null),w(null),r()):m({text:d_(NB,W,z)})}catch{C.current&&m({text:tn(z,null)})}finally{I()}},[r,A,I]),Y=x.useCallback(async()=>{const $=f.trim();if(!(!$||!A("join"))){b(null);try{const z=await Wp("/api/lan/invite",{action:"join",token:$});if(!C.current)return;z!=null&&z.ok?(p(""),m(null),r(),n()):(z==null?void 0:z.reason)==="unreachable"&&Array.isArray(z.tried)&&z.tried.length?(b(z.tried),m(null)):(b(null),m({text:d_(kB,z,"use that invite"),field:"join"}))}catch{C.current&&m({text:tn("use that invite",null),field:"join"})}finally{I()}}},[f,r,n,A,I]),M=x.useCallback(async($,z)=>{try{await navigator.clipboard.writeText($),w(z),window.setTimeout(()=>{C.current&&w(W=>W===z?null:W)},1600)}catch{m({text:"Could not copy it — select the text and copy it by hand."})}},[]),J=e.invite&&e.invite.expiresAt>N?e.invite:null,V=e.port!=null?(e.addrs??[]).map($=>`${$}:${e.port}`):[];return Sn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:o.jsxs("div",{ref:l,className:"modal lan-add",onClick:$=>$.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-add-title",children:[o.jsxs("header",{className:"modal-head",children:[o.jsx("div",{className:"modal-title",children:o.jsx("span",{id:"lan-add-title",className:"modal-tool-name",children:"Add a deck"})}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body",children:[h&&o.jsxs("div",{className:"ap-failure",role:"alert",children:[o.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:h.text}),o.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>m(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),o.jsx(XR,{reach:e.reach,where:"dialog"}),o.jsxs("div",{className:"modal-section",children:[o.jsx("h3",{className:"lan-h",children:"By address"}),o.jsxs("div",{className:"ap-lan-row",children:[o.jsx("input",{ref:a,className:"ap-manage-input ap-lan-input","aria-label":"Another deck's address",value:c,placeholder:"192.168.1.5:54340",spellCheck:!1,...q("addr"),onChange:$=>{u($.target.value),L("addr")},onKeyDown:$=>{$.key==="Enter"&&U()}}),c.trim()!==""&&o.jsx("button",{type:"button",className:"ap-manage-btn",...B("add"),onClick:()=>void U(),title:"Add it to the decks this one calls, starting now.",children:"add"})]}),o.jsx("p",{className:"lan-note",children:"This deck calls that address until somebody there accepts."}),e.port!=null&&V.length>0&&o.jsxs("p",{className:"lan-note",children:["They type this deck’s own address into the same field on theirs:"," ",V.map(($,z)=>o.jsxs("span",{children:[z>0&&" or ",o.jsx("code",{className:"ap-lan-code",children:$})]},$)),o.jsx("button",{type:"button",className:"ap-lan-word lan-copy",...B("copy:mine"),onClick:()=>void M(V.join(" "),"mine"),title:"Copy this deck's address, to send to whoever is adding it",children:y==="mine"?"copied":"copy"})]})]}),o.jsxs("div",{className:"modal-section",children:[o.jsxs("h3",{className:"lan-h",children:["With an invite",!J&&o.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",...B("invite:make"),onClick:()=>void X("make"),title:"One piece of text you send them. They paste it, and the two decks pair — nobody has to press anything here.",children:j==="invite:make"?"making…":"make one to send"})]}),o.jsxs("div",{className:"ap-lan-row",children:[o.jsx("input",{className:"ap-manage-input ap-lan-input","aria-label":"An invite you were sent",value:f,placeholder:"paste one you were sent",spellCheck:!1,...q("join"),onChange:$=>{p($.target.value),b(null),L("join")},onKeyDown:$=>{$.key==="Enter"&&Y()}}),f.trim()!==""&&o.jsx("button",{type:"button",className:"ap-manage-btn",...B("join"),onClick:()=>void Y(),title:"Reach that deck and pair with it. Nobody has to press anything there.",children:j==="join"?"joining…":"join"})]}),o.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),S&&o.jsxs("div",{className:"ap-lan-tried",children:[o.jsx("span",{className:"lan-note",children:"Nothing answered at any address in that invite. Check that deck is running with its Local network switch on."}),S.map($=>o.jsxs("span",{className:"ap-lan-tried-row",children:[o.jsx("code",{className:"ap-lan-code",children:$.addr}),o.jsx("span",{className:"ap-lan-bad",children:$.why})]},$.addr))]}),J&&o.jsxs("div",{className:"ap-lan-invite",children:[o.jsxs("div",{className:"ap-lan-invite-head",children:[o.jsx("span",{className:"ap-lan-invite-title",children:"Send this to them"}),o.jsxs("span",{className:"ap-lan-invite-left",children:[HB(J.expiresAt,N)," left"]})]}),o.jsx("code",{className:"ap-lan-token",children:J.token}),o.jsxs("div",{className:"ap-lan-acts",children:[o.jsx("button",{type:"button",className:"ap-manage-btn",...B("copy:invite"),onClick:()=>void M(J.token,"invite"),title:"Copy it, and send it however you already talk to them",children:y==="invite"?"copied":"copy"}),o.jsx("button",{type:"button",className:"ap-manage-btn",...B("invite:withdraw"),onClick:()=>void X("withdraw"),title:"Cancel it. Anybody already holding the text can no longer use it.",children:"cancel"})]}),o.jsx("p",{className:"lan-warn",children:"Anyone who gets this text can pair with this deck until it runs out."})]})]})]})]})}),document.body)}function SB(e){const t=(e??"").trim();if(t==="")return"Type an address and a port, like 192.168.1.5:54340.";if(!t.startsWith("[")&&(t.match(/:/g)??[]).length>1)return"Too many colons to split. Use that deck's IPv4 address or its name, like 192.168.1.5:54340.";if(!t.includes(":"))return`Add the port too, like ${t}:54340.`;const n=t.slice(t.lastIndexOf(":")+1).trim();return n===""?"That is missing its port — try 192.168.1.5:54340.":/^\d+$/.test(n)?`A port runs from 1 to 65535, and this one is ${n}.`:`A port is a number, and this one is "${n}".`}const jB=1e3;function EB(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),r=xs(e,t);return`${n} · ${r==="now"?"just now":r}`}function h_(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}function CB(){return o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M9.6 2.4l2 2L5 11l-2.6.6L3 9z"}),o.jsx("path",{d:"M8.4 3.6l2 2"})]})}function f_(){return o.jsxs("svg",{className:"lan-machine",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("rect",{x:"2.5",y:"3",width:"11",height:"7.5",rx:"1.2"}),o.jsx("path",{d:"M1 13h14"})]})}function Id({dir:e,gate:t=!1}){const n=t?12:8;return o.jsx("svg",{className:"lan-chev","data-dir":e,"data-gate":t||void 0,width:n,height:"8",viewBox:`0 0 ${n} 8`,fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:o.jsx("path",{d:e==="out"?"M2.8 1L6 4 2.8 7":t?"M1 1v6M9.6 1L6.4 4l3.2 3":"M5.2 1L2 4l3.2 3"})})}const TB={works:"works here",expired:"expired here",missing:"not on this deck"},AB={works:"works there",broken:"broken there",unknown:"not offered by that deck"};function RB(e){const t=e.in&&e.out?"offered both ways":e.in?"offered by that deck":"offered by this deck";return`${TB[e.here]}, ${AB[e.there]}, ${t}${e.usedThere?", in use there":""}.`}function MB({row:e,source:t,status:n,accounts:r,now:a,busy:l,onClose:c,onRename:u,onCheck:f,onVerb:p,onSettings:h,twins:m=[],onUnpair:y}){var vt,an,jn,Nt,Yt;const w=x.useRef(null),j=sn(c,{focusRef:w}),[k,S]=x.useState(null),[b,N]=x.useState(null),[E,C]=x.useState(!1),T=x.useRef(0),[A,I]=x.useState(null),[B,q]=x.useState(!1),[L,U]=x.useState(0),X=x.useRef(null),Y=x.useRef(!0);x.useEffect(()=>()=>{Y.current=!1},[]);const M=k!=null;x.useEffect(()=>{var fe;M&&((fe=X.current)==null||fe.select())},[M]),x.useEffect(()=>{if(!E)return;const fe=window.setTimeout(()=>C(!1),4e3);return()=>window.clearTimeout(fe)},[E]),x.useEffect(()=>{if(!A)return;const fe=window.setTimeout(()=>I(null),4e3);return()=>window.clearTimeout(fe)},[A]);const J=fe=>{const st=Fa(l,fe);return{disabled:st.disabled,"aria-busy":st.busy}},V=async fe=>{const st=await fe();return Y.current&&N(st),st==null},{peer:$,stranger:z}=t,W=e.kind==="paired",G=e.self??e.name,F=e.kind!=="dialling",K=e.kind==="dialling"?null:e.fp,de=$?$.addr?`${$.addr}:${$.port}`:"":z?z.port?`${z.addr}:${z.port}`:z.addr:e.addr,H=($==null?void 0:$.about)??null,Q=((vt=n.about)==null?void 0:vt.version)??null,O=async fe=>{const st=fe.trim()===G?"":fe;await V(()=>u(st))&&S(null)},te=async()=>{if(K)try{if(await navigator.clipboard.writeText(K),!Y.current)return;q(!0),window.setTimeout(()=>{Y.current&&q(!1)},1600)}catch{Y.current&&N("Could not copy it — select the fingerprint and copy it by hand.")}},ae=W?$!=null&&$.waiting?$.lastSeen!=null?"not said — it runs an older version":"not said yet — it says when it next calls":$!=null&&$.offers?"not said — it runs an older version":"not reached yet":"shown once paired",he=h_(n.about),ge=h_(H),Te=H!=null&&H.version&&Q?QB(H.version,Q):null,De=$?ZR($.last,a):null,Ve=$&&((an=$.last)!=null&&an.error)?FB({error:$.last.error,host:$.addr,port:$.port},[...n.strangers??[],...n.pending??[],...(n.peers??[]).filter(fe=>!fe.manual&&fe.addr).map(fe=>({fp:fe.fp,name:fe.name,addr:fe.addr,port:fe.port,at:fe.lastSeen??0}))],a):null,je=(jn=$==null?void 0:$.last)!=null&&jn.error&&De&&De.text!==$.last.error?$.last.error:null,ve=((Nt=$==null?void 0:$.last)==null?void 0:Nt.done)??[],Ue=!!De&&!!je&&!e.quiet&&e.state.startsWith(De.text),ke=W||e.kind==="dialling",xe=(($==null?void 0:$.via)??e.via)==="tailscale",Ge=$?$.waiting?null:$.manual?xe?"added by its Tailscale address":"added by address":xe?"over Tailscale":"on this network":e.kind==="nearby"?xe?"heard over Tailscale":"heard on this network":xe?"asked this deck to pair, over Tailscale":"asked this deck to pair",rt=e.tone==="bad"?"bad":W?e.here?"up":"down":"loose",at=l===`check:${e.fp}`,le=($==null?void 0:$.offers)??null,_e=rt==="up"?(le==null?void 0:le.current)??null:null,Ie=_e&&"key"in _e?_e.key:null,Ze=!!_e&&"hidden"in _e,We=!!_e&&"other"in _e,Je=W?ez((le==null?void 0:le.accounts)??null,r,n.shared??[],Ie):[],ye=Je.filter(fe=>fe.in==null&&fe.out==="cut"),Me=Je.some(fe=>fe.in!=null),Qe=Je.some(fe=>fe.out!=null),ue=new Map(ve.map(fe=>[fe.email,fe])),kt=ve.filter(fe=>!Je.some(st=>st.email===fe.email)),pt=W?le?le.accounts.length===0?"That deck offers nothing. Nobody there has chosen a login to share.":null:$!=null&&$.waiting?"What that deck offers is not known yet. A deck that calls in says so each time it calls — one on an older version never does.":(Yt=$==null?void 0:$.last)!=null&&Yt.error?"What that deck offers is not known — the last attempt to ask it did not get through.":"Nobody has asked that deck what it offers yet. The next round asks it.":null,ut=le&&($!=null&&$.last)&&$.last.at-le.at>jB?xs(le.at,a):null,Bt=[];W&&($!=null&&$.pairedAt)?Bt.push({label:"Paired",value:EB($.pairedAt,a),tone:"meta"}):e.kind==="declined"&&z&&Bt.push({label:"Paired",value:`no · you said no ${Y0(z.at,a)}`,tone:"meta"}),Bt.push({label:"Fingerprint",value:K?o.jsxs("span",{className:"lan-fp",children:[o.jsx("code",{className:"ap-lan-code",children:K}),o.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void te(),"aria-label":B?"Fingerprint copied":"Copy the fingerprint",children:B?"copied":"copy"})]}):"not known — nothing has answered there",tone:K?void 0:"quiet"});const jt=m.length?[{row:e,peer:$??null},...m]:[];return Sn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:c,role:"presentation",children:o.jsxs("div",{ref:j,className:"modal lan-peer","data-tone":e.tone,onClick:fe=>fe.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-peer-title","aria-describedby":"lan-peer-sub",children:[o.jsxs("header",{className:"modal-head lan-peer-head",children:[o.jsx("i",{className:e.here?"ap-pulse":"ap-dot","aria-hidden":!0}),o.jsxs("div",{className:"lan-peer-id",children:[M?o.jsxs("form",{className:"lan-peer-edit",onSubmit:fe=>{fe.preventDefault(),O(k??"")},children:[o.jsx("span",{id:"lan-peer-title",className:"vis-hidden",children:e.name}),o.jsx("input",{ref:X,className:"ap-manage-input lan-peer-input",value:k??"",maxLength:48,placeholder:G,"aria-label":"Name for this deck, shown on this deck only",onChange:fe=>S(fe.target.value)}),o.jsx("button",{type:"submit",className:"ap-manage-btn",...J(`alias:${e.fp}`),children:"save"}),o.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>S(null),children:"cancel"})]}):o.jsxs("span",{className:"lan-peer-title",children:[o.jsx("span",{id:"lan-peer-title",className:"lan-peer-name",children:e.name}),F&&o.jsx("button",{type:"button",className:"glyph-btn lan-peer-rename",onClick:()=>{N(null),S(e.name)},"aria-label":`Rename ${e.name} on this deck`,title:"Give it a name of your own. Only this deck sees it.",children:o.jsx(CB,{})})]}),o.jsxs("p",{id:"lan-peer-sub",className:"lan-peer-sub",children:[e.self&&o.jsxs(o.Fragment,{children:["calls itself ",o.jsx("span",{className:"lan-peer-self",children:e.self}),M&&o.jsx("button",{type:"button",className:"ap-lan-word lan-peer-restore",...J(`alias:${e.fp}`),onClick:()=>void O(""),children:"use this name"}),o.jsx("span",{className:"vis-hidden",children:". "}),!e.quiet&&o.jsx("span",{"aria-hidden":!0,children:" · "})]}),o.jsx("span",{className:e.quiet?"vis-hidden":"lan-peer-state",children:e.state})]})]}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{ref:w,type:"button",className:"glyph-btn",onClick:c,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body lan-peer-body",children:[b&&o.jsxs("div",{className:"ap-failure",role:"alert",children:[o.jsx("span",{className:"ap-failure-text",children:b}),o.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>N(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),o.jsxs("div",{className:"lan-map","data-link":rt,"data-asking":at||void 0,"data-bus":Je.length>0||void 0,children:[o.jsxs("div",{className:"lan-ends",children:[o.jsxs("p",{className:"lan-end",children:[o.jsx("span",{className:"lan-end-name",children:"This deck"}),he&&o.jsx("span",{className:"lan-end-runs",children:he}),W&&n.shareActive===!1&&o.jsx("span",{className:"lan-end-note",children:"current account hidden"})]}),o.jsxs("p",{className:"lan-end","data-side":"there",children:[o.jsx("span",{className:"lan-end-name",children:e.name}),e.kind!=="dialling"&&o.jsxs("span",{className:"lan-end-runs",children:[ge??(H?"not said":ae),Te?` · ${Te<0?"older":"newer"}`:null]}),Ze&&o.jsx("span",{className:"lan-end-note",children:"current account hidden"}),We&&o.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),o.jsxs("div",{className:"lan-link",children:[o.jsx(f_,{}),o.jsxs("span",{className:"lan-span",children:[o.jsxs("span",{className:"lan-wire","aria-hidden":!0,children:[o.jsx("i",{className:"lan-glint","data-dir":"out"}),o.jsx("i",{className:"lan-glint","data-dir":"in"})]}),o.jsx("span",{className:"lan-link-label",children:de?o.jsx("code",{className:"ap-lan-code",children:de}):"none here — it calls this deck"})]}),o.jsx(f_,{}),(de&&Ge||ke)&&o.jsxs("p",{className:"lan-link-sub",children:[de&&Ge,de&&Ge&&ke&&" · ",ke&&(De?Ue?o.jsx("code",{className:"ap-lan-code",children:je}):o.jsx("span",{className:"lan-round","data-tone":De.tone,children:De.text.replace(/ · now$/," · just now")}):"not asked yet"),ke&&je&&!Ue&&o.jsx("code",{className:"lan-fact-raw",children:je})]}),kt.length>0&&o.jsx("ul",{className:"lan-done",children:kt.map(fe=>o.jsxs("li",{"data-ok":fe.ok,children:[fe.email," ",o.jsx("span",{className:"lan-done-what",children:fe.ok?"arrived":"did not arrive"})]},`${fe.email}:${fe.action}`))}),Ve&&o.jsx("p",{className:"lan-note lan-link-note",children:Ve}),($==null?void 0:$.waiting)&&o.jsx("p",{className:"lan-note lan-link-note",children:e.hint})]}),Je.length>0&&o.jsx("ul",{className:"lan-lanes",role:"list","aria-label":`Logins between this deck and ${e.name}`,children:Je.map((fe,st)=>{const It=ue.get(fe.email),Et=fe.out==="live"||fe.in!=null&&fe.in!=="cut";return o.jsxs("li",{role:"listitem",className:"lan-lane","data-tone":fe.tone,"data-draw":fe.in&&fe.out?"both":fe.in?"in":"out","data-used-there":fe.usedThere||void 0,style:{"--i":st},children:[o.jsx("i",{className:"lan-pip","data-end":"here","data-state":fe.here,"aria-hidden":!0}),o.jsxs("span",{className:"lan-track",children:[o.jsxs("span",{className:"lan-wire","data-flow":Et?"live":"cut","aria-hidden":!0,children:[(fe.in==="live"||fe.in==="wait")&&o.jsx("i",{className:"lan-glint","data-dir":"in","data-tone":fe.in}),fe.out==="live"&&o.jsx("i",{className:"lan-glint","data-dir":"out"})]}),fe.in&&fe.in!=="cut"&&o.jsx(Id,{dir:"in",gate:fe.in==="blocked"}),fe.out==="live"&&o.jsx(Id,{dir:"out"}),o.jsx("span",{className:"lan-lane-email",children:fe.email})]}),o.jsx("i",{className:"lan-pip","data-end":"there","data-state":fe.there,"aria-hidden":!0}),o.jsx("span",{className:"vis-hidden",children:RB(fe)}),(fe.caption||It)&&o.jsxs("span",{className:"lan-lane-note",children:[fe.caption,fe.caption&&It&&" · ",It&&o.jsx("span",{className:"lan-lane-done","data-ok":It.ok,children:It.ok?"arrived last round":"did not arrive last round"})]})]},fe.key)})},L),W&&o.jsxs(o.Fragment,{children:[ye.length>0&&o.jsxs("p",{className:"lan-spent",children:["Paired decks get nothing from ",ye.length===1?ye[0].email:"the expired ones"," until you sign in again here."]}),pt&&o.jsx("p",{className:"lan-empty",children:pt}),ut&&o.jsxs("p",{className:"lan-stale",children:["As of ",ut==="now"?"just now":ut,", when it last answered."]}),o.jsxs("div",{className:"lan-legend",children:[Me&&o.jsxs("span",{className:"lan-key",children:[o.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:o.jsx(Id,{dir:"in"})}),"from ",e.name]}),Qe?o.jsxs("span",{className:"lan-key",children:[o.jsx("span",{className:"lan-key-wire","data-dir":"out","aria-hidden":!0,children:o.jsx(Id,{dir:"out"})}),"from this deck, to every paired deck"]}):o.jsx("span",{className:"lan-key",children:"This deck offers nothing yet."}),o.jsx("button",{type:"button",className:"ap-lan-word lan-legend-act",onClick:h,"aria-label":"Change what this deck offers",children:"change"})]})]})]}),o.jsx("dl",{className:"lan-facts",children:Bt.map(fe=>o.jsxs("div",{className:"lan-fact","data-tone":fe.tone,children:[o.jsx("dt",{children:fe.label}),o.jsx("dd",{children:fe.value})]},fe.label))}),jt.length>1&&o.jsxs("div",{className:"modal-section",children:[o.jsxs("h3",{className:"lan-h",children:[jt.length," decks on this machine"]}),o.jsx("ul",{className:"lan-twins",role:"list",children:jt.map((fe,st)=>{var lr,yn,Xt,Cn;const It=(lr=fe.peer)!=null&&lr.addr?`${fe.peer.addr}:${fe.peer.port}`:fe.row.addr,Et=It||fe.row.fp,En=(yn=fe.peer)!=null&&yn.pairedAt?xs(fe.peer.pairedAt,a):null,Gn=[(Cn=(Xt=fe.peer)==null?void 0:Xt.about)!=null&&Cn.version?`runs ${fe.peer.about.version}`:null,En?`paired ${En==="now"?"just now":En}`:null,fe.row.state].filter(Boolean).join(" · "),St=fe.row.fp;return o.jsxs("li",{role:"listitem",className:"lan-twin","data-tone":fe.row.tone,children:[o.jsx("i",{className:fe.row.here?"ap-pulse":"ap-dot","aria-hidden":!0}),It?o.jsx("code",{className:"ap-lan-code lan-twin-at",children:It}):o.jsx("span",{className:"lan-twin-at lan-twin-none",children:"no address here"}),o.jsx("code",{className:"ap-lan-code lan-twin-fp",children:St}),st>0&&y&&o.jsx("button",{type:"button",className:`ap-manage-btn danger lan-twin-do${A===St?" armed":""}`,...J(`unpair:${St}`),onKeyDown:zt=>{zt.repeat&&zt.preventDefault()},onClick:()=>{const zt=Date.now(),In=uh({armedFor:A,target:St,armedAt:T.current,now:zt,gapMs:fh});if(In==="arm"){I(St),T.current=zt;return}In!=="ignore"&&(I(null),V(()=>y(St)))},"aria-label":A===St?`Confirm unpairing ${Et}`:`Unpair ${Et}`,title:A===St?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this one of the machine's decks",children:l===`unpair:${St}`?"unpairing…":A===St?"confirm":"unpair"}),o.jsx("span",{className:"lan-twin-meta",children:st===0?`${Gn} · shown above`:Gn})]},St)})})]})]}),o.jsxs("footer",{className:"lan-peer-foot",children:[e.kind==="asks"&&o.jsx("p",{className:"lan-foot-note",children:"This deck is now asking to pair. Answer it from the panel behind this."}),W&&!($!=null&&$.waiting)&&o.jsx("button",{type:"button",className:"btn",...J(`check:${e.fp}`),onClick:()=>void V(f).then(fe=>{fe&&Y.current&&U(st=>st+1)}),title:"Ask this deck now instead of waiting for the next round",children:l===`check:${e.fp}`?"Checking…":"Check now"}),e.kind==="paired"&&o.jsx("button",{type:"button",className:`btn danger lan-peer-verb${E?" armed":""}`,...J(`unpair:${e.fp}`),onKeyDown:fe=>{fe.repeat&&fe.preventDefault()},onClick:()=>{const fe=Date.now(),st=uh({armedFor:E?e.fp:null,target:e.fp,armedAt:T.current,now:fe,gapMs:fh});if(st==="arm"){C(!0),T.current=fe;return}st!=="ignore"&&(C(!1),V(p))},"aria-label":E?`Confirm unpairing ${e.name}`:`Unpair ${e.name}`,title:E?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this deck from now on",children:l===`unpair:${e.fp}`?"Unpairing…":E?"Confirm unpair":"Unpair"}),e.kind==="nearby"&&o.jsx("button",{type:"button",className:"btn primary lan-peer-verb",...J(`accept:${e.fp}`),onClick:()=>void V(p),title:"Send it a request. Somebody at that machine has to accept it before anything is shared.",children:l===`accept:${e.fp}`?"Asking…":"Ask to pair"}),e.kind==="dialling"&&o.jsx("button",{type:"button",className:"btn lan-peer-verb",...J(`drop:${e.fp}`),onClick:()=>void V(p),title:"Stop trying this address. Nothing was ever paired here.",children:l===`drop:${e.fp}`?"Stopping…":"Stop dialling"}),e.kind==="declined"&&o.jsx("button",{type:"button",className:"btn lan-peer-verb",...J(`allow:${e.fp}`),onClick:()=>void V(p),title:"Take the no back. That deck is still trying, so its request comes round again on its own.",children:l===`allow:${e.fp}`?"Allowing…":"Let it ask again"})]})]})}),document.body)}function IB(e){if(!e.running)return`Tailscale is ${e.state==="Stopped"?"turned off":e.state==="NeedsLogin"||e.state==="NeedsMachineAuth"?"signed out":e.state==="Starting"?"still starting":"not answering"} on this machine`;const t=e.login??"your Tailscale account";return e.on?`${e.devices} online · ${t}`:t}function $B({status:e,accounts:t,onClose:n,onChanged:r}){const a=sn(n),[l,c]=x.useState(null),[u,f]=x.useState(null),[p,h]=x.useState(!1),[m,y]=x.useState(null),w=x.useRef(null),j=X=>{const Y=Fa(m,X);return{disabled:Y.disabled,"aria-busy":Y.busy}},k=x.useRef(null),S=x.useRef(!0);x.useEffect(()=>()=>{S.current=!1},[]),x.useEffect(()=>{k.current=p_(k.current,e.shared??[],null)},[e.shared]);const b=x.useCallback(async(X,Y,M="write")=>{w.current=M,y(M);try{const V=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:X})})).json().catch(()=>null);return S.current?(V!=null&&V.ok?f(null):f(tn(Y,V)),r(),(V==null?void 0:V.ok)===!0):!1}catch{return S.current&&f(tn(Y,null)),!1}finally{w.current=null,S.current&&y(null)}},[r]),N=x.useCallback(async()=>{if(l!=null&&l!==(e.name??"")){if(!await b({name:l},"save the name","name"))return;S.current&&c(null)}n()},[l,e.name,b,n]),E=async()=>{if(!e.fp)return;const X=await sl(e.fp);if(S.current){if(!X){f("Could not copy it — select the fingerprint and copy it by hand.");return}h(!0),window.setTimeout(()=>{S.current&&h(!1)},1600)}},C=new Set(k.current??e.shared??[]),T=e.autoAsk!==!1,A=e.autoAccept!==!1,I=e.shareActive!==!1,B=e.tailscale??null,q=!!(B!=null&&B.on),L=(B==null?void 0:B.ask)!==!1,U=(B==null?void 0:B.accept)!==!1;return Sn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:o.jsxs("div",{ref:a,className:"modal lan-modal",onClick:X=>X.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-modal-title",children:[o.jsxs("header",{className:"modal-head",children:[o.jsx("div",{className:"modal-title",children:o.jsx("span",{id:"lan-modal-title",className:"modal-tool-name",children:"This deck on the network"})}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body",children:[u&&o.jsxs("div",{className:"ap-failure",role:"alert",children:[o.jsx("span",{className:"ap-failure-text",children:u}),o.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>f(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),o.jsxs("div",{className:"modal-section",children:[o.jsx("h3",{className:"lan-h",children:"Name"}),o.jsxs("div",{className:"ap-lan-row",children:[o.jsx("span",{className:"ap-lan-label",children:"appear as"}),o.jsx("input",{className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:l??e.name??"",placeholder:"this machine",onChange:X=>c(X.target.value),onKeyDown:X=>{X.key!=="Enter"||l==null||(b({name:l},"save the name","name"),c(null))}}),l!=null&&l!==(e.name??"")&&o.jsx("button",{type:"button",className:"ap-manage-btn",...j("name"),onClick:()=>{b({name:l},"save the name","name"),c(null)},title:"Save it. This is the name other decks show for this one.",children:"save"})]}),o.jsxs("div",{className:"ap-lan-row",children:[o.jsx("span",{className:"ap-lan-label",children:"fingerprint"}),e.fp?o.jsxs("span",{className:"lan-fp",children:[o.jsx("code",{className:"ap-lan-code",children:e.fp}),o.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void E(),"aria-label":p?"Fingerprint copied":"Copy this deck's fingerprint",children:p?"copied":"copy"})]}):o.jsx("span",{className:"ap-lan-label",children:"not known yet"})]})]}),o.jsxs("div",{className:"modal-section",children:[o.jsx("h3",{className:"lan-h",children:"Share these accounts"}),o.jsxs("div",{className:"ap-lan-picks",children:[t.length===0&&o.jsx("span",{className:"ap-lan-empty",children:"No Claude accounts on this deck yet — add one with + at the top of this panel."}),t.map(X=>o.jsxs("label",{className:"ap-lan-pick",title:X.alive?"Offer this account to the decks you have paired with, so one whose copy has died can heal from yours. Unticking stops it being offered from now on; it does not take back a copy somebody already has.":"This deck cannot use this login, so it has nothing to offer — a deck that can will heal it",children:[o.jsx("input",{type:"checkbox",checked:C.has(X.key),onChange:Y=>{const M=zB(k.current,e.shared??[],X.key,Y.target.checked);k.current=M,b({shared:M},Y.target.checked?"share that account":"stop sharing that account").then(J=>{k.current===M&&(k.current=p_(M,e.shared??[],{ok:J}))})}}),o.jsx("span",{className:"ap-lan-pick-name",children:X.email}),!X.alive&&o.jsx("span",{className:"ap-lan-dead",children:"not working here"})]},X.key))]}),t.length>0&&o.jsxs("div",{className:"lan-switch",children:[o.jsx("span",{className:"lan-switch-what",children:"Show paired decks which of these this deck is using"}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":I,"aria-label":"Show paired decks which of these this deck is using",...j("current"),onClick:()=>void b({shareActive:!I},I?"stop showing which account this deck is using":"show which account this deck is using","current"),title:I?"Stop telling paired decks which account this one is on. They read “current account hidden” instead.":"Tell paired decks which of the ticked accounts this one is on. An unticked account is never named.",children:o.jsx("span",{className:"switch-knob"})})]})]}),o.jsxs("div",{className:"modal-section",children:[o.jsx("h3",{className:"lan-h",children:"Pairing"}),o.jsxs("div",{className:"lan-switches",children:[o.jsxs("div",{className:"lan-switch",children:[o.jsx("span",{className:"lan-switch-what",children:"Ask every deck this one finds"}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":T,"aria-label":"Ask every deck this one finds",...j("ask"),onClick:()=>void b({autoAsk:!T},T?"stop asking automatically":"ask every deck this one finds","ask"),title:T?"Stop sending requests on their own. You press ask on the row instead.":"Send a pairing request to every deck heard on this network. Somebody over there still has to say yes.",children:o.jsx("span",{className:"switch-knob"})})]}),o.jsxs("div",{className:"lan-switch",children:[o.jsx("span",{className:"lan-switch-what",children:"Say yes to every deck that asks"}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":A,"aria-label":"Say yes to every deck that asks","data-tone":"warn",...j("accept"),onKeyDown:X=>{X.repeat&&X.preventDefault()},onClick:()=>void b({autoAccept:!A},A?"stop accepting automatically":"accept every deck that asks","accept"),title:A?"Stop saying yes for you. A deck that asks waits in the panel again.":"Say yes for you. Every deck on this network that asks is paired without anybody being asked here.",children:o.jsx("span",{className:"switch-knob"})})]})]})]}),(B==null?void 0:B.found)&&o.jsxs("div",{className:"modal-section",children:[o.jsx("h3",{className:"lan-h",children:"Tailscale"}),o.jsxs("div",{className:"lan-switches",children:[o.jsxs("div",{className:"lan-switch",children:[o.jsxs("span",{className:"lan-switch-what",children:["Look for my devices",o.jsx("span",{id:"lan-ts-detail",className:"lan-switch-detail",children:IB(B)})]}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":q,"aria-label":"Look for my devices over Tailscale","aria-describedby":"lan-ts-detail",...j("tailscale"),onClick:()=>void b({tailscale:!q},q?"stop looking over Tailscale":"look for your devices over Tailscale","tailscale"),title:q?"Stop. Nothing is looked for or answered over the tailnet; decks already paired stay paired.":"Find the decks on your other machines on Tailscale, wherever they are. Only machines signed in to your Tailscale account are asked.",children:o.jsx("span",{className:"switch-knob"})})]}),q&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"lan-switch",children:[o.jsx("span",{className:"lan-switch-what",children:"Ask each device it finds"}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":L,"aria-label":"Ask each of my devices it finds over Tailscale",...j("tailscale-ask"),onClick:()=>void b({tailscaleAsk:!L},L?"stop asking your devices automatically":"ask your devices automatically","tailscale-ask"),title:L?"Stop sending requests on their own. You press ask on the row instead.":"Send a pairing request to every deck found on your devices over Tailscale.",children:o.jsx("span",{className:"switch-knob"})})]}),o.jsxs("div",{className:"lan-switch",children:[o.jsx("span",{className:"lan-switch-what",children:"Say yes to each device that asks"}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":U,"aria-label":"Say yes to my devices when they ask over Tailscale","data-tone":"warn",...j("tailscale-accept"),onKeyDown:X=>{X.repeat&&X.preventDefault()},onClick:()=>void b({tailscaleAccept:!U},U?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:U?"Stop saying yes for you. A device that asks waits in the panel again.":"Say yes for you when a deck on one of your own devices asks. Anybody else on the tailnet still waits for a press.",children:o.jsx("span",{className:"switch-knob"})})]})]})]})]})]}),o.jsxs("footer",{className:"lan-setup-foot",children:[o.jsx("span",{className:"lan-foot-note",children:"Changes are saved as you make them."}),o.jsx("button",{type:"button",className:"btn primary",...j("name"),onClick:()=>void N(),children:"Done"})]})]})}),document.body)}function xs(e,t){if(e==null)return"not seen";const n=Math.max(0,Math.round((t-e)/1e3));if(n<90)return"now";const r=Math.round(n/60);if(r<60)return`${r}m ago`;const a=Math.round(r/60);return a<48?`${a}h ago`:`${Math.round(a/24)}d ago`}const K0={"waiting for the other deck to accept this one":{text:"waiting for them to say yes",tone:"idle"},"that deck said no":{text:"it said no",tone:"bad"}},OB={ECONNREFUSED:"not listening",EHOSTUNREACH:"no route to it",ENETUNREACH:"no network here",ETIMEDOUT:"no answer",ECONNRESET:"it hung up",EHOSTDOWN:"it is down",ENOTFOUND:"name not found",EACCES:"blocked here",EPIPE:"it hung up"};function LB(e){var r;const t=PB[e];if(t)return t;const n=(r=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:r[1];return n&&OB[n]||e}const PB={"handshake timed out":"no answer","peer closed the connection":"it hung up","peer went quiet":"it stopped mid-sentence","bad reply":"it answered with nonsense","no manifest":"it would not say what it has","bad challenge":"it answered as somebody else","a different deck is answering at that address":"a different deck is at that address","that deck could not prove its own key":"it could not prove who it is","the other deck refused this one's proof":"it would not take this deck's word","the other deck refused this handshake":"it turned this deck away","that deck has this one pinned under a different key":"it knows this deck by another key"};function ZR(e,t){if(!e)return null;if(e.error)return K0[e.error]??{text:LB(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${xs(e.at,t)}`,tone:"idle"};const r=n.filter(l=>l.ok),a=r.length===1?"login":"logins";return r.length===n.length?{text:`${r.length} ${a} arrived · ${xs(e.at,t)}`,tone:"ok"}:{text:`${r.length} of ${n.length} logins arrived · ${xs(e.at,t)}`,tone:"bad"}}const DB=9e4;function FB({error:e,host:t,port:n},r,a,l=45317){if(e!=="handshake timed out")return null;const c=(t??"").trim();if(!c)return null;const u=r.filter(p=>p.addr===c&&p.port&&p.at>0&&a-p.at<DB);if(!u.length)return null;const f=[...new Set(u.map(p=>p.port))];if(n!=null&&!f.includes(n)){const p=f.length===1?`port ${f[0]}`:`ports ${f.join(" and ")}`;return`A deck at ${c} is announcing itself on ${p}, not on ${n}. This deck already hears it and dials it there, so this typed row has nothing to reach.`}return`That machine is running the deck — its beacon arrives here every half minute — and what this deck sends back never gets there. That is a firewall on ${c}, not a network fault. Whoever uses it can allow two ports: UDP ${l} and TCP ${n??f[0]}.`}const e0=5e3,QR=6e4,fh=400;function qB(e){const t=(e??"").trim(),n=t.lastIndexOf(":");if(n<=0||n===t.length-1)return null;const r=t.slice(0,n).trim(),a=Number(t.slice(n+1).trim());return!r||!Number.isInteger(a)||a<1||a>65535||r.includes(":")&&!(r.startsWith("[")&&r.endsWith("]"))?null:{addr:r,port:a}}function tn(e,t){return t==null?`Could not ${e} — the deck did not answer.`:t.reason?`Could not ${e} — the deck refused it (${t.reason}).`:`Could not ${e}.`}function BB(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(r=>n.has(r))}function zB(e,t,n,r){const a=new Set(e??t);return r?a.add(n):a.delete(n),[...a]}function p_(e,t,n){return e==null||n!=null&&!n.ok||BB(e,t)?null:e}function HB(e,t){const n=Math.max(0,Math.round((e-t)/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function JR(e,t){var n,r;return(n=e.last)!=null&&n.error&&!K0[e.last.error]?!1:!!((r=e.last)!=null&&r.at&&t-e.last.at<ph||e.lastSeen!=null&&t-e.lastSeen<ph)}const ph=95e3,eM=160,UB=6,tM=140;function WB(e,t){const n=[],r=[];for(const a of e??[])(JR(a,t)?n:r).push(a);return{online:n,offline:r}}function VB(e){var t;return(t=e.tailscale)!=null&&t.exitNode?"Tailscale sends this machine's local network through an exit node, so decks on this network cannot find this one. Turn on Allow local network access in Tailscale's exit node menu to bring them back.":"This machine sends its local network through a VPN, so decks on this network cannot find this one. Allowing local network access in the VPN brings them back."}function GB(e,t){if(!e)return{text:"checking…",tone:"idle"};if(!e.enabled)return{text:"",tone:"idle"};if(e.stalled)return{text:`could not start — ${e.stalled}`,tone:"bad"};if(!e.running)return{text:"starting…",tone:"wait"};const n=(e.pending??[]).length;if(n)return{text:n===1?"1 deck is waiting for your answer":`${n} decks are waiting for your answer`,tone:"wait"};const r=(e.peers??[]).filter(w=>w.paired!==!1||w.met);if(!r.length)return{text:"no deck paired yet",tone:"idle"};const a=r.filter(w=>w.waiting),l=r.filter(w=>!w.waiting),c=a.filter(w=>{var j;return!((j=w.last)!=null&&j.error)&&w.lastSeen!=null&&t-w.lastSeen<ph}),{online:u,offline:f}=WB(l,t),p=[...f,...a.filter(w=>!c.includes(w))],h=u.length+c.length,m=u.filter(w=>{var j;return((j=w.last)==null?void 0:j.error)==="waiting for the other deck to accept this one"});if(h&&m.length===h)return{text:h===1?"1 deck found · waiting for them to accept":`${h} decks found · waiting for them to accept`,tone:"wait"};if(!h)return{text:p.length===1?"this deck cannot reach the one it is paired with":`this deck cannot reach any of its ${p.length} decks`,tone:"bad"};const y=h===1?"1 deck ready":`${h} decks ready`;return{text:p.length?`${y} · ${p.length} away`:y,tone:"ok"}}function KB(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const r=xs(e,t);return r==="now"?"checked just now":`checked ${r}`}function Y0(e,t){const n=Math.max(0,Math.round((t-e)/1e3));if(n<90)return"just now";const r=Math.round(n/60);return r<60?`${r}m ago`:`${Math.round(r/60)}h ago`}function YB(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=t-e<ph;return{text:n?"online · one-way, it calls in":`one-way · last online ${xs(e,t)}`,here:n}}function m_(e,t,n){return t?"online":e.lastSeen!=null?`last online ${xs(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function XB(e,t){var y,w,j,k,S;if(!e)return[];const n=[],r=new Set,a=(b,N)=>b.name.localeCompare(N.name,void 0,{numeric:!0}),l=e.aliases??{},c=(b,N)=>{const E=b?l[b]:void 0;return E&&E!==N?{name:E,self:N}:{name:N}};for(const b of e.pending??[]){if(!(b!=null&&b.fp)||r.has(b.fp))continue;r.add(b.fp);const N=c(b.fp,b.name||b.fp);n.push({fp:b.fp,name:N.name,...N.self?{self:N.self}:{},addr:b.addr??"",kind:"asks",state:`wants to pair · ${Y0(b.at,t)}`,tone:"wait",here:!0,hint:`${N.name} at ${b.addr}${b.via==="tailscale"?", over Tailscale,":""} is waiting for an answer.`,...b.via==="tailscale"?{via:"tailscale"}:{}})}const u=[],f=[];for(const b of e.peers??[]){const N=b.peerFp??b.fp;if(!N||r.has(N))continue;r.add(N);const E=ZR(b.last,t),C=JR(b,t),T=b.addr?`${b.addr}:${b.port}`:"";if(!b.paired&&b.manual&&!b.met){f.push({fp:T,name:T||b.name||N,addr:b.addr??"",kind:"dialling",state:E?E.text.replace(/ · .*$/,""):"trying…",tone:E?E.tone:"idle",here:!1,hint:(y=b.last)!=null&&y.error?`Nothing has answered at ${T} yet — ${b.last.error}.`:`Dialling ${T} until something answers.`,...b.via==="tailscale"?{via:"tailscale"}:{}});continue}const A=b.waiting?YB(b.lastSeen,t):null,I=A?A.here:C,B=!A&&E?I?`online · ${E.text.replace(/ · .*$/,"")}`:`${E.text.replace(/ · .*$/,"")} · ${m_(b,I,t)}`:A?A.text:m_(b,I,t),q=(w=b.last)!=null&&w.error?K0[b.last.error]:null,L=!A&&I&&!((j=b.last)!=null&&j.error)&&!(((k=b.last)==null?void 0:k.done)??[]).length,U=b.manual&&!b.met?{name:T}:c(N,b.name||N);u.push({fp:N,name:U.name,...U.self?{self:U.self}:{},addr:b.addr??"",kind:"paired",state:B,quiet:L,tone:q?q.tone==="bad"?"bad":"wait":E?E.tone:I?"ok":"idle",here:A?A.here:C,...b.via==="tailscale"?{via:"tailscale"}:{},hint:A?`${U.name} calls this deck, and this deck has no address to call back on — so it can repair its logins from here, and this deck cannot repair from it. ${b.lastSeen==null?"It has not called since this deck started.":`It last called ${xs(b.lastSeen,t)}.`} Add its address with the + at the top of this section to reach it either way.`:`${U.name}${T?` at ${T}`:""}${(S=b.last)!=null&&S.error?` — ${b.last.error}`:""}`})}n.push(...ZB(u).sort(a),...f.sort(a));const p=[];for(const b of e.strangers??[]){if(!(b!=null&&b.fp)||r.has(b.fp))continue;r.add(b.fp);const N=c(b.fp,b.name||b.fp);p.push({fp:b.fp,name:N.name,...N.self?{self:N.self}:{},addr:b.addr??"",kind:"nearby",state:"not paired yet",tone:"idle",here:!0,hint:b.via==="tailscale"?`${N.name} at ${b.addr} is on your tailnet and nothing is shared with it.`:`${N.name} at ${b.addr} is on this network and nothing is shared with it.`,...b.via==="tailscale"?{via:"tailscale"}:{}})}n.push(...p.sort(a));const h=[];for(const b of e.declined??[]){if(!(b!=null&&b.fp)||r.has(b.fp))continue;r.add(b.fp);const N=c(b.fp,b.name||b.fp);h.push({fp:b.fp,name:N.name,...N.self?{self:N.self}:{},addr:b.addr??"",kind:"declined",state:"you said no",tone:"idle",here:!1,hint:`${N.name} asked and was turned away. It is not asking any more.`})}n.push(...h.sort(a));const m=new Map;for(const b of n)m.set(b.name,(m.get(b.name)??0)+1);for(const b of n)(m.get(b.name)??0)<2||!b.addr||(b.state=b.quiet||!b.state?b.addr:`${b.addr} · ${b.state}`,b.quiet=!1);return n}function ZB(e){const t=new Map;for(const r of e){const a=t.get(r.name);a?a.push(r):t.set(r.name,[r])}const n=[];for(const r of t.values()){const a=[...new Set(r.filter(l=>l.addr).map(l=>l.addr))];if(a.length>1){for(const l of a)n.push(g_(r.filter(c=>c.addr===l)));n.push(...r.filter(l=>!l.addr))}else n.push(g_(r))}return n}function g_(e){const[t,...n]=[...e].sort((r,a)=>Number(a.here)-Number(r.here)||+!!a.addr-+!!r.addr);return n.length?{...t,twins:n}:t}function y_(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function w_(e,t){if(!e)return{};switch(t.kind){case"paired":return{peer:(e.peers??[]).find(n=>(n.peerFp??n.fp)===t.fp)??null};case"dialling":return{peer:(e.peers??[]).find(n=>n.manual&&!n.met&&`${n.addr}:${n.port}`===t.fp)??null};case"nearby":return{stranger:(e.strangers??[]).find(n=>n.fp===t.fp)??null};case"declined":return{stranger:(e.declined??[]).find(n=>n.fp===t.fp)??null};case"asks":return{stranger:(e.pending??[]).find(n=>n.fp===t.fp)??null}}}function QB(e,t){const n=/^(\d+)\.(\d+)\.(\d+)/.exec(e??""),r=/^(\d+)\.(\d+)\.(\d+)/.exec(t??"");if(!n||!r)return null;for(let a=1;a<=3;a++){const l=Number(n[a])-Number(r[a]);if(l)return Math.sign(l)}return 0}function JB(e,t,n){const r=t?t.alive?"works here":"expired here":"not on this deck";if(!e.alive){const a=t&&!t.alive?"neither copy works — sign in again here":null;return{there:"broken there",here:r,note:a,tone:a?"bad":"idle"}}return t?t.alive?{there:"works there",here:r,note:null,tone:"ok"}:n?{there:"works there",here:r,note:"repairs next round",tone:"wait"}:{there:"works there",here:r,note:"share it to repair",tone:"bad"}:{there:"works there",here:r,note:"arrives next round",tone:"wait"}}function ez(e,t,n,r=null){const a=new Map(t.map(f=>[f.key,f])),l=new Set(n),c=[],u=new Set;for(const f of e??[]){if(u.has(f.key))continue;u.add(f.key);const p=a.get(f.key)??null,h=l.has(f.key),m=JB(f,p,h),y=p?p.alive?"works":"expired":"missing",w=!f.alive&&p&&!p.alive?m.note:[y==="works"?null:m.here,f.alive?null:m.there,m.note].filter(Boolean).join(" · ")||null;c.push({key:f.key,email:f.email,here:y,there:f.alive?"works":"broken",in:f.alive?m.tone==="wait"?"wait":m.tone==="bad"?"blocked":"live":"cut",out:h&&p?p.alive?"live":"cut":null,caption:w,tone:m.tone,usedThere:r===f.key})}for(const f of n){const p=a.get(f);!p||u.has(f)||(u.add(f),c.push({key:f,email:p.email,here:p.alive?"works":"expired",there:"unknown",in:null,out:p.alive?"live":"cut",caption:p.alive?null:"expired here",tone:p.alive?"ok":"bad",usedThere:!1}))}return c}async function Li(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}function tz({anchorId:e,id:t,rows:n,onHold:r,onLet:a}){const l=x.useRef(null),c=n.filter(y=>y.kind==="paired"),u=c.filter(y=>y.here),f=u.slice(0,UB),p=c.length-u.length,h=u.length>f.length?`and ${u.length-f.length} more`:p>0?`${p} not on right now`:null,m=x.useCallback(()=>{const y=l.current,w=document.getElementById(e);if(!y||!w)return;const j=U0(w.getBoundingClientRect(),{width:y.offsetWidth,height:y.offsetHeight},{width:window.innerWidth,height:window.innerHeight});y.style.top=`${j.top}px`,y.style.left=`${j.left}px`,y.style.maxHeight=j.maxHeight==null?"":`${j.maxHeight}px`,y.dataset.side=j.side},[e]);return x.useLayoutEffect(()=>{m()}),x.useEffect(()=>(window.addEventListener("scroll",m,!0),window.addEventListener("resize",m),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}),[m]),Sn.createPortal(o.jsxs("div",{ref:l,id:t,className:"ap-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:a,children:[o.jsx("p",{className:"ap-peek-title",children:u.length?"On the network now":"Nobody on the network"}),f.length>0&&o.jsx("div",{className:"ap-peek-list",children:f.map(y=>o.jsxs("span",{className:"ap-peek-who",children:[o.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),o.jsxs("span",{children:[y.name,y.via==="tailscale"&&o.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]})]},`${y.kind}:${y.fp}`))}),h&&o.jsx("p",{className:"ap-peek-rest",children:h})]}),document.body)}function nz(e,t){var l;if(!e)return{text:"checking…",tone:"idle",live:!1};if(!e.enabled)return{text:"Off",tone:"idle",live:!1};if(e.stalled)return{text:"could not start",tone:"bad",live:!1};if(!e.running)return{text:"starting…",tone:"wait",live:!1};const n=t.filter(c=>c.kind==="asks").length;if(n)return{text:n===1?"1 deck wants to pair":`${n} decks want to pair`,tone:"wait",live:!1};if((l=e.reach)!=null&&l.blocked)return{text:"nothing can get in",tone:"bad",live:!1};const r=t.filter(c=>c.kind==="paired");if(!r.length)return{text:"On · none paired yet",tone:"idle",live:!1};const a=r.filter(c=>c.here).length;return a?a===r.length?{text:`${a} online`,tone:"ok",live:!0}:{text:`${a} of ${r.length} online`,tone:"ok",live:!0}:{text:`none of ${r.length} online`,tone:"idle",live:!1}}function rz({accounts:e,onChanged:t,view:n,onOpen:r,onBack:a,closeButton:l}){const[c,u]=x.useState(null),[f,p]=x.useState([]),[h,m]=x.useState(null),[y,w]=x.useState(!1),[j,k]=x.useState(null),S=x.useRef(0),[b,N]=x.useState(!1),[E,C]=x.useState(!1),[T,A]=x.useState(!1),I=x.useRef(0);x.useEffect(()=>()=>window.clearTimeout(I.current),[]);const[B,q]=x.useState(!1),[L,U]=x.useState(null),X=x.useRef(null),Y=x.useCallback(le=>Oh(X.current)?(X.current=le,m(le),!0):!1,[]),M=x.useCallback(()=>{X.current=null,z.current&&m(null)},[]),J=le=>{const _e=Fa(h,le);return{disabled:_e.disabled,"aria-busy":_e.busy}},[V,$]=x.useState(()=>Date.now()),z=x.useRef(!0),W=x.useRef(e0),G=x.useCallback(async()=>{var le,_e;try{const[Ie,Ze]=await Promise.all([fetch("/api/lan").then(We=>We.json()),fetch("/api/prefs").then(We=>We.json())]);if(!z.current)return;Ie!=null&&Ie.ok&&u(Ie),Ze!=null&&Ze.ok&&p(Array.isArray((_e=(le=Ze.prefs)==null?void 0:le.lan)==null?void 0:_e.manual)?Ze.prefs.lan.manual:[]),W.current=(Ie==null?void 0:Ie.enabled)===!0?e0:QR}catch{}},[]);x.useEffect(()=>{z.current=!0;let le=0;const _e=async()=>{$(Date.now()),await G(),z.current&&(le=window.setTimeout(_e,W.current))};return _e(),()=>{z.current=!1,window.clearTimeout(le)}},[G]);const F=x.useCallback(async()=>{const le=(c==null?void 0:c.enabled)===!0;if(Y("switch"))try{const _e=await Li("/api/prefs",{lan:{enabled:!le}});if(!z.current)return;_e!=null&&_e.ok?(U(null),le||w(!0)):U(tn(le?"turn this off":"turn this on",_e)),await G()}catch{z.current&&U(tn(le?"turn this off":"turn this on",null))}finally{M()}},[c==null?void 0:c.enabled,G,Y,M]),K=x.useCallback(async(le,_e,Ie)=>{if(!Y(`${le}:${_e}`))return null;let Ze=null;try{const We=await Li("/api/lan/peer",{action:le,fp:_e});if(!z.current)return null;We!=null&&We.ok?(u(We),U(null)):(Ze=tn(Ie,We),U(Ze)),await G()}catch{Ze=tn(Ie,null),z.current&&U(Ze)}finally{M()}return Ze},[G,Y,M]),de=x.useCallback(async le=>{if(!Y(`drop:${le}`))return null;let _e=null;try{const Ie=await Li("/api/prefs",{lan:{manual:f.filter(Ze=>Ze!==le)}});if(!z.current)return null;Ie!=null&&Ie.ok?(U(null),t()):(_e=tn("stop dialling that address",Ie),U(_e)),await G()}catch{_e=tn("stop dialling that address",null),z.current&&U(_e)}finally{M()}return _e},[f,G,t,Y,M]),[H,Q]=x.useState(null),O=x.useCallback(async(le,_e)=>{if(!Y(`alias:${le}`))return"Something else is still being saved. Try again in a moment.";try{const Ie=await Li("/api/lan/peer",{action:"alias",fp:le,name:_e});return z.current?Ie!=null&&Ie.ok?(u(Ie),null):tn("rename that deck",Ie):null}catch{return tn("rename that deck",null)}finally{M()}},[Y,M]),te=x.useCallback(async le=>{if(!Y(`check:${le}`))return null;try{const _e=await Li("/api/lan/sync",{fp:le});return z.current?_e!=null&&_e.ok?(u(_e),t(),null):(_e==null?void 0:_e.reason)==="no_address"?"There is no address here to call it on. It calls this deck, and it is up to date each time it does.":tn("check that deck",_e):null}catch{return tn("check that deck",null)}finally{M()}},[Y,M,t]),ae=x.useCallback(async()=>{if(Y("check"))try{const le=await Li("/api/lan/sync",{});if(!z.current)return;le!=null&&le.ok?(u(le),U(null)):U(tn("check the other decks",le)),t()}catch{z.current&&U(tn("check the other decks",null))}finally{M()}},[Y,M,t]),he=(c==null?void 0:c.enabled)===!0,ge=XB(c,V),Te=H?ge.find(le=>{var _e;return le.fp===H||((_e=le.twins)==null?void 0:_e.some(Ie=>Ie.fp===H))})??null:null;x.useEffect(()=>{H&&c&&!Te&&Q(null)},[H,c,Te]);const De=ge.filter(le=>le.kind==="asks"),Ve=ge.filter(le=>le.kind!=="asks"),je=Ve.filter(le=>le.here),ve=Ve.filter(le=>!le.here),Ue=ve.filter(le=>le.tone==="bad").length,ke=B||je.length===0,xe=GB(c,V),Ge=Ve.filter(le=>le.kind==="paired").length,rt=nz(c,ge),at=o.jsxs(o.Fragment,{children:[b&&c&&o.jsx(_B,{status:c,manual:f,onClose:()=>N(!1),onChanged:()=>{G(),t()}}),E&&o.jsx(KR,{title:"How Local network works",steps:wB,finish:he?void 0:{label:"Turn it on",act:()=>{C(!1),F()}},onClose:()=>C(!1)}),y&&c&&o.jsx($B,{status:{...c,manualRows:f},accounts:e,manual:f,onClose:()=>w(!1),onChanged:()=>{G(),t()}}),Te&&c&&o.jsx(MB,{row:Te,source:w_(c,Te),status:c,accounts:e,now:V,busy:h,onClose:()=>Q(null),onRename:le=>O(Te.fp,le),onCheck:()=>te(Te.fp),onVerb:()=>{switch(Te.kind){case"paired":return K("unpair",Te.fp,"unpair that deck");case"nearby":return K("accept",Te.fp,"reach that deck");case"declined":return K("allow",Te.fp,"let that deck ask again");case"dialling":return de(Te.fp);default:return Promise.resolve(null)}},onSettings:()=>{Q(null),w(!0)},twins:(Te.twins??[]).map(le=>({row:le,peer:w_(c,le).peer??null})),onUnpair:le=>K("unpair",le,"unpair that deck")})]});if(!n){const le=We=>{window.clearTimeout(I.current),I.current=window.setTimeout(()=>A(!0),We)},_e=()=>{window.clearTimeout(I.current),I.current=window.setTimeout(()=>A(!1),tM)},Ie=()=>window.clearTimeout(I.current),Ze=()=>{window.clearTimeout(I.current),A(!1)};return o.jsxs("div",{className:"ap-foot",children:[o.jsxs("button",{type:"button",id:"ap-lan-entry",className:"ap-nav",onClick:()=>{Ze(),r()},"aria-describedby":T?"ap-lan-peek":void 0,onPointerEnter:We=>{We.pointerType==="mouse"&&le(eM)},onPointerLeave:_e,onFocus:We=>{We.target.matches(":focus-visible")&&le(0)},onBlur:_e,children:[o.jsxs("svg",{className:"ap-nav-glyph",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("rect",{x:"1.8",y:"2.3",width:"10.4",height:"7.2",rx:"1.2"}),o.jsx("path",{d:"M5 11.9h4M7 9.5v2.4"})]}),o.jsxs("span",{className:"ap-nav-text",children:[o.jsx("span",{className:"ap-nav-name",children:"Local network"}),o.jsxs("span",{className:"ap-nav-state","data-tone":rt.tone,children:[rt.live&&o.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),rt.text]})]}),o.jsx("svg",{className:"ap-nav-chev",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:o.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),T&&o.jsx(tz,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:ge,onHold:Ie,onLet:_e}),o.jsx("p",{className:"vis-hidden",role:"status",children:xe.tone==="ok"?"":xe.text}),at]})}return o.jsxs("div",{className:"ap-lan-view",children:[o.jsxs("div",{className:"ap-header",children:[o.jsx("button",{type:"button",id:"ap-lan-back",className:"glyph-btn ap-back",onClick:a,"aria-label":"Back to Claude accounts",title:"Back to Claude accounts",children:o.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:o.jsx("path",{d:"M8.4 3.4 4.8 7l3.6 3.6"})})}),o.jsx("h2",{id:"ap-lan-title",children:"Local network"}),o.jsxs("div",{className:"ap-header-right",children:[he&&o.jsx("button",{type:"button",className:"glyph-btn ap-lan-plus",onClick:()=>N(!0),"aria-label":"Add a deck",title:"Reach a deck that has not turned up on its own — by address, or with an invite",children:o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M6.1 7.9a2.6 2.6 0 0 0 3.7 0l1.9-1.9a2.6 2.6 0 0 0-3.7-3.7l-.9.9"}),o.jsx("path",{d:"M7.9 6.1a2.6 2.6 0 0 0-3.7 0L2.3 8a2.6 2.6 0 0 0 3.7 3.7l.9-.9"})]})}),he&&Ge>0&&o.jsx("button",{type:"button",className:"glyph-btn ap-lan-check",...J("check"),onClick:()=>void ae(),"aria-label":h==="check"?"Checking every paired deck":"Check every paired deck now",title:"Ask every paired deck now for anything this deck's expired logins need, instead of waiting for the next round",children:o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("circle",{cx:"7",cy:"7",r:"1.1",fill:"currentColor",stroke:"none"}),o.jsx("path",{d:"M4.6 4.6a3.4 3.4 0 0 0 0 4.8M9.4 4.6a3.4 3.4 0 0 1 0 4.8"}),o.jsx("path",{d:"M2.6 2.6a6.2 6.2 0 0 0 0 8.8M11.4 2.6a6.2 6.2 0 0 1 0 8.8"})]})}),he&&o.jsx("button",{type:"button",className:"glyph-btn ap-lan-set",...J("setup"),onClick:()=>w(!0),"aria-label":"This deck's name and shared logins",title:"This deck's name on the network, and which of its logins it offers",children:o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M1.8 4.7h10.4M1.8 9.3h10.4"}),o.jsx("circle",{cx:"9.1",cy:"4.7",r:"1.6",fill:"var(--panel)"}),o.jsx("circle",{cx:"4.9",cy:"9.3",r:"1.6",fill:"var(--panel)"})]})}),l]})]}),o.jsx("div",{className:"ap-scroll",id:"ap-lan-scroll",children:o.jsxs("div",{className:"ap-lan",children:[o.jsxs("div",{className:"ap-policy",children:[o.jsx("h3",{className:"ap-auto-title",children:"Sync with paired decks"}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":he,"aria-label":"Sync with paired decks",...J("switch"),onClick:()=>void F(),title:he?"Stop talking to other decks. Nothing is shared while this is off.":"Let the decks you pair with repair this one's expired logins",children:o.jsx("span",{className:"switch-knob"})})]}),he&&o.jsx(XR,{reach:c==null?void 0:c.reach,where:"panel"}),he&&(c==null?void 0:c.deaf)&&o.jsx("p",{className:"ap-lan-fine",children:c.deaf}),he&&(c==null?void 0:c.lanTunneled)&&o.jsx("p",{className:"ap-lan-fine",children:VB(c)}),!he&&o.jsxs("button",{type:"button",className:"ap-lan-intro",onClick:()=>C(!0),title:"Four pictures: what this does, and what to do on each machine",children:[o.jsx(vB,{}),o.jsx("span",{className:"ap-lan-intro-text",children:"Paired machines repair each other's expired logins."}),o.jsx("span",{className:"ap-lan-intro-go",children:"See how it works"})]}),o.jsx("p",{className:`ap-lan-status ${xe.tone}`,role:"status",children:xe.tone==="ok"?"":xe.text}),L&&o.jsxs("div",{className:"ap-failure",role:"alert",children:[o.jsx("span",{className:"ap-failure-text",children:L}),o.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>U(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),he&&o.jsxs(o.Fragment,{children:[De.length>0&&o.jsx("div",{className:"ap-lan-asks",role:"alert",children:De.map(le=>o.jsxs("div",{className:"ap-lan-ask",children:[o.jsxs("span",{className:"ap-lan-ask-what",children:[o.jsx("strong",{className:"ap-lan-peer-name",children:le.name})," at ",o.jsx("code",{className:"ap-lan-code",children:le.addr})," wants to pair"]}),o.jsxs("span",{className:"ap-lan-ask-fp",children:["fingerprint ",o.jsx("code",{className:"ap-lan-code",children:le.fp})]}),o.jsxs("span",{className:"ap-lan-ask-acts",children:[o.jsx("button",{type:"button",className:"ap-manage-btn",...J(`accept:${le.fp}`),onClick:()=>void K("accept",le.fp,"accept that deck"),title:`Talk to this deck from now on. Its fingerprint is ${le.fp} — check it matches the one on their screen before you accept.`,children:"accept"}),o.jsx("button",{type:"button",className:"ap-manage-btn",...J(`dismiss:${le.fp}`),onClick:()=>void K("dismiss",le.fp,"decline that request"),title:"Say no. Nothing is shared, and that deck is told rather than left waiting.",children:"decline"})]})]},le.fp))}),(ke?[...je,...ve]:je).length>0&&o.jsx("ul",{className:"ap-lan-here",children:(ke?[...je,...ve]:je).map((le,_e)=>o.jsxs("li",{className:"ap-lan-who","data-tone":le.tone,children:[o.jsx("i",{className:le.here?"ap-pulse":"ap-dot","aria-hidden":!0}),o.jsxs("span",{className:"ap-lan-who-name","aria-hidden":!0,children:[le.name,le.via==="tailscale"&&o.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]}),o.jsx("button",{type:"button",className:"ap-lan-who-open","aria-haspopup":"dialog","aria-describedby":`lan-who-state-${_e}`,onClick:()=>Q(le.fp),children:o.jsxs("span",{className:"vis-hidden",children:[le.name,le.via==="tailscale"?", over Tailscale":"",", details"]})}),o.jsx("span",{id:`lan-who-state-${_e}`,className:le.quiet?"vis-hidden":"ap-lan-who-when",children:le.state}),le.kind==="nearby"&&o.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...J(`accept:${le.fp}`),onClick:()=>void K("accept",le.fp,"reach that deck"),"aria-label":`Ask ${le.name} to pair`,title:`Send ${le.name} a request. Somebody at that machine has to accept it before anything is shared. Its fingerprint is ${le.fp}.`,children:"ask"}),le.kind==="paired"&&o.jsx("button",{type:"button",className:`ap-manage-btn ap-lan-do danger${j===le.fp?" armed":""}`,...J(`unpair:${le.fp}`),onClick:()=>{const Ie=Date.now(),Ze=uh({armedFor:j,target:le.fp,armedAt:S.current,now:Ie,gapMs:fh});if(Ze==="arm"){k(le.fp),S.current=Ie,window.setTimeout(()=>k(We=>We===le.fp?null:We),4e3);return}Ze!=="ignore"&&(k(null),K("unpair",le.fp,"unpair that deck"))},"aria-label":j===le.fp?`Confirm unpairing ${le.name}`:`Unpair ${le.name}`,title:j===le.fp?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this deck from now on",children:j===le.fp?"confirm":"unpair"}),le.kind==="dialling"&&o.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...J(`drop:${le.fp}`),onClick:()=>void de(le.fp),"aria-label":`Stop dialling ${le.name}`,title:"Stop trying this address. Nothing was ever paired here.",children:"stop"}),le.kind==="declined"&&o.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...J(`allow:${le.fp}`),onClick:()=>void K("allow",le.fp,"let that deck ask again"),"aria-label":`Let ${le.name} ask again`,title:"Take the no back. That deck is still trying, so the request comes round again on its own.",children:"allow"})]},`${le.kind}:${le.fp}`))}),(je.length>0&&ve.length>0||he&&Ge>0)&&o.jsxs("div",{className:"ap-lan-tail",children:[je.length>0&&ve.length>0&&o.jsxs("button",{type:"button",className:"ap-lan-word ap-lan-more","aria-expanded":B,onClick:()=>q(le=>!le),title:B?"Show only the decks that are on":`Show the ${ve.length} deck${ve.length===1?"":"s"} that are not responding right now`,children:[o.jsx("span",{className:`ap-lan-chev${B?" open":""}`,"aria-hidden":!0,children:"›"}),B?"fewer":`${ve.length} more`,!B&&Ue>0&&o.jsxs("span",{className:"ap-lan-more-bad",children:[" · ",Ue," not responding"]})]}),he&&Ge>0&&o.jsx("span",{className:"ap-lan-checked",children:KB(c==null?void 0:c.checkedAt,V,h==="check")})]}),Ve.length===0&&De.length===0&&!(c!=null&&c.stalled)&&!(c!=null&&c.deaf)&&!(c!=null&&c.lanTunneled)&&o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"ap-lan-fine",children:"No other deck yet. Decks on one network usually find each other on their own; when that has not happened, the link at the top of this view reaches one by address or by invite."}),o.jsx("button",{type:"button",className:"ap-lan-word ap-lan-how",onClick:()=>C(!0),children:"How it works"})]})]})]})}),at]})}function sz({anchorId:e,id:t,peers:n,onHold:r,onLet:a}){const l=x.useRef(null),{title:c,shown:u,rest:f}=sB(n),p=x.useCallback(()=>{const h=l.current,m=document.getElementById(e);if(!h||!m)return;const y=U0(m.getBoundingClientRect(),{width:h.offsetWidth,height:h.offsetHeight},{width:window.innerWidth,height:window.innerHeight});h.style.top=`${y.top}px`,h.style.left=`${y.left}px`,h.style.maxHeight=y.maxHeight==null?"":`${y.maxHeight}px`,h.dataset.side=y.side},[e]);return x.useLayoutEffect(()=>{p()}),x.useEffect(()=>(window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}),[p]),Sn.createPortal(o.jsxs("div",{ref:l,id:t,className:"ap-peek ap-fold-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:a,children:[o.jsx("p",{className:"ap-peek-title",children:c}),o.jsx("div",{className:"ap-peek-list",children:u.map(h=>o.jsxs("span",{className:"ap-peek-who ap-fold-who",children:[o.jsx("span",{className:"ap-fold-name",children:h.name}),o.jsx("span",{className:"ap-fold-state","data-tone":h.ready?"ok":h.warn?"warn":"idle",children:h.ready?h.headroom==null?"not read yet":`${h.headroom}% free`:h.why})]},h.key))}),f&&o.jsx("p",{className:"ap-peek-rest",children:f})]}),document.body)}function az({peers:e,strained:t,armed:n,threshold:r,open:a,onToggle:l}){const[c,u]=x.useState(!1),f=x.useRef(0);x.useEffect(()=>()=>window.clearTimeout(f.current),[]),x.useEffect(()=>{a&&(window.clearTimeout(f.current),u(!1))},[a]);const p=j=>{a||(window.clearTimeout(f.current),f.current=window.setTimeout(()=>u(!0),j))},h=()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>u(!1),tM)},m=()=>window.clearTimeout(f.current),y=()=>{window.clearTimeout(f.current),u(!1)},w=nB(e,{strained:t&&!a,armed:n,threshold:r});return o.jsxs("div",{className:"ap-rest",children:[o.jsxs("button",{type:"button",id:"ap-rest-entry",className:"ap-nav","aria-expanded":a,"aria-controls":a?"ap-rest-panel":void 0,"aria-describedby":c?"ap-rest-peek":void 0,onClick:()=>{y(),l()},onPointerEnter:j=>{j.pointerType==="mouse"&&p(eM)},onPointerLeave:h,onFocus:j=>{j.target.matches(":focus-visible")&&p(0)},onBlur:h,children:[o.jsxs("span",{className:"ap-nav-text",children:[o.jsx("span",{className:"ap-nav-name",children:"Other accounts"}),o.jsx("span",{className:"ap-nav-state","data-tone":w.tone,children:w.text})]}),o.jsx("svg",{className:"ap-nav-chev",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:o.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),c&&o.jsx(sz,{anchorId:"ap-rest-entry",id:"ap-rest-peek",peers:e,onHold:m,onLet:h})]})}async function oz(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const iz=1800;function lz({accounts:e,onClose:t,copyText:n}){const[r,a]=x.useState([]),[l,c]=x.useState(null),[u,f]=x.useState(!1),[p,h]=x.useState(null),[m,y]=x.useState(!1),[w,j]=x.useState(()=>Math.floor(Date.now()/1e3)),k=x.useRef(null),S=x.useRef(!1),b=sn(t,{focusRef:k});x.useEffect(()=>{if(!l)return;j(Math.floor(Date.now()/1e3));const L=window.setInterval(()=>j(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(L)},[l]);const N=W8(e),E=V8(e,r),C=E.length===e.length,T=L=>a(U=>G8(U,L)),A=x.useCallback(async()=>{const L=K8(E);if(!Ks(S.current)||!L)return;S.current=!0,f(!0),h(null),y(!1);const U=await oz(L).catch(()=>null);if(S.current=!1,f(!1),!(U!=null&&U.ok)){h(zi(U,"the share could not be made"));return}c({blob:U.blob,expiresAt:U.expiresAt,shared:U.shared??[],failed:U.failed??[]})},[e,E]),I=l?GR(l.expiresAt,w):null,B=(I==null?void 0:I.tone)==="gone",q=(l==null?void 0:l.shared.length)??0;return Sn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:o.jsxs("div",{ref:b,className:"modal sa-modal",onClick:L=>L.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Share accounts with another deck",children:[o.jsxs("header",{className:"modal-head",children:[o.jsx("div",{className:"modal-title",children:o.jsx("h3",{children:"Share accounts"})}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsx("section",{className:"modal-body sa-body",children:l?o.jsxs("div",{className:"sa-step",children:[o.jsx("h4",{children:B?"This share has expired":q===1?"1 account, ready to paste":`${q} accounts, ready to paste`}),o.jsx("code",{className:`ap-share-blob${B?" sa-dead":""}`,children:l.blob}),o.jsxs("div",{className:"ap-share-foot",children:[o.jsx("button",{type:"button",className:"ap-manage-btn",ref:k,onClick:async()=>{if(B){c(null),A();return}await n(l.blob)&&(y(!0),window.setTimeout(()=>y(!1),iz))},children:B?"make a new share":m?"copied":`copy ${q===1?"the share":"all "+q}`}),o.jsxs("span",{className:"ap-manage-hint",title:"This text is the sign-in for every account in it. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the logins themselves are in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign those accounts out and back in.",children:[o.jsx("span",{className:"ap-share-warn",children:q===1?"this is the password":`this is ${q} passwords`})," · ",o.jsx("span",{className:`ap-share-expiry ${I==null?void 0:I.tone}`,children:I==null?void 0:I.text})]})]}),l.failed.length>0&&o.jsxs("div",{className:"sa-failed",role:"alert",children:[o.jsx("p",{className:"sa-failed-head",children:l.failed.length===1?"One account is not in this bundle:":`${l.failed.length} accounts are not in this bundle:`}),o.jsx("ul",{className:"sa-list",children:l.failed.map(L=>{var X;const U=!!(L.email&&((X=L.detail)!=null&&X.includes(L.email)));return o.jsxs("li",{children:[!U&&o.jsx("span",{className:"sa-who",children:L.email||`account ${L.num}`}),o.jsx("span",{className:"sa-why",children:L.detail||"could not be exported"})]},`${L.num}-${L.email}`)})})]}),o.jsx("p",{className:"sa-note",children:B?o.jsx(o.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):o.jsxs(o.Fragment,{children:["Paste it into the other deck with ",o.jsx("strong",{children:"+"})," → ",o.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),o.jsxs("div",{className:"sa-actions",children:[o.jsx("button",{type:"button",className:"btn",onClick:()=>{c(null),y(!1)},children:"Pick again"}),o.jsx("button",{type:"button",className:"btn primary",onClick:t,children:"Done"})]})]}):e.length===0?o.jsxs("div",{className:"sa-step",children:[o.jsx("h4",{children:"Nothing to share"}),o.jsxs("p",{className:"sa-note",children:["This deck is not holding any accounts right now. Sign one in with ",o.jsx("strong",{children:"+"}),", or wait — the panel is still reading the store."]}),o.jsx("div",{className:"sa-actions",children:o.jsx("button",{type:"button",className:"btn primary",ref:k,onClick:t,children:"Close"})})]}):o.jsxs("div",{className:"sa-step",children:[o.jsxs("h4",{children:["Which accounts go to the other ",nn,"?"]}),o.jsx("p",{className:`sa-count${E.length?"":" empty"}`,children:Y8(E.length)}),o.jsx("ul",{className:"sa-list sa-pick",children:N.map(L=>o.jsx("li",{children:o.jsxs("label",{className:"sa-row",children:[o.jsx("input",{type:"checkbox",checked:E.includes(L.num),onChange:()=>T(L.num)}),o.jsx("span",{className:"sa-who",children:L.label}),L.sub&&o.jsx("span",{className:"sa-sub",children:L.sub})]})},L.num))}),p&&o.jsx("p",{className:"aa-err",children:p}),o.jsxs("div",{className:"sa-actions",children:[o.jsx("button",{type:"button",className:"btn",onClick:()=>a(C?e.map(L=>L.num):[]),children:C?"Clear all":"Select all"}),o.jsx("button",{type:"button",className:"btn primary",ref:k,...Ma(u,!E.length),onClick:A,children:u?"making the share…":E.length===0?"Share":E.length===1?"Share 1 account":`Share ${E.length} accounts`})]})]})})]})}),document.body)}function cz(e,t){const n=new Set(e),r=e.length?Math.max(...e):0;return[...new Set([...e,r+1])].sort((a,l)=>a-l).map(a=>{const l=a===t?"here":n.has(a)?"swap":"free";return{slot:a,kind:l,label:l==="here"?`slot ${a}`:`slot ${a} · ${l}`}})}function uz(e,t,n){if(!(n!=null&&n.ok))return null;const r=Number.isInteger(n.to)?n.to:null;if(r==null)return{menuFor:null,confirmRemove:null,shareFor:null,swapNote:null};const a=n.swapped===!0&&r!==t;return{menuFor:e.menuFor===t?r:a&&e.menuFor===r?t:e.menuFor,confirmRemove:null,shareFor:null,swapNote:a?{at:r,displaced:t}:null}}function dz(e,t,n){return t!=null&&e.some(r=>r.slot===t)?t:n}function hz(e,t,n){var a;const r=((a=e.find(l=>l.slot===t))==null?void 0:a.kind)??"here";return r==="swap"?{label:"swap",done:"swapped",sends:!0,swaps:!0,title:`Send this account to slot ${t}. That slot is taken, so the two accounts trade places and the one standing there moves to slot ${n}.`}:r==="free"?{label:"move",done:"moved",sends:!0,swaps:!1,title:`Send this account to slot ${t}. That slot is empty, so no other account moves.`}:{label:"move",done:"here",sends:!1,swaps:!1,title:`This account already holds slot ${n}.`}}function fz(e,t){return{label:"save",done:"saved",sends:e!==t,swaps:!1,title:`Switch the active account out once it passes ${e}% of its limit.`}}function v_(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function pz(e){const t=e.filter(u=>!v_(u)),n=e.filter(u=>v_(u)),r=t.length?t:n,a=t.length?n:[],l=r.reduce((u,f)=>u&&u.pct>=f.pct?u:f,null);let c=null;for(const u of a)l&&u.pct<=l.pct||(!c||u.pct>c.pct)&&(c=u);return{shown:r,rest:a,fuller:c,peak:c??l}}const mz="\0";function mh(e){const t=typeof e.email=="string"?e.email.trim():"";if(!t)return`slot:${e.num}`;const n=typeof e.org=="string"?e.org.trim():"";return`acct:${t}${mz}${n}`}function gz(e,t){const n=mh(t);return e.includes(n)?e.filter(r=>r!==n):[...e,n]}function yz(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(mh)),r=e.filter(a=>n.has(a));return r.length===e.length?e:r}const wz=64;function vz(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}const xz=Object.freeze({text:"couldn't reach the deck server",reload:!0}),bz=Object.freeze({text:"still waiting on the deck server — claude-swap can be slow to answer",reload:!0});async function x_(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function kz(e){const t=e.find(r=>!r.ok);if(!t)return null;const n=Bc(t.body);return{text:Xx(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function b_(e,t){return t?e!=null&&e.reload&&e.text===t.text&&e.raw===t.raw?e:t:e!=null&&e.reload?null:e}const k_=15e3,Nz=8e3,_z=1800,Sz=3e4,Vp=[70,80,85,90,95];function Gp(e,t){return CR(t-Math.floor(e/1e3))}function jz(e,t){if(!e)return"";const n=Math.floor(e/1e3)-t;return n<=0?" · due":n<60?` · next in ${n}s`:` · next in ${Math.round(n/60)}m`}function bc(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ez(e,t){const n="The deck can still see this account — its live usage is being read — but claude-swap's own stored copy of the login was rejected, so these numbers stopped updating.";if((e==null?void 0:e.state)==="running")return{text:"resuming…",hint:`${n} The deck is re-capturing it from the login you already have. No sign-in, no switch.`};if((e==null?void 0:e.state)==="failed"){const r=Math.max(1,Math.ceil((e.retryAt/1e3-t)/60)),a=e.reason?`Re-capturing it from the login you already have did not work (${e.reason}).`:"The deck re-captured it from the login you already have, and claude-swap still cannot read it.";return{text:"numbers paused",hint:`${n} ${a} It tries again in ${r}m. No sign-in, no switch.`}}return{text:"numbers paused",hint:n}}function Cz(e){switch(e){case"invalid_grant":case"no_refresh_token":return{text:"login expired",hint:"claude-swap's stored login for this account was rejected and cannot be refreshed. Signing in again replaces it — the account keeps its slot, its alias and its history.",fixable:!0};case"http-401":return{text:"re-login needed",hint:"Anthropic refused this account's token.",fixable:!0};case"http-429":return{text:"rate limited",hint:"Anthropic is throttling requests for this account. It clears on its own.",fixable:!1};case"transient":return{text:"temporary error",hint:"A network or server hiccup while reading usage. The next collection retries.",fixable:!1};case"timeout":return{text:"timed out",hint:"Reading this account's usage took too long. The next collection retries.",fixable:!1};case"network":return{text:"unreachable",hint:"Could not reach Anthropic to read this account's usage.",fixable:!1};default:return{text:e,hint:`claude-swap reported "${e}" for this account.`,fixable:!1}}}function Tz(e){switch(e){case"no_credentials":return{text:"no stored login",hint:"claude-swap holds no credentials for this account, so there is nothing to read its usage with and nothing to switch to. A paired deck that has them sends them on its own; signing in as this account puts them there by hand.",fix:"sign in"};case"relogin_required":return{text:"login expired",hint:"claude-swap's stored login for this account was rejected and cannot be refreshed. Signing in again replaces it — the account keeps its slot, its alias and its history.",fix:"sign in again"};case"keychain_unavailable":return{text:"keychain unreadable",hint:"This is about the deck, not the account: claude-swap could not open your keychain, so it cannot read any account's stored login. A deck started from a background session cannot reach the keychain at all — start it from a terminal, or let it start at login, and this clears."};case"token_expired":return{text:"token expired",hint:"The access token ran out and the refresh was deferred. The next collection retries."};case"foreign_credential":return{text:"wrong credential",hint:"The live credential belongs to a different account. Switching to this one repairs it."};case null:case void 0:return null;default:return{text:e,hint:`claude-swap reported "${e}" for this account.`}}}function $d(e,t){if(e.staleCopy){const n=Ez(e.repair??null,t);return{text:bc(n.text),hint:n.hint,fix:null,tone:"quiet",blocksSwitch:!1}}if(e.stopped){const n=Tz(e.collector??null);if(!n)return{text:"Not collecting",hint:"claude-swap has collected nothing for this account in over half a day and has not said why. A paired deck holding a working copy of this account will replace it on its own. To do it by hand, sign in as this account from + Add.",fix:null,tone:"quiet",blocksSwitch:!1};const r=e.collector==="no_credentials"||e.collector==="relogin_required";return{text:bc(n.text),hint:n.hint,fix:n.fix?bc(n.fix):null,tone:r||e.collector==="keychain_unavailable"?"warn":"quiet",blocksSwitch:r}}if(e.error){const n=Cz(e.error);return{text:bc(n.text),hint:n.hint,fix:n.fixable?"Sign in again":null,tone:n.fixable?"warn":"quiet",blocksSwitch:n.fixable}}return null}function Kp(){return o.jsxs("svg",{className:"ap-warn-glyph",width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M7 1.9 12.9 12H1.1Z"}),o.jsx("path",{d:"M7 5.6v2.9"}),o.jsx("path",{d:"M7 10.3v.05"})]})}function Az(e){return e>=90?"hi":e>=70?"mid":void 0}function Rz(e){const t=Number(e);return[...Number.isFinite(t)&&t>0&&!Vp.includes(t)?[...Vp,t]:Vp].sort((r,a)=>r-a)}function Mz({lane:e,nowSec:t,frozen:n}){const r=Math.min(100,Math.max(0,e.pct)),a=n?"var(--muted)":r>=90?"var(--err)":r>=70?"var(--warn)":"var(--accent)",l=e.resetAt&&!n?TR(e.resetAt,t):null;return o.jsxs("div",{className:"ap-lane",children:[o.jsx("span",{className:"ap-lane-label",title:e.label,children:e.label}),o.jsx("div",{className:"ap-lane-track",children:o.jsx("div",{className:"ap-lane-fill",style:{width:`${r===0?1.5:r}%`,background:a,opacity:r===0||n?.4:1}})}),o.jsxs("span",{className:"ap-lane-pct",style:{color:a},children:[r,"%"]}),o.jsx("span",{className:"ap-lane-reset",title:l?`${e.label} resets in ${l}`:void 0,children:l&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"vis-hidden",children:"resets in "}),l]})})]})}function Iz({onClose:e,leaving:t}){var _s,On,wn;const[n,r]=x.useState(null),[a,l]=x.useState(null),[c,u]=x.useState(null),[f,p]=x.useState(!1),[h,m]=x.useState(null),[y,w]=x.useState(null),[j,k]=x.useState("accounts"),[S,b]=x.useState(!1),[N,E]=x.useState(null),C=x.useRef(N);C.current=N;const[T,A]=x.useState(()=>Math.floor(Date.now()/1e3)),I=x.useRef(null),[B,q]=x.useState(null),L=(B==null?void 0:B.num)??null,U=x.useRef(B);U.current=B;const[X,Y]=x.useState(null),[M,J]=x.useState(!1),[V,$]=x.useState(""),[z,W]=x.useState(null),G=x.useRef(0),[F,K]=x.useState(null),[de,H]=x.useState(!1),[Q,O]=x.useState(!1),[te,ae]=x.useState(null),[he,ge]=x.useState(null),[Te,De]=x.useState(null),[Ve,je]=x.useState(null),[ve,Ue]=x.useState(!1),ke=x.useRef(null),xe=x.useRef(null),[Ge,rt]=x.useState([]),[at,le]=x.useState(!1),_e=x.useRef(null),Ie=x.useCallback(ee=>Oh(_e.current)?(_e.current=ee,u(ee),!0):!1,[]),Ze=x.useCallback(()=>{_e.current=null,u(null)},[]),We=(ee,Ae=!1)=>{const Oe=Fa(c,ee);return{disabled:Oe.disabled,"aria-busy":Oe.busy||Ae}},Je=x.useCallback(ee=>{window.requestAnimationFrame(()=>{var Ae;if(KN(((Ae=document.activeElement)==null?void 0:Ae.tagName)??null))for(const Oe of dq(ee)){const Re=document.querySelector(Oe);if(Re){Re.focus();return}}})},[]),ye=x.useCallback(async(ee=!1)=>{ee&&p(!0);const Ae=new AbortController,Oe=window.setTimeout(()=>Ae.abort(),Sz);try{const[Re,ze]=await Promise.all([fetch(`/api/claude-accounts${ee?"?refresh=1":""}`,{signal:Ae.signal}),fetch("/api/cswap-auto",{signal:Ae.signal})]);if(Re.ok){const yt=await Re.json();r(yt),rt(Ct=>yz(Ct,yt.accounts))}ze.ok&&l(await ze.json());const dt=kz([await x_(Re),await x_(ze)]);m(yt=>b_(yt,dt))}catch{m(Re=>b_(Re,Ae.signal.aborted?bz:xz))}finally{window.clearTimeout(Oe),ee&&p(!1)}},[]),Me=x.useCallback(async(ee,Ae,Oe="panel")=>{if(!Ie(Ae))return null;const Re=Oe==="menu"?Y:m;Re(null);try{const ze=await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ee)}),dt=await ze.json().catch(()=>null);return dt!=null&&dt.ok||Re({text:Xx(dt,"command failed",ze.status),raw:Bc(dt)}),dt}catch{return Re({text:"server unreachable"}),null}finally{Ze()}},[Ie,Ze]),Qe=x.useCallback(async(ee,Ae)=>{if(!Ie(Ae))return null;m(null),Y(null);try{const Oe=await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ee)}),Re=await Oe.json().catch(()=>null);return Re!=null&&Re.ok||Y({text:zi(Re,"command failed",Oe.status)}),Re}catch{return Y({text:"server unreachable"}),null}finally{Ze()}},[Ie,Ze]);x.useEffect(()=>(ye(!0),I.current=window.setInterval(()=>ye(!1),k_),()=>{I.current!=null&&window.clearInterval(I.current)}),[ye]),x.useEffect(()=>{const ee=window.setInterval(()=>A(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(ee)},[]);const ue=((_s=a==null?void 0:a.settings["autoswitch.threshold"])==null?void 0:_s.value)??"90",kt=Ve??ue,pt=fz(kt,ue),ut=(On=n==null?void 0:n.accounts)==null?void 0:On.find(ee=>ee.active),Bt=ut?$d(ut,T):null,jt=(n==null?void 0:n.accounts)??[],vt=ut?jt.filter(ee=>!ee.active):[],an=vt.length?jt.filter(ee=>ee.active):jt,jn=vt.map(ee=>{const Ae=$d(ee,T);return{key:mh(ee),name:ee.alias??ee.email??`account ${ee.num}`,ready:!ee.disabled&&!(Ae!=null&&Ae.blocksSwitch),why:ee.disabled?"held out":Ae!=null&&Ae.blocksSwitch?Ae.text:null,warn:(Ae==null?void 0:Ae.tone)==="warn",headroom:ee.headroom}}),Nt=Number(ue),Yt=(ut==null?void 0:ut.headroom)!=null&&Number.isFinite(Nt)&&100-ut.headroom>=Nt,fe=(a==null?void 0:a.ok)===!0&&(a.enabled||a.external),st=ee=>at&&vt.some(Ae=>Ae.num===ee)?"ap-rest-list":"ap-scroll",It=async(ee,Ae)=>{if(Ie(`switch-${ee}`)){m(null),w(null);try{const Re=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:ee})})).json().catch(()=>null);Re!=null&&Re.ok?w({num:ee,name:Ae}):m({text:Xx(Re,"the switch failed"),raw:Bc(Re),row:ee}),await ye(!0)}catch{m({text:"server unreachable",row:ee})}finally{Ze(),Je(ee)}}},Et=x.useCallback(()=>{q(null),Y(null),W(null),K(null),O(!1)},[]),En=(ee,Ae="first")=>{Et(),E(null),De(null),q({num:ee,view:"menu",start:Ae})},Gn=(ee,Ae)=>{Et(),E(Oe=>(Oe==null?void 0:Oe.anchor)===Ae?null:{num:ee,anchor:Ae})},St=x.useCallback((ee=!1)=>{var Oe;const Ae=C.current;ee&&Ae&&((Oe=document.getElementById(Ae.anchor))==null||Oe.focus()),E(null)},[]),lr=()=>{Et(),E(null),k("lan")},yn=x.useRef(j);x.useEffect(()=>{yn.current!==j&&(yn.current=j,window.requestAnimationFrame(()=>{var ee;(ee=document.getElementById(j==="lan"?"ap-lan-back":"ap-lan-entry"))==null||ee.focus()}))},[j]),x.useEffect(()=>{n!=null&&n.ok&&b(!0)},[n==null?void 0:n.ok]);const Xt=x.useCallback(ee=>{var Re,ze;const Ae=U.current;if(!Ae||ee!=null&&Ae.num!==ee)return;const Oe=document.getElementById(`ap-menu-${Ae.num}`);(Oe!=null&&Oe.contains(document.activeElement)||KN(((Re=document.activeElement)==null?void 0:Re.tagName)??null))&&((ze=document.getElementById(`ap-more-${Ae.num}`))==null||ze.focus()),Et()},[Et]);x.useEffect(()=>{t&&(Et(),E(null))},[t,Et]),x.useEffect(()=>{B&&(n!=null&&n.accounts)&&!n.accounts.some(ee=>ee.num===B.num)&&Et(),N&&(n!=null&&n.accounts)&&!n.accounts.some(ee=>ee.num===N.num)&&E(null)},[n,B,N,Et]);const Cn=async ee=>{var Oe;O(!1);const Ae=await Qe({action:"share",account:ee},`share-${ee}`);!(Ae!=null&&Ae.ok)||((Oe=U.current)==null?void 0:Oe.num)!==ee||(K({num:ee,blob:Ae.blob,expiresAt:Ae.expiresAt}),q({num:ee,view:"share"}))},zt=async(ee,Ae)=>{const{commit:Oe,alias:Re}=vz(V,Ae);if(Oe){const ze=await Qe({action:"alias",account:ee,alias:Re},`alias-${ee}`);if(await ye(!0),!(ze!=null&&ze.ok))return}Xt(ee)},In=async(ee,Ae)=>{var ze,dt;const Oe=await Qe({action:"move",account:ee,slot:Ae},`move-${ee}`),Re=uz({menuFor:((ze=U.current)==null?void 0:ze.num)??null,shareFor:(F==null?void 0:F.num)??null},ee,Oe);if(await ye(!0),Re){((dt=U.current)==null?void 0:dt.num)===ee&&Et(),W(Re.confirmRemove),Re.shareFor==null&&(K(null),O(!1)),ge(Re.swapNote);const yt=Re.swapNote;yt&&window.setTimeout(()=>ge(Ct=>Ct===yt?null:Ct),Nz),De(null),Je(Re.menuFor)}return Oe},Kn=async(ee,Ae,Oe)=>{if(!Oe.sends){Xt(ee);return}await In(ee,Ae)},cr=async(ee,Ae)=>{if(Ae.sends){const Oe=await Me({action:"setting",key:"autoswitch.threshold",value:ee},"threshold");if(await ye(!0),!(Oe!=null&&Oe.ok))return;je(null)}Ue(!0),window.setTimeout(()=>{var Oe;document.activeElement===xe.current&&((Oe=ke.current)==null||Oe.focus()),Ue(!1)},_z)},$n=o.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:o.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:o.jsx("path",{d:"M3.4 3.4l7.2 7.2M10.6 3.4l-7.2 7.2"})})}),ea=ee=>{const{shown:Ae,fuller:Oe}=pz(ee.lanes),Re=$d(ee,T),ze=ee.active||Ge.includes(mh(ee)),dt=ee.alias??ee.email??`account ${ee.num}`,yt=ee.stale||(Re==null?void 0:Re.blocksSwitch)===!0,Ct=Oe?[...Ae,Oe]:Ae,gt=ee.fetchedAt?Gp(ee.fetchedAt,T):null;return o.jsxs("li",{className:`ap-account${ee.active?" active":""}`,"aria-current":ee.active?"true":void 0,"data-open":ze?"":void 0,"data-frozen":yt?"":void 0,children:[!ee.active&&o.jsx("button",{type:"button",className:"ap-row-open",id:`ap-row-${ee.num}`,"aria-expanded":ze,"aria-controls":ze?`ap-detail-${ee.num}`:void 0,"aria-describedby":!ze&&!(Re!=null&&Re.blocksSwitch)?`ap-quota-${ee.num}`:void 0,onClick:()=>rt(xt=>gz(xt,ee)),children:o.jsxs("span",{className:"vis-hidden",children:[dt,", ",ze?"hide details":"details"]})}),o.jsxs("div",{className:"ap-account-head",children:[ee.active?o.jsx("span",{className:"ap-live",title:`Active account · slot ${ee.num}`,children:o.jsxs("span",{className:"vis-hidden",children:["Active account, slot ",ee.num,":"]})}):o.jsx("span",{className:"ap-num",children:ee.num}),ee.alias&&o.jsx("span",{className:"ap-alias",title:ee.alias,children:ee.alias}),o.jsx("span",{className:"ap-email",title:ee.email??void 0,children:ee.email}),ee.disabled&&o.jsx("span",{className:"ap-held",children:"held out"}),!ee.active&&!ee.disabled&&!(Re!=null&&Re.blocksSwitch)&&o.jsx("button",{type:"button",className:"ap-switch",...We(`switch-${ee.num}`),onClick:()=>It(ee.num,dt),"aria-label":`Switch to ${dt}`,title:`Switch to ${ee.alias??ee.email}`,children:c===`switch-${ee.num}`?"…":"Switch"}),o.jsx("button",{type:"button",id:`ap-more-${ee.num}`,className:"ap-more","aria-label":`More actions for ${ee.email??ee.alias??`account ${ee.num}`}`,"aria-haspopup":"menu","aria-expanded":L===ee.num,"aria-controls":L===ee.num?`ap-menu-${ee.num}`:void 0,title:"More actions",onClick:()=>L===ee.num?Xt():En(ee.num),onKeyDown:xt=>{xt.key!=="ArrowDown"&&xt.key!=="ArrowUp"||(xt.preventDefault(),En(ee.num,xt.key==="ArrowUp"?"last":"first"))},children:o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"currentColor","aria-hidden":!0,children:[o.jsx("circle",{cx:"2.8",cy:"7",r:"1.15"}),o.jsx("circle",{cx:"7",cy:"7",r:"1.15"}),o.jsx("circle",{cx:"11.2",cy:"7",r:"1.15"})]})})]}),(h==null?void 0:h.row)===ee.num&&o.jsxs("div",{className:"ap-failure ap-row-failure",role:"alert",children:[o.jsx("span",{className:"ap-failure-text",title:h.raw||void 0,children:h.text}),o.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>m(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),ee.active&&(y==null?void 0:y.num)===ee.num&&o.jsx("p",{className:"ap-switched",children:"Now active. New sessions start on it; ones already running pick it up on their next message, up to about 30 seconds later on macOS."}),(he==null?void 0:he.at)===ee.num&&(()=>{const xt=jt.find(Ss=>Ss.num===he.displaced),Ar=(xt==null?void 0:xt.alias)??(xt==null?void 0:xt.email)??"the account that was there";return o.jsxs("p",{className:"ap-note ap-swap-note",title:`Slot ${he.at} was taken, so the two accounts traded places: ${Ar} now holds slot ${he.displaced}.`,children:["swapped with slot ",he.displaced]})})(),Re&&o.jsxs("div",{className:"ap-issue-line",children:[o.jsxs("button",{type:"button",id:`ap-issue-${ee.num}`,className:"ap-issue","data-tone":Re.tone,"aria-haspopup":"dialog","aria-expanded":(N==null?void 0:N.anchor)===`ap-issue-${ee.num}`,"aria-controls":(N==null?void 0:N.anchor)===`ap-issue-${ee.num}`?"ap-issue-pop":void 0,onClick:()=>Gn(ee.num,`ap-issue-${ee.num}`),children:[Re.tone==="warn"&&o.jsx(Kp,{}),o.jsx("span",{className:"ap-issue-text",children:Re.text})]}),!ze&&o.jsx("span",{className:"ap-issue-age",title:"When claude-swap last read this account's usage",children:gt??"never collected"})]}),!ze&&!(Re!=null&&Re.blocksSwitch)&&o.jsxs("p",{className:"ap-quota",id:`ap-quota-${ee.num}`,children:[Ct.length?Ct.map(xt=>o.jsxs("span",{className:"ap-q",children:[o.jsx("span",{className:"ap-q-label",children:xt.label})," ",o.jsxs("span",{className:"ap-q-pct","data-level":yt?void 0:Az(xt.pct),children:[Math.round(xt.pct),"%"]})]},xt.id)):o.jsx("span",{className:"ap-q-label",children:"no usage recorded yet"}),ee.stale&&!Re&&o.jsx("span",{className:"ap-q-age","data-never":gt?void 0:"",title:"When claude-swap last read this account's usage",children:gt??"never collected"})]}),ze&&o.jsxs("div",{className:"ap-detail",id:`ap-detail-${ee.num}`,children:[o.jsx("div",{className:"ap-lanes",children:ee.lanes.length?ee.lanes.map(xt=>o.jsx(Mz,{lane:xt,nowSec:T,frozen:yt},xt.id)):o.jsx("div",{className:"ap-hint",children:"No usage recorded yet."})}),o.jsx("div",{className:"ap-meta",children:ee.fetchedAt?o.jsxs("span",{className:`ap-age${ee.stale&&!Re?" ap-stale":""}`,title:"When claude-swap last read this account's usage, and when it plans to read it again. It sets that interval itself — 3 minutes at the fastest, wider while an account is recovering from a rate limit — and every surface, including `cswap watch`, follows the same plan.",children:["collected ",Gp(ee.fetchedAt,T),Re!=null&&Re.blocksSwitch?"":jz(ee.nextAt,T)]}):o.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})})]})]},ee.num)},ta=n!=null&&n.ok&&(a!=null&&a.ok)?o.jsxs("div",{className:"ap-policy-block",children:[o.jsxs("div",{className:"ap-policy",children:[o.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),o.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:o.jsx("select",{ref:ke,"aria-label":"Switch threshold",value:kt,...We("threshold"),onChange:ee=>je(ee.target.value),children:Rz(ue).map(ee=>o.jsxs("option",{value:ee,children:[ee,"%"]},ee))})}),(pt.sends||ve)&&o.jsx("button",{ref:xe,type:"button",className:"ap-manage-btn",...We("threshold"),title:pt.title,onClick:()=>cr(kt,pt),children:ve&&!pt.sends?pt.done:pt.label}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":a.enabled,"aria-label":"Auto-switch",...We("enable"),onClick:()=>Me({action:"enable",enabled:!a.enabled},"enable").then(()=>ye(!0)),title:a.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:o.jsx("span",{className:"switch-knob"})})]}),a.external&&o.jsxs("p",{className:"ap-auto-note",children:[o.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",o.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",a.enabled?" — this toggle takes over when you stop it.":"."]})]}):null;return o.jsxs("aside",{className:`accounts-panel${t?" leaving":""}`,id:"accounts-panel","aria-label":"Claude accounts",children:[j==="accounts"&&o.jsxs("div",{className:"ap-header",children:[o.jsx("h2",{children:"Claude accounts"}),o.jsxs("div",{className:"ap-header-right",children:[o.jsx("button",{type:"button",className:"glyph-btn ap-add",onClick:()=>J(!0),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:o.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:o.jsx("path",{d:"M7 2.2v9.6M2.2 7h9.6"})})}),(((wn=n==null?void 0:n.accounts)==null?void 0:wn.length)??0)>0&&o.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>H(!0),"aria-label":"Share accounts with another deck",title:`Copy several accounts to another ${nn} in one paste. The text carries a live login for each one — treat it as those passwords.`,children:o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M3.3 10.7L10.7 3.3"}),o.jsx("path",{d:"M5.5 3.3h5.2v5.2"})]})}),o.jsx("button",{type:"button",className:"glyph-btn ap-refresh",onClick:()=>ye(!0),...We("reload",f),"aria-label":"Reload accounts",title:"Reload from claude-swap",children:o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),o.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}),$n]})]}),j==="accounts"&&o.jsx("div",{className:"ap-scroll",id:"ap-scroll",children:n==null?h?o.jsxs("div",{className:"ap-empty",role:"alert",children:[o.jsx("span",{title:h.raw||void 0,children:h.text}),o.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",k_/1e3," seconds."]}),o.jsx("button",{type:"button",className:"ap-fix",disabled:f,onClick:()=>ye(!0),children:f?"trying…":"try again"})]}):o.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?o.jsxs(o.Fragment,{children:[ut&&(Bt==null?void 0:Bt.tone)==="warn"&&o.jsxs("div",{className:"ap-notice",children:[o.jsxs("button",{type:"button",id:"ap-notice",className:"ap-issue","data-tone":"warn","aria-haspopup":"dialog","aria-expanded":(N==null?void 0:N.anchor)==="ap-notice","aria-controls":(N==null?void 0:N.anchor)==="ap-notice"?"ap-issue-pop":void 0,onClick:()=>Gn(ut.num,"ap-notice"),children:[o.jsx(Kp,{}),o.jsx("span",{className:"ap-issue-text",children:"Current account needs attention"})]}),Bt.fix&&o.jsx("button",{type:"button",className:"ap-notice-fix",onClick:()=>J(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"Sign in"})]}),o.jsx("ul",{className:"ap-list",children:an.map(ea)}),vt.length>0&&o.jsx(az,{peers:jn,strained:Yt,armed:fe,threshold:a!=null&&a.ok?ue:null,open:at,onToggle:()=>le(ee=>!ee)}),vt.length>0&&at&&o.jsxs("div",{className:"ap-rest-panel",id:"ap-rest-panel",children:[o.jsx("ul",{className:"ap-list ap-others",id:"ap-rest-list",children:vt.map(ea)}),ta]}),vt.length===0&&ta,h&&h.row==null&&o.jsxs("div",{className:"ap-failure",role:"alert",children:[o.jsx("span",{className:"ap-failure-text",title:h.raw||void 0,children:h.text}),o.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>m(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),B&&(()=>{var Re;const ee=(Re=n.accounts)==null?void 0:Re.find(ze=>ze.num===B.num);if(!ee)return null;const Ae=`ap-pop-title-${ee.num}`,Oe=X&&o.jsx("p",{className:"ap-pop-error",role:"alert",title:X.raw||void 0,children:X.text});return o.jsxs(Kx,{anchorId:`ap-more-${ee.num}`,boundaryId:st(ee.num),id:`ap-menu-${ee.num}`,className:"ap-pop",role:B.view==="menu"?"menu":"dialog",labelledBy:B.view==="menu"?`ap-more-${ee.num}`:Ae,start:B.start,onClose:Et,children:[B.view==="menu"&&o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>{$(ee.alias??""),Y(null),q({num:ee.num,view:"rename"})},children:"Rename"}),o.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>{De(null),Y(null),q({num:ee.num,view:"move"})},children:"Move to slot…"}),o.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...We(`share-${ee.num}`),title:`Copy this account to another ${nn}. Anyone who has the text can use the account — treat it as the password. The other deck stops accepting it after 10 minutes; that does not make an escaped copy safe.`,onClick:()=>Cn(ee.num),children:c===`share-${ee.num}`?"Sharing…":"Share"}),o.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",title:"See how much this account worked in each project",onClick:()=>{ae(ee.num),Xt(ee.num)},children:"Projects"}),(((a==null?void 0:a.enabled)||(a==null?void 0:a.external))&&!ee.active||ee.disabled)&&o.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...We(`rot-${ee.num}`),title:ee.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",onClick:()=>Me({action:"account",account:ee.num,enabled:ee.disabled},`rot-${ee.num}`,"menu").then(ze=>{ye(!0),ze!=null&&ze.ok&&Xt(ee.num)}),children:ee.disabled?"Put back in rotation":"Hold out of rotation"}),o.jsx("div",{role:"separator",className:"ap-menu-sep"}),o.jsx("button",{type:"button",role:"menuitem",className:`ap-menu-item danger${z===ee.num?" armed":""}`,...We(`rm-${ee.num}`),"aria-label":z===ee.num?"Confirm remove":void 0,title:z===ee.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{const ze=Date.now(),dt=uh({armedFor:z,target:ee.num,armedAt:G.current,now:ze,gapMs:fh});if(dt==="arm"){W(ee.num),G.current=ze,window.setTimeout(()=>W(yt=>yt===ee.num?null:yt),4e3);return}dt!=="ignore"&&(W(null),Qe({action:"remove",account:ee.num},`rm-${ee.num}`).then(yt=>{var Ct;ye(!0),yt!=null&&yt.ok&&(((Ct=U.current)==null?void 0:Ct.num)===ee.num&&Et(),Je(null))}))},children:c===`rm-${ee.num}`?"Removing…":z===ee.num?"Confirm":"Remove"}),Oe]}),B.view==="rename"&&o.jsxs("form",{className:"ap-pop-form",onSubmit:ze=>{ze.preventDefault(),zt(ee.num,ee.alias)},children:[o.jsx("label",{className:"ap-pop-title",id:Ae,htmlFor:`ap-alias-${ee.num}`,children:"Rename account"}),o.jsx("input",{id:`ap-alias-${ee.num}`,className:"ap-manage-input",type:"text",value:V,onChange:ze=>$(ze.target.value),maxLength:wz,placeholder:"e.g. work",spellCheck:!1,autoComplete:"off",autoFocus:!0,onFocus:ze=>ze.currentTarget.select()}),Oe,o.jsxs("div",{className:"ap-pop-actions",children:[o.jsx("button",{type:"button",className:"btn",onClick:()=>Xt(),children:"Cancel"}),o.jsx("button",{type:"submit",className:"btn primary",...We(`alias-${ee.num}`),title:"A short name to show instead of the email",children:c===`alias-${ee.num}`?"…":"Save"})]})]}),B.view==="move"&&(()=>{const ze=cz((n.accounts??[]).map(Ct=>Ct.num),ee.num),dt=dz(ze,Te,ee.num),yt=hz(ze,dt,ee.num);return o.jsxs("div",{className:"ap-pop-form",children:[o.jsx("label",{className:"ap-pop-title",id:Ae,htmlFor:`ap-slot-${ee.num}`,children:"Move to slot"}),o.jsx("span",{className:"ap-field",children:o.jsx("select",{id:`ap-slot-${ee.num}`,value:String(dt),...We(`move-${ee.num}`),onChange:Ct=>De(Number(Ct.target.value)),autoFocus:!0,children:ze.map(Ct=>o.jsx("option",{value:Ct.slot,children:Ct.label},Ct.slot))})}),Oe,o.jsxs("div",{className:"ap-pop-actions",children:[o.jsx("button",{type:"button",className:"btn",onClick:()=>Xt(),children:"Cancel"}),o.jsx("button",{type:"button",className:"btn primary",...We(`move-${ee.num}`),title:yt.title,onClick:()=>Kn(ee.num,dt,yt),children:c===`move-${ee.num}`?"…":bc(yt.label)})]})]})})(),B.view==="share"&&(F==null?void 0:F.num)===ee.num&&(()=>{const ze=GR(F.expiresAt,T),dt=ze.tone==="gone";return o.jsxs("div",{className:`ap-pop-form ap-share${dt?" expired":""}`,children:[o.jsx("p",{className:"ap-pop-title",id:Ae,children:"Share account"}),o.jsx("code",{className:"ap-share-blob",children:F.blob}),o.jsxs("p",{className:"ap-pop-note",title:"This text is the account's password. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the login itself is in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign the account out and back in.",children:[o.jsx("span",{className:"ap-share-warn",children:"This is the password"})," · ",o.jsx("span",{className:`ap-share-expiry ${ze.tone}`,children:ze.text})]}),Oe,o.jsxs("div",{className:"ap-pop-actions",children:[o.jsx("button",{type:"button",className:"btn",onClick:()=>Xt(),children:"Done"}),o.jsx("button",{type:"button",className:"btn primary",...We(`share-${ee.num}`),autoFocus:!0,onClick:async()=>{if(dt){await Cn(ee.num);return}await sl(F.blob)&&(O(!0),window.setTimeout(()=>O(!1),1800))},children:dt?"Make a new share":Q?"Copied":"Copy"})]})]})})()]})})(),N&&(()=>{var Oe;const ee=(Oe=n.accounts)==null?void 0:Oe.find(Re=>Re.num===N.num),Ae=ee?$d(ee,T):null;return!ee||!Ae?null:o.jsx(Kx,{anchorId:N.anchor,boundaryId:N.anchor==="ap-notice"?"ap-scroll":st(ee.num),id:"ap-issue-pop",className:"ap-pop ap-issue-pop",role:"dialog",labelledBy:"ap-issue-title",onClose:()=>St(),children:o.jsxs("div",{className:"ap-pop-form",children:[o.jsxs("p",{className:"ap-pop-title ap-issue-title",id:"ap-issue-title","data-tone":Ae.tone,children:[Ae.tone==="warn"&&o.jsx(Kp,{}),Ae.text]}),o.jsx("p",{className:"ap-pop-note ap-issue-hint",children:Ae.hint}),o.jsxs("p",{className:"ap-pop-note ap-issue-when",children:[o.jsx("span",{className:"ap-issue-who",children:ee.alias??ee.email??`account ${ee.num}`})," · ",ee.fetchedAt?`last collected ${Gp(ee.fetchedAt,T)}`:"never collected"]}),o.jsxs("div",{className:"ap-pop-actions",children:[o.jsx("button",{type:"button",className:"btn",onClick:()=>St(!0),children:"Done"}),Ae.fix&&o.jsx("button",{type:"button",className:"btn primary",onClick:()=>{St(!0),J(!0)},title:"Open the sign-in dialog. Signing in as this account puts its login back in this slot — it keeps its slot, its alias and its history.",children:Ae.fix})]})]})})})()]}):o.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"claude-swap isn't installed."}),o.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),n.hint&&o.jsx("code",{className:"ap-cmd",children:n.hint}),o.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",o.jsx("strong",{children:"+"})," button above."]})]}):n.reason==="no_accounts"?o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"No accounts added yet."}),o.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",o.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"Couldn't read the account store."}),o.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})})}),o.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:y?`Now active: ${y.name}`:""}),S&&o.jsx(rz,{accounts:((n==null?void 0:n.accounts)??[]).map(ee=>({key:`${String(ee.email??"").trim().toLowerCase()}@@${ee.orgUuid??""}`,email:ee.email??"",alive:ee.alive===!0})),onChanged:()=>ye(!0),view:j==="lan",onOpen:lr,onBack:()=>k("accounts"),closeButton:$n}),M&&o.jsx(eB,{onClose:()=>J(!1),onChanged:()=>ye(!0)}),de&&o.jsx(lz,{accounts:((n==null?void 0:n.accounts)??[]).map(ee=>({num:ee.num,email:ee.email,alias:ee.alias,org:ee.org})),onClose:()=>H(!1),copyText:sl}),te!=null&&(()=>{const ee=((n==null?void 0:n.accounts)??[]).find(Ae=>Ae.num===te);return ee?o.jsx(v8,{num:ee.num,name:ee.alias??ee.email??`account ${ee.num}`,onClose:()=>ae(null)}):(ae(null),null)})()]})}const $z=3e4;function Oz({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function Lz({bundle:e,running:t,pending:n,lastTried:r}){return t?Oz({bundle:e,running:t,lastTried:r})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function Pz(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function Dz({asked:e,reported:t}){return t?t!==e:!1}function nM(e){const t=e.thresholdMs??$z;return!e.enabled||e.kind!=="restart"||!e.canRestart||!e.noticeOpen||!e.visible||e.busy?null:e.idleSince==null||e.now<e.idleSince?t:Math.max(0,t-(e.now-e.idleSince))}function Fz(e){const t=Math.max(0,Math.ceil(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function qz(e,t){return e?t==null?"auto when idle":`auto in ${Fz(t)}`:"auto-restart off"}function N_(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function Bz(e){return e<=0?{label:"Restart now",clause:"nothing is running"}:{label:"Restart anyway",clause:`${e===1?"1 agent is running":`${e} agents are running`} — their events during the restart are lost`}}function zz(e){const t=nM(e);return t==null?{idleSince:null,restart:!1,remainingMs:null}:e.idleSince==null||e.now<e.idleSince?{idleSince:e.now,restart:!1,remainingMs:t}:{idleSince:e.idleSince,restart:t===0,remainingMs:t}}function X0(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Yp,__;function Hz(){if(__)return Yp;__=1;function e(){this.__data__=[],this.size=0}return Yp=e,Yp}var Xp,S_;function hl(){if(S_)return Xp;S_=1;function e(t,n){return t===n||t!==t&&n!==n}return Xp=e,Xp}var Zp,j_;function Dh(){if(j_)return Zp;j_=1;var e=hl();function t(n,r){for(var a=n.length;a--;)if(e(n[a][0],r))return a;return-1}return Zp=t,Zp}var Qp,E_;function Uz(){if(E_)return Qp;E_=1;var e=Dh(),t=Array.prototype,n=t.splice;function r(a){var l=this.__data__,c=e(l,a);if(c<0)return!1;var u=l.length-1;return c==u?l.pop():n.call(l,c,1),--this.size,!0}return Qp=r,Qp}var Jp,C_;function Wz(){if(C_)return Jp;C_=1;var e=Dh();function t(n){var r=this.__data__,a=e(r,n);return a<0?void 0:r[a][1]}return Jp=t,Jp}var em,T_;function Vz(){if(T_)return em;T_=1;var e=Dh();function t(n){return e(this.__data__,n)>-1}return em=t,em}var tm,A_;function Gz(){if(A_)return tm;A_=1;var e=Dh();function t(n,r){var a=this.__data__,l=e(a,n);return l<0?(++this.size,a.push([n,r])):a[l][1]=r,this}return tm=t,tm}var nm,R_;function Fh(){if(R_)return nm;R_=1;var e=Hz(),t=Uz(),n=Wz(),r=Vz(),a=Gz();function l(c){var u=-1,f=c==null?0:c.length;for(this.clear();++u<f;){var p=c[u];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=r,l.prototype.set=a,nm=l,nm}var rm,M_;function Kz(){if(M_)return rm;M_=1;var e=Fh();function t(){this.__data__=new e,this.size=0}return rm=t,rm}var sm,I_;function Yz(){if(I_)return sm;I_=1;function e(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}return sm=e,sm}var am,$_;function Xz(){if($_)return am;$_=1;function e(t){return this.__data__.get(t)}return am=e,am}var om,O_;function Zz(){if(O_)return om;O_=1;function e(t){return this.__data__.has(t)}return om=e,om}var im,L_;function rM(){if(L_)return im;L_=1;var e=typeof gd=="object"&&gd&&gd.Object===Object&&gd;return im=e,im}var lm,P_;function ts(){if(P_)return lm;P_=1;var e=rM(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return lm=n,lm}var cm,D_;function fl(){if(D_)return cm;D_=1;var e=ts(),t=e.Symbol;return cm=t,cm}var um,F_;function Qz(){if(F_)return um;F_=1;var e=fl(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,a=e?e.toStringTag:void 0;function l(c){var u=n.call(c,a),f=c[a];try{c[a]=void 0;var p=!0}catch{}var h=r.call(c);return p&&(u?c[a]=f:delete c[a]),h}return um=l,um}var dm,q_;function Jz(){if(q_)return dm;q_=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return dm=n,dm}var hm,B_;function Bo(){if(B_)return hm;B_=1;var e=fl(),t=Qz(),n=Jz(),r="[object Null]",a="[object Undefined]",l=e?e.toStringTag:void 0;function c(u){return u==null?u===void 0?a:r:l&&l in Object(u)?t(u):n(u)}return hm=c,hm}var fm,z_;function Cr(){if(z_)return fm;z_=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return fm=e,fm}var pm,H_;function Jc(){if(H_)return pm;H_=1;var e=Bo(),t=Cr(),n="[object AsyncFunction]",r="[object Function]",a="[object GeneratorFunction]",l="[object Proxy]";function c(u){if(!t(u))return!1;var f=e(u);return f==r||f==a||f==n||f==l}return pm=c,pm}var mm,U_;function eH(){if(U_)return mm;U_=1;var e=ts(),t=e["__core-js_shared__"];return mm=t,mm}var gm,W_;function tH(){if(W_)return gm;W_=1;var e=eH(),t=(function(){var r=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""})();function n(r){return!!t&&t in r}return gm=n,gm}var ym,V_;function sM(){if(V_)return ym;V_=1;var e=Function.prototype,t=e.toString;function n(r){if(r!=null){try{return t.call(r)}catch{}try{return r+""}catch{}}return""}return ym=n,ym}var wm,G_;function nH(){if(G_)return wm;G_=1;var e=Jc(),t=tH(),n=Cr(),r=sM(),a=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,c=Function.prototype,u=Object.prototype,f=c.toString,p=u.hasOwnProperty,h=RegExp("^"+f.call(p).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!n(y)||t(y))return!1;var w=e(y)?h:l;return w.test(r(y))}return wm=m,wm}var vm,K_;function rH(){if(K_)return vm;K_=1;function e(t,n){return t==null?void 0:t[n]}return vm=e,vm}var xm,Y_;function zo(){if(Y_)return xm;Y_=1;var e=nH(),t=rH();function n(r,a){var l=t(r,a);return e(l)?l:void 0}return xm=n,xm}var bm,X_;function Z0(){if(X_)return bm;X_=1;var e=zo(),t=ts(),n=e(t,"Map");return bm=n,bm}var km,Z_;function qh(){if(Z_)return km;Z_=1;var e=zo(),t=e(Object,"create");return km=t,km}var Nm,Q_;function sH(){if(Q_)return Nm;Q_=1;var e=qh();function t(){this.__data__=e?e(null):{},this.size=0}return Nm=t,Nm}var _m,J_;function aH(){if(J_)return _m;J_=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return _m=e,_m}var Sm,eS;function oH(){if(eS)return Sm;eS=1;var e=qh(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function a(l){var c=this.__data__;if(e){var u=c[l];return u===t?void 0:u}return r.call(c,l)?c[l]:void 0}return Sm=a,Sm}var jm,tS;function iH(){if(tS)return jm;tS=1;var e=qh(),t=Object.prototype,n=t.hasOwnProperty;function r(a){var l=this.__data__;return e?l[a]!==void 0:n.call(l,a)}return jm=r,jm}var Em,nS;function lH(){if(nS)return Em;nS=1;var e=qh(),t="__lodash_hash_undefined__";function n(r,a){var l=this.__data__;return this.size+=this.has(r)?0:1,l[r]=e&&a===void 0?t:a,this}return Em=n,Em}var Cm,rS;function cH(){if(rS)return Cm;rS=1;var e=sH(),t=aH(),n=oH(),r=iH(),a=lH();function l(c){var u=-1,f=c==null?0:c.length;for(this.clear();++u<f;){var p=c[u];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=r,l.prototype.set=a,Cm=l,Cm}var Tm,sS;function uH(){if(sS)return Tm;sS=1;var e=cH(),t=Fh(),n=Z0();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return Tm=r,Tm}var Am,aS;function dH(){if(aS)return Am;aS=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return Am=e,Am}var Rm,oS;function Bh(){if(oS)return Rm;oS=1;var e=dH();function t(n,r){var a=n.__data__;return e(r)?a[typeof r=="string"?"string":"hash"]:a.map}return Rm=t,Rm}var Mm,iS;function hH(){if(iS)return Mm;iS=1;var e=Bh();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return Mm=t,Mm}var Im,lS;function fH(){if(lS)return Im;lS=1;var e=Bh();function t(n){return e(this,n).get(n)}return Im=t,Im}var $m,cS;function pH(){if(cS)return $m;cS=1;var e=Bh();function t(n){return e(this,n).has(n)}return $m=t,$m}var Om,uS;function mH(){if(uS)return Om;uS=1;var e=Bh();function t(n,r){var a=e(this,n),l=a.size;return a.set(n,r),this.size+=a.size==l?0:1,this}return Om=t,Om}var Lm,dS;function Q0(){if(dS)return Lm;dS=1;var e=uH(),t=hH(),n=fH(),r=pH(),a=mH();function l(c){var u=-1,f=c==null?0:c.length;for(this.clear();++u<f;){var p=c[u];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=r,l.prototype.set=a,Lm=l,Lm}var Pm,hS;function gH(){if(hS)return Pm;hS=1;var e=Fh(),t=Z0(),n=Q0(),r=200;function a(l,c){var u=this.__data__;if(u instanceof e){var f=u.__data__;if(!t||f.length<r-1)return f.push([l,c]),this.size=++u.size,this;u=this.__data__=new n(f)}return u.set(l,c),this.size=u.size,this}return Pm=a,Pm}var Dm,fS;function zh(){if(fS)return Dm;fS=1;var e=Fh(),t=Kz(),n=Yz(),r=Xz(),a=Zz(),l=gH();function c(u){var f=this.__data__=new e(u);this.size=f.size}return c.prototype.clear=t,c.prototype.delete=n,c.prototype.get=r,c.prototype.has=a,c.prototype.set=l,Dm=c,Dm}var Fm,pS;function J0(){if(pS)return Fm;pS=1;function e(t,n){for(var r=-1,a=t==null?0:t.length;++r<a&&n(t[r],r,t)!==!1;);return t}return Fm=e,Fm}var qm,mS;function aM(){if(mS)return qm;mS=1;var e=zo(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return qm=t,qm}var Bm,gS;function Hh(){if(gS)return Bm;gS=1;var e=aM();function t(n,r,a){r=="__proto__"&&e?e(n,r,{configurable:!0,enumerable:!0,value:a,writable:!0}):n[r]=a}return Bm=t,Bm}var zm,yS;function Uh(){if(yS)return zm;yS=1;var e=Hh(),t=hl(),n=Object.prototype,r=n.hasOwnProperty;function a(l,c,u){var f=l[c];(!(r.call(l,c)&&t(f,u))||u===void 0&&!(c in l))&&e(l,c,u)}return zm=a,zm}var Hm,wS;function eu(){if(wS)return Hm;wS=1;var e=Uh(),t=Hh();function n(r,a,l,c){var u=!l;l||(l={});for(var f=-1,p=a.length;++f<p;){var h=a[f],m=c?c(l[h],r[h],h,l,r):void 0;m===void 0&&(m=r[h]),u?t(l,h,m):e(l,h,m)}return l}return Hm=n,Hm}var Um,vS;function yH(){if(vS)return Um;vS=1;function e(t,n){for(var r=-1,a=Array(t);++r<t;)a[r]=n(r);return a}return Um=e,Um}var Wm,xS;function Ns(){if(xS)return Wm;xS=1;function e(t){return t!=null&&typeof t=="object"}return Wm=e,Wm}var Vm,bS;function wH(){if(bS)return Vm;bS=1;var e=Bo(),t=Ns(),n="[object Arguments]";function r(a){return t(a)&&e(a)==n}return Vm=r,Vm}var Gm,kS;function tu(){if(kS)return Gm;kS=1;var e=wH(),t=Ns(),n=Object.prototype,r=n.hasOwnProperty,a=n.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(c){return t(c)&&r.call(c,"callee")&&!a.call(c,"callee")};return Gm=l,Gm}var Km,NS;function Kt(){if(NS)return Km;NS=1;var e=Array.isArray;return Km=e,Km}var kc={exports:{}},Ym,_S;function vH(){if(_S)return Ym;_S=1;function e(){return!1}return Ym=e,Ym}kc.exports;var SS;function pl(){return SS||(SS=1,(function(e,t){var n=ts(),r=vH(),a=t&&!t.nodeType&&t,l=a&&!0&&e&&!e.nodeType&&e,c=l&&l.exports===a,u=c?n.Buffer:void 0,f=u?u.isBuffer:void 0,p=f||r;e.exports=p})(kc,kc.exports)),kc.exports}var Xm,jS;function Wh(){if(jS)return Xm;jS=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(r,a){var l=typeof r;return a=a??e,!!a&&(l=="number"||l!="symbol"&&t.test(r))&&r>-1&&r%1==0&&r<a}return Xm=n,Xm}var Zm,ES;function eb(){if(ES)return Zm;ES=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Zm=t,Zm}var Qm,CS;function xH(){if(CS)return Qm;CS=1;var e=Bo(),t=eb(),n=Ns(),r="[object Arguments]",a="[object Array]",l="[object Boolean]",c="[object Date]",u="[object Error]",f="[object Function]",p="[object Map]",h="[object Number]",m="[object Object]",y="[object RegExp]",w="[object Set]",j="[object String]",k="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",N="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",T="[object Int16Array]",A="[object Int32Array]",I="[object Uint8Array]",B="[object Uint8ClampedArray]",q="[object Uint16Array]",L="[object Uint32Array]",U={};U[N]=U[E]=U[C]=U[T]=U[A]=U[I]=U[B]=U[q]=U[L]=!0,U[r]=U[a]=U[S]=U[l]=U[b]=U[c]=U[u]=U[f]=U[p]=U[h]=U[m]=U[y]=U[w]=U[j]=U[k]=!1;function X(Y){return n(Y)&&t(Y.length)&&!!U[e(Y)]}return Qm=X,Qm}var Jm,TS;function Vh(){if(TS)return Jm;TS=1;function e(t){return function(n){return t(n)}}return Jm=e,Jm}var Nc={exports:{}};Nc.exports;var AS;function tb(){return AS||(AS=1,(function(e,t){var n=rM(),r=t&&!t.nodeType&&t,a=r&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===r,c=l&&n.process,u=(function(){try{var f=a&&a.require&&a.require("util").types;return f||c&&c.binding&&c.binding("util")}catch{}})();e.exports=u})(Nc,Nc.exports)),Nc.exports}var eg,RS;function nu(){if(RS)return eg;RS=1;var e=xH(),t=Vh(),n=tb(),r=n&&n.isTypedArray,a=r?t(r):e;return eg=a,eg}var tg,MS;function oM(){if(MS)return tg;MS=1;var e=yH(),t=tu(),n=Kt(),r=pl(),a=Wh(),l=nu(),c=Object.prototype,u=c.hasOwnProperty;function f(p,h){var m=n(p),y=!m&&t(p),w=!m&&!y&&r(p),j=!m&&!y&&!w&&l(p),k=m||y||w||j,S=k?e(p.length,String):[],b=S.length;for(var N in p)(h||u.call(p,N))&&!(k&&(N=="length"||w&&(N=="offset"||N=="parent")||j&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||a(N,b)))&&S.push(N);return S}return tg=f,tg}var ng,IS;function Gh(){if(IS)return ng;IS=1;var e=Object.prototype;function t(n){var r=n&&n.constructor,a=typeof r=="function"&&r.prototype||e;return n===a}return ng=t,ng}var rg,$S;function iM(){if($S)return rg;$S=1;function e(t,n){return function(r){return t(n(r))}}return rg=e,rg}var sg,OS;function bH(){if(OS)return sg;OS=1;var e=iM(),t=e(Object.keys,Object);return sg=t,sg}var ag,LS;function nb(){if(LS)return ag;LS=1;var e=Gh(),t=bH(),n=Object.prototype,r=n.hasOwnProperty;function a(l){if(!e(l))return t(l);var c=[];for(var u in Object(l))r.call(l,u)&&u!="constructor"&&c.push(u);return c}return ag=a,ag}var og,PS;function Qs(){if(PS)return og;PS=1;var e=Jc(),t=eb();function n(r){return r!=null&&t(r.length)&&!e(r)}return og=n,og}var ig,DS;function qa(){if(DS)return ig;DS=1;var e=oM(),t=nb(),n=Qs();function r(a){return n(a)?e(a):t(a)}return ig=r,ig}var lg,FS;function kH(){if(FS)return lg;FS=1;var e=eu(),t=qa();function n(r,a){return r&&e(a,t(a),r)}return lg=n,lg}var cg,qS;function NH(){if(qS)return cg;qS=1;function e(t){var n=[];if(t!=null)for(var r in Object(t))n.push(r);return n}return cg=e,cg}var ug,BS;function _H(){if(BS)return ug;BS=1;var e=Cr(),t=Gh(),n=NH(),r=Object.prototype,a=r.hasOwnProperty;function l(c){if(!e(c))return n(c);var u=t(c),f=[];for(var p in c)p=="constructor"&&(u||!a.call(c,p))||f.push(p);return f}return ug=l,ug}var dg,zS;function Ho(){if(zS)return dg;zS=1;var e=oM(),t=_H(),n=Qs();function r(a){return n(a)?e(a,!0):t(a)}return dg=r,dg}var hg,HS;function SH(){if(HS)return hg;HS=1;var e=eu(),t=Ho();function n(r,a){return r&&e(a,t(a),r)}return hg=n,hg}var _c={exports:{}};_c.exports;var US;function lM(){return US||(US=1,(function(e,t){var n=ts(),r=t&&!t.nodeType&&t,a=r&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===r,c=l?n.Buffer:void 0,u=c?c.allocUnsafe:void 0;function f(p,h){if(h)return p.slice();var m=p.length,y=u?u(m):new p.constructor(m);return p.copy(y),y}e.exports=f})(_c,_c.exports)),_c.exports}var fg,WS;function cM(){if(WS)return fg;WS=1;function e(t,n){var r=-1,a=t.length;for(n||(n=Array(a));++r<a;)n[r]=t[r];return n}return fg=e,fg}var pg,VS;function uM(){if(VS)return pg;VS=1;function e(t,n){for(var r=-1,a=t==null?0:t.length,l=0,c=[];++r<a;){var u=t[r];n(u,r,t)&&(c[l++]=u)}return c}return pg=e,pg}var mg,GS;function dM(){if(GS)return mg;GS=1;function e(){return[]}return mg=e,mg}var gg,KS;function rb(){if(KS)return gg;KS=1;var e=uM(),t=dM(),n=Object.prototype,r=n.propertyIsEnumerable,a=Object.getOwnPropertySymbols,l=a?function(c){return c==null?[]:(c=Object(c),e(a(c),function(u){return r.call(c,u)}))}:t;return gg=l,gg}var yg,YS;function jH(){if(YS)return yg;YS=1;var e=eu(),t=rb();function n(r,a){return e(r,t(r),a)}return yg=n,yg}var wg,XS;function sb(){if(XS)return wg;XS=1;function e(t,n){for(var r=-1,a=n.length,l=t.length;++r<a;)t[l+r]=n[r];return t}return wg=e,wg}var vg,ZS;function Kh(){if(ZS)return vg;ZS=1;var e=iM(),t=e(Object.getPrototypeOf,Object);return vg=t,vg}var xg,QS;function hM(){if(QS)return xg;QS=1;var e=sb(),t=Kh(),n=rb(),r=dM(),a=Object.getOwnPropertySymbols,l=a?function(c){for(var u=[];c;)e(u,n(c)),c=t(c);return u}:r;return xg=l,xg}var bg,JS;function EH(){if(JS)return bg;JS=1;var e=eu(),t=hM();function n(r,a){return e(r,t(r),a)}return bg=n,bg}var kg,ej;function fM(){if(ej)return kg;ej=1;var e=sb(),t=Kt();function n(r,a,l){var c=a(r);return t(r)?c:e(c,l(r))}return kg=n,kg}var Ng,tj;function pM(){if(tj)return Ng;tj=1;var e=fM(),t=rb(),n=qa();function r(a){return e(a,n,t)}return Ng=r,Ng}var _g,nj;function CH(){if(nj)return _g;nj=1;var e=fM(),t=hM(),n=Ho();function r(a){return e(a,n,t)}return _g=r,_g}var Sg,rj;function TH(){if(rj)return Sg;rj=1;var e=zo(),t=ts(),n=e(t,"DataView");return Sg=n,Sg}var jg,sj;function AH(){if(sj)return jg;sj=1;var e=zo(),t=ts(),n=e(t,"Promise");return jg=n,jg}var Eg,aj;function mM(){if(aj)return Eg;aj=1;var e=zo(),t=ts(),n=e(t,"Set");return Eg=n,Eg}var Cg,oj;function RH(){if(oj)return Cg;oj=1;var e=zo(),t=ts(),n=e(t,"WeakMap");return Cg=n,Cg}var Tg,ij;function ml(){if(ij)return Tg;ij=1;var e=TH(),t=Z0(),n=AH(),r=mM(),a=RH(),l=Bo(),c=sM(),u="[object Map]",f="[object Object]",p="[object Promise]",h="[object Set]",m="[object WeakMap]",y="[object DataView]",w=c(e),j=c(t),k=c(n),S=c(r),b=c(a),N=l;return(e&&N(new e(new ArrayBuffer(1)))!=y||t&&N(new t)!=u||n&&N(n.resolve())!=p||r&&N(new r)!=h||a&&N(new a)!=m)&&(N=function(E){var C=l(E),T=C==f?E.constructor:void 0,A=T?c(T):"";if(A)switch(A){case w:return y;case j:return u;case k:return p;case S:return h;case b:return m}return C}),Tg=N,Tg}var Ag,lj;function MH(){if(lj)return Ag;lj=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r){var a=r.length,l=new r.constructor(a);return a&&typeof r[0]=="string"&&t.call(r,"index")&&(l.index=r.index,l.input=r.input),l}return Ag=n,Ag}var Rg,cj;function gM(){if(cj)return Rg;cj=1;var e=ts(),t=e.Uint8Array;return Rg=t,Rg}var Mg,uj;function ab(){if(uj)return Mg;uj=1;var e=gM();function t(n){var r=new n.constructor(n.byteLength);return new e(r).set(new e(n)),r}return Mg=t,Mg}var Ig,dj;function IH(){if(dj)return Ig;dj=1;var e=ab();function t(n,r){var a=r?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.byteLength)}return Ig=t,Ig}var $g,hj;function $H(){if(hj)return $g;hj=1;var e=/\w*$/;function t(n){var r=new n.constructor(n.source,e.exec(n));return r.lastIndex=n.lastIndex,r}return $g=t,$g}var Og,fj;function OH(){if(fj)return Og;fj=1;var e=fl(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function r(a){return n?Object(n.call(a)):{}}return Og=r,Og}var Lg,pj;function yM(){if(pj)return Lg;pj=1;var e=ab();function t(n,r){var a=r?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.length)}return Lg=t,Lg}var Pg,mj;function LH(){if(mj)return Pg;mj=1;var e=ab(),t=IH(),n=$H(),r=OH(),a=yM(),l="[object Boolean]",c="[object Date]",u="[object Map]",f="[object Number]",p="[object RegExp]",h="[object Set]",m="[object String]",y="[object Symbol]",w="[object ArrayBuffer]",j="[object DataView]",k="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",N="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",T="[object Uint8ClampedArray]",A="[object Uint16Array]",I="[object Uint32Array]";function B(q,L,U){var X=q.constructor;switch(L){case w:return e(q);case l:case c:return new X(+q);case j:return t(q,U);case k:case S:case b:case N:case E:case C:case T:case A:case I:return a(q,U);case u:return new X;case f:case m:return new X(q);case p:return n(q);case h:return new X;case y:return r(q)}}return Pg=B,Pg}var Dg,gj;function wM(){if(gj)return Dg;gj=1;var e=Cr(),t=Object.create,n=(function(){function r(){}return function(a){if(!e(a))return{};if(t)return t(a);r.prototype=a;var l=new r;return r.prototype=void 0,l}})();return Dg=n,Dg}var Fg,yj;function vM(){if(yj)return Fg;yj=1;var e=wM(),t=Kh(),n=Gh();function r(a){return typeof a.constructor=="function"&&!n(a)?e(t(a)):{}}return Fg=r,Fg}var qg,wj;function PH(){if(wj)return qg;wj=1;var e=ml(),t=Ns(),n="[object Map]";function r(a){return t(a)&&e(a)==n}return qg=r,qg}var Bg,vj;function DH(){if(vj)return Bg;vj=1;var e=PH(),t=Vh(),n=tb(),r=n&&n.isMap,a=r?t(r):e;return Bg=a,Bg}var zg,xj;function FH(){if(xj)return zg;xj=1;var e=ml(),t=Ns(),n="[object Set]";function r(a){return t(a)&&e(a)==n}return zg=r,zg}var Hg,bj;function qH(){if(bj)return Hg;bj=1;var e=FH(),t=Vh(),n=tb(),r=n&&n.isSet,a=r?t(r):e;return Hg=a,Hg}var Ug,kj;function xM(){if(kj)return Ug;kj=1;var e=zh(),t=J0(),n=Uh(),r=kH(),a=SH(),l=lM(),c=cM(),u=jH(),f=EH(),p=pM(),h=CH(),m=ml(),y=MH(),w=LH(),j=vM(),k=Kt(),S=pl(),b=DH(),N=Cr(),E=qH(),C=qa(),T=Ho(),A=1,I=2,B=4,q="[object Arguments]",L="[object Array]",U="[object Boolean]",X="[object Date]",Y="[object Error]",M="[object Function]",J="[object GeneratorFunction]",V="[object Map]",$="[object Number]",z="[object Object]",W="[object RegExp]",G="[object Set]",F="[object String]",K="[object Symbol]",de="[object WeakMap]",H="[object ArrayBuffer]",Q="[object DataView]",O="[object Float32Array]",te="[object Float64Array]",ae="[object Int8Array]",he="[object Int16Array]",ge="[object Int32Array]",Te="[object Uint8Array]",De="[object Uint8ClampedArray]",Ve="[object Uint16Array]",je="[object Uint32Array]",ve={};ve[q]=ve[L]=ve[H]=ve[Q]=ve[U]=ve[X]=ve[O]=ve[te]=ve[ae]=ve[he]=ve[ge]=ve[V]=ve[$]=ve[z]=ve[W]=ve[G]=ve[F]=ve[K]=ve[Te]=ve[De]=ve[Ve]=ve[je]=!0,ve[Y]=ve[M]=ve[de]=!1;function Ue(ke,xe,Ge,rt,at,le){var _e,Ie=xe&A,Ze=xe&I,We=xe&B;if(Ge&&(_e=at?Ge(ke,rt,at,le):Ge(ke)),_e!==void 0)return _e;if(!N(ke))return ke;var Je=k(ke);if(Je){if(_e=y(ke),!Ie)return c(ke,_e)}else{var ye=m(ke),Me=ye==M||ye==J;if(S(ke))return l(ke,Ie);if(ye==z||ye==q||Me&&!at){if(_e=Ze||Me?{}:j(ke),!Ie)return Ze?f(ke,a(_e,ke)):u(ke,r(_e,ke))}else{if(!ve[ye])return at?ke:{};_e=w(ke,ye,Ie)}}le||(le=new e);var Qe=le.get(ke);if(Qe)return Qe;le.set(ke,_e),E(ke)?ke.forEach(function(pt){_e.add(Ue(pt,xe,Ge,pt,ke,le))}):b(ke)&&ke.forEach(function(pt,ut){_e.set(ut,Ue(pt,xe,Ge,ut,ke,le))});var ue=We?Ze?h:p:Ze?T:C,kt=Je?void 0:ue(ke);return t(kt||ke,function(pt,ut){kt&&(ut=pt,pt=ke[ut]),n(_e,ut,Ue(pt,xe,Ge,ut,ke,le))}),_e}return Ug=Ue,Ug}var Wg,Nj;function BH(){if(Nj)return Wg;Nj=1;var e=xM(),t=4;function n(r){return e(r,t)}return Wg=n,Wg}var Vg,_j;function ob(){if(_j)return Vg;_j=1;function e(t){return function(){return t}}return Vg=e,Vg}var Gg,Sj;function zH(){if(Sj)return Gg;Sj=1;function e(t){return function(n,r,a){for(var l=-1,c=Object(n),u=a(n),f=u.length;f--;){var p=u[t?f:++l];if(r(c[p],p,c)===!1)break}return n}}return Gg=e,Gg}var Kg,jj;function ib(){if(jj)return Kg;jj=1;var e=zH(),t=e();return Kg=t,Kg}var Yg,Ej;function lb(){if(Ej)return Yg;Ej=1;var e=ib(),t=qa();function n(r,a){return r&&e(r,a,t)}return Yg=n,Yg}var Xg,Cj;function HH(){if(Cj)return Xg;Cj=1;var e=Qs();function t(n,r){return function(a,l){if(a==null)return a;if(!e(a))return n(a,l);for(var c=a.length,u=r?c:-1,f=Object(a);(r?u--:++u<c)&&l(f[u],u,f)!==!1;);return a}}return Xg=t,Xg}var Zg,Tj;function Yh(){if(Tj)return Zg;Tj=1;var e=lb(),t=HH(),n=t(e);return Zg=n,Zg}var Qg,Aj;function Uo(){if(Aj)return Qg;Aj=1;function e(t){return t}return Qg=e,Qg}var Jg,Rj;function bM(){if(Rj)return Jg;Rj=1;var e=Uo();function t(n){return typeof n=="function"?n:e}return Jg=t,Jg}var ey,Mj;function kM(){if(Mj)return ey;Mj=1;var e=J0(),t=Yh(),n=bM(),r=Kt();function a(l,c){var u=r(l)?e:t;return u(l,n(c))}return ey=a,ey}var ty,Ij;function NM(){return Ij||(Ij=1,ty=kM()),ty}var ny,$j;function UH(){if($j)return ny;$j=1;var e=Yh();function t(n,r){var a=[];return e(n,function(l,c,u){r(l,c,u)&&a.push(l)}),a}return ny=t,ny}var ry,Oj;function WH(){if(Oj)return ry;Oj=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return ry=t,ry}var sy,Lj;function VH(){if(Lj)return sy;Lj=1;function e(t){return this.__data__.has(t)}return sy=e,sy}var ay,Pj;function _M(){if(Pj)return ay;Pj=1;var e=Q0(),t=WH(),n=VH();function r(a){var l=-1,c=a==null?0:a.length;for(this.__data__=new e;++l<c;)this.add(a[l])}return r.prototype.add=r.prototype.push=t,r.prototype.has=n,ay=r,ay}var oy,Dj;function GH(){if(Dj)return oy;Dj=1;function e(t,n){for(var r=-1,a=t==null?0:t.length;++r<a;)if(n(t[r],r,t))return!0;return!1}return oy=e,oy}var iy,Fj;function SM(){if(Fj)return iy;Fj=1;function e(t,n){return t.has(n)}return iy=e,iy}var ly,qj;function jM(){if(qj)return ly;qj=1;var e=_M(),t=GH(),n=SM(),r=1,a=2;function l(c,u,f,p,h,m){var y=f&r,w=c.length,j=u.length;if(w!=j&&!(y&&j>w))return!1;var k=m.get(c),S=m.get(u);if(k&&S)return k==u&&S==c;var b=-1,N=!0,E=f&a?new e:void 0;for(m.set(c,u),m.set(u,c);++b<w;){var C=c[b],T=u[b];if(p)var A=y?p(T,C,b,u,c,m):p(C,T,b,c,u,m);if(A!==void 0){if(A)continue;N=!1;break}if(E){if(!t(u,function(I,B){if(!n(E,B)&&(C===I||h(C,I,f,p,m)))return E.push(B)})){N=!1;break}}else if(!(C===T||h(C,T,f,p,m))){N=!1;break}}return m.delete(c),m.delete(u),N}return ly=l,ly}var cy,Bj;function KH(){if(Bj)return cy;Bj=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(a,l){r[++n]=[l,a]}),r}return cy=e,cy}var uy,zj;function cb(){if(zj)return uy;zj=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(a){r[++n]=a}),r}return uy=e,uy}var dy,Hj;function YH(){if(Hj)return dy;Hj=1;var e=fl(),t=gM(),n=hl(),r=jM(),a=KH(),l=cb(),c=1,u=2,f="[object Boolean]",p="[object Date]",h="[object Error]",m="[object Map]",y="[object Number]",w="[object RegExp]",j="[object Set]",k="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",N="[object DataView]",E=e?e.prototype:void 0,C=E?E.valueOf:void 0;function T(A,I,B,q,L,U,X){switch(B){case N:if(A.byteLength!=I.byteLength||A.byteOffset!=I.byteOffset)return!1;A=A.buffer,I=I.buffer;case b:return!(A.byteLength!=I.byteLength||!U(new t(A),new t(I)));case f:case p:case y:return n(+A,+I);case h:return A.name==I.name&&A.message==I.message;case w:case k:return A==I+"";case m:var Y=a;case j:var M=q&c;if(Y||(Y=l),A.size!=I.size&&!M)return!1;var J=X.get(A);if(J)return J==I;q|=u,X.set(A,I);var V=r(Y(A),Y(I),q,L,U,X);return X.delete(A),V;case S:if(C)return C.call(A)==C.call(I)}return!1}return dy=T,dy}var hy,Uj;function XH(){if(Uj)return hy;Uj=1;var e=pM(),t=1,n=Object.prototype,r=n.hasOwnProperty;function a(l,c,u,f,p,h){var m=u&t,y=e(l),w=y.length,j=e(c),k=j.length;if(w!=k&&!m)return!1;for(var S=w;S--;){var b=y[S];if(!(m?b in c:r.call(c,b)))return!1}var N=h.get(l),E=h.get(c);if(N&&E)return N==c&&E==l;var C=!0;h.set(l,c),h.set(c,l);for(var T=m;++S<w;){b=y[S];var A=l[b],I=c[b];if(f)var B=m?f(I,A,b,c,l,h):f(A,I,b,l,c,h);if(!(B===void 0?A===I||p(A,I,u,f,h):B)){C=!1;break}T||(T=b=="constructor")}if(C&&!T){var q=l.constructor,L=c.constructor;q!=L&&"constructor"in l&&"constructor"in c&&!(typeof q=="function"&&q instanceof q&&typeof L=="function"&&L instanceof L)&&(C=!1)}return h.delete(l),h.delete(c),C}return hy=a,hy}var fy,Wj;function ZH(){if(Wj)return fy;Wj=1;var e=zh(),t=jM(),n=YH(),r=XH(),a=ml(),l=Kt(),c=pl(),u=nu(),f=1,p="[object Arguments]",h="[object Array]",m="[object Object]",y=Object.prototype,w=y.hasOwnProperty;function j(k,S,b,N,E,C){var T=l(k),A=l(S),I=T?h:a(k),B=A?h:a(S);I=I==p?m:I,B=B==p?m:B;var q=I==m,L=B==m,U=I==B;if(U&&c(k)){if(!c(S))return!1;T=!0,q=!1}if(U&&!q)return C||(C=new e),T||u(k)?t(k,S,b,N,E,C):n(k,S,I,b,N,E,C);if(!(b&f)){var X=q&&w.call(k,"__wrapped__"),Y=L&&w.call(S,"__wrapped__");if(X||Y){var M=X?k.value():k,J=Y?S.value():S;return C||(C=new e),E(M,J,b,N,C)}}return U?(C||(C=new e),r(k,S,b,N,E,C)):!1}return fy=j,fy}var py,Vj;function EM(){if(Vj)return py;Vj=1;var e=ZH(),t=Ns();function n(r,a,l,c,u){return r===a?!0:r==null||a==null||!t(r)&&!t(a)?r!==r&&a!==a:e(r,a,l,c,n,u)}return py=n,py}var my,Gj;function QH(){if(Gj)return my;Gj=1;var e=zh(),t=EM(),n=1,r=2;function a(l,c,u,f){var p=u.length,h=p,m=!f;if(l==null)return!h;for(l=Object(l);p--;){var y=u[p];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++p<h;){y=u[p];var w=y[0],j=l[w],k=y[1];if(m&&y[2]){if(j===void 0&&!(w in l))return!1}else{var S=new e;if(f)var b=f(j,k,w,l,c,S);if(!(b===void 0?t(k,j,n|r,f,S):b))return!1}}return!0}return my=a,my}var gy,Kj;function CM(){if(Kj)return gy;Kj=1;var e=Cr();function t(n){return n===n&&!e(n)}return gy=t,gy}var yy,Yj;function JH(){if(Yj)return yy;Yj=1;var e=CM(),t=qa();function n(r){for(var a=t(r),l=a.length;l--;){var c=a[l],u=r[c];a[l]=[c,u,e(u)]}return a}return yy=n,yy}var wy,Xj;function TM(){if(Xj)return wy;Xj=1;function e(t,n){return function(r){return r==null?!1:r[t]===n&&(n!==void 0||t in Object(r))}}return wy=e,wy}var vy,Zj;function eU(){if(Zj)return vy;Zj=1;var e=QH(),t=JH(),n=TM();function r(a){var l=t(a);return l.length==1&&l[0][2]?n(l[0][0],l[0][1]):function(c){return c===a||e(c,a,l)}}return vy=r,vy}var xy,Qj;function gl(){if(Qj)return xy;Qj=1;var e=Bo(),t=Ns(),n="[object Symbol]";function r(a){return typeof a=="symbol"||t(a)&&e(a)==n}return xy=r,xy}var by,Jj;function ub(){if(Jj)return by;Jj=1;var e=Kt(),t=gl(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function a(l,c){if(e(l))return!1;var u=typeof l;return u=="number"||u=="symbol"||u=="boolean"||l==null||t(l)?!0:r.test(l)||!n.test(l)||c!=null&&l in Object(c)}return by=a,by}var ky,eE;function tU(){if(eE)return ky;eE=1;var e=Q0(),t="Expected a function";function n(r,a){if(typeof r!="function"||a!=null&&typeof a!="function")throw new TypeError(t);var l=function(){var c=arguments,u=a?a.apply(this,c):c[0],f=l.cache;if(f.has(u))return f.get(u);var p=r.apply(this,c);return l.cache=f.set(u,p)||f,p};return l.cache=new(n.Cache||e),l}return n.Cache=e,ky=n,ky}var Ny,tE;function nU(){if(tE)return Ny;tE=1;var e=tU(),t=500;function n(r){var a=e(r,function(c){return l.size===t&&l.clear(),c}),l=a.cache;return a}return Ny=n,Ny}var _y,nE;function rU(){if(nE)return _y;nE=1;var e=nU(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(a){var l=[];return a.charCodeAt(0)===46&&l.push(""),a.replace(t,function(c,u,f,p){l.push(f?p.replace(n,"$1"):u||c)}),l});return _y=r,_y}var Sy,rE;function Xh(){if(rE)return Sy;rE=1;function e(t,n){for(var r=-1,a=t==null?0:t.length,l=Array(a);++r<a;)l[r]=n(t[r],r,t);return l}return Sy=e,Sy}var jy,sE;function sU(){if(sE)return jy;sE=1;var e=fl(),t=Xh(),n=Kt(),r=gl(),a=e?e.prototype:void 0,l=a?a.toString:void 0;function c(u){if(typeof u=="string")return u;if(n(u))return t(u,c)+"";if(r(u))return l?l.call(u):"";var f=u+"";return f=="0"&&1/u==-1/0?"-0":f}return jy=c,jy}var Ey,aE;function AM(){if(aE)return Ey;aE=1;var e=sU();function t(n){return n==null?"":e(n)}return Ey=t,Ey}var Cy,oE;function Zh(){if(oE)return Cy;oE=1;var e=Kt(),t=ub(),n=rU(),r=AM();function a(l,c){return e(l)?l:t(l,c)?[l]:n(r(l))}return Cy=a,Cy}var Ty,iE;function ru(){if(iE)return Ty;iE=1;var e=gl();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return Ty=t,Ty}var Ay,lE;function Qh(){if(lE)return Ay;lE=1;var e=Zh(),t=ru();function n(r,a){a=e(a,r);for(var l=0,c=a.length;r!=null&&l<c;)r=r[t(a[l++])];return l&&l==c?r:void 0}return Ay=n,Ay}var Ry,cE;function aU(){if(cE)return Ry;cE=1;var e=Qh();function t(n,r,a){var l=n==null?void 0:e(n,r);return l===void 0?a:l}return Ry=t,Ry}var My,uE;function oU(){if(uE)return My;uE=1;function e(t,n){return t!=null&&n in Object(t)}return My=e,My}var Iy,dE;function RM(){if(dE)return Iy;dE=1;var e=Zh(),t=tu(),n=Kt(),r=Wh(),a=eb(),l=ru();function c(u,f,p){f=e(f,u);for(var h=-1,m=f.length,y=!1;++h<m;){var w=l(f[h]);if(!(y=u!=null&&p(u,w)))break;u=u[w]}return y||++h!=m?y:(m=u==null?0:u.length,!!m&&a(m)&&r(w,m)&&(n(u)||t(u)))}return Iy=c,Iy}var $y,hE;function MM(){if(hE)return $y;hE=1;var e=oU(),t=RM();function n(r,a){return r!=null&&t(r,a,e)}return $y=n,$y}var Oy,fE;function iU(){if(fE)return Oy;fE=1;var e=EM(),t=aU(),n=MM(),r=ub(),a=CM(),l=TM(),c=ru(),u=1,f=2;function p(h,m){return r(h)&&a(m)?l(c(h),m):function(y){var w=t(y,h);return w===void 0&&w===m?n(y,h):e(m,w,u|f)}}return Oy=p,Oy}var Ly,pE;function IM(){if(pE)return Ly;pE=1;function e(t){return function(n){return n==null?void 0:n[t]}}return Ly=e,Ly}var Py,mE;function lU(){if(mE)return Py;mE=1;var e=Qh();function t(n){return function(r){return e(r,n)}}return Py=t,Py}var Dy,gE;function cU(){if(gE)return Dy;gE=1;var e=IM(),t=lU(),n=ub(),r=ru();function a(l){return n(l)?e(r(l)):t(l)}return Dy=a,Dy}var Fy,yE;function Js(){if(yE)return Fy;yE=1;var e=eU(),t=iU(),n=Uo(),r=Kt(),a=cU();function l(c){return typeof c=="function"?c:c==null?n:typeof c=="object"?r(c)?t(c[0],c[1]):e(c):a(c)}return Fy=l,Fy}var qy,wE;function $M(){if(wE)return qy;wE=1;var e=uM(),t=UH(),n=Js(),r=Kt();function a(l,c){var u=r(l)?e:t;return u(l,n(c,3))}return qy=a,qy}var By,vE;function uU(){if(vE)return By;vE=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r,a){return r!=null&&t.call(r,a)}return By=n,By}var zy,xE;function OM(){if(xE)return zy;xE=1;var e=uU(),t=RM();function n(r,a){return r!=null&&t(r,a,e)}return zy=n,zy}var Hy,bE;function dU(){if(bE)return Hy;bE=1;var e=nb(),t=ml(),n=tu(),r=Kt(),a=Qs(),l=pl(),c=Gh(),u=nu(),f="[object Map]",p="[object Set]",h=Object.prototype,m=h.hasOwnProperty;function y(w){if(w==null)return!0;if(a(w)&&(r(w)||typeof w=="string"||typeof w.splice=="function"||l(w)||u(w)||n(w)))return!w.length;var j=t(w);if(j==f||j==p)return!w.size;if(c(w))return!e(w).length;for(var k in w)if(m.call(w,k))return!1;return!0}return Hy=y,Hy}var Uy,kE;function LM(){if(kE)return Uy;kE=1;function e(t){return t===void 0}return Uy=e,Uy}var Wy,NE;function PM(){if(NE)return Wy;NE=1;var e=Yh(),t=Qs();function n(r,a){var l=-1,c=t(r)?Array(r.length):[];return e(r,function(u,f,p){c[++l]=a(u,f,p)}),c}return Wy=n,Wy}var Vy,_E;function DM(){if(_E)return Vy;_E=1;var e=Xh(),t=Js(),n=PM(),r=Kt();function a(l,c){var u=r(l)?e:n;return u(l,t(c,3))}return Vy=a,Vy}var Gy,SE;function hU(){if(SE)return Gy;SE=1;function e(t,n,r,a){var l=-1,c=t==null?0:t.length;for(a&&c&&(r=t[++l]);++l<c;)r=n(r,t[l],l,t);return r}return Gy=e,Gy}var Ky,jE;function fU(){if(jE)return Ky;jE=1;function e(t,n,r,a,l){return l(t,function(c,u,f){r=a?(a=!1,c):n(r,c,u,f)}),r}return Ky=e,Ky}var Yy,EE;function FM(){if(EE)return Yy;EE=1;var e=hU(),t=Yh(),n=Js(),r=fU(),a=Kt();function l(c,u,f){var p=a(c)?e:r,h=arguments.length<3;return p(c,n(u,4),f,h,t)}return Yy=l,Yy}var Xy,CE;function pU(){if(CE)return Xy;CE=1;var e=Bo(),t=Kt(),n=Ns(),r="[object String]";function a(l){return typeof l=="string"||!t(l)&&n(l)&&e(l)==r}return Xy=a,Xy}var Zy,TE;function mU(){if(TE)return Zy;TE=1;var e=IM(),t=e("length");return Zy=t,Zy}var Qy,AE;function gU(){if(AE)return Qy;AE=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",a=t+n+r,l="\\ufe0e\\ufe0f",c="\\u200d",u=RegExp("["+c+e+a+l+"]");function f(p){return u.test(p)}return Qy=f,Qy}var Jy,RE;function yU(){if(RE)return Jy;RE=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",a=t+n+r,l="\\ufe0e\\ufe0f",c="["+e+"]",u="["+a+"]",f="\\ud83c[\\udffb-\\udfff]",p="(?:"+u+"|"+f+")",h="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",j=p+"?",k="["+l+"]?",S="(?:"+w+"(?:"+[h,m,y].join("|")+")"+k+j+")*",b=k+j+S,N="(?:"+[h+u+"?",u,m,y,c].join("|")+")",E=RegExp(f+"(?="+f+")|"+N+b,"g");function C(T){for(var A=E.lastIndex=0;E.test(T);)++A;return A}return Jy=C,Jy}var ew,ME;function wU(){if(ME)return ew;ME=1;var e=mU(),t=gU(),n=yU();function r(a){return t(a)?n(a):e(a)}return ew=r,ew}var tw,IE;function vU(){if(IE)return tw;IE=1;var e=nb(),t=ml(),n=Qs(),r=pU(),a=wU(),l="[object Map]",c="[object Set]";function u(f){if(f==null)return 0;if(n(f))return r(f)?a(f):f.length;var p=t(f);return p==l||p==c?f.size:e(f).length}return tw=u,tw}var nw,$E;function xU(){if($E)return nw;$E=1;var e=J0(),t=wM(),n=lb(),r=Js(),a=Kh(),l=Kt(),c=pl(),u=Jc(),f=Cr(),p=nu();function h(m,y,w){var j=l(m),k=j||c(m)||p(m);if(y=r(y,4),w==null){var S=m&&m.constructor;k?w=j?new S:[]:f(m)?w=u(S)?t(a(m)):{}:w={}}return(k?e:n)(m,function(b,N,E){return y(w,b,N,E)}),w}return nw=h,nw}var rw,OE;function bU(){if(OE)return rw;OE=1;var e=fl(),t=tu(),n=Kt(),r=e?e.isConcatSpreadable:void 0;function a(l){return n(l)||t(l)||!!(r&&l&&l[r])}return rw=a,rw}var sw,LE;function db(){if(LE)return sw;LE=1;var e=sb(),t=bU();function n(r,a,l,c,u){var f=-1,p=r.length;for(l||(l=t),u||(u=[]);++f<p;){var h=r[f];a>0&&l(h)?a>1?n(h,a-1,l,c,u):e(u,h):c||(u[u.length]=h)}return u}return sw=n,sw}var aw,PE;function kU(){if(PE)return aw;PE=1;function e(t,n,r){switch(r.length){case 0:return t.call(n);case 1:return t.call(n,r[0]);case 2:return t.call(n,r[0],r[1]);case 3:return t.call(n,r[0],r[1],r[2])}return t.apply(n,r)}return aw=e,aw}var ow,DE;function qM(){if(DE)return ow;DE=1;var e=kU(),t=Math.max;function n(r,a,l){return a=t(a===void 0?r.length-1:a,0),function(){for(var c=arguments,u=-1,f=t(c.length-a,0),p=Array(f);++u<f;)p[u]=c[a+u];u=-1;for(var h=Array(a+1);++u<a;)h[u]=c[u];return h[a]=l(p),e(r,this,h)}}return ow=n,ow}var iw,FE;function NU(){if(FE)return iw;FE=1;var e=ob(),t=aM(),n=Uo(),r=t?function(a,l){return t(a,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:n;return iw=r,iw}var lw,qE;function _U(){if(qE)return lw;qE=1;var e=800,t=16,n=Date.now;function r(a){var l=0,c=0;return function(){var u=n(),f=t-(u-c);if(c=u,f>0){if(++l>=e)return arguments[0]}else l=0;return a.apply(void 0,arguments)}}return lw=r,lw}var cw,BE;function BM(){if(BE)return cw;BE=1;var e=NU(),t=_U(),n=t(e);return cw=n,cw}var uw,zE;function Jh(){if(zE)return uw;zE=1;var e=Uo(),t=qM(),n=BM();function r(a,l){return n(t(a,l,e),a+"")}return uw=r,uw}var dw,HE;function zM(){if(HE)return dw;HE=1;function e(t,n,r,a){for(var l=t.length,c=r+(a?1:-1);a?c--:++c<l;)if(n(t[c],c,t))return c;return-1}return dw=e,dw}var hw,UE;function SU(){if(UE)return hw;UE=1;function e(t){return t!==t}return hw=e,hw}var fw,WE;function jU(){if(WE)return fw;WE=1;function e(t,n,r){for(var a=r-1,l=t.length;++a<l;)if(t[a]===n)return a;return-1}return fw=e,fw}var pw,VE;function EU(){if(VE)return pw;VE=1;var e=zM(),t=SU(),n=jU();function r(a,l,c){return l===l?n(a,l,c):e(a,t,c)}return pw=r,pw}var mw,GE;function CU(){if(GE)return mw;GE=1;var e=EU();function t(n,r){var a=n==null?0:n.length;return!!a&&e(n,r,0)>-1}return mw=t,mw}var gw,KE;function TU(){if(KE)return gw;KE=1;function e(t,n,r){for(var a=-1,l=t==null?0:t.length;++a<l;)if(r(n,t[a]))return!0;return!1}return gw=e,gw}var yw,YE;function AU(){if(YE)return yw;YE=1;function e(){}return yw=e,yw}var ww,XE;function RU(){if(XE)return ww;XE=1;var e=mM(),t=AU(),n=cb(),r=1/0,a=e&&1/n(new e([,-0]))[1]==r?function(l){return new e(l)}:t;return ww=a,ww}var vw,ZE;function MU(){if(ZE)return vw;ZE=1;var e=_M(),t=CU(),n=TU(),r=SM(),a=RU(),l=cb(),c=200;function u(f,p,h){var m=-1,y=t,w=f.length,j=!0,k=[],S=k;if(h)j=!1,y=n;else if(w>=c){var b=p?null:a(f);if(b)return l(b);j=!1,y=r,S=new e}else S=p?[]:k;e:for(;++m<w;){var N=f[m],E=p?p(N):N;if(N=h||N!==0?N:0,j&&E===E){for(var C=S.length;C--;)if(S[C]===E)continue e;p&&S.push(E),k.push(N)}else y(S,E,h)||(S!==k&&S.push(E),k.push(N))}return k}return vw=u,vw}var xw,QE;function HM(){if(QE)return xw;QE=1;var e=Qs(),t=Ns();function n(r){return t(r)&&e(r)}return xw=n,xw}var bw,JE;function IU(){if(JE)return bw;JE=1;var e=db(),t=Jh(),n=MU(),r=HM(),a=t(function(l){return n(e(l,1,r,!0))});return bw=a,bw}var kw,eC;function $U(){if(eC)return kw;eC=1;var e=Xh();function t(n,r){return e(r,function(a){return n[a]})}return kw=t,kw}var Nw,tC;function UM(){if(tC)return Nw;tC=1;var e=$U(),t=qa();function n(r){return r==null?[]:e(r,t(r))}return Nw=n,Nw}var _w,nC;function Tr(){if(nC)return _w;nC=1;var e;if(typeof X0=="function")try{e={clone:BH(),constant:ob(),each:NM(),filter:$M(),has:OM(),isArray:Kt(),isEmpty:dU(),isFunction:Jc(),isUndefined:LM(),keys:qa(),map:DM(),reduce:FM(),size:vU(),transform:xU(),union:IU(),values:UM()}}catch{}return e||(e=window._),_w=e,_w}var Sw,rC;function hb(){if(rC)return Sw;rC=1;var e=Tr();Sw=a;var t="\0",n="\0",r="";function a(h){this._isDirected=e.has(h,"directed")?h.directed:!0,this._isMultigraph=e.has(h,"multigraph")?h.multigraph:!1,this._isCompound=e.has(h,"compound")?h.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}a.prototype._nodeCount=0,a.prototype._edgeCount=0,a.prototype.isDirected=function(){return this._isDirected},a.prototype.isMultigraph=function(){return this._isMultigraph},a.prototype.isCompound=function(){return this._isCompound},a.prototype.setGraph=function(h){return this._label=h,this},a.prototype.graph=function(){return this._label},a.prototype.setDefaultNodeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultNodeLabelFn=h,this},a.prototype.nodeCount=function(){return this._nodeCount},a.prototype.nodes=function(){return e.keys(this._nodes)},a.prototype.sources=function(){var h=this;return e.filter(this.nodes(),function(m){return e.isEmpty(h._in[m])})},a.prototype.sinks=function(){var h=this;return e.filter(this.nodes(),function(m){return e.isEmpty(h._out[m])})},a.prototype.setNodes=function(h,m){var y=arguments,w=this;return e.each(h,function(j){y.length>1?w.setNode(j,m):w.setNode(j)}),this},a.prototype.setNode=function(h,m){return e.has(this._nodes,h)?(arguments.length>1&&(this._nodes[h]=m),this):(this._nodes[h]=arguments.length>1?m:this._defaultNodeLabelFn(h),this._isCompound&&(this._parent[h]=n,this._children[h]={},this._children[n][h]=!0),this._in[h]={},this._preds[h]={},this._out[h]={},this._sucs[h]={},++this._nodeCount,this)},a.prototype.node=function(h){return this._nodes[h]},a.prototype.hasNode=function(h){return e.has(this._nodes,h)},a.prototype.removeNode=function(h){var m=this;if(e.has(this._nodes,h)){var y=function(w){m.removeEdge(m._edgeObjs[w])};delete this._nodes[h],this._isCompound&&(this._removeFromParentsChildList(h),delete this._parent[h],e.each(this.children(h),function(w){m.setParent(w)}),delete this._children[h]),e.each(e.keys(this._in[h]),y),delete this._in[h],delete this._preds[h],e.each(e.keys(this._out[h]),y),delete this._out[h],delete this._sucs[h],--this._nodeCount}return this},a.prototype.setParent=function(h,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=n;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===h)throw new Error("Setting "+m+" as parent of "+h+" would create a cycle");this.setNode(m)}return this.setNode(h),this._removeFromParentsChildList(h),this._parent[h]=m,this._children[m][h]=!0,this},a.prototype._removeFromParentsChildList=function(h){delete this._children[this._parent[h]][h]},a.prototype.parent=function(h){if(this._isCompound){var m=this._parent[h];if(m!==n)return m}},a.prototype.children=function(h){if(e.isUndefined(h)&&(h=n),this._isCompound){var m=this._children[h];if(m)return e.keys(m)}else{if(h===n)return this.nodes();if(this.hasNode(h))return[]}},a.prototype.predecessors=function(h){var m=this._preds[h];if(m)return e.keys(m)},a.prototype.successors=function(h){var m=this._sucs[h];if(m)return e.keys(m)},a.prototype.neighbors=function(h){var m=this.predecessors(h);if(m)return e.union(m,this.successors(h))},a.prototype.isLeaf=function(h){var m;return this.isDirected()?m=this.successors(h):m=this.neighbors(h),m.length===0},a.prototype.filterNodes=function(h){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(k,S){h(S)&&m.setNode(S,k)}),e.each(this._edgeObjs,function(k){m.hasNode(k.v)&&m.hasNode(k.w)&&m.setEdge(k,y.edge(k))});var w={};function j(k){var S=y.parent(k);return S===void 0||m.hasNode(S)?(w[k]=S,S):S in w?w[S]:j(S)}return this._isCompound&&e.each(m.nodes(),function(k){m.setParent(k,j(k))}),m},a.prototype.setDefaultEdgeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultEdgeLabelFn=h,this},a.prototype.edgeCount=function(){return this._edgeCount},a.prototype.edges=function(){return e.values(this._edgeObjs)},a.prototype.setPath=function(h,m){var y=this,w=arguments;return e.reduce(h,function(j,k){return w.length>1?y.setEdge(j,k,m):y.setEdge(j,k),k}),this},a.prototype.setEdge=function(){var h,m,y,w,j=!1,k=arguments[0];typeof k=="object"&&k!==null&&"v"in k?(h=k.v,m=k.w,y=k.name,arguments.length===2&&(w=arguments[1],j=!0)):(h=k,m=arguments[1],y=arguments[3],arguments.length>2&&(w=arguments[2],j=!0)),h=""+h,m=""+m,e.isUndefined(y)||(y=""+y);var S=u(this._isDirected,h,m,y);if(e.has(this._edgeLabels,S))return j&&(this._edgeLabels[S]=w),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(h),this.setNode(m),this._edgeLabels[S]=j?w:this._defaultEdgeLabelFn(h,m,y);var b=f(this._isDirected,h,m,y);return h=b.v,m=b.w,Object.freeze(b),this._edgeObjs[S]=b,l(this._preds[m],h),l(this._sucs[h],m),this._in[m][S]=b,this._out[h][S]=b,this._edgeCount++,this},a.prototype.edge=function(h,m,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,h,m,y);return this._edgeLabels[w]},a.prototype.hasEdge=function(h,m,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,h,m,y);return e.has(this._edgeLabels,w)},a.prototype.removeEdge=function(h,m,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,h,m,y),j=this._edgeObjs[w];return j&&(h=j.v,m=j.w,delete this._edgeLabels[w],delete this._edgeObjs[w],c(this._preds[m],h),c(this._sucs[h],m),delete this._in[m][w],delete this._out[h][w],this._edgeCount--),this},a.prototype.inEdges=function(h,m){var y=this._in[h];if(y){var w=e.values(y);return m?e.filter(w,function(j){return j.v===m}):w}},a.prototype.outEdges=function(h,m){var y=this._out[h];if(y){var w=e.values(y);return m?e.filter(w,function(j){return j.w===m}):w}},a.prototype.nodeEdges=function(h,m){var y=this.inEdges(h,m);if(y)return y.concat(this.outEdges(h,m))};function l(h,m){h[m]?h[m]++:h[m]=1}function c(h,m){--h[m]||delete h[m]}function u(h,m,y,w){var j=""+m,k=""+y;if(!h&&j>k){var S=j;j=k,k=S}return j+r+k+r+(e.isUndefined(w)?t:w)}function f(h,m,y,w){var j=""+m,k=""+y;if(!h&&j>k){var S=j;j=k,k=S}var b={v:j,w:k};return w&&(b.name=w),b}function p(h,m){return u(h,m.v,m.w,m.name)}return Sw}var jw,sC;function OU(){return sC||(sC=1,jw="2.1.8"),jw}var Ew,aC;function LU(){return aC||(aC=1,Ew={Graph:hb(),version:OU()}),Ew}var Cw,oC;function PU(){if(oC)return Cw;oC=1;var e=Tr(),t=hb();Cw={write:n,read:l};function n(c){var u={options:{directed:c.isDirected(),multigraph:c.isMultigraph(),compound:c.isCompound()},nodes:r(c),edges:a(c)};return e.isUndefined(c.graph())||(u.value=e.clone(c.graph())),u}function r(c){return e.map(c.nodes(),function(u){var f=c.node(u),p=c.parent(u),h={v:u};return e.isUndefined(f)||(h.value=f),e.isUndefined(p)||(h.parent=p),h})}function a(c){return e.map(c.edges(),function(u){var f=c.edge(u),p={v:u.v,w:u.w};return e.isUndefined(u.name)||(p.name=u.name),e.isUndefined(f)||(p.value=f),p})}function l(c){var u=new t(c.options).setGraph(c.value);return e.each(c.nodes,function(f){u.setNode(f.v,f.value),f.parent&&u.setParent(f.v,f.parent)}),e.each(c.edges,function(f){u.setEdge({v:f.v,w:f.w,name:f.name},f.value)}),u}return Cw}var Tw,iC;function DU(){if(iC)return Tw;iC=1;var e=Tr();Tw=t;function t(n){var r={},a=[],l;function c(u){e.has(r,u)||(r[u]=!0,l.push(u),e.each(n.successors(u),c),e.each(n.predecessors(u),c))}return e.each(n.nodes(),function(u){l=[],c(u),l.length&&a.push(l)}),a}return Tw}var Aw,lC;function WM(){if(lC)return Aw;lC=1;var e=Tr();Aw=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(n){return n.key})},t.prototype.has=function(n){return e.has(this._keyIndices,n)},t.prototype.priority=function(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(n,r){var a=this._keyIndices;if(n=String(n),!e.has(a,n)){var l=this._arr,c=l.length;return a[n]=c,l.push({key:n,priority:r}),this._decrease(c),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key},t.prototype.decrease=function(n,r){var a=this._keyIndices[n];if(r>this._arr[a].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[a].priority+" New: "+r);this._arr[a].priority=r,this._decrease(a)},t.prototype._heapify=function(n){var r=this._arr,a=2*n,l=a+1,c=n;a<r.length&&(c=r[a].priority<r[c].priority?a:c,l<r.length&&(c=r[l].priority<r[c].priority?l:c),c!==n&&(this._swap(n,c),this._heapify(c)))},t.prototype._decrease=function(n){for(var r=this._arr,a=r[n].priority,l;n!==0&&(l=n>>1,!(r[l].priority<a));)this._swap(n,l),n=l},t.prototype._swap=function(n,r){var a=this._arr,l=this._keyIndices,c=a[n],u=a[r];a[n]=u,a[r]=c,l[u.key]=n,l[c.key]=r},Aw}var Rw,cC;function VM(){if(cC)return Rw;cC=1;var e=Tr(),t=WM();Rw=r;var n=e.constant(1);function r(l,c,u,f){return a(l,String(c),u||n,f||function(p){return l.outEdges(p)})}function a(l,c,u,f){var p={},h=new t,m,y,w=function(j){var k=j.v!==m?j.v:j.w,S=p[k],b=u(j),N=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+j+" Weight: "+b);N<S.distance&&(S.distance=N,S.predecessor=m,h.decrease(k,N))};for(l.nodes().forEach(function(j){var k=j===c?0:Number.POSITIVE_INFINITY;p[j]={distance:k},h.add(j,k)});h.size()>0&&(m=h.removeMin(),y=p[m],y.distance!==Number.POSITIVE_INFINITY);)f(m).forEach(w);return p}return Rw}var Mw,uC;function FU(){if(uC)return Mw;uC=1;var e=VM(),t=Tr();Mw=n;function n(r,a,l){return t.transform(r.nodes(),function(c,u){c[u]=e(r,u,a,l)},{})}return Mw}var Iw,dC;function GM(){if(dC)return Iw;dC=1;var e=Tr();Iw=t;function t(n){var r=0,a=[],l={},c=[];function u(f){var p=l[f]={onStack:!0,lowlink:r,index:r++};if(a.push(f),n.successors(f).forEach(function(y){e.has(l,y)?l[y].onStack&&(p.lowlink=Math.min(p.lowlink,l[y].index)):(u(y),p.lowlink=Math.min(p.lowlink,l[y].lowlink))}),p.lowlink===p.index){var h=[],m;do m=a.pop(),l[m].onStack=!1,h.push(m);while(f!==m);c.push(h)}}return n.nodes().forEach(function(f){e.has(l,f)||u(f)}),c}return Iw}var $w,hC;function qU(){if(hC)return $w;hC=1;var e=Tr(),t=GM();$w=n;function n(r){return e.filter(t(r),function(a){return a.length>1||a.length===1&&r.hasEdge(a[0],a[0])})}return $w}var Ow,fC;function BU(){if(fC)return Ow;fC=1;var e=Tr();Ow=n;var t=e.constant(1);function n(a,l,c){return r(a,l||t,c||function(u){return a.outEdges(u)})}function r(a,l,c){var u={},f=a.nodes();return f.forEach(function(p){u[p]={},u[p][p]={distance:0},f.forEach(function(h){p!==h&&(u[p][h]={distance:Number.POSITIVE_INFINITY})}),c(p).forEach(function(h){var m=h.v===p?h.w:h.v,y=l(h);u[p][m]={distance:y,predecessor:p}})}),f.forEach(function(p){var h=u[p];f.forEach(function(m){var y=u[m];f.forEach(function(w){var j=y[p],k=h[w],S=y[w],b=j.distance+k.distance;b<S.distance&&(S.distance=b,S.predecessor=k.predecessor)})})}),u}return Ow}var Lw,pC;function KM(){if(pC)return Lw;pC=1;var e=Tr();Lw=t,t.CycleException=n;function t(r){var a={},l={},c=[];function u(f){if(e.has(l,f))throw new n;e.has(a,f)||(l[f]=!0,a[f]=!0,e.each(r.predecessors(f),u),delete l[f],c.push(f))}if(e.each(r.sinks(),u),e.size(a)!==r.nodeCount())throw new n;return c}function n(){}return n.prototype=new Error,Lw}var Pw,mC;function zU(){if(mC)return Pw;mC=1;var e=KM();Pw=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return Pw}var Dw,gC;function YM(){if(gC)return Dw;gC=1;var e=Tr();Dw=t;function t(r,a,l){e.isArray(a)||(a=[a]);var c=(r.isDirected()?r.successors:r.neighbors).bind(r),u=[],f={};return e.each(a,function(p){if(!r.hasNode(p))throw new Error("Graph does not have node: "+p);n(r,p,l==="post",f,c,u)}),u}function n(r,a,l,c,u,f){e.has(c,a)||(c[a]=!0,l||f.push(a),e.each(u(a),function(p){n(r,p,l,c,u,f)}),l&&f.push(a))}return Dw}var Fw,yC;function HU(){if(yC)return Fw;yC=1;var e=YM();Fw=t;function t(n,r){return e(n,r,"post")}return Fw}var qw,wC;function UU(){if(wC)return qw;wC=1;var e=YM();qw=t;function t(n,r){return e(n,r,"pre")}return qw}var Bw,vC;function WU(){if(vC)return Bw;vC=1;var e=Tr(),t=hb(),n=WM();Bw=r;function r(a,l){var c=new t,u={},f=new n,p;function h(y){var w=y.v===p?y.w:y.v,j=f.priority(w);if(j!==void 0){var k=l(y);k<j&&(u[w]=p,f.decrease(w,k))}}if(a.nodeCount()===0)return c;e.each(a.nodes(),function(y){f.add(y,Number.POSITIVE_INFINITY),c.setNode(y)}),f.decrease(a.nodes()[0],0);for(var m=!1;f.size()>0;){if(p=f.removeMin(),e.has(u,p))c.setEdge(p,u[p]);else{if(m)throw new Error("Input graph is not connected: "+a);m=!0}a.nodeEdges(p).forEach(h)}return c}return Bw}var zw,xC;function VU(){return xC||(xC=1,zw={components:DU(),dijkstra:VM(),dijkstraAll:FU(),findCycles:qU(),floydWarshall:BU(),isAcyclic:zU(),postorder:HU(),preorder:UU(),prim:WU(),tarjan:GM(),topsort:KM()}),zw}var Hw,bC;function GU(){if(bC)return Hw;bC=1;var e=LU();return Hw={Graph:e.Graph,json:PU(),alg:VU(),version:e.version},Hw}var Uw,kC;function Jr(){if(kC)return Uw;kC=1;var e;if(typeof X0=="function")try{e=GU()}catch{}return e||(e=window.graphlib),Uw=e,Uw}var Ww,NC;function KU(){if(NC)return Ww;NC=1;var e=xM(),t=1,n=4;function r(a){return e(a,t|n)}return Ww=r,Ww}var Vw,_C;function ef(){if(_C)return Vw;_C=1;var e=hl(),t=Qs(),n=Wh(),r=Cr();function a(l,c,u){if(!r(u))return!1;var f=typeof c;return(f=="number"?t(u)&&n(c,u.length):f=="string"&&c in u)?e(u[c],l):!1}return Vw=a,Vw}var Gw,SC;function YU(){if(SC)return Gw;SC=1;var e=Jh(),t=hl(),n=ef(),r=Ho(),a=Object.prototype,l=a.hasOwnProperty,c=e(function(u,f){u=Object(u);var p=-1,h=f.length,m=h>2?f[2]:void 0;for(m&&n(f[0],f[1],m)&&(h=1);++p<h;)for(var y=f[p],w=r(y),j=-1,k=w.length;++j<k;){var S=w[j],b=u[S];(b===void 0||t(b,a[S])&&!l.call(u,S))&&(u[S]=y[S])}return u});return Gw=c,Gw}var Kw,jC;function XU(){if(jC)return Kw;jC=1;var e=Js(),t=Qs(),n=qa();function r(a){return function(l,c,u){var f=Object(l);if(!t(l)){var p=e(c,3);l=n(l),c=function(m){return p(f[m],m,f)}}var h=a(l,c,u);return h>-1?f[p?l[h]:h]:void 0}}return Kw=r,Kw}var Yw,EC;function ZU(){if(EC)return Yw;EC=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return Yw=t,Yw}var Xw,CC;function QU(){if(CC)return Xw;CC=1;var e=ZU(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return Xw=n,Xw}var Zw,TC;function JU(){if(TC)return Zw;TC=1;var e=QU(),t=Cr(),n=gl(),r=NaN,a=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt;function f(p){if(typeof p=="number")return p;if(n(p))return r;if(t(p)){var h=typeof p.valueOf=="function"?p.valueOf():p;p=t(h)?h+"":h}if(typeof p!="string")return p===0?p:+p;p=e(p);var m=l.test(p);return m||c.test(p)?u(p.slice(2),m?2:8):a.test(p)?r:+p}return Zw=f,Zw}var Qw,AC;function XM(){if(AC)return Qw;AC=1;var e=JU(),t=1/0,n=17976931348623157e292;function r(a){if(!a)return a===0?a:0;if(a=e(a),a===t||a===-t){var l=a<0?-1:1;return l*n}return a===a?a:0}return Qw=r,Qw}var Jw,RC;function eW(){if(RC)return Jw;RC=1;var e=XM();function t(n){var r=e(n),a=r%1;return r===r?a?r-a:r:0}return Jw=t,Jw}var ev,MC;function tW(){if(MC)return ev;MC=1;var e=zM(),t=Js(),n=eW(),r=Math.max;function a(l,c,u){var f=l==null?0:l.length;if(!f)return-1;var p=u==null?0:n(u);return p<0&&(p=r(f+p,0)),e(l,t(c,3),p)}return ev=a,ev}var tv,IC;function nW(){if(IC)return tv;IC=1;var e=XU(),t=tW(),n=e(t);return tv=n,tv}var nv,$C;function ZM(){if($C)return nv;$C=1;var e=db();function t(n){var r=n==null?0:n.length;return r?e(n,1):[]}return nv=t,nv}var rv,OC;function rW(){if(OC)return rv;OC=1;var e=ib(),t=bM(),n=Ho();function r(a,l){return a==null?a:e(a,t(l),n)}return rv=r,rv}var sv,LC;function sW(){if(LC)return sv;LC=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return sv=e,sv}var av,PC;function aW(){if(PC)return av;PC=1;var e=Hh(),t=lb(),n=Js();function r(a,l){var c={};return l=n(l,3),t(a,function(u,f,p){e(c,f,l(u,f,p))}),c}return av=r,av}var ov,DC;function fb(){if(DC)return ov;DC=1;var e=gl();function t(n,r,a){for(var l=-1,c=n.length;++l<c;){var u=n[l],f=r(u);if(f!=null&&(p===void 0?f===f&&!e(f):a(f,p)))var p=f,h=u}return h}return ov=t,ov}var iv,FC;function oW(){if(FC)return iv;FC=1;function e(t,n){return t>n}return iv=e,iv}var lv,qC;function iW(){if(qC)return lv;qC=1;var e=fb(),t=oW(),n=Uo();function r(a){return a&&a.length?e(a,n,t):void 0}return lv=r,lv}var cv,BC;function QM(){if(BC)return cv;BC=1;var e=Hh(),t=hl();function n(r,a,l){(l!==void 0&&!t(r[a],l)||l===void 0&&!(a in r))&&e(r,a,l)}return cv=n,cv}var uv,zC;function lW(){if(zC)return uv;zC=1;var e=Bo(),t=Kh(),n=Ns(),r="[object Object]",a=Function.prototype,l=Object.prototype,c=a.toString,u=l.hasOwnProperty,f=c.call(Object);function p(h){if(!n(h)||e(h)!=r)return!1;var m=t(h);if(m===null)return!0;var y=u.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&c.call(y)==f}return uv=p,uv}var dv,HC;function JM(){if(HC)return dv;HC=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return dv=e,dv}var hv,UC;function cW(){if(UC)return hv;UC=1;var e=eu(),t=Ho();function n(r){return e(r,t(r))}return hv=n,hv}var fv,WC;function uW(){if(WC)return fv;WC=1;var e=QM(),t=lM(),n=yM(),r=cM(),a=vM(),l=tu(),c=Kt(),u=HM(),f=pl(),p=Jc(),h=Cr(),m=lW(),y=nu(),w=JM(),j=cW();function k(S,b,N,E,C,T,A){var I=w(S,N),B=w(b,N),q=A.get(B);if(q){e(S,N,q);return}var L=T?T(I,B,N+"",S,b,A):void 0,U=L===void 0;if(U){var X=c(B),Y=!X&&f(B),M=!X&&!Y&&y(B);L=B,X||Y||M?c(I)?L=I:u(I)?L=r(I):Y?(U=!1,L=t(B,!0)):M?(U=!1,L=n(B,!0)):L=[]:m(B)||l(B)?(L=I,l(I)?L=j(I):(!h(I)||p(I))&&(L=a(B))):U=!1}U&&(A.set(B,L),C(L,B,E,T,A),A.delete(B)),e(S,N,L)}return fv=k,fv}var pv,VC;function dW(){if(VC)return pv;VC=1;var e=zh(),t=QM(),n=ib(),r=uW(),a=Cr(),l=Ho(),c=JM();function u(f,p,h,m,y){f!==p&&n(p,function(w,j){if(y||(y=new e),a(w))r(f,p,j,h,u,m,y);else{var k=m?m(c(f,j),w,j+"",f,p,y):void 0;k===void 0&&(k=w),t(f,j,k)}},l)}return pv=u,pv}var mv,GC;function hW(){if(GC)return mv;GC=1;var e=Jh(),t=ef();function n(r){return e(function(a,l){var c=-1,u=l.length,f=u>1?l[u-1]:void 0,p=u>2?l[2]:void 0;for(f=r.length>3&&typeof f=="function"?(u--,f):void 0,p&&t(l[0],l[1],p)&&(f=u<3?void 0:f,u=1),a=Object(a);++c<u;){var h=l[c];h&&r(a,h,c,f)}return a})}return mv=n,mv}var gv,KC;function fW(){if(KC)return gv;KC=1;var e=dW(),t=hW(),n=t(function(r,a,l){e(r,a,l)});return gv=n,gv}var yv,YC;function eI(){if(YC)return yv;YC=1;function e(t,n){return t<n}return yv=e,yv}var wv,XC;function pW(){if(XC)return wv;XC=1;var e=fb(),t=eI(),n=Uo();function r(a){return a&&a.length?e(a,n,t):void 0}return wv=r,wv}var vv,ZC;function mW(){if(ZC)return vv;ZC=1;var e=fb(),t=Js(),n=eI();function r(a,l){return a&&a.length?e(a,t(l,2),n):void 0}return vv=r,vv}var xv,QC;function gW(){if(QC)return xv;QC=1;var e=ts(),t=function(){return e.Date.now()};return xv=t,xv}var bv,JC;function yW(){if(JC)return bv;JC=1;var e=Uh(),t=Zh(),n=Wh(),r=Cr(),a=ru();function l(c,u,f,p){if(!r(c))return c;u=t(u,c);for(var h=-1,m=u.length,y=m-1,w=c;w!=null&&++h<m;){var j=a(u[h]),k=f;if(j==="__proto__"||j==="constructor"||j==="prototype")return c;if(h!=y){var S=w[j];k=p?p(S,j,w):void 0,k===void 0&&(k=r(S)?S:n(u[h+1])?[]:{})}e(w,j,k),w=w[j]}return c}return bv=l,bv}var kv,eT;function wW(){if(eT)return kv;eT=1;var e=Qh(),t=yW(),n=Zh();function r(a,l,c){for(var u=-1,f=l.length,p={};++u<f;){var h=l[u],m=e(a,h);c(m,h)&&t(p,n(h,a),m)}return p}return kv=r,kv}var Nv,tT;function vW(){if(tT)return Nv;tT=1;var e=wW(),t=MM();function n(r,a){return e(r,a,function(l,c){return t(r,c)})}return Nv=n,Nv}var _v,nT;function xW(){if(nT)return _v;nT=1;var e=ZM(),t=qM(),n=BM();function r(a){return n(t(a,void 0,e),a+"")}return _v=r,_v}var Sv,rT;function bW(){if(rT)return Sv;rT=1;var e=vW(),t=xW(),n=t(function(r,a){return r==null?{}:e(r,a)});return Sv=n,Sv}var jv,sT;function kW(){if(sT)return jv;sT=1;var e=Math.ceil,t=Math.max;function n(r,a,l,c){for(var u=-1,f=t(e((a-r)/(l||1)),0),p=Array(f);f--;)p[c?f:++u]=r,r+=l;return p}return jv=n,jv}var Ev,aT;function NW(){if(aT)return Ev;aT=1;var e=kW(),t=ef(),n=XM();function r(a){return function(l,c,u){return u&&typeof u!="number"&&t(l,c,u)&&(c=u=void 0),l=n(l),c===void 0?(c=l,l=0):c=n(c),u=u===void 0?l<c?1:-1:n(u),e(l,c,u,a)}}return Ev=r,Ev}var Cv,oT;function _W(){if(oT)return Cv;oT=1;var e=NW(),t=e();return Cv=t,Cv}var Tv,iT;function SW(){if(iT)return Tv;iT=1;function e(t,n){var r=t.length;for(t.sort(n);r--;)t[r]=t[r].value;return t}return Tv=e,Tv}var Av,lT;function jW(){if(lT)return Av;lT=1;var e=gl();function t(n,r){if(n!==r){var a=n!==void 0,l=n===null,c=n===n,u=e(n),f=r!==void 0,p=r===null,h=r===r,m=e(r);if(!p&&!m&&!u&&n>r||u&&f&&h&&!p&&!m||l&&f&&h||!a&&h||!c)return 1;if(!l&&!u&&!m&&n<r||m&&a&&c&&!l&&!u||p&&a&&c||!f&&c||!h)return-1}return 0}return Av=t,Av}var Rv,cT;function EW(){if(cT)return Rv;cT=1;var e=jW();function t(n,r,a){for(var l=-1,c=n.criteria,u=r.criteria,f=c.length,p=a.length;++l<f;){var h=e(c[l],u[l]);if(h){if(l>=p)return h;var m=a[l];return h*(m=="desc"?-1:1)}}return n.index-r.index}return Rv=t,Rv}var Mv,uT;function CW(){if(uT)return Mv;uT=1;var e=Xh(),t=Qh(),n=Js(),r=PM(),a=SW(),l=Vh(),c=EW(),u=Uo(),f=Kt();function p(h,m,y){m.length?m=e(m,function(k){return f(k)?function(S){return t(S,k.length===1?k[0]:k)}:k}):m=[u];var w=-1;m=e(m,l(n));var j=r(h,function(k,S,b){var N=e(m,function(E){return E(k)});return{criteria:N,index:++w,value:k}});return a(j,function(k,S){return c(k,S,y)})}return Mv=p,Mv}var Iv,dT;function TW(){if(dT)return Iv;dT=1;var e=db(),t=CW(),n=Jh(),r=ef(),a=n(function(l,c){if(l==null)return[];var u=c.length;return u>1&&r(l,c[0],c[1])?c=[]:u>2&&r(c[0],c[1],c[2])&&(c=[c[0]]),t(l,e(c,1),[])});return Iv=a,Iv}var $v,hT;function AW(){if(hT)return $v;hT=1;var e=AM(),t=0;function n(r){var a=++t;return e(r)+a}return $v=n,$v}var Ov,fT;function RW(){if(fT)return Ov;fT=1;function e(t,n,r){for(var a=-1,l=t.length,c=n.length,u={};++a<l;){var f=a<c?n[a]:void 0;r(u,t[a],f)}return u}return Ov=e,Ov}var Lv,pT;function MW(){if(pT)return Lv;pT=1;var e=Uh(),t=RW();function n(r,a){return t(r||[],a||[],e)}return Lv=n,Lv}var Pv,mT;function Mt(){if(mT)return Pv;mT=1;var e;if(typeof X0=="function")try{e={cloneDeep:KU(),constant:ob(),defaults:YU(),each:NM(),filter:$M(),find:nW(),flatten:ZM(),forEach:kM(),forIn:rW(),has:OM(),isUndefined:LM(),last:sW(),map:DM(),mapValues:aW(),max:iW(),merge:fW(),min:pW(),minBy:mW(),now:gW(),pick:bW(),range:_W(),reduce:FM(),sortBy:TW(),uniqueId:AW(),values:UM(),zipObject:MW()}}catch{}return e||(e=window._),Pv=e,Pv}var Dv,gT;function IW(){if(gT)return Dv;gT=1,Dv=e;function e(){var r={};r._next=r._prev=r,this._sentinel=r}e.prototype.dequeue=function(){var r=this._sentinel,a=r._prev;if(a!==r)return t(a),a},e.prototype.enqueue=function(r){var a=this._sentinel;r._prev&&r._next&&t(r),r._next=a._next,a._next._prev=r,a._next=r,r._prev=a},e.prototype.toString=function(){for(var r=[],a=this._sentinel,l=a._prev;l!==a;)r.push(JSON.stringify(l,n)),l=l._prev;return"["+r.join(", ")+"]"};function t(r){r._prev._next=r._next,r._next._prev=r._prev,delete r._next,delete r._prev}function n(r,a){if(r!=="_next"&&r!=="_prev")return a}return Dv}var Fv,yT;function $W(){if(yT)return Fv;yT=1;var e=Mt(),t=Jr().Graph,n=IW();Fv=a;var r=e.constant(1);function a(p,h){if(p.nodeCount()<=1)return[];var m=u(p,h||r),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(w){return p.outEdges(w.v,w.w)}),!0)}function l(p,h,m){for(var y=[],w=h[h.length-1],j=h[0],k;p.nodeCount();){for(;k=j.dequeue();)c(p,h,m,k);for(;k=w.dequeue();)c(p,h,m,k);if(p.nodeCount()){for(var S=h.length-2;S>0;--S)if(k=h[S].dequeue(),k){y=y.concat(c(p,h,m,k,!0));break}}}return y}function c(p,h,m,y,w){var j=w?[]:void 0;return e.forEach(p.inEdges(y.v),function(k){var S=p.edge(k),b=p.node(k.v);w&&j.push({v:k.v,w:k.w}),b.out-=S,f(h,m,b)}),e.forEach(p.outEdges(y.v),function(k){var S=p.edge(k),b=k.w,N=p.node(b);N.in-=S,f(h,m,N)}),p.removeNode(y.v),j}function u(p,h){var m=new t,y=0,w=0;e.forEach(p.nodes(),function(S){m.setNode(S,{v:S,in:0,out:0})}),e.forEach(p.edges(),function(S){var b=m.edge(S.v,S.w)||0,N=h(S),E=b+N;m.setEdge(S.v,S.w,E),w=Math.max(w,m.node(S.v).out+=N),y=Math.max(y,m.node(S.w).in+=N)});var j=e.range(w+y+3).map(function(){return new n}),k=y+1;return e.forEach(m.nodes(),function(S){f(j,k,m.node(S))}),{graph:m,buckets:j,zeroIdx:k}}function f(p,h,m){m.out?m.in?p[m.out-m.in+h].enqueue(m):p[p.length-1].enqueue(m):p[0].enqueue(m)}return Fv}var qv,wT;function OW(){if(wT)return qv;wT=1;var e=Mt(),t=$W();qv={run:n,undo:a};function n(l){var c=l.graph().acyclicer==="greedy"?t(l,u(l)):r(l);e.forEach(c,function(f){var p=l.edge(f);l.removeEdge(f),p.forwardName=f.name,p.reversed=!0,l.setEdge(f.w,f.v,p,e.uniqueId("rev"))});function u(f){return function(p){return f.edge(p).weight}}}function r(l){var c=[],u={},f={};function p(h){e.has(f,h)||(f[h]=!0,u[h]=!0,e.forEach(l.outEdges(h),function(m){e.has(u,m.w)?c.push(m):p(m.w)}),delete u[h])}return e.forEach(l.nodes(),p),c}function a(l){e.forEach(l.edges(),function(c){var u=l.edge(c);if(u.reversed){l.removeEdge(c);var f=u.forwardName;delete u.reversed,delete u.forwardName,l.setEdge(c.w,c.v,u,f)}})}return qv}var Bv,vT;function Wn(){if(vT)return Bv;vT=1;var e=Mt(),t=Jr().Graph;Bv={addDummyNode:n,simplify:r,asNonCompoundGraph:a,successorWeights:l,predecessorWeights:c,intersectRect:u,buildLayerMatrix:f,normalizeRanks:p,removeEmptyRanks:h,addBorderNode:m,maxRank:y,partition:w,time:j,notime:k};function n(S,b,N,E){var C;do C=e.uniqueId(E);while(S.hasNode(C));return N.dummy=b,S.setNode(C,N),C}function r(S){var b=new t().setGraph(S.graph());return e.forEach(S.nodes(),function(N){b.setNode(N,S.node(N))}),e.forEach(S.edges(),function(N){var E=b.edge(N.v,N.w)||{weight:0,minlen:1},C=S.edge(N);b.setEdge(N.v,N.w,{weight:E.weight+C.weight,minlen:Math.max(E.minlen,C.minlen)})}),b}function a(S){var b=new t({multigraph:S.isMultigraph()}).setGraph(S.graph());return e.forEach(S.nodes(),function(N){S.children(N).length||b.setNode(N,S.node(N))}),e.forEach(S.edges(),function(N){b.setEdge(N,S.edge(N))}),b}function l(S){var b=e.map(S.nodes(),function(N){var E={};return e.forEach(S.outEdges(N),function(C){E[C.w]=(E[C.w]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function c(S){var b=e.map(S.nodes(),function(N){var E={};return e.forEach(S.inEdges(N),function(C){E[C.v]=(E[C.v]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function u(S,b){var N=S.x,E=S.y,C=b.x-N,T=b.y-E,A=S.width/2,I=S.height/2;if(!C&&!T)throw new Error("Not possible to find intersection inside of the rectangle");var B,q;return Math.abs(T)*A>Math.abs(C)*I?(T<0&&(I=-I),B=I*C/T,q=I):(C<0&&(A=-A),B=A,q=A*T/C),{x:N+B,y:E+q}}function f(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(N){var E=S.node(N),C=E.rank;e.isUndefined(C)||(b[C][E.order]=N)}),b}function p(S){var b=e.min(e.map(S.nodes(),function(N){return S.node(N).rank}));e.forEach(S.nodes(),function(N){var E=S.node(N);e.has(E,"rank")&&(E.rank-=b)})}function h(S){var b=e.min(e.map(S.nodes(),function(T){return S.node(T).rank})),N=[];e.forEach(S.nodes(),function(T){var A=S.node(T).rank-b;N[A]||(N[A]=[]),N[A].push(T)});var E=0,C=S.graph().nodeRankFactor;e.forEach(N,function(T,A){e.isUndefined(T)&&A%C!==0?--E:E&&e.forEach(T,function(I){S.node(I).rank+=E})})}function m(S,b,N,E){var C={width:0,height:0};return arguments.length>=4&&(C.rank=N,C.order=E),n(S,"border",C,b)}function y(S){return e.max(e.map(S.nodes(),function(b){var N=S.node(b).rank;if(!e.isUndefined(N))return N}))}function w(S,b){var N={lhs:[],rhs:[]};return e.forEach(S,function(E){b(E)?N.lhs.push(E):N.rhs.push(E)}),N}function j(S,b){var N=e.now();try{return b()}finally{console.log(S+" time: "+(e.now()-N)+"ms")}}function k(S,b){return b()}return Bv}var zv,xT;function LW(){if(xT)return zv;xT=1;var e=Mt(),t=Wn();zv={run:n,undo:a};function n(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(c){r(l,c)})}function r(l,c){var u=c.v,f=l.node(u).rank,p=c.w,h=l.node(p).rank,m=c.name,y=l.edge(c),w=y.labelRank;if(h!==f+1){l.removeEdge(c);var j,k,S;for(S=0,++f;f<h;++S,++f)y.points=[],k={width:0,height:0,edgeLabel:y,edgeObj:c,rank:f},j=t.addDummyNode(l,"edge",k,"_d"),f===w&&(k.width=y.width,k.height=y.height,k.dummy="edge-label",k.labelpos=y.labelpos),l.setEdge(u,j,{weight:y.weight},m),S===0&&l.graph().dummyChains.push(j),u=j;l.setEdge(u,p,{weight:y.weight},m)}}function a(l){e.forEach(l.graph().dummyChains,function(c){var u=l.node(c),f=u.edgeLabel,p;for(l.setEdge(u.edgeObj,f);u.dummy;)p=l.successors(c)[0],l.removeNode(c),f.points.push({x:u.x,y:u.y}),u.dummy==="edge-label"&&(f.x=u.x,f.y=u.y,f.width=u.width,f.height=u.height),c=p,u=l.node(c)})}return zv}var Hv,bT;function gh(){if(bT)return Hv;bT=1;var e=Mt();Hv={longestPath:t,slack:n};function t(r){var a={};function l(c){var u=r.node(c);if(e.has(a,c))return u.rank;a[c]=!0;var f=e.min(e.map(r.outEdges(c),function(p){return l(p.w)-r.edge(p).minlen}));return(f===Number.POSITIVE_INFINITY||f===void 0||f===null)&&(f=0),u.rank=f}e.forEach(r.sources(),l)}function n(r,a){return r.node(a.w).rank-r.node(a.v).rank-r.edge(a).minlen}return Hv}var Uv,kT;function tI(){if(kT)return Uv;kT=1;var e=Mt(),t=Jr().Graph,n=gh().slack;Uv=r;function r(u){var f=new t({directed:!1}),p=u.nodes()[0],h=u.nodeCount();f.setNode(p,{});for(var m,y;a(f,u)<h;)m=l(f,u),y=f.hasNode(m.v)?n(u,m):-n(u,m),c(f,u,y);return f}function a(u,f){function p(h){e.forEach(f.nodeEdges(h),function(m){var y=m.v,w=h===y?m.w:y;!u.hasNode(w)&&!n(f,m)&&(u.setNode(w,{}),u.setEdge(h,w,{}),p(w))})}return e.forEach(u.nodes(),p),u.nodeCount()}function l(u,f){return e.minBy(f.edges(),function(p){if(u.hasNode(p.v)!==u.hasNode(p.w))return n(f,p)})}function c(u,f,p){e.forEach(u.nodes(),function(h){f.node(h).rank+=p})}return Uv}var Wv,NT;function PW(){if(NT)return Wv;NT=1;var e=Mt(),t=tI(),n=gh().slack,r=gh().longestPath,a=Jr().alg.preorder,l=Jr().alg.postorder,c=Wn().simplify;Wv=u,u.initLowLimValues=m,u.initCutValues=f,u.calcCutValue=h,u.leaveEdge=w,u.enterEdge=j,u.exchangeEdges=k;function u(E){E=c(E),r(E);var C=t(E);m(C),f(C,E);for(var T,A;T=w(C);)A=j(C,E,T),k(C,E,T,A)}function f(E,C){var T=l(E,E.nodes());T=T.slice(0,T.length-1),e.forEach(T,function(A){p(E,C,A)})}function p(E,C,T){var A=E.node(T),I=A.parent;E.edge(T,I).cutvalue=h(E,C,T)}function h(E,C,T){var A=E.node(T),I=A.parent,B=!0,q=C.edge(T,I),L=0;return q||(B=!1,q=C.edge(I,T)),L=q.weight,e.forEach(C.nodeEdges(T),function(U){var X=U.v===T,Y=X?U.w:U.v;if(Y!==I){var M=X===B,J=C.edge(U).weight;if(L+=M?J:-J,b(E,T,Y)){var V=E.edge(T,Y).cutvalue;L+=M?-V:V}}}),L}function m(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,T,A,I){var B=T,q=E.node(A);return C[A]=!0,e.forEach(E.neighbors(A),function(L){e.has(C,L)||(T=y(E,C,T,L,A))}),q.low=B,q.lim=T++,I?q.parent=I:delete q.parent,T}function w(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function j(E,C,T){var A=T.v,I=T.w;C.hasEdge(A,I)||(A=T.w,I=T.v);var B=E.node(A),q=E.node(I),L=B,U=!1;B.lim>q.lim&&(L=q,U=!0);var X=e.filter(C.edges(),function(Y){return U===N(E,E.node(Y.v),L)&&U!==N(E,E.node(Y.w),L)});return e.minBy(X,function(Y){return n(C,Y)})}function k(E,C,T,A){var I=T.v,B=T.w;E.removeEdge(I,B),E.setEdge(A.v,A.w,{}),m(E),f(E,C),S(E,C)}function S(E,C){var T=e.find(E.nodes(),function(I){return!C.node(I).parent}),A=a(E,T);A=A.slice(1),e.forEach(A,function(I){var B=E.node(I).parent,q=C.edge(I,B),L=!1;q||(q=C.edge(B,I),L=!0),C.node(I).rank=C.node(B).rank+(L?q.minlen:-q.minlen)})}function b(E,C,T){return E.hasEdge(C,T)}function N(E,C,T){return T.low<=C.lim&&C.lim<=T.lim}return Wv}var Vv,_T;function DW(){if(_T)return Vv;_T=1;var e=gh(),t=e.longestPath,n=tI(),r=PW();Vv=a;function a(f){switch(f.graph().ranker){case"network-simplex":u(f);break;case"tight-tree":c(f);break;case"longest-path":l(f);break;default:u(f)}}var l=t;function c(f){t(f),n(f)}function u(f){r(f)}return Vv}var Gv,ST;function FW(){if(ST)return Gv;ST=1;var e=Mt();Gv=t;function t(a){var l=r(a);e.forEach(a.graph().dummyChains,function(c){for(var u=a.node(c),f=u.edgeObj,p=n(a,l,f.v,f.w),h=p.path,m=p.lca,y=0,w=h[y],j=!0;c!==f.w;){if(u=a.node(c),j){for(;(w=h[y])!==m&&a.node(w).maxRank<u.rank;)y++;w===m&&(j=!1)}if(!j){for(;y<h.length-1&&a.node(w=h[y+1]).minRank<=u.rank;)y++;w=h[y]}a.setParent(c,w),c=a.successors(c)[0]}})}function n(a,l,c,u){var f=[],p=[],h=Math.min(l[c].low,l[u].low),m=Math.max(l[c].lim,l[u].lim),y,w;y=c;do y=a.parent(y),f.push(y);while(y&&(l[y].low>h||m>l[y].lim));for(w=y,y=u;(y=a.parent(y))!==w;)p.push(y);return{path:f.concat(p.reverse()),lca:w}}function r(a){var l={},c=0;function u(f){var p=c;e.forEach(a.children(f),u),l[f]={low:p,lim:c++}}return e.forEach(a.children(),u),l}return Gv}var Kv,jT;function qW(){if(jT)return Kv;jT=1;var e=Mt(),t=Wn();Kv={run:n,cleanup:c};function n(u){var f=t.addDummyNode(u,"root",{},"_root"),p=a(u),h=e.max(e.values(p))-1,m=2*h+1;u.graph().nestingRoot=f,e.forEach(u.edges(),function(w){u.edge(w).minlen*=m});var y=l(u)+1;e.forEach(u.children(),function(w){r(u,f,m,y,h,p,w)}),u.graph().nodeRankFactor=m}function r(u,f,p,h,m,y,w){var j=u.children(w);if(!j.length){w!==f&&u.setEdge(f,w,{weight:0,minlen:p});return}var k=t.addBorderNode(u,"_bt"),S=t.addBorderNode(u,"_bb"),b=u.node(w);u.setParent(k,w),b.borderTop=k,u.setParent(S,w),b.borderBottom=S,e.forEach(j,function(N){r(u,f,p,h,m,y,N);var E=u.node(N),C=E.borderTop?E.borderTop:N,T=E.borderBottom?E.borderBottom:N,A=E.borderTop?h:2*h,I=C!==T?1:m-y[w]+1;u.setEdge(k,C,{weight:A,minlen:I,nestingEdge:!0}),u.setEdge(T,S,{weight:A,minlen:I,nestingEdge:!0})}),u.parent(w)||u.setEdge(f,k,{weight:0,minlen:m+y[w]})}function a(u){var f={};function p(h,m){var y=u.children(h);y&&y.length&&e.forEach(y,function(w){p(w,m+1)}),f[h]=m}return e.forEach(u.children(),function(h){p(h,1)}),f}function l(u){return e.reduce(u.edges(),function(f,p){return f+u.edge(p).weight},0)}function c(u){var f=u.graph();u.removeNode(f.nestingRoot),delete f.nestingRoot,e.forEach(u.edges(),function(p){var h=u.edge(p);h.nestingEdge&&u.removeEdge(p)})}return Kv}var Yv,ET;function BW(){if(ET)return Yv;ET=1;var e=Mt(),t=Wn();Yv=n;function n(a){function l(c){var u=a.children(c),f=a.node(c);if(u.length&&e.forEach(u,l),e.has(f,"minRank")){f.borderLeft=[],f.borderRight=[];for(var p=f.minRank,h=f.maxRank+1;p<h;++p)r(a,"borderLeft","_bl",c,f,p),r(a,"borderRight","_br",c,f,p)}}e.forEach(a.children(),l)}function r(a,l,c,u,f,p){var h={width:0,height:0,rank:p,borderType:l},m=f[l][p-1],y=t.addDummyNode(a,"border",h,c);f[l][p]=y,a.setParent(y,u),m&&a.setEdge(m,y,{weight:1})}return Yv}var Xv,CT;function zW(){if(CT)return Xv;CT=1;var e=Mt();Xv={adjust:t,undo:n};function t(p){var h=p.graph().rankdir.toLowerCase();(h==="lr"||h==="rl")&&r(p)}function n(p){var h=p.graph().rankdir.toLowerCase();(h==="bt"||h==="rl")&&l(p),(h==="lr"||h==="rl")&&(u(p),r(p))}function r(p){e.forEach(p.nodes(),function(h){a(p.node(h))}),e.forEach(p.edges(),function(h){a(p.edge(h))})}function a(p){var h=p.width;p.width=p.height,p.height=h}function l(p){e.forEach(p.nodes(),function(h){c(p.node(h))}),e.forEach(p.edges(),function(h){var m=p.edge(h);e.forEach(m.points,c),e.has(m,"y")&&c(m)})}function c(p){p.y=-p.y}function u(p){e.forEach(p.nodes(),function(h){f(p.node(h))}),e.forEach(p.edges(),function(h){var m=p.edge(h);e.forEach(m.points,f),e.has(m,"x")&&f(m)})}function f(p){var h=p.x;p.x=p.y,p.y=h}return Xv}var Zv,TT;function HW(){if(TT)return Zv;TT=1;var e=Mt();Zv=t;function t(n){var r={},a=e.filter(n.nodes(),function(p){return!n.children(p).length}),l=e.max(e.map(a,function(p){return n.node(p).rank})),c=e.map(e.range(l+1),function(){return[]});function u(p){if(!e.has(r,p)){r[p]=!0;var h=n.node(p);c[h.rank].push(p),e.forEach(n.successors(p),u)}}var f=e.sortBy(a,function(p){return n.node(p).rank});return e.forEach(f,u),c}return Zv}var Qv,AT;function UW(){if(AT)return Qv;AT=1;var e=Mt();Qv=t;function t(r,a){for(var l=0,c=1;c<a.length;++c)l+=n(r,a[c-1],a[c]);return l}function n(r,a,l){for(var c=e.zipObject(l,e.map(l,function(y,w){return w})),u=e.flatten(e.map(a,function(y){return e.sortBy(e.map(r.outEdges(y),function(w){return{pos:c[w.w],weight:r.edge(w).weight}}),"pos")}),!0),f=1;f<l.length;)f<<=1;var p=2*f-1;f-=1;var h=e.map(new Array(p),function(){return 0}),m=0;return e.forEach(u.forEach(function(y){var w=y.pos+f;h[w]+=y.weight;for(var j=0;w>0;)w%2&&(j+=h[w+1]),w=w-1>>1,h[w]+=y.weight;m+=y.weight*j})),m}return Qv}var Jv,RT;function WW(){if(RT)return Jv;RT=1;var e=Mt();Jv=t;function t(n,r){return e.map(r,function(a){var l=n.inEdges(a);if(l.length){var c=e.reduce(l,function(u,f){var p=n.edge(f),h=n.node(f.v);return{sum:u.sum+p.weight*h.order,weight:u.weight+p.weight}},{sum:0,weight:0});return{v:a,barycenter:c.sum/c.weight,weight:c.weight}}else return{v:a}})}return Jv}var ex,MT;function VW(){if(MT)return ex;MT=1;var e=Mt();ex=t;function t(a,l){var c={};e.forEach(a,function(f,p){var h=c[f.v]={indegree:0,in:[],out:[],vs:[f.v],i:p};e.isUndefined(f.barycenter)||(h.barycenter=f.barycenter,h.weight=f.weight)}),e.forEach(l.edges(),function(f){var p=c[f.v],h=c[f.w];!e.isUndefined(p)&&!e.isUndefined(h)&&(h.indegree++,p.out.push(c[f.w]))});var u=e.filter(c,function(f){return!f.indegree});return n(u)}function n(a){var l=[];function c(p){return function(h){h.merged||(e.isUndefined(h.barycenter)||e.isUndefined(p.barycenter)||h.barycenter>=p.barycenter)&&r(p,h)}}function u(p){return function(h){h.in.push(p),--h.indegree===0&&a.push(h)}}for(;a.length;){var f=a.pop();l.push(f),e.forEach(f.in.reverse(),c(f)),e.forEach(f.out,u(f))}return e.map(e.filter(l,function(p){return!p.merged}),function(p){return e.pick(p,["vs","i","barycenter","weight"])})}function r(a,l){var c=0,u=0;a.weight&&(c+=a.barycenter*a.weight,u+=a.weight),l.weight&&(c+=l.barycenter*l.weight,u+=l.weight),a.vs=l.vs.concat(a.vs),a.barycenter=c/u,a.weight=u,a.i=Math.min(l.i,a.i),l.merged=!0}return ex}var tx,IT;function GW(){if(IT)return tx;IT=1;var e=Mt(),t=Wn();tx=n;function n(l,c){var u=t.partition(l,function(k){return e.has(k,"barycenter")}),f=u.lhs,p=e.sortBy(u.rhs,function(k){return-k.i}),h=[],m=0,y=0,w=0;f.sort(a(!!c)),w=r(h,p,w),e.forEach(f,function(k){w+=k.vs.length,h.push(k.vs),m+=k.barycenter*k.weight,y+=k.weight,w=r(h,p,w)});var j={vs:e.flatten(h,!0)};return y&&(j.barycenter=m/y,j.weight=y),j}function r(l,c,u){for(var f;c.length&&(f=e.last(c)).i<=u;)c.pop(),l.push(f.vs),u++;return u}function a(l){return function(c,u){return c.barycenter<u.barycenter?-1:c.barycenter>u.barycenter?1:l?u.i-c.i:c.i-u.i}}return tx}var nx,$T;function KW(){if($T)return nx;$T=1;var e=Mt(),t=WW(),n=VW(),r=GW();nx=a;function a(u,f,p,h){var m=u.children(f),y=u.node(f),w=y?y.borderLeft:void 0,j=y?y.borderRight:void 0,k={};w&&(m=e.filter(m,function(T){return T!==w&&T!==j}));var S=t(u,m);e.forEach(S,function(T){if(u.children(T.v).length){var A=a(u,T.v,p,h);k[T.v]=A,e.has(A,"barycenter")&&c(T,A)}});var b=n(S,p);l(b,k);var N=r(b,h);if(w&&(N.vs=e.flatten([w,N.vs,j],!0),u.predecessors(w).length)){var E=u.node(u.predecessors(w)[0]),C=u.node(u.predecessors(j)[0]);e.has(N,"barycenter")||(N.barycenter=0,N.weight=0),N.barycenter=(N.barycenter*N.weight+E.order+C.order)/(N.weight+2),N.weight+=2}return N}function l(u,f){e.forEach(u,function(p){p.vs=e.flatten(p.vs.map(function(h){return f[h]?f[h].vs:h}),!0)})}function c(u,f){e.isUndefined(u.barycenter)?(u.barycenter=f.barycenter,u.weight=f.weight):(u.barycenter=(u.barycenter*u.weight+f.barycenter*f.weight)/(u.weight+f.weight),u.weight+=f.weight)}return nx}var rx,OT;function YW(){if(OT)return rx;OT=1;var e=Mt(),t=Jr().Graph;rx=n;function n(a,l,c){var u=r(a),f=new t({compound:!0}).setGraph({root:u}).setDefaultNodeLabel(function(p){return a.node(p)});return e.forEach(a.nodes(),function(p){var h=a.node(p),m=a.parent(p);(h.rank===l||h.minRank<=l&&l<=h.maxRank)&&(f.setNode(p),f.setParent(p,m||u),e.forEach(a[c](p),function(y){var w=y.v===p?y.w:y.v,j=f.edge(w,p),k=e.isUndefined(j)?0:j.weight;f.setEdge(w,p,{weight:a.edge(y).weight+k})}),e.has(h,"minRank")&&f.setNode(p,{borderLeft:h.borderLeft[l],borderRight:h.borderRight[l]}))}),f}function r(a){for(var l;a.hasNode(l=e.uniqueId("_root")););return l}return rx}var sx,LT;function XW(){if(LT)return sx;LT=1;var e=Mt();sx=t;function t(n,r,a){var l={},c;e.forEach(a,function(u){for(var f=n.parent(u),p,h;f;){if(p=n.parent(f),p?(h=l[p],l[p]=f):(h=c,c=f),h&&h!==f){r.setEdge(h,f);return}f=p}})}return sx}var ax,PT;function ZW(){if(PT)return ax;PT=1;var e=Mt(),t=HW(),n=UW(),r=KW(),a=YW(),l=XW(),c=Jr().Graph,u=Wn();ax=f;function f(y){var w=u.maxRank(y),j=p(y,e.range(1,w+1),"inEdges"),k=p(y,e.range(w-1,-1,-1),"outEdges"),S=t(y);m(y,S);for(var b=Number.POSITIVE_INFINITY,N,E=0,C=0;C<4;++E,++C){h(E%2?j:k,E%4>=2),S=u.buildLayerMatrix(y);var T=n(y,S);T<b&&(C=0,N=e.cloneDeep(S),b=T)}m(y,N)}function p(y,w,j){return e.map(w,function(k){return a(y,k,j)})}function h(y,w){var j=new c;e.forEach(y,function(k){var S=k.graph().root,b=r(k,S,j,w);e.forEach(b.vs,function(N,E){k.node(N).order=E}),l(k,j,b.vs)})}function m(y,w){e.forEach(w,function(j){e.forEach(j,function(k,S){y.node(k).order=S})})}return ax}var ox,DT;function QW(){if(DT)return ox;DT=1;var e=Mt(),t=Jr().Graph,n=Wn();ox={positionX:j,findType1Conflicts:r,findType2Conflicts:a,addConflict:c,hasConflict:u,verticalAlignment:f,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:m,balance:w};function r(b,N){var E={};function C(T,A){var I=0,B=0,q=T.length,L=e.last(A);return e.forEach(A,function(U,X){var Y=l(b,U),M=Y?b.node(Y).order:q;(Y||U===L)&&(e.forEach(A.slice(B,X+1),function(J){e.forEach(b.predecessors(J),function(V){var $=b.node(V),z=$.order;(z<I||M<z)&&!($.dummy&&b.node(J).dummy)&&c(E,V,J)})}),B=X+1,I=M)}),A}return e.reduce(N,C),E}function a(b,N){var E={};function C(A,I,B,q,L){var U;e.forEach(e.range(I,B),function(X){U=A[X],b.node(U).dummy&&e.forEach(b.predecessors(U),function(Y){var M=b.node(Y);M.dummy&&(M.order<q||M.order>L)&&c(E,Y,U)})})}function T(A,I){var B=-1,q,L=0;return e.forEach(I,function(U,X){if(b.node(U).dummy==="border"){var Y=b.predecessors(U);Y.length&&(q=b.node(Y[0]).order,C(I,L,X,B,q),L=X,B=q)}C(I,L,I.length,q,A.length)}),I}return e.reduce(N,T),E}function l(b,N){if(b.node(N).dummy)return e.find(b.predecessors(N),function(E){return b.node(E).dummy})}function c(b,N,E){if(N>E){var C=N;N=E,E=C}var T=b[N];T||(b[N]=T={}),T[E]=!0}function u(b,N,E){if(N>E){var C=N;N=E,E=C}return e.has(b[N],E)}function f(b,N,E,C){var T={},A={},I={};return e.forEach(N,function(B){e.forEach(B,function(q,L){T[q]=q,A[q]=q,I[q]=L})}),e.forEach(N,function(B){var q=-1;e.forEach(B,function(L){var U=C(L);if(U.length){U=e.sortBy(U,function(V){return I[V]});for(var X=(U.length-1)/2,Y=Math.floor(X),M=Math.ceil(X);Y<=M;++Y){var J=U[Y];A[L]===L&&q<I[J]&&!u(E,L,J)&&(A[J]=L,A[L]=T[L]=T[J],q=I[J])}}})}),{root:T,align:A}}function p(b,N,E,C,T){var A={},I=h(b,N,E,T),B=T?"borderLeft":"borderRight";function q(X,Y){for(var M=I.nodes(),J=M.pop(),V={};J;)V[J]?X(J):(V[J]=!0,M.push(J),M=M.concat(Y(J))),J=M.pop()}function L(X){A[X]=I.inEdges(X).reduce(function(Y,M){return Math.max(Y,A[M.v]+I.edge(M))},0)}function U(X){var Y=I.outEdges(X).reduce(function(J,V){return Math.min(J,A[V.w]-I.edge(V))},Number.POSITIVE_INFINITY),M=b.node(X);Y!==Number.POSITIVE_INFINITY&&M.borderType!==B&&(A[X]=Math.max(A[X],Y))}return q(L,I.predecessors.bind(I)),q(U,I.successors.bind(I)),e.forEach(C,function(X){A[X]=A[E[X]]}),A}function h(b,N,E,C){var T=new t,A=b.graph(),I=k(A.nodesep,A.edgesep,C);return e.forEach(N,function(B){var q;e.forEach(B,function(L){var U=E[L];if(T.setNode(U),q){var X=E[q],Y=T.edge(X,U);T.setEdge(X,U,Math.max(I(b,L,q),Y||0))}q=L})}),T}function m(b,N){return e.minBy(e.values(N),function(E){var C=Number.NEGATIVE_INFINITY,T=Number.POSITIVE_INFINITY;return e.forIn(E,function(A,I){var B=S(b,I)/2;C=Math.max(A+B,C),T=Math.min(A-B,T)}),C-T})}function y(b,N){var E=e.values(N),C=e.min(E),T=e.max(E);e.forEach(["u","d"],function(A){e.forEach(["l","r"],function(I){var B=A+I,q=b[B],L;if(q!==N){var U=e.values(q);L=I==="l"?C-e.min(U):T-e.max(U),L&&(b[B]=e.mapValues(q,function(X){return X+L}))}})})}function w(b,N){return e.mapValues(b.ul,function(E,C){if(N)return b[N.toLowerCase()][C];var T=e.sortBy(e.map(b,C));return(T[1]+T[2])/2})}function j(b){var N=n.buildLayerMatrix(b),E=e.merge(r(b,N),a(b,N)),C={},T;e.forEach(["u","d"],function(I){T=I==="u"?N:e.values(N).reverse(),e.forEach(["l","r"],function(B){B==="r"&&(T=e.map(T,function(X){return e.values(X).reverse()}));var q=(I==="u"?b.predecessors:b.successors).bind(b),L=f(b,T,E,q),U=p(b,T,L.root,L.align,B==="r");B==="r"&&(U=e.mapValues(U,function(X){return-X})),C[I+B]=U})});var A=m(b,C);return y(C,A),w(C,b.graph().align)}function k(b,N,E){return function(C,T,A){var I=C.node(T),B=C.node(A),q=0,L;if(q+=I.width/2,e.has(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":L=-I.width/2;break;case"r":L=I.width/2;break}if(L&&(q+=E?L:-L),L=0,q+=(I.dummy?N:b)/2,q+=(B.dummy?N:b)/2,q+=B.width/2,e.has(B,"labelpos"))switch(B.labelpos.toLowerCase()){case"l":L=B.width/2;break;case"r":L=-B.width/2;break}return L&&(q+=E?L:-L),L=0,q}}function S(b,N){return b.node(N).width}return ox}var ix,FT;function JW(){if(FT)return ix;FT=1;var e=Mt(),t=Wn(),n=QW().positionX;ix=r;function r(l){l=t.asNonCompoundGraph(l),a(l),e.forEach(n(l),function(c,u){l.node(u).x=c})}function a(l){var c=t.buildLayerMatrix(l),u=l.graph().ranksep,f=0;e.forEach(c,function(p){var h=e.max(e.map(p,function(m){return l.node(m).height}));e.forEach(p,function(m){l.node(m).y=f+h/2}),f+=h+u})}return ix}var lx,qT;function e7(){if(qT)return lx;qT=1;var e=Mt(),t=OW(),n=LW(),r=DW(),a=Wn().normalizeRanks,l=FW(),c=Wn().removeEmptyRanks,u=qW(),f=BW(),p=zW(),h=ZW(),m=JW(),y=Wn(),w=Jr().Graph;lx=j;function j(H,Q){var O=Q&&Q.debugTiming?y.time:y.notime;O("layout",function(){var te=O(" buildLayoutGraph",function(){return q(H)});O(" runLayout",function(){k(te,O)}),O(" updateInputGraph",function(){S(H,te)})})}function k(H,Q){Q(" makeSpaceForEdgeLabels",function(){L(H)}),Q(" removeSelfEdges",function(){W(H)}),Q(" acyclic",function(){t.run(H)}),Q(" nestingGraph.run",function(){u.run(H)}),Q(" rank",function(){r(y.asNonCompoundGraph(H))}),Q(" injectEdgeLabelProxies",function(){U(H)}),Q(" removeEmptyRanks",function(){c(H)}),Q(" nestingGraph.cleanup",function(){u.cleanup(H)}),Q(" normalizeRanks",function(){a(H)}),Q(" assignRankMinMax",function(){X(H)}),Q(" removeEdgeLabelProxies",function(){Y(H)}),Q(" normalize.run",function(){n.run(H)}),Q(" parentDummyChains",function(){l(H)}),Q(" addBorderSegments",function(){f(H)}),Q(" order",function(){h(H)}),Q(" insertSelfEdges",function(){G(H)}),Q(" adjustCoordinateSystem",function(){p.adjust(H)}),Q(" position",function(){m(H)}),Q(" positionSelfEdges",function(){F(H)}),Q(" removeBorderNodes",function(){z(H)}),Q(" normalize.undo",function(){n.undo(H)}),Q(" fixupEdgeLabelCoords",function(){V(H)}),Q(" undoCoordinateSystem",function(){p.undo(H)}),Q(" translateGraph",function(){M(H)}),Q(" assignNodeIntersects",function(){J(H)}),Q(" reversePoints",function(){$(H)}),Q(" acyclic.undo",function(){t.undo(H)})}function S(H,Q){e.forEach(H.nodes(),function(O){var te=H.node(O),ae=Q.node(O);te&&(te.x=ae.x,te.y=ae.y,Q.children(O).length&&(te.width=ae.width,te.height=ae.height))}),e.forEach(H.edges(),function(O){var te=H.edge(O),ae=Q.edge(O);te.points=ae.points,e.has(ae,"x")&&(te.x=ae.x,te.y=ae.y)}),H.graph().width=Q.graph().width,H.graph().height=Q.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],N={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],C=["width","height"],T={width:0,height:0},A=["minlen","weight","width","height","labeloffset"],I={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},B=["labelpos"];function q(H){var Q=new w({multigraph:!0,compound:!0}),O=de(H.graph());return Q.setGraph(e.merge({},N,K(O,b),e.pick(O,E))),e.forEach(H.nodes(),function(te){var ae=de(H.node(te));Q.setNode(te,e.defaults(K(ae,C),T)),Q.setParent(te,H.parent(te))}),e.forEach(H.edges(),function(te){var ae=de(H.edge(te));Q.setEdge(te,e.merge({},I,K(ae,A),e.pick(ae,B)))}),Q}function L(H){var Q=H.graph();Q.ranksep/=2,e.forEach(H.edges(),function(O){var te=H.edge(O);te.minlen*=2,te.labelpos.toLowerCase()!=="c"&&(Q.rankdir==="TB"||Q.rankdir==="BT"?te.width+=te.labeloffset:te.height+=te.labeloffset)})}function U(H){e.forEach(H.edges(),function(Q){var O=H.edge(Q);if(O.width&&O.height){var te=H.node(Q.v),ae=H.node(Q.w),he={rank:(ae.rank-te.rank)/2+te.rank,e:Q};y.addDummyNode(H,"edge-proxy",he,"_ep")}})}function X(H){var Q=0;e.forEach(H.nodes(),function(O){var te=H.node(O);te.borderTop&&(te.minRank=H.node(te.borderTop).rank,te.maxRank=H.node(te.borderBottom).rank,Q=e.max(Q,te.maxRank))}),H.graph().maxRank=Q}function Y(H){e.forEach(H.nodes(),function(Q){var O=H.node(Q);O.dummy==="edge-proxy"&&(H.edge(O.e).labelRank=O.rank,H.removeNode(Q))})}function M(H){var Q=Number.POSITIVE_INFINITY,O=0,te=Number.POSITIVE_INFINITY,ae=0,he=H.graph(),ge=he.marginx||0,Te=he.marginy||0;function De(Ve){var je=Ve.x,ve=Ve.y,Ue=Ve.width,ke=Ve.height;Q=Math.min(Q,je-Ue/2),O=Math.max(O,je+Ue/2),te=Math.min(te,ve-ke/2),ae=Math.max(ae,ve+ke/2)}e.forEach(H.nodes(),function(Ve){De(H.node(Ve))}),e.forEach(H.edges(),function(Ve){var je=H.edge(Ve);e.has(je,"x")&&De(je)}),Q-=ge,te-=Te,e.forEach(H.nodes(),function(Ve){var je=H.node(Ve);je.x-=Q,je.y-=te}),e.forEach(H.edges(),function(Ve){var je=H.edge(Ve);e.forEach(je.points,function(ve){ve.x-=Q,ve.y-=te}),e.has(je,"x")&&(je.x-=Q),e.has(je,"y")&&(je.y-=te)}),he.width=O-Q+ge,he.height=ae-te+Te}function J(H){e.forEach(H.edges(),function(Q){var O=H.edge(Q),te=H.node(Q.v),ae=H.node(Q.w),he,ge;O.points?(he=O.points[0],ge=O.points[O.points.length-1]):(O.points=[],he=ae,ge=te),O.points.unshift(y.intersectRect(te,he)),O.points.push(y.intersectRect(ae,ge))})}function V(H){e.forEach(H.edges(),function(Q){var O=H.edge(Q);if(e.has(O,"x"))switch((O.labelpos==="l"||O.labelpos==="r")&&(O.width-=O.labeloffset),O.labelpos){case"l":O.x-=O.width/2+O.labeloffset;break;case"r":O.x+=O.width/2+O.labeloffset;break}})}function $(H){e.forEach(H.edges(),function(Q){var O=H.edge(Q);O.reversed&&O.points.reverse()})}function z(H){e.forEach(H.nodes(),function(Q){if(H.children(Q).length){var O=H.node(Q),te=H.node(O.borderTop),ae=H.node(O.borderBottom),he=H.node(e.last(O.borderLeft)),ge=H.node(e.last(O.borderRight));O.width=Math.abs(ge.x-he.x),O.height=Math.abs(ae.y-te.y),O.x=he.x+O.width/2,O.y=te.y+O.height/2}}),e.forEach(H.nodes(),function(Q){H.node(Q).dummy==="border"&&H.removeNode(Q)})}function W(H){e.forEach(H.edges(),function(Q){if(Q.v===Q.w){var O=H.node(Q.v);O.selfEdges||(O.selfEdges=[]),O.selfEdges.push({e:Q,label:H.edge(Q)}),H.removeEdge(Q)}})}function G(H){var Q=y.buildLayerMatrix(H);e.forEach(Q,function(O){var te=0;e.forEach(O,function(ae,he){var ge=H.node(ae);ge.order=he+te,e.forEach(ge.selfEdges,function(Te){y.addDummyNode(H,"selfedge",{width:Te.label.width,height:Te.label.height,rank:ge.rank,order:he+ ++te,e:Te.e,label:Te.label},"_se")}),delete ge.selfEdges})})}function F(H){e.forEach(H.nodes(),function(Q){var O=H.node(Q);if(O.dummy==="selfedge"){var te=H.node(O.e.v),ae=te.x+te.width/2,he=te.y,ge=O.x-ae,Te=te.height/2;H.setEdge(O.e,O.label),H.removeNode(Q),O.label.points=[{x:ae+2*ge/3,y:he-Te},{x:ae+5*ge/6,y:he-Te},{x:ae+ge,y:he},{x:ae+5*ge/6,y:he+Te},{x:ae+2*ge/3,y:he+Te}],O.label.x=O.x,O.label.y=O.y}})}function K(H,Q){return e.mapValues(e.pick(H,Q),Number)}function de(H){var Q={};return e.forEach(H,function(O,te){Q[te.toLowerCase()]=O}),Q}return lx}var cx,BT;function t7(){if(BT)return cx;BT=1;var e=Mt(),t=Wn(),n=Jr().Graph;cx={debugOrdering:r};function r(a){var l=t.buildLayerMatrix(a),c=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(a.nodes(),function(u){c.setNode(u,{label:u}),c.setParent(u,"layer"+a.node(u).rank)}),e.forEach(a.edges(),function(u){c.setEdge(u.v,u.w,{},u.name)}),e.forEach(l,function(u,f){var p="layer"+f;c.setNode(p,{rank:"same"}),e.reduce(u,function(h,m){return c.setEdge(h,m,{style:"invis"}),m})}),c}return cx}var ux,zT;function n7(){return zT||(zT=1,ux="0.8.5"),ux}var dx,HT;function r7(){return HT||(HT=1,dx={graphlib:Jr(),layout:e7(),debug:t7(),util:{time:Wn().time,notime:Wn().notime},version:n7()}),dx}var s7=r7();const UT=d0(s7),Fo=240,zc=130,Yi=74,tf=72,Cc=Yi+tf;function nI(e,t){var r;let n=Fo;for(const a of e)n=Math.max(n,((r=t.get(a.id))==null?void 0:r.width)??Fo);return n}const yh=420,rI=1;function a7(e,t,n,r){return Math.min(rI,n/Math.max(1,e),r/Math.max(1,t))}function qo(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function o7(e,t){return((t==null?void 0:t.get(e))??0)>0?yh:0}function i7(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function Hc(e,t,n){const r=t.get(e);return{w:((r==null?void 0:r.width)??Fo)+o7(e,n),h:Math.max((r==null?void 0:r.height)??zc,i7(e,n))}}function l7(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function c7(e,t,n,r,a,l){const c=new UT.graphlib.Graph;c.setDefaultEdgeLabel(()=>({})),c.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const u=e.filter(b=>!a.has(b)),f=new Set(u);for(const b of u){const{w:N,h:E}=Hc(b,r,l);c.setNode(b,{width:N,height:E})}for(const b of t)f.has(b.source)&&f.has(b.target)&&c.setEdge(b.source,b.target);UT.layout(c);const p=new Map;let h=1/0,m=1/0,y=-1/0,w=-1/0;for(const b of u){const N=c.node(b);if(!N)continue;const E=r.get(b),C=(E==null?void 0:E.width)??Fo,T=(E==null?void 0:E.height)??zc,A=Hc(b,r,l),I=N.x-A.w/2,B=N.y-A.h/2;p.set(b,{x:I,y:B}),I<h&&(h=I),B<m&&(m=B),I+C>y&&(y=I+C),B+T>w&&(w=B+T)}if(Number.isFinite(h)&&Number.isFinite(m))for(const[b,N]of p)p.set(b,{x:N.x-h,y:N.y-m});const j=Number.isFinite(y)?y-h:0,k=Number.isFinite(w)?w-m:0;let S=null;for(const b of e){const N=a.get(b);if(!N)continue;const E=r.get(b),C=(E==null?void 0:E.width)??Fo,T=(E==null?void 0:E.height)??zc;S=S===null?{minX:N.x,minY:N.y,maxX:N.x+C,maxY:N.y+T}:{minX:Math.min(S.minX,N.x),minY:Math.min(S.minY,N.y),maxX:Math.max(S.maxX,N.x+C),maxY:Math.max(S.maxY,N.y+T)}}return{positions:p,width:j,height:k,pinnedBox:S}}function sI(e,t,n){const r=n.direction??"LR",a=n.pinned??new Map,l=n.measured??new Map,c=n.lanes,u=new Map;for(const h of e){const m=qo(h),y=u.get(m);y?y.push(h.id):u.set(m,[h.id])}return{laid:Array.from(u.keys()).sort().map(h=>({sid:h,...c7(u.get(h),t,r,l,a,c)})),gap:nI(e,l)}}const aI=e=>e.reduce((t,n)=>Math.max(t,n.width),0)+yh,u7=e=>e.reduce((t,n)=>t+n.height,0)+Cc*Math.max(0,e.length-1);function t0(e,t,n,r){const a=f=>{const p=[[]];let h=0;for(const m of e)h>0&&h+m.height>f&&(p.push([]),h=0),p[p.length-1].push(m),h+=m.height+Cc;return p},l=[];for(let f=0;f<e.length;f++){let p=-Cc;for(let h=f;h<e.length;h++)l.push(p+=e[h].height+Cc)}l.sort((f,p)=>f-p);const c=f=>{let p=0,h=l.length-1;for(;p<h;){const m=p+h>>1;a(l[m]).length<=f?h=m:p=m+1}return a(l[p])};let u=[e];if(n>0&&r>0){const f=h=>a7(h.reduce((m,y)=>m+aI(y),0)+t*(h.length-1),Math.max(...h.map(u7)),n,r);let p=f(u);for(let h=2;h<=e.length;h++){const m=c(h),y=f(m);y>p+1e-9&&(p=y,u=m)}}return u}function d7(e,t,n,r,a){if(!(r.width>0&&r.height>0&&a.width>0&&a.height>0))return!1;const{laid:l,gap:c}=sI(e,t,n);return l.length<2?!1:t0(l,c,r.width,r.height).length!==t0(l,c,a.width,a.height).length}function h7(e,t,n={}){const r=n.pinned??new Map,{laid:a,gap:l}=sI(e,t,n),c=t0(a,l,n.availableWidth??0,n.availableHeight??0),u=new Map;let f=0;for(const p of c){const h=aI(p);let m=0;for(const{positions:y,height:w,pinnedBox:j}of p){for(const[S,b]of y)u.set(S,{x:b.x+f,y:b.y+m});let k=m+w;j&&j.maxY>k&&j.minX<f+h&&f<j.maxX&&(k=j.maxY),m=k+Cc}f+=h+l}return e.map(p=>{const h=r.get(p.id);if(h)return{...p,position:h};const m=u.get(p.id);return m?{...p,position:m}:p})}function f7(e,t,n,r,a){const c=Yi+tf,u=60,f=w=>Hc(w,r,a),p=new Map(e.map(w=>[w.id,qo(w)])),h=[],m=e.map(w=>({id:w.id,pos:n.get(w.id)??t.get(w.id)})).filter(w=>w.pos!=null).sort((w,j)=>w.pos.y-j.pos.y||w.pos.x-j.pos.x||w.id.localeCompare(j.id)),y=[];for(const{id:w,pos:j}of m){const{w:k,h:S}=f(w),b=p.get(w)??"_default";if(n.has(w)){h.push({x:j.x,y:j.y,w:k,h:S,sid:b});continue}let N=j.y;for(let E=0;E<h.length+1;E++){const C=h.find(T=>{const A=T.sid===b?24:u,I=T.sid===b?24:c;return j.x<T.x+T.w+A&&T.x<j.x+k+A&&N<T.y+T.h+I&&T.y<N+S+I});if(!C)break;N=C.y+C.h+(C.sid===b?24:c)}N!==j.y&&(t.set(w,{x:j.x,y:N}),y.push(w)),h.push({x:j.x,y:N,w:k,h:S,sid:b})}return y}function p7(e,t,n,r,a,l,c){const u=E=>Hc(E,r,l),f=E=>n.get(E)??t.get(E),p=E=>{const C=r.get(E);return{cw:(C==null?void 0:C.width)??Fo,ch:(C==null?void 0:C.height)??zc}},h=c!=null&&c.width>0&&c.height>0,m=new Map;for(const E of e){if(!f(E.id))continue;const C=qo(E),T=m.get(C);T?T.push(E):m.set(C,[E])}const y=new Set;for(const[E,C]of m)C.every(T=>a.has(T.id)&&!n.has(T.id))&&y.add(E);const w=new Map,j=[];for(const E of e){const C=f(E.id);if(!C)continue;const{w:T,h:A}=u(E.id),I=qo(E);y.has(I)?(w.get(I)??w.set(I,[]).get(I)).push(E):j.push({x:C.x,y:C.y,w:T,h:A,...p(E.id)})}if(w.size===0||h&&j.length===0)return[];const k=Yi+tf,S=(E,C,T,A)=>j.some(I=>E<I.x+I.w+Yi&&I.x<E+T+Yi&&C<I.y+I.h+k&&I.y<C+A+k),b=nI(e,r),N=[];for(const E of[...w.keys()].sort()){const C=w.get(E);let T=1/0,A=1/0,I=-1/0,B=-1/0,q=-1/0,L=-1/0;for(const $ of C){const z=f($.id),{w:W,h:G}=u($.id),{cw:F,ch:K}=p($.id);T=Math.min(T,z.x),A=Math.min(A,z.y),I=Math.max(I,z.x+W),B=Math.max(B,z.y+G),q=Math.max(q,z.x+F),L=Math.max(L,z.y+K)}const U=I-T,X=B-A,Y=[...new Set(j.map($=>Math.round($.x)))].sort(($,z)=>$-z),M=Y.length?Y:[T],J=[0,...j.map($=>$.y+$.h+k)].sort(($,z)=>$-z);let V=null;if(h){let $=1/0,z=1/0,W=-1/0,G=-1/0;for(const O of j)$=Math.min($,O.x),z=Math.min(z,O.y),W=Math.max(W,O.x+O.cw),G=Math.max(G,O.y+O.ch);const F=(O,te)=>{const ae=c.width/(Math.max(W,O+q-T)-Math.min($,O)+yh),he=c.height/(Math.max(G,te+L-A)-Math.min(z,te));return[Math.min(rI,ae,he),Math.min(ae,he),Math.max(ae,he)]},K=(O,te)=>{for(let ae=0;ae<O.length;ae++){if(O[ae]>te[ae]+1e-9)return!0;if(O[ae]<te[ae]-1e-9)return!1}return!1},de=Math.round(W+yh+b),H=[...new Set([...J,z])].sort((O,te)=>O-te);let Q=null;for(const O of[...M,de])for(const te of H){if(S(O,te,U,X))continue;const ae=F(O,te);(Q===null||K(ae,Q))&&(Q=ae,V={x:O,y:te})}V&&V.x===T&&V.y===A&&(V=null)}else e:for(const $ of M)for(const z of J){if(z>=A)break;if(!S($,z,U,X)){V={x:$,y:z};break e}}if(V){const $=V.x-T,z=V.y-A;for(const W of C){const G=f(W.id);t.set(W.id,{x:G.x+$,y:G.y+z})}N.push(E)}for(const $ of C){const z=f($.id),{w:W,h:G}=u($.id);j.push({x:z.x,y:z.y,w:W,h:G,...p($.id)})}}return N}function m7(e,t,n){const r=new Map;for(const a of e){if(t.has(a.id)||!n(a.id))continue;const l=qo(a);(r.get(l)??r.set(l,[]).get(l)).push(a)}if(r.size===0)return e;for(const a of r.values())a.sort((l,c)=>l.id.localeCompare(c.id));return e.map(a=>{var p;if(t.has(a.id)||n(a.id))return a;const l=r.get(qo(a));if(!l)return a;const c=(p=a.data)==null?void 0:p.parentId,u=l.find(h=>h.id===c)??l[0],f=n(u.id);return{...a,position:{x:a.position.x+f.x-u.position.x,y:a.position.y+f.y-u.position.y}}})}function g7(e,t,n,r,a,l=!1,c){const p=Yi+tf+1,h=8,m=1.75,y=200,w=.7,j=.01,k=L=>Hc(L,r,c),S=L=>n.get(L)??t.get(L),b=new Map;for(const L of e){if(!S(L.id))continue;const U=qo(L),X=b.get(U);X?X.push(L):b.set(U,[L])}const N=[],E=new Set,C=new Set,T=a.size===0;for(const L of[...b.keys()].sort()){const U=b.get(L);let X=1/0,Y=1/0,M=-1/0,J=-1/0,V=!1;for(const G of U){const F=S(G.id),{w:K,h:de}=k(G.id);X=Math.min(X,F.x),Y=Math.min(Y,F.y),M=Math.max(M,F.x+K),J=Math.max(J,F.y+de),n.has(G.id)&&(V=!0)}const $=M-X,z=J-Y;C.add(L);const W=a.get(L);W&&($>W.w+h||z>W.h+h)&&E.add(L),a.set(L,{w:$,h:z}),N.push({sid:L,members:U.map(G=>G.id),x:X,y:Y,w:$,h:z,anchored:V,mass:1})}for(const L of[...a.keys()])C.has(L)||a.delete(L);if(l||T)return[];let A=!1;for(let L=0;L<N.length&&!A;L++)for(let U=L+1;U<N.length;U++){const X=N[L],Y=N[U];if(!(X.anchored&&Y.anchored)&&Math.abs(X.x+X.w/2-(Y.x+Y.w/2))<(X.w+Y.w)/2+61&&Math.abs(X.y+X.h/2-(Y.y+Y.h/2))<(X.h+Y.h)/2+p){A=!0;break}}if(E.size===0&&!A)return[];if(E.size>0)for(const L of N)E.has(L.sid)&&(L.mass=8);else for(const L of N)L.mass=Math.max(1,L.w*L.h/(Fo*zc));const I=new Map(N.map(L=>[L.sid,L.x])),B=new Map(N.map(L=>[L.sid,L.y]));for(let L=0;L<y;L++){const U=new Map,X=new Map;let Y=0;for(let M=0;M<N.length;M++)for(let J=M+1;J<N.length;J++){const V=N[M],$=N[J];if(V.anchored&&$.anchored)continue;const z=V.x+V.w/2,W=V.y+V.h/2,G=$.x+$.w/2,F=$.y+$.h/2,K=(V.w+$.w)/2+61-Math.abs(z-G),de=(V.h+$.h)/2+p-Math.abs(W-F);if(K<=0||de<=0)continue;const H=(_e,Ie)=>!_e.anchored&&!(Ie<0&&_e.x<=0),Q=(_e,Ie)=>!_e.anchored&&!(Ie<0&&_e.y<=0),O=(_e,Ie,Ze)=>{const We=_e===Ie,Je=We?V.sid<$.sid?-1:1:Math.sign(_e-Ie);return Ze(V,Je)||Ze($,-Je)?Je:We&&(Ze(V,-Je)||Ze($,Je))?-Je:0},te=O(z,G,H),ae=O(W,F,Q),he=te!==0,ge=ae!==0;if(!he&&!ge)continue;const Te=he&&(!ge||K*m<de),[De,Ve,je,ve]=Te?[te,K,U,H]:[ae,de,X,Q],Ue=ve(V,De),ke=ve($,-De),xe=V.mass,Ge=$.mass,rt=Ue?ke?Ge/(xe+Ge):1:0,at=ke?Ue?xe/(xe+Ge):1:0,le=Ve*w;je.set(V.sid,(je.get(V.sid)??0)+De*le*rt),je.set($.sid,(je.get($.sid)??0)-De*le*at),Y+=le}for(const M of N)M.anchored||(M.x=Math.max(0,M.x+(U.get(M.sid)??0)),M.y=Math.max(0,M.y+(X.get(M.sid)??0)));if(Y<j)break}const q=[];for(const L of N){const U=L.x-I.get(L.sid),X=L.y-B.get(L.sid);if(!(Math.abs(U)<1&&Math.abs(X)<1)){for(const Y of L.members){if(n.has(Y))continue;const M=t.get(Y);M&&t.set(Y,{x:M.x+U,y:M.y+X})}q.push(L.sid)}}return q}function Zd(e,t,n){return!t.has(e)||n.has(e)}function y7(e,t,n,r){return!t.has(e)&&Zd(e,n,r)}function w7(e,t,n){const r={x:0,y:0};return t.set(e,r),n.add(e),r}function WT(e,t,n,r){n.set(e,t),r.delete(e)}const v7=200,x7=5*6e4,b7=6,k7=2*6e4;function Od(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function N7(e,t){let n=!1;for(const a of e)if(!t.has(a)){n=!0;break}if(!n)return e;const r=new Set;for(const a of e)t.has(a)&&r.add(a);return r}function _7(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(L0(n.id));return t}function S7(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(L0(n.id));return t}function j7(e,t){let n=iD(e,t,iN);lD(e,t,iN)&&(n=!0);const r=[],a=l=>{r.push(l)};return rD(e,t,v7,x7,a)&&(n=!0),sD(e,t,b7,k7,a)&&(n=!0),{changed:n,forgotten:r}}const E7=300,VT=130,C7=160,GT=new WeakMap;function T7(e,t){let n=GT.get(e);(!n||n.revision!==e.revision||n.open!==t)&&(n={revision:e.revision,open:t,byId:new Map,branches:g6(e.agents.values())},GT.set(e,n));const{byId:r,branches:a}=n;return l=>{let c=r.get(l.id);if(!c){const u=l.kind==="root"?a.get(l.sessionId):void 0;c=u?{...l,onOpenContext:t,branch:u}:{...l,onOpenContext:t},r.set(l.id,c)}return c}}function n0(e){const t=new Map;for(const n of e.agents.values())n.tools.length>0&&t.set(n.id,Math.min(4,n.tools.length));return t}function A7(e,t,n,r,a,l,c,u,f,p,h,m,y,w,j,k,S,b){var Y,M,J,V;const N=[],E=[],C=T7(e,b);for(const $ of e.agents.values()){if(!S.has($.id))continue;const z=$.exitAt!=null,W=k!=null&&!k.has($.id),G=[z?"rf-exiting":"",W?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,F=l.get($.id);if(N.push({id:$.id,type:"agent",position:{x:0,y:0},data:C($),className:G,ariaLabel:oF($,t),...F?{width:F.width,height:F.height}:null}),$.parentId&&S.has($.parentId)){const H=lh($.sessionId),Q=z,O=j.size>0&&(j.has($.id)||j.has($.parentId)),te=k!=null&&!k.has($.id)&&!k.has($.parentId),ae=$.state==="active"?2:1.5,he=O?ae+1.5:ae,ge=Q?.2:te?.12:1,Te=["sess-edge",$.state==="active"?"sess-live":"sess-idle",Q?"rf-edge-exiting":"",O?"rf-edge-selected":""].filter(Boolean).join(" ");E.push({id:`e:${$.parentId}->${$.id}`,source:$.parentId,target:$.id,animated:($.state==="active"||O)&&!Q,type:"smoothstep",style:{"--session-hue":H,strokeWidth:`calc(${he}px * var(--edge-k, 1))`,opacity:ge,transition:"var(--edge-transition)"},className:Te})}const K=$.kind==="root"?Ih($):null,de=K?wR($.sessionId,K.at):null;if(K&&de&&!u6(de)){const H=L0($.id),Q=lh($.sessionId),O=l.get(H);N.push({id:H,type:"recapNote",position:{x:0,y:0},data:{sessionId:$.sessionId,parentId:$.id,recap:K,noteKey:de,hue:Q},className:W?"rf-spotlit-out":void 0,selectable:!1,focusable:!1,ariaLabel:`Claude Code's recap for ${$.label}`,...O?{width:O.width,height:O.height}:null}),E.push({id:`e:recap:${$.id}`,source:H,target:$.id,type:"recapTie",className:"recap-edge",focusable:!1,style:{"--session-hue":Q}})}}const T=n0(e),A=`${y}#lanes:${l7(T)}`,I=new Set(N.filter($=>$.type==="recapNote").map($=>$.id));for(const $ of Array.from(h.keys()))p6($)&&!I.has($)&&!a.has($)&&(h.delete($),m.delete($));const B=N.filter($=>y7($.id,a,h,m));if(B.length>0||A!==w.current){if(B.length>0){const $=m7(h7(N,E,{direction:"LR",pinned:a,measured:l,availableWidth:n,availableHeight:r,lanes:T}),a,z=>Zd(z,h,m)?void 0:h.get(z));for(const z of $)Zd(z.id,h,m)&&WT(z.id,z.position,h,m);p7(N,h,a,l,new Set(B.filter(z=>z.type!=="recapNote").map(z=>z.id)),T,{width:n,height:r});for(const z of B){if(z.type!=="recapNote")continue;const W=(Y=z.data)==null?void 0:Y.parentId;if(!W)continue;const G=a.get(W)??(Zd(W,h,m)?void 0:h.get(W));if(!G)continue;const F=((M=l.get(z.id))==null?void 0:M.width)??E7,K=((J=l.get(z.id))==null?void 0:J.height)??VT,de=((V=l.get(W))==null?void 0:V.height)??VT;WT(z.id,{x:G.x-C7-F,y:G.y+(de-K)/2},h,m)}}f7(N,h,a,l,T),w.current=A}const q=g7(N,h,a,l,c,!f||p,T);q.length>0&&u(q);const L=S7(e.agents.values());Od(h,L),Od(m,L),Od(a,L),Od(l,_7(e.agents.values()));const U=[];let X=!1;for(const $ of N){let z=a.get($.id)??h.get($.id);z||(z=w7($.id,h,m),X=!0),U.push({...$,position:z})}return X&&(w.current=""),{nodes:U,edges:E}}const R7=1;function M7(e){return{id:e.id,name:e.name,inputPreview:e.inputPreview,startedAt:e.startedAt,endedAt:e.endedAt,ok:e.ok,errorPreview:e.errorPreview,usage:e.usage}}function I7(e,t,n){const r=e.agents.get(t);if(!r)return null;const a=[];for(const l of e.agents.values())l.sessionId===t&&a.push(l);return{schemaVersion:R7,exportedAt:n,sessionId:t,label:r.label,cwd:r.cwd,startedAt:r.startedAt,endedAt:r.endedAt,model:r.model,agents:a.map(l=>({id:l.id,kind:l.kind,label:l.label,parentId:l.parentId,state:l.state,startedAt:l.startedAt,endedAt:l.endedAt,model:l.model,cwd:l.cwd,usage:l.usage,prompts:l.prompts,tools:l.tools.map(M7)}))}}function $7(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${nn}-${n}-${t.slice(0,8)}.json`}function O7(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function L7(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.decks!="number"||typeof t.mine!="boolean")return null;const n=t.owner&&typeof t.owner=="object"?t.owner.port:null;return{path:typeof t.path=="string"&&t.path!==""?t.path:null,decks:t.decks,mine:t.mine,ownerPort:typeof n=="number"?n:null}}function P7(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function D7(e,t){const n=P7(e),r=(...c)=>[n?`${n} on the canvas`:null,...c,"layout, pins and selection"].filter(u=>u!==null),a="This cannot be undone.";if(!t)return{goes:r("the event log on disk — the file a restarted deck replays to rebuild what you see, and the file every deck on this machine shares unless one was told otherwise"),stays:[],final:a,confirm:"Clear everything"};if(!t.path)return{goes:r(),stays:[],final:`This deck keeps no event log, so nothing on disk changes — and nothing can bring the canvas back. ${a}`,confirm:"Clear everything"};if(!t.mine){const c=t.ownerPort===null?"another running deck owns that file":`the deck on port ${t.ownerPort} owns that file`,u=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{goes:r(),stays:[`the event log — ${c}${u}`,"restart this deck and the log replays back onto it"],final:null,confirm:"Clear this canvas"}}if(t.decks<=1)return{goes:r("this deck's event log — the file a restarted deck replays to rebuild what you see"),stays:[],final:a,confirm:"Clear everything"};const l=t.decks-1;return{goes:r(`the event log ${l===1?"1 other running deck shares":`${l} other running decks share`} with this one — every session recorded in it, not just the ones drawn here`),stays:[l===1?"what that deck shows, until it restarts — then it is gone there too":"what those decks show, until they restart — then it is gone there too"],final:a,confirm:"Clear everything"}}function F7({agentCount:e,onConfirm:t,onCancel:n}){const r=x.useRef(null),a=sn(n,{focusRef:r,layer:PD}),[l,c]=x.useState(null);x.useEffect(()=>{let m=!1;return fetch("/api/clear").then(y=>y.ok?y.json():null).then(y=>{m||c(L7(y))}).catch(()=>{}),()=>{m=!0}},[]);const{goes:u,stays:f,final:p,confirm:h}=D7(e,l);return o.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:o.jsxs("div",{ref:a,className:"modal clear-confirm",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[o.jsxs("header",{className:"modal-head",children:[o.jsxs("div",{className:"modal-title",children:[o.jsx("span",{className:"status-dot err","aria-hidden":!0}),o.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body",children:[o.jsxs("dl",{className:"cc-plan",children:[o.jsx("dt",{children:"Goes"}),o.jsx("dd",{children:u.map(m=>o.jsx("span",{children:m},m))}),o.jsx("dt",{children:"Stays"}),o.jsx("dd",{children:f.length>0?f.map(m=>o.jsx("span",{children:m},m)):o.jsx("span",{children:"nothing"})})]}),p&&o.jsx("p",{className:"cc-final",children:p}),o.jsxs("div",{className:"cc-actions",children:[o.jsx("button",{type:"button",ref:r,className:"btn",onClick:n,children:"Cancel"}),o.jsx("button",{type:"button",className:"btn danger",onClick:t,children:h})]})]})]})})}const q7="Press Esc first if a key does nothing.",B7=[{title:"Canvas",rows:[{cap:"Space",action:"pause or resume the stream",binds:[" "]},{cap:"J",action:"next agent",binds:["j","J"]},{cap:"K",action:"previous agent",binds:["k","K"]},{cap:"W",action:"the session waiting on you — oldest first, again for the next",binds:["w","W"]},{cap:"F",action:"fit every agent on screen",binds:["f","F"]},{cap:"Z",action:"zoom to the selected agent and its session",binds:["z","Z"]},{cap:"R",action:"re-arrange the canvas and drop the pins",binds:["r","R"]},{cap:"C",action:"clear the canvas and the event log — asks first",binds:["c","C"]}]},{title:"Panels and dialogs",rows:[{cap:"U",action:"usage panel",binds:["u","U"]},{cap:"L",action:"session list",binds:["l","L"]},{cap:"D",action:"detail panel",binds:["d","D"]},{cap:"H",action:"usage history",binds:["h","H"]},{cap:"A",action:"Claude accounts, where Claude Code is installed",binds:["a","A"]},{cap:"S",action:"this machine — cores, memory, temperature",binds:["s","S"]},{cap:"B",action:"Browser Watch",binds:["b","B"]},{cap:"V",action:"the sound menu — volume, tones, notifications",binds:["v","V"]},{cap:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"M",action:"sound on or off",binds:["m","M"]},{cap:"T",action:"light or dark theme",binds:["t","T"]}]},{title:"Focus and selection",rows:[{cap:"Tab",action:"reach the agent cards",binds:[]},{cap:"Enter",action:"select the focused card",binds:["Enter"]},{cap:"Shift + Enter",action:"add the focused card to the selection",binds:["Enter"]},{cap:"Esc",action:"close what is open, deselect, release focus",binds:["Escape"]}]},{title:"Mouse",rows:[{cap:"drag",action:"move a node, and pin it where you dropped it",binds:[]},{cap:"shift-click",action:"add an agent to the selection",binds:[]},{cap:"click",action:"a card: go to it and its session",binds:[]},{cap:"double-click",action:"a card: its prompt, every tool call, tokens and timing",binds:[]},{cap:"hover",action:"zoomed out, a card's name, state and numbers",binds:[]},{cap:"click",action:"the topbar speaker opens volume and sound settings",binds:[]}]}];function z7({onClose:e,onTour:t}){const n=sn(e);return o.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:o.jsxs("div",{ref:n,className:"modal key-help",onClick:r=>r.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title",children:[o.jsxs("header",{className:"modal-head",children:[o.jsx("div",{className:"modal-title",children:o.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body",children:[t&&o.jsxs("div",{className:"guide-door",children:[o.jsx("span",{children:"Eight pictures of what the deck shows."}),o.jsx("button",{type:"button",className:"btn",onClick:t,children:"Take the tour"})]}),o.jsx("div",{className:"shortcuts",children:B7.map(r=>o.jsxs(x.Fragment,{children:[o.jsx("h3",{className:"kh-group",children:r.title}),r.rows.map(a=>o.jsxs("div",{className:"sc",children:[o.jsx("kbd",{children:a.cap}),o.jsx("span",{children:a.action})]},`${r.title}:${a.cap}:${a.action}`))]},r.title))}),o.jsx("p",{className:"kh-foot",children:q7})]})]})})}const H7=["done","needs-input"],U7=[{id:"two",label:"Two notes",notes:[{at:0,hz:740,ms:90},{at:.085,hz:440,ms:150}]},{id:"arc",label:"Descent",notes:[{at:0,hz:988,ms:80},{at:.07,hz:659,ms:80},{at:.14,hz:440,ms:160}]},{id:"tap",label:"Double tap",notes:[{at:0,hz:740,ms:55},{at:.055,hz:740,ms:55},{at:.165,hz:440,ms:150}]},{id:"chord",label:"Chord",trim:.7,notes:[{at:0,hz:988,ms:110},{at:0,hz:740,ms:110},{at:.1,hz:440,ms:170}]},{id:"bell",label:"Bell",type:"triangle",notes:[{at:0,hz:740,ms:120},{at:.11,hz:440,ms:260}]},{id:"blip",label:"Blip",type:"square",trim:.7,notes:[{at:0,hz:740,ms:55},{at:.06,hz:440,ms:90}]}],W7=[{id:"two",label:"Two notes",notes:[{at:0,hz:440,ms:90},{at:.085,hz:740,ms:150}]},{id:"arc",label:"Ascent",notes:[{at:0,hz:440,ms:80},{at:.07,hz:659,ms:80},{at:.14,hz:988,ms:160}]},{id:"tap",label:"Double tap",notes:[{at:0,hz:440,ms:55},{at:.055,hz:440,ms:55},{at:.165,hz:740,ms:150}]},{id:"chord",label:"Chord",trim:.7,notes:[{at:0,hz:440,ms:110},{at:.1,hz:740,ms:170},{at:.1,hz:988,ms:170}]},{id:"bell",label:"Bell",type:"triangle",notes:[{at:0,hz:440,ms:120},{at:.11,hz:740,ms:260}]},{id:"blip",label:"Blip",type:"square",trim:.7,notes:[{at:0,hz:440,ms:55},{at:.06,hz:740,ms:90}]}],pb={done:U7,"needs-input":W7},al="two";function r0(e,t){const n=pb[e];return n.find(r=>r.id===t)??n.find(r=>r.id===al)??n[0]}function oI(e,t){return pb[e].some(r=>r.id===t)?t:al}r0("done",al).notes,r0("needs-input",al).notes;const KT=.04,V7=.24,Mo=0,ol=100,wh=5,Uc=50;function Wc(e){if(!Number.isFinite(e))return Uc;const t=Math.round(e/wh)*wh;return Math.min(ol,Math.max(Mo,t))}function iI(e){if(e==null)return Uc;const t=e.trim();return/^-?\d+(\.\d+)?$/.test(t)?Wc(Number(t)):Uc}function G7(e){const t=Wc(e),n=KT+(V7-KT)*(t/ol);return Math.round(n*1e4)/1e4}function K7(e,t){const n=t.trim,r=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(G7(e)*r*1e4)/1e4}const Y7=160,X7="agent-dag.soundLevel.done",Z7="agent-dag.soundLevel.needs-input",Q7="agent-dag.soundFigure.done",J7="agent-dag.soundFigure.needs-input",lI={done:X7,"needs-input":Z7},cI={done:Q7,"needs-input":J7},s0={done:{level:Uc,figure:al},"needs-input":{level:Uc,figure:al}};function e9(e){const t=n=>({level:iI(e(lI[n])),figure:oI(n,e(cI[n]))});return{done:t("done"),"needs-input":t("needs-input")}}const YT={Stop:"done",Notification:"needs-input"};function t9(e,t){var r;if(t)return null;const n=(r=e==null?void 0:e.payload)==null?void 0:r.hook_event_name;return typeof n!="string"?null:Object.hasOwn(YT,n)?YT[n]:null}function n9(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null,r=!1;const a=()=>e.enabled()?r&&(n==null?void 0:n.state)==="running"?"ready":"locked":"off",l=()=>{var f;return(f=e.onState)==null?void 0:f.call(e,a())};function c(){var f;if(!(!t||r))try{n=n??new t,(f=n.resume)==null||f.call(n).then(l,()=>{}),r=!0,l()}catch{}}function u(f,p=!1){var j;if(!p&&!e.enabled()||!n||n.state!=="running")return!1;const h=(((j=e.prefs)==null?void 0:j.call(e))??s0)[f]??s0[f],m=r0(f,h.figure),y=K7(h.level,m),w=n.currentTime;for(const k of m.notes){const S=n.createOscillator(),b=n.createGain();S.type=m.type??"sine",S.frequency.value=k.hz;const N=w+k.at,E=N+k.ms/1e3;b.gain.setValueAtTime(1e-4,N),b.gain.exponentialRampToValueAtTime(y,N+.012),b.gain.exponentialRampToValueAtTime(1e-4,E),S.connect(b).connect(n.destination),S.start(N),S.stop(E+.02)}return!0}return{unlock:c,play:u,state:a,get context(){return n}}}const r9="With no deck tab open, get a notification wherever a sound would have played.",s9="With the ccdeck window closed, get a notification wherever a sound would have played.";function a9(e){return e?s9:r9}const o9="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",XT="Get notified when you're away from this tab.";function i9(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:XT};case"default":return{status:null,ask:!0,ok:!1,note:XT};case"denied":return{status:"Blocked",ask:!1,ok:!1,note:"Your browser is blocking them; only its own site settings can undo that. You'll still be told once this tab is closed."};default:return{status:"Unavailable",ask:!1,ok:!1,note:"This browser cannot show them. You'll still be told once this tab is closed."}}}function l9(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}const ZT={done:"Turn finished","needs-input":"Claude is asking"},c9={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function u9({onClose:e,soundOn:t,onToggleSound:n,prefs:r,onLevel:a,onFigure:l,onPreview:c,openerRef:u,notifyOn:f,onToggleNotify:p,notifyVetoed:h,notifyPermission:m,onAskNotify:y}){const w=i9(m),j=l9(),k=f&&!h&&!j,S=sn(e,{popover:!0}),b=x.useRef(e);return b.current=e,x.useEffect(()=>{const N=E=>{var T,A;const C=E.target;C&&((T=S.current)!=null&&T.contains(C)||(A=u.current)!=null&&A.contains(C)||b.current())};return window.addEventListener("pointerdown",N,!0),()=>window.removeEventListener("pointerdown",N,!0)},[S,u]),o.jsxs("div",{ref:S,id:"sound-menu",className:"sound-menu",role:"dialog","aria-label":"Sound settings",children:[o.jsxs("div",{className:"sm-switches",children:[o.jsxs("label",{className:"sm-switch",children:[o.jsx("span",{className:"sm-switch-label",id:"sm-sound-label",children:"Sounds"}),o.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-labelledby":"sm-sound-label",className:"switch",onClick:n,title:"A tone when a turn finishes, and when Claude asks for something",children:o.jsx("span",{className:"switch-knob"})})]}),o.jsxs("div",{className:"sm-setting",children:[o.jsxs("label",{className:"sm-switch",children:[o.jsx("span",{className:"sm-switch-label",id:"sm-notify-label",children:"Notifications while closed"}),o.jsx("button",{type:"button",role:"switch","aria-checked":f,"aria-labelledby":"sm-notify-label",className:"switch",onClick:p,title:"With no deck tab open, a notification wherever a sound would play",children:o.jsx("span",{className:"switch-knob"})})]}),o.jsx("p",{className:"sm-note",children:h?o9:a9(j)})]})]}),k&&o.jsxs("section",{className:"sm-channel","aria-labelledby":"sm-channel-name",children:[o.jsxs("div",{className:"sm-channel-head",children:[o.jsx("h3",{className:"sm-channel-name",id:"sm-channel-name",children:"Browser notifications"}),w.ask?o.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:y,children:"Enable"}):o.jsxs("span",{className:"sm-channel-state","data-ok":w.ok||void 0,children:[w.ok&&o.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:o.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),w.status]})]}),o.jsx("p",{className:"sm-note",children:w.note})]}),!t&&o.jsx("span",{id:"sm-preview-note",className:"vis-hidden",children:"Plays even when Sounds is off, so you can set a tone before turning sounds back on."}),o.jsx("div",{className:"sm-tones",children:H7.map(N=>{const E=r[N],C=`sm-level-${N}`,T=`sm-figure-${N}`;return o.jsxs("section",{className:"sm-tone","aria-labelledby":`sm-name-${N}`,children:[o.jsxs("div",{className:"sm-tone-head",children:[o.jsx("h3",{className:"sm-tone-name",id:`sm-name-${N}`,children:ZT[N]}),o.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(N),"aria-label":`Hear the ${ZT[N].toLowerCase()} tone`,title:t?"Play this tone now, at what it is set to":"Plays even when Sounds is off","aria-describedby":t?void 0:"sm-preview-note",children:[o.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:o.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]})]}),o.jsxs("div",{className:"sm-row",children:[o.jsx("label",{htmlFor:C,children:"Volume"}),o.jsx("input",{id:C,type:"range",min:Mo,max:ol,step:wh,value:E.level,onChange:A=>a(N,Number(A.target.value)),style:{"--sm-level":`${(E.level-Mo)/(ol-Mo)*100}%`}}),o.jsxs("span",{className:"sm-read",children:[E.level,"%"]})]}),o.jsxs("div",{className:"sm-row",children:[o.jsx("label",{htmlFor:T,children:"Tone"}),o.jsx("select",{id:T,className:"sm-select",value:E.figure,onChange:A=>l(N,A.target.value),children:pb[N].map(A=>o.jsx("option",{value:A.id,children:A.label},A.id))})]}),o.jsx("p",{className:"sm-note",children:c9[N]})]},N)})}),o.jsxs("p",{className:"sm-foot",children:[o.jsx("kbd",{children:"M"}),"Mute or unmute sounds anywhere."]})]})}const uI="agent-dag.character-enabled",dI="agent-dag.fm-volume",hI="agent-dag.fm-source";function fI(e){return e==="lofi-relax"||e==="lofi-game"||e==="lofi-vibe"||e==="lofi-sleep"||e==="radio-mix"||e==="best-of-nostalgia"||e==="good-life-radio"||e==="cafe-music-bgm"?e:"claude-fm"}function d9(){return fI(ks(hI))}function h9(e){return e!=="0"}function f9(){return h9(ks(uI))}function p9(e){return iI(e)}function m9(){return p9(ks(dI))}const Pi=["light","dark"],g9={light:"Light",dark:"Dark"},hx=[{value:"claude-fm",label:"🎧 Claude FM"},{value:"lofi-relax",label:"📚 Relax / study",group:"📻 Lofi Girl"},{value:"lofi-game",label:"🎮 Chill / game",group:"📻 Lofi Girl"},{value:"lofi-vibe",label:"🌅 Vibe / chill",group:"📻 Lofi Girl"},{value:"lofi-sleep",label:"💤 Sleep / chill",group:"📻 Lofi Girl"},{value:"radio-mix",label:"📡 Live radio mix",group:"📻 Radio Mix"},{value:"best-of-nostalgia",label:"📼 Best of nostalgia live",group:"📻 Best of Nostalgia"},{value:"good-life-radio",label:"🌴 The Good Life Radio",group:"📻 The Good Life Radio"},{value:"cafe-music-bgm",label:"☕ Cafe music BGM",group:"☕ Cafe Music BGM"}];function y9({theme:e}){return o.jsx("span",{className:"appearance-preview","data-swatch":e,children:o.jsxs("svg",{viewBox:"0 0 112 56","aria-hidden":!0,focusable:"false",children:[o.jsx("rect",{className:"tp-canvas",width:"112",height:"56"}),o.jsx("rect",{className:"tp-surface",width:"112",height:"7"}),o.jsx("rect",{className:"tp-rule",y:"7",width:"112",height:"1"}),o.jsx("rect",{className:"tp-surface",y:"8",width:"25",height:"48"}),o.jsx("rect",{className:"tp-rule",x:"25",y:"8",width:"1",height:"48"}),o.jsx("rect",{className:"tp-card",x:"36.5",y:"27.5",width:"28",height:"14",rx:"2.5"}),o.jsx("rect",{className:"tp-tag",x:"39.5",y:"25.5",width:"13",height:"4",rx:"2"}),o.jsx("rect",{className:"tp-card",x:"76.5",y:"14.5",width:"29",height:"20",rx:"2.5"}),o.jsx("rect",{className:"tp-rule",x:"81",y:"23",width:"20",height:"2",rx:"1"}),o.jsx("rect",{className:"tp-accent",x:"81",y:"23",width:"12",height:"2",rx:"1"})]})})}function w9({theme:e,onTheme:t,characterEnabled:n,onToggleCharacter:r,fmVolume:a,onFmVolume:l,fmSource:c,onFmSource:u,onClose:f}){const p=sn(f),[h,m]=x.useState(!1),y=x.useRef(null),w=hx.find(S=>S.value===c)??hx[0];x.useEffect(()=>{if(!h)return;const S=b=>{var N;(N=y.current)!=null&&N.contains(b.target)||m(!1)};return document.addEventListener("pointerdown",S),()=>document.removeEventListener("pointerdown",S)},[h]);const j=S=>{var E;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(S.key))return;S.preventDefault();const N=(Pi.indexOf(e)+(S.key==="ArrowLeft"||S.key==="ArrowUp"?-1:1)+Pi.length)%Pi.length;t(Pi[N]),(E=S.currentTarget.querySelectorAll('[role="radio"]')[N])==null||E.focus()},k=S=>{var N;if(S.key===" "){S.stopPropagation();return}if(S.key!=="t"&&S.key!=="T"||S.ctrlKey||S.metaKey||S.altKey)return;S.preventDefault(),S.stopPropagation();const b=e==="dark"?"light":"dark";t(b),S.target.getAttribute("role")==="radio"&&((N=S.currentTarget.querySelectorAll('[role="radio"]')[Pi.indexOf(b)])==null||N.focus())};return Sn.createPortal(o.jsx("div",{className:"modal-backdrop appearance-backdrop",onClick:f,role:"presentation",children:o.jsxs("div",{ref:p,id:"appearance-menu",className:"modal appearance-menu appearance-modal",role:"dialog","aria-modal":"true","aria-labelledby":"appearance-title",onClick:S=>S.stopPropagation(),onKeyDown:k,children:[o.jsxs("div",{className:"appearance-head",children:[o.jsxs("div",{className:"appearance-heading",children:[o.jsx("h2",{id:"appearance-title",className:"appearance-title",children:"Appearance"}),o.jsx("p",{className:"appearance-subtitle",children:"Tune the deck to your workspace."})]}),o.jsx("button",{type:"button",className:"glyph-btn appearance-close",onClick:f,"aria-label":"Close appearance settings",title:"Close (Esc)",children:"×"})]}),o.jsxs("section",{className:"appearance-section","aria-labelledby":"appearance-theme-caption",children:[o.jsxs("div",{className:"appearance-caption",children:[o.jsxs("div",{children:[o.jsx("h3",{id:"appearance-theme-caption",children:"Color theme"}),o.jsx("p",{className:"appearance-section-note",children:"Choose how the dashboard looks."})]}),o.jsx("kbd",{className:"appearance-key","aria-hidden":!0,title:"Press T anywhere to switch themes",children:"T"})]}),o.jsx("div",{className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":"T",onKeyDown:j,children:Pi.map(S=>o.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","aria-checked":e===S,tabIndex:e===S?0:-1,onClick:()=>t(S),children:[o.jsx(y9,{theme:S}),o.jsxs("span",{className:"appearance-theme-name",children:[g9[S],o.jsx("svg",{className:"appearance-check",viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:o.jsx("path",{d:"M2.5 6.4 4.9 8.7 9.5 3.6"})})]})]},S))})]}),o.jsxs("section",{className:"appearance-section","aria-labelledby":"appearance-fm-caption",children:[o.jsx("div",{className:"appearance-caption",children:o.jsx("h3",{id:"appearance-fm-caption",children:"Music source"})}),o.jsxs("div",{className:"appearance-controls",children:[o.jsxs("div",{className:"appearance-source-row",children:[o.jsx("label",{htmlFor:"appearance-fm-source",children:"Station"}),o.jsxs("div",{ref:y,className:"appearance-source-picker",children:[o.jsxs("button",{id:"appearance-fm-source",type:"button",className:"sm-select appearance-source-trigger","aria-haspopup":"listbox","aria-expanded":h,"aria-describedby":"appearance-fm-source-note",onClick:()=>m(S=>!S),children:[o.jsx("span",{children:w.label}),o.jsx("svg",{className:"appearance-source-chevron",viewBox:"0 0 12 8","aria-hidden":!0,focusable:"false",children:o.jsx("path",{d:"m1 1.5 5 5 5-5"})})]}),h&&o.jsx("div",{className:"appearance-source-list",role:"listbox","aria-label":"Music station",children:hx.map(S=>o.jsxs("button",{type:"button",role:"option","aria-selected":S.value===c,className:"appearance-source-option",onClick:()=>{u(fI(S.value)),m(!1)},children:[o.jsx("span",{children:S.label}),S.value===c&&o.jsx("span",{"aria-hidden":!0,children:"✓"})]},S.value))})]})]}),o.jsx("span",{id:"appearance-fm-source-note",className:"vis-hidden",children:"Changing station starts live playback automatically."}),o.jsxs("label",{className:"appearance-row",children:[o.jsx("span",{className:"appearance-row-label",id:"appearance-character-label",children:"Show character on minimap"}),o.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":n,"aria-labelledby":"appearance-character-label","aria-describedby":"appearance-character-note",onClick:r,children:o.jsx("span",{className:"switch-knob"})}),o.jsx("span",{id:"appearance-character-note",className:"vis-hidden",children:"Shows the animated minimap character and enables music playback."})]}),o.jsxs("div",{className:"sm-row",children:[o.jsx("label",{htmlFor:"appearance-fm-volume",children:"Volume"}),o.jsx("input",{id:"appearance-fm-volume",type:"range",min:Mo,max:ol,step:wh,value:a,"aria-describedby":"appearance-fm-volume-note",onChange:S=>l(Number(S.target.value)),style:{"--sm-level":`${(a-Mo)/(ol-Mo)*100}%`}}),o.jsxs("span",{className:"sm-read",children:[a,"%"]})]})]}),o.jsx("span",{id:"appearance-fm-volume-note",className:"vis-hidden",children:"Controls live music volume."})]})]})}),document.body)}const a0="https://www.youtube-nocookie.com";function v9(e,t,n){const r=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${a0}/embed/${n?encodeURIComponent(n):"live_stream"}?${r.toString()}`}function Ld(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function x9(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const b9=[1,3],k9=[0,2],N9=[2,5,100,101,150];function _9(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;const{event:n,info:r}=t;if(n==="onReady")return{kind:"ready"};if(n==="onError"){const a=typeof r=="number"?r:Number(r==null?void 0:r.errorCode);return Number.isFinite(a)?{kind:"error",code:a}:null}if(n==="onStateChange"||n==="infoDelivery"){const a=typeof r=="number"?r:r==null?void 0:r.playerState;return typeof a!="number"||!Number.isFinite(a)?null:b9.includes(a)?{kind:"playing",playing:!0}:k9.includes(a)?{kind:"playing",playing:!1}:null}return null}const pI=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],QT=18,S9=pI.length,mI=new Set(["a","c","p"]);function nf(e=pI){const t=[];return e.forEach((n,r)=>{let a=0;for(;a<n.length;){const l=n[a];if(l==="."){a+=1;continue}let c=1;for(;a+c<n.length&&n[a+c]===l;)c+=1;t.push({x:a,y:r,w:c,cell:l}),a+=c}}),t}const Io=148,JT=6e3,j9=16e3,gI=46,$a=34;function E9(e,t,n=Io){let r=-Math.round(t()*n);if(Math.abs(r-e)<$a){const a=e-$a>=-n?-$a:$a;r=Math.max(-n,Math.min(0,Math.round(e+a)))}return{to:r,ms:Math.round(Math.abs(r-e)*gI)}}function C9(e){return Math.round(JT+e()*(j9-JT))}const e2=[{kind:"stroll",weight:44},{kind:"tidy",weight:17},{kind:"kick",weight:17},{kind:"sit",weight:12},{kind:"watch",weight:16},{kind:"leave",weight:7},{kind:"fish",weight:12},{kind:"skip",weight:10}];function T9(e){const t=e2.reduce((r,a)=>r+a.weight,0);let n=e()*t;for(const r of e2)if(n-=r.weight,n<0)return r.kind;return"stroll"}const A9=720,R9=260,M9=620,I9=220,t2=520,yI=1600,n2=7e3,$9=15e3,r2=6e3,O9=14e3;function Di(e,t,n=Io){let r=-Math.round(t()*n);if(Math.abs(r-e)<$a){const a=e-$a>=-n?-$a:$a;r=Math.max(-n,Math.min(0,Math.round(e+a)))}return r}const dn=(e,t)=>Math.round(Math.abs(t-e)*gI),Pd=0;function L9(e,t){const n=r=>({kind:"litter",at:t,...r});return[{x:t,prop:n({}),act:"walk",ms:dn(e,t)},{x:t,prop:n({}),act:"stoop",ms:A9},{x:Pd,prop:n({held:!0}),act:"carry",ms:dn(t,Pd)},{x:Pd,prop:n({held:!0}),act:"windup",ms:R9},{x:Pd,prop:n({held:!0,leaving:!0}),act:"toss",ms:M9}]}function P9(e,t){const n=t>e?1:-1,r=t-n*Math.min(15,Math.abs(t-e)),a=(l={})=>({kind:"ball",at:t,...l});return[{x:r,prop:a(),act:"walk",ms:dn(e,r)},{x:r,prop:a(),act:"windup",ms:I9,facing:n>0?"right":"left"},{x:r,prop:a({leaving:!0}),act:"kick",ms:t2,facing:n>0?"right":"left"},{x:r,prop:a({leaving:!0}),act:"stand",ms:yI-t2}]}const wI=640;function D9(e,t,n){const r=Math.max(-70,Math.min(-20,t)),a={x:r,prop:null,facing:"left"};return[{x:r,prop:null,act:"walk",ms:dn(e,r)},{...a,act:"sit",ms:600},{...a,act:"cast",ms:900},{...a,act:"fish",ms:6e3+Math.round(n()*4e3)},{...a,act:"reel",ms:1200},{...a,act:"stow",ms:500},{...a,act:"stand",ms:400},{x:0,prop:null,act:"walk",ms:dn(r,0)}]}function F9(e,t,n){const r=Math.max(-110,Math.min(-30,t)),a={x:r,prop:null};return[{...a,act:"walk",ms:dn(e,r)},{...a,act:"skip-ready",ms:500},{...a,act:"skip",ms:wI*(6+Math.floor(n()*5))},{...a,act:"skip-rest",ms:600},{...a,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:dn(r,0)}]}function q9(e,t,n){return[{x:t,prop:null,act:"walk",ms:dn(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(r2+n()*(O9-r2))},{x:t,prop:null,act:"stand",ms:400}]}function B9(e,t,n){t=Math.max(-110,Math.min(0,t));const r=()=>({kind:"scope",at:t,held:!0});return[{x:t,prop:null,act:"walk",ms:dn(e,t)},{x:t,prop:r(),act:"watch",ms:Math.round(n2+n()*($9-n2))},{x:t,prop:r(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function s2(e,t,n){return e.facing?e.facing:e.act==="watch"||e.act==="scope-pack"?"left":e.x===t?n:e.x>t?"right":"left"}const z9=1500,H9=e=>Math.round(1e3*Math.sqrt(2*e/z9)),U9=115,W9=e=>Math.round(e/U9*1e3),V9=620,G9=200,K9=760,Y9=600,X9=240;function Z9(e,t,n){const a=-(t.ledgeSpan??Io),l=H9(t.ledgeH),c=W9(t.ledgeH),u=-Math.round(n()*t.floorSpan),f=-Math.round(n()*t.floorSpan);return[{x:a,act:"walk",prop:null,ms:dn(e,a)},{x:a,act:"peer",prop:null,ms:V9},{x:a,act:"fall",prop:null,ms:l,place:"floor"},{x:a,act:"land",prop:null,ms:G9,place:"floor"},{x:u,act:"walk",prop:null,ms:dn(a,u),place:"floor"},{x:f,act:"walk",prop:null,ms:dn(u,f),place:"floor"},{x:a,act:"walk",prop:null,ms:dn(f,a),place:"floor"},{x:a,act:"lasso",prop:null,ms:K9,place:"floor"},{x:a,act:"rope-throw",prop:null,ms:Y9,place:"floor"},{x:a,act:"rope-catch",prop:null,ms:X9,place:"floor"},{x:a,act:"climb",prop:null,ms:c},{x:a,act:"pull-up",prop:null,ms:480}]}function Q9(e,t,n){const r=(n==null?void 0:n.ledgeSpan)??Io;switch(T9(t)){case"tidy":return L9(e,Di(e,t,r));case"kick":return P9(e,Di(e,t,r));case"sit":return q9(e,Di(e,t,r),t);case"watch":return B9(e,Di(e,t,r),t);case"fish":return D9(e,Di(e,t,r),t);case"skip":return F9(e,Di(e,t,r),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return Z9(e,n,t)}}const l=E9(e,t,r);return[{x:l.to,prop:null,act:"walk",ms:l.ms}]}const J9=[".xx.","xxxx",".xx."],eV=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],tV=["...xx...............","..xaax..............",".xaallx.............","xaallllx............",".xllllllx...........","..xllllllx..........","...xllllllx.........","....xllllllxx.......",".....xllllxsxx..xx..","......xllxsssx.xllxx",".......xxssssxxxllxx","........xssssssxx...",".........xssssx.....","..........xxxx......","..........xax.......",".........xxxxx......","........xx.x.xx.....","........xl.x.lx.....",".......xl..x..lx....",".......xl..x..lx....","......xl...x...lx...","......xl...x...lx...",".....xl....x....lx..","....xxx...xxx...xxx."],fx={litter:J9,ball:eV,scope:tV},vI=["bob","sway","groove"],a2=9e3,nV=16e3,xI=1e3,rV=.08;function sV(e,t){const n=vI.filter(l=>l!==e),r=n[Math.min(n.length-1,Math.floor(t()*n.length))],a=(t()*2-1)*rV;return{dance:r,beatMs:Math.round(xI*(1+a))}}function aV(e){return Math.round(a2+e()*(nV-a2))}const oV=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],iV=3,lV=-1,o0=11,o2=9,cV=420;function uV(e,t,n){const r=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(cV,Math.max(0,r))}const dV=260,hV=200;function fV(e,t,n){const r=(h,m=dn(e,h))=>({x:h,prop:null,act:"walk",ms:m,place:"floor"});if(!n||n.height<=0)return[r(t)];const a=Math.min(e,t);if(Math.max(e,t)<=n.left||a>=n.right)return[r(t)];const c=t>e,u=c?n.left:n.right,f=c?n.right:n.left,p={place:"floor",riser:n.height,prop:null};return[r(u,dn(e,u)),{...p,x:u,act:"mount",ms:dV},{...p,x:f,act:"walk",ms:dn(u,f)},{x:f,prop:null,act:"dismount",ms:hV,place:"floor"},{x:t,prop:null,act:"walk",ms:dn(f,t),place:"floor"}]}function i2(e){let t=null,n=null,r=0,a=0,l=!1;const c=()=>{t!==null&&clearTimeout(t),t=null},u=()=>{l||e.hidden||!n||t!==null||(a=performance.now(),t=setTimeout(()=>{t=null;const p=n;n=null,p==null||p()},r))},f=()=>{e.hidden&&t!==null?(r=Math.max(0,r-(performance.now()-a)),c()):e.hidden||u()};return e.addEventListener("visibilitychange",f),{schedule(p,h){l||(c(),n=p,r=Math.max(0,h),u())},dispose(){l=!0,c(),n=null,e.removeEventListener("visibilitychange",f)}}}const wc={"claude-fm":"Claude FM","lofi-relax":"Lofi Girl relax/study","lofi-game":"Lofi Girl chill/game","lofi-vibe":"Lofi Girl vibe/chill","lofi-sleep":"Lofi Girl sleep/chill","radio-mix":"Radio Mix Live","best-of-nostalgia":"Best of Nostalgia Live","good-life-radio":"The Good Life Radio Live","cafe-music-bgm":"Cafe Music BGM Live"},pV={"claude-fm":null,"lofi-relax":null,"lofi-game":null,"lofi-vibe":null,"lofi-sleep":null,"radio-mix":"/api/live-radio-mix","best-of-nostalgia":"/api/best-of-nostalgia","good-life-radio":"/api/good-life-radio","cafe-music-bgm":"/api/cafe-music-bgm"};function px(e,t){var r;const n=((r=e[0])==null?void 0:r.length)??0;return o.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:nf(e).map(a=>o.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,fill:a.cell==="s"?"var(--fm-prop-shadow, var(--bg))":a.cell==="l"?"var(--fm-prop-light, var(--text))":a.cell==="a"?"var(--accent)":void 0},`${t}${a.y}-${a.x}`))})}const mx={e:"fm-eye",s:"fm-shade",p:"fm-pad"},vh=nf().filter(e=>!mI.has(e.cell)),mV=nf().filter(e=>mI.has(e.cell)),l2=vh.filter(e=>e.cell==="e"),gV=nf(oV),yV=vh.filter(e=>e.y<o0&&e.cell!=="e").map(e=>{if(e.y!==8&&e.y!==9)return e;const t=Math.max(6,e.x);return{...e,x:t,w:Math.max(0,Math.min(12,e.x+e.w)-t)}}).filter(e=>e.w>0),wV={left:vh.filter(e=>e.y>=o0&&e.x<o2),right:vh.filter(e=>e.y>=o0&&e.x>=o2)},c2={litter:px(fx.litter,"litter"),ball:px(fx.ball,"ball"),scope:px(fx.scope,"scope")},vV=x.memo(function({fetchImpl:t,volume:n,source:r="claude-fm"}){const[a,l]=x.useState(null),[c,u]=x.useState(!1),[f,p]=x.useState(!1),[h,m]=x.useState(!1),y=x.useRef(r),[w,j]=x.useState(0),[k,S]=x.useState(0),[b,N]=x.useState(null),[E,C]=x.useState(null),[T,A]=x.useState({x:0,drop:0}),[I,B]=x.useState("ledge"),[q,L]=x.useState("left"),[U,X]=x.useState(0),Y=x.useRef(null),[M,J]=x.useState(()=>document.hidden);x.useEffect(()=>{const O=new Set,te=()=>{var ae;if(document.hidden){for(const he of((ae=Y.current)==null?void 0:ae.getAnimations({subtree:!0}))??[])if(he.playState==="running"||he.pending){const ge=he.currentTime;he.pause(),ge!==null&&(he.currentTime=ge),O.add(he)}}else{for(const he of O)he.playState==="paused"&&he.play();O.clear()}J(document.hidden)};return te(),document.addEventListener("visibilitychange",te),()=>document.removeEventListener("visibilitychange",te)},[a,c]);const[V,$]=x.useState(null),[z,W]=x.useState(xI),[G,F]=x.useState(()=>{var O;return((O=window.matchMedia)==null?void 0:O.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});x.useEffect(()=>{var ae;const O=(ae=window.matchMedia)==null?void 0:ae.call(window,"(prefers-reduced-motion: reduce)");if(!O)return;const te=()=>F(O.matches);return te(),O.addEventListener("change",te),()=>O.removeEventListener("change",te)},[]);const K=x.useRef(null),de=x.useCallback(O=>{var te,ae;(ae=(te=K.current)==null?void 0:te.contentWindow)==null||ae.postMessage(O,a0)},[]),H=x.useRef(n);if(H.current=n,x.useEffect(()=>{f&&de(Ld("setVolume",[n]))},[n,f,de]),x.useEffect(()=>{let O=!0;const te=t??fetch,ae=y.current!==r;y.current=r,l(null),u(!1),p(ae),m(ae);const he=pV[r];if(he)te(he).then(ge=>ge.ok?ge.json():null).then(ge=>{O&&(ge!=null&&ge.video)&&l({live:!0,channel:"",video:ge.video})}).catch(()=>{});else if(r!=="claude-fm"){const ge=r.replace("lofi-","");te(`/api/lofi-girl?station=${encodeURIComponent(ge)}`).then(Te=>Te.ok?Te.json():null).then(Te=>{O&&(Te!=null&&Te.video)&&l({live:!0,channel:"",video:Te.video})}).catch(()=>{})}else te("/api/claude-fm").then(ge=>ge.ok?ge.json():null).then(ge=>{O&&(ge!=null&&ge.live)&&(ge!=null&&ge.channel)&&l({live:!0,channel:ge.channel})}).catch(()=>{});return()=>{O=!1}},[t,r]),x.useEffect(()=>{if(!f)return;const O=te=>{var he;if(te.origin!==a0||te.source!==((he=K.current)==null?void 0:he.contentWindow))return;const ae=_9(te.data);if(ae){if(ae.kind==="ready"){de(Ld("setVolume",[H.current])),de(Ld("playVideo"));return}if(ae.kind==="playing"){m(ae.playing);return}N9.includes(ae.code)&&(p(!1),m(!1),u(!0))}};return window.addEventListener("message",O),()=>window.removeEventListener("message",O)},[f,de]),x.useEffect(()=>{if(!a||c||G)return;const O=i2(document);let te=0;j(je=>te=je);const ae=je=>{var at,le;const[ve,...Ue]=je;if(!ve){N(null),C(null),Ve();return}N(ve.act),C(ve.prop),B(ve.place??"ledge"),X(ve.riser??0);const ke=De(ve),xe=te;if(ve.act==="kick"){const _e=(le=(at=Y.current)==null?void 0:at.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:le.getBoundingClientRect();_e&&A({x:uV(_e.x,s2(ve,xe,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-_e.y+24)})}const rt=ve.act==="walk"||ve.act==="carry"?dn(xe,ke):ve.ms;S(rt),L(_e=>s2({...ve,x:ke},xe,_e)),j(ke),te=ke,O.schedule(()=>ae(Ue),rt)},he=()=>{const je=Y.current,ve=je==null?void 0:je.querySelector(".fm-sprite"),Ue=je==null?void 0:je.parentElement;if(!je||!ve||!Ue)return null;const ke=je.getBoundingClientRect(),xe=Ue.getBoundingClientRect(),Ge=xe.right-ke.right,rt=xe.width-Ge*2-ve.offsetWidth;return rt>0?rt:null},ge=()=>{const je=Y.current,ve=je==null?void 0:je.querySelector(".fm-walker"),Ue=he();if(!je||!ve||Ue==null)return;const ke=je.getBoundingClientRect().bottom-ve.getBoundingClientRect().bottom;if(ke>0)return{ledgeH:ke,floorSpan:Ue}},Te=()=>{const je=Y.current,ve=document.querySelector(".autofit-chip");if(!je||!ve)return null;const Ue=je.getBoundingClientRect(),ke=ve.getBoundingClientRect();return ke.width<=0||ke.height<=0?null:{left:ke.left-Ue.right,right:ke.right-Ue.right,height:ke.height}},De=je=>{const ve=(je.place??"ledge")==="floor"?he()??Io:Io;return Math.max(-ve,Math.min(0,je.x))},Ve=()=>{O.schedule(()=>{const je=Q9(te,Math.random,ge()),ve=je.some(xe=>xe.place==="floor")?Te():null;let Ue=te;const ke=je.flatMap(xe=>{const Ge=Ue;return Ue=xe.x,xe.place==="floor"&&xe.act==="walk"?fV(Ge,xe.x,ve):[xe]});ae(ke)},C9(Math.random))};return Ve(),()=>{O.dispose(),B("ledge"),j(je=>Math.max(-Io,Math.min(0,je))),S(0),N(null),C(null),X(0)}},[a,c,G]),x.useEffect(()=>{if(!h||G){$(null);return}const O=i2(document),te=ae=>{const he=sV(ae,Math.random);$(he.dance),W(he.beatMs),O.schedule(()=>te(he.dance),aV(Math.random))};return te(null),()=>O.dispose()},[h,G]),!a||c)return null;const Q=()=>{if(!f){p(!0),m(!0);return}const O=!h;m(O),de(Ld(O?"playVideo":"pauseVideo")),O||p(!1)};return o.jsxs("div",{ref:Y,className:"fm","data-suspended":M?"":void 0,"data-place":I,style:{"--fm-beat":`${z}ms`},children:[E&&!E.held&&o.jsx("div",{className:"fm-prop","data-prop":E.kind,"data-leaving":E.leaving?"":void 0,style:{"--fm-prop-x":`${E.at}px`,"--fm-roll-to":`${T.x}px`,"--fm-ball-drop":`${T.drop}px`,"--fm-ball-flight-ms":`${yI}ms`,"--fm-ball-turn":q==="right"?"1080deg":"-1080deg"},children:c2[E.kind]}),(b==="lasso"||b==="rope-throw"||b==="rope-catch"||b==="climb"||b==="pull-up")&&o.jsxs("div",{className:"fm-rope","data-act":b,style:{"--fm-rope-x":`${w}px`,"--fm-rope-ms":`${k}ms`},children:[o.jsx("div",{className:"fm-rope-line"}),o.jsxs("svg",{className:"fm-rope-hook",viewBox:"0 0 9 9",shapeRendering:"crispEdges","aria-hidden":!0,children:[o.jsx("path",{d:"M4 8V3H3V1H1V3H0V5H2V4H3V6H5V4H6V5H8V3H7V1H5V3H4"}),o.jsx("rect",{className:"fm-rope-knot",x:"3",y:"6",width:"3",height:"2"})]})]}),o.jsxs("div",{className:"fm-walker","data-act":b??void 0,"data-place":I,"data-facing":q,style:{"--fm-x":`${w}px`,"--fm-walk-ms":`${k}ms`,"--fm-riser":`${U}px`,"--fm-skip-beat":`${wI}ms`},children:[(E==null?void 0:E.held)&&o.jsx("div",{className:"fm-held","data-prop":E.kind,"data-toss":E.leaving?"":void 0,children:c2[E.kind]}),["cast","fish","reel","stow"].includes(b)&&o.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[o.jsxs("g",{children:[o.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),o.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),o.jsxs("g",{className:"fm-fishing-line",children:[o.jsx("path",{d:"M8 2V26"}),o.jsxs("g",{className:"fm-float",children:[o.jsx("rect",{x:"7",y:"25",width:"3",height:"2"}),o.jsx("rect",{x:"8",y:"24",width:"1",height:"1"})]})]}),o.jsx("path",{className:"fm-ripple",d:"M3 28H6M10 28H14M5 30H12"})]}),["skip-ready","skip","skip-rest"].includes(b)&&o.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[o.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),o.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),o.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),o.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),o.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),o.jsx("button",{type:"button",className:"fm-sprite","data-playing":h?"":void 0,"data-dance":h?V??vI[0]:void 0,"aria-pressed":h,onClick:Q,title:h?`Stop ${wc[r]}`:`Play ${wc[r]} — streams from YouTube`,"aria-label":h?`Stop ${wc[r]}`:`Play ${wc[r]}`,children:o.jsxs("svg",{viewBox:`0 0 ${QT} ${S9}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[o.jsx("g",{className:"fm-gear",children:o.jsx("g",{className:"fm-gear-motion",children:mV.map(O=>o.jsx("rect",{x:O.x,y:O.y,width:O.w,height:1,className:mx[O.cell]},`g${O.y}-${O.x}`))})}),o.jsxs("g",{className:"fm-body",children:[l2.map(O=>o.jsx("rect",{x:O.x,y:O.y,width:O.w,height:1,fill:"var(--accent)"},`eye-bed-${O.x}`)),yV.map(O=>o.jsx("rect",{x:O.x,y:O.y,width:O.w,height:1,className:mx[O.cell]},`b${O.y}-${O.x}`)),o.jsxs("g",{className:"fm-arms",children:[o.jsx("rect",{x:4,y:8,width:2,height:2}),o.jsx("rect",{x:12,y:8,width:1,height:2}),o.jsx("rect",{x:13,y:8,width:1,height:2,className:"fm-shade"})]}),l2.map(O=>o.jsx("rect",{x:O.x-(O.x>=QT/2?1:0)+(q==="right"?1:0),y:O.y,width:O.w,height:1,className:"fm-eye"},`eye-${O.x}`))]}),o.jsx("g",{className:"fm-hat",children:gV.map(O=>o.jsx("rect",{x:iV+O.x,y:lV+O.y,width:O.w,height:1,className:O.cell==="k"?"fm-hatband":void 0},`h${O.y}-${O.x}`))}),(b==="climb"||b==="rope-throw"||b==="rope-catch"||b==="pull-up")&&o.jsxs("g",{className:"fm-grip",children:[o.jsx("path",{className:"fm-grip-left",d:"M5 9H4V4H7V3H9V5H6V9Z"}),o.jsx("path",{className:"fm-grip-right",d:"M12 9H14V6H11V5H9V7H12Z"})]}),(b==="land"||b==="dismount")&&o.jsxs("g",{className:"fm-crouch-legs",children:[o.jsx("path",{d:"M6 11H8V13H6Z"}),o.jsx("path",{d:"M10 11H12V13H10Z"})]}),["sit","cast","fish","reel","stow"].includes(b)&&o.jsxs("g",{className:"fm-seated-legs",children:[o.jsx("path",{className:"fm-seated-far",d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),o.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(O=>o.jsx("g",{className:"fm-leg","data-side":O,children:wV[O].map(te=>o.jsx("rect",{x:te.x,y:te.y,width:te.w,height:1,className:mx[te.cell]},`${O}${te.y}-${te.x}`))},O))]})})]}),f&&(a.channel||a.video)&&o.jsx("iframe",{ref:K,className:"fm-frame",title:wc[r],src:v9(a.channel,window.location.origin,a.video),onLoad:()=>de(x9()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})]})}),xV=15e3;function bV(e){return e.visibilityState==="visible"&&e.hasFocus()}function kV(e,t){return t||e===!0}function NV(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}const _V={"//":["What a user would NOTICE. One key per version that has something to say,","and no key at all for a version that has nothing — which is most of them.","","The rule this file exists to serve: before every release, ask 'what would a","user notice?' and write the answer here. 'Nothing user-visible' is a valid","and expected answer, and it is spelled by adding no key. A release with no","key shows no modal, and that silence is what keeps the modal worth reading","on the day it is not silent.","","What belongs here: something that changed on the user's machine or under","their hands — a hook written to or removed from settings.json, a default","that flipped, a control that moved or went away, a stored preference that","changed meaning. What does not: bounds, races, assertions that could not","fire, anything that is invisible when it is correct.","","Write it for the person running the deck, not for the person reading the","diff. `title` is the sentence they scan; `body` is what they need in order","to act on it, or to stop worrying about it.","","Keys are versions exactly as package.json spells them. A key that is not a","version, or an entry missing either field, fails the suite rather than","being quietly dropped — see src/web/__tests__/release-notes-file.test.ts.","Ordering here is for humans; the deck sorts by version itself.","","A title may open with an emoji, and if it does, put exactly ONE space after","it. Not two: the dialog gives a leading emoji its own optical gap, because","a colour glyph is drawn edge to edge inside its advance and one word space","after one reads as none. A second space here would be a lie in the data","about a defect in the type, and the suite refuses both it and no space at","all.","","A release that genuinely has nothing to say is spelled TWICE: no key here,",'and its version written into "//nothing-to-say" below. One spelling on its',"own is ambiguous — a missing key reads the same whether it was a decision","or a forgotten step, and five releases in a row were once forgotten. The list","is what tells the two apart, and release-notes-current-version.test.ts fails","the release whose version is in neither place. Any key opening with // is a","note to the author and never a release."],"//nothing-to-say":["3.23.1","3.23.2","3.23.3","3.23.4","3.26.0","3.26.1","3.26.3","3.26.4","3.26.5","3.27.6"],"3.27.0":[{title:"📊 Projects: where each account spent its work",body:"Each account card's ⋯ menu now breaks its cost down by project, over 7d / 30d / all."}],"3.27.1":[{title:"🎨 Make Appearance easier to tune",body:"The Appearance dialog now has clearer sections, stronger selection states, and a calmer layout for choosing a theme and configuring music. Your existing settings and keyboard shortcuts continue to work."}],"3.27.2":[{title:"💰 Project costs now match Usage",body:"Project cost totals no longer count the same Claude request once for every content block. Existing project history is rebuilt automatically so the totals align with the Usage panel."}],"3.27.3":[{title:"🎵 Station selection works in the desktop app",body:"The music station picker now opens inside ccdeck instead of relying on the operating system popup, so choosing a station works reliably in the Electron app."}],"3.27.4":[{title:"✅ Desktop picker release checks are green",body:"The station picker now keeps the same keyboard, motion, focus, and layout behavior as the rest of ccdeck across desktop and browser builds."}],"3.27.5":[{title:"🧭 The welcome tour stays dismissed",body:"Electron now remembers that you completed the onboarding tour at the deck level, so an update or loopback port change no longer shows the same tour again."},{title:"🎵 The station picker has a clearer finish",body:"The music selector has a tighter trigger, a purposeful chevron, and more deliberate option spacing so it reads like a native part of Appearance."}],"3.25.0":[{title:"🖱️ A click goes to the session, a double-click opens the details",body:"Clicking a card frames it with the rest of its session and leaves the detail panel shut. Double-click a card to open its details; `j`/`k`, the session list, Enter and `D` still open them too."},{title:"🔭 Cards stay readable when you zoom out",body:"At every zoom a card shows its name, its state and anything waiting on you, instead of shrinking to a coloured pill. Hover or focus a card to see it whole. Recap notes read at a distance too, and show the full recap on hover."},{title:"🌐 The Machine panel shows your network",body:"A new Network section shows download, upload and the round trip to Claude's API, and names the route when traffic goes through a VPN or a Tailscale exit node. Those checks run only while the panel is open. The panel is regrouped into CPU, Memory, Network and Thermal, with a flag at the top when something needs attention."},{title:"🎨 See each theme before you pick it",body:"The Appearance menu shows a small preview of the deck in Light and in Dark. Claude FM also keeps its volume when a notification chime plays, instead of dipping under it."}],"3.24.1":[{title:"🎛️ Appearance is one small menu now",body:"The topbar's appearance control opens a compact menu where you can choose Light or Dark and show or hide the character. The character stays on by default, and your choice is remembered."}],"3.24.0":[{title:"🎧 Claude FM plays from the minimap",body:"A small character stands on the minimap's top edge. Press it and the Claude channel's live stream plays; press it again and it stops. It only turns up when the channel is actually broadcasting, so a deck with no network never shows it at all."},{title:"🤠 And it gets on with its day",body:"It walks that edge, tidies up what it finds, kicks a ball along it, sits with its legs over the side, and watches the board through a scope. Now and then it drops onto the canvas and ropes its way back up. Headphones on while the music plays, a hat when it does not."}],"3.23.5":[{title:"🧭 The accounts panel opens on the account you are on",body:"Its windows, its resets and how old the numbers are — whole, at the top of the column. Every other account stands behind one row that says how many of them a switch could actually reach; press it to see them, or rest on it to be shown their names and how much room each has left."},{title:"⚙️ Auto-switch moved in there with them",body:"It is behind that same row now, after the accounts it switches between, rather than at the foot of the panel. The row says `auto 90%` or `auto off` so you can tell what the policy is doing without opening it — and says so in amber when it is armed with nowhere left to go."}],"3.23.0":[{title:"🧭 The accounts column leads with accounts",body:`The live account is the open row: its windows as bars, when each one resets, and how old the numbers are. Every other account rests on the two figures a switch is decided by, and opens with a click when you want the rest.
|
|
92
|
+
`)})}),o.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>void c(),title:u?"Copy these lines, then paste them into a terminal":"Copy these lines, then paste them into an elevated PowerShell",children:n?"copied":"copy command"})]})]})}async function Wp(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const kB={not_an_invite:"That is not an invite — paste the whole line they sent you.",expired:"That invite has run out. Ask them for a fresh one.",not_running:"This deck is not on the network yet. Turn Local network on, then try again."},NB={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function d_(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||tn(n,t)}function _B({status:e,manual:t,onClose:n,onChanged:r}){const a=x.useRef(null),l=sn(n,{focusRef:a}),[c,u]=x.useState(""),[f,p]=x.useState(""),[h,m]=x.useState(null),[y,w]=x.useState(null),[j,k]=x.useState(null),[S,b]=x.useState(null),[N,E]=x.useState(()=>Date.now());x.useEffect(()=>{const $=window.setInterval(()=>E(Date.now()),1e3);return()=>window.clearInterval($)},[]);const C=x.useRef(!0);x.useEffect(()=>()=>{C.current=!1},[]);const T=x.useRef(null),A=x.useCallback($=>Oh(T.current)?(T.current=$,k($),!0):!1,[]),I=x.useCallback(()=>{T.current=null,C.current&&k(null)},[]),B=$=>{const z=Fa(j,$);return{disabled:z.disabled,"aria-busy":z.busy}},q=$=>(h==null?void 0:h.field)===$?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},L=$=>m(z=>z&&z.field===$?null:z),U=x.useCallback(async()=>{const $=qB(c);if(!$){m({text:SB(c),field:"addr"});return}const z=`${$.addr}:${$.port}`,W=e.peers.find(G=>G.addr===$.addr&&G.port===$.port&&G.paired);if(W){m({text:`Already paired with ${W.name} at that address.`,field:"addr"});return}if(t.includes(z)){m({text:"This deck already calls that address.",field:"addr"});return}if(A("add"))try{const G=await Wp("/api/prefs",{lan:{manual:[...t,z]}});if(!C.current)return;G!=null&&G.ok?(m(null),u(""),r(),n()):m({text:tn("add that address",G),field:"addr"})}catch{C.current&&m({text:tn("add that address",null),field:"addr"})}finally{I()}},[c,t,e.peers,r,n,A,I]),X=x.useCallback(async $=>{if(!A(`invite:${$}`))return;const z=$==="make"?"make an invite":"cancel that invite";try{const W=await Wp("/api/lan/invite",{action:$});if(!C.current)return;W!=null&&W.ok?(m(null),w(null),r()):m({text:d_(NB,W,z)})}catch{C.current&&m({text:tn(z,null)})}finally{I()}},[r,A,I]),Y=x.useCallback(async()=>{const $=f.trim();if(!(!$||!A("join"))){b(null);try{const z=await Wp("/api/lan/invite",{action:"join",token:$});if(!C.current)return;z!=null&&z.ok?(p(""),m(null),r(),n()):(z==null?void 0:z.reason)==="unreachable"&&Array.isArray(z.tried)&&z.tried.length?(b(z.tried),m(null)):(b(null),m({text:d_(kB,z,"use that invite"),field:"join"}))}catch{C.current&&m({text:tn("use that invite",null),field:"join"})}finally{I()}}},[f,r,n,A,I]),M=x.useCallback(async($,z)=>{try{await navigator.clipboard.writeText($),w(z),window.setTimeout(()=>{C.current&&w(W=>W===z?null:W)},1600)}catch{m({text:"Could not copy it — select the text and copy it by hand."})}},[]),J=e.invite&&e.invite.expiresAt>N?e.invite:null,V=e.port!=null?(e.addrs??[]).map($=>`${$}:${e.port}`):[];return Sn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:o.jsxs("div",{ref:l,className:"modal lan-add",onClick:$=>$.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-add-title",children:[o.jsxs("header",{className:"modal-head",children:[o.jsx("div",{className:"modal-title",children:o.jsx("span",{id:"lan-add-title",className:"modal-tool-name",children:"Add a deck"})}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body",children:[h&&o.jsxs("div",{className:"ap-failure",role:"alert",children:[o.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:h.text}),o.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>m(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),o.jsx(XR,{reach:e.reach,where:"dialog"}),o.jsxs("div",{className:"modal-section",children:[o.jsx("h3",{className:"lan-h",children:"By address"}),o.jsxs("div",{className:"ap-lan-row",children:[o.jsx("input",{ref:a,className:"ap-manage-input ap-lan-input","aria-label":"Another deck's address",value:c,placeholder:"192.168.1.5:54340",spellCheck:!1,...q("addr"),onChange:$=>{u($.target.value),L("addr")},onKeyDown:$=>{$.key==="Enter"&&U()}}),c.trim()!==""&&o.jsx("button",{type:"button",className:"ap-manage-btn",...B("add"),onClick:()=>void U(),title:"Add it to the decks this one calls, starting now.",children:"add"})]}),o.jsx("p",{className:"lan-note",children:"This deck calls that address until somebody there accepts."}),e.port!=null&&V.length>0&&o.jsxs("p",{className:"lan-note",children:["They type this deck’s own address into the same field on theirs:"," ",V.map(($,z)=>o.jsxs("span",{children:[z>0&&" or ",o.jsx("code",{className:"ap-lan-code",children:$})]},$)),o.jsx("button",{type:"button",className:"ap-lan-word lan-copy",...B("copy:mine"),onClick:()=>void M(V.join(" "),"mine"),title:"Copy this deck's address, to send to whoever is adding it",children:y==="mine"?"copied":"copy"})]})]}),o.jsxs("div",{className:"modal-section",children:[o.jsxs("h3",{className:"lan-h",children:["With an invite",!J&&o.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",...B("invite:make"),onClick:()=>void X("make"),title:"One piece of text you send them. They paste it, and the two decks pair — nobody has to press anything here.",children:j==="invite:make"?"making…":"make one to send"})]}),o.jsxs("div",{className:"ap-lan-row",children:[o.jsx("input",{className:"ap-manage-input ap-lan-input","aria-label":"An invite you were sent",value:f,placeholder:"paste one you were sent",spellCheck:!1,...q("join"),onChange:$=>{p($.target.value),b(null),L("join")},onKeyDown:$=>{$.key==="Enter"&&Y()}}),f.trim()!==""&&o.jsx("button",{type:"button",className:"ap-manage-btn",...B("join"),onClick:()=>void Y(),title:"Reach that deck and pair with it. Nobody has to press anything there.",children:j==="join"?"joining…":"join"})]}),o.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),S&&o.jsxs("div",{className:"ap-lan-tried",children:[o.jsx("span",{className:"lan-note",children:"Nothing answered at any address in that invite. Check that deck is running with its Local network switch on."}),S.map($=>o.jsxs("span",{className:"ap-lan-tried-row",children:[o.jsx("code",{className:"ap-lan-code",children:$.addr}),o.jsx("span",{className:"ap-lan-bad",children:$.why})]},$.addr))]}),J&&o.jsxs("div",{className:"ap-lan-invite",children:[o.jsxs("div",{className:"ap-lan-invite-head",children:[o.jsx("span",{className:"ap-lan-invite-title",children:"Send this to them"}),o.jsxs("span",{className:"ap-lan-invite-left",children:[HB(J.expiresAt,N)," left"]})]}),o.jsx("code",{className:"ap-lan-token",children:J.token}),o.jsxs("div",{className:"ap-lan-acts",children:[o.jsx("button",{type:"button",className:"ap-manage-btn",...B("copy:invite"),onClick:()=>void M(J.token,"invite"),title:"Copy it, and send it however you already talk to them",children:y==="invite"?"copied":"copy"}),o.jsx("button",{type:"button",className:"ap-manage-btn",...B("invite:withdraw"),onClick:()=>void X("withdraw"),title:"Cancel it. Anybody already holding the text can no longer use it.",children:"cancel"})]}),o.jsx("p",{className:"lan-warn",children:"Anyone who gets this text can pair with this deck until it runs out."})]})]})]})]})}),document.body)}function SB(e){const t=(e??"").trim();if(t==="")return"Type an address and a port, like 192.168.1.5:54340.";if(!t.startsWith("[")&&(t.match(/:/g)??[]).length>1)return"Too many colons to split. Use that deck's IPv4 address or its name, like 192.168.1.5:54340.";if(!t.includes(":"))return`Add the port too, like ${t}:54340.`;const n=t.slice(t.lastIndexOf(":")+1).trim();return n===""?"That is missing its port — try 192.168.1.5:54340.":/^\d+$/.test(n)?`A port runs from 1 to 65535, and this one is ${n}.`:`A port is a number, and this one is "${n}".`}const jB=1e3;function EB(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),r=xs(e,t);return`${n} · ${r==="now"?"just now":r}`}function h_(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}function CB(){return o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M9.6 2.4l2 2L5 11l-2.6.6L3 9z"}),o.jsx("path",{d:"M8.4 3.6l2 2"})]})}function f_(){return o.jsxs("svg",{className:"lan-machine",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("rect",{x:"2.5",y:"3",width:"11",height:"7.5",rx:"1.2"}),o.jsx("path",{d:"M1 13h14"})]})}function Id({dir:e,gate:t=!1}){const n=t?12:8;return o.jsx("svg",{className:"lan-chev","data-dir":e,"data-gate":t||void 0,width:n,height:"8",viewBox:`0 0 ${n} 8`,fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:o.jsx("path",{d:e==="out"?"M2.8 1L6 4 2.8 7":t?"M1 1v6M9.6 1L6.4 4l3.2 3":"M5.2 1L2 4l3.2 3"})})}const TB={works:"works here",expired:"expired here",missing:"not on this deck"},AB={works:"works there",broken:"broken there",unknown:"not offered by that deck"};function RB(e){const t=e.in&&e.out?"offered both ways":e.in?"offered by that deck":"offered by this deck";return`${TB[e.here]}, ${AB[e.there]}, ${t}${e.usedThere?", in use there":""}.`}function MB({row:e,source:t,status:n,accounts:r,now:a,busy:l,onClose:c,onRename:u,onCheck:f,onVerb:p,onSettings:h,twins:m=[],onUnpair:y}){var vt,an,jn,Nt,Yt;const w=x.useRef(null),j=sn(c,{focusRef:w}),[k,S]=x.useState(null),[b,N]=x.useState(null),[E,C]=x.useState(!1),T=x.useRef(0),[A,I]=x.useState(null),[B,q]=x.useState(!1),[L,U]=x.useState(0),X=x.useRef(null),Y=x.useRef(!0);x.useEffect(()=>()=>{Y.current=!1},[]);const M=k!=null;x.useEffect(()=>{var fe;M&&((fe=X.current)==null||fe.select())},[M]),x.useEffect(()=>{if(!E)return;const fe=window.setTimeout(()=>C(!1),4e3);return()=>window.clearTimeout(fe)},[E]),x.useEffect(()=>{if(!A)return;const fe=window.setTimeout(()=>I(null),4e3);return()=>window.clearTimeout(fe)},[A]);const J=fe=>{const st=Fa(l,fe);return{disabled:st.disabled,"aria-busy":st.busy}},V=async fe=>{const st=await fe();return Y.current&&N(st),st==null},{peer:$,stranger:z}=t,W=e.kind==="paired",G=e.self??e.name,F=e.kind!=="dialling",K=e.kind==="dialling"?null:e.fp,de=$?$.addr?`${$.addr}:${$.port}`:"":z?z.port?`${z.addr}:${z.port}`:z.addr:e.addr,H=($==null?void 0:$.about)??null,Q=((vt=n.about)==null?void 0:vt.version)??null,O=async fe=>{const st=fe.trim()===G?"":fe;await V(()=>u(st))&&S(null)},te=async()=>{if(K)try{if(await navigator.clipboard.writeText(K),!Y.current)return;q(!0),window.setTimeout(()=>{Y.current&&q(!1)},1600)}catch{Y.current&&N("Could not copy it — select the fingerprint and copy it by hand.")}},ae=W?$!=null&&$.waiting?$.lastSeen!=null?"not said — it runs an older version":"not said yet — it says when it next calls":$!=null&&$.offers?"not said — it runs an older version":"not reached yet":"shown once paired",he=h_(n.about),ge=h_(H),Te=H!=null&&H.version&&Q?QB(H.version,Q):null,De=$?ZR($.last,a):null,Ve=$&&((an=$.last)!=null&&an.error)?FB({error:$.last.error,host:$.addr,port:$.port},[...n.strangers??[],...n.pending??[],...(n.peers??[]).filter(fe=>!fe.manual&&fe.addr).map(fe=>({fp:fe.fp,name:fe.name,addr:fe.addr,port:fe.port,at:fe.lastSeen??0}))],a):null,je=(jn=$==null?void 0:$.last)!=null&&jn.error&&De&&De.text!==$.last.error?$.last.error:null,ve=((Nt=$==null?void 0:$.last)==null?void 0:Nt.done)??[],Ue=!!De&&!!je&&!e.quiet&&e.state.startsWith(De.text),ke=W||e.kind==="dialling",xe=(($==null?void 0:$.via)??e.via)==="tailscale",Ge=$?$.waiting?null:$.manual?xe?"added by its Tailscale address":"added by address":xe?"over Tailscale":"on this network":e.kind==="nearby"?xe?"heard over Tailscale":"heard on this network":xe?"asked this deck to pair, over Tailscale":"asked this deck to pair",rt=e.tone==="bad"?"bad":W?e.here?"up":"down":"loose",at=l===`check:${e.fp}`,le=($==null?void 0:$.offers)??null,_e=rt==="up"?(le==null?void 0:le.current)??null:null,Ie=_e&&"key"in _e?_e.key:null,Ze=!!_e&&"hidden"in _e,We=!!_e&&"other"in _e,Je=W?ez((le==null?void 0:le.accounts)??null,r,n.shared??[],Ie):[],ye=Je.filter(fe=>fe.in==null&&fe.out==="cut"),Me=Je.some(fe=>fe.in!=null),Qe=Je.some(fe=>fe.out!=null),ue=new Map(ve.map(fe=>[fe.email,fe])),kt=ve.filter(fe=>!Je.some(st=>st.email===fe.email)),pt=W?le?le.accounts.length===0?"That deck offers nothing. Nobody there has chosen a login to share.":null:$!=null&&$.waiting?"What that deck offers is not known yet. A deck that calls in says so each time it calls — one on an older version never does.":(Yt=$==null?void 0:$.last)!=null&&Yt.error?"What that deck offers is not known — the last attempt to ask it did not get through.":"Nobody has asked that deck what it offers yet. The next round asks it.":null,ut=le&&($!=null&&$.last)&&$.last.at-le.at>jB?xs(le.at,a):null,Bt=[];W&&($!=null&&$.pairedAt)?Bt.push({label:"Paired",value:EB($.pairedAt,a),tone:"meta"}):e.kind==="declined"&&z&&Bt.push({label:"Paired",value:`no · you said no ${Y0(z.at,a)}`,tone:"meta"}),Bt.push({label:"Fingerprint",value:K?o.jsxs("span",{className:"lan-fp",children:[o.jsx("code",{className:"ap-lan-code",children:K}),o.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void te(),"aria-label":B?"Fingerprint copied":"Copy the fingerprint",children:B?"copied":"copy"})]}):"not known — nothing has answered there",tone:K?void 0:"quiet"});const jt=m.length?[{row:e,peer:$??null},...m]:[];return Sn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:c,role:"presentation",children:o.jsxs("div",{ref:j,className:"modal lan-peer","data-tone":e.tone,onClick:fe=>fe.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-peer-title","aria-describedby":"lan-peer-sub",children:[o.jsxs("header",{className:"modal-head lan-peer-head",children:[o.jsx("i",{className:e.here?"ap-pulse":"ap-dot","aria-hidden":!0}),o.jsxs("div",{className:"lan-peer-id",children:[M?o.jsxs("form",{className:"lan-peer-edit",onSubmit:fe=>{fe.preventDefault(),O(k??"")},children:[o.jsx("span",{id:"lan-peer-title",className:"vis-hidden",children:e.name}),o.jsx("input",{ref:X,className:"ap-manage-input lan-peer-input",value:k??"",maxLength:48,placeholder:G,"aria-label":"Name for this deck, shown on this deck only",onChange:fe=>S(fe.target.value)}),o.jsx("button",{type:"submit",className:"ap-manage-btn",...J(`alias:${e.fp}`),children:"save"}),o.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>S(null),children:"cancel"})]}):o.jsxs("span",{className:"lan-peer-title",children:[o.jsx("span",{id:"lan-peer-title",className:"lan-peer-name",children:e.name}),F&&o.jsx("button",{type:"button",className:"glyph-btn lan-peer-rename",onClick:()=>{N(null),S(e.name)},"aria-label":`Rename ${e.name} on this deck`,title:"Give it a name of your own. Only this deck sees it.",children:o.jsx(CB,{})})]}),o.jsxs("p",{id:"lan-peer-sub",className:"lan-peer-sub",children:[e.self&&o.jsxs(o.Fragment,{children:["calls itself ",o.jsx("span",{className:"lan-peer-self",children:e.self}),M&&o.jsx("button",{type:"button",className:"ap-lan-word lan-peer-restore",...J(`alias:${e.fp}`),onClick:()=>void O(""),children:"use this name"}),o.jsx("span",{className:"vis-hidden",children:". "}),!e.quiet&&o.jsx("span",{"aria-hidden":!0,children:" · "})]}),o.jsx("span",{className:e.quiet?"vis-hidden":"lan-peer-state",children:e.state})]})]}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{ref:w,type:"button",className:"glyph-btn",onClick:c,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body lan-peer-body",children:[b&&o.jsxs("div",{className:"ap-failure",role:"alert",children:[o.jsx("span",{className:"ap-failure-text",children:b}),o.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>N(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),o.jsxs("div",{className:"lan-map","data-link":rt,"data-asking":at||void 0,"data-bus":Je.length>0||void 0,children:[o.jsxs("div",{className:"lan-ends",children:[o.jsxs("p",{className:"lan-end",children:[o.jsx("span",{className:"lan-end-name",children:"This deck"}),he&&o.jsx("span",{className:"lan-end-runs",children:he}),W&&n.shareActive===!1&&o.jsx("span",{className:"lan-end-note",children:"current account hidden"})]}),o.jsxs("p",{className:"lan-end","data-side":"there",children:[o.jsx("span",{className:"lan-end-name",children:e.name}),e.kind!=="dialling"&&o.jsxs("span",{className:"lan-end-runs",children:[ge??(H?"not said":ae),Te?` · ${Te<0?"older":"newer"}`:null]}),Ze&&o.jsx("span",{className:"lan-end-note",children:"current account hidden"}),We&&o.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),o.jsxs("div",{className:"lan-link",children:[o.jsx(f_,{}),o.jsxs("span",{className:"lan-span",children:[o.jsxs("span",{className:"lan-wire","aria-hidden":!0,children:[o.jsx("i",{className:"lan-glint","data-dir":"out"}),o.jsx("i",{className:"lan-glint","data-dir":"in"})]}),o.jsx("span",{className:"lan-link-label",children:de?o.jsx("code",{className:"ap-lan-code",children:de}):"none here — it calls this deck"})]}),o.jsx(f_,{}),(de&&Ge||ke)&&o.jsxs("p",{className:"lan-link-sub",children:[de&&Ge,de&&Ge&&ke&&" · ",ke&&(De?Ue?o.jsx("code",{className:"ap-lan-code",children:je}):o.jsx("span",{className:"lan-round","data-tone":De.tone,children:De.text.replace(/ · now$/," · just now")}):"not asked yet"),ke&&je&&!Ue&&o.jsx("code",{className:"lan-fact-raw",children:je})]}),kt.length>0&&o.jsx("ul",{className:"lan-done",children:kt.map(fe=>o.jsxs("li",{"data-ok":fe.ok,children:[fe.email," ",o.jsx("span",{className:"lan-done-what",children:fe.ok?"arrived":"did not arrive"})]},`${fe.email}:${fe.action}`))}),Ve&&o.jsx("p",{className:"lan-note lan-link-note",children:Ve}),($==null?void 0:$.waiting)&&o.jsx("p",{className:"lan-note lan-link-note",children:e.hint})]}),Je.length>0&&o.jsx("ul",{className:"lan-lanes",role:"list","aria-label":`Logins between this deck and ${e.name}`,children:Je.map((fe,st)=>{const It=ue.get(fe.email),Et=fe.out==="live"||fe.in!=null&&fe.in!=="cut";return o.jsxs("li",{role:"listitem",className:"lan-lane","data-tone":fe.tone,"data-draw":fe.in&&fe.out?"both":fe.in?"in":"out","data-used-there":fe.usedThere||void 0,style:{"--i":st},children:[o.jsx("i",{className:"lan-pip","data-end":"here","data-state":fe.here,"aria-hidden":!0}),o.jsxs("span",{className:"lan-track",children:[o.jsxs("span",{className:"lan-wire","data-flow":Et?"live":"cut","aria-hidden":!0,children:[(fe.in==="live"||fe.in==="wait")&&o.jsx("i",{className:"lan-glint","data-dir":"in","data-tone":fe.in}),fe.out==="live"&&o.jsx("i",{className:"lan-glint","data-dir":"out"})]}),fe.in&&fe.in!=="cut"&&o.jsx(Id,{dir:"in",gate:fe.in==="blocked"}),fe.out==="live"&&o.jsx(Id,{dir:"out"}),o.jsx("span",{className:"lan-lane-email",children:fe.email})]}),o.jsx("i",{className:"lan-pip","data-end":"there","data-state":fe.there,"aria-hidden":!0}),o.jsx("span",{className:"vis-hidden",children:RB(fe)}),(fe.caption||It)&&o.jsxs("span",{className:"lan-lane-note",children:[fe.caption,fe.caption&&It&&" · ",It&&o.jsx("span",{className:"lan-lane-done","data-ok":It.ok,children:It.ok?"arrived last round":"did not arrive last round"})]})]},fe.key)})},L),W&&o.jsxs(o.Fragment,{children:[ye.length>0&&o.jsxs("p",{className:"lan-spent",children:["Paired decks get nothing from ",ye.length===1?ye[0].email:"the expired ones"," until you sign in again here."]}),pt&&o.jsx("p",{className:"lan-empty",children:pt}),ut&&o.jsxs("p",{className:"lan-stale",children:["As of ",ut==="now"?"just now":ut,", when it last answered."]}),o.jsxs("div",{className:"lan-legend",children:[Me&&o.jsxs("span",{className:"lan-key",children:[o.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:o.jsx(Id,{dir:"in"})}),"from ",e.name]}),Qe?o.jsxs("span",{className:"lan-key",children:[o.jsx("span",{className:"lan-key-wire","data-dir":"out","aria-hidden":!0,children:o.jsx(Id,{dir:"out"})}),"from this deck, to every paired deck"]}):o.jsx("span",{className:"lan-key",children:"This deck offers nothing yet."}),o.jsx("button",{type:"button",className:"ap-lan-word lan-legend-act",onClick:h,"aria-label":"Change what this deck offers",children:"change"})]})]})]}),o.jsx("dl",{className:"lan-facts",children:Bt.map(fe=>o.jsxs("div",{className:"lan-fact","data-tone":fe.tone,children:[o.jsx("dt",{children:fe.label}),o.jsx("dd",{children:fe.value})]},fe.label))}),jt.length>1&&o.jsxs("div",{className:"modal-section",children:[o.jsxs("h3",{className:"lan-h",children:[jt.length," decks on this machine"]}),o.jsx("ul",{className:"lan-twins",role:"list",children:jt.map((fe,st)=>{var lr,yn,Xt,Cn;const It=(lr=fe.peer)!=null&&lr.addr?`${fe.peer.addr}:${fe.peer.port}`:fe.row.addr,Et=It||fe.row.fp,En=(yn=fe.peer)!=null&&yn.pairedAt?xs(fe.peer.pairedAt,a):null,Gn=[(Cn=(Xt=fe.peer)==null?void 0:Xt.about)!=null&&Cn.version?`runs ${fe.peer.about.version}`:null,En?`paired ${En==="now"?"just now":En}`:null,fe.row.state].filter(Boolean).join(" · "),St=fe.row.fp;return o.jsxs("li",{role:"listitem",className:"lan-twin","data-tone":fe.row.tone,children:[o.jsx("i",{className:fe.row.here?"ap-pulse":"ap-dot","aria-hidden":!0}),It?o.jsx("code",{className:"ap-lan-code lan-twin-at",children:It}):o.jsx("span",{className:"lan-twin-at lan-twin-none",children:"no address here"}),o.jsx("code",{className:"ap-lan-code lan-twin-fp",children:St}),st>0&&y&&o.jsx("button",{type:"button",className:`ap-manage-btn danger lan-twin-do${A===St?" armed":""}`,...J(`unpair:${St}`),onKeyDown:zt=>{zt.repeat&&zt.preventDefault()},onClick:()=>{const zt=Date.now(),In=uh({armedFor:A,target:St,armedAt:T.current,now:zt,gapMs:fh});if(In==="arm"){I(St),T.current=zt;return}In!=="ignore"&&(I(null),V(()=>y(St)))},"aria-label":A===St?`Confirm unpairing ${Et}`:`Unpair ${Et}`,title:A===St?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this one of the machine's decks",children:l===`unpair:${St}`?"unpairing…":A===St?"confirm":"unpair"}),o.jsx("span",{className:"lan-twin-meta",children:st===0?`${Gn} · shown above`:Gn})]},St)})})]})]}),o.jsxs("footer",{className:"lan-peer-foot",children:[e.kind==="asks"&&o.jsx("p",{className:"lan-foot-note",children:"This deck is now asking to pair. Answer it from the panel behind this."}),W&&!($!=null&&$.waiting)&&o.jsx("button",{type:"button",className:"btn",...J(`check:${e.fp}`),onClick:()=>void V(f).then(fe=>{fe&&Y.current&&U(st=>st+1)}),title:"Ask this deck now instead of waiting for the next round",children:l===`check:${e.fp}`?"Checking…":"Check now"}),e.kind==="paired"&&o.jsx("button",{type:"button",className:`btn danger lan-peer-verb${E?" armed":""}`,...J(`unpair:${e.fp}`),onKeyDown:fe=>{fe.repeat&&fe.preventDefault()},onClick:()=>{const fe=Date.now(),st=uh({armedFor:E?e.fp:null,target:e.fp,armedAt:T.current,now:fe,gapMs:fh});if(st==="arm"){C(!0),T.current=fe;return}st!=="ignore"&&(C(!1),V(p))},"aria-label":E?`Confirm unpairing ${e.name}`:`Unpair ${e.name}`,title:E?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this deck from now on",children:l===`unpair:${e.fp}`?"Unpairing…":E?"Confirm unpair":"Unpair"}),e.kind==="nearby"&&o.jsx("button",{type:"button",className:"btn primary lan-peer-verb",...J(`accept:${e.fp}`),onClick:()=>void V(p),title:"Send it a request. Somebody at that machine has to accept it before anything is shared.",children:l===`accept:${e.fp}`?"Asking…":"Ask to pair"}),e.kind==="dialling"&&o.jsx("button",{type:"button",className:"btn lan-peer-verb",...J(`drop:${e.fp}`),onClick:()=>void V(p),title:"Stop trying this address. Nothing was ever paired here.",children:l===`drop:${e.fp}`?"Stopping…":"Stop dialling"}),e.kind==="declined"&&o.jsx("button",{type:"button",className:"btn lan-peer-verb",...J(`allow:${e.fp}`),onClick:()=>void V(p),title:"Take the no back. That deck is still trying, so its request comes round again on its own.",children:l===`allow:${e.fp}`?"Allowing…":"Let it ask again"})]})]})}),document.body)}function IB(e){if(!e.running)return`Tailscale is ${e.state==="Stopped"?"turned off":e.state==="NeedsLogin"||e.state==="NeedsMachineAuth"?"signed out":e.state==="Starting"?"still starting":"not answering"} on this machine`;const t=e.login??"your Tailscale account";return e.on?`${e.devices} online · ${t}`:t}function $B({status:e,accounts:t,onClose:n,onChanged:r}){const a=sn(n),[l,c]=x.useState(null),[u,f]=x.useState(null),[p,h]=x.useState(!1),[m,y]=x.useState(null),w=x.useRef(null),j=X=>{const Y=Fa(m,X);return{disabled:Y.disabled,"aria-busy":Y.busy}},k=x.useRef(null),S=x.useRef(!0);x.useEffect(()=>()=>{S.current=!1},[]),x.useEffect(()=>{k.current=p_(k.current,e.shared??[],null)},[e.shared]);const b=x.useCallback(async(X,Y,M="write")=>{w.current=M,y(M);try{const V=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:X})})).json().catch(()=>null);return S.current?(V!=null&&V.ok?f(null):f(tn(Y,V)),r(),(V==null?void 0:V.ok)===!0):!1}catch{return S.current&&f(tn(Y,null)),!1}finally{w.current=null,S.current&&y(null)}},[r]),N=x.useCallback(async()=>{if(l!=null&&l!==(e.name??"")){if(!await b({name:l},"save the name","name"))return;S.current&&c(null)}n()},[l,e.name,b,n]),E=async()=>{if(!e.fp)return;const X=await sl(e.fp);if(S.current){if(!X){f("Could not copy it — select the fingerprint and copy it by hand.");return}h(!0),window.setTimeout(()=>{S.current&&h(!1)},1600)}},C=new Set(k.current??e.shared??[]),T=e.autoAsk!==!1,A=e.autoAccept!==!1,I=e.shareActive!==!1,B=e.tailscale??null,q=!!(B!=null&&B.on),L=(B==null?void 0:B.ask)!==!1,U=(B==null?void 0:B.accept)!==!1;return Sn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:o.jsxs("div",{ref:a,className:"modal lan-modal",onClick:X=>X.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-modal-title",children:[o.jsxs("header",{className:"modal-head",children:[o.jsx("div",{className:"modal-title",children:o.jsx("span",{id:"lan-modal-title",className:"modal-tool-name",children:"This deck on the network"})}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body",children:[u&&o.jsxs("div",{className:"ap-failure",role:"alert",children:[o.jsx("span",{className:"ap-failure-text",children:u}),o.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>f(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),o.jsxs("div",{className:"modal-section",children:[o.jsx("h3",{className:"lan-h",children:"Name"}),o.jsxs("div",{className:"ap-lan-row",children:[o.jsx("span",{className:"ap-lan-label",children:"appear as"}),o.jsx("input",{className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:l??e.name??"",placeholder:"this machine",onChange:X=>c(X.target.value),onKeyDown:X=>{X.key!=="Enter"||l==null||(b({name:l},"save the name","name"),c(null))}}),l!=null&&l!==(e.name??"")&&o.jsx("button",{type:"button",className:"ap-manage-btn",...j("name"),onClick:()=>{b({name:l},"save the name","name"),c(null)},title:"Save it. This is the name other decks show for this one.",children:"save"})]}),o.jsxs("div",{className:"ap-lan-row",children:[o.jsx("span",{className:"ap-lan-label",children:"fingerprint"}),e.fp?o.jsxs("span",{className:"lan-fp",children:[o.jsx("code",{className:"ap-lan-code",children:e.fp}),o.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void E(),"aria-label":p?"Fingerprint copied":"Copy this deck's fingerprint",children:p?"copied":"copy"})]}):o.jsx("span",{className:"ap-lan-label",children:"not known yet"})]})]}),o.jsxs("div",{className:"modal-section",children:[o.jsx("h3",{className:"lan-h",children:"Share these accounts"}),o.jsxs("div",{className:"ap-lan-picks",children:[t.length===0&&o.jsx("span",{className:"ap-lan-empty",children:"No Claude accounts on this deck yet — add one with + at the top of this panel."}),t.map(X=>o.jsxs("label",{className:"ap-lan-pick",title:X.alive?"Offer this account to the decks you have paired with, so one whose copy has died can heal from yours. Unticking stops it being offered from now on; it does not take back a copy somebody already has.":"This deck cannot use this login, so it has nothing to offer — a deck that can will heal it",children:[o.jsx("input",{type:"checkbox",checked:C.has(X.key),onChange:Y=>{const M=zB(k.current,e.shared??[],X.key,Y.target.checked);k.current=M,b({shared:M},Y.target.checked?"share that account":"stop sharing that account").then(J=>{k.current===M&&(k.current=p_(M,e.shared??[],{ok:J}))})}}),o.jsx("span",{className:"ap-lan-pick-name",children:X.email}),!X.alive&&o.jsx("span",{className:"ap-lan-dead",children:"not working here"})]},X.key))]}),t.length>0&&o.jsxs("div",{className:"lan-switch",children:[o.jsx("span",{className:"lan-switch-what",children:"Show paired decks which of these this deck is using"}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":I,"aria-label":"Show paired decks which of these this deck is using",...j("current"),onClick:()=>void b({shareActive:!I},I?"stop showing which account this deck is using":"show which account this deck is using","current"),title:I?"Stop telling paired decks which account this one is on. They read “current account hidden” instead.":"Tell paired decks which of the ticked accounts this one is on. An unticked account is never named.",children:o.jsx("span",{className:"switch-knob"})})]})]}),o.jsxs("div",{className:"modal-section",children:[o.jsx("h3",{className:"lan-h",children:"Pairing"}),o.jsxs("div",{className:"lan-switches",children:[o.jsxs("div",{className:"lan-switch",children:[o.jsx("span",{className:"lan-switch-what",children:"Ask every deck this one finds"}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":T,"aria-label":"Ask every deck this one finds",...j("ask"),onClick:()=>void b({autoAsk:!T},T?"stop asking automatically":"ask every deck this one finds","ask"),title:T?"Stop sending requests on their own. You press ask on the row instead.":"Send a pairing request to every deck heard on this network. Somebody over there still has to say yes.",children:o.jsx("span",{className:"switch-knob"})})]}),o.jsxs("div",{className:"lan-switch",children:[o.jsx("span",{className:"lan-switch-what",children:"Say yes to every deck that asks"}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":A,"aria-label":"Say yes to every deck that asks","data-tone":"warn",...j("accept"),onKeyDown:X=>{X.repeat&&X.preventDefault()},onClick:()=>void b({autoAccept:!A},A?"stop accepting automatically":"accept every deck that asks","accept"),title:A?"Stop saying yes for you. A deck that asks waits in the panel again.":"Say yes for you. Every deck on this network that asks is paired without anybody being asked here.",children:o.jsx("span",{className:"switch-knob"})})]})]})]}),(B==null?void 0:B.found)&&o.jsxs("div",{className:"modal-section",children:[o.jsx("h3",{className:"lan-h",children:"Tailscale"}),o.jsxs("div",{className:"lan-switches",children:[o.jsxs("div",{className:"lan-switch",children:[o.jsxs("span",{className:"lan-switch-what",children:["Look for my devices",o.jsx("span",{id:"lan-ts-detail",className:"lan-switch-detail",children:IB(B)})]}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":q,"aria-label":"Look for my devices over Tailscale","aria-describedby":"lan-ts-detail",...j("tailscale"),onClick:()=>void b({tailscale:!q},q?"stop looking over Tailscale":"look for your devices over Tailscale","tailscale"),title:q?"Stop. Nothing is looked for or answered over the tailnet; decks already paired stay paired.":"Find the decks on your other machines on Tailscale, wherever they are. Only machines signed in to your Tailscale account are asked.",children:o.jsx("span",{className:"switch-knob"})})]}),q&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"lan-switch",children:[o.jsx("span",{className:"lan-switch-what",children:"Ask each device it finds"}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":L,"aria-label":"Ask each of my devices it finds over Tailscale",...j("tailscale-ask"),onClick:()=>void b({tailscaleAsk:!L},L?"stop asking your devices automatically":"ask your devices automatically","tailscale-ask"),title:L?"Stop sending requests on their own. You press ask on the row instead.":"Send a pairing request to every deck found on your devices over Tailscale.",children:o.jsx("span",{className:"switch-knob"})})]}),o.jsxs("div",{className:"lan-switch",children:[o.jsx("span",{className:"lan-switch-what",children:"Say yes to each device that asks"}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":U,"aria-label":"Say yes to my devices when they ask over Tailscale","data-tone":"warn",...j("tailscale-accept"),onKeyDown:X=>{X.repeat&&X.preventDefault()},onClick:()=>void b({tailscaleAccept:!U},U?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:U?"Stop saying yes for you. A device that asks waits in the panel again.":"Say yes for you when a deck on one of your own devices asks. Anybody else on the tailnet still waits for a press.",children:o.jsx("span",{className:"switch-knob"})})]})]})]})]})]}),o.jsxs("footer",{className:"lan-setup-foot",children:[o.jsx("span",{className:"lan-foot-note",children:"Changes are saved as you make them."}),o.jsx("button",{type:"button",className:"btn primary",...j("name"),onClick:()=>void N(),children:"Done"})]})]})}),document.body)}function xs(e,t){if(e==null)return"not seen";const n=Math.max(0,Math.round((t-e)/1e3));if(n<90)return"now";const r=Math.round(n/60);if(r<60)return`${r}m ago`;const a=Math.round(r/60);return a<48?`${a}h ago`:`${Math.round(a/24)}d ago`}const K0={"waiting for the other deck to accept this one":{text:"waiting for them to say yes",tone:"idle"},"that deck said no":{text:"it said no",tone:"bad"}},OB={ECONNREFUSED:"not listening",EHOSTUNREACH:"no route to it",ENETUNREACH:"no network here",ETIMEDOUT:"no answer",ECONNRESET:"it hung up",EHOSTDOWN:"it is down",ENOTFOUND:"name not found",EACCES:"blocked here",EPIPE:"it hung up"};function LB(e){var r;const t=PB[e];if(t)return t;const n=(r=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:r[1];return n&&OB[n]||e}const PB={"handshake timed out":"no answer","peer closed the connection":"it hung up","peer went quiet":"it stopped mid-sentence","bad reply":"it answered with nonsense","no manifest":"it would not say what it has","bad challenge":"it answered as somebody else","a different deck is answering at that address":"a different deck is at that address","that deck could not prove its own key":"it could not prove who it is","the other deck refused this one's proof":"it would not take this deck's word","the other deck refused this handshake":"it turned this deck away","that deck has this one pinned under a different key":"it knows this deck by another key"};function ZR(e,t){if(!e)return null;if(e.error)return K0[e.error]??{text:LB(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${xs(e.at,t)}`,tone:"idle"};const r=n.filter(l=>l.ok),a=r.length===1?"login":"logins";return r.length===n.length?{text:`${r.length} ${a} arrived · ${xs(e.at,t)}`,tone:"ok"}:{text:`${r.length} of ${n.length} logins arrived · ${xs(e.at,t)}`,tone:"bad"}}const DB=9e4;function FB({error:e,host:t,port:n},r,a,l=45317){if(e!=="handshake timed out")return null;const c=(t??"").trim();if(!c)return null;const u=r.filter(p=>p.addr===c&&p.port&&p.at>0&&a-p.at<DB);if(!u.length)return null;const f=[...new Set(u.map(p=>p.port))];if(n!=null&&!f.includes(n)){const p=f.length===1?`port ${f[0]}`:`ports ${f.join(" and ")}`;return`A deck at ${c} is announcing itself on ${p}, not on ${n}. This deck already hears it and dials it there, so this typed row has nothing to reach.`}return`That machine is running the deck — its beacon arrives here every half minute — and what this deck sends back never gets there. That is a firewall on ${c}, not a network fault. Whoever uses it can allow two ports: UDP ${l} and TCP ${n??f[0]}.`}const e0=5e3,QR=6e4,fh=400;function qB(e){const t=(e??"").trim(),n=t.lastIndexOf(":");if(n<=0||n===t.length-1)return null;const r=t.slice(0,n).trim(),a=Number(t.slice(n+1).trim());return!r||!Number.isInteger(a)||a<1||a>65535||r.includes(":")&&!(r.startsWith("[")&&r.endsWith("]"))?null:{addr:r,port:a}}function tn(e,t){return t==null?`Could not ${e} — the deck did not answer.`:t.reason?`Could not ${e} — the deck refused it (${t.reason}).`:`Could not ${e}.`}function BB(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(r=>n.has(r))}function zB(e,t,n,r){const a=new Set(e??t);return r?a.add(n):a.delete(n),[...a]}function p_(e,t,n){return e==null||n!=null&&!n.ok||BB(e,t)?null:e}function HB(e,t){const n=Math.max(0,Math.round((e-t)/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function JR(e,t){var n,r;return(n=e.last)!=null&&n.error&&!K0[e.last.error]?!1:!!((r=e.last)!=null&&r.at&&t-e.last.at<ph||e.lastSeen!=null&&t-e.lastSeen<ph)}const ph=95e3,eM=160,UB=6,tM=140;function WB(e,t){const n=[],r=[];for(const a of e??[])(JR(a,t)?n:r).push(a);return{online:n,offline:r}}function VB(e){var t;return(t=e.tailscale)!=null&&t.exitNode?"Tailscale sends this machine's local network through an exit node, so decks on this network cannot find this one. Turn on Allow local network access in Tailscale's exit node menu to bring them back.":"This machine sends its local network through a VPN, so decks on this network cannot find this one. Allowing local network access in the VPN brings them back."}function GB(e,t){if(!e)return{text:"checking…",tone:"idle"};if(!e.enabled)return{text:"",tone:"idle"};if(e.stalled)return{text:`could not start — ${e.stalled}`,tone:"bad"};if(!e.running)return{text:"starting…",tone:"wait"};const n=(e.pending??[]).length;if(n)return{text:n===1?"1 deck is waiting for your answer":`${n} decks are waiting for your answer`,tone:"wait"};const r=(e.peers??[]).filter(w=>w.paired!==!1||w.met);if(!r.length)return{text:"no deck paired yet",tone:"idle"};const a=r.filter(w=>w.waiting),l=r.filter(w=>!w.waiting),c=a.filter(w=>{var j;return!((j=w.last)!=null&&j.error)&&w.lastSeen!=null&&t-w.lastSeen<ph}),{online:u,offline:f}=WB(l,t),p=[...f,...a.filter(w=>!c.includes(w))],h=u.length+c.length,m=u.filter(w=>{var j;return((j=w.last)==null?void 0:j.error)==="waiting for the other deck to accept this one"});if(h&&m.length===h)return{text:h===1?"1 deck found · waiting for them to accept":`${h} decks found · waiting for them to accept`,tone:"wait"};if(!h)return{text:p.length===1?"this deck cannot reach the one it is paired with":`this deck cannot reach any of its ${p.length} decks`,tone:"bad"};const y=h===1?"1 deck ready":`${h} decks ready`;return{text:p.length?`${y} · ${p.length} away`:y,tone:"ok"}}function KB(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const r=xs(e,t);return r==="now"?"checked just now":`checked ${r}`}function Y0(e,t){const n=Math.max(0,Math.round((t-e)/1e3));if(n<90)return"just now";const r=Math.round(n/60);return r<60?`${r}m ago`:`${Math.round(r/60)}h ago`}function YB(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=t-e<ph;return{text:n?"online · one-way, it calls in":`one-way · last online ${xs(e,t)}`,here:n}}function m_(e,t,n){return t?"online":e.lastSeen!=null?`last online ${xs(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function XB(e,t){var y,w,j,k,S;if(!e)return[];const n=[],r=new Set,a=(b,N)=>b.name.localeCompare(N.name,void 0,{numeric:!0}),l=e.aliases??{},c=(b,N)=>{const E=b?l[b]:void 0;return E&&E!==N?{name:E,self:N}:{name:N}};for(const b of e.pending??[]){if(!(b!=null&&b.fp)||r.has(b.fp))continue;r.add(b.fp);const N=c(b.fp,b.name||b.fp);n.push({fp:b.fp,name:N.name,...N.self?{self:N.self}:{},addr:b.addr??"",kind:"asks",state:`wants to pair · ${Y0(b.at,t)}`,tone:"wait",here:!0,hint:`${N.name} at ${b.addr}${b.via==="tailscale"?", over Tailscale,":""} is waiting for an answer.`,...b.via==="tailscale"?{via:"tailscale"}:{}})}const u=[],f=[];for(const b of e.peers??[]){const N=b.peerFp??b.fp;if(!N||r.has(N))continue;r.add(N);const E=ZR(b.last,t),C=JR(b,t),T=b.addr?`${b.addr}:${b.port}`:"";if(!b.paired&&b.manual&&!b.met){f.push({fp:T,name:T||b.name||N,addr:b.addr??"",kind:"dialling",state:E?E.text.replace(/ · .*$/,""):"trying…",tone:E?E.tone:"idle",here:!1,hint:(y=b.last)!=null&&y.error?`Nothing has answered at ${T} yet — ${b.last.error}.`:`Dialling ${T} until something answers.`,...b.via==="tailscale"?{via:"tailscale"}:{}});continue}const A=b.waiting?YB(b.lastSeen,t):null,I=A?A.here:C,B=!A&&E?I?`online · ${E.text.replace(/ · .*$/,"")}`:`${E.text.replace(/ · .*$/,"")} · ${m_(b,I,t)}`:A?A.text:m_(b,I,t),q=(w=b.last)!=null&&w.error?K0[b.last.error]:null,L=!A&&I&&!((j=b.last)!=null&&j.error)&&!(((k=b.last)==null?void 0:k.done)??[]).length,U=b.manual&&!b.met?{name:T}:c(N,b.name||N);u.push({fp:N,name:U.name,...U.self?{self:U.self}:{},addr:b.addr??"",kind:"paired",state:B,quiet:L,tone:q?q.tone==="bad"?"bad":"wait":E?E.tone:I?"ok":"idle",here:A?A.here:C,...b.via==="tailscale"?{via:"tailscale"}:{},hint:A?`${U.name} calls this deck, and this deck has no address to call back on — so it can repair its logins from here, and this deck cannot repair from it. ${b.lastSeen==null?"It has not called since this deck started.":`It last called ${xs(b.lastSeen,t)}.`} Add its address with the + at the top of this section to reach it either way.`:`${U.name}${T?` at ${T}`:""}${(S=b.last)!=null&&S.error?` — ${b.last.error}`:""}`})}n.push(...ZB(u).sort(a),...f.sort(a));const p=[];for(const b of e.strangers??[]){if(!(b!=null&&b.fp)||r.has(b.fp))continue;r.add(b.fp);const N=c(b.fp,b.name||b.fp);p.push({fp:b.fp,name:N.name,...N.self?{self:N.self}:{},addr:b.addr??"",kind:"nearby",state:"not paired yet",tone:"idle",here:!0,hint:b.via==="tailscale"?`${N.name} at ${b.addr} is on your tailnet and nothing is shared with it.`:`${N.name} at ${b.addr} is on this network and nothing is shared with it.`,...b.via==="tailscale"?{via:"tailscale"}:{}})}n.push(...p.sort(a));const h=[];for(const b of e.declined??[]){if(!(b!=null&&b.fp)||r.has(b.fp))continue;r.add(b.fp);const N=c(b.fp,b.name||b.fp);h.push({fp:b.fp,name:N.name,...N.self?{self:N.self}:{},addr:b.addr??"",kind:"declined",state:"you said no",tone:"idle",here:!1,hint:`${N.name} asked and was turned away. It is not asking any more.`})}n.push(...h.sort(a));const m=new Map;for(const b of n)m.set(b.name,(m.get(b.name)??0)+1);for(const b of n)(m.get(b.name)??0)<2||!b.addr||(b.state=b.quiet||!b.state?b.addr:`${b.addr} · ${b.state}`,b.quiet=!1);return n}function ZB(e){const t=new Map;for(const r of e){const a=t.get(r.name);a?a.push(r):t.set(r.name,[r])}const n=[];for(const r of t.values()){const a=[...new Set(r.filter(l=>l.addr).map(l=>l.addr))];if(a.length>1){for(const l of a)n.push(g_(r.filter(c=>c.addr===l)));n.push(...r.filter(l=>!l.addr))}else n.push(g_(r))}return n}function g_(e){const[t,...n]=[...e].sort((r,a)=>Number(a.here)-Number(r.here)||+!!a.addr-+!!r.addr);return n.length?{...t,twins:n}:t}function y_(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function w_(e,t){if(!e)return{};switch(t.kind){case"paired":return{peer:(e.peers??[]).find(n=>(n.peerFp??n.fp)===t.fp)??null};case"dialling":return{peer:(e.peers??[]).find(n=>n.manual&&!n.met&&`${n.addr}:${n.port}`===t.fp)??null};case"nearby":return{stranger:(e.strangers??[]).find(n=>n.fp===t.fp)??null};case"declined":return{stranger:(e.declined??[]).find(n=>n.fp===t.fp)??null};case"asks":return{stranger:(e.pending??[]).find(n=>n.fp===t.fp)??null}}}function QB(e,t){const n=/^(\d+)\.(\d+)\.(\d+)/.exec(e??""),r=/^(\d+)\.(\d+)\.(\d+)/.exec(t??"");if(!n||!r)return null;for(let a=1;a<=3;a++){const l=Number(n[a])-Number(r[a]);if(l)return Math.sign(l)}return 0}function JB(e,t,n){const r=t?t.alive?"works here":"expired here":"not on this deck";if(!e.alive){const a=t&&!t.alive?"neither copy works — sign in again here":null;return{there:"broken there",here:r,note:a,tone:a?"bad":"idle"}}return t?t.alive?{there:"works there",here:r,note:null,tone:"ok"}:n?{there:"works there",here:r,note:"repairs next round",tone:"wait"}:{there:"works there",here:r,note:"share it to repair",tone:"bad"}:{there:"works there",here:r,note:"arrives next round",tone:"wait"}}function ez(e,t,n,r=null){const a=new Map(t.map(f=>[f.key,f])),l=new Set(n),c=[],u=new Set;for(const f of e??[]){if(u.has(f.key))continue;u.add(f.key);const p=a.get(f.key)??null,h=l.has(f.key),m=JB(f,p,h),y=p?p.alive?"works":"expired":"missing",w=!f.alive&&p&&!p.alive?m.note:[y==="works"?null:m.here,f.alive?null:m.there,m.note].filter(Boolean).join(" · ")||null;c.push({key:f.key,email:f.email,here:y,there:f.alive?"works":"broken",in:f.alive?m.tone==="wait"?"wait":m.tone==="bad"?"blocked":"live":"cut",out:h&&p?p.alive?"live":"cut":null,caption:w,tone:m.tone,usedThere:r===f.key})}for(const f of n){const p=a.get(f);!p||u.has(f)||(u.add(f),c.push({key:f,email:p.email,here:p.alive?"works":"expired",there:"unknown",in:null,out:p.alive?"live":"cut",caption:p.alive?null:"expired here",tone:p.alive?"ok":"bad",usedThere:!1}))}return c}async function Li(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}function tz({anchorId:e,id:t,rows:n,onHold:r,onLet:a}){const l=x.useRef(null),c=n.filter(y=>y.kind==="paired"),u=c.filter(y=>y.here),f=u.slice(0,UB),p=c.length-u.length,h=u.length>f.length?`and ${u.length-f.length} more`:p>0?`${p} not on right now`:null,m=x.useCallback(()=>{const y=l.current,w=document.getElementById(e);if(!y||!w)return;const j=U0(w.getBoundingClientRect(),{width:y.offsetWidth,height:y.offsetHeight},{width:window.innerWidth,height:window.innerHeight});y.style.top=`${j.top}px`,y.style.left=`${j.left}px`,y.style.maxHeight=j.maxHeight==null?"":`${j.maxHeight}px`,y.dataset.side=j.side},[e]);return x.useLayoutEffect(()=>{m()}),x.useEffect(()=>(window.addEventListener("scroll",m,!0),window.addEventListener("resize",m),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}),[m]),Sn.createPortal(o.jsxs("div",{ref:l,id:t,className:"ap-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:a,children:[o.jsx("p",{className:"ap-peek-title",children:u.length?"On the network now":"Nobody on the network"}),f.length>0&&o.jsx("div",{className:"ap-peek-list",children:f.map(y=>o.jsxs("span",{className:"ap-peek-who",children:[o.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),o.jsxs("span",{children:[y.name,y.via==="tailscale"&&o.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]})]},`${y.kind}:${y.fp}`))}),h&&o.jsx("p",{className:"ap-peek-rest",children:h})]}),document.body)}function nz(e,t){var l;if(!e)return{text:"checking…",tone:"idle",live:!1};if(!e.enabled)return{text:"Off",tone:"idle",live:!1};if(e.stalled)return{text:"could not start",tone:"bad",live:!1};if(!e.running)return{text:"starting…",tone:"wait",live:!1};const n=t.filter(c=>c.kind==="asks").length;if(n)return{text:n===1?"1 deck wants to pair":`${n} decks want to pair`,tone:"wait",live:!1};if((l=e.reach)!=null&&l.blocked)return{text:"nothing can get in",tone:"bad",live:!1};const r=t.filter(c=>c.kind==="paired");if(!r.length)return{text:"On · none paired yet",tone:"idle",live:!1};const a=r.filter(c=>c.here).length;return a?a===r.length?{text:`${a} online`,tone:"ok",live:!0}:{text:`${a} of ${r.length} online`,tone:"ok",live:!0}:{text:`none of ${r.length} online`,tone:"idle",live:!1}}function rz({accounts:e,onChanged:t,view:n,onOpen:r,onBack:a,closeButton:l}){const[c,u]=x.useState(null),[f,p]=x.useState([]),[h,m]=x.useState(null),[y,w]=x.useState(!1),[j,k]=x.useState(null),S=x.useRef(0),[b,N]=x.useState(!1),[E,C]=x.useState(!1),[T,A]=x.useState(!1),I=x.useRef(0);x.useEffect(()=>()=>window.clearTimeout(I.current),[]);const[B,q]=x.useState(!1),[L,U]=x.useState(null),X=x.useRef(null),Y=x.useCallback(le=>Oh(X.current)?(X.current=le,m(le),!0):!1,[]),M=x.useCallback(()=>{X.current=null,z.current&&m(null)},[]),J=le=>{const _e=Fa(h,le);return{disabled:_e.disabled,"aria-busy":_e.busy}},[V,$]=x.useState(()=>Date.now()),z=x.useRef(!0),W=x.useRef(e0),G=x.useCallback(async()=>{var le,_e;try{const[Ie,Ze]=await Promise.all([fetch("/api/lan").then(We=>We.json()),fetch("/api/prefs").then(We=>We.json())]);if(!z.current)return;Ie!=null&&Ie.ok&&u(Ie),Ze!=null&&Ze.ok&&p(Array.isArray((_e=(le=Ze.prefs)==null?void 0:le.lan)==null?void 0:_e.manual)?Ze.prefs.lan.manual:[]),W.current=(Ie==null?void 0:Ie.enabled)===!0?e0:QR}catch{}},[]);x.useEffect(()=>{z.current=!0;let le=0;const _e=async()=>{$(Date.now()),await G(),z.current&&(le=window.setTimeout(_e,W.current))};return _e(),()=>{z.current=!1,window.clearTimeout(le)}},[G]);const F=x.useCallback(async()=>{const le=(c==null?void 0:c.enabled)===!0;if(Y("switch"))try{const _e=await Li("/api/prefs",{lan:{enabled:!le}});if(!z.current)return;_e!=null&&_e.ok?(U(null),le||w(!0)):U(tn(le?"turn this off":"turn this on",_e)),await G()}catch{z.current&&U(tn(le?"turn this off":"turn this on",null))}finally{M()}},[c==null?void 0:c.enabled,G,Y,M]),K=x.useCallback(async(le,_e,Ie)=>{if(!Y(`${le}:${_e}`))return null;let Ze=null;try{const We=await Li("/api/lan/peer",{action:le,fp:_e});if(!z.current)return null;We!=null&&We.ok?(u(We),U(null)):(Ze=tn(Ie,We),U(Ze)),await G()}catch{Ze=tn(Ie,null),z.current&&U(Ze)}finally{M()}return Ze},[G,Y,M]),de=x.useCallback(async le=>{if(!Y(`drop:${le}`))return null;let _e=null;try{const Ie=await Li("/api/prefs",{lan:{manual:f.filter(Ze=>Ze!==le)}});if(!z.current)return null;Ie!=null&&Ie.ok?(U(null),t()):(_e=tn("stop dialling that address",Ie),U(_e)),await G()}catch{_e=tn("stop dialling that address",null),z.current&&U(_e)}finally{M()}return _e},[f,G,t,Y,M]),[H,Q]=x.useState(null),O=x.useCallback(async(le,_e)=>{if(!Y(`alias:${le}`))return"Something else is still being saved. Try again in a moment.";try{const Ie=await Li("/api/lan/peer",{action:"alias",fp:le,name:_e});return z.current?Ie!=null&&Ie.ok?(u(Ie),null):tn("rename that deck",Ie):null}catch{return tn("rename that deck",null)}finally{M()}},[Y,M]),te=x.useCallback(async le=>{if(!Y(`check:${le}`))return null;try{const _e=await Li("/api/lan/sync",{fp:le});return z.current?_e!=null&&_e.ok?(u(_e),t(),null):(_e==null?void 0:_e.reason)==="no_address"?"There is no address here to call it on. It calls this deck, and it is up to date each time it does.":tn("check that deck",_e):null}catch{return tn("check that deck",null)}finally{M()}},[Y,M,t]),ae=x.useCallback(async()=>{if(Y("check"))try{const le=await Li("/api/lan/sync",{});if(!z.current)return;le!=null&&le.ok?(u(le),U(null)):U(tn("check the other decks",le)),t()}catch{z.current&&U(tn("check the other decks",null))}finally{M()}},[Y,M,t]),he=(c==null?void 0:c.enabled)===!0,ge=XB(c,V),Te=H?ge.find(le=>{var _e;return le.fp===H||((_e=le.twins)==null?void 0:_e.some(Ie=>Ie.fp===H))})??null:null;x.useEffect(()=>{H&&c&&!Te&&Q(null)},[H,c,Te]);const De=ge.filter(le=>le.kind==="asks"),Ve=ge.filter(le=>le.kind!=="asks"),je=Ve.filter(le=>le.here),ve=Ve.filter(le=>!le.here),Ue=ve.filter(le=>le.tone==="bad").length,ke=B||je.length===0,xe=GB(c,V),Ge=Ve.filter(le=>le.kind==="paired").length,rt=nz(c,ge),at=o.jsxs(o.Fragment,{children:[b&&c&&o.jsx(_B,{status:c,manual:f,onClose:()=>N(!1),onChanged:()=>{G(),t()}}),E&&o.jsx(KR,{title:"How Local network works",steps:wB,finish:he?void 0:{label:"Turn it on",act:()=>{C(!1),F()}},onClose:()=>C(!1)}),y&&c&&o.jsx($B,{status:{...c,manualRows:f},accounts:e,manual:f,onClose:()=>w(!1),onChanged:()=>{G(),t()}}),Te&&c&&o.jsx(MB,{row:Te,source:w_(c,Te),status:c,accounts:e,now:V,busy:h,onClose:()=>Q(null),onRename:le=>O(Te.fp,le),onCheck:()=>te(Te.fp),onVerb:()=>{switch(Te.kind){case"paired":return K("unpair",Te.fp,"unpair that deck");case"nearby":return K("accept",Te.fp,"reach that deck");case"declined":return K("allow",Te.fp,"let that deck ask again");case"dialling":return de(Te.fp);default:return Promise.resolve(null)}},onSettings:()=>{Q(null),w(!0)},twins:(Te.twins??[]).map(le=>({row:le,peer:w_(c,le).peer??null})),onUnpair:le=>K("unpair",le,"unpair that deck")})]});if(!n){const le=We=>{window.clearTimeout(I.current),I.current=window.setTimeout(()=>A(!0),We)},_e=()=>{window.clearTimeout(I.current),I.current=window.setTimeout(()=>A(!1),tM)},Ie=()=>window.clearTimeout(I.current),Ze=()=>{window.clearTimeout(I.current),A(!1)};return o.jsxs("div",{className:"ap-foot",children:[o.jsxs("button",{type:"button",id:"ap-lan-entry",className:"ap-nav",onClick:()=>{Ze(),r()},"aria-describedby":T?"ap-lan-peek":void 0,onPointerEnter:We=>{We.pointerType==="mouse"&&le(eM)},onPointerLeave:_e,onFocus:We=>{We.target.matches(":focus-visible")&&le(0)},onBlur:_e,children:[o.jsxs("svg",{className:"ap-nav-glyph",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("rect",{x:"1.8",y:"2.3",width:"10.4",height:"7.2",rx:"1.2"}),o.jsx("path",{d:"M5 11.9h4M7 9.5v2.4"})]}),o.jsxs("span",{className:"ap-nav-text",children:[o.jsx("span",{className:"ap-nav-name",children:"Local network"}),o.jsxs("span",{className:"ap-nav-state","data-tone":rt.tone,children:[rt.live&&o.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),rt.text]})]}),o.jsx("svg",{className:"ap-nav-chev",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:o.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),T&&o.jsx(tz,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:ge,onHold:Ie,onLet:_e}),o.jsx("p",{className:"vis-hidden",role:"status",children:xe.tone==="ok"?"":xe.text}),at]})}return o.jsxs("div",{className:"ap-lan-view",children:[o.jsxs("div",{className:"ap-header",children:[o.jsx("button",{type:"button",id:"ap-lan-back",className:"glyph-btn ap-back",onClick:a,"aria-label":"Back to Claude accounts",title:"Back to Claude accounts",children:o.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:o.jsx("path",{d:"M8.4 3.4 4.8 7l3.6 3.6"})})}),o.jsx("h2",{id:"ap-lan-title",children:"Local network"}),o.jsxs("div",{className:"ap-header-right",children:[he&&o.jsx("button",{type:"button",className:"glyph-btn ap-lan-plus",onClick:()=>N(!0),"aria-label":"Add a deck",title:"Reach a deck that has not turned up on its own — by address, or with an invite",children:o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M6.1 7.9a2.6 2.6 0 0 0 3.7 0l1.9-1.9a2.6 2.6 0 0 0-3.7-3.7l-.9.9"}),o.jsx("path",{d:"M7.9 6.1a2.6 2.6 0 0 0-3.7 0L2.3 8a2.6 2.6 0 0 0 3.7 3.7l.9-.9"})]})}),he&&Ge>0&&o.jsx("button",{type:"button",className:"glyph-btn ap-lan-check",...J("check"),onClick:()=>void ae(),"aria-label":h==="check"?"Checking every paired deck":"Check every paired deck now",title:"Ask every paired deck now for anything this deck's expired logins need, instead of waiting for the next round",children:o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("circle",{cx:"7",cy:"7",r:"1.1",fill:"currentColor",stroke:"none"}),o.jsx("path",{d:"M4.6 4.6a3.4 3.4 0 0 0 0 4.8M9.4 4.6a3.4 3.4 0 0 1 0 4.8"}),o.jsx("path",{d:"M2.6 2.6a6.2 6.2 0 0 0 0 8.8M11.4 2.6a6.2 6.2 0 0 1 0 8.8"})]})}),he&&o.jsx("button",{type:"button",className:"glyph-btn ap-lan-set",...J("setup"),onClick:()=>w(!0),"aria-label":"This deck's name and shared logins",title:"This deck's name on the network, and which of its logins it offers",children:o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M1.8 4.7h10.4M1.8 9.3h10.4"}),o.jsx("circle",{cx:"9.1",cy:"4.7",r:"1.6",fill:"var(--panel)"}),o.jsx("circle",{cx:"4.9",cy:"9.3",r:"1.6",fill:"var(--panel)"})]})}),l]})]}),o.jsx("div",{className:"ap-scroll",id:"ap-lan-scroll",children:o.jsxs("div",{className:"ap-lan",children:[o.jsxs("div",{className:"ap-policy",children:[o.jsx("h3",{className:"ap-auto-title",children:"Sync with paired decks"}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":he,"aria-label":"Sync with paired decks",...J("switch"),onClick:()=>void F(),title:he?"Stop talking to other decks. Nothing is shared while this is off.":"Let the decks you pair with repair this one's expired logins",children:o.jsx("span",{className:"switch-knob"})})]}),he&&o.jsx(XR,{reach:c==null?void 0:c.reach,where:"panel"}),he&&(c==null?void 0:c.deaf)&&o.jsx("p",{className:"ap-lan-fine",children:c.deaf}),he&&(c==null?void 0:c.lanTunneled)&&o.jsx("p",{className:"ap-lan-fine",children:VB(c)}),!he&&o.jsxs("button",{type:"button",className:"ap-lan-intro",onClick:()=>C(!0),title:"Four pictures: what this does, and what to do on each machine",children:[o.jsx(vB,{}),o.jsx("span",{className:"ap-lan-intro-text",children:"Paired machines repair each other's expired logins."}),o.jsx("span",{className:"ap-lan-intro-go",children:"See how it works"})]}),o.jsx("p",{className:`ap-lan-status ${xe.tone}`,role:"status",children:xe.tone==="ok"?"":xe.text}),L&&o.jsxs("div",{className:"ap-failure",role:"alert",children:[o.jsx("span",{className:"ap-failure-text",children:L}),o.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>U(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),he&&o.jsxs(o.Fragment,{children:[De.length>0&&o.jsx("div",{className:"ap-lan-asks",role:"alert",children:De.map(le=>o.jsxs("div",{className:"ap-lan-ask",children:[o.jsxs("span",{className:"ap-lan-ask-what",children:[o.jsx("strong",{className:"ap-lan-peer-name",children:le.name})," at ",o.jsx("code",{className:"ap-lan-code",children:le.addr})," wants to pair"]}),o.jsxs("span",{className:"ap-lan-ask-fp",children:["fingerprint ",o.jsx("code",{className:"ap-lan-code",children:le.fp})]}),o.jsxs("span",{className:"ap-lan-ask-acts",children:[o.jsx("button",{type:"button",className:"ap-manage-btn",...J(`accept:${le.fp}`),onClick:()=>void K("accept",le.fp,"accept that deck"),title:`Talk to this deck from now on. Its fingerprint is ${le.fp} — check it matches the one on their screen before you accept.`,children:"accept"}),o.jsx("button",{type:"button",className:"ap-manage-btn",...J(`dismiss:${le.fp}`),onClick:()=>void K("dismiss",le.fp,"decline that request"),title:"Say no. Nothing is shared, and that deck is told rather than left waiting.",children:"decline"})]})]},le.fp))}),(ke?[...je,...ve]:je).length>0&&o.jsx("ul",{className:"ap-lan-here",children:(ke?[...je,...ve]:je).map((le,_e)=>o.jsxs("li",{className:"ap-lan-who","data-tone":le.tone,children:[o.jsx("i",{className:le.here?"ap-pulse":"ap-dot","aria-hidden":!0}),o.jsxs("span",{className:"ap-lan-who-name","aria-hidden":!0,children:[le.name,le.via==="tailscale"&&o.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]}),o.jsx("button",{type:"button",className:"ap-lan-who-open","aria-haspopup":"dialog","aria-describedby":`lan-who-state-${_e}`,onClick:()=>Q(le.fp),children:o.jsxs("span",{className:"vis-hidden",children:[le.name,le.via==="tailscale"?", over Tailscale":"",", details"]})}),o.jsx("span",{id:`lan-who-state-${_e}`,className:le.quiet?"vis-hidden":"ap-lan-who-when",children:le.state}),le.kind==="nearby"&&o.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...J(`accept:${le.fp}`),onClick:()=>void K("accept",le.fp,"reach that deck"),"aria-label":`Ask ${le.name} to pair`,title:`Send ${le.name} a request. Somebody at that machine has to accept it before anything is shared. Its fingerprint is ${le.fp}.`,children:"ask"}),le.kind==="paired"&&o.jsx("button",{type:"button",className:`ap-manage-btn ap-lan-do danger${j===le.fp?" armed":""}`,...J(`unpair:${le.fp}`),onClick:()=>{const Ie=Date.now(),Ze=uh({armedFor:j,target:le.fp,armedAt:S.current,now:Ie,gapMs:fh});if(Ze==="arm"){k(le.fp),S.current=Ie,window.setTimeout(()=>k(We=>We===le.fp?null:We),4e3);return}Ze!=="ignore"&&(k(null),K("unpair",le.fp,"unpair that deck"))},"aria-label":j===le.fp?`Confirm unpairing ${le.name}`:`Unpair ${le.name}`,title:j===le.fp?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this deck from now on",children:j===le.fp?"confirm":"unpair"}),le.kind==="dialling"&&o.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...J(`drop:${le.fp}`),onClick:()=>void de(le.fp),"aria-label":`Stop dialling ${le.name}`,title:"Stop trying this address. Nothing was ever paired here.",children:"stop"}),le.kind==="declined"&&o.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...J(`allow:${le.fp}`),onClick:()=>void K("allow",le.fp,"let that deck ask again"),"aria-label":`Let ${le.name} ask again`,title:"Take the no back. That deck is still trying, so the request comes round again on its own.",children:"allow"})]},`${le.kind}:${le.fp}`))}),(je.length>0&&ve.length>0||he&&Ge>0)&&o.jsxs("div",{className:"ap-lan-tail",children:[je.length>0&&ve.length>0&&o.jsxs("button",{type:"button",className:"ap-lan-word ap-lan-more","aria-expanded":B,onClick:()=>q(le=>!le),title:B?"Show only the decks that are on":`Show the ${ve.length} deck${ve.length===1?"":"s"} that are not responding right now`,children:[o.jsx("span",{className:`ap-lan-chev${B?" open":""}`,"aria-hidden":!0,children:"›"}),B?"fewer":`${ve.length} more`,!B&&Ue>0&&o.jsxs("span",{className:"ap-lan-more-bad",children:[" · ",Ue," not responding"]})]}),he&&Ge>0&&o.jsx("span",{className:"ap-lan-checked",children:KB(c==null?void 0:c.checkedAt,V,h==="check")})]}),Ve.length===0&&De.length===0&&!(c!=null&&c.stalled)&&!(c!=null&&c.deaf)&&!(c!=null&&c.lanTunneled)&&o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"ap-lan-fine",children:"No other deck yet. Decks on one network usually find each other on their own; when that has not happened, the link at the top of this view reaches one by address or by invite."}),o.jsx("button",{type:"button",className:"ap-lan-word ap-lan-how",onClick:()=>C(!0),children:"How it works"})]})]})]})}),at]})}function sz({anchorId:e,id:t,peers:n,onHold:r,onLet:a}){const l=x.useRef(null),{title:c,shown:u,rest:f}=sB(n),p=x.useCallback(()=>{const h=l.current,m=document.getElementById(e);if(!h||!m)return;const y=U0(m.getBoundingClientRect(),{width:h.offsetWidth,height:h.offsetHeight},{width:window.innerWidth,height:window.innerHeight});h.style.top=`${y.top}px`,h.style.left=`${y.left}px`,h.style.maxHeight=y.maxHeight==null?"":`${y.maxHeight}px`,h.dataset.side=y.side},[e]);return x.useLayoutEffect(()=>{p()}),x.useEffect(()=>(window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}),[p]),Sn.createPortal(o.jsxs("div",{ref:l,id:t,className:"ap-peek ap-fold-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:a,children:[o.jsx("p",{className:"ap-peek-title",children:c}),o.jsx("div",{className:"ap-peek-list",children:u.map(h=>o.jsxs("span",{className:"ap-peek-who ap-fold-who",children:[o.jsx("span",{className:"ap-fold-name",children:h.name}),o.jsx("span",{className:"ap-fold-state","data-tone":h.ready?"ok":h.warn?"warn":"idle",children:h.ready?h.headroom==null?"not read yet":`${h.headroom}% free`:h.why})]},h.key))}),f&&o.jsx("p",{className:"ap-peek-rest",children:f})]}),document.body)}function az({peers:e,strained:t,armed:n,threshold:r,open:a,onToggle:l}){const[c,u]=x.useState(!1),f=x.useRef(0);x.useEffect(()=>()=>window.clearTimeout(f.current),[]),x.useEffect(()=>{a&&(window.clearTimeout(f.current),u(!1))},[a]);const p=j=>{a||(window.clearTimeout(f.current),f.current=window.setTimeout(()=>u(!0),j))},h=()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>u(!1),tM)},m=()=>window.clearTimeout(f.current),y=()=>{window.clearTimeout(f.current),u(!1)},w=nB(e,{strained:t&&!a,armed:n,threshold:r});return o.jsxs("div",{className:"ap-rest",children:[o.jsxs("button",{type:"button",id:"ap-rest-entry",className:"ap-nav","aria-expanded":a,"aria-controls":a?"ap-rest-panel":void 0,"aria-describedby":c?"ap-rest-peek":void 0,onClick:()=>{y(),l()},onPointerEnter:j=>{j.pointerType==="mouse"&&p(eM)},onPointerLeave:h,onFocus:j=>{j.target.matches(":focus-visible")&&p(0)},onBlur:h,children:[o.jsxs("span",{className:"ap-nav-text",children:[o.jsx("span",{className:"ap-nav-name",children:"Other accounts"}),o.jsx("span",{className:"ap-nav-state","data-tone":w.tone,children:w.text})]}),o.jsx("svg",{className:"ap-nav-chev",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:o.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),c&&o.jsx(sz,{anchorId:"ap-rest-entry",id:"ap-rest-peek",peers:e,onHold:m,onLet:h})]})}async function oz(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const iz=1800;function lz({accounts:e,onClose:t,copyText:n}){const[r,a]=x.useState([]),[l,c]=x.useState(null),[u,f]=x.useState(!1),[p,h]=x.useState(null),[m,y]=x.useState(!1),[w,j]=x.useState(()=>Math.floor(Date.now()/1e3)),k=x.useRef(null),S=x.useRef(!1),b=sn(t,{focusRef:k});x.useEffect(()=>{if(!l)return;j(Math.floor(Date.now()/1e3));const L=window.setInterval(()=>j(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(L)},[l]);const N=W8(e),E=V8(e,r),C=E.length===e.length,T=L=>a(U=>G8(U,L)),A=x.useCallback(async()=>{const L=K8(E);if(!Ks(S.current)||!L)return;S.current=!0,f(!0),h(null),y(!1);const U=await oz(L).catch(()=>null);if(S.current=!1,f(!1),!(U!=null&&U.ok)){h(zi(U,"the share could not be made"));return}c({blob:U.blob,expiresAt:U.expiresAt,shared:U.shared??[],failed:U.failed??[]})},[e,E]),I=l?GR(l.expiresAt,w):null,B=(I==null?void 0:I.tone)==="gone",q=(l==null?void 0:l.shared.length)??0;return Sn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:o.jsxs("div",{ref:b,className:"modal sa-modal",onClick:L=>L.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Share accounts with another deck",children:[o.jsxs("header",{className:"modal-head",children:[o.jsx("div",{className:"modal-title",children:o.jsx("h3",{children:"Share accounts"})}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsx("section",{className:"modal-body sa-body",children:l?o.jsxs("div",{className:"sa-step",children:[o.jsx("h4",{children:B?"This share has expired":q===1?"1 account, ready to paste":`${q} accounts, ready to paste`}),o.jsx("code",{className:`ap-share-blob${B?" sa-dead":""}`,children:l.blob}),o.jsxs("div",{className:"ap-share-foot",children:[o.jsx("button",{type:"button",className:"ap-manage-btn",ref:k,onClick:async()=>{if(B){c(null),A();return}await n(l.blob)&&(y(!0),window.setTimeout(()=>y(!1),iz))},children:B?"make a new share":m?"copied":`copy ${q===1?"the share":"all "+q}`}),o.jsxs("span",{className:"ap-manage-hint",title:"This text is the sign-in for every account in it. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the logins themselves are in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign those accounts out and back in.",children:[o.jsx("span",{className:"ap-share-warn",children:q===1?"this is the password":`this is ${q} passwords`})," · ",o.jsx("span",{className:`ap-share-expiry ${I==null?void 0:I.tone}`,children:I==null?void 0:I.text})]})]}),l.failed.length>0&&o.jsxs("div",{className:"sa-failed",role:"alert",children:[o.jsx("p",{className:"sa-failed-head",children:l.failed.length===1?"One account is not in this bundle:":`${l.failed.length} accounts are not in this bundle:`}),o.jsx("ul",{className:"sa-list",children:l.failed.map(L=>{var X;const U=!!(L.email&&((X=L.detail)!=null&&X.includes(L.email)));return o.jsxs("li",{children:[!U&&o.jsx("span",{className:"sa-who",children:L.email||`account ${L.num}`}),o.jsx("span",{className:"sa-why",children:L.detail||"could not be exported"})]},`${L.num}-${L.email}`)})})]}),o.jsx("p",{className:"sa-note",children:B?o.jsx(o.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):o.jsxs(o.Fragment,{children:["Paste it into the other deck with ",o.jsx("strong",{children:"+"})," → ",o.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),o.jsxs("div",{className:"sa-actions",children:[o.jsx("button",{type:"button",className:"btn",onClick:()=>{c(null),y(!1)},children:"Pick again"}),o.jsx("button",{type:"button",className:"btn primary",onClick:t,children:"Done"})]})]}):e.length===0?o.jsxs("div",{className:"sa-step",children:[o.jsx("h4",{children:"Nothing to share"}),o.jsxs("p",{className:"sa-note",children:["This deck is not holding any accounts right now. Sign one in with ",o.jsx("strong",{children:"+"}),", or wait — the panel is still reading the store."]}),o.jsx("div",{className:"sa-actions",children:o.jsx("button",{type:"button",className:"btn primary",ref:k,onClick:t,children:"Close"})})]}):o.jsxs("div",{className:"sa-step",children:[o.jsxs("h4",{children:["Which accounts go to the other ",nn,"?"]}),o.jsx("p",{className:`sa-count${E.length?"":" empty"}`,children:Y8(E.length)}),o.jsx("ul",{className:"sa-list sa-pick",children:N.map(L=>o.jsx("li",{children:o.jsxs("label",{className:"sa-row",children:[o.jsx("input",{type:"checkbox",checked:E.includes(L.num),onChange:()=>T(L.num)}),o.jsx("span",{className:"sa-who",children:L.label}),L.sub&&o.jsx("span",{className:"sa-sub",children:L.sub})]})},L.num))}),p&&o.jsx("p",{className:"aa-err",children:p}),o.jsxs("div",{className:"sa-actions",children:[o.jsx("button",{type:"button",className:"btn",onClick:()=>a(C?e.map(L=>L.num):[]),children:C?"Clear all":"Select all"}),o.jsx("button",{type:"button",className:"btn primary",ref:k,...Ma(u,!E.length),onClick:A,children:u?"making the share…":E.length===0?"Share":E.length===1?"Share 1 account":`Share ${E.length} accounts`})]})]})})]})}),document.body)}function cz(e,t){const n=new Set(e),r=e.length?Math.max(...e):0;return[...new Set([...e,r+1])].sort((a,l)=>a-l).map(a=>{const l=a===t?"here":n.has(a)?"swap":"free";return{slot:a,kind:l,label:l==="here"?`slot ${a}`:`slot ${a} · ${l}`}})}function uz(e,t,n){if(!(n!=null&&n.ok))return null;const r=Number.isInteger(n.to)?n.to:null;if(r==null)return{menuFor:null,confirmRemove:null,shareFor:null,swapNote:null};const a=n.swapped===!0&&r!==t;return{menuFor:e.menuFor===t?r:a&&e.menuFor===r?t:e.menuFor,confirmRemove:null,shareFor:null,swapNote:a?{at:r,displaced:t}:null}}function dz(e,t,n){return t!=null&&e.some(r=>r.slot===t)?t:n}function hz(e,t,n){var a;const r=((a=e.find(l=>l.slot===t))==null?void 0:a.kind)??"here";return r==="swap"?{label:"swap",done:"swapped",sends:!0,swaps:!0,title:`Send this account to slot ${t}. That slot is taken, so the two accounts trade places and the one standing there moves to slot ${n}.`}:r==="free"?{label:"move",done:"moved",sends:!0,swaps:!1,title:`Send this account to slot ${t}. That slot is empty, so no other account moves.`}:{label:"move",done:"here",sends:!1,swaps:!1,title:`This account already holds slot ${n}.`}}function fz(e,t){return{label:"save",done:"saved",sends:e!==t,swaps:!1,title:`Switch the active account out once it passes ${e}% of its limit.`}}function v_(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function pz(e){const t=e.filter(u=>!v_(u)),n=e.filter(u=>v_(u)),r=t.length?t:n,a=t.length?n:[],l=r.reduce((u,f)=>u&&u.pct>=f.pct?u:f,null);let c=null;for(const u of a)l&&u.pct<=l.pct||(!c||u.pct>c.pct)&&(c=u);return{shown:r,rest:a,fuller:c,peak:c??l}}const mz="\0";function mh(e){const t=typeof e.email=="string"?e.email.trim():"";if(!t)return`slot:${e.num}`;const n=typeof e.org=="string"?e.org.trim():"";return`acct:${t}${mz}${n}`}function gz(e,t){const n=mh(t);return e.includes(n)?e.filter(r=>r!==n):[...e,n]}function yz(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(mh)),r=e.filter(a=>n.has(a));return r.length===e.length?e:r}const wz=64;function vz(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}const xz=Object.freeze({text:"couldn't reach the deck server",reload:!0}),bz=Object.freeze({text:"still waiting on the deck server — claude-swap can be slow to answer",reload:!0});async function x_(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function kz(e){const t=e.find(r=>!r.ok);if(!t)return null;const n=Bc(t.body);return{text:Xx(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function b_(e,t){return t?e!=null&&e.reload&&e.text===t.text&&e.raw===t.raw?e:t:e!=null&&e.reload?null:e}const k_=15e3,Nz=8e3,_z=1800,Sz=3e4,Vp=[70,80,85,90,95];function Gp(e,t){return CR(t-Math.floor(e/1e3))}function jz(e,t){if(!e)return"";const n=Math.floor(e/1e3)-t;return n<=0?" · due":n<60?` · next in ${n}s`:` · next in ${Math.round(n/60)}m`}function bc(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ez(e,t){const n="The deck can still see this account — its live usage is being read — but claude-swap's own stored copy of the login was rejected, so these numbers stopped updating.";if((e==null?void 0:e.state)==="running")return{text:"resuming…",hint:`${n} The deck is re-capturing it from the login you already have. No sign-in, no switch.`};if((e==null?void 0:e.state)==="failed"){const r=Math.max(1,Math.ceil((e.retryAt/1e3-t)/60)),a=e.reason?`Re-capturing it from the login you already have did not work (${e.reason}).`:"The deck re-captured it from the login you already have, and claude-swap still cannot read it.";return{text:"numbers paused",hint:`${n} ${a} It tries again in ${r}m. No sign-in, no switch.`}}return{text:"numbers paused",hint:n}}function Cz(e){switch(e){case"invalid_grant":case"no_refresh_token":return{text:"login expired",hint:"claude-swap's stored login for this account was rejected and cannot be refreshed. Signing in again replaces it — the account keeps its slot, its alias and its history.",fixable:!0};case"http-401":return{text:"re-login needed",hint:"Anthropic refused this account's token.",fixable:!0};case"http-429":return{text:"rate limited",hint:"Anthropic is throttling requests for this account. It clears on its own.",fixable:!1};case"transient":return{text:"temporary error",hint:"A network or server hiccup while reading usage. The next collection retries.",fixable:!1};case"timeout":return{text:"timed out",hint:"Reading this account's usage took too long. The next collection retries.",fixable:!1};case"network":return{text:"unreachable",hint:"Could not reach Anthropic to read this account's usage.",fixable:!1};default:return{text:e,hint:`claude-swap reported "${e}" for this account.`,fixable:!1}}}function Tz(e){switch(e){case"no_credentials":return{text:"no stored login",hint:"claude-swap holds no credentials for this account, so there is nothing to read its usage with and nothing to switch to. A paired deck that has them sends them on its own; signing in as this account puts them there by hand.",fix:"sign in"};case"relogin_required":return{text:"login expired",hint:"claude-swap's stored login for this account was rejected and cannot be refreshed. Signing in again replaces it — the account keeps its slot, its alias and its history.",fix:"sign in again"};case"keychain_unavailable":return{text:"keychain unreadable",hint:"This is about the deck, not the account: claude-swap could not open your keychain, so it cannot read any account's stored login. A deck started from a background session cannot reach the keychain at all — start it from a terminal, or let it start at login, and this clears."};case"token_expired":return{text:"token expired",hint:"The access token ran out and the refresh was deferred. The next collection retries."};case"foreign_credential":return{text:"wrong credential",hint:"The live credential belongs to a different account. Switching to this one repairs it."};case null:case void 0:return null;default:return{text:e,hint:`claude-swap reported "${e}" for this account.`}}}function $d(e,t){if(e.staleCopy){const n=Ez(e.repair??null,t);return{text:bc(n.text),hint:n.hint,fix:null,tone:"quiet",blocksSwitch:!1}}if(e.stopped){const n=Tz(e.collector??null);if(!n)return{text:"Not collecting",hint:"claude-swap has collected nothing for this account in over half a day and has not said why. A paired deck holding a working copy of this account will replace it on its own. To do it by hand, sign in as this account from + Add.",fix:null,tone:"quiet",blocksSwitch:!1};const r=e.collector==="no_credentials"||e.collector==="relogin_required";return{text:bc(n.text),hint:n.hint,fix:n.fix?bc(n.fix):null,tone:r||e.collector==="keychain_unavailable"?"warn":"quiet",blocksSwitch:r}}if(e.error){const n=Cz(e.error);return{text:bc(n.text),hint:n.hint,fix:n.fixable?"Sign in again":null,tone:n.fixable?"warn":"quiet",blocksSwitch:n.fixable}}return null}function Kp(){return o.jsxs("svg",{className:"ap-warn-glyph",width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M7 1.9 12.9 12H1.1Z"}),o.jsx("path",{d:"M7 5.6v2.9"}),o.jsx("path",{d:"M7 10.3v.05"})]})}function Az(e){return e>=90?"hi":e>=70?"mid":void 0}function Rz(e){const t=Number(e);return[...Number.isFinite(t)&&t>0&&!Vp.includes(t)?[...Vp,t]:Vp].sort((r,a)=>r-a)}function Mz({lane:e,nowSec:t,frozen:n}){const r=Math.min(100,Math.max(0,e.pct)),a=n?"var(--muted)":r>=90?"var(--err)":r>=70?"var(--warn)":"var(--accent)",l=e.resetAt&&!n?TR(e.resetAt,t):null;return o.jsxs("div",{className:"ap-lane",children:[o.jsx("span",{className:"ap-lane-label",title:e.label,children:e.label}),o.jsx("div",{className:"ap-lane-track",children:o.jsx("div",{className:"ap-lane-fill",style:{width:`${r===0?1.5:r}%`,background:a,opacity:r===0||n?.4:1}})}),o.jsxs("span",{className:"ap-lane-pct",style:{color:a},children:[r,"%"]}),o.jsx("span",{className:"ap-lane-reset",title:l?`${e.label} resets in ${l}`:void 0,children:l&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"vis-hidden",children:"resets in "}),l]})})]})}function Iz({onClose:e,leaving:t}){var _s,On,wn;const[n,r]=x.useState(null),[a,l]=x.useState(null),[c,u]=x.useState(null),[f,p]=x.useState(!1),[h,m]=x.useState(null),[y,w]=x.useState(null),[j,k]=x.useState("accounts"),[S,b]=x.useState(!1),[N,E]=x.useState(null),C=x.useRef(N);C.current=N;const[T,A]=x.useState(()=>Math.floor(Date.now()/1e3)),I=x.useRef(null),[B,q]=x.useState(null),L=(B==null?void 0:B.num)??null,U=x.useRef(B);U.current=B;const[X,Y]=x.useState(null),[M,J]=x.useState(!1),[V,$]=x.useState(""),[z,W]=x.useState(null),G=x.useRef(0),[F,K]=x.useState(null),[de,H]=x.useState(!1),[Q,O]=x.useState(!1),[te,ae]=x.useState(null),[he,ge]=x.useState(null),[Te,De]=x.useState(null),[Ve,je]=x.useState(null),[ve,Ue]=x.useState(!1),ke=x.useRef(null),xe=x.useRef(null),[Ge,rt]=x.useState([]),[at,le]=x.useState(!1),_e=x.useRef(null),Ie=x.useCallback(ee=>Oh(_e.current)?(_e.current=ee,u(ee),!0):!1,[]),Ze=x.useCallback(()=>{_e.current=null,u(null)},[]),We=(ee,Ae=!1)=>{const Oe=Fa(c,ee);return{disabled:Oe.disabled,"aria-busy":Oe.busy||Ae}},Je=x.useCallback(ee=>{window.requestAnimationFrame(()=>{var Ae;if(KN(((Ae=document.activeElement)==null?void 0:Ae.tagName)??null))for(const Oe of dq(ee)){const Re=document.querySelector(Oe);if(Re){Re.focus();return}}})},[]),ye=x.useCallback(async(ee=!1)=>{ee&&p(!0);const Ae=new AbortController,Oe=window.setTimeout(()=>Ae.abort(),Sz);try{const[Re,ze]=await Promise.all([fetch(`/api/claude-accounts${ee?"?refresh=1":""}`,{signal:Ae.signal}),fetch("/api/cswap-auto",{signal:Ae.signal})]);if(Re.ok){const yt=await Re.json();r(yt),rt(Ct=>yz(Ct,yt.accounts))}ze.ok&&l(await ze.json());const dt=kz([await x_(Re),await x_(ze)]);m(yt=>b_(yt,dt))}catch{m(Re=>b_(Re,Ae.signal.aborted?bz:xz))}finally{window.clearTimeout(Oe),ee&&p(!1)}},[]),Me=x.useCallback(async(ee,Ae,Oe="panel")=>{if(!Ie(Ae))return null;const Re=Oe==="menu"?Y:m;Re(null);try{const ze=await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ee)}),dt=await ze.json().catch(()=>null);return dt!=null&&dt.ok||Re({text:Xx(dt,"command failed",ze.status),raw:Bc(dt)}),dt}catch{return Re({text:"server unreachable"}),null}finally{Ze()}},[Ie,Ze]),Qe=x.useCallback(async(ee,Ae)=>{if(!Ie(Ae))return null;m(null),Y(null);try{const Oe=await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ee)}),Re=await Oe.json().catch(()=>null);return Re!=null&&Re.ok||Y({text:zi(Re,"command failed",Oe.status)}),Re}catch{return Y({text:"server unreachable"}),null}finally{Ze()}},[Ie,Ze]);x.useEffect(()=>(ye(!0),I.current=window.setInterval(()=>ye(!1),k_),()=>{I.current!=null&&window.clearInterval(I.current)}),[ye]),x.useEffect(()=>{const ee=window.setInterval(()=>A(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(ee)},[]);const ue=((_s=a==null?void 0:a.settings["autoswitch.threshold"])==null?void 0:_s.value)??"90",kt=Ve??ue,pt=fz(kt,ue),ut=(On=n==null?void 0:n.accounts)==null?void 0:On.find(ee=>ee.active),Bt=ut?$d(ut,T):null,jt=(n==null?void 0:n.accounts)??[],vt=ut?jt.filter(ee=>!ee.active):[],an=vt.length?jt.filter(ee=>ee.active):jt,jn=vt.map(ee=>{const Ae=$d(ee,T);return{key:mh(ee),name:ee.alias??ee.email??`account ${ee.num}`,ready:!ee.disabled&&!(Ae!=null&&Ae.blocksSwitch),why:ee.disabled?"held out":Ae!=null&&Ae.blocksSwitch?Ae.text:null,warn:(Ae==null?void 0:Ae.tone)==="warn",headroom:ee.headroom}}),Nt=Number(ue),Yt=(ut==null?void 0:ut.headroom)!=null&&Number.isFinite(Nt)&&100-ut.headroom>=Nt,fe=(a==null?void 0:a.ok)===!0&&(a.enabled||a.external),st=ee=>at&&vt.some(Ae=>Ae.num===ee)?"ap-rest-list":"ap-scroll",It=async(ee,Ae)=>{if(Ie(`switch-${ee}`)){m(null),w(null);try{const Re=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:ee})})).json().catch(()=>null);Re!=null&&Re.ok?w({num:ee,name:Ae}):m({text:Xx(Re,"the switch failed"),raw:Bc(Re),row:ee}),await ye(!0)}catch{m({text:"server unreachable",row:ee})}finally{Ze(),Je(ee)}}},Et=x.useCallback(()=>{q(null),Y(null),W(null),K(null),O(!1)},[]),En=(ee,Ae="first")=>{Et(),E(null),De(null),q({num:ee,view:"menu",start:Ae})},Gn=(ee,Ae)=>{Et(),E(Oe=>(Oe==null?void 0:Oe.anchor)===Ae?null:{num:ee,anchor:Ae})},St=x.useCallback((ee=!1)=>{var Oe;const Ae=C.current;ee&&Ae&&((Oe=document.getElementById(Ae.anchor))==null||Oe.focus()),E(null)},[]),lr=()=>{Et(),E(null),k("lan")},yn=x.useRef(j);x.useEffect(()=>{yn.current!==j&&(yn.current=j,window.requestAnimationFrame(()=>{var ee;(ee=document.getElementById(j==="lan"?"ap-lan-back":"ap-lan-entry"))==null||ee.focus()}))},[j]),x.useEffect(()=>{n!=null&&n.ok&&b(!0)},[n==null?void 0:n.ok]);const Xt=x.useCallback(ee=>{var Re,ze;const Ae=U.current;if(!Ae||ee!=null&&Ae.num!==ee)return;const Oe=document.getElementById(`ap-menu-${Ae.num}`);(Oe!=null&&Oe.contains(document.activeElement)||KN(((Re=document.activeElement)==null?void 0:Re.tagName)??null))&&((ze=document.getElementById(`ap-more-${Ae.num}`))==null||ze.focus()),Et()},[Et]);x.useEffect(()=>{t&&(Et(),E(null))},[t,Et]),x.useEffect(()=>{B&&(n!=null&&n.accounts)&&!n.accounts.some(ee=>ee.num===B.num)&&Et(),N&&(n!=null&&n.accounts)&&!n.accounts.some(ee=>ee.num===N.num)&&E(null)},[n,B,N,Et]);const Cn=async ee=>{var Oe;O(!1);const Ae=await Qe({action:"share",account:ee},`share-${ee}`);!(Ae!=null&&Ae.ok)||((Oe=U.current)==null?void 0:Oe.num)!==ee||(K({num:ee,blob:Ae.blob,expiresAt:Ae.expiresAt}),q({num:ee,view:"share"}))},zt=async(ee,Ae)=>{const{commit:Oe,alias:Re}=vz(V,Ae);if(Oe){const ze=await Qe({action:"alias",account:ee,alias:Re},`alias-${ee}`);if(await ye(!0),!(ze!=null&&ze.ok))return}Xt(ee)},In=async(ee,Ae)=>{var ze,dt;const Oe=await Qe({action:"move",account:ee,slot:Ae},`move-${ee}`),Re=uz({menuFor:((ze=U.current)==null?void 0:ze.num)??null,shareFor:(F==null?void 0:F.num)??null},ee,Oe);if(await ye(!0),Re){((dt=U.current)==null?void 0:dt.num)===ee&&Et(),W(Re.confirmRemove),Re.shareFor==null&&(K(null),O(!1)),ge(Re.swapNote);const yt=Re.swapNote;yt&&window.setTimeout(()=>ge(Ct=>Ct===yt?null:Ct),Nz),De(null),Je(Re.menuFor)}return Oe},Kn=async(ee,Ae,Oe)=>{if(!Oe.sends){Xt(ee);return}await In(ee,Ae)},cr=async(ee,Ae)=>{if(Ae.sends){const Oe=await Me({action:"setting",key:"autoswitch.threshold",value:ee},"threshold");if(await ye(!0),!(Oe!=null&&Oe.ok))return;je(null)}Ue(!0),window.setTimeout(()=>{var Oe;document.activeElement===xe.current&&((Oe=ke.current)==null||Oe.focus()),Ue(!1)},_z)},$n=o.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:o.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:o.jsx("path",{d:"M3.4 3.4l7.2 7.2M10.6 3.4l-7.2 7.2"})})}),ea=ee=>{const{shown:Ae,fuller:Oe}=pz(ee.lanes),Re=$d(ee,T),ze=ee.active||Ge.includes(mh(ee)),dt=ee.alias??ee.email??`account ${ee.num}`,yt=ee.stale||(Re==null?void 0:Re.blocksSwitch)===!0,Ct=Oe?[...Ae,Oe]:Ae,gt=ee.fetchedAt?Gp(ee.fetchedAt,T):null;return o.jsxs("li",{className:`ap-account${ee.active?" active":""}`,"aria-current":ee.active?"true":void 0,"data-open":ze?"":void 0,"data-frozen":yt?"":void 0,children:[!ee.active&&o.jsx("button",{type:"button",className:"ap-row-open",id:`ap-row-${ee.num}`,"aria-expanded":ze,"aria-controls":ze?`ap-detail-${ee.num}`:void 0,"aria-describedby":!ze&&!(Re!=null&&Re.blocksSwitch)?`ap-quota-${ee.num}`:void 0,onClick:()=>rt(xt=>gz(xt,ee)),children:o.jsxs("span",{className:"vis-hidden",children:[dt,", ",ze?"hide details":"details"]})}),o.jsxs("div",{className:"ap-account-head",children:[ee.active?o.jsx("span",{className:"ap-live",title:`Active account · slot ${ee.num}`,children:o.jsxs("span",{className:"vis-hidden",children:["Active account, slot ",ee.num,":"]})}):o.jsx("span",{className:"ap-num",children:ee.num}),ee.alias&&o.jsx("span",{className:"ap-alias",title:ee.alias,children:ee.alias}),o.jsx("span",{className:"ap-email",title:ee.email??void 0,children:ee.email}),ee.disabled&&o.jsx("span",{className:"ap-held",children:"held out"}),!ee.active&&!ee.disabled&&!(Re!=null&&Re.blocksSwitch)&&o.jsx("button",{type:"button",className:"ap-switch",...We(`switch-${ee.num}`),onClick:()=>It(ee.num,dt),"aria-label":`Switch to ${dt}`,title:`Switch to ${ee.alias??ee.email}`,children:c===`switch-${ee.num}`?"…":"Switch"}),o.jsx("button",{type:"button",id:`ap-more-${ee.num}`,className:"ap-more","aria-label":`More actions for ${ee.email??ee.alias??`account ${ee.num}`}`,"aria-haspopup":"menu","aria-expanded":L===ee.num,"aria-controls":L===ee.num?`ap-menu-${ee.num}`:void 0,title:"More actions",onClick:()=>L===ee.num?Xt():En(ee.num),onKeyDown:xt=>{xt.key!=="ArrowDown"&&xt.key!=="ArrowUp"||(xt.preventDefault(),En(ee.num,xt.key==="ArrowUp"?"last":"first"))},children:o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"currentColor","aria-hidden":!0,children:[o.jsx("circle",{cx:"2.8",cy:"7",r:"1.15"}),o.jsx("circle",{cx:"7",cy:"7",r:"1.15"}),o.jsx("circle",{cx:"11.2",cy:"7",r:"1.15"})]})})]}),(h==null?void 0:h.row)===ee.num&&o.jsxs("div",{className:"ap-failure ap-row-failure",role:"alert",children:[o.jsx("span",{className:"ap-failure-text",title:h.raw||void 0,children:h.text}),o.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>m(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),ee.active&&(y==null?void 0:y.num)===ee.num&&o.jsx("p",{className:"ap-switched",children:"Now active. New sessions start on it; ones already running pick it up on their next message, up to about 30 seconds later on macOS."}),(he==null?void 0:he.at)===ee.num&&(()=>{const xt=jt.find(Ss=>Ss.num===he.displaced),Ar=(xt==null?void 0:xt.alias)??(xt==null?void 0:xt.email)??"the account that was there";return o.jsxs("p",{className:"ap-note ap-swap-note",title:`Slot ${he.at} was taken, so the two accounts traded places: ${Ar} now holds slot ${he.displaced}.`,children:["swapped with slot ",he.displaced]})})(),Re&&o.jsxs("div",{className:"ap-issue-line",children:[o.jsxs("button",{type:"button",id:`ap-issue-${ee.num}`,className:"ap-issue","data-tone":Re.tone,"aria-haspopup":"dialog","aria-expanded":(N==null?void 0:N.anchor)===`ap-issue-${ee.num}`,"aria-controls":(N==null?void 0:N.anchor)===`ap-issue-${ee.num}`?"ap-issue-pop":void 0,onClick:()=>Gn(ee.num,`ap-issue-${ee.num}`),children:[Re.tone==="warn"&&o.jsx(Kp,{}),o.jsx("span",{className:"ap-issue-text",children:Re.text})]}),!ze&&o.jsx("span",{className:"ap-issue-age",title:"When claude-swap last read this account's usage",children:gt??"never collected"})]}),!ze&&!(Re!=null&&Re.blocksSwitch)&&o.jsxs("p",{className:"ap-quota",id:`ap-quota-${ee.num}`,children:[Ct.length?Ct.map(xt=>o.jsxs("span",{className:"ap-q",children:[o.jsx("span",{className:"ap-q-label",children:xt.label})," ",o.jsxs("span",{className:"ap-q-pct","data-level":yt?void 0:Az(xt.pct),children:[Math.round(xt.pct),"%"]})]},xt.id)):o.jsx("span",{className:"ap-q-label",children:"no usage recorded yet"}),ee.stale&&!Re&&o.jsx("span",{className:"ap-q-age","data-never":gt?void 0:"",title:"When claude-swap last read this account's usage",children:gt??"never collected"})]}),ze&&o.jsxs("div",{className:"ap-detail",id:`ap-detail-${ee.num}`,children:[o.jsx("div",{className:"ap-lanes",children:ee.lanes.length?ee.lanes.map(xt=>o.jsx(Mz,{lane:xt,nowSec:T,frozen:yt},xt.id)):o.jsx("div",{className:"ap-hint",children:"No usage recorded yet."})}),o.jsx("div",{className:"ap-meta",children:ee.fetchedAt?o.jsxs("span",{className:`ap-age${ee.stale&&!Re?" ap-stale":""}`,title:"When claude-swap last read this account's usage, and when it plans to read it again. It sets that interval itself — 3 minutes at the fastest, wider while an account is recovering from a rate limit — and every surface, including `cswap watch`, follows the same plan.",children:["collected ",Gp(ee.fetchedAt,T),Re!=null&&Re.blocksSwitch?"":jz(ee.nextAt,T)]}):o.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})})]})]},ee.num)},ta=n!=null&&n.ok&&(a!=null&&a.ok)?o.jsxs("div",{className:"ap-policy-block",children:[o.jsxs("div",{className:"ap-policy",children:[o.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),o.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:o.jsx("select",{ref:ke,"aria-label":"Switch threshold",value:kt,...We("threshold"),onChange:ee=>je(ee.target.value),children:Rz(ue).map(ee=>o.jsxs("option",{value:ee,children:[ee,"%"]},ee))})}),(pt.sends||ve)&&o.jsx("button",{ref:xe,type:"button",className:"ap-manage-btn",...We("threshold"),title:pt.title,onClick:()=>cr(kt,pt),children:ve&&!pt.sends?pt.done:pt.label}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":a.enabled,"aria-label":"Auto-switch",...We("enable"),onClick:()=>Me({action:"enable",enabled:!a.enabled},"enable").then(()=>ye(!0)),title:a.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:o.jsx("span",{className:"switch-knob"})})]}),a.external&&o.jsxs("p",{className:"ap-auto-note",children:[o.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",o.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",a.enabled?" — this toggle takes over when you stop it.":"."]})]}):null;return o.jsxs("aside",{className:`accounts-panel${t?" leaving":""}`,id:"accounts-panel","aria-label":"Claude accounts",children:[j==="accounts"&&o.jsxs("div",{className:"ap-header",children:[o.jsx("h2",{children:"Claude accounts"}),o.jsxs("div",{className:"ap-header-right",children:[o.jsx("button",{type:"button",className:"glyph-btn ap-add",onClick:()=>J(!0),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:o.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:o.jsx("path",{d:"M7 2.2v9.6M2.2 7h9.6"})})}),(((wn=n==null?void 0:n.accounts)==null?void 0:wn.length)??0)>0&&o.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>H(!0),"aria-label":"Share accounts with another deck",title:`Copy several accounts to another ${nn} in one paste. The text carries a live login for each one — treat it as those passwords.`,children:o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M3.3 10.7L10.7 3.3"}),o.jsx("path",{d:"M5.5 3.3h5.2v5.2"})]})}),o.jsx("button",{type:"button",className:"glyph-btn ap-refresh",onClick:()=>ye(!0),...We("reload",f),"aria-label":"Reload accounts",title:"Reload from claude-swap",children:o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),o.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}),$n]})]}),j==="accounts"&&o.jsx("div",{className:"ap-scroll",id:"ap-scroll",children:n==null?h?o.jsxs("div",{className:"ap-empty",role:"alert",children:[o.jsx("span",{title:h.raw||void 0,children:h.text}),o.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",k_/1e3," seconds."]}),o.jsx("button",{type:"button",className:"ap-fix",disabled:f,onClick:()=>ye(!0),children:f?"trying…":"try again"})]}):o.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?o.jsxs(o.Fragment,{children:[ut&&(Bt==null?void 0:Bt.tone)==="warn"&&o.jsxs("div",{className:"ap-notice",children:[o.jsxs("button",{type:"button",id:"ap-notice",className:"ap-issue","data-tone":"warn","aria-haspopup":"dialog","aria-expanded":(N==null?void 0:N.anchor)==="ap-notice","aria-controls":(N==null?void 0:N.anchor)==="ap-notice"?"ap-issue-pop":void 0,onClick:()=>Gn(ut.num,"ap-notice"),children:[o.jsx(Kp,{}),o.jsx("span",{className:"ap-issue-text",children:"Current account needs attention"})]}),Bt.fix&&o.jsx("button",{type:"button",className:"ap-notice-fix",onClick:()=>J(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"Sign in"})]}),o.jsx("ul",{className:"ap-list",children:an.map(ea)}),vt.length>0&&o.jsx(az,{peers:jn,strained:Yt,armed:fe,threshold:a!=null&&a.ok?ue:null,open:at,onToggle:()=>le(ee=>!ee)}),vt.length>0&&at&&o.jsxs("div",{className:"ap-rest-panel",id:"ap-rest-panel",children:[o.jsx("ul",{className:"ap-list ap-others",id:"ap-rest-list",children:vt.map(ea)}),ta]}),vt.length===0&&ta,h&&h.row==null&&o.jsxs("div",{className:"ap-failure",role:"alert",children:[o.jsx("span",{className:"ap-failure-text",title:h.raw||void 0,children:h.text}),o.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>m(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),B&&(()=>{var Re;const ee=(Re=n.accounts)==null?void 0:Re.find(ze=>ze.num===B.num);if(!ee)return null;const Ae=`ap-pop-title-${ee.num}`,Oe=X&&o.jsx("p",{className:"ap-pop-error",role:"alert",title:X.raw||void 0,children:X.text});return o.jsxs(Kx,{anchorId:`ap-more-${ee.num}`,boundaryId:st(ee.num),id:`ap-menu-${ee.num}`,className:"ap-pop",role:B.view==="menu"?"menu":"dialog",labelledBy:B.view==="menu"?`ap-more-${ee.num}`:Ae,start:B.start,onClose:Et,children:[B.view==="menu"&&o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>{$(ee.alias??""),Y(null),q({num:ee.num,view:"rename"})},children:"Rename"}),o.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>{De(null),Y(null),q({num:ee.num,view:"move"})},children:"Move to slot…"}),o.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...We(`share-${ee.num}`),title:`Copy this account to another ${nn}. Anyone who has the text can use the account — treat it as the password. The other deck stops accepting it after 10 minutes; that does not make an escaped copy safe.`,onClick:()=>Cn(ee.num),children:c===`share-${ee.num}`?"Sharing…":"Share"}),o.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",title:"See how much this account worked in each project",onClick:()=>{ae(ee.num),Xt(ee.num)},children:"Projects"}),(((a==null?void 0:a.enabled)||(a==null?void 0:a.external))&&!ee.active||ee.disabled)&&o.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...We(`rot-${ee.num}`),title:ee.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",onClick:()=>Me({action:"account",account:ee.num,enabled:ee.disabled},`rot-${ee.num}`,"menu").then(ze=>{ye(!0),ze!=null&&ze.ok&&Xt(ee.num)}),children:ee.disabled?"Put back in rotation":"Hold out of rotation"}),o.jsx("div",{role:"separator",className:"ap-menu-sep"}),o.jsx("button",{type:"button",role:"menuitem",className:`ap-menu-item danger${z===ee.num?" armed":""}`,...We(`rm-${ee.num}`),"aria-label":z===ee.num?"Confirm remove":void 0,title:z===ee.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{const ze=Date.now(),dt=uh({armedFor:z,target:ee.num,armedAt:G.current,now:ze,gapMs:fh});if(dt==="arm"){W(ee.num),G.current=ze,window.setTimeout(()=>W(yt=>yt===ee.num?null:yt),4e3);return}dt!=="ignore"&&(W(null),Qe({action:"remove",account:ee.num},`rm-${ee.num}`).then(yt=>{var Ct;ye(!0),yt!=null&&yt.ok&&(((Ct=U.current)==null?void 0:Ct.num)===ee.num&&Et(),Je(null))}))},children:c===`rm-${ee.num}`?"Removing…":z===ee.num?"Confirm":"Remove"}),Oe]}),B.view==="rename"&&o.jsxs("form",{className:"ap-pop-form",onSubmit:ze=>{ze.preventDefault(),zt(ee.num,ee.alias)},children:[o.jsx("label",{className:"ap-pop-title",id:Ae,htmlFor:`ap-alias-${ee.num}`,children:"Rename account"}),o.jsx("input",{id:`ap-alias-${ee.num}`,className:"ap-manage-input",type:"text",value:V,onChange:ze=>$(ze.target.value),maxLength:wz,placeholder:"e.g. work",spellCheck:!1,autoComplete:"off",autoFocus:!0,onFocus:ze=>ze.currentTarget.select()}),Oe,o.jsxs("div",{className:"ap-pop-actions",children:[o.jsx("button",{type:"button",className:"btn",onClick:()=>Xt(),children:"Cancel"}),o.jsx("button",{type:"submit",className:"btn primary",...We(`alias-${ee.num}`),title:"A short name to show instead of the email",children:c===`alias-${ee.num}`?"…":"Save"})]})]}),B.view==="move"&&(()=>{const ze=cz((n.accounts??[]).map(Ct=>Ct.num),ee.num),dt=dz(ze,Te,ee.num),yt=hz(ze,dt,ee.num);return o.jsxs("div",{className:"ap-pop-form",children:[o.jsx("label",{className:"ap-pop-title",id:Ae,htmlFor:`ap-slot-${ee.num}`,children:"Move to slot"}),o.jsx("span",{className:"ap-field",children:o.jsx("select",{id:`ap-slot-${ee.num}`,value:String(dt),...We(`move-${ee.num}`),onChange:Ct=>De(Number(Ct.target.value)),autoFocus:!0,children:ze.map(Ct=>o.jsx("option",{value:Ct.slot,children:Ct.label},Ct.slot))})}),Oe,o.jsxs("div",{className:"ap-pop-actions",children:[o.jsx("button",{type:"button",className:"btn",onClick:()=>Xt(),children:"Cancel"}),o.jsx("button",{type:"button",className:"btn primary",...We(`move-${ee.num}`),title:yt.title,onClick:()=>Kn(ee.num,dt,yt),children:c===`move-${ee.num}`?"…":bc(yt.label)})]})]})})(),B.view==="share"&&(F==null?void 0:F.num)===ee.num&&(()=>{const ze=GR(F.expiresAt,T),dt=ze.tone==="gone";return o.jsxs("div",{className:`ap-pop-form ap-share${dt?" expired":""}`,children:[o.jsx("p",{className:"ap-pop-title",id:Ae,children:"Share account"}),o.jsx("code",{className:"ap-share-blob",children:F.blob}),o.jsxs("p",{className:"ap-pop-note",title:"This text is the account's password. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the login itself is in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign the account out and back in.",children:[o.jsx("span",{className:"ap-share-warn",children:"This is the password"})," · ",o.jsx("span",{className:`ap-share-expiry ${ze.tone}`,children:ze.text})]}),Oe,o.jsxs("div",{className:"ap-pop-actions",children:[o.jsx("button",{type:"button",className:"btn",onClick:()=>Xt(),children:"Done"}),o.jsx("button",{type:"button",className:"btn primary",...We(`share-${ee.num}`),autoFocus:!0,onClick:async()=>{if(dt){await Cn(ee.num);return}await sl(F.blob)&&(O(!0),window.setTimeout(()=>O(!1),1800))},children:dt?"Make a new share":Q?"Copied":"Copy"})]})]})})()]})})(),N&&(()=>{var Oe;const ee=(Oe=n.accounts)==null?void 0:Oe.find(Re=>Re.num===N.num),Ae=ee?$d(ee,T):null;return!ee||!Ae?null:o.jsx(Kx,{anchorId:N.anchor,boundaryId:N.anchor==="ap-notice"?"ap-scroll":st(ee.num),id:"ap-issue-pop",className:"ap-pop ap-issue-pop",role:"dialog",labelledBy:"ap-issue-title",onClose:()=>St(),children:o.jsxs("div",{className:"ap-pop-form",children:[o.jsxs("p",{className:"ap-pop-title ap-issue-title",id:"ap-issue-title","data-tone":Ae.tone,children:[Ae.tone==="warn"&&o.jsx(Kp,{}),Ae.text]}),o.jsx("p",{className:"ap-pop-note ap-issue-hint",children:Ae.hint}),o.jsxs("p",{className:"ap-pop-note ap-issue-when",children:[o.jsx("span",{className:"ap-issue-who",children:ee.alias??ee.email??`account ${ee.num}`})," · ",ee.fetchedAt?`last collected ${Gp(ee.fetchedAt,T)}`:"never collected"]}),o.jsxs("div",{className:"ap-pop-actions",children:[o.jsx("button",{type:"button",className:"btn",onClick:()=>St(!0),children:"Done"}),Ae.fix&&o.jsx("button",{type:"button",className:"btn primary",onClick:()=>{St(!0),J(!0)},title:"Open the sign-in dialog. Signing in as this account puts its login back in this slot — it keeps its slot, its alias and its history.",children:Ae.fix})]})]})})})()]}):o.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"claude-swap isn't installed."}),o.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),n.hint&&o.jsx("code",{className:"ap-cmd",children:n.hint}),o.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",o.jsx("strong",{children:"+"})," button above."]})]}):n.reason==="no_accounts"?o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"No accounts added yet."}),o.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",o.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"Couldn't read the account store."}),o.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})})}),o.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:y?`Now active: ${y.name}`:""}),S&&o.jsx(rz,{accounts:((n==null?void 0:n.accounts)??[]).map(ee=>({key:`${String(ee.email??"").trim().toLowerCase()}@@${ee.orgUuid??""}`,email:ee.email??"",alive:ee.alive===!0})),onChanged:()=>ye(!0),view:j==="lan",onOpen:lr,onBack:()=>k("accounts"),closeButton:$n}),M&&o.jsx(eB,{onClose:()=>J(!1),onChanged:()=>ye(!0)}),de&&o.jsx(lz,{accounts:((n==null?void 0:n.accounts)??[]).map(ee=>({num:ee.num,email:ee.email,alias:ee.alias,org:ee.org})),onClose:()=>H(!1),copyText:sl}),te!=null&&(()=>{const ee=((n==null?void 0:n.accounts)??[]).find(Ae=>Ae.num===te);return ee?o.jsx(v8,{num:ee.num,name:ee.alias??ee.email??`account ${ee.num}`,onClose:()=>ae(null)}):(ae(null),null)})()]})}const $z=3e4;function Oz({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function Lz({bundle:e,running:t,pending:n,lastTried:r}){return t?Oz({bundle:e,running:t,lastTried:r})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function Pz(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function Dz({asked:e,reported:t}){return t?t!==e:!1}function nM(e){const t=e.thresholdMs??$z;return!e.enabled||e.kind!=="restart"||!e.canRestart||!e.noticeOpen||!e.visible||e.busy?null:e.idleSince==null||e.now<e.idleSince?t:Math.max(0,t-(e.now-e.idleSince))}function Fz(e){const t=Math.max(0,Math.ceil(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function qz(e,t){return e?t==null?"auto when idle":`auto in ${Fz(t)}`:"auto-restart off"}function N_(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function Bz(e){return e<=0?{label:"Restart now",clause:"nothing is running"}:{label:"Restart anyway",clause:`${e===1?"1 agent is running":`${e} agents are running`} — their events during the restart are lost`}}function zz(e){const t=nM(e);return t==null?{idleSince:null,restart:!1,remainingMs:null}:e.idleSince==null||e.now<e.idleSince?{idleSince:e.now,restart:!1,remainingMs:t}:{idleSince:e.idleSince,restart:t===0,remainingMs:t}}function X0(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Yp,__;function Hz(){if(__)return Yp;__=1;function e(){this.__data__=[],this.size=0}return Yp=e,Yp}var Xp,S_;function hl(){if(S_)return Xp;S_=1;function e(t,n){return t===n||t!==t&&n!==n}return Xp=e,Xp}var Zp,j_;function Dh(){if(j_)return Zp;j_=1;var e=hl();function t(n,r){for(var a=n.length;a--;)if(e(n[a][0],r))return a;return-1}return Zp=t,Zp}var Qp,E_;function Uz(){if(E_)return Qp;E_=1;var e=Dh(),t=Array.prototype,n=t.splice;function r(a){var l=this.__data__,c=e(l,a);if(c<0)return!1;var u=l.length-1;return c==u?l.pop():n.call(l,c,1),--this.size,!0}return Qp=r,Qp}var Jp,C_;function Wz(){if(C_)return Jp;C_=1;var e=Dh();function t(n){var r=this.__data__,a=e(r,n);return a<0?void 0:r[a][1]}return Jp=t,Jp}var em,T_;function Vz(){if(T_)return em;T_=1;var e=Dh();function t(n){return e(this.__data__,n)>-1}return em=t,em}var tm,A_;function Gz(){if(A_)return tm;A_=1;var e=Dh();function t(n,r){var a=this.__data__,l=e(a,n);return l<0?(++this.size,a.push([n,r])):a[l][1]=r,this}return tm=t,tm}var nm,R_;function Fh(){if(R_)return nm;R_=1;var e=Hz(),t=Uz(),n=Wz(),r=Vz(),a=Gz();function l(c){var u=-1,f=c==null?0:c.length;for(this.clear();++u<f;){var p=c[u];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=r,l.prototype.set=a,nm=l,nm}var rm,M_;function Kz(){if(M_)return rm;M_=1;var e=Fh();function t(){this.__data__=new e,this.size=0}return rm=t,rm}var sm,I_;function Yz(){if(I_)return sm;I_=1;function e(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}return sm=e,sm}var am,$_;function Xz(){if($_)return am;$_=1;function e(t){return this.__data__.get(t)}return am=e,am}var om,O_;function Zz(){if(O_)return om;O_=1;function e(t){return this.__data__.has(t)}return om=e,om}var im,L_;function rM(){if(L_)return im;L_=1;var e=typeof gd=="object"&&gd&&gd.Object===Object&&gd;return im=e,im}var lm,P_;function ts(){if(P_)return lm;P_=1;var e=rM(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return lm=n,lm}var cm,D_;function fl(){if(D_)return cm;D_=1;var e=ts(),t=e.Symbol;return cm=t,cm}var um,F_;function Qz(){if(F_)return um;F_=1;var e=fl(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,a=e?e.toStringTag:void 0;function l(c){var u=n.call(c,a),f=c[a];try{c[a]=void 0;var p=!0}catch{}var h=r.call(c);return p&&(u?c[a]=f:delete c[a]),h}return um=l,um}var dm,q_;function Jz(){if(q_)return dm;q_=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return dm=n,dm}var hm,B_;function Bo(){if(B_)return hm;B_=1;var e=fl(),t=Qz(),n=Jz(),r="[object Null]",a="[object Undefined]",l=e?e.toStringTag:void 0;function c(u){return u==null?u===void 0?a:r:l&&l in Object(u)?t(u):n(u)}return hm=c,hm}var fm,z_;function Cr(){if(z_)return fm;z_=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return fm=e,fm}var pm,H_;function Jc(){if(H_)return pm;H_=1;var e=Bo(),t=Cr(),n="[object AsyncFunction]",r="[object Function]",a="[object GeneratorFunction]",l="[object Proxy]";function c(u){if(!t(u))return!1;var f=e(u);return f==r||f==a||f==n||f==l}return pm=c,pm}var mm,U_;function eH(){if(U_)return mm;U_=1;var e=ts(),t=e["__core-js_shared__"];return mm=t,mm}var gm,W_;function tH(){if(W_)return gm;W_=1;var e=eH(),t=(function(){var r=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""})();function n(r){return!!t&&t in r}return gm=n,gm}var ym,V_;function sM(){if(V_)return ym;V_=1;var e=Function.prototype,t=e.toString;function n(r){if(r!=null){try{return t.call(r)}catch{}try{return r+""}catch{}}return""}return ym=n,ym}var wm,G_;function nH(){if(G_)return wm;G_=1;var e=Jc(),t=tH(),n=Cr(),r=sM(),a=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,c=Function.prototype,u=Object.prototype,f=c.toString,p=u.hasOwnProperty,h=RegExp("^"+f.call(p).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!n(y)||t(y))return!1;var w=e(y)?h:l;return w.test(r(y))}return wm=m,wm}var vm,K_;function rH(){if(K_)return vm;K_=1;function e(t,n){return t==null?void 0:t[n]}return vm=e,vm}var xm,Y_;function zo(){if(Y_)return xm;Y_=1;var e=nH(),t=rH();function n(r,a){var l=t(r,a);return e(l)?l:void 0}return xm=n,xm}var bm,X_;function Z0(){if(X_)return bm;X_=1;var e=zo(),t=ts(),n=e(t,"Map");return bm=n,bm}var km,Z_;function qh(){if(Z_)return km;Z_=1;var e=zo(),t=e(Object,"create");return km=t,km}var Nm,Q_;function sH(){if(Q_)return Nm;Q_=1;var e=qh();function t(){this.__data__=e?e(null):{},this.size=0}return Nm=t,Nm}var _m,J_;function aH(){if(J_)return _m;J_=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return _m=e,_m}var Sm,eS;function oH(){if(eS)return Sm;eS=1;var e=qh(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function a(l){var c=this.__data__;if(e){var u=c[l];return u===t?void 0:u}return r.call(c,l)?c[l]:void 0}return Sm=a,Sm}var jm,tS;function iH(){if(tS)return jm;tS=1;var e=qh(),t=Object.prototype,n=t.hasOwnProperty;function r(a){var l=this.__data__;return e?l[a]!==void 0:n.call(l,a)}return jm=r,jm}var Em,nS;function lH(){if(nS)return Em;nS=1;var e=qh(),t="__lodash_hash_undefined__";function n(r,a){var l=this.__data__;return this.size+=this.has(r)?0:1,l[r]=e&&a===void 0?t:a,this}return Em=n,Em}var Cm,rS;function cH(){if(rS)return Cm;rS=1;var e=sH(),t=aH(),n=oH(),r=iH(),a=lH();function l(c){var u=-1,f=c==null?0:c.length;for(this.clear();++u<f;){var p=c[u];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=r,l.prototype.set=a,Cm=l,Cm}var Tm,sS;function uH(){if(sS)return Tm;sS=1;var e=cH(),t=Fh(),n=Z0();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return Tm=r,Tm}var Am,aS;function dH(){if(aS)return Am;aS=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return Am=e,Am}var Rm,oS;function Bh(){if(oS)return Rm;oS=1;var e=dH();function t(n,r){var a=n.__data__;return e(r)?a[typeof r=="string"?"string":"hash"]:a.map}return Rm=t,Rm}var Mm,iS;function hH(){if(iS)return Mm;iS=1;var e=Bh();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return Mm=t,Mm}var Im,lS;function fH(){if(lS)return Im;lS=1;var e=Bh();function t(n){return e(this,n).get(n)}return Im=t,Im}var $m,cS;function pH(){if(cS)return $m;cS=1;var e=Bh();function t(n){return e(this,n).has(n)}return $m=t,$m}var Om,uS;function mH(){if(uS)return Om;uS=1;var e=Bh();function t(n,r){var a=e(this,n),l=a.size;return a.set(n,r),this.size+=a.size==l?0:1,this}return Om=t,Om}var Lm,dS;function Q0(){if(dS)return Lm;dS=1;var e=uH(),t=hH(),n=fH(),r=pH(),a=mH();function l(c){var u=-1,f=c==null?0:c.length;for(this.clear();++u<f;){var p=c[u];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=r,l.prototype.set=a,Lm=l,Lm}var Pm,hS;function gH(){if(hS)return Pm;hS=1;var e=Fh(),t=Z0(),n=Q0(),r=200;function a(l,c){var u=this.__data__;if(u instanceof e){var f=u.__data__;if(!t||f.length<r-1)return f.push([l,c]),this.size=++u.size,this;u=this.__data__=new n(f)}return u.set(l,c),this.size=u.size,this}return Pm=a,Pm}var Dm,fS;function zh(){if(fS)return Dm;fS=1;var e=Fh(),t=Kz(),n=Yz(),r=Xz(),a=Zz(),l=gH();function c(u){var f=this.__data__=new e(u);this.size=f.size}return c.prototype.clear=t,c.prototype.delete=n,c.prototype.get=r,c.prototype.has=a,c.prototype.set=l,Dm=c,Dm}var Fm,pS;function J0(){if(pS)return Fm;pS=1;function e(t,n){for(var r=-1,a=t==null?0:t.length;++r<a&&n(t[r],r,t)!==!1;);return t}return Fm=e,Fm}var qm,mS;function aM(){if(mS)return qm;mS=1;var e=zo(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return qm=t,qm}var Bm,gS;function Hh(){if(gS)return Bm;gS=1;var e=aM();function t(n,r,a){r=="__proto__"&&e?e(n,r,{configurable:!0,enumerable:!0,value:a,writable:!0}):n[r]=a}return Bm=t,Bm}var zm,yS;function Uh(){if(yS)return zm;yS=1;var e=Hh(),t=hl(),n=Object.prototype,r=n.hasOwnProperty;function a(l,c,u){var f=l[c];(!(r.call(l,c)&&t(f,u))||u===void 0&&!(c in l))&&e(l,c,u)}return zm=a,zm}var Hm,wS;function eu(){if(wS)return Hm;wS=1;var e=Uh(),t=Hh();function n(r,a,l,c){var u=!l;l||(l={});for(var f=-1,p=a.length;++f<p;){var h=a[f],m=c?c(l[h],r[h],h,l,r):void 0;m===void 0&&(m=r[h]),u?t(l,h,m):e(l,h,m)}return l}return Hm=n,Hm}var Um,vS;function yH(){if(vS)return Um;vS=1;function e(t,n){for(var r=-1,a=Array(t);++r<t;)a[r]=n(r);return a}return Um=e,Um}var Wm,xS;function Ns(){if(xS)return Wm;xS=1;function e(t){return t!=null&&typeof t=="object"}return Wm=e,Wm}var Vm,bS;function wH(){if(bS)return Vm;bS=1;var e=Bo(),t=Ns(),n="[object Arguments]";function r(a){return t(a)&&e(a)==n}return Vm=r,Vm}var Gm,kS;function tu(){if(kS)return Gm;kS=1;var e=wH(),t=Ns(),n=Object.prototype,r=n.hasOwnProperty,a=n.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(c){return t(c)&&r.call(c,"callee")&&!a.call(c,"callee")};return Gm=l,Gm}var Km,NS;function Kt(){if(NS)return Km;NS=1;var e=Array.isArray;return Km=e,Km}var kc={exports:{}},Ym,_S;function vH(){if(_S)return Ym;_S=1;function e(){return!1}return Ym=e,Ym}kc.exports;var SS;function pl(){return SS||(SS=1,(function(e,t){var n=ts(),r=vH(),a=t&&!t.nodeType&&t,l=a&&!0&&e&&!e.nodeType&&e,c=l&&l.exports===a,u=c?n.Buffer:void 0,f=u?u.isBuffer:void 0,p=f||r;e.exports=p})(kc,kc.exports)),kc.exports}var Xm,jS;function Wh(){if(jS)return Xm;jS=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(r,a){var l=typeof r;return a=a??e,!!a&&(l=="number"||l!="symbol"&&t.test(r))&&r>-1&&r%1==0&&r<a}return Xm=n,Xm}var Zm,ES;function eb(){if(ES)return Zm;ES=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Zm=t,Zm}var Qm,CS;function xH(){if(CS)return Qm;CS=1;var e=Bo(),t=eb(),n=Ns(),r="[object Arguments]",a="[object Array]",l="[object Boolean]",c="[object Date]",u="[object Error]",f="[object Function]",p="[object Map]",h="[object Number]",m="[object Object]",y="[object RegExp]",w="[object Set]",j="[object String]",k="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",N="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",T="[object Int16Array]",A="[object Int32Array]",I="[object Uint8Array]",B="[object Uint8ClampedArray]",q="[object Uint16Array]",L="[object Uint32Array]",U={};U[N]=U[E]=U[C]=U[T]=U[A]=U[I]=U[B]=U[q]=U[L]=!0,U[r]=U[a]=U[S]=U[l]=U[b]=U[c]=U[u]=U[f]=U[p]=U[h]=U[m]=U[y]=U[w]=U[j]=U[k]=!1;function X(Y){return n(Y)&&t(Y.length)&&!!U[e(Y)]}return Qm=X,Qm}var Jm,TS;function Vh(){if(TS)return Jm;TS=1;function e(t){return function(n){return t(n)}}return Jm=e,Jm}var Nc={exports:{}};Nc.exports;var AS;function tb(){return AS||(AS=1,(function(e,t){var n=rM(),r=t&&!t.nodeType&&t,a=r&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===r,c=l&&n.process,u=(function(){try{var f=a&&a.require&&a.require("util").types;return f||c&&c.binding&&c.binding("util")}catch{}})();e.exports=u})(Nc,Nc.exports)),Nc.exports}var eg,RS;function nu(){if(RS)return eg;RS=1;var e=xH(),t=Vh(),n=tb(),r=n&&n.isTypedArray,a=r?t(r):e;return eg=a,eg}var tg,MS;function oM(){if(MS)return tg;MS=1;var e=yH(),t=tu(),n=Kt(),r=pl(),a=Wh(),l=nu(),c=Object.prototype,u=c.hasOwnProperty;function f(p,h){var m=n(p),y=!m&&t(p),w=!m&&!y&&r(p),j=!m&&!y&&!w&&l(p),k=m||y||w||j,S=k?e(p.length,String):[],b=S.length;for(var N in p)(h||u.call(p,N))&&!(k&&(N=="length"||w&&(N=="offset"||N=="parent")||j&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||a(N,b)))&&S.push(N);return S}return tg=f,tg}var ng,IS;function Gh(){if(IS)return ng;IS=1;var e=Object.prototype;function t(n){var r=n&&n.constructor,a=typeof r=="function"&&r.prototype||e;return n===a}return ng=t,ng}var rg,$S;function iM(){if($S)return rg;$S=1;function e(t,n){return function(r){return t(n(r))}}return rg=e,rg}var sg,OS;function bH(){if(OS)return sg;OS=1;var e=iM(),t=e(Object.keys,Object);return sg=t,sg}var ag,LS;function nb(){if(LS)return ag;LS=1;var e=Gh(),t=bH(),n=Object.prototype,r=n.hasOwnProperty;function a(l){if(!e(l))return t(l);var c=[];for(var u in Object(l))r.call(l,u)&&u!="constructor"&&c.push(u);return c}return ag=a,ag}var og,PS;function Qs(){if(PS)return og;PS=1;var e=Jc(),t=eb();function n(r){return r!=null&&t(r.length)&&!e(r)}return og=n,og}var ig,DS;function qa(){if(DS)return ig;DS=1;var e=oM(),t=nb(),n=Qs();function r(a){return n(a)?e(a):t(a)}return ig=r,ig}var lg,FS;function kH(){if(FS)return lg;FS=1;var e=eu(),t=qa();function n(r,a){return r&&e(a,t(a),r)}return lg=n,lg}var cg,qS;function NH(){if(qS)return cg;qS=1;function e(t){var n=[];if(t!=null)for(var r in Object(t))n.push(r);return n}return cg=e,cg}var ug,BS;function _H(){if(BS)return ug;BS=1;var e=Cr(),t=Gh(),n=NH(),r=Object.prototype,a=r.hasOwnProperty;function l(c){if(!e(c))return n(c);var u=t(c),f=[];for(var p in c)p=="constructor"&&(u||!a.call(c,p))||f.push(p);return f}return ug=l,ug}var dg,zS;function Ho(){if(zS)return dg;zS=1;var e=oM(),t=_H(),n=Qs();function r(a){return n(a)?e(a,!0):t(a)}return dg=r,dg}var hg,HS;function SH(){if(HS)return hg;HS=1;var e=eu(),t=Ho();function n(r,a){return r&&e(a,t(a),r)}return hg=n,hg}var _c={exports:{}};_c.exports;var US;function lM(){return US||(US=1,(function(e,t){var n=ts(),r=t&&!t.nodeType&&t,a=r&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===r,c=l?n.Buffer:void 0,u=c?c.allocUnsafe:void 0;function f(p,h){if(h)return p.slice();var m=p.length,y=u?u(m):new p.constructor(m);return p.copy(y),y}e.exports=f})(_c,_c.exports)),_c.exports}var fg,WS;function cM(){if(WS)return fg;WS=1;function e(t,n){var r=-1,a=t.length;for(n||(n=Array(a));++r<a;)n[r]=t[r];return n}return fg=e,fg}var pg,VS;function uM(){if(VS)return pg;VS=1;function e(t,n){for(var r=-1,a=t==null?0:t.length,l=0,c=[];++r<a;){var u=t[r];n(u,r,t)&&(c[l++]=u)}return c}return pg=e,pg}var mg,GS;function dM(){if(GS)return mg;GS=1;function e(){return[]}return mg=e,mg}var gg,KS;function rb(){if(KS)return gg;KS=1;var e=uM(),t=dM(),n=Object.prototype,r=n.propertyIsEnumerable,a=Object.getOwnPropertySymbols,l=a?function(c){return c==null?[]:(c=Object(c),e(a(c),function(u){return r.call(c,u)}))}:t;return gg=l,gg}var yg,YS;function jH(){if(YS)return yg;YS=1;var e=eu(),t=rb();function n(r,a){return e(r,t(r),a)}return yg=n,yg}var wg,XS;function sb(){if(XS)return wg;XS=1;function e(t,n){for(var r=-1,a=n.length,l=t.length;++r<a;)t[l+r]=n[r];return t}return wg=e,wg}var vg,ZS;function Kh(){if(ZS)return vg;ZS=1;var e=iM(),t=e(Object.getPrototypeOf,Object);return vg=t,vg}var xg,QS;function hM(){if(QS)return xg;QS=1;var e=sb(),t=Kh(),n=rb(),r=dM(),a=Object.getOwnPropertySymbols,l=a?function(c){for(var u=[];c;)e(u,n(c)),c=t(c);return u}:r;return xg=l,xg}var bg,JS;function EH(){if(JS)return bg;JS=1;var e=eu(),t=hM();function n(r,a){return e(r,t(r),a)}return bg=n,bg}var kg,ej;function fM(){if(ej)return kg;ej=1;var e=sb(),t=Kt();function n(r,a,l){var c=a(r);return t(r)?c:e(c,l(r))}return kg=n,kg}var Ng,tj;function pM(){if(tj)return Ng;tj=1;var e=fM(),t=rb(),n=qa();function r(a){return e(a,n,t)}return Ng=r,Ng}var _g,nj;function CH(){if(nj)return _g;nj=1;var e=fM(),t=hM(),n=Ho();function r(a){return e(a,n,t)}return _g=r,_g}var Sg,rj;function TH(){if(rj)return Sg;rj=1;var e=zo(),t=ts(),n=e(t,"DataView");return Sg=n,Sg}var jg,sj;function AH(){if(sj)return jg;sj=1;var e=zo(),t=ts(),n=e(t,"Promise");return jg=n,jg}var Eg,aj;function mM(){if(aj)return Eg;aj=1;var e=zo(),t=ts(),n=e(t,"Set");return Eg=n,Eg}var Cg,oj;function RH(){if(oj)return Cg;oj=1;var e=zo(),t=ts(),n=e(t,"WeakMap");return Cg=n,Cg}var Tg,ij;function ml(){if(ij)return Tg;ij=1;var e=TH(),t=Z0(),n=AH(),r=mM(),a=RH(),l=Bo(),c=sM(),u="[object Map]",f="[object Object]",p="[object Promise]",h="[object Set]",m="[object WeakMap]",y="[object DataView]",w=c(e),j=c(t),k=c(n),S=c(r),b=c(a),N=l;return(e&&N(new e(new ArrayBuffer(1)))!=y||t&&N(new t)!=u||n&&N(n.resolve())!=p||r&&N(new r)!=h||a&&N(new a)!=m)&&(N=function(E){var C=l(E),T=C==f?E.constructor:void 0,A=T?c(T):"";if(A)switch(A){case w:return y;case j:return u;case k:return p;case S:return h;case b:return m}return C}),Tg=N,Tg}var Ag,lj;function MH(){if(lj)return Ag;lj=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r){var a=r.length,l=new r.constructor(a);return a&&typeof r[0]=="string"&&t.call(r,"index")&&(l.index=r.index,l.input=r.input),l}return Ag=n,Ag}var Rg,cj;function gM(){if(cj)return Rg;cj=1;var e=ts(),t=e.Uint8Array;return Rg=t,Rg}var Mg,uj;function ab(){if(uj)return Mg;uj=1;var e=gM();function t(n){var r=new n.constructor(n.byteLength);return new e(r).set(new e(n)),r}return Mg=t,Mg}var Ig,dj;function IH(){if(dj)return Ig;dj=1;var e=ab();function t(n,r){var a=r?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.byteLength)}return Ig=t,Ig}var $g,hj;function $H(){if(hj)return $g;hj=1;var e=/\w*$/;function t(n){var r=new n.constructor(n.source,e.exec(n));return r.lastIndex=n.lastIndex,r}return $g=t,$g}var Og,fj;function OH(){if(fj)return Og;fj=1;var e=fl(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function r(a){return n?Object(n.call(a)):{}}return Og=r,Og}var Lg,pj;function yM(){if(pj)return Lg;pj=1;var e=ab();function t(n,r){var a=r?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.length)}return Lg=t,Lg}var Pg,mj;function LH(){if(mj)return Pg;mj=1;var e=ab(),t=IH(),n=$H(),r=OH(),a=yM(),l="[object Boolean]",c="[object Date]",u="[object Map]",f="[object Number]",p="[object RegExp]",h="[object Set]",m="[object String]",y="[object Symbol]",w="[object ArrayBuffer]",j="[object DataView]",k="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",N="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",T="[object Uint8ClampedArray]",A="[object Uint16Array]",I="[object Uint32Array]";function B(q,L,U){var X=q.constructor;switch(L){case w:return e(q);case l:case c:return new X(+q);case j:return t(q,U);case k:case S:case b:case N:case E:case C:case T:case A:case I:return a(q,U);case u:return new X;case f:case m:return new X(q);case p:return n(q);case h:return new X;case y:return r(q)}}return Pg=B,Pg}var Dg,gj;function wM(){if(gj)return Dg;gj=1;var e=Cr(),t=Object.create,n=(function(){function r(){}return function(a){if(!e(a))return{};if(t)return t(a);r.prototype=a;var l=new r;return r.prototype=void 0,l}})();return Dg=n,Dg}var Fg,yj;function vM(){if(yj)return Fg;yj=1;var e=wM(),t=Kh(),n=Gh();function r(a){return typeof a.constructor=="function"&&!n(a)?e(t(a)):{}}return Fg=r,Fg}var qg,wj;function PH(){if(wj)return qg;wj=1;var e=ml(),t=Ns(),n="[object Map]";function r(a){return t(a)&&e(a)==n}return qg=r,qg}var Bg,vj;function DH(){if(vj)return Bg;vj=1;var e=PH(),t=Vh(),n=tb(),r=n&&n.isMap,a=r?t(r):e;return Bg=a,Bg}var zg,xj;function FH(){if(xj)return zg;xj=1;var e=ml(),t=Ns(),n="[object Set]";function r(a){return t(a)&&e(a)==n}return zg=r,zg}var Hg,bj;function qH(){if(bj)return Hg;bj=1;var e=FH(),t=Vh(),n=tb(),r=n&&n.isSet,a=r?t(r):e;return Hg=a,Hg}var Ug,kj;function xM(){if(kj)return Ug;kj=1;var e=zh(),t=J0(),n=Uh(),r=kH(),a=SH(),l=lM(),c=cM(),u=jH(),f=EH(),p=pM(),h=CH(),m=ml(),y=MH(),w=LH(),j=vM(),k=Kt(),S=pl(),b=DH(),N=Cr(),E=qH(),C=qa(),T=Ho(),A=1,I=2,B=4,q="[object Arguments]",L="[object Array]",U="[object Boolean]",X="[object Date]",Y="[object Error]",M="[object Function]",J="[object GeneratorFunction]",V="[object Map]",$="[object Number]",z="[object Object]",W="[object RegExp]",G="[object Set]",F="[object String]",K="[object Symbol]",de="[object WeakMap]",H="[object ArrayBuffer]",Q="[object DataView]",O="[object Float32Array]",te="[object Float64Array]",ae="[object Int8Array]",he="[object Int16Array]",ge="[object Int32Array]",Te="[object Uint8Array]",De="[object Uint8ClampedArray]",Ve="[object Uint16Array]",je="[object Uint32Array]",ve={};ve[q]=ve[L]=ve[H]=ve[Q]=ve[U]=ve[X]=ve[O]=ve[te]=ve[ae]=ve[he]=ve[ge]=ve[V]=ve[$]=ve[z]=ve[W]=ve[G]=ve[F]=ve[K]=ve[Te]=ve[De]=ve[Ve]=ve[je]=!0,ve[Y]=ve[M]=ve[de]=!1;function Ue(ke,xe,Ge,rt,at,le){var _e,Ie=xe&A,Ze=xe&I,We=xe&B;if(Ge&&(_e=at?Ge(ke,rt,at,le):Ge(ke)),_e!==void 0)return _e;if(!N(ke))return ke;var Je=k(ke);if(Je){if(_e=y(ke),!Ie)return c(ke,_e)}else{var ye=m(ke),Me=ye==M||ye==J;if(S(ke))return l(ke,Ie);if(ye==z||ye==q||Me&&!at){if(_e=Ze||Me?{}:j(ke),!Ie)return Ze?f(ke,a(_e,ke)):u(ke,r(_e,ke))}else{if(!ve[ye])return at?ke:{};_e=w(ke,ye,Ie)}}le||(le=new e);var Qe=le.get(ke);if(Qe)return Qe;le.set(ke,_e),E(ke)?ke.forEach(function(pt){_e.add(Ue(pt,xe,Ge,pt,ke,le))}):b(ke)&&ke.forEach(function(pt,ut){_e.set(ut,Ue(pt,xe,Ge,ut,ke,le))});var ue=We?Ze?h:p:Ze?T:C,kt=Je?void 0:ue(ke);return t(kt||ke,function(pt,ut){kt&&(ut=pt,pt=ke[ut]),n(_e,ut,Ue(pt,xe,Ge,ut,ke,le))}),_e}return Ug=Ue,Ug}var Wg,Nj;function BH(){if(Nj)return Wg;Nj=1;var e=xM(),t=4;function n(r){return e(r,t)}return Wg=n,Wg}var Vg,_j;function ob(){if(_j)return Vg;_j=1;function e(t){return function(){return t}}return Vg=e,Vg}var Gg,Sj;function zH(){if(Sj)return Gg;Sj=1;function e(t){return function(n,r,a){for(var l=-1,c=Object(n),u=a(n),f=u.length;f--;){var p=u[t?f:++l];if(r(c[p],p,c)===!1)break}return n}}return Gg=e,Gg}var Kg,jj;function ib(){if(jj)return Kg;jj=1;var e=zH(),t=e();return Kg=t,Kg}var Yg,Ej;function lb(){if(Ej)return Yg;Ej=1;var e=ib(),t=qa();function n(r,a){return r&&e(r,a,t)}return Yg=n,Yg}var Xg,Cj;function HH(){if(Cj)return Xg;Cj=1;var e=Qs();function t(n,r){return function(a,l){if(a==null)return a;if(!e(a))return n(a,l);for(var c=a.length,u=r?c:-1,f=Object(a);(r?u--:++u<c)&&l(f[u],u,f)!==!1;);return a}}return Xg=t,Xg}var Zg,Tj;function Yh(){if(Tj)return Zg;Tj=1;var e=lb(),t=HH(),n=t(e);return Zg=n,Zg}var Qg,Aj;function Uo(){if(Aj)return Qg;Aj=1;function e(t){return t}return Qg=e,Qg}var Jg,Rj;function bM(){if(Rj)return Jg;Rj=1;var e=Uo();function t(n){return typeof n=="function"?n:e}return Jg=t,Jg}var ey,Mj;function kM(){if(Mj)return ey;Mj=1;var e=J0(),t=Yh(),n=bM(),r=Kt();function a(l,c){var u=r(l)?e:t;return u(l,n(c))}return ey=a,ey}var ty,Ij;function NM(){return Ij||(Ij=1,ty=kM()),ty}var ny,$j;function UH(){if($j)return ny;$j=1;var e=Yh();function t(n,r){var a=[];return e(n,function(l,c,u){r(l,c,u)&&a.push(l)}),a}return ny=t,ny}var ry,Oj;function WH(){if(Oj)return ry;Oj=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return ry=t,ry}var sy,Lj;function VH(){if(Lj)return sy;Lj=1;function e(t){return this.__data__.has(t)}return sy=e,sy}var ay,Pj;function _M(){if(Pj)return ay;Pj=1;var e=Q0(),t=WH(),n=VH();function r(a){var l=-1,c=a==null?0:a.length;for(this.__data__=new e;++l<c;)this.add(a[l])}return r.prototype.add=r.prototype.push=t,r.prototype.has=n,ay=r,ay}var oy,Dj;function GH(){if(Dj)return oy;Dj=1;function e(t,n){for(var r=-1,a=t==null?0:t.length;++r<a;)if(n(t[r],r,t))return!0;return!1}return oy=e,oy}var iy,Fj;function SM(){if(Fj)return iy;Fj=1;function e(t,n){return t.has(n)}return iy=e,iy}var ly,qj;function jM(){if(qj)return ly;qj=1;var e=_M(),t=GH(),n=SM(),r=1,a=2;function l(c,u,f,p,h,m){var y=f&r,w=c.length,j=u.length;if(w!=j&&!(y&&j>w))return!1;var k=m.get(c),S=m.get(u);if(k&&S)return k==u&&S==c;var b=-1,N=!0,E=f&a?new e:void 0;for(m.set(c,u),m.set(u,c);++b<w;){var C=c[b],T=u[b];if(p)var A=y?p(T,C,b,u,c,m):p(C,T,b,c,u,m);if(A!==void 0){if(A)continue;N=!1;break}if(E){if(!t(u,function(I,B){if(!n(E,B)&&(C===I||h(C,I,f,p,m)))return E.push(B)})){N=!1;break}}else if(!(C===T||h(C,T,f,p,m))){N=!1;break}}return m.delete(c),m.delete(u),N}return ly=l,ly}var cy,Bj;function KH(){if(Bj)return cy;Bj=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(a,l){r[++n]=[l,a]}),r}return cy=e,cy}var uy,zj;function cb(){if(zj)return uy;zj=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(a){r[++n]=a}),r}return uy=e,uy}var dy,Hj;function YH(){if(Hj)return dy;Hj=1;var e=fl(),t=gM(),n=hl(),r=jM(),a=KH(),l=cb(),c=1,u=2,f="[object Boolean]",p="[object Date]",h="[object Error]",m="[object Map]",y="[object Number]",w="[object RegExp]",j="[object Set]",k="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",N="[object DataView]",E=e?e.prototype:void 0,C=E?E.valueOf:void 0;function T(A,I,B,q,L,U,X){switch(B){case N:if(A.byteLength!=I.byteLength||A.byteOffset!=I.byteOffset)return!1;A=A.buffer,I=I.buffer;case b:return!(A.byteLength!=I.byteLength||!U(new t(A),new t(I)));case f:case p:case y:return n(+A,+I);case h:return A.name==I.name&&A.message==I.message;case w:case k:return A==I+"";case m:var Y=a;case j:var M=q&c;if(Y||(Y=l),A.size!=I.size&&!M)return!1;var J=X.get(A);if(J)return J==I;q|=u,X.set(A,I);var V=r(Y(A),Y(I),q,L,U,X);return X.delete(A),V;case S:if(C)return C.call(A)==C.call(I)}return!1}return dy=T,dy}var hy,Uj;function XH(){if(Uj)return hy;Uj=1;var e=pM(),t=1,n=Object.prototype,r=n.hasOwnProperty;function a(l,c,u,f,p,h){var m=u&t,y=e(l),w=y.length,j=e(c),k=j.length;if(w!=k&&!m)return!1;for(var S=w;S--;){var b=y[S];if(!(m?b in c:r.call(c,b)))return!1}var N=h.get(l),E=h.get(c);if(N&&E)return N==c&&E==l;var C=!0;h.set(l,c),h.set(c,l);for(var T=m;++S<w;){b=y[S];var A=l[b],I=c[b];if(f)var B=m?f(I,A,b,c,l,h):f(A,I,b,l,c,h);if(!(B===void 0?A===I||p(A,I,u,f,h):B)){C=!1;break}T||(T=b=="constructor")}if(C&&!T){var q=l.constructor,L=c.constructor;q!=L&&"constructor"in l&&"constructor"in c&&!(typeof q=="function"&&q instanceof q&&typeof L=="function"&&L instanceof L)&&(C=!1)}return h.delete(l),h.delete(c),C}return hy=a,hy}var fy,Wj;function ZH(){if(Wj)return fy;Wj=1;var e=zh(),t=jM(),n=YH(),r=XH(),a=ml(),l=Kt(),c=pl(),u=nu(),f=1,p="[object Arguments]",h="[object Array]",m="[object Object]",y=Object.prototype,w=y.hasOwnProperty;function j(k,S,b,N,E,C){var T=l(k),A=l(S),I=T?h:a(k),B=A?h:a(S);I=I==p?m:I,B=B==p?m:B;var q=I==m,L=B==m,U=I==B;if(U&&c(k)){if(!c(S))return!1;T=!0,q=!1}if(U&&!q)return C||(C=new e),T||u(k)?t(k,S,b,N,E,C):n(k,S,I,b,N,E,C);if(!(b&f)){var X=q&&w.call(k,"__wrapped__"),Y=L&&w.call(S,"__wrapped__");if(X||Y){var M=X?k.value():k,J=Y?S.value():S;return C||(C=new e),E(M,J,b,N,C)}}return U?(C||(C=new e),r(k,S,b,N,E,C)):!1}return fy=j,fy}var py,Vj;function EM(){if(Vj)return py;Vj=1;var e=ZH(),t=Ns();function n(r,a,l,c,u){return r===a?!0:r==null||a==null||!t(r)&&!t(a)?r!==r&&a!==a:e(r,a,l,c,n,u)}return py=n,py}var my,Gj;function QH(){if(Gj)return my;Gj=1;var e=zh(),t=EM(),n=1,r=2;function a(l,c,u,f){var p=u.length,h=p,m=!f;if(l==null)return!h;for(l=Object(l);p--;){var y=u[p];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++p<h;){y=u[p];var w=y[0],j=l[w],k=y[1];if(m&&y[2]){if(j===void 0&&!(w in l))return!1}else{var S=new e;if(f)var b=f(j,k,w,l,c,S);if(!(b===void 0?t(k,j,n|r,f,S):b))return!1}}return!0}return my=a,my}var gy,Kj;function CM(){if(Kj)return gy;Kj=1;var e=Cr();function t(n){return n===n&&!e(n)}return gy=t,gy}var yy,Yj;function JH(){if(Yj)return yy;Yj=1;var e=CM(),t=qa();function n(r){for(var a=t(r),l=a.length;l--;){var c=a[l],u=r[c];a[l]=[c,u,e(u)]}return a}return yy=n,yy}var wy,Xj;function TM(){if(Xj)return wy;Xj=1;function e(t,n){return function(r){return r==null?!1:r[t]===n&&(n!==void 0||t in Object(r))}}return wy=e,wy}var vy,Zj;function eU(){if(Zj)return vy;Zj=1;var e=QH(),t=JH(),n=TM();function r(a){var l=t(a);return l.length==1&&l[0][2]?n(l[0][0],l[0][1]):function(c){return c===a||e(c,a,l)}}return vy=r,vy}var xy,Qj;function gl(){if(Qj)return xy;Qj=1;var e=Bo(),t=Ns(),n="[object Symbol]";function r(a){return typeof a=="symbol"||t(a)&&e(a)==n}return xy=r,xy}var by,Jj;function ub(){if(Jj)return by;Jj=1;var e=Kt(),t=gl(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function a(l,c){if(e(l))return!1;var u=typeof l;return u=="number"||u=="symbol"||u=="boolean"||l==null||t(l)?!0:r.test(l)||!n.test(l)||c!=null&&l in Object(c)}return by=a,by}var ky,eE;function tU(){if(eE)return ky;eE=1;var e=Q0(),t="Expected a function";function n(r,a){if(typeof r!="function"||a!=null&&typeof a!="function")throw new TypeError(t);var l=function(){var c=arguments,u=a?a.apply(this,c):c[0],f=l.cache;if(f.has(u))return f.get(u);var p=r.apply(this,c);return l.cache=f.set(u,p)||f,p};return l.cache=new(n.Cache||e),l}return n.Cache=e,ky=n,ky}var Ny,tE;function nU(){if(tE)return Ny;tE=1;var e=tU(),t=500;function n(r){var a=e(r,function(c){return l.size===t&&l.clear(),c}),l=a.cache;return a}return Ny=n,Ny}var _y,nE;function rU(){if(nE)return _y;nE=1;var e=nU(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(a){var l=[];return a.charCodeAt(0)===46&&l.push(""),a.replace(t,function(c,u,f,p){l.push(f?p.replace(n,"$1"):u||c)}),l});return _y=r,_y}var Sy,rE;function Xh(){if(rE)return Sy;rE=1;function e(t,n){for(var r=-1,a=t==null?0:t.length,l=Array(a);++r<a;)l[r]=n(t[r],r,t);return l}return Sy=e,Sy}var jy,sE;function sU(){if(sE)return jy;sE=1;var e=fl(),t=Xh(),n=Kt(),r=gl(),a=e?e.prototype:void 0,l=a?a.toString:void 0;function c(u){if(typeof u=="string")return u;if(n(u))return t(u,c)+"";if(r(u))return l?l.call(u):"";var f=u+"";return f=="0"&&1/u==-1/0?"-0":f}return jy=c,jy}var Ey,aE;function AM(){if(aE)return Ey;aE=1;var e=sU();function t(n){return n==null?"":e(n)}return Ey=t,Ey}var Cy,oE;function Zh(){if(oE)return Cy;oE=1;var e=Kt(),t=ub(),n=rU(),r=AM();function a(l,c){return e(l)?l:t(l,c)?[l]:n(r(l))}return Cy=a,Cy}var Ty,iE;function ru(){if(iE)return Ty;iE=1;var e=gl();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return Ty=t,Ty}var Ay,lE;function Qh(){if(lE)return Ay;lE=1;var e=Zh(),t=ru();function n(r,a){a=e(a,r);for(var l=0,c=a.length;r!=null&&l<c;)r=r[t(a[l++])];return l&&l==c?r:void 0}return Ay=n,Ay}var Ry,cE;function aU(){if(cE)return Ry;cE=1;var e=Qh();function t(n,r,a){var l=n==null?void 0:e(n,r);return l===void 0?a:l}return Ry=t,Ry}var My,uE;function oU(){if(uE)return My;uE=1;function e(t,n){return t!=null&&n in Object(t)}return My=e,My}var Iy,dE;function RM(){if(dE)return Iy;dE=1;var e=Zh(),t=tu(),n=Kt(),r=Wh(),a=eb(),l=ru();function c(u,f,p){f=e(f,u);for(var h=-1,m=f.length,y=!1;++h<m;){var w=l(f[h]);if(!(y=u!=null&&p(u,w)))break;u=u[w]}return y||++h!=m?y:(m=u==null?0:u.length,!!m&&a(m)&&r(w,m)&&(n(u)||t(u)))}return Iy=c,Iy}var $y,hE;function MM(){if(hE)return $y;hE=1;var e=oU(),t=RM();function n(r,a){return r!=null&&t(r,a,e)}return $y=n,$y}var Oy,fE;function iU(){if(fE)return Oy;fE=1;var e=EM(),t=aU(),n=MM(),r=ub(),a=CM(),l=TM(),c=ru(),u=1,f=2;function p(h,m){return r(h)&&a(m)?l(c(h),m):function(y){var w=t(y,h);return w===void 0&&w===m?n(y,h):e(m,w,u|f)}}return Oy=p,Oy}var Ly,pE;function IM(){if(pE)return Ly;pE=1;function e(t){return function(n){return n==null?void 0:n[t]}}return Ly=e,Ly}var Py,mE;function lU(){if(mE)return Py;mE=1;var e=Qh();function t(n){return function(r){return e(r,n)}}return Py=t,Py}var Dy,gE;function cU(){if(gE)return Dy;gE=1;var e=IM(),t=lU(),n=ub(),r=ru();function a(l){return n(l)?e(r(l)):t(l)}return Dy=a,Dy}var Fy,yE;function Js(){if(yE)return Fy;yE=1;var e=eU(),t=iU(),n=Uo(),r=Kt(),a=cU();function l(c){return typeof c=="function"?c:c==null?n:typeof c=="object"?r(c)?t(c[0],c[1]):e(c):a(c)}return Fy=l,Fy}var qy,wE;function $M(){if(wE)return qy;wE=1;var e=uM(),t=UH(),n=Js(),r=Kt();function a(l,c){var u=r(l)?e:t;return u(l,n(c,3))}return qy=a,qy}var By,vE;function uU(){if(vE)return By;vE=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r,a){return r!=null&&t.call(r,a)}return By=n,By}var zy,xE;function OM(){if(xE)return zy;xE=1;var e=uU(),t=RM();function n(r,a){return r!=null&&t(r,a,e)}return zy=n,zy}var Hy,bE;function dU(){if(bE)return Hy;bE=1;var e=nb(),t=ml(),n=tu(),r=Kt(),a=Qs(),l=pl(),c=Gh(),u=nu(),f="[object Map]",p="[object Set]",h=Object.prototype,m=h.hasOwnProperty;function y(w){if(w==null)return!0;if(a(w)&&(r(w)||typeof w=="string"||typeof w.splice=="function"||l(w)||u(w)||n(w)))return!w.length;var j=t(w);if(j==f||j==p)return!w.size;if(c(w))return!e(w).length;for(var k in w)if(m.call(w,k))return!1;return!0}return Hy=y,Hy}var Uy,kE;function LM(){if(kE)return Uy;kE=1;function e(t){return t===void 0}return Uy=e,Uy}var Wy,NE;function PM(){if(NE)return Wy;NE=1;var e=Yh(),t=Qs();function n(r,a){var l=-1,c=t(r)?Array(r.length):[];return e(r,function(u,f,p){c[++l]=a(u,f,p)}),c}return Wy=n,Wy}var Vy,_E;function DM(){if(_E)return Vy;_E=1;var e=Xh(),t=Js(),n=PM(),r=Kt();function a(l,c){var u=r(l)?e:n;return u(l,t(c,3))}return Vy=a,Vy}var Gy,SE;function hU(){if(SE)return Gy;SE=1;function e(t,n,r,a){var l=-1,c=t==null?0:t.length;for(a&&c&&(r=t[++l]);++l<c;)r=n(r,t[l],l,t);return r}return Gy=e,Gy}var Ky,jE;function fU(){if(jE)return Ky;jE=1;function e(t,n,r,a,l){return l(t,function(c,u,f){r=a?(a=!1,c):n(r,c,u,f)}),r}return Ky=e,Ky}var Yy,EE;function FM(){if(EE)return Yy;EE=1;var e=hU(),t=Yh(),n=Js(),r=fU(),a=Kt();function l(c,u,f){var p=a(c)?e:r,h=arguments.length<3;return p(c,n(u,4),f,h,t)}return Yy=l,Yy}var Xy,CE;function pU(){if(CE)return Xy;CE=1;var e=Bo(),t=Kt(),n=Ns(),r="[object String]";function a(l){return typeof l=="string"||!t(l)&&n(l)&&e(l)==r}return Xy=a,Xy}var Zy,TE;function mU(){if(TE)return Zy;TE=1;var e=IM(),t=e("length");return Zy=t,Zy}var Qy,AE;function gU(){if(AE)return Qy;AE=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",a=t+n+r,l="\\ufe0e\\ufe0f",c="\\u200d",u=RegExp("["+c+e+a+l+"]");function f(p){return u.test(p)}return Qy=f,Qy}var Jy,RE;function yU(){if(RE)return Jy;RE=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",a=t+n+r,l="\\ufe0e\\ufe0f",c="["+e+"]",u="["+a+"]",f="\\ud83c[\\udffb-\\udfff]",p="(?:"+u+"|"+f+")",h="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",j=p+"?",k="["+l+"]?",S="(?:"+w+"(?:"+[h,m,y].join("|")+")"+k+j+")*",b=k+j+S,N="(?:"+[h+u+"?",u,m,y,c].join("|")+")",E=RegExp(f+"(?="+f+")|"+N+b,"g");function C(T){for(var A=E.lastIndex=0;E.test(T);)++A;return A}return Jy=C,Jy}var ew,ME;function wU(){if(ME)return ew;ME=1;var e=mU(),t=gU(),n=yU();function r(a){return t(a)?n(a):e(a)}return ew=r,ew}var tw,IE;function vU(){if(IE)return tw;IE=1;var e=nb(),t=ml(),n=Qs(),r=pU(),a=wU(),l="[object Map]",c="[object Set]";function u(f){if(f==null)return 0;if(n(f))return r(f)?a(f):f.length;var p=t(f);return p==l||p==c?f.size:e(f).length}return tw=u,tw}var nw,$E;function xU(){if($E)return nw;$E=1;var e=J0(),t=wM(),n=lb(),r=Js(),a=Kh(),l=Kt(),c=pl(),u=Jc(),f=Cr(),p=nu();function h(m,y,w){var j=l(m),k=j||c(m)||p(m);if(y=r(y,4),w==null){var S=m&&m.constructor;k?w=j?new S:[]:f(m)?w=u(S)?t(a(m)):{}:w={}}return(k?e:n)(m,function(b,N,E){return y(w,b,N,E)}),w}return nw=h,nw}var rw,OE;function bU(){if(OE)return rw;OE=1;var e=fl(),t=tu(),n=Kt(),r=e?e.isConcatSpreadable:void 0;function a(l){return n(l)||t(l)||!!(r&&l&&l[r])}return rw=a,rw}var sw,LE;function db(){if(LE)return sw;LE=1;var e=sb(),t=bU();function n(r,a,l,c,u){var f=-1,p=r.length;for(l||(l=t),u||(u=[]);++f<p;){var h=r[f];a>0&&l(h)?a>1?n(h,a-1,l,c,u):e(u,h):c||(u[u.length]=h)}return u}return sw=n,sw}var aw,PE;function kU(){if(PE)return aw;PE=1;function e(t,n,r){switch(r.length){case 0:return t.call(n);case 1:return t.call(n,r[0]);case 2:return t.call(n,r[0],r[1]);case 3:return t.call(n,r[0],r[1],r[2])}return t.apply(n,r)}return aw=e,aw}var ow,DE;function qM(){if(DE)return ow;DE=1;var e=kU(),t=Math.max;function n(r,a,l){return a=t(a===void 0?r.length-1:a,0),function(){for(var c=arguments,u=-1,f=t(c.length-a,0),p=Array(f);++u<f;)p[u]=c[a+u];u=-1;for(var h=Array(a+1);++u<a;)h[u]=c[u];return h[a]=l(p),e(r,this,h)}}return ow=n,ow}var iw,FE;function NU(){if(FE)return iw;FE=1;var e=ob(),t=aM(),n=Uo(),r=t?function(a,l){return t(a,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:n;return iw=r,iw}var lw,qE;function _U(){if(qE)return lw;qE=1;var e=800,t=16,n=Date.now;function r(a){var l=0,c=0;return function(){var u=n(),f=t-(u-c);if(c=u,f>0){if(++l>=e)return arguments[0]}else l=0;return a.apply(void 0,arguments)}}return lw=r,lw}var cw,BE;function BM(){if(BE)return cw;BE=1;var e=NU(),t=_U(),n=t(e);return cw=n,cw}var uw,zE;function Jh(){if(zE)return uw;zE=1;var e=Uo(),t=qM(),n=BM();function r(a,l){return n(t(a,l,e),a+"")}return uw=r,uw}var dw,HE;function zM(){if(HE)return dw;HE=1;function e(t,n,r,a){for(var l=t.length,c=r+(a?1:-1);a?c--:++c<l;)if(n(t[c],c,t))return c;return-1}return dw=e,dw}var hw,UE;function SU(){if(UE)return hw;UE=1;function e(t){return t!==t}return hw=e,hw}var fw,WE;function jU(){if(WE)return fw;WE=1;function e(t,n,r){for(var a=r-1,l=t.length;++a<l;)if(t[a]===n)return a;return-1}return fw=e,fw}var pw,VE;function EU(){if(VE)return pw;VE=1;var e=zM(),t=SU(),n=jU();function r(a,l,c){return l===l?n(a,l,c):e(a,t,c)}return pw=r,pw}var mw,GE;function CU(){if(GE)return mw;GE=1;var e=EU();function t(n,r){var a=n==null?0:n.length;return!!a&&e(n,r,0)>-1}return mw=t,mw}var gw,KE;function TU(){if(KE)return gw;KE=1;function e(t,n,r){for(var a=-1,l=t==null?0:t.length;++a<l;)if(r(n,t[a]))return!0;return!1}return gw=e,gw}var yw,YE;function AU(){if(YE)return yw;YE=1;function e(){}return yw=e,yw}var ww,XE;function RU(){if(XE)return ww;XE=1;var e=mM(),t=AU(),n=cb(),r=1/0,a=e&&1/n(new e([,-0]))[1]==r?function(l){return new e(l)}:t;return ww=a,ww}var vw,ZE;function MU(){if(ZE)return vw;ZE=1;var e=_M(),t=CU(),n=TU(),r=SM(),a=RU(),l=cb(),c=200;function u(f,p,h){var m=-1,y=t,w=f.length,j=!0,k=[],S=k;if(h)j=!1,y=n;else if(w>=c){var b=p?null:a(f);if(b)return l(b);j=!1,y=r,S=new e}else S=p?[]:k;e:for(;++m<w;){var N=f[m],E=p?p(N):N;if(N=h||N!==0?N:0,j&&E===E){for(var C=S.length;C--;)if(S[C]===E)continue e;p&&S.push(E),k.push(N)}else y(S,E,h)||(S!==k&&S.push(E),k.push(N))}return k}return vw=u,vw}var xw,QE;function HM(){if(QE)return xw;QE=1;var e=Qs(),t=Ns();function n(r){return t(r)&&e(r)}return xw=n,xw}var bw,JE;function IU(){if(JE)return bw;JE=1;var e=db(),t=Jh(),n=MU(),r=HM(),a=t(function(l){return n(e(l,1,r,!0))});return bw=a,bw}var kw,eC;function $U(){if(eC)return kw;eC=1;var e=Xh();function t(n,r){return e(r,function(a){return n[a]})}return kw=t,kw}var Nw,tC;function UM(){if(tC)return Nw;tC=1;var e=$U(),t=qa();function n(r){return r==null?[]:e(r,t(r))}return Nw=n,Nw}var _w,nC;function Tr(){if(nC)return _w;nC=1;var e;if(typeof X0=="function")try{e={clone:BH(),constant:ob(),each:NM(),filter:$M(),has:OM(),isArray:Kt(),isEmpty:dU(),isFunction:Jc(),isUndefined:LM(),keys:qa(),map:DM(),reduce:FM(),size:vU(),transform:xU(),union:IU(),values:UM()}}catch{}return e||(e=window._),_w=e,_w}var Sw,rC;function hb(){if(rC)return Sw;rC=1;var e=Tr();Sw=a;var t="\0",n="\0",r="";function a(h){this._isDirected=e.has(h,"directed")?h.directed:!0,this._isMultigraph=e.has(h,"multigraph")?h.multigraph:!1,this._isCompound=e.has(h,"compound")?h.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}a.prototype._nodeCount=0,a.prototype._edgeCount=0,a.prototype.isDirected=function(){return this._isDirected},a.prototype.isMultigraph=function(){return this._isMultigraph},a.prototype.isCompound=function(){return this._isCompound},a.prototype.setGraph=function(h){return this._label=h,this},a.prototype.graph=function(){return this._label},a.prototype.setDefaultNodeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultNodeLabelFn=h,this},a.prototype.nodeCount=function(){return this._nodeCount},a.prototype.nodes=function(){return e.keys(this._nodes)},a.prototype.sources=function(){var h=this;return e.filter(this.nodes(),function(m){return e.isEmpty(h._in[m])})},a.prototype.sinks=function(){var h=this;return e.filter(this.nodes(),function(m){return e.isEmpty(h._out[m])})},a.prototype.setNodes=function(h,m){var y=arguments,w=this;return e.each(h,function(j){y.length>1?w.setNode(j,m):w.setNode(j)}),this},a.prototype.setNode=function(h,m){return e.has(this._nodes,h)?(arguments.length>1&&(this._nodes[h]=m),this):(this._nodes[h]=arguments.length>1?m:this._defaultNodeLabelFn(h),this._isCompound&&(this._parent[h]=n,this._children[h]={},this._children[n][h]=!0),this._in[h]={},this._preds[h]={},this._out[h]={},this._sucs[h]={},++this._nodeCount,this)},a.prototype.node=function(h){return this._nodes[h]},a.prototype.hasNode=function(h){return e.has(this._nodes,h)},a.prototype.removeNode=function(h){var m=this;if(e.has(this._nodes,h)){var y=function(w){m.removeEdge(m._edgeObjs[w])};delete this._nodes[h],this._isCompound&&(this._removeFromParentsChildList(h),delete this._parent[h],e.each(this.children(h),function(w){m.setParent(w)}),delete this._children[h]),e.each(e.keys(this._in[h]),y),delete this._in[h],delete this._preds[h],e.each(e.keys(this._out[h]),y),delete this._out[h],delete this._sucs[h],--this._nodeCount}return this},a.prototype.setParent=function(h,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=n;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===h)throw new Error("Setting "+m+" as parent of "+h+" would create a cycle");this.setNode(m)}return this.setNode(h),this._removeFromParentsChildList(h),this._parent[h]=m,this._children[m][h]=!0,this},a.prototype._removeFromParentsChildList=function(h){delete this._children[this._parent[h]][h]},a.prototype.parent=function(h){if(this._isCompound){var m=this._parent[h];if(m!==n)return m}},a.prototype.children=function(h){if(e.isUndefined(h)&&(h=n),this._isCompound){var m=this._children[h];if(m)return e.keys(m)}else{if(h===n)return this.nodes();if(this.hasNode(h))return[]}},a.prototype.predecessors=function(h){var m=this._preds[h];if(m)return e.keys(m)},a.prototype.successors=function(h){var m=this._sucs[h];if(m)return e.keys(m)},a.prototype.neighbors=function(h){var m=this.predecessors(h);if(m)return e.union(m,this.successors(h))},a.prototype.isLeaf=function(h){var m;return this.isDirected()?m=this.successors(h):m=this.neighbors(h),m.length===0},a.prototype.filterNodes=function(h){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(k,S){h(S)&&m.setNode(S,k)}),e.each(this._edgeObjs,function(k){m.hasNode(k.v)&&m.hasNode(k.w)&&m.setEdge(k,y.edge(k))});var w={};function j(k){var S=y.parent(k);return S===void 0||m.hasNode(S)?(w[k]=S,S):S in w?w[S]:j(S)}return this._isCompound&&e.each(m.nodes(),function(k){m.setParent(k,j(k))}),m},a.prototype.setDefaultEdgeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultEdgeLabelFn=h,this},a.prototype.edgeCount=function(){return this._edgeCount},a.prototype.edges=function(){return e.values(this._edgeObjs)},a.prototype.setPath=function(h,m){var y=this,w=arguments;return e.reduce(h,function(j,k){return w.length>1?y.setEdge(j,k,m):y.setEdge(j,k),k}),this},a.prototype.setEdge=function(){var h,m,y,w,j=!1,k=arguments[0];typeof k=="object"&&k!==null&&"v"in k?(h=k.v,m=k.w,y=k.name,arguments.length===2&&(w=arguments[1],j=!0)):(h=k,m=arguments[1],y=arguments[3],arguments.length>2&&(w=arguments[2],j=!0)),h=""+h,m=""+m,e.isUndefined(y)||(y=""+y);var S=u(this._isDirected,h,m,y);if(e.has(this._edgeLabels,S))return j&&(this._edgeLabels[S]=w),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(h),this.setNode(m),this._edgeLabels[S]=j?w:this._defaultEdgeLabelFn(h,m,y);var b=f(this._isDirected,h,m,y);return h=b.v,m=b.w,Object.freeze(b),this._edgeObjs[S]=b,l(this._preds[m],h),l(this._sucs[h],m),this._in[m][S]=b,this._out[h][S]=b,this._edgeCount++,this},a.prototype.edge=function(h,m,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,h,m,y);return this._edgeLabels[w]},a.prototype.hasEdge=function(h,m,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,h,m,y);return e.has(this._edgeLabels,w)},a.prototype.removeEdge=function(h,m,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,h,m,y),j=this._edgeObjs[w];return j&&(h=j.v,m=j.w,delete this._edgeLabels[w],delete this._edgeObjs[w],c(this._preds[m],h),c(this._sucs[h],m),delete this._in[m][w],delete this._out[h][w],this._edgeCount--),this},a.prototype.inEdges=function(h,m){var y=this._in[h];if(y){var w=e.values(y);return m?e.filter(w,function(j){return j.v===m}):w}},a.prototype.outEdges=function(h,m){var y=this._out[h];if(y){var w=e.values(y);return m?e.filter(w,function(j){return j.w===m}):w}},a.prototype.nodeEdges=function(h,m){var y=this.inEdges(h,m);if(y)return y.concat(this.outEdges(h,m))};function l(h,m){h[m]?h[m]++:h[m]=1}function c(h,m){--h[m]||delete h[m]}function u(h,m,y,w){var j=""+m,k=""+y;if(!h&&j>k){var S=j;j=k,k=S}return j+r+k+r+(e.isUndefined(w)?t:w)}function f(h,m,y,w){var j=""+m,k=""+y;if(!h&&j>k){var S=j;j=k,k=S}var b={v:j,w:k};return w&&(b.name=w),b}function p(h,m){return u(h,m.v,m.w,m.name)}return Sw}var jw,sC;function OU(){return sC||(sC=1,jw="2.1.8"),jw}var Ew,aC;function LU(){return aC||(aC=1,Ew={Graph:hb(),version:OU()}),Ew}var Cw,oC;function PU(){if(oC)return Cw;oC=1;var e=Tr(),t=hb();Cw={write:n,read:l};function n(c){var u={options:{directed:c.isDirected(),multigraph:c.isMultigraph(),compound:c.isCompound()},nodes:r(c),edges:a(c)};return e.isUndefined(c.graph())||(u.value=e.clone(c.graph())),u}function r(c){return e.map(c.nodes(),function(u){var f=c.node(u),p=c.parent(u),h={v:u};return e.isUndefined(f)||(h.value=f),e.isUndefined(p)||(h.parent=p),h})}function a(c){return e.map(c.edges(),function(u){var f=c.edge(u),p={v:u.v,w:u.w};return e.isUndefined(u.name)||(p.name=u.name),e.isUndefined(f)||(p.value=f),p})}function l(c){var u=new t(c.options).setGraph(c.value);return e.each(c.nodes,function(f){u.setNode(f.v,f.value),f.parent&&u.setParent(f.v,f.parent)}),e.each(c.edges,function(f){u.setEdge({v:f.v,w:f.w,name:f.name},f.value)}),u}return Cw}var Tw,iC;function DU(){if(iC)return Tw;iC=1;var e=Tr();Tw=t;function t(n){var r={},a=[],l;function c(u){e.has(r,u)||(r[u]=!0,l.push(u),e.each(n.successors(u),c),e.each(n.predecessors(u),c))}return e.each(n.nodes(),function(u){l=[],c(u),l.length&&a.push(l)}),a}return Tw}var Aw,lC;function WM(){if(lC)return Aw;lC=1;var e=Tr();Aw=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(n){return n.key})},t.prototype.has=function(n){return e.has(this._keyIndices,n)},t.prototype.priority=function(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(n,r){var a=this._keyIndices;if(n=String(n),!e.has(a,n)){var l=this._arr,c=l.length;return a[n]=c,l.push({key:n,priority:r}),this._decrease(c),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key},t.prototype.decrease=function(n,r){var a=this._keyIndices[n];if(r>this._arr[a].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[a].priority+" New: "+r);this._arr[a].priority=r,this._decrease(a)},t.prototype._heapify=function(n){var r=this._arr,a=2*n,l=a+1,c=n;a<r.length&&(c=r[a].priority<r[c].priority?a:c,l<r.length&&(c=r[l].priority<r[c].priority?l:c),c!==n&&(this._swap(n,c),this._heapify(c)))},t.prototype._decrease=function(n){for(var r=this._arr,a=r[n].priority,l;n!==0&&(l=n>>1,!(r[l].priority<a));)this._swap(n,l),n=l},t.prototype._swap=function(n,r){var a=this._arr,l=this._keyIndices,c=a[n],u=a[r];a[n]=u,a[r]=c,l[u.key]=n,l[c.key]=r},Aw}var Rw,cC;function VM(){if(cC)return Rw;cC=1;var e=Tr(),t=WM();Rw=r;var n=e.constant(1);function r(l,c,u,f){return a(l,String(c),u||n,f||function(p){return l.outEdges(p)})}function a(l,c,u,f){var p={},h=new t,m,y,w=function(j){var k=j.v!==m?j.v:j.w,S=p[k],b=u(j),N=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+j+" Weight: "+b);N<S.distance&&(S.distance=N,S.predecessor=m,h.decrease(k,N))};for(l.nodes().forEach(function(j){var k=j===c?0:Number.POSITIVE_INFINITY;p[j]={distance:k},h.add(j,k)});h.size()>0&&(m=h.removeMin(),y=p[m],y.distance!==Number.POSITIVE_INFINITY);)f(m).forEach(w);return p}return Rw}var Mw,uC;function FU(){if(uC)return Mw;uC=1;var e=VM(),t=Tr();Mw=n;function n(r,a,l){return t.transform(r.nodes(),function(c,u){c[u]=e(r,u,a,l)},{})}return Mw}var Iw,dC;function GM(){if(dC)return Iw;dC=1;var e=Tr();Iw=t;function t(n){var r=0,a=[],l={},c=[];function u(f){var p=l[f]={onStack:!0,lowlink:r,index:r++};if(a.push(f),n.successors(f).forEach(function(y){e.has(l,y)?l[y].onStack&&(p.lowlink=Math.min(p.lowlink,l[y].index)):(u(y),p.lowlink=Math.min(p.lowlink,l[y].lowlink))}),p.lowlink===p.index){var h=[],m;do m=a.pop(),l[m].onStack=!1,h.push(m);while(f!==m);c.push(h)}}return n.nodes().forEach(function(f){e.has(l,f)||u(f)}),c}return Iw}var $w,hC;function qU(){if(hC)return $w;hC=1;var e=Tr(),t=GM();$w=n;function n(r){return e.filter(t(r),function(a){return a.length>1||a.length===1&&r.hasEdge(a[0],a[0])})}return $w}var Ow,fC;function BU(){if(fC)return Ow;fC=1;var e=Tr();Ow=n;var t=e.constant(1);function n(a,l,c){return r(a,l||t,c||function(u){return a.outEdges(u)})}function r(a,l,c){var u={},f=a.nodes();return f.forEach(function(p){u[p]={},u[p][p]={distance:0},f.forEach(function(h){p!==h&&(u[p][h]={distance:Number.POSITIVE_INFINITY})}),c(p).forEach(function(h){var m=h.v===p?h.w:h.v,y=l(h);u[p][m]={distance:y,predecessor:p}})}),f.forEach(function(p){var h=u[p];f.forEach(function(m){var y=u[m];f.forEach(function(w){var j=y[p],k=h[w],S=y[w],b=j.distance+k.distance;b<S.distance&&(S.distance=b,S.predecessor=k.predecessor)})})}),u}return Ow}var Lw,pC;function KM(){if(pC)return Lw;pC=1;var e=Tr();Lw=t,t.CycleException=n;function t(r){var a={},l={},c=[];function u(f){if(e.has(l,f))throw new n;e.has(a,f)||(l[f]=!0,a[f]=!0,e.each(r.predecessors(f),u),delete l[f],c.push(f))}if(e.each(r.sinks(),u),e.size(a)!==r.nodeCount())throw new n;return c}function n(){}return n.prototype=new Error,Lw}var Pw,mC;function zU(){if(mC)return Pw;mC=1;var e=KM();Pw=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return Pw}var Dw,gC;function YM(){if(gC)return Dw;gC=1;var e=Tr();Dw=t;function t(r,a,l){e.isArray(a)||(a=[a]);var c=(r.isDirected()?r.successors:r.neighbors).bind(r),u=[],f={};return e.each(a,function(p){if(!r.hasNode(p))throw new Error("Graph does not have node: "+p);n(r,p,l==="post",f,c,u)}),u}function n(r,a,l,c,u,f){e.has(c,a)||(c[a]=!0,l||f.push(a),e.each(u(a),function(p){n(r,p,l,c,u,f)}),l&&f.push(a))}return Dw}var Fw,yC;function HU(){if(yC)return Fw;yC=1;var e=YM();Fw=t;function t(n,r){return e(n,r,"post")}return Fw}var qw,wC;function UU(){if(wC)return qw;wC=1;var e=YM();qw=t;function t(n,r){return e(n,r,"pre")}return qw}var Bw,vC;function WU(){if(vC)return Bw;vC=1;var e=Tr(),t=hb(),n=WM();Bw=r;function r(a,l){var c=new t,u={},f=new n,p;function h(y){var w=y.v===p?y.w:y.v,j=f.priority(w);if(j!==void 0){var k=l(y);k<j&&(u[w]=p,f.decrease(w,k))}}if(a.nodeCount()===0)return c;e.each(a.nodes(),function(y){f.add(y,Number.POSITIVE_INFINITY),c.setNode(y)}),f.decrease(a.nodes()[0],0);for(var m=!1;f.size()>0;){if(p=f.removeMin(),e.has(u,p))c.setEdge(p,u[p]);else{if(m)throw new Error("Input graph is not connected: "+a);m=!0}a.nodeEdges(p).forEach(h)}return c}return Bw}var zw,xC;function VU(){return xC||(xC=1,zw={components:DU(),dijkstra:VM(),dijkstraAll:FU(),findCycles:qU(),floydWarshall:BU(),isAcyclic:zU(),postorder:HU(),preorder:UU(),prim:WU(),tarjan:GM(),topsort:KM()}),zw}var Hw,bC;function GU(){if(bC)return Hw;bC=1;var e=LU();return Hw={Graph:e.Graph,json:PU(),alg:VU(),version:e.version},Hw}var Uw,kC;function Jr(){if(kC)return Uw;kC=1;var e;if(typeof X0=="function")try{e=GU()}catch{}return e||(e=window.graphlib),Uw=e,Uw}var Ww,NC;function KU(){if(NC)return Ww;NC=1;var e=xM(),t=1,n=4;function r(a){return e(a,t|n)}return Ww=r,Ww}var Vw,_C;function ef(){if(_C)return Vw;_C=1;var e=hl(),t=Qs(),n=Wh(),r=Cr();function a(l,c,u){if(!r(u))return!1;var f=typeof c;return(f=="number"?t(u)&&n(c,u.length):f=="string"&&c in u)?e(u[c],l):!1}return Vw=a,Vw}var Gw,SC;function YU(){if(SC)return Gw;SC=1;var e=Jh(),t=hl(),n=ef(),r=Ho(),a=Object.prototype,l=a.hasOwnProperty,c=e(function(u,f){u=Object(u);var p=-1,h=f.length,m=h>2?f[2]:void 0;for(m&&n(f[0],f[1],m)&&(h=1);++p<h;)for(var y=f[p],w=r(y),j=-1,k=w.length;++j<k;){var S=w[j],b=u[S];(b===void 0||t(b,a[S])&&!l.call(u,S))&&(u[S]=y[S])}return u});return Gw=c,Gw}var Kw,jC;function XU(){if(jC)return Kw;jC=1;var e=Js(),t=Qs(),n=qa();function r(a){return function(l,c,u){var f=Object(l);if(!t(l)){var p=e(c,3);l=n(l),c=function(m){return p(f[m],m,f)}}var h=a(l,c,u);return h>-1?f[p?l[h]:h]:void 0}}return Kw=r,Kw}var Yw,EC;function ZU(){if(EC)return Yw;EC=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return Yw=t,Yw}var Xw,CC;function QU(){if(CC)return Xw;CC=1;var e=ZU(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return Xw=n,Xw}var Zw,TC;function JU(){if(TC)return Zw;TC=1;var e=QU(),t=Cr(),n=gl(),r=NaN,a=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt;function f(p){if(typeof p=="number")return p;if(n(p))return r;if(t(p)){var h=typeof p.valueOf=="function"?p.valueOf():p;p=t(h)?h+"":h}if(typeof p!="string")return p===0?p:+p;p=e(p);var m=l.test(p);return m||c.test(p)?u(p.slice(2),m?2:8):a.test(p)?r:+p}return Zw=f,Zw}var Qw,AC;function XM(){if(AC)return Qw;AC=1;var e=JU(),t=1/0,n=17976931348623157e292;function r(a){if(!a)return a===0?a:0;if(a=e(a),a===t||a===-t){var l=a<0?-1:1;return l*n}return a===a?a:0}return Qw=r,Qw}var Jw,RC;function eW(){if(RC)return Jw;RC=1;var e=XM();function t(n){var r=e(n),a=r%1;return r===r?a?r-a:r:0}return Jw=t,Jw}var ev,MC;function tW(){if(MC)return ev;MC=1;var e=zM(),t=Js(),n=eW(),r=Math.max;function a(l,c,u){var f=l==null?0:l.length;if(!f)return-1;var p=u==null?0:n(u);return p<0&&(p=r(f+p,0)),e(l,t(c,3),p)}return ev=a,ev}var tv,IC;function nW(){if(IC)return tv;IC=1;var e=XU(),t=tW(),n=e(t);return tv=n,tv}var nv,$C;function ZM(){if($C)return nv;$C=1;var e=db();function t(n){var r=n==null?0:n.length;return r?e(n,1):[]}return nv=t,nv}var rv,OC;function rW(){if(OC)return rv;OC=1;var e=ib(),t=bM(),n=Ho();function r(a,l){return a==null?a:e(a,t(l),n)}return rv=r,rv}var sv,LC;function sW(){if(LC)return sv;LC=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return sv=e,sv}var av,PC;function aW(){if(PC)return av;PC=1;var e=Hh(),t=lb(),n=Js();function r(a,l){var c={};return l=n(l,3),t(a,function(u,f,p){e(c,f,l(u,f,p))}),c}return av=r,av}var ov,DC;function fb(){if(DC)return ov;DC=1;var e=gl();function t(n,r,a){for(var l=-1,c=n.length;++l<c;){var u=n[l],f=r(u);if(f!=null&&(p===void 0?f===f&&!e(f):a(f,p)))var p=f,h=u}return h}return ov=t,ov}var iv,FC;function oW(){if(FC)return iv;FC=1;function e(t,n){return t>n}return iv=e,iv}var lv,qC;function iW(){if(qC)return lv;qC=1;var e=fb(),t=oW(),n=Uo();function r(a){return a&&a.length?e(a,n,t):void 0}return lv=r,lv}var cv,BC;function QM(){if(BC)return cv;BC=1;var e=Hh(),t=hl();function n(r,a,l){(l!==void 0&&!t(r[a],l)||l===void 0&&!(a in r))&&e(r,a,l)}return cv=n,cv}var uv,zC;function lW(){if(zC)return uv;zC=1;var e=Bo(),t=Kh(),n=Ns(),r="[object Object]",a=Function.prototype,l=Object.prototype,c=a.toString,u=l.hasOwnProperty,f=c.call(Object);function p(h){if(!n(h)||e(h)!=r)return!1;var m=t(h);if(m===null)return!0;var y=u.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&c.call(y)==f}return uv=p,uv}var dv,HC;function JM(){if(HC)return dv;HC=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return dv=e,dv}var hv,UC;function cW(){if(UC)return hv;UC=1;var e=eu(),t=Ho();function n(r){return e(r,t(r))}return hv=n,hv}var fv,WC;function uW(){if(WC)return fv;WC=1;var e=QM(),t=lM(),n=yM(),r=cM(),a=vM(),l=tu(),c=Kt(),u=HM(),f=pl(),p=Jc(),h=Cr(),m=lW(),y=nu(),w=JM(),j=cW();function k(S,b,N,E,C,T,A){var I=w(S,N),B=w(b,N),q=A.get(B);if(q){e(S,N,q);return}var L=T?T(I,B,N+"",S,b,A):void 0,U=L===void 0;if(U){var X=c(B),Y=!X&&f(B),M=!X&&!Y&&y(B);L=B,X||Y||M?c(I)?L=I:u(I)?L=r(I):Y?(U=!1,L=t(B,!0)):M?(U=!1,L=n(B,!0)):L=[]:m(B)||l(B)?(L=I,l(I)?L=j(I):(!h(I)||p(I))&&(L=a(B))):U=!1}U&&(A.set(B,L),C(L,B,E,T,A),A.delete(B)),e(S,N,L)}return fv=k,fv}var pv,VC;function dW(){if(VC)return pv;VC=1;var e=zh(),t=QM(),n=ib(),r=uW(),a=Cr(),l=Ho(),c=JM();function u(f,p,h,m,y){f!==p&&n(p,function(w,j){if(y||(y=new e),a(w))r(f,p,j,h,u,m,y);else{var k=m?m(c(f,j),w,j+"",f,p,y):void 0;k===void 0&&(k=w),t(f,j,k)}},l)}return pv=u,pv}var mv,GC;function hW(){if(GC)return mv;GC=1;var e=Jh(),t=ef();function n(r){return e(function(a,l){var c=-1,u=l.length,f=u>1?l[u-1]:void 0,p=u>2?l[2]:void 0;for(f=r.length>3&&typeof f=="function"?(u--,f):void 0,p&&t(l[0],l[1],p)&&(f=u<3?void 0:f,u=1),a=Object(a);++c<u;){var h=l[c];h&&r(a,h,c,f)}return a})}return mv=n,mv}var gv,KC;function fW(){if(KC)return gv;KC=1;var e=dW(),t=hW(),n=t(function(r,a,l){e(r,a,l)});return gv=n,gv}var yv,YC;function eI(){if(YC)return yv;YC=1;function e(t,n){return t<n}return yv=e,yv}var wv,XC;function pW(){if(XC)return wv;XC=1;var e=fb(),t=eI(),n=Uo();function r(a){return a&&a.length?e(a,n,t):void 0}return wv=r,wv}var vv,ZC;function mW(){if(ZC)return vv;ZC=1;var e=fb(),t=Js(),n=eI();function r(a,l){return a&&a.length?e(a,t(l,2),n):void 0}return vv=r,vv}var xv,QC;function gW(){if(QC)return xv;QC=1;var e=ts(),t=function(){return e.Date.now()};return xv=t,xv}var bv,JC;function yW(){if(JC)return bv;JC=1;var e=Uh(),t=Zh(),n=Wh(),r=Cr(),a=ru();function l(c,u,f,p){if(!r(c))return c;u=t(u,c);for(var h=-1,m=u.length,y=m-1,w=c;w!=null&&++h<m;){var j=a(u[h]),k=f;if(j==="__proto__"||j==="constructor"||j==="prototype")return c;if(h!=y){var S=w[j];k=p?p(S,j,w):void 0,k===void 0&&(k=r(S)?S:n(u[h+1])?[]:{})}e(w,j,k),w=w[j]}return c}return bv=l,bv}var kv,eT;function wW(){if(eT)return kv;eT=1;var e=Qh(),t=yW(),n=Zh();function r(a,l,c){for(var u=-1,f=l.length,p={};++u<f;){var h=l[u],m=e(a,h);c(m,h)&&t(p,n(h,a),m)}return p}return kv=r,kv}var Nv,tT;function vW(){if(tT)return Nv;tT=1;var e=wW(),t=MM();function n(r,a){return e(r,a,function(l,c){return t(r,c)})}return Nv=n,Nv}var _v,nT;function xW(){if(nT)return _v;nT=1;var e=ZM(),t=qM(),n=BM();function r(a){return n(t(a,void 0,e),a+"")}return _v=r,_v}var Sv,rT;function bW(){if(rT)return Sv;rT=1;var e=vW(),t=xW(),n=t(function(r,a){return r==null?{}:e(r,a)});return Sv=n,Sv}var jv,sT;function kW(){if(sT)return jv;sT=1;var e=Math.ceil,t=Math.max;function n(r,a,l,c){for(var u=-1,f=t(e((a-r)/(l||1)),0),p=Array(f);f--;)p[c?f:++u]=r,r+=l;return p}return jv=n,jv}var Ev,aT;function NW(){if(aT)return Ev;aT=1;var e=kW(),t=ef(),n=XM();function r(a){return function(l,c,u){return u&&typeof u!="number"&&t(l,c,u)&&(c=u=void 0),l=n(l),c===void 0?(c=l,l=0):c=n(c),u=u===void 0?l<c?1:-1:n(u),e(l,c,u,a)}}return Ev=r,Ev}var Cv,oT;function _W(){if(oT)return Cv;oT=1;var e=NW(),t=e();return Cv=t,Cv}var Tv,iT;function SW(){if(iT)return Tv;iT=1;function e(t,n){var r=t.length;for(t.sort(n);r--;)t[r]=t[r].value;return t}return Tv=e,Tv}var Av,lT;function jW(){if(lT)return Av;lT=1;var e=gl();function t(n,r){if(n!==r){var a=n!==void 0,l=n===null,c=n===n,u=e(n),f=r!==void 0,p=r===null,h=r===r,m=e(r);if(!p&&!m&&!u&&n>r||u&&f&&h&&!p&&!m||l&&f&&h||!a&&h||!c)return 1;if(!l&&!u&&!m&&n<r||m&&a&&c&&!l&&!u||p&&a&&c||!f&&c||!h)return-1}return 0}return Av=t,Av}var Rv,cT;function EW(){if(cT)return Rv;cT=1;var e=jW();function t(n,r,a){for(var l=-1,c=n.criteria,u=r.criteria,f=c.length,p=a.length;++l<f;){var h=e(c[l],u[l]);if(h){if(l>=p)return h;var m=a[l];return h*(m=="desc"?-1:1)}}return n.index-r.index}return Rv=t,Rv}var Mv,uT;function CW(){if(uT)return Mv;uT=1;var e=Xh(),t=Qh(),n=Js(),r=PM(),a=SW(),l=Vh(),c=EW(),u=Uo(),f=Kt();function p(h,m,y){m.length?m=e(m,function(k){return f(k)?function(S){return t(S,k.length===1?k[0]:k)}:k}):m=[u];var w=-1;m=e(m,l(n));var j=r(h,function(k,S,b){var N=e(m,function(E){return E(k)});return{criteria:N,index:++w,value:k}});return a(j,function(k,S){return c(k,S,y)})}return Mv=p,Mv}var Iv,dT;function TW(){if(dT)return Iv;dT=1;var e=db(),t=CW(),n=Jh(),r=ef(),a=n(function(l,c){if(l==null)return[];var u=c.length;return u>1&&r(l,c[0],c[1])?c=[]:u>2&&r(c[0],c[1],c[2])&&(c=[c[0]]),t(l,e(c,1),[])});return Iv=a,Iv}var $v,hT;function AW(){if(hT)return $v;hT=1;var e=AM(),t=0;function n(r){var a=++t;return e(r)+a}return $v=n,$v}var Ov,fT;function RW(){if(fT)return Ov;fT=1;function e(t,n,r){for(var a=-1,l=t.length,c=n.length,u={};++a<l;){var f=a<c?n[a]:void 0;r(u,t[a],f)}return u}return Ov=e,Ov}var Lv,pT;function MW(){if(pT)return Lv;pT=1;var e=Uh(),t=RW();function n(r,a){return t(r||[],a||[],e)}return Lv=n,Lv}var Pv,mT;function Mt(){if(mT)return Pv;mT=1;var e;if(typeof X0=="function")try{e={cloneDeep:KU(),constant:ob(),defaults:YU(),each:NM(),filter:$M(),find:nW(),flatten:ZM(),forEach:kM(),forIn:rW(),has:OM(),isUndefined:LM(),last:sW(),map:DM(),mapValues:aW(),max:iW(),merge:fW(),min:pW(),minBy:mW(),now:gW(),pick:bW(),range:_W(),reduce:FM(),sortBy:TW(),uniqueId:AW(),values:UM(),zipObject:MW()}}catch{}return e||(e=window._),Pv=e,Pv}var Dv,gT;function IW(){if(gT)return Dv;gT=1,Dv=e;function e(){var r={};r._next=r._prev=r,this._sentinel=r}e.prototype.dequeue=function(){var r=this._sentinel,a=r._prev;if(a!==r)return t(a),a},e.prototype.enqueue=function(r){var a=this._sentinel;r._prev&&r._next&&t(r),r._next=a._next,a._next._prev=r,a._next=r,r._prev=a},e.prototype.toString=function(){for(var r=[],a=this._sentinel,l=a._prev;l!==a;)r.push(JSON.stringify(l,n)),l=l._prev;return"["+r.join(", ")+"]"};function t(r){r._prev._next=r._next,r._next._prev=r._prev,delete r._next,delete r._prev}function n(r,a){if(r!=="_next"&&r!=="_prev")return a}return Dv}var Fv,yT;function $W(){if(yT)return Fv;yT=1;var e=Mt(),t=Jr().Graph,n=IW();Fv=a;var r=e.constant(1);function a(p,h){if(p.nodeCount()<=1)return[];var m=u(p,h||r),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(w){return p.outEdges(w.v,w.w)}),!0)}function l(p,h,m){for(var y=[],w=h[h.length-1],j=h[0],k;p.nodeCount();){for(;k=j.dequeue();)c(p,h,m,k);for(;k=w.dequeue();)c(p,h,m,k);if(p.nodeCount()){for(var S=h.length-2;S>0;--S)if(k=h[S].dequeue(),k){y=y.concat(c(p,h,m,k,!0));break}}}return y}function c(p,h,m,y,w){var j=w?[]:void 0;return e.forEach(p.inEdges(y.v),function(k){var S=p.edge(k),b=p.node(k.v);w&&j.push({v:k.v,w:k.w}),b.out-=S,f(h,m,b)}),e.forEach(p.outEdges(y.v),function(k){var S=p.edge(k),b=k.w,N=p.node(b);N.in-=S,f(h,m,N)}),p.removeNode(y.v),j}function u(p,h){var m=new t,y=0,w=0;e.forEach(p.nodes(),function(S){m.setNode(S,{v:S,in:0,out:0})}),e.forEach(p.edges(),function(S){var b=m.edge(S.v,S.w)||0,N=h(S),E=b+N;m.setEdge(S.v,S.w,E),w=Math.max(w,m.node(S.v).out+=N),y=Math.max(y,m.node(S.w).in+=N)});var j=e.range(w+y+3).map(function(){return new n}),k=y+1;return e.forEach(m.nodes(),function(S){f(j,k,m.node(S))}),{graph:m,buckets:j,zeroIdx:k}}function f(p,h,m){m.out?m.in?p[m.out-m.in+h].enqueue(m):p[p.length-1].enqueue(m):p[0].enqueue(m)}return Fv}var qv,wT;function OW(){if(wT)return qv;wT=1;var e=Mt(),t=$W();qv={run:n,undo:a};function n(l){var c=l.graph().acyclicer==="greedy"?t(l,u(l)):r(l);e.forEach(c,function(f){var p=l.edge(f);l.removeEdge(f),p.forwardName=f.name,p.reversed=!0,l.setEdge(f.w,f.v,p,e.uniqueId("rev"))});function u(f){return function(p){return f.edge(p).weight}}}function r(l){var c=[],u={},f={};function p(h){e.has(f,h)||(f[h]=!0,u[h]=!0,e.forEach(l.outEdges(h),function(m){e.has(u,m.w)?c.push(m):p(m.w)}),delete u[h])}return e.forEach(l.nodes(),p),c}function a(l){e.forEach(l.edges(),function(c){var u=l.edge(c);if(u.reversed){l.removeEdge(c);var f=u.forwardName;delete u.reversed,delete u.forwardName,l.setEdge(c.w,c.v,u,f)}})}return qv}var Bv,vT;function Wn(){if(vT)return Bv;vT=1;var e=Mt(),t=Jr().Graph;Bv={addDummyNode:n,simplify:r,asNonCompoundGraph:a,successorWeights:l,predecessorWeights:c,intersectRect:u,buildLayerMatrix:f,normalizeRanks:p,removeEmptyRanks:h,addBorderNode:m,maxRank:y,partition:w,time:j,notime:k};function n(S,b,N,E){var C;do C=e.uniqueId(E);while(S.hasNode(C));return N.dummy=b,S.setNode(C,N),C}function r(S){var b=new t().setGraph(S.graph());return e.forEach(S.nodes(),function(N){b.setNode(N,S.node(N))}),e.forEach(S.edges(),function(N){var E=b.edge(N.v,N.w)||{weight:0,minlen:1},C=S.edge(N);b.setEdge(N.v,N.w,{weight:E.weight+C.weight,minlen:Math.max(E.minlen,C.minlen)})}),b}function a(S){var b=new t({multigraph:S.isMultigraph()}).setGraph(S.graph());return e.forEach(S.nodes(),function(N){S.children(N).length||b.setNode(N,S.node(N))}),e.forEach(S.edges(),function(N){b.setEdge(N,S.edge(N))}),b}function l(S){var b=e.map(S.nodes(),function(N){var E={};return e.forEach(S.outEdges(N),function(C){E[C.w]=(E[C.w]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function c(S){var b=e.map(S.nodes(),function(N){var E={};return e.forEach(S.inEdges(N),function(C){E[C.v]=(E[C.v]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function u(S,b){var N=S.x,E=S.y,C=b.x-N,T=b.y-E,A=S.width/2,I=S.height/2;if(!C&&!T)throw new Error("Not possible to find intersection inside of the rectangle");var B,q;return Math.abs(T)*A>Math.abs(C)*I?(T<0&&(I=-I),B=I*C/T,q=I):(C<0&&(A=-A),B=A,q=A*T/C),{x:N+B,y:E+q}}function f(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(N){var E=S.node(N),C=E.rank;e.isUndefined(C)||(b[C][E.order]=N)}),b}function p(S){var b=e.min(e.map(S.nodes(),function(N){return S.node(N).rank}));e.forEach(S.nodes(),function(N){var E=S.node(N);e.has(E,"rank")&&(E.rank-=b)})}function h(S){var b=e.min(e.map(S.nodes(),function(T){return S.node(T).rank})),N=[];e.forEach(S.nodes(),function(T){var A=S.node(T).rank-b;N[A]||(N[A]=[]),N[A].push(T)});var E=0,C=S.graph().nodeRankFactor;e.forEach(N,function(T,A){e.isUndefined(T)&&A%C!==0?--E:E&&e.forEach(T,function(I){S.node(I).rank+=E})})}function m(S,b,N,E){var C={width:0,height:0};return arguments.length>=4&&(C.rank=N,C.order=E),n(S,"border",C,b)}function y(S){return e.max(e.map(S.nodes(),function(b){var N=S.node(b).rank;if(!e.isUndefined(N))return N}))}function w(S,b){var N={lhs:[],rhs:[]};return e.forEach(S,function(E){b(E)?N.lhs.push(E):N.rhs.push(E)}),N}function j(S,b){var N=e.now();try{return b()}finally{console.log(S+" time: "+(e.now()-N)+"ms")}}function k(S,b){return b()}return Bv}var zv,xT;function LW(){if(xT)return zv;xT=1;var e=Mt(),t=Wn();zv={run:n,undo:a};function n(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(c){r(l,c)})}function r(l,c){var u=c.v,f=l.node(u).rank,p=c.w,h=l.node(p).rank,m=c.name,y=l.edge(c),w=y.labelRank;if(h!==f+1){l.removeEdge(c);var j,k,S;for(S=0,++f;f<h;++S,++f)y.points=[],k={width:0,height:0,edgeLabel:y,edgeObj:c,rank:f},j=t.addDummyNode(l,"edge",k,"_d"),f===w&&(k.width=y.width,k.height=y.height,k.dummy="edge-label",k.labelpos=y.labelpos),l.setEdge(u,j,{weight:y.weight},m),S===0&&l.graph().dummyChains.push(j),u=j;l.setEdge(u,p,{weight:y.weight},m)}}function a(l){e.forEach(l.graph().dummyChains,function(c){var u=l.node(c),f=u.edgeLabel,p;for(l.setEdge(u.edgeObj,f);u.dummy;)p=l.successors(c)[0],l.removeNode(c),f.points.push({x:u.x,y:u.y}),u.dummy==="edge-label"&&(f.x=u.x,f.y=u.y,f.width=u.width,f.height=u.height),c=p,u=l.node(c)})}return zv}var Hv,bT;function gh(){if(bT)return Hv;bT=1;var e=Mt();Hv={longestPath:t,slack:n};function t(r){var a={};function l(c){var u=r.node(c);if(e.has(a,c))return u.rank;a[c]=!0;var f=e.min(e.map(r.outEdges(c),function(p){return l(p.w)-r.edge(p).minlen}));return(f===Number.POSITIVE_INFINITY||f===void 0||f===null)&&(f=0),u.rank=f}e.forEach(r.sources(),l)}function n(r,a){return r.node(a.w).rank-r.node(a.v).rank-r.edge(a).minlen}return Hv}var Uv,kT;function tI(){if(kT)return Uv;kT=1;var e=Mt(),t=Jr().Graph,n=gh().slack;Uv=r;function r(u){var f=new t({directed:!1}),p=u.nodes()[0],h=u.nodeCount();f.setNode(p,{});for(var m,y;a(f,u)<h;)m=l(f,u),y=f.hasNode(m.v)?n(u,m):-n(u,m),c(f,u,y);return f}function a(u,f){function p(h){e.forEach(f.nodeEdges(h),function(m){var y=m.v,w=h===y?m.w:y;!u.hasNode(w)&&!n(f,m)&&(u.setNode(w,{}),u.setEdge(h,w,{}),p(w))})}return e.forEach(u.nodes(),p),u.nodeCount()}function l(u,f){return e.minBy(f.edges(),function(p){if(u.hasNode(p.v)!==u.hasNode(p.w))return n(f,p)})}function c(u,f,p){e.forEach(u.nodes(),function(h){f.node(h).rank+=p})}return Uv}var Wv,NT;function PW(){if(NT)return Wv;NT=1;var e=Mt(),t=tI(),n=gh().slack,r=gh().longestPath,a=Jr().alg.preorder,l=Jr().alg.postorder,c=Wn().simplify;Wv=u,u.initLowLimValues=m,u.initCutValues=f,u.calcCutValue=h,u.leaveEdge=w,u.enterEdge=j,u.exchangeEdges=k;function u(E){E=c(E),r(E);var C=t(E);m(C),f(C,E);for(var T,A;T=w(C);)A=j(C,E,T),k(C,E,T,A)}function f(E,C){var T=l(E,E.nodes());T=T.slice(0,T.length-1),e.forEach(T,function(A){p(E,C,A)})}function p(E,C,T){var A=E.node(T),I=A.parent;E.edge(T,I).cutvalue=h(E,C,T)}function h(E,C,T){var A=E.node(T),I=A.parent,B=!0,q=C.edge(T,I),L=0;return q||(B=!1,q=C.edge(I,T)),L=q.weight,e.forEach(C.nodeEdges(T),function(U){var X=U.v===T,Y=X?U.w:U.v;if(Y!==I){var M=X===B,J=C.edge(U).weight;if(L+=M?J:-J,b(E,T,Y)){var V=E.edge(T,Y).cutvalue;L+=M?-V:V}}}),L}function m(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,T,A,I){var B=T,q=E.node(A);return C[A]=!0,e.forEach(E.neighbors(A),function(L){e.has(C,L)||(T=y(E,C,T,L,A))}),q.low=B,q.lim=T++,I?q.parent=I:delete q.parent,T}function w(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function j(E,C,T){var A=T.v,I=T.w;C.hasEdge(A,I)||(A=T.w,I=T.v);var B=E.node(A),q=E.node(I),L=B,U=!1;B.lim>q.lim&&(L=q,U=!0);var X=e.filter(C.edges(),function(Y){return U===N(E,E.node(Y.v),L)&&U!==N(E,E.node(Y.w),L)});return e.minBy(X,function(Y){return n(C,Y)})}function k(E,C,T,A){var I=T.v,B=T.w;E.removeEdge(I,B),E.setEdge(A.v,A.w,{}),m(E),f(E,C),S(E,C)}function S(E,C){var T=e.find(E.nodes(),function(I){return!C.node(I).parent}),A=a(E,T);A=A.slice(1),e.forEach(A,function(I){var B=E.node(I).parent,q=C.edge(I,B),L=!1;q||(q=C.edge(B,I),L=!0),C.node(I).rank=C.node(B).rank+(L?q.minlen:-q.minlen)})}function b(E,C,T){return E.hasEdge(C,T)}function N(E,C,T){return T.low<=C.lim&&C.lim<=T.lim}return Wv}var Vv,_T;function DW(){if(_T)return Vv;_T=1;var e=gh(),t=e.longestPath,n=tI(),r=PW();Vv=a;function a(f){switch(f.graph().ranker){case"network-simplex":u(f);break;case"tight-tree":c(f);break;case"longest-path":l(f);break;default:u(f)}}var l=t;function c(f){t(f),n(f)}function u(f){r(f)}return Vv}var Gv,ST;function FW(){if(ST)return Gv;ST=1;var e=Mt();Gv=t;function t(a){var l=r(a);e.forEach(a.graph().dummyChains,function(c){for(var u=a.node(c),f=u.edgeObj,p=n(a,l,f.v,f.w),h=p.path,m=p.lca,y=0,w=h[y],j=!0;c!==f.w;){if(u=a.node(c),j){for(;(w=h[y])!==m&&a.node(w).maxRank<u.rank;)y++;w===m&&(j=!1)}if(!j){for(;y<h.length-1&&a.node(w=h[y+1]).minRank<=u.rank;)y++;w=h[y]}a.setParent(c,w),c=a.successors(c)[0]}})}function n(a,l,c,u){var f=[],p=[],h=Math.min(l[c].low,l[u].low),m=Math.max(l[c].lim,l[u].lim),y,w;y=c;do y=a.parent(y),f.push(y);while(y&&(l[y].low>h||m>l[y].lim));for(w=y,y=u;(y=a.parent(y))!==w;)p.push(y);return{path:f.concat(p.reverse()),lca:w}}function r(a){var l={},c=0;function u(f){var p=c;e.forEach(a.children(f),u),l[f]={low:p,lim:c++}}return e.forEach(a.children(),u),l}return Gv}var Kv,jT;function qW(){if(jT)return Kv;jT=1;var e=Mt(),t=Wn();Kv={run:n,cleanup:c};function n(u){var f=t.addDummyNode(u,"root",{},"_root"),p=a(u),h=e.max(e.values(p))-1,m=2*h+1;u.graph().nestingRoot=f,e.forEach(u.edges(),function(w){u.edge(w).minlen*=m});var y=l(u)+1;e.forEach(u.children(),function(w){r(u,f,m,y,h,p,w)}),u.graph().nodeRankFactor=m}function r(u,f,p,h,m,y,w){var j=u.children(w);if(!j.length){w!==f&&u.setEdge(f,w,{weight:0,minlen:p});return}var k=t.addBorderNode(u,"_bt"),S=t.addBorderNode(u,"_bb"),b=u.node(w);u.setParent(k,w),b.borderTop=k,u.setParent(S,w),b.borderBottom=S,e.forEach(j,function(N){r(u,f,p,h,m,y,N);var E=u.node(N),C=E.borderTop?E.borderTop:N,T=E.borderBottom?E.borderBottom:N,A=E.borderTop?h:2*h,I=C!==T?1:m-y[w]+1;u.setEdge(k,C,{weight:A,minlen:I,nestingEdge:!0}),u.setEdge(T,S,{weight:A,minlen:I,nestingEdge:!0})}),u.parent(w)||u.setEdge(f,k,{weight:0,minlen:m+y[w]})}function a(u){var f={};function p(h,m){var y=u.children(h);y&&y.length&&e.forEach(y,function(w){p(w,m+1)}),f[h]=m}return e.forEach(u.children(),function(h){p(h,1)}),f}function l(u){return e.reduce(u.edges(),function(f,p){return f+u.edge(p).weight},0)}function c(u){var f=u.graph();u.removeNode(f.nestingRoot),delete f.nestingRoot,e.forEach(u.edges(),function(p){var h=u.edge(p);h.nestingEdge&&u.removeEdge(p)})}return Kv}var Yv,ET;function BW(){if(ET)return Yv;ET=1;var e=Mt(),t=Wn();Yv=n;function n(a){function l(c){var u=a.children(c),f=a.node(c);if(u.length&&e.forEach(u,l),e.has(f,"minRank")){f.borderLeft=[],f.borderRight=[];for(var p=f.minRank,h=f.maxRank+1;p<h;++p)r(a,"borderLeft","_bl",c,f,p),r(a,"borderRight","_br",c,f,p)}}e.forEach(a.children(),l)}function r(a,l,c,u,f,p){var h={width:0,height:0,rank:p,borderType:l},m=f[l][p-1],y=t.addDummyNode(a,"border",h,c);f[l][p]=y,a.setParent(y,u),m&&a.setEdge(m,y,{weight:1})}return Yv}var Xv,CT;function zW(){if(CT)return Xv;CT=1;var e=Mt();Xv={adjust:t,undo:n};function t(p){var h=p.graph().rankdir.toLowerCase();(h==="lr"||h==="rl")&&r(p)}function n(p){var h=p.graph().rankdir.toLowerCase();(h==="bt"||h==="rl")&&l(p),(h==="lr"||h==="rl")&&(u(p),r(p))}function r(p){e.forEach(p.nodes(),function(h){a(p.node(h))}),e.forEach(p.edges(),function(h){a(p.edge(h))})}function a(p){var h=p.width;p.width=p.height,p.height=h}function l(p){e.forEach(p.nodes(),function(h){c(p.node(h))}),e.forEach(p.edges(),function(h){var m=p.edge(h);e.forEach(m.points,c),e.has(m,"y")&&c(m)})}function c(p){p.y=-p.y}function u(p){e.forEach(p.nodes(),function(h){f(p.node(h))}),e.forEach(p.edges(),function(h){var m=p.edge(h);e.forEach(m.points,f),e.has(m,"x")&&f(m)})}function f(p){var h=p.x;p.x=p.y,p.y=h}return Xv}var Zv,TT;function HW(){if(TT)return Zv;TT=1;var e=Mt();Zv=t;function t(n){var r={},a=e.filter(n.nodes(),function(p){return!n.children(p).length}),l=e.max(e.map(a,function(p){return n.node(p).rank})),c=e.map(e.range(l+1),function(){return[]});function u(p){if(!e.has(r,p)){r[p]=!0;var h=n.node(p);c[h.rank].push(p),e.forEach(n.successors(p),u)}}var f=e.sortBy(a,function(p){return n.node(p).rank});return e.forEach(f,u),c}return Zv}var Qv,AT;function UW(){if(AT)return Qv;AT=1;var e=Mt();Qv=t;function t(r,a){for(var l=0,c=1;c<a.length;++c)l+=n(r,a[c-1],a[c]);return l}function n(r,a,l){for(var c=e.zipObject(l,e.map(l,function(y,w){return w})),u=e.flatten(e.map(a,function(y){return e.sortBy(e.map(r.outEdges(y),function(w){return{pos:c[w.w],weight:r.edge(w).weight}}),"pos")}),!0),f=1;f<l.length;)f<<=1;var p=2*f-1;f-=1;var h=e.map(new Array(p),function(){return 0}),m=0;return e.forEach(u.forEach(function(y){var w=y.pos+f;h[w]+=y.weight;for(var j=0;w>0;)w%2&&(j+=h[w+1]),w=w-1>>1,h[w]+=y.weight;m+=y.weight*j})),m}return Qv}var Jv,RT;function WW(){if(RT)return Jv;RT=1;var e=Mt();Jv=t;function t(n,r){return e.map(r,function(a){var l=n.inEdges(a);if(l.length){var c=e.reduce(l,function(u,f){var p=n.edge(f),h=n.node(f.v);return{sum:u.sum+p.weight*h.order,weight:u.weight+p.weight}},{sum:0,weight:0});return{v:a,barycenter:c.sum/c.weight,weight:c.weight}}else return{v:a}})}return Jv}var ex,MT;function VW(){if(MT)return ex;MT=1;var e=Mt();ex=t;function t(a,l){var c={};e.forEach(a,function(f,p){var h=c[f.v]={indegree:0,in:[],out:[],vs:[f.v],i:p};e.isUndefined(f.barycenter)||(h.barycenter=f.barycenter,h.weight=f.weight)}),e.forEach(l.edges(),function(f){var p=c[f.v],h=c[f.w];!e.isUndefined(p)&&!e.isUndefined(h)&&(h.indegree++,p.out.push(c[f.w]))});var u=e.filter(c,function(f){return!f.indegree});return n(u)}function n(a){var l=[];function c(p){return function(h){h.merged||(e.isUndefined(h.barycenter)||e.isUndefined(p.barycenter)||h.barycenter>=p.barycenter)&&r(p,h)}}function u(p){return function(h){h.in.push(p),--h.indegree===0&&a.push(h)}}for(;a.length;){var f=a.pop();l.push(f),e.forEach(f.in.reverse(),c(f)),e.forEach(f.out,u(f))}return e.map(e.filter(l,function(p){return!p.merged}),function(p){return e.pick(p,["vs","i","barycenter","weight"])})}function r(a,l){var c=0,u=0;a.weight&&(c+=a.barycenter*a.weight,u+=a.weight),l.weight&&(c+=l.barycenter*l.weight,u+=l.weight),a.vs=l.vs.concat(a.vs),a.barycenter=c/u,a.weight=u,a.i=Math.min(l.i,a.i),l.merged=!0}return ex}var tx,IT;function GW(){if(IT)return tx;IT=1;var e=Mt(),t=Wn();tx=n;function n(l,c){var u=t.partition(l,function(k){return e.has(k,"barycenter")}),f=u.lhs,p=e.sortBy(u.rhs,function(k){return-k.i}),h=[],m=0,y=0,w=0;f.sort(a(!!c)),w=r(h,p,w),e.forEach(f,function(k){w+=k.vs.length,h.push(k.vs),m+=k.barycenter*k.weight,y+=k.weight,w=r(h,p,w)});var j={vs:e.flatten(h,!0)};return y&&(j.barycenter=m/y,j.weight=y),j}function r(l,c,u){for(var f;c.length&&(f=e.last(c)).i<=u;)c.pop(),l.push(f.vs),u++;return u}function a(l){return function(c,u){return c.barycenter<u.barycenter?-1:c.barycenter>u.barycenter?1:l?u.i-c.i:c.i-u.i}}return tx}var nx,$T;function KW(){if($T)return nx;$T=1;var e=Mt(),t=WW(),n=VW(),r=GW();nx=a;function a(u,f,p,h){var m=u.children(f),y=u.node(f),w=y?y.borderLeft:void 0,j=y?y.borderRight:void 0,k={};w&&(m=e.filter(m,function(T){return T!==w&&T!==j}));var S=t(u,m);e.forEach(S,function(T){if(u.children(T.v).length){var A=a(u,T.v,p,h);k[T.v]=A,e.has(A,"barycenter")&&c(T,A)}});var b=n(S,p);l(b,k);var N=r(b,h);if(w&&(N.vs=e.flatten([w,N.vs,j],!0),u.predecessors(w).length)){var E=u.node(u.predecessors(w)[0]),C=u.node(u.predecessors(j)[0]);e.has(N,"barycenter")||(N.barycenter=0,N.weight=0),N.barycenter=(N.barycenter*N.weight+E.order+C.order)/(N.weight+2),N.weight+=2}return N}function l(u,f){e.forEach(u,function(p){p.vs=e.flatten(p.vs.map(function(h){return f[h]?f[h].vs:h}),!0)})}function c(u,f){e.isUndefined(u.barycenter)?(u.barycenter=f.barycenter,u.weight=f.weight):(u.barycenter=(u.barycenter*u.weight+f.barycenter*f.weight)/(u.weight+f.weight),u.weight+=f.weight)}return nx}var rx,OT;function YW(){if(OT)return rx;OT=1;var e=Mt(),t=Jr().Graph;rx=n;function n(a,l,c){var u=r(a),f=new t({compound:!0}).setGraph({root:u}).setDefaultNodeLabel(function(p){return a.node(p)});return e.forEach(a.nodes(),function(p){var h=a.node(p),m=a.parent(p);(h.rank===l||h.minRank<=l&&l<=h.maxRank)&&(f.setNode(p),f.setParent(p,m||u),e.forEach(a[c](p),function(y){var w=y.v===p?y.w:y.v,j=f.edge(w,p),k=e.isUndefined(j)?0:j.weight;f.setEdge(w,p,{weight:a.edge(y).weight+k})}),e.has(h,"minRank")&&f.setNode(p,{borderLeft:h.borderLeft[l],borderRight:h.borderRight[l]}))}),f}function r(a){for(var l;a.hasNode(l=e.uniqueId("_root")););return l}return rx}var sx,LT;function XW(){if(LT)return sx;LT=1;var e=Mt();sx=t;function t(n,r,a){var l={},c;e.forEach(a,function(u){for(var f=n.parent(u),p,h;f;){if(p=n.parent(f),p?(h=l[p],l[p]=f):(h=c,c=f),h&&h!==f){r.setEdge(h,f);return}f=p}})}return sx}var ax,PT;function ZW(){if(PT)return ax;PT=1;var e=Mt(),t=HW(),n=UW(),r=KW(),a=YW(),l=XW(),c=Jr().Graph,u=Wn();ax=f;function f(y){var w=u.maxRank(y),j=p(y,e.range(1,w+1),"inEdges"),k=p(y,e.range(w-1,-1,-1),"outEdges"),S=t(y);m(y,S);for(var b=Number.POSITIVE_INFINITY,N,E=0,C=0;C<4;++E,++C){h(E%2?j:k,E%4>=2),S=u.buildLayerMatrix(y);var T=n(y,S);T<b&&(C=0,N=e.cloneDeep(S),b=T)}m(y,N)}function p(y,w,j){return e.map(w,function(k){return a(y,k,j)})}function h(y,w){var j=new c;e.forEach(y,function(k){var S=k.graph().root,b=r(k,S,j,w);e.forEach(b.vs,function(N,E){k.node(N).order=E}),l(k,j,b.vs)})}function m(y,w){e.forEach(w,function(j){e.forEach(j,function(k,S){y.node(k).order=S})})}return ax}var ox,DT;function QW(){if(DT)return ox;DT=1;var e=Mt(),t=Jr().Graph,n=Wn();ox={positionX:j,findType1Conflicts:r,findType2Conflicts:a,addConflict:c,hasConflict:u,verticalAlignment:f,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:m,balance:w};function r(b,N){var E={};function C(T,A){var I=0,B=0,q=T.length,L=e.last(A);return e.forEach(A,function(U,X){var Y=l(b,U),M=Y?b.node(Y).order:q;(Y||U===L)&&(e.forEach(A.slice(B,X+1),function(J){e.forEach(b.predecessors(J),function(V){var $=b.node(V),z=$.order;(z<I||M<z)&&!($.dummy&&b.node(J).dummy)&&c(E,V,J)})}),B=X+1,I=M)}),A}return e.reduce(N,C),E}function a(b,N){var E={};function C(A,I,B,q,L){var U;e.forEach(e.range(I,B),function(X){U=A[X],b.node(U).dummy&&e.forEach(b.predecessors(U),function(Y){var M=b.node(Y);M.dummy&&(M.order<q||M.order>L)&&c(E,Y,U)})})}function T(A,I){var B=-1,q,L=0;return e.forEach(I,function(U,X){if(b.node(U).dummy==="border"){var Y=b.predecessors(U);Y.length&&(q=b.node(Y[0]).order,C(I,L,X,B,q),L=X,B=q)}C(I,L,I.length,q,A.length)}),I}return e.reduce(N,T),E}function l(b,N){if(b.node(N).dummy)return e.find(b.predecessors(N),function(E){return b.node(E).dummy})}function c(b,N,E){if(N>E){var C=N;N=E,E=C}var T=b[N];T||(b[N]=T={}),T[E]=!0}function u(b,N,E){if(N>E){var C=N;N=E,E=C}return e.has(b[N],E)}function f(b,N,E,C){var T={},A={},I={};return e.forEach(N,function(B){e.forEach(B,function(q,L){T[q]=q,A[q]=q,I[q]=L})}),e.forEach(N,function(B){var q=-1;e.forEach(B,function(L){var U=C(L);if(U.length){U=e.sortBy(U,function(V){return I[V]});for(var X=(U.length-1)/2,Y=Math.floor(X),M=Math.ceil(X);Y<=M;++Y){var J=U[Y];A[L]===L&&q<I[J]&&!u(E,L,J)&&(A[J]=L,A[L]=T[L]=T[J],q=I[J])}}})}),{root:T,align:A}}function p(b,N,E,C,T){var A={},I=h(b,N,E,T),B=T?"borderLeft":"borderRight";function q(X,Y){for(var M=I.nodes(),J=M.pop(),V={};J;)V[J]?X(J):(V[J]=!0,M.push(J),M=M.concat(Y(J))),J=M.pop()}function L(X){A[X]=I.inEdges(X).reduce(function(Y,M){return Math.max(Y,A[M.v]+I.edge(M))},0)}function U(X){var Y=I.outEdges(X).reduce(function(J,V){return Math.min(J,A[V.w]-I.edge(V))},Number.POSITIVE_INFINITY),M=b.node(X);Y!==Number.POSITIVE_INFINITY&&M.borderType!==B&&(A[X]=Math.max(A[X],Y))}return q(L,I.predecessors.bind(I)),q(U,I.successors.bind(I)),e.forEach(C,function(X){A[X]=A[E[X]]}),A}function h(b,N,E,C){var T=new t,A=b.graph(),I=k(A.nodesep,A.edgesep,C);return e.forEach(N,function(B){var q;e.forEach(B,function(L){var U=E[L];if(T.setNode(U),q){var X=E[q],Y=T.edge(X,U);T.setEdge(X,U,Math.max(I(b,L,q),Y||0))}q=L})}),T}function m(b,N){return e.minBy(e.values(N),function(E){var C=Number.NEGATIVE_INFINITY,T=Number.POSITIVE_INFINITY;return e.forIn(E,function(A,I){var B=S(b,I)/2;C=Math.max(A+B,C),T=Math.min(A-B,T)}),C-T})}function y(b,N){var E=e.values(N),C=e.min(E),T=e.max(E);e.forEach(["u","d"],function(A){e.forEach(["l","r"],function(I){var B=A+I,q=b[B],L;if(q!==N){var U=e.values(q);L=I==="l"?C-e.min(U):T-e.max(U),L&&(b[B]=e.mapValues(q,function(X){return X+L}))}})})}function w(b,N){return e.mapValues(b.ul,function(E,C){if(N)return b[N.toLowerCase()][C];var T=e.sortBy(e.map(b,C));return(T[1]+T[2])/2})}function j(b){var N=n.buildLayerMatrix(b),E=e.merge(r(b,N),a(b,N)),C={},T;e.forEach(["u","d"],function(I){T=I==="u"?N:e.values(N).reverse(),e.forEach(["l","r"],function(B){B==="r"&&(T=e.map(T,function(X){return e.values(X).reverse()}));var q=(I==="u"?b.predecessors:b.successors).bind(b),L=f(b,T,E,q),U=p(b,T,L.root,L.align,B==="r");B==="r"&&(U=e.mapValues(U,function(X){return-X})),C[I+B]=U})});var A=m(b,C);return y(C,A),w(C,b.graph().align)}function k(b,N,E){return function(C,T,A){var I=C.node(T),B=C.node(A),q=0,L;if(q+=I.width/2,e.has(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":L=-I.width/2;break;case"r":L=I.width/2;break}if(L&&(q+=E?L:-L),L=0,q+=(I.dummy?N:b)/2,q+=(B.dummy?N:b)/2,q+=B.width/2,e.has(B,"labelpos"))switch(B.labelpos.toLowerCase()){case"l":L=B.width/2;break;case"r":L=-B.width/2;break}return L&&(q+=E?L:-L),L=0,q}}function S(b,N){return b.node(N).width}return ox}var ix,FT;function JW(){if(FT)return ix;FT=1;var e=Mt(),t=Wn(),n=QW().positionX;ix=r;function r(l){l=t.asNonCompoundGraph(l),a(l),e.forEach(n(l),function(c,u){l.node(u).x=c})}function a(l){var c=t.buildLayerMatrix(l),u=l.graph().ranksep,f=0;e.forEach(c,function(p){var h=e.max(e.map(p,function(m){return l.node(m).height}));e.forEach(p,function(m){l.node(m).y=f+h/2}),f+=h+u})}return ix}var lx,qT;function e7(){if(qT)return lx;qT=1;var e=Mt(),t=OW(),n=LW(),r=DW(),a=Wn().normalizeRanks,l=FW(),c=Wn().removeEmptyRanks,u=qW(),f=BW(),p=zW(),h=ZW(),m=JW(),y=Wn(),w=Jr().Graph;lx=j;function j(H,Q){var O=Q&&Q.debugTiming?y.time:y.notime;O("layout",function(){var te=O(" buildLayoutGraph",function(){return q(H)});O(" runLayout",function(){k(te,O)}),O(" updateInputGraph",function(){S(H,te)})})}function k(H,Q){Q(" makeSpaceForEdgeLabels",function(){L(H)}),Q(" removeSelfEdges",function(){W(H)}),Q(" acyclic",function(){t.run(H)}),Q(" nestingGraph.run",function(){u.run(H)}),Q(" rank",function(){r(y.asNonCompoundGraph(H))}),Q(" injectEdgeLabelProxies",function(){U(H)}),Q(" removeEmptyRanks",function(){c(H)}),Q(" nestingGraph.cleanup",function(){u.cleanup(H)}),Q(" normalizeRanks",function(){a(H)}),Q(" assignRankMinMax",function(){X(H)}),Q(" removeEdgeLabelProxies",function(){Y(H)}),Q(" normalize.run",function(){n.run(H)}),Q(" parentDummyChains",function(){l(H)}),Q(" addBorderSegments",function(){f(H)}),Q(" order",function(){h(H)}),Q(" insertSelfEdges",function(){G(H)}),Q(" adjustCoordinateSystem",function(){p.adjust(H)}),Q(" position",function(){m(H)}),Q(" positionSelfEdges",function(){F(H)}),Q(" removeBorderNodes",function(){z(H)}),Q(" normalize.undo",function(){n.undo(H)}),Q(" fixupEdgeLabelCoords",function(){V(H)}),Q(" undoCoordinateSystem",function(){p.undo(H)}),Q(" translateGraph",function(){M(H)}),Q(" assignNodeIntersects",function(){J(H)}),Q(" reversePoints",function(){$(H)}),Q(" acyclic.undo",function(){t.undo(H)})}function S(H,Q){e.forEach(H.nodes(),function(O){var te=H.node(O),ae=Q.node(O);te&&(te.x=ae.x,te.y=ae.y,Q.children(O).length&&(te.width=ae.width,te.height=ae.height))}),e.forEach(H.edges(),function(O){var te=H.edge(O),ae=Q.edge(O);te.points=ae.points,e.has(ae,"x")&&(te.x=ae.x,te.y=ae.y)}),H.graph().width=Q.graph().width,H.graph().height=Q.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],N={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],C=["width","height"],T={width:0,height:0},A=["minlen","weight","width","height","labeloffset"],I={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},B=["labelpos"];function q(H){var Q=new w({multigraph:!0,compound:!0}),O=de(H.graph());return Q.setGraph(e.merge({},N,K(O,b),e.pick(O,E))),e.forEach(H.nodes(),function(te){var ae=de(H.node(te));Q.setNode(te,e.defaults(K(ae,C),T)),Q.setParent(te,H.parent(te))}),e.forEach(H.edges(),function(te){var ae=de(H.edge(te));Q.setEdge(te,e.merge({},I,K(ae,A),e.pick(ae,B)))}),Q}function L(H){var Q=H.graph();Q.ranksep/=2,e.forEach(H.edges(),function(O){var te=H.edge(O);te.minlen*=2,te.labelpos.toLowerCase()!=="c"&&(Q.rankdir==="TB"||Q.rankdir==="BT"?te.width+=te.labeloffset:te.height+=te.labeloffset)})}function U(H){e.forEach(H.edges(),function(Q){var O=H.edge(Q);if(O.width&&O.height){var te=H.node(Q.v),ae=H.node(Q.w),he={rank:(ae.rank-te.rank)/2+te.rank,e:Q};y.addDummyNode(H,"edge-proxy",he,"_ep")}})}function X(H){var Q=0;e.forEach(H.nodes(),function(O){var te=H.node(O);te.borderTop&&(te.minRank=H.node(te.borderTop).rank,te.maxRank=H.node(te.borderBottom).rank,Q=e.max(Q,te.maxRank))}),H.graph().maxRank=Q}function Y(H){e.forEach(H.nodes(),function(Q){var O=H.node(Q);O.dummy==="edge-proxy"&&(H.edge(O.e).labelRank=O.rank,H.removeNode(Q))})}function M(H){var Q=Number.POSITIVE_INFINITY,O=0,te=Number.POSITIVE_INFINITY,ae=0,he=H.graph(),ge=he.marginx||0,Te=he.marginy||0;function De(Ve){var je=Ve.x,ve=Ve.y,Ue=Ve.width,ke=Ve.height;Q=Math.min(Q,je-Ue/2),O=Math.max(O,je+Ue/2),te=Math.min(te,ve-ke/2),ae=Math.max(ae,ve+ke/2)}e.forEach(H.nodes(),function(Ve){De(H.node(Ve))}),e.forEach(H.edges(),function(Ve){var je=H.edge(Ve);e.has(je,"x")&&De(je)}),Q-=ge,te-=Te,e.forEach(H.nodes(),function(Ve){var je=H.node(Ve);je.x-=Q,je.y-=te}),e.forEach(H.edges(),function(Ve){var je=H.edge(Ve);e.forEach(je.points,function(ve){ve.x-=Q,ve.y-=te}),e.has(je,"x")&&(je.x-=Q),e.has(je,"y")&&(je.y-=te)}),he.width=O-Q+ge,he.height=ae-te+Te}function J(H){e.forEach(H.edges(),function(Q){var O=H.edge(Q),te=H.node(Q.v),ae=H.node(Q.w),he,ge;O.points?(he=O.points[0],ge=O.points[O.points.length-1]):(O.points=[],he=ae,ge=te),O.points.unshift(y.intersectRect(te,he)),O.points.push(y.intersectRect(ae,ge))})}function V(H){e.forEach(H.edges(),function(Q){var O=H.edge(Q);if(e.has(O,"x"))switch((O.labelpos==="l"||O.labelpos==="r")&&(O.width-=O.labeloffset),O.labelpos){case"l":O.x-=O.width/2+O.labeloffset;break;case"r":O.x+=O.width/2+O.labeloffset;break}})}function $(H){e.forEach(H.edges(),function(Q){var O=H.edge(Q);O.reversed&&O.points.reverse()})}function z(H){e.forEach(H.nodes(),function(Q){if(H.children(Q).length){var O=H.node(Q),te=H.node(O.borderTop),ae=H.node(O.borderBottom),he=H.node(e.last(O.borderLeft)),ge=H.node(e.last(O.borderRight));O.width=Math.abs(ge.x-he.x),O.height=Math.abs(ae.y-te.y),O.x=he.x+O.width/2,O.y=te.y+O.height/2}}),e.forEach(H.nodes(),function(Q){H.node(Q).dummy==="border"&&H.removeNode(Q)})}function W(H){e.forEach(H.edges(),function(Q){if(Q.v===Q.w){var O=H.node(Q.v);O.selfEdges||(O.selfEdges=[]),O.selfEdges.push({e:Q,label:H.edge(Q)}),H.removeEdge(Q)}})}function G(H){var Q=y.buildLayerMatrix(H);e.forEach(Q,function(O){var te=0;e.forEach(O,function(ae,he){var ge=H.node(ae);ge.order=he+te,e.forEach(ge.selfEdges,function(Te){y.addDummyNode(H,"selfedge",{width:Te.label.width,height:Te.label.height,rank:ge.rank,order:he+ ++te,e:Te.e,label:Te.label},"_se")}),delete ge.selfEdges})})}function F(H){e.forEach(H.nodes(),function(Q){var O=H.node(Q);if(O.dummy==="selfedge"){var te=H.node(O.e.v),ae=te.x+te.width/2,he=te.y,ge=O.x-ae,Te=te.height/2;H.setEdge(O.e,O.label),H.removeNode(Q),O.label.points=[{x:ae+2*ge/3,y:he-Te},{x:ae+5*ge/6,y:he-Te},{x:ae+ge,y:he},{x:ae+5*ge/6,y:he+Te},{x:ae+2*ge/3,y:he+Te}],O.label.x=O.x,O.label.y=O.y}})}function K(H,Q){return e.mapValues(e.pick(H,Q),Number)}function de(H){var Q={};return e.forEach(H,function(O,te){Q[te.toLowerCase()]=O}),Q}return lx}var cx,BT;function t7(){if(BT)return cx;BT=1;var e=Mt(),t=Wn(),n=Jr().Graph;cx={debugOrdering:r};function r(a){var l=t.buildLayerMatrix(a),c=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(a.nodes(),function(u){c.setNode(u,{label:u}),c.setParent(u,"layer"+a.node(u).rank)}),e.forEach(a.edges(),function(u){c.setEdge(u.v,u.w,{},u.name)}),e.forEach(l,function(u,f){var p="layer"+f;c.setNode(p,{rank:"same"}),e.reduce(u,function(h,m){return c.setEdge(h,m,{style:"invis"}),m})}),c}return cx}var ux,zT;function n7(){return zT||(zT=1,ux="0.8.5"),ux}var dx,HT;function r7(){return HT||(HT=1,dx={graphlib:Jr(),layout:e7(),debug:t7(),util:{time:Wn().time,notime:Wn().notime},version:n7()}),dx}var s7=r7();const UT=d0(s7),Fo=240,zc=130,Yi=74,tf=72,Cc=Yi+tf;function nI(e,t){var r;let n=Fo;for(const a of e)n=Math.max(n,((r=t.get(a.id))==null?void 0:r.width)??Fo);return n}const yh=420,rI=1;function a7(e,t,n,r){return Math.min(rI,n/Math.max(1,e),r/Math.max(1,t))}function qo(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function o7(e,t){return((t==null?void 0:t.get(e))??0)>0?yh:0}function i7(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function Hc(e,t,n){const r=t.get(e);return{w:((r==null?void 0:r.width)??Fo)+o7(e,n),h:Math.max((r==null?void 0:r.height)??zc,i7(e,n))}}function l7(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function c7(e,t,n,r,a,l){const c=new UT.graphlib.Graph;c.setDefaultEdgeLabel(()=>({})),c.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const u=e.filter(b=>!a.has(b)),f=new Set(u);for(const b of u){const{w:N,h:E}=Hc(b,r,l);c.setNode(b,{width:N,height:E})}for(const b of t)f.has(b.source)&&f.has(b.target)&&c.setEdge(b.source,b.target);UT.layout(c);const p=new Map;let h=1/0,m=1/0,y=-1/0,w=-1/0;for(const b of u){const N=c.node(b);if(!N)continue;const E=r.get(b),C=(E==null?void 0:E.width)??Fo,T=(E==null?void 0:E.height)??zc,A=Hc(b,r,l),I=N.x-A.w/2,B=N.y-A.h/2;p.set(b,{x:I,y:B}),I<h&&(h=I),B<m&&(m=B),I+C>y&&(y=I+C),B+T>w&&(w=B+T)}if(Number.isFinite(h)&&Number.isFinite(m))for(const[b,N]of p)p.set(b,{x:N.x-h,y:N.y-m});const j=Number.isFinite(y)?y-h:0,k=Number.isFinite(w)?w-m:0;let S=null;for(const b of e){const N=a.get(b);if(!N)continue;const E=r.get(b),C=(E==null?void 0:E.width)??Fo,T=(E==null?void 0:E.height)??zc;S=S===null?{minX:N.x,minY:N.y,maxX:N.x+C,maxY:N.y+T}:{minX:Math.min(S.minX,N.x),minY:Math.min(S.minY,N.y),maxX:Math.max(S.maxX,N.x+C),maxY:Math.max(S.maxY,N.y+T)}}return{positions:p,width:j,height:k,pinnedBox:S}}function sI(e,t,n){const r=n.direction??"LR",a=n.pinned??new Map,l=n.measured??new Map,c=n.lanes,u=new Map;for(const h of e){const m=qo(h),y=u.get(m);y?y.push(h.id):u.set(m,[h.id])}return{laid:Array.from(u.keys()).sort().map(h=>({sid:h,...c7(u.get(h),t,r,l,a,c)})),gap:nI(e,l)}}const aI=e=>e.reduce((t,n)=>Math.max(t,n.width),0)+yh,u7=e=>e.reduce((t,n)=>t+n.height,0)+Cc*Math.max(0,e.length-1);function t0(e,t,n,r){const a=f=>{const p=[[]];let h=0;for(const m of e)h>0&&h+m.height>f&&(p.push([]),h=0),p[p.length-1].push(m),h+=m.height+Cc;return p},l=[];for(let f=0;f<e.length;f++){let p=-Cc;for(let h=f;h<e.length;h++)l.push(p+=e[h].height+Cc)}l.sort((f,p)=>f-p);const c=f=>{let p=0,h=l.length-1;for(;p<h;){const m=p+h>>1;a(l[m]).length<=f?h=m:p=m+1}return a(l[p])};let u=[e];if(n>0&&r>0){const f=h=>a7(h.reduce((m,y)=>m+aI(y),0)+t*(h.length-1),Math.max(...h.map(u7)),n,r);let p=f(u);for(let h=2;h<=e.length;h++){const m=c(h),y=f(m);y>p+1e-9&&(p=y,u=m)}}return u}function d7(e,t,n,r,a){if(!(r.width>0&&r.height>0&&a.width>0&&a.height>0))return!1;const{laid:l,gap:c}=sI(e,t,n);return l.length<2?!1:t0(l,c,r.width,r.height).length!==t0(l,c,a.width,a.height).length}function h7(e,t,n={}){const r=n.pinned??new Map,{laid:a,gap:l}=sI(e,t,n),c=t0(a,l,n.availableWidth??0,n.availableHeight??0),u=new Map;let f=0;for(const p of c){const h=aI(p);let m=0;for(const{positions:y,height:w,pinnedBox:j}of p){for(const[S,b]of y)u.set(S,{x:b.x+f,y:b.y+m});let k=m+w;j&&j.maxY>k&&j.minX<f+h&&f<j.maxX&&(k=j.maxY),m=k+Cc}f+=h+l}return e.map(p=>{const h=r.get(p.id);if(h)return{...p,position:h};const m=u.get(p.id);return m?{...p,position:m}:p})}function f7(e,t,n,r,a){const c=Yi+tf,u=60,f=w=>Hc(w,r,a),p=new Map(e.map(w=>[w.id,qo(w)])),h=[],m=e.map(w=>({id:w.id,pos:n.get(w.id)??t.get(w.id)})).filter(w=>w.pos!=null).sort((w,j)=>w.pos.y-j.pos.y||w.pos.x-j.pos.x||w.id.localeCompare(j.id)),y=[];for(const{id:w,pos:j}of m){const{w:k,h:S}=f(w),b=p.get(w)??"_default";if(n.has(w)){h.push({x:j.x,y:j.y,w:k,h:S,sid:b});continue}let N=j.y;for(let E=0;E<h.length+1;E++){const C=h.find(T=>{const A=T.sid===b?24:u,I=T.sid===b?24:c;return j.x<T.x+T.w+A&&T.x<j.x+k+A&&N<T.y+T.h+I&&T.y<N+S+I});if(!C)break;N=C.y+C.h+(C.sid===b?24:c)}N!==j.y&&(t.set(w,{x:j.x,y:N}),y.push(w)),h.push({x:j.x,y:N,w:k,h:S,sid:b})}return y}function p7(e,t,n,r,a,l,c){const u=E=>Hc(E,r,l),f=E=>n.get(E)??t.get(E),p=E=>{const C=r.get(E);return{cw:(C==null?void 0:C.width)??Fo,ch:(C==null?void 0:C.height)??zc}},h=c!=null&&c.width>0&&c.height>0,m=new Map;for(const E of e){if(!f(E.id))continue;const C=qo(E),T=m.get(C);T?T.push(E):m.set(C,[E])}const y=new Set;for(const[E,C]of m)C.every(T=>a.has(T.id)&&!n.has(T.id))&&y.add(E);const w=new Map,j=[];for(const E of e){const C=f(E.id);if(!C)continue;const{w:T,h:A}=u(E.id),I=qo(E);y.has(I)?(w.get(I)??w.set(I,[]).get(I)).push(E):j.push({x:C.x,y:C.y,w:T,h:A,...p(E.id)})}if(w.size===0||h&&j.length===0)return[];const k=Yi+tf,S=(E,C,T,A)=>j.some(I=>E<I.x+I.w+Yi&&I.x<E+T+Yi&&C<I.y+I.h+k&&I.y<C+A+k),b=nI(e,r),N=[];for(const E of[...w.keys()].sort()){const C=w.get(E);let T=1/0,A=1/0,I=-1/0,B=-1/0,q=-1/0,L=-1/0;for(const $ of C){const z=f($.id),{w:W,h:G}=u($.id),{cw:F,ch:K}=p($.id);T=Math.min(T,z.x),A=Math.min(A,z.y),I=Math.max(I,z.x+W),B=Math.max(B,z.y+G),q=Math.max(q,z.x+F),L=Math.max(L,z.y+K)}const U=I-T,X=B-A,Y=[...new Set(j.map($=>Math.round($.x)))].sort(($,z)=>$-z),M=Y.length?Y:[T],J=[0,...j.map($=>$.y+$.h+k)].sort(($,z)=>$-z);let V=null;if(h){let $=1/0,z=1/0,W=-1/0,G=-1/0;for(const O of j)$=Math.min($,O.x),z=Math.min(z,O.y),W=Math.max(W,O.x+O.cw),G=Math.max(G,O.y+O.ch);const F=(O,te)=>{const ae=c.width/(Math.max(W,O+q-T)-Math.min($,O)+yh),he=c.height/(Math.max(G,te+L-A)-Math.min(z,te));return[Math.min(rI,ae,he),Math.min(ae,he),Math.max(ae,he)]},K=(O,te)=>{for(let ae=0;ae<O.length;ae++){if(O[ae]>te[ae]+1e-9)return!0;if(O[ae]<te[ae]-1e-9)return!1}return!1},de=Math.round(W+yh+b),H=[...new Set([...J,z])].sort((O,te)=>O-te);let Q=null;for(const O of[...M,de])for(const te of H){if(S(O,te,U,X))continue;const ae=F(O,te);(Q===null||K(ae,Q))&&(Q=ae,V={x:O,y:te})}V&&V.x===T&&V.y===A&&(V=null)}else e:for(const $ of M)for(const z of J){if(z>=A)break;if(!S($,z,U,X)){V={x:$,y:z};break e}}if(V){const $=V.x-T,z=V.y-A;for(const W of C){const G=f(W.id);t.set(W.id,{x:G.x+$,y:G.y+z})}N.push(E)}for(const $ of C){const z=f($.id),{w:W,h:G}=u($.id);j.push({x:z.x,y:z.y,w:W,h:G,...p($.id)})}}return N}function m7(e,t,n){const r=new Map;for(const a of e){if(t.has(a.id)||!n(a.id))continue;const l=qo(a);(r.get(l)??r.set(l,[]).get(l)).push(a)}if(r.size===0)return e;for(const a of r.values())a.sort((l,c)=>l.id.localeCompare(c.id));return e.map(a=>{var p;if(t.has(a.id)||n(a.id))return a;const l=r.get(qo(a));if(!l)return a;const c=(p=a.data)==null?void 0:p.parentId,u=l.find(h=>h.id===c)??l[0],f=n(u.id);return{...a,position:{x:a.position.x+f.x-u.position.x,y:a.position.y+f.y-u.position.y}}})}function g7(e,t,n,r,a,l=!1,c){const p=Yi+tf+1,h=8,m=1.75,y=200,w=.7,j=.01,k=L=>Hc(L,r,c),S=L=>n.get(L)??t.get(L),b=new Map;for(const L of e){if(!S(L.id))continue;const U=qo(L),X=b.get(U);X?X.push(L):b.set(U,[L])}const N=[],E=new Set,C=new Set,T=a.size===0;for(const L of[...b.keys()].sort()){const U=b.get(L);let X=1/0,Y=1/0,M=-1/0,J=-1/0,V=!1;for(const G of U){const F=S(G.id),{w:K,h:de}=k(G.id);X=Math.min(X,F.x),Y=Math.min(Y,F.y),M=Math.max(M,F.x+K),J=Math.max(J,F.y+de),n.has(G.id)&&(V=!0)}const $=M-X,z=J-Y;C.add(L);const W=a.get(L);W&&($>W.w+h||z>W.h+h)&&E.add(L),a.set(L,{w:$,h:z}),N.push({sid:L,members:U.map(G=>G.id),x:X,y:Y,w:$,h:z,anchored:V,mass:1})}for(const L of[...a.keys()])C.has(L)||a.delete(L);if(l||T)return[];let A=!1;for(let L=0;L<N.length&&!A;L++)for(let U=L+1;U<N.length;U++){const X=N[L],Y=N[U];if(!(X.anchored&&Y.anchored)&&Math.abs(X.x+X.w/2-(Y.x+Y.w/2))<(X.w+Y.w)/2+61&&Math.abs(X.y+X.h/2-(Y.y+Y.h/2))<(X.h+Y.h)/2+p){A=!0;break}}if(E.size===0&&!A)return[];if(E.size>0)for(const L of N)E.has(L.sid)&&(L.mass=8);else for(const L of N)L.mass=Math.max(1,L.w*L.h/(Fo*zc));const I=new Map(N.map(L=>[L.sid,L.x])),B=new Map(N.map(L=>[L.sid,L.y]));for(let L=0;L<y;L++){const U=new Map,X=new Map;let Y=0;for(let M=0;M<N.length;M++)for(let J=M+1;J<N.length;J++){const V=N[M],$=N[J];if(V.anchored&&$.anchored)continue;const z=V.x+V.w/2,W=V.y+V.h/2,G=$.x+$.w/2,F=$.y+$.h/2,K=(V.w+$.w)/2+61-Math.abs(z-G),de=(V.h+$.h)/2+p-Math.abs(W-F);if(K<=0||de<=0)continue;const H=(_e,Ie)=>!_e.anchored&&!(Ie<0&&_e.x<=0),Q=(_e,Ie)=>!_e.anchored&&!(Ie<0&&_e.y<=0),O=(_e,Ie,Ze)=>{const We=_e===Ie,Je=We?V.sid<$.sid?-1:1:Math.sign(_e-Ie);return Ze(V,Je)||Ze($,-Je)?Je:We&&(Ze(V,-Je)||Ze($,Je))?-Je:0},te=O(z,G,H),ae=O(W,F,Q),he=te!==0,ge=ae!==0;if(!he&&!ge)continue;const Te=he&&(!ge||K*m<de),[De,Ve,je,ve]=Te?[te,K,U,H]:[ae,de,X,Q],Ue=ve(V,De),ke=ve($,-De),xe=V.mass,Ge=$.mass,rt=Ue?ke?Ge/(xe+Ge):1:0,at=ke?Ue?xe/(xe+Ge):1:0,le=Ve*w;je.set(V.sid,(je.get(V.sid)??0)+De*le*rt),je.set($.sid,(je.get($.sid)??0)-De*le*at),Y+=le}for(const M of N)M.anchored||(M.x=Math.max(0,M.x+(U.get(M.sid)??0)),M.y=Math.max(0,M.y+(X.get(M.sid)??0)));if(Y<j)break}const q=[];for(const L of N){const U=L.x-I.get(L.sid),X=L.y-B.get(L.sid);if(!(Math.abs(U)<1&&Math.abs(X)<1)){for(const Y of L.members){if(n.has(Y))continue;const M=t.get(Y);M&&t.set(Y,{x:M.x+U,y:M.y+X})}q.push(L.sid)}}return q}function Zd(e,t,n){return!t.has(e)||n.has(e)}function y7(e,t,n,r){return!t.has(e)&&Zd(e,n,r)}function w7(e,t,n){const r={x:0,y:0};return t.set(e,r),n.add(e),r}function WT(e,t,n,r){n.set(e,t),r.delete(e)}const v7=200,x7=5*6e4,b7=6,k7=2*6e4;function Od(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function N7(e,t){let n=!1;for(const a of e)if(!t.has(a)){n=!0;break}if(!n)return e;const r=new Set;for(const a of e)t.has(a)&&r.add(a);return r}function _7(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(L0(n.id));return t}function S7(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(L0(n.id));return t}function j7(e,t){let n=iD(e,t,iN);lD(e,t,iN)&&(n=!0);const r=[],a=l=>{r.push(l)};return rD(e,t,v7,x7,a)&&(n=!0),sD(e,t,b7,k7,a)&&(n=!0),{changed:n,forgotten:r}}const E7=300,VT=130,C7=160,GT=new WeakMap;function T7(e,t){let n=GT.get(e);(!n||n.revision!==e.revision||n.open!==t)&&(n={revision:e.revision,open:t,byId:new Map,branches:g6(e.agents.values())},GT.set(e,n));const{byId:r,branches:a}=n;return l=>{let c=r.get(l.id);if(!c){const u=l.kind==="root"?a.get(l.sessionId):void 0;c=u?{...l,onOpenContext:t,branch:u}:{...l,onOpenContext:t},r.set(l.id,c)}return c}}function n0(e){const t=new Map;for(const n of e.agents.values())n.tools.length>0&&t.set(n.id,Math.min(4,n.tools.length));return t}function A7(e,t,n,r,a,l,c,u,f,p,h,m,y,w,j,k,S,b){var Y,M,J,V;const N=[],E=[],C=T7(e,b);for(const $ of e.agents.values()){if(!S.has($.id))continue;const z=$.exitAt!=null,W=k!=null&&!k.has($.id),G=[z?"rf-exiting":"",W?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,F=l.get($.id);if(N.push({id:$.id,type:"agent",position:{x:0,y:0},data:C($),className:G,ariaLabel:oF($,t),...F?{width:F.width,height:F.height}:null}),$.parentId&&S.has($.parentId)){const H=lh($.sessionId),Q=z,O=j.size>0&&(j.has($.id)||j.has($.parentId)),te=k!=null&&!k.has($.id)&&!k.has($.parentId),ae=$.state==="active"?2:1.5,he=O?ae+1.5:ae,ge=Q?.2:te?.12:1,Te=["sess-edge",$.state==="active"?"sess-live":"sess-idle",Q?"rf-edge-exiting":"",O?"rf-edge-selected":""].filter(Boolean).join(" ");E.push({id:`e:${$.parentId}->${$.id}`,source:$.parentId,target:$.id,animated:($.state==="active"||O)&&!Q,type:"smoothstep",style:{"--session-hue":H,strokeWidth:`calc(${he}px * var(--edge-k, 1))`,opacity:ge,transition:"var(--edge-transition)"},className:Te})}const K=$.kind==="root"?Ih($):null,de=K?wR($.sessionId,K.at):null;if(K&&de&&!u6(de)){const H=L0($.id),Q=lh($.sessionId),O=l.get(H);N.push({id:H,type:"recapNote",position:{x:0,y:0},data:{sessionId:$.sessionId,parentId:$.id,recap:K,noteKey:de,hue:Q},className:W?"rf-spotlit-out":void 0,selectable:!1,focusable:!1,ariaLabel:`Claude Code's recap for ${$.label}`,...O?{width:O.width,height:O.height}:null}),E.push({id:`e:recap:${$.id}`,source:H,target:$.id,type:"recapTie",className:"recap-edge",focusable:!1,style:{"--session-hue":Q}})}}const T=n0(e),A=`${y}#lanes:${l7(T)}`,I=new Set(N.filter($=>$.type==="recapNote").map($=>$.id));for(const $ of Array.from(h.keys()))p6($)&&!I.has($)&&!a.has($)&&(h.delete($),m.delete($));const B=N.filter($=>y7($.id,a,h,m));if(B.length>0||A!==w.current){if(B.length>0){const $=m7(h7(N,E,{direction:"LR",pinned:a,measured:l,availableWidth:n,availableHeight:r,lanes:T}),a,z=>Zd(z,h,m)?void 0:h.get(z));for(const z of $)Zd(z.id,h,m)&&WT(z.id,z.position,h,m);p7(N,h,a,l,new Set(B.filter(z=>z.type!=="recapNote").map(z=>z.id)),T,{width:n,height:r});for(const z of B){if(z.type!=="recapNote")continue;const W=(Y=z.data)==null?void 0:Y.parentId;if(!W)continue;const G=a.get(W)??(Zd(W,h,m)?void 0:h.get(W));if(!G)continue;const F=((M=l.get(z.id))==null?void 0:M.width)??E7,K=((J=l.get(z.id))==null?void 0:J.height)??VT,de=((V=l.get(W))==null?void 0:V.height)??VT;WT(z.id,{x:G.x-C7-F,y:G.y+(de-K)/2},h,m)}}f7(N,h,a,l,T),w.current=A}const q=g7(N,h,a,l,c,!f||p,T);q.length>0&&u(q);const L=S7(e.agents.values());Od(h,L),Od(m,L),Od(a,L),Od(l,_7(e.agents.values()));const U=[];let X=!1;for(const $ of N){let z=a.get($.id)??h.get($.id);z||(z=w7($.id,h,m),X=!0),U.push({...$,position:z})}return X&&(w.current=""),{nodes:U,edges:E}}const R7=1;function M7(e){return{id:e.id,name:e.name,inputPreview:e.inputPreview,startedAt:e.startedAt,endedAt:e.endedAt,ok:e.ok,errorPreview:e.errorPreview,usage:e.usage}}function I7(e,t,n){const r=e.agents.get(t);if(!r)return null;const a=[];for(const l of e.agents.values())l.sessionId===t&&a.push(l);return{schemaVersion:R7,exportedAt:n,sessionId:t,label:r.label,cwd:r.cwd,startedAt:r.startedAt,endedAt:r.endedAt,model:r.model,agents:a.map(l=>({id:l.id,kind:l.kind,label:l.label,parentId:l.parentId,state:l.state,startedAt:l.startedAt,endedAt:l.endedAt,model:l.model,cwd:l.cwd,usage:l.usage,prompts:l.prompts,tools:l.tools.map(M7)}))}}function $7(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${nn}-${n}-${t.slice(0,8)}.json`}function O7(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function L7(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.decks!="number"||typeof t.mine!="boolean")return null;const n=t.owner&&typeof t.owner=="object"?t.owner.port:null;return{path:typeof t.path=="string"&&t.path!==""?t.path:null,decks:t.decks,mine:t.mine,ownerPort:typeof n=="number"?n:null}}function P7(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function D7(e,t){const n=P7(e),r=(...c)=>[n?`${n} on the canvas`:null,...c,"layout, pins and selection"].filter(u=>u!==null),a="This cannot be undone.";if(!t)return{goes:r("the event log on disk — the file a restarted deck replays to rebuild what you see, and the file every deck on this machine shares unless one was told otherwise"),stays:[],final:a,confirm:"Clear everything"};if(!t.path)return{goes:r(),stays:[],final:`This deck keeps no event log, so nothing on disk changes — and nothing can bring the canvas back. ${a}`,confirm:"Clear everything"};if(!t.mine){const c=t.ownerPort===null?"another running deck owns that file":`the deck on port ${t.ownerPort} owns that file`,u=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{goes:r(),stays:[`the event log — ${c}${u}`,"restart this deck and the log replays back onto it"],final:null,confirm:"Clear this canvas"}}if(t.decks<=1)return{goes:r("this deck's event log — the file a restarted deck replays to rebuild what you see"),stays:[],final:a,confirm:"Clear everything"};const l=t.decks-1;return{goes:r(`the event log ${l===1?"1 other running deck shares":`${l} other running decks share`} with this one — every session recorded in it, not just the ones drawn here`),stays:[l===1?"what that deck shows, until it restarts — then it is gone there too":"what those decks show, until they restart — then it is gone there too"],final:a,confirm:"Clear everything"}}function F7({agentCount:e,onConfirm:t,onCancel:n}){const r=x.useRef(null),a=sn(n,{focusRef:r,layer:PD}),[l,c]=x.useState(null);x.useEffect(()=>{let m=!1;return fetch("/api/clear").then(y=>y.ok?y.json():null).then(y=>{m||c(L7(y))}).catch(()=>{}),()=>{m=!0}},[]);const{goes:u,stays:f,final:p,confirm:h}=D7(e,l);return o.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:o.jsxs("div",{ref:a,className:"modal clear-confirm",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[o.jsxs("header",{className:"modal-head",children:[o.jsxs("div",{className:"modal-title",children:[o.jsx("span",{className:"status-dot err","aria-hidden":!0}),o.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body",children:[o.jsxs("dl",{className:"cc-plan",children:[o.jsx("dt",{children:"Goes"}),o.jsx("dd",{children:u.map(m=>o.jsx("span",{children:m},m))}),o.jsx("dt",{children:"Stays"}),o.jsx("dd",{children:f.length>0?f.map(m=>o.jsx("span",{children:m},m)):o.jsx("span",{children:"nothing"})})]}),p&&o.jsx("p",{className:"cc-final",children:p}),o.jsxs("div",{className:"cc-actions",children:[o.jsx("button",{type:"button",ref:r,className:"btn",onClick:n,children:"Cancel"}),o.jsx("button",{type:"button",className:"btn danger",onClick:t,children:h})]})]})]})})}const q7="Press Esc first if a key does nothing.",B7=[{title:"Canvas",rows:[{cap:"Space",action:"pause or resume the stream",binds:[" "]},{cap:"J",action:"next agent",binds:["j","J"]},{cap:"K",action:"previous agent",binds:["k","K"]},{cap:"W",action:"the session waiting on you — oldest first, again for the next",binds:["w","W"]},{cap:"F",action:"fit every agent on screen",binds:["f","F"]},{cap:"Z",action:"zoom to the selected agent and its session",binds:["z","Z"]},{cap:"R",action:"re-arrange the canvas and drop the pins",binds:["r","R"]},{cap:"C",action:"clear the canvas and the event log — asks first",binds:["c","C"]}]},{title:"Panels and dialogs",rows:[{cap:"U",action:"usage panel",binds:["u","U"]},{cap:"L",action:"session list",binds:["l","L"]},{cap:"D",action:"detail panel",binds:["d","D"]},{cap:"H",action:"usage history",binds:["h","H"]},{cap:"A",action:"Claude accounts, where Claude Code is installed",binds:["a","A"]},{cap:"S",action:"this machine — cores, memory, temperature",binds:["s","S"]},{cap:"B",action:"Browser Watch",binds:["b","B"]},{cap:"V",action:"the sound menu — volume, tones, notifications",binds:["v","V"]},{cap:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"M",action:"sound on or off",binds:["m","M"]},{cap:"T",action:"light or dark theme",binds:["t","T"]}]},{title:"Focus and selection",rows:[{cap:"Tab",action:"reach the agent cards",binds:[]},{cap:"Enter",action:"select the focused card",binds:["Enter"]},{cap:"Shift + Enter",action:"add the focused card to the selection",binds:["Enter"]},{cap:"Esc",action:"close what is open, deselect, release focus",binds:["Escape"]}]},{title:"Mouse",rows:[{cap:"drag",action:"move a node, and pin it where you dropped it",binds:[]},{cap:"shift-click",action:"add an agent to the selection",binds:[]},{cap:"click",action:"a card: go to it and its session",binds:[]},{cap:"double-click",action:"a card: its prompt, every tool call, tokens and timing",binds:[]},{cap:"hover",action:"zoomed out, a card's name, state and numbers",binds:[]},{cap:"click",action:"the topbar speaker opens volume and sound settings",binds:[]}]}];function z7({onClose:e,onTour:t}){const n=sn(e);return o.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:o.jsxs("div",{ref:n,className:"modal key-help",onClick:r=>r.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title",children:[o.jsxs("header",{className:"modal-head",children:[o.jsx("div",{className:"modal-title",children:o.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body",children:[t&&o.jsxs("div",{className:"guide-door",children:[o.jsx("span",{children:"Eight pictures of what the deck shows."}),o.jsx("button",{type:"button",className:"btn",onClick:t,children:"Take the tour"})]}),o.jsx("div",{className:"shortcuts",children:B7.map(r=>o.jsxs(x.Fragment,{children:[o.jsx("h3",{className:"kh-group",children:r.title}),r.rows.map(a=>o.jsxs("div",{className:"sc",children:[o.jsx("kbd",{children:a.cap}),o.jsx("span",{children:a.action})]},`${r.title}:${a.cap}:${a.action}`))]},r.title))}),o.jsx("p",{className:"kh-foot",children:q7})]})]})})}const H7=["done","needs-input"],U7=[{id:"two",label:"Two notes",notes:[{at:0,hz:740,ms:90},{at:.085,hz:440,ms:150}]},{id:"arc",label:"Descent",notes:[{at:0,hz:988,ms:80},{at:.07,hz:659,ms:80},{at:.14,hz:440,ms:160}]},{id:"tap",label:"Double tap",notes:[{at:0,hz:740,ms:55},{at:.055,hz:740,ms:55},{at:.165,hz:440,ms:150}]},{id:"chord",label:"Chord",trim:.7,notes:[{at:0,hz:988,ms:110},{at:0,hz:740,ms:110},{at:.1,hz:440,ms:170}]},{id:"bell",label:"Bell",type:"triangle",notes:[{at:0,hz:740,ms:120},{at:.11,hz:440,ms:260}]},{id:"blip",label:"Blip",type:"square",trim:.7,notes:[{at:0,hz:740,ms:55},{at:.06,hz:440,ms:90}]}],W7=[{id:"two",label:"Two notes",notes:[{at:0,hz:440,ms:90},{at:.085,hz:740,ms:150}]},{id:"arc",label:"Ascent",notes:[{at:0,hz:440,ms:80},{at:.07,hz:659,ms:80},{at:.14,hz:988,ms:160}]},{id:"tap",label:"Double tap",notes:[{at:0,hz:440,ms:55},{at:.055,hz:440,ms:55},{at:.165,hz:740,ms:150}]},{id:"chord",label:"Chord",trim:.7,notes:[{at:0,hz:440,ms:110},{at:.1,hz:740,ms:170},{at:.1,hz:988,ms:170}]},{id:"bell",label:"Bell",type:"triangle",notes:[{at:0,hz:440,ms:120},{at:.11,hz:740,ms:260}]},{id:"blip",label:"Blip",type:"square",trim:.7,notes:[{at:0,hz:440,ms:55},{at:.06,hz:740,ms:90}]}],pb={done:U7,"needs-input":W7},al="two";function r0(e,t){const n=pb[e];return n.find(r=>r.id===t)??n.find(r=>r.id===al)??n[0]}function oI(e,t){return pb[e].some(r=>r.id===t)?t:al}r0("done",al).notes,r0("needs-input",al).notes;const KT=.04,V7=.24,Mo=0,ol=100,wh=5,Uc=50;function Wc(e){if(!Number.isFinite(e))return Uc;const t=Math.round(e/wh)*wh;return Math.min(ol,Math.max(Mo,t))}function iI(e){if(e==null)return Uc;const t=e.trim();return/^-?\d+(\.\d+)?$/.test(t)?Wc(Number(t)):Uc}function G7(e){const t=Wc(e),n=KT+(V7-KT)*(t/ol);return Math.round(n*1e4)/1e4}function K7(e,t){const n=t.trim,r=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(G7(e)*r*1e4)/1e4}const Y7=160,X7="agent-dag.soundLevel.done",Z7="agent-dag.soundLevel.needs-input",Q7="agent-dag.soundFigure.done",J7="agent-dag.soundFigure.needs-input",lI={done:X7,"needs-input":Z7},cI={done:Q7,"needs-input":J7},s0={done:{level:Uc,figure:al},"needs-input":{level:Uc,figure:al}};function e9(e){const t=n=>({level:iI(e(lI[n])),figure:oI(n,e(cI[n]))});return{done:t("done"),"needs-input":t("needs-input")}}const YT={Stop:"done",Notification:"needs-input"};function t9(e,t){var r;if(t)return null;const n=(r=e==null?void 0:e.payload)==null?void 0:r.hook_event_name;return typeof n!="string"?null:Object.hasOwn(YT,n)?YT[n]:null}function n9(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null,r=!1;const a=()=>e.enabled()?r&&(n==null?void 0:n.state)==="running"?"ready":"locked":"off",l=()=>{var f;return(f=e.onState)==null?void 0:f.call(e,a())};function c(){var f;if(!(!t||r))try{n=n??new t,(f=n.resume)==null||f.call(n).then(l,()=>{}),r=!0,l()}catch{}}function u(f,p=!1){var j;if(!p&&!e.enabled()||!n||n.state!=="running")return!1;const h=(((j=e.prefs)==null?void 0:j.call(e))??s0)[f]??s0[f],m=r0(f,h.figure),y=K7(h.level,m),w=n.currentTime;for(const k of m.notes){const S=n.createOscillator(),b=n.createGain();S.type=m.type??"sine",S.frequency.value=k.hz;const N=w+k.at,E=N+k.ms/1e3;b.gain.setValueAtTime(1e-4,N),b.gain.exponentialRampToValueAtTime(y,N+.012),b.gain.exponentialRampToValueAtTime(1e-4,E),S.connect(b).connect(n.destination),S.start(N),S.stop(E+.02)}return!0}return{unlock:c,play:u,state:a,get context(){return n}}}const r9="With no deck tab open, get a notification wherever a sound would have played.",s9="With the ccdeck window closed, get a notification wherever a sound would have played.";function a9(e){return e?s9:r9}const o9="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",XT="Get notified when you're away from this tab.";function i9(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:XT};case"default":return{status:null,ask:!0,ok:!1,note:XT};case"denied":return{status:"Blocked",ask:!1,ok:!1,note:"Your browser is blocking them; only its own site settings can undo that. You'll still be told once this tab is closed."};default:return{status:"Unavailable",ask:!1,ok:!1,note:"This browser cannot show them. You'll still be told once this tab is closed."}}}function l9(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}const ZT={done:"Turn finished","needs-input":"Claude is asking"},c9={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function u9({onClose:e,soundOn:t,onToggleSound:n,prefs:r,onLevel:a,onFigure:l,onPreview:c,openerRef:u,notifyOn:f,onToggleNotify:p,notifyVetoed:h,notifyPermission:m,onAskNotify:y}){const w=i9(m),j=l9(),k=f&&!h&&!j,S=sn(e,{popover:!0}),b=x.useRef(e);return b.current=e,x.useEffect(()=>{const N=E=>{var T,A;const C=E.target;C&&((T=S.current)!=null&&T.contains(C)||(A=u.current)!=null&&A.contains(C)||b.current())};return window.addEventListener("pointerdown",N,!0),()=>window.removeEventListener("pointerdown",N,!0)},[S,u]),o.jsxs("div",{ref:S,id:"sound-menu",className:"sound-menu",role:"dialog","aria-label":"Sound settings",children:[o.jsxs("div",{className:"sm-switches",children:[o.jsxs("label",{className:"sm-switch",children:[o.jsx("span",{className:"sm-switch-label",id:"sm-sound-label",children:"Sounds"}),o.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-labelledby":"sm-sound-label",className:"switch",onClick:n,title:"A tone when a turn finishes, and when Claude asks for something",children:o.jsx("span",{className:"switch-knob"})})]}),o.jsxs("div",{className:"sm-setting",children:[o.jsxs("label",{className:"sm-switch",children:[o.jsx("span",{className:"sm-switch-label",id:"sm-notify-label",children:"Notifications while closed"}),o.jsx("button",{type:"button",role:"switch","aria-checked":f,"aria-labelledby":"sm-notify-label",className:"switch",onClick:p,title:"With no deck tab open, a notification wherever a sound would play",children:o.jsx("span",{className:"switch-knob"})})]}),o.jsx("p",{className:"sm-note",children:h?o9:a9(j)})]})]}),k&&o.jsxs("section",{className:"sm-channel","aria-labelledby":"sm-channel-name",children:[o.jsxs("div",{className:"sm-channel-head",children:[o.jsx("h3",{className:"sm-channel-name",id:"sm-channel-name",children:"Browser notifications"}),w.ask?o.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:y,children:"Enable"}):o.jsxs("span",{className:"sm-channel-state","data-ok":w.ok||void 0,children:[w.ok&&o.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:o.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),w.status]})]}),o.jsx("p",{className:"sm-note",children:w.note})]}),!t&&o.jsx("span",{id:"sm-preview-note",className:"vis-hidden",children:"Plays even when Sounds is off, so you can set a tone before turning sounds back on."}),o.jsx("div",{className:"sm-tones",children:H7.map(N=>{const E=r[N],C=`sm-level-${N}`,T=`sm-figure-${N}`;return o.jsxs("section",{className:"sm-tone","aria-labelledby":`sm-name-${N}`,children:[o.jsxs("div",{className:"sm-tone-head",children:[o.jsx("h3",{className:"sm-tone-name",id:`sm-name-${N}`,children:ZT[N]}),o.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(N),"aria-label":`Hear the ${ZT[N].toLowerCase()} tone`,title:t?"Play this tone now, at what it is set to":"Plays even when Sounds is off","aria-describedby":t?void 0:"sm-preview-note",children:[o.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:o.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]})]}),o.jsxs("div",{className:"sm-row",children:[o.jsx("label",{htmlFor:C,children:"Volume"}),o.jsx("input",{id:C,type:"range",min:Mo,max:ol,step:wh,value:E.level,onChange:A=>a(N,Number(A.target.value)),style:{"--sm-level":`${(E.level-Mo)/(ol-Mo)*100}%`}}),o.jsxs("span",{className:"sm-read",children:[E.level,"%"]})]}),o.jsxs("div",{className:"sm-row",children:[o.jsx("label",{htmlFor:T,children:"Tone"}),o.jsx("select",{id:T,className:"sm-select",value:E.figure,onChange:A=>l(N,A.target.value),children:pb[N].map(A=>o.jsx("option",{value:A.id,children:A.label},A.id))})]}),o.jsx("p",{className:"sm-note",children:c9[N]})]},N)})}),o.jsxs("p",{className:"sm-foot",children:[o.jsx("kbd",{children:"M"}),"Mute or unmute sounds anywhere."]})]})}const uI="agent-dag.character-enabled",dI="agent-dag.fm-volume",hI="agent-dag.fm-source";function fI(e){return e==="lofi-relax"||e==="lofi-game"||e==="lofi-vibe"||e==="lofi-sleep"||e==="radio-mix"||e==="best-of-nostalgia"||e==="good-life-radio"||e==="cafe-music-bgm"?e:"claude-fm"}function d9(){return fI(ks(hI))}function h9(e){return e!=="0"}function f9(){return h9(ks(uI))}function p9(e){return iI(e)}function m9(){return p9(ks(dI))}const Pi=["light","dark"],g9={light:"Light",dark:"Dark"},hx=[{value:"claude-fm",label:"🎧 Claude FM"},{value:"lofi-relax",label:"📚 Relax / study",group:"📻 Lofi Girl"},{value:"lofi-game",label:"🎮 Chill / game",group:"📻 Lofi Girl"},{value:"lofi-vibe",label:"🌅 Vibe / chill",group:"📻 Lofi Girl"},{value:"lofi-sleep",label:"💤 Sleep / chill",group:"📻 Lofi Girl"},{value:"radio-mix",label:"📡 Live radio mix",group:"📻 Radio Mix"},{value:"best-of-nostalgia",label:"📼 Best of nostalgia live",group:"📻 Best of Nostalgia"},{value:"good-life-radio",label:"🌴 The Good Life Radio",group:"📻 The Good Life Radio"},{value:"cafe-music-bgm",label:"☕ Cafe music BGM",group:"☕ Cafe Music BGM"}];function y9({theme:e}){return o.jsx("span",{className:"appearance-preview","data-swatch":e,children:o.jsxs("svg",{viewBox:"0 0 112 56","aria-hidden":!0,focusable:"false",children:[o.jsx("rect",{className:"tp-canvas",width:"112",height:"56"}),o.jsx("rect",{className:"tp-surface",width:"112",height:"7"}),o.jsx("rect",{className:"tp-rule",y:"7",width:"112",height:"1"}),o.jsx("rect",{className:"tp-surface",y:"8",width:"25",height:"48"}),o.jsx("rect",{className:"tp-rule",x:"25",y:"8",width:"1",height:"48"}),o.jsx("rect",{className:"tp-card",x:"36.5",y:"27.5",width:"28",height:"14",rx:"2.5"}),o.jsx("rect",{className:"tp-tag",x:"39.5",y:"25.5",width:"13",height:"4",rx:"2"}),o.jsx("rect",{className:"tp-card",x:"76.5",y:"14.5",width:"29",height:"20",rx:"2.5"}),o.jsx("rect",{className:"tp-rule",x:"81",y:"23",width:"20",height:"2",rx:"1"}),o.jsx("rect",{className:"tp-accent",x:"81",y:"23",width:"12",height:"2",rx:"1"})]})})}function w9({theme:e,onTheme:t,characterEnabled:n,onToggleCharacter:r,fmVolume:a,onFmVolume:l,fmSource:c,onFmSource:u,onClose:f}){const p=sn(f),[h,m]=x.useState(!1),y=x.useRef(null),w=hx.find(S=>S.value===c)??hx[0];x.useEffect(()=>{if(!h)return;const S=b=>{var N;(N=y.current)!=null&&N.contains(b.target)||m(!1)};return document.addEventListener("pointerdown",S),()=>document.removeEventListener("pointerdown",S)},[h]);const j=S=>{var E;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(S.key))return;S.preventDefault();const N=(Pi.indexOf(e)+(S.key==="ArrowLeft"||S.key==="ArrowUp"?-1:1)+Pi.length)%Pi.length;t(Pi[N]),(E=S.currentTarget.querySelectorAll('[role="radio"]')[N])==null||E.focus()},k=S=>{var N;if(S.key===" "){S.stopPropagation();return}if(S.key!=="t"&&S.key!=="T"||S.ctrlKey||S.metaKey||S.altKey)return;S.preventDefault(),S.stopPropagation();const b=e==="dark"?"light":"dark";t(b),S.target.getAttribute("role")==="radio"&&((N=S.currentTarget.querySelectorAll('[role="radio"]')[Pi.indexOf(b)])==null||N.focus())};return Sn.createPortal(o.jsx("div",{className:"modal-backdrop appearance-backdrop",onClick:f,role:"presentation",children:o.jsxs("div",{ref:p,id:"appearance-menu",className:"modal appearance-menu appearance-modal",role:"dialog","aria-modal":"true","aria-labelledby":"appearance-title",onClick:S=>S.stopPropagation(),onKeyDown:k,children:[o.jsxs("div",{className:"appearance-head",children:[o.jsxs("div",{className:"appearance-heading",children:[o.jsx("h2",{id:"appearance-title",className:"appearance-title",children:"Appearance"}),o.jsx("p",{className:"appearance-subtitle",children:"Tune the deck to your workspace."})]}),o.jsx("button",{type:"button",className:"glyph-btn appearance-close",onClick:f,"aria-label":"Close appearance settings",title:"Close (Esc)",children:"×"})]}),o.jsxs("section",{className:"appearance-section","aria-labelledby":"appearance-theme-caption",children:[o.jsxs("div",{className:"appearance-caption",children:[o.jsxs("div",{children:[o.jsx("h3",{id:"appearance-theme-caption",children:"Color theme"}),o.jsx("p",{className:"appearance-section-note",children:"Choose how the dashboard looks."})]}),o.jsx("kbd",{className:"appearance-key","aria-hidden":!0,title:"Press T anywhere to switch themes",children:"T"})]}),o.jsx("div",{className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":"T",onKeyDown:j,children:Pi.map(S=>o.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","aria-checked":e===S,tabIndex:e===S?0:-1,onClick:()=>t(S),children:[o.jsx(y9,{theme:S}),o.jsxs("span",{className:"appearance-theme-name",children:[g9[S],o.jsx("svg",{className:"appearance-check",viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:o.jsx("path",{d:"M2.5 6.4 4.9 8.7 9.5 3.6"})})]})]},S))})]}),o.jsxs("section",{className:"appearance-section","aria-labelledby":"appearance-fm-caption",children:[o.jsx("div",{className:"appearance-caption",children:o.jsx("h3",{id:"appearance-fm-caption",children:"Music source"})}),o.jsxs("div",{className:"appearance-controls",children:[o.jsxs("div",{className:"appearance-source-row",children:[o.jsx("label",{htmlFor:"appearance-fm-source",children:"Station"}),o.jsxs("div",{ref:y,className:"appearance-source-picker",children:[o.jsxs("button",{id:"appearance-fm-source",type:"button",className:"sm-select appearance-source-trigger","aria-haspopup":"listbox","aria-expanded":h,"aria-describedby":"appearance-fm-source-note",onClick:()=>m(S=>!S),children:[o.jsx("span",{children:w.label}),o.jsx("svg",{className:"appearance-source-chevron",viewBox:"0 0 12 8","aria-hidden":!0,focusable:"false",children:o.jsx("path",{d:"m1 1.5 5 5 5-5"})})]}),h&&o.jsx("div",{className:"appearance-source-list",role:"listbox","aria-label":"Music station",children:hx.map(S=>o.jsxs("button",{type:"button",role:"option","aria-selected":S.value===c,className:"appearance-source-option",onClick:()=>{u(fI(S.value)),m(!1)},children:[o.jsx("span",{children:S.label}),S.value===c&&o.jsx("span",{"aria-hidden":!0,children:"✓"})]},S.value))})]})]}),o.jsx("span",{id:"appearance-fm-source-note",className:"vis-hidden",children:"Changing station starts live playback automatically."}),o.jsxs("label",{className:"appearance-row",children:[o.jsx("span",{className:"appearance-row-label",id:"appearance-character-label",children:"Show character on minimap"}),o.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":n,"aria-labelledby":"appearance-character-label","aria-describedby":"appearance-character-note",onClick:r,children:o.jsx("span",{className:"switch-knob"})}),o.jsx("span",{id:"appearance-character-note",className:"vis-hidden",children:"Shows the animated minimap character and enables music playback."})]}),o.jsxs("div",{className:"sm-row",children:[o.jsx("label",{htmlFor:"appearance-fm-volume",children:"Volume"}),o.jsx("input",{id:"appearance-fm-volume",type:"range",min:Mo,max:ol,step:wh,value:a,"aria-describedby":"appearance-fm-volume-note",onChange:S=>l(Number(S.target.value)),style:{"--sm-level":`${(a-Mo)/(ol-Mo)*100}%`}}),o.jsxs("span",{className:"sm-read",children:[a,"%"]})]})]}),o.jsx("span",{id:"appearance-fm-volume-note",className:"vis-hidden",children:"Controls live music volume."})]})]})}),document.body)}const a0="https://www.youtube-nocookie.com";function v9(e,t,n){const r=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${a0}/embed/${n?encodeURIComponent(n):"live_stream"}?${r.toString()}`}function Ld(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function x9(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const b9=[1,3],k9=[0,2],N9=[2,5,100,101,150];function _9(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;const{event:n,info:r}=t;if(n==="onReady")return{kind:"ready"};if(n==="onError"){const a=typeof r=="number"?r:Number(r==null?void 0:r.errorCode);return Number.isFinite(a)?{kind:"error",code:a}:null}if(n==="onStateChange"||n==="infoDelivery"){const a=typeof r=="number"?r:r==null?void 0:r.playerState;return typeof a!="number"||!Number.isFinite(a)?null:b9.includes(a)?{kind:"playing",playing:!0}:k9.includes(a)?{kind:"playing",playing:!1}:null}return null}const pI=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],QT=18,S9=pI.length,mI=new Set(["a","c","p"]);function nf(e=pI){const t=[];return e.forEach((n,r)=>{let a=0;for(;a<n.length;){const l=n[a];if(l==="."){a+=1;continue}let c=1;for(;a+c<n.length&&n[a+c]===l;)c+=1;t.push({x:a,y:r,w:c,cell:l}),a+=c}}),t}const Io=148,JT=6e3,j9=16e3,gI=46,$a=34;function E9(e,t,n=Io){let r=-Math.round(t()*n);if(Math.abs(r-e)<$a){const a=e-$a>=-n?-$a:$a;r=Math.max(-n,Math.min(0,Math.round(e+a)))}return{to:r,ms:Math.round(Math.abs(r-e)*gI)}}function C9(e){return Math.round(JT+e()*(j9-JT))}const e2=[{kind:"stroll",weight:44},{kind:"tidy",weight:17},{kind:"kick",weight:17},{kind:"sit",weight:12},{kind:"watch",weight:16},{kind:"leave",weight:7},{kind:"fish",weight:12},{kind:"skip",weight:10}];function T9(e){const t=e2.reduce((r,a)=>r+a.weight,0);let n=e()*t;for(const r of e2)if(n-=r.weight,n<0)return r.kind;return"stroll"}const A9=720,R9=260,M9=620,I9=220,t2=520,yI=1600,n2=7e3,$9=15e3,r2=6e3,O9=14e3;function Di(e,t,n=Io){let r=-Math.round(t()*n);if(Math.abs(r-e)<$a){const a=e-$a>=-n?-$a:$a;r=Math.max(-n,Math.min(0,Math.round(e+a)))}return r}const dn=(e,t)=>Math.round(Math.abs(t-e)*gI),Pd=0;function L9(e,t){const n=r=>({kind:"litter",at:t,...r});return[{x:t,prop:n({}),act:"walk",ms:dn(e,t)},{x:t,prop:n({}),act:"stoop",ms:A9},{x:Pd,prop:n({held:!0}),act:"carry",ms:dn(t,Pd)},{x:Pd,prop:n({held:!0}),act:"windup",ms:R9},{x:Pd,prop:n({held:!0,leaving:!0}),act:"toss",ms:M9}]}function P9(e,t){const n=t>e?1:-1,r=t-n*Math.min(15,Math.abs(t-e)),a=(l={})=>({kind:"ball",at:t,...l});return[{x:r,prop:a(),act:"walk",ms:dn(e,r)},{x:r,prop:a(),act:"windup",ms:I9,facing:n>0?"right":"left"},{x:r,prop:a({leaving:!0}),act:"kick",ms:t2,facing:n>0?"right":"left"},{x:r,prop:a({leaving:!0}),act:"stand",ms:yI-t2}]}const wI=640;function D9(e,t,n){const r=Math.max(-70,Math.min(-20,t)),a={x:r,prop:null,facing:"left"};return[{x:r,prop:null,act:"walk",ms:dn(e,r)},{...a,act:"sit",ms:600},{...a,act:"cast",ms:900},{...a,act:"fish",ms:6e3+Math.round(n()*4e3)},{...a,act:"reel",ms:1200},{...a,act:"stow",ms:500},{...a,act:"stand",ms:400},{x:0,prop:null,act:"walk",ms:dn(r,0)}]}function F9(e,t,n){const r=Math.max(-110,Math.min(-30,t)),a={x:r,prop:null};return[{...a,act:"walk",ms:dn(e,r)},{...a,act:"skip-ready",ms:500},{...a,act:"skip",ms:wI*(6+Math.floor(n()*5))},{...a,act:"skip-rest",ms:600},{...a,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:dn(r,0)}]}function q9(e,t,n){return[{x:t,prop:null,act:"walk",ms:dn(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(r2+n()*(O9-r2))},{x:t,prop:null,act:"stand",ms:400}]}function B9(e,t,n){t=Math.max(-110,Math.min(0,t));const r=()=>({kind:"scope",at:t,held:!0});return[{x:t,prop:null,act:"walk",ms:dn(e,t)},{x:t,prop:r(),act:"watch",ms:Math.round(n2+n()*($9-n2))},{x:t,prop:r(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function s2(e,t,n){return e.facing?e.facing:e.act==="watch"||e.act==="scope-pack"?"left":e.x===t?n:e.x>t?"right":"left"}const z9=1500,H9=e=>Math.round(1e3*Math.sqrt(2*e/z9)),U9=115,W9=e=>Math.round(e/U9*1e3),V9=620,G9=200,K9=760,Y9=600,X9=240;function Z9(e,t,n){const a=-(t.ledgeSpan??Io),l=H9(t.ledgeH),c=W9(t.ledgeH),u=-Math.round(n()*t.floorSpan),f=-Math.round(n()*t.floorSpan);return[{x:a,act:"walk",prop:null,ms:dn(e,a)},{x:a,act:"peer",prop:null,ms:V9},{x:a,act:"fall",prop:null,ms:l,place:"floor"},{x:a,act:"land",prop:null,ms:G9,place:"floor"},{x:u,act:"walk",prop:null,ms:dn(a,u),place:"floor"},{x:f,act:"walk",prop:null,ms:dn(u,f),place:"floor"},{x:a,act:"walk",prop:null,ms:dn(f,a),place:"floor"},{x:a,act:"lasso",prop:null,ms:K9,place:"floor"},{x:a,act:"rope-throw",prop:null,ms:Y9,place:"floor"},{x:a,act:"rope-catch",prop:null,ms:X9,place:"floor"},{x:a,act:"climb",prop:null,ms:c},{x:a,act:"pull-up",prop:null,ms:480}]}function Q9(e,t,n){const r=(n==null?void 0:n.ledgeSpan)??Io;switch(T9(t)){case"tidy":return L9(e,Di(e,t,r));case"kick":return P9(e,Di(e,t,r));case"sit":return q9(e,Di(e,t,r),t);case"watch":return B9(e,Di(e,t,r),t);case"fish":return D9(e,Di(e,t,r),t);case"skip":return F9(e,Di(e,t,r),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return Z9(e,n,t)}}const l=E9(e,t,r);return[{x:l.to,prop:null,act:"walk",ms:l.ms}]}const J9=[".xx.","xxxx",".xx."],eV=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],tV=["...xx...............","..xaax..............",".xaallx.............","xaallllx............",".xllllllx...........","..xllllllx..........","...xllllllx.........","....xllllllxx.......",".....xllllxsxx..xx..","......xllxsssx.xllxx",".......xxssssxxxllxx","........xssssssxx...",".........xssssx.....","..........xxxx......","..........xax.......",".........xxxxx......","........xx.x.xx.....","........xl.x.lx.....",".......xl..x..lx....",".......xl..x..lx....","......xl...x...lx...","......xl...x...lx...",".....xl....x....lx..","....xxx...xxx...xxx."],fx={litter:J9,ball:eV,scope:tV},vI=["bob","sway","groove"],a2=9e3,nV=16e3,xI=1e3,rV=.08;function sV(e,t){const n=vI.filter(l=>l!==e),r=n[Math.min(n.length-1,Math.floor(t()*n.length))],a=(t()*2-1)*rV;return{dance:r,beatMs:Math.round(xI*(1+a))}}function aV(e){return Math.round(a2+e()*(nV-a2))}const oV=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],iV=3,lV=-1,o0=11,o2=9,cV=420;function uV(e,t,n){const r=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(cV,Math.max(0,r))}const dV=260,hV=200;function fV(e,t,n){const r=(h,m=dn(e,h))=>({x:h,prop:null,act:"walk",ms:m,place:"floor"});if(!n||n.height<=0)return[r(t)];const a=Math.min(e,t);if(Math.max(e,t)<=n.left||a>=n.right)return[r(t)];const c=t>e,u=c?n.left:n.right,f=c?n.right:n.left,p={place:"floor",riser:n.height,prop:null};return[r(u,dn(e,u)),{...p,x:u,act:"mount",ms:dV},{...p,x:f,act:"walk",ms:dn(u,f)},{x:f,prop:null,act:"dismount",ms:hV,place:"floor"},{x:t,prop:null,act:"walk",ms:dn(f,t),place:"floor"}]}function i2(e){let t=null,n=null,r=0,a=0,l=!1;const c=()=>{t!==null&&clearTimeout(t),t=null},u=()=>{l||e.hidden||!n||t!==null||(a=performance.now(),t=setTimeout(()=>{t=null;const p=n;n=null,p==null||p()},r))},f=()=>{e.hidden&&t!==null?(r=Math.max(0,r-(performance.now()-a)),c()):e.hidden||u()};return e.addEventListener("visibilitychange",f),{schedule(p,h){l||(c(),n=p,r=Math.max(0,h),u())},dispose(){l=!0,c(),n=null,e.removeEventListener("visibilitychange",f)}}}const wc={"claude-fm":"Claude FM","lofi-relax":"Lofi Girl relax/study","lofi-game":"Lofi Girl chill/game","lofi-vibe":"Lofi Girl vibe/chill","lofi-sleep":"Lofi Girl sleep/chill","radio-mix":"Radio Mix Live","best-of-nostalgia":"Best of Nostalgia Live","good-life-radio":"The Good Life Radio Live","cafe-music-bgm":"Cafe Music BGM Live"},pV={"claude-fm":null,"lofi-relax":null,"lofi-game":null,"lofi-vibe":null,"lofi-sleep":null,"radio-mix":"/api/live-radio-mix","best-of-nostalgia":"/api/best-of-nostalgia","good-life-radio":"/api/good-life-radio","cafe-music-bgm":"/api/cafe-music-bgm"};function px(e,t){var r;const n=((r=e[0])==null?void 0:r.length)??0;return o.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:nf(e).map(a=>o.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,fill:a.cell==="s"?"var(--fm-prop-shadow, var(--bg))":a.cell==="l"?"var(--fm-prop-light, var(--text))":a.cell==="a"?"var(--accent)":void 0},`${t}${a.y}-${a.x}`))})}const mx={e:"fm-eye",s:"fm-shade",p:"fm-pad"},vh=nf().filter(e=>!mI.has(e.cell)),mV=nf().filter(e=>mI.has(e.cell)),l2=vh.filter(e=>e.cell==="e"),gV=nf(oV),yV=vh.filter(e=>e.y<o0&&e.cell!=="e").map(e=>{if(e.y!==8&&e.y!==9)return e;const t=Math.max(6,e.x);return{...e,x:t,w:Math.max(0,Math.min(12,e.x+e.w)-t)}}).filter(e=>e.w>0),wV={left:vh.filter(e=>e.y>=o0&&e.x<o2),right:vh.filter(e=>e.y>=o0&&e.x>=o2)},c2={litter:px(fx.litter,"litter"),ball:px(fx.ball,"ball"),scope:px(fx.scope,"scope")},vV=x.memo(function({fetchImpl:t,volume:n,source:r="claude-fm"}){const[a,l]=x.useState(null),[c,u]=x.useState(!1),[f,p]=x.useState(!1),[h,m]=x.useState(!1),y=x.useRef(r),[w,j]=x.useState(0),[k,S]=x.useState(0),[b,N]=x.useState(null),[E,C]=x.useState(null),[T,A]=x.useState({x:0,drop:0}),[I,B]=x.useState("ledge"),[q,L]=x.useState("left"),[U,X]=x.useState(0),Y=x.useRef(null),[M,J]=x.useState(()=>document.hidden);x.useEffect(()=>{const O=new Set,te=()=>{var ae;if(document.hidden){for(const he of((ae=Y.current)==null?void 0:ae.getAnimations({subtree:!0}))??[])if(he.playState==="running"||he.pending){const ge=he.currentTime;he.pause(),ge!==null&&(he.currentTime=ge),O.add(he)}}else{for(const he of O)he.playState==="paused"&&he.play();O.clear()}J(document.hidden)};return te(),document.addEventListener("visibilitychange",te),()=>document.removeEventListener("visibilitychange",te)},[a,c]);const[V,$]=x.useState(null),[z,W]=x.useState(xI),[G,F]=x.useState(()=>{var O;return((O=window.matchMedia)==null?void 0:O.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});x.useEffect(()=>{var ae;const O=(ae=window.matchMedia)==null?void 0:ae.call(window,"(prefers-reduced-motion: reduce)");if(!O)return;const te=()=>F(O.matches);return te(),O.addEventListener("change",te),()=>O.removeEventListener("change",te)},[]);const K=x.useRef(null),de=x.useCallback(O=>{var te,ae;(ae=(te=K.current)==null?void 0:te.contentWindow)==null||ae.postMessage(O,a0)},[]),H=x.useRef(n);if(H.current=n,x.useEffect(()=>{f&&de(Ld("setVolume",[n]))},[n,f,de]),x.useEffect(()=>{let O=!0;const te=t??fetch,ae=y.current!==r;y.current=r,l(null),u(!1),p(ae),m(ae);const he=pV[r];if(he)te(he).then(ge=>ge.ok?ge.json():null).then(ge=>{O&&(ge!=null&&ge.video)&&l({live:!0,channel:"",video:ge.video})}).catch(()=>{});else if(r!=="claude-fm"){const ge=r.replace("lofi-","");te(`/api/lofi-girl?station=${encodeURIComponent(ge)}`).then(Te=>Te.ok?Te.json():null).then(Te=>{O&&(Te!=null&&Te.video)&&l({live:!0,channel:"",video:Te.video})}).catch(()=>{})}else te("/api/claude-fm").then(ge=>ge.ok?ge.json():null).then(ge=>{O&&(ge!=null&&ge.live)&&(ge!=null&&ge.channel)&&l({live:!0,channel:ge.channel})}).catch(()=>{});return()=>{O=!1}},[t,r]),x.useEffect(()=>{if(!f)return;const O=te=>{var he;if(te.origin!==a0||te.source!==((he=K.current)==null?void 0:he.contentWindow))return;const ae=_9(te.data);if(ae){if(ae.kind==="ready"){de(Ld("setVolume",[H.current])),de(Ld("playVideo"));return}if(ae.kind==="playing"){m(ae.playing);return}N9.includes(ae.code)&&(p(!1),m(!1),u(!0))}};return window.addEventListener("message",O),()=>window.removeEventListener("message",O)},[f,de]),x.useEffect(()=>{if(!a||c||G)return;const O=i2(document);let te=0;j(je=>te=je);const ae=je=>{var at,le;const[ve,...Ue]=je;if(!ve){N(null),C(null),Ve();return}N(ve.act),C(ve.prop),B(ve.place??"ledge"),X(ve.riser??0);const ke=De(ve),xe=te;if(ve.act==="kick"){const _e=(le=(at=Y.current)==null?void 0:at.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:le.getBoundingClientRect();_e&&A({x:uV(_e.x,s2(ve,xe,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-_e.y+24)})}const rt=ve.act==="walk"||ve.act==="carry"?dn(xe,ke):ve.ms;S(rt),L(_e=>s2({...ve,x:ke},xe,_e)),j(ke),te=ke,O.schedule(()=>ae(Ue),rt)},he=()=>{const je=Y.current,ve=je==null?void 0:je.querySelector(".fm-sprite"),Ue=je==null?void 0:je.parentElement;if(!je||!ve||!Ue)return null;const ke=je.getBoundingClientRect(),xe=Ue.getBoundingClientRect(),Ge=xe.right-ke.right,rt=xe.width-Ge*2-ve.offsetWidth;return rt>0?rt:null},ge=()=>{const je=Y.current,ve=je==null?void 0:je.querySelector(".fm-walker"),Ue=he();if(!je||!ve||Ue==null)return;const ke=je.getBoundingClientRect().bottom-ve.getBoundingClientRect().bottom;if(ke>0)return{ledgeH:ke,floorSpan:Ue}},Te=()=>{const je=Y.current,ve=document.querySelector(".autofit-chip");if(!je||!ve)return null;const Ue=je.getBoundingClientRect(),ke=ve.getBoundingClientRect();return ke.width<=0||ke.height<=0?null:{left:ke.left-Ue.right,right:ke.right-Ue.right,height:ke.height}},De=je=>{const ve=(je.place??"ledge")==="floor"?he()??Io:Io;return Math.max(-ve,Math.min(0,je.x))},Ve=()=>{O.schedule(()=>{const je=Q9(te,Math.random,ge()),ve=je.some(xe=>xe.place==="floor")?Te():null;let Ue=te;const ke=je.flatMap(xe=>{const Ge=Ue;return Ue=xe.x,xe.place==="floor"&&xe.act==="walk"?fV(Ge,xe.x,ve):[xe]});ae(ke)},C9(Math.random))};return Ve(),()=>{O.dispose(),B("ledge"),j(je=>Math.max(-Io,Math.min(0,je))),S(0),N(null),C(null),X(0)}},[a,c,G]),x.useEffect(()=>{if(!h||G){$(null);return}const O=i2(document),te=ae=>{const he=sV(ae,Math.random);$(he.dance),W(he.beatMs),O.schedule(()=>te(he.dance),aV(Math.random))};return te(null),()=>O.dispose()},[h,G]),!a||c)return null;const Q=()=>{if(!f){p(!0),m(!0);return}const O=!h;m(O),de(Ld(O?"playVideo":"pauseVideo")),O||p(!1)};return o.jsxs("div",{ref:Y,className:"fm","data-suspended":M?"":void 0,"data-place":I,style:{"--fm-beat":`${z}ms`},children:[E&&!E.held&&o.jsx("div",{className:"fm-prop","data-prop":E.kind,"data-leaving":E.leaving?"":void 0,style:{"--fm-prop-x":`${E.at}px`,"--fm-roll-to":`${T.x}px`,"--fm-ball-drop":`${T.drop}px`,"--fm-ball-flight-ms":`${yI}ms`,"--fm-ball-turn":q==="right"?"1080deg":"-1080deg"},children:c2[E.kind]}),(b==="lasso"||b==="rope-throw"||b==="rope-catch"||b==="climb"||b==="pull-up")&&o.jsxs("div",{className:"fm-rope","data-act":b,style:{"--fm-rope-x":`${w}px`,"--fm-rope-ms":`${k}ms`},children:[o.jsx("div",{className:"fm-rope-line"}),o.jsxs("svg",{className:"fm-rope-hook",viewBox:"0 0 9 9",shapeRendering:"crispEdges","aria-hidden":!0,children:[o.jsx("path",{d:"M4 8V3H3V1H1V3H0V5H2V4H3V6H5V4H6V5H8V3H7V1H5V3H4"}),o.jsx("rect",{className:"fm-rope-knot",x:"3",y:"6",width:"3",height:"2"})]})]}),o.jsxs("div",{className:"fm-walker","data-act":b??void 0,"data-place":I,"data-facing":q,style:{"--fm-x":`${w}px`,"--fm-walk-ms":`${k}ms`,"--fm-riser":`${U}px`,"--fm-skip-beat":`${wI}ms`},children:[(E==null?void 0:E.held)&&o.jsx("div",{className:"fm-held","data-prop":E.kind,"data-toss":E.leaving?"":void 0,children:c2[E.kind]}),["cast","fish","reel","stow"].includes(b)&&o.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[o.jsxs("g",{children:[o.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),o.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),o.jsxs("g",{className:"fm-fishing-line",children:[o.jsx("path",{d:"M8 2V26"}),o.jsxs("g",{className:"fm-float",children:[o.jsx("rect",{x:"7",y:"25",width:"3",height:"2"}),o.jsx("rect",{x:"8",y:"24",width:"1",height:"1"})]})]}),o.jsx("path",{className:"fm-ripple",d:"M3 28H6M10 28H14M5 30H12"})]}),["skip-ready","skip","skip-rest"].includes(b)&&o.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[o.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),o.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),o.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),o.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),o.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),o.jsx("button",{type:"button",className:"fm-sprite","data-playing":h?"":void 0,"data-dance":h?V??vI[0]:void 0,"aria-pressed":h,onClick:Q,title:h?`Stop ${wc[r]}`:`Play ${wc[r]} — streams from YouTube`,"aria-label":h?`Stop ${wc[r]}`:`Play ${wc[r]}`,children:o.jsxs("svg",{viewBox:`0 0 ${QT} ${S9}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[o.jsx("g",{className:"fm-gear",children:o.jsx("g",{className:"fm-gear-motion",children:mV.map(O=>o.jsx("rect",{x:O.x,y:O.y,width:O.w,height:1,className:mx[O.cell]},`g${O.y}-${O.x}`))})}),o.jsxs("g",{className:"fm-body",children:[l2.map(O=>o.jsx("rect",{x:O.x,y:O.y,width:O.w,height:1,fill:"var(--accent)"},`eye-bed-${O.x}`)),yV.map(O=>o.jsx("rect",{x:O.x,y:O.y,width:O.w,height:1,className:mx[O.cell]},`b${O.y}-${O.x}`)),o.jsxs("g",{className:"fm-arms",children:[o.jsx("rect",{x:4,y:8,width:2,height:2}),o.jsx("rect",{x:12,y:8,width:1,height:2}),o.jsx("rect",{x:13,y:8,width:1,height:2,className:"fm-shade"})]}),l2.map(O=>o.jsx("rect",{x:O.x-(O.x>=QT/2?1:0)+(q==="right"?1:0),y:O.y,width:O.w,height:1,className:"fm-eye"},`eye-${O.x}`))]}),o.jsx("g",{className:"fm-hat",children:gV.map(O=>o.jsx("rect",{x:iV+O.x,y:lV+O.y,width:O.w,height:1,className:O.cell==="k"?"fm-hatband":void 0},`h${O.y}-${O.x}`))}),(b==="climb"||b==="rope-throw"||b==="rope-catch"||b==="pull-up")&&o.jsxs("g",{className:"fm-grip",children:[o.jsx("path",{className:"fm-grip-left",d:"M5 9H4V4H7V3H9V5H6V9Z"}),o.jsx("path",{className:"fm-grip-right",d:"M12 9H14V6H11V5H9V7H12Z"})]}),(b==="land"||b==="dismount")&&o.jsxs("g",{className:"fm-crouch-legs",children:[o.jsx("path",{d:"M6 11H8V13H6Z"}),o.jsx("path",{d:"M10 11H12V13H10Z"})]}),["sit","cast","fish","reel","stow"].includes(b)&&o.jsxs("g",{className:"fm-seated-legs",children:[o.jsx("path",{className:"fm-seated-far",d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),o.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(O=>o.jsx("g",{className:"fm-leg","data-side":O,children:wV[O].map(te=>o.jsx("rect",{x:te.x,y:te.y,width:te.w,height:1,className:mx[te.cell]},`${O}${te.y}-${te.x}`))},O))]})})]}),f&&(a.channel||a.video)&&o.jsx("iframe",{ref:K,className:"fm-frame",title:wc[r],src:v9(a.channel,window.location.origin,a.video),onLoad:()=>de(x9()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})]})}),xV=15e3;function bV(e){return e.visibilityState==="visible"&&e.hasFocus()}function kV(e,t){return t||e===!0}function NV(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}const _V={"//":["What a user would NOTICE. One key per version that has something to say,","and no key at all for a version that has nothing — which is most of them.","","The rule this file exists to serve: before every release, ask 'what would a","user notice?' and write the answer here. 'Nothing user-visible' is a valid","and expected answer, and it is spelled by adding no key. A release with no","key shows no modal, and that silence is what keeps the modal worth reading","on the day it is not silent.","","What belongs here: something that changed on the user's machine or under","their hands — a hook written to or removed from settings.json, a default","that flipped, a control that moved or went away, a stored preference that","changed meaning. What does not: bounds, races, assertions that could not","fire, anything that is invisible when it is correct.","","Write it for the person running the deck, not for the person reading the","diff. `title` is the sentence they scan; `body` is what they need in order","to act on it, or to stop worrying about it.","","Keys are versions exactly as package.json spells them. A key that is not a","version, or an entry missing either field, fails the suite rather than","being quietly dropped — see src/web/__tests__/release-notes-file.test.ts.","Ordering here is for humans; the deck sorts by version itself.","","A title may open with an emoji, and if it does, put exactly ONE space after","it. Not two: the dialog gives a leading emoji its own optical gap, because","a colour glyph is drawn edge to edge inside its advance and one word space","after one reads as none. A second space here would be a lie in the data","about a defect in the type, and the suite refuses both it and no space at","all.","","A release that genuinely has nothing to say is spelled TWICE: no key here,",'and its version written into "//nothing-to-say" below. One spelling on its',"own is ambiguous — a missing key reads the same whether it was a decision","or a forgotten step, and five releases in a row were once forgotten. The list","is what tells the two apart, and release-notes-current-version.test.ts fails","the release whose version is in neither place. Any key opening with // is a","note to the author and never a release."],"//nothing-to-say":["3.23.1","3.23.2","3.23.3","3.23.4","3.26.0","3.26.1","3.26.3","3.26.4","3.26.5","3.27.6","3.27.7"],"3.27.0":[{title:"📊 Projects: where each account spent its work",body:"Each account card's ⋯ menu now breaks its cost down by project, over 7d / 30d / all."}],"3.27.1":[{title:"🎨 Make Appearance easier to tune",body:"The Appearance dialog now has clearer sections, stronger selection states, and a calmer layout for choosing a theme and configuring music. Your existing settings and keyboard shortcuts continue to work."}],"3.27.2":[{title:"💰 Project costs now match Usage",body:"Project cost totals no longer count the same Claude request once for every content block. Existing project history is rebuilt automatically so the totals align with the Usage panel."}],"3.27.3":[{title:"🎵 Station selection works in the desktop app",body:"The music station picker now opens inside ccdeck instead of relying on the operating system popup, so choosing a station works reliably in the Electron app."}],"3.27.4":[{title:"✅ Desktop picker release checks are green",body:"The station picker now keeps the same keyboard, motion, focus, and layout behavior as the rest of ccdeck across desktop and browser builds."}],"3.27.5":[{title:"🧭 The welcome tour stays dismissed",body:"Electron now remembers that you completed the onboarding tour at the deck level, so an update or loopback port change no longer shows the same tour again."},{title:"🎵 The station picker has a clearer finish",body:"The music selector has a tighter trigger, a purposeful chevron, and more deliberate option spacing so it reads like a native part of Appearance."}],"3.25.0":[{title:"🖱️ A click goes to the session, a double-click opens the details",body:"Clicking a card frames it with the rest of its session and leaves the detail panel shut. Double-click a card to open its details; `j`/`k`, the session list, Enter and `D` still open them too."},{title:"🔭 Cards stay readable when you zoom out",body:"At every zoom a card shows its name, its state and anything waiting on you, instead of shrinking to a coloured pill. Hover or focus a card to see it whole. Recap notes read at a distance too, and show the full recap on hover."},{title:"🌐 The Machine panel shows your network",body:"A new Network section shows download, upload and the round trip to Claude's API, and names the route when traffic goes through a VPN or a Tailscale exit node. Those checks run only while the panel is open. The panel is regrouped into CPU, Memory, Network and Thermal, with a flag at the top when something needs attention."},{title:"🎨 See each theme before you pick it",body:"The Appearance menu shows a small preview of the deck in Light and in Dark. Claude FM also keeps its volume when a notification chime plays, instead of dipping under it."}],"3.24.1":[{title:"🎛️ Appearance is one small menu now",body:"The topbar's appearance control opens a compact menu where you can choose Light or Dark and show or hide the character. The character stays on by default, and your choice is remembered."}],"3.24.0":[{title:"🎧 Claude FM plays from the minimap",body:"A small character stands on the minimap's top edge. Press it and the Claude channel's live stream plays; press it again and it stops. It only turns up when the channel is actually broadcasting, so a deck with no network never shows it at all."},{title:"🤠 And it gets on with its day",body:"It walks that edge, tidies up what it finds, kicks a ball along it, sits with its legs over the side, and watches the board through a scope. Now and then it drops onto the canvas and ropes its way back up. Headphones on while the music plays, a hat when it does not."}],"3.23.5":[{title:"🧭 The accounts panel opens on the account you are on",body:"Its windows, its resets and how old the numbers are — whole, at the top of the column. Every other account stands behind one row that says how many of them a switch could actually reach; press it to see them, or rest on it to be shown their names and how much room each has left."},{title:"⚙️ Auto-switch moved in there with them",body:"It is behind that same row now, after the accounts it switches between, rather than at the foot of the panel. The row says `auto 90%` or `auto off` so you can tell what the policy is doing without opening it — and says so in amber when it is armed with nowhere left to go."}],"3.23.0":[{title:"🧭 The accounts column leads with accounts",body:`The live account is the open row: its windows as bars, when each one resets, and how old the numbers are. Every other account rests on the two figures a switch is decided by, and opens with a click when you want the rest.
|
|
93
93
|
|
|
94
94
|
A problem stays on the row — an expired login, one that was never stored, a keychain the deck cannot open — with the reason and the sign-in one press away. Auto-switch is one row now: its threshold and its switch. Local network moved out of the column into a view of its own, reached from a row at the foot that says how many of the paired machines are on right now, and shows which ones when you hover it.`},{title:"💬 A resting session shows Claude Code's recap beside its card",body:"When a session stops, Claude Code's own recap of what it did is drawn beside the card — so a board you come back to says what happened without opening anything."},{title:"🪟 The chrome went quiet",body:`The topbar is borderless, one set of corners runs through the app, the canvas ground is flat, and the minimap, the zoom controls, the type filter and the Machine and Usage panels read as tooling rather than as cards.
|
|
95
95
|
|
|
@@ -287,7 +287,7 @@ Both CLIs get the finish tone. The second tone — Claude is waiting for you —
|
|
|
287
287
|
|
|
288
288
|
Waiting for a click: this browser plays no sound until the page has been used at least once. Anything you press unlocks it.`:"";return c+u+f+`
|
|
289
289
|
|
|
290
|
-
Click to set the volume and the sound of each tone, and to hear either one.`}function xh(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const x2=99;function aK(e){const t=Math.max(0,Math.floor(e));return t>x2?`${x2}+`:String(t)}const oK="Pause the canvas";function iK(e){if(!e.paused)return"Pause live updates — events keep arriving and are applied when you resume (Space)";const t=Math.max(0,Math.floor(e.dropped??0));return t>0?`The pause is full — ${xh(e.held)} held and ${t} older ${t===1?"one":"ones"} already dropped. Resume to follow the canvas again (Space)`:e.held<=0?"Nothing has arrived since you paused. Resume to follow the canvas again (Space)":`${xh(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function lK(e){return e.connected||!e.paused?null:"The canvas is paused as well — Space resumes it, but nothing new arrives until the stream is back."}const LI="paused · full",cK=(e,t)=>t>0?LI:e>0?`paused · ${aK(e)}`:"paused";function uK(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:cK(e.held,t),widest:LI,title:t>0?`Connected — the pause is full at ${xh(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${xh(e.held)} held until you resume (Space)`:"Connected — updates held until you resume (Space)"}:{tone:"live",resting:!0,label:"live",widest:"live",title:"Receiving events"}:{tone:"dead",resting:!1,label:"offline",widest:"offline",title:e.paused?"SSE disconnected — and the canvas is paused, so resuming will not bring events back until it reconnects":"SSE disconnected"}}const dK=x.lazy(()=>T2(()=>import("./UsageHistoryModal-DuvLGQcU.js"),[])),hK=x.lazy(()=>T2(()=>import("./BrowserWatchModal-Co4YHA59.js"),[]));function b2(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const fK={agent:nF,sessionGroup:$F,recapNote:LF},pK={recapTie:PF},PI="react-flow__node";function vx(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,PI))===!0}const xx=80,bx=.86;function k2(e){if(!e)return 0;const t=e.getBoundingClientRect();let n=t.right;for(const r of document.querySelectorAll(".sysdetail:not(.leaving), .usage-panel:not(.leaving)")){const a=r.getBoundingClientRect();a.width>0&&a.left>t.left&&(n=Math.min(n,a.left))}return Math.max(0,t.right-n)}function mK(e){try{const t=document.querySelector(`.${PI}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}const gK=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),yK=420,Bd=18,N2=400,kx=450,yb="agent-dag.layout",wb="agent-dag.layoutFrame",vb="agent-dag.viewport",DI="agent-dag.sessionListOpen",FI="agent-dag.detailOpen",qI="agent-dag.usagePanelOpen",BI="agent-dag.systemPanelOpen",_2="agent-dag.accountsPanelOpen",Nx="agent-dag.versionNoticeDismissed",S2="agent-dag.oldNameNoticeDismissed",wK=15*6e4,_x={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:",retired_name:"this install came from a name that is no longer published — run:"},zd="agent-dag.autoRestart",j2="agent-dag.bundleReloadedFor";function vK(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(DI)==="1"}catch{return!1}}function xK(e){if(!(typeof window>"u"))try{window.localStorage.setItem(DI,e?"1":"0")}catch{}}function bK(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(FI)==="1"}catch{return!1}}function kK(e){if(!(typeof window>"u"))try{window.localStorage.setItem(FI,e?"1":"0")}catch{}}function NK(){const e=ks(qI);return e===null?!0:e==="1"}function _K(e){if(!(typeof window>"u"))try{window.localStorage.setItem(qI,e?"1":"0")}catch{}}function SK(){const e=ks(BI);return e===null?!0:e==="1"}function jK(e){if(!(typeof window>"u"))try{window.localStorage.setItem(BI,e?"1":"0")}catch{}}function EK(){if(typeof window>"u")return{positions:[],pins:[]};try{return NG(window.localStorage.getItem(yb))}catch{return{positions:[],pins:[]}}}function Hd(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(yb,_G(e,t))}catch{}}function CK(){if(typeof window>"u")return null;try{return SG(window.localStorage.getItem(wb))}catch{return null}}function TK(e){if(!(typeof window>"u"))try{window.localStorage.setItem(wb,JSON.stringify(e))}catch{}}function AK(){if(typeof window>"u")return null;try{return jG(window.localStorage.getItem(vb))}catch{return null}}function RK(e){if(!(typeof window>"u"))try{window.localStorage.setItem(vb,JSON.stringify(e))}catch{}}function E2(){if(!(typeof window>"u")){try{window.localStorage.removeItem(yb)}catch{}try{window.localStorage.removeItem(vb)}catch{}try{window.localStorage.removeItem(wb)}catch{}}}function MK(e,t){const n=I7(e,t,new Date().toISOString());if(!n)return;const r=JSON.stringify(n,null,2),a=new Blob([r],{type:"application/json"}),l=URL.createObjectURL(a),c=document.createElement("a");c.href=l,c.download=$7(n.label,t),document.body.appendChild(c),c.click(),document.body.removeChild(c),setTimeout(()=>URL.revokeObjectURL(l),1e3)}const zI={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},IK={file:"M3.4 1.8h4.5l2.7 2.7v7.7H3.4z M7.9 1.8v2.7h2.7",shell:"M2.4 3.8 5.6 7l-3.2 3.2 M7.4 10.6h4.2",web:"M7 1.8a5.2 5.2 0 1 0 0 10.4A5.2 5.2 0 1 0 7 1.8z M1.8 7h10.4 M7 1.8c-1.5 1.4-2.3 3.1-2.3 5.2s.8 3.8 2.3 5.2c1.5-1.4 2.3-3.1 2.3-5.2S8.5 3.2 7 1.8z",agent:"M3.3 4.8h7.4a1.2 1.2 0 0 1 1.2 1.2v4.8a1.2 1.2 0 0 1-1.2 1.2H3.3a1.2 1.2 0 0 1-1.2-1.2V6a1.2 1.2 0 0 1 1.2-1.2z M7 4.8V2.4 M5.3 8.2h.01 M8.7 8.2h.01",task:"M2.2 4l1.2 1.2 2-2.2 M7.4 4.2h4.4 M2.2 9.4l1.2 1.2 2-2.2 M7.4 9.6h4.4",plan:"M7 1.8a5.2 5.2 0 1 0 0 10.4A5.2 5.2 0 1 0 7 1.8z M9 5 8 8 5 9l1-3z",mcp:"M5 1.8v2.6 M9 1.8v2.6 M3.6 4.4h6.8v2.2a3.4 3.4 0 0 1-6.8 0z M7 10v2.2",other:"M3.5 7h.01 M7 7h.01 M10.5 7h.01"};function $K({cat:e}){return o.jsx("svg",{className:"cat-glyph",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:o.jsx("path",{d:IK[e]})})}const bh={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},HI=bR;function OK(){return o.jsx(T0,{children:o.jsx(DK,{})})}const LK=e=>e.transform[2]>=e.maxZoom,PK=e=>e.transform[2]<=e.minZoom;function DK(){var Ru,Mu,mi,Fr;const e=Th(),t=mt(LK),n=mt(PK),r=Gt(),a=x.useState(Bx)[0],l=x.useRef(a),[,c]=x.useState(0),u=x.useCallback(()=>c(D=>D+1),[]),[f,p]=x.useState(bK);x.useEffect(()=>{kK(f)},[f]);const[h,m]=x.useState(()=>new Set),[y,w]=x.useState(null),[j,k]=x.useState(null),S=x.useCallback((D,P,re=!P)=>{m(oe=>{if(!P)return new Set([D]);const we=new Set(oe);return we.has(D)?we.delete(D):we.add(D),we}),w(oe=>P&&oe===D?oe:D),!P&&re&&p(!0)},[]),b=x.useCallback(()=>{m(new Set),w(null)},[]),[N,E]=x.useState(null),[C,T]=x.useState(null),A=x.useCallback(D=>T(D),[]),[I,B]=x.useState(!1),[q,L]=x.useState(!1),[U,X]=x.useState(!1),Y=x.useRef(null),[M,J]=x.useState(vK);x.useEffect(()=>{xK(M)},[M]);const[V,$]=x.useState(NK);x.useEffect(()=>{_K(V)},[V]);const[z,W]=x.useState(SK);x.useEffect(()=>{jK(z)},[z]);const G=x.useRef(!1),[F,K]=x.useState(()=>{const D=(()=>{try{const P=window.localStorage.getItem(_2);return P===null?!0:P==="1"}catch{return!0}})();return D&&M?(G.current=!0,!1):D});x.useEffect(()=>{if(!(!F&&G.current))try{window.localStorage.setItem(_2,F?"1":"0")}catch{}},[F]),x.useEffect(()=>{!M&&G.current&&(G.current=!1,K(!0))},[M]);const de=Fp(F,200),H=Fp(V,130),Q=Fp(z,130),[O,te]=x.useState(null);x.useEffect(()=>{let D=null;try{D=localStorage.getItem("agent-dag.sound")}catch{}te(D===null?!0:D==="on")},[]);const ae=x.useCallback(()=>{te(D=>{var re;const P=D!==!0;try{localStorage.setItem("agent-dag.sound",P?"on":"off")}catch{}return P&&((re=Ie.current)==null||re.unlock()),P})},[]),he=x.useCallback(D=>{ae()},[ae]),ge=x.useRef(he);ge.current=he;const Te=x.useRef(O);Te.current=O;const[De,Ve]=x.useState(()=>e9(ks)),je=x.useRef(De);je.current=De;const ve=x.useRef(null),Ue=x.useCallback((D,P=!1)=>{var re,oe;if((re=Ie.current)==null||re.unlock(),ve.current!==null&&clearTimeout(ve.current),ve.current=null,!P){(oe=Ie.current)==null||oe.play(D,!0);return}ve.current=setTimeout(()=>{var we;ve.current=null,(we=Ie.current)==null||we.play(D,!0)},Y7)},[]),ke=x.useCallback((D,P)=>{Ve(re=>{const oe={level:Wc(P.level??re[D].level),figure:oI(D,P.figure??re[D].figure)};try{localStorage.setItem(lI[D],String(oe.level)),localStorage.setItem(cI[D],oe.figure)}catch{}return{...re,[D]:oe}}),Ue(D,!0)},[Ue]);x.useEffect(()=>()=>{ve.current!==null&&clearTimeout(ve.current)},[]);const[xe,Ge]=x.useState(!1),rt=x.useRef(null),[at,le]=x.useState(!1),_e=x.useRef(null);x.useEffect(()=>{xe&&le(!1)},[xe]);const Ie=x.useRef(null),[Ze,We]=x.useState("locked");x.useEffect(()=>{const D=n9({enabled:()=>Te.current===!0,prefs:()=>je.current,onState:We});Ie.current=D,We(D.state());const P=()=>D.unlock();return window.addEventListener("pointerdown",P,{once:!0,capture:!0}),window.addEventListener("keydown",P,{once:!0,capture:!0}),()=>{window.removeEventListener("pointerdown",P,{capture:!0}),window.removeEventListener("keydown",P,{capture:!0})}},[]);const[Je,ye]=x.useState(!1),[Me,Qe]=x.useState(!1),[ue,kt]=x.useState(null),[pt,ut]=x.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(Nx)??""}catch{return""}}),[Bt,jt]=x.useState(!1),vt=x.useRef(0),[an,jn]=x.useState(!1),Nt=x.useCallback((D=!1)=>(D&&(vt.current=Date.now(),jn(!0)),fetch(D?"/api/version?refresh=1":"/api/version").then(P=>P.ok?P.json():null).then(P=>{P&&kt(P)}).catch(()=>{}).finally(()=>{D&&jn(!1)})),[]),Yt=x.useCallback(()=>{Nt(Date.now()-vt.current>=wK)},[Nt]);x.useEffect(()=>{Nt();const D=window.setInterval(Yt,5*6e4),P=()=>{document.visibilityState==="visible"&&Yt()};return document.addEventListener("visibilitychange",P),()=>{window.clearInterval(D),document.removeEventListener("visibilitychange",P)}},[Nt,Yt]),x.useEffect(()=>{Je&&Nt()},[Je,Nt]),x.useEffect(()=>{const D=NV();let P=null;const re=Le=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:D,looking:Le}),keepalive:!0}).catch(()=>{})},oe=()=>{const Le=bV(document);kV(P,Le)&&re(Le),P=Le},we=()=>{P&&re(!1),P=!1};oe();const Ce=window.setInterval(oe,xV);return window.addEventListener("focus",oe),window.addEventListener("blur",oe),document.addEventListener("visibilitychange",oe),window.addEventListener("pagehide",we),()=>{window.clearInterval(Ce),window.removeEventListener("focus",oe),window.removeEventListener("blur",oe),document.removeEventListener("visibilitychange",oe),window.removeEventListener("pagehide",we),we()}},[]);const fe=(ue==null?void 0:ue.notice)??null,[st,It]=x.useState(null),Et=x.useRef(!1),[En,Gn]=x.useState(null);x.useEffect(()=>{fetch("/api/prefs").then(D=>D.ok?D.json():null).then(D=>{var P;return Gn(typeof((P=D==null?void 0:D.prefs)==null?void 0:P.tourSeen)=="boolean"?D.prefs.tourSeen:!1)}).catch(()=>Gn(!1))},[]),x.useEffect(()=>{if(Et.current||En===null)return;const D=h2(),P=MV(D),re=DV({stored:P,running:(ue==null?void 0:ue.running)??null,notes:d2,remembers:IV(D)});if(re.reason==="no-version")return;if(Et.current=!0,re.record&&$V(D,re.record),En)try{D==null||D.setItem("agent-dag.tourSeen","1")}catch{}const oe=PV({tourSeen:OV(D),decision:re}),we=re.show.length?{entries:re.show,since:P,firstRun:!1}:null;oe.tour&&X(!0),oe.notes==="now"?It(we):oe.notes==="after"&&(Y.current=we)},[En,ue==null?void 0:ue.running]);const St=(ue==null?void 0:ue.running)??"3.27.6",lr=x.useMemo(()=>bI(d2,null,St),[St]),yn=x.useCallback(()=>{It({entries:lr,since:null,firstRun:!1})},[lr]),[Xt,Cn]=x.useState(null),[zt,In]=x.useState(u0);x.useEffect(()=>{let D=!1;return fetch("/api/health").then(P=>P.ok?P.json():null).then(P=>{D||(In(JG(P)),!(!P||typeof P.workspace!="string")&&Cn(P.workspace))}).catch(()=>{}),()=>{D=!0}},[Je]);const Kn=x.useRef(zt);Kn.current=zt;const cr=OI(fe),$n=ZG(fe,pt),ea=x.useCallback(()=>{ut("");try{window.localStorage.setItem(Nx,"")}catch{}},[]),ta=x.useCallback(()=>{if(fe){ut(cr);try{window.localStorage.setItem(Nx,cr)}catch{}}},[fe,cr]),[_s,On]=x.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(S2)??""}catch{return""}}),wn=ue!=null&&ue.invokedAs&&ue.invokedAs!==nn?ue.invokedAs:null,ee=wn!=null&&_s!==wn,Ae=x.useCallback(()=>{if(wn){On(wn);try{window.localStorage.setItem(S2,wn)}catch{}}},[wn]),Oe=((Ru=ue==null?void 0:ue.upgrade)==null?void 0:Ru.state)??"idle",Re=Pz(ue==null?void 0:ue.upgrade),ze=x.useRef(!1),dt=x.useCallback(async()=>{if(Ks(ze.current||Oe==="running")){ze.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await Nt(),ze.current=!1}},[Oe,Nt]);x.useEffect(()=>{if(Oe!=="running")return;const D=window.setInterval(Nt,3e3);return()=>window.clearInterval(D)},[Oe,Nt]);const yt=x.useCallback(async()=>{const D=ue==null?void 0:ue.command;!D||!await sl(D)||(jt(!0),window.setTimeout(()=>jt(!1),1600))},[ue==null?void 0:ue.command]),Ct=x.useCallback(()=>{J(D=>(D||K(P=>(P&&(G.current=!0),!1)),!D))},[]),gt=x.useCallback(()=>{G.current=!1,K(D=>(D||J(!1),!D))},[]),[xt,Ar]=x.useState(!1),[Ss,ns]=x.useState(!1),[Ba,Wo]=x.useState(()=>{try{return Number(localStorage.getItem(f2))||0}catch{return 0}}),[js,Ln]=x.useState([]),[Es,Pn]=x.useState(!1);x.useEffect(()=>{let D=!0;const P=()=>{fetch("/api/browser-watch?live=0").then(oe=>oe.ok?oe.json():null).then(oe=>{var we;!D||!(oe!=null&&oe.ok)||(Ln(oe.episodes??[]),Pn(((we=oe.settings)==null?void 0:we.enabled)===!0))}).catch(()=>{})};P();const re=setInterval(P,5*6e4);return()=>{D=!1,clearInterval(re)}},[]);const[rf,Vo]=x.useState([]),su=x.useRef(new Set),[Cs,za]=x.useState(null);x.useEffect(()=>{let D=!0,P=0;const re=()=>{fetch("/api/lan").then(oe=>oe.ok?oe.json():null).then(oe=>D?(oe!=null&&oe.ok&&Vo(y_(Array.isArray(oe.pending)?oe.pending:[],oe.aliases)),oe):null).catch(()=>null).then(oe=>{D&&(P=window.setTimeout(re,(oe==null?void 0:oe.enabled)===!0?e0:QR))})};return re(),()=>{D=!1,window.clearTimeout(P)}},[]);const na=x.useCallback(async(D,P)=>{if(!Cs){za(D);try{const oe=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:D,fp:P})})).json().catch(()=>null);oe&&Array.isArray(oe.pending)?Vo(y_(oe.pending,oe.aliases)):Vo(we=>we.filter(Ce=>Ce.fp!==P))}catch{}finally{za(null)}}},[Cs]),rs=x.useMemo(()=>hG(js,Ba).length,[js,Ba]),[sf,au]=x.useState(0),Go=x.useRef(null),[ou,Ko]=x.useState(!1),Rr=x.useRef(null),[af,Yo]=x.useState(0),nt=x.useState(()=>JV({protect:D=>aD(l.current,D)}))[0],[Ha,iu]=x.useState(!1),Ua=x.useCallback(()=>{const D=nt.paused&&nt.dropped>0,P=nt.setPaused(!nt.paused);D&&oD(l.current);for(const re of P)l.current=lN(l.current,re);iu(nt.paused)},[nt]),[Wt,lu]=x.useState(Date.now()),[Mr,ra]=x.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(zd)!=="0"}catch{return!0}}),Wa=x.useRef(!1),ss=x.useCallback(()=>{const D=!Mr;Wa.current=!0;try{window.localStorage.removeItem(zd)}catch{}ra(D),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:D})}).then(P=>P.ok?P.json():null).then(P=>{var re;P!=null&&P.ok&&ra(((re=P.prefs)==null?void 0:re.autoUpdate)!==!1)}).catch(()=>{})},[Mr]),[hn,Yn]=x.useState(!1),[Va,Ga]=x.useState("restart"),[Ir,cu]=x.useState(null),Ts=x.useRef(!1),sa=x.useRef(null),uu=x.useRef(0),aa=x.useCallback(async D=>{if(!Ks(Ts.current))return;const P=(D==null?void 0:D.upgrade)===!0;Ts.current=!0,sa.current=Re;const re=++uu.current;Ga(P?"npx":"restart"),Yn(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(fe==null?void 0:fe.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:P})})}catch{}window.setTimeout(()=>{if(uu.current===re&&Ts.current){Ts.current=!1,Yn(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},P?18e4:3e4)},[fe==null?void 0:fe.to,Re]),oa=x.useRef(null);x.useEffect(()=>{const D=N_(l.current.agents.values())>0,P=zz({enabled:Mr,kind:fe==null?void 0:fe.kind,canRestart:(ue==null?void 0:ue.canRestart)===!0,noticeOpen:$n,visible:document.visibilityState==="visible",busy:D,idleSince:oa.current,now:Wt});oa.current=P.idleSince,P.restart&&aa()},[Mr,fe==null?void 0:fe.kind,ue==null?void 0:ue.canRestart,$n,Wt,aa]);const yl=N_(l.current.agents.values()),du=Bz(yl),ia=nM({enabled:Mr,kind:fe==null?void 0:fe.kind,canRestart:(ue==null?void 0:ue.canRestart)===!0,noticeOpen:$n,visible:document.visibilityState==="visible",busy:yl>0,idleSince:oa.current,now:Wt});x.useEffect(()=>{const D=ue==null?void 0:ue.running;let P=null,re=null;try{P=window.sessionStorage.getItem("agent-dag.restartPending"),re=window.sessionStorage.getItem(j2)}catch{return}const oe=Lz({bundle:"3.27.6",running:D,pending:P,lastTried:re});if(oe==="reload"){try{window.sessionStorage.setItem(j2,D??"")}catch{return}window.location.reload();return}if(oe!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}Ts.current=!1,Yn(!1),cu(D??null);const we=window.setTimeout(()=>cu(null),6e3);return()=>window.clearTimeout(we)},[ue==null?void 0:ue.running]),x.useEffect(()=>{if(hn&&Dz({asked:sa.current,reported:Re})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}Ts.current=!1,Yn(!1)}},[hn,Re]);const la=x.useState(()=>kG(EK()))[0],Tt=x.useRef(la.pinned),As=x.useRef(null),Xo=x.useState(()=>AK())[0],[wl,vl]=x.useState(()=>new Set),[$r,Zo]=x.useState(nG),[ca,as]=x.useState(f9),[ua,Qo]=x.useState(m9),[Ka,Jo]=x.useState(d9),[Or,hu]=x.useState(()=>p2(b2)),vn=x.useMemo(()=>xG(Or),[Or]),da=x.useCallback(D=>vG(D,vn),[vn]),[ei,Ya]=x.useState(!1);x.useEffect(()=>{document.documentElement.dataset.theme=$r;try{window.localStorage.setItem(SI,$r)}catch{}hu(D=>{const P=p2(b2);return bG(D,P)?D:P})},[$r]),x.useEffect(()=>{try{window.localStorage.setItem(uI,ca?"1":"0")}catch{}},[ca]),x.useEffect(()=>{try{window.localStorage.setItem(dI,String(ua))}catch{}},[ua]),x.useEffect(()=>{try{window.localStorage.setItem(hI,Ka)}catch{}},[Ka]);const Xn=x.useCallback((D,P)=>{if(qd({durationMs:P,documentHidden:document.hidden})){e.setViewport(D,{duration:P});return}const{d3Zoom:re,d3Selection:oe}=r.getState(),we=oe==null?void 0:oe.property("__zoom");if(re&&oe&&we&&we.k>0&&D.zoom>0){re.transform(oe,we.scale(D.zoom/we.k).translate((D.x-we.x)/D.zoom,(D.y-we.y)/D.zoom));return}e.setViewport(D,{duration:0})},[e,r]),os=x.useRef(null),Rs=x.useRef(0),is=x.useRef(null),Xa=x.useRef(()=>{});x.useEffect(()=>{if(!Xo)return;const D=window.setTimeout(()=>{try{Xn(Xo,0)}catch{}Lr.current=Date.now()},60);return()=>window.clearTimeout(D)},[Xn,Xo]);const xl=x.useRef(!0),[Za,fu]=x.useState(null);x.useEffect(()=>{const D=new EventSource("/events"),P=ZV(u,{now:()=>Date.now(),setTimeout:(Ce,Le)=>window.setTimeout(Ce,Le),clearTimeout:Ce=>window.clearTimeout(Ce)});let re=!1;const oe=typeof BroadcastChannel=="function"?oG(new BroadcastChannel(sG),Math.random().toString(36).slice(2),()=>re):null,we=window.setInterval(()=>{re||!oe||oe.ask(600).then(Ce=>{re||Qe(aG(Ce))})},3e3);return D.addEventListener("open",()=>{ye(!0),Ya(!0)}),D.addEventListener("error",()=>{ye(!1),fu(null)}),D.addEventListener("open",()=>{re=!0,Qe(!1)}),D.addEventListener("error",()=>{re=!1}),D.addEventListener("replay-end",()=>{xl.current=!1,P.flush(),fu(Date.now())}),D.addEventListener("hook",Ce=>{var Le;try{const et=JSON.parse(Ce.data);if(!nt.accept(et))return;l.current=lN(l.current,et);const ct=et.replay===!0||xl.current||Date.now()-et.receivedAt>3e4;ct?P.replay():P.live();const Ke=t9(et,ct);Ke&&((Le=Ie.current)==null||Le.play(Ke))}catch{}}),()=>{D.close(),P.cancel(),window.clearInterval(we),oe==null||oe.leave()}},[u]),x.useEffect(()=>{const D=setInterval(()=>{const P=Date.now();lu(P);const{changed:re,forgotten:oe}=j7(l.current,P);oe.length>0&&fetch("/api/forget",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:oe})}).catch(()=>{}),m(we=>N7(we,l.current.agents)),w(we=>we!=null&&!l.current.agents.has(we)?null:we),T(we=>we!=null&&!l.current.agents.has(we)?null:we),E(we=>we!=null&&!l.current.agents.has(we)?null:we),re&&u()},250);return()=>clearInterval(D)},[u]);const bl=x.useRef(null),Lr=x.useRef(0),pu=420,Dn=x.useCallback((D=500)=>{const P=xx,re=1,oe=.2,we=bx;try{const Ce=document.querySelector(".canvas-wrap"),Le=Array.from(document.querySelectorAll(".react-flow__node")).filter(At=>At.offsetWidth>0);if(!Ce||Le.length===0)return;const et=Ce.getBoundingClientRect(),ct=e.getViewport();if(!Number.isFinite(ct.zoom)||ct.zoom<=0)return;const Ke=At=>(At-et.left-ct.x)/ct.zoom,Pt=At=>(At-et.top-ct.y)/ct.zoom,Dt=Le.map(At=>At.getBoundingClientRect()),qr=Math.min(...Dt.map(At=>Ke(At.left))),hr=Math.max(...Dt.map(At=>Ke(At.right))),Jn=Math.min(...Dt.map(At=>Pt(At.top))),_t=Math.max(...Dt.map(At=>Pt(At.bottom))),wt=hr-qr,fr=_t-Jn;if(!(wt>0&&fr>0))return;const on=k2(Ce),fn=At=>Math.max(oe,Math.min(re,(et.width-on-P*2)/(wt+At)*we,(et.height-P*2)/fr*we)),er=PG(fn(pu),fn(0)),pr={x:P-qr*er,y:Math.max(P,(et.height-fr*er)/2)-Jn*er,zoom:er},bn=++Rs.current;Xn(pr,D),Lr.current=Date.now(),os.current=qd({durationMs:D,documentHidden:document.hidden})?{target:pr,until:Date.now()+D+60}:null,window.setTimeout(()=>{var At;try{if(((At=os.current)==null?void 0:At.target)===pr&&(os.current=null),Rs.current!==bn)return;const Gl=e.getViewport();(Math.abs(Gl.zoom-er)>.01||Math.abs(Gl.x-pr.x)>2)&&Xn(pr,0)}catch{}},D+60)}catch{}},[e,Xn]);x.useEffect(()=>{const D=()=>{if(!document.hidden)return;const P=os.current;if(os.current=null,!(!P||Date.now()>P.until)){try{Xn(P.target,0)}catch{}Lr.current=Date.now()}};return document.addEventListener("visibilitychange",D),()=>document.removeEventListener("visibilitychange",D)},[Xn]);const kl=x.useRef(""),Nl=x.useRef(null),mu=x.useRef(0),Qa=x.useCallback(()=>{mu.current=Date.now()},[]),_l=x.useRef(null),gu=x.useRef(0),Sl=x.useCallback(()=>{gu.current=Date.now()},[]),jl=x.useCallback(D=>({hasSourceEvent:!!D,at:Date.now(),lastDeckFitAt:Lr.current,lastCanvasInputAt:gu.current}),[]),El="agent-dag.autoFitDisabled",Ms=x.useRef(!1),[Cl,yu]=x.useState(!1);x.useEffect(()=>{try{window.localStorage.removeItem(El)}catch{}},[]);const ha=x.useCallback(()=>{Ms.current||(Ms.current=!0,yu(!0))},[]),wu=x.useCallback(()=>{Ms.current=!1,yu(!1),Dn(400)},[e,Dn]);x.useEffect(()=>{const D=setInterval(()=>{if(Ms.current||Date.now()-mu.current<800)return;const P=l.current,re=Date.now(),oe=[];for(const Ce of P.agents.values())i0(Ce,re)&&oe.push({id:Ce.id});if(oe.length===0)return;const we=[];for(const{id:Ce}of oe){const Le=Pr.current.get(Ce),et=Tt.current.get(Ce)??$t.current.get(Ce);!Le||!et||we.push({x:et.x,y:et.y,width:Le.width,height:Le.height})}RG({pane:_l.current,viewport:e.getViewport(),boxes:we})&&Dn(600)},1500);return()=>clearInterval(D)},[e]);const ti=x.useRef(!1),Pr=x.useRef(new Map),Tl=x.useRef(0),of=x.useCallback(D=>{const P=Pr.current;let re=!1;for(const oe of D.nodeInternals.values()){const we=oe.width,Ce=oe.height;if(we==null||Ce==null)continue;const Le=P.get(oe.id);Le?(Math.abs(Le.height-Ce)>4||Math.abs(Le.width-we)>4)&&(P.set(oe.id,{width:we,height:Ce}),re=!0):(P.set(oe.id,{width:we,height:Ce}),re=!0)}return re&&(Tl.current+=1),Tl.current},[]),vu=mt(of),[xu,Al]=x.useState(0);x.useEffect(()=>{let D=0;const P=()=>{const oe=Pr.current;let we=!1;for(const Ce of document.querySelectorAll(".react-flow__node[data-id]")){const Le=Ce.getAttribute("data-id");if(!Le)continue;const et=Ce.offsetWidth,ct=Ce.offsetHeight;if(!et||!ct)continue;const Ke=oe.get(Le);(!Ke||Math.abs(Ke.width-et)>4||Math.abs(Ke.height-ct)>4)&&(oe.set(Le,{width:et,height:ct}),we=!0)}we&&Al(Ce=>Ce+1)};if(ti.current)return;let re=0;return document.visibilityState==="hidden"?re=window.setTimeout(P,32):D=requestAnimationFrame(P),()=>{cancelAnimationFrame(D),window.clearTimeout(re)}});const $t=x.useRef(la.positions),bu=x.useRef(new Set),Ja=x.useRef(""),Is=x.useMemo(()=>{const D=[];for(const P of l.current.agents.values())i0(P,Wt)&&D.push(P.id+(P.parentId?`>${P.parentId}`:""));return D.sort(),`${D.join("|")}#sv${vu}.${xu}`},[l.current,l.current.revision,Wt,vu,xu]),fa=x.useRef(null);x.useEffect(()=>(fa.current!=null&&window.clearTimeout(fa.current),fa.current=window.setTimeout(()=>{Hd($t.current,Tt.current)},1500),()=>{fa.current!=null&&window.clearTimeout(fa.current)}),[Is]),x.useEffect(()=>{if(kl.current===Is)return;const D=kl.current;if(kl.current=Is,!D||Ms.current)return;Date.now()-Lr.current>1200&&Dn(400),bl.current&&window.clearTimeout(bl.current),bl.current=window.setTimeout(()=>{Ms.current||Dn(500)},280)},[Is,e,Dn]);const ni=x.useMemo(()=>KV(l.current,h),[l.current,l.current.revision,h]),ri=x.useMemo(()=>gG(l.current,Wt),[l.current,l.current.revision,Wt]),Fn=x.useRef(null),[eo,ku]=x.useState({w:0,h:0});x.useEffect(()=>{const D=Fn.current;if(!D||typeof ResizeObserver>"u")return;const P=new ResizeObserver(re=>{var we;const oe=(we=re[0])==null?void 0:we.contentRect;oe&&(_l.current={width:oe.width,height:oe.height},ku(Ce=>Math.abs(Ce.w-oe.width)>40||Math.abs(Ce.h-oe.height)>40?{w:oe.width,h:oe.height}:Ce))});return P.observe(D),_l.current={width:D.clientWidth,height:D.clientHeight},ku({w:D.clientWidth,h:D.clientHeight}),()=>P.disconnect()},[]);const lf=x.useCallback(D=>{var re,oe;const P=D.target;!(P!=null&&P.closest)||P.closest(gK)!==D.currentTarget||(D.preventDefault(),(oe=(re=document.activeElement)==null?void 0:re.blur)==null||oe.call(re))},[]),Nu=x.useRef(new Map),[to,no]=x.useState(!1);x.useEffect(()=>{const D=window.setTimeout(()=>no(!0),2500);return()=>window.clearTimeout(D)},[]);const[ro,Rl]=x.useState(!1),Zn=x.useRef(null),[so,Ml]=x.useState(!1),[Il,$l]=x.useState("detail"),ls=x.useRef(null),si=x.useRef(null),_u=x.useCallback(()=>{var oe;const D=Tl.current;if(((oe=si.current)==null?void 0:oe.version)===D)return si.current.card;const P=[];for(const we of l.current.agents.keys()){const Ce=Pr.current.get(we);Ce&&P.push(Ce)}const re=IG(P);return si.current={version:D,card:re},re},[]),cf=x.useCallback(()=>{Zn.current&&(window.clearTimeout(Zn.current),Zn.current=null),Rl(!1)},[]),uf=x.useCallback(D=>{D.length!==0&&queueMicrotask(()=>{Rl(!0),Zn.current&&window.clearTimeout(Zn.current),Zn.current=window.setTimeout(()=>Rl(!1),yK+80)})},[]);x.useEffect(()=>()=>{Zn.current&&window.clearTimeout(Zn.current)},[]);const xn=y?l.current.agents.get(y):null,Su=f&&xn!=null,[Ol,Qn]=x.useState(0);x.useEffect(()=>{const D=k2(Fn.current);Qn(P=>Math.abs(P-D)>40?D:P)},[Q,H,V,Su,eo.w]);const $s=x.useRef(Ol);$s.current=Ol;const ao=eo.w>0?Math.max(0,(eo.w-Ol-xx*2)*bx):0,oo=eo.h>0?Math.max(0,(eo.h-xx*2)*bx):0,ju=m6(),{nodes:Dr,edges:ai}=x.useMemo(()=>A7(l.current,Wt,ao,oo,Tt.current,Pr.current,Nu.current,uf,to,so,$t.current,bu.current,Is,Ja,h,ni,ri,A),[l.current,l.current.revision,Wt,ao,oo,to,so,Is,h,ni,ri,A,sf,ju]),df=x.useState(CK)[0],Eu=x.useRef(df);x.useEffect(()=>{if(!to||so)return;const D={width:ao,height:oo};if(!(D.width>0&&D.height>0))return;const P=Eu.current;if(Eu.current=D,TK(D),!P||P.width===D.width&&P.height===D.height)return;const re={direction:"LR",pinned:Tt.current,measured:Pr.current,lanes:n0(l.current)};if(!d7(Dr,ai,re,P,D))return;const oe=is.current&&Date.now()-is.current.at<1500?is.current.id:null,we=oe??hs.current,Ce=we?Tt.current.get(we)??$t.current.get(we):void 0;for(const Le of Array.from($t.current.keys()))Tt.current.has(Le)||$t.current.delete(Le);bu.current.clear(),Ja.current="",u(),window.setTimeout(()=>{if(Hd($t.current,Tt.current),Ms.current){if(oe){Xa.current(oe);return}const Le=we?Tt.current.get(we)??$t.current.get(we):void 0;if(Ce&&Le&&(Le.x!==Ce.x||Le.y!==Ce.y)){const et=e.getViewport();Rs.current+=1,Xn({x:et.x-(Le.x-Ce.x)*et.zoom,y:et.y-(Le.y-Ce.y)*et.zoom,zoom:et.zoom},0),Lr.current=Date.now()}return}Dn(500)},80)},[ao,oo,to,so,u,Dn,e,Xn]);const Os=x.useMemo(()=>{const D=new Map;for(const re of Dr){const oe=re.data;if(!(oe!=null&&oe.sessionId)||oe.exitAt!=null)continue;const we=re.width,Ce=re.height;if(we==null||Ce==null)continue;const Le=re.position.x,et=re.position.y,ct=Le+we,Ke=et+Ce,Pt=D.get(oe.sessionId);Pt?(Pt.minX=Math.min(Pt.minX,Le),Pt.minY=Math.min(Pt.minY,et),Pt.maxX=Math.max(Pt.maxX,ct),Pt.maxY=Math.max(Pt.maxY,Ke)):D.set(oe.sessionId,{minX:Le,minY:et,maxX:ct,maxY:Ke})}const P=[];for(const[re,oe]of D){const we=oe.maxX-oe.minX+Bd*2,Ce=oe.maxY-oe.minY+Bd*2;P.push({id:`group:${re}`,type:jI,position:{x:oe.minX-Bd,y:oe.minY-Bd},data:{sessionId:re,w:we,h:Ce},width:we,height:Ce,style:{width:we,height:Ce},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return P},[Dr]),Ll=x.useMemo(()=>{const D=[...Os,...Dr],P=Rr.current;return!P||P.size===0?D:D.map(re=>{const oe=P.get(re.id);return oe?{...re,position:oe}:re})},[Os,Dr,af]),cs=x.useMemo(()=>{const D=new Set;for(const P of l.current.agents.values())for(const re of P.tools)D.add(HI(re.name));return Object.keys(zI).filter(P=>D.has(P))},[l.current,l.current.revision]);x.useEffect(()=>{if(cs.length<=1){Ko(!1);return}let D=0;const P=()=>{const re=Go.current;if(re&&!document.hidden){const oe=re.getBoundingClientRect(),we=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Le=>Le.getBoundingClientRect()),Ce=wG(oe,we,8);Ko(Le=>Le===Ce?Le:Ce)}D=window.setTimeout(P,300)};return P(),()=>window.clearTimeout(D)},[cs.length]);const Pl=x.useCallback(D=>{vl(P=>{const re=new Set(P);return re.has(D)?re.delete(D):re.add(D),re})},[]),oi=j?Z5(l.current.agents,j):null,io=x.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}l.current=Bx(),Tt.current.clear(),Pr.current.clear(),$t.current.clear(),Ja.current="",E2(),b(),u()},[u,b]),Ls=x.useRef(I);Ls.current=I;const ii=x.useRef(q);ii.current=q;const li=x.useRef(!1);li.current=oi!=null||xt||C!=null||U||N!=null||Ss||q||st!=null;const Ps=x.useCallback(D=>{const P=O7(D,{confirmOpen:Ls.current,modalOpen:li.current});P==="confirm"?B(!0):P==="clear"&&(B(!1),io())},[io]),ci=x.useCallback(()=>{Tt.current.clear(),$t.current.clear(),Ja.current="",E2(),u(),window.setTimeout(()=>Dn(500),80)},[u,e,Dn]),Dl=x.useCallback(()=>Dn(500),[Dn]),us=x.useRef(Dr);us.current=Dr;const Tn=x.useCallback(D=>{var Pt;const P=Fn.current,re=l.current.agents.get(D);if(!P||!re)return;const oe=n0(l.current),we=(Dt,qr)=>{const hr=Pr.current.get(Dt.id);if(!hr)return null;const Jn=qr&&oe.has(Dt.id)?pu:0;return{x:Dt.position.x,y:Dt.position.y,width:hr.width+Jn,height:hr.height}},Ce=us.current.find(Dt=>Dt.id===D),Le=Ce?we(Ce,!1):null;if(!Le)return;const et=[];for(const Dt of us.current){if(Dt.type!=="agent"&&Dt.type!=="recapNote"||((Pt=Dt.data)==null?void 0:Pt.sessionId)!==re.sessionId)continue;const qr=we(Dt,Dt.type==="agent");qr&&et.push(qr)}const ct=P.getBoundingClientRect(),Ke=qG({pane:{width:ct.width,height:ct.height},insets:{top:56,left:72,bottom:32,right:$s.current+32},context:BG(et)??Le,anchor:Le});Ca(),ha(),is.current={id:D,at:Date.now()},Rs.current+=1,Xn(Ke,kx),Lr.current=Date.now(),os.current=qd({durationMs:kx,documentHidden:document.hidden})?{target:Ke,until:Date.now()+kx+60}:null},[Xn,ha]);Xa.current=Tn;const Cu=x.useCallback(D=>{const P=us.current.find(re=>re.id===D&&re.type==="agent");return P?P.data:void 0},[]),Tu=x.useCallback(D=>{var P;return(P=l.current.agents.get(D))==null?void 0:P.label},[]),ds=x.useCallback(D=>{var oe;const P=us.current.find(we=>we.id===D&&we.type==="recapNote");if(!P)return;const re=P.data;return{recap:re.recap,hue:re.hue,sessionLabel:(oe=l.current.agents.get(re.parentId))==null?void 0:oe.label}},[]),Fl=x.useCallback(()=>{var re;const D=(re=Fn.current)==null?void 0:re.getBoundingClientRect(),P=document.documentElement;return D?{width:D.right-$s.current,height:D.bottom}:{width:P.clientWidth,height:P.clientHeight}},[]),hs=x.useRef(y);hs.current=y;const ui=x.useCallback(D=>{const P=us.current.filter(Ce=>Ce.type==="agent"),re=zV(P.map(Ce=>({id:Ce.id,x:Ce.position.x,y:Ce.position.y})),hs.current,D),oe=re?P.find(Ce=>Ce.id===re):void 0;if(!oe)return;const we=vx(document.activeElement);S(oe.id,!1),window.setTimeout(()=>{try{Tn(oe.id)}catch{}we&&mK(oe.id)},30)},[S,Tn]),ql=x.useRef(null),ur=x.useCallback(D=>{S(D,!1),window.setTimeout(()=>{try{Tn(D)}catch{}},60)},[S,Tn]),Au=x.useRef(null);x.useEffect(()=>{let D=-1/0;const P=()=>{D=performance.now()},re=oe=>{Au.current=performance.now()-D<250?oe.target:null};return window.addEventListener("pointerdown",P,!0),window.addEventListener("focusin",re,!0),()=>{window.removeEventListener("pointerdown",P,!0),window.removeEventListener("focusin",re,!0)}},[]),x.useEffect(()=>{const D=P=>{var et,ct;const re=P.target,oe={tagName:re==null?void 0:re.tagName,isContentEditable:re==null?void 0:re.isContentEditable,role:(et=re==null?void 0:re.getAttribute)==null?void 0:et.call(re,"role"),type:re==null?void 0:re.type,pointerFocused:re!=null&&re===Au.current};if(P.key==="Escape"){const Ke=FD({overlayOpen:jc.depth()>0,typing:O0(oe)});Ke==="dismiss"?jc.dismissTop():Ke==="blur"?re==null||re.blur():(VV(oe)&&(re==null||re.blur()),b());return}if(Mh(P))return;const we=vx(re)?(ct=re==null?void 0:re.getAttribute)==null?void 0:ct.call(re,"data-id"):null,Ce=we&&us.current.some(Ke=>Ke.id===we)?we:null,Le=UV(P,Ce);if(Le.kind==="activate"){P.preventDefault(),S(Le.nodeId,Le.additive);return}if(Le.kind!=="node"&&!(Le.nodeId==null&&KD(oe,P.key))&&!YD({key:P.key,modalOpen:XD({appModal:li.current,dialogDepth:jc.dialogDepth()}),sheetOpen:ii.current})){if(P.key===" "&&(P.preventDefault(),Ua()),(P.key==="c"||P.key==="C")&&Ps("shortcut"),(P.key==="r"||P.key==="R")&&ci(),(P.key==="f"||P.key==="F")&&Dl(),(P.key==="z"||P.key==="Z")&&hs.current&&Tn(hs.current),(P.key==="l"||P.key==="L")&&Ct(),P.key==="d"||P.key==="D")if(hs.current)p(Ke=>!Ke);else{const Ke=Lp(l.current.agents.values());Ke.length>0?ur(Ke[0].id):ui(1)}if((P.key==="h"||P.key==="H")&&Ar(Ke=>!Ke),(P.key==="u"||P.key==="U")&&$(Ke=>!Ke),(P.key==="a"||P.key==="A")&&Kn.current.claude&>(),(P.key==="j"||P.key==="J")&&ui(1),(P.key==="k"||P.key==="K")&&ui(-1),P.key==="w"||P.key==="W"){const Ke=TD(Lp(l.current.agents.values()),ql.current);Ke&&(ql.current=Ke.id,ur(Ke.id))}(P.key==="t"||P.key==="T")&&Zo(Ke=>Ke==="dark"?"light":"dark"),(P.key==="m"||P.key==="M")&&Kn.current.claude&&Te.current!==null&&ge.current(P.shiftKey),(P.key==="s"||P.key==="S")&&W(Ke=>!Ke),(P.key==="b"||P.key==="B")&&ns(Ke=>!Ke),(P.key==="v"||P.key==="V")&&Kn.current.claude&&Te.current!==null&&Ge(Ke=>!Ke),P.key==="?"&&L(Ke=>!Ke)}};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[Ps,ci,Dl,b,S,ui,ur,Tn,Ua]);const Bl=l.current.agents.size,Zt=x.useMemo(()=>Lp(l.current.agents.values()),[l.current,l.current.revision]),bt=x.useMemo(()=>AD(l.current.agents.values()),[l.current,l.current.revision]),di=x.useRef(null);x.useEffect(()=>{const D=iG({waiting:Zt.length,running:bt,connected:Je}),P=di.current;if(di.current=D,(P==null?void 0:P.title)!==D.title&&(document.title=D.title),(P==null?void 0:P.icon)!==D.icon){const re=document.querySelector('link[rel="icon"]');re&&(re.href=lG[D.icon])}},[Zt.length,bt,Je]);const[hi,lo]=x.useState(""),zl=uG(Zt);x.useEffect(()=>{lo(D=>dG(D,zl))},[zl]);const[pa,co]=x.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[dr,fs]=x.useState(null),[uo,Hl]=x.useState(!1),[hf,Ul]=x.useState(!1);x.useEffect(()=>{let D=!0;return fetch("/api/prefs").then(P=>P.ok?P.json():null).then(P=>{var re,oe,we;if(!(!D||!(P!=null&&P.ok))){if(!Wa.current){let Ce=!1;try{Ce=window.localStorage.getItem(zd)==="0",window.localStorage.removeItem(zd)}catch{}Ce&&((re=P.prefs)==null?void 0:re.autoUpdate)!==!1?(ra(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):ra(((oe=P.prefs)==null?void 0:oe.autoUpdate)!==!1)}Hl(((we=P.prefs)==null?void 0:we.notifications)===!0),Ul(P.notificationsVetoed===!0)}}).catch(()=>{}),()=>{D=!1}},[]);const ho=x.useRef(()=>{}),fi=x.useCallback(()=>{const D=!uo;Hl(D),D&&typeof Notification<"u"&&Notification.permission==="default"&&ho.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:D})}).then(P=>P.ok?P.json():null).then(P=>{var re;P!=null&&P.ok&&(Hl(((re=P.prefs)==null?void 0:re.notifications)===!0),Ul(P.notificationsVetoed===!0))}).catch(()=>{})},[uo]),Wl=typeof Notification<"u";x.useEffect(()=>{if(!dr)return;const P=setTimeout(()=>fs(null),dr==="blocked"?8e3:4e3);return()=>clearTimeout(P)},[dr]);const pi=x.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(D=>{const P=D;co(P),P==="granted"?fs("on"):P==="denied"&&fs("blocked")})},[]);ho.current=pi;const Ds=x.useRef(new Set),fo=x.useRef(null),ff=Zt.map(D=>Rh(D.id,D.waiting)).join("|");x.useEffect(()=>{$D(fo.current,pa)&&(fo.current=pa,Ds.current=Pp(Zt))},[pa]);const Vl=x.useRef(!1);return x.useEffect(()=>{OD(Vl.current,Za)&&(Vl.current=!0,Ds.current=Pp(Zt))},[Za]),x.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!LD(fo.current,Za))return;const D=typeof document>"u"||!document.hidden,P=MD(Zt,Ds.current,D,uo);for(const re of P)try{const oe=new Notification(re.title,{body:re.body,tag:re.key});oe.onclick=()=>{window.focus(),ur(re.sessionId),oe.close()}}catch{}Ds.current=D?Pp(Zt):ID(Zt,P,Ds.current)},[ff,Za]),o.jsxs("div",{className:"app",children:[o.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),o.jsxs("header",{className:"topbar",children:[o.jsxs("div",{className:"readout",children:[o.jsxs("div",{className:"brand",children:[o.jsx("span",{className:"logo"}),o.jsx("h1",{children:nn}),fe?o.jsxs("button",{type:"button",className:"v stale",onClick:()=>{yn(),ea()},"aria-haspopup":"dialog","aria-label":XG({...fe,open:$n}),title:fe.kind==="restart"?`Running v${fe.from}; v${fe.to} is installed on disk. Restart to pick it up · click for what's new`:`Running v${fe.from}; v${fe.to} is on npm · click for what's new`,children:["v",fe.from,o.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const D={running:St,latest:ue==null?void 0:ue.latest,latestPending:ue==null?void 0:ue.latestPending,checkedAgo:ue!=null&&ue.checkedAt?Yd(Wt-ue.checkedAt):null,checkFailedAgo:ue!=null&&ue.checkFailedAt&&ue.checkFailedAt>(ue.checkedAt??0)?Yd(Wt-ue.checkFailedAt):null,checkDisabled:ue==null?void 0:ue.checkDisabled,checking:an};return o.jsxs("button",{type:"button",className:an?"v checking":"v",onClick:()=>{yn(),Nt(!0)},"aria-busy":an||void 0,"aria-haspopup":"dialog","aria-label":YG(D),title:KG(D),children:["v",D.running]})})()]}),o.jsx("span",{className:"status",children:(()=>{const D=uK({connected:Je,paused:Ha,held:nt.size,dropped:nt.dropped});return D.resting?null:o.jsx("span",{className:`pill ${D.tone}`,title:D.title,children:o.jsxs("span",{className:"pill-box",children:[o.jsx("span",{className:"pill-widest","aria-hidden":!0,children:D.widest}),o.jsx("span",{className:"pill-label",children:D.label})]})})})()}),o.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:hi}),Zt.length>0&&o.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>{ql.current=Zt[0].id,ur(Zt[0].id)},title:`Blocked waiting for you — click, or press W, to go to the one that has been stuck longest:
|
|
290
|
+
Click to set the volume and the sound of each tone, and to hear either one.`}function xh(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const x2=99;function aK(e){const t=Math.max(0,Math.floor(e));return t>x2?`${x2}+`:String(t)}const oK="Pause the canvas";function iK(e){if(!e.paused)return"Pause live updates — events keep arriving and are applied when you resume (Space)";const t=Math.max(0,Math.floor(e.dropped??0));return t>0?`The pause is full — ${xh(e.held)} held and ${t} older ${t===1?"one":"ones"} already dropped. Resume to follow the canvas again (Space)`:e.held<=0?"Nothing has arrived since you paused. Resume to follow the canvas again (Space)":`${xh(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function lK(e){return e.connected||!e.paused?null:"The canvas is paused as well — Space resumes it, but nothing new arrives until the stream is back."}const LI="paused · full",cK=(e,t)=>t>0?LI:e>0?`paused · ${aK(e)}`:"paused";function uK(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:cK(e.held,t),widest:LI,title:t>0?`Connected — the pause is full at ${xh(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${xh(e.held)} held until you resume (Space)`:"Connected — updates held until you resume (Space)"}:{tone:"live",resting:!0,label:"live",widest:"live",title:"Receiving events"}:{tone:"dead",resting:!1,label:"offline",widest:"offline",title:e.paused?"SSE disconnected — and the canvas is paused, so resuming will not bring events back until it reconnects":"SSE disconnected"}}const dK=x.lazy(()=>T2(()=>import("./UsageHistoryModal-6HRc9h9q.js"),[])),hK=x.lazy(()=>T2(()=>import("./BrowserWatchModal-DiMnzuse.js"),[]));function b2(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const fK={agent:nF,sessionGroup:$F,recapNote:LF},pK={recapTie:PF},PI="react-flow__node";function vx(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,PI))===!0}const xx=80,bx=.86;function k2(e){if(!e)return 0;const t=e.getBoundingClientRect();let n=t.right;for(const r of document.querySelectorAll(".sysdetail:not(.leaving), .usage-panel:not(.leaving)")){const a=r.getBoundingClientRect();a.width>0&&a.left>t.left&&(n=Math.min(n,a.left))}return Math.max(0,t.right-n)}function mK(e){try{const t=document.querySelector(`.${PI}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}const gK=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),yK=420,Bd=18,N2=400,kx=450,yb="agent-dag.layout",wb="agent-dag.layoutFrame",vb="agent-dag.viewport",DI="agent-dag.sessionListOpen",FI="agent-dag.detailOpen",qI="agent-dag.usagePanelOpen",BI="agent-dag.systemPanelOpen",_2="agent-dag.accountsPanelOpen",Nx="agent-dag.versionNoticeDismissed",S2="agent-dag.oldNameNoticeDismissed",wK=15*6e4,_x={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:",retired_name:"this install came from a name that is no longer published — run:"},zd="agent-dag.autoRestart",j2="agent-dag.bundleReloadedFor";function vK(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(DI)==="1"}catch{return!1}}function xK(e){if(!(typeof window>"u"))try{window.localStorage.setItem(DI,e?"1":"0")}catch{}}function bK(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(FI)==="1"}catch{return!1}}function kK(e){if(!(typeof window>"u"))try{window.localStorage.setItem(FI,e?"1":"0")}catch{}}function NK(){const e=ks(qI);return e===null?!0:e==="1"}function _K(e){if(!(typeof window>"u"))try{window.localStorage.setItem(qI,e?"1":"0")}catch{}}function SK(){const e=ks(BI);return e===null?!0:e==="1"}function jK(e){if(!(typeof window>"u"))try{window.localStorage.setItem(BI,e?"1":"0")}catch{}}function EK(){if(typeof window>"u")return{positions:[],pins:[]};try{return NG(window.localStorage.getItem(yb))}catch{return{positions:[],pins:[]}}}function Hd(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(yb,_G(e,t))}catch{}}function CK(){if(typeof window>"u")return null;try{return SG(window.localStorage.getItem(wb))}catch{return null}}function TK(e){if(!(typeof window>"u"))try{window.localStorage.setItem(wb,JSON.stringify(e))}catch{}}function AK(){if(typeof window>"u")return null;try{return jG(window.localStorage.getItem(vb))}catch{return null}}function RK(e){if(!(typeof window>"u"))try{window.localStorage.setItem(vb,JSON.stringify(e))}catch{}}function E2(){if(!(typeof window>"u")){try{window.localStorage.removeItem(yb)}catch{}try{window.localStorage.removeItem(vb)}catch{}try{window.localStorage.removeItem(wb)}catch{}}}function MK(e,t){const n=I7(e,t,new Date().toISOString());if(!n)return;const r=JSON.stringify(n,null,2),a=new Blob([r],{type:"application/json"}),l=URL.createObjectURL(a),c=document.createElement("a");c.href=l,c.download=$7(n.label,t),document.body.appendChild(c),c.click(),document.body.removeChild(c),setTimeout(()=>URL.revokeObjectURL(l),1e3)}const zI={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},IK={file:"M3.4 1.8h4.5l2.7 2.7v7.7H3.4z M7.9 1.8v2.7h2.7",shell:"M2.4 3.8 5.6 7l-3.2 3.2 M7.4 10.6h4.2",web:"M7 1.8a5.2 5.2 0 1 0 0 10.4A5.2 5.2 0 1 0 7 1.8z M1.8 7h10.4 M7 1.8c-1.5 1.4-2.3 3.1-2.3 5.2s.8 3.8 2.3 5.2c1.5-1.4 2.3-3.1 2.3-5.2S8.5 3.2 7 1.8z",agent:"M3.3 4.8h7.4a1.2 1.2 0 0 1 1.2 1.2v4.8a1.2 1.2 0 0 1-1.2 1.2H3.3a1.2 1.2 0 0 1-1.2-1.2V6a1.2 1.2 0 0 1 1.2-1.2z M7 4.8V2.4 M5.3 8.2h.01 M8.7 8.2h.01",task:"M2.2 4l1.2 1.2 2-2.2 M7.4 4.2h4.4 M2.2 9.4l1.2 1.2 2-2.2 M7.4 9.6h4.4",plan:"M7 1.8a5.2 5.2 0 1 0 0 10.4A5.2 5.2 0 1 0 7 1.8z M9 5 8 8 5 9l1-3z",mcp:"M5 1.8v2.6 M9 1.8v2.6 M3.6 4.4h6.8v2.2a3.4 3.4 0 0 1-6.8 0z M7 10v2.2",other:"M3.5 7h.01 M7 7h.01 M10.5 7h.01"};function $K({cat:e}){return o.jsx("svg",{className:"cat-glyph",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:o.jsx("path",{d:IK[e]})})}const bh={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},HI=bR;function OK(){return o.jsx(T0,{children:o.jsx(DK,{})})}const LK=e=>e.transform[2]>=e.maxZoom,PK=e=>e.transform[2]<=e.minZoom;function DK(){var Ru,Mu,mi,Fr;const e=Th(),t=mt(LK),n=mt(PK),r=Gt(),a=x.useState(Bx)[0],l=x.useRef(a),[,c]=x.useState(0),u=x.useCallback(()=>c(D=>D+1),[]),[f,p]=x.useState(bK);x.useEffect(()=>{kK(f)},[f]);const[h,m]=x.useState(()=>new Set),[y,w]=x.useState(null),[j,k]=x.useState(null),S=x.useCallback((D,P,re=!P)=>{m(oe=>{if(!P)return new Set([D]);const we=new Set(oe);return we.has(D)?we.delete(D):we.add(D),we}),w(oe=>P&&oe===D?oe:D),!P&&re&&p(!0)},[]),b=x.useCallback(()=>{m(new Set),w(null)},[]),[N,E]=x.useState(null),[C,T]=x.useState(null),A=x.useCallback(D=>T(D),[]),[I,B]=x.useState(!1),[q,L]=x.useState(!1),[U,X]=x.useState(!1),Y=x.useRef(null),[M,J]=x.useState(vK);x.useEffect(()=>{xK(M)},[M]);const[V,$]=x.useState(NK);x.useEffect(()=>{_K(V)},[V]);const[z,W]=x.useState(SK);x.useEffect(()=>{jK(z)},[z]);const G=x.useRef(!1),[F,K]=x.useState(()=>{const D=(()=>{try{const P=window.localStorage.getItem(_2);return P===null?!0:P==="1"}catch{return!0}})();return D&&M?(G.current=!0,!1):D});x.useEffect(()=>{if(!(!F&&G.current))try{window.localStorage.setItem(_2,F?"1":"0")}catch{}},[F]),x.useEffect(()=>{!M&&G.current&&(G.current=!1,K(!0))},[M]);const de=Fp(F,200),H=Fp(V,130),Q=Fp(z,130),[O,te]=x.useState(null);x.useEffect(()=>{let D=null;try{D=localStorage.getItem("agent-dag.sound")}catch{}te(D===null?!0:D==="on")},[]);const ae=x.useCallback(()=>{te(D=>{var re;const P=D!==!0;try{localStorage.setItem("agent-dag.sound",P?"on":"off")}catch{}return P&&((re=Ie.current)==null||re.unlock()),P})},[]),he=x.useCallback(D=>{ae()},[ae]),ge=x.useRef(he);ge.current=he;const Te=x.useRef(O);Te.current=O;const[De,Ve]=x.useState(()=>e9(ks)),je=x.useRef(De);je.current=De;const ve=x.useRef(null),Ue=x.useCallback((D,P=!1)=>{var re,oe;if((re=Ie.current)==null||re.unlock(),ve.current!==null&&clearTimeout(ve.current),ve.current=null,!P){(oe=Ie.current)==null||oe.play(D,!0);return}ve.current=setTimeout(()=>{var we;ve.current=null,(we=Ie.current)==null||we.play(D,!0)},Y7)},[]),ke=x.useCallback((D,P)=>{Ve(re=>{const oe={level:Wc(P.level??re[D].level),figure:oI(D,P.figure??re[D].figure)};try{localStorage.setItem(lI[D],String(oe.level)),localStorage.setItem(cI[D],oe.figure)}catch{}return{...re,[D]:oe}}),Ue(D,!0)},[Ue]);x.useEffect(()=>()=>{ve.current!==null&&clearTimeout(ve.current)},[]);const[xe,Ge]=x.useState(!1),rt=x.useRef(null),[at,le]=x.useState(!1),_e=x.useRef(null);x.useEffect(()=>{xe&&le(!1)},[xe]);const Ie=x.useRef(null),[Ze,We]=x.useState("locked");x.useEffect(()=>{const D=n9({enabled:()=>Te.current===!0,prefs:()=>je.current,onState:We});Ie.current=D,We(D.state());const P=()=>D.unlock();return window.addEventListener("pointerdown",P,{once:!0,capture:!0}),window.addEventListener("keydown",P,{once:!0,capture:!0}),()=>{window.removeEventListener("pointerdown",P,{capture:!0}),window.removeEventListener("keydown",P,{capture:!0})}},[]);const[Je,ye]=x.useState(!1),[Me,Qe]=x.useState(!1),[ue,kt]=x.useState(null),[pt,ut]=x.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(Nx)??""}catch{return""}}),[Bt,jt]=x.useState(!1),vt=x.useRef(0),[an,jn]=x.useState(!1),Nt=x.useCallback((D=!1)=>(D&&(vt.current=Date.now(),jn(!0)),fetch(D?"/api/version?refresh=1":"/api/version").then(P=>P.ok?P.json():null).then(P=>{P&&kt(P)}).catch(()=>{}).finally(()=>{D&&jn(!1)})),[]),Yt=x.useCallback(()=>{Nt(Date.now()-vt.current>=wK)},[Nt]);x.useEffect(()=>{Nt();const D=window.setInterval(Yt,5*6e4),P=()=>{document.visibilityState==="visible"&&Yt()};return document.addEventListener("visibilitychange",P),()=>{window.clearInterval(D),document.removeEventListener("visibilitychange",P)}},[Nt,Yt]),x.useEffect(()=>{Je&&Nt()},[Je,Nt]),x.useEffect(()=>{const D=NV();let P=null;const re=Le=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:D,looking:Le}),keepalive:!0}).catch(()=>{})},oe=()=>{const Le=bV(document);kV(P,Le)&&re(Le),P=Le},we=()=>{P&&re(!1),P=!1};oe();const Ce=window.setInterval(oe,xV);return window.addEventListener("focus",oe),window.addEventListener("blur",oe),document.addEventListener("visibilitychange",oe),window.addEventListener("pagehide",we),()=>{window.clearInterval(Ce),window.removeEventListener("focus",oe),window.removeEventListener("blur",oe),document.removeEventListener("visibilitychange",oe),window.removeEventListener("pagehide",we),we()}},[]);const fe=(ue==null?void 0:ue.notice)??null,[st,It]=x.useState(null),Et=x.useRef(!1),[En,Gn]=x.useState(null);x.useEffect(()=>{fetch("/api/prefs").then(D=>D.ok?D.json():null).then(D=>{var P;return Gn(typeof((P=D==null?void 0:D.prefs)==null?void 0:P.tourSeen)=="boolean"?D.prefs.tourSeen:!1)}).catch(()=>Gn(!1))},[]),x.useEffect(()=>{if(Et.current||En===null)return;const D=h2(),P=MV(D),re=DV({stored:P,running:(ue==null?void 0:ue.running)??null,notes:d2,remembers:IV(D)});if(re.reason==="no-version")return;if(Et.current=!0,re.record&&$V(D,re.record),En)try{D==null||D.setItem("agent-dag.tourSeen","1")}catch{}const oe=PV({tourSeen:OV(D),decision:re}),we=re.show.length?{entries:re.show,since:P,firstRun:!1}:null;oe.tour&&X(!0),oe.notes==="now"?It(we):oe.notes==="after"&&(Y.current=we)},[En,ue==null?void 0:ue.running]);const St=(ue==null?void 0:ue.running)??"3.27.7",lr=x.useMemo(()=>bI(d2,null,St),[St]),yn=x.useCallback(()=>{It({entries:lr,since:null,firstRun:!1})},[lr]),[Xt,Cn]=x.useState(null),[zt,In]=x.useState(u0);x.useEffect(()=>{let D=!1;return fetch("/api/health").then(P=>P.ok?P.json():null).then(P=>{D||(In(JG(P)),!(!P||typeof P.workspace!="string")&&Cn(P.workspace))}).catch(()=>{}),()=>{D=!0}},[Je]);const Kn=x.useRef(zt);Kn.current=zt;const cr=OI(fe),$n=ZG(fe,pt),ea=x.useCallback(()=>{ut("");try{window.localStorage.setItem(Nx,"")}catch{}},[]),ta=x.useCallback(()=>{if(fe){ut(cr);try{window.localStorage.setItem(Nx,cr)}catch{}}},[fe,cr]),[_s,On]=x.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(S2)??""}catch{return""}}),wn=ue!=null&&ue.invokedAs&&ue.invokedAs!==nn?ue.invokedAs:null,ee=wn!=null&&_s!==wn,Ae=x.useCallback(()=>{if(wn){On(wn);try{window.localStorage.setItem(S2,wn)}catch{}}},[wn]),Oe=((Ru=ue==null?void 0:ue.upgrade)==null?void 0:Ru.state)??"idle",Re=Pz(ue==null?void 0:ue.upgrade),ze=x.useRef(!1),dt=x.useCallback(async()=>{if(Ks(ze.current||Oe==="running")){ze.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await Nt(),ze.current=!1}},[Oe,Nt]);x.useEffect(()=>{if(Oe!=="running")return;const D=window.setInterval(Nt,3e3);return()=>window.clearInterval(D)},[Oe,Nt]);const yt=x.useCallback(async()=>{const D=ue==null?void 0:ue.command;!D||!await sl(D)||(jt(!0),window.setTimeout(()=>jt(!1),1600))},[ue==null?void 0:ue.command]),Ct=x.useCallback(()=>{J(D=>(D||K(P=>(P&&(G.current=!0),!1)),!D))},[]),gt=x.useCallback(()=>{G.current=!1,K(D=>(D||J(!1),!D))},[]),[xt,Ar]=x.useState(!1),[Ss,ns]=x.useState(!1),[Ba,Wo]=x.useState(()=>{try{return Number(localStorage.getItem(f2))||0}catch{return 0}}),[js,Ln]=x.useState([]),[Es,Pn]=x.useState(!1);x.useEffect(()=>{let D=!0;const P=()=>{fetch("/api/browser-watch?live=0").then(oe=>oe.ok?oe.json():null).then(oe=>{var we;!D||!(oe!=null&&oe.ok)||(Ln(oe.episodes??[]),Pn(((we=oe.settings)==null?void 0:we.enabled)===!0))}).catch(()=>{})};P();const re=setInterval(P,5*6e4);return()=>{D=!1,clearInterval(re)}},[]);const[rf,Vo]=x.useState([]),su=x.useRef(new Set),[Cs,za]=x.useState(null);x.useEffect(()=>{let D=!0,P=0;const re=()=>{fetch("/api/lan").then(oe=>oe.ok?oe.json():null).then(oe=>D?(oe!=null&&oe.ok&&Vo(y_(Array.isArray(oe.pending)?oe.pending:[],oe.aliases)),oe):null).catch(()=>null).then(oe=>{D&&(P=window.setTimeout(re,(oe==null?void 0:oe.enabled)===!0?e0:QR))})};return re(),()=>{D=!1,window.clearTimeout(P)}},[]);const na=x.useCallback(async(D,P)=>{if(!Cs){za(D);try{const oe=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:D,fp:P})})).json().catch(()=>null);oe&&Array.isArray(oe.pending)?Vo(y_(oe.pending,oe.aliases)):Vo(we=>we.filter(Ce=>Ce.fp!==P))}catch{}finally{za(null)}}},[Cs]),rs=x.useMemo(()=>hG(js,Ba).length,[js,Ba]),[sf,au]=x.useState(0),Go=x.useRef(null),[ou,Ko]=x.useState(!1),Rr=x.useRef(null),[af,Yo]=x.useState(0),nt=x.useState(()=>JV({protect:D=>aD(l.current,D)}))[0],[Ha,iu]=x.useState(!1),Ua=x.useCallback(()=>{const D=nt.paused&&nt.dropped>0,P=nt.setPaused(!nt.paused);D&&oD(l.current);for(const re of P)l.current=lN(l.current,re);iu(nt.paused)},[nt]),[Wt,lu]=x.useState(Date.now()),[Mr,ra]=x.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(zd)!=="0"}catch{return!0}}),Wa=x.useRef(!1),ss=x.useCallback(()=>{const D=!Mr;Wa.current=!0;try{window.localStorage.removeItem(zd)}catch{}ra(D),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:D})}).then(P=>P.ok?P.json():null).then(P=>{var re;P!=null&&P.ok&&ra(((re=P.prefs)==null?void 0:re.autoUpdate)!==!1)}).catch(()=>{})},[Mr]),[hn,Yn]=x.useState(!1),[Va,Ga]=x.useState("restart"),[Ir,cu]=x.useState(null),Ts=x.useRef(!1),sa=x.useRef(null),uu=x.useRef(0),aa=x.useCallback(async D=>{if(!Ks(Ts.current))return;const P=(D==null?void 0:D.upgrade)===!0;Ts.current=!0,sa.current=Re;const re=++uu.current;Ga(P?"npx":"restart"),Yn(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(fe==null?void 0:fe.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:P})})}catch{}window.setTimeout(()=>{if(uu.current===re&&Ts.current){Ts.current=!1,Yn(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},P?18e4:3e4)},[fe==null?void 0:fe.to,Re]),oa=x.useRef(null);x.useEffect(()=>{const D=N_(l.current.agents.values())>0,P=zz({enabled:Mr,kind:fe==null?void 0:fe.kind,canRestart:(ue==null?void 0:ue.canRestart)===!0,noticeOpen:$n,visible:document.visibilityState==="visible",busy:D,idleSince:oa.current,now:Wt});oa.current=P.idleSince,P.restart&&aa()},[Mr,fe==null?void 0:fe.kind,ue==null?void 0:ue.canRestart,$n,Wt,aa]);const yl=N_(l.current.agents.values()),du=Bz(yl),ia=nM({enabled:Mr,kind:fe==null?void 0:fe.kind,canRestart:(ue==null?void 0:ue.canRestart)===!0,noticeOpen:$n,visible:document.visibilityState==="visible",busy:yl>0,idleSince:oa.current,now:Wt});x.useEffect(()=>{const D=ue==null?void 0:ue.running;let P=null,re=null;try{P=window.sessionStorage.getItem("agent-dag.restartPending"),re=window.sessionStorage.getItem(j2)}catch{return}const oe=Lz({bundle:"3.27.7",running:D,pending:P,lastTried:re});if(oe==="reload"){try{window.sessionStorage.setItem(j2,D??"")}catch{return}window.location.reload();return}if(oe!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}Ts.current=!1,Yn(!1),cu(D??null);const we=window.setTimeout(()=>cu(null),6e3);return()=>window.clearTimeout(we)},[ue==null?void 0:ue.running]),x.useEffect(()=>{if(hn&&Dz({asked:sa.current,reported:Re})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}Ts.current=!1,Yn(!1)}},[hn,Re]);const la=x.useState(()=>kG(EK()))[0],Tt=x.useRef(la.pinned),As=x.useRef(null),Xo=x.useState(()=>AK())[0],[wl,vl]=x.useState(()=>new Set),[$r,Zo]=x.useState(nG),[ca,as]=x.useState(f9),[ua,Qo]=x.useState(m9),[Ka,Jo]=x.useState(d9),[Or,hu]=x.useState(()=>p2(b2)),vn=x.useMemo(()=>xG(Or),[Or]),da=x.useCallback(D=>vG(D,vn),[vn]),[ei,Ya]=x.useState(!1);x.useEffect(()=>{document.documentElement.dataset.theme=$r;try{window.localStorage.setItem(SI,$r)}catch{}hu(D=>{const P=p2(b2);return bG(D,P)?D:P})},[$r]),x.useEffect(()=>{try{window.localStorage.setItem(uI,ca?"1":"0")}catch{}},[ca]),x.useEffect(()=>{try{window.localStorage.setItem(dI,String(ua))}catch{}},[ua]),x.useEffect(()=>{try{window.localStorage.setItem(hI,Ka)}catch{}},[Ka]);const Xn=x.useCallback((D,P)=>{if(qd({durationMs:P,documentHidden:document.hidden})){e.setViewport(D,{duration:P});return}const{d3Zoom:re,d3Selection:oe}=r.getState(),we=oe==null?void 0:oe.property("__zoom");if(re&&oe&&we&&we.k>0&&D.zoom>0){re.transform(oe,we.scale(D.zoom/we.k).translate((D.x-we.x)/D.zoom,(D.y-we.y)/D.zoom));return}e.setViewport(D,{duration:0})},[e,r]),os=x.useRef(null),Rs=x.useRef(0),is=x.useRef(null),Xa=x.useRef(()=>{});x.useEffect(()=>{if(!Xo)return;const D=window.setTimeout(()=>{try{Xn(Xo,0)}catch{}Lr.current=Date.now()},60);return()=>window.clearTimeout(D)},[Xn,Xo]);const xl=x.useRef(!0),[Za,fu]=x.useState(null);x.useEffect(()=>{const D=new EventSource("/events"),P=ZV(u,{now:()=>Date.now(),setTimeout:(Ce,Le)=>window.setTimeout(Ce,Le),clearTimeout:Ce=>window.clearTimeout(Ce)});let re=!1;const oe=typeof BroadcastChannel=="function"?oG(new BroadcastChannel(sG),Math.random().toString(36).slice(2),()=>re):null,we=window.setInterval(()=>{re||!oe||oe.ask(600).then(Ce=>{re||Qe(aG(Ce))})},3e3);return D.addEventListener("open",()=>{ye(!0),Ya(!0)}),D.addEventListener("error",()=>{ye(!1),fu(null)}),D.addEventListener("open",()=>{re=!0,Qe(!1)}),D.addEventListener("error",()=>{re=!1}),D.addEventListener("replay-end",()=>{xl.current=!1,P.flush(),fu(Date.now())}),D.addEventListener("hook",Ce=>{var Le;try{const et=JSON.parse(Ce.data);if(!nt.accept(et))return;l.current=lN(l.current,et);const ct=et.replay===!0||xl.current||Date.now()-et.receivedAt>3e4;ct?P.replay():P.live();const Ke=t9(et,ct);Ke&&((Le=Ie.current)==null||Le.play(Ke))}catch{}}),()=>{D.close(),P.cancel(),window.clearInterval(we),oe==null||oe.leave()}},[u]),x.useEffect(()=>{const D=setInterval(()=>{const P=Date.now();lu(P);const{changed:re,forgotten:oe}=j7(l.current,P);oe.length>0&&fetch("/api/forget",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:oe})}).catch(()=>{}),m(we=>N7(we,l.current.agents)),w(we=>we!=null&&!l.current.agents.has(we)?null:we),T(we=>we!=null&&!l.current.agents.has(we)?null:we),E(we=>we!=null&&!l.current.agents.has(we)?null:we),re&&u()},250);return()=>clearInterval(D)},[u]);const bl=x.useRef(null),Lr=x.useRef(0),pu=420,Dn=x.useCallback((D=500)=>{const P=xx,re=1,oe=.2,we=bx;try{const Ce=document.querySelector(".canvas-wrap"),Le=Array.from(document.querySelectorAll(".react-flow__node")).filter(At=>At.offsetWidth>0);if(!Ce||Le.length===0)return;const et=Ce.getBoundingClientRect(),ct=e.getViewport();if(!Number.isFinite(ct.zoom)||ct.zoom<=0)return;const Ke=At=>(At-et.left-ct.x)/ct.zoom,Pt=At=>(At-et.top-ct.y)/ct.zoom,Dt=Le.map(At=>At.getBoundingClientRect()),qr=Math.min(...Dt.map(At=>Ke(At.left))),hr=Math.max(...Dt.map(At=>Ke(At.right))),Jn=Math.min(...Dt.map(At=>Pt(At.top))),_t=Math.max(...Dt.map(At=>Pt(At.bottom))),wt=hr-qr,fr=_t-Jn;if(!(wt>0&&fr>0))return;const on=k2(Ce),fn=At=>Math.max(oe,Math.min(re,(et.width-on-P*2)/(wt+At)*we,(et.height-P*2)/fr*we)),er=PG(fn(pu),fn(0)),pr={x:P-qr*er,y:Math.max(P,(et.height-fr*er)/2)-Jn*er,zoom:er},bn=++Rs.current;Xn(pr,D),Lr.current=Date.now(),os.current=qd({durationMs:D,documentHidden:document.hidden})?{target:pr,until:Date.now()+D+60}:null,window.setTimeout(()=>{var At;try{if(((At=os.current)==null?void 0:At.target)===pr&&(os.current=null),Rs.current!==bn)return;const Gl=e.getViewport();(Math.abs(Gl.zoom-er)>.01||Math.abs(Gl.x-pr.x)>2)&&Xn(pr,0)}catch{}},D+60)}catch{}},[e,Xn]);x.useEffect(()=>{const D=()=>{if(!document.hidden)return;const P=os.current;if(os.current=null,!(!P||Date.now()>P.until)){try{Xn(P.target,0)}catch{}Lr.current=Date.now()}};return document.addEventListener("visibilitychange",D),()=>document.removeEventListener("visibilitychange",D)},[Xn]);const kl=x.useRef(""),Nl=x.useRef(null),mu=x.useRef(0),Qa=x.useCallback(()=>{mu.current=Date.now()},[]),_l=x.useRef(null),gu=x.useRef(0),Sl=x.useCallback(()=>{gu.current=Date.now()},[]),jl=x.useCallback(D=>({hasSourceEvent:!!D,at:Date.now(),lastDeckFitAt:Lr.current,lastCanvasInputAt:gu.current}),[]),El="agent-dag.autoFitDisabled",Ms=x.useRef(!1),[Cl,yu]=x.useState(!1);x.useEffect(()=>{try{window.localStorage.removeItem(El)}catch{}},[]);const ha=x.useCallback(()=>{Ms.current||(Ms.current=!0,yu(!0))},[]),wu=x.useCallback(()=>{Ms.current=!1,yu(!1),Dn(400)},[e,Dn]);x.useEffect(()=>{const D=setInterval(()=>{if(Ms.current||Date.now()-mu.current<800)return;const P=l.current,re=Date.now(),oe=[];for(const Ce of P.agents.values())i0(Ce,re)&&oe.push({id:Ce.id});if(oe.length===0)return;const we=[];for(const{id:Ce}of oe){const Le=Pr.current.get(Ce),et=Tt.current.get(Ce)??$t.current.get(Ce);!Le||!et||we.push({x:et.x,y:et.y,width:Le.width,height:Le.height})}RG({pane:_l.current,viewport:e.getViewport(),boxes:we})&&Dn(600)},1500);return()=>clearInterval(D)},[e]);const ti=x.useRef(!1),Pr=x.useRef(new Map),Tl=x.useRef(0),of=x.useCallback(D=>{const P=Pr.current;let re=!1;for(const oe of D.nodeInternals.values()){const we=oe.width,Ce=oe.height;if(we==null||Ce==null)continue;const Le=P.get(oe.id);Le?(Math.abs(Le.height-Ce)>4||Math.abs(Le.width-we)>4)&&(P.set(oe.id,{width:we,height:Ce}),re=!0):(P.set(oe.id,{width:we,height:Ce}),re=!0)}return re&&(Tl.current+=1),Tl.current},[]),vu=mt(of),[xu,Al]=x.useState(0);x.useEffect(()=>{let D=0;const P=()=>{const oe=Pr.current;let we=!1;for(const Ce of document.querySelectorAll(".react-flow__node[data-id]")){const Le=Ce.getAttribute("data-id");if(!Le)continue;const et=Ce.offsetWidth,ct=Ce.offsetHeight;if(!et||!ct)continue;const Ke=oe.get(Le);(!Ke||Math.abs(Ke.width-et)>4||Math.abs(Ke.height-ct)>4)&&(oe.set(Le,{width:et,height:ct}),we=!0)}we&&Al(Ce=>Ce+1)};if(ti.current)return;let re=0;return document.visibilityState==="hidden"?re=window.setTimeout(P,32):D=requestAnimationFrame(P),()=>{cancelAnimationFrame(D),window.clearTimeout(re)}});const $t=x.useRef(la.positions),bu=x.useRef(new Set),Ja=x.useRef(""),Is=x.useMemo(()=>{const D=[];for(const P of l.current.agents.values())i0(P,Wt)&&D.push(P.id+(P.parentId?`>${P.parentId}`:""));return D.sort(),`${D.join("|")}#sv${vu}.${xu}`},[l.current,l.current.revision,Wt,vu,xu]),fa=x.useRef(null);x.useEffect(()=>(fa.current!=null&&window.clearTimeout(fa.current),fa.current=window.setTimeout(()=>{Hd($t.current,Tt.current)},1500),()=>{fa.current!=null&&window.clearTimeout(fa.current)}),[Is]),x.useEffect(()=>{if(kl.current===Is)return;const D=kl.current;if(kl.current=Is,!D||Ms.current)return;Date.now()-Lr.current>1200&&Dn(400),bl.current&&window.clearTimeout(bl.current),bl.current=window.setTimeout(()=>{Ms.current||Dn(500)},280)},[Is,e,Dn]);const ni=x.useMemo(()=>KV(l.current,h),[l.current,l.current.revision,h]),ri=x.useMemo(()=>gG(l.current,Wt),[l.current,l.current.revision,Wt]),Fn=x.useRef(null),[eo,ku]=x.useState({w:0,h:0});x.useEffect(()=>{const D=Fn.current;if(!D||typeof ResizeObserver>"u")return;const P=new ResizeObserver(re=>{var we;const oe=(we=re[0])==null?void 0:we.contentRect;oe&&(_l.current={width:oe.width,height:oe.height},ku(Ce=>Math.abs(Ce.w-oe.width)>40||Math.abs(Ce.h-oe.height)>40?{w:oe.width,h:oe.height}:Ce))});return P.observe(D),_l.current={width:D.clientWidth,height:D.clientHeight},ku({w:D.clientWidth,h:D.clientHeight}),()=>P.disconnect()},[]);const lf=x.useCallback(D=>{var re,oe;const P=D.target;!(P!=null&&P.closest)||P.closest(gK)!==D.currentTarget||(D.preventDefault(),(oe=(re=document.activeElement)==null?void 0:re.blur)==null||oe.call(re))},[]),Nu=x.useRef(new Map),[to,no]=x.useState(!1);x.useEffect(()=>{const D=window.setTimeout(()=>no(!0),2500);return()=>window.clearTimeout(D)},[]);const[ro,Rl]=x.useState(!1),Zn=x.useRef(null),[so,Ml]=x.useState(!1),[Il,$l]=x.useState("detail"),ls=x.useRef(null),si=x.useRef(null),_u=x.useCallback(()=>{var oe;const D=Tl.current;if(((oe=si.current)==null?void 0:oe.version)===D)return si.current.card;const P=[];for(const we of l.current.agents.keys()){const Ce=Pr.current.get(we);Ce&&P.push(Ce)}const re=IG(P);return si.current={version:D,card:re},re},[]),cf=x.useCallback(()=>{Zn.current&&(window.clearTimeout(Zn.current),Zn.current=null),Rl(!1)},[]),uf=x.useCallback(D=>{D.length!==0&&queueMicrotask(()=>{Rl(!0),Zn.current&&window.clearTimeout(Zn.current),Zn.current=window.setTimeout(()=>Rl(!1),yK+80)})},[]);x.useEffect(()=>()=>{Zn.current&&window.clearTimeout(Zn.current)},[]);const xn=y?l.current.agents.get(y):null,Su=f&&xn!=null,[Ol,Qn]=x.useState(0);x.useEffect(()=>{const D=k2(Fn.current);Qn(P=>Math.abs(P-D)>40?D:P)},[Q,H,V,Su,eo.w]);const $s=x.useRef(Ol);$s.current=Ol;const ao=eo.w>0?Math.max(0,(eo.w-Ol-xx*2)*bx):0,oo=eo.h>0?Math.max(0,(eo.h-xx*2)*bx):0,ju=m6(),{nodes:Dr,edges:ai}=x.useMemo(()=>A7(l.current,Wt,ao,oo,Tt.current,Pr.current,Nu.current,uf,to,so,$t.current,bu.current,Is,Ja,h,ni,ri,A),[l.current,l.current.revision,Wt,ao,oo,to,so,Is,h,ni,ri,A,sf,ju]),df=x.useState(CK)[0],Eu=x.useRef(df);x.useEffect(()=>{if(!to||so)return;const D={width:ao,height:oo};if(!(D.width>0&&D.height>0))return;const P=Eu.current;if(Eu.current=D,TK(D),!P||P.width===D.width&&P.height===D.height)return;const re={direction:"LR",pinned:Tt.current,measured:Pr.current,lanes:n0(l.current)};if(!d7(Dr,ai,re,P,D))return;const oe=is.current&&Date.now()-is.current.at<1500?is.current.id:null,we=oe??hs.current,Ce=we?Tt.current.get(we)??$t.current.get(we):void 0;for(const Le of Array.from($t.current.keys()))Tt.current.has(Le)||$t.current.delete(Le);bu.current.clear(),Ja.current="",u(),window.setTimeout(()=>{if(Hd($t.current,Tt.current),Ms.current){if(oe){Xa.current(oe);return}const Le=we?Tt.current.get(we)??$t.current.get(we):void 0;if(Ce&&Le&&(Le.x!==Ce.x||Le.y!==Ce.y)){const et=e.getViewport();Rs.current+=1,Xn({x:et.x-(Le.x-Ce.x)*et.zoom,y:et.y-(Le.y-Ce.y)*et.zoom,zoom:et.zoom},0),Lr.current=Date.now()}return}Dn(500)},80)},[ao,oo,to,so,u,Dn,e,Xn]);const Os=x.useMemo(()=>{const D=new Map;for(const re of Dr){const oe=re.data;if(!(oe!=null&&oe.sessionId)||oe.exitAt!=null)continue;const we=re.width,Ce=re.height;if(we==null||Ce==null)continue;const Le=re.position.x,et=re.position.y,ct=Le+we,Ke=et+Ce,Pt=D.get(oe.sessionId);Pt?(Pt.minX=Math.min(Pt.minX,Le),Pt.minY=Math.min(Pt.minY,et),Pt.maxX=Math.max(Pt.maxX,ct),Pt.maxY=Math.max(Pt.maxY,Ke)):D.set(oe.sessionId,{minX:Le,minY:et,maxX:ct,maxY:Ke})}const P=[];for(const[re,oe]of D){const we=oe.maxX-oe.minX+Bd*2,Ce=oe.maxY-oe.minY+Bd*2;P.push({id:`group:${re}`,type:jI,position:{x:oe.minX-Bd,y:oe.minY-Bd},data:{sessionId:re,w:we,h:Ce},width:we,height:Ce,style:{width:we,height:Ce},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return P},[Dr]),Ll=x.useMemo(()=>{const D=[...Os,...Dr],P=Rr.current;return!P||P.size===0?D:D.map(re=>{const oe=P.get(re.id);return oe?{...re,position:oe}:re})},[Os,Dr,af]),cs=x.useMemo(()=>{const D=new Set;for(const P of l.current.agents.values())for(const re of P.tools)D.add(HI(re.name));return Object.keys(zI).filter(P=>D.has(P))},[l.current,l.current.revision]);x.useEffect(()=>{if(cs.length<=1){Ko(!1);return}let D=0;const P=()=>{const re=Go.current;if(re&&!document.hidden){const oe=re.getBoundingClientRect(),we=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Le=>Le.getBoundingClientRect()),Ce=wG(oe,we,8);Ko(Le=>Le===Ce?Le:Ce)}D=window.setTimeout(P,300)};return P(),()=>window.clearTimeout(D)},[cs.length]);const Pl=x.useCallback(D=>{vl(P=>{const re=new Set(P);return re.has(D)?re.delete(D):re.add(D),re})},[]),oi=j?Z5(l.current.agents,j):null,io=x.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}l.current=Bx(),Tt.current.clear(),Pr.current.clear(),$t.current.clear(),Ja.current="",E2(),b(),u()},[u,b]),Ls=x.useRef(I);Ls.current=I;const ii=x.useRef(q);ii.current=q;const li=x.useRef(!1);li.current=oi!=null||xt||C!=null||U||N!=null||Ss||q||st!=null;const Ps=x.useCallback(D=>{const P=O7(D,{confirmOpen:Ls.current,modalOpen:li.current});P==="confirm"?B(!0):P==="clear"&&(B(!1),io())},[io]),ci=x.useCallback(()=>{Tt.current.clear(),$t.current.clear(),Ja.current="",E2(),u(),window.setTimeout(()=>Dn(500),80)},[u,e,Dn]),Dl=x.useCallback(()=>Dn(500),[Dn]),us=x.useRef(Dr);us.current=Dr;const Tn=x.useCallback(D=>{var Pt;const P=Fn.current,re=l.current.agents.get(D);if(!P||!re)return;const oe=n0(l.current),we=(Dt,qr)=>{const hr=Pr.current.get(Dt.id);if(!hr)return null;const Jn=qr&&oe.has(Dt.id)?pu:0;return{x:Dt.position.x,y:Dt.position.y,width:hr.width+Jn,height:hr.height}},Ce=us.current.find(Dt=>Dt.id===D),Le=Ce?we(Ce,!1):null;if(!Le)return;const et=[];for(const Dt of us.current){if(Dt.type!=="agent"&&Dt.type!=="recapNote"||((Pt=Dt.data)==null?void 0:Pt.sessionId)!==re.sessionId)continue;const qr=we(Dt,Dt.type==="agent");qr&&et.push(qr)}const ct=P.getBoundingClientRect(),Ke=qG({pane:{width:ct.width,height:ct.height},insets:{top:56,left:72,bottom:32,right:$s.current+32},context:BG(et)??Le,anchor:Le});Ca(),ha(),is.current={id:D,at:Date.now()},Rs.current+=1,Xn(Ke,kx),Lr.current=Date.now(),os.current=qd({durationMs:kx,documentHidden:document.hidden})?{target:Ke,until:Date.now()+kx+60}:null},[Xn,ha]);Xa.current=Tn;const Cu=x.useCallback(D=>{const P=us.current.find(re=>re.id===D&&re.type==="agent");return P?P.data:void 0},[]),Tu=x.useCallback(D=>{var P;return(P=l.current.agents.get(D))==null?void 0:P.label},[]),ds=x.useCallback(D=>{var oe;const P=us.current.find(we=>we.id===D&&we.type==="recapNote");if(!P)return;const re=P.data;return{recap:re.recap,hue:re.hue,sessionLabel:(oe=l.current.agents.get(re.parentId))==null?void 0:oe.label}},[]),Fl=x.useCallback(()=>{var re;const D=(re=Fn.current)==null?void 0:re.getBoundingClientRect(),P=document.documentElement;return D?{width:D.right-$s.current,height:D.bottom}:{width:P.clientWidth,height:P.clientHeight}},[]),hs=x.useRef(y);hs.current=y;const ui=x.useCallback(D=>{const P=us.current.filter(Ce=>Ce.type==="agent"),re=zV(P.map(Ce=>({id:Ce.id,x:Ce.position.x,y:Ce.position.y})),hs.current,D),oe=re?P.find(Ce=>Ce.id===re):void 0;if(!oe)return;const we=vx(document.activeElement);S(oe.id,!1),window.setTimeout(()=>{try{Tn(oe.id)}catch{}we&&mK(oe.id)},30)},[S,Tn]),ql=x.useRef(null),ur=x.useCallback(D=>{S(D,!1),window.setTimeout(()=>{try{Tn(D)}catch{}},60)},[S,Tn]),Au=x.useRef(null);x.useEffect(()=>{let D=-1/0;const P=()=>{D=performance.now()},re=oe=>{Au.current=performance.now()-D<250?oe.target:null};return window.addEventListener("pointerdown",P,!0),window.addEventListener("focusin",re,!0),()=>{window.removeEventListener("pointerdown",P,!0),window.removeEventListener("focusin",re,!0)}},[]),x.useEffect(()=>{const D=P=>{var et,ct;const re=P.target,oe={tagName:re==null?void 0:re.tagName,isContentEditable:re==null?void 0:re.isContentEditable,role:(et=re==null?void 0:re.getAttribute)==null?void 0:et.call(re,"role"),type:re==null?void 0:re.type,pointerFocused:re!=null&&re===Au.current};if(P.key==="Escape"){const Ke=FD({overlayOpen:jc.depth()>0,typing:O0(oe)});Ke==="dismiss"?jc.dismissTop():Ke==="blur"?re==null||re.blur():(VV(oe)&&(re==null||re.blur()),b());return}if(Mh(P))return;const we=vx(re)?(ct=re==null?void 0:re.getAttribute)==null?void 0:ct.call(re,"data-id"):null,Ce=we&&us.current.some(Ke=>Ke.id===we)?we:null,Le=UV(P,Ce);if(Le.kind==="activate"){P.preventDefault(),S(Le.nodeId,Le.additive);return}if(Le.kind!=="node"&&!(Le.nodeId==null&&KD(oe,P.key))&&!YD({key:P.key,modalOpen:XD({appModal:li.current,dialogDepth:jc.dialogDepth()}),sheetOpen:ii.current})){if(P.key===" "&&(P.preventDefault(),Ua()),(P.key==="c"||P.key==="C")&&Ps("shortcut"),(P.key==="r"||P.key==="R")&&ci(),(P.key==="f"||P.key==="F")&&Dl(),(P.key==="z"||P.key==="Z")&&hs.current&&Tn(hs.current),(P.key==="l"||P.key==="L")&&Ct(),P.key==="d"||P.key==="D")if(hs.current)p(Ke=>!Ke);else{const Ke=Lp(l.current.agents.values());Ke.length>0?ur(Ke[0].id):ui(1)}if((P.key==="h"||P.key==="H")&&Ar(Ke=>!Ke),(P.key==="u"||P.key==="U")&&$(Ke=>!Ke),(P.key==="a"||P.key==="A")&&Kn.current.claude&>(),(P.key==="j"||P.key==="J")&&ui(1),(P.key==="k"||P.key==="K")&&ui(-1),P.key==="w"||P.key==="W"){const Ke=TD(Lp(l.current.agents.values()),ql.current);Ke&&(ql.current=Ke.id,ur(Ke.id))}(P.key==="t"||P.key==="T")&&Zo(Ke=>Ke==="dark"?"light":"dark"),(P.key==="m"||P.key==="M")&&Kn.current.claude&&Te.current!==null&&ge.current(P.shiftKey),(P.key==="s"||P.key==="S")&&W(Ke=>!Ke),(P.key==="b"||P.key==="B")&&ns(Ke=>!Ke),(P.key==="v"||P.key==="V")&&Kn.current.claude&&Te.current!==null&&Ge(Ke=>!Ke),P.key==="?"&&L(Ke=>!Ke)}};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[Ps,ci,Dl,b,S,ui,ur,Tn,Ua]);const Bl=l.current.agents.size,Zt=x.useMemo(()=>Lp(l.current.agents.values()),[l.current,l.current.revision]),bt=x.useMemo(()=>AD(l.current.agents.values()),[l.current,l.current.revision]),di=x.useRef(null);x.useEffect(()=>{const D=iG({waiting:Zt.length,running:bt,connected:Je}),P=di.current;if(di.current=D,(P==null?void 0:P.title)!==D.title&&(document.title=D.title),(P==null?void 0:P.icon)!==D.icon){const re=document.querySelector('link[rel="icon"]');re&&(re.href=lG[D.icon])}},[Zt.length,bt,Je]);const[hi,lo]=x.useState(""),zl=uG(Zt);x.useEffect(()=>{lo(D=>dG(D,zl))},[zl]);const[pa,co]=x.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[dr,fs]=x.useState(null),[uo,Hl]=x.useState(!1),[hf,Ul]=x.useState(!1);x.useEffect(()=>{let D=!0;return fetch("/api/prefs").then(P=>P.ok?P.json():null).then(P=>{var re,oe,we;if(!(!D||!(P!=null&&P.ok))){if(!Wa.current){let Ce=!1;try{Ce=window.localStorage.getItem(zd)==="0",window.localStorage.removeItem(zd)}catch{}Ce&&((re=P.prefs)==null?void 0:re.autoUpdate)!==!1?(ra(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):ra(((oe=P.prefs)==null?void 0:oe.autoUpdate)!==!1)}Hl(((we=P.prefs)==null?void 0:we.notifications)===!0),Ul(P.notificationsVetoed===!0)}}).catch(()=>{}),()=>{D=!1}},[]);const ho=x.useRef(()=>{}),fi=x.useCallback(()=>{const D=!uo;Hl(D),D&&typeof Notification<"u"&&Notification.permission==="default"&&ho.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:D})}).then(P=>P.ok?P.json():null).then(P=>{var re;P!=null&&P.ok&&(Hl(((re=P.prefs)==null?void 0:re.notifications)===!0),Ul(P.notificationsVetoed===!0))}).catch(()=>{})},[uo]),Wl=typeof Notification<"u";x.useEffect(()=>{if(!dr)return;const P=setTimeout(()=>fs(null),dr==="blocked"?8e3:4e3);return()=>clearTimeout(P)},[dr]);const pi=x.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(D=>{const P=D;co(P),P==="granted"?fs("on"):P==="denied"&&fs("blocked")})},[]);ho.current=pi;const Ds=x.useRef(new Set),fo=x.useRef(null),ff=Zt.map(D=>Rh(D.id,D.waiting)).join("|");x.useEffect(()=>{$D(fo.current,pa)&&(fo.current=pa,Ds.current=Pp(Zt))},[pa]);const Vl=x.useRef(!1);return x.useEffect(()=>{OD(Vl.current,Za)&&(Vl.current=!0,Ds.current=Pp(Zt))},[Za]),x.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!LD(fo.current,Za))return;const D=typeof document>"u"||!document.hidden,P=MD(Zt,Ds.current,D,uo);for(const re of P)try{const oe=new Notification(re.title,{body:re.body,tag:re.key});oe.onclick=()=>{window.focus(),ur(re.sessionId),oe.close()}}catch{}Ds.current=D?Pp(Zt):ID(Zt,P,Ds.current)},[ff,Za]),o.jsxs("div",{className:"app",children:[o.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),o.jsxs("header",{className:"topbar",children:[o.jsxs("div",{className:"readout",children:[o.jsxs("div",{className:"brand",children:[o.jsx("span",{className:"logo"}),o.jsx("h1",{children:nn}),fe?o.jsxs("button",{type:"button",className:"v stale",onClick:()=>{yn(),ea()},"aria-haspopup":"dialog","aria-label":XG({...fe,open:$n}),title:fe.kind==="restart"?`Running v${fe.from}; v${fe.to} is installed on disk. Restart to pick it up · click for what's new`:`Running v${fe.from}; v${fe.to} is on npm · click for what's new`,children:["v",fe.from,o.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const D={running:St,latest:ue==null?void 0:ue.latest,latestPending:ue==null?void 0:ue.latestPending,checkedAgo:ue!=null&&ue.checkedAt?Yd(Wt-ue.checkedAt):null,checkFailedAgo:ue!=null&&ue.checkFailedAt&&ue.checkFailedAt>(ue.checkedAt??0)?Yd(Wt-ue.checkFailedAt):null,checkDisabled:ue==null?void 0:ue.checkDisabled,checking:an};return o.jsxs("button",{type:"button",className:an?"v checking":"v",onClick:()=>{yn(),Nt(!0)},"aria-busy":an||void 0,"aria-haspopup":"dialog","aria-label":YG(D),title:KG(D),children:["v",D.running]})})()]}),o.jsx("span",{className:"status",children:(()=>{const D=uK({connected:Je,paused:Ha,held:nt.size,dropped:nt.dropped});return D.resting?null:o.jsx("span",{className:`pill ${D.tone}`,title:D.title,children:o.jsxs("span",{className:"pill-box",children:[o.jsx("span",{className:"pill-widest","aria-hidden":!0,children:D.widest}),o.jsx("span",{className:"pill-label",children:D.label})]})})})()}),o.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:hi}),Zt.length>0&&o.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>{ql.current=Zt[0].id,ur(Zt[0].id)},title:`Blocked waiting for you — click, or press W, to go to the one that has been stuck longest:
|
|
291
291
|
${Zt.map(D=>` ${D.label}: ${rl(D.waiting)} (${Yd(Wt-D.waiting.since)})`).join(`
|
|
292
292
|
`)}`,"aria-label":`${Zt.length} session${Zt.length===1?"":"s"} waiting for you`,children:[o.jsx("span",{className:"ap-pulse","aria-hidden":!0}),o.jsx("b",{children:Zt.length})," ",o.jsx("span",{className:"ws-word",children:"waiting"})]}),dr&&o.jsx("span",{className:dr==="on"?"notify-said":"notify-said notify-said-blocked",role:"status",title:dr==="on"?"The deck will raise a system notification when a session blocks on you and this tab is in the background":"Notifications are blocked for this page. Only your browser can undo that — its site settings for this address",children:dr==="on"?"notifications on":"notifications blocked"})]}),xn&&(()=>{const D=Vn(xn),P=Math.max(0,((xn.endedAt??Wt)-xn.startedAt)/1e3),re=xn.state==="active"?M0(D.total,P):null,oe=h.size-1;return o.jsxs("button",{type:"button",className:"selected-ribbon",title:`Zoom to ${xn.label} and its session (Z)`,onClick:()=>{try{Tn(xn.id)}catch{}},children:[o.jsx("span",{className:`state-pill state-${xn.state}`,children:xn.state==="active"?"live":xn.state}),o.jsx("span",{className:"selected-label",children:xn.label}),D.total>0&&o.jsxs("span",{className:"selected-cost",children:[lt(D.total),re?o.jsxs("span",{className:"selected-rate",children:[" · ",re]}):null]}),oe>0&&o.jsxs("span",{className:"selected-extra",children:["+",oe]}),o.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:we=>{we.stopPropagation(),b()},children:"×"})]})})(),o.jsxs("div",{className:"actions",children:[o.jsxs("div",{className:"action-run",children:[o.jsxs("button",{className:"btn icon-btn",onClick:Ct,title:`${M?"Hide":"Show"} session list (L)`,"aria-label":"Toggle session list","aria-expanded":M,"aria-controls":M?"session-list":void 0,children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M5.4 3.6h6.6M5.4 7h6.6M5.4 10.4h6.6"}),o.jsx("path",{d:"M2.2 3.6h.2M2.2 7h.2M2.2 10.4h.2"})]}),o.jsx("span",{className:"tb-word",children:"Session list"})]}),o.jsxs("button",{className:"btn icon-btn",onClick:()=>$(D=>!D),title:`${V?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel","aria-expanded":V,"aria-controls":V?"usage-panel":void 0,children:[o.jsxs("svg",{className:"tb-glyph-narrow",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M9.4 4.5C9 3.6 8.1 3.1 7 3.1c-1.4 0-2.4.8-2.4 1.9 0 1.2 1.2 1.6 2.4 2s2.4.8 2.4 2c0 1.1-1 1.9-2.4 1.9-1.1 0-2-.5-2.4-1.4"}),o.jsx("path",{d:"M7 1.6v1.5M7 10.9v1.5"})]}),o.jsx("span",{className:"tb-word",children:"Usage"})]}),o.jsxs("button",{className:"btn icon-btn",onClick:()=>Ar(D=>!D),title:"Usage history — ccusage (H)","aria-label":"Open usage history","aria-haspopup":"dialog",children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),o.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),o.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]}),o.jsx("span",{className:"tb-word",children:"History"})]})]}),o.jsxs("div",{className:"action-run",children:[zt.claude&&o.jsxs("button",{className:"btn icon-btn",onClick:gt,title:`${F?"Hide":"Show"} accounts (A)`,"aria-label":"Toggle accounts panel","aria-expanded":F,"aria-controls":F?"accounts-panel":void 0,children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),o.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]}),o.jsx("span",{className:"tb-word",children:"Accounts"})]}),o.jsxs("button",{className:"btn icon-btn",onClick:()=>W(D=>!D),title:`${z?"Hide":"Show"} this machine — cores, memory, temperature (S)`,"aria-label":"Toggle machine detail","aria-expanded":z,"aria-controls":z?"system-panel":void 0,children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("rect",{x:"3.6",y:"3.6",width:"6.8",height:"6.8",rx:"1.2"}),o.jsx("path",{d:"M5.8 1.4v2.2M8.2 1.4v2.2M5.8 10.4v2.2M8.2 10.4v2.2M1.4 5.8h2.2M1.4 8.2h2.2M10.4 5.8h2.2M10.4 8.2h2.2"})]}),o.jsx("span",{className:"tb-word",children:"Machine"})]}),o.jsxs("button",{className:"btn icon-btn bw-btn",onClick:()=>ns(D=>!D),title:Es?"Browser watch — watching; the deck is keeping its own copy (B)":"Browser watch — not watching; reading the browser's history live (B)","aria-label":`Browser watch, ${Es?"watching":"not watching"}`+(rs>0?`, ${rs} unread`:""),"aria-haspopup":"dialog",children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M0.9 7s2.2-4 6.1-4 6.1 4 6.1 4-2.2 4-6.1 4S0.9 7 0.9 7Z"}),Es||rs>0?o.jsx("circle",{cx:"7",cy:"7",r:"1.8",fill:"currentColor",stroke:"none"}):o.jsx("line",{x1:"2.4",y1:"11.6",x2:"11.6",y2:"2.4"})]}),o.jsx("span",{className:"tb-word",children:"Browser watch"}),rs>0&&o.jsx("span",{className:"bw-badge","aria-hidden":!0,children:rs})]})]}),o.jsxs("div",{className:"action-run action-run-utility",children:[zt.claude&&O!==null&&o.jsxs("div",{className:"sound-slot",children:[o.jsxs("button",{ref:rt,className:"btn icon-btn",onClick:()=>Ge(D=>!D),...Ma(!1),title:sK(zt,{on:O===!0,locked:Ze==="locked",prefs:De}),"aria-label":`Sound settings, ${O?"on":"off"}`,"aria-haspopup":"dialog","aria-expanded":xe,"aria-controls":xe?"sound-menu":void 0,children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),O?o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),o.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}):o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M10 5.6l2.6 2.8"}),o.jsx("path",{d:"M12.6 5.6L10 8.4"})]})]}),o.jsx("span",{className:"tb-word",children:"Sound"})]}),xe&&o.jsx(u9,{onClose:()=>Ge(!1),soundOn:O===!0,onToggleSound:ae,prefs:De,onLevel:(D,P)=>ke(D,{level:P}),onFigure:(D,P)=>ke(D,{figure:P}),onPreview:D=>Ue(D),notifyOn:uo,onToggleNotify:fi,notifyVetoed:hf,notifyPermission:Wl?pa:"unsupported",onAskNotify:pi,openerRef:rt})]}),o.jsxs("div",{className:"appearance-slot",children:[o.jsx("button",{ref:_e,className:"btn icon-btn",onClick:()=>{Ge(!1),le(D=>!D)},title:"Appearance settings","aria-label":`Appearance settings, ${$r} theme, character ${ca?"shown":"hidden"}`,"aria-haspopup":"dialog","aria-expanded":at,"aria-controls":at?"appearance-menu":void 0,children:$r==="dark"?o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("circle",{cx:"7",cy:"7",r:"2.5"}),o.jsx("path",{d:"M7 1.5v1.2M7 11.3v1.2M1.5 7h1.2M11.3 7h1.2M3.1 3.1l.85.85M10.05 10.05l.85.85M3.1 10.9l.85-.85M10.05 3.95l.85-.85"})]}):o.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:o.jsx("path",{d:"M11.8 8.4A5 5 0 1 1 5.6 2.2a4 4 0 0 0 6.2 6.2Z"})})}),at&&o.jsx(w9,{theme:$r,onTheme:Zo,characterEnabled:ca,onToggleCharacter:()=>as(D=>!D),fmVolume:ua,onFmVolume:Qo,fmSource:Ka,onFmSource:Jo,onClose:()=>le(!1)})]})]})]})]}),Ir?o.jsxs("div",{className:"ver-banner done",role:"status",children:[o.jsx("span",{className:"ver-dot"}),o.jsxs("strong",{children:["Restarted — now running v",Ir,"."]}),o.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):ei&&!Je?o.jsxs("div",{className:"conn-banner",role:"alert",children:[o.jsx("span",{className:"conn-dot"}),hn?Va==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${nn}…`:(()=>{const D=lK({connected:Je,paused:Ha});return o.jsxs(o.Fragment,{children:[`Lost connection to the ${nn} server. Reconnecting…`,D&&o.jsx("span",{className:"conn-sub",children:D})]})})()]}):$n&&fe?o.jsxs("div",{className:`ver-banner ${fe.kind}`,role:"status",children:[o.jsx("span",{className:`ver-dot${ia==null?"":" armed"}`}),fe.kind==="restart"?o.jsxs(o.Fragment,{children:[o.jsxs("strong",{children:["v",fe.to," is installed — this deck still runs v",fe.from,"."]}),ue!=null&&ue.canRestart?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"ver-act",onClick:()=>aa(),...Ma(hn),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
|
|
293
293
|
|