agent-dag 1.33.142 → 1.33.143
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.
|
@@ -58,7 +58,7 @@ Error generating stack: `+w.message+`
|
|
|
58
58
|
`)}function wv(e,n,r){const i=(n??r)-e;if(i<1e3)return`${Math.max(0,i)}ms`;const o=Math.floor(i/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60),u=o%60;return`${l}m ${String(u).padStart(2,"0")}s`}function _O({data:e,selected:n}){var p;const r=e.now??Date.now(),i=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",n?"selected":""].filter(Boolean).join(" "),o=e.tools.filter(f=>!f.endedAt).length,l=Vv(e.sessionId),u=((p=e.context)==null?void 0:p.currentContextTokens)??0,c=e.kind==="root"&&u>0;return m.jsxs("div",{className:i,style:{"--session-hue":l},children:[m.jsx("span",{className:"accent-stripe"}),m.jsx(po,{type:"target",position:Ae.Left,style:{background:"transparent",border:"none"}}),m.jsxs("div",{className:"head",children:[m.jsxs("div",{className:"title",children:[m.jsx(bO,{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(wO,{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:wv(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:li(e.model)})]}),e.waiting&&m.jsx(kO,{waiting:e.waiting,now:r}),e.tools.length>0&&m.jsx(NO,{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:EO(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&Gv(e.model)&&(()=>{const f=fn(e.usage,e.model);if(f.total<=0)return null;const h=Math.max(0,((e.endedAt??r)-e.startedAt)/1e3),g=e.state==="active"?gu(f.total,h):null,y=xO(e.usage,e.model)+(g?`
|
|
59
59
|
burn: ${g}`:"");return m.jsxs("span",{className:"cost-meta",title:y,children:[m.jsx("b",{children:Fe(f.total)}),g&&m.jsx("span",{className:"cost-rate",children:g})]})})()]}),m.jsx(po,{type:"source",position:Ae.Right,style:{background:"transparent",border:"none"}})]})}function bO({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return m.jsx("span",{className:`state-pill state-${e}`,children:n})}function Nu(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function SO(e){return e.kind==="permission"?Nu(e):"Your turn"}function kO({waiting:e,now:n}){const r=e.kind==="permission",i=Nu(e);return m.jsxs("div",{className:r?"waiting-row permission":"waiting-row idle",title:`${i}
|
|
60
60
|
Blocked for ${wv(e.since,void 0,n)} — 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:SO(e)}),m.jsx("b",{children:wv(e.since,void 0,n)})]})}function EO(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function NO({tools:e,now:n}){const l=new Array(24).fill(0);let u=0;for(const y of e){const x=n-y.startedAt;if(x<0||x>=6e4)continue;const N=23-Math.floor(x/2500);N>=0&&N<24&&(l[N]+=1,u+=1)}const c=Math.max(1,...l),p=132,f=14,h=p/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:p,height:f,viewBox:`0 0 ${p} ${f}`,"aria-hidden":!0,children:l.map((y,x)=>{const N=y===0?1.5:Math.max(1.5,y/c*f),_=x===23&&y>0,b=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return m.jsx("rect",{x:x*h+.4,y:f-N,width:Math.max(.5,h-1),height:N,rx:.8,className:b},x)})}),m.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function li(e){const n=e.replace(/^anthropic\./,"").replace(/[-_]\d{8}(?!\d)/,""),r=n.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(r){const l=r[1][0].toUpperCase()+r[1].slice(1).toLowerCase(),u=r[2].replace(/[-_]/g,".");return`${l} ${u}`}const i=n.match(/^gpt[-_](\d+(?:[-_.]\d+)*)[-_]codex\b/i);if(i)return`GPT-${i[1].replace(/[-_]/g,".")} Codex`;const o=n.match(/^gpt[-_](\d+(?:[-_.]\d+)*)/i);return o?`GPT-${o[1].replace(/[-_]/g,".")}`:e}function Tx(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function CO(e){if(e.endedAt==null)return"in-flight…";const n=e.endedAt-e.startedAt;return n<1e3?`${n}ms`:`${(n/1e3).toFixed(2)}s`}function jO({tool:e,onClose:n}){vo(n);const r=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return m.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:m.jsxs("div",{className:"modal",onClick:i=>i.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 ${r}`}),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:CO(e)}),m.jsx("button",{className:"btn icon-btn",onClick:n,"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:Tx(e.input??e.inputPreview)})]}),m.jsxs("div",{className:"modal-section",children:[m.jsxs("h4",{children:["Response ",r==="err"&&m.jsx("span",{className:"err-tag",children:"error"})]}),m.jsx("pre",{children:e.endedAt==null?"(waiting…)":Tx(e.response??e.errorPreview)})]})]})]})})}const Yl=18,Ax=26,RO=12;function TO(e){return AO(e.nodeInternals.values())}function AO(e){const n=new Map;for(const o of e){if(o.type!=="agent")continue;const l=o.data;if(!(l!=null&&l.sessionId)||l.exitAt!=null||o.width==null||o.height==null)continue;const u=o.position.x,c=o.position.y,p=u+o.width,f=c+o.height,h=n.get(l.sessionId);h?(h.minX=Math.min(h.minX,u),h.minY=Math.min(h.minY,c),h.maxX=Math.max(h.maxX,p),h.maxY=Math.max(h.maxY,f),l.kind==="root"&&(h.label=Ix(l)??h.label)):n.set(l.sessionId,{minX:u,minY:c,maxX:p,maxY:f,label:Ix(l)??l.sessionId})}const r=new Map;for(const o of n.values())r.set(o.label,(r.get(o.label)??0)+1);const i=[];for(const[o,l]of n){const c=(r.get(l.label)??0)>1?`${l.label} · ${IO(o)}`:l.label;i.push({sessionId:o,label:c,x:l.minX-Yl,y:l.minY-Yl-Ax,w:l.maxX-l.minX+Yl*2,h:l.maxY-l.minY+Yl*2+Ax})}return i}function IO(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function Ix(e){if(e.kind==="root")return e.label}function MO(){const{x:e,y:n,zoom:r}=VN(),i=Pa(),o=Ke(TO,PO);if(o.length<=1)return null;const l=u=>{try{const c=i.getNodes().filter(p=>{const f=p.data;return(f==null?void 0:f.sessionId)===u});if(c.length===0)return;i.fitView({padding:.3,duration:500,nodes:c})}catch{}};return m.jsx("div",{className:"session-clusters",children:o.map(u=>{const c=Vv(u.sessionId),p={position:"absolute",left:u.x*r+e,top:u.y*r+n,width:u.w*r,height:u.h*r,"--session-hue":c},f={position:"absolute",left:u.x*r+e+16*r,top:(u.y-RO)*r+n,transform:`scale(${Math.min(1,r)})`,transformOrigin:"left top","--session-hue":c};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:f,title:`Fit view to ${u.label} · drag the wrapper to move the whole session`,onClick:()=>l(u.sessionId),children:u.label})]},u.sessionId)})})}function PO(e,n){if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],o=n[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 OO({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 iC=600,LO=4,qO=36,xv=16,$O=60,DO=6,Mx=220,Px=96,FO=28,zO={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",shell:"shell",exec_command:"shell",shell_command:"shell",write_stdin:"shell",wait:"shell",apply_patch:"file",update_plan:"task",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",ScheduleWakeup:"other",CronCreate:"other",CronList:"other",CronDelete:"other",Monitor:"other",PushNotification:"other",RemoteTrigger:"other",ToolSearch:"other"};function BO(e){return e.startsWith("mcp__")?"mcp":zO[e]??"other"}const UO={Read:"📖",Write:"💾",Edit:"✏️",MultiEdit:"🔧",Glob:"🗺️",Grep:"🔎",Bash:"⚡",PowerShell:"💻",shell:"⚡",exec_command:"⚡",shell_command:"⚡",write_stdin:"💻",wait:"⏳",apply_patch:"🩹",update_plan:"📋",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:"📡"};function Ox(e){return e.startsWith("mcp__")?"🔌":UO[e]??"✨"}const HO={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 oC(e){if(!e)return null;let n=e.trim();if(!n)return null;const r=n.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(r)return oC(r[1]);for(;;){const l=n.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!l)break;n=n.slice(l[0].length)}n=n.replace(/^sudo(?:\s+-\S+)*\s+/,""),n=n.replace(/^(?:time|nohup|xargs)\s+/,"");const i=n.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 WO(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const n=e;if(typeof n.cmd=="string")return n.cmd;if(typeof n.command=="string")return n.command;if(Array.isArray(n.command)&&n.command.every(r=>typeof r=="string")){const r=n.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 n.script=="string"?n.script:null}const VO=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),GO=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function YO(e,n){return GO.has(e)||e.startsWith("mcp__")?Math.max(Px,34+n.length*7.5):Px}function KO(e,n){if(!VO.has(e))return null;const r=WO(n);if(!r)return null;const i=oC(r);return i?{emoji:HO[i]??"⚙️",label:i,category:"shell",detail:r}:null}const XO=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),Lx={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:"🗄️"},qx={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 QO(e){const r=e.replace(/\\/g,"/").replace(/\/+$/,""),i=r.lastIndexOf("/");return i>=0?r.slice(i+1):r}function ZO(e){const n=e.toLowerCase();if(qx[n])return qx[n];if(n.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(n))return"🧪";const r=n.lastIndexOf(".");if(r>0&&r<n.length-1){const i=n.slice(r+1);if(Lx[i])return Lx[i]}return"📄"}function JO(e,n){if(!n||typeof n!="object")return null;const r=n;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 e3(e,n){if(!XO.has(e))return null;const r=JO(e,n);if(!r)return null;const i=QO(r);return i?{emoji:e==="LS"?"📂":ZO(i),label:i,category:"file",detail:r}:null}const aC={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 lC(e){if(!e.startsWith("mcp__"))return null;const n=e.slice(5),r=n.indexOf("__");return r<=0?{server:n,method:""}:{server:n.slice(0,r),method:n.slice(r+2)}}function t3(e){let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n^e.charCodeAt(r);return Math.abs(n)%360}function n3(e,n){const r=lC(e);if(!r)return null;const{server:i,method:o}=r;if(!o)return null;const l=aC[i.toLowerCase()];return{emoji:(l==null?void 0:l.emoji)??"🔌",label:o,category:"mcp",detail:l?`${l.name} · ${o}`:`${i} · ${o}`}}function r3(e,n){return KO(e,n)??e3(e,n)??n3(e)}const s3={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function i3(e){const n=lC(e);if(n){const i=aC[n.server.toLowerCase()];return i?{emoji:i.emoji,label:i.name}:{emoji:"🔌",label:n.server,hue:t3(n.server)}}const r=s3[e];return r?{emoji:Ox(e),label:r}:{emoji:Ox(e),label:e}}function o3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function a3(e,n,r){if(r==null)return 1;const i=n-r;return i<0?1:Math.max(0,1-i/iC)}function l3(e,n){const r=[],i=new Set;for(let o=e.length-1;o>=0&&r.length<n;o--){const l=e[o];i.has(l.id)||(i.add(l.id),r.push(l))}return r.reverse()}function u3(e,n,r,i,o,l){const u=[];for(const c of e.values()){if(!n.has(c.id)||c.exitAt!=null&&l-c.exitAt>iC)continue;const p=i.get(c.id)??r.get(c.id);if(!p)continue;const f=l3(c.tools,LO);if(f.length===0)continue;const h=c.exitAt??null,g=o.get(c.id),y=Math.max((g==null?void 0:g.width)??Mx,Mx),x=(g==null?void 0:g.height)??130,N=p.x,_=p.y,S=N+y,b=_+x/2;f.forEach((k,E)=>{const C=E*qO,A=N+y+$O,M=_+DO+C,L=a3(k,l,h),H=k.inputPreview??"",O=o3(k),P=L<.999,F=i3(k.name);u.push({id:`${c.id}::${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:F.label,emoji:F.emoji,status:O,category:BO(k.name),mcpHue:F.hue,inputPreview:H,fade:L,fading:P,worldX:A,worldY:M,anchorX:S,anchorY:b,spawnDx:S-A,spawnDy:b-(M+xv)});const G=r3(k.name,k.input);if(G){const q=YO(k.name,F.label),R=A+q+FO,Q=M,z=A+q,ne=M+xv;u.push({id:`sub:${c.id}::${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:G.label,emoji:G.emoji,isSub:!0,status:O,category:G.category,inputPreview:G.detail??H,fade:L,fading:P,worldX:R,worldY:Q,anchorX:z,anchorY:ne,spawnDx:z-R,spawnDy:0})}})}return u}function c3({agents:e,visibleAgentIds:n,positions:r,pinned:i,measured:o,dimUnmatched:l,spotlight:u,hiddenCategories:c,now:p,onOpenTool:f}){const h=u3(e,n,r,i,o,p),g=c&&c.size>0?h.filter(y=>!c.has(y.category)):h;return m.jsx(d3,{bursts:g,dimUnmatched:l,spotlight:u,onOpenTool:f})}function d3({bursts:e,dimUnmatched:n,spotlight:r,onOpenTool:i}){const{x:o,y:l,zoom:u}=VN();return m.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[m.jsx("svg",{className:"tool-bursts-svg",children:e.map(c=>{const p=c.anchorX*u+o,f=c.anchorY*u+l,h=(c.worldX+6)*u+o,g=(c.worldY+xv)*u+l,y=p+(h-p)*.55,x=n!=null&&!n.has(c.agentId),N=r!=null&&!r.has(c.agentId),_=c.fade*(x||N?.14:1);return m.jsx("path",{d:`M ${p} ${f} Q ${y} ${f}, ${h} ${g}`,className:`tool-conn status-${c.status}${c.fading?" fading":""}`,opacity:_},`l:${c.id}`)})}),e.map(c=>{const p=c.worldX*u+o,f=c.worldY*u+l,h={left:`${p}px`,top:`${f}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,x=i!=null,N=c.mcpHue!=null?{"--mcp-hue":c.mcpHue}:{},_=n!=null&&!n.has(c.agentId),S=r!=null&&!r.has(c.agentId),b=_||S?" dim":"";return m.jsx("div",{className:"tool-burst-wrap",style:h,children:m.jsxs("div",{className:`tool-burst cat-${c.category}${c.mcpHue!=null?" mcp-hue":""} status-${c.status}${c.fading?" fading":""}${x?" clickable":""}${c.isSub?" sub":""}${b}`,style:N,title:y,role:x?"button":void 0,tabIndex:x?0:void 0,"aria-label":x?`Open ${c.toolName} ${c.status==="inflight"?"in flight":c.status} — click for details`:void 0,onClick:x?()=>i(c.toolId):void 0,onKeyDown:x?k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),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 f3({state:e,sessionId:n,onClose:r}){const i=T.useMemo(()=>p3(e,n),[e,n]),o=T.useRef(null);return vo(r,{focusRef:o}),i?m.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:m.jsxs("div",{className:"modal session-summary",onClick:l=>l.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:Fe(i.cost.total)}),i.modelChips.length>0&&m.jsx("div",{className:"ss-models",children:i.modelChips.map(l=>m.jsx("span",{className:"model-chip",title:l,children:li(l)},l))})]}),m.jsx("div",{className:"ss-hero-right",children:i.cost.total>0&&m.jsxs(m.Fragment,{children:[m.jsx(h3,{cost:i.cost}),m.jsxs("div",{className:"ss-cost-legend",children:[m.jsxs("span",{className:"ssl ssl-in",children:["input ",m.jsx("b",{children:Fe(i.cost.input)})]}),m.jsxs("span",{className:"ssl ssl-out",children:["output ",m.jsx("b",{children:Fe(i.cost.output)})]}),m.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",m.jsx("b",{children:Fe(i.cost.cacheRead)})]}),m.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",m.jsx("b",{children:Fe(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(([l,u])=>m.jsxs("div",{className:"ss-tt",children:[m.jsx("span",{className:"ss-tt-name",children:l}),m.jsx("span",{className:"ss-tt-bar",children:m.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${u/i.topTools[0][1]*100}%`}})}),m.jsx("span",{className:"ss-tt-count",children:u})]},l))})]}),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:n,tone:r}){return m.jsxs("div",{className:`ss-stat${r?` tone-${r}`:""}`,children:[m.jsx("div",{className:"ss-stat-value",children:n}),m.jsx("div",{className:"ss-stat-label",children:e})]})}function h3({cost:e}){const n=e.total;if(n<=0)return null;const r=(i,o,l)=>{if(i<=0)return null;const u=i/n*100;return m.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Fe(i)} (${u.toFixed(0)}%)`},o)};return m.jsxs("div",{className:"cost-bar cost-bar-lg","aria-label":"Cost breakdown",children:[r(e.input,"cb-input","input"),r(e.output,"cb-output","output"),r(e.cacheRead,"cb-cache-r","cache read"),r(e.cacheWrite,"cb-cache-w","cache write")]})}function p3(e,n){const r=e.agents.get(n);if(!r)return null;const i=[];for(const E of e.agents.values())E.sessionId===n&&i.push(E);if(i.length===0)return null;const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},l=new Set,u=new Map;let c=0,p=0,f=0,h=0,g=0,y,x=1/0,N=0;for(const E of i){const C=fn(E.usage,E.model);o.input+=C.input,o.output+=C.output,o.cacheRead+=C.cacheRead,o.cacheWrite+=C.cacheWrite,o.total+=C.total,E.model&&l.add(E.model),E.kind==="subagent"&&g++,p+=E.prompts.length,!y&&E.prompts.length>0&&(y=E.prompts[0].text),f+=E.usage.inputTokens+E.usage.outputTokens,c+=E.toolCount,x=Math.min(x,E.startedAt),N=Math.max(N,E.endedAt??Date.now());for(const A of E.tools)u.set(A.name,(u.get(A.name)??0)+1),A.ok===!1&&h++}const _=Math.max(0,N-x),S=Math.floor(_/1e3),b=S<60?`${S}s`:S<3600?`${Math.floor(S/60)}m ${String(S%60).padStart(2,"0")}s`:`${Math.floor(S/3600)}h ${Math.floor(S%3600/60)}m`,k=Array.from(u.entries()).sort((E,C)=>C[1]-E[1]).slice(0,5);return{sessionId:n,label:r.label||r.cwdBasename||"session",cwd:r.cwd,durationLabel:b,cost:o,modelChips:Array.from(l),agentCount:i.length,subagentCount:g,toolCount:c,promptCount:p,tokensSum:f,errCount:h,topTools:k,firstPrompt:y}}function $x(e){return e.waiting?e.waiting.kind==="permission"?0:1:e.state==="active"?2:3}function m3(e,n){const r=[];for(const i of e.agents.values()){if(i.kind!=="root")continue;let o=i.toolCount,l=fn(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,l+=fn(c.usage,c.model).total;const p=c.endedAt??c.startedAt;p>u&&(u=p)}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:l,startedAt:i.startedAt,lastActivity:u})}return r.sort((i,o)=>{const l=$x(i),u=$x(o);return l!==u?l-u:i.waiting&&o.waiting?i.waiting.since-o.waiting.since:o.lastActivity-i.lastActivity}),r}function Dx(e,n,r){const i=(n??r)-e;if(i<1e3)return"<1s";const o=Math.floor(i/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60);return l<60?`${l}m`:`${Math.floor(l/60)}h ${l%60}m`}function g3({state:e,now:n,selectedIds:r,onSelect:i,onClose:o}){const l=T.useMemo(()=>m3(e),[e,e.lastSeq,n]),u=l.filter(p=>p.state==="active").length,c=l.filter(p=>{var f;return((f=p.waiting)==null?void 0:f.kind)==="permission"}).length;return m.jsxs("aside",{className:"session-list","aria-label":"Sessions",children:[m.jsxs("div",{className:"sl-header",children:[m.jsxs("h3",{children:["Sessions ",m.jsx("span",{className:"sl-count",children:l.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:[l.length===0&&m.jsx("div",{className:"sl-empty",children:"No sessions yet."}),l.map(p=>{const f=r.has(p.sessionId);return m.jsxs("button",{type:"button",className:`sl-row state-${p.state}${f?" selected":""}`,onClick:()=>i(p.sessionId),title:`Focus ${p.label}`,children:[m.jsx("span",{className:`sl-dot state-${p.state}`,"aria-hidden":!0}),m.jsxs("div",{className:"sl-row-body",children:[m.jsxs("div",{className:"sl-row-head",children:[m.jsx("span",{className:"sl-label",children:p.label}),p.modelId&&m.jsx("span",{className:"model-chip",title:p.modelId,children:li(p.modelId)})]}),m.jsxs("div",{className:"sl-row-meta",children:[m.jsxs("span",{title:"tool calls",children:[m.jsx("b",{children:p.toolCount})," tools"]}),p.cost>0&&m.jsx("span",{className:"sl-cost",title:"total spend",children:m.jsx("b",{children:Fe(p.cost)})}),p.waiting?m.jsxs("span",{className:"sl-waiting",title:`${Nu(p.waiting)}
|
|
61
|
-
Blocked since ${new Date(p.waiting.since).toLocaleTimeString()} · started ${new Date(p.startedAt).toLocaleString()}`,children:["waiting ",Dx(p.waiting.since,void 0,n)]}):m.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(p.startedAt).toLocaleString()}`,children:Dx(p.startedAt,p.state==="active"?void 0:p.lastActivity,n)})]})]})]},p.sessionId)})]})]})}const zt="ccdeck";function Ft(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:e<1e9?`${(e/1e6).toFixed(2)}M`:`${(e/1e9).toFixed(2)}B`}function Fx(e,n){if(!e)return null;const r=n-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 v3(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"}function y3({cost:e}){const n=e.total;if(n<=0)return null;const r=(i,o,l)=>{if(i<=0)return null;const u=i/n*100;return m.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Fe(i)} (${u.toFixed(0)}%)`},o)};return m.jsxs("div",{className:"cost-bar","aria-label":"Cost breakdown",children:[r(e.input,"cb-input","input"),r(e.output,"cb-output","output"),r(e.cacheRead,"cb-cache-r","cache read"),r(e.cacheWrite,"cb-cache-w","cache write")]})}function w3(e,n){const r=e-n;if(r<=0)return null;const i=Math.floor(r/3600),o=Math.floor(r%3600/60);if(i>23){const l=Math.floor(r/86400),u=Math.floor(r%86400/3600);return`${l}d ${u}h`}return i>0?`${i}h ${o}m`:`${o}m`}function x3(e,n,r,i){const o=Math.max(0,n-i),l=Math.max(0,r-o);if(l<120)return null;const u=Math.min(100,l/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 p=100-e,f=l>0?e/l:0,h=f>0?p/f:1/0,g={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(h<o&&h<86400){const y=Math.floor(h/3600),x=Math.floor(h%3600/60);g.runsOutIn=y>0?`${y}h ${x}m`:`${x}m`}return g}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function ei({pct:e,label:n,reset:r,resetAt:i,windowSec:o,limitReached:l,nowSec:u}){const c=Math.min(100,Math.max(0,e)),f=l||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",h=c===0?"< 1%":`${c}%`,g=c===0?2:c,y=i?w3(i,u):null,x=i&&o?x3(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:[n,l&&m.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),m.jsx("span",{className:"qb-pct",style:{color:f},children:h})]}),m.jsxs("div",{className:"qb-track",children:[m.jsx("div",{className:"qb-fill",style:{width:`${g}%`,background:f,opacity:c===0?.4:1}}),x&&m.jsx("div",{className:"qb-pace-marker",style:{left:`${x.expectedPct}%`,background:x.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(x.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,x&&m.jsx("span",{className:"qb-pace",style:{color:x.color},children:x.runsOutIn?`runs out in ${x.runsOutIn}`:x.label})]})]})}const _3=6e4;function b3(){const[e,n]=T.useState(null),[r,i]=T.useState(!1),o=T.useRef(null),l=async(c=!1)=>{c&&i(!0);try{const f=await fetch(c?"/api/quota?refresh=1":"/api/quota");f.ok&&n(await f.json())}catch{}finally{c&&i(!1)}};return T.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),_3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:r,refresh:()=>l(!0)}}function S3(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.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const uC=6e4;function k3(){const[e,n]=T.useState(null),[r,i]=T.useState(!1),o=T.useRef(null),l=async(c=!1)=>{c&&i(!0);try{const f=await fetch(c?"/api/codex-quota?refresh=1":"/api/codex-quota");f.ok&&n(await f.json())}catch{}finally{c&&i(!1)}};return T.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),uC),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:r,refresh:()=>l(!0)}}function E3(){const[e,n]=T.useState(null),r=T.useRef(null),i=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return T.useEffect(()=>(i(),r.current=window.setInterval(i,uC),()=>{r.current!=null&&window.clearInterval(r.current)}),[]),{data:e}}function N3({state:e,now:n,onClose:r}){var L,H;const{quota:i,loading:o,refresh:l}=b3(),{data:u,loading:c,refresh:p}=k3(),{data:f}=E3(),[h,g]=T.useState(()=>Math.floor(Date.now()/1e3));T.useEffect(()=>{const O=window.setInterval(()=>g(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(O)},[]);const{byModel:y,totalCost:x,totalTokens:N,burnRate:_}=T.useMemo(()=>{const O=new Map,P={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let F=0,G=0,q=0,R=0;for(const $ of e.agents.values()){const X=$.model??"__unknown__",I=fn($.usage,$.model),W=O.get(X);W?(W.inputTokens+=$.usage.inputTokens,W.outputTokens+=$.usage.outputTokens,W.cacheReadTokens+=$.usage.cacheReadTokens,W.cacheCreateTokens+=$.usage.cacheCreateTokens,W.cost.total+=I.total,W.cost.input+=I.input,W.cost.output+=I.output,W.cost.cacheRead+=I.cacheRead,W.cost.cacheWrite+=I.cacheWrite,W.agentCount++):O.set(X,{model:X,inputTokens:$.usage.inputTokens,outputTokens:$.usage.outputTokens,cacheReadTokens:$.usage.cacheReadTokens,cacheCreateTokens:$.usage.cacheCreateTokens,cost:{...I},agentCount:1}),P.total+=I.total,P.input+=I.input,P.output+=I.output,P.cacheRead+=I.cacheRead,P.cacheWrite+=I.cacheWrite,F+=$.usage.inputTokens,G+=$.usage.outputTokens,q+=$.usage.cacheReadTokens,R+=$.usage.cacheCreateTokens}const Q=Array.from(O.values()).sort(($,X)=>X.cost.total-$.cost.total);let z=0,ne=0;for(const $ of e.agents.values()){if($.state!=="active")continue;const X=fn($.usage,$.model);z+=X.total,ne=Math.max(ne,(($.endedAt??n)-$.startedAt)/1e3)}const Z=ne>0?gu(z,ne):null;return{byModel:Q,totalCost:P,totalTokens:{in:F,out:G,cacheR:q,cacheC:R},burnRate:Z}},[e,e.lastSeq,n]),S=T.useMemo(()=>{const O=[];for(const P of e.agents.values()){if(P.kind!=="root")continue;let F=fn(P.usage,P.model).total,G=P.usage.inputTokens,q=P.usage.outputTokens;for(const R of e.agents.values())R.sessionId!==P.sessionId||R.kind==="root"||(F+=fn(R.usage,R.model).total,G+=R.usage.inputTokens,q+=R.usage.outputTokens);O.push({sessionId:P.sessionId,label:P.label||P.cwdBasename||"session",state:P.state,cost:F,inputTokens:G,outputTokens:q})}return O.sort((P,F)=>F.cost-P.cost).slice(0,12)},[e,e.lastSeq]),b=x.total>0,k=N.in+N.out,E=o||c,C=Fx(i==null?void 0:i.fetchedAt,h),A=Fx(u==null?void 0:u.fetchedAt,h),M=()=>{l(),p()};return m.jsxs("div",{className:"usage-panel","aria-label":"Usage",children:[m.jsxs("div",{className:"up-header",children:[m.jsx("h3",{children:"Usage"}),_&&m.jsx("span",{className:"up-rate",children:_}),m.jsxs("div",{className:"up-header-right",children:[m.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:M,disabled:E,title:"Refresh Claude + Codex quota",children:E?"…":"↻"}),m.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:r,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),m.jsxs("section",{className:"up-section up-quota-section",children:[m.jsxs("h4",{className:"up-section-title",children:["Claude quota",C&&!o&&m.jsx("span",{className:"up-section-age",title:v3(i==null?void 0:i.source),children:C})]}),i!=null&&i.ok?m.jsxs("div",{className:"up-quota-bars",children:[i.session5hPct!=null&&m.jsx(ei,{label:"5-hour window",pct:i.session5hPct,reset:i.session5hReset,resetAt:i.session5hResetAt,windowSec:i.session5hWindowSec,nowSec:h}),i.week7dPct!=null&&m.jsx(ei,{label:"7-day window",pct:i.week7dPct,reset:i.week7dReset,resetAt:i.week7dResetAt,windowSec:i.week7dWindowSec,nowSec:h}),i.weekSonnetPct!=null&&m.jsx(ei,{label:"Sonnet (7d)",pct:i.weekSonnetPct,nowSec:h}),i.weekOpusPct!=null&&m.jsx(ei,{label:"Opus (7d)",pct:i.weekOpusPct,nowSec:h})]}):(i==null?void 0:i.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…"})]}),m.jsxs("section",{className:"up-section up-quota-section",children:[m.jsxs("h4",{className:"up-section-title",children:["Codex quota",(u==null?void 0:u.ok)&&u.planLabel&&m.jsx("span",{className:"up-plan-badge",children:u.planLabel}),A&&!c&&m.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:A})]}),u!=null&&u.ok?m.jsxs("div",{className:"up-quota-bars",children:[(L=u.windows)==null?void 0:L.map(O=>m.jsx(ei,{label:O.label,pct:O.pct,reset:O.reset??void 0,resetAt:O.resetAt??void 0,windowSec:O.windowSec??void 0,limitReached:u.limitReached&&O.pct>=100,nowSec:h},O.id)),(H=u.extraWindows)==null?void 0:H.map(O=>m.jsx(ei,{label:O.label,pct:O.pct,reset:O.reset??void 0,resetAt:O.resetAt??void 0,windowSec:O.windowSec??void 0,nowSec:h},O.id)),u.creditLimit&&m.jsx(ei,{label:`spend cap · $${Math.round(u.creditLimit.used)} of $${Math.round(u.creditLimit.limit)}`,pct:u.creditLimit.usedPct,reset:u.creditLimit.reset??void 0,resetAt:u.creditLimit.resetAt??void 0,limitReached:u.spendControlReached,nowSec:h}),(f==null?void 0:f.ok)&&f.window7d&&f.window7d.sessionCount>0&&m.jsxs("div",{className:"up-quota-sub",children:[Ft(f.window7d.totalTokens)," tokens · ",f.window7d.sessionCount," session",f.window7d.sessionCount!==1?"s":""," (7d)"]}),u.creditsBalance&&!u.creditsUnlimited&&m.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",u.creditsBalance,u.overageReached&&" · overage limit reached"]}),u.creditsUnlimited&&m.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),u.resetCredits&&u.resetCredits.availableCount>0&&m.jsxs("div",{className:"up-quota-sub up-reset-credits",title:`Redeem in the Codex CLI or ChatGPT — ${zt} only reports them`,children:[u.resetCredits.availableCount," rate-limit reset",u.resetCredits.availableCount!==1?"s":""," available",u.resetCredits.nextExpiryAt&&` · expires ${new Date(u.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),u.promo&&m.jsx("div",{className:"up-quota-sub",children:u.promo}),u.partial&&m.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(u==null?void 0:u.ok)===!1?m.jsxs("div",{className:"up-quota-na",children:[m.jsx("span",{children:"Quota unavailable."}),m.jsx("span",{className:"up-quota-hint",children:S3(u.reason)})]}):m.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),b?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"up-total",children:[m.jsx("span",{className:"up-total-value",children:Fe(x.total)}),m.jsx("span",{className:"up-total-label",children:"total spend"})]}),m.jsx(y3,{cost:x}),k>0&&m.jsxs("div",{className:"up-tokens-row",children:[m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"in"}),Ft(N.in)]}),m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"out"}),Ft(N.out)]}),N.cacheR>0&&m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"cache r"}),Ft(N.cacheR)]}),N.cacheC>0&&m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"cache c"}),Ft(N.cacheC)]})]}),y.filter(O=>O.cost.total>0).length>0&&m.jsxs("section",{className:"up-section",children:[m.jsx("h4",{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:y.filter(O=>O.cost.total>0).map(O=>m.jsxs("tr",{children:[m.jsx("td",{className:"up-model-name",title:O.model,children:li(O.model)}),m.jsx("td",{className:"up-num",children:Ft(O.inputTokens+O.outputTokens)}),m.jsx("td",{className:"up-num up-cost-val",children:Fe(O.cost.total)})]},O.model))})]})]}),S.filter(O=>O.cost>0).length>0&&m.jsxs("section",{className:"up-section",children:[m.jsx("h4",{className:"up-section-title",children:"By session"}),m.jsx("div",{className:"up-sessions",children:S.filter(O=>O.cost>0).map(O=>m.jsxs("div",{className:"up-session-row",children:[m.jsx("span",{className:`sl-dot state-${O.state}`,"aria-hidden":!0}),m.jsx("span",{className:"up-session-label",children:O.label}),m.jsx("span",{className:"up-session-tokens",children:Ft(O.inputTokens+O.outputTokens)}),m.jsx("span",{className:"up-session-cost",children:Fe(O.cost)})]},O.sessionId))})]})]}):k>0?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"up-tokens-row",children:[m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"in"}),Ft(N.in)]}),m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"out"}),Ft(N.out)]})]}),m.jsx("div",{className:"up-hint",children:"Cost appears once a known model is detected."})]}):m.jsxs("div",{className:"up-empty",children:["No usage data yet.",m.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const zx=18,C3=1100,no=(e,n)=>{const r=Math.sin(e*12.9898+n*78.233)*43758.5453;return r-Math.floor(r)},j3=Array.from({length:zx},(e,n)=>{const r=-72+144*n/(zx-1)+(no(n,1)-.5)*9,i=(r-90)*(Math.PI/180),o=(54+32*Math.cos(r*Math.PI/180))*(.74+no(n,2)*.52);return{dx:Math.cos(i)*o,dy:Math.sin(i)*o,rot:(n%2?1:-1)*(100+no(n,3)*260),delay:Math.round(no(n,4)*90),dur:760+Math.round(no(n,5)*260),scale:.8+no(n,6)*.45,hue:n%4,round:n%3===0}});function Bx({anchor:e,lifetimeMs:n=C3}){var l;const[r,i]=T.useState(null),o=typeof window<"u"&&((l=window.matchMedia)==null?void 0:l.call(window,"(prefers-reduced-motion: reduce)").matches);return T.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 p=window.setTimeout(()=>i(null),n);return()=>window.clearTimeout(p)},[e,n,o]),o||!r?null:TI.createPortal(m.jsx("div",{className:"confetti",style:{left:`${r.x}px`,top:`${r.y}px`},"aria-hidden":!0,children:j3.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 cC=new Set(["awaiting_url","awaiting_code","registering"]);function R3(e){return e!=null&&cC.has(e)}function dC(e){return e!=null&&e!=="done"&&!cC.has(e)}const T3="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",A3="the sign-in did not complete";function I3({state:e,serverError:n,localError:r}){const i=e==="idle";return{title:i?"Sign-in ended":"Sign-in failed",message:r||n||(i?T3:A3)}}const M3="done";function P3(){let e=!1;return{shouldAnnounce(n){return n!==M3?(e=!1,!1):e?!1:(e=!0,!0)}}}const Ux={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 ${zt}`,expired:"that share has expired — make a new one",import_failed:"claude-swap refused the import"},Hx={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"},O3=`claude-swap could not read the login keychain — start ${zt} from a Terminal window rather than a background service`;function _v(e,n){return(e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(mo(e))?O3:e!=null&&e.reason&&Hx[e.reason]?Hx[e.reason]:(e==null?void 0:e.reason)||n}function mo(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const Wx={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",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",unreachable:"the deck did not answer — check it is still running, then try again"},L3="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 q3(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}function $3(e,n){return q3(mo(e))?L3:e!=null&&e.reason&&Wx[e.reason]?Wx[e.reason]:(e==null?void 0:e.reason)||n}function iu(e,n){return e!=null&&e.detail?e.detail:e!=null&&e.error&&dC(e.state)?e.error:e!=null&&e.reason&&Ux[e.reason]?Ux[e.reason]:e!=null&&e.error?e.error:(e==null?void 0:e.reason)||n}const D3=1500;async function Kl(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const bv=ue.forwardRef((e,n)=>m.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:n,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"})]}));bv.displayName="SuccessMark";function F3({onClose:e,onChanged:n}){const[r,i]=T.useState("login"),[o,l]=T.useState(null),[u,c]=T.useState(""),[p,f]=T.useState(""),[h,g]=T.useState(!1),[y,x]=T.useState(null),[N,_]=T.useState(null),S=T.useRef(!1),b=T.useRef(null),k=T.useRef(null),E=T.useRef(null),C=T.useCallback(()=>{S.current&&Kl({action:"login-cancel"}).catch(()=>{}),e()},[e]);vo(C);const A=T.useCallback(async()=>{g(!0),x(null),S.current=!0;const q=await Kl({action:"login"}).catch(()=>null);if(g(!1),!(q!=null&&q.ok)){x(iu(q,"could not start the sign-in"));return}l(q)},[]);T.useEffect(()=>{if(!R3(o==null?void 0:o.state))return;const q=window.setInterval(async()=>{try{const R=await fetch("/api/claude-accounts/login");R.ok&&l(await R.json())}catch{}},D3);return()=>window.clearInterval(q)},[o]);const M=T.useRef(n);M.current=n;const L=T.useRef(P3());T.useEffect(()=>{var q;(o==null?void 0:o.state)==="awaiting_code"&&((q=b.current)==null||q.focus()),L.current.shouldAnnounce(o==null?void 0:o.state)&&M.current()},[o==null?void 0:o.state]),T.useEffect(()=>{var q;r==="paste"&&((q=k.current)==null||q.focus())},[r]);const H=T.useCallback(async()=>{var R;g(!0),x(null);const q=await Kl({action:"login-code",code:u}).catch(()=>null);if(g(!1),!(q!=null&&q.ok)){x(iu(q,"the code was not accepted")),q!=null&&q.state&&l(q),(R=b.current)==null||R.select();return}c(""),l(q)},[u,o]),O=T.useCallback(async()=>{g(!0),x(null);const q=await Kl({action:"import",blob:p}).catch(()=>null);if(g(!1),!(q!=null&&q.ok)){x(iu(q,"the import failed"));return}f(""),_({added:q.added===!0,num:q.num??null,email:q.email??null}),n()},[p,n]),P=(o==null?void 0:o.state)==="done"?o.account:null,F=dC(o==null?void 0:o.state)||!!(y&&S.current&&!h),G=I3({state:o==null?void 0:o.state,serverError:o==null?void 0:o.error,localError:y});return m.jsx("div",{className:"modal-backdrop",onClick:C,role:"presentation",children:m.jsxs("div",{className:"modal aa-modal",onClick:q=>q.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:C,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),m.jsx("section",{className:"modal-body aa-body",children:r==="login"?P?m.jsxs("div",{className:"aa-done",children:[m.jsx(bv,{ref:E}),m.jsx(Bx,{anchor:E}),m.jsx("h4",{children:P.added?`Account ${P.num} added`:"Credentials refreshed"}),m.jsxs("p",{className:"aa-note",children:[m.jsx("strong",{children:P.email}),P.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:b,type:"text",value:u,onChange:q=>c(q.target.value),onKeyDown:q=>{q.key==="Enter"&&u.trim()&&!h&&H()},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:h||!u.trim()||o.state==="registering",onClick:H,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."})]})]}):F?m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:G.title}),m.jsx("p",{className:"aa-err",children:G.message}),m.jsx("button",{type:"button",className:"btn",onClick:()=>{S.current=!1,l(null),x(null),A()},children:"Try again"})]}):h||S.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",className:"btn primary",onClick:A,disabled:h,children:"Open the sign-in page"})})]}):N?m.jsxs("div",{className:"aa-done",children:[m.jsx(bv,{ref:E}),N.added&&m.jsx(Bx,{anchor:E}),m.jsx("h4",{children:N.added?`Account ${N.num} imported`:"Already here"}),m.jsx("p",{className:"aa-note",children:N.added?m.jsxs(m.Fragment,{children:[N.email?m.jsx("strong",{children:N.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:p,onChange:q=>f(q.target.value),onKeyDown:q=>{q.key==="Enter"&&p.trim()&&!h&&O()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),m.jsx("button",{type:"button",className:"btn primary",disabled:h||!p.trim(),onClick:O,children:h?"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 z3(e,n){const r=new Set(e),i=e.length?Math.max(...e):0;return[...new Set([...e,i+1])].sort((o,l)=>o-l).map(o=>{const l=o===n?"here":r.has(o)?"swap":"free";return{slot:o,kind:l,label:l==="here"?`slot ${o}`:`slot ${o} · ${l}`}})}function B3(e,n,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!==n;return{menuFor:e.menuFor===n?i:o&&e.menuFor===i?n:e.menuFor,confirmRemove:null,shareFor:null,swapNote:o?{at:i,displaced:n}:null}}function U3(e,n){const r=e.trim();return{alias:r,commit:r!==(n??"").trim()}}const H3=Object.freeze({text:"couldn't reach the deck server",reload:!0});async function Vx(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function W3(e){const n=e.find(i=>!i.ok);if(!n)return null;const r=mo(n.body);return{text:_v(n.body,`the deck server answered ${n.status}`),...r?{raw:r}:{},reload:!0}}function Gx(e,n){return n?e!=null&&e.reload&&e.text===n.text&&e.raw===n.raw?e:n:e!=null&&e.reload?null:e}const Yx=15e3,V3=8e3,G3=1800,Y3=3e4,K3=[70,80,85,90,95];function X3(e,n){const r=e-n;if(r<=0)return null;const i=Math.floor(r/86400),o=Math.floor(r%86400/3600),l=Math.floor(r%3600/60);return i>0?`${i}d ${o}h`:o>0?`${o}h ${l}m`:`${l}m`}function Kx(e,n){const r=n-Math.floor(e/1e3);return r<60?"just now":r<3600?`${Math.floor(r/60)}m ago`:r<86400?`${Math.floor(r/3600)}h ago`:`${Math.floor(r/86400)}d ago`}function Q3(e,n){if(!e)return"";const r=Math.floor(e/1e3)-n;return r<=0?" · due":r<60?` · next in ${r}s`:` · next in ${Math.round(r/60)}m`}function Z3(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 J3({lane:e,nowSec:n}){const r=Math.min(100,Math.max(0,e.pct)),i=r>=90?"var(--err)":r>=70?"var(--warn)":"var(--accent)",o=e.resetAt?X3(e.resetAt,n):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 eL(e){var r;let n=!1;try{n=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{n=!1}if(n)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(),n=document.execCommand("copy"),i.remove()}catch{n=!1}return n}function tL(e,n){const r=Math.round(e/1e3)-n;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 nL({onClose:e}){var re,le,fe;const[n,r]=T.useState(null),[i,o]=T.useState(null),[l,u]=T.useState(null),[c,p]=T.useState(!1),[f,h]=T.useState(null),[g,y]=T.useState(null),[x,N]=T.useState(()=>Math.floor(Date.now()/1e3)),_=T.useRef(null),[S,b]=T.useState(null),[k,E]=T.useState(!1),[C,A]=T.useState(""),[M,L]=T.useState(null),[H,O]=T.useState(null),[P,F]=T.useState(null),[G,q]=T.useState(!1),[R,Q]=T.useState(null),z=T.useCallback(async(te=!1)=>{te&&p(!0);const ce=new AbortController,Ce=window.setTimeout(()=>ce.abort(),Y3);try{const[ve,Te]=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()),Te.ok&&o(await Te.json());const ye=W3([await Vx(ve),await Vx(Te)]);y(ke=>Gx(ke,ye))}catch{y(ve=>Gx(ve,H3))}finally{window.clearTimeout(Ce),te&&p(!1)}},[]),ne=T.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:_v(ve,"command failed"),raw:mo(ve)}),ve}catch{return y({text:"server unreachable"}),null}finally{u(null)}},[]),Z=T.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:iu(ve,"command failed")}),ve}catch{return y({text:"server unreachable"}),null}finally{u(null)}},[]);T.useEffect(()=>(z(!0),_.current=window.setInterval(()=>z(!1),Yx),()=>{_.current!=null&&window.clearInterval(_.current)}),[z]),T.useEffect(()=>{const te=window.setInterval(()=>N(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(te)},[]);const $=((re=i==null?void 0:i.settings["autoswitch.threshold"])==null?void 0:re.value)??"90",X=(le=n==null?void 0:n.accounts)==null?void 0:le.find(te=>te.active),I=X!=null&&X.lanes.length?Math.max(...X.lanes.map(te=>te.pct)):null,W=I!=null&&I>=Number($)-15,Y=async te=>{h(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:_v(Ce,"the switch failed"),raw:mo(Ce)}),await z(!0)}catch{y({text:"server unreachable"})}finally{h(null)}},U=async(te,ce)=>{const{commit:Ce,alias:ve}=U3(C,ce);if(Ce){const Te=await Z({action:"alias",account:te,alias:ve},`alias-${te}`);if(await z(!0),!(Te!=null&&Te.ok))return;A(ve)}L(te),window.setTimeout(()=>L(Te=>Te===te?null:Te),G3)},J=async(te,ce)=>{const Ce=await Z({action:"move",account:te,slot:ce},`move-${te}`),ve=B3({menuFor:S,shareFor:(P==null?void 0:P.num)??null},te,Ce);if(await z(!0),ve){b(ve.menuFor),O(ve.confirmRemove),ve.shareFor==null&&(F(null),q(!1)),Q(ve.swapNote);const Te=ve.swapNote;Te&&window.setTimeout(()=>Q(ye=>ye===Te?null:ye),V3)}};return m.jsxs("div",{className:"accounts-panel","aria-label":"Claude accounts",children:[m.jsxs("div",{className:"ap-header",children:[m.jsx("h3",{children:"Accounts"}),m.jsxs("div",{className:"ap-header-right",children:[m.jsx("button",{type:"button",className:"btn ap-add",onClick:()=>E(!0),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:()=>z(!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:"×"})]})]}),n==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 ",Yx/1e3," seconds."]}),m.jsx("button",{type:"button",className:"ap-fix",disabled:c,onClick:()=>z(!0),children:c?"trying…":"try again"})]}):m.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?m.jsxs(m.Fragment,{children:[(fe=n.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",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${S===te.num?" on":""}`,"aria-label":`Manage account ${te.num}`,"aria-expanded":S===te.num,"aria-controls":S===te.num?`ap-manage-${te.num}`:void 0,title:"Share, rename, move, remove",onClick:()=>{b(S===te.num?null:te.num),A(te.alias??""),O(null),F(null),q(!1),Q(null),L(null)},children:"⋯"}),te.active?m.jsx("span",{className:"ap-badge-active",children:"● active"}):m.jsx("button",{type:"button",className:"btn ap-switch",disabled:f!=null||te.disabled,onClick:()=>Y(te.num),title:te.disabled?"Held out of rotation":`Switch to ${te.alias??te.email}`,children:f===te.num?"…":"switch"})]}),te.lanes.length>0?te.lanes.map(ce=>m.jsx(J3,{lane:ce,nowSec:x},ce.id)):m.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),m.jsxs("div",{className:"ap-meta",children:[te.error&&(()=>{const ce=Z3(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:()=>E(!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:l!=null,onClick:()=>ne({action:"account",account:te.num,enabled:te.disabled},`rot-${te.num}`).then(()=>z(!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 ",Kx(te.fetchedAt,x),Q3(te.nextAt,x)]}):m.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),S===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:"ap-vh",htmlFor:`ap-alias-${te.num}`,children:"Alias"}),m.jsx("input",{id:`ap-alias-${te.num}`,className:"ap-manage-input",type:"text",value:C,onChange:ce=>A(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&U(te.num,te.alias)},placeholder:"e.g. work",spellCheck:!1,autoFocus:!0}),m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:()=>U(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:"ap-vh",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:l!=null,onChange:ce=>J(te.num,Number(ce.target.value)),children:z3((n.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:l!=null,title:`Copy this account to another ${zt}. The share carries a live login and expires in 10 minutes.`,onClick:async()=>{q(!1);const ce=await Z({action:"share",account:te.num},`share-${te.num}`);ce!=null&&ce.ok&&F({num:te.num,blob:ce.blob,expiresAt:ce.expiresAt})},children:"share"}),m.jsx("button",{type:"button",className:`ap-manage-btn danger${H===te.num?" armed":""}`,disabled:l!=null,title:H===te.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(H!==te.num){O(te.num),window.setTimeout(()=>O(ce=>ce===te.num?null:ce),4e3);return}O(null),Z({action:"remove",account:te.num},`rm-${te.num}`).then(()=>{b(null),z(!0)})},children:H===te.num?"confirm":"remove"})]}),(R==null?void 0:R.at)===te.num&&(()=>{var ve;const ce=(ve=n.accounts)==null?void 0:ve.find(Te=>Te.num===R.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 ${R.at} was taken, so the two accounts traded places: ${Ce} now holds slot ${R.displaced}.`,children:["swapped with slot ",R.displaced]})})(),(P==null?void 0:P.num)===te.num&&(()=>{const ce=tL(P.expiresAt,x),Ce=ce.tone==="gone";return m.jsxs("div",{className:`ap-share${Ce?" expired":""}`,children:[m.jsx("code",{className:"ap-share-blob",children:P.blob}),m.jsxs("div",{className:"ap-share-foot",children:[m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:async()=>{if(Ce){q(!1);const ve=await Z({action:"share",account:te.num},`share-${te.num}`);ve!=null&&ve.ok&&F({num:te.num,blob:ve.blob,expiresAt:ve.expiresAt});return}await eL(P.blob)&&(q(!0),window.setTimeout(()=>q(!1),1800))},children:Ce?"make a new share":G?"copied":"copy"}),m.jsxs("span",{className:"ap-manage-hint",children:["carries a live login · ",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${W?" 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:$,disabled:l!=null,onChange:te=>ne({action:"setting",key:"autoswitch.threshold",value:te.target.value},"threshold").then(()=>z(!0)),children:K3.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:l!=null,onClick:()=>ne({action:"enable",enabled:!i.enabled},"enable").then(()=>z(!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 ",Kx(i.lastTick.at,x)]})})]}),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:n.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."}),n.hint&&m.jsx("code",{className:"ap-cmd",children:n.hint}),m.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",m.jsx("strong",{children:"+"})," button above."]})]}):n.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",n.reason?` (${n.reason})`:"","."]})]})}),k&&m.jsx(F3,{onClose:()=>E(!1),onChanged:()=>z(!0)})]})}const rL=3e4;function sL({bundle:e,running:n,lastTried:r}){return!n||e===n?!1:r!==n}function iL({bundle:e,running:n,pending:r,lastTried:i}){return n?sL({bundle:e,running:n,lastTried:i})?"reload":r==null||r&&r!==n?"wait":"confirm":"wait"}function oL(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function aL({asked:e,reported:n}){return n?n!==e:!1}function lL(e){const n=e.thresholdMs??rL;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>=n}}function uL(e){return e.ctrlKey||e.metaKey||e.altKey}const cL=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),dL=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),fL=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function fC(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function hC(e){if(!e)return!1;if(e.isContentEditable)return!0;const n=fC(e);return n==="TEXTAREA"?!0:n!=="INPUT"?!1:!cL.has(String(e.type??"text").toLowerCase())}function hL(e){if(!e)return!1;if(hC(e)||dL.has(fC(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(r=>fL.has(r))}function pL({agentCount:e,onConfirm:n,onCancel:r}){const i=T.useRef(null);vo(r,{focusRef:i,layer:dO});const o=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",{className:"modal clear-confirm",onClick:l=>l.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:[o," — 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:n,children:"Clear everything"})]})]})]})})}function mL(e,n){return e==="confirmation"?n.confirmOpen?"clear":"ignore":n.modalOpen||n.confirmOpen?"ignore":"confirm"}function Xl(e,n){if(n.size!==0)for(const r of Array.from(e.keys()))n.has(r)||e.delete(r)}function gL(e){const n=new Set;for(const r of e)n.add(r.id),n.add(`group:${r.sessionId}`);return n}function pC(e,n,r){return!n.has(e)||r.has(e)}function vL(e,n,r,i){return!n.has(e)&&pC(e,r,i)}function yL(e,n,r){const i={x:0,y:0};return n.set(e,i),r.add(e),i}function wL(e,n,r,i){r.set(e,n),i.delete(e)}const xL=40,_L=120;function bL(e,n){let r=null,i=0,o=Number.NEGATIVE_INFINITY;const l=()=>{r=null,o=n.now(),e()},u=()=>{r!=null&&(n.clearTimeout(r),r=null)},c=(p,f,h)=>{if(r!=null){if(i<=p)return;u()}const g=Math.min(h,Math.max(0,p-f));i=p,r=n.setTimeout(l,g)};return{live(p=xL){const f=n.now(),h=Math.max(o+p,f);if(h<=f){u(),l();return}c(h,f,p)},replay(p=_L){u(),i=n.now()+p,r=n.setTimeout(l,p)},flush(){u(),l()},cancel(){u()}}}function SL(){let e=!1,n=[];return{get paused(){return e},get size(){return n.length},accept(r){return e?(n.push(r),!1):!0},setPaused(r){if(e=r,r||n.length===0)return[];const i=n;return n=[],i}}}const kL="1",Xx="agent-dag.schema",EL=["agent-dag.layout","agent-dag.viewport"];function mC(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function NL(e,n=kL){let r=null;try{r=e.getItem(Xx)}catch{return[]}if(r===n)return[];const i=[];if(r!==null)for(const o of EL)try{e.getItem(o)!==null&&(e.removeItem(o),i.push(o))}catch{}try{e.setItem(Xx,n)}catch{}return i}const gC="agent-dag.theme";function CL(e){return e==="light"?"light":"dark"}function jL(){return CL(mC(gC))}function RL({waiting:e,running:n}){return{title:e>0?`(${e}) ${zt}`:zt,icon:e>0?"waiting":n>0?"running":"idle"}}const Md={waiting:"#c97d12",running:"#2a90d4",idle:"#7e828c"};function Pd(e,n){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">${n==="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"/>`+(n==="running"?`<circle cx="16" cy="16" r="5" fill="${e}"/>`:"")}</svg>`}const TL=Object.freeze({waiting:`data:image/svg+xml,${encodeURIComponent(Pd(Md.waiting,"waiting"))}`,running:`data:image/svg+xml,${encodeURIComponent(Pd(Md.running,"running"))}`,idle:`data:image/svg+xml,${encodeURIComponent(Pd(Md.idle,"idle"))}`});function AL(){let e=0;return{begin(){const n=++e;return()=>n===e},cancel(){e++}}}function IL(e,n=new Date){return new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}function ML(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 Ql(e){const n=e.toLowerCase();return n.includes("opus")?"#c4b5fd":n.includes("sonnet")?"#7dd3fc":n.includes("haiku")?"#86efac":n.includes("gpt-5")||n.includes("gpt5")?"#fcd34d":n.includes("gpt")?"#fca5a5":n.includes("gemini")?"#a5b4fc":n.includes("codex")?"#fdba74":"#94a3b8"}const PL=[7,14,30,90];function OL(e){const[n,r]=T.useState(null),[i,o]=T.useState(!1),l=T.useRef(AL()).current,u=(c=!1)=>{const p=l.begin(),f=e;o(!0);const g=`/api/ccusage?since=${IL(f)}${c?"&refresh=1":""}`;fetch(g).then(y=>y.json()).then(y=>{p()&&r({range:f,resp:y})}).catch(()=>{p()&&r({range:f,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{p()&&o(!1)})};return T.useEffect(()=>(u(!1),()=>l.cancel()),[e]),{landed:n,loading:i,reload:()=>u(!0)}}function LL({onClose:e}){var k,E,C;const[n,r]=T.useState(30),[i,o]=T.useState(null),{landed:l,loading:u,reload:c}=OL(n);vo(e);const p=ML({loading:u,want:n,answer:l&&{range:l.range,ok:l.resp.ok===!0,days:((k=l.resp.days)==null?void 0:k.length)??0}}),f=p.phase==="chart"?l.resp.days??[]:[],h=T.useMemo(()=>f.reduce((A,M)=>Math.max(A,M.totalCost),0),[f]),{totalCost:g,totalTok:y,inOut:x,cacheRead:N,modelCosts:_}=T.useMemo(()=>{let A=0,M=0,L=0,H=0;const O=new Map;for(const P of f){A+=P.totalCost,M+=P.totalTokens,L+=P.inputTokens+P.outputTokens,H+=P.cacheReadTokens;for(const F of P.modelBreakdowns)O.set(F.modelName,(O.get(F.modelName)??0)+F.cost)}return{totalCost:A,totalTok:M,inOut:L,cacheRead:H,modelCosts:O}},[f]),S=T.useMemo(()=>Array.from(_.entries()).sort((A,M)=>M[1]-A[1]),[_]),b=i?f.find(A=>A.period===i)??null:null;return m.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:m.jsxs("div",{className:"uh-modal",onClick:A=>A.stopPropagation(),role:"dialog","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:"via ccusage · local Claude / Codex logs"})]}),m.jsx("div",{className:"uh-range",role:"tablist","aria-label":"Range",children:PL.map(A=>m.jsxs("button",{role:"tab","aria-selected":n===A,className:`uh-range-btn${n===A?" on":""}`,onClick:()=>{r(A),o(null)},children:[A,"d"]},A))}),m.jsx("button",{className:"btn icon-btn uh-reload",onClick:c,disabled:u,title:"Re-run ccusage","aria-label":"Reload",children:u?"…":"↻"}),m.jsx("button",{className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),p.phase==="busy"?m.jsx("div",{className:"uh-status","aria-busy":"true",children:l?"running ccusage…":"running ccusage… (first run downloads the package)"}):p.phase==="error"?m.jsxs("div",{className:"uh-status uh-err",title:mo(l.resp)||void 0,children:[$3(l.resp,"ccusage did not report usage"),m.jsx("div",{children:m.jsx("button",{className:"btn uh-retry",onClick:c,disabled:u,children:u?"trying…":"Try again"})})]}):p.phase==="empty"?m.jsx("div",{className:`uh-status${p.stale?" uh-stale":""}`,"aria-busy":p.stale||void 0,children:"no usage in this range"}):m.jsxs("div",{className:p.stale?"uh-stale":void 0,"aria-busy":p.stale||void 0,children:[m.jsxs("div",{className:"uh-totals",children:[m.jsx(Zl,{label:"total cost",val:Fe(g),accent:!0}),m.jsx(Zl,{label:"tokens",val:Ft(y)}),m.jsx(Zl,{label:"input+output",val:Ft(x)}),m.jsx(Zl,{label:"cache reads",val:Ft(N)})]}),m.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:f.map(A=>{const M=h>0?A.totalCost/h*100:0,L=A.period===i;return m.jsxs("button",{className:`uh-bar-col${L?" sel":""}`,onClick:()=>o(L?null:A.period),title:`${A.period} · ${Fe(A.totalCost)}`,style:{flexBasis:`${100/f.length}%`},children:[m.jsx("div",{className:"uh-bar",style:{height:`${Math.max(M,A.totalCost>0?2:0)}%`},children:A.modelBreakdowns.slice().sort((H,O)=>O.cost-H.cost).map(H=>{const O=A.totalCost>0?H.cost/A.totalCost*100:0;return m.jsx("div",{className:"uh-bar-seg",style:{height:`${O}%`,background:Ql(H.modelName)}},H.modelName)})}),m.jsx("span",{className:"uh-bar-label",children:A.period.slice(5)})]},A.period)})}),m.jsx("div",{className:"uh-legend",children:S.map(([A,M])=>m.jsxs("span",{className:"uh-legend-item",children:[m.jsx("span",{className:"uh-legend-dot",style:{background:Ql(A)}}),li(A)," ",m.jsx("span",{className:"uh-legend-cost",children:Fe(M)})]},A))}),b&&m.jsxs("div",{className:"uh-detail",children:[m.jsxs("div",{className:"uh-detail-head",children:[m.jsx("span",{className:"uh-detail-date",children:b.period}),m.jsx("span",{className:"uh-detail-cost",children:Fe(b.totalCost)}),(C=(E=b.metadata)==null?void 0:E.agents)!=null&&C.length?m.jsx("span",{className:"uh-detail-agents",children:b.metadata.agents.join(" · ")}):null]}),m.jsxs("div",{className:"uh-detail-mini",children:[m.jsx(Jl,{label:"input",val:Ft(b.inputTokens)}),m.jsx(Jl,{label:"output",val:Ft(b.outputTokens)}),m.jsx(Jl,{label:"cache write",val:Ft(b.cacheCreationTokens)}),m.jsx(Jl,{label:"cache read",val:Ft(b.cacheReadTokens)})]}),m.jsx("div",{className:"uh-detail-models",children:b.modelBreakdowns.slice().sort((A,M)=>M.cost-A.cost).map(A=>{const M=b.totalCost>0?A.cost/b.totalCost*100:0;return m.jsxs("div",{className:"uh-model-row",children:[m.jsxs("span",{className:"uh-model-name",children:[m.jsx("span",{className:"uh-legend-dot",style:{background:Ql(A.modelName)}}),li(A.modelName)]}),m.jsx("span",{className:"uh-model-bar",children:m.jsx("span",{className:"uh-model-bar-fill",style:{width:`${M}%`,background:Ql(A.modelName)}})}),m.jsx("span",{className:"uh-model-cost",children:Fe(A.cost)})]},A.modelName)})})]})]})]})})}function Zl({label:e,val:n,accent:r}){return m.jsxs("div",{className:"uh-stat",children:[m.jsx("span",{className:`uh-stat-val${r?" accent":""}`,children:n}),m.jsx("span",{className:"uh-stat-label",children:e})]})}function Jl({label:e,val:n}){return m.jsxs("div",{className:"uh-ministat",children:[m.jsx("span",{className:"uh-ministat-val",children:n}),m.jsx("span",{className:"uh-ministat-label",children:e})]})}function Yv(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 Od,Qx;function qL(){if(Qx)return Od;Qx=1;function e(){this.__data__=[],this.size=0}return Od=e,Od}var Ld,Zx;function yo(){if(Zx)return Ld;Zx=1;function e(n,r){return n===r||n!==n&&r!==r}return Ld=e,Ld}var qd,Jx;function Cu(){if(Jx)return qd;Jx=1;var e=yo();function n(r,i){for(var o=r.length;o--;)if(e(r[o][0],i))return o;return-1}return qd=n,qd}var $d,e_;function $L(){if(e_)return $d;e_=1;var e=Cu(),n=Array.prototype,r=n.splice;function i(o){var l=this.__data__,u=e(l,o);if(u<0)return!1;var c=l.length-1;return u==c?l.pop():r.call(l,u,1),--this.size,!0}return $d=i,$d}var Dd,t_;function DL(){if(t_)return Dd;t_=1;var e=Cu();function n(r){var i=this.__data__,o=e(i,r);return o<0?void 0:i[o][1]}return Dd=n,Dd}var Fd,n_;function FL(){if(n_)return Fd;n_=1;var e=Cu();function n(r){return e(this.__data__,r)>-1}return Fd=n,Fd}var zd,r_;function zL(){if(r_)return zd;r_=1;var e=Cu();function n(r,i){var o=this.__data__,l=e(o,r);return l<0?(++this.size,o.push([r,i])):o[l][1]=i,this}return zd=n,zd}var Bd,s_;function ju(){if(s_)return Bd;s_=1;var e=qL(),n=$L(),r=DL(),i=FL(),o=zL();function l(u){var c=-1,p=u==null?0:u.length;for(this.clear();++c<p;){var f=u[c];this.set(f[0],f[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=i,l.prototype.set=o,Bd=l,Bd}var Ud,i_;function BL(){if(i_)return Ud;i_=1;var e=ju();function n(){this.__data__=new e,this.size=0}return Ud=n,Ud}var Hd,o_;function UL(){if(o_)return Hd;o_=1;function e(n){var r=this.__data__,i=r.delete(n);return this.size=r.size,i}return Hd=e,Hd}var Wd,a_;function HL(){if(a_)return Wd;a_=1;function e(n){return this.__data__.get(n)}return Wd=e,Wd}var Vd,l_;function WL(){if(l_)return Vd;l_=1;function e(n){return this.__data__.has(n)}return Vd=e,Vd}var Gd,u_;function vC(){if(u_)return Gd;u_=1;var e=typeof Ll=="object"&&Ll&&Ll.Object===Object&⋘return Gd=e,Gd}var Yd,c_;function tr(){if(c_)return Yd;c_=1;var e=vC(),n=typeof self=="object"&&self&&self.Object===Object&&self,r=e||n||Function("return this")();return Yd=r,Yd}var Kd,d_;function wo(){if(d_)return Kd;d_=1;var e=tr(),n=e.Symbol;return Kd=n,Kd}var Xd,f_;function VL(){if(f_)return Xd;f_=1;var e=wo(),n=Object.prototype,r=n.hasOwnProperty,i=n.toString,o=e?e.toStringTag:void 0;function l(u){var c=r.call(u,o),p=u[o];try{u[o]=void 0;var f=!0}catch{}var h=i.call(u);return f&&(c?u[o]=p:delete u[o]),h}return Xd=l,Xd}var Qd,h_;function GL(){if(h_)return Qd;h_=1;var e=Object.prototype,n=e.toString;function r(i){return n.call(i)}return Qd=r,Qd}var Zd,p_;function ui(){if(p_)return Zd;p_=1;var e=wo(),n=VL(),r=GL(),i="[object Null]",o="[object Undefined]",l=e?e.toStringTag:void 0;function u(c){return c==null?c===void 0?o:i:l&&l in Object(c)?n(c):r(c)}return Zd=u,Zd}var Jd,m_;function Ln(){if(m_)return Jd;m_=1;function e(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}return Jd=e,Jd}var ef,g_;function Oa(){if(g_)return ef;g_=1;var e=ui(),n=Ln(),r="[object AsyncFunction]",i="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function u(c){if(!n(c))return!1;var p=e(c);return p==i||p==o||p==r||p==l}return ef=u,ef}var tf,v_;function YL(){if(v_)return tf;v_=1;var e=tr(),n=e["__core-js_shared__"];return tf=n,tf}var nf,y_;function KL(){if(y_)return nf;y_=1;var e=YL(),n=(function(){var i=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""})();function r(i){return!!n&&n in i}return nf=r,nf}var rf,w_;function yC(){if(w_)return rf;w_=1;var e=Function.prototype,n=e.toString;function r(i){if(i!=null){try{return n.call(i)}catch{}try{return i+""}catch{}}return""}return rf=r,rf}var sf,x_;function XL(){if(x_)return sf;x_=1;var e=Oa(),n=KL(),r=Ln(),i=yC(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,p=u.toString,f=c.hasOwnProperty,h=RegExp("^"+p.call(f).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function g(y){if(!r(y)||n(y))return!1;var x=e(y)?h:l;return x.test(i(y))}return sf=g,sf}var of,__;function QL(){if(__)return of;__=1;function e(n,r){return n==null?void 0:n[r]}return of=e,of}var af,b_;function ci(){if(b_)return af;b_=1;var e=XL(),n=QL();function r(i,o){var l=n(i,o);return e(l)?l:void 0}return af=r,af}var lf,S_;function Kv(){if(S_)return lf;S_=1;var e=ci(),n=tr(),r=e(n,"Map");return lf=r,lf}var uf,k_;function Ru(){if(k_)return uf;k_=1;var e=ci(),n=e(Object,"create");return uf=n,uf}var cf,E_;function ZL(){if(E_)return cf;E_=1;var e=Ru();function n(){this.__data__=e?e(null):{},this.size=0}return cf=n,cf}var df,N_;function JL(){if(N_)return df;N_=1;function e(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}return df=e,df}var ff,C_;function eq(){if(C_)return ff;C_=1;var e=Ru(),n="__lodash_hash_undefined__",r=Object.prototype,i=r.hasOwnProperty;function o(l){var u=this.__data__;if(e){var c=u[l];return c===n?void 0:c}return i.call(u,l)?u[l]:void 0}return ff=o,ff}var hf,j_;function tq(){if(j_)return hf;j_=1;var e=Ru(),n=Object.prototype,r=n.hasOwnProperty;function i(o){var l=this.__data__;return e?l[o]!==void 0:r.call(l,o)}return hf=i,hf}var pf,R_;function nq(){if(R_)return pf;R_=1;var e=Ru(),n="__lodash_hash_undefined__";function r(i,o){var l=this.__data__;return this.size+=this.has(i)?0:1,l[i]=e&&o===void 0?n:o,this}return pf=r,pf}var mf,T_;function rq(){if(T_)return mf;T_=1;var e=ZL(),n=JL(),r=eq(),i=tq(),o=nq();function l(u){var c=-1,p=u==null?0:u.length;for(this.clear();++c<p;){var f=u[c];this.set(f[0],f[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=i,l.prototype.set=o,mf=l,mf}var gf,A_;function sq(){if(A_)return gf;A_=1;var e=rq(),n=ju(),r=Kv();function i(){this.size=0,this.__data__={hash:new e,map:new(r||n),string:new e}}return gf=i,gf}var vf,I_;function iq(){if(I_)return vf;I_=1;function e(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}return vf=e,vf}var yf,M_;function Tu(){if(M_)return yf;M_=1;var e=iq();function n(r,i){var o=r.__data__;return e(i)?o[typeof i=="string"?"string":"hash"]:o.map}return yf=n,yf}var wf,P_;function oq(){if(P_)return wf;P_=1;var e=Tu();function n(r){var i=e(this,r).delete(r);return this.size-=i?1:0,i}return wf=n,wf}var xf,O_;function aq(){if(O_)return xf;O_=1;var e=Tu();function n(r){return e(this,r).get(r)}return xf=n,xf}var _f,L_;function lq(){if(L_)return _f;L_=1;var e=Tu();function n(r){return e(this,r).has(r)}return _f=n,_f}var bf,q_;function uq(){if(q_)return bf;q_=1;var e=Tu();function n(r,i){var o=e(this,r),l=o.size;return o.set(r,i),this.size+=o.size==l?0:1,this}return bf=n,bf}var Sf,$_;function Xv(){if($_)return Sf;$_=1;var e=sq(),n=oq(),r=aq(),i=lq(),o=uq();function l(u){var c=-1,p=u==null?0:u.length;for(this.clear();++c<p;){var f=u[c];this.set(f[0],f[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=i,l.prototype.set=o,Sf=l,Sf}var kf,D_;function cq(){if(D_)return kf;D_=1;var e=ju(),n=Kv(),r=Xv(),i=200;function o(l,u){var c=this.__data__;if(c instanceof e){var p=c.__data__;if(!n||p.length<i-1)return p.push([l,u]),this.size=++c.size,this;c=this.__data__=new r(p)}return c.set(l,u),this.size=c.size,this}return kf=o,kf}var Ef,F_;function Au(){if(F_)return Ef;F_=1;var e=ju(),n=BL(),r=UL(),i=HL(),o=WL(),l=cq();function u(c){var p=this.__data__=new e(c);this.size=p.size}return u.prototype.clear=n,u.prototype.delete=r,u.prototype.get=i,u.prototype.has=o,u.prototype.set=l,Ef=u,Ef}var Nf,z_;function Qv(){if(z_)return Nf;z_=1;function e(n,r){for(var i=-1,o=n==null?0:n.length;++i<o&&r(n[i],i,n)!==!1;);return n}return Nf=e,Nf}var Cf,B_;function wC(){if(B_)return Cf;B_=1;var e=ci(),n=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return Cf=n,Cf}var jf,U_;function Iu(){if(U_)return jf;U_=1;var e=wC();function n(r,i,o){i=="__proto__"&&e?e(r,i,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[i]=o}return jf=n,jf}var Rf,H_;function Mu(){if(H_)return Rf;H_=1;var e=Iu(),n=yo(),r=Object.prototype,i=r.hasOwnProperty;function o(l,u,c){var p=l[u];(!(i.call(l,u)&&n(p,c))||c===void 0&&!(u in l))&&e(l,u,c)}return Rf=o,Rf}var Tf,W_;function La(){if(W_)return Tf;W_=1;var e=Mu(),n=Iu();function r(i,o,l,u){var c=!l;l||(l={});for(var p=-1,f=o.length;++p<f;){var h=o[p],g=u?u(l[h],i[h],h,l,i):void 0;g===void 0&&(g=i[h]),c?n(l,h,g):e(l,h,g)}return l}return Tf=r,Tf}var Af,V_;function dq(){if(V_)return Af;V_=1;function e(n,r){for(var i=-1,o=Array(n);++i<n;)o[i]=r(i);return o}return Af=e,Af}var If,G_;function vr(){if(G_)return If;G_=1;function e(n){return n!=null&&typeof n=="object"}return If=e,If}var Mf,Y_;function fq(){if(Y_)return Mf;Y_=1;var e=ui(),n=vr(),r="[object Arguments]";function i(o){return n(o)&&e(o)==r}return Mf=i,Mf}var Pf,K_;function qa(){if(K_)return Pf;K_=1;var e=fq(),n=vr(),r=Object.prototype,i=r.hasOwnProperty,o=r.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(u){return n(u)&&i.call(u,"callee")&&!o.call(u,"callee")};return Pf=l,Pf}var Of,X_;function bt(){if(X_)return Of;X_=1;var e=Array.isArray;return Of=e,Of}var va={exports:{}},Lf,Q_;function hq(){if(Q_)return Lf;Q_=1;function e(){return!1}return Lf=e,Lf}va.exports;var Z_;function xo(){return Z_||(Z_=1,(function(e,n){var r=tr(),i=hq(),o=n&&!n.nodeType&&n,l=o&&!0&&e&&!e.nodeType&&e,u=l&&l.exports===o,c=u?r.Buffer:void 0,p=c?c.isBuffer:void 0,f=p||i;e.exports=f})(va,va.exports)),va.exports}var qf,J_;function Pu(){if(J_)return qf;J_=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function r(i,o){var l=typeof i;return o=o??e,!!o&&(l=="number"||l!="symbol"&&n.test(i))&&i>-1&&i%1==0&&i<o}return qf=r,qf}var $f,e1;function Zv(){if(e1)return $f;e1=1;var e=9007199254740991;function n(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return $f=n,$f}var Df,t1;function pq(){if(t1)return Df;t1=1;var e=ui(),n=Zv(),r=vr(),i="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",p="[object Function]",f="[object Map]",h="[object Number]",g="[object Object]",y="[object RegExp]",x="[object Set]",N="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",k="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",A="[object Int16Array]",M="[object Int32Array]",L="[object Uint8Array]",H="[object Uint8ClampedArray]",O="[object Uint16Array]",P="[object Uint32Array]",F={};F[k]=F[E]=F[C]=F[A]=F[M]=F[L]=F[H]=F[O]=F[P]=!0,F[i]=F[o]=F[S]=F[l]=F[b]=F[u]=F[c]=F[p]=F[f]=F[h]=F[g]=F[y]=F[x]=F[N]=F[_]=!1;function G(q){return r(q)&&n(q.length)&&!!F[e(q)]}return Df=G,Df}var Ff,n1;function Ou(){if(n1)return Ff;n1=1;function e(n){return function(r){return n(r)}}return Ff=e,Ff}var ya={exports:{}};ya.exports;var r1;function Jv(){return r1||(r1=1,(function(e,n){var r=vC(),i=n&&!n.nodeType&&n,o=i&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===i,u=l&&r.process,c=(function(){try{var p=o&&o.require&&o.require("util").types;return p||u&&u.binding&&u.binding("util")}catch{}})();e.exports=c})(ya,ya.exports)),ya.exports}var zf,s1;function $a(){if(s1)return zf;s1=1;var e=pq(),n=Ou(),r=Jv(),i=r&&r.isTypedArray,o=i?n(i):e;return zf=o,zf}var Bf,i1;function xC(){if(i1)return Bf;i1=1;var e=dq(),n=qa(),r=bt(),i=xo(),o=Pu(),l=$a(),u=Object.prototype,c=u.hasOwnProperty;function p(f,h){var g=r(f),y=!g&&n(f),x=!g&&!y&&i(f),N=!g&&!y&&!x&&l(f),_=g||y||x||N,S=_?e(f.length,String):[],b=S.length;for(var k in f)(h||c.call(f,k))&&!(_&&(k=="length"||x&&(k=="offset"||k=="parent")||N&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||o(k,b)))&&S.push(k);return S}return Bf=p,Bf}var Uf,o1;function Lu(){if(o1)return Uf;o1=1;var e=Object.prototype;function n(r){var i=r&&r.constructor,o=typeof i=="function"&&i.prototype||e;return r===o}return Uf=n,Uf}var Hf,a1;function _C(){if(a1)return Hf;a1=1;function e(n,r){return function(i){return n(r(i))}}return Hf=e,Hf}var Wf,l1;function mq(){if(l1)return Wf;l1=1;var e=_C(),n=e(Object.keys,Object);return Wf=n,Wf}var Vf,u1;function ey(){if(u1)return Vf;u1=1;var e=Lu(),n=mq(),r=Object.prototype,i=r.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=[];for(var c in Object(l))i.call(l,c)&&c!="constructor"&&u.push(c);return u}return Vf=o,Vf}var Gf,c1;function Wr(){if(c1)return Gf;c1=1;var e=Oa(),n=Zv();function r(i){return i!=null&&n(i.length)&&!e(i)}return Gf=r,Gf}var Yf,d1;function ks(){if(d1)return Yf;d1=1;var e=xC(),n=ey(),r=Wr();function i(o){return r(o)?e(o):n(o)}return Yf=i,Yf}var Kf,f1;function gq(){if(f1)return Kf;f1=1;var e=La(),n=ks();function r(i,o){return i&&e(o,n(o),i)}return Kf=r,Kf}var Xf,h1;function vq(){if(h1)return Xf;h1=1;function e(n){var r=[];if(n!=null)for(var i in Object(n))r.push(i);return r}return Xf=e,Xf}var Qf,p1;function yq(){if(p1)return Qf;p1=1;var e=Ln(),n=Lu(),r=vq(),i=Object.prototype,o=i.hasOwnProperty;function l(u){if(!e(u))return r(u);var c=n(u),p=[];for(var f in u)f=="constructor"&&(c||!o.call(u,f))||p.push(f);return p}return Qf=l,Qf}var Zf,m1;function di(){if(m1)return Zf;m1=1;var e=xC(),n=yq(),r=Wr();function i(o){return r(o)?e(o,!0):n(o)}return Zf=i,Zf}var Jf,g1;function wq(){if(g1)return Jf;g1=1;var e=La(),n=di();function r(i,o){return i&&e(o,n(o),i)}return Jf=r,Jf}var wa={exports:{}};wa.exports;var v1;function bC(){return v1||(v1=1,(function(e,n){var r=tr(),i=n&&!n.nodeType&&n,o=i&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===i,u=l?r.Buffer:void 0,c=u?u.allocUnsafe:void 0;function p(f,h){if(h)return f.slice();var g=f.length,y=c?c(g):new f.constructor(g);return f.copy(y),y}e.exports=p})(wa,wa.exports)),wa.exports}var eh,y1;function SC(){if(y1)return eh;y1=1;function e(n,r){var i=-1,o=n.length;for(r||(r=Array(o));++i<o;)r[i]=n[i];return r}return eh=e,eh}var th,w1;function kC(){if(w1)return th;w1=1;function e(n,r){for(var i=-1,o=n==null?0:n.length,l=0,u=[];++i<o;){var c=n[i];r(c,i,n)&&(u[l++]=c)}return u}return th=e,th}var nh,x1;function EC(){if(x1)return nh;x1=1;function e(){return[]}return nh=e,nh}var rh,_1;function ty(){if(_1)return rh;_1=1;var e=kC(),n=EC(),r=Object.prototype,i=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,l=o?function(u){return u==null?[]:(u=Object(u),e(o(u),function(c){return i.call(u,c)}))}:n;return rh=l,rh}var sh,b1;function xq(){if(b1)return sh;b1=1;var e=La(),n=ty();function r(i,o){return e(i,n(i),o)}return sh=r,sh}var ih,S1;function ny(){if(S1)return ih;S1=1;function e(n,r){for(var i=-1,o=r.length,l=n.length;++i<o;)n[l+i]=r[i];return n}return ih=e,ih}var oh,k1;function qu(){if(k1)return oh;k1=1;var e=_C(),n=e(Object.getPrototypeOf,Object);return oh=n,oh}var ah,E1;function NC(){if(E1)return ah;E1=1;var e=ny(),n=qu(),r=ty(),i=EC(),o=Object.getOwnPropertySymbols,l=o?function(u){for(var c=[];u;)e(c,r(u)),u=n(u);return c}:i;return ah=l,ah}var lh,N1;function _q(){if(N1)return lh;N1=1;var e=La(),n=NC();function r(i,o){return e(i,n(i),o)}return lh=r,lh}var uh,C1;function CC(){if(C1)return uh;C1=1;var e=ny(),n=bt();function r(i,o,l){var u=o(i);return n(i)?u:e(u,l(i))}return uh=r,uh}var ch,j1;function jC(){if(j1)return ch;j1=1;var e=CC(),n=ty(),r=ks();function i(o){return e(o,r,n)}return ch=i,ch}var dh,R1;function bq(){if(R1)return dh;R1=1;var e=CC(),n=NC(),r=di();function i(o){return e(o,r,n)}return dh=i,dh}var fh,T1;function Sq(){if(T1)return fh;T1=1;var e=ci(),n=tr(),r=e(n,"DataView");return fh=r,fh}var hh,A1;function kq(){if(A1)return hh;A1=1;var e=ci(),n=tr(),r=e(n,"Promise");return hh=r,hh}var ph,I1;function RC(){if(I1)return ph;I1=1;var e=ci(),n=tr(),r=e(n,"Set");return ph=r,ph}var mh,M1;function Eq(){if(M1)return mh;M1=1;var e=ci(),n=tr(),r=e(n,"WeakMap");return mh=r,mh}var gh,P1;function _o(){if(P1)return gh;P1=1;var e=Sq(),n=Kv(),r=kq(),i=RC(),o=Eq(),l=ui(),u=yC(),c="[object Map]",p="[object Object]",f="[object Promise]",h="[object Set]",g="[object WeakMap]",y="[object DataView]",x=u(e),N=u(n),_=u(r),S=u(i),b=u(o),k=l;return(e&&k(new e(new ArrayBuffer(1)))!=y||n&&k(new n)!=c||r&&k(r.resolve())!=f||i&&k(new i)!=h||o&&k(new o)!=g)&&(k=function(E){var C=l(E),A=C==p?E.constructor:void 0,M=A?u(A):"";if(M)switch(M){case x:return y;case N:return c;case _:return f;case S:return h;case b:return g}return C}),gh=k,gh}var vh,O1;function Nq(){if(O1)return vh;O1=1;var e=Object.prototype,n=e.hasOwnProperty;function r(i){var o=i.length,l=new i.constructor(o);return o&&typeof i[0]=="string"&&n.call(i,"index")&&(l.index=i.index,l.input=i.input),l}return vh=r,vh}var yh,L1;function TC(){if(L1)return yh;L1=1;var e=tr(),n=e.Uint8Array;return yh=n,yh}var wh,q1;function ry(){if(q1)return wh;q1=1;var e=TC();function n(r){var i=new r.constructor(r.byteLength);return new e(i).set(new e(r)),i}return wh=n,wh}var xh,$1;function Cq(){if($1)return xh;$1=1;var e=ry();function n(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return xh=n,xh}var _h,D1;function jq(){if(D1)return _h;D1=1;var e=/\w*$/;function n(r){var i=new r.constructor(r.source,e.exec(r));return i.lastIndex=r.lastIndex,i}return _h=n,_h}var bh,F1;function Rq(){if(F1)return bh;F1=1;var e=wo(),n=e?e.prototype:void 0,r=n?n.valueOf:void 0;function i(o){return r?Object(r.call(o)):{}}return bh=i,bh}var Sh,z1;function AC(){if(z1)return Sh;z1=1;var e=ry();function n(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return Sh=n,Sh}var kh,B1;function Tq(){if(B1)return kh;B1=1;var e=ry(),n=Cq(),r=jq(),i=Rq(),o=AC(),l="[object Boolean]",u="[object Date]",c="[object Map]",p="[object Number]",f="[object RegExp]",h="[object Set]",g="[object String]",y="[object Symbol]",x="[object ArrayBuffer]",N="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",k="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",A="[object Uint8ClampedArray]",M="[object Uint16Array]",L="[object Uint32Array]";function H(O,P,F){var G=O.constructor;switch(P){case x:return e(O);case l:case u:return new G(+O);case N:return n(O,F);case _:case S:case b:case k:case E:case C:case A:case M:case L:return o(O,F);case c:return new G;case p:case g:return new G(O);case f:return r(O);case h:return new G;case y:return i(O)}}return kh=H,kh}var Eh,U1;function IC(){if(U1)return Eh;U1=1;var e=Ln(),n=Object.create,r=(function(){function i(){}return function(o){if(!e(o))return{};if(n)return n(o);i.prototype=o;var l=new i;return i.prototype=void 0,l}})();return Eh=r,Eh}var Nh,H1;function MC(){if(H1)return Nh;H1=1;var e=IC(),n=qu(),r=Lu();function i(o){return typeof o.constructor=="function"&&!r(o)?e(n(o)):{}}return Nh=i,Nh}var Ch,W1;function Aq(){if(W1)return Ch;W1=1;var e=_o(),n=vr(),r="[object Map]";function i(o){return n(o)&&e(o)==r}return Ch=i,Ch}var jh,V1;function Iq(){if(V1)return jh;V1=1;var e=Aq(),n=Ou(),r=Jv(),i=r&&r.isMap,o=i?n(i):e;return jh=o,jh}var Rh,G1;function Mq(){if(G1)return Rh;G1=1;var e=_o(),n=vr(),r="[object Set]";function i(o){return n(o)&&e(o)==r}return Rh=i,Rh}var Th,Y1;function Pq(){if(Y1)return Th;Y1=1;var e=Mq(),n=Ou(),r=Jv(),i=r&&r.isSet,o=i?n(i):e;return Th=o,Th}var Ah,K1;function PC(){if(K1)return Ah;K1=1;var e=Au(),n=Qv(),r=Mu(),i=gq(),o=wq(),l=bC(),u=SC(),c=xq(),p=_q(),f=jC(),h=bq(),g=_o(),y=Nq(),x=Tq(),N=MC(),_=bt(),S=xo(),b=Iq(),k=Ln(),E=Pq(),C=ks(),A=di(),M=1,L=2,H=4,O="[object Arguments]",P="[object Array]",F="[object Boolean]",G="[object Date]",q="[object Error]",R="[object Function]",Q="[object GeneratorFunction]",z="[object Map]",ne="[object Number]",Z="[object Object]",$="[object RegExp]",X="[object Set]",I="[object String]",W="[object Symbol]",Y="[object WeakMap]",U="[object ArrayBuffer]",J="[object DataView]",re="[object Float32Array]",le="[object Float64Array]",fe="[object Int8Array]",te="[object Int16Array]",ce="[object Int32Array]",Ce="[object Uint8Array]",ve="[object Uint8ClampedArray]",Te="[object Uint16Array]",ye="[object Uint32Array]",ke={};ke[O]=ke[P]=ke[U]=ke[J]=ke[F]=ke[G]=ke[re]=ke[le]=ke[fe]=ke[te]=ke[ce]=ke[z]=ke[ne]=ke[Z]=ke[$]=ke[X]=ke[I]=ke[W]=ke[Ce]=ke[ve]=ke[Te]=ke[ye]=!0,ke[q]=ke[R]=ke[Y]=!1;function Ge(we,_e,ze,ft,ht,Ue){var De,Ze=_e&M,Ye=_e&L,vt=_e&H;if(ze&&(De=ht?ze(we,ft,ht,Ue):ze(we)),De!==void 0)return De;if(!k(we))return we;var ot=_(we);if(ot){if(De=y(we),!Ze)return u(we,De)}else{var yt=g(we),Kt=yt==R||yt==Q;if(S(we))return l(we,Ze);if(yt==Z||yt==O||Kt&&!ht){if(De=Ye||Kt?{}:N(we),!Ze)return Ye?p(we,o(De,we)):c(we,i(De,we))}else{if(!ke[yt])return ht?we:{};De=x(we,yt,Ze)}}Ue||(Ue=new e);var Mt=Ue.get(we);if(Mt)return Mt;Ue.set(we,De),E(we)?we.forEach(function(pt){De.add(Ge(pt,_e,ze,pt,we,Ue))}):b(we)&&we.forEach(function(pt,mt){De.set(mt,Ge(pt,_e,ze,mt,we,Ue))});var Xe=vt?Ye?h:f:Ye?A:C,wt=ot?void 0:Xe(we);return n(wt||we,function(pt,mt){wt&&(mt=pt,pt=we[mt]),r(De,mt,Ge(pt,_e,ze,mt,we,Ue))}),De}return Ah=Ge,Ah}var Ih,X1;function Oq(){if(X1)return Ih;X1=1;var e=PC(),n=4;function r(i){return e(i,n)}return Ih=r,Ih}var Mh,Q1;function sy(){if(Q1)return Mh;Q1=1;function e(n){return function(){return n}}return Mh=e,Mh}var Ph,Z1;function Lq(){if(Z1)return Ph;Z1=1;function e(n){return function(r,i,o){for(var l=-1,u=Object(r),c=o(r),p=c.length;p--;){var f=c[n?p:++l];if(i(u[f],f,u)===!1)break}return r}}return Ph=e,Ph}var Oh,J1;function iy(){if(J1)return Oh;J1=1;var e=Lq(),n=e();return Oh=n,Oh}var Lh,eb;function oy(){if(eb)return Lh;eb=1;var e=iy(),n=ks();function r(i,o){return i&&e(i,o,n)}return Lh=r,Lh}var qh,tb;function qq(){if(tb)return qh;tb=1;var e=Wr();function n(r,i){return function(o,l){if(o==null)return o;if(!e(o))return r(o,l);for(var u=o.length,c=i?u:-1,p=Object(o);(i?c--:++c<u)&&l(p[c],c,p)!==!1;);return o}}return qh=n,qh}var $h,nb;function $u(){if(nb)return $h;nb=1;var e=oy(),n=qq(),r=n(e);return $h=r,$h}var Dh,rb;function fi(){if(rb)return Dh;rb=1;function e(n){return n}return Dh=e,Dh}var Fh,sb;function OC(){if(sb)return Fh;sb=1;var e=fi();function n(r){return typeof r=="function"?r:e}return Fh=n,Fh}var zh,ib;function LC(){if(ib)return zh;ib=1;var e=Qv(),n=$u(),r=OC(),i=bt();function o(l,u){var c=i(l)?e:n;return c(l,r(u))}return zh=o,zh}var Bh,ob;function qC(){return ob||(ob=1,Bh=LC()),Bh}var Uh,ab;function $q(){if(ab)return Uh;ab=1;var e=$u();function n(r,i){var o=[];return e(r,function(l,u,c){i(l,u,c)&&o.push(l)}),o}return Uh=n,Uh}var Hh,lb;function Dq(){if(lb)return Hh;lb=1;var e="__lodash_hash_undefined__";function n(r){return this.__data__.set(r,e),this}return Hh=n,Hh}var Wh,ub;function Fq(){if(ub)return Wh;ub=1;function e(n){return this.__data__.has(n)}return Wh=e,Wh}var Vh,cb;function $C(){if(cb)return Vh;cb=1;var e=Xv(),n=Dq(),r=Fq();function i(o){var l=-1,u=o==null?0:o.length;for(this.__data__=new e;++l<u;)this.add(o[l])}return i.prototype.add=i.prototype.push=n,i.prototype.has=r,Vh=i,Vh}var Gh,db;function zq(){if(db)return Gh;db=1;function e(n,r){for(var i=-1,o=n==null?0:n.length;++i<o;)if(r(n[i],i,n))return!0;return!1}return Gh=e,Gh}var Yh,fb;function DC(){if(fb)return Yh;fb=1;function e(n,r){return n.has(r)}return Yh=e,Yh}var Kh,hb;function FC(){if(hb)return Kh;hb=1;var e=$C(),n=zq(),r=DC(),i=1,o=2;function l(u,c,p,f,h,g){var y=p&i,x=u.length,N=c.length;if(x!=N&&!(y&&N>x))return!1;var _=g.get(u),S=g.get(c);if(_&&S)return _==c&&S==u;var b=-1,k=!0,E=p&o?new e:void 0;for(g.set(u,c),g.set(c,u);++b<x;){var C=u[b],A=c[b];if(f)var M=y?f(A,C,b,c,u,g):f(C,A,b,u,c,g);if(M!==void 0){if(M)continue;k=!1;break}if(E){if(!n(c,function(L,H){if(!r(E,H)&&(C===L||h(C,L,p,f,g)))return E.push(H)})){k=!1;break}}else if(!(C===A||h(C,A,p,f,g))){k=!1;break}}return g.delete(u),g.delete(c),k}return Kh=l,Kh}var Xh,pb;function Bq(){if(pb)return Xh;pb=1;function e(n){var r=-1,i=Array(n.size);return n.forEach(function(o,l){i[++r]=[l,o]}),i}return Xh=e,Xh}var Qh,mb;function ay(){if(mb)return Qh;mb=1;function e(n){var r=-1,i=Array(n.size);return n.forEach(function(o){i[++r]=o}),i}return Qh=e,Qh}var Zh,gb;function Uq(){if(gb)return Zh;gb=1;var e=wo(),n=TC(),r=yo(),i=FC(),o=Bq(),l=ay(),u=1,c=2,p="[object Boolean]",f="[object Date]",h="[object Error]",g="[object Map]",y="[object Number]",x="[object RegExp]",N="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",k="[object DataView]",E=e?e.prototype:void 0,C=E?E.valueOf:void 0;function A(M,L,H,O,P,F,G){switch(H){case k:if(M.byteLength!=L.byteLength||M.byteOffset!=L.byteOffset)return!1;M=M.buffer,L=L.buffer;case b:return!(M.byteLength!=L.byteLength||!F(new n(M),new n(L)));case p:case f:case y:return r(+M,+L);case h:return M.name==L.name&&M.message==L.message;case x:case _:return M==L+"";case g:var q=o;case N:var R=O&u;if(q||(q=l),M.size!=L.size&&!R)return!1;var Q=G.get(M);if(Q)return Q==L;O|=c,G.set(M,L);var z=i(q(M),q(L),O,P,F,G);return G.delete(M),z;case S:if(C)return C.call(M)==C.call(L)}return!1}return Zh=A,Zh}var Jh,vb;function Hq(){if(vb)return Jh;vb=1;var e=jC(),n=1,r=Object.prototype,i=r.hasOwnProperty;function o(l,u,c,p,f,h){var g=c&n,y=e(l),x=y.length,N=e(u),_=N.length;if(x!=_&&!g)return!1;for(var S=x;S--;){var b=y[S];if(!(g?b in u:i.call(u,b)))return!1}var k=h.get(l),E=h.get(u);if(k&&E)return k==u&&E==l;var C=!0;h.set(l,u),h.set(u,l);for(var A=g;++S<x;){b=y[S];var M=l[b],L=u[b];if(p)var H=g?p(L,M,b,u,l,h):p(M,L,b,l,u,h);if(!(H===void 0?M===L||f(M,L,c,p,h):H)){C=!1;break}A||(A=b=="constructor")}if(C&&!A){var O=l.constructor,P=u.constructor;O!=P&&"constructor"in l&&"constructor"in u&&!(typeof O=="function"&&O instanceof O&&typeof P=="function"&&P instanceof P)&&(C=!1)}return h.delete(l),h.delete(u),C}return Jh=o,Jh}var ep,yb;function Wq(){if(yb)return ep;yb=1;var e=Au(),n=FC(),r=Uq(),i=Hq(),o=_o(),l=bt(),u=xo(),c=$a(),p=1,f="[object Arguments]",h="[object Array]",g="[object Object]",y=Object.prototype,x=y.hasOwnProperty;function N(_,S,b,k,E,C){var A=l(_),M=l(S),L=A?h:o(_),H=M?h:o(S);L=L==f?g:L,H=H==f?g:H;var O=L==g,P=H==g,F=L==H;if(F&&u(_)){if(!u(S))return!1;A=!0,O=!1}if(F&&!O)return C||(C=new e),A||c(_)?n(_,S,b,k,E,C):r(_,S,L,b,k,E,C);if(!(b&p)){var G=O&&x.call(_,"__wrapped__"),q=P&&x.call(S,"__wrapped__");if(G||q){var R=G?_.value():_,Q=q?S.value():S;return C||(C=new e),E(R,Q,b,k,C)}}return F?(C||(C=new e),i(_,S,b,k,E,C)):!1}return ep=N,ep}var tp,wb;function zC(){if(wb)return tp;wb=1;var e=Wq(),n=vr();function r(i,o,l,u,c){return i===o?!0:i==null||o==null||!n(i)&&!n(o)?i!==i&&o!==o:e(i,o,l,u,r,c)}return tp=r,tp}var np,xb;function Vq(){if(xb)return np;xb=1;var e=Au(),n=zC(),r=1,i=2;function o(l,u,c,p){var f=c.length,h=f,g=!p;if(l==null)return!h;for(l=Object(l);f--;){var y=c[f];if(g&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++f<h;){y=c[f];var x=y[0],N=l[x],_=y[1];if(g&&y[2]){if(N===void 0&&!(x in l))return!1}else{var S=new e;if(p)var b=p(N,_,x,l,u,S);if(!(b===void 0?n(_,N,r|i,p,S):b))return!1}}return!0}return np=o,np}var rp,_b;function BC(){if(_b)return rp;_b=1;var e=Ln();function n(r){return r===r&&!e(r)}return rp=n,rp}var sp,bb;function Gq(){if(bb)return sp;bb=1;var e=BC(),n=ks();function r(i){for(var o=n(i),l=o.length;l--;){var u=o[l],c=i[u];o[l]=[u,c,e(c)]}return o}return sp=r,sp}var ip,Sb;function UC(){if(Sb)return ip;Sb=1;function e(n,r){return function(i){return i==null?!1:i[n]===r&&(r!==void 0||n in Object(i))}}return ip=e,ip}var op,kb;function Yq(){if(kb)return op;kb=1;var e=Vq(),n=Gq(),r=UC();function i(o){var l=n(o);return l.length==1&&l[0][2]?r(l[0][0],l[0][1]):function(u){return u===o||e(u,o,l)}}return op=i,op}var ap,Eb;function bo(){if(Eb)return ap;Eb=1;var e=ui(),n=vr(),r="[object Symbol]";function i(o){return typeof o=="symbol"||n(o)&&e(o)==r}return ap=i,ap}var lp,Nb;function ly(){if(Nb)return lp;Nb=1;var e=bt(),n=bo(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i=/^\w*$/;function o(l,u){if(e(l))return!1;var c=typeof l;return c=="number"||c=="symbol"||c=="boolean"||l==null||n(l)?!0:i.test(l)||!r.test(l)||u!=null&&l in Object(u)}return lp=o,lp}var up,Cb;function Kq(){if(Cb)return up;Cb=1;var e=Xv(),n="Expected a function";function r(i,o){if(typeof i!="function"||o!=null&&typeof o!="function")throw new TypeError(n);var l=function(){var u=arguments,c=o?o.apply(this,u):u[0],p=l.cache;if(p.has(c))return p.get(c);var f=i.apply(this,u);return l.cache=p.set(c,f)||p,f};return l.cache=new(r.Cache||e),l}return r.Cache=e,up=r,up}var cp,jb;function Xq(){if(jb)return cp;jb=1;var e=Kq(),n=500;function r(i){var o=e(i,function(u){return l.size===n&&l.clear(),u}),l=o.cache;return o}return cp=r,cp}var dp,Rb;function Qq(){if(Rb)return dp;Rb=1;var e=Xq(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,i=e(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(n,function(u,c,p,f){l.push(p?f.replace(r,"$1"):c||u)}),l});return dp=i,dp}var fp,Tb;function Du(){if(Tb)return fp;Tb=1;function e(n,r){for(var i=-1,o=n==null?0:n.length,l=Array(o);++i<o;)l[i]=r(n[i],i,n);return l}return fp=e,fp}var hp,Ab;function Zq(){if(Ab)return hp;Ab=1;var e=wo(),n=Du(),r=bt(),i=bo(),o=e?e.prototype:void 0,l=o?o.toString:void 0;function u(c){if(typeof c=="string")return c;if(r(c))return n(c,u)+"";if(i(c))return l?l.call(c):"";var p=c+"";return p=="0"&&1/c==-1/0?"-0":p}return hp=u,hp}var pp,Ib;function HC(){if(Ib)return pp;Ib=1;var e=Zq();function n(r){return r==null?"":e(r)}return pp=n,pp}var mp,Mb;function Fu(){if(Mb)return mp;Mb=1;var e=bt(),n=ly(),r=Qq(),i=HC();function o(l,u){return e(l)?l:n(l,u)?[l]:r(i(l))}return mp=o,mp}var gp,Pb;function Da(){if(Pb)return gp;Pb=1;var e=bo();function n(r){if(typeof r=="string"||e(r))return r;var i=r+"";return i=="0"&&1/r==-1/0?"-0":i}return gp=n,gp}var vp,Ob;function zu(){if(Ob)return vp;Ob=1;var e=Fu(),n=Da();function r(i,o){o=e(o,i);for(var l=0,u=o.length;i!=null&&l<u;)i=i[n(o[l++])];return l&&l==u?i:void 0}return vp=r,vp}var yp,Lb;function Jq(){if(Lb)return yp;Lb=1;var e=zu();function n(r,i,o){var l=r==null?void 0:e(r,i);return l===void 0?o:l}return yp=n,yp}var wp,qb;function e$(){if(qb)return wp;qb=1;function e(n,r){return n!=null&&r in Object(n)}return wp=e,wp}var xp,$b;function WC(){if($b)return xp;$b=1;var e=Fu(),n=qa(),r=bt(),i=Pu(),o=Zv(),l=Da();function u(c,p,f){p=e(p,c);for(var h=-1,g=p.length,y=!1;++h<g;){var x=l(p[h]);if(!(y=c!=null&&f(c,x)))break;c=c[x]}return y||++h!=g?y:(g=c==null?0:c.length,!!g&&o(g)&&i(x,g)&&(r(c)||n(c)))}return xp=u,xp}var _p,Db;function VC(){if(Db)return _p;Db=1;var e=e$(),n=WC();function r(i,o){return i!=null&&n(i,o,e)}return _p=r,_p}var bp,Fb;function t$(){if(Fb)return bp;Fb=1;var e=zC(),n=Jq(),r=VC(),i=ly(),o=BC(),l=UC(),u=Da(),c=1,p=2;function f(h,g){return i(h)&&o(g)?l(u(h),g):function(y){var x=n(y,h);return x===void 0&&x===g?r(y,h):e(g,x,c|p)}}return bp=f,bp}var Sp,zb;function GC(){if(zb)return Sp;zb=1;function e(n){return function(r){return r==null?void 0:r[n]}}return Sp=e,Sp}var kp,Bb;function n$(){if(Bb)return kp;Bb=1;var e=zu();function n(r){return function(i){return e(i,r)}}return kp=n,kp}var Ep,Ub;function r$(){if(Ub)return Ep;Ub=1;var e=GC(),n=n$(),r=ly(),i=Da();function o(l){return r(l)?e(i(l)):n(l)}return Ep=o,Ep}var Np,Hb;function Vr(){if(Hb)return Np;Hb=1;var e=Yq(),n=t$(),r=fi(),i=bt(),o=r$();function l(u){return typeof u=="function"?u:u==null?r:typeof u=="object"?i(u)?n(u[0],u[1]):e(u):o(u)}return Np=l,Np}var Cp,Wb;function YC(){if(Wb)return Cp;Wb=1;var e=kC(),n=$q(),r=Vr(),i=bt();function o(l,u){var c=i(l)?e:n;return c(l,r(u,3))}return Cp=o,Cp}var jp,Vb;function s$(){if(Vb)return jp;Vb=1;var e=Object.prototype,n=e.hasOwnProperty;function r(i,o){return i!=null&&n.call(i,o)}return jp=r,jp}var Rp,Gb;function KC(){if(Gb)return Rp;Gb=1;var e=s$(),n=WC();function r(i,o){return i!=null&&n(i,o,e)}return Rp=r,Rp}var Tp,Yb;function i$(){if(Yb)return Tp;Yb=1;var e=ey(),n=_o(),r=qa(),i=bt(),o=Wr(),l=xo(),u=Lu(),c=$a(),p="[object Map]",f="[object Set]",h=Object.prototype,g=h.hasOwnProperty;function y(x){if(x==null)return!0;if(o(x)&&(i(x)||typeof x=="string"||typeof x.splice=="function"||l(x)||c(x)||r(x)))return!x.length;var N=n(x);if(N==p||N==f)return!x.size;if(u(x))return!e(x).length;for(var _ in x)if(g.call(x,_))return!1;return!0}return Tp=y,Tp}var Ap,Kb;function XC(){if(Kb)return Ap;Kb=1;function e(n){return n===void 0}return Ap=e,Ap}var Ip,Xb;function QC(){if(Xb)return Ip;Xb=1;var e=$u(),n=Wr();function r(i,o){var l=-1,u=n(i)?Array(i.length):[];return e(i,function(c,p,f){u[++l]=o(c,p,f)}),u}return Ip=r,Ip}var Mp,Qb;function ZC(){if(Qb)return Mp;Qb=1;var e=Du(),n=Vr(),r=QC(),i=bt();function o(l,u){var c=i(l)?e:r;return c(l,n(u,3))}return Mp=o,Mp}var Pp,Zb;function o$(){if(Zb)return Pp;Zb=1;function e(n,r,i,o){var l=-1,u=n==null?0:n.length;for(o&&u&&(i=n[++l]);++l<u;)i=r(i,n[l],l,n);return i}return Pp=e,Pp}var Op,Jb;function a$(){if(Jb)return Op;Jb=1;function e(n,r,i,o,l){return l(n,function(u,c,p){i=o?(o=!1,u):r(i,u,c,p)}),i}return Op=e,Op}var Lp,eS;function JC(){if(eS)return Lp;eS=1;var e=o$(),n=$u(),r=Vr(),i=a$(),o=bt();function l(u,c,p){var f=o(u)?e:i,h=arguments.length<3;return f(u,r(c,4),p,h,n)}return Lp=l,Lp}var qp,tS;function l$(){if(tS)return qp;tS=1;var e=ui(),n=bt(),r=vr(),i="[object String]";function o(l){return typeof l=="string"||!n(l)&&r(l)&&e(l)==i}return qp=o,qp}var $p,nS;function u$(){if(nS)return $p;nS=1;var e=GC(),n=e("length");return $p=n,$p}var Dp,rS;function c$(){if(rS)return Dp;rS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",o=n+r+i,l="\\ufe0e\\ufe0f",u="\\u200d",c=RegExp("["+u+e+o+l+"]");function p(f){return c.test(f)}return Dp=p,Dp}var Fp,sS;function d$(){if(sS)return Fp;sS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",o=n+r+i,l="\\ufe0e\\ufe0f",u="["+e+"]",c="["+o+"]",p="\\ud83c[\\udffb-\\udfff]",f="(?:"+c+"|"+p+")",h="[^"+e+"]",g="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",x="\\u200d",N=f+"?",_="["+l+"]?",S="(?:"+x+"(?:"+[h,g,y].join("|")+")"+_+N+")*",b=_+N+S,k="(?:"+[h+c+"?",c,g,y,u].join("|")+")",E=RegExp(p+"(?="+p+")|"+k+b,"g");function C(A){for(var M=E.lastIndex=0;E.test(A);)++M;return M}return Fp=C,Fp}var zp,iS;function f$(){if(iS)return zp;iS=1;var e=u$(),n=c$(),r=d$();function i(o){return n(o)?r(o):e(o)}return zp=i,zp}var Bp,oS;function h$(){if(oS)return Bp;oS=1;var e=ey(),n=_o(),r=Wr(),i=l$(),o=f$(),l="[object Map]",u="[object Set]";function c(p){if(p==null)return 0;if(r(p))return i(p)?o(p):p.length;var f=n(p);return f==l||f==u?p.size:e(p).length}return Bp=c,Bp}var Up,aS;function p$(){if(aS)return Up;aS=1;var e=Qv(),n=IC(),r=oy(),i=Vr(),o=qu(),l=bt(),u=xo(),c=Oa(),p=Ln(),f=$a();function h(g,y,x){var N=l(g),_=N||u(g)||f(g);if(y=i(y,4),x==null){var S=g&&g.constructor;_?x=N?new S:[]:p(g)?x=c(S)?n(o(g)):{}:x={}}return(_?e:r)(g,function(b,k,E){return y(x,b,k,E)}),x}return Up=h,Up}var Hp,lS;function m$(){if(lS)return Hp;lS=1;var e=wo(),n=qa(),r=bt(),i=e?e.isConcatSpreadable:void 0;function o(l){return r(l)||n(l)||!!(i&&l&&l[i])}return Hp=o,Hp}var Wp,uS;function uy(){if(uS)return Wp;uS=1;var e=ny(),n=m$();function r(i,o,l,u,c){var p=-1,f=i.length;for(l||(l=n),c||(c=[]);++p<f;){var h=i[p];o>0&&l(h)?o>1?r(h,o-1,l,u,c):e(c,h):u||(c[c.length]=h)}return c}return Wp=r,Wp}var Vp,cS;function g$(){if(cS)return Vp;cS=1;function e(n,r,i){switch(i.length){case 0:return n.call(r);case 1:return n.call(r,i[0]);case 2:return n.call(r,i[0],i[1]);case 3:return n.call(r,i[0],i[1],i[2])}return n.apply(r,i)}return Vp=e,Vp}var Gp,dS;function ej(){if(dS)return Gp;dS=1;var e=g$(),n=Math.max;function r(i,o,l){return o=n(o===void 0?i.length-1:o,0),function(){for(var u=arguments,c=-1,p=n(u.length-o,0),f=Array(p);++c<p;)f[c]=u[o+c];c=-1;for(var h=Array(o+1);++c<o;)h[c]=u[c];return h[o]=l(f),e(i,this,h)}}return Gp=r,Gp}var Yp,fS;function v$(){if(fS)return Yp;fS=1;var e=sy(),n=wC(),r=fi(),i=n?function(o,l){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:r;return Yp=i,Yp}var Kp,hS;function y$(){if(hS)return Kp;hS=1;var e=800,n=16,r=Date.now;function i(o){var l=0,u=0;return function(){var c=r(),p=n-(c-u);if(u=c,p>0){if(++l>=e)return arguments[0]}else l=0;return o.apply(void 0,arguments)}}return Kp=i,Kp}var Xp,pS;function tj(){if(pS)return Xp;pS=1;var e=v$(),n=y$(),r=n(e);return Xp=r,Xp}var Qp,mS;function Bu(){if(mS)return Qp;mS=1;var e=fi(),n=ej(),r=tj();function i(o,l){return r(n(o,l,e),o+"")}return Qp=i,Qp}var Zp,gS;function nj(){if(gS)return Zp;gS=1;function e(n,r,i,o){for(var l=n.length,u=i+(o?1:-1);o?u--:++u<l;)if(r(n[u],u,n))return u;return-1}return Zp=e,Zp}var Jp,vS;function w$(){if(vS)return Jp;vS=1;function e(n){return n!==n}return Jp=e,Jp}var em,yS;function x$(){if(yS)return em;yS=1;function e(n,r,i){for(var o=i-1,l=n.length;++o<l;)if(n[o]===r)return o;return-1}return em=e,em}var tm,wS;function _$(){if(wS)return tm;wS=1;var e=nj(),n=w$(),r=x$();function i(o,l,u){return l===l?r(o,l,u):e(o,n,u)}return tm=i,tm}var nm,xS;function b$(){if(xS)return nm;xS=1;var e=_$();function n(r,i){var o=r==null?0:r.length;return!!o&&e(r,i,0)>-1}return nm=n,nm}var rm,_S;function S$(){if(_S)return rm;_S=1;function e(n,r,i){for(var o=-1,l=n==null?0:n.length;++o<l;)if(i(r,n[o]))return!0;return!1}return rm=e,rm}var sm,bS;function k$(){if(bS)return sm;bS=1;function e(){}return sm=e,sm}var im,SS;function E$(){if(SS)return im;SS=1;var e=RC(),n=k$(),r=ay(),i=1/0,o=e&&1/r(new e([,-0]))[1]==i?function(l){return new e(l)}:n;return im=o,im}var om,kS;function N$(){if(kS)return om;kS=1;var e=$C(),n=b$(),r=S$(),i=DC(),o=E$(),l=ay(),u=200;function c(p,f,h){var g=-1,y=n,x=p.length,N=!0,_=[],S=_;if(h)N=!1,y=r;else if(x>=u){var b=f?null:o(p);if(b)return l(b);N=!1,y=i,S=new e}else S=f?[]:_;e:for(;++g<x;){var k=p[g],E=f?f(k):k;if(k=h||k!==0?k:0,N&&E===E){for(var C=S.length;C--;)if(S[C]===E)continue e;f&&S.push(E),_.push(k)}else y(S,E,h)||(S!==_&&S.push(E),_.push(k))}return _}return om=c,om}var am,ES;function rj(){if(ES)return am;ES=1;var e=Wr(),n=vr();function r(i){return n(i)&&e(i)}return am=r,am}var lm,NS;function C$(){if(NS)return lm;NS=1;var e=uy(),n=Bu(),r=N$(),i=rj(),o=n(function(l){return r(e(l,1,i,!0))});return lm=o,lm}var um,CS;function j$(){if(CS)return um;CS=1;var e=Du();function n(r,i){return e(i,function(o){return r[o]})}return um=n,um}var cm,jS;function sj(){if(jS)return cm;jS=1;var e=j$(),n=ks();function r(i){return i==null?[]:e(i,n(i))}return cm=r,cm}var dm,RS;function qn(){if(RS)return dm;RS=1;var e;if(typeof Yv=="function")try{e={clone:Oq(),constant:sy(),each:qC(),filter:YC(),has:KC(),isArray:bt(),isEmpty:i$(),isFunction:Oa(),isUndefined:XC(),keys:ks(),map:ZC(),reduce:JC(),size:h$(),transform:p$(),union:C$(),values:sj()}}catch{}return e||(e=window._),dm=e,dm}var fm,TS;function cy(){if(TS)return fm;TS=1;var e=qn();fm=o;var n="\0",r="\0",i="";function o(h){this._isDirected=e.has(h,"directed")?h.directed:!0,this._isMultigraph=e.has(h,"multigraph")?h.multigraph:!1,this._isCompound=e.has(h,"compound")?h.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[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(h){return this._label=h,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultNodeLabelFn=h,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var h=this;return e.filter(this.nodes(),function(g){return e.isEmpty(h._in[g])})},o.prototype.sinks=function(){var h=this;return e.filter(this.nodes(),function(g){return e.isEmpty(h._out[g])})},o.prototype.setNodes=function(h,g){var y=arguments,x=this;return e.each(h,function(N){y.length>1?x.setNode(N,g):x.setNode(N)}),this},o.prototype.setNode=function(h,g){return e.has(this._nodes,h)?(arguments.length>1&&(this._nodes[h]=g),this):(this._nodes[h]=arguments.length>1?g:this._defaultNodeLabelFn(h),this._isCompound&&(this._parent[h]=r,this._children[h]={},this._children[r][h]=!0),this._in[h]={},this._preds[h]={},this._out[h]={},this._sucs[h]={},++this._nodeCount,this)},o.prototype.node=function(h){return this._nodes[h]},o.prototype.hasNode=function(h){return e.has(this._nodes,h)},o.prototype.removeNode=function(h){var g=this;if(e.has(this._nodes,h)){var y=function(x){g.removeEdge(g._edgeObjs[x])};delete this._nodes[h],this._isCompound&&(this._removeFromParentsChildList(h),delete this._parent[h],e.each(this.children(h),function(x){g.setParent(x)}),delete this._children[h]),e.each(e.keys(this._in[h]),y),delete this._in[h],delete this._preds[h],e.each(e.keys(this._out[h]),y),delete this._out[h],delete this._sucs[h],--this._nodeCount}return this},o.prototype.setParent=function(h,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===h)throw new Error("Setting "+g+" as parent of "+h+" would create a cycle");this.setNode(g)}return this.setNode(h),this._removeFromParentsChildList(h),this._parent[h]=g,this._children[g][h]=!0,this},o.prototype._removeFromParentsChildList=function(h){delete this._children[this._parent[h]][h]},o.prototype.parent=function(h){if(this._isCompound){var g=this._parent[h];if(g!==r)return g}},o.prototype.children=function(h){if(e.isUndefined(h)&&(h=r),this._isCompound){var g=this._children[h];if(g)return e.keys(g)}else{if(h===r)return this.nodes();if(this.hasNode(h))return[]}},o.prototype.predecessors=function(h){var g=this._preds[h];if(g)return e.keys(g)},o.prototype.successors=function(h){var g=this._sucs[h];if(g)return e.keys(g)},o.prototype.neighbors=function(h){var g=this.predecessors(h);if(g)return e.union(g,this.successors(h))},o.prototype.isLeaf=function(h){var g;return this.isDirected()?g=this.successors(h):g=this.neighbors(h),g.length===0},o.prototype.filterNodes=function(h){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(_,S){h(S)&&g.setNode(S,_)}),e.each(this._edgeObjs,function(_){g.hasNode(_.v)&&g.hasNode(_.w)&&g.setEdge(_,y.edge(_))});var x={};function N(_){var S=y.parent(_);return S===void 0||g.hasNode(S)?(x[_]=S,S):S in x?x[S]:N(S)}return this._isCompound&&e.each(g.nodes(),function(_){g.setParent(_,N(_))}),g},o.prototype.setDefaultEdgeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultEdgeLabelFn=h,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(h,g){var y=this,x=arguments;return e.reduce(h,function(N,_){return x.length>1?y.setEdge(N,_,g):y.setEdge(N,_),_}),this},o.prototype.setEdge=function(){var h,g,y,x,N=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(h=_.v,g=_.w,y=_.name,arguments.length===2&&(x=arguments[1],N=!0)):(h=_,g=arguments[1],y=arguments[3],arguments.length>2&&(x=arguments[2],N=!0)),h=""+h,g=""+g,e.isUndefined(y)||(y=""+y);var S=c(this._isDirected,h,g,y);if(e.has(this._edgeLabels,S))return N&&(this._edgeLabels[S]=x),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(h),this.setNode(g),this._edgeLabels[S]=N?x:this._defaultEdgeLabelFn(h,g,y);var b=p(this._isDirected,h,g,y);return h=b.v,g=b.w,Object.freeze(b),this._edgeObjs[S]=b,l(this._preds[g],h),l(this._sucs[h],g),this._in[g][S]=b,this._out[h][S]=b,this._edgeCount++,this},o.prototype.edge=function(h,g,y){var x=arguments.length===1?f(this._isDirected,arguments[0]):c(this._isDirected,h,g,y);return this._edgeLabels[x]},o.prototype.hasEdge=function(h,g,y){var x=arguments.length===1?f(this._isDirected,arguments[0]):c(this._isDirected,h,g,y);return e.has(this._edgeLabels,x)},o.prototype.removeEdge=function(h,g,y){var x=arguments.length===1?f(this._isDirected,arguments[0]):c(this._isDirected,h,g,y),N=this._edgeObjs[x];return N&&(h=N.v,g=N.w,delete this._edgeLabels[x],delete this._edgeObjs[x],u(this._preds[g],h),u(this._sucs[h],g),delete this._in[g][x],delete this._out[h][x],this._edgeCount--),this},o.prototype.inEdges=function(h,g){var y=this._in[h];if(y){var x=e.values(y);return g?e.filter(x,function(N){return N.v===g}):x}},o.prototype.outEdges=function(h,g){var y=this._out[h];if(y){var x=e.values(y);return g?e.filter(x,function(N){return N.w===g}):x}},o.prototype.nodeEdges=function(h,g){var y=this.inEdges(h,g);if(y)return y.concat(this.outEdges(h,g))};function l(h,g){h[g]?h[g]++:h[g]=1}function u(h,g){--h[g]||delete h[g]}function c(h,g,y,x){var N=""+g,_=""+y;if(!h&&N>_){var S=N;N=_,_=S}return N+i+_+i+(e.isUndefined(x)?n:x)}function p(h,g,y,x){var N=""+g,_=""+y;if(!h&&N>_){var S=N;N=_,_=S}var b={v:N,w:_};return x&&(b.name=x),b}function f(h,g){return c(h,g.v,g.w,g.name)}return fm}var hm,AS;function R$(){return AS||(AS=1,hm="2.1.8"),hm}var pm,IS;function T$(){return IS||(IS=1,pm={Graph:cy(),version:R$()}),pm}var mm,MS;function A$(){if(MS)return mm;MS=1;var e=qn(),n=cy();mm={write:r,read:l};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 p=u.node(c),f=u.parent(c),h={v:c};return e.isUndefined(p)||(h.value=p),e.isUndefined(f)||(h.parent=f),h})}function o(u){return e.map(u.edges(),function(c){var p=u.edge(c),f={v:c.v,w:c.w};return e.isUndefined(c.name)||(f.name=c.name),e.isUndefined(p)||(f.value=p),f})}function l(u){var c=new n(u.options).setGraph(u.value);return e.each(u.nodes,function(p){c.setNode(p.v,p.value),p.parent&&c.setParent(p.v,p.parent)}),e.each(u.edges,function(p){c.setEdge({v:p.v,w:p.w,name:p.name},p.value)}),c}return mm}var gm,PS;function I$(){if(PS)return gm;PS=1;var e=qn();gm=n;function n(r){var i={},o=[],l;function u(c){e.has(i,c)||(i[c]=!0,l.push(c),e.each(r.successors(c),u),e.each(r.predecessors(c),u))}return e.each(r.nodes(),function(c){l=[],u(c),l.length&&o.push(l)}),o}return gm}var vm,OS;function ij(){if(OS)return vm;OS=1;var e=qn();vm=n;function n(){this._arr=[],this._keyIndices={}}return n.prototype.size=function(){return this._arr.length},n.prototype.keys=function(){return this._arr.map(function(r){return r.key})},n.prototype.has=function(r){return e.has(this._keyIndices,r)},n.prototype.priority=function(r){var i=this._keyIndices[r];if(i!==void 0)return this._arr[i].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(r,i){var o=this._keyIndices;if(r=String(r),!e.has(o,r)){var l=this._arr,u=l.length;return o[r]=u,l.push({key:r,priority:i}),this._decrease(u),!0}return!1},n.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},n.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)},n.prototype._heapify=function(r){var i=this._arr,o=2*r,l=o+1,u=r;o<i.length&&(u=i[o].priority<i[u].priority?o:u,l<i.length&&(u=i[l].priority<i[u].priority?l:u),u!==r&&(this._swap(r,u),this._heapify(u)))},n.prototype._decrease=function(r){for(var i=this._arr,o=i[r].priority,l;r!==0&&(l=r>>1,!(i[l].priority<o));)this._swap(r,l),r=l},n.prototype._swap=function(r,i){var o=this._arr,l=this._keyIndices,u=o[r],c=o[i];o[r]=c,o[i]=u,l[c.key]=r,l[u.key]=i},vm}var ym,LS;function oj(){if(LS)return ym;LS=1;var e=qn(),n=ij();ym=i;var r=e.constant(1);function i(l,u,c,p){return o(l,String(u),c||r,p||function(f){return l.outEdges(f)})}function o(l,u,c,p){var f={},h=new n,g,y,x=function(N){var _=N.v!==g?N.v:N.w,S=f[_],b=c(N),k=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+N+" Weight: "+b);k<S.distance&&(S.distance=k,S.predecessor=g,h.decrease(_,k))};for(l.nodes().forEach(function(N){var _=N===u?0:Number.POSITIVE_INFINITY;f[N]={distance:_},h.add(N,_)});h.size()>0&&(g=h.removeMin(),y=f[g],y.distance!==Number.POSITIVE_INFINITY);)p(g).forEach(x);return f}return ym}var wm,qS;function M$(){if(qS)return wm;qS=1;var e=oj(),n=qn();wm=r;function r(i,o,l){return n.transform(i.nodes(),function(u,c){u[c]=e(i,c,o,l)},{})}return wm}var xm,$S;function aj(){if($S)return xm;$S=1;var e=qn();xm=n;function n(r){var i=0,o=[],l={},u=[];function c(p){var f=l[p]={onStack:!0,lowlink:i,index:i++};if(o.push(p),r.successors(p).forEach(function(y){e.has(l,y)?l[y].onStack&&(f.lowlink=Math.min(f.lowlink,l[y].index)):(c(y),f.lowlink=Math.min(f.lowlink,l[y].lowlink))}),f.lowlink===f.index){var h=[],g;do g=o.pop(),l[g].onStack=!1,h.push(g);while(p!==g);u.push(h)}}return r.nodes().forEach(function(p){e.has(l,p)||c(p)}),u}return xm}var _m,DS;function P$(){if(DS)return _m;DS=1;var e=qn(),n=aj();_m=r;function r(i){return e.filter(n(i),function(o){return o.length>1||o.length===1&&i.hasEdge(o[0],o[0])})}return _m}var bm,FS;function O$(){if(FS)return bm;FS=1;var e=qn();bm=r;var n=e.constant(1);function r(o,l,u){return i(o,l||n,u||function(c){return o.outEdges(c)})}function i(o,l,u){var c={},p=o.nodes();return p.forEach(function(f){c[f]={},c[f][f]={distance:0},p.forEach(function(h){f!==h&&(c[f][h]={distance:Number.POSITIVE_INFINITY})}),u(f).forEach(function(h){var g=h.v===f?h.w:h.v,y=l(h);c[f][g]={distance:y,predecessor:f}})}),p.forEach(function(f){var h=c[f];p.forEach(function(g){var y=c[g];p.forEach(function(x){var N=y[f],_=h[x],S=y[x],b=N.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return bm}var Sm,zS;function lj(){if(zS)return Sm;zS=1;var e=qn();Sm=n,n.CycleException=r;function n(i){var o={},l={},u=[];function c(p){if(e.has(l,p))throw new r;e.has(o,p)||(l[p]=!0,o[p]=!0,e.each(i.predecessors(p),c),delete l[p],u.push(p))}if(e.each(i.sinks(),c),e.size(o)!==i.nodeCount())throw new r;return u}function r(){}return r.prototype=new Error,Sm}var km,BS;function L$(){if(BS)return km;BS=1;var e=lj();km=n;function n(r){try{e(r)}catch(i){if(i instanceof e.CycleException)return!1;throw i}return!0}return km}var Em,US;function uj(){if(US)return Em;US=1;var e=qn();Em=n;function n(i,o,l){e.isArray(o)||(o=[o]);var u=(i.isDirected()?i.successors:i.neighbors).bind(i),c=[],p={};return e.each(o,function(f){if(!i.hasNode(f))throw new Error("Graph does not have node: "+f);r(i,f,l==="post",p,u,c)}),c}function r(i,o,l,u,c,p){e.has(u,o)||(u[o]=!0,l||p.push(o),e.each(c(o),function(f){r(i,f,l,u,c,p)}),l&&p.push(o))}return Em}var Nm,HS;function q$(){if(HS)return Nm;HS=1;var e=uj();Nm=n;function n(r,i){return e(r,i,"post")}return Nm}var Cm,WS;function $$(){if(WS)return Cm;WS=1;var e=uj();Cm=n;function n(r,i){return e(r,i,"pre")}return Cm}var jm,VS;function D$(){if(VS)return jm;VS=1;var e=qn(),n=cy(),r=ij();jm=i;function i(o,l){var u=new n,c={},p=new r,f;function h(y){var x=y.v===f?y.w:y.v,N=p.priority(x);if(N!==void 0){var _=l(y);_<N&&(c[x]=f,p.decrease(x,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){p.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),p.decrease(o.nodes()[0],0);for(var g=!1;p.size()>0;){if(f=p.removeMin(),e.has(c,f))u.setEdge(f,c[f]);else{if(g)throw new Error("Input graph is not connected: "+o);g=!0}o.nodeEdges(f).forEach(h)}return u}return jm}var Rm,GS;function F$(){return GS||(GS=1,Rm={components:I$(),dijkstra:oj(),dijkstraAll:M$(),findCycles:P$(),floydWarshall:O$(),isAcyclic:L$(),postorder:q$(),preorder:$$(),prim:D$(),tarjan:aj(),topsort:lj()}),Rm}var Tm,YS;function z$(){if(YS)return Tm;YS=1;var e=T$();return Tm={Graph:e.Graph,json:A$(),alg:F$(),version:e.version},Tm}var Am,KS;function Jn(){if(KS)return Am;KS=1;var e;if(typeof Yv=="function")try{e=z$()}catch{}return e||(e=window.graphlib),Am=e,Am}var Im,XS;function B$(){if(XS)return Im;XS=1;var e=PC(),n=1,r=4;function i(o){return e(o,n|r)}return Im=i,Im}var Mm,QS;function Uu(){if(QS)return Mm;QS=1;var e=yo(),n=Wr(),r=Pu(),i=Ln();function o(l,u,c){if(!i(c))return!1;var p=typeof u;return(p=="number"?n(c)&&r(u,c.length):p=="string"&&u in c)?e(c[u],l):!1}return Mm=o,Mm}var Pm,ZS;function U$(){if(ZS)return Pm;ZS=1;var e=Bu(),n=yo(),r=Uu(),i=di(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,p){c=Object(c);var f=-1,h=p.length,g=h>2?p[2]:void 0;for(g&&r(p[0],p[1],g)&&(h=1);++f<h;)for(var y=p[f],x=i(y),N=-1,_=x.length;++N<_;){var S=x[N],b=c[S];(b===void 0||n(b,o[S])&&!l.call(c,S))&&(c[S]=y[S])}return c});return Pm=u,Pm}var Om,JS;function H$(){if(JS)return Om;JS=1;var e=Vr(),n=Wr(),r=ks();function i(o){return function(l,u,c){var p=Object(l);if(!n(l)){var f=e(u,3);l=r(l),u=function(g){return f(p[g],g,p)}}var h=o(l,u,c);return h>-1?p[f?l[h]:h]:void 0}}return Om=i,Om}var Lm,ek;function W$(){if(ek)return Lm;ek=1;var e=/\s/;function n(r){for(var i=r.length;i--&&e.test(r.charAt(i)););return i}return Lm=n,Lm}var qm,tk;function V$(){if(tk)return qm;tk=1;var e=W$(),n=/^\s+/;function r(i){return i&&i.slice(0,e(i)+1).replace(n,"")}return qm=r,qm}var $m,nk;function G$(){if(nk)return $m;nk=1;var e=V$(),n=Ln(),r=bo(),i=NaN,o=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function p(f){if(typeof f=="number")return f;if(r(f))return i;if(n(f)){var h=typeof f.valueOf=="function"?f.valueOf():f;f=n(h)?h+"":h}if(typeof f!="string")return f===0?f:+f;f=e(f);var g=l.test(f);return g||u.test(f)?c(f.slice(2),g?2:8):o.test(f)?i:+f}return $m=p,$m}var Dm,rk;function cj(){if(rk)return Dm;rk=1;var e=G$(),n=1/0,r=17976931348623157e292;function i(o){if(!o)return o===0?o:0;if(o=e(o),o===n||o===-n){var l=o<0?-1:1;return l*r}return o===o?o:0}return Dm=i,Dm}var Fm,sk;function Y$(){if(sk)return Fm;sk=1;var e=cj();function n(r){var i=e(r),o=i%1;return i===i?o?i-o:i:0}return Fm=n,Fm}var zm,ik;function K$(){if(ik)return zm;ik=1;var e=nj(),n=Vr(),r=Y$(),i=Math.max;function o(l,u,c){var p=l==null?0:l.length;if(!p)return-1;var f=c==null?0:r(c);return f<0&&(f=i(p+f,0)),e(l,n(u,3),f)}return zm=o,zm}var Bm,ok;function X$(){if(ok)return Bm;ok=1;var e=H$(),n=K$(),r=e(n);return Bm=r,Bm}var Um,ak;function dj(){if(ak)return Um;ak=1;var e=uy();function n(r){var i=r==null?0:r.length;return i?e(r,1):[]}return Um=n,Um}var Hm,lk;function Q$(){if(lk)return Hm;lk=1;var e=iy(),n=OC(),r=di();function i(o,l){return o==null?o:e(o,n(l),r)}return Hm=i,Hm}var Wm,uk;function Z$(){if(uk)return Wm;uk=1;function e(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}return Wm=e,Wm}var Vm,ck;function J$(){if(ck)return Vm;ck=1;var e=Iu(),n=oy(),r=Vr();function i(o,l){var u={};return l=r(l,3),n(o,function(c,p,f){e(u,p,l(c,p,f))}),u}return Vm=i,Vm}var Gm,dk;function dy(){if(dk)return Gm;dk=1;var e=bo();function n(r,i,o){for(var l=-1,u=r.length;++l<u;){var c=r[l],p=i(c);if(p!=null&&(f===void 0?p===p&&!e(p):o(p,f)))var f=p,h=c}return h}return Gm=n,Gm}var Ym,fk;function e4(){if(fk)return Ym;fk=1;function e(n,r){return n>r}return Ym=e,Ym}var Km,hk;function t4(){if(hk)return Km;hk=1;var e=dy(),n=e4(),r=fi();function i(o){return o&&o.length?e(o,r,n):void 0}return Km=i,Km}var Xm,pk;function fj(){if(pk)return Xm;pk=1;var e=Iu(),n=yo();function r(i,o,l){(l!==void 0&&!n(i[o],l)||l===void 0&&!(o in i))&&e(i,o,l)}return Xm=r,Xm}var Qm,mk;function n4(){if(mk)return Qm;mk=1;var e=ui(),n=qu(),r=vr(),i="[object Object]",o=Function.prototype,l=Object.prototype,u=o.toString,c=l.hasOwnProperty,p=u.call(Object);function f(h){if(!r(h)||e(h)!=i)return!1;var g=n(h);if(g===null)return!0;var y=c.call(g,"constructor")&&g.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==p}return Qm=f,Qm}var Zm,gk;function hj(){if(gk)return Zm;gk=1;function e(n,r){if(!(r==="constructor"&&typeof n[r]=="function")&&r!="__proto__")return n[r]}return Zm=e,Zm}var Jm,vk;function r4(){if(vk)return Jm;vk=1;var e=La(),n=di();function r(i){return e(i,n(i))}return Jm=r,Jm}var eg,yk;function s4(){if(yk)return eg;yk=1;var e=fj(),n=bC(),r=AC(),i=SC(),o=MC(),l=qa(),u=bt(),c=rj(),p=xo(),f=Oa(),h=Ln(),g=n4(),y=$a(),x=hj(),N=r4();function _(S,b,k,E,C,A,M){var L=x(S,k),H=x(b,k),O=M.get(H);if(O){e(S,k,O);return}var P=A?A(L,H,k+"",S,b,M):void 0,F=P===void 0;if(F){var G=u(H),q=!G&&p(H),R=!G&&!q&&y(H);P=H,G||q||R?u(L)?P=L:c(L)?P=i(L):q?(F=!1,P=n(H,!0)):R?(F=!1,P=r(H,!0)):P=[]:g(H)||l(H)?(P=L,l(L)?P=N(L):(!h(L)||f(L))&&(P=o(H))):F=!1}F&&(M.set(H,P),C(P,H,E,A,M),M.delete(H)),e(S,k,P)}return eg=_,eg}var tg,wk;function i4(){if(wk)return tg;wk=1;var e=Au(),n=fj(),r=iy(),i=s4(),o=Ln(),l=di(),u=hj();function c(p,f,h,g,y){p!==f&&r(f,function(x,N){if(y||(y=new e),o(x))i(p,f,N,h,c,g,y);else{var _=g?g(u(p,N),x,N+"",p,f,y):void 0;_===void 0&&(_=x),n(p,N,_)}},l)}return tg=c,tg}var ng,xk;function o4(){if(xk)return ng;xk=1;var e=Bu(),n=Uu();function r(i){return e(function(o,l){var u=-1,c=l.length,p=c>1?l[c-1]:void 0,f=c>2?l[2]:void 0;for(p=i.length>3&&typeof p=="function"?(c--,p):void 0,f&&n(l[0],l[1],f)&&(p=c<3?void 0:p,c=1),o=Object(o);++u<c;){var h=l[u];h&&i(o,h,u,p)}return o})}return ng=r,ng}var rg,_k;function a4(){if(_k)return rg;_k=1;var e=i4(),n=o4(),r=n(function(i,o,l){e(i,o,l)});return rg=r,rg}var sg,bk;function pj(){if(bk)return sg;bk=1;function e(n,r){return n<r}return sg=e,sg}var ig,Sk;function l4(){if(Sk)return ig;Sk=1;var e=dy(),n=pj(),r=fi();function i(o){return o&&o.length?e(o,r,n):void 0}return ig=i,ig}var og,kk;function u4(){if(kk)return og;kk=1;var e=dy(),n=Vr(),r=pj();function i(o,l){return o&&o.length?e(o,n(l,2),r):void 0}return og=i,og}var ag,Ek;function c4(){if(Ek)return ag;Ek=1;var e=tr(),n=function(){return e.Date.now()};return ag=n,ag}var lg,Nk;function d4(){if(Nk)return lg;Nk=1;var e=Mu(),n=Fu(),r=Pu(),i=Ln(),o=Da();function l(u,c,p,f){if(!i(u))return u;c=n(c,u);for(var h=-1,g=c.length,y=g-1,x=u;x!=null&&++h<g;){var N=o(c[h]),_=p;if(N==="__proto__"||N==="constructor"||N==="prototype")return u;if(h!=y){var S=x[N];_=f?f(S,N,x):void 0,_===void 0&&(_=i(S)?S:r(c[h+1])?[]:{})}e(x,N,_),x=x[N]}return u}return lg=l,lg}var ug,Ck;function f4(){if(Ck)return ug;Ck=1;var e=zu(),n=d4(),r=Fu();function i(o,l,u){for(var c=-1,p=l.length,f={};++c<p;){var h=l[c],g=e(o,h);u(g,h)&&n(f,r(h,o),g)}return f}return ug=i,ug}var cg,jk;function h4(){if(jk)return cg;jk=1;var e=f4(),n=VC();function r(i,o){return e(i,o,function(l,u){return n(i,u)})}return cg=r,cg}var dg,Rk;function p4(){if(Rk)return dg;Rk=1;var e=dj(),n=ej(),r=tj();function i(o){return r(n(o,void 0,e),o+"")}return dg=i,dg}var fg,Tk;function m4(){if(Tk)return fg;Tk=1;var e=h4(),n=p4(),r=n(function(i,o){return i==null?{}:e(i,o)});return fg=r,fg}var hg,Ak;function g4(){if(Ak)return hg;Ak=1;var e=Math.ceil,n=Math.max;function r(i,o,l,u){for(var c=-1,p=n(e((o-i)/(l||1)),0),f=Array(p);p--;)f[u?p:++c]=i,i+=l;return f}return hg=r,hg}var pg,Ik;function v4(){if(Ik)return pg;Ik=1;var e=g4(),n=Uu(),r=cj();function i(o){return function(l,u,c){return c&&typeof c!="number"&&n(l,u,c)&&(u=c=void 0),l=r(l),u===void 0?(u=l,l=0):u=r(u),c=c===void 0?l<u?1:-1:r(c),e(l,u,c,o)}}return pg=i,pg}var mg,Mk;function y4(){if(Mk)return mg;Mk=1;var e=v4(),n=e();return mg=n,mg}var gg,Pk;function w4(){if(Pk)return gg;Pk=1;function e(n,r){var i=n.length;for(n.sort(r);i--;)n[i]=n[i].value;return n}return gg=e,gg}var vg,Ok;function x4(){if(Ok)return vg;Ok=1;var e=bo();function n(r,i){if(r!==i){var o=r!==void 0,l=r===null,u=r===r,c=e(r),p=i!==void 0,f=i===null,h=i===i,g=e(i);if(!f&&!g&&!c&&r>i||c&&p&&h&&!f&&!g||l&&p&&h||!o&&h||!u)return 1;if(!l&&!c&&!g&&r<i||g&&o&&u&&!l&&!c||f&&o&&u||!p&&u||!h)return-1}return 0}return vg=n,vg}var yg,Lk;function _4(){if(Lk)return yg;Lk=1;var e=x4();function n(r,i,o){for(var l=-1,u=r.criteria,c=i.criteria,p=u.length,f=o.length;++l<p;){var h=e(u[l],c[l]);if(h){if(l>=f)return h;var g=o[l];return h*(g=="desc"?-1:1)}}return r.index-i.index}return yg=n,yg}var wg,qk;function b4(){if(qk)return wg;qk=1;var e=Du(),n=zu(),r=Vr(),i=QC(),o=w4(),l=Ou(),u=_4(),c=fi(),p=bt();function f(h,g,y){g.length?g=e(g,function(_){return p(_)?function(S){return n(S,_.length===1?_[0]:_)}:_}):g=[c];var x=-1;g=e(g,l(r));var N=i(h,function(_,S,b){var k=e(g,function(E){return E(_)});return{criteria:k,index:++x,value:_}});return o(N,function(_,S){return u(_,S,y)})}return wg=f,wg}var xg,$k;function S4(){if($k)return xg;$k=1;var e=uy(),n=b4(),r=Bu(),i=Uu(),o=r(function(l,u){if(l==null)return[];var c=u.length;return c>1&&i(l,u[0],u[1])?u=[]:c>2&&i(u[0],u[1],u[2])&&(u=[u[0]]),n(l,e(u,1),[])});return xg=o,xg}var _g,Dk;function k4(){if(Dk)return _g;Dk=1;var e=HC(),n=0;function r(i){var o=++n;return e(i)+o}return _g=r,_g}var bg,Fk;function E4(){if(Fk)return bg;Fk=1;function e(n,r,i){for(var o=-1,l=n.length,u=r.length,c={};++o<l;){var p=o<u?r[o]:void 0;i(c,n[o],p)}return c}return bg=e,bg}var Sg,zk;function N4(){if(zk)return Sg;zk=1;var e=Mu(),n=E4();function r(i,o){return n(i||[],o||[],e)}return Sg=r,Sg}var kg,Bk;function it(){if(Bk)return kg;Bk=1;var e;if(typeof Yv=="function")try{e={cloneDeep:B$(),constant:sy(),defaults:U$(),each:qC(),filter:YC(),find:X$(),flatten:dj(),forEach:LC(),forIn:Q$(),has:KC(),isUndefined:XC(),last:Z$(),map:ZC(),mapValues:J$(),max:t4(),merge:a4(),min:l4(),minBy:u4(),now:c4(),pick:m4(),range:y4(),reduce:JC(),sortBy:S4(),uniqueId:k4(),values:sj(),zipObject:N4()}}catch{}return e||(e=window._),kg=e,kg}var Eg,Uk;function C4(){if(Uk)return Eg;Uk=1,Eg=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 n(o),o},e.prototype.enqueue=function(i){var o=this._sentinel;i._prev&&i._next&&n(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,l=o._prev;l!==o;)i.push(JSON.stringify(l,r)),l=l._prev;return"["+i.join(", ")+"]"};function n(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 Eg}var Ng,Hk;function j4(){if(Hk)return Ng;Hk=1;var e=it(),n=Jn().Graph,r=C4();Ng=o;var i=e.constant(1);function o(f,h){if(f.nodeCount()<=1)return[];var g=c(f,h||i),y=l(g.graph,g.buckets,g.zeroIdx);return e.flatten(e.map(y,function(x){return f.outEdges(x.v,x.w)}),!0)}function l(f,h,g){for(var y=[],x=h[h.length-1],N=h[0],_;f.nodeCount();){for(;_=N.dequeue();)u(f,h,g,_);for(;_=x.dequeue();)u(f,h,g,_);if(f.nodeCount()){for(var S=h.length-2;S>0;--S)if(_=h[S].dequeue(),_){y=y.concat(u(f,h,g,_,!0));break}}}return y}function u(f,h,g,y,x){var N=x?[]:void 0;return e.forEach(f.inEdges(y.v),function(_){var S=f.edge(_),b=f.node(_.v);x&&N.push({v:_.v,w:_.w}),b.out-=S,p(h,g,b)}),e.forEach(f.outEdges(y.v),function(_){var S=f.edge(_),b=_.w,k=f.node(b);k.in-=S,p(h,g,k)}),f.removeNode(y.v),N}function c(f,h){var g=new n,y=0,x=0;e.forEach(f.nodes(),function(S){g.setNode(S,{v:S,in:0,out:0})}),e.forEach(f.edges(),function(S){var b=g.edge(S.v,S.w)||0,k=h(S),E=b+k;g.setEdge(S.v,S.w,E),x=Math.max(x,g.node(S.v).out+=k),y=Math.max(y,g.node(S.w).in+=k)});var N=e.range(x+y+3).map(function(){return new r}),_=y+1;return e.forEach(g.nodes(),function(S){p(N,_,g.node(S))}),{graph:g,buckets:N,zeroIdx:_}}function p(f,h,g){g.out?g.in?f[g.out-g.in+h].enqueue(g):f[f.length-1].enqueue(g):f[0].enqueue(g)}return Ng}var Cg,Wk;function R4(){if(Wk)return Cg;Wk=1;var e=it(),n=j4();Cg={run:r,undo:o};function r(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):i(l);e.forEach(u,function(p){var f=l.edge(p);l.removeEdge(p),f.forwardName=p.name,f.reversed=!0,l.setEdge(p.w,p.v,f,e.uniqueId("rev"))});function c(p){return function(f){return p.edge(f).weight}}}function i(l){var u=[],c={},p={};function f(h){e.has(p,h)||(p[h]=!0,c[h]=!0,e.forEach(l.outEdges(h),function(g){e.has(c,g.w)?u.push(g):f(g.w)}),delete c[h])}return e.forEach(l.nodes(),f),u}function o(l){e.forEach(l.edges(),function(u){var c=l.edge(u);if(c.reversed){l.removeEdge(u);var p=c.forwardName;delete c.reversed,delete c.forwardName,l.setEdge(u.w,u.v,c,p)}})}return Cg}var jg,Vk;function hn(){if(Vk)return jg;Vk=1;var e=it(),n=Jn().Graph;jg={addDummyNode:r,simplify:i,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:p,normalizeRanks:f,removeEmptyRanks:h,addBorderNode:g,maxRank:y,partition:x,time:N,notime:_};function r(S,b,k,E){var C;do C=e.uniqueId(E);while(S.hasNode(C));return k.dummy=b,S.setNode(C,k),C}function i(S){var b=new n().setGraph(S.graph());return e.forEach(S.nodes(),function(k){b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){var E=b.edge(k.v,k.w)||{weight:0,minlen:1},C=S.edge(k);b.setEdge(k.v,k.w,{weight:E.weight+C.weight,minlen:Math.max(E.minlen,C.minlen)})}),b}function o(S){var b=new n({multigraph:S.isMultigraph()}).setGraph(S.graph());return e.forEach(S.nodes(),function(k){S.children(k).length||b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){b.setEdge(k,S.edge(k))}),b}function l(S){var b=e.map(S.nodes(),function(k){var E={};return e.forEach(S.outEdges(k),function(C){E[C.w]=(E[C.w]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function u(S){var b=e.map(S.nodes(),function(k){var E={};return e.forEach(S.inEdges(k),function(C){E[C.v]=(E[C.v]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function c(S,b){var k=S.x,E=S.y,C=b.x-k,A=b.y-E,M=S.width/2,L=S.height/2;if(!C&&!A)throw new Error("Not possible to find intersection inside of the rectangle");var H,O;return Math.abs(A)*M>Math.abs(C)*L?(A<0&&(L=-L),H=L*C/A,O=L):(C<0&&(M=-M),H=M,O=M*A/C),{x:k+H,y:E+O}}function p(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(k){var E=S.node(k),C=E.rank;e.isUndefined(C)||(b[C][E.order]=k)}),b}function f(S){var b=e.min(e.map(S.nodes(),function(k){return S.node(k).rank}));e.forEach(S.nodes(),function(k){var E=S.node(k);e.has(E,"rank")&&(E.rank-=b)})}function h(S){var b=e.min(e.map(S.nodes(),function(A){return S.node(A).rank})),k=[];e.forEach(S.nodes(),function(A){var M=S.node(A).rank-b;k[M]||(k[M]=[]),k[M].push(A)});var E=0,C=S.graph().nodeRankFactor;e.forEach(k,function(A,M){e.isUndefined(A)&&M%C!==0?--E:E&&e.forEach(A,function(L){S.node(L).rank+=E})})}function g(S,b,k,E){var C={width:0,height:0};return arguments.length>=4&&(C.rank=k,C.order=E),r(S,"border",C,b)}function y(S){return e.max(e.map(S.nodes(),function(b){var k=S.node(b).rank;if(!e.isUndefined(k))return k}))}function x(S,b){var k={lhs:[],rhs:[]};return e.forEach(S,function(E){b(E)?k.lhs.push(E):k.rhs.push(E)}),k}function N(S,b){var k=e.now();try{return b()}finally{console.log(S+" time: "+(e.now()-k)+"ms")}}function _(S,b){return b()}return jg}var Rg,Gk;function T4(){if(Gk)return Rg;Gk=1;var e=it(),n=hn();Rg={run:r,undo:o};function r(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(u){i(l,u)})}function i(l,u){var c=u.v,p=l.node(c).rank,f=u.w,h=l.node(f).rank,g=u.name,y=l.edge(u),x=y.labelRank;if(h!==p+1){l.removeEdge(u);var N,_,S;for(S=0,++p;p<h;++S,++p)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:u,rank:p},N=n.addDummyNode(l,"edge",_,"_d"),p===x&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(c,N,{weight:y.weight},g),S===0&&l.graph().dummyChains.push(N),c=N;l.setEdge(c,f,{weight:y.weight},g)}}function o(l){e.forEach(l.graph().dummyChains,function(u){var c=l.node(u),p=c.edgeLabel,f;for(l.setEdge(c.edgeObj,p);c.dummy;)f=l.successors(u)[0],l.removeNode(u),p.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(p.x=c.x,p.y=c.y,p.width=c.width,p.height=c.height),u=f,c=l.node(u)})}return Rg}var Tg,Yk;function vu(){if(Yk)return Tg;Yk=1;var e=it();Tg={longestPath:n,slack:r};function n(i){var o={};function l(u){var c=i.node(u);if(e.has(o,u))return c.rank;o[u]=!0;var p=e.min(e.map(i.outEdges(u),function(f){return l(f.w)-i.edge(f).minlen}));return(p===Number.POSITIVE_INFINITY||p===void 0||p===null)&&(p=0),c.rank=p}e.forEach(i.sources(),l)}function r(i,o){return i.node(o.w).rank-i.node(o.v).rank-i.edge(o).minlen}return Tg}var Ag,Kk;function mj(){if(Kk)return Ag;Kk=1;var e=it(),n=Jn().Graph,r=vu().slack;Ag=i;function i(c){var p=new n({directed:!1}),f=c.nodes()[0],h=c.nodeCount();p.setNode(f,{});for(var g,y;o(p,c)<h;)g=l(p,c),y=p.hasNode(g.v)?r(c,g):-r(c,g),u(p,c,y);return p}function o(c,p){function f(h){e.forEach(p.nodeEdges(h),function(g){var y=g.v,x=h===y?g.w:y;!c.hasNode(x)&&!r(p,g)&&(c.setNode(x,{}),c.setEdge(h,x,{}),f(x))})}return e.forEach(c.nodes(),f),c.nodeCount()}function l(c,p){return e.minBy(p.edges(),function(f){if(c.hasNode(f.v)!==c.hasNode(f.w))return r(p,f)})}function u(c,p,f){e.forEach(c.nodes(),function(h){p.node(h).rank+=f})}return Ag}var Ig,Xk;function A4(){if(Xk)return Ig;Xk=1;var e=it(),n=mj(),r=vu().slack,i=vu().longestPath,o=Jn().alg.preorder,l=Jn().alg.postorder,u=hn().simplify;Ig=c,c.initLowLimValues=g,c.initCutValues=p,c.calcCutValue=h,c.leaveEdge=x,c.enterEdge=N,c.exchangeEdges=_;function c(E){E=u(E),i(E);var C=n(E);g(C),p(C,E);for(var A,M;A=x(C);)M=N(C,E,A),_(C,E,A,M)}function p(E,C){var A=l(E,E.nodes());A=A.slice(0,A.length-1),e.forEach(A,function(M){f(E,C,M)})}function f(E,C,A){var M=E.node(A),L=M.parent;E.edge(A,L).cutvalue=h(E,C,A)}function h(E,C,A){var M=E.node(A),L=M.parent,H=!0,O=C.edge(A,L),P=0;return O||(H=!1,O=C.edge(L,A)),P=O.weight,e.forEach(C.nodeEdges(A),function(F){var G=F.v===A,q=G?F.w:F.v;if(q!==L){var R=G===H,Q=C.edge(F).weight;if(P+=R?Q:-Q,b(E,A,q)){var z=E.edge(A,q).cutvalue;P+=R?-z:z}}}),P}function g(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,A,M,L){var H=A,O=E.node(M);return C[M]=!0,e.forEach(E.neighbors(M),function(P){e.has(C,P)||(A=y(E,C,A,P,M))}),O.low=H,O.lim=A++,L?O.parent=L:delete O.parent,A}function x(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function N(E,C,A){var M=A.v,L=A.w;C.hasEdge(M,L)||(M=A.w,L=A.v);var H=E.node(M),O=E.node(L),P=H,F=!1;H.lim>O.lim&&(P=O,F=!0);var G=e.filter(C.edges(),function(q){return F===k(E,E.node(q.v),P)&&F!==k(E,E.node(q.w),P)});return e.minBy(G,function(q){return r(C,q)})}function _(E,C,A,M){var L=A.v,H=A.w;E.removeEdge(L,H),E.setEdge(M.v,M.w,{}),g(E),p(E,C),S(E,C)}function S(E,C){var A=e.find(E.nodes(),function(L){return!C.node(L).parent}),M=o(E,A);M=M.slice(1),e.forEach(M,function(L){var H=E.node(L).parent,O=C.edge(L,H),P=!1;O||(O=C.edge(H,L),P=!0),C.node(L).rank=C.node(H).rank+(P?O.minlen:-O.minlen)})}function b(E,C,A){return E.hasEdge(C,A)}function k(E,C,A){return A.low<=C.lim&&C.lim<=A.lim}return Ig}var Mg,Qk;function I4(){if(Qk)return Mg;Qk=1;var e=vu(),n=e.longestPath,r=mj(),i=A4();Mg=o;function o(p){switch(p.graph().ranker){case"network-simplex":c(p);break;case"tight-tree":u(p);break;case"longest-path":l(p);break;default:c(p)}}var l=n;function u(p){n(p),r(p)}function c(p){i(p)}return Mg}var Pg,Zk;function M4(){if(Zk)return Pg;Zk=1;var e=it();Pg=n;function n(o){var l=i(o);e.forEach(o.graph().dummyChains,function(u){for(var c=o.node(u),p=c.edgeObj,f=r(o,l,p.v,p.w),h=f.path,g=f.lca,y=0,x=h[y],N=!0;u!==p.w;){if(c=o.node(u),N){for(;(x=h[y])!==g&&o.node(x).maxRank<c.rank;)y++;x===g&&(N=!1)}if(!N){for(;y<h.length-1&&o.node(x=h[y+1]).minRank<=c.rank;)y++;x=h[y]}o.setParent(u,x),u=o.successors(u)[0]}})}function r(o,l,u,c){var p=[],f=[],h=Math.min(l[u].low,l[c].low),g=Math.max(l[u].lim,l[c].lim),y,x;y=u;do y=o.parent(y),p.push(y);while(y&&(l[y].low>h||g>l[y].lim));for(x=y,y=c;(y=o.parent(y))!==x;)f.push(y);return{path:p.concat(f.reverse()),lca:x}}function i(o){var l={},u=0;function c(p){var f=u;e.forEach(o.children(p),c),l[p]={low:f,lim:u++}}return e.forEach(o.children(),c),l}return Pg}var Og,Jk;function P4(){if(Jk)return Og;Jk=1;var e=it(),n=hn();Og={run:r,cleanup:u};function r(c){var p=n.addDummyNode(c,"root",{},"_root"),f=o(c),h=e.max(e.values(f))-1,g=2*h+1;c.graph().nestingRoot=p,e.forEach(c.edges(),function(x){c.edge(x).minlen*=g});var y=l(c)+1;e.forEach(c.children(),function(x){i(c,p,g,y,h,f,x)}),c.graph().nodeRankFactor=g}function i(c,p,f,h,g,y,x){var N=c.children(x);if(!N.length){x!==p&&c.setEdge(p,x,{weight:0,minlen:f});return}var _=n.addBorderNode(c,"_bt"),S=n.addBorderNode(c,"_bb"),b=c.node(x);c.setParent(_,x),b.borderTop=_,c.setParent(S,x),b.borderBottom=S,e.forEach(N,function(k){i(c,p,f,h,g,y,k);var E=c.node(k),C=E.borderTop?E.borderTop:k,A=E.borderBottom?E.borderBottom:k,M=E.borderTop?h:2*h,L=C!==A?1:g-y[x]+1;c.setEdge(_,C,{weight:M,minlen:L,nestingEdge:!0}),c.setEdge(A,S,{weight:M,minlen:L,nestingEdge:!0})}),c.parent(x)||c.setEdge(p,_,{weight:0,minlen:g+y[x]})}function o(c){var p={};function f(h,g){var y=c.children(h);y&&y.length&&e.forEach(y,function(x){f(x,g+1)}),p[h]=g}return e.forEach(c.children(),function(h){f(h,1)}),p}function l(c){return e.reduce(c.edges(),function(p,f){return p+c.edge(f).weight},0)}function u(c){var p=c.graph();c.removeNode(p.nestingRoot),delete p.nestingRoot,e.forEach(c.edges(),function(f){var h=c.edge(f);h.nestingEdge&&c.removeEdge(f)})}return Og}var Lg,eE;function O4(){if(eE)return Lg;eE=1;var e=it(),n=hn();Lg=r;function r(o){function l(u){var c=o.children(u),p=o.node(u);if(c.length&&e.forEach(c,l),e.has(p,"minRank")){p.borderLeft=[],p.borderRight=[];for(var f=p.minRank,h=p.maxRank+1;f<h;++f)i(o,"borderLeft","_bl",u,p,f),i(o,"borderRight","_br",u,p,f)}}e.forEach(o.children(),l)}function i(o,l,u,c,p,f){var h={width:0,height:0,rank:f,borderType:l},g=p[l][f-1],y=n.addDummyNode(o,"border",h,u);p[l][f]=y,o.setParent(y,c),g&&o.setEdge(g,y,{weight:1})}return Lg}var qg,tE;function L4(){if(tE)return qg;tE=1;var e=it();qg={adjust:n,undo:r};function n(f){var h=f.graph().rankdir.toLowerCase();(h==="lr"||h==="rl")&&i(f)}function r(f){var h=f.graph().rankdir.toLowerCase();(h==="bt"||h==="rl")&&l(f),(h==="lr"||h==="rl")&&(c(f),i(f))}function i(f){e.forEach(f.nodes(),function(h){o(f.node(h))}),e.forEach(f.edges(),function(h){o(f.edge(h))})}function o(f){var h=f.width;f.width=f.height,f.height=h}function l(f){e.forEach(f.nodes(),function(h){u(f.node(h))}),e.forEach(f.edges(),function(h){var g=f.edge(h);e.forEach(g.points,u),e.has(g,"y")&&u(g)})}function u(f){f.y=-f.y}function c(f){e.forEach(f.nodes(),function(h){p(f.node(h))}),e.forEach(f.edges(),function(h){var g=f.edge(h);e.forEach(g.points,p),e.has(g,"x")&&p(g)})}function p(f){var h=f.x;f.x=f.y,f.y=h}return qg}var $g,nE;function q4(){if(nE)return $g;nE=1;var e=it();$g=n;function n(r){var i={},o=e.filter(r.nodes(),function(f){return!r.children(f).length}),l=e.max(e.map(o,function(f){return r.node(f).rank})),u=e.map(e.range(l+1),function(){return[]});function c(f){if(!e.has(i,f)){i[f]=!0;var h=r.node(f);u[h.rank].push(f),e.forEach(r.successors(f),c)}}var p=e.sortBy(o,function(f){return r.node(f).rank});return e.forEach(p,c),u}return $g}var Dg,rE;function $4(){if(rE)return Dg;rE=1;var e=it();Dg=n;function n(i,o){for(var l=0,u=1;u<o.length;++u)l+=r(i,o[u-1],o[u]);return l}function r(i,o,l){for(var u=e.zipObject(l,e.map(l,function(y,x){return x})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(i.outEdges(y),function(x){return{pos:u[x.w],weight:i.edge(x).weight}}),"pos")}),!0),p=1;p<l.length;)p<<=1;var f=2*p-1;p-=1;var h=e.map(new Array(f),function(){return 0}),g=0;return e.forEach(c.forEach(function(y){var x=y.pos+p;h[x]+=y.weight;for(var N=0;x>0;)x%2&&(N+=h[x+1]),x=x-1>>1,h[x]+=y.weight;g+=y.weight*N})),g}return Dg}var Fg,sE;function D4(){if(sE)return Fg;sE=1;var e=it();Fg=n;function n(r,i){return e.map(i,function(o){var l=r.inEdges(o);if(l.length){var u=e.reduce(l,function(c,p){var f=r.edge(p),h=r.node(p.v);return{sum:c.sum+f.weight*h.order,weight:c.weight+f.weight}},{sum:0,weight:0});return{v:o,barycenter:u.sum/u.weight,weight:u.weight}}else return{v:o}})}return Fg}var zg,iE;function F4(){if(iE)return zg;iE=1;var e=it();zg=n;function n(o,l){var u={};e.forEach(o,function(p,f){var h=u[p.v]={indegree:0,in:[],out:[],vs:[p.v],i:f};e.isUndefined(p.barycenter)||(h.barycenter=p.barycenter,h.weight=p.weight)}),e.forEach(l.edges(),function(p){var f=u[p.v],h=u[p.w];!e.isUndefined(f)&&!e.isUndefined(h)&&(h.indegree++,f.out.push(u[p.w]))});var c=e.filter(u,function(p){return!p.indegree});return r(c)}function r(o){var l=[];function u(f){return function(h){h.merged||(e.isUndefined(h.barycenter)||e.isUndefined(f.barycenter)||h.barycenter>=f.barycenter)&&i(f,h)}}function c(f){return function(h){h.in.push(f),--h.indegree===0&&o.push(h)}}for(;o.length;){var p=o.pop();l.push(p),e.forEach(p.in.reverse(),u(p)),e.forEach(p.out,c(p))}return e.map(e.filter(l,function(f){return!f.merged}),function(f){return e.pick(f,["vs","i","barycenter","weight"])})}function i(o,l){var u=0,c=0;o.weight&&(u+=o.barycenter*o.weight,c+=o.weight),l.weight&&(u+=l.barycenter*l.weight,c+=l.weight),o.vs=l.vs.concat(o.vs),o.barycenter=u/c,o.weight=c,o.i=Math.min(l.i,o.i),l.merged=!0}return zg}var Bg,oE;function z4(){if(oE)return Bg;oE=1;var e=it(),n=hn();Bg=r;function r(l,u){var c=n.partition(l,function(_){return e.has(_,"barycenter")}),p=c.lhs,f=e.sortBy(c.rhs,function(_){return-_.i}),h=[],g=0,y=0,x=0;p.sort(o(!!u)),x=i(h,f,x),e.forEach(p,function(_){x+=_.vs.length,h.push(_.vs),g+=_.barycenter*_.weight,y+=_.weight,x=i(h,f,x)});var N={vs:e.flatten(h,!0)};return y&&(N.barycenter=g/y,N.weight=y),N}function i(l,u,c){for(var p;u.length&&(p=e.last(u)).i<=c;)u.pop(),l.push(p.vs),c++;return c}function o(l){return function(u,c){return u.barycenter<c.barycenter?-1:u.barycenter>c.barycenter?1:l?c.i-u.i:u.i-c.i}}return Bg}var Ug,aE;function B4(){if(aE)return Ug;aE=1;var e=it(),n=D4(),r=F4(),i=z4();Ug=o;function o(c,p,f,h){var g=c.children(p),y=c.node(p),x=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,_={};x&&(g=e.filter(g,function(A){return A!==x&&A!==N}));var S=n(c,g);e.forEach(S,function(A){if(c.children(A.v).length){var M=o(c,A.v,f,h);_[A.v]=M,e.has(M,"barycenter")&&u(A,M)}});var b=r(S,f);l(b,_);var k=i(b,h);if(x&&(k.vs=e.flatten([x,k.vs,N],!0),c.predecessors(x).length)){var E=c.node(c.predecessors(x)[0]),C=c.node(c.predecessors(N)[0]);e.has(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+E.order+C.order)/(k.weight+2),k.weight+=2}return k}function l(c,p){e.forEach(c,function(f){f.vs=e.flatten(f.vs.map(function(h){return p[h]?p[h].vs:h}),!0)})}function u(c,p){e.isUndefined(c.barycenter)?(c.barycenter=p.barycenter,c.weight=p.weight):(c.barycenter=(c.barycenter*c.weight+p.barycenter*p.weight)/(c.weight+p.weight),c.weight+=p.weight)}return Ug}var Hg,lE;function U4(){if(lE)return Hg;lE=1;var e=it(),n=Jn().Graph;Hg=r;function r(o,l,u){var c=i(o),p=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(f){return o.node(f)});return e.forEach(o.nodes(),function(f){var h=o.node(f),g=o.parent(f);(h.rank===l||h.minRank<=l&&l<=h.maxRank)&&(p.setNode(f),p.setParent(f,g||c),e.forEach(o[u](f),function(y){var x=y.v===f?y.w:y.v,N=p.edge(x,f),_=e.isUndefined(N)?0:N.weight;p.setEdge(x,f,{weight:o.edge(y).weight+_})}),e.has(h,"minRank")&&p.setNode(f,{borderLeft:h.borderLeft[l],borderRight:h.borderRight[l]}))}),p}function i(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return Hg}var Wg,uE;function H4(){if(uE)return Wg;uE=1;var e=it();Wg=n;function n(r,i,o){var l={},u;e.forEach(o,function(c){for(var p=r.parent(c),f,h;p;){if(f=r.parent(p),f?(h=l[f],l[f]=p):(h=u,u=p),h&&h!==p){i.setEdge(h,p);return}p=f}})}return Wg}var Vg,cE;function W4(){if(cE)return Vg;cE=1;var e=it(),n=q4(),r=$4(),i=B4(),o=U4(),l=H4(),u=Jn().Graph,c=hn();Vg=p;function p(y){var x=c.maxRank(y),N=f(y,e.range(1,x+1),"inEdges"),_=f(y,e.range(x-1,-1,-1),"outEdges"),S=n(y);g(y,S);for(var b=Number.POSITIVE_INFINITY,k,E=0,C=0;C<4;++E,++C){h(E%2?N:_,E%4>=2),S=c.buildLayerMatrix(y);var A=r(y,S);A<b&&(C=0,k=e.cloneDeep(S),b=A)}g(y,k)}function f(y,x,N){return e.map(x,function(_){return o(y,_,N)})}function h(y,x){var N=new u;e.forEach(y,function(_){var S=_.graph().root,b=i(_,S,N,x);e.forEach(b.vs,function(k,E){_.node(k).order=E}),l(_,N,b.vs)})}function g(y,x){e.forEach(x,function(N){e.forEach(N,function(_,S){y.node(_).order=S})})}return Vg}var Gg,dE;function V4(){if(dE)return Gg;dE=1;var e=it(),n=Jn().Graph,r=hn();Gg={positionX:N,findType1Conflicts:i,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:p,horizontalCompaction:f,alignCoordinates:y,findSmallestWidthAlignment:g,balance:x};function i(b,k){var E={};function C(A,M){var L=0,H=0,O=A.length,P=e.last(M);return e.forEach(M,function(F,G){var q=l(b,F),R=q?b.node(q).order:O;(q||F===P)&&(e.forEach(M.slice(H,G+1),function(Q){e.forEach(b.predecessors(Q),function(z){var ne=b.node(z),Z=ne.order;(Z<L||R<Z)&&!(ne.dummy&&b.node(Q).dummy)&&u(E,z,Q)})}),H=G+1,L=R)}),M}return e.reduce(k,C),E}function o(b,k){var E={};function C(M,L,H,O,P){var F;e.forEach(e.range(L,H),function(G){F=M[G],b.node(F).dummy&&e.forEach(b.predecessors(F),function(q){var R=b.node(q);R.dummy&&(R.order<O||R.order>P)&&u(E,q,F)})})}function A(M,L){var H=-1,O,P=0;return e.forEach(L,function(F,G){if(b.node(F).dummy==="border"){var q=b.predecessors(F);q.length&&(O=b.node(q[0]).order,C(L,P,G,H,O),P=G,H=O)}C(L,P,L.length,O,M.length)}),L}return e.reduce(k,A),E}function l(b,k){if(b.node(k).dummy)return e.find(b.predecessors(k),function(E){return b.node(E).dummy})}function u(b,k,E){if(k>E){var C=k;k=E,E=C}var A=b[k];A||(b[k]=A={}),A[E]=!0}function c(b,k,E){if(k>E){var C=k;k=E,E=C}return e.has(b[k],E)}function p(b,k,E,C){var A={},M={},L={};return e.forEach(k,function(H){e.forEach(H,function(O,P){A[O]=O,M[O]=O,L[O]=P})}),e.forEach(k,function(H){var O=-1;e.forEach(H,function(P){var F=C(P);if(F.length){F=e.sortBy(F,function(z){return L[z]});for(var G=(F.length-1)/2,q=Math.floor(G),R=Math.ceil(G);q<=R;++q){var Q=F[q];M[P]===P&&O<L[Q]&&!c(E,P,Q)&&(M[Q]=P,M[P]=A[P]=A[Q],O=L[Q])}}})}),{root:A,align:M}}function f(b,k,E,C,A){var M={},L=h(b,k,E,A),H=A?"borderLeft":"borderRight";function O(G,q){for(var R=L.nodes(),Q=R.pop(),z={};Q;)z[Q]?G(Q):(z[Q]=!0,R.push(Q),R=R.concat(q(Q))),Q=R.pop()}function P(G){M[G]=L.inEdges(G).reduce(function(q,R){return Math.max(q,M[R.v]+L.edge(R))},0)}function F(G){var q=L.outEdges(G).reduce(function(Q,z){return Math.min(Q,M[z.w]-L.edge(z))},Number.POSITIVE_INFINITY),R=b.node(G);q!==Number.POSITIVE_INFINITY&&R.borderType!==H&&(M[G]=Math.max(M[G],q))}return O(P,L.predecessors.bind(L)),O(F,L.successors.bind(L)),e.forEach(C,function(G){M[G]=M[E[G]]}),M}function h(b,k,E,C){var A=new n,M=b.graph(),L=_(M.nodesep,M.edgesep,C);return e.forEach(k,function(H){var O;e.forEach(H,function(P){var F=E[P];if(A.setNode(F),O){var G=E[O],q=A.edge(G,F);A.setEdge(G,F,Math.max(L(b,P,O),q||0))}O=P})}),A}function g(b,k){return e.minBy(e.values(k),function(E){var C=Number.NEGATIVE_INFINITY,A=Number.POSITIVE_INFINITY;return e.forIn(E,function(M,L){var H=S(b,L)/2;C=Math.max(M+H,C),A=Math.min(M-H,A)}),C-A})}function y(b,k){var E=e.values(k),C=e.min(E),A=e.max(E);e.forEach(["u","d"],function(M){e.forEach(["l","r"],function(L){var H=M+L,O=b[H],P;if(O!==k){var F=e.values(O);P=L==="l"?C-e.min(F):A-e.max(F),P&&(b[H]=e.mapValues(O,function(G){return G+P}))}})})}function x(b,k){return e.mapValues(b.ul,function(E,C){if(k)return b[k.toLowerCase()][C];var A=e.sortBy(e.map(b,C));return(A[1]+A[2])/2})}function N(b){var k=r.buildLayerMatrix(b),E=e.merge(i(b,k),o(b,k)),C={},A;e.forEach(["u","d"],function(L){A=L==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(H){H==="r"&&(A=e.map(A,function(G){return e.values(G).reverse()}));var O=(L==="u"?b.predecessors:b.successors).bind(b),P=p(b,A,E,O),F=f(b,A,P.root,P.align,H==="r");H==="r"&&(F=e.mapValues(F,function(G){return-G})),C[L+H]=F})});var M=g(b,C);return y(C,M),x(C,b.graph().align)}function _(b,k,E){return function(C,A,M){var L=C.node(A),H=C.node(M),O=0,P;if(O+=L.width/2,e.has(L,"labelpos"))switch(L.labelpos.toLowerCase()){case"l":P=-L.width/2;break;case"r":P=L.width/2;break}if(P&&(O+=E?P:-P),P=0,O+=(L.dummy?k:b)/2,O+=(H.dummy?k:b)/2,O+=H.width/2,e.has(H,"labelpos"))switch(H.labelpos.toLowerCase()){case"l":P=H.width/2;break;case"r":P=-H.width/2;break}return P&&(O+=E?P:-P),P=0,O}}function S(b,k){return b.node(k).width}return Gg}var Yg,fE;function G4(){if(fE)return Yg;fE=1;var e=it(),n=hn(),r=V4().positionX;Yg=i;function i(l){l=n.asNonCompoundGraph(l),o(l),e.forEach(r(l),function(u,c){l.node(c).x=u})}function o(l){var u=n.buildLayerMatrix(l),c=l.graph().ranksep,p=0;e.forEach(u,function(f){var h=e.max(e.map(f,function(g){return l.node(g).height}));e.forEach(f,function(g){l.node(g).y=p+h/2}),p+=h+c})}return Yg}var Kg,hE;function Y4(){if(hE)return Kg;hE=1;var e=it(),n=R4(),r=T4(),i=I4(),o=hn().normalizeRanks,l=M4(),u=hn().removeEmptyRanks,c=P4(),p=O4(),f=L4(),h=W4(),g=G4(),y=hn(),x=Jn().Graph;Kg=N;function N(U,J){var re=J&&J.debugTiming?y.time:y.notime;re("layout",function(){var le=re(" buildLayoutGraph",function(){return O(U)});re(" runLayout",function(){_(le,re)}),re(" updateInputGraph",function(){S(U,le)})})}function _(U,J){J(" makeSpaceForEdgeLabels",function(){P(U)}),J(" removeSelfEdges",function(){$(U)}),J(" acyclic",function(){n.run(U)}),J(" nestingGraph.run",function(){c.run(U)}),J(" rank",function(){i(y.asNonCompoundGraph(U))}),J(" injectEdgeLabelProxies",function(){F(U)}),J(" removeEmptyRanks",function(){u(U)}),J(" nestingGraph.cleanup",function(){c.cleanup(U)}),J(" normalizeRanks",function(){o(U)}),J(" assignRankMinMax",function(){G(U)}),J(" removeEdgeLabelProxies",function(){q(U)}),J(" normalize.run",function(){r.run(U)}),J(" parentDummyChains",function(){l(U)}),J(" addBorderSegments",function(){p(U)}),J(" order",function(){h(U)}),J(" insertSelfEdges",function(){X(U)}),J(" adjustCoordinateSystem",function(){f.adjust(U)}),J(" position",function(){g(U)}),J(" positionSelfEdges",function(){I(U)}),J(" removeBorderNodes",function(){Z(U)}),J(" normalize.undo",function(){r.undo(U)}),J(" fixupEdgeLabelCoords",function(){z(U)}),J(" undoCoordinateSystem",function(){f.undo(U)}),J(" translateGraph",function(){R(U)}),J(" assignNodeIntersects",function(){Q(U)}),J(" reversePoints",function(){ne(U)}),J(" acyclic.undo",function(){n.undo(U)})}function S(U,J){e.forEach(U.nodes(),function(re){var le=U.node(re),fe=J.node(re);le&&(le.x=fe.x,le.y=fe.y,J.children(re).length&&(le.width=fe.width,le.height=fe.height))}),e.forEach(U.edges(),function(re){var le=U.edge(re),fe=J.edge(re);le.points=fe.points,e.has(fe,"x")&&(le.x=fe.x,le.y=fe.y)}),U.graph().width=J.graph().width,U.graph().height=J.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],C=["width","height"],A={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],L={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},H=["labelpos"];function O(U){var J=new x({multigraph:!0,compound:!0}),re=Y(U.graph());return J.setGraph(e.merge({},k,W(re,b),e.pick(re,E))),e.forEach(U.nodes(),function(le){var fe=Y(U.node(le));J.setNode(le,e.defaults(W(fe,C),A)),J.setParent(le,U.parent(le))}),e.forEach(U.edges(),function(le){var fe=Y(U.edge(le));J.setEdge(le,e.merge({},L,W(fe,M),e.pick(fe,H)))}),J}function P(U){var J=U.graph();J.ranksep/=2,e.forEach(U.edges(),function(re){var le=U.edge(re);le.minlen*=2,le.labelpos.toLowerCase()!=="c"&&(J.rankdir==="TB"||J.rankdir==="BT"?le.width+=le.labeloffset:le.height+=le.labeloffset)})}function F(U){e.forEach(U.edges(),function(J){var re=U.edge(J);if(re.width&&re.height){var le=U.node(J.v),fe=U.node(J.w),te={rank:(fe.rank-le.rank)/2+le.rank,e:J};y.addDummyNode(U,"edge-proxy",te,"_ep")}})}function G(U){var J=0;e.forEach(U.nodes(),function(re){var le=U.node(re);le.borderTop&&(le.minRank=U.node(le.borderTop).rank,le.maxRank=U.node(le.borderBottom).rank,J=e.max(J,le.maxRank))}),U.graph().maxRank=J}function q(U){e.forEach(U.nodes(),function(J){var re=U.node(J);re.dummy==="edge-proxy"&&(U.edge(re.e).labelRank=re.rank,U.removeNode(J))})}function R(U){var J=Number.POSITIVE_INFINITY,re=0,le=Number.POSITIVE_INFINITY,fe=0,te=U.graph(),ce=te.marginx||0,Ce=te.marginy||0;function ve(Te){var ye=Te.x,ke=Te.y,Ge=Te.width,we=Te.height;J=Math.min(J,ye-Ge/2),re=Math.max(re,ye+Ge/2),le=Math.min(le,ke-we/2),fe=Math.max(fe,ke+we/2)}e.forEach(U.nodes(),function(Te){ve(U.node(Te))}),e.forEach(U.edges(),function(Te){var ye=U.edge(Te);e.has(ye,"x")&&ve(ye)}),J-=ce,le-=Ce,e.forEach(U.nodes(),function(Te){var ye=U.node(Te);ye.x-=J,ye.y-=le}),e.forEach(U.edges(),function(Te){var ye=U.edge(Te);e.forEach(ye.points,function(ke){ke.x-=J,ke.y-=le}),e.has(ye,"x")&&(ye.x-=J),e.has(ye,"y")&&(ye.y-=le)}),te.width=re-J+ce,te.height=fe-le+Ce}function Q(U){e.forEach(U.edges(),function(J){var re=U.edge(J),le=U.node(J.v),fe=U.node(J.w),te,ce;re.points?(te=re.points[0],ce=re.points[re.points.length-1]):(re.points=[],te=fe,ce=le),re.points.unshift(y.intersectRect(le,te)),re.points.push(y.intersectRect(fe,ce))})}function z(U){e.forEach(U.edges(),function(J){var re=U.edge(J);if(e.has(re,"x"))switch((re.labelpos==="l"||re.labelpos==="r")&&(re.width-=re.labeloffset),re.labelpos){case"l":re.x-=re.width/2+re.labeloffset;break;case"r":re.x+=re.width/2+re.labeloffset;break}})}function ne(U){e.forEach(U.edges(),function(J){var re=U.edge(J);re.reversed&&re.points.reverse()})}function Z(U){e.forEach(U.nodes(),function(J){if(U.children(J).length){var re=U.node(J),le=U.node(re.borderTop),fe=U.node(re.borderBottom),te=U.node(e.last(re.borderLeft)),ce=U.node(e.last(re.borderRight));re.width=Math.abs(ce.x-te.x),re.height=Math.abs(fe.y-le.y),re.x=te.x+re.width/2,re.y=le.y+re.height/2}}),e.forEach(U.nodes(),function(J){U.node(J).dummy==="border"&&U.removeNode(J)})}function $(U){e.forEach(U.edges(),function(J){if(J.v===J.w){var re=U.node(J.v);re.selfEdges||(re.selfEdges=[]),re.selfEdges.push({e:J,label:U.edge(J)}),U.removeEdge(J)}})}function X(U){var J=y.buildLayerMatrix(U);e.forEach(J,function(re){var le=0;e.forEach(re,function(fe,te){var ce=U.node(fe);ce.order=te+le,e.forEach(ce.selfEdges,function(Ce){y.addDummyNode(U,"selfedge",{width:Ce.label.width,height:Ce.label.height,rank:ce.rank,order:te+ ++le,e:Ce.e,label:Ce.label},"_se")}),delete ce.selfEdges})})}function I(U){e.forEach(U.nodes(),function(J){var re=U.node(J);if(re.dummy==="selfedge"){var le=U.node(re.e.v),fe=le.x+le.width/2,te=le.y,ce=re.x-fe,Ce=le.height/2;U.setEdge(re.e,re.label),U.removeNode(J),re.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}],re.label.x=re.x,re.label.y=re.y}})}function W(U,J){return e.mapValues(e.pick(U,J),Number)}function Y(U){var J={};return e.forEach(U,function(re,le){J[le.toLowerCase()]=re}),J}return Kg}var Xg,pE;function K4(){if(pE)return Xg;pE=1;var e=it(),n=hn(),r=Jn().Graph;Xg={debugOrdering:i};function i(o){var l=n.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(l,function(c,p){var f="layer"+p;u.setNode(f,{rank:"same"}),e.reduce(c,function(h,g){return u.setEdge(h,g,{style:"invis"}),g})}),u}return Xg}var Qg,mE;function X4(){return mE||(mE=1,Qg="0.8.5"),Qg}var Zg,gE;function Q4(){return gE||(gE=1,Zg={graphlib:Jn(),layout:Y4(),debug:K4(),util:{time:hn().time,notime:hn().notime},version:X4()}),Zg}var Z4=Q4();const vE=Cv(Z4),go=240,yu=130,uo=74,Hu=72,yE=uo+Hu;function J4(e,n){var i;let r=go;for(const o of e)r=Math.max(r,((i=n.get(o.id))==null?void 0:i.width)??go);return r}const gj=420,eD=2;function ja(e){var r;return((r=e.data)==null?void 0:r.sessionId)??"_default"}function tD(e,n){return((n==null?void 0:n.get(e))??0)>0?gj:0}function nD(e,n){const r=(n==null?void 0:n.get(e))??0;return r>0?6+r*36:0}function Ra(e,n,r){const i=n.get(e);return{w:((i==null?void 0:i.width)??go)+tD(e,r),h:Math.max((i==null?void 0:i.height)??yu,nD(e,r))}}function rD(e){return[...e.keys()].sort().map(n=>`${n}:${e.get(n)}`).join("|")}function sD(e,n,r,i,o,l){const u=new vE.graphlib.Graph;u.setDefaultEdgeLabel(()=>({})),u.setGraph({rankdir:r,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(b=>!o.has(b)),p=new Set(c);for(const b of c){const{w:k,h:E}=Ra(b,i,l);u.setNode(b,{width:k,height:E})}for(const b of n)p.has(b.source)&&p.has(b.target)&&u.setEdge(b.source,b.target);vE.layout(u);const f=new Map;let h=1/0,g=1/0,y=-1/0,x=-1/0;for(const b of c){const k=u.node(b);if(!k)continue;const E=i.get(b),C=(E==null?void 0:E.width)??go,A=(E==null?void 0:E.height)??yu,M=Ra(b,i,l),L=k.x-M.w/2,H=k.y-M.h/2;f.set(b,{x:L,y:H}),L<h&&(h=L),H<g&&(g=H),L+C>y&&(y=L+C),H+A>x&&(x=H+A)}if(Number.isFinite(h)&&Number.isFinite(g))for(const[b,k]of f)f.set(b,{x:k.x-h,y:k.y-g});const N=Number.isFinite(y)?y-h:0,_=Number.isFinite(x)?x-g:0;let S=null;for(const b of e){const k=o.get(b);if(!k)continue;const E=i.get(b),C=(E==null?void 0:E.width)??go,A=(E==null?void 0:E.height)??yu;S=S===null?{minX:k.x,minY:k.y,maxX:k.x+C,maxY:k.y+A}:{minX:Math.min(S.minX,k.x),minY:Math.min(S.minY,k.y),maxX:Math.max(S.maxX,k.x+C),maxY:Math.max(S.maxY,k.y+A)}}return{positions:f,width:N,height:_,pinnedBox:S}}function iD(e,n,r={}){const i=r.direction??"LR",o=r.pinned??new Map,l=r.measured??new Map,u=r.lanes,c=new Map;for(const b of e){const k=ja(b),E=c.get(k);E?E.push(b.id):c.set(k,[b.id])}const f=Array.from(c.keys()).sort().map(b=>({sid:b,...sD(c.get(b),n,i,l,o,u)})),h=J4(e,l),g=r.availableHeight&&r.availableHeight>0?r.availableHeight:Number.POSITIVE_INFINITY,y=b=>{const k=[[]];let E=0;for(const C of f)k.length<b&&E>0&&E+C.height>g&&(k.push([]),E=0),k[k.length-1].push(C),E+=C.height+yE;return k},x=b=>b.reduce((k,E)=>Math.max(k,E.width),0)+gj;let N=y(r.availableWidth?eD:1);N.length>1&&N.reduce((k,E)=>k+x(E),0)+h*(N.length-1)>(r.availableWidth??0)&&(N=y(1));const _=new Map;let S=0;for(const b of N){const k=x(b);let E=0;for(const{positions:C,height:A,pinnedBox:M}of b){for(const[H,O]of C)_.set(H,{x:O.x+S,y:O.y+E});let L=E+A;M&&M.maxY>L&&M.minX<S+k&&S<M.maxX&&(L=M.maxY),E=L+yE}S+=k+h}return e.map(b=>{const k=o.get(b.id);if(k)return{...b,position:k};const E=_.get(b.id);return E?{...b,position:E}:b})}function oD(e,n,r,i,o){const u=uo+Hu,c=60,p=x=>Ra(x,i,o),f=new Map(e.map(x=>[x.id,ja(x)])),h=[],g=e.map(x=>({id:x.id,pos:r.get(x.id)??n.get(x.id)})).filter(x=>x.pos!=null).sort((x,N)=>x.pos.y-N.pos.y||x.pos.x-N.pos.x||x.id.localeCompare(N.id)),y=[];for(const{id:x,pos:N}of g){const{w:_,h:S}=p(x),b=f.get(x)??"_default";if(r.has(x)){h.push({x:N.x,y:N.y,w:_,h:S,sid:b});continue}let k=N.y;for(let E=0;E<h.length+1;E++){const C=h.find(A=>{const M=A.sid===b?24:c,L=A.sid===b?24:u;return N.x<A.x+A.w+M&&A.x<N.x+_+M&&k<A.y+A.h+L&&A.y<k+S+L});if(!C)break;k=C.y+C.h+(C.sid===b?24:u)}k!==N.y&&(n.set(x,{x:N.x,y:k}),y.push(x)),h.push({x:N.x,y:k,w:_,h:S,sid:b})}return y}function aD(e,n,r,i,o,l){const u=_=>Ra(_,i,l),c=_=>r.get(_)??n.get(_),p=new Map;for(const _ of e){if(!c(_.id))continue;const S=ja(_),b=p.get(S);b?b.push(_):p.set(S,[_])}const f=new Set;for(const[_,S]of p)S.every(b=>o.has(b.id)&&!r.has(b.id))&&f.add(_);const h=new Map,g=[];for(const _ of e){const S=c(_.id);if(!S)continue;const{w:b,h:k}=u(_.id),E=ja(_);f.has(E)?(h.get(E)??h.set(E,[]).get(E)).push(_):g.push({x:S.x,y:S.y,w:b,h:k})}if(h.size===0)return[];const y=uo+Hu,x=(_,S,b,k)=>g.some(E=>_<E.x+E.w+uo&&E.x<_+b+uo&&S<E.y+E.h+y&&E.y<S+k+y),N=[];for(const _ of[...h.keys()].sort()){const S=h.get(_);let b=1/0,k=1/0,E=-1/0,C=-1/0;for(const F of S){const G=c(F.id),{w:q,h:R}=u(F.id);b=Math.min(b,G.x),k=Math.min(k,G.y),E=Math.max(E,G.x+q),C=Math.max(C,G.y+R)}const A=E-b,M=C-k,L=[...new Set(g.map(F=>Math.round(F.x)))].sort((F,G)=>F-G),H=L.length?L:[b],O=[0,...g.map(F=>F.y+F.h+y)].sort((F,G)=>F-G);let P=null;e:for(const F of H)for(const G of O){if(G>=k)break;if(!x(F,G,A,M)){P={x:F,y:G};break e}}if(P){const F=P.x-b,G=P.y-k;for(const q of S){const R=c(q.id);n.set(q.id,{x:R.x+F,y:R.y+G})}N.push(_)}for(const F of S){const G=c(F.id),{w:q,h:R}=u(F.id);g.push({x:G.x,y:G.y,w:q,h:R})}}return N}function lD(e,n,r,i,o,l=!1,u){const f=uo+Hu+1,h=8,g=1.75,y=200,x=.7,N=.01,_=P=>Ra(P,i,u),S=P=>r.get(P)??n.get(P),b=new Map;for(const P of e){if(!S(P.id))continue;const F=ja(P),G=b.get(F);G?G.push(P):b.set(F,[P])}const k=[],E=new Set,C=new Set,A=o.size===0;for(const P of[...b.keys()].sort()){const F=b.get(P);let G=1/0,q=1/0,R=-1/0,Q=-1/0,z=!1;for(const X of F){const I=S(X.id),{w:W,h:Y}=_(X.id);G=Math.min(G,I.x),q=Math.min(q,I.y),R=Math.max(R,I.x+W),Q=Math.max(Q,I.y+Y),r.has(X.id)&&(z=!0)}const ne=R-G,Z=Q-q;C.add(P);const $=o.get(P);$&&(ne>$.w+h||Z>$.h+h)&&E.add(P),o.set(P,{w:ne,h:Z}),k.push({sid:P,members:F.map(X=>X.id),x:G,y:q,w:ne,h:Z,anchored:z,mass:1})}for(const P of[...o.keys()])C.has(P)||o.delete(P);if(l||A)return[];let M=!1;for(let P=0;P<k.length&&!M;P++)for(let F=P+1;F<k.length;F++){const G=k[P],q=k[F];if(!(G.anchored&&q.anchored)&&Math.abs(G.x+G.w/2-(q.x+q.w/2))<(G.w+q.w)/2+61&&Math.abs(G.y+G.h/2-(q.y+q.h/2))<(G.h+q.h)/2+f){M=!0;break}}if(E.size===0&&!M)return[];if(E.size>0)for(const P of k)E.has(P.sid)&&(P.mass=8);else for(const P of k)P.mass=Math.max(1,P.w*P.h/(go*yu));const L=new Map(k.map(P=>[P.sid,P.x])),H=new Map(k.map(P=>[P.sid,P.y]));for(let P=0;P<y;P++){const F=new Map,G=new Map;let q=0;for(let R=0;R<k.length;R++)for(let Q=R+1;Q<k.length;Q++){const z=k[R],ne=k[Q];if(z.anchored&&ne.anchored)continue;const Z=z.x+z.w/2,$=z.y+z.h/2,X=ne.x+ne.w/2,I=ne.y+ne.h/2,W=(z.w+ne.w)/2+61-Math.abs(Z-X),Y=(z.h+ne.h)/2+f-Math.abs($-I);if(W<=0||Y<=0)continue;const U=(De,Ze)=>!De.anchored&&!(Ze<0&&De.x<=0),J=(De,Ze)=>!De.anchored&&!(Ze<0&&De.y<=0),re=(De,Ze,Ye)=>{const vt=De===Ze,ot=vt?z.sid<ne.sid?-1:1:Math.sign(De-Ze);return Ye(z,ot)||Ye(ne,-ot)?ot:vt&&(Ye(z,-ot)||Ye(ne,ot))?-ot:0},le=re(Z,X,U),fe=re($,I,J),te=le!==0,ce=fe!==0;if(!te&&!ce)continue;const Ce=te&&(!ce||W*g<Y),[ve,Te,ye,ke]=Ce?[le,W,F,U]:[fe,Y,G,J],Ge=ke(z,ve),we=ke(ne,-ve),_e=z.mass,ze=ne.mass,ft=Ge?we?ze/(_e+ze):1:0,ht=we?Ge?_e/(_e+ze):1:0,Ue=Te*x;ye.set(z.sid,(ye.get(z.sid)??0)+ve*Ue*ft),ye.set(ne.sid,(ye.get(ne.sid)??0)-ve*Ue*ht),q+=Ue}for(const R of k)R.anchored||(R.x=Math.max(0,R.x+(F.get(R.sid)??0)),R.y=Math.max(0,R.y+(G.get(R.sid)??0)));if(q<N)break}const O=[];for(const P of k){const F=P.x-L.get(P.sid),G=P.y-H.get(P.sid);if(!(Math.abs(F)<1&&Math.abs(G)<1)){for(const q of P.members){if(r.has(q))continue;const R=n.get(q);R&&n.set(q,{x:R.x+F,y:R.y+G})}O.push(P.sid)}}return O}const uD=600;function Sv(e,n){return!(e.exitAt!=null&&n-e.exitAt>uD||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function cD(e,n){const r=new Set;for(const i of e.agents.values())Sv(i,n)&&r.add(i.id);return r}function dD(e,n,r=0){return e.right+r>n.left&&e.left-r<n.right&&e.bottom+r>n.top&&e.top-r<n.bottom}function fD(e,n,r=0){if(!e)return!1;for(const i of n)if(dD(e,i,r))return!0;return!1}const vj="sessionGroup";function hD(e,n){var i;if(e.type===vj)return"transparent";const r=(i=e.data)==null?void 0:i.state;return n(r==="err"?"--err":r==="active"?"--inflight":"--ok")}const pD="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1).";function mD(e){if(e.checkDisabled)return pD;if(e.checking)return"Asking npm for the newest release…";const n=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`${n}${r} · re-checked periodically · click to check npm now`}function gD(e){const n=`Version v${e.running}`;return e.checkDisabled?`${n}, update checks are off`:e.checking?`${n}, checking npm for a newer release`:`${n}, check npm for a newer release`}function vD(e){if(e==null)return{kind:"unknown",lead:"No data yet. Start a Claude Code or Codex session — it appears here as soon as its first hook fires.",workspace:null,tail:""};const n=e.trim();return n===""?{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:n,tail:" — start one there, or restart it without --workspace/--scope to watch the whole machine."}}function yj(e){const n=Math.max(0,Math.floor(e));return`${n} event${n===1?"":"s"}`}function yD(e){return e.connected?e.paused?{tone:"paused",label:"paused",title:e.held>0?`Connected — ${yj(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 wD(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:`${yj(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 wj(e,n){return e!==""&&n>0}function xD(e,n,r){return e===""?{active:!1,matched:n,total:r,count:null,empty:!1,message:null,dim:!1}:{active:!0,matched:n,total:r,count:`${n} of ${r}`,empty:n===0,message:n===0?`No agents match “${e}”`:null,dim:wj(e,n)}}function kv(e){const n=Math.max(0,Math.floor(e/1e3));return n<60?"just now":n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:`${Math.floor(n/86400)}d ago`}function _D(e,n){return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function bD(e,n,r){const i=new Date(e),o=kv(n-e);return{label:_D(i,new Date(n))?o:`${o} · ${i.toLocaleDateString(r,{month:"short",day:"numeric"})}`,title:i.toLocaleString(r,{dateStyle:"medium",timeStyle:"medium"})}}function pa(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const SD={agent:_O,sessionGroup:OO},kD=420,eu=18,ED=9e4,ND=200,CD=5*6e4,jD=6,RD=2*6e4,fy="agent-dag.layout",hy="agent-dag.viewport",xj="agent-dag.summariesDismissed",_j="agent-dag.sessionListOpen",bj="agent-dag.detailOpen",Sj="agent-dag.usagePanelOpen",wE="agent-dag.accountsPanelOpen",xE="agent-dag.versionNoticeDismissed",_E="agent-dag.oldNameNoticeDismissed",TD=15*6e4,bE={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:"},SE="agent-dag.autoRestart",kE="agent-dag.bundleReloadedFor";function AD(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(_j)==="1"}catch{return!1}}function ID(e){if(!(typeof window>"u"))try{window.localStorage.setItem(_j,e?"1":"0")}catch{}}function MD(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(bj)==="1"}catch{return!1}}function PD(e){if(!(typeof window>"u"))try{window.localStorage.setItem(bj,e?"1":"0")}catch{}}function OD(){const e=mC(Sj);return e===null?!0:e==="1"}function LD(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Sj,e?"1":"0")}catch{}}function qD(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(xj);if(!e)return new Set;const n=JSON.parse(e);return new Set(Array.isArray(n)?n.filter(r=>typeof r=="string"):[])}catch{return new Set}}function EE(e){if(!(typeof window>"u"))try{const n=Array.from(e),r=n.length>200?n.slice(-200):n;window.localStorage.setItem(xj,JSON.stringify(r))}catch{}}function $D(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(fy);if(!n)return e;const r=JSON.parse(n);if(!("v"in r)){const o=Object.entries(r).filter(([,l])=>l&&typeof l.x=="number"&&typeof l.y=="number");return{positions:o,pins:o.map(([l])=>l)}}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 Jg(e,n){if(!(typeof window>"u"))try{const r={};for(const[i,o]of e)r[i]=o;for(const[i,o]of n)r[i]=o;window.localStorage.setItem(fy,JSON.stringify({v:2,positions:r,pins:Array.from(n.keys())}))}catch{}}function DD(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(hy);if(!e)return null;const n=JSON.parse(e);return typeof(n==null?void 0:n.x)!="number"||typeof(n==null?void 0:n.y)!="number"||typeof(n==null?void 0:n.zoom)!="number"?null:n}catch{return null}}function FD(e){if(!(typeof window>"u"))try{window.localStorage.setItem(hy,JSON.stringify(e))}catch{}}function NE(){if(!(typeof window>"u")){try{window.localStorage.removeItem(fy)}catch{}try{window.localStorage.removeItem(hy)}catch{}}}function zD(e,n){const r=e.agents.get(n);if(!r)return;const i=[];for(const h of e.agents.values())h.sessionId===n&&i.push(h);const o={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:n,label:r.label,cwd:r.cwd,startedAt:r.startedAt,endedAt:r.endedAt,model:r.model,agents:i.map(h=>({id:h.id,kind:h.kind,label:h.label,parentId:h.parentId,state:h.state,startedAt:h.startedAt,endedAt:h.endedAt,model:h.model,cwd:h.cwd,usage:h.usage,prompts:h.prompts,tools:h.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}))}))},l=JSON.stringify(o,null,2),u=new Blob([l],{type:"application/json"}),c=URL.createObjectURL(u),p=document.createElement("a"),f=(r.label||"session").replace(/[^a-z0-9._-]/gi,"_");p.href=c,p.download=`${zt}-${f}-${n.slice(0,8)}.json`,document.body.appendChild(p),p.click(),document.body.removeChild(p),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const Ev={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Nv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},BD={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",shell:"shell",exec_command:"shell",shell_command:"shell",write_stdin:"shell",wait:"shell",apply_patch:"file",update_plan:"task",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"};function kj(e){return e.startsWith("mcp__")?"mcp":BD[e]??"other"}function Ej(e,n){var i,o,l;if(!n)return!0;const r=n.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)||(l=e.firstPrompt)!=null&&l.toLowerCase().includes(r))return!0;for(const u of e.tools)if(u.name.toLowerCase().includes(r))return!0;return!1}function UD(e,n){if(!n)return null;const r=new Set([n]);let i=n;for(;i;){const l=e.agents.get(i);if(!(l!=null&&l.parentId)||r.has(l.parentId))break;r.add(l.parentId),i=l.parentId}let o=!0;for(;o;){o=!1;for(const l of e.agents.values())l.parentId&&r.has(l.parentId)&&!r.has(l.id)&&(r.add(l.id),o=!0)}return r}function HD(e,n,r,i,o,l,u,c,p,f,h,g,y,x,N,_,S,b,k){const E=[],C=[],A=new Set;if(l)for(const q of e.agents.values())b.has(q.id)&&Ej(q,l)&&A.add(q.id);const M=wj(l,A.size);for(const q of e.agents.values()){if(!b.has(q.id))continue;const R=M&&!A.has(q.id),Q=q.exitAt!=null,z=S!=null&&!S.has(q.id),ne=[R?"rf-dim":"",Q?"rf-exiting":"",z?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,Z=u.get(q.id);if(E.push({id:q.id,type:"agent",position:{x:0,y:0},data:{...q,now:n,onOpenContext:k},className:ne,...Z?{width:Z.width,height:Z.height}:null}),q.parentId&&b.has(q.parentId)){const $=Vv(q.sessionId),X=l&&!A.has(q.id)&&!A.has(q.parentId),I=Q,W=_.size>0&&(_.has(q.id)||_.has(q.parentId)),Y=S!=null&&!S.has(q.id)&&!S.has(q.parentId),U=q.state==="active"?2:1.5,J=W?U+1.5:U,re=X||I?.2:Y?.12:1,le=["sess-edge",q.state==="active"?"sess-live":"sess-idle",I?"rf-edge-exiting":"",W?"rf-edge-selected":""].filter(Boolean).join(" ");C.push({id:`e:${q.parentId}->${q.id}`,source:q.parentId,target:q.id,animated:(q.state==="active"||W)&&!X&&!I,type:"smoothstep",style:{"--session-hue":$,strokeWidth:J,opacity:re,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:le})}}const L=new Map;for(const q of e.agents.values())q.tools.length>0&&L.set(q.id,Math.min(4,q.tools.length));const H=`${x}#lanes:${rD(L)}`,O=E.filter(q=>vL(q.id,o,g,y));if(O.length>0||H!==N.current){if(O.length>0){const q=iD(E,C,{direction:"LR",pinned:o,measured:u,availableWidth:r,availableHeight:i,lanes:L});for(const R of q)pC(R.id,g,y)&&wL(R.id,R.position,g,y);aD(E,g,o,u,new Set(O.map(R=>R.id)),L)}oD(E,g,o,u,L),N.current=H}const P=lD(E,g,o,u,c,!f||h,L);P.length>0&&p(P),Xl(g,e.agents),Xl(y,e.agents),Xl(o,e.agents),Xl(u,gL(e.agents.values()));const F=[];let G=!1;for(const q of E){let R=o.get(q.id)??g.get(q.id);R||(R=yL(q.id,g,y),G=!0),F.push({...q,position:R})}return G&&(N.current=""),{nodes:F,edges:C}}function WD(){return m.jsx(Hv,{children:m.jsx(VD,{})})}function VD(){var Fs,Po,za,Ba;const e=Pa(),n=T.useRef(gv()),[,r]=T.useState(0),i=T.useCallback(()=>r(B=>B+1),[]),[o,l]=T.useState(()=>new Set),[u,c]=T.useState(null),[p,f]=T.useState(null),h=T.useCallback((B,V)=>{l(ae=>{if(!V)return new Set([B]);const de=new Set(ae);return de.has(B)?de.delete(B):de.add(B),de}),c(ae=>V&&ae===B?ae:B)},[]),g=T.useCallback(()=>{l(new Set),c(null)},[]),[y,x]=T.useState(null),[N,_]=T.useState(null),S=T.useCallback(B=>_(B),[]),[b,k]=T.useState(!1),E=T.useRef(qD()),[C,A]=T.useState(AD);T.useEffect(()=>{ID(C)},[C]);const[M,L]=T.useState(MD);T.useEffect(()=>{PD(M)},[M]);const[H,O]=T.useState(OD);T.useEffect(()=>{LD(H)},[H]);const[P,F]=T.useState(()=>{try{const B=window.localStorage.getItem(wE);return B===null?!0:B==="1"}catch{return!0}});T.useEffect(()=>{try{window.localStorage.setItem(wE,P?"1":"0")}catch{}},[P]);const[G,q]=T.useState(null),[R,Q]=T.useState(!1),[z,ne]=T.useState(0),[Z,$]=T.useState(0);T.useEffect(()=>{fetch("/api/sound-hook").then(B=>B.ok?B.json():null).then(B=>{B!=null&&B.ok&&(q(B.enabled===!0),ne((B.foreign??[]).filter(V=>V.worksHere).length),$(typeof B.parked=="number"?B.parked:0))}).catch(()=>{})},[]);const X=T.useCallback(async()=>{Q(!0);try{const V=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!G})})).json().catch(()=>null);V!=null&&V.ok&&q(V.enabled===!0),fetch("/api/sound-hook").then(ae=>ae.ok?ae.json():null).then(ae=>{ae!=null&&ae.ok&&(ne((ae.foreign??[]).filter(de=>de.worksHere).length),$(typeof ae.parked=="number"?ae.parked:0))}).catch(()=>{})}catch{}finally{Q(!1)}},[G]),[I,W]=T.useState(!1),[Y,U]=T.useState(null),[J,re]=T.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(xE)??""}catch{return""}}),[le,fe]=T.useState(!1),te=T.useRef(0),[ce,Ce]=T.useState(!1),ve=T.useCallback((B=!1)=>{B&&(te.current=Date.now(),Ce(!0)),fetch(B?"/api/version?refresh=1":"/api/version").then(V=>V.ok?V.json():null).then(V=>{V&&U(V)}).catch(()=>{}).finally(()=>{B&&Ce(!1)})},[]),Te=T.useCallback(()=>{ve(Date.now()-te.current>=TD)},[ve]);T.useEffect(()=>{ve();const B=window.setInterval(Te,5*6e4),V=()=>{document.visibilityState==="visible"&&Te()};return document.addEventListener("visibilitychange",V),()=>{window.clearInterval(B),document.removeEventListener("visibilitychange",V)}},[ve,Te]),T.useEffect(()=>{I&&ve()},[I,ve]);const ye=(Y==null?void 0:Y.notice)??null,[ke,Ge]=T.useState(null);T.useEffect(()=>{let B=!1;return fetch("/api/health").then(V=>V.ok?V.json():null).then(V=>{B||!V||typeof V.workspace!="string"||Ge(V.workspace)}).catch(()=>{}),()=>{B=!0}},[I]);const we=ye?`${ye.kind}:${ye.to}`:"",_e=ye!=null&&J!==we,ze=T.useCallback(()=>{if(!ye)return;const B=J===we?"":we;re(B);try{window.localStorage.setItem(xE,B)}catch{}},[ye,we,J]),[ft,ht]=T.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(_E)??""}catch{return""}}),Ue=Y!=null&&Y.invokedAs&&Y.invokedAs!==zt?Y.invokedAs:null,De=Ue!=null&&ft!==Ue,Ze=T.useCallback(()=>{if(Ue){ht(Ue);try{window.localStorage.setItem(_E,Ue)}catch{}}},[Ue]),Ye=((Fs=Y==null?void 0:Y.upgrade)==null?void 0:Fs.state)??"idle",vt=oL(Y==null?void 0:Y.upgrade),ot=T.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}ve()},[ve]);T.useEffect(()=>{if(Ye!=="running")return;const B=window.setInterval(ve,3e3);return()=>window.clearInterval(B)},[Ye,ve]);const yt=T.useCallback(async()=>{var ae;const B=Y==null?void 0:Y.command;if(!B)return;let V=!1;try{V=await Promise.race([((ae=navigator.clipboard)==null?void 0:ae.writeText(B).then(()=>!0))??Promise.resolve(!1),new Promise(de=>window.setTimeout(()=>de(!1),500))])}catch{V=!1}if(!V)try{const de=document.createElement("textarea");de.value=B,de.setAttribute("readonly",""),de.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(de),de.select(),V=document.execCommand("copy"),de.remove()}catch{V=!1}V&&(fe(!0),window.setTimeout(()=>fe(!1),1600))},[Y==null?void 0:Y.command]),Kt=T.useCallback(()=>{A(B=>(B||F(!1),!B))},[]),Mt=T.useCallback(()=>{F(B=>(B||A(!1),!B))},[]),[Xe,wt]=T.useState(!1),[pt,mt]=T.useState(0),_n=T.useRef(null),[Xt,Pt]=T.useState(!1),Qt=T.useRef(null),[yr,bn]=T.useState(0),Zt=T.useRef(SL()),[pn,Sn]=T.useState(!1),Gr=T.useCallback(()=>{const B=Zt.current,V=B.setPaused(!B.paused);for(const ae of V)n.current=Cx(n.current,ae);Sn(B.paused)},[]),[ut,hi]=T.useState(Date.now()),[nr,Es]=T.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(SE)!=="0"}catch{return!0}}),pi=T.useCallback(()=>{Es(B=>{const V=!B;try{window.localStorage.setItem(SE,V?"1":"0")}catch{}return V})},[]),[Jt,rr]=T.useState(!1),[wr,So]=T.useState("restart"),[sr,xr]=T.useState(null),mn=T.useRef(!1),Yr=T.useRef(null),mi=T.useRef(0),Kr=T.useCallback(async B=>{if(mn.current)return;const V=(B==null?void 0:B.upgrade)===!0;mn.current=!0,Yr.current=vt;const ae=++mi.current;So(V?"npx":"restart"),rr(!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:V})})}catch{}window.setTimeout(()=>{if(mi.current===ae&&mn.current){mn.current=!1,rr(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},V?18e4:3e4)},[ye==null?void 0:ye.to,vt]),Ns=T.useRef(null);T.useEffect(()=>{let B=!1;for(const ae of n.current.agents.values())if(ae.state==="active"){B=!0;break}const V=lL({enabled:nr,kind:ye==null?void 0:ye.kind,canRestart:(Y==null?void 0:Y.canRestart)===!0,busy:B,idleSince:Ns.current,now:ut});Ns.current=V.idleSince,V.restart&&Kr()},[nr,ye==null?void 0:ye.kind,Y==null?void 0:Y.canRestart,ut,Kr]),T.useEffect(()=>{const B=Y==null?void 0:Y.running;let V=null,ae=null;try{V=window.sessionStorage.getItem("agent-dag.restartPending"),ae=window.sessionStorage.getItem(kE)}catch{return}const de=iL({bundle:"1.33.142",running:B,pending:V,lastTried:ae});if(de==="reload"){try{window.sessionStorage.setItem(kE,B??"")}catch{return}window.location.reload();return}if(de!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}mn.current=!1,rr(!1),xr(B??null);const xe=window.setTimeout(()=>xr(null),6e3);return()=>window.clearTimeout(xe)},[Y==null?void 0:Y.running]),T.useEffect(()=>{if(Jt&&aL({asked:Yr.current,reported:vt})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}mn.current=!1,rr(!1)}},[Jt,vt]);const gn=T.useRef($D()).current;T.useRef(!1);const jt=T.useRef(new Map(gn.positions.filter(([B])=>gn.pins.includes(B)))),_r=T.useRef(null),Xr=T.useState(()=>DD())[0],[en,Qr]=T.useState(""),[Cs,gi]=T.useState(()=>new Set),[ir,vi]=T.useState(jL),[Je,ko]=T.useState(!1),br=T.useRef(null);T.useEffect(()=>{document.documentElement.dataset.theme=ir;try{window.localStorage.setItem(gC,ir)}catch{}},[ir]),T.useEffect(()=>{if(!Xr)return;const B=window.setTimeout(()=>{try{e.setViewport(Xr,{duration:0})}catch{}},60);return()=>window.clearTimeout(B)},[e,Xr]);const js=T.useRef(!0);T.useEffect(()=>{const B=new EventSource("/events"),V=bL(i,{now:()=>Date.now(),setTimeout:(ae,de)=>window.setTimeout(ae,de),clearTimeout:ae=>window.clearTimeout(ae)});return B.addEventListener("open",()=>{W(!0),ko(!0)}),B.addEventListener("error",()=>W(!1)),B.addEventListener("replay-end",()=>{js.current=!1,V.flush()}),B.addEventListener("hook",ae=>{try{const de=JSON.parse(ae.data);if(!Zt.current.accept(de))return;n.current=Cx(n.current,de),de.replay===!0||js.current||Date.now()-de.receivedAt>3e4?V.replay():V.live()}catch{}}),()=>{B.close(),V.cancel()}},[i]),T.useEffect(()=>{const B=setInterval(()=>{const V=Date.now();hi(V);let ae=eO(n.current,V,ED);ZP(n.current,V,ND,CD)&&(ae=!0),JP(n.current,V,jD,RD)&&(ae=!0),ae&&i()},250);return()=>clearInterval(B)},[i]);const or=T.useRef(null),$n=T.useRef(0),yi=420,Ot=T.useCallback((B=500)=>{try{const Ne=document.querySelector(".canvas-wrap"),Ie=Array.from(document.querySelectorAll(".react-flow__node")).filter(xt=>xt.offsetWidth>0);if(!Ne||Ie.length===0)return;const Le=Ne.getBoundingClientRect(),Ve=e.getViewport();if(!Number.isFinite(Ve.zoom)||Ve.zoom<=0)return;const Qe=xt=>(xt-Le.left-Ve.x)/Ve.zoom,rt=xt=>(xt-Le.top-Ve.y)/Ve.zoom,Nn=Ie.map(xt=>xt.getBoundingClientRect()),Ar=Math.min(...Nn.map(xt=>Qe(xt.left))),Oo=Math.max(...Nn.map(xt=>Qe(xt.right))),zs=Math.min(...Nn.map(xt=>rt(xt.top))),Lo=Math.max(...Nn.map(xt=>rt(xt.bottom))),qo=Oo-Ar,Ti=Lo-zs;if(!(qo>0&&Ti>0))return;const Bn=Math.max(.2,Math.min(1,(Le.width-160)/(qo+yi)*.86,(Le.height-160)/Ti*.86));e.setViewport({x:80-Ar*Bn,y:Math.max(80,(Le.height-Ti*Bn)/2)-zs*Bn,zoom:Bn},{duration:B}),$n.current=Date.now(),window.setTimeout(()=>{try{const xt={x:80-Ar*Bn,y:Math.max(80,(Le.height-Ti*Bn)/2)-zs*Bn,zoom:Bn},Ua=e.getViewport();(Math.abs(Ua.zoom-Bn)>.01||Math.abs(Ua.x-xt.x)>2)&&e.setViewport(xt,{duration:0})}catch{}},B+60)}catch{}},[e]),Ut=T.useRef(""),Sr=T.useRef(null),rn=T.useRef(0),wi=T.useCallback(()=>{rn.current=Date.now()},[]),Eo="agent-dag.autoFitDisabled",kr=T.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Eo)==="1"}catch{return!1}})()),[Rs,Ts]=T.useState(kr.current),Zr=T.useCallback(()=>{if(!kr.current){kr.current=!0,Ts(!0);try{window.localStorage.setItem(Eo,"1")}catch{}}},[]),xi=T.useCallback(()=>{kr.current=!1,Ts(!1);try{window.localStorage.removeItem(Eo)}catch{}Ot(400)},[e,Ot]);T.useEffect(()=>{const B=setInterval(()=>{if(kr.current||Date.now()-rn.current<800)return;const V=n.current,ae=Date.now(),de=[];for(const Qe of V.agents.values())Sv(Qe,ae)&&de.push({id:Qe.id});if(de.length===0)return;const xe=e.getViewport(),Ne=window.innerWidth-360,Ie=window.innerHeight-52;let Le=!1,Ve=!1;for(const{id:Qe}of de){const rt=Jr.current.get(Qe),Nn=jt.current.get(Qe)??Ht.current.get(Qe);if(!rt||!Nn)continue;Ve=!0;const Ar=Nn.x*xe.zoom+xe.x,Oo=Nn.y*xe.zoom+xe.y,zs=(Nn.x+rt.width)*xe.zoom+xe.x,Lo=(Nn.y+rt.height)*xe.zoom+xe.y;if(zs>0&&Ar<Ne&&Lo>0&&Oo<Ie){Le=!0;break}}Ve&&!Le&&Ot(600)},1500);return()=>clearInterval(B)},[e]);const No=T.useRef(!1),Jr=T.useRef(new Map),_i=T.useRef(0),Fa=T.useCallback(B=>{const V=Jr.current;let ae=!1;for(const de of B.nodeInternals.values()){const xe=de.width,Ne=de.height;if(xe==null||Ne==null)continue;const Ie=V.get(de.id);Ie?(Math.abs(Ie.height-Ne)>4||Math.abs(Ie.width-xe)>4)&&(V.set(de.id,{width:xe,height:Ne}),ae=!0):(V.set(de.id,{width:xe,height:Ne}),ae=!0)}return ae&&(_i.current+=1),_i.current},[]),bi=Ke(Fa),[es,Wu]=T.useState(0);T.useEffect(()=>{let B=0;const V=()=>{const de=Jr.current;let xe=!1;for(const Ne of document.querySelectorAll(".react-flow__node[data-id]")){const Ie=Ne.getAttribute("data-id");if(!Ie)continue;const Le=Ne.offsetWidth,Ve=Ne.offsetHeight;if(!Le||!Ve)continue;const Qe=de.get(Ie);(!Qe||Math.abs(Qe.width-Le)>4||Math.abs(Qe.height-Ve)>4)&&(de.set(Ie,{width:Le,height:Ve}),xe=!0)}xe&&Wu(Ne=>Ne+1)};if(No.current)return;let ae=0;return document.visibilityState==="hidden"?ae=window.setTimeout(V,32):B=requestAnimationFrame(V),()=>{cancelAnimationFrame(B),window.clearTimeout(ae)}});const Ht=T.useRef(new Map(gn.positions)),We=T.useRef(new Set),Si=T.useRef(""),Er=T.useMemo(()=>{const B=[];for(const V of n.current.agents.values())Sv(V,ut)&&B.push(V.id+(V.parentId?`>${V.parentId}`:""));return B.sort(),`${B.join("|")}#sv${bi}.${es}`},[n.current,n.current.lastSeq,ut,bi,es]),Nr=T.useRef(null);T.useEffect(()=>(Nr.current!=null&&window.clearTimeout(Nr.current),Nr.current=window.setTimeout(()=>{Jg(Ht.current,jt.current)},1500),()=>{Nr.current!=null&&window.clearTimeout(Nr.current)}),[Er]),T.useEffect(()=>{if(Ut.current===Er)return;const B=Ut.current;if(Ut.current=Er,!B||kr.current)return;Date.now()-$n.current>1200&&Ot(400),or.current&&window.clearTimeout(or.current),or.current=window.setTimeout(()=>{kr.current||Ot(500)},280)},[Er,e,Ot]);const ki=T.useMemo(()=>{if(o.size===0)return null;const B=new Set;for(const V of o){const ae=UD(n.current,V);if(ae)for(const de of ae)B.add(de)}return B.size>0?B:null},[n.current,n.current.lastSeq,o]),ar=T.useMemo(()=>cD(n.current,ut),[n.current,n.current.lastSeq,ut]),Co=T.useRef(null),[ts,As]=T.useState({w:0,h:0});T.useEffect(()=>{const B=Co.current;if(!B||typeof ResizeObserver>"u")return;const V=new ResizeObserver(ae=>{var xe;const de=(xe=ae[0])==null?void 0:xe.contentRect;de&&As(Ne=>Math.abs(Ne.w-de.width)>40||Math.abs(Ne.h-de.height)>40?{w:de.width,h:de.height}:Ne)});return V.observe(B),As({w:B.clientWidth,h:B.clientHeight}),()=>V.disconnect()},[]);const lr=T.useRef(new Map),[Dn,ur]=T.useState(!1);T.useEffect(()=>{const B=window.setTimeout(()=>ur(!0),2500);return()=>window.clearTimeout(B)},[]);const[Is,Cr]=T.useState(!1),Lt=T.useRef(null),[jo,Ro]=T.useState(!1),Ms=T.useCallback(()=>{Lt.current&&(window.clearTimeout(Lt.current),Lt.current=null),Cr(!1)},[]),Vu=T.useCallback(B=>{B.length!==0&&queueMicrotask(()=>{Cr(!0),Lt.current&&window.clearTimeout(Lt.current),Lt.current=window.setTimeout(()=>Cr(!1),kD+80)})},[]);T.useEffect(()=>()=>{Lt.current&&window.clearTimeout(Lt.current)},[]);const To=ts.w>0?ts.w*.92:0,Ps=ts.h>0?ts.h:0,{nodes:Fn,edges:Gu}=T.useMemo(()=>HD(n.current,ut,To,Ps,jt.current,en,Jr.current,lr.current,Vu,Dn,jo,Ht.current,We.current,Er,Si,o,ki,ar,S),[n.current,n.current.lastSeq,ut,To,Ps,Dn,jo,en,Er,o,ki,ar,S,pt]),ns=T.useMemo(()=>{const B=new Map;for(const ae of Fn){const de=ae.data;if(!(de!=null&&de.sessionId)||de.exitAt!=null)continue;const xe=ae.width,Ne=ae.height;if(xe==null||Ne==null)continue;const Ie=ae.position.x,Le=ae.position.y,Ve=Ie+xe,Qe=Le+Ne,rt=B.get(de.sessionId);rt?(rt.minX=Math.min(rt.minX,Ie),rt.minY=Math.min(rt.minY,Le),rt.maxX=Math.max(rt.maxX,Ve),rt.maxY=Math.max(rt.maxY,Qe)):B.set(de.sessionId,{minX:Ie,minY:Le,maxX:Ve,maxY:Qe})}const V=[];for(const[ae,de]of B){const xe=de.maxX-de.minX+eu*2,Ne=de.maxY-de.minY+eu*2;V.push({id:`group:${ae}`,type:vj,position:{x:de.minX-eu,y:de.minY-eu},data:{sessionId:ae,w:xe,h:Ne},width:xe,height:Ne,style:{width:xe,height:Ne},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return V},[Fn,ut]),Os=T.useMemo(()=>{const B=[...ns,...Fn],V=Qt.current;return!V||V.size===0?B:B.map(ae=>{const de=V.get(ae.id);return de?{...ae,position:de}:ae})},[ns,Fn,yr]),kn=T.useMemo(()=>{if(!en)return null;const B=new Set;for(const V of n.current.agents.values())ar.has(V.id)&&Ej(V,en)&&B.add(V.id);return B},[n.current,n.current.lastSeq,en,ar]),En=T.useMemo(()=>xD(en,(kn==null?void 0:kn.size)??0,ar.size),[en,kn,ar]),Ei=T.useMemo(()=>{const B=new Set;for(const V of n.current.agents.values())for(const ae of V.tools)B.add(kj(ae.name));return Object.keys(Ev).filter(V=>B.has(V))},[n.current,n.current.lastSeq]);T.useEffect(()=>{if(Ei.length<=1){Pt(!1);return}let B=0;const V=()=>{const ae=_n.current;if(ae&&!document.hidden){const de=ae.getBoundingClientRect(),xe=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Ie=>Ie.getBoundingClientRect()),Ne=fD(de,xe,8);Pt(Ie=>Ie===Ne?Ie:Ne)}B=window.setTimeout(V,300)};return V(),()=>window.clearTimeout(B)},[Ei.length]);const Ls=T.useMemo(()=>{const B=new Map;for(const ae of n.current.agents.values())for(const de of ae.tools){if(!de.name.startsWith("mcp__"))continue;const xe=de.name.slice(5),Ne=xe.indexOf("__"),Ie=Ne>0?xe.slice(0,Ne):xe;B.set(Ie,(B.get(Ie)??0)+1)}const V=[];for(const[ae,de]of B){let xe=5381;for(let Ne=0;Ne<ae.length;Ne++)xe=(xe<<5)+xe^ae.charCodeAt(Ne);V.push({server:ae,count:de,hue:Math.abs(xe)%360})}return V.sort((ae,de)=>de.count-ae.count),V},[n.current,n.current.lastSeq]),Ao=T.useCallback(B=>{gi(V=>{const ae=new Set(V);return ae.has(B)?ae.delete(B):ae.add(B),ae})},[]),St=u?n.current.agents.get(u):null,qs=p?Array.from(n.current.agents.values()).flatMap(B=>B.tools).find(B=>B.id===p)??null:null,Io=T.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=gv(),jt.current.clear(),Jr.current.clear(),Ht.current.clear(),Si.current="",NE(),g(),i()},[i,g]),zn=T.useRef(b);zn.current=b;const Ni=T.useRef(!1);Ni.current=qs!=null||Xe||N!=null||y!=null;const jr=T.useCallback(B=>{const V=mL(B,{confirmOpen:zn.current,modalOpen:Ni.current});V==="confirm"?k(!0):V==="clear"&&(k(!1),Io())},[Io]),Ci=T.useCallback(()=>{jt.current.clear(),Ht.current.clear(),Si.current="",NE(),i(),window.setTimeout(()=>Ot(500),80)},[i,e,Ot]),$s=T.useCallback(()=>Ot(500),[Ot]),rs=T.useRef(Fn);rs.current=Fn;const Mo=T.useRef(u);Mo.current=u;const qt=T.useCallback(B=>{const V=rs.current;if(V.length===0)return;const ae=V.slice().sort((Le,Ve)=>Le.position.y-Ve.position.y||Le.position.x-Ve.position.x),de=Mo.current,xe=de?ae.findIndex(Le=>Le.id===de):-1;let Ne;xe===-1?Ne=B===1?0:ae.length-1:Ne=(xe+B+ae.length)%ae.length;const Ie=ae[Ne];Ie&&(h(Ie.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[Ie]})}catch{}$n.current=Date.now()},30))},[h,e]),Rr=T.useCallback(B=>{h(B,!1),window.setTimeout(()=>{try{const V=rs.current.find(ae=>ae.id===B);V&&e.fitView({padding:.3,duration:500,nodes:[V]}),$n.current=Date.now()}catch{}},60)},[h,e]);T.useEffect(()=>{const B=V=>{var xe,Ne;const ae=V.target,de={tagName:ae==null?void 0:ae.tagName,isContentEditable:ae==null?void 0:ae.isContentEditable,role:(xe=ae==null?void 0:ae.getAttribute)==null?void 0:xe.call(ae,"role"),type:ae==null?void 0:ae.type};if(V.key==="Escape"){const Ie=hO({overlayOpen:yv.depth()>0,typing:hC(de)});Ie==="dismiss"?yv.dismissTop():Ie==="blur"?ae==null||ae.blur():g();return}if(!hL(de)&&!uL(V)){if(V.key==="/"){V.preventDefault(),(Ne=br.current)==null||Ne.focus();return}V.key===" "&&(V.preventDefault(),Gr()),(V.key==="c"||V.key==="C")&&jr("shortcut"),(V.key==="r"||V.key==="R")&&Ci(),(V.key==="f"||V.key==="F")&&$s(),(V.key==="l"||V.key==="L")&&Kt(),(V.key==="h"||V.key==="H")&&wt(Ie=>!Ie),(V.key==="u"||V.key==="U")&&O(Ie=>!Ie),(V.key==="a"||V.key==="A")&&Mt(),(V.key==="j"||V.key==="J")&&qt(1),(V.key==="k"||V.key==="K")&&qt(-1),(V.key==="t"||V.key==="T")&&vi(Ie=>Ie==="dark"?"light":"dark")}};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[jr,Ci,$s,g,qt,Gr]);const Tr=n.current.agents.size,Ds=new Set(Array.from(n.current.agents.values()).map(B=>B.sessionId)).size,cr=T.useMemo(()=>{var V;const B=[];for(const ae of n.current.agents.values())ae.kind==="root"&&((V=ae.waiting)==null?void 0:V.kind)==="permission"&&B.push({id:ae.id,label:ae.label,waiting:ae.waiting});return B.sort((ae,de)=>ae.waiting.since-de.waiting.since)},[n.current,n.current.lastSeq]),ji=T.useMemo(()=>{const B=new Set;for(const V of n.current.agents.values())V.state==="active"&&B.add(V.sessionId);return B.size},[n.current,n.current.lastSeq]),Ri=T.useRef(null);T.useEffect(()=>{const B=RL({waiting:cr.length,running:ji}),V=Ri.current;if(Ri.current=B,(V==null?void 0:V.title)!==B.title&&(document.title=B.title),(V==null?void 0:V.icon)!==B.icon){const ae=document.querySelector('link[rel="icon"]');ae&&(ae.href=TL[B.icon])}},[cr.length,ji]);const Rt=T.useMemo(()=>{let B=0,V=0,ae=0,de=0,xe=0,Ne=0,Ie=0,Le=0,Ve=0;for(const Qe of n.current.agents.values()){B+=Qe.usage.inputTokens,V+=Qe.usage.outputTokens,ae+=Qe.usage.cacheReadTokens,de+=Qe.usage.cacheCreateTokens;const rt=fn(Qe.usage,Qe.model);xe+=rt.total,Ne+=rt.input,Ie+=rt.output,Le+=rt.cacheRead,Ve+=rt.cacheWrite}return{inT:B,outT:V,cacheR:ae,cacheC:de,sum:B+V,cost:{total:xe,input:Ne,output:Ie,cacheRead:Le,cacheWrite:Ve}}},[n.current,n.current.lastSeq]);return m.jsxs("div",{className:"app",children:[m.jsxs("header",{className:"topbar",children:[m.jsxs("div",{className:"brand",children:[m.jsx("span",{className:"logo"}),zt,ye?m.jsxs("button",{type:"button",className:"v stale",onClick:ze,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 B={running:(Y==null?void 0:Y.running)??"1.33.142",latest:Y==null?void 0:Y.latest,latestPending:Y==null?void 0:Y.latestPending,checkedAgo:Y!=null&&Y.checkedAt?kv(ut-Y.checkedAt):null,checkDisabled:Y==null?void 0:Y.checkDisabled,checking:ce};return m.jsxs("button",{type:"button",className:ce?"v checking":"v",onClick:()=>ve(!0),"aria-busy":ce||void 0,"aria-label":gD(B),title:mD(B),children:["v",B.running]})})()]}),St&&(()=>{const B=fn(St.usage,St.model),V=Math.max(0,((St.endedAt??ut)-St.startedAt)/1e3),ae=St.state==="active"?gu(B.total,V):null,de=o.size-1;return m.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${St.label}`,onClick:()=>{try{const xe=Fn.find(Ne=>Ne.id===St.id);xe&&e.fitView({padding:.35,duration:500,nodes:[xe]}),$n.current=Date.now()}catch{}},children:[m.jsx("span",{className:`state-pill state-${St.state}`,children:St.state==="active"?"live":St.state}),m.jsx("span",{className:"selected-label",children:St.label}),B.total>0&&m.jsxs("span",{className:"selected-cost",children:[Fe(B.total),ae?m.jsxs("span",{className:"selected-rate",children:[" · ",ae]}):null]}),de>0&&m.jsxs("span",{className:"selected-extra",children:["+",de]}),m.jsx("span",{role:"button","aria-label":"Deselect",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:br,type:"text",placeholder:"Search agents, cwd, tools…",value:en,onChange:B=>Qr(B.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),en?m.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>Qr(""),children:"×"}):m.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"}),En.count&&m.jsx("span",{className:`search-count${En.empty?" none":""}`,"aria-live":"polite",title:`${En.count} agents on the canvas match “${en}”`,children:En.count})]}),m.jsxs("span",{className:"status",role:"status",children:[(()=>{const B=yD({connected:I,paused:pn,held:Zt.current.size});return m.jsx("span",{className:`pill ${B.tone}`,title:B.title,children:B.label})})(),m.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[m.jsx("span",{className:"count",children:Ds}),m.jsx("span",{className:"lbl",children:"sessions"})]}),m.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[m.jsx("span",{className:"count",children:Tr}),m.jsx("span",{className:"lbl",children:"agents"})]}),m.jsxs("span",{className:"stat",title:"Total hook events received",children:[m.jsx("span",{className:"count",children:n.current.totalEvents}),m.jsx("span",{className:"lbl",children:"events"})]}),Rt.sum>0&&m.jsxs("span",{className:"stat",title:`in:${Rt.inT.toLocaleString()} out:${Rt.outT.toLocaleString()} cache-r:${Rt.cacheR.toLocaleString()} cache-c:${Rt.cacheC.toLocaleString()}`,children:[m.jsx("span",{className:"count",children:Ft(Rt.sum)}),m.jsx("span",{className:"lbl",children:"tokens"})]}),Ls.length>0&&m.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
|
|
61
|
+
Blocked since ${new Date(p.waiting.since).toLocaleTimeString()} · started ${new Date(p.startedAt).toLocaleString()}`,children:["waiting ",Dx(p.waiting.since,void 0,n)]}):m.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(p.startedAt).toLocaleString()}`,children:Dx(p.startedAt,p.state==="active"?void 0:p.lastActivity,n)})]})]})]},p.sessionId)})]})]})}const zt="ccdeck";function Ft(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:e<1e9?`${(e/1e6).toFixed(2)}M`:`${(e/1e9).toFixed(2)}B`}function Fx(e,n){if(!e)return null;const r=n-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 v3(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"}function y3({cost:e}){const n=e.total;if(n<=0)return null;const r=(i,o,l)=>{if(i<=0)return null;const u=i/n*100;return m.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${Fe(i)} (${u.toFixed(0)}%)`},o)};return m.jsxs("div",{className:"cost-bar","aria-label":"Cost breakdown",children:[r(e.input,"cb-input","input"),r(e.output,"cb-output","output"),r(e.cacheRead,"cb-cache-r","cache read"),r(e.cacheWrite,"cb-cache-w","cache write")]})}function w3(e,n){const r=e-n;if(r<=0)return null;const i=Math.floor(r/3600),o=Math.floor(r%3600/60);if(i>23){const l=Math.floor(r/86400),u=Math.floor(r%86400/3600);return`${l}d ${u}h`}return i>0?`${i}h ${o}m`:`${o}m`}function x3(e,n,r,i){const o=Math.max(0,n-i),l=Math.max(0,r-o);if(l<120)return null;const u=Math.min(100,l/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 p=100-e,f=l>0?e/l:0,h=f>0?p/f:1/0,g={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(h<o&&h<86400){const y=Math.floor(h/3600),x=Math.floor(h%3600/60);g.runsOutIn=y>0?`${y}h ${x}m`:`${x}m`}return g}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function ei({pct:e,label:n,reset:r,resetAt:i,windowSec:o,limitReached:l,nowSec:u}){const c=Math.min(100,Math.max(0,e)),f=l||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",h=c===0?"< 1%":`${c}%`,g=c===0?2:c,y=i?w3(i,u):null,x=i&&o?x3(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:[n,l&&m.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),m.jsx("span",{className:"qb-pct",style:{color:f},children:h})]}),m.jsxs("div",{className:"qb-track",children:[m.jsx("div",{className:"qb-fill",style:{width:`${g}%`,background:f,opacity:c===0?.4:1}}),x&&m.jsx("div",{className:"qb-pace-marker",style:{left:`${x.expectedPct}%`,background:x.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(x.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,x&&m.jsx("span",{className:"qb-pace",style:{color:x.color},children:x.runsOutIn?`runs out in ${x.runsOutIn}`:x.label})]})]})}const _3=6e4;function b3(){const[e,n]=T.useState(null),[r,i]=T.useState(!1),o=T.useRef(null),l=async(c=!1)=>{c&&i(!0);try{const f=await fetch(c?"/api/quota?refresh=1":"/api/quota");f.ok&&n(await f.json())}catch{}finally{c&&i(!1)}};return T.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),_3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:r,refresh:()=>l(!0)}}function S3(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.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const uC=6e4;function k3(){const[e,n]=T.useState(null),[r,i]=T.useState(!1),o=T.useRef(null),l=async(c=!1)=>{c&&i(!0);try{const f=await fetch(c?"/api/codex-quota?refresh=1":"/api/codex-quota");f.ok&&n(await f.json())}catch{}finally{c&&i(!1)}};return T.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),uC),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:r,refresh:()=>l(!0)}}function E3(){const[e,n]=T.useState(null),r=T.useRef(null),i=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return T.useEffect(()=>(i(),r.current=window.setInterval(i,uC),()=>{r.current!=null&&window.clearInterval(r.current)}),[]),{data:e}}function N3({state:e,now:n,onClose:r}){var L,H;const{quota:i,loading:o,refresh:l}=b3(),{data:u,loading:c,refresh:p}=k3(),{data:f}=E3(),[h,g]=T.useState(()=>Math.floor(Date.now()/1e3));T.useEffect(()=>{const O=window.setInterval(()=>g(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(O)},[]);const{byModel:y,totalCost:x,totalTokens:N,burnRate:_}=T.useMemo(()=>{const O=new Map,P={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let F=0,G=0,q=0,R=0;for(const $ of e.agents.values()){const X=$.model??"__unknown__",I=fn($.usage,$.model),W=O.get(X);W?(W.inputTokens+=$.usage.inputTokens,W.outputTokens+=$.usage.outputTokens,W.cacheReadTokens+=$.usage.cacheReadTokens,W.cacheCreateTokens+=$.usage.cacheCreateTokens,W.cost.total+=I.total,W.cost.input+=I.input,W.cost.output+=I.output,W.cost.cacheRead+=I.cacheRead,W.cost.cacheWrite+=I.cacheWrite,W.agentCount++):O.set(X,{model:X,inputTokens:$.usage.inputTokens,outputTokens:$.usage.outputTokens,cacheReadTokens:$.usage.cacheReadTokens,cacheCreateTokens:$.usage.cacheCreateTokens,cost:{...I},agentCount:1}),P.total+=I.total,P.input+=I.input,P.output+=I.output,P.cacheRead+=I.cacheRead,P.cacheWrite+=I.cacheWrite,F+=$.usage.inputTokens,G+=$.usage.outputTokens,q+=$.usage.cacheReadTokens,R+=$.usage.cacheCreateTokens}const Q=Array.from(O.values()).sort(($,X)=>X.cost.total-$.cost.total);let z=0,ne=0;for(const $ of e.agents.values()){if($.state!=="active")continue;const X=fn($.usage,$.model);z+=X.total,ne=Math.max(ne,(($.endedAt??n)-$.startedAt)/1e3)}const Z=ne>0?gu(z,ne):null;return{byModel:Q,totalCost:P,totalTokens:{in:F,out:G,cacheR:q,cacheC:R},burnRate:Z}},[e,e.lastSeq,n]),S=T.useMemo(()=>{const O=[];for(const P of e.agents.values()){if(P.kind!=="root")continue;let F=fn(P.usage,P.model).total,G=P.usage.inputTokens,q=P.usage.outputTokens;for(const R of e.agents.values())R.sessionId!==P.sessionId||R.kind==="root"||(F+=fn(R.usage,R.model).total,G+=R.usage.inputTokens,q+=R.usage.outputTokens);O.push({sessionId:P.sessionId,label:P.label||P.cwdBasename||"session",state:P.state,cost:F,inputTokens:G,outputTokens:q})}return O.sort((P,F)=>F.cost-P.cost).slice(0,12)},[e,e.lastSeq]),b=x.total>0,k=N.in+N.out,E=o||c,C=Fx(i==null?void 0:i.fetchedAt,h),A=Fx(u==null?void 0:u.fetchedAt,h),M=()=>{l(),p()};return m.jsxs("div",{className:"usage-panel","aria-label":"Usage",children:[m.jsxs("div",{className:"up-header",children:[m.jsx("h3",{children:"Usage"}),_&&m.jsx("span",{className:"up-rate",children:_}),m.jsxs("div",{className:"up-header-right",children:[m.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:M,disabled:E,title:"Refresh Claude + Codex quota",children:E?"…":"↻"}),m.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:r,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),m.jsxs("section",{className:"up-section up-quota-section",children:[m.jsxs("h4",{className:"up-section-title",children:["Claude quota",C&&!o&&m.jsx("span",{className:"up-section-age",title:v3(i==null?void 0:i.source),children:C})]}),i!=null&&i.ok?m.jsxs("div",{className:"up-quota-bars",children:[i.session5hPct!=null&&m.jsx(ei,{label:"5-hour window",pct:i.session5hPct,reset:i.session5hReset,resetAt:i.session5hResetAt,windowSec:i.session5hWindowSec,nowSec:h}),i.week7dPct!=null&&m.jsx(ei,{label:"7-day window",pct:i.week7dPct,reset:i.week7dReset,resetAt:i.week7dResetAt,windowSec:i.week7dWindowSec,nowSec:h}),i.weekSonnetPct!=null&&m.jsx(ei,{label:"Sonnet (7d)",pct:i.weekSonnetPct,nowSec:h}),i.weekOpusPct!=null&&m.jsx(ei,{label:"Opus (7d)",pct:i.weekOpusPct,nowSec:h})]}):(i==null?void 0:i.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…"})]}),m.jsxs("section",{className:"up-section up-quota-section",children:[m.jsxs("h4",{className:"up-section-title",children:["Codex quota",(u==null?void 0:u.ok)&&u.planLabel&&m.jsx("span",{className:"up-plan-badge",children:u.planLabel}),A&&!c&&m.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:A})]}),u!=null&&u.ok?m.jsxs("div",{className:"up-quota-bars",children:[(L=u.windows)==null?void 0:L.map(O=>m.jsx(ei,{label:O.label,pct:O.pct,reset:O.reset??void 0,resetAt:O.resetAt??void 0,windowSec:O.windowSec??void 0,limitReached:u.limitReached&&O.pct>=100,nowSec:h},O.id)),(H=u.extraWindows)==null?void 0:H.map(O=>m.jsx(ei,{label:O.label,pct:O.pct,reset:O.reset??void 0,resetAt:O.resetAt??void 0,windowSec:O.windowSec??void 0,nowSec:h},O.id)),u.creditLimit&&m.jsx(ei,{label:`spend cap · $${Math.round(u.creditLimit.used)} of $${Math.round(u.creditLimit.limit)}`,pct:u.creditLimit.usedPct,reset:u.creditLimit.reset??void 0,resetAt:u.creditLimit.resetAt??void 0,limitReached:u.spendControlReached,nowSec:h}),(f==null?void 0:f.ok)&&f.window7d&&f.window7d.sessionCount>0&&m.jsxs("div",{className:"up-quota-sub",children:[Ft(f.window7d.totalTokens)," tokens · ",f.window7d.sessionCount," session",f.window7d.sessionCount!==1?"s":""," (7d)"]}),u.creditsBalance&&!u.creditsUnlimited&&m.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",u.creditsBalance,u.overageReached&&" · overage limit reached"]}),u.creditsUnlimited&&m.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),u.resetCredits&&u.resetCredits.availableCount>0&&m.jsxs("div",{className:"up-quota-sub up-reset-credits",title:`Redeem in the Codex CLI or ChatGPT — ${zt} only reports them`,children:[u.resetCredits.availableCount," rate-limit reset",u.resetCredits.availableCount!==1?"s":""," available",u.resetCredits.nextExpiryAt&&` · expires ${new Date(u.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),u.promo&&m.jsx("div",{className:"up-quota-sub",children:u.promo}),u.partial&&m.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(u==null?void 0:u.ok)===!1?m.jsxs("div",{className:"up-quota-na",children:[m.jsx("span",{children:"Quota unavailable."}),m.jsx("span",{className:"up-quota-hint",children:S3(u.reason)})]}):m.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),b?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"up-total",children:[m.jsx("span",{className:"up-total-value",children:Fe(x.total)}),m.jsx("span",{className:"up-total-label",children:"total spend"})]}),m.jsx(y3,{cost:x}),k>0&&m.jsxs("div",{className:"up-tokens-row",children:[m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"in"}),Ft(N.in)]}),m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"out"}),Ft(N.out)]}),N.cacheR>0&&m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"cache r"}),Ft(N.cacheR)]}),N.cacheC>0&&m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"cache c"}),Ft(N.cacheC)]})]}),y.filter(O=>O.cost.total>0).length>0&&m.jsxs("section",{className:"up-section",children:[m.jsx("h4",{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:y.filter(O=>O.cost.total>0).map(O=>m.jsxs("tr",{children:[m.jsx("td",{className:"up-model-name",title:O.model,children:li(O.model)}),m.jsx("td",{className:"up-num",children:Ft(O.inputTokens+O.outputTokens)}),m.jsx("td",{className:"up-num up-cost-val",children:Fe(O.cost.total)})]},O.model))})]})]}),S.filter(O=>O.cost>0).length>0&&m.jsxs("section",{className:"up-section",children:[m.jsx("h4",{className:"up-section-title",children:"By session"}),m.jsx("div",{className:"up-sessions",children:S.filter(O=>O.cost>0).map(O=>m.jsxs("div",{className:"up-session-row",children:[m.jsx("span",{className:`sl-dot state-${O.state}`,"aria-hidden":!0}),m.jsx("span",{className:"up-session-label",children:O.label}),m.jsx("span",{className:"up-session-tokens",children:Ft(O.inputTokens+O.outputTokens)}),m.jsx("span",{className:"up-session-cost",children:Fe(O.cost)})]},O.sessionId))})]})]}):k>0?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"up-tokens-row",children:[m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"in"}),Ft(N.in)]}),m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"out"}),Ft(N.out)]})]}),m.jsx("div",{className:"up-hint",children:"Cost appears once a known model is detected."})]}):m.jsxs("div",{className:"up-empty",children:["No usage data yet.",m.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const zx=18,C3=1100,no=(e,n)=>{const r=Math.sin(e*12.9898+n*78.233)*43758.5453;return r-Math.floor(r)},j3=Array.from({length:zx},(e,n)=>{const r=-72+144*n/(zx-1)+(no(n,1)-.5)*9,i=(r-90)*(Math.PI/180),o=(54+32*Math.cos(r*Math.PI/180))*(.74+no(n,2)*.52);return{dx:Math.cos(i)*o,dy:Math.sin(i)*o,rot:(n%2?1:-1)*(100+no(n,3)*260),delay:Math.round(no(n,4)*90),dur:760+Math.round(no(n,5)*260),scale:.8+no(n,6)*.45,hue:n%4,round:n%3===0}});function Bx({anchor:e,lifetimeMs:n=C3}){var l;const[r,i]=T.useState(null),o=typeof window<"u"&&((l=window.matchMedia)==null?void 0:l.call(window,"(prefers-reduced-motion: reduce)").matches);return T.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 p=window.setTimeout(()=>i(null),n);return()=>window.clearTimeout(p)},[e,n,o]),o||!r?null:TI.createPortal(m.jsx("div",{className:"confetti",style:{left:`${r.x}px`,top:`${r.y}px`},"aria-hidden":!0,children:j3.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 cC=new Set(["awaiting_url","awaiting_code","registering"]);function R3(e){return e!=null&&cC.has(e)}function dC(e){return e!=null&&e!=="done"&&!cC.has(e)}const T3="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",A3="the sign-in did not complete";function I3({state:e,serverError:n,localError:r}){const i=e==="idle";return{title:i?"Sign-in ended":"Sign-in failed",message:r||n||(i?T3:A3)}}const M3="done";function P3(){let e=!1;return{shouldAnnounce(n){return n!==M3?(e=!1,!1):e?!1:(e=!0,!0)}}}const Ux={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 ${zt}`,expired:"that share has expired — make a new one",import_failed:"claude-swap refused the import"},Hx={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"},O3=`claude-swap could not read the login keychain — start ${zt} from a Terminal window rather than a background service`;function _v(e,n){return(e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(mo(e))?O3:e!=null&&e.reason&&Hx[e.reason]?Hx[e.reason]:(e==null?void 0:e.reason)||n}function mo(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const Wx={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",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",unreachable:"the deck did not answer — check it is still running, then try again"},L3="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 q3(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}function $3(e,n){return q3(mo(e))?L3:e!=null&&e.reason&&Wx[e.reason]?Wx[e.reason]:(e==null?void 0:e.reason)||n}function iu(e,n){return e!=null&&e.detail?e.detail:e!=null&&e.error&&dC(e.state)?e.error:e!=null&&e.reason&&Ux[e.reason]?Ux[e.reason]:e!=null&&e.error?e.error:(e==null?void 0:e.reason)||n}const D3=1500;async function Kl(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const bv=ue.forwardRef((e,n)=>m.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:n,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"})]}));bv.displayName="SuccessMark";function F3({onClose:e,onChanged:n}){const[r,i]=T.useState("login"),[o,l]=T.useState(null),[u,c]=T.useState(""),[p,f]=T.useState(""),[h,g]=T.useState(!1),[y,x]=T.useState(null),[N,_]=T.useState(null),S=T.useRef(!1),b=T.useRef(null),k=T.useRef(null),E=T.useRef(null),C=T.useCallback(()=>{S.current&&Kl({action:"login-cancel"}).catch(()=>{}),e()},[e]);vo(C);const A=T.useCallback(async()=>{g(!0),x(null),S.current=!0;const q=await Kl({action:"login"}).catch(()=>null);if(g(!1),!(q!=null&&q.ok)){x(iu(q,"could not start the sign-in"));return}l(q)},[]);T.useEffect(()=>{if(!R3(o==null?void 0:o.state))return;const q=window.setInterval(async()=>{try{const R=await fetch("/api/claude-accounts/login");R.ok&&l(await R.json())}catch{}},D3);return()=>window.clearInterval(q)},[o]);const M=T.useRef(n);M.current=n;const L=T.useRef(P3());T.useEffect(()=>{var q;(o==null?void 0:o.state)==="awaiting_code"&&((q=b.current)==null||q.focus()),L.current.shouldAnnounce(o==null?void 0:o.state)&&M.current()},[o==null?void 0:o.state]),T.useEffect(()=>{var q;r==="paste"&&((q=k.current)==null||q.focus())},[r]);const H=T.useCallback(async()=>{var R;g(!0),x(null);const q=await Kl({action:"login-code",code:u}).catch(()=>null);if(g(!1),!(q!=null&&q.ok)){x(iu(q,"the code was not accepted")),q!=null&&q.state&&l(q),(R=b.current)==null||R.select();return}c(""),l(q)},[u,o]),O=T.useCallback(async()=>{g(!0),x(null);const q=await Kl({action:"import",blob:p}).catch(()=>null);if(g(!1),!(q!=null&&q.ok)){x(iu(q,"the import failed"));return}f(""),_({added:q.added===!0,num:q.num??null,email:q.email??null}),n()},[p,n]),P=(o==null?void 0:o.state)==="done"?o.account:null,F=dC(o==null?void 0:o.state)||!!(y&&S.current&&!h),G=I3({state:o==null?void 0:o.state,serverError:o==null?void 0:o.error,localError:y});return m.jsx("div",{className:"modal-backdrop",onClick:C,role:"presentation",children:m.jsxs("div",{className:"modal aa-modal",onClick:q=>q.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:C,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),m.jsx("section",{className:"modal-body aa-body",children:r==="login"?P?m.jsxs("div",{className:"aa-done",children:[m.jsx(bv,{ref:E}),m.jsx(Bx,{anchor:E}),m.jsx("h4",{children:P.added?`Account ${P.num} added`:"Credentials refreshed"}),m.jsxs("p",{className:"aa-note",children:[m.jsx("strong",{children:P.email}),P.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:b,type:"text",value:u,onChange:q=>c(q.target.value),onKeyDown:q=>{q.key==="Enter"&&u.trim()&&!h&&H()},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:h||!u.trim()||o.state==="registering",onClick:H,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."})]})]}):F?m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:G.title}),m.jsx("p",{className:"aa-err",children:G.message}),m.jsx("button",{type:"button",className:"btn",onClick:()=>{S.current=!1,l(null),x(null),A()},children:"Try again"})]}):h||S.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",className:"btn primary",onClick:A,disabled:h,children:"Open the sign-in page"})})]}):N?m.jsxs("div",{className:"aa-done",children:[m.jsx(bv,{ref:E}),N.added&&m.jsx(Bx,{anchor:E}),m.jsx("h4",{children:N.added?`Account ${N.num} imported`:"Already here"}),m.jsx("p",{className:"aa-note",children:N.added?m.jsxs(m.Fragment,{children:[N.email?m.jsx("strong",{children:N.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:p,onChange:q=>f(q.target.value),onKeyDown:q=>{q.key==="Enter"&&p.trim()&&!h&&O()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),m.jsx("button",{type:"button",className:"btn primary",disabled:h||!p.trim(),onClick:O,children:h?"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 z3(e,n){const r=new Set(e),i=e.length?Math.max(...e):0;return[...new Set([...e,i+1])].sort((o,l)=>o-l).map(o=>{const l=o===n?"here":r.has(o)?"swap":"free";return{slot:o,kind:l,label:l==="here"?`slot ${o}`:`slot ${o} · ${l}`}})}function B3(e,n,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!==n;return{menuFor:e.menuFor===n?i:o&&e.menuFor===i?n:e.menuFor,confirmRemove:null,shareFor:null,swapNote:o?{at:i,displaced:n}:null}}function U3(e,n){const r=e.trim();return{alias:r,commit:r!==(n??"").trim()}}const H3=Object.freeze({text:"couldn't reach the deck server",reload:!0});async function Vx(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function W3(e){const n=e.find(i=>!i.ok);if(!n)return null;const r=mo(n.body);return{text:_v(n.body,`the deck server answered ${n.status}`),...r?{raw:r}:{},reload:!0}}function Gx(e,n){return n?e!=null&&e.reload&&e.text===n.text&&e.raw===n.raw?e:n:e!=null&&e.reload?null:e}const Yx=15e3,V3=8e3,G3=1800,Y3=3e4,K3=[70,80,85,90,95];function X3(e,n){const r=e-n;if(r<=0)return null;const i=Math.floor(r/86400),o=Math.floor(r%86400/3600),l=Math.floor(r%3600/60);return i>0?`${i}d ${o}h`:o>0?`${o}h ${l}m`:`${l}m`}function Kx(e,n){const r=n-Math.floor(e/1e3);return r<60?"just now":r<3600?`${Math.floor(r/60)}m ago`:r<86400?`${Math.floor(r/3600)}h ago`:`${Math.floor(r/86400)}d ago`}function Q3(e,n){if(!e)return"";const r=Math.floor(e/1e3)-n;return r<=0?" · due":r<60?` · next in ${r}s`:` · next in ${Math.round(r/60)}m`}function Z3(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 J3({lane:e,nowSec:n}){const r=Math.min(100,Math.max(0,e.pct)),i=r>=90?"var(--err)":r>=70?"var(--warn)":"var(--accent)",o=e.resetAt?X3(e.resetAt,n):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 eL(e){var r;let n=!1;try{n=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{n=!1}if(n)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(),n=document.execCommand("copy"),i.remove()}catch{n=!1}return n}function tL(e,n){const r=Math.round(e/1e3)-n;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 nL({onClose:e}){var re,le,fe;const[n,r]=T.useState(null),[i,o]=T.useState(null),[l,u]=T.useState(null),[c,p]=T.useState(!1),[f,h]=T.useState(null),[g,y]=T.useState(null),[x,N]=T.useState(()=>Math.floor(Date.now()/1e3)),_=T.useRef(null),[S,b]=T.useState(null),[k,E]=T.useState(!1),[C,A]=T.useState(""),[M,L]=T.useState(null),[H,O]=T.useState(null),[P,F]=T.useState(null),[G,q]=T.useState(!1),[R,Q]=T.useState(null),z=T.useCallback(async(te=!1)=>{te&&p(!0);const ce=new AbortController,Ce=window.setTimeout(()=>ce.abort(),Y3);try{const[ve,Te]=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()),Te.ok&&o(await Te.json());const ye=W3([await Vx(ve),await Vx(Te)]);y(ke=>Gx(ke,ye))}catch{y(ve=>Gx(ve,H3))}finally{window.clearTimeout(Ce),te&&p(!1)}},[]),ne=T.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:_v(ve,"command failed"),raw:mo(ve)}),ve}catch{return y({text:"server unreachable"}),null}finally{u(null)}},[]),Z=T.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:iu(ve,"command failed")}),ve}catch{return y({text:"server unreachable"}),null}finally{u(null)}},[]);T.useEffect(()=>(z(!0),_.current=window.setInterval(()=>z(!1),Yx),()=>{_.current!=null&&window.clearInterval(_.current)}),[z]),T.useEffect(()=>{const te=window.setInterval(()=>N(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(te)},[]);const $=((re=i==null?void 0:i.settings["autoswitch.threshold"])==null?void 0:re.value)??"90",X=(le=n==null?void 0:n.accounts)==null?void 0:le.find(te=>te.active),I=X!=null&&X.lanes.length?Math.max(...X.lanes.map(te=>te.pct)):null,W=I!=null&&I>=Number($)-15,Y=async te=>{h(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:_v(Ce,"the switch failed"),raw:mo(Ce)}),await z(!0)}catch{y({text:"server unreachable"})}finally{h(null)}},U=async(te,ce)=>{const{commit:Ce,alias:ve}=U3(C,ce);if(Ce){const Te=await Z({action:"alias",account:te,alias:ve},`alias-${te}`);if(await z(!0),!(Te!=null&&Te.ok))return;A(ve)}L(te),window.setTimeout(()=>L(Te=>Te===te?null:Te),G3)},J=async(te,ce)=>{const Ce=await Z({action:"move",account:te,slot:ce},`move-${te}`),ve=B3({menuFor:S,shareFor:(P==null?void 0:P.num)??null},te,Ce);if(await z(!0),ve){b(ve.menuFor),O(ve.confirmRemove),ve.shareFor==null&&(F(null),q(!1)),Q(ve.swapNote);const Te=ve.swapNote;Te&&window.setTimeout(()=>Q(ye=>ye===Te?null:ye),V3)}};return m.jsxs("div",{className:"accounts-panel","aria-label":"Claude accounts",children:[m.jsxs("div",{className:"ap-header",children:[m.jsx("h3",{children:"Accounts"}),m.jsxs("div",{className:"ap-header-right",children:[m.jsx("button",{type:"button",className:"btn ap-add",onClick:()=>E(!0),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:()=>z(!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:"×"})]})]}),n==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 ",Yx/1e3," seconds."]}),m.jsx("button",{type:"button",className:"ap-fix",disabled:c,onClick:()=>z(!0),children:c?"trying…":"try again"})]}):m.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?m.jsxs(m.Fragment,{children:[(fe=n.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",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${S===te.num?" on":""}`,"aria-label":`Manage account ${te.num}`,"aria-expanded":S===te.num,"aria-controls":S===te.num?`ap-manage-${te.num}`:void 0,title:"Share, rename, move, remove",onClick:()=>{b(S===te.num?null:te.num),A(te.alias??""),O(null),F(null),q(!1),Q(null),L(null)},children:"⋯"}),te.active?m.jsx("span",{className:"ap-badge-active",children:"● active"}):m.jsx("button",{type:"button",className:"btn ap-switch",disabled:f!=null||te.disabled,onClick:()=>Y(te.num),title:te.disabled?"Held out of rotation":`Switch to ${te.alias??te.email}`,children:f===te.num?"…":"switch"})]}),te.lanes.length>0?te.lanes.map(ce=>m.jsx(J3,{lane:ce,nowSec:x},ce.id)):m.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),m.jsxs("div",{className:"ap-meta",children:[te.error&&(()=>{const ce=Z3(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:()=>E(!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:l!=null,onClick:()=>ne({action:"account",account:te.num,enabled:te.disabled},`rot-${te.num}`).then(()=>z(!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 ",Kx(te.fetchedAt,x),Q3(te.nextAt,x)]}):m.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),S===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:"ap-vh",htmlFor:`ap-alias-${te.num}`,children:"Alias"}),m.jsx("input",{id:`ap-alias-${te.num}`,className:"ap-manage-input",type:"text",value:C,onChange:ce=>A(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&U(te.num,te.alias)},placeholder:"e.g. work",spellCheck:!1,autoFocus:!0}),m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:()=>U(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:"ap-vh",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:l!=null,onChange:ce=>J(te.num,Number(ce.target.value)),children:z3((n.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:l!=null,title:`Copy this account to another ${zt}. The share carries a live login and expires in 10 minutes.`,onClick:async()=>{q(!1);const ce=await Z({action:"share",account:te.num},`share-${te.num}`);ce!=null&&ce.ok&&F({num:te.num,blob:ce.blob,expiresAt:ce.expiresAt})},children:"share"}),m.jsx("button",{type:"button",className:`ap-manage-btn danger${H===te.num?" armed":""}`,disabled:l!=null,title:H===te.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(H!==te.num){O(te.num),window.setTimeout(()=>O(ce=>ce===te.num?null:ce),4e3);return}O(null),Z({action:"remove",account:te.num},`rm-${te.num}`).then(()=>{b(null),z(!0)})},children:H===te.num?"confirm":"remove"})]}),(R==null?void 0:R.at)===te.num&&(()=>{var ve;const ce=(ve=n.accounts)==null?void 0:ve.find(Te=>Te.num===R.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 ${R.at} was taken, so the two accounts traded places: ${Ce} now holds slot ${R.displaced}.`,children:["swapped with slot ",R.displaced]})})(),(P==null?void 0:P.num)===te.num&&(()=>{const ce=tL(P.expiresAt,x),Ce=ce.tone==="gone";return m.jsxs("div",{className:`ap-share${Ce?" expired":""}`,children:[m.jsx("code",{className:"ap-share-blob",children:P.blob}),m.jsxs("div",{className:"ap-share-foot",children:[m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:async()=>{if(Ce){q(!1);const ve=await Z({action:"share",account:te.num},`share-${te.num}`);ve!=null&&ve.ok&&F({num:te.num,blob:ve.blob,expiresAt:ve.expiresAt});return}await eL(P.blob)&&(q(!0),window.setTimeout(()=>q(!1),1800))},children:Ce?"make a new share":G?"copied":"copy"}),m.jsxs("span",{className:"ap-manage-hint",children:["carries a live login · ",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${W?" 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:$,disabled:l!=null,onChange:te=>ne({action:"setting",key:"autoswitch.threshold",value:te.target.value},"threshold").then(()=>z(!0)),children:K3.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:l!=null,onClick:()=>ne({action:"enable",enabled:!i.enabled},"enable").then(()=>z(!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 ",Kx(i.lastTick.at,x)]})})]}),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:n.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."}),n.hint&&m.jsx("code",{className:"ap-cmd",children:n.hint}),m.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",m.jsx("strong",{children:"+"})," button above."]})]}):n.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",n.reason?` (${n.reason})`:"","."]})]})}),k&&m.jsx(F3,{onClose:()=>E(!1),onChanged:()=>z(!0)})]})}const rL=3e4;function sL({bundle:e,running:n,lastTried:r}){return!n||e===n?!1:r!==n}function iL({bundle:e,running:n,pending:r,lastTried:i}){return n?sL({bundle:e,running:n,lastTried:i})?"reload":r==null||r&&r!==n?"wait":"confirm":"wait"}function oL(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function aL({asked:e,reported:n}){return n?n!==e:!1}function lL(e){const n=e.thresholdMs??rL;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>=n}}function uL(e){return e.ctrlKey||e.metaKey||e.altKey}const cL=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),dL=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),fL=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function fC(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function hC(e){if(!e)return!1;if(e.isContentEditable)return!0;const n=fC(e);return n==="TEXTAREA"?!0:n!=="INPUT"?!1:!cL.has(String(e.type??"text").toLowerCase())}function hL(e){if(!e)return!1;if(hC(e)||dL.has(fC(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(r=>fL.has(r))}function pL({agentCount:e,onConfirm:n,onCancel:r}){const i=T.useRef(null);vo(r,{focusRef:i,layer:dO});const o=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",{className:"modal clear-confirm",onClick:l=>l.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:[o," — 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:n,children:"Clear everything"})]})]})]})})}function mL(e,n){return e==="confirmation"?n.confirmOpen?"clear":"ignore":n.modalOpen||n.confirmOpen?"ignore":"confirm"}function Xl(e,n){if(n.size!==0)for(const r of Array.from(e.keys()))n.has(r)||e.delete(r)}function gL(e){const n=new Set;for(const r of e)n.add(r.id),n.add(`group:${r.sessionId}`);return n}function pC(e,n,r){return!n.has(e)||r.has(e)}function vL(e,n,r,i){return!n.has(e)&&pC(e,r,i)}function yL(e,n,r){const i={x:0,y:0};return n.set(e,i),r.add(e),i}function wL(e,n,r,i){r.set(e,n),i.delete(e)}const xL=40,_L=120;function bL(e,n){let r=null,i=0,o=Number.NEGATIVE_INFINITY;const l=()=>{r=null,o=n.now(),e()},u=()=>{r!=null&&(n.clearTimeout(r),r=null)},c=(p,f,h)=>{if(r!=null){if(i<=p)return;u()}const g=Math.min(h,Math.max(0,p-f));i=p,r=n.setTimeout(l,g)};return{live(p=xL){const f=n.now(),h=Math.max(o+p,f);if(h<=f){u(),l();return}c(h,f,p)},replay(p=_L){u(),i=n.now()+p,r=n.setTimeout(l,p)},flush(){u(),l()},cancel(){u()}}}function SL(){let e=!1,n=[];return{get paused(){return e},get size(){return n.length},accept(r){return e?(n.push(r),!1):!0},setPaused(r){if(e=r,r||n.length===0)return[];const i=n;return n=[],i}}}const kL="1",Xx="agent-dag.schema",EL=["agent-dag.layout","agent-dag.viewport"];function mC(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function NL(e,n=kL){let r=null;try{r=e.getItem(Xx)}catch{return[]}if(r===n)return[];const i=[];if(r!==null)for(const o of EL)try{e.getItem(o)!==null&&(e.removeItem(o),i.push(o))}catch{}try{e.setItem(Xx,n)}catch{}return i}const gC="agent-dag.theme";function CL(e){return e==="light"?"light":"dark"}function jL(){return CL(mC(gC))}function RL({waiting:e,running:n}){return{title:e>0?`(${e}) ${zt}`:zt,icon:e>0?"waiting":n>0?"running":"idle"}}const Md={waiting:"#c97d12",running:"#2a90d4",idle:"#7e828c"};function Pd(e,n){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">${n==="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"/>`+(n==="running"?`<circle cx="16" cy="16" r="5" fill="${e}"/>`:"")}</svg>`}const TL=Object.freeze({waiting:`data:image/svg+xml,${encodeURIComponent(Pd(Md.waiting,"waiting"))}`,running:`data:image/svg+xml,${encodeURIComponent(Pd(Md.running,"running"))}`,idle:`data:image/svg+xml,${encodeURIComponent(Pd(Md.idle,"idle"))}`});function AL(){let e=0;return{begin(){const n=++e;return()=>n===e},cancel(){e++}}}function IL(e,n=new Date){return new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}function ML(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 Ql(e){const n=e.toLowerCase();return n.includes("opus")?"#c4b5fd":n.includes("sonnet")?"#7dd3fc":n.includes("haiku")?"#86efac":n.includes("gpt-5")||n.includes("gpt5")?"#fcd34d":n.includes("gpt")?"#fca5a5":n.includes("gemini")?"#a5b4fc":n.includes("codex")?"#fdba74":"#94a3b8"}const PL=[7,14,30,90];function OL(e){const[n,r]=T.useState(null),[i,o]=T.useState(!1),l=T.useRef(AL()).current,u=(c=!1)=>{const p=l.begin(),f=e;o(!0);const g=`/api/ccusage?since=${IL(f)}${c?"&refresh=1":""}`;fetch(g).then(y=>y.json()).then(y=>{p()&&r({range:f,resp:y})}).catch(()=>{p()&&r({range:f,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{p()&&o(!1)})};return T.useEffect(()=>(u(!1),()=>l.cancel()),[e]),{landed:n,loading:i,reload:()=>u(!0)}}function LL({onClose:e}){var k,E,C;const[n,r]=T.useState(30),[i,o]=T.useState(null),{landed:l,loading:u,reload:c}=OL(n);vo(e);const p=ML({loading:u,want:n,answer:l&&{range:l.range,ok:l.resp.ok===!0,days:((k=l.resp.days)==null?void 0:k.length)??0}}),f=p.phase==="chart"?l.resp.days??[]:[],h=T.useMemo(()=>f.reduce((A,M)=>Math.max(A,M.totalCost),0),[f]),{totalCost:g,totalTok:y,inOut:x,cacheRead:N,modelCosts:_}=T.useMemo(()=>{let A=0,M=0,L=0,H=0;const O=new Map;for(const P of f){A+=P.totalCost,M+=P.totalTokens,L+=P.inputTokens+P.outputTokens,H+=P.cacheReadTokens;for(const F of P.modelBreakdowns)O.set(F.modelName,(O.get(F.modelName)??0)+F.cost)}return{totalCost:A,totalTok:M,inOut:L,cacheRead:H,modelCosts:O}},[f]),S=T.useMemo(()=>Array.from(_.entries()).sort((A,M)=>M[1]-A[1]),[_]),b=i?f.find(A=>A.period===i)??null:null;return m.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:m.jsxs("div",{className:"uh-modal",onClick:A=>A.stopPropagation(),role:"dialog","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:"via ccusage · local Claude / Codex logs"})]}),m.jsx("div",{className:"uh-range",role:"tablist","aria-label":"Range",children:PL.map(A=>m.jsxs("button",{role:"tab","aria-selected":n===A,className:`uh-range-btn${n===A?" on":""}`,onClick:()=>{r(A),o(null)},children:[A,"d"]},A))}),m.jsx("button",{className:"btn icon-btn uh-reload",onClick:c,disabled:u,title:"Re-run ccusage","aria-label":"Reload",children:u?"…":"↻"}),m.jsx("button",{className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),p.phase==="busy"?m.jsx("div",{className:"uh-status","aria-busy":"true",children:l?"running ccusage…":"running ccusage… (first run downloads the package)"}):p.phase==="error"?m.jsxs("div",{className:"uh-status uh-err",title:mo(l.resp)||void 0,children:[$3(l.resp,"ccusage did not report usage"),m.jsx("div",{children:m.jsx("button",{className:"btn uh-retry",onClick:c,disabled:u,children:u?"trying…":"Try again"})})]}):p.phase==="empty"?m.jsx("div",{className:`uh-status${p.stale?" uh-stale":""}`,"aria-busy":p.stale||void 0,children:"no usage in this range"}):m.jsxs("div",{className:p.stale?"uh-stale":void 0,"aria-busy":p.stale||void 0,children:[m.jsxs("div",{className:"uh-totals",children:[m.jsx(Zl,{label:"total cost",val:Fe(g),accent:!0}),m.jsx(Zl,{label:"tokens",val:Ft(y)}),m.jsx(Zl,{label:"input+output",val:Ft(x)}),m.jsx(Zl,{label:"cache reads",val:Ft(N)})]}),m.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:f.map(A=>{const M=h>0?A.totalCost/h*100:0,L=A.period===i;return m.jsxs("button",{className:`uh-bar-col${L?" sel":""}`,onClick:()=>o(L?null:A.period),title:`${A.period} · ${Fe(A.totalCost)}`,style:{flexBasis:`${100/f.length}%`},children:[m.jsx("div",{className:"uh-bar",style:{height:`${Math.max(M,A.totalCost>0?2:0)}%`},children:A.modelBreakdowns.slice().sort((H,O)=>O.cost-H.cost).map(H=>{const O=A.totalCost>0?H.cost/A.totalCost*100:0;return m.jsx("div",{className:"uh-bar-seg",style:{height:`${O}%`,background:Ql(H.modelName)}},H.modelName)})}),m.jsx("span",{className:"uh-bar-label",children:A.period.slice(5)})]},A.period)})}),m.jsx("div",{className:"uh-legend",children:S.map(([A,M])=>m.jsxs("span",{className:"uh-legend-item",children:[m.jsx("span",{className:"uh-legend-dot",style:{background:Ql(A)}}),li(A)," ",m.jsx("span",{className:"uh-legend-cost",children:Fe(M)})]},A))}),b&&m.jsxs("div",{className:"uh-detail",children:[m.jsxs("div",{className:"uh-detail-head",children:[m.jsx("span",{className:"uh-detail-date",children:b.period}),m.jsx("span",{className:"uh-detail-cost",children:Fe(b.totalCost)}),(C=(E=b.metadata)==null?void 0:E.agents)!=null&&C.length?m.jsx("span",{className:"uh-detail-agents",children:b.metadata.agents.join(" · ")}):null]}),m.jsxs("div",{className:"uh-detail-mini",children:[m.jsx(Jl,{label:"input",val:Ft(b.inputTokens)}),m.jsx(Jl,{label:"output",val:Ft(b.outputTokens)}),m.jsx(Jl,{label:"cache write",val:Ft(b.cacheCreationTokens)}),m.jsx(Jl,{label:"cache read",val:Ft(b.cacheReadTokens)})]}),m.jsx("div",{className:"uh-detail-models",children:b.modelBreakdowns.slice().sort((A,M)=>M.cost-A.cost).map(A=>{const M=b.totalCost>0?A.cost/b.totalCost*100:0;return m.jsxs("div",{className:"uh-model-row",children:[m.jsxs("span",{className:"uh-model-name",children:[m.jsx("span",{className:"uh-legend-dot",style:{background:Ql(A.modelName)}}),li(A.modelName)]}),m.jsx("span",{className:"uh-model-bar",children:m.jsx("span",{className:"uh-model-bar-fill",style:{width:`${M}%`,background:Ql(A.modelName)}})}),m.jsx("span",{className:"uh-model-cost",children:Fe(A.cost)})]},A.modelName)})})]})]})]})})}function Zl({label:e,val:n,accent:r}){return m.jsxs("div",{className:"uh-stat",children:[m.jsx("span",{className:`uh-stat-val${r?" accent":""}`,children:n}),m.jsx("span",{className:"uh-stat-label",children:e})]})}function Jl({label:e,val:n}){return m.jsxs("div",{className:"uh-ministat",children:[m.jsx("span",{className:"uh-ministat-val",children:n}),m.jsx("span",{className:"uh-ministat-label",children:e})]})}function Yv(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 Od,Qx;function qL(){if(Qx)return Od;Qx=1;function e(){this.__data__=[],this.size=0}return Od=e,Od}var Ld,Zx;function yo(){if(Zx)return Ld;Zx=1;function e(n,r){return n===r||n!==n&&r!==r}return Ld=e,Ld}var qd,Jx;function Cu(){if(Jx)return qd;Jx=1;var e=yo();function n(r,i){for(var o=r.length;o--;)if(e(r[o][0],i))return o;return-1}return qd=n,qd}var $d,e_;function $L(){if(e_)return $d;e_=1;var e=Cu(),n=Array.prototype,r=n.splice;function i(o){var l=this.__data__,u=e(l,o);if(u<0)return!1;var c=l.length-1;return u==c?l.pop():r.call(l,u,1),--this.size,!0}return $d=i,$d}var Dd,t_;function DL(){if(t_)return Dd;t_=1;var e=Cu();function n(r){var i=this.__data__,o=e(i,r);return o<0?void 0:i[o][1]}return Dd=n,Dd}var Fd,n_;function FL(){if(n_)return Fd;n_=1;var e=Cu();function n(r){return e(this.__data__,r)>-1}return Fd=n,Fd}var zd,r_;function zL(){if(r_)return zd;r_=1;var e=Cu();function n(r,i){var o=this.__data__,l=e(o,r);return l<0?(++this.size,o.push([r,i])):o[l][1]=i,this}return zd=n,zd}var Bd,s_;function ju(){if(s_)return Bd;s_=1;var e=qL(),n=$L(),r=DL(),i=FL(),o=zL();function l(u){var c=-1,p=u==null?0:u.length;for(this.clear();++c<p;){var f=u[c];this.set(f[0],f[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=i,l.prototype.set=o,Bd=l,Bd}var Ud,i_;function BL(){if(i_)return Ud;i_=1;var e=ju();function n(){this.__data__=new e,this.size=0}return Ud=n,Ud}var Hd,o_;function UL(){if(o_)return Hd;o_=1;function e(n){var r=this.__data__,i=r.delete(n);return this.size=r.size,i}return Hd=e,Hd}var Wd,a_;function HL(){if(a_)return Wd;a_=1;function e(n){return this.__data__.get(n)}return Wd=e,Wd}var Vd,l_;function WL(){if(l_)return Vd;l_=1;function e(n){return this.__data__.has(n)}return Vd=e,Vd}var Gd,u_;function vC(){if(u_)return Gd;u_=1;var e=typeof Ll=="object"&&Ll&&Ll.Object===Object&⋘return Gd=e,Gd}var Yd,c_;function tr(){if(c_)return Yd;c_=1;var e=vC(),n=typeof self=="object"&&self&&self.Object===Object&&self,r=e||n||Function("return this")();return Yd=r,Yd}var Kd,d_;function wo(){if(d_)return Kd;d_=1;var e=tr(),n=e.Symbol;return Kd=n,Kd}var Xd,f_;function VL(){if(f_)return Xd;f_=1;var e=wo(),n=Object.prototype,r=n.hasOwnProperty,i=n.toString,o=e?e.toStringTag:void 0;function l(u){var c=r.call(u,o),p=u[o];try{u[o]=void 0;var f=!0}catch{}var h=i.call(u);return f&&(c?u[o]=p:delete u[o]),h}return Xd=l,Xd}var Qd,h_;function GL(){if(h_)return Qd;h_=1;var e=Object.prototype,n=e.toString;function r(i){return n.call(i)}return Qd=r,Qd}var Zd,p_;function ui(){if(p_)return Zd;p_=1;var e=wo(),n=VL(),r=GL(),i="[object Null]",o="[object Undefined]",l=e?e.toStringTag:void 0;function u(c){return c==null?c===void 0?o:i:l&&l in Object(c)?n(c):r(c)}return Zd=u,Zd}var Jd,m_;function Ln(){if(m_)return Jd;m_=1;function e(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}return Jd=e,Jd}var ef,g_;function Oa(){if(g_)return ef;g_=1;var e=ui(),n=Ln(),r="[object AsyncFunction]",i="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function u(c){if(!n(c))return!1;var p=e(c);return p==i||p==o||p==r||p==l}return ef=u,ef}var tf,v_;function YL(){if(v_)return tf;v_=1;var e=tr(),n=e["__core-js_shared__"];return tf=n,tf}var nf,y_;function KL(){if(y_)return nf;y_=1;var e=YL(),n=(function(){var i=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""})();function r(i){return!!n&&n in i}return nf=r,nf}var rf,w_;function yC(){if(w_)return rf;w_=1;var e=Function.prototype,n=e.toString;function r(i){if(i!=null){try{return n.call(i)}catch{}try{return i+""}catch{}}return""}return rf=r,rf}var sf,x_;function XL(){if(x_)return sf;x_=1;var e=Oa(),n=KL(),r=Ln(),i=yC(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,p=u.toString,f=c.hasOwnProperty,h=RegExp("^"+p.call(f).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function g(y){if(!r(y)||n(y))return!1;var x=e(y)?h:l;return x.test(i(y))}return sf=g,sf}var of,__;function QL(){if(__)return of;__=1;function e(n,r){return n==null?void 0:n[r]}return of=e,of}var af,b_;function ci(){if(b_)return af;b_=1;var e=XL(),n=QL();function r(i,o){var l=n(i,o);return e(l)?l:void 0}return af=r,af}var lf,S_;function Kv(){if(S_)return lf;S_=1;var e=ci(),n=tr(),r=e(n,"Map");return lf=r,lf}var uf,k_;function Ru(){if(k_)return uf;k_=1;var e=ci(),n=e(Object,"create");return uf=n,uf}var cf,E_;function ZL(){if(E_)return cf;E_=1;var e=Ru();function n(){this.__data__=e?e(null):{},this.size=0}return cf=n,cf}var df,N_;function JL(){if(N_)return df;N_=1;function e(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}return df=e,df}var ff,C_;function eq(){if(C_)return ff;C_=1;var e=Ru(),n="__lodash_hash_undefined__",r=Object.prototype,i=r.hasOwnProperty;function o(l){var u=this.__data__;if(e){var c=u[l];return c===n?void 0:c}return i.call(u,l)?u[l]:void 0}return ff=o,ff}var hf,j_;function tq(){if(j_)return hf;j_=1;var e=Ru(),n=Object.prototype,r=n.hasOwnProperty;function i(o){var l=this.__data__;return e?l[o]!==void 0:r.call(l,o)}return hf=i,hf}var pf,R_;function nq(){if(R_)return pf;R_=1;var e=Ru(),n="__lodash_hash_undefined__";function r(i,o){var l=this.__data__;return this.size+=this.has(i)?0:1,l[i]=e&&o===void 0?n:o,this}return pf=r,pf}var mf,T_;function rq(){if(T_)return mf;T_=1;var e=ZL(),n=JL(),r=eq(),i=tq(),o=nq();function l(u){var c=-1,p=u==null?0:u.length;for(this.clear();++c<p;){var f=u[c];this.set(f[0],f[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=i,l.prototype.set=o,mf=l,mf}var gf,A_;function sq(){if(A_)return gf;A_=1;var e=rq(),n=ju(),r=Kv();function i(){this.size=0,this.__data__={hash:new e,map:new(r||n),string:new e}}return gf=i,gf}var vf,I_;function iq(){if(I_)return vf;I_=1;function e(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}return vf=e,vf}var yf,M_;function Tu(){if(M_)return yf;M_=1;var e=iq();function n(r,i){var o=r.__data__;return e(i)?o[typeof i=="string"?"string":"hash"]:o.map}return yf=n,yf}var wf,P_;function oq(){if(P_)return wf;P_=1;var e=Tu();function n(r){var i=e(this,r).delete(r);return this.size-=i?1:0,i}return wf=n,wf}var xf,O_;function aq(){if(O_)return xf;O_=1;var e=Tu();function n(r){return e(this,r).get(r)}return xf=n,xf}var _f,L_;function lq(){if(L_)return _f;L_=1;var e=Tu();function n(r){return e(this,r).has(r)}return _f=n,_f}var bf,q_;function uq(){if(q_)return bf;q_=1;var e=Tu();function n(r,i){var o=e(this,r),l=o.size;return o.set(r,i),this.size+=o.size==l?0:1,this}return bf=n,bf}var Sf,$_;function Xv(){if($_)return Sf;$_=1;var e=sq(),n=oq(),r=aq(),i=lq(),o=uq();function l(u){var c=-1,p=u==null?0:u.length;for(this.clear();++c<p;){var f=u[c];this.set(f[0],f[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=i,l.prototype.set=o,Sf=l,Sf}var kf,D_;function cq(){if(D_)return kf;D_=1;var e=ju(),n=Kv(),r=Xv(),i=200;function o(l,u){var c=this.__data__;if(c instanceof e){var p=c.__data__;if(!n||p.length<i-1)return p.push([l,u]),this.size=++c.size,this;c=this.__data__=new r(p)}return c.set(l,u),this.size=c.size,this}return kf=o,kf}var Ef,F_;function Au(){if(F_)return Ef;F_=1;var e=ju(),n=BL(),r=UL(),i=HL(),o=WL(),l=cq();function u(c){var p=this.__data__=new e(c);this.size=p.size}return u.prototype.clear=n,u.prototype.delete=r,u.prototype.get=i,u.prototype.has=o,u.prototype.set=l,Ef=u,Ef}var Nf,z_;function Qv(){if(z_)return Nf;z_=1;function e(n,r){for(var i=-1,o=n==null?0:n.length;++i<o&&r(n[i],i,n)!==!1;);return n}return Nf=e,Nf}var Cf,B_;function wC(){if(B_)return Cf;B_=1;var e=ci(),n=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return Cf=n,Cf}var jf,U_;function Iu(){if(U_)return jf;U_=1;var e=wC();function n(r,i,o){i=="__proto__"&&e?e(r,i,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[i]=o}return jf=n,jf}var Rf,H_;function Mu(){if(H_)return Rf;H_=1;var e=Iu(),n=yo(),r=Object.prototype,i=r.hasOwnProperty;function o(l,u,c){var p=l[u];(!(i.call(l,u)&&n(p,c))||c===void 0&&!(u in l))&&e(l,u,c)}return Rf=o,Rf}var Tf,W_;function La(){if(W_)return Tf;W_=1;var e=Mu(),n=Iu();function r(i,o,l,u){var c=!l;l||(l={});for(var p=-1,f=o.length;++p<f;){var h=o[p],g=u?u(l[h],i[h],h,l,i):void 0;g===void 0&&(g=i[h]),c?n(l,h,g):e(l,h,g)}return l}return Tf=r,Tf}var Af,V_;function dq(){if(V_)return Af;V_=1;function e(n,r){for(var i=-1,o=Array(n);++i<n;)o[i]=r(i);return o}return Af=e,Af}var If,G_;function vr(){if(G_)return If;G_=1;function e(n){return n!=null&&typeof n=="object"}return If=e,If}var Mf,Y_;function fq(){if(Y_)return Mf;Y_=1;var e=ui(),n=vr(),r="[object Arguments]";function i(o){return n(o)&&e(o)==r}return Mf=i,Mf}var Pf,K_;function qa(){if(K_)return Pf;K_=1;var e=fq(),n=vr(),r=Object.prototype,i=r.hasOwnProperty,o=r.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(u){return n(u)&&i.call(u,"callee")&&!o.call(u,"callee")};return Pf=l,Pf}var Of,X_;function bt(){if(X_)return Of;X_=1;var e=Array.isArray;return Of=e,Of}var va={exports:{}},Lf,Q_;function hq(){if(Q_)return Lf;Q_=1;function e(){return!1}return Lf=e,Lf}va.exports;var Z_;function xo(){return Z_||(Z_=1,(function(e,n){var r=tr(),i=hq(),o=n&&!n.nodeType&&n,l=o&&!0&&e&&!e.nodeType&&e,u=l&&l.exports===o,c=u?r.Buffer:void 0,p=c?c.isBuffer:void 0,f=p||i;e.exports=f})(va,va.exports)),va.exports}var qf,J_;function Pu(){if(J_)return qf;J_=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function r(i,o){var l=typeof i;return o=o??e,!!o&&(l=="number"||l!="symbol"&&n.test(i))&&i>-1&&i%1==0&&i<o}return qf=r,qf}var $f,e1;function Zv(){if(e1)return $f;e1=1;var e=9007199254740991;function n(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return $f=n,$f}var Df,t1;function pq(){if(t1)return Df;t1=1;var e=ui(),n=Zv(),r=vr(),i="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",p="[object Function]",f="[object Map]",h="[object Number]",g="[object Object]",y="[object RegExp]",x="[object Set]",N="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",k="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",A="[object Int16Array]",M="[object Int32Array]",L="[object Uint8Array]",H="[object Uint8ClampedArray]",O="[object Uint16Array]",P="[object Uint32Array]",F={};F[k]=F[E]=F[C]=F[A]=F[M]=F[L]=F[H]=F[O]=F[P]=!0,F[i]=F[o]=F[S]=F[l]=F[b]=F[u]=F[c]=F[p]=F[f]=F[h]=F[g]=F[y]=F[x]=F[N]=F[_]=!1;function G(q){return r(q)&&n(q.length)&&!!F[e(q)]}return Df=G,Df}var Ff,n1;function Ou(){if(n1)return Ff;n1=1;function e(n){return function(r){return n(r)}}return Ff=e,Ff}var ya={exports:{}};ya.exports;var r1;function Jv(){return r1||(r1=1,(function(e,n){var r=vC(),i=n&&!n.nodeType&&n,o=i&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===i,u=l&&r.process,c=(function(){try{var p=o&&o.require&&o.require("util").types;return p||u&&u.binding&&u.binding("util")}catch{}})();e.exports=c})(ya,ya.exports)),ya.exports}var zf,s1;function $a(){if(s1)return zf;s1=1;var e=pq(),n=Ou(),r=Jv(),i=r&&r.isTypedArray,o=i?n(i):e;return zf=o,zf}var Bf,i1;function xC(){if(i1)return Bf;i1=1;var e=dq(),n=qa(),r=bt(),i=xo(),o=Pu(),l=$a(),u=Object.prototype,c=u.hasOwnProperty;function p(f,h){var g=r(f),y=!g&&n(f),x=!g&&!y&&i(f),N=!g&&!y&&!x&&l(f),_=g||y||x||N,S=_?e(f.length,String):[],b=S.length;for(var k in f)(h||c.call(f,k))&&!(_&&(k=="length"||x&&(k=="offset"||k=="parent")||N&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||o(k,b)))&&S.push(k);return S}return Bf=p,Bf}var Uf,o1;function Lu(){if(o1)return Uf;o1=1;var e=Object.prototype;function n(r){var i=r&&r.constructor,o=typeof i=="function"&&i.prototype||e;return r===o}return Uf=n,Uf}var Hf,a1;function _C(){if(a1)return Hf;a1=1;function e(n,r){return function(i){return n(r(i))}}return Hf=e,Hf}var Wf,l1;function mq(){if(l1)return Wf;l1=1;var e=_C(),n=e(Object.keys,Object);return Wf=n,Wf}var Vf,u1;function ey(){if(u1)return Vf;u1=1;var e=Lu(),n=mq(),r=Object.prototype,i=r.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=[];for(var c in Object(l))i.call(l,c)&&c!="constructor"&&u.push(c);return u}return Vf=o,Vf}var Gf,c1;function Wr(){if(c1)return Gf;c1=1;var e=Oa(),n=Zv();function r(i){return i!=null&&n(i.length)&&!e(i)}return Gf=r,Gf}var Yf,d1;function ks(){if(d1)return Yf;d1=1;var e=xC(),n=ey(),r=Wr();function i(o){return r(o)?e(o):n(o)}return Yf=i,Yf}var Kf,f1;function gq(){if(f1)return Kf;f1=1;var e=La(),n=ks();function r(i,o){return i&&e(o,n(o),i)}return Kf=r,Kf}var Xf,h1;function vq(){if(h1)return Xf;h1=1;function e(n){var r=[];if(n!=null)for(var i in Object(n))r.push(i);return r}return Xf=e,Xf}var Qf,p1;function yq(){if(p1)return Qf;p1=1;var e=Ln(),n=Lu(),r=vq(),i=Object.prototype,o=i.hasOwnProperty;function l(u){if(!e(u))return r(u);var c=n(u),p=[];for(var f in u)f=="constructor"&&(c||!o.call(u,f))||p.push(f);return p}return Qf=l,Qf}var Zf,m1;function di(){if(m1)return Zf;m1=1;var e=xC(),n=yq(),r=Wr();function i(o){return r(o)?e(o,!0):n(o)}return Zf=i,Zf}var Jf,g1;function wq(){if(g1)return Jf;g1=1;var e=La(),n=di();function r(i,o){return i&&e(o,n(o),i)}return Jf=r,Jf}var wa={exports:{}};wa.exports;var v1;function bC(){return v1||(v1=1,(function(e,n){var r=tr(),i=n&&!n.nodeType&&n,o=i&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===i,u=l?r.Buffer:void 0,c=u?u.allocUnsafe:void 0;function p(f,h){if(h)return f.slice();var g=f.length,y=c?c(g):new f.constructor(g);return f.copy(y),y}e.exports=p})(wa,wa.exports)),wa.exports}var eh,y1;function SC(){if(y1)return eh;y1=1;function e(n,r){var i=-1,o=n.length;for(r||(r=Array(o));++i<o;)r[i]=n[i];return r}return eh=e,eh}var th,w1;function kC(){if(w1)return th;w1=1;function e(n,r){for(var i=-1,o=n==null?0:n.length,l=0,u=[];++i<o;){var c=n[i];r(c,i,n)&&(u[l++]=c)}return u}return th=e,th}var nh,x1;function EC(){if(x1)return nh;x1=1;function e(){return[]}return nh=e,nh}var rh,_1;function ty(){if(_1)return rh;_1=1;var e=kC(),n=EC(),r=Object.prototype,i=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,l=o?function(u){return u==null?[]:(u=Object(u),e(o(u),function(c){return i.call(u,c)}))}:n;return rh=l,rh}var sh,b1;function xq(){if(b1)return sh;b1=1;var e=La(),n=ty();function r(i,o){return e(i,n(i),o)}return sh=r,sh}var ih,S1;function ny(){if(S1)return ih;S1=1;function e(n,r){for(var i=-1,o=r.length,l=n.length;++i<o;)n[l+i]=r[i];return n}return ih=e,ih}var oh,k1;function qu(){if(k1)return oh;k1=1;var e=_C(),n=e(Object.getPrototypeOf,Object);return oh=n,oh}var ah,E1;function NC(){if(E1)return ah;E1=1;var e=ny(),n=qu(),r=ty(),i=EC(),o=Object.getOwnPropertySymbols,l=o?function(u){for(var c=[];u;)e(c,r(u)),u=n(u);return c}:i;return ah=l,ah}var lh,N1;function _q(){if(N1)return lh;N1=1;var e=La(),n=NC();function r(i,o){return e(i,n(i),o)}return lh=r,lh}var uh,C1;function CC(){if(C1)return uh;C1=1;var e=ny(),n=bt();function r(i,o,l){var u=o(i);return n(i)?u:e(u,l(i))}return uh=r,uh}var ch,j1;function jC(){if(j1)return ch;j1=1;var e=CC(),n=ty(),r=ks();function i(o){return e(o,r,n)}return ch=i,ch}var dh,R1;function bq(){if(R1)return dh;R1=1;var e=CC(),n=NC(),r=di();function i(o){return e(o,r,n)}return dh=i,dh}var fh,T1;function Sq(){if(T1)return fh;T1=1;var e=ci(),n=tr(),r=e(n,"DataView");return fh=r,fh}var hh,A1;function kq(){if(A1)return hh;A1=1;var e=ci(),n=tr(),r=e(n,"Promise");return hh=r,hh}var ph,I1;function RC(){if(I1)return ph;I1=1;var e=ci(),n=tr(),r=e(n,"Set");return ph=r,ph}var mh,M1;function Eq(){if(M1)return mh;M1=1;var e=ci(),n=tr(),r=e(n,"WeakMap");return mh=r,mh}var gh,P1;function _o(){if(P1)return gh;P1=1;var e=Sq(),n=Kv(),r=kq(),i=RC(),o=Eq(),l=ui(),u=yC(),c="[object Map]",p="[object Object]",f="[object Promise]",h="[object Set]",g="[object WeakMap]",y="[object DataView]",x=u(e),N=u(n),_=u(r),S=u(i),b=u(o),k=l;return(e&&k(new e(new ArrayBuffer(1)))!=y||n&&k(new n)!=c||r&&k(r.resolve())!=f||i&&k(new i)!=h||o&&k(new o)!=g)&&(k=function(E){var C=l(E),A=C==p?E.constructor:void 0,M=A?u(A):"";if(M)switch(M){case x:return y;case N:return c;case _:return f;case S:return h;case b:return g}return C}),gh=k,gh}var vh,O1;function Nq(){if(O1)return vh;O1=1;var e=Object.prototype,n=e.hasOwnProperty;function r(i){var o=i.length,l=new i.constructor(o);return o&&typeof i[0]=="string"&&n.call(i,"index")&&(l.index=i.index,l.input=i.input),l}return vh=r,vh}var yh,L1;function TC(){if(L1)return yh;L1=1;var e=tr(),n=e.Uint8Array;return yh=n,yh}var wh,q1;function ry(){if(q1)return wh;q1=1;var e=TC();function n(r){var i=new r.constructor(r.byteLength);return new e(i).set(new e(r)),i}return wh=n,wh}var xh,$1;function Cq(){if($1)return xh;$1=1;var e=ry();function n(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return xh=n,xh}var _h,D1;function jq(){if(D1)return _h;D1=1;var e=/\w*$/;function n(r){var i=new r.constructor(r.source,e.exec(r));return i.lastIndex=r.lastIndex,i}return _h=n,_h}var bh,F1;function Rq(){if(F1)return bh;F1=1;var e=wo(),n=e?e.prototype:void 0,r=n?n.valueOf:void 0;function i(o){return r?Object(r.call(o)):{}}return bh=i,bh}var Sh,z1;function AC(){if(z1)return Sh;z1=1;var e=ry();function n(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return Sh=n,Sh}var kh,B1;function Tq(){if(B1)return kh;B1=1;var e=ry(),n=Cq(),r=jq(),i=Rq(),o=AC(),l="[object Boolean]",u="[object Date]",c="[object Map]",p="[object Number]",f="[object RegExp]",h="[object Set]",g="[object String]",y="[object Symbol]",x="[object ArrayBuffer]",N="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",k="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",A="[object Uint8ClampedArray]",M="[object Uint16Array]",L="[object Uint32Array]";function H(O,P,F){var G=O.constructor;switch(P){case x:return e(O);case l:case u:return new G(+O);case N:return n(O,F);case _:case S:case b:case k:case E:case C:case A:case M:case L:return o(O,F);case c:return new G;case p:case g:return new G(O);case f:return r(O);case h:return new G;case y:return i(O)}}return kh=H,kh}var Eh,U1;function IC(){if(U1)return Eh;U1=1;var e=Ln(),n=Object.create,r=(function(){function i(){}return function(o){if(!e(o))return{};if(n)return n(o);i.prototype=o;var l=new i;return i.prototype=void 0,l}})();return Eh=r,Eh}var Nh,H1;function MC(){if(H1)return Nh;H1=1;var e=IC(),n=qu(),r=Lu();function i(o){return typeof o.constructor=="function"&&!r(o)?e(n(o)):{}}return Nh=i,Nh}var Ch,W1;function Aq(){if(W1)return Ch;W1=1;var e=_o(),n=vr(),r="[object Map]";function i(o){return n(o)&&e(o)==r}return Ch=i,Ch}var jh,V1;function Iq(){if(V1)return jh;V1=1;var e=Aq(),n=Ou(),r=Jv(),i=r&&r.isMap,o=i?n(i):e;return jh=o,jh}var Rh,G1;function Mq(){if(G1)return Rh;G1=1;var e=_o(),n=vr(),r="[object Set]";function i(o){return n(o)&&e(o)==r}return Rh=i,Rh}var Th,Y1;function Pq(){if(Y1)return Th;Y1=1;var e=Mq(),n=Ou(),r=Jv(),i=r&&r.isSet,o=i?n(i):e;return Th=o,Th}var Ah,K1;function PC(){if(K1)return Ah;K1=1;var e=Au(),n=Qv(),r=Mu(),i=gq(),o=wq(),l=bC(),u=SC(),c=xq(),p=_q(),f=jC(),h=bq(),g=_o(),y=Nq(),x=Tq(),N=MC(),_=bt(),S=xo(),b=Iq(),k=Ln(),E=Pq(),C=ks(),A=di(),M=1,L=2,H=4,O="[object Arguments]",P="[object Array]",F="[object Boolean]",G="[object Date]",q="[object Error]",R="[object Function]",Q="[object GeneratorFunction]",z="[object Map]",ne="[object Number]",Z="[object Object]",$="[object RegExp]",X="[object Set]",I="[object String]",W="[object Symbol]",Y="[object WeakMap]",U="[object ArrayBuffer]",J="[object DataView]",re="[object Float32Array]",le="[object Float64Array]",fe="[object Int8Array]",te="[object Int16Array]",ce="[object Int32Array]",Ce="[object Uint8Array]",ve="[object Uint8ClampedArray]",Te="[object Uint16Array]",ye="[object Uint32Array]",ke={};ke[O]=ke[P]=ke[U]=ke[J]=ke[F]=ke[G]=ke[re]=ke[le]=ke[fe]=ke[te]=ke[ce]=ke[z]=ke[ne]=ke[Z]=ke[$]=ke[X]=ke[I]=ke[W]=ke[Ce]=ke[ve]=ke[Te]=ke[ye]=!0,ke[q]=ke[R]=ke[Y]=!1;function Ge(we,_e,ze,ft,ht,Ue){var De,Ze=_e&M,Ye=_e&L,vt=_e&H;if(ze&&(De=ht?ze(we,ft,ht,Ue):ze(we)),De!==void 0)return De;if(!k(we))return we;var ot=_(we);if(ot){if(De=y(we),!Ze)return u(we,De)}else{var yt=g(we),Kt=yt==R||yt==Q;if(S(we))return l(we,Ze);if(yt==Z||yt==O||Kt&&!ht){if(De=Ye||Kt?{}:N(we),!Ze)return Ye?p(we,o(De,we)):c(we,i(De,we))}else{if(!ke[yt])return ht?we:{};De=x(we,yt,Ze)}}Ue||(Ue=new e);var Mt=Ue.get(we);if(Mt)return Mt;Ue.set(we,De),E(we)?we.forEach(function(pt){De.add(Ge(pt,_e,ze,pt,we,Ue))}):b(we)&&we.forEach(function(pt,mt){De.set(mt,Ge(pt,_e,ze,mt,we,Ue))});var Xe=vt?Ye?h:f:Ye?A:C,wt=ot?void 0:Xe(we);return n(wt||we,function(pt,mt){wt&&(mt=pt,pt=we[mt]),r(De,mt,Ge(pt,_e,ze,mt,we,Ue))}),De}return Ah=Ge,Ah}var Ih,X1;function Oq(){if(X1)return Ih;X1=1;var e=PC(),n=4;function r(i){return e(i,n)}return Ih=r,Ih}var Mh,Q1;function sy(){if(Q1)return Mh;Q1=1;function e(n){return function(){return n}}return Mh=e,Mh}var Ph,Z1;function Lq(){if(Z1)return Ph;Z1=1;function e(n){return function(r,i,o){for(var l=-1,u=Object(r),c=o(r),p=c.length;p--;){var f=c[n?p:++l];if(i(u[f],f,u)===!1)break}return r}}return Ph=e,Ph}var Oh,J1;function iy(){if(J1)return Oh;J1=1;var e=Lq(),n=e();return Oh=n,Oh}var Lh,eb;function oy(){if(eb)return Lh;eb=1;var e=iy(),n=ks();function r(i,o){return i&&e(i,o,n)}return Lh=r,Lh}var qh,tb;function qq(){if(tb)return qh;tb=1;var e=Wr();function n(r,i){return function(o,l){if(o==null)return o;if(!e(o))return r(o,l);for(var u=o.length,c=i?u:-1,p=Object(o);(i?c--:++c<u)&&l(p[c],c,p)!==!1;);return o}}return qh=n,qh}var $h,nb;function $u(){if(nb)return $h;nb=1;var e=oy(),n=qq(),r=n(e);return $h=r,$h}var Dh,rb;function fi(){if(rb)return Dh;rb=1;function e(n){return n}return Dh=e,Dh}var Fh,sb;function OC(){if(sb)return Fh;sb=1;var e=fi();function n(r){return typeof r=="function"?r:e}return Fh=n,Fh}var zh,ib;function LC(){if(ib)return zh;ib=1;var e=Qv(),n=$u(),r=OC(),i=bt();function o(l,u){var c=i(l)?e:n;return c(l,r(u))}return zh=o,zh}var Bh,ob;function qC(){return ob||(ob=1,Bh=LC()),Bh}var Uh,ab;function $q(){if(ab)return Uh;ab=1;var e=$u();function n(r,i){var o=[];return e(r,function(l,u,c){i(l,u,c)&&o.push(l)}),o}return Uh=n,Uh}var Hh,lb;function Dq(){if(lb)return Hh;lb=1;var e="__lodash_hash_undefined__";function n(r){return this.__data__.set(r,e),this}return Hh=n,Hh}var Wh,ub;function Fq(){if(ub)return Wh;ub=1;function e(n){return this.__data__.has(n)}return Wh=e,Wh}var Vh,cb;function $C(){if(cb)return Vh;cb=1;var e=Xv(),n=Dq(),r=Fq();function i(o){var l=-1,u=o==null?0:o.length;for(this.__data__=new e;++l<u;)this.add(o[l])}return i.prototype.add=i.prototype.push=n,i.prototype.has=r,Vh=i,Vh}var Gh,db;function zq(){if(db)return Gh;db=1;function e(n,r){for(var i=-1,o=n==null?0:n.length;++i<o;)if(r(n[i],i,n))return!0;return!1}return Gh=e,Gh}var Yh,fb;function DC(){if(fb)return Yh;fb=1;function e(n,r){return n.has(r)}return Yh=e,Yh}var Kh,hb;function FC(){if(hb)return Kh;hb=1;var e=$C(),n=zq(),r=DC(),i=1,o=2;function l(u,c,p,f,h,g){var y=p&i,x=u.length,N=c.length;if(x!=N&&!(y&&N>x))return!1;var _=g.get(u),S=g.get(c);if(_&&S)return _==c&&S==u;var b=-1,k=!0,E=p&o?new e:void 0;for(g.set(u,c),g.set(c,u);++b<x;){var C=u[b],A=c[b];if(f)var M=y?f(A,C,b,c,u,g):f(C,A,b,u,c,g);if(M!==void 0){if(M)continue;k=!1;break}if(E){if(!n(c,function(L,H){if(!r(E,H)&&(C===L||h(C,L,p,f,g)))return E.push(H)})){k=!1;break}}else if(!(C===A||h(C,A,p,f,g))){k=!1;break}}return g.delete(u),g.delete(c),k}return Kh=l,Kh}var Xh,pb;function Bq(){if(pb)return Xh;pb=1;function e(n){var r=-1,i=Array(n.size);return n.forEach(function(o,l){i[++r]=[l,o]}),i}return Xh=e,Xh}var Qh,mb;function ay(){if(mb)return Qh;mb=1;function e(n){var r=-1,i=Array(n.size);return n.forEach(function(o){i[++r]=o}),i}return Qh=e,Qh}var Zh,gb;function Uq(){if(gb)return Zh;gb=1;var e=wo(),n=TC(),r=yo(),i=FC(),o=Bq(),l=ay(),u=1,c=2,p="[object Boolean]",f="[object Date]",h="[object Error]",g="[object Map]",y="[object Number]",x="[object RegExp]",N="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",k="[object DataView]",E=e?e.prototype:void 0,C=E?E.valueOf:void 0;function A(M,L,H,O,P,F,G){switch(H){case k:if(M.byteLength!=L.byteLength||M.byteOffset!=L.byteOffset)return!1;M=M.buffer,L=L.buffer;case b:return!(M.byteLength!=L.byteLength||!F(new n(M),new n(L)));case p:case f:case y:return r(+M,+L);case h:return M.name==L.name&&M.message==L.message;case x:case _:return M==L+"";case g:var q=o;case N:var R=O&u;if(q||(q=l),M.size!=L.size&&!R)return!1;var Q=G.get(M);if(Q)return Q==L;O|=c,G.set(M,L);var z=i(q(M),q(L),O,P,F,G);return G.delete(M),z;case S:if(C)return C.call(M)==C.call(L)}return!1}return Zh=A,Zh}var Jh,vb;function Hq(){if(vb)return Jh;vb=1;var e=jC(),n=1,r=Object.prototype,i=r.hasOwnProperty;function o(l,u,c,p,f,h){var g=c&n,y=e(l),x=y.length,N=e(u),_=N.length;if(x!=_&&!g)return!1;for(var S=x;S--;){var b=y[S];if(!(g?b in u:i.call(u,b)))return!1}var k=h.get(l),E=h.get(u);if(k&&E)return k==u&&E==l;var C=!0;h.set(l,u),h.set(u,l);for(var A=g;++S<x;){b=y[S];var M=l[b],L=u[b];if(p)var H=g?p(L,M,b,u,l,h):p(M,L,b,l,u,h);if(!(H===void 0?M===L||f(M,L,c,p,h):H)){C=!1;break}A||(A=b=="constructor")}if(C&&!A){var O=l.constructor,P=u.constructor;O!=P&&"constructor"in l&&"constructor"in u&&!(typeof O=="function"&&O instanceof O&&typeof P=="function"&&P instanceof P)&&(C=!1)}return h.delete(l),h.delete(u),C}return Jh=o,Jh}var ep,yb;function Wq(){if(yb)return ep;yb=1;var e=Au(),n=FC(),r=Uq(),i=Hq(),o=_o(),l=bt(),u=xo(),c=$a(),p=1,f="[object Arguments]",h="[object Array]",g="[object Object]",y=Object.prototype,x=y.hasOwnProperty;function N(_,S,b,k,E,C){var A=l(_),M=l(S),L=A?h:o(_),H=M?h:o(S);L=L==f?g:L,H=H==f?g:H;var O=L==g,P=H==g,F=L==H;if(F&&u(_)){if(!u(S))return!1;A=!0,O=!1}if(F&&!O)return C||(C=new e),A||c(_)?n(_,S,b,k,E,C):r(_,S,L,b,k,E,C);if(!(b&p)){var G=O&&x.call(_,"__wrapped__"),q=P&&x.call(S,"__wrapped__");if(G||q){var R=G?_.value():_,Q=q?S.value():S;return C||(C=new e),E(R,Q,b,k,C)}}return F?(C||(C=new e),i(_,S,b,k,E,C)):!1}return ep=N,ep}var tp,wb;function zC(){if(wb)return tp;wb=1;var e=Wq(),n=vr();function r(i,o,l,u,c){return i===o?!0:i==null||o==null||!n(i)&&!n(o)?i!==i&&o!==o:e(i,o,l,u,r,c)}return tp=r,tp}var np,xb;function Vq(){if(xb)return np;xb=1;var e=Au(),n=zC(),r=1,i=2;function o(l,u,c,p){var f=c.length,h=f,g=!p;if(l==null)return!h;for(l=Object(l);f--;){var y=c[f];if(g&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++f<h;){y=c[f];var x=y[0],N=l[x],_=y[1];if(g&&y[2]){if(N===void 0&&!(x in l))return!1}else{var S=new e;if(p)var b=p(N,_,x,l,u,S);if(!(b===void 0?n(_,N,r|i,p,S):b))return!1}}return!0}return np=o,np}var rp,_b;function BC(){if(_b)return rp;_b=1;var e=Ln();function n(r){return r===r&&!e(r)}return rp=n,rp}var sp,bb;function Gq(){if(bb)return sp;bb=1;var e=BC(),n=ks();function r(i){for(var o=n(i),l=o.length;l--;){var u=o[l],c=i[u];o[l]=[u,c,e(c)]}return o}return sp=r,sp}var ip,Sb;function UC(){if(Sb)return ip;Sb=1;function e(n,r){return function(i){return i==null?!1:i[n]===r&&(r!==void 0||n in Object(i))}}return ip=e,ip}var op,kb;function Yq(){if(kb)return op;kb=1;var e=Vq(),n=Gq(),r=UC();function i(o){var l=n(o);return l.length==1&&l[0][2]?r(l[0][0],l[0][1]):function(u){return u===o||e(u,o,l)}}return op=i,op}var ap,Eb;function bo(){if(Eb)return ap;Eb=1;var e=ui(),n=vr(),r="[object Symbol]";function i(o){return typeof o=="symbol"||n(o)&&e(o)==r}return ap=i,ap}var lp,Nb;function ly(){if(Nb)return lp;Nb=1;var e=bt(),n=bo(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i=/^\w*$/;function o(l,u){if(e(l))return!1;var c=typeof l;return c=="number"||c=="symbol"||c=="boolean"||l==null||n(l)?!0:i.test(l)||!r.test(l)||u!=null&&l in Object(u)}return lp=o,lp}var up,Cb;function Kq(){if(Cb)return up;Cb=1;var e=Xv(),n="Expected a function";function r(i,o){if(typeof i!="function"||o!=null&&typeof o!="function")throw new TypeError(n);var l=function(){var u=arguments,c=o?o.apply(this,u):u[0],p=l.cache;if(p.has(c))return p.get(c);var f=i.apply(this,u);return l.cache=p.set(c,f)||p,f};return l.cache=new(r.Cache||e),l}return r.Cache=e,up=r,up}var cp,jb;function Xq(){if(jb)return cp;jb=1;var e=Kq(),n=500;function r(i){var o=e(i,function(u){return l.size===n&&l.clear(),u}),l=o.cache;return o}return cp=r,cp}var dp,Rb;function Qq(){if(Rb)return dp;Rb=1;var e=Xq(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,i=e(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(n,function(u,c,p,f){l.push(p?f.replace(r,"$1"):c||u)}),l});return dp=i,dp}var fp,Tb;function Du(){if(Tb)return fp;Tb=1;function e(n,r){for(var i=-1,o=n==null?0:n.length,l=Array(o);++i<o;)l[i]=r(n[i],i,n);return l}return fp=e,fp}var hp,Ab;function Zq(){if(Ab)return hp;Ab=1;var e=wo(),n=Du(),r=bt(),i=bo(),o=e?e.prototype:void 0,l=o?o.toString:void 0;function u(c){if(typeof c=="string")return c;if(r(c))return n(c,u)+"";if(i(c))return l?l.call(c):"";var p=c+"";return p=="0"&&1/c==-1/0?"-0":p}return hp=u,hp}var pp,Ib;function HC(){if(Ib)return pp;Ib=1;var e=Zq();function n(r){return r==null?"":e(r)}return pp=n,pp}var mp,Mb;function Fu(){if(Mb)return mp;Mb=1;var e=bt(),n=ly(),r=Qq(),i=HC();function o(l,u){return e(l)?l:n(l,u)?[l]:r(i(l))}return mp=o,mp}var gp,Pb;function Da(){if(Pb)return gp;Pb=1;var e=bo();function n(r){if(typeof r=="string"||e(r))return r;var i=r+"";return i=="0"&&1/r==-1/0?"-0":i}return gp=n,gp}var vp,Ob;function zu(){if(Ob)return vp;Ob=1;var e=Fu(),n=Da();function r(i,o){o=e(o,i);for(var l=0,u=o.length;i!=null&&l<u;)i=i[n(o[l++])];return l&&l==u?i:void 0}return vp=r,vp}var yp,Lb;function Jq(){if(Lb)return yp;Lb=1;var e=zu();function n(r,i,o){var l=r==null?void 0:e(r,i);return l===void 0?o:l}return yp=n,yp}var wp,qb;function e$(){if(qb)return wp;qb=1;function e(n,r){return n!=null&&r in Object(n)}return wp=e,wp}var xp,$b;function WC(){if($b)return xp;$b=1;var e=Fu(),n=qa(),r=bt(),i=Pu(),o=Zv(),l=Da();function u(c,p,f){p=e(p,c);for(var h=-1,g=p.length,y=!1;++h<g;){var x=l(p[h]);if(!(y=c!=null&&f(c,x)))break;c=c[x]}return y||++h!=g?y:(g=c==null?0:c.length,!!g&&o(g)&&i(x,g)&&(r(c)||n(c)))}return xp=u,xp}var _p,Db;function VC(){if(Db)return _p;Db=1;var e=e$(),n=WC();function r(i,o){return i!=null&&n(i,o,e)}return _p=r,_p}var bp,Fb;function t$(){if(Fb)return bp;Fb=1;var e=zC(),n=Jq(),r=VC(),i=ly(),o=BC(),l=UC(),u=Da(),c=1,p=2;function f(h,g){return i(h)&&o(g)?l(u(h),g):function(y){var x=n(y,h);return x===void 0&&x===g?r(y,h):e(g,x,c|p)}}return bp=f,bp}var Sp,zb;function GC(){if(zb)return Sp;zb=1;function e(n){return function(r){return r==null?void 0:r[n]}}return Sp=e,Sp}var kp,Bb;function n$(){if(Bb)return kp;Bb=1;var e=zu();function n(r){return function(i){return e(i,r)}}return kp=n,kp}var Ep,Ub;function r$(){if(Ub)return Ep;Ub=1;var e=GC(),n=n$(),r=ly(),i=Da();function o(l){return r(l)?e(i(l)):n(l)}return Ep=o,Ep}var Np,Hb;function Vr(){if(Hb)return Np;Hb=1;var e=Yq(),n=t$(),r=fi(),i=bt(),o=r$();function l(u){return typeof u=="function"?u:u==null?r:typeof u=="object"?i(u)?n(u[0],u[1]):e(u):o(u)}return Np=l,Np}var Cp,Wb;function YC(){if(Wb)return Cp;Wb=1;var e=kC(),n=$q(),r=Vr(),i=bt();function o(l,u){var c=i(l)?e:n;return c(l,r(u,3))}return Cp=o,Cp}var jp,Vb;function s$(){if(Vb)return jp;Vb=1;var e=Object.prototype,n=e.hasOwnProperty;function r(i,o){return i!=null&&n.call(i,o)}return jp=r,jp}var Rp,Gb;function KC(){if(Gb)return Rp;Gb=1;var e=s$(),n=WC();function r(i,o){return i!=null&&n(i,o,e)}return Rp=r,Rp}var Tp,Yb;function i$(){if(Yb)return Tp;Yb=1;var e=ey(),n=_o(),r=qa(),i=bt(),o=Wr(),l=xo(),u=Lu(),c=$a(),p="[object Map]",f="[object Set]",h=Object.prototype,g=h.hasOwnProperty;function y(x){if(x==null)return!0;if(o(x)&&(i(x)||typeof x=="string"||typeof x.splice=="function"||l(x)||c(x)||r(x)))return!x.length;var N=n(x);if(N==p||N==f)return!x.size;if(u(x))return!e(x).length;for(var _ in x)if(g.call(x,_))return!1;return!0}return Tp=y,Tp}var Ap,Kb;function XC(){if(Kb)return Ap;Kb=1;function e(n){return n===void 0}return Ap=e,Ap}var Ip,Xb;function QC(){if(Xb)return Ip;Xb=1;var e=$u(),n=Wr();function r(i,o){var l=-1,u=n(i)?Array(i.length):[];return e(i,function(c,p,f){u[++l]=o(c,p,f)}),u}return Ip=r,Ip}var Mp,Qb;function ZC(){if(Qb)return Mp;Qb=1;var e=Du(),n=Vr(),r=QC(),i=bt();function o(l,u){var c=i(l)?e:r;return c(l,n(u,3))}return Mp=o,Mp}var Pp,Zb;function o$(){if(Zb)return Pp;Zb=1;function e(n,r,i,o){var l=-1,u=n==null?0:n.length;for(o&&u&&(i=n[++l]);++l<u;)i=r(i,n[l],l,n);return i}return Pp=e,Pp}var Op,Jb;function a$(){if(Jb)return Op;Jb=1;function e(n,r,i,o,l){return l(n,function(u,c,p){i=o?(o=!1,u):r(i,u,c,p)}),i}return Op=e,Op}var Lp,eS;function JC(){if(eS)return Lp;eS=1;var e=o$(),n=$u(),r=Vr(),i=a$(),o=bt();function l(u,c,p){var f=o(u)?e:i,h=arguments.length<3;return f(u,r(c,4),p,h,n)}return Lp=l,Lp}var qp,tS;function l$(){if(tS)return qp;tS=1;var e=ui(),n=bt(),r=vr(),i="[object String]";function o(l){return typeof l=="string"||!n(l)&&r(l)&&e(l)==i}return qp=o,qp}var $p,nS;function u$(){if(nS)return $p;nS=1;var e=GC(),n=e("length");return $p=n,$p}var Dp,rS;function c$(){if(rS)return Dp;rS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",o=n+r+i,l="\\ufe0e\\ufe0f",u="\\u200d",c=RegExp("["+u+e+o+l+"]");function p(f){return c.test(f)}return Dp=p,Dp}var Fp,sS;function d$(){if(sS)return Fp;sS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",o=n+r+i,l="\\ufe0e\\ufe0f",u="["+e+"]",c="["+o+"]",p="\\ud83c[\\udffb-\\udfff]",f="(?:"+c+"|"+p+")",h="[^"+e+"]",g="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",x="\\u200d",N=f+"?",_="["+l+"]?",S="(?:"+x+"(?:"+[h,g,y].join("|")+")"+_+N+")*",b=_+N+S,k="(?:"+[h+c+"?",c,g,y,u].join("|")+")",E=RegExp(p+"(?="+p+")|"+k+b,"g");function C(A){for(var M=E.lastIndex=0;E.test(A);)++M;return M}return Fp=C,Fp}var zp,iS;function f$(){if(iS)return zp;iS=1;var e=u$(),n=c$(),r=d$();function i(o){return n(o)?r(o):e(o)}return zp=i,zp}var Bp,oS;function h$(){if(oS)return Bp;oS=1;var e=ey(),n=_o(),r=Wr(),i=l$(),o=f$(),l="[object Map]",u="[object Set]";function c(p){if(p==null)return 0;if(r(p))return i(p)?o(p):p.length;var f=n(p);return f==l||f==u?p.size:e(p).length}return Bp=c,Bp}var Up,aS;function p$(){if(aS)return Up;aS=1;var e=Qv(),n=IC(),r=oy(),i=Vr(),o=qu(),l=bt(),u=xo(),c=Oa(),p=Ln(),f=$a();function h(g,y,x){var N=l(g),_=N||u(g)||f(g);if(y=i(y,4),x==null){var S=g&&g.constructor;_?x=N?new S:[]:p(g)?x=c(S)?n(o(g)):{}:x={}}return(_?e:r)(g,function(b,k,E){return y(x,b,k,E)}),x}return Up=h,Up}var Hp,lS;function m$(){if(lS)return Hp;lS=1;var e=wo(),n=qa(),r=bt(),i=e?e.isConcatSpreadable:void 0;function o(l){return r(l)||n(l)||!!(i&&l&&l[i])}return Hp=o,Hp}var Wp,uS;function uy(){if(uS)return Wp;uS=1;var e=ny(),n=m$();function r(i,o,l,u,c){var p=-1,f=i.length;for(l||(l=n),c||(c=[]);++p<f;){var h=i[p];o>0&&l(h)?o>1?r(h,o-1,l,u,c):e(c,h):u||(c[c.length]=h)}return c}return Wp=r,Wp}var Vp,cS;function g$(){if(cS)return Vp;cS=1;function e(n,r,i){switch(i.length){case 0:return n.call(r);case 1:return n.call(r,i[0]);case 2:return n.call(r,i[0],i[1]);case 3:return n.call(r,i[0],i[1],i[2])}return n.apply(r,i)}return Vp=e,Vp}var Gp,dS;function ej(){if(dS)return Gp;dS=1;var e=g$(),n=Math.max;function r(i,o,l){return o=n(o===void 0?i.length-1:o,0),function(){for(var u=arguments,c=-1,p=n(u.length-o,0),f=Array(p);++c<p;)f[c]=u[o+c];c=-1;for(var h=Array(o+1);++c<o;)h[c]=u[c];return h[o]=l(f),e(i,this,h)}}return Gp=r,Gp}var Yp,fS;function v$(){if(fS)return Yp;fS=1;var e=sy(),n=wC(),r=fi(),i=n?function(o,l){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:r;return Yp=i,Yp}var Kp,hS;function y$(){if(hS)return Kp;hS=1;var e=800,n=16,r=Date.now;function i(o){var l=0,u=0;return function(){var c=r(),p=n-(c-u);if(u=c,p>0){if(++l>=e)return arguments[0]}else l=0;return o.apply(void 0,arguments)}}return Kp=i,Kp}var Xp,pS;function tj(){if(pS)return Xp;pS=1;var e=v$(),n=y$(),r=n(e);return Xp=r,Xp}var Qp,mS;function Bu(){if(mS)return Qp;mS=1;var e=fi(),n=ej(),r=tj();function i(o,l){return r(n(o,l,e),o+"")}return Qp=i,Qp}var Zp,gS;function nj(){if(gS)return Zp;gS=1;function e(n,r,i,o){for(var l=n.length,u=i+(o?1:-1);o?u--:++u<l;)if(r(n[u],u,n))return u;return-1}return Zp=e,Zp}var Jp,vS;function w$(){if(vS)return Jp;vS=1;function e(n){return n!==n}return Jp=e,Jp}var em,yS;function x$(){if(yS)return em;yS=1;function e(n,r,i){for(var o=i-1,l=n.length;++o<l;)if(n[o]===r)return o;return-1}return em=e,em}var tm,wS;function _$(){if(wS)return tm;wS=1;var e=nj(),n=w$(),r=x$();function i(o,l,u){return l===l?r(o,l,u):e(o,n,u)}return tm=i,tm}var nm,xS;function b$(){if(xS)return nm;xS=1;var e=_$();function n(r,i){var o=r==null?0:r.length;return!!o&&e(r,i,0)>-1}return nm=n,nm}var rm,_S;function S$(){if(_S)return rm;_S=1;function e(n,r,i){for(var o=-1,l=n==null?0:n.length;++o<l;)if(i(r,n[o]))return!0;return!1}return rm=e,rm}var sm,bS;function k$(){if(bS)return sm;bS=1;function e(){}return sm=e,sm}var im,SS;function E$(){if(SS)return im;SS=1;var e=RC(),n=k$(),r=ay(),i=1/0,o=e&&1/r(new e([,-0]))[1]==i?function(l){return new e(l)}:n;return im=o,im}var om,kS;function N$(){if(kS)return om;kS=1;var e=$C(),n=b$(),r=S$(),i=DC(),o=E$(),l=ay(),u=200;function c(p,f,h){var g=-1,y=n,x=p.length,N=!0,_=[],S=_;if(h)N=!1,y=r;else if(x>=u){var b=f?null:o(p);if(b)return l(b);N=!1,y=i,S=new e}else S=f?[]:_;e:for(;++g<x;){var k=p[g],E=f?f(k):k;if(k=h||k!==0?k:0,N&&E===E){for(var C=S.length;C--;)if(S[C]===E)continue e;f&&S.push(E),_.push(k)}else y(S,E,h)||(S!==_&&S.push(E),_.push(k))}return _}return om=c,om}var am,ES;function rj(){if(ES)return am;ES=1;var e=Wr(),n=vr();function r(i){return n(i)&&e(i)}return am=r,am}var lm,NS;function C$(){if(NS)return lm;NS=1;var e=uy(),n=Bu(),r=N$(),i=rj(),o=n(function(l){return r(e(l,1,i,!0))});return lm=o,lm}var um,CS;function j$(){if(CS)return um;CS=1;var e=Du();function n(r,i){return e(i,function(o){return r[o]})}return um=n,um}var cm,jS;function sj(){if(jS)return cm;jS=1;var e=j$(),n=ks();function r(i){return i==null?[]:e(i,n(i))}return cm=r,cm}var dm,RS;function qn(){if(RS)return dm;RS=1;var e;if(typeof Yv=="function")try{e={clone:Oq(),constant:sy(),each:qC(),filter:YC(),has:KC(),isArray:bt(),isEmpty:i$(),isFunction:Oa(),isUndefined:XC(),keys:ks(),map:ZC(),reduce:JC(),size:h$(),transform:p$(),union:C$(),values:sj()}}catch{}return e||(e=window._),dm=e,dm}var fm,TS;function cy(){if(TS)return fm;TS=1;var e=qn();fm=o;var n="\0",r="\0",i="";function o(h){this._isDirected=e.has(h,"directed")?h.directed:!0,this._isMultigraph=e.has(h,"multigraph")?h.multigraph:!1,this._isCompound=e.has(h,"compound")?h.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[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(h){return this._label=h,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultNodeLabelFn=h,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var h=this;return e.filter(this.nodes(),function(g){return e.isEmpty(h._in[g])})},o.prototype.sinks=function(){var h=this;return e.filter(this.nodes(),function(g){return e.isEmpty(h._out[g])})},o.prototype.setNodes=function(h,g){var y=arguments,x=this;return e.each(h,function(N){y.length>1?x.setNode(N,g):x.setNode(N)}),this},o.prototype.setNode=function(h,g){return e.has(this._nodes,h)?(arguments.length>1&&(this._nodes[h]=g),this):(this._nodes[h]=arguments.length>1?g:this._defaultNodeLabelFn(h),this._isCompound&&(this._parent[h]=r,this._children[h]={},this._children[r][h]=!0),this._in[h]={},this._preds[h]={},this._out[h]={},this._sucs[h]={},++this._nodeCount,this)},o.prototype.node=function(h){return this._nodes[h]},o.prototype.hasNode=function(h){return e.has(this._nodes,h)},o.prototype.removeNode=function(h){var g=this;if(e.has(this._nodes,h)){var y=function(x){g.removeEdge(g._edgeObjs[x])};delete this._nodes[h],this._isCompound&&(this._removeFromParentsChildList(h),delete this._parent[h],e.each(this.children(h),function(x){g.setParent(x)}),delete this._children[h]),e.each(e.keys(this._in[h]),y),delete this._in[h],delete this._preds[h],e.each(e.keys(this._out[h]),y),delete this._out[h],delete this._sucs[h],--this._nodeCount}return this},o.prototype.setParent=function(h,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===h)throw new Error("Setting "+g+" as parent of "+h+" would create a cycle");this.setNode(g)}return this.setNode(h),this._removeFromParentsChildList(h),this._parent[h]=g,this._children[g][h]=!0,this},o.prototype._removeFromParentsChildList=function(h){delete this._children[this._parent[h]][h]},o.prototype.parent=function(h){if(this._isCompound){var g=this._parent[h];if(g!==r)return g}},o.prototype.children=function(h){if(e.isUndefined(h)&&(h=r),this._isCompound){var g=this._children[h];if(g)return e.keys(g)}else{if(h===r)return this.nodes();if(this.hasNode(h))return[]}},o.prototype.predecessors=function(h){var g=this._preds[h];if(g)return e.keys(g)},o.prototype.successors=function(h){var g=this._sucs[h];if(g)return e.keys(g)},o.prototype.neighbors=function(h){var g=this.predecessors(h);if(g)return e.union(g,this.successors(h))},o.prototype.isLeaf=function(h){var g;return this.isDirected()?g=this.successors(h):g=this.neighbors(h),g.length===0},o.prototype.filterNodes=function(h){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(_,S){h(S)&&g.setNode(S,_)}),e.each(this._edgeObjs,function(_){g.hasNode(_.v)&&g.hasNode(_.w)&&g.setEdge(_,y.edge(_))});var x={};function N(_){var S=y.parent(_);return S===void 0||g.hasNode(S)?(x[_]=S,S):S in x?x[S]:N(S)}return this._isCompound&&e.each(g.nodes(),function(_){g.setParent(_,N(_))}),g},o.prototype.setDefaultEdgeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultEdgeLabelFn=h,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(h,g){var y=this,x=arguments;return e.reduce(h,function(N,_){return x.length>1?y.setEdge(N,_,g):y.setEdge(N,_),_}),this},o.prototype.setEdge=function(){var h,g,y,x,N=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(h=_.v,g=_.w,y=_.name,arguments.length===2&&(x=arguments[1],N=!0)):(h=_,g=arguments[1],y=arguments[3],arguments.length>2&&(x=arguments[2],N=!0)),h=""+h,g=""+g,e.isUndefined(y)||(y=""+y);var S=c(this._isDirected,h,g,y);if(e.has(this._edgeLabels,S))return N&&(this._edgeLabels[S]=x),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(h),this.setNode(g),this._edgeLabels[S]=N?x:this._defaultEdgeLabelFn(h,g,y);var b=p(this._isDirected,h,g,y);return h=b.v,g=b.w,Object.freeze(b),this._edgeObjs[S]=b,l(this._preds[g],h),l(this._sucs[h],g),this._in[g][S]=b,this._out[h][S]=b,this._edgeCount++,this},o.prototype.edge=function(h,g,y){var x=arguments.length===1?f(this._isDirected,arguments[0]):c(this._isDirected,h,g,y);return this._edgeLabels[x]},o.prototype.hasEdge=function(h,g,y){var x=arguments.length===1?f(this._isDirected,arguments[0]):c(this._isDirected,h,g,y);return e.has(this._edgeLabels,x)},o.prototype.removeEdge=function(h,g,y){var x=arguments.length===1?f(this._isDirected,arguments[0]):c(this._isDirected,h,g,y),N=this._edgeObjs[x];return N&&(h=N.v,g=N.w,delete this._edgeLabels[x],delete this._edgeObjs[x],u(this._preds[g],h),u(this._sucs[h],g),delete this._in[g][x],delete this._out[h][x],this._edgeCount--),this},o.prototype.inEdges=function(h,g){var y=this._in[h];if(y){var x=e.values(y);return g?e.filter(x,function(N){return N.v===g}):x}},o.prototype.outEdges=function(h,g){var y=this._out[h];if(y){var x=e.values(y);return g?e.filter(x,function(N){return N.w===g}):x}},o.prototype.nodeEdges=function(h,g){var y=this.inEdges(h,g);if(y)return y.concat(this.outEdges(h,g))};function l(h,g){h[g]?h[g]++:h[g]=1}function u(h,g){--h[g]||delete h[g]}function c(h,g,y,x){var N=""+g,_=""+y;if(!h&&N>_){var S=N;N=_,_=S}return N+i+_+i+(e.isUndefined(x)?n:x)}function p(h,g,y,x){var N=""+g,_=""+y;if(!h&&N>_){var S=N;N=_,_=S}var b={v:N,w:_};return x&&(b.name=x),b}function f(h,g){return c(h,g.v,g.w,g.name)}return fm}var hm,AS;function R$(){return AS||(AS=1,hm="2.1.8"),hm}var pm,IS;function T$(){return IS||(IS=1,pm={Graph:cy(),version:R$()}),pm}var mm,MS;function A$(){if(MS)return mm;MS=1;var e=qn(),n=cy();mm={write:r,read:l};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 p=u.node(c),f=u.parent(c),h={v:c};return e.isUndefined(p)||(h.value=p),e.isUndefined(f)||(h.parent=f),h})}function o(u){return e.map(u.edges(),function(c){var p=u.edge(c),f={v:c.v,w:c.w};return e.isUndefined(c.name)||(f.name=c.name),e.isUndefined(p)||(f.value=p),f})}function l(u){var c=new n(u.options).setGraph(u.value);return e.each(u.nodes,function(p){c.setNode(p.v,p.value),p.parent&&c.setParent(p.v,p.parent)}),e.each(u.edges,function(p){c.setEdge({v:p.v,w:p.w,name:p.name},p.value)}),c}return mm}var gm,PS;function I$(){if(PS)return gm;PS=1;var e=qn();gm=n;function n(r){var i={},o=[],l;function u(c){e.has(i,c)||(i[c]=!0,l.push(c),e.each(r.successors(c),u),e.each(r.predecessors(c),u))}return e.each(r.nodes(),function(c){l=[],u(c),l.length&&o.push(l)}),o}return gm}var vm,OS;function ij(){if(OS)return vm;OS=1;var e=qn();vm=n;function n(){this._arr=[],this._keyIndices={}}return n.prototype.size=function(){return this._arr.length},n.prototype.keys=function(){return this._arr.map(function(r){return r.key})},n.prototype.has=function(r){return e.has(this._keyIndices,r)},n.prototype.priority=function(r){var i=this._keyIndices[r];if(i!==void 0)return this._arr[i].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(r,i){var o=this._keyIndices;if(r=String(r),!e.has(o,r)){var l=this._arr,u=l.length;return o[r]=u,l.push({key:r,priority:i}),this._decrease(u),!0}return!1},n.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},n.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)},n.prototype._heapify=function(r){var i=this._arr,o=2*r,l=o+1,u=r;o<i.length&&(u=i[o].priority<i[u].priority?o:u,l<i.length&&(u=i[l].priority<i[u].priority?l:u),u!==r&&(this._swap(r,u),this._heapify(u)))},n.prototype._decrease=function(r){for(var i=this._arr,o=i[r].priority,l;r!==0&&(l=r>>1,!(i[l].priority<o));)this._swap(r,l),r=l},n.prototype._swap=function(r,i){var o=this._arr,l=this._keyIndices,u=o[r],c=o[i];o[r]=c,o[i]=u,l[c.key]=r,l[u.key]=i},vm}var ym,LS;function oj(){if(LS)return ym;LS=1;var e=qn(),n=ij();ym=i;var r=e.constant(1);function i(l,u,c,p){return o(l,String(u),c||r,p||function(f){return l.outEdges(f)})}function o(l,u,c,p){var f={},h=new n,g,y,x=function(N){var _=N.v!==g?N.v:N.w,S=f[_],b=c(N),k=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+N+" Weight: "+b);k<S.distance&&(S.distance=k,S.predecessor=g,h.decrease(_,k))};for(l.nodes().forEach(function(N){var _=N===u?0:Number.POSITIVE_INFINITY;f[N]={distance:_},h.add(N,_)});h.size()>0&&(g=h.removeMin(),y=f[g],y.distance!==Number.POSITIVE_INFINITY);)p(g).forEach(x);return f}return ym}var wm,qS;function M$(){if(qS)return wm;qS=1;var e=oj(),n=qn();wm=r;function r(i,o,l){return n.transform(i.nodes(),function(u,c){u[c]=e(i,c,o,l)},{})}return wm}var xm,$S;function aj(){if($S)return xm;$S=1;var e=qn();xm=n;function n(r){var i=0,o=[],l={},u=[];function c(p){var f=l[p]={onStack:!0,lowlink:i,index:i++};if(o.push(p),r.successors(p).forEach(function(y){e.has(l,y)?l[y].onStack&&(f.lowlink=Math.min(f.lowlink,l[y].index)):(c(y),f.lowlink=Math.min(f.lowlink,l[y].lowlink))}),f.lowlink===f.index){var h=[],g;do g=o.pop(),l[g].onStack=!1,h.push(g);while(p!==g);u.push(h)}}return r.nodes().forEach(function(p){e.has(l,p)||c(p)}),u}return xm}var _m,DS;function P$(){if(DS)return _m;DS=1;var e=qn(),n=aj();_m=r;function r(i){return e.filter(n(i),function(o){return o.length>1||o.length===1&&i.hasEdge(o[0],o[0])})}return _m}var bm,FS;function O$(){if(FS)return bm;FS=1;var e=qn();bm=r;var n=e.constant(1);function r(o,l,u){return i(o,l||n,u||function(c){return o.outEdges(c)})}function i(o,l,u){var c={},p=o.nodes();return p.forEach(function(f){c[f]={},c[f][f]={distance:0},p.forEach(function(h){f!==h&&(c[f][h]={distance:Number.POSITIVE_INFINITY})}),u(f).forEach(function(h){var g=h.v===f?h.w:h.v,y=l(h);c[f][g]={distance:y,predecessor:f}})}),p.forEach(function(f){var h=c[f];p.forEach(function(g){var y=c[g];p.forEach(function(x){var N=y[f],_=h[x],S=y[x],b=N.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return bm}var Sm,zS;function lj(){if(zS)return Sm;zS=1;var e=qn();Sm=n,n.CycleException=r;function n(i){var o={},l={},u=[];function c(p){if(e.has(l,p))throw new r;e.has(o,p)||(l[p]=!0,o[p]=!0,e.each(i.predecessors(p),c),delete l[p],u.push(p))}if(e.each(i.sinks(),c),e.size(o)!==i.nodeCount())throw new r;return u}function r(){}return r.prototype=new Error,Sm}var km,BS;function L$(){if(BS)return km;BS=1;var e=lj();km=n;function n(r){try{e(r)}catch(i){if(i instanceof e.CycleException)return!1;throw i}return!0}return km}var Em,US;function uj(){if(US)return Em;US=1;var e=qn();Em=n;function n(i,o,l){e.isArray(o)||(o=[o]);var u=(i.isDirected()?i.successors:i.neighbors).bind(i),c=[],p={};return e.each(o,function(f){if(!i.hasNode(f))throw new Error("Graph does not have node: "+f);r(i,f,l==="post",p,u,c)}),c}function r(i,o,l,u,c,p){e.has(u,o)||(u[o]=!0,l||p.push(o),e.each(c(o),function(f){r(i,f,l,u,c,p)}),l&&p.push(o))}return Em}var Nm,HS;function q$(){if(HS)return Nm;HS=1;var e=uj();Nm=n;function n(r,i){return e(r,i,"post")}return Nm}var Cm,WS;function $$(){if(WS)return Cm;WS=1;var e=uj();Cm=n;function n(r,i){return e(r,i,"pre")}return Cm}var jm,VS;function D$(){if(VS)return jm;VS=1;var e=qn(),n=cy(),r=ij();jm=i;function i(o,l){var u=new n,c={},p=new r,f;function h(y){var x=y.v===f?y.w:y.v,N=p.priority(x);if(N!==void 0){var _=l(y);_<N&&(c[x]=f,p.decrease(x,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){p.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),p.decrease(o.nodes()[0],0);for(var g=!1;p.size()>0;){if(f=p.removeMin(),e.has(c,f))u.setEdge(f,c[f]);else{if(g)throw new Error("Input graph is not connected: "+o);g=!0}o.nodeEdges(f).forEach(h)}return u}return jm}var Rm,GS;function F$(){return GS||(GS=1,Rm={components:I$(),dijkstra:oj(),dijkstraAll:M$(),findCycles:P$(),floydWarshall:O$(),isAcyclic:L$(),postorder:q$(),preorder:$$(),prim:D$(),tarjan:aj(),topsort:lj()}),Rm}var Tm,YS;function z$(){if(YS)return Tm;YS=1;var e=T$();return Tm={Graph:e.Graph,json:A$(),alg:F$(),version:e.version},Tm}var Am,KS;function Jn(){if(KS)return Am;KS=1;var e;if(typeof Yv=="function")try{e=z$()}catch{}return e||(e=window.graphlib),Am=e,Am}var Im,XS;function B$(){if(XS)return Im;XS=1;var e=PC(),n=1,r=4;function i(o){return e(o,n|r)}return Im=i,Im}var Mm,QS;function Uu(){if(QS)return Mm;QS=1;var e=yo(),n=Wr(),r=Pu(),i=Ln();function o(l,u,c){if(!i(c))return!1;var p=typeof u;return(p=="number"?n(c)&&r(u,c.length):p=="string"&&u in c)?e(c[u],l):!1}return Mm=o,Mm}var Pm,ZS;function U$(){if(ZS)return Pm;ZS=1;var e=Bu(),n=yo(),r=Uu(),i=di(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,p){c=Object(c);var f=-1,h=p.length,g=h>2?p[2]:void 0;for(g&&r(p[0],p[1],g)&&(h=1);++f<h;)for(var y=p[f],x=i(y),N=-1,_=x.length;++N<_;){var S=x[N],b=c[S];(b===void 0||n(b,o[S])&&!l.call(c,S))&&(c[S]=y[S])}return c});return Pm=u,Pm}var Om,JS;function H$(){if(JS)return Om;JS=1;var e=Vr(),n=Wr(),r=ks();function i(o){return function(l,u,c){var p=Object(l);if(!n(l)){var f=e(u,3);l=r(l),u=function(g){return f(p[g],g,p)}}var h=o(l,u,c);return h>-1?p[f?l[h]:h]:void 0}}return Om=i,Om}var Lm,ek;function W$(){if(ek)return Lm;ek=1;var e=/\s/;function n(r){for(var i=r.length;i--&&e.test(r.charAt(i)););return i}return Lm=n,Lm}var qm,tk;function V$(){if(tk)return qm;tk=1;var e=W$(),n=/^\s+/;function r(i){return i&&i.slice(0,e(i)+1).replace(n,"")}return qm=r,qm}var $m,nk;function G$(){if(nk)return $m;nk=1;var e=V$(),n=Ln(),r=bo(),i=NaN,o=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function p(f){if(typeof f=="number")return f;if(r(f))return i;if(n(f)){var h=typeof f.valueOf=="function"?f.valueOf():f;f=n(h)?h+"":h}if(typeof f!="string")return f===0?f:+f;f=e(f);var g=l.test(f);return g||u.test(f)?c(f.slice(2),g?2:8):o.test(f)?i:+f}return $m=p,$m}var Dm,rk;function cj(){if(rk)return Dm;rk=1;var e=G$(),n=1/0,r=17976931348623157e292;function i(o){if(!o)return o===0?o:0;if(o=e(o),o===n||o===-n){var l=o<0?-1:1;return l*r}return o===o?o:0}return Dm=i,Dm}var Fm,sk;function Y$(){if(sk)return Fm;sk=1;var e=cj();function n(r){var i=e(r),o=i%1;return i===i?o?i-o:i:0}return Fm=n,Fm}var zm,ik;function K$(){if(ik)return zm;ik=1;var e=nj(),n=Vr(),r=Y$(),i=Math.max;function o(l,u,c){var p=l==null?0:l.length;if(!p)return-1;var f=c==null?0:r(c);return f<0&&(f=i(p+f,0)),e(l,n(u,3),f)}return zm=o,zm}var Bm,ok;function X$(){if(ok)return Bm;ok=1;var e=H$(),n=K$(),r=e(n);return Bm=r,Bm}var Um,ak;function dj(){if(ak)return Um;ak=1;var e=uy();function n(r){var i=r==null?0:r.length;return i?e(r,1):[]}return Um=n,Um}var Hm,lk;function Q$(){if(lk)return Hm;lk=1;var e=iy(),n=OC(),r=di();function i(o,l){return o==null?o:e(o,n(l),r)}return Hm=i,Hm}var Wm,uk;function Z$(){if(uk)return Wm;uk=1;function e(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}return Wm=e,Wm}var Vm,ck;function J$(){if(ck)return Vm;ck=1;var e=Iu(),n=oy(),r=Vr();function i(o,l){var u={};return l=r(l,3),n(o,function(c,p,f){e(u,p,l(c,p,f))}),u}return Vm=i,Vm}var Gm,dk;function dy(){if(dk)return Gm;dk=1;var e=bo();function n(r,i,o){for(var l=-1,u=r.length;++l<u;){var c=r[l],p=i(c);if(p!=null&&(f===void 0?p===p&&!e(p):o(p,f)))var f=p,h=c}return h}return Gm=n,Gm}var Ym,fk;function e4(){if(fk)return Ym;fk=1;function e(n,r){return n>r}return Ym=e,Ym}var Km,hk;function t4(){if(hk)return Km;hk=1;var e=dy(),n=e4(),r=fi();function i(o){return o&&o.length?e(o,r,n):void 0}return Km=i,Km}var Xm,pk;function fj(){if(pk)return Xm;pk=1;var e=Iu(),n=yo();function r(i,o,l){(l!==void 0&&!n(i[o],l)||l===void 0&&!(o in i))&&e(i,o,l)}return Xm=r,Xm}var Qm,mk;function n4(){if(mk)return Qm;mk=1;var e=ui(),n=qu(),r=vr(),i="[object Object]",o=Function.prototype,l=Object.prototype,u=o.toString,c=l.hasOwnProperty,p=u.call(Object);function f(h){if(!r(h)||e(h)!=i)return!1;var g=n(h);if(g===null)return!0;var y=c.call(g,"constructor")&&g.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==p}return Qm=f,Qm}var Zm,gk;function hj(){if(gk)return Zm;gk=1;function e(n,r){if(!(r==="constructor"&&typeof n[r]=="function")&&r!="__proto__")return n[r]}return Zm=e,Zm}var Jm,vk;function r4(){if(vk)return Jm;vk=1;var e=La(),n=di();function r(i){return e(i,n(i))}return Jm=r,Jm}var eg,yk;function s4(){if(yk)return eg;yk=1;var e=fj(),n=bC(),r=AC(),i=SC(),o=MC(),l=qa(),u=bt(),c=rj(),p=xo(),f=Oa(),h=Ln(),g=n4(),y=$a(),x=hj(),N=r4();function _(S,b,k,E,C,A,M){var L=x(S,k),H=x(b,k),O=M.get(H);if(O){e(S,k,O);return}var P=A?A(L,H,k+"",S,b,M):void 0,F=P===void 0;if(F){var G=u(H),q=!G&&p(H),R=!G&&!q&&y(H);P=H,G||q||R?u(L)?P=L:c(L)?P=i(L):q?(F=!1,P=n(H,!0)):R?(F=!1,P=r(H,!0)):P=[]:g(H)||l(H)?(P=L,l(L)?P=N(L):(!h(L)||f(L))&&(P=o(H))):F=!1}F&&(M.set(H,P),C(P,H,E,A,M),M.delete(H)),e(S,k,P)}return eg=_,eg}var tg,wk;function i4(){if(wk)return tg;wk=1;var e=Au(),n=fj(),r=iy(),i=s4(),o=Ln(),l=di(),u=hj();function c(p,f,h,g,y){p!==f&&r(f,function(x,N){if(y||(y=new e),o(x))i(p,f,N,h,c,g,y);else{var _=g?g(u(p,N),x,N+"",p,f,y):void 0;_===void 0&&(_=x),n(p,N,_)}},l)}return tg=c,tg}var ng,xk;function o4(){if(xk)return ng;xk=1;var e=Bu(),n=Uu();function r(i){return e(function(o,l){var u=-1,c=l.length,p=c>1?l[c-1]:void 0,f=c>2?l[2]:void 0;for(p=i.length>3&&typeof p=="function"?(c--,p):void 0,f&&n(l[0],l[1],f)&&(p=c<3?void 0:p,c=1),o=Object(o);++u<c;){var h=l[u];h&&i(o,h,u,p)}return o})}return ng=r,ng}var rg,_k;function a4(){if(_k)return rg;_k=1;var e=i4(),n=o4(),r=n(function(i,o,l){e(i,o,l)});return rg=r,rg}var sg,bk;function pj(){if(bk)return sg;bk=1;function e(n,r){return n<r}return sg=e,sg}var ig,Sk;function l4(){if(Sk)return ig;Sk=1;var e=dy(),n=pj(),r=fi();function i(o){return o&&o.length?e(o,r,n):void 0}return ig=i,ig}var og,kk;function u4(){if(kk)return og;kk=1;var e=dy(),n=Vr(),r=pj();function i(o,l){return o&&o.length?e(o,n(l,2),r):void 0}return og=i,og}var ag,Ek;function c4(){if(Ek)return ag;Ek=1;var e=tr(),n=function(){return e.Date.now()};return ag=n,ag}var lg,Nk;function d4(){if(Nk)return lg;Nk=1;var e=Mu(),n=Fu(),r=Pu(),i=Ln(),o=Da();function l(u,c,p,f){if(!i(u))return u;c=n(c,u);for(var h=-1,g=c.length,y=g-1,x=u;x!=null&&++h<g;){var N=o(c[h]),_=p;if(N==="__proto__"||N==="constructor"||N==="prototype")return u;if(h!=y){var S=x[N];_=f?f(S,N,x):void 0,_===void 0&&(_=i(S)?S:r(c[h+1])?[]:{})}e(x,N,_),x=x[N]}return u}return lg=l,lg}var ug,Ck;function f4(){if(Ck)return ug;Ck=1;var e=zu(),n=d4(),r=Fu();function i(o,l,u){for(var c=-1,p=l.length,f={};++c<p;){var h=l[c],g=e(o,h);u(g,h)&&n(f,r(h,o),g)}return f}return ug=i,ug}var cg,jk;function h4(){if(jk)return cg;jk=1;var e=f4(),n=VC();function r(i,o){return e(i,o,function(l,u){return n(i,u)})}return cg=r,cg}var dg,Rk;function p4(){if(Rk)return dg;Rk=1;var e=dj(),n=ej(),r=tj();function i(o){return r(n(o,void 0,e),o+"")}return dg=i,dg}var fg,Tk;function m4(){if(Tk)return fg;Tk=1;var e=h4(),n=p4(),r=n(function(i,o){return i==null?{}:e(i,o)});return fg=r,fg}var hg,Ak;function g4(){if(Ak)return hg;Ak=1;var e=Math.ceil,n=Math.max;function r(i,o,l,u){for(var c=-1,p=n(e((o-i)/(l||1)),0),f=Array(p);p--;)f[u?p:++c]=i,i+=l;return f}return hg=r,hg}var pg,Ik;function v4(){if(Ik)return pg;Ik=1;var e=g4(),n=Uu(),r=cj();function i(o){return function(l,u,c){return c&&typeof c!="number"&&n(l,u,c)&&(u=c=void 0),l=r(l),u===void 0?(u=l,l=0):u=r(u),c=c===void 0?l<u?1:-1:r(c),e(l,u,c,o)}}return pg=i,pg}var mg,Mk;function y4(){if(Mk)return mg;Mk=1;var e=v4(),n=e();return mg=n,mg}var gg,Pk;function w4(){if(Pk)return gg;Pk=1;function e(n,r){var i=n.length;for(n.sort(r);i--;)n[i]=n[i].value;return n}return gg=e,gg}var vg,Ok;function x4(){if(Ok)return vg;Ok=1;var e=bo();function n(r,i){if(r!==i){var o=r!==void 0,l=r===null,u=r===r,c=e(r),p=i!==void 0,f=i===null,h=i===i,g=e(i);if(!f&&!g&&!c&&r>i||c&&p&&h&&!f&&!g||l&&p&&h||!o&&h||!u)return 1;if(!l&&!c&&!g&&r<i||g&&o&&u&&!l&&!c||f&&o&&u||!p&&u||!h)return-1}return 0}return vg=n,vg}var yg,Lk;function _4(){if(Lk)return yg;Lk=1;var e=x4();function n(r,i,o){for(var l=-1,u=r.criteria,c=i.criteria,p=u.length,f=o.length;++l<p;){var h=e(u[l],c[l]);if(h){if(l>=f)return h;var g=o[l];return h*(g=="desc"?-1:1)}}return r.index-i.index}return yg=n,yg}var wg,qk;function b4(){if(qk)return wg;qk=1;var e=Du(),n=zu(),r=Vr(),i=QC(),o=w4(),l=Ou(),u=_4(),c=fi(),p=bt();function f(h,g,y){g.length?g=e(g,function(_){return p(_)?function(S){return n(S,_.length===1?_[0]:_)}:_}):g=[c];var x=-1;g=e(g,l(r));var N=i(h,function(_,S,b){var k=e(g,function(E){return E(_)});return{criteria:k,index:++x,value:_}});return o(N,function(_,S){return u(_,S,y)})}return wg=f,wg}var xg,$k;function S4(){if($k)return xg;$k=1;var e=uy(),n=b4(),r=Bu(),i=Uu(),o=r(function(l,u){if(l==null)return[];var c=u.length;return c>1&&i(l,u[0],u[1])?u=[]:c>2&&i(u[0],u[1],u[2])&&(u=[u[0]]),n(l,e(u,1),[])});return xg=o,xg}var _g,Dk;function k4(){if(Dk)return _g;Dk=1;var e=HC(),n=0;function r(i){var o=++n;return e(i)+o}return _g=r,_g}var bg,Fk;function E4(){if(Fk)return bg;Fk=1;function e(n,r,i){for(var o=-1,l=n.length,u=r.length,c={};++o<l;){var p=o<u?r[o]:void 0;i(c,n[o],p)}return c}return bg=e,bg}var Sg,zk;function N4(){if(zk)return Sg;zk=1;var e=Mu(),n=E4();function r(i,o){return n(i||[],o||[],e)}return Sg=r,Sg}var kg,Bk;function it(){if(Bk)return kg;Bk=1;var e;if(typeof Yv=="function")try{e={cloneDeep:B$(),constant:sy(),defaults:U$(),each:qC(),filter:YC(),find:X$(),flatten:dj(),forEach:LC(),forIn:Q$(),has:KC(),isUndefined:XC(),last:Z$(),map:ZC(),mapValues:J$(),max:t4(),merge:a4(),min:l4(),minBy:u4(),now:c4(),pick:m4(),range:y4(),reduce:JC(),sortBy:S4(),uniqueId:k4(),values:sj(),zipObject:N4()}}catch{}return e||(e=window._),kg=e,kg}var Eg,Uk;function C4(){if(Uk)return Eg;Uk=1,Eg=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 n(o),o},e.prototype.enqueue=function(i){var o=this._sentinel;i._prev&&i._next&&n(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,l=o._prev;l!==o;)i.push(JSON.stringify(l,r)),l=l._prev;return"["+i.join(", ")+"]"};function n(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 Eg}var Ng,Hk;function j4(){if(Hk)return Ng;Hk=1;var e=it(),n=Jn().Graph,r=C4();Ng=o;var i=e.constant(1);function o(f,h){if(f.nodeCount()<=1)return[];var g=c(f,h||i),y=l(g.graph,g.buckets,g.zeroIdx);return e.flatten(e.map(y,function(x){return f.outEdges(x.v,x.w)}),!0)}function l(f,h,g){for(var y=[],x=h[h.length-1],N=h[0],_;f.nodeCount();){for(;_=N.dequeue();)u(f,h,g,_);for(;_=x.dequeue();)u(f,h,g,_);if(f.nodeCount()){for(var S=h.length-2;S>0;--S)if(_=h[S].dequeue(),_){y=y.concat(u(f,h,g,_,!0));break}}}return y}function u(f,h,g,y,x){var N=x?[]:void 0;return e.forEach(f.inEdges(y.v),function(_){var S=f.edge(_),b=f.node(_.v);x&&N.push({v:_.v,w:_.w}),b.out-=S,p(h,g,b)}),e.forEach(f.outEdges(y.v),function(_){var S=f.edge(_),b=_.w,k=f.node(b);k.in-=S,p(h,g,k)}),f.removeNode(y.v),N}function c(f,h){var g=new n,y=0,x=0;e.forEach(f.nodes(),function(S){g.setNode(S,{v:S,in:0,out:0})}),e.forEach(f.edges(),function(S){var b=g.edge(S.v,S.w)||0,k=h(S),E=b+k;g.setEdge(S.v,S.w,E),x=Math.max(x,g.node(S.v).out+=k),y=Math.max(y,g.node(S.w).in+=k)});var N=e.range(x+y+3).map(function(){return new r}),_=y+1;return e.forEach(g.nodes(),function(S){p(N,_,g.node(S))}),{graph:g,buckets:N,zeroIdx:_}}function p(f,h,g){g.out?g.in?f[g.out-g.in+h].enqueue(g):f[f.length-1].enqueue(g):f[0].enqueue(g)}return Ng}var Cg,Wk;function R4(){if(Wk)return Cg;Wk=1;var e=it(),n=j4();Cg={run:r,undo:o};function r(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):i(l);e.forEach(u,function(p){var f=l.edge(p);l.removeEdge(p),f.forwardName=p.name,f.reversed=!0,l.setEdge(p.w,p.v,f,e.uniqueId("rev"))});function c(p){return function(f){return p.edge(f).weight}}}function i(l){var u=[],c={},p={};function f(h){e.has(p,h)||(p[h]=!0,c[h]=!0,e.forEach(l.outEdges(h),function(g){e.has(c,g.w)?u.push(g):f(g.w)}),delete c[h])}return e.forEach(l.nodes(),f),u}function o(l){e.forEach(l.edges(),function(u){var c=l.edge(u);if(c.reversed){l.removeEdge(u);var p=c.forwardName;delete c.reversed,delete c.forwardName,l.setEdge(u.w,u.v,c,p)}})}return Cg}var jg,Vk;function hn(){if(Vk)return jg;Vk=1;var e=it(),n=Jn().Graph;jg={addDummyNode:r,simplify:i,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:p,normalizeRanks:f,removeEmptyRanks:h,addBorderNode:g,maxRank:y,partition:x,time:N,notime:_};function r(S,b,k,E){var C;do C=e.uniqueId(E);while(S.hasNode(C));return k.dummy=b,S.setNode(C,k),C}function i(S){var b=new n().setGraph(S.graph());return e.forEach(S.nodes(),function(k){b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){var E=b.edge(k.v,k.w)||{weight:0,minlen:1},C=S.edge(k);b.setEdge(k.v,k.w,{weight:E.weight+C.weight,minlen:Math.max(E.minlen,C.minlen)})}),b}function o(S){var b=new n({multigraph:S.isMultigraph()}).setGraph(S.graph());return e.forEach(S.nodes(),function(k){S.children(k).length||b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){b.setEdge(k,S.edge(k))}),b}function l(S){var b=e.map(S.nodes(),function(k){var E={};return e.forEach(S.outEdges(k),function(C){E[C.w]=(E[C.w]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function u(S){var b=e.map(S.nodes(),function(k){var E={};return e.forEach(S.inEdges(k),function(C){E[C.v]=(E[C.v]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function c(S,b){var k=S.x,E=S.y,C=b.x-k,A=b.y-E,M=S.width/2,L=S.height/2;if(!C&&!A)throw new Error("Not possible to find intersection inside of the rectangle");var H,O;return Math.abs(A)*M>Math.abs(C)*L?(A<0&&(L=-L),H=L*C/A,O=L):(C<0&&(M=-M),H=M,O=M*A/C),{x:k+H,y:E+O}}function p(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(k){var E=S.node(k),C=E.rank;e.isUndefined(C)||(b[C][E.order]=k)}),b}function f(S){var b=e.min(e.map(S.nodes(),function(k){return S.node(k).rank}));e.forEach(S.nodes(),function(k){var E=S.node(k);e.has(E,"rank")&&(E.rank-=b)})}function h(S){var b=e.min(e.map(S.nodes(),function(A){return S.node(A).rank})),k=[];e.forEach(S.nodes(),function(A){var M=S.node(A).rank-b;k[M]||(k[M]=[]),k[M].push(A)});var E=0,C=S.graph().nodeRankFactor;e.forEach(k,function(A,M){e.isUndefined(A)&&M%C!==0?--E:E&&e.forEach(A,function(L){S.node(L).rank+=E})})}function g(S,b,k,E){var C={width:0,height:0};return arguments.length>=4&&(C.rank=k,C.order=E),r(S,"border",C,b)}function y(S){return e.max(e.map(S.nodes(),function(b){var k=S.node(b).rank;if(!e.isUndefined(k))return k}))}function x(S,b){var k={lhs:[],rhs:[]};return e.forEach(S,function(E){b(E)?k.lhs.push(E):k.rhs.push(E)}),k}function N(S,b){var k=e.now();try{return b()}finally{console.log(S+" time: "+(e.now()-k)+"ms")}}function _(S,b){return b()}return jg}var Rg,Gk;function T4(){if(Gk)return Rg;Gk=1;var e=it(),n=hn();Rg={run:r,undo:o};function r(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(u){i(l,u)})}function i(l,u){var c=u.v,p=l.node(c).rank,f=u.w,h=l.node(f).rank,g=u.name,y=l.edge(u),x=y.labelRank;if(h!==p+1){l.removeEdge(u);var N,_,S;for(S=0,++p;p<h;++S,++p)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:u,rank:p},N=n.addDummyNode(l,"edge",_,"_d"),p===x&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(c,N,{weight:y.weight},g),S===0&&l.graph().dummyChains.push(N),c=N;l.setEdge(c,f,{weight:y.weight},g)}}function o(l){e.forEach(l.graph().dummyChains,function(u){var c=l.node(u),p=c.edgeLabel,f;for(l.setEdge(c.edgeObj,p);c.dummy;)f=l.successors(u)[0],l.removeNode(u),p.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(p.x=c.x,p.y=c.y,p.width=c.width,p.height=c.height),u=f,c=l.node(u)})}return Rg}var Tg,Yk;function vu(){if(Yk)return Tg;Yk=1;var e=it();Tg={longestPath:n,slack:r};function n(i){var o={};function l(u){var c=i.node(u);if(e.has(o,u))return c.rank;o[u]=!0;var p=e.min(e.map(i.outEdges(u),function(f){return l(f.w)-i.edge(f).minlen}));return(p===Number.POSITIVE_INFINITY||p===void 0||p===null)&&(p=0),c.rank=p}e.forEach(i.sources(),l)}function r(i,o){return i.node(o.w).rank-i.node(o.v).rank-i.edge(o).minlen}return Tg}var Ag,Kk;function mj(){if(Kk)return Ag;Kk=1;var e=it(),n=Jn().Graph,r=vu().slack;Ag=i;function i(c){var p=new n({directed:!1}),f=c.nodes()[0],h=c.nodeCount();p.setNode(f,{});for(var g,y;o(p,c)<h;)g=l(p,c),y=p.hasNode(g.v)?r(c,g):-r(c,g),u(p,c,y);return p}function o(c,p){function f(h){e.forEach(p.nodeEdges(h),function(g){var y=g.v,x=h===y?g.w:y;!c.hasNode(x)&&!r(p,g)&&(c.setNode(x,{}),c.setEdge(h,x,{}),f(x))})}return e.forEach(c.nodes(),f),c.nodeCount()}function l(c,p){return e.minBy(p.edges(),function(f){if(c.hasNode(f.v)!==c.hasNode(f.w))return r(p,f)})}function u(c,p,f){e.forEach(c.nodes(),function(h){p.node(h).rank+=f})}return Ag}var Ig,Xk;function A4(){if(Xk)return Ig;Xk=1;var e=it(),n=mj(),r=vu().slack,i=vu().longestPath,o=Jn().alg.preorder,l=Jn().alg.postorder,u=hn().simplify;Ig=c,c.initLowLimValues=g,c.initCutValues=p,c.calcCutValue=h,c.leaveEdge=x,c.enterEdge=N,c.exchangeEdges=_;function c(E){E=u(E),i(E);var C=n(E);g(C),p(C,E);for(var A,M;A=x(C);)M=N(C,E,A),_(C,E,A,M)}function p(E,C){var A=l(E,E.nodes());A=A.slice(0,A.length-1),e.forEach(A,function(M){f(E,C,M)})}function f(E,C,A){var M=E.node(A),L=M.parent;E.edge(A,L).cutvalue=h(E,C,A)}function h(E,C,A){var M=E.node(A),L=M.parent,H=!0,O=C.edge(A,L),P=0;return O||(H=!1,O=C.edge(L,A)),P=O.weight,e.forEach(C.nodeEdges(A),function(F){var G=F.v===A,q=G?F.w:F.v;if(q!==L){var R=G===H,Q=C.edge(F).weight;if(P+=R?Q:-Q,b(E,A,q)){var z=E.edge(A,q).cutvalue;P+=R?-z:z}}}),P}function g(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,A,M,L){var H=A,O=E.node(M);return C[M]=!0,e.forEach(E.neighbors(M),function(P){e.has(C,P)||(A=y(E,C,A,P,M))}),O.low=H,O.lim=A++,L?O.parent=L:delete O.parent,A}function x(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function N(E,C,A){var M=A.v,L=A.w;C.hasEdge(M,L)||(M=A.w,L=A.v);var H=E.node(M),O=E.node(L),P=H,F=!1;H.lim>O.lim&&(P=O,F=!0);var G=e.filter(C.edges(),function(q){return F===k(E,E.node(q.v),P)&&F!==k(E,E.node(q.w),P)});return e.minBy(G,function(q){return r(C,q)})}function _(E,C,A,M){var L=A.v,H=A.w;E.removeEdge(L,H),E.setEdge(M.v,M.w,{}),g(E),p(E,C),S(E,C)}function S(E,C){var A=e.find(E.nodes(),function(L){return!C.node(L).parent}),M=o(E,A);M=M.slice(1),e.forEach(M,function(L){var H=E.node(L).parent,O=C.edge(L,H),P=!1;O||(O=C.edge(H,L),P=!0),C.node(L).rank=C.node(H).rank+(P?O.minlen:-O.minlen)})}function b(E,C,A){return E.hasEdge(C,A)}function k(E,C,A){return A.low<=C.lim&&C.lim<=A.lim}return Ig}var Mg,Qk;function I4(){if(Qk)return Mg;Qk=1;var e=vu(),n=e.longestPath,r=mj(),i=A4();Mg=o;function o(p){switch(p.graph().ranker){case"network-simplex":c(p);break;case"tight-tree":u(p);break;case"longest-path":l(p);break;default:c(p)}}var l=n;function u(p){n(p),r(p)}function c(p){i(p)}return Mg}var Pg,Zk;function M4(){if(Zk)return Pg;Zk=1;var e=it();Pg=n;function n(o){var l=i(o);e.forEach(o.graph().dummyChains,function(u){for(var c=o.node(u),p=c.edgeObj,f=r(o,l,p.v,p.w),h=f.path,g=f.lca,y=0,x=h[y],N=!0;u!==p.w;){if(c=o.node(u),N){for(;(x=h[y])!==g&&o.node(x).maxRank<c.rank;)y++;x===g&&(N=!1)}if(!N){for(;y<h.length-1&&o.node(x=h[y+1]).minRank<=c.rank;)y++;x=h[y]}o.setParent(u,x),u=o.successors(u)[0]}})}function r(o,l,u,c){var p=[],f=[],h=Math.min(l[u].low,l[c].low),g=Math.max(l[u].lim,l[c].lim),y,x;y=u;do y=o.parent(y),p.push(y);while(y&&(l[y].low>h||g>l[y].lim));for(x=y,y=c;(y=o.parent(y))!==x;)f.push(y);return{path:p.concat(f.reverse()),lca:x}}function i(o){var l={},u=0;function c(p){var f=u;e.forEach(o.children(p),c),l[p]={low:f,lim:u++}}return e.forEach(o.children(),c),l}return Pg}var Og,Jk;function P4(){if(Jk)return Og;Jk=1;var e=it(),n=hn();Og={run:r,cleanup:u};function r(c){var p=n.addDummyNode(c,"root",{},"_root"),f=o(c),h=e.max(e.values(f))-1,g=2*h+1;c.graph().nestingRoot=p,e.forEach(c.edges(),function(x){c.edge(x).minlen*=g});var y=l(c)+1;e.forEach(c.children(),function(x){i(c,p,g,y,h,f,x)}),c.graph().nodeRankFactor=g}function i(c,p,f,h,g,y,x){var N=c.children(x);if(!N.length){x!==p&&c.setEdge(p,x,{weight:0,minlen:f});return}var _=n.addBorderNode(c,"_bt"),S=n.addBorderNode(c,"_bb"),b=c.node(x);c.setParent(_,x),b.borderTop=_,c.setParent(S,x),b.borderBottom=S,e.forEach(N,function(k){i(c,p,f,h,g,y,k);var E=c.node(k),C=E.borderTop?E.borderTop:k,A=E.borderBottom?E.borderBottom:k,M=E.borderTop?h:2*h,L=C!==A?1:g-y[x]+1;c.setEdge(_,C,{weight:M,minlen:L,nestingEdge:!0}),c.setEdge(A,S,{weight:M,minlen:L,nestingEdge:!0})}),c.parent(x)||c.setEdge(p,_,{weight:0,minlen:g+y[x]})}function o(c){var p={};function f(h,g){var y=c.children(h);y&&y.length&&e.forEach(y,function(x){f(x,g+1)}),p[h]=g}return e.forEach(c.children(),function(h){f(h,1)}),p}function l(c){return e.reduce(c.edges(),function(p,f){return p+c.edge(f).weight},0)}function u(c){var p=c.graph();c.removeNode(p.nestingRoot),delete p.nestingRoot,e.forEach(c.edges(),function(f){var h=c.edge(f);h.nestingEdge&&c.removeEdge(f)})}return Og}var Lg,eE;function O4(){if(eE)return Lg;eE=1;var e=it(),n=hn();Lg=r;function r(o){function l(u){var c=o.children(u),p=o.node(u);if(c.length&&e.forEach(c,l),e.has(p,"minRank")){p.borderLeft=[],p.borderRight=[];for(var f=p.minRank,h=p.maxRank+1;f<h;++f)i(o,"borderLeft","_bl",u,p,f),i(o,"borderRight","_br",u,p,f)}}e.forEach(o.children(),l)}function i(o,l,u,c,p,f){var h={width:0,height:0,rank:f,borderType:l},g=p[l][f-1],y=n.addDummyNode(o,"border",h,u);p[l][f]=y,o.setParent(y,c),g&&o.setEdge(g,y,{weight:1})}return Lg}var qg,tE;function L4(){if(tE)return qg;tE=1;var e=it();qg={adjust:n,undo:r};function n(f){var h=f.graph().rankdir.toLowerCase();(h==="lr"||h==="rl")&&i(f)}function r(f){var h=f.graph().rankdir.toLowerCase();(h==="bt"||h==="rl")&&l(f),(h==="lr"||h==="rl")&&(c(f),i(f))}function i(f){e.forEach(f.nodes(),function(h){o(f.node(h))}),e.forEach(f.edges(),function(h){o(f.edge(h))})}function o(f){var h=f.width;f.width=f.height,f.height=h}function l(f){e.forEach(f.nodes(),function(h){u(f.node(h))}),e.forEach(f.edges(),function(h){var g=f.edge(h);e.forEach(g.points,u),e.has(g,"y")&&u(g)})}function u(f){f.y=-f.y}function c(f){e.forEach(f.nodes(),function(h){p(f.node(h))}),e.forEach(f.edges(),function(h){var g=f.edge(h);e.forEach(g.points,p),e.has(g,"x")&&p(g)})}function p(f){var h=f.x;f.x=f.y,f.y=h}return qg}var $g,nE;function q4(){if(nE)return $g;nE=1;var e=it();$g=n;function n(r){var i={},o=e.filter(r.nodes(),function(f){return!r.children(f).length}),l=e.max(e.map(o,function(f){return r.node(f).rank})),u=e.map(e.range(l+1),function(){return[]});function c(f){if(!e.has(i,f)){i[f]=!0;var h=r.node(f);u[h.rank].push(f),e.forEach(r.successors(f),c)}}var p=e.sortBy(o,function(f){return r.node(f).rank});return e.forEach(p,c),u}return $g}var Dg,rE;function $4(){if(rE)return Dg;rE=1;var e=it();Dg=n;function n(i,o){for(var l=0,u=1;u<o.length;++u)l+=r(i,o[u-1],o[u]);return l}function r(i,o,l){for(var u=e.zipObject(l,e.map(l,function(y,x){return x})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(i.outEdges(y),function(x){return{pos:u[x.w],weight:i.edge(x).weight}}),"pos")}),!0),p=1;p<l.length;)p<<=1;var f=2*p-1;p-=1;var h=e.map(new Array(f),function(){return 0}),g=0;return e.forEach(c.forEach(function(y){var x=y.pos+p;h[x]+=y.weight;for(var N=0;x>0;)x%2&&(N+=h[x+1]),x=x-1>>1,h[x]+=y.weight;g+=y.weight*N})),g}return Dg}var Fg,sE;function D4(){if(sE)return Fg;sE=1;var e=it();Fg=n;function n(r,i){return e.map(i,function(o){var l=r.inEdges(o);if(l.length){var u=e.reduce(l,function(c,p){var f=r.edge(p),h=r.node(p.v);return{sum:c.sum+f.weight*h.order,weight:c.weight+f.weight}},{sum:0,weight:0});return{v:o,barycenter:u.sum/u.weight,weight:u.weight}}else return{v:o}})}return Fg}var zg,iE;function F4(){if(iE)return zg;iE=1;var e=it();zg=n;function n(o,l){var u={};e.forEach(o,function(p,f){var h=u[p.v]={indegree:0,in:[],out:[],vs:[p.v],i:f};e.isUndefined(p.barycenter)||(h.barycenter=p.barycenter,h.weight=p.weight)}),e.forEach(l.edges(),function(p){var f=u[p.v],h=u[p.w];!e.isUndefined(f)&&!e.isUndefined(h)&&(h.indegree++,f.out.push(u[p.w]))});var c=e.filter(u,function(p){return!p.indegree});return r(c)}function r(o){var l=[];function u(f){return function(h){h.merged||(e.isUndefined(h.barycenter)||e.isUndefined(f.barycenter)||h.barycenter>=f.barycenter)&&i(f,h)}}function c(f){return function(h){h.in.push(f),--h.indegree===0&&o.push(h)}}for(;o.length;){var p=o.pop();l.push(p),e.forEach(p.in.reverse(),u(p)),e.forEach(p.out,c(p))}return e.map(e.filter(l,function(f){return!f.merged}),function(f){return e.pick(f,["vs","i","barycenter","weight"])})}function i(o,l){var u=0,c=0;o.weight&&(u+=o.barycenter*o.weight,c+=o.weight),l.weight&&(u+=l.barycenter*l.weight,c+=l.weight),o.vs=l.vs.concat(o.vs),o.barycenter=u/c,o.weight=c,o.i=Math.min(l.i,o.i),l.merged=!0}return zg}var Bg,oE;function z4(){if(oE)return Bg;oE=1;var e=it(),n=hn();Bg=r;function r(l,u){var c=n.partition(l,function(_){return e.has(_,"barycenter")}),p=c.lhs,f=e.sortBy(c.rhs,function(_){return-_.i}),h=[],g=0,y=0,x=0;p.sort(o(!!u)),x=i(h,f,x),e.forEach(p,function(_){x+=_.vs.length,h.push(_.vs),g+=_.barycenter*_.weight,y+=_.weight,x=i(h,f,x)});var N={vs:e.flatten(h,!0)};return y&&(N.barycenter=g/y,N.weight=y),N}function i(l,u,c){for(var p;u.length&&(p=e.last(u)).i<=c;)u.pop(),l.push(p.vs),c++;return c}function o(l){return function(u,c){return u.barycenter<c.barycenter?-1:u.barycenter>c.barycenter?1:l?c.i-u.i:u.i-c.i}}return Bg}var Ug,aE;function B4(){if(aE)return Ug;aE=1;var e=it(),n=D4(),r=F4(),i=z4();Ug=o;function o(c,p,f,h){var g=c.children(p),y=c.node(p),x=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,_={};x&&(g=e.filter(g,function(A){return A!==x&&A!==N}));var S=n(c,g);e.forEach(S,function(A){if(c.children(A.v).length){var M=o(c,A.v,f,h);_[A.v]=M,e.has(M,"barycenter")&&u(A,M)}});var b=r(S,f);l(b,_);var k=i(b,h);if(x&&(k.vs=e.flatten([x,k.vs,N],!0),c.predecessors(x).length)){var E=c.node(c.predecessors(x)[0]),C=c.node(c.predecessors(N)[0]);e.has(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+E.order+C.order)/(k.weight+2),k.weight+=2}return k}function l(c,p){e.forEach(c,function(f){f.vs=e.flatten(f.vs.map(function(h){return p[h]?p[h].vs:h}),!0)})}function u(c,p){e.isUndefined(c.barycenter)?(c.barycenter=p.barycenter,c.weight=p.weight):(c.barycenter=(c.barycenter*c.weight+p.barycenter*p.weight)/(c.weight+p.weight),c.weight+=p.weight)}return Ug}var Hg,lE;function U4(){if(lE)return Hg;lE=1;var e=it(),n=Jn().Graph;Hg=r;function r(o,l,u){var c=i(o),p=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(f){return o.node(f)});return e.forEach(o.nodes(),function(f){var h=o.node(f),g=o.parent(f);(h.rank===l||h.minRank<=l&&l<=h.maxRank)&&(p.setNode(f),p.setParent(f,g||c),e.forEach(o[u](f),function(y){var x=y.v===f?y.w:y.v,N=p.edge(x,f),_=e.isUndefined(N)?0:N.weight;p.setEdge(x,f,{weight:o.edge(y).weight+_})}),e.has(h,"minRank")&&p.setNode(f,{borderLeft:h.borderLeft[l],borderRight:h.borderRight[l]}))}),p}function i(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return Hg}var Wg,uE;function H4(){if(uE)return Wg;uE=1;var e=it();Wg=n;function n(r,i,o){var l={},u;e.forEach(o,function(c){for(var p=r.parent(c),f,h;p;){if(f=r.parent(p),f?(h=l[f],l[f]=p):(h=u,u=p),h&&h!==p){i.setEdge(h,p);return}p=f}})}return Wg}var Vg,cE;function W4(){if(cE)return Vg;cE=1;var e=it(),n=q4(),r=$4(),i=B4(),o=U4(),l=H4(),u=Jn().Graph,c=hn();Vg=p;function p(y){var x=c.maxRank(y),N=f(y,e.range(1,x+1),"inEdges"),_=f(y,e.range(x-1,-1,-1),"outEdges"),S=n(y);g(y,S);for(var b=Number.POSITIVE_INFINITY,k,E=0,C=0;C<4;++E,++C){h(E%2?N:_,E%4>=2),S=c.buildLayerMatrix(y);var A=r(y,S);A<b&&(C=0,k=e.cloneDeep(S),b=A)}g(y,k)}function f(y,x,N){return e.map(x,function(_){return o(y,_,N)})}function h(y,x){var N=new u;e.forEach(y,function(_){var S=_.graph().root,b=i(_,S,N,x);e.forEach(b.vs,function(k,E){_.node(k).order=E}),l(_,N,b.vs)})}function g(y,x){e.forEach(x,function(N){e.forEach(N,function(_,S){y.node(_).order=S})})}return Vg}var Gg,dE;function V4(){if(dE)return Gg;dE=1;var e=it(),n=Jn().Graph,r=hn();Gg={positionX:N,findType1Conflicts:i,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:p,horizontalCompaction:f,alignCoordinates:y,findSmallestWidthAlignment:g,balance:x};function i(b,k){var E={};function C(A,M){var L=0,H=0,O=A.length,P=e.last(M);return e.forEach(M,function(F,G){var q=l(b,F),R=q?b.node(q).order:O;(q||F===P)&&(e.forEach(M.slice(H,G+1),function(Q){e.forEach(b.predecessors(Q),function(z){var ne=b.node(z),Z=ne.order;(Z<L||R<Z)&&!(ne.dummy&&b.node(Q).dummy)&&u(E,z,Q)})}),H=G+1,L=R)}),M}return e.reduce(k,C),E}function o(b,k){var E={};function C(M,L,H,O,P){var F;e.forEach(e.range(L,H),function(G){F=M[G],b.node(F).dummy&&e.forEach(b.predecessors(F),function(q){var R=b.node(q);R.dummy&&(R.order<O||R.order>P)&&u(E,q,F)})})}function A(M,L){var H=-1,O,P=0;return e.forEach(L,function(F,G){if(b.node(F).dummy==="border"){var q=b.predecessors(F);q.length&&(O=b.node(q[0]).order,C(L,P,G,H,O),P=G,H=O)}C(L,P,L.length,O,M.length)}),L}return e.reduce(k,A),E}function l(b,k){if(b.node(k).dummy)return e.find(b.predecessors(k),function(E){return b.node(E).dummy})}function u(b,k,E){if(k>E){var C=k;k=E,E=C}var A=b[k];A||(b[k]=A={}),A[E]=!0}function c(b,k,E){if(k>E){var C=k;k=E,E=C}return e.has(b[k],E)}function p(b,k,E,C){var A={},M={},L={};return e.forEach(k,function(H){e.forEach(H,function(O,P){A[O]=O,M[O]=O,L[O]=P})}),e.forEach(k,function(H){var O=-1;e.forEach(H,function(P){var F=C(P);if(F.length){F=e.sortBy(F,function(z){return L[z]});for(var G=(F.length-1)/2,q=Math.floor(G),R=Math.ceil(G);q<=R;++q){var Q=F[q];M[P]===P&&O<L[Q]&&!c(E,P,Q)&&(M[Q]=P,M[P]=A[P]=A[Q],O=L[Q])}}})}),{root:A,align:M}}function f(b,k,E,C,A){var M={},L=h(b,k,E,A),H=A?"borderLeft":"borderRight";function O(G,q){for(var R=L.nodes(),Q=R.pop(),z={};Q;)z[Q]?G(Q):(z[Q]=!0,R.push(Q),R=R.concat(q(Q))),Q=R.pop()}function P(G){M[G]=L.inEdges(G).reduce(function(q,R){return Math.max(q,M[R.v]+L.edge(R))},0)}function F(G){var q=L.outEdges(G).reduce(function(Q,z){return Math.min(Q,M[z.w]-L.edge(z))},Number.POSITIVE_INFINITY),R=b.node(G);q!==Number.POSITIVE_INFINITY&&R.borderType!==H&&(M[G]=Math.max(M[G],q))}return O(P,L.predecessors.bind(L)),O(F,L.successors.bind(L)),e.forEach(C,function(G){M[G]=M[E[G]]}),M}function h(b,k,E,C){var A=new n,M=b.graph(),L=_(M.nodesep,M.edgesep,C);return e.forEach(k,function(H){var O;e.forEach(H,function(P){var F=E[P];if(A.setNode(F),O){var G=E[O],q=A.edge(G,F);A.setEdge(G,F,Math.max(L(b,P,O),q||0))}O=P})}),A}function g(b,k){return e.minBy(e.values(k),function(E){var C=Number.NEGATIVE_INFINITY,A=Number.POSITIVE_INFINITY;return e.forIn(E,function(M,L){var H=S(b,L)/2;C=Math.max(M+H,C),A=Math.min(M-H,A)}),C-A})}function y(b,k){var E=e.values(k),C=e.min(E),A=e.max(E);e.forEach(["u","d"],function(M){e.forEach(["l","r"],function(L){var H=M+L,O=b[H],P;if(O!==k){var F=e.values(O);P=L==="l"?C-e.min(F):A-e.max(F),P&&(b[H]=e.mapValues(O,function(G){return G+P}))}})})}function x(b,k){return e.mapValues(b.ul,function(E,C){if(k)return b[k.toLowerCase()][C];var A=e.sortBy(e.map(b,C));return(A[1]+A[2])/2})}function N(b){var k=r.buildLayerMatrix(b),E=e.merge(i(b,k),o(b,k)),C={},A;e.forEach(["u","d"],function(L){A=L==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(H){H==="r"&&(A=e.map(A,function(G){return e.values(G).reverse()}));var O=(L==="u"?b.predecessors:b.successors).bind(b),P=p(b,A,E,O),F=f(b,A,P.root,P.align,H==="r");H==="r"&&(F=e.mapValues(F,function(G){return-G})),C[L+H]=F})});var M=g(b,C);return y(C,M),x(C,b.graph().align)}function _(b,k,E){return function(C,A,M){var L=C.node(A),H=C.node(M),O=0,P;if(O+=L.width/2,e.has(L,"labelpos"))switch(L.labelpos.toLowerCase()){case"l":P=-L.width/2;break;case"r":P=L.width/2;break}if(P&&(O+=E?P:-P),P=0,O+=(L.dummy?k:b)/2,O+=(H.dummy?k:b)/2,O+=H.width/2,e.has(H,"labelpos"))switch(H.labelpos.toLowerCase()){case"l":P=H.width/2;break;case"r":P=-H.width/2;break}return P&&(O+=E?P:-P),P=0,O}}function S(b,k){return b.node(k).width}return Gg}var Yg,fE;function G4(){if(fE)return Yg;fE=1;var e=it(),n=hn(),r=V4().positionX;Yg=i;function i(l){l=n.asNonCompoundGraph(l),o(l),e.forEach(r(l),function(u,c){l.node(c).x=u})}function o(l){var u=n.buildLayerMatrix(l),c=l.graph().ranksep,p=0;e.forEach(u,function(f){var h=e.max(e.map(f,function(g){return l.node(g).height}));e.forEach(f,function(g){l.node(g).y=p+h/2}),p+=h+c})}return Yg}var Kg,hE;function Y4(){if(hE)return Kg;hE=1;var e=it(),n=R4(),r=T4(),i=I4(),o=hn().normalizeRanks,l=M4(),u=hn().removeEmptyRanks,c=P4(),p=O4(),f=L4(),h=W4(),g=G4(),y=hn(),x=Jn().Graph;Kg=N;function N(U,J){var re=J&&J.debugTiming?y.time:y.notime;re("layout",function(){var le=re(" buildLayoutGraph",function(){return O(U)});re(" runLayout",function(){_(le,re)}),re(" updateInputGraph",function(){S(U,le)})})}function _(U,J){J(" makeSpaceForEdgeLabels",function(){P(U)}),J(" removeSelfEdges",function(){$(U)}),J(" acyclic",function(){n.run(U)}),J(" nestingGraph.run",function(){c.run(U)}),J(" rank",function(){i(y.asNonCompoundGraph(U))}),J(" injectEdgeLabelProxies",function(){F(U)}),J(" removeEmptyRanks",function(){u(U)}),J(" nestingGraph.cleanup",function(){c.cleanup(U)}),J(" normalizeRanks",function(){o(U)}),J(" assignRankMinMax",function(){G(U)}),J(" removeEdgeLabelProxies",function(){q(U)}),J(" normalize.run",function(){r.run(U)}),J(" parentDummyChains",function(){l(U)}),J(" addBorderSegments",function(){p(U)}),J(" order",function(){h(U)}),J(" insertSelfEdges",function(){X(U)}),J(" adjustCoordinateSystem",function(){f.adjust(U)}),J(" position",function(){g(U)}),J(" positionSelfEdges",function(){I(U)}),J(" removeBorderNodes",function(){Z(U)}),J(" normalize.undo",function(){r.undo(U)}),J(" fixupEdgeLabelCoords",function(){z(U)}),J(" undoCoordinateSystem",function(){f.undo(U)}),J(" translateGraph",function(){R(U)}),J(" assignNodeIntersects",function(){Q(U)}),J(" reversePoints",function(){ne(U)}),J(" acyclic.undo",function(){n.undo(U)})}function S(U,J){e.forEach(U.nodes(),function(re){var le=U.node(re),fe=J.node(re);le&&(le.x=fe.x,le.y=fe.y,J.children(re).length&&(le.width=fe.width,le.height=fe.height))}),e.forEach(U.edges(),function(re){var le=U.edge(re),fe=J.edge(re);le.points=fe.points,e.has(fe,"x")&&(le.x=fe.x,le.y=fe.y)}),U.graph().width=J.graph().width,U.graph().height=J.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],C=["width","height"],A={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],L={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},H=["labelpos"];function O(U){var J=new x({multigraph:!0,compound:!0}),re=Y(U.graph());return J.setGraph(e.merge({},k,W(re,b),e.pick(re,E))),e.forEach(U.nodes(),function(le){var fe=Y(U.node(le));J.setNode(le,e.defaults(W(fe,C),A)),J.setParent(le,U.parent(le))}),e.forEach(U.edges(),function(le){var fe=Y(U.edge(le));J.setEdge(le,e.merge({},L,W(fe,M),e.pick(fe,H)))}),J}function P(U){var J=U.graph();J.ranksep/=2,e.forEach(U.edges(),function(re){var le=U.edge(re);le.minlen*=2,le.labelpos.toLowerCase()!=="c"&&(J.rankdir==="TB"||J.rankdir==="BT"?le.width+=le.labeloffset:le.height+=le.labeloffset)})}function F(U){e.forEach(U.edges(),function(J){var re=U.edge(J);if(re.width&&re.height){var le=U.node(J.v),fe=U.node(J.w),te={rank:(fe.rank-le.rank)/2+le.rank,e:J};y.addDummyNode(U,"edge-proxy",te,"_ep")}})}function G(U){var J=0;e.forEach(U.nodes(),function(re){var le=U.node(re);le.borderTop&&(le.minRank=U.node(le.borderTop).rank,le.maxRank=U.node(le.borderBottom).rank,J=e.max(J,le.maxRank))}),U.graph().maxRank=J}function q(U){e.forEach(U.nodes(),function(J){var re=U.node(J);re.dummy==="edge-proxy"&&(U.edge(re.e).labelRank=re.rank,U.removeNode(J))})}function R(U){var J=Number.POSITIVE_INFINITY,re=0,le=Number.POSITIVE_INFINITY,fe=0,te=U.graph(),ce=te.marginx||0,Ce=te.marginy||0;function ve(Te){var ye=Te.x,ke=Te.y,Ge=Te.width,we=Te.height;J=Math.min(J,ye-Ge/2),re=Math.max(re,ye+Ge/2),le=Math.min(le,ke-we/2),fe=Math.max(fe,ke+we/2)}e.forEach(U.nodes(),function(Te){ve(U.node(Te))}),e.forEach(U.edges(),function(Te){var ye=U.edge(Te);e.has(ye,"x")&&ve(ye)}),J-=ce,le-=Ce,e.forEach(U.nodes(),function(Te){var ye=U.node(Te);ye.x-=J,ye.y-=le}),e.forEach(U.edges(),function(Te){var ye=U.edge(Te);e.forEach(ye.points,function(ke){ke.x-=J,ke.y-=le}),e.has(ye,"x")&&(ye.x-=J),e.has(ye,"y")&&(ye.y-=le)}),te.width=re-J+ce,te.height=fe-le+Ce}function Q(U){e.forEach(U.edges(),function(J){var re=U.edge(J),le=U.node(J.v),fe=U.node(J.w),te,ce;re.points?(te=re.points[0],ce=re.points[re.points.length-1]):(re.points=[],te=fe,ce=le),re.points.unshift(y.intersectRect(le,te)),re.points.push(y.intersectRect(fe,ce))})}function z(U){e.forEach(U.edges(),function(J){var re=U.edge(J);if(e.has(re,"x"))switch((re.labelpos==="l"||re.labelpos==="r")&&(re.width-=re.labeloffset),re.labelpos){case"l":re.x-=re.width/2+re.labeloffset;break;case"r":re.x+=re.width/2+re.labeloffset;break}})}function ne(U){e.forEach(U.edges(),function(J){var re=U.edge(J);re.reversed&&re.points.reverse()})}function Z(U){e.forEach(U.nodes(),function(J){if(U.children(J).length){var re=U.node(J),le=U.node(re.borderTop),fe=U.node(re.borderBottom),te=U.node(e.last(re.borderLeft)),ce=U.node(e.last(re.borderRight));re.width=Math.abs(ce.x-te.x),re.height=Math.abs(fe.y-le.y),re.x=te.x+re.width/2,re.y=le.y+re.height/2}}),e.forEach(U.nodes(),function(J){U.node(J).dummy==="border"&&U.removeNode(J)})}function $(U){e.forEach(U.edges(),function(J){if(J.v===J.w){var re=U.node(J.v);re.selfEdges||(re.selfEdges=[]),re.selfEdges.push({e:J,label:U.edge(J)}),U.removeEdge(J)}})}function X(U){var J=y.buildLayerMatrix(U);e.forEach(J,function(re){var le=0;e.forEach(re,function(fe,te){var ce=U.node(fe);ce.order=te+le,e.forEach(ce.selfEdges,function(Ce){y.addDummyNode(U,"selfedge",{width:Ce.label.width,height:Ce.label.height,rank:ce.rank,order:te+ ++le,e:Ce.e,label:Ce.label},"_se")}),delete ce.selfEdges})})}function I(U){e.forEach(U.nodes(),function(J){var re=U.node(J);if(re.dummy==="selfedge"){var le=U.node(re.e.v),fe=le.x+le.width/2,te=le.y,ce=re.x-fe,Ce=le.height/2;U.setEdge(re.e,re.label),U.removeNode(J),re.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}],re.label.x=re.x,re.label.y=re.y}})}function W(U,J){return e.mapValues(e.pick(U,J),Number)}function Y(U){var J={};return e.forEach(U,function(re,le){J[le.toLowerCase()]=re}),J}return Kg}var Xg,pE;function K4(){if(pE)return Xg;pE=1;var e=it(),n=hn(),r=Jn().Graph;Xg={debugOrdering:i};function i(o){var l=n.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(l,function(c,p){var f="layer"+p;u.setNode(f,{rank:"same"}),e.reduce(c,function(h,g){return u.setEdge(h,g,{style:"invis"}),g})}),u}return Xg}var Qg,mE;function X4(){return mE||(mE=1,Qg="0.8.5"),Qg}var Zg,gE;function Q4(){return gE||(gE=1,Zg={graphlib:Jn(),layout:Y4(),debug:K4(),util:{time:hn().time,notime:hn().notime},version:X4()}),Zg}var Z4=Q4();const vE=Cv(Z4),go=240,yu=130,uo=74,Hu=72,yE=uo+Hu;function J4(e,n){var i;let r=go;for(const o of e)r=Math.max(r,((i=n.get(o.id))==null?void 0:i.width)??go);return r}const gj=420,eD=2;function ja(e){var r;return((r=e.data)==null?void 0:r.sessionId)??"_default"}function tD(e,n){return((n==null?void 0:n.get(e))??0)>0?gj:0}function nD(e,n){const r=(n==null?void 0:n.get(e))??0;return r>0?6+r*36:0}function Ra(e,n,r){const i=n.get(e);return{w:((i==null?void 0:i.width)??go)+tD(e,r),h:Math.max((i==null?void 0:i.height)??yu,nD(e,r))}}function rD(e){return[...e.keys()].sort().map(n=>`${n}:${e.get(n)}`).join("|")}function sD(e,n,r,i,o,l){const u=new vE.graphlib.Graph;u.setDefaultEdgeLabel(()=>({})),u.setGraph({rankdir:r,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(b=>!o.has(b)),p=new Set(c);for(const b of c){const{w:k,h:E}=Ra(b,i,l);u.setNode(b,{width:k,height:E})}for(const b of n)p.has(b.source)&&p.has(b.target)&&u.setEdge(b.source,b.target);vE.layout(u);const f=new Map;let h=1/0,g=1/0,y=-1/0,x=-1/0;for(const b of c){const k=u.node(b);if(!k)continue;const E=i.get(b),C=(E==null?void 0:E.width)??go,A=(E==null?void 0:E.height)??yu,M=Ra(b,i,l),L=k.x-M.w/2,H=k.y-M.h/2;f.set(b,{x:L,y:H}),L<h&&(h=L),H<g&&(g=H),L+C>y&&(y=L+C),H+A>x&&(x=H+A)}if(Number.isFinite(h)&&Number.isFinite(g))for(const[b,k]of f)f.set(b,{x:k.x-h,y:k.y-g});const N=Number.isFinite(y)?y-h:0,_=Number.isFinite(x)?x-g:0;let S=null;for(const b of e){const k=o.get(b);if(!k)continue;const E=i.get(b),C=(E==null?void 0:E.width)??go,A=(E==null?void 0:E.height)??yu;S=S===null?{minX:k.x,minY:k.y,maxX:k.x+C,maxY:k.y+A}:{minX:Math.min(S.minX,k.x),minY:Math.min(S.minY,k.y),maxX:Math.max(S.maxX,k.x+C),maxY:Math.max(S.maxY,k.y+A)}}return{positions:f,width:N,height:_,pinnedBox:S}}function iD(e,n,r={}){const i=r.direction??"LR",o=r.pinned??new Map,l=r.measured??new Map,u=r.lanes,c=new Map;for(const b of e){const k=ja(b),E=c.get(k);E?E.push(b.id):c.set(k,[b.id])}const f=Array.from(c.keys()).sort().map(b=>({sid:b,...sD(c.get(b),n,i,l,o,u)})),h=J4(e,l),g=r.availableHeight&&r.availableHeight>0?r.availableHeight:Number.POSITIVE_INFINITY,y=b=>{const k=[[]];let E=0;for(const C of f)k.length<b&&E>0&&E+C.height>g&&(k.push([]),E=0),k[k.length-1].push(C),E+=C.height+yE;return k},x=b=>b.reduce((k,E)=>Math.max(k,E.width),0)+gj;let N=y(r.availableWidth?eD:1);N.length>1&&N.reduce((k,E)=>k+x(E),0)+h*(N.length-1)>(r.availableWidth??0)&&(N=y(1));const _=new Map;let S=0;for(const b of N){const k=x(b);let E=0;for(const{positions:C,height:A,pinnedBox:M}of b){for(const[H,O]of C)_.set(H,{x:O.x+S,y:O.y+E});let L=E+A;M&&M.maxY>L&&M.minX<S+k&&S<M.maxX&&(L=M.maxY),E=L+yE}S+=k+h}return e.map(b=>{const k=o.get(b.id);if(k)return{...b,position:k};const E=_.get(b.id);return E?{...b,position:E}:b})}function oD(e,n,r,i,o){const u=uo+Hu,c=60,p=x=>Ra(x,i,o),f=new Map(e.map(x=>[x.id,ja(x)])),h=[],g=e.map(x=>({id:x.id,pos:r.get(x.id)??n.get(x.id)})).filter(x=>x.pos!=null).sort((x,N)=>x.pos.y-N.pos.y||x.pos.x-N.pos.x||x.id.localeCompare(N.id)),y=[];for(const{id:x,pos:N}of g){const{w:_,h:S}=p(x),b=f.get(x)??"_default";if(r.has(x)){h.push({x:N.x,y:N.y,w:_,h:S,sid:b});continue}let k=N.y;for(let E=0;E<h.length+1;E++){const C=h.find(A=>{const M=A.sid===b?24:c,L=A.sid===b?24:u;return N.x<A.x+A.w+M&&A.x<N.x+_+M&&k<A.y+A.h+L&&A.y<k+S+L});if(!C)break;k=C.y+C.h+(C.sid===b?24:u)}k!==N.y&&(n.set(x,{x:N.x,y:k}),y.push(x)),h.push({x:N.x,y:k,w:_,h:S,sid:b})}return y}function aD(e,n,r,i,o,l){const u=_=>Ra(_,i,l),c=_=>r.get(_)??n.get(_),p=new Map;for(const _ of e){if(!c(_.id))continue;const S=ja(_),b=p.get(S);b?b.push(_):p.set(S,[_])}const f=new Set;for(const[_,S]of p)S.every(b=>o.has(b.id)&&!r.has(b.id))&&f.add(_);const h=new Map,g=[];for(const _ of e){const S=c(_.id);if(!S)continue;const{w:b,h:k}=u(_.id),E=ja(_);f.has(E)?(h.get(E)??h.set(E,[]).get(E)).push(_):g.push({x:S.x,y:S.y,w:b,h:k})}if(h.size===0)return[];const y=uo+Hu,x=(_,S,b,k)=>g.some(E=>_<E.x+E.w+uo&&E.x<_+b+uo&&S<E.y+E.h+y&&E.y<S+k+y),N=[];for(const _ of[...h.keys()].sort()){const S=h.get(_);let b=1/0,k=1/0,E=-1/0,C=-1/0;for(const F of S){const G=c(F.id),{w:q,h:R}=u(F.id);b=Math.min(b,G.x),k=Math.min(k,G.y),E=Math.max(E,G.x+q),C=Math.max(C,G.y+R)}const A=E-b,M=C-k,L=[...new Set(g.map(F=>Math.round(F.x)))].sort((F,G)=>F-G),H=L.length?L:[b],O=[0,...g.map(F=>F.y+F.h+y)].sort((F,G)=>F-G);let P=null;e:for(const F of H)for(const G of O){if(G>=k)break;if(!x(F,G,A,M)){P={x:F,y:G};break e}}if(P){const F=P.x-b,G=P.y-k;for(const q of S){const R=c(q.id);n.set(q.id,{x:R.x+F,y:R.y+G})}N.push(_)}for(const F of S){const G=c(F.id),{w:q,h:R}=u(F.id);g.push({x:G.x,y:G.y,w:q,h:R})}}return N}function lD(e,n,r,i,o,l=!1,u){const f=uo+Hu+1,h=8,g=1.75,y=200,x=.7,N=.01,_=P=>Ra(P,i,u),S=P=>r.get(P)??n.get(P),b=new Map;for(const P of e){if(!S(P.id))continue;const F=ja(P),G=b.get(F);G?G.push(P):b.set(F,[P])}const k=[],E=new Set,C=new Set,A=o.size===0;for(const P of[...b.keys()].sort()){const F=b.get(P);let G=1/0,q=1/0,R=-1/0,Q=-1/0,z=!1;for(const X of F){const I=S(X.id),{w:W,h:Y}=_(X.id);G=Math.min(G,I.x),q=Math.min(q,I.y),R=Math.max(R,I.x+W),Q=Math.max(Q,I.y+Y),r.has(X.id)&&(z=!0)}const ne=R-G,Z=Q-q;C.add(P);const $=o.get(P);$&&(ne>$.w+h||Z>$.h+h)&&E.add(P),o.set(P,{w:ne,h:Z}),k.push({sid:P,members:F.map(X=>X.id),x:G,y:q,w:ne,h:Z,anchored:z,mass:1})}for(const P of[...o.keys()])C.has(P)||o.delete(P);if(l||A)return[];let M=!1;for(let P=0;P<k.length&&!M;P++)for(let F=P+1;F<k.length;F++){const G=k[P],q=k[F];if(!(G.anchored&&q.anchored)&&Math.abs(G.x+G.w/2-(q.x+q.w/2))<(G.w+q.w)/2+61&&Math.abs(G.y+G.h/2-(q.y+q.h/2))<(G.h+q.h)/2+f){M=!0;break}}if(E.size===0&&!M)return[];if(E.size>0)for(const P of k)E.has(P.sid)&&(P.mass=8);else for(const P of k)P.mass=Math.max(1,P.w*P.h/(go*yu));const L=new Map(k.map(P=>[P.sid,P.x])),H=new Map(k.map(P=>[P.sid,P.y]));for(let P=0;P<y;P++){const F=new Map,G=new Map;let q=0;for(let R=0;R<k.length;R++)for(let Q=R+1;Q<k.length;Q++){const z=k[R],ne=k[Q];if(z.anchored&&ne.anchored)continue;const Z=z.x+z.w/2,$=z.y+z.h/2,X=ne.x+ne.w/2,I=ne.y+ne.h/2,W=(z.w+ne.w)/2+61-Math.abs(Z-X),Y=(z.h+ne.h)/2+f-Math.abs($-I);if(W<=0||Y<=0)continue;const U=(De,Ze)=>!De.anchored&&!(Ze<0&&De.x<=0),J=(De,Ze)=>!De.anchored&&!(Ze<0&&De.y<=0),re=(De,Ze,Ye)=>{const vt=De===Ze,ot=vt?z.sid<ne.sid?-1:1:Math.sign(De-Ze);return Ye(z,ot)||Ye(ne,-ot)?ot:vt&&(Ye(z,-ot)||Ye(ne,ot))?-ot:0},le=re(Z,X,U),fe=re($,I,J),te=le!==0,ce=fe!==0;if(!te&&!ce)continue;const Ce=te&&(!ce||W*g<Y),[ve,Te,ye,ke]=Ce?[le,W,F,U]:[fe,Y,G,J],Ge=ke(z,ve),we=ke(ne,-ve),_e=z.mass,ze=ne.mass,ft=Ge?we?ze/(_e+ze):1:0,ht=we?Ge?_e/(_e+ze):1:0,Ue=Te*x;ye.set(z.sid,(ye.get(z.sid)??0)+ve*Ue*ft),ye.set(ne.sid,(ye.get(ne.sid)??0)-ve*Ue*ht),q+=Ue}for(const R of k)R.anchored||(R.x=Math.max(0,R.x+(F.get(R.sid)??0)),R.y=Math.max(0,R.y+(G.get(R.sid)??0)));if(q<N)break}const O=[];for(const P of k){const F=P.x-L.get(P.sid),G=P.y-H.get(P.sid);if(!(Math.abs(F)<1&&Math.abs(G)<1)){for(const q of P.members){if(r.has(q))continue;const R=n.get(q);R&&n.set(q,{x:R.x+F,y:R.y+G})}O.push(P.sid)}}return O}const uD=600;function Sv(e,n){return!(e.exitAt!=null&&n-e.exitAt>uD||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function cD(e,n){const r=new Set;for(const i of e.agents.values())Sv(i,n)&&r.add(i.id);return r}function dD(e,n,r=0){return e.right+r>n.left&&e.left-r<n.right&&e.bottom+r>n.top&&e.top-r<n.bottom}function fD(e,n,r=0){if(!e)return!1;for(const i of n)if(dD(e,i,r))return!0;return!1}const vj="sessionGroup";function hD(e,n){var i;if(e.type===vj)return"transparent";const r=(i=e.data)==null?void 0:i.state;return n(r==="err"?"--err":r==="active"?"--inflight":"--ok")}const pD="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1).";function mD(e){if(e.checkDisabled)return pD;if(e.checking)return"Asking npm for the newest release…";const n=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`${n}${r} · re-checked periodically · click to check npm now`}function gD(e){const n=`Version v${e.running}`;return e.checkDisabled?`${n}, update checks are off`:e.checking?`${n}, checking npm for a newer release`:`${n}, check npm for a newer release`}function vD(e){if(e==null)return{kind:"unknown",lead:"No data yet. Start a Claude Code or Codex session — it appears here as soon as its first hook fires.",workspace:null,tail:""};const n=e.trim();return n===""?{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:n,tail:" — start one there, or restart it without --workspace/--scope to watch the whole machine."}}function yj(e){const n=Math.max(0,Math.floor(e));return`${n} event${n===1?"":"s"}`}function yD(e){return e.connected?e.paused?{tone:"paused",label:"paused",title:e.held>0?`Connected — ${yj(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 wD(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:`${yj(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 wj(e,n){return e!==""&&n>0}function xD(e,n,r){return e===""?{active:!1,matched:n,total:r,count:null,empty:!1,message:null,dim:!1}:{active:!0,matched:n,total:r,count:`${n} of ${r}`,empty:n===0,message:n===0?`No agents match “${e}”`:null,dim:wj(e,n)}}function kv(e){const n=Math.max(0,Math.floor(e/1e3));return n<60?"just now":n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:`${Math.floor(n/86400)}d ago`}function _D(e,n){return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function bD(e,n,r){const i=new Date(e),o=kv(n-e);return{label:_D(i,new Date(n))?o:`${o} · ${i.toLocaleDateString(r,{month:"short",day:"numeric"})}`,title:i.toLocaleString(r,{dateStyle:"medium",timeStyle:"medium"})}}function pa(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const SD={agent:_O,sessionGroup:OO},kD=420,eu=18,ED=9e4,ND=200,CD=5*6e4,jD=6,RD=2*6e4,fy="agent-dag.layout",hy="agent-dag.viewport",xj="agent-dag.summariesDismissed",_j="agent-dag.sessionListOpen",bj="agent-dag.detailOpen",Sj="agent-dag.usagePanelOpen",wE="agent-dag.accountsPanelOpen",xE="agent-dag.versionNoticeDismissed",_E="agent-dag.oldNameNoticeDismissed",TD=15*6e4,bE={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:"},SE="agent-dag.autoRestart",kE="agent-dag.bundleReloadedFor";function AD(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(_j)==="1"}catch{return!1}}function ID(e){if(!(typeof window>"u"))try{window.localStorage.setItem(_j,e?"1":"0")}catch{}}function MD(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(bj)==="1"}catch{return!1}}function PD(e){if(!(typeof window>"u"))try{window.localStorage.setItem(bj,e?"1":"0")}catch{}}function OD(){const e=mC(Sj);return e===null?!0:e==="1"}function LD(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Sj,e?"1":"0")}catch{}}function qD(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(xj);if(!e)return new Set;const n=JSON.parse(e);return new Set(Array.isArray(n)?n.filter(r=>typeof r=="string"):[])}catch{return new Set}}function EE(e){if(!(typeof window>"u"))try{const n=Array.from(e),r=n.length>200?n.slice(-200):n;window.localStorage.setItem(xj,JSON.stringify(r))}catch{}}function $D(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(fy);if(!n)return e;const r=JSON.parse(n);if(!("v"in r)){const o=Object.entries(r).filter(([,l])=>l&&typeof l.x=="number"&&typeof l.y=="number");return{positions:o,pins:o.map(([l])=>l)}}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 Jg(e,n){if(!(typeof window>"u"))try{const r={};for(const[i,o]of e)r[i]=o;for(const[i,o]of n)r[i]=o;window.localStorage.setItem(fy,JSON.stringify({v:2,positions:r,pins:Array.from(n.keys())}))}catch{}}function DD(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(hy);if(!e)return null;const n=JSON.parse(e);return typeof(n==null?void 0:n.x)!="number"||typeof(n==null?void 0:n.y)!="number"||typeof(n==null?void 0:n.zoom)!="number"?null:n}catch{return null}}function FD(e){if(!(typeof window>"u"))try{window.localStorage.setItem(hy,JSON.stringify(e))}catch{}}function NE(){if(!(typeof window>"u")){try{window.localStorage.removeItem(fy)}catch{}try{window.localStorage.removeItem(hy)}catch{}}}function zD(e,n){const r=e.agents.get(n);if(!r)return;const i=[];for(const h of e.agents.values())h.sessionId===n&&i.push(h);const o={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:n,label:r.label,cwd:r.cwd,startedAt:r.startedAt,endedAt:r.endedAt,model:r.model,agents:i.map(h=>({id:h.id,kind:h.kind,label:h.label,parentId:h.parentId,state:h.state,startedAt:h.startedAt,endedAt:h.endedAt,model:h.model,cwd:h.cwd,usage:h.usage,prompts:h.prompts,tools:h.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}))}))},l=JSON.stringify(o,null,2),u=new Blob([l],{type:"application/json"}),c=URL.createObjectURL(u),p=document.createElement("a"),f=(r.label||"session").replace(/[^a-z0-9._-]/gi,"_");p.href=c,p.download=`${zt}-${f}-${n.slice(0,8)}.json`,document.body.appendChild(p),p.click(),document.body.removeChild(p),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const Ev={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Nv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},BD={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",shell:"shell",exec_command:"shell",shell_command:"shell",write_stdin:"shell",wait:"shell",apply_patch:"file",update_plan:"task",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"};function kj(e){return e.startsWith("mcp__")?"mcp":BD[e]??"other"}function Ej(e,n){var i,o,l;if(!n)return!0;const r=n.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)||(l=e.firstPrompt)!=null&&l.toLowerCase().includes(r))return!0;for(const u of e.tools)if(u.name.toLowerCase().includes(r))return!0;return!1}function UD(e,n){if(!n)return null;const r=new Set([n]);let i=n;for(;i;){const l=e.agents.get(i);if(!(l!=null&&l.parentId)||r.has(l.parentId))break;r.add(l.parentId),i=l.parentId}let o=!0;for(;o;){o=!1;for(const l of e.agents.values())l.parentId&&r.has(l.parentId)&&!r.has(l.id)&&(r.add(l.id),o=!0)}return r}function HD(e,n,r,i,o,l,u,c,p,f,h,g,y,x,N,_,S,b,k){const E=[],C=[],A=new Set;if(l)for(const q of e.agents.values())b.has(q.id)&&Ej(q,l)&&A.add(q.id);const M=wj(l,A.size);for(const q of e.agents.values()){if(!b.has(q.id))continue;const R=M&&!A.has(q.id),Q=q.exitAt!=null,z=S!=null&&!S.has(q.id),ne=[R?"rf-dim":"",Q?"rf-exiting":"",z?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,Z=u.get(q.id);if(E.push({id:q.id,type:"agent",position:{x:0,y:0},data:{...q,now:n,onOpenContext:k},className:ne,...Z?{width:Z.width,height:Z.height}:null}),q.parentId&&b.has(q.parentId)){const $=Vv(q.sessionId),X=l&&!A.has(q.id)&&!A.has(q.parentId),I=Q,W=_.size>0&&(_.has(q.id)||_.has(q.parentId)),Y=S!=null&&!S.has(q.id)&&!S.has(q.parentId),U=q.state==="active"?2:1.5,J=W?U+1.5:U,re=X||I?.2:Y?.12:1,le=["sess-edge",q.state==="active"?"sess-live":"sess-idle",I?"rf-edge-exiting":"",W?"rf-edge-selected":""].filter(Boolean).join(" ");C.push({id:`e:${q.parentId}->${q.id}`,source:q.parentId,target:q.id,animated:(q.state==="active"||W)&&!X&&!I,type:"smoothstep",style:{"--session-hue":$,strokeWidth:J,opacity:re,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:le})}}const L=new Map;for(const q of e.agents.values())q.tools.length>0&&L.set(q.id,Math.min(4,q.tools.length));const H=`${x}#lanes:${rD(L)}`,O=E.filter(q=>vL(q.id,o,g,y));if(O.length>0||H!==N.current){if(O.length>0){const q=iD(E,C,{direction:"LR",pinned:o,measured:u,availableWidth:r,availableHeight:i,lanes:L});for(const R of q)pC(R.id,g,y)&&wL(R.id,R.position,g,y);aD(E,g,o,u,new Set(O.map(R=>R.id)),L)}oD(E,g,o,u,L),N.current=H}const P=lD(E,g,o,u,c,!f||h,L);P.length>0&&p(P),Xl(g,e.agents),Xl(y,e.agents),Xl(o,e.agents),Xl(u,gL(e.agents.values()));const F=[];let G=!1;for(const q of E){let R=o.get(q.id)??g.get(q.id);R||(R=yL(q.id,g,y),G=!0),F.push({...q,position:R})}return G&&(N.current=""),{nodes:F,edges:C}}function WD(){return m.jsx(Hv,{children:m.jsx(VD,{})})}function VD(){var Fs,Po,za,Ba;const e=Pa(),n=T.useRef(gv()),[,r]=T.useState(0),i=T.useCallback(()=>r(B=>B+1),[]),[o,l]=T.useState(()=>new Set),[u,c]=T.useState(null),[p,f]=T.useState(null),h=T.useCallback((B,V)=>{l(ae=>{if(!V)return new Set([B]);const de=new Set(ae);return de.has(B)?de.delete(B):de.add(B),de}),c(ae=>V&&ae===B?ae:B)},[]),g=T.useCallback(()=>{l(new Set),c(null)},[]),[y,x]=T.useState(null),[N,_]=T.useState(null),S=T.useCallback(B=>_(B),[]),[b,k]=T.useState(!1),E=T.useRef(qD()),[C,A]=T.useState(AD);T.useEffect(()=>{ID(C)},[C]);const[M,L]=T.useState(MD);T.useEffect(()=>{PD(M)},[M]);const[H,O]=T.useState(OD);T.useEffect(()=>{LD(H)},[H]);const[P,F]=T.useState(()=>{try{const B=window.localStorage.getItem(wE);return B===null?!0:B==="1"}catch{return!0}});T.useEffect(()=>{try{window.localStorage.setItem(wE,P?"1":"0")}catch{}},[P]);const[G,q]=T.useState(null),[R,Q]=T.useState(!1),[z,ne]=T.useState(0),[Z,$]=T.useState(0);T.useEffect(()=>{fetch("/api/sound-hook").then(B=>B.ok?B.json():null).then(B=>{B!=null&&B.ok&&(q(B.enabled===!0),ne((B.foreign??[]).filter(V=>V.worksHere).length),$(typeof B.parked=="number"?B.parked:0))}).catch(()=>{})},[]);const X=T.useCallback(async()=>{Q(!0);try{const V=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!G})})).json().catch(()=>null);V!=null&&V.ok&&q(V.enabled===!0),fetch("/api/sound-hook").then(ae=>ae.ok?ae.json():null).then(ae=>{ae!=null&&ae.ok&&(ne((ae.foreign??[]).filter(de=>de.worksHere).length),$(typeof ae.parked=="number"?ae.parked:0))}).catch(()=>{})}catch{}finally{Q(!1)}},[G]),[I,W]=T.useState(!1),[Y,U]=T.useState(null),[J,re]=T.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(xE)??""}catch{return""}}),[le,fe]=T.useState(!1),te=T.useRef(0),[ce,Ce]=T.useState(!1),ve=T.useCallback((B=!1)=>{B&&(te.current=Date.now(),Ce(!0)),fetch(B?"/api/version?refresh=1":"/api/version").then(V=>V.ok?V.json():null).then(V=>{V&&U(V)}).catch(()=>{}).finally(()=>{B&&Ce(!1)})},[]),Te=T.useCallback(()=>{ve(Date.now()-te.current>=TD)},[ve]);T.useEffect(()=>{ve();const B=window.setInterval(Te,5*6e4),V=()=>{document.visibilityState==="visible"&&Te()};return document.addEventListener("visibilitychange",V),()=>{window.clearInterval(B),document.removeEventListener("visibilitychange",V)}},[ve,Te]),T.useEffect(()=>{I&&ve()},[I,ve]);const ye=(Y==null?void 0:Y.notice)??null,[ke,Ge]=T.useState(null);T.useEffect(()=>{let B=!1;return fetch("/api/health").then(V=>V.ok?V.json():null).then(V=>{B||!V||typeof V.workspace!="string"||Ge(V.workspace)}).catch(()=>{}),()=>{B=!0}},[I]);const we=ye?`${ye.kind}:${ye.to}`:"",_e=ye!=null&&J!==we,ze=T.useCallback(()=>{if(!ye)return;const B=J===we?"":we;re(B);try{window.localStorage.setItem(xE,B)}catch{}},[ye,we,J]),[ft,ht]=T.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(_E)??""}catch{return""}}),Ue=Y!=null&&Y.invokedAs&&Y.invokedAs!==zt?Y.invokedAs:null,De=Ue!=null&&ft!==Ue,Ze=T.useCallback(()=>{if(Ue){ht(Ue);try{window.localStorage.setItem(_E,Ue)}catch{}}},[Ue]),Ye=((Fs=Y==null?void 0:Y.upgrade)==null?void 0:Fs.state)??"idle",vt=oL(Y==null?void 0:Y.upgrade),ot=T.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}ve()},[ve]);T.useEffect(()=>{if(Ye!=="running")return;const B=window.setInterval(ve,3e3);return()=>window.clearInterval(B)},[Ye,ve]);const yt=T.useCallback(async()=>{var ae;const B=Y==null?void 0:Y.command;if(!B)return;let V=!1;try{V=await Promise.race([((ae=navigator.clipboard)==null?void 0:ae.writeText(B).then(()=>!0))??Promise.resolve(!1),new Promise(de=>window.setTimeout(()=>de(!1),500))])}catch{V=!1}if(!V)try{const de=document.createElement("textarea");de.value=B,de.setAttribute("readonly",""),de.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(de),de.select(),V=document.execCommand("copy"),de.remove()}catch{V=!1}V&&(fe(!0),window.setTimeout(()=>fe(!1),1600))},[Y==null?void 0:Y.command]),Kt=T.useCallback(()=>{A(B=>(B||F(!1),!B))},[]),Mt=T.useCallback(()=>{F(B=>(B||A(!1),!B))},[]),[Xe,wt]=T.useState(!1),[pt,mt]=T.useState(0),_n=T.useRef(null),[Xt,Pt]=T.useState(!1),Qt=T.useRef(null),[yr,bn]=T.useState(0),Zt=T.useRef(SL()),[pn,Sn]=T.useState(!1),Gr=T.useCallback(()=>{const B=Zt.current,V=B.setPaused(!B.paused);for(const ae of V)n.current=Cx(n.current,ae);Sn(B.paused)},[]),[ut,hi]=T.useState(Date.now()),[nr,Es]=T.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(SE)!=="0"}catch{return!0}}),pi=T.useCallback(()=>{Es(B=>{const V=!B;try{window.localStorage.setItem(SE,V?"1":"0")}catch{}return V})},[]),[Jt,rr]=T.useState(!1),[wr,So]=T.useState("restart"),[sr,xr]=T.useState(null),mn=T.useRef(!1),Yr=T.useRef(null),mi=T.useRef(0),Kr=T.useCallback(async B=>{if(mn.current)return;const V=(B==null?void 0:B.upgrade)===!0;mn.current=!0,Yr.current=vt;const ae=++mi.current;So(V?"npx":"restart"),rr(!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:V})})}catch{}window.setTimeout(()=>{if(mi.current===ae&&mn.current){mn.current=!1,rr(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},V?18e4:3e4)},[ye==null?void 0:ye.to,vt]),Ns=T.useRef(null);T.useEffect(()=>{let B=!1;for(const ae of n.current.agents.values())if(ae.state==="active"){B=!0;break}const V=lL({enabled:nr,kind:ye==null?void 0:ye.kind,canRestart:(Y==null?void 0:Y.canRestart)===!0,busy:B,idleSince:Ns.current,now:ut});Ns.current=V.idleSince,V.restart&&Kr()},[nr,ye==null?void 0:ye.kind,Y==null?void 0:Y.canRestart,ut,Kr]),T.useEffect(()=>{const B=Y==null?void 0:Y.running;let V=null,ae=null;try{V=window.sessionStorage.getItem("agent-dag.restartPending"),ae=window.sessionStorage.getItem(kE)}catch{return}const de=iL({bundle:"1.33.143",running:B,pending:V,lastTried:ae});if(de==="reload"){try{window.sessionStorage.setItem(kE,B??"")}catch{return}window.location.reload();return}if(de!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}mn.current=!1,rr(!1),xr(B??null);const xe=window.setTimeout(()=>xr(null),6e3);return()=>window.clearTimeout(xe)},[Y==null?void 0:Y.running]),T.useEffect(()=>{if(Jt&&aL({asked:Yr.current,reported:vt})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}mn.current=!1,rr(!1)}},[Jt,vt]);const gn=T.useRef($D()).current;T.useRef(!1);const jt=T.useRef(new Map(gn.positions.filter(([B])=>gn.pins.includes(B)))),_r=T.useRef(null),Xr=T.useState(()=>DD())[0],[en,Qr]=T.useState(""),[Cs,gi]=T.useState(()=>new Set),[ir,vi]=T.useState(jL),[Je,ko]=T.useState(!1),br=T.useRef(null);T.useEffect(()=>{document.documentElement.dataset.theme=ir;try{window.localStorage.setItem(gC,ir)}catch{}},[ir]),T.useEffect(()=>{if(!Xr)return;const B=window.setTimeout(()=>{try{e.setViewport(Xr,{duration:0})}catch{}},60);return()=>window.clearTimeout(B)},[e,Xr]);const js=T.useRef(!0);T.useEffect(()=>{const B=new EventSource("/events"),V=bL(i,{now:()=>Date.now(),setTimeout:(ae,de)=>window.setTimeout(ae,de),clearTimeout:ae=>window.clearTimeout(ae)});return B.addEventListener("open",()=>{W(!0),ko(!0)}),B.addEventListener("error",()=>W(!1)),B.addEventListener("replay-end",()=>{js.current=!1,V.flush()}),B.addEventListener("hook",ae=>{try{const de=JSON.parse(ae.data);if(!Zt.current.accept(de))return;n.current=Cx(n.current,de),de.replay===!0||js.current||Date.now()-de.receivedAt>3e4?V.replay():V.live()}catch{}}),()=>{B.close(),V.cancel()}},[i]),T.useEffect(()=>{const B=setInterval(()=>{const V=Date.now();hi(V);let ae=eO(n.current,V,ED);ZP(n.current,V,ND,CD)&&(ae=!0),JP(n.current,V,jD,RD)&&(ae=!0),ae&&i()},250);return()=>clearInterval(B)},[i]);const or=T.useRef(null),$n=T.useRef(0),yi=420,Ot=T.useCallback((B=500)=>{try{const Ne=document.querySelector(".canvas-wrap"),Ie=Array.from(document.querySelectorAll(".react-flow__node")).filter(xt=>xt.offsetWidth>0);if(!Ne||Ie.length===0)return;const Le=Ne.getBoundingClientRect(),Ve=e.getViewport();if(!Number.isFinite(Ve.zoom)||Ve.zoom<=0)return;const Qe=xt=>(xt-Le.left-Ve.x)/Ve.zoom,rt=xt=>(xt-Le.top-Ve.y)/Ve.zoom,Nn=Ie.map(xt=>xt.getBoundingClientRect()),Ar=Math.min(...Nn.map(xt=>Qe(xt.left))),Oo=Math.max(...Nn.map(xt=>Qe(xt.right))),zs=Math.min(...Nn.map(xt=>rt(xt.top))),Lo=Math.max(...Nn.map(xt=>rt(xt.bottom))),qo=Oo-Ar,Ti=Lo-zs;if(!(qo>0&&Ti>0))return;const Bn=Math.max(.2,Math.min(1,(Le.width-160)/(qo+yi)*.86,(Le.height-160)/Ti*.86));e.setViewport({x:80-Ar*Bn,y:Math.max(80,(Le.height-Ti*Bn)/2)-zs*Bn,zoom:Bn},{duration:B}),$n.current=Date.now(),window.setTimeout(()=>{try{const xt={x:80-Ar*Bn,y:Math.max(80,(Le.height-Ti*Bn)/2)-zs*Bn,zoom:Bn},Ua=e.getViewport();(Math.abs(Ua.zoom-Bn)>.01||Math.abs(Ua.x-xt.x)>2)&&e.setViewport(xt,{duration:0})}catch{}},B+60)}catch{}},[e]),Ut=T.useRef(""),Sr=T.useRef(null),rn=T.useRef(0),wi=T.useCallback(()=>{rn.current=Date.now()},[]),Eo="agent-dag.autoFitDisabled",kr=T.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Eo)==="1"}catch{return!1}})()),[Rs,Ts]=T.useState(kr.current),Zr=T.useCallback(()=>{if(!kr.current){kr.current=!0,Ts(!0);try{window.localStorage.setItem(Eo,"1")}catch{}}},[]),xi=T.useCallback(()=>{kr.current=!1,Ts(!1);try{window.localStorage.removeItem(Eo)}catch{}Ot(400)},[e,Ot]);T.useEffect(()=>{const B=setInterval(()=>{if(kr.current||Date.now()-rn.current<800)return;const V=n.current,ae=Date.now(),de=[];for(const Qe of V.agents.values())Sv(Qe,ae)&&de.push({id:Qe.id});if(de.length===0)return;const xe=e.getViewport(),Ne=window.innerWidth-360,Ie=window.innerHeight-52;let Le=!1,Ve=!1;for(const{id:Qe}of de){const rt=Jr.current.get(Qe),Nn=jt.current.get(Qe)??Ht.current.get(Qe);if(!rt||!Nn)continue;Ve=!0;const Ar=Nn.x*xe.zoom+xe.x,Oo=Nn.y*xe.zoom+xe.y,zs=(Nn.x+rt.width)*xe.zoom+xe.x,Lo=(Nn.y+rt.height)*xe.zoom+xe.y;if(zs>0&&Ar<Ne&&Lo>0&&Oo<Ie){Le=!0;break}}Ve&&!Le&&Ot(600)},1500);return()=>clearInterval(B)},[e]);const No=T.useRef(!1),Jr=T.useRef(new Map),_i=T.useRef(0),Fa=T.useCallback(B=>{const V=Jr.current;let ae=!1;for(const de of B.nodeInternals.values()){const xe=de.width,Ne=de.height;if(xe==null||Ne==null)continue;const Ie=V.get(de.id);Ie?(Math.abs(Ie.height-Ne)>4||Math.abs(Ie.width-xe)>4)&&(V.set(de.id,{width:xe,height:Ne}),ae=!0):(V.set(de.id,{width:xe,height:Ne}),ae=!0)}return ae&&(_i.current+=1),_i.current},[]),bi=Ke(Fa),[es,Wu]=T.useState(0);T.useEffect(()=>{let B=0;const V=()=>{const de=Jr.current;let xe=!1;for(const Ne of document.querySelectorAll(".react-flow__node[data-id]")){const Ie=Ne.getAttribute("data-id");if(!Ie)continue;const Le=Ne.offsetWidth,Ve=Ne.offsetHeight;if(!Le||!Ve)continue;const Qe=de.get(Ie);(!Qe||Math.abs(Qe.width-Le)>4||Math.abs(Qe.height-Ve)>4)&&(de.set(Ie,{width:Le,height:Ve}),xe=!0)}xe&&Wu(Ne=>Ne+1)};if(No.current)return;let ae=0;return document.visibilityState==="hidden"?ae=window.setTimeout(V,32):B=requestAnimationFrame(V),()=>{cancelAnimationFrame(B),window.clearTimeout(ae)}});const Ht=T.useRef(new Map(gn.positions)),We=T.useRef(new Set),Si=T.useRef(""),Er=T.useMemo(()=>{const B=[];for(const V of n.current.agents.values())Sv(V,ut)&&B.push(V.id+(V.parentId?`>${V.parentId}`:""));return B.sort(),`${B.join("|")}#sv${bi}.${es}`},[n.current,n.current.lastSeq,ut,bi,es]),Nr=T.useRef(null);T.useEffect(()=>(Nr.current!=null&&window.clearTimeout(Nr.current),Nr.current=window.setTimeout(()=>{Jg(Ht.current,jt.current)},1500),()=>{Nr.current!=null&&window.clearTimeout(Nr.current)}),[Er]),T.useEffect(()=>{if(Ut.current===Er)return;const B=Ut.current;if(Ut.current=Er,!B||kr.current)return;Date.now()-$n.current>1200&&Ot(400),or.current&&window.clearTimeout(or.current),or.current=window.setTimeout(()=>{kr.current||Ot(500)},280)},[Er,e,Ot]);const ki=T.useMemo(()=>{if(o.size===0)return null;const B=new Set;for(const V of o){const ae=UD(n.current,V);if(ae)for(const de of ae)B.add(de)}return B.size>0?B:null},[n.current,n.current.lastSeq,o]),ar=T.useMemo(()=>cD(n.current,ut),[n.current,n.current.lastSeq,ut]),Co=T.useRef(null),[ts,As]=T.useState({w:0,h:0});T.useEffect(()=>{const B=Co.current;if(!B||typeof ResizeObserver>"u")return;const V=new ResizeObserver(ae=>{var xe;const de=(xe=ae[0])==null?void 0:xe.contentRect;de&&As(Ne=>Math.abs(Ne.w-de.width)>40||Math.abs(Ne.h-de.height)>40?{w:de.width,h:de.height}:Ne)});return V.observe(B),As({w:B.clientWidth,h:B.clientHeight}),()=>V.disconnect()},[]);const lr=T.useRef(new Map),[Dn,ur]=T.useState(!1);T.useEffect(()=>{const B=window.setTimeout(()=>ur(!0),2500);return()=>window.clearTimeout(B)},[]);const[Is,Cr]=T.useState(!1),Lt=T.useRef(null),[jo,Ro]=T.useState(!1),Ms=T.useCallback(()=>{Lt.current&&(window.clearTimeout(Lt.current),Lt.current=null),Cr(!1)},[]),Vu=T.useCallback(B=>{B.length!==0&&queueMicrotask(()=>{Cr(!0),Lt.current&&window.clearTimeout(Lt.current),Lt.current=window.setTimeout(()=>Cr(!1),kD+80)})},[]);T.useEffect(()=>()=>{Lt.current&&window.clearTimeout(Lt.current)},[]);const To=ts.w>0?ts.w*.92:0,Ps=ts.h>0?ts.h:0,{nodes:Fn,edges:Gu}=T.useMemo(()=>HD(n.current,ut,To,Ps,jt.current,en,Jr.current,lr.current,Vu,Dn,jo,Ht.current,We.current,Er,Si,o,ki,ar,S),[n.current,n.current.lastSeq,ut,To,Ps,Dn,jo,en,Er,o,ki,ar,S,pt]),ns=T.useMemo(()=>{const B=new Map;for(const ae of Fn){const de=ae.data;if(!(de!=null&&de.sessionId)||de.exitAt!=null)continue;const xe=ae.width,Ne=ae.height;if(xe==null||Ne==null)continue;const Ie=ae.position.x,Le=ae.position.y,Ve=Ie+xe,Qe=Le+Ne,rt=B.get(de.sessionId);rt?(rt.minX=Math.min(rt.minX,Ie),rt.minY=Math.min(rt.minY,Le),rt.maxX=Math.max(rt.maxX,Ve),rt.maxY=Math.max(rt.maxY,Qe)):B.set(de.sessionId,{minX:Ie,minY:Le,maxX:Ve,maxY:Qe})}const V=[];for(const[ae,de]of B){const xe=de.maxX-de.minX+eu*2,Ne=de.maxY-de.minY+eu*2;V.push({id:`group:${ae}`,type:vj,position:{x:de.minX-eu,y:de.minY-eu},data:{sessionId:ae,w:xe,h:Ne},width:xe,height:Ne,style:{width:xe,height:Ne},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return V},[Fn,ut]),Os=T.useMemo(()=>{const B=[...ns,...Fn],V=Qt.current;return!V||V.size===0?B:B.map(ae=>{const de=V.get(ae.id);return de?{...ae,position:de}:ae})},[ns,Fn,yr]),kn=T.useMemo(()=>{if(!en)return null;const B=new Set;for(const V of n.current.agents.values())ar.has(V.id)&&Ej(V,en)&&B.add(V.id);return B},[n.current,n.current.lastSeq,en,ar]),En=T.useMemo(()=>xD(en,(kn==null?void 0:kn.size)??0,ar.size),[en,kn,ar]),Ei=T.useMemo(()=>{const B=new Set;for(const V of n.current.agents.values())for(const ae of V.tools)B.add(kj(ae.name));return Object.keys(Ev).filter(V=>B.has(V))},[n.current,n.current.lastSeq]);T.useEffect(()=>{if(Ei.length<=1){Pt(!1);return}let B=0;const V=()=>{const ae=_n.current;if(ae&&!document.hidden){const de=ae.getBoundingClientRect(),xe=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Ie=>Ie.getBoundingClientRect()),Ne=fD(de,xe,8);Pt(Ie=>Ie===Ne?Ie:Ne)}B=window.setTimeout(V,300)};return V(),()=>window.clearTimeout(B)},[Ei.length]);const Ls=T.useMemo(()=>{const B=new Map;for(const ae of n.current.agents.values())for(const de of ae.tools){if(!de.name.startsWith("mcp__"))continue;const xe=de.name.slice(5),Ne=xe.indexOf("__"),Ie=Ne>0?xe.slice(0,Ne):xe;B.set(Ie,(B.get(Ie)??0)+1)}const V=[];for(const[ae,de]of B){let xe=5381;for(let Ne=0;Ne<ae.length;Ne++)xe=(xe<<5)+xe^ae.charCodeAt(Ne);V.push({server:ae,count:de,hue:Math.abs(xe)%360})}return V.sort((ae,de)=>de.count-ae.count),V},[n.current,n.current.lastSeq]),Ao=T.useCallback(B=>{gi(V=>{const ae=new Set(V);return ae.has(B)?ae.delete(B):ae.add(B),ae})},[]),St=u?n.current.agents.get(u):null,qs=p?Array.from(n.current.agents.values()).flatMap(B=>B.tools).find(B=>B.id===p)??null:null,Io=T.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=gv(),jt.current.clear(),Jr.current.clear(),Ht.current.clear(),Si.current="",NE(),g(),i()},[i,g]),zn=T.useRef(b);zn.current=b;const Ni=T.useRef(!1);Ni.current=qs!=null||Xe||N!=null||y!=null;const jr=T.useCallback(B=>{const V=mL(B,{confirmOpen:zn.current,modalOpen:Ni.current});V==="confirm"?k(!0):V==="clear"&&(k(!1),Io())},[Io]),Ci=T.useCallback(()=>{jt.current.clear(),Ht.current.clear(),Si.current="",NE(),i(),window.setTimeout(()=>Ot(500),80)},[i,e,Ot]),$s=T.useCallback(()=>Ot(500),[Ot]),rs=T.useRef(Fn);rs.current=Fn;const Mo=T.useRef(u);Mo.current=u;const qt=T.useCallback(B=>{const V=rs.current;if(V.length===0)return;const ae=V.slice().sort((Le,Ve)=>Le.position.y-Ve.position.y||Le.position.x-Ve.position.x),de=Mo.current,xe=de?ae.findIndex(Le=>Le.id===de):-1;let Ne;xe===-1?Ne=B===1?0:ae.length-1:Ne=(xe+B+ae.length)%ae.length;const Ie=ae[Ne];Ie&&(h(Ie.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[Ie]})}catch{}$n.current=Date.now()},30))},[h,e]),Rr=T.useCallback(B=>{h(B,!1),window.setTimeout(()=>{try{const V=rs.current.find(ae=>ae.id===B);V&&e.fitView({padding:.3,duration:500,nodes:[V]}),$n.current=Date.now()}catch{}},60)},[h,e]);T.useEffect(()=>{const B=V=>{var xe,Ne;const ae=V.target,de={tagName:ae==null?void 0:ae.tagName,isContentEditable:ae==null?void 0:ae.isContentEditable,role:(xe=ae==null?void 0:ae.getAttribute)==null?void 0:xe.call(ae,"role"),type:ae==null?void 0:ae.type};if(V.key==="Escape"){const Ie=hO({overlayOpen:yv.depth()>0,typing:hC(de)});Ie==="dismiss"?yv.dismissTop():Ie==="blur"?ae==null||ae.blur():g();return}if(!hL(de)&&!uL(V)){if(V.key==="/"){V.preventDefault(),(Ne=br.current)==null||Ne.focus();return}V.key===" "&&(V.preventDefault(),Gr()),(V.key==="c"||V.key==="C")&&jr("shortcut"),(V.key==="r"||V.key==="R")&&Ci(),(V.key==="f"||V.key==="F")&&$s(),(V.key==="l"||V.key==="L")&&Kt(),(V.key==="h"||V.key==="H")&&wt(Ie=>!Ie),(V.key==="u"||V.key==="U")&&O(Ie=>!Ie),(V.key==="a"||V.key==="A")&&Mt(),(V.key==="j"||V.key==="J")&&qt(1),(V.key==="k"||V.key==="K")&&qt(-1),(V.key==="t"||V.key==="T")&&vi(Ie=>Ie==="dark"?"light":"dark")}};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[jr,Ci,$s,g,qt,Gr]);const Tr=n.current.agents.size,Ds=new Set(Array.from(n.current.agents.values()).map(B=>B.sessionId)).size,cr=T.useMemo(()=>{var V;const B=[];for(const ae of n.current.agents.values())ae.kind==="root"&&((V=ae.waiting)==null?void 0:V.kind)==="permission"&&B.push({id:ae.id,label:ae.label,waiting:ae.waiting});return B.sort((ae,de)=>ae.waiting.since-de.waiting.since)},[n.current,n.current.lastSeq]),ji=T.useMemo(()=>{const B=new Set;for(const V of n.current.agents.values())V.state==="active"&&B.add(V.sessionId);return B.size},[n.current,n.current.lastSeq]),Ri=T.useRef(null);T.useEffect(()=>{const B=RL({waiting:cr.length,running:ji}),V=Ri.current;if(Ri.current=B,(V==null?void 0:V.title)!==B.title&&(document.title=B.title),(V==null?void 0:V.icon)!==B.icon){const ae=document.querySelector('link[rel="icon"]');ae&&(ae.href=TL[B.icon])}},[cr.length,ji]);const Rt=T.useMemo(()=>{let B=0,V=0,ae=0,de=0,xe=0,Ne=0,Ie=0,Le=0,Ve=0;for(const Qe of n.current.agents.values()){B+=Qe.usage.inputTokens,V+=Qe.usage.outputTokens,ae+=Qe.usage.cacheReadTokens,de+=Qe.usage.cacheCreateTokens;const rt=fn(Qe.usage,Qe.model);xe+=rt.total,Ne+=rt.input,Ie+=rt.output,Le+=rt.cacheRead,Ve+=rt.cacheWrite}return{inT:B,outT:V,cacheR:ae,cacheC:de,sum:B+V,cost:{total:xe,input:Ne,output:Ie,cacheRead:Le,cacheWrite:Ve}}},[n.current,n.current.lastSeq]);return m.jsxs("div",{className:"app",children:[m.jsxs("header",{className:"topbar",children:[m.jsxs("div",{className:"brand",children:[m.jsx("span",{className:"logo"}),zt,ye?m.jsxs("button",{type:"button",className:"v stale",onClick:ze,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 B={running:(Y==null?void 0:Y.running)??"1.33.143",latest:Y==null?void 0:Y.latest,latestPending:Y==null?void 0:Y.latestPending,checkedAgo:Y!=null&&Y.checkedAt?kv(ut-Y.checkedAt):null,checkDisabled:Y==null?void 0:Y.checkDisabled,checking:ce};return m.jsxs("button",{type:"button",className:ce?"v checking":"v",onClick:()=>ve(!0),"aria-busy":ce||void 0,"aria-label":gD(B),title:mD(B),children:["v",B.running]})})()]}),St&&(()=>{const B=fn(St.usage,St.model),V=Math.max(0,((St.endedAt??ut)-St.startedAt)/1e3),ae=St.state==="active"?gu(B.total,V):null,de=o.size-1;return m.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${St.label}`,onClick:()=>{try{const xe=Fn.find(Ne=>Ne.id===St.id);xe&&e.fitView({padding:.35,duration:500,nodes:[xe]}),$n.current=Date.now()}catch{}},children:[m.jsx("span",{className:`state-pill state-${St.state}`,children:St.state==="active"?"live":St.state}),m.jsx("span",{className:"selected-label",children:St.label}),B.total>0&&m.jsxs("span",{className:"selected-cost",children:[Fe(B.total),ae?m.jsxs("span",{className:"selected-rate",children:[" · ",ae]}):null]}),de>0&&m.jsxs("span",{className:"selected-extra",children:["+",de]}),m.jsx("span",{role:"button","aria-label":"Deselect",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:br,type:"text",placeholder:"Search agents, cwd, tools…",value:en,onChange:B=>Qr(B.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),en?m.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>Qr(""),children:"×"}):m.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"}),En.count&&m.jsx("span",{className:`search-count${En.empty?" none":""}`,"aria-live":"polite",title:`${En.count} agents on the canvas match “${en}”`,children:En.count})]}),m.jsxs("span",{className:"status",role:"status",children:[(()=>{const B=yD({connected:I,paused:pn,held:Zt.current.size});return m.jsx("span",{className:`pill ${B.tone}`,title:B.title,children:B.label})})(),m.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[m.jsx("span",{className:"count",children:Ds}),m.jsx("span",{className:"lbl",children:"sessions"})]}),m.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[m.jsx("span",{className:"count",children:Tr}),m.jsx("span",{className:"lbl",children:"agents"})]}),m.jsxs("span",{className:"stat",title:"Total hook events received",children:[m.jsx("span",{className:"count",children:n.current.totalEvents}),m.jsx("span",{className:"lbl",children:"events"})]}),Rt.sum>0&&m.jsxs("span",{className:"stat",title:`in:${Rt.inT.toLocaleString()} out:${Rt.outT.toLocaleString()} cache-r:${Rt.cacheR.toLocaleString()} cache-c:${Rt.cacheC.toLocaleString()}`,children:[m.jsx("span",{className:"count",children:Ft(Rt.sum)}),m.jsx("span",{className:"lbl",children:"tokens"})]}),Ls.length>0&&m.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
|
|
62
62
|
${Ls.map(B=>` ${B.server}: ${B.count} call${B.count===1?"":"s"}`).join(`
|
|
63
63
|
`)}`,children:[Ls.slice(0,6).map(B=>m.jsx("span",{className:"mcp-dot",style:{"--mcp-hue":B.hue}},B.server)),Ls.length>6&&m.jsxs("span",{className:"mcp-more",children:["+",Ls.length-6]}),m.jsx("span",{className:"lbl",children:"mcp"})]}),Rt.cost.total>0&&(()=>{let B=0,V=0;for(const xe of n.current.agents.values()){if(xe.state!=="active")continue;const Ne=fn(xe.usage,xe.model);B+=Ne.total,V=Math.max(V,((xe.endedAt??ut)-xe.startedAt)/1e3)}const ae=V>0?gu(B,V):null,de=`input ${Fe(Rt.cost.input)} + output ${Fe(Rt.cost.output)} + cache r ${Fe(Rt.cost.cacheRead)} + cache w ${Fe(Rt.cost.cacheWrite)}${ae?`
|
|
64
64
|
active burn: ${ae}`:""}`;return m.jsxs("span",{className:"stat",title:de,children:[m.jsx("span",{className:"count",children:Fe(Rt.cost.total)}),m.jsxs("span",{className:"lbl",children:["cost",ae?` · ${ae}`:""]})]})})()]}),cr.length>0&&m.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>Rr(cr[0].id),title:`Blocked waiting for you — click to go to the one that has been stuck longest:
|
package/dist/web/index.html
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
document.documentElement.setAttribute("data-theme", stored === "light" ? "light" : "dark");
|
|
41
41
|
})();
|
|
42
42
|
</script>
|
|
43
|
-
<script type="module" crossorigin src="/assets/index-
|
|
43
|
+
<script type="module" crossorigin src="/assets/index-vlMkMZZ-.js"></script>
|
|
44
44
|
<link rel="stylesheet" crossorigin href="/assets/index-DhGa0tR_.css">
|
|
45
45
|
</head>
|
|
46
46
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-dag",
|
|
3
|
-
"version": "1.33.
|
|
3
|
+
"version": "1.33.143",
|
|
4
4
|
"description": "Live deck of Claude Code and Codex agents — watch parallel subagents fork, call tools, and return on one calm canvas. Also available as npx ccdeck and npx agent-dag.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|