ccdeck 3.37.0 → 3.37.1
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-DCHV09J8.js → BrowserWatchModal-njN0zg93.js} +1 -1
- package/dist/web/assets/{UsageHistoryModal-oDjpHw4z.js → UsageHistoryModal-DYSZZZEz.js} +1 -1
- package/dist/web/assets/{index-wCbqcRJd.js → index-DDxnWaTa.js} +4 -4
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/release-notes.json +6 -0
- package/src/server/lan-engine.mjs +30 -20
|
@@ -88,7 +88,7 @@ ${h.sessionId}`:h.sessionId,children:h.label??i0(h.sessionId,8)}),a.jsx("span",{
|
|
|
88
88
|
|
|
89
89
|
${n}`:`Sort by ${t}`,onClick:()=>o(s(r,e)),children:[t,a.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:c==="none"?"":c==="ascending"?"↑":"↓"})]})})}function Ip(e){return e<9.95?e.toFixed(1):String(Math.round(e))}function c0(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<50?{value:"0",unit:"KB/s"}:t<999500?{value:Ip(t/1e3),unit:"KB/s"}:t<9995e5?{value:Ip(t/1e6),unit:"MB/s"}:{value:Ip(t/1e9),unit:"GB/s"}}function ih(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<999.5?{value:String(Math.round(t)),unit:"ms"}:{value:(t/1e3).toFixed(1),unit:"s"}}function Yl(e){return e.unit?e.unit==="%"||e.unit==="°C"?`${e.value}${e.unit}`:`${e.value} ${e.unit}`:e.value}function Op(e,t){return t==="B/s"?c0(e):t==="ms"?ih(e):{value:String(e),unit:t==="C"?"°C":t}}const Et={l:30,r:6,t:6,b:2},Xs={l:0,r:0,t:2,b:1},lh=104,L7=64;function ir(e,t=100,n=lh,r=Et){const s=n-r.t-r.b;return r.t+s*(1-Math.max(0,Math.min(t,e))/t)}function cI(e,t){return t??[e[0].t,e[e.length-1].t]}function u0(e,[t,n],r,s=Et){const o=r-s.l-s.r,l=n-t;return s.l+(l>0?o*(e-t)/l:o/2)}function uI(e,t,n,r=100,s=lh,o=Et,l){if(!e.length)return"";const c=cI(e,l),d=p=>u0(p,c,t,o);let h="",f=null;for(const p of e){const g=f&&p.t-f.t<=n*2?"L":"M";h+=`${g}${d(p.t).toFixed(1)} ${ir(p.v,r,s,o).toFixed(1)}`,f=p}return h}function dI(e,t,n,r=100,s=lh,o=Et,l){if(e.length<2)return"";const c=s-o.b,d=cI(e,l),h=v=>u0(v,d,t,o);let f="",p=[];const g=()=>{if(p.length>=2){let v=`M${h(p[0].t).toFixed(1)} ${c}`;for(const N of p)v+=`L${h(N.t).toFixed(1)} ${ir(N.v,r,s,o).toFixed(1)}`;f+=`${v}L${h(p[p.length-1].t).toFixed(1)} ${c}Z`}p=[]};for(const v of e)p.length&&v.t-p[p.length-1].t>n*2&&g(),p.push(v);return g(),f}function P7(e){return e.length?{now:e[e.length-1].v,peak:e.reduce((t,n)=>Math.max(t,n.v),e[0].v)}:{now:null,peak:null}}function hI(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function D7(e,t,n=r=>Fa(r)){const r=e.filter(l=>l.v>0);if(!e.length)return null;if(!r.length)return"never held back";const s=r.length*(t/6e4),o=r[r.length-1];return`held back for ${s===1?"1 minute":`${s} minutes`}, last at ${n(o.t)}`}function Fa(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function d0(e,t){const n=Math.max(0,Math.floor((t-e)/6e4));if(n<1)return"less than a minute";if(n<60)return`${n} minute${n===1?"":"s"}`;const r=Math.floor(n/60),s=n%60;return s?`${r}h ${s}m`:`${r}h`}function F7({group:e,title:t,onClose:n}){const r=ut(n),s=gt(n),[o,l]=y.useState(null);y.useEffect(()=>{let p=!0;const g=async()=>{try{const N=await fetch(`/api/system/history?group=${e}`);if(!N.ok)return;const k=await N.json();p&&(k!=null&&k.ok)&&l(k)}catch{}};g();const v=window.setInterval(g,2e4);return()=>{p=!1,window.clearInterval(v)}},[e]);const c=(o==null?void 0:o.series)??[],[d,h,f]=y.useMemo(()=>{let p=1/0,g=0;for(const v of c)v.points.length&&(p=Math.min(p,v.points[0].t),g=Math.max(g,v.points[v.points.length-1].t));return Number.isFinite(p)?[Math.max(p,(o==null?void 0:o.sinceMs)??0),g,[p,g]]:[(o==null?void 0:o.sinceMs)??0,g,void 0]},[c,o==null?void 0:o.sinceMs]);return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal hist-modal",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"hist-modal-title",children:[a.jsxs("div",{className:"modal-head",children:[a.jsx("span",{className:"modal-title",id:"hist-modal-title",children:t}),o&&d>0&&a.jsxs("span",{className:"hist-since",children:["since ",Fa(d)," · ",d0(d,h||Date.now())]}),a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),a.jsx("div",{className:"hist-body",children:o==null?a.jsx("p",{className:"hist-empty",children:"Reading…"}):c.length===0?a.jsx("p",{className:"hist-empty",children:"Nothing has been measured yet."}):c.map(p=>a.jsx(B7,{series:p,stepMs:o.stepMs,domain:f},p.label))})]})}),document.body)}function B7({series:e,stepMs:t,domain:n}){const r=y.useRef(null),[s,o]=y.useState(560),[l,c]=y.useState(null);y.useEffect(()=>{const O=r.current;if(!O||typeof ResizeObserver>"u")return;const I=new ResizeObserver(([B])=>o(Math.max(160,B.contentRect.width)));return I.observe(O),()=>I.disconnect()},[]);const{points:d,unit:h,warnAt:f,critAt:p,label:g,top:v,restsAtZero:N,changes:k}=e,x=N?L7:lh,{now:j,peak:b}=P7(d),_=j!=null?Op(j,h):null,E=b!=null?Op(b,h):null,R=g==="Throttling"?D7(d,t):null,T=l!=null?d[l]:null,[A,U]=n??(d.length?[d[0].t,d[d.length-1].t]:[0,0]),L=O=>u0(O,[A,U],s),F=O=>{if(d.length<2)return;const I=O.currentTarget.getBoundingClientRect(),B=(O.clientX-I.left-Et.l)/Math.max(1,I.width-Et.l-Et.r),M=A+(U-A)*Math.max(0,Math.min(1,B));let $=0;for(let P=1;P<d.length;P++)Math.abs(d[P].t-M)<Math.abs(d[$].t-M)&&($=P);c($)};return a.jsxs("section",{className:"hist-series","aria-label":`${g} history`,children:[a.jsxs("div",{className:"hist-head",children:[a.jsx("span",{className:"hist-label",children:g}),a.jsxs("span",{className:"hist-stats",children:[_&&a.jsxs(a.Fragment,{children:[a.jsx("b",{children:_.value}),a.jsxs("span",{children:[_.unit," now"]})]}),b!=null&&E&&a.jsxs(a.Fragment,{children:[a.jsx("b",{className:hI(b,f,p),children:E.value}),a.jsxs("span",{children:[E.unit," peak"]})]})]})]}),a.jsx("div",{className:"hist-plot",ref:r,children:a.jsxs("svg",{className:"hist-chart",width:"100%",height:x,viewBox:`0 0 ${s} ${x}`,preserveAspectRatio:"none",role:"img","aria-label":_==null||E==null?`${g}: nothing measured yet`:`${g}: ${Yl(_)} now, peak ${Yl(E)}, over ${d0(d[0].t,d[d.length-1].t)}`,onPointerMove:F,onPointerLeave:()=>c(null),children:[[["warn",f],["hot",p]].map(([O,I])=>I==null||I>v?null:a.jsxs("g",{children:[a.jsx("line",{className:`hist-rule ${O}`,x1:Et.l,x2:s-Et.r,y1:ir(I,v,x),y2:ir(I,v,x)}),a.jsx("text",{className:`hist-rule-tag ${O}`,x:2,y:ir(I,v,x)+3,children:I})]},O)),a.jsx("line",{className:"hist-floor",x1:Et.l,x2:s-Et.r,y1:x-Et.b,y2:x-Et.b}),(k??[]).filter(O=>O.from!=null&&d.length>1&&O.t>=A&&O.t<=U).map(O=>a.jsx("line",{className:"hist-mark",x1:L(O.t),x2:L(O.t),y1:Et.t,y2:x-Et.b},O.t)),a.jsx("path",{className:"hist-area",d:dI(d,s,t,v,x,Et,[A,U])}),a.jsx("path",{className:"hist-line",d:uI(d,s,t,v,x,Et,[A,U])}),d.length===1&&a.jsx("circle",{className:"hist-dot",cx:L(d[0].t),cy:ir(d[0].v,v,x),r:3}),T&&a.jsxs("g",{children:[a.jsx("line",{className:"hist-cross",x1:L(T.t),x2:L(T.t),y1:Et.t,y2:x-Et.b}),a.jsx("circle",{className:"hist-dot",cx:L(T.t),cy:ir(T.v,v,x),r:3})]})]})}),a.jsx("div",{className:"hist-axis",children:T?a.jsxs("span",{className:"hist-at",children:[Fa(T.t)," — ",(()=>{const O=Op(T.v,h);return a.jsxs(a.Fragment,{children:[a.jsx("b",{children:O.value}),O.unit==="%"||O.unit==="°C"||!O.unit?O.unit:` ${O.unit}`]})})()]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{children:d.length?Fa(A):""}),a.jsx("span",{children:d.length?Fa(U):""})]})}),R&&a.jsx("div",{className:"hist-note",children:R}),k==null?void 0:k.slice(-3).map(O=>a.jsx("div",{className:"hist-note hist-route",children:O.from==null?`Since ${Fa(O.t)} — ${O.label}`:`${Fa(O.t)} — ${O.label.charAt(0).toUpperCase()+O.label.slice(1)}`},O.t))]})}const q7="thermal:Throttling";function U7(e){var n,r,s,o;const t={};e.cpu!=null&&(t["cpu:all"]=e.cpu),(n=e.perCore)!=null&&n.length&&(t["cpu:busiest"]=Math.max(...e.perCore)),e.memory&&(t["mem:physical"]=e.memory.usedPct),e.swap&&e.swap.total>0&&(t["mem:swap"]=Math.round(e.swap.used/e.swap.total*1e3)/10),(r=e.loadavg)!=null&&r.length&&(t["load:1m"]=e.loadavg[0]);for(const l of((s=e.thermal)==null?void 0:s.celsius)??[])t[`thermal:${l.label}`]=l.celsius;return(o=e.thermal)!=null&&o.throttle&&(t[q7]=Math.max(0,100-e.thermal.throttle.speedLimit)),t}function $l(e,t){return t==="B/s"?Yl(c0(e)):t==="ms"?Yl(ih(e)):t==="C"?`${Math.round(e)}°`:t==="%"?`${Math.round(e)}%`:e.toFixed(2)}function Lu(e,t){return t==="B/s"||t==="ms"||!Number.isInteger(e)?$l(e,t):t==="C"?`${e}°`:t==="%"?`${e}%`:`${e}`}const uS=["cores","memory","load","thermal"],Ia=116,Ir=24,z7=60,W7=6e4;function H7(e){return e.points.length?e.restsAtZero?e.points.some(t=>t.v>0):!0:!1}function V7(e){return e.unit==="C"?`${e.label} temp`:e.key==="mem:physical"?"Physical RAM":e.key==="mem:swap"?`${e.label} memory`:e.label}function G7(e,t=z7){return e.points.length<=t?e:{...e,points:e.points.slice(-t)}}function K7({sys:e}){const[t,n]=y.useState({});y.useEffect(()=>{let l=!0;const c=async()=>{const h=await Promise.all(uS.map(async f=>{try{const p=await fetch(`/api/system/history?group=${f}`);return p.ok?[f,await p.json()]:[f,null]}catch{return[f,null]}}));l&&n(f=>{const p={...f};for(const[g,v]of h)v!=null&&v.ok&&(p[g]=v);return p})};c();const d=setInterval(()=>void c(),W7);return()=>{l=!1,clearInterval(d)}},[]);const r=y.useMemo(()=>U7(e),[e]),s=y.useMemo(()=>uS.flatMap(l=>{const c=t[l];return c?c.series.filter(H7).map(d=>({series:G7(d),stepMs:c.stepMs})):[]}),[t]),o=y.useMemo(()=>{let l=1/0,c=-1/0;for(const{series:d}of s){const h=d.points;h.length&&(l=Math.min(l,h[0].t),c=Math.max(c,h[h.length-1].t))}return Number.isFinite(l)?d0(l,c):"less than a minute"},[s]);return Object.keys(r).length?a.jsx("div",{className:"pl-strip",role:"group","aria-label":`This machine, over the last ${o}`,children:s.map(({series:l,stepMs:c})=>a.jsx(Y7,{series:l,stepMs:c,now:r[l.key],span:o},l.key))}):null}function Y7({series:e,stepMs:t,now:n,span:r}){var v;const{points:s,top:o,unit:l,warnAt:c,critAt:d}=e,h=V7(e),f=n??((v=s[s.length-1])==null?void 0:v.v),p=f==null?"":hI(f,c,d),g=Math.max(...s.map(N=>N.v));return a.jsxs("div",{className:`pl-cell${p?` ${p}`:""}`,title:[`${h} · peak ${$l(g,l)} over the last ${r}`,c!=null?`over ${Lu(c,l)} is uncomfortable`:"",d!=null?`over ${Lu(d,l)} the machine acts`:""].filter(Boolean).join(" · "),children:[a.jsxs("div",{className:"pl-cell-head",children:[a.jsx("span",{className:"pl-cell-label",children:h}),a.jsx("span",{className:"pl-cell-now",children:f==null?"—":$l(f,l)})]}),a.jsxs("svg",{className:"pl-spark",width:Ia,height:Ir,viewBox:`0 0 ${Ia} ${Ir}`,preserveAspectRatio:"none","aria-hidden":!0,children:[a.jsx("line",{className:"pl-spark-floor",x1:0,x2:Ia,y1:Ir-Xs.b,y2:Ir-Xs.b}),a.jsx("path",{className:"pl-spark-area",d:dI(s,Ia,t,o,Ir,Xs)}),c!=null&&a.jsx("line",{className:"pl-rule warn",x1:0,x2:Ia,y1:ir(c,o,Ir,Xs),y2:ir(c,o,Ir,Xs)}),d!=null&&a.jsx("line",{className:"pl-rule hot",x1:0,x2:Ia,y1:ir(d,o,Ir,Xs),y2:ir(d,o,Ir,Xs)}),a.jsx("path",{className:"pl-spark-line",d:uI(s,Ia,t,o,Ir,Xs)})]}),a.jsxs("span",{className:"vis-hidden",children:["peak ",$l(g,l)," over the last ",r,c!=null&&`, uncomfortable over ${Lu(c,l)}`,d!=null&&`, the machine acts over ${Lu(d,l)}`]})]})}const fI={key:"cpu",dir:"desc"};function X7(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"||t==="user"?"asc":"desc"}}function Z7(e,t){const n=t.dir==="asc"?1:-1,r=o=>t.key==="cpu"?o.cpu:t.key==="mem"?o.mem:t.key==="rss"?o.rssBytes:t.key==="threads"?o.threads:o.uptimeSec,s=(o,l)=>{if(t.key==="name")return n*o.name.localeCompare(l.name,void 0,{sensitivity:"base"});if(t.key==="user"){const h=o.user??"",f=l.user??"";return!h||!f?h===f?0:h?-1:1:n*h.localeCompare(f,void 0,{sensitivity:"base"})}const c=r(o),d=r(l);return c==null||d==null?c==null?d==null?0:1:-1:n*(c-d)};return[...e].sort((o,l)=>s(o,l)||(l.cpu??-1)-(o.cpu??-1)||l.mem-o.mem||o.pid-l.pid)}const J7=4e3;function Q7(e,t){const n=t!=null&&t.ok&&Array.isArray(t.procs)?t.procs:[];return n.length?{procs:n,total:t.total??0}:e??{procs:[],total:0}}function e9(){const[e,t]=y.useState(null);return y.useEffect(()=>{let n=!0;const r=async()=>{if(document.visibilityState!=="hidden")try{const o=await fetch("/api/system/processes?detail=1");if(!o.ok)return;const l=await o.json();n&&t(c=>Q7(c,l))}catch{}};r();const s=window.setInterval(r,J7);return()=>{n=!1,window.clearInterval(s)}},[]),e}function t9(e){return e==null||!Number.isFinite(e)||e<0?"—":e<60?`${Math.floor(e)}s`:e<3600?`${Math.floor(e/60)}m`:e<86400?`${Math.floor(e/3600)}h`:`${Math.floor(e/86400)}d`}function n9({sys:e,onClose:t}){qt("process-list");const n=ut(t),r=gt(t),[s,o]=y.useState(fI),l=e9();return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsx("div",{ref:n,className:"modal pl-modal",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"pl-modal-title",children:a.jsx(r9,{read:l,sort:s,onSort:o,sys:e,onClose:t})})}),document.body)}function r9({read:e,sort:t,onSort:n,sys:r,onClose:s}){const o=e?Z7(e.procs,t):null;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"modal-head",children:[a.jsx("span",{className:"modal-title",id:"pl-modal-title",children:"Busiest processes"}),o!=null&&o.length>0&&a.jsxs("span",{className:"pl-count",children:[o.length," of ",e.total," running"]}),a.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),a.jsxs("div",{className:"pl-split",children:[a.jsx("div",{className:"pl-body",children:o==null?a.jsx("p",{className:"pl-empty",children:"Reading the process list…"}):o.length===0?a.jsx("p",{className:"pl-empty",children:"Could not read the process list — retrying."}):a.jsxs("table",{className:"sd-procs pl-table",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx(Uo,{col:"cpu",label:"cpu",sort:t,onSort:n}),a.jsx(Uo,{col:"rss",label:"memory",note:"Resident set size, which is what ps and Task Manager report; macOS Activity Monitor shows a different figure.",sort:t,onSort:n}),a.jsx(Uo,{col:"threads",label:"threads",sort:t,onSort:n}),a.jsx(Uo,{col:"uptime",label:"up",sort:t,onSort:n}),a.jsx(Uo,{col:"user",label:"user",sort:t,onSort:n}),a.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),a.jsx(Uo,{col:"name",label:"process",note:"Command lines have anything secret-shaped removed, which is a filter and not a guarantee.",sort:t,onSort:n})]})}),a.jsx("tbody",{children:o.map(l=>a.jsxs("tr",{children:[a.jsx("td",{className:"sd-num",children:l.cpu==null?"—":l.cpu.toFixed(0)}),a.jsx("td",{className:"sd-num sd-dim",title:`${l.mem.toFixed(1)}% of installed memory`,children:ea(l.rssBytes)}),a.jsx("td",{className:"sd-num sd-dim",children:l.threads??"—"}),a.jsx("td",{className:"sd-num sd-dim",children:t9(l.uptimeSec)}),a.jsx("td",{className:"sd-dim pl-user",children:l.user??"—"}),a.jsx("td",{className:"sd-num sd-dim pl-pid",children:l.pid}),a.jsxs("td",{className:"pl-name",children:[l.name,l.cmd&&a.jsxs("span",{className:"pl-cmd",title:l.cmd,children:[" ",l.cmd]})]})]},l.pid))})]})}),a.jsx(K7,{sys:r})]})]})}function Uo(e){return a.jsx(jl,{...e,next:(t,n)=>X7(t??fI,n)})}function Vx({value:e,unit:t,cap:n}){return t?a.jsxs("span",{className:"sd-fig",children:[a.jsx("span",{className:"sd-fig-cap",children:n}),a.jsxs("span",{className:"sd-fig-read",children:[a.jsx("b",{children:e})," ",a.jsx("span",{className:"sd-fig-unit",children:t})]})]}):a.jsxs("span",{className:"sd-fig",children:[a.jsx("b",{children:e}),a.jsx("span",{className:"sd-fig-cap",children:n})]})}const s9=300;function Xl({group:e,title:t,action:n,label:r,value:s,hint:o,children:l}){const[c,d]=y.useState(!1),h=y.useRef(null),f=y.useRef(null),p=()=>{f.current!=null&&window.clearTimeout(f.current),f.current=null};y.useEffect(()=>p,[]);const g=v=>{var N;p(),!(v.detail>1||((N=window.getSelection())==null?void 0:N.isCollapsed)===!1)&&(f.current=window.setTimeout(()=>{var k,x;f.current=null,((k=window.getSelection())==null?void 0:k.isCollapsed)!==!1&&((x=h.current)==null||x.focus({preventScroll:!0}),d(!0))},s9))};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"sd-reading",onClick:g,children:[a.jsx("button",{ref:h,type:"button",className:"sd-open",onClick:v=>{v.stopPropagation(),p(),d(!0)},title:n,"aria-label":s==null?`${r}: show history`:`${r}: show history, now ${s}`,"aria-describedby":o?`sd-hint-${e}`:void 0,children:a.jsxs("span",{className:"sd-h","aria-hidden":!0,children:[r," ",a.jsx("i",{className:"sd-row-more",children:"›"}),s!=null&&a.jsx("span",{className:"sd-h-val",children:s})]})}),l]}),o&&a.jsx("span",{id:`sd-hint-${e}`,className:"vis-hidden",children:o}),c&&a.jsx(F7,{group:e,title:t,onClose:()=>d(!1)})]})}function jd({label:e,value:t,pct:n,tone:r="calm",note:s,mark:o,title:l,trackLabel:c}){return a.jsxs("div",{className:"sd-row",title:l,children:[a.jsxs("div",{className:"sd-row-head",children:[a.jsx("span",{className:"sd-row-label",children:e}),a.jsx("span",{className:"sd-row-val",children:t})]}),a.jsxs("span",{className:"sd-track",role:c?"img":void 0,"aria-label":c,children:[a.jsx("span",{className:`sd-fill${r==="calm"?"":` ${r}`}`,style:{transform:`scaleX(${n<=0?0:Math.max(1,Math.min(100,n))/100})`}}),o!=null&&o>0&&o<100&&a.jsx("span",{className:"sd-mark",style:{left:`${o}%`},"aria-hidden":!0})]}),s&&a.jsx("div",{className:"sd-note",children:s})]})}function a9(e,t,n){if(n<=0||Jd(e))return{kind:"pass"};const r=t>=0&&t<n?t:-1;switch(e.key){case"ArrowDown":return{kind:"focus",index:r===-1?0:(r+1)%n};case"ArrowUp":return{kind:"focus",index:r===-1?n-1:(r-1+n)%n};case"Home":return{kind:"focus",index:0};case"End":return{kind:"focus",index:n-1};default:return{kind:"pass"}}}const ra=4,Bn=8;function h0(e,t,n){const r=n.width-Bn-(e.right+ra),s=e.left-ra-Bn,o=t.width<=r||r>=s?"right":"left",l=o==="right"?e.right+ra:e.left-ra-t.width,c=n.height-Bn*2,d=t.height<=c,h=d?t.height:Math.max(0,c),f=Math.max(Bn,Math.min(e.top,n.height-Bn-h)),p=Math.max(Bn,Math.min(l,n.width-Bn-t.width));return{top:f,left:p,side:o,maxHeight:d?null:h}}function o9(e,t,n){const r=n.height-Bn-(e.bottom+ra),s=e.top-ra-Bn,o=t.height<=r||r>=s?"below":"above",l=o==="below"?r:s,c=t.height<=l,d=c?t.height:Math.max(0,l),h=o==="below"?e.bottom+ra:e.top-ra-d,f=Math.max(Bn,Math.min(e.right-t.width,n.width-Bn-t.width));return{top:Math.max(Bn,h),left:f,side:o,maxHeight:c?null:d}}function i9(e,t,n){return!(!e||t!=null&&t.contains(e)||n!=null&&n.contains(e))}function pI(e,t,n){const r=y.useRef(t);r.current=t;const s=y.useRef(n);s.current=n,y.useEffect(()=>{const o=l=>{i9(l.target,e.current,r.current())&&s.current()};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[e])}const mI='[role="menuitem"]';function dS(e){return e?Array.from(e.querySelectorAll(mI)).filter(t=>!t.disabled):[]}function ch({anchorId:e,boundaryId:t,id:n,className:r,role:s,labelledBy:o,start:l="first",focusRef:c,fallbackFocus:d,onClose:h,children:f}){const p=y.useRef(h);p.current=h;const g=y.useRef(d);g.current=d;const v=ut(()=>{var b;(b=document.getElementById(e))==null||b.focus(),p.current()},{popover:!0,focusRef:c}),N=y.useCallback(()=>{var A,U,L;const b=v.current;if(!b)return;const _=document.getElementById(e);if(!_){p.current();return}if(_.getClientRects().length===0){b.contains(document.activeElement)&&((U=(A=g.current)==null?void 0:A.call(g))==null||U.focus()),p.current();return}const E=_.getBoundingClientRect(),R=t?(L=document.getElementById(t))==null?void 0:L.getBoundingClientRect():null;if(R&&(E.bottom<=R.top||E.top>=R.bottom)){b.contains(document.activeElement)&&_.focus({preventScroll:!0}),p.current();return}b.style.maxHeight="";const T=o9(E,{width:b.offsetWidth,height:b.offsetHeight},{width:window.innerWidth,height:window.innerHeight});b.style.top=`${T.top}px`,b.style.left=`${T.left}px`,b.style.maxHeight=T.maxHeight==null?"":`${T.maxHeight}px`,b.dataset.side=T.side},[e,t,v]);y.useLayoutEffect(()=>{N()}),y.useEffect(()=>{const b=_=>{var E;(E=v.current)!=null&&E.contains(_.target)||N()};return window.addEventListener("scroll",b,!0),window.addEventListener("resize",N),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",N)}},[N,v]),pI(v,()=>document.getElementById(e),h),y.useEffect(()=>{var _;if(s!=="menu")return;const b=dS(v.current);(_=l==="last"?b[b.length-1]:b[0])==null||_.focus()},[]);const k=b=>{var _;if(s==="menu"&&b.key==="Tab"){b.stopPropagation(),(_=document.getElementById(e))==null||_.focus(),b.shiftKey&&b.preventDefault(),p.current();return}if(s==="menu"){const E=dS(v.current),R=a9(b,E.indexOf(document.activeElement),E.length);R.kind==="focus"&&(b.preventDefault(),E[R.index].focus())}b.key.length===1&&b.stopPropagation()},x=b=>{b.target.closest("button, input, select, textarea, code")||b.preventDefault()},j=b=>{if(s!=="menu"||b.pointerType==="touch")return;const _=b.target.closest(mI);_&&!_.disabled&&document.activeElement!==_&&_.focus({preventScroll:!0})};return Lt.createPortal(a.jsx("div",{ref:v,id:n,className:`anchored-popover${r?` ${r}`:""}`,role:s,"aria-labelledby":o,onKeyDown:k,onMouseDown:x,onPointerMove:j,children:f}),document.body)}function l9({network:e}){const{down:t,up:n,api:r,route:s}=e,[o,l]=y.useState(!1),c=r&&r.ms!=null?ih(r.ms):null,d=t!=null&&n!=null;return a.jsxs("div",{className:"sd-section",role:"group","aria-label":"Network",children:[a.jsxs(Xl,{group:"network",title:"Network history",action:"Show network history",label:"Network",children:[(d||c)&&a.jsxs("div",{className:"sd-figs sd-figs-named",children:[d&&[["Download",t],["Upload",n]].map(([h,f])=>{const p=c0(f);return a.jsx(Vx,{value:p.value,unit:p.unit,cap:h},h)}),c&&a.jsx(Vx,{value:c.value,unit:c.unit,cap:"Claude API"})]}),!d&&a.jsx("div",{className:"sd-note",children:"measuring…"}),r&&r.ms==null&&a.jsx("div",{className:"sd-note sd-note-warn",children:"Can’t reach Claude"})]}),s&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"sd-detail",id:"sd-conn","aria-expanded":o,"aria-haspopup":"dialog",onClick:()=>l(h=>!h),children:["Connection details",s.relay&&a.jsx("span",{className:"sd-route-relay",children:" · relayed"}),a.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),o&&a.jsx(c9,{route:s,api:r,onClose:()=>l(!1)})]})]})}function c9({route:e,api:t,onClose:n}){return a.jsxs(ch,{anchorId:"sd-conn",boundaryId:"system-panel",id:"sd-conn-pop",className:"sd-pop",role:"dialog",labelledBy:"sd-conn-title",onClose:n,children:[a.jsx("p",{className:"sd-pop-title",id:"sd-conn-title",children:"Connection"}),a.jsxs("dl",{className:"sd-pop-rows",children:[a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:e.to==="claude"?"Traffic to Claude":"Internet traffic"}),a.jsxs("dd",{children:["through ",M7(e)]})]}),e.relay&&a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:"Relay"}),a.jsxs("dd",{children:[a.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&&a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:"Round trip"}),a.jsx("dd",{children:t.ms==null?`${t.host} did not answer`:`${Yl(ih(t.ms))} to open a connection to ${t.host}`})]}),a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:"Throughput"}),a.jsx("dd",{children:"every interface on this machine, not this path alone"})]})]})]})}function hS({usageOpen:e,leaving:t,sub:n,flag:r,onClose:s,children:o}){return a.jsxs("aside",{className:`sysdetail${e?" shifted":""}${t?" leaving":""}`,id:"system-panel","aria-labelledby":"sd-title",children:[a.jsxs("div",{className:"sd-top",children:[a.jsxs("div",{className:"sd-head",children:[a.jsx("h2",{className:"sd-title",id:"sd-title",children:"This machine"}),n&&a.jsx("span",{className:"sd-sub",children:n}),a.jsx("button",{type:"button",className:"glyph-btn sd-close",onClick:s,"aria-label":"Close",title:"Close",children:"×"})]}),r&&a.jsx("p",{className:"sd-flag",children:r})]}),o]})}function u9({usageOpen:e,leaving:t,onClose:n}){const r=I7();if(!r||r.cpu==null||!r.memory)return a.jsx(hS,{usageOpen:e,leaving:t,onClose:n,children:a.jsx("div",{className:"sd-note",children:"reading this machine…"})});const{memory:s,swap:o,perCore:l,loadavg:c,cores:d,uptimeSec:h,platform:f,thermal:p,network:g,cpu:v}=r;return a.jsxs(hS,{usageOpen:e,leaving:t,sub:`up ${A7(h)} · ${d} cores`,flag:R7(r),onClose:n,children:[a.jsx(d9,{cpu:v,perCore:l,loadavg:c,cores:d}),a.jsx(h9,{memory:s,swap:o,platform:f}),g&&a.jsx(l9,{network:g}),a.jsx(f9,{thermal:p}),a.jsx(p9,{sys:r})]})}function d9({cpu:e,perCore:t,loadavg:n,cores:r}){const s=!!t&&t.length>0;return!s&&!n?null:a.jsxs("div",{className:"sd-section sd-cpu",role:"group","aria-label":"CPU",children:[s&&a.jsx(Xl,{group:"cores",title:"Core history",action:"Show core history",label:"CPU",value:e==null?null:`${Math.round(e)}%`,children:a.jsx("div",{className:"sd-cores",role:"img","aria-label":`${t.length} logical cores, busiest at ${Math.round(Math.max(...t))}%`,children:t.map((o,l)=>a.jsx("span",{className:"sd-core",title:`logical core ${l+1} · ${o}% busy`,children:a.jsx("span",{className:"sd-core-fill",style:{transform:`scaleY(${Math.max(2,o)/100})`}})},l))})}),n&&a.jsxs(Xl,{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:[a.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((o,l)=>a.jsx(Vx,{value:o.toFixed(2),cap:["1m","5m","15m"][l]},l))}),n[0]>r&&a.jsx("div",{className:"sd-note",children:`${(n[0]/r).toFixed(1)}× more work queued than cores to run it`})]})]})}function h9({memory:e,swap:t,platform:n}){const r=e.total-e.available,s=n==="win32"?"Commit":"Swap",o=t&&t.total>0?t.used/t.total*100:0;return a.jsx("div",{className:"sd-section",role:"group","aria-label":"Memory",children:a.jsxs(Xl,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[a.jsx(jd,{label:"Physical",value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:ea(r)})," of ",ea(e.total)]}),pct:e.usedPct,tone:e.usedPct>=90?"warn":"calm",note:`${ea(e.available)} available`}),t&&t.total>0&&a.jsx(jd,{label:s,value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:ea(t.used)})," of ",ea(t.total)]}),pct:o,tone:o>=90?"warn":"calm"})]})})}function f9({thermal:e}){if(!e)return null;const t=e.throttle?C7(e.throttle.speedLimit,e.heldBack):null;return a.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:a.jsxs(Xl,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>a.jsx(jd,{label:n.label,value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:n.celsius})," °C"]}),pct:n.celsius/n.critAt*100,mark:n.warnAt/n.critAt*100,tone:E7(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&&a.jsx(jd,{label:"Throttling",value:a.jsx("b",{children:t.value}),pct:t.pct,tone:t.tone,note:t.note})]})})}function p9({sys:e}){const[t,n]=y.useState(!1);return a.jsxs("div",{className:"sd-section sd-door-section",children:[a.jsx("button",{type:"button",className:"sd-open sd-door",onClick:()=>n(!0),"aria-label":"Busiest processes: show every process the deck is watching",children:a.jsxs("span",{className:"sd-door-plate",children:[a.jsxs("span",{className:"sd-door-name",children:["Busiest processes",a.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),a.jsx("span",{className:"sd-door-sub",children:"every process, with its command line"})]})}),t&&a.jsx(n9,{sys:e,onClose:()=>n(!1)})]})}function f0(e){const t={inputTokens:e.i,outputTokens:e.o,cacheReadTokens:e.cr,cacheCreateTokens:e.cc,cacheCreate1hTokens:e.c1h,cacheCreate5mTokens:e.c5m},n=e.s?Object.entries(e.s):[];return n.length>0&&(t.bySpeed=Object.fromEntries(n.map(([r,s])=>[r,f0(s)]))),t}function fS(e){const t=r=>({...r,cacheCreate1hTokens:0,cacheCreate5mTokens:0}),n=t(f0(e));return n.bySpeed&&(n.bySpeed=Object.fromEntries(Object.entries(n.bySpeed).map(([r,s])=>[r,t(s)]))),n}function gI(e){return e.i+e.o+e.cr+e.cc}function yI(e,t){var n;e.i+=t.i,e.o+=t.o,e.cr+=t.cr,e.cc+=t.cc,e.c1h+=t.c1h,e.c5m+=t.c5m;for(const[r,s]of Object.entries(t.s??{}))yI((n=e.s??(e.s={}))[r]??(n[r]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),s);return e}function pS(e,t,n){let r=0,s=0,o=0;const l=[];for(const c of Yd(e)){if(!ca(t,n,c.speed)){const d=c.usage,h=d.inputTokens+d.outputTokens+d.cacheReadTokens+d.cacheCreateTokens;h>0&&(o+=h,l.push(c.speed));continue}r+=vd(c.usage,t,c.speed,n).total,s+=vd(c.usage,t,aa,n).total}return{atSpeed:r,atStandard:s,unpriced:o,unpricedSpeeds:l}}function mS(e){let t=0;for(const n of Object.values(e))t+=gI(n);return t}function m9(e){const t=s=>typeof s=="number"&&Number.isFinite(s)?s:0,n=new Map,r=e&&Array.isArray(e.days)?e.days:[];for(const s of r){const o=typeof s.period=="string"?s.period:"",l=Array.isArray(s.modelBreakdowns)?s.modelBreakdowns:[];for(const c of l){const d=typeof c.modelName=="string"?c.modelName:"";if(!o||!/claude/i.test(d)||c.missingPricing===!0)continue;const h=`${o}|${d}`,f=n.get(h),p=f?f.usage:{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,cacheCreate1hTokens:0,cacheCreate5mTokens:0};p.inputTokens+=t(c.inputTokens),p.outputTokens+=t(c.outputTokens),p.cacheReadTokens+=t(c.cacheReadTokens),p.cacheCreateTokens+=t(c.cacheCreationTokens),f?f.cost+=t(c.cost):n.set(h,{cost:t(c.cost),usage:p})}}return n}function g9(e,t,n,r=Date.now()){const s=new Map;for(const A of e){const U={},L=F=>{for(const[O,I]of Object.entries(F))yI(U[O]??(U[O]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),I)};for(const F of A.projects)L(F.models);A.unattributed&&L(A.unattributed);for(const[F,O]of Object.entries(U)){if(!O.s)continue;const{atSpeed:I,atStandard:B}=pS(fS(O),F,r);if(!(I>0&&B>0))continue;let M=s.get(A.day);M||(M=new Map,s.set(A.day,M)),M.set(F,I/B),M.has(cs(F))||M.set(cs(F),I/B)}}const o=(A,U)=>{const L=s.get(A);return(L==null?void 0:L.get(U))??(L==null?void 0:L.get(cs(U)))??1},l=new Map;let c=0,d=0;for(const[A,U]of n){const L=A.indexOf("|"),F=A.slice(0,L),O=A.slice(L+1),I=Kd(U.usage,O,r).total*o(F,O);if(!(I>0&&U.cost>0))continue;c+=U.cost,d+=I;let B=l.get(F);B||(B=new Map,l.set(F,B)),B.set(O,U.cost/I)}const h=d>0,f=(A,U)=>{const L=l.get(A);return(L==null?void 0:L.get(U))??(L==null?void 0:L.get(cs(U)))??null},p=new Set,g=(A,U)=>{let L=0,F=0;for(const[O,I]of Object.entries(A)){if(ca(O,r)){const M=U(O),$=pS(M===null?f0(I):fS(I),O,r);L+=M===null?$.atSpeed:$.atSpeed*M,F+=$.unpriced;for(const P of $.unpricedSpeeds)p.add(`${O} (${P})`);continue}const B=gI(I);B>0&&(F+=B,p.add(O))}return{cost:L,unpriced:F}},v=new Map,N=[];for(const A of e){const U=new Map,L=new Map;let F=0;for(const O of A.projects){const{cost:I,unpriced:B}=g(O.models,$=>f(A.day,$));U.set(O.path,(U.get(O.path)??0)+I),B>0&&L.set(O.path,(L.get(O.path)??0)+B),F+=I;let M=v.get(O.path);M||(M={path:O.path,cost:0,tokens:0,unpricedTokens:0},v.set(O.path,M)),M.cost+=I,M.tokens+=mS(O.models),M.unpricedTokens+=B}N.push({day:A.day,total:F,byPath:U,unpricedByPath:L})}const k=[...v.values()].sort((A,U)=>U.cost-A.cost||U.tokens-A.tokens),x=k.reduce((A,U)=>A+U.cost,0),j=k.reduce((A,U)=>A+U.tokens,0),b=k.reduce((A,U)=>A+U.unpricedTokens,0),_=h?c/d:null,E=t?mS(t):0,R=t?g(t,()=>_):{cost:0,unpriced:0},T=R.cost>0||E>0?{cost:R.cost,tokens:E,unpricedTokens:R.unpriced}:null;return{projects:k,totalCost:x,totalTokens:j,unpricedTokens:b,perDay:N,unattributed:T,unpricedModels:[...p].sort(),calibrated:h,reconciled:h&&b===0}}function Or(e,t,n=qe){return t>0?e>0?`${n(e)}+`:ms:n(e)}function zo(e){return e>0?`${it(e)} of these tokens are on an unpriced model, so this is a floor`:void 0}function y9(e){if(e.length===0)return null;const t=e.length===1,n=t?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`;return t?`${n} is ${ms}: this build holds no published rate for it, so its tokens are counted and its dollars are not.`:`${n} are ${ms}: this build holds no published rate for them, so their tokens are counted and their dollars are not.`}const w9={phase:"running"},v9={phase:"failed"},x9={gen:0,report:null,error:null,early:null};function b9(e,t){var n,r;if(t.type!=="start"&&t.gen!==e.gen)return e;switch(t.type){case"start":return{...e,gen:t.gen,error:null,early:null};case"report":{const s=((n=e.early)==null?void 0:n.gen)===t.gen?e.early.cost:w9;return{...e,report:{gen:t.gen,days:t.days,data:t.data,cost:s},early:null}}case"reportFailed":return{...e,report:null,error:t.message,early:null};case"cost":return((r=e.report)==null?void 0:r.gen)===t.gen?{...e,report:{...e.report,cost:t.cost}}:{...e,early:{gen:t.gen,cost:t.cost}}}}function k9(e){var t;return((t=e.report)==null?void 0:t.gen)!==e.gen&&e.error===null}function N9(e){const t=e;return t&&t.ok!==!1?{phase:"ready",range:t}:v9}function j9(e){return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}`}function S9(e,t,n=Date.now()){const r=t===0?60:t,s=new Date(n),o=Wx(r,s),l=j9(s);return{report:`/api/account-projects?num=${e}&days=${t}`,ccusage:`/api/ccusage?since=${o}&until=${l}`}}function _9({num:e,days:t,gen:n,dispatch:r,get:s=(l,c)=>fetch(l,c),now:o=Date.now()}){const l=S9(e,t,o),c={credentials:"same-origin"};s(l.report,c).then(d=>d.ok?d.json():Promise.reject(new Error(`HTTP ${d.status}`))).then(d=>r({type:"report",gen:n,days:t,data:d}),d=>r({type:"reportFailed",gen:n,message:(d==null?void 0:d.message)||"Could not load"})),s(l.ccusage,c).then(d=>d.ok?d.json():null).catch(()=>null).then(d=>r({type:"cost",gen:n,cost:N9(d)}))}async function eo(e,t=500){var r;if(!e)return!1;let n=!1;try{n=await Promise.race([((r=navigator.clipboard)==null?void 0:r.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(s=>window.setTimeout(()=>s(!1),t))])}catch{n=!1}if(n)return!0;try{const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(s),s.select(),n=document.execCommand("copy"),s.remove()}catch{n=!1}return n}function wI(e){return/^[A-Za-z]:[\\/]$/.test(e)?e:e.replace(/[\\/]+$/,"")}function Lp(e){const t=wI(e).replace(/\\/g,"/");return/^[A-Za-z]:\//.test(t)?t.toLowerCase():t}function gS(e){if(!e)return e;const t=wI(e),n=t.match(/^\/(?:Users|home)\/[^/]+(\/.*)?$/);if(n)return`~${n[1]??""}`;const r=t.replace(/\\/g,"/").match(/^[A-Za-z]:\/Users\/[^/]+(\/.*)?$/i);return r?`~${r[1]??""}`:t.replace(/\\/g,"/")}function E9(e,t){const n=Lp(e);let r;for(const s of t){const o=Lp(s.path);!o||o===n||!n.startsWith(`${o}/`)||(!r||Lp(r.path).length<o.length)&&(r=s)}return r==null?void 0:r.label}function Gx(e){return e===0?"all time":e===1?"today":`the last ${e} days`}function C9(e){return e===1?"No work attributed to this account yet today.":`No work attributed to this account in ${Gx(e)}.`}function T9(e){return e===1?7:e===7?30:e===30?0:null}function A9(e,t){return e!==1&&t>0}const R9=[{days:1,label:"Today"},{days:7,label:"7d"},{days:30,label:"30d"},{days:0,label:"All"}],Wo=["var(--usage-blue)","var(--usage-teal)","var(--usage-lime)","var(--usage-purple)","var(--usage-indigo)","var(--usage-pink)","var(--usage-orange)","var(--usage-zinc)"],M9="var(--usage-zinc)",Pp=6,$9=1600;function I9(e){const t=qe(e),n=/^\$(\d{4,})$/.exec(t);return n?`$${Number(n[1]).toLocaleString("en-US")}`:t}function Pu(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 O9(e){const t=/^\d{4}-(\d{2})-(\d{2})$/.exec(e);return t?`${Number(t[1])}/${Number(t[2])}`:e}function L9(e){const t=Math.max(1,Math.ceil(e/6));return n=>n===0||n===e-1||n%t===0}function Dp(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function P9({num:e,name:t,onClose:n}){var P,G,K,q;qt("account-projects");const[r,s]=y.useState(1),[o,l]=y.useReducer(b9,x9),c=((P=o.report)==null?void 0:P.data)??null,d=((G=o.report)==null?void 0:G.days)??r,h=((K=o.report)==null?void 0:K.cost.phase)==="ready"?o.report.cost.range:null,f=((q=o.report)==null?void 0:q.cost.phase)==="running",[p,g]=y.useState(null),[v,N]=y.useState(()=>new Set),k=k9(o),x=o.error,[j,b]=y.useState(null),_=y.useRef(void 0),E=y.useRef(!0);y.useEffect(()=>()=>{E.current=!1,window.clearTimeout(_.current)},[]);const R=y.useRef(null),T=ut(n,{focusRef:R}),A=gt(n),U=y.useRef(0);y.useEffect(()=>{const H=++U.current;l({type:"start",gen:H}),g(null),N(new Set),_9({num:e,days:r,gen:H,dispatch:l})},[e,r]);const L=y.useMemo(()=>{const H=Date.now();if(!c)return null;const D=g9(c.daily??[],c.unattributed,m9(h),H),W=be=>be.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||be||"(unknown)",J=new Map;for(const be of D.projects)J.set(W(be.path),(J.get(W(be.path))??0)+1);const V=be=>{const oe=W(be);if((J.get(oe)??0)<=1)return oe;const je=be.replace(/[\\/]+$/,"").split(/[\\/]/).slice(-2,-1)[0];return je?`${je}/${oe}`:oe},X=D.projects.map(be=>({path:be.path,label:V(be.path)})),Y=be=>({path:be.path,label:V(be.path),parentLabel:E9(be.path,X),cost:be.cost,tokens:be.tokens,unpricedTokens:be.unpricedTokens}),Z=Wo[Pp%Wo.length],ee=new Map,ne=[],se=D.projects.slice(0,Pp),pe=D.projects.slice(Pp);se.forEach((be,oe)=>{ee.set(be.path,Wo[oe%Wo.length]),ne.push({key:be.path,...Y(be),color:Wo[oe%Wo.length]})}),pe.length&&ne.push({key:"__other__",label:`Other · ${pe.length} project${pe.length>1?"s":""}`,cost:pe.reduce((be,oe)=>be+oe.cost,0),tokens:pe.reduce((be,oe)=>be+oe.tokens,0),unpricedTokens:pe.reduce((be,oe)=>be+oe.unpricedTokens,0),color:Z,muted:!0,members:pe.map(Y)});const ke=D.totalCost,ae=D.totalTokens,fe=ke>0&&D.unpricedTokens===0?"cost":"tokens",me=fe==="cost"?ke:ae,he=ne.map(be=>be.color),ge=D.perDay.map(be=>{const oe=new Map;for(const[Oe,Ue]of be.byPath){const Be=ee.get(Oe)??Z;oe.set(Be,(oe.get(Be)??0)+Ue)}const je=new Map;let $e=0;for(const[Oe,Ue]of be.unpricedByPath){const Be=ee.get(Oe)??Z;je.set(Be,(je.get(Be)??0)+Ue),$e+=Ue}return{day:be.day,total:be.total,costByColor:oe,unpricedByColor:je,unpriced:$e}}),ue=ge.reduce((be,oe)=>Math.max(be,oe.total),0);return{projectCount:D.projects.length,rows:ne,totalCost:ke,totalTokens:ae,basis:fe,denom:me,un:D.unattributed,chart:ge,maxDay:ue,colorOrder:he,unpricedTokens:D.unpricedTokens,unpricedNote:y9(D.unpricedModels),calibrated:D.calibrated,reconciled:D.reconciled}},[c,h]),F=(H,D)=>{eo(H).then(W=>{E.current&&(window.clearTimeout(_.current),b({path:H,label:D,ok:W}),_.current=window.setTimeout(()=>{E.current&&b(null)},$9))})},O=H=>j!=null&&j.ok&&j.path===H?"Copied":"Copy",I=c!=null&&c.trackedSince?`Tracked since ${Dp(c.trackedSince)}`:"Tracking starts with this version",B=Gx(d),M=T9(d),$=k&&!!c;return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...A,role:"presentation",children:a.jsxs("div",{ref:T,className:"modal ap-proj-modal",onClick:H=>H.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-proj-title ap-proj-sub",children:[a.jsxs("header",{className:"ap-proj-head",children:[a.jsxs("div",{className:"ap-proj-titlewrap",children:[a.jsx("div",{className:"ap-proj-title",id:"ap-proj-title",children:"Projects"}),a.jsx("div",{className:"ap-proj-sub",id:"ap-proj-sub",title:t,children:t})]}),a.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:R9.map(H=>a.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":r===H.days,onClick:()=>s(H.days),children:H.label},H.days))}),a.jsx("button",{ref:R,className:"glyph-btn ap-proj-close",onClick:n,"aria-label":"Close",children:"×"})]}),a.jsxs("div",{className:`ap-proj-body${$?" refreshing":""}`,"aria-busy":k,children:[k&&!c&&a.jsx("div",{className:"ap-proj-state",children:"Loading…"}),!k&&x&&a.jsxs("div",{className:"ap-proj-state ap-proj-error",children:["Couldn’t load this report: ",x]}),!x&&L&&a.jsx(a.Fragment,{children:L.rows.length===0?a.jsxs("div",{className:"ap-proj-state",children:[$?"Updating…":C9(d),M!=null&&a.jsx("div",{className:"ap-proj-widen-wrap",children:a.jsxs("button",{type:"button",className:"ap-proj-copy",onClick:()=>s(M),children:["Show ",Gx(M)]})}),a.jsxs("div",{className:"ap-proj-note",children:[I,". Only work from this version onward can be tied to an account."]})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"ap-proj-bar",role:"img","aria-label":`Share of ${L.basis==="cost"?qe(L.totalCost):`${it(L.totalTokens)} tokens`} across ${L.projectCount} project${L.projectCount>1?"s":""}`,children:L.rows.map(H=>{const D=L.basis==="cost"?H.cost:H.tokens,W=L.denom>0?D/L.denom*100:0;if(W<=0)return null;const J=L.basis==="cost"?Pu(H.cost,L.totalCost):`${Pu(H.tokens,L.totalTokens)} of tokens`;return a.jsx("span",{className:"ap-proj-seg",style:{width:`${W}%`,background:H.color},title:`${H.label} · ${Or(H.cost,H.unpricedTokens)} · ${J}${H.tokens?` · ${it(H.tokens)} tokens`:""}`},H.key)})}),a.jsxs("div",{className:"ap-proj-totals",children:[a.jsx("span",{className:"ap-proj-total-cost",title:zo(L.unpricedTokens),children:Or(L.totalCost,L.unpricedTokens)}),a.jsxs("span",{className:"ap-proj-total-tok",children:[it(L.totalTokens)," tokens"]}),a.jsxs("span",{className:"ap-proj-total-win",children:["· ",$?"updating…":B]}),f&&a.jsx("span",{className:"ap-proj-total-pending",children:"Reconciling cost…"})]}),L.unpricedNote&&a.jsx("div",{className:"ap-proj-note",children:L.unpricedNote}),A9(d,L.chart.length)&&a.jsxs("div",{className:"ap-proj-days",children:[a.jsxs("div",{className:"ap-proj-days-cap",children:["By day",L.chart.length>1?" · click a bar":""]}),a.jsx("div",{className:"ap-proj-days-plot",role:"group","aria-label":`Spend across ${L.chart.length} day${L.chart.length>1?"s":""}`,children:L.chart.map(H=>{const D=L.maxDay>0?H.total/L.maxDay*100:0,W=p===H.day,J=L.rows.map(X=>({label:X.label,c:H.costByColor.get(X.color)??0,u:H.unpricedByColor.get(X.color)??0})).filter(X=>X.c>0||X.u>0),V=`${Dp(Date.parse(`${H.day}T00:00:00`))}, ${Or(H.total,H.unpriced)}. ${J.map(X=>`${X.label} ${Or(X.c,X.u)}`).join(", ")}`;return a.jsx("button",{type:"button",className:`ap-proj-day${W?" selected":""}`,"aria-pressed":W,"aria-label":V,title:`${H.day} · ${Or(H.total,H.unpriced)}`,onClick:()=>g(X=>X===H.day?null:H.day),children:a.jsx("span",{className:"ap-proj-col",style:{height:`${D}%`},children:L.colorOrder.map((X,Y)=>{const Z=H.costByColor.get(X)??0;return Z<=0||H.total<=0?null:a.jsx("span",{className:"ap-proj-colseg",style:{height:`${Z/H.total*100}%`,background:X}},Y)})})},H.day)})}),(()=>{const H=L9(L.chart.length);return a.jsx("div",{className:"ap-proj-days-axis","aria-hidden":"true",children:L.chart.map((D,W)=>a.jsx("div",{className:"ap-proj-axis-cell",children:H(W)?O9(D.day):""},D.day))})})(),(()=>{const H=p?L.chart.find(W=>W.day===p):null;if(!H)return null;const D=L.rows.map(W=>({r:W,c:H.costByColor.get(W.color)??0,u:H.unpricedByColor.get(W.color)??0})).filter(W=>W.c>0||W.u>0);return a.jsxs("div",{className:"ap-proj-day-detail",children:[a.jsxs("div",{className:"ap-proj-day-detail-head",children:[a.jsx("span",{children:Dp(Date.parse(`${H.day}T00:00:00`))}),a.jsx("span",{className:"ap-proj-day-detail-total",title:zo(H.unpriced),children:Or(H.total,H.unpriced)})]}),D.map(({r:W,c:J,u:V})=>a.jsxs("div",{className:"ap-proj-day-detail-row",children:[a.jsx("span",{className:"ap-proj-dot",style:{background:W.color},"aria-hidden":"true"}),a.jsx("span",{className:"ap-proj-day-detail-name",children:W.label}),a.jsx("span",{className:"ap-proj-day-detail-cost",title:zo(V),children:Or(J,V)})]},W.key))]})})()]}),a.jsx("ul",{className:"ap-proj-list",children:L.rows.map((H,D)=>{const W=L.basis==="cost"?H.cost:H.tokens,J=L.denom>0?W/L.denom*100:0,V=v.has(H.key),X=`ap-proj-details-${D}`,Y=V&&(!!H.path||!!H.members),Z=H.members?`${V?"Hide":"Show"} the ${H.members.length} project${H.members.length>1?"s":""} folded into Other`:`${V?"Hide":"Show"} location for ${H.label}`;return a.jsxs("li",{className:`ap-proj-row${H.muted?" muted":""}${V?" expanded":""}`,children:[a.jsx("span",{className:"ap-proj-dot",style:{background:H.color},"aria-hidden":"true"}),a.jsxs("span",{className:"ap-proj-name",children:[H.label,H.parentLabel&&a.jsxs("span",{className:"ap-proj-parent",children:[" · in ",H.parentLabel]})]}),a.jsx("span",{className:"ap-proj-track",title:L.basis==="cost"?`${Pu(H.cost,L.totalCost)} of tracked cost`:`${Pu(H.tokens,L.totalTokens)} of tracked tokens`,children:a.jsx("span",{className:"ap-proj-fill",style:{width:`${J}%`,background:H.color}})}),a.jsx("span",{className:"ap-proj-cost",title:zo(H.unpricedTokens),children:Or(H.cost,H.unpricedTokens)}),a.jsx("span",{className:"ap-proj-tok",children:it(H.tokens)}),a.jsx("button",{type:"button",className:"glyph-btn ap-proj-info","aria-expanded":V,"aria-controls":Y?X:void 0,"aria-label":Z,onClick:()=>N(ee=>{const ne=new Set(ee);return ne.has(H.key)?ne.delete(H.key):ne.add(H.key),ne}),children:"ⓘ"}),V&&H.path&&a.jsxs("div",{className:"ap-proj-details",id:X,children:[a.jsx("code",{className:"ap-proj-path",children:gS(H.path)}),a.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${O(H.path)} location for ${H.label}`,onClick:()=>F(H.path,H.label),children:O(H.path)})]}),V&&H.members&&a.jsx("div",{className:"ap-proj-details ap-proj-other-members",id:X,children:H.members.map(ee=>a.jsxs("div",{className:"ap-proj-other-member",children:[a.jsxs("div",{className:"ap-proj-other-name",children:[ee.label,ee.parentLabel&&a.jsxs("span",{className:"ap-proj-parent",children:[" · in ",ee.parentLabel]})]}),a.jsx("code",{className:"ap-proj-path",children:gS(ee.path)}),a.jsx("span",{className:"ap-proj-cost",title:zo(ee.unpricedTokens),children:Or(ee.cost,ee.unpricedTokens)}),a.jsx("span",{className:"ap-proj-tok",children:it(ee.tokens)}),a.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${O(ee.path)} location for ${ee.label}`,onClick:()=>F(ee.path,ee.label),children:O(ee.path)})]},ee.path))})]},H.key)})}),L.un&&a.jsxs("div",{className:"ap-proj-unattributed",children:[a.jsx("span",{className:"ap-proj-dot",style:{background:M9},"aria-hidden":"true"}),a.jsxs("div",{className:"ap-proj-un-labels",children:[a.jsx("span",{className:"ap-proj-un-title",children:"Unattributed usage"}),a.jsx("span",{className:"ap-proj-un-tag",children:"Excluded from the project totals"})]}),a.jsx("span",{className:"ap-proj-un-cost",title:zo(L.un.unpricedTokens),children:Or(L.un.cost,L.un.unpricedTokens,I9)}),a.jsx("span",{className:"ap-proj-un-tok",children:it(L.un.tokens)}),a.jsx("div",{className:"ap-proj-note",children:"Work no account could be tied to — from before tracking, or a gap."})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:j&&(j.ok?`Copied the location of ${j.label}`:`Could not copy the location of ${j.label} — select it and copy it by hand`)}),a.jsxs("div",{className:"ap-proj-foot",children:[f?"Dollars estimated · ccusage still running":L.reconciled?"Dollars from ccusage · split by activity":L.calibrated?"Dollars from ccusage for the priced models · split by activity":h?"Dollars estimated · ccusage could not price this window":"Dollars estimated · ccusage unavailable"," · ",I]})]})})]})]})}),document.body)}function yi(e,t){return U$(t-Math.floor(e/1e3))}function D9(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 p0(){return a.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:[a.jsx("path",{d:"M7 1.9 12.9 12H1.1Z"}),a.jsx("path",{d:"M7 5.6v2.9"}),a.jsx("path",{d:"M7 10.3v.05"})]})}function F9({anchorId:e,boundaryId:t,issue:n,who:r,fetchedAt:s,nowSec:o,onClose:l,onSignIn:c,onReport:d}){const h=y.useRef(null);return a.jsx(ch,{anchorId:e,boundaryId:t,id:"ap-issue-pop",className:"ap-pop ap-issue-pop",role:"dialog",labelledBy:"ap-issue-title",focusRef:h,onClose:()=>l(),children:a.jsxs("div",{className:"ap-pop-form",children:[a.jsxs("p",{className:"ap-pop-title ap-issue-title",id:"ap-issue-title","data-tone":n.tone,children:[n.tone==="warn"&&a.jsx(p0,{}),n.text]}),a.jsx("p",{className:"ap-pop-note ap-issue-hint",children:n.hint}),a.jsxs("p",{className:"ap-pop-note ap-issue-when",children:[a.jsx("span",{className:"ap-issue-who",children:r})," · ",s?`last collected ${yi(s,o)}`:"never collected"]}),a.jsxs("div",{className:"ap-pop-actions",children:[d&&a.jsx("button",{type:"button",className:"ap-issue-report",onClick:()=>{l(),d()},children:"Report this"}),a.jsx("button",{type:"button",ref:h,className:"btn",onClick:()=>l(!0),children:"Done"}),n.fix&&a.jsx("button",{type:"button",className:"btn primary",onClick:()=>{l(!0),c()},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:n.fix})]})]})})}function Sl(e){return e.charAt(0).toUpperCase()+e.slice(1)}function B9(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)),s=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} ${s} It tries again in ${r}m. No sign-in, no switch.`}}return{text:"numbers paused",hint:n}}function q9(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 U9(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.`}}}const yS={text:"Login expired on all online decks",hint:"Every paired deck online right now that shares this account holds a copy that has expired too, so none of them can repair this one. Claude retires a login's other copies each time one machine refreshes it, which is how shared copies expire together. Sign in again on any one machine; the others repair from it on their next round."};function wi(e,t,n){const r=W9(e,t);return!r||!(n!=null&&n.noCopyWorksNearby)||!z9(e)?r:{...r,text:yS.text,hint:yS.hint}}function z9(e){return e.staleCopy?!1:e.stopped?e.collector==="relogin_required":e.error==="invalid_grant"||e.error==="no_refresh_token"}function W9(e,t){if(e.staleCopy){const n=B9(e.repair??null,t);return{text:Sl(n.text),hint:n.hint,fix:null,tone:"quiet",blocksSwitch:!1}}if(e.stopped){const n=U9(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:Sl(n.text),hint:n.hint,fix:n.fix?Sl(n.fix):null,tone:r||e.collector==="keychain_unavailable"?"warn":"quiet",blocksSwitch:r}}if(e.error){const n=q9(e.error);return{text:Sl(n.text),hint:n.hint,fix:n.fixable?"Sign in again":null,tone:n.fixable?"warn":"quiet",blocksSwitch:n.fixable}}return null}function wS(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function vS(e){const t=e.filter(c=>!wS(c)),n=e.filter(c=>wS(c)),r=t.length?t:n,s=t.length?n:[],o=r.reduce((c,d)=>c&&c.pct>=d.pct?c:d,null);let l=null;for(const c of s)o&&c.pct<=o.pct||(!l||c.pct>l.pct)&&(l=c);return{shown:r,rest:s,fuller:l,peak:l??o}}function Zl(e,t){return!!e.resetAt&&e.resetAt<=t}function m0(e,t){const n=e.lanes??[],r=n.filter(s=>!Zl(s,t));return r.length===n.length?e.headroom:r.length?Math.max(0,100-Math.max(...r.map(s=>s.pct))):null}const H9="\0";function Lr(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}${H9}${n}`}function V9(e,t,n=Lr){const r=n(t);return e.includes(r)?e.filter(s=>s!==r):[...e,r]}const uh="slot",g0=[{lane:"five_hour",name:"5h"},{lane:"seven_day",name:"7d"}],vI=e=>e.id.startsWith("scoped-");function G9(e){var t;return((t=g0.find(n=>n.lane===e.id))==null?void 0:t.name)??e.label}function K9(e){if(e==="room")return"room";const t=/^(.+):(full|empty)$/.exec(e);return t?t[1]:null}function xI(e){const t=[...new Set(e.flatMap(r=>(r.lanes??[]).filter(vI).map(s=>s.label)))].sort((r,s)=>r.localeCompare(s)),n=[...g0.map(r=>r.name),...t];return[{id:uh,label:"Slot"},...n.flatMap(r=>[{id:`${r}:full`,label:`${r} · fullest`},{id:`${r}:empty`,label:`${r} · emptiest`}]),{id:"room",label:"Most room"}]}function xS(e,t,n){const r=g0.find(o=>o.name===t),s=(e.lanes??[]).find(o=>r?o.id===r.lane:vI(o)&&o.label===t);return s&&n!=null&&Zl(s,n)?null:s&&Number.isFinite(s.pct)?s.pct:null}function Y9(e,t,n=()=>!0,r){const s=[...e],o=f=>[...f.filter(n),...f.filter(p=>!n(p))];if(t==="room"){const f=p=>r==null?p.headroom:m0(p,r);return o(bS(s,p=>{const g=f(p);return Number.isFinite(g)?g:null},"desc"))}const l=/^(.+):(full|empty)$/.exec(t);if(!l)return s;const[,c,d]=l;if(!s.some(f=>xS(f,c,r)!=null))return s;const h=bS(s,f=>xS(f,c,r),d==="full"?"desc":"asc");return d==="empty"?o(h):h}function bS(e,t,n){const r=e.filter(o=>t(o)!=null),s=e.filter(o=>t(o)==null);return r.sort((o,l)=>n==="desc"?t(l)-t(o):t(o)-t(l)),[...r,...s]}function X9(e,t){return xI(t).some(n=>n.id===e)?e:uh}function Kx(e,t){if(!t)return[...e];const n=new Map(t.map((o,l)=>[o,l])),r=e.filter(o=>n.has(Lr(o))).sort((o,l)=>n.get(Lr(o))-n.get(Lr(l))),s=e.filter(o=>!n.has(Lr(o)));return[...r,...s]}function y0(e){const t=Lr(e);return t.startsWith("slot:")?t:`h:${Z9(t)}`}function Z9(e){let t=3735928559,n=1103547991;for(let r=0;r<e.length;r++){const s=e.charCodeAt(r);t=Math.imul(t^s,2654435761),n=Math.imul(n^s,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),(4294967296*(2097151&n)+(t>>>0)).toString(36)}const Yx={mode:"some",keys:[]};function bI(e,t){const n=e.keys.includes(y0(t));return e.mode==="all"?!n:n}function J9(e,t){return{mode:e.mode,keys:V9(e.keys,t,y0)}}function kI(e,t){return t.length>0&&t.every(n=>bI(e,n))}function Q9(e,t){return kI(e,t)?Yx:{mode:"all",keys:[]}}function eV(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(y0)),r=e.keys.filter(s=>n.has(s));return r.length===e.keys.length?e:{mode:e.mode,keys:r}}function tV(e){return e>=90?"hi":e>=70?"mid":void 0}function nV({lane:e,nowSec:t,frozen:n,sortedBy:r}){const s=Math.min(100,Math.max(0,e.pct)),o=Zl(e,t),l=n||o,c=l?"var(--muted)":s>=90?"var(--err)":s>=70?"var(--warn)":"var(--accent)",d=e.resetAt&&!l?nh(e.resetAt,t):null;return a.jsxs("div",{className:"ap-lane","data-sort-key":r?"":void 0,children:[a.jsx("span",{className:"ap-lane-label",title:e.label,children:e.label}),a.jsx("div",{className:"ap-lane-track",children:a.jsx("div",{className:"ap-lane-fill",style:{width:`${s===0?1.5:s}%`,background:c,opacity:s===0||l?.4:1}})}),a.jsxs("span",{className:"ap-lane-pct",style:{color:c},children:[Math.round(s),"%"]}),a.jsxs("span",{className:"ap-lane-reset",title:d?`${e.label} resets in ${d}`:o&&!n?`${e.label} has reset since this reading`:void 0,children:[d&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"vis-hidden",children:"resets in "}),d]}),o&&!n&&"reset"]})]})}function rV({a:e,nowSec:t,lan:n,opened:r,onToggleLanes:s,busy:o,pressProps:l,onSwitch:c,menuOpen:d,onOpenMenu:h,onCloseMenu:f,refusal:p,onDismissRefusal:g,switchedHere:v,swapped:N,displaced:k,issueExpanded:x,onOpenIssue:j,sortKey:b=null}){const _=e.lanes.filter(M=>!Zl(M,t)),{shown:E}=vS(e.lanes),{fuller:R}=vS(_),T=b==="room"?_.reduce((M,$)=>M&&M.pct>=$.pct?M:$,null):b?e.lanes.find(M=>G9(M)===b)??null:null,A=wi(e,t,n),U=e.active||r,L=e.alias??e.email??`account ${e.num}`,F=e.alias&&e.email?`${e.alias} · ${e.email}`:L,O=e.stale||(A==null?void 0:A.blocksSwitch)===!0,I=R?[...E,R]:E,B=e.fetchedAt?yi(e.fetchedAt,t):null;return a.jsxs("li",{className:`ap-account${e.active?" active":""}`,"aria-current":e.active?"true":void 0,"data-open":U?"":void 0,"data-frozen":O?"":void 0,children:[!e.active&&a.jsx("button",{type:"button",className:"ap-row-open",id:`ap-row-${e.num}`,title:F,"aria-expanded":U,"aria-controls":U?`ap-detail-${e.num}`:void 0,"aria-describedby":[e.alias&&e.email?`ap-email-${e.num}`:null,!U&&!(A!=null&&A.blocksSwitch)?`ap-quota-${e.num}`:null].filter(Boolean).join(" ")||void 0,onClick:()=>s(),children:a.jsxs("span",{className:"vis-hidden",children:[L,", ",U?"hide details":"details"]})}),a.jsxs("div",{className:"ap-account-head",children:[e.active?a.jsx("span",{className:"ap-live",title:`Active account · slot ${e.num}`,children:a.jsxs("span",{className:"vis-hidden",children:["Active account, slot ",e.num,":"]})}):a.jsx("span",{className:"ap-num",children:e.num}),e.alias&&a.jsx("span",{className:"ap-alias",title:e.alias,children:e.alias}),a.jsx("span",{className:"ap-email",id:`ap-email-${e.num}`,title:e.email??void 0,children:e.email}),e.disabled&&a.jsx("span",{className:"ap-held",children:"held out"}),!e.active&&!e.disabled&&!(A!=null&&A.blocksSwitch)&&a.jsx("button",{type:"button",className:"ap-switch",...l(`switch-${e.num}`),onClick:()=>c(e.num,L),"aria-label":`Switch to ${L}`,title:`Switch to ${e.alias??e.email}`,children:o===`switch-${e.num}`?"…":"Switch"}),a.jsx("button",{type:"button",id:`ap-more-${e.num}`,className:"ap-more","aria-label":`More actions for ${e.email??e.alias??`account ${e.num}`}`,"aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?`ap-menu-${e.num}`:void 0,title:"More actions",onClick:()=>d?f():h(e.num),onKeyDown:M=>{M.key!=="ArrowDown"&&M.key!=="ArrowUp"||(M.preventDefault(),h(e.num,M.key==="ArrowUp"?"last":"first"))},children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"currentColor","aria-hidden":!0,children:[a.jsx("circle",{cx:"2.8",cy:"7",r:"1.15"}),a.jsx("circle",{cx:"7",cy:"7",r:"1.15"}),a.jsx("circle",{cx:"11.2",cy:"7",r:"1.15"})]})})]}),p&&a.jsxs("div",{className:"ap-failure ap-row-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",title:p.raw||void 0,children:p.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>g(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),e.active&&v&&a.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."}),N&&(()=>{const M=(k==null?void 0:k.alias)??(k==null?void 0:k.email)??"the account that was there";return a.jsxs("p",{className:"ap-note ap-swap-note",title:`Slot ${N.at} was taken, so the two accounts traded places: ${M} now holds slot ${N.displaced}.`,children:["swapped with slot ",N.displaced]})})(),A&&a.jsxs("div",{className:"ap-issue-line",children:[a.jsxs("button",{type:"button",id:`ap-issue-${e.num}`,className:"ap-issue","data-tone":A.tone,"aria-haspopup":"dialog","aria-expanded":x,"aria-controls":x?"ap-issue-pop":void 0,onClick:()=>j(e.num,`ap-issue-${e.num}`),children:[A.tone==="warn"&&a.jsx(p0,{}),a.jsx("span",{className:"ap-issue-text",children:A.text})]}),!U&&a.jsx("span",{className:"ap-issue-age",title:"When claude-swap last read this account's usage",children:B??"never collected"})]}),!U&&!(A!=null&&A.blocksSwitch)&&a.jsxs("p",{className:"ap-quota",id:`ap-quota-${e.num}`,children:[I.length?I.map(M=>a.jsxs("span",{className:"ap-q","data-sort-key":M.id===(T==null?void 0:T.id)?"":void 0,children:[a.jsx("span",{className:"ap-q-label",children:M.label})," ",Zl(M,t)?a.jsx("span",{className:"ap-q-pct",title:`${M.label} has reset since this reading`,children:"reset"}):a.jsxs("span",{className:"ap-q-pct","data-level":O?void 0:tV(M.pct),children:[Math.round(M.pct),"%"]})]},M.id)):a.jsx("span",{className:"ap-q-label",children:"no usage recorded yet"}),e.stale&&!A&&a.jsx("span",{className:"ap-q-age","data-never":B?void 0:"",title:"When claude-swap last read this account's usage",children:B??"never collected"})]}),U&&a.jsxs("div",{className:"ap-detail",id:`ap-detail-${e.num}`,children:[a.jsx("div",{className:"ap-lanes",children:e.lanes.length?e.lanes.map(M=>a.jsx(nV,{lane:M,nowSec:t,frozen:O,sortedBy:M.id===(T==null?void 0:T.id)},M.id)):a.jsx("div",{className:"ap-hint",children:"No usage recorded yet."})}),a.jsx("div",{className:"ap-meta",children:e.fetchedAt?a.jsxs("span",{className:`ap-age${e.stale&&!A?" 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 ",yi(e.fetchedAt,t),A!=null&&A.blocksSwitch?"":D9(e.nextAt,t)]}):a.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})})]})]})}function sV({data:e}){return a.jsx("div",{className:"ap-empty",children:e.reason==="cswap_installing"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"Installing claude-swap…"}),a.jsx("span",{className:"ap-hint",children:"The deck is setting it up in the background, so there is nothing to do here. On a new machine this can take a few minutes; the panel fills in by itself when it is done."})]}):e.reason==="no_cswap"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"claude-swap isn't installed."}),a.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."}),e.hint&&a.jsx("code",{className:"ap-cmd",children:e.hint}),a.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",a.jsx("strong",{children:"+"})," button above."]})]}):e.reason==="cswap_refused"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"claude-swap was installed, but not the version the deck asked for."}),a.jsxs("span",{className:"ap-hint",children:[e.version?`v${e.version} answered`:"A different version answered",e.want?` where ${e.want} was asked for`:"",", so the deck is not driving it. Install the version it asked for, or set AGENTS_DECK_CSWAP to a claude-swap you trust."]})]}):e.reason==="no_accounts"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"No accounts added yet."}),a.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",a.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"Couldn't read the account store."}),a.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",e.reason?` (${e.reason})`:"","."]})]})})}function aV({canShare:e,canReport:t,onAdd:n,onReport:r,onShareSet:s,onReload:o,pressProps:l,reloading:c,closeButton:d}){return a.jsxs("div",{className:"ap-header",children:[a.jsx("h2",{children:"Claude accounts"}),a.jsxs("div",{className:"ap-header-right",children:[a.jsx("button",{type:"button",className:"glyph-btn ap-add",onClick:()=>n(),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:a.jsx("path",{d:"M7 2.2v9.6M2.2 7h9.6"})})}),t&&a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>r(),"aria-label":"Account capacity","aria-haspopup":"dialog",title:"Account capacity — how many accounts are ready, and what the 5h and 7d windows have left",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M2.5 10.9A5.2 5.2 0 1 1 11.5 10.9"}),a.jsx("path",{d:"M7 8.3l2.1-2.1"})]})}),e&&a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>s(),"aria-label":"Share accounts with another deck",title:`Copy several accounts to another ${kt} in one paste. The text carries a live login for each one — treat it as those passwords.`,children:a.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:[a.jsx("path",{d:"M3.3 10.7L10.7 3.3"}),a.jsx("path",{d:"M5.5 3.3h5.2v5.2"})]})}),a.jsx("button",{type:"button",className:"glyph-btn ap-refresh",onClick:()=>o(),...l("reload",c),"aria-label":"Reload accounts",title:"Reload from claude-swap",children:a.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:[a.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),a.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}),d]})]})}const Va=[{id:"five_hour",label:"5h",long:"5-hour"},{id:"seven_day",label:"7d",long:"7-day"}];function kS(e){return e.counted?e.pct:e.why==="login"?null:e.estimate}function oV(e){const t=kS(e.five_hour),n=kS(e.seven_day);if(t==null||n==null)return"stale";const r=+(t>=100)+ +(n>=100);return r===0?"ready":r===1?"limited":"exhausted"}function iV(e,t){const n=Va.map(r=>e.cells[r.id]);for(const r of n)if(!r.counted&&(r.why==="login"||r.why==="none"))return{text:r.say,old:!0};return e.updatedAt==null?{text:"never read",old:!0}:n.every(r=>r.counted)?{text:"now",old:!1}:{text:yi(e.updatedAt,t),old:!0}}const lV=15*6e4,cV=e=>e.alias??e.email??`account ${e.num}`;function NS(e,t,n){const r=Va.find(f=>f.id===t).label,s=(e.lanes??[]).find(f=>f.id===t),o=s&&Number.isFinite(s.pct)?uV(s.pct):null,l=wi(e,n),c=(s==null?void 0:s.resetAt)!=null&&s.resetAt<=n,d=(f,p)=>({counted:!1,why:f,say:p,last:o,estimate:o==null?null:c?0:o,resetAt:c?null:(s==null?void 0:s.resetAt)??null});return l!=null&&l.blocksSwitch?d("login",l.text):o==null?d("none",`No ${r} reading`):e.stale||e.fetchedAt==null||n*1e3-e.fetchedAt>lV?d("stale",e.fetchedAt?`Updated ${yi(e.fetchedAt,n)}`:"Never read"):c?d("reset",`Reset ${yi(s.resetAt*1e3,n)}, not updated`):{counted:!0,pct:o,resetAt:s.resetAt}}const uV=e=>Math.min(100,Math.max(0,e));function dV(e,t){const n=Va.find(h=>h.id===t);let r=0,s=0,o=0;const l=[];for(const h of e){const f=h.cells[t],p=f.counted?f.pct:f.estimate;p!=null&&(r+=p,o++,f.counted&&s++,f.resetAt!=null&&l.push({at:f.resetAt,name:h.name,pct:p}))}const c=l.reduce((h,f)=>!h||f.at<h.at?f:h,null),d=c&&{...c,more:l.filter(h=>h!==c&&h.at-c.at<60).length};return{id:t,label:n.label,long:n.long,reporting:s,included:o,total:e.length,used:o?r/o:null,nextReset:d}}function NI(e,t){const n=e.map(s=>{const o={five_hour:NS(s,"five_hour",t),seven_day:NS(s,"seven_day",t)};return{num:s.num,key:Lr(s),name:cV(s),active:s.active,heldOut:s.disabled===!0,cells:o,status:oV(o),updatedAt:s.fetchedAt??null}}),r=n.filter(s=>s.status==="ready").length;return{rows:n,windows:Va.map(s=>dV(n,s.id)),roomInBoth:r}}function Du(e,t){return(e==null?void 0:e.key)===t?{key:t,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:"asc"}}const hV={ready:0,limited:1,exhausted:2,stale:3};function fV(e){return e.counted?e.pct:e.last}function jS(e,t){return t==="status"?hV[e.status]:t==="updated"?e.updatedAt==null?null:-e.updatedAt:fV(e.cells[t])}function pV(e,t){if(!t)return[...e];const n=t.dir==="asc"?1:-1,r=new Map(e.map((o,l)=>[o.num,l])),s=(o,l)=>{if(t.key==="account")return n*o.name.localeCompare(l.name,void 0,{sensitivity:"base"});const c=jS(o,t.key),d=jS(l,t.key);return c==null||d==null?c==null?d==null?0:1:-1:n*(c-d)};return[...e].sort((o,l)=>s(o,l)||r.get(o.num)-r.get(l.num))}function Sd(e){return e>=100?100:Math.min(99,Math.round(e))}function mV(e){const t=Sd(e);return{used:t,available:100-t}}function gV(e,t,n){return e?`${e} These are the last readings.`:t&&n?"The account store could not be read just now. These are the last readings.":null}function jI(e){return e>=90?"hi":e>=70?"mid":void 0}const SI=(e,t,n)=>`${e} ${e===1?t:n}`;function SS(e){const t=e.more>0?`, and ${SI(e.more,"more account","more accounts")} in the same minute`:"";return`First: ${e.name} (${Sd(e.pct)}% used)${t}`}function yV({w:e,nowSec:t}){const n=`ap-report-${e.id}`,r=e.total-e.included,s=r>0&&a.jsxs("p",{className:"ap-report-basis",children:[r," never read"]}),{used:o,available:l}=mV(e.used??0),c=Math.round(Da(l,{countIn:!0}));if(e.used==null)return a.jsxs("section",{className:"ap-report-sum","aria-labelledby":n,children:[a.jsxs("h3",{className:"ap-report-win",id:n,children:[e.long," window"]}),a.jsxs("p",{className:"ap-report-none",children:["No account has a ",e.long," reading yet."]}),s]});const d=e.nextReset?nh(e.nextReset.at,t):null;return a.jsxs("section",{className:"ap-report-sum","aria-labelledby":n,children:[a.jsxs("h3",{className:"ap-report-win",id:n,children:[e.long," window"]}),a.jsxs("p",{className:"ap-report-left",children:[a.jsxs("b",{children:[c,"%"]})," remaining"]}),a.jsx("div",{className:"ap-report-meter","data-level":jI(o),"aria-hidden":!0,children:a.jsx("i",{style:{"--left":l/100}})}),d&&e.nextReset&&a.jsxs("p",{className:"ap-report-reset",title:SS(e.nextReset),children:[a.jsxs("span",{children:["Next reset in ",a.jsx("span",{className:"ap-report-num",children:d})]}),a.jsx("span",{"aria-hidden":!0,children:"·"}),a.jsx("span",{className:"ap-report-who",children:e.nextReset.name}),e.nextReset.more>0&&a.jsxs("span",{className:"ap-report-more",children:["+",e.nextReset.more]}),a.jsxs("span",{className:"vis-hidden",children:[". ",SS(e.nextReset)]})]}),s]})}function wV({cell:e,nowSec:t}){if(!e.counted)return a.jsxs("td",{className:"ap-report-cell","data-uncounted":"",children:[a.jsx("span",{className:"ap-report-pct",children:e.last==null?a.jsxs(a.Fragment,{children:[a.jsx("span",{"aria-hidden":!0,children:"—"}),a.jsx("span",{className:"vis-hidden",children:"no reading"})]}):`${Sd(e.last)}%`}),a.jsx("span",{className:"vis-hidden",children:", not counted"})]});const n=e.resetAt!=null?nh(e.resetAt,t):null;return a.jsxs("td",{className:"ap-report-cell",children:[a.jsxs("span",{className:"ap-report-pct","data-level":jI(e.pct),children:[Sd(e.pct),"%"]}),n&&a.jsxs("span",{className:"ap-report-in",children:[a.jsx("span",{className:"vis-hidden",children:"resets in "}),n]})]})}const vV={ready:"Ready",limited:"Limited",exhausted:"Exhausted",stale:"Stale"};function xV({row:e}){return a.jsx("td",{className:"ap-report-state","data-status":e.status,children:a.jsxs("span",{className:"ap-report-state-word",children:[a.jsx("i",{"aria-hidden":!0}),vV[e.status]]})})}function bV({row:e,nowSec:t}){const n=iV(e,t);return a.jsx("td",{className:"ap-report-upd","data-old":n.old?"":void 0,children:n.text})}function kV(){return a.jsxs("svg",{className:"ap-report-how-mark",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":!0,focusable:"false",children:[a.jsx("circle",{cx:"8",cy:"8",r:"6.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),a.jsx("path",{d:"M8 7.2v4.1M8 4.8v.1",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}function NV({accounts:e,nowSec:t,held:n,sort:r=null,onSort:s=()=>{}}){const o=NI(e,t),l=o.rows.length,c=Math.round(Da(o.roomInBoth,{countIn:!0}));return a.jsxs("div",{className:"ap-proj-body ap-report-body",role:"region","aria-label":"Report",children:[n&&a.jsx("p",{className:"ap-report-held",children:n}),a.jsxs("p",{className:"ap-report-lead",children:[a.jsx("b",{children:c})," of ",SI(l,"Claude account","Claude accounts")," ready"]}),a.jsx("div",{className:"ap-report-sums",children:o.windows.map(d=>a.jsx(yV,{w:d,nowSec:t},d.id))}),a.jsxs("table",{className:"ap-report-table",children:[a.jsx("caption",{className:"vis-hidden",children:"Each account's use of each window, and what it can do now"}),a.jsxs("colgroup",{children:[a.jsx("col",{}),Va.map(d=>a.jsx("col",{className:"ap-report-col-win"},d.id)),a.jsx("col",{className:"ap-report-col-state"}),a.jsx("col",{className:"ap-report-col-upd"})]}),a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx(jl,{col:"account",label:"Account",sort:r,next:Du,onSort:s}),Va.map(d=>a.jsx(jl,{col:d.id,label:`${d.label} used`,sort:r,next:Du,onSort:s},d.id)),a.jsx(jl,{col:"status",label:"Status",sort:r,next:Du,onSort:s}),a.jsx(jl,{col:"updated",label:"Updated",className:"ap-report-upd-h",sort:r,next:Du,onSort:s})]})}),a.jsx("tbody",{children:o.rows.map((d,h)=>a.jsxs("tr",{"data-active":d.active?"":void 0,style:{"--row":h},children:[a.jsx("th",{scope:"row",className:"ap-report-acct",children:a.jsxs("span",{className:"ap-report-acct-in",children:[a.jsx("span",{className:"ap-report-name",title:d.name,children:d.name}),d.active&&a.jsx("span",{className:"ap-report-current",children:"Current"}),d.heldOut&&a.jsx("span",{className:"ap-report-tag",children:"held out"})]})}),Va.map(f=>a.jsx(wV,{cell:d.cells[f.id],nowSec:t},f.id)),a.jsx(xV,{row:d}),a.jsx(bV,{row:d,nowSec:t})]},d.num))})]}),a.jsxs("details",{className:"ap-report-how",children:[a.jsxs("summary",{children:[a.jsx(kV,{}),"How usage is calculated"]}),a.jsxs("div",{className:"ap-report-how-body",children:[a.jsxs("p",{children:["Every account here, at its last reading: ",a.jsx("b",{children:"used"})," is their average, and ",a.jsx("b",{children:"remaining"})," is the rest."]}),a.jsxs("p",{children:[a.jsx("b",{children:"Ready"})," has room in both windows. ",a.jsx("b",{children:"Limited"})," is at the limit of one, and ",a.jsx("b",{children:"Exhausted"})," of both. ",a.jsx("b",{children:"Stale"})," was never read, or is signed out."]})]})]})]})}function jV({accounts:e,order:t,failed:n,nowSec:r,onClose:s}){const o=y.useRef(null),l=ut(s,{focusRef:o}),c=gt(s),[d,h]=y.useState(e??[]);y.useEffect(()=>{e&&e.length>0&&h(e)},[e]);const f=gV(n,!e||e.length===0,d.length>0),[p,g]=y.useState(null),v=Kx(d,(p==null?void 0:p.order)??t),N=k=>{const x=NI(Kx(d,t),r).rows;g({sort:k,order:pV(x,k).map(j=>j.key)})};return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...c,role:"presentation",children:a.jsxs("div",{ref:l,className:"modal ap-report-modal",onClick:k=>k.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-report-title",children:[a.jsxs("header",{className:"ap-proj-head",children:[a.jsx("div",{className:"ap-proj-titlewrap",children:a.jsx("h2",{className:"ap-proj-title",id:"ap-report-title",children:"Account capacity"})}),a.jsx("button",{ref:o,type:"button",className:"glyph-btn ap-proj-close",onClick:s,"aria-label":"Close",children:"×"})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:f??""}),a.jsx(NV,{accounts:v,nowSec:r,held:f,sort:(p==null?void 0:p.sort)??null,onSort:N})]})}),document.body)}const Fp=[70,80,85,90,95];function SV(e){const t=Number(e);return[...Number.isFinite(t)&&t>0&&!Fp.includes(t)?[...Fp,t]:Fp].sort((r,s)=>r-s)}function _V({auto:e,threshold:t,thresholdPick:n,thresholdCtl:r,thresholdSaved:s,thresholdRef:o,thresholdSaveRef:l,proposeThreshold:c,doThreshold:d,pressProps:h,post:f,load:p}){return a.jsxs("div",{className:"ap-policy-block",children:[a.jsxs("div",{className:"ap-policy",children:[a.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),a.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:a.jsx("select",{ref:o,"aria-label":"Switch threshold",value:n,...h("threshold"),onChange:g=>c(g.target.value),children:SV(t).map(g=>a.jsxs("option",{value:g,children:[g,"%"]},g))})}),(r.sends||s)&&a.jsx("button",{ref:l,type:"button",className:"ap-manage-btn",...h("threshold"),title:r.title,onClick:()=>d(n,r),children:s&&!r.sends?r.done:r.label}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":e.enabled,"aria-label":"Auto-switch",...h("enable"),onClick:()=>f({action:"enable",enabled:!e.enabled},"enable").then(()=>p(!0)),title:e.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:a.jsx("span",{className:"switch-knob"})})]}),e.external&&a.jsxs("p",{className:"ap-auto-note",children:[a.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",a.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",e.enabled?" — this toggle takes over when you stop it.":"."]})]})}const _S=18,EV=1100,Ho=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},CV=Array.from({length:_S},(e,t)=>{const n=-72+144*t/(_S-1)+(Ho(t,1)-.5)*9,r=(n-90)*(Math.PI/180),s=(54+32*Math.cos(n*Math.PI/180))*(.74+Ho(t,2)*.52);return{dx:Math.cos(r)*s,dy:Math.sin(r)*s,rot:(t%2?1:-1)*(100+Ho(t,3)*260),delay:Math.round(Ho(t,4)*90),dur:760+Math.round(Ho(t,5)*260),scale:.8+Ho(t,6)*.45,hue:t%4,round:t%3===0}});function ES({anchor:e}){var s;const[t,n]=y.useState(null),r=typeof window<"u"&&((s=window.matchMedia)==null?void 0:s.call(window,"(prefers-reduced-motion: reduce)").matches);return y.useEffect(()=>{if(r)return;const o=e.current;if(!o)return;const l=o.getBoundingClientRect();n({x:l.left+l.width/2,y:l.top+l.height/2});const c=window.setTimeout(()=>n(null),EV);return()=>window.clearTimeout(c)},[e,r]),r||!t?null:Lt.createPortal(a.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:CV.map((o,l)=>a.jsx("span",{className:`confetti-bit${o.round?" round":""}`,"data-hue":o.hue,style:{"--dx":`${o.dx.toFixed(1)}px`,"--dy":`${o.dy.toFixed(1)}px`,"--rot":`${o.rot}deg`,"--s":o.scale.toFixed(2),animationDelay:`${o.delay}ms`,animationDuration:`${o.dur}ms, ${o.dur}ms`}},l))}),document.body)}const _d=y.forwardRef((e,t)=>a.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[a.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),a.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));_d.displayName="SuccessMark";const _I=new Set(["awaiting_url","awaiting_code","registering"]);function EI(e){return e!=null&&_I.has(e)}function CI(e){return e!=null&&e!=="done"&&!_I.has(e)}const TV="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",AV="the sign-in did not complete";function RV({state:e,serverError:t,localError:n}){const r=e==="idle";return{title:r?"Sign-in ended":"Sign-in failed",message:n||t||(r?TV:AV)}}function MV({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 $V({started:e,state:t}){return!e||t==="done"?null:{action:"login-cancel"}}function IV({login:e,started:t,loginError:n,loginBusy:r}){return(e==null?void 0:e.state)==="done"&&e.account?"done":(e==null?void 0:e.state)==="awaiting_code"||(e==null?void 0:e.state)==="registering"?"code":CI(e==null?void 0:e.state)||n&&t&&!r?"ended":r||EI(e==null?void 0:e.state)?"asking":"primer"}const OV="done";function LV(){let e=!1;return{shouldAnnounce(t){return t!==OV?(e=!1,!1):e?!1:(e=!0,!0)}}}function w0(e,t){return t?Ot(e,t):void 0}const PV={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 ${kt}`,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"},DV={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"},v0=`claude-swap could not read the login keychain — start ${kt} from a Terminal window rather than a background service`,FV={unreadable_here:{short:"Keychain locked on this Mac",long:`${v0}.`},no_credentials_here:{short:"no stored login here",long:"claude-swap still holds no login for it here."},relogin_required_here:{short:"login expired",long:"the imported login was rejected — sign in again on a deck where it still works."},unverified_here:{short:"not checked",long:"claude-swap could not confirm whether this Mac can read it."}};function Ed(e){return e?Ot(FV,e)??null:null}const TI={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:TI[n];if(r)return r;if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(Jl(e)))return v0;const s=w0(DV,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function Jl(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const BV={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"},qV="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 UV(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const zV="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",WV="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",HV=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),VV=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,GV=/[\\/]_npx[\\/]/i,KV=`the copy of ccusage ${kt} installed for itself`;function YV(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function $le(e,t){const n=XV(e,t),r=YV(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 ${vl(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${vl(n)}`;case"managed":return`${KV} failed to run: ${vl(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${vl(n)}`:`the ccusage this deck found on your PATH failed to run: ${vl(n)}`;default:return n}}const vl=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function XV(e,t){const n=Jl(e);if(HV(n)){if(GV.test(n))return WV;if(VV.test(n))return zV}if(UV(n))return qV;const r=w0(BV,e==null?void 0:e.reason);return r||(e==null?void 0:e.reason)||t}function Jo(e,t,n){const r=n==null?null:TI[n];if(r)return r;if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&CI(e.state))return e.error;const s=w0(PV,e==null?void 0:e.reason);return s||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function ZV(e,t,n){if(n<=0||Jd(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 AI(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 JV(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(),s=n.alias||r||`account ${n.num}`,o=[];return n.alias&&r&&o.push(r),r&&(t.get(r.toLowerCase())??0)>1&&o.push(n.org||`slot ${n.num}`),{num:n.num,label:s,sub:o.length?o.join(" · "):null}})}function QV(e,t){return e.filter(n=>!t.includes(n.num)).map(n=>n.num)}function eG(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function tG(e){return e.length?{action:"share",accounts:[...e]}:null}function nG(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 rG(e,t,n){return e&&e.map(r=>Zx(r)===t?n:r)}function sG(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 aG(e){const t=e.length;if(!t)return"Nothing to import.";const n=f=>e.filter(p=>p.state===f).length,r=[],s=n("imported");s&&r.push(`${s} of ${t} imported`);const o=n("healed");o&&r.push(`${o} had a dead token replaced`);const l=n("updated");l&&r.push(`${l} updated`);const c=n("present");c&&r.push(`${c} already here`);const d=n("failed");d&&r.push(`${d} did not arrive`);const h=[...new Set(e.map(f=>{var p;return(p=Ed(f.check))==null?void 0:p.short}).filter(f=>!!f))];return`${r.join(", ")}${h.length?`, ${h.join(", ")}`:""}.`}const oG=1500,Fu=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],CS="aa-panel",TS=e=>`aa-tab-${e}`;async function Vo(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}function RI({onClose:e,onChanged:t,email:n=null,onSignedIn:r}){qt("add-account");const[s,o]=y.useState("login"),[l,c]=y.useState(null),[d,h]=y.useState(""),[f,p]=y.useState(""),[g,v]=y.useState(!1),[N,k]=y.useState(!1),[x,j]=y.useState(null),[b,_]=y.useState(null),E=g||N,[R,T]=y.useState(null),[A,U]=y.useState(null),[L,F]=y.useState(null),O=y.useRef(""),I=y.useRef(!1),B=y.useRef(!1),M=y.useRef(null),$=y.useRef(null),P=y.useRef(null),G=y.useRef(null),K=y.useRef([]),q=y.useRef(!1),H=y.useCallback(()=>{const he=$V({started:I.current,state:l==null?void 0:l.state});he&&Vo(he).catch(()=>{}),e()},[e,l==null?void 0:l.state]),D=ut(H,{focusRef:P}),W=gt(H),J=y.useCallback(async()=>{if(!lr(B.current))return;B.current=!0,v(!0),j(null),I.current=!0;let he=await Vo(n?{action:"login",email:n}:{action:"login"}).catch(()=>null);if(n&&(he==null?void 0:he.reason)==="bad_email"&&(he=await Vo({action:"login"}).catch(()=>null)),B.current=!1,v(!1),!(he!=null&&he.ok)){j(Jo(he,"could not start the sign-in"));return}c(he)},[n]);y.useEffect(()=>{if(!EI(l==null?void 0:l.state))return;const he=window.setInterval(async()=>{try{const ge=await fetch("/api/claude-accounts/login");ge.ok&&c(await ge.json())}catch{}},oG);return()=>window.clearInterval(he)},[l]);const V=y.useRef(t);V.current=t;const X=y.useState(LV)[0];y.useEffect(()=>{var he;(l==null?void 0:l.state)==="awaiting_code"&&((he=M.current)==null||he.focus()),X.shouldAnnounce(l==null?void 0:l.state)&&V.current()},[l==null?void 0:l.state,X]);const Y=y.useRef(r);Y.current=r;const Z=y.useRef(null);y.useEffect(()=>{var ue;const he=(l==null?void 0:l.state)==="done"?l.account:null,ge=he?`${he.num??""}|${he.email}`:null;!he||Z.current===ge||(Z.current=ge,(ue=Y.current)==null||ue.call(Y,he))},[l]),y.useEffect(()=>{var he;s==="paste"&&!q.current&&((he=$.current)==null||he.focus()),q.current=!1},[s]);const ee=y.useCallback(he=>{var ue;const ge=ZV(he,Fu.findIndex(be=>be.id===s),Fu.length);ge.kind!=="pass"&&(he.preventDefault(),q.current=!0,o(Fu[ge.index].id),(ue=K.current[ge.index])==null||ue.focus())},[s]),ne=y.useCallback(async()=>{var ge;if(!lr(B.current))return;B.current=!0,v(!0),j(null);const he=await Vo({action:"login-code",code:d}).catch(()=>null);if(B.current=!1,v(!1),!(he!=null&&he.ok)){j(Jo(he,"the code was not accepted")),he!=null&&he.state&&c(he),(ge=M.current)==null||ge.select();return}h(""),c(he)},[d,l]),se=y.useCallback(async()=>{if(!lr(B.current))return;B.current=!0,k(!0),_(null);const he=await Vo({action:"import",blob:f}).catch(()=>null);if(B.current=!1,k(!1),!(he!=null&&he.ok)){_(Jo(he,"the import failed"));return}O.current=f,p(""),F(null),T(he.results??[]),t()},[f,t]),pe=y.useCallback(async he=>{const ge=Zx(he);if(!lr(B.current)||!O.current)return;B.current=!0,k(!0),U(ge),F(null);const ue=await Vo({action:"import",blob:O.current,force:!0,only:{email:he.email,org:he.org??""}}).catch(()=>null);if(B.current=!1,k(!1),U(null),!(ue!=null&&ue.ok)){F({key:ge,text:Jo(ue,"that account could not be updated")});return}const be=(ue.results??[])[0];be&&T(oe=>rG(oe,ge,be)),t()},[t]),ke=(l==null?void 0:l.state)==="done"?l.account:null,ae=MV({restored:l==null?void 0:l.restored,activeAccount:l==null?void 0:l.activeAccount}),fe=IV({login:l,started:I.current,loginError:x,loginBusy:g}),me=RV({state:l==null?void 0:l.state,serverError:l==null?void 0:l.error,localError:x});return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...W,role:"presentation",children:a.jsxs("div",{ref:D,className:"modal aa-modal",onClick:he=>he.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{className:"aa-tabs",role:"tablist","aria-label":"How to add the account",onKeyDown:ee,children:Fu.map((he,ge)=>a.jsx("button",{type:"button",role:"tab",id:TS(he.id),ref:ue=>{K.current[ge]=ue},"aria-selected":s===he.id,"aria-controls":CS,tabIndex:s===he.id?0:-1,className:`aa-tab${s===he.id?" on":""}`,onClick:()=>{q.current=!1,o(he.id)},children:he.label},he.id))})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:H,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsx("section",{className:"modal-body aa-body",id:CS,role:"tabpanel","aria-labelledby":TS(s),children:s==="login"?fe==="done"&&ke?a.jsxs("div",{className:"aa-done",children:[a.jsx(_d,{ref:G}),a.jsx(ES,{anchor:G}),a.jsx("h4",{children:ke.added?`Account ${ke.num} added`:"Credentials refreshed"}),a.jsxs("p",{className:"aa-note",children:[a.jsx("strong",{children:ke.email}),ke.added?ae?" 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."]}),ae?a.jsx("p",{className:"aa-note aa-warn",role:"status",children:ae}):null,a.jsx("button",{type:"button",className:"btn primary",onClick:H,children:"Done"})]}):fe==="code"&&l?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"aa-step",children:[a.jsx("h4",{children:"1 · Approve in the browser"}),a.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),a.jsx("a",{className:"aa-link",href:l.url??"#",target:"_blank",rel:"noreferrer noopener",children:l.url})]}),a.jsxs("div",{className:"aa-step",children:[a.jsx("h4",{children:"2 · Paste a code, if the page shows one"}),a.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."}),a.jsxs("div",{className:"aa-field",children:[a.jsx("input",{ref:M,type:"text",value:d,onChange:he=>h(he.target.value),onKeyDown:he=>{he.key==="Enter"&&d.trim()&&!E&&ne()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:l.state==="registering"}),a.jsx("button",{type:"button",className:"btn primary",...Dr(E,!d.trim()||l.state==="registering"),onClick:ne,children:l.state==="registering"?"registering…":"Continue"})]}),(x||l.error)&&a.jsx("p",{className:"aa-err",children:x??l.error}),a.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."})]})]}):fe==="ended"?a.jsxs("div",{className:"aa-step",children:[a.jsx("h4",{children:me.title}),a.jsx("p",{className:"aa-err",children:me.message}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{I.current=!1,c(null),j(null),J()},children:"Try again"})]}):fe==="asking"?a.jsx("div",{className:"aa-step",children:a.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):a.jsxs("div",{className:"aa-step aa-primer",children:[a.jsx("h4",{children:n?a.jsxs(a.Fragment,{children:["Sign in again as ",a.jsx("strong",{children:n})]}):"Sign in to Anthropic"}),a.jsxs("p",{className:"aa-note",children:["Opens a browser tab where you approve the sign-in",n?", with this address already filled in":"",". It normally completes by itself; only if the page hands you a code does it need pasting back here.",n?" claude-swap replaces the expired login in place — the account keeps its slot, its alias and its history — and the account you are using now stays active.":" claude-swap records the account when it completes, and the account you are using now stays active."]}),a.jsx("div",{className:"aa-actions",children:a.jsx("button",{type:"button",ref:P,className:"btn primary",...Dr(E),onClick:J,children:"Open the sign-in page"})})]}):R?(()=>{const he=R.filter(ue=>ue.state==="imported").length,ge=R.some(ue=>Ed(ue.check));return a.jsxs("div",{className:"aa-done",children:[!ge&&a.jsx(_d,{ref:G}),he>0&&!ge&&a.jsx(ES,{anchor:G}),a.jsx("h4",{children:aG(R)}),R.length>0&&a.jsx("ul",{className:"aa-results",children:R.map(ue=>{const be=Zx(ue),oe=Ed(ue.check);return a.jsxs("li",{className:`aa-result ${ue.state}`,children:[a.jsx("span",{className:"aa-result-who",children:ue.email||(ue.num?`slot ${ue.num}`:"an account")}),a.jsx("span",{className:"aa-result-what",children:sG(ue.state)}),ue.state==="present"&&a.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":A===be,title:`Overwrite the stored login for ${ue.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>pe(ue),children:A===be?"updating…":"update anyway"}),oe&&a.jsx("span",{className:"aa-result-err",children:oe.long}),(L==null?void 0:L.key)===be&&a.jsx("span",{className:"aa-result-err",children:L.text})]},be)})}),a.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",a.jsx("strong",{children:" update anyway"}),"."]}),a.jsxs("div",{className:"aa-actions",children:[a.jsx("button",{type:"button",className:"btn primary",onClick:H,children:"Done"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{O.current="",F(null),T(null)},children:"Import another"})]})]})})():a.jsxs("div",{className:"aa-step",children:[a.jsx("h4",{children:"Paste an account shared from another deck"}),a.jsxs("div",{className:"aa-field",children:[a.jsx("input",{ref:$,type:"text",value:f,onChange:he=>p(he.target.value),onKeyDown:he=>{he.key==="Enter"&&f.trim()&&!E&&se()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),a.jsx("button",{type:"button",className:"btn primary",...Dr(E,!f.trim()),onClick:se,children:N?"importing…":"Import"})]}),b&&a.jsx("p",{className:"aa-err",children:b}),a.jsxs("p",{className:"aa-note",children:["Use ",a.jsx("strong",{children:"share"})," on one account in the other deck, or ",a.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)}function iG(e,t){const n=new Set(e),r=e.length?Math.max(...e):0;return[...new Set([...e,r+1])].sort((s,o)=>s-o).map(s=>{const o=s===t?"here":n.has(s)?"swap":"free";return{slot:s,kind:o,label:o==="here"?`slot ${s}`:`slot ${s} · ${o}`}})}function lG(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 s=n.swapped===!0&&r!==t;return{menuFor:e.menuFor===t?r:s&&e.menuFor===r?t:e.menuFor,confirmRemove:null,shareFor:null,swapNote:s?{at:r,displaced:t}:null}}const cG=64;function uG(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}function dG(e,t,n){return t!=null&&e.some(r=>r.slot===t)?t:n}function hG(e,t,n){var s;const r=((s=e.find(o=>o.slot===t))==null?void 0:s.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 fG(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 pG({a:e,slots:t,nowSec:n,boundaryId:r,accountMenu:s,busy:o,pressProps:l,rotating:c,onProjects:d,onRotation:h}){const{menu:f,menuError:p,aliasDraft:g,confirmRemove:v,share:N,shareCopied:k,slotDraft:x,dropMenu:j,closeMenu:b,startRename:_,typeAlias:E,doAlias:R,startMove:T,pickSlot:A,doSlot:U,makeShare:L,copyShare:F,pressRemove:O}=s;if(!f)return null;const I=`ap-pop-title-${e.num}`,B=p&&a.jsx("p",{className:"ap-pop-error",role:"alert",title:p.raw||void 0,children:p.text});return a.jsxs(ch,{anchorId:`ap-more-${e.num}`,boundaryId:r,id:`ap-menu-${e.num}`,className:"ap-pop",role:f.view==="menu"?"menu":"dialog",labelledBy:f.view==="menu"?`ap-more-${e.num}`:I,start:f.start,onClose:j,children:[f.view==="menu"&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>_(e.num,e.alias),children:"Rename"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>T(e.num),children:"Move to slot…"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...l(`share-${e.num}`),title:`Copy this account to another ${kt}. 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:()=>L(e.num),children:o===`share-${e.num}`?"Sharing…":"Share"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",title:"See how much this account worked in each project",onClick:()=>d(),children:"Projects"}),(c&&!e.active||e.disabled)&&a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...l(`rot-${e.num}`),title:e.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",onClick:()=>h(),children:e.disabled?"Put back in rotation":"Hold out of rotation"}),a.jsx("div",{role:"separator",className:"ap-menu-sep"}),a.jsx("button",{type:"button",role:"menuitem",className:`ap-menu-item danger${v===e.num?" armed":""}`,...l(`rm-${e.num}`),"aria-label":v===e.num?"Confirm remove":void 0,title:v===e.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>O(e.num),children:o===`rm-${e.num}`?"Removing…":v===e.num?"Confirm":"Remove"}),B]}),f.view==="rename"&&a.jsxs("form",{className:"ap-pop-form",onSubmit:M=>{M.preventDefault(),R(e.num,e.alias)},children:[a.jsx("label",{className:"ap-pop-title",id:I,htmlFor:`ap-alias-${e.num}`,children:"Rename account"}),a.jsx("input",{id:`ap-alias-${e.num}`,className:"ap-manage-input",type:"text",value:g,onChange:M=>E(M.target.value),maxLength:cG,placeholder:"e.g. work",spellCheck:!1,autoComplete:"off",autoFocus:!0,onFocus:M=>M.currentTarget.select()}),B,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>b(),children:"Cancel"}),a.jsx("button",{type:"submit",className:"btn primary",...l(`alias-${e.num}`),title:"A short name to show instead of the email",children:o===`alias-${e.num}`?"…":"Save"})]})]}),f.view==="move"&&(()=>{const M=iG(t,e.num),$=dG(M,x,e.num),P=hG(M,$,e.num);return a.jsxs("div",{className:"ap-pop-form",children:[a.jsx("label",{className:"ap-pop-title",id:I,htmlFor:`ap-slot-${e.num}`,children:"Move to slot"}),a.jsx("span",{className:"ap-field",children:a.jsx("select",{id:`ap-slot-${e.num}`,value:String($),...l(`move-${e.num}`),onChange:G=>A(Number(G.target.value)),autoFocus:!0,children:M.map(G=>a.jsx("option",{value:G.slot,children:G.label},G.slot))})}),B,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>b(),children:"Cancel"}),a.jsx("button",{type:"button",className:"btn primary",...l(`move-${e.num}`),title:P.title,onClick:()=>U(e.num,$,P),children:o===`move-${e.num}`?"…":Sl(P.label)})]})]})})(),f.view==="share"&&(N==null?void 0:N.num)===e.num&&(()=>{const M=AI(N.expiresAt,n),$=M.tone==="gone";return a.jsxs("div",{className:"ap-pop-form",children:[a.jsx("p",{className:"ap-pop-title",id:I,children:"Share account"}),a.jsx("code",{className:"ap-share-blob",children:N.blob}),a.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:[a.jsx("span",{className:"ap-share-warn",children:"This is the password"})," · ",a.jsx("span",{className:`ap-share-expiry ${M.tone}`,children:M.text})]}),B,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>b(),children:"Done"}),a.jsx("button",{type:"button",className:"btn primary",...l(`share-${e.num}`),autoFocus:!0,onClick:async()=>{if($){await L(e.num);return}await F(N.blob)},children:$?"Make a new share":k?"Copied":"Copy"})]})]})})()]})}const mG=6;function gG(e,t){const n=e.filter(c=>c.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`,s=n.length?"ok":"idle",o=t.strained&&!t.armed?yG(n):null,l=[r];return o!=null&&l.push(`${o}% free`),l.push(t.armed?`auto ${t.threshold??"on"}${t.threshold?"%":""}`:"auto off"),{text:l.join(" · "),tone:s,free:o}}function yG(e){const t=e.map(n=>n.headroom).filter(n=>typeof n=="number");return t.length?Math.round(Math.max(...t)):null}function wG(e){const t=[...e].sort((s,o)=>{if(s.ready!==o.ready)return s.ready?-1:1;if(!s.ready)return s.name.localeCompare(o.name);const l=s.headroom,c=o.headroom;return l==null&&c==null?s.name.localeCompare(o.name):l==null?1:c==null?-1:c-l}),n=t.slice(0,mG),r=t.length-n.length;return{title:e.some(s=>s.ready)?"Where you could switch":"Nothing to switch to",shown:n,rest:r>0?`and ${r} more`:null}}function Fr(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 s=Math.round(r/60);return s<48?`${s}h ago`:`${Math.round(s/24)}d ago`}const vG={keychain_unavailable:{short:"Keychain locked on the other Mac",long:`the other Mac could not export it. On that Mac: ${v0}. The next round brings it.`}};function Jx(e){return e.why?Ot(vG,e.why)??Ed(e.why):null}const x0={"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"},"that deck pairs only by invite":{text:"it pairs only by invite",tone:"idle"},"this deck pairs only by invite":{text:"needs an invite · your setting",tone:"idle"}},xG={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 AS(e){var r;const t=bG[e];if(t)return t;const n=(r=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:r[1];return n&&xG[n]||e}const bG={"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 dh(e,t){var f;if(!e)return null;if(e.error&&((f=e.done)!=null&&f.length)){const p=dh({...e,error:void 0},t),g=` · ${Fr(e.at,t)}`;return{...p,text:`${p.text.slice(0,-g.length)}, then ${AS(e.error)}${g}`,tone:"bad"}}if(e.error)return x0[e.error]??{text:AS(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${Fr(e.at,t)}`,tone:"idle"};const r=n.filter(p=>p.ok),s=r.length===1?"login":"logins",o=n.map(p=>({d:p,why:Jx(p)})).filter(p=>p.why),l=[...new Set(o.map(p=>p.why.short))],c=l.length?`, ${l.join(", ")}`:"",d=o.length?o.map(p=>`${p.d.email}: ${p.why.long}`).join(" "):void 0,h=Fr(e.at,t);return r.length===n.length?{text:`${r.length} ${s} arrived${c} · ${h}`,tone:o.length?"warn":"ok",...d?{hint:d}:{}}:{text:`${r.length} of ${n.length} logins arrived${c} · ${h}`,tone:"bad",...d?{hint:d}:{}}}const kG=9e4;function NG({error:e,host:t,port:n},r,s,o=45317){if(e!=="handshake timed out")return null;const l=(t??"").trim();if(!l)return null;const c=r.filter(h=>h.addr===l&&h.port&&h.at>0&&s-h.at<kG);if(!c.length)return null;const d=[...new Set(c.map(h=>h.port))];if(n!=null&&!d.includes(n)){const h=d.length===1?`port ${d[0]}`:`ports ${d.join(" and ")}`;return`A deck at ${l} is announcing itself on ${h}, 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 ${l}, not a network fault. Whoever uses it can allow two ports: UDP ${o} and TCP ${n??d[0]}.`}function hh(e,t){var n,r;return(n=e.last)!=null&&n.error&&!x0[e.last.error]?!1:!!((r=e.last)!=null&&r.at&&t-e.last.at<Qx||e.lastSeen!=null&&t-e.lastSeen<Qx)}const Qx=95e3;function jG(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(p=>p.paired!==!1||p.met);if(!r.length)return{text:"no deck paired yet",tone:"idle"};const s=p=>p.waiting?MI(p.lastSeen,t):hh(p,t),o=p=>{var g;return!p.waiting&&((g=p.last)==null?void 0:g.error)==="waiting for the other deck to accept this one"},l=e.aliases??{};let c=0,d=0,h=0;for(const p of II(r,g=>$I(g,g.peerFp??g.fp,l).name,g=>g.addr??"")){const g=p.filter(s);if(!g.length){h++;continue}c++,g.every(o)&&d++}if(c&&d===c)return{text:c===1?"1 deck found · waiting for them to accept":`${c} decks found · waiting for them to accept`,tone:"wait"};if(!c)return{text:h===1?"this deck cannot reach the one it is paired with":`this deck cannot reach any of its ${h} decks`,tone:"bad"};const f=c===1?"1 deck ready":`${c} decks ready`;return{text:h?`${f} · ${h} away`:f,tone:"ok"}}function SG(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const r=Fr(e,t);return r==="now"?"checked just now":`checked ${r}`}function b0(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 MI(e,t){return e!=null&&t-e<Qx}function _G(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=MI(e,t);return{text:n?"online · one-way, it calls in":`one-way · last online ${Fr(e,t)}`,here:n}}function RS(e,t,n){return t?"online":e.lastSeen!=null?`last online ${Fr(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function EG(e,t){if(!e)return[];const n=[],r=new Set,s=(p,g)=>p.name.localeCompare(g.name,void 0,{numeric:!0}),o=e.aliases??{};for(const p of e.pending??[])!(p!=null&&p.fp)||r.has(p.fp)||(r.add(p.fp),n.push(CG(p,o,t)));const l=[],c=[];for(const p of e.peers??[]){const g=p.peerFp??p.fp;!g||r.has(g)||(r.add(g),!p.paired&&p.manual&&!p.met?c.push(TG(p,g,t)):l.push(AG(p,g,o,t)))}n.push(...$G(l).sort(s),...c.sort(s));const d=[];for(const p of e.strangers??[])!(p!=null&&p.fp)||r.has(p.fp)||(r.add(p.fp),d.push(RG(p,o,e.pairingMode)));n.push(...d.sort(s));const h=[];for(const p of e.declined??[])!(p!=null&&p.fp)||r.has(p.fp)||(r.add(p.fp),h.push(MG(p,o)));n.push(...h.sort(s));const f=new Map;for(const p of n)f.set(p.name,(f.get(p.name)??0)+1);for(const p of n)(f.get(p.name)??0)<2||!p.addr||(p.state=p.quiet||!p.state?p.addr:`${p.addr} · ${p.state}`,p.quiet=!1);return n}function CG(e,t,n){const r=fh(t,e.fp,e.name||e.fp);return{fp:e.fp,...r,addr:e.addr??"",kind:"asks",state:`wants to pair · ${b0(e.at,n)}`,tone:"wait",here:!0,hint:`${r.name} at ${e.addr}${e.via==="tailscale"?", over Tailscale,":""} is waiting for an answer.`,...ph(e.via)}}function TG(e,t,n){var o;const r=dh(e.last,n),s=e.addr?`${e.addr}:${e.port}`:"";return{fp:s,name:s||e.name||t,addr:e.addr??"",kind:"dialling",state:r?eb(r):"trying…",tone:r?r.tone:"idle",here:!1,hint:(o=e.last)!=null&&o.error?`Nothing has answered at ${s} yet — ${e.last.error}.`:`Dialling ${s} until something answers.`,...ph(e.via)}}function AG(e,t,n,r){var v,N,k,x;const s=dh(e.last,r),o=hh(e,r),l=e.addr?`${e.addr}:${e.port}`:"",c=e.waiting?_G(e.lastSeen,r):null,d=c?c.here:o,h=!c&&s?d?`online · ${eb(s)}`:`${eb(s)} · ${RS(e,d,r)}`:c?c.text:RS(e,d,r),f=(v=e.last)!=null&&v.error?x0[e.last.error]:null,p=!c&&d&&!((N=e.last)!=null&&N.error)&&!(((k=e.last)==null?void 0:k.done)??[]).length,g=$I(e,t,n);return{fp:t,...g,addr:e.addr??"",kind:"paired",state:h,quiet:p,tone:f?f.tone==="bad"?"bad":"wait":s?s.tone:d?"ok":"idle",here:c?c.here:o,...ph(e.via),hint:c?`${g.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. ${e.lastSeen==null?"It has not called since this deck started.":`It last called ${Fr(e.lastSeen,r)}.`} Add its address through Add a deck, the link at the top of this view, to reach it either way.`:`${g.name}${l?` at ${l}`:""}${(x=e.last)!=null&&x.error?` — ${e.last.error}`:""}${s!=null&&s.hint?` — ${s.hint}`:""}`}}function $I(e,t,n){return e.manual&&!e.met?{name:e.addr?`${e.addr}:${e.port}`:""}:fh(n,t,e.name||t)}function RG(e,t,n){const r=fh(t,e.fp,e.name||e.fp);return{fp:e.fp,...r,addr:e.addr??"",kind:"nearby",state:n==="invite"?"needs an invite":"not paired yet",tone:"idle",here:!0,hint:e.via==="tailscale"?`${r.name} at ${e.addr} is on your tailnet and nothing is shared with it.`:`${r.name} at ${e.addr} is on this network and nothing is shared with it.`,...ph(e.via)}}function MG(e,t){const n=fh(t,e.fp,e.name||e.fp);return{fp:e.fp,...n,addr:e.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.`}}function fh(e,t,n){const r=t?e[t]:void 0;return r&&r!==n?{name:r,self:n}:{name:n}}function ph(e){return e==="tailscale"?{via:"tailscale"}:{}}function eb(e){return e.text.replace(/ · .*$/,"")}function $G(e){return II(e,t=>t.name,t=>t.addr).map(IG)}function II(e,t,n){const r=new Map;for(const o of e){const l=r.get(t(o));l?l.push(o):r.set(t(o),[o])}const s=[];for(const o of r.values()){const l=[...new Set(o.map(n).filter(Boolean))];if(l.length>1){for(const c of l)s.push(o.filter(d=>n(d)===c));for(const c of o)n(c)||s.push([c])}else s.push(o)}return s}function IG(e){const[t,...n]=[...e].sort((r,s)=>Number(s.here)-Number(r.here)||+!!s.addr-+!!r.addr);return n.length?{...t,twins:n}:t}function MS(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function Ql(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 OG(e,t){var o;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(l=>l.kind==="asks").length;if(n)return{text:n===1?"1 deck wants to pair":`${n} decks want to pair`,tone:"wait",live:!1};if((o=e.reach)!=null&&o.blocked)return{text:"nothing can get in",tone:"bad",live:!1};const r=t.filter(l=>l.kind==="paired");if(!r.length)return{text:"On · none paired yet",tone:"idle",live:!1};const s=r.filter(l=>l.here).length;return s?s===r.length?{text:`${s} online`,tone:"ok",live:!0}:{text:`${s} of ${r.length} online`,tone:"ok",live:!0}:{text:`none of ${r.length} online`,tone:"idle",live:!1}}function LG(e,t){const n=e.filter(f=>f.kind==="asks"),r=e.filter(f=>f.kind!=="asks"),s=r.filter(f=>f.here),o=r.filter(f=>!f.here),l=o.filter(f=>f.tone==="bad").length,c=t||s.length===0,d=c?[...s,...o]:s,h=r.filter(f=>f.kind==="paired").length;return{asks:n,rest:r,live:s,folded:o,troubled:l,showFolded:c,shown:d,paired:h}}function $S(e){return e.map(t=>({key:`${String(t.email??"").trim().toLowerCase()}@@${t.orgUuid??""}`,email:t.email??"",alive:t.alive===!0,shareable:t.collector==="ok"||t.collector==null&&!t.active}))}function PG(e,t,n){if(!(t!=null&&t.enabled)||!(t.shared??[]).includes(e))return!1;const r=(t.peers??[]).filter(s=>s.paired&&hh(s,n)).map(s=>{var o,l;return(l=(o=s.offers)==null?void 0:o.accounts)==null?void 0:l.find(c=>c.key===e)}).filter(s=>s!=null);return r.length>0&&r.every(s=>!s.alive)}function DG(e,t,n,r){if(!(n!=null&&n.enabled)||n.running===!1||!(n.shared??[]).includes(e))return!1;const s=String(t??"").trim().toLowerCase();return(n.peers??[]).some(o=>{var c,d,h,f;if(!o.paired||!hh(o,r))return!1;const l=(d=(c=o.offers)==null?void 0:c.accounts)==null?void 0:d.find(p=>p.key===e);return!(l!=null&&l.alive)||l.shareable===!1?!1:!((f=(h=o.last)==null?void 0:h.done)!=null&&f.some(p=>p.action==="heal"&&String(p.email??"").trim().toLowerCase()===s))})}const OI=160,LI=140;function FG(){const[e,t]=y.useState(!1),n=y.useRef(0);return y.useEffect(()=>()=>window.clearTimeout(n.current),[]),{peek:e,openPeek:c=>{window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!0),c)},shutPeek:()=>{window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),LI)},holdPeek:()=>window.clearTimeout(n.current),dropPeek:()=>{window.clearTimeout(n.current),t(!1)}}}function BG(e){var t;return((t=e==null?void 0:e.detail)==null?void 0:t.fix)==="give_back"}function sr(e,t){return{text:e,giveBack:BG(t),done:!1}}async function qG(){try{return await(await fetch("/api/prefs/give-back",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json().catch(()=>null)}catch{return null}}const UG={cancelled:"Nothing changed — the password dialog was closed. The folder still belongs to another user.",timed_out:"Nothing changed — the password dialog was not answered in time.",busy:"The password dialog is already open. It may be behind this window."};function zG(e){if(e!=null&&e.ok)return{text:e.changed===!1?"The settings folder is already yours, and the deck has read it again. Try that once more.":"Done — the settings folder is yours again, and the deck has read it again. Try that once more.",giveBack:!1,done:!0};if(e==null)return{text:"Could not give it back — the deck did not answer.",giveBack:!0,done:!1};const t=e.reason?UG[e.reason]:void 0;return t?{text:t,giveBack:!0,done:!1}:{text:"macOS did not give the folder back. The deck's log has the command that does it by hand.",giveBack:!1,done:!1}}const tb=5e3,PI=6e4;function Ct(e,t){if(t==null)return`Could not ${e} — the deck did not answer.`;const n=t.reason?VG(t.reason,t.detail):void 0;return n?`Could not ${e} — ${n}`:t.reason?`Could not ${e} — the deck refused it (${t.reason}).`:`Could not ${e}.`}const WG={prefs_unreadable:"this deck cannot read its settings file, so it will not write over it. The file may belong to another user, for example after ccdeck was run with sudo. The deck's log names the file.",prefs_not_writable:"this deck is not allowed to save its settings. The settings folder may belong to another user, for example after ccdeck was run with sudo, or another program may be holding the file. The deck's log names the folder."},HG=new Set(["EACCES","EPERM"]);function VG(e,t){const n=WG[e];if(!n)return;const r=e==="prefs_unreadable"&&t?GG(t):void 0,s=t!=null&&t.code&&t.code!=="BADJSON"?` Error code: ${t.code}.`:"";return(r??n)+s}function GG({code:e,owner:t,on:n}){if(e==="BADJSON")return"its settings file is damaged and could not be moved aside, so it will not write over it. The deck's log names the file.";if(n==="folder"&&t==="other")return"this deck cannot open its settings folder, which belongs to another user, for example after ccdeck was run with sudo. The deck's log has the command that gives it back.";if(n==="folder"&&t==="you")return"this deck cannot open its own settings folder, so it will not write over what is in it. The deck's log names the folder.";if(t==="other")return"its settings file belongs to another user and could not be moved aside, so it will not write over it. The deck's log names the file.";if(t==="you")return"this deck cannot read its settings file although the file is yours, so it will not write over it. Something on this machine is blocking the read; the deck's log names the file.";if(e&&!HG.has(e))return"this deck cannot read its settings file, so it will not write over it. The deck's log names the file."}async function Go(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}function KG(e,t){const[n,r]=y.useState(null),[s,o]=y.useState([]),[l,c]=y.useState(null),[d,h]=y.useState(null),f=y.useRef(null),p=y.useCallback(O=>oh(f.current)?(f.current=O,c(O),!0):!1,[]),g=y.useCallback(()=>{f.current=null,x.current&&c(null)},[]),v=O=>{const I=ia(l,O);return{disabled:I.disabled,"aria-busy":I.busy}},[N,k]=y.useState(()=>Date.now()),x=y.useRef(!0),j=y.useRef(tb),b=y.useCallback(async()=>{var O,I;try{const[B,M]=await Promise.all([fetch("/api/lan").then($=>$.json()),fetch("/api/prefs").then($=>$.json())]);if(!x.current)return;B!=null&&B.ok&&r(B),M!=null&&M.ok&&o(Array.isArray((I=(O=M.prefs)==null?void 0:O.lan)==null?void 0:I.manual)?M.prefs.lan.manual:[]),j.current=(B==null?void 0:B.enabled)===!0?tb:PI}catch{}},[]);y.useEffect(()=>{x.current=!0;let O=0;const I=async()=>{k(Date.now()),await b(),x.current&&(O=window.setTimeout(I,j.current))};return I(),()=>{x.current=!1,window.clearTimeout(O)}},[b]);const _=y.useCallback(async()=>{const O=(n==null?void 0:n.enabled)===!0;if(p("switch"))try{const I=await Go("/api/prefs",{lan:{enabled:!O}});if(!x.current)return;I!=null&&I.ok?(h(null),O||t()):h(sr(Ct(O?"turn this off":"turn this on",I),I)),await b()}catch{x.current&&h(sr(Ct(O?"turn this off":"turn this on",null)))}finally{g()}},[n==null?void 0:n.enabled,b,p,g,t]),E=y.useCallback(async(O,I,B)=>{if(!p(`${O}:${I}`))return null;let M=null;try{const $=await Go("/api/lan/peer",{action:O,fp:I});if(!x.current)return null;$!=null&&$.ok?(r($),h(null)):(M=Ct(B,$),h(sr(M,$))),await b()}catch{M=Ct(B,null),x.current&&h(sr(M))}finally{g()}return M},[b,p,g]),R=y.useCallback(async O=>{if(!p(`drop:${O}`))return null;let I=null;try{const B=await Go("/api/prefs",{lan:{manual:s.filter(M=>M!==O)}});if(!x.current)return null;B!=null&&B.ok?(h(null),e()):(I=Ct("stop dialling that address",B),h(sr(I,B))),await b()}catch{I=Ct("stop dialling that address",null),x.current&&h(sr(I))}finally{g()}return I},[s,b,e,p,g]),T=y.useCallback(async(O,I)=>{if(!p(`alias:${O}`))return"Something else is still being saved. Try again in a moment.";try{const B=await Go("/api/lan/peer",{action:"alias",fp:O,name:I});return x.current?B!=null&&B.ok?(r(B),null):Ct("rename that deck",B):null}catch{return Ct("rename that deck",null)}finally{g()}},[p,g]),A=y.useCallback(async O=>{if(!p(`check:${O}`))return null;try{const I=await Go("/api/lan/sync",{fp:O});return x.current?I!=null&&I.ok?(r(I),e(),null):(I==null?void 0:I.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.":Ct("check that deck",I):null}catch{return Ct("check that deck",null)}finally{g()}},[p,g,e]),U=y.useCallback(async()=>{if(p("check"))try{const O=await Go("/api/lan/sync",{});if(!x.current)return;O!=null&&O.ok?(r(O),h(null)):h(sr(Ct("check the other decks",O),O)),e()}catch{x.current&&h(sr(Ct("check the other decks",null)))}finally{g()}},[p,g,e]);return{status:n,manual:s,now:N,busy:l,failure:d,dismissFailure:()=>h(null),answerGiveBack:O=>{h(O),O.done&&(b(),e())},pressProps:v,load:b,toggle:_,answer:E,dropAddress:R,rename:T,checkOne:A,checkNow:U}}function YG(e){const[t,n]=y.useState(null),r=y.useRef(0);return y.useEffect(()=>{if(t==null)return;const o=window.setTimeout(()=>n(null),4e3);return()=>window.clearTimeout(o)},[t]),{armed:t,pressUnpair:o=>{const l=Date.now(),c=Kl({armedFor:t,target:o.fp,armedAt:r.current,now:l,gapMs:Gl});if(c==="arm"){n(o.fp),r.current=l;return}c!=="ignore"&&(n(null),e("unpair",o.fp,"unpair that deck"))}}}function DI({title:e,steps:t,finish:n,aside:r,onClose:s}){const o=y.useRef(null),l=ut(s,{focusRef:o}),c=gt(s),[d,h]=y.useState(0),f=d===t.length-1,p=t[d],g=k=>h(Math.max(0,Math.min(t.length-1,k)));y.useEffect(()=>{var k,x;Cn(((k=document.activeElement)==null?void 0:k.tagName)??null)&&((x=o.current)==null||x.focus())},[d]);const v=k=>{k.key!=="ArrowRight"&&k.key!=="ArrowLeft"||(k.preventDefault(),k.stopPropagation(),g(k.key==="ArrowRight"?d+1:d-1))},N=()=>{if(!f){g(d+1);return}n?n.act():s()};return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...c,role:"presentation",children:a.jsxs("div",{ref:l,className:"modal guide",onClick:k=>k.stopPropagation(),onKeyDown:v,role:"dialog","aria-modal":"true","aria-labelledby":"guide-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{id:"guide-title",className:"modal-tool-name",children:e}),a.jsxs("span",{className:"modal-tool-id",children:[d+1," / ",t.length]})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsx("div",{className:"guide-stage",children:p.art},d),a.jsx("p",{className:"guide-line","aria-live":"polite",children:p.line}),a.jsx("p",{className:"guide-tip",children:p.tip??""}),a.jsxs("div",{className:"guide-foot",children:[a.jsx("div",{className:"guide-dots",children:t.map((k,x)=>a.jsx("button",{type:"button",className:"glyph-btn guide-dot","aria-label":`Step ${x+1} of ${t.length}`,"aria-current":x===d?"step":void 0,onClick:()=>g(x)},x))}),f&&r&&a.jsx("button",{type:"button",className:"ap-lan-word guide-aside",onClick:r.act,children:r.label}),d>0&&a.jsx("button",{type:"button",className:"btn",onClick:()=>g(d-1),children:"Back"}),a.jsx("button",{ref:o,type:"button",className:"btn primary",onClick:N,children:f?(n==null?void 0:n.label)??"Done":"Next"})]})]})]})}),document.body)}const nb={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function Hn({children:e}){return a.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function Wn({x:e,y:t=34,w:n=176,h:r=132,label:s}){return a.jsxs(a.Fragment,{children:[s&&a.jsx("text",{x:e+2,y:t-9,className:"ga-cap",children:s}),a.jsx("rect",{x:e,y:t,width:n,height:r,rx:10,className:"ga-screen"})]})}function ur({x:e,y:t,email:n,state:r,tone:s,bars:o}){return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:e+3,cy:t-4,r:3,className:nb[s]}),a.jsx("text",{x:e+12,y:t,className:"ga-t ga-mono",children:n}),a.jsx("text",{x:e+12,y:t+16,className:`ga-s ${nb[s]}`,children:r}),o==null?void 0:o.map((l,c)=>a.jsxs("g",{children:[a.jsx("text",{x:e,y:t+40+c*18,className:"ga-s",children:c?"7d":"5h"}),a.jsx("rect",{x:e+22,y:t+35+c*18,width:96,height:4,rx:2,className:"ga-track"}),a.jsx("rect",{x:e+22,y:t+35+c*18,width:96*l/100,height:4,rx:2,className:"ga-accent"}),a.jsxs("text",{x:e+148,y:t+40+c*18,className:"ga-s ga-accent",textAnchor:"end",children:[l,"%"]})]},c))]})}function FI({x:e,y:t,on:n}){return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:30,height:18,rx:9,className:n?"ga-switch-on":"ga-switch"}),a.jsx("circle",{cx:n?e+21:e+9,cy:t+9,r:6,className:n?"ga-knob-on":"ga-knob"})]})}function Bu({x:e,y:t,name:n,here:r=!0}){return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:e+3,cy:t-4,r:3,className:r?"ga-ok":"ga-dim"}),a.jsx("text",{x:e+12,y:t,className:r?"ga-t":"ga-s",children:n})]})}function IS({x:e,y:t,on:n}){return n?a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:12,height:12,rx:3,className:"ga-accent"}),a.jsx("path",{d:`M${e+3} ${t+6.2}l2.3 2.3 4-4.6`,className:"ga-tick"})]}):a.jsx("rect",{x:e+.5,y:t+.5,width:11,height:11,rx:3,className:"ga-box"})}function OS({x:e,y:t,d:n}){return a.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function k0({x:e,y:t}){return a.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 N0(){return a.jsxs(a.Fragment,{children:[a.jsx("circle",{r:9,className:"ga-key-bed"}),a.jsxs("g",{transform:"translate(-6 -6) scale(0.857)",className:"ga-key",children:[a.jsx("circle",{cx:4.6,cy:7,r:2.6}),a.jsx("path",{d:"M7.2 7h5.2M10.6 7v2.2M12.4 7v1.6"})]})]})}function Qo({x:e,y:t,w:n,title:r,sub:s,tone:o}){return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:n,height:40,rx:8,className:"ga-screen"}),a.jsx("rect",{x:e+6,y:t+10,width:3,height:20,rx:1.5,className:nb[o]}),a.jsx("text",{x:e+16,y:t+17,className:"ga-t ga-strong",children:r}),a.jsx("text",{x:e+16,y:t+31,className:"ga-s",children:s})]})}function oi({x:e,y:t,label:n,live:r}){return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:46,height:20,rx:10,className:r?"ga-chip-live":"ga-chip"}),a.jsx("text",{x:e+23,y:t+14,className:"ga-s ga-mono",textAnchor:"middle",children:n})]})}function Cd({x:e,y:t}){return a.jsxs(a.Fragment,{children:[a.jsx("text",{x:e,y:t,className:"ga-cap",children:"LOCAL NETWORK"}),a.jsx(FI,{x:e+118,y:t-13,on:!0})]})}function XG(){return a.jsxs(Hn,{children:[a.jsx("rect",{x:14,y:14,width:206,height:172,rx:10,className:"ga-screen"}),a.jsx("text",{x:28,y:38,className:"ga-t ga-strong",children:"Sessions"}),a.jsx("text",{x:206,y:38,className:"ga-s ga-warn",textAnchor:"end",children:"1 waiting"}),a.jsx("rect",{x:20,y:50,width:194,height:42,rx:6,className:"ga-bed-warn"}),a.jsx("circle",{cx:33,cy:64,r:7,className:"ga-ring-warn ga-ping"}),a.jsx("circle",{cx:33,cy:64,r:3.5,className:"ga-warn"}),a.jsx("text",{x:44,y:68,className:"ga-t",children:"api-server"}),a.jsx("text",{x:44,y:83,className:"ga-s ga-warn",children:"waiting 6m · Bash"}),a.jsx("circle",{cx:33,cy:108,r:3.5,className:"ga-flight"}),a.jsx("text",{x:44,y:112,className:"ga-t",children:"docs-site"}),a.jsx("text",{x:44,y:127,className:"ga-s",children:"running · 12 tools"}),a.jsx("circle",{cx:33,cy:150,r:3.5,className:"ga-ok"}),a.jsx("text",{x:44,y:154,className:"ga-t",children:"billing"}),a.jsx("text",{x:44,y:169,className:"ga-s",children:"done · $0.84"}),a.jsx("path",{d:"M216 71C234 71 230 100 244 100",className:"ga-arc"}),a.jsx("path",{d:"M239 96l5 4-5 4",className:"ga-arrow"}),a.jsx("rect",{x:248,y:44,width:178,height:112,rx:10,className:"ga-screen"}),a.jsx("text",{x:262,y:64,className:"ga-cap",children:"API-SERVER"}),a.jsx("line",{x1:248,y1:74,x2:426,y2:74,className:"ga-line"}),a.jsx("text",{x:262,y:96,className:"ga-s ga-mono",children:"Bash(npm test)"}),a.jsx("text",{x:262,y:116,className:"ga-t ga-mono ga-warn",children:"Allow this command?"}),a.jsx("text",{x:262,y:136,className:"ga-s ga-mono",children:"> 1. Yes 2. No"})]})}function ZG(){return a.jsxs(Hn,{children:[a.jsx("path",{d:"M136 100C166 100 166 38 196 38",className:"ga-edge ga-flow"}),a.jsx("path",{d:"M136 100H196",className:"ga-edge ga-flow"}),a.jsx("path",{d:"M136 100C166 100 166 162 196 162",className:"ga-edge-done"}),a.jsx("path",{d:"M308 38H326M308 100H326",className:"ga-edge"}),a.jsx(Qo,{x:20,y:80,w:116,title:"main",sub:"Opus 5 · 9 tools",tone:"accent"}),a.jsx(Qo,{x:196,y:18,w:112,title:"explore",sub:"Haiku · 14 tools",tone:"flight"}),a.jsx(Qo,{x:196,y:80,w:112,title:"tests",sub:"Sonnet · 6 tools",tone:"flight"}),a.jsx(Qo,{x:196,y:142,w:112,title:"review",sub:"done · 38s",tone:"ok"}),a.jsx(oi,{x:326,y:28,label:"Read"}),a.jsx(oi,{x:380,y:28,label:"Grep",live:!0}),a.jsx(oi,{x:326,y:90,label:"Bash",live:!0})]})}function LS({x:e,y:t,label:n,pct:r,note:s}){return a.jsxs(a.Fragment,{children:[a.jsx("text",{x:e,y:t,className:"ga-s",children:n}),a.jsxs("text",{x:e+194,y:t,className:"ga-s ga-accent",textAnchor:"end",children:[r,"%"]}),a.jsx("rect",{x:e,y:t+7,width:194,height:5,rx:2.5,className:"ga-track"}),a.jsx("rect",{x:e,y:t+7,width:194*r/100,height:5,rx:2.5,className:"ga-accent"}),a.jsx("text",{x:e,y:t+26,className:"ga-s",children:s})]})}function JG(){return a.jsxs(Hn,{children:[a.jsx("rect",{x:14,y:30,width:172,height:140,rx:10,className:"ga-screen"}),a.jsx("text",{x:30,y:56,className:"ga-cap",children:"THIS SESSION"}),a.jsx("text",{x:30,y:98,className:"ga-big",children:"$3.66"}),a.jsx("text",{x:30,y:122,className:"ga-s",children:"Opus 5 · 1.2M tokens"}),a.jsx("text",{x:30,y:150,className:"ga-s",children:"$21.40 today"}),a.jsx("rect",{x:200,y:30,width:226,height:140,rx:10,className:"ga-screen"}),a.jsx("text",{x:216,y:56,className:"ga-cap",children:"CLAUDE QUOTA"}),a.jsx(LS,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),a.jsx(LS,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function QG(){return a.jsxs(Hn,{children:[a.jsx("rect",{x:14,y:40,width:172,height:120,rx:10,className:"ga-canvas"}),a.jsx(Qo,{x:30,y:80,w:140,title:"tests",sub:"Sonnet 5 · 6 tools",tone:"flight"}),a.jsx(k0,{x:156,y:106}),a.jsx("path",{d:"M170 92C186 92 184 60 200 60",className:"ga-arc"}),a.jsx("path",{d:"M195 56l5 4-5 4",className:"ga-arrow"}),a.jsx(Wn,{x:200,y:22,w:226,h:160}),a.jsx("text",{x:214,y:46,className:"ga-t ga-strong",children:"tests"}),a.jsx("text",{x:412,y:46,className:"ga-s",textAnchor:"end",children:"Sonnet 5 · 38s"}),a.jsx("line",{x1:200,y1:56,x2:426,y2:56,className:"ga-line"}),a.jsx("text",{x:214,y:76,className:"ga-cap",children:"PROMPT"}),a.jsx("text",{x:214,y:92,className:"ga-t",children:"Run the suite and fix what fails"}),a.jsx("text",{x:214,y:116,className:"ga-cap",children:"TOOLS · 6"}),a.jsx(oi,{x:214,y:122,label:"Read"}),a.jsx(oi,{x:266,y:122,label:"Edit"}),a.jsx(oi,{x:318,y:122,label:"Bash",live:!0}),a.jsx("text",{x:214,y:164,className:"ga-cap",children:"TOKENS"}),a.jsx("text",{x:214,y:178,className:"ga-s ga-mono",children:"41k in · 2.1k out · $0.12"})]})}function eK(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return a.jsxs(Hn,{children:[a.jsx(Wn,{x:14,y:20,w:412,h:160}),a.jsx("text",{x:28,y:44,className:"ga-t ga-strong",children:"This machine"}),a.jsx("text",{x:412,y:44,className:"ga-s",textAnchor:"end",children:"12 cores · up 10d"}),a.jsx("line",{x1:14,y1:56,x2:426,y2:56,className:"ga-line"}),a.jsx("text",{x:28,y:76,className:"ga-cap",children:"CORES"}),e.map((t,n)=>a.jsxs("g",{children:[a.jsx("rect",{x:28+n*15,y:82,width:10,height:30,rx:2,className:"ga-track"}),a.jsx("rect",{x:28+n*15,y:112-t,width:10,height:t,rx:2,className:"ga-accent"})]},n)),a.jsx("text",{x:28,y:136,className:"ga-cap",children:"MEMORY"}),a.jsx("rect",{x:28,y:143,width:178,height:5,rx:2.5,className:"ga-track"}),a.jsx("rect",{x:28,y:143,width:105,height:5,rx:2.5,className:"ga-accent"}),a.jsx("text",{x:28,y:165,className:"ga-s",children:"18.9 GB of 32.0 GB"}),a.jsx("text",{x:240,y:76,className:"ga-cap",children:"THERMAL"}),a.jsx("text",{x:240,y:100,className:"ga-big",children:"66 °C"}),a.jsx("text",{x:240,y:118,className:"ga-s ga-ok",children:"running at full speed"}),a.jsx("text",{x:240,y:142,className:"ga-cap",children:"BUSIEST PROCESSES"}),a.jsx("text",{x:240,y:160,className:"ga-s ga-mono",children:"node · claude"}),a.jsx("text",{x:412,y:160,className:"ga-s ga-mono",textAnchor:"end",children:"38%"}),a.jsx("text",{x:240,y:176,className:"ga-s ga-mono",children:"esbuild"}),a.jsx("text",{x:412,y:176,className:"ga-s ga-mono",textAnchor:"end",children:"21%"})]})}function tK(){return a.jsxs(Hn,{children:[a.jsx("rect",{x:14,y:40,width:188,height:120,rx:10,className:"ga-screen"}),a.jsx("text",{x:28,y:60,className:"ga-cap",children:"~/MY-PROJECT"}),a.jsx("line",{x1:14,y1:70,x2:202,y2:70,className:"ga-line"}),a.jsxs("text",{x:28,y:100,className:"ga-t ga-mono",children:[a.jsx("tspan",{className:"ga-accent",children:"$"})," claude"]}),a.jsx("rect",{x:86,y:90,width:7,height:13,className:"ga-caret ga-blink"}),a.jsx("text",{x:28,y:130,className:"ga-s ga-mono",children:"or: codex"}),a.jsx("path",{d:"M210 100H238",className:"ga-arc"}),a.jsx("path",{d:"M233 95l6 5-6 5",className:"ga-arrow"}),a.jsx("rect",{x:250,y:40,width:176,height:120,rx:10,className:"ga-canvas"}),a.jsx("g",{className:"ga-pop",children:a.jsx(Qo,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function nK(){return a.jsxs(Hn,{children:[a.jsx(Wn,{x:14,y:16,w:232,h:170}),a.jsx("text",{x:28,y:40,className:"ga-t ga-strong",children:"Claude accounts"}),a.jsx(OS,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),a.jsx(OS,{x:220,y:33,d:"M3.3 10.7L10.7 3.3M5.2 3.3h5.5v5.5"}),a.jsx("line",{x1:14,y1:52,x2:246,y2:52,className:"ga-line"}),a.jsx(ur,{x:28,y:74,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),a.jsx("rect",{x:190,y:62,width:44,height:18,rx:9,className:"ga-accent"}),a.jsx("text",{x:212,y:74,className:"ga-s ga-on-accent",textAnchor:"middle",children:"active"}),a.jsx("line",{x1:14,y1:140,x2:246,y2:140,className:"ga-line"}),a.jsx(ur,{x:28,y:160,email:"personal@me.dev",state:"signed in",tone:"ok"}),a.jsx("rect",{x:188,y:148,width:46,height:18,rx:9,className:"ga-chip"}),a.jsx("text",{x:211,y:160,className:"ga-s",textAnchor:"middle",children:"switch"}),a.jsx(k0,{x:221,y:161}),a.jsx("path",{d:"M250 40C270 40 262 78 282 78",className:"ga-arc"}),a.jsx("path",{d:"M277 74l5 4-5 4",className:"ga-arrow"}),a.jsx(Wn,{x:282,y:62,w:144,h:64,label:"ANOTHER MACHINE"}),a.jsx("g",{className:"ga-pop",children:a.jsx(ur,{x:296,y:92,email:"work@team.dev",state:"shared here",tone:"ok"})})]})}function rK(){return a.jsxs(Hn,{children:[a.jsx(Wn,{x:14,label:"THIS MACHINE"}),a.jsx(Cd,{x:28,y:60}),a.jsx("g",{className:"ga-swap-out",children:a.jsx(ur,{x:28,y:98,email:"work@team.dev",state:"login expired",tone:"warn"})}),a.jsx("g",{className:"ga-swap-in",children:a.jsx(ur,{x:28,y:98,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),a.jsx(Wn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(Cd,{x:264,y:60}),a.jsx(ur,{x:264,y:98,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),a.jsx("path",{d:"M246 120C234 80 206 80 194 120",className:"ga-arc"}),a.jsx("g",{className:"ga-travel ga-travel-low",transform:"translate(220 90)",children:a.jsx(N0,{})})]})}const sK=[{art:a.jsx(XG,{}),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:a.jsx(ZG,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:a.jsx(QG,{}),line:"Double-click any node: its prompt, every tool call, tokens and timing."},{art:a.jsx(JG,{}),line:"What each session costs, and how much quota is left."},{art:a.jsx(eK,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:a.jsx(nK,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:a.jsx(rK,{}),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:a.jsx(tK,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function aK(){return a.jsxs(Hn,{children:[a.jsx(Wn,{x:14,label:"THIS MACHINE"}),a.jsx(ur,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"}),a.jsx("rect",{x:40,y:94,width:86,height:20,rx:10,className:"ga-pill-warn"}),a.jsx("text",{x:83,y:108,className:"ga-s ga-warn",textAnchor:"middle",children:"sign in again"}),a.jsx("line",{x1:198,y1:100,x2:242,y2:100,className:"ga-off"}),a.jsx(Wn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(ur,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function oK(){return a.jsxs(Hn,{children:[a.jsx(Wn,{x:14,label:"THIS MACHINE"}),a.jsx(Cd,{x:28,y:60}),a.jsx(Bu,{x:28,y:92,name:"Ana's MacBook"}),a.jsx(Bu,{x:28,y:114,name:"Dorin's PC"}),a.jsx(Wn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(Cd,{x:264,y:60}),a.jsx(Bu,{x:264,y:92,name:"Your MacBook"}),a.jsx(Bu,{x:264,y:114,name:"Dorin's PC"}),a.jsx("line",{x1:196,y1:100,x2:244,y2:100,className:"ga-arc"}),a.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping"}),a.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping ga-ping-2"}),a.jsx("circle",{cx:220,cy:100,r:3,className:"ga-accent"})]})}function iK(){return a.jsxs(Hn,{children:[a.jsx("rect",{x:90,y:18,width:260,height:164,rx:10,className:"ga-screen"}),a.jsx("text",{x:106,y:42,className:"ga-t ga-strong",children:"This deck on the network"}),a.jsx("line",{x1:90,y1:54,x2:350,y2:54,className:"ga-line"}),a.jsx("text",{x:106,y:76,className:"ga-cap",children:"SHARE THESE ACCOUNTS"}),a.jsx(IS,{x:106,y:88,on:!0}),a.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),a.jsx(IS,{x:106,y:112}),a.jsx("text",{x:126,y:122,className:"ga-s ga-mono",children:"personal@me.dev"}),a.jsx("text",{x:106,y:150,className:"ga-cap",children:"PAIRING"}),a.jsx("text",{x:106,y:168,className:"ga-s",children:"Say yes to every deck that asks"}),a.jsx(FI,{x:304,y:157,on:!0}),a.jsx(k0,{x:115,y:97})]})}function lK(){return a.jsxs(Hn,{children:[a.jsx(Wn,{x:14,label:"THIS MACHINE"}),a.jsx("g",{className:"ga-swap-out",children:a.jsx(ur,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"})}),a.jsx("g",{className:"ga-swap-in",children:a.jsx(ur,{x:28,y:64,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),a.jsx(Wn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(ur,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),a.jsx("path",{d:"M246 96C234 56 206 56 194 96",className:"ga-arc"}),a.jsx("g",{className:"ga-travel",transform:"translate(220 66)",children:a.jsx(N0,{})})]})}const cK=[{art:a.jsx(aK,{}),line:"A login can expire on one machine while it still works on another."},{art:a.jsx(oK,{}),line:"Both decks are on. They find each other and ask to pair.",tip:"Not showing up? Add a deck, the link at the top, takes an address or invite."},{art:a.jsx(iK,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:a.jsx(lK,{}),line:"An expired login is copied from a paired machine within a minute."}];function uK(){return a.jsxs("svg",{className:"guide-art",viewBox:"0 0 232 60","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{x:1,y:14,width:78,height:42,rx:7,className:"ga-screen"}),a.jsx("circle",{cx:13,cy:29,r:3,className:"ga-warn"}),a.jsx("rect",{x:21,y:27,width:46,height:4,rx:2,className:"ga-track"}),a.jsx("rect",{x:13,y:39,width:40,height:3,rx:1.5,className:"ga-track"}),a.jsx("rect",{x:153,y:14,width:78,height:42,rx:7,className:"ga-screen"}),a.jsx("circle",{cx:165,cy:29,r:3,className:"ga-ok"}),a.jsx("rect",{x:173,y:27,width:46,height:4,rx:2,className:"ga-track"}),a.jsx("rect",{x:165,y:39,width:40,height:3,rx:1.5,className:"ga-accent"}),a.jsx("path",{d:"M150 36C138 6 94 6 82 36",className:"ga-arc"}),a.jsx("g",{transform:"translate(116 13)",children:a.jsx(N0,{})})]})}const dK={panel:"Nothing here is stuck: whoever pastes an invite is the one dialling out. Ask them for one and paste it behind Add a deck, the link 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."},hK=1600;function BI({reach:e,where:t}){const[n,r]=y.useState(!1),s=y.useRef(!0);y.useEffect(()=>()=>{s.current=!1},[]);const o=(e==null?void 0:e.steps)??[],l=y.useCallback(async()=>{await eo(o.join(`
|
|
90
90
|
`))&&s.current&&(r(!0),window.setTimeout(()=>{s.current&&r(!1)},hK))},[o]);if(!(e!=null&&e.blocked))return null;const c=e.shell==="sh";return a.jsxs("div",{className:"ap-lan-reach",children:[a.jsx("p",{className:"lan-warn",children:e.text}),a.jsx("p",{className:"lan-note",children:dK[t]}),o.length>0&&a.jsxs("details",{className:"ap-lan-reach-fix",children:[a.jsx("summary",{children:"or let them find this deck on their own"}),a.jsxs("p",{className:"lan-note",children:[c?a.jsx(a.Fragment,{children:"Run this in a terminal on this machine, then restart the deck."}):a.jsxs(a.Fragment,{children:["Run this in PowerShell ",a.jsx("strong",{children:"as Administrator"}),", then restart the deck."]}),e.category==="Public"&&a.jsx(a.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&&a.jsxs(a.Fragment,{children:[" ",e.unsure]})]}),a.jsx("pre",{className:"ap-lan-cmd",children:a.jsx("code",{children:o.join(`
|
|
91
|
-
`)})}),a.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>void l(),title:c?"Copy these lines, then paste them into a terminal":"Copy these lines, then paste them into an elevated PowerShell",children:n?"copied":"copy command"})]})]})}function fK(e){const t=(e??"").trim(),n=t.lastIndexOf(":");if(n<=0||n===t.length-1)return null;const r=t.slice(0,n).trim(),s=Number(t.slice(n+1).trim());return!r||!Number.isInteger(s)||s<1||s>65535||r.includes(":")&&!(r.startsWith("[")&&r.endsWith("]"))?null:{addr:r,port:s}}function pK(e,t){const n=Math.max(0,Math.round((e-t)/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}async function Bp(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const mK={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."},gK={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function PS(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||Ct(n,t)}function yK({status:e,manual:t,startWith:n,onClose:r,onChanged:s}){const o=y.useRef(null),l=y.useRef(null),c=y.useRef(null),d=y.useRef(null),h=e.pairingMode==="invite",f=ut(r,{focusRef:h?l:o}),p=gt(r),[g,v]=y.useState(""),[N,k]=y.useState(""),[x,j]=y.useState(null),[b,_]=y.useState(null),[E,R]=y.useState(null),[T,A]=y.useState(null),[U,L]=y.useState(()=>Date.now());y.useEffect(()=>{const Y=window.setInterval(()=>L(Date.now()),1e3);return()=>window.clearInterval(Y)},[]);const F=y.useRef(!0);y.useEffect(()=>()=>{F.current=!1},[]);const O=y.useRef(null),I=y.useRef(null),B=y.useCallback(Y=>oh(O.current)?(O.current=Y,R(Y),!0):!1,[]),M=y.useCallback(()=>{O.current=null,F.current&&R(null)},[]),$=Y=>{const Z=ia(E,Y);return{disabled:Z.disabled,"aria-busy":Z.busy}},P=Y=>(x==null?void 0:x.field)===Y?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},G=Y=>j(Z=>Z&&Z.field===Y?null:Z),K=y.useCallback(async()=>{if(h)return;const Y=fK(g);if(!Y){j({text:wK(g),field:"addr"});return}const Z=`${Y.addr}:${Y.port}`,ee=e.peers.find(ne=>ne.addr===Y.addr&&ne.port===Y.port&&ne.paired);if(ee){j({text:`Already paired with ${ee.name} at that address.`,field:"addr"});return}if(t.includes(Z)){j({text:"This deck already calls that address.",field:"addr"});return}if(B("add"))try{const ne=await Bp("/api/prefs",{lan:{manual:[...t,Z]}});if(!F.current)return;ne!=null&&ne.ok?(j(null),v(""),s(),r()):j({text:Ct("add that address",ne),field:"addr"})}catch{F.current&&j({text:Ct("add that address",null),field:"addr"})}finally{M()}},[g,h,t,e.peers,s,r,B,M]),q=y.useCallback(async Y=>{if(!B(`invite:${Y}`))return;const Z=Y==="make"?"make an invite":"cancel that invite";try{const ee=await Bp("/api/lan/invite",{action:Y});if(!F.current)return;ee!=null&&ee.ok?(I.current=Y,j(null),_(null),s()):j({text:PS(gK,ee,Z)})}catch{F.current&&j({text:Ct(Z,null)})}finally{M()}},[s,B,M]),H=y.useCallback(async()=>{const Y=N.trim();if(!(!Y||!B("join"))){A(null);try{const Z=await Bp("/api/lan/invite",{action:"join",token:Y});if(!F.current)return;Z!=null&&Z.ok?(k(""),j(null),s(),r()):(Z==null?void 0:Z.reason)==="unreachable"&&Array.isArray(Z.tried)&&Z.tried.length?(A(Z.tried),j(null)):(A(null),j({text:PS(mK,Z,"use that invite"),field:"join"}))}catch{F.current&&j({text:Ct("use that invite",null),field:"join"})}finally{M()}}},[N,s,r,B,M]),D=y.useCallback(async(Y,Z)=>{try{await navigator.clipboard.writeText(Y),_(Z),window.setTimeout(()=>{F.current&&_(ee=>ee===Z?null:ee)},1600)}catch{j({text:"Could not copy it — select the text and copy it by hand."})}},[]),W=e.invite&&e.invite.expiresAt>U?e.invite:null,J=y.useRef(!1);y.useEffect(()=>{n!=="invite"||J.current||W||(J.current=!0,q("make"))},[n,W,q]);const V=y.useRef(!1);y.useEffect(()=>{var Y;n!=="invite"||V.current||!W||(V.current=!0,(Y=c.current)==null||Y.focus())},[n,W]),y.useEffect(()=>{var Z,ee;const Y=I.current;!Y||Y==="make"!=!!W||(I.current=null,Cn(((Z=document.activeElement)==null?void 0:Z.tagName)??null)&&((ee=(Y==="make"?c:d).current)==null||ee.focus()))},[W]);const X=e.port!=null?(e.addrs??[]).map(Y=>`${Y}:${e.port}`):[];return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:a.jsxs("div",{ref:f,className:"modal lan-add",onClick:Y=>Y.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-add-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"lan-add-title",className:"modal-tool-name",children:"Add a deck"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{className:"glyph-btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[x&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:x.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>j(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),a.jsx(BI,{reach:e.reach,where:"dialog"}),h&&a.jsx("div",{className:"modal-section",children:a.jsx("p",{className:"lan-note",children:"Adding by address is off while this deck pairs only by invite."})}),!h&&a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"By address"}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("input",{ref:o,className:"ap-manage-input ap-lan-input","aria-label":"Another deck's address",value:g,placeholder:"192.168.1.5:54340",spellCheck:!1,...P("addr"),onChange:Y=>{v(Y.target.value),G("addr")},onKeyDown:Y=>{Y.key==="Enter"&&K()}}),g.trim()!==""&&a.jsx("button",{type:"button",className:"ap-manage-btn",...$("add"),onClick:()=>void K(),title:"Add it to the decks this one calls, starting now.",children:"add"})]}),a.jsx("p",{className:"lan-note",children:"This deck calls that address until somebody there accepts."}),e.port!=null&&X.length>0&&a.jsxs("p",{className:"lan-note",children:["They type this deck’s own address into the same field on theirs:"," ",X.map((Y,Z)=>a.jsxs("span",{children:[Z>0&&" or ",a.jsx("code",{className:"ap-lan-code",children:Y})]},Y)),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",...$("copy:mine"),onClick:()=>void D(X.join(" "),"mine"),title:"Copy this deck's address, to send to whoever is adding it",children:b==="mine"?"copied":"copy"})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("h3",{className:"lan-h",children:["With an invite",!W&&a.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",ref:d,...$("invite:make"),onClick:()=>void q("make"),title:"One piece of text you send them. They paste it, and the two decks pair — nobody has to press anything here.",children:E==="invite:make"?"making…":"make one to send"})]}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("input",{ref:l,className:"ap-manage-input ap-lan-input","aria-label":"An invite you were sent",value:N,placeholder:"paste one you were sent",spellCheck:!1,...P("join"),onChange:Y=>{k(Y.target.value),A(null),G("join")},onKeyDown:Y=>{Y.key==="Enter"&&H()}}),N.trim()!==""&&a.jsx("button",{type:"button",className:"ap-manage-btn",...$("join"),onClick:()=>void H(),title:"Reach that deck and pair with it. Nobody has to press anything there.",children:E==="join"?"joining…":"join"})]}),a.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),T&&a.jsxs("div",{className:"ap-lan-tried",children:[a.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."}),T.map(Y=>a.jsxs("span",{className:"ap-lan-tried-row",children:[a.jsx("code",{className:"ap-lan-code",children:Y.addr}),a.jsx("span",{className:"ap-lan-bad",children:Y.why})]},Y.addr))]}),W&&a.jsxs("div",{className:"ap-lan-invite",children:[a.jsxs("div",{className:"ap-lan-invite-head",children:[a.jsx("span",{className:"ap-lan-invite-title",children:"Send this to them"}),a.jsxs("span",{className:"ap-lan-invite-left",id:"lan-invite-left",children:[pK(W.expiresAt,U)," left"]})]}),a.jsx("code",{className:"ap-lan-token",children:W.token}),a.jsxs("div",{className:"ap-lan-acts",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",ref:c,...$("copy:invite"),"aria-label":b==="invite"?"Invite copied":"Copy invite","aria-describedby":"lan-invite-left",onClick:()=>void D(W.token,"invite"),title:"Copy it, and send it however you already talk to them",children:b==="invite"?"copied":"copy"}),a.jsx("button",{type:"button",className:"ap-manage-btn",...$("invite:withdraw"),onClick:()=>void q("withdraw"),title:"Cancel it. Anybody already holding the text can no longer use it.",children:"cancel"})]}),a.jsx("p",{className:"lan-warn",children:"Anyone who gets this text can pair with this deck until it runs out."})]})]})]})]})}),document.body)}function wK(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}".`}function vK({asks:e,pressProps:t,answer:n}){return a.jsx("div",{className:"ap-lan-asks",role:"alert",children:e.map(r=>a.jsxs("div",{className:"ap-lan-ask",children:[a.jsxs("span",{className:"ap-lan-ask-what",children:[a.jsx("strong",{className:"ap-lan-peer-name",children:r.name})," at ",a.jsx("code",{className:"ap-lan-code",children:r.addr})," wants to pair"]}),a.jsxs("span",{className:"ap-lan-ask-fp",id:`lan-ask-fp-${r.fp}`,children:["fingerprint ",a.jsx("code",{className:"ap-lan-code",children:r.fp})]}),a.jsxs("span",{className:"ap-lan-ask-acts",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",...t(`accept:${r.fp}`),"aria-label":`Accept ${r.name}`,"aria-describedby":`lan-ask-fp-${r.fp}`,onClick:()=>void n("accept",r.fp,"accept that deck"),title:`Talk to this deck from now on. Its fingerprint is ${r.fp} — check it matches the one on their screen before you accept.`,children:"accept"}),a.jsx("button",{type:"button",className:"ap-manage-btn",...t(`dismiss:${r.fp}`),"aria-label":`Decline ${r.name}`,"aria-describedby":`lan-ask-fp-${r.fp}`,onClick:()=>void n("dismiss",r.fp,"decline that request"),title:"Say no. Nothing is shared, and that deck is told rather than left waiting.",children:"decline"})]})]},r.fp))})}function xK({rows:e,pairingMode:t,armed:n,pressProps:r,answer:s,dropAddress:o,onUnpair:l,onOpenPeer:c,onInvite:d}){return a.jsx("ul",{className:"ap-lan-here",children:e.map((h,f)=>a.jsxs("li",{className:"ap-lan-who","data-tone":h.tone,children:[a.jsx("i",{className:h.here?"ap-pulse":"ap-dot","aria-hidden":!0}),a.jsxs("span",{className:"ap-lan-who-name","aria-hidden":!0,children:[h.name,h.via==="tailscale"&&a.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]}),a.jsx("button",{type:"button",className:"ap-lan-who-open","aria-haspopup":"dialog","aria-describedby":`lan-who-state-${f}`,onClick:()=>c(h.fp),children:a.jsxs("span",{className:"vis-hidden",children:[h.name,h.via==="tailscale"?", over Tailscale":"",", details"]})}),a.jsx("span",{id:`lan-who-state-${f}`,className:h.quiet?"vis-hidden":"ap-lan-who-when",children:h.state}),h.kind==="nearby"&&t!=="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`accept:${h.fp}`),onClick:()=>void s("accept",h.fp,"reach that deck"),"aria-label":`Ask ${h.name} to pair`,title:`Send ${h.name} a request. Somebody at that machine has to accept it before anything is shared. Its fingerprint is ${h.fp}.`,children:"ask"}),(h.kind==="nearby"||h.kind==="declined")&&t==="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do","aria-haspopup":"dialog",onClick:d,"aria-label":`Invite ${h.name} to pair`,title:`This deck pairs only by invite. Make one and send it to whoever is at ${h.name}.`,children:"invite"}),h.kind==="paired"&&a.jsx("button",{type:"button",className:`ap-manage-btn ap-lan-do danger${n===h.fp?" armed":""}`,...r(`unpair:${h.fp}`),onClick:()=>l(h),"aria-label":n===h.fp?`Confirm unpairing ${h.name}`:`Unpair ${h.name}`,title:n===h.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:n===h.fp?"confirm":"unpair"}),h.kind==="dialling"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`drop:${h.fp}`),onClick:()=>void o(h.fp),"aria-label":`Stop dialling ${h.name}`,title:"Stop trying this address. Nothing was ever paired here.",children:"stop"}),h.kind==="declined"&&t!=="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`allow:${h.fp}`),onClick:()=>void s("allow",h.fp,"let that deck ask again"),"aria-label":`Let ${h.name} ask again`,title:"Take the no back. That deck is still trying, so the request comes round again on its own.",children:"allow"})]},`${h.kind}:${h.fp}`))})}function bK(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 kK({on:e,status:t}){return a.jsxs(a.Fragment,{children:[e&&a.jsx(BI,{reach:t==null?void 0:t.reach,where:"panel"}),e&&(t==null?void 0:t.deaf)&&a.jsx("p",{className:"ap-lan-fine",children:t.deaf}),e&&(t==null?void 0:t.lanTunneled)&&a.jsx("p",{className:"ap-lan-fine",children:bK(t)})]})}const DS=["online","offline","loose"],NK={online:0,offline:1,loose:2};function jK(e){return e.kind==="declined"?null:e.kind==="paired"?e.here?"online":"offline":"loose"}const SK=76,_K=62,Td=96,EK={1:[.62],2:[.58,1],3:[.42,.72,1]},CK=.2,TK=.16,AK=.05,RK=20,MK=17,qu=7,$K=30,IK=116,OK=6.6,LK=6,PK=e=>j0(e,null),DK=1.5,FK=80,BK=.45,FS=40,qK=64,UK=150,BS=.3,qS=84,US=8,zK=1.3,Ad=6,WK=5.94,zS=7,WS=16,xl=4,HS=.16;function rb(e,t){return Math.PI*(3*(e+t)-Math.sqrt((3*e+t)*(e+3*t)))}function qI(e,t){return t<-Math.abs(e)*.6?"top":"bottom"}function HK(e,t){if(e<=2)return t%2===0?0:90;const n=360/e;return-90+(t%2===0?0:n/2)}function VK(e){return e.map((t,n)=>({...t,i:n})).sort((t,n)=>DS.indexOf(t.tier)-DS.indexOf(n.tier)||+(t.row.via==="tailscale")-+(n.row.via==="tailscale")||t.i-n.i).map(({row:t,tier:n})=>({row:t,tier:n}))}function VS(e,t){let n=2166136261^t;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619);return(n>>>0)%2e4/1e4-1}function GK(e,t,n){const r=[...EK[e.length]??[]];for(let s=0;s<r.length;s++){const o=e[s];if(o<2)continue;const l=rb(t*r[s],n*r[s])/o;if(!(l>0)||l>=Td)continue;const c=s+1<r.length?r[s+1]-CK:1;r[s]=Math.max(r[s],Math.min(c,r[s]*(Td/l)*1.02))}return r}const Pa=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1,qp={h:16,ch:6.1,maxW:100};function KK(e){const t=e?Math.max(80,e.length*7.2+16):128;return{x0:-t/2,y0:32,x1:t/2,y1:66}}function UI(e,t,n,r,s,o){const l=t==="loose"?MK:RK,c=!s||e.kind==="asks",d=c?$K:qp.h,h=s?qp.ch:OK,f=c?o.length:0,p=Math.min(s?qp.maxW:IK,Math.max(2*l,WI(e).length*h,f*LK)),g={x0:n-l,y0:r-l,x1:n+l,y1:r+l},v=qI(n,r)==="top"?{x0:n-p/2,y0:r-l-qu-d,x1:n+p/2,y1:r-l-qu}:{x0:n-p/2,y0:r+l+qu,x1:n+p/2,y1:r+l+qu+d};return[g,v]}const sb=e=>{const t=e.theta*Math.PI/180;return[Math.cos(t)*e.ring.rx*e.reach,Math.sin(t)*e.ring.ry*e.reach]},Uu=(e,t)=>((e-t)%360+540)%360-180;function GS(e,t,n){const r=new Map;for(const f of e)r.has(f.ring)||r.set(f.ring,[]),r.get(f.ring).push(f);const s=()=>e.map(f=>{const[p,g]=sb(f);return UI(f.row,f.tier,p,g,t,f.caption)}),o=(f,p,g=!1)=>{if(f.count<=2&&!g)return!1;const v=f.theta+p*DK,N=r.get(f.ring),k=(f.count>2?360/f.count:f.turn)*BK,x=N[(f.index+1)%f.count],j=N[(f.index-1+f.count)%f.count];return!(x===f||(p>0?Uu(x.theta,v)>=k:Uu(v,j.theta)>=k))||v<f.lo||v>f.hi?!1:(f.theta=v,!0)},l=([f,p],[g,v])=>Pa(p,g)||Pa(v,f)||Pa(p,v)||Pa(f,g),c=([f,p])=>Pa(f,n)||Pa(p,n);for(let f=0;f<FK;f++){const p=s();let g=!1;for(let v=0;v<e.length;v++){c(p[v])&&(g=o(e[v],Uu(e[v].theta,90)>=0?1:-1,!0)||g);for(let N=v+1;N<e.length;N++){if(!l(p[v],p[N]))continue;const k=e[v],x=e[N],j=x.ring.ring>k.ring.ring||x.ring===k.ring&&N>v?x:k,b=j===x?k:x,_=Uu(j.theta,b.theta)>=0?1:-1;g=o(j,_)||o(b,-_)||g}}if(!g)break}const d=s();let h=0;for(let f=0;f<d.length;f++){c(d[f])&&h++;for(let p=f+1;p<d.length;p++)l(d[f],d[p])&&h++}return h}const YK={online:0,offline:1,loose:1};function XK(e,t,n,r="",s=PK){const o=[];for(const l of[!0,!1]){const c=KS(e,t,n,r,NK,s,l);if(c.clashes===0)return c.named();if(o.push(c),c.layout.rings.length===3){const d=KS(e,t,n,r,YK,s,l),h={clashes:d.clashes,named:()=>({...d.named(),folded:!0})};if(h.clashes===0)return h.named();o.push(h)}if(!c.layout.zone)break}return o.reduce((l,c)=>c.clashes<l.clashes?c:l).named()}function KS(e,t,n,r,s,o,l=!0){const c=new Map;for(const B of e){const M=jK(B);if(!M)continue;const $=s[M];c.has($)||c.set($,[]),c.get($).push({row:B,tier:M})}const d=[...c.keys()].sort((B,M)=>B-M),h=Math.max(0,t/2-SK),f=Math.max(0,n/2-_K),p=GK(d.map(B=>c.get(B).length),h,f),g=d.map((B,M)=>({ring:B,rx:h*p[M],ry:f*p[M],count:c.get(B).length})),v=g.reduce((B,M)=>B+M.count,0),N=B=>B.row.via==="tailscale",k=[...c.values()].flat().filter(N).length,x=Math.max(0,...g.map(B=>{const M=c.get(B.ring).filter(N).length,$=rb(B.rx,B.ry);return M>0&&$>0?M*Td*zK/$*360:0})),j=l&&k>0&&k<v?Math.min(UK,Math.max(qK,k/v*360,x)):0,b=FS-j/2,_=FS+j/2,E=[];let R=!1;g.forEach((B,M)=>{const $=VK(c.get(B.ring)),P=$.length,G=P>1&&rb(B.rx,B.ry)/P<Td;G&&(R=!0);const K=M===g.length-1,q=K?-HS*(p[M]-(p[M-1]??0)):HS*(p[M+1]-p[M]),H=j>0?[{members:$.filter(W=>W.row.via!=="tailscale"),from:_,width:360-j},{members:$.filter(W=>W.row.via==="tailscale"),from:b+360,width:j}]:[{members:$,from:null,width:360}];let D=0;for(const W of H){const J=W.members.length;if(J===0)continue;const V=W.width/J,X=J>2;W.members.forEach(({row:Y,tier:Z},ee)=>{const ne=rr(Y),se=W.from==null?HK(J,M)+V*ee:W.from+V*(ee+.5),pe=X?VS(ne,1)*TK*V:0,ke=G&&D%2===1?1+q/p[M]:1,ae=X?VS(ne,2)*AK:0,fe=V*.3;E.push({row:Y,tier:Z,ring:B,index:D,count:P,theta:se+pe,reach:ke*(1+(K?-Math.abs(ae):ae)),lo:W.from==null?-1/0:W.from+fe,hi:W.from==null?1/0:W.from+W.width-fe,turn:V,caption:o(Y)}),D++})}});const T=KK(r);let A=GS(E,R,T);A>0&&!R&&(R=!0,A=GS(E,!0,T));const U=E.map((B,M)=>{const[$,P]=sb(B);return{row:B.row,tier:B.tier,ring:B.ring.ring,x:$,y:P,angle:ZK(Math.atan2(P,$)*180/Math.PI),dist:Math.hypot($,P),side:qI($,P),order:M}}),L=g.reduce((B,M,$)=>c.get(M.ring).some(N)?Math.max(B,p[$]):B,0),F=B=>({from:b,to:_,inner:{rx:h*BS,ry:f*BS},outer:{rx:Math.min(t/2-8,h*L+B),ry:Math.min(n/2-8,f*L+B)},count:k}),O={nodes:U,rings:g,dense:R,zone:j>0?{...F(qS),labelAt:null}:null};return{layout:O,clashes:A,named:()=>{if(!O.zone)return O;const B=E.flatMap(P=>{const[G,K]=sb(P);return UI(P.row,P.tier,G,K,R,P.caption)});let M={...O.zone,labelAt:YS(O.zone,B)},$=M.outer;for(let P=qS+US;M.labelAt==null;P+=US){const G=F(P);if(G.outer.rx===$.rx&&G.outer.ry===$.ry)break;$=G.outer;const K=YS(G,B);K!=null&&(M={...G,labelAt:K})}return{...O,zone:M}}}}function zI(e){return`Tailscale · ${e} deck${e===1?"":"s"}`}function YS(e,t){const n={rx:e.outer.rx-Ad,ry:e.outer.ry-Ad};if(!(n.rx>0&&n.ry>0))return null;const r=Math.min(.5,2/Math.max(n.rx,n.ry)*(180/Math.PI)),s=[];for(let b=e.to;b>=e.from;b-=r){const _=b*Math.PI/180;s.push([Math.cos(_)*n.rx,Math.sin(_)*n.ry])}const o=zS+xl,l={x0:Math.min(...s.map(b=>b[0]))-o,x1:Math.max(...s.map(b=>b[0]))+o,y0:Math.min(...s.map(b=>b[1]))-o,y1:Math.max(...s.map(b=>b[1]))+o},c=t.map(b=>({x0:b.x0-xl,y0:b.y0-xl,x1:b.x1+xl,y1:b.y1+xl})).filter(b=>Pa(b,l)),d=(b,_)=>c.some(E=>b>E.x0&&b<E.x1&&_>E.y0&&_<E.y1),h=[],f=[];let p=0;s.forEach(([b,_],E)=>{E>0&&(p+=Math.hypot(b-s[E-1][0],_-s[E-1][1]));const R=Math.hypot(b,_)||1;let T=!1;for(let A=0;A<=zS&&!T;A+=1.75)T=d(b-b/R*A,_-_/R*A);h.push(p),f.push((f.at(-1)??0)+(T?1:0))});const g=zI(e.count).length*WK/2,v=g+WS,N=p-g-WS;if(!(p>0)||N<v)return null;const k=b=>{let _=0,E=h.length;for(;_<E;){const R=_+E>>1;h[R]<b?_=R+1:E=R}return _},x=b=>{const _=k(b-g),E=k(b+g+1e-9)-1;return E<_||f[E]-(_>0?f[_-1]:0)===0},j=p/2;for(let b=0;j-b>=v;b+=2)for(const _ of b===0?[j]:[j-b,j+b])if(x(_))return _/p;return null}function ZK(e){return(e%360+360)%360}function JK(e){const t=n=>e.filter(n).length;return{paired:t(n=>n.kind==="paired"),online:t(n=>n.kind==="paired"&&n.here),offline:t(n=>n.kind==="paired"&&!n.here),nearby:t(n=>n.kind==="nearby"),asks:t(n=>n.kind==="asks"),dialling:t(n=>n.kind==="dialling"),declined:t(n=>n.kind==="declined"),tailnet:t(n=>n.kind!=="declined"&&n.via==="tailscale"),oneWay:t(n=>n.kind==="paired"&&!n.here&&n.state.startsWith("one-way"))}}function QK(e){const t=[];return e.asks&&t.push(e.asks===1?"1 deck wants to pair":`${e.asks} decks want to pair`),e.paired===0?t.push("no paired decks yet"):e.paired===1?t.push(e.online?"1 paired deck, online":"1 paired deck, away"):e.online===e.paired?t.push(`${e.paired} paired decks, all online`):t.push(`${e.online} of ${e.paired} paired decks online`),e.nearby&&t.push(`${e.nearby} nearby, not paired`),e.dialling&&t.push(`${e.dialling} still dialling`),t.join(" · ")}function j0(e,t){switch(e.kind){case"asks":return"wants to pair";case"nearby":return e.state;case"dialling":return HI(e)?`${e.name.slice(e.addr.length)} · dialling`:"dialling";case"declined":return"declined";case"paired":{if(e.here)return t?eY(t):"online";const n=GI(e);return n?n==="now"?"away · just now":`away · ${n}`:e.state.startsWith("one-way")?"has not called yet":"away"}}}function WI(e){return HI(e)?e.addr:e.name}function HI(e){return e.kind==="dialling"&&!!e.addr&&e.name.startsWith(`${e.addr}:`)}function VI(e){if(e.kind!=="paired")return e.via==="tailscale"?`${e.state}, over Tailscale`:e.state;if(e.here)return e.via==="tailscale"?"online, over Tailscale":"online";const t=GI(e),n=t?t==="now"?"away · last online just now":`away · last online ${t}`:e.state.startsWith("one-way")?e.state:"away";return e.via==="tailscale"?`${n}, over Tailscale`:n}function GI(e){var t;return((t=/last online (.+)$/.exec(e.state))==null?void 0:t[1])??null}function eY(e){return e.trim().split(/\s+/).slice(0,2).join(" ")}function tY(e){var r;if(!e)return[];const t=(e.addrs??[]).map(s=>`${s}:${e.port}`),n=(r=e.tailscale)==null?void 0:r.addr;return n&&!(e.addrs??[]).includes(n)&&t.push(`${n}:${e.port}`),t}function rr(e){let t=e.fp;for(const n of e.twins??[])n.fp<t&&(t=n.fp);return t}function nY(e,t){if(e==null)return t;const n=((t-e)%360+540)%360-180;return e+n}function rY(e,t){if(e.asks)return e.asks===1?"1 deck wants to pair. Answer it in the Local network list, behind this map.":`${e.asks} decks want to pair. Answer them in the Local network list, behind this map.`;if(e.oneWay)return`${e.oneWay} away deck${e.oneWay===1?" only calls":"s only call"} in, and this deck has no address to call ${e.oneWay===1?"it":"them"} on. Add ${e.oneWay===1?"its address":"their addresses"} through Add a deck to reach ${e.oneWay===1?"it":"them"} both ways.`;if(e.dialling)return e.dialling===1?"1 address has never answered. Open it to stop dialling it.":`${e.dialling} addresses have never answered. Open one to stop dialling it.`;if(e.nearby){const n=e.nearby===1?"1 deck nearby is not paired.":`${e.nearby} decks nearby are not paired.`;return t==="invite"?`${n} ${KI}`:e.nearby===1?`${n} Open it to ask to pair.`:`${n} Open one to ask to pair.`}return null}const KI="This deck pairs by invite only. Send one from Add a deck.";function sY(e,t){switch(e.kind){case"asks":return"Waiting for your answer, in the Local network list behind this map.";case"dialling":return"Nothing has answered here yet. Its dialog can stop dialling it.";case"nearby":return t==="invite"?KI:"Not paired yet. Its dialog can ask to pair.";case"paired":return!e.here&&e.state.startsWith("one-way")?"It can reach this deck, not the other way. Add its address through Add a deck.":null;default:return null}}function aY(e){const t={bad:0,wait:1,idle:2,ok:3};return e.map((n,r)=>({l:n,i:r})).sort((n,r)=>t[n.l.tone]-t[r.l.tone]||n.i-r.i).map(({l:n})=>n)}function oY(e,t){const n=/^(\d+)\.(\d+)\.(\d+)/.exec(e??""),r=/^(\d+)\.(\d+)\.(\d+)/.exec(t??"");if(!n||!r)return null;for(let s=1;s<=3;s++){const o=Number(n[s])-Number(r[s]);if(o)return Math.sign(o)}return 0}function iY(e,t,n,r=!0){const s=t?t.alive?t.shareable===!1?"cannot share here":"works here":"expired here":"not on this deck";if(e.alive&&e.shareable===!1)return{there:"cannot share there",here:s,note:null,tone:"idle"};if(!e.alive){const o=t&&!t.alive?"neither copy works — sign in again here":null;return{there:"broken there",here:s,note:o,tone:o?"bad":"idle"}}return t?t.alive?{there:"works there",here:s,note:null,tone:t.shareable===!1?"idle":"ok"}:n?{there:"works there",here:s,note:"repairs next round",tone:"wait"}:{there:"works there",here:s,note:"share it to repair",tone:"bad"}:r||n?{there:"works there",here:s,note:"arrives next round",tone:"wait"}:{there:"works there",here:s,note:"paired automatically — pair by invite to take it",tone:"bad"}}function lY(e,t,n,r=null,s=!0){var h;const o=new Map;for(const f of t)(h=o.get(f.key))!=null&&h.alive||o.set(f.key,f);const l=new Set(n),c=[],d=new Set;for(const f of e??[]){if(d.has(f.key))continue;d.add(f.key);const p=o.get(f.key)??null,g=l.has(f.key),v=iY(f,p,g,s),N=p?p.alive?p.shareable===!1?"unavailable":"works":"expired":"missing",k=!f.alive&&p&&!p.alive?v.note:[N==="works"?null:v.here,f.alive&&f.shareable!==!1?null:v.there,v.note].filter(Boolean).join(" · ")||null;c.push({key:f.key,email:f.email,here:N,there:f.alive?f.shareable===!1?"unavailable":"works":"broken",in:!f.alive||f.shareable===!1?"cut":v.tone==="wait"?"wait":v.tone==="bad"?"blocked":"live",out:g&&p?p.alive&&p.shareable!==!1?"live":"cut":null,caption:k,tone:v.tone,usedThere:r===f.key})}for(const f of n){const p=o.get(f);!p||d.has(f)||(d.add(f),c.push({key:f,email:p.email,here:p.alive?p.shareable===!1?"unavailable":"works":"expired",there:"unknown",in:null,out:p.alive&&p.shareable!==!1?"live":"cut",caption:p.alive?p.shareable===!1?"cannot share here":null:"expired here",tone:p.alive?p.shareable===!1?"idle":"ok":"bad",usedThere:!1}))}return c}const cY=1e3;function uY(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),r=Fr(e,t);return`${n} · ${r==="now"?"just now":r}`}function ab(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}const YI={works:"works here",expired:"expired here",missing:"not on this deck",unavailable:"cannot share here"},XI={works:"works there",broken:"broken there",unavailable:"cannot share there",unknown:"not offered by that deck"};function ZI(e){const t=e.in&&e.out?"offered both ways":e.in?"offered by that deck":"offered by this deck";return`${YI[e.here]}, ${XI[e.there]}, ${t}${e.usedThere?", in use there":""}.`}function JI({row:e,source:t,status:n,accounts:r,now:s}){var V,X,Y,Z,ee;const{peer:o,stranger:l}=t,c=e.kind==="paired",d=e.self??e.name,h=e.kind!=="dialling",f=e.kind==="dialling"?null:e.fp,p=o?o.addr?`${o.addr}:${o.port}`:"":l?l.port?`${l.addr}:${l.port}`:l.addr:e.addr,g=(o==null?void 0:o.about)??null,v=((V=n.about)==null?void 0:V.version)??null,N=c?o!=null&&o.waiting?o.lastSeen!=null?"not said — it runs an older version":"not said yet — it says when it next calls":o!=null&&o.offers?"not said — it runs an older version":"not reached yet":"shown once paired",k=ab(n.about),x=ab(g),j=g!=null&&g.version&&v?oY(g.version,v):null,b=o?dh(o.last,s):null,_=o&&((X=o.last)!=null&&X.error)?NG({error:o.last.error,host:o.addr,port:o.port},[...n.strangers??[],...n.pending??[],...(n.peers??[]).filter(ne=>!ne.manual&&ne.addr).map(ne=>({fp:ne.fp,name:ne.name,addr:ne.addr,port:ne.port,at:ne.lastSeen??0}))],s):null,E=(Y=o==null?void 0:o.last)!=null&&Y.error&&b&&b.text!==o.last.error?o.last.error:null,R=((Z=o==null?void 0:o.last)==null?void 0:Z.done)??[],T=!!b&&!!E&&!e.quiet&&e.state.startsWith(b.text),A=c||e.kind==="dialling",U=((o==null?void 0:o.via)??e.via)==="tailscale",L=o?o.waiting?null:o.manual?U?"added by its Tailscale address":"added by address":U?"over Tailscale":"on this network":e.kind==="nearby"?U?"heard over Tailscale":"heard on this network":U?"asked this deck to pair, over Tailscale":"asked this deck to pair",F=e.tone==="bad"?"bad":c?e.here?"up":"down":"loose",O=(o==null?void 0:o.offers)??null,I=F==="up"?(O==null?void 0:O.current)??null:null,B=I&&"key"in I?I.key:null,M=!!I&&"hidden"in I,$=!!I&&"other"in I,P=c?lY((O==null?void 0:O.accounts)??null,r,n.shared??[],B,(o==null?void 0:o.autoPaired)!==!0):[],G=P.filter(ne=>ne.in==null&&ne.out==="cut"),K=P.some(ne=>ne.in!=null),q=P.some(ne=>ne.out!=null),H=new Map(R.map(ne=>[ne.email,ne])),D=R.filter(ne=>!P.some(se=>se.email===ne.email)),W=c?O?O.accounts.length===0?"That deck offers nothing. Nobody there has chosen a login to share.":null:o!=null&&o.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.":(ee=o==null?void 0:o.last)!=null&&ee.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,J=O&&(o!=null&&o.last)&&o.last.at-O.at>cY?Fr(O.at,s):null;return{peer:o,stranger:l,paired:c,own:d,canRename:h,fp:f,where:p,about:g,unsaid:N,hereRuns:k,thereRuns:x,order:j,line:b,silence:_,raw:E,echoed:T,showRound:A,how:L,link:F,hiddenThere:M,otherThere:$,lanes:P,spent:G,taking:K,giving:q,told:H,unplaced:D,unknown:W,stale:J}}function ob(){return a.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:[a.jsx("rect",{x:"2.5",y:"3",width:"11",height:"7.5",rx:"1.2"}),a.jsx("path",{d:"M1 13h14"})]})}function zu({dir:e,gate:t=!1}){const n=t?12:8;return a.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:a.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"})})}function dY({view:e,row:t,status:n,asking:r,drawn:s,onSettings:o}){const{peer:l,paired:c,where:d,about:h,unsaid:f,hereRuns:p,thereRuns:g,order:v,line:N,silence:k,raw:x,echoed:j,showRound:b,how:_,link:E,hiddenThere:R,otherThere:T,lanes:A,spent:U,taking:L,giving:F,told:O,unplaced:I,unknown:B,stale:M}=e;return a.jsxs("div",{className:"lan-map","data-link":E,"data-asking":r||void 0,"data-bus":A.length>0||void 0,children:[a.jsxs("div",{className:"lan-ends",children:[a.jsxs("p",{className:"lan-end",children:[a.jsx("span",{className:"lan-end-name",children:"This deck"}),p&&a.jsx("span",{className:"lan-end-runs",children:p}),c&&n.shareActive===!1&&a.jsx("span",{className:"lan-end-note",children:"current account hidden"})]}),a.jsxs("p",{className:"lan-end","data-side":"there",children:[a.jsx("span",{className:"lan-end-name",children:t.name}),t.kind!=="dialling"&&a.jsxs("span",{className:"lan-end-runs",children:[g??(h?"not said":f),v?` · ${v<0?"older":"newer"}`:null]}),R&&a.jsx("span",{className:"lan-end-note",children:"current account hidden"}),T&&a.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),a.jsxs("div",{className:"lan-link",children:[a.jsx(ob,{}),a.jsxs("span",{className:"lan-span",children:[a.jsxs("span",{className:"lan-wire","aria-hidden":!0,children:[a.jsx("i",{className:"lan-glint","data-dir":"out"}),a.jsx("i",{className:"lan-glint","data-dir":"in"})]}),a.jsx("span",{className:"lan-link-label",children:d?a.jsx("code",{className:"ap-lan-code",children:d}):"none here — it calls this deck"})]}),a.jsx(ob,{}),(d&&_||b)&&a.jsxs("p",{className:"lan-link-sub",children:[d&&_,d&&_&&b&&" · ",b&&(N?j?a.jsx("code",{className:"ap-lan-code",children:x}):a.jsx("span",{className:"lan-round","data-tone":N.tone,children:N.text.replace(/ · now$/," · just now")}):"not asked yet"),b&&x&&!j&&a.jsx("code",{className:"lan-fact-raw",children:x})]}),I.length>0&&a.jsx("ul",{className:"lan-done",children:I.map($=>{const P=Jx($);return a.jsxs("li",{"data-ok":$.ok&&!P,children:[$.email," ",a.jsxs("span",{className:"lan-done-what",children:[$.ok?"arrived":"did not arrive",P&&` — ${P.long}`]})]},`${$.email}:${$.action}`)})}),k&&a.jsx("p",{className:"lan-note lan-link-note",children:k}),(l==null?void 0:l.waiting)&&a.jsx("p",{className:"lan-note lan-link-note",children:t.hint}),(N==null?void 0:N.hint)&&a.jsx("p",{className:"lan-note lan-link-note",children:N.hint})]}),A.length>0&&a.jsx("ul",{className:"lan-lanes",role:"list","aria-label":`Logins between this deck and ${t.name}`,children:A.map(($,P)=>{const G=O.get($.email),K=G?Jx(G):null,q=$.out==="live"||$.in!=null&&$.in!=="cut";return a.jsxs("li",{role:"listitem",className:"lan-lane","data-tone":$.tone,"data-draw":$.in&&$.out?"both":$.in?"in":"out","data-used-there":$.usedThere||void 0,style:{"--i":P},children:[a.jsx("i",{className:"lan-pip","data-end":"here","data-state":$.here,"aria-hidden":!0}),a.jsxs("span",{className:"lan-track",children:[a.jsxs("span",{className:"lan-wire","data-flow":q?"live":"cut","aria-hidden":!0,children:[($.in==="live"||$.in==="wait")&&a.jsx("i",{className:"lan-glint","data-dir":"in","data-tone":$.in}),$.out==="live"&&a.jsx("i",{className:"lan-glint","data-dir":"out"})]}),$.in&&$.in!=="cut"&&a.jsx(zu,{dir:"in",gate:$.in==="blocked"}),$.out==="live"&&a.jsx(zu,{dir:"out"}),a.jsx("span",{className:"lan-lane-email",children:$.email})]}),a.jsx("i",{className:"lan-pip","data-end":"there","data-state":$.there,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:ZI($)}),($.caption||G)&&a.jsxs("span",{className:"lan-lane-note",children:[$.caption,$.caption&&G&&" · ",G&&a.jsxs("span",{className:"lan-lane-done","data-ok":G.ok&&!K,children:[G.ok?"arrived last round":"did not arrive last round",K&&` — ${K.long}`]})]})]},$.key)})},s),c&&a.jsxs(a.Fragment,{children:[U.length>0&&a.jsxs("p",{className:"lan-spent",children:["Paired decks get nothing from ",U.length===1?U[0].email:"the expired ones"," until you sign in again here."]}),B&&a.jsx("p",{className:"lan-empty",children:B}),M&&a.jsxs("p",{className:"lan-stale",children:["As of ",M==="now"?"just now":M,", when it last answered."]}),a.jsxs("div",{className:"lan-legend",children:[L&&a.jsxs("span",{className:"lan-key",children:[a.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:a.jsx(zu,{dir:"in"})}),"from ",t.name]}),F?a.jsxs("span",{className:"lan-key",children:[a.jsx("span",{className:"lan-key-wire","data-dir":"out","aria-hidden":!0,children:a.jsx(zu,{dir:"out"})}),"from this deck, to every paired deck"]}):a.jsx("span",{className:"lan-key",children:"This deck offers nothing yet."}),a.jsx("button",{type:"button",className:"ap-lan-word lan-legend-act",onClick:o,"aria-label":"Change what this deck offers",children:"change"})]})]})]})}const hY=20,fY=17,XS=34,pY=160,mY=80,gY=200,yY=8,wY=14,vY=10,xY=.61803398875;function bY({status:e,rows:t,accounts:n,now:r,covered:s,onOpenDeck:o,onClose:l}){const c=y.useRef(null),d=ut(l,{focusRef:c}),h=gt(l),f=y.useRef(null),[p,g]=y.useState(null),[v,N]=y.useState(!1),k=y.useRef(null);y.useLayoutEffect(()=>{const ae=f.current;if(!ae)return;let fe=null;const me=()=>{const ge=Math.round(ae.clientWidth),ue=Math.round(ae.clientHeight);fe&&fe.w===ge&&fe.h===ue||(fe&&(N(!0),k.current!=null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>N(!1),gY)),fe={w:ge,h:ue},g(fe))};if(me(),typeof ResizeObserver>"u")return;const he=new ResizeObserver(me);return he.observe(ae),()=>{he.disconnect(),k.current!=null&&window.clearTimeout(k.current)}},[]);const x=y.useMemo(()=>p?XK(t,p.w,p.h,(e==null?void 0:e.name)??"",ae=>{var fe,me;return j0(ae,(me=(fe=Ql(e,ae).peer)==null?void 0:fe.about)==null?void 0:me.os)}):null,[t,p,e]),j=y.useMemo(()=>JK(t),[t]),b=(x==null?void 0:x.nodes)??[],_=y.useRef(new Map),E=y.useMemo(()=>{const ae=new Map;for(const fe of b){const me=rr(fe.row);ae.set(me,nY(_.current.get(me),fe.angle))}return _.current=ae,ae},[b]),[R,T]=y.useState(null),[A,U]=y.useState(null),[L,F]=y.useState("none"),O=y.useRef(null),I=y.useCallback((ae,fe)=>{O.current!==ae&&(O.current=ae,F(fe),U(ae))},[]),B=y.useRef(null),M=y.useRef(null),$=y.useCallback(()=>{M.current!=null&&window.clearTimeout(M.current),M.current=null},[]),P=y.useCallback((ae,fe)=>{if(B.current!=null&&window.clearTimeout(B.current),B.current=null,$(),T(ae),fe==="keyboard"){I(ae,"none");return}M.current=window.setTimeout(()=>I(ae,O.current?"swap":"full"),mY)},[I,$]),G=y.useCallback(()=>{B.current!=null&&window.clearTimeout(B.current),$(),B.current=window.setTimeout(()=>T(null),pY)},[$]);y.useEffect(()=>()=>{B.current!=null&&window.clearTimeout(B.current),$()},[$]);const K=R&&b.some(ae=>rr(ae.row)===R)?R:null,q=A?t.find(ae=>rr(ae)===A)??null:null;y.useEffect(()=>{A&&!q&&I(null,"swap")},[A,q,I]);const[H,D]=y.useState(null),W=y.useRef(new Map),J=b.findIndex(ae=>rr(ae.row)===H),V=J<0?0:J,X=ae=>{var ge;if(b.length===0)return;const fe=ae.key==="ArrowRight"||ae.key==="ArrowDown"?1:ae.key==="ArrowLeft"||ae.key==="ArrowUp"?-1:0,me=ae.key==="Home"?0:ae.key==="End"?b.length-1:fe?(V+fe+b.length)%b.length:null;if(me==null)return;ae.preventDefault();const he=rr(b[me].row);D(he),(ge=W.current.get(he))==null||ge.focus()},[Y,Z]=y.useState(()=>typeof document<"u"&&document.hidden);y.useEffect(()=>{const ae=()=>Z(document.hidden);return document.addEventListener("visibilitychange",ae),()=>document.removeEventListener("visibilitychange",ae)},[]);const ee=(e==null?void 0:e.enabled)===!0,ne=e?ee?QK(j):"Local network is off":"checking…",se=()=>{$(),I(null,"swap"),T(null)},pe=K?b.find(ae=>rr(ae.row)===K)??null:null,ke=()=>{var ae;A&&((ae=W.current.get(A))==null||ae.focus()),se()};return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal nm-modal",onClick:ae=>ae.stopPropagation(),"data-paused":s||Y||void 0,role:"dialog","aria-modal":"true","aria-labelledby":"nm-title","aria-describedby":"nm-sub",children:[a.jsxs("header",{className:"modal-head nm-head",children:[a.jsxs("div",{className:"nm-heading",children:[a.jsx("h2",{id:"nm-title",className:"modal-title nm-title",children:"Network map"}),a.jsx("p",{id:"nm-sub",className:"nm-sub",children:ne})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:c,type:"button",className:"glyph-btn",onClick:l,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("div",{className:"nm-body",children:[a.jsxs("div",{className:"nm-view",children:[a.jsx("div",{ref:f,className:"nm-stage","data-focus":K?"":void 0,"data-focus-via":pe==null?void 0:pe.row.via,"data-dense":(x==null?void 0:x.dense)||void 0,"data-still":v||void 0,onClick:ae=>{ae.target===ae.currentTarget&&se()},children:p&&x&&a.jsxs(a.Fragment,{children:[a.jsx(kY,{layout:x,w:p.w,h:p.h}),b.map(ae=>{const fe=rr(ae.row);return a.jsx(SY,{node:ae,angle:E.get(fe)??ae.angle,lit:K===fe},fe)}),a.jsx(_Y,{status:e}),a.jsx("span",{id:"nm-ring-hint",className:"vis-hidden",children:"Arrow keys move between decks. Enter opens the deck's own dialog."}),a.jsx("div",{className:"nm-ring",role:"group","aria-label":`Decks around this deck, ${b.length}`,"aria-describedby":"nm-ring-hint",onKeyDown:X,children:b.map((ae,fe)=>{var he,ge;const me=rr(ae.row);return a.jsx(EY,{node:ae,angle:E.get(me)??ae.angle,os:(ge=(he=Ql(e,ae.row).peer)==null?void 0:he.about)==null?void 0:ge.os,lit:K===me,shown:A===me,tabbable:fe===V,register:ue=>{ue?W.current.set(me,ue):W.current.delete(me)},onHold:ue=>{D(me),P(me,ue)},onRelease:G,onOpen:()=>o(ae.row.fp)},me)})}),b.length===0&&a.jsx(CY,{status:e})]})}),a.jsx(TY,{slice:(x==null?void 0:x.zone)!=null})]}),a.jsx("aside",{className:"nm-side","aria-label":"Details",children:q&&e?a.jsx(RY,{row:q,status:e,accounts:n,now:r,entrance:L,onOpen:()=>o(q.fp),onBack:ke},rr(q)):a.jsx(AY,{status:e,summary:j,entrance:L,slice:(x==null?void 0:x.zone)!=null})})]})]})}),document.body)}function QI(){return a.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:[a.jsx("circle",{cx:"7",cy:"7.4",r:"1.8"}),a.jsx("circle",{cx:"2.4",cy:"2.9",r:"1.2"}),a.jsx("circle",{cx:"11.6",cy:"2.9",r:"1.2"}),a.jsx("circle",{cx:"7",cy:"12.4",r:"1.1"}),a.jsx("path",{d:"M5.7 6.1 3.3 3.8M8.3 6.1l2.4-2.3M7 9.2v2.1"})]})}function kY({layout:e,w:t,h:n}){const{zone:r}=e;return a.jsxs("svg",{className:"nm-orbits",width:t,height:n,viewBox:`0 0 ${t} ${n}`,"aria-hidden":!0,children:[r&&a.jsxs(a.Fragment,{children:[a.jsxs("defs",{children:[a.jsx("path",{id:"nm-zone-arc",d:jY(r,t/2,n/2)}),a.jsxs("radialGradient",{id:"nm-zone-fill",gradientUnits:"userSpaceOnUse",cx:t/2,cy:n/2,r:Math.max(r.outer.rx,r.outer.ry),children:[a.jsx("stop",{className:"nm-zone-stop",offset:"0.2","data-at":"in"}),a.jsx("stop",{className:"nm-zone-stop",offset:"0.5","data-at":"mid"}),a.jsx("stop",{className:"nm-zone-stop",offset:"1","data-at":"out"})]})]}),a.jsx("path",{className:"nm-zone",d:NY(r,t/2,n/2),fill:"url(#nm-zone-fill)"}),r.labelAt!=null&&a.jsx("text",{className:"nm-zone-label",children:a.jsx("textPath",{href:"#nm-zone-arc",startOffset:`${(r.labelAt*100).toFixed(2)}%`,textAnchor:"middle",children:zI(r.count)})})]}),e.rings.map((s,o)=>a.jsx("ellipse",{className:"nm-orbit","data-ring":s.ring,"data-folded":e.folded&&s.ring===1||void 0,cx:t/2,cy:n/2,rx:s.rx,ry:s.ry,style:{"--ring":o}},s.ring))]})}function ZS(e,t,n,r){const s=r*Math.PI/180;return`${(t+Math.cos(s)*e.rx).toFixed(1)},${(n+Math.sin(s)*e.ry).toFixed(1)}`}function NY(e,t,n){const r=e.to-e.from>180?1:0,s=(j,b)=>{const _=b*Math.PI/180;return[t+Math.cos(_)*j.rx,n+Math.sin(_)*j.ry]},o=(j,b)=>b/((j.rx+j.ry)/2)*(180/Math.PI),l=(j,b,_)=>{const E=Math.hypot(b[0]-j[0],b[1]-j[1])||1,R=Math.min(.5,_/E);return[j[0]+(b[0]-j[0])*R,j[1]+(b[1]-j[1])*R]},c=([j,b])=>`${j.toFixed(1)},${b.toFixed(1)}`,d=vY,h=wY,f=o(e.inner,d),p=o(e.outer,h),g=s(e.inner,e.from),v=s(e.outer,e.from),N=s(e.outer,e.to),k=s(e.inner,e.to),x=j=>`${j.rx.toFixed(1)},${j.ry.toFixed(1)}`;return[`M${c(s(e.inner,e.from+f))}`,`Q${c(g)} ${c(l(g,v,d))}`,`L${c(l(v,g,h))}`,`Q${c(v)} ${c(s(e.outer,e.from+p))}`,`A${x(e.outer)} 0 ${r} 1 ${c(s(e.outer,e.to-p))}`,`Q${c(N)} ${c(l(N,k,h))}`,`L${c(l(k,N,d))}`,`Q${c(k)} ${c(s(e.inner,e.to-f))}`,`A${x(e.inner)} 0 ${r} 0 ${c(s(e.inner,e.from+f))}`,"Z"].join(" ")}function jY(e,t,n){const r={rx:e.outer.rx-Ad,ry:e.outer.ry-Ad},s=e.to-e.from>180?1:0;return`M${ZS(r,t,n,e.to)} A${r.rx.toFixed(1)},${r.ry.toFixed(1)} 0 ${s} 0 ${ZS(r,t,n,e.from)}`}function SY({node:e,angle:t,lit:n}){const r=e.row.kind==="paired"&&e.row.here,s=e.order*xY%1*yY;return a.jsx("span",{className:"nm-wire","aria-hidden":!0,"data-tier":e.tier,"data-via":e.row.via,"data-on":n||void 0,style:{"--nm-a":`${t.toFixed(2)}deg`,"--nm-d":`${e.dist.toFixed(1)}px`,"--from":`${XS}px`,"--gap":`${XS+(e.tier==="loose"?fY:hY)}px`,"--i":e.order,"--phase":`${s.toFixed(2)}s`},children:r&&a.jsx("i",{className:"nm-glint"})})}function _Y({status:e}){const t=(e==null?void 0:e.enabled)===!0&&e.running;return a.jsxs("div",{className:"nm-core","data-listening":t||void 0,children:[a.jsx("span",{className:"nm-core-orb","aria-hidden":!0}),a.jsxs("span",{className:"nm-core-label",children:[a.jsx("span",{className:"nm-core-name",children:(e==null?void 0:e.name)??"…"}),a.jsx("span",{className:"nm-core-what",children:"this deck"})]})]})}function EY({node:e,angle:t,os:n,lit:r,shown:s,tabbable:o,register:l,onHold:c,onRelease:d,onOpen:h}){const{row:f}=e,p=`nm-d-${MY(rr(f))}`,g=e.angle*Math.PI/180,v=j0(f,n);return a.jsxs("button",{ref:l,type:"button",className:"nm-node",tabIndex:o?0:-1,"data-tier":e.tier,"data-kind":f.kind,"data-side":e.side,"data-via":f.via,"data-on":r||void 0,"data-shown":s||void 0,"aria-label":`${f.name}: ${VI(f)}`,"aria-describedby":e.tier==="online"?p:void 0,style:{"--nm-a":`${t.toFixed(2)}deg`,"--nm-d":`${e.dist.toFixed(1)}px`,"--i":e.order,"--in-x":`${(-Math.cos(g)*14).toFixed(1)}px`,"--in-y":`${(-Math.sin(g)*14).toFixed(1)}px`},onPointerEnter:N=>{N.pointerType==="mouse"&&c("pointer")},onPointerLeave:d,onFocus:N=>c(N.currentTarget.matches(":focus-visible")?"keyboard":"pointer"),onBlur:d,onClick:h,children:[a.jsx("i",{className:"nm-halo","data-tier":e.tier,"aria-hidden":!0}),f.kind==="dialling"?a.jsx("i",{className:"nm-addr-dot","aria-hidden":!0}):a.jsx(ob,{}),e.tier!=="online"&&a.jsx("i",{className:"nm-mark","data-tier":e.tier,"data-kind":f.kind,"aria-hidden":!0}),a.jsxs("span",{className:"nm-label","aria-hidden":!0,children:[a.jsx("span",{className:"nm-name",children:WI(f)}),a.jsx("span",{className:"nm-cap",children:v})]}),e.tier==="online"&&a.jsx("span",{id:p,className:"vis-hidden",children:v})]})}function CY({status:e}){const t=(e==null?void 0:e.enabled)===!0;return a.jsx("p",{className:"nm-empty",children:e?t?"No other deck yet. Decks on one network usually find each other within a minute; one on another network needs its address, through Add a deck in Local network.":"Local network is off, so this deck is not looking for any other.":"Asking this deck about the network…"})}function TY({slice:e}){return a.jsxs("ul",{className:"nm-legend",children:[a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"online"}),a.jsx("i",{className:"nm-key-mark","data-tier":"online"})]}),"online"]}),a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"offline"}),a.jsx("i",{className:"nm-key-mark","data-tier":"offline"})]}),"away"]}),a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"loose"}),a.jsx("i",{className:"nm-key-mark","data-tier":"loose"})]}),"not paired"]}),e&&a.jsxs("li",{children:[a.jsx("i",{className:"nm-key-zone","aria-hidden":!0}),"over Tailscale"]})]})}function eO({facts:e}){return a.jsx("dl",{className:"lan-facts nm-facts",children:e.map(t=>a.jsxs("div",{className:"lan-fact","data-tone":t.quiet?"quiet":void 0,children:[a.jsx("dt",{children:t.label}),a.jsx("dd",{children:t.value})]},t.label))})}function AY({status:e,summary:t,entrance:n,slice:r}){const s=tY(e),o=ab(e==null?void 0:e.about),l=[];o&&l.push({label:"Runs",value:o}),l.push({label:s.length>1?"Addresses":"Address",value:s.length?a.jsx("span",{className:"nm-addrs",children:s.map(h=>a.jsx("code",{className:"ap-lan-code",children:h},h))}):"none yet",quiet:s.length===0}),e!=null&&e.pairingMode&&l.push({label:"Pairing",value:e.pairingMode==="invite"?"by invite only":"asks and answers"});const c=[{key:"online",n:t.online,words:"online",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"online","aria-hidden":!0})},{key:"away",n:t.offline,words:"away",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"offline","aria-hidden":!0})},{key:"asks",n:t.asks,words:"asking to pair",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","data-kind":"asks","aria-hidden":!0})},{key:"nearby",n:t.nearby,words:"nearby, not paired",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","aria-hidden":!0})},{key:"dialling",n:t.dialling,words:"still dialling",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","aria-hidden":!0})},{key:"declined",n:t.declined,words:"declined, not drawn",mark:a.jsx("i",{"aria-hidden":!0})}],d=rY(t,e==null?void 0:e.pairingMode);return a.jsxs("div",{className:"nm-panel","data-view":"network","data-entrance":n,children:[a.jsx("h3",{className:"nm-panel-name",children:(e==null?void 0:e.name)??"…"}),a.jsx("p",{className:"nm-panel-self",children:"this deck, at the centre of the map"}),a.jsx("ul",{className:"nm-counts",children:c.filter(h=>h.n>0).map(h=>a.jsxs("li",{"data-count":h.key,children:[h.mark,a.jsx("span",{className:"nm-count-n",children:h.n}),a.jsx("span",{className:"nm-count-words",children:h.words})]},h.key))}),t.tailnet>0&&a.jsxs("p",{className:"nm-counts-note",children:[t.tailnet," reached over Tailscale",r?" — the shaded slice, lower right":""]}),d&&a.jsx("p",{className:"nm-next",children:d}),a.jsx(eO,{facts:l}),a.jsx("p",{className:"nm-panel-hint",children:"Point at a deck, or reach one with the arrow keys, to see it here. Press it to open its own dialog."})]})}function RY({row:e,status:t,accounts:n,now:r,entrance:s,onOpen:o,onBack:l}){var x;const c=JI({row:e,source:Ql(t,e),status:t,accounts:n,now:r}),d=[];c.where&&d.push({label:"Address",value:a.jsx("code",{className:"ap-lan-code",children:c.where})}),c.thereRuns&&d.push({label:"Runs",value:`${c.thereRuns}${c.order?` · ${c.order<0?"older than this deck":"newer than this deck"}`:""}`}),c.hiddenThere&&d.push({label:"Signed in to",value:"not said — its owner hides it",quiet:!0}),c.otherThere&&d.push({label:"Signed in to",value:"an account it does not share",quiet:!0});const h=e.kind==="paired"&&e.here||e.kind==="asks",f=sY(e,t.pairingMode),p=aY(c.lanes),g=p.length,v=p.filter(j=>j.tone==="ok").length,N=g===0?"No shared logins":v===g?`${g} shared login${g===1?", fine":"s, all fine"}`:`${g} shared login${g===1?"":"s"} · ${v} fine`,k=c.unknown&&((x=c.peer)!=null&&x.waiting)&&!c.peer.offers?"Its side is not known until it next calls.":c.unknown;return a.jsxs("div",{className:"nm-panel","data-view":"deck","data-entrance":s,"data-tier":e.kind==="paired"?e.here?"online":"offline":"loose",children:[a.jsxs("button",{type:"button",className:"ap-lan-word nm-back",onClick:l,children:[a.jsx("span",{"aria-hidden":!0,children:"‹ "}),"the whole network"]}),a.jsxs("div",{className:"nm-panel-head",children:[a.jsxs("h3",{className:"nm-panel-name",children:[a.jsx("i",{className:h?"ap-pulse":"ap-dot","data-kind":e.kind,"aria-hidden":!0}),a.jsx("span",{className:"nm-panel-title",children:e.name})]}),a.jsx("button",{type:"button",className:"btn nm-open",onClick:o,"aria-label":`Open ${e.name}`,children:"Open"})]}),e.self&&a.jsxs("p",{className:"nm-panel-self",children:["calls itself ",e.self]}),a.jsx("p",{className:"nm-panel-state","data-kind":e.kind,children:VI(e)}),f&&a.jsx("p",{className:"nm-next",children:f}),d.length>0&&a.jsx(eO,{facts:d}),c.paired&&a.jsxs("section",{className:"nm-logins","aria-label":"Logins the two decks share",children:[a.jsx("p",{className:"nm-logins-title",children:N}),g>0&&a.jsx("ul",{className:"nm-lanes",children:p.map((j,b)=>a.jsxs("li",{className:"nm-lane","data-tone":j.tone,style:{"--k":b},children:[a.jsx("i",{className:"nm-lane-dot","aria-hidden":!0}),a.jsx("span",{className:"nm-lane-email","aria-hidden":!0,children:j.email}),JS(j)&&a.jsx("span",{className:"nm-lane-said","aria-hidden":!0,children:JS(j)}),j.usedThere&&a.jsx("span",{className:"nm-lane-used","aria-hidden":!0,children:"in use there"}),a.jsxs("span",{className:"vis-hidden",children:[j.email,": ",ZI(j)]})]},j.key))}),k&&a.jsx("p",{className:"nm-panel-hint",children:k})]})]})}function JS(e){return e.caption?e.caption:e.tone==="ok"?null:`${YI[e.here]} · ${XI[e.there]}`}function MY(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}const $Y=6;function IY({anchorId:e,id:t,rows:n,onHold:r,onLet:s}){const o=y.useRef(null),l=n.filter(g=>g.kind==="paired"),c=l.filter(g=>g.here),d=c.slice(0,$Y),h=l.length-c.length,f=c.length>d.length?`and ${c.length-d.length} more`:h>0?`${h} not on right now`:null,p=y.useCallback(()=>{const g=o.current,v=document.getElementById(e);if(!g||!v)return;const N=h0(v.getBoundingClientRect(),{width:g.offsetWidth,height:g.offsetHeight},{width:window.innerWidth,height:window.innerHeight});g.style.top=`${N.top}px`,g.style.left=`${N.left}px`,g.style.maxHeight=N.maxHeight==null?"":`${N.maxHeight}px`,g.dataset.side=N.side},[e]);return y.useLayoutEffect(()=>{p()}),y.useEffect(()=>(window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}),[p]),Lt.createPortal(a.jsxs("div",{ref:o,id:t,className:"ap-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:s,children:[a.jsx("p",{className:"ap-peek-title",children:c.length?"On the network now":"Nobody on the network"}),d.length>0&&a.jsx("div",{className:"ap-peek-list",children:d.map(g=>a.jsxs("span",{className:"ap-peek-who",children:[a.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),a.jsxs("span",{children:[g.name,g.via==="tailscale"&&a.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]})]},`${g.kind}:${g.fp}`))}),f&&a.jsx("p",{className:"ap-peek-rest",children:f})]}),document.body)}function OY({entry:e,rows:t,onOpen:n,onMap:r,peek:s,openPeek:o,shutPeek:l,holdPeek:c,dropPeek:d}){return a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",id:"ap-lan-entry",className:"ap-nav",onClick:()=>{d(),n()},"aria-describedby":s?"ap-lan-peek":void 0,onPointerEnter:h=>{h.pointerType==="mouse"&&o(OI)},onPointerLeave:l,onFocus:h=>{h.target.matches(":focus-visible")&&o(0)},onBlur:l,children:[a.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:[a.jsx("rect",{x:"1.8",y:"2.3",width:"10.4",height:"7.2",rx:"1.2"}),a.jsx("path",{d:"M5 11.9h4M7 9.5v2.4"})]}),a.jsxs("span",{className:"ap-nav-text",children:[a.jsx("span",{className:"ap-nav-name",children:"Local network"}),a.jsxs("span",{className:"ap-nav-state","data-tone":e.tone,children:[e.live&&a.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),e.text]})]}),a.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:a.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),r&&a.jsx("button",{type:"button",className:"ap-lan-map",onClick:()=>{d(),r()},"aria-label":"Show the network map",title:"Network map — every deck this one knows, drawn around it",children:a.jsx(QI,{})}),s&&a.jsx(IY,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:t,onHold:c,onLet:l})]})}function LY({row:e,run:t,onVerb:n,onUnpair:r}){const[s,o]=y.useState(!1),l=y.useRef(0),[c,d]=y.useState(null);return y.useEffect(()=>{if(!s)return;const p=window.setTimeout(()=>o(!1),4e3);return()=>window.clearTimeout(p)},[s]),y.useEffect(()=>{if(!c)return;const p=window.setTimeout(()=>d(null),4e3);return()=>window.clearTimeout(p)},[c]),{armed:s,armedTwin:c,pressOwn:()=>{const p=Date.now(),g=Kl({armedFor:s?e.fp:null,target:e.fp,armedAt:l.current,now:p,gapMs:Gl});if(g==="arm"){o(!0),d(null),l.current=p;return}g!=="ignore"&&(o(!1),t(n))},pressTwin:p=>{if(!r)return;const g=Date.now(),v=Kl({armedFor:c,target:p,armedAt:l.current,now:g,gapMs:Gl});if(v==="arm"){d(p),o(!1),l.current=g;return}v!=="ignore"&&(d(null),t(()=>r(p)))}}}function PY({row:e,paired:t,peer:n,status:r,busy:s,press:o,checkNow:l,armed:c,pressOwn:d,run:h,onVerb:f,onInvite:p}){return a.jsxs("footer",{className:"lan-peer-foot",children:[e.kind==="asks"&&a.jsx("p",{className:"lan-foot-note",children:"This deck is now asking to pair. Answer it from the panel behind this."}),t&&!(n!=null&&n.waiting)&&a.jsx("button",{type:"button",className:"btn",...o(`check:${e.fp}`),onClick:l,title:"Ask this deck now instead of waiting for the next round",children:s===`check:${e.fp}`?"Checking…":"Check now"}),e.kind==="paired"&&a.jsx("button",{type:"button",className:`btn danger lan-peer-verb${c?" armed":""}`,...o(`unpair:${e.fp}`),onKeyDown:g=>{g.repeat&&g.preventDefault()},onClick:()=>d(),"aria-label":c?`Confirm unpairing ${e.name}`:`Unpair ${e.name}`,title:c?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this deck from now on",children:s===`unpair:${e.fp}`?"Unpairing…":c?"Confirm unpair":"Unpair"}),e.kind==="nearby"&&r.pairingMode!=="invite"&&a.jsx("button",{type:"button",className:"btn primary lan-peer-verb",...o(`accept:${e.fp}`),onClick:()=>void h(f),title:"Send it a request. Somebody at that machine has to accept it before anything is shared.",children:s===`accept:${e.fp}`?"Asking…":"Ask to pair"}),e.kind==="dialling"&&a.jsx("button",{type:"button",className:"btn lan-peer-verb",...o(`drop:${e.fp}`),onClick:()=>void h(f),title:"Stop trying this address. Nothing was ever paired here.",children:s===`drop:${e.fp}`?"Stopping…":"Stop dialling"}),e.kind==="declined"&&r.pairingMode!=="invite"&&a.jsx("button",{type:"button",className:"btn lan-peer-verb",...o(`allow:${e.fp}`),onClick:()=>void h(f),title:"Take the no back. That deck is still trying, so its request comes round again on its own.",children:s===`allow:${e.fp}`?"Allowing…":"Let it ask again"}),(e.kind==="nearby"||e.kind==="declined")&&r.pairingMode==="invite"&&p&&a.jsx("button",{type:"button",className:"btn primary lan-peer-verb",onClick:p,title:"This deck pairs only by invite. Make one and send it to whoever is at that machine.",children:"Invite to pair"})]})}function DY({instances:e,now:t,busy:n,press:r,armedTwin:s,pressTwin:o,onUnpair:l}){return a.jsxs("div",{className:"modal-section",children:[a.jsxs("h3",{className:"lan-h",children:[e.length," decks on this machine"]}),a.jsx("ul",{className:"lan-twins",role:"list",children:e.map((c,d)=>{var N,k,x,j;const h=(N=c.peer)!=null&&N.addr?`${c.peer.addr}:${c.peer.port}`:c.row.addr,f=h||c.row.fp,p=(k=c.peer)!=null&&k.pairedAt?Fr(c.peer.pairedAt,t):null,g=[(j=(x=c.peer)==null?void 0:x.about)!=null&&j.version?`runs ${c.peer.about.version}`:null,p?`paired ${p==="now"?"just now":p}`:null,c.row.state].filter(Boolean).join(" · "),v=c.row.fp;return a.jsxs("li",{role:"listitem",className:"lan-twin","data-tone":c.row.tone,children:[a.jsx("i",{className:c.row.here?"ap-pulse":"ap-dot","aria-hidden":!0}),h?a.jsx("code",{className:"ap-lan-code lan-twin-at",children:h}):a.jsx("span",{className:"lan-twin-at lan-twin-none",children:"no address here"}),a.jsx("code",{className:"ap-lan-code lan-twin-fp",children:v}),d>0&&l&&a.jsx("button",{type:"button",className:`ap-manage-btn danger lan-twin-do${s===v?" armed":""}`,...r(`unpair:${v}`),onKeyDown:b=>{b.repeat&&b.preventDefault()},onClick:()=>o(v),"aria-label":s===v?`Confirm unpairing ${f}`:`Unpair ${f}`,title:s===v?"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:n===`unpair:${v}`?"unpairing…":s===v?"confirm":"unpair"}),a.jsx("span",{className:"lan-twin-meta",children:d===0?`${g} · shown above`:g})]},v)})})]})}function FY(){return a.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:[a.jsx("path",{d:"M9.6 2.4l2 2L5 11l-2.6.6L3 9z"}),a.jsx("path",{d:"M8.4 3.6l2 2"})]})}function BY({row:e,source:t,status:n,accounts:r,now:s,busy:o,onClose:l,onRename:c,onCheck:d,onVerb:h,onSettings:f,onInvite:p,twins:g=[],onUnpair:v}){const N=y.useRef(null),k=ut(l,{focusRef:N}),x=gt(l),[j,b]=y.useState(null),[_,E]=y.useState(null),[R,T]=y.useState(!1),[A,U]=y.useState(0),L=y.useRef(null),F=y.useRef(null),O=y.useRef(!0);y.useEffect(()=>()=>{O.current=!1},[]);const I=j!=null;y.useEffect(()=>{var ae;I&&((ae=L.current)==null||ae.select())},[I]);const B=y.useRef(!1);y.useEffect(()=>{var ae,fe;B.current&&!I&&Cn(((ae=document.activeElement)==null?void 0:ae.tagName)??null)&&((fe=F.current)==null||fe.focus()),B.current=I},[I]);const M=ae=>{const fe=ia(o,ae);return{disabled:fe.disabled,"aria-busy":fe.busy}},$=async ae=>{const fe=await ae();return O.current&&E(fe),fe==null},{armed:P,armedTwin:G,pressOwn:K,pressTwin:q}=LY({row:e,run:$,onVerb:h,onUnpair:v}),H=JI({row:e,source:t,status:n,accounts:r,now:s}),{peer:D,stranger:W,paired:J,own:V,canRename:X,fp:Y}=H,Z=o===`check:${e.fp}`,ee=async ae=>{const fe=ae.trim()===V?"":ae;await $(()=>c(fe))&&b(null)},ne=()=>void $(d).then(ae=>{ae&&O.current&&U(fe=>fe+1)}),se=async()=>{if(Y)try{if(await navigator.clipboard.writeText(Y),!O.current)return;T(!0),window.setTimeout(()=>{O.current&&T(!1)},1600)}catch{O.current&&E("Could not copy it — select the fingerprint and copy it by hand.")}},pe=[];J&&(D!=null&&D.pairedAt)?pe.push({label:"Paired",value:uY(D.pairedAt,s),tone:"meta"}):e.kind==="declined"&&W&&pe.push({label:"Paired",value:`no · you said no ${b0(W.at,s)}`,tone:"meta"}),pe.push({label:"Fingerprint",value:Y?a.jsxs("span",{className:"lan-fp",children:[a.jsx("code",{className:"ap-lan-code",children:Y}),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void se(),"aria-label":R?"Fingerprint copied":"Copy the fingerprint",children:R?"copied":"copy"})]}):"not known — nothing has answered there",tone:Y?void 0:"quiet"});const ke=g.length?[{row:e,peer:D??null},...g]:[];return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...x,role:"presentation",children:a.jsxs("div",{ref:k,className:"modal lan-peer","data-tone":e.tone,onClick:ae=>ae.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-peer-title","aria-describedby":"lan-peer-sub",children:[a.jsxs("header",{className:"modal-head lan-peer-head",children:[a.jsx("i",{className:e.here?"ap-pulse":"ap-dot","aria-hidden":!0}),a.jsxs("div",{className:"lan-peer-id",children:[I?a.jsxs("form",{className:"lan-peer-edit",onSubmit:ae=>{ae.preventDefault(),ee(j??"")},children:[a.jsx("span",{id:"lan-peer-title",className:"vis-hidden",children:e.name}),a.jsx("input",{ref:L,className:"ap-manage-input lan-peer-input",value:j??"",maxLength:48,placeholder:V,"aria-label":"Name for this deck, shown on this deck only",onChange:ae=>b(ae.target.value)}),a.jsx("button",{type:"submit",className:"ap-manage-btn",...M(`alias:${e.fp}`),children:"save"}),a.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>b(null),children:"cancel"})]}):a.jsxs("span",{className:"lan-peer-title",children:[a.jsx("span",{id:"lan-peer-title",className:"lan-peer-name",children:e.name}),X&&a.jsx("button",{type:"button",className:"glyph-btn lan-peer-rename",ref:F,onClick:()=>{E(null),b(e.name)},"aria-label":`Rename ${e.name} on this deck`,title:"Give it a name of your own. Only this deck sees it.",children:a.jsx(FY,{})})]}),a.jsxs("p",{id:"lan-peer-sub",className:"lan-peer-sub",children:[e.self&&a.jsxs(a.Fragment,{children:["calls itself ",a.jsx("span",{className:"lan-peer-self",children:e.self}),I&&a.jsx("button",{type:"button",className:"ap-lan-word lan-peer-restore",...M(`alias:${e.fp}`),onClick:()=>void ee(""),children:"use this name"}),a.jsx("span",{className:"vis-hidden",children:". "}),!e.quiet&&a.jsx("span",{"aria-hidden":!0,children:" · "})]}),a.jsx("span",{className:e.quiet?"vis-hidden":"lan-peer-state",children:e.state})]})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:N,type:"button",className:"glyph-btn",onClick:l,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body lan-peer-body",children:[_&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",children:_}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>E(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),a.jsx(dY,{view:H,row:e,status:n,asking:Z,drawn:A,onSettings:f}),a.jsx("dl",{className:"lan-facts",children:pe.map(ae=>a.jsxs("div",{className:"lan-fact","data-tone":ae.tone,children:[a.jsx("dt",{children:ae.label}),a.jsx("dd",{children:ae.value})]},ae.label))}),ke.length>1&&a.jsx(DY,{instances:ke,now:s,busy:o,press:M,armedTwin:G,pressTwin:q,onUnpair:v})]}),a.jsx(PY,{row:e,paired:J,peer:D,status:n,busy:o,press:M,checkNow:ne,armed:P,pressOwn:K,run:$,onVerb:h,onInvite:p})]})}),document.body)}function is(e,t){const n=y.useRef(!1);return y.useEffect(()=>{var r,s;!e||!n.current||(n.current=!1,Cn(((r=document.activeElement)==null?void 0:r.tagName)??null)&&(typeof t=="function"?t():(s=t.current)==null||s.focus()))},[e]),()=>{n.current=!0}}function qY(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(r=>n.has(r))}function UY(e,t,n,r){const s=new Set(e??t);return r?s.add(n):s.delete(n),[...s]}function QS(e,t,n){return e==null||n!=null&&!n.ok||qY(e,t)?null:e}function tO({line:e,onDismiss:t,onAnswer:n}){const[r,s]=y.useState(!1),o=y.useRef(!1),l=y.useRef(!0);y.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);const c=y.useRef(null),d=y.useRef(null),h=y.useRef(!1);if(y.useEffect(()=>{var p;h.current&&(h.current=!1,e!=null&&e.giveBack||(p=d.current)==null||p.focus())},[e]),!e)return null;const f=async()=>{if(o.current)return;o.current=!0,s(!0);const p=await qG();o.current=!1,l.current&&(s(!1),h.current=document.activeElement===c.current,n(zG(p)))};return a.jsxs("div",{className:e.done?"ap-failure ap-failure-done":"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",children:e.text}),e.giveBack&&a.jsx("button",{ref:c,type:"button",className:"ap-fix ap-give-back","aria-busy":r,onClick:f,title:"Opens macOS's password dialog to make the settings folder yours again",children:r?"waiting for macOS…":"give it back"}),a.jsx("button",{ref:d,type:"button",className:"ap-failure-x",onClick:t,"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]})}function zY(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}const Wu="Paused while this deck pairs only by invite. Turn that off above to use it.";function WY({status:e,accounts:t,onClose:n,onChanged:r}){qt("lan-setup");const s=ut(n),o=gt(n),[l,c]=y.useState(null),[d,h]=y.useState(null),[f,p]=y.useState(!1),[g,v]=y.useState(null),N=y.useRef(null),k=q=>{const H=ia(g,q);return{disabled:H.disabled,"aria-busy":H.busy}},x=y.useRef(null),j=y.useRef(!0);y.useEffect(()=>()=>{j.current=!1},[]),y.useEffect(()=>{x.current=QS(x.current,e.shared??[],null)},[e.shared]);const b=y.useCallback(async(q,H,D="write")=>{N.current=D,v(D);try{const J=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:q})})).json().catch(()=>null);return j.current?(J!=null&&J.ok?h(null):h(sr(Ct(H,J),J)),r(),(J==null?void 0:J.ok)===!0):!1}catch{return j.current&&h(sr(Ct(H,null))),!1}finally{N.current=null,j.current&&v(null)}},[r]),_=y.useCallback(async q=>{const H=await b({name:q},"save the name","name");return H&&j.current&&c(D=>D===q?null:D),H},[b]),E=y.useRef(null),R=l!=null&&l!==(e.name??""),T=is(!R,E),A=y.useCallback(async()=>{R&&!await _(l)||n()},[R,l,_,n]),U=async()=>{if(!e.fp)return;const q=await eo(e.fp);if(j.current){if(!q){h(sr("Could not copy it — select the fingerprint and copy it by hand."));return}p(!0),window.setTimeout(()=>{j.current&&p(!1)},1600)}},L=new Set(x.current??e.shared??[]),F=e.autoAsk!==!1,O=e.autoAccept!==!1,I=e.pairingMode==="invite",B=q=>{const H=k(q);return{...H,disabled:H.disabled||I}},M=e.shareActive!==!1,$=e.tailscale??null,P=!!($!=null&&$.on),G=($==null?void 0:$.ask)!==!1,K=($==null?void 0:$.accept)!==!1;return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal lan-modal",onClick:q=>q.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-modal-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"lan-modal-title",className:"modal-tool-name",children:"This deck on the network"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsx(tO,{line:d,onDismiss:()=>h(null),onAnswer:q=>{h(q),q.done&&r()}}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Name"}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("span",{className:"ap-lan-label",children:"appear as"}),a.jsx("input",{ref:E,className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:l??e.name??"",placeholder:"this machine",onChange:q=>c(q.target.value),onKeyDown:q=>{q.key!=="Enter"||l==null||_(l)}}),R&&a.jsx("button",{type:"button",className:"ap-manage-btn",...k("name"),onClick:()=>{T(),_(l)},title:"Save it. This is the name other decks show for this one.",children:"save"})]}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("span",{className:"ap-lan-label",children:"fingerprint"}),e.fp?a.jsxs("span",{className:"lan-fp",children:[a.jsx("code",{className:"ap-lan-code",children:e.fp}),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void U(),"aria-label":f?"Fingerprint copied":"Copy this deck's fingerprint",children:f?"copied":"copy"})]}):a.jsx("span",{className:"ap-lan-label",children:"not known yet"})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Share these accounts"}),a.jsxs("div",{className:"ap-lan-picks",children:[t.length===0&&a.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(q=>a.jsxs("label",{className:"ap-lan-pick",title:q.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:[a.jsx("input",{type:"checkbox",checked:L.has(q.key),onChange:H=>{const D=UY(x.current,e.shared??[],q.key,H.target.checked);x.current=D,b({shared:D},H.target.checked?"share that account":"stop sharing that account").then(W=>{x.current===D&&(x.current=QS(D,e.shared??[],{ok:W}))})}}),a.jsx("span",{className:"ap-lan-pick-name",children:q.email}),!q.alive&&a.jsx("span",{className:"ap-lan-dead",children:"not working here"})]},q.key))]}),t.length>0&&a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Show paired decks which of these this deck is using"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":M,"aria-label":"Show paired decks which of these this deck is using",...k("current"),onClick:()=>void b({shareActive:!M},M?"stop showing which account this deck is using":"show which account this deck is using","current"),title:M?"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:a.jsx("span",{className:"switch-knob"})})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",id:"lan-pairing-h",children:"Pairing"}),a.jsx("div",{className:"lan-switches lan-switches-lead",role:"group","aria-labelledby":"lan-pairing-h",children:a.jsxs("div",{className:"lan-switch",children:[a.jsxs("span",{className:"lan-switch-what",children:["Pair new decks only by invite",I&&a.jsx("span",{id:"lan-invite-only-detail",className:"lan-switch-detail",children:"A new deck needs an invite from Add a deck, the link at the top of Local network. Paired decks stay paired."})]}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":I,"aria-label":"Pair new decks only by invite","aria-describedby":I?"lan-invite-only-detail":void 0,...k("mode"),onKeyDown:q=>{q.repeat&&q.preventDefault()},onClick:()=>void b({pairingMode:I?"automatic":"invite"},I?"let decks pair on their own again":"pair new decks only by invite","mode"),title:I?"Let decks on this network pair as the two switches below say again.":"Only a deck you send an invite to can pair with this one. Nearby decks can't ask, and requests waiting now are turned away.",children:a.jsx("span",{className:"switch-knob"})})]})}),a.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-auto-h",children:[a.jsxs("p",{className:"lan-sub",id:"lan-auto-h",children:["Automatic pairing",I&&a.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),a.jsxs("div",{className:"lan-switches","data-paused":I||void 0,children:[a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Ask every deck this one finds"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":F,"aria-label":"Ask every deck this one finds",...B("ask"),onClick:()=>void b({autoAsk:!F},F?"stop asking automatically":"ask every deck this one finds","ask"),title:I?Wu:F?"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:a.jsx("span",{className:"switch-knob"})})]}),a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Say yes to every deck that asks"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":O,"aria-label":"Say yes to every deck that asks","data-tone":"warn",...B("accept"),onKeyDown:q=>{q.repeat&&q.preventDefault()},onClick:()=>void b({autoAccept:!O},O?"stop accepting automatically":"accept every deck that asks","accept"),title:I?Wu:O?"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:a.jsx("span",{className:"switch-knob"})})]})]})]})]}),($==null?void 0:$.found)&&a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Tailscale"}),a.jsxs("div",{className:"lan-switches",children:[a.jsxs("div",{className:"lan-switch",children:[a.jsxs("span",{className:"lan-switch-what",children:["Look for my devices",a.jsx("span",{id:"lan-ts-detail",className:"lan-switch-detail",children:zY($)})]}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":P,"aria-label":"Look for my devices over Tailscale","aria-describedby":"lan-ts-detail",...k("tailscale"),onClick:()=>void b({tailscale:!P},P?"stop looking over Tailscale":"look for your devices over Tailscale","tailscale"),title:P?"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:a.jsx("span",{className:"switch-knob"})})]}),P&&a.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-ts-auto-h",children:[a.jsxs("p",{className:"lan-sub",id:"lan-ts-auto-h",children:["Automatic pairing with my devices",I&&a.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),a.jsxs("div",{className:"lan-switches",children:[a.jsxs("div",{className:"lan-switch","data-paused":I||void 0,children:[a.jsx("span",{className:"lan-switch-what",children:"Ask each device it finds"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":G,"aria-label":"Ask each of my devices it finds over Tailscale",...B("tailscale-ask"),onClick:()=>void b({tailscaleAsk:!G},G?"stop asking your devices automatically":"ask your devices automatically","tailscale-ask"),title:I?Wu:G?"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:a.jsx("span",{className:"switch-knob"})})]}),a.jsxs("div",{className:"lan-switch","data-paused":I||void 0,children:[a.jsx("span",{className:"lan-switch-what",children:"Say yes to each device that asks"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":K,"aria-label":"Say yes to my devices when they ask over Tailscale","data-tone":"warn",...B("tailscale-accept"),onKeyDown:q=>{q.repeat&&q.preventDefault()},onClick:()=>void b({tailscaleAccept:!K},K?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:I?Wu:K?"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:a.jsx("span",{className:"switch-knob"})})]})]})]})]})]})]}),a.jsxs("footer",{className:"lan-setup-foot",children:[a.jsx("span",{className:"lan-foot-note",children:"Changes are saved as you make them."}),a.jsx("button",{type:"button",className:"btn primary",...k("name"),onClick:()=>void A(),children:"Done"})]})]})}),document.body)}function HY({on:e,status:t,paired:n,busy:r,pressProps:s,checkNow:o,setAddOpen:l,setSetupOpen:c,setMapOpen:d,onBack:h,closeButton:f}){return a.jsxs("div",{className:"ap-header",children:[a.jsx("button",{type:"button",id:"ap-lan-back",className:"glyph-btn ap-back",onClick:h,"aria-label":"Back to Claude accounts",title:"Back to Claude accounts",children:a.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:a.jsx("path",{d:"M8.4 3.4 4.8 7l3.6 3.6"})})}),a.jsx("h2",{id:"ap-lan-title",children:"Local network"}),a.jsxs("div",{className:"ap-header-right",children:[e&&a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>d(!0),"aria-label":"Show the network map",title:"Network map — every deck this one knows, drawn around it",children:a.jsx(QI,{})}),e&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-plus",onClick:()=>l("add"),"aria-label":"Add a deck",title:(t==null?void 0:t.pairingMode)==="invite"?"Send an invite, or use one you were sent. This deck pairs only by invite.":"Reach a deck that has not turned up on its own — by address, or with an invite",children:a.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:[a.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"}),a.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"})]})}),e&&n>0&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-check",...s("check"),onClick:()=>void o(),"aria-label":r==="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:a.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:[a.jsx("circle",{cx:"7",cy:"7",r:"1.1",fill:"currentColor",stroke:"none"}),a.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"}),a.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"})]})}),e&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-set",...s("setup"),onClick:()=>c(!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:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M1.8 4.7h10.4M1.8 9.3h10.4"}),a.jsx("circle",{cx:"9.1",cy:"4.7",r:"1.6",fill:"var(--panel)"}),a.jsx("circle",{cx:"4.9",cy:"9.3",r:"1.6",fill:"var(--panel)"})]})}),f]})]})}function VY({accounts:e,onChanged:t,onNoCopy:n,view:r,onOpen:s,onBack:o,closeButton:l}){const[c,d]=y.useState(!1),[h,f]=y.useState(!1),[p,g]=y.useState(!1),v=FG(),[N,k]=y.useState(!1),{status:x,manual:j,now:b,busy:_,failure:E,dismissFailure:R,answerGiveBack:T,pressProps:A,load:U,toggle:L,answer:F,dropAddress:O,rename:I,checkOne:B,checkNow:M}=KG(t,()=>d(!0)),{armed:$,pressUnpair:P}=YG(F),[G,K]=y.useState(null),[q,H]=y.useState(!1),D=y.useMemo(()=>e.filter(me=>PG(me.key,x??null,b)).map(me=>me.key).sort().join(`
|
|
91
|
+
`)})}),a.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>void l(),title:c?"Copy these lines, then paste them into a terminal":"Copy these lines, then paste them into an elevated PowerShell",children:n?"copied":"copy command"})]})]})}function fK(e){const t=(e??"").trim(),n=t.lastIndexOf(":");if(n<=0||n===t.length-1)return null;const r=t.slice(0,n).trim(),s=Number(t.slice(n+1).trim());return!r||!Number.isInteger(s)||s<1||s>65535||r.includes(":")&&!(r.startsWith("[")&&r.endsWith("]"))?null:{addr:r,port:s}}function pK(e,t){const n=Math.max(0,Math.round((e-t)/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}async function Bp(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const mK={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."},gK={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function PS(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||Ct(n,t)}function yK({status:e,manual:t,startWith:n,onClose:r,onChanged:s}){const o=y.useRef(null),l=y.useRef(null),c=y.useRef(null),d=y.useRef(null),h=e.pairingMode==="invite",f=ut(r,{focusRef:h?l:o}),p=gt(r),[g,v]=y.useState(""),[N,k]=y.useState(""),[x,j]=y.useState(null),[b,_]=y.useState(null),[E,R]=y.useState(null),[T,A]=y.useState(null),[U,L]=y.useState(()=>Date.now());y.useEffect(()=>{const Y=window.setInterval(()=>L(Date.now()),1e3);return()=>window.clearInterval(Y)},[]);const F=y.useRef(!0);y.useEffect(()=>()=>{F.current=!1},[]);const O=y.useRef(null),I=y.useRef(null),B=y.useCallback(Y=>oh(O.current)?(O.current=Y,R(Y),!0):!1,[]),M=y.useCallback(()=>{O.current=null,F.current&&R(null)},[]),$=Y=>{const Z=ia(E,Y);return{disabled:Z.disabled,"aria-busy":Z.busy}},P=Y=>(x==null?void 0:x.field)===Y?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},G=Y=>j(Z=>Z&&Z.field===Y?null:Z),K=y.useCallback(async()=>{if(h)return;const Y=fK(g);if(!Y){j({text:wK(g),field:"addr"});return}const Z=`${Y.addr}:${Y.port}`,ee=e.peers.find(ne=>ne.addr===Y.addr&&ne.port===Y.port&&ne.paired);if(ee){j({text:`Already paired with ${ee.name} at that address.`,field:"addr"});return}if(t.includes(Z)){j({text:"This deck already calls that address.",field:"addr"});return}if(B("add"))try{const ne=await Bp("/api/prefs",{lan:{manual:[...t,Z]}});if(!F.current)return;ne!=null&&ne.ok?(j(null),v(""),s(),r()):j({text:Ct("add that address",ne),field:"addr"})}catch{F.current&&j({text:Ct("add that address",null),field:"addr"})}finally{M()}},[g,h,t,e.peers,s,r,B,M]),q=y.useCallback(async Y=>{if(!B(`invite:${Y}`))return;const Z=Y==="make"?"make an invite":"cancel that invite";try{const ee=await Bp("/api/lan/invite",{action:Y});if(!F.current)return;ee!=null&&ee.ok?(I.current=Y,j(null),_(null),s()):j({text:PS(gK,ee,Z)})}catch{F.current&&j({text:Ct(Z,null)})}finally{M()}},[s,B,M]),H=y.useCallback(async()=>{const Y=N.trim();if(!(!Y||!B("join"))){A(null);try{const Z=await Bp("/api/lan/invite",{action:"join",token:Y});if(!F.current)return;Z!=null&&Z.ok?(k(""),j(null),s(),r()):(Z==null?void 0:Z.reason)==="unreachable"&&Array.isArray(Z.tried)&&Z.tried.length?(A(Z.tried),j(null)):(A(null),j({text:PS(mK,Z,"use that invite"),field:"join"}))}catch{F.current&&j({text:Ct("use that invite",null),field:"join"})}finally{M()}}},[N,s,r,B,M]),D=y.useCallback(async(Y,Z)=>{try{await navigator.clipboard.writeText(Y),_(Z),window.setTimeout(()=>{F.current&&_(ee=>ee===Z?null:ee)},1600)}catch{j({text:"Could not copy it — select the text and copy it by hand."})}},[]),W=e.invite&&e.invite.expiresAt>U?e.invite:null,J=y.useRef(!1);y.useEffect(()=>{n!=="invite"||J.current||W||(J.current=!0,q("make"))},[n,W,q]);const V=y.useRef(!1);y.useEffect(()=>{var Y;n!=="invite"||V.current||!W||(V.current=!0,(Y=c.current)==null||Y.focus())},[n,W]),y.useEffect(()=>{var Z,ee;const Y=I.current;!Y||Y==="make"!=!!W||(I.current=null,Cn(((Z=document.activeElement)==null?void 0:Z.tagName)??null)&&((ee=(Y==="make"?c:d).current)==null||ee.focus()))},[W]);const X=e.port!=null?(e.addrs??[]).map(Y=>`${Y}:${e.port}`):[];return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:a.jsxs("div",{ref:f,className:"modal lan-add",onClick:Y=>Y.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-add-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"lan-add-title",className:"modal-tool-name",children:"Add a deck"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{className:"glyph-btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[x&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:x.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>j(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),a.jsx(BI,{reach:e.reach,where:"dialog"}),h&&a.jsx("div",{className:"modal-section",children:a.jsx("p",{className:"lan-note",children:"Adding by address is off while this deck pairs only by invite."})}),!h&&a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"By address"}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("input",{ref:o,className:"ap-manage-input ap-lan-input","aria-label":"Another deck's address",value:g,placeholder:"192.168.1.5:54340",spellCheck:!1,...P("addr"),onChange:Y=>{v(Y.target.value),G("addr")},onKeyDown:Y=>{Y.key==="Enter"&&K()}}),g.trim()!==""&&a.jsx("button",{type:"button",className:"ap-manage-btn",...$("add"),onClick:()=>void K(),title:"Add it to the decks this one calls, starting now.",children:"add"})]}),a.jsx("p",{className:"lan-note",children:"This deck calls that address until somebody there accepts."}),e.port!=null&&X.length>0&&a.jsxs("p",{className:"lan-note",children:["They type this deck’s own address into the same field on theirs:"," ",X.map((Y,Z)=>a.jsxs("span",{children:[Z>0&&" or ",a.jsx("code",{className:"ap-lan-code",children:Y})]},Y)),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",...$("copy:mine"),onClick:()=>void D(X.join(" "),"mine"),title:"Copy this deck's address, to send to whoever is adding it",children:b==="mine"?"copied":"copy"})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("h3",{className:"lan-h",children:["With an invite",!W&&a.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",ref:d,...$("invite:make"),onClick:()=>void q("make"),title:"One piece of text you send them. They paste it, and the two decks pair — nobody has to press anything here.",children:E==="invite:make"?"making…":"make one to send"})]}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("input",{ref:l,className:"ap-manage-input ap-lan-input","aria-label":"An invite you were sent",value:N,placeholder:"paste one you were sent",spellCheck:!1,...P("join"),onChange:Y=>{k(Y.target.value),A(null),G("join")},onKeyDown:Y=>{Y.key==="Enter"&&H()}}),N.trim()!==""&&a.jsx("button",{type:"button",className:"ap-manage-btn",...$("join"),onClick:()=>void H(),title:"Reach that deck and pair with it. Nobody has to press anything there.",children:E==="join"?"joining…":"join"})]}),a.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),T&&a.jsxs("div",{className:"ap-lan-tried",children:[a.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."}),T.map(Y=>a.jsxs("span",{className:"ap-lan-tried-row",children:[a.jsx("code",{className:"ap-lan-code",children:Y.addr}),a.jsx("span",{className:"ap-lan-bad",children:Y.why})]},Y.addr))]}),W&&a.jsxs("div",{className:"ap-lan-invite",children:[a.jsxs("div",{className:"ap-lan-invite-head",children:[a.jsx("span",{className:"ap-lan-invite-title",children:"Send this to them"}),a.jsxs("span",{className:"ap-lan-invite-left",id:"lan-invite-left",children:[pK(W.expiresAt,U)," left"]})]}),a.jsx("code",{className:"ap-lan-token",children:W.token}),a.jsxs("div",{className:"ap-lan-acts",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",ref:c,...$("copy:invite"),"aria-label":b==="invite"?"Invite copied":"Copy invite","aria-describedby":"lan-invite-left",onClick:()=>void D(W.token,"invite"),title:"Copy it, and send it however you already talk to them",children:b==="invite"?"copied":"copy"}),a.jsx("button",{type:"button",className:"ap-manage-btn",...$("invite:withdraw"),onClick:()=>void q("withdraw"),title:"Cancel it. Anybody already holding the text can no longer use it.",children:"cancel"})]}),a.jsx("p",{className:"lan-warn",children:"Anyone who gets this text can pair with this deck until it runs out."})]})]})]})]})}),document.body)}function wK(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}".`}function vK({asks:e,pressProps:t,answer:n}){return a.jsx("div",{className:"ap-lan-asks",role:"alert",children:e.map(r=>a.jsxs("div",{className:"ap-lan-ask",children:[a.jsxs("span",{className:"ap-lan-ask-what",children:[a.jsx("strong",{className:"ap-lan-peer-name",children:r.name})," at ",a.jsx("code",{className:"ap-lan-code",children:r.addr})," wants to pair"]}),a.jsxs("span",{className:"ap-lan-ask-fp",id:`lan-ask-fp-${r.fp}`,children:["fingerprint ",a.jsx("code",{className:"ap-lan-code",children:r.fp})]}),a.jsxs("span",{className:"ap-lan-ask-acts",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",...t(`accept:${r.fp}`),"aria-label":`Accept ${r.name}`,"aria-describedby":`lan-ask-fp-${r.fp}`,onClick:()=>void n("accept",r.fp,"accept that deck"),title:`Talk to this deck from now on. Its fingerprint is ${r.fp} — check it matches the one on their screen before you accept.`,children:"accept"}),a.jsx("button",{type:"button",className:"ap-manage-btn",...t(`dismiss:${r.fp}`),"aria-label":`Decline ${r.name}`,"aria-describedby":`lan-ask-fp-${r.fp}`,onClick:()=>void n("dismiss",r.fp,"decline that request"),title:"Say no. Nothing is shared, and that deck is told rather than left waiting.",children:"decline"})]})]},r.fp))})}function xK({rows:e,pairingMode:t,armed:n,pressProps:r,answer:s,dropAddress:o,onUnpair:l,onOpenPeer:c,onInvite:d}){return a.jsx("ul",{className:"ap-lan-here",children:e.map((h,f)=>a.jsxs("li",{className:"ap-lan-who","data-tone":h.tone,children:[a.jsx("i",{className:h.here?"ap-pulse":"ap-dot","aria-hidden":!0}),a.jsxs("span",{className:"ap-lan-who-name","aria-hidden":!0,children:[h.name,h.via==="tailscale"&&a.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]}),a.jsx("button",{type:"button",className:"ap-lan-who-open","aria-haspopup":"dialog","aria-describedby":`lan-who-state-${f}`,onClick:()=>c(h.fp),children:a.jsxs("span",{className:"vis-hidden",children:[h.name,h.via==="tailscale"?", over Tailscale":"",", details"]})}),a.jsx("span",{id:`lan-who-state-${f}`,className:h.quiet?"vis-hidden":"ap-lan-who-when",children:h.state}),h.kind==="nearby"&&t!=="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`accept:${h.fp}`),onClick:()=>void s("accept",h.fp,"reach that deck"),"aria-label":`Ask ${h.name} to pair`,title:`Send ${h.name} a request. Somebody at that machine has to accept it before anything is shared. Its fingerprint is ${h.fp}.`,children:"ask"}),(h.kind==="nearby"||h.kind==="declined")&&t==="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do","aria-haspopup":"dialog",onClick:d,"aria-label":`Invite ${h.name} to pair`,title:`This deck pairs only by invite. Make one and send it to whoever is at ${h.name}.`,children:"invite"}),h.kind==="paired"&&a.jsx("button",{type:"button",className:`ap-manage-btn ap-lan-do danger${n===h.fp?" armed":""}`,...r(`unpair:${h.fp}`),onClick:()=>l(h),"aria-label":n===h.fp?`Confirm unpairing ${h.name}`:`Unpair ${h.name}`,title:n===h.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:n===h.fp?"confirm":"unpair"}),h.kind==="dialling"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`drop:${h.fp}`),onClick:()=>void o(h.fp),"aria-label":`Stop dialling ${h.name}`,title:"Stop trying this address. Nothing was ever paired here.",children:"stop"}),h.kind==="declined"&&t!=="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`allow:${h.fp}`),onClick:()=>void s("allow",h.fp,"let that deck ask again"),"aria-label":`Let ${h.name} ask again`,title:"Take the no back. That deck is still trying, so the request comes round again on its own.",children:"allow"})]},`${h.kind}:${h.fp}`))})}function bK(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 kK({on:e,status:t}){return a.jsxs(a.Fragment,{children:[e&&a.jsx(BI,{reach:t==null?void 0:t.reach,where:"panel"}),e&&(t==null?void 0:t.deaf)&&a.jsx("p",{className:"ap-lan-fine",children:t.deaf}),e&&(t==null?void 0:t.lanTunneled)&&a.jsx("p",{className:"ap-lan-fine",children:bK(t)})]})}const DS=["online","offline","loose"],NK={online:0,offline:1,loose:2};function jK(e){return e.kind==="declined"?null:e.kind==="paired"?e.here?"online":"offline":"loose"}const SK=76,_K=62,Td=96,EK={1:[.62],2:[.58,1],3:[.42,.72,1]},CK=.2,TK=.16,AK=.05,RK=20,MK=17,qu=7,$K=30,IK=116,OK=6.6,LK=6,PK=e=>j0(e,null),DK=1.5,FK=80,BK=.45,FS=40,qK=64,UK=150,BS=.3,qS=84,US=8,zK=1.3,Ad=6,WK=5.94,zS=7,WS=16,xl=4,HS=.16;function rb(e,t){return Math.PI*(3*(e+t)-Math.sqrt((3*e+t)*(e+3*t)))}function qI(e,t){return t<-Math.abs(e)*.6?"top":"bottom"}function HK(e,t){if(e<=2)return t%2===0?0:90;const n=360/e;return-90+(t%2===0?0:n/2)}function VK(e){return e.map((t,n)=>({...t,i:n})).sort((t,n)=>DS.indexOf(t.tier)-DS.indexOf(n.tier)||+(t.row.via==="tailscale")-+(n.row.via==="tailscale")||t.i-n.i).map(({row:t,tier:n})=>({row:t,tier:n}))}function VS(e,t){let n=2166136261^t;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619);return(n>>>0)%2e4/1e4-1}function GK(e,t,n){const r=[...EK[e.length]??[]];for(let s=0;s<r.length;s++){const o=e[s];if(o<2)continue;const l=rb(t*r[s],n*r[s])/o;if(!(l>0)||l>=Td)continue;const c=s+1<r.length?r[s+1]-CK:1;r[s]=Math.max(r[s],Math.min(c,r[s]*(Td/l)*1.02))}return r}const Pa=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1,qp={h:16,ch:6.1,maxW:100};function KK(e){const t=e?Math.max(80,e.length*7.2+16):128;return{x0:-t/2,y0:32,x1:t/2,y1:66}}function UI(e,t,n,r,s,o){const l=t==="loose"?MK:RK,c=!s||e.kind==="asks",d=c?$K:qp.h,h=s?qp.ch:OK,f=c?o.length:0,p=Math.min(s?qp.maxW:IK,Math.max(2*l,WI(e).length*h,f*LK)),g={x0:n-l,y0:r-l,x1:n+l,y1:r+l},v=qI(n,r)==="top"?{x0:n-p/2,y0:r-l-qu-d,x1:n+p/2,y1:r-l-qu}:{x0:n-p/2,y0:r+l+qu,x1:n+p/2,y1:r+l+qu+d};return[g,v]}const sb=e=>{const t=e.theta*Math.PI/180;return[Math.cos(t)*e.ring.rx*e.reach,Math.sin(t)*e.ring.ry*e.reach]},Uu=(e,t)=>((e-t)%360+540)%360-180;function GS(e,t,n){const r=new Map;for(const f of e)r.has(f.ring)||r.set(f.ring,[]),r.get(f.ring).push(f);const s=()=>e.map(f=>{const[p,g]=sb(f);return UI(f.row,f.tier,p,g,t,f.caption)}),o=(f,p,g=!1)=>{if(f.count<=2&&!g)return!1;const v=f.theta+p*DK,N=r.get(f.ring),k=(f.count>2?360/f.count:f.turn)*BK,x=N[(f.index+1)%f.count],j=N[(f.index-1+f.count)%f.count];return!(x===f||(p>0?Uu(x.theta,v)>=k:Uu(v,j.theta)>=k))||v<f.lo||v>f.hi?!1:(f.theta=v,!0)},l=([f,p],[g,v])=>Pa(p,g)||Pa(v,f)||Pa(p,v)||Pa(f,g),c=([f,p])=>Pa(f,n)||Pa(p,n);for(let f=0;f<FK;f++){const p=s();let g=!1;for(let v=0;v<e.length;v++){c(p[v])&&(g=o(e[v],Uu(e[v].theta,90)>=0?1:-1,!0)||g);for(let N=v+1;N<e.length;N++){if(!l(p[v],p[N]))continue;const k=e[v],x=e[N],j=x.ring.ring>k.ring.ring||x.ring===k.ring&&N>v?x:k,b=j===x?k:x,_=Uu(j.theta,b.theta)>=0?1:-1;g=o(j,_)||o(b,-_)||g}}if(!g)break}const d=s();let h=0;for(let f=0;f<d.length;f++){c(d[f])&&h++;for(let p=f+1;p<d.length;p++)l(d[f],d[p])&&h++}return h}const YK={online:0,offline:1,loose:1};function XK(e,t,n,r="",s=PK){const o=[];for(const l of[!0,!1]){const c=KS(e,t,n,r,NK,s,l);if(c.clashes===0)return c.named();if(o.push(c),c.layout.rings.length===3){const d=KS(e,t,n,r,YK,s,l),h={clashes:d.clashes,named:()=>({...d.named(),folded:!0})};if(h.clashes===0)return h.named();o.push(h)}if(!c.layout.zone)break}return o.reduce((l,c)=>c.clashes<l.clashes?c:l).named()}function KS(e,t,n,r,s,o,l=!0){const c=new Map;for(const B of e){const M=jK(B);if(!M)continue;const $=s[M];c.has($)||c.set($,[]),c.get($).push({row:B,tier:M})}const d=[...c.keys()].sort((B,M)=>B-M),h=Math.max(0,t/2-SK),f=Math.max(0,n/2-_K),p=GK(d.map(B=>c.get(B).length),h,f),g=d.map((B,M)=>({ring:B,rx:h*p[M],ry:f*p[M],count:c.get(B).length})),v=g.reduce((B,M)=>B+M.count,0),N=B=>B.row.via==="tailscale",k=[...c.values()].flat().filter(N).length,x=Math.max(0,...g.map(B=>{const M=c.get(B.ring).filter(N).length,$=rb(B.rx,B.ry);return M>0&&$>0?M*Td*zK/$*360:0})),j=l&&k>0&&k<v?Math.min(UK,Math.max(qK,k/v*360,x)):0,b=FS-j/2,_=FS+j/2,E=[];let R=!1;g.forEach((B,M)=>{const $=VK(c.get(B.ring)),P=$.length,G=P>1&&rb(B.rx,B.ry)/P<Td;G&&(R=!0);const K=M===g.length-1,q=K?-HS*(p[M]-(p[M-1]??0)):HS*(p[M+1]-p[M]),H=j>0?[{members:$.filter(W=>W.row.via!=="tailscale"),from:_,width:360-j},{members:$.filter(W=>W.row.via==="tailscale"),from:b+360,width:j}]:[{members:$,from:null,width:360}];let D=0;for(const W of H){const J=W.members.length;if(J===0)continue;const V=W.width/J,X=J>2;W.members.forEach(({row:Y,tier:Z},ee)=>{const ne=rr(Y),se=W.from==null?HK(J,M)+V*ee:W.from+V*(ee+.5),pe=X?VS(ne,1)*TK*V:0,ke=G&&D%2===1?1+q/p[M]:1,ae=X?VS(ne,2)*AK:0,fe=V*.3;E.push({row:Y,tier:Z,ring:B,index:D,count:P,theta:se+pe,reach:ke*(1+(K?-Math.abs(ae):ae)),lo:W.from==null?-1/0:W.from+fe,hi:W.from==null?1/0:W.from+W.width-fe,turn:V,caption:o(Y)}),D++})}});const T=KK(r);let A=GS(E,R,T);A>0&&!R&&(R=!0,A=GS(E,!0,T));const U=E.map((B,M)=>{const[$,P]=sb(B);return{row:B.row,tier:B.tier,ring:B.ring.ring,x:$,y:P,angle:ZK(Math.atan2(P,$)*180/Math.PI),dist:Math.hypot($,P),side:qI($,P),order:M}}),L=g.reduce((B,M,$)=>c.get(M.ring).some(N)?Math.max(B,p[$]):B,0),F=B=>({from:b,to:_,inner:{rx:h*BS,ry:f*BS},outer:{rx:Math.min(t/2-8,h*L+B),ry:Math.min(n/2-8,f*L+B)},count:k}),O={nodes:U,rings:g,dense:R,zone:j>0?{...F(qS),labelAt:null}:null};return{layout:O,clashes:A,named:()=>{if(!O.zone)return O;const B=E.flatMap(P=>{const[G,K]=sb(P);return UI(P.row,P.tier,G,K,R,P.caption)});let M={...O.zone,labelAt:YS(O.zone,B)},$=M.outer;for(let P=qS+US;M.labelAt==null;P+=US){const G=F(P);if(G.outer.rx===$.rx&&G.outer.ry===$.ry)break;$=G.outer;const K=YS(G,B);K!=null&&(M={...G,labelAt:K})}return{...O,zone:M}}}}function zI(e){return`Tailscale · ${e} deck${e===1?"":"s"}`}function YS(e,t){const n={rx:e.outer.rx-Ad,ry:e.outer.ry-Ad};if(!(n.rx>0&&n.ry>0))return null;const r=Math.min(.5,2/Math.max(n.rx,n.ry)*(180/Math.PI)),s=[];for(let b=e.to;b>=e.from;b-=r){const _=b*Math.PI/180;s.push([Math.cos(_)*n.rx,Math.sin(_)*n.ry])}const o=zS+xl,l={x0:Math.min(...s.map(b=>b[0]))-o,x1:Math.max(...s.map(b=>b[0]))+o,y0:Math.min(...s.map(b=>b[1]))-o,y1:Math.max(...s.map(b=>b[1]))+o},c=t.map(b=>({x0:b.x0-xl,y0:b.y0-xl,x1:b.x1+xl,y1:b.y1+xl})).filter(b=>Pa(b,l)),d=(b,_)=>c.some(E=>b>E.x0&&b<E.x1&&_>E.y0&&_<E.y1),h=[],f=[];let p=0;s.forEach(([b,_],E)=>{E>0&&(p+=Math.hypot(b-s[E-1][0],_-s[E-1][1]));const R=Math.hypot(b,_)||1;let T=!1;for(let A=0;A<=zS&&!T;A+=1.75)T=d(b-b/R*A,_-_/R*A);h.push(p),f.push((f.at(-1)??0)+(T?1:0))});const g=zI(e.count).length*WK/2,v=g+WS,N=p-g-WS;if(!(p>0)||N<v)return null;const k=b=>{let _=0,E=h.length;for(;_<E;){const R=_+E>>1;h[R]<b?_=R+1:E=R}return _},x=b=>{const _=k(b-g),E=k(b+g+1e-9)-1;return E<_||f[E]-(_>0?f[_-1]:0)===0},j=p/2;for(let b=0;j-b>=v;b+=2)for(const _ of b===0?[j]:[j-b,j+b])if(x(_))return _/p;return null}function ZK(e){return(e%360+360)%360}function JK(e){const t=n=>e.filter(n).length;return{paired:t(n=>n.kind==="paired"),online:t(n=>n.kind==="paired"&&n.here),offline:t(n=>n.kind==="paired"&&!n.here),nearby:t(n=>n.kind==="nearby"),asks:t(n=>n.kind==="asks"),dialling:t(n=>n.kind==="dialling"),declined:t(n=>n.kind==="declined"),tailnet:t(n=>n.kind!=="declined"&&n.via==="tailscale"),oneWay:t(n=>n.kind==="paired"&&!n.here&&n.state.startsWith("one-way"))}}function QK(e){const t=[];return e.asks&&t.push(e.asks===1?"1 deck wants to pair":`${e.asks} decks want to pair`),e.paired===0?t.push("no paired decks yet"):e.paired===1?t.push(e.online?"1 paired deck, online":"1 paired deck, away"):e.online===e.paired?t.push(`${e.paired} paired decks, all online`):t.push(`${e.online} of ${e.paired} paired decks online`),e.nearby&&t.push(`${e.nearby} nearby, not paired`),e.dialling&&t.push(`${e.dialling} still dialling`),t.join(" · ")}function j0(e,t){switch(e.kind){case"asks":return"wants to pair";case"nearby":return e.state;case"dialling":return HI(e)?`${e.name.slice(e.addr.length)} · dialling`:"dialling";case"declined":return"declined";case"paired":{if(e.here)return t?eY(t):"online";const n=GI(e);return n?n==="now"?"away · just now":`away · ${n}`:e.state.startsWith("one-way")?"has not called yet":"away"}}}function WI(e){return HI(e)?e.addr:e.name}function HI(e){return e.kind==="dialling"&&!!e.addr&&e.name.startsWith(`${e.addr}:`)}function VI(e){if(e.kind!=="paired")return e.via==="tailscale"?`${e.state}, over Tailscale`:e.state;if(e.here)return e.via==="tailscale"?"online, over Tailscale":"online";const t=GI(e),n=t?t==="now"?"away · last online just now":`away · last online ${t}`:e.state.startsWith("one-way")?e.state:"away";return e.via==="tailscale"?`${n}, over Tailscale`:n}function GI(e){var t;return((t=/last online (.+)$/.exec(e.state))==null?void 0:t[1])??null}function eY(e){return e.trim().split(/\s+/).slice(0,2).join(" ")}function tY(e){var r;if(!e)return[];const t=(e.addrs??[]).map(s=>`${s}:${e.port}`),n=(r=e.tailscale)==null?void 0:r.addr;return n&&!(e.addrs??[]).includes(n)&&t.push(`${n}:${e.port}`),t}function rr(e){let t=e.fp;for(const n of e.twins??[])n.fp<t&&(t=n.fp);return t}function nY(e,t){if(e==null)return t;const n=((t-e)%360+540)%360-180;return e+n}function rY(e,t){if(e.asks)return e.asks===1?"1 deck wants to pair. Answer it in the Local network list, behind this map.":`${e.asks} decks want to pair. Answer them in the Local network list, behind this map.`;if(e.oneWay)return`${e.oneWay} away deck${e.oneWay===1?" only calls":"s only call"} in, and this deck has no address to call ${e.oneWay===1?"it":"them"} on. Add ${e.oneWay===1?"its address":"their addresses"} through Add a deck to reach ${e.oneWay===1?"it":"them"} both ways.`;if(e.dialling)return e.dialling===1?"1 address has never answered. Open it to stop dialling it.":`${e.dialling} addresses have never answered. Open one to stop dialling it.`;if(e.nearby){const n=e.nearby===1?"1 deck nearby is not paired.":`${e.nearby} decks nearby are not paired.`;return t==="invite"?`${n} ${KI}`:e.nearby===1?`${n} Open it to ask to pair.`:`${n} Open one to ask to pair.`}return null}const KI="This deck pairs by invite only. Send one from Add a deck.";function sY(e,t){switch(e.kind){case"asks":return"Waiting for your answer, in the Local network list behind this map.";case"dialling":return"Nothing has answered here yet. Its dialog can stop dialling it.";case"nearby":return t==="invite"?KI:"Not paired yet. Its dialog can ask to pair.";case"paired":return!e.here&&e.state.startsWith("one-way")?"It can reach this deck, not the other way. Add its address through Add a deck.":null;default:return null}}function aY(e){const t={bad:0,wait:1,idle:2,ok:3};return e.map((n,r)=>({l:n,i:r})).sort((n,r)=>t[n.l.tone]-t[r.l.tone]||n.i-r.i).map(({l:n})=>n)}function oY(e,t){const n=/^(\d+)\.(\d+)\.(\d+)/.exec(e??""),r=/^(\d+)\.(\d+)\.(\d+)/.exec(t??"");if(!n||!r)return null;for(let s=1;s<=3;s++){const o=Number(n[s])-Number(r[s]);if(o)return Math.sign(o)}return 0}function iY(e,t,n,r=!0){const s=t?t.alive?t.shareable===!1?"cannot share here":"works here":"expired here":"not on this deck";if(e.alive&&e.shareable===!1)return{there:"cannot share there",here:s,note:null,tone:"idle"};if(!e.alive){const o=t&&!t.alive?"neither copy works — sign in again here":null;return{there:"broken there",here:s,note:o,tone:o?"bad":"idle"}}return t?t.alive?{there:"works there",here:s,note:null,tone:t.shareable===!1?"idle":"ok"}:r||n?{there:"works there",here:s,note:"repairs next round",tone:"wait"}:{there:"works there",here:s,note:"paired automatically — share it to repair",tone:"bad"}:r||n?{there:"works there",here:s,note:"arrives next round",tone:"wait"}:{there:"works there",here:s,note:"paired automatically — pair by invite to take it",tone:"bad"}}function lY(e,t,n,r=null,s=!0){var h;const o=new Map;for(const f of t)(h=o.get(f.key))!=null&&h.alive||o.set(f.key,f);const l=new Set(n),c=[],d=new Set;for(const f of e??[]){if(d.has(f.key))continue;d.add(f.key);const p=o.get(f.key)??null,g=l.has(f.key),v=iY(f,p,g,s),N=p?p.alive?p.shareable===!1?"unavailable":"works":"expired":"missing",k=!f.alive&&p&&!p.alive?v.note:[N==="works"?null:v.here,f.alive&&f.shareable!==!1?null:v.there,v.note].filter(Boolean).join(" · ")||null;c.push({key:f.key,email:f.email,here:N,there:f.alive?f.shareable===!1?"unavailable":"works":"broken",in:!f.alive||f.shareable===!1?"cut":v.tone==="wait"?"wait":v.tone==="bad"?"blocked":"live",out:g&&p?p.alive&&p.shareable!==!1?"live":"cut":null,caption:k,tone:v.tone,usedThere:r===f.key})}for(const f of n){const p=o.get(f);!p||d.has(f)||(d.add(f),c.push({key:f,email:p.email,here:p.alive?p.shareable===!1?"unavailable":"works":"expired",there:"unknown",in:null,out:p.alive&&p.shareable!==!1?"live":"cut",caption:p.alive?p.shareable===!1?"cannot share here":null:"expired here",tone:p.alive?p.shareable===!1?"idle":"ok":"bad",usedThere:!1}))}return c}const cY=1e3;function uY(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),r=Fr(e,t);return`${n} · ${r==="now"?"just now":r}`}function ab(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}const YI={works:"works here",expired:"expired here",missing:"not on this deck",unavailable:"cannot share here"},XI={works:"works there",broken:"broken there",unavailable:"cannot share there",unknown:"not offered by that deck"};function ZI(e){const t=e.in&&e.out?"offered both ways":e.in?"offered by that deck":"offered by this deck";return`${YI[e.here]}, ${XI[e.there]}, ${t}${e.usedThere?", in use there":""}.`}function JI({row:e,source:t,status:n,accounts:r,now:s}){var V,X,Y,Z,ee;const{peer:o,stranger:l}=t,c=e.kind==="paired",d=e.self??e.name,h=e.kind!=="dialling",f=e.kind==="dialling"?null:e.fp,p=o?o.addr?`${o.addr}:${o.port}`:"":l?l.port?`${l.addr}:${l.port}`:l.addr:e.addr,g=(o==null?void 0:o.about)??null,v=((V=n.about)==null?void 0:V.version)??null,N=c?o!=null&&o.waiting?o.lastSeen!=null?"not said — it runs an older version":"not said yet — it says when it next calls":o!=null&&o.offers?"not said — it runs an older version":"not reached yet":"shown once paired",k=ab(n.about),x=ab(g),j=g!=null&&g.version&&v?oY(g.version,v):null,b=o?dh(o.last,s):null,_=o&&((X=o.last)!=null&&X.error)?NG({error:o.last.error,host:o.addr,port:o.port},[...n.strangers??[],...n.pending??[],...(n.peers??[]).filter(ne=>!ne.manual&&ne.addr).map(ne=>({fp:ne.fp,name:ne.name,addr:ne.addr,port:ne.port,at:ne.lastSeen??0}))],s):null,E=(Y=o==null?void 0:o.last)!=null&&Y.error&&b&&b.text!==o.last.error?o.last.error:null,R=((Z=o==null?void 0:o.last)==null?void 0:Z.done)??[],T=!!b&&!!E&&!e.quiet&&e.state.startsWith(b.text),A=c||e.kind==="dialling",U=((o==null?void 0:o.via)??e.via)==="tailscale",L=o?o.waiting?null:o.manual?U?"added by its Tailscale address":"added by address":U?"over Tailscale":"on this network":e.kind==="nearby"?U?"heard over Tailscale":"heard on this network":U?"asked this deck to pair, over Tailscale":"asked this deck to pair",F=e.tone==="bad"?"bad":c?e.here?"up":"down":"loose",O=(o==null?void 0:o.offers)??null,I=F==="up"?(O==null?void 0:O.current)??null:null,B=I&&"key"in I?I.key:null,M=!!I&&"hidden"in I,$=!!I&&"other"in I,P=c?lY((O==null?void 0:O.accounts)??null,r,n.shared??[],B,(o==null?void 0:o.autoPaired)!==!0):[],G=P.filter(ne=>ne.in==null&&ne.out==="cut"),K=P.some(ne=>ne.in!=null),q=P.some(ne=>ne.out!=null),H=new Map(R.map(ne=>[ne.email,ne])),D=R.filter(ne=>!P.some(se=>se.email===ne.email)),W=c?O?O.accounts.length===0?"That deck offers nothing. Nobody there has chosen a login to share.":null:o!=null&&o.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.":(ee=o==null?void 0:o.last)!=null&&ee.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,J=O&&(o!=null&&o.last)&&o.last.at-O.at>cY?Fr(O.at,s):null;return{peer:o,stranger:l,paired:c,own:d,canRename:h,fp:f,where:p,about:g,unsaid:N,hereRuns:k,thereRuns:x,order:j,line:b,silence:_,raw:E,echoed:T,showRound:A,how:L,link:F,hiddenThere:M,otherThere:$,lanes:P,spent:G,taking:K,giving:q,told:H,unplaced:D,unknown:W,stale:J}}function ob(){return a.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:[a.jsx("rect",{x:"2.5",y:"3",width:"11",height:"7.5",rx:"1.2"}),a.jsx("path",{d:"M1 13h14"})]})}function zu({dir:e,gate:t=!1}){const n=t?12:8;return a.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:a.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"})})}function dY({view:e,row:t,status:n,asking:r,drawn:s,onSettings:o}){const{peer:l,paired:c,where:d,about:h,unsaid:f,hereRuns:p,thereRuns:g,order:v,line:N,silence:k,raw:x,echoed:j,showRound:b,how:_,link:E,hiddenThere:R,otherThere:T,lanes:A,spent:U,taking:L,giving:F,told:O,unplaced:I,unknown:B,stale:M}=e;return a.jsxs("div",{className:"lan-map","data-link":E,"data-asking":r||void 0,"data-bus":A.length>0||void 0,children:[a.jsxs("div",{className:"lan-ends",children:[a.jsxs("p",{className:"lan-end",children:[a.jsx("span",{className:"lan-end-name",children:"This deck"}),p&&a.jsx("span",{className:"lan-end-runs",children:p}),c&&n.shareActive===!1&&a.jsx("span",{className:"lan-end-note",children:"current account hidden"})]}),a.jsxs("p",{className:"lan-end","data-side":"there",children:[a.jsx("span",{className:"lan-end-name",children:t.name}),t.kind!=="dialling"&&a.jsxs("span",{className:"lan-end-runs",children:[g??(h?"not said":f),v?` · ${v<0?"older":"newer"}`:null]}),R&&a.jsx("span",{className:"lan-end-note",children:"current account hidden"}),T&&a.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),a.jsxs("div",{className:"lan-link",children:[a.jsx(ob,{}),a.jsxs("span",{className:"lan-span",children:[a.jsxs("span",{className:"lan-wire","aria-hidden":!0,children:[a.jsx("i",{className:"lan-glint","data-dir":"out"}),a.jsx("i",{className:"lan-glint","data-dir":"in"})]}),a.jsx("span",{className:"lan-link-label",children:d?a.jsx("code",{className:"ap-lan-code",children:d}):"none here — it calls this deck"})]}),a.jsx(ob,{}),(d&&_||b)&&a.jsxs("p",{className:"lan-link-sub",children:[d&&_,d&&_&&b&&" · ",b&&(N?j?a.jsx("code",{className:"ap-lan-code",children:x}):a.jsx("span",{className:"lan-round","data-tone":N.tone,children:N.text.replace(/ · now$/," · just now")}):"not asked yet"),b&&x&&!j&&a.jsx("code",{className:"lan-fact-raw",children:x})]}),I.length>0&&a.jsx("ul",{className:"lan-done",children:I.map($=>{const P=Jx($);return a.jsxs("li",{"data-ok":$.ok&&!P,children:[$.email," ",a.jsxs("span",{className:"lan-done-what",children:[$.ok?"arrived":"did not arrive",P&&` — ${P.long}`]})]},`${$.email}:${$.action}`)})}),k&&a.jsx("p",{className:"lan-note lan-link-note",children:k}),(l==null?void 0:l.waiting)&&a.jsx("p",{className:"lan-note lan-link-note",children:t.hint}),(N==null?void 0:N.hint)&&a.jsx("p",{className:"lan-note lan-link-note",children:N.hint})]}),A.length>0&&a.jsx("ul",{className:"lan-lanes",role:"list","aria-label":`Logins between this deck and ${t.name}`,children:A.map(($,P)=>{const G=O.get($.email),K=G?Jx(G):null,q=$.out==="live"||$.in!=null&&$.in!=="cut";return a.jsxs("li",{role:"listitem",className:"lan-lane","data-tone":$.tone,"data-draw":$.in&&$.out?"both":$.in?"in":"out","data-used-there":$.usedThere||void 0,style:{"--i":P},children:[a.jsx("i",{className:"lan-pip","data-end":"here","data-state":$.here,"aria-hidden":!0}),a.jsxs("span",{className:"lan-track",children:[a.jsxs("span",{className:"lan-wire","data-flow":q?"live":"cut","aria-hidden":!0,children:[($.in==="live"||$.in==="wait")&&a.jsx("i",{className:"lan-glint","data-dir":"in","data-tone":$.in}),$.out==="live"&&a.jsx("i",{className:"lan-glint","data-dir":"out"})]}),$.in&&$.in!=="cut"&&a.jsx(zu,{dir:"in",gate:$.in==="blocked"}),$.out==="live"&&a.jsx(zu,{dir:"out"}),a.jsx("span",{className:"lan-lane-email",children:$.email})]}),a.jsx("i",{className:"lan-pip","data-end":"there","data-state":$.there,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:ZI($)}),($.caption||G)&&a.jsxs("span",{className:"lan-lane-note",children:[$.caption,$.caption&&G&&" · ",G&&a.jsxs("span",{className:"lan-lane-done","data-ok":G.ok&&!K,children:[G.ok?"arrived last round":"did not arrive last round",K&&` — ${K.long}`]})]})]},$.key)})},s),c&&a.jsxs(a.Fragment,{children:[U.length>0&&a.jsxs("p",{className:"lan-spent",children:["Paired decks get nothing from ",U.length===1?U[0].email:"the expired ones"," until you sign in again here."]}),B&&a.jsx("p",{className:"lan-empty",children:B}),M&&a.jsxs("p",{className:"lan-stale",children:["As of ",M==="now"?"just now":M,", when it last answered."]}),a.jsxs("div",{className:"lan-legend",children:[L&&a.jsxs("span",{className:"lan-key",children:[a.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:a.jsx(zu,{dir:"in"})}),"from ",t.name]}),F?a.jsxs("span",{className:"lan-key",children:[a.jsx("span",{className:"lan-key-wire","data-dir":"out","aria-hidden":!0,children:a.jsx(zu,{dir:"out"})}),"from this deck, to every paired deck"]}):a.jsx("span",{className:"lan-key",children:"This deck offers nothing yet."}),a.jsx("button",{type:"button",className:"ap-lan-word lan-legend-act",onClick:o,"aria-label":"Change what this deck offers",children:"change"})]})]})]})}const hY=20,fY=17,XS=34,pY=160,mY=80,gY=200,yY=8,wY=14,vY=10,xY=.61803398875;function bY({status:e,rows:t,accounts:n,now:r,covered:s,onOpenDeck:o,onClose:l}){const c=y.useRef(null),d=ut(l,{focusRef:c}),h=gt(l),f=y.useRef(null),[p,g]=y.useState(null),[v,N]=y.useState(!1),k=y.useRef(null);y.useLayoutEffect(()=>{const ae=f.current;if(!ae)return;let fe=null;const me=()=>{const ge=Math.round(ae.clientWidth),ue=Math.round(ae.clientHeight);fe&&fe.w===ge&&fe.h===ue||(fe&&(N(!0),k.current!=null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>N(!1),gY)),fe={w:ge,h:ue},g(fe))};if(me(),typeof ResizeObserver>"u")return;const he=new ResizeObserver(me);return he.observe(ae),()=>{he.disconnect(),k.current!=null&&window.clearTimeout(k.current)}},[]);const x=y.useMemo(()=>p?XK(t,p.w,p.h,(e==null?void 0:e.name)??"",ae=>{var fe,me;return j0(ae,(me=(fe=Ql(e,ae).peer)==null?void 0:fe.about)==null?void 0:me.os)}):null,[t,p,e]),j=y.useMemo(()=>JK(t),[t]),b=(x==null?void 0:x.nodes)??[],_=y.useRef(new Map),E=y.useMemo(()=>{const ae=new Map;for(const fe of b){const me=rr(fe.row);ae.set(me,nY(_.current.get(me),fe.angle))}return _.current=ae,ae},[b]),[R,T]=y.useState(null),[A,U]=y.useState(null),[L,F]=y.useState("none"),O=y.useRef(null),I=y.useCallback((ae,fe)=>{O.current!==ae&&(O.current=ae,F(fe),U(ae))},[]),B=y.useRef(null),M=y.useRef(null),$=y.useCallback(()=>{M.current!=null&&window.clearTimeout(M.current),M.current=null},[]),P=y.useCallback((ae,fe)=>{if(B.current!=null&&window.clearTimeout(B.current),B.current=null,$(),T(ae),fe==="keyboard"){I(ae,"none");return}M.current=window.setTimeout(()=>I(ae,O.current?"swap":"full"),mY)},[I,$]),G=y.useCallback(()=>{B.current!=null&&window.clearTimeout(B.current),$(),B.current=window.setTimeout(()=>T(null),pY)},[$]);y.useEffect(()=>()=>{B.current!=null&&window.clearTimeout(B.current),$()},[$]);const K=R&&b.some(ae=>rr(ae.row)===R)?R:null,q=A?t.find(ae=>rr(ae)===A)??null:null;y.useEffect(()=>{A&&!q&&I(null,"swap")},[A,q,I]);const[H,D]=y.useState(null),W=y.useRef(new Map),J=b.findIndex(ae=>rr(ae.row)===H),V=J<0?0:J,X=ae=>{var ge;if(b.length===0)return;const fe=ae.key==="ArrowRight"||ae.key==="ArrowDown"?1:ae.key==="ArrowLeft"||ae.key==="ArrowUp"?-1:0,me=ae.key==="Home"?0:ae.key==="End"?b.length-1:fe?(V+fe+b.length)%b.length:null;if(me==null)return;ae.preventDefault();const he=rr(b[me].row);D(he),(ge=W.current.get(he))==null||ge.focus()},[Y,Z]=y.useState(()=>typeof document<"u"&&document.hidden);y.useEffect(()=>{const ae=()=>Z(document.hidden);return document.addEventListener("visibilitychange",ae),()=>document.removeEventListener("visibilitychange",ae)},[]);const ee=(e==null?void 0:e.enabled)===!0,ne=e?ee?QK(j):"Local network is off":"checking…",se=()=>{$(),I(null,"swap"),T(null)},pe=K?b.find(ae=>rr(ae.row)===K)??null:null,ke=()=>{var ae;A&&((ae=W.current.get(A))==null||ae.focus()),se()};return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal nm-modal",onClick:ae=>ae.stopPropagation(),"data-paused":s||Y||void 0,role:"dialog","aria-modal":"true","aria-labelledby":"nm-title","aria-describedby":"nm-sub",children:[a.jsxs("header",{className:"modal-head nm-head",children:[a.jsxs("div",{className:"nm-heading",children:[a.jsx("h2",{id:"nm-title",className:"modal-title nm-title",children:"Network map"}),a.jsx("p",{id:"nm-sub",className:"nm-sub",children:ne})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:c,type:"button",className:"glyph-btn",onClick:l,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("div",{className:"nm-body",children:[a.jsxs("div",{className:"nm-view",children:[a.jsx("div",{ref:f,className:"nm-stage","data-focus":K?"":void 0,"data-focus-via":pe==null?void 0:pe.row.via,"data-dense":(x==null?void 0:x.dense)||void 0,"data-still":v||void 0,onClick:ae=>{ae.target===ae.currentTarget&&se()},children:p&&x&&a.jsxs(a.Fragment,{children:[a.jsx(kY,{layout:x,w:p.w,h:p.h}),b.map(ae=>{const fe=rr(ae.row);return a.jsx(SY,{node:ae,angle:E.get(fe)??ae.angle,lit:K===fe},fe)}),a.jsx(_Y,{status:e}),a.jsx("span",{id:"nm-ring-hint",className:"vis-hidden",children:"Arrow keys move between decks. Enter opens the deck's own dialog."}),a.jsx("div",{className:"nm-ring",role:"group","aria-label":`Decks around this deck, ${b.length}`,"aria-describedby":"nm-ring-hint",onKeyDown:X,children:b.map((ae,fe)=>{var he,ge;const me=rr(ae.row);return a.jsx(EY,{node:ae,angle:E.get(me)??ae.angle,os:(ge=(he=Ql(e,ae.row).peer)==null?void 0:he.about)==null?void 0:ge.os,lit:K===me,shown:A===me,tabbable:fe===V,register:ue=>{ue?W.current.set(me,ue):W.current.delete(me)},onHold:ue=>{D(me),P(me,ue)},onRelease:G,onOpen:()=>o(ae.row.fp)},me)})}),b.length===0&&a.jsx(CY,{status:e})]})}),a.jsx(TY,{slice:(x==null?void 0:x.zone)!=null})]}),a.jsx("aside",{className:"nm-side","aria-label":"Details",children:q&&e?a.jsx(RY,{row:q,status:e,accounts:n,now:r,entrance:L,onOpen:()=>o(q.fp),onBack:ke},rr(q)):a.jsx(AY,{status:e,summary:j,entrance:L,slice:(x==null?void 0:x.zone)!=null})})]})]})}),document.body)}function QI(){return a.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:[a.jsx("circle",{cx:"7",cy:"7.4",r:"1.8"}),a.jsx("circle",{cx:"2.4",cy:"2.9",r:"1.2"}),a.jsx("circle",{cx:"11.6",cy:"2.9",r:"1.2"}),a.jsx("circle",{cx:"7",cy:"12.4",r:"1.1"}),a.jsx("path",{d:"M5.7 6.1 3.3 3.8M8.3 6.1l2.4-2.3M7 9.2v2.1"})]})}function kY({layout:e,w:t,h:n}){const{zone:r}=e;return a.jsxs("svg",{className:"nm-orbits",width:t,height:n,viewBox:`0 0 ${t} ${n}`,"aria-hidden":!0,children:[r&&a.jsxs(a.Fragment,{children:[a.jsxs("defs",{children:[a.jsx("path",{id:"nm-zone-arc",d:jY(r,t/2,n/2)}),a.jsxs("radialGradient",{id:"nm-zone-fill",gradientUnits:"userSpaceOnUse",cx:t/2,cy:n/2,r:Math.max(r.outer.rx,r.outer.ry),children:[a.jsx("stop",{className:"nm-zone-stop",offset:"0.2","data-at":"in"}),a.jsx("stop",{className:"nm-zone-stop",offset:"0.5","data-at":"mid"}),a.jsx("stop",{className:"nm-zone-stop",offset:"1","data-at":"out"})]})]}),a.jsx("path",{className:"nm-zone",d:NY(r,t/2,n/2),fill:"url(#nm-zone-fill)"}),r.labelAt!=null&&a.jsx("text",{className:"nm-zone-label",children:a.jsx("textPath",{href:"#nm-zone-arc",startOffset:`${(r.labelAt*100).toFixed(2)}%`,textAnchor:"middle",children:zI(r.count)})})]}),e.rings.map((s,o)=>a.jsx("ellipse",{className:"nm-orbit","data-ring":s.ring,"data-folded":e.folded&&s.ring===1||void 0,cx:t/2,cy:n/2,rx:s.rx,ry:s.ry,style:{"--ring":o}},s.ring))]})}function ZS(e,t,n,r){const s=r*Math.PI/180;return`${(t+Math.cos(s)*e.rx).toFixed(1)},${(n+Math.sin(s)*e.ry).toFixed(1)}`}function NY(e,t,n){const r=e.to-e.from>180?1:0,s=(j,b)=>{const _=b*Math.PI/180;return[t+Math.cos(_)*j.rx,n+Math.sin(_)*j.ry]},o=(j,b)=>b/((j.rx+j.ry)/2)*(180/Math.PI),l=(j,b,_)=>{const E=Math.hypot(b[0]-j[0],b[1]-j[1])||1,R=Math.min(.5,_/E);return[j[0]+(b[0]-j[0])*R,j[1]+(b[1]-j[1])*R]},c=([j,b])=>`${j.toFixed(1)},${b.toFixed(1)}`,d=vY,h=wY,f=o(e.inner,d),p=o(e.outer,h),g=s(e.inner,e.from),v=s(e.outer,e.from),N=s(e.outer,e.to),k=s(e.inner,e.to),x=j=>`${j.rx.toFixed(1)},${j.ry.toFixed(1)}`;return[`M${c(s(e.inner,e.from+f))}`,`Q${c(g)} ${c(l(g,v,d))}`,`L${c(l(v,g,h))}`,`Q${c(v)} ${c(s(e.outer,e.from+p))}`,`A${x(e.outer)} 0 ${r} 1 ${c(s(e.outer,e.to-p))}`,`Q${c(N)} ${c(l(N,k,h))}`,`L${c(l(k,N,d))}`,`Q${c(k)} ${c(s(e.inner,e.to-f))}`,`A${x(e.inner)} 0 ${r} 0 ${c(s(e.inner,e.from+f))}`,"Z"].join(" ")}function jY(e,t,n){const r={rx:e.outer.rx-Ad,ry:e.outer.ry-Ad},s=e.to-e.from>180?1:0;return`M${ZS(r,t,n,e.to)} A${r.rx.toFixed(1)},${r.ry.toFixed(1)} 0 ${s} 0 ${ZS(r,t,n,e.from)}`}function SY({node:e,angle:t,lit:n}){const r=e.row.kind==="paired"&&e.row.here,s=e.order*xY%1*yY;return a.jsx("span",{className:"nm-wire","aria-hidden":!0,"data-tier":e.tier,"data-via":e.row.via,"data-on":n||void 0,style:{"--nm-a":`${t.toFixed(2)}deg`,"--nm-d":`${e.dist.toFixed(1)}px`,"--from":`${XS}px`,"--gap":`${XS+(e.tier==="loose"?fY:hY)}px`,"--i":e.order,"--phase":`${s.toFixed(2)}s`},children:r&&a.jsx("i",{className:"nm-glint"})})}function _Y({status:e}){const t=(e==null?void 0:e.enabled)===!0&&e.running;return a.jsxs("div",{className:"nm-core","data-listening":t||void 0,children:[a.jsx("span",{className:"nm-core-orb","aria-hidden":!0}),a.jsxs("span",{className:"nm-core-label",children:[a.jsx("span",{className:"nm-core-name",children:(e==null?void 0:e.name)??"…"}),a.jsx("span",{className:"nm-core-what",children:"this deck"})]})]})}function EY({node:e,angle:t,os:n,lit:r,shown:s,tabbable:o,register:l,onHold:c,onRelease:d,onOpen:h}){const{row:f}=e,p=`nm-d-${MY(rr(f))}`,g=e.angle*Math.PI/180,v=j0(f,n);return a.jsxs("button",{ref:l,type:"button",className:"nm-node",tabIndex:o?0:-1,"data-tier":e.tier,"data-kind":f.kind,"data-side":e.side,"data-via":f.via,"data-on":r||void 0,"data-shown":s||void 0,"aria-label":`${f.name}: ${VI(f)}`,"aria-describedby":e.tier==="online"?p:void 0,style:{"--nm-a":`${t.toFixed(2)}deg`,"--nm-d":`${e.dist.toFixed(1)}px`,"--i":e.order,"--in-x":`${(-Math.cos(g)*14).toFixed(1)}px`,"--in-y":`${(-Math.sin(g)*14).toFixed(1)}px`},onPointerEnter:N=>{N.pointerType==="mouse"&&c("pointer")},onPointerLeave:d,onFocus:N=>c(N.currentTarget.matches(":focus-visible")?"keyboard":"pointer"),onBlur:d,onClick:h,children:[a.jsx("i",{className:"nm-halo","data-tier":e.tier,"aria-hidden":!0}),f.kind==="dialling"?a.jsx("i",{className:"nm-addr-dot","aria-hidden":!0}):a.jsx(ob,{}),e.tier!=="online"&&a.jsx("i",{className:"nm-mark","data-tier":e.tier,"data-kind":f.kind,"aria-hidden":!0}),a.jsxs("span",{className:"nm-label","aria-hidden":!0,children:[a.jsx("span",{className:"nm-name",children:WI(f)}),a.jsx("span",{className:"nm-cap",children:v})]}),e.tier==="online"&&a.jsx("span",{id:p,className:"vis-hidden",children:v})]})}function CY({status:e}){const t=(e==null?void 0:e.enabled)===!0;return a.jsx("p",{className:"nm-empty",children:e?t?"No other deck yet. Decks on one network usually find each other within a minute; one on another network needs its address, through Add a deck in Local network.":"Local network is off, so this deck is not looking for any other.":"Asking this deck about the network…"})}function TY({slice:e}){return a.jsxs("ul",{className:"nm-legend",children:[a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"online"}),a.jsx("i",{className:"nm-key-mark","data-tier":"online"})]}),"online"]}),a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"offline"}),a.jsx("i",{className:"nm-key-mark","data-tier":"offline"})]}),"away"]}),a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"loose"}),a.jsx("i",{className:"nm-key-mark","data-tier":"loose"})]}),"not paired"]}),e&&a.jsxs("li",{children:[a.jsx("i",{className:"nm-key-zone","aria-hidden":!0}),"over Tailscale"]})]})}function eO({facts:e}){return a.jsx("dl",{className:"lan-facts nm-facts",children:e.map(t=>a.jsxs("div",{className:"lan-fact","data-tone":t.quiet?"quiet":void 0,children:[a.jsx("dt",{children:t.label}),a.jsx("dd",{children:t.value})]},t.label))})}function AY({status:e,summary:t,entrance:n,slice:r}){const s=tY(e),o=ab(e==null?void 0:e.about),l=[];o&&l.push({label:"Runs",value:o}),l.push({label:s.length>1?"Addresses":"Address",value:s.length?a.jsx("span",{className:"nm-addrs",children:s.map(h=>a.jsx("code",{className:"ap-lan-code",children:h},h))}):"none yet",quiet:s.length===0}),e!=null&&e.pairingMode&&l.push({label:"Pairing",value:e.pairingMode==="invite"?"by invite only":"asks and answers"});const c=[{key:"online",n:t.online,words:"online",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"online","aria-hidden":!0})},{key:"away",n:t.offline,words:"away",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"offline","aria-hidden":!0})},{key:"asks",n:t.asks,words:"asking to pair",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","data-kind":"asks","aria-hidden":!0})},{key:"nearby",n:t.nearby,words:"nearby, not paired",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","aria-hidden":!0})},{key:"dialling",n:t.dialling,words:"still dialling",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","aria-hidden":!0})},{key:"declined",n:t.declined,words:"declined, not drawn",mark:a.jsx("i",{"aria-hidden":!0})}],d=rY(t,e==null?void 0:e.pairingMode);return a.jsxs("div",{className:"nm-panel","data-view":"network","data-entrance":n,children:[a.jsx("h3",{className:"nm-panel-name",children:(e==null?void 0:e.name)??"…"}),a.jsx("p",{className:"nm-panel-self",children:"this deck, at the centre of the map"}),a.jsx("ul",{className:"nm-counts",children:c.filter(h=>h.n>0).map(h=>a.jsxs("li",{"data-count":h.key,children:[h.mark,a.jsx("span",{className:"nm-count-n",children:h.n}),a.jsx("span",{className:"nm-count-words",children:h.words})]},h.key))}),t.tailnet>0&&a.jsxs("p",{className:"nm-counts-note",children:[t.tailnet," reached over Tailscale",r?" — the shaded slice, lower right":""]}),d&&a.jsx("p",{className:"nm-next",children:d}),a.jsx(eO,{facts:l}),a.jsx("p",{className:"nm-panel-hint",children:"Point at a deck, or reach one with the arrow keys, to see it here. Press it to open its own dialog."})]})}function RY({row:e,status:t,accounts:n,now:r,entrance:s,onOpen:o,onBack:l}){var x;const c=JI({row:e,source:Ql(t,e),status:t,accounts:n,now:r}),d=[];c.where&&d.push({label:"Address",value:a.jsx("code",{className:"ap-lan-code",children:c.where})}),c.thereRuns&&d.push({label:"Runs",value:`${c.thereRuns}${c.order?` · ${c.order<0?"older than this deck":"newer than this deck"}`:""}`}),c.hiddenThere&&d.push({label:"Signed in to",value:"not said — its owner hides it",quiet:!0}),c.otherThere&&d.push({label:"Signed in to",value:"an account it does not share",quiet:!0});const h=e.kind==="paired"&&e.here||e.kind==="asks",f=sY(e,t.pairingMode),p=aY(c.lanes),g=p.length,v=p.filter(j=>j.tone==="ok").length,N=g===0?"No shared logins":v===g?`${g} shared login${g===1?", fine":"s, all fine"}`:`${g} shared login${g===1?"":"s"} · ${v} fine`,k=c.unknown&&((x=c.peer)!=null&&x.waiting)&&!c.peer.offers?"Its side is not known until it next calls.":c.unknown;return a.jsxs("div",{className:"nm-panel","data-view":"deck","data-entrance":s,"data-tier":e.kind==="paired"?e.here?"online":"offline":"loose",children:[a.jsxs("button",{type:"button",className:"ap-lan-word nm-back",onClick:l,children:[a.jsx("span",{"aria-hidden":!0,children:"‹ "}),"the whole network"]}),a.jsxs("div",{className:"nm-panel-head",children:[a.jsxs("h3",{className:"nm-panel-name",children:[a.jsx("i",{className:h?"ap-pulse":"ap-dot","data-kind":e.kind,"aria-hidden":!0}),a.jsx("span",{className:"nm-panel-title",children:e.name})]}),a.jsx("button",{type:"button",className:"btn nm-open",onClick:o,"aria-label":`Open ${e.name}`,children:"Open"})]}),e.self&&a.jsxs("p",{className:"nm-panel-self",children:["calls itself ",e.self]}),a.jsx("p",{className:"nm-panel-state","data-kind":e.kind,children:VI(e)}),f&&a.jsx("p",{className:"nm-next",children:f}),d.length>0&&a.jsx(eO,{facts:d}),c.paired&&a.jsxs("section",{className:"nm-logins","aria-label":"Logins the two decks share",children:[a.jsx("p",{className:"nm-logins-title",children:N}),g>0&&a.jsx("ul",{className:"nm-lanes",children:p.map((j,b)=>a.jsxs("li",{className:"nm-lane","data-tone":j.tone,style:{"--k":b},children:[a.jsx("i",{className:"nm-lane-dot","aria-hidden":!0}),a.jsx("span",{className:"nm-lane-email","aria-hidden":!0,children:j.email}),JS(j)&&a.jsx("span",{className:"nm-lane-said","aria-hidden":!0,children:JS(j)}),j.usedThere&&a.jsx("span",{className:"nm-lane-used","aria-hidden":!0,children:"in use there"}),a.jsxs("span",{className:"vis-hidden",children:[j.email,": ",ZI(j)]})]},j.key))}),k&&a.jsx("p",{className:"nm-panel-hint",children:k})]})]})}function JS(e){return e.caption?e.caption:e.tone==="ok"?null:`${YI[e.here]} · ${XI[e.there]}`}function MY(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}const $Y=6;function IY({anchorId:e,id:t,rows:n,onHold:r,onLet:s}){const o=y.useRef(null),l=n.filter(g=>g.kind==="paired"),c=l.filter(g=>g.here),d=c.slice(0,$Y),h=l.length-c.length,f=c.length>d.length?`and ${c.length-d.length} more`:h>0?`${h} not on right now`:null,p=y.useCallback(()=>{const g=o.current,v=document.getElementById(e);if(!g||!v)return;const N=h0(v.getBoundingClientRect(),{width:g.offsetWidth,height:g.offsetHeight},{width:window.innerWidth,height:window.innerHeight});g.style.top=`${N.top}px`,g.style.left=`${N.left}px`,g.style.maxHeight=N.maxHeight==null?"":`${N.maxHeight}px`,g.dataset.side=N.side},[e]);return y.useLayoutEffect(()=>{p()}),y.useEffect(()=>(window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}),[p]),Lt.createPortal(a.jsxs("div",{ref:o,id:t,className:"ap-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:s,children:[a.jsx("p",{className:"ap-peek-title",children:c.length?"On the network now":"Nobody on the network"}),d.length>0&&a.jsx("div",{className:"ap-peek-list",children:d.map(g=>a.jsxs("span",{className:"ap-peek-who",children:[a.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),a.jsxs("span",{children:[g.name,g.via==="tailscale"&&a.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]})]},`${g.kind}:${g.fp}`))}),f&&a.jsx("p",{className:"ap-peek-rest",children:f})]}),document.body)}function OY({entry:e,rows:t,onOpen:n,onMap:r,peek:s,openPeek:o,shutPeek:l,holdPeek:c,dropPeek:d}){return a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",id:"ap-lan-entry",className:"ap-nav",onClick:()=>{d(),n()},"aria-describedby":s?"ap-lan-peek":void 0,onPointerEnter:h=>{h.pointerType==="mouse"&&o(OI)},onPointerLeave:l,onFocus:h=>{h.target.matches(":focus-visible")&&o(0)},onBlur:l,children:[a.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:[a.jsx("rect",{x:"1.8",y:"2.3",width:"10.4",height:"7.2",rx:"1.2"}),a.jsx("path",{d:"M5 11.9h4M7 9.5v2.4"})]}),a.jsxs("span",{className:"ap-nav-text",children:[a.jsx("span",{className:"ap-nav-name",children:"Local network"}),a.jsxs("span",{className:"ap-nav-state","data-tone":e.tone,children:[e.live&&a.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),e.text]})]}),a.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:a.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),r&&a.jsx("button",{type:"button",className:"ap-lan-map",onClick:()=>{d(),r()},"aria-label":"Show the network map",title:"Network map — every deck this one knows, drawn around it",children:a.jsx(QI,{})}),s&&a.jsx(IY,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:t,onHold:c,onLet:l})]})}function LY({row:e,run:t,onVerb:n,onUnpair:r}){const[s,o]=y.useState(!1),l=y.useRef(0),[c,d]=y.useState(null);return y.useEffect(()=>{if(!s)return;const p=window.setTimeout(()=>o(!1),4e3);return()=>window.clearTimeout(p)},[s]),y.useEffect(()=>{if(!c)return;const p=window.setTimeout(()=>d(null),4e3);return()=>window.clearTimeout(p)},[c]),{armed:s,armedTwin:c,pressOwn:()=>{const p=Date.now(),g=Kl({armedFor:s?e.fp:null,target:e.fp,armedAt:l.current,now:p,gapMs:Gl});if(g==="arm"){o(!0),d(null),l.current=p;return}g!=="ignore"&&(o(!1),t(n))},pressTwin:p=>{if(!r)return;const g=Date.now(),v=Kl({armedFor:c,target:p,armedAt:l.current,now:g,gapMs:Gl});if(v==="arm"){d(p),o(!1),l.current=g;return}v!=="ignore"&&(d(null),t(()=>r(p)))}}}function PY({row:e,paired:t,peer:n,status:r,busy:s,press:o,checkNow:l,armed:c,pressOwn:d,run:h,onVerb:f,onInvite:p}){return a.jsxs("footer",{className:"lan-peer-foot",children:[e.kind==="asks"&&a.jsx("p",{className:"lan-foot-note",children:"This deck is now asking to pair. Answer it from the panel behind this."}),t&&!(n!=null&&n.waiting)&&a.jsx("button",{type:"button",className:"btn",...o(`check:${e.fp}`),onClick:l,title:"Ask this deck now instead of waiting for the next round",children:s===`check:${e.fp}`?"Checking…":"Check now"}),e.kind==="paired"&&a.jsx("button",{type:"button",className:`btn danger lan-peer-verb${c?" armed":""}`,...o(`unpair:${e.fp}`),onKeyDown:g=>{g.repeat&&g.preventDefault()},onClick:()=>d(),"aria-label":c?`Confirm unpairing ${e.name}`:`Unpair ${e.name}`,title:c?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this deck from now on",children:s===`unpair:${e.fp}`?"Unpairing…":c?"Confirm unpair":"Unpair"}),e.kind==="nearby"&&r.pairingMode!=="invite"&&a.jsx("button",{type:"button",className:"btn primary lan-peer-verb",...o(`accept:${e.fp}`),onClick:()=>void h(f),title:"Send it a request. Somebody at that machine has to accept it before anything is shared.",children:s===`accept:${e.fp}`?"Asking…":"Ask to pair"}),e.kind==="dialling"&&a.jsx("button",{type:"button",className:"btn lan-peer-verb",...o(`drop:${e.fp}`),onClick:()=>void h(f),title:"Stop trying this address. Nothing was ever paired here.",children:s===`drop:${e.fp}`?"Stopping…":"Stop dialling"}),e.kind==="declined"&&r.pairingMode!=="invite"&&a.jsx("button",{type:"button",className:"btn lan-peer-verb",...o(`allow:${e.fp}`),onClick:()=>void h(f),title:"Take the no back. That deck is still trying, so its request comes round again on its own.",children:s===`allow:${e.fp}`?"Allowing…":"Let it ask again"}),(e.kind==="nearby"||e.kind==="declined")&&r.pairingMode==="invite"&&p&&a.jsx("button",{type:"button",className:"btn primary lan-peer-verb",onClick:p,title:"This deck pairs only by invite. Make one and send it to whoever is at that machine.",children:"Invite to pair"})]})}function DY({instances:e,now:t,busy:n,press:r,armedTwin:s,pressTwin:o,onUnpair:l}){return a.jsxs("div",{className:"modal-section",children:[a.jsxs("h3",{className:"lan-h",children:[e.length," decks on this machine"]}),a.jsx("ul",{className:"lan-twins",role:"list",children:e.map((c,d)=>{var N,k,x,j;const h=(N=c.peer)!=null&&N.addr?`${c.peer.addr}:${c.peer.port}`:c.row.addr,f=h||c.row.fp,p=(k=c.peer)!=null&&k.pairedAt?Fr(c.peer.pairedAt,t):null,g=[(j=(x=c.peer)==null?void 0:x.about)!=null&&j.version?`runs ${c.peer.about.version}`:null,p?`paired ${p==="now"?"just now":p}`:null,c.row.state].filter(Boolean).join(" · "),v=c.row.fp;return a.jsxs("li",{role:"listitem",className:"lan-twin","data-tone":c.row.tone,children:[a.jsx("i",{className:c.row.here?"ap-pulse":"ap-dot","aria-hidden":!0}),h?a.jsx("code",{className:"ap-lan-code lan-twin-at",children:h}):a.jsx("span",{className:"lan-twin-at lan-twin-none",children:"no address here"}),a.jsx("code",{className:"ap-lan-code lan-twin-fp",children:v}),d>0&&l&&a.jsx("button",{type:"button",className:`ap-manage-btn danger lan-twin-do${s===v?" armed":""}`,...r(`unpair:${v}`),onKeyDown:b=>{b.repeat&&b.preventDefault()},onClick:()=>o(v),"aria-label":s===v?`Confirm unpairing ${f}`:`Unpair ${f}`,title:s===v?"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:n===`unpair:${v}`?"unpairing…":s===v?"confirm":"unpair"}),a.jsx("span",{className:"lan-twin-meta",children:d===0?`${g} · shown above`:g})]},v)})})]})}function FY(){return a.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:[a.jsx("path",{d:"M9.6 2.4l2 2L5 11l-2.6.6L3 9z"}),a.jsx("path",{d:"M8.4 3.6l2 2"})]})}function BY({row:e,source:t,status:n,accounts:r,now:s,busy:o,onClose:l,onRename:c,onCheck:d,onVerb:h,onSettings:f,onInvite:p,twins:g=[],onUnpair:v}){const N=y.useRef(null),k=ut(l,{focusRef:N}),x=gt(l),[j,b]=y.useState(null),[_,E]=y.useState(null),[R,T]=y.useState(!1),[A,U]=y.useState(0),L=y.useRef(null),F=y.useRef(null),O=y.useRef(!0);y.useEffect(()=>()=>{O.current=!1},[]);const I=j!=null;y.useEffect(()=>{var ae;I&&((ae=L.current)==null||ae.select())},[I]);const B=y.useRef(!1);y.useEffect(()=>{var ae,fe;B.current&&!I&&Cn(((ae=document.activeElement)==null?void 0:ae.tagName)??null)&&((fe=F.current)==null||fe.focus()),B.current=I},[I]);const M=ae=>{const fe=ia(o,ae);return{disabled:fe.disabled,"aria-busy":fe.busy}},$=async ae=>{const fe=await ae();return O.current&&E(fe),fe==null},{armed:P,armedTwin:G,pressOwn:K,pressTwin:q}=LY({row:e,run:$,onVerb:h,onUnpair:v}),H=JI({row:e,source:t,status:n,accounts:r,now:s}),{peer:D,stranger:W,paired:J,own:V,canRename:X,fp:Y}=H,Z=o===`check:${e.fp}`,ee=async ae=>{const fe=ae.trim()===V?"":ae;await $(()=>c(fe))&&b(null)},ne=()=>void $(d).then(ae=>{ae&&O.current&&U(fe=>fe+1)}),se=async()=>{if(Y)try{if(await navigator.clipboard.writeText(Y),!O.current)return;T(!0),window.setTimeout(()=>{O.current&&T(!1)},1600)}catch{O.current&&E("Could not copy it — select the fingerprint and copy it by hand.")}},pe=[];J&&(D!=null&&D.pairedAt)?pe.push({label:"Paired",value:uY(D.pairedAt,s),tone:"meta"}):e.kind==="declined"&&W&&pe.push({label:"Paired",value:`no · you said no ${b0(W.at,s)}`,tone:"meta"}),pe.push({label:"Fingerprint",value:Y?a.jsxs("span",{className:"lan-fp",children:[a.jsx("code",{className:"ap-lan-code",children:Y}),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void se(),"aria-label":R?"Fingerprint copied":"Copy the fingerprint",children:R?"copied":"copy"})]}):"not known — nothing has answered there",tone:Y?void 0:"quiet"});const ke=g.length?[{row:e,peer:D??null},...g]:[];return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...x,role:"presentation",children:a.jsxs("div",{ref:k,className:"modal lan-peer","data-tone":e.tone,onClick:ae=>ae.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-peer-title","aria-describedby":"lan-peer-sub",children:[a.jsxs("header",{className:"modal-head lan-peer-head",children:[a.jsx("i",{className:e.here?"ap-pulse":"ap-dot","aria-hidden":!0}),a.jsxs("div",{className:"lan-peer-id",children:[I?a.jsxs("form",{className:"lan-peer-edit",onSubmit:ae=>{ae.preventDefault(),ee(j??"")},children:[a.jsx("span",{id:"lan-peer-title",className:"vis-hidden",children:e.name}),a.jsx("input",{ref:L,className:"ap-manage-input lan-peer-input",value:j??"",maxLength:48,placeholder:V,"aria-label":"Name for this deck, shown on this deck only",onChange:ae=>b(ae.target.value)}),a.jsx("button",{type:"submit",className:"ap-manage-btn",...M(`alias:${e.fp}`),children:"save"}),a.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>b(null),children:"cancel"})]}):a.jsxs("span",{className:"lan-peer-title",children:[a.jsx("span",{id:"lan-peer-title",className:"lan-peer-name",children:e.name}),X&&a.jsx("button",{type:"button",className:"glyph-btn lan-peer-rename",ref:F,onClick:()=>{E(null),b(e.name)},"aria-label":`Rename ${e.name} on this deck`,title:"Give it a name of your own. Only this deck sees it.",children:a.jsx(FY,{})})]}),a.jsxs("p",{id:"lan-peer-sub",className:"lan-peer-sub",children:[e.self&&a.jsxs(a.Fragment,{children:["calls itself ",a.jsx("span",{className:"lan-peer-self",children:e.self}),I&&a.jsx("button",{type:"button",className:"ap-lan-word lan-peer-restore",...M(`alias:${e.fp}`),onClick:()=>void ee(""),children:"use this name"}),a.jsx("span",{className:"vis-hidden",children:". "}),!e.quiet&&a.jsx("span",{"aria-hidden":!0,children:" · "})]}),a.jsx("span",{className:e.quiet?"vis-hidden":"lan-peer-state",children:e.state})]})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:N,type:"button",className:"glyph-btn",onClick:l,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body lan-peer-body",children:[_&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",children:_}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>E(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),a.jsx(dY,{view:H,row:e,status:n,asking:Z,drawn:A,onSettings:f}),a.jsx("dl",{className:"lan-facts",children:pe.map(ae=>a.jsxs("div",{className:"lan-fact","data-tone":ae.tone,children:[a.jsx("dt",{children:ae.label}),a.jsx("dd",{children:ae.value})]},ae.label))}),ke.length>1&&a.jsx(DY,{instances:ke,now:s,busy:o,press:M,armedTwin:G,pressTwin:q,onUnpair:v})]}),a.jsx(PY,{row:e,paired:J,peer:D,status:n,busy:o,press:M,checkNow:ne,armed:P,pressOwn:K,run:$,onVerb:h,onInvite:p})]})}),document.body)}function is(e,t){const n=y.useRef(!1);return y.useEffect(()=>{var r,s;!e||!n.current||(n.current=!1,Cn(((r=document.activeElement)==null?void 0:r.tagName)??null)&&(typeof t=="function"?t():(s=t.current)==null||s.focus()))},[e]),()=>{n.current=!0}}function qY(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(r=>n.has(r))}function UY(e,t,n,r){const s=new Set(e??t);return r?s.add(n):s.delete(n),[...s]}function QS(e,t,n){return e==null||n!=null&&!n.ok||qY(e,t)?null:e}function tO({line:e,onDismiss:t,onAnswer:n}){const[r,s]=y.useState(!1),o=y.useRef(!1),l=y.useRef(!0);y.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);const c=y.useRef(null),d=y.useRef(null),h=y.useRef(!1);if(y.useEffect(()=>{var p;h.current&&(h.current=!1,e!=null&&e.giveBack||(p=d.current)==null||p.focus())},[e]),!e)return null;const f=async()=>{if(o.current)return;o.current=!0,s(!0);const p=await qG();o.current=!1,l.current&&(s(!1),h.current=document.activeElement===c.current,n(zG(p)))};return a.jsxs("div",{className:e.done?"ap-failure ap-failure-done":"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",children:e.text}),e.giveBack&&a.jsx("button",{ref:c,type:"button",className:"ap-fix ap-give-back","aria-busy":r,onClick:f,title:"Opens macOS's password dialog to make the settings folder yours again",children:r?"waiting for macOS…":"give it back"}),a.jsx("button",{ref:d,type:"button",className:"ap-failure-x",onClick:t,"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]})}function zY(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}const Wu="Paused while this deck pairs only by invite. Turn that off above to use it.";function WY({status:e,accounts:t,onClose:n,onChanged:r}){qt("lan-setup");const s=ut(n),o=gt(n),[l,c]=y.useState(null),[d,h]=y.useState(null),[f,p]=y.useState(!1),[g,v]=y.useState(null),N=y.useRef(null),k=q=>{const H=ia(g,q);return{disabled:H.disabled,"aria-busy":H.busy}},x=y.useRef(null),j=y.useRef(!0);y.useEffect(()=>()=>{j.current=!1},[]),y.useEffect(()=>{x.current=QS(x.current,e.shared??[],null)},[e.shared]);const b=y.useCallback(async(q,H,D="write")=>{N.current=D,v(D);try{const J=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:q})})).json().catch(()=>null);return j.current?(J!=null&&J.ok?h(null):h(sr(Ct(H,J),J)),r(),(J==null?void 0:J.ok)===!0):!1}catch{return j.current&&h(sr(Ct(H,null))),!1}finally{N.current=null,j.current&&v(null)}},[r]),_=y.useCallback(async q=>{const H=await b({name:q},"save the name","name");return H&&j.current&&c(D=>D===q?null:D),H},[b]),E=y.useRef(null),R=l!=null&&l!==(e.name??""),T=is(!R,E),A=y.useCallback(async()=>{R&&!await _(l)||n()},[R,l,_,n]),U=async()=>{if(!e.fp)return;const q=await eo(e.fp);if(j.current){if(!q){h(sr("Could not copy it — select the fingerprint and copy it by hand."));return}p(!0),window.setTimeout(()=>{j.current&&p(!1)},1600)}},L=new Set(x.current??e.shared??[]),F=e.autoAsk!==!1,O=e.autoAccept!==!1,I=e.pairingMode==="invite",B=q=>{const H=k(q);return{...H,disabled:H.disabled||I}},M=e.shareActive!==!1,$=e.tailscale??null,P=!!($!=null&&$.on),G=($==null?void 0:$.ask)!==!1,K=($==null?void 0:$.accept)!==!1;return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal lan-modal",onClick:q=>q.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-modal-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"lan-modal-title",className:"modal-tool-name",children:"This deck on the network"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsx(tO,{line:d,onDismiss:()=>h(null),onAnswer:q=>{h(q),q.done&&r()}}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Name"}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("span",{className:"ap-lan-label",children:"appear as"}),a.jsx("input",{ref:E,className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:l??e.name??"",placeholder:"this machine",onChange:q=>c(q.target.value),onKeyDown:q=>{q.key!=="Enter"||l==null||_(l)}}),R&&a.jsx("button",{type:"button",className:"ap-manage-btn",...k("name"),onClick:()=>{T(),_(l)},title:"Save it. This is the name other decks show for this one.",children:"save"})]}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("span",{className:"ap-lan-label",children:"fingerprint"}),e.fp?a.jsxs("span",{className:"lan-fp",children:[a.jsx("code",{className:"ap-lan-code",children:e.fp}),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void U(),"aria-label":f?"Fingerprint copied":"Copy this deck's fingerprint",children:f?"copied":"copy"})]}):a.jsx("span",{className:"ap-lan-label",children:"not known yet"})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Share these accounts"}),a.jsxs("div",{className:"ap-lan-picks",children:[t.length===0&&a.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(q=>a.jsxs("label",{className:"ap-lan-pick",title:q.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:[a.jsx("input",{type:"checkbox",checked:L.has(q.key),onChange:H=>{const D=UY(x.current,e.shared??[],q.key,H.target.checked);x.current=D,b({shared:D},H.target.checked?"share that account":"stop sharing that account").then(W=>{x.current===D&&(x.current=QS(D,e.shared??[],{ok:W}))})}}),a.jsx("span",{className:"ap-lan-pick-name",children:q.email}),!q.alive&&a.jsx("span",{className:"ap-lan-dead",children:"not working here"})]},q.key))]}),t.length>0&&a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Show paired decks which of these this deck is using"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":M,"aria-label":"Show paired decks which of these this deck is using",...k("current"),onClick:()=>void b({shareActive:!M},M?"stop showing which account this deck is using":"show which account this deck is using","current"),title:M?"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:a.jsx("span",{className:"switch-knob"})})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",id:"lan-pairing-h",children:"Pairing"}),a.jsx("div",{className:"lan-switches lan-switches-lead",role:"group","aria-labelledby":"lan-pairing-h",children:a.jsxs("div",{className:"lan-switch",children:[a.jsxs("span",{className:"lan-switch-what",children:["Pair new decks only by invite",I&&a.jsx("span",{id:"lan-invite-only-detail",className:"lan-switch-detail",children:"A new deck needs an invite from Add a deck, the link at the top of Local network. Paired decks stay paired."})]}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":I,"aria-label":"Pair new decks only by invite","aria-describedby":I?"lan-invite-only-detail":void 0,...k("mode"),onKeyDown:q=>{q.repeat&&q.preventDefault()},onClick:()=>void b({pairingMode:I?"automatic":"invite"},I?"let decks pair on their own again":"pair new decks only by invite","mode"),title:I?"Let decks on this network pair as the two switches below say again.":"Only a deck you send an invite to can pair with this one. Nearby decks can't ask, and requests waiting now are turned away.",children:a.jsx("span",{className:"switch-knob"})})]})}),a.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-auto-h",children:[a.jsxs("p",{className:"lan-sub",id:"lan-auto-h",children:["Automatic pairing",I&&a.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),a.jsxs("div",{className:"lan-switches","data-paused":I||void 0,children:[a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Ask every deck this one finds"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":F,"aria-label":"Ask every deck this one finds",...B("ask"),onClick:()=>void b({autoAsk:!F},F?"stop asking automatically":"ask every deck this one finds","ask"),title:I?Wu:F?"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:a.jsx("span",{className:"switch-knob"})})]}),a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Say yes to every deck that asks"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":O,"aria-label":"Say yes to every deck that asks","data-tone":"warn",...B("accept"),onKeyDown:q=>{q.repeat&&q.preventDefault()},onClick:()=>void b({autoAccept:!O},O?"stop accepting automatically":"accept every deck that asks","accept"),title:I?Wu:O?"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:a.jsx("span",{className:"switch-knob"})})]})]})]})]}),($==null?void 0:$.found)&&a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Tailscale"}),a.jsxs("div",{className:"lan-switches",children:[a.jsxs("div",{className:"lan-switch",children:[a.jsxs("span",{className:"lan-switch-what",children:["Look for my devices",a.jsx("span",{id:"lan-ts-detail",className:"lan-switch-detail",children:zY($)})]}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":P,"aria-label":"Look for my devices over Tailscale","aria-describedby":"lan-ts-detail",...k("tailscale"),onClick:()=>void b({tailscale:!P},P?"stop looking over Tailscale":"look for your devices over Tailscale","tailscale"),title:P?"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:a.jsx("span",{className:"switch-knob"})})]}),P&&a.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-ts-auto-h",children:[a.jsxs("p",{className:"lan-sub",id:"lan-ts-auto-h",children:["Automatic pairing with my devices",I&&a.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),a.jsxs("div",{className:"lan-switches",children:[a.jsxs("div",{className:"lan-switch","data-paused":I||void 0,children:[a.jsx("span",{className:"lan-switch-what",children:"Ask each device it finds"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":G,"aria-label":"Ask each of my devices it finds over Tailscale",...B("tailscale-ask"),onClick:()=>void b({tailscaleAsk:!G},G?"stop asking your devices automatically":"ask your devices automatically","tailscale-ask"),title:I?Wu:G?"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:a.jsx("span",{className:"switch-knob"})})]}),a.jsxs("div",{className:"lan-switch","data-paused":I||void 0,children:[a.jsx("span",{className:"lan-switch-what",children:"Say yes to each device that asks"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":K,"aria-label":"Say yes to my devices when they ask over Tailscale","data-tone":"warn",...B("tailscale-accept"),onKeyDown:q=>{q.repeat&&q.preventDefault()},onClick:()=>void b({tailscaleAccept:!K},K?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:I?Wu:K?"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:a.jsx("span",{className:"switch-knob"})})]})]})]})]})]})]}),a.jsxs("footer",{className:"lan-setup-foot",children:[a.jsx("span",{className:"lan-foot-note",children:"Changes are saved as you make them."}),a.jsx("button",{type:"button",className:"btn primary",...k("name"),onClick:()=>void A(),children:"Done"})]})]})}),document.body)}function HY({on:e,status:t,paired:n,busy:r,pressProps:s,checkNow:o,setAddOpen:l,setSetupOpen:c,setMapOpen:d,onBack:h,closeButton:f}){return a.jsxs("div",{className:"ap-header",children:[a.jsx("button",{type:"button",id:"ap-lan-back",className:"glyph-btn ap-back",onClick:h,"aria-label":"Back to Claude accounts",title:"Back to Claude accounts",children:a.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:a.jsx("path",{d:"M8.4 3.4 4.8 7l3.6 3.6"})})}),a.jsx("h2",{id:"ap-lan-title",children:"Local network"}),a.jsxs("div",{className:"ap-header-right",children:[e&&a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>d(!0),"aria-label":"Show the network map",title:"Network map — every deck this one knows, drawn around it",children:a.jsx(QI,{})}),e&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-plus",onClick:()=>l("add"),"aria-label":"Add a deck",title:(t==null?void 0:t.pairingMode)==="invite"?"Send an invite, or use one you were sent. This deck pairs only by invite.":"Reach a deck that has not turned up on its own — by address, or with an invite",children:a.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:[a.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"}),a.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"})]})}),e&&n>0&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-check",...s("check"),onClick:()=>void o(),"aria-label":r==="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:a.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:[a.jsx("circle",{cx:"7",cy:"7",r:"1.1",fill:"currentColor",stroke:"none"}),a.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"}),a.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"})]})}),e&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-set",...s("setup"),onClick:()=>c(!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:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M1.8 4.7h10.4M1.8 9.3h10.4"}),a.jsx("circle",{cx:"9.1",cy:"4.7",r:"1.6",fill:"var(--panel)"}),a.jsx("circle",{cx:"4.9",cy:"9.3",r:"1.6",fill:"var(--panel)"})]})}),f]})]})}function VY({accounts:e,onChanged:t,onNoCopy:n,view:r,onOpen:s,onBack:o,closeButton:l}){const[c,d]=y.useState(!1),[h,f]=y.useState(!1),[p,g]=y.useState(!1),v=FG(),[N,k]=y.useState(!1),{status:x,manual:j,now:b,busy:_,failure:E,dismissFailure:R,answerGiveBack:T,pressProps:A,load:U,toggle:L,answer:F,dropAddress:O,rename:I,checkOne:B,checkNow:M}=KG(t,()=>d(!0)),{armed:$,pressUnpair:P}=YG(F),[G,K]=y.useState(null),[q,H]=y.useState(!1),D=y.useMemo(()=>e.filter(me=>PG(me.key,x??null,b)).map(me=>me.key).sort().join(`
|
|
92
92
|
`),[e,x,b]);y.useEffect(()=>{n==null||n(D?D.split(`
|
|
93
93
|
`):[])},[D,n]);const W=(x==null?void 0:x.enabled)===!0,J=y.useMemo(()=>EG((x==null?void 0:x.pairingMode)==="invite"&&x?{...x,pending:[]}:x,b),[x,b]),V=G?J.find(me=>{var he;return me.fp===G||((he=me.twins)==null?void 0:he.some(ge=>ge.fp===G))})??null:null;y.useEffect(()=>{G&&x&&!V&&K(null)},[G,x,V]);const{asks:X,rest:Y,live:Z,folded:ee,troubled:ne,shown:se,paired:pe}=LG(J,N),ke=jG(x,b),ae=OG(x,J),fe=a.jsxs(a.Fragment,{children:[h&&x&&a.jsx(yK,{status:x,manual:j,startWith:h==="invite"?"invite":void 0,onClose:()=>f(!1),onChanged:()=>{U(),t()}}),p&&a.jsx(DI,{title:"How Local network works",steps:cK,finish:W?void 0:{label:"Turn it on",act:()=>{g(!1),L()}},onClose:()=>g(!1)}),c&&x&&a.jsx(WY,{status:{...x,manualRows:j},accounts:e,manual:j,onClose:()=>d(!1),onChanged:()=>{U(),t()}}),q&&a.jsx(bY,{status:x,rows:J,accounts:e,now:b,covered:!!V||c||!!h||p,onOpenDeck:K,onClose:()=>H(!1)}),V&&x&&a.jsx(BY,{row:V,source:Ql(x,V),status:x,accounts:e,now:b,busy:_,onClose:()=>K(null),onRename:me=>I(V.fp,me),onCheck:()=>B(V.fp),onVerb:()=>{switch(V.kind){case"paired":return F("unpair",V.fp,"unpair that deck");case"nearby":return F("accept",V.fp,"reach that deck");case"declined":return F("allow",V.fp,"let that deck ask again");case"dialling":return O(V.fp);default:return Promise.resolve(null)}},onSettings:()=>{K(null),d(!0)},onInvite:()=>{K(null),f("invite")},twins:(V.twins??[]).map(me=>({row:me,peer:Ql(x,me).peer??null})),onUnpair:me=>F("unpair",me,"unpair that deck")})]});return r?a.jsxs("div",{className:"ap-lan-view",children:[a.jsx(HY,{on:W,status:x,paired:pe,busy:_,pressProps:A,checkNow:M,setAddOpen:f,setSetupOpen:d,setMapOpen:H,onBack:o,closeButton:l}),a.jsx("div",{className:"ap-scroll",id:"ap-lan-scroll",children:a.jsxs("div",{className:"ap-lan",children:[a.jsxs("div",{className:"ap-policy",children:[a.jsx("h3",{className:"ap-auto-title",children:"Sync with paired decks"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":W,"aria-label":"Sync with paired decks",...A("switch"),onClick:()=>void L(),title:W?"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:a.jsx("span",{className:"switch-knob"})})]}),a.jsx(kK,{on:W,status:x}),!W&&a.jsxs("button",{type:"button",className:"ap-lan-intro",onClick:()=>g(!0),title:"Four pictures: what this does, and what to do on each machine",children:[a.jsx(uK,{}),a.jsx("span",{className:"ap-lan-intro-text",children:"Paired machines repair each other's expired logins."}),a.jsx("span",{className:"ap-lan-intro-go",children:"See how it works"})]}),a.jsx("p",{className:`ap-lan-status ${ke.tone}`,role:"status",children:ke.tone==="ok"?"":ke.text}),a.jsx(tO,{line:E,onDismiss:R,onAnswer:T}),W&&a.jsxs(a.Fragment,{children:[X.length>0&&a.jsx(vK,{asks:X,pressProps:A,answer:F}),se.length>0&&a.jsx(xK,{rows:se,pairingMode:x==null?void 0:x.pairingMode,armed:$,pressProps:A,answer:F,dropAddress:O,onUnpair:P,onOpenPeer:K,onInvite:()=>f("invite")}),(Z.length>0&&ee.length>0||W&&pe>0)&&a.jsxs("div",{className:"ap-lan-tail",children:[Z.length>0&&ee.length>0&&a.jsxs("button",{type:"button",className:"ap-lan-word ap-lan-more","aria-expanded":N,onClick:()=>k(me=>!me),title:N?"Show only the decks that are on":`Show the ${ee.length} deck${ee.length===1?"":"s"} that are not responding right now`,children:[a.jsx("span",{className:`ap-lan-chev${N?" open":""}`,"aria-hidden":!0,children:"›"}),N?"fewer":`${ee.length} more`,!N&&ne>0&&a.jsxs("span",{className:"ap-lan-more-bad",children:[" · ",ne," not responding"]})]}),W&&pe>0&&a.jsx("span",{className:"ap-lan-checked",children:SG(x==null?void 0:x.checkedAt,b,_==="check")})]}),Y.length===0&&X.length===0&&!(x!=null&&x.stalled)&&!(x!=null&&x.deaf)&&!(x!=null&&x.lanTunneled)&&a.jsxs(a.Fragment,{children:[a.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."}),a.jsx("button",{type:"button",className:"ap-lan-word ap-lan-how",onClick:()=>g(!0),children:"How it works"})]})]})]})}),fe]}):a.jsxs("div",{className:"ap-foot",children:[a.jsx(OY,{entry:ae,rows:J,onOpen:s,onMap:W?()=>H(!0):void 0,...v}),a.jsx("p",{className:"vis-hidden",role:"status",children:ke.tone==="ok"?"":ke.text}),fe]})}function GY({anchorId:e,id:t,peers:n,onHold:r,onLet:s}){const o=y.useRef(null),{title:l,shown:c,rest:d}=wG(n),h=y.useCallback(()=>{const f=o.current,p=document.getElementById(e);if(!f||!p)return;const g=h0(p.getBoundingClientRect(),{width:f.offsetWidth,height:f.offsetHeight},{width:window.innerWidth,height:window.innerHeight});f.style.top=`${g.top}px`,f.style.left=`${g.left}px`,f.style.maxHeight=g.maxHeight==null?"":`${g.maxHeight}px`,f.dataset.side=g.side},[e]);return y.useLayoutEffect(()=>{h()}),y.useEffect(()=>(window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}),[h]),Lt.createPortal(a.jsxs("div",{ref:o,id:t,className:"ap-peek ap-fold-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:s,children:[a.jsx("p",{className:"ap-peek-title",children:l}),a.jsx("div",{className:"ap-peek-list",children:c.map(f=>a.jsxs("span",{className:"ap-peek-who ap-fold-who",children:[a.jsx("span",{className:"ap-fold-name",children:f.name}),a.jsx("span",{className:"ap-fold-state","data-tone":f.ready?"ok":f.warn?"warn":"idle",children:f.ready?f.headroom==null?"not read yet":`${Math.round(f.headroom)}% free`:f.why})]},f.key))}),d&&a.jsx("p",{className:"ap-peek-rest",children:d})]}),document.body)}function KY({peers:e,strained:t,armed:n,threshold:r,open:s,onToggle:o,order:l,choices:c,onOrder:d,allOpen:h,onToggleAll:f,held:p=!1}){const[g,v]=y.useState(!1),N=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(N.current),[]),y.useEffect(()=>{s&&(window.clearTimeout(N.current),v(!1))},[s]);const k=E=>{s||(window.clearTimeout(N.current),N.current=window.setTimeout(()=>v(!0),E))},x=()=>{window.clearTimeout(N.current),N.current=window.setTimeout(()=>v(!1),LI)},j=()=>window.clearTimeout(N.current),b=()=>{window.clearTimeout(N.current),v(!1)},_=gG(e,{strained:t&&!s,armed:n,threshold:r});return a.jsxs("div",{className:"ap-rest",children:[a.jsxs("button",{type:"button",id:"ap-rest-entry",className:"ap-nav","aria-expanded":s,"aria-controls":s?"ap-rest-panel":void 0,"aria-describedby":g?"ap-rest-peek":void 0,onClick:()=>{b(),o()},onPointerEnter:E=>{E.pointerType==="mouse"&&k(OI)},onPointerLeave:x,onFocus:E=>{E.target.matches(":focus-visible")&&k(0)},onBlur:x,children:[a.jsxs("span",{className:"ap-nav-text",children:[a.jsx("span",{className:"ap-nav-name",children:"Other accounts"}),a.jsx("span",{className:"ap-nav-state","data-tone":_.tone,children:_.text})]}),a.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:a.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),g&&a.jsx(GY,{anchorId:"ap-rest-entry",id:"ap-rest-peek",peers:e,onHold:j,onLet:x}),s&&a.jsx(YY,{order:l,choices:c,onOrder:d,allOpen:h,onToggleAll:f,held:p})]})}function YY({order:e,choices:t,onOrder:n,allOpen:r,onToggleAll:s,held:o}){var d;const l=y.useRef(null);y.useLayoutEffect(()=>{const h=l.current,f=h==null?void 0:h.parentElement;if(!h||!f)return;const p=()=>f.style.setProperty("--rest-tools-w",`${Math.ceil(h.offsetWidth)}px`);if(p(),typeof ResizeObserver>"u")return;const g=new ResizeObserver(p);return g.observe(h),()=>{g.disconnect(),f.style.removeProperty("--rest-tools-w")}},[]);const c=((d=t.find(h=>h.id===e))==null?void 0:d.label)??"Slot";return a.jsxs("div",{className:"ap-rest-tools",ref:l,children:[a.jsxs("span",{className:"ap-rest-sort",children:[a.jsx("select",{value:e,onChange:h=>n(h.target.value),"aria-label":"Order of the other accounts",title:o?`${c} — held where it was while you are in the list`:c,"data-sorted":e===uh?void 0:"","data-held":o?"":void 0,children:t.map(h=>a.jsx("option",{value:h.id,children:h.label},h.id))}),a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M2.5 3.8 5 6.3l2.5-2.5"})})]}),a.jsx("button",{type:"button",className:"ap-rest-all","aria-label":"Expand every account","aria-pressed":r,"aria-controls":"ap-rest-list",title:r?"Collapse every account":"Expand every account",onClick:s,children:a.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:a.jsx("path",{d:r?"M2 7h10M7 1.5V5M5.2 3.2 7 5l1.8-1.8M7 12.5V9M5.2 10.8 7 9l1.8 1.8":"M2 7h10M7 1.5V5M5.2 3.3 7 1.5l1.8 1.8M7 12.5V9M5.2 10.7 7 12.5l1.8-1.8"})})})]})}async function XY(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const ZY=1800;function JY({accounts:e,onClose:t,copyText:n}){qt("share-accounts");const[r,s]=y.useState([]),[o,l]=y.useState(null),[c,d]=y.useState(!1),[h,f]=y.useState(null),[p,g]=y.useState(!1),[v,N]=y.useState(()=>Math.floor(Date.now()/1e3)),k=y.useRef(null),x=y.useRef(!1),j=ut(t,{focusRef:k}),b=gt(t),_=is(o!=null,k),E=is(o==null,k);y.useEffect(()=>{if(!o)return;N(Math.floor(Date.now()/1e3));const P=window.setInterval(()=>N(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(P)},[o]);const R=JV(e),T=QV(e,r),A=T.length===e.length,U=P=>s(G=>eG(G,P)),L=y.useCallback(async()=>{const P=tG(T);if(!lr(x.current)||!P)return;x.current=!0,d(!0),f(null),g(!1);const G=await XY(P).catch(()=>null);if(x.current=!1,d(!1),!(G!=null&&G.ok)){f(Jo(G,"the share could not be made"));return}l({blob:G.blob,expiresAt:G.expiresAt,shared:G.shared??[],failed:G.failed??[]})},[e,T]),F=o?AI(o.expiresAt,v):null,O=(F==null?void 0:F.tone)==="gone",I=(o==null?void 0:o.shared.length)??0,B=O?"This share has expired":I===1?"1 account, ready to paste":`${I} accounts, ready to paste`,M=I===1?"this is the password":`this is ${I} passwords`,$=o?O?B:`${B} — ${M}`:"";return Lt.createPortal(a.jsx("div",{className:"modal-backdrop",...b,role:"presentation",children:a.jsxs("div",{ref:j,className:"modal sa-modal",onClick:P=>P.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Share accounts with another deck",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("h3",{children:"Share accounts"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body sa-body",children:[a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:$}),o?a.jsxs("div",{className:"sa-step",children:[a.jsx("h4",{children:B}),a.jsx("code",{className:"ap-share-blob",children:o.blob}),a.jsxs("div",{className:"ap-share-foot",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",ref:k,onClick:async()=>{if(O){E(),_(),l(null),L();return}await n(o.blob)&&(g(!0),window.setTimeout(()=>g(!1),ZY))},children:O?"make a new share":p?"copied":`copy ${I===1?"the share":"all "+I}`}),a.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:[a.jsx("span",{className:"ap-share-warn",children:M})," · ",a.jsx("span",{className:`ap-share-expiry ${F==null?void 0:F.tone}`,children:F==null?void 0:F.text})]})]}),o.failed.length>0&&a.jsxs("div",{className:"sa-failed",role:"alert",children:[a.jsx("p",{className:"sa-failed-head",children:o.failed.length===1?"One account is not in this bundle:":`${o.failed.length} accounts are not in this bundle:`}),a.jsx("ul",{className:"sa-list",children:o.failed.map(P=>{var K;const G=!!(P.email&&((K=P.detail)!=null&&K.includes(P.email)));return a.jsxs("li",{children:[!G&&a.jsx("span",{className:"sa-who",children:P.email||`account ${P.num}`}),a.jsx("span",{className:"sa-why",children:P.detail||"could not be exported"})]},`${P.num}-${P.email}`)})})]}),a.jsx("p",{className:"sa-note",children:O?a.jsx(a.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):a.jsxs(a.Fragment,{children:["Paste it into the other deck with ",a.jsx("strong",{children:"+"})," → ",a.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),a.jsxs("div",{className:"sa-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>{E(),l(null),g(!1)},children:"Pick again"}),a.jsx("button",{type:"button",className:"btn primary",onClick:t,children:"Done"})]})]}):e.length===0?a.jsxs("div",{className:"sa-step",children:[a.jsx("h4",{children:"Nothing to share"}),a.jsxs("p",{className:"sa-note",children:["This deck is not holding any accounts right now. Sign one in with ",a.jsx("strong",{children:"+"}),", or wait — the panel is still reading the store."]}),a.jsx("div",{className:"sa-actions",children:a.jsx("button",{type:"button",className:"btn primary",ref:k,onClick:t,children:"Close"})})]}):a.jsxs("div",{className:"sa-step",children:[a.jsxs("h4",{children:["Which accounts go to the other ",kt,"?"]}),a.jsx("p",{className:`sa-count${T.length?"":" empty"}`,children:nG(T.length)}),a.jsx("ul",{className:"sa-list sa-pick",children:R.map(P=>a.jsx("li",{children:a.jsxs("label",{className:"sa-row",children:[a.jsx("input",{type:"checkbox",checked:T.includes(P.num),onChange:()=>U(P.num)}),a.jsx("span",{className:"sa-who",children:P.label}),P.sub&&a.jsx("span",{className:"sa-sub",children:P.sub})]})},P.num))}),h&&a.jsx("p",{className:"aa-err",role:"alert",children:h}),a.jsxs("div",{className:"sa-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>s(A?e.map(P=>P.num):[]),children:A?"Clear all":"Select all"}),a.jsx("button",{type:"button",className:"btn primary",ref:k,...Dr(c,!T.length),onClick:()=>{_(),L()},children:c?"making the share…":T.length===0?"Share":T.length===1?"Share 1 account":`Share ${T.length} accounts`})]})]})]})]})}),document.body)}function nO(e,t){var n;return!e.disabled&&!((n=wi(e,t))!=null&&n.blocksSwitch)}function QY(e,t,n){return e.map(r=>{const s=wi(r,t,n==null?void 0:n(r));return{key:Lr(r),name:r.alias??r.email??`account ${r.num}`,ready:nO(r,t),why:r.disabled?"held out":s!=null&&s.blocksSwitch?s.text:null,warn:(s==null?void 0:s.tone)==="warn",headroom:m0(r,t)}})}function eX(e,t,n){const r=Number(t),s=e&&(n==null?e.headroom:m0(e,n));return s!=null&&Number.isFinite(r)&&100-s>=r}function tX(e){return(e==null?void 0:e.ok)===!0&&(e.enabled||e.external)}const rO="agent-dag.otherAccountsOrder",sO="agent-dag.otherAccountsOpen";function nX(){const e=Qe(rO);return typeof e=="string"&&e.length>0&&e.length<=64?e:uh}function rX(e){Ze(rO,e)}function sX(){const e=Qe(sO);if(!e)return Yx;try{const t=JSON.parse(e);if(((t==null?void 0:t.mode)==="some"||(t==null?void 0:t.mode)==="all")&&Array.isArray(t.keys)&&t.keys.every(n=>typeof n=="string"))return{mode:t.mode,keys:t.keys.slice(0,200)}}catch{}return Yx}function aX(e){Ze(sO,JSON.stringify({mode:e.mode,keys:e.keys.filter(t=>!t.startsWith("slot:"))}))}function oX(){const[e,t]=y.useState(null),n=y.useRef(null),r=y.useCallback(l=>oh(n.current)?(n.current=l,t(l),!0):!1,[]),s=y.useCallback(()=>{n.current=null,t(null)},[]);return{busy:e,claim:r,release:s,pressProps:(l,c=!1)=>{const d=ia(e,l);return{disabled:d.disabled,"aria-busy":d.busy||c}}}}const iX=8e3,lX=1800,cX=4e3;function uX({claim:e,release:t,load:n,clearFailure:r,rescueFocus:s}){const[o,l]=y.useState(null),c=(o==null?void 0:o.num)??null,d=y.useRef(o);d.current=o;const[h,f]=y.useState(null),[p,g]=y.useState(""),[v,N]=y.useState(null),k=y.useRef(0);y.useEffect(()=>{if(v==null)return;const J=window.setTimeout(()=>N(null),cX);return()=>window.clearTimeout(J)},[v]);const[x,j]=y.useState(null),[b,_]=y.useState(!1),[E,R]=y.useState(null),[T,A]=y.useState(null),U=y.useCallback(async(J,V)=>{if(!e(V))return null;r(),f(null);try{const X=await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(J)}),Y=await X.json().catch(()=>null);return Y!=null&&Y.ok||f({text:Jo(Y,"command failed",X.status)}),Y}catch{return f({text:"server unreachable"}),null}finally{t()}},[e,t,r]),L=y.useCallback(()=>{l(null),f(null),N(null),j(null),_(!1)},[]),F=(J,V="first")=>{L(),A(null),l({num:J,view:"menu",start:V})},O=y.useCallback(J=>{var Y,Z;const V=d.current;if(!V||J!=null&&V.num!==J)return;const X=document.getElementById(`ap-menu-${V.num}`);(X!=null&&X.contains(document.activeElement)||Cn(((Y=document.activeElement)==null?void 0:Y.tagName)??null))&&((Z=document.getElementById(`ap-more-${V.num}`))==null||Z.focus()),L()},[L]),I=y.useCallback(J=>f(J),[]),B=(J,V)=>{g(V??""),f(null),l({num:J,view:"rename"})},M=J=>g(J),$=J=>{A(null),f(null),l({num:J,view:"move"})},P=J=>A(J),G=async J=>{var X;_(!1);const V=await U({action:"share",account:J},`share-${J}`);!(V!=null&&V.ok)||((X=d.current)==null?void 0:X.num)!==J||(j({num:J,blob:V.blob,expiresAt:V.expiresAt}),l({num:J,view:"share"}))},K=async J=>{await eo(J)&&(_(!0),window.setTimeout(()=>_(!1),lX))},q=async(J,V)=>{const{commit:X,alias:Y}=uG(p,V);if(X){const Z=await U({action:"alias",account:J,alias:Y},`alias-${J}`);if(await n(!0),!(Z!=null&&Z.ok))return}O(J)},H=async(J,V)=>{var Z,ee,ne;const X=await U({action:"move",account:J,slot:V},`move-${J}`),Y=lG({menuFor:((Z=d.current)==null?void 0:Z.num)??null,shareFor:(x==null?void 0:x.num)??null},J,X);if(await n(!0),Y){if(Y.menuFor!=null){const pe=document.getElementById(`ap-menu-${J}`),ke=document.getElementById(`ap-more-${Y.menuFor}`);ke&&(pe!=null&&pe.contains(document.activeElement)||Cn(((ee=document.activeElement)==null?void 0:ee.tagName)??null))&&ke.focus()}((ne=d.current)==null?void 0:ne.num)===J&&L(),N(Y.confirmRemove),Y.shareFor==null&&(j(null),_(!1)),R(Y.swapNote);const se=Y.swapNote;se&&window.setTimeout(()=>R(pe=>pe===se?null:pe),iX),A(null),s(Y.menuFor)}return X};return{menu:o,menuFor:c,menuError:h,aliasDraft:p,confirmRemove:v,share:x,shareCopied:b,slotDraft:T,swapNote:E,showMenu:F,dropMenu:L,closeMenu:O,sayInMenu:I,startRename:B,typeAlias:M,doAlias:q,startMove:$,pickSlot:P,doSlot:async(J,V,X)=>{if(!X.sends){O(J);return}await H(J,V)},makeShare:G,copyShare:K,pressRemove:J=>{const V=Date.now(),X=Kl({armedFor:v,target:J,armedAt:k.current,now:V,gapMs:Gl});if(X==="arm"){N(J),k.current=V;return}X!=="ignore"&&(N(null),U({action:"remove",account:J},`rm-${J}`).then(Y=>{var Z;n(!0),Y!=null&&Y.ok&&(((Z=d.current)==null?void 0:Z.num)===J&&L(),s(null))}))}}}function dX(e,t){return!e||!t||t.some(n=>n.num===e.num&&n.active)?e:null}function hX({data:e,claim:t,release:n,load:r,sayFailure:s,clearFailure:o,sayInMenu:l,rescueFocus:c}){const[d,h]=y.useState(null),f=y.useCallback(async(g,v,N="panel")=>{if(!t(v))return null;const k=N==="menu"?l:s;k(null);try{const x=await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),j=await x.json().catch(()=>null);return j!=null&&j.ok||k({text:Xx(j,"command failed",x.status),raw:Jl(j)}),j}catch{return k({text:"server unreachable"}),null}finally{n()}},[t,n,l,s]);return y.useEffect(()=>{!(e!=null&&e.ok)||!e.accounts||h(g=>dX(g,e.accounts))},[e]),{switched:d,post:f,doSwitch:async(g,v)=>{if(t(`switch-${g}`)){o(),h(null);try{const k=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:g})})).json().catch(()=>null);k!=null&&k.ok?h({num:g,name:v}):s({text:Xx(k,"the switch failed"),raw:Jl(k),row:g}),await r(!0)}catch{s({text:"server unreachable",row:g})}finally{n(),c(g)}}}}}const fX=1800;function pX({auto:e,post:t,load:n}){var N;const[r,s]=y.useState(null),[o,l]=y.useState(!1),c=y.useRef(null),d=y.useRef(null),h=((N=e==null?void 0:e.settings["autoswitch.threshold"])==null?void 0:N.value)??"90",f=r??h,p=fG(f,h);return{threshold:h,thresholdPick:f,thresholdCtl:p,thresholdSaved:o,thresholdRef:c,thresholdSaveRef:d,proposeThreshold:k=>s(k),doThreshold:async(k,x)=>{if(x.sends){const j=await t({action:"setting",key:"autoswitch.threshold",value:k},"threshold");if(await n(!0),!(j!=null&&j.ok))return;s(null)}l(!0),window.setTimeout(()=>{var j;document.activeElement===d.current&&((j=c.current)==null||j.focus()),l(!1)},fX)}}}const mX=Object.freeze({text:"couldn't reach the deck server",reload:!0}),gX=Object.freeze({text:"still waiting on the deck server — claude-swap can be slow to answer",reload:!0});async function e_(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function yX(e){const t=e.find(r=>!r.ok);if(!t)return null;const n=Jl(t.body);return{text:Xx(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function t_(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 aO=15e3,wX=3e4;function vX(e){const[t,n]=y.useState(null),[r,s]=y.useState(null),[o,l]=y.useState(!1),[c,d]=y.useState(null),h=y.useRef(null),f=y.useCallback(async(v=!1)=>{v&&l(!0);const N=new AbortController,k=window.setTimeout(()=>N.abort(),wX);try{const[x,j]=await Promise.all([fetch(`/api/claude-accounts${v?"?refresh=1":""}`,{signal:N.signal}),fetch("/api/cswap-auto",{signal:N.signal})]);if(x.ok){const _=await x.json();n(_),e(_)}j.ok&&s(await j.json());const b=yX([await e_(x),await e_(j)]);d(_=>t_(_,b))}catch{d(x=>t_(x,N.signal.aborted?gX:mX))}finally{window.clearTimeout(k),v&&l(!1)}},[e]);y.useEffect(()=>(f(!0),h.current=window.setInterval(()=>f(!1),aO),()=>{h.current!=null&&window.clearInterval(h.current)}),[f]);const p=y.useCallback(v=>d(v),[]),g=y.useCallback(()=>d(null),[]);return{data:t,auto:r,reloading:o,failure:c,load:f,sayFailure:p,clearFailure:g}}const xX="#ap-rest-entry";function bX(e){return[`#${e}`,xX,...tI(null)]}function kX(e){const t=y.useRef(null),n=s=>{t.current=s.target.id||null},r=s=>{s.target.isConnected&&(t.current=null)};return y.useLayoutEffect(()=>{var o;const s=t.current;if(!(!s||!Cn(((o=document.activeElement)==null?void 0:o.tagName)??null)))for(const l of bX(s)){const c=document.querySelector(l);if(c){c.focus();return}}},[e]),{onFocus:n,onBlur:r}}function NX({onClose:e,leaving:t,onReport:n,onRoster:r}){var Gt,bs,Vr;qt("accounts-panel");const{busy:s,claim:o,release:l,pressProps:c}=oX(),[d,h]=y.useState("accounts"),[f,p]=y.useState(!1),[g,v]=y.useState(null),N=y.useRef(g);N.current=g;const[k,x]=y.useState(!1),[j,b]=y.useState(!1),[_,E]=y.useState([]),[R,T]=y.useState(!1),[A,U]=y.useState(null),[L,F]=y.useState(sX),[O,I]=y.useState(nX),[B,M]=y.useState(null),[$,P]=y.useState(!1),G=y.useRef(r);G.current=r;const K=y.useCallback(ye=>{var Fe;F(Ge=>eV(Ge,ye.accounts)),(Fe=G.current)==null||Fe.call(G,ye)},[]),{data:q,auto:H,reloading:D,failure:W,load:J,sayFailure:V,clearFailure:X}=vX(K),Y=kX(q),Z=y.useCallback(ye=>{window.requestAnimationFrame(()=>{var Fe;if(Cn(((Fe=document.activeElement)==null?void 0:Fe.tagName)??null))for(const Ge of tI(ye)){const rn=document.querySelector(Ge);if(rn){rn.focus();return}}})},[]),ee=uX({claim:o,release:l,load:J,clearFailure:X,rescueFocus:Z}),{menu:ne,menuFor:se,swapNote:pe,showMenu:ke,dropMenu:ae,closeMenu:fe,sayInMenu:me}=ee,{switched:he,post:ge,doSwitch:ue}=hX({data:q,claim:o,release:l,load:J,sayFailure:V,clearFailure:X,sayInMenu:me,rescueFocus:Z}),{threshold:be,thresholdPick:oe,thresholdCtl:je,thresholdSaved:$e,thresholdRef:Oe,thresholdSaveRef:Ue,proposeThreshold:Be,doThreshold:We}=pX({auto:H,post:ge,load:J}),He=lI();y.useEffect(()=>{aX(L)},[L]),y.useEffect(()=>{rX(O)},[O]);const[rt,lt]=y.useState(()=>new Set),Rt=y.useCallback(ye=>lt(new Set(ye)),[]),De=ye=>({noCopyWorksNearby:rt.has($S([ye])[0].key)}),et=(Gt=q==null?void 0:q.accounts)==null?void 0:Gt.find(ye=>ye.active),Je=et?wi(et,He,De(et)):null,tt=(q==null?void 0:q.accounts)??[],yt=et?tt.filter(ye=>!ye.active):[],Pt=xI(yt),wt=X9(O,yt),st=Kx(Y9(yt,wt,ye=>nO(ye,He),He),B),zt=y.useRef(!1),Wt=y.useRef(!1),Dt=y.useRef(!1),Ht=y.useCallback(()=>{!zt.current&&!Wt.current&&!Dt.current&&M(null)},[]),Vt=()=>M(ye=>ye??st.map(Lr)),vs={onPointerEnter:()=>{zt.current=!0,Vt()},onPointerLeave:()=>{zt.current=!1,Ht()},onFocus:ye=>{ye.target.matches(":focus-visible")&&(Wt.current=!0,Vt())},onBlur:ye=>{ye.currentTarget.contains(ye.relatedTarget)||(Wt.current=!1,Ht())}},Tn=se!=null&&yt.some(ye=>ye.num===se)||g!=null&&yt.some(ye=>ye.num===g.num);y.useEffect(()=>{Dt.current=Tn,Tn||Ht()},[Tn,Ht]);const mr=$&&yt.length>0;y.useEffect(()=>{mr||(zt.current=Wt.current=Dt.current=!1,M(null))},[mr]);const zr=y.useRef(!1);y.useEffect(()=>{zr.current&&yt.length===0&&Z(null),zr.current=yt.length>0},[yt.length,Z]);const gr=st.length?tt.filter(ye=>ye.active):tt,Wr=QY(st,He,De),mn=eX(et,be,He),Hr=tX(H),An=ye=>$&&st.some(Fe=>Fe.num===ye)?"ap-rest-list":"ap-scroll",da=(ye,Fe="first")=>{ke(ye,Fe),v(null)},gn=(ye,Fe)=>{ae(),v(Ge=>(Ge==null?void 0:Ge.anchor)===Fe?null:{num:ye,anchor:Fe})},yr=y.useCallback((ye=!1)=>{var Ge;const Fe=N.current;ye&&Fe&&((Ge=document.getElementById(Fe.anchor))==null||Ge.focus()),v(null)},[]),wr=()=>{ae(),v(null),h("lan")},xt=y.useRef(d);y.useEffect(()=>{xt.current!==d&&(xt.current=d,window.requestAnimationFrame(()=>{var ye;(ye=document.getElementById(d==="lan"?"ap-lan-back":"ap-lan-entry"))==null||ye.focus()}))},[d]),y.useEffect(()=>{q!=null&&q.ok&&p(!0)},[q==null?void 0:q.ok]),y.useEffect(()=>{t&&(ae(),v(null))},[t,ae]),y.useEffect(()=>{ne&&(q!=null&&q.accounts)&&!q.accounts.some(ye=>ye.num===ne.num)&&ae(),g&&(q!=null&&q.accounts)&&!q.accounts.some(ye=>ye.num===g.num)&&v(null)},[q,ne,g,ae]),y.useEffect(()=>{A==null||!(q!=null&&q.accounts)||q.accounts.some(ye=>ye.num===A.num)||(U(null),Z(null))},[q,A,Z]);const xs=a.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:a.jsx("path",{d:"M3.4 3.4l7.2 7.2M10.6 3.4l-7.2 7.2"})})}),vr=ye=>{const Fe=bI(L,ye),Ge=se===ye.num,rn=(W==null?void 0:W.row)===ye.num?W:null,Gr=(he==null?void 0:he.num)===ye.num,br=(pe==null?void 0:pe.at)===ye.num?pe:null,ha=br?tt.find(Kr=>Kr.num===br.displaced):void 0,Ke=(g==null?void 0:g.anchor)===`ap-issue-${ye.num}`;return a.jsx(rV,{a:ye,nowSec:He,lan:De(ye),opened:Fe,onToggleLanes:()=>F(Kr=>J9(Kr,ye)),busy:s,pressProps:c,onSwitch:ue,menuOpen:Ge,onOpenMenu:da,onCloseMenu:fe,refusal:rn,onDismissRefusal:()=>X(),switchedHere:Gr,swapped:br,displaced:ha,issueExpanded:Ke,onOpenIssue:gn,sortKey:ye.active?null:K9(wt)},ye.num)},xr=q!=null&&q.ok&&(H!=null&&H.ok)?a.jsx(_V,{auto:H,threshold:be,thresholdPick:oe,thresholdCtl:je,thresholdSaved:$e,thresholdRef:Oe,thresholdSaveRef:Ue,proposeThreshold:Be,doThreshold:We,pressProps:c,post:ge,load:J}):null;return a.jsxs("aside",{className:`accounts-panel${t?" leaving":""}`,id:"accounts-panel","aria-label":"Claude accounts",onFocus:Y.onFocus,onBlur:Y.onBlur,children:[d==="accounts"&&a.jsx(aV,{canShare:(((bs=q==null?void 0:q.accounts)==null?void 0:bs.length)??0)>0,canReport:(((Vr=q==null?void 0:q.accounts)==null?void 0:Vr.length)??0)>1||j,onAdd:()=>x(!0),onReport:()=>{E([...gr,...st].map(Lr)),b(!0)},onShareSet:()=>T(!0),onReload:()=>J(!0),pressProps:c,reloading:D,closeButton:xs}),d==="accounts"&&a.jsx("div",{className:"ap-scroll",id:"ap-scroll",children:q==null?W?a.jsxs("div",{className:"ap-empty",role:"alert",children:[a.jsx("span",{title:W.raw||void 0,children:W.text}),a.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",aO/1e3," seconds."]}),a.jsx("button",{type:"button",className:"ap-fix",...c("reload",D),onClick:()=>J(!0).then(()=>Z(null)),children:D?"trying…":"try again"})]}):a.jsx("div",{className:"ap-empty",children:"Checking…"}):q.ok?a.jsxs(a.Fragment,{children:[et&&(Je==null?void 0:Je.tone)==="warn"&&a.jsxs("div",{className:"ap-notice",children:[a.jsxs("button",{type:"button",id:"ap-notice",className:"ap-issue","data-tone":"warn","aria-haspopup":"dialog","aria-expanded":(g==null?void 0:g.anchor)==="ap-notice","aria-controls":(g==null?void 0:g.anchor)==="ap-notice"?"ap-issue-pop":void 0,onClick:()=>gn(et.num,"ap-notice"),children:[a.jsx(p0,{}),a.jsx("span",{className:"ap-issue-text",children:"Current account needs attention"})]}),Je.fix&&a.jsx("button",{type:"button",className:"ap-notice-fix",onClick:()=>x(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"Sign in"})]}),a.jsx("ul",{className:"ap-list",children:gr.map(vr)}),st.length>0&&a.jsx(KY,{peers:Wr,strained:mn,armed:Hr,threshold:H!=null&&H.ok?be:null,open:$,onToggle:()=>P(ye=>!ye),order:wt,choices:Pt,onOrder:I,allOpen:kI(L,st),onToggleAll:()=>F(ye=>Q9(ye,st)),held:B!=null}),st.length>0&&$&&a.jsxs("div",{className:"ap-rest-panel",id:"ap-rest-panel",children:[a.jsx("ul",{className:"ap-list ap-others",id:"ap-rest-list",...vs,children:st.map(vr)}),xr]}),st.length===0&&xr,W&&W.row==null&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",title:W.raw||void 0,children:W.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>X(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),ne&&(()=>{var Fe;const ye=(Fe=q.accounts)==null?void 0:Fe.find(Ge=>Ge.num===ne.num);return ye?a.jsx(pG,{a:ye,accountMenu:ee,slots:(q.accounts??[]).map(Ge=>Ge.num),boundaryId:An(ye.num),nowSec:He,busy:s,pressProps:c,rotating:!!(H!=null&&H.enabled||H!=null&&H.external),onProjects:()=>{U({num:ye.num,name:ye.alias??ye.email??`account ${ye.num}`}),fe(ye.num)},onRotation:()=>ge({action:"account",account:ye.num,enabled:ye.disabled},`rot-${ye.num}`,"menu").then(Ge=>{J(!0),Ge!=null&&Ge.ok&&fe(ye.num)})}):null})(),g&&(()=>{var Ge;const ye=(Ge=q.accounts)==null?void 0:Ge.find(rn=>rn.num===g.num),Fe=ye?wi(ye,He,De(ye)):null;return!ye||!Fe?null:a.jsx(F9,{anchorId:g.anchor,boundaryId:g.anchor==="ap-notice"?"ap-scroll":An(ye.num),issue:Fe,who:ye.alias??ye.email??`account ${ye.num}`,fetchedAt:ye.fetchedAt,nowSec:He,onClose:yr,onSignIn:()=>x(!0),onReport:n&&(()=>n({initialKind:Fe.tone==="warn"?"bug":"other",initialBody:`Account issue: ${Fe.text}. ${Fe.hint}`}))})})()]}):a.jsx(sV,{data:q})}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:he?`Now active: ${he.name}`:""}),f&&a.jsx(VY,{accounts:$S((q==null?void 0:q.accounts)??[]),onChanged:()=>J(!0),onNoCopy:Rt,view:d==="lan",onOpen:wr,onBack:()=>h("accounts"),closeButton:xs}),k&&a.jsx(RI,{onClose:()=>x(!1),onChanged:()=>J(!0)}),R&&a.jsx(JY,{accounts:((q==null?void 0:q.accounts)??[]).map(ye=>({num:ye.num,email:ye.email,alias:ye.alias,org:ye.org})),onClose:()=>T(!1),copyText:eo}),A!=null&&(()=>{var Fe;const ye=(Fe=q==null?void 0:q.accounts)==null?void 0:Fe.find(Ge=>Ge.num===A.num);return q!=null&&q.accounts&&!ye?null:a.jsx(P9,{num:A.num,name:ye?ye.alias??ye.email??`account ${ye.num}`:A.name,onClose:()=>U(null)})})(),j&&a.jsx(jV,{accounts:(q==null?void 0:q.accounts)??null,order:_,failed:W!=null&&W.reload?W.text:null,nowSec:He,onClose:()=>b(!1)})]})}const jX=16,SX=120;function _X(e,t,n=0){return e.clientX>=t.left-n&&e.clientX<=t.right+n&&e.clientY>=t.top-n&&e.clientY<=t.bottom+n}function EX(e,t){const n=Math.max(t.left-e.clientX,0,e.clientX-t.right),r=Math.max(t.top-e.clientY,0,e.clientY-t.bottom);return Math.hypot(n,r)}function CX(e,t){return _X(e,t,jX)?"over":EX(e,t)<=SX?"near":"far"}function TX(e){var n,r;if(typeof e.clientX=="number"&&typeof e.clientY=="number")return{clientX:e.clientX,clientY:e.clientY};const t=((n=e.changedTouches)==null?void 0:n[0])??((r=e.touches)==null?void 0:r[0]);return t?{clientX:t.clientX,clientY:t.clientY}:null}function AX(){const[e,t]=y.useState(!1),[n,r]=y.useState(""),[s,o]=y.useState("far"),l=y.useRef(null),c=Qu(e,140),d=y.useCallback(g=>{var k;const v=(k=l.current)==null?void 0:k.getBoundingClientRect(),N=TX(g);return v&&N?CX(N,v):"far"},[]),h=y.useCallback(g=>{g!==null&&(r(g),t(!0)),o("far")},[]),f=y.useCallback(g=>{o(d(g))},[d]),p=y.useCallback((g,v)=>{const N=v&&d(g)==="over";return t(!1),N},[d]);return{trashDragging:e,trashLabel:n,trashState:s,trashZoneRef:l,trashPhase:c,beginTrashDrag:h,trackTrashDrag:f,endTrashDrag:p}}const RX=420;function MX(){const[e,t]=y.useState(!1),n=y.useRef(null),r=y.useCallback(()=>{n.current&&(window.clearTimeout(n.current),n.current=null),t(!1)},[]),s=y.useCallback(o=>{o.length!==0&&queueMicrotask(()=>{t(!0),n.current&&window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),RX+80)})},[]);return y.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{bubbling:e,endBubble:r,onBubble:s}}const S0=11,oO=7.2,iO=6.6,$X={width:104,height:48},n_={width:96,height:44},lO={width:220,height:103};function IX(e){let t=1/0,n=1/0;for(const r of e)!(r.width>0)||!(r.height>0)||(t=Math.min(t,r.width),n=Math.min(n,r.height));return!Number.isFinite(t)||!Number.isFinite(n)?lO:{width:Math.max(160,t),height:Math.max(72,n)}}function Up(e,t,n){return e.width*t>=n.width&&e.height*t>=n.height}function OX(e,t,n=lO){if(!Number.isFinite(t)||t<=0)return e??"detail";const r=S0*t;return e==="detail"?r>=iO?"detail":Up(n,t,n_)?"compact":"overview":r>=oO?"detail":e==="compact"?Up(n,t,n_)?"compact":"overview":Up(n,t,$X)?"compact":"overview"}const LX=oO/S0,PX=iO/S0;function DX(e,t){return e>=LX?e:Math.max(e,Math.min(t,PX-.001))}const FX=.8,BX=1;function qX({stateRef:e,measuredRef:t,measuredVersionRef:n,canvasRef:r}){const[s,o]=y.useState("detail"),l=y.useRef(null),c=y.useRef(null),d=y.useCallback(()=>{var v;const f=n.current;if(((v=c.current)==null?void 0:v.version)===f)return c.current.card;const p=[];for(const N of e.current.agents.keys()){const k=t.current.get(N);k&&p.push(k)}const g=IX(p);return c.current={version:f,card:g},g},[]),h=y.useCallback(f=>{var g;const p=OX(l.current,f,d());return p===l.current?null:(l.current=p,(g=r.current)==null||g.setAttribute("data-lod",p),o(p),p)},[d,r]);return{lod:s,lodRef:l,applyZoom:h}}const UX=40,zX=120;function WX(e,t){let n=null,r=0,s=Number.NEGATIVE_INFINITY;const o=()=>{n=null,s=t.now(),e()},l=()=>{n!=null&&(t.clearTimeout(n),n=null)},c=(d,h,f)=>{if(n!=null){if(r<=d)return;l()}const p=Math.min(f,Math.max(0,d-h));r=d,n=t.setTimeout(o,p)};return{live(d=UX){const h=t.now(),f=Math.max(s+d,h);if(f<=h){l(),o();return}c(f,h,d)},replay(d=zX){l(),r=t.now()+d,n=t.setTimeout(o,d)},flush(){l(),o()},cancel(){l()}}}const HX=1024*1024,r_=5,cO=.8,ib=24,VX="agent-dag.soundCustom.done",GX="agent-dag.soundCustom.needs-input",Il={done:VX,"needs-input":GX};function ec(e){if(e.kind!=="audio")return e;const{bytes:t,...n}=e;return n}function s_(e){return!e||!/^[a-zA-Z0-9._-]{1,96}$/.test(e)?null:e}function KX(e){return{done:s_(e(Il.done)),"needs-input":s_(e(Il["needs-input"]))}}function YX(e,t){return{done:e.done===t?null:e.done,"needs-input":e["needs-input"]===t?null:e["needs-input"]}}function XX(e){return e.done&&e.done===e["needs-input"]?e.done:null}const ZX={wav:"audio/wav",wave:"audio/wav",mp3:"audio/mpeg",ogg:"audio/ogg",oga:"audio/ogg",webm:"audio/webm",m4a:"audio/mp4",mp4:"audio/mp4"},uO=new Set(["audio/wav","audio/x-wav","audio/mpeg","audio/mp3","audio/ogg","audio/webm","audio/mp4"]);function dO(e,t){const n=t.toLowerCase().split(";")[0].trim();if(uO.has(n))return n;const r=e.toLowerCase().split(".").pop()??"";return ZX[r]??n}function a_(e,t){const n=dO(e.name,e.type);if(!uO.has(n))return"Use a WAV, MP3, OGG, or browser-recorded audio file.";if(!Number.isFinite(e.size)||e.size<=0)return"The audio file is empty.";if(e.size>HX)return"Audio must be 1 MB or smaller.";if(t!==void 0){if(!Number.isFinite(t)||t<=0)return"The audio file could not be decoded.";if(t>r_)return`Audio must be ${r_} seconds or shorter.`}return null}function lb(e){return e>=ib?`There are already ${ib} custom sounds. Delete one first.`:null}function JX(e,t){const n=e.indexOf(t);return n<0?null:e[n+1]??e[n-1]??null}function QX(e){let t=0;for(const n of e)for(let r=0;r<n.length;r++)t=Math.max(t,Math.abs(n[r]));return t<=1e-5?1:Math.min(16,cO/t)}function hO(){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)}`}async function eZ(e,t,n=hO()){var h;const r=((h=e.name)==null?void 0:h.trim())||"Custom sound",s=a_({name:r,type:e.type,size:e.size});if(s)throw new Error(s);const o=await e.arrayBuffer();let l;try{l=await t(o.slice(0))}catch{throw new Error("The audio file could not be decoded.")}const c=a_({name:r,type:e.type,size:e.size},l.duration);if(c)throw new Error(c);const d=Array.from({length:l.numberOfChannels},(f,p)=>l.getChannelData(p));return{id:n,name:r.replace(/\.(wav|wave|mp3|ogg|oga|webm|m4a|mp4)$/i,"")||"Custom sound",kind:"audio",mime:dO(r,e.type),duration:l.duration,normalizationGain:QX(d),bytes:o}}function tZ(e,t=hO()){const n=e.name.trim()||"Custom voice",r=e.text.trim();if(!r)throw new Error("Enter the words this voice should say.");const s=Number.isFinite(e.rate)?e.rate:1,o=Number.isFinite(e.pitch)?e.pitch:1;return{id:t,name:n,kind:"tts",text:r.slice(0,180),voiceURI:e.voiceURI??"",rate:Math.min(2,Math.max(.5,s)),pitch:Math.min(2,Math.max(.5,o))}}const nZ="ccdeck-notification-audio",rZ=2,dr="assets",Br="summaries";function hc(){return typeof window<"u"?window.ccdeckNotificationAudio??null:null}function sZ(){return new Promise((e,t)=>{const n=indexedDB.open(nZ,rZ);n.onupgradeneeded=r=>{const s=n.result,o=s.objectStoreNames.contains(dr)?n.transaction.objectStore(dr):s.createObjectStore(dr,{keyPath:"id"});if(s.objectStoreNames.contains(Br))return;const l=s.createObjectStore(Br,{keyPath:"id"});if(r.oldVersion<1)return;const c=o.openCursor();c.onsuccess=()=>{const d=c.result;d&&(l.put(ec(d.value)),d.continue())}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??new Error("Could not open local audio storage."))})}async function fc(e,t,n){const r=await sZ();try{return await new Promise((s,o)=>{const l=r.transaction(e,t),c=n(l),d=()=>o(l.error??new Error("Local audio storage failed."));l.oncomplete=()=>s(c?c.result:void 0),l.onerror=d,l.onabort=d})}finally{r.close()}}async function aZ(){const e=hc();return e?e.list():typeof indexedDB>"u"?[]:await fc([Br],"readonly",t=>t.objectStore(Br).getAll())??[]}async function oZ(e){const t=hc();return t?t.get(e):typeof indexedDB>"u"?null:await fc([dr],"readonly",n=>n.objectStore(dr).get(e))??null}async function o_(e){const t=hc();if(t){await t.put(e);return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await fc([dr,Br],"readwrite",n=>{n.objectStore(dr).put(e),n.objectStore(Br).put(ec(e))})}async function iZ(e,t){const n=hc();if(n){const r=await n.get(e);r&&await n.put({...r,name:t});return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await fc([dr,Br],"readwrite",r=>{const s=r.objectStore(dr),o=s.get(e);o.onsuccess=()=>{const l=o.result;if(!l)return;const c={...l,name:t};s.put(c),r.objectStore(Br).put(ec(c))}})}async function lZ(e){const t=hc();if(t){await t.remove(e);return}typeof indexedDB>"u"||await fc([dr,Br],"readwrite",n=>{n.objectStore(dr).delete(e),n.objectStore(Br).delete(e)})}const rd=["done","needs-input"],cZ=[{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}]}],uZ=[{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}]}],_0={done:cZ,"needs-input":uZ},jn="two";function cb(e,t){const n=_0[e];return n.find(r=>r.id===t)??n.find(r=>r.id===jn)??n[0]}function fO(e,t){return _0[e].some(r=>r.id===t)?t:jn}cb("done",jn).notes,cb("needs-input",jn).notes;const i_=.04,pO=.24,sd=0,Rd=100,ub=5,Qa=50;function vi(e){if(!Number.isFinite(e))return Qa;const t=Math.round(e/ub)*ub;return Math.min(Rd,Math.max(sd,t))}function mO(e){if(e==null)return Qa;const t=e.trim();return/^-?\d+(\.\d+)?$/.test(t)?vi(Number(t)):Qa}function E0(e){const t=vi(e),n=i_+(pO-i_)*(t/Rd);return Math.round(n*1e4)/1e4}function dZ(e,t){const n=t.trim,r=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(E0(e)*r*1e4)/1e4}const hZ=.012,l_=1e-4;function fZ(e){return Math.min(1,E0(e)/pO)}function pZ(e,t){const n=e*(E0(t)/cO);return Math.max(1e-4,n)}const mZ=160,gZ="agent-dag.soundLevel.done",yZ="agent-dag.soundLevel.needs-input",wZ="agent-dag.soundFigure.done",vZ="agent-dag.soundFigure.needs-input",gO={done:gZ,"needs-input":yZ},Md={done:wZ,"needs-input":vZ},db={done:{level:Qa,figure:jn},"needs-input":{level:Qa,figure:jn}};function xZ(e){const t=n=>({level:mO(e(gO[n])),figure:fO(n,e(Md[n]))});return{done:t("done"),"needs-input":t("needs-input")}}function bZ(e,t){return(e??db)[t]??db[t]}const kZ={Stop:"done",Notification:"needs-input"};function NZ(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:Ot(kZ,n)??null}const jZ=6,SZ="ccdeck-tabs";function _Z(e){return e>=jZ}function EZ(e,t,n){const r=s=>{const o=s.data;(o==null?void 0:o.kind)==="who"&&o.from!==t&&e.postMessage({kind:"here",from:t,to:o.from,streaming:n()})};return e.addEventListener("message",r),{ask(s,o=(l,c)=>setTimeout(l,c)){return new Promise(l=>{const c=new Set,d=h=>{const f=h.data;(f==null?void 0:f.kind)==="here"&&f.to===t&&f.streaming&&c.add(f.from)};e.addEventListener("message",d),e.postMessage({kind:"who",from:t}),o(()=>{e.removeEventListener("message",d),l(c.size)},s)})},leave(){var s;e.removeEventListener("message",r),(s=e.close)==null||s.call(e)}}}function CZ({stateRef:e,rerender:t,pauseGate:n,chimesRef:r,desktopUpdateRef:s}){const[o,l]=y.useState(!1),[c,d]=y.useState(!1),[h,f]=y.useState(!1),p=y.useRef(!0),[g,v]=y.useState(null);return y.useEffect(()=>{const N=new EventSource("/events"),k=WX(t,{now:()=>Date.now(),setTimeout:(_,E)=>window.setTimeout(_,E),clearTimeout:_=>window.clearTimeout(_)});let x=!1;const j=typeof BroadcastChannel=="function"?EZ(new BroadcastChannel(SZ),Math.random().toString(36).slice(2),()=>x):null,b=window.setInterval(()=>{x||!j||j.ask(600).then(_=>{x||d(_Z(_))})},3e3);return N.addEventListener("open",()=>{l(!0),f(!0)}),N.addEventListener("error",()=>{l(!1),v(null)}),N.addEventListener("open",()=>{x=!0,d(!1)}),N.addEventListener("error",()=>{x=!1}),N.addEventListener("replay-end",()=>{p.current=!1,k.flush(),v(Date.now())}),N.addEventListener("desktop-update",_=>s.current(_.data)),N.addEventListener("hook",_=>{var E;try{const R=JSON.parse(_.data);if(!n.accept(R))return;e.current=l$(e.current,R);const T=R.replay===!0||p.current||Date.now()-R.receivedAt>3e4;T?k.replay():k.live();const A=NZ(R,T);A&&((E=r.current)==null||E.play(A))}catch{}}),()=>{N.close(),k.cancel(),window.clearInterval(b),j==null||j.leave()}},[t]),{live:o,tabCapped:c,everConnected:h,liveSince:g}}const TZ=200,AZ=5*6e4,RZ=6,MZ=2*6e4;function Hu(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function $Z(e,t){let n=!1;for(const s of e)if(!t.has(s)){n=!0;break}if(!n)return e;const r=new Set;for(const s of e)t.has(s)&&r.add(s);return r}function IZ(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(n0(n.id));return t}function OZ(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(n0(n.id));return t}function LZ(e,t){let n=S8(e,t,kj);_8(e,t,kj)&&(n=!0);const r=[],s=o=>{r.push(o)};return k8(e,t,TZ,AZ,s)&&(n=!0),N8(e,t,RZ,MZ,s)&&(n=!0),{changed:n,forgotten:r}}function PZ(e,t,n){if(!n)return{ids:new Set([t]),primary:t};const r=new Set(e.ids);if(!r.has(t))return r.add(t),{ids:r,primary:t};if(r.delete(t),e.primary!==t)return{ids:r,primary:e.primary};let s=null;for(const o of r)s=o;return{ids:r,primary:s}}function DZ(e,t){const[n,r]=y.useState(()=>({ids:new Set,primary:null})),{ids:s,primary:o}=n,l=y.useCallback((h,f,p=!f)=>{r(g=>PZ(g,h,f)),!f&&p&&t(!0)},[]),c=y.useCallback(()=>{r({ids:new Set,primary:null})},[]),d=y.useCallback(()=>{r(h=>{const f=$Z(h.ids,e.current.agents),p=h.primary!=null&&!e.current.agents.has(h.primary)?null:h.primary;return f===h.ids&&p===h.primary?h:{ids:f,primary:p}})},[e]);return{selectedIds:s,primarySelectedId:o,selectAgent:l,clearSelection:c,pruneSelectionToBoard:d}}function FZ({stateRef:e,rerender:t,pruneSelectionToBoard:n,setContextFor:r,setSummaryFor:s}){const[o,l]=y.useState(Date.now());return y.useEffect(()=>{const c=setInterval(()=>{const d=Date.now();l(d);const{changed:h,forgotten:f}=LZ(e.current,d);f.length>0&&fetch("/api/forget",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:f})}).catch(()=>{}),n(),r(p=>p!=null&&!e.current.agents.has(p)?null:p),s(p=>p!=null&&!e.current.agents.has(p)?null:p),h&&t()},250);return()=>clearInterval(c)},[t]),o}function C0(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 zp,c_;function BZ(){if(c_)return zp;c_=1;function e(){this.__data__=[],this.size=0}return zp=e,zp}var Wp,u_;function Ei(){if(u_)return Wp;u_=1;function e(t,n){return t===n||t!==t&&n!==n}return Wp=e,Wp}var Hp,d_;function mh(){if(d_)return Hp;d_=1;var e=Ei();function t(n,r){for(var s=n.length;s--;)if(e(n[s][0],r))return s;return-1}return Hp=t,Hp}var Vp,h_;function qZ(){if(h_)return Vp;h_=1;var e=mh(),t=Array.prototype,n=t.splice;function r(s){var o=this.__data__,l=e(o,s);if(l<0)return!1;var c=o.length-1;return l==c?o.pop():n.call(o,l,1),--this.size,!0}return Vp=r,Vp}var Gp,f_;function UZ(){if(f_)return Gp;f_=1;var e=mh();function t(n){var r=this.__data__,s=e(r,n);return s<0?void 0:r[s][1]}return Gp=t,Gp}var Kp,p_;function zZ(){if(p_)return Kp;p_=1;var e=mh();function t(n){return e(this.__data__,n)>-1}return Kp=t,Kp}var Yp,m_;function WZ(){if(m_)return Yp;m_=1;var e=mh();function t(n,r){var s=this.__data__,o=e(s,n);return o<0?(++this.size,s.push([n,r])):s[o][1]=r,this}return Yp=t,Yp}var Xp,g_;function gh(){if(g_)return Xp;g_=1;var e=BZ(),t=qZ(),n=UZ(),r=zZ(),s=WZ();function o(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var h=l[c];this.set(h[0],h[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=s,Xp=o,Xp}var Zp,y_;function HZ(){if(y_)return Zp;y_=1;var e=gh();function t(){this.__data__=new e,this.size=0}return Zp=t,Zp}var Jp,w_;function VZ(){if(w_)return Jp;w_=1;function e(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}return Jp=e,Jp}var Qp,v_;function GZ(){if(v_)return Qp;v_=1;function e(t){return this.__data__.get(t)}return Qp=e,Qp}var em,x_;function KZ(){if(x_)return em;x_=1;function e(t){return this.__data__.has(t)}return em=e,em}var tm,b_;function yO(){if(b_)return tm;b_=1;var e=typeof ku=="object"&&ku&&ku.Object===Object&&ku;return tm=e,tm}var nm,k_;function pr(){if(k_)return nm;k_=1;var e=yO(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return nm=n,nm}var rm,N_;function Ci(){if(N_)return rm;N_=1;var e=pr(),t=e.Symbol;return rm=t,rm}var sm,j_;function YZ(){if(j_)return sm;j_=1;var e=Ci(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,s=e?e.toStringTag:void 0;function o(l){var c=n.call(l,s),d=l[s];try{l[s]=void 0;var h=!0}catch{}var f=r.call(l);return h&&(c?l[s]=d:delete l[s]),f}return sm=o,sm}var am,S_;function XZ(){if(S_)return am;S_=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return am=n,am}var om,__;function to(){if(__)return om;__=1;var e=Ci(),t=YZ(),n=XZ(),r="[object Null]",s="[object Undefined]",o=e?e.toStringTag:void 0;function l(c){return c==null?c===void 0?s:r:o&&o in Object(c)?t(c):n(c)}return om=l,om}var im,E_;function Vn(){if(E_)return im;E_=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return im=e,im}var lm,C_;function pc(){if(C_)return lm;C_=1;var e=to(),t=Vn(),n="[object AsyncFunction]",r="[object Function]",s="[object GeneratorFunction]",o="[object Proxy]";function l(c){if(!t(c))return!1;var d=e(c);return d==r||d==s||d==n||d==o}return lm=l,lm}var cm,T_;function ZZ(){if(T_)return cm;T_=1;var e=pr(),t=e["__core-js_shared__"];return cm=t,cm}var um,A_;function JZ(){if(A_)return um;A_=1;var e=ZZ(),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 um=n,um}var dm,R_;function wO(){if(R_)return dm;R_=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 dm=n,dm}var hm,M_;function QZ(){if(M_)return hm;M_=1;var e=pc(),t=JZ(),n=Vn(),r=wO(),s=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,l=Function.prototype,c=Object.prototype,d=l.toString,h=c.hasOwnProperty,f=RegExp("^"+d.call(h).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function p(g){if(!n(g)||t(g))return!1;var v=e(g)?f:o;return v.test(r(g))}return hm=p,hm}var fm,$_;function eJ(){if($_)return fm;$_=1;function e(t,n){return t==null?void 0:t[n]}return fm=e,fm}var pm,I_;function no(){if(I_)return pm;I_=1;var e=QZ(),t=eJ();function n(r,s){var o=t(r,s);return e(o)?o:void 0}return pm=n,pm}var mm,O_;function T0(){if(O_)return mm;O_=1;var e=no(),t=pr(),n=e(t,"Map");return mm=n,mm}var gm,L_;function yh(){if(L_)return gm;L_=1;var e=no(),t=e(Object,"create");return gm=t,gm}var ym,P_;function tJ(){if(P_)return ym;P_=1;var e=yh();function t(){this.__data__=e?e(null):{},this.size=0}return ym=t,ym}var wm,D_;function nJ(){if(D_)return wm;D_=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return wm=e,wm}var vm,F_;function rJ(){if(F_)return vm;F_=1;var e=yh(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function s(o){var l=this.__data__;if(e){var c=l[o];return c===t?void 0:c}return r.call(l,o)?l[o]:void 0}return vm=s,vm}var xm,B_;function sJ(){if(B_)return xm;B_=1;var e=yh(),t=Object.prototype,n=t.hasOwnProperty;function r(s){var o=this.__data__;return e?o[s]!==void 0:n.call(o,s)}return xm=r,xm}var bm,q_;function aJ(){if(q_)return bm;q_=1;var e=yh(),t="__lodash_hash_undefined__";function n(r,s){var o=this.__data__;return this.size+=this.has(r)?0:1,o[r]=e&&s===void 0?t:s,this}return bm=n,bm}var km,U_;function oJ(){if(U_)return km;U_=1;var e=tJ(),t=nJ(),n=rJ(),r=sJ(),s=aJ();function o(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var h=l[c];this.set(h[0],h[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=s,km=o,km}var Nm,z_;function iJ(){if(z_)return Nm;z_=1;var e=oJ(),t=gh(),n=T0();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return Nm=r,Nm}var jm,W_;function lJ(){if(W_)return jm;W_=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return jm=e,jm}var Sm,H_;function wh(){if(H_)return Sm;H_=1;var e=lJ();function t(n,r){var s=n.__data__;return e(r)?s[typeof r=="string"?"string":"hash"]:s.map}return Sm=t,Sm}var _m,V_;function cJ(){if(V_)return _m;V_=1;var e=wh();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return _m=t,_m}var Em,G_;function uJ(){if(G_)return Em;G_=1;var e=wh();function t(n){return e(this,n).get(n)}return Em=t,Em}var Cm,K_;function dJ(){if(K_)return Cm;K_=1;var e=wh();function t(n){return e(this,n).has(n)}return Cm=t,Cm}var Tm,Y_;function hJ(){if(Y_)return Tm;Y_=1;var e=wh();function t(n,r){var s=e(this,n),o=s.size;return s.set(n,r),this.size+=s.size==o?0:1,this}return Tm=t,Tm}var Am,X_;function A0(){if(X_)return Am;X_=1;var e=iJ(),t=cJ(),n=uJ(),r=dJ(),s=hJ();function o(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var h=l[c];this.set(h[0],h[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=s,Am=o,Am}var Rm,Z_;function fJ(){if(Z_)return Rm;Z_=1;var e=gh(),t=T0(),n=A0(),r=200;function s(o,l){var c=this.__data__;if(c instanceof e){var d=c.__data__;if(!t||d.length<r-1)return d.push([o,l]),this.size=++c.size,this;c=this.__data__=new n(d)}return c.set(o,l),this.size=c.size,this}return Rm=s,Rm}var Mm,J_;function vh(){if(J_)return Mm;J_=1;var e=gh(),t=HZ(),n=VZ(),r=GZ(),s=KZ(),o=fJ();function l(c){var d=this.__data__=new e(c);this.size=d.size}return l.prototype.clear=t,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=s,l.prototype.set=o,Mm=l,Mm}var $m,Q_;function R0(){if(Q_)return $m;Q_=1;function e(t,n){for(var r=-1,s=t==null?0:t.length;++r<s&&n(t[r],r,t)!==!1;);return t}return $m=e,$m}var Im,eE;function vO(){if(eE)return Im;eE=1;var e=no(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return Im=t,Im}var Om,tE;function xh(){if(tE)return Om;tE=1;var e=vO();function t(n,r,s){r=="__proto__"&&e?e(n,r,{configurable:!0,enumerable:!0,value:s,writable:!0}):n[r]=s}return Om=t,Om}var Lm,nE;function bh(){if(nE)return Lm;nE=1;var e=xh(),t=Ei(),n=Object.prototype,r=n.hasOwnProperty;function s(o,l,c){var d=o[l];(!(r.call(o,l)&&t(d,c))||c===void 0&&!(l in o))&&e(o,l,c)}return Lm=s,Lm}var Pm,rE;function mc(){if(rE)return Pm;rE=1;var e=bh(),t=xh();function n(r,s,o,l){var c=!o;o||(o={});for(var d=-1,h=s.length;++d<h;){var f=s[d],p=l?l(o[f],r[f],f,o,r):void 0;p===void 0&&(p=r[f]),c?t(o,f,p):e(o,f,p)}return o}return Pm=n,Pm}var Dm,sE;function pJ(){if(sE)return Dm;sE=1;function e(t,n){for(var r=-1,s=Array(t);++r<t;)s[r]=n(r);return s}return Dm=e,Dm}var Fm,aE;function Ur(){if(aE)return Fm;aE=1;function e(t){return t!=null&&typeof t=="object"}return Fm=e,Fm}var Bm,oE;function mJ(){if(oE)return Bm;oE=1;var e=to(),t=Ur(),n="[object Arguments]";function r(s){return t(s)&&e(s)==n}return Bm=r,Bm}var qm,iE;function gc(){if(iE)return qm;iE=1;var e=mJ(),t=Ur(),n=Object.prototype,r=n.hasOwnProperty,s=n.propertyIsEnumerable,o=e((function(){return arguments})())?e:function(l){return t(l)&&r.call(l,"callee")&&!s.call(l,"callee")};return qm=o,qm}var Um,lE;function jt(){if(lE)return Um;lE=1;var e=Array.isArray;return Um=e,Um}var _l={exports:{}},zm,cE;function gJ(){if(cE)return zm;cE=1;function e(){return!1}return zm=e,zm}_l.exports;var uE;function Ti(){return uE||(uE=1,(function(e,t){var n=pr(),r=gJ(),s=t&&!t.nodeType&&t,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,c=l?n.Buffer:void 0,d=c?c.isBuffer:void 0,h=d||r;e.exports=h})(_l,_l.exports)),_l.exports}var Wm,dE;function kh(){if(dE)return Wm;dE=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(r,s){var o=typeof r;return s=s??e,!!s&&(o=="number"||o!="symbol"&&t.test(r))&&r>-1&&r%1==0&&r<s}return Wm=n,Wm}var Hm,hE;function M0(){if(hE)return Hm;hE=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Hm=t,Hm}var Vm,fE;function yJ(){if(fE)return Vm;fE=1;var e=to(),t=M0(),n=Ur(),r="[object Arguments]",s="[object Array]",o="[object Boolean]",l="[object Date]",c="[object Error]",d="[object Function]",h="[object Map]",f="[object Number]",p="[object Object]",g="[object RegExp]",v="[object Set]",N="[object String]",k="[object WeakMap]",x="[object ArrayBuffer]",j="[object DataView]",b="[object Float32Array]",_="[object Float64Array]",E="[object Int8Array]",R="[object Int16Array]",T="[object Int32Array]",A="[object Uint8Array]",U="[object Uint8ClampedArray]",L="[object Uint16Array]",F="[object Uint32Array]",O={};O[b]=O[_]=O[E]=O[R]=O[T]=O[A]=O[U]=O[L]=O[F]=!0,O[r]=O[s]=O[x]=O[o]=O[j]=O[l]=O[c]=O[d]=O[h]=O[f]=O[p]=O[g]=O[v]=O[N]=O[k]=!1;function I(B){return n(B)&&t(B.length)&&!!O[e(B)]}return Vm=I,Vm}var Gm,pE;function Nh(){if(pE)return Gm;pE=1;function e(t){return function(n){return t(n)}}return Gm=e,Gm}var El={exports:{}};El.exports;var mE;function $0(){return mE||(mE=1,(function(e,t){var n=yO(),r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,o=s&&s.exports===r,l=o&&n.process,c=(function(){try{var d=s&&s.require&&s.require("util").types;return d||l&&l.binding&&l.binding("util")}catch{}})();e.exports=c})(El,El.exports)),El.exports}var Km,gE;function yc(){if(gE)return Km;gE=1;var e=yJ(),t=Nh(),n=$0(),r=n&&n.isTypedArray,s=r?t(r):e;return Km=s,Km}var Ym,yE;function xO(){if(yE)return Ym;yE=1;var e=pJ(),t=gc(),n=jt(),r=Ti(),s=kh(),o=yc(),l=Object.prototype,c=l.hasOwnProperty;function d(h,f){var p=n(h),g=!p&&t(h),v=!p&&!g&&r(h),N=!p&&!g&&!v&&o(h),k=p||g||v||N,x=k?e(h.length,String):[],j=x.length;for(var b in h)(f||c.call(h,b))&&!(k&&(b=="length"||v&&(b=="offset"||b=="parent")||N&&(b=="buffer"||b=="byteLength"||b=="byteOffset")||s(b,j)))&&x.push(b);return x}return Ym=d,Ym}var Xm,wE;function jh(){if(wE)return Xm;wE=1;var e=Object.prototype;function t(n){var r=n&&n.constructor,s=typeof r=="function"&&r.prototype||e;return n===s}return Xm=t,Xm}var Zm,vE;function bO(){if(vE)return Zm;vE=1;function e(t,n){return function(r){return t(n(r))}}return Zm=e,Zm}var Jm,xE;function wJ(){if(xE)return Jm;xE=1;var e=bO(),t=e(Object.keys,Object);return Jm=t,Jm}var Qm,bE;function I0(){if(bE)return Qm;bE=1;var e=jh(),t=wJ(),n=Object.prototype,r=n.hasOwnProperty;function s(o){if(!e(o))return t(o);var l=[];for(var c in Object(o))r.call(o,c)&&c!="constructor"&&l.push(c);return l}return Qm=s,Qm}var eg,kE;function ys(){if(kE)return eg;kE=1;var e=pc(),t=M0();function n(r){return r!=null&&t(r.length)&&!e(r)}return eg=n,eg}var tg,NE;function ua(){if(NE)return tg;NE=1;var e=xO(),t=I0(),n=ys();function r(s){return n(s)?e(s):t(s)}return tg=r,tg}var ng,jE;function vJ(){if(jE)return ng;jE=1;var e=mc(),t=ua();function n(r,s){return r&&e(s,t(s),r)}return ng=n,ng}var rg,SE;function xJ(){if(SE)return rg;SE=1;function e(t){var n=[];if(t!=null)for(var r in Object(t))n.push(r);return n}return rg=e,rg}var sg,_E;function bJ(){if(_E)return sg;_E=1;var e=Vn(),t=jh(),n=xJ(),r=Object.prototype,s=r.hasOwnProperty;function o(l){if(!e(l))return n(l);var c=t(l),d=[];for(var h in l)h=="constructor"&&(c||!s.call(l,h))||d.push(h);return d}return sg=o,sg}var ag,EE;function ro(){if(EE)return ag;EE=1;var e=xO(),t=bJ(),n=ys();function r(s){return n(s)?e(s,!0):t(s)}return ag=r,ag}var og,CE;function kJ(){if(CE)return og;CE=1;var e=mc(),t=ro();function n(r,s){return r&&e(s,t(s),r)}return og=n,og}var Cl={exports:{}};Cl.exports;var TE;function kO(){return TE||(TE=1,(function(e,t){var n=pr(),r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,o=s&&s.exports===r,l=o?n.Buffer:void 0,c=l?l.allocUnsafe:void 0;function d(h,f){if(f)return h.slice();var p=h.length,g=c?c(p):new h.constructor(p);return h.copy(g),g}e.exports=d})(Cl,Cl.exports)),Cl.exports}var ig,AE;function NO(){if(AE)return ig;AE=1;function e(t,n){var r=-1,s=t.length;for(n||(n=Array(s));++r<s;)n[r]=t[r];return n}return ig=e,ig}var lg,RE;function jO(){if(RE)return lg;RE=1;function e(t,n){for(var r=-1,s=t==null?0:t.length,o=0,l=[];++r<s;){var c=t[r];n(c,r,t)&&(l[o++]=c)}return l}return lg=e,lg}var cg,ME;function SO(){if(ME)return cg;ME=1;function e(){return[]}return cg=e,cg}var ug,$E;function O0(){if($E)return ug;$E=1;var e=jO(),t=SO(),n=Object.prototype,r=n.propertyIsEnumerable,s=Object.getOwnPropertySymbols,o=s?function(l){return l==null?[]:(l=Object(l),e(s(l),function(c){return r.call(l,c)}))}:t;return ug=o,ug}var dg,IE;function NJ(){if(IE)return dg;IE=1;var e=mc(),t=O0();function n(r,s){return e(r,t(r),s)}return dg=n,dg}var hg,OE;function L0(){if(OE)return hg;OE=1;function e(t,n){for(var r=-1,s=n.length,o=t.length;++r<s;)t[o+r]=n[r];return t}return hg=e,hg}var fg,LE;function Sh(){if(LE)return fg;LE=1;var e=bO(),t=e(Object.getPrototypeOf,Object);return fg=t,fg}var pg,PE;function _O(){if(PE)return pg;PE=1;var e=L0(),t=Sh(),n=O0(),r=SO(),s=Object.getOwnPropertySymbols,o=s?function(l){for(var c=[];l;)e(c,n(l)),l=t(l);return c}:r;return pg=o,pg}var mg,DE;function jJ(){if(DE)return mg;DE=1;var e=mc(),t=_O();function n(r,s){return e(r,t(r),s)}return mg=n,mg}var gg,FE;function EO(){if(FE)return gg;FE=1;var e=L0(),t=jt();function n(r,s,o){var l=s(r);return t(r)?l:e(l,o(r))}return gg=n,gg}var yg,BE;function CO(){if(BE)return yg;BE=1;var e=EO(),t=O0(),n=ua();function r(s){return e(s,n,t)}return yg=r,yg}var wg,qE;function SJ(){if(qE)return wg;qE=1;var e=EO(),t=_O(),n=ro();function r(s){return e(s,n,t)}return wg=r,wg}var vg,UE;function _J(){if(UE)return vg;UE=1;var e=no(),t=pr(),n=e(t,"DataView");return vg=n,vg}var xg,zE;function EJ(){if(zE)return xg;zE=1;var e=no(),t=pr(),n=e(t,"Promise");return xg=n,xg}var bg,WE;function TO(){if(WE)return bg;WE=1;var e=no(),t=pr(),n=e(t,"Set");return bg=n,bg}var kg,HE;function CJ(){if(HE)return kg;HE=1;var e=no(),t=pr(),n=e(t,"WeakMap");return kg=n,kg}var Ng,VE;function Ai(){if(VE)return Ng;VE=1;var e=_J(),t=T0(),n=EJ(),r=TO(),s=CJ(),o=to(),l=wO(),c="[object Map]",d="[object Object]",h="[object Promise]",f="[object Set]",p="[object WeakMap]",g="[object DataView]",v=l(e),N=l(t),k=l(n),x=l(r),j=l(s),b=o;return(e&&b(new e(new ArrayBuffer(1)))!=g||t&&b(new t)!=c||n&&b(n.resolve())!=h||r&&b(new r)!=f||s&&b(new s)!=p)&&(b=function(_){var E=o(_),R=E==d?_.constructor:void 0,T=R?l(R):"";if(T)switch(T){case v:return g;case N:return c;case k:return h;case x:return f;case j:return p}return E}),Ng=b,Ng}var jg,GE;function TJ(){if(GE)return jg;GE=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r){var s=r.length,o=new r.constructor(s);return s&&typeof r[0]=="string"&&t.call(r,"index")&&(o.index=r.index,o.input=r.input),o}return jg=n,jg}var Sg,KE;function AO(){if(KE)return Sg;KE=1;var e=pr(),t=e.Uint8Array;return Sg=t,Sg}var _g,YE;function P0(){if(YE)return _g;YE=1;var e=AO();function t(n){var r=new n.constructor(n.byteLength);return new e(r).set(new e(n)),r}return _g=t,_g}var Eg,XE;function AJ(){if(XE)return Eg;XE=1;var e=P0();function t(n,r){var s=r?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.byteLength)}return Eg=t,Eg}var Cg,ZE;function RJ(){if(ZE)return Cg;ZE=1;var e=/\w*$/;function t(n){var r=new n.constructor(n.source,e.exec(n));return r.lastIndex=n.lastIndex,r}return Cg=t,Cg}var Tg,JE;function MJ(){if(JE)return Tg;JE=1;var e=Ci(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function r(s){return n?Object(n.call(s)):{}}return Tg=r,Tg}var Ag,QE;function RO(){if(QE)return Ag;QE=1;var e=P0();function t(n,r){var s=r?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.length)}return Ag=t,Ag}var Rg,eC;function $J(){if(eC)return Rg;eC=1;var e=P0(),t=AJ(),n=RJ(),r=MJ(),s=RO(),o="[object Boolean]",l="[object Date]",c="[object Map]",d="[object Number]",h="[object RegExp]",f="[object Set]",p="[object String]",g="[object Symbol]",v="[object ArrayBuffer]",N="[object DataView]",k="[object Float32Array]",x="[object Float64Array]",j="[object Int8Array]",b="[object Int16Array]",_="[object Int32Array]",E="[object Uint8Array]",R="[object Uint8ClampedArray]",T="[object Uint16Array]",A="[object Uint32Array]";function U(L,F,O){var I=L.constructor;switch(F){case v:return e(L);case o:case l:return new I(+L);case N:return t(L,O);case k:case x:case j:case b:case _:case E:case R:case T:case A:return s(L,O);case c:return new I;case d:case p:return new I(L);case h:return n(L);case f:return new I;case g:return r(L)}}return Rg=U,Rg}var Mg,tC;function MO(){if(tC)return Mg;tC=1;var e=Vn(),t=Object.create,n=(function(){function r(){}return function(s){if(!e(s))return{};if(t)return t(s);r.prototype=s;var o=new r;return r.prototype=void 0,o}})();return Mg=n,Mg}var $g,nC;function $O(){if(nC)return $g;nC=1;var e=MO(),t=Sh(),n=jh();function r(s){return typeof s.constructor=="function"&&!n(s)?e(t(s)):{}}return $g=r,$g}var Ig,rC;function IJ(){if(rC)return Ig;rC=1;var e=Ai(),t=Ur(),n="[object Map]";function r(s){return t(s)&&e(s)==n}return Ig=r,Ig}var Og,sC;function OJ(){if(sC)return Og;sC=1;var e=IJ(),t=Nh(),n=$0(),r=n&&n.isMap,s=r?t(r):e;return Og=s,Og}var Lg,aC;function LJ(){if(aC)return Lg;aC=1;var e=Ai(),t=Ur(),n="[object Set]";function r(s){return t(s)&&e(s)==n}return Lg=r,Lg}var Pg,oC;function PJ(){if(oC)return Pg;oC=1;var e=LJ(),t=Nh(),n=$0(),r=n&&n.isSet,s=r?t(r):e;return Pg=s,Pg}var Dg,iC;function IO(){if(iC)return Dg;iC=1;var e=vh(),t=R0(),n=bh(),r=vJ(),s=kJ(),o=kO(),l=NO(),c=NJ(),d=jJ(),h=CO(),f=SJ(),p=Ai(),g=TJ(),v=$J(),N=$O(),k=jt(),x=Ti(),j=OJ(),b=Vn(),_=PJ(),E=ua(),R=ro(),T=1,A=2,U=4,L="[object Arguments]",F="[object Array]",O="[object Boolean]",I="[object Date]",B="[object Error]",M="[object Function]",$="[object GeneratorFunction]",P="[object Map]",G="[object Number]",K="[object Object]",q="[object RegExp]",H="[object Set]",D="[object String]",W="[object Symbol]",J="[object WeakMap]",V="[object ArrayBuffer]",X="[object DataView]",Y="[object Float32Array]",Z="[object Float64Array]",ee="[object Int8Array]",ne="[object Int16Array]",se="[object Int32Array]",pe="[object Uint8Array]",ke="[object Uint8ClampedArray]",ae="[object Uint16Array]",fe="[object Uint32Array]",me={};me[L]=me[F]=me[V]=me[X]=me[O]=me[I]=me[Y]=me[Z]=me[ee]=me[ne]=me[se]=me[P]=me[G]=me[K]=me[q]=me[H]=me[D]=me[W]=me[pe]=me[ke]=me[ae]=me[fe]=!0,me[B]=me[M]=me[J]=!1;function he(ge,ue,be,oe,je,$e){var Oe,Ue=ue&T,Be=ue&A,We=ue&U;if(be&&(Oe=je?be(ge,oe,je,$e):be(ge)),Oe!==void 0)return Oe;if(!b(ge))return ge;var He=k(ge);if(He){if(Oe=g(ge),!Ue)return l(ge,Oe)}else{var rt=p(ge),lt=rt==M||rt==$;if(x(ge))return o(ge,Ue);if(rt==K||rt==L||lt&&!je){if(Oe=Be||lt?{}:N(ge),!Ue)return Be?d(ge,s(Oe,ge)):c(ge,r(Oe,ge))}else{if(!me[rt])return je?ge:{};Oe=v(ge,rt,Ue)}}$e||($e=new e);var Rt=$e.get(ge);if(Rt)return Rt;$e.set(ge,Oe),_(ge)?ge.forEach(function(Je){Oe.add(he(Je,ue,be,Je,ge,$e))}):j(ge)&&ge.forEach(function(Je,tt){Oe.set(tt,he(Je,ue,be,tt,ge,$e))});var De=We?Be?f:h:Be?R:E,et=He?void 0:De(ge);return t(et||ge,function(Je,tt){et&&(tt=Je,Je=ge[tt]),n(Oe,tt,he(Je,ue,be,tt,ge,$e))}),Oe}return Dg=he,Dg}var Fg,lC;function DJ(){if(lC)return Fg;lC=1;var e=IO(),t=4;function n(r){return e(r,t)}return Fg=n,Fg}var Bg,cC;function D0(){if(cC)return Bg;cC=1;function e(t){return function(){return t}}return Bg=e,Bg}var qg,uC;function FJ(){if(uC)return qg;uC=1;function e(t){return function(n,r,s){for(var o=-1,l=Object(n),c=s(n),d=c.length;d--;){var h=c[t?d:++o];if(r(l[h],h,l)===!1)break}return n}}return qg=e,qg}var Ug,dC;function F0(){if(dC)return Ug;dC=1;var e=FJ(),t=e();return Ug=t,Ug}var zg,hC;function B0(){if(hC)return zg;hC=1;var e=F0(),t=ua();function n(r,s){return r&&e(r,s,t)}return zg=n,zg}var Wg,fC;function BJ(){if(fC)return Wg;fC=1;var e=ys();function t(n,r){return function(s,o){if(s==null)return s;if(!e(s))return n(s,o);for(var l=s.length,c=r?l:-1,d=Object(s);(r?c--:++c<l)&&o(d[c],c,d)!==!1;);return s}}return Wg=t,Wg}var Hg,pC;function _h(){if(pC)return Hg;pC=1;var e=B0(),t=BJ(),n=t(e);return Hg=n,Hg}var Vg,mC;function so(){if(mC)return Vg;mC=1;function e(t){return t}return Vg=e,Vg}var Gg,gC;function OO(){if(gC)return Gg;gC=1;var e=so();function t(n){return typeof n=="function"?n:e}return Gg=t,Gg}var Kg,yC;function LO(){if(yC)return Kg;yC=1;var e=R0(),t=_h(),n=OO(),r=jt();function s(o,l){var c=r(o)?e:t;return c(o,n(l))}return Kg=s,Kg}var Yg,wC;function PO(){return wC||(wC=1,Yg=LO()),Yg}var Xg,vC;function qJ(){if(vC)return Xg;vC=1;var e=_h();function t(n,r){var s=[];return e(n,function(o,l,c){r(o,l,c)&&s.push(o)}),s}return Xg=t,Xg}var Zg,xC;function UJ(){if(xC)return Zg;xC=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return Zg=t,Zg}var Jg,bC;function zJ(){if(bC)return Jg;bC=1;function e(t){return this.__data__.has(t)}return Jg=e,Jg}var Qg,kC;function DO(){if(kC)return Qg;kC=1;var e=A0(),t=UJ(),n=zJ();function r(s){var o=-1,l=s==null?0:s.length;for(this.__data__=new e;++o<l;)this.add(s[o])}return r.prototype.add=r.prototype.push=t,r.prototype.has=n,Qg=r,Qg}var ey,NC;function WJ(){if(NC)return ey;NC=1;function e(t,n){for(var r=-1,s=t==null?0:t.length;++r<s;)if(n(t[r],r,t))return!0;return!1}return ey=e,ey}var ty,jC;function FO(){if(jC)return ty;jC=1;function e(t,n){return t.has(n)}return ty=e,ty}var ny,SC;function BO(){if(SC)return ny;SC=1;var e=DO(),t=WJ(),n=FO(),r=1,s=2;function o(l,c,d,h,f,p){var g=d&r,v=l.length,N=c.length;if(v!=N&&!(g&&N>v))return!1;var k=p.get(l),x=p.get(c);if(k&&x)return k==c&&x==l;var j=-1,b=!0,_=d&s?new e:void 0;for(p.set(l,c),p.set(c,l);++j<v;){var E=l[j],R=c[j];if(h)var T=g?h(R,E,j,c,l,p):h(E,R,j,l,c,p);if(T!==void 0){if(T)continue;b=!1;break}if(_){if(!t(c,function(A,U){if(!n(_,U)&&(E===A||f(E,A,d,h,p)))return _.push(U)})){b=!1;break}}else if(!(E===R||f(E,R,d,h,p))){b=!1;break}}return p.delete(l),p.delete(c),b}return ny=o,ny}var ry,_C;function HJ(){if(_C)return ry;_C=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(s,o){r[++n]=[o,s]}),r}return ry=e,ry}var sy,EC;function q0(){if(EC)return sy;EC=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(s){r[++n]=s}),r}return sy=e,sy}var ay,CC;function VJ(){if(CC)return ay;CC=1;var e=Ci(),t=AO(),n=Ei(),r=BO(),s=HJ(),o=q0(),l=1,c=2,d="[object Boolean]",h="[object Date]",f="[object Error]",p="[object Map]",g="[object Number]",v="[object RegExp]",N="[object Set]",k="[object String]",x="[object Symbol]",j="[object ArrayBuffer]",b="[object DataView]",_=e?e.prototype:void 0,E=_?_.valueOf:void 0;function R(T,A,U,L,F,O,I){switch(U){case b:if(T.byteLength!=A.byteLength||T.byteOffset!=A.byteOffset)return!1;T=T.buffer,A=A.buffer;case j:return!(T.byteLength!=A.byteLength||!O(new t(T),new t(A)));case d:case h:case g:return n(+T,+A);case f:return T.name==A.name&&T.message==A.message;case v:case k:return T==A+"";case p:var B=s;case N:var M=L&l;if(B||(B=o),T.size!=A.size&&!M)return!1;var $=I.get(T);if($)return $==A;L|=c,I.set(T,A);var P=r(B(T),B(A),L,F,O,I);return I.delete(T),P;case x:if(E)return E.call(T)==E.call(A)}return!1}return ay=R,ay}var oy,TC;function GJ(){if(TC)return oy;TC=1;var e=CO(),t=1,n=Object.prototype,r=n.hasOwnProperty;function s(o,l,c,d,h,f){var p=c&t,g=e(o),v=g.length,N=e(l),k=N.length;if(v!=k&&!p)return!1;for(var x=v;x--;){var j=g[x];if(!(p?j in l:r.call(l,j)))return!1}var b=f.get(o),_=f.get(l);if(b&&_)return b==l&&_==o;var E=!0;f.set(o,l),f.set(l,o);for(var R=p;++x<v;){j=g[x];var T=o[j],A=l[j];if(d)var U=p?d(A,T,j,l,o,f):d(T,A,j,o,l,f);if(!(U===void 0?T===A||h(T,A,c,d,f):U)){E=!1;break}R||(R=j=="constructor")}if(E&&!R){var L=o.constructor,F=l.constructor;L!=F&&"constructor"in o&&"constructor"in l&&!(typeof L=="function"&&L instanceof L&&typeof F=="function"&&F instanceof F)&&(E=!1)}return f.delete(o),f.delete(l),E}return oy=s,oy}var iy,AC;function KJ(){if(AC)return iy;AC=1;var e=vh(),t=BO(),n=VJ(),r=GJ(),s=Ai(),o=jt(),l=Ti(),c=yc(),d=1,h="[object Arguments]",f="[object Array]",p="[object Object]",g=Object.prototype,v=g.hasOwnProperty;function N(k,x,j,b,_,E){var R=o(k),T=o(x),A=R?f:s(k),U=T?f:s(x);A=A==h?p:A,U=U==h?p:U;var L=A==p,F=U==p,O=A==U;if(O&&l(k)){if(!l(x))return!1;R=!0,L=!1}if(O&&!L)return E||(E=new e),R||c(k)?t(k,x,j,b,_,E):n(k,x,A,j,b,_,E);if(!(j&d)){var I=L&&v.call(k,"__wrapped__"),B=F&&v.call(x,"__wrapped__");if(I||B){var M=I?k.value():k,$=B?x.value():x;return E||(E=new e),_(M,$,j,b,E)}}return O?(E||(E=new e),r(k,x,j,b,_,E)):!1}return iy=N,iy}var ly,RC;function qO(){if(RC)return ly;RC=1;var e=KJ(),t=Ur();function n(r,s,o,l,c){return r===s?!0:r==null||s==null||!t(r)&&!t(s)?r!==r&&s!==s:e(r,s,o,l,n,c)}return ly=n,ly}var cy,MC;function YJ(){if(MC)return cy;MC=1;var e=vh(),t=qO(),n=1,r=2;function s(o,l,c,d){var h=c.length,f=h,p=!d;if(o==null)return!f;for(o=Object(o);h--;){var g=c[h];if(p&&g[2]?g[1]!==o[g[0]]:!(g[0]in o))return!1}for(;++h<f;){g=c[h];var v=g[0],N=o[v],k=g[1];if(p&&g[2]){if(N===void 0&&!(v in o))return!1}else{var x=new e;if(d)var j=d(N,k,v,o,l,x);if(!(j===void 0?t(k,N,n|r,d,x):j))return!1}}return!0}return cy=s,cy}var uy,$C;function UO(){if($C)return uy;$C=1;var e=Vn();function t(n){return n===n&&!e(n)}return uy=t,uy}var dy,IC;function XJ(){if(IC)return dy;IC=1;var e=UO(),t=ua();function n(r){for(var s=t(r),o=s.length;o--;){var l=s[o],c=r[l];s[o]=[l,c,e(c)]}return s}return dy=n,dy}var hy,OC;function zO(){if(OC)return hy;OC=1;function e(t,n){return function(r){return r==null?!1:r[t]===n&&(n!==void 0||t in Object(r))}}return hy=e,hy}var fy,LC;function ZJ(){if(LC)return fy;LC=1;var e=YJ(),t=XJ(),n=zO();function r(s){var o=t(s);return o.length==1&&o[0][2]?n(o[0][0],o[0][1]):function(l){return l===s||e(l,s,o)}}return fy=r,fy}var py,PC;function Ri(){if(PC)return py;PC=1;var e=to(),t=Ur(),n="[object Symbol]";function r(s){return typeof s=="symbol"||t(s)&&e(s)==n}return py=r,py}var my,DC;function U0(){if(DC)return my;DC=1;var e=jt(),t=Ri(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function s(o,l){if(e(o))return!1;var c=typeof o;return c=="number"||c=="symbol"||c=="boolean"||o==null||t(o)?!0:r.test(o)||!n.test(o)||l!=null&&o in Object(l)}return my=s,my}var gy,FC;function JJ(){if(FC)return gy;FC=1;var e=A0(),t="Expected a function";function n(r,s){if(typeof r!="function"||s!=null&&typeof s!="function")throw new TypeError(t);var o=function(){var l=arguments,c=s?s.apply(this,l):l[0],d=o.cache;if(d.has(c))return d.get(c);var h=r.apply(this,l);return o.cache=d.set(c,h)||d,h};return o.cache=new(n.Cache||e),o}return n.Cache=e,gy=n,gy}var yy,BC;function QJ(){if(BC)return yy;BC=1;var e=JJ(),t=500;function n(r){var s=e(r,function(l){return o.size===t&&o.clear(),l}),o=s.cache;return s}return yy=n,yy}var wy,qC;function eQ(){if(qC)return wy;qC=1;var e=QJ(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(s){var o=[];return s.charCodeAt(0)===46&&o.push(""),s.replace(t,function(l,c,d,h){o.push(d?h.replace(n,"$1"):c||l)}),o});return wy=r,wy}var vy,UC;function Eh(){if(UC)return vy;UC=1;function e(t,n){for(var r=-1,s=t==null?0:t.length,o=Array(s);++r<s;)o[r]=n(t[r],r,t);return o}return vy=e,vy}var xy,zC;function tQ(){if(zC)return xy;zC=1;var e=Ci(),t=Eh(),n=jt(),r=Ri(),s=e?e.prototype:void 0,o=s?s.toString:void 0;function l(c){if(typeof c=="string")return c;if(n(c))return t(c,l)+"";if(r(c))return o?o.call(c):"";var d=c+"";return d=="0"&&1/c==-1/0?"-0":d}return xy=l,xy}var by,WC;function WO(){if(WC)return by;WC=1;var e=tQ();function t(n){return n==null?"":e(n)}return by=t,by}var ky,HC;function Ch(){if(HC)return ky;HC=1;var e=jt(),t=U0(),n=eQ(),r=WO();function s(o,l){return e(o)?o:t(o,l)?[o]:n(r(o))}return ky=s,ky}var Ny,VC;function wc(){if(VC)return Ny;VC=1;var e=Ri();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return Ny=t,Ny}var jy,GC;function Th(){if(GC)return jy;GC=1;var e=Ch(),t=wc();function n(r,s){s=e(s,r);for(var o=0,l=s.length;r!=null&&o<l;)r=r[t(s[o++])];return o&&o==l?r:void 0}return jy=n,jy}var Sy,KC;function nQ(){if(KC)return Sy;KC=1;var e=Th();function t(n,r,s){var o=n==null?void 0:e(n,r);return o===void 0?s:o}return Sy=t,Sy}var _y,YC;function rQ(){if(YC)return _y;YC=1;function e(t,n){return t!=null&&n in Object(t)}return _y=e,_y}var Ey,XC;function HO(){if(XC)return Ey;XC=1;var e=Ch(),t=gc(),n=jt(),r=kh(),s=M0(),o=wc();function l(c,d,h){d=e(d,c);for(var f=-1,p=d.length,g=!1;++f<p;){var v=o(d[f]);if(!(g=c!=null&&h(c,v)))break;c=c[v]}return g||++f!=p?g:(p=c==null?0:c.length,!!p&&s(p)&&r(v,p)&&(n(c)||t(c)))}return Ey=l,Ey}var Cy,ZC;function VO(){if(ZC)return Cy;ZC=1;var e=rQ(),t=HO();function n(r,s){return r!=null&&t(r,s,e)}return Cy=n,Cy}var Ty,JC;function sQ(){if(JC)return Ty;JC=1;var e=qO(),t=nQ(),n=VO(),r=U0(),s=UO(),o=zO(),l=wc(),c=1,d=2;function h(f,p){return r(f)&&s(p)?o(l(f),p):function(g){var v=t(g,f);return v===void 0&&v===p?n(g,f):e(p,v,c|d)}}return Ty=h,Ty}var Ay,QC;function GO(){if(QC)return Ay;QC=1;function e(t){return function(n){return n==null?void 0:n[t]}}return Ay=e,Ay}var Ry,eT;function aQ(){if(eT)return Ry;eT=1;var e=Th();function t(n){return function(r){return e(r,n)}}return Ry=t,Ry}var My,tT;function oQ(){if(tT)return My;tT=1;var e=GO(),t=aQ(),n=U0(),r=wc();function s(o){return n(o)?e(r(o)):t(o)}return My=s,My}var $y,nT;function ws(){if(nT)return $y;nT=1;var e=ZJ(),t=sQ(),n=so(),r=jt(),s=oQ();function o(l){return typeof l=="function"?l:l==null?n:typeof l=="object"?r(l)?t(l[0],l[1]):e(l):s(l)}return $y=o,$y}var Iy,rT;function KO(){if(rT)return Iy;rT=1;var e=jO(),t=qJ(),n=ws(),r=jt();function s(o,l){var c=r(o)?e:t;return c(o,n(l,3))}return Iy=s,Iy}var Oy,sT;function iQ(){if(sT)return Oy;sT=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r,s){return r!=null&&t.call(r,s)}return Oy=n,Oy}var Ly,aT;function YO(){if(aT)return Ly;aT=1;var e=iQ(),t=HO();function n(r,s){return r!=null&&t(r,s,e)}return Ly=n,Ly}var Py,oT;function lQ(){if(oT)return Py;oT=1;var e=I0(),t=Ai(),n=gc(),r=jt(),s=ys(),o=Ti(),l=jh(),c=yc(),d="[object Map]",h="[object Set]",f=Object.prototype,p=f.hasOwnProperty;function g(v){if(v==null)return!0;if(s(v)&&(r(v)||typeof v=="string"||typeof v.splice=="function"||o(v)||c(v)||n(v)))return!v.length;var N=t(v);if(N==d||N==h)return!v.size;if(l(v))return!e(v).length;for(var k in v)if(p.call(v,k))return!1;return!0}return Py=g,Py}var Dy,iT;function XO(){if(iT)return Dy;iT=1;function e(t){return t===void 0}return Dy=e,Dy}var Fy,lT;function ZO(){if(lT)return Fy;lT=1;var e=_h(),t=ys();function n(r,s){var o=-1,l=t(r)?Array(r.length):[];return e(r,function(c,d,h){l[++o]=s(c,d,h)}),l}return Fy=n,Fy}var By,cT;function JO(){if(cT)return By;cT=1;var e=Eh(),t=ws(),n=ZO(),r=jt();function s(o,l){var c=r(o)?e:n;return c(o,t(l,3))}return By=s,By}var qy,uT;function cQ(){if(uT)return qy;uT=1;function e(t,n,r,s){var o=-1,l=t==null?0:t.length;for(s&&l&&(r=t[++o]);++o<l;)r=n(r,t[o],o,t);return r}return qy=e,qy}var Uy,dT;function uQ(){if(dT)return Uy;dT=1;function e(t,n,r,s,o){return o(t,function(l,c,d){r=s?(s=!1,l):n(r,l,c,d)}),r}return Uy=e,Uy}var zy,hT;function QO(){if(hT)return zy;hT=1;var e=cQ(),t=_h(),n=ws(),r=uQ(),s=jt();function o(l,c,d){var h=s(l)?e:r,f=arguments.length<3;return h(l,n(c,4),d,f,t)}return zy=o,zy}var Wy,fT;function dQ(){if(fT)return Wy;fT=1;var e=to(),t=jt(),n=Ur(),r="[object String]";function s(o){return typeof o=="string"||!t(o)&&n(o)&&e(o)==r}return Wy=s,Wy}var Hy,pT;function hQ(){if(pT)return Hy;pT=1;var e=GO(),t=e("length");return Hy=t,Hy}var Vy,mT;function fQ(){if(mT)return Vy;mT=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",s=t+n+r,o="\\ufe0e\\ufe0f",l="\\u200d",c=RegExp("["+l+e+s+o+"]");function d(h){return c.test(h)}return Vy=d,Vy}var Gy,gT;function pQ(){if(gT)return Gy;gT=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",s=t+n+r,o="\\ufe0e\\ufe0f",l="["+e+"]",c="["+s+"]",d="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+d+")",f="[^"+e+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",g="[\\ud800-\\udbff][\\udc00-\\udfff]",v="\\u200d",N=h+"?",k="["+o+"]?",x="(?:"+v+"(?:"+[f,p,g].join("|")+")"+k+N+")*",j=k+N+x,b="(?:"+[f+c+"?",c,p,g,l].join("|")+")",_=RegExp(d+"(?="+d+")|"+b+j,"g");function E(R){for(var T=_.lastIndex=0;_.test(R);)++T;return T}return Gy=E,Gy}var Ky,yT;function mQ(){if(yT)return Ky;yT=1;var e=hQ(),t=fQ(),n=pQ();function r(s){return t(s)?n(s):e(s)}return Ky=r,Ky}var Yy,wT;function gQ(){if(wT)return Yy;wT=1;var e=I0(),t=Ai(),n=ys(),r=dQ(),s=mQ(),o="[object Map]",l="[object Set]";function c(d){if(d==null)return 0;if(n(d))return r(d)?s(d):d.length;var h=t(d);return h==o||h==l?d.size:e(d).length}return Yy=c,Yy}var Xy,vT;function yQ(){if(vT)return Xy;vT=1;var e=R0(),t=MO(),n=B0(),r=ws(),s=Sh(),o=jt(),l=Ti(),c=pc(),d=Vn(),h=yc();function f(p,g,v){var N=o(p),k=N||l(p)||h(p);if(g=r(g,4),v==null){var x=p&&p.constructor;k?v=N?new x:[]:d(p)?v=c(x)?t(s(p)):{}:v={}}return(k?e:n)(p,function(j,b,_){return g(v,j,b,_)}),v}return Xy=f,Xy}var Zy,xT;function wQ(){if(xT)return Zy;xT=1;var e=Ci(),t=gc(),n=jt(),r=e?e.isConcatSpreadable:void 0;function s(o){return n(o)||t(o)||!!(r&&o&&o[r])}return Zy=s,Zy}var Jy,bT;function z0(){if(bT)return Jy;bT=1;var e=L0(),t=wQ();function n(r,s,o,l,c){var d=-1,h=r.length;for(o||(o=t),c||(c=[]);++d<h;){var f=r[d];s>0&&o(f)?s>1?n(f,s-1,o,l,c):e(c,f):l||(c[c.length]=f)}return c}return Jy=n,Jy}var Qy,kT;function vQ(){if(kT)return Qy;kT=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 Qy=e,Qy}var ew,NT;function eL(){if(NT)return ew;NT=1;var e=vQ(),t=Math.max;function n(r,s,o){return s=t(s===void 0?r.length-1:s,0),function(){for(var l=arguments,c=-1,d=t(l.length-s,0),h=Array(d);++c<d;)h[c]=l[s+c];c=-1;for(var f=Array(s+1);++c<s;)f[c]=l[c];return f[s]=o(h),e(r,this,f)}}return ew=n,ew}var tw,jT;function xQ(){if(jT)return tw;jT=1;var e=D0(),t=vO(),n=so(),r=t?function(s,o){return t(s,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:n;return tw=r,tw}var nw,ST;function bQ(){if(ST)return nw;ST=1;var e=800,t=16,n=Date.now;function r(s){var o=0,l=0;return function(){var c=n(),d=t-(c-l);if(l=c,d>0){if(++o>=e)return arguments[0]}else o=0;return s.apply(void 0,arguments)}}return nw=r,nw}var rw,_T;function tL(){if(_T)return rw;_T=1;var e=xQ(),t=bQ(),n=t(e);return rw=n,rw}var sw,ET;function Ah(){if(ET)return sw;ET=1;var e=so(),t=eL(),n=tL();function r(s,o){return n(t(s,o,e),s+"")}return sw=r,sw}var aw,CT;function nL(){if(CT)return aw;CT=1;function e(t,n,r,s){for(var o=t.length,l=r+(s?1:-1);s?l--:++l<o;)if(n(t[l],l,t))return l;return-1}return aw=e,aw}var ow,TT;function kQ(){if(TT)return ow;TT=1;function e(t){return t!==t}return ow=e,ow}var iw,AT;function NQ(){if(AT)return iw;AT=1;function e(t,n,r){for(var s=r-1,o=t.length;++s<o;)if(t[s]===n)return s;return-1}return iw=e,iw}var lw,RT;function jQ(){if(RT)return lw;RT=1;var e=nL(),t=kQ(),n=NQ();function r(s,o,l){return o===o?n(s,o,l):e(s,t,l)}return lw=r,lw}var cw,MT;function SQ(){if(MT)return cw;MT=1;var e=jQ();function t(n,r){var s=n==null?0:n.length;return!!s&&e(n,r,0)>-1}return cw=t,cw}var uw,$T;function _Q(){if($T)return uw;$T=1;function e(t,n,r){for(var s=-1,o=t==null?0:t.length;++s<o;)if(r(n,t[s]))return!0;return!1}return uw=e,uw}var dw,IT;function EQ(){if(IT)return dw;IT=1;function e(){}return dw=e,dw}var hw,OT;function CQ(){if(OT)return hw;OT=1;var e=TO(),t=EQ(),n=q0(),r=1/0,s=e&&1/n(new e([,-0]))[1]==r?function(o){return new e(o)}:t;return hw=s,hw}var fw,LT;function TQ(){if(LT)return fw;LT=1;var e=DO(),t=SQ(),n=_Q(),r=FO(),s=CQ(),o=q0(),l=200;function c(d,h,f){var p=-1,g=t,v=d.length,N=!0,k=[],x=k;if(f)N=!1,g=n;else if(v>=l){var j=h?null:s(d);if(j)return o(j);N=!1,g=r,x=new e}else x=h?[]:k;e:for(;++p<v;){var b=d[p],_=h?h(b):b;if(b=f||b!==0?b:0,N&&_===_){for(var E=x.length;E--;)if(x[E]===_)continue e;h&&x.push(_),k.push(b)}else g(x,_,f)||(x!==k&&x.push(_),k.push(b))}return k}return fw=c,fw}var pw,PT;function rL(){if(PT)return pw;PT=1;var e=ys(),t=Ur();function n(r){return t(r)&&e(r)}return pw=n,pw}var mw,DT;function AQ(){if(DT)return mw;DT=1;var e=z0(),t=Ah(),n=TQ(),r=rL(),s=t(function(o){return n(e(o,1,r,!0))});return mw=s,mw}var gw,FT;function RQ(){if(FT)return gw;FT=1;var e=Eh();function t(n,r){return e(r,function(s){return n[s]})}return gw=t,gw}var yw,BT;function sL(){if(BT)return yw;BT=1;var e=RQ(),t=ua();function n(r){return r==null?[]:e(r,t(r))}return yw=n,yw}var ww,qT;function Gn(){if(qT)return ww;qT=1;var e;if(typeof C0=="function")try{e={clone:DJ(),constant:D0(),each:PO(),filter:KO(),has:YO(),isArray:jt(),isEmpty:lQ(),isFunction:pc(),isUndefined:XO(),keys:ua(),map:JO(),reduce:QO(),size:gQ(),transform:yQ(),union:AQ(),values:sL()}}catch{}return e||(e=window._),ww=e,ww}var vw,UT;function W0(){if(UT)return vw;UT=1;var e=Gn();vw=s;var t="\0",n="\0",r="";function s(f){this._isDirected=e.has(f,"directed")?f.directed:!0,this._isMultigraph=e.has(f,"multigraph")?f.multigraph:!1,this._isCompound=e.has(f,"compound")?f.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={}}s.prototype._nodeCount=0,s.prototype._edgeCount=0,s.prototype.isDirected=function(){return this._isDirected},s.prototype.isMultigraph=function(){return this._isMultigraph},s.prototype.isCompound=function(){return this._isCompound},s.prototype.setGraph=function(f){return this._label=f,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return e.keys(this._nodes)},s.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(p){return e.isEmpty(f._in[p])})},s.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(p){return e.isEmpty(f._out[p])})},s.prototype.setNodes=function(f,p){var g=arguments,v=this;return e.each(f,function(N){g.length>1?v.setNode(N,p):v.setNode(N)}),this},s.prototype.setNode=function(f,p){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=p),this):(this._nodes[f]=arguments.length>1?p:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=n,this._children[f]={},this._children[n][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},s.prototype.node=function(f){return this._nodes[f]},s.prototype.hasNode=function(f){return e.has(this._nodes,f)},s.prototype.removeNode=function(f){var p=this;if(e.has(this._nodes,f)){var g=function(v){p.removeEdge(p._edgeObjs[v])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(v){p.setParent(v)}),delete this._children[f]),e.each(e.keys(this._in[f]),g),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),g),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},s.prototype.setParent=function(f,p){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(p))p=n;else{p+="";for(var g=p;!e.isUndefined(g);g=this.parent(g))if(g===f)throw new Error("Setting "+p+" as parent of "+f+" would create a cycle");this.setNode(p)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=p,this._children[p][f]=!0,this},s.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},s.prototype.parent=function(f){if(this._isCompound){var p=this._parent[f];if(p!==n)return p}},s.prototype.children=function(f){if(e.isUndefined(f)&&(f=n),this._isCompound){var p=this._children[f];if(p)return e.keys(p)}else{if(f===n)return this.nodes();if(this.hasNode(f))return[]}},s.prototype.predecessors=function(f){var p=this._preds[f];if(p)return e.keys(p)},s.prototype.successors=function(f){var p=this._sucs[f];if(p)return e.keys(p)},s.prototype.neighbors=function(f){var p=this.predecessors(f);if(p)return e.union(p,this.successors(f))},s.prototype.isLeaf=function(f){var p;return this.isDirected()?p=this.successors(f):p=this.neighbors(f),p.length===0},s.prototype.filterNodes=function(f){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var g=this;e.each(this._nodes,function(k,x){f(x)&&p.setNode(x,k)}),e.each(this._edgeObjs,function(k){p.hasNode(k.v)&&p.hasNode(k.w)&&p.setEdge(k,g.edge(k))});var v={};function N(k){var x=g.parent(k);return x===void 0||p.hasNode(x)?(v[k]=x,x):x in v?v[x]:N(x)}return this._isCompound&&e.each(p.nodes(),function(k){p.setParent(k,N(k))}),p},s.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return e.values(this._edgeObjs)},s.prototype.setPath=function(f,p){var g=this,v=arguments;return e.reduce(f,function(N,k){return v.length>1?g.setEdge(N,k,p):g.setEdge(N,k),k}),this},s.prototype.setEdge=function(){var f,p,g,v,N=!1,k=arguments[0];typeof k=="object"&&k!==null&&"v"in k?(f=k.v,p=k.w,g=k.name,arguments.length===2&&(v=arguments[1],N=!0)):(f=k,p=arguments[1],g=arguments[3],arguments.length>2&&(v=arguments[2],N=!0)),f=""+f,p=""+p,e.isUndefined(g)||(g=""+g);var x=c(this._isDirected,f,p,g);if(e.has(this._edgeLabels,x))return N&&(this._edgeLabels[x]=v),this;if(!e.isUndefined(g)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(p),this._edgeLabels[x]=N?v:this._defaultEdgeLabelFn(f,p,g);var j=d(this._isDirected,f,p,g);return f=j.v,p=j.w,Object.freeze(j),this._edgeObjs[x]=j,o(this._preds[p],f),o(this._sucs[f],p),this._in[p][x]=j,this._out[f][x]=j,this._edgeCount++,this},s.prototype.edge=function(f,p,g){var v=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,g);return this._edgeLabels[v]},s.prototype.hasEdge=function(f,p,g){var v=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,g);return e.has(this._edgeLabels,v)},s.prototype.removeEdge=function(f,p,g){var v=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,g),N=this._edgeObjs[v];return N&&(f=N.v,p=N.w,delete this._edgeLabels[v],delete this._edgeObjs[v],l(this._preds[p],f),l(this._sucs[f],p),delete this._in[p][v],delete this._out[f][v],this._edgeCount--),this},s.prototype.inEdges=function(f,p){var g=this._in[f];if(g){var v=e.values(g);return p?e.filter(v,function(N){return N.v===p}):v}},s.prototype.outEdges=function(f,p){var g=this._out[f];if(g){var v=e.values(g);return p?e.filter(v,function(N){return N.w===p}):v}},s.prototype.nodeEdges=function(f,p){var g=this.inEdges(f,p);if(g)return g.concat(this.outEdges(f,p))};function o(f,p){f[p]?f[p]++:f[p]=1}function l(f,p){--f[p]||delete f[p]}function c(f,p,g,v){var N=""+p,k=""+g;if(!f&&N>k){var x=N;N=k,k=x}return N+r+k+r+(e.isUndefined(v)?t:v)}function d(f,p,g,v){var N=""+p,k=""+g;if(!f&&N>k){var x=N;N=k,k=x}var j={v:N,w:k};return v&&(j.name=v),j}function h(f,p){return c(f,p.v,p.w,p.name)}return vw}var xw,zT;function MQ(){return zT||(zT=1,xw="2.1.8"),xw}var bw,WT;function $Q(){return WT||(WT=1,bw={Graph:W0(),version:MQ()}),bw}var kw,HT;function IQ(){if(HT)return kw;HT=1;var e=Gn(),t=W0();kw={write:n,read:o};function n(l){var c={options:{directed:l.isDirected(),multigraph:l.isMultigraph(),compound:l.isCompound()},nodes:r(l),edges:s(l)};return e.isUndefined(l.graph())||(c.value=e.clone(l.graph())),c}function r(l){return e.map(l.nodes(),function(c){var d=l.node(c),h=l.parent(c),f={v:c};return e.isUndefined(d)||(f.value=d),e.isUndefined(h)||(f.parent=h),f})}function s(l){return e.map(l.edges(),function(c){var d=l.edge(c),h={v:c.v,w:c.w};return e.isUndefined(c.name)||(h.name=c.name),e.isUndefined(d)||(h.value=d),h})}function o(l){var c=new t(l.options).setGraph(l.value);return e.each(l.nodes,function(d){c.setNode(d.v,d.value),d.parent&&c.setParent(d.v,d.parent)}),e.each(l.edges,function(d){c.setEdge({v:d.v,w:d.w,name:d.name},d.value)}),c}return kw}var Nw,VT;function OQ(){if(VT)return Nw;VT=1;var e=Gn();Nw=t;function t(n){var r={},s=[],o;function l(c){e.has(r,c)||(r[c]=!0,o.push(c),e.each(n.successors(c),l),e.each(n.predecessors(c),l))}return e.each(n.nodes(),function(c){o=[],l(c),o.length&&s.push(o)}),s}return Nw}var jw,GT;function aL(){if(GT)return jw;GT=1;var e=Gn();jw=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 s=this._keyIndices;if(n=String(n),!e.has(s,n)){var o=this._arr,l=o.length;return s[n]=l,o.push({key:n,priority:r}),this._decrease(l),!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 s=this._keyIndices[n];if(r>this._arr[s].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[s].priority+" New: "+r);this._arr[s].priority=r,this._decrease(s)},t.prototype._heapify=function(n){var r=this._arr,s=2*n,o=s+1,l=n;s<r.length&&(l=r[s].priority<r[l].priority?s:l,o<r.length&&(l=r[o].priority<r[l].priority?o:l),l!==n&&(this._swap(n,l),this._heapify(l)))},t.prototype._decrease=function(n){for(var r=this._arr,s=r[n].priority,o;n!==0&&(o=n>>1,!(r[o].priority<s));)this._swap(n,o),n=o},t.prototype._swap=function(n,r){var s=this._arr,o=this._keyIndices,l=s[n],c=s[r];s[n]=c,s[r]=l,o[c.key]=n,o[l.key]=r},jw}var Sw,KT;function oL(){if(KT)return Sw;KT=1;var e=Gn(),t=aL();Sw=r;var n=e.constant(1);function r(o,l,c,d){return s(o,String(l),c||n,d||function(h){return o.outEdges(h)})}function s(o,l,c,d){var h={},f=new t,p,g,v=function(N){var k=N.v!==p?N.v:N.w,x=h[k],j=c(N),b=g.distance+j;if(j<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+N+" Weight: "+j);b<x.distance&&(x.distance=b,x.predecessor=p,f.decrease(k,b))};for(o.nodes().forEach(function(N){var k=N===l?0:Number.POSITIVE_INFINITY;h[N]={distance:k},f.add(N,k)});f.size()>0&&(p=f.removeMin(),g=h[p],g.distance!==Number.POSITIVE_INFINITY);)d(p).forEach(v);return h}return Sw}var _w,YT;function LQ(){if(YT)return _w;YT=1;var e=oL(),t=Gn();_w=n;function n(r,s,o){return t.transform(r.nodes(),function(l,c){l[c]=e(r,c,s,o)},{})}return _w}var Ew,XT;function iL(){if(XT)return Ew;XT=1;var e=Gn();Ew=t;function t(n){var r=0,s=[],o={},l=[];function c(d){var h=o[d]={onStack:!0,lowlink:r,index:r++};if(s.push(d),n.successors(d).forEach(function(g){e.has(o,g)?o[g].onStack&&(h.lowlink=Math.min(h.lowlink,o[g].index)):(c(g),h.lowlink=Math.min(h.lowlink,o[g].lowlink))}),h.lowlink===h.index){var f=[],p;do p=s.pop(),o[p].onStack=!1,f.push(p);while(d!==p);l.push(f)}}return n.nodes().forEach(function(d){e.has(o,d)||c(d)}),l}return Ew}var Cw,ZT;function PQ(){if(ZT)return Cw;ZT=1;var e=Gn(),t=iL();Cw=n;function n(r){return e.filter(t(r),function(s){return s.length>1||s.length===1&&r.hasEdge(s[0],s[0])})}return Cw}var Tw,JT;function DQ(){if(JT)return Tw;JT=1;var e=Gn();Tw=n;var t=e.constant(1);function n(s,o,l){return r(s,o||t,l||function(c){return s.outEdges(c)})}function r(s,o,l){var c={},d=s.nodes();return d.forEach(function(h){c[h]={},c[h][h]={distance:0},d.forEach(function(f){h!==f&&(c[h][f]={distance:Number.POSITIVE_INFINITY})}),l(h).forEach(function(f){var p=f.v===h?f.w:f.v,g=o(f);c[h][p]={distance:g,predecessor:h}})}),d.forEach(function(h){var f=c[h];d.forEach(function(p){var g=c[p];d.forEach(function(v){var N=g[h],k=f[v],x=g[v],j=N.distance+k.distance;j<x.distance&&(x.distance=j,x.predecessor=k.predecessor)})})}),c}return Tw}var Aw,QT;function lL(){if(QT)return Aw;QT=1;var e=Gn();Aw=t,t.CycleException=n;function t(r){var s={},o={},l=[];function c(d){if(e.has(o,d))throw new n;e.has(s,d)||(o[d]=!0,s[d]=!0,e.each(r.predecessors(d),c),delete o[d],l.push(d))}if(e.each(r.sinks(),c),e.size(s)!==r.nodeCount())throw new n;return l}function n(){}return n.prototype=new Error,Aw}var Rw,eA;function FQ(){if(eA)return Rw;eA=1;var e=lL();Rw=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return Rw}var Mw,tA;function cL(){if(tA)return Mw;tA=1;var e=Gn();Mw=t;function t(r,s,o){e.isArray(s)||(s=[s]);var l=(r.isDirected()?r.successors:r.neighbors).bind(r),c=[],d={};return e.each(s,function(h){if(!r.hasNode(h))throw new Error("Graph does not have node: "+h);n(r,h,o==="post",d,l,c)}),c}function n(r,s,o,l,c,d){e.has(l,s)||(l[s]=!0,o||d.push(s),e.each(c(s),function(h){n(r,h,o,l,c,d)}),o&&d.push(s))}return Mw}var $w,nA;function BQ(){if(nA)return $w;nA=1;var e=cL();$w=t;function t(n,r){return e(n,r,"post")}return $w}var Iw,rA;function qQ(){if(rA)return Iw;rA=1;var e=cL();Iw=t;function t(n,r){return e(n,r,"pre")}return Iw}var Ow,sA;function UQ(){if(sA)return Ow;sA=1;var e=Gn(),t=W0(),n=aL();Ow=r;function r(s,o){var l=new t,c={},d=new n,h;function f(g){var v=g.v===h?g.w:g.v,N=d.priority(v);if(N!==void 0){var k=o(g);k<N&&(c[v]=h,d.decrease(v,k))}}if(s.nodeCount()===0)return l;e.each(s.nodes(),function(g){d.add(g,Number.POSITIVE_INFINITY),l.setNode(g)}),d.decrease(s.nodes()[0],0);for(var p=!1;d.size()>0;){if(h=d.removeMin(),e.has(c,h))l.setEdge(h,c[h]);else{if(p)throw new Error("Input graph is not connected: "+s);p=!0}s.nodeEdges(h).forEach(f)}return l}return Ow}var Lw,aA;function zQ(){return aA||(aA=1,Lw={components:OQ(),dijkstra:oL(),dijkstraAll:LQ(),findCycles:PQ(),floydWarshall:DQ(),isAcyclic:FQ(),postorder:BQ(),preorder:qQ(),prim:UQ(),tarjan:iL(),topsort:lL()}),Lw}var Pw,oA;function WQ(){if(oA)return Pw;oA=1;var e=$Q();return Pw={Graph:e.Graph,json:IQ(),alg:zQ(),version:e.version},Pw}var Dw,iA;function hr(){if(iA)return Dw;iA=1;var e;if(typeof C0=="function")try{e=WQ()}catch{}return e||(e=window.graphlib),Dw=e,Dw}var Fw,lA;function HQ(){if(lA)return Fw;lA=1;var e=IO(),t=1,n=4;function r(s){return e(s,t|n)}return Fw=r,Fw}var Bw,cA;function Rh(){if(cA)return Bw;cA=1;var e=Ei(),t=ys(),n=kh(),r=Vn();function s(o,l,c){if(!r(c))return!1;var d=typeof l;return(d=="number"?t(c)&&n(l,c.length):d=="string"&&l in c)?e(c[l],o):!1}return Bw=s,Bw}var qw,uA;function VQ(){if(uA)return qw;uA=1;var e=Ah(),t=Ei(),n=Rh(),r=ro(),s=Object.prototype,o=s.hasOwnProperty,l=e(function(c,d){c=Object(c);var h=-1,f=d.length,p=f>2?d[2]:void 0;for(p&&n(d[0],d[1],p)&&(f=1);++h<f;)for(var g=d[h],v=r(g),N=-1,k=v.length;++N<k;){var x=v[N],j=c[x];(j===void 0||t(j,s[x])&&!o.call(c,x))&&(c[x]=g[x])}return c});return qw=l,qw}var Uw,dA;function GQ(){if(dA)return Uw;dA=1;var e=ws(),t=ys(),n=ua();function r(s){return function(o,l,c){var d=Object(o);if(!t(o)){var h=e(l,3);o=n(o),l=function(p){return h(d[p],p,d)}}var f=s(o,l,c);return f>-1?d[h?o[f]:f]:void 0}}return Uw=r,Uw}var zw,hA;function KQ(){if(hA)return zw;hA=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return zw=t,zw}var Ww,fA;function YQ(){if(fA)return Ww;fA=1;var e=KQ(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return Ww=n,Ww}var Hw,pA;function XQ(){if(pA)return Hw;pA=1;var e=YQ(),t=Vn(),n=Ri(),r=NaN,s=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,l=/^0o[0-7]+$/i,c=parseInt;function d(h){if(typeof h=="number")return h;if(n(h))return r;if(t(h)){var f=typeof h.valueOf=="function"?h.valueOf():h;h=t(f)?f+"":f}if(typeof h!="string")return h===0?h:+h;h=e(h);var p=o.test(h);return p||l.test(h)?c(h.slice(2),p?2:8):s.test(h)?r:+h}return Hw=d,Hw}var Vw,mA;function uL(){if(mA)return Vw;mA=1;var e=XQ(),t=1/0,n=17976931348623157e292;function r(s){if(!s)return s===0?s:0;if(s=e(s),s===t||s===-t){var o=s<0?-1:1;return o*n}return s===s?s:0}return Vw=r,Vw}var Gw,gA;function ZQ(){if(gA)return Gw;gA=1;var e=uL();function t(n){var r=e(n),s=r%1;return r===r?s?r-s:r:0}return Gw=t,Gw}var Kw,yA;function JQ(){if(yA)return Kw;yA=1;var e=nL(),t=ws(),n=ZQ(),r=Math.max;function s(o,l,c){var d=o==null?0:o.length;if(!d)return-1;var h=c==null?0:n(c);return h<0&&(h=r(d+h,0)),e(o,t(l,3),h)}return Kw=s,Kw}var Yw,wA;function QQ(){if(wA)return Yw;wA=1;var e=GQ(),t=JQ(),n=e(t);return Yw=n,Yw}var Xw,vA;function dL(){if(vA)return Xw;vA=1;var e=z0();function t(n){var r=n==null?0:n.length;return r?e(n,1):[]}return Xw=t,Xw}var Zw,xA;function eee(){if(xA)return Zw;xA=1;var e=F0(),t=OO(),n=ro();function r(s,o){return s==null?s:e(s,t(o),n)}return Zw=r,Zw}var Jw,bA;function tee(){if(bA)return Jw;bA=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return Jw=e,Jw}var Qw,kA;function nee(){if(kA)return Qw;kA=1;var e=xh(),t=B0(),n=ws();function r(s,o){var l={};return o=n(o,3),t(s,function(c,d,h){e(l,d,o(c,d,h))}),l}return Qw=r,Qw}var ev,NA;function H0(){if(NA)return ev;NA=1;var e=Ri();function t(n,r,s){for(var o=-1,l=n.length;++o<l;){var c=n[o],d=r(c);if(d!=null&&(h===void 0?d===d&&!e(d):s(d,h)))var h=d,f=c}return f}return ev=t,ev}var tv,jA;function ree(){if(jA)return tv;jA=1;function e(t,n){return t>n}return tv=e,tv}var nv,SA;function see(){if(SA)return nv;SA=1;var e=H0(),t=ree(),n=so();function r(s){return s&&s.length?e(s,n,t):void 0}return nv=r,nv}var rv,_A;function hL(){if(_A)return rv;_A=1;var e=xh(),t=Ei();function n(r,s,o){(o!==void 0&&!t(r[s],o)||o===void 0&&!(s in r))&&e(r,s,o)}return rv=n,rv}var sv,EA;function aee(){if(EA)return sv;EA=1;var e=to(),t=Sh(),n=Ur(),r="[object Object]",s=Function.prototype,o=Object.prototype,l=s.toString,c=o.hasOwnProperty,d=l.call(Object);function h(f){if(!n(f)||e(f)!=r)return!1;var p=t(f);if(p===null)return!0;var g=c.call(p,"constructor")&&p.constructor;return typeof g=="function"&&g instanceof g&&l.call(g)==d}return sv=h,sv}var av,CA;function fL(){if(CA)return av;CA=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return av=e,av}var ov,TA;function oee(){if(TA)return ov;TA=1;var e=mc(),t=ro();function n(r){return e(r,t(r))}return ov=n,ov}var iv,AA;function iee(){if(AA)return iv;AA=1;var e=hL(),t=kO(),n=RO(),r=NO(),s=$O(),o=gc(),l=jt(),c=rL(),d=Ti(),h=pc(),f=Vn(),p=aee(),g=yc(),v=fL(),N=oee();function k(x,j,b,_,E,R,T){var A=v(x,b),U=v(j,b),L=T.get(U);if(L){e(x,b,L);return}var F=R?R(A,U,b+"",x,j,T):void 0,O=F===void 0;if(O){var I=l(U),B=!I&&d(U),M=!I&&!B&&g(U);F=U,I||B||M?l(A)?F=A:c(A)?F=r(A):B?(O=!1,F=t(U,!0)):M?(O=!1,F=n(U,!0)):F=[]:p(U)||o(U)?(F=A,o(A)?F=N(A):(!f(A)||h(A))&&(F=s(U))):O=!1}O&&(T.set(U,F),E(F,U,_,R,T),T.delete(U)),e(x,b,F)}return iv=k,iv}var lv,RA;function lee(){if(RA)return lv;RA=1;var e=vh(),t=hL(),n=F0(),r=iee(),s=Vn(),o=ro(),l=fL();function c(d,h,f,p,g){d!==h&&n(h,function(v,N){if(g||(g=new e),s(v))r(d,h,N,f,c,p,g);else{var k=p?p(l(d,N),v,N+"",d,h,g):void 0;k===void 0&&(k=v),t(d,N,k)}},o)}return lv=c,lv}var cv,MA;function cee(){if(MA)return cv;MA=1;var e=Ah(),t=Rh();function n(r){return e(function(s,o){var l=-1,c=o.length,d=c>1?o[c-1]:void 0,h=c>2?o[2]:void 0;for(d=r.length>3&&typeof d=="function"?(c--,d):void 0,h&&t(o[0],o[1],h)&&(d=c<3?void 0:d,c=1),s=Object(s);++l<c;){var f=o[l];f&&r(s,f,l,d)}return s})}return cv=n,cv}var uv,$A;function uee(){if($A)return uv;$A=1;var e=lee(),t=cee(),n=t(function(r,s,o){e(r,s,o)});return uv=n,uv}var dv,IA;function pL(){if(IA)return dv;IA=1;function e(t,n){return t<n}return dv=e,dv}var hv,OA;function dee(){if(OA)return hv;OA=1;var e=H0(),t=pL(),n=so();function r(s){return s&&s.length?e(s,n,t):void 0}return hv=r,hv}var fv,LA;function hee(){if(LA)return fv;LA=1;var e=H0(),t=ws(),n=pL();function r(s,o){return s&&s.length?e(s,t(o,2),n):void 0}return fv=r,fv}var pv,PA;function fee(){if(PA)return pv;PA=1;var e=pr(),t=function(){return e.Date.now()};return pv=t,pv}var mv,DA;function pee(){if(DA)return mv;DA=1;var e=bh(),t=Ch(),n=kh(),r=Vn(),s=wc();function o(l,c,d,h){if(!r(l))return l;c=t(c,l);for(var f=-1,p=c.length,g=p-1,v=l;v!=null&&++f<p;){var N=s(c[f]),k=d;if(N==="__proto__"||N==="constructor"||N==="prototype")return l;if(f!=g){var x=v[N];k=h?h(x,N,v):void 0,k===void 0&&(k=r(x)?x:n(c[f+1])?[]:{})}e(v,N,k),v=v[N]}return l}return mv=o,mv}var gv,FA;function mee(){if(FA)return gv;FA=1;var e=Th(),t=pee(),n=Ch();function r(s,o,l){for(var c=-1,d=o.length,h={};++c<d;){var f=o[c],p=e(s,f);l(p,f)&&t(h,n(f,s),p)}return h}return gv=r,gv}var yv,BA;function gee(){if(BA)return yv;BA=1;var e=mee(),t=VO();function n(r,s){return e(r,s,function(o,l){return t(r,l)})}return yv=n,yv}var wv,qA;function yee(){if(qA)return wv;qA=1;var e=dL(),t=eL(),n=tL();function r(s){return n(t(s,void 0,e),s+"")}return wv=r,wv}var vv,UA;function wee(){if(UA)return vv;UA=1;var e=gee(),t=yee(),n=t(function(r,s){return r==null?{}:e(r,s)});return vv=n,vv}var xv,zA;function vee(){if(zA)return xv;zA=1;var e=Math.ceil,t=Math.max;function n(r,s,o,l){for(var c=-1,d=t(e((s-r)/(o||1)),0),h=Array(d);d--;)h[l?d:++c]=r,r+=o;return h}return xv=n,xv}var bv,WA;function xee(){if(WA)return bv;WA=1;var e=vee(),t=Rh(),n=uL();function r(s){return function(o,l,c){return c&&typeof c!="number"&&t(o,l,c)&&(l=c=void 0),o=n(o),l===void 0?(l=o,o=0):l=n(l),c=c===void 0?o<l?1:-1:n(c),e(o,l,c,s)}}return bv=r,bv}var kv,HA;function bee(){if(HA)return kv;HA=1;var e=xee(),t=e();return kv=t,kv}var Nv,VA;function kee(){if(VA)return Nv;VA=1;function e(t,n){var r=t.length;for(t.sort(n);r--;)t[r]=t[r].value;return t}return Nv=e,Nv}var jv,GA;function Nee(){if(GA)return jv;GA=1;var e=Ri();function t(n,r){if(n!==r){var s=n!==void 0,o=n===null,l=n===n,c=e(n),d=r!==void 0,h=r===null,f=r===r,p=e(r);if(!h&&!p&&!c&&n>r||c&&d&&f&&!h&&!p||o&&d&&f||!s&&f||!l)return 1;if(!o&&!c&&!p&&n<r||p&&s&&l&&!o&&!c||h&&s&&l||!d&&l||!f)return-1}return 0}return jv=t,jv}var Sv,KA;function jee(){if(KA)return Sv;KA=1;var e=Nee();function t(n,r,s){for(var o=-1,l=n.criteria,c=r.criteria,d=l.length,h=s.length;++o<d;){var f=e(l[o],c[o]);if(f){if(o>=h)return f;var p=s[o];return f*(p=="desc"?-1:1)}}return n.index-r.index}return Sv=t,Sv}var _v,YA;function See(){if(YA)return _v;YA=1;var e=Eh(),t=Th(),n=ws(),r=ZO(),s=kee(),o=Nh(),l=jee(),c=so(),d=jt();function h(f,p,g){p.length?p=e(p,function(k){return d(k)?function(x){return t(x,k.length===1?k[0]:k)}:k}):p=[c];var v=-1;p=e(p,o(n));var N=r(f,function(k,x,j){var b=e(p,function(_){return _(k)});return{criteria:b,index:++v,value:k}});return s(N,function(k,x){return l(k,x,g)})}return _v=h,_v}var Ev,XA;function _ee(){if(XA)return Ev;XA=1;var e=z0(),t=See(),n=Ah(),r=Rh(),s=n(function(o,l){if(o==null)return[];var c=l.length;return c>1&&r(o,l[0],l[1])?l=[]:c>2&&r(l[0],l[1],l[2])&&(l=[l[0]]),t(o,e(l,1),[])});return Ev=s,Ev}var Cv,ZA;function Eee(){if(ZA)return Cv;ZA=1;var e=WO(),t=0;function n(r){var s=++t;return e(r)+s}return Cv=n,Cv}var Tv,JA;function Cee(){if(JA)return Tv;JA=1;function e(t,n,r){for(var s=-1,o=t.length,l=n.length,c={};++s<o;){var d=s<l?n[s]:void 0;r(c,t[s],d)}return c}return Tv=e,Tv}var Av,QA;function Tee(){if(QA)return Av;QA=1;var e=bh(),t=Cee();function n(r,s){return t(r||[],s||[],e)}return Av=n,Av}var Rv,eR;function dt(){if(eR)return Rv;eR=1;var e;if(typeof C0=="function")try{e={cloneDeep:HQ(),constant:D0(),defaults:VQ(),each:PO(),filter:KO(),find:QQ(),flatten:dL(),forEach:LO(),forIn:eee(),has:YO(),isUndefined:XO(),last:tee(),map:JO(),mapValues:nee(),max:see(),merge:uee(),min:dee(),minBy:hee(),now:fee(),pick:wee(),range:bee(),reduce:QO(),sortBy:_ee(),uniqueId:Eee(),values:sL(),zipObject:Tee()}}catch{}return e||(e=window._),Rv=e,Rv}var Mv,tR;function Aee(){if(tR)return Mv;tR=1,Mv=e;function e(){var r={};r._next=r._prev=r,this._sentinel=r}e.prototype.dequeue=function(){var r=this._sentinel,s=r._prev;if(s!==r)return t(s),s},e.prototype.enqueue=function(r){var s=this._sentinel;r._prev&&r._next&&t(r),r._next=s._next,s._next._prev=r,s._next=r,r._prev=s},e.prototype.toString=function(){for(var r=[],s=this._sentinel,o=s._prev;o!==s;)r.push(JSON.stringify(o,n)),o=o._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,s){if(r!=="_next"&&r!=="_prev")return s}return Mv}var $v,nR;function Ree(){if(nR)return $v;nR=1;var e=dt(),t=hr().Graph,n=Aee();$v=s;var r=e.constant(1);function s(h,f){if(h.nodeCount()<=1)return[];var p=c(h,f||r),g=o(p.graph,p.buckets,p.zeroIdx);return e.flatten(e.map(g,function(v){return h.outEdges(v.v,v.w)}),!0)}function o(h,f,p){for(var g=[],v=f[f.length-1],N=f[0],k;h.nodeCount();){for(;k=N.dequeue();)l(h,f,p,k);for(;k=v.dequeue();)l(h,f,p,k);if(h.nodeCount()){for(var x=f.length-2;x>0;--x)if(k=f[x].dequeue(),k){g=g.concat(l(h,f,p,k,!0));break}}}return g}function l(h,f,p,g,v){var N=v?[]:void 0;return e.forEach(h.inEdges(g.v),function(k){var x=h.edge(k),j=h.node(k.v);v&&N.push({v:k.v,w:k.w}),j.out-=x,d(f,p,j)}),e.forEach(h.outEdges(g.v),function(k){var x=h.edge(k),j=k.w,b=h.node(j);b.in-=x,d(f,p,b)}),h.removeNode(g.v),N}function c(h,f){var p=new t,g=0,v=0;e.forEach(h.nodes(),function(x){p.setNode(x,{v:x,in:0,out:0})}),e.forEach(h.edges(),function(x){var j=p.edge(x.v,x.w)||0,b=f(x),_=j+b;p.setEdge(x.v,x.w,_),v=Math.max(v,p.node(x.v).out+=b),g=Math.max(g,p.node(x.w).in+=b)});var N=e.range(v+g+3).map(function(){return new n}),k=g+1;return e.forEach(p.nodes(),function(x){d(N,k,p.node(x))}),{graph:p,buckets:N,zeroIdx:k}}function d(h,f,p){p.out?p.in?h[p.out-p.in+f].enqueue(p):h[h.length-1].enqueue(p):h[0].enqueue(p)}return $v}var Iv,rR;function Mee(){if(rR)return Iv;rR=1;var e=dt(),t=Ree();Iv={run:n,undo:s};function n(o){var l=o.graph().acyclicer==="greedy"?t(o,c(o)):r(o);e.forEach(l,function(d){var h=o.edge(d);o.removeEdge(d),h.forwardName=d.name,h.reversed=!0,o.setEdge(d.w,d.v,h,e.uniqueId("rev"))});function c(d){return function(h){return d.edge(h).weight}}}function r(o){var l=[],c={},d={};function h(f){e.has(d,f)||(d[f]=!0,c[f]=!0,e.forEach(o.outEdges(f),function(p){e.has(c,p.w)?l.push(p):h(p.w)}),delete c[f])}return e.forEach(o.nodes(),h),l}function s(o){e.forEach(o.edges(),function(l){var c=o.edge(l);if(c.reversed){o.removeEdge(l);var d=c.forwardName;delete c.reversed,delete c.forwardName,o.setEdge(l.w,l.v,c,d)}})}return Iv}var Ov,sR;function fn(){if(sR)return Ov;sR=1;var e=dt(),t=hr().Graph;Ov={addDummyNode:n,simplify:r,asNonCompoundGraph:s,successorWeights:o,predecessorWeights:l,intersectRect:c,buildLayerMatrix:d,normalizeRanks:h,removeEmptyRanks:f,addBorderNode:p,maxRank:g,partition:v,time:N,notime:k};function n(x,j,b,_){var E;do E=e.uniqueId(_);while(x.hasNode(E));return b.dummy=j,x.setNode(E,b),E}function r(x){var j=new t().setGraph(x.graph());return e.forEach(x.nodes(),function(b){j.setNode(b,x.node(b))}),e.forEach(x.edges(),function(b){var _=j.edge(b.v,b.w)||{weight:0,minlen:1},E=x.edge(b);j.setEdge(b.v,b.w,{weight:_.weight+E.weight,minlen:Math.max(_.minlen,E.minlen)})}),j}function s(x){var j=new t({multigraph:x.isMultigraph()}).setGraph(x.graph());return e.forEach(x.nodes(),function(b){x.children(b).length||j.setNode(b,x.node(b))}),e.forEach(x.edges(),function(b){j.setEdge(b,x.edge(b))}),j}function o(x){var j=e.map(x.nodes(),function(b){var _={};return e.forEach(x.outEdges(b),function(E){_[E.w]=(_[E.w]||0)+x.edge(E).weight}),_});return e.zipObject(x.nodes(),j)}function l(x){var j=e.map(x.nodes(),function(b){var _={};return e.forEach(x.inEdges(b),function(E){_[E.v]=(_[E.v]||0)+x.edge(E).weight}),_});return e.zipObject(x.nodes(),j)}function c(x,j){var b=x.x,_=x.y,E=j.x-b,R=j.y-_,T=x.width/2,A=x.height/2;if(!E&&!R)throw new Error("Not possible to find intersection inside of the rectangle");var U,L;return Math.abs(R)*T>Math.abs(E)*A?(R<0&&(A=-A),U=A*E/R,L=A):(E<0&&(T=-T),U=T,L=T*R/E),{x:b+U,y:_+L}}function d(x){var j=e.map(e.range(g(x)+1),function(){return[]});return e.forEach(x.nodes(),function(b){var _=x.node(b),E=_.rank;e.isUndefined(E)||(j[E][_.order]=b)}),j}function h(x){var j=e.min(e.map(x.nodes(),function(b){return x.node(b).rank}));e.forEach(x.nodes(),function(b){var _=x.node(b);e.has(_,"rank")&&(_.rank-=j)})}function f(x){var j=e.min(e.map(x.nodes(),function(R){return x.node(R).rank})),b=[];e.forEach(x.nodes(),function(R){var T=x.node(R).rank-j;b[T]||(b[T]=[]),b[T].push(R)});var _=0,E=x.graph().nodeRankFactor;e.forEach(b,function(R,T){e.isUndefined(R)&&T%E!==0?--_:_&&e.forEach(R,function(A){x.node(A).rank+=_})})}function p(x,j,b,_){var E={width:0,height:0};return arguments.length>=4&&(E.rank=b,E.order=_),n(x,"border",E,j)}function g(x){return e.max(e.map(x.nodes(),function(j){var b=x.node(j).rank;if(!e.isUndefined(b))return b}))}function v(x,j){var b={lhs:[],rhs:[]};return e.forEach(x,function(_){j(_)?b.lhs.push(_):b.rhs.push(_)}),b}function N(x,j){var b=e.now();try{return j()}finally{console.log(x+" time: "+(e.now()-b)+"ms")}}function k(x,j){return j()}return Ov}var Lv,aR;function $ee(){if(aR)return Lv;aR=1;var e=dt(),t=fn();Lv={run:n,undo:s};function n(o){o.graph().dummyChains=[],e.forEach(o.edges(),function(l){r(o,l)})}function r(o,l){var c=l.v,d=o.node(c).rank,h=l.w,f=o.node(h).rank,p=l.name,g=o.edge(l),v=g.labelRank;if(f!==d+1){o.removeEdge(l);var N,k,x;for(x=0,++d;d<f;++x,++d)g.points=[],k={width:0,height:0,edgeLabel:g,edgeObj:l,rank:d},N=t.addDummyNode(o,"edge",k,"_d"),d===v&&(k.width=g.width,k.height=g.height,k.dummy="edge-label",k.labelpos=g.labelpos),o.setEdge(c,N,{weight:g.weight},p),x===0&&o.graph().dummyChains.push(N),c=N;o.setEdge(c,h,{weight:g.weight},p)}}function s(o){e.forEach(o.graph().dummyChains,function(l){var c=o.node(l),d=c.edgeLabel,h;for(o.setEdge(c.edgeObj,d);c.dummy;)h=o.successors(l)[0],o.removeNode(l),d.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(d.x=c.x,d.y=c.y,d.width=c.width,d.height=c.height),l=h,c=o.node(l)})}return Lv}var Pv,oR;function $d(){if(oR)return Pv;oR=1;var e=dt();Pv={longestPath:t,slack:n};function t(r){var s={};function o(l){var c=r.node(l);if(e.has(s,l))return c.rank;s[l]=!0;var d=e.min(e.map(r.outEdges(l),function(h){return o(h.w)-r.edge(h).minlen}));return(d===Number.POSITIVE_INFINITY||d===void 0||d===null)&&(d=0),c.rank=d}e.forEach(r.sources(),o)}function n(r,s){return r.node(s.w).rank-r.node(s.v).rank-r.edge(s).minlen}return Pv}var Dv,iR;function mL(){if(iR)return Dv;iR=1;var e=dt(),t=hr().Graph,n=$d().slack;Dv=r;function r(c){var d=new t({directed:!1}),h=c.nodes()[0],f=c.nodeCount();d.setNode(h,{});for(var p,g;s(d,c)<f;)p=o(d,c),g=d.hasNode(p.v)?n(c,p):-n(c,p),l(d,c,g);return d}function s(c,d){function h(f){e.forEach(d.nodeEdges(f),function(p){var g=p.v,v=f===g?p.w:g;!c.hasNode(v)&&!n(d,p)&&(c.setNode(v,{}),c.setEdge(f,v,{}),h(v))})}return e.forEach(c.nodes(),h),c.nodeCount()}function o(c,d){return e.minBy(d.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return n(d,h)})}function l(c,d,h){e.forEach(c.nodes(),function(f){d.node(f).rank+=h})}return Dv}var Fv,lR;function Iee(){if(lR)return Fv;lR=1;var e=dt(),t=mL(),n=$d().slack,r=$d().longestPath,s=hr().alg.preorder,o=hr().alg.postorder,l=fn().simplify;Fv=c,c.initLowLimValues=p,c.initCutValues=d,c.calcCutValue=f,c.leaveEdge=v,c.enterEdge=N,c.exchangeEdges=k;function c(_){_=l(_),r(_);var E=t(_);p(E),d(E,_);for(var R,T;R=v(E);)T=N(E,_,R),k(E,_,R,T)}function d(_,E){var R=o(_,_.nodes());R=R.slice(0,R.length-1),e.forEach(R,function(T){h(_,E,T)})}function h(_,E,R){var T=_.node(R),A=T.parent;_.edge(R,A).cutvalue=f(_,E,R)}function f(_,E,R){var T=_.node(R),A=T.parent,U=!0,L=E.edge(R,A),F=0;return L||(U=!1,L=E.edge(A,R)),F=L.weight,e.forEach(E.nodeEdges(R),function(O){var I=O.v===R,B=I?O.w:O.v;if(B!==A){var M=I===U,$=E.edge(O).weight;if(F+=M?$:-$,j(_,R,B)){var P=_.edge(R,B).cutvalue;F+=M?-P:P}}}),F}function p(_,E){arguments.length<2&&(E=_.nodes()[0]),g(_,{},1,E)}function g(_,E,R,T,A){var U=R,L=_.node(T);return E[T]=!0,e.forEach(_.neighbors(T),function(F){e.has(E,F)||(R=g(_,E,R,F,T))}),L.low=U,L.lim=R++,A?L.parent=A:delete L.parent,R}function v(_){return e.find(_.edges(),function(E){return _.edge(E).cutvalue<0})}function N(_,E,R){var T=R.v,A=R.w;E.hasEdge(T,A)||(T=R.w,A=R.v);var U=_.node(T),L=_.node(A),F=U,O=!1;U.lim>L.lim&&(F=L,O=!0);var I=e.filter(E.edges(),function(B){return O===b(_,_.node(B.v),F)&&O!==b(_,_.node(B.w),F)});return e.minBy(I,function(B){return n(E,B)})}function k(_,E,R,T){var A=R.v,U=R.w;_.removeEdge(A,U),_.setEdge(T.v,T.w,{}),p(_),d(_,E),x(_,E)}function x(_,E){var R=e.find(_.nodes(),function(A){return!E.node(A).parent}),T=s(_,R);T=T.slice(1),e.forEach(T,function(A){var U=_.node(A).parent,L=E.edge(A,U),F=!1;L||(L=E.edge(U,A),F=!0),E.node(A).rank=E.node(U).rank+(F?L.minlen:-L.minlen)})}function j(_,E,R){return _.hasEdge(E,R)}function b(_,E,R){return R.low<=E.lim&&E.lim<=R.lim}return Fv}var Bv,cR;function Oee(){if(cR)return Bv;cR=1;var e=$d(),t=e.longestPath,n=mL(),r=Iee();Bv=s;function s(d){switch(d.graph().ranker){case"network-simplex":c(d);break;case"tight-tree":l(d);break;case"longest-path":o(d);break;default:c(d)}}var o=t;function l(d){t(d),n(d)}function c(d){r(d)}return Bv}var qv,uR;function Lee(){if(uR)return qv;uR=1;var e=dt();qv=t;function t(s){var o=r(s);e.forEach(s.graph().dummyChains,function(l){for(var c=s.node(l),d=c.edgeObj,h=n(s,o,d.v,d.w),f=h.path,p=h.lca,g=0,v=f[g],N=!0;l!==d.w;){if(c=s.node(l),N){for(;(v=f[g])!==p&&s.node(v).maxRank<c.rank;)g++;v===p&&(N=!1)}if(!N){for(;g<f.length-1&&s.node(v=f[g+1]).minRank<=c.rank;)g++;v=f[g]}s.setParent(l,v),l=s.successors(l)[0]}})}function n(s,o,l,c){var d=[],h=[],f=Math.min(o[l].low,o[c].low),p=Math.max(o[l].lim,o[c].lim),g,v;g=l;do g=s.parent(g),d.push(g);while(g&&(o[g].low>f||p>o[g].lim));for(v=g,g=c;(g=s.parent(g))!==v;)h.push(g);return{path:d.concat(h.reverse()),lca:v}}function r(s){var o={},l=0;function c(d){var h=l;e.forEach(s.children(d),c),o[d]={low:h,lim:l++}}return e.forEach(s.children(),c),o}return qv}var Uv,dR;function Pee(){if(dR)return Uv;dR=1;var e=dt(),t=fn();Uv={run:n,cleanup:l};function n(c){var d=t.addDummyNode(c,"root",{},"_root"),h=s(c),f=e.max(e.values(h))-1,p=2*f+1;c.graph().nestingRoot=d,e.forEach(c.edges(),function(v){c.edge(v).minlen*=p});var g=o(c)+1;e.forEach(c.children(),function(v){r(c,d,p,g,f,h,v)}),c.graph().nodeRankFactor=p}function r(c,d,h,f,p,g,v){var N=c.children(v);if(!N.length){v!==d&&c.setEdge(d,v,{weight:0,minlen:h});return}var k=t.addBorderNode(c,"_bt"),x=t.addBorderNode(c,"_bb"),j=c.node(v);c.setParent(k,v),j.borderTop=k,c.setParent(x,v),j.borderBottom=x,e.forEach(N,function(b){r(c,d,h,f,p,g,b);var _=c.node(b),E=_.borderTop?_.borderTop:b,R=_.borderBottom?_.borderBottom:b,T=_.borderTop?f:2*f,A=E!==R?1:p-g[v]+1;c.setEdge(k,E,{weight:T,minlen:A,nestingEdge:!0}),c.setEdge(R,x,{weight:T,minlen:A,nestingEdge:!0})}),c.parent(v)||c.setEdge(d,k,{weight:0,minlen:p+g[v]})}function s(c){var d={};function h(f,p){var g=c.children(f);g&&g.length&&e.forEach(g,function(v){h(v,p+1)}),d[f]=p}return e.forEach(c.children(),function(f){h(f,1)}),d}function o(c){return e.reduce(c.edges(),function(d,h){return d+c.edge(h).weight},0)}function l(c){var d=c.graph();c.removeNode(d.nestingRoot),delete d.nestingRoot,e.forEach(c.edges(),function(h){var f=c.edge(h);f.nestingEdge&&c.removeEdge(h)})}return Uv}var zv,hR;function Dee(){if(hR)return zv;hR=1;var e=dt(),t=fn();zv=n;function n(s){function o(l){var c=s.children(l),d=s.node(l);if(c.length&&e.forEach(c,o),e.has(d,"minRank")){d.borderLeft=[],d.borderRight=[];for(var h=d.minRank,f=d.maxRank+1;h<f;++h)r(s,"borderLeft","_bl",l,d,h),r(s,"borderRight","_br",l,d,h)}}e.forEach(s.children(),o)}function r(s,o,l,c,d,h){var f={width:0,height:0,rank:h,borderType:o},p=d[o][h-1],g=t.addDummyNode(s,"border",f,l);d[o][h]=g,s.setParent(g,c),p&&s.setEdge(p,g,{weight:1})}return zv}var Wv,fR;function Fee(){if(fR)return Wv;fR=1;var e=dt();Wv={adjust:t,undo:n};function t(h){var f=h.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&r(h)}function n(h){var f=h.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&o(h),(f==="lr"||f==="rl")&&(c(h),r(h))}function r(h){e.forEach(h.nodes(),function(f){s(h.node(f))}),e.forEach(h.edges(),function(f){s(h.edge(f))})}function s(h){var f=h.width;h.width=h.height,h.height=f}function o(h){e.forEach(h.nodes(),function(f){l(h.node(f))}),e.forEach(h.edges(),function(f){var p=h.edge(f);e.forEach(p.points,l),e.has(p,"y")&&l(p)})}function l(h){h.y=-h.y}function c(h){e.forEach(h.nodes(),function(f){d(h.node(f))}),e.forEach(h.edges(),function(f){var p=h.edge(f);e.forEach(p.points,d),e.has(p,"x")&&d(p)})}function d(h){var f=h.x;h.x=h.y,h.y=f}return Wv}var Hv,pR;function Bee(){if(pR)return Hv;pR=1;var e=dt();Hv=t;function t(n){var r={},s=e.filter(n.nodes(),function(h){return!n.children(h).length}),o=e.max(e.map(s,function(h){return n.node(h).rank})),l=e.map(e.range(o+1),function(){return[]});function c(h){if(!e.has(r,h)){r[h]=!0;var f=n.node(h);l[f.rank].push(h),e.forEach(n.successors(h),c)}}var d=e.sortBy(s,function(h){return n.node(h).rank});return e.forEach(d,c),l}return Hv}var Vv,mR;function qee(){if(mR)return Vv;mR=1;var e=dt();Vv=t;function t(r,s){for(var o=0,l=1;l<s.length;++l)o+=n(r,s[l-1],s[l]);return o}function n(r,s,o){for(var l=e.zipObject(o,e.map(o,function(g,v){return v})),c=e.flatten(e.map(s,function(g){return e.sortBy(e.map(r.outEdges(g),function(v){return{pos:l[v.w],weight:r.edge(v).weight}}),"pos")}),!0),d=1;d<o.length;)d<<=1;var h=2*d-1;d-=1;var f=e.map(new Array(h),function(){return 0}),p=0;return e.forEach(c.forEach(function(g){var v=g.pos+d;f[v]+=g.weight;for(var N=0;v>0;)v%2&&(N+=f[v+1]),v=v-1>>1,f[v]+=g.weight;p+=g.weight*N})),p}return Vv}var Gv,gR;function Uee(){if(gR)return Gv;gR=1;var e=dt();Gv=t;function t(n,r){return e.map(r,function(s){var o=n.inEdges(s);if(o.length){var l=e.reduce(o,function(c,d){var h=n.edge(d),f=n.node(d.v);return{sum:c.sum+h.weight*f.order,weight:c.weight+h.weight}},{sum:0,weight:0});return{v:s,barycenter:l.sum/l.weight,weight:l.weight}}else return{v:s}})}return Gv}var Kv,yR;function zee(){if(yR)return Kv;yR=1;var e=dt();Kv=t;function t(s,o){var l={};e.forEach(s,function(d,h){var f=l[d.v]={indegree:0,in:[],out:[],vs:[d.v],i:h};e.isUndefined(d.barycenter)||(f.barycenter=d.barycenter,f.weight=d.weight)}),e.forEach(o.edges(),function(d){var h=l[d.v],f=l[d.w];!e.isUndefined(h)&&!e.isUndefined(f)&&(f.indegree++,h.out.push(l[d.w]))});var c=e.filter(l,function(d){return!d.indegree});return n(c)}function n(s){var o=[];function l(h){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(h.barycenter)||f.barycenter>=h.barycenter)&&r(h,f)}}function c(h){return function(f){f.in.push(h),--f.indegree===0&&s.push(f)}}for(;s.length;){var d=s.pop();o.push(d),e.forEach(d.in.reverse(),l(d)),e.forEach(d.out,c(d))}return e.map(e.filter(o,function(h){return!h.merged}),function(h){return e.pick(h,["vs","i","barycenter","weight"])})}function r(s,o){var l=0,c=0;s.weight&&(l+=s.barycenter*s.weight,c+=s.weight),o.weight&&(l+=o.barycenter*o.weight,c+=o.weight),s.vs=o.vs.concat(s.vs),s.barycenter=l/c,s.weight=c,s.i=Math.min(o.i,s.i),o.merged=!0}return Kv}var Yv,wR;function Wee(){if(wR)return Yv;wR=1;var e=dt(),t=fn();Yv=n;function n(o,l){var c=t.partition(o,function(k){return e.has(k,"barycenter")}),d=c.lhs,h=e.sortBy(c.rhs,function(k){return-k.i}),f=[],p=0,g=0,v=0;d.sort(s(!!l)),v=r(f,h,v),e.forEach(d,function(k){v+=k.vs.length,f.push(k.vs),p+=k.barycenter*k.weight,g+=k.weight,v=r(f,h,v)});var N={vs:e.flatten(f,!0)};return g&&(N.barycenter=p/g,N.weight=g),N}function r(o,l,c){for(var d;l.length&&(d=e.last(l)).i<=c;)l.pop(),o.push(d.vs),c++;return c}function s(o){return function(l,c){return l.barycenter<c.barycenter?-1:l.barycenter>c.barycenter?1:o?c.i-l.i:l.i-c.i}}return Yv}var Xv,vR;function Hee(){if(vR)return Xv;vR=1;var e=dt(),t=Uee(),n=zee(),r=Wee();Xv=s;function s(c,d,h,f){var p=c.children(d),g=c.node(d),v=g?g.borderLeft:void 0,N=g?g.borderRight:void 0,k={};v&&(p=e.filter(p,function(R){return R!==v&&R!==N}));var x=t(c,p);e.forEach(x,function(R){if(c.children(R.v).length){var T=s(c,R.v,h,f);k[R.v]=T,e.has(T,"barycenter")&&l(R,T)}});var j=n(x,h);o(j,k);var b=r(j,f);if(v&&(b.vs=e.flatten([v,b.vs,N],!0),c.predecessors(v).length)){var _=c.node(c.predecessors(v)[0]),E=c.node(c.predecessors(N)[0]);e.has(b,"barycenter")||(b.barycenter=0,b.weight=0),b.barycenter=(b.barycenter*b.weight+_.order+E.order)/(b.weight+2),b.weight+=2}return b}function o(c,d){e.forEach(c,function(h){h.vs=e.flatten(h.vs.map(function(f){return d[f]?d[f].vs:f}),!0)})}function l(c,d){e.isUndefined(c.barycenter)?(c.barycenter=d.barycenter,c.weight=d.weight):(c.barycenter=(c.barycenter*c.weight+d.barycenter*d.weight)/(c.weight+d.weight),c.weight+=d.weight)}return Xv}var Zv,xR;function Vee(){if(xR)return Zv;xR=1;var e=dt(),t=hr().Graph;Zv=n;function n(s,o,l){var c=r(s),d=new t({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return s.node(h)});return e.forEach(s.nodes(),function(h){var f=s.node(h),p=s.parent(h);(f.rank===o||f.minRank<=o&&o<=f.maxRank)&&(d.setNode(h),d.setParent(h,p||c),e.forEach(s[l](h),function(g){var v=g.v===h?g.w:g.v,N=d.edge(v,h),k=e.isUndefined(N)?0:N.weight;d.setEdge(v,h,{weight:s.edge(g).weight+k})}),e.has(f,"minRank")&&d.setNode(h,{borderLeft:f.borderLeft[o],borderRight:f.borderRight[o]}))}),d}function r(s){for(var o;s.hasNode(o=e.uniqueId("_root")););return o}return Zv}var Jv,bR;function Gee(){if(bR)return Jv;bR=1;var e=dt();Jv=t;function t(n,r,s){var o={},l;e.forEach(s,function(c){for(var d=n.parent(c),h,f;d;){if(h=n.parent(d),h?(f=o[h],o[h]=d):(f=l,l=d),f&&f!==d){r.setEdge(f,d);return}d=h}})}return Jv}var Qv,kR;function Kee(){if(kR)return Qv;kR=1;var e=dt(),t=Bee(),n=qee(),r=Hee(),s=Vee(),o=Gee(),l=hr().Graph,c=fn();Qv=d;function d(g){var v=c.maxRank(g),N=h(g,e.range(1,v+1),"inEdges"),k=h(g,e.range(v-1,-1,-1),"outEdges"),x=t(g);p(g,x);for(var j=Number.POSITIVE_INFINITY,b,_=0,E=0;E<4;++_,++E){f(_%2?N:k,_%4>=2),x=c.buildLayerMatrix(g);var R=n(g,x);R<j&&(E=0,b=e.cloneDeep(x),j=R)}p(g,b)}function h(g,v,N){return e.map(v,function(k){return s(g,k,N)})}function f(g,v){var N=new l;e.forEach(g,function(k){var x=k.graph().root,j=r(k,x,N,v);e.forEach(j.vs,function(b,_){k.node(b).order=_}),o(k,N,j.vs)})}function p(g,v){e.forEach(v,function(N){e.forEach(N,function(k,x){g.node(k).order=x})})}return Qv}var ex,NR;function Yee(){if(NR)return ex;NR=1;var e=dt(),t=hr().Graph,n=fn();ex={positionX:N,findType1Conflicts:r,findType2Conflicts:s,addConflict:l,hasConflict:c,verticalAlignment:d,horizontalCompaction:h,alignCoordinates:g,findSmallestWidthAlignment:p,balance:v};function r(j,b){var _={};function E(R,T){var A=0,U=0,L=R.length,F=e.last(T);return e.forEach(T,function(O,I){var B=o(j,O),M=B?j.node(B).order:L;(B||O===F)&&(e.forEach(T.slice(U,I+1),function($){e.forEach(j.predecessors($),function(P){var G=j.node(P),K=G.order;(K<A||M<K)&&!(G.dummy&&j.node($).dummy)&&l(_,P,$)})}),U=I+1,A=M)}),T}return e.reduce(b,E),_}function s(j,b){var _={};function E(T,A,U,L,F){var O;e.forEach(e.range(A,U),function(I){O=T[I],j.node(O).dummy&&e.forEach(j.predecessors(O),function(B){var M=j.node(B);M.dummy&&(M.order<L||M.order>F)&&l(_,B,O)})})}function R(T,A){var U=-1,L,F=0;return e.forEach(A,function(O,I){if(j.node(O).dummy==="border"){var B=j.predecessors(O);B.length&&(L=j.node(B[0]).order,E(A,F,I,U,L),F=I,U=L)}E(A,F,A.length,L,T.length)}),A}return e.reduce(b,R),_}function o(j,b){if(j.node(b).dummy)return e.find(j.predecessors(b),function(_){return j.node(_).dummy})}function l(j,b,_){if(b>_){var E=b;b=_,_=E}var R=j[b];R||(j[b]=R={}),R[_]=!0}function c(j,b,_){if(b>_){var E=b;b=_,_=E}return e.has(j[b],_)}function d(j,b,_,E){var R={},T={},A={};return e.forEach(b,function(U){e.forEach(U,function(L,F){R[L]=L,T[L]=L,A[L]=F})}),e.forEach(b,function(U){var L=-1;e.forEach(U,function(F){var O=E(F);if(O.length){O=e.sortBy(O,function(P){return A[P]});for(var I=(O.length-1)/2,B=Math.floor(I),M=Math.ceil(I);B<=M;++B){var $=O[B];T[F]===F&&L<A[$]&&!c(_,F,$)&&(T[$]=F,T[F]=R[F]=R[$],L=A[$])}}})}),{root:R,align:T}}function h(j,b,_,E,R){var T={},A=f(j,b,_,R),U=R?"borderLeft":"borderRight";function L(I,B){for(var M=A.nodes(),$=M.pop(),P={};$;)P[$]?I($):(P[$]=!0,M.push($),M=M.concat(B($))),$=M.pop()}function F(I){T[I]=A.inEdges(I).reduce(function(B,M){return Math.max(B,T[M.v]+A.edge(M))},0)}function O(I){var B=A.outEdges(I).reduce(function($,P){return Math.min($,T[P.w]-A.edge(P))},Number.POSITIVE_INFINITY),M=j.node(I);B!==Number.POSITIVE_INFINITY&&M.borderType!==U&&(T[I]=Math.max(T[I],B))}return L(F,A.predecessors.bind(A)),L(O,A.successors.bind(A)),e.forEach(E,function(I){T[I]=T[_[I]]}),T}function f(j,b,_,E){var R=new t,T=j.graph(),A=k(T.nodesep,T.edgesep,E);return e.forEach(b,function(U){var L;e.forEach(U,function(F){var O=_[F];if(R.setNode(O),L){var I=_[L],B=R.edge(I,O);R.setEdge(I,O,Math.max(A(j,F,L),B||0))}L=F})}),R}function p(j,b){return e.minBy(e.values(b),function(_){var E=Number.NEGATIVE_INFINITY,R=Number.POSITIVE_INFINITY;return e.forIn(_,function(T,A){var U=x(j,A)/2;E=Math.max(T+U,E),R=Math.min(T-U,R)}),E-R})}function g(j,b){var _=e.values(b),E=e.min(_),R=e.max(_);e.forEach(["u","d"],function(T){e.forEach(["l","r"],function(A){var U=T+A,L=j[U],F;if(L!==b){var O=e.values(L);F=A==="l"?E-e.min(O):R-e.max(O),F&&(j[U]=e.mapValues(L,function(I){return I+F}))}})})}function v(j,b){return e.mapValues(j.ul,function(_,E){if(b)return j[b.toLowerCase()][E];var R=e.sortBy(e.map(j,E));return(R[1]+R[2])/2})}function N(j){var b=n.buildLayerMatrix(j),_=e.merge(r(j,b),s(j,b)),E={},R;e.forEach(["u","d"],function(A){R=A==="u"?b:e.values(b).reverse(),e.forEach(["l","r"],function(U){U==="r"&&(R=e.map(R,function(I){return e.values(I).reverse()}));var L=(A==="u"?j.predecessors:j.successors).bind(j),F=d(j,R,_,L),O=h(j,R,F.root,F.align,U==="r");U==="r"&&(O=e.mapValues(O,function(I){return-I})),E[A+U]=O})});var T=p(j,E);return g(E,T),v(E,j.graph().align)}function k(j,b,_){return function(E,R,T){var A=E.node(R),U=E.node(T),L=0,F;if(L+=A.width/2,e.has(A,"labelpos"))switch(A.labelpos.toLowerCase()){case"l":F=-A.width/2;break;case"r":F=A.width/2;break}if(F&&(L+=_?F:-F),F=0,L+=(A.dummy?b:j)/2,L+=(U.dummy?b:j)/2,L+=U.width/2,e.has(U,"labelpos"))switch(U.labelpos.toLowerCase()){case"l":F=U.width/2;break;case"r":F=-U.width/2;break}return F&&(L+=_?F:-F),F=0,L}}function x(j,b){return j.node(b).width}return ex}var tx,jR;function Xee(){if(jR)return tx;jR=1;var e=dt(),t=fn(),n=Yee().positionX;tx=r;function r(o){o=t.asNonCompoundGraph(o),s(o),e.forEach(n(o),function(l,c){o.node(c).x=l})}function s(o){var l=t.buildLayerMatrix(o),c=o.graph().ranksep,d=0;e.forEach(l,function(h){var f=e.max(e.map(h,function(p){return o.node(p).height}));e.forEach(h,function(p){o.node(p).y=d+f/2}),d+=f+c})}return tx}var nx,SR;function Zee(){if(SR)return nx;SR=1;var e=dt(),t=Mee(),n=$ee(),r=Oee(),s=fn().normalizeRanks,o=Lee(),l=fn().removeEmptyRanks,c=Pee(),d=Dee(),h=Fee(),f=Kee(),p=Xee(),g=fn(),v=hr().Graph;nx=N;function N(V,X){var Y=X&&X.debugTiming?g.time:g.notime;Y("layout",function(){var Z=Y(" buildLayoutGraph",function(){return L(V)});Y(" runLayout",function(){k(Z,Y)}),Y(" updateInputGraph",function(){x(V,Z)})})}function k(V,X){X(" makeSpaceForEdgeLabels",function(){F(V)}),X(" removeSelfEdges",function(){q(V)}),X(" acyclic",function(){t.run(V)}),X(" nestingGraph.run",function(){c.run(V)}),X(" rank",function(){r(g.asNonCompoundGraph(V))}),X(" injectEdgeLabelProxies",function(){O(V)}),X(" removeEmptyRanks",function(){l(V)}),X(" nestingGraph.cleanup",function(){c.cleanup(V)}),X(" normalizeRanks",function(){s(V)}),X(" assignRankMinMax",function(){I(V)}),X(" removeEdgeLabelProxies",function(){B(V)}),X(" normalize.run",function(){n.run(V)}),X(" parentDummyChains",function(){o(V)}),X(" addBorderSegments",function(){d(V)}),X(" order",function(){f(V)}),X(" insertSelfEdges",function(){H(V)}),X(" adjustCoordinateSystem",function(){h.adjust(V)}),X(" position",function(){p(V)}),X(" positionSelfEdges",function(){D(V)}),X(" removeBorderNodes",function(){K(V)}),X(" normalize.undo",function(){n.undo(V)}),X(" fixupEdgeLabelCoords",function(){P(V)}),X(" undoCoordinateSystem",function(){h.undo(V)}),X(" translateGraph",function(){M(V)}),X(" assignNodeIntersects",function(){$(V)}),X(" reversePoints",function(){G(V)}),X(" acyclic.undo",function(){t.undo(V)})}function x(V,X){e.forEach(V.nodes(),function(Y){var Z=V.node(Y),ee=X.node(Y);Z&&(Z.x=ee.x,Z.y=ee.y,X.children(Y).length&&(Z.width=ee.width,Z.height=ee.height))}),e.forEach(V.edges(),function(Y){var Z=V.edge(Y),ee=X.edge(Y);Z.points=ee.points,e.has(ee,"x")&&(Z.x=ee.x,Z.y=ee.y)}),V.graph().width=X.graph().width,V.graph().height=X.graph().height}var j=["nodesep","edgesep","ranksep","marginx","marginy"],b={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},_=["acyclicer","ranker","rankdir","align"],E=["width","height"],R={width:0,height:0},T=["minlen","weight","width","height","labeloffset"],A={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},U=["labelpos"];function L(V){var X=new v({multigraph:!0,compound:!0}),Y=J(V.graph());return X.setGraph(e.merge({},b,W(Y,j),e.pick(Y,_))),e.forEach(V.nodes(),function(Z){var ee=J(V.node(Z));X.setNode(Z,e.defaults(W(ee,E),R)),X.setParent(Z,V.parent(Z))}),e.forEach(V.edges(),function(Z){var ee=J(V.edge(Z));X.setEdge(Z,e.merge({},A,W(ee,T),e.pick(ee,U)))}),X}function F(V){var X=V.graph();X.ranksep/=2,e.forEach(V.edges(),function(Y){var Z=V.edge(Y);Z.minlen*=2,Z.labelpos.toLowerCase()!=="c"&&(X.rankdir==="TB"||X.rankdir==="BT"?Z.width+=Z.labeloffset:Z.height+=Z.labeloffset)})}function O(V){e.forEach(V.edges(),function(X){var Y=V.edge(X);if(Y.width&&Y.height){var Z=V.node(X.v),ee=V.node(X.w),ne={rank:(ee.rank-Z.rank)/2+Z.rank,e:X};g.addDummyNode(V,"edge-proxy",ne,"_ep")}})}function I(V){var X=0;e.forEach(V.nodes(),function(Y){var Z=V.node(Y);Z.borderTop&&(Z.minRank=V.node(Z.borderTop).rank,Z.maxRank=V.node(Z.borderBottom).rank,X=e.max(X,Z.maxRank))}),V.graph().maxRank=X}function B(V){e.forEach(V.nodes(),function(X){var Y=V.node(X);Y.dummy==="edge-proxy"&&(V.edge(Y.e).labelRank=Y.rank,V.removeNode(X))})}function M(V){var X=Number.POSITIVE_INFINITY,Y=0,Z=Number.POSITIVE_INFINITY,ee=0,ne=V.graph(),se=ne.marginx||0,pe=ne.marginy||0;function ke(ae){var fe=ae.x,me=ae.y,he=ae.width,ge=ae.height;X=Math.min(X,fe-he/2),Y=Math.max(Y,fe+he/2),Z=Math.min(Z,me-ge/2),ee=Math.max(ee,me+ge/2)}e.forEach(V.nodes(),function(ae){ke(V.node(ae))}),e.forEach(V.edges(),function(ae){var fe=V.edge(ae);e.has(fe,"x")&&ke(fe)}),X-=se,Z-=pe,e.forEach(V.nodes(),function(ae){var fe=V.node(ae);fe.x-=X,fe.y-=Z}),e.forEach(V.edges(),function(ae){var fe=V.edge(ae);e.forEach(fe.points,function(me){me.x-=X,me.y-=Z}),e.has(fe,"x")&&(fe.x-=X),e.has(fe,"y")&&(fe.y-=Z)}),ne.width=Y-X+se,ne.height=ee-Z+pe}function $(V){e.forEach(V.edges(),function(X){var Y=V.edge(X),Z=V.node(X.v),ee=V.node(X.w),ne,se;Y.points?(ne=Y.points[0],se=Y.points[Y.points.length-1]):(Y.points=[],ne=ee,se=Z),Y.points.unshift(g.intersectRect(Z,ne)),Y.points.push(g.intersectRect(ee,se))})}function P(V){e.forEach(V.edges(),function(X){var Y=V.edge(X);if(e.has(Y,"x"))switch((Y.labelpos==="l"||Y.labelpos==="r")&&(Y.width-=Y.labeloffset),Y.labelpos){case"l":Y.x-=Y.width/2+Y.labeloffset;break;case"r":Y.x+=Y.width/2+Y.labeloffset;break}})}function G(V){e.forEach(V.edges(),function(X){var Y=V.edge(X);Y.reversed&&Y.points.reverse()})}function K(V){e.forEach(V.nodes(),function(X){if(V.children(X).length){var Y=V.node(X),Z=V.node(Y.borderTop),ee=V.node(Y.borderBottom),ne=V.node(e.last(Y.borderLeft)),se=V.node(e.last(Y.borderRight));Y.width=Math.abs(se.x-ne.x),Y.height=Math.abs(ee.y-Z.y),Y.x=ne.x+Y.width/2,Y.y=Z.y+Y.height/2}}),e.forEach(V.nodes(),function(X){V.node(X).dummy==="border"&&V.removeNode(X)})}function q(V){e.forEach(V.edges(),function(X){if(X.v===X.w){var Y=V.node(X.v);Y.selfEdges||(Y.selfEdges=[]),Y.selfEdges.push({e:X,label:V.edge(X)}),V.removeEdge(X)}})}function H(V){var X=g.buildLayerMatrix(V);e.forEach(X,function(Y){var Z=0;e.forEach(Y,function(ee,ne){var se=V.node(ee);se.order=ne+Z,e.forEach(se.selfEdges,function(pe){g.addDummyNode(V,"selfedge",{width:pe.label.width,height:pe.label.height,rank:se.rank,order:ne+ ++Z,e:pe.e,label:pe.label},"_se")}),delete se.selfEdges})})}function D(V){e.forEach(V.nodes(),function(X){var Y=V.node(X);if(Y.dummy==="selfedge"){var Z=V.node(Y.e.v),ee=Z.x+Z.width/2,ne=Z.y,se=Y.x-ee,pe=Z.height/2;V.setEdge(Y.e,Y.label),V.removeNode(X),Y.label.points=[{x:ee+2*se/3,y:ne-pe},{x:ee+5*se/6,y:ne-pe},{x:ee+se,y:ne},{x:ee+5*se/6,y:ne+pe},{x:ee+2*se/3,y:ne+pe}],Y.label.x=Y.x,Y.label.y=Y.y}})}function W(V,X){return e.mapValues(e.pick(V,X),Number)}function J(V){var X={};return e.forEach(V,function(Y,Z){X[Z.toLowerCase()]=Y}),X}return nx}var rx,_R;function Jee(){if(_R)return rx;_R=1;var e=dt(),t=fn(),n=hr().Graph;rx={debugOrdering:r};function r(s){var o=t.buildLayerMatrix(s),l=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(s.nodes(),function(c){l.setNode(c,{label:c}),l.setParent(c,"layer"+s.node(c).rank)}),e.forEach(s.edges(),function(c){l.setEdge(c.v,c.w,{},c.name)}),e.forEach(o,function(c,d){var h="layer"+d;l.setNode(h,{rank:"same"}),e.reduce(c,function(f,p){return l.setEdge(f,p,{style:"invis"}),p})}),l}return rx}var sx,ER;function Qee(){return ER||(ER=1,sx="0.8.5"),sx}var ax,CR;function ete(){return CR||(CR=1,ax={graphlib:hr(),layout:Zee(),debug:Jee(),util:{time:fn().time,notime:fn().notime},version:Qee()}),ax}var tte=ete();const TR=_b(tte),tc=240,gL=130,hb=Ua*2+Fx+W$,nte=72,ii=hb+nte,ad=24,yL=Ua*2+ad,Id=ii;function wL(e,t){var r;let n=tc;for(const s of e)n=Math.max(n,((r=t.get(s.id))==null?void 0:r.width)??tc);return n}const Od=420,vL=1;function rte(e,t,n,r){return Math.min(vL,n/Math.max(1,e),r/Math.max(1,t))}function Mh(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function $h(e,t=()=>!0){const n=new Map;for(const r of e){if(!t(r))continue;const s=Mh(r),o=n.get(s);o?o.push(r):n.set(s,[r])}return n}function ste(e,t){return((t==null?void 0:t.get(e))??0)>0?Od:0}function ate(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function Ld(e,t){const n=t.get(e);return{w:(n==null?void 0:n.width)??tc,h:(n==null?void 0:n.height)??gL}}function nc(e,t,n){const r=Ld(e,t);return{w:r.w+ste(e,n),h:Math.max(r.h,ate(e,n))}}function ote(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function ite(e,t,n){const r=$h(e,s=>!t.has(s.id)&&n(s.id)!=null);if(r.size===0)return e;for(const s of r.values())s.sort((o,l)=>o.id.localeCompare(l.id));return e.map(s=>{var h;if(t.has(s.id)||n(s.id))return s;const o=r.get(Mh(s));if(!o)return s;const l=(h=s.data)==null?void 0:h.parentId,c=o.find(f=>f.id===l)??o[0],d=n(c.id);return{...s,position:{x:s.position.x+d.x-c.position.x,y:s.position.y+d.y-c.position.y}}})}function lte(e,t,n,r,s,o,l){const c=_=>nc(_,r,o),d=_=>n.get(_)??t.get(_),h=_=>{const{w:E,h:R}=Ld(_,r);return{cw:E,ch:R}},f=l!=null&&l.width>0&&l.height>0,p=$h(e,_=>d(_.id)!=null),g=new Set;for(const[_,E]of p)E.every(R=>s.has(R.id)&&!n.has(R.id))&&g.add(_);const v=new Map,N=[];for(const _ of e){const E=d(_.id);if(!E)continue;const{w:R,h:T}=c(_.id),A=Mh(_);g.has(A)?(v.get(A)??v.set(A,[]).get(A)).push(_):N.push({x:E.x,y:E.y,w:R,h:T,...h(_.id)})}if(v.size===0||f&&N.length===0)return[];const k=Id,x=(_,E,R,T)=>N.some(A=>_<A.x+A.w+hb&&A.x<_+R+hb&&E<A.y+A.h+k&&A.y<E+T+k),j=wL(e,r),b=[];for(const _ of[...v.keys()].sort()){const E=v.get(_);let R=1/0,T=1/0,A=-1/0,U=-1/0,L=-1/0,F=-1/0;for(const G of E){const K=d(G.id),{w:q,h:H}=c(G.id),{cw:D,ch:W}=h(G.id);R=Math.min(R,K.x),T=Math.min(T,K.y),A=Math.max(A,K.x+q),U=Math.max(U,K.y+H),L=Math.max(L,K.x+D),F=Math.max(F,K.y+W)}const O=A-R,I=U-T,B=[...new Set(N.map(G=>Math.round(G.x)))].sort((G,K)=>G-K),M=B.length?B:[R],$=[0,...N.map(G=>G.y+G.h+k)].sort((G,K)=>G-K);let P=null;if(f){let G=1/0,K=1/0,q=-1/0,H=-1/0;for(const Y of N)G=Math.min(G,Y.x),K=Math.min(K,Y.y),q=Math.max(q,Y.x+Y.cw),H=Math.max(H,Y.y+Y.ch);const D=(Y,Z)=>{const ee=l.width/(Math.max(q,Y+L-R)-Math.min(G,Y)+Od),ne=l.height/(Math.max(H,Z+F-T)-Math.min(K,Z));return[Math.min(vL,ee,ne),Math.min(ee,ne),Math.max(ee,ne)]},W=(Y,Z)=>{for(let ee=0;ee<Y.length;ee++){if(Y[ee]>Z[ee]+1e-9)return!0;if(Y[ee]<Z[ee]-1e-9)return!1}return!1},J=Math.round(q+Od+j),V=[...new Set([...$,K])].sort((Y,Z)=>Y-Z);let X=null;for(const Y of[...M,J])for(const Z of V){if(x(Y,Z,O,I))continue;const ee=D(Y,Z);(X===null||W(ee,X))&&(X=ee,P={x:Y,y:Z})}P&&P.x===R&&P.y===T&&(P=null)}else e:for(const G of M)for(const K of $){if(K>=T)break;if(!x(G,K,O,I)){P={x:G,y:K};break e}}if(P){const G=P.x-R,K=P.y-T;for(const q of E){const H=d(q.id);t.set(q.id,{x:H.x+G,y:H.y+K})}b.push(_)}for(const G of E){const K=d(G.id),{w:q,h:H}=c(G.id);N.push({x:K.x,y:K.y,w:q,h:H,...h(G.id)})}}return b}function cte(e,t,n,r,s,o){const l=g=>nc(g,r,s),c=new Map(e.map(g=>[g.id,Mh(g)])),d=[],h=e.map(g=>({id:g.id,pos:n.get(g.id)??t.get(g.id)})).filter(g=>g.pos!=null).sort((g,v)=>g.pos.y-v.pos.y||g.pos.x-v.pos.x||g.id.localeCompare(v.id)),f=g=>(o==null?void 0:o.has(g))===!0&&!n.has(g);for(const{id:g,pos:v}of h){if(!f(g))continue;const{w:N,h:k}=l(g);d.push({x:v.x,y:v.y,w:N,h:k,sid:c.get(g)??"_default"})}const p=[];for(const{id:g,pos:v}of h){if(f(g))continue;const{w:N,h:k}=l(g),x=c.get(g)??"_default";if(n.has(g)){d.push({x:v.x,y:v.y,w:N,h:k,sid:x});continue}let j=v.y;for(let b=0;b<d.length+1;b++){const _=d.find(E=>{const R=E.sid===x?ad:yL,T=E.sid===x?ad:Id;return v.x<E.x+E.w+R&&E.x<v.x+N+R&&j<E.y+E.h+T&&E.y<j+k+T});if(!_)break;j=_.y+_.h+(_.sid===x?ad:Id)}j!==v.y&&(t.set(g,{x:v.x,y:j}),p.push(g)),d.push({x:v.x,y:j,w:N,h:k,sid:x})}return p}function ute(e,t,n,r,s,o=!1,l){const d=yL+1,h=Id+1,f=8,p=1.75,g=200,v=.7,N=.01,k=I=>nc(I,r,l),x=I=>n.get(I)??t.get(I),j=$h(e,I=>x(I.id)!=null),b=[],_=new Set,E=new Set,R=s.size===0;for(const I of[...j.keys()].sort()){const B=j.get(I);let M=1/0,$=1/0,P=-1/0,G=-1/0,K=!1;for(const W of B){const J=x(W.id),{w:V,h:X}=k(W.id);M=Math.min(M,J.x),$=Math.min($,J.y),P=Math.max(P,J.x+V),G=Math.max(G,J.y+X),n.has(W.id)&&(K=!0)}const q=P-M,H=G-$;E.add(I);const D=s.get(I);D&&(q>D.w+f||H>D.h+f)&&_.add(I),s.set(I,{w:q,h:H}),b.push({sid:I,members:B.map(W=>W.id),x:M,y:$,w:q,h:H,anchored:K,mass:1})}for(const I of[...s.keys()])E.has(I)||s.delete(I);if(o||R)return[];let T=!1;for(let I=0;I<b.length&&!T;I++)for(let B=I+1;B<b.length;B++){const M=b[I],$=b[B];if(!(M.anchored&&$.anchored)&&Math.abs(M.x+M.w/2-($.x+$.w/2))<(M.w+$.w)/2+d&&Math.abs(M.y+M.h/2-($.y+$.h/2))<(M.h+$.h)/2+h){T=!0;break}}if(_.size===0&&!T)return[];if(_.size>0)for(const I of b)_.has(I.sid)&&(I.mass=8);else for(const I of b)I.mass=Math.max(1,I.w*I.h/(tc*gL));const A=new Map(b.map(I=>[I.sid,I.x])),U=new Map(b.map(I=>[I.sid,I.y])),L=new Map(b.map(I=>[I.sid,Math.min(0,I.x)])),F=new Map(b.map(I=>[I.sid,Math.min(0,I.y)]));for(let I=0;I<g;I++){const B=new Map,M=new Map;let $=0;for(let P=0;P<b.length;P++)for(let G=P+1;G<b.length;G++){const K=b[P],q=b[G];if(K.anchored&&q.anchored)continue;const H=K.x+K.w/2,D=K.y+K.h/2,W=q.x+q.w/2,J=q.y+q.h/2,V=(K.w+q.w)/2+d-Math.abs(H-W),X=(K.h+q.h)/2+h-Math.abs(D-J);if(V<=0||X<=0)continue;const Y=(Be,We)=>!Be.anchored&&!(We<0&&Be.x<=L.get(Be.sid)),Z=(Be,We)=>!Be.anchored&&!(We<0&&Be.y<=F.get(Be.sid)),ee=(Be,We,He)=>{const rt=Be===We,lt=rt?K.sid<q.sid?-1:1:Math.sign(Be-We);return He(K,lt)||He(q,-lt)?lt:rt&&(He(K,-lt)||He(q,lt))?-lt:0},ne=ee(H,W,Y),se=ee(D,J,Z),pe=ne!==0,ke=se!==0;if(!pe&&!ke)continue;const ae=pe&&(!ke||V*p<X),[fe,me,he,ge]=ae?[ne,V,B,Y]:[se,X,M,Z],ue=ge(K,fe),be=ge(q,-fe),oe=K.mass,je=q.mass,$e=ue?be?je/(oe+je):1:0,Oe=be?ue?oe/(oe+je):1:0,Ue=me*v;he.set(K.sid,(he.get(K.sid)??0)+fe*Ue*$e),he.set(q.sid,(he.get(q.sid)??0)-fe*Ue*Oe),$+=Ue}for(const P of b)P.anchored||(P.x=Math.max(L.get(P.sid),P.x+(B.get(P.sid)??0)),P.y=Math.max(F.get(P.sid),P.y+(M.get(P.sid)??0)));if($<N)break}const O=[];for(const I of b){const B=I.x-A.get(I.sid),M=I.y-U.get(I.sid);if(!(Math.abs(B)<1&&Math.abs(M)<1)){for(const $ of I.members){if(n.has($))continue;const P=t.get($);P&&t.set($,{x:P.x+B,y:P.y+M})}O.push(I.sid)}}return O}function dte(e,t,n,r,s,o){const l=new TR.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(j=>!s.has(j)),d=new Set(c);for(const j of c){const{w:b,h:_}=nc(j,r,o);l.setNode(j,{width:b,height:_})}for(const j of t)d.has(j.source)&&d.has(j.target)&&l.setEdge(j.source,j.target);TR.layout(l);const h=new Map;let f=1/0,p=1/0,g=-1/0,v=-1/0;for(const j of c){const b=l.node(j);if(!b)continue;const{w:_,h:E}=Ld(j,r),R=nc(j,r,o),T=b.x-R.w/2,A=b.y-R.h/2;h.set(j,{x:T,y:A}),T<f&&(f=T),A<p&&(p=A),T+_>g&&(g=T+_),A+E>v&&(v=A+E)}if(Number.isFinite(f)&&Number.isFinite(p))for(const[j,b]of h)h.set(j,{x:b.x-f,y:b.y-p});const N=Number.isFinite(g)?g-f:0,k=Number.isFinite(v)?v-p:0;let x=null;for(const j of e){const b=s.get(j);if(!b)continue;const{w:_,h:E}=Ld(j,r);x=x===null?{minX:b.x,minY:b.y,maxX:b.x+_,maxY:b.y+E}:{minX:Math.min(x.minX,b.x),minY:Math.min(x.minY,b.y),maxX:Math.max(x.maxX,b.x+_),maxY:Math.max(x.maxY,b.y+E)}}return{positions:h,width:N,height:k,pinnedBox:x}}function xL(e,t,n){const r=n.direction??"LR",s=n.pinned??new Map,o=n.measured??new Map,l=n.lanes,c=$h(e);return{laid:Array.from(c.keys()).sort().map(f=>({sid:f,...dte(c.get(f).map(p=>p.id),t,r,o,s,l)})),gap:wL(e,o)}}const bL=e=>e.reduce((t,n)=>Math.max(t,n.width),0)+Od,hte=e=>e.reduce((t,n)=>t+n.height,0)+ii*Math.max(0,e.length-1);function fb(e,t,n,r){const s=d=>{const h=[[]];let f=0;for(const p of e)f>0&&f+p.height>d&&(h.push([]),f=0),h[h.length-1].push(p),f+=p.height+ii;return h},o=[];for(let d=0;d<e.length;d++){let h=-ii;for(let f=d;f<e.length;f++)o.push(h+=e[f].height+ii)}o.sort((d,h)=>d-h);const l=d=>{let h=0,f=o.length-1;for(;h<f;){const p=h+f>>1;s(o[p]).length<=d?f=p:h=p+1}return s(o[h])};let c=[e];if(n>0&&r>0){const d=f=>rte(f.reduce((p,g)=>p+bL(g),0)+t*(f.length-1),Math.max(...f.map(hte)),n,r);let h=d(c);for(let f=2;f<=e.length;f++){const p=l(f),g=d(p);g>h+1e-9&&(h=g,c=p)}}return c}function fte(e,t,n,r,s){if(!(r.width>0&&r.height>0&&s.width>0&&s.height>0))return!1;const{laid:o,gap:l}=xL(e,t,n);return o.length<2?!1:fb(o,l,r.width,r.height).length!==fb(o,l,s.width,s.height).length}function pte(e,t,n={}){const r=n.pinned??new Map,{laid:s,gap:o}=xL(e,t,n),l=fb(s,o,n.availableWidth??0,n.availableHeight??0),c=new Map;let d=0;for(const h of l){const f=bL(h);let p=0;for(const{positions:g,height:v,pinnedBox:N}of h){for(const[x,j]of g)c.set(x,{x:j.x+d,y:j.y+p});let k=p+v;N&&N.maxY>k&&N.minX<d+f&&d<N.maxX&&(k=N.maxY),p=k+ii}d+=f+o}return e.map(h=>{const f=r.get(h.id);if(f)return{...h,position:f};const p=c.get(h.id);return p?{...h,position:p}:h})}function od(e,t,n){return!t.has(e)||n.has(e)}function mte(e,t,n,r){return!t.has(e)&&od(e,n,r)}function gte(e,t,n){const r={x:0,y:0};return t.set(e,r),n.add(e),r}function AR(e,t,n,r){n.set(e,t),r.delete(e)}const yte=300,RR=130,wte=160,MR=new WeakMap;function vte(e,t){let n=MR.get(e);(!n||n.revision!==e.revision||n.open!==t)&&(n={revision:e.revision,open:t,byId:new Map,branches:MU(e.agents.values())},MR.set(e,n));const{byId:r,branches:s}=n;return o=>{let l=r.get(o.id);if(!l){const c=o.kind==="root"?s.get(o.sessionId):void 0;l=c?{...o,onOpenContext:t,branch:c}:{...o,onOpenContext:t},r.set(o.id,l)}return l}}function V0(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 xte(e,t){const n=l=>{var c;return((c=l.data)==null?void 0:c.sessionId)??l.id},r=new Map;for(const l of e){const c=n(l),d=l.position.x+(l.width??tc),h=r.get(c);h?(h.minX=Math.min(h.minX,l.position.x),h.maxX=Math.max(h.maxX,d),h.minY=Math.min(h.minY,l.position.y)):r.set(c,{minX:l.position.x,maxX:d,minY:l.position.y})}const s=[];for(const[l,c]of[...r].sort((d,h)=>d[1].minX-h[1].minX)){const d=s[s.length-1];d&&c.minX<d.maxX?(d.maxX=Math.max(d.maxX,c.maxX),d.sessions.push({sid:l,top:c.minY})):s.push({maxX:c.maxX,sessions:[{sid:l,top:c.minY}]})}const o=new Map;for(const l of s)for(const{sid:c}of l.sessions.sort((d,h)=>d.top-h.top))o.set(c,o.size);return e.slice().sort((l,c)=>o.get(n(l))-o.get(n(c))||t(l)-t(c)||l.position.y-c.position.y||l.position.x-c.position.x)}function bte(e,t){var r;let n=0;for(let s=t.parentId;s!=null&&n<e.agents.size;s=(r=e.agents.get(s))==null?void 0:r.parentId)n++;return n}function kte(e,t,n,r,s,o,l,c,d,h,f,p,g,v,N,k,x,j,b,_){var G,K,q,H;const E=[],R=[],T=vte(e,j);for(const D of e.agents.values()){if(!x.has(D.id))continue;const W=D.exitAt!=null,J=k!=null&&!k.has(D.id),V=[W?"rf-exiting":"",J?"rf-spotlit-out":"",N.has(D.id)?"rf-selected":""].filter(Boolean).join(" ")||void 0,X=o.get(D.id);if(E.push({id:D.id,type:"agent",position:{x:0,y:0},data:T(D),className:V,ariaLabel:K8(D,t,N.has(D.id)),...X?{width:X.width,height:X.height}:null}),D.parentId&&x.has(D.parentId)){const ee=wd(D.sessionId),ne=W,se=N.size>0&&(N.has(D.id)||N.has(D.parentId)),pe=k!=null&&!k.has(D.id)&&!k.has(D.parentId),ke=D.state==="active"?2:1.5,ae=se?ke+1.5:ke,fe=ne?.2:pe?.12:1,me=["sess-edge",D.state==="active"?"sess-live":"sess-idle",ne?"rf-edge-exiting":"",se?"rf-edge-selected":""].filter(Boolean).join(" ");R.push({id:`e:${D.parentId}->${D.id}`,source:D.parentId,target:D.id,animated:(D.state==="active"||se)&&!ne,type:"smoothstep",style:{"--session-hue":ee,strokeWidth:`calc(${ae}px * var(--edge-k, 1))`,opacity:fe,transition:"var(--edge-transition)"},className:me})}const Y=D.kind==="root"?Qd(D):null,Z=Y?S$(D.sessionId,Y.at):null;if(Y&&Z&&!_U(Z)){const ee=n0(D.id),ne=wd(D.sessionId),se=o.get(ee);E.push({id:ee,type:"recapNote",position:{x:0,y:0},data:{sessionId:D.sessionId,parentId:D.id,recap:Y,noteKey:Z,hue:ne},className:J?"rf-spotlit-out":void 0,selectable:!1,focusable:!1,ariaLabel:`Claude Code's recap for ${D.label}`,...se?{width:se.width,height:se.height}:null}),R.push({id:`e:recap:${D.id}`,source:ee,target:D.id,type:"recapTie",className:"recap-edge",focusable:!1,style:{"--session-hue":ne}})}}const A=V0(e),U=_.size>0&&!(d&&b);U||_.clear();const L=`${g}#lanes:${ote(A)}${U?"#held":""}`,F=new Set(E.filter(D=>D.type==="recapNote").map(D=>D.id));for(const D of Array.from(f.keys()))b&&AU(D)&&!F.has(D)&&!s.has(D)&&(f.delete(D),p.delete(D));const O=E.filter(D=>mte(D.id,s,f,p));if(O.length>0||L!==v.current){if(O.length>0){for(const W of O)_.delete(W.id);const D=ite(pte(E,R,{direction:"LR",pinned:s,measured:o,availableWidth:n,availableHeight:r,lanes:A}),s,W=>od(W,f,p)?void 0:f.get(W));for(const W of D)od(W.id,f,p)&&AR(W.id,W.position,f,p);lte(E,f,s,o,new Set(O.filter(W=>W.type!=="recapNote").map(W=>W.id)),A,{width:n,height:r});for(const W of O){if(W.type!=="recapNote")continue;const J=(G=W.data)==null?void 0:G.parentId;if(!J)continue;const V=s.get(J)??(od(J,f,p)?void 0:f.get(J));if(!V)continue;const X=((K=o.get(W.id))==null?void 0:K.width)??yte,Y=((q=o.get(W.id))==null?void 0:q.height)??RR,Z=((H=o.get(J))==null?void 0:H.height)??RR;AR(W.id,{x:V.x-wte-X,y:V.y+(Z-Y)/2},f,p)}}cte(E,f,s,o,A,U?_:void 0),v.current=L}const I=ute(E,f,s,o,l,!d||h,A);I.length>0&&c(I);const B=OZ(e.agents.values());b&&Hu(f,B),Hu(p,B),b&&Hu(s,B),Hu(o,IZ(e.agents.values()));const M=[];let $=!1;for(const D of E){let W=s.get(D.id)??f.get(D.id);W||(W=gte(D.id,f,p),$=!0),M.push({...D,position:W})}return $&&(v.current=""),{nodes:xte(M,D=>{if(D.type==="recapNote")return-1;const W=e.agents.get(D.id);return W?bte(e,W):0}),edges:R}}function Nte(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function jte(e,t,n){var l;if(e.length===0)return null;const r=Nte(e),s=t?r.findIndex(c=>c.id===t):-1,o=s===-1?n===1?0:r.length-1:(s+n+r.length)%r.length;return((l=r[o])==null?void 0:l.id)??null}const Ste=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Backspace"]);function _te(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:Ste.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const Ete=new Set(["","BODY","HTML","#DOCUMENT"]);function Cte(e){return!e||dc(e)?!1:!Ete.has(String(e.tagName??"").toUpperCase())}const kL="react-flow__node";function G0(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,kL))===!0}function NL(e){try{const t=document.querySelector(`.${kL}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}let Ga=null,ei=null;const pb=new Set,mb=()=>{for(const e of pb)e()},Tte=e=>(pb.add(e),()=>{pb.delete(e)}),$R=()=>Ga,Ate=90;function jL(e){!ei||e!=null&&ei.at.id!==e||(clearTimeout(ei.timer),ei=null)}function SL(e,t,n="pointer"){jL();const r={id:e,anchor:t,by:n};if(Ga||n==="focus"){Ga=r,mb();return}ei={at:r,timer:setTimeout(()=>{ei=null,Ga=r,mb()},Ate)}}function la(e){jL(e),!(!Ga||e!=null&&Ga.id!==e)&&(Ga=null,mb())}function Rte({agentFor:e,recapFor:t,labelFor:n,bounds:r}){const s=y.useSyncExternalStore(Tte,$R,$R),o=s?e(s.id):void 0,l=s&&!o?t(s.id):void 0,c=s!=null&&(!o&&!l||!s.anchor.isConnected);return y.useEffect(()=>{c&&s&&la(s.id)},[c,s]),!s||c?null:o?a.jsx($te,{a:o,anchor:s.anchor,parentLabel:o.parentId?n(o.parentId):void 0,bounds:r},s.id):l?a.jsx(Mte,{r:l,anchor:s.anchor,bounds:r},s.id):null}function _L(e,t){const n=y.useRef(null),r=y.useCallback(()=>{const s=n.current;if(!s||!e.isConnected)return;const o=h0(e.getBoundingClientRect(),{width:s.offsetWidth,height:s.offsetHeight},t());s.style.top=`${o.top}px`,s.style.left=`${o.left}px`,s.style.maxHeight=o.maxHeight==null?"":`${o.maxHeight}px`,s.dataset.side=o.side},[e,t]);return y.useLayoutEffect(()=>{r()}),n}function Mte({r:e,anchor:t,bounds:n}){const r=_L(t,n),s=_i(3e4),o=Nd(e.recap.at,s);return Lt.createPortal(a.jsxs("div",{ref:r,className:"ap-peek node-peek recap-peek",role:"tooltip",id:"node-peek",style:{"--session-hue":e.hue},children:[a.jsxs("div",{className:"node-peek-head",children:[a.jsxs("span",{className:"recap-peek-mark",children:[a.jsx(Vl,{}),"recap"]}),a.jsx("span",{className:"node-peek-time",title:o.title,children:o.label})]}),e.sessionLabel&&a.jsx("div",{className:"node-peek-kind",children:a.jsxs("span",{children:["Claude Code's recap of ",e.sessionLabel]})}),a.jsx("p",{className:"recap-peek-text",children:e.recap.text}),a.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for its details"})]}),document.body)}function $te({a:e,anchor:t,parentLabel:n,bounds:r}){const s=_L(t,r),o=_i(1e3),l=e0(e.sessionName,e.sessionTitle),c=e.toolErrorCount??0,d=e.tools.filter(N=>!N.endedAt).length,h=pn(e,o).total,f=e.usage.inputTokens+e.usage.outputTokens,p=e.kind==="root"&&Sn(e.waiting),g=e.kind==="root"?"session":n?`subagent of ${n}`:"subagent",v=[`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,d>0?`${d} in-flight`:null,f>0?`${it(f)} tok`:null,h>0?`${qe(h)}${Hl(e,o)>0?"+":""}`:null].filter(Boolean).join(" · ");return Lt.createPortal(a.jsxs("div",{ref:s,className:"ap-peek node-peek",role:"tooltip",id:"node-peek",children:[a.jsxs("div",{className:"node-peek-head",children:[a.jsx("span",{className:"node-peek-name",children:e.label}),a.jsxs("span",{className:"node-peek-time",children:[e.synthetic?"≥ ":"",mi(e.startedAt,e.endedAt,o)]})]}),a.jsxs("div",{className:"node-peek-kind",children:[a.jsxs("span",{className:"node-peek-state","data-kind":Ix(e.state),children:[a.jsx($$,{kind:Ix(e.state)}),fi(e.state)]}),a.jsx("span",{children:g}),e.model?a.jsx("span",{children:oa(e.model)}):null]}),e.kind==="root"&&l.face&&a.jsx("p",{className:"node-peek-title",children:l.face}),e.kind==="root"&&e.waiting&&a.jsxs("p",{className:`node-peek-wait${p?" warn":""}`,children:[p&&a.jsx(a0,{}),a.jsx("span",{children:Qb(e.waiting)}),a.jsx("b",{children:mi(e.waiting.since,void 0,o)})]}),a.jsxs("p",{className:"node-peek-facts",children:[v,c>0&&a.jsxs("span",{className:"node-peek-failed",children:[" · ",c," failed"]})]}),e.branch&&e.branch.total>0&&a.jsx("p",{className:"node-peek-branch",children:_$(e.branch)}),a.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for details"})]}),document.body)}function Ite(e){const t=e.minZoom??FX,n=e.maxZoom??BX,r=e.fill??.9,s=e.insets.left,o=e.insets.top,l=Math.max(1,e.pane.width-e.insets.left-e.insets.right),c=Math.max(1,e.pane.height-e.insets.top-e.insets.bottom),d=e.context,h=e.anchor,f=Math.min(l/Math.max(1,d.width),c/Math.max(1,d.height))*r,p=Math.max(t,Math.min(n,f)),g=(v,N,k,x,j,b)=>{let _=v+(N-x*p)/2-k*p;const E=j*p+_,R=(j+b)*p+_;return b*p<=N?E<v?_+=v-E:R>v+N&&(_-=R-(v+N)):_+=v-E,_};return{x:g(s,l,d.x,d.width,h.x,h.width),y:g(o,c,d.y,d.height,h.y,h.height),zoom:p}}function Ote(e){let t=1/0,n=1/0,r=-1/0,s=-1/0;for(const o of e)t=Math.min(t,o.x),n=Math.min(n,o.y),r=Math.max(r,o.x+o.width),s=Math.max(s,o.y+o.height);return Number.isFinite(t)?{x:t,y:n,width:r-t,height:s-n}:null}function _n(e){const t=y.useRef(e);return t.current=e,t}const gb=80,yb=.86;function EL(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 s=r.getBoundingClientRect();s.width>0&&s.left>t.left&&(n=Math.min(n,s.left))}return Math.max(0,t.right-n)}function Lte({canvasRef:e,canvasSize:t,machinePhase:n,usagePhase:r,usagePanelOpen:s,detailShown:o}){const[l,c]=y.useState(0);y.useEffect(()=>{const p=EL(e.current);c(g=>Math.abs(g-p)>40?p:g)},[n,r,s,o,t.w]);const d=_n(l),h=t.w>0?Math.max(0,(t.w-l-gb*2)*yb):0,f=t.h>0?Math.max(0,(t.h-gb*2)*yb):0;return{railInsetRef:d,availableWidth:h,availableHeight:f}}const CL=420;function Pte(){const e=ki(),t=Nt(),n=y.useCallback((d,h)=>{if(Rx({durationMs:h,documentHidden:document.hidden})){e.setViewport(d,{duration:h});return}const{d3Zoom:f,d3Selection:p}=t.getState(),g=p==null?void 0:p.property("__zoom");if(f&&p&&g&&g.k>0&&d.zoom>0){f.transform(p,g.scale(d.zoom/g.k).translate((d.x-g.x)/d.zoom,(d.y-g.y)/d.zoom));return}e.setViewport(d,{duration:0})},[e,t]),r=y.useRef(null),s=y.useRef(0),o=y.useRef(0),l=y.useCallback((d,h)=>{const f=++s.current;return n(d,h),o.current=Date.now(),r.current=Rx({durationMs:h,documentHidden:document.hidden})?{target:d,until:Date.now()+h+60}:null,f},[n]),c=y.useCallback((d=500)=>{const h=gb,f=1,p=.2,g=yb;try{const v=document.querySelector(".canvas-wrap"),N=Array.from(document.querySelectorAll(".react-flow__node")).filter($=>$.offsetWidth>0);if(!v||N.length===0)return;const k=v.getBoundingClientRect(),x=e.getViewport();if(!Number.isFinite(x.zoom)||x.zoom<=0)return;const j=$=>($-k.left-x.x)/x.zoom,b=$=>($-k.top-x.y)/x.zoom,_=N.map($=>$.getBoundingClientRect()),E=Math.min(..._.map($=>j($.left))),R=Math.max(..._.map($=>j($.right))),T=Math.min(..._.map($=>b($.top))),A=Math.max(..._.map($=>b($.bottom))),U=R-E,L=A-T;if(!(U>0&&L>0))return;const F=EL(v),O=$=>Math.max(p,Math.min(f,(k.width-F-h*2)/(U+$)*g,(k.height-h*2)/L*g)),I=DX(O(CL),O(0)),B={x:h-E*I,y:Math.max(h,(k.height-L*I)/2)-T*I,zoom:I},M=l(B,d);window.setTimeout(()=>{var $;try{if((($=r.current)==null?void 0:$.target)===B&&(r.current=null),s.current!==M)return;const P=e.getViewport();(Math.abs(P.zoom-I)>.01||Math.abs(P.x-B.x)>2)&&n(B,0)}catch{}},d+60)}catch{}},[e,n,l]);return y.useEffect(()=>{const d=()=>{if(!document.hidden)return;const h=r.current;if(r.current=null,!(!h||Date.now()>h.until)){try{n(h.target,0)}catch{}o.current=Date.now()}};return document.addEventListener("visibilitychange",d),()=>document.removeEventListener("visibilitychange",d)},[n]),{applyViewport:n,moveCamera:l,fitLeft:c,cameraEpochRef:s,lastFitTimeRef:o}}const Dte=450;function Fte({canvasRef:e,stateRef:t,measuredRef:n,nodesRef:r,railInsetRef:s,moveCamera:o,disableAutoFit:l,lastFocusRef:c,focusAgentRef:d,selectAgent:h,primarySelectedIdRef:f}){const p=y.useCallback(N=>{var U;const k=e.current,x=t.current.agents.get(N);if(!k||!x)return;const j=V0(t.current),b=(L,F)=>{const O=n.current.get(L.id);if(!O)return null;const I=F&&j.has(L.id)?CL:0;return{x:L.position.x,y:L.position.y,width:O.width+I,height:O.height}},_=r.current.find(L=>L.id===N),E=_?b(_,!1):null;if(!E)return;const R=[];for(const L of r.current){if(L.type!=="agent"&&L.type!=="recapNote"||((U=L.data)==null?void 0:U.sessionId)!==x.sessionId)continue;const F=b(L,L.type==="agent");F&&R.push(F)}const T=k.getBoundingClientRect(),A=Ite({pane:{width:T.width,height:T.height},insets:{top:56,left:72,bottom:32,right:s.current+32},context:Ote(R)??E,anchor:E});la(),l(),c.current={id:N,at:Date.now()},o(A,Dte)},[o,l]);d.current=p;const g=y.useCallback(N=>{const k=r.current.filter(_=>_.type==="agent"),x=jte(k.map(_=>({id:_.id,x:_.position.x,y:_.position.y})),f.current,N),j=x?k.find(_=>_.id===x):void 0;if(!j)return;const b=G0(document.activeElement);h(j.id,!1),window.setTimeout(()=>{try{p(j.id)}catch{}b&&NL(j.id)},30)},[h,p]),v=y.useCallback(N=>{h(N,!1),window.setTimeout(()=>{try{p(N)}catch{}},60)},[h,p]);return{focusAgent:p,stepAgent:g,focusSession:v}}function Bte({nodesRef:e,stateRef:t,canvasRef:n,railInsetRef:r}){const s=y.useCallback(d=>{const h=e.current.find(f=>f.id===d&&f.type==="agent");return h?h.data:void 0},[]),o=y.useCallback(d=>{var h;return(h=t.current.agents.get(d))==null?void 0:h.label},[]),l=y.useCallback(d=>{var p;const h=e.current.find(g=>g.id===d&&g.type==="recapNote");if(!h)return;const f=h.data;return{recap:f.recap,hue:f.hue,sessionLabel:(p=t.current.agents.get(f.parentId))==null?void 0:p.label}},[]),c=y.useCallback(()=>{var f;const d=(f=n.current)==null?void 0:f.getBoundingClientRect(),h=document.documentElement;return d?{width:d.right-r.current,height:d.bottom}:{width:h.clientWidth,height:h.clientHeight}},[]);return{peekAgent:s,peekLabel:o,peekRecap:l,peekBounds:c}}function qte(e){const t=new Set(e.pins),n=new Map,r=new Map;for(const[s,o]of e.positions)n.set(s,o),t.has(s)&&r.set(s,o);return{positions:n,pinned:r,restored:new Set(n.keys())}}function IR(e){return Object.entries(e??{}).filter(([,t])=>t&&typeof t.x=="number"&&typeof t.y=="number")}function Ute(e){const t={positions:[],pins:[]};if(!e)return t;let n;try{n=JSON.parse(e)}catch{return t}if(!n||typeof n!="object")return t;if(!("v"in n)){const s=IR(n);return{positions:s,pins:s.map(([o])=>o)}}const r=n;return{positions:IR(r.positions),pins:Array.isArray(r.pins)?r.pins:[]}}function zte(e,t){const n={};for(const[r,s]of e)n[r]=s;for(const[r,s]of t)n[r]=s;return JSON.stringify({v:2,positions:n,pins:Array.from(t.keys())})}function Wte(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}return!(typeof(t==null?void 0:t.width)=="number"&&typeof(t==null?void 0:t.height)=="number")||!(t.width>0&&t.height>0)?null:{width:t.width,height:t.height}}const K0="agent-dag.layout",Y0="agent-dag.layoutFrame",X0="agent-dag.viewport";function Hte(){return Ute(Qe(K0))}function rc(e,t){Ze(K0,zte(e,t))}function Vte(){return Wte(Qe(Y0))}function TL(e){Ze(Y0,JSON.stringify(e))}function Gte(){return fq(Qe(X0))}function Kte(e){Ze(X0,JSON.stringify(e))}function AL(){hs(K0),hs(X0),hs(Y0)}function Yte(e){const t=y.useState(()=>qte(Hte()))[0],n=y.useRef(t.pinned),r=y.useRef(t.positions),s=y.useRef(new Set),o=y.useRef(""),[l,c]=y.useState(0),d=y.useState(Vte)[0],h=y.useRef(d),f=y.useCallback(()=>{n.current.clear(),r.current.clear(),o.current="",AL(),c(p=>p+1),window.setTimeout(()=>{rc(r.current,n.current),h.current&&TL(h.current),e(500)},80)},[e]);return{restoredLayout:t,pinnedRef:n,positionsRef:r,provisionalRef:s,lastLayoutSigRef:o,layoutEpoch:l,setLayoutEpoch:c,lastLayoutFrameRef:h,handleRelayout:f}}function Xte(e,t){const{positionsRef:n,pinnedRef:r}=t,s=y.useRef(null);y.useEffect(()=>(s.current!=null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{rc(n.current,r.current)},1500),()=>{s.current!=null&&window.clearTimeout(s.current)}),[e])}function Zte({nodes:e,edges:t,settled:n,dragging:r,availableWidth:s,availableHeight:o,layout:l,camera:c,rf:d,measuredRef:h,stateRef:f,lastFocusRef:p,primarySelectedIdRef:g,focusAgentRef:v,autoFitDisabledRef:N}){const{lastLayoutFrameRef:k,pinnedRef:x,positionsRef:j,provisionalRef:b,lastLayoutSigRef:_,setLayoutEpoch:E}=l,{applyViewport:R,fitLeft:T,cameraEpochRef:A,lastFitTimeRef:U}=c;y.useEffect(()=>{if(!n||r)return;const L={width:s,height:o};if(!(L.width>0&&L.height>0))return;const F=k.current;if(k.current=L,TL(L),!F||F.width===L.width&&F.height===L.height)return;const O={direction:"LR",pinned:x.current,measured:h.current,lanes:V0(f.current)};if(!fte(e,t,O,F,L))return;const I=p.current&&Date.now()-p.current.at<1500?p.current.id:null,B=I??g.current,M=B?x.current.get(B)??j.current.get(B):void 0;for(const $ of Array.from(j.current.keys()))x.current.has($)||j.current.delete($);b.current.clear(),_.current="",E($=>$+1),window.setTimeout(()=>{if(rc(j.current,x.current),N.current){if(I){v.current(I);return}const $=B?x.current.get(B)??j.current.get(B):void 0;if(M&&$&&($.x!==M.x||$.y!==M.y)){const P=d.getViewport();A.current+=1,R({x:P.x-($.x-M.x)*P.zoom,y:P.y-($.y-M.y)*P.zoom,zoom:P.zoom},0),U.current=Date.now()}return}T(500)},80)},[s,o,n,r,T,d,R])}function Jte(e,t,n,r,s){const o=[];for(const l of e)!rh(l,t)||n.has(l.id)||o.push(l.id+(l.parentId?`>${l.parentId}`:""));return o.sort(),`${o.join("|")}#sv${r}.${s}`}const Z0="agent-dag.removedNodes";function Qte(e){try{const t=JSON.parse((e==null?void 0:e.getItem(Z0))??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function OR(e,t){try{e==null||e.setItem(Z0,JSON.stringify([...t]))}catch{}}function RL(e,t){const n=new Map(e.map(o=>[o.id,o.parentId])),r=new Set(t),s=o=>{if(r.has(o))return!0;const l=new Set([o]);let c=n.get(o);for(;c&&!l.has(c);){if(r.has(c))return r.add(o),!0;l.add(c),c=n.get(c)}return!1};return o=>s(o.id)||s(o.sessionId??o.id)}function ene(e,t){if(t.size===0)return new Set;const n=[...e],r=RL(n,t);return new Set(n.filter(r).map(s=>s.id))}function tne(e,t,n){const r=c=>({id:c.id,parentId:c.data.parentId,sessionId:c.data.sessionId}),s=RL(e.map(r),n),o=e.filter(c=>!s(r(c))),l=new Set(o.map(c=>c.id));return{nodes:o,edges:t.filter(c=>l.has(c.source)&&l.has(c.target))}}function nne(e,t){let n=null;for(const r of t)e.has(r)&&(n??(n=new Set(e)),n.delete(r));return n??e}function rne(e,t){return t.size===0?[]:[...e].filter(n=>t.has(n.id)).map(n=>n.id)}function sne(e){let t=e.kind==="subagent"?e.startedAt:-1/0;const n=e.tools[e.tools.length-1];n&&n.startedAt>t&&(t=n.startedAt);const r=e.prompts[e.prompts.length-1];return r&&r.at>t&&(t=r.at),e.lastOutputAt!=null&&e.lastOutputAt>t&&(t=e.lastOutputAt),t}function ane(e,t,n){let r=null;for(const s of t)e.has(s)||(r??(r=new Map(e)),r.set(s,n));for(const s of e.keys())t.has(s)||(r??(r=new Map(e)),r.delete(s));return r??e}function one(e,t,n,r){if(n.size===0)return[];let s=1/0;for(const l of r.values())l<s&&(s=l);const o=new Set;for(const l of t){const c=e.get(l);if(!c)continue;const d=sne(c);if(d<=s)continue;const h=[],f=new Set,p=v=>{var N;for(let k=v;k&&!f.has(k);k=(N=e.get(k))==null?void 0:N.parentId)f.add(k),n.has(k)&&h.push(k)};p(c.id),p(c.sessionId);let g=-1/0;for(const v of h)g=Math.max(g,r.get(v)??1/0);if(d>g)for(const v of h)o.add(v)}return[...o]}const ML="sessionGroup";function ine(e,t){var r,s;if(e.type===ML)return"transparent";if(Sn((r=e.data)==null?void 0:r.waiting))return t("--warn");if(e.type==="recapNote")return t("--muted");const n=(s=e.data)==null?void 0:s.state;return t(n==="err"?"--err":n==="active"?"--inflight":"--ok")}const Vu=Ua;function lne(e){const t=new Map;for(const r of e){const s=r.data;if(!(s!=null&&s.sessionId)||s.exitAt!=null)continue;const o=r.width,l=r.height;if(o==null||l==null)continue;const c=r.position.x,d=r.position.y,h=c+o,f=d+l,p=t.get(s.sessionId);p?(p.minX=Math.min(p.minX,c),p.minY=Math.min(p.minY,d),p.maxX=Math.max(p.maxX,h),p.maxY=Math.max(p.maxY,f)):t.set(s.sessionId,{minX:c,minY:d,maxX:h,maxY:f})}const n=[];for(const[r,s]of t){const o=s.maxX-s.minX+Vu*2,l=s.maxY-s.minY+Vu*2;n.push({id:`group:${r}`,type:ML,position:{x:s.minX-Vu,y:s.minY-Vu},data:{sessionId:r,w:o,h:l},width:o,height:l,style:{width:o,height:l},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return n}function cne(e,t){if(!t||!e.agents.get(t))return null;const r=new Set([t]);let s=t;for(;s;){const l=e.agents.get(s);if(!(l!=null&&l.parentId)||r.has(l.parentId))break;r.add(l.parentId),s=l.parentId}let o=!0;for(;o;){o=!1;for(const l of e.agents.values())l.parentId&&r.has(l.parentId)&&!r.has(l.id)&&(r.add(l.id),o=!0)}return r}function une(e,t){const n=new Set;for(const r of t){const s=cne(e,r);if(s)for(const o of s)n.add(o)}return n.size>0?n:null}function dne({stateRef:e,now:t,removedAgentIds:n,sizeVersion:r,domSizeVersion:s}){return y.useMemo(()=>Jte(e.current.agents.values(),t,n,r,s),[e.current,e.current.revision,t,r,s,n])}function hne({stateRef:e,now:t,availableWidth:n,availableHeight:r,layout:s,measuredRef:o,onBubble:l,settled:c,dragging:d,layoutSig:h,selectedIds:f,openContext:p,historyReplayed:g,removedNodes:v,removedAgentIds:N,dragTick:k,dragPatchRef:x,dragMoveTick:j}){const{pinnedRef:b,positionsRef:_,provisionalRef:E,lastLayoutSigRef:R,restoredLayout:T,layoutEpoch:A}=s,U=y.useMemo(()=>une(e.current,f),[e.current,e.current.revision,f]),L=y.useMemo(()=>{const P=CH(e.current,t);for(const G of N)P.delete(G);return P},[e.current,e.current.revision,t,N]),F=y.useRef(new Map),O=RU(),{nodes:I,edges:B}=y.useMemo(()=>{const P=kte(e.current,t,n,r,b.current,o.current,F.current,l,c,d,_.current,E.current,h,R,f,U,L,p,g,T.restored);return tne(P.nodes,P.edges,v)},[e.current,e.current.revision,t,n,r,c,d,h,f,U,L,p,k,O,v,A,g]),M=y.useMemo(()=>lne(I),[I]),$=y.useMemo(()=>{const P=[...M,...I],G=x.current;return!G||G.size===0?P:P.map(K=>{const q=G.get(K.id);return q?{...K,position:q}:K})},[M,I,j]);return{spotlightSet:U,visibleAgentIds:L,nodes:I,edges:B,allNodes:$}}function fne(e,t,n){const r=e.x*t.zoom+t.x,s=e.y*t.zoom+t.y,o=(e.x+e.width)*t.zoom+t.x,l=(e.y+e.height)*t.zoom+t.y;return o>0&&r<n.width&&l>0&&s<n.height}function pne({pane:e,viewport:t,boxes:n}){if(!e||!(e.width>0)||!(e.height>0)||!Number.isFinite(t.zoom)||t.zoom<=0||!Number.isFinite(t.x)||!Number.isFinite(t.y))return!1;let r=!1;for(const s of n)if(r=!0,fne(s,t,e))return!1;return r}function mne({layoutSig:e,rf:t,stateRef:n,measuredRef:r,pinnedRef:s,positionsRef:o,paneSizeRef:l,lastInteractRef:c,autoFitDisabledRef:d,lastFitTimeRef:h,fitLeft:f}){const p=y.useRef(null),g=y.useRef("");y.useEffect(()=>{const v=setInterval(()=>{if(d.current||Date.now()-c.current<800)return;const N=n.current,k=Date.now(),x=[];for(const b of N.agents.values())rh(b,k)&&x.push({id:b.id});if(x.length===0)return;const j=[];for(const{id:b}of x){const _=r.current.get(b),E=s.current.get(b)??o.current.get(b);!_||!E||j.push({x:E.x,y:E.y,width:_.width,height:_.height})}pne({pane:l.current,viewport:t.getViewport(),boxes:j})&&f(600)},1500);return()=>clearInterval(v)},[t]),y.useEffect(()=>{if(g.current===e)return;const v=g.current;if(g.current=e,!v||d.current)return;Date.now()-h.current>1200&&f(400),p.current&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{d.current||f(500)},280)},[e,t,f])}function gne({stateRef:e,pinnedRef:t,positionsRef:n,canvasRef:r,clearSelection:s,primarySelectedId:o}){const[l,c]=y.useState(()=>Qte(Ml())),[d,h]=y.useState(null),f=y.useMemo(()=>ene(e.current.agents.values(),l),[e.current,e.current.revision,l]),p=y.useCallback(j=>{const b=e.current.agents.get(j);b&&(c(_=>{const E=new Set(_);return E.add(j),OR(Ml(),E),E}),h({id:j,label:b.label}),t.current.delete(j),n.current.delete(j),s())},[s]),g=y.useCallback(()=>{o&&p(o)},[o,p]),v=d&&l.has(d.id)?d:null;y.useEffect(()=>{var j;d&&((j=r.current)==null||j.focus())},[d]);const N=y.useCallback(j=>{const b=[...j];c(_=>{const E=nne(_,b);return E!==_&&OR(Ml(),E),E})},[]),k=y.useCallback(()=>{N([...l]),h(null)},[N,l]),x=y.useCallback(()=>{c(new Set),h(null),hs(Z0)},[]);return{removedNodes:l,lastRemoval:d,removedAgentIds:f,removeNode:p,removeSelectedNode:g,removalNotice:v,bringBack:N,bringBackAll:k,forgetRemovals:x}}function yne({stateRef:e,waitingSessions:t,removedAgentIds:n,removedNodes:r,bringBack:s}){const o=y.useRef(new Map);y.useEffect(()=>{o.current=ane(o.current,r,Date.now());const l=[...rne(t,n),...one(e.current.agents,n,r,o.current)];l.length>0&&s(l)},[t,n,r,s])}function wne({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) ${kt}`:kt,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const $L=Object.freeze({offline:"/state/favicon-error.svg",waiting:"/state/favicon-waiting.svg",running:"/state/favicon-syncing.svg",idle:"/favicon.svg"}),IL=Object.freeze({offline:"/state/favicon-error-32.png",waiting:"/state/favicon-waiting-32.png",running:"/state/favicon-syncing-32.png",idle:"/favicon.ico"}),vne=Object.freeze([...new Set([...Object.values($L),...Object.values(IL)])]),wb=new Map;function LR(e){return wb.get(e)??e}async function xne(e,t=n=>fetch(n)){await Promise.all(e.map(async n=>{if(!wb.has(n))try{const r=await t(n),s=(r.headers.get("Content-Type")??"").split(";")[0].trim();if(!r.ok||!s.startsWith("image/"))return;wb.set(n,`data:${s};base64,${bne(new Uint8Array(await r.arrayBuffer()))}`)}catch{}}))}function bne(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function kne({stateRef:e,waitingSessions:t,live:n}){const r=y.useMemo(()=>B8(e.current.agents.values()),[e.current,e.current.revision]),s=y.useRef(null);y.useEffect(()=>{n&&xne(vne)},[n]),y.useEffect(()=>{const o=wne({waiting:t.length,running:r,connected:n}),l=s.current;s.current=o,(l==null?void 0:l.title)!==o.title&&(document.title=o.title),(l==null?void 0:l.icon)!==o.icon&&OL(o.icon)},[t.length,r,n])}function OL(e){const t=document.querySelector('link[rel="icon"][type="image/svg+xml"]');t&&(t.href=LR($L[e]));const n=document.querySelector('link[rel="icon"][sizes="32x32"]');n&&(n.href=LR(IL[e]))}const Nne=1200,jne=1e3;function ox(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<Nne?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<jne}function Sne({applyViewport:e,lastFitTimeRef:t,cameraEpochRef:n,disableAutoFit:r,markInteract:s,canvasRef:o,applyZoom:l}){const c=y.useState(()=>Gte())[0];y.useEffect(()=>{if(!c)return;const N=window.setTimeout(()=>{try{e(c,0)}catch{}t.current=Date.now()},60);return()=>window.clearTimeout(N)},[e,c]);const d=y.useRef(null),h=y.useRef(0),f=y.useCallback(()=>{h.current=Date.now()},[]),p=y.useCallback(N=>({hasSourceEvent:!!N,at:Date.now(),lastDeckFitAt:t.current,lastCanvasInputAt:h.current}),[]);return{restoredViewport:c,markCanvasInput:f,onMoveStart:N=>{la(),ox(p(N))&&(n.current+=1),ox(p(N))&&r()},onMove:(N,k)=>{var x;s(),ox(p(N))&&r(),(x=o.current)==null||x.style.setProperty("--zoom",String(k.zoom)),l(k.zoom)==="detail"&&la(),d.current&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>Kte(k),250)}}}function _ne({clearSelection:e,selectAgent:t,detailOpen:n,setDetailOpen:r,detailShown:s,focusAgent:o,draggingRef:l,lodRef:c}){return{onNodeClick:(v,N)=>{if(N.type==="sessionGroup"){e();return}const k=N.type==="recapNote"?N.data.parentId:N.id;t(k,v.shiftKey,!1),!v.shiftKey&&(n&&r(!1),s?window.setTimeout(()=>{try{o(k)}catch{}},80):o(k))},onPaneClick:()=>{la(),e()},onNodeDoubleClick:(v,N)=>{if(N.type!=="agent"&&N.type!=="recapNote")return;const k=N.type==="recapNote"?N.data.parentId:N.id;t(k,!1),window.setTimeout(()=>{try{o(k)}catch{}},80)},onNodeMouseEnter:(v,N)=>{N.type!=="agent"&&N.type!=="recapNote"||l.current||c.current==null||c.current==="detail"||SL(N.id,v.currentTarget)},onNodeMouseLeave:(v,N)=>la(N.id)}}function Ene(){const e=y.useRef(null),t=y.useRef(null),[n,r]=y.useState({w:0,h:0});return y.useEffect(()=>{const s=t.current;if(!s||typeof ResizeObserver>"u")return;const o=new ResizeObserver(l=>{var d;const c=(d=l[0])==null?void 0:d.contentRect;c&&(e.current={width:c.width,height:c.height},r(h=>Math.abs(h.w-c.width)>40||Math.abs(h.h-c.height)>40?{w:c.width,h:c.height}:h))});return o.observe(s),e.current={width:s.clientWidth,height:s.clientHeight},r({w:s.clientWidth,h:s.clientHeight}),()=>o.disconnect()},[]),{canvasRef:t,canvasSize:n,paneSizeRef:e}}function Cne(e){const t=y.useRef(new Map),n=y.useRef(0),r=y.useCallback(c=>{const d=t.current;let h=!1;for(const f of c.nodeInternals.values()){const p=f.width,g=f.height;if(p==null||g==null)continue;const v=d.get(f.id);v?(Math.abs(v.height-g)>4||Math.abs(v.width-p)>4)&&(d.set(f.id,{width:p,height:g}),h=!0):(d.set(f.id,{width:p,height:g}),h=!0)}return h&&(n.current+=1),n.current},[]),s=Xe(r),[o,l]=y.useState(0);return y.useEffect(()=>{let c=0;const d=()=>{const f=t.current;let p=!1;for(const g of document.querySelectorAll(".react-flow__node[data-id]")){const v=g.getAttribute("data-id");if(!v)continue;const N=g.offsetWidth,k=g.offsetHeight;if(!N||!k)continue;const x=f.get(v);(!x||Math.abs(x.width-N)>4||Math.abs(x.height-k)>4)&&(f.set(v,{width:N,height:k}),p=!0)}p&&l(g=>g+1)};if(e.current)return;let h=0;return document.visibilityState==="hidden"?h=window.setTimeout(d,32):c=requestAnimationFrame(d),()=>{cancelAnimationFrame(c),window.clearTimeout(h)}}),{measuredRef:t,measuredVersionRef:n,sizeVersion:s,domSizeVersion:o}}function Tne(){const[e,t]=y.useState(!1);return y.useEffect(()=>{const n=window.setTimeout(()=>t(!0),2500);return()=>window.clearTimeout(n)},[]),e}function Ane(){const e=y.useRef(null);return y.useEffect(()=>{let t=-1/0;const n=()=>{t=performance.now()},r=s=>{e.current=performance.now()-t<250?s.target:null};return window.addEventListener("pointerdown",n,!0),window.addEventListener("focusin",r,!0),()=>{window.removeEventListener("pointerdown",n,!0),window.removeEventListener("focusin",r,!0)}},[]),e}function Rne({pointerFocusRef:e,nodesRef:t,stateRef:n,primarySelectedIdRef:r,providersRef:s,soundOnRef:o,keyHelpOpenRef:l,modalOpenRef:c,waitingCursorRef:d,removeSelectedRef:h,activateSoundRef:f,clearSelection:p,selectAgent:g,focusAgent:v,stepAgent:N,focusSession:k,requestClear:x,handleRelayout:j,handleFit:b,togglePause:_,toggleSessionList:E,toggleAccountsPanel:R,setDetailOpen:T,setUsageHistoryOpen:A,setUsagePanelOpen:U,setMachinePanelOpen:L,setBrowserWatchOpen:F,setSoundMenuOpen:O,setKeyHelpOpen:I,setTheme:B}){y.useEffect(()=>{const M=$=>{var D,W;const P=$.target,G={tagName:P==null?void 0:P.tagName,isContentEditable:P==null?void 0:P.isContentEditable,role:(D=P==null?void 0:P.getAttribute)==null?void 0:D.call(P,"role"),type:P==null?void 0:P.type,pointerFocused:P!=null&&P===e.current};if($.key==="Escape"){const J=nU({overlayOpen:ds.depth()>0,typing:dc(G)});J==="dismiss"?ds.dismissTop():J==="blur"?P==null||P.blur():(Cte(G)&&(P==null||P.blur()),p());return}if(Jd($))return;const K=G0(P)?(W=P==null?void 0:P.getAttribute)==null?void 0:W.call(P,"data-id"):null,q=K&&t.current.some(J=>J.id===K)?K:null,H=_te($,q);if(H.kind==="activate"){$.preventDefault(),g(H.nodeId,H.additive);return}if(H.kind!=="node"){if(fU({key:$.key,sheetOpen:l.current,target:G})){$.repeat||I(!1);return}if(!(H.nodeId==null&&dU(G,$.key))&&!hU({key:$.key,modalOpen:w$({appModal:c.current,dialogDepth:ds.dialogDepth()}),sheetOpen:l.current})&&!($.repeat&&!/^[ jkJK]$/.test($.key))){if($.key===" "&&($.preventDefault(),$.repeat||_()),($.key==="c"||$.key==="C")&&x("shortcut"),($.key==="r"||$.key==="R")&&j(),($.key==="f"||$.key==="F")&&b(),($.key==="z"||$.key==="Z")&&r.current&&v(r.current),$.key==="Delete"&&h.current(),($.key==="l"||$.key==="L")&&E(),$.key==="d"||$.key==="D")if(r.current)T(J=>!J);else{const J=Mx(n.current.agents.values());J.length>0?k(J[0].id):N(1)}if(($.key==="h"||$.key==="H")&&A(J=>!J),($.key==="u"||$.key==="U")&&U(J=>!J),($.key==="a"||$.key==="A")&&s.current.claude&&R(),($.key==="j"||$.key==="J")&&N(1),($.key==="k"||$.key==="K")&&N(-1),$.key==="w"||$.key==="W"){const J=F8(Mx(n.current.agents.values()),d.current);J&&(d.current=J.id,k(J.id))}($.key==="t"||$.key==="T")&&B(J=>J==="dark"?"light":"dark"),($.key==="m"||$.key==="M")&&s.current.claude&&o.current!==null&&f.current($.shiftKey),($.key==="s"||$.key==="S")&&L(J=>!J),($.key==="b"||$.key==="B")&&F(J=>!J),($.key==="v"||$.key==="V")&&s.current.claude&&o.current!==null&&O(J=>!J),$.key==="?"&&I(J=>!J)}}};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[x,j,b,p,g,N,k,v,_])}function Mne(){var e,t;return((t=(e=document.activeElement)==null?void 0:e.matches)==null?void 0:t.call(e,":focus-visible"))===!0}function $ne({sessionListShown:e,usageShown:t,machineShown:n,accountsShown:r,detailShown:s,primarySelectedId:o,canvasRef:l}){const c={sessionList:y.useRef(null),usage:y.useRef(null),accounts:y.useRef(null),machine:y.useRef(null)},d=h=>()=>{Mne()&&h()};return{toggles:c,sessionList:d(is(!e,c.sessionList)),usage:d(is(!t,c.usage)),machine:d(is(!n,c.machine)),accounts:d(is(!r,c.accounts)),detail:d(is(!s,()=>{var h,f;o&&NL(o),Cn(((h=document.activeElement)==null?void 0:h.tagName)??null)&&((f=l.current)==null||f.focus({preventScroll:!0}))}))}}function Ine({nodes:e,stateRef:t,pinnedRef:n,positionsRef:r,draggingRef:s,dragPatchRef:o,setDragging:l,setDragMoveTick:c,setDragTick:d,endBubble:h,markInteract:f,disableAutoFit:p,beginTrashDrag:g,trackTrashDrag:v,endTrashDrag:N,removeNode:k}){const x=y.useRef(null);return{onNodeDragStart:(E,R)=>{var T,A;if(la(),h(),s.current=!0,o.current=new Map,l(!0),g(R.type==="agent"?((T=t.current.agents.get(R.id))==null?void 0:T.label)??"":null),f(),p(),R.type==="sessionGroup"){const U=(A=R.data)==null?void 0:A.sessionId,L=new Map;if(U)for(const F of e){const O=F.data;(O==null?void 0:O.sessionId)===U&&L.set(F.id,{x:F.position.x,y:F.position.y})}x.current={start:{x:R.position.x,y:R.position.y},members:L};return}n.current.set(R.id,{x:R.position.x,y:R.position.y})},onNodeDrag:(E,R)=>{var T;if(f(),R.type==="agent"&&v(E),R.type==="sessionGroup"){const A=x.current;if(!A)return;const U=R.position.x-A.start.x,L=R.position.y-A.start.y;for(const[O,I]of A.members){const B={x:I.x+U,y:I.y+L};n.current.set(O,B),r.current.set(O,B)}const F=o.current;if(F){for(const[O,I]of A.members)F.set(O,{x:I.x+U,y:I.y+L});F.set(R.id,{x:R.position.x,y:R.position.y})}c(O=>O+1);return}n.current.set(R.id,{x:R.position.x,y:R.position.y}),r.current.set(R.id,{x:R.position.x,y:R.position.y}),(T=o.current)==null||T.set(R.id,{x:R.position.x,y:R.position.y}),c(A=>A+1)},onNodeDragStop:(E,R)=>{f();const T=N(E,R.type==="agent");if(s.current=!1,o.current=null,l(!1),d(A=>A+1),R.type==="sessionGroup"){const A=x.current;if(A){const U=R.position.x-A.start.x,L=R.position.y-A.start.y;for(const[F,O]of A.members){const I={x:O.x+U,y:O.y+L};n.current.set(F,I),r.current.set(F,I)}}x.current=null,rc(r.current,n.current),d(U=>U+1);return}if(n.current.set(R.id,{x:R.position.x,y:R.position.y}),r.current.set(R.id,{x:R.position.x,y:R.position.y}),T){k(R.id);return}rc(r.current,n.current)}}}function One(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const Lne={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent",zcode:"ZCode"};function Pne(e){const t=e.toLowerCase(),n=Ot(Lne,t);return n!==void 0?n:t?t[0].toUpperCase()+t.slice(1):""}function Dne(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Ile(e,t=[]){const n=t.length?Dne(t.map(Pne)):One(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function Fne(e){const t=e.claude?{provider:"claude",watching:!0,spans:[{text:"Claude Code sends its events through a hook in "},{text:"~/.claude/settings.json",code:!0},{text:" — or in "},{text:"$CLAUDE_CONFIG_DIR/settings.json",code:!0},{text:" when you have that set — which the deck installs on first run."}]}:{provider:"claude",watching:!1,spans:[{text:"Claude Code capture is off: no Claude Code was found on this machine, or the deck was started with "},{text:"--no-claude",code:!0},{text:"."}]},n=e.codex?{provider:"codex",watching:!0,spans:[{text:"Codex installs nothing and needs no trust prompt — the deck reads "},{text:"~/.codex/sessions/",code:!0},{text:" itself, so an empty canvas means no rollout has been written there yet, or that "},{text:"$CODEX_HOME",code:!0},{text:" points at a different tree."}]}:{provider:"codex",watching:!1,spans:[{text:"Codex capture is off: no "},{text:"~/.codex/",code:!0},{text:" was found — set "},{text:"$CODEX_HOME",code:!0},{text:" if yours lives elsewhere — or the deck was started with "},{text:"--no-codex",code:!0},{text:"."}]};return[t,n]}function Bne(e,t){const n=t.prefs??db,r=vi(n.done.level),s=vi(n["needs-input"].level),o=r===s?`${r}%`:`${r}% and ${s}%`,l=t.on?`Sound: on at ${o} — a tone when a turn finishes, another when Claude asks for you (M)`:"Sound: off — press M, or use the switch in here, for a tone when a turn finishes (M)",c=e.codex?`
|
|
94
94
|
|
|
@@ -105,7 +105,7 @@ ${e.map(s=>` ${s.label}: ${pi(s.waiting)} (${kd(r-s.waiting.since)})`).join(`
|
|
|
105
105
|
${qe(o.total)} spent${c?` · ${c}`:""}`:""}`,onClick:()=>{try{r(e.id)}catch{}},children:[a.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),a.jsx("span",{className:"selected-label",children:e.label}),o.total>0&&a.jsxs("span",{className:"selected-cost",children:[qe(o.total),c?a.jsxs("span",{className:"selected-rate",children:[" · ",c]}):null]}),d>0&&a.jsxs("span",{className:"selected-extra",children:["+",d]}),a.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:h=>{h.stopPropagation(),s()},children:"×"})]})}function rse({catBarRef:e,catBarOccluded:t,presentCats:n,hiddenCats:r,toggleCat:s}){return a.jsx("div",{ref:e,className:`cat-filter-bar${t?" occluded":""}`,role:"group","aria-label":"Filter tools by category",children:n.map(o=>{const l=r.has(o);return a.jsxs("button",{type:"button",className:`cat-filter${l?" off":""}`,onClick:()=>s(o),"aria-pressed":!l,title:`${l?"Show":"Hide"} ${Pd[o]} tools`,children:[a.jsx(Xne,{cat:o}),a.jsx("span",{className:"cat-name",children:Pd[o]})]},o)})})}const sse=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function ase(e){var n,r;const t=e.target;!(t!=null&&t.closest)||t.closest(sse)!==e.currentTarget||(e.preventDefault(),(r=(n=document.activeElement)==null?void 0:n.blur)==null||r.call(n))}function ose({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:r}){return a.jsxs("div",{ref:e,className:`drag-trash-zone ${t}${n==="leaving"?" leaving":""}`,role:"status",children:[a.jsx("svg",{className:"drag-trash-icon",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{d:"M8 7V5.8C8 4.8 8.8 4 9.8 4h4.4c1 0 1.8.8 1.8 1.8V7m-10 0h12M8 10v8m4-8v8m4-8v8M7 7l.7 13h8.6L17 7"})}),a.jsxs("span",{className:"drag-trash-copy",children:[a.jsx("span",{className:"drag-trash-text",children:t==="over"?a.jsxs(a.Fragment,{children:["Release to remove ",a.jsx("strong",{className:"drag-trash-name",children:r||"this card"})]}):"Drop here to remove from the board"}),a.jsx("span",{className:"drag-trash-hint",children:t==="over"?"The session list (L) brings it back":"The session keeps running"})]})]})}function ise({canvasRef:e,bubbling:t,dragging:n,trash:r,zoom:s,viewport:o,stateRef:l,peek:c,children:d}){const{trashDragging:h,trashState:f,trashPhase:p,trashZoneRef:g,trashLabel:v}=r,{lod:N,lodRef:k}=s,{markCanvasInput:x}=o,{peekAgent:j,peekLabel:b,peekRecap:_,peekBounds:E}=c;return a.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${n?" dragging-any":""}${h&&f==="over"?" trash-hover":""}`,"data-lod":N,ref:e,onMouseDownCapture:ase,onPointerDownCapture:x,onPointerUpCapture:x,onWheelCapture:x,onFocusCapture:R=>{const T=R.target;if(!G0(T)||k.current==null||k.current==="detail")return;const A=T.getAttribute("data-id");A&&l.current.agents.has(A)&&T.matches(":focus-visible")&&SL(A,T,"focus")},onBlurCapture:R=>{var A,U;const T=(U=(A=R.target).getAttribute)==null?void 0:U.call(A,"data-id");T&&la(T)},children:[d,La(p)&&a.jsx(ose,{trashZoneRef:g,trashState:f,trashPhase:p,trashLabel:v}),a.jsx(Rte,{agentFor:j,recapFor:_,labelFor:b,bounds:E})]})}function lse({restarting:e,restartMode:t,live:n,paused:r}){return a.jsxs("div",{className:"conn-banner",role:"alert",children:[a.jsx("span",{className:"conn-dot"}),e?t==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${kt}…`:(()=>{const s=Nz({connected:n,paused:r});return a.jsxs(a.Fragment,{children:[`Lost connection to the ${kt} server. Reconnecting…`,s&&a.jsx("span",{className:"conn-sub",children:s})]})})()]})}function cse({oldName:e,version:t,dismissOldName:n}){return a.jsxs("div",{className:"ver-banner",role:"status",children:[a.jsx("span",{className:"ver-dot"}),a.jsxs("strong",{children:[e," still works — the deck is called ",kt," now."]}),t!=null&&t.renameFix?a.jsx("span",{className:"ver-sub",children:t.renameFix}):null,a.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}const zL="Thanks — that helps.",use=Array.from({length:11},(e,t)=>t);function dse(e){return e===0?"0 out of 10, not useful":e===10?"10 out of 10, extremely useful":`${e} out of 10`}const hse=6;function fse(e){const t=y.useRef(null);return y.useLayoutEffect(()=>{const n=t.current,r=n==null?void 0:n.closest(".app");if(!n||!r)return;const s=()=>r.style.setProperty("--rating-h",`${Math.ceil(n.getBoundingClientRect().height)}px`);s();const o=typeof ResizeObserver>"u"?null:new ResizeObserver(s);return o==null||o.observe(n),()=>{o==null||o.disconnect(),r.style.removeProperty("--rating-h")}},[e]),t}function pse(){var e;(e=document.getElementById("canvas"))==null||e.focus()}function mse({phase:e,score:t,onAnswer:n,onLater:r,onClose:s,onFeedback:o,onHold:l}){const c=fse(e),d=y.useRef(null),h=y.useRef(null),f=y.useRef(!1);y.useEffect(()=>{var g,v;e!=="thanks"||!f.current||(f.current=!1,Cn(((g=document.activeElement)==null?void 0:g.tagName)??null)&&((v=d.current??h.current)==null||v.focus()))},[e]);const p=g=>{var v;(v=c.current)!=null&&v.contains(document.activeElement)&&pse(),g()};return e==="thanks"?a.jsxs("div",{ref:c,className:"ver-banner note rating-banner",onFocus:()=>l(!0),onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||l(!1)},children:[a.jsx("span",{className:"ver-dot"}),a.jsx("strong",{children:zL}),t!==null&&t<=hse?a.jsx("button",{ref:d,type:"button",className:"ver-act",onClick:o,children:"Tell us what would make it better"}):null,a.jsx("button",{ref:h,type:"button","aria-label":"Dismiss",className:"ver-close",onClick:()=>p(s),children:"×"})]}):a.jsxs("div",{ref:c,className:"ver-banner note rating-banner",role:"group","aria-labelledby":"rating-question",children:[a.jsx("span",{className:"ver-dot"}),a.jsx("strong",{id:"rating-question",children:"How useful is ccdeck to you?"}),a.jsx("span",{className:"rating-scale",children:use.map(g=>a.jsx("button",{type:"button",className:"rating-pick","aria-label":dse(g),onClick:v=>{f.current=v.detail===0||v.currentTarget.matches(":focus-visible"),n(g)},children:g},g))}),a.jsx("span",{className:"ver-sub rating-ends","aria-hidden":"true",children:"0 not at all · 10 extremely"}),a.jsx("button",{type:"button",className:"ver-act",onClick:()=>p(r),children:"Not now"})]})}const gse=3e4;function yse({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function wse({bundle:e,running:t,pending:n,lastTried:r}){return t?yse({bundle:e,running:t,lastTried:r})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function vse(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function xse({asked:e,reported:t}){return t?t!==e:!1}function WL(e){const t=e.thresholdMs??gse;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 bse(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 kse(e,t){return e?t==null?"auto when idle":`auto in ${bse(t)}`:"auto-restart off"}function HR(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function Nse(e,t=!1){return e<=0&&t?{label:"Restart anyway",clause:"the canvas is paused — running agents cannot be seen"}: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 jse(e){const t=WL(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}}const VR={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",one_off:"this deck runs from a one-off pnpm dlx, bunx or yarn dlx copy that cannot be upgraded in place — to keep one, 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:"};function Sse({notice:e,version:t,dismissNotice:n,upgradeState:r,startUpgrade:s,copyCommand:o,cmdCopied:l,autoRestart:c,toggleAutoRestart:d,askRestart:h,restartCopy:f,restartFuseMs:p,restarting:g}){var v,N,k;return a.jsxs("div",{className:`ver-banner ${e.kind}`,role:"status",children:[a.jsx("span",{className:`ver-dot${p==null?"":" armed"}`}),e.kind==="restart"?a.jsxs(a.Fragment,{children:[a.jsxs("strong",{children:["v",e.to," is installed — this deck still runs v",e.from,"."]}),t!=null&&t.canRestart?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"ver-act",onClick:()=>h(),...Dr(g),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
|
|
106
106
|
|
|
107
107
|
Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.`,children:g?"restarting…":f.label}),!g&&a.jsx("span",{className:"ver-sub",children:f.clause}),a.jsxs("label",{className:"ver-auto",children:[a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":c,onClick:d,"aria-label":"Auto-restart when idle",title:c?"Updates on its own. While you are here it restarts once nothing has been running for 30 seconds; while you are away it also installs the new version first. Click to require a click instead.":"Only updates when you click. Click to let it update itself when idle or while you are away.",children:a.jsx("span",{className:"switch-knob"})}),a.jsx("span",{"aria-hidden":!0,children:kse(c,p)})]})]}):a.jsx("span",{className:"ver-sub",title:"Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.",children:"Restart it to pick up the new code."})]}):a.jsxs(a.Fragment,{children:[a.jsxs("strong",{children:[kt," v",e.to," is out — you are on v",e.from,"."]}),(t==null?void 0:t.upgradeMode)==="install"&&r!=="failed"&&a.jsx("button",{type:"button",className:"ver-act",onClick:s,...Dr(r==="running",r==="done"),title:`Runs ${((v=t==null?void 0:t.upgrade)==null?void 0:v.command)??(t==null?void 0:t.command)??"npm i -g"} here, then restarts once nothing is running.`,children:r==="running"?"installing…":r==="done"?"installed":"Update now"}),(t==null?void 0:t.upgradeMode)==="npx"&&(t==null?void 0:t.canRestart)&&a.jsx("button",{type:"button",className:"ver-act",onClick:()=>h({upgrade:!0}),...Dr(g),title:`Runs ${t==null?void 0:t.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:g?"fetching…":r==="failed"?"Retry update":"Update & restart"}),r==="failed"?a.jsxs("span",{className:"ver-sub fail",title:((N=t==null?void 0:t.upgrade)==null?void 0:N.error)??"",children:[(t==null?void 0:t.upgradeMode)==="npx"?"update failed":"install failed",": ",((k=t==null?void 0:t.upgrade)==null?void 0:k.error)??"unknown error"," — run it yourself:"]}):(t==null?void 0:t.upgradeMode)==="npx"?a.jsx("span",{className:"ver-sub",children:t!=null&&t.canRestart?"npx cannot upgrade in place, so the deck re-runs:":VR.npx}):t!=null&&t.upgradeBlocked?a.jsx("span",{className:"ver-sub",children:Ot(VR,t.upgradeBlocked)??"cannot install from here"}):null,a.jsxs("button",{type:"button",className:"ver-cmd",onClick:o,title:"Copy to clipboard",children:[a.jsx("code",{children:t==null?void 0:t.command}),a.jsx("span",{className:"ver-cmd-hint",children:l?"copied":"copy"})]})]}),a.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}function _se({restart:e,versionCheck:t,upgrade:n,oldNameNotice:r,rating:s,onFeedback:o,everConnected:l,live:c,paused:d}){const{autoRestart:h,toggleAutoRestart:f,restarting:p,restartMode:g,restartedTo:v,askRestart:N,restartCopy:k,restartFuseMs:x}=e,{version:j,notice:b,noticeOpen:_,dismissNotice:E}=t,{upgradeState:R,startUpgrade:T,copyCommand:A,cmdCopied:U}=n,{oldName:L,oldNameOpen:F,dismissOldName:O}=r,{ratingPhase:I,ratingScore:B,answerRating:M,rateLater:$,closeRating:P,holdThanks:G}=s,K=v?a.jsxs("div",{className:"ver-banner done",role:"status",children:[a.jsx("span",{className:"ver-dot"}),a.jsxs("strong",{children:["Restarted — now running v",v,"."]}),a.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):l&&!c?a.jsx(lse,{restarting:p,restartMode:g,live:c,paused:d}):_&&b?a.jsx(Sse,{notice:b,version:j,dismissNotice:E,upgradeState:R,startUpgrade:T,copyCommand:A,cmdCopied:U,autoRestart:h,toggleAutoRestart:f,askRestart:N,restartCopy:k,restartFuseMs:x,restarting:p}):F&&L?a.jsx(cse,{oldName:L,version:j,dismissOldName:O}):I!=="hidden"?a.jsx(mse,{phase:I,score:B,onAnswer:M,onLater:$,onClose:P,onFeedback:o,onHold:G}):null;return a.jsxs(a.Fragment,{children:[K,a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:I==="thanks"?zL:""})]})}function Ese(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function Cse(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 Tse(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function Ase(e,t){const n=Tse(e),r=(...l)=>[n?`${n} on the canvas`:null,...l,"layout, pins and selection"].filter(c=>c!==null),s="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:s,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. ${s}`,confirm:"Clear everything"};if(!t.mine){const l=t.ownerPort===null?"another running deck owns that file":`the deck on port ${t.ownerPort} owns that file`,c=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{goes:r(),stays:[`the event log — ${l}${c}`,"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:s,confirm:"Clear everything"};const o=t.decks-1;return{goes:r(`the event log ${o===1?"1 other running deck shares":`${o} other running decks share`} with this one — every session recorded in it, not just the ones drawn here`),stays:[o===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:s,confirm:"Clear everything"}}function Rse({agentCount:e,onConfirm:t,onCancel:n}){const r=y.useRef(null),s=ut(n,{focusRef:r,layer:eU}),o=gt(n),[l,c]=y.useState(null);y.useEffect(()=>{let g=!1;return fetch("/api/clear").then(v=>v.ok?v.json():null).then(v=>{g||c(Cse(v))}).catch(()=>{}),()=>{g=!0}},[]);const{goes:d,stays:h,final:f,confirm:p}=Ase(e,l);return a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal clear-confirm",onClick:g=>g.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:"status-dot err","aria-hidden":!0}),a.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("dl",{className:"cc-plan",children:[a.jsx("dt",{children:"Goes"}),a.jsx("dd",{children:d.map(g=>a.jsx("span",{children:g},g))}),a.jsx("dt",{children:"Stays"}),a.jsx("dd",{children:h.length>0?h.map(g=>a.jsx("span",{children:g},g)):a.jsx("span",{children:"nothing"})})]}),f&&a.jsx("p",{className:"cc-final",children:f}),a.jsxs("div",{className:"cc-actions",children:[a.jsx("button",{type:"button",ref:r,className:"btn",onClick:n,children:"Cancel"}),a.jsx("button",{type:"button",className:"btn danger",onClick:t,children:p})]})]})]})})}const kb=[{value:"bug",label:"Bug",question:"What happened?",placeholder:`I was trying to…
|
|
108
|
-
What did you expect to happen?`},{value:"idea",label:"Idea",question:"What would make ccdeck better?",placeholder:"It would be useful if…"},{value:"other",label:"Other",question:"What would you like to tell us?",placeholder:"Write anything…"}];function HL(e){return kb.find(t=>t.value===e)??kb[0]}const Nb=3,lx=120,Mse=1e4,$se=200,Ise="Write something first.";function GR(e){return e.trim()!==""}function Ose(e){var o;const t=e.trim();if(t==="")return"";const n=KR(t.split(/\r?\n/,1)[0]),r=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,s=cx(r).length>=Nb?cx(r):cx(n);return Pse(s.length>=Nb?s:KR(t))}function Lse(e,t){const n=Ose(t);return n.length>=Nb?n:`${HL(e).label}: ${n}`}function KR(e){return e.replace(/\s+/g," ").trim()}function cx(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function Pse(e){if(e.length<=lx)return e;const t=e.slice(0,lx-1),n=t.lastIndexOf(" ");return`${(n>=lx/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function Dse({kind:e,body:t,contact:n}){const r={kind:e,title:Lse(e,t),body:t.trim()};return n.trim()!==""&&(r.contact=n.trim()),r}function Fse(e){const t=e;return(t==null?void 0:t.ok)!==!0||typeof t.appVersion!="string"||typeof t.platform!="string"||t.appVersion===""||t.platform===""?null:{appVersion:t.appVersion,platform:t.platform}}const Bse={darwin:"macOS",win32:"Windows",linux:"Linux"};function qse(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),r=t===-1?"":e.slice(t+1),s=Bse[n]??n;return r?`${s} · ${r}`:s}function Use(e){return e?`ccdeck ${e.appVersion} · ${qse(e.platform)}`:null}const zse="sent with it",Wse="Your ccdeck version and system are sent with it.",Hse="Add details",Vse="How to reach you",Gse="Email or GitHub @name",Kse="Only if you would like an answer.",Yse=["It all goes to the people who make ccdeck, with the version and system below.","Nothing becomes public by being sent. They may open a public GitHub issue from it, choosing its title and text; your contact and screenshots are never put on one."];function Xse(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function VL(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function Zse(e){return/mac|iphone|ipad/i.test(e)?["⌘","Enter"]:["Ctrl","Enter"]}function Jse(e){return[...e].length===1}const GL="Thanks — feedback sent.";function YR(e,t,n){if(t==="vetoed")return"This deck was started with AGENTS_DECK_NO_INSTALL=1, which keeps it off the network, so nothing was sent.";if(e===429||t==="too_many")return"Too much feedback from this network in the last hour. Try again later; your text is still here.";if(e===413||t==="too_large")return"The images are too large to send together. Remove one and send again; your text is still here.";const r=n==null?void 0:n.images;return e===400&&Array.isArray(r)&&typeof r[0]=="string"?`The server did not accept an image. ${r[0]} Remove it and send again; your text is still here.`:e===400?"The server did not accept the message. It is still here; check it and send again.":"ccdeck's server could not be reached. Nothing was sent; your text is still here, so try again in a moment."}function Qse(e){return e==="sending"?"Sending…":e==="sent"?GL:""}const XR=1400,eae=160;function tae({kind:e,onChange:t}){return a.jsxs("fieldset",{className:"fb-kinds",children:[a.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),kb.map(n=>a.jsxs("label",{className:"fb-kind",children:[a.jsx("input",{type:"radio",name:"feedback-kind",value:n.value,checked:e===n.value,onChange:()=>t(n.value),onKeyDown:r=>{VL(r.nativeEvent)&&r.preventDefault()}}),n.label]},n.value))]})}const KL="fb-details";function nae({open:e,onToggle:t}){return a.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":KL,onClick:t,children:[Hse,a.jsx("svg",{className:"fb-chev",width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 3.75 5 6.25l2.5-2.5"})})]})}function rae({open:e,contact:t,onContact:n}){const r=y.useId();return a.jsx("div",{id:KL,className:"fb-details","data-open":e||void 0,children:a.jsx("div",{className:"fb-details-clip",children:a.jsxs("div",{className:"fb-details-body",children:[a.jsxs("div",{className:"fb-field",children:[a.jsxs("label",{className:"fb-field-label",htmlFor:"fb-contact",children:[Vse,a.jsx("span",{className:"fb-optional",children:"optional"})]}),a.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:$se,autoComplete:"email",placeholder:Gse,"aria-describedby":r,onChange:s=>n(s.target.value),onKeyDown:s=>{VL(s.nativeEvent)&&s.preventDefault()}}),a.jsx("p",{id:r,className:"fb-hint",children:Kse})]}),a.jsx("div",{className:"fb-where",children:Yse.map(s=>a.jsx("p",{children:s},s))})]})})})}const ti=3,sae=5*1024*1024,aae=12*1024*1024,jb=8192,oae=64*1024,iae=256*1024,lae=.92,cae=640,YL=.9,uae=.85,dae=6,hae=512*1024,Fd={png:"image/png",jpeg:"image/jpeg"},fae={png:"png",jpeg:"jpg"},pae=[137,80,78,71,13,10,26,10],mae=[255,216,255];function XL(e){const t=n=>e.length>=n.length&&n.every((r,s)=>e[s]===r);return t(pae)?"png":t(mae)?"jpeg":null}function gae(e){const t=XL(e);return t==="png"?yae(e):t==="jpeg"?vae(e):null}function yae(e){const t=[73,72,68,82];if(e.length<24||!t.every((r,s)=>e[12+s]===r))return null;const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:n.getUint32(16),height:n.getUint32(20)}}function wae(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function vae(e){let t=2;for(;t<e.length;){if(e[t]!==255)return null;for(;t<e.length&&e[t]===255;)t++;const n=e[t++];if(n===void 0||n===217||n===218)return null;if(n===1||n>=208&&n<=215)continue;if(t+2>e.length)return null;const r=e[t]<<8|e[t+1];if(r<2)return null;if(wae(n))return t+7>e.length?null:{height:e[t+3]<<8|e[t+4],width:e[t+5]<<8|e[t+6]};t+=r}return null}function ZR(e,t){return e.bytes>t||e.width>jb||e.height>jb}function xae(e){return Math.min(sae,aae-oae-e)}function ZL(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function bae(e,t){const n=jb/Math.max(e.width,e.height),r=e.bytes>t?Math.sqrt(t/e.bytes)*YL:1;return ZL(e,Math.min(1,n,r))}async function kae(e,t,n){let r=bae(e,t),s=e.format;for(let o=0;o<dae;o++){const l=await n(r,s,s==="jpeg"?lae:void 0);if(!l)return null;if(l.size<=t)return{...r,blob:l,format:s};if(s==="png"){s="jpeg";continue}if(r=ZL(r,Math.min(uae,Math.sqrt(t/l.size)*YL)),Math.max(r.width,r.height)<cae)return null}return null}async function Nae(e,t,n){const r=new Uint8Array(await e.slice(0,hae).arrayBuffer()),s=XL(r);if(!s)return{ok:!1,problem:"type"};if(t<iae)return{ok:!1,problem:"no_room"};const o=e.type===Fd[s]?e:new Blob([e],{type:Fd[s]}),l=gae(r);if(l&&!ZR({...l,bytes:e.size},t))return{ok:!0,blob:o,resized:null};const c=await n(e).catch(()=>null);if(!c)return{ok:!1,problem:"unreadable"};try{const d={width:c.width,height:c.height,bytes:e.size,format:s};if(!ZR(d,t))return{ok:!0,blob:o,resized:null};const h=await kae(d,t,c.encoder);return h?{ok:!0,blob:h.blob,resized:{width:h.width,height:h.height}}:{ok:!1,problem:"too_large"}}finally{c.release()}}function jae(e){return({width:t,height:n},r,s)=>new Promise(o=>{const l=document.createElement("canvas");l.width=t,l.height=n;const c=l.getContext("2d");if(!c)return o(null);r==="jpeg"&&(c.fillStyle="white",c.fillRect(0,0,t,n)),c.imageSmoothingQuality="high",c.drawImage(e,0,0,t,n),l.toBlob(d=>{l.width=0,l.height=0,o(d)},Fd[r],s)})}const Sae=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:jae(t),release:()=>t.close()}};function _ae(e){return e.includes("Files")}function Eae({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function Cae(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function Tae(e,t){if(t.length===0)return{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)};const n=new FormData;return n.append("kind",e.kind),n.append("title",e.title),n.append("body",e.body),e.contact!==void 0&&n.append("contact",e.contact),t.forEach((r,s)=>{const o=r.type===Fd.jpeg?"jpeg":"png";n.append("images",r,`image-${s+1}.${fae[o]}`)}),{method:"POST",body:n}}const Aae="Add screenshot",JR="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",Rae="A screenshot can show emails, costs and paths. Crop out what should not be seen.",QR="Three images at most. Remove one to add another.",Mae="An image could not be attached, so nothing was sent. Check the images and send again; your text is still here.";function $ae(e,t,n){const r=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${r}`}function Iae(e,t){const n=`${e} of ${ti}`;return t>0?`${n} · ${t} resized to fit`:n}function Oae(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function Lae(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function Pae(e,t){const n=Lae(t);return e==="type"?`${n} is not a PNG or a JPEG, so it was not added. GIF, WebP and HEIC are not converted; save it as a PNG or a JPEG first.`:e==="no_room"?`There is no room left for ${n}: images go at up to 12 MB in all. Remove one to add it.`:e==="unreadable"?`${n} could not be read as an image.`:`${n} could not be made small enough to send: images go at up to 5 MB each.`}const JL="image/png,image/jpeg";function QL({className:e="fb-glyph"}){return a.jsxs("svg",{className:e,width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{x:"1.8",y:"2.4",width:"10.4",height:"9.2",rx:"1.6"}),a.jsx("circle",{cx:"5",cy:"5.6",r:"1"}),a.jsx("path",{d:"M2.4 10.4 5.5 7.6l2.1 1.8 1.5-1.3 2.5 2.2"})]})}function Dae({images:e,buttonRef:t}){const n=y.useRef(null),r=e.shots.length>=ti;return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:JR,"aria-describedby":"fb-attach-hint",onClick:()=>{var s;return r?e.sayFull():(s=n.current)==null?void 0:s.click()},children:[a.jsx(QL,{}),Aae]}),a.jsx("span",{id:"fb-attach-hint",hidden:!0,children:JR}),a.jsx("input",{ref:n,type:"file",accept:JL,multiple:!0,hidden:!0,onChange:s=>{e.add(Array.from(s.target.files??[])),s.target.value=""}})]})}function Fae({images:e,addRef:t}){const n=y.useRef(new Map),r=y.useRef(null),s=y.useRef(null),o=y.useRef(null),[l,c]=y.useState(null),{shots:d}=e,h=Iae(d.length,d.filter(g=>g.resized).length);y.useLayoutEffect(()=>{var g;l!==null&&((g=l==="add"?t.current:n.current.get(l))==null||g.focus(),c(null))},[l,t]),y.useEffect(()=>{var g;e.problem&&((g=r.current)==null||g.scrollIntoView({block:"nearest"}))},[e.problem,e.problemId]);function f(g){c(Cae(d.map(v=>v.id),g)??"add"),e.remove(g)}function p(g){var v;o.current=g,(v=s.current)==null||v.click()}return a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"vis-hidden",role:"status",children:e.announcement}),a.jsx("input",{ref:s,type:"file",accept:JL,hidden:!0,onChange:g=>{const v=o.current;v!==null&&e.replace(v,Array.from(g.target.files??[])),o.current=null,g.target.value=""}}),d.length>0&&a.jsxs("div",{className:"fb-shots",children:[a.jsxs("div",{className:"fb-shots-row",children:[a.jsx("ul",{className:"fb-shots-list",children:d.map((g,v)=>a.jsxs("li",{className:"fb-shot","data-fitting":g.blob?void 0:!0,children:[a.jsxs("button",{type:"button",className:"fb-shot-pick","aria-label":$ae(v,g.name,g.resized),onClick:()=>p(g.id),children:[a.jsx("img",{className:"fb-shot-img",src:g.url,alt:""}),g.blob?a.jsx("span",{className:"fb-shot-cue","aria-hidden":"true",children:"Replace"}):a.jsx("span",{className:"fb-shot-busy","aria-hidden":"true",children:"Resizing…"})]}),a.jsx("button",{ref:N=>{N?n.current.set(g.id,N):n.current.delete(g.id)},type:"button",className:"glyph-btn fb-shot-remove","aria-label":`Remove image ${v+1}`,title:`Remove image ${v+1}`,onClick:()=>f(g.id),children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 2.5 7.5 7.5M7.5 2.5 2.5 7.5"})})})]},g.id))}),a.jsx("span",{className:"fb-shots-count",children:h})]}),a.jsx("p",{className:"fb-hint",children:Rae})]}),e.problem&&a.jsx("p",{ref:r,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function Bae(e,t,n){return n?e.map(r=>r.id===t.id?t:r):[...e,t]}function qae(e,t,n){return n?e.map(r=>r.id===t?n:r):e.filter(r=>r.id!==t)}function Uae(){const[e,t]=y.useState([]),[n,r]=y.useState({problem:"",id:0}),s=y.useRef(0),o=y.useCallback(T=>{T&&s.current++,r(A=>T?{problem:T,id:A.id+1}:A.problem?{problem:"",id:A.id}:A)},[]),[l,c]=y.useState(""),d=y.useRef([]),h=y.useRef(null),f=y.useRef(1),p=y.useRef(!0),g=y.useCallback(T=>{d.current=T(d.current),t(d.current)},[]);y.useEffect(()=>(p.current=!0,()=>{p.current=!1;for(const T of d.current)URL.revokeObjectURL(T.url)}),[]);const v=y.useCallback(async(T,A)=>{const U=d.current.reduce((P,G)=>{var K;return P+(G.id===(A==null?void 0:A.id)?0:((K=G.blob)==null?void 0:K.size)??0)},0),L=(A==null?void 0:A.id)??f.current++,F=URL.createObjectURL(T),O={id:L,name:T.name||"image",url:F,blob:null,resized:null};let I=!1;const B=()=>{I||(I=!0,g(P=>Bae(P,O,A!==void 0)))},M=await Nae(T,xae(U),async P=>(B(),Sae(P))).catch(()=>({ok:!1,problem:"unreadable"})),$=d.current.some(P=>P.id===L);return!p.current||!$&&(I||A)?(URL.revokeObjectURL(F),A&&URL.revokeObjectURL(A.url),""):M.ok?(B(),A&&URL.revokeObjectURL(A.url),g(P=>P.map(G=>G.id===L?{...G,blob:M.blob,resized:M.resized}:G)),""):(URL.revokeObjectURL(F),I&&g(P=>qae(P,L,A)),Pae(M.problem,T.name||"image"))},[g]),N=y.useCallback(async T=>{o("");const A=[];let U=0,L=0;for(const O of T){if(!p.current)return;if(d.current.length>=ti){U++;continue}const I=d.current.length,B=await v(O);B&&A.push(B),d.current.length>I&&L++}if(!p.current)return;U>0&&A.push(L===0&&A.length===0?QR:Oae(U)),o(A.join(" "));const F=d.current.length;L>0&&c(`${L===1?"Image":`${L} images`} added, ${F} of ${ti}.`)},[v,o]),k=y.useCallback(async(T,A)=>{o("");const U=d.current.find(O=>O.id===T);if(!U)return N([A]);const L=await v(A,U);if(!p.current)return;o(L);const F=d.current.findIndex(O=>O.id===T);!L&&F!==-1&&c(`Image ${F+1} replaced, ${d.current.length} of ${ti}.`)},[N,v,o]),x=y.useCallback(T=>{h.current=(h.current??Promise.resolve()).then(T).catch(()=>{})},[]),j=y.useCallback(T=>{T.length>0&&x(()=>N(T))},[N,x]),b=y.useCallback((T,A)=>{const U=A[0];U&&x(()=>k(T,U))},[x,k]),_=y.useCallback(T=>{const A=d.current.find(U=>U.id===T);A&&(URL.revokeObjectURL(A.url),g(U=>U.filter(L=>L.id!==T)),o(""),c(`Image removed, ${d.current.length} of ${ti}.`))},[g,o]),E=y.useCallback(()=>o(QR),[o]),R=y.useCallback(async()=>{const T=s.current;return await h.current,s.current!==T?null:d.current.flatMap(A=>A.blob?[A.blob]:[])},[]);return{shots:e,problem:n.problem,problemId:n.id,announcement:l,add:j,replace:b,remove:_,sayFull:E,ready:R}}function zae(){const[e,t]=y.useState(null);return y.useEffect(()=>{let n=!0;return fetch("/api/feedback").then(r=>r.ok?r.json():null).then(r=>{n&&t(Fse(r))}).catch(()=>{}),()=>{n=!1}},[]),e}function Wae(e){const[t,n]=y.useState({state:"idle"}),r=y.useRef(!1),s=y.useRef(null);y.useEffect(()=>()=>{var l;return(l=s.current)==null?void 0:l.abort()},[]);async function o(l){if(!lr(r.current))return;r.current=!0;const{signal:c}=s.current=new AbortController;n({state:"sending"});try{const d=await e.ready();if(c.aborted)return;if(!d){n({state:"failed",message:Mae});return}const h=await fetch("/api/feedback",{...Tae(Dse(l),d),signal:c}),f=await h.json().catch(()=>null);n(h.ok&&(f!=null&&f.ok)?{state:"sent"}:{state:"failed",message:YR(h.status,f==null?void 0:f.reason,f==null?void 0:f.errors)})}catch{c.aborted||n({state:"failed",message:YR(0,null)})}finally{r.current=!1}}return{outcome:t,sending:t.state==="sending",send:o}}function Hae(e,t){const[n,r]=y.useState(!1),s=y.useRef(t);return s.current=t,y.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>r(!0),XR),l=window.setTimeout(()=>s.current(),XR+eae);return()=>{window.clearTimeout(o),window.clearTimeout(l)}},[e]),n}function Vae(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function eP({onClose:e,initialKind:t,initialBody:n}){const r=y.useRef(null),s=y.useRef(null),o=y.useRef(null),l=y.useRef(null),c=y.useRef(null),d=y.useRef(null),h=y.useRef(null),f=y.useRef(0),p=ut(e,{focusRef:r}),g=gt(e),[v,N]=y.useState(t??"bug"),[k,x]=y.useState(n??""),[j,b]=y.useState(""),[_,E]=y.useState(!1),[R,T]=y.useState(!1),[A,U]=y.useState(!1),L=Uae(),F=Use(zae()),{outcome:O,sending:I,send:B}=Wae(L),M=O.state==="sent",$=Hae(M,e),P=HL(v),G=R&&!GR(k),[K,q]=Zse(Vae());y.useEffect(()=>{var ke,ae;const se=l.current;if(!se)return;const pe=se.contains(document.activeElement)||Cn(((ke=document.activeElement)==null?void 0:ke.tagName)??null);se.inert=M,M&&pe&&((ae=s.current)==null||ae.focus())},[M]),y.useEffect(()=>{var ae,fe;const se=c.current;if(!se)return;if(I){const me=document.activeElement;h.current=me&&se.contains(me)?me:null,se.inert=!0,h.current&&((ae=d.current)==null||ae.focus());return}se.inert=!1;const pe=h.current;h.current=null;const ke=document.activeElement===d.current||Cn(((fe=document.activeElement)==null?void 0:fe.tagName)??null);!M&&pe&&ke&&pe.focus()},[I,M]);function H(se){var pe;if(se.preventDefault(),!GR(k)){T(!0),(pe=r.current)==null||pe.focus();return}B({kind:v,body:k,contact:j})}const D=!M&&!I,W=se=>_ae(Array.from(se.dataTransfer.types));function J(se){!W(se)||!D||(se.preventDefault(),f.current++,U(!0))}function V(se){W(se)&&(se.preventDefault(),se.dataTransfer.dropEffect=D?"copy":"none")}function X(se){W(se)&&(f.current=Math.max(0,f.current-1),f.current===0&&U(!1))}function Y(se){W(se)&&(se.preventDefault(),f.current=0,U(!1),D&&L.add(Array.from(se.dataTransfer.files)))}function Z(se){se.target!==se.currentTarget||!W(se)||(se.preventDefault(),se.dataTransfer.dropEffect="none")}function ee(se){W(se)&&se.preventDefault()}function ne(se){if(!D)return;const pe=Array.from(se.clipboardData.files),ke=se.target,ae=ke instanceof HTMLTextAreaElement||ke instanceof HTMLInputElement,fe=Array.from(se.clipboardData.types).includes("text/plain");Eae({files:pe.length,hasText:fe,intoTextField:ae})&&(se.preventDefault(),L.add(pe))}return a.jsx("div",{className:"modal-backdrop",...g,role:"presentation",onDragOver:Z,onDrop:ee,"data-leaving":$||void 0,children:a.jsxs("div",{ref:p,className:"modal feedback-dialog",onClick:se=>se.stopPropagation(),onDragEnter:J,onDragOver:V,onDragLeave:X,onDrop:Y,onPaste:ne,role:"dialog","aria-modal":"true","aria-labelledby":"feedback-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"feedback-title",className:"modal-tool-name",children:"Send feedback"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:s,type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsx("p",{className:"vis-hidden",role:"status",children:Qse(O.state)}),a.jsxs("div",{className:"fb-stage",children:[a.jsxs("form",{ref:l,className:"fb-form",onSubmit:H,onKeyDown:se=>{Xse(se.nativeEvent)&&(se.preventDefault(),se.currentTarget.requestSubmit())},noValidate:!0,children:[a.jsxs("section",{ref:c,className:"modal-body fb-body",children:[a.jsx(tae,{kind:v,onChange:N}),a.jsxs("div",{className:"fb-compose",children:[a.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:P.question}),a.jsx("textarea",{ref:r,id:"fb-body",className:"ap-manage-input fb-message",value:k,maxLength:Mse,rows:5,placeholder:P.placeholder,onChange:se=>x(se.target.value),"aria-invalid":G||void 0,"aria-describedby":G?"fb-body-error":void 0,required:!0}),G&&a.jsx("p",{id:"fb-body-error",className:"fb-error",children:Ise}),a.jsx(Fae,{images:L,addRef:o}),a.jsxs("div",{className:"fb-tools",children:[a.jsx(Dae,{images:L,buttonRef:o}),a.jsx(nae,{open:_,onToggle:()=>E(se=>!se)})]}),a.jsx(rae,{open:_,contact:j,onContact:b})]}),a.jsx("p",{className:"fb-facts",children:F?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"fb-facts-value",children:F})," — ",zse]}):Wse}),O.state==="failed"&&a.jsx("p",{className:"fb-error",role:"alert",children:O.message})]}),a.jsxs("div",{className:"fb-foot",children:[a.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[a.jsx("kbd",{"data-symbol":Jse(K)||void 0,children:K}),a.jsx("kbd",{children:q})," to send"]}),a.jsx("button",{type:"button",className:"btn",onClick:e,children:"Cancel"}),a.jsx("button",{ref:d,type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...Dr(I),children:a.jsxs("span",{className:"fb-send-label",children:[a.jsx("span",{className:"fb-send-idle",children:"Send feedback"}),a.jsx("span",{className:"fb-send-busy",children:"Sending…"})]})})]})]}),M&&a.jsxs("div",{className:"fb-done",children:[a.jsx(_d,{}),a.jsx("p",{className:"fb-done-line",children:GL})]})]}),a.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":A||void 0,children:a.jsxs("div",{className:"fb-drop-frame",children:[a.jsx(QL,{className:"fb-drop-glyph"}),a.jsx("p",{className:"fb-drop-title",children:"Drop to attach"}),a.jsx("p",{className:"fb-drop-note",children:"PNG or JPEG, up to three"})]})})]})})}const Gae="Press Esc first if a key does nothing.",Kae=[{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:"Delete",action:"take the selected card off the board — the session list (L) brings it back",binds:["Delete"]},{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 Yae({onClose:e,onTour:t}){const n=ut(e),r=gt(e);return a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal key-help",onClick:s=>s.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[t&&a.jsxs("div",{className:"guide-door",children:[a.jsx("span",{children:"Eight pictures of what the deck shows."}),a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Take the tour"})]}),a.jsx("div",{className:"shortcuts",children:Kae.map(s=>a.jsxs(y.Fragment,{children:[a.jsx("h3",{className:"kh-group",children:s.title}),s.rows.map(o=>a.jsxs("div",{className:"sc",children:[a.jsx("kbd",{children:o.cap}),a.jsx("span",{children:o.action})]},`${s.title}:${o.cap}:${o.action}`))]},s.title))}),a.jsx("p",{className:"kh-foot",children:Gae})]})]})})}function tP(e,t){return y.lazy(()=>e().catch(n=>(console.warn(`ccdeck could not load ${t}`,n),{default:({onClose:r})=>a.jsx(Xae,{name:t,onClose:r})})))}function Xae({name:e,onClose:t}){const n=y.useRef(null),r=ut(t,{focusRef:n}),s=gt(t);return a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal dialog-missing",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"dialog-missing-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"dialog-missing-title",className:"modal-tool-name",children:e})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{className:"dm-note",children:[e," did not load. The deck has most likely been updated since this tab opened, and a reload picks up the new version."]}),a.jsxs("div",{className:"dm-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"}),a.jsx("button",{type:"button",ref:n,className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"})]})]})]})})}function Zae(e,t){return`${e}#${t}`}function Jae(e,{lan:t,now:n,closed:r}){if(t===void 0)return[];const s=[];for(const o of e??[]){const l=o.reauth;if(!l||l.dismissed||o.origin!=="ccdeck_signin")continue;const c=Zae(l.key,l.since);if(r.has(c)||DG(l.key,o.email,t,n))continue;const d=o.email??"";s.push({id:c,key:l.key,since:l.since,num:o.num,email:d,name:d||o.alias||`Account ${o.num}`,alias:d&&o.alias?o.alias:null})}return s}function Qae(e,t){const n=String((t==null?void 0:t.email)??"").trim().toLowerCase();return n?e.filter(r=>r.email.toLowerCase()===n&&((t==null?void 0:t.num)==null||String(r.num)===String(t.num))).map(r=>r.id):[]}function nP({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function eoe(e){return e===1?"Account needs your attention":"Accounts need your attention"}function toe(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const noe="Login expired",roe="Until then the deck cannot read its usage or switch to it. Signing in again brings it back — it keeps its slot, its alias and its history.",soe="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function aoe(e,t){const n=(e??[]).filter(s=>s&&typeof s.fp=="string"&&!t.has(s.fp));if(!n.length)return{request:null,waiting:0};const r=[...n].sort((s,o)=>(s.at??0)-(o.at??0));return{request:r[0],waiting:r.length-1}}function ooe({request:e,waiting:t,busy:n,now:r,onAccept:s,onDecline:o,onLater:l}){const c=y.useRef(null),d=ut(l,{focusRef:c}),h=gt(l),f=ia(n,"accept"),p=ia(n,"dismiss");return a.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal lan-ask",onClick:g=>g.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title","aria-describedby":"lan-ask-who",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("i",{className:"ap-pulse","aria-hidden":!0}),a.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:"A deck wants to pair"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:l,"aria-label":"Answer later (Esc)",title:"Answer later (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{id:"lan-ask-who",className:"lan-ask-who",children:[a.jsx("strong",{className:"lan-ask-name",children:e.name})," at ",a.jsx("code",{className:"ap-lan-code",children:e.addr})," · asked ",b0(e.at,r)]}),a.jsx("p",{className:"modal-note",children:"Paired decks repair each other's expired logins. Accept only if you know this machine — what it shares is an account, not a screen."}),a.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",a.jsx("code",{className:"ap-lan-code",children:e.fp})," — that machine shows its own under This deck on the network; the two should match."]}),t>0&&a.jsx("p",{className:"lan-ask-more",children:t===1?"One more deck is waiting behind this one.":`${t} more decks are waiting behind this one.`}),a.jsxs("div",{className:"lan-ask-acts",children:[a.jsx("button",{type:"button",ref:c,className:"btn",disabled:p.disabled,"aria-busy":p.busy,onClick:o,title:"Nothing is shared. If that deck asks again, this comes back.",children:n==="dismiss"?"declining…":"Decline"}),a.jsx("button",{type:"button",className:"btn primary",disabled:f.disabled,"aria-busy":f.busy,onClick:s,title:"Talk to this deck from now on, and repair its expired logins with this deck's own.",children:n==="accept"?"accepting…":"Accept"})]})]})]})})}function ioe(e){const t=y.useRef(!1),n=loe(e),r=nP({rows:n?1:0,ours:t.current,dialogs:ds.dialogDepth()});return t.current=r,r?n:null}function loe({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:r,deferLanPair:s}){const{request:o,waiting:l}=aoe(e,t.current);return o?a.jsx(ooe,{request:o,waiting:l,busy:n,now:Date.now(),onAccept:()=>void r("accept",o.fp),onDecline:()=>void r("dismiss",o.fp),onLater:()=>s(o.fp)},o.fp):null}function coe({rows:e,onSignIn:t,onLater:n,firstRef:r}){const s=e.length===1?e[0]:null;return a.jsxs("section",{className:"modal-body",children:[s?a.jsxs(a.Fragment,{children:[a.jsxs("p",{id:"reauth-lead",className:"reauth-lead",children:["The Claude login for ",a.jsx("strong",{className:"reauth-name",children:s.name}),s.alias?a.jsxs("span",{className:"reauth-alias",children:[" (",s.alias,")"]}):null," ","has expired and needs a new sign","‑","in."]}),a.jsx("p",{className:"reauth-note",children:roe})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:toe(e.length)}),a.jsx("ul",{className:"reauth-list",children:e.map((o,l)=>a.jsxs("li",{className:"reauth-row",children:[a.jsxs("span",{className:"reauth-who",title:o.alias?`${o.alias} — ${o.name}`:o.name,children:[o.name,o.alias?a.jsxs("span",{className:"reauth-alias",children:[" ",o.alias]}):null]}),a.jsx("span",{className:"reauth-what",children:noe}),a.jsx("button",{type:"button",className:"btn",ref:l===0?r:void 0,"aria-label":`Sign in again as ${o.name}`,onClick:()=>t(o),children:"Sign in again"})]},o.id))}),a.jsx("p",{className:"reauth-note",children:"Each keeps its slot, its alias and its history."})]}),a.jsxs("div",{className:"reauth-acts",children:[a.jsx("button",{type:"button",className:"btn",title:soe,onClick:n,children:"Not now"}),s&&a.jsx("button",{type:"button",className:"btn primary",ref:r,onClick:()=>t(s),children:"Sign in again"})]})]})}function uoe({rows:e,onSignIn:t,onLater:n}){const r=y.useRef(null),s=ut(n,{focusRef:r}),o=gt(n);return a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal reauth-ask",onClick:l=>l.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"reauth-title","aria-describedby":"reauth-lead",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"reauth-title",className:"modal-tool-name",children:eoe(e.length)})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Not now (Esc)",title:"Not now (Esc)",children:"×"})})]}),a.jsx(coe,{rows:e,onSignIn:t,onLater:n,firstRef:r})]})})}function doe({rows:e,signingIn:t,signIn:n,signedIn:r,refresh:s,closeSignIn:o,later:l,pairing:c=!1}){const d=y.useRef(!1),h=ds.dialogDepth()+(c?1:0),f=t!=null||nP({rows:e.length,ours:d.current,dialogs:h});return d.current=f,t?a.jsx(RI,{email:t.email||null,onClose:o,onChanged:s,onSignedIn:r}):f?a.jsx(uoe,{rows:e,onSignIn:n,onLater:l},e.length===1?"one":"many"):null}const hoe={"//":["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.28.0","3.28.1","3.29.3","3.29.4","3.29.6","3.29.7","3.29.9","3.33.1","3.35.0","3.35.1","3.36.0","3.36.1","3.36.4","3.36.5","3.36.6","3.36.7","3.36.8","3.36.9","3.37.0"],"3.36.3":[{title:"🔑 An expired login asks to be signed in again",body:"When an account you added with + → Sign in stops working, the deck now tells you in one dialog, with every affected account together and Sign in again beside each. That opens the usual sign-in with the address already filled in, and the account keeps its slot, its alias and its history. Not now leaves it marked in the Accounts panel and does not ask again until it has worked and stopped again. A paired deck holding a working copy gets to repair it first, and accounts that came from a share or Local network are never asked about."}],"3.34.1":[{title:"🗂️ The tray menu stays open while you read it",body:"On Linux the menu behind the tray icon could close by itself while agents were working, often before the row you pressed took the click, so it had to be opened and pressed again. It now changes only when something it says has changed, and stays open while you choose."}],"3.34.0":[{title:"🗺️ The network map shows who you are connected to",body:"Paired decks that are on stand closest to this one, and a light runs along their wires. Paired decks that are away come next, in a colour of their own, with how long they have been gone, and machines that are not paired stand outside in grey. Decks reached over Tailscale sit together in their own shaded slice instead of on dashed wires. Pointing at a deck opens its details beside the map: whether it is there, what to do next if anything, its address and what it runs, and every login the two share, the ones that need a look first."},{title:"🔑 A login that expired everywhere says so",body:`When a shared login expired on this deck and every paired deck that is on held an expired copy too, the row said "Login expired" and waited for a repair that could never come. It now says "Login expired on all online decks". Claude retires a login's other copies each time one machine refreshes it, so shared copies expire together: sign in again on any one machine and the others repair from it on their next round.`},{title:"💬 Send feedback from inside the deck",body:'Appearance settings has a "Send feedback…" button: pick what kind it is, write a title and a few lines, and add a way to reach you if you want an answer. It goes to the people who make ccdeck, who may open a public issue from it, never with your contact in it. If it cannot be sent, the form stays filled in and says why.'}],"3.33.0":[{title:"🪝 Hooks you add in Claude Code are no longer removed",body:"Claude Code's hook editor often files a new hook into the same group as the deck's own. Starting the deck, or uninstalling it, then removed the whole group, and your hook went with it without a word. The deck now takes out only its own command and leaves yours where it was, and the same goes for the old finish-sound hook. `ccdeck --uninstall` also stops the decks that are running, so an update in the background cannot put the hooks back."},{title:"🧵 Resumed Codex sessions show up again",body:"A Codex session picked up with `codex resume`, or one that ran for days, could go dark on the canvas and drop out of the 5-hour and 7-day usage, because the deck only looked in the two newest day folders. It now follows those sessions and counts their tokens. Two Codex sessions in the same folder get different id suffixes, and a `bash -lc` call shows the command it runs."},{title:"🤝 A deck paired by the accept switch brings in less",body:'A deck that paired through the automatic accept switch, and not through an invite, now brings in only the logins you have ticked on this deck, and nothing from it is ticked for sharing onward. Its dialog says "paired automatically — pair by invite to take it". Pairing by invite works as before. A typed address is no longer dropped after one failed round, and the sync port stays the same after a rename.'},{title:"⬆️ Desktop updates install when you expect them",body:'On Windows and Linux a downloaded update now installs when you quit. On a Mac, Quit installs it and the app stays closed. The Linux .deb needs an administrator password to install, so it no longer does that by itself: it waits for "Restart to update" and says a password is coming. "Start at login" now works on Linux, and "Restart ccdeck" stops a deck that has hung.'},{title:"🕵️ Browser Watch waits before it acts, and quits only its own browser",body:"A program's visit is now logged and reacted to once its quiet window has closed, about 16 minutes after it, and not on the first poll, so a visit that is withdrawn no longer quits the browser. On Linux the quit reaction ends only the browser that holds the watched profile; other Chrome channels and headless browsers keep running. When it cannot tell which process that is, it does nothing and says so, which includes a Flatpak Brave."},{title:"🧮 Figures that were off are right",body:`Spend by labelled and workflow subagents counts toward a session's tokens and cost. The Projects report prices 1-hour cache writes the way ccusage does, so its dollars match the Usage panel. After a restart the deck rebuilds its whole event history, where it used to rebuild about a third. On Linux the process list shows what each process is using now, not its lifetime average. A count near a boundary reads "1.00M", and a full quota window says "used up".`},{title:"🔑 The Usage panel's reads answer the deck's own page only",body:"The routes behind the Usage panel (/api/quota, /api/ccusage, /api/codex-usage, /api/codex-quota and /api/cswap-auto) now answer the deck's own page, or a client that sends the deck's token. A script that read them with a plain request gets 401 from this version on. The hook, the desktop app and the `ccdeck` command are not affected."},{title:"🛠️ Smaller fixes you may notice",body:"With the canvas paused, an update no longer restarts the server while an agent is working: it waits until no turn is open. `ccdeck --stop -p4317` stops that one deck. A deck started at login can update itself on Homebrew and nvm setups. Dialogs keep keyboard focus after a button goes away, screen readers hear pairing requests by deck name and the machine panel's readings, dim text is readable in both themes, Windows High Contrast shows what is selected, and below 640px the detail panel opens over the canvas."}],"3.32.2":[{title:"🔒 Self-updates wait until your screen is unlocked",body:"On Linux with GNOME, the app installs an update by itself when you leave it alone, which is often while your screen is locked. GNOME switches the panel's tray off under the lock screen, and a version that started then never showed its icon. The app now waits until you are back before restarting by itself, so its icon comes back with it."}],"3.32.1":[{title:"🔔 The tray icon comes back on Linux",body:"On Linux the app could lose its icon in the panel, after it updated itself or when the panel restarted, and stay without it until it was quit. It now notices within a minute and restarts by itself the next time you are away from its window, the way it installs an update. It does this at most once every six hours, and not again if a restart did not help."},{title:"🔕 A window you closed stays closed after a self-update",body:"When the app restarted by itself to install an update, it opened its window again even if you had closed it, and while that window was open the deck held back its notifications. A window you closed now stays closed."},{title:"🪟 No empty icon when ccdeck is already open",body:'Opening ccdeck again while it was running flashed an empty "…" icon in the Linux panel before bringing the window forward. It now only brings the window forward.'}],"3.32.0":[{title:"🗺️ A map of your network",body:"A new button on the Local network row, and in its view's header, opens a map of every deck around this one. This deck is at the centre and the paired decks that are on stand around it. Further out are the quiet ones, the machines nearby and any deck asking to pair. Wires are solid on your local network and dashed over Tailscale. Pointing at a deck says how it is reached, what it runs and which logins the two share, and pressing it opens that deck's own dialog."}],"3.31.0":[{title:"📊 Account capacity",body:"A gauge button in the accounts panel's header opens Account capacity: how many of your Claude accounts are ready now, what the 5-hour and 7-day windows have left across all of them, and a row for each account with its use, its state (Ready, Limited, Exhausted or Stale) and when it was last read. Each window also says whose reset comes next."},{title:"🚦 Claude and Codex incidents",body:"When Anthropic's or OpenAI's status page reports an incident on something your sessions use, the deck says so in the topbar, the Usage panel and the tray, and every mark links to the status page. A provider with nothing wrong draws nothing."},{title:"↕️ Order your other accounts",body:"The Other accounts row can sort the list by slot, by how full a window is, or by most room, and open every account at once. Both stay as you left them after a reload."},{title:"🔐 A settings folder left by sudo can be given back",body:'On a Mac, running ccdeck once with sudo left its settings folder owned by another user, and every settings change was refused, sharing an account included. The message now offers "give it back": macOS asks for your password, the folder is yours again, and the deck reads its settings back without a restart.'}],"3.30.0":[{title:"🧮 Token counts and costs are no longer doubled",body:"Claude Code writes a reply that has thinking, text and tool calls as several transcript lines, each carrying the whole request's usage. The deck added up every line, so a session's tokens and cost on its card came out close to twice what it was billed, and the context panel counted each part of a reply as its own message. Each request is now counted once. Expect the totals on your cards to come down."},{title:"⏳ Claude's saved limit resets on the Usage panel",body:`When your Claude account has free limit resets to spend ("Reset for free" in Claude's Settings → Usage), the Claude card now says how many there are and when the first one expires, the way the Codex card already did. The deck only reports them; you spend them in Claude's own settings.`},{title:"🔑 LAN invites need the other deck updated",body:`An invite's code is now a long random secret instead of six digits, so nobody else on the network can work it out and pair in your place, and a wrong code is refused by name. An invite made on this version can only be joined from a deck on this version or later: an older deck answers "That is not an invite". Update that deck, or make the invite on the older one and join it here.`},{title:"🔕 AGENTS_DECK_NO_NOTIFY keeps Browser Watch quiet too",body:"A deck started with AGENTS_DECK_NO_NOTIFY=1 still raised a desktop notification for every new Browser Watch finding. It no longer does. The finding is still in the Browser Watch panel and its log, which says why no notification came."},{title:"🛠️ Smaller fixes",body:'Delete removes the card you just clicked. A LAN address you typed stays in the list when a round cannot reach it, and the status line under the LAN switch now agrees with the rows below it. In the desktop app, a dismissed "update is ready" notice stays dismissed after you answer the first-launch question. Sizes read the same in every panel ("1.1 KB"). Faded text stays readable, a keyboard can see the scrollbar, and numbers use a monospaced font on Windows and Linux as well.'}],"3.29.11":[{title:"💲 Claude Sonnet 5.5 has a price",body:`Sessions on Claude Sonnet 5.5 showed "not priced" on the board, and the Projects report could only show a minimum for them. They are now priced at Anthropic's published rate, the same as Sonnet 5: $2 per million input tokens and $10 per million output tokens.`}],"3.29.10":[{title:"💲 Claude Opus 5.5 has a price",body:`Sessions on Claude Opus 5.5 showed "not priced" on the board, and the Projects report counted them as costing nothing, so its totals read far too low. They are now priced at Anthropic's published rate. If a model still has no price, Projects shows its total as a minimum, like $11.19+, and names the model, instead of a total that looks complete.`}],"3.29.8":[{title:"🔁 Removed cards come back when their agent works again",body:"Remove from board is for finished work. If the agent behind a card you removed starts a tool call, gets a new prompt or starts a subagent, the card returns on its own, together with the card it hangs from, and it stays back after a reload. Cards whose agents stay idle stay removed."}],"3.29.1":[{title:"🗂️ One row per project in Projects",body:"The Projects report now counts a session's work under the folder you started it in, the same name its card has on the canvas, instead of adding a row for every folder the agent moved into. The first start after updating re-reads your transcripts once to regroup the report."},{title:"🔔 Tidier custom sounds",body:"Importing a sound, recording one and choosing a spoken voice now sit in compact cards that respond to clicks and focus like the rest of the deck."}],"3.29.0":[{title:"🎵 Your own stations in Claude FM",body:"Add any YouTube live link or radio stream as a station in Appearance, next to the built-in ones, and mute the music without losing your volume. When a station is not live, the picker now says so instead of staying silent."},{title:"🔔 Notification sounds and voices of your own",body:"Pick a local audio file or a spoken voice for each alert, so the sound that means an agent is waiting is one you will recognise."},{title:"🗑️ Drag a card off the board to remove it",body:"Drag a card to the target at the bottom of the canvas to take it off the board, or use Remove from board in the detail panel (Delete). The session keeps running, and the session list (L) brings it back."},{title:"🔐 Optional invite-only pairing",body:"Pairing works as before, with or without an invite. If you want, Local network can now be set to accept only decks that join with an invite you created, so a nearby machine cannot ask to pair on its own."},{title:"🌐 Account sharing between your machines is more reliable",body:"A locked macOS Keychain is explained instead of failing silently, a login that is broken or belongs to another account is never shared, and a sync that stops partway keeps what already arrived."},{title:"📅 Projects opens on Today",body:"The Projects report per account starts with today's work, and an empty window offers the next wider one. The topbar also shows this month's usage, and the desktop app can restart into an update from its own window."}],"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.
|
|
108
|
+
What did you expect to happen?`},{value:"idea",label:"Idea",question:"What would make ccdeck better?",placeholder:"It would be useful if…"},{value:"other",label:"Other",question:"What would you like to tell us?",placeholder:"Write anything…"}];function HL(e){return kb.find(t=>t.value===e)??kb[0]}const Nb=3,lx=120,Mse=1e4,$se=200,Ise="Write something first.";function GR(e){return e.trim()!==""}function Ose(e){var o;const t=e.trim();if(t==="")return"";const n=KR(t.split(/\r?\n/,1)[0]),r=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,s=cx(r).length>=Nb?cx(r):cx(n);return Pse(s.length>=Nb?s:KR(t))}function Lse(e,t){const n=Ose(t);return n.length>=Nb?n:`${HL(e).label}: ${n}`}function KR(e){return e.replace(/\s+/g," ").trim()}function cx(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function Pse(e){if(e.length<=lx)return e;const t=e.slice(0,lx-1),n=t.lastIndexOf(" ");return`${(n>=lx/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function Dse({kind:e,body:t,contact:n}){const r={kind:e,title:Lse(e,t),body:t.trim()};return n.trim()!==""&&(r.contact=n.trim()),r}function Fse(e){const t=e;return(t==null?void 0:t.ok)!==!0||typeof t.appVersion!="string"||typeof t.platform!="string"||t.appVersion===""||t.platform===""?null:{appVersion:t.appVersion,platform:t.platform}}const Bse={darwin:"macOS",win32:"Windows",linux:"Linux"};function qse(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),r=t===-1?"":e.slice(t+1),s=Bse[n]??n;return r?`${s} · ${r}`:s}function Use(e){return e?`ccdeck ${e.appVersion} · ${qse(e.platform)}`:null}const zse="sent with it",Wse="Your ccdeck version and system are sent with it.",Hse="Add details",Vse="How to reach you",Gse="Email or GitHub @name",Kse="Only if you would like an answer.",Yse=["It all goes to the people who make ccdeck, with the version and system below.","Nothing becomes public by being sent. They may open a public GitHub issue from it, choosing its title and text; your contact and screenshots are never put on one."];function Xse(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function VL(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function Zse(e){return/mac|iphone|ipad/i.test(e)?["⌘","Enter"]:["Ctrl","Enter"]}function Jse(e){return[...e].length===1}const GL="Thanks — feedback sent.";function YR(e,t,n){if(t==="vetoed")return"This deck was started with AGENTS_DECK_NO_INSTALL=1, which keeps it off the network, so nothing was sent.";if(e===429||t==="too_many")return"Too much feedback from this network in the last hour. Try again later; your text is still here.";if(e===413||t==="too_large")return"The images are too large to send together. Remove one and send again; your text is still here.";const r=n==null?void 0:n.images;return e===400&&Array.isArray(r)&&typeof r[0]=="string"?`The server did not accept an image. ${r[0]} Remove it and send again; your text is still here.`:e===400?"The server did not accept the message. It is still here; check it and send again.":"ccdeck's server could not be reached. Nothing was sent; your text is still here, so try again in a moment."}function Qse(e){return e==="sending"?"Sending…":e==="sent"?GL:""}const XR=1400,eae=160;function tae({kind:e,onChange:t}){return a.jsxs("fieldset",{className:"fb-kinds",children:[a.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),kb.map(n=>a.jsxs("label",{className:"fb-kind",children:[a.jsx("input",{type:"radio",name:"feedback-kind",value:n.value,checked:e===n.value,onChange:()=>t(n.value),onKeyDown:r=>{VL(r.nativeEvent)&&r.preventDefault()}}),n.label]},n.value))]})}const KL="fb-details";function nae({open:e,onToggle:t}){return a.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":KL,onClick:t,children:[Hse,a.jsx("svg",{className:"fb-chev",width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 3.75 5 6.25l2.5-2.5"})})]})}function rae({open:e,contact:t,onContact:n}){const r=y.useId();return a.jsx("div",{id:KL,className:"fb-details","data-open":e||void 0,children:a.jsx("div",{className:"fb-details-clip",children:a.jsxs("div",{className:"fb-details-body",children:[a.jsxs("div",{className:"fb-field",children:[a.jsxs("label",{className:"fb-field-label",htmlFor:"fb-contact",children:[Vse,a.jsx("span",{className:"fb-optional",children:"optional"})]}),a.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:$se,autoComplete:"email",placeholder:Gse,"aria-describedby":r,onChange:s=>n(s.target.value),onKeyDown:s=>{VL(s.nativeEvent)&&s.preventDefault()}}),a.jsx("p",{id:r,className:"fb-hint",children:Kse})]}),a.jsx("div",{className:"fb-where",children:Yse.map(s=>a.jsx("p",{children:s},s))})]})})})}const ti=3,sae=5*1024*1024,aae=12*1024*1024,jb=8192,oae=64*1024,iae=256*1024,lae=.92,cae=640,YL=.9,uae=.85,dae=6,hae=512*1024,Fd={png:"image/png",jpeg:"image/jpeg"},fae={png:"png",jpeg:"jpg"},pae=[137,80,78,71,13,10,26,10],mae=[255,216,255];function XL(e){const t=n=>e.length>=n.length&&n.every((r,s)=>e[s]===r);return t(pae)?"png":t(mae)?"jpeg":null}function gae(e){const t=XL(e);return t==="png"?yae(e):t==="jpeg"?vae(e):null}function yae(e){const t=[73,72,68,82];if(e.length<24||!t.every((r,s)=>e[12+s]===r))return null;const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:n.getUint32(16),height:n.getUint32(20)}}function wae(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function vae(e){let t=2;for(;t<e.length;){if(e[t]!==255)return null;for(;t<e.length&&e[t]===255;)t++;const n=e[t++];if(n===void 0||n===217||n===218)return null;if(n===1||n>=208&&n<=215)continue;if(t+2>e.length)return null;const r=e[t]<<8|e[t+1];if(r<2)return null;if(wae(n))return t+7>e.length?null:{height:e[t+3]<<8|e[t+4],width:e[t+5]<<8|e[t+6]};t+=r}return null}function ZR(e,t){return e.bytes>t||e.width>jb||e.height>jb}function xae(e){return Math.min(sae,aae-oae-e)}function ZL(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function bae(e,t){const n=jb/Math.max(e.width,e.height),r=e.bytes>t?Math.sqrt(t/e.bytes)*YL:1;return ZL(e,Math.min(1,n,r))}async function kae(e,t,n){let r=bae(e,t),s=e.format;for(let o=0;o<dae;o++){const l=await n(r,s,s==="jpeg"?lae:void 0);if(!l)return null;if(l.size<=t)return{...r,blob:l,format:s};if(s==="png"){s="jpeg";continue}if(r=ZL(r,Math.min(uae,Math.sqrt(t/l.size)*YL)),Math.max(r.width,r.height)<cae)return null}return null}async function Nae(e,t,n){const r=new Uint8Array(await e.slice(0,hae).arrayBuffer()),s=XL(r);if(!s)return{ok:!1,problem:"type"};if(t<iae)return{ok:!1,problem:"no_room"};const o=e.type===Fd[s]?e:new Blob([e],{type:Fd[s]}),l=gae(r);if(l&&!ZR({...l,bytes:e.size},t))return{ok:!0,blob:o,resized:null};const c=await n(e).catch(()=>null);if(!c)return{ok:!1,problem:"unreadable"};try{const d={width:c.width,height:c.height,bytes:e.size,format:s};if(!ZR(d,t))return{ok:!0,blob:o,resized:null};const h=await kae(d,t,c.encoder);return h?{ok:!0,blob:h.blob,resized:{width:h.width,height:h.height}}:{ok:!1,problem:"too_large"}}finally{c.release()}}function jae(e){return({width:t,height:n},r,s)=>new Promise(o=>{const l=document.createElement("canvas");l.width=t,l.height=n;const c=l.getContext("2d");if(!c)return o(null);r==="jpeg"&&(c.fillStyle="white",c.fillRect(0,0,t,n)),c.imageSmoothingQuality="high",c.drawImage(e,0,0,t,n),l.toBlob(d=>{l.width=0,l.height=0,o(d)},Fd[r],s)})}const Sae=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:jae(t),release:()=>t.close()}};function _ae(e){return e.includes("Files")}function Eae({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function Cae(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function Tae(e,t){if(t.length===0)return{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)};const n=new FormData;return n.append("kind",e.kind),n.append("title",e.title),n.append("body",e.body),e.contact!==void 0&&n.append("contact",e.contact),t.forEach((r,s)=>{const o=r.type===Fd.jpeg?"jpeg":"png";n.append("images",r,`image-${s+1}.${fae[o]}`)}),{method:"POST",body:n}}const Aae="Add screenshot",JR="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",Rae="A screenshot can show emails, costs and paths. Crop out what should not be seen.",QR="Three images at most. Remove one to add another.",Mae="An image could not be attached, so nothing was sent. Check the images and send again; your text is still here.";function $ae(e,t,n){const r=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${r}`}function Iae(e,t){const n=`${e} of ${ti}`;return t>0?`${n} · ${t} resized to fit`:n}function Oae(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function Lae(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function Pae(e,t){const n=Lae(t);return e==="type"?`${n} is not a PNG or a JPEG, so it was not added. GIF, WebP and HEIC are not converted; save it as a PNG or a JPEG first.`:e==="no_room"?`There is no room left for ${n}: images go at up to 12 MB in all. Remove one to add it.`:e==="unreadable"?`${n} could not be read as an image.`:`${n} could not be made small enough to send: images go at up to 5 MB each.`}const JL="image/png,image/jpeg";function QL({className:e="fb-glyph"}){return a.jsxs("svg",{className:e,width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{x:"1.8",y:"2.4",width:"10.4",height:"9.2",rx:"1.6"}),a.jsx("circle",{cx:"5",cy:"5.6",r:"1"}),a.jsx("path",{d:"M2.4 10.4 5.5 7.6l2.1 1.8 1.5-1.3 2.5 2.2"})]})}function Dae({images:e,buttonRef:t}){const n=y.useRef(null),r=e.shots.length>=ti;return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:JR,"aria-describedby":"fb-attach-hint",onClick:()=>{var s;return r?e.sayFull():(s=n.current)==null?void 0:s.click()},children:[a.jsx(QL,{}),Aae]}),a.jsx("span",{id:"fb-attach-hint",hidden:!0,children:JR}),a.jsx("input",{ref:n,type:"file",accept:JL,multiple:!0,hidden:!0,onChange:s=>{e.add(Array.from(s.target.files??[])),s.target.value=""}})]})}function Fae({images:e,addRef:t}){const n=y.useRef(new Map),r=y.useRef(null),s=y.useRef(null),o=y.useRef(null),[l,c]=y.useState(null),{shots:d}=e,h=Iae(d.length,d.filter(g=>g.resized).length);y.useLayoutEffect(()=>{var g;l!==null&&((g=l==="add"?t.current:n.current.get(l))==null||g.focus(),c(null))},[l,t]),y.useEffect(()=>{var g;e.problem&&((g=r.current)==null||g.scrollIntoView({block:"nearest"}))},[e.problem,e.problemId]);function f(g){c(Cae(d.map(v=>v.id),g)??"add"),e.remove(g)}function p(g){var v;o.current=g,(v=s.current)==null||v.click()}return a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"vis-hidden",role:"status",children:e.announcement}),a.jsx("input",{ref:s,type:"file",accept:JL,hidden:!0,onChange:g=>{const v=o.current;v!==null&&e.replace(v,Array.from(g.target.files??[])),o.current=null,g.target.value=""}}),d.length>0&&a.jsxs("div",{className:"fb-shots",children:[a.jsxs("div",{className:"fb-shots-row",children:[a.jsx("ul",{className:"fb-shots-list",children:d.map((g,v)=>a.jsxs("li",{className:"fb-shot","data-fitting":g.blob?void 0:!0,children:[a.jsxs("button",{type:"button",className:"fb-shot-pick","aria-label":$ae(v,g.name,g.resized),onClick:()=>p(g.id),children:[a.jsx("img",{className:"fb-shot-img",src:g.url,alt:""}),g.blob?a.jsx("span",{className:"fb-shot-cue","aria-hidden":"true",children:"Replace"}):a.jsx("span",{className:"fb-shot-busy","aria-hidden":"true",children:"Resizing…"})]}),a.jsx("button",{ref:N=>{N?n.current.set(g.id,N):n.current.delete(g.id)},type:"button",className:"glyph-btn fb-shot-remove","aria-label":`Remove image ${v+1}`,title:`Remove image ${v+1}`,onClick:()=>f(g.id),children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 2.5 7.5 7.5M7.5 2.5 2.5 7.5"})})})]},g.id))}),a.jsx("span",{className:"fb-shots-count",children:h})]}),a.jsx("p",{className:"fb-hint",children:Rae})]}),e.problem&&a.jsx("p",{ref:r,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function Bae(e,t,n){return n?e.map(r=>r.id===t.id?t:r):[...e,t]}function qae(e,t,n){return n?e.map(r=>r.id===t?n:r):e.filter(r=>r.id!==t)}function Uae(){const[e,t]=y.useState([]),[n,r]=y.useState({problem:"",id:0}),s=y.useRef(0),o=y.useCallback(T=>{T&&s.current++,r(A=>T?{problem:T,id:A.id+1}:A.problem?{problem:"",id:A.id}:A)},[]),[l,c]=y.useState(""),d=y.useRef([]),h=y.useRef(null),f=y.useRef(1),p=y.useRef(!0),g=y.useCallback(T=>{d.current=T(d.current),t(d.current)},[]);y.useEffect(()=>(p.current=!0,()=>{p.current=!1;for(const T of d.current)URL.revokeObjectURL(T.url)}),[]);const v=y.useCallback(async(T,A)=>{const U=d.current.reduce((P,G)=>{var K;return P+(G.id===(A==null?void 0:A.id)?0:((K=G.blob)==null?void 0:K.size)??0)},0),L=(A==null?void 0:A.id)??f.current++,F=URL.createObjectURL(T),O={id:L,name:T.name||"image",url:F,blob:null,resized:null};let I=!1;const B=()=>{I||(I=!0,g(P=>Bae(P,O,A!==void 0)))},M=await Nae(T,xae(U),async P=>(B(),Sae(P))).catch(()=>({ok:!1,problem:"unreadable"})),$=d.current.some(P=>P.id===L);return!p.current||!$&&(I||A)?(URL.revokeObjectURL(F),A&&URL.revokeObjectURL(A.url),""):M.ok?(B(),A&&URL.revokeObjectURL(A.url),g(P=>P.map(G=>G.id===L?{...G,blob:M.blob,resized:M.resized}:G)),""):(URL.revokeObjectURL(F),I&&g(P=>qae(P,L,A)),Pae(M.problem,T.name||"image"))},[g]),N=y.useCallback(async T=>{o("");const A=[];let U=0,L=0;for(const O of T){if(!p.current)return;if(d.current.length>=ti){U++;continue}const I=d.current.length,B=await v(O);B&&A.push(B),d.current.length>I&&L++}if(!p.current)return;U>0&&A.push(L===0&&A.length===0?QR:Oae(U)),o(A.join(" "));const F=d.current.length;L>0&&c(`${L===1?"Image":`${L} images`} added, ${F} of ${ti}.`)},[v,o]),k=y.useCallback(async(T,A)=>{o("");const U=d.current.find(O=>O.id===T);if(!U)return N([A]);const L=await v(A,U);if(!p.current)return;o(L);const F=d.current.findIndex(O=>O.id===T);!L&&F!==-1&&c(`Image ${F+1} replaced, ${d.current.length} of ${ti}.`)},[N,v,o]),x=y.useCallback(T=>{h.current=(h.current??Promise.resolve()).then(T).catch(()=>{})},[]),j=y.useCallback(T=>{T.length>0&&x(()=>N(T))},[N,x]),b=y.useCallback((T,A)=>{const U=A[0];U&&x(()=>k(T,U))},[x,k]),_=y.useCallback(T=>{const A=d.current.find(U=>U.id===T);A&&(URL.revokeObjectURL(A.url),g(U=>U.filter(L=>L.id!==T)),o(""),c(`Image removed, ${d.current.length} of ${ti}.`))},[g,o]),E=y.useCallback(()=>o(QR),[o]),R=y.useCallback(async()=>{const T=s.current;return await h.current,s.current!==T?null:d.current.flatMap(A=>A.blob?[A.blob]:[])},[]);return{shots:e,problem:n.problem,problemId:n.id,announcement:l,add:j,replace:b,remove:_,sayFull:E,ready:R}}function zae(){const[e,t]=y.useState(null);return y.useEffect(()=>{let n=!0;return fetch("/api/feedback").then(r=>r.ok?r.json():null).then(r=>{n&&t(Fse(r))}).catch(()=>{}),()=>{n=!1}},[]),e}function Wae(e){const[t,n]=y.useState({state:"idle"}),r=y.useRef(!1),s=y.useRef(null);y.useEffect(()=>()=>{var l;return(l=s.current)==null?void 0:l.abort()},[]);async function o(l){if(!lr(r.current))return;r.current=!0;const{signal:c}=s.current=new AbortController;n({state:"sending"});try{const d=await e.ready();if(c.aborted)return;if(!d){n({state:"failed",message:Mae});return}const h=await fetch("/api/feedback",{...Tae(Dse(l),d),signal:c}),f=await h.json().catch(()=>null);n(h.ok&&(f!=null&&f.ok)?{state:"sent"}:{state:"failed",message:YR(h.status,f==null?void 0:f.reason,f==null?void 0:f.errors)})}catch{c.aborted||n({state:"failed",message:YR(0,null)})}finally{r.current=!1}}return{outcome:t,sending:t.state==="sending",send:o}}function Hae(e,t){const[n,r]=y.useState(!1),s=y.useRef(t);return s.current=t,y.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>r(!0),XR),l=window.setTimeout(()=>s.current(),XR+eae);return()=>{window.clearTimeout(o),window.clearTimeout(l)}},[e]),n}function Vae(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function eP({onClose:e,initialKind:t,initialBody:n}){const r=y.useRef(null),s=y.useRef(null),o=y.useRef(null),l=y.useRef(null),c=y.useRef(null),d=y.useRef(null),h=y.useRef(null),f=y.useRef(0),p=ut(e,{focusRef:r}),g=gt(e),[v,N]=y.useState(t??"bug"),[k,x]=y.useState(n??""),[j,b]=y.useState(""),[_,E]=y.useState(!1),[R,T]=y.useState(!1),[A,U]=y.useState(!1),L=Uae(),F=Use(zae()),{outcome:O,sending:I,send:B}=Wae(L),M=O.state==="sent",$=Hae(M,e),P=HL(v),G=R&&!GR(k),[K,q]=Zse(Vae());y.useEffect(()=>{var ke,ae;const se=l.current;if(!se)return;const pe=se.contains(document.activeElement)||Cn(((ke=document.activeElement)==null?void 0:ke.tagName)??null);se.inert=M,M&&pe&&((ae=s.current)==null||ae.focus())},[M]),y.useEffect(()=>{var ae,fe;const se=c.current;if(!se)return;if(I){const me=document.activeElement;h.current=me&&se.contains(me)?me:null,se.inert=!0,h.current&&((ae=d.current)==null||ae.focus());return}se.inert=!1;const pe=h.current;h.current=null;const ke=document.activeElement===d.current||Cn(((fe=document.activeElement)==null?void 0:fe.tagName)??null);!M&&pe&&ke&&pe.focus()},[I,M]);function H(se){var pe;if(se.preventDefault(),!GR(k)){T(!0),(pe=r.current)==null||pe.focus();return}B({kind:v,body:k,contact:j})}const D=!M&&!I,W=se=>_ae(Array.from(se.dataTransfer.types));function J(se){!W(se)||!D||(se.preventDefault(),f.current++,U(!0))}function V(se){W(se)&&(se.preventDefault(),se.dataTransfer.dropEffect=D?"copy":"none")}function X(se){W(se)&&(f.current=Math.max(0,f.current-1),f.current===0&&U(!1))}function Y(se){W(se)&&(se.preventDefault(),f.current=0,U(!1),D&&L.add(Array.from(se.dataTransfer.files)))}function Z(se){se.target!==se.currentTarget||!W(se)||(se.preventDefault(),se.dataTransfer.dropEffect="none")}function ee(se){W(se)&&se.preventDefault()}function ne(se){if(!D)return;const pe=Array.from(se.clipboardData.files),ke=se.target,ae=ke instanceof HTMLTextAreaElement||ke instanceof HTMLInputElement,fe=Array.from(se.clipboardData.types).includes("text/plain");Eae({files:pe.length,hasText:fe,intoTextField:ae})&&(se.preventDefault(),L.add(pe))}return a.jsx("div",{className:"modal-backdrop",...g,role:"presentation",onDragOver:Z,onDrop:ee,"data-leaving":$||void 0,children:a.jsxs("div",{ref:p,className:"modal feedback-dialog",onClick:se=>se.stopPropagation(),onDragEnter:J,onDragOver:V,onDragLeave:X,onDrop:Y,onPaste:ne,role:"dialog","aria-modal":"true","aria-labelledby":"feedback-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"feedback-title",className:"modal-tool-name",children:"Send feedback"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:s,type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsx("p",{className:"vis-hidden",role:"status",children:Qse(O.state)}),a.jsxs("div",{className:"fb-stage",children:[a.jsxs("form",{ref:l,className:"fb-form",onSubmit:H,onKeyDown:se=>{Xse(se.nativeEvent)&&(se.preventDefault(),se.currentTarget.requestSubmit())},noValidate:!0,children:[a.jsxs("section",{ref:c,className:"modal-body fb-body",children:[a.jsx(tae,{kind:v,onChange:N}),a.jsxs("div",{className:"fb-compose",children:[a.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:P.question}),a.jsx("textarea",{ref:r,id:"fb-body",className:"ap-manage-input fb-message",value:k,maxLength:Mse,rows:5,placeholder:P.placeholder,onChange:se=>x(se.target.value),"aria-invalid":G||void 0,"aria-describedby":G?"fb-body-error":void 0,required:!0}),G&&a.jsx("p",{id:"fb-body-error",className:"fb-error",children:Ise}),a.jsx(Fae,{images:L,addRef:o}),a.jsxs("div",{className:"fb-tools",children:[a.jsx(Dae,{images:L,buttonRef:o}),a.jsx(nae,{open:_,onToggle:()=>E(se=>!se)})]}),a.jsx(rae,{open:_,contact:j,onContact:b})]}),a.jsx("p",{className:"fb-facts",children:F?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"fb-facts-value",children:F})," — ",zse]}):Wse}),O.state==="failed"&&a.jsx("p",{className:"fb-error",role:"alert",children:O.message})]}),a.jsxs("div",{className:"fb-foot",children:[a.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[a.jsx("kbd",{"data-symbol":Jse(K)||void 0,children:K}),a.jsx("kbd",{children:q})," to send"]}),a.jsx("button",{type:"button",className:"btn",onClick:e,children:"Cancel"}),a.jsx("button",{ref:d,type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...Dr(I),children:a.jsxs("span",{className:"fb-send-label",children:[a.jsx("span",{className:"fb-send-idle",children:"Send feedback"}),a.jsx("span",{className:"fb-send-busy",children:"Sending…"})]})})]})]}),M&&a.jsxs("div",{className:"fb-done",children:[a.jsx(_d,{}),a.jsx("p",{className:"fb-done-line",children:GL})]})]}),a.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":A||void 0,children:a.jsxs("div",{className:"fb-drop-frame",children:[a.jsx(QL,{className:"fb-drop-glyph"}),a.jsx("p",{className:"fb-drop-title",children:"Drop to attach"}),a.jsx("p",{className:"fb-drop-note",children:"PNG or JPEG, up to three"})]})})]})})}const Gae="Press Esc first if a key does nothing.",Kae=[{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:"Delete",action:"take the selected card off the board — the session list (L) brings it back",binds:["Delete"]},{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 Yae({onClose:e,onTour:t}){const n=ut(e),r=gt(e);return a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal key-help",onClick:s=>s.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[t&&a.jsxs("div",{className:"guide-door",children:[a.jsx("span",{children:"Eight pictures of what the deck shows."}),a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Take the tour"})]}),a.jsx("div",{className:"shortcuts",children:Kae.map(s=>a.jsxs(y.Fragment,{children:[a.jsx("h3",{className:"kh-group",children:s.title}),s.rows.map(o=>a.jsxs("div",{className:"sc",children:[a.jsx("kbd",{children:o.cap}),a.jsx("span",{children:o.action})]},`${s.title}:${o.cap}:${o.action}`))]},s.title))}),a.jsx("p",{className:"kh-foot",children:Gae})]})]})})}function tP(e,t){return y.lazy(()=>e().catch(n=>(console.warn(`ccdeck could not load ${t}`,n),{default:({onClose:r})=>a.jsx(Xae,{name:t,onClose:r})})))}function Xae({name:e,onClose:t}){const n=y.useRef(null),r=ut(t,{focusRef:n}),s=gt(t);return a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal dialog-missing",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"dialog-missing-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"dialog-missing-title",className:"modal-tool-name",children:e})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{className:"dm-note",children:[e," did not load. The deck has most likely been updated since this tab opened, and a reload picks up the new version."]}),a.jsxs("div",{className:"dm-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"}),a.jsx("button",{type:"button",ref:n,className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"})]})]})]})})}function Zae(e,t){return`${e}#${t}`}function Jae(e,{lan:t,now:n,closed:r}){if(t===void 0)return[];const s=[];for(const o of e??[]){const l=o.reauth;if(!l||l.dismissed||o.origin!=="ccdeck_signin")continue;const c=Zae(l.key,l.since);if(r.has(c)||DG(l.key,o.email,t,n))continue;const d=o.email??"";s.push({id:c,key:l.key,since:l.since,num:o.num,email:d,name:d||o.alias||`Account ${o.num}`,alias:d&&o.alias?o.alias:null})}return s}function Qae(e,t){const n=String((t==null?void 0:t.email)??"").trim().toLowerCase();return n?e.filter(r=>r.email.toLowerCase()===n&&((t==null?void 0:t.num)==null||String(r.num)===String(t.num))).map(r=>r.id):[]}function nP({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function eoe(e){return e===1?"Account needs your attention":"Accounts need your attention"}function toe(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const noe="Login expired",roe="Until then the deck cannot read its usage or switch to it. Signing in again brings it back — it keeps its slot, its alias and its history.",soe="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function aoe(e,t){const n=(e??[]).filter(s=>s&&typeof s.fp=="string"&&!t.has(s.fp));if(!n.length)return{request:null,waiting:0};const r=[...n].sort((s,o)=>(s.at??0)-(o.at??0));return{request:r[0],waiting:r.length-1}}function ooe({request:e,waiting:t,busy:n,now:r,onAccept:s,onDecline:o,onLater:l}){const c=y.useRef(null),d=ut(l,{focusRef:c}),h=gt(l),f=ia(n,"accept"),p=ia(n,"dismiss");return a.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal lan-ask",onClick:g=>g.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title","aria-describedby":"lan-ask-who",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("i",{className:"ap-pulse","aria-hidden":!0}),a.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:"A deck wants to pair"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:l,"aria-label":"Answer later (Esc)",title:"Answer later (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{id:"lan-ask-who",className:"lan-ask-who",children:[a.jsx("strong",{className:"lan-ask-name",children:e.name})," at ",a.jsx("code",{className:"ap-lan-code",children:e.addr})," · asked ",b0(e.at,r)]}),a.jsx("p",{className:"modal-note",children:"Paired decks repair each other's expired logins. Accept only if you know this machine — what it shares is an account, not a screen."}),a.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",a.jsx("code",{className:"ap-lan-code",children:e.fp})," — that machine shows its own under This deck on the network; the two should match."]}),t>0&&a.jsx("p",{className:"lan-ask-more",children:t===1?"One more deck is waiting behind this one.":`${t} more decks are waiting behind this one.`}),a.jsxs("div",{className:"lan-ask-acts",children:[a.jsx("button",{type:"button",ref:c,className:"btn",disabled:p.disabled,"aria-busy":p.busy,onClick:o,title:"Nothing is shared. If that deck asks again, this comes back.",children:n==="dismiss"?"declining…":"Decline"}),a.jsx("button",{type:"button",className:"btn primary",disabled:f.disabled,"aria-busy":f.busy,onClick:s,title:"Talk to this deck from now on, and repair its expired logins with this deck's own.",children:n==="accept"?"accepting…":"Accept"})]})]})]})})}function ioe(e){const t=y.useRef(!1),n=loe(e),r=nP({rows:n?1:0,ours:t.current,dialogs:ds.dialogDepth()});return t.current=r,r?n:null}function loe({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:r,deferLanPair:s}){const{request:o,waiting:l}=aoe(e,t.current);return o?a.jsx(ooe,{request:o,waiting:l,busy:n,now:Date.now(),onAccept:()=>void r("accept",o.fp),onDecline:()=>void r("dismiss",o.fp),onLater:()=>s(o.fp)},o.fp):null}function coe({rows:e,onSignIn:t,onLater:n,firstRef:r}){const s=e.length===1?e[0]:null;return a.jsxs("section",{className:"modal-body",children:[s?a.jsxs(a.Fragment,{children:[a.jsxs("p",{id:"reauth-lead",className:"reauth-lead",children:["The Claude login for ",a.jsx("strong",{className:"reauth-name",children:s.name}),s.alias?a.jsxs("span",{className:"reauth-alias",children:[" (",s.alias,")"]}):null," ","has expired and needs a new sign","‑","in."]}),a.jsx("p",{className:"reauth-note",children:roe})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:toe(e.length)}),a.jsx("ul",{className:"reauth-list",children:e.map((o,l)=>a.jsxs("li",{className:"reauth-row",children:[a.jsxs("span",{className:"reauth-who",title:o.alias?`${o.alias} — ${o.name}`:o.name,children:[o.name,o.alias?a.jsxs("span",{className:"reauth-alias",children:[" ",o.alias]}):null]}),a.jsx("span",{className:"reauth-what",children:noe}),a.jsx("button",{type:"button",className:"btn",ref:l===0?r:void 0,"aria-label":`Sign in again as ${o.name}`,onClick:()=>t(o),children:"Sign in again"})]},o.id))}),a.jsx("p",{className:"reauth-note",children:"Each keeps its slot, its alias and its history."})]}),a.jsxs("div",{className:"reauth-acts",children:[a.jsx("button",{type:"button",className:"btn",title:soe,onClick:n,children:"Not now"}),s&&a.jsx("button",{type:"button",className:"btn primary",ref:r,onClick:()=>t(s),children:"Sign in again"})]})]})}function uoe({rows:e,onSignIn:t,onLater:n}){const r=y.useRef(null),s=ut(n,{focusRef:r}),o=gt(n);return a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal reauth-ask",onClick:l=>l.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"reauth-title","aria-describedby":"reauth-lead",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"reauth-title",className:"modal-tool-name",children:eoe(e.length)})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Not now (Esc)",title:"Not now (Esc)",children:"×"})})]}),a.jsx(coe,{rows:e,onSignIn:t,onLater:n,firstRef:r})]})})}function doe({rows:e,signingIn:t,signIn:n,signedIn:r,refresh:s,closeSignIn:o,later:l,pairing:c=!1}){const d=y.useRef(!1),h=ds.dialogDepth()+(c?1:0),f=t!=null||nP({rows:e.length,ours:d.current,dialogs:h});return d.current=f,t?a.jsx(RI,{email:t.email||null,onClose:o,onChanged:s,onSignedIn:r}):f?a.jsx(uoe,{rows:e,onSignIn:n,onLater:l},e.length===1?"one":"many"):null}const hoe={"//":["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.28.0","3.28.1","3.29.3","3.29.4","3.29.6","3.29.7","3.29.9","3.33.1","3.35.0","3.35.1","3.36.0","3.36.1","3.36.4","3.36.5","3.36.6","3.36.7","3.36.8","3.36.9","3.37.0"],"3.37.1":[{title:"🔁 Expired logins repair from your other machines",body:"When a login stops working on this machine and a machine you paired with still has it working and ticked, Local network now copies it back on the next round, whether or not the account is ticked here. Before, it stayed marked expired until the account was ticked here as well, or deleted so that it arrived again. A machine that paired on its own, through Say yes to every deck that asks, still repairs only the accounts ticked here."}],"3.36.3":[{title:"🔑 An expired login asks to be signed in again",body:"When an account you added with + → Sign in stops working, the deck now tells you in one dialog, with every affected account together and Sign in again beside each. That opens the usual sign-in with the address already filled in, and the account keeps its slot, its alias and its history. Not now leaves it marked in the Accounts panel and does not ask again until it has worked and stopped again. A paired deck holding a working copy gets to repair it first, and accounts that came from a share or Local network are never asked about."}],"3.34.1":[{title:"🗂️ The tray menu stays open while you read it",body:"On Linux the menu behind the tray icon could close by itself while agents were working, often before the row you pressed took the click, so it had to be opened and pressed again. It now changes only when something it says has changed, and stays open while you choose."}],"3.34.0":[{title:"🗺️ The network map shows who you are connected to",body:"Paired decks that are on stand closest to this one, and a light runs along their wires. Paired decks that are away come next, in a colour of their own, with how long they have been gone, and machines that are not paired stand outside in grey. Decks reached over Tailscale sit together in their own shaded slice instead of on dashed wires. Pointing at a deck opens its details beside the map: whether it is there, what to do next if anything, its address and what it runs, and every login the two share, the ones that need a look first."},{title:"🔑 A login that expired everywhere says so",body:`When a shared login expired on this deck and every paired deck that is on held an expired copy too, the row said "Login expired" and waited for a repair that could never come. It now says "Login expired on all online decks". Claude retires a login's other copies each time one machine refreshes it, so shared copies expire together: sign in again on any one machine and the others repair from it on their next round.`},{title:"💬 Send feedback from inside the deck",body:'Appearance settings has a "Send feedback…" button: pick what kind it is, write a title and a few lines, and add a way to reach you if you want an answer. It goes to the people who make ccdeck, who may open a public issue from it, never with your contact in it. If it cannot be sent, the form stays filled in and says why.'}],"3.33.0":[{title:"🪝 Hooks you add in Claude Code are no longer removed",body:"Claude Code's hook editor often files a new hook into the same group as the deck's own. Starting the deck, or uninstalling it, then removed the whole group, and your hook went with it without a word. The deck now takes out only its own command and leaves yours where it was, and the same goes for the old finish-sound hook. `ccdeck --uninstall` also stops the decks that are running, so an update in the background cannot put the hooks back."},{title:"🧵 Resumed Codex sessions show up again",body:"A Codex session picked up with `codex resume`, or one that ran for days, could go dark on the canvas and drop out of the 5-hour and 7-day usage, because the deck only looked in the two newest day folders. It now follows those sessions and counts their tokens. Two Codex sessions in the same folder get different id suffixes, and a `bash -lc` call shows the command it runs."},{title:"🤝 A deck paired by the accept switch brings in less",body:'A deck that paired through the automatic accept switch, and not through an invite, now brings in only the logins you have ticked on this deck, and nothing from it is ticked for sharing onward. Its dialog says "paired automatically — pair by invite to take it". Pairing by invite works as before. A typed address is no longer dropped after one failed round, and the sync port stays the same after a rename.'},{title:"⬆️ Desktop updates install when you expect them",body:'On Windows and Linux a downloaded update now installs when you quit. On a Mac, Quit installs it and the app stays closed. The Linux .deb needs an administrator password to install, so it no longer does that by itself: it waits for "Restart to update" and says a password is coming. "Start at login" now works on Linux, and "Restart ccdeck" stops a deck that has hung.'},{title:"🕵️ Browser Watch waits before it acts, and quits only its own browser",body:"A program's visit is now logged and reacted to once its quiet window has closed, about 16 minutes after it, and not on the first poll, so a visit that is withdrawn no longer quits the browser. On Linux the quit reaction ends only the browser that holds the watched profile; other Chrome channels and headless browsers keep running. When it cannot tell which process that is, it does nothing and says so, which includes a Flatpak Brave."},{title:"🧮 Figures that were off are right",body:`Spend by labelled and workflow subagents counts toward a session's tokens and cost. The Projects report prices 1-hour cache writes the way ccusage does, so its dollars match the Usage panel. After a restart the deck rebuilds its whole event history, where it used to rebuild about a third. On Linux the process list shows what each process is using now, not its lifetime average. A count near a boundary reads "1.00M", and a full quota window says "used up".`},{title:"🔑 The Usage panel's reads answer the deck's own page only",body:"The routes behind the Usage panel (/api/quota, /api/ccusage, /api/codex-usage, /api/codex-quota and /api/cswap-auto) now answer the deck's own page, or a client that sends the deck's token. A script that read them with a plain request gets 401 from this version on. The hook, the desktop app and the `ccdeck` command are not affected."},{title:"🛠️ Smaller fixes you may notice",body:"With the canvas paused, an update no longer restarts the server while an agent is working: it waits until no turn is open. `ccdeck --stop -p4317` stops that one deck. A deck started at login can update itself on Homebrew and nvm setups. Dialogs keep keyboard focus after a button goes away, screen readers hear pairing requests by deck name and the machine panel's readings, dim text is readable in both themes, Windows High Contrast shows what is selected, and below 640px the detail panel opens over the canvas."}],"3.32.2":[{title:"🔒 Self-updates wait until your screen is unlocked",body:"On Linux with GNOME, the app installs an update by itself when you leave it alone, which is often while your screen is locked. GNOME switches the panel's tray off under the lock screen, and a version that started then never showed its icon. The app now waits until you are back before restarting by itself, so its icon comes back with it."}],"3.32.1":[{title:"🔔 The tray icon comes back on Linux",body:"On Linux the app could lose its icon in the panel, after it updated itself or when the panel restarted, and stay without it until it was quit. It now notices within a minute and restarts by itself the next time you are away from its window, the way it installs an update. It does this at most once every six hours, and not again if a restart did not help."},{title:"🔕 A window you closed stays closed after a self-update",body:"When the app restarted by itself to install an update, it opened its window again even if you had closed it, and while that window was open the deck held back its notifications. A window you closed now stays closed."},{title:"🪟 No empty icon when ccdeck is already open",body:'Opening ccdeck again while it was running flashed an empty "…" icon in the Linux panel before bringing the window forward. It now only brings the window forward.'}],"3.32.0":[{title:"🗺️ A map of your network",body:"A new button on the Local network row, and in its view's header, opens a map of every deck around this one. This deck is at the centre and the paired decks that are on stand around it. Further out are the quiet ones, the machines nearby and any deck asking to pair. Wires are solid on your local network and dashed over Tailscale. Pointing at a deck says how it is reached, what it runs and which logins the two share, and pressing it opens that deck's own dialog."}],"3.31.0":[{title:"📊 Account capacity",body:"A gauge button in the accounts panel's header opens Account capacity: how many of your Claude accounts are ready now, what the 5-hour and 7-day windows have left across all of them, and a row for each account with its use, its state (Ready, Limited, Exhausted or Stale) and when it was last read. Each window also says whose reset comes next."},{title:"🚦 Claude and Codex incidents",body:"When Anthropic's or OpenAI's status page reports an incident on something your sessions use, the deck says so in the topbar, the Usage panel and the tray, and every mark links to the status page. A provider with nothing wrong draws nothing."},{title:"↕️ Order your other accounts",body:"The Other accounts row can sort the list by slot, by how full a window is, or by most room, and open every account at once. Both stay as you left them after a reload."},{title:"🔐 A settings folder left by sudo can be given back",body:'On a Mac, running ccdeck once with sudo left its settings folder owned by another user, and every settings change was refused, sharing an account included. The message now offers "give it back": macOS asks for your password, the folder is yours again, and the deck reads its settings back without a restart.'}],"3.30.0":[{title:"🧮 Token counts and costs are no longer doubled",body:"Claude Code writes a reply that has thinking, text and tool calls as several transcript lines, each carrying the whole request's usage. The deck added up every line, so a session's tokens and cost on its card came out close to twice what it was billed, and the context panel counted each part of a reply as its own message. Each request is now counted once. Expect the totals on your cards to come down."},{title:"⏳ Claude's saved limit resets on the Usage panel",body:`When your Claude account has free limit resets to spend ("Reset for free" in Claude's Settings → Usage), the Claude card now says how many there are and when the first one expires, the way the Codex card already did. The deck only reports them; you spend them in Claude's own settings.`},{title:"🔑 LAN invites need the other deck updated",body:`An invite's code is now a long random secret instead of six digits, so nobody else on the network can work it out and pair in your place, and a wrong code is refused by name. An invite made on this version can only be joined from a deck on this version or later: an older deck answers "That is not an invite". Update that deck, or make the invite on the older one and join it here.`},{title:"🔕 AGENTS_DECK_NO_NOTIFY keeps Browser Watch quiet too",body:"A deck started with AGENTS_DECK_NO_NOTIFY=1 still raised a desktop notification for every new Browser Watch finding. It no longer does. The finding is still in the Browser Watch panel and its log, which says why no notification came."},{title:"🛠️ Smaller fixes",body:'Delete removes the card you just clicked. A LAN address you typed stays in the list when a round cannot reach it, and the status line under the LAN switch now agrees with the rows below it. In the desktop app, a dismissed "update is ready" notice stays dismissed after you answer the first-launch question. Sizes read the same in every panel ("1.1 KB"). Faded text stays readable, a keyboard can see the scrollbar, and numbers use a monospaced font on Windows and Linux as well.'}],"3.29.11":[{title:"💲 Claude Sonnet 5.5 has a price",body:`Sessions on Claude Sonnet 5.5 showed "not priced" on the board, and the Projects report could only show a minimum for them. They are now priced at Anthropic's published rate, the same as Sonnet 5: $2 per million input tokens and $10 per million output tokens.`}],"3.29.10":[{title:"💲 Claude Opus 5.5 has a price",body:`Sessions on Claude Opus 5.5 showed "not priced" on the board, and the Projects report counted them as costing nothing, so its totals read far too low. They are now priced at Anthropic's published rate. If a model still has no price, Projects shows its total as a minimum, like $11.19+, and names the model, instead of a total that looks complete.`}],"3.29.8":[{title:"🔁 Removed cards come back when their agent works again",body:"Remove from board is for finished work. If the agent behind a card you removed starts a tool call, gets a new prompt or starts a subagent, the card returns on its own, together with the card it hangs from, and it stays back after a reload. Cards whose agents stay idle stay removed."}],"3.29.1":[{title:"🗂️ One row per project in Projects",body:"The Projects report now counts a session's work under the folder you started it in, the same name its card has on the canvas, instead of adding a row for every folder the agent moved into. The first start after updating re-reads your transcripts once to regroup the report."},{title:"🔔 Tidier custom sounds",body:"Importing a sound, recording one and choosing a spoken voice now sit in compact cards that respond to clicks and focus like the rest of the deck."}],"3.29.0":[{title:"🎵 Your own stations in Claude FM",body:"Add any YouTube live link or radio stream as a station in Appearance, next to the built-in ones, and mute the music without losing your volume. When a station is not live, the picker now says so instead of staying silent."},{title:"🔔 Notification sounds and voices of your own",body:"Pick a local audio file or a spoken voice for each alert, so the sound that means an agent is waiting is one you will recognise."},{title:"🗑️ Drag a card off the board to remove it",body:"Drag a card to the target at the bottom of the canvas to take it off the board, or use Remove from board in the detail panel (Delete). The session keeps running, and the session list (L) brings it back."},{title:"🔐 Optional invite-only pairing",body:"Pairing works as before, with or without an invite. If you want, Local network can now be set to accept only decks that join with an invite you created, so a nearby machine cannot ask to pair on its own."},{title:"🌐 Account sharing between your machines is more reliable",body:"A locked macOS Keychain is explained instead of failing silently, a login that is broken or belongs to another account is never shared, and a sync that stops partway keeps what already arrived."},{title:"📅 Projects opens on Today",body:"The Projects report per account starts with today's work, and an empty window offers the next wider one. The topbar also shows this month's usage, and the desktop app can restart into an update from its own window."}],"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.
|
|
109
109
|
|
|
110
110
|
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.
|
|
111
111
|
|
|
@@ -299,8 +299,8 @@ It marks that work now. A chart with bars in it means the agent is doing somethi
|
|
|
299
299
|
|
|
300
300
|
Nothing was added to the card and nothing new is polled. The deck already reads each session's transcript for its token counts; this reads the same file for what the model has finished writing, and a session that is quiet costs one file check per second and a half.`}]},J0="agent-dag.releaseNotesSeen";function e2(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function xi(e,t){const n=e2(e),r=e2(t);for(let s=0;s<Math.max(n.length,r.length);s++){const o=(n[s]??0)-(r[s]??0);if(o!==0)return o<0?-1:1}return 0}function bi(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function foe(e){if(!e||typeof e!="object")return!1;const{title:t,body:n}=e;return typeof t=="string"&&t.trim()!==""&&typeof n=="string"&&n.trim()!==""}function poe(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,r]of Object.entries(e)){if(!bi(n)||!Array.isArray(r))continue;const s=r.filter(foe);s.length&&t.push({version:n,notes:s})}return t.sort((n,r)=>xi(r.version,n.version))}const t2=poe(hoe);function rP(e,t,n){return e.filter(r=>xi(r.version,n)<=0&&(t===null||xi(r.version,t)>0))}function moe(e,t){return e.filter(n=>xi(n.version,t)===0)}function goe(e){if(!e.length)return"";const t=e[0].version,n=e[e.length-1].version;return t===n?`v${t}`:`v${n} – v${t}`}function yoe({since:e,running:t,entries:n,firstRun:r}){if(!n.length)return"Nothing in this build has anything to report yet. Most releases do not, which is the point.";if(e!==null){const l=n.length===1?"one release":`${n.length} releases`;return`You were last caught up at v${e}. Since then ${l} changed something you would notice. Clicking the version in the topbar brings this back.`}if(r&&bi(t))return`The deck has not run in this browser before, so this is what v${t} — the release you have — changed. Earlier releases are not repeated here; clicking the version in the topbar brings all of them back.`;const s=n[0].version;if(!bi(t))return"Everything this build has to say, newest first. Most releases have nothing here, which is why the deck stays quiet about them.";const o=xi(s,t);return o<0?`v${t} — the release you are running — changed nothing you would notice, which most releases do not. Below is the last release that did, and everything before it, newest first.`:o>0?"Everything this build has to say, newest first. Most releases have nothing here, which is why the deck stays quiet about them.":`You are running v${t}, and this is what it changed — and everything before it, newest first. Most releases have nothing here, which is why the deck stays quiet about them.`}const woe=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function voe(e){const t=woe.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function xoe(e){if(!e)return null;let t=null;try{t=e.getItem(J0)}catch{return null}return bi(t)?t:null}function boe(e){if(!e)return!1;try{return e.getItem(J0),!0}catch{return!1}}function koe(e,t){if(!e)return!1;try{return e.setItem(J0,t),!0}catch{return!1}}const sP="agent-dag.tourSeen";function Noe(e){if(!e)return!1;try{return e.getItem(sP)==="1"}catch{return!1}}function joe(e){if(!e)return!1;try{return e.setItem(sP,"1"),!0}catch{return!1}}function Soe({tourSeen:e,decision:t}){if(t.reason==="no-version"||t.reason==="cannot-remember")return{tour:!1,notes:"none"};if(t.reason==="welcome"||t.reason==="first-run")return{tour:!e,notes:"none"};const n=t.show.length>0;return e?{tour:!1,notes:n?"now":"none"}:{tour:!0,notes:n?"after":"none"}}function _oe({stored:e,running:t,notes:n,remembers:r=!0}){if(!bi(t))return{show:[],record:null,reason:"no-version"};if(!bi(e)){if(!r)return{show:[],record:t,reason:"cannot-remember"};const l=moe(n,t);return l.length?{show:l,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const s=xi(e,t);if(s===0)return{show:[],record:null,reason:"seen"};if(s>0)return{show:[],record:null,reason:"ahead"};const o=rP(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function Eoe(e,t){if(/\s|^$/.test(e[t+2]??""))return-1;let n=t+2;for(;n<e.length;){if(e[n]==="`"){const r=e.indexOf("`",n+1);if(r<0)break;n=r+1;continue}if(e.startsWith("**",n)&&!/\s/.test(e[n-1]??" "))return n;n++}return-1}function aP(e,t=!0){const n=[];let r="";const s=()=>{r&&(n.push({kind:"text",text:r}),r="")};let o=0;for(;o<e.length;){if(e[o]==="`"){const l=e.indexOf("`",o+1);if(l>o+1){s(),n.push({kind:"code",text:e.slice(o+1,l)}),o=l+1;continue}}else if(t&&e.startsWith("**",o)){const l=Eoe(e,o);if(l>0){s(),n.push({kind:"bold",kids:aP(e.slice(o+2,l),!1)}),o=l+2;continue}}r+=e[o],o+=1}return s(),n}function Coe({entries:e,since:t,running:n,firstRun:r,onClose:s,onTour:o,updateVersion:l,updateBusy:c,onUpdateRestart:d,updateFailure:h,onRestart:f}){const p=ut(s),g=gt(s),v=goe(e);return a.jsx("div",{className:"modal-backdrop",...g,role:"presentation",children:a.jsxs("div",{ref:p,className:"modal release-notes",onClick:N=>N.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"release-notes-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:"What's new"}),v&&a.jsx("span",{className:"modal-tool-id",children:v})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[(l||h)&&a.jsxs("div",{className:"rn-update",children:[l&&d&&a.jsxs("div",{className:"guide-door",children:[a.jsxs("span",{children:["ccdeck v",l," is downloaded and verified."]}),a.jsx("button",{type:"button",className:"btn",onClick:d,"aria-busy":c||void 0,children:c?"Restarting…":Dd})]}),a.jsx("p",{className:"rn-update-said",role:"status",children:h})]}),a.jsx("p",{className:"modal-note",children:yoe({since:t,running:n,firstRun:r,entries:e})}),o&&!l&&a.jsxs("div",{className:"guide-door",children:[a.jsx("span",{children:"Eight pictures of what the deck shows."}),a.jsx("button",{type:"button",className:"btn",onClick:o,children:"Take the tour"})]}),f&&a.jsxs("div",{className:"guide-door",children:[a.jsx("span",{children:"Restart the deck. Sessions, settings and pairings come back as they were."}),a.jsx("button",{type:"button",className:"btn",onClick:f,children:"Restart"})]}),e.map(N=>a.jsxs("section",{className:"modal-section",children:[a.jsxs("h3",{className:"rn-version",children:["v",N.version]}),a.jsx("ul",{className:"rn-notes",children:N.notes.map((k,x)=>{const{icon:j,rest:b}=voe(k.title);return a.jsxs("li",{className:"rn-note",children:[a.jsxs("p",{className:"rn-note-title",children:[j&&a.jsx("span",{className:"rn-note-icon",children:j}),b]}),a.jsx("p",{className:"rn-note-body",children:oP(aP(k.body))})]},x)})})]},N.version))]})]})})}function oP(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?a.jsx("code",{className:"rn-code",children:t.text},n):a.jsx("strong",{className:"rn-strong",children:oP(t.kids)},n))}function Toe({state:e,sessionId:t,onClose:n}){const r=y.useMemo(()=>Aoe(e,t),[e,e.revision,t]),s=y.useRef(null),o=ut(n,{focusRef:s}),l=gt(n);return r?a.jsx("div",{className:"modal-backdrop",...l,role:"presentation",children:a.jsxs("div",{ref:o,className:"modal session-summary",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[a.jsxs("div",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),a.jsx("span",{id:"ss-title",className:"modal-tool-name",title:r.cwd??r.sessionId,children:r.label}),a.jsxs("span",{className:"modal-tool-id",children:["· ",r.sessionId.slice(0,8)]})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("span",{className:"modal-dur",title:"Total wall time",children:r.durationLabel}),a.jsx("button",{type:"button",ref:s,className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("div",{className:"modal-body",children:[a.jsxs("section",{className:"ss-hero",children:[a.jsxs("div",{className:"ss-hero-left",children:[a.jsx("div",{className:"ss-cost-label",children:V$}),a.jsx("div",{className:"ss-cost",children:qe(r.cost.total)}),r.modelChips.length>0&&a.jsx("div",{className:"ss-models",children:r.modelChips.map(c=>a.jsx("span",{className:"model-chip","data-family":Xd(c),title:c,children:oa(c)},c))})]}),a.jsx("div",{className:"ss-hero-right",children:r.cost.total>0&&a.jsxs(a.Fragment,{children:[a.jsx(l0,{cost:r.cost,size:"lg"}),a.jsxs("div",{className:"ss-cost-legend",children:[a.jsxs("span",{className:"ssl ssl-in",children:["input ",a.jsx("b",{children:qe(r.cost.input)})]}),a.jsxs("span",{className:"ssl ssl-out",children:["output ",a.jsx("b",{children:qe(r.cost.output)})]}),a.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",a.jsx("b",{children:qe(r.cost.cacheRead)})]}),a.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",a.jsx("b",{children:qe(r.cost.cacheWrite)})]})]})]})})]}),a.jsxs("section",{className:"ss-stats",children:[a.jsx(Xo,{label:"agents",value:r.agentCount}),a.jsx(Xo,{label:"subagents",value:r.subagentCount}),a.jsx(Xo,{label:"tool calls",value:r.toolCount}),a.jsx(Xo,{label:"prompts",value:r.promptCount}),a.jsx(Xo,{label:"tokens",value:r.tokensSum.toLocaleString()}),r.errCount>0&&a.jsx(Xo,{label:"errors",value:r.errCount,tone:"err"})]}),r.topTools.length>0&&a.jsxs("section",{className:"modal-section",children:[a.jsx("h4",{children:"Most-used tools"}),a.jsx("div",{className:"ss-top-tools",children:r.topTools.map(([c,d])=>a.jsxs("div",{className:"ss-tt",children:[a.jsx("span",{className:"ss-tt-name",children:c}),a.jsx("span",{className:"ss-tt-bar",children:a.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${d/r.topTools[0][1]*100}%`}})}),a.jsx("span",{className:"ss-tt-count",children:d})]},c))})]}),r.firstPrompt&&a.jsxs("section",{className:"modal-section",children:[a.jsx("h4",{children:"Opening prompt"}),a.jsx("div",{className:"ss-prompt",children:r.firstPrompt})]})]})]})}):null}function Xo({label:e,value:t,tone:n}){return a.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,children:[a.jsx("div",{className:"ss-stat-value",children:t}),a.jsx("div",{className:"ss-stat-label",children:e})]})}function Aoe(e,t){const n=e.agents.get(t);if(!n)return null;const r=[];for(const _ of e.agents.values())_.sessionId===t&&r.push(_);if(r.length===0)return null;const s={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},o=new Set,l=new Map;let c=0,d=0,h=0,f=0,p=0,g,v=1/0,N=0;for(const _ of r){const E=pn(_);s.input+=E.input,s.output+=E.output,s.cacheRead+=E.cacheRead,s.cacheWrite+=E.cacheWrite,s.total+=E.total;for(const T of h$(_))o.add(T);_.model&&o.add(_.model),_.kind==="subagent"&&p++;const R=ZM(_.prompts);d+=R.length,!g&&R.length>0&&(g=R[0].text),h+=_.usage.inputTokens+_.usage.outputTokens,c+=_.toolCount,f+=_.toolErrorCount??0;for(const[T,A]of _.toolCountByName??[])l.set(T,(l.get(T)??0)+A);v=Math.min(v,_.startedAt),N=Math.max(N,_.endedAt??Date.now())}const k=Math.max(0,N-v),x=Math.floor(k/1e3),j=x<60?`${x}s`:x<3600?`${Math.floor(x/60)}m ${String(x%60).padStart(2,"0")}s`:`${Math.floor(x/3600)}h ${Math.floor(x%3600/60)}m`,b=Array.from(l.entries()).sort((_,E)=>E[1]-_[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||"session",cwd:n.cwd,durationLabel:j,cost:s,modelChips:Array.from(o),agentCount:r.length,subagentCount:p,toolCount:c,promptCount:d,tokensSum:h,errCount:f,topTools:b,firstPrompt:g}}function Roe({tool:e,onClose:t}){const n=ut(t),r=gt(t),s=e.endedAt==null?"inflight":e.ok===!1?"err":"done",o=y.useRef({of:null});o.current.of!==e&&(o.current={of:e}),e.input!==void 0&&(o.current.input=e.input),e.response!==void 0&&(o.current.response=e.response);const l=o.current.input??e.inputPreview,c=o.current.response??e.errorPreview,d=e.trimmed===!0&&o.current.input===void 0&&o.current.response===void 0,h=y.useMemo(()=>{const f=zq(e.name,l,c);return{input:f.input.map((p,g)=>a.jsx(n2,{block:p},g)),response:f.response.map((p,g)=>a.jsx(n2,{block:p},g)),copyInput:wj(e.name,"input",l),copyResponse:wj(e.name,"response",c)}},[e.name,l,c]);return a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal",onClick:f=>f.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:`status-dot ${s}`,"aria-hidden":!0}),a.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),a.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("span",{className:"modal-dur",children:m$(e,"in-flight…")}),a.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("section",{className:"modal-body",children:[d&&a.jsx("div",{className:"modal-section",children:a.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsx("h4",{children:"Input"}),a.jsx(r2,{text:h.copyInput,what:"input"})]}),h.input]}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsxs("h4",{children:["Response ",s==="err"&&a.jsx("span",{className:"err-tag",children:"error"})]}),e.endedAt!=null&&a.jsx(r2,{text:h.copyResponse,what:"response"})]}),e.endedAt==null?a.jsx("pre",{children:"(waiting…)"}):h.response]})]})]})})}const Moe={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function n2({block:e}){const[t,n]=y.useState(!1);if(e.inline)return a.jsxs("p",{className:"tm-inline",children:[e.label&&a.jsx("span",{className:"tm-label",children:e.label}),a.jsx("code",{children:e.text})]});const r=y.useMemo(()=>Lq(e),[e]),{shown:s}=JM(r,t),o=Pq(r,t);return a.jsxs("div",{className:"tm-block",children:[e.label&&a.jsx("span",{className:"tm-label",children:e.label}),a.jsx("pre",{className:e.err?"tm-err":void 0,children:e.lines?s.map((l,c)=>a.jsxs("span",{className:l.tone?Moe[l.tone]:void 0,children:[l.text,c<s.length-1?`
|
|
301
301
|
`:""]},c)):s.map(l=>l.text).join(`
|
|
302
|
-
`)}),o&&a.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(l=>!l),children:o.label})]})}function r2({text:e,what:t}){const[n,r]=y.useState(!1),s=y.useRef(!0);return y.useEffect(()=>()=>{s.current=!1},[]),a.jsx("button",{type:"button",className:"btn tm-copy",disabled:!e,"aria-label":n?`The ${t} was copied`:`Copy the ${t}`,onClick:()=>void eo(e).then(o=>{!o||!s.current||(r(!0),window.setTimeout(()=>{s.current&&r(!1)},1600))}),children:n?"copied":"copy"})}const $oe=tP(()=>o0(()=>import("./UsageHistoryModal-
|
|
302
|
+
`)}),o&&a.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(l=>!l),children:o.label})]})}function r2({text:e,what:t}){const[n,r]=y.useState(!1),s=y.useRef(!0);return y.useEffect(()=>()=>{s.current=!1},[]),a.jsx("button",{type:"button",className:"btn tm-copy",disabled:!e,"aria-label":n?`The ${t} was copied`:`Copy the ${t}`,onClick:()=>void eo(e).then(o=>{!o||!s.current||(r(!0),window.setTimeout(()=>{s.current&&r(!1)},1600))}),children:n?"copied":"copy"})}const $oe=tP(()=>o0(()=>import("./UsageHistoryModal-DYSZZZEz.js"),[]),"Usage history"),Ioe=tP(()=>o0(()=>import("./BrowserWatchModal-njN0zg93.js"),[]),"Browser Watch");function Ooe({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:r,restart:s,lanPairs:o,attention:l,clearFlow:c,watchBadge:d,announcements:h,appearance:f,providers:p,stateRef:g,agentCount:v}){const{openedTool:N,setOpenedToolKey:k,usageHistoryOpen:x,setUsageHistoryOpen:j,browserWatchOpen:b,setBrowserWatchOpen:_,contextAgent:E,setContextFor:R,summaryFor:T,setSummaryFor:A,keyHelpOpen:U,setKeyHelpOpen:L,feedbackOpen:F,setFeedbackOpen:O,feedbackPrefill:I,setFeedbackPrefill:B}=e,{tourOpen:M,openTour:$,closeTour:P,releaseNotes:G,closeReleaseNotes:K,chipVersion:q}=t,{desktopUpdateRestarting:H,desktopUpdateFailure:D,readyAppUpdate:W,askDesktopUpdateRestart:J}=n,{version:V}=r,{askRestart:X}=s,{clearConfirmOpen:Y,setClearConfirmOpen:Z,requestClear:ee}=c,{setWatchOn:ne,markWatchSeen:se}=d,{setWatchSaid:pe}=h,{palette:ke}=f;return a.jsxs(a.Fragment,{children:[N&&a.jsx(Roe,{tool:N,onClose:()=>k(null)}),x&&a.jsx(y.Suspense,{fallback:null,children:a.jsx($oe,{providers:p,onClose:()=>j(!1)})}),b&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Ioe,{onClose:()=>_(!1),onSeen:ae=>{pe(""),se(ae)},onWatching:ne,palette:ke})}),E&&a.jsx(wU,{agent:E,onClose:()=>R(null)}),F&&a.jsx(eP,{initialKind:I==null?void 0:I.initialKind,initialBody:I==null?void 0:I.initialBody,onClose:()=>{O(!1),B(null)}}),T&&a.jsx(Toe,{state:g.current,sessionId:T,onClose:()=>A(null)}),G&&a.jsx(Coe,{entries:G.entries,since:G.since,firstRun:G.firstRun,running:q,onClose:K,onTour:()=>{K(),$()},updateVersion:W==null?void 0:W.version,updateBusy:H,updateFailure:D&&(!W||W.version===D.version)?Wre(D.failure,D.version):void 0,onUpdateRestart:W?()=>{J(W.version)}:void 0,onRestart:!W&&(V!=null&&V.canRestart)?()=>{K(),X()}:void 0}),a.jsx(Loe,{lanPairs:o,attention:l}),U&&a.jsx(Yae,{onClose:()=>L(!1),onTour:()=>{L(!1),$()}}),M&&a.jsx(DI,{title:"What the deck shows you",steps:sK,onClose:P}),Y&&a.jsx(Rse,{agentCount:v,onConfirm:()=>ee("confirmation"),onCancel:()=>Z(!1)})]})}function Loe({lanPairs:e,attention:t}){const n=ioe(e);return a.jsxs(a.Fragment,{children:[n,a.jsx(doe,{...t,pairing:n!=null})]})}const Poe=10,iP=500,lP=4e3,Doe=[/ResizeObserver loop/i,/^Script error\.?$/i],Bd=String.raw`[^\s\\/:'"\`<>|?*;,]`,Foe=String.raw`${Bd}(?:[^\\/\r\n:'"\`<>|?*;,]*${Bd})?[\\/]`,Boe=String.raw`[^\s\\/:'"\`<>|?*;,()]+`,bl=String.raw`(?:${Foe})*(?:${Boe})?`,qoe=String.raw`(?<![\w.~/\\\]-]|<(?:deck|host)>)(?:file://(?:/[A-Za-z]:)?[^\s:'"\`<>()]*|~[\\/]${bl}|[A-Za-z]:[\\/]${bl}|\\\\(?:[?.]\\)?(?:[A-Za-z]:\\)?${bl}|/(?=${Bd})${bl}|(?<!:)//(?=${Bd})${bl})`,Uoe=String.raw`(?<![\w-])(?:[A-Za-z]--|-[A-Za-z0-9][\w.]*-)[\w.-]*`,zoe=new Set([".claude",".codex"]);function Woe(e){if(!e.startsWith("~"))return"<path>";const t=e[1],[n,...r]=e.slice(2).split(/[\\/]/);return n?zoe.has(n)?r.join("")?`~${t}${n}${t}<path>`:e:`~${t}<path>`:e}const Hoe=String.raw`\b(https?|wss?)://[^\s/?#\\'"\x60<>(),;]+(?=(/assets/)?)`;function Voe(e,t,n){return n?"<deck>":`${t}://<host>`}const s2=String.raw`(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)`,cP=String.raw`${s2}(?:\.${s2}){3}`,ux=String.raw`[0-9A-Fa-f]{1,4}`,a2=String.raw`(?=[0-9A-Fa-f:]*\d)(?=[0-9A-Fa-f:]*::|(?:${ux}:){7})(?:(?:${ux})?:)+(?:${cP}|${ux})?`,o2=String.raw`%[\w-]+(?:\.[\w-]+)*`,i2=String.raw`(?:::1?|::ffff:(?:127(?:\.\d{1,3}){3}|0\.0\.0\.0))`,Goe=String.raw`(?<![\w:.%-])(?:\[(?!${i2}\])${a2}(?:${o2})?\]|(?!${i2}(?::\d{1,5})?(?![\w:%]|\.\d))${a2}(?:${o2})?(?![\w%]|\.\d))|(?<![\w./-])(?!127\.|0\.0\.0\.0\b)${cP}(?![\w-]|\.\d)`,dx=String.raw`(?=[\w.-]*[A-Za-z])[A-Za-z0-9][\w-]*(?:\.[\w-]+)*`,Koe=String.raw`(?<![\w.@/\\%-])(?!localhost(?![\w-]|\.\w))(?:(?<=\b(?:(?:getaddrinfo|connect) E[A-Z_]+|ENOTFOUND|EAI_AGAIN) )${dx}|${dx}(?=:\d{1,5}(?![\w:-]|\.\w))|${dx}\.(?:local|lan|home|internal|ts\.net)(?![\w-]|\.\w))`;function l2(e){return String(e??"").replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").replace(new RegExp(qoe,"g"),Woe).replace(new RegExp(Uoe,"g"),"<project>").replace(new RegExp(Hoe,"g"),Voe).replace(new RegExp(Goe,"g"),"<host>").replace(new RegExp(Koe,"g"),"<host>").replace(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,"<email>").replace(/\b(?:sk-ant-[A-Za-z0-9_-]{8,}|sk-[A-Za-z0-9_-]{20,}|gh[pousr]_[A-Za-z0-9]{20,}|xox[abpr]-[A-Za-z0-9-]{10,}|eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}|[A-Fa-f0-9]{40,}|[A-Za-z0-9+_=-]{48,})/g,"<secret>")}const uP=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function Yoe(e,t,n=uP){const r=String(e??"").slice(0,iP).trim();r&&n({message:r,stack:typeof t=="string"?t.slice(0,lP):void 0})}function Xoe(e,t=window,n=uP){let r=0;const s=new Set,o=(d,h)=>{const f=String(d??"").slice(0,iP).trim();!e()||!f||r>=Poe||s.has(f)||Doe.some(p=>p.test(f))||(s.add(f),r++,n({message:f,stack:typeof h=="string"?h.slice(0,lP):void 0}))},l=d=>{var h,f;return o(((h=d.error)==null?void 0:h.message)??d.message,(f=d.error)==null?void 0:f.stack)},c=d=>typeof d.reason=="object"&&d.reason!==null?o(d.reason.message,d.reason.stack):o(d.reason,void 0);return t.addEventListener("error",l),t.addEventListener("unhandledrejection",c),()=>{t.removeEventListener("error",l),t.removeEventListener("unhandledrejection",c)}}const Zoe=12;function Joe(e,t){const n=[l2(e).trim()||"The deck threw an error with no message."],r=t==null?void 0:t.trim();if(r){const s=r.split(`
|
|
303
303
|
`).slice(0,Zoe).join(`
|
|
304
304
|
`);n.push("",l2(s).trim())}return n.join(`
|
|
305
305
|
`)}class Qoe extends y.Component{constructor(){super(...arguments);op(this,"state",{error:null,componentStack:null,reportOpen:!1});op(this,"onKey",n=>{y$(n.key)&&ds.dismissTop()})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){console.error("ccdeck hit a render error it could not draw past",n,r.componentStack),this.setState({componentStack:r.componentStack??null}),Yoe(n.message,n.stack),OL("offline")}componentDidUpdate(n,r){this.state.reportOpen!==r.reportOpen&&(this.state.reportOpen?window.addEventListener("keydown",this.onKey):window.removeEventListener("keydown",this.onKey))}componentWillUnmount(){window.removeEventListener("keydown",this.onKey)}render(){const{error:n,componentStack:r,reportOpen:s}=this.state;return n?a.jsxs("div",{className:"error-fallback",children:[a.jsxs("div",{className:"error-fallback-card",role:"alert",children:[a.jsx("p",{className:"error-fallback-title",children:"Something went wrong"}),a.jsx("p",{className:"error-fallback-note",children:"The deck hit an error it could not draw past. Reloading usually clears it — and if it keeps happening, a report tells the people who make ccdeck what broke."}),a.jsxs("div",{className:"error-fallback-actions",children:[a.jsx("button",{type:"button",className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>this.setState({reportOpen:!0}),"aria-haspopup":"dialog",children:"Send report"})]})]}),s&&a.jsx(eP,{initialKind:"bug",initialBody:Joe(n.message,r),onClose:()=>this.setState({reportOpen:!1})})]}):this.props.children}}const eie=1e3;function tie(e={}){const t=Math.max(1,Math.floor(e.limit??eie)),n=e.protect;let r=!1,s=[],o=new Set,l=0,c=0,d=null;return{get paused(){return r},get size(){return s.length},get dropped(){return l},get overflowed(){return l>0},get through(){return c},accept(h){const f=typeof(h==null?void 0:h.seq)=="number"?h.seq:null,p=(h==null?void 0:h.epoch)??null,g=p!==null&&p!==d;g&&(d=p,c=0);const v=f!==null&&!g&&f<=c;if(f!==null&&f>c&&(c=f),!r)return!0;if(v)return!1;if(s.push(h),n!=null&&n(h)&&o.add(h),s.length>t){let N=0;if(o.size<s.length)for(;o.has(s[N]);)N++;const[k]=s.splice(N,1);o.delete(k),l++}return!1},setPaused(h){if(r=h,h)return[];const f=s;return s=[],o=new Set,l=0,f}}}function nie(e){const t=y.useState(()=>tie({protect:o=>Kq(e.current,o)}))[0],[n,r]=y.useState(!1),s=y.useCallback(()=>{const o=t.paused&&t.dropped>0,l=t.setPaused(!t.paused);o&&j8(e.current);for(const c of l)e.current=l$(e.current,c);r(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:s}}const Sb={kind:"assumed",claude:!0,codex:!0};function rie(e){if(!e||typeof e!="object")return Sb;const t=e.providers;if(!t||typeof t!="object")return Sb;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function sie(e){const[t,n]=y.useState(null),[r,s]=y.useState(Sb);y.useEffect(()=>{let l=!1;return fetch("/api/health").then(c=>c.ok?c.json():null).then(c=>{l||(s(rie(c)),!(!c||typeof c.workspace!="string")&&n(c.workspace))}).catch(()=>{}),()=>{l=!0}},[e]);const o=_n(r);return{workspace:t,providers:r,providersRef:o}}const dP=3*6e4,aie=2e4;function oie({fetchReport:e,visible:t,now:n,onReport:r}){let s=0,o=!0;const l=async()=>{if(!t())return;const c=await e();!o||!c||(s=n(),r(c))};return{tick:l,wake:async()=>{t()&&n()-s>=dP&&await l()},stop:()=>{o=!1}}}async function iie(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(aie)});return e.ok?await e.json():null}catch{return null}}function lie(e){const[t,n]=y.useState(null);return y.useEffect(()=>{if(!e){n(null);return}const r=oie({fetchReport:iie,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});r.tick();const s=window.setInterval(r.tick,dP),o=()=>{r.wake()};return document.addEventListener("visibilitychange",o),()=>{r.stop(),window.clearInterval(s),document.removeEventListener("visibilitychange",o)}},[e]),t}const cie={degraded:"degraded performance",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},uie={degraded:"degraded",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},die={degraded:"degraded",partial_outage:"outage",major_outage:"outage",maintenance:"maint."},hie={claude:"Claude",codex:"Codex"},fie=new Set(["status.claude.com","status.openai.com"]),pie=30*6e4,mie=10*6e4;function gie(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&fie.has(t.hostname)?t:null}catch{return null}}function c2(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function yie(e){const t=Math.floor(e/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`}function wie(e,t){if(!e||typeof e!="object")return null;const n=Ot(cie,e.state),r=Ot(hie,e.provider);if(!n||!r||typeof e.checkedAt!="number"||t-e.checkedAt>pie)return null;const s=gie(e.statusPageUrl);if(!s)return null;const o=Array.isArray(e.components)?e.components:[],l=e.stale===!0||t-e.checkedAt>mie,c=[`${r}: ${n}${e.summary?` — ${e.summary}`:""}`,o.length>0?`Affected: ${o.join(", ")}`:null,e.scope==="page"?`The page's overall status: it names none of ${r}'s components`:null,l?`Last read from ${s.hostname} at ${c2(e.checkedAt)}; this is the last thing it said`:`Reported by ${s.hostname}, checked ${yie(t-e.checkedAt)}`,"Opens the status page"],d=l?c2(e.checkedAt):null;return{provider:e.provider,state:e.state,name:r,label:`${r} · ${n}${d?` · as of ${d}`:""}`,words:n,chipWords:Ot(uie,e.state)??n,shortWords:Ot(die,e.state)??n,asOf:d,what:e.summary||(o.length>0?o.join(", "):null),href:s.href,host:s.hostname,stale:l,detail:c.filter(Boolean).join(`
|
|
306
|
-
`)}}function vie(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>wie(n,t)).filter(n=>n!==null)}function xie(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const bie="The providers' status pages report no incident.";function kie({version:e,loadVersion:t}){var h;const[n,r]=y.useState(!1),s=((h=e==null?void 0:e.upgrade)==null?void 0:h.state)??"idle",o=vse(e==null?void 0:e.upgrade),l=y.useRef(!1),c=y.useCallback(async()=>{if(lr(l.current||s==="running")){l.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),l.current=!1}},[s,t]);y.useEffect(()=>{if(s!=="running")return;const f=window.setInterval(t,3e3);return()=>window.clearInterval(f)},[s,t]);const d=y.useCallback(async()=>{const f=e==null?void 0:e.command;!f||!await eo(f)||(r(!0),window.setTimeout(()=>r(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:s,upgradeFailure:o,startUpgrade:c,copyCommand:d,cmdCopied:n}}const u2="agent-dag.browserWatch.seenMs";function Nie(e,t){return e.filter(n=>n.startMs>t)}function jie(){const[e,t]=y.useState(()=>Number(Qe(u2))||0),[n,r]=y.useState([]),[s,o]=y.useState(!1);y.useEffect(()=>{let d=!0;const h=()=>{fetch("/api/browser-watch?live=0").then(p=>p.ok?p.json():null).then(p=>{var g;!d||!(p!=null&&p.ok)||(r(p.episodes??[]),o(((g=p.settings)==null?void 0:g.enabled)===!0))}).catch(()=>{})};h();const f=setInterval(h,5*6e4);return()=>{d=!1,clearInterval(f)}},[]);const l=y.useMemo(()=>Nie(n,e).length,[n,e]),c=y.useCallback(d=>{t(d),Ze(u2,String(d))},[]);return{watchOn:s,setWatchOn:o,watchUnseen:l,markWatchSeen:c}}const hP=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function d2(e){const t={};for(const n of hP)t[n]=e(n);return t}function Sie(e){return t=>e[t]??""}function _ie(e,t){return hP.every(n=>e[n]===t[n])}const fP="agent-dag.theme";function Eie(e,t=!1){return e==="light"||e==="dark"?e:t?"light":"dark"}function Cie(){try{return window.matchMedia("(prefers-color-scheme: light)").matches}catch{return!1}}function Tie(){return Eie(Qe(fP),Cie())}function h2(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function Aie(){const[e,t]=y.useState(Tie),[n,r]=y.useState(ore),[s,o]=y.useState(()=>d2(h2)),l=y.useMemo(()=>Sie(s),[s]),c=y.useCallback(d=>ine(d,l),[l]);return y.useEffect(()=>{document.documentElement.dataset.theme=e,Ze(fP,e),o(d=>{const h=d2(h2);return _ie(d,h)?d:h})},[e]),y.useEffect(()=>{Ze(FL,n?"1":"0")},[n]),y.useEffect(()=>{const d=document.querySelector('meta[name="theme-color"]'),h=s["--panel"];d&&h&&d.setAttribute("content",h)},[s]),{theme:e,setTheme:t,characterEnabled:n,setCharacterEnabled:r,palette:s,minimapNodeFill:c}}function Rie(e){const t=y.useRef(null),[n,r]=y.useState(!1),[s,o]=y.useState(()=>new Set),l=y.useMemo(()=>{const d=new Set;for(const h of e.current.agents.values())for(const f of h.tools)d.add(PL(f.name));return Object.keys(LL).filter(h=>d.has(h))},[e.current,e.current.revision]);y.useEffect(()=>{if(l.length<=1){r(!1);return}let d=0;const h=()=>{const f=t.current;if(f&&!document.hidden){const p=f.getBoundingClientRect(),g=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(N=>N.getBoundingClientRect()),v=AH(p,g,8);r(N=>N===v?N:v)}d=window.setTimeout(h,300)};return h(),()=>window.clearTimeout(d)},[l.length]);const c=y.useCallback(d=>{o(h=>{const f=new Set(h);return f.has(d)?f.delete(d):f.add(d),f})},[]);return{presentCats:l,hiddenCats:s,toggleCat:c,catBarRef:t,catBarOccluded:n}}function Mie(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const r=new Set,s=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",o=()=>{var g;return(g=e.onState)==null?void 0:g.call(e,s())};function l(){var g,v;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(g=n.addEventListener)==null||g.call(n,"statechange",o)),(v=n.resume)==null||v.call(n).then(o,()=>{}),o()}catch{}}function c(g,v,N=v.figure){if(!n||n.state!=="running")return!1;const k=cb(g,N),x=dZ(v.level,k),j=n.currentTime;for(const b of k.notes){const _=n.createOscillator(),E=n.createGain();_.type=k.type??"sine",_.frequency.value=b.hz;const R=j+b.at,T=R+b.ms/1e3;E.gain.setValueAtTime(l_,R),E.gain.exponentialRampToValueAtTime(x,R+hZ),E.gain.exponentialRampToValueAtTime(l_,T),_.connect(E).connect(n.destination),_.start(R),_.stop(T+.02)}return!0}async function d(g,v){var x;if(!e.loadCustom)return"unavailable";let N;try{N=await e.loadCustom(g)}catch{return"unavailable"}if(!N)return"missing";if(N.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const j=new SpeechSynthesisUtterance(N.text),b=window.speechSynthesis.getVoices();j.voice=b.find(_=>_.voiceURI===N.voiceURI)??null,j.rate=N.rate,j.pitch=N.pitch,j.volume=fZ(v.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(j),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let k;try{k=await n.decodeAudioData(N.bytes.slice(0))}catch{return"broken"}try{const j=n.createBufferSource(),b=n.createGain();return j.buffer=k,b.gain.setValueAtTime(pZ(N.normalizationGain,v.level),n.currentTime),j.connect(b).connect(n.destination),r.add(j),(x=j.addEventListener)==null||x.call(j,"ended",()=>r.delete(j)),j.start(n.currentTime),"played"}catch{return"unavailable"}}function h(g,v=!1){var x,j;if(!v&&!e.enabled())return!1;const N=bZ((x=e.prefs)==null?void 0:x.call(e),g),k=((j=e.customSelection)==null?void 0:j.call(e)[g])??null;return k&&e.loadCustom?(d(k,N).then(b=>{var _;b==="played"||b==="locked"||((b==="missing"||b==="broken")&&((_=e.onCustomFailure)==null||_.call(e,g,k)),c(g,{...N,figure:jn},jn))}),!0):!n||n.state!=="running"?!1:c(g,N)}function f(g,v=Qa){return d(g,{level:vi(v),figure:jn}),!0}function p(){try{typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}catch{}for(const g of r)try{g.stop()}catch{}r.clear()}return{unlock:l,play:h,previewCustom:f,silence:p,state:s,get context(){return n}}}function $ie({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:r,fallbackCustomRef:s}){const[o,l]=y.useState("locked");return y.useEffect(()=>{const c=Mie({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>r.current,loadCustom:oZ,onCustomFailure:(p,g)=>s.current(p,g),onState:l});e.current=c,l(c.state());const d=["pointerdown","pointerup","keydown"],h=()=>{for(const p of d)window.removeEventListener(p,f,{capture:!0})},f=()=>{var p;c.unlock(),((p=c.context)==null?void 0:p.state)==="running"&&h()};for(const p of d)window.addEventListener(p,f,{capture:!0});return h},[]),{chimeState:o}}function Iie(){const[e,t]=y.useState(lre),[n,r]=y.useState(()=>lq(Qe(dj))),[s,o]=y.useState(()=>iq(Qe(hj))),[l,c]=y.useState(()=>cq(Qe(PR),n,sre)),[d,h]=y.useState(()=>new Set),[f,p]=y.useState(0);y.useEffect(()=>{Ze(BL,String(e))},[e]),y.useEffect(()=>{Ze(hj,s?"1":"0")},[s]),y.useEffect(()=>{Ze(dj,JSON.stringify(n))},[n]),y.useEffect(()=>{Ze(PR,l)},[l]);const g=y.useCallback(j=>{r(b=>b.some(_=>_.id===j.id)?b:[...b,j]),h(b=>{if(!b.has(j.id))return b;const _=new Set(b);return _.delete(j.id),_})},[]),v=y.useCallback((j,b)=>{const _=b.trim();!_||_.length>zl||r(E=>E.map(R=>R.id===j?{...R,name:_}:R))},[]),N=y.useCallback(j=>{r(b=>b.filter(_=>_.id!==j)),c(b=>uq(b,j)),h(b=>{if(!b.has(j))return b;const _=new Set(b);return _.delete(j),_})},[]),k=y.useCallback(j=>{const b=fj(j),_=d.has(b);j===l&&!_||(_&&h(E=>{const R=new Set(E);return R.delete(b),R}),c(j),p(E=>E+1))},[l,d]),x=y.useCallback((j,b)=>{const _=fj(j);h(E=>{if(E.has(_)===b)return E;const T=new Set(E);return b?T.add(_):T.delete(_),T})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:s,setFmMuted:o,fmSource:l,customFmStations:n,unavailableFmStations:d,fmPlayRequest:f,addFmStation:g,renameFmStation:v,removeFmStation:N,pickFmSource:k,markFmStationAvailability:x}}function Oie(e){const[t,n]=y.useState(null),[r,s]=y.useState(!1),[o,l]=y.useState(null),c=y.useRef(0);y.useEffect(()=>{if(!e||!sc())return;let N=!1;const k=c.current;return fetch("/api/desktop-update").then(x=>x.ok?x.json():null).then(x=>{if(N||c.current!==k)return;const j=WR(x);j&&n(j)}).catch(()=>{}),()=>{N=!0}},[e]);const d=Fre(t),h=y.useRef(!1),f=y.useRef(0),p=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(f.current),[]);const g=y.useCallback(async N=>{if(!lr(h.current))return;const k=++p.current;window.clearTimeout(f.current),h.current=!0,s(!0),l(null);const x=j=>{k===p.current&&(window.clearTimeout(f.current),h.current=!1,s(!1),l({failure:j,version:N}))};try{const j=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:N})});if(!j.ok)return x(zre(await j.json().catch(()=>null)))}catch{return x("unreachable")}k===p.current&&(f.current=window.setTimeout(()=>x("timeout"),qL))},[]),v=y.useCallback(N=>{if(sc())try{const k=WR(JSON.parse(N));k&&(c.current++,n(k),k.status!=="ready"&&(p.current++,window.clearTimeout(f.current),h.current=!1,s(!1)))}catch{}},[]);return{desktopUpdateRestarting:r,desktopUpdateFailure:o,readyAppUpdate:d,askDesktopUpdateRestart:g,onDesktopUpdateEvent:v}}const Ku="agent-dag.autoRestart",f2="agent-dag.bundleReloadedFor";function Lie({now:e,stateRef:t,version:n,notice:r,noticeOpen:s,upgradeFailure:o,paused:l}){const[c,d]=y.useState(()=>Qe(Ku)!=="0"),h=y.useRef(!1),f=y.useCallback(()=>{const F=!c;h.current=!0,hs(Ku),d(F),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:F})}).then(O=>O.ok?O.json():null).then(O=>{var I;O!=null&&O.ok&&d(((I=O.prefs)==null?void 0:I.autoUpdate)!==!1)}).catch(()=>{})},[c]),[p,g]=y.useState(!1),[v,N]=y.useState("restart"),[k,x]=y.useState(null),j=y.useRef(!1),b=y.useRef(null),_=y.useRef(0),E=y.useRef(null),R=y.useCallback(async F=>{if(!lr(j.current))return;const O=(F==null?void 0:F.upgrade)===!0,I=(F==null?void 0:F.whenIdle)===!0;j.current=!0,b.current=o;const B=++_.current,M=()=>{N(O?"npx":"restart"),g(!0)};I||M();try{window.sessionStorage.setItem("agent-dag.restartPending",(r==null?void 0:r.to)??"")}catch{}let $=!1;try{const P=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I?{upgrade:O,whenIdle:I}:{upgrade:O})});$=I&&P.status===409}catch{}if($){j.current=!1,E.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}I&&M(),window.setTimeout(()=>{if(_.current===B&&j.current){j.current=!1,g(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},O?18e4:3e4)},[r==null?void 0:r.to,o]);y.useEffect(()=>{const F=HR(t.current.agents.values())>0,O=jse({enabled:c,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:F,idleSince:E.current,now:e});E.current=O.idleSince,O.restart&&R({whenIdle:!0})},[c,r==null?void 0:r.kind,n==null?void 0:n.canRestart,s,e,R]);const T=HR(t.current.agents.values()),A=Nse(T,l),U=WL({enabled:c,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:T>0,idleSince:E.current,now:e});y.useEffect(()=>{const F=n==null?void 0:n.running;let O=null,I=null;try{O=window.sessionStorage.getItem("agent-dag.restartPending"),I=window.sessionStorage.getItem(f2)}catch{return}const B=wse({bundle:"3.37.0",running:F,pending:O,lastTried:I});if(B==="reload"){try{window.sessionStorage.setItem(f2,F??"")}catch{return}window.location.reload();return}if(B!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}j.current=!1,g(!1),x(F??null);const M=window.setTimeout(()=>x(null),6e3);return()=>window.clearTimeout(M)},[n==null?void 0:n.running]),y.useEffect(()=>{if(p&&xse({asked:b.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}j.current=!1,g(!1)}},[p,o]);const L=y.useCallback(F=>{var O,I;if(!h.current){const B=Qe(Ku)==="0";hs(Ku),B&&((O=F.prefs)==null?void 0:O.autoUpdate)!==!1?(d(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):d(((I=F.prefs)==null?void 0:I.autoUpdate)!==!1)}},[]);return{autoRestart:c,toggleAutoRestart:f,restarting:p,restartMode:v,restartedTo:k,askRestart:R,restartCopy:A,restartFuseMs:U,loadAutoRestartPrefs:L}}function Pie(){const[e,t]=y.useState([]),n=y.useRef(new Set),[r,s]=y.useState(null),[o,l]=y.useState(void 0);y.useEffect(()=>{let h=!0,f=0;const p=()=>{fetch("/api/lan").then(g=>g.ok?g.json():null).then(g=>h?(g!=null&&g.ok&&t(MS(Array.isArray(g.pending)?g.pending:[],g.aliases)),g):null).catch(()=>null).then(g=>{h&&(l(v=>g!=null&&g.ok?g:v===void 0?null:v),f=window.setTimeout(p,(g==null?void 0:g.enabled)===!0?tb:PI))})};return p(),()=>{h=!1,window.clearTimeout(f)}},[]);const c=y.useCallback(async(h,f)=>{if(!r){s(h);try{const g=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:h,fp:f})})).json().catch(()=>null);g&&Array.isArray(g.pending)?t(MS(g.pending,g.aliases)):t(v=>v.filter(N=>N.fp!==f))}catch{}finally{s(null)}}},[r]),d=y.useCallback(h=>{r||(n.current.add(h),t(f=>[...f]))},[r]);return{lanPending:e,lanDeferred:n,lanBusy:r,answerLanPair:c,deferLanPair:d,lanStatus:o}}const Die=6e4;function Fie({enabled:e,lanStatus:t,now:n}){const[r,s]=y.useState(null),[o,l]=y.useState(()=>new Set),[c,d]=y.useState(null),h=y.useCallback(j=>{j!=null&&j.ok&&Array.isArray(j.accounts)&&s(j.accounts)},[]),f=y.useCallback(async j=>{try{const b=await fetch(`/api/claude-accounts${j?"?refresh=1":""}`);b.ok&&h(await b.json())}catch{}},[h]);y.useEffect(()=>{e&&f(!1)},[e,f]),y.useEffect(()=>{if(!e)return;let j=Date.now();const b=()=>{document.visibilityState!=="visible"||Date.now()-j<Die||(j=Date.now(),f(!1))};return document.addEventListener("visibilitychange",b),window.addEventListener("focus",b),()=>{document.removeEventListener("visibilitychange",b),window.removeEventListener("focus",b)}},[e,f]);const p=y.useMemo(()=>e?Jae(r,{lan:t,now:n,closed:o}):[],[e,r,t,n,o]),g=y.useRef(p);g.current=p;const v=y.useCallback(j=>{j.length&&l(b=>new Set([...b,...j]))},[]),N=y.useCallback(()=>{const j=g.current;j.length&&(v(j.map(b=>b.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:j.map(b=>({key:b.key,since:b.since}))})}).catch(()=>{}))},[v]),k=y.useRef(c);k.current=c;const x=y.useCallback(j=>{const b=k.current;v(Qae(b?[b,...g.current]:g.current,j))},[v]);return{rows:p,signingIn:c,observe:h,signIn:d,signedIn:x,refresh:y.useCallback(()=>{f(!0)},[f]),closeSignIn:y.useCallback(()=>d(null),[]),later:N}}const pP="agent-dag.sessionListOpen",mP="agent-dag.accountsPanelOpen";function Bie(){return Qe(pP)==="1"}function qie(e){Ze(pP,e?"1":"0")}function Uie(){const e=Qe(mP);return e===null?!0:e==="1"}function zie(){const[e,t]=y.useState(Bie);y.useEffect(()=>{qie(e)},[e]);const n=y.useRef(!1),[r,s]=y.useState(()=>{const h=Uie();return h&&e?(n.current=!0,!1):h});y.useEffect(()=>{!r&&n.current||Ze(mP,r?"1":"0")},[r]),y.useEffect(()=>{!e&&n.current&&(n.current=!1,s(!0))},[e]);const o=y.useCallback(()=>{t(h=>(h||s(f=>(f&&(n.current=!0),!1)),!h))},[]),l=y.useCallback(()=>{n.current=!1,s(h=>(h||t(!1),!h))},[]),c=y.useCallback(()=>t(!1),[]),d=y.useCallback(()=>s(!1),[]);return{sessionListOpen:e,accountsPanelOpen:r,toggleSessionList:o,toggleAccountsPanel:l,closeSessionList:c,closeAccountsPanel:d}}const gP="agent-dag.detailOpen",yP="agent-dag.usagePanelOpen",wP="agent-dag.systemPanelOpen";function Wie(){return Qe(gP)==="1"}function Hie(e){Ze(gP,e?"1":"0")}function Vie(){const e=Qe(yP);return e===null?!0:e==="1"}function Gie(e){Ze(yP,e?"1":"0")}function Kie(){const e=Qe(wP);return e===null?!0:e==="1"}function Yie(e){Ze(wP,e?"1":"0")}function Xie(){const[e,t]=y.useState(Wie);y.useEffect(()=>{Hie(e)},[e]);const[n,r]=y.useState(Vie);y.useEffect(()=>{Gie(n)},[n]);const[s,o]=y.useState(Kie);return y.useEffect(()=>{Yie(s)},[s]),qt("usage-panel",n),qt("machine-panel",s),{detailOpen:e,setDetailOpen:t,usagePanelOpen:n,setUsagePanelOpen:r,machinePanelOpen:s,setMachinePanelOpen:o}}const Zie={permission:"your permission",asked:"your answer"},Jie="No sessions are waiting for you.";function Qie(e){if(e.length===0)return"";const[t,...n]=e,r=t.waiting.kind,s=n.every(l=>l.waiting.kind===r)?Zie[r]??"you":"you";if(n.length===0)return`${t.label} is waiting for ${s}.`;const o=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${o} are waiting for ${s}.`}function hx(e,t,n=Jie){return t!==""?t:e===""?"":n}function ele({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[r,s]=y.useState(""),o=Qie(e);y.useEffect(()=>{s(g=>hx(g,o))},[o]);const[l,c]=y.useState(""),d=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";y.useEffect(()=>{c(g=>hx(g,d,"Browser watch has no unread findings."))},[d]);const[h,f]=y.useState(""),p=xie(n);return y.useEffect(()=>{f(g=>hx(g,p,bie))},[p]),{blockedSaid:r,watchSaid:l,setWatchSaid:c,incidentSaid:h}}const tle="/icon-192.png";function nle({waitingSessions:e,liveSince:t,focusSession:n}){const[r,s]=y.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[o,l]=y.useState(null),[c,d]=y.useState(!1),[h,f]=y.useState(!1),p=y.useRef(()=>{}),g=y.useRef(new Set),v=_n(e),N=y.useCallback(()=>{const R=!c;d(R),R&&(g.current=$u(v.current)),R&&typeof Notification<"u"&&Notification.permission==="default"&&p.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:R})}).then(T=>T.ok?T.json():null).then(T=>{var A;T!=null&&T.ok&&(d(((A=T.prefs)==null?void 0:A.notifications)===!0),f(T.notificationsVetoed===!0))}).catch(()=>{})},[c]),k=typeof Notification<"u";y.useEffect(()=>{if(!o)return;const T=setTimeout(()=>l(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(T)},[o]);const x=y.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(R=>{const T=R;s(T),T==="granted"?l("on"):T==="denied"&&l("blocked")})},[]);p.current=x;const j=y.useRef(null),b=e.map(R=>Zd(R.id,R.waiting)).join("|");y.useEffect(()=>{W8(j.current,r)&&(j.current=r,g.current=$u(e))},[r]);const _=y.useRef(!1);y.useEffect(()=>{H8(_.current,t)&&(_.current=!0,g.current=$u(e))},[t]),y.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!V8(j.current,t))return;const R=typeof document>"u"||!document.hidden,T=U8(e,g.current,R,c);for(const A of T)try{const U=new Notification(A.title,{body:A.body,tag:A.key,icon:tle});U.onclick=()=>{window.focus(),n(A.sessionId),U.close()}}catch{}g.current=R?$u(e):z8(e,T,g.current)},[b,t]);const E=y.useCallback(R=>{var T;d(((T=R.prefs)==null?void 0:T.notifications)===!0),f(R.notificationsVetoed===!0)},[]);return{notifyPermission:r,notifySaid:o,notifyOn:c,notifyVetoed:h,toggleNotify:N,notifySupported:k,askForNotifications:x,loadNotifyPrefs:E}}function rle({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:r,summaryFor:s,browserWatchOpen:o,keyHelpOpen:l,releaseNotes:c,feedbackOpen:d}){const h=_n(l),f=y.useRef(!1);return f.current=e!=null||t||n!=null||r||s!=null||o||l||c!=null||d,{keyHelpOpenRef:h,modalOpenRef:f}}function sle({stateRef:e,tourOpen:t,releaseNotes:n}){const[r,s]=y.useState(null),o=y.useCallback((F,O)=>s({agentId:F,toolId:O}),[]),[l,c]=y.useState(null),[d,h]=y.useState(null),f=y.useCallback(F=>h(F),[]),[p,g]=y.useState(!1),[v,N]=y.useState(!1),[k,x]=y.useState(!1),[j,b]=y.useState(!1),[_,E]=y.useState(null),R=y.useCallback(F=>{E(F??null),b(!0)},[]);qt("tool-detail",r!==null),qt("session-summary",l!==null),qt("context-window",d!==null),qt("keyboard-help",p),qt("usage-history",v),qt("browser-watch",k),qt("feedback",j);const T=r?Wq(e.current.agents,r.agentId,r.toolId):null,A=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:U,modalOpenRef:L}=rle({openedTool:T,usageHistoryOpen:v,contextFor:d,tourOpen:t,summaryFor:l,browserWatchOpen:k,keyHelpOpen:p,releaseNotes:n,feedbackOpen:j});return{setOpenedToolKey:s,openTool:o,openedTool:T,summaryFor:l,setSummaryFor:c,contextFor:d,setContextFor:h,openContext:f,contextAgent:A,keyHelpOpen:p,setKeyHelpOpen:g,usageHistoryOpen:v,setUsageHistoryOpen:N,browserWatchOpen:k,setBrowserWatchOpen:x,feedbackOpen:j,setFeedbackOpen:b,feedbackPrefill:_,setFeedbackPrefill:E,openFeedback:R,keyHelpOpenRef:U,modalOpenRef:L}}function ale({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:r,lastLayoutSigRef:s,forgetRemovals:o,clearSelection:l,rerender:c,modalOpenRef:d}){const[h,f]=y.useState(!1),p=y.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=Gb(),t.current.clear(),n.current.clear(),r.current.clear(),s.current="",AL(),o(),l(),c()},[c,l,o]),g=_n(h),v=y.useCallback(N=>{const k=Ese(N,{confirmOpen:g.current,modalOpen:d.current});k==="confirm"?f(!0):k==="clear"&&(f(!1),p())},[p]);return{clearConfirmOpen:h,setClearConfirmOpen:f,requestClear:v}}const p2="agent-dag.oldNameNoticeDismissed";function ole(e){const[t,n]=y.useState(()=>Qe(p2)??""),r=e!=null&&e.invokedAs&&e.invokedAs!==kt?e.invokedAs:null,s=r!=null&&t!==r,o=y.useCallback(()=>{r&&(n(r),Ze(p2,r))},[r]);return{oldName:r,oldNameOpen:s,dismissOldName:o}}const ile=300*1e3,lle=1800*1e3,cle=8e3,ule=3e4;function m2(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function dle({modalOpenRef:e}){const t=y.useCallback(()=>w$({appModal:e.current,dialogDepth:ds.dialogDepth()}),[e]),[n,r]=y.useState("hidden"),[s,o]=y.useState(null),[l,c]=y.useState(!1),d=y.useRef(n);d.current=n,y.useEffect(()=>{let v=!1;const N=async()=>{if(d.current==="thanks"||d.current==="hidden"&&(document.hidden||t()))return;const j=await fetch("/api/rating").then(b=>b.ok?b.json():null).catch(()=>null);v||!j||r(b=>b==="thanks"?b:j.ask===!0?"asking":"hidden")},k=window.setTimeout(N,ile),x=window.setInterval(N,lle);return()=>{v=!0,window.clearTimeout(k),window.clearInterval(x)}},[t]),y.useEffect(()=>{if(n!=="thanks"||l)return;const v=s!==null&&s<=6?ule:cle;let N=0;const k=()=>{t()?N=window.setTimeout(k,v):r("hidden")};return N=window.setTimeout(k,v),()=>window.clearTimeout(N)},[n,s,l,t]);const h=y.useCallback(v=>{o(v),c(!1),r("thanks"),m2({score:v})},[]),f=y.useCallback(v=>c(v),[]),p=y.useCallback(()=>{r("hidden"),m2({later:!0})},[]),g=y.useCallback(()=>r("hidden"),[]);return{ratingPhase:n,ratingScore:s,answerRating:h,rateLater:p,closeRating:g,holdThanks:f}}function hle({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:r}){const[s,o]=y.useState(()=>KX(Qe)),l=_n(s),[c,d]=y.useState([]),h=y.useCallback(b=>{o(_=>{const E={..._,[b]:null};return l.current=E,E}),hs(Il[b])},[]),f=y.useCallback((b,_)=>{const E=l.current[b];_&&E!==_||(h(b),t(R=>{const T={...R,[b]:{...R[b],figure:jn}};return n.current=T,T}),Ze(Md[b],jn))},[h]),p=_n(f);y.useEffect(()=>{let b=!0;return aZ().then(_=>{if(!b)return;d(_);const E=new Set(_.map(R=>R.id));for(const R of rd){const T=l.current[R];T&&!E.has(T)&&p.current(R,T)}},()=>{}),()=>{b=!1}},[]);const g=y.useCallback((b,_)=>{if(!c.some(R=>R.id===_))return;const E={...l.current,[b]:_};l.current=E,o(E),Ze(Il[b],_),r(b,!0)},[c,r]),v=y.useCallback(async b=>{var T;const _=lb(c.length);if(_)throw new Error(_);const E=window.AudioContext??window.webkitAudioContext;if(!E)throw new Error("This browser cannot decode audio files.");const R=new E;try{const A=await eZ(b,L=>R.decodeAudioData(L));await o_(A);const U=ec(A);d(L=>[...L.filter(F=>F.id!==U.id),U])}finally{(T=R.close)==null||T.call(R)}},[c.length]),N=y.useCallback(async b=>{const _=lb(c.length);if(_)throw new Error(_);const E=tZ(b);await o_(E);const R=ec(E);d(T=>[...T.filter(A=>A.id!==R.id),R])},[c.length]),k=y.useCallback(async(b,_)=>{const E=c.find(T=>T.id===b),R=_.trim().slice(0,80);!E||!R||R===E.name||(await iZ(b,R),d(T=>T.map(A=>A.id===b?{...A,name:R}:A)))},[c]),x=y.useCallback(async b=>{await lZ(b),d(T=>T.filter(A=>A.id!==b));const _=l.current,E=YX(_,b);l.current=E,o(E);const R=rd.filter(T=>_[T]===b);for(const T of R)hs(Il[T]),Ze(Md[T],jn);R.length>0&&t(T=>{const A={...T};for(const U of R)A[U]={...A[U],figure:jn};return n.current=A,A})},[]),j=y.useCallback(b=>{var R,T;const _=rd.find(A=>l.current[A]===b),E=_?n.current[_].level:Qa;(R=e.current)==null||R.unlock(),(T=e.current)==null||T.previewCustom(b,E)},[]);return{customSelections:s,customSelectionsRef:l,customAssets:c,clearCustomOnly:h,fallbackCustomRef:p,selectCustomTone:g,importNotificationAudio:v,createNotificationVoice:N,renameCustomAsset:k,deleteCustomAsset:x,previewCustomAsset:j}}function fle(e){const[t,n]=y.useState(()=>xZ(Qe)),r=_n(t),s=y.useRef(null),o=y.useCallback((c,d=!1)=>{var h,f;if((h=e.current)==null||h.unlock(),s.current!==null&&clearTimeout(s.current),s.current=null,!d){(f=e.current)==null||f.play(c,!0);return}s.current=setTimeout(()=>{var p;s.current=null,(p=e.current)==null||p.play(c,!0)},mZ)},[]),l=y.useCallback((c,d)=>{n(h=>{const f={level:vi(d.level??h[c].level),figure:fO(c,d.figure??h[c].figure)};return Ze(gO[c],String(f.level)),Ze(Md[c],f.figure),{...h,[c]:f}}),o(c,!0)},[o]);return y.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:r,previewTone:o,changeTone:l}}const ple=15e3;function mle(e){return e.visibilityState==="visible"&&e.hasFocus()}function gle(e,t){return t||e===!0}function yle(){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)}`}function wle(){y.useEffect(()=>{const e=yle();let t=null;const n=l=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:e,looking:l}),keepalive:!0}).catch(()=>{})},r=()=>{const l=mle(document);gle(t,l)&&n(l),t=l},s=()=>{t&&n(!1),t=!1};r();const o=window.setInterval(r,ple);return window.addEventListener("focus",r),window.addEventListener("blur",r),document.addEventListener("visibilitychange",r),window.addEventListener("pagehide",s),()=>{window.clearInterval(o),window.removeEventListener("focus",r),window.removeEventListener("blur",r),document.removeEventListener("visibilitychange",r),window.removeEventListener("pagehide",s),s()}},[])}function vle({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n}){y.useEffect(()=>{let r=!0;return fetch("/api/prefs").then(s=>s.ok?s.json():null).then(s=>{!r||!(s!=null&&s.ok)||(e(s),t(s),n(s))}).catch(()=>{}),()=>{r=!1}},[])}const fx="agent-dag.versionNoticeDismissed",xle=15*6e4;function ble(e){const[t,n]=y.useState(null),[r,s]=y.useState(()=>Qe(fx)??""),o=y.useRef(0),[l,c]=y.useState(!1),d=y.useCallback((k=!1)=>(k&&(o.current=Date.now(),c(!0)),fetch(k?"/api/version?refresh=1":"/api/version").then(x=>x.ok?x.json():null).then(x=>{x&&n(x)}).catch(()=>{}).finally(()=>{k&&c(!1)})),[]),h=y.useCallback(()=>{d(Date.now()-o.current>=xle)},[d]);y.useEffect(()=>{d();const k=window.setInterval(h,5*6e4),x=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",x),()=>{window.clearInterval(k),document.removeEventListener("visibilitychange",x)}},[d,h]),y.useEffect(()=>{e&&d()},[e,d]);const f=(t==null?void 0:t.notice)??null,p=UL(f),g=Yre(f,r),v=y.useCallback(()=>{s(""),Ze(fx,"")},[]),N=y.useCallback(()=>{f&&(s(p),Ze(fx,p))},[f,p]);return{version:t,notice:f,noticeOpen:g,showNotice:v,dismissNotice:N,versionChecking:l,loadVersion:d}}function kle({version:e,readyAppUpdate:t}){const[n,r]=y.useState(!1),s=y.useRef(null),[o,l]=y.useState(null),c=o&&t?t.version:null,d=y.useRef(null);y.useEffect(()=>{!c||d.current===c||(d.current=c,fetch("/api/desktop-update/seen",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:c})}).catch(()=>{}))},[c]);const h=y.useRef(!1);y.useEffect(()=>{if(h.current)return;const x=Ml(),j=xoe(x),b=_oe({stored:j,running:(e==null?void 0:e.running)??null,notes:t2,remembers:boe(x)});if(b.reason==="no-version")return;h.current=!0,b.record&&koe(x,b.record);let _=!0;return(async()=>{var U;let R=Noe(x);if(sc())try{const L=await fetch("/api/prefs");if(!L.ok)throw new Error("desktop tour preferences unavailable");const F=await L.json();if(!(F!=null&&F.ok))throw new Error("desktop tour preferences unavailable");const O=((U=F.prefs)==null?void 0:U.tourSeen)===!0;R&&!O&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),R=R||O}catch{R=!0}if(!_)return;const T=Soe({tourSeen:R,decision:b}),A=b.show.length?{entries:b.show,since:j,firstRun:!1}:null;T.tour&&r(!0),T.notes==="now"?l(A):T.notes==="after"&&(s.current=A)})(),()=>{_=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.37.0",p=y.useMemo(()=>rP(t2,null,f),[f]),g=y.useCallback(()=>{l({entries:p,since:null,firstRun:!1})},[p]),v=y.useCallback(()=>r(!0),[]),N=y.useCallback(()=>l(null),[]),k=y.useCallback(()=>{r(!1),joe(Ml()),sc()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const x=s.current;s.current=null,x&&l(x)},[]);return{tourOpen:n,openTour:v,closeTour:k,releaseNotes:o,closeReleaseNotes:N,chipVersion:f,openReleaseNotes:g}}function Nle(){const[e,t]=y.useState(void 0),[n,r]=y.useState(!1),s=y.useRef(!1);return s.current=e===!0&&!n,y.useEffect(()=>Xoe(()=>s.current),[]),{loadReportsPrefs:y.useCallback(l=>{var c;t(((c=l.prefs)==null?void 0:c.reports)!==!1),r(l.reportsVetoed===!0)},[])}}function jle(){const[e,t]=y.useState(null),[n,r]=y.useState(!1),s=y.useRef(null);return y.useEffect(()=>{let o=!0,l=!1,c=null,d=null,h="";const f=k=>{o&&(r(!0),k!==h&&t(null))},p=()=>{if(l)return;l=!0,c=Date.now();const k=UR();d=k,fetch(`/api/ccusage?since=${k}`).then(x=>x.ok?x.json():null).then(x=>{if(o){if(!(x!=null&&x.ok)){f(k);return}h=k,t(Pre(x)),r(!1)}}).catch(()=>f(k)).finally(()=>{l=!1})},g=()=>{const k=s.current;Lre({shown:!!k&&k.getClientRects().length>0,tabVisible:document.visibilityState==="visible",lastSince:d,since:UR(),lastReadAt:c,now:Date.now()})&&p()};g();const v=window.setInterval(g,Ore);document.addEventListener("visibilitychange",g);let N=null;return s.current&&typeof ResizeObserver<"u"&&(N=new ResizeObserver(g),N.observe(s.current)),()=>{o=!1,window.clearInterval(v),document.removeEventListener("visibilitychange",g),N==null||N.disconnect()}},[]),{monthlyUsage:e,monthlyUsageUnavailable:n,monthUsageRef:s}}function Sle(e){const[t,n]=y.useState(null);y.useEffect(()=>{const c=Qe("agent-dag.sound");n(c===null?!0:c==="on")},[]);const r=y.useCallback(()=>{n(c=>{var h,f;const d=c!==!0;return Ze("agent-dag.sound",d?"on":"off"),d?(h=e.current)==null||h.unlock():(f=e.current)==null||f.silence(),d})},[]),s=y.useCallback(c=>{r()},[r]),o=_n(s),l=_n(t);return{soundOn:t,toggleSound:r,activateSoundRef:o,soundOnRef:l}}function _le(){const[e,t]=y.useState(!1),n=y.useRef(null),[r,s]=y.useState(!1),o=y.useRef(null);return y.useEffect(()=>{e&&s(!1)},[e]),{soundMenuOpen:e,setSoundMenuOpen:t,soundButtonRef:n,appearanceMenuOpen:r,setAppearanceMenuOpen:s,appearanceButtonRef:o}}const Ele="agent-dag.autoFitDisabled";function Cle(e){const t=y.useRef(!1),[n,r]=y.useState(!1);y.useEffect(()=>{hs(Ele)},[]);const s=y.useCallback(()=>{t.current||(t.current=!0,r(!0))},[]),o=y.useCallback(()=>{t.current=!1,r(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:s,enableAutoFitAndRefit:o}}function Tle(){return a.jsx(Wb,{children:a.jsx(Qoe,{children:a.jsx(Ale,{})})})}function Ale(){const e=ki(),t=y.useState(Gb)[0],n=y.useRef(t),[,r]=y.useState(0),s=y.useCallback(()=>r(ba=>ba+1),[]),{detailOpen:o,setDetailOpen:l,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f}=Xie(),{selectedIds:p,primarySelectedId:g,selectAgent:v,clearSelection:N,pruneSelectionToBoard:k}=DZ(n,l),{sessionListOpen:x,accountsPanelOpen:j,toggleSessionList:b,toggleAccountsPanel:_,closeSessionList:E,closeAccountsPanel:R}=zie(),T=jle(),A=Qu(j,200),U=Qu(c,130),L=Qu(h,130),F=y.useRef(null),O=Sle(F),{activateSoundRef:I,soundOnRef:B}=O,M=fle(F),{setTonePrefs:$,tonePrefsRef:P,previewTone:G}=M,K=hle({chimesRef:F,setTonePrefs:$,tonePrefsRef:P,previewTone:G}),{customSelectionsRef:q,fallbackCustomRef:H}=K,D=_le(),{setSoundMenuOpen:W}=D,{chimeState:J}=$ie({chimesRef:F,soundOnRef:B,tonePrefsRef:P,customSelectionsRef:q,fallbackCustomRef:H}),V=nie(n),{pauseGate:X,paused:Y,togglePause:Z}=V,ee=y.useRef(()=>{}),{live:ne,tabCapped:se,everConnected:pe,liveSince:ke}=CZ({stateRef:n,rerender:s,pauseGate:X,chimesRef:F,desktopUpdateRef:ee}),ae=ble(ne),{version:fe,notice:me,noticeOpen:he,loadVersion:ge}=ae,ue=Oie(ne),{readyAppUpdate:be,onDesktopUpdateEvent:oe}=ue;ee.current=oe,wle();const je=kle({version:fe,readyAppUpdate:be}),{tourOpen:$e,openTour:Oe,releaseNotes:Ue}=je,{workspace:Be,providers:We,providersRef:He}=sie(ne),rt=ole(fe),lt=kie({version:fe,loadVersion:ge}),{upgradeFailure:Rt}=lt,De=sle({stateRef:n,tourOpen:$e,releaseNotes:Ue}),et=dle({modalOpenRef:De.modalOpenRef}),{openTool:Je,setSummaryFor:tt,setContextFor:yt,openContext:Pt,setKeyHelpOpen:wt,setUsageHistoryOpen:st,setBrowserWatchOpen:zt,keyHelpOpenRef:Wt,modalOpenRef:Dt}=De,Ht=Nle(),Vt=jie(),{watchOn:vs,watchUnseen:Tn}=Vt,mr=Pie(),[zr,gr]=y.useState(0),{presentCats:Wr,hiddenCats:mn,toggleCat:Hr,catBarRef:An,catBarOccluded:da}=Rie(n),gn=y.useRef(null),[yr,wr]=y.useState(0),xt=FZ({stateRef:n,rerender:s,pruneSelectionToBoard:k,setContextFor:yt,setSummaryFor:tt}),xs=lie(We.claude||We.codex),vr=vie(xs,xt),xr=Fie({enabled:We.claude,lanStatus:mr.lanStatus,now:xt}),Gt=Lie({now:xt,stateRef:n,version:fe,notice:me,noticeOpen:he,upgradeFailure:Rt,paused:V.paused}),{askRestart:bs,loadAutoRestartPrefs:Vr}=Gt,ye=Aie(),{setTheme:Fe,palette:Ge}=ye,rn=Iie(),Gr=Pte(),{applyViewport:br,moveCamera:ha,fitLeft:Ke,cameraEpochRef:Kr,lastFitTimeRef:ks}=Gr,kr=Yte(Ke),{pinnedRef:Kn,positionsRef:Yr,lastLayoutSigRef:ao,handleRelayout:Ns}=kr,Jt=y.useRef(null),js=y.useRef(()=>{}),yn=ke!==null,vc=y.useRef(0),xc=y.useCallback(()=>{vc.current=Date.now()},[]),{canvasRef:Nr,canvasSize:oo,paneSizeRef:io}=Ene(),Ss=Cle(Ke),{autoFitDisabledRef:fa,disableAutoFit:Mi}=Ss,$i=y.useRef(!1),{measuredRef:Yn,measuredVersionRef:bc,sizeVersion:Ii,domSizeVersion:pa}=Cne($i),{removedNodes:kc,removedAgentIds:jr,removeNode:Ye,removeSelectedNode:Oi,removalNotice:Li,bringBack:ma,bringBackAll:Nc,forgetRemovals:jc}=gne({stateRef:n,pinnedRef:Kn,positionsRef:Yr,canvasRef:Nr,clearSelection:N,primarySelectedId:g}),lo=dne({stateRef:n,now:xt,removedAgentIds:jr,sizeVersion:Ii,domSizeVersion:pa});Xte(lo,kr),mne({layoutSig:lo,rf:e,stateRef:n,measuredRef:Yn,pinnedRef:Kn,positionsRef:Yr,paneSizeRef:io,lastInteractRef:vc,autoFitDisabledRef:fa,lastFitTimeRef:ks,fitLeft:Ke});const co=Tne(),{bubbling:uo,endBubble:Sr,onBubble:_r}=MX(),[Rn,ga]=y.useState(!1),_s=AX(),{beginTrashDrag:Er,trackTrashDrag:Ih,endTrashDrag:Sc}=_s,Es=qX({stateRef:n,measuredRef:Yn,measuredVersionRef:bc,canvasRef:Nr}),{lodRef:Oh,applyZoom:_c}=Es,ya=Sne({applyViewport:br,lastFitTimeRef:ks,cameraEpochRef:Kr,disableAutoFit:Mi,markInteract:xc,canvasRef:Nr,applyZoom:_c}),Cs=g?n.current.agents.get(g):null,Pi=o&&Cs!=null,wn=$ne({sessionListShown:x,usageShown:La(U),machineShown:La(L),accountsShown:La(A)&&We.claude,detailShown:Pi,primarySelectedId:g,canvasRef:Nr}),{railInsetRef:Ts,availableWidth:Xr,availableHeight:wa}=Lte({canvasRef:Nr,canvasSize:oo,machinePhase:L,usagePhase:U,usagePanelOpen:c,detailShown:Pi}),Ec=hne({stateRef:n,now:xt,availableWidth:Xr,availableHeight:wa,layout:kr,measuredRef:Yn,onBubble:_r,settled:co,dragging:Rn,layoutSig:lo,selectedIds:p,openContext:Pt,historyReplayed:yn,removedNodes:kc,removedAgentIds:jr,dragTick:zr,dragPatchRef:gn,dragMoveTick:yr}),{nodes:Di,edges:Fi}=Ec,As=_n(g);Zte({nodes:Di,edges:Fi,settled:co,dragging:Rn,availableWidth:Xr,availableHeight:wa,layout:kr,camera:Gr,rf:e,measuredRef:Yn,stateRef:n,lastFocusRef:Jt,primarySelectedIdRef:As,focusAgentRef:js,autoFitDisabledRef:fa});const ho=ale({stateRef:n,pinnedRef:Kn,measuredRef:Yn,positionsRef:Yr,lastLayoutSigRef:ao,forgetRemovals:jc,clearSelection:N,rerender:s,modalOpenRef:Dt}),{requestClear:Bi}=ho,Cr=Ine({nodes:Di,stateRef:n,pinnedRef:Kn,positionsRef:Yr,draggingRef:$i,dragPatchRef:gn,setDragging:ga,setDragMoveTick:wr,setDragTick:gr,endBubble:Sr,markInteract:xc,disableAutoFit:Mi,beginTrashDrag:Er,trackTrashDrag:Ih,endTrashDrag:Sc,removeNode:Ye}),qi=y.useCallback(()=>Ke(500),[Ke]),Rs=_n(Di),{focusAgent:va,stepAgent:fo,focusSession:Tr}=Fte({canvasRef:Nr,stateRef:n,measuredRef:Yn,nodesRef:Rs,railInsetRef:Ts,moveCamera:ha,disableAutoFit:Mi,lastFocusRef:Jt,focusAgentRef:js,selectAgent:v,primarySelectedIdRef:As}),Cc=_ne({clearSelection:N,selectAgent:v,detailOpen:o,setDetailOpen:l,detailShown:Pi,focusAgent:va,draggingRef:$i,lodRef:Oh}),Qt=Bte({nodesRef:Rs,stateRef:n,canvasRef:Nr,railInsetRef:Ts}),Ms=_n(Oi),po=y.useRef(null),xa=y.useCallback(ba=>{jr.has(ba)&&ma([ba]),Tr(ba)},[jr,ma,Tr]),Lh=Ane();Rne({pointerFocusRef:Lh,nodesRef:Rs,stateRef:n,primarySelectedIdRef:As,providersRef:He,soundOnRef:B,keyHelpOpenRef:Wt,modalOpenRef:Dt,waitingCursorRef:po,removeSelectedRef:Ms,activateSoundRef:I,clearSelection:N,selectAgent:v,focusAgent:va,stepAgent:fo,focusSession:Tr,requestClear:Bi,handleRelayout:Ns,handleFit:qi,togglePause:Z,toggleSessionList:b,toggleAccountsPanel:_,setDetailOpen:l,setUsageHistoryOpen:st,setUsagePanelOpen:d,setMachinePanelOpen:f,setBrowserWatchOpen:zt,setSoundMenuOpen:W,setKeyHelpOpen:wt,setTheme:Fe});const mo=n.current.agents.size,Zr=y.useMemo(()=>Mx(n.current.agents.values()),[n.current,n.current.revision]);yne({stateRef:n,waitingSessions:Zr,removedAgentIds:jr,removedNodes:kc,bringBack:ma}),kne({stateRef:n,waitingSessions:Zr,live:ne});const $s=ele({waitingSessions:Zr,watchUnseen:Tn,incidents:vr}),Is=nle({waitingSessions:Zr,liveSince:ke,focusSession:Tr}),{loadNotifyPrefs:Tc}=Is;return vle({loadAutoRestartPrefs:Vr,loadNotifyPrefs:Tc,loadReportsPrefs:Ht.loadReportsPrefs}),a.jsxs("div",{className:"app",children:[a.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),a.jsxs("header",{className:"topbar",children:[a.jsx(tse,{versionCheck:ae,welcome:je,desktopUpdate:ue,pause:V,monthly:T,announcements:$s,notify:Is,waitingSessions:Zr,waitingCursorRef:po,focusSession:Tr,live:ne,now:xt,incidents:vr}),Cs&&a.jsx(nse,{selected:Cs,now:xt,selectedIds:p,focusAgent:va,clearSelection:N}),a.jsxs("div",{className:"actions",children:[a.jsx(Rre,{sessionListOpen:x,toggleSessionList:b,usagePanelOpen:c,setUsagePanelOpen:d,setUsageHistoryOpen:st,toggles:wn.toggles}),a.jsx(Mre,{providers:We,accountsPanelOpen:j,toggleAccountsPanel:_,machinePanelOpen:h,setMachinePanelOpen:f,watchOn:vs,watchUnseen:Tn,setBrowserWatchOpen:zt,toggles:wn.toggles}),a.jsx($re,{providers:We,sound:O,tones:M,customTones:K,notify:Is,chimeState:J,menus:D,appearance:ye,fm:rn,onFeedback:()=>De.openFeedback(),watchUnseen:Tn,setUsageHistoryOpen:st,setBrowserWatchOpen:zt})]})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Li?`${Li.label} removed from the board.`:""}),a.jsx(_se,{restart:Gt,versionCheck:ae,upgrade:lt,oldNameNotice:rt,rating:et,onFeedback:De.openFeedback,everConnected:pe,live:ne,paused:Y}),La(A)&&We.claude&&a.jsx(NX,{leaving:A==="leaving",onReport:De.openFeedback,onRoster:xr.observe,onClose:()=>{wn.accounts(),R()}}),x&&a.jsx(MH,{state:n.current,now:xt,selectedIds:p,onSelect:xa,onClose:()=>{wn.sessionList(),E()},removedIds:jr,onBringBackAll:Nc}),a.jsxs(ise,{canvasRef:Nr,bubbling:uo,dragging:Rn,trash:_s,zoom:Es,viewport:ya,stateRef:n,peek:Qt,children:[mo===0&&(!ne&&se?a.jsx(Une,{}):a.jsx(zne,{live:ne,everConnected:pe,providers:We,workspace:Be,onTour:Oe})),(Wr.length>1||mn.size>0)&&a.jsx(rse,{catBarRef:An,catBarOccluded:da,presentCats:Wr,hiddenCats:mn,toggleCat:Hr}),a.jsx(xH,{graph:Ec,layout:kr,viewport:ya,clicks:Cc,drag:Cr,appearance:ye,fm:rn,autoFit:Ss,pause:V,stateRef:n,measuredRef:Yn,hiddenCats:mn,now:xt,openTool:Je,focusAgent:va,requestClear:Bi,setKeyHelpOpen:wt})]}),La(U)&&a.jsx(_7,{state:n.current,now:xt,providers:We,incidents:vr,liveSince:ke,leaving:U==="leaving",onClose:()=>{wn.usage(),d(!1)}}),La(L)&&a.jsx(u9,{usageOpen:c,leaving:L==="leaving",onClose:()=>{wn.machine(),f(!1)}}),o&&Cs?a.jsx(nre,{selected:Cs,now:xt,openTool:Je,setSummaryFor:tt,stateRef:n,removeSelectedNode:Oi,onClose:()=>{wn.detail(),l(!1)}}):null,a.jsx(Ooe,{dialogs:De,welcome:je,desktopUpdate:ue,versionCheck:ae,restart:Gt,lanPairs:mr,attention:xr,clearFlow:ho,watchBadge:Vt,announcements:$s,appearance:ye,providers:We,stateRef:n,agentCount:mo})]})}try{jU(window.localStorage)}catch{}const Rle=Q3.createRoot(document.getElementById("root"));Rle.render(a.jsx(Tle,{}));export{Pne as a,it as b,oa as c,gt as d,is as e,qe as f,Ile as g,Dr as h,$le as i,a as j,Jl as k,Cn as l,JX as m,ea as n,eo as o,Wx as p,y as r,lr as s,ut as u};
|
|
306
|
+
`)}}function vie(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>wie(n,t)).filter(n=>n!==null)}function xie(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const bie="The providers' status pages report no incident.";function kie({version:e,loadVersion:t}){var h;const[n,r]=y.useState(!1),s=((h=e==null?void 0:e.upgrade)==null?void 0:h.state)??"idle",o=vse(e==null?void 0:e.upgrade),l=y.useRef(!1),c=y.useCallback(async()=>{if(lr(l.current||s==="running")){l.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),l.current=!1}},[s,t]);y.useEffect(()=>{if(s!=="running")return;const f=window.setInterval(t,3e3);return()=>window.clearInterval(f)},[s,t]);const d=y.useCallback(async()=>{const f=e==null?void 0:e.command;!f||!await eo(f)||(r(!0),window.setTimeout(()=>r(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:s,upgradeFailure:o,startUpgrade:c,copyCommand:d,cmdCopied:n}}const u2="agent-dag.browserWatch.seenMs";function Nie(e,t){return e.filter(n=>n.startMs>t)}function jie(){const[e,t]=y.useState(()=>Number(Qe(u2))||0),[n,r]=y.useState([]),[s,o]=y.useState(!1);y.useEffect(()=>{let d=!0;const h=()=>{fetch("/api/browser-watch?live=0").then(p=>p.ok?p.json():null).then(p=>{var g;!d||!(p!=null&&p.ok)||(r(p.episodes??[]),o(((g=p.settings)==null?void 0:g.enabled)===!0))}).catch(()=>{})};h();const f=setInterval(h,5*6e4);return()=>{d=!1,clearInterval(f)}},[]);const l=y.useMemo(()=>Nie(n,e).length,[n,e]),c=y.useCallback(d=>{t(d),Ze(u2,String(d))},[]);return{watchOn:s,setWatchOn:o,watchUnseen:l,markWatchSeen:c}}const hP=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function d2(e){const t={};for(const n of hP)t[n]=e(n);return t}function Sie(e){return t=>e[t]??""}function _ie(e,t){return hP.every(n=>e[n]===t[n])}const fP="agent-dag.theme";function Eie(e,t=!1){return e==="light"||e==="dark"?e:t?"light":"dark"}function Cie(){try{return window.matchMedia("(prefers-color-scheme: light)").matches}catch{return!1}}function Tie(){return Eie(Qe(fP),Cie())}function h2(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function Aie(){const[e,t]=y.useState(Tie),[n,r]=y.useState(ore),[s,o]=y.useState(()=>d2(h2)),l=y.useMemo(()=>Sie(s),[s]),c=y.useCallback(d=>ine(d,l),[l]);return y.useEffect(()=>{document.documentElement.dataset.theme=e,Ze(fP,e),o(d=>{const h=d2(h2);return _ie(d,h)?d:h})},[e]),y.useEffect(()=>{Ze(FL,n?"1":"0")},[n]),y.useEffect(()=>{const d=document.querySelector('meta[name="theme-color"]'),h=s["--panel"];d&&h&&d.setAttribute("content",h)},[s]),{theme:e,setTheme:t,characterEnabled:n,setCharacterEnabled:r,palette:s,minimapNodeFill:c}}function Rie(e){const t=y.useRef(null),[n,r]=y.useState(!1),[s,o]=y.useState(()=>new Set),l=y.useMemo(()=>{const d=new Set;for(const h of e.current.agents.values())for(const f of h.tools)d.add(PL(f.name));return Object.keys(LL).filter(h=>d.has(h))},[e.current,e.current.revision]);y.useEffect(()=>{if(l.length<=1){r(!1);return}let d=0;const h=()=>{const f=t.current;if(f&&!document.hidden){const p=f.getBoundingClientRect(),g=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(N=>N.getBoundingClientRect()),v=AH(p,g,8);r(N=>N===v?N:v)}d=window.setTimeout(h,300)};return h(),()=>window.clearTimeout(d)},[l.length]);const c=y.useCallback(d=>{o(h=>{const f=new Set(h);return f.has(d)?f.delete(d):f.add(d),f})},[]);return{presentCats:l,hiddenCats:s,toggleCat:c,catBarRef:t,catBarOccluded:n}}function Mie(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const r=new Set,s=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",o=()=>{var g;return(g=e.onState)==null?void 0:g.call(e,s())};function l(){var g,v;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(g=n.addEventListener)==null||g.call(n,"statechange",o)),(v=n.resume)==null||v.call(n).then(o,()=>{}),o()}catch{}}function c(g,v,N=v.figure){if(!n||n.state!=="running")return!1;const k=cb(g,N),x=dZ(v.level,k),j=n.currentTime;for(const b of k.notes){const _=n.createOscillator(),E=n.createGain();_.type=k.type??"sine",_.frequency.value=b.hz;const R=j+b.at,T=R+b.ms/1e3;E.gain.setValueAtTime(l_,R),E.gain.exponentialRampToValueAtTime(x,R+hZ),E.gain.exponentialRampToValueAtTime(l_,T),_.connect(E).connect(n.destination),_.start(R),_.stop(T+.02)}return!0}async function d(g,v){var x;if(!e.loadCustom)return"unavailable";let N;try{N=await e.loadCustom(g)}catch{return"unavailable"}if(!N)return"missing";if(N.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const j=new SpeechSynthesisUtterance(N.text),b=window.speechSynthesis.getVoices();j.voice=b.find(_=>_.voiceURI===N.voiceURI)??null,j.rate=N.rate,j.pitch=N.pitch,j.volume=fZ(v.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(j),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let k;try{k=await n.decodeAudioData(N.bytes.slice(0))}catch{return"broken"}try{const j=n.createBufferSource(),b=n.createGain();return j.buffer=k,b.gain.setValueAtTime(pZ(N.normalizationGain,v.level),n.currentTime),j.connect(b).connect(n.destination),r.add(j),(x=j.addEventListener)==null||x.call(j,"ended",()=>r.delete(j)),j.start(n.currentTime),"played"}catch{return"unavailable"}}function h(g,v=!1){var x,j;if(!v&&!e.enabled())return!1;const N=bZ((x=e.prefs)==null?void 0:x.call(e),g),k=((j=e.customSelection)==null?void 0:j.call(e)[g])??null;return k&&e.loadCustom?(d(k,N).then(b=>{var _;b==="played"||b==="locked"||((b==="missing"||b==="broken")&&((_=e.onCustomFailure)==null||_.call(e,g,k)),c(g,{...N,figure:jn},jn))}),!0):!n||n.state!=="running"?!1:c(g,N)}function f(g,v=Qa){return d(g,{level:vi(v),figure:jn}),!0}function p(){try{typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}catch{}for(const g of r)try{g.stop()}catch{}r.clear()}return{unlock:l,play:h,previewCustom:f,silence:p,state:s,get context(){return n}}}function $ie({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:r,fallbackCustomRef:s}){const[o,l]=y.useState("locked");return y.useEffect(()=>{const c=Mie({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>r.current,loadCustom:oZ,onCustomFailure:(p,g)=>s.current(p,g),onState:l});e.current=c,l(c.state());const d=["pointerdown","pointerup","keydown"],h=()=>{for(const p of d)window.removeEventListener(p,f,{capture:!0})},f=()=>{var p;c.unlock(),((p=c.context)==null?void 0:p.state)==="running"&&h()};for(const p of d)window.addEventListener(p,f,{capture:!0});return h},[]),{chimeState:o}}function Iie(){const[e,t]=y.useState(lre),[n,r]=y.useState(()=>lq(Qe(dj))),[s,o]=y.useState(()=>iq(Qe(hj))),[l,c]=y.useState(()=>cq(Qe(PR),n,sre)),[d,h]=y.useState(()=>new Set),[f,p]=y.useState(0);y.useEffect(()=>{Ze(BL,String(e))},[e]),y.useEffect(()=>{Ze(hj,s?"1":"0")},[s]),y.useEffect(()=>{Ze(dj,JSON.stringify(n))},[n]),y.useEffect(()=>{Ze(PR,l)},[l]);const g=y.useCallback(j=>{r(b=>b.some(_=>_.id===j.id)?b:[...b,j]),h(b=>{if(!b.has(j.id))return b;const _=new Set(b);return _.delete(j.id),_})},[]),v=y.useCallback((j,b)=>{const _=b.trim();!_||_.length>zl||r(E=>E.map(R=>R.id===j?{...R,name:_}:R))},[]),N=y.useCallback(j=>{r(b=>b.filter(_=>_.id!==j)),c(b=>uq(b,j)),h(b=>{if(!b.has(j))return b;const _=new Set(b);return _.delete(j),_})},[]),k=y.useCallback(j=>{const b=fj(j),_=d.has(b);j===l&&!_||(_&&h(E=>{const R=new Set(E);return R.delete(b),R}),c(j),p(E=>E+1))},[l,d]),x=y.useCallback((j,b)=>{const _=fj(j);h(E=>{if(E.has(_)===b)return E;const T=new Set(E);return b?T.add(_):T.delete(_),T})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:s,setFmMuted:o,fmSource:l,customFmStations:n,unavailableFmStations:d,fmPlayRequest:f,addFmStation:g,renameFmStation:v,removeFmStation:N,pickFmSource:k,markFmStationAvailability:x}}function Oie(e){const[t,n]=y.useState(null),[r,s]=y.useState(!1),[o,l]=y.useState(null),c=y.useRef(0);y.useEffect(()=>{if(!e||!sc())return;let N=!1;const k=c.current;return fetch("/api/desktop-update").then(x=>x.ok?x.json():null).then(x=>{if(N||c.current!==k)return;const j=WR(x);j&&n(j)}).catch(()=>{}),()=>{N=!0}},[e]);const d=Fre(t),h=y.useRef(!1),f=y.useRef(0),p=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(f.current),[]);const g=y.useCallback(async N=>{if(!lr(h.current))return;const k=++p.current;window.clearTimeout(f.current),h.current=!0,s(!0),l(null);const x=j=>{k===p.current&&(window.clearTimeout(f.current),h.current=!1,s(!1),l({failure:j,version:N}))};try{const j=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:N})});if(!j.ok)return x(zre(await j.json().catch(()=>null)))}catch{return x("unreachable")}k===p.current&&(f.current=window.setTimeout(()=>x("timeout"),qL))},[]),v=y.useCallback(N=>{if(sc())try{const k=WR(JSON.parse(N));k&&(c.current++,n(k),k.status!=="ready"&&(p.current++,window.clearTimeout(f.current),h.current=!1,s(!1)))}catch{}},[]);return{desktopUpdateRestarting:r,desktopUpdateFailure:o,readyAppUpdate:d,askDesktopUpdateRestart:g,onDesktopUpdateEvent:v}}const Ku="agent-dag.autoRestart",f2="agent-dag.bundleReloadedFor";function Lie({now:e,stateRef:t,version:n,notice:r,noticeOpen:s,upgradeFailure:o,paused:l}){const[c,d]=y.useState(()=>Qe(Ku)!=="0"),h=y.useRef(!1),f=y.useCallback(()=>{const F=!c;h.current=!0,hs(Ku),d(F),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:F})}).then(O=>O.ok?O.json():null).then(O=>{var I;O!=null&&O.ok&&d(((I=O.prefs)==null?void 0:I.autoUpdate)!==!1)}).catch(()=>{})},[c]),[p,g]=y.useState(!1),[v,N]=y.useState("restart"),[k,x]=y.useState(null),j=y.useRef(!1),b=y.useRef(null),_=y.useRef(0),E=y.useRef(null),R=y.useCallback(async F=>{if(!lr(j.current))return;const O=(F==null?void 0:F.upgrade)===!0,I=(F==null?void 0:F.whenIdle)===!0;j.current=!0,b.current=o;const B=++_.current,M=()=>{N(O?"npx":"restart"),g(!0)};I||M();try{window.sessionStorage.setItem("agent-dag.restartPending",(r==null?void 0:r.to)??"")}catch{}let $=!1;try{const P=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I?{upgrade:O,whenIdle:I}:{upgrade:O})});$=I&&P.status===409}catch{}if($){j.current=!1,E.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}I&&M(),window.setTimeout(()=>{if(_.current===B&&j.current){j.current=!1,g(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},O?18e4:3e4)},[r==null?void 0:r.to,o]);y.useEffect(()=>{const F=HR(t.current.agents.values())>0,O=jse({enabled:c,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:F,idleSince:E.current,now:e});E.current=O.idleSince,O.restart&&R({whenIdle:!0})},[c,r==null?void 0:r.kind,n==null?void 0:n.canRestart,s,e,R]);const T=HR(t.current.agents.values()),A=Nse(T,l),U=WL({enabled:c,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:T>0,idleSince:E.current,now:e});y.useEffect(()=>{const F=n==null?void 0:n.running;let O=null,I=null;try{O=window.sessionStorage.getItem("agent-dag.restartPending"),I=window.sessionStorage.getItem(f2)}catch{return}const B=wse({bundle:"3.37.1",running:F,pending:O,lastTried:I});if(B==="reload"){try{window.sessionStorage.setItem(f2,F??"")}catch{return}window.location.reload();return}if(B!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}j.current=!1,g(!1),x(F??null);const M=window.setTimeout(()=>x(null),6e3);return()=>window.clearTimeout(M)},[n==null?void 0:n.running]),y.useEffect(()=>{if(p&&xse({asked:b.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}j.current=!1,g(!1)}},[p,o]);const L=y.useCallback(F=>{var O,I;if(!h.current){const B=Qe(Ku)==="0";hs(Ku),B&&((O=F.prefs)==null?void 0:O.autoUpdate)!==!1?(d(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):d(((I=F.prefs)==null?void 0:I.autoUpdate)!==!1)}},[]);return{autoRestart:c,toggleAutoRestart:f,restarting:p,restartMode:v,restartedTo:k,askRestart:R,restartCopy:A,restartFuseMs:U,loadAutoRestartPrefs:L}}function Pie(){const[e,t]=y.useState([]),n=y.useRef(new Set),[r,s]=y.useState(null),[o,l]=y.useState(void 0);y.useEffect(()=>{let h=!0,f=0;const p=()=>{fetch("/api/lan").then(g=>g.ok?g.json():null).then(g=>h?(g!=null&&g.ok&&t(MS(Array.isArray(g.pending)?g.pending:[],g.aliases)),g):null).catch(()=>null).then(g=>{h&&(l(v=>g!=null&&g.ok?g:v===void 0?null:v),f=window.setTimeout(p,(g==null?void 0:g.enabled)===!0?tb:PI))})};return p(),()=>{h=!1,window.clearTimeout(f)}},[]);const c=y.useCallback(async(h,f)=>{if(!r){s(h);try{const g=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:h,fp:f})})).json().catch(()=>null);g&&Array.isArray(g.pending)?t(MS(g.pending,g.aliases)):t(v=>v.filter(N=>N.fp!==f))}catch{}finally{s(null)}}},[r]),d=y.useCallback(h=>{r||(n.current.add(h),t(f=>[...f]))},[r]);return{lanPending:e,lanDeferred:n,lanBusy:r,answerLanPair:c,deferLanPair:d,lanStatus:o}}const Die=6e4;function Fie({enabled:e,lanStatus:t,now:n}){const[r,s]=y.useState(null),[o,l]=y.useState(()=>new Set),[c,d]=y.useState(null),h=y.useCallback(j=>{j!=null&&j.ok&&Array.isArray(j.accounts)&&s(j.accounts)},[]),f=y.useCallback(async j=>{try{const b=await fetch(`/api/claude-accounts${j?"?refresh=1":""}`);b.ok&&h(await b.json())}catch{}},[h]);y.useEffect(()=>{e&&f(!1)},[e,f]),y.useEffect(()=>{if(!e)return;let j=Date.now();const b=()=>{document.visibilityState!=="visible"||Date.now()-j<Die||(j=Date.now(),f(!1))};return document.addEventListener("visibilitychange",b),window.addEventListener("focus",b),()=>{document.removeEventListener("visibilitychange",b),window.removeEventListener("focus",b)}},[e,f]);const p=y.useMemo(()=>e?Jae(r,{lan:t,now:n,closed:o}):[],[e,r,t,n,o]),g=y.useRef(p);g.current=p;const v=y.useCallback(j=>{j.length&&l(b=>new Set([...b,...j]))},[]),N=y.useCallback(()=>{const j=g.current;j.length&&(v(j.map(b=>b.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:j.map(b=>({key:b.key,since:b.since}))})}).catch(()=>{}))},[v]),k=y.useRef(c);k.current=c;const x=y.useCallback(j=>{const b=k.current;v(Qae(b?[b,...g.current]:g.current,j))},[v]);return{rows:p,signingIn:c,observe:h,signIn:d,signedIn:x,refresh:y.useCallback(()=>{f(!0)},[f]),closeSignIn:y.useCallback(()=>d(null),[]),later:N}}const pP="agent-dag.sessionListOpen",mP="agent-dag.accountsPanelOpen";function Bie(){return Qe(pP)==="1"}function qie(e){Ze(pP,e?"1":"0")}function Uie(){const e=Qe(mP);return e===null?!0:e==="1"}function zie(){const[e,t]=y.useState(Bie);y.useEffect(()=>{qie(e)},[e]);const n=y.useRef(!1),[r,s]=y.useState(()=>{const h=Uie();return h&&e?(n.current=!0,!1):h});y.useEffect(()=>{!r&&n.current||Ze(mP,r?"1":"0")},[r]),y.useEffect(()=>{!e&&n.current&&(n.current=!1,s(!0))},[e]);const o=y.useCallback(()=>{t(h=>(h||s(f=>(f&&(n.current=!0),!1)),!h))},[]),l=y.useCallback(()=>{n.current=!1,s(h=>(h||t(!1),!h))},[]),c=y.useCallback(()=>t(!1),[]),d=y.useCallback(()=>s(!1),[]);return{sessionListOpen:e,accountsPanelOpen:r,toggleSessionList:o,toggleAccountsPanel:l,closeSessionList:c,closeAccountsPanel:d}}const gP="agent-dag.detailOpen",yP="agent-dag.usagePanelOpen",wP="agent-dag.systemPanelOpen";function Wie(){return Qe(gP)==="1"}function Hie(e){Ze(gP,e?"1":"0")}function Vie(){const e=Qe(yP);return e===null?!0:e==="1"}function Gie(e){Ze(yP,e?"1":"0")}function Kie(){const e=Qe(wP);return e===null?!0:e==="1"}function Yie(e){Ze(wP,e?"1":"0")}function Xie(){const[e,t]=y.useState(Wie);y.useEffect(()=>{Hie(e)},[e]);const[n,r]=y.useState(Vie);y.useEffect(()=>{Gie(n)},[n]);const[s,o]=y.useState(Kie);return y.useEffect(()=>{Yie(s)},[s]),qt("usage-panel",n),qt("machine-panel",s),{detailOpen:e,setDetailOpen:t,usagePanelOpen:n,setUsagePanelOpen:r,machinePanelOpen:s,setMachinePanelOpen:o}}const Zie={permission:"your permission",asked:"your answer"},Jie="No sessions are waiting for you.";function Qie(e){if(e.length===0)return"";const[t,...n]=e,r=t.waiting.kind,s=n.every(l=>l.waiting.kind===r)?Zie[r]??"you":"you";if(n.length===0)return`${t.label} is waiting for ${s}.`;const o=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${o} are waiting for ${s}.`}function hx(e,t,n=Jie){return t!==""?t:e===""?"":n}function ele({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[r,s]=y.useState(""),o=Qie(e);y.useEffect(()=>{s(g=>hx(g,o))},[o]);const[l,c]=y.useState(""),d=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";y.useEffect(()=>{c(g=>hx(g,d,"Browser watch has no unread findings."))},[d]);const[h,f]=y.useState(""),p=xie(n);return y.useEffect(()=>{f(g=>hx(g,p,bie))},[p]),{blockedSaid:r,watchSaid:l,setWatchSaid:c,incidentSaid:h}}const tle="/icon-192.png";function nle({waitingSessions:e,liveSince:t,focusSession:n}){const[r,s]=y.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[o,l]=y.useState(null),[c,d]=y.useState(!1),[h,f]=y.useState(!1),p=y.useRef(()=>{}),g=y.useRef(new Set),v=_n(e),N=y.useCallback(()=>{const R=!c;d(R),R&&(g.current=$u(v.current)),R&&typeof Notification<"u"&&Notification.permission==="default"&&p.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:R})}).then(T=>T.ok?T.json():null).then(T=>{var A;T!=null&&T.ok&&(d(((A=T.prefs)==null?void 0:A.notifications)===!0),f(T.notificationsVetoed===!0))}).catch(()=>{})},[c]),k=typeof Notification<"u";y.useEffect(()=>{if(!o)return;const T=setTimeout(()=>l(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(T)},[o]);const x=y.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(R=>{const T=R;s(T),T==="granted"?l("on"):T==="denied"&&l("blocked")})},[]);p.current=x;const j=y.useRef(null),b=e.map(R=>Zd(R.id,R.waiting)).join("|");y.useEffect(()=>{W8(j.current,r)&&(j.current=r,g.current=$u(e))},[r]);const _=y.useRef(!1);y.useEffect(()=>{H8(_.current,t)&&(_.current=!0,g.current=$u(e))},[t]),y.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!V8(j.current,t))return;const R=typeof document>"u"||!document.hidden,T=U8(e,g.current,R,c);for(const A of T)try{const U=new Notification(A.title,{body:A.body,tag:A.key,icon:tle});U.onclick=()=>{window.focus(),n(A.sessionId),U.close()}}catch{}g.current=R?$u(e):z8(e,T,g.current)},[b,t]);const E=y.useCallback(R=>{var T;d(((T=R.prefs)==null?void 0:T.notifications)===!0),f(R.notificationsVetoed===!0)},[]);return{notifyPermission:r,notifySaid:o,notifyOn:c,notifyVetoed:h,toggleNotify:N,notifySupported:k,askForNotifications:x,loadNotifyPrefs:E}}function rle({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:r,summaryFor:s,browserWatchOpen:o,keyHelpOpen:l,releaseNotes:c,feedbackOpen:d}){const h=_n(l),f=y.useRef(!1);return f.current=e!=null||t||n!=null||r||s!=null||o||l||c!=null||d,{keyHelpOpenRef:h,modalOpenRef:f}}function sle({stateRef:e,tourOpen:t,releaseNotes:n}){const[r,s]=y.useState(null),o=y.useCallback((F,O)=>s({agentId:F,toolId:O}),[]),[l,c]=y.useState(null),[d,h]=y.useState(null),f=y.useCallback(F=>h(F),[]),[p,g]=y.useState(!1),[v,N]=y.useState(!1),[k,x]=y.useState(!1),[j,b]=y.useState(!1),[_,E]=y.useState(null),R=y.useCallback(F=>{E(F??null),b(!0)},[]);qt("tool-detail",r!==null),qt("session-summary",l!==null),qt("context-window",d!==null),qt("keyboard-help",p),qt("usage-history",v),qt("browser-watch",k),qt("feedback",j);const T=r?Wq(e.current.agents,r.agentId,r.toolId):null,A=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:U,modalOpenRef:L}=rle({openedTool:T,usageHistoryOpen:v,contextFor:d,tourOpen:t,summaryFor:l,browserWatchOpen:k,keyHelpOpen:p,releaseNotes:n,feedbackOpen:j});return{setOpenedToolKey:s,openTool:o,openedTool:T,summaryFor:l,setSummaryFor:c,contextFor:d,setContextFor:h,openContext:f,contextAgent:A,keyHelpOpen:p,setKeyHelpOpen:g,usageHistoryOpen:v,setUsageHistoryOpen:N,browserWatchOpen:k,setBrowserWatchOpen:x,feedbackOpen:j,setFeedbackOpen:b,feedbackPrefill:_,setFeedbackPrefill:E,openFeedback:R,keyHelpOpenRef:U,modalOpenRef:L}}function ale({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:r,lastLayoutSigRef:s,forgetRemovals:o,clearSelection:l,rerender:c,modalOpenRef:d}){const[h,f]=y.useState(!1),p=y.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=Gb(),t.current.clear(),n.current.clear(),r.current.clear(),s.current="",AL(),o(),l(),c()},[c,l,o]),g=_n(h),v=y.useCallback(N=>{const k=Ese(N,{confirmOpen:g.current,modalOpen:d.current});k==="confirm"?f(!0):k==="clear"&&(f(!1),p())},[p]);return{clearConfirmOpen:h,setClearConfirmOpen:f,requestClear:v}}const p2="agent-dag.oldNameNoticeDismissed";function ole(e){const[t,n]=y.useState(()=>Qe(p2)??""),r=e!=null&&e.invokedAs&&e.invokedAs!==kt?e.invokedAs:null,s=r!=null&&t!==r,o=y.useCallback(()=>{r&&(n(r),Ze(p2,r))},[r]);return{oldName:r,oldNameOpen:s,dismissOldName:o}}const ile=300*1e3,lle=1800*1e3,cle=8e3,ule=3e4;function m2(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function dle({modalOpenRef:e}){const t=y.useCallback(()=>w$({appModal:e.current,dialogDepth:ds.dialogDepth()}),[e]),[n,r]=y.useState("hidden"),[s,o]=y.useState(null),[l,c]=y.useState(!1),d=y.useRef(n);d.current=n,y.useEffect(()=>{let v=!1;const N=async()=>{if(d.current==="thanks"||d.current==="hidden"&&(document.hidden||t()))return;const j=await fetch("/api/rating").then(b=>b.ok?b.json():null).catch(()=>null);v||!j||r(b=>b==="thanks"?b:j.ask===!0?"asking":"hidden")},k=window.setTimeout(N,ile),x=window.setInterval(N,lle);return()=>{v=!0,window.clearTimeout(k),window.clearInterval(x)}},[t]),y.useEffect(()=>{if(n!=="thanks"||l)return;const v=s!==null&&s<=6?ule:cle;let N=0;const k=()=>{t()?N=window.setTimeout(k,v):r("hidden")};return N=window.setTimeout(k,v),()=>window.clearTimeout(N)},[n,s,l,t]);const h=y.useCallback(v=>{o(v),c(!1),r("thanks"),m2({score:v})},[]),f=y.useCallback(v=>c(v),[]),p=y.useCallback(()=>{r("hidden"),m2({later:!0})},[]),g=y.useCallback(()=>r("hidden"),[]);return{ratingPhase:n,ratingScore:s,answerRating:h,rateLater:p,closeRating:g,holdThanks:f}}function hle({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:r}){const[s,o]=y.useState(()=>KX(Qe)),l=_n(s),[c,d]=y.useState([]),h=y.useCallback(b=>{o(_=>{const E={..._,[b]:null};return l.current=E,E}),hs(Il[b])},[]),f=y.useCallback((b,_)=>{const E=l.current[b];_&&E!==_||(h(b),t(R=>{const T={...R,[b]:{...R[b],figure:jn}};return n.current=T,T}),Ze(Md[b],jn))},[h]),p=_n(f);y.useEffect(()=>{let b=!0;return aZ().then(_=>{if(!b)return;d(_);const E=new Set(_.map(R=>R.id));for(const R of rd){const T=l.current[R];T&&!E.has(T)&&p.current(R,T)}},()=>{}),()=>{b=!1}},[]);const g=y.useCallback((b,_)=>{if(!c.some(R=>R.id===_))return;const E={...l.current,[b]:_};l.current=E,o(E),Ze(Il[b],_),r(b,!0)},[c,r]),v=y.useCallback(async b=>{var T;const _=lb(c.length);if(_)throw new Error(_);const E=window.AudioContext??window.webkitAudioContext;if(!E)throw new Error("This browser cannot decode audio files.");const R=new E;try{const A=await eZ(b,L=>R.decodeAudioData(L));await o_(A);const U=ec(A);d(L=>[...L.filter(F=>F.id!==U.id),U])}finally{(T=R.close)==null||T.call(R)}},[c.length]),N=y.useCallback(async b=>{const _=lb(c.length);if(_)throw new Error(_);const E=tZ(b);await o_(E);const R=ec(E);d(T=>[...T.filter(A=>A.id!==R.id),R])},[c.length]),k=y.useCallback(async(b,_)=>{const E=c.find(T=>T.id===b),R=_.trim().slice(0,80);!E||!R||R===E.name||(await iZ(b,R),d(T=>T.map(A=>A.id===b?{...A,name:R}:A)))},[c]),x=y.useCallback(async b=>{await lZ(b),d(T=>T.filter(A=>A.id!==b));const _=l.current,E=YX(_,b);l.current=E,o(E);const R=rd.filter(T=>_[T]===b);for(const T of R)hs(Il[T]),Ze(Md[T],jn);R.length>0&&t(T=>{const A={...T};for(const U of R)A[U]={...A[U],figure:jn};return n.current=A,A})},[]),j=y.useCallback(b=>{var R,T;const _=rd.find(A=>l.current[A]===b),E=_?n.current[_].level:Qa;(R=e.current)==null||R.unlock(),(T=e.current)==null||T.previewCustom(b,E)},[]);return{customSelections:s,customSelectionsRef:l,customAssets:c,clearCustomOnly:h,fallbackCustomRef:p,selectCustomTone:g,importNotificationAudio:v,createNotificationVoice:N,renameCustomAsset:k,deleteCustomAsset:x,previewCustomAsset:j}}function fle(e){const[t,n]=y.useState(()=>xZ(Qe)),r=_n(t),s=y.useRef(null),o=y.useCallback((c,d=!1)=>{var h,f;if((h=e.current)==null||h.unlock(),s.current!==null&&clearTimeout(s.current),s.current=null,!d){(f=e.current)==null||f.play(c,!0);return}s.current=setTimeout(()=>{var p;s.current=null,(p=e.current)==null||p.play(c,!0)},mZ)},[]),l=y.useCallback((c,d)=>{n(h=>{const f={level:vi(d.level??h[c].level),figure:fO(c,d.figure??h[c].figure)};return Ze(gO[c],String(f.level)),Ze(Md[c],f.figure),{...h,[c]:f}}),o(c,!0)},[o]);return y.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:r,previewTone:o,changeTone:l}}const ple=15e3;function mle(e){return e.visibilityState==="visible"&&e.hasFocus()}function gle(e,t){return t||e===!0}function yle(){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)}`}function wle(){y.useEffect(()=>{const e=yle();let t=null;const n=l=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:e,looking:l}),keepalive:!0}).catch(()=>{})},r=()=>{const l=mle(document);gle(t,l)&&n(l),t=l},s=()=>{t&&n(!1),t=!1};r();const o=window.setInterval(r,ple);return window.addEventListener("focus",r),window.addEventListener("blur",r),document.addEventListener("visibilitychange",r),window.addEventListener("pagehide",s),()=>{window.clearInterval(o),window.removeEventListener("focus",r),window.removeEventListener("blur",r),document.removeEventListener("visibilitychange",r),window.removeEventListener("pagehide",s),s()}},[])}function vle({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n}){y.useEffect(()=>{let r=!0;return fetch("/api/prefs").then(s=>s.ok?s.json():null).then(s=>{!r||!(s!=null&&s.ok)||(e(s),t(s),n(s))}).catch(()=>{}),()=>{r=!1}},[])}const fx="agent-dag.versionNoticeDismissed",xle=15*6e4;function ble(e){const[t,n]=y.useState(null),[r,s]=y.useState(()=>Qe(fx)??""),o=y.useRef(0),[l,c]=y.useState(!1),d=y.useCallback((k=!1)=>(k&&(o.current=Date.now(),c(!0)),fetch(k?"/api/version?refresh=1":"/api/version").then(x=>x.ok?x.json():null).then(x=>{x&&n(x)}).catch(()=>{}).finally(()=>{k&&c(!1)})),[]),h=y.useCallback(()=>{d(Date.now()-o.current>=xle)},[d]);y.useEffect(()=>{d();const k=window.setInterval(h,5*6e4),x=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",x),()=>{window.clearInterval(k),document.removeEventListener("visibilitychange",x)}},[d,h]),y.useEffect(()=>{e&&d()},[e,d]);const f=(t==null?void 0:t.notice)??null,p=UL(f),g=Yre(f,r),v=y.useCallback(()=>{s(""),Ze(fx,"")},[]),N=y.useCallback(()=>{f&&(s(p),Ze(fx,p))},[f,p]);return{version:t,notice:f,noticeOpen:g,showNotice:v,dismissNotice:N,versionChecking:l,loadVersion:d}}function kle({version:e,readyAppUpdate:t}){const[n,r]=y.useState(!1),s=y.useRef(null),[o,l]=y.useState(null),c=o&&t?t.version:null,d=y.useRef(null);y.useEffect(()=>{!c||d.current===c||(d.current=c,fetch("/api/desktop-update/seen",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:c})}).catch(()=>{}))},[c]);const h=y.useRef(!1);y.useEffect(()=>{if(h.current)return;const x=Ml(),j=xoe(x),b=_oe({stored:j,running:(e==null?void 0:e.running)??null,notes:t2,remembers:boe(x)});if(b.reason==="no-version")return;h.current=!0,b.record&&koe(x,b.record);let _=!0;return(async()=>{var U;let R=Noe(x);if(sc())try{const L=await fetch("/api/prefs");if(!L.ok)throw new Error("desktop tour preferences unavailable");const F=await L.json();if(!(F!=null&&F.ok))throw new Error("desktop tour preferences unavailable");const O=((U=F.prefs)==null?void 0:U.tourSeen)===!0;R&&!O&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),R=R||O}catch{R=!0}if(!_)return;const T=Soe({tourSeen:R,decision:b}),A=b.show.length?{entries:b.show,since:j,firstRun:!1}:null;T.tour&&r(!0),T.notes==="now"?l(A):T.notes==="after"&&(s.current=A)})(),()=>{_=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.37.1",p=y.useMemo(()=>rP(t2,null,f),[f]),g=y.useCallback(()=>{l({entries:p,since:null,firstRun:!1})},[p]),v=y.useCallback(()=>r(!0),[]),N=y.useCallback(()=>l(null),[]),k=y.useCallback(()=>{r(!1),joe(Ml()),sc()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const x=s.current;s.current=null,x&&l(x)},[]);return{tourOpen:n,openTour:v,closeTour:k,releaseNotes:o,closeReleaseNotes:N,chipVersion:f,openReleaseNotes:g}}function Nle(){const[e,t]=y.useState(void 0),[n,r]=y.useState(!1),s=y.useRef(!1);return s.current=e===!0&&!n,y.useEffect(()=>Xoe(()=>s.current),[]),{loadReportsPrefs:y.useCallback(l=>{var c;t(((c=l.prefs)==null?void 0:c.reports)!==!1),r(l.reportsVetoed===!0)},[])}}function jle(){const[e,t]=y.useState(null),[n,r]=y.useState(!1),s=y.useRef(null);return y.useEffect(()=>{let o=!0,l=!1,c=null,d=null,h="";const f=k=>{o&&(r(!0),k!==h&&t(null))},p=()=>{if(l)return;l=!0,c=Date.now();const k=UR();d=k,fetch(`/api/ccusage?since=${k}`).then(x=>x.ok?x.json():null).then(x=>{if(o){if(!(x!=null&&x.ok)){f(k);return}h=k,t(Pre(x)),r(!1)}}).catch(()=>f(k)).finally(()=>{l=!1})},g=()=>{const k=s.current;Lre({shown:!!k&&k.getClientRects().length>0,tabVisible:document.visibilityState==="visible",lastSince:d,since:UR(),lastReadAt:c,now:Date.now()})&&p()};g();const v=window.setInterval(g,Ore);document.addEventListener("visibilitychange",g);let N=null;return s.current&&typeof ResizeObserver<"u"&&(N=new ResizeObserver(g),N.observe(s.current)),()=>{o=!1,window.clearInterval(v),document.removeEventListener("visibilitychange",g),N==null||N.disconnect()}},[]),{monthlyUsage:e,monthlyUsageUnavailable:n,monthUsageRef:s}}function Sle(e){const[t,n]=y.useState(null);y.useEffect(()=>{const c=Qe("agent-dag.sound");n(c===null?!0:c==="on")},[]);const r=y.useCallback(()=>{n(c=>{var h,f;const d=c!==!0;return Ze("agent-dag.sound",d?"on":"off"),d?(h=e.current)==null||h.unlock():(f=e.current)==null||f.silence(),d})},[]),s=y.useCallback(c=>{r()},[r]),o=_n(s),l=_n(t);return{soundOn:t,toggleSound:r,activateSoundRef:o,soundOnRef:l}}function _le(){const[e,t]=y.useState(!1),n=y.useRef(null),[r,s]=y.useState(!1),o=y.useRef(null);return y.useEffect(()=>{e&&s(!1)},[e]),{soundMenuOpen:e,setSoundMenuOpen:t,soundButtonRef:n,appearanceMenuOpen:r,setAppearanceMenuOpen:s,appearanceButtonRef:o}}const Ele="agent-dag.autoFitDisabled";function Cle(e){const t=y.useRef(!1),[n,r]=y.useState(!1);y.useEffect(()=>{hs(Ele)},[]);const s=y.useCallback(()=>{t.current||(t.current=!0,r(!0))},[]),o=y.useCallback(()=>{t.current=!1,r(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:s,enableAutoFitAndRefit:o}}function Tle(){return a.jsx(Wb,{children:a.jsx(Qoe,{children:a.jsx(Ale,{})})})}function Ale(){const e=ki(),t=y.useState(Gb)[0],n=y.useRef(t),[,r]=y.useState(0),s=y.useCallback(()=>r(ba=>ba+1),[]),{detailOpen:o,setDetailOpen:l,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f}=Xie(),{selectedIds:p,primarySelectedId:g,selectAgent:v,clearSelection:N,pruneSelectionToBoard:k}=DZ(n,l),{sessionListOpen:x,accountsPanelOpen:j,toggleSessionList:b,toggleAccountsPanel:_,closeSessionList:E,closeAccountsPanel:R}=zie(),T=jle(),A=Qu(j,200),U=Qu(c,130),L=Qu(h,130),F=y.useRef(null),O=Sle(F),{activateSoundRef:I,soundOnRef:B}=O,M=fle(F),{setTonePrefs:$,tonePrefsRef:P,previewTone:G}=M,K=hle({chimesRef:F,setTonePrefs:$,tonePrefsRef:P,previewTone:G}),{customSelectionsRef:q,fallbackCustomRef:H}=K,D=_le(),{setSoundMenuOpen:W}=D,{chimeState:J}=$ie({chimesRef:F,soundOnRef:B,tonePrefsRef:P,customSelectionsRef:q,fallbackCustomRef:H}),V=nie(n),{pauseGate:X,paused:Y,togglePause:Z}=V,ee=y.useRef(()=>{}),{live:ne,tabCapped:se,everConnected:pe,liveSince:ke}=CZ({stateRef:n,rerender:s,pauseGate:X,chimesRef:F,desktopUpdateRef:ee}),ae=ble(ne),{version:fe,notice:me,noticeOpen:he,loadVersion:ge}=ae,ue=Oie(ne),{readyAppUpdate:be,onDesktopUpdateEvent:oe}=ue;ee.current=oe,wle();const je=kle({version:fe,readyAppUpdate:be}),{tourOpen:$e,openTour:Oe,releaseNotes:Ue}=je,{workspace:Be,providers:We,providersRef:He}=sie(ne),rt=ole(fe),lt=kie({version:fe,loadVersion:ge}),{upgradeFailure:Rt}=lt,De=sle({stateRef:n,tourOpen:$e,releaseNotes:Ue}),et=dle({modalOpenRef:De.modalOpenRef}),{openTool:Je,setSummaryFor:tt,setContextFor:yt,openContext:Pt,setKeyHelpOpen:wt,setUsageHistoryOpen:st,setBrowserWatchOpen:zt,keyHelpOpenRef:Wt,modalOpenRef:Dt}=De,Ht=Nle(),Vt=jie(),{watchOn:vs,watchUnseen:Tn}=Vt,mr=Pie(),[zr,gr]=y.useState(0),{presentCats:Wr,hiddenCats:mn,toggleCat:Hr,catBarRef:An,catBarOccluded:da}=Rie(n),gn=y.useRef(null),[yr,wr]=y.useState(0),xt=FZ({stateRef:n,rerender:s,pruneSelectionToBoard:k,setContextFor:yt,setSummaryFor:tt}),xs=lie(We.claude||We.codex),vr=vie(xs,xt),xr=Fie({enabled:We.claude,lanStatus:mr.lanStatus,now:xt}),Gt=Lie({now:xt,stateRef:n,version:fe,notice:me,noticeOpen:he,upgradeFailure:Rt,paused:V.paused}),{askRestart:bs,loadAutoRestartPrefs:Vr}=Gt,ye=Aie(),{setTheme:Fe,palette:Ge}=ye,rn=Iie(),Gr=Pte(),{applyViewport:br,moveCamera:ha,fitLeft:Ke,cameraEpochRef:Kr,lastFitTimeRef:ks}=Gr,kr=Yte(Ke),{pinnedRef:Kn,positionsRef:Yr,lastLayoutSigRef:ao,handleRelayout:Ns}=kr,Jt=y.useRef(null),js=y.useRef(()=>{}),yn=ke!==null,vc=y.useRef(0),xc=y.useCallback(()=>{vc.current=Date.now()},[]),{canvasRef:Nr,canvasSize:oo,paneSizeRef:io}=Ene(),Ss=Cle(Ke),{autoFitDisabledRef:fa,disableAutoFit:Mi}=Ss,$i=y.useRef(!1),{measuredRef:Yn,measuredVersionRef:bc,sizeVersion:Ii,domSizeVersion:pa}=Cne($i),{removedNodes:kc,removedAgentIds:jr,removeNode:Ye,removeSelectedNode:Oi,removalNotice:Li,bringBack:ma,bringBackAll:Nc,forgetRemovals:jc}=gne({stateRef:n,pinnedRef:Kn,positionsRef:Yr,canvasRef:Nr,clearSelection:N,primarySelectedId:g}),lo=dne({stateRef:n,now:xt,removedAgentIds:jr,sizeVersion:Ii,domSizeVersion:pa});Xte(lo,kr),mne({layoutSig:lo,rf:e,stateRef:n,measuredRef:Yn,pinnedRef:Kn,positionsRef:Yr,paneSizeRef:io,lastInteractRef:vc,autoFitDisabledRef:fa,lastFitTimeRef:ks,fitLeft:Ke});const co=Tne(),{bubbling:uo,endBubble:Sr,onBubble:_r}=MX(),[Rn,ga]=y.useState(!1),_s=AX(),{beginTrashDrag:Er,trackTrashDrag:Ih,endTrashDrag:Sc}=_s,Es=qX({stateRef:n,measuredRef:Yn,measuredVersionRef:bc,canvasRef:Nr}),{lodRef:Oh,applyZoom:_c}=Es,ya=Sne({applyViewport:br,lastFitTimeRef:ks,cameraEpochRef:Kr,disableAutoFit:Mi,markInteract:xc,canvasRef:Nr,applyZoom:_c}),Cs=g?n.current.agents.get(g):null,Pi=o&&Cs!=null,wn=$ne({sessionListShown:x,usageShown:La(U),machineShown:La(L),accountsShown:La(A)&&We.claude,detailShown:Pi,primarySelectedId:g,canvasRef:Nr}),{railInsetRef:Ts,availableWidth:Xr,availableHeight:wa}=Lte({canvasRef:Nr,canvasSize:oo,machinePhase:L,usagePhase:U,usagePanelOpen:c,detailShown:Pi}),Ec=hne({stateRef:n,now:xt,availableWidth:Xr,availableHeight:wa,layout:kr,measuredRef:Yn,onBubble:_r,settled:co,dragging:Rn,layoutSig:lo,selectedIds:p,openContext:Pt,historyReplayed:yn,removedNodes:kc,removedAgentIds:jr,dragTick:zr,dragPatchRef:gn,dragMoveTick:yr}),{nodes:Di,edges:Fi}=Ec,As=_n(g);Zte({nodes:Di,edges:Fi,settled:co,dragging:Rn,availableWidth:Xr,availableHeight:wa,layout:kr,camera:Gr,rf:e,measuredRef:Yn,stateRef:n,lastFocusRef:Jt,primarySelectedIdRef:As,focusAgentRef:js,autoFitDisabledRef:fa});const ho=ale({stateRef:n,pinnedRef:Kn,measuredRef:Yn,positionsRef:Yr,lastLayoutSigRef:ao,forgetRemovals:jc,clearSelection:N,rerender:s,modalOpenRef:Dt}),{requestClear:Bi}=ho,Cr=Ine({nodes:Di,stateRef:n,pinnedRef:Kn,positionsRef:Yr,draggingRef:$i,dragPatchRef:gn,setDragging:ga,setDragMoveTick:wr,setDragTick:gr,endBubble:Sr,markInteract:xc,disableAutoFit:Mi,beginTrashDrag:Er,trackTrashDrag:Ih,endTrashDrag:Sc,removeNode:Ye}),qi=y.useCallback(()=>Ke(500),[Ke]),Rs=_n(Di),{focusAgent:va,stepAgent:fo,focusSession:Tr}=Fte({canvasRef:Nr,stateRef:n,measuredRef:Yn,nodesRef:Rs,railInsetRef:Ts,moveCamera:ha,disableAutoFit:Mi,lastFocusRef:Jt,focusAgentRef:js,selectAgent:v,primarySelectedIdRef:As}),Cc=_ne({clearSelection:N,selectAgent:v,detailOpen:o,setDetailOpen:l,detailShown:Pi,focusAgent:va,draggingRef:$i,lodRef:Oh}),Qt=Bte({nodesRef:Rs,stateRef:n,canvasRef:Nr,railInsetRef:Ts}),Ms=_n(Oi),po=y.useRef(null),xa=y.useCallback(ba=>{jr.has(ba)&&ma([ba]),Tr(ba)},[jr,ma,Tr]),Lh=Ane();Rne({pointerFocusRef:Lh,nodesRef:Rs,stateRef:n,primarySelectedIdRef:As,providersRef:He,soundOnRef:B,keyHelpOpenRef:Wt,modalOpenRef:Dt,waitingCursorRef:po,removeSelectedRef:Ms,activateSoundRef:I,clearSelection:N,selectAgent:v,focusAgent:va,stepAgent:fo,focusSession:Tr,requestClear:Bi,handleRelayout:Ns,handleFit:qi,togglePause:Z,toggleSessionList:b,toggleAccountsPanel:_,setDetailOpen:l,setUsageHistoryOpen:st,setUsagePanelOpen:d,setMachinePanelOpen:f,setBrowserWatchOpen:zt,setSoundMenuOpen:W,setKeyHelpOpen:wt,setTheme:Fe});const mo=n.current.agents.size,Zr=y.useMemo(()=>Mx(n.current.agents.values()),[n.current,n.current.revision]);yne({stateRef:n,waitingSessions:Zr,removedAgentIds:jr,removedNodes:kc,bringBack:ma}),kne({stateRef:n,waitingSessions:Zr,live:ne});const $s=ele({waitingSessions:Zr,watchUnseen:Tn,incidents:vr}),Is=nle({waitingSessions:Zr,liveSince:ke,focusSession:Tr}),{loadNotifyPrefs:Tc}=Is;return vle({loadAutoRestartPrefs:Vr,loadNotifyPrefs:Tc,loadReportsPrefs:Ht.loadReportsPrefs}),a.jsxs("div",{className:"app",children:[a.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),a.jsxs("header",{className:"topbar",children:[a.jsx(tse,{versionCheck:ae,welcome:je,desktopUpdate:ue,pause:V,monthly:T,announcements:$s,notify:Is,waitingSessions:Zr,waitingCursorRef:po,focusSession:Tr,live:ne,now:xt,incidents:vr}),Cs&&a.jsx(nse,{selected:Cs,now:xt,selectedIds:p,focusAgent:va,clearSelection:N}),a.jsxs("div",{className:"actions",children:[a.jsx(Rre,{sessionListOpen:x,toggleSessionList:b,usagePanelOpen:c,setUsagePanelOpen:d,setUsageHistoryOpen:st,toggles:wn.toggles}),a.jsx(Mre,{providers:We,accountsPanelOpen:j,toggleAccountsPanel:_,machinePanelOpen:h,setMachinePanelOpen:f,watchOn:vs,watchUnseen:Tn,setBrowserWatchOpen:zt,toggles:wn.toggles}),a.jsx($re,{providers:We,sound:O,tones:M,customTones:K,notify:Is,chimeState:J,menus:D,appearance:ye,fm:rn,onFeedback:()=>De.openFeedback(),watchUnseen:Tn,setUsageHistoryOpen:st,setBrowserWatchOpen:zt})]})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Li?`${Li.label} removed from the board.`:""}),a.jsx(_se,{restart:Gt,versionCheck:ae,upgrade:lt,oldNameNotice:rt,rating:et,onFeedback:De.openFeedback,everConnected:pe,live:ne,paused:Y}),La(A)&&We.claude&&a.jsx(NX,{leaving:A==="leaving",onReport:De.openFeedback,onRoster:xr.observe,onClose:()=>{wn.accounts(),R()}}),x&&a.jsx(MH,{state:n.current,now:xt,selectedIds:p,onSelect:xa,onClose:()=>{wn.sessionList(),E()},removedIds:jr,onBringBackAll:Nc}),a.jsxs(ise,{canvasRef:Nr,bubbling:uo,dragging:Rn,trash:_s,zoom:Es,viewport:ya,stateRef:n,peek:Qt,children:[mo===0&&(!ne&&se?a.jsx(Une,{}):a.jsx(zne,{live:ne,everConnected:pe,providers:We,workspace:Be,onTour:Oe})),(Wr.length>1||mn.size>0)&&a.jsx(rse,{catBarRef:An,catBarOccluded:da,presentCats:Wr,hiddenCats:mn,toggleCat:Hr}),a.jsx(xH,{graph:Ec,layout:kr,viewport:ya,clicks:Cc,drag:Cr,appearance:ye,fm:rn,autoFit:Ss,pause:V,stateRef:n,measuredRef:Yn,hiddenCats:mn,now:xt,openTool:Je,focusAgent:va,requestClear:Bi,setKeyHelpOpen:wt})]}),La(U)&&a.jsx(_7,{state:n.current,now:xt,providers:We,incidents:vr,liveSince:ke,leaving:U==="leaving",onClose:()=>{wn.usage(),d(!1)}}),La(L)&&a.jsx(u9,{usageOpen:c,leaving:L==="leaving",onClose:()=>{wn.machine(),f(!1)}}),o&&Cs?a.jsx(nre,{selected:Cs,now:xt,openTool:Je,setSummaryFor:tt,stateRef:n,removeSelectedNode:Oi,onClose:()=>{wn.detail(),l(!1)}}):null,a.jsx(Ooe,{dialogs:De,welcome:je,desktopUpdate:ue,versionCheck:ae,restart:Gt,lanPairs:mr,attention:xr,clearFlow:ho,watchBadge:Vt,announcements:$s,appearance:ye,providers:We,stateRef:n,agentCount:mo})]})}try{jU(window.localStorage)}catch{}const Rle=Q3.createRoot(document.getElementById("root"));Rle.render(a.jsx(Tle,{}));export{Pne as a,it as b,oa as c,gt as d,is as e,qe as f,Ile as g,Dr as h,$le as i,a as j,Jl as k,Cn as l,JX as m,ea as n,eo as o,Wx as p,y as r,lr as s,ut as u};
|