agent-dag 1.36.2 → 1.36.3
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.
|
@@ -61,18 +61,18 @@ no published rate in this build — the tokens are counted, the dollars are not`
|
|
|
61
61
|
`)}function _L({data:e,selected:t}){var f;const r=e.now??Date.now(),i=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",t?"selected":""].filter(Boolean).join(" "),o=e.tools.filter(p=>!p.endedAt).length,a=uy(e.sessionId),u=((f=e.context)==null?void 0:f.currentContextTokens)??0,c=e.kind==="root"&&u>0;return m.jsxs("div",{className:i,style:{"--session-hue":a},children:[m.jsx("span",{className:"accent-stripe"}),m.jsx(mo,{type:"target",position:Ae.Left,style:{background:"transparent",border:"none"}}),m.jsxs("div",{className:"head",children:[m.jsxs("div",{className:"title",children:[m.jsx(bL,{state:e.state}),m.jsx("span",{className:"label",title:e.cwd,children:e.label}),e.synthetic&&m.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"})]}),m.jsxs("div",{className:"head-right",children:[c&&e.onOpenContext&&m.jsx(xL,{currentContextTokens:u,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)}),m.jsx("div",{className:"time",title:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:Tu(e.startedAt,e.endedAt,r)})]})]}),m.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&m.jsxs("span",{className:"spawn-badge",title:`${e.childCount} subagents spawned`,children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model?m.jsx("span",{className:"model-chip",title:e.model,children:Rs(e.model)}):e.provider==="codex"?m.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),e.waiting&&m.jsx(kL,{waiting:e.waiting,now:r}),(()=>{const p=nL(e);return p?m.jsxs("div",{className:"approval-blind-row",title:p.detail,children:[m.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),m.jsx("span",{className:"approval-blind-said",children:p.label})]}):null})(),e.tools.length>0&&m.jsx(EL,{tools:e.tools,now:r}),m.jsxs("div",{className:"meta",children:[m.jsxs("span",{children:[m.jsx("b",{children:e.toolCount})," tools"]}),o>0&&m.jsxs("span",{className:"inflight-meta",children:[m.jsx("b",{children:o})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&m.jsxs("span",{className:"tokens-meta",title:`in:${e.usage.inputTokens} out:${e.usage.outputTokens} cache-r:${e.usage.cacheReadTokens} cache-c:${e.usage.cacheCreateTokens}${(e.usage.reasoningOutputTokens??0)>0?` reasoning:${e.usage.reasoningOutputTokens}`:""}`,children:[m.jsx("b",{children:Nt(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&(()=>{if(!go(e.model))return e.usage.inputTokens+e.usage.outputTokens<=0?null:m.jsx("span",{className:"cost-unpriced",title:n_(e.usage,e.model),children:gu});const d=dn(e.usage,e.model);if(d.total<=0)return null;const g=Math.max(0,((e.endedAt??r)-e.startedAt)/1e3),y=e.state==="active"?ju(d.total,g):null,w=n_(e.usage,e.model)+(y?`
|
|
62
62
|
burn: ${y}`:"");return m.jsxs("span",{className:"cost-meta",title:w,children:[m.jsx("b",{children:qe(d.total)}),y&&m.jsx("span",{className:"cost-rate",children:y})]})})()]}),m.jsx(mo,{type:"source",position:Ae.Right,style:{background:"transparent",border:"none"}})]})}function dy(e){return e==="active"?"live":e==="done"?"done":"err"}function bL({state:e}){return m.jsx("span",{className:`state-pill state-${e}`,children:dy(e)})}function zu(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function SL(e){return e.kind==="permission"?zu(e):"Your turn"}function kL({waiting:e,now:t}){const r=e.kind==="permission",i=zu(e);return m.jsxs("div",{className:r?"waiting-row permission":"waiting-row idle",title:`${i}
|
|
63
63
|
Blocked for ${Tu(e.since,void 0,t)} — the answer goes in the terminal, not here.`,children:[r?m.jsx("span",{className:"ap-pulse","aria-hidden":!0}):m.jsx("span",{className:"waiting-dot","aria-hidden":!0}),m.jsx("span",{className:"waiting-said",children:SL(e)}),m.jsx("b",{children:Tu(e.since,void 0,t)})]})}function EL({tools:e,now:t}){const a=new Array(24).fill(0);let u=0;for(const y of e){const w=t-y.startedAt;if(w<0||w>=6e4)continue;const E=23-Math.floor(w/2500);E>=0&&E<24&&(a[E]+=1,u+=1)}const c=Math.max(1,...a),f=132,p=14,d=f/24,g=c/(2500/1e3);return m.jsxs("div",{className:"tool-spark-row",title:`${u} tool calls in last 60s · peak ${g.toFixed(1)}/s`,children:[m.jsx("svg",{className:"tool-spark",width:f,height:p,viewBox:`0 0 ${f} ${p}`,"aria-hidden":!0,children:a.map((y,w)=>{const E=y===0?1.5:Math.max(1.5,y/c*p),_=w===23&&y>0,S=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return m.jsx("rect",{x:w*d+.4,y:p-E,width:Math.max(.5,d-1),height:E,rx:.8,className:S},w)})}),m.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function r_(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function NL({tool:e,onClose:t}){const r=wo(t),i=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return m.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:m.jsxs("div",{ref:r,className:"modal",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[m.jsxs("header",{className:"modal-head",children:[m.jsxs("div",{className:"modal-title",children:[m.jsx("span",{className:`status-dot ${i}`,"aria-hidden":!0}),m.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),m.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),m.jsxs("div",{className:"modal-actions",children:[m.jsx("span",{className:"modal-dur",children:qC(e,"in-flight…")}),m.jsx("button",{className:"btn icon-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),m.jsxs("section",{className:"modal-body",children:[e.trimmed&&m.jsx("div",{className:"modal-section",children:m.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),m.jsxs("div",{className:"modal-section",children:[m.jsx("h4",{children:"Input"}),m.jsx("pre",{children:r_(e.input??e.inputPreview)})]}),m.jsxs("div",{className:"modal-section",children:[m.jsxs("h4",{children:["Response ",i==="err"&&m.jsx("span",{className:"err-tag",children:"error"})]}),m.jsx("pre",{children:e.endedAt==null?"(waiting…)":r_(e.response??e.errorPreview)})]})]})]})})}const iu=18,s_=26,CL=12;function jL(e){return TL(e.nodeInternals.values())}function TL(e){const t=new Map;for(const o of e){if(o.type!=="agent")continue;const a=o.data;if(!(a!=null&&a.sessionId)||a.exitAt!=null||o.width==null||o.height==null)continue;const u=o.position.x,c=o.position.y,f=u+o.width,p=c+o.height,d=t.get(a.sessionId);d?(d.minX=Math.min(d.minX,u),d.minY=Math.min(d.minY,c),d.maxX=Math.max(d.maxX,f),d.maxY=Math.max(d.maxY,p),a.kind==="root"&&(d.label=i_(a)??d.label)):t.set(a.sessionId,{minX:u,minY:c,maxX:f,maxY:p,label:i_(a)??a.sessionId})}const r=new Map;for(const o of t.values())r.set(o.label,(r.get(o.label)??0)+1);const i=[];for(const[o,a]of t){const c=(r.get(a.label)??0)>1?`${a.label} · ${RL(o)}`:a.label;i.push({sessionId:o,label:c,x:a.minX-iu,y:a.minY-iu-s_,w:a.maxX-a.minX+iu*2,h:a.maxY-a.minY+iu*2+s_})}return i}function RL(e){const t=e.match(/[a-zA-Z0-9]{4}/);return t?t[0]:e.slice(0,4)}function i_(e){if(e.kind==="root")return e.label}function AL(){const{x:e,y:t,zoom:r}=kC(),i=Oa(),o=Ke(jL,IL);if(o.length<=1)return null;const a=c=>{try{const f=i.getNodes().filter(p=>{const d=p.data;return(d==null?void 0:d.sessionId)===c});if(f.length===0)return;i.fitView({padding:.3,duration:500,nodes:f})}catch{}},u={transform:`translate(${e}px, ${t}px) scale(${r})`};return m.jsx("div",{className:"session-clusters",style:u,children:o.map(c=>{const f=uy(c.sessionId),p={position:"absolute",left:c.x,top:c.y,width:c.w,height:c.h,"--session-hue":f},d={position:"absolute",left:c.x+16,top:c.y-CL,transform:`scale(${Math.min(1,r)/(r||1)})`,transformOrigin:"left top","--session-hue":f};return m.jsxs(ue.Fragment,{children:[m.jsx("div",{className:"cluster-card",style:p,"aria-hidden":!0}),m.jsx("button",{type:"button",className:"cluster-label",style:d,title:`Fit view to ${c.label} · drag the wrapper to move the whole session`,onClick:()=>a(c.sessionId),children:c.label})]},c.sessionId)})})}function IL(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],o=t[r];if(i.sessionId!==o.sessionId||i.label!==o.label||i.x!==o.x||i.y!==o.y||i.w!==o.w||i.h!==o.h)return!1}return!0}function ML({data:e}){return m.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const La={exec:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},shell:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},exec_command:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},shell_command:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},write_stdin:{category:"shell",emoji:"💻",label:"stdin",shell:!0},wait:{category:"shell",emoji:"⏳",label:"wait",shell:!0},apply_patch:{category:"file",emoji:"🩹",label:"Edit"},update_plan:{category:"task",emoji:"📋",label:"Plan"},run:{category:"web",emoji:"🌐",label:"Web"}},OL=Object.fromEntries(Object.entries(La).map(([e,t])=>[e,t.category])),PL=Object.fromEntries(Object.entries(La).map(([e,t])=>[e,t.emoji])),LL=Object.fromEntries(Object.entries(La).map(([e,t])=>[e,t.label])),$L=new Set(Object.keys(La)),qL=new Set(Object.entries(La).filter(([,e])=>e.shell).map(([e])=>e)),o_={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",WebFetch:"web",WebSearch:"web",Task:"agent",Agent:"agent",TodoWrite:"task",TaskCreate:"task",TaskUpdate:"task",TaskList:"task",TaskGet:"task",TaskOutput:"task",TaskStop:"task",EnterPlanMode:"plan",ExitPlanMode:"plan",AskUserQuestion:"plan",Skill:"plan",Workflow:"plan",...OL};function BC(e){return e.startsWith("mcp__")?"mcp":Object.hasOwn(o_,e)?o_[e]:"other"}const DL=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,FL=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function zL(e){if(typeof e!="string"||!e)return null;const t=DL.exec(e);if(t){const i=BL(t[2]);if(i.trim())return i}const r=FL.exec(e);return r?r[1]:null}function BL(e){return e.replace(/\\(["'`\\nrt])/g,(t,r)=>r==="n"?`
|
|
64
|
-
`:r==="r"?"\r":r==="t"?" ":r)}const UC=600,UL=4,HL=36,$v=16,WL=60,VL=6,a_=220,l_=96,GL=28,u_={Read:"📖",Write:"💾",Edit:"✏️",MultiEdit:"🔧",Glob:"🗺️",Grep:"🔎",Bash:"⚡",PowerShell:"💻",LS:"📂",Task:"🤖",Agent:"🤖",TodoWrite:"📋",TaskCreate:"📋",TaskUpdate:"📝",TaskList:"🗂️",TaskGet:"🗂️",TaskOutput:"📤",TaskStop:"🛑",WebFetch:"🌐",WebSearch:"🔭",ToolSearch:"🧰",NotebookEdit:"📓",EnterPlanMode:"🧭",ExitPlanMode:"🏁",AskUserQuestion:"❓",ScheduleWakeup:"⏰",CronCreate:"⏰",CronList:"📅",CronDelete:"🗑️",Skill:"🎯",Workflow:"🎬",Monitor:"📡",PushNotification:"🔔",RemoteTrigger:"📡",...PL};function c_(e){return e.startsWith("mcp__")?"🔌":Object.hasOwn(u_,e)?u_[e]:"✨"}const d_={git:"🐙",gh:"🐙",glab:"🐙",npm:"📦",pnpm:"📦",yarn:"📦",bun:"📦",brew:"🍺",node:"🟢",deno:"🟢",python:"🐍",python3:"🐍",py:"🐍",pip:"🐍",pip3:"🐍",uv:"🐍",ruby:"💎",bundle:"💎",gem:"💎",cargo:"🦀",rustc:"🦀",rustup:"🦀",go:"🐹",docker:"🐳","docker-compose":"🐳",podman:"🐳",kubectl:"☸️",helm:"☸️",k9s:"☸️",grep:"🔎",rg:"🔎",ag:"🔎",ack:"🔎",find:"🔍",fd:"🔍",locate:"🔍",which:"🔍",ls:"📂",dir:"📂",tree:"📂",cat:"📄",head:"📄",tail:"📄",less:"📄",more:"📄",bat:"📄",cp:"📋",mv:"✂️",rm:"🗑️",rmdir:"🗑️",mkdir:"📁",touch:"📁",sed:"✏️",awk:"✏️",tr:"✏️",curl:"🌐",wget:"🌐",http:"🌐",httpie:"🌐",ssh:"🔐",scp:"🔐",rsync:"🔐",ping:"📡",make:"🔨",cmake:"🔨",ninja:"🔨",bazel:"🔨",just:"🔨",terraform:"🏗️",ansible:"📕",pulumi:"🏗️",ps:"📊",top:"📊",htop:"📊",btm:"📊",kill:"💀",pkill:"💀",systemctl:"⚙️",service:"⚙️",tar:"🗜️",zip:"🗜️",unzip:"🗜️",gzip:"🗜️","7z":"🗜️",vim:"📝",nvim:"📝",nano:"📝",emacs:"📝",code:"📝",jq:"🪺",yq:"🪺",echo:"💬",printf:"💬",ffmpeg:"🎞️",ffprobe:"🎞️",imagemagick:"🖼️",convert:"🖼️","Get-ChildItem":"📂","Get-Content":"📄","Set-Content":"💾","Out-File":"💾","Add-Content":"💾","Set-Location":"📍","Get-Location":"📍","Get-Process":"📊","Start-Process":"▶️","Stop-Process":"💀","Invoke-WebRequest":"🌐","Invoke-RestMethod":"🌐","New-Item":"📁","Remove-Item":"🗑️","Copy-Item":"📋","Move-Item":"✂️","Test-Path":"🔍","Where-Object":"🔎","ForEach-Object":"🔁","Select-Object":"🎯","Measure-Object":"📊","Get-Service":"⚙️","Restart-Service":"⚙️","ConvertTo-Json":"🪺","ConvertFrom-Json":"🪺"};function HC(e){if(!e)return null;let t=e.trim();if(!t)return null;const r=t.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(r)return HC(r[1]);for(;;){const a=t.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!a)break;t=t.slice(a[0].length)}t=t.replace(/^sudo(?:\s+-\S+)*\s+/,""),t=t.replace(/^(?:time|nohup|xargs)\s+/,"");const i=t.match(/^([^\s|;&<>(]+)/);if(!i)return null;let o=i[1];return o=o.replace(/^.*[/\\]/,""),o=o.replace(/\.(exe|cmd|bat|ps1)$/i,""),o||null}function YL(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const r=zL(t.script);if(r)return r}if(typeof t.cmd=="string")return t.cmd;if(typeof t.command=="string")return t.command;if(Array.isArray(t.command)&&t.command.every(r=>typeof r=="string")){const r=t.command;if(/powershell|cmd|bash|sh(\.exe)?$/i.test(r[0]??"")){const i=r.findIndex(o=>/^(-Command|-c)$/i.test(o));if(i>=0&&i+1<r.length)return r[i+1]}return r.join(" ")}return typeof t.script=="string"?t.script:null}const KL=new Set(["Bash","PowerShell",...qL]),XL=$L;function QL(e,t){return XL.has(e)||e.startsWith("mcp__")?Math.max(l_,34+t.length*7.5):l_}function ZL(e,t){if(!KL.has(e))return null;const r=YL(t);if(!r)return null;const i=HC(r);return i?{emoji:Object.hasOwn(d_,i)?d_[i]:"⚙️",label:i,category:"shell",detail:r}:null}const JL=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),f_={ts:"🟦",tsx:"🟦",d:"🟦",js:"🟨",jsx:"🟨",mjs:"🟨",cjs:"🟨",py:"🐍",pyi:"🐍",ipynb:"📓",rs:"🦀",go:"🐹",rb:"💎",erb:"💎",java:"☕",kt:"☕",scala:"☕",gradle:"☕",cs:"🔷",fs:"🔷",php:"🐘",swift:"🦅",c:"🇨",cpp:"🇨",cc:"🇨",h:"🇨",hpp:"🇨",md:"📝",mdx:"📝",rst:"📝",json:"🪺",json5:"🪺",jsonl:"🪺",yaml:"⚙️",yml:"⚙️",toml:"⚙️",ini:"⚙️",conf:"⚙️",cfg:"⚙️",xml:"📰",html:"🌐",htm:"🌐",vue:"🌐",svelte:"🌐",css:"🎨",scss:"🎨",sass:"🎨",less:"🎨",sh:"⚡",bash:"⚡",zsh:"⚡",fish:"⚡",ps1:"⚡",txt:"📄",log:"📄",out:"📄",csv:"📊",tsv:"📊",xlsx:"📊",xls:"📊",pdf:"📕",png:"🖼️",jpg:"🖼️",jpeg:"🖼️",gif:"🖼️",webp:"🖼️",svg:"🖼️",ico:"🖼️",mp4:"🎬",mov:"🎬",avi:"🎬",mkv:"🎬",webm:"🎬",mp3:"🎵",wav:"🎵",ogg:"🎵",flac:"🎵",zip:"🗜️",tar:"🗜️",gz:"🗜️",bz2:"🗜️","7z":"🗜️",xz:"🗜️",rar:"🗜️",env:"🔐",lock:"🔐",pem:"🔐",key:"🔐",crt:"🔐",sql:"🗄️",db:"🗄️",sqlite:"🗄️",parquet:"🗄️"},h_={dockerfile:"🐳",makefile:"🔨",rakefile:"💎","package.json":"📦","pnpm-lock.yaml":"📦","yarn.lock":"📦","cargo.toml":"🦀","cargo.lock":"🦀","go.mod":"🐹","go.sum":"🐹","pyproject.toml":"🐍","requirements.txt":"🐍","readme.md":"📖",readme:"📖",license:"📜",".gitignore":"🐙",".gitattributes":"🐙",".env":"🔐",".dockerignore":"🐳"};function e$(e){const r=e.replace(/\\/g,"/").replace(/\/+$/,""),i=r.lastIndexOf("/");return i>=0?r.slice(i+1):r}function t$(e){const t=e.toLowerCase();if(Object.hasOwn(h_,t))return h_[t];if(t.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(t))return"🧪";const r=t.lastIndexOf(".");if(r>0&&r<t.length-1){const i=t.slice(r+1);if(Object.hasOwn(f_,i))return f_[i]}return"📄"}function n$(e,t){if(!t||typeof t!="object")return null;const r=t;if(e==="apply_patch"&&typeof r.patch=="string"){const i=r.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return i?i[1].trim():null}return typeof r.file_path=="string"?r.file_path:typeof r.notebook_path=="string"?r.notebook_path:typeof r.path=="string"?r.path:e==="Glob"&&typeof r.pattern=="string"?r.pattern:null}function r$(e,t){if(!JL.has(e))return null;const r=n$(e,t);if(!r)return null;const i=e$(r);return i?{emoji:e==="LS"?"📂":t$(i),label:i,category:"file",detail:r}:null}const p_={github:{emoji:"🐙",name:"GitHub"},git:{emoji:"🐙",name:"Git"},gitlab:{emoji:"🦊",name:"GitLab"},slack:{emoji:"💬",name:"Slack"},discord:{emoji:"💬",name:"Discord"},linear:{emoji:"📐",name:"Linear"},jira:{emoji:"🅹",name:"Jira"},atlassian:{emoji:"🅰️",name:"Atlassian"},notion:{emoji:"📓",name:"Notion"},asana:{emoji:"📋",name:"Asana"},intercom:{emoji:"💬",name:"Intercom"},figma:{emoji:"🎨",name:"Figma"},gmail:{emoji:"📧",name:"Gmail"},calendar:{emoji:"📅",name:"Calendar"},drive:{emoji:"☁️",name:"Drive"},zoom:{emoji:"📹",name:"Zoom"},spotify:{emoji:"🎵",name:"Spotify"},youtube:{emoji:"📺",name:"YouTube"},ccd_session:{emoji:"📡",name:"Session"},ccd_directory:{emoji:"📂",name:"Directory"},ccd_session_mgmt:{emoji:"📡",name:"Sessions"},mcp_registry:{emoji:"🧰",name:"Registry"},"computer-use":{emoji:"🖱️",name:"Computer"},"claude-in-chrome":{emoji:"🌐",name:"Chrome"},"claude-preview":{emoji:"👀",name:"Preview"},"scheduled-tasks":{emoji:"⏰",name:"Scheduler"},visualize:{emoji:"🎨",name:"Visualize"},"plugin-design-asana":{emoji:"📋",name:"Asana"},"plugin-design-atlassian":{emoji:"🅰️",name:"Atlassian"},"plugin-design-figma":{emoji:"🎨",name:"Figma"},"plugin-design-intercom":{emoji:"💬",name:"Intercom"},"plugin-design-linear":{emoji:"📐",name:"Linear"},"plugin-design-notion":{emoji:"📓",name:"Notion"},"plugin-design-slack":{emoji:"💬",name:"Slack"}};function WC(e){if(!e.startsWith("mcp__"))return null;const t=e.slice(5),r=t.indexOf("__");return r<=0?{server:t,method:""}:{server:t.slice(0,r),method:t.slice(r+2)}}function s$(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t^e.charCodeAt(r);return Math.abs(t)%360}function VC(e){const t=e.toLowerCase();return Object.hasOwn(p_,t)?p_[t]:void 0}function i$(e,t){const r=WC(e);if(!r)return null;const{server:i,method:o}=r;if(!o)return null;const a=VC(i);return{emoji:(a==null?void 0:a.emoji)??"🔌",label:o,category:"mcp",detail:a?`${a.name} · ${o}`:`${i} · ${o}`}}function o$(e,t){return ZL(e,t)??r$(e,t)??i$(e)}const m_=LL;function a$(e){const t=WC(e);if(t){const i=VC(t.server);return i?{emoji:i.emoji,label:i.name}:{emoji:"🔌",label:t.server,hue:s$(t.server)}}const r=Object.hasOwn(m_,e)?m_[e]:"";return r?{emoji:c_(e),label:r}:{emoji:c_(e),label:e}}function l$(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function u$(e,t,r){if(r==null)return 1;const i=t-r;return i<0?1:Math.max(0,1-i/UC)}function c$(e,t){const r=[],i=new Set;for(let o=e.length-1;o>=0&&r.length<t;o--){const a=e[o];i.has(a.id)||(i.add(a.id),r.push(a))}return r.reverse()}function d$(e,t,r,i,o,a){const u=[];for(const c of e.values()){if(!t.has(c.id)||c.exitAt!=null&&a-c.exitAt>UC)continue;const f=i.get(c.id)??r.get(c.id);if(!f)continue;const p=c$(c.tools,UL);if(p.length===0)continue;const d=c.exitAt??null,g=o.get(c.id),y=Math.max((g==null?void 0:g.width)??a_,a_),w=(g==null?void 0:g.height)??130,E=f.x,_=f.y,b=E+y,S=_+w/2;p.forEach((k,N)=>{const j=N*HL,A=E+y+WL,M=_+VL+j,P=u$(k,a,d),O=k.inputPreview??"",D=l$(k),L=P<.999,U=a$(k.name);u.push({id:`${c.id}::${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:U.label,emoji:U.emoji,status:D,category:BC(k.name),mcpHue:U.hue,inputPreview:O,fade:P,fading:L,worldX:A,worldY:M,anchorX:b,anchorY:S,spawnDx:b-A,spawnDy:S-(M+$v)});const V=o$(k.name,k.input);if(V){const z=QL(k.name,U.label),C=A+z+GL,F=M,$=A+z,re=M+$v;u.push({id:`sub:${c.id}::${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:V.label,emoji:V.emoji,isSub:!0,status:D,category:V.category,inputPreview:V.detail??O,fade:P,fading:L,worldX:C,worldY:F,anchorX:$,anchorY:re,spawnDx:$-C,spawnDy:0})}})}return u}function f$({agents:e,visibleAgentIds:t,positions:r,pinned:i,measured:o,dimUnmatched:a,spotlight:u,hiddenCategories:c,now:f,onOpenTool:p}){const d=d$(e,t,r,i,o,f),g=c&&c.size>0?d.filter(y=>!c.has(y.category)):d;return m.jsx(h$,{bursts:g,dimUnmatched:a,spotlight:u,onOpenTool:p})}function h$({bursts:e,dimUnmatched:t,spotlight:r,onOpenTool:i}){const{x:o,y:a,zoom:u}=kC();return m.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[m.jsx("svg",{className:"tool-bursts-svg",children:e.map(c=>{const f=c.anchorX*u+o,p=c.anchorY*u+a,d=(c.worldX+6)*u+o,g=(c.worldY+$v)*u+a,y=f+(d-f)*.55,w=t!=null&&!t.has(c.agentId),E=r!=null&&!r.has(c.agentId),_=c.fade*(w||E?.14:1);return m.jsx("path",{d:`M ${f} ${p} Q ${y} ${p}, ${d} ${g}`,className:`tool-conn status-${c.status}${c.fading?" fading":""}`,opacity:_},`l:${c.id}`)})}),e.map(c=>{const f=c.worldX*u+o,p=c.worldY*u+a,d={left:`${f}px`,top:`${p}px`,transform:`scale(${u})`,transformOrigin:"left top","--spawn-dx":`${c.spawnDx}px`,"--spawn-dy":`${c.spawnDy}px`},g=c.isSub?`${c.toolName} · ${c.name}`:c.toolName,y=c.inputPreview?`${g} · ${c.inputPreview}`:g,w=i!=null,E=c.mcpHue!=null?{"--mcp-hue":c.mcpHue}:{},_=t!=null&&!t.has(c.agentId),b=r!=null&&!r.has(c.agentId),S=_||b?" dim":"";return m.jsx("div",{className:"tool-burst-wrap",style:d,children:m.jsxs("div",{className:`tool-burst cat-${c.category}${c.mcpHue!=null?" mcp-hue":""} status-${c.status}${c.fading?" fading":""}${w?" clickable":""}${c.isSub?" sub":""}${S}`,style:E,title:y,onClick:w?()=>i(c.toolId):void 0,children:[m.jsx("span",{className:"tb-emoji",children:c.emoji}),m.jsx("span",{className:"tb-name",children:c.name}),c.status==="inflight"&&m.jsx("span",{className:"tb-spin"}),c.status==="done"&&m.jsx("span",{className:"tb-mark done",children:"✓"}),c.status==="err"&&m.jsx("span",{className:"tb-mark err",children:"×"})]})},c.id)})]})}function fy({cost:e,size:t="md"}){const r=e.total;if(r<=0)return null;const i=(a,u,c)=>{if(a<=0)return null;const f=a/r*100;return m.jsx("span",{className:`cb-seg ${u}`,style:{width:`${f}%`},title:`${c}: ${qe(a)} (${f.toFixed(0)}%)`},u)},o=t==="lg";return m.jsxs("div",{className:o?"cost-bar cost-bar-lg":"cost-bar",role:"img","aria-label":"Cost breakdown",children:[i(e.input,"cb-input","input"),i(e.output,"cb-output","output"),i(e.cacheRead,"cb-cache-r","cache read"),i(e.cacheWrite,"cb-cache-w","cache write")]})}function p$({state:e,sessionId:t,onClose:r}){const i=R.useMemo(()=>m$(e,t),[e,t]),o=R.useRef(null),a=wo(r,{focusRef:o});return i?m.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:m.jsxs("div",{ref:a,className:"modal session-summary",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[m.jsxs("div",{className:"modal-head",children:[m.jsxs("div",{className:"modal-title",children:[m.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),m.jsx("span",{id:"ss-title",className:"modal-tool-name",title:i.cwd??i.sessionId,children:i.label}),m.jsxs("span",{className:"modal-tool-id",children:["· ",i.sessionId.slice(0,8)]})]}),m.jsxs("div",{className:"modal-actions",children:[m.jsx("span",{className:"modal-dur",title:"Total wall time",children:i.durationLabel}),m.jsx("button",{type:"button",ref:o,className:"btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),m.jsxs("div",{className:"modal-body",children:[m.jsxs("section",{className:"ss-hero",children:[m.jsxs("div",{className:"ss-hero-left",children:[m.jsx("div",{className:"ss-cost-label",children:"total spend"}),m.jsx("div",{className:"ss-cost",children:qe(i.cost.total)}),i.modelChips.length>0&&m.jsx("div",{className:"ss-models",children:i.modelChips.map(u=>m.jsx("span",{className:"model-chip",title:u,children:Rs(u)},u))})]}),m.jsx("div",{className:"ss-hero-right",children:i.cost.total>0&&m.jsxs(m.Fragment,{children:[m.jsx(fy,{cost:i.cost,size:"lg"}),m.jsxs("div",{className:"ss-cost-legend",children:[m.jsxs("span",{className:"ssl ssl-in",children:["input ",m.jsx("b",{children:qe(i.cost.input)})]}),m.jsxs("span",{className:"ssl ssl-out",children:["output ",m.jsx("b",{children:qe(i.cost.output)})]}),m.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",m.jsx("b",{children:qe(i.cost.cacheRead)})]}),m.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",m.jsx("b",{children:qe(i.cost.cacheWrite)})]})]})]})})]}),m.jsxs("section",{className:"ss-stats",children:[m.jsx(to,{label:"agents",value:i.agentCount}),m.jsx(to,{label:"subagents",value:i.subagentCount}),m.jsx(to,{label:"tool calls",value:i.toolCount}),m.jsx(to,{label:"prompts",value:i.promptCount}),m.jsx(to,{label:"tokens",value:i.tokensSum.toLocaleString()}),i.errCount>0&&m.jsx(to,{label:"errors",value:i.errCount,tone:"err"})]}),i.topTools.length>0&&m.jsxs("section",{className:"modal-section",children:[m.jsx("h4",{children:"Most-used tools"}),m.jsx("div",{className:"ss-top-tools",children:i.topTools.map(([u,c])=>m.jsxs("div",{className:"ss-tt",children:[m.jsx("span",{className:"ss-tt-name",children:u}),m.jsx("span",{className:"ss-tt-bar",children:m.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${c/i.topTools[0][1]*100}%`}})}),m.jsx("span",{className:"ss-tt-count",children:c})]},u))})]}),i.firstPrompt&&m.jsxs("section",{className:"modal-section",children:[m.jsx("h4",{children:"Opening prompt"}),m.jsx("div",{className:"ss-prompt",children:i.firstPrompt})]})]})]})}):null}function to({label:e,value:t,tone:r}){return m.jsxs("div",{className:`ss-stat${r?` tone-${r}`:""}`,children:[m.jsx("div",{className:"ss-stat-value",children:t}),m.jsx("div",{className:"ss-stat-label",children:e})]})}function m$(e,t){const r=e.agents.get(t);if(!r)return null;const i=[];for(const N of e.agents.values())N.sessionId===t&&i.push(N);if(i.length===0)return null;const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},a=new Set,u=new Map;let c=0,f=0,p=0,d=0,g=0,y,w=1/0,E=0;for(const N of i){const j=dn(N.usage,N.model);o.input+=j.input,o.output+=j.output,o.cacheRead+=j.cacheRead,o.cacheWrite+=j.cacheWrite,o.total+=j.total,N.model&&a.add(N.model),N.kind==="subagent"&&g++,f+=N.prompts.length,!y&&N.prompts.length>0&&(y=N.prompts[0].text),p+=N.usage.inputTokens+N.usage.outputTokens,c+=N.toolCount,w=Math.min(w,N.startedAt),E=Math.max(E,N.endedAt??Date.now());for(const A of N.tools)u.set(A.name,(u.get(A.name)??0)+1),A.ok===!1&&d++}const _=Math.max(0,E-w),b=Math.floor(_/1e3),S=b<60?`${b}s`:b<3600?`${Math.floor(b/60)}m ${String(b%60).padStart(2,"0")}s`:`${Math.floor(b/3600)}h ${Math.floor(b%3600/60)}m`,k=Array.from(u.entries()).sort((N,j)=>j[1]-N[1]).slice(0,5);return{sessionId:t,label:r.label||r.cwdBasename||"session",cwd:r.cwd,durationLabel:S,cost:o,modelChips:Array.from(a),agentCount:i.length,subagentCount:g,toolCount:c,promptCount:f,tokensSum:p,errCount:d,topTools:k,firstPrompt:y}}function hy(e){return(e==null?void 0:e.kind)==="permission"}function g$(e){const t=[];for(const r of e)r.kind==="root"&&hy(r.waiting)&&t.push({id:r.id,label:r.label,waiting:r.waiting});return t.sort((r,i)=>r.waiting.since-i.waiting.since)}function v$(e){const t=new Set;for(const r of e)r.state==="active"&&t.add(r.sessionId);return t.size}function g_(e){return e.waiting?hy(e.waiting)?0:1:e.state==="active"?2:3}function y$(e,t){const r=[];for(const i of e.agents.values()){if(i.kind!=="root")continue;let o=i.toolCount,a=dn(i.usage,i.model).total,u=i.endedAt??i.startedAt;for(const c of e.agents.values()){if(c.sessionId!==i.sessionId||c.kind==="root")continue;o+=c.toolCount,a+=dn(c.usage,c.model).total;const f=c.endedAt??c.startedAt;f>u&&(u=f)}r.push({sessionId:i.sessionId,label:i.label||i.cwdBasename||"session",cwdBasename:i.cwdBasename,state:i.state,waiting:i.waiting,modelId:i.model,toolCount:o,cost:a,startedAt:i.startedAt,lastActivity:u})}return r.sort((i,o)=>{const a=g_(i),u=g_(o);return a!==u?a-u:i.waiting&&o.waiting?i.waiting.since-o.waiting.since:o.lastActivity-i.lastActivity}),r}function v_(e,t,r){const i=(t??r)-e;if(i<1e3)return"<1s";const o=Math.floor(i/1e3);if(o<60)return`${o}s`;const a=Math.floor(o/60);return a<60?`${a}m`:`${Math.floor(a/60)}h ${a%60}m`}function w$({state:e,now:t,selectedIds:r,onSelect:i,onClose:o}){const a=R.useMemo(()=>y$(e),[e,e.lastSeq,t]),u=a.filter(f=>f.state==="active").length,c=a.filter(f=>hy(f.waiting)).length;return m.jsxs("aside",{className:"session-list",id:"session-list","aria-label":"Sessions",children:[m.jsxs("div",{className:"sl-header",children:[m.jsxs("h2",{children:["Sessions ",m.jsx("span",{className:"sl-count",children:a.length})]}),c>0&&m.jsxs("span",{className:"sl-waiting-count",children:[c," waiting"]}),u>0&&m.jsxs("span",{className:"sl-live-count",children:[u," live"]}),m.jsx("button",{className:"btn icon-btn sl-close",onClick:o,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),m.jsxs("div",{className:"sl-rows",children:[a.length===0&&m.jsx("div",{className:"sl-empty",children:"No sessions yet."}),a.map(f=>{const p=r.has(f.sessionId);return m.jsxs("button",{type:"button",className:`sl-row state-${f.state}${p?" selected":""}`,onClick:()=>i(f.sessionId),title:`Focus ${f.label}`,children:[m.jsx("span",{className:`sl-dot state-${f.state}`,"aria-hidden":!0}),m.jsx("span",{className:"vis-hidden",children:dy(f.state)}),m.jsxs("div",{className:"sl-row-body",children:[m.jsxs("div",{className:"sl-row-head",children:[m.jsx("span",{className:"sl-label",children:f.label}),f.modelId&&m.jsx("span",{className:"model-chip",title:f.modelId,children:Rs(f.modelId)})]}),m.jsxs("div",{className:"sl-row-meta",children:[m.jsxs("span",{title:"tool calls",children:[m.jsx("b",{children:f.toolCount})," tools"]}),f.cost>0&&m.jsx("span",{className:"sl-cost",title:"total spend",children:m.jsx("b",{children:qe(f.cost)})}),f.waiting?m.jsxs("span",{className:"sl-waiting",title:`${zu(f.waiting)}
|
|
65
|
-
Blocked since ${new Date(f.waiting.since).toLocaleTimeString()} · started ${new Date(f.startedAt).toLocaleString()}`,children:["waiting ",v_(f.waiting.since,void 0,t)]}):m.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(f.startedAt).toLocaleString()}`,children:v_(f.startedAt,f.state==="active"?void 0:f.lastActivity,t)})]})]})]},f.sessionId)})]})]})}const Gt="ccdeck";function GC(e){const t=Math.max(0,e);return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function qv(e){return GC(Math.floor(e/1e3))}function YC(e,t){const r=e-t;if(r<=0)return null;const i=Math.floor(r/86400),o=Math.floor(r%86400/3600),a=Math.floor(r%3600/60);return i>0?`${i}d ${o}h`:o>0?`${o}h ${a}m`:`${a}m`}function x$(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function _$(e,t,r){const i=new Date(e),o=qv(t-e);return{label:x$(i,new Date(t))?o:`${o} · ${i.toLocaleDateString(r,{month:"short",day:"numeric"})}`,title:i.toLocaleString(r,{dateStyle:"medium",timeStyle:"medium"})}}function y_(e,t){if(!e)return null;const r=t-Math.floor(e/1e3);return r<10?"just now":r<60?`${r}s ago`:r<3600?`${Math.floor(r/60)}m ago`:`${Math.floor(r/3600)}h ago`}function b$(e){return e==="claude-swap"?"Read from claude-swap's last collection — costs no request against your usage-endpoint budget":e==="api"?"Fetched from Anthropic's usage endpoint, at most once every 5 minutes":e==="cli"?"Parsed from `claude /usage`, at most once every 5 minutes":"Last update"}const Xd="__unknown__";function S$(e,t,r,i){const o=Math.max(0,t-i),a=Math.max(0,r-o);if(a<120)return null;const u=Math.min(100,a/r*100),c=e-u;if(Math.abs(c)<3)return{label:"on pace",color:"var(--ok)",expectedPct:u,isDeficit:!1};if(c>0){const f=100-e,p=a>0?e/a:0,d=p>0?f/p:1/0,g={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(d<o&&d<86400){const y=Math.floor(d/3600),w=Math.floor(d%3600/60);g.runsOutIn=y>0?`${y}h ${w}m`:`${w}m`}return g}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function li({pct:e,label:t,reset:r,resetAt:i,windowSec:o,limitReached:a,nowSec:u}){const c=Math.min(100,Math.max(0,e)),p=a||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",d=c===0?"< 1%":`${c}%`,g=c===0?2:c,y=i?YC(i,u):null,w=i&&o?S$(c,i,o,u):null;return m.jsxs("div",{className:"qb-row",children:[m.jsxs("div",{className:"qb-meta",children:[m.jsxs("span",{className:"qb-label",children:[t,a&&m.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),m.jsx("span",{className:"qb-pct",style:{color:p},children:d})]}),m.jsxs("div",{className:"qb-track",children:[m.jsx("div",{className:"qb-fill",style:{width:`${g}%`,background:p,opacity:c===0?.4:1}}),w&&m.jsx("div",{className:"qb-pace-marker",style:{left:`${w.expectedPct}%`,background:w.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(w.expectedPct)}% by now`})]}),m.jsxs("div",{className:"qb-reset-row",children:[y?m.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):r?m.jsxs("span",{className:"qb-reset",children:["resets ",r]}):null,w&&m.jsx("span",{className:"qb-pace",style:{color:w.color},children:w.runsOutIn?`runs out in ${w.runsOutIn}`:w.label})]})]})}const k$=6e4;function E$(e){const[t,r]=R.useState(null),[i,o]=R.useState(!1),a=R.useRef(null),u=async(f=!1)=>{f&&o(!0);try{const d=await fetch(f?"/api/quota?refresh=1":"/api/quota");d.ok&&r(await d.json())}catch{}finally{f&&o(!1)}};return R.useEffect(()=>{if(e)return u(!0),a.current=window.setInterval(()=>u(!1),k$),()=>{a.current!=null&&window.clearInterval(a.current)}},[e]),{quota:t,loading:i,refresh:()=>{e&&u(!0)}}}function N$(e){switch(e){case"no_token":return"Run codex login to authenticate.";case"api_key_mode":return"API-key login — ChatGPT quota is only available for codex login.";case"refresh_rejected":return"Codex session expired — run codex login.";case"refresh_failed":return"Couldn't refresh the Codex token — click ↻ to retry.";case"untrusted_base_url":return"chatgpt_base_url in ~/.codex/config.toml is not an https OpenAI host, so the token was not sent.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const KC=6e4;function C$(e){const[t,r]=R.useState(null),[i,o]=R.useState(!1),a=R.useRef(null),u=async(f=!1)=>{f&&o(!0);try{const d=await fetch(f?"/api/codex-quota?refresh=1":"/api/codex-quota");d.ok&&r(await d.json())}catch{}finally{f&&o(!1)}};return R.useEffect(()=>{if(e)return u(!0),a.current=window.setInterval(()=>u(!1),KC),()=>{a.current!=null&&window.clearInterval(a.current)}},[e]),{data:t,loading:i,refresh:()=>{e&&u(!0)}}}function j$(e){const[t,r]=R.useState(null),i=R.useRef(null),o=async()=>{try{const a=await fetch("/api/codex-usage");a.ok&&r(await a.json())}catch{}};return R.useEffect(()=>{if(e)return o(),i.current=window.setInterval(o,KC),()=>{i.current!=null&&window.clearInterval(i.current)}},[e]),{data:t}}function T$({state:e,now:t,providers:r,onClose:i}){var V,z;const{quota:o,loading:a,refresh:u}=E$(r.claude),{data:c,loading:f,refresh:p}=C$(r.codex),{data:d}=j$(r.codex),[g,y]=R.useState(()=>Math.floor(Date.now()/1e3));R.useEffect(()=>{const C=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(C)},[]);const{byModel:w,totalCost:E,totalTokens:_,burnRate:b}=R.useMemo(()=>{const C=new Map,F={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let $=0,re=0,J=0,W=0;for(const q of e.agents.values()){const Q=q.model??Xd,ne=dn(q.usage,q.model),ae=C.get(Q);ae?(ae.inputTokens+=q.usage.inputTokens,ae.outputTokens+=q.usage.outputTokens,ae.cacheReadTokens+=q.usage.cacheReadTokens,ae.cacheCreateTokens+=q.usage.cacheCreateTokens,ae.cost.total+=ne.total,ae.cost.input+=ne.input,ae.cost.output+=ne.output,ae.cost.cacheRead+=ne.cacheRead,ae.cost.cacheWrite+=ne.cacheWrite,ae.agentCount++):C.set(Q,{model:Q,inputTokens:q.usage.inputTokens,outputTokens:q.usage.outputTokens,cacheReadTokens:q.usage.cacheReadTokens,cacheCreateTokens:q.usage.cacheCreateTokens,cost:{...ne},agentCount:1,priced:go(q.model)!=null}),F.total+=ne.total,F.input+=ne.input,F.output+=ne.output,F.cacheRead+=ne.cacheRead,F.cacheWrite+=ne.cacheWrite,$+=q.usage.inputTokens,re+=q.usage.outputTokens,J+=q.usage.cacheReadTokens,W+=q.usage.cacheCreateTokens}const Z=Array.from(C.values()).sort((q,Q)=>Q.cost.total-q.cost.total||Q.inputTokens+Q.outputTokens-(q.inputTokens+q.outputTokens));let I=0,G=0;for(const q of e.agents.values()){if(q.state!=="active")continue;const Q=dn(q.usage,q.model);I+=Q.total,G=Math.max(G,((q.endedAt??t)-q.startedAt)/1e3)}const K=G>0?ju(I,G):null;return{byModel:Z,totalCost:F,totalTokens:{in:$,out:re,cacheR:J,cacheC:W},burnRate:K}},[e,e.lastSeq,t]),S=R.useMemo(()=>{const C=[],F=$=>go($.model)==null?$.usage.inputTokens+$.usage.outputTokens:0;for(const $ of e.agents.values()){if($.kind!=="root")continue;let re=dn($.usage,$.model).total,J=$.usage.inputTokens,W=$.usage.outputTokens,Z=F($);for(const I of e.agents.values())I.sessionId!==$.sessionId||I.kind==="root"||(re+=dn(I.usage,I.model).total,J+=I.usage.inputTokens,W+=I.usage.outputTokens,Z+=F(I));C.push({sessionId:$.sessionId,label:$.label||$.cwdBasename||"session",state:$.state,cost:re,inputTokens:J,outputTokens:W,unpricedTokens:Z})}return C.sort(($,re)=>re.cost-$.cost||re.inputTokens+re.outputTokens-($.inputTokens+$.outputTokens)).slice(0,12)},[e,e.lastSeq]),k=E.total>0,N=_.in+_.out,j=w.filter(C=>C.cost.total>0||C.inputTokens+C.outputTokens>0),A=S.filter(C=>C.cost>0||C.inputTokens+C.outputTokens>0),M=j.some(C=>!C.priced),P=a||f,O=y_(o==null?void 0:o.fetchedAt,g),D=y_(c==null?void 0:c.fetchedAt,g),L=()=>{u(),p()},U=r.claude&&r.codex?"Refresh Claude + Codex quota":r.codex?"Refresh Codex quota":"Refresh Claude quota";return m.jsxs("aside",{className:"usage-panel",id:"usage-panel","aria-label":"Usage",children:[m.jsxs("div",{className:"up-header",children:[m.jsx("h2",{children:"Usage"}),b&&m.jsx("span",{className:"up-rate",children:b}),m.jsxs("div",{className:"up-header-right",children:[(r.claude||r.codex)&&m.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:L,disabled:P,"aria-label":U,title:U,children:P?"…":"↻"}),m.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:i,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),r.claude&&m.jsxs("section",{className:"up-section up-quota-section",children:[m.jsxs("h3",{className:"up-section-title",children:["Claude quota",O&&!a&&m.jsx("span",{className:"up-section-age",title:b$(o==null?void 0:o.source),children:O})]}),o!=null&&o.ok?m.jsxs("div",{className:"up-quota-bars",children:[o.session5hPct!=null&&m.jsx(li,{label:"5-hour window",pct:o.session5hPct,reset:o.session5hReset,resetAt:o.session5hResetAt,windowSec:o.session5hWindowSec,nowSec:g}),o.week7dPct!=null&&m.jsx(li,{label:"7-day window",pct:o.week7dPct,reset:o.week7dReset,resetAt:o.week7dResetAt,windowSec:o.week7dWindowSec,nowSec:g}),o.weekSonnetPct!=null&&m.jsx(li,{label:"Sonnet (7d)",pct:o.weekSonnetPct,nowSec:g}),o.weekOpusPct!=null&&m.jsx(li,{label:"Opus (7d)",pct:o.weekOpusPct,nowSec:g})]}):(o==null?void 0:o.ok)===!1?m.jsxs("div",{className:"up-quota-na",children:[m.jsx("span",{children:"Quota unavailable."}),m.jsxs("span",{className:"up-quota-hint",children:["Run ",m.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):m.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),r.codex&&m.jsxs("section",{className:"up-section up-quota-section",children:[m.jsxs("h3",{className:"up-section-title",children:["Codex quota",(c==null?void 0:c.ok)&&c.planLabel&&m.jsx("span",{className:"up-plan-badge",children:c.planLabel}),D&&!f&&m.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:D})]}),c!=null&&c.ok?m.jsxs("div",{className:"up-quota-bars",children:[(V=c.windows)==null?void 0:V.map(C=>m.jsx(li,{label:C.label,pct:C.pct,reset:C.reset??void 0,resetAt:C.resetAt??void 0,windowSec:C.windowSec??void 0,limitReached:c.limitReached&&C.pct>=100,nowSec:g},C.id)),(z=c.extraWindows)==null?void 0:z.map(C=>m.jsx(li,{label:C.label,pct:C.pct,reset:C.reset??void 0,resetAt:C.resetAt??void 0,windowSec:C.windowSec??void 0,nowSec:g},C.id)),c.creditLimit&&m.jsx(li,{label:`spend cap · $${Math.round(c.creditLimit.used)} of $${Math.round(c.creditLimit.limit)}`,pct:c.creditLimit.usedPct,reset:c.creditLimit.reset??void 0,resetAt:c.creditLimit.resetAt??void 0,limitReached:c.spendControlReached,nowSec:g}),c.creditsBalance&&!c.creditsUnlimited&&m.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",c.creditsBalance,c.overageReached&&" · overage limit reached"]}),c.creditsUnlimited&&m.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),c.resetCredits&&c.resetCredits.availableCount>0&&m.jsxs("div",{className:"up-quota-sub up-reset-credits",title:`Redeem in the Codex CLI or ChatGPT — ${Gt} only reports them`,children:[c.resetCredits.availableCount," rate-limit reset",c.resetCredits.availableCount!==1?"s":""," available",c.resetCredits.nextExpiryAt&&` · expires ${new Date(c.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),c.promo&&m.jsx("div",{className:"up-quota-sub",children:c.promo}),c.partial&&m.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(c==null?void 0:c.ok)===!1?m.jsxs("div",{className:"up-quota-na",children:[m.jsx("span",{children:"Quota unavailable."}),m.jsx("span",{className:"up-quota-hint",children:N$(c.reason)})]}):m.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"}),(d==null?void 0:d.ok)&&d.window7d&&d.window7d.sessionCount>0&&m.jsxs("div",{className:"up-quota-sub",title:`Counted from the rollout files under CODEX_HOME — no network, no account${d.window5h?`
|
|
66
|
-
last 5h: ${Nt(d.window5h.totalTokens)} tokens · ${d.window5h.sessionCount} session${d.window5h.sessionCount!==1?"s":""}`:""}`,children:[Nt(d.window7d.totalTokens)," tokens · ",d.window7d.sessionCount," session",d.window7d.sessionCount!==1?"s":""," (7d)"]})]}),N>0?m.jsxs(m.Fragment,{children:[k&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"up-total",children:[m.jsx("span",{className:"up-total-value",children:qe(E.total)}),m.jsx("span",{className:"up-total-label",children:"total spend"})]}),m.jsx(fy,{cost:E})]}),m.jsxs("div",{className:"up-tokens-row",children:[m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"in"}),Nt(_.in)]}),m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"out"}),Nt(_.out)]}),_.cacheR>0&&m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"cache r"}),Nt(_.cacheR)]}),_.cacheC>0&&m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"cache c"}),Nt(_.cacheC)]})]}),j.length>0&&m.jsxs("section",{className:"up-section",children:[m.jsx("h3",{className:"up-section-title",children:"By model"}),m.jsxs("table",{className:"up-table",children:[m.jsx("thead",{children:m.jsxs("tr",{children:[m.jsx("th",{children:"Model"}),m.jsx("th",{children:"Tokens"}),m.jsx("th",{children:"Cost"})]})}),m.jsx("tbody",{children:j.map(C=>m.jsxs("tr",{children:[m.jsx("td",{className:"up-model-name",title:C.model===Xd?"no model reported yet":C.model,children:C.model===Xd?"unknown":Rs(C.model)}),m.jsx("td",{className:"up-num",children:Nt(C.inputTokens+C.outputTokens)}),C.priced?m.jsx("td",{className:"up-num up-cost-val",children:qe(C.cost.total)}):m.jsx("td",{className:"up-num up-unpriced",children:gu})]},C.model))})]})]}),A.length>0&&m.jsxs("section",{className:"up-section",children:[m.jsx("h3",{className:"up-section-title",children:"By session"}),m.jsx("div",{className:"up-sessions",children:A.map(C=>m.jsxs("div",{className:"up-session-row",children:[m.jsx("span",{className:`sl-dot state-${C.state}`,"aria-hidden":!0}),m.jsx("span",{className:"vis-hidden",children:dy(C.state)}),m.jsx("span",{className:"up-session-label",children:C.label}),m.jsx("span",{className:"up-session-tokens",children:Nt(C.inputTokens+C.outputTokens)}),C.cost>0?m.jsxs("span",{className:"up-session-cost",title:C.unpricedTokens>0?`${Nt(C.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[qe(C.cost),C.unpricedTokens>0?"+":""]}):m.jsx("span",{className:"up-session-cost up-unpriced",children:gu})]},C.sessionId))})]}),M&&m.jsxs("div",{className:"up-hint",children:["“",gu,"” means this build holds no published rate for that model — those tokens are counted above and their dollars are not."]})]}):m.jsxs("div",{className:"up-empty",children:["No usage data yet.",m.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const
|
|
67
|
-
`);return m.jsxs("span",{className:"sysmeter-wrap",children:[m.jsxs("button",{type:"button",ref:o,className:"sysmeter",title:E,"aria-label":"Toggle machine detail","aria-expanded":r,"aria-controls":r?"system-panel":void 0,onClick:()=>i(_=>!_),children:[m.jsxs("span",{className:"sm-box","aria-hidden":!0,children:[m.jsxs("span",{className:"sm-graphic",children:[m.jsx("svg",{className:"sm-spark",width:ca,height:no,viewBox:`0 0 ${ca} ${no}`,children:g.map((_,b)=>{const S=y+b,k=Math.max(1,_/100*no),N=.32+.68*((b+1)/g.length);return m.jsx("rect",{x:S*w,y:no-k,width:Math.max(.8,w-.7),height:k,rx:.5,fill:"var(--accent)",opacity:N},S)})}),m.jsx("span",{className:"sm-ram",children:m.jsx("span",{className:`sm-ram-fill${d?" warn":""}`,style:{transform:`scaleX(${Math.max(2,f.usedPct)/100})`}})})]}),m.jsxs("span",{className:"sm-read",children:[m.jsx("b",{children:a.toFixed(0)}),m.jsx("i",{children:"·"}),m.jsx("b",{children:f.usedPct.toFixed(0)})]})]}),m.jsxs("span",{className:"sm-sr",children:["CPU ",a.toFixed(0)," percent, memory ",f.usedPct.toFixed(0)," percent used"]})]}),r&&m.jsx(z$,{sys:t,usageOpen:e,onClose:()=>{var _;i(!1),(_=o.current)==null||_.focus()}})]})}function z$({sys:e,usageOpen:t,onClose:r}){const i=D$(!0),{memory:o,swap:a,perCore:u,loadavg:c,cores:f,uptimeSec:p,platform:d}=e,g=o?o.total-o.available:0,y=d==="win32"?"Commit":"Swap",w=a&&a.total>0?a.used/a.total*100:0;return m.jsxs("aside",{className:`sysdetail${t?" shifted":""}`,id:"system-panel","aria-label":"Machine detail",children:[m.jsxs("div",{className:"sd-head",children:[m.jsx("span",{className:"sd-title",children:"This machine"}),m.jsxs("span",{className:"sd-sub",children:["up ",$$(p)," · ",f," cores"]}),m.jsx("button",{type:"button",className:"sd-close",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),u&&u.length>0&&m.jsxs("div",{className:"sd-section",role:"group","aria-label":"Cores",children:[m.jsx("div",{className:"sd-h","aria-hidden":!0,children:"Cores"}),m.jsx("div",{className:"sd-cores",style:{"--n":u.length},children:u.map((E,_)=>m.jsx("span",{className:"sd-core",title:`core ${_+1}: ${E}%`,children:m.jsx("span",{className:"sd-core-fill",style:{height:`${Math.max(2,E)}%`}})},_))})]}),m.jsxs("div",{className:"sd-section",role:"group","aria-label":"Memory",children:[m.jsx("div",{className:"sd-h","aria-hidden":!0,children:"Memory"}),o&&m.jsx(x_,{label:"Physical",used:g,total:o.total,pct:o.usedPct,note:`${Ca(o.available)} available`}),a&&a.total>0&&m.jsx(x_,{label:y,used:a.used,total:a.total,pct:w,note:w>=50?"paging to disk":void 0})]}),c&&m.jsxs("div",{className:"sd-section",role:"group","aria-label":"Load average",children:[m.jsx("div",{className:"sd-h","aria-hidden":!0,children:"Load average"}),m.jsx("div",{className:"sd-load",children:c.map((E,_)=>m.jsxs("span",{className:`sd-load-item${E>f?" over":""}`,children:[m.jsx("b",{children:E.toFixed(2)}),m.jsx("span",{children:["1m","5m","15m"][_]})]},_))}),m.jsx("div",{className:"sd-note",children:c[0]>f?`${(c[0]/f).toFixed(1)}× more work queued than cores to run it`:`within ${f} cores`})]}),m.jsxs("div",{className:"sd-section",role:"group","aria-label":"Busiest processes",children:[m.jsx("div",{className:"sd-h","aria-hidden":!0,children:"Busiest processes"}),i==null?m.jsx("div",{className:"sd-note",children:"reading…"}):i.length===0?m.jsx("div",{className:"sd-note",children:"Could not read the process list on this platform."}):m.jsxs("table",{className:"sd-procs",children:[m.jsx("thead",{children:m.jsxs("tr",{children:[m.jsx("th",{children:"cpu"}),m.jsx("th",{children:"mem"}),m.jsx("th",{children:"process"})]})}),m.jsx("tbody",{children:i.map(E=>m.jsxs("tr",{children:[m.jsx("td",{className:"sd-num",children:E.cpu==null?"—":E.cpu.toFixed(0)}),m.jsx("td",{className:"sd-num sd-dim",children:E.mem.toFixed(1)}),m.jsx("td",{className:"sd-proc-name",title:`pid ${E.pid}`,children:E.name})]},E.pid))})]})]})]})}function x_({label:e,used:t,total:r,pct:i,note:o}){const a=i>=90;return m.jsxs("div",{className:"sd-row",children:[m.jsxs("div",{className:"sd-row-head",children:[m.jsx("span",{className:"sd-row-label",children:e}),m.jsxs("span",{className:"sd-row-val",children:[m.jsx("b",{children:Ca(t)})," of ",Ca(r)]})]}),m.jsx("span",{className:"sd-track",children:m.jsx("span",{className:`sd-fill${a?" warn":""}`,style:{transform:`scaleX(${Math.max(1,Math.min(100,i))/100})`}})}),o&&m.jsx("div",{className:"sd-note",children:o})]})}const __=18,B$=1100,ro=(e,t)=>{const r=Math.sin(e*12.9898+t*78.233)*43758.5453;return r-Math.floor(r)},U$=Array.from({length:__},(e,t)=>{const r=-72+144*t/(__-1)+(ro(t,1)-.5)*9,i=(r-90)*(Math.PI/180),o=(54+32*Math.cos(r*Math.PI/180))*(.74+ro(t,2)*.52);return{dx:Math.cos(i)*o,dy:Math.sin(i)*o,rot:(t%2?1:-1)*(100+ro(t,3)*260),delay:Math.round(ro(t,4)*90),dur:760+Math.round(ro(t,5)*260),scale:.8+ro(t,6)*.45,hue:t%4,round:t%3===0}});function b_({anchor:e,lifetimeMs:t=B$}){var a;const[r,i]=R.useState(null),o=typeof window<"u"&&((a=window.matchMedia)==null?void 0:a.call(window,"(prefers-reduced-motion: reduce)").matches);return R.useEffect(()=>{if(o)return;const u=e.current;if(!u)return;const c=u.getBoundingClientRect();i({x:c.left+c.width/2,y:c.top+c.height/2});const f=window.setTimeout(()=>i(null),t);return()=>window.clearTimeout(f)},[e,t,o]),o||!r?null:hM.createPortal(m.jsx("div",{className:"confetti",style:{left:`${r.x}px`,top:`${r.y}px`},"aria-hidden":!0,children:U$.map((u,c)=>m.jsx("span",{className:`confetti-bit${u.round?" round":""}`,"data-hue":u.hue,style:{"--dx":`${u.dx.toFixed(1)}px`,"--dy":`${u.dy.toFixed(1)}px`,"--rot":`${u.rot}deg`,"--s":u.scale.toFixed(2),animationDelay:`${u.delay}ms`,animationDuration:`${u.dur}ms, ${u.dur}ms`}},c))}),document.body)}const QC=new Set(["awaiting_url","awaiting_code","registering"]);function H$(e){return e!=null&&QC.has(e)}function ZC(e){return e!=null&&e!=="done"&&!QC.has(e)}const W$="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",V$="the sign-in did not complete";function G$({state:e,serverError:t,localError:r}){const i=e==="idle";return{title:i?"Sign-in ended":"Sign-in failed",message:r||t||(i?W$:V$)}}const Y$="done";function K$(){let e=!1;return{shouldAnnounce(t){return t!==Y$?(e=!1,!1):e?!1:(e=!0,!0)}}}function my(e,t){return t&&Object.hasOwn(e,t)?e[t]:void 0}const X$={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 ccdeck1:",corrupt:"that share is incomplete — copy the whole thing",wrong_version:`that share was made by a newer ${Gt}`,expired:"that share has expired — make a new one",import_failed:"claude-swap refused the import",bad_value:"an alias can only use letters, numbers, spaces, dots, dashes and underscores, up to 64 characters"},Q$={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"},Z$=`claude-swap could not read the login keychain — start ${Gt} from a Terminal window rather than a background service`;function Dv(e,t){if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(vo(e)))return Z$;const r=my(Q$,e==null?void 0:e.reason);return r||(e==null?void 0:e.reason)||t}function vo(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const J$={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"},e3="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 t3(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const n3="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",r3="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",s3=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),i3=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,o3=/[\\/]_npx[\\/]/i,a3=`the copy of ccusage ${Gt} installed for itself`;function l3(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function u3(e,t){const r=c3(e,t),i=l3(e);switch(e==null?void 0:e.stage){case"npx":return i?`ccusage failed on both of its paths. The managed install failed first — ${i} — and the deck then fell back to npx, where ${da(r)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${da(r)}`;case"managed":return`${a3} failed to run: ${da(r)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${da(r)}`:`the ccusage this deck found on your PATH failed to run: ${da(r)}`;default:return r}}const da=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function c3(e,t){const r=vo(e);if(s3(r)){if(o3.test(r))return r3;if(i3.test(r))return n3}if(t3(r))return e3;const i=my(J$,e==null?void 0:e.reason);return i||(e==null?void 0:e.reason)||t}function vu(e,t){if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&ZC(e.state))return e.error;const r=my(X$,e==null?void 0:e.reason);return r||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}const d3=1500;async function ou(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const Fv=ue.forwardRef((e,t)=>m.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[m.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),m.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));Fv.displayName="SuccessMark";function f3({onClose:e,onChanged:t}){const[r,i]=R.useState("login"),[o,a]=R.useState(null),[u,c]=R.useState(""),[f,p]=R.useState(""),[d,g]=R.useState(!1),[y,w]=R.useState(null),[E,_]=R.useState(null),b=R.useRef(!1),S=R.useRef(null),k=R.useRef(null),N=R.useRef(null),j=R.useRef(null),A=R.useCallback(()=>{b.current&&ou({action:"login-cancel"}).catch(()=>{}),e()},[e]),M=wo(A,{focusRef:N}),P=R.useCallback(async()=>{g(!0),w(null),b.current=!0;const F=await ou({action:"login"}).catch(()=>null);if(g(!1),!(F!=null&&F.ok)){w(vu(F,"could not start the sign-in"));return}a(F)},[]);R.useEffect(()=>{if(!H$(o==null?void 0:o.state))return;const F=window.setInterval(async()=>{try{const $=await fetch("/api/claude-accounts/login");$.ok&&a(await $.json())}catch{}},d3);return()=>window.clearInterval(F)},[o]);const O=R.useRef(t);O.current=t;const D=R.useRef(K$());R.useEffect(()=>{var F;(o==null?void 0:o.state)==="awaiting_code"&&((F=S.current)==null||F.focus()),D.current.shouldAnnounce(o==null?void 0:o.state)&&O.current()},[o==null?void 0:o.state]),R.useEffect(()=>{var F;r==="paste"&&((F=k.current)==null||F.focus())},[r]);const L=R.useCallback(async()=>{var $;g(!0),w(null);const F=await ou({action:"login-code",code:u}).catch(()=>null);if(g(!1),!(F!=null&&F.ok)){w(vu(F,"the code was not accepted")),F!=null&&F.state&&a(F),($=S.current)==null||$.select();return}c(""),a(F)},[u,o]),U=R.useCallback(async()=>{g(!0),w(null);const F=await ou({action:"import",blob:f}).catch(()=>null);if(g(!1),!(F!=null&&F.ok)){w(vu(F,"the import failed"));return}p(""),_({added:F.added===!0,num:F.num??null,email:F.email??null}),t()},[f,t]),V=(o==null?void 0:o.state)==="done"?o.account:null,z=ZC(o==null?void 0:o.state)||!!(y&&b.current&&!d),C=G$({state:o==null?void 0:o.state,serverError:o==null?void 0:o.error,localError:y});return m.jsx("div",{className:"modal-backdrop",onClick:A,role:"presentation",children:m.jsxs("div",{ref:M,className:"modal aa-modal",onClick:F=>F.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[m.jsxs("header",{className:"modal-head",children:[m.jsx("div",{className:"modal-title",children:m.jsxs("span",{className:"aa-tabs",role:"tablist",children:[m.jsx("button",{type:"button",role:"tab","aria-selected":r==="login",className:`aa-tab${r==="login"?" on":""}`,onClick:()=>i("login"),children:"Sign in"}),m.jsx("button",{type:"button",role:"tab","aria-selected":r==="paste",className:`aa-tab${r==="paste"?" on":""}`,onClick:()=>i("paste"),children:"Paste a share"})]})}),m.jsx("div",{className:"modal-actions",children:m.jsx("button",{type:"button",className:"btn icon-btn",onClick:A,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),m.jsx("section",{className:"modal-body aa-body",children:r==="login"?V?m.jsxs("div",{className:"aa-done",children:[m.jsx(Fv,{ref:j}),m.jsx(b_,{anchor:j}),m.jsx("h4",{children:V.added?`Account ${V.num} added`:"Credentials refreshed"}),m.jsxs("p",{className:"aa-note",children:[m.jsx("strong",{children:V.email}),V.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),m.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"})]}):(o==null?void 0:o.state)==="awaiting_code"||(o==null?void 0:o.state)==="registering"?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"1 · Approve in the browser"}),m.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),m.jsx("a",{className:"aa-link",href:o.url??"#",target:"_blank",rel:"noreferrer noopener",children:o.url})]}),m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"2 · Paste the code it gives you"}),m.jsxs("div",{className:"aa-field",children:[m.jsx("input",{ref:S,type:"text",value:u,onChange:F=>c(F.target.value),onKeyDown:F=>{F.key==="Enter"&&u.trim()&&!d&&L()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:o.state==="registering"}),m.jsx("button",{type:"button",className:"btn primary",disabled:d||!u.trim()||o.state==="registering",onClick:L,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&m.jsx("p",{className:"aa-err",children:y??o.error}),m.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."})]})]}):z?m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:C.title}),m.jsx("p",{className:"aa-err",children:C.message}),m.jsx("button",{type:"button",className:"btn",onClick:()=>{b.current=!1,a(null),w(null),P()},children:"Try again"})]}):d||b.current?m.jsx("div",{className:"aa-step",children:m.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):m.jsxs("div",{className:"aa-step aa-primer",children:[m.jsx("h4",{children:"Sign in to Anthropic"}),m.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in, then asks for the code it shows you. claude-swap records the account when it completes, and the account you are using now stays active."}),m.jsx("div",{className:"aa-actions",children:m.jsx("button",{type:"button",ref:N,className:"btn primary",onClick:P,disabled:d,children:"Open the sign-in page"})})]}):E?m.jsxs("div",{className:"aa-done",children:[m.jsx(Fv,{ref:j}),E.added&&m.jsx(b_,{anchor:j}),m.jsx("h4",{children:E.added?`Account ${E.num} imported`:"Already here"}),m.jsx("p",{className:"aa-note",children:E.added?m.jsxs(m.Fragment,{children:[E.email?m.jsx("strong",{children:E.email}):"That account"," is in the rotation now. Nothing changed on the deck you copied it from."]}):"This deck already holds that account, so nothing changed."}),m.jsxs("div",{className:"aa-actions",children:[m.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),m.jsx("button",{type:"button",className:"btn",onClick:()=>_(null),children:"Import another"})]})]}):m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"Paste an account shared from another deck"}),m.jsxs("div",{className:"aa-field",children:[m.jsx("input",{ref:k,type:"text",value:f,onChange:F=>p(F.target.value),onKeyDown:F=>{F.key==="Enter"&&f.trim()&&!d&&U()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),m.jsx("button",{type:"button",className:"btn primary",disabled:d||!f.trim(),onClick:U,children:d?"importing…":"Import"})]}),y&&m.jsx("p",{className:"aa-err",children:y}),m.jsxs("p",{className:"aa-note",children:["Use ",m.jsx("strong",{children:"share"})," on an account in the other deck. A share carries a live login and expires ten minutes after it is made."]})]})})]})})}function h3(e,t){const r=new Set(e),i=e.length?Math.max(...e):0;return[...new Set([...e,i+1])].sort((o,a)=>o-a).map(o=>{const a=o===t?"here":r.has(o)?"swap":"free";return{slot:o,kind:a,label:a==="here"?`slot ${o}`:`slot ${o} · ${a}`}})}function p3(e,t,r){if(!(r!=null&&r.ok))return null;const i=Number.isInteger(r.to)?r.to:null;if(i==null)return{menuFor:null,confirmRemove:null,shareFor:null,swapNote:null};const o=r.swapped===!0&&i!==t;return{menuFor:e.menuFor===t?i:o&&e.menuFor===i?t:e.menuFor,confirmRemove:null,shareFor:null,swapNote:o?{at:i,displaced:t}:null}}const m3=64;function g3(e,t){const r=e.trim();return{alias:r,commit:r!==(t??"").trim()}}const v3=Object.freeze({text:"couldn't reach the deck server",reload:!0});async function S_(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function y3(e){const t=e.find(i=>!i.ok);if(!t)return null;const r=vo(t.body);return{text:Dv(t.body,`the deck server answered ${t.status}`),...r?{raw:r}:{},reload:!0}}function k_(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 E_=15e3,w3=8e3,x3=1800,_3=3e4,b3=[70,80,85,90,95];function N_(e,t){return GC(t-Math.floor(e/1e3))}function S3(e,t){if(!e)return"";const r=Math.floor(e/1e3)-t;return r<=0?" · due":r<60?` · next in ${r}s`:` · next in ${Math.round(r/60)}m`}function k3(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 E3({lane:e,nowSec:t}){const r=Math.min(100,Math.max(0,e.pct)),i=r>=90?"var(--err)":r>=70?"var(--warn)":"var(--accent)",o=e.resetAt?YC(e.resetAt,t):null;return m.jsxs("div",{className:"ap-lane",children:[m.jsx("span",{className:"ap-lane-label",children:e.label}),m.jsx("div",{className:"ap-lane-track",children:m.jsx("div",{className:"ap-lane-fill",style:{width:`${r===0?1.5:r}%`,background:i,opacity:r===0?.4:1}})}),m.jsxs("span",{className:"ap-lane-pct",style:{color:i},children:[r,"%"]}),m.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}async function N3(e){var r;let t=!1;try{t=await Promise.race([((r=navigator.clipboard)==null?void 0:r.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(i=>window.setTimeout(()=>i(!1),500))])}catch{t=!1}if(t)return!0;try{const i=document.createElement("textarea");i.value=e,i.setAttribute("readonly",""),i.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(i),i.select(),t=document.execCommand("copy"),i.remove()}catch{t=!1}return t}function C3(e,t){const r=Math.round(e/1e3)-t;return r<=0?{text:"expired",tone:"gone"}:r<60?{text:`expires in ${r}s`,tone:"soon"}:{text:`expires in ${Math.round(r/60)}m`,tone:"ok"}}function j3({onClose:e}){var ne,ae,fe;const[t,r]=R.useState(null),[i,o]=R.useState(null),[a,u]=R.useState(null),[c,f]=R.useState(!1),[p,d]=R.useState(null),[g,y]=R.useState(null),[w,E]=R.useState(()=>Math.floor(Date.now()/1e3)),_=R.useRef(null),[b,S]=R.useState(null),[k,N]=R.useState(!1),[j,A]=R.useState(""),[M,P]=R.useState(null),[O,D]=R.useState(null),[L,U]=R.useState(null),[V,z]=R.useState(!1),[C,F]=R.useState(null),$=R.useCallback(async(te=!1)=>{te&&f(!0);const ce=new AbortController,Ce=window.setTimeout(()=>ce.abort(),_3);try{const[ve,Re]=await Promise.all([fetch(`/api/claude-accounts${te?"?refresh=1":""}`,{signal:ce.signal}),fetch("/api/cswap-auto",{signal:ce.signal})]);ve.ok&&r(await ve.json()),Re.ok&&o(await Re.json());const ye=y3([await S_(ve),await S_(Re)]);y(Ee=>k_(Ee,ye))}catch{y(ve=>k_(ve,v3))}finally{window.clearTimeout(Ce),te&&f(!1)}},[]),re=R.useCallback(async(te,ce)=>{u(ce),y(null);try{const ve=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)})).json().catch(()=>null);return ve!=null&&ve.ok||y({text:Dv(ve,"command failed"),raw:vo(ve)}),ve}catch{return y({text:"server unreachable"}),null}finally{u(null)}},[]),J=R.useCallback(async(te,ce)=>{u(ce),y(null);try{const ve=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)})).json().catch(()=>null);return ve!=null&&ve.ok||y({text:vu(ve,"command failed")}),ve}catch{return y({text:"server unreachable"}),null}finally{u(null)}},[]);R.useEffect(()=>($(!0),_.current=window.setInterval(()=>$(!1),E_),()=>{_.current!=null&&window.clearInterval(_.current)}),[$]),R.useEffect(()=>{const te=window.setInterval(()=>E(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(te)},[]);const W=((ne=i==null?void 0:i.settings["autoswitch.threshold"])==null?void 0:ne.value)??"90",Z=(ae=t==null?void 0:t.accounts)==null?void 0:ae.find(te=>te.active),I=Z!=null&&Z.lanes.length?Math.max(...Z.lanes.map(te=>te.pct)):null,G=I!=null&&I>=Number(W)-15,K=async te=>{d(te),y(null);try{const Ce=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:te})})).json().catch(()=>null);Ce!=null&&Ce.ok||y({text:Dv(Ce,"the switch failed"),raw:vo(Ce)}),await $(!0)}catch{y({text:"server unreachable"})}finally{d(null)}},q=async(te,ce)=>{const{commit:Ce,alias:ve}=g3(j,ce);if(Ce){const Re=await J({action:"alias",account:te,alias:ve},`alias-${te}`);if(await $(!0),!(Re!=null&&Re.ok))return;A(ve)}P(te),window.setTimeout(()=>P(Re=>Re===te?null:Re),x3)},Q=async(te,ce)=>{const Ce=await J({action:"move",account:te,slot:ce},`move-${te}`),ve=p3({menuFor:b,shareFor:(L==null?void 0:L.num)??null},te,Ce);if(await $(!0),ve){S(ve.menuFor),D(ve.confirmRemove),ve.shareFor==null&&(U(null),z(!1)),F(ve.swapNote);const Re=ve.swapNote;Re&&window.setTimeout(()=>F(ye=>ye===Re?null:ye),w3)}};return m.jsxs("aside",{className:"accounts-panel",id:"accounts-panel","aria-label":"Claude accounts",children:[m.jsxs("div",{className:"ap-header",children:[m.jsx("h2",{children:"Accounts"}),m.jsxs("div",{className:"ap-header-right",children:[m.jsx("button",{type:"button",className:"btn ap-add",onClick:()=>N(!0),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),m.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>$(!0),disabled:c,"aria-label":"Reload accounts",title:"Reload from claude-swap",children:c?"…":"↻"}),m.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),t==null?g?m.jsxs("div",{className:"ap-empty",role:"alert",children:[m.jsx("span",{title:g.raw||void 0,children:g.text}),m.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",E_/1e3," seconds."]}),m.jsx("button",{type:"button",className:"ap-fix",disabled:c,onClick:()=>$(!0),children:c?"trying…":"try again"})]}):m.jsx("div",{className:"ap-empty",children:"Checking…"}):t.ok?m.jsxs(m.Fragment,{children:[(fe=t.accounts)==null?void 0:fe.map(te=>m.jsxs("div",{className:`ap-account${te.active?" active":""}${te.disabled?" disabled":""}`,children:[m.jsxs("div",{className:"ap-account-head",children:[m.jsx("span",{className:"ap-num",children:te.num}),te.alias&&m.jsx("span",{className:"ap-alias",title:te.alias,children:te.alias}),m.jsx("span",{className:"ap-email",title:te.org??void 0,children:te.email}),m.jsx("button",{type:"button",className:`ap-more${b===te.num?" on":""}`,"aria-label":`Manage account ${te.num}`,"aria-expanded":b===te.num,"aria-controls":b===te.num?`ap-manage-${te.num}`:void 0,title:"Share, rename, move, remove",onClick:()=>{S(b===te.num?null:te.num),A(te.alias??""),D(null),U(null),z(!1),F(null),P(null)},children:"⋯"}),te.active?m.jsx("span",{className:"ap-badge-active",children:"● active"}):m.jsx("button",{type:"button",className:"btn ap-switch",disabled:p!=null||te.disabled,onClick:()=>K(te.num),title:te.disabled?"Held out of rotation":`Switch to ${te.alias??te.email}`,children:p===te.num?"…":"switch"})]}),te.lanes.length>0?te.lanes.map(ce=>m.jsx(E3,{lane:ce,nowSec:w},ce.id)):m.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),m.jsxs("div",{className:"ap-meta",children:[te.error&&(()=>{const ce=k3(te.error);return m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"ap-err",title:ce.hint,children:ce.text}),ce.fixable&&m.jsx("button",{type:"button",className:"ap-fix",onClick:()=>N(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"sign in again"})]})})(),((i==null?void 0:i.enabled)||(i==null?void 0:i.external))&&!te.active&&m.jsx("button",{type:"button",className:"ap-rotate",disabled:a!=null,onClick:()=>re({action:"account",account:te.num,enabled:te.disabled},`rot-${te.num}`).then(()=>$(!0)),title:te.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:te.disabled?"held out":"in rotation"}),te.fetchedAt?m.jsxs("span",{className:`ap-age${te.stale?" 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 ",N_(te.fetchedAt,w),S3(te.nextAt,w)]}):m.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),b===te.num&&m.jsxs("div",{className:"ap-manage",id:`ap-manage-${te.num}`,role:"group","aria-label":`Manage account ${te.num}`,children:[m.jsxs("div",{className:"ap-manage-name",children:[m.jsx("label",{className:"vis-hidden",htmlFor:`ap-alias-${te.num}`,children:"Alias"}),m.jsx("input",{id:`ap-alias-${te.num}`,className:"ap-manage-input",type:"text",value:j,onChange:ce=>A(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&q(te.num,te.alias)},maxLength:m3,placeholder:"e.g. work",spellCheck:!1,autoFocus:!0}),m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:a!=null,onClick:()=>q(te.num,te.alias),title:"A short name to show instead of the email",children:M===te.num?"saved":"save"})]}),m.jsxs("div",{className:"ap-manage-acts",children:[m.jsx("label",{className:"vis-hidden",htmlFor:`ap-slot-${te.num}`,children:"Slot"}),m.jsx("span",{className:"ap-field",children:m.jsx("select",{id:`ap-slot-${te.num}`,value:String(te.num),disabled:a!=null,onChange:ce=>Q(te.num,Number(ce.target.value)),children:h3((t.accounts??[]).map(ce=>ce.num),te.num).map(ce=>m.jsx("option",{value:ce.slot,children:ce.label},ce.slot))})}),m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:a!=null,title:`Copy this account to another ${Gt}. 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:async()=>{z(!1);const ce=await J({action:"share",account:te.num},`share-${te.num}`);ce!=null&&ce.ok&&U({num:te.num,blob:ce.blob,expiresAt:ce.expiresAt})},children:"share"}),m.jsx("button",{type:"button",className:`ap-manage-btn danger${O===te.num?" armed":""}`,disabled:a!=null,title:O===te.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(O!==te.num){D(te.num),window.setTimeout(()=>D(ce=>ce===te.num?null:ce),4e3);return}D(null),J({action:"remove",account:te.num},`rm-${te.num}`).then(()=>{S(null),$(!0)})},children:O===te.num?"confirm":"remove"})]}),(C==null?void 0:C.at)===te.num&&(()=>{var ve;const ce=(ve=t.accounts)==null?void 0:ve.find(Re=>Re.num===C.displaced),Ce=(ce==null?void 0:ce.alias)??(ce==null?void 0:ce.email)??"the account that was there";return m.jsxs("span",{className:"ap-manage-hint ap-manage-swap",title:`Slot ${C.at} was taken, so the two accounts traded places: ${Ce} now holds slot ${C.displaced}.`,children:["swapped with slot ",C.displaced]})})(),(L==null?void 0:L.num)===te.num&&(()=>{const ce=C3(L.expiresAt,w),Ce=ce.tone==="gone";return m.jsxs("div",{className:`ap-share${Ce?" expired":""}`,children:[m.jsx("code",{className:"ap-share-blob",children:L.blob}),m.jsxs("div",{className:"ap-share-foot",children:[m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:a!=null,onClick:async()=>{if(Ce){z(!1);const ve=await J({action:"share",account:te.num},`share-${te.num}`);ve!=null&&ve.ok&&U({num:te.num,blob:ve.blob,expiresAt:ve.expiresAt});return}await N3(L.blob)&&(z(!0),window.setTimeout(()=>z(!1),1800))},children:Ce?"make a new share":V?"copied":"copy"}),m.jsxs("span",{className:"ap-manage-hint",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:[m.jsx("span",{className:"ap-share-warn",children:"this is the password"})," · ",m.jsx("span",{className:`ap-share-expiry ${ce.tone}`,children:ce.text})]})]})]})})()]})]},te.num)),(i==null?void 0:i.ok)&&m.jsxs("div",{className:"ap-auto",children:[m.jsxs("div",{className:"ap-auto-head",children:[m.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),m.jsxs("span",{className:"ap-auto-ctl",children:[I!=null&&m.jsxs("span",{className:`ap-auto-now${G?" near":""}`,children:[Math.round(I),"%"]}),m.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:m.jsx("select",{"aria-label":"Switch threshold",value:W,disabled:a!=null,onChange:te=>re({action:"setting",key:"autoswitch.threshold",value:te.target.value},"threshold").then(()=>$(!0)),children:b3.map(te=>m.jsxs("option",{value:te,children:[te,"%"]},te))})}),m.jsxs("button",{type:"button",className:`ap-auto-state${i.enabled?" live":""}`,role:"switch","aria-checked":i.enabled,disabled:a!=null,onClick:()=>re({action:"enable",enabled:!i.enabled},"enable").then(()=>$(!0)),title:i.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[m.jsx("i",{className:i.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),i.enabled?"on":"off"]})]})]}),i.external&&m.jsxs("p",{className:"ap-auto-note",children:[m.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",m.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",i.enabled?" — this toggle takes over when you stop it.":"."]}),i.lastTick&&m.jsx("div",{className:"ap-auto-foot",children:m.jsxs("span",{className:"ap-auto-result",children:["checked ",N_(i.lastTick.at,w)]})})]}),g&&m.jsxs("div",{className:"ap-failure",role:"alert",children:[m.jsx("span",{className:"ap-failure-text",title:g.raw||void 0,children:g.text}),m.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>y(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),m.jsx("p",{className:"ap-footnote",title:"Anthropic's usage endpoint allows roughly 28–30 requests per hour per account, shared by every tool on this machine — polling it from here would rate-limit your account. So the deck never fetches: it asks claude-swap to collect while this panel is open, at most once every three minutes, and claude-swap decides whether that touches the network at all.",children:"Collected by claude-swap while this panel is open."})]}):m.jsx("div",{className:"ap-empty",children:t.reason==="no_cswap"?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"claude-swap isn't installed."}),m.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."}),t.hint&&m.jsx("code",{className:"ap-cmd",children:t.hint}),m.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",m.jsx("strong",{children:"+"})," button above."]})]}):t.reason==="no_accounts"?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"No accounts added yet."}),m.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",m.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"Couldn't read the account store."}),m.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",t.reason?` (${t.reason})`:"","."]})]})}),k&&m.jsx(f3,{onClose:()=>N(!1),onChanged:()=>$(!0)})]})}const T3=3e4;function R3({bundle:e,running:t,lastTried:r}){return!t||e===t?!1:r!==t}function A3({bundle:e,running:t,pending:r,lastTried:i}){return t?R3({bundle:e,running:t,lastTried:i})?"reload":r==null||r&&r!==t?"wait":"confirm":"wait"}function I3(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function M3({asked:e,reported:t}){return t?t!==e:!1}function O3(e){const t=e.thresholdMs??T3;return!e.enabled||e.kind!=="restart"||!e.canRestart?{idleSince:null,restart:!1}:e.busy?{idleSince:null,restart:!1}:e.idleSince==null?{idleSince:e.now,restart:!1}:e.now<e.idleSince?{idleSince:e.now,restart:!1}:{idleSince:e.idleSince,restart:e.now-e.idleSince>=t}}function P3({agentCount:e,onConfirm:t,onCancel:r}){const i=R.useRef(null),o=wo(r,{focusRef:i,layer:rL}),a=e===0?"This deletes the server's event log":`This removes ${e===1?"the one agent":`all ${e} agents`} on the canvas and deletes the server's event log`;return m.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:m.jsxs("div",{ref:o,className:"modal clear-confirm",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[m.jsxs("header",{className:"modal-head",children:[m.jsxs("div",{className:"modal-title",children:[m.jsx("span",{className:"status-dot err","aria-hidden":!0}),m.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),m.jsx("div",{className:"modal-actions",children:m.jsx("button",{type:"button",className:"btn icon-btn",onClick:r,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),m.jsxs("section",{className:"modal-body",children:[m.jsxs("p",{className:"modal-note",children:[a," — the file a restarted deck replays to rebuild what you see. Layout, pins and selection go with it. This cannot be undone."]}),m.jsxs("div",{className:"cc-actions",children:[m.jsx("button",{type:"button",ref:i,className:"btn",onClick:r,children:"Cancel"}),m.jsx("button",{type:"button",className:"btn danger",onClick:t,children:"Clear everything"})]})]})]})})}function L3(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function $3(e){return e.slice().sort((t,r)=>t.y-r.y||t.x-r.x)}function q3(e,t,r){var u;if(e.length===0)return null;const i=$3(e),o=t?i.findIndex(c=>c.id===t):-1,a=o===-1?r===1?0:i.length-1:(o+r+i.length)%i.length;return((u=i[a])==null?void 0:u.id)??null}const D3=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Delete","Backspace"]);function F3(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:D3.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const z3=new Set(["","BODY","HTML","#DOCUMENT"]);function B3(e){return!e||cy(e)?!1:!z3.has(String(e.tagName??"").toUpperCase())}function au(e,t){if(t.size!==0)for(const r of Array.from(e.keys()))t.has(r)||e.delete(r)}function U3(e){const t=new Set;for(const r of e)t.add(r.id),t.add(`group:${r.sessionId}`);return t}function JC(e,t,r){return!t.has(e)||r.has(e)}function H3(e,t,r,i){return!t.has(e)&&JC(e,r,i)}function W3(e,t,r){const i={x:0,y:0};return t.set(e,i),r.add(e),i}function V3(e,t,r,i){r.set(e,t),i.delete(e)}const G3=40,Y3=120;function K3(e,t){let r=null,i=0,o=Number.NEGATIVE_INFINITY;const a=()=>{r=null,o=t.now(),e()},u=()=>{r!=null&&(t.clearTimeout(r),r=null)},c=(f,p,d)=>{if(r!=null){if(i<=f)return;u()}const g=Math.min(d,Math.max(0,f-p));i=f,r=t.setTimeout(a,g)};return{live(f=G3){const p=t.now(),d=Math.max(o+f,p);if(d<=p){u(),a();return}c(d,p,f)},replay(f=Y3){u(),i=t.now()+f,r=t.setTimeout(a,f)},flush(){u(),a()},cancel(){u()}}}function X3(){let e=!1,t=[];return{get paused(){return e},get size(){return t.length},accept(r){return e?(t.push(r),!1):!0},setPaused(r){if(e=r,r||t.length===0)return[];const i=t;return t=[],i}}}const ej="agent-dag.theme";function Q3(e){return e==="light"?"light":"dark"}function Z3(){return Q3(py(ej))}function J3({waiting:e,running:t}){return{title:e>0?`(${e}) ${Gt}`:Gt,icon:e>0?"waiting":t>0?"running":"idle"}}const Zd={waiting:"#c97d12",running:"#2a90d4",idle:"#7e828c"};function Jd(e,t){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">${t==="waiting"?`<circle cx="16" cy="16" r="14.5" fill="${e}"/>`:`<circle cx="16" cy="16" r="12" fill="none" stroke="${e}" stroke-width="5"/>`+(t==="running"?`<circle cx="16" cy="16" r="5" fill="${e}"/>`:"")}</svg>`}const eq=Object.freeze({waiting:`data:image/svg+xml,${encodeURIComponent(Jd(Zd.waiting,"waiting"))}`,running:`data:image/svg+xml,${encodeURIComponent(Jd(Zd.running,"running"))}`,idle:`data:image/svg+xml,${encodeURIComponent(Jd(Zd.idle,"idle"))}`}),tq="No sessions are waiting for you.";function nq(e){if(e.length===0)return"";const[t,...r]=e;if(r.length===0)return`${t.label} is waiting for your permission.`;const i=`${r.length} more session${r.length===1?"":"s"}`;return`${t.label} and ${i} are waiting for your permission.`}function rq(e,t){return t!==""?t:e===""?"":tq}function sq(){let e=0;return{begin(){const t=++e;return()=>t===e},cancel(){e++}}}function iq(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}function oq(e){return!e.answer||e.answer.range!==e.want?{phase:"busy",stale:!1}:e.answer.ok?{phase:e.answer.days>0?"chart":"empty",stale:e.loading}:{phase:"error",stale:e.loading}}function tj(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const C_={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent"};function gy(e){const t=e.toLowerCase();return Object.hasOwn(C_,t)?C_[t]:t?t[0].toUpperCase()+t.slice(1):""}function aq(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function lq(e,t=[]){const r=t.length?aq(t.map(gy)):tj(e);return r?`via ccusage · local ${r} logs`:"via ccusage · local agent logs"}function uq(e){return e.claude&&e.codex?"Claude Code hooks and Codex rollout files":e.claude?"Claude Code hooks":e.codex?"Codex rollout files":null}function cq(e){const t=tj(e);return t?`Distinct sessions — ${t}`:"Distinct sessions"}function dq(e){const t=uq(e);return t?`Total events received — ${t}`:"Total events received"}function fq(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:"."}]},r=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,r]}function hq(e,t){const r=t.on?"Sound on turn finish: on — click to remove the hook":"Sound on turn finish: off — click to add a Stop hook",i=e.codex?`
|
|
64
|
+
`:r==="r"?"\r":r==="t"?" ":r)}const UC=600,UL=4,HL=36,$v=16,WL=60,VL=6,a_=220,l_=96,GL=28,u_={Read:"📖",Write:"💾",Edit:"✏️",MultiEdit:"🔧",Glob:"🗺️",Grep:"🔎",Bash:"⚡",PowerShell:"💻",LS:"📂",Task:"🤖",Agent:"🤖",TodoWrite:"📋",TaskCreate:"📋",TaskUpdate:"📝",TaskList:"🗂️",TaskGet:"🗂️",TaskOutput:"📤",TaskStop:"🛑",WebFetch:"🌐",WebSearch:"🔭",ToolSearch:"🧰",NotebookEdit:"📓",EnterPlanMode:"🧭",ExitPlanMode:"🏁",AskUserQuestion:"❓",ScheduleWakeup:"⏰",CronCreate:"⏰",CronList:"📅",CronDelete:"🗑️",Skill:"🎯",Workflow:"🎬",Monitor:"📡",PushNotification:"🔔",RemoteTrigger:"📡",...PL};function c_(e){return e.startsWith("mcp__")?"🔌":Object.hasOwn(u_,e)?u_[e]:"✨"}const d_={git:"🐙",gh:"🐙",glab:"🐙",npm:"📦",pnpm:"📦",yarn:"📦",bun:"📦",brew:"🍺",node:"🟢",deno:"🟢",python:"🐍",python3:"🐍",py:"🐍",pip:"🐍",pip3:"🐍",uv:"🐍",ruby:"💎",bundle:"💎",gem:"💎",cargo:"🦀",rustc:"🦀",rustup:"🦀",go:"🐹",docker:"🐳","docker-compose":"🐳",podman:"🐳",kubectl:"☸️",helm:"☸️",k9s:"☸️",grep:"🔎",rg:"🔎",ag:"🔎",ack:"🔎",find:"🔍",fd:"🔍",locate:"🔍",which:"🔍",ls:"📂",dir:"📂",tree:"📂",cat:"📄",head:"📄",tail:"📄",less:"📄",more:"📄",bat:"📄",cp:"📋",mv:"✂️",rm:"🗑️",rmdir:"🗑️",mkdir:"📁",touch:"📁",sed:"✏️",awk:"✏️",tr:"✏️",curl:"🌐",wget:"🌐",http:"🌐",httpie:"🌐",ssh:"🔐",scp:"🔐",rsync:"🔐",ping:"📡",make:"🔨",cmake:"🔨",ninja:"🔨",bazel:"🔨",just:"🔨",terraform:"🏗️",ansible:"📕",pulumi:"🏗️",ps:"📊",top:"📊",htop:"📊",btm:"📊",kill:"💀",pkill:"💀",systemctl:"⚙️",service:"⚙️",tar:"🗜️",zip:"🗜️",unzip:"🗜️",gzip:"🗜️","7z":"🗜️",vim:"📝",nvim:"📝",nano:"📝",emacs:"📝",code:"📝",jq:"🪺",yq:"🪺",echo:"💬",printf:"💬",ffmpeg:"🎞️",ffprobe:"🎞️",imagemagick:"🖼️",convert:"🖼️","Get-ChildItem":"📂","Get-Content":"📄","Set-Content":"💾","Out-File":"💾","Add-Content":"💾","Set-Location":"📍","Get-Location":"📍","Get-Process":"📊","Start-Process":"▶️","Stop-Process":"💀","Invoke-WebRequest":"🌐","Invoke-RestMethod":"🌐","New-Item":"📁","Remove-Item":"🗑️","Copy-Item":"📋","Move-Item":"✂️","Test-Path":"🔍","Where-Object":"🔎","ForEach-Object":"🔁","Select-Object":"🎯","Measure-Object":"📊","Get-Service":"⚙️","Restart-Service":"⚙️","ConvertTo-Json":"🪺","ConvertFrom-Json":"🪺"};function HC(e){if(!e)return null;let t=e.trim();if(!t)return null;const r=t.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(r)return HC(r[1]);for(;;){const a=t.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!a)break;t=t.slice(a[0].length)}t=t.replace(/^sudo(?:\s+-\S+)*\s+/,""),t=t.replace(/^(?:time|nohup|xargs)\s+/,"");const i=t.match(/^([^\s|;&<>(]+)/);if(!i)return null;let o=i[1];return o=o.replace(/^.*[/\\]/,""),o=o.replace(/\.(exe|cmd|bat|ps1)$/i,""),o||null}function YL(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const r=zL(t.script);if(r)return r}if(typeof t.cmd=="string")return t.cmd;if(typeof t.command=="string")return t.command;if(Array.isArray(t.command)&&t.command.every(r=>typeof r=="string")){const r=t.command;if(/powershell|cmd|bash|sh(\.exe)?$/i.test(r[0]??"")){const i=r.findIndex(o=>/^(-Command|-c)$/i.test(o));if(i>=0&&i+1<r.length)return r[i+1]}return r.join(" ")}return typeof t.script=="string"?t.script:null}const KL=new Set(["Bash","PowerShell",...qL]),XL=$L;function QL(e,t){return XL.has(e)||e.startsWith("mcp__")?Math.max(l_,34+t.length*7.5):l_}function ZL(e,t){if(!KL.has(e))return null;const r=YL(t);if(!r)return null;const i=HC(r);return i?{emoji:Object.hasOwn(d_,i)?d_[i]:"⚙️",label:i,category:"shell",detail:r}:null}const JL=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),f_={ts:"🟦",tsx:"🟦",d:"🟦",js:"🟨",jsx:"🟨",mjs:"🟨",cjs:"🟨",py:"🐍",pyi:"🐍",ipynb:"📓",rs:"🦀",go:"🐹",rb:"💎",erb:"💎",java:"☕",kt:"☕",scala:"☕",gradle:"☕",cs:"🔷",fs:"🔷",php:"🐘",swift:"🦅",c:"🇨",cpp:"🇨",cc:"🇨",h:"🇨",hpp:"🇨",md:"📝",mdx:"📝",rst:"📝",json:"🪺",json5:"🪺",jsonl:"🪺",yaml:"⚙️",yml:"⚙️",toml:"⚙️",ini:"⚙️",conf:"⚙️",cfg:"⚙️",xml:"📰",html:"🌐",htm:"🌐",vue:"🌐",svelte:"🌐",css:"🎨",scss:"🎨",sass:"🎨",less:"🎨",sh:"⚡",bash:"⚡",zsh:"⚡",fish:"⚡",ps1:"⚡",txt:"📄",log:"📄",out:"📄",csv:"📊",tsv:"📊",xlsx:"📊",xls:"📊",pdf:"📕",png:"🖼️",jpg:"🖼️",jpeg:"🖼️",gif:"🖼️",webp:"🖼️",svg:"🖼️",ico:"🖼️",mp4:"🎬",mov:"🎬",avi:"🎬",mkv:"🎬",webm:"🎬",mp3:"🎵",wav:"🎵",ogg:"🎵",flac:"🎵",zip:"🗜️",tar:"🗜️",gz:"🗜️",bz2:"🗜️","7z":"🗜️",xz:"🗜️",rar:"🗜️",env:"🔐",lock:"🔐",pem:"🔐",key:"🔐",crt:"🔐",sql:"🗄️",db:"🗄️",sqlite:"🗄️",parquet:"🗄️"},h_={dockerfile:"🐳",makefile:"🔨",rakefile:"💎","package.json":"📦","pnpm-lock.yaml":"📦","yarn.lock":"📦","cargo.toml":"🦀","cargo.lock":"🦀","go.mod":"🐹","go.sum":"🐹","pyproject.toml":"🐍","requirements.txt":"🐍","readme.md":"📖",readme:"📖",license:"📜",".gitignore":"🐙",".gitattributes":"🐙",".env":"🔐",".dockerignore":"🐳"};function e3(e){const r=e.replace(/\\/g,"/").replace(/\/+$/,""),i=r.lastIndexOf("/");return i>=0?r.slice(i+1):r}function t3(e){const t=e.toLowerCase();if(Object.hasOwn(h_,t))return h_[t];if(t.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(t))return"🧪";const r=t.lastIndexOf(".");if(r>0&&r<t.length-1){const i=t.slice(r+1);if(Object.hasOwn(f_,i))return f_[i]}return"📄"}function n3(e,t){if(!t||typeof t!="object")return null;const r=t;if(e==="apply_patch"&&typeof r.patch=="string"){const i=r.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return i?i[1].trim():null}return typeof r.file_path=="string"?r.file_path:typeof r.notebook_path=="string"?r.notebook_path:typeof r.path=="string"?r.path:e==="Glob"&&typeof r.pattern=="string"?r.pattern:null}function r3(e,t){if(!JL.has(e))return null;const r=n3(e,t);if(!r)return null;const i=e3(r);return i?{emoji:e==="LS"?"📂":t3(i),label:i,category:"file",detail:r}:null}const p_={github:{emoji:"🐙",name:"GitHub"},git:{emoji:"🐙",name:"Git"},gitlab:{emoji:"🦊",name:"GitLab"},slack:{emoji:"💬",name:"Slack"},discord:{emoji:"💬",name:"Discord"},linear:{emoji:"📐",name:"Linear"},jira:{emoji:"🅹",name:"Jira"},atlassian:{emoji:"🅰️",name:"Atlassian"},notion:{emoji:"📓",name:"Notion"},asana:{emoji:"📋",name:"Asana"},intercom:{emoji:"💬",name:"Intercom"},figma:{emoji:"🎨",name:"Figma"},gmail:{emoji:"📧",name:"Gmail"},calendar:{emoji:"📅",name:"Calendar"},drive:{emoji:"☁️",name:"Drive"},zoom:{emoji:"📹",name:"Zoom"},spotify:{emoji:"🎵",name:"Spotify"},youtube:{emoji:"📺",name:"YouTube"},ccd_session:{emoji:"📡",name:"Session"},ccd_directory:{emoji:"📂",name:"Directory"},ccd_session_mgmt:{emoji:"📡",name:"Sessions"},mcp_registry:{emoji:"🧰",name:"Registry"},"computer-use":{emoji:"🖱️",name:"Computer"},"claude-in-chrome":{emoji:"🌐",name:"Chrome"},"claude-preview":{emoji:"👀",name:"Preview"},"scheduled-tasks":{emoji:"⏰",name:"Scheduler"},visualize:{emoji:"🎨",name:"Visualize"},"plugin-design-asana":{emoji:"📋",name:"Asana"},"plugin-design-atlassian":{emoji:"🅰️",name:"Atlassian"},"plugin-design-figma":{emoji:"🎨",name:"Figma"},"plugin-design-intercom":{emoji:"💬",name:"Intercom"},"plugin-design-linear":{emoji:"📐",name:"Linear"},"plugin-design-notion":{emoji:"📓",name:"Notion"},"plugin-design-slack":{emoji:"💬",name:"Slack"}};function WC(e){if(!e.startsWith("mcp__"))return null;const t=e.slice(5),r=t.indexOf("__");return r<=0?{server:t,method:""}:{server:t.slice(0,r),method:t.slice(r+2)}}function s3(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t^e.charCodeAt(r);return Math.abs(t)%360}function VC(e){const t=e.toLowerCase();return Object.hasOwn(p_,t)?p_[t]:void 0}function i3(e,t){const r=WC(e);if(!r)return null;const{server:i,method:o}=r;if(!o)return null;const a=VC(i);return{emoji:(a==null?void 0:a.emoji)??"🔌",label:o,category:"mcp",detail:a?`${a.name} · ${o}`:`${i} · ${o}`}}function o3(e,t){return ZL(e,t)??r3(e,t)??i3(e)}const m_=LL;function a3(e){const t=WC(e);if(t){const i=VC(t.server);return i?{emoji:i.emoji,label:i.name}:{emoji:"🔌",label:t.server,hue:s3(t.server)}}const r=Object.hasOwn(m_,e)?m_[e]:"";return r?{emoji:c_(e),label:r}:{emoji:c_(e),label:e}}function l3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function u3(e,t,r){if(r==null)return 1;const i=t-r;return i<0?1:Math.max(0,1-i/UC)}function c3(e,t){const r=[],i=new Set;for(let o=e.length-1;o>=0&&r.length<t;o--){const a=e[o];i.has(a.id)||(i.add(a.id),r.push(a))}return r.reverse()}function d3(e,t,r,i,o,a){const u=[];for(const c of e.values()){if(!t.has(c.id)||c.exitAt!=null&&a-c.exitAt>UC)continue;const f=i.get(c.id)??r.get(c.id);if(!f)continue;const p=c3(c.tools,UL);if(p.length===0)continue;const d=c.exitAt??null,g=o.get(c.id),y=Math.max((g==null?void 0:g.width)??a_,a_),w=(g==null?void 0:g.height)??130,E=f.x,_=f.y,b=E+y,S=_+w/2;p.forEach((k,N)=>{const j=N*HL,A=E+y+WL,M=_+VL+j,P=u3(k,a,d),O=k.inputPreview??"",D=l3(k),L=P<.999,U=a3(k.name);u.push({id:`${c.id}::${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:U.label,emoji:U.emoji,status:D,category:BC(k.name),mcpHue:U.hue,inputPreview:O,fade:P,fading:L,worldX:A,worldY:M,anchorX:b,anchorY:S,spawnDx:b-A,spawnDy:S-(M+$v)});const V=o3(k.name,k.input);if(V){const z=QL(k.name,U.label),C=A+z+GL,F=M,$=A+z,re=M+$v;u.push({id:`sub:${c.id}::${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:V.label,emoji:V.emoji,isSub:!0,status:D,category:V.category,inputPreview:V.detail??O,fade:P,fading:L,worldX:C,worldY:F,anchorX:$,anchorY:re,spawnDx:$-C,spawnDy:0})}})}return u}function f3({agents:e,visibleAgentIds:t,positions:r,pinned:i,measured:o,dimUnmatched:a,spotlight:u,hiddenCategories:c,now:f,onOpenTool:p}){const d=d3(e,t,r,i,o,f),g=c&&c.size>0?d.filter(y=>!c.has(y.category)):d;return m.jsx(h3,{bursts:g,dimUnmatched:a,spotlight:u,onOpenTool:p})}function h3({bursts:e,dimUnmatched:t,spotlight:r,onOpenTool:i}){const{x:o,y:a,zoom:u}=kC();return m.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[m.jsx("svg",{className:"tool-bursts-svg",children:e.map(c=>{const f=c.anchorX*u+o,p=c.anchorY*u+a,d=(c.worldX+6)*u+o,g=(c.worldY+$v)*u+a,y=f+(d-f)*.55,w=t!=null&&!t.has(c.agentId),E=r!=null&&!r.has(c.agentId),_=c.fade*(w||E?.14:1);return m.jsx("path",{d:`M ${f} ${p} Q ${y} ${p}, ${d} ${g}`,className:`tool-conn status-${c.status}${c.fading?" fading":""}`,opacity:_},`l:${c.id}`)})}),e.map(c=>{const f=c.worldX*u+o,p=c.worldY*u+a,d={left:`${f}px`,top:`${p}px`,transform:`scale(${u})`,transformOrigin:"left top","--spawn-dx":`${c.spawnDx}px`,"--spawn-dy":`${c.spawnDy}px`},g=c.isSub?`${c.toolName} · ${c.name}`:c.toolName,y=c.inputPreview?`${g} · ${c.inputPreview}`:g,w=i!=null,E=c.mcpHue!=null?{"--mcp-hue":c.mcpHue}:{},_=t!=null&&!t.has(c.agentId),b=r!=null&&!r.has(c.agentId),S=_||b?" dim":"";return m.jsx("div",{className:"tool-burst-wrap",style:d,children:m.jsxs("div",{className:`tool-burst cat-${c.category}${c.mcpHue!=null?" mcp-hue":""} status-${c.status}${c.fading?" fading":""}${w?" clickable":""}${c.isSub?" sub":""}${S}`,style:E,title:y,onClick:w?()=>i(c.toolId):void 0,children:[m.jsx("span",{className:"tb-emoji",children:c.emoji}),m.jsx("span",{className:"tb-name",children:c.name}),c.status==="inflight"&&m.jsx("span",{className:"tb-spin"}),c.status==="done"&&m.jsx("span",{className:"tb-mark done",children:"✓"}),c.status==="err"&&m.jsx("span",{className:"tb-mark err",children:"×"})]})},c.id)})]})}function fy({cost:e,size:t="md"}){const r=e.total;if(r<=0)return null;const i=(a,u,c)=>{if(a<=0)return null;const f=a/r*100;return m.jsx("span",{className:`cb-seg ${u}`,style:{width:`${f}%`},title:`${c}: ${qe(a)} (${f.toFixed(0)}%)`},u)},o=t==="lg";return m.jsxs("div",{className:o?"cost-bar cost-bar-lg":"cost-bar",role:"img","aria-label":"Cost breakdown",children:[i(e.input,"cb-input","input"),i(e.output,"cb-output","output"),i(e.cacheRead,"cb-cache-r","cache read"),i(e.cacheWrite,"cb-cache-w","cache write")]})}function p3({state:e,sessionId:t,onClose:r}){const i=R.useMemo(()=>m3(e,t),[e,t]),o=R.useRef(null),a=wo(r,{focusRef:o});return i?m.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:m.jsxs("div",{ref:a,className:"modal session-summary",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[m.jsxs("div",{className:"modal-head",children:[m.jsxs("div",{className:"modal-title",children:[m.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),m.jsx("span",{id:"ss-title",className:"modal-tool-name",title:i.cwd??i.sessionId,children:i.label}),m.jsxs("span",{className:"modal-tool-id",children:["· ",i.sessionId.slice(0,8)]})]}),m.jsxs("div",{className:"modal-actions",children:[m.jsx("span",{className:"modal-dur",title:"Total wall time",children:i.durationLabel}),m.jsx("button",{type:"button",ref:o,className:"btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),m.jsxs("div",{className:"modal-body",children:[m.jsxs("section",{className:"ss-hero",children:[m.jsxs("div",{className:"ss-hero-left",children:[m.jsx("div",{className:"ss-cost-label",children:"total spend"}),m.jsx("div",{className:"ss-cost",children:qe(i.cost.total)}),i.modelChips.length>0&&m.jsx("div",{className:"ss-models",children:i.modelChips.map(u=>m.jsx("span",{className:"model-chip",title:u,children:Rs(u)},u))})]}),m.jsx("div",{className:"ss-hero-right",children:i.cost.total>0&&m.jsxs(m.Fragment,{children:[m.jsx(fy,{cost:i.cost,size:"lg"}),m.jsxs("div",{className:"ss-cost-legend",children:[m.jsxs("span",{className:"ssl ssl-in",children:["input ",m.jsx("b",{children:qe(i.cost.input)})]}),m.jsxs("span",{className:"ssl ssl-out",children:["output ",m.jsx("b",{children:qe(i.cost.output)})]}),m.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",m.jsx("b",{children:qe(i.cost.cacheRead)})]}),m.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",m.jsx("b",{children:qe(i.cost.cacheWrite)})]})]})]})})]}),m.jsxs("section",{className:"ss-stats",children:[m.jsx(to,{label:"agents",value:i.agentCount}),m.jsx(to,{label:"subagents",value:i.subagentCount}),m.jsx(to,{label:"tool calls",value:i.toolCount}),m.jsx(to,{label:"prompts",value:i.promptCount}),m.jsx(to,{label:"tokens",value:i.tokensSum.toLocaleString()}),i.errCount>0&&m.jsx(to,{label:"errors",value:i.errCount,tone:"err"})]}),i.topTools.length>0&&m.jsxs("section",{className:"modal-section",children:[m.jsx("h4",{children:"Most-used tools"}),m.jsx("div",{className:"ss-top-tools",children:i.topTools.map(([u,c])=>m.jsxs("div",{className:"ss-tt",children:[m.jsx("span",{className:"ss-tt-name",children:u}),m.jsx("span",{className:"ss-tt-bar",children:m.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${c/i.topTools[0][1]*100}%`}})}),m.jsx("span",{className:"ss-tt-count",children:c})]},u))})]}),i.firstPrompt&&m.jsxs("section",{className:"modal-section",children:[m.jsx("h4",{children:"Opening prompt"}),m.jsx("div",{className:"ss-prompt",children:i.firstPrompt})]})]})]})}):null}function to({label:e,value:t,tone:r}){return m.jsxs("div",{className:`ss-stat${r?` tone-${r}`:""}`,children:[m.jsx("div",{className:"ss-stat-value",children:t}),m.jsx("div",{className:"ss-stat-label",children:e})]})}function m3(e,t){const r=e.agents.get(t);if(!r)return null;const i=[];for(const N of e.agents.values())N.sessionId===t&&i.push(N);if(i.length===0)return null;const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},a=new Set,u=new Map;let c=0,f=0,p=0,d=0,g=0,y,w=1/0,E=0;for(const N of i){const j=dn(N.usage,N.model);o.input+=j.input,o.output+=j.output,o.cacheRead+=j.cacheRead,o.cacheWrite+=j.cacheWrite,o.total+=j.total,N.model&&a.add(N.model),N.kind==="subagent"&&g++,f+=N.prompts.length,!y&&N.prompts.length>0&&(y=N.prompts[0].text),p+=N.usage.inputTokens+N.usage.outputTokens,c+=N.toolCount,w=Math.min(w,N.startedAt),E=Math.max(E,N.endedAt??Date.now());for(const A of N.tools)u.set(A.name,(u.get(A.name)??0)+1),A.ok===!1&&d++}const _=Math.max(0,E-w),b=Math.floor(_/1e3),S=b<60?`${b}s`:b<3600?`${Math.floor(b/60)}m ${String(b%60).padStart(2,"0")}s`:`${Math.floor(b/3600)}h ${Math.floor(b%3600/60)}m`,k=Array.from(u.entries()).sort((N,j)=>j[1]-N[1]).slice(0,5);return{sessionId:t,label:r.label||r.cwdBasename||"session",cwd:r.cwd,durationLabel:S,cost:o,modelChips:Array.from(a),agentCount:i.length,subagentCount:g,toolCount:c,promptCount:f,tokensSum:p,errCount:d,topTools:k,firstPrompt:y}}function hy(e){return(e==null?void 0:e.kind)==="permission"}function g3(e){const t=[];for(const r of e)r.kind==="root"&&hy(r.waiting)&&t.push({id:r.id,label:r.label,waiting:r.waiting});return t.sort((r,i)=>r.waiting.since-i.waiting.since)}function v3(e){const t=new Set;for(const r of e)r.state==="active"&&t.add(r.sessionId);return t.size}function g_(e){return e.waiting?hy(e.waiting)?0:1:e.state==="active"?2:3}function y3(e,t){const r=[];for(const i of e.agents.values()){if(i.kind!=="root")continue;let o=i.toolCount,a=dn(i.usage,i.model).total,u=i.endedAt??i.startedAt;for(const c of e.agents.values()){if(c.sessionId!==i.sessionId||c.kind==="root")continue;o+=c.toolCount,a+=dn(c.usage,c.model).total;const f=c.endedAt??c.startedAt;f>u&&(u=f)}r.push({sessionId:i.sessionId,label:i.label||i.cwdBasename||"session",cwdBasename:i.cwdBasename,state:i.state,waiting:i.waiting,modelId:i.model,toolCount:o,cost:a,startedAt:i.startedAt,lastActivity:u})}return r.sort((i,o)=>{const a=g_(i),u=g_(o);return a!==u?a-u:i.waiting&&o.waiting?i.waiting.since-o.waiting.since:o.lastActivity-i.lastActivity}),r}function v_(e,t,r){const i=(t??r)-e;if(i<1e3)return"<1s";const o=Math.floor(i/1e3);if(o<60)return`${o}s`;const a=Math.floor(o/60);return a<60?`${a}m`:`${Math.floor(a/60)}h ${a%60}m`}function w3({state:e,now:t,selectedIds:r,onSelect:i,onClose:o}){const a=R.useMemo(()=>y3(e),[e,e.lastSeq,t]),u=a.filter(f=>f.state==="active").length,c=a.filter(f=>hy(f.waiting)).length;return m.jsxs("aside",{className:"session-list",id:"session-list","aria-label":"Sessions",children:[m.jsxs("div",{className:"sl-header",children:[m.jsxs("h2",{children:["Sessions ",m.jsx("span",{className:"sl-count",children:a.length})]}),c>0&&m.jsxs("span",{className:"sl-waiting-count",children:[c," waiting"]}),u>0&&m.jsxs("span",{className:"sl-live-count",children:[u," live"]}),m.jsx("button",{className:"btn icon-btn sl-close",onClick:o,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),m.jsxs("div",{className:"sl-rows",children:[a.length===0&&m.jsx("div",{className:"sl-empty",children:"No sessions yet."}),a.map(f=>{const p=r.has(f.sessionId);return m.jsxs("button",{type:"button",className:`sl-row state-${f.state}${p?" selected":""}`,onClick:()=>i(f.sessionId),title:`Focus ${f.label}`,children:[m.jsx("span",{className:`sl-dot state-${f.state}`,"aria-hidden":!0}),m.jsx("span",{className:"vis-hidden",children:dy(f.state)}),m.jsxs("div",{className:"sl-row-body",children:[m.jsxs("div",{className:"sl-row-head",children:[m.jsx("span",{className:"sl-label",children:f.label}),f.modelId&&m.jsx("span",{className:"model-chip",title:f.modelId,children:Rs(f.modelId)})]}),m.jsxs("div",{className:"sl-row-meta",children:[m.jsxs("span",{title:"tool calls",children:[m.jsx("b",{children:f.toolCount})," tools"]}),f.cost>0&&m.jsx("span",{className:"sl-cost",title:"total spend",children:m.jsx("b",{children:qe(f.cost)})}),f.waiting?m.jsxs("span",{className:"sl-waiting",title:`${zu(f.waiting)}
|
|
65
|
+
Blocked since ${new Date(f.waiting.since).toLocaleTimeString()} · started ${new Date(f.startedAt).toLocaleString()}`,children:["waiting ",v_(f.waiting.since,void 0,t)]}):m.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(f.startedAt).toLocaleString()}`,children:v_(f.startedAt,f.state==="active"?void 0:f.lastActivity,t)})]})]})]},f.sessionId)})]})]})}const Gt="ccdeck";function GC(e){const t=Math.max(0,e);return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function qv(e){return GC(Math.floor(e/1e3))}function YC(e,t){const r=e-t;if(r<=0)return null;const i=Math.floor(r/86400),o=Math.floor(r%86400/3600),a=Math.floor(r%3600/60);return i>0?`${i}d ${o}h`:o>0?`${o}h ${a}m`:`${a}m`}function x3(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function _3(e,t,r){const i=new Date(e),o=qv(t-e);return{label:x3(i,new Date(t))?o:`${o} · ${i.toLocaleDateString(r,{month:"short",day:"numeric"})}`,title:i.toLocaleString(r,{dateStyle:"medium",timeStyle:"medium"})}}function y_(e,t){if(!e)return null;const r=t-Math.floor(e/1e3);return r<10?"just now":r<60?`${r}s ago`:r<3600?`${Math.floor(r/60)}m ago`:`${Math.floor(r/3600)}h ago`}function b3(e){return e==="claude-swap"?"Read from claude-swap's last collection — costs no request against your usage-endpoint budget":e==="api"?"Fetched from Anthropic's usage endpoint, at most once every 5 minutes":e==="cli"?"Parsed from `claude /usage`, at most once every 5 minutes":"Last update"}const Xd="__unknown__";function S3(e,t,r,i){const o=Math.max(0,t-i),a=Math.max(0,r-o);if(a<120)return null;const u=Math.min(100,a/r*100),c=e-u;if(Math.abs(c)<3)return{label:"on pace",color:"var(--ok)",expectedPct:u,isDeficit:!1};if(c>0){const f=100-e,p=a>0?e/a:0,d=p>0?f/p:1/0,g={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(d<o&&d<86400){const y=Math.floor(d/3600),w=Math.floor(d%3600/60);g.runsOutIn=y>0?`${y}h ${w}m`:`${w}m`}return g}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function li({pct:e,label:t,reset:r,resetAt:i,windowSec:o,limitReached:a,nowSec:u}){const c=Math.min(100,Math.max(0,e)),p=a||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",d=c===0?"< 1%":`${c}%`,g=c===0?2:c,y=i?YC(i,u):null,w=i&&o?S3(c,i,o,u):null;return m.jsxs("div",{className:"qb-row",children:[m.jsxs("div",{className:"qb-meta",children:[m.jsxs("span",{className:"qb-label",children:[t,a&&m.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),m.jsx("span",{className:"qb-pct",style:{color:p},children:d})]}),m.jsxs("div",{className:"qb-track",children:[m.jsx("div",{className:"qb-fill",style:{width:`${g}%`,background:p,opacity:c===0?.4:1}}),w&&m.jsx("div",{className:"qb-pace-marker",style:{left:`${w.expectedPct}%`,background:w.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(w.expectedPct)}% by now`})]}),m.jsxs("div",{className:"qb-reset-row",children:[y?m.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):r?m.jsxs("span",{className:"qb-reset",children:["resets ",r]}):null,w&&m.jsx("span",{className:"qb-pace",style:{color:w.color},children:w.runsOutIn?`runs out in ${w.runsOutIn}`:w.label})]})]})}const k3=6e4;function E3(e){const[t,r]=R.useState(null),[i,o]=R.useState(!1),a=R.useRef(null),u=async(f=!1)=>{f&&o(!0);try{const d=await fetch(f?"/api/quota?refresh=1":"/api/quota");d.ok&&r(await d.json())}catch{}finally{f&&o(!1)}};return R.useEffect(()=>{if(e)return u(!0),a.current=window.setInterval(()=>u(!1),k3),()=>{a.current!=null&&window.clearInterval(a.current)}},[e]),{quota:t,loading:i,refresh:()=>{e&&u(!0)}}}function N3(e){switch(e){case"no_token":return"Run codex login to authenticate.";case"api_key_mode":return"API-key login — ChatGPT quota is only available for codex login.";case"refresh_rejected":return"Codex session expired — run codex login.";case"refresh_failed":return"Couldn't refresh the Codex token — click ↻ to retry.";case"untrusted_base_url":return"chatgpt_base_url in ~/.codex/config.toml is not an https OpenAI host, so the token was not sent.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const KC=6e4;function C3(e){const[t,r]=R.useState(null),[i,o]=R.useState(!1),a=R.useRef(null),u=async(f=!1)=>{f&&o(!0);try{const d=await fetch(f?"/api/codex-quota?refresh=1":"/api/codex-quota");d.ok&&r(await d.json())}catch{}finally{f&&o(!1)}};return R.useEffect(()=>{if(e)return u(!0),a.current=window.setInterval(()=>u(!1),KC),()=>{a.current!=null&&window.clearInterval(a.current)}},[e]),{data:t,loading:i,refresh:()=>{e&&u(!0)}}}function j3(e){const[t,r]=R.useState(null),i=R.useRef(null),o=async()=>{try{const a=await fetch("/api/codex-usage");a.ok&&r(await a.json())}catch{}};return R.useEffect(()=>{if(e)return o(),i.current=window.setInterval(o,KC),()=>{i.current!=null&&window.clearInterval(i.current)}},[e]),{data:t}}function T3({state:e,now:t,providers:r,onClose:i}){var V,z;const{quota:o,loading:a,refresh:u}=E3(r.claude),{data:c,loading:f,refresh:p}=C3(r.codex),{data:d}=j3(r.codex),[g,y]=R.useState(()=>Math.floor(Date.now()/1e3));R.useEffect(()=>{const C=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(C)},[]);const{byModel:w,totalCost:E,totalTokens:_,burnRate:b}=R.useMemo(()=>{const C=new Map,F={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let $=0,re=0,J=0,W=0;for(const q of e.agents.values()){const Q=q.model??Xd,ne=dn(q.usage,q.model),ae=C.get(Q);ae?(ae.inputTokens+=q.usage.inputTokens,ae.outputTokens+=q.usage.outputTokens,ae.cacheReadTokens+=q.usage.cacheReadTokens,ae.cacheCreateTokens+=q.usage.cacheCreateTokens,ae.cost.total+=ne.total,ae.cost.input+=ne.input,ae.cost.output+=ne.output,ae.cost.cacheRead+=ne.cacheRead,ae.cost.cacheWrite+=ne.cacheWrite,ae.agentCount++):C.set(Q,{model:Q,inputTokens:q.usage.inputTokens,outputTokens:q.usage.outputTokens,cacheReadTokens:q.usage.cacheReadTokens,cacheCreateTokens:q.usage.cacheCreateTokens,cost:{...ne},agentCount:1,priced:go(q.model)!=null}),F.total+=ne.total,F.input+=ne.input,F.output+=ne.output,F.cacheRead+=ne.cacheRead,F.cacheWrite+=ne.cacheWrite,$+=q.usage.inputTokens,re+=q.usage.outputTokens,J+=q.usage.cacheReadTokens,W+=q.usage.cacheCreateTokens}const Z=Array.from(C.values()).sort((q,Q)=>Q.cost.total-q.cost.total||Q.inputTokens+Q.outputTokens-(q.inputTokens+q.outputTokens));let I=0,G=0;for(const q of e.agents.values()){if(q.state!=="active")continue;const Q=dn(q.usage,q.model);I+=Q.total,G=Math.max(G,((q.endedAt??t)-q.startedAt)/1e3)}const K=G>0?ju(I,G):null;return{byModel:Z,totalCost:F,totalTokens:{in:$,out:re,cacheR:J,cacheC:W},burnRate:K}},[e,e.lastSeq,t]),S=R.useMemo(()=>{const C=[],F=$=>go($.model)==null?$.usage.inputTokens+$.usage.outputTokens:0;for(const $ of e.agents.values()){if($.kind!=="root")continue;let re=dn($.usage,$.model).total,J=$.usage.inputTokens,W=$.usage.outputTokens,Z=F($);for(const I of e.agents.values())I.sessionId!==$.sessionId||I.kind==="root"||(re+=dn(I.usage,I.model).total,J+=I.usage.inputTokens,W+=I.usage.outputTokens,Z+=F(I));C.push({sessionId:$.sessionId,label:$.label||$.cwdBasename||"session",state:$.state,cost:re,inputTokens:J,outputTokens:W,unpricedTokens:Z})}return C.sort(($,re)=>re.cost-$.cost||re.inputTokens+re.outputTokens-($.inputTokens+$.outputTokens)).slice(0,12)},[e,e.lastSeq]),k=E.total>0,N=_.in+_.out,j=w.filter(C=>C.cost.total>0||C.inputTokens+C.outputTokens>0),A=S.filter(C=>C.cost>0||C.inputTokens+C.outputTokens>0),M=j.some(C=>!C.priced),P=a||f,O=y_(o==null?void 0:o.fetchedAt,g),D=y_(c==null?void 0:c.fetchedAt,g),L=()=>{u(),p()},U=r.claude&&r.codex?"Refresh Claude + Codex quota":r.codex?"Refresh Codex quota":"Refresh Claude quota";return m.jsxs("aside",{className:"usage-panel",id:"usage-panel","aria-label":"Usage",children:[m.jsxs("div",{className:"up-header",children:[m.jsx("h2",{children:"Usage"}),b&&m.jsx("span",{className:"up-rate",children:b}),m.jsxs("div",{className:"up-header-right",children:[(r.claude||r.codex)&&m.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:L,disabled:P,"aria-label":U,title:U,children:P?"…":"↻"}),m.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:i,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),r.claude&&m.jsxs("section",{className:"up-section up-quota-section",children:[m.jsxs("h3",{className:"up-section-title",children:["Claude quota",O&&!a&&m.jsx("span",{className:"up-section-age",title:b3(o==null?void 0:o.source),children:O})]}),o!=null&&o.ok?m.jsxs("div",{className:"up-quota-bars",children:[o.session5hPct!=null&&m.jsx(li,{label:"5-hour window",pct:o.session5hPct,reset:o.session5hReset,resetAt:o.session5hResetAt,windowSec:o.session5hWindowSec,nowSec:g}),o.week7dPct!=null&&m.jsx(li,{label:"7-day window",pct:o.week7dPct,reset:o.week7dReset,resetAt:o.week7dResetAt,windowSec:o.week7dWindowSec,nowSec:g}),o.weekSonnetPct!=null&&m.jsx(li,{label:"Sonnet (7d)",pct:o.weekSonnetPct,nowSec:g}),o.weekOpusPct!=null&&m.jsx(li,{label:"Opus (7d)",pct:o.weekOpusPct,nowSec:g})]}):(o==null?void 0:o.ok)===!1?m.jsxs("div",{className:"up-quota-na",children:[m.jsx("span",{children:"Quota unavailable."}),m.jsxs("span",{className:"up-quota-hint",children:["Run ",m.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):m.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),r.codex&&m.jsxs("section",{className:"up-section up-quota-section",children:[m.jsxs("h3",{className:"up-section-title",children:["Codex quota",(c==null?void 0:c.ok)&&c.planLabel&&m.jsx("span",{className:"up-plan-badge",children:c.planLabel}),D&&!f&&m.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:D})]}),c!=null&&c.ok?m.jsxs("div",{className:"up-quota-bars",children:[(V=c.windows)==null?void 0:V.map(C=>m.jsx(li,{label:C.label,pct:C.pct,reset:C.reset??void 0,resetAt:C.resetAt??void 0,windowSec:C.windowSec??void 0,limitReached:c.limitReached&&C.pct>=100,nowSec:g},C.id)),(z=c.extraWindows)==null?void 0:z.map(C=>m.jsx(li,{label:C.label,pct:C.pct,reset:C.reset??void 0,resetAt:C.resetAt??void 0,windowSec:C.windowSec??void 0,nowSec:g},C.id)),c.creditLimit&&m.jsx(li,{label:`spend cap · $${Math.round(c.creditLimit.used)} of $${Math.round(c.creditLimit.limit)}`,pct:c.creditLimit.usedPct,reset:c.creditLimit.reset??void 0,resetAt:c.creditLimit.resetAt??void 0,limitReached:c.spendControlReached,nowSec:g}),c.creditsBalance&&!c.creditsUnlimited&&m.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",c.creditsBalance,c.overageReached&&" · overage limit reached"]}),c.creditsUnlimited&&m.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),c.resetCredits&&c.resetCredits.availableCount>0&&m.jsxs("div",{className:"up-quota-sub up-reset-credits",title:`Redeem in the Codex CLI or ChatGPT — ${Gt} only reports them`,children:[c.resetCredits.availableCount," rate-limit reset",c.resetCredits.availableCount!==1?"s":""," available",c.resetCredits.nextExpiryAt&&` · expires ${new Date(c.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),c.promo&&m.jsx("div",{className:"up-quota-sub",children:c.promo}),c.partial&&m.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(c==null?void 0:c.ok)===!1?m.jsxs("div",{className:"up-quota-na",children:[m.jsx("span",{children:"Quota unavailable."}),m.jsx("span",{className:"up-quota-hint",children:N3(c.reason)})]}):m.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"}),(d==null?void 0:d.ok)&&d.window7d&&d.window7d.sessionCount>0&&m.jsxs("div",{className:"up-quota-sub",title:`Counted from the rollout files under CODEX_HOME — no network, no account${d.window5h?`
|
|
66
|
+
last 5h: ${Nt(d.window5h.totalTokens)} tokens · ${d.window5h.sessionCount} session${d.window5h.sessionCount!==1?"s":""}`:""}`,children:[Nt(d.window7d.totalTokens)," tokens · ",d.window7d.sessionCount," session",d.window7d.sessionCount!==1?"s":""," (7d)"]})]}),N>0?m.jsxs(m.Fragment,{children:[k&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"up-total",children:[m.jsx("span",{className:"up-total-value",children:qe(E.total)}),m.jsx("span",{className:"up-total-label",children:"total spend"})]}),m.jsx(fy,{cost:E})]}),m.jsxs("div",{className:"up-tokens-row",children:[m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"in"}),Nt(_.in)]}),m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"out"}),Nt(_.out)]}),_.cacheR>0&&m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"cache r"}),Nt(_.cacheR)]}),_.cacheC>0&&m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"cache c"}),Nt(_.cacheC)]})]}),j.length>0&&m.jsxs("section",{className:"up-section",children:[m.jsx("h3",{className:"up-section-title",children:"By model"}),m.jsxs("table",{className:"up-table",children:[m.jsx("thead",{children:m.jsxs("tr",{children:[m.jsx("th",{children:"Model"}),m.jsx("th",{children:"Tokens"}),m.jsx("th",{children:"Cost"})]})}),m.jsx("tbody",{children:j.map(C=>m.jsxs("tr",{children:[m.jsx("td",{className:"up-model-name",title:C.model===Xd?"no model reported yet":C.model,children:C.model===Xd?"unknown":Rs(C.model)}),m.jsx("td",{className:"up-num",children:Nt(C.inputTokens+C.outputTokens)}),C.priced?m.jsx("td",{className:"up-num up-cost-val",children:qe(C.cost.total)}):m.jsx("td",{className:"up-num up-unpriced",children:gu})]},C.model))})]})]}),A.length>0&&m.jsxs("section",{className:"up-section",children:[m.jsx("h3",{className:"up-section-title",children:"By session"}),m.jsx("div",{className:"up-sessions",children:A.map(C=>m.jsxs("div",{className:"up-session-row",children:[m.jsx("span",{className:`sl-dot state-${C.state}`,"aria-hidden":!0}),m.jsx("span",{className:"vis-hidden",children:dy(C.state)}),m.jsx("span",{className:"up-session-label",children:C.label}),m.jsx("span",{className:"up-session-tokens",children:Nt(C.inputTokens+C.outputTokens)}),C.cost>0?m.jsxs("span",{className:"up-session-cost",title:C.unpricedTokens>0?`${Nt(C.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[qe(C.cost),C.unpricedTokens>0?"+":""]}):m.jsx("span",{className:"up-session-cost up-unpriced",children:gu})]},C.sessionId))})]}),M&&m.jsxs("div",{className:"up-hint",children:["“",gu,"” means this build holds no published rate for that model — those tokens are counted above and their dollars are not."]})]}):m.jsxs("div",{className:"up-empty",children:["No usage data yet.",m.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const R3="1",w_="agent-dag.schema",A3=["agent-dag.layout","agent-dag.viewport"];function py(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function I3(e,t=R3){let r=null;try{r=e.getItem(w_)}catch{return[]}if(r===t)return[];const i=[];if(r!==null)for(const o of A3)try{e.getItem(o)!==null&&(e.removeItem(o),i.push(o))}catch{}try{e.setItem(w_,t)}catch{}return i}const M3=3e3,O3=4e3,Qd=20,ca=36,no=8,XC="agent-dag.systemPanelOpen";function P3(){return py(XC)==="1"}function L3(e){if(!(typeof window>"u"))try{window.localStorage.setItem(XC,e?"1":"0")}catch{}}function Ca(e){return e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} KB`}function $3(e){const t=Math.floor(e/86400),r=Math.floor(e%86400/3600),i=Math.floor(e%3600/60);return t>0?`${t}d ${r}h`:r>0?`${r}h ${i}m`:`${i}m`}function q3(){const[e,t]=R.useState(null),r=R.useRef(null);return R.useEffect(()=>{let i=!0;const o=async()=>{if(document.visibilityState!=="hidden")try{const f=await fetch("/api/system");if(!f.ok)return;const p=await f.json();i&&(p!=null&&p.ok)&&t(p)}catch{}},a=()=>{r.current==null&&(o(),r.current=window.setInterval(o,M3))},u=()=>{r.current!=null&&(window.clearInterval(r.current),r.current=null)},c=()=>{if(document.visibilityState==="hidden"){u();return}a(),o()};return a(),document.addEventListener("visibilitychange",c),()=>{i=!1,u(),document.removeEventListener("visibilitychange",c)}},[]),e}function D3(e){const[t,r]=R.useState(null);return R.useEffect(()=>{let i=!0;const o=async()=>{if(document.visibilityState!=="hidden")try{const u=await fetch("/api/system/processes");if(!u.ok)return;const c=await u.json();i&&(c!=null&&c.ok)&&r(c.procs??[])}catch{}};o();const a=window.setInterval(o,O3);return()=>{i=!1,window.clearInterval(a)}},[e]),t}function F3({usageOpen:e=!1}){const t=q3(),[r,i]=R.useState(P3);R.useEffect(()=>{L3(r)},[r]);const o=R.useRef(null);if(!t||t.cpu==null||!t.memory)return m.jsx("span",{className:"sysmeter idle",title:"Sampling this machine…",children:m.jsx("span",{className:"sm-box","aria-hidden":!0,children:m.jsxs("span",{className:"sm-graphic",children:[m.jsx("svg",{className:"sm-spark",width:ca,height:no,viewBox:`0 0 ${ca} ${no}`}),m.jsx("span",{className:"sm-ram"})]})})});const{cpu:a,cpuHistory:u,cores:c,memory:f,loadavg:p}=t,d=f.usedPct>=90,g=u.slice(-Qd),y=Qd-g.length,w=ca/Qd,E=[`CPU ${a.toFixed(0)}% of ${c} cores`,p?`load ${p[0]} · ${p[1]} · ${p[2]} (1m · 5m · 15m)`:null,`Memory ${Ca(f.total-f.available)} of ${Ca(f.total)} used`,"","Click for detail. This machine, not this session."].filter(_=>_!==null).join(`
|
|
67
|
+
`);return m.jsxs("span",{className:"sysmeter-wrap",children:[m.jsxs("button",{type:"button",ref:o,className:"sysmeter",title:E,"aria-label":"Toggle machine detail","aria-expanded":r,"aria-controls":r?"system-panel":void 0,onClick:()=>i(_=>!_),children:[m.jsxs("span",{className:"sm-box","aria-hidden":!0,children:[m.jsxs("span",{className:"sm-graphic",children:[m.jsx("svg",{className:"sm-spark",width:ca,height:no,viewBox:`0 0 ${ca} ${no}`,children:g.map((_,b)=>{const S=y+b,k=Math.max(1,_/100*no),N=.32+.68*((b+1)/g.length);return m.jsx("rect",{x:S*w,y:no-k,width:Math.max(.8,w-.7),height:k,rx:.5,fill:"var(--accent)",opacity:N},S)})}),m.jsx("span",{className:"sm-ram",children:m.jsx("span",{className:`sm-ram-fill${d?" warn":""}`,style:{transform:`scaleX(${Math.max(2,f.usedPct)/100})`}})})]}),m.jsxs("span",{className:"sm-read",children:[m.jsx("b",{children:a.toFixed(0)}),m.jsx("i",{children:"·"}),m.jsx("b",{children:f.usedPct.toFixed(0)})]})]}),m.jsxs("span",{className:"sm-sr",children:["CPU ",a.toFixed(0)," percent, memory ",f.usedPct.toFixed(0)," percent used"]})]}),r&&m.jsx(z3,{sys:t,usageOpen:e,onClose:()=>{var _;i(!1),(_=o.current)==null||_.focus()}})]})}function z3({sys:e,usageOpen:t,onClose:r}){const i=D3(!0),{memory:o,swap:a,perCore:u,loadavg:c,cores:f,uptimeSec:p,platform:d}=e,g=o?o.total-o.available:0,y=d==="win32"?"Commit":"Swap",w=a&&a.total>0?a.used/a.total*100:0;return m.jsxs("aside",{className:`sysdetail${t?" shifted":""}`,id:"system-panel","aria-label":"Machine detail",children:[m.jsxs("div",{className:"sd-head",children:[m.jsx("span",{className:"sd-title",children:"This machine"}),m.jsxs("span",{className:"sd-sub",children:["up ",$3(p)," · ",f," cores"]}),m.jsx("button",{type:"button",className:"sd-close",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),u&&u.length>0&&m.jsxs("div",{className:"sd-section",role:"group","aria-label":"Cores",children:[m.jsx("div",{className:"sd-h","aria-hidden":!0,children:"Cores"}),m.jsx("div",{className:"sd-cores",style:{"--n":u.length},children:u.map((E,_)=>m.jsx("span",{className:"sd-core",title:`core ${_+1}: ${E}%`,children:m.jsx("span",{className:"sd-core-fill",style:{height:`${Math.max(2,E)}%`}})},_))})]}),m.jsxs("div",{className:"sd-section",role:"group","aria-label":"Memory",children:[m.jsx("div",{className:"sd-h","aria-hidden":!0,children:"Memory"}),o&&m.jsx(x_,{label:"Physical",used:g,total:o.total,pct:o.usedPct,note:`${Ca(o.available)} available`}),a&&a.total>0&&m.jsx(x_,{label:y,used:a.used,total:a.total,pct:w,note:w>=50?"paging to disk":void 0})]}),c&&m.jsxs("div",{className:"sd-section",role:"group","aria-label":"Load average",children:[m.jsx("div",{className:"sd-h","aria-hidden":!0,children:"Load average"}),m.jsx("div",{className:"sd-load",children:c.map((E,_)=>m.jsxs("span",{className:`sd-load-item${E>f?" over":""}`,children:[m.jsx("b",{children:E.toFixed(2)}),m.jsx("span",{children:["1m","5m","15m"][_]})]},_))}),m.jsx("div",{className:"sd-note",children:c[0]>f?`${(c[0]/f).toFixed(1)}× more work queued than cores to run it`:`within ${f} cores`})]}),m.jsxs("div",{className:"sd-section",role:"group","aria-label":"Busiest processes",children:[m.jsx("div",{className:"sd-h","aria-hidden":!0,children:"Busiest processes"}),i==null?m.jsx("div",{className:"sd-note",children:"reading…"}):i.length===0?m.jsx("div",{className:"sd-note",children:"Could not read the process list on this platform."}):m.jsxs("table",{className:"sd-procs",children:[m.jsx("thead",{children:m.jsxs("tr",{children:[m.jsx("th",{children:"cpu"}),m.jsx("th",{children:"mem"}),m.jsx("th",{children:"process"})]})}),m.jsx("tbody",{children:i.map(E=>m.jsxs("tr",{children:[m.jsx("td",{className:"sd-num",children:E.cpu==null?"—":E.cpu.toFixed(0)}),m.jsx("td",{className:"sd-num sd-dim",children:E.mem.toFixed(1)}),m.jsx("td",{className:"sd-proc-name",title:`pid ${E.pid}`,children:E.name})]},E.pid))})]})]})]})}function x_({label:e,used:t,total:r,pct:i,note:o}){const a=i>=90;return m.jsxs("div",{className:"sd-row",children:[m.jsxs("div",{className:"sd-row-head",children:[m.jsx("span",{className:"sd-row-label",children:e}),m.jsxs("span",{className:"sd-row-val",children:[m.jsx("b",{children:Ca(t)})," of ",Ca(r)]})]}),m.jsx("span",{className:"sd-track",children:m.jsx("span",{className:`sd-fill${a?" warn":""}`,style:{transform:`scaleX(${Math.max(1,Math.min(100,i))/100})`}})}),o&&m.jsx("div",{className:"sd-note",children:o})]})}const __=18,B3=1100,ro=(e,t)=>{const r=Math.sin(e*12.9898+t*78.233)*43758.5453;return r-Math.floor(r)},U3=Array.from({length:__},(e,t)=>{const r=-72+144*t/(__-1)+(ro(t,1)-.5)*9,i=(r-90)*(Math.PI/180),o=(54+32*Math.cos(r*Math.PI/180))*(.74+ro(t,2)*.52);return{dx:Math.cos(i)*o,dy:Math.sin(i)*o,rot:(t%2?1:-1)*(100+ro(t,3)*260),delay:Math.round(ro(t,4)*90),dur:760+Math.round(ro(t,5)*260),scale:.8+ro(t,6)*.45,hue:t%4,round:t%3===0}});function b_({anchor:e,lifetimeMs:t=B3}){var a;const[r,i]=R.useState(null),o=typeof window<"u"&&((a=window.matchMedia)==null?void 0:a.call(window,"(prefers-reduced-motion: reduce)").matches);return R.useEffect(()=>{if(o)return;const u=e.current;if(!u)return;const c=u.getBoundingClientRect();i({x:c.left+c.width/2,y:c.top+c.height/2});const f=window.setTimeout(()=>i(null),t);return()=>window.clearTimeout(f)},[e,t,o]),o||!r?null:hM.createPortal(m.jsx("div",{className:"confetti",style:{left:`${r.x}px`,top:`${r.y}px`},"aria-hidden":!0,children:U3.map((u,c)=>m.jsx("span",{className:`confetti-bit${u.round?" round":""}`,"data-hue":u.hue,style:{"--dx":`${u.dx.toFixed(1)}px`,"--dy":`${u.dy.toFixed(1)}px`,"--rot":`${u.rot}deg`,"--s":u.scale.toFixed(2),animationDelay:`${u.delay}ms`,animationDuration:`${u.dur}ms, ${u.dur}ms`}},c))}),document.body)}const QC=new Set(["awaiting_url","awaiting_code","registering"]);function H3(e){return e!=null&&QC.has(e)}function ZC(e){return e!=null&&e!=="done"&&!QC.has(e)}const W3="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",V3="the sign-in did not complete";function G3({state:e,serverError:t,localError:r}){const i=e==="idle";return{title:i?"Sign-in ended":"Sign-in failed",message:r||t||(i?W3:V3)}}const Y3="done";function K3(){let e=!1;return{shouldAnnounce(t){return t!==Y3?(e=!1,!1):e?!1:(e=!0,!0)}}}function my(e,t){return t&&Object.hasOwn(e,t)?e[t]:void 0}const X3={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 ccdeck1:",corrupt:"that share is incomplete — copy the whole thing",wrong_version:`that share was made by a newer ${Gt}`,expired:"that share has expired — make a new one",import_failed:"claude-swap refused the import",bad_value:"an alias can only use letters, numbers, spaces, dots, dashes and underscores, up to 64 characters"},Q3={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"},Z3=`claude-swap could not read the login keychain — start ${Gt} from a Terminal window rather than a background service`;function Dv(e,t){if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(vo(e)))return Z3;const r=my(Q3,e==null?void 0:e.reason);return r||(e==null?void 0:e.reason)||t}function vo(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const J3={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"},e$="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 t$(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const n$="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",r$="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",s$=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),i$=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,o$=/[\\/]_npx[\\/]/i,a$=`the copy of ccusage ${Gt} installed for itself`;function l$(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function u$(e,t){const r=c$(e,t),i=l$(e);switch(e==null?void 0:e.stage){case"npx":return i?`ccusage failed on both of its paths. The managed install failed first — ${i} — and the deck then fell back to npx, where ${da(r)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${da(r)}`;case"managed":return`${a$} failed to run: ${da(r)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${da(r)}`:`the ccusage this deck found on your PATH failed to run: ${da(r)}`;default:return r}}const da=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function c$(e,t){const r=vo(e);if(s$(r)){if(o$.test(r))return r$;if(i$.test(r))return n$}if(t$(r))return e$;const i=my(J3,e==null?void 0:e.reason);return i||(e==null?void 0:e.reason)||t}function vu(e,t){if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&ZC(e.state))return e.error;const r=my(X3,e==null?void 0:e.reason);return r||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}const d$=1500;async function ou(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const Fv=ue.forwardRef((e,t)=>m.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[m.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),m.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));Fv.displayName="SuccessMark";function f$({onClose:e,onChanged:t}){const[r,i]=R.useState("login"),[o,a]=R.useState(null),[u,c]=R.useState(""),[f,p]=R.useState(""),[d,g]=R.useState(!1),[y,w]=R.useState(null),[E,_]=R.useState(null),b=R.useRef(!1),S=R.useRef(null),k=R.useRef(null),N=R.useRef(null),j=R.useRef(null),A=R.useCallback(()=>{b.current&&ou({action:"login-cancel"}).catch(()=>{}),e()},[e]),M=wo(A,{focusRef:N}),P=R.useCallback(async()=>{g(!0),w(null),b.current=!0;const F=await ou({action:"login"}).catch(()=>null);if(g(!1),!(F!=null&&F.ok)){w(vu(F,"could not start the sign-in"));return}a(F)},[]);R.useEffect(()=>{if(!H3(o==null?void 0:o.state))return;const F=window.setInterval(async()=>{try{const $=await fetch("/api/claude-accounts/login");$.ok&&a(await $.json())}catch{}},d$);return()=>window.clearInterval(F)},[o]);const O=R.useRef(t);O.current=t;const D=R.useRef(K3());R.useEffect(()=>{var F;(o==null?void 0:o.state)==="awaiting_code"&&((F=S.current)==null||F.focus()),D.current.shouldAnnounce(o==null?void 0:o.state)&&O.current()},[o==null?void 0:o.state]),R.useEffect(()=>{var F;r==="paste"&&((F=k.current)==null||F.focus())},[r]);const L=R.useCallback(async()=>{var $;g(!0),w(null);const F=await ou({action:"login-code",code:u}).catch(()=>null);if(g(!1),!(F!=null&&F.ok)){w(vu(F,"the code was not accepted")),F!=null&&F.state&&a(F),($=S.current)==null||$.select();return}c(""),a(F)},[u,o]),U=R.useCallback(async()=>{g(!0),w(null);const F=await ou({action:"import",blob:f}).catch(()=>null);if(g(!1),!(F!=null&&F.ok)){w(vu(F,"the import failed"));return}p(""),_({added:F.added===!0,num:F.num??null,email:F.email??null}),t()},[f,t]),V=(o==null?void 0:o.state)==="done"?o.account:null,z=ZC(o==null?void 0:o.state)||!!(y&&b.current&&!d),C=G3({state:o==null?void 0:o.state,serverError:o==null?void 0:o.error,localError:y});return m.jsx("div",{className:"modal-backdrop",onClick:A,role:"presentation",children:m.jsxs("div",{ref:M,className:"modal aa-modal",onClick:F=>F.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[m.jsxs("header",{className:"modal-head",children:[m.jsx("div",{className:"modal-title",children:m.jsxs("span",{className:"aa-tabs",role:"tablist",children:[m.jsx("button",{type:"button",role:"tab","aria-selected":r==="login",className:`aa-tab${r==="login"?" on":""}`,onClick:()=>i("login"),children:"Sign in"}),m.jsx("button",{type:"button",role:"tab","aria-selected":r==="paste",className:`aa-tab${r==="paste"?" on":""}`,onClick:()=>i("paste"),children:"Paste a share"})]})}),m.jsx("div",{className:"modal-actions",children:m.jsx("button",{type:"button",className:"btn icon-btn",onClick:A,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),m.jsx("section",{className:"modal-body aa-body",children:r==="login"?V?m.jsxs("div",{className:"aa-done",children:[m.jsx(Fv,{ref:j}),m.jsx(b_,{anchor:j}),m.jsx("h4",{children:V.added?`Account ${V.num} added`:"Credentials refreshed"}),m.jsxs("p",{className:"aa-note",children:[m.jsx("strong",{children:V.email}),V.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),m.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"})]}):(o==null?void 0:o.state)==="awaiting_code"||(o==null?void 0:o.state)==="registering"?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"1 · Approve in the browser"}),m.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),m.jsx("a",{className:"aa-link",href:o.url??"#",target:"_blank",rel:"noreferrer noopener",children:o.url})]}),m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"2 · Paste the code it gives you"}),m.jsxs("div",{className:"aa-field",children:[m.jsx("input",{ref:S,type:"text",value:u,onChange:F=>c(F.target.value),onKeyDown:F=>{F.key==="Enter"&&u.trim()&&!d&&L()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:o.state==="registering"}),m.jsx("button",{type:"button",className:"btn primary",disabled:d||!u.trim()||o.state==="registering",onClick:L,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&m.jsx("p",{className:"aa-err",children:y??o.error}),m.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."})]})]}):z?m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:C.title}),m.jsx("p",{className:"aa-err",children:C.message}),m.jsx("button",{type:"button",className:"btn",onClick:()=>{b.current=!1,a(null),w(null),P()},children:"Try again"})]}):d||b.current?m.jsx("div",{className:"aa-step",children:m.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):m.jsxs("div",{className:"aa-step aa-primer",children:[m.jsx("h4",{children:"Sign in to Anthropic"}),m.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in, then asks for the code it shows you. claude-swap records the account when it completes, and the account you are using now stays active."}),m.jsx("div",{className:"aa-actions",children:m.jsx("button",{type:"button",ref:N,className:"btn primary",onClick:P,disabled:d,children:"Open the sign-in page"})})]}):E?m.jsxs("div",{className:"aa-done",children:[m.jsx(Fv,{ref:j}),E.added&&m.jsx(b_,{anchor:j}),m.jsx("h4",{children:E.added?`Account ${E.num} imported`:"Already here"}),m.jsx("p",{className:"aa-note",children:E.added?m.jsxs(m.Fragment,{children:[E.email?m.jsx("strong",{children:E.email}):"That account"," is in the rotation now. Nothing changed on the deck you copied it from."]}):"This deck already holds that account, so nothing changed."}),m.jsxs("div",{className:"aa-actions",children:[m.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),m.jsx("button",{type:"button",className:"btn",onClick:()=>_(null),children:"Import another"})]})]}):m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"Paste an account shared from another deck"}),m.jsxs("div",{className:"aa-field",children:[m.jsx("input",{ref:k,type:"text",value:f,onChange:F=>p(F.target.value),onKeyDown:F=>{F.key==="Enter"&&f.trim()&&!d&&U()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),m.jsx("button",{type:"button",className:"btn primary",disabled:d||!f.trim(),onClick:U,children:d?"importing…":"Import"})]}),y&&m.jsx("p",{className:"aa-err",children:y}),m.jsxs("p",{className:"aa-note",children:["Use ",m.jsx("strong",{children:"share"})," on an account in the other deck. A share carries a live login and expires ten minutes after it is made."]})]})})]})})}function h$(e,t){const r=new Set(e),i=e.length?Math.max(...e):0;return[...new Set([...e,i+1])].sort((o,a)=>o-a).map(o=>{const a=o===t?"here":r.has(o)?"swap":"free";return{slot:o,kind:a,label:a==="here"?`slot ${o}`:`slot ${o} · ${a}`}})}function p$(e,t,r){if(!(r!=null&&r.ok))return null;const i=Number.isInteger(r.to)?r.to:null;if(i==null)return{menuFor:null,confirmRemove:null,shareFor:null,swapNote:null};const o=r.swapped===!0&&i!==t;return{menuFor:e.menuFor===t?i:o&&e.menuFor===i?t:e.menuFor,confirmRemove:null,shareFor:null,swapNote:o?{at:i,displaced:t}:null}}const m$=64;function g$(e,t){const r=e.trim();return{alias:r,commit:r!==(t??"").trim()}}const v$=Object.freeze({text:"couldn't reach the deck server",reload:!0});async function S_(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function y$(e){const t=e.find(i=>!i.ok);if(!t)return null;const r=vo(t.body);return{text:Dv(t.body,`the deck server answered ${t.status}`),...r?{raw:r}:{},reload:!0}}function k_(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 E_=15e3,w$=8e3,x$=1800,_$=3e4,b$=[70,80,85,90,95];function N_(e,t){return GC(t-Math.floor(e/1e3))}function S$(e,t){if(!e)return"";const r=Math.floor(e/1e3)-t;return r<=0?" · due":r<60?` · next in ${r}s`:` · next in ${Math.round(r/60)}m`}function k$(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 E$({lane:e,nowSec:t}){const r=Math.min(100,Math.max(0,e.pct)),i=r>=90?"var(--err)":r>=70?"var(--warn)":"var(--accent)",o=e.resetAt?YC(e.resetAt,t):null;return m.jsxs("div",{className:"ap-lane",children:[m.jsx("span",{className:"ap-lane-label",children:e.label}),m.jsx("div",{className:"ap-lane-track",children:m.jsx("div",{className:"ap-lane-fill",style:{width:`${r===0?1.5:r}%`,background:i,opacity:r===0?.4:1}})}),m.jsxs("span",{className:"ap-lane-pct",style:{color:i},children:[r,"%"]}),m.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}async function N$(e){var r;let t=!1;try{t=await Promise.race([((r=navigator.clipboard)==null?void 0:r.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(i=>window.setTimeout(()=>i(!1),500))])}catch{t=!1}if(t)return!0;try{const i=document.createElement("textarea");i.value=e,i.setAttribute("readonly",""),i.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(i),i.select(),t=document.execCommand("copy"),i.remove()}catch{t=!1}return t}function C$(e,t){const r=Math.round(e/1e3)-t;return r<=0?{text:"expired",tone:"gone"}:r<60?{text:`expires in ${r}s`,tone:"soon"}:{text:`expires in ${Math.round(r/60)}m`,tone:"ok"}}function j$({onClose:e}){var ne,ae,fe;const[t,r]=R.useState(null),[i,o]=R.useState(null),[a,u]=R.useState(null),[c,f]=R.useState(!1),[p,d]=R.useState(null),[g,y]=R.useState(null),[w,E]=R.useState(()=>Math.floor(Date.now()/1e3)),_=R.useRef(null),[b,S]=R.useState(null),[k,N]=R.useState(!1),[j,A]=R.useState(""),[M,P]=R.useState(null),[O,D]=R.useState(null),[L,U]=R.useState(null),[V,z]=R.useState(!1),[C,F]=R.useState(null),$=R.useCallback(async(te=!1)=>{te&&f(!0);const ce=new AbortController,Ce=window.setTimeout(()=>ce.abort(),_$);try{const[ve,Re]=await Promise.all([fetch(`/api/claude-accounts${te?"?refresh=1":""}`,{signal:ce.signal}),fetch("/api/cswap-auto",{signal:ce.signal})]);ve.ok&&r(await ve.json()),Re.ok&&o(await Re.json());const ye=y$([await S_(ve),await S_(Re)]);y(Ee=>k_(Ee,ye))}catch{y(ve=>k_(ve,v$))}finally{window.clearTimeout(Ce),te&&f(!1)}},[]),re=R.useCallback(async(te,ce)=>{u(ce),y(null);try{const ve=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)})).json().catch(()=>null);return ve!=null&&ve.ok||y({text:Dv(ve,"command failed"),raw:vo(ve)}),ve}catch{return y({text:"server unreachable"}),null}finally{u(null)}},[]),J=R.useCallback(async(te,ce)=>{u(ce),y(null);try{const ve=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)})).json().catch(()=>null);return ve!=null&&ve.ok||y({text:vu(ve,"command failed")}),ve}catch{return y({text:"server unreachable"}),null}finally{u(null)}},[]);R.useEffect(()=>($(!0),_.current=window.setInterval(()=>$(!1),E_),()=>{_.current!=null&&window.clearInterval(_.current)}),[$]),R.useEffect(()=>{const te=window.setInterval(()=>E(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(te)},[]);const W=((ne=i==null?void 0:i.settings["autoswitch.threshold"])==null?void 0:ne.value)??"90",Z=(ae=t==null?void 0:t.accounts)==null?void 0:ae.find(te=>te.active),I=Z!=null&&Z.lanes.length?Math.max(...Z.lanes.map(te=>te.pct)):null,G=I!=null&&I>=Number(W)-15,K=async te=>{d(te),y(null);try{const Ce=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:te})})).json().catch(()=>null);Ce!=null&&Ce.ok||y({text:Dv(Ce,"the switch failed"),raw:vo(Ce)}),await $(!0)}catch{y({text:"server unreachable"})}finally{d(null)}},q=async(te,ce)=>{const{commit:Ce,alias:ve}=g$(j,ce);if(Ce){const Re=await J({action:"alias",account:te,alias:ve},`alias-${te}`);if(await $(!0),!(Re!=null&&Re.ok))return;A(ve)}P(te),window.setTimeout(()=>P(Re=>Re===te?null:Re),x$)},Q=async(te,ce)=>{const Ce=await J({action:"move",account:te,slot:ce},`move-${te}`),ve=p$({menuFor:b,shareFor:(L==null?void 0:L.num)??null},te,Ce);if(await $(!0),ve){S(ve.menuFor),D(ve.confirmRemove),ve.shareFor==null&&(U(null),z(!1)),F(ve.swapNote);const Re=ve.swapNote;Re&&window.setTimeout(()=>F(ye=>ye===Re?null:ye),w$)}};return m.jsxs("aside",{className:"accounts-panel",id:"accounts-panel","aria-label":"Claude accounts",children:[m.jsxs("div",{className:"ap-header",children:[m.jsx("h2",{children:"Accounts"}),m.jsxs("div",{className:"ap-header-right",children:[m.jsx("button",{type:"button",className:"btn ap-add",onClick:()=>N(!0),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),m.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>$(!0),disabled:c,"aria-label":"Reload accounts",title:"Reload from claude-swap",children:c?"…":"↻"}),m.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),t==null?g?m.jsxs("div",{className:"ap-empty",role:"alert",children:[m.jsx("span",{title:g.raw||void 0,children:g.text}),m.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",E_/1e3," seconds."]}),m.jsx("button",{type:"button",className:"ap-fix",disabled:c,onClick:()=>$(!0),children:c?"trying…":"try again"})]}):m.jsx("div",{className:"ap-empty",children:"Checking…"}):t.ok?m.jsxs(m.Fragment,{children:[(fe=t.accounts)==null?void 0:fe.map(te=>m.jsxs("div",{className:`ap-account${te.active?" active":""}${te.disabled?" disabled":""}`,children:[m.jsxs("div",{className:"ap-account-head",children:[m.jsx("span",{className:"ap-num",children:te.num}),te.alias&&m.jsx("span",{className:"ap-alias",title:te.alias,children:te.alias}),m.jsx("span",{className:"ap-email",title:te.org??void 0,children:te.email}),m.jsx("button",{type:"button",className:`ap-more${b===te.num?" on":""}`,"aria-label":`Manage account ${te.num}`,"aria-expanded":b===te.num,"aria-controls":b===te.num?`ap-manage-${te.num}`:void 0,title:"Share, rename, move, remove",onClick:()=>{S(b===te.num?null:te.num),A(te.alias??""),D(null),U(null),z(!1),F(null),P(null)},children:"⋯"}),te.active?m.jsx("span",{className:"ap-badge-active",children:"● active"}):m.jsx("button",{type:"button",className:"btn ap-switch",disabled:p!=null||te.disabled,onClick:()=>K(te.num),title:te.disabled?"Held out of rotation":`Switch to ${te.alias??te.email}`,children:p===te.num?"…":"switch"})]}),te.lanes.length>0?te.lanes.map(ce=>m.jsx(E$,{lane:ce,nowSec:w},ce.id)):m.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),m.jsxs("div",{className:"ap-meta",children:[te.error&&(()=>{const ce=k$(te.error);return m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"ap-err",title:ce.hint,children:ce.text}),ce.fixable&&m.jsx("button",{type:"button",className:"ap-fix",onClick:()=>N(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"sign in again"})]})})(),((i==null?void 0:i.enabled)||(i==null?void 0:i.external))&&!te.active&&m.jsx("button",{type:"button",className:"ap-rotate",disabled:a!=null,onClick:()=>re({action:"account",account:te.num,enabled:te.disabled},`rot-${te.num}`).then(()=>$(!0)),title:te.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:te.disabled?"held out":"in rotation"}),te.fetchedAt?m.jsxs("span",{className:`ap-age${te.stale?" 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 ",N_(te.fetchedAt,w),S$(te.nextAt,w)]}):m.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),b===te.num&&m.jsxs("div",{className:"ap-manage",id:`ap-manage-${te.num}`,role:"group","aria-label":`Manage account ${te.num}`,children:[m.jsxs("div",{className:"ap-manage-name",children:[m.jsx("label",{className:"vis-hidden",htmlFor:`ap-alias-${te.num}`,children:"Alias"}),m.jsx("input",{id:`ap-alias-${te.num}`,className:"ap-manage-input",type:"text",value:j,onChange:ce=>A(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&q(te.num,te.alias)},maxLength:m$,placeholder:"e.g. work",spellCheck:!1,autoFocus:!0}),m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:a!=null,onClick:()=>q(te.num,te.alias),title:"A short name to show instead of the email",children:M===te.num?"saved":"save"})]}),m.jsxs("div",{className:"ap-manage-acts",children:[m.jsx("label",{className:"vis-hidden",htmlFor:`ap-slot-${te.num}`,children:"Slot"}),m.jsx("span",{className:"ap-field",children:m.jsx("select",{id:`ap-slot-${te.num}`,value:String(te.num),disabled:a!=null,onChange:ce=>Q(te.num,Number(ce.target.value)),children:h$((t.accounts??[]).map(ce=>ce.num),te.num).map(ce=>m.jsx("option",{value:ce.slot,children:ce.label},ce.slot))})}),m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:a!=null,title:`Copy this account to another ${Gt}. 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:async()=>{z(!1);const ce=await J({action:"share",account:te.num},`share-${te.num}`);ce!=null&&ce.ok&&U({num:te.num,blob:ce.blob,expiresAt:ce.expiresAt})},children:"share"}),m.jsx("button",{type:"button",className:`ap-manage-btn danger${O===te.num?" armed":""}`,disabled:a!=null,title:O===te.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(O!==te.num){D(te.num),window.setTimeout(()=>D(ce=>ce===te.num?null:ce),4e3);return}D(null),J({action:"remove",account:te.num},`rm-${te.num}`).then(()=>{S(null),$(!0)})},children:O===te.num?"confirm":"remove"})]}),(C==null?void 0:C.at)===te.num&&(()=>{var ve;const ce=(ve=t.accounts)==null?void 0:ve.find(Re=>Re.num===C.displaced),Ce=(ce==null?void 0:ce.alias)??(ce==null?void 0:ce.email)??"the account that was there";return m.jsxs("span",{className:"ap-manage-hint ap-manage-swap",title:`Slot ${C.at} was taken, so the two accounts traded places: ${Ce} now holds slot ${C.displaced}.`,children:["swapped with slot ",C.displaced]})})(),(L==null?void 0:L.num)===te.num&&(()=>{const ce=C$(L.expiresAt,w),Ce=ce.tone==="gone";return m.jsxs("div",{className:`ap-share${Ce?" expired":""}`,children:[m.jsx("code",{className:"ap-share-blob",children:L.blob}),m.jsxs("div",{className:"ap-share-foot",children:[m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:a!=null,onClick:async()=>{if(Ce){z(!1);const ve=await J({action:"share",account:te.num},`share-${te.num}`);ve!=null&&ve.ok&&U({num:te.num,blob:ve.blob,expiresAt:ve.expiresAt});return}await N$(L.blob)&&(z(!0),window.setTimeout(()=>z(!1),1800))},children:Ce?"make a new share":V?"copied":"copy"}),m.jsxs("span",{className:"ap-manage-hint",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:[m.jsx("span",{className:"ap-share-warn",children:"this is the password"})," · ",m.jsx("span",{className:`ap-share-expiry ${ce.tone}`,children:ce.text})]})]})]})})()]})]},te.num)),(i==null?void 0:i.ok)&&m.jsxs("div",{className:"ap-auto",children:[m.jsxs("div",{className:"ap-auto-head",children:[m.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),m.jsxs("span",{className:"ap-auto-ctl",children:[I!=null&&m.jsxs("span",{className:`ap-auto-now${G?" near":""}`,children:[Math.round(I),"%"]}),m.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:m.jsx("select",{"aria-label":"Switch threshold",value:W,disabled:a!=null,onChange:te=>re({action:"setting",key:"autoswitch.threshold",value:te.target.value},"threshold").then(()=>$(!0)),children:b$.map(te=>m.jsxs("option",{value:te,children:[te,"%"]},te))})}),m.jsxs("button",{type:"button",className:`ap-auto-state${i.enabled?" live":""}`,role:"switch","aria-checked":i.enabled,disabled:a!=null,onClick:()=>re({action:"enable",enabled:!i.enabled},"enable").then(()=>$(!0)),title:i.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[m.jsx("i",{className:i.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),i.enabled?"on":"off"]})]})]}),i.external&&m.jsxs("p",{className:"ap-auto-note",children:[m.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",m.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",i.enabled?" — this toggle takes over when you stop it.":"."]}),i.lastTick&&m.jsx("div",{className:"ap-auto-foot",children:m.jsxs("span",{className:"ap-auto-result",children:["checked ",N_(i.lastTick.at,w)]})})]}),g&&m.jsxs("div",{className:"ap-failure",role:"alert",children:[m.jsx("span",{className:"ap-failure-text",title:g.raw||void 0,children:g.text}),m.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>y(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),m.jsx("p",{className:"ap-footnote",title:"Anthropic's usage endpoint allows roughly 28–30 requests per hour per account, shared by every tool on this machine — polling it from here would rate-limit your account. So the deck never fetches: it asks claude-swap to collect while this panel is open, at most once every three minutes, and claude-swap decides whether that touches the network at all.",children:"Collected by claude-swap while this panel is open."})]}):m.jsx("div",{className:"ap-empty",children:t.reason==="no_cswap"?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"claude-swap isn't installed."}),m.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."}),t.hint&&m.jsx("code",{className:"ap-cmd",children:t.hint}),m.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",m.jsx("strong",{children:"+"})," button above."]})]}):t.reason==="no_accounts"?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"No accounts added yet."}),m.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",m.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"Couldn't read the account store."}),m.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",t.reason?` (${t.reason})`:"","."]})]})}),k&&m.jsx(f$,{onClose:()=>N(!1),onChanged:()=>$(!0)})]})}const T$=3e4;function R$({bundle:e,running:t,lastTried:r}){return!t||e===t?!1:r!==t}function A$({bundle:e,running:t,pending:r,lastTried:i}){return t?R$({bundle:e,running:t,lastTried:i})?"reload":r==null||r&&r!==t?"wait":"confirm":"wait"}function I$(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function M$({asked:e,reported:t}){return t?t!==e:!1}function O$(e){const t=e.thresholdMs??T$;return!e.enabled||e.kind!=="restart"||!e.canRestart?{idleSince:null,restart:!1}:e.busy?{idleSince:null,restart:!1}:e.idleSince==null?{idleSince:e.now,restart:!1}:e.now<e.idleSince?{idleSince:e.now,restart:!1}:{idleSince:e.idleSince,restart:e.now-e.idleSince>=t}}function P$({agentCount:e,onConfirm:t,onCancel:r}){const i=R.useRef(null),o=wo(r,{focusRef:i,layer:rL}),a=e===0?"This deletes the server's event log":`This removes ${e===1?"the one agent":`all ${e} agents`} on the canvas and deletes the server's event log`;return m.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:m.jsxs("div",{ref:o,className:"modal clear-confirm",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[m.jsxs("header",{className:"modal-head",children:[m.jsxs("div",{className:"modal-title",children:[m.jsx("span",{className:"status-dot err","aria-hidden":!0}),m.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),m.jsx("div",{className:"modal-actions",children:m.jsx("button",{type:"button",className:"btn icon-btn",onClick:r,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),m.jsxs("section",{className:"modal-body",children:[m.jsxs("p",{className:"modal-note",children:[a," — the file a restarted deck replays to rebuild what you see. Layout, pins and selection go with it. This cannot be undone."]}),m.jsxs("div",{className:"cc-actions",children:[m.jsx("button",{type:"button",ref:i,className:"btn",onClick:r,children:"Cancel"}),m.jsx("button",{type:"button",className:"btn danger",onClick:t,children:"Clear everything"})]})]})]})})}function L$(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function $$(e){return e.slice().sort((t,r)=>t.y-r.y||t.x-r.x)}function q$(e,t,r){var u;if(e.length===0)return null;const i=$$(e),o=t?i.findIndex(c=>c.id===t):-1,a=o===-1?r===1?0:i.length-1:(o+r+i.length)%i.length;return((u=i[a])==null?void 0:u.id)??null}const D$=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Delete","Backspace"]);function F$(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:D$.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const z$=new Set(["","BODY","HTML","#DOCUMENT"]);function B$(e){return!e||cy(e)?!1:!z$.has(String(e.tagName??"").toUpperCase())}function au(e,t){if(t.size!==0)for(const r of Array.from(e.keys()))t.has(r)||e.delete(r)}function U$(e){const t=new Set;for(const r of e)t.add(r.id),t.add(`group:${r.sessionId}`);return t}function JC(e,t,r){return!t.has(e)||r.has(e)}function H$(e,t,r,i){return!t.has(e)&&JC(e,r,i)}function W$(e,t,r){const i={x:0,y:0};return t.set(e,i),r.add(e),i}function V$(e,t,r,i){r.set(e,t),i.delete(e)}const G$=40,Y$=120;function K$(e,t){let r=null,i=0,o=Number.NEGATIVE_INFINITY;const a=()=>{r=null,o=t.now(),e()},u=()=>{r!=null&&(t.clearTimeout(r),r=null)},c=(f,p,d)=>{if(r!=null){if(i<=f)return;u()}const g=Math.min(d,Math.max(0,f-p));i=f,r=t.setTimeout(a,g)};return{live(f=G$){const p=t.now(),d=Math.max(o+f,p);if(d<=p){u(),a();return}c(d,p,f)},replay(f=Y$){u(),i=t.now()+f,r=t.setTimeout(a,f)},flush(){u(),a()},cancel(){u()}}}function X$(){let e=!1,t=[];return{get paused(){return e},get size(){return t.length},accept(r){return e?(t.push(r),!1):!0},setPaused(r){if(e=r,r||t.length===0)return[];const i=t;return t=[],i}}}const ej="agent-dag.theme";function Q$(e){return e==="light"?"light":"dark"}function Z$(){return Q$(py(ej))}function J$({waiting:e,running:t}){return{title:e>0?`(${e}) ${Gt}`:Gt,icon:e>0?"waiting":t>0?"running":"idle"}}const Zd={waiting:"#c97d12",running:"#2a90d4",idle:"#7e828c"};function Jd(e,t){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">${t==="waiting"?`<circle cx="16" cy="16" r="14.5" fill="${e}"/>`:`<circle cx="16" cy="16" r="12" fill="none" stroke="${e}" stroke-width="5"/>`+(t==="running"?`<circle cx="16" cy="16" r="5" fill="${e}"/>`:"")}</svg>`}const eq=Object.freeze({waiting:`data:image/svg+xml,${encodeURIComponent(Jd(Zd.waiting,"waiting"))}`,running:`data:image/svg+xml,${encodeURIComponent(Jd(Zd.running,"running"))}`,idle:`data:image/svg+xml,${encodeURIComponent(Jd(Zd.idle,"idle"))}`}),tq="No sessions are waiting for you.";function nq(e){if(e.length===0)return"";const[t,...r]=e;if(r.length===0)return`${t.label} is waiting for your permission.`;const i=`${r.length} more session${r.length===1?"":"s"}`;return`${t.label} and ${i} are waiting for your permission.`}function rq(e,t){return t!==""?t:e===""?"":tq}function sq(){let e=0;return{begin(){const t=++e;return()=>t===e},cancel(){e++}}}function iq(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}function oq(e){return!e.answer||e.answer.range!==e.want?{phase:"busy",stale:!1}:e.answer.ok?{phase:e.answer.days>0?"chart":"empty",stale:e.loading}:{phase:"error",stale:e.loading}}function tj(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const C_={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent"};function gy(e){const t=e.toLowerCase();return Object.hasOwn(C_,t)?C_[t]:t?t[0].toUpperCase()+t.slice(1):""}function aq(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function lq(e,t=[]){const r=t.length?aq(t.map(gy)):tj(e);return r?`via ccusage · local ${r} logs`:"via ccusage · local agent logs"}function uq(e){return e.claude&&e.codex?"Claude Code hooks and Codex rollout files":e.claude?"Claude Code hooks":e.codex?"Codex rollout files":null}function cq(e){const t=tj(e);return t?`Distinct sessions — ${t}`:"Distinct sessions"}function dq(e){const t=uq(e);return t?`Total events received — ${t}`:"Total events received"}function fq(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:"."}]},r=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,r]}function hq(e,t){const r=t.on?"Sound on turn finish: on — click to remove the hook":"Sound on turn finish: off — click to add a Stop hook",i=e.codex?`
|
|
68
68
|
|
|
69
69
|
Claude Code turns only. The sound is a Stop hook Claude Code runs itself when a turn ends; the deck installs nothing for Codex and reads its rollout files after the fact, so Codex turns finish in silence.`:"",o=t.clash>0?`
|
|
70
70
|
|
|
71
71
|
${t.clash} sound hook${t.clash>1?"s":""} of your own in settings.json also run${t.clash>1?"":"s"} here.`:"",a=t.parked>0?`
|
|
72
72
|
|
|
73
|
-
${t.parked} of your own sound hook${t.parked>1?"s were":" was"} set aside so this switch actually controls the sound. Nothing was deleted — shift-click to put ${t.parked>1?"them":"it"} back.`:"";return r+i+o+a}function nj(e){const t=new Map;for(const r of e)for(const i of r.agents??[]){if(!i||typeof i.agent!="string"||i.agent==="")continue;const o=t.get(i.agent)??{id:i.agent,cost:0,tokens:0};o.cost+=Number.isFinite(i.totalCost)?i.totalCost:0,o.tokens+=Number.isFinite(i.totalTokens)?i.totalTokens:0,t.set(i.agent,o)}return[...t.values()].sort((r,i)=>i.cost-r.cost||r.id.localeCompare(i.id))}function pq(e){const t=nj([{agents:e}]);return t.length<2?null:t.map(r=>`${gy(r.id)} ${qe(r.cost)}`).join(" · ")}function j_(e){switch(e.toLowerCase()){case"claude":return"#c4b5fd";case"codex":return"#fdba74";case"gemini":return"#a5b4fc";case"copilot":return"#86efac";default:return"#94a3b8"}}function mq(e,t){if(!(t>0)||!(e>0))return"0%";const r=e/t*100;return r<.1?"<0.1%":`${r.toFixed(1)}%`}function lu(e){const t=e.toLowerCase();return t.includes("opus")?"#c4b5fd":t.includes("sonnet")?"#7dd3fc":t.includes("haiku")?"#86efac":t.includes("gpt-5")||t.includes("gpt5")?"#fcd34d":t.includes("gpt")?"#fca5a5":t.includes("gemini")?"#a5b4fc":t.includes("codex")?"#fdba74":"#94a3b8"}const gq=[7,14,30,90];function vq(e){const[t,r]=R.useState(null),[i,o]=R.useState(!1),a=R.useRef(sq()).current,u=(c=!1)=>{const f=a.begin(),p=e;o(!0);const g=`/api/ccusage?since=${iq(p)}${c?"&refresh=1":""}`;fetch(g).then(y=>y.json()).then(y=>{f()&&r({range:p,resp:y})}).catch(()=>{f()&&r({range:p,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{f()&&o(!1)})};return R.useEffect(()=>(u(!1),()=>a.cancel()),[e]),{landed:t,loading:i,reload:()=>u(!0)}}function yq({onClose:e,providers:t}){var P;const[r,i]=R.useState(30),[o,a]=R.useState(null),{landed:u,loading:c,reload:f}=vq(r),p=R.useRef(null),d=wo(e,{focusRef:p}),g=oq({loading:c,want:r,answer:u&&{range:u.range,ok:u.resp.ok===!0,days:((P=u.resp.days)==null?void 0:P.length)??0}}),y=g.phase==="chart"?u.resp.days??[]:[],w=R.useMemo(()=>y.reduce((O,D)=>Math.max(O,D.totalCost),0),[y]),{totalCost:E,totalTok:_,inOut:b,cacheRead:S,modelCosts:k}=R.useMemo(()=>{let O=0,D=0,L=0,U=0;const V=new Map;for(const z of y){O+=z.totalCost,D+=z.totalTokens,L+=z.inputTokens+z.outputTokens,U+=z.cacheReadTokens;for(const C of z.modelBreakdowns)V.set(C.modelName,(V.get(C.modelName)??0)+C.cost)}return{totalCost:O,totalTok:D,inOut:L,cacheRead:U,modelCosts:V}},[y]),N=R.useMemo(()=>Array.from(k.entries()).sort((O,D)=>D[1]-O[1]),[k]),j=R.useMemo(()=>nj(y),[y]),A=j.length>1,M=o?y.find(O=>O.period===o)??null:null;return m.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:m.jsxs("div",{ref:d,className:"uh-modal",onClick:O=>O.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Usage history",children:[m.jsxs("header",{className:"uh-head",children:[m.jsxs("div",{className:"uh-titlewrap",children:[m.jsx("div",{className:"uh-title",children:"Usage history"}),m.jsx("div",{className:"uh-sub",children:lq(t,j.map(O=>O.id))})]}),m.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:gq.map(O=>m.jsxs("button",{type:"button","aria-pressed":r===O,className:`uh-range-btn${r===O?" on":""}`,onClick:()=>{i(O),a(null)},children:[O,"d"]},O))}),m.jsx("button",{className:"btn icon-btn uh-reload",onClick:f,disabled:c,title:"Re-run ccusage","aria-label":"Reload",children:c?"…":"↻"}),m.jsx("button",{ref:p,className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),g.phase==="busy"?m.jsx("div",{className:"uh-status","aria-busy":"true",children:u?"running ccusage…":"running ccusage… (first run downloads the package)"}):g.phase==="error"?m.jsxs("div",{className:"uh-status uh-err",title:vo(u.resp)||void 0,children:[u3(u.resp,"ccusage did not report usage"),m.jsx("div",{children:m.jsx("button",{className:"btn uh-retry",onClick:f,disabled:c,children:c?"trying…":"Try again"})})]}):g.phase==="empty"?m.jsx("div",{className:`uh-status${g.stale?" uh-stale":""}`,"aria-busy":g.stale||void 0,children:"no usage in this range"}):m.jsxs("div",{className:g.stale?"uh-stale":void 0,"aria-busy":g.stale||void 0,children:[m.jsxs("div",{className:"uh-totals",children:[m.jsx(uu,{label:"total cost",val:qe(E),accent:!0}),m.jsx(uu,{label:"tokens",val:Nt(_)}),m.jsx(uu,{label:"input+output",val:Nt(b)}),m.jsx(uu,{label:"cache reads",val:Nt(S)})]}),A&&m.jsxs("div",{className:"uh-agents",role:"group","aria-label":"Cost by CLI",children:[m.jsx("div",{className:"uh-agent-bar","aria-hidden":"true",children:j.map(O=>m.jsx("span",{className:"uh-agent-seg",style:{width:`${E>0?O.cost/E*100:0}%`,background:j_(O.id)}},O.id))}),m.jsx("div",{className:"uh-agent-keys",children:j.map(O=>m.jsxs("span",{className:"uh-agent-key",title:`${O.id} · ${Nt(O.tokens)} tokens`,children:[m.jsx("span",{className:"uh-legend-dot",style:{background:j_(O.id)}}),gy(O.id),m.jsx("span",{className:"uh-agent-cost",children:qe(O.cost)}),m.jsx("span",{className:"uh-agent-share",children:mq(O.cost,E)})]},O.id))})]}),m.jsx("div",{className:"uh-chart",role:"group","aria-label":"Daily cost by model",children:y.map(O=>{const D=w>0?O.totalCost/w*100:0,L=O.period===o,U=`${O.period}, ${qe(O.totalCost)}`;return m.jsxs("button",{className:`uh-bar-col${L?" sel":""}`,onClick:()=>a(L?null:O.period),"aria-pressed":L,"aria-label":U,title:`${O.period} · ${qe(O.totalCost)}`,style:{flexBasis:`${100/y.length}%`},children:[m.jsx("div",{className:"uh-bar",style:{height:`${Math.max(D,O.totalCost>0?2:0)}%`},children:O.modelBreakdowns.slice().sort((V,z)=>z.cost-V.cost).map(V=>{const z=O.totalCost>0?V.cost/O.totalCost*100:0;return m.jsx("div",{className:"uh-bar-seg",style:{height:`${z}%`,background:lu(V.modelName)}},V.modelName)})}),m.jsx("span",{className:"uh-bar-label",children:O.period.slice(5)})]},O.period)})}),m.jsx("div",{className:"uh-legend",children:N.map(([O,D])=>m.jsxs("span",{className:"uh-legend-item",title:O,children:[m.jsx("span",{className:"uh-legend-dot",style:{background:lu(O)}}),Rs(O)," ",m.jsx("span",{className:"uh-legend-cost",children:qe(D)})]},O))}),M&&m.jsxs("div",{className:"uh-detail",children:[m.jsxs("div",{className:"uh-detail-head",children:[m.jsx("span",{className:"uh-detail-date",children:M.period}),m.jsx("span",{className:"uh-detail-cost",children:qe(M.totalCost)}),(()=>{var L,U;const D=pq(M.agents)??((U=(L=M.metadata)==null?void 0:L.agents)!=null&&U.length?M.metadata.agents.join(" · "):null);return D?m.jsx("span",{className:"uh-detail-agents",title:D,children:D}):null})()]}),m.jsxs("div",{className:"uh-detail-mini",children:[m.jsx(cu,{label:"input",val:Nt(M.inputTokens)}),m.jsx(cu,{label:"output",val:Nt(M.outputTokens)}),m.jsx(cu,{label:"cache write",val:Nt(M.cacheCreationTokens)}),m.jsx(cu,{label:"cache read",val:Nt(M.cacheReadTokens)})]}),m.jsx("div",{className:"uh-detail-models",children:M.modelBreakdowns.slice().sort((O,D)=>D.cost-O.cost).map(O=>{const D=M.totalCost>0?O.cost/M.totalCost*100:0;return m.jsxs("div",{className:"uh-model-row",title:O.modelName,children:[m.jsxs("span",{className:"uh-model-name",children:[m.jsx("span",{className:"uh-legend-dot",style:{background:lu(O.modelName)}}),m.jsx("span",{className:"uh-model-label",children:Rs(O.modelName)})]}),m.jsx("span",{className:"uh-model-bar",children:m.jsx("span",{className:"uh-model-bar-fill",style:{width:`${D}%`,background:lu(O.modelName)}})}),m.jsx("span",{className:"uh-model-cost",children:qe(O.cost)})]},O.modelName)})})]})]})]})})}function uu({label:e,val:t,accent:r}){return m.jsxs("div",{className:"uh-stat",children:[m.jsx("span",{className:`uh-stat-val${r?" accent":""}`,children:t}),m.jsx("span",{className:"uh-stat-label",children:e})]})}function cu({label:e,val:t}){return m.jsxs("div",{className:"uh-ministat",children:[m.jsx("span",{className:"uh-ministat-val",children:t}),m.jsx("span",{className:"uh-ministat-label",children:e})]})}function vy(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 ef,T_;function wq(){if(T_)return ef;T_=1;function e(){this.__data__=[],this.size=0}return ef=e,ef}var tf,R_;function xo(){if(R_)return tf;R_=1;function e(t,r){return t===r||t!==t&&r!==r}return tf=e,tf}var nf,A_;function Bu(){if(A_)return nf;A_=1;var e=xo();function t(r,i){for(var o=r.length;o--;)if(e(r[o][0],i))return o;return-1}return nf=t,nf}var rf,I_;function xq(){if(I_)return rf;I_=1;var e=Bu(),t=Array.prototype,r=t.splice;function i(o){var a=this.__data__,u=e(a,o);if(u<0)return!1;var c=a.length-1;return u==c?a.pop():r.call(a,u,1),--this.size,!0}return rf=i,rf}var sf,M_;function _q(){if(M_)return sf;M_=1;var e=Bu();function t(r){var i=this.__data__,o=e(i,r);return o<0?void 0:i[o][1]}return sf=t,sf}var of,O_;function bq(){if(O_)return of;O_=1;var e=Bu();function t(r){return e(this.__data__,r)>-1}return of=t,of}var af,P_;function Sq(){if(P_)return af;P_=1;var e=Bu();function t(r,i){var o=this.__data__,a=e(o,r);return a<0?(++this.size,o.push([r,i])):o[a][1]=i,this}return af=t,af}var lf,L_;function Uu(){if(L_)return lf;L_=1;var e=wq(),t=xq(),r=_q(),i=bq(),o=Sq();function a(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var p=u[c];this.set(p[0],p[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=i,a.prototype.set=o,lf=a,lf}var uf,$_;function kq(){if($_)return uf;$_=1;var e=Uu();function t(){this.__data__=new e,this.size=0}return uf=t,uf}var cf,q_;function Eq(){if(q_)return cf;q_=1;function e(t){var r=this.__data__,i=r.delete(t);return this.size=r.size,i}return cf=e,cf}var df,D_;function Nq(){if(D_)return df;D_=1;function e(t){return this.__data__.get(t)}return df=e,df}var ff,F_;function Cq(){if(F_)return ff;F_=1;function e(t){return this.__data__.has(t)}return ff=e,ff}var hf,z_;function rj(){if(z_)return hf;z_=1;var e=typeof Gl=="object"&&Gl&&Gl.Object===Object&&Gl;return hf=e,hf}var pf,B_;function rr(){if(B_)return pf;B_=1;var e=rj(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return pf=r,pf}var mf,U_;function _o(){if(U_)return mf;U_=1;var e=rr(),t=e.Symbol;return mf=t,mf}var gf,H_;function jq(){if(H_)return gf;H_=1;var e=_o(),t=Object.prototype,r=t.hasOwnProperty,i=t.toString,o=e?e.toStringTag:void 0;function a(u){var c=r.call(u,o),f=u[o];try{u[o]=void 0;var p=!0}catch{}var d=i.call(u);return p&&(c?u[o]=f:delete u[o]),d}return gf=a,gf}var vf,W_;function Tq(){if(W_)return vf;W_=1;var e=Object.prototype,t=e.toString;function r(i){return t.call(i)}return vf=r,vf}var yf,V_;function gi(){if(V_)return yf;V_=1;var e=_o(),t=jq(),r=Tq(),i="[object Null]",o="[object Undefined]",a=e?e.toStringTag:void 0;function u(c){return c==null?c===void 0?o:i:a&&a in Object(c)?t(c):r(c)}return yf=u,yf}var wf,G_;function qn(){if(G_)return wf;G_=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return wf=e,wf}var xf,Y_;function $a(){if(Y_)return xf;Y_=1;var e=gi(),t=qn(),r="[object AsyncFunction]",i="[object Function]",o="[object GeneratorFunction]",a="[object Proxy]";function u(c){if(!t(c))return!1;var f=e(c);return f==i||f==o||f==r||f==a}return xf=u,xf}var _f,K_;function Rq(){if(K_)return _f;K_=1;var e=rr(),t=e["__core-js_shared__"];return _f=t,_f}var bf,X_;function Aq(){if(X_)return bf;X_=1;var e=Rq(),t=(function(){var i=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""})();function r(i){return!!t&&t in i}return bf=r,bf}var Sf,Q_;function sj(){if(Q_)return Sf;Q_=1;var e=Function.prototype,t=e.toString;function r(i){if(i!=null){try{return t.call(i)}catch{}try{return i+""}catch{}}return""}return Sf=r,Sf}var kf,Z_;function Iq(){if(Z_)return kf;Z_=1;var e=$a(),t=Aq(),r=qn(),i=sj(),o=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,f=u.toString,p=c.hasOwnProperty,d=RegExp("^"+f.call(p).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function g(y){if(!r(y)||t(y))return!1;var w=e(y)?d:a;return w.test(i(y))}return kf=g,kf}var Ef,J_;function Mq(){if(J_)return Ef;J_=1;function e(t,r){return t==null?void 0:t[r]}return Ef=e,Ef}var Nf,e1;function vi(){if(e1)return Nf;e1=1;var e=Iq(),t=Mq();function r(i,o){var a=t(i,o);return e(a)?a:void 0}return Nf=r,Nf}var Cf,t1;function yy(){if(t1)return Cf;t1=1;var e=vi(),t=rr(),r=e(t,"Map");return Cf=r,Cf}var jf,n1;function Hu(){if(n1)return jf;n1=1;var e=vi(),t=e(Object,"create");return jf=t,jf}var Tf,r1;function Oq(){if(r1)return Tf;r1=1;var e=Hu();function t(){this.__data__=e?e(null):{},this.size=0}return Tf=t,Tf}var Rf,s1;function Pq(){if(s1)return Rf;s1=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return Rf=e,Rf}var Af,i1;function Lq(){if(i1)return Af;i1=1;var e=Hu(),t="__lodash_hash_undefined__",r=Object.prototype,i=r.hasOwnProperty;function o(a){var u=this.__data__;if(e){var c=u[a];return c===t?void 0:c}return i.call(u,a)?u[a]:void 0}return Af=o,Af}var If,o1;function $q(){if(o1)return If;o1=1;var e=Hu(),t=Object.prototype,r=t.hasOwnProperty;function i(o){var a=this.__data__;return e?a[o]!==void 0:r.call(a,o)}return If=i,If}var Mf,a1;function qq(){if(a1)return Mf;a1=1;var e=Hu(),t="__lodash_hash_undefined__";function r(i,o){var a=this.__data__;return this.size+=this.has(i)?0:1,a[i]=e&&o===void 0?t:o,this}return Mf=r,Mf}var Of,l1;function Dq(){if(l1)return Of;l1=1;var e=Oq(),t=Pq(),r=Lq(),i=$q(),o=qq();function a(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var p=u[c];this.set(p[0],p[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=i,a.prototype.set=o,Of=a,Of}var Pf,u1;function Fq(){if(u1)return Pf;u1=1;var e=Dq(),t=Uu(),r=yy();function i(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return Pf=i,Pf}var Lf,c1;function zq(){if(c1)return Lf;c1=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return Lf=e,Lf}var $f,d1;function Wu(){if(d1)return $f;d1=1;var e=zq();function t(r,i){var o=r.__data__;return e(i)?o[typeof i=="string"?"string":"hash"]:o.map}return $f=t,$f}var qf,f1;function Bq(){if(f1)return qf;f1=1;var e=Wu();function t(r){var i=e(this,r).delete(r);return this.size-=i?1:0,i}return qf=t,qf}var Df,h1;function Uq(){if(h1)return Df;h1=1;var e=Wu();function t(r){return e(this,r).get(r)}return Df=t,Df}var Ff,p1;function Hq(){if(p1)return Ff;p1=1;var e=Wu();function t(r){return e(this,r).has(r)}return Ff=t,Ff}var zf,m1;function Wq(){if(m1)return zf;m1=1;var e=Wu();function t(r,i){var o=e(this,r),a=o.size;return o.set(r,i),this.size+=o.size==a?0:1,this}return zf=t,zf}var Bf,g1;function wy(){if(g1)return Bf;g1=1;var e=Fq(),t=Bq(),r=Uq(),i=Hq(),o=Wq();function a(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var p=u[c];this.set(p[0],p[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=i,a.prototype.set=o,Bf=a,Bf}var Uf,v1;function Vq(){if(v1)return Uf;v1=1;var e=Uu(),t=yy(),r=wy(),i=200;function o(a,u){var c=this.__data__;if(c instanceof e){var f=c.__data__;if(!t||f.length<i-1)return f.push([a,u]),this.size=++c.size,this;c=this.__data__=new r(f)}return c.set(a,u),this.size=c.size,this}return Uf=o,Uf}var Hf,y1;function Vu(){if(y1)return Hf;y1=1;var e=Uu(),t=kq(),r=Eq(),i=Nq(),o=Cq(),a=Vq();function u(c){var f=this.__data__=new e(c);this.size=f.size}return u.prototype.clear=t,u.prototype.delete=r,u.prototype.get=i,u.prototype.has=o,u.prototype.set=a,Hf=u,Hf}var Wf,w1;function xy(){if(w1)return Wf;w1=1;function e(t,r){for(var i=-1,o=t==null?0:t.length;++i<o&&r(t[i],i,t)!==!1;);return t}return Wf=e,Wf}var Vf,x1;function ij(){if(x1)return Vf;x1=1;var e=vi(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return Vf=t,Vf}var Gf,_1;function Gu(){if(_1)return Gf;_1=1;var e=ij();function t(r,i,o){i=="__proto__"&&e?e(r,i,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[i]=o}return Gf=t,Gf}var Yf,b1;function Yu(){if(b1)return Yf;b1=1;var e=Gu(),t=xo(),r=Object.prototype,i=r.hasOwnProperty;function o(a,u,c){var f=a[u];(!(i.call(a,u)&&t(f,c))||c===void 0&&!(u in a))&&e(a,u,c)}return Yf=o,Yf}var Kf,S1;function qa(){if(S1)return Kf;S1=1;var e=Yu(),t=Gu();function r(i,o,a,u){var c=!a;a||(a={});for(var f=-1,p=o.length;++f<p;){var d=o[f],g=u?u(a[d],i[d],d,a,i):void 0;g===void 0&&(g=i[d]),c?t(a,d,g):e(a,d,g)}return a}return Kf=r,Kf}var Xf,k1;function Gq(){if(k1)return Xf;k1=1;function e(t,r){for(var i=-1,o=Array(t);++i<t;)o[i]=r(i);return o}return Xf=e,Xf}var Qf,E1;function mr(){if(E1)return Qf;E1=1;function e(t){return t!=null&&typeof t=="object"}return Qf=e,Qf}var Zf,N1;function Yq(){if(N1)return Zf;N1=1;var e=gi(),t=mr(),r="[object Arguments]";function i(o){return t(o)&&e(o)==r}return Zf=i,Zf}var Jf,C1;function Da(){if(C1)return Jf;C1=1;var e=Yq(),t=mr(),r=Object.prototype,i=r.hasOwnProperty,o=r.propertyIsEnumerable,a=e((function(){return arguments})())?e:function(u){return t(u)&&i.call(u,"callee")&&!o.call(u,"callee")};return Jf=a,Jf}var eh,j1;function _t(){if(j1)return eh;j1=1;var e=Array.isArray;return eh=e,eh}var ma={exports:{}},th,T1;function Kq(){if(T1)return th;T1=1;function e(){return!1}return th=e,th}ma.exports;var R1;function bo(){return R1||(R1=1,(function(e,t){var r=rr(),i=Kq(),o=t&&!t.nodeType&&t,a=o&&!0&&e&&!e.nodeType&&e,u=a&&a.exports===o,c=u?r.Buffer:void 0,f=c?c.isBuffer:void 0,p=f||i;e.exports=p})(ma,ma.exports)),ma.exports}var nh,A1;function Ku(){if(A1)return nh;A1=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(i,o){var a=typeof i;return o=o??e,!!o&&(a=="number"||a!="symbol"&&t.test(i))&&i>-1&&i%1==0&&i<o}return nh=r,nh}var rh,I1;function _y(){if(I1)return rh;I1=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return rh=t,rh}var sh,M1;function Xq(){if(M1)return sh;M1=1;var e=gi(),t=_y(),r=mr(),i="[object Arguments]",o="[object Array]",a="[object Boolean]",u="[object Date]",c="[object Error]",f="[object Function]",p="[object Map]",d="[object Number]",g="[object Object]",y="[object RegExp]",w="[object Set]",E="[object String]",_="[object WeakMap]",b="[object ArrayBuffer]",S="[object DataView]",k="[object Float32Array]",N="[object Float64Array]",j="[object Int8Array]",A="[object Int16Array]",M="[object Int32Array]",P="[object Uint8Array]",O="[object Uint8ClampedArray]",D="[object Uint16Array]",L="[object Uint32Array]",U={};U[k]=U[N]=U[j]=U[A]=U[M]=U[P]=U[O]=U[D]=U[L]=!0,U[i]=U[o]=U[b]=U[a]=U[S]=U[u]=U[c]=U[f]=U[p]=U[d]=U[g]=U[y]=U[w]=U[E]=U[_]=!1;function V(z){return r(z)&&t(z.length)&&!!U[e(z)]}return sh=V,sh}var ih,O1;function Xu(){if(O1)return ih;O1=1;function e(t){return function(r){return t(r)}}return ih=e,ih}var ga={exports:{}};ga.exports;var P1;function by(){return P1||(P1=1,(function(e,t){var r=rj(),i=t&&!t.nodeType&&t,o=i&&!0&&e&&!e.nodeType&&e,a=o&&o.exports===i,u=a&&r.process,c=(function(){try{var f=o&&o.require&&o.require("util").types;return f||u&&u.binding&&u.binding("util")}catch{}})();e.exports=c})(ga,ga.exports)),ga.exports}var oh,L1;function Fa(){if(L1)return oh;L1=1;var e=Xq(),t=Xu(),r=by(),i=r&&r.isTypedArray,o=i?t(i):e;return oh=o,oh}var ah,$1;function oj(){if($1)return ah;$1=1;var e=Gq(),t=Da(),r=_t(),i=bo(),o=Ku(),a=Fa(),u=Object.prototype,c=u.hasOwnProperty;function f(p,d){var g=r(p),y=!g&&t(p),w=!g&&!y&&i(p),E=!g&&!y&&!w&&a(p),_=g||y||w||E,b=_?e(p.length,String):[],S=b.length;for(var k in p)(d||c.call(p,k))&&!(_&&(k=="length"||w&&(k=="offset"||k=="parent")||E&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||o(k,S)))&&b.push(k);return b}return ah=f,ah}var lh,q1;function Qu(){if(q1)return lh;q1=1;var e=Object.prototype;function t(r){var i=r&&r.constructor,o=typeof i=="function"&&i.prototype||e;return r===o}return lh=t,lh}var uh,D1;function aj(){if(D1)return uh;D1=1;function e(t,r){return function(i){return t(r(i))}}return uh=e,uh}var ch,F1;function Qq(){if(F1)return ch;F1=1;var e=aj(),t=e(Object.keys,Object);return ch=t,ch}var dh,z1;function Sy(){if(z1)return dh;z1=1;var e=Qu(),t=Qq(),r=Object.prototype,i=r.hasOwnProperty;function o(a){if(!e(a))return t(a);var u=[];for(var c in Object(a))i.call(a,c)&&c!="constructor"&&u.push(c);return u}return dh=o,dh}var fh,B1;function Br(){if(B1)return fh;B1=1;var e=$a(),t=_y();function r(i){return i!=null&&t(i.length)&&!e(i)}return fh=r,fh}var hh,U1;function As(){if(U1)return hh;U1=1;var e=oj(),t=Sy(),r=Br();function i(o){return r(o)?e(o):t(o)}return hh=i,hh}var ph,H1;function Zq(){if(H1)return ph;H1=1;var e=qa(),t=As();function r(i,o){return i&&e(o,t(o),i)}return ph=r,ph}var mh,W1;function Jq(){if(W1)return mh;W1=1;function e(t){var r=[];if(t!=null)for(var i in Object(t))r.push(i);return r}return mh=e,mh}var gh,V1;function eD(){if(V1)return gh;V1=1;var e=qn(),t=Qu(),r=Jq(),i=Object.prototype,o=i.hasOwnProperty;function a(u){if(!e(u))return r(u);var c=t(u),f=[];for(var p in u)p=="constructor"&&(c||!o.call(u,p))||f.push(p);return f}return gh=a,gh}var vh,G1;function yi(){if(G1)return vh;G1=1;var e=oj(),t=eD(),r=Br();function i(o){return r(o)?e(o,!0):t(o)}return vh=i,vh}var yh,Y1;function tD(){if(Y1)return yh;Y1=1;var e=qa(),t=yi();function r(i,o){return i&&e(o,t(o),i)}return yh=r,yh}var va={exports:{}};va.exports;var K1;function lj(){return K1||(K1=1,(function(e,t){var r=rr(),i=t&&!t.nodeType&&t,o=i&&!0&&e&&!e.nodeType&&e,a=o&&o.exports===i,u=a?r.Buffer:void 0,c=u?u.allocUnsafe:void 0;function f(p,d){if(d)return p.slice();var g=p.length,y=c?c(g):new p.constructor(g);return p.copy(y),y}e.exports=f})(va,va.exports)),va.exports}var wh,X1;function uj(){if(X1)return wh;X1=1;function e(t,r){var i=-1,o=t.length;for(r||(r=Array(o));++i<o;)r[i]=t[i];return r}return wh=e,wh}var xh,Q1;function cj(){if(Q1)return xh;Q1=1;function e(t,r){for(var i=-1,o=t==null?0:t.length,a=0,u=[];++i<o;){var c=t[i];r(c,i,t)&&(u[a++]=c)}return u}return xh=e,xh}var _h,Z1;function dj(){if(Z1)return _h;Z1=1;function e(){return[]}return _h=e,_h}var bh,J1;function ky(){if(J1)return bh;J1=1;var e=cj(),t=dj(),r=Object.prototype,i=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,a=o?function(u){return u==null?[]:(u=Object(u),e(o(u),function(c){return i.call(u,c)}))}:t;return bh=a,bh}var Sh,eb;function nD(){if(eb)return Sh;eb=1;var e=qa(),t=ky();function r(i,o){return e(i,t(i),o)}return Sh=r,Sh}var kh,tb;function Ey(){if(tb)return kh;tb=1;function e(t,r){for(var i=-1,o=r.length,a=t.length;++i<o;)t[a+i]=r[i];return t}return kh=e,kh}var Eh,nb;function Zu(){if(nb)return Eh;nb=1;var e=aj(),t=e(Object.getPrototypeOf,Object);return Eh=t,Eh}var Nh,rb;function fj(){if(rb)return Nh;rb=1;var e=Ey(),t=Zu(),r=ky(),i=dj(),o=Object.getOwnPropertySymbols,a=o?function(u){for(var c=[];u;)e(c,r(u)),u=t(u);return c}:i;return Nh=a,Nh}var Ch,sb;function rD(){if(sb)return Ch;sb=1;var e=qa(),t=fj();function r(i,o){return e(i,t(i),o)}return Ch=r,Ch}var jh,ib;function hj(){if(ib)return jh;ib=1;var e=Ey(),t=_t();function r(i,o,a){var u=o(i);return t(i)?u:e(u,a(i))}return jh=r,jh}var Th,ob;function pj(){if(ob)return Th;ob=1;var e=hj(),t=ky(),r=As();function i(o){return e(o,r,t)}return Th=i,Th}var Rh,ab;function sD(){if(ab)return Rh;ab=1;var e=hj(),t=fj(),r=yi();function i(o){return e(o,r,t)}return Rh=i,Rh}var Ah,lb;function iD(){if(lb)return Ah;lb=1;var e=vi(),t=rr(),r=e(t,"DataView");return Ah=r,Ah}var Ih,ub;function oD(){if(ub)return Ih;ub=1;var e=vi(),t=rr(),r=e(t,"Promise");return Ih=r,Ih}var Mh,cb;function mj(){if(cb)return Mh;cb=1;var e=vi(),t=rr(),r=e(t,"Set");return Mh=r,Mh}var Oh,db;function aD(){if(db)return Oh;db=1;var e=vi(),t=rr(),r=e(t,"WeakMap");return Oh=r,Oh}var Ph,fb;function So(){if(fb)return Ph;fb=1;var e=iD(),t=yy(),r=oD(),i=mj(),o=aD(),a=gi(),u=sj(),c="[object Map]",f="[object Object]",p="[object Promise]",d="[object Set]",g="[object WeakMap]",y="[object DataView]",w=u(e),E=u(t),_=u(r),b=u(i),S=u(o),k=a;return(e&&k(new e(new ArrayBuffer(1)))!=y||t&&k(new t)!=c||r&&k(r.resolve())!=p||i&&k(new i)!=d||o&&k(new o)!=g)&&(k=function(N){var j=a(N),A=j==f?N.constructor:void 0,M=A?u(A):"";if(M)switch(M){case w:return y;case E:return c;case _:return p;case b:return d;case S:return g}return j}),Ph=k,Ph}var Lh,hb;function lD(){if(hb)return Lh;hb=1;var e=Object.prototype,t=e.hasOwnProperty;function r(i){var o=i.length,a=new i.constructor(o);return o&&typeof i[0]=="string"&&t.call(i,"index")&&(a.index=i.index,a.input=i.input),a}return Lh=r,Lh}var $h,pb;function gj(){if(pb)return $h;pb=1;var e=rr(),t=e.Uint8Array;return $h=t,$h}var qh,mb;function Ny(){if(mb)return qh;mb=1;var e=gj();function t(r){var i=new r.constructor(r.byteLength);return new e(i).set(new e(r)),i}return qh=t,qh}var Dh,gb;function uD(){if(gb)return Dh;gb=1;var e=Ny();function t(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return Dh=t,Dh}var Fh,vb;function cD(){if(vb)return Fh;vb=1;var e=/\w*$/;function t(r){var i=new r.constructor(r.source,e.exec(r));return i.lastIndex=r.lastIndex,i}return Fh=t,Fh}var zh,yb;function dD(){if(yb)return zh;yb=1;var e=_o(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function i(o){return r?Object(r.call(o)):{}}return zh=i,zh}var Bh,wb;function vj(){if(wb)return Bh;wb=1;var e=Ny();function t(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return Bh=t,Bh}var Uh,xb;function fD(){if(xb)return Uh;xb=1;var e=Ny(),t=uD(),r=cD(),i=dD(),o=vj(),a="[object Boolean]",u="[object Date]",c="[object Map]",f="[object Number]",p="[object RegExp]",d="[object Set]",g="[object String]",y="[object Symbol]",w="[object ArrayBuffer]",E="[object DataView]",_="[object Float32Array]",b="[object Float64Array]",S="[object Int8Array]",k="[object Int16Array]",N="[object Int32Array]",j="[object Uint8Array]",A="[object Uint8ClampedArray]",M="[object Uint16Array]",P="[object Uint32Array]";function O(D,L,U){var V=D.constructor;switch(L){case w:return e(D);case a:case u:return new V(+D);case E:return t(D,U);case _:case b:case S:case k:case N:case j:case A:case M:case P:return o(D,U);case c:return new V;case f:case g:return new V(D);case p:return r(D);case d:return new V;case y:return i(D)}}return Uh=O,Uh}var Hh,_b;function yj(){if(_b)return Hh;_b=1;var e=qn(),t=Object.create,r=(function(){function i(){}return function(o){if(!e(o))return{};if(t)return t(o);i.prototype=o;var a=new i;return i.prototype=void 0,a}})();return Hh=r,Hh}var Wh,bb;function wj(){if(bb)return Wh;bb=1;var e=yj(),t=Zu(),r=Qu();function i(o){return typeof o.constructor=="function"&&!r(o)?e(t(o)):{}}return Wh=i,Wh}var Vh,Sb;function hD(){if(Sb)return Vh;Sb=1;var e=So(),t=mr(),r="[object Map]";function i(o){return t(o)&&e(o)==r}return Vh=i,Vh}var Gh,kb;function pD(){if(kb)return Gh;kb=1;var e=hD(),t=Xu(),r=by(),i=r&&r.isMap,o=i?t(i):e;return Gh=o,Gh}var Yh,Eb;function mD(){if(Eb)return Yh;Eb=1;var e=So(),t=mr(),r="[object Set]";function i(o){return t(o)&&e(o)==r}return Yh=i,Yh}var Kh,Nb;function gD(){if(Nb)return Kh;Nb=1;var e=mD(),t=Xu(),r=by(),i=r&&r.isSet,o=i?t(i):e;return Kh=o,Kh}var Xh,Cb;function xj(){if(Cb)return Xh;Cb=1;var e=Vu(),t=xy(),r=Yu(),i=Zq(),o=tD(),a=lj(),u=uj(),c=nD(),f=rD(),p=pj(),d=sD(),g=So(),y=lD(),w=fD(),E=wj(),_=_t(),b=bo(),S=pD(),k=qn(),N=gD(),j=As(),A=yi(),M=1,P=2,O=4,D="[object Arguments]",L="[object Array]",U="[object Boolean]",V="[object Date]",z="[object Error]",C="[object Function]",F="[object GeneratorFunction]",$="[object Map]",re="[object Number]",J="[object Object]",W="[object RegExp]",Z="[object Set]",I="[object String]",G="[object Symbol]",K="[object WeakMap]",q="[object ArrayBuffer]",Q="[object DataView]",ne="[object Float32Array]",ae="[object Float64Array]",fe="[object Int8Array]",te="[object Int16Array]",ce="[object Int32Array]",Ce="[object Uint8Array]",ve="[object Uint8ClampedArray]",Re="[object Uint16Array]",ye="[object Uint32Array]",Ee={};Ee[D]=Ee[L]=Ee[q]=Ee[Q]=Ee[U]=Ee[V]=Ee[ne]=Ee[ae]=Ee[fe]=Ee[te]=Ee[ce]=Ee[$]=Ee[re]=Ee[J]=Ee[W]=Ee[Z]=Ee[I]=Ee[G]=Ee[Ce]=Ee[ve]=Ee[Re]=Ee[ye]=!0,Ee[z]=Ee[C]=Ee[K]=!1;function Ye(we,_e,Be,it,ft,Ze){var De,Je=_e&M,Xe=_e&P,Ot=_e&O;if(Be&&(De=ft?Be(we,it,ft,Ze):Be(we)),De!==void 0)return De;if(!k(we))return we;var lt=_(we);if(lt){if(De=y(we),!Je)return u(we,De)}else{var Qe=g(we),Pt=Qe==C||Qe==F;if(b(we))return a(we,Je);if(Qe==J||Qe==D||Pt&&!ft){if(De=Xe||Pt?{}:E(we),!Je)return Xe?f(we,o(De,we)):c(we,i(De,we))}else{if(!Ee[Qe])return ft?we:{};De=w(we,Qe,Je)}}Ze||(Ze=new e);var zt=Ze.get(we);if(zt)return zt;Ze.set(we,De),N(we)?we.forEach(function(ht){De.add(Ye(ht,_e,Be,ht,we,Ze))}):S(we)&&we.forEach(function(ht,vt){De.set(vt,Ye(ht,_e,Be,vt,we,Ze))});var et=Ot?Xe?d:p:Xe?A:j,bt=lt?void 0:et(we);return t(bt||we,function(ht,vt){bt&&(vt=ht,ht=we[vt]),r(De,vt,Ye(ht,_e,Be,vt,we,Ze))}),De}return Xh=Ye,Xh}var Qh,jb;function vD(){if(jb)return Qh;jb=1;var e=xj(),t=4;function r(i){return e(i,t)}return Qh=r,Qh}var Zh,Tb;function Cy(){if(Tb)return Zh;Tb=1;function e(t){return function(){return t}}return Zh=e,Zh}var Jh,Rb;function yD(){if(Rb)return Jh;Rb=1;function e(t){return function(r,i,o){for(var a=-1,u=Object(r),c=o(r),f=c.length;f--;){var p=c[t?f:++a];if(i(u[p],p,u)===!1)break}return r}}return Jh=e,Jh}var ep,Ab;function jy(){if(Ab)return ep;Ab=1;var e=yD(),t=e();return ep=t,ep}var tp,Ib;function Ty(){if(Ib)return tp;Ib=1;var e=jy(),t=As();function r(i,o){return i&&e(i,o,t)}return tp=r,tp}var np,Mb;function wD(){if(Mb)return np;Mb=1;var e=Br();function t(r,i){return function(o,a){if(o==null)return o;if(!e(o))return r(o,a);for(var u=o.length,c=i?u:-1,f=Object(o);(i?c--:++c<u)&&a(f[c],c,f)!==!1;);return o}}return np=t,np}var rp,Ob;function Ju(){if(Ob)return rp;Ob=1;var e=Ty(),t=wD(),r=t(e);return rp=r,rp}var sp,Pb;function wi(){if(Pb)return sp;Pb=1;function e(t){return t}return sp=e,sp}var ip,Lb;function _j(){if(Lb)return ip;Lb=1;var e=wi();function t(r){return typeof r=="function"?r:e}return ip=t,ip}var op,$b;function bj(){if($b)return op;$b=1;var e=xy(),t=Ju(),r=_j(),i=_t();function o(a,u){var c=i(a)?e:t;return c(a,r(u))}return op=o,op}var ap,qb;function Sj(){return qb||(qb=1,ap=bj()),ap}var lp,Db;function xD(){if(Db)return lp;Db=1;var e=Ju();function t(r,i){var o=[];return e(r,function(a,u,c){i(a,u,c)&&o.push(a)}),o}return lp=t,lp}var up,Fb;function _D(){if(Fb)return up;Fb=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return up=t,up}var cp,zb;function bD(){if(zb)return cp;zb=1;function e(t){return this.__data__.has(t)}return cp=e,cp}var dp,Bb;function kj(){if(Bb)return dp;Bb=1;var e=wy(),t=_D(),r=bD();function i(o){var a=-1,u=o==null?0:o.length;for(this.__data__=new e;++a<u;)this.add(o[a])}return i.prototype.add=i.prototype.push=t,i.prototype.has=r,dp=i,dp}var fp,Ub;function SD(){if(Ub)return fp;Ub=1;function e(t,r){for(var i=-1,o=t==null?0:t.length;++i<o;)if(r(t[i],i,t))return!0;return!1}return fp=e,fp}var hp,Hb;function Ej(){if(Hb)return hp;Hb=1;function e(t,r){return t.has(r)}return hp=e,hp}var pp,Wb;function Nj(){if(Wb)return pp;Wb=1;var e=kj(),t=SD(),r=Ej(),i=1,o=2;function a(u,c,f,p,d,g){var y=f&i,w=u.length,E=c.length;if(w!=E&&!(y&&E>w))return!1;var _=g.get(u),b=g.get(c);if(_&&b)return _==c&&b==u;var S=-1,k=!0,N=f&o?new e:void 0;for(g.set(u,c),g.set(c,u);++S<w;){var j=u[S],A=c[S];if(p)var M=y?p(A,j,S,c,u,g):p(j,A,S,u,c,g);if(M!==void 0){if(M)continue;k=!1;break}if(N){if(!t(c,function(P,O){if(!r(N,O)&&(j===P||d(j,P,f,p,g)))return N.push(O)})){k=!1;break}}else if(!(j===A||d(j,A,f,p,g))){k=!1;break}}return g.delete(u),g.delete(c),k}return pp=a,pp}var mp,Vb;function kD(){if(Vb)return mp;Vb=1;function e(t){var r=-1,i=Array(t.size);return t.forEach(function(o,a){i[++r]=[a,o]}),i}return mp=e,mp}var gp,Gb;function Ry(){if(Gb)return gp;Gb=1;function e(t){var r=-1,i=Array(t.size);return t.forEach(function(o){i[++r]=o}),i}return gp=e,gp}var vp,Yb;function ED(){if(Yb)return vp;Yb=1;var e=_o(),t=gj(),r=xo(),i=Nj(),o=kD(),a=Ry(),u=1,c=2,f="[object Boolean]",p="[object Date]",d="[object Error]",g="[object Map]",y="[object Number]",w="[object RegExp]",E="[object Set]",_="[object String]",b="[object Symbol]",S="[object ArrayBuffer]",k="[object DataView]",N=e?e.prototype:void 0,j=N?N.valueOf:void 0;function A(M,P,O,D,L,U,V){switch(O){case k:if(M.byteLength!=P.byteLength||M.byteOffset!=P.byteOffset)return!1;M=M.buffer,P=P.buffer;case S:return!(M.byteLength!=P.byteLength||!U(new t(M),new t(P)));case f:case p:case y:return r(+M,+P);case d:return M.name==P.name&&M.message==P.message;case w:case _:return M==P+"";case g:var z=o;case E:var C=D&u;if(z||(z=a),M.size!=P.size&&!C)return!1;var F=V.get(M);if(F)return F==P;D|=c,V.set(M,P);var $=i(z(M),z(P),D,L,U,V);return V.delete(M),$;case b:if(j)return j.call(M)==j.call(P)}return!1}return vp=A,vp}var yp,Kb;function ND(){if(Kb)return yp;Kb=1;var e=pj(),t=1,r=Object.prototype,i=r.hasOwnProperty;function o(a,u,c,f,p,d){var g=c&t,y=e(a),w=y.length,E=e(u),_=E.length;if(w!=_&&!g)return!1;for(var b=w;b--;){var S=y[b];if(!(g?S in u:i.call(u,S)))return!1}var k=d.get(a),N=d.get(u);if(k&&N)return k==u&&N==a;var j=!0;d.set(a,u),d.set(u,a);for(var A=g;++b<w;){S=y[b];var M=a[S],P=u[S];if(f)var O=g?f(P,M,S,u,a,d):f(M,P,S,a,u,d);if(!(O===void 0?M===P||p(M,P,c,f,d):O)){j=!1;break}A||(A=S=="constructor")}if(j&&!A){var D=a.constructor,L=u.constructor;D!=L&&"constructor"in a&&"constructor"in u&&!(typeof D=="function"&&D instanceof D&&typeof L=="function"&&L instanceof L)&&(j=!1)}return d.delete(a),d.delete(u),j}return yp=o,yp}var wp,Xb;function CD(){if(Xb)return wp;Xb=1;var e=Vu(),t=Nj(),r=ED(),i=ND(),o=So(),a=_t(),u=bo(),c=Fa(),f=1,p="[object Arguments]",d="[object Array]",g="[object Object]",y=Object.prototype,w=y.hasOwnProperty;function E(_,b,S,k,N,j){var A=a(_),M=a(b),P=A?d:o(_),O=M?d:o(b);P=P==p?g:P,O=O==p?g:O;var D=P==g,L=O==g,U=P==O;if(U&&u(_)){if(!u(b))return!1;A=!0,D=!1}if(U&&!D)return j||(j=new e),A||c(_)?t(_,b,S,k,N,j):r(_,b,P,S,k,N,j);if(!(S&f)){var V=D&&w.call(_,"__wrapped__"),z=L&&w.call(b,"__wrapped__");if(V||z){var C=V?_.value():_,F=z?b.value():b;return j||(j=new e),N(C,F,S,k,j)}}return U?(j||(j=new e),i(_,b,S,k,N,j)):!1}return wp=E,wp}var xp,Qb;function Cj(){if(Qb)return xp;Qb=1;var e=CD(),t=mr();function r(i,o,a,u,c){return i===o?!0:i==null||o==null||!t(i)&&!t(o)?i!==i&&o!==o:e(i,o,a,u,r,c)}return xp=r,xp}var _p,Zb;function jD(){if(Zb)return _p;Zb=1;var e=Vu(),t=Cj(),r=1,i=2;function o(a,u,c,f){var p=c.length,d=p,g=!f;if(a==null)return!d;for(a=Object(a);p--;){var y=c[p];if(g&&y[2]?y[1]!==a[y[0]]:!(y[0]in a))return!1}for(;++p<d;){y=c[p];var w=y[0],E=a[w],_=y[1];if(g&&y[2]){if(E===void 0&&!(w in a))return!1}else{var b=new e;if(f)var S=f(E,_,w,a,u,b);if(!(S===void 0?t(_,E,r|i,f,b):S))return!1}}return!0}return _p=o,_p}var bp,Jb;function jj(){if(Jb)return bp;Jb=1;var e=qn();function t(r){return r===r&&!e(r)}return bp=t,bp}var Sp,eS;function TD(){if(eS)return Sp;eS=1;var e=jj(),t=As();function r(i){for(var o=t(i),a=o.length;a--;){var u=o[a],c=i[u];o[a]=[u,c,e(c)]}return o}return Sp=r,Sp}var kp,tS;function Tj(){if(tS)return kp;tS=1;function e(t,r){return function(i){return i==null?!1:i[t]===r&&(r!==void 0||t in Object(i))}}return kp=e,kp}var Ep,nS;function RD(){if(nS)return Ep;nS=1;var e=jD(),t=TD(),r=Tj();function i(o){var a=t(o);return a.length==1&&a[0][2]?r(a[0][0],a[0][1]):function(u){return u===o||e(u,o,a)}}return Ep=i,Ep}var Np,rS;function ko(){if(rS)return Np;rS=1;var e=gi(),t=mr(),r="[object Symbol]";function i(o){return typeof o=="symbol"||t(o)&&e(o)==r}return Np=i,Np}var Cp,sS;function Ay(){if(sS)return Cp;sS=1;var e=_t(),t=ko(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i=/^\w*$/;function o(a,u){if(e(a))return!1;var c=typeof a;return c=="number"||c=="symbol"||c=="boolean"||a==null||t(a)?!0:i.test(a)||!r.test(a)||u!=null&&a in Object(u)}return Cp=o,Cp}var jp,iS;function AD(){if(iS)return jp;iS=1;var e=wy(),t="Expected a function";function r(i,o){if(typeof i!="function"||o!=null&&typeof o!="function")throw new TypeError(t);var a=function(){var u=arguments,c=o?o.apply(this,u):u[0],f=a.cache;if(f.has(c))return f.get(c);var p=i.apply(this,u);return a.cache=f.set(c,p)||f,p};return a.cache=new(r.Cache||e),a}return r.Cache=e,jp=r,jp}var Tp,oS;function ID(){if(oS)return Tp;oS=1;var e=AD(),t=500;function r(i){var o=e(i,function(u){return a.size===t&&a.clear(),u}),a=o.cache;return o}return Tp=r,Tp}var Rp,aS;function MD(){if(aS)return Rp;aS=1;var e=ID(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,i=e(function(o){var a=[];return o.charCodeAt(0)===46&&a.push(""),o.replace(t,function(u,c,f,p){a.push(f?p.replace(r,"$1"):c||u)}),a});return Rp=i,Rp}var Ap,lS;function ec(){if(lS)return Ap;lS=1;function e(t,r){for(var i=-1,o=t==null?0:t.length,a=Array(o);++i<o;)a[i]=r(t[i],i,t);return a}return Ap=e,Ap}var Ip,uS;function OD(){if(uS)return Ip;uS=1;var e=_o(),t=ec(),r=_t(),i=ko(),o=e?e.prototype:void 0,a=o?o.toString:void 0;function u(c){if(typeof c=="string")return c;if(r(c))return t(c,u)+"";if(i(c))return a?a.call(c):"";var f=c+"";return f=="0"&&1/c==-1/0?"-0":f}return Ip=u,Ip}var Mp,cS;function Rj(){if(cS)return Mp;cS=1;var e=OD();function t(r){return r==null?"":e(r)}return Mp=t,Mp}var Op,dS;function tc(){if(dS)return Op;dS=1;var e=_t(),t=Ay(),r=MD(),i=Rj();function o(a,u){return e(a)?a:t(a,u)?[a]:r(i(a))}return Op=o,Op}var Pp,fS;function za(){if(fS)return Pp;fS=1;var e=ko();function t(r){if(typeof r=="string"||e(r))return r;var i=r+"";return i=="0"&&1/r==-1/0?"-0":i}return Pp=t,Pp}var Lp,hS;function nc(){if(hS)return Lp;hS=1;var e=tc(),t=za();function r(i,o){o=e(o,i);for(var a=0,u=o.length;i!=null&&a<u;)i=i[t(o[a++])];return a&&a==u?i:void 0}return Lp=r,Lp}var $p,pS;function PD(){if(pS)return $p;pS=1;var e=nc();function t(r,i,o){var a=r==null?void 0:e(r,i);return a===void 0?o:a}return $p=t,$p}var qp,mS;function LD(){if(mS)return qp;mS=1;function e(t,r){return t!=null&&r in Object(t)}return qp=e,qp}var Dp,gS;function Aj(){if(gS)return Dp;gS=1;var e=tc(),t=Da(),r=_t(),i=Ku(),o=_y(),a=za();function u(c,f,p){f=e(f,c);for(var d=-1,g=f.length,y=!1;++d<g;){var w=a(f[d]);if(!(y=c!=null&&p(c,w)))break;c=c[w]}return y||++d!=g?y:(g=c==null?0:c.length,!!g&&o(g)&&i(w,g)&&(r(c)||t(c)))}return Dp=u,Dp}var Fp,vS;function Ij(){if(vS)return Fp;vS=1;var e=LD(),t=Aj();function r(i,o){return i!=null&&t(i,o,e)}return Fp=r,Fp}var zp,yS;function $D(){if(yS)return zp;yS=1;var e=Cj(),t=PD(),r=Ij(),i=Ay(),o=jj(),a=Tj(),u=za(),c=1,f=2;function p(d,g){return i(d)&&o(g)?a(u(d),g):function(y){var w=t(y,d);return w===void 0&&w===g?r(y,d):e(g,w,c|f)}}return zp=p,zp}var Bp,wS;function Mj(){if(wS)return Bp;wS=1;function e(t){return function(r){return r==null?void 0:r[t]}}return Bp=e,Bp}var Up,xS;function qD(){if(xS)return Up;xS=1;var e=nc();function t(r){return function(i){return e(i,r)}}return Up=t,Up}var Hp,_S;function DD(){if(_S)return Hp;_S=1;var e=Mj(),t=qD(),r=Ay(),i=za();function o(a){return r(a)?e(i(a)):t(a)}return Hp=o,Hp}var Wp,bS;function Ur(){if(bS)return Wp;bS=1;var e=RD(),t=$D(),r=wi(),i=_t(),o=DD();function a(u){return typeof u=="function"?u:u==null?r:typeof u=="object"?i(u)?t(u[0],u[1]):e(u):o(u)}return Wp=a,Wp}var Vp,SS;function Oj(){if(SS)return Vp;SS=1;var e=cj(),t=xD(),r=Ur(),i=_t();function o(a,u){var c=i(a)?e:t;return c(a,r(u,3))}return Vp=o,Vp}var Gp,kS;function FD(){if(kS)return Gp;kS=1;var e=Object.prototype,t=e.hasOwnProperty;function r(i,o){return i!=null&&t.call(i,o)}return Gp=r,Gp}var Yp,ES;function Pj(){if(ES)return Yp;ES=1;var e=FD(),t=Aj();function r(i,o){return i!=null&&t(i,o,e)}return Yp=r,Yp}var Kp,NS;function zD(){if(NS)return Kp;NS=1;var e=Sy(),t=So(),r=Da(),i=_t(),o=Br(),a=bo(),u=Qu(),c=Fa(),f="[object Map]",p="[object Set]",d=Object.prototype,g=d.hasOwnProperty;function y(w){if(w==null)return!0;if(o(w)&&(i(w)||typeof w=="string"||typeof w.splice=="function"||a(w)||c(w)||r(w)))return!w.length;var E=t(w);if(E==f||E==p)return!w.size;if(u(w))return!e(w).length;for(var _ in w)if(g.call(w,_))return!1;return!0}return Kp=y,Kp}var Xp,CS;function Lj(){if(CS)return Xp;CS=1;function e(t){return t===void 0}return Xp=e,Xp}var Qp,jS;function $j(){if(jS)return Qp;jS=1;var e=Ju(),t=Br();function r(i,o){var a=-1,u=t(i)?Array(i.length):[];return e(i,function(c,f,p){u[++a]=o(c,f,p)}),u}return Qp=r,Qp}var Zp,TS;function qj(){if(TS)return Zp;TS=1;var e=ec(),t=Ur(),r=$j(),i=_t();function o(a,u){var c=i(a)?e:r;return c(a,t(u,3))}return Zp=o,Zp}var Jp,RS;function BD(){if(RS)return Jp;RS=1;function e(t,r,i,o){var a=-1,u=t==null?0:t.length;for(o&&u&&(i=t[++a]);++a<u;)i=r(i,t[a],a,t);return i}return Jp=e,Jp}var em,AS;function UD(){if(AS)return em;AS=1;function e(t,r,i,o,a){return a(t,function(u,c,f){i=o?(o=!1,u):r(i,u,c,f)}),i}return em=e,em}var tm,IS;function Dj(){if(IS)return tm;IS=1;var e=BD(),t=Ju(),r=Ur(),i=UD(),o=_t();function a(u,c,f){var p=o(u)?e:i,d=arguments.length<3;return p(u,r(c,4),f,d,t)}return tm=a,tm}var nm,MS;function HD(){if(MS)return nm;MS=1;var e=gi(),t=_t(),r=mr(),i="[object String]";function o(a){return typeof a=="string"||!t(a)&&r(a)&&e(a)==i}return nm=o,nm}var rm,OS;function WD(){if(OS)return rm;OS=1;var e=Mj(),t=e("length");return rm=t,rm}var sm,PS;function VD(){if(PS)return sm;PS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",o=t+r+i,a="\\ufe0e\\ufe0f",u="\\u200d",c=RegExp("["+u+e+o+a+"]");function f(p){return c.test(p)}return sm=f,sm}var im,LS;function GD(){if(LS)return im;LS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",o=t+r+i,a="\\ufe0e\\ufe0f",u="["+e+"]",c="["+o+"]",f="\\ud83c[\\udffb-\\udfff]",p="(?:"+c+"|"+f+")",d="[^"+e+"]",g="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",E=p+"?",_="["+a+"]?",b="(?:"+w+"(?:"+[d,g,y].join("|")+")"+_+E+")*",S=_+E+b,k="(?:"+[d+c+"?",c,g,y,u].join("|")+")",N=RegExp(f+"(?="+f+")|"+k+S,"g");function j(A){for(var M=N.lastIndex=0;N.test(A);)++M;return M}return im=j,im}var om,$S;function YD(){if($S)return om;$S=1;var e=WD(),t=VD(),r=GD();function i(o){return t(o)?r(o):e(o)}return om=i,om}var am,qS;function KD(){if(qS)return am;qS=1;var e=Sy(),t=So(),r=Br(),i=HD(),o=YD(),a="[object Map]",u="[object Set]";function c(f){if(f==null)return 0;if(r(f))return i(f)?o(f):f.length;var p=t(f);return p==a||p==u?f.size:e(f).length}return am=c,am}var lm,DS;function XD(){if(DS)return lm;DS=1;var e=xy(),t=yj(),r=Ty(),i=Ur(),o=Zu(),a=_t(),u=bo(),c=$a(),f=qn(),p=Fa();function d(g,y,w){var E=a(g),_=E||u(g)||p(g);if(y=i(y,4),w==null){var b=g&&g.constructor;_?w=E?new b:[]:f(g)?w=c(b)?t(o(g)):{}:w={}}return(_?e:r)(g,function(S,k,N){return y(w,S,k,N)}),w}return lm=d,lm}var um,FS;function QD(){if(FS)return um;FS=1;var e=_o(),t=Da(),r=_t(),i=e?e.isConcatSpreadable:void 0;function o(a){return r(a)||t(a)||!!(i&&a&&a[i])}return um=o,um}var cm,zS;function Iy(){if(zS)return cm;zS=1;var e=Ey(),t=QD();function r(i,o,a,u,c){var f=-1,p=i.length;for(a||(a=t),c||(c=[]);++f<p;){var d=i[f];o>0&&a(d)?o>1?r(d,o-1,a,u,c):e(c,d):u||(c[c.length]=d)}return c}return cm=r,cm}var dm,BS;function ZD(){if(BS)return dm;BS=1;function e(t,r,i){switch(i.length){case 0:return t.call(r);case 1:return t.call(r,i[0]);case 2:return t.call(r,i[0],i[1]);case 3:return t.call(r,i[0],i[1],i[2])}return t.apply(r,i)}return dm=e,dm}var fm,US;function Fj(){if(US)return fm;US=1;var e=ZD(),t=Math.max;function r(i,o,a){return o=t(o===void 0?i.length-1:o,0),function(){for(var u=arguments,c=-1,f=t(u.length-o,0),p=Array(f);++c<f;)p[c]=u[o+c];c=-1;for(var d=Array(o+1);++c<o;)d[c]=u[c];return d[o]=a(p),e(i,this,d)}}return fm=r,fm}var hm,HS;function JD(){if(HS)return hm;HS=1;var e=Cy(),t=ij(),r=wi(),i=t?function(o,a){return t(o,"toString",{configurable:!0,enumerable:!1,value:e(a),writable:!0})}:r;return hm=i,hm}var pm,WS;function e4(){if(WS)return pm;WS=1;var e=800,t=16,r=Date.now;function i(o){var a=0,u=0;return function(){var c=r(),f=t-(c-u);if(u=c,f>0){if(++a>=e)return arguments[0]}else a=0;return o.apply(void 0,arguments)}}return pm=i,pm}var mm,VS;function zj(){if(VS)return mm;VS=1;var e=JD(),t=e4(),r=t(e);return mm=r,mm}var gm,GS;function rc(){if(GS)return gm;GS=1;var e=wi(),t=Fj(),r=zj();function i(o,a){return r(t(o,a,e),o+"")}return gm=i,gm}var vm,YS;function Bj(){if(YS)return vm;YS=1;function e(t,r,i,o){for(var a=t.length,u=i+(o?1:-1);o?u--:++u<a;)if(r(t[u],u,t))return u;return-1}return vm=e,vm}var ym,KS;function t4(){if(KS)return ym;KS=1;function e(t){return t!==t}return ym=e,ym}var wm,XS;function n4(){if(XS)return wm;XS=1;function e(t,r,i){for(var o=i-1,a=t.length;++o<a;)if(t[o]===r)return o;return-1}return wm=e,wm}var xm,QS;function r4(){if(QS)return xm;QS=1;var e=Bj(),t=t4(),r=n4();function i(o,a,u){return a===a?r(o,a,u):e(o,t,u)}return xm=i,xm}var _m,ZS;function s4(){if(ZS)return _m;ZS=1;var e=r4();function t(r,i){var o=r==null?0:r.length;return!!o&&e(r,i,0)>-1}return _m=t,_m}var bm,JS;function i4(){if(JS)return bm;JS=1;function e(t,r,i){for(var o=-1,a=t==null?0:t.length;++o<a;)if(i(r,t[o]))return!0;return!1}return bm=e,bm}var Sm,ek;function o4(){if(ek)return Sm;ek=1;function e(){}return Sm=e,Sm}var km,tk;function a4(){if(tk)return km;tk=1;var e=mj(),t=o4(),r=Ry(),i=1/0,o=e&&1/r(new e([,-0]))[1]==i?function(a){return new e(a)}:t;return km=o,km}var Em,nk;function l4(){if(nk)return Em;nk=1;var e=kj(),t=s4(),r=i4(),i=Ej(),o=a4(),a=Ry(),u=200;function c(f,p,d){var g=-1,y=t,w=f.length,E=!0,_=[],b=_;if(d)E=!1,y=r;else if(w>=u){var S=p?null:o(f);if(S)return a(S);E=!1,y=i,b=new e}else b=p?[]:_;e:for(;++g<w;){var k=f[g],N=p?p(k):k;if(k=d||k!==0?k:0,E&&N===N){for(var j=b.length;j--;)if(b[j]===N)continue e;p&&b.push(N),_.push(k)}else y(b,N,d)||(b!==_&&b.push(N),_.push(k))}return _}return Em=c,Em}var Nm,rk;function Uj(){if(rk)return Nm;rk=1;var e=Br(),t=mr();function r(i){return t(i)&&e(i)}return Nm=r,Nm}var Cm,sk;function u4(){if(sk)return Cm;sk=1;var e=Iy(),t=rc(),r=l4(),i=Uj(),o=t(function(a){return r(e(a,1,i,!0))});return Cm=o,Cm}var jm,ik;function c4(){if(ik)return jm;ik=1;var e=ec();function t(r,i){return e(i,function(o){return r[o]})}return jm=t,jm}var Tm,ok;function Hj(){if(ok)return Tm;ok=1;var e=c4(),t=As();function r(i){return i==null?[]:e(i,t(i))}return Tm=r,Tm}var Rm,ak;function Dn(){if(ak)return Rm;ak=1;var e;if(typeof vy=="function")try{e={clone:vD(),constant:Cy(),each:Sj(),filter:Oj(),has:Pj(),isArray:_t(),isEmpty:zD(),isFunction:$a(),isUndefined:Lj(),keys:As(),map:qj(),reduce:Dj(),size:KD(),transform:XD(),union:u4(),values:Hj()}}catch{}return e||(e=window._),Rm=e,Rm}var Am,lk;function My(){if(lk)return Am;lk=1;var e=Dn();Am=o;var t="\0",r="\0",i="";function o(d){this._isDirected=e.has(d,"directed")?d.directed:!0,this._isMultigraph=e.has(d,"multigraph")?d.multigraph:!1,this._isCompound=e.has(d,"compound")?d.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[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(d){return this._label=d,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(g){return e.isEmpty(d._in[g])})},o.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(g){return e.isEmpty(d._out[g])})},o.prototype.setNodes=function(d,g){var y=arguments,w=this;return e.each(d,function(E){y.length>1?w.setNode(E,g):w.setNode(E)}),this},o.prototype.setNode=function(d,g){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=g),this):(this._nodes[d]=arguments.length>1?g:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=r,this._children[d]={},this._children[r][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},o.prototype.node=function(d){return this._nodes[d]},o.prototype.hasNode=function(d){return e.has(this._nodes,d)},o.prototype.removeNode=function(d){var g=this;if(e.has(this._nodes,d)){var y=function(w){g.removeEdge(g._edgeObjs[w])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(w){g.setParent(w)}),delete this._children[d]),e.each(e.keys(this._in[d]),y),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),y),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},o.prototype.setParent=function(d,g){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(g))g=r;else{g+="";for(var y=g;!e.isUndefined(y);y=this.parent(y))if(y===d)throw new Error("Setting "+g+" as parent of "+d+" would create a cycle");this.setNode(g)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=g,this._children[g][d]=!0,this},o.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},o.prototype.parent=function(d){if(this._isCompound){var g=this._parent[d];if(g!==r)return g}},o.prototype.children=function(d){if(e.isUndefined(d)&&(d=r),this._isCompound){var g=this._children[d];if(g)return e.keys(g)}else{if(d===r)return this.nodes();if(this.hasNode(d))return[]}},o.prototype.predecessors=function(d){var g=this._preds[d];if(g)return e.keys(g)},o.prototype.successors=function(d){var g=this._sucs[d];if(g)return e.keys(g)},o.prototype.neighbors=function(d){var g=this.predecessors(d);if(g)return e.union(g,this.successors(d))},o.prototype.isLeaf=function(d){var g;return this.isDirected()?g=this.successors(d):g=this.neighbors(d),g.length===0},o.prototype.filterNodes=function(d){var g=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});g.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,b){d(b)&&g.setNode(b,_)}),e.each(this._edgeObjs,function(_){g.hasNode(_.v)&&g.hasNode(_.w)&&g.setEdge(_,y.edge(_))});var w={};function E(_){var b=y.parent(_);return b===void 0||g.hasNode(b)?(w[_]=b,b):b in w?w[b]:E(b)}return this._isCompound&&e.each(g.nodes(),function(_){g.setParent(_,E(_))}),g},o.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(d,g){var y=this,w=arguments;return e.reduce(d,function(E,_){return w.length>1?y.setEdge(E,_,g):y.setEdge(E,_),_}),this},o.prototype.setEdge=function(){var d,g,y,w,E=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(d=_.v,g=_.w,y=_.name,arguments.length===2&&(w=arguments[1],E=!0)):(d=_,g=arguments[1],y=arguments[3],arguments.length>2&&(w=arguments[2],E=!0)),d=""+d,g=""+g,e.isUndefined(y)||(y=""+y);var b=c(this._isDirected,d,g,y);if(e.has(this._edgeLabels,b))return E&&(this._edgeLabels[b]=w),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(g),this._edgeLabels[b]=E?w:this._defaultEdgeLabelFn(d,g,y);var S=f(this._isDirected,d,g,y);return d=S.v,g=S.w,Object.freeze(S),this._edgeObjs[b]=S,a(this._preds[g],d),a(this._sucs[d],g),this._in[g][b]=S,this._out[d][b]=S,this._edgeCount++,this},o.prototype.edge=function(d,g,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,d,g,y);return this._edgeLabels[w]},o.prototype.hasEdge=function(d,g,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,d,g,y);return e.has(this._edgeLabels,w)},o.prototype.removeEdge=function(d,g,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,d,g,y),E=this._edgeObjs[w];return E&&(d=E.v,g=E.w,delete this._edgeLabels[w],delete this._edgeObjs[w],u(this._preds[g],d),u(this._sucs[d],g),delete this._in[g][w],delete this._out[d][w],this._edgeCount--),this},o.prototype.inEdges=function(d,g){var y=this._in[d];if(y){var w=e.values(y);return g?e.filter(w,function(E){return E.v===g}):w}},o.prototype.outEdges=function(d,g){var y=this._out[d];if(y){var w=e.values(y);return g?e.filter(w,function(E){return E.w===g}):w}},o.prototype.nodeEdges=function(d,g){var y=this.inEdges(d,g);if(y)return y.concat(this.outEdges(d,g))};function a(d,g){d[g]?d[g]++:d[g]=1}function u(d,g){--d[g]||delete d[g]}function c(d,g,y,w){var E=""+g,_=""+y;if(!d&&E>_){var b=E;E=_,_=b}return E+i+_+i+(e.isUndefined(w)?t:w)}function f(d,g,y,w){var E=""+g,_=""+y;if(!d&&E>_){var b=E;E=_,_=b}var S={v:E,w:_};return w&&(S.name=w),S}function p(d,g){return c(d,g.v,g.w,g.name)}return Am}var Im,uk;function d4(){return uk||(uk=1,Im="2.1.8"),Im}var Mm,ck;function f4(){return ck||(ck=1,Mm={Graph:My(),version:d4()}),Mm}var Om,dk;function h4(){if(dk)return Om;dk=1;var e=Dn(),t=My();Om={write:r,read:a};function r(u){var c={options:{directed:u.isDirected(),multigraph:u.isMultigraph(),compound:u.isCompound()},nodes:i(u),edges:o(u)};return e.isUndefined(u.graph())||(c.value=e.clone(u.graph())),c}function i(u){return e.map(u.nodes(),function(c){var f=u.node(c),p=u.parent(c),d={v:c};return e.isUndefined(f)||(d.value=f),e.isUndefined(p)||(d.parent=p),d})}function o(u){return e.map(u.edges(),function(c){var f=u.edge(c),p={v:c.v,w:c.w};return e.isUndefined(c.name)||(p.name=c.name),e.isUndefined(f)||(p.value=f),p})}function a(u){var c=new t(u.options).setGraph(u.value);return e.each(u.nodes,function(f){c.setNode(f.v,f.value),f.parent&&c.setParent(f.v,f.parent)}),e.each(u.edges,function(f){c.setEdge({v:f.v,w:f.w,name:f.name},f.value)}),c}return Om}var Pm,fk;function p4(){if(fk)return Pm;fk=1;var e=Dn();Pm=t;function t(r){var i={},o=[],a;function u(c){e.has(i,c)||(i[c]=!0,a.push(c),e.each(r.successors(c),u),e.each(r.predecessors(c),u))}return e.each(r.nodes(),function(c){a=[],u(c),a.length&&o.push(a)}),o}return Pm}var Lm,hk;function Wj(){if(hk)return Lm;hk=1;var e=Dn();Lm=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(r){return r.key})},t.prototype.has=function(r){return e.has(this._keyIndices,r)},t.prototype.priority=function(r){var i=this._keyIndices[r];if(i!==void 0)return this._arr[i].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(r,i){var o=this._keyIndices;if(r=String(r),!e.has(o,r)){var a=this._arr,u=a.length;return o[r]=u,a.push({key:r,priority:i}),this._decrease(u),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},t.prototype.decrease=function(r,i){var o=this._keyIndices[r];if(i>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[o].priority+" New: "+i);this._arr[o].priority=i,this._decrease(o)},t.prototype._heapify=function(r){var i=this._arr,o=2*r,a=o+1,u=r;o<i.length&&(u=i[o].priority<i[u].priority?o:u,a<i.length&&(u=i[a].priority<i[u].priority?a:u),u!==r&&(this._swap(r,u),this._heapify(u)))},t.prototype._decrease=function(r){for(var i=this._arr,o=i[r].priority,a;r!==0&&(a=r>>1,!(i[a].priority<o));)this._swap(r,a),r=a},t.prototype._swap=function(r,i){var o=this._arr,a=this._keyIndices,u=o[r],c=o[i];o[r]=c,o[i]=u,a[c.key]=r,a[u.key]=i},Lm}var $m,pk;function Vj(){if(pk)return $m;pk=1;var e=Dn(),t=Wj();$m=i;var r=e.constant(1);function i(a,u,c,f){return o(a,String(u),c||r,f||function(p){return a.outEdges(p)})}function o(a,u,c,f){var p={},d=new t,g,y,w=function(E){var _=E.v!==g?E.v:E.w,b=p[_],S=c(E),k=y.distance+S;if(S<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+E+" Weight: "+S);k<b.distance&&(b.distance=k,b.predecessor=g,d.decrease(_,k))};for(a.nodes().forEach(function(E){var _=E===u?0:Number.POSITIVE_INFINITY;p[E]={distance:_},d.add(E,_)});d.size()>0&&(g=d.removeMin(),y=p[g],y.distance!==Number.POSITIVE_INFINITY);)f(g).forEach(w);return p}return $m}var qm,mk;function m4(){if(mk)return qm;mk=1;var e=Vj(),t=Dn();qm=r;function r(i,o,a){return t.transform(i.nodes(),function(u,c){u[c]=e(i,c,o,a)},{})}return qm}var Dm,gk;function Gj(){if(gk)return Dm;gk=1;var e=Dn();Dm=t;function t(r){var i=0,o=[],a={},u=[];function c(f){var p=a[f]={onStack:!0,lowlink:i,index:i++};if(o.push(f),r.successors(f).forEach(function(y){e.has(a,y)?a[y].onStack&&(p.lowlink=Math.min(p.lowlink,a[y].index)):(c(y),p.lowlink=Math.min(p.lowlink,a[y].lowlink))}),p.lowlink===p.index){var d=[],g;do g=o.pop(),a[g].onStack=!1,d.push(g);while(f!==g);u.push(d)}}return r.nodes().forEach(function(f){e.has(a,f)||c(f)}),u}return Dm}var Fm,vk;function g4(){if(vk)return Fm;vk=1;var e=Dn(),t=Gj();Fm=r;function r(i){return e.filter(t(i),function(o){return o.length>1||o.length===1&&i.hasEdge(o[0],o[0])})}return Fm}var zm,yk;function v4(){if(yk)return zm;yk=1;var e=Dn();zm=r;var t=e.constant(1);function r(o,a,u){return i(o,a||t,u||function(c){return o.outEdges(c)})}function i(o,a,u){var c={},f=o.nodes();return f.forEach(function(p){c[p]={},c[p][p]={distance:0},f.forEach(function(d){p!==d&&(c[p][d]={distance:Number.POSITIVE_INFINITY})}),u(p).forEach(function(d){var g=d.v===p?d.w:d.v,y=a(d);c[p][g]={distance:y,predecessor:p}})}),f.forEach(function(p){var d=c[p];f.forEach(function(g){var y=c[g];f.forEach(function(w){var E=y[p],_=d[w],b=y[w],S=E.distance+_.distance;S<b.distance&&(b.distance=S,b.predecessor=_.predecessor)})})}),c}return zm}var Bm,wk;function Yj(){if(wk)return Bm;wk=1;var e=Dn();Bm=t,t.CycleException=r;function t(i){var o={},a={},u=[];function c(f){if(e.has(a,f))throw new r;e.has(o,f)||(a[f]=!0,o[f]=!0,e.each(i.predecessors(f),c),delete a[f],u.push(f))}if(e.each(i.sinks(),c),e.size(o)!==i.nodeCount())throw new r;return u}function r(){}return r.prototype=new Error,Bm}var Um,xk;function y4(){if(xk)return Um;xk=1;var e=Yj();Um=t;function t(r){try{e(r)}catch(i){if(i instanceof e.CycleException)return!1;throw i}return!0}return Um}var Hm,_k;function Kj(){if(_k)return Hm;_k=1;var e=Dn();Hm=t;function t(i,o,a){e.isArray(o)||(o=[o]);var u=(i.isDirected()?i.successors:i.neighbors).bind(i),c=[],f={};return e.each(o,function(p){if(!i.hasNode(p))throw new Error("Graph does not have node: "+p);r(i,p,a==="post",f,u,c)}),c}function r(i,o,a,u,c,f){e.has(u,o)||(u[o]=!0,a||f.push(o),e.each(c(o),function(p){r(i,p,a,u,c,f)}),a&&f.push(o))}return Hm}var Wm,bk;function w4(){if(bk)return Wm;bk=1;var e=Kj();Wm=t;function t(r,i){return e(r,i,"post")}return Wm}var Vm,Sk;function x4(){if(Sk)return Vm;Sk=1;var e=Kj();Vm=t;function t(r,i){return e(r,i,"pre")}return Vm}var Gm,kk;function _4(){if(kk)return Gm;kk=1;var e=Dn(),t=My(),r=Wj();Gm=i;function i(o,a){var u=new t,c={},f=new r,p;function d(y){var w=y.v===p?y.w:y.v,E=f.priority(w);if(E!==void 0){var _=a(y);_<E&&(c[w]=p,f.decrease(w,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){f.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),f.decrease(o.nodes()[0],0);for(var g=!1;f.size()>0;){if(p=f.removeMin(),e.has(c,p))u.setEdge(p,c[p]);else{if(g)throw new Error("Input graph is not connected: "+o);g=!0}o.nodeEdges(p).forEach(d)}return u}return Gm}var Ym,Ek;function b4(){return Ek||(Ek=1,Ym={components:p4(),dijkstra:Vj(),dijkstraAll:m4(),findCycles:g4(),floydWarshall:v4(),isAcyclic:y4(),postorder:w4(),preorder:x4(),prim:_4(),tarjan:Gj(),topsort:Yj()}),Ym}var Km,Nk;function S4(){if(Nk)return Km;Nk=1;var e=f4();return Km={Graph:e.Graph,json:h4(),alg:b4(),version:e.version},Km}var Xm,Ck;function tr(){if(Ck)return Xm;Ck=1;var e;if(typeof vy=="function")try{e=S4()}catch{}return e||(e=window.graphlib),Xm=e,Xm}var Qm,jk;function k4(){if(jk)return Qm;jk=1;var e=xj(),t=1,r=4;function i(o){return e(o,t|r)}return Qm=i,Qm}var Zm,Tk;function sc(){if(Tk)return Zm;Tk=1;var e=xo(),t=Br(),r=Ku(),i=qn();function o(a,u,c){if(!i(c))return!1;var f=typeof u;return(f=="number"?t(c)&&r(u,c.length):f=="string"&&u in c)?e(c[u],a):!1}return Zm=o,Zm}var Jm,Rk;function E4(){if(Rk)return Jm;Rk=1;var e=rc(),t=xo(),r=sc(),i=yi(),o=Object.prototype,a=o.hasOwnProperty,u=e(function(c,f){c=Object(c);var p=-1,d=f.length,g=d>2?f[2]:void 0;for(g&&r(f[0],f[1],g)&&(d=1);++p<d;)for(var y=f[p],w=i(y),E=-1,_=w.length;++E<_;){var b=w[E],S=c[b];(S===void 0||t(S,o[b])&&!a.call(c,b))&&(c[b]=y[b])}return c});return Jm=u,Jm}var eg,Ak;function N4(){if(Ak)return eg;Ak=1;var e=Ur(),t=Br(),r=As();function i(o){return function(a,u,c){var f=Object(a);if(!t(a)){var p=e(u,3);a=r(a),u=function(g){return p(f[g],g,f)}}var d=o(a,u,c);return d>-1?f[p?a[d]:d]:void 0}}return eg=i,eg}var tg,Ik;function C4(){if(Ik)return tg;Ik=1;var e=/\s/;function t(r){for(var i=r.length;i--&&e.test(r.charAt(i)););return i}return tg=t,tg}var ng,Mk;function j4(){if(Mk)return ng;Mk=1;var e=C4(),t=/^\s+/;function r(i){return i&&i.slice(0,e(i)+1).replace(t,"")}return ng=r,ng}var rg,Ok;function T4(){if(Ok)return rg;Ok=1;var e=j4(),t=qn(),r=ko(),i=NaN,o=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function f(p){if(typeof p=="number")return p;if(r(p))return i;if(t(p)){var d=typeof p.valueOf=="function"?p.valueOf():p;p=t(d)?d+"":d}if(typeof p!="string")return p===0?p:+p;p=e(p);var g=a.test(p);return g||u.test(p)?c(p.slice(2),g?2:8):o.test(p)?i:+p}return rg=f,rg}var sg,Pk;function Xj(){if(Pk)return sg;Pk=1;var e=T4(),t=1/0,r=17976931348623157e292;function i(o){if(!o)return o===0?o:0;if(o=e(o),o===t||o===-t){var a=o<0?-1:1;return a*r}return o===o?o:0}return sg=i,sg}var ig,Lk;function R4(){if(Lk)return ig;Lk=1;var e=Xj();function t(r){var i=e(r),o=i%1;return i===i?o?i-o:i:0}return ig=t,ig}var og,$k;function A4(){if($k)return og;$k=1;var e=Bj(),t=Ur(),r=R4(),i=Math.max;function o(a,u,c){var f=a==null?0:a.length;if(!f)return-1;var p=c==null?0:r(c);return p<0&&(p=i(f+p,0)),e(a,t(u,3),p)}return og=o,og}var ag,qk;function I4(){if(qk)return ag;qk=1;var e=N4(),t=A4(),r=e(t);return ag=r,ag}var lg,Dk;function Qj(){if(Dk)return lg;Dk=1;var e=Iy();function t(r){var i=r==null?0:r.length;return i?e(r,1):[]}return lg=t,lg}var ug,Fk;function M4(){if(Fk)return ug;Fk=1;var e=jy(),t=_j(),r=yi();function i(o,a){return o==null?o:e(o,t(a),r)}return ug=i,ug}var cg,zk;function O4(){if(zk)return cg;zk=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return cg=e,cg}var dg,Bk;function P4(){if(Bk)return dg;Bk=1;var e=Gu(),t=Ty(),r=Ur();function i(o,a){var u={};return a=r(a,3),t(o,function(c,f,p){e(u,f,a(c,f,p))}),u}return dg=i,dg}var fg,Uk;function Oy(){if(Uk)return fg;Uk=1;var e=ko();function t(r,i,o){for(var a=-1,u=r.length;++a<u;){var c=r[a],f=i(c);if(f!=null&&(p===void 0?f===f&&!e(f):o(f,p)))var p=f,d=c}return d}return fg=t,fg}var hg,Hk;function L4(){if(Hk)return hg;Hk=1;function e(t,r){return t>r}return hg=e,hg}var pg,Wk;function $4(){if(Wk)return pg;Wk=1;var e=Oy(),t=L4(),r=wi();function i(o){return o&&o.length?e(o,r,t):void 0}return pg=i,pg}var mg,Vk;function Zj(){if(Vk)return mg;Vk=1;var e=Gu(),t=xo();function r(i,o,a){(a!==void 0&&!t(i[o],a)||a===void 0&&!(o in i))&&e(i,o,a)}return mg=r,mg}var gg,Gk;function q4(){if(Gk)return gg;Gk=1;var e=gi(),t=Zu(),r=mr(),i="[object Object]",o=Function.prototype,a=Object.prototype,u=o.toString,c=a.hasOwnProperty,f=u.call(Object);function p(d){if(!r(d)||e(d)!=i)return!1;var g=t(d);if(g===null)return!0;var y=c.call(g,"constructor")&&g.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==f}return gg=p,gg}var vg,Yk;function Jj(){if(Yk)return vg;Yk=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return vg=e,vg}var yg,Kk;function D4(){if(Kk)return yg;Kk=1;var e=qa(),t=yi();function r(i){return e(i,t(i))}return yg=r,yg}var wg,Xk;function F4(){if(Xk)return wg;Xk=1;var e=Zj(),t=lj(),r=vj(),i=uj(),o=wj(),a=Da(),u=_t(),c=Uj(),f=bo(),p=$a(),d=qn(),g=q4(),y=Fa(),w=Jj(),E=D4();function _(b,S,k,N,j,A,M){var P=w(b,k),O=w(S,k),D=M.get(O);if(D){e(b,k,D);return}var L=A?A(P,O,k+"",b,S,M):void 0,U=L===void 0;if(U){var V=u(O),z=!V&&f(O),C=!V&&!z&&y(O);L=O,V||z||C?u(P)?L=P:c(P)?L=i(P):z?(U=!1,L=t(O,!0)):C?(U=!1,L=r(O,!0)):L=[]:g(O)||a(O)?(L=P,a(P)?L=E(P):(!d(P)||p(P))&&(L=o(O))):U=!1}U&&(M.set(O,L),j(L,O,N,A,M),M.delete(O)),e(b,k,L)}return wg=_,wg}var xg,Qk;function z4(){if(Qk)return xg;Qk=1;var e=Vu(),t=Zj(),r=jy(),i=F4(),o=qn(),a=yi(),u=Jj();function c(f,p,d,g,y){f!==p&&r(p,function(w,E){if(y||(y=new e),o(w))i(f,p,E,d,c,g,y);else{var _=g?g(u(f,E),w,E+"",f,p,y):void 0;_===void 0&&(_=w),t(f,E,_)}},a)}return xg=c,xg}var _g,Zk;function B4(){if(Zk)return _g;Zk=1;var e=rc(),t=sc();function r(i){return e(function(o,a){var u=-1,c=a.length,f=c>1?a[c-1]:void 0,p=c>2?a[2]:void 0;for(f=i.length>3&&typeof f=="function"?(c--,f):void 0,p&&t(a[0],a[1],p)&&(f=c<3?void 0:f,c=1),o=Object(o);++u<c;){var d=a[u];d&&i(o,d,u,f)}return o})}return _g=r,_g}var bg,Jk;function U4(){if(Jk)return bg;Jk=1;var e=z4(),t=B4(),r=t(function(i,o,a){e(i,o,a)});return bg=r,bg}var Sg,eE;function eT(){if(eE)return Sg;eE=1;function e(t,r){return t<r}return Sg=e,Sg}var kg,tE;function H4(){if(tE)return kg;tE=1;var e=Oy(),t=eT(),r=wi();function i(o){return o&&o.length?e(o,r,t):void 0}return kg=i,kg}var Eg,nE;function W4(){if(nE)return Eg;nE=1;var e=Oy(),t=Ur(),r=eT();function i(o,a){return o&&o.length?e(o,t(a,2),r):void 0}return Eg=i,Eg}var Ng,rE;function V4(){if(rE)return Ng;rE=1;var e=rr(),t=function(){return e.Date.now()};return Ng=t,Ng}var Cg,sE;function G4(){if(sE)return Cg;sE=1;var e=Yu(),t=tc(),r=Ku(),i=qn(),o=za();function a(u,c,f,p){if(!i(u))return u;c=t(c,u);for(var d=-1,g=c.length,y=g-1,w=u;w!=null&&++d<g;){var E=o(c[d]),_=f;if(E==="__proto__"||E==="constructor"||E==="prototype")return u;if(d!=y){var b=w[E];_=p?p(b,E,w):void 0,_===void 0&&(_=i(b)?b:r(c[d+1])?[]:{})}e(w,E,_),w=w[E]}return u}return Cg=a,Cg}var jg,iE;function Y4(){if(iE)return jg;iE=1;var e=nc(),t=G4(),r=tc();function i(o,a,u){for(var c=-1,f=a.length,p={};++c<f;){var d=a[c],g=e(o,d);u(g,d)&&t(p,r(d,o),g)}return p}return jg=i,jg}var Tg,oE;function K4(){if(oE)return Tg;oE=1;var e=Y4(),t=Ij();function r(i,o){return e(i,o,function(a,u){return t(i,u)})}return Tg=r,Tg}var Rg,aE;function X4(){if(aE)return Rg;aE=1;var e=Qj(),t=Fj(),r=zj();function i(o){return r(t(o,void 0,e),o+"")}return Rg=i,Rg}var Ag,lE;function Q4(){if(lE)return Ag;lE=1;var e=K4(),t=X4(),r=t(function(i,o){return i==null?{}:e(i,o)});return Ag=r,Ag}var Ig,uE;function Z4(){if(uE)return Ig;uE=1;var e=Math.ceil,t=Math.max;function r(i,o,a,u){for(var c=-1,f=t(e((o-i)/(a||1)),0),p=Array(f);f--;)p[u?f:++c]=i,i+=a;return p}return Ig=r,Ig}var Mg,cE;function J4(){if(cE)return Mg;cE=1;var e=Z4(),t=sc(),r=Xj();function i(o){return function(a,u,c){return c&&typeof c!="number"&&t(a,u,c)&&(u=c=void 0),a=r(a),u===void 0?(u=a,a=0):u=r(u),c=c===void 0?a<u?1:-1:r(c),e(a,u,c,o)}}return Mg=i,Mg}var Og,dE;function e5(){if(dE)return Og;dE=1;var e=J4(),t=e();return Og=t,Og}var Pg,fE;function t5(){if(fE)return Pg;fE=1;function e(t,r){var i=t.length;for(t.sort(r);i--;)t[i]=t[i].value;return t}return Pg=e,Pg}var Lg,hE;function n5(){if(hE)return Lg;hE=1;var e=ko();function t(r,i){if(r!==i){var o=r!==void 0,a=r===null,u=r===r,c=e(r),f=i!==void 0,p=i===null,d=i===i,g=e(i);if(!p&&!g&&!c&&r>i||c&&f&&d&&!p&&!g||a&&f&&d||!o&&d||!u)return 1;if(!a&&!c&&!g&&r<i||g&&o&&u&&!a&&!c||p&&o&&u||!f&&u||!d)return-1}return 0}return Lg=t,Lg}var $g,pE;function r5(){if(pE)return $g;pE=1;var e=n5();function t(r,i,o){for(var a=-1,u=r.criteria,c=i.criteria,f=u.length,p=o.length;++a<f;){var d=e(u[a],c[a]);if(d){if(a>=p)return d;var g=o[a];return d*(g=="desc"?-1:1)}}return r.index-i.index}return $g=t,$g}var qg,mE;function s5(){if(mE)return qg;mE=1;var e=ec(),t=nc(),r=Ur(),i=$j(),o=t5(),a=Xu(),u=r5(),c=wi(),f=_t();function p(d,g,y){g.length?g=e(g,function(_){return f(_)?function(b){return t(b,_.length===1?_[0]:_)}:_}):g=[c];var w=-1;g=e(g,a(r));var E=i(d,function(_,b,S){var k=e(g,function(N){return N(_)});return{criteria:k,index:++w,value:_}});return o(E,function(_,b){return u(_,b,y)})}return qg=p,qg}var Dg,gE;function i5(){if(gE)return Dg;gE=1;var e=Iy(),t=s5(),r=rc(),i=sc(),o=r(function(a,u){if(a==null)return[];var c=u.length;return c>1&&i(a,u[0],u[1])?u=[]:c>2&&i(u[0],u[1],u[2])&&(u=[u[0]]),t(a,e(u,1),[])});return Dg=o,Dg}var Fg,vE;function o5(){if(vE)return Fg;vE=1;var e=Rj(),t=0;function r(i){var o=++t;return e(i)+o}return Fg=r,Fg}var zg,yE;function a5(){if(yE)return zg;yE=1;function e(t,r,i){for(var o=-1,a=t.length,u=r.length,c={};++o<a;){var f=o<u?r[o]:void 0;i(c,t[o],f)}return c}return zg=e,zg}var Bg,wE;function l5(){if(wE)return Bg;wE=1;var e=Yu(),t=a5();function r(i,o){return t(i||[],o||[],e)}return Bg=r,Bg}var Ug,xE;function at(){if(xE)return Ug;xE=1;var e;if(typeof vy=="function")try{e={cloneDeep:k4(),constant:Cy(),defaults:E4(),each:Sj(),filter:Oj(),find:I4(),flatten:Qj(),forEach:bj(),forIn:M4(),has:Pj(),isUndefined:Lj(),last:O4(),map:qj(),mapValues:P4(),max:$4(),merge:U4(),min:H4(),minBy:W4(),now:V4(),pick:Q4(),range:e5(),reduce:Dj(),sortBy:i5(),uniqueId:o5(),values:Hj(),zipObject:l5()}}catch{}return e||(e=window._),Ug=e,Ug}var Hg,_E;function u5(){if(_E)return Hg;_E=1,Hg=e;function e(){var i={};i._next=i._prev=i,this._sentinel=i}e.prototype.dequeue=function(){var i=this._sentinel,o=i._prev;if(o!==i)return t(o),o},e.prototype.enqueue=function(i){var o=this._sentinel;i._prev&&i._next&&t(i),i._next=o._next,o._next._prev=i,o._next=i,i._prev=o},e.prototype.toString=function(){for(var i=[],o=this._sentinel,a=o._prev;a!==o;)i.push(JSON.stringify(a,r)),a=a._prev;return"["+i.join(", ")+"]"};function t(i){i._prev._next=i._next,i._next._prev=i._prev,delete i._next,delete i._prev}function r(i,o){if(i!=="_next"&&i!=="_prev")return o}return Hg}var Wg,bE;function c5(){if(bE)return Wg;bE=1;var e=at(),t=tr().Graph,r=u5();Wg=o;var i=e.constant(1);function o(p,d){if(p.nodeCount()<=1)return[];var g=c(p,d||i),y=a(g.graph,g.buckets,g.zeroIdx);return e.flatten(e.map(y,function(w){return p.outEdges(w.v,w.w)}),!0)}function a(p,d,g){for(var y=[],w=d[d.length-1],E=d[0],_;p.nodeCount();){for(;_=E.dequeue();)u(p,d,g,_);for(;_=w.dequeue();)u(p,d,g,_);if(p.nodeCount()){for(var b=d.length-2;b>0;--b)if(_=d[b].dequeue(),_){y=y.concat(u(p,d,g,_,!0));break}}}return y}function u(p,d,g,y,w){var E=w?[]:void 0;return e.forEach(p.inEdges(y.v),function(_){var b=p.edge(_),S=p.node(_.v);w&&E.push({v:_.v,w:_.w}),S.out-=b,f(d,g,S)}),e.forEach(p.outEdges(y.v),function(_){var b=p.edge(_),S=_.w,k=p.node(S);k.in-=b,f(d,g,k)}),p.removeNode(y.v),E}function c(p,d){var g=new t,y=0,w=0;e.forEach(p.nodes(),function(b){g.setNode(b,{v:b,in:0,out:0})}),e.forEach(p.edges(),function(b){var S=g.edge(b.v,b.w)||0,k=d(b),N=S+k;g.setEdge(b.v,b.w,N),w=Math.max(w,g.node(b.v).out+=k),y=Math.max(y,g.node(b.w).in+=k)});var E=e.range(w+y+3).map(function(){return new r}),_=y+1;return e.forEach(g.nodes(),function(b){f(E,_,g.node(b))}),{graph:g,buckets:E,zeroIdx:_}}function f(p,d,g){g.out?g.in?p[g.out-g.in+d].enqueue(g):p[p.length-1].enqueue(g):p[0].enqueue(g)}return Wg}var Vg,SE;function d5(){if(SE)return Vg;SE=1;var e=at(),t=c5();Vg={run:r,undo:o};function r(a){var u=a.graph().acyclicer==="greedy"?t(a,c(a)):i(a);e.forEach(u,function(f){var p=a.edge(f);a.removeEdge(f),p.forwardName=f.name,p.reversed=!0,a.setEdge(f.w,f.v,p,e.uniqueId("rev"))});function c(f){return function(p){return f.edge(p).weight}}}function i(a){var u=[],c={},f={};function p(d){e.has(f,d)||(f[d]=!0,c[d]=!0,e.forEach(a.outEdges(d),function(g){e.has(c,g.w)?u.push(g):p(g.w)}),delete c[d])}return e.forEach(a.nodes(),p),u}function o(a){e.forEach(a.edges(),function(u){var c=a.edge(u);if(c.reversed){a.removeEdge(u);var f=c.forwardName;delete c.reversed,delete c.forwardName,a.setEdge(u.w,u.v,c,f)}})}return Vg}var Gg,kE;function fn(){if(kE)return Gg;kE=1;var e=at(),t=tr().Graph;Gg={addDummyNode:r,simplify:i,asNonCompoundGraph:o,successorWeights:a,predecessorWeights:u,intersectRect:c,buildLayerMatrix:f,normalizeRanks:p,removeEmptyRanks:d,addBorderNode:g,maxRank:y,partition:w,time:E,notime:_};function r(b,S,k,N){var j;do j=e.uniqueId(N);while(b.hasNode(j));return k.dummy=S,b.setNode(j,k),j}function i(b){var S=new t().setGraph(b.graph());return e.forEach(b.nodes(),function(k){S.setNode(k,b.node(k))}),e.forEach(b.edges(),function(k){var N=S.edge(k.v,k.w)||{weight:0,minlen:1},j=b.edge(k);S.setEdge(k.v,k.w,{weight:N.weight+j.weight,minlen:Math.max(N.minlen,j.minlen)})}),S}function o(b){var S=new t({multigraph:b.isMultigraph()}).setGraph(b.graph());return e.forEach(b.nodes(),function(k){b.children(k).length||S.setNode(k,b.node(k))}),e.forEach(b.edges(),function(k){S.setEdge(k,b.edge(k))}),S}function a(b){var S=e.map(b.nodes(),function(k){var N={};return e.forEach(b.outEdges(k),function(j){N[j.w]=(N[j.w]||0)+b.edge(j).weight}),N});return e.zipObject(b.nodes(),S)}function u(b){var S=e.map(b.nodes(),function(k){var N={};return e.forEach(b.inEdges(k),function(j){N[j.v]=(N[j.v]||0)+b.edge(j).weight}),N});return e.zipObject(b.nodes(),S)}function c(b,S){var k=b.x,N=b.y,j=S.x-k,A=S.y-N,M=b.width/2,P=b.height/2;if(!j&&!A)throw new Error("Not possible to find intersection inside of the rectangle");var O,D;return Math.abs(A)*M>Math.abs(j)*P?(A<0&&(P=-P),O=P*j/A,D=P):(j<0&&(M=-M),O=M,D=M*A/j),{x:k+O,y:N+D}}function f(b){var S=e.map(e.range(y(b)+1),function(){return[]});return e.forEach(b.nodes(),function(k){var N=b.node(k),j=N.rank;e.isUndefined(j)||(S[j][N.order]=k)}),S}function p(b){var S=e.min(e.map(b.nodes(),function(k){return b.node(k).rank}));e.forEach(b.nodes(),function(k){var N=b.node(k);e.has(N,"rank")&&(N.rank-=S)})}function d(b){var S=e.min(e.map(b.nodes(),function(A){return b.node(A).rank})),k=[];e.forEach(b.nodes(),function(A){var M=b.node(A).rank-S;k[M]||(k[M]=[]),k[M].push(A)});var N=0,j=b.graph().nodeRankFactor;e.forEach(k,function(A,M){e.isUndefined(A)&&M%j!==0?--N:N&&e.forEach(A,function(P){b.node(P).rank+=N})})}function g(b,S,k,N){var j={width:0,height:0};return arguments.length>=4&&(j.rank=k,j.order=N),r(b,"border",j,S)}function y(b){return e.max(e.map(b.nodes(),function(S){var k=b.node(S).rank;if(!e.isUndefined(k))return k}))}function w(b,S){var k={lhs:[],rhs:[]};return e.forEach(b,function(N){S(N)?k.lhs.push(N):k.rhs.push(N)}),k}function E(b,S){var k=e.now();try{return S()}finally{console.log(b+" time: "+(e.now()-k)+"ms")}}function _(b,S){return S()}return Gg}var Yg,EE;function f5(){if(EE)return Yg;EE=1;var e=at(),t=fn();Yg={run:r,undo:o};function r(a){a.graph().dummyChains=[],e.forEach(a.edges(),function(u){i(a,u)})}function i(a,u){var c=u.v,f=a.node(c).rank,p=u.w,d=a.node(p).rank,g=u.name,y=a.edge(u),w=y.labelRank;if(d!==f+1){a.removeEdge(u);var E,_,b;for(b=0,++f;f<d;++b,++f)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:u,rank:f},E=t.addDummyNode(a,"edge",_,"_d"),f===w&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),a.setEdge(c,E,{weight:y.weight},g),b===0&&a.graph().dummyChains.push(E),c=E;a.setEdge(c,p,{weight:y.weight},g)}}function o(a){e.forEach(a.graph().dummyChains,function(u){var c=a.node(u),f=c.edgeLabel,p;for(a.setEdge(c.edgeObj,f);c.dummy;)p=a.successors(u)[0],a.removeNode(u),f.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(f.x=c.x,f.y=c.y,f.width=c.width,f.height=c.height),u=p,c=a.node(u)})}return Yg}var Kg,NE;function Au(){if(NE)return Kg;NE=1;var e=at();Kg={longestPath:t,slack:r};function t(i){var o={};function a(u){var c=i.node(u);if(e.has(o,u))return c.rank;o[u]=!0;var f=e.min(e.map(i.outEdges(u),function(p){return a(p.w)-i.edge(p).minlen}));return(f===Number.POSITIVE_INFINITY||f===void 0||f===null)&&(f=0),c.rank=f}e.forEach(i.sources(),a)}function r(i,o){return i.node(o.w).rank-i.node(o.v).rank-i.edge(o).minlen}return Kg}var Xg,CE;function tT(){if(CE)return Xg;CE=1;var e=at(),t=tr().Graph,r=Au().slack;Xg=i;function i(c){var f=new t({directed:!1}),p=c.nodes()[0],d=c.nodeCount();f.setNode(p,{});for(var g,y;o(f,c)<d;)g=a(f,c),y=f.hasNode(g.v)?r(c,g):-r(c,g),u(f,c,y);return f}function o(c,f){function p(d){e.forEach(f.nodeEdges(d),function(g){var y=g.v,w=d===y?g.w:y;!c.hasNode(w)&&!r(f,g)&&(c.setNode(w,{}),c.setEdge(d,w,{}),p(w))})}return e.forEach(c.nodes(),p),c.nodeCount()}function a(c,f){return e.minBy(f.edges(),function(p){if(c.hasNode(p.v)!==c.hasNode(p.w))return r(f,p)})}function u(c,f,p){e.forEach(c.nodes(),function(d){f.node(d).rank+=p})}return Xg}var Qg,jE;function h5(){if(jE)return Qg;jE=1;var e=at(),t=tT(),r=Au().slack,i=Au().longestPath,o=tr().alg.preorder,a=tr().alg.postorder,u=fn().simplify;Qg=c,c.initLowLimValues=g,c.initCutValues=f,c.calcCutValue=d,c.leaveEdge=w,c.enterEdge=E,c.exchangeEdges=_;function c(N){N=u(N),i(N);var j=t(N);g(j),f(j,N);for(var A,M;A=w(j);)M=E(j,N,A),_(j,N,A,M)}function f(N,j){var A=a(N,N.nodes());A=A.slice(0,A.length-1),e.forEach(A,function(M){p(N,j,M)})}function p(N,j,A){var M=N.node(A),P=M.parent;N.edge(A,P).cutvalue=d(N,j,A)}function d(N,j,A){var M=N.node(A),P=M.parent,O=!0,D=j.edge(A,P),L=0;return D||(O=!1,D=j.edge(P,A)),L=D.weight,e.forEach(j.nodeEdges(A),function(U){var V=U.v===A,z=V?U.w:U.v;if(z!==P){var C=V===O,F=j.edge(U).weight;if(L+=C?F:-F,S(N,A,z)){var $=N.edge(A,z).cutvalue;L+=C?-$:$}}}),L}function g(N,j){arguments.length<2&&(j=N.nodes()[0]),y(N,{},1,j)}function y(N,j,A,M,P){var O=A,D=N.node(M);return j[M]=!0,e.forEach(N.neighbors(M),function(L){e.has(j,L)||(A=y(N,j,A,L,M))}),D.low=O,D.lim=A++,P?D.parent=P:delete D.parent,A}function w(N){return e.find(N.edges(),function(j){return N.edge(j).cutvalue<0})}function E(N,j,A){var M=A.v,P=A.w;j.hasEdge(M,P)||(M=A.w,P=A.v);var O=N.node(M),D=N.node(P),L=O,U=!1;O.lim>D.lim&&(L=D,U=!0);var V=e.filter(j.edges(),function(z){return U===k(N,N.node(z.v),L)&&U!==k(N,N.node(z.w),L)});return e.minBy(V,function(z){return r(j,z)})}function _(N,j,A,M){var P=A.v,O=A.w;N.removeEdge(P,O),N.setEdge(M.v,M.w,{}),g(N),f(N,j),b(N,j)}function b(N,j){var A=e.find(N.nodes(),function(P){return!j.node(P).parent}),M=o(N,A);M=M.slice(1),e.forEach(M,function(P){var O=N.node(P).parent,D=j.edge(P,O),L=!1;D||(D=j.edge(O,P),L=!0),j.node(P).rank=j.node(O).rank+(L?D.minlen:-D.minlen)})}function S(N,j,A){return N.hasEdge(j,A)}function k(N,j,A){return A.low<=j.lim&&j.lim<=A.lim}return Qg}var Zg,TE;function p5(){if(TE)return Zg;TE=1;var e=Au(),t=e.longestPath,r=tT(),i=h5();Zg=o;function o(f){switch(f.graph().ranker){case"network-simplex":c(f);break;case"tight-tree":u(f);break;case"longest-path":a(f);break;default:c(f)}}var a=t;function u(f){t(f),r(f)}function c(f){i(f)}return Zg}var Jg,RE;function m5(){if(RE)return Jg;RE=1;var e=at();Jg=t;function t(o){var a=i(o);e.forEach(o.graph().dummyChains,function(u){for(var c=o.node(u),f=c.edgeObj,p=r(o,a,f.v,f.w),d=p.path,g=p.lca,y=0,w=d[y],E=!0;u!==f.w;){if(c=o.node(u),E){for(;(w=d[y])!==g&&o.node(w).maxRank<c.rank;)y++;w===g&&(E=!1)}if(!E){for(;y<d.length-1&&o.node(w=d[y+1]).minRank<=c.rank;)y++;w=d[y]}o.setParent(u,w),u=o.successors(u)[0]}})}function r(o,a,u,c){var f=[],p=[],d=Math.min(a[u].low,a[c].low),g=Math.max(a[u].lim,a[c].lim),y,w;y=u;do y=o.parent(y),f.push(y);while(y&&(a[y].low>d||g>a[y].lim));for(w=y,y=c;(y=o.parent(y))!==w;)p.push(y);return{path:f.concat(p.reverse()),lca:w}}function i(o){var a={},u=0;function c(f){var p=u;e.forEach(o.children(f),c),a[f]={low:p,lim:u++}}return e.forEach(o.children(),c),a}return Jg}var ev,AE;function g5(){if(AE)return ev;AE=1;var e=at(),t=fn();ev={run:r,cleanup:u};function r(c){var f=t.addDummyNode(c,"root",{},"_root"),p=o(c),d=e.max(e.values(p))-1,g=2*d+1;c.graph().nestingRoot=f,e.forEach(c.edges(),function(w){c.edge(w).minlen*=g});var y=a(c)+1;e.forEach(c.children(),function(w){i(c,f,g,y,d,p,w)}),c.graph().nodeRankFactor=g}function i(c,f,p,d,g,y,w){var E=c.children(w);if(!E.length){w!==f&&c.setEdge(f,w,{weight:0,minlen:p});return}var _=t.addBorderNode(c,"_bt"),b=t.addBorderNode(c,"_bb"),S=c.node(w);c.setParent(_,w),S.borderTop=_,c.setParent(b,w),S.borderBottom=b,e.forEach(E,function(k){i(c,f,p,d,g,y,k);var N=c.node(k),j=N.borderTop?N.borderTop:k,A=N.borderBottom?N.borderBottom:k,M=N.borderTop?d:2*d,P=j!==A?1:g-y[w]+1;c.setEdge(_,j,{weight:M,minlen:P,nestingEdge:!0}),c.setEdge(A,b,{weight:M,minlen:P,nestingEdge:!0})}),c.parent(w)||c.setEdge(f,_,{weight:0,minlen:g+y[w]})}function o(c){var f={};function p(d,g){var y=c.children(d);y&&y.length&&e.forEach(y,function(w){p(w,g+1)}),f[d]=g}return e.forEach(c.children(),function(d){p(d,1)}),f}function a(c){return e.reduce(c.edges(),function(f,p){return f+c.edge(p).weight},0)}function u(c){var f=c.graph();c.removeNode(f.nestingRoot),delete f.nestingRoot,e.forEach(c.edges(),function(p){var d=c.edge(p);d.nestingEdge&&c.removeEdge(p)})}return ev}var tv,IE;function v5(){if(IE)return tv;IE=1;var e=at(),t=fn();tv=r;function r(o){function a(u){var c=o.children(u),f=o.node(u);if(c.length&&e.forEach(c,a),e.has(f,"minRank")){f.borderLeft=[],f.borderRight=[];for(var p=f.minRank,d=f.maxRank+1;p<d;++p)i(o,"borderLeft","_bl",u,f,p),i(o,"borderRight","_br",u,f,p)}}e.forEach(o.children(),a)}function i(o,a,u,c,f,p){var d={width:0,height:0,rank:p,borderType:a},g=f[a][p-1],y=t.addDummyNode(o,"border",d,u);f[a][p]=y,o.setParent(y,c),g&&o.setEdge(g,y,{weight:1})}return tv}var nv,ME;function y5(){if(ME)return nv;ME=1;var e=at();nv={adjust:t,undo:r};function t(p){var d=p.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&i(p)}function r(p){var d=p.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&a(p),(d==="lr"||d==="rl")&&(c(p),i(p))}function i(p){e.forEach(p.nodes(),function(d){o(p.node(d))}),e.forEach(p.edges(),function(d){o(p.edge(d))})}function o(p){var d=p.width;p.width=p.height,p.height=d}function a(p){e.forEach(p.nodes(),function(d){u(p.node(d))}),e.forEach(p.edges(),function(d){var g=p.edge(d);e.forEach(g.points,u),e.has(g,"y")&&u(g)})}function u(p){p.y=-p.y}function c(p){e.forEach(p.nodes(),function(d){f(p.node(d))}),e.forEach(p.edges(),function(d){var g=p.edge(d);e.forEach(g.points,f),e.has(g,"x")&&f(g)})}function f(p){var d=p.x;p.x=p.y,p.y=d}return nv}var rv,OE;function w5(){if(OE)return rv;OE=1;var e=at();rv=t;function t(r){var i={},o=e.filter(r.nodes(),function(p){return!r.children(p).length}),a=e.max(e.map(o,function(p){return r.node(p).rank})),u=e.map(e.range(a+1),function(){return[]});function c(p){if(!e.has(i,p)){i[p]=!0;var d=r.node(p);u[d.rank].push(p),e.forEach(r.successors(p),c)}}var f=e.sortBy(o,function(p){return r.node(p).rank});return e.forEach(f,c),u}return rv}var sv,PE;function x5(){if(PE)return sv;PE=1;var e=at();sv=t;function t(i,o){for(var a=0,u=1;u<o.length;++u)a+=r(i,o[u-1],o[u]);return a}function r(i,o,a){for(var u=e.zipObject(a,e.map(a,function(y,w){return w})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(i.outEdges(y),function(w){return{pos:u[w.w],weight:i.edge(w).weight}}),"pos")}),!0),f=1;f<a.length;)f<<=1;var p=2*f-1;f-=1;var d=e.map(new Array(p),function(){return 0}),g=0;return e.forEach(c.forEach(function(y){var w=y.pos+f;d[w]+=y.weight;for(var E=0;w>0;)w%2&&(E+=d[w+1]),w=w-1>>1,d[w]+=y.weight;g+=y.weight*E})),g}return sv}var iv,LE;function _5(){if(LE)return iv;LE=1;var e=at();iv=t;function t(r,i){return e.map(i,function(o){var a=r.inEdges(o);if(a.length){var u=e.reduce(a,function(c,f){var p=r.edge(f),d=r.node(f.v);return{sum:c.sum+p.weight*d.order,weight:c.weight+p.weight}},{sum:0,weight:0});return{v:o,barycenter:u.sum/u.weight,weight:u.weight}}else return{v:o}})}return iv}var ov,$E;function b5(){if($E)return ov;$E=1;var e=at();ov=t;function t(o,a){var u={};e.forEach(o,function(f,p){var d=u[f.v]={indegree:0,in:[],out:[],vs:[f.v],i:p};e.isUndefined(f.barycenter)||(d.barycenter=f.barycenter,d.weight=f.weight)}),e.forEach(a.edges(),function(f){var p=u[f.v],d=u[f.w];!e.isUndefined(p)&&!e.isUndefined(d)&&(d.indegree++,p.out.push(u[f.w]))});var c=e.filter(u,function(f){return!f.indegree});return r(c)}function r(o){var a=[];function u(p){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(p.barycenter)||d.barycenter>=p.barycenter)&&i(p,d)}}function c(p){return function(d){d.in.push(p),--d.indegree===0&&o.push(d)}}for(;o.length;){var f=o.pop();a.push(f),e.forEach(f.in.reverse(),u(f)),e.forEach(f.out,c(f))}return e.map(e.filter(a,function(p){return!p.merged}),function(p){return e.pick(p,["vs","i","barycenter","weight"])})}function i(o,a){var u=0,c=0;o.weight&&(u+=o.barycenter*o.weight,c+=o.weight),a.weight&&(u+=a.barycenter*a.weight,c+=a.weight),o.vs=a.vs.concat(o.vs),o.barycenter=u/c,o.weight=c,o.i=Math.min(a.i,o.i),a.merged=!0}return ov}var av,qE;function S5(){if(qE)return av;qE=1;var e=at(),t=fn();av=r;function r(a,u){var c=t.partition(a,function(_){return e.has(_,"barycenter")}),f=c.lhs,p=e.sortBy(c.rhs,function(_){return-_.i}),d=[],g=0,y=0,w=0;f.sort(o(!!u)),w=i(d,p,w),e.forEach(f,function(_){w+=_.vs.length,d.push(_.vs),g+=_.barycenter*_.weight,y+=_.weight,w=i(d,p,w)});var E={vs:e.flatten(d,!0)};return y&&(E.barycenter=g/y,E.weight=y),E}function i(a,u,c){for(var f;u.length&&(f=e.last(u)).i<=c;)u.pop(),a.push(f.vs),c++;return c}function o(a){return function(u,c){return u.barycenter<c.barycenter?-1:u.barycenter>c.barycenter?1:a?c.i-u.i:u.i-c.i}}return av}var lv,DE;function k5(){if(DE)return lv;DE=1;var e=at(),t=_5(),r=b5(),i=S5();lv=o;function o(c,f,p,d){var g=c.children(f),y=c.node(f),w=y?y.borderLeft:void 0,E=y?y.borderRight:void 0,_={};w&&(g=e.filter(g,function(A){return A!==w&&A!==E}));var b=t(c,g);e.forEach(b,function(A){if(c.children(A.v).length){var M=o(c,A.v,p,d);_[A.v]=M,e.has(M,"barycenter")&&u(A,M)}});var S=r(b,p);a(S,_);var k=i(S,d);if(w&&(k.vs=e.flatten([w,k.vs,E],!0),c.predecessors(w).length)){var N=c.node(c.predecessors(w)[0]),j=c.node(c.predecessors(E)[0]);e.has(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+N.order+j.order)/(k.weight+2),k.weight+=2}return k}function a(c,f){e.forEach(c,function(p){p.vs=e.flatten(p.vs.map(function(d){return f[d]?f[d].vs:d}),!0)})}function u(c,f){e.isUndefined(c.barycenter)?(c.barycenter=f.barycenter,c.weight=f.weight):(c.barycenter=(c.barycenter*c.weight+f.barycenter*f.weight)/(c.weight+f.weight),c.weight+=f.weight)}return lv}var uv,FE;function E5(){if(FE)return uv;FE=1;var e=at(),t=tr().Graph;uv=r;function r(o,a,u){var c=i(o),f=new t({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(p){return o.node(p)});return e.forEach(o.nodes(),function(p){var d=o.node(p),g=o.parent(p);(d.rank===a||d.minRank<=a&&a<=d.maxRank)&&(f.setNode(p),f.setParent(p,g||c),e.forEach(o[u](p),function(y){var w=y.v===p?y.w:y.v,E=f.edge(w,p),_=e.isUndefined(E)?0:E.weight;f.setEdge(w,p,{weight:o.edge(y).weight+_})}),e.has(d,"minRank")&&f.setNode(p,{borderLeft:d.borderLeft[a],borderRight:d.borderRight[a]}))}),f}function i(o){for(var a;o.hasNode(a=e.uniqueId("_root")););return a}return uv}var cv,zE;function N5(){if(zE)return cv;zE=1;var e=at();cv=t;function t(r,i,o){var a={},u;e.forEach(o,function(c){for(var f=r.parent(c),p,d;f;){if(p=r.parent(f),p?(d=a[p],a[p]=f):(d=u,u=f),d&&d!==f){i.setEdge(d,f);return}f=p}})}return cv}var dv,BE;function C5(){if(BE)return dv;BE=1;var e=at(),t=w5(),r=x5(),i=k5(),o=E5(),a=N5(),u=tr().Graph,c=fn();dv=f;function f(y){var w=c.maxRank(y),E=p(y,e.range(1,w+1),"inEdges"),_=p(y,e.range(w-1,-1,-1),"outEdges"),b=t(y);g(y,b);for(var S=Number.POSITIVE_INFINITY,k,N=0,j=0;j<4;++N,++j){d(N%2?E:_,N%4>=2),b=c.buildLayerMatrix(y);var A=r(y,b);A<S&&(j=0,k=e.cloneDeep(b),S=A)}g(y,k)}function p(y,w,E){return e.map(w,function(_){return o(y,_,E)})}function d(y,w){var E=new u;e.forEach(y,function(_){var b=_.graph().root,S=i(_,b,E,w);e.forEach(S.vs,function(k,N){_.node(k).order=N}),a(_,E,S.vs)})}function g(y,w){e.forEach(w,function(E){e.forEach(E,function(_,b){y.node(_).order=b})})}return dv}var fv,UE;function j5(){if(UE)return fv;UE=1;var e=at(),t=tr().Graph,r=fn();fv={positionX:E,findType1Conflicts:i,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:f,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:g,balance:w};function i(S,k){var N={};function j(A,M){var P=0,O=0,D=A.length,L=e.last(M);return e.forEach(M,function(U,V){var z=a(S,U),C=z?S.node(z).order:D;(z||U===L)&&(e.forEach(M.slice(O,V+1),function(F){e.forEach(S.predecessors(F),function($){var re=S.node($),J=re.order;(J<P||C<J)&&!(re.dummy&&S.node(F).dummy)&&u(N,$,F)})}),O=V+1,P=C)}),M}return e.reduce(k,j),N}function o(S,k){var N={};function j(M,P,O,D,L){var U;e.forEach(e.range(P,O),function(V){U=M[V],S.node(U).dummy&&e.forEach(S.predecessors(U),function(z){var C=S.node(z);C.dummy&&(C.order<D||C.order>L)&&u(N,z,U)})})}function A(M,P){var O=-1,D,L=0;return e.forEach(P,function(U,V){if(S.node(U).dummy==="border"){var z=S.predecessors(U);z.length&&(D=S.node(z[0]).order,j(P,L,V,O,D),L=V,O=D)}j(P,L,P.length,D,M.length)}),P}return e.reduce(k,A),N}function a(S,k){if(S.node(k).dummy)return e.find(S.predecessors(k),function(N){return S.node(N).dummy})}function u(S,k,N){if(k>N){var j=k;k=N,N=j}var A=S[k];A||(S[k]=A={}),A[N]=!0}function c(S,k,N){if(k>N){var j=k;k=N,N=j}return e.has(S[k],N)}function f(S,k,N,j){var A={},M={},P={};return e.forEach(k,function(O){e.forEach(O,function(D,L){A[D]=D,M[D]=D,P[D]=L})}),e.forEach(k,function(O){var D=-1;e.forEach(O,function(L){var U=j(L);if(U.length){U=e.sortBy(U,function($){return P[$]});for(var V=(U.length-1)/2,z=Math.floor(V),C=Math.ceil(V);z<=C;++z){var F=U[z];M[L]===L&&D<P[F]&&!c(N,L,F)&&(M[F]=L,M[L]=A[L]=A[F],D=P[F])}}})}),{root:A,align:M}}function p(S,k,N,j,A){var M={},P=d(S,k,N,A),O=A?"borderLeft":"borderRight";function D(V,z){for(var C=P.nodes(),F=C.pop(),$={};F;)$[F]?V(F):($[F]=!0,C.push(F),C=C.concat(z(F))),F=C.pop()}function L(V){M[V]=P.inEdges(V).reduce(function(z,C){return Math.max(z,M[C.v]+P.edge(C))},0)}function U(V){var z=P.outEdges(V).reduce(function(F,$){return Math.min(F,M[$.w]-P.edge($))},Number.POSITIVE_INFINITY),C=S.node(V);z!==Number.POSITIVE_INFINITY&&C.borderType!==O&&(M[V]=Math.max(M[V],z))}return D(L,P.predecessors.bind(P)),D(U,P.successors.bind(P)),e.forEach(j,function(V){M[V]=M[N[V]]}),M}function d(S,k,N,j){var A=new t,M=S.graph(),P=_(M.nodesep,M.edgesep,j);return e.forEach(k,function(O){var D;e.forEach(O,function(L){var U=N[L];if(A.setNode(U),D){var V=N[D],z=A.edge(V,U);A.setEdge(V,U,Math.max(P(S,L,D),z||0))}D=L})}),A}function g(S,k){return e.minBy(e.values(k),function(N){var j=Number.NEGATIVE_INFINITY,A=Number.POSITIVE_INFINITY;return e.forIn(N,function(M,P){var O=b(S,P)/2;j=Math.max(M+O,j),A=Math.min(M-O,A)}),j-A})}function y(S,k){var N=e.values(k),j=e.min(N),A=e.max(N);e.forEach(["u","d"],function(M){e.forEach(["l","r"],function(P){var O=M+P,D=S[O],L;if(D!==k){var U=e.values(D);L=P==="l"?j-e.min(U):A-e.max(U),L&&(S[O]=e.mapValues(D,function(V){return V+L}))}})})}function w(S,k){return e.mapValues(S.ul,function(N,j){if(k)return S[k.toLowerCase()][j];var A=e.sortBy(e.map(S,j));return(A[1]+A[2])/2})}function E(S){var k=r.buildLayerMatrix(S),N=e.merge(i(S,k),o(S,k)),j={},A;e.forEach(["u","d"],function(P){A=P==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(O){O==="r"&&(A=e.map(A,function(V){return e.values(V).reverse()}));var D=(P==="u"?S.predecessors:S.successors).bind(S),L=f(S,A,N,D),U=p(S,A,L.root,L.align,O==="r");O==="r"&&(U=e.mapValues(U,function(V){return-V})),j[P+O]=U})});var M=g(S,j);return y(j,M),w(j,S.graph().align)}function _(S,k,N){return function(j,A,M){var P=j.node(A),O=j.node(M),D=0,L;if(D+=P.width/2,e.has(P,"labelpos"))switch(P.labelpos.toLowerCase()){case"l":L=-P.width/2;break;case"r":L=P.width/2;break}if(L&&(D+=N?L:-L),L=0,D+=(P.dummy?k:S)/2,D+=(O.dummy?k:S)/2,D+=O.width/2,e.has(O,"labelpos"))switch(O.labelpos.toLowerCase()){case"l":L=O.width/2;break;case"r":L=-O.width/2;break}return L&&(D+=N?L:-L),L=0,D}}function b(S,k){return S.node(k).width}return fv}var hv,HE;function T5(){if(HE)return hv;HE=1;var e=at(),t=fn(),r=j5().positionX;hv=i;function i(a){a=t.asNonCompoundGraph(a),o(a),e.forEach(r(a),function(u,c){a.node(c).x=u})}function o(a){var u=t.buildLayerMatrix(a),c=a.graph().ranksep,f=0;e.forEach(u,function(p){var d=e.max(e.map(p,function(g){return a.node(g).height}));e.forEach(p,function(g){a.node(g).y=f+d/2}),f+=d+c})}return hv}var pv,WE;function R5(){if(WE)return pv;WE=1;var e=at(),t=d5(),r=f5(),i=p5(),o=fn().normalizeRanks,a=m5(),u=fn().removeEmptyRanks,c=g5(),f=v5(),p=y5(),d=C5(),g=T5(),y=fn(),w=tr().Graph;pv=E;function E(q,Q){var ne=Q&&Q.debugTiming?y.time:y.notime;ne("layout",function(){var ae=ne(" buildLayoutGraph",function(){return D(q)});ne(" runLayout",function(){_(ae,ne)}),ne(" updateInputGraph",function(){b(q,ae)})})}function _(q,Q){Q(" makeSpaceForEdgeLabels",function(){L(q)}),Q(" removeSelfEdges",function(){W(q)}),Q(" acyclic",function(){t.run(q)}),Q(" nestingGraph.run",function(){c.run(q)}),Q(" rank",function(){i(y.asNonCompoundGraph(q))}),Q(" injectEdgeLabelProxies",function(){U(q)}),Q(" removeEmptyRanks",function(){u(q)}),Q(" nestingGraph.cleanup",function(){c.cleanup(q)}),Q(" normalizeRanks",function(){o(q)}),Q(" assignRankMinMax",function(){V(q)}),Q(" removeEdgeLabelProxies",function(){z(q)}),Q(" normalize.run",function(){r.run(q)}),Q(" parentDummyChains",function(){a(q)}),Q(" addBorderSegments",function(){f(q)}),Q(" order",function(){d(q)}),Q(" insertSelfEdges",function(){Z(q)}),Q(" adjustCoordinateSystem",function(){p.adjust(q)}),Q(" position",function(){g(q)}),Q(" positionSelfEdges",function(){I(q)}),Q(" removeBorderNodes",function(){J(q)}),Q(" normalize.undo",function(){r.undo(q)}),Q(" fixupEdgeLabelCoords",function(){$(q)}),Q(" undoCoordinateSystem",function(){p.undo(q)}),Q(" translateGraph",function(){C(q)}),Q(" assignNodeIntersects",function(){F(q)}),Q(" reversePoints",function(){re(q)}),Q(" acyclic.undo",function(){t.undo(q)})}function b(q,Q){e.forEach(q.nodes(),function(ne){var ae=q.node(ne),fe=Q.node(ne);ae&&(ae.x=fe.x,ae.y=fe.y,Q.children(ne).length&&(ae.width=fe.width,ae.height=fe.height))}),e.forEach(q.edges(),function(ne){var ae=q.edge(ne),fe=Q.edge(ne);ae.points=fe.points,e.has(fe,"x")&&(ae.x=fe.x,ae.y=fe.y)}),q.graph().width=Q.graph().width,q.graph().height=Q.graph().height}var S=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},N=["acyclicer","ranker","rankdir","align"],j=["width","height"],A={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],P={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},O=["labelpos"];function D(q){var Q=new w({multigraph:!0,compound:!0}),ne=K(q.graph());return Q.setGraph(e.merge({},k,G(ne,S),e.pick(ne,N))),e.forEach(q.nodes(),function(ae){var fe=K(q.node(ae));Q.setNode(ae,e.defaults(G(fe,j),A)),Q.setParent(ae,q.parent(ae))}),e.forEach(q.edges(),function(ae){var fe=K(q.edge(ae));Q.setEdge(ae,e.merge({},P,G(fe,M),e.pick(fe,O)))}),Q}function L(q){var Q=q.graph();Q.ranksep/=2,e.forEach(q.edges(),function(ne){var ae=q.edge(ne);ae.minlen*=2,ae.labelpos.toLowerCase()!=="c"&&(Q.rankdir==="TB"||Q.rankdir==="BT"?ae.width+=ae.labeloffset:ae.height+=ae.labeloffset)})}function U(q){e.forEach(q.edges(),function(Q){var ne=q.edge(Q);if(ne.width&&ne.height){var ae=q.node(Q.v),fe=q.node(Q.w),te={rank:(fe.rank-ae.rank)/2+ae.rank,e:Q};y.addDummyNode(q,"edge-proxy",te,"_ep")}})}function V(q){var Q=0;e.forEach(q.nodes(),function(ne){var ae=q.node(ne);ae.borderTop&&(ae.minRank=q.node(ae.borderTop).rank,ae.maxRank=q.node(ae.borderBottom).rank,Q=e.max(Q,ae.maxRank))}),q.graph().maxRank=Q}function z(q){e.forEach(q.nodes(),function(Q){var ne=q.node(Q);ne.dummy==="edge-proxy"&&(q.edge(ne.e).labelRank=ne.rank,q.removeNode(Q))})}function C(q){var Q=Number.POSITIVE_INFINITY,ne=0,ae=Number.POSITIVE_INFINITY,fe=0,te=q.graph(),ce=te.marginx||0,Ce=te.marginy||0;function ve(Re){var ye=Re.x,Ee=Re.y,Ye=Re.width,we=Re.height;Q=Math.min(Q,ye-Ye/2),ne=Math.max(ne,ye+Ye/2),ae=Math.min(ae,Ee-we/2),fe=Math.max(fe,Ee+we/2)}e.forEach(q.nodes(),function(Re){ve(q.node(Re))}),e.forEach(q.edges(),function(Re){var ye=q.edge(Re);e.has(ye,"x")&&ve(ye)}),Q-=ce,ae-=Ce,e.forEach(q.nodes(),function(Re){var ye=q.node(Re);ye.x-=Q,ye.y-=ae}),e.forEach(q.edges(),function(Re){var ye=q.edge(Re);e.forEach(ye.points,function(Ee){Ee.x-=Q,Ee.y-=ae}),e.has(ye,"x")&&(ye.x-=Q),e.has(ye,"y")&&(ye.y-=ae)}),te.width=ne-Q+ce,te.height=fe-ae+Ce}function F(q){e.forEach(q.edges(),function(Q){var ne=q.edge(Q),ae=q.node(Q.v),fe=q.node(Q.w),te,ce;ne.points?(te=ne.points[0],ce=ne.points[ne.points.length-1]):(ne.points=[],te=fe,ce=ae),ne.points.unshift(y.intersectRect(ae,te)),ne.points.push(y.intersectRect(fe,ce))})}function $(q){e.forEach(q.edges(),function(Q){var ne=q.edge(Q);if(e.has(ne,"x"))switch((ne.labelpos==="l"||ne.labelpos==="r")&&(ne.width-=ne.labeloffset),ne.labelpos){case"l":ne.x-=ne.width/2+ne.labeloffset;break;case"r":ne.x+=ne.width/2+ne.labeloffset;break}})}function re(q){e.forEach(q.edges(),function(Q){var ne=q.edge(Q);ne.reversed&&ne.points.reverse()})}function J(q){e.forEach(q.nodes(),function(Q){if(q.children(Q).length){var ne=q.node(Q),ae=q.node(ne.borderTop),fe=q.node(ne.borderBottom),te=q.node(e.last(ne.borderLeft)),ce=q.node(e.last(ne.borderRight));ne.width=Math.abs(ce.x-te.x),ne.height=Math.abs(fe.y-ae.y),ne.x=te.x+ne.width/2,ne.y=ae.y+ne.height/2}}),e.forEach(q.nodes(),function(Q){q.node(Q).dummy==="border"&&q.removeNode(Q)})}function W(q){e.forEach(q.edges(),function(Q){if(Q.v===Q.w){var ne=q.node(Q.v);ne.selfEdges||(ne.selfEdges=[]),ne.selfEdges.push({e:Q,label:q.edge(Q)}),q.removeEdge(Q)}})}function Z(q){var Q=y.buildLayerMatrix(q);e.forEach(Q,function(ne){var ae=0;e.forEach(ne,function(fe,te){var ce=q.node(fe);ce.order=te+ae,e.forEach(ce.selfEdges,function(Ce){y.addDummyNode(q,"selfedge",{width:Ce.label.width,height:Ce.label.height,rank:ce.rank,order:te+ ++ae,e:Ce.e,label:Ce.label},"_se")}),delete ce.selfEdges})})}function I(q){e.forEach(q.nodes(),function(Q){var ne=q.node(Q);if(ne.dummy==="selfedge"){var ae=q.node(ne.e.v),fe=ae.x+ae.width/2,te=ae.y,ce=ne.x-fe,Ce=ae.height/2;q.setEdge(ne.e,ne.label),q.removeNode(Q),ne.label.points=[{x:fe+2*ce/3,y:te-Ce},{x:fe+5*ce/6,y:te-Ce},{x:fe+ce,y:te},{x:fe+5*ce/6,y:te+Ce},{x:fe+2*ce/3,y:te+Ce}],ne.label.x=ne.x,ne.label.y=ne.y}})}function G(q,Q){return e.mapValues(e.pick(q,Q),Number)}function K(q){var Q={};return e.forEach(q,function(ne,ae){Q[ae.toLowerCase()]=ne}),Q}return pv}var mv,VE;function A5(){if(VE)return mv;VE=1;var e=at(),t=fn(),r=tr().Graph;mv={debugOrdering:i};function i(o){var a=t.buildLayerMatrix(o),u=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(c){u.setNode(c,{label:c}),u.setParent(c,"layer"+o.node(c).rank)}),e.forEach(o.edges(),function(c){u.setEdge(c.v,c.w,{},c.name)}),e.forEach(a,function(c,f){var p="layer"+f;u.setNode(p,{rank:"same"}),e.reduce(c,function(d,g){return u.setEdge(d,g,{style:"invis"}),g})}),u}return mv}var gv,GE;function I5(){return GE||(GE=1,gv="0.8.5"),gv}var vv,YE;function M5(){return YE||(YE=1,vv={graphlib:tr(),layout:R5(),debug:A5(),util:{time:fn().time,notime:fn().notime},version:I5()}),vv}var O5=M5();const KE=Wv(O5),yo=240,Iu=130,co=74,ic=72,XE=co+ic;function P5(e,t){var i;let r=yo;for(const o of e)r=Math.max(r,((i=t.get(o.id))==null?void 0:i.width)??yo);return r}const nT=420,L5=2;function ja(e){var r;return((r=e.data)==null?void 0:r.sessionId)??"_default"}function $5(e,t){return((t==null?void 0:t.get(e))??0)>0?nT:0}function q5(e,t){const r=(t==null?void 0:t.get(e))??0;return r>0?6+r*36:0}function Ta(e,t,r){const i=t.get(e);return{w:((i==null?void 0:i.width)??yo)+$5(e,r),h:Math.max((i==null?void 0:i.height)??Iu,q5(e,r))}}function D5(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function F5(e,t,r,i,o,a){const u=new KE.graphlib.Graph;u.setDefaultEdgeLabel(()=>({})),u.setGraph({rankdir:r,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(S=>!o.has(S)),f=new Set(c);for(const S of c){const{w:k,h:N}=Ta(S,i,a);u.setNode(S,{width:k,height:N})}for(const S of t)f.has(S.source)&&f.has(S.target)&&u.setEdge(S.source,S.target);KE.layout(u);const p=new Map;let d=1/0,g=1/0,y=-1/0,w=-1/0;for(const S of c){const k=u.node(S);if(!k)continue;const N=i.get(S),j=(N==null?void 0:N.width)??yo,A=(N==null?void 0:N.height)??Iu,M=Ta(S,i,a),P=k.x-M.w/2,O=k.y-M.h/2;p.set(S,{x:P,y:O}),P<d&&(d=P),O<g&&(g=O),P+j>y&&(y=P+j),O+A>w&&(w=O+A)}if(Number.isFinite(d)&&Number.isFinite(g))for(const[S,k]of p)p.set(S,{x:k.x-d,y:k.y-g});const E=Number.isFinite(y)?y-d:0,_=Number.isFinite(w)?w-g:0;let b=null;for(const S of e){const k=o.get(S);if(!k)continue;const N=i.get(S),j=(N==null?void 0:N.width)??yo,A=(N==null?void 0:N.height)??Iu;b=b===null?{minX:k.x,minY:k.y,maxX:k.x+j,maxY:k.y+A}:{minX:Math.min(b.minX,k.x),minY:Math.min(b.minY,k.y),maxX:Math.max(b.maxX,k.x+j),maxY:Math.max(b.maxY,k.y+A)}}return{positions:p,width:E,height:_,pinnedBox:b}}function z5(e,t,r={}){const i=r.direction??"LR",o=r.pinned??new Map,a=r.measured??new Map,u=r.lanes,c=new Map;for(const S of e){const k=ja(S),N=c.get(k);N?N.push(S.id):c.set(k,[S.id])}const p=Array.from(c.keys()).sort().map(S=>({sid:S,...F5(c.get(S),t,i,a,o,u)})),d=P5(e,a),g=r.availableHeight&&r.availableHeight>0?r.availableHeight:Number.POSITIVE_INFINITY,y=S=>{const k=[[]];let N=0;for(const j of p)k.length<S&&N>0&&N+j.height>g&&(k.push([]),N=0),k[k.length-1].push(j),N+=j.height+XE;return k},w=S=>S.reduce((k,N)=>Math.max(k,N.width),0)+nT;let E=y(r.availableWidth?L5:1);E.length>1&&E.reduce((k,N)=>k+w(N),0)+d*(E.length-1)>(r.availableWidth??0)&&(E=y(1));const _=new Map;let b=0;for(const S of E){const k=w(S);let N=0;for(const{positions:j,height:A,pinnedBox:M}of S){for(const[O,D]of j)_.set(O,{x:D.x+b,y:D.y+N});let P=N+A;M&&M.maxY>P&&M.minX<b+k&&b<M.maxX&&(P=M.maxY),N=P+XE}b+=k+d}return e.map(S=>{const k=o.get(S.id);if(k)return{...S,position:k};const N=_.get(S.id);return N?{...S,position:N}:S})}function B5(e,t,r,i,o){const u=co+ic,c=60,f=w=>Ta(w,i,o),p=new Map(e.map(w=>[w.id,ja(w)])),d=[],g=e.map(w=>({id:w.id,pos:r.get(w.id)??t.get(w.id)})).filter(w=>w.pos!=null).sort((w,E)=>w.pos.y-E.pos.y||w.pos.x-E.pos.x||w.id.localeCompare(E.id)),y=[];for(const{id:w,pos:E}of g){const{w:_,h:b}=f(w),S=p.get(w)??"_default";if(r.has(w)){d.push({x:E.x,y:E.y,w:_,h:b,sid:S});continue}let k=E.y;for(let N=0;N<d.length+1;N++){const j=d.find(A=>{const M=A.sid===S?24:c,P=A.sid===S?24:u;return E.x<A.x+A.w+M&&A.x<E.x+_+M&&k<A.y+A.h+P&&A.y<k+b+P});if(!j)break;k=j.y+j.h+(j.sid===S?24:u)}k!==E.y&&(t.set(w,{x:E.x,y:k}),y.push(w)),d.push({x:E.x,y:k,w:_,h:b,sid:S})}return y}function U5(e,t,r,i,o,a){const u=_=>Ta(_,i,a),c=_=>r.get(_)??t.get(_),f=new Map;for(const _ of e){if(!c(_.id))continue;const b=ja(_),S=f.get(b);S?S.push(_):f.set(b,[_])}const p=new Set;for(const[_,b]of f)b.every(S=>o.has(S.id)&&!r.has(S.id))&&p.add(_);const d=new Map,g=[];for(const _ of e){const b=c(_.id);if(!b)continue;const{w:S,h:k}=u(_.id),N=ja(_);p.has(N)?(d.get(N)??d.set(N,[]).get(N)).push(_):g.push({x:b.x,y:b.y,w:S,h:k})}if(d.size===0)return[];const y=co+ic,w=(_,b,S,k)=>g.some(N=>_<N.x+N.w+co&&N.x<_+S+co&&b<N.y+N.h+y&&N.y<b+k+y),E=[];for(const _ of[...d.keys()].sort()){const b=d.get(_);let S=1/0,k=1/0,N=-1/0,j=-1/0;for(const U of b){const V=c(U.id),{w:z,h:C}=u(U.id);S=Math.min(S,V.x),k=Math.min(k,V.y),N=Math.max(N,V.x+z),j=Math.max(j,V.y+C)}const A=N-S,M=j-k,P=[...new Set(g.map(U=>Math.round(U.x)))].sort((U,V)=>U-V),O=P.length?P:[S],D=[0,...g.map(U=>U.y+U.h+y)].sort((U,V)=>U-V);let L=null;e:for(const U of O)for(const V of D){if(V>=k)break;if(!w(U,V,A,M)){L={x:U,y:V};break e}}if(L){const U=L.x-S,V=L.y-k;for(const z of b){const C=c(z.id);t.set(z.id,{x:C.x+U,y:C.y+V})}E.push(_)}for(const U of b){const V=c(U.id),{w:z,h:C}=u(U.id);g.push({x:V.x,y:V.y,w:z,h:C})}}return E}function H5(e,t,r,i,o,a=!1,u){const p=co+ic+1,d=8,g=1.75,y=200,w=.7,E=.01,_=L=>Ta(L,i,u),b=L=>r.get(L)??t.get(L),S=new Map;for(const L of e){if(!b(L.id))continue;const U=ja(L),V=S.get(U);V?V.push(L):S.set(U,[L])}const k=[],N=new Set,j=new Set,A=o.size===0;for(const L of[...S.keys()].sort()){const U=S.get(L);let V=1/0,z=1/0,C=-1/0,F=-1/0,$=!1;for(const Z of U){const I=b(Z.id),{w:G,h:K}=_(Z.id);V=Math.min(V,I.x),z=Math.min(z,I.y),C=Math.max(C,I.x+G),F=Math.max(F,I.y+K),r.has(Z.id)&&($=!0)}const re=C-V,J=F-z;j.add(L);const W=o.get(L);W&&(re>W.w+d||J>W.h+d)&&N.add(L),o.set(L,{w:re,h:J}),k.push({sid:L,members:U.map(Z=>Z.id),x:V,y:z,w:re,h:J,anchored:$,mass:1})}for(const L of[...o.keys()])j.has(L)||o.delete(L);if(a||A)return[];let M=!1;for(let L=0;L<k.length&&!M;L++)for(let U=L+1;U<k.length;U++){const V=k[L],z=k[U];if(!(V.anchored&&z.anchored)&&Math.abs(V.x+V.w/2-(z.x+z.w/2))<(V.w+z.w)/2+61&&Math.abs(V.y+V.h/2-(z.y+z.h/2))<(V.h+z.h)/2+p){M=!0;break}}if(N.size===0&&!M)return[];if(N.size>0)for(const L of k)N.has(L.sid)&&(L.mass=8);else for(const L of k)L.mass=Math.max(1,L.w*L.h/(yo*Iu));const P=new Map(k.map(L=>[L.sid,L.x])),O=new Map(k.map(L=>[L.sid,L.y]));for(let L=0;L<y;L++){const U=new Map,V=new Map;let z=0;for(let C=0;C<k.length;C++)for(let F=C+1;F<k.length;F++){const $=k[C],re=k[F];if($.anchored&&re.anchored)continue;const J=$.x+$.w/2,W=$.y+$.h/2,Z=re.x+re.w/2,I=re.y+re.h/2,G=($.w+re.w)/2+61-Math.abs(J-Z),K=($.h+re.h)/2+p-Math.abs(W-I);if(G<=0||K<=0)continue;const q=(De,Je)=>!De.anchored&&!(Je<0&&De.x<=0),Q=(De,Je)=>!De.anchored&&!(Je<0&&De.y<=0),ne=(De,Je,Xe)=>{const Ot=De===Je,lt=Ot?$.sid<re.sid?-1:1:Math.sign(De-Je);return Xe($,lt)||Xe(re,-lt)?lt:Ot&&(Xe($,-lt)||Xe(re,lt))?-lt:0},ae=ne(J,Z,q),fe=ne(W,I,Q),te=ae!==0,ce=fe!==0;if(!te&&!ce)continue;const Ce=te&&(!ce||G*g<K),[ve,Re,ye,Ee]=Ce?[ae,G,U,q]:[fe,K,V,Q],Ye=Ee($,ve),we=Ee(re,-ve),_e=$.mass,Be=re.mass,it=Ye?we?Be/(_e+Be):1:0,ft=we?Ye?_e/(_e+Be):1:0,Ze=Re*w;ye.set($.sid,(ye.get($.sid)??0)+ve*Ze*it),ye.set(re.sid,(ye.get(re.sid)??0)-ve*Ze*ft),z+=Ze}for(const C of k)C.anchored||(C.x=Math.max(0,C.x+(U.get(C.sid)??0)),C.y=Math.max(0,C.y+(V.get(C.sid)??0)));if(z<E)break}const D=[];for(const L of k){const U=L.x-P.get(L.sid),V=L.y-O.get(L.sid);if(!(Math.abs(U)<1&&Math.abs(V)<1)){for(const z of L.members){if(r.has(z))continue;const C=t.get(z);C&&t.set(z,{x:C.x+U,y:C.y+V})}D.push(L.sid)}}return D}const W5=600;function zv(e,t){return!(e.exitAt!=null&&t-e.exitAt>W5||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function V5(e,t){const r=new Set;for(const i of e.agents.values())zv(i,t)&&r.add(i.id);return r}function G5(e,t,r=0){return e.right+r>t.left&&e.left-r<t.right&&e.bottom+r>t.top&&e.top-r<t.bottom}function Y5(e,t,r=0){if(!e)return!1;for(const i of t)if(G5(e,i,r))return!0;return!1}const rT="sessionGroup";function K5(e,t){var i;if(e.type===rT)return"transparent";const r=(i=e.data)==null?void 0:i.state;return t(r==="err"?"--err":r==="active"?"--inflight":"--ok")}const X5="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1).";function Q5(e){if(e.checkDisabled)return X5;if(e.checking)return"Asking npm for the newest release…";const t=e.latest?`npm has v${e.latest}`:e.latestPending?`npm's latest tag names v${e.latestPending}, which it cannot serve yet`:"npm not reached yet",r=e.checkedAgo?` · checked ${e.checkedAgo}`:"";return`${t}${r} · re-checked periodically · click to check npm now`}function Z5(e){const t=`Version v${e.running}`;return e.checkDisabled?`${t}, update checks are off`:e.checking?`${t}, checking npm for a newer release`:`${t}, check npm for a newer release`}function J5(e){const t=e.kind==="restart"?`v${e.to} is installed and waiting for a restart`:`v${e.to} is available on npm`;return`Version v${e.from}, ${t} — ${e.open?"hide":"show"} the notice`}function eF(e){if(e==null)return{kind:"unknown",lead:"No data yet. Start a Claude Code or Codex session — it appears here as soon as the deck sees its first event.",workspace:null,tail:""};const t=e.trim();return t===""?{kind:"machine",lead:"No data yet. Start a Claude Code or Codex session anywhere on this machine — this deck is unscoped and captures every workspace.",workspace:null,tail:""}:{kind:"scoped",lead:"No data yet. This deck only captures sessions running under",workspace:t,tail:" — start one there, or restart it without --workspace/--scope to watch the whole machine."}}const Bv={kind:"assumed",claude:!0,codex:!0};function tF(e){if(!e||typeof e!="object")return Bv;const t=e.providers;if(!t||typeof t!="object")return Bv;const r=t;return{kind:"reported",claude:r.claude!==!1,codex:r.codex!==!1}}function sT(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}function nF(e){return e.connected?e.paused?{tone:"paused",label:"paused",title:e.held>0?`Connected — ${sT(e.held)} held until you resume (Space)`:"Connected — updates held until you resume (Space)"}:{tone:"live",label:"live",title:"Receiving events"}:{tone:"dead",label:"offline",title:e.paused?"SSE disconnected — and the canvas is paused, so resuming will not bring events back until it reconnects":"SSE disconnected"}}function rF(e){return e.paused?e.held<=0?{label:"Resume",title:"Nothing has arrived since you paused. Resume to follow the canvas again (Space)"}:{label:`Resume · ${e.held} held`,title:`${sT(e.held)} arrived while paused and will be applied in order when you resume (Space)`}:{label:"Pause",title:"Pause live updates — events keep arriving and are applied when you resume (Space)"}}function iT(e,t){return e!==""&&t>0}function sF(e,t,r){return e===""?{active:!1,matched:t,total:r,count:null,empty:!1,message:null,dim:!1}:{active:!0,matched:t,total:r,count:`${t} of ${r}`,empty:t===0,message:t===0?`No agents match “${e}”`:null,dim:iT(e,t)}}const iF="Search agents, tools, model…";function oT(e,t){var i,o,a,u;if(!t)return!0;const r=t.toLowerCase();if(e.label.toLowerCase().includes(r)||(i=e.cwd)!=null&&i.toLowerCase().includes(r)||(o=e.cwdBasename)!=null&&o.toLowerCase().includes(r)||e.sessionId.toLowerCase().includes(r)||(a=e.firstPrompt)!=null&&a.toLowerCase().includes(r)||e.model&&(e.model.toLowerCase().includes(r)||Rs(e.model).toLowerCase().includes(r))||(u=e.provider)!=null&&u.toLowerCase().startsWith(r))return!0;for(const c of e.tools)if(c.name.toLowerCase().includes(r))return!0;return!1}function fa(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const oF={agent:_L,sessionGroup:ML},aT="react-flow__node";function QE(e){var t,r;return!!e&&((r=(t=e.classList)==null?void 0:t.contains)==null?void 0:r.call(t,aT))===!0}function aF(e){try{const t=document.querySelector(`.${aT}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}const lF=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),uF=420,du=18,cF=200,dF=5*6e4,fF=6,hF=2*6e4,Py="agent-dag.layout",Ly="agent-dag.viewport",lT="agent-dag.summariesDismissed",uT="agent-dag.sessionListOpen",cT="agent-dag.detailOpen",dT="agent-dag.usagePanelOpen",ZE="agent-dag.accountsPanelOpen",JE="agent-dag.versionNoticeDismissed",eN="agent-dag.oldNameNoticeDismissed",pF=15*6e4,yv={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:"},tN="agent-dag.autoRestart",nN="agent-dag.bundleReloadedFor";function mF(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(uT)==="1"}catch{return!1}}function gF(e){if(!(typeof window>"u"))try{window.localStorage.setItem(uT,e?"1":"0")}catch{}}function vF(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(cT)==="1"}catch{return!1}}function yF(e){if(!(typeof window>"u"))try{window.localStorage.setItem(cT,e?"1":"0")}catch{}}function wF(){const e=py(dT);return e===null?!0:e==="1"}function xF(e){if(!(typeof window>"u"))try{window.localStorage.setItem(dT,e?"1":"0")}catch{}}function _F(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(lT);if(!e)return new Set;const t=JSON.parse(e);return new Set(Array.isArray(t)?t.filter(r=>typeof r=="string"):[])}catch{return new Set}}function rN(e){if(!(typeof window>"u"))try{const t=Array.from(e),r=t.length>200?t.slice(-200):t;window.localStorage.setItem(lT,JSON.stringify(r))}catch{}}function bF(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const t=window.localStorage.getItem(Py);if(!t)return e;const r=JSON.parse(t);if(!("v"in r)){const o=Object.entries(r).filter(([,a])=>a&&typeof a.x=="number"&&typeof a.y=="number");return{positions:o,pins:o.map(([a])=>a)}}return{positions:Object.entries(r.positions??{}).filter(([,o])=>o&&typeof o.x=="number"&&typeof o.y=="number"),pins:Array.isArray(r.pins)?r.pins:[]}}catch{return e}}function wv(e,t){if(!(typeof window>"u"))try{const r={};for(const[i,o]of e)r[i]=o;for(const[i,o]of t)r[i]=o;window.localStorage.setItem(Py,JSON.stringify({v:2,positions:r,pins:Array.from(t.keys())}))}catch{}}function SF(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Ly);if(!e)return null;const t=JSON.parse(e);return typeof(t==null?void 0:t.x)!="number"||typeof(t==null?void 0:t.y)!="number"||typeof(t==null?void 0:t.zoom)!="number"?null:t}catch{return null}}function kF(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Ly,JSON.stringify(e))}catch{}}function sN(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Py)}catch{}try{window.localStorage.removeItem(Ly)}catch{}}}function EF(e,t){const r=e.agents.get(t);if(!r)return;const i=[];for(const d of e.agents.values())d.sessionId===t&&i.push(d);const o={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:t,label:r.label,cwd:r.cwd,startedAt:r.startedAt,endedAt:r.endedAt,model:r.model,agents:i.map(d=>({id:d.id,kind:d.kind,label:d.label,parentId:d.parentId,state:d.state,startedAt:d.startedAt,endedAt:d.endedAt,model:d.model,cwd:d.cwd,usage:d.usage,prompts:d.prompts,tools:d.tools.map(g=>({id:g.id,name:g.name,inputPreview:g.inputPreview,startedAt:g.startedAt,endedAt:g.endedAt,ok:g.ok,errorPreview:g.errorPreview,usage:g.usage}))}))},a=JSON.stringify(o,null,2),u=new Blob([a],{type:"application/json"}),c=URL.createObjectURL(u),f=document.createElement("a"),p=(r.label||"session").replace(/[^a-z0-9._-]/gi,"_");f.href=c,f.download=`${Gt}-${p}-${t.slice(0,8)}.json`,document.body.appendChild(f),f.click(),document.body.removeChild(f),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const Uv={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Hv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},fT=BC;function NF(e,t){if(!t)return null;const r=new Set([t]);let i=t;for(;i;){const a=e.agents.get(i);if(!(a!=null&&a.parentId)||r.has(a.parentId))break;r.add(a.parentId),i=a.parentId}let o=!0;for(;o;){o=!1;for(const a of e.agents.values())a.parentId&&r.has(a.parentId)&&!r.has(a.id)&&(r.add(a.id),o=!0)}return r}function CF(e,t,r,i,o,a,u,c,f,p,d,g,y,w,E,_,b,S,k){const N=[],j=[],A=new Set;if(a)for(const z of e.agents.values())S.has(z.id)&&oT(z,a)&&A.add(z.id);const M=iT(a,A.size);for(const z of e.agents.values()){if(!S.has(z.id))continue;const C=M&&!A.has(z.id),F=z.exitAt!=null,$=b!=null&&!b.has(z.id),re=[C?"rf-dim":"",F?"rf-exiting":"",$?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,J=u.get(z.id);if(N.push({id:z.id,type:"agent",position:{x:0,y:0},data:{...z,now:t,onOpenContext:k},className:re,...J?{width:J.width,height:J.height}:null}),z.parentId&&S.has(z.parentId)){const W=uy(z.sessionId),Z=a&&!A.has(z.id)&&!A.has(z.parentId),I=F,G=_.size>0&&(_.has(z.id)||_.has(z.parentId)),K=b!=null&&!b.has(z.id)&&!b.has(z.parentId),q=z.state==="active"?2:1.5,Q=G?q+1.5:q,ne=Z||I?.2:K?.12:1,ae=["sess-edge",z.state==="active"?"sess-live":"sess-idle",I?"rf-edge-exiting":"",G?"rf-edge-selected":""].filter(Boolean).join(" ");j.push({id:`e:${z.parentId}->${z.id}`,source:z.parentId,target:z.id,animated:(z.state==="active"||G)&&!Z&&!I,type:"smoothstep",style:{"--session-hue":W,strokeWidth:Q,opacity:ne,transition:"var(--edge-transition)"},className:ae})}}const P=new Map;for(const z of e.agents.values())z.tools.length>0&&P.set(z.id,Math.min(4,z.tools.length));const O=`${w}#lanes:${D5(P)}`,D=N.filter(z=>H3(z.id,o,g,y));if(D.length>0||O!==E.current){if(D.length>0){const z=z5(N,j,{direction:"LR",pinned:o,measured:u,availableWidth:r,availableHeight:i,lanes:P});for(const C of z)JC(C.id,g,y)&&V3(C.id,C.position,g,y);U5(N,g,o,u,new Set(D.map(C=>C.id)),P)}B5(N,g,o,u,P),E.current=O}const L=H5(N,g,o,u,c,!p||d,P);L.length>0&&f(L),au(g,e.agents),au(y,e.agents),au(o,e.agents),au(u,U3(e.agents.values()));const U=[];let V=!1;for(const z of N){let C=o.get(z.id)??g.get(z.id);C||(C=W3(z.id,g,y),V=!0),U.push({...z,position:C})}return V&&(E.current=""),{nodes:U,edges:j}}function jF(){return m.jsx(ly,{children:m.jsx(TF,{})})}function TF(){var Xa,Qa,Za,Ja;const e=Oa(),t=R.useRef(Lv()),[,r]=R.useState(0),i=R.useCallback(()=>r(H=>H+1),[]),[o,a]=R.useState(()=>new Set),[u,c]=R.useState(null),[f,p]=R.useState(null),d=R.useCallback((H,Y)=>{a(oe=>{if(!Y)return new Set([H]);const de=new Set(oe);return de.has(H)?de.delete(H):de.add(H),de}),c(oe=>Y&&oe===H?oe:H)},[]),g=R.useCallback(()=>{a(new Set),c(null)},[]),[y,w]=R.useState(null),[E,_]=R.useState(null),b=R.useCallback(H=>_(H),[]),[S,k]=R.useState(!1),N=R.useRef(_F()),[j,A]=R.useState(mF);R.useEffect(()=>{gF(j)},[j]);const[M,P]=R.useState(vF);R.useEffect(()=>{yF(M)},[M]);const[O,D]=R.useState(wF);R.useEffect(()=>{xF(O)},[O]);const[L,U]=R.useState(()=>{try{const H=window.localStorage.getItem(ZE);return H===null?!0:H==="1"}catch{return!0}});R.useEffect(()=>{try{window.localStorage.setItem(ZE,L?"1":"0")}catch{}},[L]);const[V,z]=R.useState(null),[C,F]=R.useState(!1),[$,re]=R.useState(0),[J,W]=R.useState(0);R.useEffect(()=>{fetch("/api/sound-hook").then(H=>H.ok?H.json():null).then(H=>{H!=null&&H.ok&&(z(H.enabled===!0),re((H.foreign??[]).filter(Y=>Y.worksHere).length),W(typeof H.parked=="number"?H.parked:0))}).catch(()=>{})},[]);const Z=R.useCallback(async()=>{F(!0);try{const Y=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!V})})).json().catch(()=>null);Y!=null&&Y.ok&&z(Y.enabled===!0),fetch("/api/sound-hook").then(oe=>oe.ok?oe.json():null).then(oe=>{oe!=null&&oe.ok&&(re((oe.foreign??[]).filter(de=>de.worksHere).length),W(typeof oe.parked=="number"?oe.parked:0))}).catch(()=>{})}catch{}finally{F(!1)}},[V]),[I,G]=R.useState(!1),[K,q]=R.useState(null),[Q,ne]=R.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(JE)??""}catch{return""}}),[ae,fe]=R.useState(!1),te=R.useRef(0),[ce,Ce]=R.useState(!1),ve=R.useCallback((H=!1)=>{H&&(te.current=Date.now(),Ce(!0)),fetch(H?"/api/version?refresh=1":"/api/version").then(Y=>Y.ok?Y.json():null).then(Y=>{Y&&q(Y)}).catch(()=>{}).finally(()=>{H&&Ce(!1)})},[]),Re=R.useCallback(()=>{ve(Date.now()-te.current>=pF)},[ve]);R.useEffect(()=>{ve();const H=window.setInterval(Re,5*6e4),Y=()=>{document.visibilityState==="visible"&&Re()};return document.addEventListener("visibilitychange",Y),()=>{window.clearInterval(H),document.removeEventListener("visibilitychange",Y)}},[ve,Re]),R.useEffect(()=>{I&&ve()},[I,ve]);const ye=(K==null?void 0:K.notice)??null,[Ee,Ye]=R.useState(null),[we,_e]=R.useState(Bv);R.useEffect(()=>{let H=!1;return fetch("/api/health").then(Y=>Y.ok?Y.json():null).then(Y=>{H||(_e(tF(Y)),!(!Y||typeof Y.workspace!="string")&&Ye(Y.workspace))}).catch(()=>{}),()=>{H=!0}},[I]);const Be=R.useRef(we);Be.current=we;const it=ye?`${ye.kind}:${ye.to}`:"",ft=ye!=null&&Q!==it,Ze=R.useCallback(()=>{if(!ye)return;const H=Q===it?"":it;ne(H);try{window.localStorage.setItem(JE,H)}catch{}},[ye,it,Q]),[De,Je]=R.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(eN)??""}catch{return""}}),Xe=K!=null&&K.invokedAs&&K.invokedAs!==Gt?K.invokedAs:null,Ot=Xe!=null&&De!==Xe,lt=R.useCallback(()=>{if(Xe){Je(Xe);try{window.localStorage.setItem(eN,Xe)}catch{}}},[Xe]),Qe=((Xa=K==null?void 0:K.upgrade)==null?void 0:Xa.state)??"idle",Pt=I3(K==null?void 0:K.upgrade),zt=R.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}ve()},[ve]);R.useEffect(()=>{if(Qe!=="running")return;const H=window.setInterval(ve,3e3);return()=>window.clearInterval(H)},[Qe,ve]);const et=R.useCallback(async()=>{var oe;const H=K==null?void 0:K.command;if(!H)return;let Y=!1;try{Y=await Promise.race([((oe=navigator.clipboard)==null?void 0:oe.writeText(H).then(()=>!0))??Promise.resolve(!1),new Promise(de=>window.setTimeout(()=>de(!1),500))])}catch{Y=!1}if(!Y)try{const de=document.createElement("textarea");de.value=H,de.setAttribute("readonly",""),de.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(de),de.select(),Y=document.execCommand("copy"),de.remove()}catch{Y=!1}Y&&(fe(!0),window.setTimeout(()=>fe(!1),1600))},[K==null?void 0:K.command]),bt=R.useCallback(()=>{A(H=>(H||U(!1),!H))},[]),ht=R.useCallback(()=>{U(H=>(H||A(!1),!H))},[]),[vt,hn]=R.useState(!1),[Yt,Lt]=R.useState(0),bn=R.useRef(null),[gr,Sn]=R.useState(!1),Bt=R.useRef(null),[Fn,pn]=R.useState(0),vr=R.useRef(X3()),[Hr,xi]=R.useState(!1),Wr=R.useCallback(()=>{const H=vr.current,Y=H.setPaused(!H.paused);for(const oe of Y)t.current=Qx(t.current,oe);xi(H.paused)},[]),[ut,_i]=R.useState(Date.now()),[mn,Is]=R.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(tN)!=="0"}catch{return!0}}),yr=R.useCallback(()=>{Is(H=>{const Y=!H;try{window.localStorage.setItem(tN,Y?"1":"0")}catch{}return Y})},[]),[zn,kn]=R.useState(!1),[Vr,Gr]=R.useState("restart"),[Yr,bi]=R.useState(null),sr=R.useRef(!1),Ms=R.useRef(null),En=R.useRef(0),wr=R.useCallback(async H=>{if(sr.current)return;const Y=(H==null?void 0:H.upgrade)===!0;sr.current=!0,Ms.current=Pt;const oe=++En.current;Gr(Y?"npx":"restart"),kn(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(ye==null?void 0:ye.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:Y})})}catch{}window.setTimeout(()=>{if(En.current===oe&&sr.current){sr.current=!1,kn(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},Y?18e4:3e4)},[ye==null?void 0:ye.to,Pt]),Os=R.useRef(null);R.useEffect(()=>{let H=!1;for(const oe of t.current.agents.values())if(oe.state==="active"){H=!0;break}const Y=O3({enabled:mn,kind:ye==null?void 0:ye.kind,canRestart:(K==null?void 0:K.canRestart)===!0,busy:H,idleSince:Os.current,now:ut});Os.current=Y.idleSince,Y.restart&&wr()},[mn,ye==null?void 0:ye.kind,K==null?void 0:K.canRestart,ut,wr]),R.useEffect(()=>{const H=K==null?void 0:K.running;let Y=null,oe=null;try{Y=window.sessionStorage.getItem("agent-dag.restartPending"),oe=window.sessionStorage.getItem(nN)}catch{return}const de=A3({bundle:"1.36.2",running:H,pending:Y,lastTried:oe});if(de==="reload"){try{window.sessionStorage.setItem(nN,H??"")}catch{return}window.location.reload();return}if(de!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}sr.current=!1,kn(!1),bi(H??null);const xe=window.setTimeout(()=>bi(null),6e3);return()=>window.clearTimeout(xe)},[K==null?void 0:K.running]),R.useEffect(()=>{if(zn&&M3({asked:Ms.current,reported:Pt})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}sr.current=!1,kn(!1)}},[zn,Pt]);const Ps=R.useRef(bF()).current;R.useRef(!1);const Tt=R.useRef(new Map(Ps.positions.filter(([H])=>Ps.pins.includes(H)))),xr=R.useRef(null),_r=R.useState(()=>SF())[0],[Kt,Kr]=R.useState(""),[Si,nt]=R.useState(()=>new Set),[br,Xr]=R.useState(Z3),[Ls,Qr]=R.useState(!1),Zr=R.useRef(null);R.useEffect(()=>{document.documentElement.dataset.theme=br;try{window.localStorage.setItem(ej,br)}catch{}},[br]),R.useEffect(()=>{if(!_r)return;const H=window.setTimeout(()=>{try{e.setViewport(_r,{duration:0})}catch{}},60);return()=>window.clearTimeout(H)},[e,_r]);const $s=R.useRef(!0);R.useEffect(()=>{const H=new EventSource("/events"),Y=K3(i,{now:()=>Date.now(),setTimeout:(oe,de)=>window.setTimeout(oe,de),clearTimeout:oe=>window.clearTimeout(oe)});return H.addEventListener("open",()=>{G(!0),Qr(!0)}),H.addEventListener("error",()=>G(!1)),H.addEventListener("replay-end",()=>{$s.current=!1,Y.flush()}),H.addEventListener("hook",oe=>{try{const de=JSON.parse(oe.data);if(!vr.current.accept(de))return;t.current=Qx(t.current,de),de.replay===!0||$s.current||Date.now()-de.receivedAt>3e4?Y.replay():Y.live()}catch{}}),()=>{H.close(),Y.cancel()}},[i]),R.useEffect(()=>{const H=setInterval(()=>{const Y=Date.now();_i(Y);let oe=DP(t.current,Y,Xx);FP(t.current,Y,Xx)&&(oe=!0),$P(t.current,Y,cF,dF)&&(oe=!0),qP(t.current,Y,fF,hF)&&(oe=!0),oe&&i()},250);return()=>clearInterval(H)},[i]);const ir=R.useRef(null),St=R.useRef(0),qs=420,pt=R.useCallback((H=500)=>{try{const Se=document.querySelector(".canvas-wrap"),Pe=Array.from(document.querySelectorAll(".react-flow__node")).filter(wt=>wt.offsetWidth>0);if(!Se||Pe.length===0)return;const Fe=Se.getBoundingClientRect(),Ge=e.getViewport();if(!Number.isFinite(Ge.zoom)||Ge.zoom<=0)return;const We=wt=>(wt-Fe.left-Ge.x)/Ge.zoom,ze=wt=>(wt-Fe.top-Ge.y)/Ge.zoom,jn=Pe.map(wt=>wt.getBoundingClientRect()),Ys=Math.min(...jn.map(wt=>We(wt.left))),Io=Math.max(...jn.map(wt=>We(wt.right))),Ks=Math.min(...jn.map(wt=>ze(wt.top))),Mo=Math.max(...jn.map(wt=>ze(wt.bottom))),el=Io-Ys,us=Mo-Ks;if(!(el>0&&us>0))return;const Zt=Math.max(.2,Math.min(1,(Fe.width-160)/(el+qs)*.86,(Fe.height-160)/us*.86));e.setViewport({x:80-Ys*Zt,y:Math.max(80,(Fe.height-us*Zt)/2)-Ks*Zt,zoom:Zt},{duration:H}),St.current=Date.now(),window.setTimeout(()=>{try{const wt={x:80-Ys*Zt,y:Math.max(80,(Fe.height-us*Zt)/2)-Ks*Zt,zoom:Zt},Oo=e.getViewport();(Math.abs(Oo.zoom-Zt)>.01||Math.abs(Oo.x-wt.x)>2)&&e.setViewport(wt,{duration:0})}catch{}},H+60)}catch{}},[e]),Eo=R.useRef(""),No=R.useRef(null),Ba=R.useRef(0),Sr=R.useCallback(()=>{Ba.current=Date.now()},[]),Jr="agent-dag.autoFitDisabled",gn=R.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Jr)==="1"}catch{return!1}})()),[Ds,Ua]=R.useState(gn.current),Ha=R.useCallback(()=>{if(!gn.current){gn.current=!0,Ua(!0);try{window.localStorage.setItem(Jr,"1")}catch{}}},[]),Co=R.useCallback(()=>{gn.current=!1,Ua(!1);try{window.localStorage.removeItem(Jr)}catch{}pt(400)},[e,pt]);R.useEffect(()=>{const H=setInterval(()=>{if(gn.current||Date.now()-Ba.current<800)return;const Y=t.current,oe=Date.now(),de=[];for(const We of Y.agents.values())zv(We,oe)&&de.push({id:We.id});if(de.length===0)return;const xe=e.getViewport(),Se=window.innerWidth-360,Pe=window.innerHeight-52;let Fe=!1,Ge=!1;for(const{id:We}of de){const ze=or.current.get(We),jn=Tt.current.get(We)??Xt.current.get(We);if(!ze||!jn)continue;Ge=!0;const Ys=jn.x*xe.zoom+xe.x,Io=jn.y*xe.zoom+xe.y,Ks=(jn.x+ze.width)*xe.zoom+xe.x,Mo=(jn.y+ze.height)*xe.zoom+xe.y;if(Ks>0&&Ys<Se&&Mo>0&&Io<Pe){Fe=!0;break}}Ge&&!Fe&&pt(600)},1500);return()=>clearInterval(H)},[e]);const ki=R.useRef(!1),or=R.useRef(new Map),es=R.useRef(0),oc=R.useCallback(H=>{const Y=or.current;let oe=!1;for(const de of H.nodeInternals.values()){const xe=de.width,Se=de.height;if(xe==null||Se==null)continue;const Pe=Y.get(de.id);Pe?(Math.abs(Pe.height-Se)>4||Math.abs(Pe.width-xe)>4)&&(Y.set(de.id,{width:xe,height:Se}),oe=!0):(Y.set(de.id,{width:xe,height:Se}),oe=!0)}return oe&&(es.current+=1),es.current},[]),Ei=Ke(oc),[He,Wa]=R.useState(0);R.useEffect(()=>{let H=0;const Y=()=>{const de=or.current;let xe=!1;for(const Se of document.querySelectorAll(".react-flow__node[data-id]")){const Pe=Se.getAttribute("data-id");if(!Pe)continue;const Fe=Se.offsetWidth,Ge=Se.offsetHeight;if(!Fe||!Ge)continue;const We=de.get(Pe);(!We||Math.abs(We.width-Fe)>4||Math.abs(We.height-Ge)>4)&&(de.set(Pe,{width:Fe,height:Ge}),xe=!0)}xe&&Wa(Se=>Se+1)};if(ki.current)return;let oe=0;return document.visibilityState==="hidden"?oe=window.setTimeout(Y,32):H=requestAnimationFrame(Y),()=>{cancelAnimationFrame(H),window.clearTimeout(oe)}});const Xt=R.useRef(new Map(Ps.positions)),jo=R.useRef(new Set),Ni=R.useRef(""),kr=R.useMemo(()=>{const H=[];for(const Y of t.current.agents.values())zv(Y,ut)&&H.push(Y.id+(Y.parentId?`>${Y.parentId}`:""));return H.sort(),`${H.join("|")}#sv${Ei}.${He}`},[t.current,t.current.lastSeq,ut,Ei,He]),ts=R.useRef(null);R.useEffect(()=>(ts.current!=null&&window.clearTimeout(ts.current),ts.current=window.setTimeout(()=>{wv(Xt.current,Tt.current)},1500),()=>{ts.current!=null&&window.clearTimeout(ts.current)}),[kr]),R.useEffect(()=>{if(Eo.current===kr)return;const H=Eo.current;if(Eo.current=kr,!H||gn.current)return;Date.now()-St.current>1200&&pt(400),ir.current&&window.clearTimeout(ir.current),ir.current=window.setTimeout(()=>{gn.current||pt(500)},280)},[kr,e,pt]);const Fs=R.useMemo(()=>{if(o.size===0)return null;const H=new Set;for(const Y of o){const oe=NF(t.current,Y);if(oe)for(const de of oe)H.add(de)}return H.size>0?H:null},[t.current,t.current.lastSeq,o]),Nn=R.useMemo(()=>V5(t.current,ut),[t.current,t.current.lastSeq,ut]),Bn=R.useRef(null),[vn,Un]=R.useState({w:0,h:0});R.useEffect(()=>{const H=Bn.current;if(!H||typeof ResizeObserver>"u")return;const Y=new ResizeObserver(oe=>{var xe;const de=(xe=oe[0])==null?void 0:xe.contentRect;de&&Un(Se=>Math.abs(Se.w-de.width)>40||Math.abs(Se.h-de.height)>40?{w:de.width,h:de.height}:Se)});return Y.observe(H),Un({w:H.clientWidth,h:H.clientHeight}),()=>Y.disconnect()},[]);const zs=R.useCallback(H=>{var oe,de;const Y=H.target;!(Y!=null&&Y.closest)||Y.closest(lF)!==H.currentTarget||(H.preventDefault(),(de=(oe=document.activeElement)==null?void 0:oe.blur)==null||de.call(oe))},[]),Bs=R.useRef(new Map),[Hn,ac]=R.useState(!1);R.useEffect(()=>{const H=window.setTimeout(()=>ac(!0),2500);return()=>window.clearTimeout(H)},[]);const[Va,Er]=R.useState(!1),ar=R.useRef(null),[Ci,Us]=R.useState(!1),Ga=R.useCallback(()=>{ar.current&&(window.clearTimeout(ar.current),ar.current=null),Er(!1)},[]),lc=R.useCallback(H=>{H.length!==0&&queueMicrotask(()=>{Er(!0),ar.current&&window.clearTimeout(ar.current),ar.current=window.setTimeout(()=>Er(!1),uF+80)})},[]);R.useEffect(()=>()=>{ar.current&&window.clearTimeout(ar.current)},[]);const ns=vn.w>0?vn.w*.92:0,rs=vn.h>0?vn.h:0,{nodes:Qt,edges:ji}=R.useMemo(()=>CF(t.current,ut,ns,rs,Tt.current,Kt,or.current,Bs.current,lc,Hn,Ci,Xt.current,jo.current,kr,Ni,o,Fs,Nn,b),[t.current,t.current.lastSeq,ut,ns,rs,Hn,Ci,Kt,kr,o,Fs,Nn,b,Yt]),Ya=R.useMemo(()=>{const H=new Map;for(const oe of Qt){const de=oe.data;if(!(de!=null&&de.sessionId)||de.exitAt!=null)continue;const xe=oe.width,Se=oe.height;if(xe==null||Se==null)continue;const Pe=oe.position.x,Fe=oe.position.y,Ge=Pe+xe,We=Fe+Se,ze=H.get(de.sessionId);ze?(ze.minX=Math.min(ze.minX,Pe),ze.minY=Math.min(ze.minY,Fe),ze.maxX=Math.max(ze.maxX,Ge),ze.maxY=Math.max(ze.maxY,We)):H.set(de.sessionId,{minX:Pe,minY:Fe,maxX:Ge,maxY:We})}const Y=[];for(const[oe,de]of H){const xe=de.maxX-de.minX+du*2,Se=de.maxY-de.minY+du*2;Y.push({id:`group:${oe}`,type:rT,position:{x:de.minX-du,y:de.minY-du},data:{sessionId:oe,w:xe,h:Se},width:xe,height:Se,style:{width:xe,height:Se},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return Y},[Qt,ut]),uc=R.useMemo(()=>{const H=[...Ya,...Qt],Y=Bt.current;return!Y||Y.size===0?H:H.map(oe=>{const de=Y.get(oe.id);return de?{...oe,position:de}:oe})},[Ya,Qt,Fn]),Nr=R.useMemo(()=>{if(!Kt)return null;const H=new Set;for(const Y of t.current.agents.values())Nn.has(Y.id)&&oT(Y,Kt)&&H.add(Y.id);return H},[t.current,t.current.lastSeq,Kt,Nn]),Cn=R.useMemo(()=>sF(Kt,(Nr==null?void 0:Nr.size)??0,Nn.size),[Kt,Nr,Nn]),ss=R.useMemo(()=>{const H=new Set;for(const Y of t.current.agents.values())for(const oe of Y.tools)H.add(fT(oe.name));return Object.keys(Uv).filter(Y=>H.has(Y))},[t.current,t.current.lastSeq]);R.useEffect(()=>{if(ss.length<=1){Sn(!1);return}let H=0;const Y=()=>{const oe=bn.current;if(oe&&!document.hidden){const de=oe.getBoundingClientRect(),xe=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Pe=>Pe.getBoundingClientRect()),Se=Y5(de,xe,8);Sn(Pe=>Pe===Se?Pe:Se)}H=window.setTimeout(Y,300)};return Y(),()=>window.clearTimeout(H)},[ss.length]);const is=R.useMemo(()=>{const H=new Map;for(const oe of t.current.agents.values())for(const de of oe.tools){if(!de.name.startsWith("mcp__"))continue;const xe=de.name.slice(5),Se=xe.indexOf("__"),Pe=Se>0?xe.slice(0,Se):xe;H.set(Pe,(H.get(Pe)??0)+1)}const Y=[];for(const[oe,de]of H){let xe=5381;for(let Se=0;Se<oe.length;Se++)xe=(xe<<5)+xe^oe.charCodeAt(Se);Y.push({server:oe,count:de,hue:Math.abs(xe)%360})}return Y.sort((oe,de)=>de.count-oe.count),Y},[t.current,t.current.lastSeq]),lr=R.useCallback(H=>{nt(Y=>{const oe=new Set(Y);return oe.has(H)?oe.delete(H):oe.add(H),oe})},[]),Rt=u?t.current.agents.get(u):null,os=f?Array.from(t.current.agents.values()).flatMap(H=>H.tools).find(H=>H.id===f)??null:null,To=R.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}t.current=Lv(),Tt.current.clear(),or.current.clear(),Xt.current.clear(),Ni.current="",sN(),g(),i()},[i,g]),Hs=R.useRef(S);Hs.current=S;const Ws=R.useRef(!1);Ws.current=os!=null||vt||E!=null||y!=null;const Vs=R.useCallback(H=>{const Y=L3(H,{confirmOpen:Hs.current,modalOpen:Ws.current});Y==="confirm"?k(!0):Y==="clear"&&(k(!1),To())},[To]),$t=R.useCallback(()=>{Tt.current.clear(),Xt.current.clear(),Ni.current="",sN(),i(),window.setTimeout(()=>pt(500),80)},[i,e,pt]),Cr=R.useCallback(()=>pt(500),[pt]),as=R.useRef(Qt);as.current=Qt;const ls=R.useRef(u);ls.current=u;const Ro=R.useCallback(H=>{const Y=as.current,oe=q3(Y.map(Se=>({id:Se.id,x:Se.position.x,y:Se.position.y})),ls.current,H),de=oe?Y.find(Se=>Se.id===oe):void 0;if(!de)return;const xe=QE(document.activeElement);d(de.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[de]})}catch{}St.current=Date.now(),xe&&aF(de.id)},30)},[d,e]),Ti=R.useCallback(H=>{d(H,!1),window.setTimeout(()=>{try{const Y=as.current.find(oe=>oe.id===H);Y&&e.fitView({padding:.3,duration:500,nodes:[Y]}),St.current=Date.now()}catch{}},60)},[d,e]);R.useEffect(()=>{const H=Y=>{var Fe,Ge,We;const oe=Y.target,de={tagName:oe==null?void 0:oe.tagName,isContentEditable:oe==null?void 0:oe.isContentEditable,role:(Fe=oe==null?void 0:oe.getAttribute)==null?void 0:Fe.call(oe,"role"),type:oe==null?void 0:oe.type};if(Y.key==="Escape"){const ze=iL({overlayOpen:Ru.depth()>0,typing:cy(de)});ze==="dismiss"?Ru.dismissTop():ze==="blur"?oe==null||oe.blur():(B3(de)&&(oe==null||oe.blur()),g());return}if(DC(Y))return;const xe=QE(oe)?(Ge=oe==null?void 0:oe.getAttribute)==null?void 0:Ge.call(oe,"data-id"):null,Se=xe&&as.current.some(ze=>ze.id===xe)?xe:null,Pe=F3(Y,Se);if(Pe.kind==="activate"){Y.preventDefault(),d(Pe.nodeId,Pe.additive);return}if(Pe.kind!=="node"&&!(Pe.nodeId==null&&hL(de))){if(Y.key==="/"){Y.preventDefault(),(We=Zr.current)==null||We.focus();return}Y.key===" "&&(Y.preventDefault(),Wr()),(Y.key==="c"||Y.key==="C")&&Vs("shortcut"),(Y.key==="r"||Y.key==="R")&&$t(),(Y.key==="f"||Y.key==="F")&&Cr(),(Y.key==="l"||Y.key==="L")&&bt(),(Y.key==="h"||Y.key==="H")&&hn(ze=>!ze),(Y.key==="u"||Y.key==="U")&&D(ze=>!ze),(Y.key==="a"||Y.key==="A")&&Be.current.claude&&ht(),(Y.key==="j"||Y.key==="J")&&Ro(1),(Y.key==="k"||Y.key==="K")&&Ro(-1),(Y.key==="t"||Y.key==="T")&&Xr(ze=>ze==="dark"?"light":"dark")}};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[Vs,$t,Cr,g,d,Ro,Wr]);const jr=t.current.agents.size,Gs=new Set(Array.from(t.current.agents.values()).map(H=>H.sessionId)).size,tn=R.useMemo(()=>g$(t.current.agents.values()),[t.current,t.current.lastSeq]),Ao=R.useMemo(()=>v$(t.current.agents.values()),[t.current,t.current.lastSeq]),Ka=R.useRef(null);R.useEffect(()=>{const H=J3({waiting:tn.length,running:Ao}),Y=Ka.current;if(Ka.current=H,(Y==null?void 0:Y.title)!==H.title&&(document.title=H.title),(Y==null?void 0:Y.icon)!==H.icon){const oe=document.querySelector('link[rel="icon"]');oe&&(oe.href=eq[H.icon])}},[tn.length,Ao]);const[cc,dc]=R.useState(""),Ri=nq(tn);R.useEffect(()=>{dc(H=>rq(H,Ri))},[Ri]);const nn=R.useMemo(()=>{let H=0,Y=0,oe=0,de=0,xe=0,Se=0,Pe=0,Fe=0,Ge=0;for(const We of t.current.agents.values()){H+=We.usage.inputTokens,Y+=We.usage.outputTokens,oe+=We.usage.cacheReadTokens,de+=We.usage.cacheCreateTokens;const ze=dn(We.usage,We.model);xe+=ze.total,Se+=ze.input,Pe+=ze.output,Fe+=ze.cacheRead,Ge+=ze.cacheWrite}return{inT:H,outT:Y,cacheR:oe,cacheC:de,sum:H+Y,cost:{total:xe,input:Se,output:Pe,cacheRead:Fe,cacheWrite:Ge}}},[t.current,t.current.lastSeq]);return m.jsxs("div",{className:"app",children:[m.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),m.jsxs("header",{className:"topbar",children:[m.jsxs("div",{className:"brand",children:[m.jsx("span",{className:"logo"}),m.jsx("h1",{children:Gt}),ye?m.jsxs("button",{type:"button",className:"v stale",onClick:Ze,"aria-label":J5({...ye,open:ft}),title:ye.kind==="restart"?`Running v${ye.from}; v${ye.to} is installed on disk. Restart to pick it up.`:`Running v${ye.from}; v${ye.to} is on npm.`,children:["v",ye.from,m.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const H={running:(K==null?void 0:K.running)??"1.36.2",latest:K==null?void 0:K.latest,latestPending:K==null?void 0:K.latestPending,checkedAgo:K!=null&&K.checkedAt?qv(ut-K.checkedAt):null,checkDisabled:K==null?void 0:K.checkDisabled,checking:ce};return m.jsxs("button",{type:"button",className:ce?"v checking":"v",onClick:()=>ve(!0),"aria-busy":ce||void 0,"aria-label":Z5(H),title:Q5(H),children:["v",H.running]})})()]}),Rt&&(()=>{const H=dn(Rt.usage,Rt.model),Y=Math.max(0,((Rt.endedAt??ut)-Rt.startedAt)/1e3),oe=Rt.state==="active"?ju(H.total,Y):null,de=o.size-1;return m.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${Rt.label}`,onClick:()=>{try{const xe=Qt.find(Se=>Se.id===Rt.id);xe&&e.fitView({padding:.35,duration:500,nodes:[xe]}),St.current=Date.now()}catch{}},children:[m.jsx("span",{className:`state-pill state-${Rt.state}`,children:Rt.state==="active"?"live":Rt.state}),m.jsx("span",{className:"selected-label",children:Rt.label}),H.total>0&&m.jsxs("span",{className:"selected-cost",children:[qe(H.total),oe?m.jsxs("span",{className:"selected-rate",children:[" · ",oe]}):null]}),de>0&&m.jsxs("span",{className:"selected-extra",children:["+",de]}),m.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:xe=>{xe.stopPropagation(),g()},children:"×"})]})})(),m.jsxs("div",{className:"actions",children:[m.jsxs("div",{className:"search",children:[m.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),m.jsx("input",{ref:Zr,type:"text",placeholder:iF,value:Kt,onChange:H=>Kr(H.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),Kt?m.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>Kr(""),children:"×"}):m.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"}),Cn.count&&m.jsx("span",{className:`search-count${Cn.empty?" none":""}`,"aria-live":"polite",title:`${Cn.count} agents on the canvas match “${Kt}”`,children:Cn.count})]}),m.jsxs("span",{className:"status",children:[(()=>{const H=nF({connected:I,paused:Hr,held:vr.current.size});return m.jsx("span",{className:`pill ${H.tone}`,title:H.title,children:H.label})})(),m.jsxs("span",{className:"stat",title:cq(we),children:[m.jsx("span",{className:"count",children:Gs}),m.jsx("span",{className:"lbl",children:"sessions"})]}),m.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[m.jsx("span",{className:"count",children:jr}),m.jsx("span",{className:"lbl",children:"agents"})]}),m.jsxs("span",{className:"stat",title:dq(we),children:[m.jsx("span",{className:"count",children:t.current.totalEvents}),m.jsx("span",{className:"lbl",children:"events"})]}),m.jsx(F$,{usageOpen:O}),nn.sum>0&&m.jsxs("span",{className:"stat",title:`in:${nn.inT.toLocaleString()} out:${nn.outT.toLocaleString()} cache-r:${nn.cacheR.toLocaleString()} cache-c:${nn.cacheC.toLocaleString()}`,children:[m.jsx("span",{className:"count",children:Nt(nn.sum)}),m.jsx("span",{className:"lbl",children:"tokens"})]}),is.length>0&&m.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
|
|
73
|
+
${t.parked} of your own sound hook${t.parked>1?"s were":" was"} set aside so this switch actually controls the sound. Nothing was deleted — shift-click to put ${t.parked>1?"them":"it"} back.`:"";return r+i+o+a}function nj(e){const t=new Map;for(const r of e)for(const i of r.agents??[]){if(!i||typeof i.agent!="string"||i.agent==="")continue;const o=t.get(i.agent)??{id:i.agent,cost:0,tokens:0};o.cost+=Number.isFinite(i.totalCost)?i.totalCost:0,o.tokens+=Number.isFinite(i.totalTokens)?i.totalTokens:0,t.set(i.agent,o)}return[...t.values()].sort((r,i)=>i.cost-r.cost||r.id.localeCompare(i.id))}function pq(e){const t=nj([{agents:e}]);return t.length<2?null:t.map(r=>`${gy(r.id)} ${qe(r.cost)}`).join(" · ")}function j_(e){switch(e.toLowerCase()){case"claude":return"#c4b5fd";case"codex":return"#fdba74";case"gemini":return"#a5b4fc";case"copilot":return"#86efac";default:return"#94a3b8"}}function mq(e,t){if(!(t>0)||!(e>0))return"0%";const r=e/t*100;return r<.1?"<0.1%":`${r.toFixed(1)}%`}function lu(e){const t=e.toLowerCase();return t.includes("opus")?"#c4b5fd":t.includes("sonnet")?"#7dd3fc":t.includes("haiku")?"#86efac":t.includes("gpt-5")||t.includes("gpt5")?"#fcd34d":t.includes("gpt")?"#fca5a5":t.includes("gemini")?"#a5b4fc":t.includes("codex")?"#fdba74":"#94a3b8"}const gq=[7,14,30,90];function vq(e){const[t,r]=R.useState(null),[i,o]=R.useState(!1),a=R.useRef(sq()).current,u=(c=!1)=>{const f=a.begin(),p=e;o(!0);const g=`/api/ccusage?since=${iq(p)}${c?"&refresh=1":""}`;fetch(g).then(y=>y.json()).then(y=>{f()&&r({range:p,resp:y})}).catch(()=>{f()&&r({range:p,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{f()&&o(!1)})};return R.useEffect(()=>(u(!1),()=>a.cancel()),[e]),{landed:t,loading:i,reload:()=>u(!0)}}function yq({onClose:e,providers:t}){var P;const[r,i]=R.useState(30),[o,a]=R.useState(null),{landed:u,loading:c,reload:f}=vq(r),p=R.useRef(null),d=wo(e,{focusRef:p}),g=oq({loading:c,want:r,answer:u&&{range:u.range,ok:u.resp.ok===!0,days:((P=u.resp.days)==null?void 0:P.length)??0}}),y=g.phase==="chart"?u.resp.days??[]:[],w=R.useMemo(()=>y.reduce((O,D)=>Math.max(O,D.totalCost),0),[y]),{totalCost:E,totalTok:_,inOut:b,cacheRead:S,modelCosts:k}=R.useMemo(()=>{let O=0,D=0,L=0,U=0;const V=new Map;for(const z of y){O+=z.totalCost,D+=z.totalTokens,L+=z.inputTokens+z.outputTokens,U+=z.cacheReadTokens;for(const C of z.modelBreakdowns)V.set(C.modelName,(V.get(C.modelName)??0)+C.cost)}return{totalCost:O,totalTok:D,inOut:L,cacheRead:U,modelCosts:V}},[y]),N=R.useMemo(()=>Array.from(k.entries()).sort((O,D)=>D[1]-O[1]),[k]),j=R.useMemo(()=>nj(y),[y]),A=j.length>1,M=o?y.find(O=>O.period===o)??null:null;return m.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:m.jsxs("div",{ref:d,className:"uh-modal",onClick:O=>O.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Usage history",children:[m.jsxs("header",{className:"uh-head",children:[m.jsxs("div",{className:"uh-titlewrap",children:[m.jsx("div",{className:"uh-title",children:"Usage history"}),m.jsx("div",{className:"uh-sub",children:lq(t,j.map(O=>O.id))})]}),m.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:gq.map(O=>m.jsxs("button",{type:"button","aria-pressed":r===O,className:`uh-range-btn${r===O?" on":""}`,onClick:()=>{i(O),a(null)},children:[O,"d"]},O))}),m.jsx("button",{className:"btn icon-btn uh-reload",onClick:f,disabled:c,title:"Re-run ccusage","aria-label":"Reload",children:c?"…":"↻"}),m.jsx("button",{ref:p,className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),g.phase==="busy"?m.jsx("div",{className:"uh-status","aria-busy":"true",children:u?"running ccusage…":"running ccusage… (first run downloads the package)"}):g.phase==="error"?m.jsxs("div",{className:"uh-status uh-err",title:vo(u.resp)||void 0,children:[u$(u.resp,"ccusage did not report usage"),m.jsx("div",{children:m.jsx("button",{className:"btn uh-retry",onClick:f,disabled:c,children:c?"trying…":"Try again"})})]}):g.phase==="empty"?m.jsx("div",{className:`uh-status${g.stale?" uh-stale":""}`,"aria-busy":g.stale||void 0,children:"no usage in this range"}):m.jsxs("div",{className:g.stale?"uh-stale":void 0,"aria-busy":g.stale||void 0,children:[m.jsxs("div",{className:"uh-totals",children:[m.jsx(uu,{label:"total cost",val:qe(E),accent:!0}),m.jsx(uu,{label:"tokens",val:Nt(_)}),m.jsx(uu,{label:"input+output",val:Nt(b)}),m.jsx(uu,{label:"cache reads",val:Nt(S)})]}),A&&m.jsxs("div",{className:"uh-agents",role:"group","aria-label":"Cost by CLI",children:[m.jsx("div",{className:"uh-agent-bar","aria-hidden":"true",children:j.map(O=>m.jsx("span",{className:"uh-agent-seg",style:{width:`${E>0?O.cost/E*100:0}%`,background:j_(O.id)}},O.id))}),m.jsx("div",{className:"uh-agent-keys",children:j.map(O=>m.jsxs("span",{className:"uh-agent-key",title:`${O.id} · ${Nt(O.tokens)} tokens`,children:[m.jsx("span",{className:"uh-legend-dot",style:{background:j_(O.id)}}),gy(O.id),m.jsx("span",{className:"uh-agent-cost",children:qe(O.cost)}),m.jsx("span",{className:"uh-agent-share",children:mq(O.cost,E)})]},O.id))})]}),m.jsx("div",{className:"uh-chart",role:"group","aria-label":"Daily cost by model",children:y.map(O=>{const D=w>0?O.totalCost/w*100:0,L=O.period===o,U=`${O.period}, ${qe(O.totalCost)}`;return m.jsxs("button",{className:`uh-bar-col${L?" sel":""}`,onClick:()=>a(L?null:O.period),"aria-pressed":L,"aria-label":U,title:`${O.period} · ${qe(O.totalCost)}`,style:{flexBasis:`${100/y.length}%`},children:[m.jsx("div",{className:"uh-bar",style:{height:`${Math.max(D,O.totalCost>0?2:0)}%`},children:O.modelBreakdowns.slice().sort((V,z)=>z.cost-V.cost).map(V=>{const z=O.totalCost>0?V.cost/O.totalCost*100:0;return m.jsx("div",{className:"uh-bar-seg",style:{height:`${z}%`,background:lu(V.modelName)}},V.modelName)})}),m.jsx("span",{className:"uh-bar-label",children:O.period.slice(5)})]},O.period)})}),m.jsx("div",{className:"uh-legend",children:N.map(([O,D])=>m.jsxs("span",{className:"uh-legend-item",title:O,children:[m.jsx("span",{className:"uh-legend-dot",style:{background:lu(O)}}),Rs(O)," ",m.jsx("span",{className:"uh-legend-cost",children:qe(D)})]},O))}),M&&m.jsxs("div",{className:"uh-detail",children:[m.jsxs("div",{className:"uh-detail-head",children:[m.jsx("span",{className:"uh-detail-date",children:M.period}),m.jsx("span",{className:"uh-detail-cost",children:qe(M.totalCost)}),(()=>{var L,U;const D=pq(M.agents)??((U=(L=M.metadata)==null?void 0:L.agents)!=null&&U.length?M.metadata.agents.join(" · "):null);return D?m.jsx("span",{className:"uh-detail-agents",title:D,children:D}):null})()]}),m.jsxs("div",{className:"uh-detail-mini",children:[m.jsx(cu,{label:"input",val:Nt(M.inputTokens)}),m.jsx(cu,{label:"output",val:Nt(M.outputTokens)}),m.jsx(cu,{label:"cache write",val:Nt(M.cacheCreationTokens)}),m.jsx(cu,{label:"cache read",val:Nt(M.cacheReadTokens)})]}),m.jsx("div",{className:"uh-detail-models",children:M.modelBreakdowns.slice().sort((O,D)=>D.cost-O.cost).map(O=>{const D=M.totalCost>0?O.cost/M.totalCost*100:0;return m.jsxs("div",{className:"uh-model-row",title:O.modelName,children:[m.jsxs("span",{className:"uh-model-name",children:[m.jsx("span",{className:"uh-legend-dot",style:{background:lu(O.modelName)}}),m.jsx("span",{className:"uh-model-label",children:Rs(O.modelName)})]}),m.jsx("span",{className:"uh-model-bar",children:m.jsx("span",{className:"uh-model-bar-fill",style:{width:`${D}%`,background:lu(O.modelName)}})}),m.jsx("span",{className:"uh-model-cost",children:qe(O.cost)})]},O.modelName)})})]})]})]})})}function uu({label:e,val:t,accent:r}){return m.jsxs("div",{className:"uh-stat",children:[m.jsx("span",{className:`uh-stat-val${r?" accent":""}`,children:t}),m.jsx("span",{className:"uh-stat-label",children:e})]})}function cu({label:e,val:t}){return m.jsxs("div",{className:"uh-ministat",children:[m.jsx("span",{className:"uh-ministat-val",children:t}),m.jsx("span",{className:"uh-ministat-label",children:e})]})}function vy(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 ef,T_;function wq(){if(T_)return ef;T_=1;function e(){this.__data__=[],this.size=0}return ef=e,ef}var tf,R_;function xo(){if(R_)return tf;R_=1;function e(t,r){return t===r||t!==t&&r!==r}return tf=e,tf}var nf,A_;function Bu(){if(A_)return nf;A_=1;var e=xo();function t(r,i){for(var o=r.length;o--;)if(e(r[o][0],i))return o;return-1}return nf=t,nf}var rf,I_;function xq(){if(I_)return rf;I_=1;var e=Bu(),t=Array.prototype,r=t.splice;function i(o){var a=this.__data__,u=e(a,o);if(u<0)return!1;var c=a.length-1;return u==c?a.pop():r.call(a,u,1),--this.size,!0}return rf=i,rf}var sf,M_;function _q(){if(M_)return sf;M_=1;var e=Bu();function t(r){var i=this.__data__,o=e(i,r);return o<0?void 0:i[o][1]}return sf=t,sf}var of,O_;function bq(){if(O_)return of;O_=1;var e=Bu();function t(r){return e(this.__data__,r)>-1}return of=t,of}var af,P_;function Sq(){if(P_)return af;P_=1;var e=Bu();function t(r,i){var o=this.__data__,a=e(o,r);return a<0?(++this.size,o.push([r,i])):o[a][1]=i,this}return af=t,af}var lf,L_;function Uu(){if(L_)return lf;L_=1;var e=wq(),t=xq(),r=_q(),i=bq(),o=Sq();function a(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var p=u[c];this.set(p[0],p[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=i,a.prototype.set=o,lf=a,lf}var uf,$_;function kq(){if($_)return uf;$_=1;var e=Uu();function t(){this.__data__=new e,this.size=0}return uf=t,uf}var cf,q_;function Eq(){if(q_)return cf;q_=1;function e(t){var r=this.__data__,i=r.delete(t);return this.size=r.size,i}return cf=e,cf}var df,D_;function Nq(){if(D_)return df;D_=1;function e(t){return this.__data__.get(t)}return df=e,df}var ff,F_;function Cq(){if(F_)return ff;F_=1;function e(t){return this.__data__.has(t)}return ff=e,ff}var hf,z_;function rj(){if(z_)return hf;z_=1;var e=typeof Gl=="object"&&Gl&&Gl.Object===Object&&Gl;return hf=e,hf}var pf,B_;function rr(){if(B_)return pf;B_=1;var e=rj(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return pf=r,pf}var mf,U_;function _o(){if(U_)return mf;U_=1;var e=rr(),t=e.Symbol;return mf=t,mf}var gf,H_;function jq(){if(H_)return gf;H_=1;var e=_o(),t=Object.prototype,r=t.hasOwnProperty,i=t.toString,o=e?e.toStringTag:void 0;function a(u){var c=r.call(u,o),f=u[o];try{u[o]=void 0;var p=!0}catch{}var d=i.call(u);return p&&(c?u[o]=f:delete u[o]),d}return gf=a,gf}var vf,W_;function Tq(){if(W_)return vf;W_=1;var e=Object.prototype,t=e.toString;function r(i){return t.call(i)}return vf=r,vf}var yf,V_;function gi(){if(V_)return yf;V_=1;var e=_o(),t=jq(),r=Tq(),i="[object Null]",o="[object Undefined]",a=e?e.toStringTag:void 0;function u(c){return c==null?c===void 0?o:i:a&&a in Object(c)?t(c):r(c)}return yf=u,yf}var wf,G_;function qn(){if(G_)return wf;G_=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return wf=e,wf}var xf,Y_;function $a(){if(Y_)return xf;Y_=1;var e=gi(),t=qn(),r="[object AsyncFunction]",i="[object Function]",o="[object GeneratorFunction]",a="[object Proxy]";function u(c){if(!t(c))return!1;var f=e(c);return f==i||f==o||f==r||f==a}return xf=u,xf}var _f,K_;function Rq(){if(K_)return _f;K_=1;var e=rr(),t=e["__core-js_shared__"];return _f=t,_f}var bf,X_;function Aq(){if(X_)return bf;X_=1;var e=Rq(),t=(function(){var i=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""})();function r(i){return!!t&&t in i}return bf=r,bf}var Sf,Q_;function sj(){if(Q_)return Sf;Q_=1;var e=Function.prototype,t=e.toString;function r(i){if(i!=null){try{return t.call(i)}catch{}try{return i+""}catch{}}return""}return Sf=r,Sf}var kf,Z_;function Iq(){if(Z_)return kf;Z_=1;var e=$a(),t=Aq(),r=qn(),i=sj(),o=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,f=u.toString,p=c.hasOwnProperty,d=RegExp("^"+f.call(p).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function g(y){if(!r(y)||t(y))return!1;var w=e(y)?d:a;return w.test(i(y))}return kf=g,kf}var Ef,J_;function Mq(){if(J_)return Ef;J_=1;function e(t,r){return t==null?void 0:t[r]}return Ef=e,Ef}var Nf,e1;function vi(){if(e1)return Nf;e1=1;var e=Iq(),t=Mq();function r(i,o){var a=t(i,o);return e(a)?a:void 0}return Nf=r,Nf}var Cf,t1;function yy(){if(t1)return Cf;t1=1;var e=vi(),t=rr(),r=e(t,"Map");return Cf=r,Cf}var jf,n1;function Hu(){if(n1)return jf;n1=1;var e=vi(),t=e(Object,"create");return jf=t,jf}var Tf,r1;function Oq(){if(r1)return Tf;r1=1;var e=Hu();function t(){this.__data__=e?e(null):{},this.size=0}return Tf=t,Tf}var Rf,s1;function Pq(){if(s1)return Rf;s1=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return Rf=e,Rf}var Af,i1;function Lq(){if(i1)return Af;i1=1;var e=Hu(),t="__lodash_hash_undefined__",r=Object.prototype,i=r.hasOwnProperty;function o(a){var u=this.__data__;if(e){var c=u[a];return c===t?void 0:c}return i.call(u,a)?u[a]:void 0}return Af=o,Af}var If,o1;function $q(){if(o1)return If;o1=1;var e=Hu(),t=Object.prototype,r=t.hasOwnProperty;function i(o){var a=this.__data__;return e?a[o]!==void 0:r.call(a,o)}return If=i,If}var Mf,a1;function qq(){if(a1)return Mf;a1=1;var e=Hu(),t="__lodash_hash_undefined__";function r(i,o){var a=this.__data__;return this.size+=this.has(i)?0:1,a[i]=e&&o===void 0?t:o,this}return Mf=r,Mf}var Of,l1;function Dq(){if(l1)return Of;l1=1;var e=Oq(),t=Pq(),r=Lq(),i=$q(),o=qq();function a(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var p=u[c];this.set(p[0],p[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=i,a.prototype.set=o,Of=a,Of}var Pf,u1;function Fq(){if(u1)return Pf;u1=1;var e=Dq(),t=Uu(),r=yy();function i(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return Pf=i,Pf}var Lf,c1;function zq(){if(c1)return Lf;c1=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return Lf=e,Lf}var $f,d1;function Wu(){if(d1)return $f;d1=1;var e=zq();function t(r,i){var o=r.__data__;return e(i)?o[typeof i=="string"?"string":"hash"]:o.map}return $f=t,$f}var qf,f1;function Bq(){if(f1)return qf;f1=1;var e=Wu();function t(r){var i=e(this,r).delete(r);return this.size-=i?1:0,i}return qf=t,qf}var Df,h1;function Uq(){if(h1)return Df;h1=1;var e=Wu();function t(r){return e(this,r).get(r)}return Df=t,Df}var Ff,p1;function Hq(){if(p1)return Ff;p1=1;var e=Wu();function t(r){return e(this,r).has(r)}return Ff=t,Ff}var zf,m1;function Wq(){if(m1)return zf;m1=1;var e=Wu();function t(r,i){var o=e(this,r),a=o.size;return o.set(r,i),this.size+=o.size==a?0:1,this}return zf=t,zf}var Bf,g1;function wy(){if(g1)return Bf;g1=1;var e=Fq(),t=Bq(),r=Uq(),i=Hq(),o=Wq();function a(u){var c=-1,f=u==null?0:u.length;for(this.clear();++c<f;){var p=u[c];this.set(p[0],p[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=i,a.prototype.set=o,Bf=a,Bf}var Uf,v1;function Vq(){if(v1)return Uf;v1=1;var e=Uu(),t=yy(),r=wy(),i=200;function o(a,u){var c=this.__data__;if(c instanceof e){var f=c.__data__;if(!t||f.length<i-1)return f.push([a,u]),this.size=++c.size,this;c=this.__data__=new r(f)}return c.set(a,u),this.size=c.size,this}return Uf=o,Uf}var Hf,y1;function Vu(){if(y1)return Hf;y1=1;var e=Uu(),t=kq(),r=Eq(),i=Nq(),o=Cq(),a=Vq();function u(c){var f=this.__data__=new e(c);this.size=f.size}return u.prototype.clear=t,u.prototype.delete=r,u.prototype.get=i,u.prototype.has=o,u.prototype.set=a,Hf=u,Hf}var Wf,w1;function xy(){if(w1)return Wf;w1=1;function e(t,r){for(var i=-1,o=t==null?0:t.length;++i<o&&r(t[i],i,t)!==!1;);return t}return Wf=e,Wf}var Vf,x1;function ij(){if(x1)return Vf;x1=1;var e=vi(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return Vf=t,Vf}var Gf,_1;function Gu(){if(_1)return Gf;_1=1;var e=ij();function t(r,i,o){i=="__proto__"&&e?e(r,i,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[i]=o}return Gf=t,Gf}var Yf,b1;function Yu(){if(b1)return Yf;b1=1;var e=Gu(),t=xo(),r=Object.prototype,i=r.hasOwnProperty;function o(a,u,c){var f=a[u];(!(i.call(a,u)&&t(f,c))||c===void 0&&!(u in a))&&e(a,u,c)}return Yf=o,Yf}var Kf,S1;function qa(){if(S1)return Kf;S1=1;var e=Yu(),t=Gu();function r(i,o,a,u){var c=!a;a||(a={});for(var f=-1,p=o.length;++f<p;){var d=o[f],g=u?u(a[d],i[d],d,a,i):void 0;g===void 0&&(g=i[d]),c?t(a,d,g):e(a,d,g)}return a}return Kf=r,Kf}var Xf,k1;function Gq(){if(k1)return Xf;k1=1;function e(t,r){for(var i=-1,o=Array(t);++i<t;)o[i]=r(i);return o}return Xf=e,Xf}var Qf,E1;function mr(){if(E1)return Qf;E1=1;function e(t){return t!=null&&typeof t=="object"}return Qf=e,Qf}var Zf,N1;function Yq(){if(N1)return Zf;N1=1;var e=gi(),t=mr(),r="[object Arguments]";function i(o){return t(o)&&e(o)==r}return Zf=i,Zf}var Jf,C1;function Da(){if(C1)return Jf;C1=1;var e=Yq(),t=mr(),r=Object.prototype,i=r.hasOwnProperty,o=r.propertyIsEnumerable,a=e((function(){return arguments})())?e:function(u){return t(u)&&i.call(u,"callee")&&!o.call(u,"callee")};return Jf=a,Jf}var eh,j1;function _t(){if(j1)return eh;j1=1;var e=Array.isArray;return eh=e,eh}var ma={exports:{}},th,T1;function Kq(){if(T1)return th;T1=1;function e(){return!1}return th=e,th}ma.exports;var R1;function bo(){return R1||(R1=1,(function(e,t){var r=rr(),i=Kq(),o=t&&!t.nodeType&&t,a=o&&!0&&e&&!e.nodeType&&e,u=a&&a.exports===o,c=u?r.Buffer:void 0,f=c?c.isBuffer:void 0,p=f||i;e.exports=p})(ma,ma.exports)),ma.exports}var nh,A1;function Ku(){if(A1)return nh;A1=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(i,o){var a=typeof i;return o=o??e,!!o&&(a=="number"||a!="symbol"&&t.test(i))&&i>-1&&i%1==0&&i<o}return nh=r,nh}var rh,I1;function _y(){if(I1)return rh;I1=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return rh=t,rh}var sh,M1;function Xq(){if(M1)return sh;M1=1;var e=gi(),t=_y(),r=mr(),i="[object Arguments]",o="[object Array]",a="[object Boolean]",u="[object Date]",c="[object Error]",f="[object Function]",p="[object Map]",d="[object Number]",g="[object Object]",y="[object RegExp]",w="[object Set]",E="[object String]",_="[object WeakMap]",b="[object ArrayBuffer]",S="[object DataView]",k="[object Float32Array]",N="[object Float64Array]",j="[object Int8Array]",A="[object Int16Array]",M="[object Int32Array]",P="[object Uint8Array]",O="[object Uint8ClampedArray]",D="[object Uint16Array]",L="[object Uint32Array]",U={};U[k]=U[N]=U[j]=U[A]=U[M]=U[P]=U[O]=U[D]=U[L]=!0,U[i]=U[o]=U[b]=U[a]=U[S]=U[u]=U[c]=U[f]=U[p]=U[d]=U[g]=U[y]=U[w]=U[E]=U[_]=!1;function V(z){return r(z)&&t(z.length)&&!!U[e(z)]}return sh=V,sh}var ih,O1;function Xu(){if(O1)return ih;O1=1;function e(t){return function(r){return t(r)}}return ih=e,ih}var ga={exports:{}};ga.exports;var P1;function by(){return P1||(P1=1,(function(e,t){var r=rj(),i=t&&!t.nodeType&&t,o=i&&!0&&e&&!e.nodeType&&e,a=o&&o.exports===i,u=a&&r.process,c=(function(){try{var f=o&&o.require&&o.require("util").types;return f||u&&u.binding&&u.binding("util")}catch{}})();e.exports=c})(ga,ga.exports)),ga.exports}var oh,L1;function Fa(){if(L1)return oh;L1=1;var e=Xq(),t=Xu(),r=by(),i=r&&r.isTypedArray,o=i?t(i):e;return oh=o,oh}var ah,$1;function oj(){if($1)return ah;$1=1;var e=Gq(),t=Da(),r=_t(),i=bo(),o=Ku(),a=Fa(),u=Object.prototype,c=u.hasOwnProperty;function f(p,d){var g=r(p),y=!g&&t(p),w=!g&&!y&&i(p),E=!g&&!y&&!w&&a(p),_=g||y||w||E,b=_?e(p.length,String):[],S=b.length;for(var k in p)(d||c.call(p,k))&&!(_&&(k=="length"||w&&(k=="offset"||k=="parent")||E&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||o(k,S)))&&b.push(k);return b}return ah=f,ah}var lh,q1;function Qu(){if(q1)return lh;q1=1;var e=Object.prototype;function t(r){var i=r&&r.constructor,o=typeof i=="function"&&i.prototype||e;return r===o}return lh=t,lh}var uh,D1;function aj(){if(D1)return uh;D1=1;function e(t,r){return function(i){return t(r(i))}}return uh=e,uh}var ch,F1;function Qq(){if(F1)return ch;F1=1;var e=aj(),t=e(Object.keys,Object);return ch=t,ch}var dh,z1;function Sy(){if(z1)return dh;z1=1;var e=Qu(),t=Qq(),r=Object.prototype,i=r.hasOwnProperty;function o(a){if(!e(a))return t(a);var u=[];for(var c in Object(a))i.call(a,c)&&c!="constructor"&&u.push(c);return u}return dh=o,dh}var fh,B1;function Br(){if(B1)return fh;B1=1;var e=$a(),t=_y();function r(i){return i!=null&&t(i.length)&&!e(i)}return fh=r,fh}var hh,U1;function As(){if(U1)return hh;U1=1;var e=oj(),t=Sy(),r=Br();function i(o){return r(o)?e(o):t(o)}return hh=i,hh}var ph,H1;function Zq(){if(H1)return ph;H1=1;var e=qa(),t=As();function r(i,o){return i&&e(o,t(o),i)}return ph=r,ph}var mh,W1;function Jq(){if(W1)return mh;W1=1;function e(t){var r=[];if(t!=null)for(var i in Object(t))r.push(i);return r}return mh=e,mh}var gh,V1;function eD(){if(V1)return gh;V1=1;var e=qn(),t=Qu(),r=Jq(),i=Object.prototype,o=i.hasOwnProperty;function a(u){if(!e(u))return r(u);var c=t(u),f=[];for(var p in u)p=="constructor"&&(c||!o.call(u,p))||f.push(p);return f}return gh=a,gh}var vh,G1;function yi(){if(G1)return vh;G1=1;var e=oj(),t=eD(),r=Br();function i(o){return r(o)?e(o,!0):t(o)}return vh=i,vh}var yh,Y1;function tD(){if(Y1)return yh;Y1=1;var e=qa(),t=yi();function r(i,o){return i&&e(o,t(o),i)}return yh=r,yh}var va={exports:{}};va.exports;var K1;function lj(){return K1||(K1=1,(function(e,t){var r=rr(),i=t&&!t.nodeType&&t,o=i&&!0&&e&&!e.nodeType&&e,a=o&&o.exports===i,u=a?r.Buffer:void 0,c=u?u.allocUnsafe:void 0;function f(p,d){if(d)return p.slice();var g=p.length,y=c?c(g):new p.constructor(g);return p.copy(y),y}e.exports=f})(va,va.exports)),va.exports}var wh,X1;function uj(){if(X1)return wh;X1=1;function e(t,r){var i=-1,o=t.length;for(r||(r=Array(o));++i<o;)r[i]=t[i];return r}return wh=e,wh}var xh,Q1;function cj(){if(Q1)return xh;Q1=1;function e(t,r){for(var i=-1,o=t==null?0:t.length,a=0,u=[];++i<o;){var c=t[i];r(c,i,t)&&(u[a++]=c)}return u}return xh=e,xh}var _h,Z1;function dj(){if(Z1)return _h;Z1=1;function e(){return[]}return _h=e,_h}var bh,J1;function ky(){if(J1)return bh;J1=1;var e=cj(),t=dj(),r=Object.prototype,i=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,a=o?function(u){return u==null?[]:(u=Object(u),e(o(u),function(c){return i.call(u,c)}))}:t;return bh=a,bh}var Sh,eb;function nD(){if(eb)return Sh;eb=1;var e=qa(),t=ky();function r(i,o){return e(i,t(i),o)}return Sh=r,Sh}var kh,tb;function Ey(){if(tb)return kh;tb=1;function e(t,r){for(var i=-1,o=r.length,a=t.length;++i<o;)t[a+i]=r[i];return t}return kh=e,kh}var Eh,nb;function Zu(){if(nb)return Eh;nb=1;var e=aj(),t=e(Object.getPrototypeOf,Object);return Eh=t,Eh}var Nh,rb;function fj(){if(rb)return Nh;rb=1;var e=Ey(),t=Zu(),r=ky(),i=dj(),o=Object.getOwnPropertySymbols,a=o?function(u){for(var c=[];u;)e(c,r(u)),u=t(u);return c}:i;return Nh=a,Nh}var Ch,sb;function rD(){if(sb)return Ch;sb=1;var e=qa(),t=fj();function r(i,o){return e(i,t(i),o)}return Ch=r,Ch}var jh,ib;function hj(){if(ib)return jh;ib=1;var e=Ey(),t=_t();function r(i,o,a){var u=o(i);return t(i)?u:e(u,a(i))}return jh=r,jh}var Th,ob;function pj(){if(ob)return Th;ob=1;var e=hj(),t=ky(),r=As();function i(o){return e(o,r,t)}return Th=i,Th}var Rh,ab;function sD(){if(ab)return Rh;ab=1;var e=hj(),t=fj(),r=yi();function i(o){return e(o,r,t)}return Rh=i,Rh}var Ah,lb;function iD(){if(lb)return Ah;lb=1;var e=vi(),t=rr(),r=e(t,"DataView");return Ah=r,Ah}var Ih,ub;function oD(){if(ub)return Ih;ub=1;var e=vi(),t=rr(),r=e(t,"Promise");return Ih=r,Ih}var Mh,cb;function mj(){if(cb)return Mh;cb=1;var e=vi(),t=rr(),r=e(t,"Set");return Mh=r,Mh}var Oh,db;function aD(){if(db)return Oh;db=1;var e=vi(),t=rr(),r=e(t,"WeakMap");return Oh=r,Oh}var Ph,fb;function So(){if(fb)return Ph;fb=1;var e=iD(),t=yy(),r=oD(),i=mj(),o=aD(),a=gi(),u=sj(),c="[object Map]",f="[object Object]",p="[object Promise]",d="[object Set]",g="[object WeakMap]",y="[object DataView]",w=u(e),E=u(t),_=u(r),b=u(i),S=u(o),k=a;return(e&&k(new e(new ArrayBuffer(1)))!=y||t&&k(new t)!=c||r&&k(r.resolve())!=p||i&&k(new i)!=d||o&&k(new o)!=g)&&(k=function(N){var j=a(N),A=j==f?N.constructor:void 0,M=A?u(A):"";if(M)switch(M){case w:return y;case E:return c;case _:return p;case b:return d;case S:return g}return j}),Ph=k,Ph}var Lh,hb;function lD(){if(hb)return Lh;hb=1;var e=Object.prototype,t=e.hasOwnProperty;function r(i){var o=i.length,a=new i.constructor(o);return o&&typeof i[0]=="string"&&t.call(i,"index")&&(a.index=i.index,a.input=i.input),a}return Lh=r,Lh}var $h,pb;function gj(){if(pb)return $h;pb=1;var e=rr(),t=e.Uint8Array;return $h=t,$h}var qh,mb;function Ny(){if(mb)return qh;mb=1;var e=gj();function t(r){var i=new r.constructor(r.byteLength);return new e(i).set(new e(r)),i}return qh=t,qh}var Dh,gb;function uD(){if(gb)return Dh;gb=1;var e=Ny();function t(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return Dh=t,Dh}var Fh,vb;function cD(){if(vb)return Fh;vb=1;var e=/\w*$/;function t(r){var i=new r.constructor(r.source,e.exec(r));return i.lastIndex=r.lastIndex,i}return Fh=t,Fh}var zh,yb;function dD(){if(yb)return zh;yb=1;var e=_o(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function i(o){return r?Object(r.call(o)):{}}return zh=i,zh}var Bh,wb;function vj(){if(wb)return Bh;wb=1;var e=Ny();function t(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return Bh=t,Bh}var Uh,xb;function fD(){if(xb)return Uh;xb=1;var e=Ny(),t=uD(),r=cD(),i=dD(),o=vj(),a="[object Boolean]",u="[object Date]",c="[object Map]",f="[object Number]",p="[object RegExp]",d="[object Set]",g="[object String]",y="[object Symbol]",w="[object ArrayBuffer]",E="[object DataView]",_="[object Float32Array]",b="[object Float64Array]",S="[object Int8Array]",k="[object Int16Array]",N="[object Int32Array]",j="[object Uint8Array]",A="[object Uint8ClampedArray]",M="[object Uint16Array]",P="[object Uint32Array]";function O(D,L,U){var V=D.constructor;switch(L){case w:return e(D);case a:case u:return new V(+D);case E:return t(D,U);case _:case b:case S:case k:case N:case j:case A:case M:case P:return o(D,U);case c:return new V;case f:case g:return new V(D);case p:return r(D);case d:return new V;case y:return i(D)}}return Uh=O,Uh}var Hh,_b;function yj(){if(_b)return Hh;_b=1;var e=qn(),t=Object.create,r=(function(){function i(){}return function(o){if(!e(o))return{};if(t)return t(o);i.prototype=o;var a=new i;return i.prototype=void 0,a}})();return Hh=r,Hh}var Wh,bb;function wj(){if(bb)return Wh;bb=1;var e=yj(),t=Zu(),r=Qu();function i(o){return typeof o.constructor=="function"&&!r(o)?e(t(o)):{}}return Wh=i,Wh}var Vh,Sb;function hD(){if(Sb)return Vh;Sb=1;var e=So(),t=mr(),r="[object Map]";function i(o){return t(o)&&e(o)==r}return Vh=i,Vh}var Gh,kb;function pD(){if(kb)return Gh;kb=1;var e=hD(),t=Xu(),r=by(),i=r&&r.isMap,o=i?t(i):e;return Gh=o,Gh}var Yh,Eb;function mD(){if(Eb)return Yh;Eb=1;var e=So(),t=mr(),r="[object Set]";function i(o){return t(o)&&e(o)==r}return Yh=i,Yh}var Kh,Nb;function gD(){if(Nb)return Kh;Nb=1;var e=mD(),t=Xu(),r=by(),i=r&&r.isSet,o=i?t(i):e;return Kh=o,Kh}var Xh,Cb;function xj(){if(Cb)return Xh;Cb=1;var e=Vu(),t=xy(),r=Yu(),i=Zq(),o=tD(),a=lj(),u=uj(),c=nD(),f=rD(),p=pj(),d=sD(),g=So(),y=lD(),w=fD(),E=wj(),_=_t(),b=bo(),S=pD(),k=qn(),N=gD(),j=As(),A=yi(),M=1,P=2,O=4,D="[object Arguments]",L="[object Array]",U="[object Boolean]",V="[object Date]",z="[object Error]",C="[object Function]",F="[object GeneratorFunction]",$="[object Map]",re="[object Number]",J="[object Object]",W="[object RegExp]",Z="[object Set]",I="[object String]",G="[object Symbol]",K="[object WeakMap]",q="[object ArrayBuffer]",Q="[object DataView]",ne="[object Float32Array]",ae="[object Float64Array]",fe="[object Int8Array]",te="[object Int16Array]",ce="[object Int32Array]",Ce="[object Uint8Array]",ve="[object Uint8ClampedArray]",Re="[object Uint16Array]",ye="[object Uint32Array]",Ee={};Ee[D]=Ee[L]=Ee[q]=Ee[Q]=Ee[U]=Ee[V]=Ee[ne]=Ee[ae]=Ee[fe]=Ee[te]=Ee[ce]=Ee[$]=Ee[re]=Ee[J]=Ee[W]=Ee[Z]=Ee[I]=Ee[G]=Ee[Ce]=Ee[ve]=Ee[Re]=Ee[ye]=!0,Ee[z]=Ee[C]=Ee[K]=!1;function Ye(we,_e,Be,it,ft,Ze){var De,Je=_e&M,Xe=_e&P,Ot=_e&O;if(Be&&(De=ft?Be(we,it,ft,Ze):Be(we)),De!==void 0)return De;if(!k(we))return we;var lt=_(we);if(lt){if(De=y(we),!Je)return u(we,De)}else{var Qe=g(we),Pt=Qe==C||Qe==F;if(b(we))return a(we,Je);if(Qe==J||Qe==D||Pt&&!ft){if(De=Xe||Pt?{}:E(we),!Je)return Xe?f(we,o(De,we)):c(we,i(De,we))}else{if(!Ee[Qe])return ft?we:{};De=w(we,Qe,Je)}}Ze||(Ze=new e);var zt=Ze.get(we);if(zt)return zt;Ze.set(we,De),N(we)?we.forEach(function(ht){De.add(Ye(ht,_e,Be,ht,we,Ze))}):S(we)&&we.forEach(function(ht,vt){De.set(vt,Ye(ht,_e,Be,vt,we,Ze))});var et=Ot?Xe?d:p:Xe?A:j,bt=lt?void 0:et(we);return t(bt||we,function(ht,vt){bt&&(vt=ht,ht=we[vt]),r(De,vt,Ye(ht,_e,Be,vt,we,Ze))}),De}return Xh=Ye,Xh}var Qh,jb;function vD(){if(jb)return Qh;jb=1;var e=xj(),t=4;function r(i){return e(i,t)}return Qh=r,Qh}var Zh,Tb;function Cy(){if(Tb)return Zh;Tb=1;function e(t){return function(){return t}}return Zh=e,Zh}var Jh,Rb;function yD(){if(Rb)return Jh;Rb=1;function e(t){return function(r,i,o){for(var a=-1,u=Object(r),c=o(r),f=c.length;f--;){var p=c[t?f:++a];if(i(u[p],p,u)===!1)break}return r}}return Jh=e,Jh}var ep,Ab;function jy(){if(Ab)return ep;Ab=1;var e=yD(),t=e();return ep=t,ep}var tp,Ib;function Ty(){if(Ib)return tp;Ib=1;var e=jy(),t=As();function r(i,o){return i&&e(i,o,t)}return tp=r,tp}var np,Mb;function wD(){if(Mb)return np;Mb=1;var e=Br();function t(r,i){return function(o,a){if(o==null)return o;if(!e(o))return r(o,a);for(var u=o.length,c=i?u:-1,f=Object(o);(i?c--:++c<u)&&a(f[c],c,f)!==!1;);return o}}return np=t,np}var rp,Ob;function Ju(){if(Ob)return rp;Ob=1;var e=Ty(),t=wD(),r=t(e);return rp=r,rp}var sp,Pb;function wi(){if(Pb)return sp;Pb=1;function e(t){return t}return sp=e,sp}var ip,Lb;function _j(){if(Lb)return ip;Lb=1;var e=wi();function t(r){return typeof r=="function"?r:e}return ip=t,ip}var op,$b;function bj(){if($b)return op;$b=1;var e=xy(),t=Ju(),r=_j(),i=_t();function o(a,u){var c=i(a)?e:t;return c(a,r(u))}return op=o,op}var ap,qb;function Sj(){return qb||(qb=1,ap=bj()),ap}var lp,Db;function xD(){if(Db)return lp;Db=1;var e=Ju();function t(r,i){var o=[];return e(r,function(a,u,c){i(a,u,c)&&o.push(a)}),o}return lp=t,lp}var up,Fb;function _D(){if(Fb)return up;Fb=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return up=t,up}var cp,zb;function bD(){if(zb)return cp;zb=1;function e(t){return this.__data__.has(t)}return cp=e,cp}var dp,Bb;function kj(){if(Bb)return dp;Bb=1;var e=wy(),t=_D(),r=bD();function i(o){var a=-1,u=o==null?0:o.length;for(this.__data__=new e;++a<u;)this.add(o[a])}return i.prototype.add=i.prototype.push=t,i.prototype.has=r,dp=i,dp}var fp,Ub;function SD(){if(Ub)return fp;Ub=1;function e(t,r){for(var i=-1,o=t==null?0:t.length;++i<o;)if(r(t[i],i,t))return!0;return!1}return fp=e,fp}var hp,Hb;function Ej(){if(Hb)return hp;Hb=1;function e(t,r){return t.has(r)}return hp=e,hp}var pp,Wb;function Nj(){if(Wb)return pp;Wb=1;var e=kj(),t=SD(),r=Ej(),i=1,o=2;function a(u,c,f,p,d,g){var y=f&i,w=u.length,E=c.length;if(w!=E&&!(y&&E>w))return!1;var _=g.get(u),b=g.get(c);if(_&&b)return _==c&&b==u;var S=-1,k=!0,N=f&o?new e:void 0;for(g.set(u,c),g.set(c,u);++S<w;){var j=u[S],A=c[S];if(p)var M=y?p(A,j,S,c,u,g):p(j,A,S,u,c,g);if(M!==void 0){if(M)continue;k=!1;break}if(N){if(!t(c,function(P,O){if(!r(N,O)&&(j===P||d(j,P,f,p,g)))return N.push(O)})){k=!1;break}}else if(!(j===A||d(j,A,f,p,g))){k=!1;break}}return g.delete(u),g.delete(c),k}return pp=a,pp}var mp,Vb;function kD(){if(Vb)return mp;Vb=1;function e(t){var r=-1,i=Array(t.size);return t.forEach(function(o,a){i[++r]=[a,o]}),i}return mp=e,mp}var gp,Gb;function Ry(){if(Gb)return gp;Gb=1;function e(t){var r=-1,i=Array(t.size);return t.forEach(function(o){i[++r]=o}),i}return gp=e,gp}var vp,Yb;function ED(){if(Yb)return vp;Yb=1;var e=_o(),t=gj(),r=xo(),i=Nj(),o=kD(),a=Ry(),u=1,c=2,f="[object Boolean]",p="[object Date]",d="[object Error]",g="[object Map]",y="[object Number]",w="[object RegExp]",E="[object Set]",_="[object String]",b="[object Symbol]",S="[object ArrayBuffer]",k="[object DataView]",N=e?e.prototype:void 0,j=N?N.valueOf:void 0;function A(M,P,O,D,L,U,V){switch(O){case k:if(M.byteLength!=P.byteLength||M.byteOffset!=P.byteOffset)return!1;M=M.buffer,P=P.buffer;case S:return!(M.byteLength!=P.byteLength||!U(new t(M),new t(P)));case f:case p:case y:return r(+M,+P);case d:return M.name==P.name&&M.message==P.message;case w:case _:return M==P+"";case g:var z=o;case E:var C=D&u;if(z||(z=a),M.size!=P.size&&!C)return!1;var F=V.get(M);if(F)return F==P;D|=c,V.set(M,P);var $=i(z(M),z(P),D,L,U,V);return V.delete(M),$;case b:if(j)return j.call(M)==j.call(P)}return!1}return vp=A,vp}var yp,Kb;function ND(){if(Kb)return yp;Kb=1;var e=pj(),t=1,r=Object.prototype,i=r.hasOwnProperty;function o(a,u,c,f,p,d){var g=c&t,y=e(a),w=y.length,E=e(u),_=E.length;if(w!=_&&!g)return!1;for(var b=w;b--;){var S=y[b];if(!(g?S in u:i.call(u,S)))return!1}var k=d.get(a),N=d.get(u);if(k&&N)return k==u&&N==a;var j=!0;d.set(a,u),d.set(u,a);for(var A=g;++b<w;){S=y[b];var M=a[S],P=u[S];if(f)var O=g?f(P,M,S,u,a,d):f(M,P,S,a,u,d);if(!(O===void 0?M===P||p(M,P,c,f,d):O)){j=!1;break}A||(A=S=="constructor")}if(j&&!A){var D=a.constructor,L=u.constructor;D!=L&&"constructor"in a&&"constructor"in u&&!(typeof D=="function"&&D instanceof D&&typeof L=="function"&&L instanceof L)&&(j=!1)}return d.delete(a),d.delete(u),j}return yp=o,yp}var wp,Xb;function CD(){if(Xb)return wp;Xb=1;var e=Vu(),t=Nj(),r=ED(),i=ND(),o=So(),a=_t(),u=bo(),c=Fa(),f=1,p="[object Arguments]",d="[object Array]",g="[object Object]",y=Object.prototype,w=y.hasOwnProperty;function E(_,b,S,k,N,j){var A=a(_),M=a(b),P=A?d:o(_),O=M?d:o(b);P=P==p?g:P,O=O==p?g:O;var D=P==g,L=O==g,U=P==O;if(U&&u(_)){if(!u(b))return!1;A=!0,D=!1}if(U&&!D)return j||(j=new e),A||c(_)?t(_,b,S,k,N,j):r(_,b,P,S,k,N,j);if(!(S&f)){var V=D&&w.call(_,"__wrapped__"),z=L&&w.call(b,"__wrapped__");if(V||z){var C=V?_.value():_,F=z?b.value():b;return j||(j=new e),N(C,F,S,k,j)}}return U?(j||(j=new e),i(_,b,S,k,N,j)):!1}return wp=E,wp}var xp,Qb;function Cj(){if(Qb)return xp;Qb=1;var e=CD(),t=mr();function r(i,o,a,u,c){return i===o?!0:i==null||o==null||!t(i)&&!t(o)?i!==i&&o!==o:e(i,o,a,u,r,c)}return xp=r,xp}var _p,Zb;function jD(){if(Zb)return _p;Zb=1;var e=Vu(),t=Cj(),r=1,i=2;function o(a,u,c,f){var p=c.length,d=p,g=!f;if(a==null)return!d;for(a=Object(a);p--;){var y=c[p];if(g&&y[2]?y[1]!==a[y[0]]:!(y[0]in a))return!1}for(;++p<d;){y=c[p];var w=y[0],E=a[w],_=y[1];if(g&&y[2]){if(E===void 0&&!(w in a))return!1}else{var b=new e;if(f)var S=f(E,_,w,a,u,b);if(!(S===void 0?t(_,E,r|i,f,b):S))return!1}}return!0}return _p=o,_p}var bp,Jb;function jj(){if(Jb)return bp;Jb=1;var e=qn();function t(r){return r===r&&!e(r)}return bp=t,bp}var Sp,eS;function TD(){if(eS)return Sp;eS=1;var e=jj(),t=As();function r(i){for(var o=t(i),a=o.length;a--;){var u=o[a],c=i[u];o[a]=[u,c,e(c)]}return o}return Sp=r,Sp}var kp,tS;function Tj(){if(tS)return kp;tS=1;function e(t,r){return function(i){return i==null?!1:i[t]===r&&(r!==void 0||t in Object(i))}}return kp=e,kp}var Ep,nS;function RD(){if(nS)return Ep;nS=1;var e=jD(),t=TD(),r=Tj();function i(o){var a=t(o);return a.length==1&&a[0][2]?r(a[0][0],a[0][1]):function(u){return u===o||e(u,o,a)}}return Ep=i,Ep}var Np,rS;function ko(){if(rS)return Np;rS=1;var e=gi(),t=mr(),r="[object Symbol]";function i(o){return typeof o=="symbol"||t(o)&&e(o)==r}return Np=i,Np}var Cp,sS;function Ay(){if(sS)return Cp;sS=1;var e=_t(),t=ko(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i=/^\w*$/;function o(a,u){if(e(a))return!1;var c=typeof a;return c=="number"||c=="symbol"||c=="boolean"||a==null||t(a)?!0:i.test(a)||!r.test(a)||u!=null&&a in Object(u)}return Cp=o,Cp}var jp,iS;function AD(){if(iS)return jp;iS=1;var e=wy(),t="Expected a function";function r(i,o){if(typeof i!="function"||o!=null&&typeof o!="function")throw new TypeError(t);var a=function(){var u=arguments,c=o?o.apply(this,u):u[0],f=a.cache;if(f.has(c))return f.get(c);var p=i.apply(this,u);return a.cache=f.set(c,p)||f,p};return a.cache=new(r.Cache||e),a}return r.Cache=e,jp=r,jp}var Tp,oS;function ID(){if(oS)return Tp;oS=1;var e=AD(),t=500;function r(i){var o=e(i,function(u){return a.size===t&&a.clear(),u}),a=o.cache;return o}return Tp=r,Tp}var Rp,aS;function MD(){if(aS)return Rp;aS=1;var e=ID(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,i=e(function(o){var a=[];return o.charCodeAt(0)===46&&a.push(""),o.replace(t,function(u,c,f,p){a.push(f?p.replace(r,"$1"):c||u)}),a});return Rp=i,Rp}var Ap,lS;function ec(){if(lS)return Ap;lS=1;function e(t,r){for(var i=-1,o=t==null?0:t.length,a=Array(o);++i<o;)a[i]=r(t[i],i,t);return a}return Ap=e,Ap}var Ip,uS;function OD(){if(uS)return Ip;uS=1;var e=_o(),t=ec(),r=_t(),i=ko(),o=e?e.prototype:void 0,a=o?o.toString:void 0;function u(c){if(typeof c=="string")return c;if(r(c))return t(c,u)+"";if(i(c))return a?a.call(c):"";var f=c+"";return f=="0"&&1/c==-1/0?"-0":f}return Ip=u,Ip}var Mp,cS;function Rj(){if(cS)return Mp;cS=1;var e=OD();function t(r){return r==null?"":e(r)}return Mp=t,Mp}var Op,dS;function tc(){if(dS)return Op;dS=1;var e=_t(),t=Ay(),r=MD(),i=Rj();function o(a,u){return e(a)?a:t(a,u)?[a]:r(i(a))}return Op=o,Op}var Pp,fS;function za(){if(fS)return Pp;fS=1;var e=ko();function t(r){if(typeof r=="string"||e(r))return r;var i=r+"";return i=="0"&&1/r==-1/0?"-0":i}return Pp=t,Pp}var Lp,hS;function nc(){if(hS)return Lp;hS=1;var e=tc(),t=za();function r(i,o){o=e(o,i);for(var a=0,u=o.length;i!=null&&a<u;)i=i[t(o[a++])];return a&&a==u?i:void 0}return Lp=r,Lp}var $p,pS;function PD(){if(pS)return $p;pS=1;var e=nc();function t(r,i,o){var a=r==null?void 0:e(r,i);return a===void 0?o:a}return $p=t,$p}var qp,mS;function LD(){if(mS)return qp;mS=1;function e(t,r){return t!=null&&r in Object(t)}return qp=e,qp}var Dp,gS;function Aj(){if(gS)return Dp;gS=1;var e=tc(),t=Da(),r=_t(),i=Ku(),o=_y(),a=za();function u(c,f,p){f=e(f,c);for(var d=-1,g=f.length,y=!1;++d<g;){var w=a(f[d]);if(!(y=c!=null&&p(c,w)))break;c=c[w]}return y||++d!=g?y:(g=c==null?0:c.length,!!g&&o(g)&&i(w,g)&&(r(c)||t(c)))}return Dp=u,Dp}var Fp,vS;function Ij(){if(vS)return Fp;vS=1;var e=LD(),t=Aj();function r(i,o){return i!=null&&t(i,o,e)}return Fp=r,Fp}var zp,yS;function $D(){if(yS)return zp;yS=1;var e=Cj(),t=PD(),r=Ij(),i=Ay(),o=jj(),a=Tj(),u=za(),c=1,f=2;function p(d,g){return i(d)&&o(g)?a(u(d),g):function(y){var w=t(y,d);return w===void 0&&w===g?r(y,d):e(g,w,c|f)}}return zp=p,zp}var Bp,wS;function Mj(){if(wS)return Bp;wS=1;function e(t){return function(r){return r==null?void 0:r[t]}}return Bp=e,Bp}var Up,xS;function qD(){if(xS)return Up;xS=1;var e=nc();function t(r){return function(i){return e(i,r)}}return Up=t,Up}var Hp,_S;function DD(){if(_S)return Hp;_S=1;var e=Mj(),t=qD(),r=Ay(),i=za();function o(a){return r(a)?e(i(a)):t(a)}return Hp=o,Hp}var Wp,bS;function Ur(){if(bS)return Wp;bS=1;var e=RD(),t=$D(),r=wi(),i=_t(),o=DD();function a(u){return typeof u=="function"?u:u==null?r:typeof u=="object"?i(u)?t(u[0],u[1]):e(u):o(u)}return Wp=a,Wp}var Vp,SS;function Oj(){if(SS)return Vp;SS=1;var e=cj(),t=xD(),r=Ur(),i=_t();function o(a,u){var c=i(a)?e:t;return c(a,r(u,3))}return Vp=o,Vp}var Gp,kS;function FD(){if(kS)return Gp;kS=1;var e=Object.prototype,t=e.hasOwnProperty;function r(i,o){return i!=null&&t.call(i,o)}return Gp=r,Gp}var Yp,ES;function Pj(){if(ES)return Yp;ES=1;var e=FD(),t=Aj();function r(i,o){return i!=null&&t(i,o,e)}return Yp=r,Yp}var Kp,NS;function zD(){if(NS)return Kp;NS=1;var e=Sy(),t=So(),r=Da(),i=_t(),o=Br(),a=bo(),u=Qu(),c=Fa(),f="[object Map]",p="[object Set]",d=Object.prototype,g=d.hasOwnProperty;function y(w){if(w==null)return!0;if(o(w)&&(i(w)||typeof w=="string"||typeof w.splice=="function"||a(w)||c(w)||r(w)))return!w.length;var E=t(w);if(E==f||E==p)return!w.size;if(u(w))return!e(w).length;for(var _ in w)if(g.call(w,_))return!1;return!0}return Kp=y,Kp}var Xp,CS;function Lj(){if(CS)return Xp;CS=1;function e(t){return t===void 0}return Xp=e,Xp}var Qp,jS;function $j(){if(jS)return Qp;jS=1;var e=Ju(),t=Br();function r(i,o){var a=-1,u=t(i)?Array(i.length):[];return e(i,function(c,f,p){u[++a]=o(c,f,p)}),u}return Qp=r,Qp}var Zp,TS;function qj(){if(TS)return Zp;TS=1;var e=ec(),t=Ur(),r=$j(),i=_t();function o(a,u){var c=i(a)?e:r;return c(a,t(u,3))}return Zp=o,Zp}var Jp,RS;function BD(){if(RS)return Jp;RS=1;function e(t,r,i,o){var a=-1,u=t==null?0:t.length;for(o&&u&&(i=t[++a]);++a<u;)i=r(i,t[a],a,t);return i}return Jp=e,Jp}var em,AS;function UD(){if(AS)return em;AS=1;function e(t,r,i,o,a){return a(t,function(u,c,f){i=o?(o=!1,u):r(i,u,c,f)}),i}return em=e,em}var tm,IS;function Dj(){if(IS)return tm;IS=1;var e=BD(),t=Ju(),r=Ur(),i=UD(),o=_t();function a(u,c,f){var p=o(u)?e:i,d=arguments.length<3;return p(u,r(c,4),f,d,t)}return tm=a,tm}var nm,MS;function HD(){if(MS)return nm;MS=1;var e=gi(),t=_t(),r=mr(),i="[object String]";function o(a){return typeof a=="string"||!t(a)&&r(a)&&e(a)==i}return nm=o,nm}var rm,OS;function WD(){if(OS)return rm;OS=1;var e=Mj(),t=e("length");return rm=t,rm}var sm,PS;function VD(){if(PS)return sm;PS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",o=t+r+i,a="\\ufe0e\\ufe0f",u="\\u200d",c=RegExp("["+u+e+o+a+"]");function f(p){return c.test(p)}return sm=f,sm}var im,LS;function GD(){if(LS)return im;LS=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",o=t+r+i,a="\\ufe0e\\ufe0f",u="["+e+"]",c="["+o+"]",f="\\ud83c[\\udffb-\\udfff]",p="(?:"+c+"|"+f+")",d="[^"+e+"]",g="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",E=p+"?",_="["+a+"]?",b="(?:"+w+"(?:"+[d,g,y].join("|")+")"+_+E+")*",S=_+E+b,k="(?:"+[d+c+"?",c,g,y,u].join("|")+")",N=RegExp(f+"(?="+f+")|"+k+S,"g");function j(A){for(var M=N.lastIndex=0;N.test(A);)++M;return M}return im=j,im}var om,$S;function YD(){if($S)return om;$S=1;var e=WD(),t=VD(),r=GD();function i(o){return t(o)?r(o):e(o)}return om=i,om}var am,qS;function KD(){if(qS)return am;qS=1;var e=Sy(),t=So(),r=Br(),i=HD(),o=YD(),a="[object Map]",u="[object Set]";function c(f){if(f==null)return 0;if(r(f))return i(f)?o(f):f.length;var p=t(f);return p==a||p==u?f.size:e(f).length}return am=c,am}var lm,DS;function XD(){if(DS)return lm;DS=1;var e=xy(),t=yj(),r=Ty(),i=Ur(),o=Zu(),a=_t(),u=bo(),c=$a(),f=qn(),p=Fa();function d(g,y,w){var E=a(g),_=E||u(g)||p(g);if(y=i(y,4),w==null){var b=g&&g.constructor;_?w=E?new b:[]:f(g)?w=c(b)?t(o(g)):{}:w={}}return(_?e:r)(g,function(S,k,N){return y(w,S,k,N)}),w}return lm=d,lm}var um,FS;function QD(){if(FS)return um;FS=1;var e=_o(),t=Da(),r=_t(),i=e?e.isConcatSpreadable:void 0;function o(a){return r(a)||t(a)||!!(i&&a&&a[i])}return um=o,um}var cm,zS;function Iy(){if(zS)return cm;zS=1;var e=Ey(),t=QD();function r(i,o,a,u,c){var f=-1,p=i.length;for(a||(a=t),c||(c=[]);++f<p;){var d=i[f];o>0&&a(d)?o>1?r(d,o-1,a,u,c):e(c,d):u||(c[c.length]=d)}return c}return cm=r,cm}var dm,BS;function ZD(){if(BS)return dm;BS=1;function e(t,r,i){switch(i.length){case 0:return t.call(r);case 1:return t.call(r,i[0]);case 2:return t.call(r,i[0],i[1]);case 3:return t.call(r,i[0],i[1],i[2])}return t.apply(r,i)}return dm=e,dm}var fm,US;function Fj(){if(US)return fm;US=1;var e=ZD(),t=Math.max;function r(i,o,a){return o=t(o===void 0?i.length-1:o,0),function(){for(var u=arguments,c=-1,f=t(u.length-o,0),p=Array(f);++c<f;)p[c]=u[o+c];c=-1;for(var d=Array(o+1);++c<o;)d[c]=u[c];return d[o]=a(p),e(i,this,d)}}return fm=r,fm}var hm,HS;function JD(){if(HS)return hm;HS=1;var e=Cy(),t=ij(),r=wi(),i=t?function(o,a){return t(o,"toString",{configurable:!0,enumerable:!1,value:e(a),writable:!0})}:r;return hm=i,hm}var pm,WS;function e4(){if(WS)return pm;WS=1;var e=800,t=16,r=Date.now;function i(o){var a=0,u=0;return function(){var c=r(),f=t-(c-u);if(u=c,f>0){if(++a>=e)return arguments[0]}else a=0;return o.apply(void 0,arguments)}}return pm=i,pm}var mm,VS;function zj(){if(VS)return mm;VS=1;var e=JD(),t=e4(),r=t(e);return mm=r,mm}var gm,GS;function rc(){if(GS)return gm;GS=1;var e=wi(),t=Fj(),r=zj();function i(o,a){return r(t(o,a,e),o+"")}return gm=i,gm}var vm,YS;function Bj(){if(YS)return vm;YS=1;function e(t,r,i,o){for(var a=t.length,u=i+(o?1:-1);o?u--:++u<a;)if(r(t[u],u,t))return u;return-1}return vm=e,vm}var ym,KS;function t4(){if(KS)return ym;KS=1;function e(t){return t!==t}return ym=e,ym}var wm,XS;function n4(){if(XS)return wm;XS=1;function e(t,r,i){for(var o=i-1,a=t.length;++o<a;)if(t[o]===r)return o;return-1}return wm=e,wm}var xm,QS;function r4(){if(QS)return xm;QS=1;var e=Bj(),t=t4(),r=n4();function i(o,a,u){return a===a?r(o,a,u):e(o,t,u)}return xm=i,xm}var _m,ZS;function s4(){if(ZS)return _m;ZS=1;var e=r4();function t(r,i){var o=r==null?0:r.length;return!!o&&e(r,i,0)>-1}return _m=t,_m}var bm,JS;function i4(){if(JS)return bm;JS=1;function e(t,r,i){for(var o=-1,a=t==null?0:t.length;++o<a;)if(i(r,t[o]))return!0;return!1}return bm=e,bm}var Sm,ek;function o4(){if(ek)return Sm;ek=1;function e(){}return Sm=e,Sm}var km,tk;function a4(){if(tk)return km;tk=1;var e=mj(),t=o4(),r=Ry(),i=1/0,o=e&&1/r(new e([,-0]))[1]==i?function(a){return new e(a)}:t;return km=o,km}var Em,nk;function l4(){if(nk)return Em;nk=1;var e=kj(),t=s4(),r=i4(),i=Ej(),o=a4(),a=Ry(),u=200;function c(f,p,d){var g=-1,y=t,w=f.length,E=!0,_=[],b=_;if(d)E=!1,y=r;else if(w>=u){var S=p?null:o(f);if(S)return a(S);E=!1,y=i,b=new e}else b=p?[]:_;e:for(;++g<w;){var k=f[g],N=p?p(k):k;if(k=d||k!==0?k:0,E&&N===N){for(var j=b.length;j--;)if(b[j]===N)continue e;p&&b.push(N),_.push(k)}else y(b,N,d)||(b!==_&&b.push(N),_.push(k))}return _}return Em=c,Em}var Nm,rk;function Uj(){if(rk)return Nm;rk=1;var e=Br(),t=mr();function r(i){return t(i)&&e(i)}return Nm=r,Nm}var Cm,sk;function u4(){if(sk)return Cm;sk=1;var e=Iy(),t=rc(),r=l4(),i=Uj(),o=t(function(a){return r(e(a,1,i,!0))});return Cm=o,Cm}var jm,ik;function c4(){if(ik)return jm;ik=1;var e=ec();function t(r,i){return e(i,function(o){return r[o]})}return jm=t,jm}var Tm,ok;function Hj(){if(ok)return Tm;ok=1;var e=c4(),t=As();function r(i){return i==null?[]:e(i,t(i))}return Tm=r,Tm}var Rm,ak;function Dn(){if(ak)return Rm;ak=1;var e;if(typeof vy=="function")try{e={clone:vD(),constant:Cy(),each:Sj(),filter:Oj(),has:Pj(),isArray:_t(),isEmpty:zD(),isFunction:$a(),isUndefined:Lj(),keys:As(),map:qj(),reduce:Dj(),size:KD(),transform:XD(),union:u4(),values:Hj()}}catch{}return e||(e=window._),Rm=e,Rm}var Am,lk;function My(){if(lk)return Am;lk=1;var e=Dn();Am=o;var t="\0",r="\0",i="";function o(d){this._isDirected=e.has(d,"directed")?d.directed:!0,this._isMultigraph=e.has(d,"multigraph")?d.multigraph:!1,this._isCompound=e.has(d,"compound")?d.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[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(d){return this._label=d,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(g){return e.isEmpty(d._in[g])})},o.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(g){return e.isEmpty(d._out[g])})},o.prototype.setNodes=function(d,g){var y=arguments,w=this;return e.each(d,function(E){y.length>1?w.setNode(E,g):w.setNode(E)}),this},o.prototype.setNode=function(d,g){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=g),this):(this._nodes[d]=arguments.length>1?g:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=r,this._children[d]={},this._children[r][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},o.prototype.node=function(d){return this._nodes[d]},o.prototype.hasNode=function(d){return e.has(this._nodes,d)},o.prototype.removeNode=function(d){var g=this;if(e.has(this._nodes,d)){var y=function(w){g.removeEdge(g._edgeObjs[w])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(w){g.setParent(w)}),delete this._children[d]),e.each(e.keys(this._in[d]),y),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),y),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},o.prototype.setParent=function(d,g){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(g))g=r;else{g+="";for(var y=g;!e.isUndefined(y);y=this.parent(y))if(y===d)throw new Error("Setting "+g+" as parent of "+d+" would create a cycle");this.setNode(g)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=g,this._children[g][d]=!0,this},o.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},o.prototype.parent=function(d){if(this._isCompound){var g=this._parent[d];if(g!==r)return g}},o.prototype.children=function(d){if(e.isUndefined(d)&&(d=r),this._isCompound){var g=this._children[d];if(g)return e.keys(g)}else{if(d===r)return this.nodes();if(this.hasNode(d))return[]}},o.prototype.predecessors=function(d){var g=this._preds[d];if(g)return e.keys(g)},o.prototype.successors=function(d){var g=this._sucs[d];if(g)return e.keys(g)},o.prototype.neighbors=function(d){var g=this.predecessors(d);if(g)return e.union(g,this.successors(d))},o.prototype.isLeaf=function(d){var g;return this.isDirected()?g=this.successors(d):g=this.neighbors(d),g.length===0},o.prototype.filterNodes=function(d){var g=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});g.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,b){d(b)&&g.setNode(b,_)}),e.each(this._edgeObjs,function(_){g.hasNode(_.v)&&g.hasNode(_.w)&&g.setEdge(_,y.edge(_))});var w={};function E(_){var b=y.parent(_);return b===void 0||g.hasNode(b)?(w[_]=b,b):b in w?w[b]:E(b)}return this._isCompound&&e.each(g.nodes(),function(_){g.setParent(_,E(_))}),g},o.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(d,g){var y=this,w=arguments;return e.reduce(d,function(E,_){return w.length>1?y.setEdge(E,_,g):y.setEdge(E,_),_}),this},o.prototype.setEdge=function(){var d,g,y,w,E=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(d=_.v,g=_.w,y=_.name,arguments.length===2&&(w=arguments[1],E=!0)):(d=_,g=arguments[1],y=arguments[3],arguments.length>2&&(w=arguments[2],E=!0)),d=""+d,g=""+g,e.isUndefined(y)||(y=""+y);var b=c(this._isDirected,d,g,y);if(e.has(this._edgeLabels,b))return E&&(this._edgeLabels[b]=w),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(g),this._edgeLabels[b]=E?w:this._defaultEdgeLabelFn(d,g,y);var S=f(this._isDirected,d,g,y);return d=S.v,g=S.w,Object.freeze(S),this._edgeObjs[b]=S,a(this._preds[g],d),a(this._sucs[d],g),this._in[g][b]=S,this._out[d][b]=S,this._edgeCount++,this},o.prototype.edge=function(d,g,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,d,g,y);return this._edgeLabels[w]},o.prototype.hasEdge=function(d,g,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,d,g,y);return e.has(this._edgeLabels,w)},o.prototype.removeEdge=function(d,g,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,d,g,y),E=this._edgeObjs[w];return E&&(d=E.v,g=E.w,delete this._edgeLabels[w],delete this._edgeObjs[w],u(this._preds[g],d),u(this._sucs[d],g),delete this._in[g][w],delete this._out[d][w],this._edgeCount--),this},o.prototype.inEdges=function(d,g){var y=this._in[d];if(y){var w=e.values(y);return g?e.filter(w,function(E){return E.v===g}):w}},o.prototype.outEdges=function(d,g){var y=this._out[d];if(y){var w=e.values(y);return g?e.filter(w,function(E){return E.w===g}):w}},o.prototype.nodeEdges=function(d,g){var y=this.inEdges(d,g);if(y)return y.concat(this.outEdges(d,g))};function a(d,g){d[g]?d[g]++:d[g]=1}function u(d,g){--d[g]||delete d[g]}function c(d,g,y,w){var E=""+g,_=""+y;if(!d&&E>_){var b=E;E=_,_=b}return E+i+_+i+(e.isUndefined(w)?t:w)}function f(d,g,y,w){var E=""+g,_=""+y;if(!d&&E>_){var b=E;E=_,_=b}var S={v:E,w:_};return w&&(S.name=w),S}function p(d,g){return c(d,g.v,g.w,g.name)}return Am}var Im,uk;function d4(){return uk||(uk=1,Im="2.1.8"),Im}var Mm,ck;function f4(){return ck||(ck=1,Mm={Graph:My(),version:d4()}),Mm}var Om,dk;function h4(){if(dk)return Om;dk=1;var e=Dn(),t=My();Om={write:r,read:a};function r(u){var c={options:{directed:u.isDirected(),multigraph:u.isMultigraph(),compound:u.isCompound()},nodes:i(u),edges:o(u)};return e.isUndefined(u.graph())||(c.value=e.clone(u.graph())),c}function i(u){return e.map(u.nodes(),function(c){var f=u.node(c),p=u.parent(c),d={v:c};return e.isUndefined(f)||(d.value=f),e.isUndefined(p)||(d.parent=p),d})}function o(u){return e.map(u.edges(),function(c){var f=u.edge(c),p={v:c.v,w:c.w};return e.isUndefined(c.name)||(p.name=c.name),e.isUndefined(f)||(p.value=f),p})}function a(u){var c=new t(u.options).setGraph(u.value);return e.each(u.nodes,function(f){c.setNode(f.v,f.value),f.parent&&c.setParent(f.v,f.parent)}),e.each(u.edges,function(f){c.setEdge({v:f.v,w:f.w,name:f.name},f.value)}),c}return Om}var Pm,fk;function p4(){if(fk)return Pm;fk=1;var e=Dn();Pm=t;function t(r){var i={},o=[],a;function u(c){e.has(i,c)||(i[c]=!0,a.push(c),e.each(r.successors(c),u),e.each(r.predecessors(c),u))}return e.each(r.nodes(),function(c){a=[],u(c),a.length&&o.push(a)}),o}return Pm}var Lm,hk;function Wj(){if(hk)return Lm;hk=1;var e=Dn();Lm=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(r){return r.key})},t.prototype.has=function(r){return e.has(this._keyIndices,r)},t.prototype.priority=function(r){var i=this._keyIndices[r];if(i!==void 0)return this._arr[i].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(r,i){var o=this._keyIndices;if(r=String(r),!e.has(o,r)){var a=this._arr,u=a.length;return o[r]=u,a.push({key:r,priority:i}),this._decrease(u),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},t.prototype.decrease=function(r,i){var o=this._keyIndices[r];if(i>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[o].priority+" New: "+i);this._arr[o].priority=i,this._decrease(o)},t.prototype._heapify=function(r){var i=this._arr,o=2*r,a=o+1,u=r;o<i.length&&(u=i[o].priority<i[u].priority?o:u,a<i.length&&(u=i[a].priority<i[u].priority?a:u),u!==r&&(this._swap(r,u),this._heapify(u)))},t.prototype._decrease=function(r){for(var i=this._arr,o=i[r].priority,a;r!==0&&(a=r>>1,!(i[a].priority<o));)this._swap(r,a),r=a},t.prototype._swap=function(r,i){var o=this._arr,a=this._keyIndices,u=o[r],c=o[i];o[r]=c,o[i]=u,a[c.key]=r,a[u.key]=i},Lm}var $m,pk;function Vj(){if(pk)return $m;pk=1;var e=Dn(),t=Wj();$m=i;var r=e.constant(1);function i(a,u,c,f){return o(a,String(u),c||r,f||function(p){return a.outEdges(p)})}function o(a,u,c,f){var p={},d=new t,g,y,w=function(E){var _=E.v!==g?E.v:E.w,b=p[_],S=c(E),k=y.distance+S;if(S<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+E+" Weight: "+S);k<b.distance&&(b.distance=k,b.predecessor=g,d.decrease(_,k))};for(a.nodes().forEach(function(E){var _=E===u?0:Number.POSITIVE_INFINITY;p[E]={distance:_},d.add(E,_)});d.size()>0&&(g=d.removeMin(),y=p[g],y.distance!==Number.POSITIVE_INFINITY);)f(g).forEach(w);return p}return $m}var qm,mk;function m4(){if(mk)return qm;mk=1;var e=Vj(),t=Dn();qm=r;function r(i,o,a){return t.transform(i.nodes(),function(u,c){u[c]=e(i,c,o,a)},{})}return qm}var Dm,gk;function Gj(){if(gk)return Dm;gk=1;var e=Dn();Dm=t;function t(r){var i=0,o=[],a={},u=[];function c(f){var p=a[f]={onStack:!0,lowlink:i,index:i++};if(o.push(f),r.successors(f).forEach(function(y){e.has(a,y)?a[y].onStack&&(p.lowlink=Math.min(p.lowlink,a[y].index)):(c(y),p.lowlink=Math.min(p.lowlink,a[y].lowlink))}),p.lowlink===p.index){var d=[],g;do g=o.pop(),a[g].onStack=!1,d.push(g);while(f!==g);u.push(d)}}return r.nodes().forEach(function(f){e.has(a,f)||c(f)}),u}return Dm}var Fm,vk;function g4(){if(vk)return Fm;vk=1;var e=Dn(),t=Gj();Fm=r;function r(i){return e.filter(t(i),function(o){return o.length>1||o.length===1&&i.hasEdge(o[0],o[0])})}return Fm}var zm,yk;function v4(){if(yk)return zm;yk=1;var e=Dn();zm=r;var t=e.constant(1);function r(o,a,u){return i(o,a||t,u||function(c){return o.outEdges(c)})}function i(o,a,u){var c={},f=o.nodes();return f.forEach(function(p){c[p]={},c[p][p]={distance:0},f.forEach(function(d){p!==d&&(c[p][d]={distance:Number.POSITIVE_INFINITY})}),u(p).forEach(function(d){var g=d.v===p?d.w:d.v,y=a(d);c[p][g]={distance:y,predecessor:p}})}),f.forEach(function(p){var d=c[p];f.forEach(function(g){var y=c[g];f.forEach(function(w){var E=y[p],_=d[w],b=y[w],S=E.distance+_.distance;S<b.distance&&(b.distance=S,b.predecessor=_.predecessor)})})}),c}return zm}var Bm,wk;function Yj(){if(wk)return Bm;wk=1;var e=Dn();Bm=t,t.CycleException=r;function t(i){var o={},a={},u=[];function c(f){if(e.has(a,f))throw new r;e.has(o,f)||(a[f]=!0,o[f]=!0,e.each(i.predecessors(f),c),delete a[f],u.push(f))}if(e.each(i.sinks(),c),e.size(o)!==i.nodeCount())throw new r;return u}function r(){}return r.prototype=new Error,Bm}var Um,xk;function y4(){if(xk)return Um;xk=1;var e=Yj();Um=t;function t(r){try{e(r)}catch(i){if(i instanceof e.CycleException)return!1;throw i}return!0}return Um}var Hm,_k;function Kj(){if(_k)return Hm;_k=1;var e=Dn();Hm=t;function t(i,o,a){e.isArray(o)||(o=[o]);var u=(i.isDirected()?i.successors:i.neighbors).bind(i),c=[],f={};return e.each(o,function(p){if(!i.hasNode(p))throw new Error("Graph does not have node: "+p);r(i,p,a==="post",f,u,c)}),c}function r(i,o,a,u,c,f){e.has(u,o)||(u[o]=!0,a||f.push(o),e.each(c(o),function(p){r(i,p,a,u,c,f)}),a&&f.push(o))}return Hm}var Wm,bk;function w4(){if(bk)return Wm;bk=1;var e=Kj();Wm=t;function t(r,i){return e(r,i,"post")}return Wm}var Vm,Sk;function x4(){if(Sk)return Vm;Sk=1;var e=Kj();Vm=t;function t(r,i){return e(r,i,"pre")}return Vm}var Gm,kk;function _4(){if(kk)return Gm;kk=1;var e=Dn(),t=My(),r=Wj();Gm=i;function i(o,a){var u=new t,c={},f=new r,p;function d(y){var w=y.v===p?y.w:y.v,E=f.priority(w);if(E!==void 0){var _=a(y);_<E&&(c[w]=p,f.decrease(w,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){f.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),f.decrease(o.nodes()[0],0);for(var g=!1;f.size()>0;){if(p=f.removeMin(),e.has(c,p))u.setEdge(p,c[p]);else{if(g)throw new Error("Input graph is not connected: "+o);g=!0}o.nodeEdges(p).forEach(d)}return u}return Gm}var Ym,Ek;function b4(){return Ek||(Ek=1,Ym={components:p4(),dijkstra:Vj(),dijkstraAll:m4(),findCycles:g4(),floydWarshall:v4(),isAcyclic:y4(),postorder:w4(),preorder:x4(),prim:_4(),tarjan:Gj(),topsort:Yj()}),Ym}var Km,Nk;function S4(){if(Nk)return Km;Nk=1;var e=f4();return Km={Graph:e.Graph,json:h4(),alg:b4(),version:e.version},Km}var Xm,Ck;function tr(){if(Ck)return Xm;Ck=1;var e;if(typeof vy=="function")try{e=S4()}catch{}return e||(e=window.graphlib),Xm=e,Xm}var Qm,jk;function k4(){if(jk)return Qm;jk=1;var e=xj(),t=1,r=4;function i(o){return e(o,t|r)}return Qm=i,Qm}var Zm,Tk;function sc(){if(Tk)return Zm;Tk=1;var e=xo(),t=Br(),r=Ku(),i=qn();function o(a,u,c){if(!i(c))return!1;var f=typeof u;return(f=="number"?t(c)&&r(u,c.length):f=="string"&&u in c)?e(c[u],a):!1}return Zm=o,Zm}var Jm,Rk;function E4(){if(Rk)return Jm;Rk=1;var e=rc(),t=xo(),r=sc(),i=yi(),o=Object.prototype,a=o.hasOwnProperty,u=e(function(c,f){c=Object(c);var p=-1,d=f.length,g=d>2?f[2]:void 0;for(g&&r(f[0],f[1],g)&&(d=1);++p<d;)for(var y=f[p],w=i(y),E=-1,_=w.length;++E<_;){var b=w[E],S=c[b];(S===void 0||t(S,o[b])&&!a.call(c,b))&&(c[b]=y[b])}return c});return Jm=u,Jm}var eg,Ak;function N4(){if(Ak)return eg;Ak=1;var e=Ur(),t=Br(),r=As();function i(o){return function(a,u,c){var f=Object(a);if(!t(a)){var p=e(u,3);a=r(a),u=function(g){return p(f[g],g,f)}}var d=o(a,u,c);return d>-1?f[p?a[d]:d]:void 0}}return eg=i,eg}var tg,Ik;function C4(){if(Ik)return tg;Ik=1;var e=/\s/;function t(r){for(var i=r.length;i--&&e.test(r.charAt(i)););return i}return tg=t,tg}var ng,Mk;function j4(){if(Mk)return ng;Mk=1;var e=C4(),t=/^\s+/;function r(i){return i&&i.slice(0,e(i)+1).replace(t,"")}return ng=r,ng}var rg,Ok;function T4(){if(Ok)return rg;Ok=1;var e=j4(),t=qn(),r=ko(),i=NaN,o=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function f(p){if(typeof p=="number")return p;if(r(p))return i;if(t(p)){var d=typeof p.valueOf=="function"?p.valueOf():p;p=t(d)?d+"":d}if(typeof p!="string")return p===0?p:+p;p=e(p);var g=a.test(p);return g||u.test(p)?c(p.slice(2),g?2:8):o.test(p)?i:+p}return rg=f,rg}var sg,Pk;function Xj(){if(Pk)return sg;Pk=1;var e=T4(),t=1/0,r=17976931348623157e292;function i(o){if(!o)return o===0?o:0;if(o=e(o),o===t||o===-t){var a=o<0?-1:1;return a*r}return o===o?o:0}return sg=i,sg}var ig,Lk;function R4(){if(Lk)return ig;Lk=1;var e=Xj();function t(r){var i=e(r),o=i%1;return i===i?o?i-o:i:0}return ig=t,ig}var og,$k;function A4(){if($k)return og;$k=1;var e=Bj(),t=Ur(),r=R4(),i=Math.max;function o(a,u,c){var f=a==null?0:a.length;if(!f)return-1;var p=c==null?0:r(c);return p<0&&(p=i(f+p,0)),e(a,t(u,3),p)}return og=o,og}var ag,qk;function I4(){if(qk)return ag;qk=1;var e=N4(),t=A4(),r=e(t);return ag=r,ag}var lg,Dk;function Qj(){if(Dk)return lg;Dk=1;var e=Iy();function t(r){var i=r==null?0:r.length;return i?e(r,1):[]}return lg=t,lg}var ug,Fk;function M4(){if(Fk)return ug;Fk=1;var e=jy(),t=_j(),r=yi();function i(o,a){return o==null?o:e(o,t(a),r)}return ug=i,ug}var cg,zk;function O4(){if(zk)return cg;zk=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return cg=e,cg}var dg,Bk;function P4(){if(Bk)return dg;Bk=1;var e=Gu(),t=Ty(),r=Ur();function i(o,a){var u={};return a=r(a,3),t(o,function(c,f,p){e(u,f,a(c,f,p))}),u}return dg=i,dg}var fg,Uk;function Oy(){if(Uk)return fg;Uk=1;var e=ko();function t(r,i,o){for(var a=-1,u=r.length;++a<u;){var c=r[a],f=i(c);if(f!=null&&(p===void 0?f===f&&!e(f):o(f,p)))var p=f,d=c}return d}return fg=t,fg}var hg,Hk;function L4(){if(Hk)return hg;Hk=1;function e(t,r){return t>r}return hg=e,hg}var pg,Wk;function $4(){if(Wk)return pg;Wk=1;var e=Oy(),t=L4(),r=wi();function i(o){return o&&o.length?e(o,r,t):void 0}return pg=i,pg}var mg,Vk;function Zj(){if(Vk)return mg;Vk=1;var e=Gu(),t=xo();function r(i,o,a){(a!==void 0&&!t(i[o],a)||a===void 0&&!(o in i))&&e(i,o,a)}return mg=r,mg}var gg,Gk;function q4(){if(Gk)return gg;Gk=1;var e=gi(),t=Zu(),r=mr(),i="[object Object]",o=Function.prototype,a=Object.prototype,u=o.toString,c=a.hasOwnProperty,f=u.call(Object);function p(d){if(!r(d)||e(d)!=i)return!1;var g=t(d);if(g===null)return!0;var y=c.call(g,"constructor")&&g.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==f}return gg=p,gg}var vg,Yk;function Jj(){if(Yk)return vg;Yk=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return vg=e,vg}var yg,Kk;function D4(){if(Kk)return yg;Kk=1;var e=qa(),t=yi();function r(i){return e(i,t(i))}return yg=r,yg}var wg,Xk;function F4(){if(Xk)return wg;Xk=1;var e=Zj(),t=lj(),r=vj(),i=uj(),o=wj(),a=Da(),u=_t(),c=Uj(),f=bo(),p=$a(),d=qn(),g=q4(),y=Fa(),w=Jj(),E=D4();function _(b,S,k,N,j,A,M){var P=w(b,k),O=w(S,k),D=M.get(O);if(D){e(b,k,D);return}var L=A?A(P,O,k+"",b,S,M):void 0,U=L===void 0;if(U){var V=u(O),z=!V&&f(O),C=!V&&!z&&y(O);L=O,V||z||C?u(P)?L=P:c(P)?L=i(P):z?(U=!1,L=t(O,!0)):C?(U=!1,L=r(O,!0)):L=[]:g(O)||a(O)?(L=P,a(P)?L=E(P):(!d(P)||p(P))&&(L=o(O))):U=!1}U&&(M.set(O,L),j(L,O,N,A,M),M.delete(O)),e(b,k,L)}return wg=_,wg}var xg,Qk;function z4(){if(Qk)return xg;Qk=1;var e=Vu(),t=Zj(),r=jy(),i=F4(),o=qn(),a=yi(),u=Jj();function c(f,p,d,g,y){f!==p&&r(p,function(w,E){if(y||(y=new e),o(w))i(f,p,E,d,c,g,y);else{var _=g?g(u(f,E),w,E+"",f,p,y):void 0;_===void 0&&(_=w),t(f,E,_)}},a)}return xg=c,xg}var _g,Zk;function B4(){if(Zk)return _g;Zk=1;var e=rc(),t=sc();function r(i){return e(function(o,a){var u=-1,c=a.length,f=c>1?a[c-1]:void 0,p=c>2?a[2]:void 0;for(f=i.length>3&&typeof f=="function"?(c--,f):void 0,p&&t(a[0],a[1],p)&&(f=c<3?void 0:f,c=1),o=Object(o);++u<c;){var d=a[u];d&&i(o,d,u,f)}return o})}return _g=r,_g}var bg,Jk;function U4(){if(Jk)return bg;Jk=1;var e=z4(),t=B4(),r=t(function(i,o,a){e(i,o,a)});return bg=r,bg}var Sg,eE;function eT(){if(eE)return Sg;eE=1;function e(t,r){return t<r}return Sg=e,Sg}var kg,tE;function H4(){if(tE)return kg;tE=1;var e=Oy(),t=eT(),r=wi();function i(o){return o&&o.length?e(o,r,t):void 0}return kg=i,kg}var Eg,nE;function W4(){if(nE)return Eg;nE=1;var e=Oy(),t=Ur(),r=eT();function i(o,a){return o&&o.length?e(o,t(a,2),r):void 0}return Eg=i,Eg}var Ng,rE;function V4(){if(rE)return Ng;rE=1;var e=rr(),t=function(){return e.Date.now()};return Ng=t,Ng}var Cg,sE;function G4(){if(sE)return Cg;sE=1;var e=Yu(),t=tc(),r=Ku(),i=qn(),o=za();function a(u,c,f,p){if(!i(u))return u;c=t(c,u);for(var d=-1,g=c.length,y=g-1,w=u;w!=null&&++d<g;){var E=o(c[d]),_=f;if(E==="__proto__"||E==="constructor"||E==="prototype")return u;if(d!=y){var b=w[E];_=p?p(b,E,w):void 0,_===void 0&&(_=i(b)?b:r(c[d+1])?[]:{})}e(w,E,_),w=w[E]}return u}return Cg=a,Cg}var jg,iE;function Y4(){if(iE)return jg;iE=1;var e=nc(),t=G4(),r=tc();function i(o,a,u){for(var c=-1,f=a.length,p={};++c<f;){var d=a[c],g=e(o,d);u(g,d)&&t(p,r(d,o),g)}return p}return jg=i,jg}var Tg,oE;function K4(){if(oE)return Tg;oE=1;var e=Y4(),t=Ij();function r(i,o){return e(i,o,function(a,u){return t(i,u)})}return Tg=r,Tg}var Rg,aE;function X4(){if(aE)return Rg;aE=1;var e=Qj(),t=Fj(),r=zj();function i(o){return r(t(o,void 0,e),o+"")}return Rg=i,Rg}var Ag,lE;function Q4(){if(lE)return Ag;lE=1;var e=K4(),t=X4(),r=t(function(i,o){return i==null?{}:e(i,o)});return Ag=r,Ag}var Ig,uE;function Z4(){if(uE)return Ig;uE=1;var e=Math.ceil,t=Math.max;function r(i,o,a,u){for(var c=-1,f=t(e((o-i)/(a||1)),0),p=Array(f);f--;)p[u?f:++c]=i,i+=a;return p}return Ig=r,Ig}var Mg,cE;function J4(){if(cE)return Mg;cE=1;var e=Z4(),t=sc(),r=Xj();function i(o){return function(a,u,c){return c&&typeof c!="number"&&t(a,u,c)&&(u=c=void 0),a=r(a),u===void 0?(u=a,a=0):u=r(u),c=c===void 0?a<u?1:-1:r(c),e(a,u,c,o)}}return Mg=i,Mg}var Og,dE;function e5(){if(dE)return Og;dE=1;var e=J4(),t=e();return Og=t,Og}var Pg,fE;function t5(){if(fE)return Pg;fE=1;function e(t,r){var i=t.length;for(t.sort(r);i--;)t[i]=t[i].value;return t}return Pg=e,Pg}var Lg,hE;function n5(){if(hE)return Lg;hE=1;var e=ko();function t(r,i){if(r!==i){var o=r!==void 0,a=r===null,u=r===r,c=e(r),f=i!==void 0,p=i===null,d=i===i,g=e(i);if(!p&&!g&&!c&&r>i||c&&f&&d&&!p&&!g||a&&f&&d||!o&&d||!u)return 1;if(!a&&!c&&!g&&r<i||g&&o&&u&&!a&&!c||p&&o&&u||!f&&u||!d)return-1}return 0}return Lg=t,Lg}var $g,pE;function r5(){if(pE)return $g;pE=1;var e=n5();function t(r,i,o){for(var a=-1,u=r.criteria,c=i.criteria,f=u.length,p=o.length;++a<f;){var d=e(u[a],c[a]);if(d){if(a>=p)return d;var g=o[a];return d*(g=="desc"?-1:1)}}return r.index-i.index}return $g=t,$g}var qg,mE;function s5(){if(mE)return qg;mE=1;var e=ec(),t=nc(),r=Ur(),i=$j(),o=t5(),a=Xu(),u=r5(),c=wi(),f=_t();function p(d,g,y){g.length?g=e(g,function(_){return f(_)?function(b){return t(b,_.length===1?_[0]:_)}:_}):g=[c];var w=-1;g=e(g,a(r));var E=i(d,function(_,b,S){var k=e(g,function(N){return N(_)});return{criteria:k,index:++w,value:_}});return o(E,function(_,b){return u(_,b,y)})}return qg=p,qg}var Dg,gE;function i5(){if(gE)return Dg;gE=1;var e=Iy(),t=s5(),r=rc(),i=sc(),o=r(function(a,u){if(a==null)return[];var c=u.length;return c>1&&i(a,u[0],u[1])?u=[]:c>2&&i(u[0],u[1],u[2])&&(u=[u[0]]),t(a,e(u,1),[])});return Dg=o,Dg}var Fg,vE;function o5(){if(vE)return Fg;vE=1;var e=Rj(),t=0;function r(i){var o=++t;return e(i)+o}return Fg=r,Fg}var zg,yE;function a5(){if(yE)return zg;yE=1;function e(t,r,i){for(var o=-1,a=t.length,u=r.length,c={};++o<a;){var f=o<u?r[o]:void 0;i(c,t[o],f)}return c}return zg=e,zg}var Bg,wE;function l5(){if(wE)return Bg;wE=1;var e=Yu(),t=a5();function r(i,o){return t(i||[],o||[],e)}return Bg=r,Bg}var Ug,xE;function at(){if(xE)return Ug;xE=1;var e;if(typeof vy=="function")try{e={cloneDeep:k4(),constant:Cy(),defaults:E4(),each:Sj(),filter:Oj(),find:I4(),flatten:Qj(),forEach:bj(),forIn:M4(),has:Pj(),isUndefined:Lj(),last:O4(),map:qj(),mapValues:P4(),max:$4(),merge:U4(),min:H4(),minBy:W4(),now:V4(),pick:Q4(),range:e5(),reduce:Dj(),sortBy:i5(),uniqueId:o5(),values:Hj(),zipObject:l5()}}catch{}return e||(e=window._),Ug=e,Ug}var Hg,_E;function u5(){if(_E)return Hg;_E=1,Hg=e;function e(){var i={};i._next=i._prev=i,this._sentinel=i}e.prototype.dequeue=function(){var i=this._sentinel,o=i._prev;if(o!==i)return t(o),o},e.prototype.enqueue=function(i){var o=this._sentinel;i._prev&&i._next&&t(i),i._next=o._next,o._next._prev=i,o._next=i,i._prev=o},e.prototype.toString=function(){for(var i=[],o=this._sentinel,a=o._prev;a!==o;)i.push(JSON.stringify(a,r)),a=a._prev;return"["+i.join(", ")+"]"};function t(i){i._prev._next=i._next,i._next._prev=i._prev,delete i._next,delete i._prev}function r(i,o){if(i!=="_next"&&i!=="_prev")return o}return Hg}var Wg,bE;function c5(){if(bE)return Wg;bE=1;var e=at(),t=tr().Graph,r=u5();Wg=o;var i=e.constant(1);function o(p,d){if(p.nodeCount()<=1)return[];var g=c(p,d||i),y=a(g.graph,g.buckets,g.zeroIdx);return e.flatten(e.map(y,function(w){return p.outEdges(w.v,w.w)}),!0)}function a(p,d,g){for(var y=[],w=d[d.length-1],E=d[0],_;p.nodeCount();){for(;_=E.dequeue();)u(p,d,g,_);for(;_=w.dequeue();)u(p,d,g,_);if(p.nodeCount()){for(var b=d.length-2;b>0;--b)if(_=d[b].dequeue(),_){y=y.concat(u(p,d,g,_,!0));break}}}return y}function u(p,d,g,y,w){var E=w?[]:void 0;return e.forEach(p.inEdges(y.v),function(_){var b=p.edge(_),S=p.node(_.v);w&&E.push({v:_.v,w:_.w}),S.out-=b,f(d,g,S)}),e.forEach(p.outEdges(y.v),function(_){var b=p.edge(_),S=_.w,k=p.node(S);k.in-=b,f(d,g,k)}),p.removeNode(y.v),E}function c(p,d){var g=new t,y=0,w=0;e.forEach(p.nodes(),function(b){g.setNode(b,{v:b,in:0,out:0})}),e.forEach(p.edges(),function(b){var S=g.edge(b.v,b.w)||0,k=d(b),N=S+k;g.setEdge(b.v,b.w,N),w=Math.max(w,g.node(b.v).out+=k),y=Math.max(y,g.node(b.w).in+=k)});var E=e.range(w+y+3).map(function(){return new r}),_=y+1;return e.forEach(g.nodes(),function(b){f(E,_,g.node(b))}),{graph:g,buckets:E,zeroIdx:_}}function f(p,d,g){g.out?g.in?p[g.out-g.in+d].enqueue(g):p[p.length-1].enqueue(g):p[0].enqueue(g)}return Wg}var Vg,SE;function d5(){if(SE)return Vg;SE=1;var e=at(),t=c5();Vg={run:r,undo:o};function r(a){var u=a.graph().acyclicer==="greedy"?t(a,c(a)):i(a);e.forEach(u,function(f){var p=a.edge(f);a.removeEdge(f),p.forwardName=f.name,p.reversed=!0,a.setEdge(f.w,f.v,p,e.uniqueId("rev"))});function c(f){return function(p){return f.edge(p).weight}}}function i(a){var u=[],c={},f={};function p(d){e.has(f,d)||(f[d]=!0,c[d]=!0,e.forEach(a.outEdges(d),function(g){e.has(c,g.w)?u.push(g):p(g.w)}),delete c[d])}return e.forEach(a.nodes(),p),u}function o(a){e.forEach(a.edges(),function(u){var c=a.edge(u);if(c.reversed){a.removeEdge(u);var f=c.forwardName;delete c.reversed,delete c.forwardName,a.setEdge(u.w,u.v,c,f)}})}return Vg}var Gg,kE;function fn(){if(kE)return Gg;kE=1;var e=at(),t=tr().Graph;Gg={addDummyNode:r,simplify:i,asNonCompoundGraph:o,successorWeights:a,predecessorWeights:u,intersectRect:c,buildLayerMatrix:f,normalizeRanks:p,removeEmptyRanks:d,addBorderNode:g,maxRank:y,partition:w,time:E,notime:_};function r(b,S,k,N){var j;do j=e.uniqueId(N);while(b.hasNode(j));return k.dummy=S,b.setNode(j,k),j}function i(b){var S=new t().setGraph(b.graph());return e.forEach(b.nodes(),function(k){S.setNode(k,b.node(k))}),e.forEach(b.edges(),function(k){var N=S.edge(k.v,k.w)||{weight:0,minlen:1},j=b.edge(k);S.setEdge(k.v,k.w,{weight:N.weight+j.weight,minlen:Math.max(N.minlen,j.minlen)})}),S}function o(b){var S=new t({multigraph:b.isMultigraph()}).setGraph(b.graph());return e.forEach(b.nodes(),function(k){b.children(k).length||S.setNode(k,b.node(k))}),e.forEach(b.edges(),function(k){S.setEdge(k,b.edge(k))}),S}function a(b){var S=e.map(b.nodes(),function(k){var N={};return e.forEach(b.outEdges(k),function(j){N[j.w]=(N[j.w]||0)+b.edge(j).weight}),N});return e.zipObject(b.nodes(),S)}function u(b){var S=e.map(b.nodes(),function(k){var N={};return e.forEach(b.inEdges(k),function(j){N[j.v]=(N[j.v]||0)+b.edge(j).weight}),N});return e.zipObject(b.nodes(),S)}function c(b,S){var k=b.x,N=b.y,j=S.x-k,A=S.y-N,M=b.width/2,P=b.height/2;if(!j&&!A)throw new Error("Not possible to find intersection inside of the rectangle");var O,D;return Math.abs(A)*M>Math.abs(j)*P?(A<0&&(P=-P),O=P*j/A,D=P):(j<0&&(M=-M),O=M,D=M*A/j),{x:k+O,y:N+D}}function f(b){var S=e.map(e.range(y(b)+1),function(){return[]});return e.forEach(b.nodes(),function(k){var N=b.node(k),j=N.rank;e.isUndefined(j)||(S[j][N.order]=k)}),S}function p(b){var S=e.min(e.map(b.nodes(),function(k){return b.node(k).rank}));e.forEach(b.nodes(),function(k){var N=b.node(k);e.has(N,"rank")&&(N.rank-=S)})}function d(b){var S=e.min(e.map(b.nodes(),function(A){return b.node(A).rank})),k=[];e.forEach(b.nodes(),function(A){var M=b.node(A).rank-S;k[M]||(k[M]=[]),k[M].push(A)});var N=0,j=b.graph().nodeRankFactor;e.forEach(k,function(A,M){e.isUndefined(A)&&M%j!==0?--N:N&&e.forEach(A,function(P){b.node(P).rank+=N})})}function g(b,S,k,N){var j={width:0,height:0};return arguments.length>=4&&(j.rank=k,j.order=N),r(b,"border",j,S)}function y(b){return e.max(e.map(b.nodes(),function(S){var k=b.node(S).rank;if(!e.isUndefined(k))return k}))}function w(b,S){var k={lhs:[],rhs:[]};return e.forEach(b,function(N){S(N)?k.lhs.push(N):k.rhs.push(N)}),k}function E(b,S){var k=e.now();try{return S()}finally{console.log(b+" time: "+(e.now()-k)+"ms")}}function _(b,S){return S()}return Gg}var Yg,EE;function f5(){if(EE)return Yg;EE=1;var e=at(),t=fn();Yg={run:r,undo:o};function r(a){a.graph().dummyChains=[],e.forEach(a.edges(),function(u){i(a,u)})}function i(a,u){var c=u.v,f=a.node(c).rank,p=u.w,d=a.node(p).rank,g=u.name,y=a.edge(u),w=y.labelRank;if(d!==f+1){a.removeEdge(u);var E,_,b;for(b=0,++f;f<d;++b,++f)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:u,rank:f},E=t.addDummyNode(a,"edge",_,"_d"),f===w&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),a.setEdge(c,E,{weight:y.weight},g),b===0&&a.graph().dummyChains.push(E),c=E;a.setEdge(c,p,{weight:y.weight},g)}}function o(a){e.forEach(a.graph().dummyChains,function(u){var c=a.node(u),f=c.edgeLabel,p;for(a.setEdge(c.edgeObj,f);c.dummy;)p=a.successors(u)[0],a.removeNode(u),f.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(f.x=c.x,f.y=c.y,f.width=c.width,f.height=c.height),u=p,c=a.node(u)})}return Yg}var Kg,NE;function Au(){if(NE)return Kg;NE=1;var e=at();Kg={longestPath:t,slack:r};function t(i){var o={};function a(u){var c=i.node(u);if(e.has(o,u))return c.rank;o[u]=!0;var f=e.min(e.map(i.outEdges(u),function(p){return a(p.w)-i.edge(p).minlen}));return(f===Number.POSITIVE_INFINITY||f===void 0||f===null)&&(f=0),c.rank=f}e.forEach(i.sources(),a)}function r(i,o){return i.node(o.w).rank-i.node(o.v).rank-i.edge(o).minlen}return Kg}var Xg,CE;function tT(){if(CE)return Xg;CE=1;var e=at(),t=tr().Graph,r=Au().slack;Xg=i;function i(c){var f=new t({directed:!1}),p=c.nodes()[0],d=c.nodeCount();f.setNode(p,{});for(var g,y;o(f,c)<d;)g=a(f,c),y=f.hasNode(g.v)?r(c,g):-r(c,g),u(f,c,y);return f}function o(c,f){function p(d){e.forEach(f.nodeEdges(d),function(g){var y=g.v,w=d===y?g.w:y;!c.hasNode(w)&&!r(f,g)&&(c.setNode(w,{}),c.setEdge(d,w,{}),p(w))})}return e.forEach(c.nodes(),p),c.nodeCount()}function a(c,f){return e.minBy(f.edges(),function(p){if(c.hasNode(p.v)!==c.hasNode(p.w))return r(f,p)})}function u(c,f,p){e.forEach(c.nodes(),function(d){f.node(d).rank+=p})}return Xg}var Qg,jE;function h5(){if(jE)return Qg;jE=1;var e=at(),t=tT(),r=Au().slack,i=Au().longestPath,o=tr().alg.preorder,a=tr().alg.postorder,u=fn().simplify;Qg=c,c.initLowLimValues=g,c.initCutValues=f,c.calcCutValue=d,c.leaveEdge=w,c.enterEdge=E,c.exchangeEdges=_;function c(N){N=u(N),i(N);var j=t(N);g(j),f(j,N);for(var A,M;A=w(j);)M=E(j,N,A),_(j,N,A,M)}function f(N,j){var A=a(N,N.nodes());A=A.slice(0,A.length-1),e.forEach(A,function(M){p(N,j,M)})}function p(N,j,A){var M=N.node(A),P=M.parent;N.edge(A,P).cutvalue=d(N,j,A)}function d(N,j,A){var M=N.node(A),P=M.parent,O=!0,D=j.edge(A,P),L=0;return D||(O=!1,D=j.edge(P,A)),L=D.weight,e.forEach(j.nodeEdges(A),function(U){var V=U.v===A,z=V?U.w:U.v;if(z!==P){var C=V===O,F=j.edge(U).weight;if(L+=C?F:-F,S(N,A,z)){var $=N.edge(A,z).cutvalue;L+=C?-$:$}}}),L}function g(N,j){arguments.length<2&&(j=N.nodes()[0]),y(N,{},1,j)}function y(N,j,A,M,P){var O=A,D=N.node(M);return j[M]=!0,e.forEach(N.neighbors(M),function(L){e.has(j,L)||(A=y(N,j,A,L,M))}),D.low=O,D.lim=A++,P?D.parent=P:delete D.parent,A}function w(N){return e.find(N.edges(),function(j){return N.edge(j).cutvalue<0})}function E(N,j,A){var M=A.v,P=A.w;j.hasEdge(M,P)||(M=A.w,P=A.v);var O=N.node(M),D=N.node(P),L=O,U=!1;O.lim>D.lim&&(L=D,U=!0);var V=e.filter(j.edges(),function(z){return U===k(N,N.node(z.v),L)&&U!==k(N,N.node(z.w),L)});return e.minBy(V,function(z){return r(j,z)})}function _(N,j,A,M){var P=A.v,O=A.w;N.removeEdge(P,O),N.setEdge(M.v,M.w,{}),g(N),f(N,j),b(N,j)}function b(N,j){var A=e.find(N.nodes(),function(P){return!j.node(P).parent}),M=o(N,A);M=M.slice(1),e.forEach(M,function(P){var O=N.node(P).parent,D=j.edge(P,O),L=!1;D||(D=j.edge(O,P),L=!0),j.node(P).rank=j.node(O).rank+(L?D.minlen:-D.minlen)})}function S(N,j,A){return N.hasEdge(j,A)}function k(N,j,A){return A.low<=j.lim&&j.lim<=A.lim}return Qg}var Zg,TE;function p5(){if(TE)return Zg;TE=1;var e=Au(),t=e.longestPath,r=tT(),i=h5();Zg=o;function o(f){switch(f.graph().ranker){case"network-simplex":c(f);break;case"tight-tree":u(f);break;case"longest-path":a(f);break;default:c(f)}}var a=t;function u(f){t(f),r(f)}function c(f){i(f)}return Zg}var Jg,RE;function m5(){if(RE)return Jg;RE=1;var e=at();Jg=t;function t(o){var a=i(o);e.forEach(o.graph().dummyChains,function(u){for(var c=o.node(u),f=c.edgeObj,p=r(o,a,f.v,f.w),d=p.path,g=p.lca,y=0,w=d[y],E=!0;u!==f.w;){if(c=o.node(u),E){for(;(w=d[y])!==g&&o.node(w).maxRank<c.rank;)y++;w===g&&(E=!1)}if(!E){for(;y<d.length-1&&o.node(w=d[y+1]).minRank<=c.rank;)y++;w=d[y]}o.setParent(u,w),u=o.successors(u)[0]}})}function r(o,a,u,c){var f=[],p=[],d=Math.min(a[u].low,a[c].low),g=Math.max(a[u].lim,a[c].lim),y,w;y=u;do y=o.parent(y),f.push(y);while(y&&(a[y].low>d||g>a[y].lim));for(w=y,y=c;(y=o.parent(y))!==w;)p.push(y);return{path:f.concat(p.reverse()),lca:w}}function i(o){var a={},u=0;function c(f){var p=u;e.forEach(o.children(f),c),a[f]={low:p,lim:u++}}return e.forEach(o.children(),c),a}return Jg}var ev,AE;function g5(){if(AE)return ev;AE=1;var e=at(),t=fn();ev={run:r,cleanup:u};function r(c){var f=t.addDummyNode(c,"root",{},"_root"),p=o(c),d=e.max(e.values(p))-1,g=2*d+1;c.graph().nestingRoot=f,e.forEach(c.edges(),function(w){c.edge(w).minlen*=g});var y=a(c)+1;e.forEach(c.children(),function(w){i(c,f,g,y,d,p,w)}),c.graph().nodeRankFactor=g}function i(c,f,p,d,g,y,w){var E=c.children(w);if(!E.length){w!==f&&c.setEdge(f,w,{weight:0,minlen:p});return}var _=t.addBorderNode(c,"_bt"),b=t.addBorderNode(c,"_bb"),S=c.node(w);c.setParent(_,w),S.borderTop=_,c.setParent(b,w),S.borderBottom=b,e.forEach(E,function(k){i(c,f,p,d,g,y,k);var N=c.node(k),j=N.borderTop?N.borderTop:k,A=N.borderBottom?N.borderBottom:k,M=N.borderTop?d:2*d,P=j!==A?1:g-y[w]+1;c.setEdge(_,j,{weight:M,minlen:P,nestingEdge:!0}),c.setEdge(A,b,{weight:M,minlen:P,nestingEdge:!0})}),c.parent(w)||c.setEdge(f,_,{weight:0,minlen:g+y[w]})}function o(c){var f={};function p(d,g){var y=c.children(d);y&&y.length&&e.forEach(y,function(w){p(w,g+1)}),f[d]=g}return e.forEach(c.children(),function(d){p(d,1)}),f}function a(c){return e.reduce(c.edges(),function(f,p){return f+c.edge(p).weight},0)}function u(c){var f=c.graph();c.removeNode(f.nestingRoot),delete f.nestingRoot,e.forEach(c.edges(),function(p){var d=c.edge(p);d.nestingEdge&&c.removeEdge(p)})}return ev}var tv,IE;function v5(){if(IE)return tv;IE=1;var e=at(),t=fn();tv=r;function r(o){function a(u){var c=o.children(u),f=o.node(u);if(c.length&&e.forEach(c,a),e.has(f,"minRank")){f.borderLeft=[],f.borderRight=[];for(var p=f.minRank,d=f.maxRank+1;p<d;++p)i(o,"borderLeft","_bl",u,f,p),i(o,"borderRight","_br",u,f,p)}}e.forEach(o.children(),a)}function i(o,a,u,c,f,p){var d={width:0,height:0,rank:p,borderType:a},g=f[a][p-1],y=t.addDummyNode(o,"border",d,u);f[a][p]=y,o.setParent(y,c),g&&o.setEdge(g,y,{weight:1})}return tv}var nv,ME;function y5(){if(ME)return nv;ME=1;var e=at();nv={adjust:t,undo:r};function t(p){var d=p.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&i(p)}function r(p){var d=p.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&a(p),(d==="lr"||d==="rl")&&(c(p),i(p))}function i(p){e.forEach(p.nodes(),function(d){o(p.node(d))}),e.forEach(p.edges(),function(d){o(p.edge(d))})}function o(p){var d=p.width;p.width=p.height,p.height=d}function a(p){e.forEach(p.nodes(),function(d){u(p.node(d))}),e.forEach(p.edges(),function(d){var g=p.edge(d);e.forEach(g.points,u),e.has(g,"y")&&u(g)})}function u(p){p.y=-p.y}function c(p){e.forEach(p.nodes(),function(d){f(p.node(d))}),e.forEach(p.edges(),function(d){var g=p.edge(d);e.forEach(g.points,f),e.has(g,"x")&&f(g)})}function f(p){var d=p.x;p.x=p.y,p.y=d}return nv}var rv,OE;function w5(){if(OE)return rv;OE=1;var e=at();rv=t;function t(r){var i={},o=e.filter(r.nodes(),function(p){return!r.children(p).length}),a=e.max(e.map(o,function(p){return r.node(p).rank})),u=e.map(e.range(a+1),function(){return[]});function c(p){if(!e.has(i,p)){i[p]=!0;var d=r.node(p);u[d.rank].push(p),e.forEach(r.successors(p),c)}}var f=e.sortBy(o,function(p){return r.node(p).rank});return e.forEach(f,c),u}return rv}var sv,PE;function x5(){if(PE)return sv;PE=1;var e=at();sv=t;function t(i,o){for(var a=0,u=1;u<o.length;++u)a+=r(i,o[u-1],o[u]);return a}function r(i,o,a){for(var u=e.zipObject(a,e.map(a,function(y,w){return w})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(i.outEdges(y),function(w){return{pos:u[w.w],weight:i.edge(w).weight}}),"pos")}),!0),f=1;f<a.length;)f<<=1;var p=2*f-1;f-=1;var d=e.map(new Array(p),function(){return 0}),g=0;return e.forEach(c.forEach(function(y){var w=y.pos+f;d[w]+=y.weight;for(var E=0;w>0;)w%2&&(E+=d[w+1]),w=w-1>>1,d[w]+=y.weight;g+=y.weight*E})),g}return sv}var iv,LE;function _5(){if(LE)return iv;LE=1;var e=at();iv=t;function t(r,i){return e.map(i,function(o){var a=r.inEdges(o);if(a.length){var u=e.reduce(a,function(c,f){var p=r.edge(f),d=r.node(f.v);return{sum:c.sum+p.weight*d.order,weight:c.weight+p.weight}},{sum:0,weight:0});return{v:o,barycenter:u.sum/u.weight,weight:u.weight}}else return{v:o}})}return iv}var ov,$E;function b5(){if($E)return ov;$E=1;var e=at();ov=t;function t(o,a){var u={};e.forEach(o,function(f,p){var d=u[f.v]={indegree:0,in:[],out:[],vs:[f.v],i:p};e.isUndefined(f.barycenter)||(d.barycenter=f.barycenter,d.weight=f.weight)}),e.forEach(a.edges(),function(f){var p=u[f.v],d=u[f.w];!e.isUndefined(p)&&!e.isUndefined(d)&&(d.indegree++,p.out.push(u[f.w]))});var c=e.filter(u,function(f){return!f.indegree});return r(c)}function r(o){var a=[];function u(p){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(p.barycenter)||d.barycenter>=p.barycenter)&&i(p,d)}}function c(p){return function(d){d.in.push(p),--d.indegree===0&&o.push(d)}}for(;o.length;){var f=o.pop();a.push(f),e.forEach(f.in.reverse(),u(f)),e.forEach(f.out,c(f))}return e.map(e.filter(a,function(p){return!p.merged}),function(p){return e.pick(p,["vs","i","barycenter","weight"])})}function i(o,a){var u=0,c=0;o.weight&&(u+=o.barycenter*o.weight,c+=o.weight),a.weight&&(u+=a.barycenter*a.weight,c+=a.weight),o.vs=a.vs.concat(o.vs),o.barycenter=u/c,o.weight=c,o.i=Math.min(a.i,o.i),a.merged=!0}return ov}var av,qE;function S5(){if(qE)return av;qE=1;var e=at(),t=fn();av=r;function r(a,u){var c=t.partition(a,function(_){return e.has(_,"barycenter")}),f=c.lhs,p=e.sortBy(c.rhs,function(_){return-_.i}),d=[],g=0,y=0,w=0;f.sort(o(!!u)),w=i(d,p,w),e.forEach(f,function(_){w+=_.vs.length,d.push(_.vs),g+=_.barycenter*_.weight,y+=_.weight,w=i(d,p,w)});var E={vs:e.flatten(d,!0)};return y&&(E.barycenter=g/y,E.weight=y),E}function i(a,u,c){for(var f;u.length&&(f=e.last(u)).i<=c;)u.pop(),a.push(f.vs),c++;return c}function o(a){return function(u,c){return u.barycenter<c.barycenter?-1:u.barycenter>c.barycenter?1:a?c.i-u.i:u.i-c.i}}return av}var lv,DE;function k5(){if(DE)return lv;DE=1;var e=at(),t=_5(),r=b5(),i=S5();lv=o;function o(c,f,p,d){var g=c.children(f),y=c.node(f),w=y?y.borderLeft:void 0,E=y?y.borderRight:void 0,_={};w&&(g=e.filter(g,function(A){return A!==w&&A!==E}));var b=t(c,g);e.forEach(b,function(A){if(c.children(A.v).length){var M=o(c,A.v,p,d);_[A.v]=M,e.has(M,"barycenter")&&u(A,M)}});var S=r(b,p);a(S,_);var k=i(S,d);if(w&&(k.vs=e.flatten([w,k.vs,E],!0),c.predecessors(w).length)){var N=c.node(c.predecessors(w)[0]),j=c.node(c.predecessors(E)[0]);e.has(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+N.order+j.order)/(k.weight+2),k.weight+=2}return k}function a(c,f){e.forEach(c,function(p){p.vs=e.flatten(p.vs.map(function(d){return f[d]?f[d].vs:d}),!0)})}function u(c,f){e.isUndefined(c.barycenter)?(c.barycenter=f.barycenter,c.weight=f.weight):(c.barycenter=(c.barycenter*c.weight+f.barycenter*f.weight)/(c.weight+f.weight),c.weight+=f.weight)}return lv}var uv,FE;function E5(){if(FE)return uv;FE=1;var e=at(),t=tr().Graph;uv=r;function r(o,a,u){var c=i(o),f=new t({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(p){return o.node(p)});return e.forEach(o.nodes(),function(p){var d=o.node(p),g=o.parent(p);(d.rank===a||d.minRank<=a&&a<=d.maxRank)&&(f.setNode(p),f.setParent(p,g||c),e.forEach(o[u](p),function(y){var w=y.v===p?y.w:y.v,E=f.edge(w,p),_=e.isUndefined(E)?0:E.weight;f.setEdge(w,p,{weight:o.edge(y).weight+_})}),e.has(d,"minRank")&&f.setNode(p,{borderLeft:d.borderLeft[a],borderRight:d.borderRight[a]}))}),f}function i(o){for(var a;o.hasNode(a=e.uniqueId("_root")););return a}return uv}var cv,zE;function N5(){if(zE)return cv;zE=1;var e=at();cv=t;function t(r,i,o){var a={},u;e.forEach(o,function(c){for(var f=r.parent(c),p,d;f;){if(p=r.parent(f),p?(d=a[p],a[p]=f):(d=u,u=f),d&&d!==f){i.setEdge(d,f);return}f=p}})}return cv}var dv,BE;function C5(){if(BE)return dv;BE=1;var e=at(),t=w5(),r=x5(),i=k5(),o=E5(),a=N5(),u=tr().Graph,c=fn();dv=f;function f(y){var w=c.maxRank(y),E=p(y,e.range(1,w+1),"inEdges"),_=p(y,e.range(w-1,-1,-1),"outEdges"),b=t(y);g(y,b);for(var S=Number.POSITIVE_INFINITY,k,N=0,j=0;j<4;++N,++j){d(N%2?E:_,N%4>=2),b=c.buildLayerMatrix(y);var A=r(y,b);A<S&&(j=0,k=e.cloneDeep(b),S=A)}g(y,k)}function p(y,w,E){return e.map(w,function(_){return o(y,_,E)})}function d(y,w){var E=new u;e.forEach(y,function(_){var b=_.graph().root,S=i(_,b,E,w);e.forEach(S.vs,function(k,N){_.node(k).order=N}),a(_,E,S.vs)})}function g(y,w){e.forEach(w,function(E){e.forEach(E,function(_,b){y.node(_).order=b})})}return dv}var fv,UE;function j5(){if(UE)return fv;UE=1;var e=at(),t=tr().Graph,r=fn();fv={positionX:E,findType1Conflicts:i,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:f,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:g,balance:w};function i(S,k){var N={};function j(A,M){var P=0,O=0,D=A.length,L=e.last(M);return e.forEach(M,function(U,V){var z=a(S,U),C=z?S.node(z).order:D;(z||U===L)&&(e.forEach(M.slice(O,V+1),function(F){e.forEach(S.predecessors(F),function($){var re=S.node($),J=re.order;(J<P||C<J)&&!(re.dummy&&S.node(F).dummy)&&u(N,$,F)})}),O=V+1,P=C)}),M}return e.reduce(k,j),N}function o(S,k){var N={};function j(M,P,O,D,L){var U;e.forEach(e.range(P,O),function(V){U=M[V],S.node(U).dummy&&e.forEach(S.predecessors(U),function(z){var C=S.node(z);C.dummy&&(C.order<D||C.order>L)&&u(N,z,U)})})}function A(M,P){var O=-1,D,L=0;return e.forEach(P,function(U,V){if(S.node(U).dummy==="border"){var z=S.predecessors(U);z.length&&(D=S.node(z[0]).order,j(P,L,V,O,D),L=V,O=D)}j(P,L,P.length,D,M.length)}),P}return e.reduce(k,A),N}function a(S,k){if(S.node(k).dummy)return e.find(S.predecessors(k),function(N){return S.node(N).dummy})}function u(S,k,N){if(k>N){var j=k;k=N,N=j}var A=S[k];A||(S[k]=A={}),A[N]=!0}function c(S,k,N){if(k>N){var j=k;k=N,N=j}return e.has(S[k],N)}function f(S,k,N,j){var A={},M={},P={};return e.forEach(k,function(O){e.forEach(O,function(D,L){A[D]=D,M[D]=D,P[D]=L})}),e.forEach(k,function(O){var D=-1;e.forEach(O,function(L){var U=j(L);if(U.length){U=e.sortBy(U,function($){return P[$]});for(var V=(U.length-1)/2,z=Math.floor(V),C=Math.ceil(V);z<=C;++z){var F=U[z];M[L]===L&&D<P[F]&&!c(N,L,F)&&(M[F]=L,M[L]=A[L]=A[F],D=P[F])}}})}),{root:A,align:M}}function p(S,k,N,j,A){var M={},P=d(S,k,N,A),O=A?"borderLeft":"borderRight";function D(V,z){for(var C=P.nodes(),F=C.pop(),$={};F;)$[F]?V(F):($[F]=!0,C.push(F),C=C.concat(z(F))),F=C.pop()}function L(V){M[V]=P.inEdges(V).reduce(function(z,C){return Math.max(z,M[C.v]+P.edge(C))},0)}function U(V){var z=P.outEdges(V).reduce(function(F,$){return Math.min(F,M[$.w]-P.edge($))},Number.POSITIVE_INFINITY),C=S.node(V);z!==Number.POSITIVE_INFINITY&&C.borderType!==O&&(M[V]=Math.max(M[V],z))}return D(L,P.predecessors.bind(P)),D(U,P.successors.bind(P)),e.forEach(j,function(V){M[V]=M[N[V]]}),M}function d(S,k,N,j){var A=new t,M=S.graph(),P=_(M.nodesep,M.edgesep,j);return e.forEach(k,function(O){var D;e.forEach(O,function(L){var U=N[L];if(A.setNode(U),D){var V=N[D],z=A.edge(V,U);A.setEdge(V,U,Math.max(P(S,L,D),z||0))}D=L})}),A}function g(S,k){return e.minBy(e.values(k),function(N){var j=Number.NEGATIVE_INFINITY,A=Number.POSITIVE_INFINITY;return e.forIn(N,function(M,P){var O=b(S,P)/2;j=Math.max(M+O,j),A=Math.min(M-O,A)}),j-A})}function y(S,k){var N=e.values(k),j=e.min(N),A=e.max(N);e.forEach(["u","d"],function(M){e.forEach(["l","r"],function(P){var O=M+P,D=S[O],L;if(D!==k){var U=e.values(D);L=P==="l"?j-e.min(U):A-e.max(U),L&&(S[O]=e.mapValues(D,function(V){return V+L}))}})})}function w(S,k){return e.mapValues(S.ul,function(N,j){if(k)return S[k.toLowerCase()][j];var A=e.sortBy(e.map(S,j));return(A[1]+A[2])/2})}function E(S){var k=r.buildLayerMatrix(S),N=e.merge(i(S,k),o(S,k)),j={},A;e.forEach(["u","d"],function(P){A=P==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(O){O==="r"&&(A=e.map(A,function(V){return e.values(V).reverse()}));var D=(P==="u"?S.predecessors:S.successors).bind(S),L=f(S,A,N,D),U=p(S,A,L.root,L.align,O==="r");O==="r"&&(U=e.mapValues(U,function(V){return-V})),j[P+O]=U})});var M=g(S,j);return y(j,M),w(j,S.graph().align)}function _(S,k,N){return function(j,A,M){var P=j.node(A),O=j.node(M),D=0,L;if(D+=P.width/2,e.has(P,"labelpos"))switch(P.labelpos.toLowerCase()){case"l":L=-P.width/2;break;case"r":L=P.width/2;break}if(L&&(D+=N?L:-L),L=0,D+=(P.dummy?k:S)/2,D+=(O.dummy?k:S)/2,D+=O.width/2,e.has(O,"labelpos"))switch(O.labelpos.toLowerCase()){case"l":L=O.width/2;break;case"r":L=-O.width/2;break}return L&&(D+=N?L:-L),L=0,D}}function b(S,k){return S.node(k).width}return fv}var hv,HE;function T5(){if(HE)return hv;HE=1;var e=at(),t=fn(),r=j5().positionX;hv=i;function i(a){a=t.asNonCompoundGraph(a),o(a),e.forEach(r(a),function(u,c){a.node(c).x=u})}function o(a){var u=t.buildLayerMatrix(a),c=a.graph().ranksep,f=0;e.forEach(u,function(p){var d=e.max(e.map(p,function(g){return a.node(g).height}));e.forEach(p,function(g){a.node(g).y=f+d/2}),f+=d+c})}return hv}var pv,WE;function R5(){if(WE)return pv;WE=1;var e=at(),t=d5(),r=f5(),i=p5(),o=fn().normalizeRanks,a=m5(),u=fn().removeEmptyRanks,c=g5(),f=v5(),p=y5(),d=C5(),g=T5(),y=fn(),w=tr().Graph;pv=E;function E(q,Q){var ne=Q&&Q.debugTiming?y.time:y.notime;ne("layout",function(){var ae=ne(" buildLayoutGraph",function(){return D(q)});ne(" runLayout",function(){_(ae,ne)}),ne(" updateInputGraph",function(){b(q,ae)})})}function _(q,Q){Q(" makeSpaceForEdgeLabels",function(){L(q)}),Q(" removeSelfEdges",function(){W(q)}),Q(" acyclic",function(){t.run(q)}),Q(" nestingGraph.run",function(){c.run(q)}),Q(" rank",function(){i(y.asNonCompoundGraph(q))}),Q(" injectEdgeLabelProxies",function(){U(q)}),Q(" removeEmptyRanks",function(){u(q)}),Q(" nestingGraph.cleanup",function(){c.cleanup(q)}),Q(" normalizeRanks",function(){o(q)}),Q(" assignRankMinMax",function(){V(q)}),Q(" removeEdgeLabelProxies",function(){z(q)}),Q(" normalize.run",function(){r.run(q)}),Q(" parentDummyChains",function(){a(q)}),Q(" addBorderSegments",function(){f(q)}),Q(" order",function(){d(q)}),Q(" insertSelfEdges",function(){Z(q)}),Q(" adjustCoordinateSystem",function(){p.adjust(q)}),Q(" position",function(){g(q)}),Q(" positionSelfEdges",function(){I(q)}),Q(" removeBorderNodes",function(){J(q)}),Q(" normalize.undo",function(){r.undo(q)}),Q(" fixupEdgeLabelCoords",function(){$(q)}),Q(" undoCoordinateSystem",function(){p.undo(q)}),Q(" translateGraph",function(){C(q)}),Q(" assignNodeIntersects",function(){F(q)}),Q(" reversePoints",function(){re(q)}),Q(" acyclic.undo",function(){t.undo(q)})}function b(q,Q){e.forEach(q.nodes(),function(ne){var ae=q.node(ne),fe=Q.node(ne);ae&&(ae.x=fe.x,ae.y=fe.y,Q.children(ne).length&&(ae.width=fe.width,ae.height=fe.height))}),e.forEach(q.edges(),function(ne){var ae=q.edge(ne),fe=Q.edge(ne);ae.points=fe.points,e.has(fe,"x")&&(ae.x=fe.x,ae.y=fe.y)}),q.graph().width=Q.graph().width,q.graph().height=Q.graph().height}var S=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},N=["acyclicer","ranker","rankdir","align"],j=["width","height"],A={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],P={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},O=["labelpos"];function D(q){var Q=new w({multigraph:!0,compound:!0}),ne=K(q.graph());return Q.setGraph(e.merge({},k,G(ne,S),e.pick(ne,N))),e.forEach(q.nodes(),function(ae){var fe=K(q.node(ae));Q.setNode(ae,e.defaults(G(fe,j),A)),Q.setParent(ae,q.parent(ae))}),e.forEach(q.edges(),function(ae){var fe=K(q.edge(ae));Q.setEdge(ae,e.merge({},P,G(fe,M),e.pick(fe,O)))}),Q}function L(q){var Q=q.graph();Q.ranksep/=2,e.forEach(q.edges(),function(ne){var ae=q.edge(ne);ae.minlen*=2,ae.labelpos.toLowerCase()!=="c"&&(Q.rankdir==="TB"||Q.rankdir==="BT"?ae.width+=ae.labeloffset:ae.height+=ae.labeloffset)})}function U(q){e.forEach(q.edges(),function(Q){var ne=q.edge(Q);if(ne.width&&ne.height){var ae=q.node(Q.v),fe=q.node(Q.w),te={rank:(fe.rank-ae.rank)/2+ae.rank,e:Q};y.addDummyNode(q,"edge-proxy",te,"_ep")}})}function V(q){var Q=0;e.forEach(q.nodes(),function(ne){var ae=q.node(ne);ae.borderTop&&(ae.minRank=q.node(ae.borderTop).rank,ae.maxRank=q.node(ae.borderBottom).rank,Q=e.max(Q,ae.maxRank))}),q.graph().maxRank=Q}function z(q){e.forEach(q.nodes(),function(Q){var ne=q.node(Q);ne.dummy==="edge-proxy"&&(q.edge(ne.e).labelRank=ne.rank,q.removeNode(Q))})}function C(q){var Q=Number.POSITIVE_INFINITY,ne=0,ae=Number.POSITIVE_INFINITY,fe=0,te=q.graph(),ce=te.marginx||0,Ce=te.marginy||0;function ve(Re){var ye=Re.x,Ee=Re.y,Ye=Re.width,we=Re.height;Q=Math.min(Q,ye-Ye/2),ne=Math.max(ne,ye+Ye/2),ae=Math.min(ae,Ee-we/2),fe=Math.max(fe,Ee+we/2)}e.forEach(q.nodes(),function(Re){ve(q.node(Re))}),e.forEach(q.edges(),function(Re){var ye=q.edge(Re);e.has(ye,"x")&&ve(ye)}),Q-=ce,ae-=Ce,e.forEach(q.nodes(),function(Re){var ye=q.node(Re);ye.x-=Q,ye.y-=ae}),e.forEach(q.edges(),function(Re){var ye=q.edge(Re);e.forEach(ye.points,function(Ee){Ee.x-=Q,Ee.y-=ae}),e.has(ye,"x")&&(ye.x-=Q),e.has(ye,"y")&&(ye.y-=ae)}),te.width=ne-Q+ce,te.height=fe-ae+Ce}function F(q){e.forEach(q.edges(),function(Q){var ne=q.edge(Q),ae=q.node(Q.v),fe=q.node(Q.w),te,ce;ne.points?(te=ne.points[0],ce=ne.points[ne.points.length-1]):(ne.points=[],te=fe,ce=ae),ne.points.unshift(y.intersectRect(ae,te)),ne.points.push(y.intersectRect(fe,ce))})}function $(q){e.forEach(q.edges(),function(Q){var ne=q.edge(Q);if(e.has(ne,"x"))switch((ne.labelpos==="l"||ne.labelpos==="r")&&(ne.width-=ne.labeloffset),ne.labelpos){case"l":ne.x-=ne.width/2+ne.labeloffset;break;case"r":ne.x+=ne.width/2+ne.labeloffset;break}})}function re(q){e.forEach(q.edges(),function(Q){var ne=q.edge(Q);ne.reversed&&ne.points.reverse()})}function J(q){e.forEach(q.nodes(),function(Q){if(q.children(Q).length){var ne=q.node(Q),ae=q.node(ne.borderTop),fe=q.node(ne.borderBottom),te=q.node(e.last(ne.borderLeft)),ce=q.node(e.last(ne.borderRight));ne.width=Math.abs(ce.x-te.x),ne.height=Math.abs(fe.y-ae.y),ne.x=te.x+ne.width/2,ne.y=ae.y+ne.height/2}}),e.forEach(q.nodes(),function(Q){q.node(Q).dummy==="border"&&q.removeNode(Q)})}function W(q){e.forEach(q.edges(),function(Q){if(Q.v===Q.w){var ne=q.node(Q.v);ne.selfEdges||(ne.selfEdges=[]),ne.selfEdges.push({e:Q,label:q.edge(Q)}),q.removeEdge(Q)}})}function Z(q){var Q=y.buildLayerMatrix(q);e.forEach(Q,function(ne){var ae=0;e.forEach(ne,function(fe,te){var ce=q.node(fe);ce.order=te+ae,e.forEach(ce.selfEdges,function(Ce){y.addDummyNode(q,"selfedge",{width:Ce.label.width,height:Ce.label.height,rank:ce.rank,order:te+ ++ae,e:Ce.e,label:Ce.label},"_se")}),delete ce.selfEdges})})}function I(q){e.forEach(q.nodes(),function(Q){var ne=q.node(Q);if(ne.dummy==="selfedge"){var ae=q.node(ne.e.v),fe=ae.x+ae.width/2,te=ae.y,ce=ne.x-fe,Ce=ae.height/2;q.setEdge(ne.e,ne.label),q.removeNode(Q),ne.label.points=[{x:fe+2*ce/3,y:te-Ce},{x:fe+5*ce/6,y:te-Ce},{x:fe+ce,y:te},{x:fe+5*ce/6,y:te+Ce},{x:fe+2*ce/3,y:te+Ce}],ne.label.x=ne.x,ne.label.y=ne.y}})}function G(q,Q){return e.mapValues(e.pick(q,Q),Number)}function K(q){var Q={};return e.forEach(q,function(ne,ae){Q[ae.toLowerCase()]=ne}),Q}return pv}var mv,VE;function A5(){if(VE)return mv;VE=1;var e=at(),t=fn(),r=tr().Graph;mv={debugOrdering:i};function i(o){var a=t.buildLayerMatrix(o),u=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(c){u.setNode(c,{label:c}),u.setParent(c,"layer"+o.node(c).rank)}),e.forEach(o.edges(),function(c){u.setEdge(c.v,c.w,{},c.name)}),e.forEach(a,function(c,f){var p="layer"+f;u.setNode(p,{rank:"same"}),e.reduce(c,function(d,g){return u.setEdge(d,g,{style:"invis"}),g})}),u}return mv}var gv,GE;function I5(){return GE||(GE=1,gv="0.8.5"),gv}var vv,YE;function M5(){return YE||(YE=1,vv={graphlib:tr(),layout:R5(),debug:A5(),util:{time:fn().time,notime:fn().notime},version:I5()}),vv}var O5=M5();const KE=Wv(O5),yo=240,Iu=130,co=74,ic=72,XE=co+ic;function P5(e,t){var i;let r=yo;for(const o of e)r=Math.max(r,((i=t.get(o.id))==null?void 0:i.width)??yo);return r}const nT=420,L5=2;function ja(e){var r;return((r=e.data)==null?void 0:r.sessionId)??"_default"}function $5(e,t){return((t==null?void 0:t.get(e))??0)>0?nT:0}function q5(e,t){const r=(t==null?void 0:t.get(e))??0;return r>0?6+r*36:0}function Ta(e,t,r){const i=t.get(e);return{w:((i==null?void 0:i.width)??yo)+$5(e,r),h:Math.max((i==null?void 0:i.height)??Iu,q5(e,r))}}function D5(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function F5(e,t,r,i,o,a){const u=new KE.graphlib.Graph;u.setDefaultEdgeLabel(()=>({})),u.setGraph({rankdir:r,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(S=>!o.has(S)),f=new Set(c);for(const S of c){const{w:k,h:N}=Ta(S,i,a);u.setNode(S,{width:k,height:N})}for(const S of t)f.has(S.source)&&f.has(S.target)&&u.setEdge(S.source,S.target);KE.layout(u);const p=new Map;let d=1/0,g=1/0,y=-1/0,w=-1/0;for(const S of c){const k=u.node(S);if(!k)continue;const N=i.get(S),j=(N==null?void 0:N.width)??yo,A=(N==null?void 0:N.height)??Iu,M=Ta(S,i,a),P=k.x-M.w/2,O=k.y-M.h/2;p.set(S,{x:P,y:O}),P<d&&(d=P),O<g&&(g=O),P+j>y&&(y=P+j),O+A>w&&(w=O+A)}if(Number.isFinite(d)&&Number.isFinite(g))for(const[S,k]of p)p.set(S,{x:k.x-d,y:k.y-g});const E=Number.isFinite(y)?y-d:0,_=Number.isFinite(w)?w-g:0;let b=null;for(const S of e){const k=o.get(S);if(!k)continue;const N=i.get(S),j=(N==null?void 0:N.width)??yo,A=(N==null?void 0:N.height)??Iu;b=b===null?{minX:k.x,minY:k.y,maxX:k.x+j,maxY:k.y+A}:{minX:Math.min(b.minX,k.x),minY:Math.min(b.minY,k.y),maxX:Math.max(b.maxX,k.x+j),maxY:Math.max(b.maxY,k.y+A)}}return{positions:p,width:E,height:_,pinnedBox:b}}function z5(e,t,r={}){const i=r.direction??"LR",o=r.pinned??new Map,a=r.measured??new Map,u=r.lanes,c=new Map;for(const S of e){const k=ja(S),N=c.get(k);N?N.push(S.id):c.set(k,[S.id])}const p=Array.from(c.keys()).sort().map(S=>({sid:S,...F5(c.get(S),t,i,a,o,u)})),d=P5(e,a),g=r.availableHeight&&r.availableHeight>0?r.availableHeight:Number.POSITIVE_INFINITY,y=S=>{const k=[[]];let N=0;for(const j of p)k.length<S&&N>0&&N+j.height>g&&(k.push([]),N=0),k[k.length-1].push(j),N+=j.height+XE;return k},w=S=>S.reduce((k,N)=>Math.max(k,N.width),0)+nT;let E=y(r.availableWidth?L5:1);E.length>1&&E.reduce((k,N)=>k+w(N),0)+d*(E.length-1)>(r.availableWidth??0)&&(E=y(1));const _=new Map;let b=0;for(const S of E){const k=w(S);let N=0;for(const{positions:j,height:A,pinnedBox:M}of S){for(const[O,D]of j)_.set(O,{x:D.x+b,y:D.y+N});let P=N+A;M&&M.maxY>P&&M.minX<b+k&&b<M.maxX&&(P=M.maxY),N=P+XE}b+=k+d}return e.map(S=>{const k=o.get(S.id);if(k)return{...S,position:k};const N=_.get(S.id);return N?{...S,position:N}:S})}function B5(e,t,r,i,o){const u=co+ic,c=60,f=w=>Ta(w,i,o),p=new Map(e.map(w=>[w.id,ja(w)])),d=[],g=e.map(w=>({id:w.id,pos:r.get(w.id)??t.get(w.id)})).filter(w=>w.pos!=null).sort((w,E)=>w.pos.y-E.pos.y||w.pos.x-E.pos.x||w.id.localeCompare(E.id)),y=[];for(const{id:w,pos:E}of g){const{w:_,h:b}=f(w),S=p.get(w)??"_default";if(r.has(w)){d.push({x:E.x,y:E.y,w:_,h:b,sid:S});continue}let k=E.y;for(let N=0;N<d.length+1;N++){const j=d.find(A=>{const M=A.sid===S?24:c,P=A.sid===S?24:u;return E.x<A.x+A.w+M&&A.x<E.x+_+M&&k<A.y+A.h+P&&A.y<k+b+P});if(!j)break;k=j.y+j.h+(j.sid===S?24:u)}k!==E.y&&(t.set(w,{x:E.x,y:k}),y.push(w)),d.push({x:E.x,y:k,w:_,h:b,sid:S})}return y}function U5(e,t,r,i,o,a){const u=_=>Ta(_,i,a),c=_=>r.get(_)??t.get(_),f=new Map;for(const _ of e){if(!c(_.id))continue;const b=ja(_),S=f.get(b);S?S.push(_):f.set(b,[_])}const p=new Set;for(const[_,b]of f)b.every(S=>o.has(S.id)&&!r.has(S.id))&&p.add(_);const d=new Map,g=[];for(const _ of e){const b=c(_.id);if(!b)continue;const{w:S,h:k}=u(_.id),N=ja(_);p.has(N)?(d.get(N)??d.set(N,[]).get(N)).push(_):g.push({x:b.x,y:b.y,w:S,h:k})}if(d.size===0)return[];const y=co+ic,w=(_,b,S,k)=>g.some(N=>_<N.x+N.w+co&&N.x<_+S+co&&b<N.y+N.h+y&&N.y<b+k+y),E=[];for(const _ of[...d.keys()].sort()){const b=d.get(_);let S=1/0,k=1/0,N=-1/0,j=-1/0;for(const U of b){const V=c(U.id),{w:z,h:C}=u(U.id);S=Math.min(S,V.x),k=Math.min(k,V.y),N=Math.max(N,V.x+z),j=Math.max(j,V.y+C)}const A=N-S,M=j-k,P=[...new Set(g.map(U=>Math.round(U.x)))].sort((U,V)=>U-V),O=P.length?P:[S],D=[0,...g.map(U=>U.y+U.h+y)].sort((U,V)=>U-V);let L=null;e:for(const U of O)for(const V of D){if(V>=k)break;if(!w(U,V,A,M)){L={x:U,y:V};break e}}if(L){const U=L.x-S,V=L.y-k;for(const z of b){const C=c(z.id);t.set(z.id,{x:C.x+U,y:C.y+V})}E.push(_)}for(const U of b){const V=c(U.id),{w:z,h:C}=u(U.id);g.push({x:V.x,y:V.y,w:z,h:C})}}return E}function H5(e,t,r,i,o,a=!1,u){const p=co+ic+1,d=8,g=1.75,y=200,w=.7,E=.01,_=L=>Ta(L,i,u),b=L=>r.get(L)??t.get(L),S=new Map;for(const L of e){if(!b(L.id))continue;const U=ja(L),V=S.get(U);V?V.push(L):S.set(U,[L])}const k=[],N=new Set,j=new Set,A=o.size===0;for(const L of[...S.keys()].sort()){const U=S.get(L);let V=1/0,z=1/0,C=-1/0,F=-1/0,$=!1;for(const Z of U){const I=b(Z.id),{w:G,h:K}=_(Z.id);V=Math.min(V,I.x),z=Math.min(z,I.y),C=Math.max(C,I.x+G),F=Math.max(F,I.y+K),r.has(Z.id)&&($=!0)}const re=C-V,J=F-z;j.add(L);const W=o.get(L);W&&(re>W.w+d||J>W.h+d)&&N.add(L),o.set(L,{w:re,h:J}),k.push({sid:L,members:U.map(Z=>Z.id),x:V,y:z,w:re,h:J,anchored:$,mass:1})}for(const L of[...o.keys()])j.has(L)||o.delete(L);if(a||A)return[];let M=!1;for(let L=0;L<k.length&&!M;L++)for(let U=L+1;U<k.length;U++){const V=k[L],z=k[U];if(!(V.anchored&&z.anchored)&&Math.abs(V.x+V.w/2-(z.x+z.w/2))<(V.w+z.w)/2+61&&Math.abs(V.y+V.h/2-(z.y+z.h/2))<(V.h+z.h)/2+p){M=!0;break}}if(N.size===0&&!M)return[];if(N.size>0)for(const L of k)N.has(L.sid)&&(L.mass=8);else for(const L of k)L.mass=Math.max(1,L.w*L.h/(yo*Iu));const P=new Map(k.map(L=>[L.sid,L.x])),O=new Map(k.map(L=>[L.sid,L.y]));for(let L=0;L<y;L++){const U=new Map,V=new Map;let z=0;for(let C=0;C<k.length;C++)for(let F=C+1;F<k.length;F++){const $=k[C],re=k[F];if($.anchored&&re.anchored)continue;const J=$.x+$.w/2,W=$.y+$.h/2,Z=re.x+re.w/2,I=re.y+re.h/2,G=($.w+re.w)/2+61-Math.abs(J-Z),K=($.h+re.h)/2+p-Math.abs(W-I);if(G<=0||K<=0)continue;const q=(De,Je)=>!De.anchored&&!(Je<0&&De.x<=0),Q=(De,Je)=>!De.anchored&&!(Je<0&&De.y<=0),ne=(De,Je,Xe)=>{const Ot=De===Je,lt=Ot?$.sid<re.sid?-1:1:Math.sign(De-Je);return Xe($,lt)||Xe(re,-lt)?lt:Ot&&(Xe($,-lt)||Xe(re,lt))?-lt:0},ae=ne(J,Z,q),fe=ne(W,I,Q),te=ae!==0,ce=fe!==0;if(!te&&!ce)continue;const Ce=te&&(!ce||G*g<K),[ve,Re,ye,Ee]=Ce?[ae,G,U,q]:[fe,K,V,Q],Ye=Ee($,ve),we=Ee(re,-ve),_e=$.mass,Be=re.mass,it=Ye?we?Be/(_e+Be):1:0,ft=we?Ye?_e/(_e+Be):1:0,Ze=Re*w;ye.set($.sid,(ye.get($.sid)??0)+ve*Ze*it),ye.set(re.sid,(ye.get(re.sid)??0)-ve*Ze*ft),z+=Ze}for(const C of k)C.anchored||(C.x=Math.max(0,C.x+(U.get(C.sid)??0)),C.y=Math.max(0,C.y+(V.get(C.sid)??0)));if(z<E)break}const D=[];for(const L of k){const U=L.x-P.get(L.sid),V=L.y-O.get(L.sid);if(!(Math.abs(U)<1&&Math.abs(V)<1)){for(const z of L.members){if(r.has(z))continue;const C=t.get(z);C&&t.set(z,{x:C.x+U,y:C.y+V})}D.push(L.sid)}}return D}const W5=600;function zv(e,t){return!(e.exitAt!=null&&t-e.exitAt>W5||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function V5(e,t){const r=new Set;for(const i of e.agents.values())zv(i,t)&&r.add(i.id);return r}function G5(e,t,r=0){return e.right+r>t.left&&e.left-r<t.right&&e.bottom+r>t.top&&e.top-r<t.bottom}function Y5(e,t,r=0){if(!e)return!1;for(const i of t)if(G5(e,i,r))return!0;return!1}const rT="sessionGroup";function K5(e,t){var i;if(e.type===rT)return"transparent";const r=(i=e.data)==null?void 0:i.state;return t(r==="err"?"--err":r==="active"?"--inflight":"--ok")}const X5="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1).";function Q5(e){if(e.checkDisabled)return X5;if(e.checking)return"Asking npm for the newest release…";const t=e.latest?`npm has v${e.latest}`:e.latestPending?`npm's latest tag names v${e.latestPending}, which it cannot serve yet`:"npm not reached yet",r=e.checkedAgo?` · checked ${e.checkedAgo}`:"";return`${t}${r} · re-checked periodically · click to check npm now`}function Z5(e){const t=`Version v${e.running}`;return e.checkDisabled?`${t}, update checks are off`:e.checking?`${t}, checking npm for a newer release`:`${t}, check npm for a newer release`}function J5(e){const t=e.kind==="restart"?`v${e.to} is installed and waiting for a restart`:`v${e.to} is available on npm`;return`Version v${e.from}, ${t} — ${e.open?"hide":"show"} the notice`}function eF(e){if(e==null)return{kind:"unknown",lead:"No data yet. Start a Claude Code or Codex session — it appears here as soon as the deck sees its first event.",workspace:null,tail:""};const t=e.trim();return t===""?{kind:"machine",lead:"No data yet. Start a Claude Code or Codex session anywhere on this machine — this deck is unscoped and captures every workspace.",workspace:null,tail:""}:{kind:"scoped",lead:"No data yet. This deck only captures sessions running under",workspace:t,tail:" — start one there, or restart it without --workspace/--scope to watch the whole machine."}}const Bv={kind:"assumed",claude:!0,codex:!0};function tF(e){if(!e||typeof e!="object")return Bv;const t=e.providers;if(!t||typeof t!="object")return Bv;const r=t;return{kind:"reported",claude:r.claude!==!1,codex:r.codex!==!1}}function sT(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}function nF(e){return e.connected?e.paused?{tone:"paused",label:"paused",title:e.held>0?`Connected — ${sT(e.held)} held until you resume (Space)`:"Connected — updates held until you resume (Space)"}:{tone:"live",label:"live",title:"Receiving events"}:{tone:"dead",label:"offline",title:e.paused?"SSE disconnected — and the canvas is paused, so resuming will not bring events back until it reconnects":"SSE disconnected"}}function rF(e){return e.paused?e.held<=0?{label:"Resume",title:"Nothing has arrived since you paused. Resume to follow the canvas again (Space)"}:{label:`Resume · ${e.held} held`,title:`${sT(e.held)} arrived while paused and will be applied in order when you resume (Space)`}:{label:"Pause",title:"Pause live updates — events keep arriving and are applied when you resume (Space)"}}function iT(e,t){return e!==""&&t>0}function sF(e,t,r){return e===""?{active:!1,matched:t,total:r,count:null,empty:!1,message:null,dim:!1}:{active:!0,matched:t,total:r,count:`${t} of ${r}`,empty:t===0,message:t===0?`No agents match “${e}”`:null,dim:iT(e,t)}}const iF="Search agents, tools, model…";function oT(e,t){var i,o,a,u;if(!t)return!0;const r=t.toLowerCase();if(e.label.toLowerCase().includes(r)||(i=e.cwd)!=null&&i.toLowerCase().includes(r)||(o=e.cwdBasename)!=null&&o.toLowerCase().includes(r)||e.sessionId.toLowerCase().includes(r)||(a=e.firstPrompt)!=null&&a.toLowerCase().includes(r)||e.model&&(e.model.toLowerCase().includes(r)||Rs(e.model).toLowerCase().includes(r))||(u=e.provider)!=null&&u.toLowerCase().startsWith(r))return!0;for(const c of e.tools)if(c.name.toLowerCase().includes(r))return!0;return!1}function fa(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const oF={agent:_L,sessionGroup:ML},aT="react-flow__node";function QE(e){var t,r;return!!e&&((r=(t=e.classList)==null?void 0:t.contains)==null?void 0:r.call(t,aT))===!0}function aF(e){try{const t=document.querySelector(`.${aT}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}const lF=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),uF=420,du=18,cF=200,dF=5*6e4,fF=6,hF=2*6e4,Py="agent-dag.layout",Ly="agent-dag.viewport",lT="agent-dag.summariesDismissed",uT="agent-dag.sessionListOpen",cT="agent-dag.detailOpen",dT="agent-dag.usagePanelOpen",ZE="agent-dag.accountsPanelOpen",JE="agent-dag.versionNoticeDismissed",eN="agent-dag.oldNameNoticeDismissed",pF=15*6e4,yv={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:"},tN="agent-dag.autoRestart",nN="agent-dag.bundleReloadedFor";function mF(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(uT)==="1"}catch{return!1}}function gF(e){if(!(typeof window>"u"))try{window.localStorage.setItem(uT,e?"1":"0")}catch{}}function vF(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(cT)==="1"}catch{return!1}}function yF(e){if(!(typeof window>"u"))try{window.localStorage.setItem(cT,e?"1":"0")}catch{}}function wF(){const e=py(dT);return e===null?!0:e==="1"}function xF(e){if(!(typeof window>"u"))try{window.localStorage.setItem(dT,e?"1":"0")}catch{}}function _F(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(lT);if(!e)return new Set;const t=JSON.parse(e);return new Set(Array.isArray(t)?t.filter(r=>typeof r=="string"):[])}catch{return new Set}}function rN(e){if(!(typeof window>"u"))try{const t=Array.from(e),r=t.length>200?t.slice(-200):t;window.localStorage.setItem(lT,JSON.stringify(r))}catch{}}function bF(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const t=window.localStorage.getItem(Py);if(!t)return e;const r=JSON.parse(t);if(!("v"in r)){const o=Object.entries(r).filter(([,a])=>a&&typeof a.x=="number"&&typeof a.y=="number");return{positions:o,pins:o.map(([a])=>a)}}return{positions:Object.entries(r.positions??{}).filter(([,o])=>o&&typeof o.x=="number"&&typeof o.y=="number"),pins:Array.isArray(r.pins)?r.pins:[]}}catch{return e}}function wv(e,t){if(!(typeof window>"u"))try{const r={};for(const[i,o]of e)r[i]=o;for(const[i,o]of t)r[i]=o;window.localStorage.setItem(Py,JSON.stringify({v:2,positions:r,pins:Array.from(t.keys())}))}catch{}}function SF(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Ly);if(!e)return null;const t=JSON.parse(e);return typeof(t==null?void 0:t.x)!="number"||typeof(t==null?void 0:t.y)!="number"||typeof(t==null?void 0:t.zoom)!="number"?null:t}catch{return null}}function kF(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Ly,JSON.stringify(e))}catch{}}function sN(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Py)}catch{}try{window.localStorage.removeItem(Ly)}catch{}}}function EF(e,t){const r=e.agents.get(t);if(!r)return;const i=[];for(const d of e.agents.values())d.sessionId===t&&i.push(d);const o={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:t,label:r.label,cwd:r.cwd,startedAt:r.startedAt,endedAt:r.endedAt,model:r.model,agents:i.map(d=>({id:d.id,kind:d.kind,label:d.label,parentId:d.parentId,state:d.state,startedAt:d.startedAt,endedAt:d.endedAt,model:d.model,cwd:d.cwd,usage:d.usage,prompts:d.prompts,tools:d.tools.map(g=>({id:g.id,name:g.name,inputPreview:g.inputPreview,startedAt:g.startedAt,endedAt:g.endedAt,ok:g.ok,errorPreview:g.errorPreview,usage:g.usage}))}))},a=JSON.stringify(o,null,2),u=new Blob([a],{type:"application/json"}),c=URL.createObjectURL(u),f=document.createElement("a"),p=(r.label||"session").replace(/[^a-z0-9._-]/gi,"_");f.href=c,f.download=`${Gt}-${p}-${t.slice(0,8)}.json`,document.body.appendChild(f),f.click(),document.body.removeChild(f),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const Uv={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Hv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},fT=BC;function NF(e,t){if(!t)return null;const r=new Set([t]);let i=t;for(;i;){const a=e.agents.get(i);if(!(a!=null&&a.parentId)||r.has(a.parentId))break;r.add(a.parentId),i=a.parentId}let o=!0;for(;o;){o=!1;for(const a of e.agents.values())a.parentId&&r.has(a.parentId)&&!r.has(a.id)&&(r.add(a.id),o=!0)}return r}function CF(e,t,r,i,o,a,u,c,f,p,d,g,y,w,E,_,b,S,k){const N=[],j=[],A=new Set;if(a)for(const z of e.agents.values())S.has(z.id)&&oT(z,a)&&A.add(z.id);const M=iT(a,A.size);for(const z of e.agents.values()){if(!S.has(z.id))continue;const C=M&&!A.has(z.id),F=z.exitAt!=null,$=b!=null&&!b.has(z.id),re=[C?"rf-dim":"",F?"rf-exiting":"",$?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,J=u.get(z.id);if(N.push({id:z.id,type:"agent",position:{x:0,y:0},data:{...z,now:t,onOpenContext:k},className:re,...J?{width:J.width,height:J.height}:null}),z.parentId&&S.has(z.parentId)){const W=uy(z.sessionId),Z=a&&!A.has(z.id)&&!A.has(z.parentId),I=F,G=_.size>0&&(_.has(z.id)||_.has(z.parentId)),K=b!=null&&!b.has(z.id)&&!b.has(z.parentId),q=z.state==="active"?2:1.5,Q=G?q+1.5:q,ne=Z||I?.2:K?.12:1,ae=["sess-edge",z.state==="active"?"sess-live":"sess-idle",I?"rf-edge-exiting":"",G?"rf-edge-selected":""].filter(Boolean).join(" ");j.push({id:`e:${z.parentId}->${z.id}`,source:z.parentId,target:z.id,animated:(z.state==="active"||G)&&!Z&&!I,type:"smoothstep",style:{"--session-hue":W,strokeWidth:Q,opacity:ne,transition:"var(--edge-transition)"},className:ae})}}const P=new Map;for(const z of e.agents.values())z.tools.length>0&&P.set(z.id,Math.min(4,z.tools.length));const O=`${w}#lanes:${D5(P)}`,D=N.filter(z=>H$(z.id,o,g,y));if(D.length>0||O!==E.current){if(D.length>0){const z=z5(N,j,{direction:"LR",pinned:o,measured:u,availableWidth:r,availableHeight:i,lanes:P});for(const C of z)JC(C.id,g,y)&&V$(C.id,C.position,g,y);U5(N,g,o,u,new Set(D.map(C=>C.id)),P)}B5(N,g,o,u,P),E.current=O}const L=H5(N,g,o,u,c,!p||d,P);L.length>0&&f(L),au(g,e.agents),au(y,e.agents),au(o,e.agents),au(u,U$(e.agents.values()));const U=[];let V=!1;for(const z of N){let C=o.get(z.id)??g.get(z.id);C||(C=W$(z.id,g,y),V=!0),U.push({...z,position:C})}return V&&(E.current=""),{nodes:U,edges:j}}function jF(){return m.jsx(ly,{children:m.jsx(TF,{})})}function TF(){var Xa,Qa,Za,Ja;const e=Oa(),t=R.useRef(Lv()),[,r]=R.useState(0),i=R.useCallback(()=>r(H=>H+1),[]),[o,a]=R.useState(()=>new Set),[u,c]=R.useState(null),[f,p]=R.useState(null),d=R.useCallback((H,Y)=>{a(oe=>{if(!Y)return new Set([H]);const de=new Set(oe);return de.has(H)?de.delete(H):de.add(H),de}),c(oe=>Y&&oe===H?oe:H)},[]),g=R.useCallback(()=>{a(new Set),c(null)},[]),[y,w]=R.useState(null),[E,_]=R.useState(null),b=R.useCallback(H=>_(H),[]),[S,k]=R.useState(!1),N=R.useRef(_F()),[j,A]=R.useState(mF);R.useEffect(()=>{gF(j)},[j]);const[M,P]=R.useState(vF);R.useEffect(()=>{yF(M)},[M]);const[O,D]=R.useState(wF);R.useEffect(()=>{xF(O)},[O]);const[L,U]=R.useState(()=>{try{const H=window.localStorage.getItem(ZE);return H===null?!0:H==="1"}catch{return!0}});R.useEffect(()=>{try{window.localStorage.setItem(ZE,L?"1":"0")}catch{}},[L]);const[V,z]=R.useState(null),[C,F]=R.useState(!1),[$,re]=R.useState(0),[J,W]=R.useState(0);R.useEffect(()=>{fetch("/api/sound-hook").then(H=>H.ok?H.json():null).then(H=>{H!=null&&H.ok&&(z(H.enabled===!0),re((H.foreign??[]).filter(Y=>Y.worksHere).length),W(typeof H.parked=="number"?H.parked:0))}).catch(()=>{})},[]);const Z=R.useCallback(async()=>{F(!0);try{const Y=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!V})})).json().catch(()=>null);Y!=null&&Y.ok&&z(Y.enabled===!0),fetch("/api/sound-hook").then(oe=>oe.ok?oe.json():null).then(oe=>{oe!=null&&oe.ok&&(re((oe.foreign??[]).filter(de=>de.worksHere).length),W(typeof oe.parked=="number"?oe.parked:0))}).catch(()=>{})}catch{}finally{F(!1)}},[V]),[I,G]=R.useState(!1),[K,q]=R.useState(null),[Q,ne]=R.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(JE)??""}catch{return""}}),[ae,fe]=R.useState(!1),te=R.useRef(0),[ce,Ce]=R.useState(!1),ve=R.useCallback((H=!1)=>{H&&(te.current=Date.now(),Ce(!0)),fetch(H?"/api/version?refresh=1":"/api/version").then(Y=>Y.ok?Y.json():null).then(Y=>{Y&&q(Y)}).catch(()=>{}).finally(()=>{H&&Ce(!1)})},[]),Re=R.useCallback(()=>{ve(Date.now()-te.current>=pF)},[ve]);R.useEffect(()=>{ve();const H=window.setInterval(Re,5*6e4),Y=()=>{document.visibilityState==="visible"&&Re()};return document.addEventListener("visibilitychange",Y),()=>{window.clearInterval(H),document.removeEventListener("visibilitychange",Y)}},[ve,Re]),R.useEffect(()=>{I&&ve()},[I,ve]);const ye=(K==null?void 0:K.notice)??null,[Ee,Ye]=R.useState(null),[we,_e]=R.useState(Bv);R.useEffect(()=>{let H=!1;return fetch("/api/health").then(Y=>Y.ok?Y.json():null).then(Y=>{H||(_e(tF(Y)),!(!Y||typeof Y.workspace!="string")&&Ye(Y.workspace))}).catch(()=>{}),()=>{H=!0}},[I]);const Be=R.useRef(we);Be.current=we;const it=ye?`${ye.kind}:${ye.to}`:"",ft=ye!=null&&Q!==it,Ze=R.useCallback(()=>{if(!ye)return;const H=Q===it?"":it;ne(H);try{window.localStorage.setItem(JE,H)}catch{}},[ye,it,Q]),[De,Je]=R.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(eN)??""}catch{return""}}),Xe=K!=null&&K.invokedAs&&K.invokedAs!==Gt?K.invokedAs:null,Ot=Xe!=null&&De!==Xe,lt=R.useCallback(()=>{if(Xe){Je(Xe);try{window.localStorage.setItem(eN,Xe)}catch{}}},[Xe]),Qe=((Xa=K==null?void 0:K.upgrade)==null?void 0:Xa.state)??"idle",Pt=I$(K==null?void 0:K.upgrade),zt=R.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}ve()},[ve]);R.useEffect(()=>{if(Qe!=="running")return;const H=window.setInterval(ve,3e3);return()=>window.clearInterval(H)},[Qe,ve]);const et=R.useCallback(async()=>{var oe;const H=K==null?void 0:K.command;if(!H)return;let Y=!1;try{Y=await Promise.race([((oe=navigator.clipboard)==null?void 0:oe.writeText(H).then(()=>!0))??Promise.resolve(!1),new Promise(de=>window.setTimeout(()=>de(!1),500))])}catch{Y=!1}if(!Y)try{const de=document.createElement("textarea");de.value=H,de.setAttribute("readonly",""),de.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(de),de.select(),Y=document.execCommand("copy"),de.remove()}catch{Y=!1}Y&&(fe(!0),window.setTimeout(()=>fe(!1),1600))},[K==null?void 0:K.command]),bt=R.useCallback(()=>{A(H=>(H||U(!1),!H))},[]),ht=R.useCallback(()=>{U(H=>(H||A(!1),!H))},[]),[vt,hn]=R.useState(!1),[Yt,Lt]=R.useState(0),bn=R.useRef(null),[gr,Sn]=R.useState(!1),Bt=R.useRef(null),[Fn,pn]=R.useState(0),vr=R.useRef(X$()),[Hr,xi]=R.useState(!1),Wr=R.useCallback(()=>{const H=vr.current,Y=H.setPaused(!H.paused);for(const oe of Y)t.current=Qx(t.current,oe);xi(H.paused)},[]),[ut,_i]=R.useState(Date.now()),[mn,Is]=R.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(tN)!=="0"}catch{return!0}}),yr=R.useCallback(()=>{Is(H=>{const Y=!H;try{window.localStorage.setItem(tN,Y?"1":"0")}catch{}return Y})},[]),[zn,kn]=R.useState(!1),[Vr,Gr]=R.useState("restart"),[Yr,bi]=R.useState(null),sr=R.useRef(!1),Ms=R.useRef(null),En=R.useRef(0),wr=R.useCallback(async H=>{if(sr.current)return;const Y=(H==null?void 0:H.upgrade)===!0;sr.current=!0,Ms.current=Pt;const oe=++En.current;Gr(Y?"npx":"restart"),kn(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(ye==null?void 0:ye.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:Y})})}catch{}window.setTimeout(()=>{if(En.current===oe&&sr.current){sr.current=!1,kn(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},Y?18e4:3e4)},[ye==null?void 0:ye.to,Pt]),Os=R.useRef(null);R.useEffect(()=>{let H=!1;for(const oe of t.current.agents.values())if(oe.state==="active"){H=!0;break}const Y=O$({enabled:mn,kind:ye==null?void 0:ye.kind,canRestart:(K==null?void 0:K.canRestart)===!0,busy:H,idleSince:Os.current,now:ut});Os.current=Y.idleSince,Y.restart&&wr()},[mn,ye==null?void 0:ye.kind,K==null?void 0:K.canRestart,ut,wr]),R.useEffect(()=>{const H=K==null?void 0:K.running;let Y=null,oe=null;try{Y=window.sessionStorage.getItem("agent-dag.restartPending"),oe=window.sessionStorage.getItem(nN)}catch{return}const de=A$({bundle:"1.36.3",running:H,pending:Y,lastTried:oe});if(de==="reload"){try{window.sessionStorage.setItem(nN,H??"")}catch{return}window.location.reload();return}if(de!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}sr.current=!1,kn(!1),bi(H??null);const xe=window.setTimeout(()=>bi(null),6e3);return()=>window.clearTimeout(xe)},[K==null?void 0:K.running]),R.useEffect(()=>{if(zn&&M$({asked:Ms.current,reported:Pt})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}sr.current=!1,kn(!1)}},[zn,Pt]);const Ps=R.useRef(bF()).current;R.useRef(!1);const Tt=R.useRef(new Map(Ps.positions.filter(([H])=>Ps.pins.includes(H)))),xr=R.useRef(null),_r=R.useState(()=>SF())[0],[Kt,Kr]=R.useState(""),[Si,nt]=R.useState(()=>new Set),[br,Xr]=R.useState(Z$),[Ls,Qr]=R.useState(!1),Zr=R.useRef(null);R.useEffect(()=>{document.documentElement.dataset.theme=br;try{window.localStorage.setItem(ej,br)}catch{}},[br]),R.useEffect(()=>{if(!_r)return;const H=window.setTimeout(()=>{try{e.setViewport(_r,{duration:0})}catch{}},60);return()=>window.clearTimeout(H)},[e,_r]);const $s=R.useRef(!0);R.useEffect(()=>{const H=new EventSource("/events"),Y=K$(i,{now:()=>Date.now(),setTimeout:(oe,de)=>window.setTimeout(oe,de),clearTimeout:oe=>window.clearTimeout(oe)});return H.addEventListener("open",()=>{G(!0),Qr(!0)}),H.addEventListener("error",()=>G(!1)),H.addEventListener("replay-end",()=>{$s.current=!1,Y.flush()}),H.addEventListener("hook",oe=>{try{const de=JSON.parse(oe.data);if(!vr.current.accept(de))return;t.current=Qx(t.current,de),de.replay===!0||$s.current||Date.now()-de.receivedAt>3e4?Y.replay():Y.live()}catch{}}),()=>{H.close(),Y.cancel()}},[i]),R.useEffect(()=>{const H=setInterval(()=>{const Y=Date.now();_i(Y);let oe=DP(t.current,Y,Xx);FP(t.current,Y,Xx)&&(oe=!0),$P(t.current,Y,cF,dF)&&(oe=!0),qP(t.current,Y,fF,hF)&&(oe=!0),oe&&i()},250);return()=>clearInterval(H)},[i]);const ir=R.useRef(null),St=R.useRef(0),qs=420,pt=R.useCallback((H=500)=>{try{const Se=document.querySelector(".canvas-wrap"),Pe=Array.from(document.querySelectorAll(".react-flow__node")).filter(wt=>wt.offsetWidth>0);if(!Se||Pe.length===0)return;const Fe=Se.getBoundingClientRect(),Ge=e.getViewport();if(!Number.isFinite(Ge.zoom)||Ge.zoom<=0)return;const We=wt=>(wt-Fe.left-Ge.x)/Ge.zoom,ze=wt=>(wt-Fe.top-Ge.y)/Ge.zoom,jn=Pe.map(wt=>wt.getBoundingClientRect()),Ys=Math.min(...jn.map(wt=>We(wt.left))),Io=Math.max(...jn.map(wt=>We(wt.right))),Ks=Math.min(...jn.map(wt=>ze(wt.top))),Mo=Math.max(...jn.map(wt=>ze(wt.bottom))),el=Io-Ys,us=Mo-Ks;if(!(el>0&&us>0))return;const Zt=Math.max(.2,Math.min(1,(Fe.width-160)/(el+qs)*.86,(Fe.height-160)/us*.86));e.setViewport({x:80-Ys*Zt,y:Math.max(80,(Fe.height-us*Zt)/2)-Ks*Zt,zoom:Zt},{duration:H}),St.current=Date.now(),window.setTimeout(()=>{try{const wt={x:80-Ys*Zt,y:Math.max(80,(Fe.height-us*Zt)/2)-Ks*Zt,zoom:Zt},Oo=e.getViewport();(Math.abs(Oo.zoom-Zt)>.01||Math.abs(Oo.x-wt.x)>2)&&e.setViewport(wt,{duration:0})}catch{}},H+60)}catch{}},[e]),Eo=R.useRef(""),No=R.useRef(null),Ba=R.useRef(0),Sr=R.useCallback(()=>{Ba.current=Date.now()},[]),Jr="agent-dag.autoFitDisabled",gn=R.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Jr)==="1"}catch{return!1}})()),[Ds,Ua]=R.useState(gn.current),Ha=R.useCallback(()=>{if(!gn.current){gn.current=!0,Ua(!0);try{window.localStorage.setItem(Jr,"1")}catch{}}},[]),Co=R.useCallback(()=>{gn.current=!1,Ua(!1);try{window.localStorage.removeItem(Jr)}catch{}pt(400)},[e,pt]);R.useEffect(()=>{const H=setInterval(()=>{if(gn.current||Date.now()-Ba.current<800)return;const Y=t.current,oe=Date.now(),de=[];for(const We of Y.agents.values())zv(We,oe)&&de.push({id:We.id});if(de.length===0)return;const xe=e.getViewport(),Se=window.innerWidth-360,Pe=window.innerHeight-52;let Fe=!1,Ge=!1;for(const{id:We}of de){const ze=or.current.get(We),jn=Tt.current.get(We)??Xt.current.get(We);if(!ze||!jn)continue;Ge=!0;const Ys=jn.x*xe.zoom+xe.x,Io=jn.y*xe.zoom+xe.y,Ks=(jn.x+ze.width)*xe.zoom+xe.x,Mo=(jn.y+ze.height)*xe.zoom+xe.y;if(Ks>0&&Ys<Se&&Mo>0&&Io<Pe){Fe=!0;break}}Ge&&!Fe&&pt(600)},1500);return()=>clearInterval(H)},[e]);const ki=R.useRef(!1),or=R.useRef(new Map),es=R.useRef(0),oc=R.useCallback(H=>{const Y=or.current;let oe=!1;for(const de of H.nodeInternals.values()){const xe=de.width,Se=de.height;if(xe==null||Se==null)continue;const Pe=Y.get(de.id);Pe?(Math.abs(Pe.height-Se)>4||Math.abs(Pe.width-xe)>4)&&(Y.set(de.id,{width:xe,height:Se}),oe=!0):(Y.set(de.id,{width:xe,height:Se}),oe=!0)}return oe&&(es.current+=1),es.current},[]),Ei=Ke(oc),[He,Wa]=R.useState(0);R.useEffect(()=>{let H=0;const Y=()=>{const de=or.current;let xe=!1;for(const Se of document.querySelectorAll(".react-flow__node[data-id]")){const Pe=Se.getAttribute("data-id");if(!Pe)continue;const Fe=Se.offsetWidth,Ge=Se.offsetHeight;if(!Fe||!Ge)continue;const We=de.get(Pe);(!We||Math.abs(We.width-Fe)>4||Math.abs(We.height-Ge)>4)&&(de.set(Pe,{width:Fe,height:Ge}),xe=!0)}xe&&Wa(Se=>Se+1)};if(ki.current)return;let oe=0;return document.visibilityState==="hidden"?oe=window.setTimeout(Y,32):H=requestAnimationFrame(Y),()=>{cancelAnimationFrame(H),window.clearTimeout(oe)}});const Xt=R.useRef(new Map(Ps.positions)),jo=R.useRef(new Set),Ni=R.useRef(""),kr=R.useMemo(()=>{const H=[];for(const Y of t.current.agents.values())zv(Y,ut)&&H.push(Y.id+(Y.parentId?`>${Y.parentId}`:""));return H.sort(),`${H.join("|")}#sv${Ei}.${He}`},[t.current,t.current.lastSeq,ut,Ei,He]),ts=R.useRef(null);R.useEffect(()=>(ts.current!=null&&window.clearTimeout(ts.current),ts.current=window.setTimeout(()=>{wv(Xt.current,Tt.current)},1500),()=>{ts.current!=null&&window.clearTimeout(ts.current)}),[kr]),R.useEffect(()=>{if(Eo.current===kr)return;const H=Eo.current;if(Eo.current=kr,!H||gn.current)return;Date.now()-St.current>1200&&pt(400),ir.current&&window.clearTimeout(ir.current),ir.current=window.setTimeout(()=>{gn.current||pt(500)},280)},[kr,e,pt]);const Fs=R.useMemo(()=>{if(o.size===0)return null;const H=new Set;for(const Y of o){const oe=NF(t.current,Y);if(oe)for(const de of oe)H.add(de)}return H.size>0?H:null},[t.current,t.current.lastSeq,o]),Nn=R.useMemo(()=>V5(t.current,ut),[t.current,t.current.lastSeq,ut]),Bn=R.useRef(null),[vn,Un]=R.useState({w:0,h:0});R.useEffect(()=>{const H=Bn.current;if(!H||typeof ResizeObserver>"u")return;const Y=new ResizeObserver(oe=>{var xe;const de=(xe=oe[0])==null?void 0:xe.contentRect;de&&Un(Se=>Math.abs(Se.w-de.width)>40||Math.abs(Se.h-de.height)>40?{w:de.width,h:de.height}:Se)});return Y.observe(H),Un({w:H.clientWidth,h:H.clientHeight}),()=>Y.disconnect()},[]);const zs=R.useCallback(H=>{var oe,de;const Y=H.target;!(Y!=null&&Y.closest)||Y.closest(lF)!==H.currentTarget||(H.preventDefault(),(de=(oe=document.activeElement)==null?void 0:oe.blur)==null||de.call(oe))},[]),Bs=R.useRef(new Map),[Hn,ac]=R.useState(!1);R.useEffect(()=>{const H=window.setTimeout(()=>ac(!0),2500);return()=>window.clearTimeout(H)},[]);const[Va,Er]=R.useState(!1),ar=R.useRef(null),[Ci,Us]=R.useState(!1),Ga=R.useCallback(()=>{ar.current&&(window.clearTimeout(ar.current),ar.current=null),Er(!1)},[]),lc=R.useCallback(H=>{H.length!==0&&queueMicrotask(()=>{Er(!0),ar.current&&window.clearTimeout(ar.current),ar.current=window.setTimeout(()=>Er(!1),uF+80)})},[]);R.useEffect(()=>()=>{ar.current&&window.clearTimeout(ar.current)},[]);const ns=vn.w>0?vn.w*.92:0,rs=vn.h>0?vn.h:0,{nodes:Qt,edges:ji}=R.useMemo(()=>CF(t.current,ut,ns,rs,Tt.current,Kt,or.current,Bs.current,lc,Hn,Ci,Xt.current,jo.current,kr,Ni,o,Fs,Nn,b),[t.current,t.current.lastSeq,ut,ns,rs,Hn,Ci,Kt,kr,o,Fs,Nn,b,Yt]),Ya=R.useMemo(()=>{const H=new Map;for(const oe of Qt){const de=oe.data;if(!(de!=null&&de.sessionId)||de.exitAt!=null)continue;const xe=oe.width,Se=oe.height;if(xe==null||Se==null)continue;const Pe=oe.position.x,Fe=oe.position.y,Ge=Pe+xe,We=Fe+Se,ze=H.get(de.sessionId);ze?(ze.minX=Math.min(ze.minX,Pe),ze.minY=Math.min(ze.minY,Fe),ze.maxX=Math.max(ze.maxX,Ge),ze.maxY=Math.max(ze.maxY,We)):H.set(de.sessionId,{minX:Pe,minY:Fe,maxX:Ge,maxY:We})}const Y=[];for(const[oe,de]of H){const xe=de.maxX-de.minX+du*2,Se=de.maxY-de.minY+du*2;Y.push({id:`group:${oe}`,type:rT,position:{x:de.minX-du,y:de.minY-du},data:{sessionId:oe,w:xe,h:Se},width:xe,height:Se,style:{width:xe,height:Se},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return Y},[Qt,ut]),uc=R.useMemo(()=>{const H=[...Ya,...Qt],Y=Bt.current;return!Y||Y.size===0?H:H.map(oe=>{const de=Y.get(oe.id);return de?{...oe,position:de}:oe})},[Ya,Qt,Fn]),Nr=R.useMemo(()=>{if(!Kt)return null;const H=new Set;for(const Y of t.current.agents.values())Nn.has(Y.id)&&oT(Y,Kt)&&H.add(Y.id);return H},[t.current,t.current.lastSeq,Kt,Nn]),Cn=R.useMemo(()=>sF(Kt,(Nr==null?void 0:Nr.size)??0,Nn.size),[Kt,Nr,Nn]),ss=R.useMemo(()=>{const H=new Set;for(const Y of t.current.agents.values())for(const oe of Y.tools)H.add(fT(oe.name));return Object.keys(Uv).filter(Y=>H.has(Y))},[t.current,t.current.lastSeq]);R.useEffect(()=>{if(ss.length<=1){Sn(!1);return}let H=0;const Y=()=>{const oe=bn.current;if(oe&&!document.hidden){const de=oe.getBoundingClientRect(),xe=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Pe=>Pe.getBoundingClientRect()),Se=Y5(de,xe,8);Sn(Pe=>Pe===Se?Pe:Se)}H=window.setTimeout(Y,300)};return Y(),()=>window.clearTimeout(H)},[ss.length]);const is=R.useMemo(()=>{const H=new Map;for(const oe of t.current.agents.values())for(const de of oe.tools){if(!de.name.startsWith("mcp__"))continue;const xe=de.name.slice(5),Se=xe.indexOf("__"),Pe=Se>0?xe.slice(0,Se):xe;H.set(Pe,(H.get(Pe)??0)+1)}const Y=[];for(const[oe,de]of H){let xe=5381;for(let Se=0;Se<oe.length;Se++)xe=(xe<<5)+xe^oe.charCodeAt(Se);Y.push({server:oe,count:de,hue:Math.abs(xe)%360})}return Y.sort((oe,de)=>de.count-oe.count),Y},[t.current,t.current.lastSeq]),lr=R.useCallback(H=>{nt(Y=>{const oe=new Set(Y);return oe.has(H)?oe.delete(H):oe.add(H),oe})},[]),Rt=u?t.current.agents.get(u):null,os=f?Array.from(t.current.agents.values()).flatMap(H=>H.tools).find(H=>H.id===f)??null:null,To=R.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}t.current=Lv(),Tt.current.clear(),or.current.clear(),Xt.current.clear(),Ni.current="",sN(),g(),i()},[i,g]),Hs=R.useRef(S);Hs.current=S;const Ws=R.useRef(!1);Ws.current=os!=null||vt||E!=null||y!=null;const Vs=R.useCallback(H=>{const Y=L$(H,{confirmOpen:Hs.current,modalOpen:Ws.current});Y==="confirm"?k(!0):Y==="clear"&&(k(!1),To())},[To]),$t=R.useCallback(()=>{Tt.current.clear(),Xt.current.clear(),Ni.current="",sN(),i(),window.setTimeout(()=>pt(500),80)},[i,e,pt]),Cr=R.useCallback(()=>pt(500),[pt]),as=R.useRef(Qt);as.current=Qt;const ls=R.useRef(u);ls.current=u;const Ro=R.useCallback(H=>{const Y=as.current,oe=q$(Y.map(Se=>({id:Se.id,x:Se.position.x,y:Se.position.y})),ls.current,H),de=oe?Y.find(Se=>Se.id===oe):void 0;if(!de)return;const xe=QE(document.activeElement);d(de.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[de]})}catch{}St.current=Date.now(),xe&&aF(de.id)},30)},[d,e]),Ti=R.useCallback(H=>{d(H,!1),window.setTimeout(()=>{try{const Y=as.current.find(oe=>oe.id===H);Y&&e.fitView({padding:.3,duration:500,nodes:[Y]}),St.current=Date.now()}catch{}},60)},[d,e]);R.useEffect(()=>{const H=Y=>{var Fe,Ge,We;const oe=Y.target,de={tagName:oe==null?void 0:oe.tagName,isContentEditable:oe==null?void 0:oe.isContentEditable,role:(Fe=oe==null?void 0:oe.getAttribute)==null?void 0:Fe.call(oe,"role"),type:oe==null?void 0:oe.type};if(Y.key==="Escape"){const ze=iL({overlayOpen:Ru.depth()>0,typing:cy(de)});ze==="dismiss"?Ru.dismissTop():ze==="blur"?oe==null||oe.blur():(B$(de)&&(oe==null||oe.blur()),g());return}if(DC(Y))return;const xe=QE(oe)?(Ge=oe==null?void 0:oe.getAttribute)==null?void 0:Ge.call(oe,"data-id"):null,Se=xe&&as.current.some(ze=>ze.id===xe)?xe:null,Pe=F$(Y,Se);if(Pe.kind==="activate"){Y.preventDefault(),d(Pe.nodeId,Pe.additive);return}if(Pe.kind!=="node"&&!(Pe.nodeId==null&&hL(de))){if(Y.key==="/"){Y.preventDefault(),(We=Zr.current)==null||We.focus();return}Y.key===" "&&(Y.preventDefault(),Wr()),(Y.key==="c"||Y.key==="C")&&Vs("shortcut"),(Y.key==="r"||Y.key==="R")&&$t(),(Y.key==="f"||Y.key==="F")&&Cr(),(Y.key==="l"||Y.key==="L")&&bt(),(Y.key==="h"||Y.key==="H")&&hn(ze=>!ze),(Y.key==="u"||Y.key==="U")&&D(ze=>!ze),(Y.key==="a"||Y.key==="A")&&Be.current.claude&&ht(),(Y.key==="j"||Y.key==="J")&&Ro(1),(Y.key==="k"||Y.key==="K")&&Ro(-1),(Y.key==="t"||Y.key==="T")&&Xr(ze=>ze==="dark"?"light":"dark")}};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[Vs,$t,Cr,g,d,Ro,Wr]);const jr=t.current.agents.size,Gs=new Set(Array.from(t.current.agents.values()).map(H=>H.sessionId)).size,tn=R.useMemo(()=>g3(t.current.agents.values()),[t.current,t.current.lastSeq]),Ao=R.useMemo(()=>v3(t.current.agents.values()),[t.current,t.current.lastSeq]),Ka=R.useRef(null);R.useEffect(()=>{const H=J$({waiting:tn.length,running:Ao}),Y=Ka.current;if(Ka.current=H,(Y==null?void 0:Y.title)!==H.title&&(document.title=H.title),(Y==null?void 0:Y.icon)!==H.icon){const oe=document.querySelector('link[rel="icon"]');oe&&(oe.href=eq[H.icon])}},[tn.length,Ao]);const[cc,dc]=R.useState(""),Ri=nq(tn);R.useEffect(()=>{dc(H=>rq(H,Ri))},[Ri]);const nn=R.useMemo(()=>{let H=0,Y=0,oe=0,de=0,xe=0,Se=0,Pe=0,Fe=0,Ge=0;for(const We of t.current.agents.values()){H+=We.usage.inputTokens,Y+=We.usage.outputTokens,oe+=We.usage.cacheReadTokens,de+=We.usage.cacheCreateTokens;const ze=dn(We.usage,We.model);xe+=ze.total,Se+=ze.input,Pe+=ze.output,Fe+=ze.cacheRead,Ge+=ze.cacheWrite}return{inT:H,outT:Y,cacheR:oe,cacheC:de,sum:H+Y,cost:{total:xe,input:Se,output:Pe,cacheRead:Fe,cacheWrite:Ge}}},[t.current,t.current.lastSeq]);return m.jsxs("div",{className:"app",children:[m.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),m.jsxs("header",{className:"topbar",children:[m.jsxs("div",{className:"brand",children:[m.jsx("span",{className:"logo"}),m.jsx("h1",{children:Gt}),ye?m.jsxs("button",{type:"button",className:"v stale",onClick:Ze,"aria-label":J5({...ye,open:ft}),title:ye.kind==="restart"?`Running v${ye.from}; v${ye.to} is installed on disk. Restart to pick it up.`:`Running v${ye.from}; v${ye.to} is on npm.`,children:["v",ye.from,m.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const H={running:(K==null?void 0:K.running)??"1.36.3",latest:K==null?void 0:K.latest,latestPending:K==null?void 0:K.latestPending,checkedAgo:K!=null&&K.checkedAt?qv(ut-K.checkedAt):null,checkDisabled:K==null?void 0:K.checkDisabled,checking:ce};return m.jsxs("button",{type:"button",className:ce?"v checking":"v",onClick:()=>ve(!0),"aria-busy":ce||void 0,"aria-label":Z5(H),title:Q5(H),children:["v",H.running]})})()]}),Rt&&(()=>{const H=dn(Rt.usage,Rt.model),Y=Math.max(0,((Rt.endedAt??ut)-Rt.startedAt)/1e3),oe=Rt.state==="active"?ju(H.total,Y):null,de=o.size-1;return m.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${Rt.label}`,onClick:()=>{try{const xe=Qt.find(Se=>Se.id===Rt.id);xe&&e.fitView({padding:.35,duration:500,nodes:[xe]}),St.current=Date.now()}catch{}},children:[m.jsx("span",{className:`state-pill state-${Rt.state}`,children:Rt.state==="active"?"live":Rt.state}),m.jsx("span",{className:"selected-label",children:Rt.label}),H.total>0&&m.jsxs("span",{className:"selected-cost",children:[qe(H.total),oe?m.jsxs("span",{className:"selected-rate",children:[" · ",oe]}):null]}),de>0&&m.jsxs("span",{className:"selected-extra",children:["+",de]}),m.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:xe=>{xe.stopPropagation(),g()},children:"×"})]})})(),m.jsxs("div",{className:"actions",children:[m.jsxs("div",{className:"search",children:[m.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),m.jsx("input",{ref:Zr,type:"text",placeholder:iF,value:Kt,onChange:H=>Kr(H.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),Kt?m.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>Kr(""),children:"×"}):m.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"}),Cn.count&&m.jsx("span",{className:`search-count${Cn.empty?" none":""}`,"aria-live":"polite",title:`${Cn.count} agents on the canvas match “${Kt}”`,children:Cn.count})]}),m.jsxs("span",{className:"status",children:[(()=>{const H=nF({connected:I,paused:Hr,held:vr.current.size});return m.jsx("span",{className:`pill ${H.tone}`,title:H.title,children:H.label})})(),m.jsxs("span",{className:"stat",title:cq(we),children:[m.jsx("span",{className:"count",children:Gs}),m.jsx("span",{className:"lbl",children:"sessions"})]}),m.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[m.jsx("span",{className:"count",children:jr}),m.jsx("span",{className:"lbl",children:"agents"})]}),m.jsxs("span",{className:"stat",title:dq(we),children:[m.jsx("span",{className:"count",children:t.current.totalEvents}),m.jsx("span",{className:"lbl",children:"events"})]}),m.jsx(F3,{usageOpen:O}),nn.sum>0&&m.jsxs("span",{className:"stat",title:`in:${nn.inT.toLocaleString()} out:${nn.outT.toLocaleString()} cache-r:${nn.cacheR.toLocaleString()} cache-c:${nn.cacheC.toLocaleString()}`,children:[m.jsx("span",{className:"count",children:Nt(nn.sum)}),m.jsx("span",{className:"lbl",children:"tokens"})]}),is.length>0&&m.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
|
|
74
74
|
${is.map(H=>` ${H.server}: ${H.count} call${H.count===1?"":"s"}`).join(`
|
|
75
75
|
`)}`,children:[is.slice(0,6).map(H=>m.jsx("span",{className:"mcp-dot",style:{"--mcp-hue":H.hue}},H.server)),is.length>6&&m.jsxs("span",{className:"mcp-more",children:["+",is.length-6]}),m.jsx("span",{className:"lbl",children:"mcp"})]}),nn.cost.total>0&&(()=>{let H=0,Y=0;for(const xe of t.current.agents.values()){if(xe.state!=="active")continue;const Se=dn(xe.usage,xe.model);H+=Se.total,Y=Math.max(Y,((xe.endedAt??ut)-xe.startedAt)/1e3)}const oe=Y>0?ju(H,Y):null,de=`input ${qe(nn.cost.input)} + output ${qe(nn.cost.output)} + cache r ${qe(nn.cost.cacheRead)} + cache w ${qe(nn.cost.cacheWrite)}${oe?`
|
|
76
76
|
active burn: ${oe}`:""}`;return m.jsxs("span",{className:"stat",title:de,children:[m.jsx("span",{className:"count",children:qe(nn.cost.total)}),m.jsxs("span",{className:"lbl",children:["cost",oe?` · ${oe}`:""]})]})})()]}),m.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:cc}),tn.length>0&&m.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>Ti(tn[0].id),title:`Blocked waiting for you — click to go to the one that has been stuck longest:
|
|
77
77
|
${tn.map(H=>` ${H.label}: ${zu(H.waiting)} (${qv(ut-H.waiting.since)})`).join(`
|
|
78
|
-
`)}`,"aria-label":`${tn.length} session${tn.length===1?"":"s"} waiting for you`,children:[m.jsx("span",{className:"ap-pulse","aria-hidden":!0}),m.jsx("b",{children:tn.length})," waiting"]}),(()=>{const H=rF({paused:Hr,held:vr.current.size});return m.jsx("button",{className:`btn ${Hr?"warn":""}`,onClick:Wr,title:H.title,children:H.label})})(),m.jsx("button",{className:"btn icon-btn",onClick:()=>D(H=>!H),title:`${O?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel","aria-expanded":O,"aria-controls":O?"usage-panel":void 0,children:"$"}),we.claude&&V!==null&&m.jsx("button",{className:"btn icon-btn",onClick:H=>{if(H.shiftKey&&J>0){F(!0),fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restore"})}).then(()=>fetch("/api/sound-hook")).then(Y=>Y.ok?Y.json():null).then(Y=>{Y!=null&&Y.ok&&(z(Y.enabled===!0),W(Y.parked??0))}).catch(()=>{}).finally(()=>F(!1));return}Z()},disabled:C,title:hq(we,{on:V,clash:$,parked:J}),"aria-label":"Toggle Claude Code finish sound","aria-pressed":V,children:m.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[m.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),V?m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),m.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}):m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M10 5.6l2.6 2.8"}),m.jsx("path",{d:"M12.6 5.6L10 8.4"})]})]})}),we.claude&&m.jsx("button",{className:"btn icon-btn",onClick:ht,title:`${L?"Hide":"Show"} accounts (A)`,"aria-label":"Toggle accounts panel","aria-expanded":L,"aria-controls":L?"accounts-panel":void 0,children:m.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[m.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),m.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]})}),m.jsx("button",{className:"btn icon-btn",onClick:bt,title:`${j?"Hide":"Show"} session list (L)`,"aria-label":"Toggle session list","aria-expanded":j,"aria-controls":j?"session-list":void 0,children:"☰"}),m.jsx("button",{className:"btn icon-btn",onClick:()=>hn(H=>!H),title:"Usage history — ccusage (H)","aria-label":"Open usage history","aria-haspopup":"dialog",children:m.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":!0,children:[m.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),m.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),m.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]})}),m.jsx("button",{className:"btn",onClick:$t,title:"Auto-arrange — clear pins (R)",children:"Re-layout"}),m.jsx("button",{className:"btn",onClick:()=>Vs("button"),title:"Clear the canvas and the server's event log — asks first (C)",children:"Clear"}),m.jsx("button",{className:"btn icon-btn",onClick:()=>Xr(H=>H==="dark"?"light":"dark"),title:`Switch to ${br==="dark"?"light":"dark"} mode (T)`,"aria-label":"Toggle theme",children:br==="dark"?"☀":"☾"})]})]}),Yr?m.jsxs("div",{className:"ver-banner done",role:"status",children:[m.jsx("span",{className:"ver-dot"}),m.jsxs("strong",{children:["Restarted — now running v",Yr,"."]}),m.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):Ls&&!I?m.jsxs("div",{className:"conn-banner",role:"alert",children:[m.jsx("span",{className:"conn-dot"}),zn?Vr==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${Gt}…`:`Lost connection to the ${Gt} server. Reconnecting…`]}):ft&&ye?m.jsxs("div",{className:`ver-banner ${ye.kind}`,role:"status",children:[m.jsx("span",{className:"ver-dot"}),ye.kind==="restart"?m.jsxs(m.Fragment,{children:[m.jsxs("strong",{children:["v",ye.to," is installed — this deck still runs v",ye.from,"."]}),K!=null&&K.canRestart?m.jsxs(m.Fragment,{children:[m.jsx("button",{type:"button",className:"ver-act",onClick:()=>wr(),disabled:zn,title:"Stop this process and bring it back on the same port. The canvas replays from the event log.",children:zn?"restarting…":"Restart now"}),m.jsxs("button",{type:"button",className:`ver-auto${mn?" on":""}`,role:"switch","aria-checked":mn,onClick:yr,title:mn?"Restarts on its own once nothing has been running for 30 seconds. Click to require a click instead.":"Only restarts when you click. Click to let it restart itself while idle.",children:[m.jsx("i",{"aria-hidden":!0}),"auto when idle"]})]}):m.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."})]}):m.jsxs(m.Fragment,{children:[m.jsxs("strong",{children:[Gt," v",ye.to," is out — you are on v",ye.from,"."]}),(K==null?void 0:K.upgradeMode)==="install"&&Qe!=="failed"&&m.jsx("button",{type:"button",className:"ver-act",onClick:zt,disabled:Qe==="running"||Qe==="done",title:`Runs ${((Qa=K==null?void 0:K.upgrade)==null?void 0:Qa.command)??(K==null?void 0:K.command)??"npm i -g"} here, then restarts once nothing is running.`,children:Qe==="running"?"installing…":Qe==="done"?"installed":"Update now"}),(K==null?void 0:K.upgradeMode)==="npx"&&(K==null?void 0:K.canRestart)&&m.jsx("button",{type:"button",className:"ver-act",onClick:()=>wr({upgrade:!0}),disabled:zn,title:`Runs ${K==null?void 0:K.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:zn?"fetching…":Qe==="failed"?"Retry update":"Update & restart"}),Qe==="failed"?m.jsxs("span",{className:"ver-sub fail",title:((Za=K==null?void 0:K.upgrade)==null?void 0:Za.error)??"",children:[(K==null?void 0:K.upgradeMode)==="npx"?"update failed":"install failed",": ",((Ja=K==null?void 0:K.upgrade)==null?void 0:Ja.error)??"unknown error"," — run it yourself:"]}):(K==null?void 0:K.upgradeMode)==="npx"?m.jsx("span",{className:"ver-sub",children:K!=null&&K.canRestart?"npx cannot upgrade in place, so the deck re-runs:":yv.npx}):K!=null&&K.upgradeBlocked?m.jsx("span",{className:"ver-sub",children:Object.hasOwn(yv,K.upgradeBlocked)?yv[K.upgradeBlocked]:"cannot install from here"}):null,m.jsxs("button",{type:"button",className:"ver-cmd",onClick:et,title:"Copy to clipboard",children:[m.jsx("code",{children:K==null?void 0:K.command}),m.jsx("span",{className:"ver-cmd-hint",children:ae?"copied":"copy"})]})]}),m.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:Ze,children:"×"})]}):Ot&&Xe?m.jsxs("div",{className:"ver-banner",role:"status",children:[m.jsx("span",{className:"ver-dot"}),m.jsxs("strong",{children:[Xe," still works — the deck is called ",Gt," now."]}),K!=null&&K.renameFix?m.jsx("span",{className:"ver-sub",children:K.renameFix}):null,m.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:lt,children:"×"})]}):null,O&&m.jsx(T$,{state:t.current,now:ut,providers:we,onClose:()=>D(!1)}),L&&we.claude&&m.jsx(j3,{onClose:()=>U(!1)}),j&&m.jsx(w$,{state:t.current,now:ut,selectedIds:o,onSelect:Ti,onClose:()=>A(!1)}),m.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${Va?" bubbling":""}${Ci?" dragging-any":""}`,ref:Bn,onMouseDownCapture:zs,children:[jr===0&&m.jsx(RF,{live:I,everConnected:Ls,providers:we}),Cn.empty&&jr>0&&m.jsxs("div",{className:"search-empty",role:"status",children:[m.jsx("span",{className:"search-empty-text",children:Cn.message}),m.jsx("button",{type:"button",className:"btn",onClick:()=>{var H;Kr(""),(H=Zr.current)==null||H.focus()},children:"Clear search"})]}),ss.length>1&&m.jsx("div",{ref:bn,className:`cat-filter-bar${gr?" occluded":""}`,role:"group","aria-label":"Filter tools by category",children:ss.map(H=>{const Y=Si.has(H);return m.jsxs("button",{type:"button",className:`cat-filter${Y?" off":""}`,onClick:()=>lr(H),"aria-pressed":!Y,title:`${Y?"Show":"Hide"} ${Hv[H]} tools`,children:[m.jsx("span",{className:"cat-emoji",children:Uv[H]}),m.jsx("span",{className:"cat-name",children:Hv[H]})]},H)})}),m.jsxs(SC,{nodes:uc,edges:ji,nodeTypes:oF,fitView:!_r,fitViewOptions:{padding:.25,duration:400},minZoom:.2,maxZoom:1.6,panOnScroll:!0,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,onNodeClick:(H,Y)=>{if(Y.type==="sessionGroup"){g();return}d(Y.id,H.shiftKey)},onPaneClick:()=>g(),onMoveStart:()=>{Date.now()-St.current<1200||Ha()},onMove:(H,Y)=>{Sr(),No.current&&window.clearTimeout(No.current),No.current=window.setTimeout(()=>kF(Y),250)},onNodeDragStart:(H,Y)=>{var oe;if(Ga(),ki.current=!0,Bt.current=new Map,Us(!0),Sr(),Ha(),Y.type==="sessionGroup"){const de=(oe=Y.data)==null?void 0:oe.sessionId,xe=new Map;if(de)for(const Se of Qt){const Pe=Se.data;(Pe==null?void 0:Pe.sessionId)===de&&xe.set(Se.id,{x:Se.position.x,y:Se.position.y})}xr.current={start:{x:Y.position.x,y:Y.position.y},members:xe};return}Tt.current.set(Y.id,{x:Y.position.x,y:Y.position.y})},onNodeDrag:(H,Y)=>{var oe;if(Sr(),Y.type==="sessionGroup"){const de=xr.current;if(!de)return;const xe=Y.position.x-de.start.x,Se=Y.position.y-de.start.y;for(const[Fe,Ge]of de.members){const We={x:Ge.x+xe,y:Ge.y+Se};Tt.current.set(Fe,We),Xt.current.set(Fe,We)}const Pe=Bt.current;if(Pe){for(const[Fe,Ge]of de.members)Pe.set(Fe,{x:Ge.x+xe,y:Ge.y+Se});Pe.set(Y.id,{x:Y.position.x,y:Y.position.y})}pn(Fe=>Fe+1);return}Tt.current.set(Y.id,{x:Y.position.x,y:Y.position.y}),Xt.current.set(Y.id,{x:Y.position.x,y:Y.position.y}),(oe=Bt.current)==null||oe.set(Y.id,{x:Y.position.x,y:Y.position.y}),pn(de=>de+1)},onNodeDragStop:(H,Y)=>{if(Sr(),ki.current=!1,Bt.current=null,Us(!1),Lt(oe=>oe+1),Y.type==="sessionGroup"){const oe=xr.current;if(oe){const de=Y.position.x-oe.start.x,xe=Y.position.y-oe.start.y;for(const[Se,Pe]of oe.members){const Fe={x:Pe.x+de,y:Pe.y+xe};Tt.current.set(Se,Fe),Xt.current.set(Se,Fe)}}xr.current=null,wv(Xt.current,Tt.current),Lt(de=>de+1);return}Tt.current.set(Y.id,{x:Y.position.x,y:Y.position.y}),Xt.current.set(Y.id,{x:Y.position.x,y:Y.position.y}),wv(Xt.current,Tt.current)},children:[m.jsx(EP,{gap:28,size:1,color:fa("--grid-line")}),m.jsx(AL,{}),m.jsx(f$,{agents:t.current.agents,visibleAgentIds:Nn,positions:Xt.current,pinned:Tt.current,measured:or.current,dimUnmatched:Cn.dim?Nr:null,spotlight:Fs,hiddenCategories:Si,now:ut,onOpenTool:p}),m.jsx(wP,{showInteractive:!1,children:m.jsx(io,{onClick:Co,title:Ds?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view",style:Ds?{color:"var(--accent)"}:void 0,children:m.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[m.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),m.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})})}),m.jsx(fP,{zoomable:!0,pannable:!0,nodeColor:H=>K5(H,fa),nodeStrokeWidth:2,maskColor:fa("--minimap-mask"),style:{background:fa("--panel"),border:`1px solid ${fa("--line")}`,borderRadius:8}})]})]}),M?m.jsxs("aside",{className:"detail","aria-label":"Detail",children:[m.jsx("button",{type:"button",className:"detail-close",title:"Close panel","aria-label":"Close detail panel",onClick:()=>P(!1),children:"×"}),Rt?m.jsx(MF,{agent:Rt,now:ut,onOpenTool:p,onShowSummary:H=>{N.current.has(H)&&(N.current.delete(H),rN(N.current)),w(H)},onExportSession:H=>EF(t.current,H)}):m.jsx(IF,{count:jr,workspace:Ee})]}):m.jsx("button",{type:"button",className:"detail-reopen",title:"Show detail panel","aria-label":"Show detail panel",onClick:()=>P(!0),children:"‹"}),os&&m.jsx(NL,{tool:os,onClose:()=>p(null)}),vt&&m.jsx(yq,{providers:we,onClose:()=>hn(!1)}),E&&(()=>{const H=t.current.agents.get(E);return H?m.jsx(wL,{agent:H,onClose:()=>_(null)}):null})(),y&&m.jsx(p$,{state:t.current,sessionId:y,onClose:()=>{N.current.add(y),rN(N.current),w(null)}}),S&&m.jsx(P3,{agentCount:jr,onConfirm:()=>Vs("confirmation"),onCancel:()=>k(!1)})]})}function RF({live:e,everConnected:t,providers:r}){const i=!e;return m.jsxs("div",{className:"empty-hero",children:[m.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[m.jsx("div",{className:"core"}),m.jsxs("div",{className:"orbit r1",children:[m.jsx("span",{className:"dot"}),m.jsx("span",{className:"dot b"})]}),m.jsxs("div",{className:"orbit r2",children:[m.jsx("span",{className:"dot"}),m.jsx("span",{className:"dot b"})]}),m.jsxs("div",{className:"orbit r3",children:[m.jsx("span",{className:"dot"}),m.jsx("span",{className:"dot b"})]})]}),i?m.jsxs(m.Fragment,{children:[m.jsx("h2",{children:t?"Disconnected from server":"Server unreachable"}),m.jsxs("p",{children:["The browser cannot reach ",m.jsx("code",{children:"/events"}),". Check that",m.jsx("code",{children:Gt})," is still running in your terminal, then this page will resume automatically."]})]}):AF(r)]})}function AF(e){return m.jsxs(m.Fragment,{children:[m.jsx("h2",{children:"Waiting for Claude Code or Codex"}),m.jsxs("p",{children:["Run ",m.jsx("code",{children:"claude"})," or ",m.jsx("code",{children:"codex"})," in any folder. As soon as a session sends an event, a node appears here and grows as subagents fork and tools are called."]}),m.jsxs("p",{className:"hint-row",children:["Not seeing anything? Make sure ",m.jsx("code",{children:Gt})," is running."]}),fq(e).map(t=>m.jsx("p",{className:"hint-row",children:t.spans.map((r,i)=>r.code?m.jsx("code",{children:r.text},i):m.jsx("span",{children:r.text},i))},t.provider))]})}function IF({count:e,workspace:t}){const r=eF(t);return m.jsxs(m.Fragment,{children:[m.jsx("h2",{children:"Detail"}),e===0?m.jsxs("div",{className:"hint",children:[r.lead,r.workspace!==null&&m.jsxs(m.Fragment,{children:[" ",m.jsx("code",{children:r.workspace}),r.tail]})]}):m.jsx("div",{className:"empty",children:"Click an agent to see its tools."}),m.jsx("h3",{style:{marginTop:4},children:"Shortcuts"}),m.jsxs("div",{className:"shortcuts",children:[m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"drag"}),m.jsx("span",{children:"move a node"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"tab"}),m.jsx("span",{children:"reach the cards"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"enter"}),m.jsx("span",{children:"select the focused card"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"/"}),m.jsx("span",{children:"focus search"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"space"}),m.jsx("span",{children:"pause / resume"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"J"}),m.jsx("span",{children:"next agent"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"K"}),m.jsx("span",{children:"previous agent"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"R"}),m.jsx("span",{children:"re-arrange"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"F"}),m.jsx("span",{children:"fit view"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"L"}),m.jsx("span",{children:"session list"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"H"}),m.jsx("span",{children:"usage history"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"U"}),m.jsx("span",{children:"usage panel"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"C"}),m.jsx("span",{children:"clear canvas"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"T"}),m.jsx("span",{children:"toggle theme"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"Esc"}),m.jsx("span",{children:"deselect, release focus"})]})]})]})}function MF({agent:e,now:t,onOpenTool:r,onShowSummary:i,onExportSession:o}){const a=Tu(e.startedAt,e.endedAt,t),u=dn(e.usage,e.model),c=u.total>0,f=e.usage.inputTokens+e.usage.outputTokens,p=new Map;for(const w of e.tools){const E=fT(w.name);p.set(E,(p.get(E)??0)+1)}const d=e.tools.filter(w=>w.ok===!1).length,g=e.tools.filter(w=>!w.endedAt).length,y=Array.from(p.entries()).sort((w,E)=>E[1]-w[1]);return m.jsxs(m.Fragment,{children:[m.jsxs("header",{className:"detail-hero",children:[m.jsxs("div",{className:"hero-line",children:[m.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),m.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),m.jsxs("div",{className:"hero-meta",children:[m.jsx("span",{className:"hero-meta-item",children:e.kind}),m.jsx("span",{className:"hero-sep",children:"·"}),m.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:a}),e.model&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"hero-sep",children:"·"}),m.jsx("span",{className:"model-chip",title:e.model,children:Rs(e.model)})]})]}),c&&m.jsxs("div",{className:"hero-cost",children:[m.jsxs("div",{className:"hero-cost-headline",children:[m.jsx("span",{className:"hero-cost-value",children:qe(u.total)}),m.jsx("span",{className:"hero-cost-label",children:"spend"})]}),m.jsx(fy,{cost:u})]}),m.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&i&&m.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>i(e.sessionId),title:"Reopen the end-of-session recap modal",children:"Show recap"}),o&&m.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>o(e.sessionId),title:"Download this session as JSON",children:"Export JSON"})]})]}),e.tools.length>0&&m.jsxs("section",{className:"detail-section",children:[m.jsx("h3",{children:"Activity"}),m.jsxs("div",{className:"activity-row",children:[m.jsxs("div",{className:"activity-counters",children:[m.jsxs("span",{className:"ac-item",children:[m.jsx("b",{children:e.toolCount})," calls"]}),g>0&&m.jsxs("span",{className:"ac-item ac-live",children:[m.jsx("b",{children:g})," live"]}),d>0&&m.jsxs("span",{className:"ac-item ac-err",children:[m.jsx("b",{children:d})," err"]})]}),m.jsx("div",{className:"cat-strip",children:y.map(([w,E])=>m.jsxs("span",{className:`cat-chip cat-${w}`,title:`${E} ${Hv[w]} call${E===1?"":"s"}`,children:[m.jsx("span",{className:"cat-emoji",children:Uv[w]}),m.jsx("span",{className:"cat-count",children:E})]},w))})]})]}),f>0&&m.jsxs("section",{className:"detail-section",children:[m.jsx("h3",{children:"Tokens"}),m.jsxs("div",{className:"tokens-grid",children:[m.jsxs("div",{children:[m.jsx("span",{className:"k",children:"in"}),m.jsx("b",{children:e.usage.inputTokens.toLocaleString()})]}),m.jsxs("div",{children:[m.jsx("span",{className:"k",children:"out"}),m.jsx("b",{children:e.usage.outputTokens.toLocaleString()})]}),m.jsxs("div",{children:[m.jsx("span",{className:"k",children:"cache r"}),m.jsx("b",{children:e.usage.cacheReadTokens.toLocaleString()})]}),m.jsxs("div",{children:[m.jsx("span",{className:"k",children:"cache c"}),m.jsx("b",{children:e.usage.cacheCreateTokens.toLocaleString()})]})]})]}),m.jsxs("section",{className:"detail-section",children:[m.jsx("h3",{children:"Identity"}),m.jsxs("div",{children:[e.cwd&&m.jsxs("div",{className:"row",children:[m.jsx("span",{className:"k",children:"cwd"}),m.jsx("span",{className:"v",title:e.cwd,children:e.cwd})]}),m.jsxs("div",{className:"row",children:[m.jsx("span",{className:"k",children:"session"}),m.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&m.jsxs("div",{className:"row",children:[m.jsx("span",{className:"k",children:"parent"}),m.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),e.prompts.length>0&&m.jsxs("section",{className:"detail-section",children:[m.jsxs("h3",{children:["Prompts ",m.jsx("span",{className:"section-count",children:e.prompts.length})]}),m.jsx("div",{className:"prompts",children:e.prompts.slice().reverse().map((w,E)=>{const _=_$(w.at,t);return m.jsxs("div",{className:"prompt-entry",children:[m.jsx("div",{className:"prompt-time",title:_.title,children:_.label}),m.jsx("div",{className:"prompt-text",children:w.text})]},E)})})]}),m.jsxs("section",{className:"detail-section",children:[m.jsxs("h3",{children:["Tool calls ",m.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&m.jsx("div",{className:"empty",children:"No tool calls yet."}),m.jsx("div",{children:e.tools.slice().reverse().map(w=>m.jsx(PF,{t:w,onClick:()=>r(w.id)},w.id))})]})]})}const OF={inflight:"in-flight",done:"done",err:"error"};function PF({t:e,onClick:t}){const r=e.endedAt==null?"inflight":e.ok===!1?"err":"done",i=qC(e,"…");return m.jsxs("button",{className:"tool clickable",title:e.inputPreview||e.name,onClick:t,children:[m.jsxs("span",{className:"name",children:[m.jsx("span",{className:`status-dot ${r}`,"aria-hidden":!0}),m.jsx("span",{className:"vis-hidden",children:OF[r]}),e.name]}),m.jsx("span",{style:{color:"var(--muted)"},children:i})]})}try{I$(window.localStorage)}catch{}const LF=SR.createRoot(document.getElementById("root"));LF.render(m.jsx(jF,{}));
|
|
78
|
+
`)}`,"aria-label":`${tn.length} session${tn.length===1?"":"s"} waiting for you`,children:[m.jsx("span",{className:"ap-pulse","aria-hidden":!0}),m.jsx("b",{children:tn.length})," waiting"]}),(()=>{const H=rF({paused:Hr,held:vr.current.size});return m.jsx("button",{className:`btn ${Hr?"warn":""}`,onClick:Wr,title:H.title,children:H.label})})(),m.jsx("button",{className:"btn icon-btn",onClick:()=>D(H=>!H),title:`${O?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel","aria-expanded":O,"aria-controls":O?"usage-panel":void 0,children:"$"}),we.claude&&V!==null&&m.jsx("button",{className:"btn icon-btn",onClick:H=>{if(H.shiftKey&&J>0){F(!0),fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restore"})}).then(()=>fetch("/api/sound-hook")).then(Y=>Y.ok?Y.json():null).then(Y=>{Y!=null&&Y.ok&&(z(Y.enabled===!0),W(Y.parked??0))}).catch(()=>{}).finally(()=>F(!1));return}Z()},disabled:C,title:hq(we,{on:V,clash:$,parked:J}),"aria-label":"Toggle Claude Code finish sound","aria-pressed":V,children:m.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[m.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),V?m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),m.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}):m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M10 5.6l2.6 2.8"}),m.jsx("path",{d:"M12.6 5.6L10 8.4"})]})]})}),we.claude&&m.jsx("button",{className:"btn icon-btn",onClick:ht,title:`${L?"Hide":"Show"} accounts (A)`,"aria-label":"Toggle accounts panel","aria-expanded":L,"aria-controls":L?"accounts-panel":void 0,children:m.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[m.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),m.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]})}),m.jsx("button",{className:"btn icon-btn",onClick:bt,title:`${j?"Hide":"Show"} session list (L)`,"aria-label":"Toggle session list","aria-expanded":j,"aria-controls":j?"session-list":void 0,children:"☰"}),m.jsx("button",{className:"btn icon-btn",onClick:()=>hn(H=>!H),title:"Usage history — ccusage (H)","aria-label":"Open usage history","aria-haspopup":"dialog",children:m.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":!0,children:[m.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),m.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),m.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]})}),m.jsx("button",{className:"btn",onClick:$t,title:"Auto-arrange — clear pins (R)",children:"Re-layout"}),m.jsx("button",{className:"btn",onClick:()=>Vs("button"),title:"Clear the canvas and the server's event log — asks first (C)",children:"Clear"}),m.jsx("button",{className:"btn icon-btn",onClick:()=>Xr(H=>H==="dark"?"light":"dark"),title:`Switch to ${br==="dark"?"light":"dark"} mode (T)`,"aria-label":"Toggle theme",children:br==="dark"?"☀":"☾"})]})]}),Yr?m.jsxs("div",{className:"ver-banner done",role:"status",children:[m.jsx("span",{className:"ver-dot"}),m.jsxs("strong",{children:["Restarted — now running v",Yr,"."]}),m.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):Ls&&!I?m.jsxs("div",{className:"conn-banner",role:"alert",children:[m.jsx("span",{className:"conn-dot"}),zn?Vr==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${Gt}…`:`Lost connection to the ${Gt} server. Reconnecting…`]}):ft&&ye?m.jsxs("div",{className:`ver-banner ${ye.kind}`,role:"status",children:[m.jsx("span",{className:"ver-dot"}),ye.kind==="restart"?m.jsxs(m.Fragment,{children:[m.jsxs("strong",{children:["v",ye.to," is installed — this deck still runs v",ye.from,"."]}),K!=null&&K.canRestart?m.jsxs(m.Fragment,{children:[m.jsx("button",{type:"button",className:"ver-act",onClick:()=>wr(),disabled:zn,title:"Stop this process and bring it back on the same port. The canvas replays from the event log.",children:zn?"restarting…":"Restart now"}),m.jsxs("button",{type:"button",className:`ver-auto${mn?" on":""}`,role:"switch","aria-checked":mn,onClick:yr,title:mn?"Restarts on its own once nothing has been running for 30 seconds. Click to require a click instead.":"Only restarts when you click. Click to let it restart itself while idle.",children:[m.jsx("i",{"aria-hidden":!0}),"auto when idle"]})]}):m.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."})]}):m.jsxs(m.Fragment,{children:[m.jsxs("strong",{children:[Gt," v",ye.to," is out — you are on v",ye.from,"."]}),(K==null?void 0:K.upgradeMode)==="install"&&Qe!=="failed"&&m.jsx("button",{type:"button",className:"ver-act",onClick:zt,disabled:Qe==="running"||Qe==="done",title:`Runs ${((Qa=K==null?void 0:K.upgrade)==null?void 0:Qa.command)??(K==null?void 0:K.command)??"npm i -g"} here, then restarts once nothing is running.`,children:Qe==="running"?"installing…":Qe==="done"?"installed":"Update now"}),(K==null?void 0:K.upgradeMode)==="npx"&&(K==null?void 0:K.canRestart)&&m.jsx("button",{type:"button",className:"ver-act",onClick:()=>wr({upgrade:!0}),disabled:zn,title:`Runs ${K==null?void 0:K.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:zn?"fetching…":Qe==="failed"?"Retry update":"Update & restart"}),Qe==="failed"?m.jsxs("span",{className:"ver-sub fail",title:((Za=K==null?void 0:K.upgrade)==null?void 0:Za.error)??"",children:[(K==null?void 0:K.upgradeMode)==="npx"?"update failed":"install failed",": ",((Ja=K==null?void 0:K.upgrade)==null?void 0:Ja.error)??"unknown error"," — run it yourself:"]}):(K==null?void 0:K.upgradeMode)==="npx"?m.jsx("span",{className:"ver-sub",children:K!=null&&K.canRestart?"npx cannot upgrade in place, so the deck re-runs:":yv.npx}):K!=null&&K.upgradeBlocked?m.jsx("span",{className:"ver-sub",children:Object.hasOwn(yv,K.upgradeBlocked)?yv[K.upgradeBlocked]:"cannot install from here"}):null,m.jsxs("button",{type:"button",className:"ver-cmd",onClick:et,title:"Copy to clipboard",children:[m.jsx("code",{children:K==null?void 0:K.command}),m.jsx("span",{className:"ver-cmd-hint",children:ae?"copied":"copy"})]})]}),m.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:Ze,children:"×"})]}):Ot&&Xe?m.jsxs("div",{className:"ver-banner",role:"status",children:[m.jsx("span",{className:"ver-dot"}),m.jsxs("strong",{children:[Xe," still works — the deck is called ",Gt," now."]}),K!=null&&K.renameFix?m.jsx("span",{className:"ver-sub",children:K.renameFix}):null,m.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:lt,children:"×"})]}):null,O&&m.jsx(T3,{state:t.current,now:ut,providers:we,onClose:()=>D(!1)}),L&&we.claude&&m.jsx(j$,{onClose:()=>U(!1)}),j&&m.jsx(w3,{state:t.current,now:ut,selectedIds:o,onSelect:Ti,onClose:()=>A(!1)}),m.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${Va?" bubbling":""}${Ci?" dragging-any":""}`,ref:Bn,onMouseDownCapture:zs,children:[jr===0&&m.jsx(RF,{live:I,everConnected:Ls,providers:we}),Cn.empty&&jr>0&&m.jsxs("div",{className:"search-empty",role:"status",children:[m.jsx("span",{className:"search-empty-text",children:Cn.message}),m.jsx("button",{type:"button",className:"btn",onClick:()=>{var H;Kr(""),(H=Zr.current)==null||H.focus()},children:"Clear search"})]}),ss.length>1&&m.jsx("div",{ref:bn,className:`cat-filter-bar${gr?" occluded":""}`,role:"group","aria-label":"Filter tools by category",children:ss.map(H=>{const Y=Si.has(H);return m.jsxs("button",{type:"button",className:`cat-filter${Y?" off":""}`,onClick:()=>lr(H),"aria-pressed":!Y,title:`${Y?"Show":"Hide"} ${Hv[H]} tools`,children:[m.jsx("span",{className:"cat-emoji",children:Uv[H]}),m.jsx("span",{className:"cat-name",children:Hv[H]})]},H)})}),m.jsxs(SC,{nodes:uc,edges:ji,nodeTypes:oF,fitView:!_r,fitViewOptions:{padding:.25,duration:400},minZoom:.2,maxZoom:1.6,panOnScroll:!0,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,onNodeClick:(H,Y)=>{if(Y.type==="sessionGroup"){g();return}d(Y.id,H.shiftKey)},onPaneClick:()=>g(),onMoveStart:()=>{Date.now()-St.current<1200||Ha()},onMove:(H,Y)=>{Sr(),No.current&&window.clearTimeout(No.current),No.current=window.setTimeout(()=>kF(Y),250)},onNodeDragStart:(H,Y)=>{var oe;if(Ga(),ki.current=!0,Bt.current=new Map,Us(!0),Sr(),Ha(),Y.type==="sessionGroup"){const de=(oe=Y.data)==null?void 0:oe.sessionId,xe=new Map;if(de)for(const Se of Qt){const Pe=Se.data;(Pe==null?void 0:Pe.sessionId)===de&&xe.set(Se.id,{x:Se.position.x,y:Se.position.y})}xr.current={start:{x:Y.position.x,y:Y.position.y},members:xe};return}Tt.current.set(Y.id,{x:Y.position.x,y:Y.position.y})},onNodeDrag:(H,Y)=>{var oe;if(Sr(),Y.type==="sessionGroup"){const de=xr.current;if(!de)return;const xe=Y.position.x-de.start.x,Se=Y.position.y-de.start.y;for(const[Fe,Ge]of de.members){const We={x:Ge.x+xe,y:Ge.y+Se};Tt.current.set(Fe,We),Xt.current.set(Fe,We)}const Pe=Bt.current;if(Pe){for(const[Fe,Ge]of de.members)Pe.set(Fe,{x:Ge.x+xe,y:Ge.y+Se});Pe.set(Y.id,{x:Y.position.x,y:Y.position.y})}pn(Fe=>Fe+1);return}Tt.current.set(Y.id,{x:Y.position.x,y:Y.position.y}),Xt.current.set(Y.id,{x:Y.position.x,y:Y.position.y}),(oe=Bt.current)==null||oe.set(Y.id,{x:Y.position.x,y:Y.position.y}),pn(de=>de+1)},onNodeDragStop:(H,Y)=>{if(Sr(),ki.current=!1,Bt.current=null,Us(!1),Lt(oe=>oe+1),Y.type==="sessionGroup"){const oe=xr.current;if(oe){const de=Y.position.x-oe.start.x,xe=Y.position.y-oe.start.y;for(const[Se,Pe]of oe.members){const Fe={x:Pe.x+de,y:Pe.y+xe};Tt.current.set(Se,Fe),Xt.current.set(Se,Fe)}}xr.current=null,wv(Xt.current,Tt.current),Lt(de=>de+1);return}Tt.current.set(Y.id,{x:Y.position.x,y:Y.position.y}),Xt.current.set(Y.id,{x:Y.position.x,y:Y.position.y}),wv(Xt.current,Tt.current)},children:[m.jsx(EP,{gap:28,size:1,color:fa("--grid-line")}),m.jsx(AL,{}),m.jsx(f3,{agents:t.current.agents,visibleAgentIds:Nn,positions:Xt.current,pinned:Tt.current,measured:or.current,dimUnmatched:Cn.dim?Nr:null,spotlight:Fs,hiddenCategories:Si,now:ut,onOpenTool:p}),m.jsx(wP,{showInteractive:!1,children:m.jsx(io,{onClick:Co,title:Ds?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view",style:Ds?{color:"var(--accent)"}:void 0,children:m.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[m.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),m.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})})}),m.jsx(fP,{zoomable:!0,pannable:!0,nodeColor:H=>K5(H,fa),nodeStrokeWidth:2,maskColor:fa("--minimap-mask"),style:{background:fa("--panel"),border:`1px solid ${fa("--line")}`,borderRadius:8}})]})]}),M?m.jsxs("aside",{className:"detail","aria-label":"Detail",children:[m.jsx("button",{type:"button",className:"detail-close",title:"Close panel","aria-label":"Close detail panel",onClick:()=>P(!1),children:"×"}),Rt?m.jsx(MF,{agent:Rt,now:ut,onOpenTool:p,onShowSummary:H=>{N.current.has(H)&&(N.current.delete(H),rN(N.current)),w(H)},onExportSession:H=>EF(t.current,H)}):m.jsx(IF,{count:jr,workspace:Ee})]}):m.jsx("button",{type:"button",className:"detail-reopen",title:"Show detail panel","aria-label":"Show detail panel",onClick:()=>P(!0),children:"‹"}),os&&m.jsx(NL,{tool:os,onClose:()=>p(null)}),vt&&m.jsx(yq,{providers:we,onClose:()=>hn(!1)}),E&&(()=>{const H=t.current.agents.get(E);return H?m.jsx(wL,{agent:H,onClose:()=>_(null)}):null})(),y&&m.jsx(p3,{state:t.current,sessionId:y,onClose:()=>{N.current.add(y),rN(N.current),w(null)}}),S&&m.jsx(P$,{agentCount:jr,onConfirm:()=>Vs("confirmation"),onCancel:()=>k(!1)})]})}function RF({live:e,everConnected:t,providers:r}){const i=!e;return m.jsxs("div",{className:"empty-hero",children:[m.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[m.jsx("div",{className:"core"}),m.jsxs("div",{className:"orbit r1",children:[m.jsx("span",{className:"dot"}),m.jsx("span",{className:"dot b"})]}),m.jsxs("div",{className:"orbit r2",children:[m.jsx("span",{className:"dot"}),m.jsx("span",{className:"dot b"})]}),m.jsxs("div",{className:"orbit r3",children:[m.jsx("span",{className:"dot"}),m.jsx("span",{className:"dot b"})]})]}),i?m.jsxs(m.Fragment,{children:[m.jsx("h2",{children:t?"Disconnected from server":"Server unreachable"}),m.jsxs("p",{children:["The browser cannot reach ",m.jsx("code",{children:"/events"}),". Check that",m.jsx("code",{children:Gt})," is still running in your terminal, then this page will resume automatically."]})]}):AF(r)]})}function AF(e){return m.jsxs(m.Fragment,{children:[m.jsx("h2",{children:"Waiting for Claude Code or Codex"}),m.jsxs("p",{children:["Run ",m.jsx("code",{children:"claude"})," or ",m.jsx("code",{children:"codex"})," in any folder. As soon as a session sends an event, a node appears here and grows as subagents fork and tools are called."]}),m.jsxs("p",{className:"hint-row",children:["Not seeing anything? Make sure ",m.jsx("code",{children:Gt})," is running."]}),fq(e).map(t=>m.jsx("p",{className:"hint-row",children:t.spans.map((r,i)=>r.code?m.jsx("code",{children:r.text},i):m.jsx("span",{children:r.text},i))},t.provider))]})}function IF({count:e,workspace:t}){const r=eF(t);return m.jsxs(m.Fragment,{children:[m.jsx("h2",{children:"Detail"}),e===0?m.jsxs("div",{className:"hint",children:[r.lead,r.workspace!==null&&m.jsxs(m.Fragment,{children:[" ",m.jsx("code",{children:r.workspace}),r.tail]})]}):m.jsx("div",{className:"empty",children:"Click an agent to see its tools."}),m.jsx("h3",{style:{marginTop:4},children:"Shortcuts"}),m.jsxs("div",{className:"shortcuts",children:[m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"drag"}),m.jsx("span",{children:"move a node"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"tab"}),m.jsx("span",{children:"reach the cards"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"enter"}),m.jsx("span",{children:"select the focused card"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"/"}),m.jsx("span",{children:"focus search"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"space"}),m.jsx("span",{children:"pause / resume"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"J"}),m.jsx("span",{children:"next agent"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"K"}),m.jsx("span",{children:"previous agent"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"R"}),m.jsx("span",{children:"re-arrange"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"F"}),m.jsx("span",{children:"fit view"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"L"}),m.jsx("span",{children:"session list"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"H"}),m.jsx("span",{children:"usage history"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"U"}),m.jsx("span",{children:"usage panel"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"C"}),m.jsx("span",{children:"clear canvas"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"T"}),m.jsx("span",{children:"toggle theme"})]}),m.jsxs("div",{className:"sc",children:[m.jsx("kbd",{children:"Esc"}),m.jsx("span",{children:"deselect, release focus"})]})]})]})}function MF({agent:e,now:t,onOpenTool:r,onShowSummary:i,onExportSession:o}){const a=Tu(e.startedAt,e.endedAt,t),u=dn(e.usage,e.model),c=u.total>0,f=e.usage.inputTokens+e.usage.outputTokens,p=new Map;for(const w of e.tools){const E=fT(w.name);p.set(E,(p.get(E)??0)+1)}const d=e.tools.filter(w=>w.ok===!1).length,g=e.tools.filter(w=>!w.endedAt).length,y=Array.from(p.entries()).sort((w,E)=>E[1]-w[1]);return m.jsxs(m.Fragment,{children:[m.jsxs("header",{className:"detail-hero",children:[m.jsxs("div",{className:"hero-line",children:[m.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),m.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),m.jsxs("div",{className:"hero-meta",children:[m.jsx("span",{className:"hero-meta-item",children:e.kind}),m.jsx("span",{className:"hero-sep",children:"·"}),m.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:a}),e.model&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"hero-sep",children:"·"}),m.jsx("span",{className:"model-chip",title:e.model,children:Rs(e.model)})]})]}),c&&m.jsxs("div",{className:"hero-cost",children:[m.jsxs("div",{className:"hero-cost-headline",children:[m.jsx("span",{className:"hero-cost-value",children:qe(u.total)}),m.jsx("span",{className:"hero-cost-label",children:"spend"})]}),m.jsx(fy,{cost:u})]}),m.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&i&&m.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>i(e.sessionId),title:"Reopen the end-of-session recap modal",children:"Show recap"}),o&&m.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>o(e.sessionId),title:"Download this session as JSON",children:"Export JSON"})]})]}),e.tools.length>0&&m.jsxs("section",{className:"detail-section",children:[m.jsx("h3",{children:"Activity"}),m.jsxs("div",{className:"activity-row",children:[m.jsxs("div",{className:"activity-counters",children:[m.jsxs("span",{className:"ac-item",children:[m.jsx("b",{children:e.toolCount})," calls"]}),g>0&&m.jsxs("span",{className:"ac-item ac-live",children:[m.jsx("b",{children:g})," live"]}),d>0&&m.jsxs("span",{className:"ac-item ac-err",children:[m.jsx("b",{children:d})," err"]})]}),m.jsx("div",{className:"cat-strip",children:y.map(([w,E])=>m.jsxs("span",{className:`cat-chip cat-${w}`,title:`${E} ${Hv[w]} call${E===1?"":"s"}`,children:[m.jsx("span",{className:"cat-emoji",children:Uv[w]}),m.jsx("span",{className:"cat-count",children:E})]},w))})]})]}),f>0&&m.jsxs("section",{className:"detail-section",children:[m.jsx("h3",{children:"Tokens"}),m.jsxs("div",{className:"tokens-grid",children:[m.jsxs("div",{children:[m.jsx("span",{className:"k",children:"in"}),m.jsx("b",{children:e.usage.inputTokens.toLocaleString()})]}),m.jsxs("div",{children:[m.jsx("span",{className:"k",children:"out"}),m.jsx("b",{children:e.usage.outputTokens.toLocaleString()})]}),m.jsxs("div",{children:[m.jsx("span",{className:"k",children:"cache r"}),m.jsx("b",{children:e.usage.cacheReadTokens.toLocaleString()})]}),m.jsxs("div",{children:[m.jsx("span",{className:"k",children:"cache c"}),m.jsx("b",{children:e.usage.cacheCreateTokens.toLocaleString()})]})]})]}),m.jsxs("section",{className:"detail-section",children:[m.jsx("h3",{children:"Identity"}),m.jsxs("div",{children:[e.cwd&&m.jsxs("div",{className:"row",children:[m.jsx("span",{className:"k",children:"cwd"}),m.jsx("span",{className:"v",title:e.cwd,children:e.cwd})]}),m.jsxs("div",{className:"row",children:[m.jsx("span",{className:"k",children:"session"}),m.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&m.jsxs("div",{className:"row",children:[m.jsx("span",{className:"k",children:"parent"}),m.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),e.prompts.length>0&&m.jsxs("section",{className:"detail-section",children:[m.jsxs("h3",{children:["Prompts ",m.jsx("span",{className:"section-count",children:e.prompts.length})]}),m.jsx("div",{className:"prompts",children:e.prompts.slice().reverse().map((w,E)=>{const _=_3(w.at,t);return m.jsxs("div",{className:"prompt-entry",children:[m.jsx("div",{className:"prompt-time",title:_.title,children:_.label}),m.jsx("div",{className:"prompt-text",children:w.text})]},E)})})]}),m.jsxs("section",{className:"detail-section",children:[m.jsxs("h3",{children:["Tool calls ",m.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&m.jsx("div",{className:"empty",children:"No tool calls yet."}),m.jsx("div",{children:e.tools.slice().reverse().map(w=>m.jsx(PF,{t:w,onClick:()=>r(w.id)},w.id))})]})]})}const OF={inflight:"in-flight",done:"done",err:"error"};function PF({t:e,onClick:t}){const r=e.endedAt==null?"inflight":e.ok===!1?"err":"done",i=qC(e,"…");return m.jsxs("button",{className:"tool clickable",title:e.inputPreview||e.name,onClick:t,children:[m.jsxs("span",{className:"name",children:[m.jsx("span",{className:`status-dot ${r}`,"aria-hidden":!0}),m.jsx("span",{className:"vis-hidden",children:OF[r]}),e.name]}),m.jsx("span",{style:{color:"var(--muted)"},children:i})]})}try{I3(window.localStorage)}catch{}const LF=SR.createRoot(document.getElementById("root"));LF.render(m.jsx(jF,{}));
|