agent-dag 1.35.32 → 1.35.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web/assets/{index-Ca-CsYuj.js → index-DBgvBZ_v.js} +2 -2
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/src/server/claude-dir.mjs +8 -1
- package/src/server/codex-auth.mjs +14 -1
- package/src/server/cswap-admin.mjs +13 -1
- package/src/server/cswap-auto.mjs +19 -1
- package/src/server/cswap-install.mjs +25 -2
- package/src/server/installer.mjs +7 -1
- package/src/server/npx.mjs +6 -1
- package/src/server/self-update.mjs +9 -2
- package/src/server/term.mjs +42 -8
|
@@ -60,7 +60,7 @@ Codex writes no approval request to its rollout files, which are the only thing
|
|
|
60
60
|
no published rate in this build — the tokens are counted, the dollars are not`;const i=d=>d.toLocaleString(),o=d=>`$${d}/MTok`,l=dn(e,n),u=EC(e,r),c=u.tokens1h>0?[`cache w5m${i(u.tokens5m).padStart(14)} × ${o(r.cacheWrite).padEnd(11)} = ${qe(u.usd5m)}`,`cache w1h${i(u.tokens1h).padStart(14)} × ${o(r.cacheWrite1h??r.cacheWrite).padEnd(11)} = ${qe(u.usd1h)}`]:[`cache w ${i(u.tokens5m).padStart(14)} × ${o(r.cacheWrite).padEnd(11)} = ${qe(u.usd5m)}`],h=NC(e,n),p=h===e.inputTokens?"input":"uncached";return[`model: ${n}`,`${p.padEnd(9)}${i(h).padStart(14)} × ${o(r.input).padEnd(11)} = ${qe(l.input)}`,`output ${i(e.outputTokens).padStart(14)} × ${o(r.output).padEnd(11)} = ${qe(l.output)}`,`cache r ${i(e.cacheReadTokens).padStart(14)} × ${o(r.cacheRead).padEnd(11)} = ${qe(l.cacheRead)}`,...c,"─────────────────────────────────────────",`total = ${qe(l.total)}`].join(`
|
|
61
61
|
`)}function uL({data:e,selected:n}){var h;const r=e.now??Date.now(),i=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",n?"selected":""].filter(Boolean).join(" "),o=e.tools.filter(p=>!p.endedAt).length,l=ry(e.sessionId),u=((h=e.context)==null?void 0:h.currentContextTokens)??0,c=e.kind==="root"&&u>0;return g.jsxs("div",{className:i,style:{"--session-hue":l},children:[g.jsx("span",{className:"accent-stripe"}),g.jsx(po,{type:"target",position:Ae.Left,style:{background:"transparent",border:"none"}}),g.jsxs("div",{className:"head",children:[g.jsxs("div",{className:"title",children:[g.jsx(cL,{state:e.state}),g.jsx("span",{className:"label",title:e.cwd,children:e.label}),e.synthetic&&g.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"})]}),g.jsxs("div",{className:"head-right",children:[c&&e.onOpenContext&&g.jsx(lL,{currentContextTokens:u,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)}),g.jsx("div",{className:"time",title:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:Nu(e.startedAt,e.endedAt,r)})]})]}),g.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&g.jsxs("span",{className:"spawn-badge",title:`${e.childCount} subagents spawned`,children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model?g.jsx("span",{className:"model-chip",title:e.model,children:Rs(e.model)}):e.provider==="codex"?g.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),e.waiting&&g.jsx(fL,{waiting:e.waiting,now:r}),(()=>{const p=HP(e);return p?g.jsxs("div",{className:"approval-blind-row",title:p.detail,children:[g.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),g.jsx("span",{className:"approval-blind-said",children:p.label})]}):null})(),e.tools.length>0&&g.jsx(hL,{tools:e.tools,now:r}),g.jsxs("div",{className:"meta",children:[g.jsxs("span",{children:[g.jsx("b",{children:e.toolCount})," tools"]}),o>0&&g.jsxs("span",{className:"inflight-meta",children:[g.jsx("b",{children:o})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&g.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:[g.jsx("b",{children:Nt(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&(()=>{if(!mo(e.model))return e.usage.inputTokens+e.usage.outputTokens<=0?null:g.jsx("span",{className:"cost-unpriced",title:Yx(e.usage,e.model),children:hu});const d=dn(e.usage,e.model);if(d.total<=0)return null;const m=Math.max(0,((e.endedAt??r)-e.startedAt)/1e3),y=e.state==="active"?Eu(d.total,m):null,w=Yx(e.usage,e.model)+(y?`
|
|
62
62
|
burn: ${y}`:"");return g.jsxs("span",{className:"cost-meta",title:w,children:[g.jsx("b",{children:qe(d.total)}),y&&g.jsx("span",{className:"cost-rate",children:y})]})})()]}),g.jsx(po,{type:"source",position:Ae.Right,style:{background:"transparent",border:"none"}})]})}function iy(e){return e==="active"?"live":e==="done"?"done":"err"}function cL({state:e}){return g.jsx("span",{className:`state-pill state-${e}`,children:iy(e)})}function $u(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function dL(e){return e.kind==="permission"?$u(e):"Your turn"}function fL({waiting:e,now:n}){const r=e.kind==="permission",i=$u(e);return g.jsxs("div",{className:r?"waiting-row permission":"waiting-row idle",title:`${i}
|
|
63
|
-
Blocked for ${Nu(e.since,void 0,n)} — the answer goes in the terminal, not here.`,children:[r?g.jsx("span",{className:"ap-pulse","aria-hidden":!0}):g.jsx("span",{className:"waiting-dot","aria-hidden":!0}),g.jsx("span",{className:"waiting-said",children:dL(e)}),g.jsx("b",{children:Nu(e.since,void 0,n)})]})}function hL({tools:e,now:n}){const l=new Array(24).fill(0);let u=0;for(const y of e){const w=n-y.startedAt;if(w<0||w>=6e4)continue;const E=23-Math.floor(w/2500);E>=0&&E<24&&(l[E]+=1,u+=1)}const c=Math.max(1,...l),h=132,p=14,d=h/24,m=c/(2500/1e3);return g.jsxs("div",{className:"tool-spark-row",title:`${u} tool calls in last 60s · peak ${m.toFixed(1)}/s`,children:[g.jsx("svg",{className:"tool-spark",width:h,height:p,viewBox:`0 0 ${h} ${p}`,"aria-hidden":!0,children:l.map((y,w)=>{const E=y===0?1.5:Math.max(1.5,y/c*p),_=w===23&&y>0,S=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return g.jsx("rect",{x:w*d+.4,y:p-E,width:Math.max(.5,d-1),height:E,rx:.8,className:S},w)})}),g.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function Kx(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function pL({tool:e,onClose:n}){const r=yo(n),i=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return g.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:g.jsxs("div",{ref:r,className:"modal",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[g.jsxs("header",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:`status-dot ${i}`,"aria-hidden":!0}),g.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),g.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",children:TC(e,"in-flight…")}),g.jsx("button",{className:"btn icon-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),g.jsxs("section",{className:"modal-body",children:[e.trimmed&&g.jsx("div",{className:"modal-section",children:g.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),g.jsxs("div",{className:"modal-section",children:[g.jsx("h4",{children:"Input"}),g.jsx("pre",{children:Kx(e.input??e.inputPreview)})]}),g.jsxs("div",{className:"modal-section",children:[g.jsxs("h4",{children:["Response ",i==="err"&&g.jsx("span",{className:"err-tag",children:"error"})]}),g.jsx("pre",{children:e.endedAt==null?"(waiting…)":Kx(e.response??e.errorPreview)})]})]})]})})}const nu=18,Xx=26,mL=12;function gL(e){return vL(e.nodeInternals.values())}function vL(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,h=u+o.width,p=c+o.height,d=n.get(l.sessionId);d?(d.minX=Math.min(d.minX,u),d.minY=Math.min(d.minY,c),d.maxX=Math.max(d.maxX,h),d.maxY=Math.max(d.maxY,p),l.kind==="root"&&(d.label=Qx(l)??d.label)):n.set(l.sessionId,{minX:u,minY:c,maxX:h,maxY:p,label:Qx(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} · ${yL(o)}`:l.label;i.push({sessionId:o,label:c,x:l.minX-nu,y:l.minY-nu-Xx,w:l.maxX-l.minX+nu*2,h:l.maxY-l.minY+nu*2+Xx})}return i}function yL(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function Qx(e){if(e.kind==="root")return e.label}function wL(){const{x:e,y:n,zoom:r}=pC(),i=Aa(),o=Ke(gL,xL);if(o.length<=1)return null;const l=c=>{try{const h=i.getNodes().filter(p=>{const d=p.data;return(d==null?void 0:d.sessionId)===c});if(h.length===0)return;i.fitView({padding:.3,duration:500,nodes:h})}catch{}},u={transform:`translate(${e}px, ${n}px) scale(${r})`};return g.jsx("div",{className:"session-clusters",style:u,children:o.map(c=>{const h=ry(c.sessionId),p={position:"absolute",left:c.x,top:c.y,width:c.w,height:c.h,"--session-hue":h},d={position:"absolute",left:c.x+16,top:c.y-mL,transform:`scale(${Math.min(1,r)/(r||1)})`,transformOrigin:"left top","--session-hue":h};return g.jsxs(ue.Fragment,{children:[g.jsx("div",{className:"cluster-card",style:p,"aria-hidden":!0}),g.jsx("button",{type:"button",className:"cluster-label",style:d,title:`Fit view to ${c.label} · drag the wrapper to move the whole session`,onClick:()=>l(c.sessionId),children:c.label})]},c.sessionId)})})}function xL(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 _L({data:e}){return g.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const Ma={exec:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},shell:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},exec_command:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},shell_command:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},write_stdin:{category:"shell",emoji:"💻",label:"stdin",shell:!0},wait:{category:"shell",emoji:"⏳",label:"wait",shell:!0},apply_patch:{category:"file",emoji:"🩹",label:"Edit"},update_plan:{category:"task",emoji:"📋",label:"Plan"},run:{category:"web",emoji:"🌐",label:"Web"}},bL=Object.fromEntries(Object.entries(Ma).map(([e,n])=>[e,n.category])),SL=Object.fromEntries(Object.entries(Ma).map(([e,n])=>[e,n.emoji])),kL=Object.fromEntries(Object.entries(Ma).map(([e,n])=>[e,n.label])),EL=new Set(Object.keys(Ma)),NL=new Set(Object.entries(Ma).filter(([,e])=>e.shell).map(([e])=>e)),CL={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",WebFetch:"web",WebSearch:"web",Task:"agent",Agent:"agent",TodoWrite:"task",TaskCreate:"task",TaskUpdate:"task",TaskList:"task",TaskGet:"task",TaskOutput:"task",TaskStop:"task",EnterPlanMode:"plan",ExitPlanMode:"plan",AskUserQuestion:"plan",Skill:"plan",Workflow:"plan"
|
|
63
|
+
Blocked for ${Nu(e.since,void 0,n)} — the answer goes in the terminal, not here.`,children:[r?g.jsx("span",{className:"ap-pulse","aria-hidden":!0}):g.jsx("span",{className:"waiting-dot","aria-hidden":!0}),g.jsx("span",{className:"waiting-said",children:dL(e)}),g.jsx("b",{children:Nu(e.since,void 0,n)})]})}function hL({tools:e,now:n}){const l=new Array(24).fill(0);let u=0;for(const y of e){const w=n-y.startedAt;if(w<0||w>=6e4)continue;const E=23-Math.floor(w/2500);E>=0&&E<24&&(l[E]+=1,u+=1)}const c=Math.max(1,...l),h=132,p=14,d=h/24,m=c/(2500/1e3);return g.jsxs("div",{className:"tool-spark-row",title:`${u} tool calls in last 60s · peak ${m.toFixed(1)}/s`,children:[g.jsx("svg",{className:"tool-spark",width:h,height:p,viewBox:`0 0 ${h} ${p}`,"aria-hidden":!0,children:l.map((y,w)=>{const E=y===0?1.5:Math.max(1.5,y/c*p),_=w===23&&y>0,S=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return g.jsx("rect",{x:w*d+.4,y:p-E,width:Math.max(.5,d-1),height:E,rx:.8,className:S},w)})}),g.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function Kx(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function pL({tool:e,onClose:n}){const r=yo(n),i=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return g.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:g.jsxs("div",{ref:r,className:"modal",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[g.jsxs("header",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:`status-dot ${i}`,"aria-hidden":!0}),g.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),g.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",children:TC(e,"in-flight…")}),g.jsx("button",{className:"btn icon-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),g.jsxs("section",{className:"modal-body",children:[e.trimmed&&g.jsx("div",{className:"modal-section",children:g.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),g.jsxs("div",{className:"modal-section",children:[g.jsx("h4",{children:"Input"}),g.jsx("pre",{children:Kx(e.input??e.inputPreview)})]}),g.jsxs("div",{className:"modal-section",children:[g.jsxs("h4",{children:["Response ",i==="err"&&g.jsx("span",{className:"err-tag",children:"error"})]}),g.jsx("pre",{children:e.endedAt==null?"(waiting…)":Kx(e.response??e.errorPreview)})]})]})]})})}const nu=18,Xx=26,mL=12;function gL(e){return vL(e.nodeInternals.values())}function vL(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,h=u+o.width,p=c+o.height,d=n.get(l.sessionId);d?(d.minX=Math.min(d.minX,u),d.minY=Math.min(d.minY,c),d.maxX=Math.max(d.maxX,h),d.maxY=Math.max(d.maxY,p),l.kind==="root"&&(d.label=Qx(l)??d.label)):n.set(l.sessionId,{minX:u,minY:c,maxX:h,maxY:p,label:Qx(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} · ${yL(o)}`:l.label;i.push({sessionId:o,label:c,x:l.minX-nu,y:l.minY-nu-Xx,w:l.maxX-l.minX+nu*2,h:l.maxY-l.minY+nu*2+Xx})}return i}function yL(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function Qx(e){if(e.kind==="root")return e.label}function wL(){const{x:e,y:n,zoom:r}=pC(),i=Aa(),o=Ke(gL,xL);if(o.length<=1)return null;const l=c=>{try{const h=i.getNodes().filter(p=>{const d=p.data;return(d==null?void 0:d.sessionId)===c});if(h.length===0)return;i.fitView({padding:.3,duration:500,nodes:h})}catch{}},u={transform:`translate(${e}px, ${n}px) scale(${r})`};return g.jsx("div",{className:"session-clusters",style:u,children:o.map(c=>{const h=ry(c.sessionId),p={position:"absolute",left:c.x,top:c.y,width:c.w,height:c.h,"--session-hue":h},d={position:"absolute",left:c.x+16,top:c.y-mL,transform:`scale(${Math.min(1,r)/(r||1)})`,transformOrigin:"left top","--session-hue":h};return g.jsxs(ue.Fragment,{children:[g.jsx("div",{className:"cluster-card",style:p,"aria-hidden":!0}),g.jsx("button",{type:"button",className:"cluster-label",style:d,title:`Fit view to ${c.label} · drag the wrapper to move the whole session`,onClick:()=>l(c.sessionId),children:c.label})]},c.sessionId)})})}function xL(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 _L({data:e}){return g.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const Ma={exec:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},shell:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},exec_command:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},shell_command:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},write_stdin:{category:"shell",emoji:"💻",label:"stdin",shell:!0},wait:{category:"shell",emoji:"⏳",label:"wait",shell:!0},apply_patch:{category:"file",emoji:"🩹",label:"Edit"},update_plan:{category:"task",emoji:"📋",label:"Plan"},run:{category:"web",emoji:"🌐",label:"Web"}},bL=Object.fromEntries(Object.entries(Ma).map(([e,n])=>[e,n.category])),SL=Object.fromEntries(Object.entries(Ma).map(([e,n])=>[e,n.emoji])),kL=Object.fromEntries(Object.entries(Ma).map(([e,n])=>[e,n.label])),EL=new Set(Object.keys(Ma)),NL=new Set(Object.entries(Ma).filter(([,e])=>e.shell).map(([e])=>e)),CL={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",WebFetch:"web",WebSearch:"web",Task:"agent",Agent:"agent",TodoWrite:"task",TaskCreate:"task",TaskUpdate:"task",TaskList:"task",TaskGet:"task",TaskOutput:"task",TaskStop:"task",EnterPlanMode:"plan",ExitPlanMode:"plan",AskUserQuestion:"plan",Skill:"plan",Workflow:"plan",...bL};function IC(e){return e.startsWith("mcp__")?"mcp":CL[e]??"other"}const TL=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,jL=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function RL(e){if(typeof e!="string"||!e)return null;const n=TL.exec(e);if(n){const i=AL(n[2]);if(i.trim())return i}const r=jL.exec(e);return r?r[1]:null}function AL(e){return e.replace(/\\(["'`\\nrt])/g,(n,r)=>r==="n"?`
|
|
64
64
|
`:r==="r"?"\r":r==="t"?" ":r)}const MC=600,IL=4,ML=36,Av=16,OL=60,PL=6,Zx=220,Jx=96,LL=28,$L={Read:"📖",Write:"💾",Edit:"✏️",MultiEdit:"🔧",Glob:"🗺️",Grep:"🔎",Bash:"⚡",PowerShell:"💻",LS:"📂",Task:"🤖",Agent:"🤖",TodoWrite:"📋",TaskCreate:"📋",TaskUpdate:"📝",TaskList:"🗂️",TaskGet:"🗂️",TaskOutput:"📤",TaskStop:"🛑",WebFetch:"🌐",WebSearch:"🔭",ToolSearch:"🧰",NotebookEdit:"📓",EnterPlanMode:"🧭",ExitPlanMode:"🏁",AskUserQuestion:"❓",ScheduleWakeup:"⏰",CronCreate:"⏰",CronList:"📅",CronDelete:"🗑️",Skill:"🎯",Workflow:"🎬",Monitor:"📡",PushNotification:"🔔",RemoteTrigger:"📡",...SL};function e_(e){return e.startsWith("mcp__")?"🔌":$L[e]??"✨"}const qL={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 DL(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const n=e;if(typeof n.script=="string"){const r=RL(n.script);if(r)return r}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 FL=new Set(["Bash","PowerShell",...NL]),zL=EL;function BL(e,n){return zL.has(e)||e.startsWith("mcp__")?Math.max(Jx,34+n.length*7.5):Jx}function UL(e,n){if(!FL.has(e))return null;const r=DL(n);if(!r)return null;const i=OC(r);return i?{emoji:qL[i]??"⚙️",label:i,category:"shell",detail:r}:null}const HL=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),t_={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:"🗄️"},n_={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 WL(e){const r=e.replace(/\\/g,"/").replace(/\/+$/,""),i=r.lastIndexOf("/");return i>=0?r.slice(i+1):r}function VL(e){const n=e.toLowerCase();if(n_[n])return n_[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(t_[i])return t_[i]}return"📄"}function GL(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 YL(e,n){if(!HL.has(e))return null;const r=GL(e,n);if(!r)return null;const i=WL(r);return i?{emoji:e==="LS"?"📂":VL(i),label:i,category:"file",detail:r}:null}const PC={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 KL(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 XL(e,n){const r=LC(e);if(!r)return null;const{server:i,method:o}=r;if(!o)return null;const l=PC[i.toLowerCase()];return{emoji:(l==null?void 0:l.emoji)??"🔌",label:o,category:"mcp",detail:l?`${l.name} · ${o}`:`${i} · ${o}`}}function QL(e,n){return UL(e,n)??YL(e,n)??XL(e)}const ZL=kL;function JL(e){const n=LC(e);if(n){const i=PC[n.server.toLowerCase()];return i?{emoji:i.emoji,label:i.name}:{emoji:"🔌",label:n.server,hue:KL(n.server)}}const r=ZL[e];return r?{emoji:e_(e),label:r}:{emoji:e_(e),label:e}}function e3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function t3(e,n,r){if(r==null)return 1;const i=n-r;return i<0?1:Math.max(0,1-i/MC)}function n3(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 r3(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>MC)continue;const h=i.get(c.id)??r.get(c.id);if(!h)continue;const p=n3(c.tools,IL);if(p.length===0)continue;const d=c.exitAt??null,m=o.get(c.id),y=Math.max((m==null?void 0:m.width)??Zx,Zx),w=(m==null?void 0:m.height)??130,E=h.x,_=h.y,b=E+y,S=_+w/2;p.forEach((k,N)=>{const T=N*ML,A=E+y+OL,M=_+PL+T,O=t3(k,l,d),P=k.inputPreview??"",D=e3(k),L=O<.999,U=JL(k.name);u.push({id:`${c.id}::${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:U.label,emoji:U.emoji,status:D,category:IC(k.name),mcpHue:U.hue,inputPreview:P,fade:O,fading:L,worldX:A,worldY:M,anchorX:b,anchorY:S,spawnDx:b-A,spawnDy:S-(M+Av)});const V=QL(k.name,k.input);if(V){const z=BL(k.name,U.label),C=A+z+LL,F=M,$=A+z,re=M+Av;u.push({id:`sub:${c.id}::${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:V.label,emoji:V.emoji,isSub:!0,status:D,category:V.category,inputPreview:V.detail??P,fade:O,fading:L,worldX:C,worldY:F,anchorX:$,anchorY:re,spawnDx:$-C,spawnDy:0})}})}return u}function s3({agents:e,visibleAgentIds:n,positions:r,pinned:i,measured:o,dimUnmatched:l,spotlight:u,hiddenCategories:c,now:h,onOpenTool:p}){const d=r3(e,n,r,i,o,h),m=c&&c.size>0?d.filter(y=>!c.has(y.category)):d;return g.jsx(i3,{bursts:m,dimUnmatched:l,spotlight:u,onOpenTool:p})}function i3({bursts:e,dimUnmatched:n,spotlight:r,onOpenTool:i}){const{x:o,y:l,zoom:u}=pC();return g.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[g.jsx("svg",{className:"tool-bursts-svg",children:e.map(c=>{const h=c.anchorX*u+o,p=c.anchorY*u+l,d=(c.worldX+6)*u+o,m=(c.worldY+Av)*u+l,y=h+(d-h)*.55,w=n!=null&&!n.has(c.agentId),E=r!=null&&!r.has(c.agentId),_=c.fade*(w||E?.14:1);return g.jsx("path",{d:`M ${h} ${p} Q ${y} ${p}, ${d} ${m}`,className:`tool-conn status-${c.status}${c.fading?" fading":""}`,opacity:_},`l:${c.id}`)})}),e.map(c=>{const h=c.worldX*u+o,p=c.worldY*u+l,d={left:`${h}px`,top:`${p}px`,transform:`scale(${u})`,transformOrigin:"left top","--spawn-dx":`${c.spawnDx}px`,"--spawn-dy":`${c.spawnDy}px`},m=c.isSub?`${c.toolName} · ${c.name}`:c.toolName,y=c.inputPreview?`${m} · ${c.inputPreview}`:m,w=i!=null,E=c.mcpHue!=null?{"--mcp-hue":c.mcpHue}:{},_=n!=null&&!n.has(c.agentId),b=r!=null&&!r.has(c.agentId),S=_||b?" dim":"";return g.jsx("div",{className:"tool-burst-wrap",style:d,children:g.jsxs("div",{className:`tool-burst cat-${c.category}${c.mcpHue!=null?" mcp-hue":""} status-${c.status}${c.fading?" fading":""}${w?" clickable":""}${c.isSub?" sub":""}${S}`,style:E,title:y,onClick:w?()=>i(c.toolId):void 0,children:[g.jsx("span",{className:"tb-emoji",children:c.emoji}),g.jsx("span",{className:"tb-name",children:c.name}),c.status==="inflight"&&g.jsx("span",{className:"tb-spin"}),c.status==="done"&&g.jsx("span",{className:"tb-mark done",children:"✓"}),c.status==="err"&&g.jsx("span",{className:"tb-mark err",children:"×"})]})},c.id)})]})}function oy({cost:e,size:n="md"}){const r=e.total;if(r<=0)return null;const i=(l,u,c)=>{if(l<=0)return null;const h=l/r*100;return g.jsx("span",{className:`cb-seg ${u}`,style:{width:`${h}%`},title:`${c}: ${qe(l)} (${h.toFixed(0)}%)`},u)},o=n==="lg";return g.jsxs("div",{className:o?"cost-bar cost-bar-lg":"cost-bar",role:"img","aria-label":"Cost breakdown",children:[i(e.input,"cb-input","input"),i(e.output,"cb-output","output"),i(e.cacheRead,"cb-cache-r","cache read"),i(e.cacheWrite,"cb-cache-w","cache write")]})}function o3({state:e,sessionId:n,onClose:r}){const i=R.useMemo(()=>a3(e,n),[e,n]),o=R.useRef(null),l=yo(r,{focusRef:o});return i?g.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:g.jsxs("div",{ref:l,className:"modal session-summary",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[g.jsxs("div",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),g.jsx("span",{id:"ss-title",className:"modal-tool-name",title:i.cwd??i.sessionId,children:i.label}),g.jsxs("span",{className:"modal-tool-id",children:["· ",i.sessionId.slice(0,8)]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",title:"Total wall time",children:i.durationLabel}),g.jsx("button",{type:"button",ref:o,className:"btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),g.jsxs("div",{className:"modal-body",children:[g.jsxs("section",{className:"ss-hero",children:[g.jsxs("div",{className:"ss-hero-left",children:[g.jsx("div",{className:"ss-cost-label",children:"total spend"}),g.jsx("div",{className:"ss-cost",children:qe(i.cost.total)}),i.modelChips.length>0&&g.jsx("div",{className:"ss-models",children:i.modelChips.map(u=>g.jsx("span",{className:"model-chip",title:u,children:Rs(u)},u))})]}),g.jsx("div",{className:"ss-hero-right",children:i.cost.total>0&&g.jsxs(g.Fragment,{children:[g.jsx(oy,{cost:i.cost,size:"lg"}),g.jsxs("div",{className:"ss-cost-legend",children:[g.jsxs("span",{className:"ssl ssl-in",children:["input ",g.jsx("b",{children:qe(i.cost.input)})]}),g.jsxs("span",{className:"ssl ssl-out",children:["output ",g.jsx("b",{children:qe(i.cost.output)})]}),g.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",g.jsx("b",{children:qe(i.cost.cacheRead)})]}),g.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",g.jsx("b",{children:qe(i.cost.cacheWrite)})]})]})]})})]}),g.jsxs("section",{className:"ss-stats",children:[g.jsx(to,{label:"agents",value:i.agentCount}),g.jsx(to,{label:"subagents",value:i.subagentCount}),g.jsx(to,{label:"tool calls",value:i.toolCount}),g.jsx(to,{label:"prompts",value:i.promptCount}),g.jsx(to,{label:"tokens",value:i.tokensSum.toLocaleString()}),i.errCount>0&&g.jsx(to,{label:"errors",value:i.errCount,tone:"err"})]}),i.topTools.length>0&&g.jsxs("section",{className:"modal-section",children:[g.jsx("h4",{children:"Most-used tools"}),g.jsx("div",{className:"ss-top-tools",children:i.topTools.map(([u,c])=>g.jsxs("div",{className:"ss-tt",children:[g.jsx("span",{className:"ss-tt-name",children:u}),g.jsx("span",{className:"ss-tt-bar",children:g.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${c/i.topTools[0][1]*100}%`}})}),g.jsx("span",{className:"ss-tt-count",children:c})]},u))})]}),i.firstPrompt&&g.jsxs("section",{className:"modal-section",children:[g.jsx("h4",{children:"Opening prompt"}),g.jsx("div",{className:"ss-prompt",children:i.firstPrompt})]})]})]})}):null}function to({label:e,value:n,tone:r}){return g.jsxs("div",{className:`ss-stat${r?` tone-${r}`:""}`,children:[g.jsx("div",{className:"ss-stat-value",children:n}),g.jsx("div",{className:"ss-stat-label",children:e})]})}function a3(e,n){const r=e.agents.get(n);if(!r)return null;const i=[];for(const N of e.agents.values())N.sessionId===n&&i.push(N);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,h=0,p=0,d=0,m=0,y,w=1/0,E=0;for(const N of i){const T=dn(N.usage,N.model);o.input+=T.input,o.output+=T.output,o.cacheRead+=T.cacheRead,o.cacheWrite+=T.cacheWrite,o.total+=T.total,N.model&&l.add(N.model),N.kind==="subagent"&&m++,h+=N.prompts.length,!y&&N.prompts.length>0&&(y=N.prompts[0].text),p+=N.usage.inputTokens+N.usage.outputTokens,c+=N.toolCount,w=Math.min(w,N.startedAt),E=Math.max(E,N.endedAt??Date.now());for(const A of N.tools)u.set(A.name,(u.get(A.name)??0)+1),A.ok===!1&&d++}const _=Math.max(0,E-w),b=Math.floor(_/1e3),S=b<60?`${b}s`:b<3600?`${Math.floor(b/60)}m ${String(b%60).padStart(2,"0")}s`:`${Math.floor(b/3600)}h ${Math.floor(b%3600/60)}m`,k=Array.from(u.entries()).sort((N,T)=>T[1]-N[1]).slice(0,5);return{sessionId:n,label:r.label||r.cwdBasename||"session",cwd:r.cwd,durationLabel:S,cost:o,modelChips:Array.from(l),agentCount:i.length,subagentCount:m,toolCount:c,promptCount:h,tokensSum:p,errCount:d,topTools:k,firstPrompt:y}}function ay(e){return(e==null?void 0:e.kind)==="permission"}function l3(e){const n=[];for(const r of e)r.kind==="root"&&ay(r.waiting)&&n.push({id:r.id,label:r.label,waiting:r.waiting});return n.sort((r,i)=>r.waiting.since-i.waiting.since)}function u3(e){const n=new Set;for(const r of e)r.state==="active"&&n.add(r.sessionId);return n.size}function r_(e){return e.waiting?ay(e.waiting)?0:1:e.state==="active"?2:3}function c3(e,n){const r=[];for(const i of e.agents.values()){if(i.kind!=="root")continue;let o=i.toolCount,l=dn(i.usage,i.model).total,u=i.endedAt??i.startedAt;for(const c of e.agents.values()){if(c.sessionId!==i.sessionId||c.kind==="root")continue;o+=c.toolCount,l+=dn(c.usage,c.model).total;const h=c.endedAt??c.startedAt;h>u&&(u=h)}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=r_(i),u=r_(o);return l!==u?l-u:i.waiting&&o.waiting?i.waiting.since-o.waiting.since:o.lastActivity-i.lastActivity}),r}function s_(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 d3({state:e,now:n,selectedIds:r,onSelect:i,onClose:o}){const l=R.useMemo(()=>c3(e),[e,e.lastSeq,n]),u=l.filter(h=>h.state==="active").length,c=l.filter(h=>ay(h.waiting)).length;return g.jsxs("aside",{className:"session-list",id:"session-list","aria-label":"Sessions",children:[g.jsxs("div",{className:"sl-header",children:[g.jsxs("h2",{children:["Sessions ",g.jsx("span",{className:"sl-count",children:l.length})]}),c>0&&g.jsxs("span",{className:"sl-waiting-count",children:[c," waiting"]}),u>0&&g.jsxs("span",{className:"sl-live-count",children:[u," live"]}),g.jsx("button",{className:"btn icon-btn sl-close",onClick:o,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),g.jsxs("div",{className:"sl-rows",children:[l.length===0&&g.jsx("div",{className:"sl-empty",children:"No sessions yet."}),l.map(h=>{const p=r.has(h.sessionId);return g.jsxs("button",{type:"button",className:`sl-row state-${h.state}${p?" selected":""}`,onClick:()=>i(h.sessionId),title:`Focus ${h.label}`,children:[g.jsx("span",{className:`sl-dot state-${h.state}`,"aria-hidden":!0}),g.jsx("span",{className:"vis-hidden",children:iy(h.state)}),g.jsxs("div",{className:"sl-row-body",children:[g.jsxs("div",{className:"sl-row-head",children:[g.jsx("span",{className:"sl-label",children:h.label}),h.modelId&&g.jsx("span",{className:"model-chip",title:h.modelId,children:Rs(h.modelId)})]}),g.jsxs("div",{className:"sl-row-meta",children:[g.jsxs("span",{title:"tool calls",children:[g.jsx("b",{children:h.toolCount})," tools"]}),h.cost>0&&g.jsx("span",{className:"sl-cost",title:"total spend",children:g.jsx("b",{children:qe(h.cost)})}),h.waiting?g.jsxs("span",{className:"sl-waiting",title:`${$u(h.waiting)}
|
|
65
65
|
Blocked since ${new Date(h.waiting.since).toLocaleTimeString()} · started ${new Date(h.startedAt).toLocaleString()}`,children:["waiting ",s_(h.waiting.since,void 0,n)]}):g.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(h.startedAt).toLocaleString()}`,children:s_(h.startedAt,h.state==="active"?void 0:h.lastActivity,n)})]})]})]},h.sessionId)})]})]})}const Gt="ccdeck";function $C(e){const n=Math.max(0,e);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 Iv(e){return $C(Math.floor(e/1e3))}function qC(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 f3(e,n){return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function h3(e,n,r){const i=new Date(e),o=Iv(n-e);return{label:f3(i,new Date(n))?o:`${o} · ${i.toLocaleDateString(r,{month:"short",day:"numeric"})}`,title:i.toLocaleString(r,{dateStyle:"medium",timeStyle:"medium"})}}function i_(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 p3(e){return e==="claude-swap"?"Read from claude-swap's last collection — costs no request against your usage-endpoint budget":e==="api"?"Fetched from Anthropic's usage endpoint, at most once every 5 minutes":e==="cli"?"Parsed from `claude /usage`, at most once every 5 minutes":"Last update"}const Vd="__unknown__";function m3(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 h=100-e,p=l>0?e/l:0,d=p>0?h/p:1/0,m={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(d<o&&d<86400){const y=Math.floor(d/3600),w=Math.floor(d%3600/60);m.runsOutIn=y>0?`${y}h ${w}m`:`${w}m`}return m}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function li({pct:e,label:n,reset:r,resetAt:i,windowSec:o,limitReached:l,nowSec:u}){const c=Math.min(100,Math.max(0,e)),p=l||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",d=c===0?"< 1%":`${c}%`,m=c===0?2:c,y=i?qC(i,u):null,w=i&&o?m3(c,i,o,u):null;return g.jsxs("div",{className:"qb-row",children:[g.jsxs("div",{className:"qb-meta",children:[g.jsxs("span",{className:"qb-label",children:[n,l&&g.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),g.jsx("span",{className:"qb-pct",style:{color:p},children:d})]}),g.jsxs("div",{className:"qb-track",children:[g.jsx("div",{className:"qb-fill",style:{width:`${m}%`,background:p,opacity:c===0?.4:1}}),w&&g.jsx("div",{className:"qb-pace-marker",style:{left:`${w.expectedPct}%`,background:w.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(w.expectedPct)}% by now`})]}),g.jsxs("div",{className:"qb-reset-row",children:[y?g.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):r?g.jsxs("span",{className:"qb-reset",children:["resets ",r]}):null,w&&g.jsx("span",{className:"qb-pace",style:{color:w.color},children:w.runsOutIn?`runs out in ${w.runsOutIn}`:w.label})]})]})}const g3=6e4;function v3(e){const[n,r]=R.useState(null),[i,o]=R.useState(!1),l=R.useRef(null),u=async(h=!1)=>{h&&o(!0);try{const d=await fetch(h?"/api/quota?refresh=1":"/api/quota");d.ok&&r(await d.json())}catch{}finally{h&&o(!1)}};return R.useEffect(()=>{if(e)return u(!0),l.current=window.setInterval(()=>u(!1),g3),()=>{l.current!=null&&window.clearInterval(l.current)}},[e]),{quota:n,loading:i,refresh:()=>{e&&u(!0)}}}function y3(e){switch(e){case"no_token":return"Run codex login to authenticate.";case"api_key_mode":return"API-key login — ChatGPT quota is only available for codex login.";case"refresh_rejected":return"Codex session expired — run codex login.";case"refresh_failed":return"Couldn't refresh the Codex token — click ↻ to retry.";case"untrusted_base_url":return"chatgpt_base_url in ~/.codex/config.toml is not an https OpenAI host, so the token was not sent.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const DC=6e4;function w3(e){const[n,r]=R.useState(null),[i,o]=R.useState(!1),l=R.useRef(null),u=async(h=!1)=>{h&&o(!0);try{const d=await fetch(h?"/api/codex-quota?refresh=1":"/api/codex-quota");d.ok&&r(await d.json())}catch{}finally{h&&o(!1)}};return R.useEffect(()=>{if(e)return u(!0),l.current=window.setInterval(()=>u(!1),DC),()=>{l.current!=null&&window.clearInterval(l.current)}},[e]),{data:n,loading:i,refresh:()=>{e&&u(!0)}}}function x3(e){const[n,r]=R.useState(null),i=R.useRef(null),o=async()=>{try{const l=await fetch("/api/codex-usage");l.ok&&r(await l.json())}catch{}};return R.useEffect(()=>{if(e)return o(),i.current=window.setInterval(o,DC),()=>{i.current!=null&&window.clearInterval(i.current)}},[e]),{data:n}}function _3({state:e,now:n,providers:r,onClose:i}){var V,z;const{quota:o,loading:l,refresh:u}=v3(r.claude),{data:c,loading:h,refresh:p}=w3(r.codex),{data:d}=x3(r.codex),[m,y]=R.useState(()=>Math.floor(Date.now()/1e3));R.useEffect(()=>{const C=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(C)},[]);const{byModel:w,totalCost:E,totalTokens:_,burnRate:b}=R.useMemo(()=>{const C=new Map,F={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let $=0,re=0,J=0,W=0;for(const q of e.agents.values()){const Q=q.model??Vd,ne=dn(q.usage,q.model),ae=C.get(Q);ae?(ae.inputTokens+=q.usage.inputTokens,ae.outputTokens+=q.usage.outputTokens,ae.cacheReadTokens+=q.usage.cacheReadTokens,ae.cacheCreateTokens+=q.usage.cacheCreateTokens,ae.cost.total+=ne.total,ae.cost.input+=ne.input,ae.cost.output+=ne.output,ae.cost.cacheRead+=ne.cacheRead,ae.cost.cacheWrite+=ne.cacheWrite,ae.agentCount++):C.set(Q,{model:Q,inputTokens:q.usage.inputTokens,outputTokens:q.usage.outputTokens,cacheReadTokens:q.usage.cacheReadTokens,cacheCreateTokens:q.usage.cacheCreateTokens,cost:{...ne},agentCount:1,priced:mo(q.model)!=null}),F.total+=ne.total,F.input+=ne.input,F.output+=ne.output,F.cacheRead+=ne.cacheRead,F.cacheWrite+=ne.cacheWrite,$+=q.usage.inputTokens,re+=q.usage.outputTokens,J+=q.usage.cacheReadTokens,W+=q.usage.cacheCreateTokens}const Z=Array.from(C.values()).sort((q,Q)=>Q.cost.total-q.cost.total||Q.inputTokens+Q.outputTokens-(q.inputTokens+q.outputTokens));let I=0,G=0;for(const q of e.agents.values()){if(q.state!=="active")continue;const Q=dn(q.usage,q.model);I+=Q.total,G=Math.max(G,((q.endedAt??n)-q.startedAt)/1e3)}const K=G>0?Eu(I,G):null;return{byModel:Z,totalCost:F,totalTokens:{in:$,out:re,cacheR:J,cacheC:W},burnRate:K}},[e,e.lastSeq,n]),S=R.useMemo(()=>{const C=[],F=$=>mo($.model)==null?$.usage.inputTokens+$.usage.outputTokens:0;for(const $ of e.agents.values()){if($.kind!=="root")continue;let re=dn($.usage,$.model).total,J=$.usage.inputTokens,W=$.usage.outputTokens,Z=F($);for(const I of e.agents.values())I.sessionId!==$.sessionId||I.kind==="root"||(re+=dn(I.usage,I.model).total,J+=I.usage.inputTokens,W+=I.usage.outputTokens,Z+=F(I));C.push({sessionId:$.sessionId,label:$.label||$.cwdBasename||"session",state:$.state,cost:re,inputTokens:J,outputTokens:W,unpricedTokens:Z})}return C.sort(($,re)=>re.cost-$.cost||re.inputTokens+re.outputTokens-($.inputTokens+$.outputTokens)).slice(0,12)},[e,e.lastSeq]),k=E.total>0,N=_.in+_.out,T=w.filter(C=>C.cost.total>0||C.inputTokens+C.outputTokens>0),A=S.filter(C=>C.cost>0||C.inputTokens+C.outputTokens>0),M=T.some(C=>!C.priced),O=l||h,P=i_(o==null?void 0:o.fetchedAt,m),D=i_(c==null?void 0:c.fetchedAt,m),L=()=>{u(),p()},U=r.claude&&r.codex?"Refresh Claude + Codex quota":r.codex?"Refresh Codex quota":"Refresh Claude quota";return g.jsxs("aside",{className:"usage-panel",id:"usage-panel","aria-label":"Usage",children:[g.jsxs("div",{className:"up-header",children:[g.jsx("h2",{children:"Usage"}),b&&g.jsx("span",{className:"up-rate",children:b}),g.jsxs("div",{className:"up-header-right",children:[(r.claude||r.codex)&&g.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:L,disabled:O,"aria-label":U,title:U,children:O?"…":"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:i,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),r.claude&&g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h3",{className:"up-section-title",children:["Claude quota",P&&!l&&g.jsx("span",{className:"up-section-age",title:p3(o==null?void 0:o.source),children:P})]}),o!=null&&o.ok?g.jsxs("div",{className:"up-quota-bars",children:[o.session5hPct!=null&&g.jsx(li,{label:"5-hour window",pct:o.session5hPct,reset:o.session5hReset,resetAt:o.session5hResetAt,windowSec:o.session5hWindowSec,nowSec:m}),o.week7dPct!=null&&g.jsx(li,{label:"7-day window",pct:o.week7dPct,reset:o.week7dReset,resetAt:o.week7dResetAt,windowSec:o.week7dWindowSec,nowSec:m}),o.weekSonnetPct!=null&&g.jsx(li,{label:"Sonnet (7d)",pct:o.weekSonnetPct,nowSec:m}),o.weekOpusPct!=null&&g.jsx(li,{label:"Opus (7d)",pct:o.weekOpusPct,nowSec:m})]}):(o==null?void 0:o.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsxs("span",{className:"up-quota-hint",children:["Run ",g.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),r.codex&&g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h3",{className:"up-section-title",children:["Codex quota",(c==null?void 0:c.ok)&&c.planLabel&&g.jsx("span",{className:"up-plan-badge",children:c.planLabel}),D&&!h&&g.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:D})]}),c!=null&&c.ok?g.jsxs("div",{className:"up-quota-bars",children:[(V=c.windows)==null?void 0:V.map(C=>g.jsx(li,{label:C.label,pct:C.pct,reset:C.reset??void 0,resetAt:C.resetAt??void 0,windowSec:C.windowSec??void 0,limitReached:c.limitReached&&C.pct>=100,nowSec:m},C.id)),(z=c.extraWindows)==null?void 0:z.map(C=>g.jsx(li,{label:C.label,pct:C.pct,reset:C.reset??void 0,resetAt:C.resetAt??void 0,windowSec:C.windowSec??void 0,nowSec:m},C.id)),c.creditLimit&&g.jsx(li,{label:`spend cap · $${Math.round(c.creditLimit.used)} of $${Math.round(c.creditLimit.limit)}`,pct:c.creditLimit.usedPct,reset:c.creditLimit.reset??void 0,resetAt:c.creditLimit.resetAt??void 0,limitReached:c.spendControlReached,nowSec:m}),c.creditsBalance&&!c.creditsUnlimited&&g.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",c.creditsBalance,c.overageReached&&" · overage limit reached"]}),c.creditsUnlimited&&g.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),c.resetCredits&&c.resetCredits.availableCount>0&&g.jsxs("div",{className:"up-quota-sub up-reset-credits",title:`Redeem in the Codex CLI or ChatGPT — ${Gt} only reports them`,children:[c.resetCredits.availableCount," rate-limit reset",c.resetCredits.availableCount!==1?"s":""," available",c.resetCredits.nextExpiryAt&&` · expires ${new Date(c.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),c.promo&&g.jsx("div",{className:"up-quota-sub",children:c.promo}),c.partial&&g.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(c==null?void 0:c.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsx("span",{className:"up-quota-hint",children:y3(c.reason)})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"}),(d==null?void 0:d.ok)&&d.window7d&&d.window7d.sessionCount>0&&g.jsxs("div",{className:"up-quota-sub",title:`Counted from the rollout files under CODEX_HOME — no network, no account${d.window5h?`
|
|
66
66
|
last 5h: ${Nt(d.window5h.totalTokens)} tokens · ${d.window5h.sessionCount} session${d.window5h.sessionCount!==1?"s":""}`:""}`,children:[Nt(d.window7d.totalTokens)," tokens · ",d.window7d.sessionCount," session",d.window7d.sessionCount!==1?"s":""," (7d)"]})]}),N>0?g.jsxs(g.Fragment,{children:[k&&g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-total",children:[g.jsx("span",{className:"up-total-value",children:qe(E.total)}),g.jsx("span",{className:"up-total-label",children:"total spend"})]}),g.jsx(oy,{cost:E})]}),g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),Nt(_.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),Nt(_.out)]}),_.cacheR>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache r"}),Nt(_.cacheR)]}),_.cacheC>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache c"}),Nt(_.cacheC)]})]}),T.length>0&&g.jsxs("section",{className:"up-section",children:[g.jsx("h3",{className:"up-section-title",children:"By model"}),g.jsxs("table",{className:"up-table",children:[g.jsx("thead",{children:g.jsxs("tr",{children:[g.jsx("th",{children:"Model"}),g.jsx("th",{children:"Tokens"}),g.jsx("th",{children:"Cost"})]})}),g.jsx("tbody",{children:T.map(C=>g.jsxs("tr",{children:[g.jsx("td",{className:"up-model-name",title:C.model===Vd?"no model reported yet":C.model,children:C.model===Vd?"unknown":Rs(C.model)}),g.jsx("td",{className:"up-num",children:Nt(C.inputTokens+C.outputTokens)}),C.priced?g.jsx("td",{className:"up-num up-cost-val",children:qe(C.cost.total)}):g.jsx("td",{className:"up-num up-unpriced",children:hu})]},C.model))})]})]}),A.length>0&&g.jsxs("section",{className:"up-section",children:[g.jsx("h3",{className:"up-section-title",children:"By session"}),g.jsx("div",{className:"up-sessions",children:A.map(C=>g.jsxs("div",{className:"up-session-row",children:[g.jsx("span",{className:`sl-dot state-${C.state}`,"aria-hidden":!0}),g.jsx("span",{className:"vis-hidden",children:iy(C.state)}),g.jsx("span",{className:"up-session-label",children:C.label}),g.jsx("span",{className:"up-session-tokens",children:Nt(C.inputTokens+C.outputTokens)}),C.cost>0?g.jsxs("span",{className:"up-session-cost",title:C.unpricedTokens>0?`${Nt(C.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[qe(C.cost),C.unpricedTokens>0?"+":""]}):g.jsx("span",{className:"up-session-cost up-unpriced",children:hu})]},C.sessionId))})]}),M&&g.jsxs("div",{className:"up-hint",children:["“",hu,"” means this build holds no published rate for that model — those tokens are counted above and their dollars are not."]})]}):g.jsxs("div",{className:"up-empty",children:["No usage data yet.",g.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const o_=18,b3=1100,no=(e,n)=>{const r=Math.sin(e*12.9898+n*78.233)*43758.5453;return r-Math.floor(r)},S3=Array.from({length:o_},(e,n)=>{const r=-72+144*n/(o_-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 a_({anchor:e,lifetimeMs:n=b3}){var l;const[r,i]=R.useState(null),o=typeof window<"u"&&((l=window.matchMedia)==null?void 0:l.call(window,"(prefers-reduced-motion: reduce)").matches);return R.useEffect(()=>{if(o)return;const u=e.current;if(!u)return;const c=u.getBoundingClientRect();i({x:c.left+c.width/2,y:c.top+c.height/2});const h=window.setTimeout(()=>i(null),n);return()=>window.clearTimeout(h)},[e,n,o]),o||!r?null:rM.createPortal(g.jsx("div",{className:"confetti",style:{left:`${r.x}px`,top:`${r.y}px`},"aria-hidden":!0,children:S3.map((u,c)=>g.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 FC=new Set(["awaiting_url","awaiting_code","registering"]);function k3(e){return e!=null&&FC.has(e)}function zC(e){return e!=null&&e!=="done"&&!FC.has(e)}const E3="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",N3="the sign-in did not complete";function C3({state:e,serverError:n,localError:r}){const i=e==="idle";return{title:i?"Sign-in ended":"Sign-in failed",message:r||n||(i?E3:N3)}}const T3="done";function j3(){let e=!1;return{shouldAnnounce(n){return n!==T3?(e=!1,!1):e?!1:(e=!0,!0)}}}const l_={already_running:"a sign-in is already in progress",no_url:"the claude CLI did not offer a sign-in link — is it installed?",not_waiting:"that sign-in is no longer waiting for a code",not_prompted:"the CLI has not asked for a code yet",code_rejected:"that code was not accepted — copy it again from the browser",no_verdict:"the claude CLI has not answered — try the code again",empty_code:"paste the code from the browser first",login_failed:"the code was not accepted",no_identity:"signed in, but the CLI still reports nobody logged in",add_failed:"signed in, but claude-swap could not record the account",not_a_share:"that does not look like a shared account — it should start with ccdeck1:",corrupt:"that share is incomplete — copy the whole thing",wrong_version:`that share was made by a newer ${Gt}`,expired:"that share has expired — make a new one",import_failed:"claude-swap refused the import",bad_value:"an alias can only use letters, numbers, spaces, dots, dashes and underscores, up to 64 characters"},u_={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"},R3=`claude-swap could not read the login keychain — start ${Gt} from a Terminal window rather than a background service`;function Mv(e,n){return(e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(go(e))?R3:e!=null&&e.reason&&u_[e.reason]?u_[e.reason]:(e==null?void 0:e.reason)||n}function go(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const c_={no_install:"ccusage is not installed, and AGENTS_DECK_NO_INSTALL=1 forbids fetching it — unset that variable and restart the deck, or install ccusage yourself so it is on this deck's PATH",bad_override:"AGENTS_DECK_CCUSAGE names a file that is not there — correct it to the full path of your ccusage, or unset it to let the deck find its own",timeout:"ccusage took more than 90 seconds and was stopped — a narrower range usually finishes",bad_output:"ccusage ran but printed no usage data — try again, and run ccusage daily --json in a terminal if it keeps happening",run_failed:"ccusage could not report usage — try again",bad_range:"that date range is not a YYYYMMDD date — reopen the modal and pick one of the presets",unreachable:"the deck did not answer — check it is still running, then try again"},A3="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 I3(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const M3="ccusage could not be started — the deck launched npx and Node could not load the npm script it points at. An older deck asked cmd.exe for a bare npx.cmd, which made the shim look for that script under the deck's working directory instead of beside itself; update the deck and reopen this modal",O3="ccusage could not be started — the copy npx fetched will not load: Node could not resolve a file inside it. That copy is in npx's own cache, which the deck never rewrites, so clear it with `npm cache clean --force` and reopen this modal",P3=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),L3=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,$3=/[\\/]_npx[\\/]/i,q3=`the copy of ccusage ${Gt} installed for itself`;function D3(e){const n=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return n.length>240?`${n.slice(0,239)}…`:n}function F3(e,n){const r=z3(e,n),i=D3(e);switch(e==null?void 0:e.stage){case"npx":return i?`ccusage failed on both of its paths. The managed install failed first — ${i} — and the deck then fell back to npx, where ${ua(r)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${ua(r)}`;case"managed":return`${q3} failed to run: ${ua(r)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${ua(r)}`:`the ccusage this deck found on your PATH failed to run: ${ua(r)}`;default:return r}}const ua=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function z3(e,n){const r=go(e);if(P3(r)){if($3.test(r))return O3;if(L3.test(r))return M3}return I3(r)?A3:e!=null&&e.reason&&c_[e.reason]?c_[e.reason]:(e==null?void 0:e.reason)||n}function pu(e,n){return e!=null&&e.detail?e.detail:e!=null&&e.error&&zC(e.state)?e.error:e!=null&&e.reason&&l_[e.reason]?l_[e.reason]:e!=null&&e.error?e.error:(e==null?void 0:e.reason)||n}const B3=1500;async function ru(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const Ov=ue.forwardRef((e,n)=>g.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:n,children:[g.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),g.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));Ov.displayName="SuccessMark";function U3({onClose:e,onChanged:n}){const[r,i]=R.useState("login"),[o,l]=R.useState(null),[u,c]=R.useState(""),[h,p]=R.useState(""),[d,m]=R.useState(!1),[y,w]=R.useState(null),[E,_]=R.useState(null),b=R.useRef(!1),S=R.useRef(null),k=R.useRef(null),N=R.useRef(null),T=R.useRef(null),A=R.useCallback(()=>{b.current&&ru({action:"login-cancel"}).catch(()=>{}),e()},[e]),M=yo(A,{focusRef:N}),O=R.useCallback(async()=>{m(!0),w(null),b.current=!0;const F=await ru({action:"login"}).catch(()=>null);if(m(!1),!(F!=null&&F.ok)){w(pu(F,"could not start the sign-in"));return}l(F)},[]);R.useEffect(()=>{if(!k3(o==null?void 0:o.state))return;const F=window.setInterval(async()=>{try{const $=await fetch("/api/claude-accounts/login");$.ok&&l(await $.json())}catch{}},B3);return()=>window.clearInterval(F)},[o]);const P=R.useRef(n);P.current=n;const D=R.useRef(j3());R.useEffect(()=>{var F;(o==null?void 0:o.state)==="awaiting_code"&&((F=S.current)==null||F.focus()),D.current.shouldAnnounce(o==null?void 0:o.state)&&P.current()},[o==null?void 0:o.state]),R.useEffect(()=>{var F;r==="paste"&&((F=k.current)==null||F.focus())},[r]);const L=R.useCallback(async()=>{var $;m(!0),w(null);const F=await ru({action:"login-code",code:u}).catch(()=>null);if(m(!1),!(F!=null&&F.ok)){w(pu(F,"the code was not accepted")),F!=null&&F.state&&l(F),($=S.current)==null||$.select();return}c(""),l(F)},[u,o]),U=R.useCallback(async()=>{m(!0),w(null);const F=await ru({action:"import",blob:h}).catch(()=>null);if(m(!1),!(F!=null&&F.ok)){w(pu(F,"the import failed"));return}p(""),_({added:F.added===!0,num:F.num??null,email:F.email??null}),n()},[h,n]),V=(o==null?void 0:o.state)==="done"?o.account:null,z=zC(o==null?void 0:o.state)||!!(y&&b.current&&!d),C=C3({state:o==null?void 0:o.state,serverError:o==null?void 0:o.error,localError:y});return g.jsx("div",{className:"modal-backdrop",onClick:A,role:"presentation",children:g.jsxs("div",{ref:M,className:"modal aa-modal",onClick:F=>F.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[g.jsxs("header",{className:"modal-head",children:[g.jsx("div",{className:"modal-title",children:g.jsxs("span",{className:"aa-tabs",role:"tablist",children:[g.jsx("button",{type:"button",role:"tab","aria-selected":r==="login",className:`aa-tab${r==="login"?" on":""}`,onClick:()=>i("login"),children:"Sign in"}),g.jsx("button",{type:"button",role:"tab","aria-selected":r==="paste",className:`aa-tab${r==="paste"?" on":""}`,onClick:()=>i("paste"),children:"Paste a share"})]})}),g.jsx("div",{className:"modal-actions",children:g.jsx("button",{type:"button",className:"btn icon-btn",onClick:A,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),g.jsx("section",{className:"modal-body aa-body",children:r==="login"?V?g.jsxs("div",{className:"aa-done",children:[g.jsx(Ov,{ref:T}),g.jsx(a_,{anchor:T}),g.jsx("h4",{children:V.added?`Account ${V.num} added`:"Credentials refreshed"}),g.jsxs("p",{className:"aa-note",children:[g.jsx("strong",{children:V.email}),V.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),g.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"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"1 · Approve in the browser"}),g.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),g.jsx("a",{className:"aa-link",href:o.url??"#",target:"_blank",rel:"noreferrer noopener",children:o.url})]}),g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"2 · Paste the code it gives you"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{ref:S,type:"text",value:u,onChange:F=>c(F.target.value),onKeyDown:F=>{F.key==="Enter"&&u.trim()&&!d&&L()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:o.state==="registering"}),g.jsx("button",{type:"button",className:"btn primary",disabled:d||!u.trim()||o.state==="registering",onClick:L,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&g.jsx("p",{className:"aa-err",children:y??o.error}),g.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):z?g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:C.title}),g.jsx("p",{className:"aa-err",children:C.message}),g.jsx("button",{type:"button",className:"btn",onClick:()=>{b.current=!1,l(null),w(null),O()},children:"Try again"})]}):d||b.current?g.jsx("div",{className:"aa-step",children:g.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):g.jsxs("div",{className:"aa-step aa-primer",children:[g.jsx("h4",{children:"Sign in to Anthropic"}),g.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."}),g.jsx("div",{className:"aa-actions",children:g.jsx("button",{type:"button",ref:N,className:"btn primary",onClick:O,disabled:d,children:"Open the sign-in page"})})]}):E?g.jsxs("div",{className:"aa-done",children:[g.jsx(Ov,{ref:T}),E.added&&g.jsx(a_,{anchor:T}),g.jsx("h4",{children:E.added?`Account ${E.num} imported`:"Already here"}),g.jsx("p",{className:"aa-note",children:E.added?g.jsxs(g.Fragment,{children:[E.email?g.jsx("strong",{children:E.email}):"That account"," is in the rotation now. Nothing changed on the deck you copied it from."]}):"This deck already holds that account, so nothing changed."}),g.jsxs("div",{className:"aa-actions",children:[g.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),g.jsx("button",{type:"button",className:"btn",onClick:()=>_(null),children:"Import another"})]})]}):g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"Paste an account shared from another deck"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{ref:k,type:"text",value:h,onChange:F=>p(F.target.value),onKeyDown:F=>{F.key==="Enter"&&h.trim()&&!d&&U()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),g.jsx("button",{type:"button",className:"btn primary",disabled:d||!h.trim(),onClick:U,children:d?"importing…":"Import"})]}),y&&g.jsx("p",{className:"aa-err",children:y}),g.jsxs("p",{className:"aa-note",children:["Use ",g.jsx("strong",{children:"share"})," on an account in the other deck. A share carries a live login and expires ten minutes after it is made."]})]})})]})})}function H3(e,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 W3(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}}const V3=64;function G3(e,n){const r=e.trim();return{alias:r,commit:r!==(n??"").trim()}}const Y3=Object.freeze({text:"couldn't reach the deck server",reload:!0});async function d_(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function K3(e){const n=e.find(i=>!i.ok);if(!n)return null;const r=go(n.body);return{text:Mv(n.body,`the deck server answered ${n.status}`),...r?{raw:r}:{},reload:!0}}function f_(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 h_=15e3,X3=8e3,Q3=1800,Z3=3e4,J3=[70,80,85,90,95];function p_(e,n){return $C(n-Math.floor(e/1e3))}function e$(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 t$(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 n$({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?qC(e.resetAt,n):null;return g.jsxs("div",{className:"ap-lane",children:[g.jsx("span",{className:"ap-lane-label",children:e.label}),g.jsx("div",{className:"ap-lane-track",children:g.jsx("div",{className:"ap-lane-fill",style:{width:`${r===0?1.5:r}%`,background:i,opacity:r===0?.4:1}})}),g.jsxs("span",{className:"ap-lane-pct",style:{color:i},children:[r,"%"]}),g.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}async function r$(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 s$(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 i$({onClose:e}){var ne,ae,fe;const[n,r]=R.useState(null),[i,o]=R.useState(null),[l,u]=R.useState(null),[c,h]=R.useState(!1),[p,d]=R.useState(null),[m,y]=R.useState(null),[w,E]=R.useState(()=>Math.floor(Date.now()/1e3)),_=R.useRef(null),[b,S]=R.useState(null),[k,N]=R.useState(!1),[T,A]=R.useState(""),[M,O]=R.useState(null),[P,D]=R.useState(null),[L,U]=R.useState(null),[V,z]=R.useState(!1),[C,F]=R.useState(null),$=R.useCallback(async(te=!1)=>{te&&h(!0);const ce=new AbortController,Ce=window.setTimeout(()=>ce.abort(),Z3);try{const[ve,Re]=await Promise.all([fetch(`/api/claude-accounts${te?"?refresh=1":""}`,{signal:ce.signal}),fetch("/api/cswap-auto",{signal:ce.signal})]);ve.ok&&r(await ve.json()),Re.ok&&o(await Re.json());const ye=K3([await d_(ve),await d_(Re)]);y(Ee=>f_(Ee,ye))}catch{y(ve=>f_(ve,Y3))}finally{window.clearTimeout(Ce),te&&h(!1)}},[]),re=R.useCallback(async(te,ce)=>{u(ce),y(null);try{const ve=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)})).json().catch(()=>null);return ve!=null&&ve.ok||y({text:Mv(ve,"command failed"),raw:go(ve)}),ve}catch{return y({text:"server unreachable"}),null}finally{u(null)}},[]),J=R.useCallback(async(te,ce)=>{u(ce),y(null);try{const ve=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)})).json().catch(()=>null);return ve!=null&&ve.ok||y({text:pu(ve,"command failed")}),ve}catch{return y({text:"server unreachable"}),null}finally{u(null)}},[]);R.useEffect(()=>($(!0),_.current=window.setInterval(()=>$(!1),h_),()=>{_.current!=null&&window.clearInterval(_.current)}),[$]),R.useEffect(()=>{const te=window.setInterval(()=>E(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(te)},[]);const W=((ne=i==null?void 0:i.settings["autoswitch.threshold"])==null?void 0:ne.value)??"90",Z=(ae=n==null?void 0:n.accounts)==null?void 0:ae.find(te=>te.active),I=Z!=null&&Z.lanes.length?Math.max(...Z.lanes.map(te=>te.pct)):null,G=I!=null&&I>=Number(W)-15,K=async te=>{d(te),y(null);try{const Ce=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:te})})).json().catch(()=>null);Ce!=null&&Ce.ok||y({text:Mv(Ce,"the switch failed"),raw:go(Ce)}),await $(!0)}catch{y({text:"server unreachable"})}finally{d(null)}},q=async(te,ce)=>{const{commit:Ce,alias:ve}=G3(T,ce);if(Ce){const Re=await J({action:"alias",account:te,alias:ve},`alias-${te}`);if(await $(!0),!(Re!=null&&Re.ok))return;A(ve)}O(te),window.setTimeout(()=>O(Re=>Re===te?null:Re),Q3)},Q=async(te,ce)=>{const Ce=await J({action:"move",account:te,slot:ce},`move-${te}`),ve=W3({menuFor:b,shareFor:(L==null?void 0:L.num)??null},te,Ce);if(await $(!0),ve){S(ve.menuFor),D(ve.confirmRemove),ve.shareFor==null&&(U(null),z(!1)),F(ve.swapNote);const Re=ve.swapNote;Re&&window.setTimeout(()=>F(ye=>ye===Re?null:ye),X3)}};return g.jsxs("aside",{className:"accounts-panel",id:"accounts-panel","aria-label":"Claude accounts",children:[g.jsxs("div",{className:"ap-header",children:[g.jsx("h2",{children:"Accounts"}),g.jsxs("div",{className:"ap-header-right",children:[g.jsx("button",{type:"button",className:"btn ap-add",onClick:()=>N(!0),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),g.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>$(!0),disabled:c,"aria-label":"Reload accounts",title:"Reload from claude-swap",children:c?"…":"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?m?g.jsxs("div",{className:"ap-empty",role:"alert",children:[g.jsx("span",{title:m.raw||void 0,children:m.text}),g.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",h_/1e3," seconds."]}),g.jsx("button",{type:"button",className:"ap-fix",disabled:c,onClick:()=>$(!0),children:c?"trying…":"try again"})]}):g.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?g.jsxs(g.Fragment,{children:[(fe=n.accounts)==null?void 0:fe.map(te=>g.jsxs("div",{className:`ap-account${te.active?" active":""}${te.disabled?" disabled":""}`,children:[g.jsxs("div",{className:"ap-account-head",children:[g.jsx("span",{className:"ap-num",children:te.num}),te.alias&&g.jsx("span",{className:"ap-alias",title:te.alias,children:te.alias}),g.jsx("span",{className:"ap-email",title:te.org??void 0,children:te.email}),g.jsx("button",{type:"button",className:`ap-more${b===te.num?" on":""}`,"aria-label":`Manage account ${te.num}`,"aria-expanded":b===te.num,"aria-controls":b===te.num?`ap-manage-${te.num}`:void 0,title:"Share, rename, move, remove",onClick:()=>{S(b===te.num?null:te.num),A(te.alias??""),D(null),U(null),z(!1),F(null),O(null)},children:"⋯"}),te.active?g.jsx("span",{className:"ap-badge-active",children:"● active"}):g.jsx("button",{type:"button",className:"btn ap-switch",disabled:p!=null||te.disabled,onClick:()=>K(te.num),title:te.disabled?"Held out of rotation":`Switch to ${te.alias??te.email}`,children:p===te.num?"…":"switch"})]}),te.lanes.length>0?te.lanes.map(ce=>g.jsx(n$,{lane:ce,nowSec:w},ce.id)):g.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),g.jsxs("div",{className:"ap-meta",children:[te.error&&(()=>{const ce=t$(te.error);return g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"ap-err",title:ce.hint,children:ce.text}),ce.fixable&&g.jsx("button",{type:"button",className:"ap-fix",onClick:()=>N(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"sign in again"})]})})(),((i==null?void 0:i.enabled)||(i==null?void 0:i.external))&&!te.active&&g.jsx("button",{type:"button",className:"ap-rotate",disabled:l!=null,onClick:()=>re({action:"account",account:te.num,enabled:te.disabled},`rot-${te.num}`).then(()=>$(!0)),title:te.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:te.disabled?"held out":"in rotation"}),te.fetchedAt?g.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 ",p_(te.fetchedAt,w),e$(te.nextAt,w)]}):g.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),b===te.num&&g.jsxs("div",{className:"ap-manage",id:`ap-manage-${te.num}`,role:"group","aria-label":`Manage account ${te.num}`,children:[g.jsxs("div",{className:"ap-manage-name",children:[g.jsx("label",{className:"vis-hidden",htmlFor:`ap-alias-${te.num}`,children:"Alias"}),g.jsx("input",{id:`ap-alias-${te.num}`,className:"ap-manage-input",type:"text",value:T,onChange:ce=>A(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&q(te.num,te.alias)},maxLength:V3,placeholder:"e.g. work",spellCheck:!1,autoFocus:!0}),g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:()=>q(te.num,te.alias),title:"A short name to show instead of the email",children:M===te.num?"saved":"save"})]}),g.jsxs("div",{className:"ap-manage-acts",children:[g.jsx("label",{className:"vis-hidden",htmlFor:`ap-slot-${te.num}`,children:"Slot"}),g.jsx("span",{className:"ap-field",children:g.jsx("select",{id:`ap-slot-${te.num}`,value:String(te.num),disabled:l!=null,onChange:ce=>Q(te.num,Number(ce.target.value)),children:H3((n.accounts??[]).map(ce=>ce.num),te.num).map(ce=>g.jsx("option",{value:ce.slot,children:ce.label},ce.slot))})}),g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,title:`Copy this account to another ${Gt}. Anyone who has the text can use the account — treat it as the password. The other deck stops accepting it after 10 minutes; that does not make an escaped copy safe.`,onClick:async()=>{z(!1);const ce=await J({action:"share",account:te.num},`share-${te.num}`);ce!=null&&ce.ok&&U({num:te.num,blob:ce.blob,expiresAt:ce.expiresAt})},children:"share"}),g.jsx("button",{type:"button",className:`ap-manage-btn danger${P===te.num?" armed":""}`,disabled:l!=null,title:P===te.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(P!==te.num){D(te.num),window.setTimeout(()=>D(ce=>ce===te.num?null:ce),4e3);return}D(null),J({action:"remove",account:te.num},`rm-${te.num}`).then(()=>{S(null),$(!0)})},children:P===te.num?"confirm":"remove"})]}),(C==null?void 0:C.at)===te.num&&(()=>{var ve;const ce=(ve=n.accounts)==null?void 0:ve.find(Re=>Re.num===C.displaced),Ce=(ce==null?void 0:ce.alias)??(ce==null?void 0:ce.email)??"the account that was there";return g.jsxs("span",{className:"ap-manage-hint ap-manage-swap",title:`Slot ${C.at} was taken, so the two accounts traded places: ${Ce} now holds slot ${C.displaced}.`,children:["swapped with slot ",C.displaced]})})(),(L==null?void 0:L.num)===te.num&&(()=>{const ce=s$(L.expiresAt,w),Ce=ce.tone==="gone";return g.jsxs("div",{className:`ap-share${Ce?" expired":""}`,children:[g.jsx("code",{className:"ap-share-blob",children:L.blob}),g.jsxs("div",{className:"ap-share-foot",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:async()=>{if(Ce){z(!1);const ve=await J({action:"share",account:te.num},`share-${te.num}`);ve!=null&&ve.ok&&U({num:te.num,blob:ve.blob,expiresAt:ve.expiresAt});return}await r$(L.blob)&&(z(!0),window.setTimeout(()=>z(!1),1800))},children:Ce?"make a new share":V?"copied":"copy"}),g.jsxs("span",{className:"ap-manage-hint",title:"This text is the account's password. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the login itself is in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign the account out and back in.",children:[g.jsx("span",{className:"ap-share-warn",children:"this is the password"})," · ",g.jsx("span",{className:`ap-share-expiry ${ce.tone}`,children:ce.text})]})]})]})})()]})]},te.num)),(i==null?void 0:i.ok)&&g.jsxs("div",{className:"ap-auto",children:[g.jsxs("div",{className:"ap-auto-head",children:[g.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),g.jsxs("span",{className:"ap-auto-ctl",children:[I!=null&&g.jsxs("span",{className:`ap-auto-now${G?" near":""}`,children:[Math.round(I),"%"]}),g.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:g.jsx("select",{"aria-label":"Switch threshold",value:W,disabled:l!=null,onChange:te=>re({action:"setting",key:"autoswitch.threshold",value:te.target.value},"threshold").then(()=>$(!0)),children:J3.map(te=>g.jsxs("option",{value:te,children:[te,"%"]},te))})}),g.jsxs("button",{type:"button",className:`ap-auto-state${i.enabled?" live":""}`,role:"switch","aria-checked":i.enabled,disabled:l!=null,onClick:()=>re({action:"enable",enabled:!i.enabled},"enable").then(()=>$(!0)),title:i.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[g.jsx("i",{className:i.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),i.enabled?"on":"off"]})]})]}),i.external&&g.jsxs("p",{className:"ap-auto-note",children:[g.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",g.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&&g.jsx("div",{className:"ap-auto-foot",children:g.jsxs("span",{className:"ap-auto-result",children:["checked ",p_(i.lastTick.at,w)]})})]}),m&&g.jsxs("div",{className:"ap-failure",role:"alert",children:[g.jsx("span",{className:"ap-failure-text",title:m.raw||void 0,children:m.text}),g.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>y(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),g.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."})]}):g.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"claude-swap isn't installed."}),g.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&&g.jsx("code",{className:"ap-cmd",children:n.hint}),g.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",g.jsx("strong",{children:"+"})," button above."]})]}):n.reason==="no_accounts"?g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"No accounts added yet."}),g.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",g.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"Couldn't read the account store."}),g.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})}),k&&g.jsx(U3,{onClose:()=>N(!1),onChanged:()=>$(!0)})]})}const o$=3e4;function a$({bundle:e,running:n,lastTried:r}){return!n||e===n?!1:r!==n}function l$({bundle:e,running:n,pending:r,lastTried:i}){return n?a$({bundle:e,running:n,lastTried:i})?"reload":r==null||r&&r!==n?"wait":"confirm":"wait"}function u$(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function c$({asked:e,reported:n}){return n?n!==e:!1}function d$(e){const n=e.thresholdMs??o$;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 f$({agentCount:e,onConfirm:n,onCancel:r}){const i=R.useRef(null),o=yo(r,{focusRef:i,layer:WP}),l=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 g.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:g.jsxs("div",{ref:o,className:"modal clear-confirm",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[g.jsxs("header",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:"status-dot err","aria-hidden":!0}),g.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),g.jsx("div",{className:"modal-actions",children:g.jsx("button",{type:"button",className:"btn icon-btn",onClick:r,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),g.jsxs("section",{className:"modal-body",children:[g.jsxs("p",{className:"modal-note",children:[l," — the file a restarted deck replays to rebuild what you see. Layout, pins and selection go with it. This cannot be undone."]}),g.jsxs("div",{className:"cc-actions",children:[g.jsx("button",{type:"button",ref:i,className:"btn",onClick:r,children:"Cancel"}),g.jsx("button",{type:"button",className:"btn danger",onClick:n,children:"Clear everything"})]})]})]})})}function h$(e,n){return e==="confirmation"?n.confirmOpen?"clear":"ignore":n.modalOpen||n.confirmOpen?"ignore":"confirm"}function p$(e){return e.slice().sort((n,r)=>n.y-r.y||n.x-r.x)}function m$(e,n,r){var u;if(e.length===0)return null;const i=p$(e),o=n?i.findIndex(c=>c.id===n):-1,l=o===-1?r===1?0:i.length-1:(o+r+i.length)%i.length;return((u=i[l])==null?void 0:u.id)??null}const g$=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Delete","Backspace"]);function v$(e,n){return n==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:n,additive:e.shiftKey}:g$.has(e.key)?{kind:"node",nodeId:n}:{kind:"deck",nodeId:n}}const y$=new Set(["","BODY","HTML","#DOCUMENT"]);function w$(e){return!e||sy(e)?!1:!y$.has(String(e.tagName??"").toUpperCase())}function su(e,n){if(n.size!==0)for(const r of Array.from(e.keys()))n.has(r)||e.delete(r)}function x$(e){const n=new Set;for(const r of e)n.add(r.id),n.add(`group:${r.sessionId}`);return n}function BC(e,n,r){return!n.has(e)||r.has(e)}function _$(e,n,r,i){return!n.has(e)&&BC(e,r,i)}function b$(e,n,r){const i={x:0,y:0};return n.set(e,i),r.add(e),i}function S$(e,n,r,i){r.set(e,n),i.delete(e)}const k$=40,E$=120;function N$(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=(h,p,d)=>{if(r!=null){if(i<=h)return;u()}const m=Math.min(d,Math.max(0,h-p));i=h,r=n.setTimeout(l,m)};return{live(h=k$){const p=n.now(),d=Math.max(o+h,p);if(d<=p){u(),l();return}c(d,p,h)},replay(h=E$){u(),i=n.now()+h,r=n.setTimeout(l,h)},flush(){u(),l()},cancel(){u()}}}function C$(){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 T$="1",m_="agent-dag.schema",j$=["agent-dag.layout","agent-dag.viewport"];function UC(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function R$(e,n=T$){let r=null;try{r=e.getItem(m_)}catch{return[]}if(r===n)return[];const i=[];if(r!==null)for(const o of j$)try{e.getItem(o)!==null&&(e.removeItem(o),i.push(o))}catch{}try{e.setItem(m_,n)}catch{}return i}const HC="agent-dag.theme";function A$(e){return e==="light"?"light":"dark"}function I$(){return A$(UC(HC))}function M$({waiting:e,running:n}){return{title:e>0?`(${e}) ${Gt}`:Gt,icon:e>0?"waiting":n>0?"running":"idle"}}const Gd={waiting:"#c97d12",running:"#2a90d4",idle:"#7e828c"};function Yd(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 O$=Object.freeze({waiting:`data:image/svg+xml,${encodeURIComponent(Yd(Gd.waiting,"waiting"))}`,running:`data:image/svg+xml,${encodeURIComponent(Yd(Gd.running,"running"))}`,idle:`data:image/svg+xml,${encodeURIComponent(Yd(Gd.idle,"idle"))}`}),P$="No sessions are waiting for you.";function L$(e){if(e.length===0)return"";const[n,...r]=e;if(r.length===0)return`${n.label} is waiting for your permission.`;const i=`${r.length} more session${r.length===1?"":"s"}`;return`${n.label} and ${i} are waiting for your permission.`}function $$(e,n){return n!==""?n:e===""?"":P$}function q$(){let e=0;return{begin(){const n=++e;return()=>n===e},cancel(){e++}}}function D$(e,n=new Date){return new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}function F$(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 WC(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const g_={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent"};function ly(e){const n=e.toLowerCase();return g_[n]?g_[n]:n?n[0].toUpperCase()+n.slice(1):""}function z$(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function B$(e,n=[]){const r=n.length?z$(n.map(ly)):WC(e);return r?`via ccusage · local ${r} logs`:"via ccusage · local agent logs"}function U$(e){return e.claude&&e.codex?"Claude Code hooks and Codex rollout files":e.claude?"Claude Code hooks":e.codex?"Codex rollout files":null}function H$(e){const n=WC(e);return n?`Distinct sessions — ${n}`:"Distinct sessions"}function W$(e){const n=U$(e);return n?`Total events received — ${n}`:"Total events received"}function V$(e){const n=e.claude?{provider:"claude",watching:!0,spans:[{text:"Claude Code sends its events through a hook in "},{text:"~/.claude/settings.json",code:!0},{text:" — or in "},{text:"$CLAUDE_CONFIG_DIR/settings.json",code:!0},{text:" when you have that set — which the deck installs on first run."}]}:{provider:"claude",watching:!1,spans:[{text:"Claude Code capture is off: no Claude Code was found on this machine, or the deck was started with "},{text:"--no-claude",code:!0},{text:"."}]},r=e.codex?{provider:"codex",watching:!0,spans:[{text:"Codex installs nothing and needs no trust prompt — the deck reads "},{text:"~/.codex/sessions/",code:!0},{text:" itself, so an empty canvas means no rollout has been written there yet, or that "},{text:"$CODEX_HOME",code:!0},{text:" points at a different tree."}]}:{provider:"codex",watching:!1,spans:[{text:"Codex capture is off: no "},{text:"~/.codex/",code:!0},{text:" was found — set "},{text:"$CODEX_HOME",code:!0},{text:" if yours lives elsewhere — or the deck was started with "},{text:"--no-codex",code:!0},{text:"."}]};return[n,r]}function G$(e,n){const r=n.on?"Sound on turn finish: on — click to remove the hook":"Sound on turn finish: off — click to add a Stop hook",i=e.codex?`
|
|
@@ -69,7 +69,7 @@ Claude Code turns only. The sound is a Stop hook Claude Code runs itself when a
|
|
|
69
69
|
|
|
70
70
|
${n.clash} sound hook${n.clash>1?"s":""} of your own in settings.json also run${n.clash>1?"":"s"} here.`:"",l=n.parked>0?`
|
|
71
71
|
|
|
72
|
-
${n.parked} of your own sound hook${n.parked>1?"s were":" was"} set aside so this switch actually controls the sound. Nothing was deleted — shift-click to put ${n.parked>1?"them":"it"} back.`:"";return r+i+o+l}function VC(e){const n=new Map;for(const r of e)for(const i of r.agents??[]){if(!i||typeof i.agent!="string"||i.agent==="")continue;const o=n.get(i.agent)??{id:i.agent,cost:0,tokens:0};o.cost+=Number.isFinite(i.totalCost)?i.totalCost:0,o.tokens+=Number.isFinite(i.totalTokens)?i.totalTokens:0,n.set(i.agent,o)}return[...n.values()].sort((r,i)=>i.cost-r.cost||r.id.localeCompare(i.id))}function Y$(e){const n=VC([{agents:e}]);return n.length<2?null:n.map(r=>`${ly(r.id)} ${qe(r.cost)}`).join(" · ")}function v_(e){switch(e.toLowerCase()){case"claude":return"#c4b5fd";case"codex":return"#fdba74";case"gemini":return"#a5b4fc";case"copilot":return"#86efac";default:return"#94a3b8"}}function K$(e,n){if(!(n>0)||!(e>0))return"0%";const r=e/n*100;return r<.1?"<0.1%":`${r.toFixed(1)}%`}function iu(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 X$=[7,14,30,90];function Q$(e){const[n,r]=R.useState(null),[i,o]=R.useState(!1),l=R.useRef(q$()).current,u=(c=!1)=>{const h=l.begin(),p=e;o(!0);const m=`/api/ccusage?since=${D$(p)}${c?"&refresh=1":""}`;fetch(m).then(y=>y.json()).then(y=>{h()&&r({range:p,resp:y})}).catch(()=>{h()&&r({range:p,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{h()&&o(!1)})};return R.useEffect(()=>(u(!1),()=>l.cancel()),[e]),{landed:n,loading:i,reload:()=>u(!0)}}function Z$({onClose:e,providers:n}){var O;const[r,i]=R.useState(30),[o,l]=R.useState(null),{landed:u,loading:c,reload:h}=Q$(r),p=R.useRef(null),d=yo(e,{focusRef:p}),m=F$({loading:c,want:r,answer:u&&{range:u.range,ok:u.resp.ok===!0,days:((O=u.resp.days)==null?void 0:O.length)??0}}),y=m.phase==="chart"?u.resp.days??[]:[],w=R.useMemo(()=>y.reduce((P,D)=>Math.max(P,D.totalCost),0),[y]),{totalCost:E,totalTok:_,inOut:b,cacheRead:S,modelCosts:k}=R.useMemo(()=>{let P=0,D=0,L=0,U=0;const V=new Map;for(const z of y){P+=z.totalCost,D+=z.totalTokens,L+=z.inputTokens+z.outputTokens,U+=z.cacheReadTokens;for(const C of z.modelBreakdowns)V.set(C.modelName,(V.get(C.modelName)??0)+C.cost)}return{totalCost:P,totalTok:D,inOut:L,cacheRead:U,modelCosts:V}},[y]),N=R.useMemo(()=>Array.from(k.entries()).sort((P,D)=>D[1]-P[1]),[k]),T=R.useMemo(()=>VC(y),[y]),A=T.length>1,M=o?y.find(P=>P.period===o)??null:null;return g.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:g.jsxs("div",{ref:d,className:"uh-modal",onClick:P=>P.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Usage history",children:[g.jsxs("header",{className:"uh-head",children:[g.jsxs("div",{className:"uh-titlewrap",children:[g.jsx("div",{className:"uh-title",children:"Usage history"}),g.jsx("div",{className:"uh-sub",children:B$(n,T.map(P=>P.id))})]}),g.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:X$.map(P=>g.jsxs("button",{type:"button","aria-pressed":r===P,className:`uh-range-btn${r===P?" on":""}`,onClick:()=>{i(P),l(null)},children:[P,"d"]},P))}),g.jsx("button",{className:"btn icon-btn uh-reload",onClick:h,disabled:c,title:"Re-run ccusage","aria-label":"Reload",children:c?"…":"↻"}),g.jsx("button",{ref:p,className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),m.phase==="busy"?g.jsx("div",{className:"uh-status","aria-busy":"true",children:u?"running ccusage…":"running ccusage… (first run downloads the package)"}):m.phase==="error"?g.jsxs("div",{className:"uh-status uh-err",title:go(u.resp)||void 0,children:[F3(u.resp,"ccusage did not report usage"),g.jsx("div",{children:g.jsx("button",{className:"btn uh-retry",onClick:h,disabled:c,children:c?"trying…":"Try again"})})]}):m.phase==="empty"?g.jsx("div",{className:`uh-status${m.stale?" uh-stale":""}`,"aria-busy":m.stale||void 0,children:"no usage in this range"}):g.jsxs("div",{className:m.stale?"uh-stale":void 0,"aria-busy":m.stale||void 0,children:[g.jsxs("div",{className:"uh-totals",children:[g.jsx(ou,{label:"total cost",val:qe(E),accent:!0}),g.jsx(ou,{label:"tokens",val:Nt(_)}),g.jsx(ou,{label:"input+output",val:Nt(b)}),g.jsx(ou,{label:"cache reads",val:Nt(S)})]}),A&&g.jsxs("div",{className:"uh-agents",role:"group","aria-label":"Cost by CLI",children:[g.jsx("div",{className:"uh-agent-bar","aria-hidden":"true",children:T.map(P=>g.jsx("span",{className:"uh-agent-seg",style:{width:`${E>0?P.cost/E*100:0}%`,background:v_(P.id)}},P.id))}),g.jsx("div",{className:"uh-agent-keys",children:T.map(P=>g.jsxs("span",{className:"uh-agent-key",title:`${P.id} · ${Nt(P.tokens)} tokens`,children:[g.jsx("span",{className:"uh-legend-dot",style:{background:v_(P.id)}}),ly(P.id),g.jsx("span",{className:"uh-agent-cost",children:qe(P.cost)}),g.jsx("span",{className:"uh-agent-share",children:K$(P.cost,E)})]},P.id))})]}),g.jsx("div",{className:"uh-chart",role:"group","aria-label":"Daily cost by model",children:y.map(P=>{const D=w>0?P.totalCost/w*100:0,L=P.period===o,U=`${P.period}, ${qe(P.totalCost)}`;return g.jsxs("button",{className:`uh-bar-col${L?" sel":""}`,onClick:()=>l(L?null:P.period),"aria-pressed":L,"aria-label":U,title:`${P.period} · ${qe(P.totalCost)}`,style:{flexBasis:`${100/y.length}%`},children:[g.jsx("div",{className:"uh-bar",style:{height:`${Math.max(D,P.totalCost>0?2:0)}%`},children:P.modelBreakdowns.slice().sort((V,z)=>z.cost-V.cost).map(V=>{const z=P.totalCost>0?V.cost/P.totalCost*100:0;return g.jsx("div",{className:"uh-bar-seg",style:{height:`${z}%`,background:iu(V.modelName)}},V.modelName)})}),g.jsx("span",{className:"uh-bar-label",children:P.period.slice(5)})]},P.period)})}),g.jsx("div",{className:"uh-legend",children:N.map(([P,D])=>g.jsxs("span",{className:"uh-legend-item",title:P,children:[g.jsx("span",{className:"uh-legend-dot",style:{background:iu(P)}}),Rs(P)," ",g.jsx("span",{className:"uh-legend-cost",children:qe(D)})]},P))}),M&&g.jsxs("div",{className:"uh-detail",children:[g.jsxs("div",{className:"uh-detail-head",children:[g.jsx("span",{className:"uh-detail-date",children:M.period}),g.jsx("span",{className:"uh-detail-cost",children:qe(M.totalCost)}),(()=>{var L,U;const D=Y$(M.agents)??((U=(L=M.metadata)==null?void 0:L.agents)!=null&&U.length?M.metadata.agents.join(" · "):null);return D?g.jsx("span",{className:"uh-detail-agents",title:D,children:D}):null})()]}),g.jsxs("div",{className:"uh-detail-mini",children:[g.jsx(au,{label:"input",val:Nt(M.inputTokens)}),g.jsx(au,{label:"output",val:Nt(M.outputTokens)}),g.jsx(au,{label:"cache write",val:Nt(M.cacheCreationTokens)}),g.jsx(au,{label:"cache read",val:Nt(M.cacheReadTokens)})]}),g.jsx("div",{className:"uh-detail-models",children:M.modelBreakdowns.slice().sort((P,D)=>D.cost-P.cost).map(P=>{const D=M.totalCost>0?P.cost/M.totalCost*100:0;return g.jsxs("div",{className:"uh-model-row",title:P.modelName,children:[g.jsxs("span",{className:"uh-model-name",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:iu(P.modelName)}}),g.jsx("span",{className:"uh-model-label",children:Rs(P.modelName)})]}),g.jsx("span",{className:"uh-model-bar",children:g.jsx("span",{className:"uh-model-bar-fill",style:{width:`${D}%`,background:iu(P.modelName)}})}),g.jsx("span",{className:"uh-model-cost",children:qe(P.cost)})]},P.modelName)})})]})]})]})})}function ou({label:e,val:n,accent:r}){return g.jsxs("div",{className:"uh-stat",children:[g.jsx("span",{className:`uh-stat-val${r?" accent":""}`,children:n}),g.jsx("span",{className:"uh-stat-label",children:e})]})}function au({label:e,val:n}){return g.jsxs("div",{className:"uh-ministat",children:[g.jsx("span",{className:"uh-ministat-val",children:n}),g.jsx("span",{className:"uh-ministat-label",children:e})]})}function uy(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 Kd,y_;function J$(){if(y_)return Kd;y_=1;function e(){this.__data__=[],this.size=0}return Kd=e,Kd}var Xd,w_;function wo(){if(w_)return Xd;w_=1;function e(n,r){return n===r||n!==n&&r!==r}return Xd=e,Xd}var Qd,x_;function qu(){if(x_)return Qd;x_=1;var e=wo();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 Zd,__;function eq(){if(__)return Zd;__=1;var e=qu(),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 Zd=i,Zd}var Jd,b_;function tq(){if(b_)return Jd;b_=1;var e=qu();function n(r){var i=this.__data__,o=e(i,r);return o<0?void 0:i[o][1]}return Jd=n,Jd}var ef,S_;function nq(){if(S_)return ef;S_=1;var e=qu();function n(r){return e(this.__data__,r)>-1}return ef=n,ef}var tf,k_;function rq(){if(k_)return tf;k_=1;var e=qu();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 tf=n,tf}var nf,E_;function Du(){if(E_)return nf;E_=1;var e=J$(),n=eq(),r=tq(),i=nq(),o=rq();function l(u){var c=-1,h=u==null?0:u.length;for(this.clear();++c<h;){var p=u[c];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=i,l.prototype.set=o,nf=l,nf}var rf,N_;function sq(){if(N_)return rf;N_=1;var e=Du();function n(){this.__data__=new e,this.size=0}return rf=n,rf}var sf,C_;function iq(){if(C_)return sf;C_=1;function e(n){var r=this.__data__,i=r.delete(n);return this.size=r.size,i}return sf=e,sf}var of,T_;function oq(){if(T_)return of;T_=1;function e(n){return this.__data__.get(n)}return of=e,of}var af,j_;function aq(){if(j_)return af;j_=1;function e(n){return this.__data__.has(n)}return af=e,af}var lf,R_;function GC(){if(R_)return lf;R_=1;var e=typeof Hl=="object"&&Hl&&Hl.Object===Object&&Hl;return lf=e,lf}var uf,A_;function rr(){if(A_)return uf;A_=1;var e=GC(),n=typeof self=="object"&&self&&self.Object===Object&&self,r=e||n||Function("return this")();return uf=r,uf}var cf,I_;function xo(){if(I_)return cf;I_=1;var e=rr(),n=e.Symbol;return cf=n,cf}var df,M_;function lq(){if(M_)return df;M_=1;var e=xo(),n=Object.prototype,r=n.hasOwnProperty,i=n.toString,o=e?e.toStringTag:void 0;function l(u){var c=r.call(u,o),h=u[o];try{u[o]=void 0;var p=!0}catch{}var d=i.call(u);return p&&(c?u[o]=h:delete u[o]),d}return df=l,df}var ff,O_;function uq(){if(O_)return ff;O_=1;var e=Object.prototype,n=e.toString;function r(i){return n.call(i)}return ff=r,ff}var hf,P_;function gi(){if(P_)return hf;P_=1;var e=xo(),n=lq(),r=uq(),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 hf=u,hf}var pf,L_;function qn(){if(L_)return pf;L_=1;function e(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}return pf=e,pf}var mf,$_;function Oa(){if($_)return mf;$_=1;var e=gi(),n=qn(),r="[object AsyncFunction]",i="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function u(c){if(!n(c))return!1;var h=e(c);return h==i||h==o||h==r||h==l}return mf=u,mf}var gf,q_;function cq(){if(q_)return gf;q_=1;var e=rr(),n=e["__core-js_shared__"];return gf=n,gf}var vf,D_;function dq(){if(D_)return vf;D_=1;var e=cq(),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 vf=r,vf}var yf,F_;function YC(){if(F_)return yf;F_=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 yf=r,yf}var wf,z_;function fq(){if(z_)return wf;z_=1;var e=Oa(),n=dq(),r=qn(),i=YC(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,h=u.toString,p=c.hasOwnProperty,d=RegExp("^"+h.call(p).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!r(y)||n(y))return!1;var w=e(y)?d:l;return w.test(i(y))}return wf=m,wf}var xf,B_;function hq(){if(B_)return xf;B_=1;function e(n,r){return n==null?void 0:n[r]}return xf=e,xf}var _f,U_;function vi(){if(U_)return _f;U_=1;var e=fq(),n=hq();function r(i,o){var l=n(i,o);return e(l)?l:void 0}return _f=r,_f}var bf,H_;function cy(){if(H_)return bf;H_=1;var e=vi(),n=rr(),r=e(n,"Map");return bf=r,bf}var Sf,W_;function Fu(){if(W_)return Sf;W_=1;var e=vi(),n=e(Object,"create");return Sf=n,Sf}var kf,V_;function pq(){if(V_)return kf;V_=1;var e=Fu();function n(){this.__data__=e?e(null):{},this.size=0}return kf=n,kf}var Ef,G_;function mq(){if(G_)return Ef;G_=1;function e(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}return Ef=e,Ef}var Nf,Y_;function gq(){if(Y_)return Nf;Y_=1;var e=Fu(),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 Nf=o,Nf}var Cf,K_;function vq(){if(K_)return Cf;K_=1;var e=Fu(),n=Object.prototype,r=n.hasOwnProperty;function i(o){var l=this.__data__;return e?l[o]!==void 0:r.call(l,o)}return Cf=i,Cf}var Tf,X_;function yq(){if(X_)return Tf;X_=1;var e=Fu(),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 Tf=r,Tf}var jf,Q_;function wq(){if(Q_)return jf;Q_=1;var e=pq(),n=mq(),r=gq(),i=vq(),o=yq();function l(u){var c=-1,h=u==null?0:u.length;for(this.clear();++c<h;){var p=u[c];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=i,l.prototype.set=o,jf=l,jf}var Rf,Z_;function xq(){if(Z_)return Rf;Z_=1;var e=wq(),n=Du(),r=cy();function i(){this.size=0,this.__data__={hash:new e,map:new(r||n),string:new e}}return Rf=i,Rf}var Af,J_;function _q(){if(J_)return Af;J_=1;function e(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}return Af=e,Af}var If,e1;function zu(){if(e1)return If;e1=1;var e=_q();function n(r,i){var o=r.__data__;return e(i)?o[typeof i=="string"?"string":"hash"]:o.map}return If=n,If}var Mf,t1;function bq(){if(t1)return Mf;t1=1;var e=zu();function n(r){var i=e(this,r).delete(r);return this.size-=i?1:0,i}return Mf=n,Mf}var Of,n1;function Sq(){if(n1)return Of;n1=1;var e=zu();function n(r){return e(this,r).get(r)}return Of=n,Of}var Pf,r1;function kq(){if(r1)return Pf;r1=1;var e=zu();function n(r){return e(this,r).has(r)}return Pf=n,Pf}var Lf,s1;function Eq(){if(s1)return Lf;s1=1;var e=zu();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 Lf=n,Lf}var $f,i1;function dy(){if(i1)return $f;i1=1;var e=xq(),n=bq(),r=Sq(),i=kq(),o=Eq();function l(u){var c=-1,h=u==null?0:u.length;for(this.clear();++c<h;){var p=u[c];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=i,l.prototype.set=o,$f=l,$f}var qf,o1;function Nq(){if(o1)return qf;o1=1;var e=Du(),n=cy(),r=dy(),i=200;function o(l,u){var c=this.__data__;if(c instanceof e){var h=c.__data__;if(!n||h.length<i-1)return h.push([l,u]),this.size=++c.size,this;c=this.__data__=new r(h)}return c.set(l,u),this.size=c.size,this}return qf=o,qf}var Df,a1;function Bu(){if(a1)return Df;a1=1;var e=Du(),n=sq(),r=iq(),i=oq(),o=aq(),l=Nq();function u(c){var h=this.__data__=new e(c);this.size=h.size}return u.prototype.clear=n,u.prototype.delete=r,u.prototype.get=i,u.prototype.has=o,u.prototype.set=l,Df=u,Df}var Ff,l1;function fy(){if(l1)return Ff;l1=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 Ff=e,Ff}var zf,u1;function KC(){if(u1)return zf;u1=1;var e=vi(),n=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return zf=n,zf}var Bf,c1;function Uu(){if(c1)return Bf;c1=1;var e=KC();function n(r,i,o){i=="__proto__"&&e?e(r,i,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[i]=o}return Bf=n,Bf}var Uf,d1;function Hu(){if(d1)return Uf;d1=1;var e=Uu(),n=wo(),r=Object.prototype,i=r.hasOwnProperty;function o(l,u,c){var h=l[u];(!(i.call(l,u)&&n(h,c))||c===void 0&&!(u in l))&&e(l,u,c)}return Uf=o,Uf}var Hf,f1;function Pa(){if(f1)return Hf;f1=1;var e=Hu(),n=Uu();function r(i,o,l,u){var c=!l;l||(l={});for(var h=-1,p=o.length;++h<p;){var d=o[h],m=u?u(l[d],i[d],d,l,i):void 0;m===void 0&&(m=i[d]),c?n(l,d,m):e(l,d,m)}return l}return Hf=r,Hf}var Wf,h1;function Cq(){if(h1)return Wf;h1=1;function e(n,r){for(var i=-1,o=Array(n);++i<n;)o[i]=r(i);return o}return Wf=e,Wf}var Vf,p1;function mr(){if(p1)return Vf;p1=1;function e(n){return n!=null&&typeof n=="object"}return Vf=e,Vf}var Gf,m1;function Tq(){if(m1)return Gf;m1=1;var e=gi(),n=mr(),r="[object Arguments]";function i(o){return n(o)&&e(o)==r}return Gf=i,Gf}var Yf,g1;function La(){if(g1)return Yf;g1=1;var e=Tq(),n=mr(),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 Yf=l,Yf}var Kf,v1;function _t(){if(v1)return Kf;v1=1;var e=Array.isArray;return Kf=e,Kf}var ha={exports:{}},Xf,y1;function jq(){if(y1)return Xf;y1=1;function e(){return!1}return Xf=e,Xf}ha.exports;var w1;function _o(){return w1||(w1=1,(function(e,n){var r=rr(),i=jq(),o=n&&!n.nodeType&&n,l=o&&!0&&e&&!e.nodeType&&e,u=l&&l.exports===o,c=u?r.Buffer:void 0,h=c?c.isBuffer:void 0,p=h||i;e.exports=p})(ha,ha.exports)),ha.exports}var Qf,x1;function Wu(){if(x1)return Qf;x1=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 Zf,_1;function hy(){if(_1)return Zf;_1=1;var e=9007199254740991;function n(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return Zf=n,Zf}var Jf,b1;function Rq(){if(b1)return Jf;b1=1;var e=gi(),n=hy(),r=mr(),i="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",h="[object Function]",p="[object Map]",d="[object Number]",m="[object Object]",y="[object RegExp]",w="[object Set]",E="[object String]",_="[object WeakMap]",b="[object ArrayBuffer]",S="[object DataView]",k="[object Float32Array]",N="[object Float64Array]",T="[object Int8Array]",A="[object Int16Array]",M="[object Int32Array]",O="[object Uint8Array]",P="[object Uint8ClampedArray]",D="[object Uint16Array]",L="[object Uint32Array]",U={};U[k]=U[N]=U[T]=U[A]=U[M]=U[O]=U[P]=U[D]=U[L]=!0,U[i]=U[o]=U[b]=U[l]=U[S]=U[u]=U[c]=U[h]=U[p]=U[d]=U[m]=U[y]=U[w]=U[E]=U[_]=!1;function V(z){return r(z)&&n(z.length)&&!!U[e(z)]}return Jf=V,Jf}var eh,S1;function Vu(){if(S1)return eh;S1=1;function e(n){return function(r){return n(r)}}return eh=e,eh}var pa={exports:{}};pa.exports;var k1;function py(){return k1||(k1=1,(function(e,n){var r=GC(),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 h=o&&o.require&&o.require("util").types;return h||u&&u.binding&&u.binding("util")}catch{}})();e.exports=c})(pa,pa.exports)),pa.exports}var th,E1;function $a(){if(E1)return th;E1=1;var e=Rq(),n=Vu(),r=py(),i=r&&r.isTypedArray,o=i?n(i):e;return th=o,th}var nh,N1;function XC(){if(N1)return nh;N1=1;var e=Cq(),n=La(),r=_t(),i=_o(),o=Wu(),l=$a(),u=Object.prototype,c=u.hasOwnProperty;function h(p,d){var m=r(p),y=!m&&n(p),w=!m&&!y&&i(p),E=!m&&!y&&!w&&l(p),_=m||y||w||E,b=_?e(p.length,String):[],S=b.length;for(var k in p)(d||c.call(p,k))&&!(_&&(k=="length"||w&&(k=="offset"||k=="parent")||E&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||o(k,S)))&&b.push(k);return b}return nh=h,nh}var rh,C1;function Gu(){if(C1)return rh;C1=1;var e=Object.prototype;function n(r){var i=r&&r.constructor,o=typeof i=="function"&&i.prototype||e;return r===o}return rh=n,rh}var sh,T1;function QC(){if(T1)return sh;T1=1;function e(n,r){return function(i){return n(r(i))}}return sh=e,sh}var ih,j1;function Aq(){if(j1)return ih;j1=1;var e=QC(),n=e(Object.keys,Object);return ih=n,ih}var oh,R1;function my(){if(R1)return oh;R1=1;var e=Gu(),n=Aq(),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 oh=o,oh}var ah,A1;function Br(){if(A1)return ah;A1=1;var e=Oa(),n=hy();function r(i){return i!=null&&n(i.length)&&!e(i)}return ah=r,ah}var lh,I1;function As(){if(I1)return lh;I1=1;var e=XC(),n=my(),r=Br();function i(o){return r(o)?e(o):n(o)}return lh=i,lh}var uh,M1;function Iq(){if(M1)return uh;M1=1;var e=Pa(),n=As();function r(i,o){return i&&e(o,n(o),i)}return uh=r,uh}var ch,O1;function Mq(){if(O1)return ch;O1=1;function e(n){var r=[];if(n!=null)for(var i in Object(n))r.push(i);return r}return ch=e,ch}var dh,P1;function Oq(){if(P1)return dh;P1=1;var e=qn(),n=Gu(),r=Mq(),i=Object.prototype,o=i.hasOwnProperty;function l(u){if(!e(u))return r(u);var c=n(u),h=[];for(var p in u)p=="constructor"&&(c||!o.call(u,p))||h.push(p);return h}return dh=l,dh}var fh,L1;function yi(){if(L1)return fh;L1=1;var e=XC(),n=Oq(),r=Br();function i(o){return r(o)?e(o,!0):n(o)}return fh=i,fh}var hh,$1;function Pq(){if($1)return hh;$1=1;var e=Pa(),n=yi();function r(i,o){return i&&e(o,n(o),i)}return hh=r,hh}var ma={exports:{}};ma.exports;var q1;function ZC(){return q1||(q1=1,(function(e,n){var r=rr(),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 h(p,d){if(d)return p.slice();var m=p.length,y=c?c(m):new p.constructor(m);return p.copy(y),y}e.exports=h})(ma,ma.exports)),ma.exports}var ph,D1;function JC(){if(D1)return ph;D1=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 ph=e,ph}var mh,F1;function eT(){if(F1)return mh;F1=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 mh=e,mh}var gh,z1;function tT(){if(z1)return gh;z1=1;function e(){return[]}return gh=e,gh}var vh,B1;function gy(){if(B1)return vh;B1=1;var e=eT(),n=tT(),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 vh=l,vh}var yh,U1;function Lq(){if(U1)return yh;U1=1;var e=Pa(),n=gy();function r(i,o){return e(i,n(i),o)}return yh=r,yh}var wh,H1;function vy(){if(H1)return wh;H1=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 wh=e,wh}var xh,W1;function Yu(){if(W1)return xh;W1=1;var e=QC(),n=e(Object.getPrototypeOf,Object);return xh=n,xh}var _h,V1;function nT(){if(V1)return _h;V1=1;var e=vy(),n=Yu(),r=gy(),i=tT(),o=Object.getOwnPropertySymbols,l=o?function(u){for(var c=[];u;)e(c,r(u)),u=n(u);return c}:i;return _h=l,_h}var bh,G1;function $q(){if(G1)return bh;G1=1;var e=Pa(),n=nT();function r(i,o){return e(i,n(i),o)}return bh=r,bh}var Sh,Y1;function rT(){if(Y1)return Sh;Y1=1;var e=vy(),n=_t();function r(i,o,l){var u=o(i);return n(i)?u:e(u,l(i))}return Sh=r,Sh}var kh,K1;function sT(){if(K1)return kh;K1=1;var e=rT(),n=gy(),r=As();function i(o){return e(o,r,n)}return kh=i,kh}var Eh,X1;function qq(){if(X1)return Eh;X1=1;var e=rT(),n=nT(),r=yi();function i(o){return e(o,r,n)}return Eh=i,Eh}var Nh,Q1;function Dq(){if(Q1)return Nh;Q1=1;var e=vi(),n=rr(),r=e(n,"DataView");return Nh=r,Nh}var Ch,Z1;function Fq(){if(Z1)return Ch;Z1=1;var e=vi(),n=rr(),r=e(n,"Promise");return Ch=r,Ch}var Th,J1;function iT(){if(J1)return Th;J1=1;var e=vi(),n=rr(),r=e(n,"Set");return Th=r,Th}var jh,eb;function zq(){if(eb)return jh;eb=1;var e=vi(),n=rr(),r=e(n,"WeakMap");return jh=r,jh}var Rh,tb;function bo(){if(tb)return Rh;tb=1;var e=Dq(),n=cy(),r=Fq(),i=iT(),o=zq(),l=gi(),u=YC(),c="[object Map]",h="[object Object]",p="[object Promise]",d="[object Set]",m="[object WeakMap]",y="[object DataView]",w=u(e),E=u(n),_=u(r),b=u(i),S=u(o),k=l;return(e&&k(new e(new ArrayBuffer(1)))!=y||n&&k(new n)!=c||r&&k(r.resolve())!=p||i&&k(new i)!=d||o&&k(new o)!=m)&&(k=function(N){var T=l(N),A=T==h?N.constructor:void 0,M=A?u(A):"";if(M)switch(M){case w:return y;case E:return c;case _:return p;case b:return d;case S:return m}return T}),Rh=k,Rh}var Ah,nb;function Bq(){if(nb)return Ah;nb=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 Ah=r,Ah}var Ih,rb;function oT(){if(rb)return Ih;rb=1;var e=rr(),n=e.Uint8Array;return Ih=n,Ih}var Mh,sb;function yy(){if(sb)return Mh;sb=1;var e=oT();function n(r){var i=new r.constructor(r.byteLength);return new e(i).set(new e(r)),i}return Mh=n,Mh}var Oh,ib;function Uq(){if(ib)return Oh;ib=1;var e=yy();function n(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return Oh=n,Oh}var Ph,ob;function Hq(){if(ob)return Ph;ob=1;var e=/\w*$/;function n(r){var i=new r.constructor(r.source,e.exec(r));return i.lastIndex=r.lastIndex,i}return Ph=n,Ph}var Lh,ab;function Wq(){if(ab)return Lh;ab=1;var e=xo(),n=e?e.prototype:void 0,r=n?n.valueOf:void 0;function i(o){return r?Object(r.call(o)):{}}return Lh=i,Lh}var $h,lb;function aT(){if(lb)return $h;lb=1;var e=yy();function n(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return $h=n,$h}var qh,ub;function Vq(){if(ub)return qh;ub=1;var e=yy(),n=Uq(),r=Hq(),i=Wq(),o=aT(),l="[object Boolean]",u="[object Date]",c="[object Map]",h="[object Number]",p="[object RegExp]",d="[object Set]",m="[object String]",y="[object Symbol]",w="[object ArrayBuffer]",E="[object DataView]",_="[object Float32Array]",b="[object Float64Array]",S="[object Int8Array]",k="[object Int16Array]",N="[object Int32Array]",T="[object Uint8Array]",A="[object Uint8ClampedArray]",M="[object Uint16Array]",O="[object Uint32Array]";function P(D,L,U){var V=D.constructor;switch(L){case w:return e(D);case l:case u:return new V(+D);case E:return n(D,U);case _:case b:case S:case k:case N:case T:case A:case M:case O:return o(D,U);case c:return new V;case h:case m:return new V(D);case p:return r(D);case d:return new V;case y:return i(D)}}return qh=P,qh}var Dh,cb;function lT(){if(cb)return Dh;cb=1;var e=qn(),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 Dh=r,Dh}var Fh,db;function uT(){if(db)return Fh;db=1;var e=lT(),n=Yu(),r=Gu();function i(o){return typeof o.constructor=="function"&&!r(o)?e(n(o)):{}}return Fh=i,Fh}var zh,fb;function Gq(){if(fb)return zh;fb=1;var e=bo(),n=mr(),r="[object Map]";function i(o){return n(o)&&e(o)==r}return zh=i,zh}var Bh,hb;function Yq(){if(hb)return Bh;hb=1;var e=Gq(),n=Vu(),r=py(),i=r&&r.isMap,o=i?n(i):e;return Bh=o,Bh}var Uh,pb;function Kq(){if(pb)return Uh;pb=1;var e=bo(),n=mr(),r="[object Set]";function i(o){return n(o)&&e(o)==r}return Uh=i,Uh}var Hh,mb;function Xq(){if(mb)return Hh;mb=1;var e=Kq(),n=Vu(),r=py(),i=r&&r.isSet,o=i?n(i):e;return Hh=o,Hh}var Wh,gb;function cT(){if(gb)return Wh;gb=1;var e=Bu(),n=fy(),r=Hu(),i=Iq(),o=Pq(),l=ZC(),u=JC(),c=Lq(),h=$q(),p=sT(),d=qq(),m=bo(),y=Bq(),w=Vq(),E=uT(),_=_t(),b=_o(),S=Yq(),k=qn(),N=Xq(),T=As(),A=yi(),M=1,O=2,P=4,D="[object Arguments]",L="[object Array]",U="[object Boolean]",V="[object Date]",z="[object Error]",C="[object Function]",F="[object GeneratorFunction]",$="[object Map]",re="[object Number]",J="[object Object]",W="[object RegExp]",Z="[object Set]",I="[object String]",G="[object Symbol]",K="[object WeakMap]",q="[object ArrayBuffer]",Q="[object DataView]",ne="[object Float32Array]",ae="[object Float64Array]",fe="[object Int8Array]",te="[object Int16Array]",ce="[object Int32Array]",Ce="[object Uint8Array]",ve="[object Uint8ClampedArray]",Re="[object Uint16Array]",ye="[object Uint32Array]",Ee={};Ee[D]=Ee[L]=Ee[q]=Ee[Q]=Ee[U]=Ee[V]=Ee[ne]=Ee[ae]=Ee[fe]=Ee[te]=Ee[ce]=Ee[$]=Ee[re]=Ee[J]=Ee[W]=Ee[Z]=Ee[I]=Ee[G]=Ee[Ce]=Ee[ve]=Ee[Re]=Ee[ye]=!0,Ee[z]=Ee[C]=Ee[K]=!1;function Ye(we,_e,Be,it,ft,Ze){var De,Je=_e&M,Xe=_e&O,Ot=_e&P;if(Be&&(De=ft?Be(we,it,ft,Ze):Be(we)),De!==void 0)return De;if(!k(we))return we;var lt=_(we);if(lt){if(De=y(we),!Je)return u(we,De)}else{var Qe=m(we),Pt=Qe==C||Qe==F;if(b(we))return l(we,Je);if(Qe==J||Qe==D||Pt&&!ft){if(De=Xe||Pt?{}:E(we),!Je)return Xe?h(we,o(De,we)):c(we,i(De,we))}else{if(!Ee[Qe])return ft?we:{};De=w(we,Qe,Je)}}Ze||(Ze=new e);var zt=Ze.get(we);if(zt)return zt;Ze.set(we,De),N(we)?we.forEach(function(ht){De.add(Ye(ht,_e,Be,ht,we,Ze))}):S(we)&&we.forEach(function(ht,vt){De.set(vt,Ye(ht,_e,Be,vt,we,Ze))});var et=Ot?Xe?d:p:Xe?A:T,bt=lt?void 0:et(we);return n(bt||we,function(ht,vt){bt&&(vt=ht,ht=we[vt]),r(De,vt,Ye(ht,_e,Be,vt,we,Ze))}),De}return Wh=Ye,Wh}var Vh,vb;function Qq(){if(vb)return Vh;vb=1;var e=cT(),n=4;function r(i){return e(i,n)}return Vh=r,Vh}var Gh,yb;function wy(){if(yb)return Gh;yb=1;function e(n){return function(){return n}}return Gh=e,Gh}var Yh,wb;function Zq(){if(wb)return Yh;wb=1;function e(n){return function(r,i,o){for(var l=-1,u=Object(r),c=o(r),h=c.length;h--;){var p=c[n?h:++l];if(i(u[p],p,u)===!1)break}return r}}return Yh=e,Yh}var Kh,xb;function xy(){if(xb)return Kh;xb=1;var e=Zq(),n=e();return Kh=n,Kh}var Xh,_b;function _y(){if(_b)return Xh;_b=1;var e=xy(),n=As();function r(i,o){return i&&e(i,o,n)}return Xh=r,Xh}var Qh,bb;function Jq(){if(bb)return Qh;bb=1;var e=Br();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,h=Object(o);(i?c--:++c<u)&&l(h[c],c,h)!==!1;);return o}}return Qh=n,Qh}var Zh,Sb;function Ku(){if(Sb)return Zh;Sb=1;var e=_y(),n=Jq(),r=n(e);return Zh=r,Zh}var Jh,kb;function wi(){if(kb)return Jh;kb=1;function e(n){return n}return Jh=e,Jh}var ep,Eb;function dT(){if(Eb)return ep;Eb=1;var e=wi();function n(r){return typeof r=="function"?r:e}return ep=n,ep}var tp,Nb;function fT(){if(Nb)return tp;Nb=1;var e=fy(),n=Ku(),r=dT(),i=_t();function o(l,u){var c=i(l)?e:n;return c(l,r(u))}return tp=o,tp}var np,Cb;function hT(){return Cb||(Cb=1,np=fT()),np}var rp,Tb;function eD(){if(Tb)return rp;Tb=1;var e=Ku();function n(r,i){var o=[];return e(r,function(l,u,c){i(l,u,c)&&o.push(l)}),o}return rp=n,rp}var sp,jb;function tD(){if(jb)return sp;jb=1;var e="__lodash_hash_undefined__";function n(r){return this.__data__.set(r,e),this}return sp=n,sp}var ip,Rb;function nD(){if(Rb)return ip;Rb=1;function e(n){return this.__data__.has(n)}return ip=e,ip}var op,Ab;function pT(){if(Ab)return op;Ab=1;var e=dy(),n=tD(),r=nD();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,op=i,op}var ap,Ib;function rD(){if(Ib)return ap;Ib=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 ap=e,ap}var lp,Mb;function mT(){if(Mb)return lp;Mb=1;function e(n,r){return n.has(r)}return lp=e,lp}var up,Ob;function gT(){if(Ob)return up;Ob=1;var e=pT(),n=rD(),r=mT(),i=1,o=2;function l(u,c,h,p,d,m){var y=h&i,w=u.length,E=c.length;if(w!=E&&!(y&&E>w))return!1;var _=m.get(u),b=m.get(c);if(_&&b)return _==c&&b==u;var S=-1,k=!0,N=h&o?new e:void 0;for(m.set(u,c),m.set(c,u);++S<w;){var T=u[S],A=c[S];if(p)var M=y?p(A,T,S,c,u,m):p(T,A,S,u,c,m);if(M!==void 0){if(M)continue;k=!1;break}if(N){if(!n(c,function(O,P){if(!r(N,P)&&(T===O||d(T,O,h,p,m)))return N.push(P)})){k=!1;break}}else if(!(T===A||d(T,A,h,p,m))){k=!1;break}}return m.delete(u),m.delete(c),k}return up=l,up}var cp,Pb;function sD(){if(Pb)return cp;Pb=1;function e(n){var r=-1,i=Array(n.size);return n.forEach(function(o,l){i[++r]=[l,o]}),i}return cp=e,cp}var dp,Lb;function by(){if(Lb)return dp;Lb=1;function e(n){var r=-1,i=Array(n.size);return n.forEach(function(o){i[++r]=o}),i}return dp=e,dp}var fp,$b;function iD(){if($b)return fp;$b=1;var e=xo(),n=oT(),r=wo(),i=gT(),o=sD(),l=by(),u=1,c=2,h="[object Boolean]",p="[object Date]",d="[object Error]",m="[object Map]",y="[object Number]",w="[object RegExp]",E="[object Set]",_="[object String]",b="[object Symbol]",S="[object ArrayBuffer]",k="[object DataView]",N=e?e.prototype:void 0,T=N?N.valueOf:void 0;function A(M,O,P,D,L,U,V){switch(P){case k:if(M.byteLength!=O.byteLength||M.byteOffset!=O.byteOffset)return!1;M=M.buffer,O=O.buffer;case S:return!(M.byteLength!=O.byteLength||!U(new n(M),new n(O)));case h:case p:case y:return r(+M,+O);case d:return M.name==O.name&&M.message==O.message;case w:case _:return M==O+"";case m:var z=o;case E:var C=D&u;if(z||(z=l),M.size!=O.size&&!C)return!1;var F=V.get(M);if(F)return F==O;D|=c,V.set(M,O);var $=i(z(M),z(O),D,L,U,V);return V.delete(M),$;case b:if(T)return T.call(M)==T.call(O)}return!1}return fp=A,fp}var hp,qb;function oD(){if(qb)return hp;qb=1;var e=sT(),n=1,r=Object.prototype,i=r.hasOwnProperty;function o(l,u,c,h,p,d){var m=c&n,y=e(l),w=y.length,E=e(u),_=E.length;if(w!=_&&!m)return!1;for(var b=w;b--;){var S=y[b];if(!(m?S in u:i.call(u,S)))return!1}var k=d.get(l),N=d.get(u);if(k&&N)return k==u&&N==l;var T=!0;d.set(l,u),d.set(u,l);for(var A=m;++b<w;){S=y[b];var M=l[S],O=u[S];if(h)var P=m?h(O,M,S,u,l,d):h(M,O,S,l,u,d);if(!(P===void 0?M===O||p(M,O,c,h,d):P)){T=!1;break}A||(A=S=="constructor")}if(T&&!A){var D=l.constructor,L=u.constructor;D!=L&&"constructor"in l&&"constructor"in u&&!(typeof D=="function"&&D instanceof D&&typeof L=="function"&&L instanceof L)&&(T=!1)}return d.delete(l),d.delete(u),T}return hp=o,hp}var pp,Db;function aD(){if(Db)return pp;Db=1;var e=Bu(),n=gT(),r=iD(),i=oD(),o=bo(),l=_t(),u=_o(),c=$a(),h=1,p="[object Arguments]",d="[object Array]",m="[object Object]",y=Object.prototype,w=y.hasOwnProperty;function E(_,b,S,k,N,T){var A=l(_),M=l(b),O=A?d:o(_),P=M?d:o(b);O=O==p?m:O,P=P==p?m:P;var D=O==m,L=P==m,U=O==P;if(U&&u(_)){if(!u(b))return!1;A=!0,D=!1}if(U&&!D)return T||(T=new e),A||c(_)?n(_,b,S,k,N,T):r(_,b,O,S,k,N,T);if(!(S&h)){var V=D&&w.call(_,"__wrapped__"),z=L&&w.call(b,"__wrapped__");if(V||z){var C=V?_.value():_,F=z?b.value():b;return T||(T=new e),N(C,F,S,k,T)}}return U?(T||(T=new e),i(_,b,S,k,N,T)):!1}return pp=E,pp}var mp,Fb;function vT(){if(Fb)return mp;Fb=1;var e=aD(),n=mr();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 mp=r,mp}var gp,zb;function lD(){if(zb)return gp;zb=1;var e=Bu(),n=vT(),r=1,i=2;function o(l,u,c,h){var p=c.length,d=p,m=!h;if(l==null)return!d;for(l=Object(l);p--;){var y=c[p];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++p<d;){y=c[p];var w=y[0],E=l[w],_=y[1];if(m&&y[2]){if(E===void 0&&!(w in l))return!1}else{var b=new e;if(h)var S=h(E,_,w,l,u,b);if(!(S===void 0?n(_,E,r|i,h,b):S))return!1}}return!0}return gp=o,gp}var vp,Bb;function yT(){if(Bb)return vp;Bb=1;var e=qn();function n(r){return r===r&&!e(r)}return vp=n,vp}var yp,Ub;function uD(){if(Ub)return yp;Ub=1;var e=yT(),n=As();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 yp=r,yp}var wp,Hb;function wT(){if(Hb)return wp;Hb=1;function e(n,r){return function(i){return i==null?!1:i[n]===r&&(r!==void 0||n in Object(i))}}return wp=e,wp}var xp,Wb;function cD(){if(Wb)return xp;Wb=1;var e=lD(),n=uD(),r=wT();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 xp=i,xp}var _p,Vb;function So(){if(Vb)return _p;Vb=1;var e=gi(),n=mr(),r="[object Symbol]";function i(o){return typeof o=="symbol"||n(o)&&e(o)==r}return _p=i,_p}var bp,Gb;function Sy(){if(Gb)return bp;Gb=1;var e=_t(),n=So(),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 bp=o,bp}var Sp,Yb;function dD(){if(Yb)return Sp;Yb=1;var e=dy(),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],h=l.cache;if(h.has(c))return h.get(c);var p=i.apply(this,u);return l.cache=h.set(c,p)||h,p};return l.cache=new(r.Cache||e),l}return r.Cache=e,Sp=r,Sp}var kp,Kb;function fD(){if(Kb)return kp;Kb=1;var e=dD(),n=500;function r(i){var o=e(i,function(u){return l.size===n&&l.clear(),u}),l=o.cache;return o}return kp=r,kp}var Ep,Xb;function hD(){if(Xb)return Ep;Xb=1;var e=fD(),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,h,p){l.push(h?p.replace(r,"$1"):c||u)}),l});return Ep=i,Ep}var Np,Qb;function Xu(){if(Qb)return Np;Qb=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 Np=e,Np}var Cp,Zb;function pD(){if(Zb)return Cp;Zb=1;var e=xo(),n=Xu(),r=_t(),i=So(),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 h=c+"";return h=="0"&&1/c==-1/0?"-0":h}return Cp=u,Cp}var Tp,Jb;function xT(){if(Jb)return Tp;Jb=1;var e=pD();function n(r){return r==null?"":e(r)}return Tp=n,Tp}var jp,eS;function Qu(){if(eS)return jp;eS=1;var e=_t(),n=Sy(),r=hD(),i=xT();function o(l,u){return e(l)?l:n(l,u)?[l]:r(i(l))}return jp=o,jp}var Rp,tS;function qa(){if(tS)return Rp;tS=1;var e=So();function n(r){if(typeof r=="string"||e(r))return r;var i=r+"";return i=="0"&&1/r==-1/0?"-0":i}return Rp=n,Rp}var Ap,nS;function Zu(){if(nS)return Ap;nS=1;var e=Qu(),n=qa();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 Ap=r,Ap}var Ip,rS;function mD(){if(rS)return Ip;rS=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 Ip=n,Ip}var Mp,sS;function gD(){if(sS)return Mp;sS=1;function e(n,r){return n!=null&&r in Object(n)}return Mp=e,Mp}var Op,iS;function _T(){if(iS)return Op;iS=1;var e=Qu(),n=La(),r=_t(),i=Wu(),o=hy(),l=qa();function u(c,h,p){h=e(h,c);for(var d=-1,m=h.length,y=!1;++d<m;){var w=l(h[d]);if(!(y=c!=null&&p(c,w)))break;c=c[w]}return y||++d!=m?y:(m=c==null?0:c.length,!!m&&o(m)&&i(w,m)&&(r(c)||n(c)))}return Op=u,Op}var Pp,oS;function bT(){if(oS)return Pp;oS=1;var e=gD(),n=_T();function r(i,o){return i!=null&&n(i,o,e)}return Pp=r,Pp}var Lp,aS;function vD(){if(aS)return Lp;aS=1;var e=vT(),n=mD(),r=bT(),i=Sy(),o=yT(),l=wT(),u=qa(),c=1,h=2;function p(d,m){return i(d)&&o(m)?l(u(d),m):function(y){var w=n(y,d);return w===void 0&&w===m?r(y,d):e(m,w,c|h)}}return Lp=p,Lp}var $p,lS;function ST(){if(lS)return $p;lS=1;function e(n){return function(r){return r==null?void 0:r[n]}}return $p=e,$p}var qp,uS;function yD(){if(uS)return qp;uS=1;var e=Zu();function n(r){return function(i){return e(i,r)}}return qp=n,qp}var Dp,cS;function wD(){if(cS)return Dp;cS=1;var e=ST(),n=yD(),r=Sy(),i=qa();function o(l){return r(l)?e(i(l)):n(l)}return Dp=o,Dp}var Fp,dS;function Ur(){if(dS)return Fp;dS=1;var e=cD(),n=vD(),r=wi(),i=_t(),o=wD();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 Fp=l,Fp}var zp,fS;function kT(){if(fS)return zp;fS=1;var e=eT(),n=eD(),r=Ur(),i=_t();function o(l,u){var c=i(l)?e:n;return c(l,r(u,3))}return zp=o,zp}var Bp,hS;function xD(){if(hS)return Bp;hS=1;var e=Object.prototype,n=e.hasOwnProperty;function r(i,o){return i!=null&&n.call(i,o)}return Bp=r,Bp}var Up,pS;function ET(){if(pS)return Up;pS=1;var e=xD(),n=_T();function r(i,o){return i!=null&&n(i,o,e)}return Up=r,Up}var Hp,mS;function _D(){if(mS)return Hp;mS=1;var e=my(),n=bo(),r=La(),i=_t(),o=Br(),l=_o(),u=Gu(),c=$a(),h="[object Map]",p="[object Set]",d=Object.prototype,m=d.hasOwnProperty;function y(w){if(w==null)return!0;if(o(w)&&(i(w)||typeof w=="string"||typeof w.splice=="function"||l(w)||c(w)||r(w)))return!w.length;var E=n(w);if(E==h||E==p)return!w.size;if(u(w))return!e(w).length;for(var _ in w)if(m.call(w,_))return!1;return!0}return Hp=y,Hp}var Wp,gS;function NT(){if(gS)return Wp;gS=1;function e(n){return n===void 0}return Wp=e,Wp}var Vp,vS;function CT(){if(vS)return Vp;vS=1;var e=Ku(),n=Br();function r(i,o){var l=-1,u=n(i)?Array(i.length):[];return e(i,function(c,h,p){u[++l]=o(c,h,p)}),u}return Vp=r,Vp}var Gp,yS;function TT(){if(yS)return Gp;yS=1;var e=Xu(),n=Ur(),r=CT(),i=_t();function o(l,u){var c=i(l)?e:r;return c(l,n(u,3))}return Gp=o,Gp}var Yp,wS;function bD(){if(wS)return Yp;wS=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 Yp=e,Yp}var Kp,xS;function SD(){if(xS)return Kp;xS=1;function e(n,r,i,o,l){return l(n,function(u,c,h){i=o?(o=!1,u):r(i,u,c,h)}),i}return Kp=e,Kp}var Xp,_S;function jT(){if(_S)return Xp;_S=1;var e=bD(),n=Ku(),r=Ur(),i=SD(),o=_t();function l(u,c,h){var p=o(u)?e:i,d=arguments.length<3;return p(u,r(c,4),h,d,n)}return Xp=l,Xp}var Qp,bS;function kD(){if(bS)return Qp;bS=1;var e=gi(),n=_t(),r=mr(),i="[object String]";function o(l){return typeof l=="string"||!n(l)&&r(l)&&e(l)==i}return Qp=o,Qp}var Zp,SS;function ED(){if(SS)return Zp;SS=1;var e=ST(),n=e("length");return Zp=n,Zp}var Jp,kS;function ND(){if(kS)return Jp;kS=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 h(p){return c.test(p)}return Jp=h,Jp}var em,ES;function CD(){if(ES)return em;ES=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+"]",h="\\ud83c[\\udffb-\\udfff]",p="(?:"+c+"|"+h+")",d="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",E=p+"?",_="["+l+"]?",b="(?:"+w+"(?:"+[d,m,y].join("|")+")"+_+E+")*",S=_+E+b,k="(?:"+[d+c+"?",c,m,y,u].join("|")+")",N=RegExp(h+"(?="+h+")|"+k+S,"g");function T(A){for(var M=N.lastIndex=0;N.test(A);)++M;return M}return em=T,em}var tm,NS;function TD(){if(NS)return tm;NS=1;var e=ED(),n=ND(),r=CD();function i(o){return n(o)?r(o):e(o)}return tm=i,tm}var nm,CS;function jD(){if(CS)return nm;CS=1;var e=my(),n=bo(),r=Br(),i=kD(),o=TD(),l="[object Map]",u="[object Set]";function c(h){if(h==null)return 0;if(r(h))return i(h)?o(h):h.length;var p=n(h);return p==l||p==u?h.size:e(h).length}return nm=c,nm}var rm,TS;function RD(){if(TS)return rm;TS=1;var e=fy(),n=lT(),r=_y(),i=Ur(),o=Yu(),l=_t(),u=_o(),c=Oa(),h=qn(),p=$a();function d(m,y,w){var E=l(m),_=E||u(m)||p(m);if(y=i(y,4),w==null){var b=m&&m.constructor;_?w=E?new b:[]:h(m)?w=c(b)?n(o(m)):{}:w={}}return(_?e:r)(m,function(S,k,N){return y(w,S,k,N)}),w}return rm=d,rm}var sm,jS;function AD(){if(jS)return sm;jS=1;var e=xo(),n=La(),r=_t(),i=e?e.isConcatSpreadable:void 0;function o(l){return r(l)||n(l)||!!(i&&l&&l[i])}return sm=o,sm}var im,RS;function ky(){if(RS)return im;RS=1;var e=vy(),n=AD();function r(i,o,l,u,c){var h=-1,p=i.length;for(l||(l=n),c||(c=[]);++h<p;){var d=i[h];o>0&&l(d)?o>1?r(d,o-1,l,u,c):e(c,d):u||(c[c.length]=d)}return c}return im=r,im}var om,AS;function ID(){if(AS)return om;AS=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 om=e,om}var am,IS;function RT(){if(IS)return am;IS=1;var e=ID(),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,h=n(u.length-o,0),p=Array(h);++c<h;)p[c]=u[o+c];c=-1;for(var d=Array(o+1);++c<o;)d[c]=u[c];return d[o]=l(p),e(i,this,d)}}return am=r,am}var lm,MS;function MD(){if(MS)return lm;MS=1;var e=wy(),n=KC(),r=wi(),i=n?function(o,l){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:r;return lm=i,lm}var um,OS;function OD(){if(OS)return um;OS=1;var e=800,n=16,r=Date.now;function i(o){var l=0,u=0;return function(){var c=r(),h=n-(c-u);if(u=c,h>0){if(++l>=e)return arguments[0]}else l=0;return o.apply(void 0,arguments)}}return um=i,um}var cm,PS;function AT(){if(PS)return cm;PS=1;var e=MD(),n=OD(),r=n(e);return cm=r,cm}var dm,LS;function Ju(){if(LS)return dm;LS=1;var e=wi(),n=RT(),r=AT();function i(o,l){return r(n(o,l,e),o+"")}return dm=i,dm}var fm,$S;function IT(){if($S)return fm;$S=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 fm=e,fm}var hm,qS;function PD(){if(qS)return hm;qS=1;function e(n){return n!==n}return hm=e,hm}var pm,DS;function LD(){if(DS)return pm;DS=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 pm=e,pm}var mm,FS;function $D(){if(FS)return mm;FS=1;var e=IT(),n=PD(),r=LD();function i(o,l,u){return l===l?r(o,l,u):e(o,n,u)}return mm=i,mm}var gm,zS;function qD(){if(zS)return gm;zS=1;var e=$D();function n(r,i){var o=r==null?0:r.length;return!!o&&e(r,i,0)>-1}return gm=n,gm}var vm,BS;function DD(){if(BS)return vm;BS=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 vm=e,vm}var ym,US;function FD(){if(US)return ym;US=1;function e(){}return ym=e,ym}var wm,HS;function zD(){if(HS)return wm;HS=1;var e=iT(),n=FD(),r=by(),i=1/0,o=e&&1/r(new e([,-0]))[1]==i?function(l){return new e(l)}:n;return wm=o,wm}var xm,WS;function BD(){if(WS)return xm;WS=1;var e=pT(),n=qD(),r=DD(),i=mT(),o=zD(),l=by(),u=200;function c(h,p,d){var m=-1,y=n,w=h.length,E=!0,_=[],b=_;if(d)E=!1,y=r;else if(w>=u){var S=p?null:o(h);if(S)return l(S);E=!1,y=i,b=new e}else b=p?[]:_;e:for(;++m<w;){var k=h[m],N=p?p(k):k;if(k=d||k!==0?k:0,E&&N===N){for(var T=b.length;T--;)if(b[T]===N)continue e;p&&b.push(N),_.push(k)}else y(b,N,d)||(b!==_&&b.push(N),_.push(k))}return _}return xm=c,xm}var _m,VS;function MT(){if(VS)return _m;VS=1;var e=Br(),n=mr();function r(i){return n(i)&&e(i)}return _m=r,_m}var bm,GS;function UD(){if(GS)return bm;GS=1;var e=ky(),n=Ju(),r=BD(),i=MT(),o=n(function(l){return r(e(l,1,i,!0))});return bm=o,bm}var Sm,YS;function HD(){if(YS)return Sm;YS=1;var e=Xu();function n(r,i){return e(i,function(o){return r[o]})}return Sm=n,Sm}var km,KS;function OT(){if(KS)return km;KS=1;var e=HD(),n=As();function r(i){return i==null?[]:e(i,n(i))}return km=r,km}var Em,XS;function Dn(){if(XS)return Em;XS=1;var e;if(typeof uy=="function")try{e={clone:Qq(),constant:wy(),each:hT(),filter:kT(),has:ET(),isArray:_t(),isEmpty:_D(),isFunction:Oa(),isUndefined:NT(),keys:As(),map:TT(),reduce:jT(),size:jD(),transform:RD(),union:UD(),values:OT()}}catch{}return e||(e=window._),Em=e,Em}var Nm,QS;function Ey(){if(QS)return Nm;QS=1;var e=Dn();Nm=o;var n="\0",r="\0",i="";function o(d){this._isDirected=e.has(d,"directed")?d.directed:!0,this._isMultigraph=e.has(d,"multigraph")?d.multigraph:!1,this._isCompound=e.has(d,"compound")?d.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(d){return this._label=d,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(m){return e.isEmpty(d._in[m])})},o.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(m){return e.isEmpty(d._out[m])})},o.prototype.setNodes=function(d,m){var y=arguments,w=this;return e.each(d,function(E){y.length>1?w.setNode(E,m):w.setNode(E)}),this},o.prototype.setNode=function(d,m){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=m),this):(this._nodes[d]=arguments.length>1?m:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=r,this._children[d]={},this._children[r][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},o.prototype.node=function(d){return this._nodes[d]},o.prototype.hasNode=function(d){return e.has(this._nodes,d)},o.prototype.removeNode=function(d){var m=this;if(e.has(this._nodes,d)){var y=function(w){m.removeEdge(m._edgeObjs[w])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(w){m.setParent(w)}),delete this._children[d]),e.each(e.keys(this._in[d]),y),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),y),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},o.prototype.setParent=function(d,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=r;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===d)throw new Error("Setting "+m+" as parent of "+d+" would create a cycle");this.setNode(m)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=m,this._children[m][d]=!0,this},o.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},o.prototype.parent=function(d){if(this._isCompound){var m=this._parent[d];if(m!==r)return m}},o.prototype.children=function(d){if(e.isUndefined(d)&&(d=r),this._isCompound){var m=this._children[d];if(m)return e.keys(m)}else{if(d===r)return this.nodes();if(this.hasNode(d))return[]}},o.prototype.predecessors=function(d){var m=this._preds[d];if(m)return e.keys(m)},o.prototype.successors=function(d){var m=this._sucs[d];if(m)return e.keys(m)},o.prototype.neighbors=function(d){var m=this.predecessors(d);if(m)return e.union(m,this.successors(d))},o.prototype.isLeaf=function(d){var m;return this.isDirected()?m=this.successors(d):m=this.neighbors(d),m.length===0},o.prototype.filterNodes=function(d){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,b){d(b)&&m.setNode(b,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var w={};function E(_){var b=y.parent(_);return b===void 0||m.hasNode(b)?(w[_]=b,b):b in w?w[b]:E(b)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,E(_))}),m},o.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(d,m){var y=this,w=arguments;return e.reduce(d,function(E,_){return w.length>1?y.setEdge(E,_,m):y.setEdge(E,_),_}),this},o.prototype.setEdge=function(){var d,m,y,w,E=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(d=_.v,m=_.w,y=_.name,arguments.length===2&&(w=arguments[1],E=!0)):(d=_,m=arguments[1],y=arguments[3],arguments.length>2&&(w=arguments[2],E=!0)),d=""+d,m=""+m,e.isUndefined(y)||(y=""+y);var b=c(this._isDirected,d,m,y);if(e.has(this._edgeLabels,b))return E&&(this._edgeLabels[b]=w),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(m),this._edgeLabels[b]=E?w:this._defaultEdgeLabelFn(d,m,y);var S=h(this._isDirected,d,m,y);return d=S.v,m=S.w,Object.freeze(S),this._edgeObjs[b]=S,l(this._preds[m],d),l(this._sucs[d],m),this._in[m][b]=S,this._out[d][b]=S,this._edgeCount++,this},o.prototype.edge=function(d,m,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,d,m,y);return this._edgeLabels[w]},o.prototype.hasEdge=function(d,m,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,d,m,y);return e.has(this._edgeLabels,w)},o.prototype.removeEdge=function(d,m,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,d,m,y),E=this._edgeObjs[w];return E&&(d=E.v,m=E.w,delete this._edgeLabels[w],delete this._edgeObjs[w],u(this._preds[m],d),u(this._sucs[d],m),delete this._in[m][w],delete this._out[d][w],this._edgeCount--),this},o.prototype.inEdges=function(d,m){var y=this._in[d];if(y){var w=e.values(y);return m?e.filter(w,function(E){return E.v===m}):w}},o.prototype.outEdges=function(d,m){var y=this._out[d];if(y){var w=e.values(y);return m?e.filter(w,function(E){return E.w===m}):w}},o.prototype.nodeEdges=function(d,m){var y=this.inEdges(d,m);if(y)return y.concat(this.outEdges(d,m))};function l(d,m){d[m]?d[m]++:d[m]=1}function u(d,m){--d[m]||delete d[m]}function c(d,m,y,w){var E=""+m,_=""+y;if(!d&&E>_){var b=E;E=_,_=b}return E+i+_+i+(e.isUndefined(w)?n:w)}function h(d,m,y,w){var E=""+m,_=""+y;if(!d&&E>_){var b=E;E=_,_=b}var S={v:E,w:_};return w&&(S.name=w),S}function p(d,m){return c(d,m.v,m.w,m.name)}return Nm}var Cm,ZS;function WD(){return ZS||(ZS=1,Cm="2.1.8"),Cm}var Tm,JS;function VD(){return JS||(JS=1,Tm={Graph:Ey(),version:WD()}),Tm}var jm,ek;function GD(){if(ek)return jm;ek=1;var e=Dn(),n=Ey();jm={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 h=u.node(c),p=u.parent(c),d={v:c};return e.isUndefined(h)||(d.value=h),e.isUndefined(p)||(d.parent=p),d})}function o(u){return e.map(u.edges(),function(c){var h=u.edge(c),p={v:c.v,w:c.w};return e.isUndefined(c.name)||(p.name=c.name),e.isUndefined(h)||(p.value=h),p})}function l(u){var c=new n(u.options).setGraph(u.value);return e.each(u.nodes,function(h){c.setNode(h.v,h.value),h.parent&&c.setParent(h.v,h.parent)}),e.each(u.edges,function(h){c.setEdge({v:h.v,w:h.w,name:h.name},h.value)}),c}return jm}var Rm,tk;function YD(){if(tk)return Rm;tk=1;var e=Dn();Rm=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 Rm}var Am,nk;function PT(){if(nk)return Am;nk=1;var e=Dn();Am=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},Am}var Im,rk;function LT(){if(rk)return Im;rk=1;var e=Dn(),n=PT();Im=i;var r=e.constant(1);function i(l,u,c,h){return o(l,String(u),c||r,h||function(p){return l.outEdges(p)})}function o(l,u,c,h){var p={},d=new n,m,y,w=function(E){var _=E.v!==m?E.v:E.w,b=p[_],S=c(E),k=y.distance+S;if(S<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+E+" Weight: "+S);k<b.distance&&(b.distance=k,b.predecessor=m,d.decrease(_,k))};for(l.nodes().forEach(function(E){var _=E===u?0:Number.POSITIVE_INFINITY;p[E]={distance:_},d.add(E,_)});d.size()>0&&(m=d.removeMin(),y=p[m],y.distance!==Number.POSITIVE_INFINITY);)h(m).forEach(w);return p}return Im}var Mm,sk;function KD(){if(sk)return Mm;sk=1;var e=LT(),n=Dn();Mm=r;function r(i,o,l){return n.transform(i.nodes(),function(u,c){u[c]=e(i,c,o,l)},{})}return Mm}var Om,ik;function $T(){if(ik)return Om;ik=1;var e=Dn();Om=n;function n(r){var i=0,o=[],l={},u=[];function c(h){var p=l[h]={onStack:!0,lowlink:i,index:i++};if(o.push(h),r.successors(h).forEach(function(y){e.has(l,y)?l[y].onStack&&(p.lowlink=Math.min(p.lowlink,l[y].index)):(c(y),p.lowlink=Math.min(p.lowlink,l[y].lowlink))}),p.lowlink===p.index){var d=[],m;do m=o.pop(),l[m].onStack=!1,d.push(m);while(h!==m);u.push(d)}}return r.nodes().forEach(function(h){e.has(l,h)||c(h)}),u}return Om}var Pm,ok;function XD(){if(ok)return Pm;ok=1;var e=Dn(),n=$T();Pm=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 Pm}var Lm,ak;function QD(){if(ak)return Lm;ak=1;var e=Dn();Lm=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={},h=o.nodes();return h.forEach(function(p){c[p]={},c[p][p]={distance:0},h.forEach(function(d){p!==d&&(c[p][d]={distance:Number.POSITIVE_INFINITY})}),u(p).forEach(function(d){var m=d.v===p?d.w:d.v,y=l(d);c[p][m]={distance:y,predecessor:p}})}),h.forEach(function(p){var d=c[p];h.forEach(function(m){var y=c[m];h.forEach(function(w){var E=y[p],_=d[w],b=y[w],S=E.distance+_.distance;S<b.distance&&(b.distance=S,b.predecessor=_.predecessor)})})}),c}return Lm}var $m,lk;function qT(){if(lk)return $m;lk=1;var e=Dn();$m=n,n.CycleException=r;function n(i){var o={},l={},u=[];function c(h){if(e.has(l,h))throw new r;e.has(o,h)||(l[h]=!0,o[h]=!0,e.each(i.predecessors(h),c),delete l[h],u.push(h))}if(e.each(i.sinks(),c),e.size(o)!==i.nodeCount())throw new r;return u}function r(){}return r.prototype=new Error,$m}var qm,uk;function ZD(){if(uk)return qm;uk=1;var e=qT();qm=n;function n(r){try{e(r)}catch(i){if(i instanceof e.CycleException)return!1;throw i}return!0}return qm}var Dm,ck;function DT(){if(ck)return Dm;ck=1;var e=Dn();Dm=n;function n(i,o,l){e.isArray(o)||(o=[o]);var u=(i.isDirected()?i.successors:i.neighbors).bind(i),c=[],h={};return e.each(o,function(p){if(!i.hasNode(p))throw new Error("Graph does not have node: "+p);r(i,p,l==="post",h,u,c)}),c}function r(i,o,l,u,c,h){e.has(u,o)||(u[o]=!0,l||h.push(o),e.each(c(o),function(p){r(i,p,l,u,c,h)}),l&&h.push(o))}return Dm}var Fm,dk;function JD(){if(dk)return Fm;dk=1;var e=DT();Fm=n;function n(r,i){return e(r,i,"post")}return Fm}var zm,fk;function e4(){if(fk)return zm;fk=1;var e=DT();zm=n;function n(r,i){return e(r,i,"pre")}return zm}var Bm,hk;function t4(){if(hk)return Bm;hk=1;var e=Dn(),n=Ey(),r=PT();Bm=i;function i(o,l){var u=new n,c={},h=new r,p;function d(y){var w=y.v===p?y.w:y.v,E=h.priority(w);if(E!==void 0){var _=l(y);_<E&&(c[w]=p,h.decrease(w,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){h.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),h.decrease(o.nodes()[0],0);for(var m=!1;h.size()>0;){if(p=h.removeMin(),e.has(c,p))u.setEdge(p,c[p]);else{if(m)throw new Error("Input graph is not connected: "+o);m=!0}o.nodeEdges(p).forEach(d)}return u}return Bm}var Um,pk;function n4(){return pk||(pk=1,Um={components:YD(),dijkstra:LT(),dijkstraAll:KD(),findCycles:XD(),floydWarshall:QD(),isAcyclic:ZD(),postorder:JD(),preorder:e4(),prim:t4(),tarjan:$T(),topsort:qT()}),Um}var Hm,mk;function r4(){if(mk)return Hm;mk=1;var e=VD();return Hm={Graph:e.Graph,json:GD(),alg:n4(),version:e.version},Hm}var Wm,gk;function tr(){if(gk)return Wm;gk=1;var e;if(typeof uy=="function")try{e=r4()}catch{}return e||(e=window.graphlib),Wm=e,Wm}var Vm,vk;function s4(){if(vk)return Vm;vk=1;var e=cT(),n=1,r=4;function i(o){return e(o,n|r)}return Vm=i,Vm}var Gm,yk;function ec(){if(yk)return Gm;yk=1;var e=wo(),n=Br(),r=Wu(),i=qn();function o(l,u,c){if(!i(c))return!1;var h=typeof u;return(h=="number"?n(c)&&r(u,c.length):h=="string"&&u in c)?e(c[u],l):!1}return Gm=o,Gm}var Ym,wk;function i4(){if(wk)return Ym;wk=1;var e=Ju(),n=wo(),r=ec(),i=yi(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,h){c=Object(c);var p=-1,d=h.length,m=d>2?h[2]:void 0;for(m&&r(h[0],h[1],m)&&(d=1);++p<d;)for(var y=h[p],w=i(y),E=-1,_=w.length;++E<_;){var b=w[E],S=c[b];(S===void 0||n(S,o[b])&&!l.call(c,b))&&(c[b]=y[b])}return c});return Ym=u,Ym}var Km,xk;function o4(){if(xk)return Km;xk=1;var e=Ur(),n=Br(),r=As();function i(o){return function(l,u,c){var h=Object(l);if(!n(l)){var p=e(u,3);l=r(l),u=function(m){return p(h[m],m,h)}}var d=o(l,u,c);return d>-1?h[p?l[d]:d]:void 0}}return Km=i,Km}var Xm,_k;function a4(){if(_k)return Xm;_k=1;var e=/\s/;function n(r){for(var i=r.length;i--&&e.test(r.charAt(i)););return i}return Xm=n,Xm}var Qm,bk;function l4(){if(bk)return Qm;bk=1;var e=a4(),n=/^\s+/;function r(i){return i&&i.slice(0,e(i)+1).replace(n,"")}return Qm=r,Qm}var Zm,Sk;function u4(){if(Sk)return Zm;Sk=1;var e=l4(),n=qn(),r=So(),i=NaN,o=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function h(p){if(typeof p=="number")return p;if(r(p))return i;if(n(p)){var d=typeof p.valueOf=="function"?p.valueOf():p;p=n(d)?d+"":d}if(typeof p!="string")return p===0?p:+p;p=e(p);var m=l.test(p);return m||u.test(p)?c(p.slice(2),m?2:8):o.test(p)?i:+p}return Zm=h,Zm}var Jm,kk;function FT(){if(kk)return Jm;kk=1;var e=u4(),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 Jm=i,Jm}var eg,Ek;function c4(){if(Ek)return eg;Ek=1;var e=FT();function n(r){var i=e(r),o=i%1;return i===i?o?i-o:i:0}return eg=n,eg}var tg,Nk;function d4(){if(Nk)return tg;Nk=1;var e=IT(),n=Ur(),r=c4(),i=Math.max;function o(l,u,c){var h=l==null?0:l.length;if(!h)return-1;var p=c==null?0:r(c);return p<0&&(p=i(h+p,0)),e(l,n(u,3),p)}return tg=o,tg}var ng,Ck;function f4(){if(Ck)return ng;Ck=1;var e=o4(),n=d4(),r=e(n);return ng=r,ng}var rg,Tk;function zT(){if(Tk)return rg;Tk=1;var e=ky();function n(r){var i=r==null?0:r.length;return i?e(r,1):[]}return rg=n,rg}var sg,jk;function h4(){if(jk)return sg;jk=1;var e=xy(),n=dT(),r=yi();function i(o,l){return o==null?o:e(o,n(l),r)}return sg=i,sg}var ig,Rk;function p4(){if(Rk)return ig;Rk=1;function e(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}return ig=e,ig}var og,Ak;function m4(){if(Ak)return og;Ak=1;var e=Uu(),n=_y(),r=Ur();function i(o,l){var u={};return l=r(l,3),n(o,function(c,h,p){e(u,h,l(c,h,p))}),u}return og=i,og}var ag,Ik;function Ny(){if(Ik)return ag;Ik=1;var e=So();function n(r,i,o){for(var l=-1,u=r.length;++l<u;){var c=r[l],h=i(c);if(h!=null&&(p===void 0?h===h&&!e(h):o(h,p)))var p=h,d=c}return d}return ag=n,ag}var lg,Mk;function g4(){if(Mk)return lg;Mk=1;function e(n,r){return n>r}return lg=e,lg}var ug,Ok;function v4(){if(Ok)return ug;Ok=1;var e=Ny(),n=g4(),r=wi();function i(o){return o&&o.length?e(o,r,n):void 0}return ug=i,ug}var cg,Pk;function BT(){if(Pk)return cg;Pk=1;var e=Uu(),n=wo();function r(i,o,l){(l!==void 0&&!n(i[o],l)||l===void 0&&!(o in i))&&e(i,o,l)}return cg=r,cg}var dg,Lk;function y4(){if(Lk)return dg;Lk=1;var e=gi(),n=Yu(),r=mr(),i="[object Object]",o=Function.prototype,l=Object.prototype,u=o.toString,c=l.hasOwnProperty,h=u.call(Object);function p(d){if(!r(d)||e(d)!=i)return!1;var m=n(d);if(m===null)return!0;var y=c.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==h}return dg=p,dg}var fg,$k;function UT(){if($k)return fg;$k=1;function e(n,r){if(!(r==="constructor"&&typeof n[r]=="function")&&r!="__proto__")return n[r]}return fg=e,fg}var hg,qk;function w4(){if(qk)return hg;qk=1;var e=Pa(),n=yi();function r(i){return e(i,n(i))}return hg=r,hg}var pg,Dk;function x4(){if(Dk)return pg;Dk=1;var e=BT(),n=ZC(),r=aT(),i=JC(),o=uT(),l=La(),u=_t(),c=MT(),h=_o(),p=Oa(),d=qn(),m=y4(),y=$a(),w=UT(),E=w4();function _(b,S,k,N,T,A,M){var O=w(b,k),P=w(S,k),D=M.get(P);if(D){e(b,k,D);return}var L=A?A(O,P,k+"",b,S,M):void 0,U=L===void 0;if(U){var V=u(P),z=!V&&h(P),C=!V&&!z&&y(P);L=P,V||z||C?u(O)?L=O:c(O)?L=i(O):z?(U=!1,L=n(P,!0)):C?(U=!1,L=r(P,!0)):L=[]:m(P)||l(P)?(L=O,l(O)?L=E(O):(!d(O)||p(O))&&(L=o(P))):U=!1}U&&(M.set(P,L),T(L,P,N,A,M),M.delete(P)),e(b,k,L)}return pg=_,pg}var mg,Fk;function _4(){if(Fk)return mg;Fk=1;var e=Bu(),n=BT(),r=xy(),i=x4(),o=qn(),l=yi(),u=UT();function c(h,p,d,m,y){h!==p&&r(p,function(w,E){if(y||(y=new e),o(w))i(h,p,E,d,c,m,y);else{var _=m?m(u(h,E),w,E+"",h,p,y):void 0;_===void 0&&(_=w),n(h,E,_)}},l)}return mg=c,mg}var gg,zk;function b4(){if(zk)return gg;zk=1;var e=Ju(),n=ec();function r(i){return e(function(o,l){var u=-1,c=l.length,h=c>1?l[c-1]:void 0,p=c>2?l[2]:void 0;for(h=i.length>3&&typeof h=="function"?(c--,h):void 0,p&&n(l[0],l[1],p)&&(h=c<3?void 0:h,c=1),o=Object(o);++u<c;){var d=l[u];d&&i(o,d,u,h)}return o})}return gg=r,gg}var vg,Bk;function S4(){if(Bk)return vg;Bk=1;var e=_4(),n=b4(),r=n(function(i,o,l){e(i,o,l)});return vg=r,vg}var yg,Uk;function HT(){if(Uk)return yg;Uk=1;function e(n,r){return n<r}return yg=e,yg}var wg,Hk;function k4(){if(Hk)return wg;Hk=1;var e=Ny(),n=HT(),r=wi();function i(o){return o&&o.length?e(o,r,n):void 0}return wg=i,wg}var xg,Wk;function E4(){if(Wk)return xg;Wk=1;var e=Ny(),n=Ur(),r=HT();function i(o,l){return o&&o.length?e(o,n(l,2),r):void 0}return xg=i,xg}var _g,Vk;function N4(){if(Vk)return _g;Vk=1;var e=rr(),n=function(){return e.Date.now()};return _g=n,_g}var bg,Gk;function C4(){if(Gk)return bg;Gk=1;var e=Hu(),n=Qu(),r=Wu(),i=qn(),o=qa();function l(u,c,h,p){if(!i(u))return u;c=n(c,u);for(var d=-1,m=c.length,y=m-1,w=u;w!=null&&++d<m;){var E=o(c[d]),_=h;if(E==="__proto__"||E==="constructor"||E==="prototype")return u;if(d!=y){var b=w[E];_=p?p(b,E,w):void 0,_===void 0&&(_=i(b)?b:r(c[d+1])?[]:{})}e(w,E,_),w=w[E]}return u}return bg=l,bg}var Sg,Yk;function T4(){if(Yk)return Sg;Yk=1;var e=Zu(),n=C4(),r=Qu();function i(o,l,u){for(var c=-1,h=l.length,p={};++c<h;){var d=l[c],m=e(o,d);u(m,d)&&n(p,r(d,o),m)}return p}return Sg=i,Sg}var kg,Kk;function j4(){if(Kk)return kg;Kk=1;var e=T4(),n=bT();function r(i,o){return e(i,o,function(l,u){return n(i,u)})}return kg=r,kg}var Eg,Xk;function R4(){if(Xk)return Eg;Xk=1;var e=zT(),n=RT(),r=AT();function i(o){return r(n(o,void 0,e),o+"")}return Eg=i,Eg}var Ng,Qk;function A4(){if(Qk)return Ng;Qk=1;var e=j4(),n=R4(),r=n(function(i,o){return i==null?{}:e(i,o)});return Ng=r,Ng}var Cg,Zk;function I4(){if(Zk)return Cg;Zk=1;var e=Math.ceil,n=Math.max;function r(i,o,l,u){for(var c=-1,h=n(e((o-i)/(l||1)),0),p=Array(h);h--;)p[u?h:++c]=i,i+=l;return p}return Cg=r,Cg}var Tg,Jk;function M4(){if(Jk)return Tg;Jk=1;var e=I4(),n=ec(),r=FT();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 Tg=i,Tg}var jg,eE;function O4(){if(eE)return jg;eE=1;var e=M4(),n=e();return jg=n,jg}var Rg,tE;function P4(){if(tE)return Rg;tE=1;function e(n,r){var i=n.length;for(n.sort(r);i--;)n[i]=n[i].value;return n}return Rg=e,Rg}var Ag,nE;function L4(){if(nE)return Ag;nE=1;var e=So();function n(r,i){if(r!==i){var o=r!==void 0,l=r===null,u=r===r,c=e(r),h=i!==void 0,p=i===null,d=i===i,m=e(i);if(!p&&!m&&!c&&r>i||c&&h&&d&&!p&&!m||l&&h&&d||!o&&d||!u)return 1;if(!l&&!c&&!m&&r<i||m&&o&&u&&!l&&!c||p&&o&&u||!h&&u||!d)return-1}return 0}return Ag=n,Ag}var Ig,rE;function $4(){if(rE)return Ig;rE=1;var e=L4();function n(r,i,o){for(var l=-1,u=r.criteria,c=i.criteria,h=u.length,p=o.length;++l<h;){var d=e(u[l],c[l]);if(d){if(l>=p)return d;var m=o[l];return d*(m=="desc"?-1:1)}}return r.index-i.index}return Ig=n,Ig}var Mg,sE;function q4(){if(sE)return Mg;sE=1;var e=Xu(),n=Zu(),r=Ur(),i=CT(),o=P4(),l=Vu(),u=$4(),c=wi(),h=_t();function p(d,m,y){m.length?m=e(m,function(_){return h(_)?function(b){return n(b,_.length===1?_[0]:_)}:_}):m=[c];var w=-1;m=e(m,l(r));var E=i(d,function(_,b,S){var k=e(m,function(N){return N(_)});return{criteria:k,index:++w,value:_}});return o(E,function(_,b){return u(_,b,y)})}return Mg=p,Mg}var Og,iE;function D4(){if(iE)return Og;iE=1;var e=ky(),n=q4(),r=Ju(),i=ec(),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 Og=o,Og}var Pg,oE;function F4(){if(oE)return Pg;oE=1;var e=xT(),n=0;function r(i){var o=++n;return e(i)+o}return Pg=r,Pg}var Lg,aE;function z4(){if(aE)return Lg;aE=1;function e(n,r,i){for(var o=-1,l=n.length,u=r.length,c={};++o<l;){var h=o<u?r[o]:void 0;i(c,n[o],h)}return c}return Lg=e,Lg}var $g,lE;function B4(){if(lE)return $g;lE=1;var e=Hu(),n=z4();function r(i,o){return n(i||[],o||[],e)}return $g=r,$g}var qg,uE;function at(){if(uE)return qg;uE=1;var e;if(typeof uy=="function")try{e={cloneDeep:s4(),constant:wy(),defaults:i4(),each:hT(),filter:kT(),find:f4(),flatten:zT(),forEach:fT(),forIn:h4(),has:ET(),isUndefined:NT(),last:p4(),map:TT(),mapValues:m4(),max:v4(),merge:S4(),min:k4(),minBy:E4(),now:N4(),pick:A4(),range:O4(),reduce:jT(),sortBy:D4(),uniqueId:F4(),values:OT(),zipObject:B4()}}catch{}return e||(e=window._),qg=e,qg}var Dg,cE;function U4(){if(cE)return Dg;cE=1,Dg=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 Dg}var Fg,dE;function H4(){if(dE)return Fg;dE=1;var e=at(),n=tr().Graph,r=U4();Fg=o;var i=e.constant(1);function o(p,d){if(p.nodeCount()<=1)return[];var m=c(p,d||i),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(w){return p.outEdges(w.v,w.w)}),!0)}function l(p,d,m){for(var y=[],w=d[d.length-1],E=d[0],_;p.nodeCount();){for(;_=E.dequeue();)u(p,d,m,_);for(;_=w.dequeue();)u(p,d,m,_);if(p.nodeCount()){for(var b=d.length-2;b>0;--b)if(_=d[b].dequeue(),_){y=y.concat(u(p,d,m,_,!0));break}}}return y}function u(p,d,m,y,w){var E=w?[]:void 0;return e.forEach(p.inEdges(y.v),function(_){var b=p.edge(_),S=p.node(_.v);w&&E.push({v:_.v,w:_.w}),S.out-=b,h(d,m,S)}),e.forEach(p.outEdges(y.v),function(_){var b=p.edge(_),S=_.w,k=p.node(S);k.in-=b,h(d,m,k)}),p.removeNode(y.v),E}function c(p,d){var m=new n,y=0,w=0;e.forEach(p.nodes(),function(b){m.setNode(b,{v:b,in:0,out:0})}),e.forEach(p.edges(),function(b){var S=m.edge(b.v,b.w)||0,k=d(b),N=S+k;m.setEdge(b.v,b.w,N),w=Math.max(w,m.node(b.v).out+=k),y=Math.max(y,m.node(b.w).in+=k)});var E=e.range(w+y+3).map(function(){return new r}),_=y+1;return e.forEach(m.nodes(),function(b){h(E,_,m.node(b))}),{graph:m,buckets:E,zeroIdx:_}}function h(p,d,m){m.out?m.in?p[m.out-m.in+d].enqueue(m):p[p.length-1].enqueue(m):p[0].enqueue(m)}return Fg}var zg,fE;function W4(){if(fE)return zg;fE=1;var e=at(),n=H4();zg={run:r,undo:o};function r(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):i(l);e.forEach(u,function(h){var p=l.edge(h);l.removeEdge(h),p.forwardName=h.name,p.reversed=!0,l.setEdge(h.w,h.v,p,e.uniqueId("rev"))});function c(h){return function(p){return h.edge(p).weight}}}function i(l){var u=[],c={},h={};function p(d){e.has(h,d)||(h[d]=!0,c[d]=!0,e.forEach(l.outEdges(d),function(m){e.has(c,m.w)?u.push(m):p(m.w)}),delete c[d])}return e.forEach(l.nodes(),p),u}function o(l){e.forEach(l.edges(),function(u){var c=l.edge(u);if(c.reversed){l.removeEdge(u);var h=c.forwardName;delete c.reversed,delete c.forwardName,l.setEdge(u.w,u.v,c,h)}})}return zg}var Bg,hE;function fn(){if(hE)return Bg;hE=1;var e=at(),n=tr().Graph;Bg={addDummyNode:r,simplify:i,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:h,normalizeRanks:p,removeEmptyRanks:d,addBorderNode:m,maxRank:y,partition:w,time:E,notime:_};function r(b,S,k,N){var T;do T=e.uniqueId(N);while(b.hasNode(T));return k.dummy=S,b.setNode(T,k),T}function i(b){var S=new n().setGraph(b.graph());return e.forEach(b.nodes(),function(k){S.setNode(k,b.node(k))}),e.forEach(b.edges(),function(k){var N=S.edge(k.v,k.w)||{weight:0,minlen:1},T=b.edge(k);S.setEdge(k.v,k.w,{weight:N.weight+T.weight,minlen:Math.max(N.minlen,T.minlen)})}),S}function o(b){var S=new n({multigraph:b.isMultigraph()}).setGraph(b.graph());return e.forEach(b.nodes(),function(k){b.children(k).length||S.setNode(k,b.node(k))}),e.forEach(b.edges(),function(k){S.setEdge(k,b.edge(k))}),S}function l(b){var S=e.map(b.nodes(),function(k){var N={};return e.forEach(b.outEdges(k),function(T){N[T.w]=(N[T.w]||0)+b.edge(T).weight}),N});return e.zipObject(b.nodes(),S)}function u(b){var S=e.map(b.nodes(),function(k){var N={};return e.forEach(b.inEdges(k),function(T){N[T.v]=(N[T.v]||0)+b.edge(T).weight}),N});return e.zipObject(b.nodes(),S)}function c(b,S){var k=b.x,N=b.y,T=S.x-k,A=S.y-N,M=b.width/2,O=b.height/2;if(!T&&!A)throw new Error("Not possible to find intersection inside of the rectangle");var P,D;return Math.abs(A)*M>Math.abs(T)*O?(A<0&&(O=-O),P=O*T/A,D=O):(T<0&&(M=-M),P=M,D=M*A/T),{x:k+P,y:N+D}}function h(b){var S=e.map(e.range(y(b)+1),function(){return[]});return e.forEach(b.nodes(),function(k){var N=b.node(k),T=N.rank;e.isUndefined(T)||(S[T][N.order]=k)}),S}function p(b){var S=e.min(e.map(b.nodes(),function(k){return b.node(k).rank}));e.forEach(b.nodes(),function(k){var N=b.node(k);e.has(N,"rank")&&(N.rank-=S)})}function d(b){var S=e.min(e.map(b.nodes(),function(A){return b.node(A).rank})),k=[];e.forEach(b.nodes(),function(A){var M=b.node(A).rank-S;k[M]||(k[M]=[]),k[M].push(A)});var N=0,T=b.graph().nodeRankFactor;e.forEach(k,function(A,M){e.isUndefined(A)&&M%T!==0?--N:N&&e.forEach(A,function(O){b.node(O).rank+=N})})}function m(b,S,k,N){var T={width:0,height:0};return arguments.length>=4&&(T.rank=k,T.order=N),r(b,"border",T,S)}function y(b){return e.max(e.map(b.nodes(),function(S){var k=b.node(S).rank;if(!e.isUndefined(k))return k}))}function w(b,S){var k={lhs:[],rhs:[]};return e.forEach(b,function(N){S(N)?k.lhs.push(N):k.rhs.push(N)}),k}function E(b,S){var k=e.now();try{return S()}finally{console.log(b+" time: "+(e.now()-k)+"ms")}}function _(b,S){return S()}return Bg}var Ug,pE;function V4(){if(pE)return Ug;pE=1;var e=at(),n=fn();Ug={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,h=l.node(c).rank,p=u.w,d=l.node(p).rank,m=u.name,y=l.edge(u),w=y.labelRank;if(d!==h+1){l.removeEdge(u);var E,_,b;for(b=0,++h;h<d;++b,++h)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:u,rank:h},E=n.addDummyNode(l,"edge",_,"_d"),h===w&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(c,E,{weight:y.weight},m),b===0&&l.graph().dummyChains.push(E),c=E;l.setEdge(c,p,{weight:y.weight},m)}}function o(l){e.forEach(l.graph().dummyChains,function(u){var c=l.node(u),h=c.edgeLabel,p;for(l.setEdge(c.edgeObj,h);c.dummy;)p=l.successors(u)[0],l.removeNode(u),h.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(h.x=c.x,h.y=c.y,h.width=c.width,h.height=c.height),u=p,c=l.node(u)})}return Ug}var Hg,mE;function Tu(){if(mE)return Hg;mE=1;var e=at();Hg={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 h=e.min(e.map(i.outEdges(u),function(p){return l(p.w)-i.edge(p).minlen}));return(h===Number.POSITIVE_INFINITY||h===void 0||h===null)&&(h=0),c.rank=h}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 Hg}var Wg,gE;function WT(){if(gE)return Wg;gE=1;var e=at(),n=tr().Graph,r=Tu().slack;Wg=i;function i(c){var h=new n({directed:!1}),p=c.nodes()[0],d=c.nodeCount();h.setNode(p,{});for(var m,y;o(h,c)<d;)m=l(h,c),y=h.hasNode(m.v)?r(c,m):-r(c,m),u(h,c,y);return h}function o(c,h){function p(d){e.forEach(h.nodeEdges(d),function(m){var y=m.v,w=d===y?m.w:y;!c.hasNode(w)&&!r(h,m)&&(c.setNode(w,{}),c.setEdge(d,w,{}),p(w))})}return e.forEach(c.nodes(),p),c.nodeCount()}function l(c,h){return e.minBy(h.edges(),function(p){if(c.hasNode(p.v)!==c.hasNode(p.w))return r(h,p)})}function u(c,h,p){e.forEach(c.nodes(),function(d){h.node(d).rank+=p})}return Wg}var Vg,vE;function G4(){if(vE)return Vg;vE=1;var e=at(),n=WT(),r=Tu().slack,i=Tu().longestPath,o=tr().alg.preorder,l=tr().alg.postorder,u=fn().simplify;Vg=c,c.initLowLimValues=m,c.initCutValues=h,c.calcCutValue=d,c.leaveEdge=w,c.enterEdge=E,c.exchangeEdges=_;function c(N){N=u(N),i(N);var T=n(N);m(T),h(T,N);for(var A,M;A=w(T);)M=E(T,N,A),_(T,N,A,M)}function h(N,T){var A=l(N,N.nodes());A=A.slice(0,A.length-1),e.forEach(A,function(M){p(N,T,M)})}function p(N,T,A){var M=N.node(A),O=M.parent;N.edge(A,O).cutvalue=d(N,T,A)}function d(N,T,A){var M=N.node(A),O=M.parent,P=!0,D=T.edge(A,O),L=0;return D||(P=!1,D=T.edge(O,A)),L=D.weight,e.forEach(T.nodeEdges(A),function(U){var V=U.v===A,z=V?U.w:U.v;if(z!==O){var C=V===P,F=T.edge(U).weight;if(L+=C?F:-F,S(N,A,z)){var $=N.edge(A,z).cutvalue;L+=C?-$:$}}}),L}function m(N,T){arguments.length<2&&(T=N.nodes()[0]),y(N,{},1,T)}function y(N,T,A,M,O){var P=A,D=N.node(M);return T[M]=!0,e.forEach(N.neighbors(M),function(L){e.has(T,L)||(A=y(N,T,A,L,M))}),D.low=P,D.lim=A++,O?D.parent=O:delete D.parent,A}function w(N){return e.find(N.edges(),function(T){return N.edge(T).cutvalue<0})}function E(N,T,A){var M=A.v,O=A.w;T.hasEdge(M,O)||(M=A.w,O=A.v);var P=N.node(M),D=N.node(O),L=P,U=!1;P.lim>D.lim&&(L=D,U=!0);var V=e.filter(T.edges(),function(z){return U===k(N,N.node(z.v),L)&&U!==k(N,N.node(z.w),L)});return e.minBy(V,function(z){return r(T,z)})}function _(N,T,A,M){var O=A.v,P=A.w;N.removeEdge(O,P),N.setEdge(M.v,M.w,{}),m(N),h(N,T),b(N,T)}function b(N,T){var A=e.find(N.nodes(),function(O){return!T.node(O).parent}),M=o(N,A);M=M.slice(1),e.forEach(M,function(O){var P=N.node(O).parent,D=T.edge(O,P),L=!1;D||(D=T.edge(P,O),L=!0),T.node(O).rank=T.node(P).rank+(L?D.minlen:-D.minlen)})}function S(N,T,A){return N.hasEdge(T,A)}function k(N,T,A){return A.low<=T.lim&&T.lim<=A.lim}return Vg}var Gg,yE;function Y4(){if(yE)return Gg;yE=1;var e=Tu(),n=e.longestPath,r=WT(),i=G4();Gg=o;function o(h){switch(h.graph().ranker){case"network-simplex":c(h);break;case"tight-tree":u(h);break;case"longest-path":l(h);break;default:c(h)}}var l=n;function u(h){n(h),r(h)}function c(h){i(h)}return Gg}var Yg,wE;function K4(){if(wE)return Yg;wE=1;var e=at();Yg=n;function n(o){var l=i(o);e.forEach(o.graph().dummyChains,function(u){for(var c=o.node(u),h=c.edgeObj,p=r(o,l,h.v,h.w),d=p.path,m=p.lca,y=0,w=d[y],E=!0;u!==h.w;){if(c=o.node(u),E){for(;(w=d[y])!==m&&o.node(w).maxRank<c.rank;)y++;w===m&&(E=!1)}if(!E){for(;y<d.length-1&&o.node(w=d[y+1]).minRank<=c.rank;)y++;w=d[y]}o.setParent(u,w),u=o.successors(u)[0]}})}function r(o,l,u,c){var h=[],p=[],d=Math.min(l[u].low,l[c].low),m=Math.max(l[u].lim,l[c].lim),y,w;y=u;do y=o.parent(y),h.push(y);while(y&&(l[y].low>d||m>l[y].lim));for(w=y,y=c;(y=o.parent(y))!==w;)p.push(y);return{path:h.concat(p.reverse()),lca:w}}function i(o){var l={},u=0;function c(h){var p=u;e.forEach(o.children(h),c),l[h]={low:p,lim:u++}}return e.forEach(o.children(),c),l}return Yg}var Kg,xE;function X4(){if(xE)return Kg;xE=1;var e=at(),n=fn();Kg={run:r,cleanup:u};function r(c){var h=n.addDummyNode(c,"root",{},"_root"),p=o(c),d=e.max(e.values(p))-1,m=2*d+1;c.graph().nestingRoot=h,e.forEach(c.edges(),function(w){c.edge(w).minlen*=m});var y=l(c)+1;e.forEach(c.children(),function(w){i(c,h,m,y,d,p,w)}),c.graph().nodeRankFactor=m}function i(c,h,p,d,m,y,w){var E=c.children(w);if(!E.length){w!==h&&c.setEdge(h,w,{weight:0,minlen:p});return}var _=n.addBorderNode(c,"_bt"),b=n.addBorderNode(c,"_bb"),S=c.node(w);c.setParent(_,w),S.borderTop=_,c.setParent(b,w),S.borderBottom=b,e.forEach(E,function(k){i(c,h,p,d,m,y,k);var N=c.node(k),T=N.borderTop?N.borderTop:k,A=N.borderBottom?N.borderBottom:k,M=N.borderTop?d:2*d,O=T!==A?1:m-y[w]+1;c.setEdge(_,T,{weight:M,minlen:O,nestingEdge:!0}),c.setEdge(A,b,{weight:M,minlen:O,nestingEdge:!0})}),c.parent(w)||c.setEdge(h,_,{weight:0,minlen:m+y[w]})}function o(c){var h={};function p(d,m){var y=c.children(d);y&&y.length&&e.forEach(y,function(w){p(w,m+1)}),h[d]=m}return e.forEach(c.children(),function(d){p(d,1)}),h}function l(c){return e.reduce(c.edges(),function(h,p){return h+c.edge(p).weight},0)}function u(c){var h=c.graph();c.removeNode(h.nestingRoot),delete h.nestingRoot,e.forEach(c.edges(),function(p){var d=c.edge(p);d.nestingEdge&&c.removeEdge(p)})}return Kg}var Xg,_E;function Q4(){if(_E)return Xg;_E=1;var e=at(),n=fn();Xg=r;function r(o){function l(u){var c=o.children(u),h=o.node(u);if(c.length&&e.forEach(c,l),e.has(h,"minRank")){h.borderLeft=[],h.borderRight=[];for(var p=h.minRank,d=h.maxRank+1;p<d;++p)i(o,"borderLeft","_bl",u,h,p),i(o,"borderRight","_br",u,h,p)}}e.forEach(o.children(),l)}function i(o,l,u,c,h,p){var d={width:0,height:0,rank:p,borderType:l},m=h[l][p-1],y=n.addDummyNode(o,"border",d,u);h[l][p]=y,o.setParent(y,c),m&&o.setEdge(m,y,{weight:1})}return Xg}var Qg,bE;function Z4(){if(bE)return Qg;bE=1;var e=at();Qg={adjust:n,undo:r};function n(p){var d=p.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&i(p)}function r(p){var d=p.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&l(p),(d==="lr"||d==="rl")&&(c(p),i(p))}function i(p){e.forEach(p.nodes(),function(d){o(p.node(d))}),e.forEach(p.edges(),function(d){o(p.edge(d))})}function o(p){var d=p.width;p.width=p.height,p.height=d}function l(p){e.forEach(p.nodes(),function(d){u(p.node(d))}),e.forEach(p.edges(),function(d){var m=p.edge(d);e.forEach(m.points,u),e.has(m,"y")&&u(m)})}function u(p){p.y=-p.y}function c(p){e.forEach(p.nodes(),function(d){h(p.node(d))}),e.forEach(p.edges(),function(d){var m=p.edge(d);e.forEach(m.points,h),e.has(m,"x")&&h(m)})}function h(p){var d=p.x;p.x=p.y,p.y=d}return Qg}var Zg,SE;function J4(){if(SE)return Zg;SE=1;var e=at();Zg=n;function n(r){var i={},o=e.filter(r.nodes(),function(p){return!r.children(p).length}),l=e.max(e.map(o,function(p){return r.node(p).rank})),u=e.map(e.range(l+1),function(){return[]});function c(p){if(!e.has(i,p)){i[p]=!0;var d=r.node(p);u[d.rank].push(p),e.forEach(r.successors(p),c)}}var h=e.sortBy(o,function(p){return r.node(p).rank});return e.forEach(h,c),u}return Zg}var Jg,kE;function e5(){if(kE)return Jg;kE=1;var e=at();Jg=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,w){return w})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(i.outEdges(y),function(w){return{pos:u[w.w],weight:i.edge(w).weight}}),"pos")}),!0),h=1;h<l.length;)h<<=1;var p=2*h-1;h-=1;var d=e.map(new Array(p),function(){return 0}),m=0;return e.forEach(c.forEach(function(y){var w=y.pos+h;d[w]+=y.weight;for(var E=0;w>0;)w%2&&(E+=d[w+1]),w=w-1>>1,d[w]+=y.weight;m+=y.weight*E})),m}return Jg}var ev,EE;function t5(){if(EE)return ev;EE=1;var e=at();ev=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,h){var p=r.edge(h),d=r.node(h.v);return{sum:c.sum+p.weight*d.order,weight:c.weight+p.weight}},{sum:0,weight:0});return{v:o,barycenter:u.sum/u.weight,weight:u.weight}}else return{v:o}})}return ev}var tv,NE;function n5(){if(NE)return tv;NE=1;var e=at();tv=n;function n(o,l){var u={};e.forEach(o,function(h,p){var d=u[h.v]={indegree:0,in:[],out:[],vs:[h.v],i:p};e.isUndefined(h.barycenter)||(d.barycenter=h.barycenter,d.weight=h.weight)}),e.forEach(l.edges(),function(h){var p=u[h.v],d=u[h.w];!e.isUndefined(p)&&!e.isUndefined(d)&&(d.indegree++,p.out.push(u[h.w]))});var c=e.filter(u,function(h){return!h.indegree});return r(c)}function r(o){var l=[];function u(p){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(p.barycenter)||d.barycenter>=p.barycenter)&&i(p,d)}}function c(p){return function(d){d.in.push(p),--d.indegree===0&&o.push(d)}}for(;o.length;){var h=o.pop();l.push(h),e.forEach(h.in.reverse(),u(h)),e.forEach(h.out,c(h))}return e.map(e.filter(l,function(p){return!p.merged}),function(p){return e.pick(p,["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 tv}var nv,CE;function r5(){if(CE)return nv;CE=1;var e=at(),n=fn();nv=r;function r(l,u){var c=n.partition(l,function(_){return e.has(_,"barycenter")}),h=c.lhs,p=e.sortBy(c.rhs,function(_){return-_.i}),d=[],m=0,y=0,w=0;h.sort(o(!!u)),w=i(d,p,w),e.forEach(h,function(_){w+=_.vs.length,d.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,w=i(d,p,w)});var E={vs:e.flatten(d,!0)};return y&&(E.barycenter=m/y,E.weight=y),E}function i(l,u,c){for(var h;u.length&&(h=e.last(u)).i<=c;)u.pop(),l.push(h.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 nv}var rv,TE;function s5(){if(TE)return rv;TE=1;var e=at(),n=t5(),r=n5(),i=r5();rv=o;function o(c,h,p,d){var m=c.children(h),y=c.node(h),w=y?y.borderLeft:void 0,E=y?y.borderRight:void 0,_={};w&&(m=e.filter(m,function(A){return A!==w&&A!==E}));var b=n(c,m);e.forEach(b,function(A){if(c.children(A.v).length){var M=o(c,A.v,p,d);_[A.v]=M,e.has(M,"barycenter")&&u(A,M)}});var S=r(b,p);l(S,_);var k=i(S,d);if(w&&(k.vs=e.flatten([w,k.vs,E],!0),c.predecessors(w).length)){var N=c.node(c.predecessors(w)[0]),T=c.node(c.predecessors(E)[0]);e.has(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+N.order+T.order)/(k.weight+2),k.weight+=2}return k}function l(c,h){e.forEach(c,function(p){p.vs=e.flatten(p.vs.map(function(d){return h[d]?h[d].vs:d}),!0)})}function u(c,h){e.isUndefined(c.barycenter)?(c.barycenter=h.barycenter,c.weight=h.weight):(c.barycenter=(c.barycenter*c.weight+h.barycenter*h.weight)/(c.weight+h.weight),c.weight+=h.weight)}return rv}var sv,jE;function i5(){if(jE)return sv;jE=1;var e=at(),n=tr().Graph;sv=r;function r(o,l,u){var c=i(o),h=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(p){return o.node(p)});return e.forEach(o.nodes(),function(p){var d=o.node(p),m=o.parent(p);(d.rank===l||d.minRank<=l&&l<=d.maxRank)&&(h.setNode(p),h.setParent(p,m||c),e.forEach(o[u](p),function(y){var w=y.v===p?y.w:y.v,E=h.edge(w,p),_=e.isUndefined(E)?0:E.weight;h.setEdge(w,p,{weight:o.edge(y).weight+_})}),e.has(d,"minRank")&&h.setNode(p,{borderLeft:d.borderLeft[l],borderRight:d.borderRight[l]}))}),h}function i(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return sv}var iv,RE;function o5(){if(RE)return iv;RE=1;var e=at();iv=n;function n(r,i,o){var l={},u;e.forEach(o,function(c){for(var h=r.parent(c),p,d;h;){if(p=r.parent(h),p?(d=l[p],l[p]=h):(d=u,u=h),d&&d!==h){i.setEdge(d,h);return}h=p}})}return iv}var ov,AE;function a5(){if(AE)return ov;AE=1;var e=at(),n=J4(),r=e5(),i=s5(),o=i5(),l=o5(),u=tr().Graph,c=fn();ov=h;function h(y){var w=c.maxRank(y),E=p(y,e.range(1,w+1),"inEdges"),_=p(y,e.range(w-1,-1,-1),"outEdges"),b=n(y);m(y,b);for(var S=Number.POSITIVE_INFINITY,k,N=0,T=0;T<4;++N,++T){d(N%2?E:_,N%4>=2),b=c.buildLayerMatrix(y);var A=r(y,b);A<S&&(T=0,k=e.cloneDeep(b),S=A)}m(y,k)}function p(y,w,E){return e.map(w,function(_){return o(y,_,E)})}function d(y,w){var E=new u;e.forEach(y,function(_){var b=_.graph().root,S=i(_,b,E,w);e.forEach(S.vs,function(k,N){_.node(k).order=N}),l(_,E,S.vs)})}function m(y,w){e.forEach(w,function(E){e.forEach(E,function(_,b){y.node(_).order=b})})}return ov}var av,IE;function l5(){if(IE)return av;IE=1;var e=at(),n=tr().Graph,r=fn();av={positionX:E,findType1Conflicts:i,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:h,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:m,balance:w};function i(S,k){var N={};function T(A,M){var O=0,P=0,D=A.length,L=e.last(M);return e.forEach(M,function(U,V){var z=l(S,U),C=z?S.node(z).order:D;(z||U===L)&&(e.forEach(M.slice(P,V+1),function(F){e.forEach(S.predecessors(F),function($){var re=S.node($),J=re.order;(J<O||C<J)&&!(re.dummy&&S.node(F).dummy)&&u(N,$,F)})}),P=V+1,O=C)}),M}return e.reduce(k,T),N}function o(S,k){var N={};function T(M,O,P,D,L){var U;e.forEach(e.range(O,P),function(V){U=M[V],S.node(U).dummy&&e.forEach(S.predecessors(U),function(z){var C=S.node(z);C.dummy&&(C.order<D||C.order>L)&&u(N,z,U)})})}function A(M,O){var P=-1,D,L=0;return e.forEach(O,function(U,V){if(S.node(U).dummy==="border"){var z=S.predecessors(U);z.length&&(D=S.node(z[0]).order,T(O,L,V,P,D),L=V,P=D)}T(O,L,O.length,D,M.length)}),O}return e.reduce(k,A),N}function l(S,k){if(S.node(k).dummy)return e.find(S.predecessors(k),function(N){return S.node(N).dummy})}function u(S,k,N){if(k>N){var T=k;k=N,N=T}var A=S[k];A||(S[k]=A={}),A[N]=!0}function c(S,k,N){if(k>N){var T=k;k=N,N=T}return e.has(S[k],N)}function h(S,k,N,T){var A={},M={},O={};return e.forEach(k,function(P){e.forEach(P,function(D,L){A[D]=D,M[D]=D,O[D]=L})}),e.forEach(k,function(P){var D=-1;e.forEach(P,function(L){var U=T(L);if(U.length){U=e.sortBy(U,function($){return O[$]});for(var V=(U.length-1)/2,z=Math.floor(V),C=Math.ceil(V);z<=C;++z){var F=U[z];M[L]===L&&D<O[F]&&!c(N,L,F)&&(M[F]=L,M[L]=A[L]=A[F],D=O[F])}}})}),{root:A,align:M}}function p(S,k,N,T,A){var M={},O=d(S,k,N,A),P=A?"borderLeft":"borderRight";function D(V,z){for(var C=O.nodes(),F=C.pop(),$={};F;)$[F]?V(F):($[F]=!0,C.push(F),C=C.concat(z(F))),F=C.pop()}function L(V){M[V]=O.inEdges(V).reduce(function(z,C){return Math.max(z,M[C.v]+O.edge(C))},0)}function U(V){var z=O.outEdges(V).reduce(function(F,$){return Math.min(F,M[$.w]-O.edge($))},Number.POSITIVE_INFINITY),C=S.node(V);z!==Number.POSITIVE_INFINITY&&C.borderType!==P&&(M[V]=Math.max(M[V],z))}return D(L,O.predecessors.bind(O)),D(U,O.successors.bind(O)),e.forEach(T,function(V){M[V]=M[N[V]]}),M}function d(S,k,N,T){var A=new n,M=S.graph(),O=_(M.nodesep,M.edgesep,T);return e.forEach(k,function(P){var D;e.forEach(P,function(L){var U=N[L];if(A.setNode(U),D){var V=N[D],z=A.edge(V,U);A.setEdge(V,U,Math.max(O(S,L,D),z||0))}D=L})}),A}function m(S,k){return e.minBy(e.values(k),function(N){var T=Number.NEGATIVE_INFINITY,A=Number.POSITIVE_INFINITY;return e.forIn(N,function(M,O){var P=b(S,O)/2;T=Math.max(M+P,T),A=Math.min(M-P,A)}),T-A})}function y(S,k){var N=e.values(k),T=e.min(N),A=e.max(N);e.forEach(["u","d"],function(M){e.forEach(["l","r"],function(O){var P=M+O,D=S[P],L;if(D!==k){var U=e.values(D);L=O==="l"?T-e.min(U):A-e.max(U),L&&(S[P]=e.mapValues(D,function(V){return V+L}))}})})}function w(S,k){return e.mapValues(S.ul,function(N,T){if(k)return S[k.toLowerCase()][T];var A=e.sortBy(e.map(S,T));return(A[1]+A[2])/2})}function E(S){var k=r.buildLayerMatrix(S),N=e.merge(i(S,k),o(S,k)),T={},A;e.forEach(["u","d"],function(O){A=O==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(P){P==="r"&&(A=e.map(A,function(V){return e.values(V).reverse()}));var D=(O==="u"?S.predecessors:S.successors).bind(S),L=h(S,A,N,D),U=p(S,A,L.root,L.align,P==="r");P==="r"&&(U=e.mapValues(U,function(V){return-V})),T[O+P]=U})});var M=m(S,T);return y(T,M),w(T,S.graph().align)}function _(S,k,N){return function(T,A,M){var O=T.node(A),P=T.node(M),D=0,L;if(D+=O.width/2,e.has(O,"labelpos"))switch(O.labelpos.toLowerCase()){case"l":L=-O.width/2;break;case"r":L=O.width/2;break}if(L&&(D+=N?L:-L),L=0,D+=(O.dummy?k:S)/2,D+=(P.dummy?k:S)/2,D+=P.width/2,e.has(P,"labelpos"))switch(P.labelpos.toLowerCase()){case"l":L=P.width/2;break;case"r":L=-P.width/2;break}return L&&(D+=N?L:-L),L=0,D}}function b(S,k){return S.node(k).width}return av}var lv,ME;function u5(){if(ME)return lv;ME=1;var e=at(),n=fn(),r=l5().positionX;lv=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,h=0;e.forEach(u,function(p){var d=e.max(e.map(p,function(m){return l.node(m).height}));e.forEach(p,function(m){l.node(m).y=h+d/2}),h+=d+c})}return lv}var uv,OE;function c5(){if(OE)return uv;OE=1;var e=at(),n=W4(),r=V4(),i=Y4(),o=fn().normalizeRanks,l=K4(),u=fn().removeEmptyRanks,c=X4(),h=Q4(),p=Z4(),d=a5(),m=u5(),y=fn(),w=tr().Graph;uv=E;function E(q,Q){var ne=Q&&Q.debugTiming?y.time:y.notime;ne("layout",function(){var ae=ne(" buildLayoutGraph",function(){return D(q)});ne(" runLayout",function(){_(ae,ne)}),ne(" updateInputGraph",function(){b(q,ae)})})}function _(q,Q){Q(" makeSpaceForEdgeLabels",function(){L(q)}),Q(" removeSelfEdges",function(){W(q)}),Q(" acyclic",function(){n.run(q)}),Q(" nestingGraph.run",function(){c.run(q)}),Q(" rank",function(){i(y.asNonCompoundGraph(q))}),Q(" injectEdgeLabelProxies",function(){U(q)}),Q(" removeEmptyRanks",function(){u(q)}),Q(" nestingGraph.cleanup",function(){c.cleanup(q)}),Q(" normalizeRanks",function(){o(q)}),Q(" assignRankMinMax",function(){V(q)}),Q(" removeEdgeLabelProxies",function(){z(q)}),Q(" normalize.run",function(){r.run(q)}),Q(" parentDummyChains",function(){l(q)}),Q(" addBorderSegments",function(){h(q)}),Q(" order",function(){d(q)}),Q(" insertSelfEdges",function(){Z(q)}),Q(" adjustCoordinateSystem",function(){p.adjust(q)}),Q(" position",function(){m(q)}),Q(" positionSelfEdges",function(){I(q)}),Q(" removeBorderNodes",function(){J(q)}),Q(" normalize.undo",function(){r.undo(q)}),Q(" fixupEdgeLabelCoords",function(){$(q)}),Q(" undoCoordinateSystem",function(){p.undo(q)}),Q(" translateGraph",function(){C(q)}),Q(" assignNodeIntersects",function(){F(q)}),Q(" reversePoints",function(){re(q)}),Q(" acyclic.undo",function(){n.undo(q)})}function b(q,Q){e.forEach(q.nodes(),function(ne){var ae=q.node(ne),fe=Q.node(ne);ae&&(ae.x=fe.x,ae.y=fe.y,Q.children(ne).length&&(ae.width=fe.width,ae.height=fe.height))}),e.forEach(q.edges(),function(ne){var ae=q.edge(ne),fe=Q.edge(ne);ae.points=fe.points,e.has(fe,"x")&&(ae.x=fe.x,ae.y=fe.y)}),q.graph().width=Q.graph().width,q.graph().height=Q.graph().height}var S=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},N=["acyclicer","ranker","rankdir","align"],T=["width","height"],A={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],O={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},P=["labelpos"];function D(q){var Q=new w({multigraph:!0,compound:!0}),ne=K(q.graph());return Q.setGraph(e.merge({},k,G(ne,S),e.pick(ne,N))),e.forEach(q.nodes(),function(ae){var fe=K(q.node(ae));Q.setNode(ae,e.defaults(G(fe,T),A)),Q.setParent(ae,q.parent(ae))}),e.forEach(q.edges(),function(ae){var fe=K(q.edge(ae));Q.setEdge(ae,e.merge({},O,G(fe,M),e.pick(fe,P)))}),Q}function L(q){var Q=q.graph();Q.ranksep/=2,e.forEach(q.edges(),function(ne){var ae=q.edge(ne);ae.minlen*=2,ae.labelpos.toLowerCase()!=="c"&&(Q.rankdir==="TB"||Q.rankdir==="BT"?ae.width+=ae.labeloffset:ae.height+=ae.labeloffset)})}function U(q){e.forEach(q.edges(),function(Q){var ne=q.edge(Q);if(ne.width&&ne.height){var ae=q.node(Q.v),fe=q.node(Q.w),te={rank:(fe.rank-ae.rank)/2+ae.rank,e:Q};y.addDummyNode(q,"edge-proxy",te,"_ep")}})}function V(q){var Q=0;e.forEach(q.nodes(),function(ne){var ae=q.node(ne);ae.borderTop&&(ae.minRank=q.node(ae.borderTop).rank,ae.maxRank=q.node(ae.borderBottom).rank,Q=e.max(Q,ae.maxRank))}),q.graph().maxRank=Q}function z(q){e.forEach(q.nodes(),function(Q){var ne=q.node(Q);ne.dummy==="edge-proxy"&&(q.edge(ne.e).labelRank=ne.rank,q.removeNode(Q))})}function C(q){var Q=Number.POSITIVE_INFINITY,ne=0,ae=Number.POSITIVE_INFINITY,fe=0,te=q.graph(),ce=te.marginx||0,Ce=te.marginy||0;function ve(Re){var ye=Re.x,Ee=Re.y,Ye=Re.width,we=Re.height;Q=Math.min(Q,ye-Ye/2),ne=Math.max(ne,ye+Ye/2),ae=Math.min(ae,Ee-we/2),fe=Math.max(fe,Ee+we/2)}e.forEach(q.nodes(),function(Re){ve(q.node(Re))}),e.forEach(q.edges(),function(Re){var ye=q.edge(Re);e.has(ye,"x")&&ve(ye)}),Q-=ce,ae-=Ce,e.forEach(q.nodes(),function(Re){var ye=q.node(Re);ye.x-=Q,ye.y-=ae}),e.forEach(q.edges(),function(Re){var ye=q.edge(Re);e.forEach(ye.points,function(Ee){Ee.x-=Q,Ee.y-=ae}),e.has(ye,"x")&&(ye.x-=Q),e.has(ye,"y")&&(ye.y-=ae)}),te.width=ne-Q+ce,te.height=fe-ae+Ce}function F(q){e.forEach(q.edges(),function(Q){var ne=q.edge(Q),ae=q.node(Q.v),fe=q.node(Q.w),te,ce;ne.points?(te=ne.points[0],ce=ne.points[ne.points.length-1]):(ne.points=[],te=fe,ce=ae),ne.points.unshift(y.intersectRect(ae,te)),ne.points.push(y.intersectRect(fe,ce))})}function $(q){e.forEach(q.edges(),function(Q){var ne=q.edge(Q);if(e.has(ne,"x"))switch((ne.labelpos==="l"||ne.labelpos==="r")&&(ne.width-=ne.labeloffset),ne.labelpos){case"l":ne.x-=ne.width/2+ne.labeloffset;break;case"r":ne.x+=ne.width/2+ne.labeloffset;break}})}function re(q){e.forEach(q.edges(),function(Q){var ne=q.edge(Q);ne.reversed&&ne.points.reverse()})}function J(q){e.forEach(q.nodes(),function(Q){if(q.children(Q).length){var ne=q.node(Q),ae=q.node(ne.borderTop),fe=q.node(ne.borderBottom),te=q.node(e.last(ne.borderLeft)),ce=q.node(e.last(ne.borderRight));ne.width=Math.abs(ce.x-te.x),ne.height=Math.abs(fe.y-ae.y),ne.x=te.x+ne.width/2,ne.y=ae.y+ne.height/2}}),e.forEach(q.nodes(),function(Q){q.node(Q).dummy==="border"&&q.removeNode(Q)})}function W(q){e.forEach(q.edges(),function(Q){if(Q.v===Q.w){var ne=q.node(Q.v);ne.selfEdges||(ne.selfEdges=[]),ne.selfEdges.push({e:Q,label:q.edge(Q)}),q.removeEdge(Q)}})}function Z(q){var Q=y.buildLayerMatrix(q);e.forEach(Q,function(ne){var ae=0;e.forEach(ne,function(fe,te){var ce=q.node(fe);ce.order=te+ae,e.forEach(ce.selfEdges,function(Ce){y.addDummyNode(q,"selfedge",{width:Ce.label.width,height:Ce.label.height,rank:ce.rank,order:te+ ++ae,e:Ce.e,label:Ce.label},"_se")}),delete ce.selfEdges})})}function I(q){e.forEach(q.nodes(),function(Q){var ne=q.node(Q);if(ne.dummy==="selfedge"){var ae=q.node(ne.e.v),fe=ae.x+ae.width/2,te=ae.y,ce=ne.x-fe,Ce=ae.height/2;q.setEdge(ne.e,ne.label),q.removeNode(Q),ne.label.points=[{x:fe+2*ce/3,y:te-Ce},{x:fe+5*ce/6,y:te-Ce},{x:fe+ce,y:te},{x:fe+5*ce/6,y:te+Ce},{x:fe+2*ce/3,y:te+Ce}],ne.label.x=ne.x,ne.label.y=ne.y}})}function G(q,Q){return e.mapValues(e.pick(q,Q),Number)}function K(q){var Q={};return e.forEach(q,function(ne,ae){Q[ae.toLowerCase()]=ne}),Q}return uv}var cv,PE;function d5(){if(PE)return cv;PE=1;var e=at(),n=fn(),r=tr().Graph;cv={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,h){var p="layer"+h;u.setNode(p,{rank:"same"}),e.reduce(c,function(d,m){return u.setEdge(d,m,{style:"invis"}),m})}),u}return cv}var dv,LE;function f5(){return LE||(LE=1,dv="0.8.5"),dv}var fv,$E;function h5(){return $E||($E=1,fv={graphlib:tr(),layout:c5(),debug:d5(),util:{time:fn().time,notime:fn().notime},version:f5()}),fv}var p5=h5();const qE=Dv(p5),vo=240,ju=130,uo=74,tc=72,DE=uo+tc;function m5(e,n){var i;let r=vo;for(const o of e)r=Math.max(r,((i=n.get(o.id))==null?void 0:i.width)??vo);return r}const VT=420,g5=2;function Ea(e){var r;return((r=e.data)==null?void 0:r.sessionId)??"_default"}function v5(e,n){return((n==null?void 0:n.get(e))??0)>0?VT:0}function y5(e,n){const r=(n==null?void 0:n.get(e))??0;return r>0?6+r*36:0}function Na(e,n,r){const i=n.get(e);return{w:((i==null?void 0:i.width)??vo)+v5(e,r),h:Math.max((i==null?void 0:i.height)??ju,y5(e,r))}}function w5(e){return[...e.keys()].sort().map(n=>`${n}:${e.get(n)}`).join("|")}function x5(e,n,r,i,o,l){const u=new qE.graphlib.Graph;u.setDefaultEdgeLabel(()=>({})),u.setGraph({rankdir:r,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(S=>!o.has(S)),h=new Set(c);for(const S of c){const{w:k,h:N}=Na(S,i,l);u.setNode(S,{width:k,height:N})}for(const S of n)h.has(S.source)&&h.has(S.target)&&u.setEdge(S.source,S.target);qE.layout(u);const p=new Map;let d=1/0,m=1/0,y=-1/0,w=-1/0;for(const S of c){const k=u.node(S);if(!k)continue;const N=i.get(S),T=(N==null?void 0:N.width)??vo,A=(N==null?void 0:N.height)??ju,M=Na(S,i,l),O=k.x-M.w/2,P=k.y-M.h/2;p.set(S,{x:O,y:P}),O<d&&(d=O),P<m&&(m=P),O+T>y&&(y=O+T),P+A>w&&(w=P+A)}if(Number.isFinite(d)&&Number.isFinite(m))for(const[S,k]of p)p.set(S,{x:k.x-d,y:k.y-m});const E=Number.isFinite(y)?y-d:0,_=Number.isFinite(w)?w-m:0;let b=null;for(const S of e){const k=o.get(S);if(!k)continue;const N=i.get(S),T=(N==null?void 0:N.width)??vo,A=(N==null?void 0:N.height)??ju;b=b===null?{minX:k.x,minY:k.y,maxX:k.x+T,maxY:k.y+A}:{minX:Math.min(b.minX,k.x),minY:Math.min(b.minY,k.y),maxX:Math.max(b.maxX,k.x+T),maxY:Math.max(b.maxY,k.y+A)}}return{positions:p,width:E,height:_,pinnedBox:b}}function _5(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 S of e){const k=Ea(S),N=c.get(k);N?N.push(S.id):c.set(k,[S.id])}const p=Array.from(c.keys()).sort().map(S=>({sid:S,...x5(c.get(S),n,i,l,o,u)})),d=m5(e,l),m=r.availableHeight&&r.availableHeight>0?r.availableHeight:Number.POSITIVE_INFINITY,y=S=>{const k=[[]];let N=0;for(const T of p)k.length<S&&N>0&&N+T.height>m&&(k.push([]),N=0),k[k.length-1].push(T),N+=T.height+DE;return k},w=S=>S.reduce((k,N)=>Math.max(k,N.width),0)+VT;let E=y(r.availableWidth?g5:1);E.length>1&&E.reduce((k,N)=>k+w(N),0)+d*(E.length-1)>(r.availableWidth??0)&&(E=y(1));const _=new Map;let b=0;for(const S of E){const k=w(S);let N=0;for(const{positions:T,height:A,pinnedBox:M}of S){for(const[P,D]of T)_.set(P,{x:D.x+b,y:D.y+N});let O=N+A;M&&M.maxY>O&&M.minX<b+k&&b<M.maxX&&(O=M.maxY),N=O+DE}b+=k+d}return e.map(S=>{const k=o.get(S.id);if(k)return{...S,position:k};const N=_.get(S.id);return N?{...S,position:N}:S})}function b5(e,n,r,i,o){const u=uo+tc,c=60,h=w=>Na(w,i,o),p=new Map(e.map(w=>[w.id,Ea(w)])),d=[],m=e.map(w=>({id:w.id,pos:r.get(w.id)??n.get(w.id)})).filter(w=>w.pos!=null).sort((w,E)=>w.pos.y-E.pos.y||w.pos.x-E.pos.x||w.id.localeCompare(E.id)),y=[];for(const{id:w,pos:E}of m){const{w:_,h:b}=h(w),S=p.get(w)??"_default";if(r.has(w)){d.push({x:E.x,y:E.y,w:_,h:b,sid:S});continue}let k=E.y;for(let N=0;N<d.length+1;N++){const T=d.find(A=>{const M=A.sid===S?24:c,O=A.sid===S?24:u;return E.x<A.x+A.w+M&&A.x<E.x+_+M&&k<A.y+A.h+O&&A.y<k+b+O});if(!T)break;k=T.y+T.h+(T.sid===S?24:u)}k!==E.y&&(n.set(w,{x:E.x,y:k}),y.push(w)),d.push({x:E.x,y:k,w:_,h:b,sid:S})}return y}function S5(e,n,r,i,o,l){const u=_=>Na(_,i,l),c=_=>r.get(_)??n.get(_),h=new Map;for(const _ of e){if(!c(_.id))continue;const b=Ea(_),S=h.get(b);S?S.push(_):h.set(b,[_])}const p=new Set;for(const[_,b]of h)b.every(S=>o.has(S.id)&&!r.has(S.id))&&p.add(_);const d=new Map,m=[];for(const _ of e){const b=c(_.id);if(!b)continue;const{w:S,h:k}=u(_.id),N=Ea(_);p.has(N)?(d.get(N)??d.set(N,[]).get(N)).push(_):m.push({x:b.x,y:b.y,w:S,h:k})}if(d.size===0)return[];const y=uo+tc,w=(_,b,S,k)=>m.some(N=>_<N.x+N.w+uo&&N.x<_+S+uo&&b<N.y+N.h+y&&N.y<b+k+y),E=[];for(const _ of[...d.keys()].sort()){const b=d.get(_);let S=1/0,k=1/0,N=-1/0,T=-1/0;for(const U of b){const V=c(U.id),{w:z,h:C}=u(U.id);S=Math.min(S,V.x),k=Math.min(k,V.y),N=Math.max(N,V.x+z),T=Math.max(T,V.y+C)}const A=N-S,M=T-k,O=[...new Set(m.map(U=>Math.round(U.x)))].sort((U,V)=>U-V),P=O.length?O:[S],D=[0,...m.map(U=>U.y+U.h+y)].sort((U,V)=>U-V);let L=null;e:for(const U of P)for(const V of D){if(V>=k)break;if(!w(U,V,A,M)){L={x:U,y:V};break e}}if(L){const U=L.x-S,V=L.y-k;for(const z of b){const C=c(z.id);n.set(z.id,{x:C.x+U,y:C.y+V})}E.push(_)}for(const U of b){const V=c(U.id),{w:z,h:C}=u(U.id);m.push({x:V.x,y:V.y,w:z,h:C})}}return E}function k5(e,n,r,i,o,l=!1,u){const p=uo+tc+1,d=8,m=1.75,y=200,w=.7,E=.01,_=L=>Na(L,i,u),b=L=>r.get(L)??n.get(L),S=new Map;for(const L of e){if(!b(L.id))continue;const U=Ea(L),V=S.get(U);V?V.push(L):S.set(U,[L])}const k=[],N=new Set,T=new Set,A=o.size===0;for(const L of[...S.keys()].sort()){const U=S.get(L);let V=1/0,z=1/0,C=-1/0,F=-1/0,$=!1;for(const Z of U){const I=b(Z.id),{w:G,h:K}=_(Z.id);V=Math.min(V,I.x),z=Math.min(z,I.y),C=Math.max(C,I.x+G),F=Math.max(F,I.y+K),r.has(Z.id)&&($=!0)}const re=C-V,J=F-z;T.add(L);const W=o.get(L);W&&(re>W.w+d||J>W.h+d)&&N.add(L),o.set(L,{w:re,h:J}),k.push({sid:L,members:U.map(Z=>Z.id),x:V,y:z,w:re,h:J,anchored:$,mass:1})}for(const L of[...o.keys()])T.has(L)||o.delete(L);if(l||A)return[];let M=!1;for(let L=0;L<k.length&&!M;L++)for(let U=L+1;U<k.length;U++){const V=k[L],z=k[U];if(!(V.anchored&&z.anchored)&&Math.abs(V.x+V.w/2-(z.x+z.w/2))<(V.w+z.w)/2+61&&Math.abs(V.y+V.h/2-(z.y+z.h/2))<(V.h+z.h)/2+p){M=!0;break}}if(N.size===0&&!M)return[];if(N.size>0)for(const L of k)N.has(L.sid)&&(L.mass=8);else for(const L of k)L.mass=Math.max(1,L.w*L.h/(vo*ju));const O=new Map(k.map(L=>[L.sid,L.x])),P=new Map(k.map(L=>[L.sid,L.y]));for(let L=0;L<y;L++){const U=new Map,V=new Map;let z=0;for(let C=0;C<k.length;C++)for(let F=C+1;F<k.length;F++){const $=k[C],re=k[F];if($.anchored&&re.anchored)continue;const J=$.x+$.w/2,W=$.y+$.h/2,Z=re.x+re.w/2,I=re.y+re.h/2,G=($.w+re.w)/2+61-Math.abs(J-Z),K=($.h+re.h)/2+p-Math.abs(W-I);if(G<=0||K<=0)continue;const q=(De,Je)=>!De.anchored&&!(Je<0&&De.x<=0),Q=(De,Je)=>!De.anchored&&!(Je<0&&De.y<=0),ne=(De,Je,Xe)=>{const Ot=De===Je,lt=Ot?$.sid<re.sid?-1:1:Math.sign(De-Je);return Xe($,lt)||Xe(re,-lt)?lt:Ot&&(Xe($,-lt)||Xe(re,lt))?-lt:0},ae=ne(J,Z,q),fe=ne(W,I,Q),te=ae!==0,ce=fe!==0;if(!te&&!ce)continue;const Ce=te&&(!ce||G*m<K),[ve,Re,ye,Ee]=Ce?[ae,G,U,q]:[fe,K,V,Q],Ye=Ee($,ve),we=Ee(re,-ve),_e=$.mass,Be=re.mass,it=Ye?we?Be/(_e+Be):1:0,ft=we?Ye?_e/(_e+Be):1:0,Ze=Re*w;ye.set($.sid,(ye.get($.sid)??0)+ve*Ze*it),ye.set(re.sid,(ye.get(re.sid)??0)-ve*Ze*ft),z+=Ze}for(const C of k)C.anchored||(C.x=Math.max(0,C.x+(U.get(C.sid)??0)),C.y=Math.max(0,C.y+(V.get(C.sid)??0)));if(z<E)break}const D=[];for(const L of k){const U=L.x-O.get(L.sid),V=L.y-P.get(L.sid);if(!(Math.abs(U)<1&&Math.abs(V)<1)){for(const z of L.members){if(r.has(z))continue;const C=n.get(z);C&&n.set(z,{x:C.x+U,y:C.y+V})}D.push(L.sid)}}return D}const E5=600;function Pv(e,n){return!(e.exitAt!=null&&n-e.exitAt>E5||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function N5(e,n){const r=new Set;for(const i of e.agents.values())Pv(i,n)&&r.add(i.id);return r}function C5(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 T5(e,n,r=0){if(!e)return!1;for(const i of n)if(C5(e,i,r))return!0;return!1}const GT="sessionGroup";function j5(e,n){var i;if(e.type===GT)return"transparent";const r=(i=e.data)==null?void 0:i.state;return n(r==="err"?"--err":r==="active"?"--inflight":"--ok")}const R5="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1).";function A5(e){if(e.checkDisabled)return R5;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 I5(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 M5(e){const n=e.kind==="restart"?`v${e.to} is installed and waiting for a restart`:`v${e.to} is available on npm`;return`Version v${e.from}, ${n} — ${e.open?"hide":"show"} the notice`}function O5(e){if(e==null)return{kind:"unknown",lead:"No data yet. Start a Claude Code or Codex session — it appears here as soon as the deck sees its first event.",workspace:null,tail:""};const 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."}}const Lv={kind:"assumed",claude:!0,codex:!0};function P5(e){if(!e||typeof e!="object")return Lv;const n=e.providers;if(!n||typeof n!="object")return Lv;const r=n;return{kind:"reported",claude:r.claude!==!1,codex:r.codex!==!1}}function YT(e){const n=Math.max(0,Math.floor(e));return`${n} event${n===1?"":"s"}`}function L5(e){return e.connected?e.paused?{tone:"paused",label:"paused",title:e.held>0?`Connected — ${YT(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 $5(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:`${YT(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 KT(e,n){return e!==""&&n>0}function q5(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:KT(e,n)}}const D5="Search agents, tools, model…";function XT(e,n){var i,o,l,u;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)||e.model&&(e.model.toLowerCase().includes(r)||Rs(e.model).toLowerCase().includes(r))||(u=e.provider)!=null&&u.toLowerCase().startsWith(r))return!0;for(const c of e.tools)if(c.name.toLowerCase().includes(r))return!0;return!1}function ca(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const F5={agent:uL,sessionGroup:_L},QT="react-flow__node";function FE(e){var n,r;return!!e&&((r=(n=e.classList)==null?void 0:n.contains)==null?void 0:r.call(n,QT))===!0}function z5(e){try{const n=document.querySelector(`.${QT}[data-id="${CSS.escape(e)}"]`);n==null||n.focus({preventScroll:!0})}catch{}}const B5=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),U5=420,lu=18,H5=200,W5=5*6e4,V5=6,G5=2*6e4,Cy="agent-dag.layout",Ty="agent-dag.viewport",ZT="agent-dag.summariesDismissed",JT="agent-dag.sessionListOpen",ej="agent-dag.detailOpen",tj="agent-dag.usagePanelOpen",zE="agent-dag.accountsPanelOpen",BE="agent-dag.versionNoticeDismissed",UE="agent-dag.oldNameNoticeDismissed",Y5=15*6e4,HE={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:"},WE="agent-dag.autoRestart",VE="agent-dag.bundleReloadedFor";function K5(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(JT)==="1"}catch{return!1}}function X5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(JT,e?"1":"0")}catch{}}function Q5(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(ej)==="1"}catch{return!1}}function Z5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(ej,e?"1":"0")}catch{}}function J5(){const e=UC(tj);return e===null?!0:e==="1"}function eF(e){if(!(typeof window>"u"))try{window.localStorage.setItem(tj,e?"1":"0")}catch{}}function tF(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(ZT);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 GE(e){if(!(typeof window>"u"))try{const n=Array.from(e),r=n.length>200?n.slice(-200):n;window.localStorage.setItem(ZT,JSON.stringify(r))}catch{}}function nF(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(Cy);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 hv(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(Cy,JSON.stringify({v:2,positions:r,pins:Array.from(n.keys())}))}catch{}}function rF(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Ty);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 sF(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Ty,JSON.stringify(e))}catch{}}function YE(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Cy)}catch{}try{window.localStorage.removeItem(Ty)}catch{}}}function iF(e,n){const r=e.agents.get(n);if(!r)return;const i=[];for(const d of e.agents.values())d.sessionId===n&&i.push(d);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(d=>({id:d.id,kind:d.kind,label:d.label,parentId:d.parentId,state:d.state,startedAt:d.startedAt,endedAt:d.endedAt,model:d.model,cwd:d.cwd,usage:d.usage,prompts:d.prompts,tools:d.tools.map(m=>({id:m.id,name:m.name,inputPreview:m.inputPreview,startedAt:m.startedAt,endedAt:m.endedAt,ok:m.ok,errorPreview:m.errorPreview,usage:m.usage}))}))},l=JSON.stringify(o,null,2),u=new Blob([l],{type:"application/json"}),c=URL.createObjectURL(u),h=document.createElement("a"),p=(r.label||"session").replace(/[^a-z0-9._-]/gi,"_");h.href=c,h.download=`${Gt}-${p}-${n.slice(0,8)}.json`,document.body.appendChild(h),h.click(),document.body.removeChild(h),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const $v={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},qv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},nj=IC;function oF(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 aF(e,n,r,i,o,l,u,c,h,p,d,m,y,w,E,_,b,S,k){const N=[],T=[],A=new Set;if(l)for(const z of e.agents.values())S.has(z.id)&&XT(z,l)&&A.add(z.id);const M=KT(l,A.size);for(const z of e.agents.values()){if(!S.has(z.id))continue;const C=M&&!A.has(z.id),F=z.exitAt!=null,$=b!=null&&!b.has(z.id),re=[C?"rf-dim":"",F?"rf-exiting":"",$?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,J=u.get(z.id);if(N.push({id:z.id,type:"agent",position:{x:0,y:0},data:{...z,now:n,onOpenContext:k},className:re,...J?{width:J.width,height:J.height}:null}),z.parentId&&S.has(z.parentId)){const W=ry(z.sessionId),Z=l&&!A.has(z.id)&&!A.has(z.parentId),I=F,G=_.size>0&&(_.has(z.id)||_.has(z.parentId)),K=b!=null&&!b.has(z.id)&&!b.has(z.parentId),q=z.state==="active"?2:1.5,Q=G?q+1.5:q,ne=Z||I?.2:K?.12:1,ae=["sess-edge",z.state==="active"?"sess-live":"sess-idle",I?"rf-edge-exiting":"",G?"rf-edge-selected":""].filter(Boolean).join(" ");T.push({id:`e:${z.parentId}->${z.id}`,source:z.parentId,target:z.id,animated:(z.state==="active"||G)&&!Z&&!I,type:"smoothstep",style:{"--session-hue":W,strokeWidth:Q,opacity:ne,transition:"var(--edge-transition)"},className:ae})}}const O=new Map;for(const z of e.agents.values())z.tools.length>0&&O.set(z.id,Math.min(4,z.tools.length));const P=`${w}#lanes:${w5(O)}`,D=N.filter(z=>_$(z.id,o,m,y));if(D.length>0||P!==E.current){if(D.length>0){const z=_5(N,T,{direction:"LR",pinned:o,measured:u,availableWidth:r,availableHeight:i,lanes:O});for(const C of z)BC(C.id,m,y)&&S$(C.id,C.position,m,y);S5(N,m,o,u,new Set(D.map(C=>C.id)),O)}b5(N,m,o,u,O),E.current=P}const L=k5(N,m,o,u,c,!p||d,O);L.length>0&&h(L),su(m,e.agents),su(y,e.agents),su(o,e.agents),su(u,x$(e.agents.values()));const U=[];let V=!1;for(const z of N){let C=o.get(z.id)??m.get(z.id);C||(C=b$(z.id,m,y),V=!0),U.push({...z,position:C})}return V&&(E.current=""),{nodes:U,edges:T}}function lF(){return g.jsx(ny,{children:g.jsx(uF,{})})}function uF(){var Ga,Ya,Ka,Xa;const e=Aa(),n=R.useRef(Rv()),[,r]=R.useState(0),i=R.useCallback(()=>r(H=>H+1),[]),[o,l]=R.useState(()=>new Set),[u,c]=R.useState(null),[h,p]=R.useState(null),d=R.useCallback((H,Y)=>{l(oe=>{if(!Y)return new Set([H]);const de=new Set(oe);return de.has(H)?de.delete(H):de.add(H),de}),c(oe=>Y&&oe===H?oe:H)},[]),m=R.useCallback(()=>{l(new Set),c(null)},[]),[y,w]=R.useState(null),[E,_]=R.useState(null),b=R.useCallback(H=>_(H),[]),[S,k]=R.useState(!1),N=R.useRef(tF()),[T,A]=R.useState(K5);R.useEffect(()=>{X5(T)},[T]);const[M,O]=R.useState(Q5);R.useEffect(()=>{Z5(M)},[M]);const[P,D]=R.useState(J5);R.useEffect(()=>{eF(P)},[P]);const[L,U]=R.useState(()=>{try{const H=window.localStorage.getItem(zE);return H===null?!0:H==="1"}catch{return!0}});R.useEffect(()=>{try{window.localStorage.setItem(zE,L?"1":"0")}catch{}},[L]);const[V,z]=R.useState(null),[C,F]=R.useState(!1),[$,re]=R.useState(0),[J,W]=R.useState(0);R.useEffect(()=>{fetch("/api/sound-hook").then(H=>H.ok?H.json():null).then(H=>{H!=null&&H.ok&&(z(H.enabled===!0),re((H.foreign??[]).filter(Y=>Y.worksHere).length),W(typeof H.parked=="number"?H.parked:0))}).catch(()=>{})},[]);const Z=R.useCallback(async()=>{F(!0);try{const Y=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!V})})).json().catch(()=>null);Y!=null&&Y.ok&&z(Y.enabled===!0),fetch("/api/sound-hook").then(oe=>oe.ok?oe.json():null).then(oe=>{oe!=null&&oe.ok&&(re((oe.foreign??[]).filter(de=>de.worksHere).length),W(typeof oe.parked=="number"?oe.parked:0))}).catch(()=>{})}catch{}finally{F(!1)}},[V]),[I,G]=R.useState(!1),[K,q]=R.useState(null),[Q,ne]=R.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(BE)??""}catch{return""}}),[ae,fe]=R.useState(!1),te=R.useRef(0),[ce,Ce]=R.useState(!1),ve=R.useCallback((H=!1)=>{H&&(te.current=Date.now(),Ce(!0)),fetch(H?"/api/version?refresh=1":"/api/version").then(Y=>Y.ok?Y.json():null).then(Y=>{Y&&q(Y)}).catch(()=>{}).finally(()=>{H&&Ce(!1)})},[]),Re=R.useCallback(()=>{ve(Date.now()-te.current>=Y5)},[ve]);R.useEffect(()=>{ve();const H=window.setInterval(Re,5*6e4),Y=()=>{document.visibilityState==="visible"&&Re()};return document.addEventListener("visibilitychange",Y),()=>{window.clearInterval(H),document.removeEventListener("visibilitychange",Y)}},[ve,Re]),R.useEffect(()=>{I&&ve()},[I,ve]);const ye=(K==null?void 0:K.notice)??null,[Ee,Ye]=R.useState(null),[we,_e]=R.useState(Lv);R.useEffect(()=>{let H=!1;return fetch("/api/health").then(Y=>Y.ok?Y.json():null).then(Y=>{H||(_e(P5(Y)),!(!Y||typeof Y.workspace!="string")&&Ye(Y.workspace))}).catch(()=>{}),()=>{H=!0}},[I]);const Be=R.useRef(we);Be.current=we;const it=ye?`${ye.kind}:${ye.to}`:"",ft=ye!=null&&Q!==it,Ze=R.useCallback(()=>{if(!ye)return;const H=Q===it?"":it;ne(H);try{window.localStorage.setItem(BE,H)}catch{}},[ye,it,Q]),[De,Je]=R.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(UE)??""}catch{return""}}),Xe=K!=null&&K.invokedAs&&K.invokedAs!==Gt?K.invokedAs:null,Ot=Xe!=null&&De!==Xe,lt=R.useCallback(()=>{if(Xe){Je(Xe);try{window.localStorage.setItem(UE,Xe)}catch{}}},[Xe]),Qe=((Ga=K==null?void 0:K.upgrade)==null?void 0:Ga.state)??"idle",Pt=u$(K==null?void 0:K.upgrade),zt=R.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}ve()},[ve]);R.useEffect(()=>{if(Qe!=="running")return;const H=window.setInterval(ve,3e3);return()=>window.clearInterval(H)},[Qe,ve]);const et=R.useCallback(async()=>{var oe;const H=K==null?void 0:K.command;if(!H)return;let Y=!1;try{Y=await Promise.race([((oe=navigator.clipboard)==null?void 0:oe.writeText(H).then(()=>!0))??Promise.resolve(!1),new Promise(de=>window.setTimeout(()=>de(!1),500))])}catch{Y=!1}if(!Y)try{const de=document.createElement("textarea");de.value=H,de.setAttribute("readonly",""),de.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(de),de.select(),Y=document.execCommand("copy"),de.remove()}catch{Y=!1}Y&&(fe(!0),window.setTimeout(()=>fe(!1),1600))},[K==null?void 0:K.command]),bt=R.useCallback(()=>{A(H=>(H||U(!1),!H))},[]),ht=R.useCallback(()=>{U(H=>(H||A(!1),!H))},[]),[vt,hn]=R.useState(!1),[Yt,Lt]=R.useState(0),bn=R.useRef(null),[gr,Sn]=R.useState(!1),Bt=R.useRef(null),[Fn,pn]=R.useState(0),vr=R.useRef(C$()),[Hr,xi]=R.useState(!1),Wr=R.useCallback(()=>{const H=vr.current,Y=H.setPaused(!H.paused);for(const oe of Y)n.current=Ux(n.current,oe);xi(H.paused)},[]),[ut,_i]=R.useState(Date.now()),[mn,Is]=R.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(WE)!=="0"}catch{return!0}}),yr=R.useCallback(()=>{Is(H=>{const Y=!H;try{window.localStorage.setItem(WE,Y?"1":"0")}catch{}return Y})},[]),[zn,kn]=R.useState(!1),[Vr,Gr]=R.useState("restart"),[Yr,bi]=R.useState(null),sr=R.useRef(!1),Ms=R.useRef(null),En=R.useRef(0),wr=R.useCallback(async H=>{if(sr.current)return;const Y=(H==null?void 0:H.upgrade)===!0;sr.current=!0,Ms.current=Pt;const oe=++En.current;Gr(Y?"npx":"restart"),kn(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(ye==null?void 0:ye.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:Y})})}catch{}window.setTimeout(()=>{if(En.current===oe&&sr.current){sr.current=!1,kn(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},Y?18e4:3e4)},[ye==null?void 0:ye.to,Pt]),Os=R.useRef(null);R.useEffect(()=>{let H=!1;for(const oe of n.current.agents.values())if(oe.state==="active"){H=!0;break}const Y=d$({enabled:mn,kind:ye==null?void 0:ye.kind,canRestart:(K==null?void 0:K.canRestart)===!0,busy:H,idleSince:Os.current,now:ut});Os.current=Y.idleSince,Y.restart&&wr()},[mn,ye==null?void 0:ye.kind,K==null?void 0:K.canRestart,ut,wr]),R.useEffect(()=>{const H=K==null?void 0:K.running;let Y=null,oe=null;try{Y=window.sessionStorage.getItem("agent-dag.restartPending"),oe=window.sessionStorage.getItem(VE)}catch{return}const de=l$({bundle:"1.35.32",running:H,pending:Y,lastTried:oe});if(de==="reload"){try{window.sessionStorage.setItem(VE,H??"")}catch{return}window.location.reload();return}if(de!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}sr.current=!1,kn(!1),bi(H??null);const xe=window.setTimeout(()=>bi(null),6e3);return()=>window.clearTimeout(xe)},[K==null?void 0:K.running]),R.useEffect(()=>{if(zn&&c$({asked:Ms.current,reported:Pt})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}sr.current=!1,kn(!1)}},[zn,Pt]);const Ps=R.useRef(nF()).current;R.useRef(!1);const jt=R.useRef(new Map(Ps.positions.filter(([H])=>Ps.pins.includes(H)))),xr=R.useRef(null),_r=R.useState(()=>rF())[0],[Kt,Kr]=R.useState(""),[Si,nt]=R.useState(()=>new Set),[br,Xr]=R.useState(I$),[Ls,Qr]=R.useState(!1),Zr=R.useRef(null);R.useEffect(()=>{document.documentElement.dataset.theme=br;try{window.localStorage.setItem(HC,br)}catch{}},[br]),R.useEffect(()=>{if(!_r)return;const H=window.setTimeout(()=>{try{e.setViewport(_r,{duration:0})}catch{}},60);return()=>window.clearTimeout(H)},[e,_r]);const $s=R.useRef(!0);R.useEffect(()=>{const H=new EventSource("/events"),Y=N$(i,{now:()=>Date.now(),setTimeout:(oe,de)=>window.setTimeout(oe,de),clearTimeout:oe=>window.clearTimeout(oe)});return H.addEventListener("open",()=>{G(!0),Qr(!0)}),H.addEventListener("error",()=>G(!1)),H.addEventListener("replay-end",()=>{$s.current=!1,Y.flush()}),H.addEventListener("hook",oe=>{try{const de=JSON.parse(oe.data);if(!vr.current.accept(de))return;n.current=Ux(n.current,de),de.replay===!0||$s.current||Date.now()-de.receivedAt>3e4?Y.replay():Y.live()}catch{}}),()=>{H.close(),Y.cancel()}},[i]),R.useEffect(()=>{const H=setInterval(()=>{const Y=Date.now();_i(Y);let oe=CP(n.current,Y,Bx);TP(n.current,Y,Bx)&&(oe=!0),EP(n.current,Y,H5,W5)&&(oe=!0),NP(n.current,Y,V5,G5)&&(oe=!0),oe&&i()},250);return()=>clearInterval(H)},[i]);const ir=R.useRef(null),St=R.useRef(0),qs=420,pt=R.useCallback((H=500)=>{try{const Se=document.querySelector(".canvas-wrap"),Pe=Array.from(document.querySelectorAll(".react-flow__node")).filter(wt=>wt.offsetWidth>0);if(!Se||Pe.length===0)return;const Fe=Se.getBoundingClientRect(),Ge=e.getViewport();if(!Number.isFinite(Ge.zoom)||Ge.zoom<=0)return;const We=wt=>(wt-Fe.left-Ge.x)/Ge.zoom,ze=wt=>(wt-Fe.top-Ge.y)/Ge.zoom,Tn=Pe.map(wt=>wt.getBoundingClientRect()),Ys=Math.min(...Tn.map(wt=>We(wt.left))),Ao=Math.max(...Tn.map(wt=>We(wt.right))),Ks=Math.min(...Tn.map(wt=>ze(wt.top))),Io=Math.max(...Tn.map(wt=>ze(wt.bottom))),Qa=Ao-Ys,us=Io-Ks;if(!(Qa>0&&us>0))return;const Zt=Math.max(.2,Math.min(1,(Fe.width-160)/(Qa+qs)*.86,(Fe.height-160)/us*.86));e.setViewport({x:80-Ys*Zt,y:Math.max(80,(Fe.height-us*Zt)/2)-Ks*Zt,zoom:Zt},{duration:H}),St.current=Date.now(),window.setTimeout(()=>{try{const wt={x:80-Ys*Zt,y:Math.max(80,(Fe.height-us*Zt)/2)-Ks*Zt,zoom:Zt},Mo=e.getViewport();(Math.abs(Mo.zoom-Zt)>.01||Math.abs(Mo.x-wt.x)>2)&&e.setViewport(wt,{duration:0})}catch{}},H+60)}catch{}},[e]),ko=R.useRef(""),Eo=R.useRef(null),Da=R.useRef(0),Sr=R.useCallback(()=>{Da.current=Date.now()},[]),Jr="agent-dag.autoFitDisabled",gn=R.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Jr)==="1"}catch{return!1}})()),[Ds,Fa]=R.useState(gn.current),za=R.useCallback(()=>{if(!gn.current){gn.current=!0,Fa(!0);try{window.localStorage.setItem(Jr,"1")}catch{}}},[]),No=R.useCallback(()=>{gn.current=!1,Fa(!1);try{window.localStorage.removeItem(Jr)}catch{}pt(400)},[e,pt]);R.useEffect(()=>{const H=setInterval(()=>{if(gn.current||Date.now()-Da.current<800)return;const Y=n.current,oe=Date.now(),de=[];for(const We of Y.agents.values())Pv(We,oe)&&de.push({id:We.id});if(de.length===0)return;const xe=e.getViewport(),Se=window.innerWidth-360,Pe=window.innerHeight-52;let Fe=!1,Ge=!1;for(const{id:We}of de){const ze=or.current.get(We),Tn=jt.current.get(We)??Xt.current.get(We);if(!ze||!Tn)continue;Ge=!0;const Ys=Tn.x*xe.zoom+xe.x,Ao=Tn.y*xe.zoom+xe.y,Ks=(Tn.x+ze.width)*xe.zoom+xe.x,Io=(Tn.y+ze.height)*xe.zoom+xe.y;if(Ks>0&&Ys<Se&&Io>0&&Ao<Pe){Fe=!0;break}}Ge&&!Fe&&pt(600)},1500);return()=>clearInterval(H)},[e]);const ki=R.useRef(!1),or=R.useRef(new Map),es=R.useRef(0),nc=R.useCallback(H=>{const Y=or.current;let oe=!1;for(const de of H.nodeInternals.values()){const xe=de.width,Se=de.height;if(xe==null||Se==null)continue;const Pe=Y.get(de.id);Pe?(Math.abs(Pe.height-Se)>4||Math.abs(Pe.width-xe)>4)&&(Y.set(de.id,{width:xe,height:Se}),oe=!0):(Y.set(de.id,{width:xe,height:Se}),oe=!0)}return oe&&(es.current+=1),es.current},[]),Ei=Ke(nc),[He,Ba]=R.useState(0);R.useEffect(()=>{let H=0;const Y=()=>{const de=or.current;let xe=!1;for(const Se of document.querySelectorAll(".react-flow__node[data-id]")){const Pe=Se.getAttribute("data-id");if(!Pe)continue;const Fe=Se.offsetWidth,Ge=Se.offsetHeight;if(!Fe||!Ge)continue;const We=de.get(Pe);(!We||Math.abs(We.width-Fe)>4||Math.abs(We.height-Ge)>4)&&(de.set(Pe,{width:Fe,height:Ge}),xe=!0)}xe&&Ba(Se=>Se+1)};if(ki.current)return;let oe=0;return document.visibilityState==="hidden"?oe=window.setTimeout(Y,32):H=requestAnimationFrame(Y),()=>{cancelAnimationFrame(H),window.clearTimeout(oe)}});const Xt=R.useRef(new Map(Ps.positions)),Co=R.useRef(new Set),Ni=R.useRef(""),kr=R.useMemo(()=>{const H=[];for(const Y of n.current.agents.values())Pv(Y,ut)&&H.push(Y.id+(Y.parentId?`>${Y.parentId}`:""));return H.sort(),`${H.join("|")}#sv${Ei}.${He}`},[n.current,n.current.lastSeq,ut,Ei,He]),ts=R.useRef(null);R.useEffect(()=>(ts.current!=null&&window.clearTimeout(ts.current),ts.current=window.setTimeout(()=>{hv(Xt.current,jt.current)},1500),()=>{ts.current!=null&&window.clearTimeout(ts.current)}),[kr]),R.useEffect(()=>{if(ko.current===kr)return;const H=ko.current;if(ko.current=kr,!H||gn.current)return;Date.now()-St.current>1200&&pt(400),ir.current&&window.clearTimeout(ir.current),ir.current=window.setTimeout(()=>{gn.current||pt(500)},280)},[kr,e,pt]);const Fs=R.useMemo(()=>{if(o.size===0)return null;const H=new Set;for(const Y of o){const oe=oF(n.current,Y);if(oe)for(const de of oe)H.add(de)}return H.size>0?H:null},[n.current,n.current.lastSeq,o]),Nn=R.useMemo(()=>N5(n.current,ut),[n.current,n.current.lastSeq,ut]),Bn=R.useRef(null),[vn,Un]=R.useState({w:0,h:0});R.useEffect(()=>{const H=Bn.current;if(!H||typeof ResizeObserver>"u")return;const Y=new ResizeObserver(oe=>{var xe;const de=(xe=oe[0])==null?void 0:xe.contentRect;de&&Un(Se=>Math.abs(Se.w-de.width)>40||Math.abs(Se.h-de.height)>40?{w:de.width,h:de.height}:Se)});return Y.observe(H),Un({w:H.clientWidth,h:H.clientHeight}),()=>Y.disconnect()},[]);const zs=R.useCallback(H=>{var oe,de;const Y=H.target;!(Y!=null&&Y.closest)||Y.closest(B5)!==H.currentTarget||(H.preventDefault(),(de=(oe=document.activeElement)==null?void 0:oe.blur)==null||de.call(oe))},[]),Bs=R.useRef(new Map),[Hn,rc]=R.useState(!1);R.useEffect(()=>{const H=window.setTimeout(()=>rc(!0),2500);return()=>window.clearTimeout(H)},[]);const[Ua,Er]=R.useState(!1),ar=R.useRef(null),[Ci,Us]=R.useState(!1),Ha=R.useCallback(()=>{ar.current&&(window.clearTimeout(ar.current),ar.current=null),Er(!1)},[]),sc=R.useCallback(H=>{H.length!==0&&queueMicrotask(()=>{Er(!0),ar.current&&window.clearTimeout(ar.current),ar.current=window.setTimeout(()=>Er(!1),U5+80)})},[]);R.useEffect(()=>()=>{ar.current&&window.clearTimeout(ar.current)},[]);const ns=vn.w>0?vn.w*.92:0,rs=vn.h>0?vn.h:0,{nodes:Qt,edges:Ti}=R.useMemo(()=>aF(n.current,ut,ns,rs,jt.current,Kt,or.current,Bs.current,sc,Hn,Ci,Xt.current,Co.current,kr,Ni,o,Fs,Nn,b),[n.current,n.current.lastSeq,ut,ns,rs,Hn,Ci,Kt,kr,o,Fs,Nn,b,Yt]),Wa=R.useMemo(()=>{const H=new Map;for(const oe of Qt){const de=oe.data;if(!(de!=null&&de.sessionId)||de.exitAt!=null)continue;const xe=oe.width,Se=oe.height;if(xe==null||Se==null)continue;const Pe=oe.position.x,Fe=oe.position.y,Ge=Pe+xe,We=Fe+Se,ze=H.get(de.sessionId);ze?(ze.minX=Math.min(ze.minX,Pe),ze.minY=Math.min(ze.minY,Fe),ze.maxX=Math.max(ze.maxX,Ge),ze.maxY=Math.max(ze.maxY,We)):H.set(de.sessionId,{minX:Pe,minY:Fe,maxX:Ge,maxY:We})}const Y=[];for(const[oe,de]of H){const xe=de.maxX-de.minX+lu*2,Se=de.maxY-de.minY+lu*2;Y.push({id:`group:${oe}`,type:GT,position:{x:de.minX-lu,y:de.minY-lu},data:{sessionId:oe,w:xe,h:Se},width:xe,height:Se,style:{width:xe,height:Se},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return Y},[Qt,ut]),ic=R.useMemo(()=>{const H=[...Wa,...Qt],Y=Bt.current;return!Y||Y.size===0?H:H.map(oe=>{const de=Y.get(oe.id);return de?{...oe,position:de}:oe})},[Wa,Qt,Fn]),Nr=R.useMemo(()=>{if(!Kt)return null;const H=new Set;for(const Y of n.current.agents.values())Nn.has(Y.id)&&XT(Y,Kt)&&H.add(Y.id);return H},[n.current,n.current.lastSeq,Kt,Nn]),Cn=R.useMemo(()=>q5(Kt,(Nr==null?void 0:Nr.size)??0,Nn.size),[Kt,Nr,Nn]),ss=R.useMemo(()=>{const H=new Set;for(const Y of n.current.agents.values())for(const oe of Y.tools)H.add(nj(oe.name));return Object.keys($v).filter(Y=>H.has(Y))},[n.current,n.current.lastSeq]);R.useEffect(()=>{if(ss.length<=1){Sn(!1);return}let H=0;const Y=()=>{const oe=bn.current;if(oe&&!document.hidden){const de=oe.getBoundingClientRect(),xe=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Pe=>Pe.getBoundingClientRect()),Se=T5(de,xe,8);Sn(Pe=>Pe===Se?Pe:Se)}H=window.setTimeout(Y,300)};return Y(),()=>window.clearTimeout(H)},[ss.length]);const is=R.useMemo(()=>{const H=new Map;for(const oe of n.current.agents.values())for(const de of oe.tools){if(!de.name.startsWith("mcp__"))continue;const xe=de.name.slice(5),Se=xe.indexOf("__"),Pe=Se>0?xe.slice(0,Se):xe;H.set(Pe,(H.get(Pe)??0)+1)}const Y=[];for(const[oe,de]of H){let xe=5381;for(let Se=0;Se<oe.length;Se++)xe=(xe<<5)+xe^oe.charCodeAt(Se);Y.push({server:oe,count:de,hue:Math.abs(xe)%360})}return Y.sort((oe,de)=>de.count-oe.count),Y},[n.current,n.current.lastSeq]),lr=R.useCallback(H=>{nt(Y=>{const oe=new Set(Y);return oe.has(H)?oe.delete(H):oe.add(H),oe})},[]),Rt=u?n.current.agents.get(u):null,os=h?Array.from(n.current.agents.values()).flatMap(H=>H.tools).find(H=>H.id===h)??null:null,To=R.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Rv(),jt.current.clear(),or.current.clear(),Xt.current.clear(),Ni.current="",YE(),m(),i()},[i,m]),Hs=R.useRef(S);Hs.current=S;const Ws=R.useRef(!1);Ws.current=os!=null||vt||E!=null||y!=null;const Vs=R.useCallback(H=>{const Y=h$(H,{confirmOpen:Hs.current,modalOpen:Ws.current});Y==="confirm"?k(!0):Y==="clear"&&(k(!1),To())},[To]),$t=R.useCallback(()=>{jt.current.clear(),Xt.current.clear(),Ni.current="",YE(),i(),window.setTimeout(()=>pt(500),80)},[i,e,pt]),Cr=R.useCallback(()=>pt(500),[pt]),as=R.useRef(Qt);as.current=Qt;const ls=R.useRef(u);ls.current=u;const jo=R.useCallback(H=>{const Y=as.current,oe=m$(Y.map(Se=>({id:Se.id,x:Se.position.x,y:Se.position.y})),ls.current,H),de=oe?Y.find(Se=>Se.id===oe):void 0;if(!de)return;const xe=FE(document.activeElement);d(de.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[de]})}catch{}St.current=Date.now(),xe&&z5(de.id)},30)},[d,e]),ji=R.useCallback(H=>{d(H,!1),window.setTimeout(()=>{try{const Y=as.current.find(oe=>oe.id===H);Y&&e.fitView({padding:.3,duration:500,nodes:[Y]}),St.current=Date.now()}catch{}},60)},[d,e]);R.useEffect(()=>{const H=Y=>{var Fe,Ge,We;const oe=Y.target,de={tagName:oe==null?void 0:oe.tagName,isContentEditable:oe==null?void 0:oe.isContentEditable,role:(Fe=oe==null?void 0:oe.getAttribute)==null?void 0:Fe.call(oe,"role"),type:oe==null?void 0:oe.type};if(Y.key==="Escape"){const ze=GP({overlayOpen:Cu.depth()>0,typing:sy(de)});ze==="dismiss"?Cu.dismissTop():ze==="blur"?oe==null||oe.blur():(w$(de)&&(oe==null||oe.blur()),m());return}if(jC(Y))return;const xe=FE(oe)?(Ge=oe==null?void 0:oe.getAttribute)==null?void 0:Ge.call(oe,"data-id"):null,Se=xe&&as.current.some(ze=>ze.id===xe)?xe:null,Pe=v$(Y,Se);if(Pe.kind==="activate"){Y.preventDefault(),d(Pe.nodeId,Pe.additive);return}if(Pe.kind!=="node"&&!(Pe.nodeId==null&&tL(de))){if(Y.key==="/"){Y.preventDefault(),(We=Zr.current)==null||We.focus();return}Y.key===" "&&(Y.preventDefault(),Wr()),(Y.key==="c"||Y.key==="C")&&Vs("shortcut"),(Y.key==="r"||Y.key==="R")&&$t(),(Y.key==="f"||Y.key==="F")&&Cr(),(Y.key==="l"||Y.key==="L")&&bt(),(Y.key==="h"||Y.key==="H")&&hn(ze=>!ze),(Y.key==="u"||Y.key==="U")&&D(ze=>!ze),(Y.key==="a"||Y.key==="A")&&Be.current.claude&&ht(),(Y.key==="j"||Y.key==="J")&&jo(1),(Y.key==="k"||Y.key==="K")&&jo(-1),(Y.key==="t"||Y.key==="T")&&Xr(ze=>ze==="dark"?"light":"dark")}};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[Vs,$t,Cr,m,d,jo,Wr]);const Tr=n.current.agents.size,Gs=new Set(Array.from(n.current.agents.values()).map(H=>H.sessionId)).size,tn=R.useMemo(()=>l3(n.current.agents.values()),[n.current,n.current.lastSeq]),Ro=R.useMemo(()=>u3(n.current.agents.values()),[n.current,n.current.lastSeq]),Va=R.useRef(null);R.useEffect(()=>{const H=M$({waiting:tn.length,running:Ro}),Y=Va.current;if(Va.current=H,(Y==null?void 0:Y.title)!==H.title&&(document.title=H.title),(Y==null?void 0:Y.icon)!==H.icon){const oe=document.querySelector('link[rel="icon"]');oe&&(oe.href=O$[H.icon])}},[tn.length,Ro]);const[oc,ac]=R.useState(""),Ri=L$(tn);R.useEffect(()=>{ac(H=>$$(H,Ri))},[Ri]);const nn=R.useMemo(()=>{let H=0,Y=0,oe=0,de=0,xe=0,Se=0,Pe=0,Fe=0,Ge=0;for(const We of n.current.agents.values()){H+=We.usage.inputTokens,Y+=We.usage.outputTokens,oe+=We.usage.cacheReadTokens,de+=We.usage.cacheCreateTokens;const ze=dn(We.usage,We.model);xe+=ze.total,Se+=ze.input,Pe+=ze.output,Fe+=ze.cacheRead,Ge+=ze.cacheWrite}return{inT:H,outT:Y,cacheR:oe,cacheC:de,sum:H+Y,cost:{total:xe,input:Se,output:Pe,cacheRead:Fe,cacheWrite:Ge}}},[n.current,n.current.lastSeq]);return g.jsxs("div",{className:"app",children:[g.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),g.jsxs("header",{className:"topbar",children:[g.jsxs("div",{className:"brand",children:[g.jsx("span",{className:"logo"}),g.jsx("h1",{children:Gt}),ye?g.jsxs("button",{type:"button",className:"v stale",onClick:Ze,"aria-label":M5({...ye,open:ft}),title:ye.kind==="restart"?`Running v${ye.from}; v${ye.to} is installed on disk. Restart to pick it up.`:`Running v${ye.from}; v${ye.to} is on npm.`,children:["v",ye.from,g.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const H={running:(K==null?void 0:K.running)??"1.35.32",latest:K==null?void 0:K.latest,latestPending:K==null?void 0:K.latestPending,checkedAgo:K!=null&&K.checkedAt?Iv(ut-K.checkedAt):null,checkDisabled:K==null?void 0:K.checkDisabled,checking:ce};return g.jsxs("button",{type:"button",className:ce?"v checking":"v",onClick:()=>ve(!0),"aria-busy":ce||void 0,"aria-label":I5(H),title:A5(H),children:["v",H.running]})})()]}),Rt&&(()=>{const H=dn(Rt.usage,Rt.model),Y=Math.max(0,((Rt.endedAt??ut)-Rt.startedAt)/1e3),oe=Rt.state==="active"?Eu(H.total,Y):null,de=o.size-1;return g.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${Rt.label}`,onClick:()=>{try{const xe=Qt.find(Se=>Se.id===Rt.id);xe&&e.fitView({padding:.35,duration:500,nodes:[xe]}),St.current=Date.now()}catch{}},children:[g.jsx("span",{className:`state-pill state-${Rt.state}`,children:Rt.state==="active"?"live":Rt.state}),g.jsx("span",{className:"selected-label",children:Rt.label}),H.total>0&&g.jsxs("span",{className:"selected-cost",children:[qe(H.total),oe?g.jsxs("span",{className:"selected-rate",children:[" · ",oe]}):null]}),de>0&&g.jsxs("span",{className:"selected-extra",children:["+",de]}),g.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:xe=>{xe.stopPropagation(),m()},children:"×"})]})})(),g.jsxs("div",{className:"actions",children:[g.jsxs("div",{className:"search",children:[g.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),g.jsx("input",{ref:Zr,type:"text",placeholder:D5,value:Kt,onChange:H=>Kr(H.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),Kt?g.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>Kr(""),children:"×"}):g.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"}),Cn.count&&g.jsx("span",{className:`search-count${Cn.empty?" none":""}`,"aria-live":"polite",title:`${Cn.count} agents on the canvas match “${Kt}”`,children:Cn.count})]}),g.jsxs("span",{className:"status",children:[(()=>{const H=L5({connected:I,paused:Hr,held:vr.current.size});return g.jsx("span",{className:`pill ${H.tone}`,title:H.title,children:H.label})})(),g.jsxs("span",{className:"stat",title:H$(we),children:[g.jsx("span",{className:"count",children:Gs}),g.jsx("span",{className:"lbl",children:"sessions"})]}),g.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[g.jsx("span",{className:"count",children:Tr}),g.jsx("span",{className:"lbl",children:"agents"})]}),g.jsxs("span",{className:"stat",title:W$(we),children:[g.jsx("span",{className:"count",children:n.current.totalEvents}),g.jsx("span",{className:"lbl",children:"events"})]}),nn.sum>0&&g.jsxs("span",{className:"stat",title:`in:${nn.inT.toLocaleString()} out:${nn.outT.toLocaleString()} cache-r:${nn.cacheR.toLocaleString()} cache-c:${nn.cacheC.toLocaleString()}`,children:[g.jsx("span",{className:"count",children:Nt(nn.sum)}),g.jsx("span",{className:"lbl",children:"tokens"})]}),is.length>0&&g.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
|
|
72
|
+
${n.parked} of your own sound hook${n.parked>1?"s were":" was"} set aside so this switch actually controls the sound. Nothing was deleted — shift-click to put ${n.parked>1?"them":"it"} back.`:"";return r+i+o+l}function VC(e){const n=new Map;for(const r of e)for(const i of r.agents??[]){if(!i||typeof i.agent!="string"||i.agent==="")continue;const o=n.get(i.agent)??{id:i.agent,cost:0,tokens:0};o.cost+=Number.isFinite(i.totalCost)?i.totalCost:0,o.tokens+=Number.isFinite(i.totalTokens)?i.totalTokens:0,n.set(i.agent,o)}return[...n.values()].sort((r,i)=>i.cost-r.cost||r.id.localeCompare(i.id))}function Y$(e){const n=VC([{agents:e}]);return n.length<2?null:n.map(r=>`${ly(r.id)} ${qe(r.cost)}`).join(" · ")}function v_(e){switch(e.toLowerCase()){case"claude":return"#c4b5fd";case"codex":return"#fdba74";case"gemini":return"#a5b4fc";case"copilot":return"#86efac";default:return"#94a3b8"}}function K$(e,n){if(!(n>0)||!(e>0))return"0%";const r=e/n*100;return r<.1?"<0.1%":`${r.toFixed(1)}%`}function iu(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 X$=[7,14,30,90];function Q$(e){const[n,r]=R.useState(null),[i,o]=R.useState(!1),l=R.useRef(q$()).current,u=(c=!1)=>{const h=l.begin(),p=e;o(!0);const m=`/api/ccusage?since=${D$(p)}${c?"&refresh=1":""}`;fetch(m).then(y=>y.json()).then(y=>{h()&&r({range:p,resp:y})}).catch(()=>{h()&&r({range:p,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{h()&&o(!1)})};return R.useEffect(()=>(u(!1),()=>l.cancel()),[e]),{landed:n,loading:i,reload:()=>u(!0)}}function Z$({onClose:e,providers:n}){var O;const[r,i]=R.useState(30),[o,l]=R.useState(null),{landed:u,loading:c,reload:h}=Q$(r),p=R.useRef(null),d=yo(e,{focusRef:p}),m=F$({loading:c,want:r,answer:u&&{range:u.range,ok:u.resp.ok===!0,days:((O=u.resp.days)==null?void 0:O.length)??0}}),y=m.phase==="chart"?u.resp.days??[]:[],w=R.useMemo(()=>y.reduce((P,D)=>Math.max(P,D.totalCost),0),[y]),{totalCost:E,totalTok:_,inOut:b,cacheRead:S,modelCosts:k}=R.useMemo(()=>{let P=0,D=0,L=0,U=0;const V=new Map;for(const z of y){P+=z.totalCost,D+=z.totalTokens,L+=z.inputTokens+z.outputTokens,U+=z.cacheReadTokens;for(const C of z.modelBreakdowns)V.set(C.modelName,(V.get(C.modelName)??0)+C.cost)}return{totalCost:P,totalTok:D,inOut:L,cacheRead:U,modelCosts:V}},[y]),N=R.useMemo(()=>Array.from(k.entries()).sort((P,D)=>D[1]-P[1]),[k]),T=R.useMemo(()=>VC(y),[y]),A=T.length>1,M=o?y.find(P=>P.period===o)??null:null;return g.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:g.jsxs("div",{ref:d,className:"uh-modal",onClick:P=>P.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Usage history",children:[g.jsxs("header",{className:"uh-head",children:[g.jsxs("div",{className:"uh-titlewrap",children:[g.jsx("div",{className:"uh-title",children:"Usage history"}),g.jsx("div",{className:"uh-sub",children:B$(n,T.map(P=>P.id))})]}),g.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:X$.map(P=>g.jsxs("button",{type:"button","aria-pressed":r===P,className:`uh-range-btn${r===P?" on":""}`,onClick:()=>{i(P),l(null)},children:[P,"d"]},P))}),g.jsx("button",{className:"btn icon-btn uh-reload",onClick:h,disabled:c,title:"Re-run ccusage","aria-label":"Reload",children:c?"…":"↻"}),g.jsx("button",{ref:p,className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),m.phase==="busy"?g.jsx("div",{className:"uh-status","aria-busy":"true",children:u?"running ccusage…":"running ccusage… (first run downloads the package)"}):m.phase==="error"?g.jsxs("div",{className:"uh-status uh-err",title:go(u.resp)||void 0,children:[F3(u.resp,"ccusage did not report usage"),g.jsx("div",{children:g.jsx("button",{className:"btn uh-retry",onClick:h,disabled:c,children:c?"trying…":"Try again"})})]}):m.phase==="empty"?g.jsx("div",{className:`uh-status${m.stale?" uh-stale":""}`,"aria-busy":m.stale||void 0,children:"no usage in this range"}):g.jsxs("div",{className:m.stale?"uh-stale":void 0,"aria-busy":m.stale||void 0,children:[g.jsxs("div",{className:"uh-totals",children:[g.jsx(ou,{label:"total cost",val:qe(E),accent:!0}),g.jsx(ou,{label:"tokens",val:Nt(_)}),g.jsx(ou,{label:"input+output",val:Nt(b)}),g.jsx(ou,{label:"cache reads",val:Nt(S)})]}),A&&g.jsxs("div",{className:"uh-agents",role:"group","aria-label":"Cost by CLI",children:[g.jsx("div",{className:"uh-agent-bar","aria-hidden":"true",children:T.map(P=>g.jsx("span",{className:"uh-agent-seg",style:{width:`${E>0?P.cost/E*100:0}%`,background:v_(P.id)}},P.id))}),g.jsx("div",{className:"uh-agent-keys",children:T.map(P=>g.jsxs("span",{className:"uh-agent-key",title:`${P.id} · ${Nt(P.tokens)} tokens`,children:[g.jsx("span",{className:"uh-legend-dot",style:{background:v_(P.id)}}),ly(P.id),g.jsx("span",{className:"uh-agent-cost",children:qe(P.cost)}),g.jsx("span",{className:"uh-agent-share",children:K$(P.cost,E)})]},P.id))})]}),g.jsx("div",{className:"uh-chart",role:"group","aria-label":"Daily cost by model",children:y.map(P=>{const D=w>0?P.totalCost/w*100:0,L=P.period===o,U=`${P.period}, ${qe(P.totalCost)}`;return g.jsxs("button",{className:`uh-bar-col${L?" sel":""}`,onClick:()=>l(L?null:P.period),"aria-pressed":L,"aria-label":U,title:`${P.period} · ${qe(P.totalCost)}`,style:{flexBasis:`${100/y.length}%`},children:[g.jsx("div",{className:"uh-bar",style:{height:`${Math.max(D,P.totalCost>0?2:0)}%`},children:P.modelBreakdowns.slice().sort((V,z)=>z.cost-V.cost).map(V=>{const z=P.totalCost>0?V.cost/P.totalCost*100:0;return g.jsx("div",{className:"uh-bar-seg",style:{height:`${z}%`,background:iu(V.modelName)}},V.modelName)})}),g.jsx("span",{className:"uh-bar-label",children:P.period.slice(5)})]},P.period)})}),g.jsx("div",{className:"uh-legend",children:N.map(([P,D])=>g.jsxs("span",{className:"uh-legend-item",title:P,children:[g.jsx("span",{className:"uh-legend-dot",style:{background:iu(P)}}),Rs(P)," ",g.jsx("span",{className:"uh-legend-cost",children:qe(D)})]},P))}),M&&g.jsxs("div",{className:"uh-detail",children:[g.jsxs("div",{className:"uh-detail-head",children:[g.jsx("span",{className:"uh-detail-date",children:M.period}),g.jsx("span",{className:"uh-detail-cost",children:qe(M.totalCost)}),(()=>{var L,U;const D=Y$(M.agents)??((U=(L=M.metadata)==null?void 0:L.agents)!=null&&U.length?M.metadata.agents.join(" · "):null);return D?g.jsx("span",{className:"uh-detail-agents",title:D,children:D}):null})()]}),g.jsxs("div",{className:"uh-detail-mini",children:[g.jsx(au,{label:"input",val:Nt(M.inputTokens)}),g.jsx(au,{label:"output",val:Nt(M.outputTokens)}),g.jsx(au,{label:"cache write",val:Nt(M.cacheCreationTokens)}),g.jsx(au,{label:"cache read",val:Nt(M.cacheReadTokens)})]}),g.jsx("div",{className:"uh-detail-models",children:M.modelBreakdowns.slice().sort((P,D)=>D.cost-P.cost).map(P=>{const D=M.totalCost>0?P.cost/M.totalCost*100:0;return g.jsxs("div",{className:"uh-model-row",title:P.modelName,children:[g.jsxs("span",{className:"uh-model-name",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:iu(P.modelName)}}),g.jsx("span",{className:"uh-model-label",children:Rs(P.modelName)})]}),g.jsx("span",{className:"uh-model-bar",children:g.jsx("span",{className:"uh-model-bar-fill",style:{width:`${D}%`,background:iu(P.modelName)}})}),g.jsx("span",{className:"uh-model-cost",children:qe(P.cost)})]},P.modelName)})})]})]})]})})}function ou({label:e,val:n,accent:r}){return g.jsxs("div",{className:"uh-stat",children:[g.jsx("span",{className:`uh-stat-val${r?" accent":""}`,children:n}),g.jsx("span",{className:"uh-stat-label",children:e})]})}function au({label:e,val:n}){return g.jsxs("div",{className:"uh-ministat",children:[g.jsx("span",{className:"uh-ministat-val",children:n}),g.jsx("span",{className:"uh-ministat-label",children:e})]})}function uy(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 Kd,y_;function J$(){if(y_)return Kd;y_=1;function e(){this.__data__=[],this.size=0}return Kd=e,Kd}var Xd,w_;function wo(){if(w_)return Xd;w_=1;function e(n,r){return n===r||n!==n&&r!==r}return Xd=e,Xd}var Qd,x_;function qu(){if(x_)return Qd;x_=1;var e=wo();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 Zd,__;function eq(){if(__)return Zd;__=1;var e=qu(),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 Zd=i,Zd}var Jd,b_;function tq(){if(b_)return Jd;b_=1;var e=qu();function n(r){var i=this.__data__,o=e(i,r);return o<0?void 0:i[o][1]}return Jd=n,Jd}var ef,S_;function nq(){if(S_)return ef;S_=1;var e=qu();function n(r){return e(this.__data__,r)>-1}return ef=n,ef}var tf,k_;function rq(){if(k_)return tf;k_=1;var e=qu();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 tf=n,tf}var nf,E_;function Du(){if(E_)return nf;E_=1;var e=J$(),n=eq(),r=tq(),i=nq(),o=rq();function l(u){var c=-1,h=u==null?0:u.length;for(this.clear();++c<h;){var p=u[c];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=i,l.prototype.set=o,nf=l,nf}var rf,N_;function sq(){if(N_)return rf;N_=1;var e=Du();function n(){this.__data__=new e,this.size=0}return rf=n,rf}var sf,C_;function iq(){if(C_)return sf;C_=1;function e(n){var r=this.__data__,i=r.delete(n);return this.size=r.size,i}return sf=e,sf}var of,T_;function oq(){if(T_)return of;T_=1;function e(n){return this.__data__.get(n)}return of=e,of}var af,j_;function aq(){if(j_)return af;j_=1;function e(n){return this.__data__.has(n)}return af=e,af}var lf,R_;function GC(){if(R_)return lf;R_=1;var e=typeof Hl=="object"&&Hl&&Hl.Object===Object&&Hl;return lf=e,lf}var uf,A_;function rr(){if(A_)return uf;A_=1;var e=GC(),n=typeof self=="object"&&self&&self.Object===Object&&self,r=e||n||Function("return this")();return uf=r,uf}var cf,I_;function xo(){if(I_)return cf;I_=1;var e=rr(),n=e.Symbol;return cf=n,cf}var df,M_;function lq(){if(M_)return df;M_=1;var e=xo(),n=Object.prototype,r=n.hasOwnProperty,i=n.toString,o=e?e.toStringTag:void 0;function l(u){var c=r.call(u,o),h=u[o];try{u[o]=void 0;var p=!0}catch{}var d=i.call(u);return p&&(c?u[o]=h:delete u[o]),d}return df=l,df}var ff,O_;function uq(){if(O_)return ff;O_=1;var e=Object.prototype,n=e.toString;function r(i){return n.call(i)}return ff=r,ff}var hf,P_;function gi(){if(P_)return hf;P_=1;var e=xo(),n=lq(),r=uq(),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 hf=u,hf}var pf,L_;function qn(){if(L_)return pf;L_=1;function e(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}return pf=e,pf}var mf,$_;function Oa(){if($_)return mf;$_=1;var e=gi(),n=qn(),r="[object AsyncFunction]",i="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function u(c){if(!n(c))return!1;var h=e(c);return h==i||h==o||h==r||h==l}return mf=u,mf}var gf,q_;function cq(){if(q_)return gf;q_=1;var e=rr(),n=e["__core-js_shared__"];return gf=n,gf}var vf,D_;function dq(){if(D_)return vf;D_=1;var e=cq(),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 vf=r,vf}var yf,F_;function YC(){if(F_)return yf;F_=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 yf=r,yf}var wf,z_;function fq(){if(z_)return wf;z_=1;var e=Oa(),n=dq(),r=qn(),i=YC(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,h=u.toString,p=c.hasOwnProperty,d=RegExp("^"+h.call(p).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!r(y)||n(y))return!1;var w=e(y)?d:l;return w.test(i(y))}return wf=m,wf}var xf,B_;function hq(){if(B_)return xf;B_=1;function e(n,r){return n==null?void 0:n[r]}return xf=e,xf}var _f,U_;function vi(){if(U_)return _f;U_=1;var e=fq(),n=hq();function r(i,o){var l=n(i,o);return e(l)?l:void 0}return _f=r,_f}var bf,H_;function cy(){if(H_)return bf;H_=1;var e=vi(),n=rr(),r=e(n,"Map");return bf=r,bf}var Sf,W_;function Fu(){if(W_)return Sf;W_=1;var e=vi(),n=e(Object,"create");return Sf=n,Sf}var kf,V_;function pq(){if(V_)return kf;V_=1;var e=Fu();function n(){this.__data__=e?e(null):{},this.size=0}return kf=n,kf}var Ef,G_;function mq(){if(G_)return Ef;G_=1;function e(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}return Ef=e,Ef}var Nf,Y_;function gq(){if(Y_)return Nf;Y_=1;var e=Fu(),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 Nf=o,Nf}var Cf,K_;function vq(){if(K_)return Cf;K_=1;var e=Fu(),n=Object.prototype,r=n.hasOwnProperty;function i(o){var l=this.__data__;return e?l[o]!==void 0:r.call(l,o)}return Cf=i,Cf}var Tf,X_;function yq(){if(X_)return Tf;X_=1;var e=Fu(),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 Tf=r,Tf}var jf,Q_;function wq(){if(Q_)return jf;Q_=1;var e=pq(),n=mq(),r=gq(),i=vq(),o=yq();function l(u){var c=-1,h=u==null?0:u.length;for(this.clear();++c<h;){var p=u[c];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=i,l.prototype.set=o,jf=l,jf}var Rf,Z_;function xq(){if(Z_)return Rf;Z_=1;var e=wq(),n=Du(),r=cy();function i(){this.size=0,this.__data__={hash:new e,map:new(r||n),string:new e}}return Rf=i,Rf}var Af,J_;function _q(){if(J_)return Af;J_=1;function e(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}return Af=e,Af}var If,e1;function zu(){if(e1)return If;e1=1;var e=_q();function n(r,i){var o=r.__data__;return e(i)?o[typeof i=="string"?"string":"hash"]:o.map}return If=n,If}var Mf,t1;function bq(){if(t1)return Mf;t1=1;var e=zu();function n(r){var i=e(this,r).delete(r);return this.size-=i?1:0,i}return Mf=n,Mf}var Of,n1;function Sq(){if(n1)return Of;n1=1;var e=zu();function n(r){return e(this,r).get(r)}return Of=n,Of}var Pf,r1;function kq(){if(r1)return Pf;r1=1;var e=zu();function n(r){return e(this,r).has(r)}return Pf=n,Pf}var Lf,s1;function Eq(){if(s1)return Lf;s1=1;var e=zu();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 Lf=n,Lf}var $f,i1;function dy(){if(i1)return $f;i1=1;var e=xq(),n=bq(),r=Sq(),i=kq(),o=Eq();function l(u){var c=-1,h=u==null?0:u.length;for(this.clear();++c<h;){var p=u[c];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=i,l.prototype.set=o,$f=l,$f}var qf,o1;function Nq(){if(o1)return qf;o1=1;var e=Du(),n=cy(),r=dy(),i=200;function o(l,u){var c=this.__data__;if(c instanceof e){var h=c.__data__;if(!n||h.length<i-1)return h.push([l,u]),this.size=++c.size,this;c=this.__data__=new r(h)}return c.set(l,u),this.size=c.size,this}return qf=o,qf}var Df,a1;function Bu(){if(a1)return Df;a1=1;var e=Du(),n=sq(),r=iq(),i=oq(),o=aq(),l=Nq();function u(c){var h=this.__data__=new e(c);this.size=h.size}return u.prototype.clear=n,u.prototype.delete=r,u.prototype.get=i,u.prototype.has=o,u.prototype.set=l,Df=u,Df}var Ff,l1;function fy(){if(l1)return Ff;l1=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 Ff=e,Ff}var zf,u1;function KC(){if(u1)return zf;u1=1;var e=vi(),n=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return zf=n,zf}var Bf,c1;function Uu(){if(c1)return Bf;c1=1;var e=KC();function n(r,i,o){i=="__proto__"&&e?e(r,i,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[i]=o}return Bf=n,Bf}var Uf,d1;function Hu(){if(d1)return Uf;d1=1;var e=Uu(),n=wo(),r=Object.prototype,i=r.hasOwnProperty;function o(l,u,c){var h=l[u];(!(i.call(l,u)&&n(h,c))||c===void 0&&!(u in l))&&e(l,u,c)}return Uf=o,Uf}var Hf,f1;function Pa(){if(f1)return Hf;f1=1;var e=Hu(),n=Uu();function r(i,o,l,u){var c=!l;l||(l={});for(var h=-1,p=o.length;++h<p;){var d=o[h],m=u?u(l[d],i[d],d,l,i):void 0;m===void 0&&(m=i[d]),c?n(l,d,m):e(l,d,m)}return l}return Hf=r,Hf}var Wf,h1;function Cq(){if(h1)return Wf;h1=1;function e(n,r){for(var i=-1,o=Array(n);++i<n;)o[i]=r(i);return o}return Wf=e,Wf}var Vf,p1;function mr(){if(p1)return Vf;p1=1;function e(n){return n!=null&&typeof n=="object"}return Vf=e,Vf}var Gf,m1;function Tq(){if(m1)return Gf;m1=1;var e=gi(),n=mr(),r="[object Arguments]";function i(o){return n(o)&&e(o)==r}return Gf=i,Gf}var Yf,g1;function La(){if(g1)return Yf;g1=1;var e=Tq(),n=mr(),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 Yf=l,Yf}var Kf,v1;function _t(){if(v1)return Kf;v1=1;var e=Array.isArray;return Kf=e,Kf}var ha={exports:{}},Xf,y1;function jq(){if(y1)return Xf;y1=1;function e(){return!1}return Xf=e,Xf}ha.exports;var w1;function _o(){return w1||(w1=1,(function(e,n){var r=rr(),i=jq(),o=n&&!n.nodeType&&n,l=o&&!0&&e&&!e.nodeType&&e,u=l&&l.exports===o,c=u?r.Buffer:void 0,h=c?c.isBuffer:void 0,p=h||i;e.exports=p})(ha,ha.exports)),ha.exports}var Qf,x1;function Wu(){if(x1)return Qf;x1=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 Zf,_1;function hy(){if(_1)return Zf;_1=1;var e=9007199254740991;function n(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return Zf=n,Zf}var Jf,b1;function Rq(){if(b1)return Jf;b1=1;var e=gi(),n=hy(),r=mr(),i="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",h="[object Function]",p="[object Map]",d="[object Number]",m="[object Object]",y="[object RegExp]",w="[object Set]",E="[object String]",_="[object WeakMap]",b="[object ArrayBuffer]",S="[object DataView]",k="[object Float32Array]",N="[object Float64Array]",T="[object Int8Array]",A="[object Int16Array]",M="[object Int32Array]",O="[object Uint8Array]",P="[object Uint8ClampedArray]",D="[object Uint16Array]",L="[object Uint32Array]",U={};U[k]=U[N]=U[T]=U[A]=U[M]=U[O]=U[P]=U[D]=U[L]=!0,U[i]=U[o]=U[b]=U[l]=U[S]=U[u]=U[c]=U[h]=U[p]=U[d]=U[m]=U[y]=U[w]=U[E]=U[_]=!1;function V(z){return r(z)&&n(z.length)&&!!U[e(z)]}return Jf=V,Jf}var eh,S1;function Vu(){if(S1)return eh;S1=1;function e(n){return function(r){return n(r)}}return eh=e,eh}var pa={exports:{}};pa.exports;var k1;function py(){return k1||(k1=1,(function(e,n){var r=GC(),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 h=o&&o.require&&o.require("util").types;return h||u&&u.binding&&u.binding("util")}catch{}})();e.exports=c})(pa,pa.exports)),pa.exports}var th,E1;function $a(){if(E1)return th;E1=1;var e=Rq(),n=Vu(),r=py(),i=r&&r.isTypedArray,o=i?n(i):e;return th=o,th}var nh,N1;function XC(){if(N1)return nh;N1=1;var e=Cq(),n=La(),r=_t(),i=_o(),o=Wu(),l=$a(),u=Object.prototype,c=u.hasOwnProperty;function h(p,d){var m=r(p),y=!m&&n(p),w=!m&&!y&&i(p),E=!m&&!y&&!w&&l(p),_=m||y||w||E,b=_?e(p.length,String):[],S=b.length;for(var k in p)(d||c.call(p,k))&&!(_&&(k=="length"||w&&(k=="offset"||k=="parent")||E&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||o(k,S)))&&b.push(k);return b}return nh=h,nh}var rh,C1;function Gu(){if(C1)return rh;C1=1;var e=Object.prototype;function n(r){var i=r&&r.constructor,o=typeof i=="function"&&i.prototype||e;return r===o}return rh=n,rh}var sh,T1;function QC(){if(T1)return sh;T1=1;function e(n,r){return function(i){return n(r(i))}}return sh=e,sh}var ih,j1;function Aq(){if(j1)return ih;j1=1;var e=QC(),n=e(Object.keys,Object);return ih=n,ih}var oh,R1;function my(){if(R1)return oh;R1=1;var e=Gu(),n=Aq(),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 oh=o,oh}var ah,A1;function Br(){if(A1)return ah;A1=1;var e=Oa(),n=hy();function r(i){return i!=null&&n(i.length)&&!e(i)}return ah=r,ah}var lh,I1;function As(){if(I1)return lh;I1=1;var e=XC(),n=my(),r=Br();function i(o){return r(o)?e(o):n(o)}return lh=i,lh}var uh,M1;function Iq(){if(M1)return uh;M1=1;var e=Pa(),n=As();function r(i,o){return i&&e(o,n(o),i)}return uh=r,uh}var ch,O1;function Mq(){if(O1)return ch;O1=1;function e(n){var r=[];if(n!=null)for(var i in Object(n))r.push(i);return r}return ch=e,ch}var dh,P1;function Oq(){if(P1)return dh;P1=1;var e=qn(),n=Gu(),r=Mq(),i=Object.prototype,o=i.hasOwnProperty;function l(u){if(!e(u))return r(u);var c=n(u),h=[];for(var p in u)p=="constructor"&&(c||!o.call(u,p))||h.push(p);return h}return dh=l,dh}var fh,L1;function yi(){if(L1)return fh;L1=1;var e=XC(),n=Oq(),r=Br();function i(o){return r(o)?e(o,!0):n(o)}return fh=i,fh}var hh,$1;function Pq(){if($1)return hh;$1=1;var e=Pa(),n=yi();function r(i,o){return i&&e(o,n(o),i)}return hh=r,hh}var ma={exports:{}};ma.exports;var q1;function ZC(){return q1||(q1=1,(function(e,n){var r=rr(),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 h(p,d){if(d)return p.slice();var m=p.length,y=c?c(m):new p.constructor(m);return p.copy(y),y}e.exports=h})(ma,ma.exports)),ma.exports}var ph,D1;function JC(){if(D1)return ph;D1=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 ph=e,ph}var mh,F1;function eT(){if(F1)return mh;F1=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 mh=e,mh}var gh,z1;function tT(){if(z1)return gh;z1=1;function e(){return[]}return gh=e,gh}var vh,B1;function gy(){if(B1)return vh;B1=1;var e=eT(),n=tT(),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 vh=l,vh}var yh,U1;function Lq(){if(U1)return yh;U1=1;var e=Pa(),n=gy();function r(i,o){return e(i,n(i),o)}return yh=r,yh}var wh,H1;function vy(){if(H1)return wh;H1=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 wh=e,wh}var xh,W1;function Yu(){if(W1)return xh;W1=1;var e=QC(),n=e(Object.getPrototypeOf,Object);return xh=n,xh}var _h,V1;function nT(){if(V1)return _h;V1=1;var e=vy(),n=Yu(),r=gy(),i=tT(),o=Object.getOwnPropertySymbols,l=o?function(u){for(var c=[];u;)e(c,r(u)),u=n(u);return c}:i;return _h=l,_h}var bh,G1;function $q(){if(G1)return bh;G1=1;var e=Pa(),n=nT();function r(i,o){return e(i,n(i),o)}return bh=r,bh}var Sh,Y1;function rT(){if(Y1)return Sh;Y1=1;var e=vy(),n=_t();function r(i,o,l){var u=o(i);return n(i)?u:e(u,l(i))}return Sh=r,Sh}var kh,K1;function sT(){if(K1)return kh;K1=1;var e=rT(),n=gy(),r=As();function i(o){return e(o,r,n)}return kh=i,kh}var Eh,X1;function qq(){if(X1)return Eh;X1=1;var e=rT(),n=nT(),r=yi();function i(o){return e(o,r,n)}return Eh=i,Eh}var Nh,Q1;function Dq(){if(Q1)return Nh;Q1=1;var e=vi(),n=rr(),r=e(n,"DataView");return Nh=r,Nh}var Ch,Z1;function Fq(){if(Z1)return Ch;Z1=1;var e=vi(),n=rr(),r=e(n,"Promise");return Ch=r,Ch}var Th,J1;function iT(){if(J1)return Th;J1=1;var e=vi(),n=rr(),r=e(n,"Set");return Th=r,Th}var jh,eb;function zq(){if(eb)return jh;eb=1;var e=vi(),n=rr(),r=e(n,"WeakMap");return jh=r,jh}var Rh,tb;function bo(){if(tb)return Rh;tb=1;var e=Dq(),n=cy(),r=Fq(),i=iT(),o=zq(),l=gi(),u=YC(),c="[object Map]",h="[object Object]",p="[object Promise]",d="[object Set]",m="[object WeakMap]",y="[object DataView]",w=u(e),E=u(n),_=u(r),b=u(i),S=u(o),k=l;return(e&&k(new e(new ArrayBuffer(1)))!=y||n&&k(new n)!=c||r&&k(r.resolve())!=p||i&&k(new i)!=d||o&&k(new o)!=m)&&(k=function(N){var T=l(N),A=T==h?N.constructor:void 0,M=A?u(A):"";if(M)switch(M){case w:return y;case E:return c;case _:return p;case b:return d;case S:return m}return T}),Rh=k,Rh}var Ah,nb;function Bq(){if(nb)return Ah;nb=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 Ah=r,Ah}var Ih,rb;function oT(){if(rb)return Ih;rb=1;var e=rr(),n=e.Uint8Array;return Ih=n,Ih}var Mh,sb;function yy(){if(sb)return Mh;sb=1;var e=oT();function n(r){var i=new r.constructor(r.byteLength);return new e(i).set(new e(r)),i}return Mh=n,Mh}var Oh,ib;function Uq(){if(ib)return Oh;ib=1;var e=yy();function n(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return Oh=n,Oh}var Ph,ob;function Hq(){if(ob)return Ph;ob=1;var e=/\w*$/;function n(r){var i=new r.constructor(r.source,e.exec(r));return i.lastIndex=r.lastIndex,i}return Ph=n,Ph}var Lh,ab;function Wq(){if(ab)return Lh;ab=1;var e=xo(),n=e?e.prototype:void 0,r=n?n.valueOf:void 0;function i(o){return r?Object(r.call(o)):{}}return Lh=i,Lh}var $h,lb;function aT(){if(lb)return $h;lb=1;var e=yy();function n(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return $h=n,$h}var qh,ub;function Vq(){if(ub)return qh;ub=1;var e=yy(),n=Uq(),r=Hq(),i=Wq(),o=aT(),l="[object Boolean]",u="[object Date]",c="[object Map]",h="[object Number]",p="[object RegExp]",d="[object Set]",m="[object String]",y="[object Symbol]",w="[object ArrayBuffer]",E="[object DataView]",_="[object Float32Array]",b="[object Float64Array]",S="[object Int8Array]",k="[object Int16Array]",N="[object Int32Array]",T="[object Uint8Array]",A="[object Uint8ClampedArray]",M="[object Uint16Array]",O="[object Uint32Array]";function P(D,L,U){var V=D.constructor;switch(L){case w:return e(D);case l:case u:return new V(+D);case E:return n(D,U);case _:case b:case S:case k:case N:case T:case A:case M:case O:return o(D,U);case c:return new V;case h:case m:return new V(D);case p:return r(D);case d:return new V;case y:return i(D)}}return qh=P,qh}var Dh,cb;function lT(){if(cb)return Dh;cb=1;var e=qn(),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 Dh=r,Dh}var Fh,db;function uT(){if(db)return Fh;db=1;var e=lT(),n=Yu(),r=Gu();function i(o){return typeof o.constructor=="function"&&!r(o)?e(n(o)):{}}return Fh=i,Fh}var zh,fb;function Gq(){if(fb)return zh;fb=1;var e=bo(),n=mr(),r="[object Map]";function i(o){return n(o)&&e(o)==r}return zh=i,zh}var Bh,hb;function Yq(){if(hb)return Bh;hb=1;var e=Gq(),n=Vu(),r=py(),i=r&&r.isMap,o=i?n(i):e;return Bh=o,Bh}var Uh,pb;function Kq(){if(pb)return Uh;pb=1;var e=bo(),n=mr(),r="[object Set]";function i(o){return n(o)&&e(o)==r}return Uh=i,Uh}var Hh,mb;function Xq(){if(mb)return Hh;mb=1;var e=Kq(),n=Vu(),r=py(),i=r&&r.isSet,o=i?n(i):e;return Hh=o,Hh}var Wh,gb;function cT(){if(gb)return Wh;gb=1;var e=Bu(),n=fy(),r=Hu(),i=Iq(),o=Pq(),l=ZC(),u=JC(),c=Lq(),h=$q(),p=sT(),d=qq(),m=bo(),y=Bq(),w=Vq(),E=uT(),_=_t(),b=_o(),S=Yq(),k=qn(),N=Xq(),T=As(),A=yi(),M=1,O=2,P=4,D="[object Arguments]",L="[object Array]",U="[object Boolean]",V="[object Date]",z="[object Error]",C="[object Function]",F="[object GeneratorFunction]",$="[object Map]",re="[object Number]",J="[object Object]",W="[object RegExp]",Z="[object Set]",I="[object String]",G="[object Symbol]",K="[object WeakMap]",q="[object ArrayBuffer]",Q="[object DataView]",ne="[object Float32Array]",ae="[object Float64Array]",fe="[object Int8Array]",te="[object Int16Array]",ce="[object Int32Array]",Ce="[object Uint8Array]",ve="[object Uint8ClampedArray]",Re="[object Uint16Array]",ye="[object Uint32Array]",Ee={};Ee[D]=Ee[L]=Ee[q]=Ee[Q]=Ee[U]=Ee[V]=Ee[ne]=Ee[ae]=Ee[fe]=Ee[te]=Ee[ce]=Ee[$]=Ee[re]=Ee[J]=Ee[W]=Ee[Z]=Ee[I]=Ee[G]=Ee[Ce]=Ee[ve]=Ee[Re]=Ee[ye]=!0,Ee[z]=Ee[C]=Ee[K]=!1;function Ye(we,_e,Be,it,ft,Ze){var De,Je=_e&M,Xe=_e&O,Ot=_e&P;if(Be&&(De=ft?Be(we,it,ft,Ze):Be(we)),De!==void 0)return De;if(!k(we))return we;var lt=_(we);if(lt){if(De=y(we),!Je)return u(we,De)}else{var Qe=m(we),Pt=Qe==C||Qe==F;if(b(we))return l(we,Je);if(Qe==J||Qe==D||Pt&&!ft){if(De=Xe||Pt?{}:E(we),!Je)return Xe?h(we,o(De,we)):c(we,i(De,we))}else{if(!Ee[Qe])return ft?we:{};De=w(we,Qe,Je)}}Ze||(Ze=new e);var zt=Ze.get(we);if(zt)return zt;Ze.set(we,De),N(we)?we.forEach(function(ht){De.add(Ye(ht,_e,Be,ht,we,Ze))}):S(we)&&we.forEach(function(ht,vt){De.set(vt,Ye(ht,_e,Be,vt,we,Ze))});var et=Ot?Xe?d:p:Xe?A:T,bt=lt?void 0:et(we);return n(bt||we,function(ht,vt){bt&&(vt=ht,ht=we[vt]),r(De,vt,Ye(ht,_e,Be,vt,we,Ze))}),De}return Wh=Ye,Wh}var Vh,vb;function Qq(){if(vb)return Vh;vb=1;var e=cT(),n=4;function r(i){return e(i,n)}return Vh=r,Vh}var Gh,yb;function wy(){if(yb)return Gh;yb=1;function e(n){return function(){return n}}return Gh=e,Gh}var Yh,wb;function Zq(){if(wb)return Yh;wb=1;function e(n){return function(r,i,o){for(var l=-1,u=Object(r),c=o(r),h=c.length;h--;){var p=c[n?h:++l];if(i(u[p],p,u)===!1)break}return r}}return Yh=e,Yh}var Kh,xb;function xy(){if(xb)return Kh;xb=1;var e=Zq(),n=e();return Kh=n,Kh}var Xh,_b;function _y(){if(_b)return Xh;_b=1;var e=xy(),n=As();function r(i,o){return i&&e(i,o,n)}return Xh=r,Xh}var Qh,bb;function Jq(){if(bb)return Qh;bb=1;var e=Br();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,h=Object(o);(i?c--:++c<u)&&l(h[c],c,h)!==!1;);return o}}return Qh=n,Qh}var Zh,Sb;function Ku(){if(Sb)return Zh;Sb=1;var e=_y(),n=Jq(),r=n(e);return Zh=r,Zh}var Jh,kb;function wi(){if(kb)return Jh;kb=1;function e(n){return n}return Jh=e,Jh}var ep,Eb;function dT(){if(Eb)return ep;Eb=1;var e=wi();function n(r){return typeof r=="function"?r:e}return ep=n,ep}var tp,Nb;function fT(){if(Nb)return tp;Nb=1;var e=fy(),n=Ku(),r=dT(),i=_t();function o(l,u){var c=i(l)?e:n;return c(l,r(u))}return tp=o,tp}var np,Cb;function hT(){return Cb||(Cb=1,np=fT()),np}var rp,Tb;function eD(){if(Tb)return rp;Tb=1;var e=Ku();function n(r,i){var o=[];return e(r,function(l,u,c){i(l,u,c)&&o.push(l)}),o}return rp=n,rp}var sp,jb;function tD(){if(jb)return sp;jb=1;var e="__lodash_hash_undefined__";function n(r){return this.__data__.set(r,e),this}return sp=n,sp}var ip,Rb;function nD(){if(Rb)return ip;Rb=1;function e(n){return this.__data__.has(n)}return ip=e,ip}var op,Ab;function pT(){if(Ab)return op;Ab=1;var e=dy(),n=tD(),r=nD();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,op=i,op}var ap,Ib;function rD(){if(Ib)return ap;Ib=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 ap=e,ap}var lp,Mb;function mT(){if(Mb)return lp;Mb=1;function e(n,r){return n.has(r)}return lp=e,lp}var up,Ob;function gT(){if(Ob)return up;Ob=1;var e=pT(),n=rD(),r=mT(),i=1,o=2;function l(u,c,h,p,d,m){var y=h&i,w=u.length,E=c.length;if(w!=E&&!(y&&E>w))return!1;var _=m.get(u),b=m.get(c);if(_&&b)return _==c&&b==u;var S=-1,k=!0,N=h&o?new e:void 0;for(m.set(u,c),m.set(c,u);++S<w;){var T=u[S],A=c[S];if(p)var M=y?p(A,T,S,c,u,m):p(T,A,S,u,c,m);if(M!==void 0){if(M)continue;k=!1;break}if(N){if(!n(c,function(O,P){if(!r(N,P)&&(T===O||d(T,O,h,p,m)))return N.push(P)})){k=!1;break}}else if(!(T===A||d(T,A,h,p,m))){k=!1;break}}return m.delete(u),m.delete(c),k}return up=l,up}var cp,Pb;function sD(){if(Pb)return cp;Pb=1;function e(n){var r=-1,i=Array(n.size);return n.forEach(function(o,l){i[++r]=[l,o]}),i}return cp=e,cp}var dp,Lb;function by(){if(Lb)return dp;Lb=1;function e(n){var r=-1,i=Array(n.size);return n.forEach(function(o){i[++r]=o}),i}return dp=e,dp}var fp,$b;function iD(){if($b)return fp;$b=1;var e=xo(),n=oT(),r=wo(),i=gT(),o=sD(),l=by(),u=1,c=2,h="[object Boolean]",p="[object Date]",d="[object Error]",m="[object Map]",y="[object Number]",w="[object RegExp]",E="[object Set]",_="[object String]",b="[object Symbol]",S="[object ArrayBuffer]",k="[object DataView]",N=e?e.prototype:void 0,T=N?N.valueOf:void 0;function A(M,O,P,D,L,U,V){switch(P){case k:if(M.byteLength!=O.byteLength||M.byteOffset!=O.byteOffset)return!1;M=M.buffer,O=O.buffer;case S:return!(M.byteLength!=O.byteLength||!U(new n(M),new n(O)));case h:case p:case y:return r(+M,+O);case d:return M.name==O.name&&M.message==O.message;case w:case _:return M==O+"";case m:var z=o;case E:var C=D&u;if(z||(z=l),M.size!=O.size&&!C)return!1;var F=V.get(M);if(F)return F==O;D|=c,V.set(M,O);var $=i(z(M),z(O),D,L,U,V);return V.delete(M),$;case b:if(T)return T.call(M)==T.call(O)}return!1}return fp=A,fp}var hp,qb;function oD(){if(qb)return hp;qb=1;var e=sT(),n=1,r=Object.prototype,i=r.hasOwnProperty;function o(l,u,c,h,p,d){var m=c&n,y=e(l),w=y.length,E=e(u),_=E.length;if(w!=_&&!m)return!1;for(var b=w;b--;){var S=y[b];if(!(m?S in u:i.call(u,S)))return!1}var k=d.get(l),N=d.get(u);if(k&&N)return k==u&&N==l;var T=!0;d.set(l,u),d.set(u,l);for(var A=m;++b<w;){S=y[b];var M=l[S],O=u[S];if(h)var P=m?h(O,M,S,u,l,d):h(M,O,S,l,u,d);if(!(P===void 0?M===O||p(M,O,c,h,d):P)){T=!1;break}A||(A=S=="constructor")}if(T&&!A){var D=l.constructor,L=u.constructor;D!=L&&"constructor"in l&&"constructor"in u&&!(typeof D=="function"&&D instanceof D&&typeof L=="function"&&L instanceof L)&&(T=!1)}return d.delete(l),d.delete(u),T}return hp=o,hp}var pp,Db;function aD(){if(Db)return pp;Db=1;var e=Bu(),n=gT(),r=iD(),i=oD(),o=bo(),l=_t(),u=_o(),c=$a(),h=1,p="[object Arguments]",d="[object Array]",m="[object Object]",y=Object.prototype,w=y.hasOwnProperty;function E(_,b,S,k,N,T){var A=l(_),M=l(b),O=A?d:o(_),P=M?d:o(b);O=O==p?m:O,P=P==p?m:P;var D=O==m,L=P==m,U=O==P;if(U&&u(_)){if(!u(b))return!1;A=!0,D=!1}if(U&&!D)return T||(T=new e),A||c(_)?n(_,b,S,k,N,T):r(_,b,O,S,k,N,T);if(!(S&h)){var V=D&&w.call(_,"__wrapped__"),z=L&&w.call(b,"__wrapped__");if(V||z){var C=V?_.value():_,F=z?b.value():b;return T||(T=new e),N(C,F,S,k,T)}}return U?(T||(T=new e),i(_,b,S,k,N,T)):!1}return pp=E,pp}var mp,Fb;function vT(){if(Fb)return mp;Fb=1;var e=aD(),n=mr();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 mp=r,mp}var gp,zb;function lD(){if(zb)return gp;zb=1;var e=Bu(),n=vT(),r=1,i=2;function o(l,u,c,h){var p=c.length,d=p,m=!h;if(l==null)return!d;for(l=Object(l);p--;){var y=c[p];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++p<d;){y=c[p];var w=y[0],E=l[w],_=y[1];if(m&&y[2]){if(E===void 0&&!(w in l))return!1}else{var b=new e;if(h)var S=h(E,_,w,l,u,b);if(!(S===void 0?n(_,E,r|i,h,b):S))return!1}}return!0}return gp=o,gp}var vp,Bb;function yT(){if(Bb)return vp;Bb=1;var e=qn();function n(r){return r===r&&!e(r)}return vp=n,vp}var yp,Ub;function uD(){if(Ub)return yp;Ub=1;var e=yT(),n=As();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 yp=r,yp}var wp,Hb;function wT(){if(Hb)return wp;Hb=1;function e(n,r){return function(i){return i==null?!1:i[n]===r&&(r!==void 0||n in Object(i))}}return wp=e,wp}var xp,Wb;function cD(){if(Wb)return xp;Wb=1;var e=lD(),n=uD(),r=wT();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 xp=i,xp}var _p,Vb;function So(){if(Vb)return _p;Vb=1;var e=gi(),n=mr(),r="[object Symbol]";function i(o){return typeof o=="symbol"||n(o)&&e(o)==r}return _p=i,_p}var bp,Gb;function Sy(){if(Gb)return bp;Gb=1;var e=_t(),n=So(),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 bp=o,bp}var Sp,Yb;function dD(){if(Yb)return Sp;Yb=1;var e=dy(),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],h=l.cache;if(h.has(c))return h.get(c);var p=i.apply(this,u);return l.cache=h.set(c,p)||h,p};return l.cache=new(r.Cache||e),l}return r.Cache=e,Sp=r,Sp}var kp,Kb;function fD(){if(Kb)return kp;Kb=1;var e=dD(),n=500;function r(i){var o=e(i,function(u){return l.size===n&&l.clear(),u}),l=o.cache;return o}return kp=r,kp}var Ep,Xb;function hD(){if(Xb)return Ep;Xb=1;var e=fD(),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,h,p){l.push(h?p.replace(r,"$1"):c||u)}),l});return Ep=i,Ep}var Np,Qb;function Xu(){if(Qb)return Np;Qb=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 Np=e,Np}var Cp,Zb;function pD(){if(Zb)return Cp;Zb=1;var e=xo(),n=Xu(),r=_t(),i=So(),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 h=c+"";return h=="0"&&1/c==-1/0?"-0":h}return Cp=u,Cp}var Tp,Jb;function xT(){if(Jb)return Tp;Jb=1;var e=pD();function n(r){return r==null?"":e(r)}return Tp=n,Tp}var jp,eS;function Qu(){if(eS)return jp;eS=1;var e=_t(),n=Sy(),r=hD(),i=xT();function o(l,u){return e(l)?l:n(l,u)?[l]:r(i(l))}return jp=o,jp}var Rp,tS;function qa(){if(tS)return Rp;tS=1;var e=So();function n(r){if(typeof r=="string"||e(r))return r;var i=r+"";return i=="0"&&1/r==-1/0?"-0":i}return Rp=n,Rp}var Ap,nS;function Zu(){if(nS)return Ap;nS=1;var e=Qu(),n=qa();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 Ap=r,Ap}var Ip,rS;function mD(){if(rS)return Ip;rS=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 Ip=n,Ip}var Mp,sS;function gD(){if(sS)return Mp;sS=1;function e(n,r){return n!=null&&r in Object(n)}return Mp=e,Mp}var Op,iS;function _T(){if(iS)return Op;iS=1;var e=Qu(),n=La(),r=_t(),i=Wu(),o=hy(),l=qa();function u(c,h,p){h=e(h,c);for(var d=-1,m=h.length,y=!1;++d<m;){var w=l(h[d]);if(!(y=c!=null&&p(c,w)))break;c=c[w]}return y||++d!=m?y:(m=c==null?0:c.length,!!m&&o(m)&&i(w,m)&&(r(c)||n(c)))}return Op=u,Op}var Pp,oS;function bT(){if(oS)return Pp;oS=1;var e=gD(),n=_T();function r(i,o){return i!=null&&n(i,o,e)}return Pp=r,Pp}var Lp,aS;function vD(){if(aS)return Lp;aS=1;var e=vT(),n=mD(),r=bT(),i=Sy(),o=yT(),l=wT(),u=qa(),c=1,h=2;function p(d,m){return i(d)&&o(m)?l(u(d),m):function(y){var w=n(y,d);return w===void 0&&w===m?r(y,d):e(m,w,c|h)}}return Lp=p,Lp}var $p,lS;function ST(){if(lS)return $p;lS=1;function e(n){return function(r){return r==null?void 0:r[n]}}return $p=e,$p}var qp,uS;function yD(){if(uS)return qp;uS=1;var e=Zu();function n(r){return function(i){return e(i,r)}}return qp=n,qp}var Dp,cS;function wD(){if(cS)return Dp;cS=1;var e=ST(),n=yD(),r=Sy(),i=qa();function o(l){return r(l)?e(i(l)):n(l)}return Dp=o,Dp}var Fp,dS;function Ur(){if(dS)return Fp;dS=1;var e=cD(),n=vD(),r=wi(),i=_t(),o=wD();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 Fp=l,Fp}var zp,fS;function kT(){if(fS)return zp;fS=1;var e=eT(),n=eD(),r=Ur(),i=_t();function o(l,u){var c=i(l)?e:n;return c(l,r(u,3))}return zp=o,zp}var Bp,hS;function xD(){if(hS)return Bp;hS=1;var e=Object.prototype,n=e.hasOwnProperty;function r(i,o){return i!=null&&n.call(i,o)}return Bp=r,Bp}var Up,pS;function ET(){if(pS)return Up;pS=1;var e=xD(),n=_T();function r(i,o){return i!=null&&n(i,o,e)}return Up=r,Up}var Hp,mS;function _D(){if(mS)return Hp;mS=1;var e=my(),n=bo(),r=La(),i=_t(),o=Br(),l=_o(),u=Gu(),c=$a(),h="[object Map]",p="[object Set]",d=Object.prototype,m=d.hasOwnProperty;function y(w){if(w==null)return!0;if(o(w)&&(i(w)||typeof w=="string"||typeof w.splice=="function"||l(w)||c(w)||r(w)))return!w.length;var E=n(w);if(E==h||E==p)return!w.size;if(u(w))return!e(w).length;for(var _ in w)if(m.call(w,_))return!1;return!0}return Hp=y,Hp}var Wp,gS;function NT(){if(gS)return Wp;gS=1;function e(n){return n===void 0}return Wp=e,Wp}var Vp,vS;function CT(){if(vS)return Vp;vS=1;var e=Ku(),n=Br();function r(i,o){var l=-1,u=n(i)?Array(i.length):[];return e(i,function(c,h,p){u[++l]=o(c,h,p)}),u}return Vp=r,Vp}var Gp,yS;function TT(){if(yS)return Gp;yS=1;var e=Xu(),n=Ur(),r=CT(),i=_t();function o(l,u){var c=i(l)?e:r;return c(l,n(u,3))}return Gp=o,Gp}var Yp,wS;function bD(){if(wS)return Yp;wS=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 Yp=e,Yp}var Kp,xS;function SD(){if(xS)return Kp;xS=1;function e(n,r,i,o,l){return l(n,function(u,c,h){i=o?(o=!1,u):r(i,u,c,h)}),i}return Kp=e,Kp}var Xp,_S;function jT(){if(_S)return Xp;_S=1;var e=bD(),n=Ku(),r=Ur(),i=SD(),o=_t();function l(u,c,h){var p=o(u)?e:i,d=arguments.length<3;return p(u,r(c,4),h,d,n)}return Xp=l,Xp}var Qp,bS;function kD(){if(bS)return Qp;bS=1;var e=gi(),n=_t(),r=mr(),i="[object String]";function o(l){return typeof l=="string"||!n(l)&&r(l)&&e(l)==i}return Qp=o,Qp}var Zp,SS;function ED(){if(SS)return Zp;SS=1;var e=ST(),n=e("length");return Zp=n,Zp}var Jp,kS;function ND(){if(kS)return Jp;kS=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 h(p){return c.test(p)}return Jp=h,Jp}var em,ES;function CD(){if(ES)return em;ES=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+"]",h="\\ud83c[\\udffb-\\udfff]",p="(?:"+c+"|"+h+")",d="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",E=p+"?",_="["+l+"]?",b="(?:"+w+"(?:"+[d,m,y].join("|")+")"+_+E+")*",S=_+E+b,k="(?:"+[d+c+"?",c,m,y,u].join("|")+")",N=RegExp(h+"(?="+h+")|"+k+S,"g");function T(A){for(var M=N.lastIndex=0;N.test(A);)++M;return M}return em=T,em}var tm,NS;function TD(){if(NS)return tm;NS=1;var e=ED(),n=ND(),r=CD();function i(o){return n(o)?r(o):e(o)}return tm=i,tm}var nm,CS;function jD(){if(CS)return nm;CS=1;var e=my(),n=bo(),r=Br(),i=kD(),o=TD(),l="[object Map]",u="[object Set]";function c(h){if(h==null)return 0;if(r(h))return i(h)?o(h):h.length;var p=n(h);return p==l||p==u?h.size:e(h).length}return nm=c,nm}var rm,TS;function RD(){if(TS)return rm;TS=1;var e=fy(),n=lT(),r=_y(),i=Ur(),o=Yu(),l=_t(),u=_o(),c=Oa(),h=qn(),p=$a();function d(m,y,w){var E=l(m),_=E||u(m)||p(m);if(y=i(y,4),w==null){var b=m&&m.constructor;_?w=E?new b:[]:h(m)?w=c(b)?n(o(m)):{}:w={}}return(_?e:r)(m,function(S,k,N){return y(w,S,k,N)}),w}return rm=d,rm}var sm,jS;function AD(){if(jS)return sm;jS=1;var e=xo(),n=La(),r=_t(),i=e?e.isConcatSpreadable:void 0;function o(l){return r(l)||n(l)||!!(i&&l&&l[i])}return sm=o,sm}var im,RS;function ky(){if(RS)return im;RS=1;var e=vy(),n=AD();function r(i,o,l,u,c){var h=-1,p=i.length;for(l||(l=n),c||(c=[]);++h<p;){var d=i[h];o>0&&l(d)?o>1?r(d,o-1,l,u,c):e(c,d):u||(c[c.length]=d)}return c}return im=r,im}var om,AS;function ID(){if(AS)return om;AS=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 om=e,om}var am,IS;function RT(){if(IS)return am;IS=1;var e=ID(),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,h=n(u.length-o,0),p=Array(h);++c<h;)p[c]=u[o+c];c=-1;for(var d=Array(o+1);++c<o;)d[c]=u[c];return d[o]=l(p),e(i,this,d)}}return am=r,am}var lm,MS;function MD(){if(MS)return lm;MS=1;var e=wy(),n=KC(),r=wi(),i=n?function(o,l){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:r;return lm=i,lm}var um,OS;function OD(){if(OS)return um;OS=1;var e=800,n=16,r=Date.now;function i(o){var l=0,u=0;return function(){var c=r(),h=n-(c-u);if(u=c,h>0){if(++l>=e)return arguments[0]}else l=0;return o.apply(void 0,arguments)}}return um=i,um}var cm,PS;function AT(){if(PS)return cm;PS=1;var e=MD(),n=OD(),r=n(e);return cm=r,cm}var dm,LS;function Ju(){if(LS)return dm;LS=1;var e=wi(),n=RT(),r=AT();function i(o,l){return r(n(o,l,e),o+"")}return dm=i,dm}var fm,$S;function IT(){if($S)return fm;$S=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 fm=e,fm}var hm,qS;function PD(){if(qS)return hm;qS=1;function e(n){return n!==n}return hm=e,hm}var pm,DS;function LD(){if(DS)return pm;DS=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 pm=e,pm}var mm,FS;function $D(){if(FS)return mm;FS=1;var e=IT(),n=PD(),r=LD();function i(o,l,u){return l===l?r(o,l,u):e(o,n,u)}return mm=i,mm}var gm,zS;function qD(){if(zS)return gm;zS=1;var e=$D();function n(r,i){var o=r==null?0:r.length;return!!o&&e(r,i,0)>-1}return gm=n,gm}var vm,BS;function DD(){if(BS)return vm;BS=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 vm=e,vm}var ym,US;function FD(){if(US)return ym;US=1;function e(){}return ym=e,ym}var wm,HS;function zD(){if(HS)return wm;HS=1;var e=iT(),n=FD(),r=by(),i=1/0,o=e&&1/r(new e([,-0]))[1]==i?function(l){return new e(l)}:n;return wm=o,wm}var xm,WS;function BD(){if(WS)return xm;WS=1;var e=pT(),n=qD(),r=DD(),i=mT(),o=zD(),l=by(),u=200;function c(h,p,d){var m=-1,y=n,w=h.length,E=!0,_=[],b=_;if(d)E=!1,y=r;else if(w>=u){var S=p?null:o(h);if(S)return l(S);E=!1,y=i,b=new e}else b=p?[]:_;e:for(;++m<w;){var k=h[m],N=p?p(k):k;if(k=d||k!==0?k:0,E&&N===N){for(var T=b.length;T--;)if(b[T]===N)continue e;p&&b.push(N),_.push(k)}else y(b,N,d)||(b!==_&&b.push(N),_.push(k))}return _}return xm=c,xm}var _m,VS;function MT(){if(VS)return _m;VS=1;var e=Br(),n=mr();function r(i){return n(i)&&e(i)}return _m=r,_m}var bm,GS;function UD(){if(GS)return bm;GS=1;var e=ky(),n=Ju(),r=BD(),i=MT(),o=n(function(l){return r(e(l,1,i,!0))});return bm=o,bm}var Sm,YS;function HD(){if(YS)return Sm;YS=1;var e=Xu();function n(r,i){return e(i,function(o){return r[o]})}return Sm=n,Sm}var km,KS;function OT(){if(KS)return km;KS=1;var e=HD(),n=As();function r(i){return i==null?[]:e(i,n(i))}return km=r,km}var Em,XS;function Dn(){if(XS)return Em;XS=1;var e;if(typeof uy=="function")try{e={clone:Qq(),constant:wy(),each:hT(),filter:kT(),has:ET(),isArray:_t(),isEmpty:_D(),isFunction:Oa(),isUndefined:NT(),keys:As(),map:TT(),reduce:jT(),size:jD(),transform:RD(),union:UD(),values:OT()}}catch{}return e||(e=window._),Em=e,Em}var Nm,QS;function Ey(){if(QS)return Nm;QS=1;var e=Dn();Nm=o;var n="\0",r="\0",i="";function o(d){this._isDirected=e.has(d,"directed")?d.directed:!0,this._isMultigraph=e.has(d,"multigraph")?d.multigraph:!1,this._isCompound=e.has(d,"compound")?d.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(d){return this._label=d,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(m){return e.isEmpty(d._in[m])})},o.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(m){return e.isEmpty(d._out[m])})},o.prototype.setNodes=function(d,m){var y=arguments,w=this;return e.each(d,function(E){y.length>1?w.setNode(E,m):w.setNode(E)}),this},o.prototype.setNode=function(d,m){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=m),this):(this._nodes[d]=arguments.length>1?m:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=r,this._children[d]={},this._children[r][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},o.prototype.node=function(d){return this._nodes[d]},o.prototype.hasNode=function(d){return e.has(this._nodes,d)},o.prototype.removeNode=function(d){var m=this;if(e.has(this._nodes,d)){var y=function(w){m.removeEdge(m._edgeObjs[w])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(w){m.setParent(w)}),delete this._children[d]),e.each(e.keys(this._in[d]),y),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),y),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},o.prototype.setParent=function(d,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=r;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===d)throw new Error("Setting "+m+" as parent of "+d+" would create a cycle");this.setNode(m)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=m,this._children[m][d]=!0,this},o.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},o.prototype.parent=function(d){if(this._isCompound){var m=this._parent[d];if(m!==r)return m}},o.prototype.children=function(d){if(e.isUndefined(d)&&(d=r),this._isCompound){var m=this._children[d];if(m)return e.keys(m)}else{if(d===r)return this.nodes();if(this.hasNode(d))return[]}},o.prototype.predecessors=function(d){var m=this._preds[d];if(m)return e.keys(m)},o.prototype.successors=function(d){var m=this._sucs[d];if(m)return e.keys(m)},o.prototype.neighbors=function(d){var m=this.predecessors(d);if(m)return e.union(m,this.successors(d))},o.prototype.isLeaf=function(d){var m;return this.isDirected()?m=this.successors(d):m=this.neighbors(d),m.length===0},o.prototype.filterNodes=function(d){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,b){d(b)&&m.setNode(b,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var w={};function E(_){var b=y.parent(_);return b===void 0||m.hasNode(b)?(w[_]=b,b):b in w?w[b]:E(b)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,E(_))}),m},o.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(d,m){var y=this,w=arguments;return e.reduce(d,function(E,_){return w.length>1?y.setEdge(E,_,m):y.setEdge(E,_),_}),this},o.prototype.setEdge=function(){var d,m,y,w,E=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(d=_.v,m=_.w,y=_.name,arguments.length===2&&(w=arguments[1],E=!0)):(d=_,m=arguments[1],y=arguments[3],arguments.length>2&&(w=arguments[2],E=!0)),d=""+d,m=""+m,e.isUndefined(y)||(y=""+y);var b=c(this._isDirected,d,m,y);if(e.has(this._edgeLabels,b))return E&&(this._edgeLabels[b]=w),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(m),this._edgeLabels[b]=E?w:this._defaultEdgeLabelFn(d,m,y);var S=h(this._isDirected,d,m,y);return d=S.v,m=S.w,Object.freeze(S),this._edgeObjs[b]=S,l(this._preds[m],d),l(this._sucs[d],m),this._in[m][b]=S,this._out[d][b]=S,this._edgeCount++,this},o.prototype.edge=function(d,m,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,d,m,y);return this._edgeLabels[w]},o.prototype.hasEdge=function(d,m,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,d,m,y);return e.has(this._edgeLabels,w)},o.prototype.removeEdge=function(d,m,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,d,m,y),E=this._edgeObjs[w];return E&&(d=E.v,m=E.w,delete this._edgeLabels[w],delete this._edgeObjs[w],u(this._preds[m],d),u(this._sucs[d],m),delete this._in[m][w],delete this._out[d][w],this._edgeCount--),this},o.prototype.inEdges=function(d,m){var y=this._in[d];if(y){var w=e.values(y);return m?e.filter(w,function(E){return E.v===m}):w}},o.prototype.outEdges=function(d,m){var y=this._out[d];if(y){var w=e.values(y);return m?e.filter(w,function(E){return E.w===m}):w}},o.prototype.nodeEdges=function(d,m){var y=this.inEdges(d,m);if(y)return y.concat(this.outEdges(d,m))};function l(d,m){d[m]?d[m]++:d[m]=1}function u(d,m){--d[m]||delete d[m]}function c(d,m,y,w){var E=""+m,_=""+y;if(!d&&E>_){var b=E;E=_,_=b}return E+i+_+i+(e.isUndefined(w)?n:w)}function h(d,m,y,w){var E=""+m,_=""+y;if(!d&&E>_){var b=E;E=_,_=b}var S={v:E,w:_};return w&&(S.name=w),S}function p(d,m){return c(d,m.v,m.w,m.name)}return Nm}var Cm,ZS;function WD(){return ZS||(ZS=1,Cm="2.1.8"),Cm}var Tm,JS;function VD(){return JS||(JS=1,Tm={Graph:Ey(),version:WD()}),Tm}var jm,ek;function GD(){if(ek)return jm;ek=1;var e=Dn(),n=Ey();jm={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 h=u.node(c),p=u.parent(c),d={v:c};return e.isUndefined(h)||(d.value=h),e.isUndefined(p)||(d.parent=p),d})}function o(u){return e.map(u.edges(),function(c){var h=u.edge(c),p={v:c.v,w:c.w};return e.isUndefined(c.name)||(p.name=c.name),e.isUndefined(h)||(p.value=h),p})}function l(u){var c=new n(u.options).setGraph(u.value);return e.each(u.nodes,function(h){c.setNode(h.v,h.value),h.parent&&c.setParent(h.v,h.parent)}),e.each(u.edges,function(h){c.setEdge({v:h.v,w:h.w,name:h.name},h.value)}),c}return jm}var Rm,tk;function YD(){if(tk)return Rm;tk=1;var e=Dn();Rm=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 Rm}var Am,nk;function PT(){if(nk)return Am;nk=1;var e=Dn();Am=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},Am}var Im,rk;function LT(){if(rk)return Im;rk=1;var e=Dn(),n=PT();Im=i;var r=e.constant(1);function i(l,u,c,h){return o(l,String(u),c||r,h||function(p){return l.outEdges(p)})}function o(l,u,c,h){var p={},d=new n,m,y,w=function(E){var _=E.v!==m?E.v:E.w,b=p[_],S=c(E),k=y.distance+S;if(S<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+E+" Weight: "+S);k<b.distance&&(b.distance=k,b.predecessor=m,d.decrease(_,k))};for(l.nodes().forEach(function(E){var _=E===u?0:Number.POSITIVE_INFINITY;p[E]={distance:_},d.add(E,_)});d.size()>0&&(m=d.removeMin(),y=p[m],y.distance!==Number.POSITIVE_INFINITY);)h(m).forEach(w);return p}return Im}var Mm,sk;function KD(){if(sk)return Mm;sk=1;var e=LT(),n=Dn();Mm=r;function r(i,o,l){return n.transform(i.nodes(),function(u,c){u[c]=e(i,c,o,l)},{})}return Mm}var Om,ik;function $T(){if(ik)return Om;ik=1;var e=Dn();Om=n;function n(r){var i=0,o=[],l={},u=[];function c(h){var p=l[h]={onStack:!0,lowlink:i,index:i++};if(o.push(h),r.successors(h).forEach(function(y){e.has(l,y)?l[y].onStack&&(p.lowlink=Math.min(p.lowlink,l[y].index)):(c(y),p.lowlink=Math.min(p.lowlink,l[y].lowlink))}),p.lowlink===p.index){var d=[],m;do m=o.pop(),l[m].onStack=!1,d.push(m);while(h!==m);u.push(d)}}return r.nodes().forEach(function(h){e.has(l,h)||c(h)}),u}return Om}var Pm,ok;function XD(){if(ok)return Pm;ok=1;var e=Dn(),n=$T();Pm=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 Pm}var Lm,ak;function QD(){if(ak)return Lm;ak=1;var e=Dn();Lm=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={},h=o.nodes();return h.forEach(function(p){c[p]={},c[p][p]={distance:0},h.forEach(function(d){p!==d&&(c[p][d]={distance:Number.POSITIVE_INFINITY})}),u(p).forEach(function(d){var m=d.v===p?d.w:d.v,y=l(d);c[p][m]={distance:y,predecessor:p}})}),h.forEach(function(p){var d=c[p];h.forEach(function(m){var y=c[m];h.forEach(function(w){var E=y[p],_=d[w],b=y[w],S=E.distance+_.distance;S<b.distance&&(b.distance=S,b.predecessor=_.predecessor)})})}),c}return Lm}var $m,lk;function qT(){if(lk)return $m;lk=1;var e=Dn();$m=n,n.CycleException=r;function n(i){var o={},l={},u=[];function c(h){if(e.has(l,h))throw new r;e.has(o,h)||(l[h]=!0,o[h]=!0,e.each(i.predecessors(h),c),delete l[h],u.push(h))}if(e.each(i.sinks(),c),e.size(o)!==i.nodeCount())throw new r;return u}function r(){}return r.prototype=new Error,$m}var qm,uk;function ZD(){if(uk)return qm;uk=1;var e=qT();qm=n;function n(r){try{e(r)}catch(i){if(i instanceof e.CycleException)return!1;throw i}return!0}return qm}var Dm,ck;function DT(){if(ck)return Dm;ck=1;var e=Dn();Dm=n;function n(i,o,l){e.isArray(o)||(o=[o]);var u=(i.isDirected()?i.successors:i.neighbors).bind(i),c=[],h={};return e.each(o,function(p){if(!i.hasNode(p))throw new Error("Graph does not have node: "+p);r(i,p,l==="post",h,u,c)}),c}function r(i,o,l,u,c,h){e.has(u,o)||(u[o]=!0,l||h.push(o),e.each(c(o),function(p){r(i,p,l,u,c,h)}),l&&h.push(o))}return Dm}var Fm,dk;function JD(){if(dk)return Fm;dk=1;var e=DT();Fm=n;function n(r,i){return e(r,i,"post")}return Fm}var zm,fk;function e4(){if(fk)return zm;fk=1;var e=DT();zm=n;function n(r,i){return e(r,i,"pre")}return zm}var Bm,hk;function t4(){if(hk)return Bm;hk=1;var e=Dn(),n=Ey(),r=PT();Bm=i;function i(o,l){var u=new n,c={},h=new r,p;function d(y){var w=y.v===p?y.w:y.v,E=h.priority(w);if(E!==void 0){var _=l(y);_<E&&(c[w]=p,h.decrease(w,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){h.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),h.decrease(o.nodes()[0],0);for(var m=!1;h.size()>0;){if(p=h.removeMin(),e.has(c,p))u.setEdge(p,c[p]);else{if(m)throw new Error("Input graph is not connected: "+o);m=!0}o.nodeEdges(p).forEach(d)}return u}return Bm}var Um,pk;function n4(){return pk||(pk=1,Um={components:YD(),dijkstra:LT(),dijkstraAll:KD(),findCycles:XD(),floydWarshall:QD(),isAcyclic:ZD(),postorder:JD(),preorder:e4(),prim:t4(),tarjan:$T(),topsort:qT()}),Um}var Hm,mk;function r4(){if(mk)return Hm;mk=1;var e=VD();return Hm={Graph:e.Graph,json:GD(),alg:n4(),version:e.version},Hm}var Wm,gk;function tr(){if(gk)return Wm;gk=1;var e;if(typeof uy=="function")try{e=r4()}catch{}return e||(e=window.graphlib),Wm=e,Wm}var Vm,vk;function s4(){if(vk)return Vm;vk=1;var e=cT(),n=1,r=4;function i(o){return e(o,n|r)}return Vm=i,Vm}var Gm,yk;function ec(){if(yk)return Gm;yk=1;var e=wo(),n=Br(),r=Wu(),i=qn();function o(l,u,c){if(!i(c))return!1;var h=typeof u;return(h=="number"?n(c)&&r(u,c.length):h=="string"&&u in c)?e(c[u],l):!1}return Gm=o,Gm}var Ym,wk;function i4(){if(wk)return Ym;wk=1;var e=Ju(),n=wo(),r=ec(),i=yi(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,h){c=Object(c);var p=-1,d=h.length,m=d>2?h[2]:void 0;for(m&&r(h[0],h[1],m)&&(d=1);++p<d;)for(var y=h[p],w=i(y),E=-1,_=w.length;++E<_;){var b=w[E],S=c[b];(S===void 0||n(S,o[b])&&!l.call(c,b))&&(c[b]=y[b])}return c});return Ym=u,Ym}var Km,xk;function o4(){if(xk)return Km;xk=1;var e=Ur(),n=Br(),r=As();function i(o){return function(l,u,c){var h=Object(l);if(!n(l)){var p=e(u,3);l=r(l),u=function(m){return p(h[m],m,h)}}var d=o(l,u,c);return d>-1?h[p?l[d]:d]:void 0}}return Km=i,Km}var Xm,_k;function a4(){if(_k)return Xm;_k=1;var e=/\s/;function n(r){for(var i=r.length;i--&&e.test(r.charAt(i)););return i}return Xm=n,Xm}var Qm,bk;function l4(){if(bk)return Qm;bk=1;var e=a4(),n=/^\s+/;function r(i){return i&&i.slice(0,e(i)+1).replace(n,"")}return Qm=r,Qm}var Zm,Sk;function u4(){if(Sk)return Zm;Sk=1;var e=l4(),n=qn(),r=So(),i=NaN,o=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function h(p){if(typeof p=="number")return p;if(r(p))return i;if(n(p)){var d=typeof p.valueOf=="function"?p.valueOf():p;p=n(d)?d+"":d}if(typeof p!="string")return p===0?p:+p;p=e(p);var m=l.test(p);return m||u.test(p)?c(p.slice(2),m?2:8):o.test(p)?i:+p}return Zm=h,Zm}var Jm,kk;function FT(){if(kk)return Jm;kk=1;var e=u4(),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 Jm=i,Jm}var eg,Ek;function c4(){if(Ek)return eg;Ek=1;var e=FT();function n(r){var i=e(r),o=i%1;return i===i?o?i-o:i:0}return eg=n,eg}var tg,Nk;function d4(){if(Nk)return tg;Nk=1;var e=IT(),n=Ur(),r=c4(),i=Math.max;function o(l,u,c){var h=l==null?0:l.length;if(!h)return-1;var p=c==null?0:r(c);return p<0&&(p=i(h+p,0)),e(l,n(u,3),p)}return tg=o,tg}var ng,Ck;function f4(){if(Ck)return ng;Ck=1;var e=o4(),n=d4(),r=e(n);return ng=r,ng}var rg,Tk;function zT(){if(Tk)return rg;Tk=1;var e=ky();function n(r){var i=r==null?0:r.length;return i?e(r,1):[]}return rg=n,rg}var sg,jk;function h4(){if(jk)return sg;jk=1;var e=xy(),n=dT(),r=yi();function i(o,l){return o==null?o:e(o,n(l),r)}return sg=i,sg}var ig,Rk;function p4(){if(Rk)return ig;Rk=1;function e(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}return ig=e,ig}var og,Ak;function m4(){if(Ak)return og;Ak=1;var e=Uu(),n=_y(),r=Ur();function i(o,l){var u={};return l=r(l,3),n(o,function(c,h,p){e(u,h,l(c,h,p))}),u}return og=i,og}var ag,Ik;function Ny(){if(Ik)return ag;Ik=1;var e=So();function n(r,i,o){for(var l=-1,u=r.length;++l<u;){var c=r[l],h=i(c);if(h!=null&&(p===void 0?h===h&&!e(h):o(h,p)))var p=h,d=c}return d}return ag=n,ag}var lg,Mk;function g4(){if(Mk)return lg;Mk=1;function e(n,r){return n>r}return lg=e,lg}var ug,Ok;function v4(){if(Ok)return ug;Ok=1;var e=Ny(),n=g4(),r=wi();function i(o){return o&&o.length?e(o,r,n):void 0}return ug=i,ug}var cg,Pk;function BT(){if(Pk)return cg;Pk=1;var e=Uu(),n=wo();function r(i,o,l){(l!==void 0&&!n(i[o],l)||l===void 0&&!(o in i))&&e(i,o,l)}return cg=r,cg}var dg,Lk;function y4(){if(Lk)return dg;Lk=1;var e=gi(),n=Yu(),r=mr(),i="[object Object]",o=Function.prototype,l=Object.prototype,u=o.toString,c=l.hasOwnProperty,h=u.call(Object);function p(d){if(!r(d)||e(d)!=i)return!1;var m=n(d);if(m===null)return!0;var y=c.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==h}return dg=p,dg}var fg,$k;function UT(){if($k)return fg;$k=1;function e(n,r){if(!(r==="constructor"&&typeof n[r]=="function")&&r!="__proto__")return n[r]}return fg=e,fg}var hg,qk;function w4(){if(qk)return hg;qk=1;var e=Pa(),n=yi();function r(i){return e(i,n(i))}return hg=r,hg}var pg,Dk;function x4(){if(Dk)return pg;Dk=1;var e=BT(),n=ZC(),r=aT(),i=JC(),o=uT(),l=La(),u=_t(),c=MT(),h=_o(),p=Oa(),d=qn(),m=y4(),y=$a(),w=UT(),E=w4();function _(b,S,k,N,T,A,M){var O=w(b,k),P=w(S,k),D=M.get(P);if(D){e(b,k,D);return}var L=A?A(O,P,k+"",b,S,M):void 0,U=L===void 0;if(U){var V=u(P),z=!V&&h(P),C=!V&&!z&&y(P);L=P,V||z||C?u(O)?L=O:c(O)?L=i(O):z?(U=!1,L=n(P,!0)):C?(U=!1,L=r(P,!0)):L=[]:m(P)||l(P)?(L=O,l(O)?L=E(O):(!d(O)||p(O))&&(L=o(P))):U=!1}U&&(M.set(P,L),T(L,P,N,A,M),M.delete(P)),e(b,k,L)}return pg=_,pg}var mg,Fk;function _4(){if(Fk)return mg;Fk=1;var e=Bu(),n=BT(),r=xy(),i=x4(),o=qn(),l=yi(),u=UT();function c(h,p,d,m,y){h!==p&&r(p,function(w,E){if(y||(y=new e),o(w))i(h,p,E,d,c,m,y);else{var _=m?m(u(h,E),w,E+"",h,p,y):void 0;_===void 0&&(_=w),n(h,E,_)}},l)}return mg=c,mg}var gg,zk;function b4(){if(zk)return gg;zk=1;var e=Ju(),n=ec();function r(i){return e(function(o,l){var u=-1,c=l.length,h=c>1?l[c-1]:void 0,p=c>2?l[2]:void 0;for(h=i.length>3&&typeof h=="function"?(c--,h):void 0,p&&n(l[0],l[1],p)&&(h=c<3?void 0:h,c=1),o=Object(o);++u<c;){var d=l[u];d&&i(o,d,u,h)}return o})}return gg=r,gg}var vg,Bk;function S4(){if(Bk)return vg;Bk=1;var e=_4(),n=b4(),r=n(function(i,o,l){e(i,o,l)});return vg=r,vg}var yg,Uk;function HT(){if(Uk)return yg;Uk=1;function e(n,r){return n<r}return yg=e,yg}var wg,Hk;function k4(){if(Hk)return wg;Hk=1;var e=Ny(),n=HT(),r=wi();function i(o){return o&&o.length?e(o,r,n):void 0}return wg=i,wg}var xg,Wk;function E4(){if(Wk)return xg;Wk=1;var e=Ny(),n=Ur(),r=HT();function i(o,l){return o&&o.length?e(o,n(l,2),r):void 0}return xg=i,xg}var _g,Vk;function N4(){if(Vk)return _g;Vk=1;var e=rr(),n=function(){return e.Date.now()};return _g=n,_g}var bg,Gk;function C4(){if(Gk)return bg;Gk=1;var e=Hu(),n=Qu(),r=Wu(),i=qn(),o=qa();function l(u,c,h,p){if(!i(u))return u;c=n(c,u);for(var d=-1,m=c.length,y=m-1,w=u;w!=null&&++d<m;){var E=o(c[d]),_=h;if(E==="__proto__"||E==="constructor"||E==="prototype")return u;if(d!=y){var b=w[E];_=p?p(b,E,w):void 0,_===void 0&&(_=i(b)?b:r(c[d+1])?[]:{})}e(w,E,_),w=w[E]}return u}return bg=l,bg}var Sg,Yk;function T4(){if(Yk)return Sg;Yk=1;var e=Zu(),n=C4(),r=Qu();function i(o,l,u){for(var c=-1,h=l.length,p={};++c<h;){var d=l[c],m=e(o,d);u(m,d)&&n(p,r(d,o),m)}return p}return Sg=i,Sg}var kg,Kk;function j4(){if(Kk)return kg;Kk=1;var e=T4(),n=bT();function r(i,o){return e(i,o,function(l,u){return n(i,u)})}return kg=r,kg}var Eg,Xk;function R4(){if(Xk)return Eg;Xk=1;var e=zT(),n=RT(),r=AT();function i(o){return r(n(o,void 0,e),o+"")}return Eg=i,Eg}var Ng,Qk;function A4(){if(Qk)return Ng;Qk=1;var e=j4(),n=R4(),r=n(function(i,o){return i==null?{}:e(i,o)});return Ng=r,Ng}var Cg,Zk;function I4(){if(Zk)return Cg;Zk=1;var e=Math.ceil,n=Math.max;function r(i,o,l,u){for(var c=-1,h=n(e((o-i)/(l||1)),0),p=Array(h);h--;)p[u?h:++c]=i,i+=l;return p}return Cg=r,Cg}var Tg,Jk;function M4(){if(Jk)return Tg;Jk=1;var e=I4(),n=ec(),r=FT();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 Tg=i,Tg}var jg,eE;function O4(){if(eE)return jg;eE=1;var e=M4(),n=e();return jg=n,jg}var Rg,tE;function P4(){if(tE)return Rg;tE=1;function e(n,r){var i=n.length;for(n.sort(r);i--;)n[i]=n[i].value;return n}return Rg=e,Rg}var Ag,nE;function L4(){if(nE)return Ag;nE=1;var e=So();function n(r,i){if(r!==i){var o=r!==void 0,l=r===null,u=r===r,c=e(r),h=i!==void 0,p=i===null,d=i===i,m=e(i);if(!p&&!m&&!c&&r>i||c&&h&&d&&!p&&!m||l&&h&&d||!o&&d||!u)return 1;if(!l&&!c&&!m&&r<i||m&&o&&u&&!l&&!c||p&&o&&u||!h&&u||!d)return-1}return 0}return Ag=n,Ag}var Ig,rE;function $4(){if(rE)return Ig;rE=1;var e=L4();function n(r,i,o){for(var l=-1,u=r.criteria,c=i.criteria,h=u.length,p=o.length;++l<h;){var d=e(u[l],c[l]);if(d){if(l>=p)return d;var m=o[l];return d*(m=="desc"?-1:1)}}return r.index-i.index}return Ig=n,Ig}var Mg,sE;function q4(){if(sE)return Mg;sE=1;var e=Xu(),n=Zu(),r=Ur(),i=CT(),o=P4(),l=Vu(),u=$4(),c=wi(),h=_t();function p(d,m,y){m.length?m=e(m,function(_){return h(_)?function(b){return n(b,_.length===1?_[0]:_)}:_}):m=[c];var w=-1;m=e(m,l(r));var E=i(d,function(_,b,S){var k=e(m,function(N){return N(_)});return{criteria:k,index:++w,value:_}});return o(E,function(_,b){return u(_,b,y)})}return Mg=p,Mg}var Og,iE;function D4(){if(iE)return Og;iE=1;var e=ky(),n=q4(),r=Ju(),i=ec(),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 Og=o,Og}var Pg,oE;function F4(){if(oE)return Pg;oE=1;var e=xT(),n=0;function r(i){var o=++n;return e(i)+o}return Pg=r,Pg}var Lg,aE;function z4(){if(aE)return Lg;aE=1;function e(n,r,i){for(var o=-1,l=n.length,u=r.length,c={};++o<l;){var h=o<u?r[o]:void 0;i(c,n[o],h)}return c}return Lg=e,Lg}var $g,lE;function B4(){if(lE)return $g;lE=1;var e=Hu(),n=z4();function r(i,o){return n(i||[],o||[],e)}return $g=r,$g}var qg,uE;function at(){if(uE)return qg;uE=1;var e;if(typeof uy=="function")try{e={cloneDeep:s4(),constant:wy(),defaults:i4(),each:hT(),filter:kT(),find:f4(),flatten:zT(),forEach:fT(),forIn:h4(),has:ET(),isUndefined:NT(),last:p4(),map:TT(),mapValues:m4(),max:v4(),merge:S4(),min:k4(),minBy:E4(),now:N4(),pick:A4(),range:O4(),reduce:jT(),sortBy:D4(),uniqueId:F4(),values:OT(),zipObject:B4()}}catch{}return e||(e=window._),qg=e,qg}var Dg,cE;function U4(){if(cE)return Dg;cE=1,Dg=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 Dg}var Fg,dE;function H4(){if(dE)return Fg;dE=1;var e=at(),n=tr().Graph,r=U4();Fg=o;var i=e.constant(1);function o(p,d){if(p.nodeCount()<=1)return[];var m=c(p,d||i),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(w){return p.outEdges(w.v,w.w)}),!0)}function l(p,d,m){for(var y=[],w=d[d.length-1],E=d[0],_;p.nodeCount();){for(;_=E.dequeue();)u(p,d,m,_);for(;_=w.dequeue();)u(p,d,m,_);if(p.nodeCount()){for(var b=d.length-2;b>0;--b)if(_=d[b].dequeue(),_){y=y.concat(u(p,d,m,_,!0));break}}}return y}function u(p,d,m,y,w){var E=w?[]:void 0;return e.forEach(p.inEdges(y.v),function(_){var b=p.edge(_),S=p.node(_.v);w&&E.push({v:_.v,w:_.w}),S.out-=b,h(d,m,S)}),e.forEach(p.outEdges(y.v),function(_){var b=p.edge(_),S=_.w,k=p.node(S);k.in-=b,h(d,m,k)}),p.removeNode(y.v),E}function c(p,d){var m=new n,y=0,w=0;e.forEach(p.nodes(),function(b){m.setNode(b,{v:b,in:0,out:0})}),e.forEach(p.edges(),function(b){var S=m.edge(b.v,b.w)||0,k=d(b),N=S+k;m.setEdge(b.v,b.w,N),w=Math.max(w,m.node(b.v).out+=k),y=Math.max(y,m.node(b.w).in+=k)});var E=e.range(w+y+3).map(function(){return new r}),_=y+1;return e.forEach(m.nodes(),function(b){h(E,_,m.node(b))}),{graph:m,buckets:E,zeroIdx:_}}function h(p,d,m){m.out?m.in?p[m.out-m.in+d].enqueue(m):p[p.length-1].enqueue(m):p[0].enqueue(m)}return Fg}var zg,fE;function W4(){if(fE)return zg;fE=1;var e=at(),n=H4();zg={run:r,undo:o};function r(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):i(l);e.forEach(u,function(h){var p=l.edge(h);l.removeEdge(h),p.forwardName=h.name,p.reversed=!0,l.setEdge(h.w,h.v,p,e.uniqueId("rev"))});function c(h){return function(p){return h.edge(p).weight}}}function i(l){var u=[],c={},h={};function p(d){e.has(h,d)||(h[d]=!0,c[d]=!0,e.forEach(l.outEdges(d),function(m){e.has(c,m.w)?u.push(m):p(m.w)}),delete c[d])}return e.forEach(l.nodes(),p),u}function o(l){e.forEach(l.edges(),function(u){var c=l.edge(u);if(c.reversed){l.removeEdge(u);var h=c.forwardName;delete c.reversed,delete c.forwardName,l.setEdge(u.w,u.v,c,h)}})}return zg}var Bg,hE;function fn(){if(hE)return Bg;hE=1;var e=at(),n=tr().Graph;Bg={addDummyNode:r,simplify:i,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:h,normalizeRanks:p,removeEmptyRanks:d,addBorderNode:m,maxRank:y,partition:w,time:E,notime:_};function r(b,S,k,N){var T;do T=e.uniqueId(N);while(b.hasNode(T));return k.dummy=S,b.setNode(T,k),T}function i(b){var S=new n().setGraph(b.graph());return e.forEach(b.nodes(),function(k){S.setNode(k,b.node(k))}),e.forEach(b.edges(),function(k){var N=S.edge(k.v,k.w)||{weight:0,minlen:1},T=b.edge(k);S.setEdge(k.v,k.w,{weight:N.weight+T.weight,minlen:Math.max(N.minlen,T.minlen)})}),S}function o(b){var S=new n({multigraph:b.isMultigraph()}).setGraph(b.graph());return e.forEach(b.nodes(),function(k){b.children(k).length||S.setNode(k,b.node(k))}),e.forEach(b.edges(),function(k){S.setEdge(k,b.edge(k))}),S}function l(b){var S=e.map(b.nodes(),function(k){var N={};return e.forEach(b.outEdges(k),function(T){N[T.w]=(N[T.w]||0)+b.edge(T).weight}),N});return e.zipObject(b.nodes(),S)}function u(b){var S=e.map(b.nodes(),function(k){var N={};return e.forEach(b.inEdges(k),function(T){N[T.v]=(N[T.v]||0)+b.edge(T).weight}),N});return e.zipObject(b.nodes(),S)}function c(b,S){var k=b.x,N=b.y,T=S.x-k,A=S.y-N,M=b.width/2,O=b.height/2;if(!T&&!A)throw new Error("Not possible to find intersection inside of the rectangle");var P,D;return Math.abs(A)*M>Math.abs(T)*O?(A<0&&(O=-O),P=O*T/A,D=O):(T<0&&(M=-M),P=M,D=M*A/T),{x:k+P,y:N+D}}function h(b){var S=e.map(e.range(y(b)+1),function(){return[]});return e.forEach(b.nodes(),function(k){var N=b.node(k),T=N.rank;e.isUndefined(T)||(S[T][N.order]=k)}),S}function p(b){var S=e.min(e.map(b.nodes(),function(k){return b.node(k).rank}));e.forEach(b.nodes(),function(k){var N=b.node(k);e.has(N,"rank")&&(N.rank-=S)})}function d(b){var S=e.min(e.map(b.nodes(),function(A){return b.node(A).rank})),k=[];e.forEach(b.nodes(),function(A){var M=b.node(A).rank-S;k[M]||(k[M]=[]),k[M].push(A)});var N=0,T=b.graph().nodeRankFactor;e.forEach(k,function(A,M){e.isUndefined(A)&&M%T!==0?--N:N&&e.forEach(A,function(O){b.node(O).rank+=N})})}function m(b,S,k,N){var T={width:0,height:0};return arguments.length>=4&&(T.rank=k,T.order=N),r(b,"border",T,S)}function y(b){return e.max(e.map(b.nodes(),function(S){var k=b.node(S).rank;if(!e.isUndefined(k))return k}))}function w(b,S){var k={lhs:[],rhs:[]};return e.forEach(b,function(N){S(N)?k.lhs.push(N):k.rhs.push(N)}),k}function E(b,S){var k=e.now();try{return S()}finally{console.log(b+" time: "+(e.now()-k)+"ms")}}function _(b,S){return S()}return Bg}var Ug,pE;function V4(){if(pE)return Ug;pE=1;var e=at(),n=fn();Ug={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,h=l.node(c).rank,p=u.w,d=l.node(p).rank,m=u.name,y=l.edge(u),w=y.labelRank;if(d!==h+1){l.removeEdge(u);var E,_,b;for(b=0,++h;h<d;++b,++h)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:u,rank:h},E=n.addDummyNode(l,"edge",_,"_d"),h===w&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(c,E,{weight:y.weight},m),b===0&&l.graph().dummyChains.push(E),c=E;l.setEdge(c,p,{weight:y.weight},m)}}function o(l){e.forEach(l.graph().dummyChains,function(u){var c=l.node(u),h=c.edgeLabel,p;for(l.setEdge(c.edgeObj,h);c.dummy;)p=l.successors(u)[0],l.removeNode(u),h.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(h.x=c.x,h.y=c.y,h.width=c.width,h.height=c.height),u=p,c=l.node(u)})}return Ug}var Hg,mE;function Tu(){if(mE)return Hg;mE=1;var e=at();Hg={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 h=e.min(e.map(i.outEdges(u),function(p){return l(p.w)-i.edge(p).minlen}));return(h===Number.POSITIVE_INFINITY||h===void 0||h===null)&&(h=0),c.rank=h}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 Hg}var Wg,gE;function WT(){if(gE)return Wg;gE=1;var e=at(),n=tr().Graph,r=Tu().slack;Wg=i;function i(c){var h=new n({directed:!1}),p=c.nodes()[0],d=c.nodeCount();h.setNode(p,{});for(var m,y;o(h,c)<d;)m=l(h,c),y=h.hasNode(m.v)?r(c,m):-r(c,m),u(h,c,y);return h}function o(c,h){function p(d){e.forEach(h.nodeEdges(d),function(m){var y=m.v,w=d===y?m.w:y;!c.hasNode(w)&&!r(h,m)&&(c.setNode(w,{}),c.setEdge(d,w,{}),p(w))})}return e.forEach(c.nodes(),p),c.nodeCount()}function l(c,h){return e.minBy(h.edges(),function(p){if(c.hasNode(p.v)!==c.hasNode(p.w))return r(h,p)})}function u(c,h,p){e.forEach(c.nodes(),function(d){h.node(d).rank+=p})}return Wg}var Vg,vE;function G4(){if(vE)return Vg;vE=1;var e=at(),n=WT(),r=Tu().slack,i=Tu().longestPath,o=tr().alg.preorder,l=tr().alg.postorder,u=fn().simplify;Vg=c,c.initLowLimValues=m,c.initCutValues=h,c.calcCutValue=d,c.leaveEdge=w,c.enterEdge=E,c.exchangeEdges=_;function c(N){N=u(N),i(N);var T=n(N);m(T),h(T,N);for(var A,M;A=w(T);)M=E(T,N,A),_(T,N,A,M)}function h(N,T){var A=l(N,N.nodes());A=A.slice(0,A.length-1),e.forEach(A,function(M){p(N,T,M)})}function p(N,T,A){var M=N.node(A),O=M.parent;N.edge(A,O).cutvalue=d(N,T,A)}function d(N,T,A){var M=N.node(A),O=M.parent,P=!0,D=T.edge(A,O),L=0;return D||(P=!1,D=T.edge(O,A)),L=D.weight,e.forEach(T.nodeEdges(A),function(U){var V=U.v===A,z=V?U.w:U.v;if(z!==O){var C=V===P,F=T.edge(U).weight;if(L+=C?F:-F,S(N,A,z)){var $=N.edge(A,z).cutvalue;L+=C?-$:$}}}),L}function m(N,T){arguments.length<2&&(T=N.nodes()[0]),y(N,{},1,T)}function y(N,T,A,M,O){var P=A,D=N.node(M);return T[M]=!0,e.forEach(N.neighbors(M),function(L){e.has(T,L)||(A=y(N,T,A,L,M))}),D.low=P,D.lim=A++,O?D.parent=O:delete D.parent,A}function w(N){return e.find(N.edges(),function(T){return N.edge(T).cutvalue<0})}function E(N,T,A){var M=A.v,O=A.w;T.hasEdge(M,O)||(M=A.w,O=A.v);var P=N.node(M),D=N.node(O),L=P,U=!1;P.lim>D.lim&&(L=D,U=!0);var V=e.filter(T.edges(),function(z){return U===k(N,N.node(z.v),L)&&U!==k(N,N.node(z.w),L)});return e.minBy(V,function(z){return r(T,z)})}function _(N,T,A,M){var O=A.v,P=A.w;N.removeEdge(O,P),N.setEdge(M.v,M.w,{}),m(N),h(N,T),b(N,T)}function b(N,T){var A=e.find(N.nodes(),function(O){return!T.node(O).parent}),M=o(N,A);M=M.slice(1),e.forEach(M,function(O){var P=N.node(O).parent,D=T.edge(O,P),L=!1;D||(D=T.edge(P,O),L=!0),T.node(O).rank=T.node(P).rank+(L?D.minlen:-D.minlen)})}function S(N,T,A){return N.hasEdge(T,A)}function k(N,T,A){return A.low<=T.lim&&T.lim<=A.lim}return Vg}var Gg,yE;function Y4(){if(yE)return Gg;yE=1;var e=Tu(),n=e.longestPath,r=WT(),i=G4();Gg=o;function o(h){switch(h.graph().ranker){case"network-simplex":c(h);break;case"tight-tree":u(h);break;case"longest-path":l(h);break;default:c(h)}}var l=n;function u(h){n(h),r(h)}function c(h){i(h)}return Gg}var Yg,wE;function K4(){if(wE)return Yg;wE=1;var e=at();Yg=n;function n(o){var l=i(o);e.forEach(o.graph().dummyChains,function(u){for(var c=o.node(u),h=c.edgeObj,p=r(o,l,h.v,h.w),d=p.path,m=p.lca,y=0,w=d[y],E=!0;u!==h.w;){if(c=o.node(u),E){for(;(w=d[y])!==m&&o.node(w).maxRank<c.rank;)y++;w===m&&(E=!1)}if(!E){for(;y<d.length-1&&o.node(w=d[y+1]).minRank<=c.rank;)y++;w=d[y]}o.setParent(u,w),u=o.successors(u)[0]}})}function r(o,l,u,c){var h=[],p=[],d=Math.min(l[u].low,l[c].low),m=Math.max(l[u].lim,l[c].lim),y,w;y=u;do y=o.parent(y),h.push(y);while(y&&(l[y].low>d||m>l[y].lim));for(w=y,y=c;(y=o.parent(y))!==w;)p.push(y);return{path:h.concat(p.reverse()),lca:w}}function i(o){var l={},u=0;function c(h){var p=u;e.forEach(o.children(h),c),l[h]={low:p,lim:u++}}return e.forEach(o.children(),c),l}return Yg}var Kg,xE;function X4(){if(xE)return Kg;xE=1;var e=at(),n=fn();Kg={run:r,cleanup:u};function r(c){var h=n.addDummyNode(c,"root",{},"_root"),p=o(c),d=e.max(e.values(p))-1,m=2*d+1;c.graph().nestingRoot=h,e.forEach(c.edges(),function(w){c.edge(w).minlen*=m});var y=l(c)+1;e.forEach(c.children(),function(w){i(c,h,m,y,d,p,w)}),c.graph().nodeRankFactor=m}function i(c,h,p,d,m,y,w){var E=c.children(w);if(!E.length){w!==h&&c.setEdge(h,w,{weight:0,minlen:p});return}var _=n.addBorderNode(c,"_bt"),b=n.addBorderNode(c,"_bb"),S=c.node(w);c.setParent(_,w),S.borderTop=_,c.setParent(b,w),S.borderBottom=b,e.forEach(E,function(k){i(c,h,p,d,m,y,k);var N=c.node(k),T=N.borderTop?N.borderTop:k,A=N.borderBottom?N.borderBottom:k,M=N.borderTop?d:2*d,O=T!==A?1:m-y[w]+1;c.setEdge(_,T,{weight:M,minlen:O,nestingEdge:!0}),c.setEdge(A,b,{weight:M,minlen:O,nestingEdge:!0})}),c.parent(w)||c.setEdge(h,_,{weight:0,minlen:m+y[w]})}function o(c){var h={};function p(d,m){var y=c.children(d);y&&y.length&&e.forEach(y,function(w){p(w,m+1)}),h[d]=m}return e.forEach(c.children(),function(d){p(d,1)}),h}function l(c){return e.reduce(c.edges(),function(h,p){return h+c.edge(p).weight},0)}function u(c){var h=c.graph();c.removeNode(h.nestingRoot),delete h.nestingRoot,e.forEach(c.edges(),function(p){var d=c.edge(p);d.nestingEdge&&c.removeEdge(p)})}return Kg}var Xg,_E;function Q4(){if(_E)return Xg;_E=1;var e=at(),n=fn();Xg=r;function r(o){function l(u){var c=o.children(u),h=o.node(u);if(c.length&&e.forEach(c,l),e.has(h,"minRank")){h.borderLeft=[],h.borderRight=[];for(var p=h.minRank,d=h.maxRank+1;p<d;++p)i(o,"borderLeft","_bl",u,h,p),i(o,"borderRight","_br",u,h,p)}}e.forEach(o.children(),l)}function i(o,l,u,c,h,p){var d={width:0,height:0,rank:p,borderType:l},m=h[l][p-1],y=n.addDummyNode(o,"border",d,u);h[l][p]=y,o.setParent(y,c),m&&o.setEdge(m,y,{weight:1})}return Xg}var Qg,bE;function Z4(){if(bE)return Qg;bE=1;var e=at();Qg={adjust:n,undo:r};function n(p){var d=p.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&i(p)}function r(p){var d=p.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&l(p),(d==="lr"||d==="rl")&&(c(p),i(p))}function i(p){e.forEach(p.nodes(),function(d){o(p.node(d))}),e.forEach(p.edges(),function(d){o(p.edge(d))})}function o(p){var d=p.width;p.width=p.height,p.height=d}function l(p){e.forEach(p.nodes(),function(d){u(p.node(d))}),e.forEach(p.edges(),function(d){var m=p.edge(d);e.forEach(m.points,u),e.has(m,"y")&&u(m)})}function u(p){p.y=-p.y}function c(p){e.forEach(p.nodes(),function(d){h(p.node(d))}),e.forEach(p.edges(),function(d){var m=p.edge(d);e.forEach(m.points,h),e.has(m,"x")&&h(m)})}function h(p){var d=p.x;p.x=p.y,p.y=d}return Qg}var Zg,SE;function J4(){if(SE)return Zg;SE=1;var e=at();Zg=n;function n(r){var i={},o=e.filter(r.nodes(),function(p){return!r.children(p).length}),l=e.max(e.map(o,function(p){return r.node(p).rank})),u=e.map(e.range(l+1),function(){return[]});function c(p){if(!e.has(i,p)){i[p]=!0;var d=r.node(p);u[d.rank].push(p),e.forEach(r.successors(p),c)}}var h=e.sortBy(o,function(p){return r.node(p).rank});return e.forEach(h,c),u}return Zg}var Jg,kE;function e5(){if(kE)return Jg;kE=1;var e=at();Jg=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,w){return w})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(i.outEdges(y),function(w){return{pos:u[w.w],weight:i.edge(w).weight}}),"pos")}),!0),h=1;h<l.length;)h<<=1;var p=2*h-1;h-=1;var d=e.map(new Array(p),function(){return 0}),m=0;return e.forEach(c.forEach(function(y){var w=y.pos+h;d[w]+=y.weight;for(var E=0;w>0;)w%2&&(E+=d[w+1]),w=w-1>>1,d[w]+=y.weight;m+=y.weight*E})),m}return Jg}var ev,EE;function t5(){if(EE)return ev;EE=1;var e=at();ev=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,h){var p=r.edge(h),d=r.node(h.v);return{sum:c.sum+p.weight*d.order,weight:c.weight+p.weight}},{sum:0,weight:0});return{v:o,barycenter:u.sum/u.weight,weight:u.weight}}else return{v:o}})}return ev}var tv,NE;function n5(){if(NE)return tv;NE=1;var e=at();tv=n;function n(o,l){var u={};e.forEach(o,function(h,p){var d=u[h.v]={indegree:0,in:[],out:[],vs:[h.v],i:p};e.isUndefined(h.barycenter)||(d.barycenter=h.barycenter,d.weight=h.weight)}),e.forEach(l.edges(),function(h){var p=u[h.v],d=u[h.w];!e.isUndefined(p)&&!e.isUndefined(d)&&(d.indegree++,p.out.push(u[h.w]))});var c=e.filter(u,function(h){return!h.indegree});return r(c)}function r(o){var l=[];function u(p){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(p.barycenter)||d.barycenter>=p.barycenter)&&i(p,d)}}function c(p){return function(d){d.in.push(p),--d.indegree===0&&o.push(d)}}for(;o.length;){var h=o.pop();l.push(h),e.forEach(h.in.reverse(),u(h)),e.forEach(h.out,c(h))}return e.map(e.filter(l,function(p){return!p.merged}),function(p){return e.pick(p,["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 tv}var nv,CE;function r5(){if(CE)return nv;CE=1;var e=at(),n=fn();nv=r;function r(l,u){var c=n.partition(l,function(_){return e.has(_,"barycenter")}),h=c.lhs,p=e.sortBy(c.rhs,function(_){return-_.i}),d=[],m=0,y=0,w=0;h.sort(o(!!u)),w=i(d,p,w),e.forEach(h,function(_){w+=_.vs.length,d.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,w=i(d,p,w)});var E={vs:e.flatten(d,!0)};return y&&(E.barycenter=m/y,E.weight=y),E}function i(l,u,c){for(var h;u.length&&(h=e.last(u)).i<=c;)u.pop(),l.push(h.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 nv}var rv,TE;function s5(){if(TE)return rv;TE=1;var e=at(),n=t5(),r=n5(),i=r5();rv=o;function o(c,h,p,d){var m=c.children(h),y=c.node(h),w=y?y.borderLeft:void 0,E=y?y.borderRight:void 0,_={};w&&(m=e.filter(m,function(A){return A!==w&&A!==E}));var b=n(c,m);e.forEach(b,function(A){if(c.children(A.v).length){var M=o(c,A.v,p,d);_[A.v]=M,e.has(M,"barycenter")&&u(A,M)}});var S=r(b,p);l(S,_);var k=i(S,d);if(w&&(k.vs=e.flatten([w,k.vs,E],!0),c.predecessors(w).length)){var N=c.node(c.predecessors(w)[0]),T=c.node(c.predecessors(E)[0]);e.has(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+N.order+T.order)/(k.weight+2),k.weight+=2}return k}function l(c,h){e.forEach(c,function(p){p.vs=e.flatten(p.vs.map(function(d){return h[d]?h[d].vs:d}),!0)})}function u(c,h){e.isUndefined(c.barycenter)?(c.barycenter=h.barycenter,c.weight=h.weight):(c.barycenter=(c.barycenter*c.weight+h.barycenter*h.weight)/(c.weight+h.weight),c.weight+=h.weight)}return rv}var sv,jE;function i5(){if(jE)return sv;jE=1;var e=at(),n=tr().Graph;sv=r;function r(o,l,u){var c=i(o),h=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(p){return o.node(p)});return e.forEach(o.nodes(),function(p){var d=o.node(p),m=o.parent(p);(d.rank===l||d.minRank<=l&&l<=d.maxRank)&&(h.setNode(p),h.setParent(p,m||c),e.forEach(o[u](p),function(y){var w=y.v===p?y.w:y.v,E=h.edge(w,p),_=e.isUndefined(E)?0:E.weight;h.setEdge(w,p,{weight:o.edge(y).weight+_})}),e.has(d,"minRank")&&h.setNode(p,{borderLeft:d.borderLeft[l],borderRight:d.borderRight[l]}))}),h}function i(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return sv}var iv,RE;function o5(){if(RE)return iv;RE=1;var e=at();iv=n;function n(r,i,o){var l={},u;e.forEach(o,function(c){for(var h=r.parent(c),p,d;h;){if(p=r.parent(h),p?(d=l[p],l[p]=h):(d=u,u=h),d&&d!==h){i.setEdge(d,h);return}h=p}})}return iv}var ov,AE;function a5(){if(AE)return ov;AE=1;var e=at(),n=J4(),r=e5(),i=s5(),o=i5(),l=o5(),u=tr().Graph,c=fn();ov=h;function h(y){var w=c.maxRank(y),E=p(y,e.range(1,w+1),"inEdges"),_=p(y,e.range(w-1,-1,-1),"outEdges"),b=n(y);m(y,b);for(var S=Number.POSITIVE_INFINITY,k,N=0,T=0;T<4;++N,++T){d(N%2?E:_,N%4>=2),b=c.buildLayerMatrix(y);var A=r(y,b);A<S&&(T=0,k=e.cloneDeep(b),S=A)}m(y,k)}function p(y,w,E){return e.map(w,function(_){return o(y,_,E)})}function d(y,w){var E=new u;e.forEach(y,function(_){var b=_.graph().root,S=i(_,b,E,w);e.forEach(S.vs,function(k,N){_.node(k).order=N}),l(_,E,S.vs)})}function m(y,w){e.forEach(w,function(E){e.forEach(E,function(_,b){y.node(_).order=b})})}return ov}var av,IE;function l5(){if(IE)return av;IE=1;var e=at(),n=tr().Graph,r=fn();av={positionX:E,findType1Conflicts:i,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:h,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:m,balance:w};function i(S,k){var N={};function T(A,M){var O=0,P=0,D=A.length,L=e.last(M);return e.forEach(M,function(U,V){var z=l(S,U),C=z?S.node(z).order:D;(z||U===L)&&(e.forEach(M.slice(P,V+1),function(F){e.forEach(S.predecessors(F),function($){var re=S.node($),J=re.order;(J<O||C<J)&&!(re.dummy&&S.node(F).dummy)&&u(N,$,F)})}),P=V+1,O=C)}),M}return e.reduce(k,T),N}function o(S,k){var N={};function T(M,O,P,D,L){var U;e.forEach(e.range(O,P),function(V){U=M[V],S.node(U).dummy&&e.forEach(S.predecessors(U),function(z){var C=S.node(z);C.dummy&&(C.order<D||C.order>L)&&u(N,z,U)})})}function A(M,O){var P=-1,D,L=0;return e.forEach(O,function(U,V){if(S.node(U).dummy==="border"){var z=S.predecessors(U);z.length&&(D=S.node(z[0]).order,T(O,L,V,P,D),L=V,P=D)}T(O,L,O.length,D,M.length)}),O}return e.reduce(k,A),N}function l(S,k){if(S.node(k).dummy)return e.find(S.predecessors(k),function(N){return S.node(N).dummy})}function u(S,k,N){if(k>N){var T=k;k=N,N=T}var A=S[k];A||(S[k]=A={}),A[N]=!0}function c(S,k,N){if(k>N){var T=k;k=N,N=T}return e.has(S[k],N)}function h(S,k,N,T){var A={},M={},O={};return e.forEach(k,function(P){e.forEach(P,function(D,L){A[D]=D,M[D]=D,O[D]=L})}),e.forEach(k,function(P){var D=-1;e.forEach(P,function(L){var U=T(L);if(U.length){U=e.sortBy(U,function($){return O[$]});for(var V=(U.length-1)/2,z=Math.floor(V),C=Math.ceil(V);z<=C;++z){var F=U[z];M[L]===L&&D<O[F]&&!c(N,L,F)&&(M[F]=L,M[L]=A[L]=A[F],D=O[F])}}})}),{root:A,align:M}}function p(S,k,N,T,A){var M={},O=d(S,k,N,A),P=A?"borderLeft":"borderRight";function D(V,z){for(var C=O.nodes(),F=C.pop(),$={};F;)$[F]?V(F):($[F]=!0,C.push(F),C=C.concat(z(F))),F=C.pop()}function L(V){M[V]=O.inEdges(V).reduce(function(z,C){return Math.max(z,M[C.v]+O.edge(C))},0)}function U(V){var z=O.outEdges(V).reduce(function(F,$){return Math.min(F,M[$.w]-O.edge($))},Number.POSITIVE_INFINITY),C=S.node(V);z!==Number.POSITIVE_INFINITY&&C.borderType!==P&&(M[V]=Math.max(M[V],z))}return D(L,O.predecessors.bind(O)),D(U,O.successors.bind(O)),e.forEach(T,function(V){M[V]=M[N[V]]}),M}function d(S,k,N,T){var A=new n,M=S.graph(),O=_(M.nodesep,M.edgesep,T);return e.forEach(k,function(P){var D;e.forEach(P,function(L){var U=N[L];if(A.setNode(U),D){var V=N[D],z=A.edge(V,U);A.setEdge(V,U,Math.max(O(S,L,D),z||0))}D=L})}),A}function m(S,k){return e.minBy(e.values(k),function(N){var T=Number.NEGATIVE_INFINITY,A=Number.POSITIVE_INFINITY;return e.forIn(N,function(M,O){var P=b(S,O)/2;T=Math.max(M+P,T),A=Math.min(M-P,A)}),T-A})}function y(S,k){var N=e.values(k),T=e.min(N),A=e.max(N);e.forEach(["u","d"],function(M){e.forEach(["l","r"],function(O){var P=M+O,D=S[P],L;if(D!==k){var U=e.values(D);L=O==="l"?T-e.min(U):A-e.max(U),L&&(S[P]=e.mapValues(D,function(V){return V+L}))}})})}function w(S,k){return e.mapValues(S.ul,function(N,T){if(k)return S[k.toLowerCase()][T];var A=e.sortBy(e.map(S,T));return(A[1]+A[2])/2})}function E(S){var k=r.buildLayerMatrix(S),N=e.merge(i(S,k),o(S,k)),T={},A;e.forEach(["u","d"],function(O){A=O==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(P){P==="r"&&(A=e.map(A,function(V){return e.values(V).reverse()}));var D=(O==="u"?S.predecessors:S.successors).bind(S),L=h(S,A,N,D),U=p(S,A,L.root,L.align,P==="r");P==="r"&&(U=e.mapValues(U,function(V){return-V})),T[O+P]=U})});var M=m(S,T);return y(T,M),w(T,S.graph().align)}function _(S,k,N){return function(T,A,M){var O=T.node(A),P=T.node(M),D=0,L;if(D+=O.width/2,e.has(O,"labelpos"))switch(O.labelpos.toLowerCase()){case"l":L=-O.width/2;break;case"r":L=O.width/2;break}if(L&&(D+=N?L:-L),L=0,D+=(O.dummy?k:S)/2,D+=(P.dummy?k:S)/2,D+=P.width/2,e.has(P,"labelpos"))switch(P.labelpos.toLowerCase()){case"l":L=P.width/2;break;case"r":L=-P.width/2;break}return L&&(D+=N?L:-L),L=0,D}}function b(S,k){return S.node(k).width}return av}var lv,ME;function u5(){if(ME)return lv;ME=1;var e=at(),n=fn(),r=l5().positionX;lv=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,h=0;e.forEach(u,function(p){var d=e.max(e.map(p,function(m){return l.node(m).height}));e.forEach(p,function(m){l.node(m).y=h+d/2}),h+=d+c})}return lv}var uv,OE;function c5(){if(OE)return uv;OE=1;var e=at(),n=W4(),r=V4(),i=Y4(),o=fn().normalizeRanks,l=K4(),u=fn().removeEmptyRanks,c=X4(),h=Q4(),p=Z4(),d=a5(),m=u5(),y=fn(),w=tr().Graph;uv=E;function E(q,Q){var ne=Q&&Q.debugTiming?y.time:y.notime;ne("layout",function(){var ae=ne(" buildLayoutGraph",function(){return D(q)});ne(" runLayout",function(){_(ae,ne)}),ne(" updateInputGraph",function(){b(q,ae)})})}function _(q,Q){Q(" makeSpaceForEdgeLabels",function(){L(q)}),Q(" removeSelfEdges",function(){W(q)}),Q(" acyclic",function(){n.run(q)}),Q(" nestingGraph.run",function(){c.run(q)}),Q(" rank",function(){i(y.asNonCompoundGraph(q))}),Q(" injectEdgeLabelProxies",function(){U(q)}),Q(" removeEmptyRanks",function(){u(q)}),Q(" nestingGraph.cleanup",function(){c.cleanup(q)}),Q(" normalizeRanks",function(){o(q)}),Q(" assignRankMinMax",function(){V(q)}),Q(" removeEdgeLabelProxies",function(){z(q)}),Q(" normalize.run",function(){r.run(q)}),Q(" parentDummyChains",function(){l(q)}),Q(" addBorderSegments",function(){h(q)}),Q(" order",function(){d(q)}),Q(" insertSelfEdges",function(){Z(q)}),Q(" adjustCoordinateSystem",function(){p.adjust(q)}),Q(" position",function(){m(q)}),Q(" positionSelfEdges",function(){I(q)}),Q(" removeBorderNodes",function(){J(q)}),Q(" normalize.undo",function(){r.undo(q)}),Q(" fixupEdgeLabelCoords",function(){$(q)}),Q(" undoCoordinateSystem",function(){p.undo(q)}),Q(" translateGraph",function(){C(q)}),Q(" assignNodeIntersects",function(){F(q)}),Q(" reversePoints",function(){re(q)}),Q(" acyclic.undo",function(){n.undo(q)})}function b(q,Q){e.forEach(q.nodes(),function(ne){var ae=q.node(ne),fe=Q.node(ne);ae&&(ae.x=fe.x,ae.y=fe.y,Q.children(ne).length&&(ae.width=fe.width,ae.height=fe.height))}),e.forEach(q.edges(),function(ne){var ae=q.edge(ne),fe=Q.edge(ne);ae.points=fe.points,e.has(fe,"x")&&(ae.x=fe.x,ae.y=fe.y)}),q.graph().width=Q.graph().width,q.graph().height=Q.graph().height}var S=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},N=["acyclicer","ranker","rankdir","align"],T=["width","height"],A={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],O={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},P=["labelpos"];function D(q){var Q=new w({multigraph:!0,compound:!0}),ne=K(q.graph());return Q.setGraph(e.merge({},k,G(ne,S),e.pick(ne,N))),e.forEach(q.nodes(),function(ae){var fe=K(q.node(ae));Q.setNode(ae,e.defaults(G(fe,T),A)),Q.setParent(ae,q.parent(ae))}),e.forEach(q.edges(),function(ae){var fe=K(q.edge(ae));Q.setEdge(ae,e.merge({},O,G(fe,M),e.pick(fe,P)))}),Q}function L(q){var Q=q.graph();Q.ranksep/=2,e.forEach(q.edges(),function(ne){var ae=q.edge(ne);ae.minlen*=2,ae.labelpos.toLowerCase()!=="c"&&(Q.rankdir==="TB"||Q.rankdir==="BT"?ae.width+=ae.labeloffset:ae.height+=ae.labeloffset)})}function U(q){e.forEach(q.edges(),function(Q){var ne=q.edge(Q);if(ne.width&&ne.height){var ae=q.node(Q.v),fe=q.node(Q.w),te={rank:(fe.rank-ae.rank)/2+ae.rank,e:Q};y.addDummyNode(q,"edge-proxy",te,"_ep")}})}function V(q){var Q=0;e.forEach(q.nodes(),function(ne){var ae=q.node(ne);ae.borderTop&&(ae.minRank=q.node(ae.borderTop).rank,ae.maxRank=q.node(ae.borderBottom).rank,Q=e.max(Q,ae.maxRank))}),q.graph().maxRank=Q}function z(q){e.forEach(q.nodes(),function(Q){var ne=q.node(Q);ne.dummy==="edge-proxy"&&(q.edge(ne.e).labelRank=ne.rank,q.removeNode(Q))})}function C(q){var Q=Number.POSITIVE_INFINITY,ne=0,ae=Number.POSITIVE_INFINITY,fe=0,te=q.graph(),ce=te.marginx||0,Ce=te.marginy||0;function ve(Re){var ye=Re.x,Ee=Re.y,Ye=Re.width,we=Re.height;Q=Math.min(Q,ye-Ye/2),ne=Math.max(ne,ye+Ye/2),ae=Math.min(ae,Ee-we/2),fe=Math.max(fe,Ee+we/2)}e.forEach(q.nodes(),function(Re){ve(q.node(Re))}),e.forEach(q.edges(),function(Re){var ye=q.edge(Re);e.has(ye,"x")&&ve(ye)}),Q-=ce,ae-=Ce,e.forEach(q.nodes(),function(Re){var ye=q.node(Re);ye.x-=Q,ye.y-=ae}),e.forEach(q.edges(),function(Re){var ye=q.edge(Re);e.forEach(ye.points,function(Ee){Ee.x-=Q,Ee.y-=ae}),e.has(ye,"x")&&(ye.x-=Q),e.has(ye,"y")&&(ye.y-=ae)}),te.width=ne-Q+ce,te.height=fe-ae+Ce}function F(q){e.forEach(q.edges(),function(Q){var ne=q.edge(Q),ae=q.node(Q.v),fe=q.node(Q.w),te,ce;ne.points?(te=ne.points[0],ce=ne.points[ne.points.length-1]):(ne.points=[],te=fe,ce=ae),ne.points.unshift(y.intersectRect(ae,te)),ne.points.push(y.intersectRect(fe,ce))})}function $(q){e.forEach(q.edges(),function(Q){var ne=q.edge(Q);if(e.has(ne,"x"))switch((ne.labelpos==="l"||ne.labelpos==="r")&&(ne.width-=ne.labeloffset),ne.labelpos){case"l":ne.x-=ne.width/2+ne.labeloffset;break;case"r":ne.x+=ne.width/2+ne.labeloffset;break}})}function re(q){e.forEach(q.edges(),function(Q){var ne=q.edge(Q);ne.reversed&&ne.points.reverse()})}function J(q){e.forEach(q.nodes(),function(Q){if(q.children(Q).length){var ne=q.node(Q),ae=q.node(ne.borderTop),fe=q.node(ne.borderBottom),te=q.node(e.last(ne.borderLeft)),ce=q.node(e.last(ne.borderRight));ne.width=Math.abs(ce.x-te.x),ne.height=Math.abs(fe.y-ae.y),ne.x=te.x+ne.width/2,ne.y=ae.y+ne.height/2}}),e.forEach(q.nodes(),function(Q){q.node(Q).dummy==="border"&&q.removeNode(Q)})}function W(q){e.forEach(q.edges(),function(Q){if(Q.v===Q.w){var ne=q.node(Q.v);ne.selfEdges||(ne.selfEdges=[]),ne.selfEdges.push({e:Q,label:q.edge(Q)}),q.removeEdge(Q)}})}function Z(q){var Q=y.buildLayerMatrix(q);e.forEach(Q,function(ne){var ae=0;e.forEach(ne,function(fe,te){var ce=q.node(fe);ce.order=te+ae,e.forEach(ce.selfEdges,function(Ce){y.addDummyNode(q,"selfedge",{width:Ce.label.width,height:Ce.label.height,rank:ce.rank,order:te+ ++ae,e:Ce.e,label:Ce.label},"_se")}),delete ce.selfEdges})})}function I(q){e.forEach(q.nodes(),function(Q){var ne=q.node(Q);if(ne.dummy==="selfedge"){var ae=q.node(ne.e.v),fe=ae.x+ae.width/2,te=ae.y,ce=ne.x-fe,Ce=ae.height/2;q.setEdge(ne.e,ne.label),q.removeNode(Q),ne.label.points=[{x:fe+2*ce/3,y:te-Ce},{x:fe+5*ce/6,y:te-Ce},{x:fe+ce,y:te},{x:fe+5*ce/6,y:te+Ce},{x:fe+2*ce/3,y:te+Ce}],ne.label.x=ne.x,ne.label.y=ne.y}})}function G(q,Q){return e.mapValues(e.pick(q,Q),Number)}function K(q){var Q={};return e.forEach(q,function(ne,ae){Q[ae.toLowerCase()]=ne}),Q}return uv}var cv,PE;function d5(){if(PE)return cv;PE=1;var e=at(),n=fn(),r=tr().Graph;cv={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,h){var p="layer"+h;u.setNode(p,{rank:"same"}),e.reduce(c,function(d,m){return u.setEdge(d,m,{style:"invis"}),m})}),u}return cv}var dv,LE;function f5(){return LE||(LE=1,dv="0.8.5"),dv}var fv,$E;function h5(){return $E||($E=1,fv={graphlib:tr(),layout:c5(),debug:d5(),util:{time:fn().time,notime:fn().notime},version:f5()}),fv}var p5=h5();const qE=Dv(p5),vo=240,ju=130,uo=74,tc=72,DE=uo+tc;function m5(e,n){var i;let r=vo;for(const o of e)r=Math.max(r,((i=n.get(o.id))==null?void 0:i.width)??vo);return r}const VT=420,g5=2;function Ea(e){var r;return((r=e.data)==null?void 0:r.sessionId)??"_default"}function v5(e,n){return((n==null?void 0:n.get(e))??0)>0?VT:0}function y5(e,n){const r=(n==null?void 0:n.get(e))??0;return r>0?6+r*36:0}function Na(e,n,r){const i=n.get(e);return{w:((i==null?void 0:i.width)??vo)+v5(e,r),h:Math.max((i==null?void 0:i.height)??ju,y5(e,r))}}function w5(e){return[...e.keys()].sort().map(n=>`${n}:${e.get(n)}`).join("|")}function x5(e,n,r,i,o,l){const u=new qE.graphlib.Graph;u.setDefaultEdgeLabel(()=>({})),u.setGraph({rankdir:r,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(S=>!o.has(S)),h=new Set(c);for(const S of c){const{w:k,h:N}=Na(S,i,l);u.setNode(S,{width:k,height:N})}for(const S of n)h.has(S.source)&&h.has(S.target)&&u.setEdge(S.source,S.target);qE.layout(u);const p=new Map;let d=1/0,m=1/0,y=-1/0,w=-1/0;for(const S of c){const k=u.node(S);if(!k)continue;const N=i.get(S),T=(N==null?void 0:N.width)??vo,A=(N==null?void 0:N.height)??ju,M=Na(S,i,l),O=k.x-M.w/2,P=k.y-M.h/2;p.set(S,{x:O,y:P}),O<d&&(d=O),P<m&&(m=P),O+T>y&&(y=O+T),P+A>w&&(w=P+A)}if(Number.isFinite(d)&&Number.isFinite(m))for(const[S,k]of p)p.set(S,{x:k.x-d,y:k.y-m});const E=Number.isFinite(y)?y-d:0,_=Number.isFinite(w)?w-m:0;let b=null;for(const S of e){const k=o.get(S);if(!k)continue;const N=i.get(S),T=(N==null?void 0:N.width)??vo,A=(N==null?void 0:N.height)??ju;b=b===null?{minX:k.x,minY:k.y,maxX:k.x+T,maxY:k.y+A}:{minX:Math.min(b.minX,k.x),minY:Math.min(b.minY,k.y),maxX:Math.max(b.maxX,k.x+T),maxY:Math.max(b.maxY,k.y+A)}}return{positions:p,width:E,height:_,pinnedBox:b}}function _5(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 S of e){const k=Ea(S),N=c.get(k);N?N.push(S.id):c.set(k,[S.id])}const p=Array.from(c.keys()).sort().map(S=>({sid:S,...x5(c.get(S),n,i,l,o,u)})),d=m5(e,l),m=r.availableHeight&&r.availableHeight>0?r.availableHeight:Number.POSITIVE_INFINITY,y=S=>{const k=[[]];let N=0;for(const T of p)k.length<S&&N>0&&N+T.height>m&&(k.push([]),N=0),k[k.length-1].push(T),N+=T.height+DE;return k},w=S=>S.reduce((k,N)=>Math.max(k,N.width),0)+VT;let E=y(r.availableWidth?g5:1);E.length>1&&E.reduce((k,N)=>k+w(N),0)+d*(E.length-1)>(r.availableWidth??0)&&(E=y(1));const _=new Map;let b=0;for(const S of E){const k=w(S);let N=0;for(const{positions:T,height:A,pinnedBox:M}of S){for(const[P,D]of T)_.set(P,{x:D.x+b,y:D.y+N});let O=N+A;M&&M.maxY>O&&M.minX<b+k&&b<M.maxX&&(O=M.maxY),N=O+DE}b+=k+d}return e.map(S=>{const k=o.get(S.id);if(k)return{...S,position:k};const N=_.get(S.id);return N?{...S,position:N}:S})}function b5(e,n,r,i,o){const u=uo+tc,c=60,h=w=>Na(w,i,o),p=new Map(e.map(w=>[w.id,Ea(w)])),d=[],m=e.map(w=>({id:w.id,pos:r.get(w.id)??n.get(w.id)})).filter(w=>w.pos!=null).sort((w,E)=>w.pos.y-E.pos.y||w.pos.x-E.pos.x||w.id.localeCompare(E.id)),y=[];for(const{id:w,pos:E}of m){const{w:_,h:b}=h(w),S=p.get(w)??"_default";if(r.has(w)){d.push({x:E.x,y:E.y,w:_,h:b,sid:S});continue}let k=E.y;for(let N=0;N<d.length+1;N++){const T=d.find(A=>{const M=A.sid===S?24:c,O=A.sid===S?24:u;return E.x<A.x+A.w+M&&A.x<E.x+_+M&&k<A.y+A.h+O&&A.y<k+b+O});if(!T)break;k=T.y+T.h+(T.sid===S?24:u)}k!==E.y&&(n.set(w,{x:E.x,y:k}),y.push(w)),d.push({x:E.x,y:k,w:_,h:b,sid:S})}return y}function S5(e,n,r,i,o,l){const u=_=>Na(_,i,l),c=_=>r.get(_)??n.get(_),h=new Map;for(const _ of e){if(!c(_.id))continue;const b=Ea(_),S=h.get(b);S?S.push(_):h.set(b,[_])}const p=new Set;for(const[_,b]of h)b.every(S=>o.has(S.id)&&!r.has(S.id))&&p.add(_);const d=new Map,m=[];for(const _ of e){const b=c(_.id);if(!b)continue;const{w:S,h:k}=u(_.id),N=Ea(_);p.has(N)?(d.get(N)??d.set(N,[]).get(N)).push(_):m.push({x:b.x,y:b.y,w:S,h:k})}if(d.size===0)return[];const y=uo+tc,w=(_,b,S,k)=>m.some(N=>_<N.x+N.w+uo&&N.x<_+S+uo&&b<N.y+N.h+y&&N.y<b+k+y),E=[];for(const _ of[...d.keys()].sort()){const b=d.get(_);let S=1/0,k=1/0,N=-1/0,T=-1/0;for(const U of b){const V=c(U.id),{w:z,h:C}=u(U.id);S=Math.min(S,V.x),k=Math.min(k,V.y),N=Math.max(N,V.x+z),T=Math.max(T,V.y+C)}const A=N-S,M=T-k,O=[...new Set(m.map(U=>Math.round(U.x)))].sort((U,V)=>U-V),P=O.length?O:[S],D=[0,...m.map(U=>U.y+U.h+y)].sort((U,V)=>U-V);let L=null;e:for(const U of P)for(const V of D){if(V>=k)break;if(!w(U,V,A,M)){L={x:U,y:V};break e}}if(L){const U=L.x-S,V=L.y-k;for(const z of b){const C=c(z.id);n.set(z.id,{x:C.x+U,y:C.y+V})}E.push(_)}for(const U of b){const V=c(U.id),{w:z,h:C}=u(U.id);m.push({x:V.x,y:V.y,w:z,h:C})}}return E}function k5(e,n,r,i,o,l=!1,u){const p=uo+tc+1,d=8,m=1.75,y=200,w=.7,E=.01,_=L=>Na(L,i,u),b=L=>r.get(L)??n.get(L),S=new Map;for(const L of e){if(!b(L.id))continue;const U=Ea(L),V=S.get(U);V?V.push(L):S.set(U,[L])}const k=[],N=new Set,T=new Set,A=o.size===0;for(const L of[...S.keys()].sort()){const U=S.get(L);let V=1/0,z=1/0,C=-1/0,F=-1/0,$=!1;for(const Z of U){const I=b(Z.id),{w:G,h:K}=_(Z.id);V=Math.min(V,I.x),z=Math.min(z,I.y),C=Math.max(C,I.x+G),F=Math.max(F,I.y+K),r.has(Z.id)&&($=!0)}const re=C-V,J=F-z;T.add(L);const W=o.get(L);W&&(re>W.w+d||J>W.h+d)&&N.add(L),o.set(L,{w:re,h:J}),k.push({sid:L,members:U.map(Z=>Z.id),x:V,y:z,w:re,h:J,anchored:$,mass:1})}for(const L of[...o.keys()])T.has(L)||o.delete(L);if(l||A)return[];let M=!1;for(let L=0;L<k.length&&!M;L++)for(let U=L+1;U<k.length;U++){const V=k[L],z=k[U];if(!(V.anchored&&z.anchored)&&Math.abs(V.x+V.w/2-(z.x+z.w/2))<(V.w+z.w)/2+61&&Math.abs(V.y+V.h/2-(z.y+z.h/2))<(V.h+z.h)/2+p){M=!0;break}}if(N.size===0&&!M)return[];if(N.size>0)for(const L of k)N.has(L.sid)&&(L.mass=8);else for(const L of k)L.mass=Math.max(1,L.w*L.h/(vo*ju));const O=new Map(k.map(L=>[L.sid,L.x])),P=new Map(k.map(L=>[L.sid,L.y]));for(let L=0;L<y;L++){const U=new Map,V=new Map;let z=0;for(let C=0;C<k.length;C++)for(let F=C+1;F<k.length;F++){const $=k[C],re=k[F];if($.anchored&&re.anchored)continue;const J=$.x+$.w/2,W=$.y+$.h/2,Z=re.x+re.w/2,I=re.y+re.h/2,G=($.w+re.w)/2+61-Math.abs(J-Z),K=($.h+re.h)/2+p-Math.abs(W-I);if(G<=0||K<=0)continue;const q=(De,Je)=>!De.anchored&&!(Je<0&&De.x<=0),Q=(De,Je)=>!De.anchored&&!(Je<0&&De.y<=0),ne=(De,Je,Xe)=>{const Ot=De===Je,lt=Ot?$.sid<re.sid?-1:1:Math.sign(De-Je);return Xe($,lt)||Xe(re,-lt)?lt:Ot&&(Xe($,-lt)||Xe(re,lt))?-lt:0},ae=ne(J,Z,q),fe=ne(W,I,Q),te=ae!==0,ce=fe!==0;if(!te&&!ce)continue;const Ce=te&&(!ce||G*m<K),[ve,Re,ye,Ee]=Ce?[ae,G,U,q]:[fe,K,V,Q],Ye=Ee($,ve),we=Ee(re,-ve),_e=$.mass,Be=re.mass,it=Ye?we?Be/(_e+Be):1:0,ft=we?Ye?_e/(_e+Be):1:0,Ze=Re*w;ye.set($.sid,(ye.get($.sid)??0)+ve*Ze*it),ye.set(re.sid,(ye.get(re.sid)??0)-ve*Ze*ft),z+=Ze}for(const C of k)C.anchored||(C.x=Math.max(0,C.x+(U.get(C.sid)??0)),C.y=Math.max(0,C.y+(V.get(C.sid)??0)));if(z<E)break}const D=[];for(const L of k){const U=L.x-O.get(L.sid),V=L.y-P.get(L.sid);if(!(Math.abs(U)<1&&Math.abs(V)<1)){for(const z of L.members){if(r.has(z))continue;const C=n.get(z);C&&n.set(z,{x:C.x+U,y:C.y+V})}D.push(L.sid)}}return D}const E5=600;function Pv(e,n){return!(e.exitAt!=null&&n-e.exitAt>E5||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function N5(e,n){const r=new Set;for(const i of e.agents.values())Pv(i,n)&&r.add(i.id);return r}function C5(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 T5(e,n,r=0){if(!e)return!1;for(const i of n)if(C5(e,i,r))return!0;return!1}const GT="sessionGroup";function j5(e,n){var i;if(e.type===GT)return"transparent";const r=(i=e.data)==null?void 0:i.state;return n(r==="err"?"--err":r==="active"?"--inflight":"--ok")}const R5="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1).";function A5(e){if(e.checkDisabled)return R5;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 I5(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 M5(e){const n=e.kind==="restart"?`v${e.to} is installed and waiting for a restart`:`v${e.to} is available on npm`;return`Version v${e.from}, ${n} — ${e.open?"hide":"show"} the notice`}function O5(e){if(e==null)return{kind:"unknown",lead:"No data yet. Start a Claude Code or Codex session — it appears here as soon as the deck sees its first event.",workspace:null,tail:""};const 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."}}const Lv={kind:"assumed",claude:!0,codex:!0};function P5(e){if(!e||typeof e!="object")return Lv;const n=e.providers;if(!n||typeof n!="object")return Lv;const r=n;return{kind:"reported",claude:r.claude!==!1,codex:r.codex!==!1}}function YT(e){const n=Math.max(0,Math.floor(e));return`${n} event${n===1?"":"s"}`}function L5(e){return e.connected?e.paused?{tone:"paused",label:"paused",title:e.held>0?`Connected — ${YT(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 $5(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:`${YT(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 KT(e,n){return e!==""&&n>0}function q5(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:KT(e,n)}}const D5="Search agents, tools, model…";function XT(e,n){var i,o,l,u;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)||e.model&&(e.model.toLowerCase().includes(r)||Rs(e.model).toLowerCase().includes(r))||(u=e.provider)!=null&&u.toLowerCase().startsWith(r))return!0;for(const c of e.tools)if(c.name.toLowerCase().includes(r))return!0;return!1}function ca(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const F5={agent:uL,sessionGroup:_L},QT="react-flow__node";function FE(e){var n,r;return!!e&&((r=(n=e.classList)==null?void 0:n.contains)==null?void 0:r.call(n,QT))===!0}function z5(e){try{const n=document.querySelector(`.${QT}[data-id="${CSS.escape(e)}"]`);n==null||n.focus({preventScroll:!0})}catch{}}const B5=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),U5=420,lu=18,H5=200,W5=5*6e4,V5=6,G5=2*6e4,Cy="agent-dag.layout",Ty="agent-dag.viewport",ZT="agent-dag.summariesDismissed",JT="agent-dag.sessionListOpen",ej="agent-dag.detailOpen",tj="agent-dag.usagePanelOpen",zE="agent-dag.accountsPanelOpen",BE="agent-dag.versionNoticeDismissed",UE="agent-dag.oldNameNoticeDismissed",Y5=15*6e4,HE={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:"},WE="agent-dag.autoRestart",VE="agent-dag.bundleReloadedFor";function K5(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(JT)==="1"}catch{return!1}}function X5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(JT,e?"1":"0")}catch{}}function Q5(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(ej)==="1"}catch{return!1}}function Z5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(ej,e?"1":"0")}catch{}}function J5(){const e=UC(tj);return e===null?!0:e==="1"}function eF(e){if(!(typeof window>"u"))try{window.localStorage.setItem(tj,e?"1":"0")}catch{}}function tF(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(ZT);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 GE(e){if(!(typeof window>"u"))try{const n=Array.from(e),r=n.length>200?n.slice(-200):n;window.localStorage.setItem(ZT,JSON.stringify(r))}catch{}}function nF(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(Cy);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 hv(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(Cy,JSON.stringify({v:2,positions:r,pins:Array.from(n.keys())}))}catch{}}function rF(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Ty);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 sF(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Ty,JSON.stringify(e))}catch{}}function YE(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Cy)}catch{}try{window.localStorage.removeItem(Ty)}catch{}}}function iF(e,n){const r=e.agents.get(n);if(!r)return;const i=[];for(const d of e.agents.values())d.sessionId===n&&i.push(d);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(d=>({id:d.id,kind:d.kind,label:d.label,parentId:d.parentId,state:d.state,startedAt:d.startedAt,endedAt:d.endedAt,model:d.model,cwd:d.cwd,usage:d.usage,prompts:d.prompts,tools:d.tools.map(m=>({id:m.id,name:m.name,inputPreview:m.inputPreview,startedAt:m.startedAt,endedAt:m.endedAt,ok:m.ok,errorPreview:m.errorPreview,usage:m.usage}))}))},l=JSON.stringify(o,null,2),u=new Blob([l],{type:"application/json"}),c=URL.createObjectURL(u),h=document.createElement("a"),p=(r.label||"session").replace(/[^a-z0-9._-]/gi,"_");h.href=c,h.download=`${Gt}-${p}-${n.slice(0,8)}.json`,document.body.appendChild(h),h.click(),document.body.removeChild(h),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const $v={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},qv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},nj=IC;function oF(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 aF(e,n,r,i,o,l,u,c,h,p,d,m,y,w,E,_,b,S,k){const N=[],T=[],A=new Set;if(l)for(const z of e.agents.values())S.has(z.id)&&XT(z,l)&&A.add(z.id);const M=KT(l,A.size);for(const z of e.agents.values()){if(!S.has(z.id))continue;const C=M&&!A.has(z.id),F=z.exitAt!=null,$=b!=null&&!b.has(z.id),re=[C?"rf-dim":"",F?"rf-exiting":"",$?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,J=u.get(z.id);if(N.push({id:z.id,type:"agent",position:{x:0,y:0},data:{...z,now:n,onOpenContext:k},className:re,...J?{width:J.width,height:J.height}:null}),z.parentId&&S.has(z.parentId)){const W=ry(z.sessionId),Z=l&&!A.has(z.id)&&!A.has(z.parentId),I=F,G=_.size>0&&(_.has(z.id)||_.has(z.parentId)),K=b!=null&&!b.has(z.id)&&!b.has(z.parentId),q=z.state==="active"?2:1.5,Q=G?q+1.5:q,ne=Z||I?.2:K?.12:1,ae=["sess-edge",z.state==="active"?"sess-live":"sess-idle",I?"rf-edge-exiting":"",G?"rf-edge-selected":""].filter(Boolean).join(" ");T.push({id:`e:${z.parentId}->${z.id}`,source:z.parentId,target:z.id,animated:(z.state==="active"||G)&&!Z&&!I,type:"smoothstep",style:{"--session-hue":W,strokeWidth:Q,opacity:ne,transition:"var(--edge-transition)"},className:ae})}}const O=new Map;for(const z of e.agents.values())z.tools.length>0&&O.set(z.id,Math.min(4,z.tools.length));const P=`${w}#lanes:${w5(O)}`,D=N.filter(z=>_$(z.id,o,m,y));if(D.length>0||P!==E.current){if(D.length>0){const z=_5(N,T,{direction:"LR",pinned:o,measured:u,availableWidth:r,availableHeight:i,lanes:O});for(const C of z)BC(C.id,m,y)&&S$(C.id,C.position,m,y);S5(N,m,o,u,new Set(D.map(C=>C.id)),O)}b5(N,m,o,u,O),E.current=P}const L=k5(N,m,o,u,c,!p||d,O);L.length>0&&h(L),su(m,e.agents),su(y,e.agents),su(o,e.agents),su(u,x$(e.agents.values()));const U=[];let V=!1;for(const z of N){let C=o.get(z.id)??m.get(z.id);C||(C=b$(z.id,m,y),V=!0),U.push({...z,position:C})}return V&&(E.current=""),{nodes:U,edges:T}}function lF(){return g.jsx(ny,{children:g.jsx(uF,{})})}function uF(){var Ga,Ya,Ka,Xa;const e=Aa(),n=R.useRef(Rv()),[,r]=R.useState(0),i=R.useCallback(()=>r(H=>H+1),[]),[o,l]=R.useState(()=>new Set),[u,c]=R.useState(null),[h,p]=R.useState(null),d=R.useCallback((H,Y)=>{l(oe=>{if(!Y)return new Set([H]);const de=new Set(oe);return de.has(H)?de.delete(H):de.add(H),de}),c(oe=>Y&&oe===H?oe:H)},[]),m=R.useCallback(()=>{l(new Set),c(null)},[]),[y,w]=R.useState(null),[E,_]=R.useState(null),b=R.useCallback(H=>_(H),[]),[S,k]=R.useState(!1),N=R.useRef(tF()),[T,A]=R.useState(K5);R.useEffect(()=>{X5(T)},[T]);const[M,O]=R.useState(Q5);R.useEffect(()=>{Z5(M)},[M]);const[P,D]=R.useState(J5);R.useEffect(()=>{eF(P)},[P]);const[L,U]=R.useState(()=>{try{const H=window.localStorage.getItem(zE);return H===null?!0:H==="1"}catch{return!0}});R.useEffect(()=>{try{window.localStorage.setItem(zE,L?"1":"0")}catch{}},[L]);const[V,z]=R.useState(null),[C,F]=R.useState(!1),[$,re]=R.useState(0),[J,W]=R.useState(0);R.useEffect(()=>{fetch("/api/sound-hook").then(H=>H.ok?H.json():null).then(H=>{H!=null&&H.ok&&(z(H.enabled===!0),re((H.foreign??[]).filter(Y=>Y.worksHere).length),W(typeof H.parked=="number"?H.parked:0))}).catch(()=>{})},[]);const Z=R.useCallback(async()=>{F(!0);try{const Y=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!V})})).json().catch(()=>null);Y!=null&&Y.ok&&z(Y.enabled===!0),fetch("/api/sound-hook").then(oe=>oe.ok?oe.json():null).then(oe=>{oe!=null&&oe.ok&&(re((oe.foreign??[]).filter(de=>de.worksHere).length),W(typeof oe.parked=="number"?oe.parked:0))}).catch(()=>{})}catch{}finally{F(!1)}},[V]),[I,G]=R.useState(!1),[K,q]=R.useState(null),[Q,ne]=R.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(BE)??""}catch{return""}}),[ae,fe]=R.useState(!1),te=R.useRef(0),[ce,Ce]=R.useState(!1),ve=R.useCallback((H=!1)=>{H&&(te.current=Date.now(),Ce(!0)),fetch(H?"/api/version?refresh=1":"/api/version").then(Y=>Y.ok?Y.json():null).then(Y=>{Y&&q(Y)}).catch(()=>{}).finally(()=>{H&&Ce(!1)})},[]),Re=R.useCallback(()=>{ve(Date.now()-te.current>=Y5)},[ve]);R.useEffect(()=>{ve();const H=window.setInterval(Re,5*6e4),Y=()=>{document.visibilityState==="visible"&&Re()};return document.addEventListener("visibilitychange",Y),()=>{window.clearInterval(H),document.removeEventListener("visibilitychange",Y)}},[ve,Re]),R.useEffect(()=>{I&&ve()},[I,ve]);const ye=(K==null?void 0:K.notice)??null,[Ee,Ye]=R.useState(null),[we,_e]=R.useState(Lv);R.useEffect(()=>{let H=!1;return fetch("/api/health").then(Y=>Y.ok?Y.json():null).then(Y=>{H||(_e(P5(Y)),!(!Y||typeof Y.workspace!="string")&&Ye(Y.workspace))}).catch(()=>{}),()=>{H=!0}},[I]);const Be=R.useRef(we);Be.current=we;const it=ye?`${ye.kind}:${ye.to}`:"",ft=ye!=null&&Q!==it,Ze=R.useCallback(()=>{if(!ye)return;const H=Q===it?"":it;ne(H);try{window.localStorage.setItem(BE,H)}catch{}},[ye,it,Q]),[De,Je]=R.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(UE)??""}catch{return""}}),Xe=K!=null&&K.invokedAs&&K.invokedAs!==Gt?K.invokedAs:null,Ot=Xe!=null&&De!==Xe,lt=R.useCallback(()=>{if(Xe){Je(Xe);try{window.localStorage.setItem(UE,Xe)}catch{}}},[Xe]),Qe=((Ga=K==null?void 0:K.upgrade)==null?void 0:Ga.state)??"idle",Pt=u$(K==null?void 0:K.upgrade),zt=R.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}ve()},[ve]);R.useEffect(()=>{if(Qe!=="running")return;const H=window.setInterval(ve,3e3);return()=>window.clearInterval(H)},[Qe,ve]);const et=R.useCallback(async()=>{var oe;const H=K==null?void 0:K.command;if(!H)return;let Y=!1;try{Y=await Promise.race([((oe=navigator.clipboard)==null?void 0:oe.writeText(H).then(()=>!0))??Promise.resolve(!1),new Promise(de=>window.setTimeout(()=>de(!1),500))])}catch{Y=!1}if(!Y)try{const de=document.createElement("textarea");de.value=H,de.setAttribute("readonly",""),de.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(de),de.select(),Y=document.execCommand("copy"),de.remove()}catch{Y=!1}Y&&(fe(!0),window.setTimeout(()=>fe(!1),1600))},[K==null?void 0:K.command]),bt=R.useCallback(()=>{A(H=>(H||U(!1),!H))},[]),ht=R.useCallback(()=>{U(H=>(H||A(!1),!H))},[]),[vt,hn]=R.useState(!1),[Yt,Lt]=R.useState(0),bn=R.useRef(null),[gr,Sn]=R.useState(!1),Bt=R.useRef(null),[Fn,pn]=R.useState(0),vr=R.useRef(C$()),[Hr,xi]=R.useState(!1),Wr=R.useCallback(()=>{const H=vr.current,Y=H.setPaused(!H.paused);for(const oe of Y)n.current=Ux(n.current,oe);xi(H.paused)},[]),[ut,_i]=R.useState(Date.now()),[mn,Is]=R.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(WE)!=="0"}catch{return!0}}),yr=R.useCallback(()=>{Is(H=>{const Y=!H;try{window.localStorage.setItem(WE,Y?"1":"0")}catch{}return Y})},[]),[zn,kn]=R.useState(!1),[Vr,Gr]=R.useState("restart"),[Yr,bi]=R.useState(null),sr=R.useRef(!1),Ms=R.useRef(null),En=R.useRef(0),wr=R.useCallback(async H=>{if(sr.current)return;const Y=(H==null?void 0:H.upgrade)===!0;sr.current=!0,Ms.current=Pt;const oe=++En.current;Gr(Y?"npx":"restart"),kn(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(ye==null?void 0:ye.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:Y})})}catch{}window.setTimeout(()=>{if(En.current===oe&&sr.current){sr.current=!1,kn(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},Y?18e4:3e4)},[ye==null?void 0:ye.to,Pt]),Os=R.useRef(null);R.useEffect(()=>{let H=!1;for(const oe of n.current.agents.values())if(oe.state==="active"){H=!0;break}const Y=d$({enabled:mn,kind:ye==null?void 0:ye.kind,canRestart:(K==null?void 0:K.canRestart)===!0,busy:H,idleSince:Os.current,now:ut});Os.current=Y.idleSince,Y.restart&&wr()},[mn,ye==null?void 0:ye.kind,K==null?void 0:K.canRestart,ut,wr]),R.useEffect(()=>{const H=K==null?void 0:K.running;let Y=null,oe=null;try{Y=window.sessionStorage.getItem("agent-dag.restartPending"),oe=window.sessionStorage.getItem(VE)}catch{return}const de=l$({bundle:"1.35.33",running:H,pending:Y,lastTried:oe});if(de==="reload"){try{window.sessionStorage.setItem(VE,H??"")}catch{return}window.location.reload();return}if(de!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}sr.current=!1,kn(!1),bi(H??null);const xe=window.setTimeout(()=>bi(null),6e3);return()=>window.clearTimeout(xe)},[K==null?void 0:K.running]),R.useEffect(()=>{if(zn&&c$({asked:Ms.current,reported:Pt})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}sr.current=!1,kn(!1)}},[zn,Pt]);const Ps=R.useRef(nF()).current;R.useRef(!1);const jt=R.useRef(new Map(Ps.positions.filter(([H])=>Ps.pins.includes(H)))),xr=R.useRef(null),_r=R.useState(()=>rF())[0],[Kt,Kr]=R.useState(""),[Si,nt]=R.useState(()=>new Set),[br,Xr]=R.useState(I$),[Ls,Qr]=R.useState(!1),Zr=R.useRef(null);R.useEffect(()=>{document.documentElement.dataset.theme=br;try{window.localStorage.setItem(HC,br)}catch{}},[br]),R.useEffect(()=>{if(!_r)return;const H=window.setTimeout(()=>{try{e.setViewport(_r,{duration:0})}catch{}},60);return()=>window.clearTimeout(H)},[e,_r]);const $s=R.useRef(!0);R.useEffect(()=>{const H=new EventSource("/events"),Y=N$(i,{now:()=>Date.now(),setTimeout:(oe,de)=>window.setTimeout(oe,de),clearTimeout:oe=>window.clearTimeout(oe)});return H.addEventListener("open",()=>{G(!0),Qr(!0)}),H.addEventListener("error",()=>G(!1)),H.addEventListener("replay-end",()=>{$s.current=!1,Y.flush()}),H.addEventListener("hook",oe=>{try{const de=JSON.parse(oe.data);if(!vr.current.accept(de))return;n.current=Ux(n.current,de),de.replay===!0||$s.current||Date.now()-de.receivedAt>3e4?Y.replay():Y.live()}catch{}}),()=>{H.close(),Y.cancel()}},[i]),R.useEffect(()=>{const H=setInterval(()=>{const Y=Date.now();_i(Y);let oe=CP(n.current,Y,Bx);TP(n.current,Y,Bx)&&(oe=!0),EP(n.current,Y,H5,W5)&&(oe=!0),NP(n.current,Y,V5,G5)&&(oe=!0),oe&&i()},250);return()=>clearInterval(H)},[i]);const ir=R.useRef(null),St=R.useRef(0),qs=420,pt=R.useCallback((H=500)=>{try{const Se=document.querySelector(".canvas-wrap"),Pe=Array.from(document.querySelectorAll(".react-flow__node")).filter(wt=>wt.offsetWidth>0);if(!Se||Pe.length===0)return;const Fe=Se.getBoundingClientRect(),Ge=e.getViewport();if(!Number.isFinite(Ge.zoom)||Ge.zoom<=0)return;const We=wt=>(wt-Fe.left-Ge.x)/Ge.zoom,ze=wt=>(wt-Fe.top-Ge.y)/Ge.zoom,Tn=Pe.map(wt=>wt.getBoundingClientRect()),Ys=Math.min(...Tn.map(wt=>We(wt.left))),Ao=Math.max(...Tn.map(wt=>We(wt.right))),Ks=Math.min(...Tn.map(wt=>ze(wt.top))),Io=Math.max(...Tn.map(wt=>ze(wt.bottom))),Qa=Ao-Ys,us=Io-Ks;if(!(Qa>0&&us>0))return;const Zt=Math.max(.2,Math.min(1,(Fe.width-160)/(Qa+qs)*.86,(Fe.height-160)/us*.86));e.setViewport({x:80-Ys*Zt,y:Math.max(80,(Fe.height-us*Zt)/2)-Ks*Zt,zoom:Zt},{duration:H}),St.current=Date.now(),window.setTimeout(()=>{try{const wt={x:80-Ys*Zt,y:Math.max(80,(Fe.height-us*Zt)/2)-Ks*Zt,zoom:Zt},Mo=e.getViewport();(Math.abs(Mo.zoom-Zt)>.01||Math.abs(Mo.x-wt.x)>2)&&e.setViewport(wt,{duration:0})}catch{}},H+60)}catch{}},[e]),ko=R.useRef(""),Eo=R.useRef(null),Da=R.useRef(0),Sr=R.useCallback(()=>{Da.current=Date.now()},[]),Jr="agent-dag.autoFitDisabled",gn=R.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Jr)==="1"}catch{return!1}})()),[Ds,Fa]=R.useState(gn.current),za=R.useCallback(()=>{if(!gn.current){gn.current=!0,Fa(!0);try{window.localStorage.setItem(Jr,"1")}catch{}}},[]),No=R.useCallback(()=>{gn.current=!1,Fa(!1);try{window.localStorage.removeItem(Jr)}catch{}pt(400)},[e,pt]);R.useEffect(()=>{const H=setInterval(()=>{if(gn.current||Date.now()-Da.current<800)return;const Y=n.current,oe=Date.now(),de=[];for(const We of Y.agents.values())Pv(We,oe)&&de.push({id:We.id});if(de.length===0)return;const xe=e.getViewport(),Se=window.innerWidth-360,Pe=window.innerHeight-52;let Fe=!1,Ge=!1;for(const{id:We}of de){const ze=or.current.get(We),Tn=jt.current.get(We)??Xt.current.get(We);if(!ze||!Tn)continue;Ge=!0;const Ys=Tn.x*xe.zoom+xe.x,Ao=Tn.y*xe.zoom+xe.y,Ks=(Tn.x+ze.width)*xe.zoom+xe.x,Io=(Tn.y+ze.height)*xe.zoom+xe.y;if(Ks>0&&Ys<Se&&Io>0&&Ao<Pe){Fe=!0;break}}Ge&&!Fe&&pt(600)},1500);return()=>clearInterval(H)},[e]);const ki=R.useRef(!1),or=R.useRef(new Map),es=R.useRef(0),nc=R.useCallback(H=>{const Y=or.current;let oe=!1;for(const de of H.nodeInternals.values()){const xe=de.width,Se=de.height;if(xe==null||Se==null)continue;const Pe=Y.get(de.id);Pe?(Math.abs(Pe.height-Se)>4||Math.abs(Pe.width-xe)>4)&&(Y.set(de.id,{width:xe,height:Se}),oe=!0):(Y.set(de.id,{width:xe,height:Se}),oe=!0)}return oe&&(es.current+=1),es.current},[]),Ei=Ke(nc),[He,Ba]=R.useState(0);R.useEffect(()=>{let H=0;const Y=()=>{const de=or.current;let xe=!1;for(const Se of document.querySelectorAll(".react-flow__node[data-id]")){const Pe=Se.getAttribute("data-id");if(!Pe)continue;const Fe=Se.offsetWidth,Ge=Se.offsetHeight;if(!Fe||!Ge)continue;const We=de.get(Pe);(!We||Math.abs(We.width-Fe)>4||Math.abs(We.height-Ge)>4)&&(de.set(Pe,{width:Fe,height:Ge}),xe=!0)}xe&&Ba(Se=>Se+1)};if(ki.current)return;let oe=0;return document.visibilityState==="hidden"?oe=window.setTimeout(Y,32):H=requestAnimationFrame(Y),()=>{cancelAnimationFrame(H),window.clearTimeout(oe)}});const Xt=R.useRef(new Map(Ps.positions)),Co=R.useRef(new Set),Ni=R.useRef(""),kr=R.useMemo(()=>{const H=[];for(const Y of n.current.agents.values())Pv(Y,ut)&&H.push(Y.id+(Y.parentId?`>${Y.parentId}`:""));return H.sort(),`${H.join("|")}#sv${Ei}.${He}`},[n.current,n.current.lastSeq,ut,Ei,He]),ts=R.useRef(null);R.useEffect(()=>(ts.current!=null&&window.clearTimeout(ts.current),ts.current=window.setTimeout(()=>{hv(Xt.current,jt.current)},1500),()=>{ts.current!=null&&window.clearTimeout(ts.current)}),[kr]),R.useEffect(()=>{if(ko.current===kr)return;const H=ko.current;if(ko.current=kr,!H||gn.current)return;Date.now()-St.current>1200&&pt(400),ir.current&&window.clearTimeout(ir.current),ir.current=window.setTimeout(()=>{gn.current||pt(500)},280)},[kr,e,pt]);const Fs=R.useMemo(()=>{if(o.size===0)return null;const H=new Set;for(const Y of o){const oe=oF(n.current,Y);if(oe)for(const de of oe)H.add(de)}return H.size>0?H:null},[n.current,n.current.lastSeq,o]),Nn=R.useMemo(()=>N5(n.current,ut),[n.current,n.current.lastSeq,ut]),Bn=R.useRef(null),[vn,Un]=R.useState({w:0,h:0});R.useEffect(()=>{const H=Bn.current;if(!H||typeof ResizeObserver>"u")return;const Y=new ResizeObserver(oe=>{var xe;const de=(xe=oe[0])==null?void 0:xe.contentRect;de&&Un(Se=>Math.abs(Se.w-de.width)>40||Math.abs(Se.h-de.height)>40?{w:de.width,h:de.height}:Se)});return Y.observe(H),Un({w:H.clientWidth,h:H.clientHeight}),()=>Y.disconnect()},[]);const zs=R.useCallback(H=>{var oe,de;const Y=H.target;!(Y!=null&&Y.closest)||Y.closest(B5)!==H.currentTarget||(H.preventDefault(),(de=(oe=document.activeElement)==null?void 0:oe.blur)==null||de.call(oe))},[]),Bs=R.useRef(new Map),[Hn,rc]=R.useState(!1);R.useEffect(()=>{const H=window.setTimeout(()=>rc(!0),2500);return()=>window.clearTimeout(H)},[]);const[Ua,Er]=R.useState(!1),ar=R.useRef(null),[Ci,Us]=R.useState(!1),Ha=R.useCallback(()=>{ar.current&&(window.clearTimeout(ar.current),ar.current=null),Er(!1)},[]),sc=R.useCallback(H=>{H.length!==0&&queueMicrotask(()=>{Er(!0),ar.current&&window.clearTimeout(ar.current),ar.current=window.setTimeout(()=>Er(!1),U5+80)})},[]);R.useEffect(()=>()=>{ar.current&&window.clearTimeout(ar.current)},[]);const ns=vn.w>0?vn.w*.92:0,rs=vn.h>0?vn.h:0,{nodes:Qt,edges:Ti}=R.useMemo(()=>aF(n.current,ut,ns,rs,jt.current,Kt,or.current,Bs.current,sc,Hn,Ci,Xt.current,Co.current,kr,Ni,o,Fs,Nn,b),[n.current,n.current.lastSeq,ut,ns,rs,Hn,Ci,Kt,kr,o,Fs,Nn,b,Yt]),Wa=R.useMemo(()=>{const H=new Map;for(const oe of Qt){const de=oe.data;if(!(de!=null&&de.sessionId)||de.exitAt!=null)continue;const xe=oe.width,Se=oe.height;if(xe==null||Se==null)continue;const Pe=oe.position.x,Fe=oe.position.y,Ge=Pe+xe,We=Fe+Se,ze=H.get(de.sessionId);ze?(ze.minX=Math.min(ze.minX,Pe),ze.minY=Math.min(ze.minY,Fe),ze.maxX=Math.max(ze.maxX,Ge),ze.maxY=Math.max(ze.maxY,We)):H.set(de.sessionId,{minX:Pe,minY:Fe,maxX:Ge,maxY:We})}const Y=[];for(const[oe,de]of H){const xe=de.maxX-de.minX+lu*2,Se=de.maxY-de.minY+lu*2;Y.push({id:`group:${oe}`,type:GT,position:{x:de.minX-lu,y:de.minY-lu},data:{sessionId:oe,w:xe,h:Se},width:xe,height:Se,style:{width:xe,height:Se},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return Y},[Qt,ut]),ic=R.useMemo(()=>{const H=[...Wa,...Qt],Y=Bt.current;return!Y||Y.size===0?H:H.map(oe=>{const de=Y.get(oe.id);return de?{...oe,position:de}:oe})},[Wa,Qt,Fn]),Nr=R.useMemo(()=>{if(!Kt)return null;const H=new Set;for(const Y of n.current.agents.values())Nn.has(Y.id)&&XT(Y,Kt)&&H.add(Y.id);return H},[n.current,n.current.lastSeq,Kt,Nn]),Cn=R.useMemo(()=>q5(Kt,(Nr==null?void 0:Nr.size)??0,Nn.size),[Kt,Nr,Nn]),ss=R.useMemo(()=>{const H=new Set;for(const Y of n.current.agents.values())for(const oe of Y.tools)H.add(nj(oe.name));return Object.keys($v).filter(Y=>H.has(Y))},[n.current,n.current.lastSeq]);R.useEffect(()=>{if(ss.length<=1){Sn(!1);return}let H=0;const Y=()=>{const oe=bn.current;if(oe&&!document.hidden){const de=oe.getBoundingClientRect(),xe=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Pe=>Pe.getBoundingClientRect()),Se=T5(de,xe,8);Sn(Pe=>Pe===Se?Pe:Se)}H=window.setTimeout(Y,300)};return Y(),()=>window.clearTimeout(H)},[ss.length]);const is=R.useMemo(()=>{const H=new Map;for(const oe of n.current.agents.values())for(const de of oe.tools){if(!de.name.startsWith("mcp__"))continue;const xe=de.name.slice(5),Se=xe.indexOf("__"),Pe=Se>0?xe.slice(0,Se):xe;H.set(Pe,(H.get(Pe)??0)+1)}const Y=[];for(const[oe,de]of H){let xe=5381;for(let Se=0;Se<oe.length;Se++)xe=(xe<<5)+xe^oe.charCodeAt(Se);Y.push({server:oe,count:de,hue:Math.abs(xe)%360})}return Y.sort((oe,de)=>de.count-oe.count),Y},[n.current,n.current.lastSeq]),lr=R.useCallback(H=>{nt(Y=>{const oe=new Set(Y);return oe.has(H)?oe.delete(H):oe.add(H),oe})},[]),Rt=u?n.current.agents.get(u):null,os=h?Array.from(n.current.agents.values()).flatMap(H=>H.tools).find(H=>H.id===h)??null:null,To=R.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Rv(),jt.current.clear(),or.current.clear(),Xt.current.clear(),Ni.current="",YE(),m(),i()},[i,m]),Hs=R.useRef(S);Hs.current=S;const Ws=R.useRef(!1);Ws.current=os!=null||vt||E!=null||y!=null;const Vs=R.useCallback(H=>{const Y=h$(H,{confirmOpen:Hs.current,modalOpen:Ws.current});Y==="confirm"?k(!0):Y==="clear"&&(k(!1),To())},[To]),$t=R.useCallback(()=>{jt.current.clear(),Xt.current.clear(),Ni.current="",YE(),i(),window.setTimeout(()=>pt(500),80)},[i,e,pt]),Cr=R.useCallback(()=>pt(500),[pt]),as=R.useRef(Qt);as.current=Qt;const ls=R.useRef(u);ls.current=u;const jo=R.useCallback(H=>{const Y=as.current,oe=m$(Y.map(Se=>({id:Se.id,x:Se.position.x,y:Se.position.y})),ls.current,H),de=oe?Y.find(Se=>Se.id===oe):void 0;if(!de)return;const xe=FE(document.activeElement);d(de.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[de]})}catch{}St.current=Date.now(),xe&&z5(de.id)},30)},[d,e]),ji=R.useCallback(H=>{d(H,!1),window.setTimeout(()=>{try{const Y=as.current.find(oe=>oe.id===H);Y&&e.fitView({padding:.3,duration:500,nodes:[Y]}),St.current=Date.now()}catch{}},60)},[d,e]);R.useEffect(()=>{const H=Y=>{var Fe,Ge,We;const oe=Y.target,de={tagName:oe==null?void 0:oe.tagName,isContentEditable:oe==null?void 0:oe.isContentEditable,role:(Fe=oe==null?void 0:oe.getAttribute)==null?void 0:Fe.call(oe,"role"),type:oe==null?void 0:oe.type};if(Y.key==="Escape"){const ze=GP({overlayOpen:Cu.depth()>0,typing:sy(de)});ze==="dismiss"?Cu.dismissTop():ze==="blur"?oe==null||oe.blur():(w$(de)&&(oe==null||oe.blur()),m());return}if(jC(Y))return;const xe=FE(oe)?(Ge=oe==null?void 0:oe.getAttribute)==null?void 0:Ge.call(oe,"data-id"):null,Se=xe&&as.current.some(ze=>ze.id===xe)?xe:null,Pe=v$(Y,Se);if(Pe.kind==="activate"){Y.preventDefault(),d(Pe.nodeId,Pe.additive);return}if(Pe.kind!=="node"&&!(Pe.nodeId==null&&tL(de))){if(Y.key==="/"){Y.preventDefault(),(We=Zr.current)==null||We.focus();return}Y.key===" "&&(Y.preventDefault(),Wr()),(Y.key==="c"||Y.key==="C")&&Vs("shortcut"),(Y.key==="r"||Y.key==="R")&&$t(),(Y.key==="f"||Y.key==="F")&&Cr(),(Y.key==="l"||Y.key==="L")&&bt(),(Y.key==="h"||Y.key==="H")&&hn(ze=>!ze),(Y.key==="u"||Y.key==="U")&&D(ze=>!ze),(Y.key==="a"||Y.key==="A")&&Be.current.claude&&ht(),(Y.key==="j"||Y.key==="J")&&jo(1),(Y.key==="k"||Y.key==="K")&&jo(-1),(Y.key==="t"||Y.key==="T")&&Xr(ze=>ze==="dark"?"light":"dark")}};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[Vs,$t,Cr,m,d,jo,Wr]);const Tr=n.current.agents.size,Gs=new Set(Array.from(n.current.agents.values()).map(H=>H.sessionId)).size,tn=R.useMemo(()=>l3(n.current.agents.values()),[n.current,n.current.lastSeq]),Ro=R.useMemo(()=>u3(n.current.agents.values()),[n.current,n.current.lastSeq]),Va=R.useRef(null);R.useEffect(()=>{const H=M$({waiting:tn.length,running:Ro}),Y=Va.current;if(Va.current=H,(Y==null?void 0:Y.title)!==H.title&&(document.title=H.title),(Y==null?void 0:Y.icon)!==H.icon){const oe=document.querySelector('link[rel="icon"]');oe&&(oe.href=O$[H.icon])}},[tn.length,Ro]);const[oc,ac]=R.useState(""),Ri=L$(tn);R.useEffect(()=>{ac(H=>$$(H,Ri))},[Ri]);const nn=R.useMemo(()=>{let H=0,Y=0,oe=0,de=0,xe=0,Se=0,Pe=0,Fe=0,Ge=0;for(const We of n.current.agents.values()){H+=We.usage.inputTokens,Y+=We.usage.outputTokens,oe+=We.usage.cacheReadTokens,de+=We.usage.cacheCreateTokens;const ze=dn(We.usage,We.model);xe+=ze.total,Se+=ze.input,Pe+=ze.output,Fe+=ze.cacheRead,Ge+=ze.cacheWrite}return{inT:H,outT:Y,cacheR:oe,cacheC:de,sum:H+Y,cost:{total:xe,input:Se,output:Pe,cacheRead:Fe,cacheWrite:Ge}}},[n.current,n.current.lastSeq]);return g.jsxs("div",{className:"app",children:[g.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),g.jsxs("header",{className:"topbar",children:[g.jsxs("div",{className:"brand",children:[g.jsx("span",{className:"logo"}),g.jsx("h1",{children:Gt}),ye?g.jsxs("button",{type:"button",className:"v stale",onClick:Ze,"aria-label":M5({...ye,open:ft}),title:ye.kind==="restart"?`Running v${ye.from}; v${ye.to} is installed on disk. Restart to pick it up.`:`Running v${ye.from}; v${ye.to} is on npm.`,children:["v",ye.from,g.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const H={running:(K==null?void 0:K.running)??"1.35.33",latest:K==null?void 0:K.latest,latestPending:K==null?void 0:K.latestPending,checkedAgo:K!=null&&K.checkedAt?Iv(ut-K.checkedAt):null,checkDisabled:K==null?void 0:K.checkDisabled,checking:ce};return g.jsxs("button",{type:"button",className:ce?"v checking":"v",onClick:()=>ve(!0),"aria-busy":ce||void 0,"aria-label":I5(H),title:A5(H),children:["v",H.running]})})()]}),Rt&&(()=>{const H=dn(Rt.usage,Rt.model),Y=Math.max(0,((Rt.endedAt??ut)-Rt.startedAt)/1e3),oe=Rt.state==="active"?Eu(H.total,Y):null,de=o.size-1;return g.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${Rt.label}`,onClick:()=>{try{const xe=Qt.find(Se=>Se.id===Rt.id);xe&&e.fitView({padding:.35,duration:500,nodes:[xe]}),St.current=Date.now()}catch{}},children:[g.jsx("span",{className:`state-pill state-${Rt.state}`,children:Rt.state==="active"?"live":Rt.state}),g.jsx("span",{className:"selected-label",children:Rt.label}),H.total>0&&g.jsxs("span",{className:"selected-cost",children:[qe(H.total),oe?g.jsxs("span",{className:"selected-rate",children:[" · ",oe]}):null]}),de>0&&g.jsxs("span",{className:"selected-extra",children:["+",de]}),g.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:xe=>{xe.stopPropagation(),m()},children:"×"})]})})(),g.jsxs("div",{className:"actions",children:[g.jsxs("div",{className:"search",children:[g.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),g.jsx("input",{ref:Zr,type:"text",placeholder:D5,value:Kt,onChange:H=>Kr(H.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),Kt?g.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>Kr(""),children:"×"}):g.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"}),Cn.count&&g.jsx("span",{className:`search-count${Cn.empty?" none":""}`,"aria-live":"polite",title:`${Cn.count} agents on the canvas match “${Kt}”`,children:Cn.count})]}),g.jsxs("span",{className:"status",children:[(()=>{const H=L5({connected:I,paused:Hr,held:vr.current.size});return g.jsx("span",{className:`pill ${H.tone}`,title:H.title,children:H.label})})(),g.jsxs("span",{className:"stat",title:H$(we),children:[g.jsx("span",{className:"count",children:Gs}),g.jsx("span",{className:"lbl",children:"sessions"})]}),g.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[g.jsx("span",{className:"count",children:Tr}),g.jsx("span",{className:"lbl",children:"agents"})]}),g.jsxs("span",{className:"stat",title:W$(we),children:[g.jsx("span",{className:"count",children:n.current.totalEvents}),g.jsx("span",{className:"lbl",children:"events"})]}),nn.sum>0&&g.jsxs("span",{className:"stat",title:`in:${nn.inT.toLocaleString()} out:${nn.outT.toLocaleString()} cache-r:${nn.cacheR.toLocaleString()} cache-c:${nn.cacheC.toLocaleString()}`,children:[g.jsx("span",{className:"count",children:Nt(nn.sum)}),g.jsx("span",{className:"lbl",children:"tokens"})]}),is.length>0&&g.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
|
|
73
73
|
${is.map(H=>` ${H.server}: ${H.count} call${H.count===1?"":"s"}`).join(`
|
|
74
74
|
`)}`,children:[is.slice(0,6).map(H=>g.jsx("span",{className:"mcp-dot",style:{"--mcp-hue":H.hue}},H.server)),is.length>6&&g.jsxs("span",{className:"mcp-more",children:["+",is.length-6]}),g.jsx("span",{className:"lbl",children:"mcp"})]}),nn.cost.total>0&&(()=>{let H=0,Y=0;for(const xe of n.current.agents.values()){if(xe.state!=="active")continue;const Se=dn(xe.usage,xe.model);H+=Se.total,Y=Math.max(Y,((xe.endedAt??ut)-xe.startedAt)/1e3)}const oe=Y>0?Eu(H,Y):null,de=`input ${qe(nn.cost.input)} + output ${qe(nn.cost.output)} + cache r ${qe(nn.cost.cacheRead)} + cache w ${qe(nn.cost.cacheWrite)}${oe?`
|
|
75
75
|
active burn: ${oe}`:""}`;return g.jsxs("span",{className:"stat",title:de,children:[g.jsx("span",{className:"count",children:qe(nn.cost.total)}),g.jsxs("span",{className:"lbl",children:["cost",oe?` · ${oe}`:""]})]})})()]}),g.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:oc}),tn.length>0&&g.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>ji(tn[0].id),title:`Blocked waiting for you — click to go to the one that has been stuck longest:
|