chain-insights 0.69.1 → 0.71.0
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/apps/claude-view.html +4 -4
- package/dist/cli.cjs +3 -3
- package/dist/cli.mjs +3 -3
- package/dist/{dex-tool-DpQKS7Te.mjs → dex-tool-CeggX4M4.mjs} +30 -9
- package/dist/dex-tool-CeggX4M4.mjs.map +1 -0
- package/dist/{dex-tool-DIKN4dXB.cjs → dex-tool-DqAHl4_z.cjs} +29 -8
- package/dist/{graph-schema-DHZi7kUu.cjs → graph-schema-BoUMa03H.cjs} +9 -3
- package/dist/{graph-schema-C7LgLhlY.mjs → graph-schema-DqZUTnP0.mjs} +10 -4
- package/dist/graph-schema-DqZUTnP0.mjs.map +1 -0
- package/dist/mcp-proxy.cjs +4 -3
- package/dist/mcp-proxy.mjs +4 -3
- package/dist/mcp-proxy.mjs.map +1 -1
- package/package.json +1 -1
- package/registry/robinhood.md +2 -0
- package/skills/chain-insights-cypher/SKILL.md +9 -2
- package/skills/chain-insights-dex/SKILL.md +3 -0
- package/dist/dex-tool-DpQKS7Te.mjs.map +0 -1
- package/dist/graph-schema-C7LgLhlY.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- Chain Insights UI
|
|
1
|
+
<!-- Chain Insights UI 7ce05b736087f012bf97333cff1cd678767200f9 (npm run build:claude-view); refresh with scripts/refresh-claude-view.mjs, never edit by hand -->
|
|
2
2
|
<!doctype html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
@@ -105,9 +105,9 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
105
105
|
- omitted: host decides border`)});C({method:$("ui/request-display-mode"),params:C({mode:ki.describe("The display mode being requested.")})});var cT=C({mode:ki.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),lT=xe([$("model"),$("app")]).describe("Tool visibility scope - who can access the tool.");C({resourceUri:E().optional(),visibility:le(lT).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
106
106
|
- "model": Tool visible to and callable by the agent
|
|
107
107
|
- "app": Tool callable by the app from this server only`),csp:Yn().optional(),permissions:Yn().optional()});C({mimeTypes:le(E()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});C({method:$("ui/download-file"),params:C({contents:le(xe([Nw,Rw])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})});C({method:$("ui/message"),params:C({role:$("user").describe('Message role, currently only "user" is supported.'),content:le(Po).describe("Message content blocks (text, image, etc.).")})});C({method:$("ui/notifications/sandbox-resource-ready"),params:C({html:E().describe("HTML content to load into the inner iframe."),sandbox:E().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Qf.optional().describe("CSP configuration from resource metadata."),permissions:eh.optional().describe("Sandbox permissions from resource metadata.")})});var dT=C({method:$("ui/notifications/tool-result"),params:eu.describe("Standard MCP tool execution result.")}),Fw=C({toolInfo:C({id:Ao.optional().describe("JSON-RPC id of the tools/call request."),tool:Xf.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:K$.optional().describe("Current color theme preference."),styles:oT.optional().describe("Style configuration for theming the app."),displayMode:ki.optional().describe("How the UI is currently displayed."),availableDisplayModes:le(ki).optional().describe("Display modes the host supports."),containerDimensions:xe([C({height:we().describe("Fixed container height in pixels.")}),C({maxHeight:xe([we(),vr()]).optional().describe("Maximum container height in pixels.")})]).and(xe([C({width:we().describe("Fixed container width in pixels.")}),C({maxWidth:xe([we(),vr()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
108
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:E().optional().describe("User's language and region preference in BCP 47 format."),timeZone:E().optional().describe("User's timezone in IANA format."),userAgent:E().optional().describe("Host application identifier."),platform:xe([$("web"),$("desktop"),$("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:C({touch:Pe().optional().describe("Whether the device supports touch input."),hover:Pe().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:C({top:we().describe("Top safe area inset in pixels."),right:we().describe("Right safe area inset in pixels."),bottom:we().describe("Bottom safe area inset in pixels."),left:we().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),fT=C({method:$("ui/notifications/host-context-changed"),params:Fw.describe("Partial context update containing only changed fields.")});C({method:$("ui/update-model-context"),params:C({content:le(Po).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:Ce(E(),Le().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});C({method:$("ui/initialize"),params:C({appInfo:Xa.describe("App identification (name and version)."),appCapabilities:uT.describe("Features and capabilities this app provides."),protocolVersion:E().describe("Protocol version this app supports.")})});var hT=C({protocolVersion:E().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Xa.describe("Host application identification and version."),hostCapabilities:aT.describe("Features and capabilities provided by the host."),hostContext:Fw.describe("Rich context about the host environment.")}).passthrough(),pT={target:"draft-2020-12"};async function vp(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](pT);if(n.vendor==="zod"){let{z:r}=await Nk(()=>Promise.resolve().then(()=>rE),void 0,import.meta.url);return r.toJSONSchema(e,{io:t})}throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function bp(e,t,n=""){let r=await e["~standard"].validate(t);if(r.issues){let i=r.issues.map(o=>{let s=o.path?.map(a=>typeof a=="object"?a.key:a).join(".");return s?`${s}: ${o.message}`:o.message}).join("; ");throw Error(n+i)}return r.value}function mT(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function gT(e){if(document.getElementById("__mcp-host-fonts"))return;let t=document.createElement("style");t.id="__mcp-host-fonts",t.textContent=e,document.head.appendChild(t)}class th extends V${_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_assertInitialized(t){if(this._initializedSent)return;let n=`[ext-apps] App.${t}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(n);console.warn(`${n}. This will throw in a future release.`)}eventSchemas={toolinput:tT,toolinputpartial:nT,toolresult:dT,toolcancelled:rT,hostcontextchanged:fT};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(t){if(!th.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(t,n){n&&this._assertHandlerTiming(t),super.setEventHandler(t,n)}addEventListener(t,n){this._assertHandlerTiming(t),super.addEventListener(t,n)}onEventDispatch(t,n){t==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...n})}constructor(t,n={},r={autoResize:!0}){super(r),this._appInfo=t,this._capabilities=n,this.options=r,r.allowUnsafeEval||et({jitless:!0}),this.setRequestHandler(Qa,i=>(console.log("Received ping:",i.params),{})),this.setEventHandler("hostcontextchanged",void 0)}registerCapabilities(t){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._capabilities=H$(this._capabilities,t)}registerTool(t,n,r){if(this._registeredTools[t])throw Error(`Tool ${t} is already registered`);let i=this,o=()=>{i._initializedSent&&i._capabilities.tools?.listChanged&&i.sendToolListChanged()},s=n.inputSchema!==void 0,a={title:n.title,description:n.description,inputSchema:n.inputSchema,outputSchema:n.outputSchema,annotations:n.annotations,_meta:n._meta,enabled:!0,enable(){this.enabled=!0,o()},disable(){this.enabled=!1,o()},update(u){Object.assign(this,u),o()},remove(){i._registeredTools[t]===a&&(delete i._registeredTools[t],o())},handler:async(u,c)=>{if(!a.enabled)throw Error(`Tool ${t} is disabled`);let l;if(s){let d=a.inputSchema,f=d?await bp(d,u??{},`Invalid input for tool ${t}: `):u??{};l=await r(f,c)}else l=await r(c);return a.outputSchema&&!l.isError&&(l.structuredContent=await bp(a.outputSchema,l.structuredContent,`Invalid output for tool ${t}: `)),l}};return this._registeredTools[t]=a,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),o(),a}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(t,n)=>{let r=this._registeredTools[t.name];if(!r)throw Error(`Tool ${t.name} not found`);return r.handler(t.arguments,n)},this.onlisttools=async(t,n)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([r,i])=>i.enabled).map(async([r,i])=>{let o={name:r,title:i.title,description:i.description,inputSchema:i.inputSchema?await vp(i.inputSchema,"input"):{type:"object",properties:{}}};return i.outputSchema&&(o.outputSchema=await vp(i.outputSchema,"output")),i.annotations&&(o.annotations=i.annotations),i._meta&&(o._meta=i._meta),o}))}))}async sendToolListChanged(t={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:t})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(t){this.setEventHandler("toolinput",t)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(t){this.setEventHandler("toolinputpartial",t)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(t){this.setEventHandler("toolresult",t)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(t){this.setEventHandler("toolcancelled",t)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(t){this.setEventHandler("hostcontextchanged",t)}_onteardown;get onteardown(){return this._onteardown}set onteardown(t){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,t),this._onteardown=t,this.replaceRequestHandler(sT,(n,r)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(n.params,r)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler(zw,(n,r)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,r)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(t){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,t),this._onlisttools=t,this.replaceRequestHandler(Lw,(n,r)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(n.params,r)})}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${t})`);break}}assertRequestHandlerCapability(t){switch(t){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${t})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${t} registered`)}}assertNotificationCapability(t){}assertTaskCapability(t){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(t){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(t,n){if(this._assertInitialized("callServerTool"),typeof t=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${t}"). Did you mean: callServerTool({ name: "${t}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:t},eu,{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(t,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},Iw,n)}async listServerResources(t,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},Aw,n)}async createSamplingMessage(t,n){this._assertInitialized("createSamplingMessage");let r=t.tools?Ow:Dw;return await this.request({method:"sampling/createMessage",params:t},r,n)}sendMessage(t,n){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:t},eT,n)}sendLog(t){return this.notification({method:"notifications/message",params:t})}updateModelContext(t,n){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:t},Of,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},X$,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},Q$,n)}requestTeardown(t={}){return this.notification({method:"ui/notifications/request-teardown",params:t})}requestDisplayMode(t,n){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:t},cT,n)}sendSizeChanged(t){return this.notification({method:"ui/notifications/size-changed",params:t})}setupSizeChangedNotifications(){let t=!1,n=0,r=0,i=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let s=document.documentElement,a=s.style.height;s.style.height="max-content";let u=Math.ceil(s.getBoundingClientRect().height);s.style.height=a;let c=Math.ceil(window.innerWidth);(c!==n||u!==r)&&(n=c,r=u,this.sendSizeChanged({width:c,height:u}))}))};i();let o=new ResizeObserver(i);return o.observe(document.documentElement),o.observe(document.body),()=>o.disconnect()}async connect(t=new Mw(window.parent,window.parent),n){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1,await super.connect(t);try{let r=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:q$}},hT,n);if(r===void 0)throw Error(`Server sent invalid initialize result: ${r}`);this._hostCapabilities=r.hostCapabilities,this._hostInfo=r.hostInfo,this._hostContext=r.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(r){throw this.close(),r}}}const yT="Chain Insights graph",vT="This graph is no longer available. Ask for it again.",wp="data-chain-insights-view",bT="This window cannot reach the local Chain Insights page. Open the link in your own browser for clicks that load more",us=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Uw=e=>!us(e)||!us(e.result)?null:{arguments:us(e.arguments)?e.arguments:null,result:e.result};function wT(e,t){const n=t.querySelector(`script[type="application/json"][${wp}]`);if(!n||n.getAttribute(wp)!==e)return null;try{return Uw(JSON.parse(n.textContent??""))}catch{return null}}const _T=new Set(["127.0.0.1","localhost","[::1]","::1"]);function kT(e){const t=new URLSearchParams(e.search).get("view");if(t&&t.trim())return t.trim();if(!_T.has(e.hostname))return null;const n=/^\/view\/([^/]+)\/?$/.exec(e.pathname);if(!n?.[1])return null;try{return decodeURIComponent(n[1])||null}catch{return null}}async function ST(e,t,n){const r=n?wT(e,n):null;if(r)return r;try{const i=await t(`/api/view/${encodeURIComponent(e)}`,{headers:{Accept:"application/json"}});return i.ok?Uw(await i.json()):null}catch{return null}}function xT(e,t){return{async callServerTool({name:n,arguments:r}){let i;try{i=await e(`/api/tools/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({arguments:r})})}catch{throw new Error(bT)}let o=null;try{o=await i.json()}catch{o=null}if(us(o)&&(Array.isArray(o.content)||"structuredContent"in o||"isError"in o))return o;throw new Error(i.ok?"the local Chain Insights page answered with no tool result":`the local Chain Insights page answered HTTP ${i.status}`)},async openLink({url:n}){return t(n,"_blank","noopener"),{}}}}const Gw=new Map;function ET(e,t){Gw.set(e,t)}function _p(e){return Gw.get(e)??null}const $T=/swiftshader|llvmpipe|softpipe|software|microsoft basic render/i;function TT(e){try{const t=e.createElement("canvas");if(typeof t.getContext!="function")return!1;const n={failIfMajorPerformanceCaveat:!0},r=t.getContext("webgl2",n)??t.getContext("webgl",n);if(!r)return!1;const i=r.getExtension?.("WEBGL_debug_renderer_info"),o=String(i?r.getParameter(i.UNMASKED_RENDERER_WEBGL):r.getParameter(r.RENDERER)??"");return $T.test(o)?(r.getExtension?.("WEBGL_lose_context")?.loseContext(),!1):(r.getExtension?.("WEBGL_lose_context")?.loseContext(),!0)}catch{return!1}}const CT="http://www.w3.org/2000/svg";let AT=0;function Vo(e){return Math.round(e*10)/10}function IT(e,t,n={}){const r=e.createElementNS(CT,t);for(const[i,o]of Object.entries(n))r.setAttribute(i,String(o));return r}function kp(e,t,n,r){const i=`cia-graph-svg-${++AT}`,o=e.ownerDocument,s=(U,H)=>IT(o,U,H),a=(U,H,K)=>{const de=s("text",{x:0,y:H,"text-anchor":"middle",class:K,"pointer-events":"none"});return de.textContent=U,de},{width:u,height:c}=t.dimensions(),l=s("svg",{class:"cia-graph-svg",viewBox:`0 0 ${u} ${c}`,role:"group",tabindex:0,"aria-label":r.label??"Money-flow graph. Drag the background or use arrow keys to pan, plus and minus to zoom. Select an address or a link for details."}),d=s("defs"),f=s("pattern",{id:`${i}-dots`,width:24,height:24,patternUnits:"userSpaceOnUse"});f.append(s("circle",{class:"cia-graph-dot",cx:1,cy:1,r:1})),d.append(f);const h=s("rect",{class:"cia-graph-backdrop",width:"100%",height:"100%","data-canvas":""}),p=s("rect",{class:"cia-graph-dots",width:"100%",height:"100%",fill:`url(#${i}-dots)`,"data-canvas":""}),m=s("g",{"data-viewport":""}),y=s("g",{"data-edges":"",class:"cia-graph-edges"}),b=s("g",{"data-nodes":"",class:"cia-graph-nodes"});m.append(y,b),l.append(d,h,p,m),e.append(l);const g=new Map,w=new Map,v=new Map;let _=null;function k(){if(_)return _;const U=t.model(),H=t.positions(),K=new Map;_=K;const de=U.nodes.length>_C,te=new Map(U.nodes.map(z=>[z.address,z])),I=de?[]:fC(U,H,t.notes());for(const z of U.edges){const G=te.get(z.from),fe=te.get(z.to),ie=G&&H[G.id],Y=fe&&H[fe.id];if(!G||!fe||!ie||!Y){K.set(z.id,null);continue}if(de){K.set(z.id,uc(ie,Y,Hn(G,U.checked_address),Hn(fe,U.checked_address)));continue}const oe=I.filter(he=>he.id!==G.id&&he.id!==fe.id);K.set(z.id,kC(ie,Y,Hn(G,U.checked_address),Hn(fe,U.checked_address),oe))}return K}function x(U){let H=g.get(U);if(H)return H;H=`${i}-arrow-${g.size}`;const K=s("marker",{id:H,viewBox:"0 0 10 10",refX:9,refY:5,markerWidth:6,markerHeight:6,orient:"auto-start-reverse",markerUnits:"strokeWidth"}),de=s("path",{d:"M0 0L10 5L0 10Z",class:"cia-graph-arrowhead"});return de.style.fill=U,K.append(de),d.append(K),g.set(U,H),H}function N(){return[...t.model().nodes??[]].sort((U,H)=>String(U.id).localeCompare(String(H.id)))}function M(){_=null;const U=t.model();y.replaceChildren(),b.replaceChildren(),w.clear(),v.clear();const H=new Map(U.nodes.map(K=>[K.address,K]));for(const K of U.edges){const de=H.get(K.from);if(!de||!H.get(K.to))continue;const te=t.colorOf(de),I=s("g",{class:"cia-graph-edge graph-edge",tabindex:0,role:"button","aria-label":hc(K,t.now())});I.dataset.edgeId=K.id,I.style.setProperty("--edge-tone",te);const z=xC(),G=s("path",{class:"cia-graph-edge-hit","stroke-width":z.hit.width,"pointer-events":"stroke"}),fe=s("path",{class:"cia-graph-edge-line","stroke-width":z.line.width,"marker-end":`url(#${x(te)})`,"pointer-events":"none"});I.append(G,fe);const ie=U.edges.length<=Xw?Qw(K):"";let Y;if(ie){fe.id=`${i}-edge-${v.size}`;const oe=s("textPath",{href:`#${fe.id}`,startOffset:"50%","text-anchor":"middle"});oe.textContent=ie;const he=s("text",{class:"cia-graph-edge-caption",dy:"-4","pointer-events":"none","aria-hidden":"true"});he.append(oe),I.append(he),Y=he}I.addEventListener("keydown",oe=>{Ip(oe.key)&&(oe.preventDefault(),n.selectEdge(K.id,"keyboard"))}),I.addEventListener("pointerenter",oe=>n.showTooltip(oe,hc(K,t.now()))),I.addEventListener("pointerleave",()=>n.hideTooltip()),y.append(I),v.set(K.id,{group:I,hit:G,line:fe,...Y?{caption:Y}:{}})}for(const K of N())b.append(F(K));ee(),me()}function F(U){const H=t.model(),K=U.address===H.checked_address,de=t.notes().get(U.id),te=Rn(U,H.checked_address,de),I=te.radius,z=s("g",{class:"cia-graph-node graph-node",tabindex:0,role:"button","aria-label":fc(U),"aria-pressed":"false"});z.dataset.nodeId=U.id,K&&(z.dataset.checked=""),z.style.setProperty("--node-tone",t.colorOf(U)),K&&z.append(s("circle",{class:"cia-graph-node-ring",r:I+6})),z.append(s("circle",{class:"cia-graph-node-body",r:I})),z.append(s("circle",{class:"cia-graph-node-dot",r:te.dot}));for(const G of te.texts)z.append(a(G.text,G.y,`cia-graph-node-${G.kind}`));de&&(z.dataset.state="refused");for(const G of t.flags().get(U.id)??[])z.setAttribute(`data-flag-${G}`,"");return z.addEventListener("keydown",G=>{Ip(G.key)&&(G.preventDefault(),n.selectNode(U.id,"keyboard"))}),z.addEventListener("pointerenter",G=>n.showTooltip(G,fc(U))),z.addEventListener("pointerleave",()=>n.hideTooltip()),w.set(U.id,z),z}function B(){const U=t.transform();m.setAttribute("transform",`translate(${U.x} ${U.y}) scale(${U.scale})`)}function ee(){B();const U=t.positions(),{width:H,height:K}=t.dimensions();for(const[te,I]of w){const z=U[te]??{x:H/2,y:K/2};I.setAttribute("transform",`translate(${Vo(z.x)} ${Vo(z.y)})`)}const de=k();for(const te of t.model().edges){const I=v.get(te.id);if(!I)continue;const z=de.get(te.id)??null;I.group.style.display=z?"":"none",z&&(I.hit.setAttribute("d",z.d),I.line.setAttribute("d",z.d),I.caption&&(I.caption.style.display=z.kind==="forward"||z.kind==="vertical"||z.kind==="straight"?"":"none"))}}function ce(U){const H=t.model(),K=t.positions(),de=K[U],te=w.get(U);if(!de||!te)return;te.setAttribute("transform",`translate(${Vo(de.x)} ${Vo(de.y)})`);const I=H.nodes.find(G=>G.id===U);if(!I)return;const z=new Map(H.nodes.map(G=>[G.address,G]));for(const G of H.edges){if(G.from!==I.address&&G.to!==I.address)continue;const fe=v.get(G.id),ie=z.get(G.from),Y=z.get(G.to),oe=ie&&K[ie.id],he=Y&&K[Y.id];if(!fe||!ie||!Y||!oe||!he)continue;const Ae=uc(oe,he,Hn(ie,H.checked_address),Hn(Y,H.checked_address));fe.group.style.display=Ae?"":"none",Ae&&(fe.hit.setAttribute("d",Ae.d),fe.line.setAttribute("d",Ae.d))}}function me(){const U=t.model(),H=t.selected(),K=t.highlighted(),de=H?.kind==="node"?U.nodes.find(te=>te.id===H.id)?.address??null:null;for(const te of U.edges){const I=v.get(te.id);if(!I)continue;const z=H?.kind==="edge"&&H.id===te.id,G=H?.kind==="edge"?z?Jt.related:Jt.faded:Ww(te,de),fe=G===Jt.faded;I.group.setAttribute("opacity",fe?String(G):"1"),I.line.setAttribute("stroke-opacity",fe?"1":String(G)),I.group.dataset.opacity=String(G),I.group.dataset.state=G===Jt.rest?"rest":G===Jt.related?"related":"faded",I.group.setAttribute("aria-pressed",String(z))}for(const[te,I]of w){const z=H?.kind==="node"&&H.id===te;I.classList.toggle("is-selected",z),I.classList.toggle("is-focused",K===te),I.setAttribute("aria-pressed",String(z))}}function $e(){let U=null;for(const H of k().values())H?.bounds&&(U=U??{...H.bounds},U.x1=Math.min(U.x1,H.bounds.x1),U.y1=Math.min(U.y1,H.bounds.y1),U.x2=Math.max(U.x2,H.bounds.x2),U.y2=Math.max(U.y2,H.bounds.y2));return U}return{kind:"svg",surface:l,build:M,geometry(){_=null,ee()},moveNode:ce,endMove(){_=null,ee()},camera:B,selection:me,flag(U,H,K){w.get(U)?.toggleAttribute(`data-flag-${H}`,K)},theme(){for(const U of t.model().nodes)w.get(U.id)?.style.setProperty("--node-tone",t.colorOf(U))},resize(U,H){l.setAttribute("viewBox",`0 0 ${U} ${H}`)},pick:()=>null,linkBounds:$e,destroy(){l.remove()}}}const NT=.1,RT=2.5,LT=5,zT="chain-insights.flows.v1",nh="cia-graph-model",PT=300,Jt={rest:.6,related:.95,faded:.25},Sp={checked:24,other:19},Si=16,DT=[["Sanctioned","Sanctioned"],["Scam","Scam"],["Poisoned","Poisoned"],["OnMoneyTrail","On money trail"],["Mixer","Mixer"],["Bridge","Bridge"],["Exchange","Exchange"],["Victim","Victim"],["Targeted","Targeted"]],qr=["exchange","scam","sanctioned","victim","pool","other"],OT={exchange:"infrastructure",scam:"danger",sanctioned:"danger",victim:"target",pool:"trail",other:"neutral"},jw={exchange:"Exchange",scam:"Scam",sanctioned:"Sanctioned",victim:"Victim",pool:"Pool",other:""};function rh(e){return!!e&&e.schema===zT}function MT(e){return!!e&&e.kind===nh}function Je(e){return String(e??"").trim().toLowerCase()}function FT(e){const t=Je(e);return qr.includes(t)?t:"other"}function vn(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function sc(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function UT(e){const t=String(e??"").toUpperCase();return t==="IN"||t==="OUT"||t==="MIXED"||t==="CHECKED"?t:"OUT"}function Mt(e){return MT(e)?e:rh(e)?GT(e):ZT(e)}function GT(e){const t=Je(e.center),n=new Map;for(const a of e.nodes??[]){const u=Je(a?.address);u&&!n.has(u)&&n.set(u,a)}const r=[],i=new Set;for(const a of e.edges??[]){const u=Je(a?.from),c=Je(a?.to);if(!n.has(u)||!n.has(c)||u===c)continue;const l=`${u}->${c}`;i.has(l)||(i.add(l),r.push({id:l,from:u,to:c,source:"flows",amount_usd_sum:vn(a.usd),tx_count:vn(a.tx_count),first_seen_timestamp:vn(a.first_seen_ms),last_seen_timestamp:vn(a.last_seen_ms),...typeof a.link_kind=="string"&&a.link_kind?{link_kind:a.link_kind}:{}}))}const o=jT(t,[...n.keys()],r),s=[...n.entries()].map(([a,u])=>{const c=o.get(a)??{direction:"OUT",hop:2};return{id:a,address:a,direction:a===t?"CHECKED":c.direction,hop:a===t?0:c.hop,labels:sc(u.labels),taxonomy:[],role:FT(u.role),total_in_usd:vn(u.total_in_usd),total_out_usd:vn(u.total_out_usd),degree_in:vn(u.degree_in),degree_out:vn(u.degree_out)}});return{kind:nh,checked_address:t,network:e.network??null,nodes:s,edges:r,truncated:!!e.truncated,cursor:e.cursor??null}}function jT(e,t,n){const r=new Map,i=new Map,o=new Map,s=(d,f,h)=>d.set(f,[...d.get(f)??[],h]);for(const d of n)s(r,d.from,d.to),s(i,d.to,d.from),s(o,d.from,d.to),s(o,d.to,d.from);const a=d=>{const f=new Map([[e,0]]);for(let h=[e];h.length;){const p=[];for(const m of h)for(const y of d.get(m)??[])f.has(y)||(f.set(y,(f.get(m)??0)+1),p.push(y));h=p}return f},u=a(r),c=a(i),l=new Map;for(const d of t){if(d===e)continue;const f=u.get(d),h=c.get(d);if(f==null&&h==null)continue;const p=f!=null&&h!=null?f<h?"OUT":h<f?"IN":"MIXED":f!=null?"OUT":"IN";l.set(d,{direction:p,hop:Math.min(2,Math.min(f??1/0,h??1/0))})}for(let d=!0;d;){d=!1;for(const f of t){if(f===e||l.has(f))continue;const h=(o.get(f)??[]).find(m=>m!==e&&l.has(m));if(h==null)continue;const p=l.get(h);l.set(f,{direction:p.direction==="MIXED"?"OUT":p.direction,hop:2}),d=!0}}return l}function ZT(e){const t=(e?.nodes??[]).map(r=>({...r,id:String(r.id??r.address),address:r.address,hop:Number(r.hop)||0,direction:r.address===e.checked_address?"CHECKED":UT(r.direction),labels:sc(r.labels),taxonomy:sc(r.taxonomy),role:null})),n=(e?.edges??[]).map(r=>({...r,id:String(r.id??`${r.from}->${r.to}`),amount_usd_sum:r.amount_usd_sum??null,tx_count:r.tx_count??null,first_seen_timestamp:r.first_seen_timestamp??null,last_seen_timestamp:r.last_seen_timestamp??null,source:"risk"}));return{kind:nh,checked_address:e?.checked_address??"",network:null,nodes:t,edges:n,truncated:!1,cursor:null}}function BT(e,t,n){const r=Mt(t),i=kn(e,n??r.checked_address),o=e.nodes.find(d=>d.id===i),s=new Map(e.nodes.map(d=>[Je(d.address),d])),a=[];for(const d of r.nodes){if(s.has(Je(d.address)))continue;const f=!o||o.direction==="CHECKED"?d.direction==="CHECKED"?"OUT":d.direction:o.direction,h={...d,id:d.id,direction:f,hop:Math.min(2,(o?.hop??0)+1)};a.push(h),s.set(Je(d.address),h)}const u=new Set(e.edges.map(d=>d.id)),c=new Set(e.edges.map(d=>`${Je(d.from)}->${Je(d.to)}`)),l=[...e.edges];for(const d of r.edges){const f=`${Je(d.from)}->${Je(d.to)}`;if(u.has(d.id)||c.has(f)||!s.has(Je(d.from))||!s.has(Je(d.to)))continue;const h=s.get(Je(d.from)).address,p=s.get(Je(d.to)).address;l.push({...d,from:h,to:p}),u.add(d.id),c.add(f)}return{model:{...e,nodes:[...e.nodes,...a],edges:l,truncated:e.truncated||r.truncated},added:a.map(d=>d.id)}}function kn(e,t){if(t==null)return null;const n=Je(t);return e.nodes.find(i=>i.id===t||Je(i.address)===n)?.id??null}function xi(e){return typeof e!="string"||e.length<=12?e:`${e.slice(0,6)}…${e.slice(-4)}`}function ih(e){return String(e??"").trim().replace(/\s+/g," ")}function ks(e){return ih(e).replaceAll(" ","").toLowerCase()}function In(e){const t=[...e.taxonomy??[],...e.labels??[]],n=new Set,r=[];for(const i of t){const o=ih(i),s=o.toLowerCase();!o||s==="address"||n.has(s)||(n.add(s),r.push(o))}return r}function qo(e,t){const n=new Set(In(e).map(ks));return t.some(r=>n.has(ks(r)))}function HT(e){if(e.role&&qr.includes(e.role))return OT[e.role];if(qo(e,["Sanctioned","Scam","Poisoned"]))return"danger";if(qo(e,["Victim","Targeted"]))return"target";if(qo(e,["OnMoneyTrail","Mixer"]))return"trail";if(qo(e,["Exchange","Bridge","token contract"]))return"infrastructure";if(e.risk_score!=null){const t=String(e.risk_level).toLowerCase();if(t==="critical"||t==="high"||t==="medium"||t==="low")return t}return"neutral"}function Ke(e){return`var(--cia-graph-${e})`}const VT={semantic:{danger:{stroke:Ke("danger"),fill:Ke("node")},target:{stroke:Ke("target"),fill:Ke("node")},trail:{stroke:Ke("trail"),fill:Ke("node")},infrastructure:{stroke:Ke("infrastructure"),fill:Ke("node")},neutral:{stroke:Ke("neutral"),fill:Ke("node")}},risk:{CRITICAL:{stroke:Ke("critical"),fill:Ke("node")},HIGH:{stroke:Ke("high"),fill:Ke("node")},MEDIUM:{stroke:Ke("medium"),fill:Ke("node")},LOW:{stroke:Ke("low"),fill:Ke("node")}}};function qT(e,t=VT){const n=HT(e);return n==="critical"||n==="high"||n==="medium"||n==="low"?t.risk[n.toUpperCase()]??t.semantic.neutral:t.semantic[n]}function WT(e){return e.role&&qr.includes(e.role)?Ke(`role-${e.role}`):qT(e).stroke}function Do(e){if(e.role&&e.role!=="other"&&qr.includes(e.role))return jw[e.role];const t=In(e);for(const[r,i]of DT)if(t.some(o=>ks(o)===ks(r)))return i;return(Array.isArray(e.labels)?e.labels.map(ih).filter(Boolean).sort((r,i)=>r.localeCompare(i)):[])[0]??""}function ac(e){return Math.min(RT,Math.max(NT,e))}function oh(e){return[...e.nodes??[]].sort((t,n)=>String(t.id).localeCompare(String(n.id)))}function Zw(e,t=oh(e)){return t.find(n=>n.address===e.checked_address)??t[0]}function xp(e,t){return e.address===t?43:e.hop>=2?25:30}function Hn(e,t){return e.address===t?Sp.checked:Sp.other}function Rn(e,t,n){const r=e.address===t,i=Hn(e,t),o=Do(e),s=[];return o&&s.push({kind:"role",text:UC(o),y:i+17}),s.push({kind:"address",text:xi(e.address),y:i+(o?33:17)}),n&&s.push({kind:"note",text:n,y:i+(o?48:32)}),{radius:i,ring:r,dot:r?8:5,texts:s}}const KT={role:{size:13,advance:.68},address:{size:11,advance:.62},note:{size:11,advance:.6}},vu=2;function sh(e){const t=e.radius+(e.ring?7:2),n=[{kind:"circle",box:{x1:-t,y1:-t,x2:t,y2:t}}];for(const r of e.texts){const i=KT[r.kind],o=[...r.text].length*i.size*i.advance/2+vu;n.push({kind:r.kind,box:{x1:-o,y1:r.y-i.size*.8-vu,x2:o,y2:r.y+i.size*.25+vu}})}return n}function Bw(e){return e.length?{x1:Math.min(...e.map(t=>t.x1)),y1:Math.min(...e.map(t=>t.y1)),x2:Math.max(...e.map(t=>t.x2)),y2:Math.max(...e.map(t=>t.y2))}:null}function Ss(e){return Bw(sh(e).map(t=>t.box))}const Ei=(e,t)=>(e instanceof Map?e.get(t):e?.[t])??null;function JT(e,t,n){const r=Mt(e),i=[];for(const o of r.nodes){const s=t[o.id];if(s)for(const{kind:a,box:u}of sh(Rn(o,r.checked_address,Ei(n,o.id))))i.push({id:o.id,kind:a,x1:s.x+u.x1,y1:s.y+u.y1,x2:s.x+u.x2,y2:s.y+u.y2})}return i}function YT(e,t,n){return Bw(JT(e,t,n))}function XT(e,t){return e.x1<t.x2&&t.x1<e.x2&&e.y1<t.y2&&t.y1<e.y2}function QT(e){let t=0;for(const n of String(e))t=(t<<5)-t+n.charCodeAt(0)|0;return Math.abs(t)}function eC(e,t,n){const r=Mt(e),i={x:t/2,y:n/2},o={},s=oh(r),a=Zw(r,s);if(!a)return o;o[a.id]=i;const u=new Map;for(const l of s){if(l.id===a.id)continue;let d=l.direction==="IN"?-1:1;l.direction==="MIXED"&&(d=QT(l.id)%2?-1:1);const f=Math.min(2,Math.max(1,Number(l.hop)||1)),h=`${d}:${f}`;u.has(h)||u.set(h,[]),u.get(h).push(l)}const c=tC(r);for(const[l,d]of u){const[f,h]=l.split(":"),p=Number(f),m=Number(h),y=i.x+p*(m===1?t*.23:t*.43);d.sort((b,g)=>(c.get(g.address)??0)-(c.get(b.address)??0)||String(b.id).localeCompare(String(g.id))),Object.assign(o,nC(d,y,i.y,r.checked_address))}return o}function tC(e){const t=new Map;for(const n of e.edges){const r=Math.max(n.last_seen_timestamp??0,n.first_seen_timestamp??0);for(const i of[n.from,n.to])r>(t.get(i)??0)&&t.set(i,r)}return t}function nC(e,t,n,r,i=24){const o=e.map((u,c)=>({node:u,x:t,y:n+(c-(e.length-1)/2)*64})),s=u=>Ss(Rn(u,r)),a=(u,c)=>Math.max(xp(u,r)+xp(c,r)+20,s(u).y2-s(c).y1+2);for(let u=0;u<i;u++){for(let d=1;d<o.length;d++){const f=o[d-1],h=o[d];!f||!h||(h.y=Math.max(h.y,f.y+a(f.node,h.node)))}for(let d=o.length-2;d>=0;d--){const f=o[d],h=o[d+1];!f||!h||(f.y=Math.min(f.y,h.y-a(f.node,h.node)))}const c=o[0],l=o[o.length-1];if(c&&l){const d=(c.y+l.y)/2,f=n-d;for(const h of o)h.y+=f}}return Object.fromEntries(o.map(u=>[u.node.id,{x:u.x,y:u.y}]))}function rC(e,t,n){const r=Mt(e),i={x:t/2,y:n/2},o={},s=oh(r),a=Zw(r,s);if(!a)return o;o[a.id]=i;const u=s.filter(c=>c.id!==a.id);return u.forEach((c,l)=>{const d=-Math.PI/2+l*Math.PI*2/Math.max(1,u.length)+(kr(c.id)-.5)*.3,f=(c.hop>=2?Math.min(t,n)*.39:Math.min(t,n)*.27)*(.85+kr(c.id+"/r")*.3);o[c.id]={x:i.x+Math.cos(d)*f,y:i.y+Math.sin(d)*f}}),o}function kr(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0)%10007/10007}const Sn={link:150,repel:50,reach:300,spring:.06,centre:.02};function iC(e,t,n,r,i){const o=e.nodes.filter(l=>t[l.id]),s=new Map(o.map(l=>[l.id,{x:0,y:0}])),a=o.filter(l=>n.has(l.id)),u=new Map(a.map((l,d)=>[l.id,d]));for(let l=0;l<a.length;l++){const d=a[l],f=t[d.id],h=s.get(d.id);for(const p of o){if(p===d)continue;const m=u.get(p.id);if(m!==void 0&&m<l)continue;const y=t[p.id];let b=y.x-f.x,g=y.y-f.y;!b&&!g&&(b=kr(d.id+p.id)-.5,g=kr(p.id+d.id)-.5);const w=Math.max(8,Math.hypot(b,g));if(w>=Sn.reach)continue;const v=Sn.repel*Sn.repel/w*(1-w/Sn.reach),_=b/w*v,k=g/w*v;if(h.x-=_,h.y-=k,m!==void 0){const x=s.get(p.id);x.x+=_,x.y+=k}}}const c=new Map(o.map(l=>[l.address,l]));for(const l of e.edges){const d=c.get(l.from),f=c.get(l.to);if(!d||!f||d===f)continue;const h=t[d.id],p=t[f.id],m=p.x-h.x,y=p.y-h.y,b=Math.max(1,Math.hypot(m,y)),g=(b-Sn.link)*Sn.spring,w=m/b*g,v=y/b*g,_=s.get(d.id);_.x+=w,_.y+=v;const k=s.get(f.id);k.x-=w,k.y-=v}for(const l of o){if(!n.has(l.id))continue;const d=t[l.id],f=s.get(l.id),h=Sn.centre/Math.max(1,l.hop);f.x+=(r.x-d.x)*h,f.y+=(r.y-d.y)*h;const p=Math.hypot(f.x,f.y),m=30*i,y=p>m?m/p:1;d.x+=f.x*y*Math.min(1,i*4),d.y+=f.y*y*Math.min(1,i*4)}}function Hw(e,t,n,r,i){const o=e.nodes.filter(c=>t[c.id]).length,s=Math.max(1,n.size*o);i=Math.min(i,Math.max(60,Math.floor(4e7/s)));const a=i>1?Math.pow(.01,1/(i-1)):1;let u=1;for(let c=0;c<i;c++)iC(e,t,n,r,u),u*=a;return t}function oC(e,t,n,r=PT){const i=Mt(e),o=rC(i,t,n),s=i.nodes.find(u=>u.address===i.checked_address),a=new Set(i.nodes.filter(u=>u!==s).map(u=>u.id));return Hw(i,o,a,{x:t/2,y:n/2},r),s&&(o[s.id]={x:t/2,y:n/2}),Vw(i,o,a)}function Wo(e,t,n,r){return t==="tree"?eC(e,n,r):oC(e,n,r)}function Vw(e,t,n,r,i=22,o=60){const s=Mt(e),a=s.nodes.filter(d=>t[d.id]),u=new Map(a.map(d=>[d.id,Ss(Rn(d,s.checked_address,Ei(r,d.id)))])),c=a.filter(d=>n.has(d.id)),l=new Map(c.map((d,f)=>[d.id,f]));for(let d=0;d<o;d++){let f=!1;for(let h=0;h<c.length;h++)for(const p of a){const m=c[h];if(p===m)continue;const y=l.get(p.id);if(y!==void 0&&y<h)continue;const b=t[m.id],g=t[p.id],w=u.get(m.id),v=u.get(p.id),_=Math.min(b.x+w.x2,g.x+v.x2)-Math.max(b.x+w.x1,g.x+v.x1)+i,k=Math.min(b.y+w.y2,g.y+v.y2)-Math.max(b.y+w.y1,g.y+v.y1)+i;if(_<=0||k<=0)continue;f=!0;const x=_<k,N=x?g.x>=b.x?1:-1:g.y>=b.y?1:-1,M=(x?_:k)/2+.5,B=n.has(m.id)&&n.has(p.id)?M:M*2;n.has(m.id)&&(x?b.x-=N*B:b.y-=N*B),n.has(p.id)&&(x?g.x+=N*B:g.y+=N*B)}if(!f)break}return t}const sC=300;function aC(e,t,n,r,i={}){const o=i.steps??sC,s=Mt(e),a=t[n],u={...t};if(!a)return u;const c=new Map(s.nodes.map(_=>[_.id,_])),l=[...r].sort().filter(_=>!u[_]&&c.has(_));if(!l.length)return u;const d=c.get(n)?.address,f=new Set(s.edges.filter(_=>_.to===d).map(_=>_.from)),h=new Set(s.edges.filter(_=>_.from===d).map(_=>_.to)),p=_=>{const k=c.get(_).address;return f.has(k)&&!h.has(k)},m=l.filter(p),y=l.filter(_=>!p(_)),b=(_,k)=>{_.forEach((N,M)=>{const F=Math.floor(M/10),B=Math.min(10,_.length-F*10),ee=M-F*10,ce=Math.PI*.8,me=(B===1?0:-ce/2+ee*ce/(B-1))+(kr(N)-.5)*.2,$e=(Sn.link+F*110)*(.9+kr(N+"/r")*.2);u[N]={x:a.x+k*Math.cos(me)*$e,y:a.y+Math.sin(me)*$e}})};b(m,-1),b(y,1);const g=s.nodes.filter(_=>t[_.id]&&!l.includes(_.id)).map(_=>({point:t[_.id],box:Ss(Rn(_,s.checked_address,Ei(i.notes,_.id)))})),w=(_,k)=>{if(!_.length)return;const x=_.map(N=>({id:N,box:Ss(Rn(c.get(N),s.checked_address,Ei(i.notes,N)))}));for(let N=0;N<12;N++){const M={x1:1/0,y1:1/0,x2:-1/0,y2:-1/0};for(const{id:B,box:ee}of x){const ce=u[B];M.x1=Math.min(M.x1,ce.x+ee.x1),M.x2=Math.max(M.x2,ce.x+ee.x2),M.y1=Math.min(M.y1,ce.y+ee.y1),M.y2=Math.max(M.y2,ce.y+ee.y2)}let F=0;for(const B of g){if(Math.min(M.y2,B.point.y+B.box.y2)-Math.max(M.y1,B.point.y+B.box.y1)+12<=0)continue;const ce=k<0?M.x2+24-(B.point.x+B.box.x1):B.point.x+B.box.x2+24-M.x1;ce>F&&(F=ce)}if(F<=0)break;for(const B of _)u[B].x+=k*F}},v=new Set(l);return Hw(s,u,v,{x:a.x,y:a.y},o),Vw(s,u,v,i.notes),w(m,-1),w(y,1),u}function uC(e,t,n,r=Si){const i=Math.max(1,e.x2-e.x1),o=Math.max(1,e.y2-e.y1),s=ac(Math.min((t-r*2)/i,(n-r*2)/o));return{x:t/2-(e.x1+e.x2)/2*s,y:n/2-(e.y1+e.y2)/2*s,scale:s}}function Ep(e,t,n,r=Si){return Math.min((t-r*2)/Math.max(1,e.x2-e.x1),(n-r*2)/Math.max(1,e.y2-e.y1))}function cC(e,t,n,r,i=4){const o=t.x-e.x,s=t.y-e.y,a=Math.hypot(o,s),u=n+i,c=r+i;if(!Number.isFinite(a)||a<=0||u+c>=a)return null;const l=o/a,d=s/a;return{x1:e.x+l*u,y1:e.y+d*u,x2:t.x-l*c,y2:t.y-d*c}}function $n(e){return Math.round(e*100)/100}function bu(e,t,n,r,i){const o=s=>`${$n(s.x)},${$n(s.y)}`;return{kind:e,start:t,end:i,controls:[n,r],d:`M${o(t)} C${o(n)} ${o(r)} ${o(i)}`}}function uc(e,t,n,r,i=4){const o=t.x-e.x,s=t.y-e.y,a=Math.hypot(o,s),u=n+r+i*2;if(!Number.isFinite(a)||a<=u)return null;if(o>=u){const f={x:e.x+n+i,y:e.y},h={x:t.x-r-i,y:t.y},p=h.x-f.x,m=Math.max(p*.45,Math.min(65,p));return bu("forward",f,{x:f.x+m,y:f.y},{x:h.x-m,y:h.y},h)}if(o<=-u){const f={x:e.x,y:e.y-n-i},h={x:t.x,y:t.y-r-i},p=Math.max(100,Math.abs(o)*.2);return bu("backward",f,{x:f.x+85,y:f.y-p},{x:h.x+85,y:h.y-p},h)}if(Math.abs(s)>u){const f=s>0?1:-1,h={x:e.x,y:e.y+f*(n+i)},p={x:t.x,y:t.y-f*(r+i)},m=Math.abs(p.y-h.y),y=Math.max(m*.45,Math.min(40,m));return bu("vertical",h,{x:h.x,y:h.y+f*y},{x:p.x,y:p.y-f*y},p)}const c=cC(e,t,n,r,i),l={x:c.x1,y:c.y1},d={x:c.x2,y:c.y2};return{kind:"straight",start:l,end:d,controls:null,d:`M${$n(l.x)},${$n(l.y)} L${$n(d.x)},${$n(d.y)}`}}const lC=6,wu=lC+3,en=14,$p=10,dC=3,Tp=6;function fC(e,t,n){const r=Mt(e),i=[];for(const o of r.nodes){const s=t[o.id];if(s)for(const{kind:a,box:u}of sh(Rn(o,r.checked_address,Ei(n,o.id))))a==="circle"?i.push({id:o.id,kind:"circle",x:s.x,y:s.y,r:u.x2}):i.push({id:o.id,kind:"box",x1:s.x+u.x1,y1:s.y+u.y1,x2:s.x+u.x2,y2:s.y+u.y2})}return i}function hC(e,t){if(t.kind==="circle")return Math.hypot(e.x-t.x,e.y-t.y)-t.r;const n=Math.max(t.x1-e.x,0,e.x-t.x2),r=Math.max(t.y1-e.y,0,e.y-t.y2);return n||r?Math.hypot(n,r):-Math.min(e.x-t.x1,t.x2-e.x,e.y-t.y1,t.y2-e.y)}function pC(e,t){return e.kind==="circle"?{x1:e.x-e.r-t,y1:e.y-e.r-t,x2:e.x+e.r+t,y2:e.y+e.r+t}:{x1:e.x1-t,y1:e.y1-t,x2:e.x2+t,y2:e.y2+t}}function mC(e,t){const n=1-t;return{x:n*n*n*e[0].x+3*n*n*t*e[1].x+3*n*t*t*e[2].x+t*t*t*e[3].x,y:n*n*n*e[0].y+3*n*n*t*e[1].y+3*n*t*t*e[2].y+t*t*t*e[3].y}}function gC(e){return e.controls?[{kind:"C",points:[e.start,e.controls[0],e.controls[1],e.end]}]:[{kind:"L",points:[e.start,e.end]}]}function qw(e){let t=0,n;for(const r of e)n&&(t+=Math.hypot(r.x-n.x,r.y-n.y)),n=r;return t}function yC(e,t){const n=[];for(const r of e){const i=Math.max(1,Math.ceil(qw(r.points)/t));for(let o=0;o<=i;o++){const s=o/i;if(r.kind==="L"){const[a,u]=r.points;n.push({x:a.x+(u.x-a.x)*s,y:a.y+(u.y-a.y)*s})}else n.push(mC(r.points,s))}}return n}function Cp(e,t,n,r){const i=e.flatMap(a=>a.points),o={x1:Math.min(...i.map(a=>a.x)),y1:Math.min(...i.map(a=>a.y)),x2:Math.max(...i.map(a=>a.x)),y2:Math.max(...i.map(a=>a.y))},s=[];if(n.forEach((a,u)=>{a.x1<=o.x2&&o.x1<=a.x2&&a.y1<=o.y2&&o.y1<=a.y2&&s.push(u)}),!s.length)return!0;for(const a of yC(e,dC))for(const u of s){const c=n[u],l=t[u];if(!(!c||!l)&&!(a.x<c.x1||a.x>c.x2||a.y<c.y1||a.y>c.y2)&&hC(a,l)<r)return!1}return!0}function vC(e){const t=e[0],n=e[e.length-1];if(!t||!n)return[];const r=[];for(let s=1;s<e.length;s++)r.push(qw(e.slice(s-1,s+1)));const i=[];let o=t;for(let s=1;s<e.length-1;s++){const a=e[s-1],u=e[s],c=e[s+1],l=r[s-1],d=r[s];if(!a||!u||!c||l===void 0||d===void 0)continue;const f=l/(s-1===0?1:2),h=d/(s===r.length-1?1:2),p=Math.min(en,f,h),m={x:(u.x-a.x)/l,y:(u.y-a.y)/l},y={x:(c.x-u.x)/d,y:(c.y-u.y)/d},b={x:u.x-m.x*p,y:u.y-m.y*p},g={x:u.x+y.x*p,y:u.y+y.y*p};i.push({kind:"L",points:[o,b]}),i.push({kind:"C",points:[b,{x:b.x+m.x*p*.55,y:b.y+m.y*p*.55},{x:g.x-y.x*p*.55,y:g.y-y.y*p*.55},g]}),o=g}return i.push({kind:"L",points:[o,n]}),i.filter(s=>s.kind==="C"||Math.hypot(s.points[1].x-s.points[0].x,s.points[1].y-s.points[0].y)>.01)}function bC(e){const t=i=>`${$n(i.x)},${$n(i.y)}`,n=e[0];if(!n)return"";let r=`M${t(n.points[0])}`;for(const i of e)r+=i.kind==="L"?` L${t(i.points[1])}`:` C${t(i.points[1])} ${t(i.points[2])} ${t(i.points[3])}`;return r}function Ap(e,t,n,r,i){const o=Math.min(e.y,n)-en,s=Math.max(e.y,n)+en,a=d=>(d-e.x)*t;let u=1/0;for(const d of i)if(d.y1<e.y&&e.y<d.y2){const f=t===1?d.x1:d.x2,h=t===1?d.x2:d.x1;a(h)>0&&(u=Math.min(u,Math.max(0,a(f))))}const c=i.filter(d=>d.y1<s&&o<d.y2).map(d=>[a(t===1?d.x1:d.x2),a(t===1?d.x2:d.x1)]).filter(([,d])=>d>r).sort((d,f)=>d[0]-f[0]);let l=r;for(const[d,f]of[...c,[1/0,1/0]]){if(d>l+1){const h=Math.min(d,u);if(h<=l+1)return null;const p=Number.isFinite(h)&&h-l<80?(l+h)/2:l+40;return e.x+t*p}if(l=Math.max(l,f),l>=u)return null}return null}function wC(e){const t=[];for(const n of e){const r=t[t.length-1];r&&Math.abs(r.x-n.x)<.01&&Math.abs(r.y-n.y)<.01||t.push(n)}return t.filter((n,r)=>{if(r===0||r===t.length-1)return!0;const i=t[r-1],o=t[r+1];return!i||!o?!0:!(Math.abs(i.x-n.x)<.01&&Math.abs(o.x-n.x)<.01||Math.abs(i.y-n.y)<.01&&Math.abs(o.y-n.y)<.01)})}const _C=120;function kC(e,t,n,r,i,o=4){const s=uc(e,t,n,r,o);if(!s||!i.length)return s;const a=i.map(f=>pC(f,wu));if(Cp(gC(s),i,a,wu))return s;const u=new Set([e.y,t.y]),c=f=>Math.abs(f-e.y)<Tp?e.y:Math.abs(f-t.y)<Tp?t.y:f;for(const f of a)u.add(c(Math.round(f.y1)-en-1)),u.add(c(Math.round(f.y2)+en+1));const l=t.x>=e.x?1:-1,d=[[l,l],[l,-l],[-l,l],[-l,-l]];for(const[f,h]of d){const p={x:e.x+f*(n+o),y:e.y},m={x:t.x-h*(r+o),y:t.y},y=[];for(const b of u){const g=Math.abs(b-p.y)<.01?p.x:Ap(p,f,b,en,a);if(g===null)continue;const w=Math.abs(b-m.y)<.01?m.x:Ap(m,-h,b,en+$p,a);if(w===null||Math.abs(b-m.y)<.01&&(m.x-g)*h<en+$p||Math.abs(b-p.y)<.01&&(w-p.x)*f<en)continue;const v=wC([p,{x:g,y:p.y},{x:g,y:b},{x:w,y:b},{x:w,y:m.y},m]);if(!SC(v,a))continue;let _=(v.length-2)*en,k;for(const x of v)k&&(_+=Math.abs(x.x-k.x)+Math.abs(x.y-k.y)),k=x;y.push({points:v,length:_})}y.sort((b,g)=>{const w=b.points[2]?.y,v=g.points[2]?.y;return b.length-g.length||(w===void 0||v===void 0?0:w-v)});for(const b of y){const g=vC(b.points);if(!Cp(g,i,a,wu))continue;const w=b.points,v=w[0],_=w[w.length-1];if(!v||!_)continue;const k={x1:Math.min(...w.map(x=>x.x)),y1:Math.min(...w.map(x=>x.y)),x2:Math.max(...w.map(x=>x.x)),y2:Math.max(...w.map(x=>x.y))};return{kind:"routed",start:v,end:_,controls:null,d:bC(g),bounds:k}}}return s}function SC(e,t){let n;for(const r of e){if(n){const i={x1:Math.min(n.x,r.x),y1:Math.min(n.y,r.y),x2:Math.max(n.x,r.x),y2:Math.max(n.y,r.y)};for(const o of t)if(XT(i,o))return!1}n=r}return!0}function Ww(e,t){if(!t)return Jt.rest;const n=Je(t);return Je(e.from)===n||Je(e.to)===n?Jt.related:Jt.faded}function xC(){return{hit:{stroke:"transparent",width:16},line:{stroke:Ke("edge"),width:1.6},arrow:{fill:Ke("edge")}}}function EC(e,t,n){return e!=="gravity"&&e!=="tree"?null:{layout:e,id:t,pointerId:n}}function $C(e,t,n,r){return e!=="node"&&e!=="edge"&&e!=="canvas"||!Number.isFinite(r?.x)||!Number.isFinite(r?.y)?null:{kind:e,id:t??null,pointerId:n,start:{...r},moved:!1}}function TC(e,t,n,r=LT){if(!e||e.pointerId!==t)return e;const i=Math.hypot(n.x-e.start.x,n.y-e.start.y);return{...e,moved:e.moved||i>r}}function CC(e,t,n=!1){return!e||e.pointerId!==t||n||e.moved?null:e.kind==="node"?{type:"select-node",id:e.id}:e.kind==="edge"?{type:"select-edge",id:e.id}:e.kind==="canvas"?{type:"clear-selection"}:null}function Ip(e){return e==="Enter"||e===" "}function AC(e,t){return{x:(e.x-t.x)/t.scale,y:(e.y-t.y)/t.scale}}function IC(e,t,n,r,i){return!t||t.pointerId!==n||!Object.hasOwn(e,t.id)?!1:(e[t.id]=AC(r,i),!0)}function NC(e,t){return e?.pointerId===t?null:e}function RC(e,t,n,r){const i=Math.min(t.width/n,t.height/r),o=t.left+(t.width-n*i)/2,s=t.top+(t.height-r*i)/2;return{x:(e.x-o)/i,y:(e.y-s)/i}}function LC(e,t,n){const r=new Map;let i=null,o=null,s=null;function a(h){if(h===e)return{kind:"canvas",id:null};const p=h;if(p?.closest?.("[data-canvas]"))return{kind:"canvas",id:null};const m=p?.closest?.("[data-node-id]");if(m)return{kind:"node",id:m.dataset.nodeId??null};const y=p?.closest?.("[data-edge-id]");return y?{kind:"edge",id:y.dataset.edgeId??null}:null}function u(h){if(h.pointerType==="mouse"&&h.button!==0)return;const p=n?n(h):a(h.target);if(!p)return;const m=t.point(h);if(r.set(h.pointerId,m),e.setPointerCapture(h.pointerId),p.kind!=="canvas"&&(h.preventDefault(),h.stopPropagation()),r.size===1){i=$C(p.kind,p.id,h.pointerId,{x:h.clientX,y:h.clientY}),o=p.kind==="canvas"?{point:m,transform:{...t.transform()}}:null;return}if(i&&(i={...i,moved:!0}),o=null,r.size===2){const[y,b]=[...r.values()];y&&b&&(s={distance:Math.hypot(b.x-y.x,b.y-y.y),scale:t.transform().scale},t.startPinch())}}function c(h){if(!r.has(h.pointerId))return;const p=t.point(h);if(r.set(h.pointerId,p),s){const[m,y]=[...r.values()];m&&y&&t.pinch(s,[m,y],h);return}if(i?.pointerId===h.pointerId){if(i=TC(i,h.pointerId,{x:h.clientX,y:h.clientY}),!i?.moved)return;if(i.kind==="node"){t.drag(i.id??"",h.pointerId,p,h);return}if(i.kind==="edge")return}o&&t.pan(o,p,h)}function l(h,p=!1){const m=CC(i,h.pointerId,p);m&&t.select(m),i?.pointerId===h.pointerId&&(i=null),t.endDrag(h.pointerId),r.delete(h.pointerId),r.size||(i=null,o=null,s=null),e.hasPointerCapture(h.pointerId)&&e.releasePointerCapture(h.pointerId)}const d=h=>l(h),f=h=>l(h,!0);return e.addEventListener("pointerdown",u,!0),e.addEventListener("pointermove",c),e.addEventListener("pointerup",d),e.addEventListener("pointercancel",f),()=>{e.removeEventListener("pointerdown",u,!0),e.removeEventListener("pointermove",c),e.removeEventListener("pointerup",d),e.removeEventListener("pointercancel",f)}}function zC(e,t,n){let r=!1;function i(o,s=!1){r=o,e.classList.toggle("graph-panel--expanded",o),n.classList.toggle("graph-expanded",o),t.classList.toggle("expand-control--expanded",o),t.setAttribute("aria-expanded",String(o)),t.setAttribute("aria-label",o?"Close expanded graph":"Expand graph"),t.setAttribute("title",o?"Close expanded graph":"Expand graph"),o?(e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true")):(e.removeAttribute("role"),e.removeAttribute("aria-modal"),s&&t.focus())}return{open(){i(!0)},close(o={}){i(!1,o.restoreFocus!==!1)},toggle(){i(!r,r)},isOpen(){return r}}}function Kw(e){const t=String(e??"").toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):"Unknown"}function cc(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e)}function lc(e){return e==null?"Unavailable":new Intl.NumberFormat("en-US").format(e)}function Tn(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return"Unavailable";const t=new Date(e<1e11?e*1e3:e);return!Number.isFinite(t.getTime())||t.getUTCFullYear()<2009||t.getUTCFullYear()>2100?"Unavailable":new Intl.DateTimeFormat("en-GB",{dateStyle:"medium",timeStyle:"short",timeZone:"UTC"}).format(t)}function Jw(e,t=Date.now()){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return"Unavailable";const n=Math.max(0,(t-(e<1e11?e*1e3:e))/1e3),r=[[31536e3,"year"],[2592e3,"month"],[86400,"day"],[3600,"hour"],[60,"minute"]];for(const[i,o]of r){const s=Math.floor(n/i);if(s>=1)return`${s} ${o}${s===1?"":"s"} ago`}return"just now"}function dc(e){if(e.amount_usd_sum==null||e.price_coverage_ratio===0)return"Unavailable";const t=e.price_coverage_ratio;return cc(e.amount_usd_sum)+(t!=null&&t>0&&t<1?" (priced portion)":"")}function PC(e){const t=[["Incoming amount (USD)",e.total_in_usd==null?"Unavailable":cc(e.total_in_usd)],["Outgoing amount (USD)",e.total_out_usd==null?"Unavailable":cc(e.total_out_usd)]];return e.role&&qr.includes(e.role)?[["Role",jw[e.role]||"Other"],...t,["Senders",lc(e.degree_in)],["Receivers",lc(e.degree_out)],["Labels",In(e).join(", ")||"No labels"]]:[["Address risk",e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} · ${Kw(e.risk_level)}`],["Confidence","Unavailable"],...t,["First activity (UTC)",Tn(e.first_activity_timestamp)],["Last activity (UTC)",Tn(e.last_activity_timestamp)],["Labels",In(e).join(", ")||"No labels"]]}function DC(e,t){if(e.source==="flows")return[["From",e.from||"Unavailable"],["To",e.to||"Unavailable"],["Value (USD)",dc(e)],["Transfers",lc(e.tx_count)],["First seen (UTC)",Tn(e.first_seen_timestamp)],["Last seen (UTC)",Tn(e.last_seen_timestamp)],["Since last seen",Jw(e.last_seen_timestamp,t)],...e.link_kind?[["Link kind",e.link_kind]]:[]];const n=e.price_coverage_ratio;return[["From",e.from||"Unavailable"],["To",e.to||"Unavailable"],["Value (USD)",dc(e)],["Price coverage",n==null?"Unavailable":new Intl.NumberFormat("en-GB",{style:"percent",maximumFractionDigits:1}).format(n)],["Transfers",e.tx_count==null?"Unavailable":String(e.tx_count)],["First seen (UTC)",Tn(e.first_seen_timestamp)],["Last seen (UTC)",Tn(e.last_seen_timestamp)],["First transaction",e.first_tx_id||"Unavailable"],["Last transaction",e.last_tx_id||"Unavailable"]]}function Yw(e){return typeof e!="string"||!/^0x[a-fA-F0-9]{64}$/.test(e)?null:`https://robinhoodchain.blockscout.com/tx/${e.toLowerCase()}`}function fc(e){const t=Do(e);if(e.role)return`${e.address}. ${t||"Other"}.${In(e).length?` Labels: ${In(e).join(", ")}.`:""}`;const n=e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} ${Kw(e.risk_level)} risk`,r=In(e).join(", ");return`${e.address}. ${n}.${r?` Labels: ${r}.`:""}`}const Xw=80;function OC(e){const t=Math.abs(e);return t>=1e9?`$${(e/1e9).toFixed(1)}B`:t>=1e6?`$${(e/1e6).toFixed(1)}M`:t>=1e4?`$${Math.round(e/1e3)}K`:t>=100?`$${Math.round(e)}`:`$${e.toFixed(2)}`}function MC(e,t){const n=u=>new Date(u<1e12?u*1e3:u),r=e&&e>0?n(e):null,i=t&&t>0?n(t):r;if(!i)return"";const o=u=>u.getUTCDate(),s=u=>u.toLocaleString("en-US",{month:"short",timeZone:"UTC"}),a=u=>`${o(u)} ${s(u)} ${u.getUTCFullYear()}`;return!r||r.toISOString().slice(0,10)===i.toISOString().slice(0,10)?a(i):r.getUTCFullYear()!==i.getUTCFullYear()?`${a(r)} – ${a(i)}`:r.getUTCMonth()!==i.getUTCMonth()?`${o(r)} ${s(r)} – ${a(i)}`:`${o(r)} – ${a(i)}`}function Qw(e){const t=e.amount_usd_sum!=null&&e.price_coverage_ratio!==0?OC(e.amount_usd_sum):"",n=MC(e.first_seen_timestamp,e.last_seen_timestamp);return[t,n].filter(Boolean).join(" · ")}function hc(e,t){const n=`${e.from} to ${e.to}. Aggregate value ${dc(e)}. ${e.tx_count??0} ${e.tx_count===1?"transfer":"transfers"}.`;return e.source==="flows"&&e.last_seen_timestamp?`${n} Last seen ${Jw(e.last_seen_timestamp,t)}.`:n}function FC(e,t){return Mt(e).nodes.map(n=>{const r={id:n.address,label:In(n).join(", ")||Do(n)};n.role&&(r.role=n.role);const i=t?.(n.address);return i&&(r.href=i),r})}function UC(e,t=22){return e.length>t?`${e.slice(0,t-1)}…`:e}function GC(e,t,n={}){const r=e.ownerDocument;let i=Mt(t),o=n.layout??(rh(t)?"tree":"gravity");const s={width:e.clientWidth||n.width||820,height:e.clientHeight||n.height||430};let a=Wo(i,o,s.width,s.height);const u=new Map,c=new Map;let l={x:0,y:0,scale:1},d=null,f=null,h=null;const p=n.now??(()=>Date.now()),m=T=>n.nodeStyle?.(T).stroke??WT(T);e.classList.add("cia-graph-engine"),e.closest(".cia-graph-surface")||e.classList.add("cia-graph-surface");const y={model:()=>i,positions:()=>a,transform:()=>l,notes:()=>u,flags:()=>c,selected:()=>d,highlighted:()=>f,colorOf:m,now:p,dimensions:()=>s},b={selectNode:(T,D)=>H(T,D),selectEdge:(T,D)=>K(T,D),showTooltip:(T,D)=>G(T,D),hideTooltip:()=>fe(),lost:()=>Te()};function g(T){const D=T==="webgl"?_p("webgl"):null;if(D)try{return D(e,y,b,{label:n.label})}catch{}return kp(e,y,b,{label:n.label})}const w=n.renderer??(_p("webgl")&&TT(r)?"webgl":"svg");let v=g(w);e.dataset.renderer=v.kind;const _=()=>{const T=YT(i,a,u);if(!T)return null;const D=v.linkBounds();return D&&(T.x1=Math.min(T.x1,D.x1),T.y1=Math.min(T.y1,D.y1),T.x2=Math.max(T.x2,D.x2),T.y2=Math.max(T.y2,D.y2)),T},k=()=>{const T=_();return T?uC(T,s.width,s.height,Si):{x:0,y:0,scale:1}};l=k();const x=r.createElement("div");x.className="graph-tooltip cia-graph-tooltip",x.hidden=!0,x.setAttribute("role","tooltip"),e.append(x);let N=0,M=!1,F=!1;function B(){if(N){M=!0;return}v.build()}function ee(){if(N){F=!0;return}l=k(),ce()}function ce(){v.camera()}function me(T="program"){const D=FC(i,n.href),ne=d?.kind==="node"?i.nodes.find(ve=>ve.id===d.id)??null:null,Se=d?.kind==="edge"?i.edges.find(ve=>ve.id===d.id)??null:null;if(ne){const ve=i.edges.filter(dt=>dt.from===ne.address||dt.to===ne.address);return{kind:"node",id:ne.id,selectedId:ne.address,nodes:D,title:"Selected address",identity:ne.address,values:PC(ne),related:ve,node:ne,edge:null,source:T}}return Se?{kind:"edge",id:Se.id,selectedId:null,nodes:D,title:"Selected aggregate flow",identity:`${Se.from} → ${Se.to}`,values:DC(Se,p()),related:[Se],node:null,edge:Se,source:T}:{kind:null,id:null,selectedId:null,nodes:D,title:"Nothing selected",identity:"",values:[],related:[],node:null,edge:null,source:T}}function $e(T){const D=me(T);U(D),n.onSelect?.(D)}function U(T){const D=n.selectionRoot,ne=D?.querySelector("[data-selection-title]"),Se=D?.querySelector("[data-selection-identity]"),ve=D?.querySelector("[data-selection-meta]");!ne||!Se||!ve||(ne.textContent=T.title,Se.textContent=T.identity,ve.replaceChildren(...T.values.map(([dt,ke])=>{const yt=r.createElement("div");yt.className="meta-item",ke!=="Unavailable"&&(["From","To","First transaction","Last transaction"].includes(dt)&&yt.classList.add("meta-item--identity"),dt==="Incoming amount (USD)"&&yt.classList.add("meta-item--incoming"),dt==="Outgoing amount (USD)"&&yt.classList.add("meta-item--outgoing")),["From","To","First transaction","Last transaction","Labels"].includes(dt)&&yt.classList.add("meta-item--wide");const nr=r.createElement("span");nr.textContent=dt;const Dn=r.createElement("strong"),xt=["First transaction","Last transaction"].includes(dt)?Yw(ke):null;if(xt&&n.openLink){const Ht=n.openLink,Vt=r.createElement("button");Vt.type="button",Vt.className="cia-graph-explorer-link",Vt.dataset.explorer=xt,Vt.textContent=ke,Vt.setAttribute("aria-label",`${dt}: ${ke} (opens the explorer)`),Vt.addEventListener("click",()=>Ht(xt)),Dn.append(Vt)}else if(xt){const Ht=r.createElement("a");Ht.href=xt,Ht.target="_blank",Ht.rel="noopener noreferrer",Ht.textContent=ke,Ht.setAttribute("aria-label",`${dt}: ${ke} (opens in new tab)`),Dn.append(Ht)}else Dn.textContent=ke;return yt.append(nr,Dn),yt})))}function H(T,D="program"){d=T?{kind:"node",id:T}:null,v.selection(),$e(D)}function K(T,D="program"){d=T?{kind:"edge",id:T}:null,v.selection(),$e(D)}function de(T){if(T==null)return H(null);const D=kn(i,T);if(D)return H(D);if(i.edges.some(ne=>ne.id===T))return K(T)}function te(){l=k(),ce()}function I(T,D={x:s.width/2,y:s.height/2}){const ne=ac(l.scale*(1+T)),Se=ne/l.scale;l={x:D.x-(D.x-l.x)*Se,y:D.y-(D.y-l.y)*Se,scale:ne},ce()}function z(T){o=T,n.controls?.querySelectorAll("[data-layout]").forEach(D=>{D.classList.toggle("active",D.dataset.layout===T),D.setAttribute("aria-pressed",String(D.dataset.layout===T))}),n.onLayoutChange?.(T),a=Wo(i,o,s.width,s.height),v.geometry(),te()}function G(T,D){x.textContent=D,x.hidden=!1;const ne=e.getBoundingClientRect();x.style.left=`${Math.min(ne.width-330,Math.max(8,T.clientX-ne.left+12))}px`,x.style.top=`${Math.max(8,T.clientY-ne.top+12)}px`}function fe(){x.hidden=!0}function ie(T){return RC({x:T.clientX,y:T.clientY},v.surface.getBoundingClientRect(),s.width,s.height)}const Y={point:ie,transform:()=>l,select(T){T.type==="select-node"?H(T.id,"pointer"):T.type==="select-edge"?K(T.id,"pointer"):H(null,"canvas")},drag(T,D,ne){!h&&(h=EC(o,T,D),!h)||IC(a,h,D,ne,l)&&(oe=!0,v.moveNode(h.id))},endDrag(T){const D=h?.pointerId===T&&oe;h=NC(h,T),D&&(oe=!1,v.endMove())},pan(T,D){l={x:T.transform.x+D.x-T.point.x,y:T.transform.y+D.y-T.point.y,scale:l.scale},ce()},startPinch(){h=null},pinch(T,[D,ne]){const Se=Math.hypot(ne.x-D.x,ne.y-D.y),ve=ac(T.scale*Se/Math.max(1,T.distance));I(ve/l.scale-1,{x:(D.x+ne.x)/2,y:(D.y+ne.y)/2})}};let oe=!1;const he=T=>{T.preventDefault(),I(T.deltaY>0?-.12:.12,ie(T))},Ae={ArrowLeft:[60,0],ArrowRight:[-60,0],ArrowUp:[0,60],ArrowDown:[0,-60]},O=T=>{if(T.target!==v.surface)return;const D=Ae[T.key];D?(T.preventDefault(),l={...l,x:l.x+D[0],y:l.y+D[1]},ce()):T.key==="+"||T.key==="="?I(.18):T.key==="-"?I(-.18):T.key==="0"&&te()};let j=()=>{};function q(){const T=v.surface,D=ne=>v.pick(ie(ne));j=LC(T,Y,v.kind==="svg"?void 0:D),T.addEventListener("wheel",he,{passive:!1}),T.addEventListener("keydown",O)}function J(){j(),v.surface.removeEventListener("wheel",he),v.surface.removeEventListener("keydown",O)}q();function Te(){v.kind!=="svg"&&(J(),v.destroy(),v=kp(e,y,b,{label:n.label}),e.dataset.renderer=v.kind,e.append(x),q(),B())}const se=n.controls?.querySelector("[data-expand]")??null,ye=n.panel&&se?zC(n.panel,se,r.body):null,Oe=()=>{ye?.toggle(),n.onExpansionChange?.(ye?.isOpen()??!1),requestAnimationFrame(te)},ae=n.panel??e,ze=T=>{if(T.key==="Tab"&&ye?.isOpen()&&n.panel){const D=Array.from(n.panel.querySelectorAll('button,a[href],[tabindex="0"],summary')).filter(ve=>ve.checkVisibility()),ne=D[0],Se=D.at(-1);T.shiftKey&&r.activeElement===ne?(T.preventDefault(),Se?.focus()):!T.shiftKey&&r.activeElement===Se&&(T.preventDefault(),ne?.focus())}if(T.key==="Escape"){if(ye?.isOpen()){ye.close(),n.onExpansionChange?.(!1),requestAnimationFrame(te);return}H(null,"keyboard")}};ae.addEventListener("keydown",ze);const qe=[],tt=(T,D)=>{T&&(T.addEventListener("click",D),qe.push([T,D]))};n.controls?.querySelectorAll("[data-layout]").forEach(T=>tt(T,()=>z(T.dataset.layout==="tree"?"tree":"gravity"))),tt(n.controls?.querySelector("[data-zoom='in']"),()=>I(.18)),tt(n.controls?.querySelector("[data-zoom='out']"),()=>I(-.18)),tt(n.controls?.querySelector("[data-zoom='fit']"),te),ye&&tt(se,Oe);const Ye=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const T=e.clientWidth,D=e.clientHeight;!T||!D||T===s.width&&D===s.height||(s.width=T,s.height=D,v.resize(T,D),te())});Ye?.observe(e),B(),n.selected&&de(n.selected);const St={update(T){const D=a;i=Mt(T);const ne=i.nodes.every(ve=>D[ve.id])?{}:Wo(i,o,s.width,s.height);a=Object.fromEntries(i.nodes.map(ve=>[ve.id,D[ve.id]??ne[ve.id]]).filter(([,ve])=>ve)),d&&!(d.kind==="node"?i.nodes.some(ve=>ve.id===d.id):i.edges.some(ve=>ve.id===d.id))&&(d=null),f&&!i.nodes.some(ve=>ve.id===f)&&(f=null);const Se=new Set(i.nodes.map(ve=>ve.id));for(const ve of[...c.keys()])Se.has(ve)||c.delete(ve);B(),ee()},merge(T,D){const ne=BT(i,T,D);i=ne.model;const Se=kn(i,D??Mt(T).checked_address);return a=Se&&o==="gravity"?aC(i,a,Se,ne.added,{notes:u}):Wo(i,o,s.width,s.height),B(),ne.added.length&&ee(),ne.added},batch(T){N++;try{T()}finally{N--,!N&&M&&(M=!1,v.build()),!N&&F&&(F=!1,l=k(),ce())}},setTheme(T){T&&r.documentElement.setAttribute("data-theme",T),v.theme()},select:de,destroy(){Ye?.disconnect(),J(),ae.removeEventListener("keydown",ze);for(const[T,D]of qe)T.removeEventListener("click",D);ye?.close({restoreFocus:!1}),v.destroy(),x.remove(),e.classList.remove("cia-graph-engine"),delete e.dataset.renderer,delete e.ciaGraph},fit:te,zoom:T=>I(T),setLayout:z,markNode(T,D){const ne=kn(i,T);ne&&(D?u.set(ne,D):u.delete(ne),B())},patchNode(T,D){const ne=kn(i,T),Se=ne?i.nodes.find(ve=>ve.id===ne):null;return Se?(Object.assign(Se,D),v.selection(),!0):!1},flagNode(T,D,ne){const Se=kn(i,T);if(!Se)return;const ve=c.get(Se)??new Set;ne?ve.add(D):ve.delete(D),ve.size?c.set(Se,ve):c.delete(Se),N?M=!0:v.flag(Se,D,ne)},positions:()=>structuredClone(a),model:()=>i,contentBounds:()=>_(),transform:()=>({...l}),highlight(T){f=T==null?null:kn(i,T),v.selection()},renderer:()=>v.kind,clientPoint(T){const D=kn(i,T),ne=D?a[D]:null;if(!ne)return null;const Se=v.surface.getBoundingClientRect(),ve=Math.min(Se.width/s.width,Se.height/s.height)||1,dt=Se.left+(Se.width-s.width*ve)/2,ke=Se.top+(Se.height-s.height*ve)/2;return{x:dt+(ne.x*l.scale+l.x)*ve,y:ke+(ne.y*l.scale+l.y)*ve}}};return Object.defineProperty(e,"ciaGraph",{value:St,configurable:!0}),St}const e_="chain-insights.flows.v1",tu="chain-insights.result.v1",t_=5e3,Np=6,jC=3,n_=/^0x[0-9a-fA-F]{40}$/,ZC=/^0x[0-9a-fA-F]{64}$/;function BC(e){return typeof e=="string"&&(n_.test(e)||ZC.test(e))}function $i(e){return typeof e=="string"&&n_.test(e)}function pc(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function nu(e){const t=e?.facts?.query?.results;return Array.isArray(t)?t.filter(pc):[]}function HC(e){const t=e?.facts;return typeof t?.subject?.network=="string"&&t.subject.network?t.subject.network:"robinhood"}function Qt(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&/^-?\d+(\.\d+)?([eE][-+]?\d+)?$/.test(e.trim())){const t=Number(e);return Number.isFinite(t)?t:null}return null}function ah(e){return e<1e11?e*1e3:e}const r_=/^\d{4}-\d{2}-\d{2}$/,VC=Date.UTC(2009,0,1),qC=Date.UTC(2100,0,1);function cs(e){return new Date(ah(e)).toISOString().slice(0,10)}function xs(e){if(typeof e!="string"||!r_.test(e))return!1;const t=Date.parse(`${e}T00:00:00Z`);return Number.isFinite(t)&&new Date(t).toISOString().slice(0,10)===e}const WC=new Set(["day","date","hour","week","month"]),KC=["_timestamp","_time","_at"];function Rp(e){return WC.has(e)||KC.some(t=>e.endsWith(t))}function i_(e){const t=[];for(const n of e)for(const r of Object.keys(n))t.includes(r)||t.push(r);return t}function JC(e){return Array.isArray(e)?e.some($i):$i(e)}function YC(e){return e.some(t=>Object.values(t).some(JC))}function o_(e){return e.length>0&&e.every(t=>$i(t.from_address)&&$i(t.to_address))}const XC=/^(\d{4})-(\d{2})$/,QC=/^(\d{4})-W(\d{2})$/,eA=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/,tA=/(?:Z|[+-]\d{2}:?\d{2})$/i;function nA(e,t){const n=Date.UTC(e,0,4);return n-(new Date(n).getUTCDay()+6)%7*864e5+(t-1)*7*864e5}function Lp(e){if(typeof e=="string"){const r=e.trim();if(r_.test(r))return xs(r)?Date.parse(`${r}T00:00:00Z`):null;const i=XC.exec(r);if(i){const s=Number(i[2])-1;return s>=0&&s<12?Date.UTC(Number(i[1]),s,1):null}const o=QC.exec(r);if(o){const s=Number(o[2]);return s>=1&&s<=53?nA(Number(o[1]),s):null}if(eA.test(r)){const s=r.replace(" ","T"),a=Date.parse(tA.test(s)?s:`${s}Z`);return Number.isFinite(a)?a:null}}const t=Qt(e);if(t==null)return null;const n=ah(t);return n>=VC&&n<qC?n:null}const rA=1e18,zp=13,iA=/^-?0*(\d+)(?:\.0+)?$/;function oA(e){const t=e.toLowerCase();return t==="balance"||t.endsWith("_balance")||t.endsWith("_wei")}function sA(e){if(typeof e=="string"){const t=iA.exec(e.trim());if(!t)return null;const n=t[1];return n==="0"?"zero":n.length>=zp?"wei":null}return typeof e!="number"||!Number.isInteger(e)?null:e===0?"zero":Math.abs(e)>=10**(zp-1)?"wei":null}function aA(e,t){if(!oA(e))return!1;if(e.toLowerCase().endsWith("_wei"))return!0;const n=t.filter(r=>r!=null).map(sA);return n.includes("wei")&&n.every(r=>r!=null)}function uA(e){return`${e.replace(/_wei$/i,"")} (ETH)`}function uh(e,t={}){if(e.length===0||YC(e))return null;const n=i_(e),i=n.filter(Rp).find(d=>e.some(f=>Lp(f[d])!=null));if(!i)return null;const o=n.filter(d=>{if(Rp(d))return!1;const f=e.map(h=>h[d]).filter(h=>h!=null);return f.length>0&&f.every(h=>Qt(h)!=null)});if(o.length===0)return null;const s=o.slice(0,Np),a=new Map;let u=0;for(const d of e){const f=Lp(d[i]);if(f==null)continue;u++;const h=a.get(f)??{count:0,sums:s.map(()=>null)};h.count++,s.forEach((p,m)=>{const y=Qt(d[p]);y!=null&&(h.sums[m]=(h.sums[m]??0)+y)}),a.set(f,h)}const c=[...a.entries()].sort((d,f)=>d[0]-f[0]);return c.filter(([,d])=>d.sums.some(f=>f!=null)).length<(t.minPoints??jC)?null:{xColumn:i,times:c.map(([d])=>d),rowCounts:c.map(([,d])=>d.count),daily:c.every(([d])=>d%864e5===0),series:s.map((d,f)=>{const h=c.map(([,p])=>p.sums[f]??null);return aA(d,e.map(p=>p[d]))?{column:d,name:uA(d),unit:"ETH",values:h.map(p=>p==null?null:p/rA)}:{column:d,values:h}}),omittedColumns:o.slice(Np),skippedRows:e.length-u,failures:[]}}function cA(e){if(!e)return"failed";const t=/^\s*([a-z][a-z0-9_]*)\s*:/.exec(e);if(t?.[1])return t[1];const n=e.trim().split(/\s+/).slice(0,4).join(" ");return n.length>40?`${n.slice(0,39)}…`:n||"failed"}const lA=e=>e==null||Qt(e)!=null;function s_(e){const t=u_(e);if(t.length<3||!t.every(c=>xs(c.id))||new Set(t.map(c=>c.id)).size!==t.length)return null;const n=t.filter(c=>c.ok);if(n.length===0||!n.every(c=>c.rows.length===1))return null;const r=Object.keys(n[0].rows[0]),i=[...r].sort().join("\0");for(const c of n){const l=c.rows[0];if(Object.keys(l).sort().join("\0")!==i||!Object.values(l).every(lA))return null}if(r.length===0||r.includes("day"))return null;const o=[...t].sort((c,l)=>c.id.localeCompare(l.id)),s=o.map(c=>({day:c.id,...c.ok?c.rows[0]:Object.fromEntries(r.map(l=>[l,null]))})),a=o.filter(c=>!c.ok).map(c=>({day:c.id,time:Date.parse(`${c.id}T00:00:00Z`),code:cA(c.error)})),u=uh(s,{minPoints:1});return u?{rows:s,columns:r,failures:a,model:{...u,failures:a}}:null}const dA=/\baddress\s*:\s*(["'])(0x[0-9a-fA-F]{40})\1/g,fA=/^\s*(<)?-(?:\[[^\]]*\])?-(>)?/,hA=/(<)?-(?:\[[^\]]*\])?-(>)?\s*$/;function Pp(e,t){if(!e)return"none";const n=!!e[1],r=!!e[2];return n===r?null:t==="after"?r?"from":"to":r?"to":"from"}function a_(e){if(typeof e!="string"||!e)return null;const t=[...e.matchAll(dA)];if(t.length===0||new Set(t.map(r=>r[2].toLowerCase())).size!==1)return null;let n=null;for(const r of t){const i=r.index??0,o=e.lastIndexOf("(",i),s=e.indexOf(")",i);if(o<0||s<0)return null;const a=[Pp(hA.exec(e.slice(0,o)),"before"),Pp(fA.exec(e.slice(s+1)),"after")];if(a.includes(null))return null;for(const u of a)if(u!=="none"){if(n&&n!==u)return null;n=u}}return n?{address:t[0][2],end:n}:null}function pA(e,t){if(e.length===0||o_(e))return null;const n=a_(t);if(!n)return null;const r=n.address.toLowerCase(),i=i_(e).filter(s=>e.every(a=>$i(a[s]))&&!e.every(a=>String(a[s]).toLowerCase()===r));if(i.length!==1)return null;const o=i[0];return e.map(s=>n.end==="from"?{...s,from_address:n.address,to_address:s[o]}:{...s,from_address:s[o],to_address:n.address})}function mA(e){return o_(e)?"graph":uh(e)?"chart":"table"}const gA=[["sanctioned","sanctioned"],["scam","scam"],["victim","victim"],["pool","pool"],["exchange","exchange"]];function Dp(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim()!=="").map(t=>t.trim()):[]}function yA(e,t){if(t)return"exchange";const n=new Set(e.map(r=>r.replace(/\s+/g,"").toLowerCase()));for(const[r,i]of gA)if(n.has(r))return i;return"other"}const Op=(e,t)=>e==null?t:t==null?e:e+t;function vA(e,t="robinhood",n){const r=new Map;for(const h of e)for(const p of new Set([String(h.from_address).toLowerCase(),String(h.to_address).toLowerCase()]))r.set(p,(r.get(p)??0)+1);let i="",o=0;for(const[h,p]of r)p>o&&(i=h,o=p);const s=n?.toLowerCase();s&&r.has(s)&&(i=s);const a=new Map,u=new Map,c=(h,p,m)=>{const y=a.get(h)??{address:h,labels:[],exchange:!1};for(const b of p)y.labels.some(g=>g.toLowerCase()===b.toLowerCase())||y.labels.push(b);y.exchange=y.exchange||m,a.set(h,y)};i&&a.set(i,{address:i,labels:[],exchange:!1});let l=0;for(const h of e){const p=String(h.from_address).toLowerCase(),m=String(h.to_address).toLowerCase(),y=[p,m].filter((_,k,x)=>!a.has(_)&&x.indexOf(_)===k).length;if(a.size+y>t_||(l++,c(p,Dp(h.from_labels),h.from_is_exchange===!0),c(m,Dp(h.to_labels),h.to_is_exchange===!0),p===m))continue;const b=`${p}->${m}`,g=u.get(b)??{from:p,to:m,usd:null,tx:null,first:null,last:null,kinds:[]};g.usd=Op(g.usd,Qt(h.amount_usd_sum)),g.tx=Op(g.tx,Qt(h.tx_count));const w=Qt(h.first_seen_timestamp),v=Qt(h.last_seen_timestamp);w!=null&&(g.first=g.first==null?w:Math.min(g.first,w)),v!=null&&(g.last=g.last==null?v:Math.max(g.last,v)),typeof h.link_kind=="string"&&h.link_kind&&!g.kinds.includes(h.link_kind)&&g.kinds.push(h.link_kind),u.set(b,g)}const d=[...a.values()].map(h=>({address:h.address,role:yA(h.labels,h.exchange),labels:h.labels})),f=[...u.values()].map(h=>({from:h.from,to:h.to,usd:h.usd,tx_count:h.tx,first_seen_ms:h.first,last_seen_ms:h.last,...h.kinds.length?{link_kind:h.kinds.join(", ")}:{}}));return{view:{schema:e_,network:t,center:i,nodes:d,edges:f,truncated:!1},rowsTotal:e.length,rowsDrawn:l,rowsLeftOut:e.length-l,addresses:a.size}}function u_(e){const t=e?.facts?.queries;return Array.isArray(t)?t.filter(pc).map((n,r)=>({id:typeof n.id=="string"&&n.id?n.id:`Query ${r+1}`,ok:n.ok!==!1&&n.error==null,error:typeof n.error=="string"&&n.error?n.error:null,rows:Array.isArray(n.results)?n.results.filter(pc):[],count:typeof n.count=="number"?n.count:null,truncated:n.truncated===!0,elapsedMs:typeof n.elapsed_ms=="number"?n.elapsed_ms:null,query:typeof n.query=="string"&&n.query?n.query:null})):[]}const Mp=200;function Wr(e){return(e?.content??[]).filter(t=>t?.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
108
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:E().optional().describe("User's language and region preference in BCP 47 format."),timeZone:E().optional().describe("User's timezone in IANA format."),userAgent:E().optional().describe("Host application identifier."),platform:xe([$("web"),$("desktop"),$("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:C({touch:Pe().optional().describe("Whether the device supports touch input."),hover:Pe().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:C({top:we().describe("Top safe area inset in pixels."),right:we().describe("Right safe area inset in pixels."),bottom:we().describe("Bottom safe area inset in pixels."),left:we().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),fT=C({method:$("ui/notifications/host-context-changed"),params:Fw.describe("Partial context update containing only changed fields.")});C({method:$("ui/update-model-context"),params:C({content:le(Po).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:Ce(E(),Le().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});C({method:$("ui/initialize"),params:C({appInfo:Xa.describe("App identification (name and version)."),appCapabilities:uT.describe("Features and capabilities this app provides."),protocolVersion:E().describe("Protocol version this app supports.")})});var hT=C({protocolVersion:E().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Xa.describe("Host application identification and version."),hostCapabilities:aT.describe("Features and capabilities provided by the host."),hostContext:Fw.describe("Rich context about the host environment.")}).passthrough(),pT={target:"draft-2020-12"};async function vp(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](pT);if(n.vendor==="zod"){let{z:r}=await Nk(()=>Promise.resolve().then(()=>rE),void 0,import.meta.url);return r.toJSONSchema(e,{io:t})}throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function bp(e,t,n=""){let r=await e["~standard"].validate(t);if(r.issues){let i=r.issues.map(o=>{let s=o.path?.map(a=>typeof a=="object"?a.key:a).join(".");return s?`${s}: ${o.message}`:o.message}).join("; ");throw Error(n+i)}return r.value}function mT(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function gT(e){if(document.getElementById("__mcp-host-fonts"))return;let t=document.createElement("style");t.id="__mcp-host-fonts",t.textContent=e,document.head.appendChild(t)}class th extends V${_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_assertInitialized(t){if(this._initializedSent)return;let n=`[ext-apps] App.${t}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(n);console.warn(`${n}. This will throw in a future release.`)}eventSchemas={toolinput:tT,toolinputpartial:nT,toolresult:dT,toolcancelled:rT,hostcontextchanged:fT};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(t){if(!th.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(t,n){n&&this._assertHandlerTiming(t),super.setEventHandler(t,n)}addEventListener(t,n){this._assertHandlerTiming(t),super.addEventListener(t,n)}onEventDispatch(t,n){t==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...n})}constructor(t,n={},r={autoResize:!0}){super(r),this._appInfo=t,this._capabilities=n,this.options=r,r.allowUnsafeEval||et({jitless:!0}),this.setRequestHandler(Qa,i=>(console.log("Received ping:",i.params),{})),this.setEventHandler("hostcontextchanged",void 0)}registerCapabilities(t){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._capabilities=H$(this._capabilities,t)}registerTool(t,n,r){if(this._registeredTools[t])throw Error(`Tool ${t} is already registered`);let i=this,o=()=>{i._initializedSent&&i._capabilities.tools?.listChanged&&i.sendToolListChanged()},s=n.inputSchema!==void 0,a={title:n.title,description:n.description,inputSchema:n.inputSchema,outputSchema:n.outputSchema,annotations:n.annotations,_meta:n._meta,enabled:!0,enable(){this.enabled=!0,o()},disable(){this.enabled=!1,o()},update(u){Object.assign(this,u),o()},remove(){i._registeredTools[t]===a&&(delete i._registeredTools[t],o())},handler:async(u,c)=>{if(!a.enabled)throw Error(`Tool ${t} is disabled`);let l;if(s){let d=a.inputSchema,f=d?await bp(d,u??{},`Invalid input for tool ${t}: `):u??{};l=await r(f,c)}else l=await r(c);return a.outputSchema&&!l.isError&&(l.structuredContent=await bp(a.outputSchema,l.structuredContent,`Invalid output for tool ${t}: `)),l}};return this._registeredTools[t]=a,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),o(),a}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(t,n)=>{let r=this._registeredTools[t.name];if(!r)throw Error(`Tool ${t.name} not found`);return r.handler(t.arguments,n)},this.onlisttools=async(t,n)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([r,i])=>i.enabled).map(async([r,i])=>{let o={name:r,title:i.title,description:i.description,inputSchema:i.inputSchema?await vp(i.inputSchema,"input"):{type:"object",properties:{}}};return i.outputSchema&&(o.outputSchema=await vp(i.outputSchema,"output")),i.annotations&&(o.annotations=i.annotations),i._meta&&(o._meta=i._meta),o}))}))}async sendToolListChanged(t={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:t})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(t){this.setEventHandler("toolinput",t)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(t){this.setEventHandler("toolinputpartial",t)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(t){this.setEventHandler("toolresult",t)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(t){this.setEventHandler("toolcancelled",t)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(t){this.setEventHandler("hostcontextchanged",t)}_onteardown;get onteardown(){return this._onteardown}set onteardown(t){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,t),this._onteardown=t,this.replaceRequestHandler(sT,(n,r)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(n.params,r)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler(zw,(n,r)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,r)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(t){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,t),this._onlisttools=t,this.replaceRequestHandler(Lw,(n,r)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(n.params,r)})}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${t})`);break}}assertRequestHandlerCapability(t){switch(t){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${t})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${t} registered`)}}assertNotificationCapability(t){}assertTaskCapability(t){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(t){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(t,n){if(this._assertInitialized("callServerTool"),typeof t=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${t}"). Did you mean: callServerTool({ name: "${t}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:t},eu,{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(t,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},Iw,n)}async listServerResources(t,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},Aw,n)}async createSamplingMessage(t,n){this._assertInitialized("createSamplingMessage");let r=t.tools?Ow:Dw;return await this.request({method:"sampling/createMessage",params:t},r,n)}sendMessage(t,n){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:t},eT,n)}sendLog(t){return this.notification({method:"notifications/message",params:t})}updateModelContext(t,n){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:t},Of,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},X$,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},Q$,n)}requestTeardown(t={}){return this.notification({method:"ui/notifications/request-teardown",params:t})}requestDisplayMode(t,n){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:t},cT,n)}sendSizeChanged(t){return this.notification({method:"ui/notifications/size-changed",params:t})}setupSizeChangedNotifications(){let t=!1,n=0,r=0,i=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let s=document.documentElement,a=s.style.height;s.style.height="max-content";let u=Math.ceil(s.getBoundingClientRect().height);s.style.height=a;let c=Math.ceil(window.innerWidth);(c!==n||u!==r)&&(n=c,r=u,this.sendSizeChanged({width:c,height:u}))}))};i();let o=new ResizeObserver(i);return o.observe(document.documentElement),o.observe(document.body),()=>o.disconnect()}async connect(t=new Mw(window.parent,window.parent),n){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1,await super.connect(t);try{let r=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:q$}},hT,n);if(r===void 0)throw Error(`Server sent invalid initialize result: ${r}`);this._hostCapabilities=r.hostCapabilities,this._hostInfo=r.hostInfo,this._hostContext=r.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(r){throw this.close(),r}}}const yT="Chain Insights graph",vT="This graph is no longer available. Ask for it again.",wp="data-chain-insights-view",bT="This window cannot reach the local Chain Insights page. Open the link in your own browser for clicks that load more",us=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Uw=e=>!us(e)||!us(e.result)?null:{arguments:us(e.arguments)?e.arguments:null,result:e.result};function wT(e,t){const n=t.querySelector(`script[type="application/json"][${wp}]`);if(!n||n.getAttribute(wp)!==e)return null;try{return Uw(JSON.parse(n.textContent??""))}catch{return null}}const _T=new Set(["127.0.0.1","localhost","[::1]","::1"]);function kT(e){const t=new URLSearchParams(e.search).get("view");if(t&&t.trim())return t.trim();if(!_T.has(e.hostname))return null;const n=/^\/view\/([^/]+)\/?$/.exec(e.pathname);if(!n?.[1])return null;try{return decodeURIComponent(n[1])||null}catch{return null}}async function ST(e,t,n){const r=n?wT(e,n):null;if(r)return r;try{const i=await t(`/api/view/${encodeURIComponent(e)}`,{headers:{Accept:"application/json"}});return i.ok?Uw(await i.json()):null}catch{return null}}function xT(e,t){return{async callServerTool({name:n,arguments:r}){let i;try{i=await e(`/api/tools/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({arguments:r})})}catch{throw new Error(bT)}let o=null;try{o=await i.json()}catch{o=null}if(us(o)&&(Array.isArray(o.content)||"structuredContent"in o||"isError"in o))return o;throw new Error(i.ok?"the local Chain Insights page answered with no tool result":`the local Chain Insights page answered HTTP ${i.status}`)},async openLink({url:n}){return t(n,"_blank","noopener"),{}}}}const Gw=new Map;function ET(e,t){Gw.set(e,t)}function _p(e){return Gw.get(e)??null}const $T=/swiftshader|llvmpipe|softpipe|software|microsoft basic render/i;function TT(e){try{const t=e.createElement("canvas");if(typeof t.getContext!="function")return!1;const n={failIfMajorPerformanceCaveat:!0},r=t.getContext("webgl2",n)??t.getContext("webgl",n);if(!r)return!1;const i=r.getExtension?.("WEBGL_debug_renderer_info"),o=String(i?r.getParameter(i.UNMASKED_RENDERER_WEBGL):r.getParameter(r.RENDERER)??"");return $T.test(o)?(r.getExtension?.("WEBGL_lose_context")?.loseContext(),!1):(r.getExtension?.("WEBGL_lose_context")?.loseContext(),!0)}catch{return!1}}const CT="http://www.w3.org/2000/svg";let AT=0;function Vo(e){return Math.round(e*10)/10}function IT(e,t,n={}){const r=e.createElementNS(CT,t);for(const[i,o]of Object.entries(n))r.setAttribute(i,String(o));return r}function kp(e,t,n,r){const i=`cia-graph-svg-${++AT}`,o=e.ownerDocument,s=(U,H)=>IT(o,U,H),a=(U,H,K)=>{const de=s("text",{x:0,y:H,"text-anchor":"middle",class:K,"pointer-events":"none"});return de.textContent=U,de},{width:u,height:c}=t.dimensions(),l=s("svg",{class:"cia-graph-svg",viewBox:`0 0 ${u} ${c}`,role:"group",tabindex:0,"aria-label":r.label??"Money-flow graph. Drag the background or use arrow keys to pan, plus and minus to zoom. Select an address or a link for details."}),d=s("defs"),f=s("pattern",{id:`${i}-dots`,width:24,height:24,patternUnits:"userSpaceOnUse"});f.append(s("circle",{class:"cia-graph-dot",cx:1,cy:1,r:1})),d.append(f);const h=s("rect",{class:"cia-graph-backdrop",width:"100%",height:"100%","data-canvas":""}),p=s("rect",{class:"cia-graph-dots",width:"100%",height:"100%",fill:`url(#${i}-dots)`,"data-canvas":""}),m=s("g",{"data-viewport":""}),y=s("g",{"data-edges":"",class:"cia-graph-edges"}),b=s("g",{"data-nodes":"",class:"cia-graph-nodes"});m.append(y,b),l.append(d,h,p,m),e.append(l);const g=new Map,w=new Map,v=new Map;let _=null;function k(){if(_)return _;const U=t.model(),H=t.positions(),K=new Map;_=K;const de=U.nodes.length>_C,te=new Map(U.nodes.map(z=>[z.address,z])),I=de?[]:fC(U,H,t.notes());for(const z of U.edges){const G=te.get(z.from),fe=te.get(z.to),ie=G&&H[G.id],Y=fe&&H[fe.id];if(!G||!fe||!ie||!Y){K.set(z.id,null);continue}if(de){K.set(z.id,uc(ie,Y,Hn(G,U.checked_address),Hn(fe,U.checked_address)));continue}const oe=I.filter(he=>he.id!==G.id&&he.id!==fe.id);K.set(z.id,kC(ie,Y,Hn(G,U.checked_address),Hn(fe,U.checked_address),oe))}return K}function x(U){let H=g.get(U);if(H)return H;H=`${i}-arrow-${g.size}`;const K=s("marker",{id:H,viewBox:"0 0 10 10",refX:9,refY:5,markerWidth:6,markerHeight:6,orient:"auto-start-reverse",markerUnits:"strokeWidth"}),de=s("path",{d:"M0 0L10 5L0 10Z",class:"cia-graph-arrowhead"});return de.style.fill=U,K.append(de),d.append(K),g.set(U,H),H}function N(){return[...t.model().nodes??[]].sort((U,H)=>String(U.id).localeCompare(String(H.id)))}function M(){_=null;const U=t.model();y.replaceChildren(),b.replaceChildren(),w.clear(),v.clear();const H=new Map(U.nodes.map(K=>[K.address,K]));for(const K of U.edges){const de=H.get(K.from);if(!de||!H.get(K.to))continue;const te=t.colorOf(de),I=s("g",{class:"cia-graph-edge graph-edge",tabindex:0,role:"button","aria-label":hc(K,t.now())});I.dataset.edgeId=K.id,I.style.setProperty("--edge-tone",te);const z=xC(),G=s("path",{class:"cia-graph-edge-hit","stroke-width":z.hit.width,"pointer-events":"stroke"}),fe=s("path",{class:"cia-graph-edge-line","stroke-width":z.line.width,"marker-end":`url(#${x(te)})`,"pointer-events":"none"});I.append(G,fe);const ie=U.edges.length<=Xw?Qw(K):"";let Y;if(ie){fe.id=`${i}-edge-${v.size}`;const oe=s("textPath",{href:`#${fe.id}`,startOffset:"50%","text-anchor":"middle"});oe.textContent=ie;const he=s("text",{class:"cia-graph-edge-caption",dy:"-4","pointer-events":"none","aria-hidden":"true"});he.append(oe),I.append(he),Y=he}I.addEventListener("keydown",oe=>{Ip(oe.key)&&(oe.preventDefault(),n.selectEdge(K.id,"keyboard"))}),I.addEventListener("pointerenter",oe=>n.showTooltip(oe,hc(K,t.now()))),I.addEventListener("pointerleave",()=>n.hideTooltip()),y.append(I),v.set(K.id,{group:I,hit:G,line:fe,...Y?{caption:Y}:{}})}for(const K of N())b.append(F(K));ee(),me()}function F(U){const H=t.model(),K=U.address===H.checked_address,de=t.notes().get(U.id),te=Rn(U,H.checked_address,de),I=te.radius,z=s("g",{class:"cia-graph-node graph-node",tabindex:0,role:"button","aria-label":fc(U),"aria-pressed":"false"});z.dataset.nodeId=U.id,K&&(z.dataset.checked=""),z.style.setProperty("--node-tone",t.colorOf(U)),K&&z.append(s("circle",{class:"cia-graph-node-ring",r:I+6})),z.append(s("circle",{class:"cia-graph-node-body",r:I})),z.append(s("circle",{class:"cia-graph-node-dot",r:te.dot}));for(const G of te.texts)z.append(a(G.text,G.y,`cia-graph-node-${G.kind}`));de&&(z.dataset.state="refused");for(const G of t.flags().get(U.id)??[])z.setAttribute(`data-flag-${G}`,"");return z.addEventListener("keydown",G=>{Ip(G.key)&&(G.preventDefault(),n.selectNode(U.id,"keyboard"))}),z.addEventListener("pointerenter",G=>n.showTooltip(G,fc(U))),z.addEventListener("pointerleave",()=>n.hideTooltip()),w.set(U.id,z),z}function B(){const U=t.transform();m.setAttribute("transform",`translate(${U.x} ${U.y}) scale(${U.scale})`)}function ee(){B();const U=t.positions(),{width:H,height:K}=t.dimensions();for(const[te,I]of w){const z=U[te]??{x:H/2,y:K/2};I.setAttribute("transform",`translate(${Vo(z.x)} ${Vo(z.y)})`)}const de=k();for(const te of t.model().edges){const I=v.get(te.id);if(!I)continue;const z=de.get(te.id)??null;I.group.style.display=z?"":"none",z&&(I.hit.setAttribute("d",z.d),I.line.setAttribute("d",z.d),I.caption&&(I.caption.style.display=z.kind==="forward"||z.kind==="vertical"||z.kind==="straight"?"":"none"))}}function ce(U){const H=t.model(),K=t.positions(),de=K[U],te=w.get(U);if(!de||!te)return;te.setAttribute("transform",`translate(${Vo(de.x)} ${Vo(de.y)})`);const I=H.nodes.find(G=>G.id===U);if(!I)return;const z=new Map(H.nodes.map(G=>[G.address,G]));for(const G of H.edges){if(G.from!==I.address&&G.to!==I.address)continue;const fe=v.get(G.id),ie=z.get(G.from),Y=z.get(G.to),oe=ie&&K[ie.id],he=Y&&K[Y.id];if(!fe||!ie||!Y||!oe||!he)continue;const Ae=uc(oe,he,Hn(ie,H.checked_address),Hn(Y,H.checked_address));fe.group.style.display=Ae?"":"none",Ae&&(fe.hit.setAttribute("d",Ae.d),fe.line.setAttribute("d",Ae.d))}}function me(){const U=t.model(),H=t.selected(),K=t.highlighted(),de=H?.kind==="node"?U.nodes.find(te=>te.id===H.id)?.address??null:null;for(const te of U.edges){const I=v.get(te.id);if(!I)continue;const z=H?.kind==="edge"&&H.id===te.id,G=H?.kind==="edge"?z?Jt.related:Jt.faded:Ww(te,de),fe=G===Jt.faded;I.group.setAttribute("opacity",fe?String(G):"1"),I.line.setAttribute("stroke-opacity",fe?"1":String(G)),I.group.dataset.opacity=String(G),I.group.dataset.state=G===Jt.rest?"rest":G===Jt.related?"related":"faded",I.group.setAttribute("aria-pressed",String(z))}for(const[te,I]of w){const z=H?.kind==="node"&&H.id===te;I.classList.toggle("is-selected",z),I.classList.toggle("is-focused",K===te),I.setAttribute("aria-pressed",String(z))}}function $e(){let U=null;for(const H of k().values())H?.bounds&&(U=U??{...H.bounds},U.x1=Math.min(U.x1,H.bounds.x1),U.y1=Math.min(U.y1,H.bounds.y1),U.x2=Math.max(U.x2,H.bounds.x2),U.y2=Math.max(U.y2,H.bounds.y2));return U}return{kind:"svg",surface:l,build:M,geometry(){_=null,ee()},moveNode:ce,endMove(){_=null,ee()},camera:B,selection:me,flag(U,H,K){w.get(U)?.toggleAttribute(`data-flag-${H}`,K)},theme(){for(const U of t.model().nodes)w.get(U.id)?.style.setProperty("--node-tone",t.colorOf(U))},resize(U,H){l.setAttribute("viewBox",`0 0 ${U} ${H}`)},pick:()=>null,linkBounds:$e,destroy(){l.remove()}}}const NT=.1,RT=2.5,LT=5,zT="chain-insights.flows.v1",nh="cia-graph-model",PT=300,Jt={rest:.6,related:.95,faded:.25},Sp={checked:24,other:19},Si=16,DT=[["Sanctioned","Sanctioned"],["Scam","Scam"],["Poisoned","Poisoned"],["OnMoneyTrail","On money trail"],["Mixer","Mixer"],["Bridge","Bridge"],["Exchange","Exchange"],["Victim","Victim"],["Targeted","Targeted"],["SelfTrader","Self-trading contract"]],qr=["exchange","scam","sanctioned","victim","pool","self_trader","other"],OT={exchange:"infrastructure",scam:"danger",sanctioned:"danger",victim:"target",pool:"trail",self_trader:"infrastructure",other:"neutral"},jw={exchange:"Exchange",scam:"Scam",sanctioned:"Sanctioned",victim:"Victim",pool:"Pool",self_trader:"Self-trading contract",other:""};function rh(e){return!!e&&e.schema===zT}function MT(e){return!!e&&e.kind===nh}function Je(e){return String(e??"").trim().toLowerCase()}function FT(e){const t=Je(e);return qr.includes(t)?t:"other"}function vn(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function sc(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function UT(e){const t=String(e??"").toUpperCase();return t==="IN"||t==="OUT"||t==="MIXED"||t==="CHECKED"?t:"OUT"}function Mt(e){return MT(e)?e:rh(e)?GT(e):ZT(e)}function GT(e){const t=Je(e.center),n=new Map;for(const a of e.nodes??[]){const u=Je(a?.address);u&&!n.has(u)&&n.set(u,a)}const r=[],i=new Set;for(const a of e.edges??[]){const u=Je(a?.from),c=Je(a?.to);if(!n.has(u)||!n.has(c)||u===c)continue;const l=`${u}->${c}`;i.has(l)||(i.add(l),r.push({id:l,from:u,to:c,source:"flows",amount_usd_sum:vn(a.usd),tx_count:vn(a.tx_count),first_seen_timestamp:vn(a.first_seen_ms),last_seen_timestamp:vn(a.last_seen_ms),...typeof a.link_kind=="string"&&a.link_kind?{link_kind:a.link_kind}:{}}))}const o=jT(t,[...n.keys()],r),s=[...n.entries()].map(([a,u])=>{const c=o.get(a)??{direction:"OUT",hop:2};return{id:a,address:a,direction:a===t?"CHECKED":c.direction,hop:a===t?0:c.hop,labels:sc(u.labels),taxonomy:[],role:FT(u.role),total_in_usd:vn(u.total_in_usd),total_out_usd:vn(u.total_out_usd),degree_in:vn(u.degree_in),degree_out:vn(u.degree_out)}});return{kind:nh,checked_address:t,network:e.network??null,nodes:s,edges:r,truncated:!!e.truncated,cursor:e.cursor??null}}function jT(e,t,n){const r=new Map,i=new Map,o=new Map,s=(d,f,h)=>d.set(f,[...d.get(f)??[],h]);for(const d of n)s(r,d.from,d.to),s(i,d.to,d.from),s(o,d.from,d.to),s(o,d.to,d.from);const a=d=>{const f=new Map([[e,0]]);for(let h=[e];h.length;){const p=[];for(const m of h)for(const y of d.get(m)??[])f.has(y)||(f.set(y,(f.get(m)??0)+1),p.push(y));h=p}return f},u=a(r),c=a(i),l=new Map;for(const d of t){if(d===e)continue;const f=u.get(d),h=c.get(d);if(f==null&&h==null)continue;const p=f!=null&&h!=null?f<h?"OUT":h<f?"IN":"MIXED":f!=null?"OUT":"IN";l.set(d,{direction:p,hop:Math.min(2,Math.min(f??1/0,h??1/0))})}for(let d=!0;d;){d=!1;for(const f of t){if(f===e||l.has(f))continue;const h=(o.get(f)??[]).find(m=>m!==e&&l.has(m));if(h==null)continue;const p=l.get(h);l.set(f,{direction:p.direction==="MIXED"?"OUT":p.direction,hop:2}),d=!0}}return l}function ZT(e){const t=(e?.nodes??[]).map(r=>({...r,id:String(r.id??r.address),address:r.address,hop:Number(r.hop)||0,direction:r.address===e.checked_address?"CHECKED":UT(r.direction),labels:sc(r.labels),taxonomy:sc(r.taxonomy),role:null})),n=(e?.edges??[]).map(r=>({...r,id:String(r.id??`${r.from}->${r.to}`),amount_usd_sum:r.amount_usd_sum??null,tx_count:r.tx_count??null,first_seen_timestamp:r.first_seen_timestamp??null,last_seen_timestamp:r.last_seen_timestamp??null,source:"risk"}));return{kind:nh,checked_address:e?.checked_address??"",network:null,nodes:t,edges:n,truncated:!1,cursor:null}}function BT(e,t,n){const r=Mt(t),i=kn(e,n??r.checked_address),o=e.nodes.find(d=>d.id===i),s=new Map(e.nodes.map(d=>[Je(d.address),d])),a=[];for(const d of r.nodes){if(s.has(Je(d.address)))continue;const f=!o||o.direction==="CHECKED"?d.direction==="CHECKED"?"OUT":d.direction:o.direction,h={...d,id:d.id,direction:f,hop:Math.min(2,(o?.hop??0)+1)};a.push(h),s.set(Je(d.address),h)}const u=new Set(e.edges.map(d=>d.id)),c=new Set(e.edges.map(d=>`${Je(d.from)}->${Je(d.to)}`)),l=[...e.edges];for(const d of r.edges){const f=`${Je(d.from)}->${Je(d.to)}`;if(u.has(d.id)||c.has(f)||!s.has(Je(d.from))||!s.has(Je(d.to)))continue;const h=s.get(Je(d.from)).address,p=s.get(Je(d.to)).address;l.push({...d,from:h,to:p}),u.add(d.id),c.add(f)}return{model:{...e,nodes:[...e.nodes,...a],edges:l,truncated:e.truncated||r.truncated},added:a.map(d=>d.id)}}function kn(e,t){if(t==null)return null;const n=Je(t);return e.nodes.find(i=>i.id===t||Je(i.address)===n)?.id??null}function xi(e){return typeof e!="string"||e.length<=12?e:`${e.slice(0,6)}…${e.slice(-4)}`}function ih(e){return String(e??"").trim().replace(/\s+/g," ")}function ks(e){return ih(e).replaceAll(" ","").toLowerCase()}function In(e){const t=[...e.taxonomy??[],...e.labels??[]],n=new Set,r=[];for(const i of t){const o=ih(i),s=o.toLowerCase();!o||s==="address"||n.has(s)||(n.add(s),r.push(o))}return r}function qo(e,t){const n=new Set(In(e).map(ks));return t.some(r=>n.has(ks(r)))}function HT(e){if(e.role&&qr.includes(e.role))return OT[e.role];if(qo(e,["Sanctioned","Scam","Poisoned"]))return"danger";if(qo(e,["Victim","Targeted"]))return"target";if(qo(e,["OnMoneyTrail","Mixer"]))return"trail";if(qo(e,["Exchange","Bridge","token contract"]))return"infrastructure";if(e.risk_score!=null){const t=String(e.risk_level).toLowerCase();if(t==="critical"||t==="high"||t==="medium"||t==="low")return t}return"neutral"}function Ke(e){return`var(--cia-graph-${e})`}const VT={semantic:{danger:{stroke:Ke("danger"),fill:Ke("node")},target:{stroke:Ke("target"),fill:Ke("node")},trail:{stroke:Ke("trail"),fill:Ke("node")},infrastructure:{stroke:Ke("infrastructure"),fill:Ke("node")},neutral:{stroke:Ke("neutral"),fill:Ke("node")}},risk:{CRITICAL:{stroke:Ke("critical"),fill:Ke("node")},HIGH:{stroke:Ke("high"),fill:Ke("node")},MEDIUM:{stroke:Ke("medium"),fill:Ke("node")},LOW:{stroke:Ke("low"),fill:Ke("node")}}};function qT(e,t=VT){const n=HT(e);return n==="critical"||n==="high"||n==="medium"||n==="low"?t.risk[n.toUpperCase()]??t.semantic.neutral:t.semantic[n]}function WT(e){return e.role&&qr.includes(e.role)?Ke(`role-${e.role}`):qT(e).stroke}function Do(e){if(e.role&&e.role!=="other"&&qr.includes(e.role))return jw[e.role];const t=In(e);for(const[r,i]of DT)if(t.some(o=>ks(o)===ks(r)))return i;return(Array.isArray(e.labels)?e.labels.map(ih).filter(Boolean).sort((r,i)=>r.localeCompare(i)):[])[0]??""}function ac(e){return Math.min(RT,Math.max(NT,e))}function oh(e){return[...e.nodes??[]].sort((t,n)=>String(t.id).localeCompare(String(n.id)))}function Zw(e,t=oh(e)){return t.find(n=>n.address===e.checked_address)??t[0]}function xp(e,t){return e.address===t?43:e.hop>=2?25:30}function Hn(e,t){return e.address===t?Sp.checked:Sp.other}function Rn(e,t,n){const r=e.address===t,i=Hn(e,t),o=Do(e),s=[];return o&&s.push({kind:"role",text:UC(o),y:i+17}),s.push({kind:"address",text:xi(e.address),y:i+(o?33:17)}),n&&s.push({kind:"note",text:n,y:i+(o?48:32)}),{radius:i,ring:r,dot:r?8:5,texts:s}}const KT={role:{size:13,advance:.68},address:{size:11,advance:.62},note:{size:11,advance:.6}},vu=2;function sh(e){const t=e.radius+(e.ring?7:2),n=[{kind:"circle",box:{x1:-t,y1:-t,x2:t,y2:t}}];for(const r of e.texts){const i=KT[r.kind],o=[...r.text].length*i.size*i.advance/2+vu;n.push({kind:r.kind,box:{x1:-o,y1:r.y-i.size*.8-vu,x2:o,y2:r.y+i.size*.25+vu}})}return n}function Bw(e){return e.length?{x1:Math.min(...e.map(t=>t.x1)),y1:Math.min(...e.map(t=>t.y1)),x2:Math.max(...e.map(t=>t.x2)),y2:Math.max(...e.map(t=>t.y2))}:null}function Ss(e){return Bw(sh(e).map(t=>t.box))}const Ei=(e,t)=>(e instanceof Map?e.get(t):e?.[t])??null;function JT(e,t,n){const r=Mt(e),i=[];for(const o of r.nodes){const s=t[o.id];if(s)for(const{kind:a,box:u}of sh(Rn(o,r.checked_address,Ei(n,o.id))))i.push({id:o.id,kind:a,x1:s.x+u.x1,y1:s.y+u.y1,x2:s.x+u.x2,y2:s.y+u.y2})}return i}function YT(e,t,n){return Bw(JT(e,t,n))}function XT(e,t){return e.x1<t.x2&&t.x1<e.x2&&e.y1<t.y2&&t.y1<e.y2}function QT(e){let t=0;for(const n of String(e))t=(t<<5)-t+n.charCodeAt(0)|0;return Math.abs(t)}function eC(e,t,n){const r=Mt(e),i={x:t/2,y:n/2},o={},s=oh(r),a=Zw(r,s);if(!a)return o;o[a.id]=i;const u=new Map;for(const l of s){if(l.id===a.id)continue;let d=l.direction==="IN"?-1:1;l.direction==="MIXED"&&(d=QT(l.id)%2?-1:1);const f=Math.min(2,Math.max(1,Number(l.hop)||1)),h=`${d}:${f}`;u.has(h)||u.set(h,[]),u.get(h).push(l)}const c=tC(r);for(const[l,d]of u){const[f,h]=l.split(":"),p=Number(f),m=Number(h),y=i.x+p*(m===1?t*.23:t*.43);d.sort((b,g)=>(c.get(g.address)??0)-(c.get(b.address)??0)||String(b.id).localeCompare(String(g.id))),Object.assign(o,nC(d,y,i.y,r.checked_address))}return o}function tC(e){const t=new Map;for(const n of e.edges){const r=Math.max(n.last_seen_timestamp??0,n.first_seen_timestamp??0);for(const i of[n.from,n.to])r>(t.get(i)??0)&&t.set(i,r)}return t}function nC(e,t,n,r,i=24){const o=e.map((u,c)=>({node:u,x:t,y:n+(c-(e.length-1)/2)*64})),s=u=>Ss(Rn(u,r)),a=(u,c)=>Math.max(xp(u,r)+xp(c,r)+20,s(u).y2-s(c).y1+2);for(let u=0;u<i;u++){for(let d=1;d<o.length;d++){const f=o[d-1],h=o[d];!f||!h||(h.y=Math.max(h.y,f.y+a(f.node,h.node)))}for(let d=o.length-2;d>=0;d--){const f=o[d],h=o[d+1];!f||!h||(f.y=Math.min(f.y,h.y-a(f.node,h.node)))}const c=o[0],l=o[o.length-1];if(c&&l){const d=(c.y+l.y)/2,f=n-d;for(const h of o)h.y+=f}}return Object.fromEntries(o.map(u=>[u.node.id,{x:u.x,y:u.y}]))}function rC(e,t,n){const r=Mt(e),i={x:t/2,y:n/2},o={},s=oh(r),a=Zw(r,s);if(!a)return o;o[a.id]=i;const u=s.filter(c=>c.id!==a.id);return u.forEach((c,l)=>{const d=-Math.PI/2+l*Math.PI*2/Math.max(1,u.length)+(kr(c.id)-.5)*.3,f=(c.hop>=2?Math.min(t,n)*.39:Math.min(t,n)*.27)*(.85+kr(c.id+"/r")*.3);o[c.id]={x:i.x+Math.cos(d)*f,y:i.y+Math.sin(d)*f}}),o}function kr(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0)%10007/10007}const Sn={link:150,repel:50,reach:300,spring:.06,centre:.02};function iC(e,t,n,r,i){const o=e.nodes.filter(l=>t[l.id]),s=new Map(o.map(l=>[l.id,{x:0,y:0}])),a=o.filter(l=>n.has(l.id)),u=new Map(a.map((l,d)=>[l.id,d]));for(let l=0;l<a.length;l++){const d=a[l],f=t[d.id],h=s.get(d.id);for(const p of o){if(p===d)continue;const m=u.get(p.id);if(m!==void 0&&m<l)continue;const y=t[p.id];let b=y.x-f.x,g=y.y-f.y;!b&&!g&&(b=kr(d.id+p.id)-.5,g=kr(p.id+d.id)-.5);const w=Math.max(8,Math.hypot(b,g));if(w>=Sn.reach)continue;const v=Sn.repel*Sn.repel/w*(1-w/Sn.reach),_=b/w*v,k=g/w*v;if(h.x-=_,h.y-=k,m!==void 0){const x=s.get(p.id);x.x+=_,x.y+=k}}}const c=new Map(o.map(l=>[l.address,l]));for(const l of e.edges){const d=c.get(l.from),f=c.get(l.to);if(!d||!f||d===f)continue;const h=t[d.id],p=t[f.id],m=p.x-h.x,y=p.y-h.y,b=Math.max(1,Math.hypot(m,y)),g=(b-Sn.link)*Sn.spring,w=m/b*g,v=y/b*g,_=s.get(d.id);_.x+=w,_.y+=v;const k=s.get(f.id);k.x-=w,k.y-=v}for(const l of o){if(!n.has(l.id))continue;const d=t[l.id],f=s.get(l.id),h=Sn.centre/Math.max(1,l.hop);f.x+=(r.x-d.x)*h,f.y+=(r.y-d.y)*h;const p=Math.hypot(f.x,f.y),m=30*i,y=p>m?m/p:1;d.x+=f.x*y*Math.min(1,i*4),d.y+=f.y*y*Math.min(1,i*4)}}function Hw(e,t,n,r,i){const o=e.nodes.filter(c=>t[c.id]).length,s=Math.max(1,n.size*o);i=Math.min(i,Math.max(60,Math.floor(4e7/s)));const a=i>1?Math.pow(.01,1/(i-1)):1;let u=1;for(let c=0;c<i;c++)iC(e,t,n,r,u),u*=a;return t}function oC(e,t,n,r=PT){const i=Mt(e),o=rC(i,t,n),s=i.nodes.find(u=>u.address===i.checked_address),a=new Set(i.nodes.filter(u=>u!==s).map(u=>u.id));return Hw(i,o,a,{x:t/2,y:n/2},r),s&&(o[s.id]={x:t/2,y:n/2}),Vw(i,o,a)}function Wo(e,t,n,r){return t==="tree"?eC(e,n,r):oC(e,n,r)}function Vw(e,t,n,r,i=22,o=60){const s=Mt(e),a=s.nodes.filter(d=>t[d.id]),u=new Map(a.map(d=>[d.id,Ss(Rn(d,s.checked_address,Ei(r,d.id)))])),c=a.filter(d=>n.has(d.id)),l=new Map(c.map((d,f)=>[d.id,f]));for(let d=0;d<o;d++){let f=!1;for(let h=0;h<c.length;h++)for(const p of a){const m=c[h];if(p===m)continue;const y=l.get(p.id);if(y!==void 0&&y<h)continue;const b=t[m.id],g=t[p.id],w=u.get(m.id),v=u.get(p.id),_=Math.min(b.x+w.x2,g.x+v.x2)-Math.max(b.x+w.x1,g.x+v.x1)+i,k=Math.min(b.y+w.y2,g.y+v.y2)-Math.max(b.y+w.y1,g.y+v.y1)+i;if(_<=0||k<=0)continue;f=!0;const x=_<k,N=x?g.x>=b.x?1:-1:g.y>=b.y?1:-1,M=(x?_:k)/2+.5,B=n.has(m.id)&&n.has(p.id)?M:M*2;n.has(m.id)&&(x?b.x-=N*B:b.y-=N*B),n.has(p.id)&&(x?g.x+=N*B:g.y+=N*B)}if(!f)break}return t}const sC=300;function aC(e,t,n,r,i={}){const o=i.steps??sC,s=Mt(e),a=t[n],u={...t};if(!a)return u;const c=new Map(s.nodes.map(_=>[_.id,_])),l=[...r].sort().filter(_=>!u[_]&&c.has(_));if(!l.length)return u;const d=c.get(n)?.address,f=new Set(s.edges.filter(_=>_.to===d).map(_=>_.from)),h=new Set(s.edges.filter(_=>_.from===d).map(_=>_.to)),p=_=>{const k=c.get(_).address;return f.has(k)&&!h.has(k)},m=l.filter(p),y=l.filter(_=>!p(_)),b=(_,k)=>{_.forEach((N,M)=>{const F=Math.floor(M/10),B=Math.min(10,_.length-F*10),ee=M-F*10,ce=Math.PI*.8,me=(B===1?0:-ce/2+ee*ce/(B-1))+(kr(N)-.5)*.2,$e=(Sn.link+F*110)*(.9+kr(N+"/r")*.2);u[N]={x:a.x+k*Math.cos(me)*$e,y:a.y+Math.sin(me)*$e}})};b(m,-1),b(y,1);const g=s.nodes.filter(_=>t[_.id]&&!l.includes(_.id)).map(_=>({point:t[_.id],box:Ss(Rn(_,s.checked_address,Ei(i.notes,_.id)))})),w=(_,k)=>{if(!_.length)return;const x=_.map(N=>({id:N,box:Ss(Rn(c.get(N),s.checked_address,Ei(i.notes,N)))}));for(let N=0;N<12;N++){const M={x1:1/0,y1:1/0,x2:-1/0,y2:-1/0};for(const{id:B,box:ee}of x){const ce=u[B];M.x1=Math.min(M.x1,ce.x+ee.x1),M.x2=Math.max(M.x2,ce.x+ee.x2),M.y1=Math.min(M.y1,ce.y+ee.y1),M.y2=Math.max(M.y2,ce.y+ee.y2)}let F=0;for(const B of g){if(Math.min(M.y2,B.point.y+B.box.y2)-Math.max(M.y1,B.point.y+B.box.y1)+12<=0)continue;const ce=k<0?M.x2+24-(B.point.x+B.box.x1):B.point.x+B.box.x2+24-M.x1;ce>F&&(F=ce)}if(F<=0)break;for(const B of _)u[B].x+=k*F}},v=new Set(l);return Hw(s,u,v,{x:a.x,y:a.y},o),Vw(s,u,v,i.notes),w(m,-1),w(y,1),u}function uC(e,t,n,r=Si){const i=Math.max(1,e.x2-e.x1),o=Math.max(1,e.y2-e.y1),s=ac(Math.min((t-r*2)/i,(n-r*2)/o));return{x:t/2-(e.x1+e.x2)/2*s,y:n/2-(e.y1+e.y2)/2*s,scale:s}}function Ep(e,t,n,r=Si){return Math.min((t-r*2)/Math.max(1,e.x2-e.x1),(n-r*2)/Math.max(1,e.y2-e.y1))}function cC(e,t,n,r,i=4){const o=t.x-e.x,s=t.y-e.y,a=Math.hypot(o,s),u=n+i,c=r+i;if(!Number.isFinite(a)||a<=0||u+c>=a)return null;const l=o/a,d=s/a;return{x1:e.x+l*u,y1:e.y+d*u,x2:t.x-l*c,y2:t.y-d*c}}function $n(e){return Math.round(e*100)/100}function bu(e,t,n,r,i){const o=s=>`${$n(s.x)},${$n(s.y)}`;return{kind:e,start:t,end:i,controls:[n,r],d:`M${o(t)} C${o(n)} ${o(r)} ${o(i)}`}}function uc(e,t,n,r,i=4){const o=t.x-e.x,s=t.y-e.y,a=Math.hypot(o,s),u=n+r+i*2;if(!Number.isFinite(a)||a<=u)return null;if(o>=u){const f={x:e.x+n+i,y:e.y},h={x:t.x-r-i,y:t.y},p=h.x-f.x,m=Math.max(p*.45,Math.min(65,p));return bu("forward",f,{x:f.x+m,y:f.y},{x:h.x-m,y:h.y},h)}if(o<=-u){const f={x:e.x,y:e.y-n-i},h={x:t.x,y:t.y-r-i},p=Math.max(100,Math.abs(o)*.2);return bu("backward",f,{x:f.x+85,y:f.y-p},{x:h.x+85,y:h.y-p},h)}if(Math.abs(s)>u){const f=s>0?1:-1,h={x:e.x,y:e.y+f*(n+i)},p={x:t.x,y:t.y-f*(r+i)},m=Math.abs(p.y-h.y),y=Math.max(m*.45,Math.min(40,m));return bu("vertical",h,{x:h.x,y:h.y+f*y},{x:p.x,y:p.y-f*y},p)}const c=cC(e,t,n,r,i),l={x:c.x1,y:c.y1},d={x:c.x2,y:c.y2};return{kind:"straight",start:l,end:d,controls:null,d:`M${$n(l.x)},${$n(l.y)} L${$n(d.x)},${$n(d.y)}`}}const lC=6,wu=lC+3,en=14,$p=10,dC=3,Tp=6;function fC(e,t,n){const r=Mt(e),i=[];for(const o of r.nodes){const s=t[o.id];if(s)for(const{kind:a,box:u}of sh(Rn(o,r.checked_address,Ei(n,o.id))))a==="circle"?i.push({id:o.id,kind:"circle",x:s.x,y:s.y,r:u.x2}):i.push({id:o.id,kind:"box",x1:s.x+u.x1,y1:s.y+u.y1,x2:s.x+u.x2,y2:s.y+u.y2})}return i}function hC(e,t){if(t.kind==="circle")return Math.hypot(e.x-t.x,e.y-t.y)-t.r;const n=Math.max(t.x1-e.x,0,e.x-t.x2),r=Math.max(t.y1-e.y,0,e.y-t.y2);return n||r?Math.hypot(n,r):-Math.min(e.x-t.x1,t.x2-e.x,e.y-t.y1,t.y2-e.y)}function pC(e,t){return e.kind==="circle"?{x1:e.x-e.r-t,y1:e.y-e.r-t,x2:e.x+e.r+t,y2:e.y+e.r+t}:{x1:e.x1-t,y1:e.y1-t,x2:e.x2+t,y2:e.y2+t}}function mC(e,t){const n=1-t;return{x:n*n*n*e[0].x+3*n*n*t*e[1].x+3*n*t*t*e[2].x+t*t*t*e[3].x,y:n*n*n*e[0].y+3*n*n*t*e[1].y+3*n*t*t*e[2].y+t*t*t*e[3].y}}function gC(e){return e.controls?[{kind:"C",points:[e.start,e.controls[0],e.controls[1],e.end]}]:[{kind:"L",points:[e.start,e.end]}]}function qw(e){let t=0,n;for(const r of e)n&&(t+=Math.hypot(r.x-n.x,r.y-n.y)),n=r;return t}function yC(e,t){const n=[];for(const r of e){const i=Math.max(1,Math.ceil(qw(r.points)/t));for(let o=0;o<=i;o++){const s=o/i;if(r.kind==="L"){const[a,u]=r.points;n.push({x:a.x+(u.x-a.x)*s,y:a.y+(u.y-a.y)*s})}else n.push(mC(r.points,s))}}return n}function Cp(e,t,n,r){const i=e.flatMap(a=>a.points),o={x1:Math.min(...i.map(a=>a.x)),y1:Math.min(...i.map(a=>a.y)),x2:Math.max(...i.map(a=>a.x)),y2:Math.max(...i.map(a=>a.y))},s=[];if(n.forEach((a,u)=>{a.x1<=o.x2&&o.x1<=a.x2&&a.y1<=o.y2&&o.y1<=a.y2&&s.push(u)}),!s.length)return!0;for(const a of yC(e,dC))for(const u of s){const c=n[u],l=t[u];if(!(!c||!l)&&!(a.x<c.x1||a.x>c.x2||a.y<c.y1||a.y>c.y2)&&hC(a,l)<r)return!1}return!0}function vC(e){const t=e[0],n=e[e.length-1];if(!t||!n)return[];const r=[];for(let s=1;s<e.length;s++)r.push(qw(e.slice(s-1,s+1)));const i=[];let o=t;for(let s=1;s<e.length-1;s++){const a=e[s-1],u=e[s],c=e[s+1],l=r[s-1],d=r[s];if(!a||!u||!c||l===void 0||d===void 0)continue;const f=l/(s-1===0?1:2),h=d/(s===r.length-1?1:2),p=Math.min(en,f,h),m={x:(u.x-a.x)/l,y:(u.y-a.y)/l},y={x:(c.x-u.x)/d,y:(c.y-u.y)/d},b={x:u.x-m.x*p,y:u.y-m.y*p},g={x:u.x+y.x*p,y:u.y+y.y*p};i.push({kind:"L",points:[o,b]}),i.push({kind:"C",points:[b,{x:b.x+m.x*p*.55,y:b.y+m.y*p*.55},{x:g.x-y.x*p*.55,y:g.y-y.y*p*.55},g]}),o=g}return i.push({kind:"L",points:[o,n]}),i.filter(s=>s.kind==="C"||Math.hypot(s.points[1].x-s.points[0].x,s.points[1].y-s.points[0].y)>.01)}function bC(e){const t=i=>`${$n(i.x)},${$n(i.y)}`,n=e[0];if(!n)return"";let r=`M${t(n.points[0])}`;for(const i of e)r+=i.kind==="L"?` L${t(i.points[1])}`:` C${t(i.points[1])} ${t(i.points[2])} ${t(i.points[3])}`;return r}function Ap(e,t,n,r,i){const o=Math.min(e.y,n)-en,s=Math.max(e.y,n)+en,a=d=>(d-e.x)*t;let u=1/0;for(const d of i)if(d.y1<e.y&&e.y<d.y2){const f=t===1?d.x1:d.x2,h=t===1?d.x2:d.x1;a(h)>0&&(u=Math.min(u,Math.max(0,a(f))))}const c=i.filter(d=>d.y1<s&&o<d.y2).map(d=>[a(t===1?d.x1:d.x2),a(t===1?d.x2:d.x1)]).filter(([,d])=>d>r).sort((d,f)=>d[0]-f[0]);let l=r;for(const[d,f]of[...c,[1/0,1/0]]){if(d>l+1){const h=Math.min(d,u);if(h<=l+1)return null;const p=Number.isFinite(h)&&h-l<80?(l+h)/2:l+40;return e.x+t*p}if(l=Math.max(l,f),l>=u)return null}return null}function wC(e){const t=[];for(const n of e){const r=t[t.length-1];r&&Math.abs(r.x-n.x)<.01&&Math.abs(r.y-n.y)<.01||t.push(n)}return t.filter((n,r)=>{if(r===0||r===t.length-1)return!0;const i=t[r-1],o=t[r+1];return!i||!o?!0:!(Math.abs(i.x-n.x)<.01&&Math.abs(o.x-n.x)<.01||Math.abs(i.y-n.y)<.01&&Math.abs(o.y-n.y)<.01)})}const _C=120;function kC(e,t,n,r,i,o=4){const s=uc(e,t,n,r,o);if(!s||!i.length)return s;const a=i.map(f=>pC(f,wu));if(Cp(gC(s),i,a,wu))return s;const u=new Set([e.y,t.y]),c=f=>Math.abs(f-e.y)<Tp?e.y:Math.abs(f-t.y)<Tp?t.y:f;for(const f of a)u.add(c(Math.round(f.y1)-en-1)),u.add(c(Math.round(f.y2)+en+1));const l=t.x>=e.x?1:-1,d=[[l,l],[l,-l],[-l,l],[-l,-l]];for(const[f,h]of d){const p={x:e.x+f*(n+o),y:e.y},m={x:t.x-h*(r+o),y:t.y},y=[];for(const b of u){const g=Math.abs(b-p.y)<.01?p.x:Ap(p,f,b,en,a);if(g===null)continue;const w=Math.abs(b-m.y)<.01?m.x:Ap(m,-h,b,en+$p,a);if(w===null||Math.abs(b-m.y)<.01&&(m.x-g)*h<en+$p||Math.abs(b-p.y)<.01&&(w-p.x)*f<en)continue;const v=wC([p,{x:g,y:p.y},{x:g,y:b},{x:w,y:b},{x:w,y:m.y},m]);if(!SC(v,a))continue;let _=(v.length-2)*en,k;for(const x of v)k&&(_+=Math.abs(x.x-k.x)+Math.abs(x.y-k.y)),k=x;y.push({points:v,length:_})}y.sort((b,g)=>{const w=b.points[2]?.y,v=g.points[2]?.y;return b.length-g.length||(w===void 0||v===void 0?0:w-v)});for(const b of y){const g=vC(b.points);if(!Cp(g,i,a,wu))continue;const w=b.points,v=w[0],_=w[w.length-1];if(!v||!_)continue;const k={x1:Math.min(...w.map(x=>x.x)),y1:Math.min(...w.map(x=>x.y)),x2:Math.max(...w.map(x=>x.x)),y2:Math.max(...w.map(x=>x.y))};return{kind:"routed",start:v,end:_,controls:null,d:bC(g),bounds:k}}}return s}function SC(e,t){let n;for(const r of e){if(n){const i={x1:Math.min(n.x,r.x),y1:Math.min(n.y,r.y),x2:Math.max(n.x,r.x),y2:Math.max(n.y,r.y)};for(const o of t)if(XT(i,o))return!1}n=r}return!0}function Ww(e,t){if(!t)return Jt.rest;const n=Je(t);return Je(e.from)===n||Je(e.to)===n?Jt.related:Jt.faded}function xC(){return{hit:{stroke:"transparent",width:16},line:{stroke:Ke("edge"),width:1.6},arrow:{fill:Ke("edge")}}}function EC(e,t,n){return e!=="gravity"&&e!=="tree"?null:{layout:e,id:t,pointerId:n}}function $C(e,t,n,r){return e!=="node"&&e!=="edge"&&e!=="canvas"||!Number.isFinite(r?.x)||!Number.isFinite(r?.y)?null:{kind:e,id:t??null,pointerId:n,start:{...r},moved:!1}}function TC(e,t,n,r=LT){if(!e||e.pointerId!==t)return e;const i=Math.hypot(n.x-e.start.x,n.y-e.start.y);return{...e,moved:e.moved||i>r}}function CC(e,t,n=!1){return!e||e.pointerId!==t||n||e.moved?null:e.kind==="node"?{type:"select-node",id:e.id}:e.kind==="edge"?{type:"select-edge",id:e.id}:e.kind==="canvas"?{type:"clear-selection"}:null}function Ip(e){return e==="Enter"||e===" "}function AC(e,t){return{x:(e.x-t.x)/t.scale,y:(e.y-t.y)/t.scale}}function IC(e,t,n,r,i){return!t||t.pointerId!==n||!Object.hasOwn(e,t.id)?!1:(e[t.id]=AC(r,i),!0)}function NC(e,t){return e?.pointerId===t?null:e}function RC(e,t,n,r){const i=Math.min(t.width/n,t.height/r),o=t.left+(t.width-n*i)/2,s=t.top+(t.height-r*i)/2;return{x:(e.x-o)/i,y:(e.y-s)/i}}function LC(e,t,n){const r=new Map;let i=null,o=null,s=null;function a(h){if(h===e)return{kind:"canvas",id:null};const p=h;if(p?.closest?.("[data-canvas]"))return{kind:"canvas",id:null};const m=p?.closest?.("[data-node-id]");if(m)return{kind:"node",id:m.dataset.nodeId??null};const y=p?.closest?.("[data-edge-id]");return y?{kind:"edge",id:y.dataset.edgeId??null}:null}function u(h){if(h.pointerType==="mouse"&&h.button!==0)return;const p=n?n(h):a(h.target);if(!p)return;const m=t.point(h);if(r.set(h.pointerId,m),e.setPointerCapture(h.pointerId),p.kind!=="canvas"&&(h.preventDefault(),h.stopPropagation()),r.size===1){i=$C(p.kind,p.id,h.pointerId,{x:h.clientX,y:h.clientY}),o=p.kind==="canvas"?{point:m,transform:{...t.transform()}}:null;return}if(i&&(i={...i,moved:!0}),o=null,r.size===2){const[y,b]=[...r.values()];y&&b&&(s={distance:Math.hypot(b.x-y.x,b.y-y.y),scale:t.transform().scale},t.startPinch())}}function c(h){if(!r.has(h.pointerId))return;const p=t.point(h);if(r.set(h.pointerId,p),s){const[m,y]=[...r.values()];m&&y&&t.pinch(s,[m,y],h);return}if(i?.pointerId===h.pointerId){if(i=TC(i,h.pointerId,{x:h.clientX,y:h.clientY}),!i?.moved)return;if(i.kind==="node"){t.drag(i.id??"",h.pointerId,p,h);return}if(i.kind==="edge")return}o&&t.pan(o,p,h)}function l(h,p=!1){const m=CC(i,h.pointerId,p);m&&t.select(m),i?.pointerId===h.pointerId&&(i=null),t.endDrag(h.pointerId),r.delete(h.pointerId),r.size||(i=null,o=null,s=null),e.hasPointerCapture(h.pointerId)&&e.releasePointerCapture(h.pointerId)}const d=h=>l(h),f=h=>l(h,!0);return e.addEventListener("pointerdown",u,!0),e.addEventListener("pointermove",c),e.addEventListener("pointerup",d),e.addEventListener("pointercancel",f),()=>{e.removeEventListener("pointerdown",u,!0),e.removeEventListener("pointermove",c),e.removeEventListener("pointerup",d),e.removeEventListener("pointercancel",f)}}function zC(e,t,n){let r=!1;function i(o,s=!1){r=o,e.classList.toggle("graph-panel--expanded",o),n.classList.toggle("graph-expanded",o),t.classList.toggle("expand-control--expanded",o),t.setAttribute("aria-expanded",String(o)),t.setAttribute("aria-label",o?"Close expanded graph":"Expand graph"),t.setAttribute("title",o?"Close expanded graph":"Expand graph"),o?(e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true")):(e.removeAttribute("role"),e.removeAttribute("aria-modal"),s&&t.focus())}return{open(){i(!0)},close(o={}){i(!1,o.restoreFocus!==!1)},toggle(){i(!r,r)},isOpen(){return r}}}function Kw(e){const t=String(e??"").toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):"Unknown"}function cc(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e)}function lc(e){return e==null?"Unavailable":new Intl.NumberFormat("en-US").format(e)}function Tn(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return"Unavailable";const t=new Date(e<1e11?e*1e3:e);return!Number.isFinite(t.getTime())||t.getUTCFullYear()<2009||t.getUTCFullYear()>2100?"Unavailable":new Intl.DateTimeFormat("en-GB",{dateStyle:"medium",timeStyle:"short",timeZone:"UTC"}).format(t)}function Jw(e,t=Date.now()){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return"Unavailable";const n=Math.max(0,(t-(e<1e11?e*1e3:e))/1e3),r=[[31536e3,"year"],[2592e3,"month"],[86400,"day"],[3600,"hour"],[60,"minute"]];for(const[i,o]of r){const s=Math.floor(n/i);if(s>=1)return`${s} ${o}${s===1?"":"s"} ago`}return"just now"}function dc(e){if(e.amount_usd_sum==null||e.price_coverage_ratio===0)return"Unavailable";const t=e.price_coverage_ratio;return cc(e.amount_usd_sum)+(t!=null&&t>0&&t<1?" (priced portion)":"")}function PC(e){const t=[["Incoming amount (USD)",e.total_in_usd==null?"Unavailable":cc(e.total_in_usd)],["Outgoing amount (USD)",e.total_out_usd==null?"Unavailable":cc(e.total_out_usd)]];return e.role&&qr.includes(e.role)?[["Role",jw[e.role]||"Other"],...t,["Senders",lc(e.degree_in)],["Receivers",lc(e.degree_out)],["Labels",In(e).join(", ")||"No labels"]]:[["Address risk",e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} · ${Kw(e.risk_level)}`],["Confidence","Unavailable"],...t,["First activity (UTC)",Tn(e.first_activity_timestamp)],["Last activity (UTC)",Tn(e.last_activity_timestamp)],["Labels",In(e).join(", ")||"No labels"]]}function DC(e,t){if(e.source==="flows")return[["From",e.from||"Unavailable"],["To",e.to||"Unavailable"],["Value (USD)",dc(e)],["Transfers",lc(e.tx_count)],["First seen (UTC)",Tn(e.first_seen_timestamp)],["Last seen (UTC)",Tn(e.last_seen_timestamp)],["Since last seen",Jw(e.last_seen_timestamp,t)],...e.link_kind?[["Link kind",e.link_kind]]:[]];const n=e.price_coverage_ratio;return[["From",e.from||"Unavailable"],["To",e.to||"Unavailable"],["Value (USD)",dc(e)],["Price coverage",n==null?"Unavailable":new Intl.NumberFormat("en-GB",{style:"percent",maximumFractionDigits:1}).format(n)],["Transfers",e.tx_count==null?"Unavailable":String(e.tx_count)],["First seen (UTC)",Tn(e.first_seen_timestamp)],["Last seen (UTC)",Tn(e.last_seen_timestamp)],["First transaction",e.first_tx_id||"Unavailable"],["Last transaction",e.last_tx_id||"Unavailable"]]}function Yw(e){return typeof e!="string"||!/^0x[a-fA-F0-9]{64}$/.test(e)?null:`https://robinhoodchain.blockscout.com/tx/${e.toLowerCase()}`}function fc(e){const t=Do(e);if(e.role)return`${e.address}. ${t||"Other"}.${In(e).length?` Labels: ${In(e).join(", ")}.`:""}`;const n=e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} ${Kw(e.risk_level)} risk`,r=In(e).join(", ");return`${e.address}. ${n}.${r?` Labels: ${r}.`:""}`}const Xw=80;function OC(e){const t=Math.abs(e);return t>=1e9?`$${(e/1e9).toFixed(1)}B`:t>=1e6?`$${(e/1e6).toFixed(1)}M`:t>=1e4?`$${Math.round(e/1e3)}K`:t>=100?`$${Math.round(e)}`:`$${e.toFixed(2)}`}function MC(e,t){const n=u=>new Date(u<1e12?u*1e3:u),r=e&&e>0?n(e):null,i=t&&t>0?n(t):r;if(!i)return"";const o=u=>u.getUTCDate(),s=u=>u.toLocaleString("en-US",{month:"short",timeZone:"UTC"}),a=u=>`${o(u)} ${s(u)} ${u.getUTCFullYear()}`;return!r||r.toISOString().slice(0,10)===i.toISOString().slice(0,10)?a(i):r.getUTCFullYear()!==i.getUTCFullYear()?`${a(r)} – ${a(i)}`:r.getUTCMonth()!==i.getUTCMonth()?`${o(r)} ${s(r)} – ${a(i)}`:`${o(r)} – ${a(i)}`}function Qw(e){const t=e.amount_usd_sum!=null&&e.price_coverage_ratio!==0?OC(e.amount_usd_sum):"",n=MC(e.first_seen_timestamp,e.last_seen_timestamp);return[t,n].filter(Boolean).join(" · ")}function hc(e,t){const n=`${e.from} to ${e.to}. Aggregate value ${dc(e)}. ${e.tx_count??0} ${e.tx_count===1?"transfer":"transfers"}.`;return e.source==="flows"&&e.last_seen_timestamp?`${n} Last seen ${Jw(e.last_seen_timestamp,t)}.`:n}function FC(e,t){return Mt(e).nodes.map(n=>{const r={id:n.address,label:In(n).join(", ")||Do(n)};n.role&&(r.role=n.role);const i=t?.(n.address);return i&&(r.href=i),r})}function UC(e,t=22){return e.length>t?`${e.slice(0,t-1)}…`:e}function GC(e,t,n={}){const r=e.ownerDocument;let i=Mt(t),o=n.layout??(rh(t)?"tree":"gravity");const s={width:e.clientWidth||n.width||820,height:e.clientHeight||n.height||430};let a=Wo(i,o,s.width,s.height);const u=new Map,c=new Map;let l={x:0,y:0,scale:1},d=null,f=null,h=null;const p=n.now??(()=>Date.now()),m=T=>n.nodeStyle?.(T).stroke??WT(T);e.classList.add("cia-graph-engine"),e.closest(".cia-graph-surface")||e.classList.add("cia-graph-surface");const y={model:()=>i,positions:()=>a,transform:()=>l,notes:()=>u,flags:()=>c,selected:()=>d,highlighted:()=>f,colorOf:m,now:p,dimensions:()=>s},b={selectNode:(T,D)=>H(T,D),selectEdge:(T,D)=>K(T,D),showTooltip:(T,D)=>G(T,D),hideTooltip:()=>fe(),lost:()=>Te()};function g(T){const D=T==="webgl"?_p("webgl"):null;if(D)try{return D(e,y,b,{label:n.label})}catch{}return kp(e,y,b,{label:n.label})}const w=n.renderer??(_p("webgl")&&TT(r)?"webgl":"svg");let v=g(w);e.dataset.renderer=v.kind;const _=()=>{const T=YT(i,a,u);if(!T)return null;const D=v.linkBounds();return D&&(T.x1=Math.min(T.x1,D.x1),T.y1=Math.min(T.y1,D.y1),T.x2=Math.max(T.x2,D.x2),T.y2=Math.max(T.y2,D.y2)),T},k=()=>{const T=_();return T?uC(T,s.width,s.height,Si):{x:0,y:0,scale:1}};l=k();const x=r.createElement("div");x.className="graph-tooltip cia-graph-tooltip",x.hidden=!0,x.setAttribute("role","tooltip"),e.append(x);let N=0,M=!1,F=!1;function B(){if(N){M=!0;return}v.build()}function ee(){if(N){F=!0;return}l=k(),ce()}function ce(){v.camera()}function me(T="program"){const D=FC(i,n.href),ne=d?.kind==="node"?i.nodes.find(ve=>ve.id===d.id)??null:null,Se=d?.kind==="edge"?i.edges.find(ve=>ve.id===d.id)??null:null;if(ne){const ve=i.edges.filter(dt=>dt.from===ne.address||dt.to===ne.address);return{kind:"node",id:ne.id,selectedId:ne.address,nodes:D,title:"Selected address",identity:ne.address,values:PC(ne),related:ve,node:ne,edge:null,source:T}}return Se?{kind:"edge",id:Se.id,selectedId:null,nodes:D,title:"Selected aggregate flow",identity:`${Se.from} → ${Se.to}`,values:DC(Se,p()),related:[Se],node:null,edge:Se,source:T}:{kind:null,id:null,selectedId:null,nodes:D,title:"Nothing selected",identity:"",values:[],related:[],node:null,edge:null,source:T}}function $e(T){const D=me(T);U(D),n.onSelect?.(D)}function U(T){const D=n.selectionRoot,ne=D?.querySelector("[data-selection-title]"),Se=D?.querySelector("[data-selection-identity]"),ve=D?.querySelector("[data-selection-meta]");!ne||!Se||!ve||(ne.textContent=T.title,Se.textContent=T.identity,ve.replaceChildren(...T.values.map(([dt,ke])=>{const yt=r.createElement("div");yt.className="meta-item",ke!=="Unavailable"&&(["From","To","First transaction","Last transaction"].includes(dt)&&yt.classList.add("meta-item--identity"),dt==="Incoming amount (USD)"&&yt.classList.add("meta-item--incoming"),dt==="Outgoing amount (USD)"&&yt.classList.add("meta-item--outgoing")),["From","To","First transaction","Last transaction","Labels"].includes(dt)&&yt.classList.add("meta-item--wide");const nr=r.createElement("span");nr.textContent=dt;const Dn=r.createElement("strong"),xt=["First transaction","Last transaction"].includes(dt)?Yw(ke):null;if(xt&&n.openLink){const Ht=n.openLink,Vt=r.createElement("button");Vt.type="button",Vt.className="cia-graph-explorer-link",Vt.dataset.explorer=xt,Vt.textContent=ke,Vt.setAttribute("aria-label",`${dt}: ${ke} (opens the explorer)`),Vt.addEventListener("click",()=>Ht(xt)),Dn.append(Vt)}else if(xt){const Ht=r.createElement("a");Ht.href=xt,Ht.target="_blank",Ht.rel="noopener noreferrer",Ht.textContent=ke,Ht.setAttribute("aria-label",`${dt}: ${ke} (opens in new tab)`),Dn.append(Ht)}else Dn.textContent=ke;return yt.append(nr,Dn),yt})))}function H(T,D="program"){d=T?{kind:"node",id:T}:null,v.selection(),$e(D)}function K(T,D="program"){d=T?{kind:"edge",id:T}:null,v.selection(),$e(D)}function de(T){if(T==null)return H(null);const D=kn(i,T);if(D)return H(D);if(i.edges.some(ne=>ne.id===T))return K(T)}function te(){l=k(),ce()}function I(T,D={x:s.width/2,y:s.height/2}){const ne=ac(l.scale*(1+T)),Se=ne/l.scale;l={x:D.x-(D.x-l.x)*Se,y:D.y-(D.y-l.y)*Se,scale:ne},ce()}function z(T){o=T,n.controls?.querySelectorAll("[data-layout]").forEach(D=>{D.classList.toggle("active",D.dataset.layout===T),D.setAttribute("aria-pressed",String(D.dataset.layout===T))}),n.onLayoutChange?.(T),a=Wo(i,o,s.width,s.height),v.geometry(),te()}function G(T,D){x.textContent=D,x.hidden=!1;const ne=e.getBoundingClientRect();x.style.left=`${Math.min(ne.width-330,Math.max(8,T.clientX-ne.left+12))}px`,x.style.top=`${Math.max(8,T.clientY-ne.top+12)}px`}function fe(){x.hidden=!0}function ie(T){return RC({x:T.clientX,y:T.clientY},v.surface.getBoundingClientRect(),s.width,s.height)}const Y={point:ie,transform:()=>l,select(T){T.type==="select-node"?H(T.id,"pointer"):T.type==="select-edge"?K(T.id,"pointer"):H(null,"canvas")},drag(T,D,ne){!h&&(h=EC(o,T,D),!h)||IC(a,h,D,ne,l)&&(oe=!0,v.moveNode(h.id))},endDrag(T){const D=h?.pointerId===T&&oe;h=NC(h,T),D&&(oe=!1,v.endMove())},pan(T,D){l={x:T.transform.x+D.x-T.point.x,y:T.transform.y+D.y-T.point.y,scale:l.scale},ce()},startPinch(){h=null},pinch(T,[D,ne]){const Se=Math.hypot(ne.x-D.x,ne.y-D.y),ve=ac(T.scale*Se/Math.max(1,T.distance));I(ve/l.scale-1,{x:(D.x+ne.x)/2,y:(D.y+ne.y)/2})}};let oe=!1;const he=T=>{T.preventDefault(),I(T.deltaY>0?-.12:.12,ie(T))},Ae={ArrowLeft:[60,0],ArrowRight:[-60,0],ArrowUp:[0,60],ArrowDown:[0,-60]},O=T=>{if(T.target!==v.surface)return;const D=Ae[T.key];D?(T.preventDefault(),l={...l,x:l.x+D[0],y:l.y+D[1]},ce()):T.key==="+"||T.key==="="?I(.18):T.key==="-"?I(-.18):T.key==="0"&&te()};let j=()=>{};function q(){const T=v.surface,D=ne=>v.pick(ie(ne));j=LC(T,Y,v.kind==="svg"?void 0:D),T.addEventListener("wheel",he,{passive:!1}),T.addEventListener("keydown",O)}function J(){j(),v.surface.removeEventListener("wheel",he),v.surface.removeEventListener("keydown",O)}q();function Te(){v.kind!=="svg"&&(J(),v.destroy(),v=kp(e,y,b,{label:n.label}),e.dataset.renderer=v.kind,e.append(x),q(),B())}const se=n.controls?.querySelector("[data-expand]")??null,ye=n.panel&&se?zC(n.panel,se,r.body):null,Oe=()=>{ye?.toggle(),n.onExpansionChange?.(ye?.isOpen()??!1),requestAnimationFrame(te)},ae=n.panel??e,ze=T=>{if(T.key==="Tab"&&ye?.isOpen()&&n.panel){const D=Array.from(n.panel.querySelectorAll('button,a[href],[tabindex="0"],summary')).filter(ve=>ve.checkVisibility()),ne=D[0],Se=D.at(-1);T.shiftKey&&r.activeElement===ne?(T.preventDefault(),Se?.focus()):!T.shiftKey&&r.activeElement===Se&&(T.preventDefault(),ne?.focus())}if(T.key==="Escape"){if(ye?.isOpen()){ye.close(),n.onExpansionChange?.(!1),requestAnimationFrame(te);return}H(null,"keyboard")}};ae.addEventListener("keydown",ze);const qe=[],tt=(T,D)=>{T&&(T.addEventListener("click",D),qe.push([T,D]))};n.controls?.querySelectorAll("[data-layout]").forEach(T=>tt(T,()=>z(T.dataset.layout==="tree"?"tree":"gravity"))),tt(n.controls?.querySelector("[data-zoom='in']"),()=>I(.18)),tt(n.controls?.querySelector("[data-zoom='out']"),()=>I(-.18)),tt(n.controls?.querySelector("[data-zoom='fit']"),te),ye&&tt(se,Oe);const Ye=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const T=e.clientWidth,D=e.clientHeight;!T||!D||T===s.width&&D===s.height||(s.width=T,s.height=D,v.resize(T,D),te())});Ye?.observe(e),B(),n.selected&&de(n.selected);const St={update(T){const D=a;i=Mt(T);const ne=i.nodes.every(ve=>D[ve.id])?{}:Wo(i,o,s.width,s.height);a=Object.fromEntries(i.nodes.map(ve=>[ve.id,D[ve.id]??ne[ve.id]]).filter(([,ve])=>ve)),d&&!(d.kind==="node"?i.nodes.some(ve=>ve.id===d.id):i.edges.some(ve=>ve.id===d.id))&&(d=null),f&&!i.nodes.some(ve=>ve.id===f)&&(f=null);const Se=new Set(i.nodes.map(ve=>ve.id));for(const ve of[...c.keys()])Se.has(ve)||c.delete(ve);B(),ee()},merge(T,D){const ne=BT(i,T,D);i=ne.model;const Se=kn(i,D??Mt(T).checked_address);return a=Se&&o==="gravity"?aC(i,a,Se,ne.added,{notes:u}):Wo(i,o,s.width,s.height),B(),ne.added.length&&ee(),ne.added},batch(T){N++;try{T()}finally{N--,!N&&M&&(M=!1,v.build()),!N&&F&&(F=!1,l=k(),ce())}},setTheme(T){T&&r.documentElement.setAttribute("data-theme",T),v.theme()},select:de,destroy(){Ye?.disconnect(),J(),ae.removeEventListener("keydown",ze);for(const[T,D]of qe)T.removeEventListener("click",D);ye?.close({restoreFocus:!1}),v.destroy(),x.remove(),e.classList.remove("cia-graph-engine"),delete e.dataset.renderer,delete e.ciaGraph},fit:te,zoom:T=>I(T),setLayout:z,markNode(T,D){const ne=kn(i,T);ne&&(D?u.set(ne,D):u.delete(ne),B())},patchNode(T,D){const ne=kn(i,T),Se=ne?i.nodes.find(ve=>ve.id===ne):null;return Se?(Object.assign(Se,D),v.selection(),!0):!1},flagNode(T,D,ne){const Se=kn(i,T);if(!Se)return;const ve=c.get(Se)??new Set;ne?ve.add(D):ve.delete(D),ve.size?c.set(Se,ve):c.delete(Se),N?M=!0:v.flag(Se,D,ne)},positions:()=>structuredClone(a),model:()=>i,contentBounds:()=>_(),transform:()=>({...l}),highlight(T){f=T==null?null:kn(i,T),v.selection()},renderer:()=>v.kind,clientPoint(T){const D=kn(i,T),ne=D?a[D]:null;if(!ne)return null;const Se=v.surface.getBoundingClientRect(),ve=Math.min(Se.width/s.width,Se.height/s.height)||1,dt=Se.left+(Se.width-s.width*ve)/2,ke=Se.top+(Se.height-s.height*ve)/2;return{x:dt+(ne.x*l.scale+l.x)*ve,y:ke+(ne.y*l.scale+l.y)*ve}}};return Object.defineProperty(e,"ciaGraph",{value:St,configurable:!0}),St}const e_="chain-insights.flows.v1",tu="chain-insights.result.v1",t_=5e3,Np=6,jC=3,n_=/^0x[0-9a-fA-F]{40}$/,ZC=/^0x[0-9a-fA-F]{64}$/;function BC(e){return typeof e=="string"&&(n_.test(e)||ZC.test(e))}function $i(e){return typeof e=="string"&&n_.test(e)}function pc(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function nu(e){const t=e?.facts?.query?.results;return Array.isArray(t)?t.filter(pc):[]}function HC(e){const t=e?.facts;return typeof t?.subject?.network=="string"&&t.subject.network?t.subject.network:"robinhood"}function Qt(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&/^-?\d+(\.\d+)?([eE][-+]?\d+)?$/.test(e.trim())){const t=Number(e);return Number.isFinite(t)?t:null}return null}function ah(e){return e<1e11?e*1e3:e}const r_=/^\d{4}-\d{2}-\d{2}$/,VC=Date.UTC(2009,0,1),qC=Date.UTC(2100,0,1);function cs(e){return new Date(ah(e)).toISOString().slice(0,10)}function xs(e){if(typeof e!="string"||!r_.test(e))return!1;const t=Date.parse(`${e}T00:00:00Z`);return Number.isFinite(t)&&new Date(t).toISOString().slice(0,10)===e}const WC=new Set(["day","date","hour","week","month"]),KC=["_timestamp","_time","_at"];function Rp(e){return WC.has(e)||KC.some(t=>e.endsWith(t))}function i_(e){const t=[];for(const n of e)for(const r of Object.keys(n))t.includes(r)||t.push(r);return t}function JC(e){return Array.isArray(e)?e.some($i):$i(e)}function YC(e){return e.some(t=>Object.values(t).some(JC))}function o_(e){return e.length>0&&e.every(t=>$i(t.from_address)&&$i(t.to_address))}const XC=/^(\d{4})-(\d{2})$/,QC=/^(\d{4})-W(\d{2})$/,eA=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/,tA=/(?:Z|[+-]\d{2}:?\d{2})$/i;function nA(e,t){const n=Date.UTC(e,0,4);return n-(new Date(n).getUTCDay()+6)%7*864e5+(t-1)*7*864e5}function Lp(e){if(typeof e=="string"){const r=e.trim();if(r_.test(r))return xs(r)?Date.parse(`${r}T00:00:00Z`):null;const i=XC.exec(r);if(i){const s=Number(i[2])-1;return s>=0&&s<12?Date.UTC(Number(i[1]),s,1):null}const o=QC.exec(r);if(o){const s=Number(o[2]);return s>=1&&s<=53?nA(Number(o[1]),s):null}if(eA.test(r)){const s=r.replace(" ","T"),a=Date.parse(tA.test(s)?s:`${s}Z`);return Number.isFinite(a)?a:null}}const t=Qt(e);if(t==null)return null;const n=ah(t);return n>=VC&&n<qC?n:null}const rA=1e18,zp=13,iA=/^-?0*(\d+)(?:\.0+)?$/;function oA(e){const t=e.toLowerCase();return t==="balance"||t.endsWith("_balance")||t.endsWith("_wei")}function sA(e){if(typeof e=="string"){const t=iA.exec(e.trim());if(!t)return null;const n=t[1];return n==="0"?"zero":n.length>=zp?"wei":null}return typeof e!="number"||!Number.isInteger(e)?null:e===0?"zero":Math.abs(e)>=10**(zp-1)?"wei":null}function aA(e,t){if(!oA(e))return!1;if(e.toLowerCase().endsWith("_wei"))return!0;const n=t.filter(r=>r!=null).map(sA);return n.includes("wei")&&n.every(r=>r!=null)}function uA(e){return`${e.replace(/_wei$/i,"")} (ETH)`}function uh(e,t={}){if(e.length===0||YC(e))return null;const n=i_(e),i=n.filter(Rp).find(d=>e.some(f=>Lp(f[d])!=null));if(!i)return null;const o=n.filter(d=>{if(Rp(d))return!1;const f=e.map(h=>h[d]).filter(h=>h!=null);return f.length>0&&f.every(h=>Qt(h)!=null)});if(o.length===0)return null;const s=o.slice(0,Np),a=new Map;let u=0;for(const d of e){const f=Lp(d[i]);if(f==null)continue;u++;const h=a.get(f)??{count:0,sums:s.map(()=>null)};h.count++,s.forEach((p,m)=>{const y=Qt(d[p]);y!=null&&(h.sums[m]=(h.sums[m]??0)+y)}),a.set(f,h)}const c=[...a.entries()].sort((d,f)=>d[0]-f[0]);return c.filter(([,d])=>d.sums.some(f=>f!=null)).length<(t.minPoints??jC)?null:{xColumn:i,times:c.map(([d])=>d),rowCounts:c.map(([,d])=>d.count),daily:c.every(([d])=>d%864e5===0),series:s.map((d,f)=>{const h=c.map(([,p])=>p.sums[f]??null);return aA(d,e.map(p=>p[d]))?{column:d,name:uA(d),unit:"ETH",values:h.map(p=>p==null?null:p/rA)}:{column:d,values:h}}),omittedColumns:o.slice(Np),skippedRows:e.length-u,failures:[]}}function cA(e){if(!e)return"failed";const t=/^\s*([a-z][a-z0-9_]*)\s*:/.exec(e);if(t?.[1])return t[1];const n=e.trim().split(/\s+/).slice(0,4).join(" ");return n.length>40?`${n.slice(0,39)}…`:n||"failed"}const lA=e=>e==null||Qt(e)!=null;function s_(e){const t=u_(e);if(t.length<3||!t.every(c=>xs(c.id))||new Set(t.map(c=>c.id)).size!==t.length)return null;const n=t.filter(c=>c.ok);if(n.length===0||!n.every(c=>c.rows.length===1))return null;const r=Object.keys(n[0].rows[0]),i=[...r].sort().join("\0");for(const c of n){const l=c.rows[0];if(Object.keys(l).sort().join("\0")!==i||!Object.values(l).every(lA))return null}if(r.length===0||r.includes("day"))return null;const o=[...t].sort((c,l)=>c.id.localeCompare(l.id)),s=o.map(c=>({day:c.id,...c.ok?c.rows[0]:Object.fromEntries(r.map(l=>[l,null]))})),a=o.filter(c=>!c.ok).map(c=>({day:c.id,time:Date.parse(`${c.id}T00:00:00Z`),code:cA(c.error)})),u=uh(s,{minPoints:1});return u?{rows:s,columns:r,failures:a,model:{...u,failures:a}}:null}const dA=/\baddress\s*:\s*(["'])(0x[0-9a-fA-F]{40})\1/g,fA=/^\s*(<)?-(?:\[[^\]]*\])?-(>)?/,hA=/(<)?-(?:\[[^\]]*\])?-(>)?\s*$/;function Pp(e,t){if(!e)return"none";const n=!!e[1],r=!!e[2];return n===r?null:t==="after"?r?"from":"to":r?"to":"from"}function a_(e){if(typeof e!="string"||!e)return null;const t=[...e.matchAll(dA)];if(t.length===0||new Set(t.map(r=>r[2].toLowerCase())).size!==1)return null;let n=null;for(const r of t){const i=r.index??0,o=e.lastIndexOf("(",i),s=e.indexOf(")",i);if(o<0||s<0)return null;const a=[Pp(hA.exec(e.slice(0,o)),"before"),Pp(fA.exec(e.slice(s+1)),"after")];if(a.includes(null))return null;for(const u of a)if(u!=="none"){if(n&&n!==u)return null;n=u}}return n?{address:t[0][2],end:n}:null}function pA(e,t){if(e.length===0||o_(e))return null;const n=a_(t);if(!n)return null;const r=n.address.toLowerCase(),i=i_(e).filter(s=>e.every(a=>$i(a[s]))&&!e.every(a=>String(a[s]).toLowerCase()===r));if(i.length!==1)return null;const o=i[0];return e.map(s=>n.end==="from"?{...s,from_address:n.address,to_address:s[o]}:{...s,from_address:s[o],to_address:n.address})}function mA(e){return o_(e)?"graph":uh(e)?"chart":"table"}const gA=[["sanctioned","sanctioned"],["scam","scam"],["victim","victim"],["pool","pool"],["exchange","exchange"],["selftrader","self_trader"]];function Dp(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim()!=="").map(t=>t.trim()):[]}function yA(e,t){if(t)return"exchange";const n=new Set(e.map(r=>r.replace(/\s+/g,"").toLowerCase()));for(const[r,i]of gA)if(n.has(r))return i;return"other"}const Op=(e,t)=>e==null?t:t==null?e:e+t;function vA(e,t="robinhood",n){const r=new Map;for(const h of e)for(const p of new Set([String(h.from_address).toLowerCase(),String(h.to_address).toLowerCase()]))r.set(p,(r.get(p)??0)+1);let i="",o=0;for(const[h,p]of r)p>o&&(i=h,o=p);const s=n?.toLowerCase();s&&r.has(s)&&(i=s);const a=new Map,u=new Map,c=(h,p,m)=>{const y=a.get(h)??{address:h,labels:[],exchange:!1};for(const b of p)y.labels.some(g=>g.toLowerCase()===b.toLowerCase())||y.labels.push(b);y.exchange=y.exchange||m,a.set(h,y)};i&&a.set(i,{address:i,labels:[],exchange:!1});let l=0;for(const h of e){const p=String(h.from_address).toLowerCase(),m=String(h.to_address).toLowerCase(),y=[p,m].filter((_,k,x)=>!a.has(_)&&x.indexOf(_)===k).length;if(a.size+y>t_||(l++,c(p,Dp(h.from_labels),h.from_is_exchange===!0),c(m,Dp(h.to_labels),h.to_is_exchange===!0),p===m))continue;const b=`${p}->${m}`,g=u.get(b)??{from:p,to:m,usd:null,tx:null,first:null,last:null,kinds:[]};g.usd=Op(g.usd,Qt(h.amount_usd_sum)),g.tx=Op(g.tx,Qt(h.tx_count));const w=Qt(h.first_seen_timestamp),v=Qt(h.last_seen_timestamp);w!=null&&(g.first=g.first==null?w:Math.min(g.first,w)),v!=null&&(g.last=g.last==null?v:Math.max(g.last,v)),typeof h.link_kind=="string"&&h.link_kind&&!g.kinds.includes(h.link_kind)&&g.kinds.push(h.link_kind),u.set(b,g)}const d=[...a.values()].map(h=>({address:h.address,role:yA(h.labels,h.exchange),labels:h.labels})),f=[...u.values()].map(h=>({from:h.from,to:h.to,usd:h.usd,tx_count:h.tx,first_seen_ms:h.first,last_seen_ms:h.last,...h.kinds.length?{link_kind:h.kinds.join(", ")}:{}}));return{view:{schema:e_,network:t,center:i,nodes:d,edges:f,truncated:!1},rowsTotal:e.length,rowsDrawn:l,rowsLeftOut:e.length-l,addresses:a.size}}function u_(e){const t=e?.facts?.queries;return Array.isArray(t)?t.filter(pc).map((n,r)=>({id:typeof n.id=="string"&&n.id?n.id:`Query ${r+1}`,ok:n.ok!==!1&&n.error==null,error:typeof n.error=="string"&&n.error?n.error:null,rows:Array.isArray(n.results)?n.results.filter(pc):[],count:typeof n.count=="number"?n.count:null,truncated:n.truncated===!0,elapsedMs:typeof n.elapsed_ms=="number"?n.elapsed_ms:null,query:typeof n.query=="string"&&n.query?n.query:null})):[]}const Mp=200;function Wr(e){return(e?.content??[]).filter(t=>t?.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
109
109
|
`).trim()}function Xr(e){if(typeof e=="string")return e.trim()||null;if(!e||typeof e!="object"||Array.isArray(e))return null;const{code:t,message:n,detail:r,error:i}=e,o=[n,r,i].find(a=>typeof a=="string"&&a.trim()!=="")?.trim()??null,s=typeof t=="string"&&t.trim()?t.trim():null;return o?s&&!o.startsWith(s)?`${s}: ${o}`:o:s}function c_(e){if(!e)return null;const t=e.structuredContent,n=Xr(t?.error)??Xr(t?.facts?.error)??Xr(t?.facts?.query?.error);if(!e.isError||n)return n;const r=Wr(e);if(r.startsWith("{"))try{const i=JSON.parse(r),o=Xr(i?.error)??Xr(i);if(o)return o}catch{}return r||"The tool answered with an error."}const bA=new Set(["usage_status","subscription_status","meta_usage_status","meta_subscription_status"]);function l_(e){if(!e||c_(e)!=null)return"text";const t=e.structuredContent;if(t?.schema===e_)return"flows";if(t?.schema===tu){if(t.tool==="graph_query")return mA(nu(t));if(t.tool==="graph_query_batch")return!Array.isArray(t.facts?.queries)||t.facts.queries.length===0?"text":s_(t)?"chart":"batch";if(typeof t.tool=="string"&&bA.has(t.tool))return"balance"}return"text"}function A(e,t,n={},...r){const i=e.createElement(t);for(const[o,s]of Object.entries(n))s==null||s===!1||(o==="class"?i.className=String(s):o==="text"?i.textContent=String(s):i.setAttribute(o,s===!0?"":String(s)));for(const o of r)o==null||o===!1||i.append(typeof o=="string"?e.createTextNode(o):o);return i}function wA(e,t){const n=A(e,"code",{class:"cv-addr",title:t,"data-full":t,text:xi(t)}),r=A(e,"button",{type:"button",class:"cv-copy","data-copy":t,"aria-label":`Copy ${t}`,title:"Copy the full value",text:"Copy"});return r.addEventListener("click",()=>{_A(e,t,n,r)}),A(e,"span",{class:"cv-addr-cell"},n,r)}async function _A(e,t,n,r){const i=e.defaultView?.navigator?.clipboard;try{if(i?.writeText)return await i.writeText(t),r&&(r.textContent="Copied"),"copied"}catch{}return n.textContent=t,n.classList.add("is-full"),e.getSelection?.()?.selectAllChildren(n),r&&(r.textContent="Selected"),"selected"}function kA(e,t){return/(timestamp|seen|_at|_ms|time)$/i.test(t)&&e>1e9?Tn(e):/usd/i.test(t)?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e):new Intl.NumberFormat("en-US",{maximumFractionDigits:4}).format(e)}const SA=160,Fp=2e3;function xA(e,t=SA){const n=e.trim().split(/\r?\n/,1)[0]??"",r=n.search(/[.!?](?=\s|$)/),i=(r<0?n:n.slice(0,r+1)).trim();if(i.length<=t)return i;const o=i.slice(0,t-1),s=o.lastIndexOf(" ");return`${(s>t*.6?o.slice(0,s):o).trimEnd()}…`}function d_(e,t,n){const r=e.ownerDocument,i=n.full!=null&&n.full.length>Fp?`${n.full.slice(0,Fp-1)}…`:n.full,o=i!=null&&i!==t,s=A(r,"section",{class:`cia-graph-surface cv-notice cv-notice-${n.kind}`,"data-view":n.view,"data-notice":n.kind,role:n.kind==="refused"?"alert":"status",title:o?i:null},o?A(r,"details",{class:"cv-notice-more"},A(r,"summary",{class:"cv-notice-line",text:t}),A(r,"p",{class:"cv-notice-full",text:i})):A(r,"p",{class:"cv-notice-line",text:t}));return e.replaceChildren(s),s}function EA(e){const t=e?.facts?.query,n=Array.isArray(t?.results)?t.results.filter(o=>!!o&&typeof o=="object"&&!Array.isArray(o)):[],r=n.slice(0,Mp),i=[];for(const o of r)for(const s of Object.keys(o))i.includes(s)||i.push(s);return{columns:i,rows:r,total:n.length,truncated:n.length>Mp||t?.truncated===!0,elapsedMs:typeof t?.elapsed_ms=="number"?t.elapsed_ms:null}}function $A(e,t,n){return t==null?A(e,"span",{class:"cv-null","aria-label":"empty",text:"—"}):BC(t)?wA(e,t):typeof t=="number"?e.createTextNode(kA(t,n)):typeof t=="boolean"?e.createTextNode(t?"yes":"no"):Array.isArray(t)?e.createTextNode(t.map(r=>typeof r=="string"?r:JSON.stringify(r)).join(", ")):typeof t=="object"?e.createTextNode(JSON.stringify(t)):e.createTextNode(String(t))}const TA={from_address:"From address",to_address:"To address",address:"Address",amount_usd_sum:"Value (USD)",amount_usd:"Value (USD)",usd:"Value (USD)",tx_count:"Transfers",first_seen_timestamp:"First seen (UTC)",last_seen_timestamp:"Last seen (UTC)",first_activity_timestamp:"First activity (UTC)",last_activity_timestamp:"Last activity (UTC)",block_timestamp:"Time (UTC)",block_date:"Day",block_height:"Block",tx_id:"Transaction",from_labels:"From labels",to_labels:"To labels",labels:"Labels",degree_in:"Senders",degree_out:"Receivers",total_in_usd:"Incoming (USD)",total_out_usd:"Outgoing (USD)",total_volume_usd:"Volume (USD)",asset_symbol:"Token",amount:"Amount"};function CA(e){const t=TA[e];if(t)return t;const n=e.replace(/_/g," ").trim();return n?n[0].toUpperCase()+n.slice(1):e}function Up(e,t,n={}){const r=e.ownerDocument,i=EA(t.structuredContent),o=i.rows.length;if(i.total===0)return d_(e,"No rows.",{kind:"empty",view:"table"}),i;const s=`${new Intl.NumberFormat("en-US").format(o)} ${o===1?"row":"rows"}${i.elapsedMs==null?"":` in ${i.elapsedMs} ms`}`,a=A(r,"table",{class:"cv-table"},A(r,"thead",{},A(r,"tr",{},...i.columns.map(u=>A(r,"th",{scope:"col",title:u,text:CA(u)})))),A(r,"tbody",{},...i.rows.map(u=>A(r,"tr",{},...i.columns.map(c=>A(r,"td",{},$A(r,u[c],c)))))));return e.replaceChildren(A(r,"section",{class:"cv-card cv-table-view","data-view":"table","aria-label":"Graph query result"},A(r,"header",{class:"cv-card-head"},A(r,"strong",{text:"Graph query result"}),A(r,"span",{class:"cv-muted",text:s}),n.toggle??null),i.truncated?A(r,"p",{class:"cv-note",role:"note","data-truncated":"",text:`Truncated: showing the first ${new Intl.NumberFormat("en-US").format(o)} of ${new Intl.NumberFormat("en-US").format(i.total)} rows. Narrow the query to see the rest.`}):null,i.columns.length?A(r,"div",{class:"cv-table-wrap"},a):null)),i}const Qr=(e,t=0)=>typeof e=="number"&&Number.isFinite(e)?e:t,Ko=e=>typeof e=="string"&&e?e:null;function AA(e){const t=e?.facts??{};if(typeof t.wallet=="string"&&t.wallet)return{kind:"wallet",wallet:t.wallet,tier:String(t.tier??"anonymous"),allowanceUsd:Qr(t.allowance_usd),consumedUsd:Qr(t.consumed_usd),windowEnd:Ko(t.window_end)};const n=t.usage;if(n&&typeof n=="object"){const r="daily_units_limit"in n||"daily_units_used"in n,i=Ko(n.access_mode);return{kind:"free",unit:r?"units":"seconds",used:Qr(r?n.daily_units_used:n.daily_seconds_used),limit:Qr(r?n.daily_units_limit:n.daily_seconds_limit),remaining:Qr(r?n.remaining_units:n.remaining_seconds),resetAt:Ko(n.reset_at),identifierKind:Ko(n.identifier_kind),accessMode:i,noLimit:!r&&i==="public_free"&&n.daily_seconds_limit===0}}return{kind:"unknown"}}const Gp=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e),Jo=(e,t)=>`${new Intl.NumberFormat("en-US").format(e)} ${t==="units"?e===1?"unit":"units":e===1?"second":"seconds"}`;function _u(e){if(!e)return"No active window";const t=Date.parse(e);return Number.isFinite(t)?`${Tn(t)} UTC`:e}function jp(e,t,n,r){const i=n>0?Math.min(1,t/n):0,o=A(e,"div",{class:"cv-meter",role:"meter","aria-label":r,"aria-valuemin":0,"aria-valuemax":n,"aria-valuenow":Math.min(t,n)},A(e,"span"));return o.firstElementChild.style.width=`${Math.round(i*100)}%`,o}function ku(e,t){return A(e,"dl",{class:"cv-facts"},...t.flatMap(([n,r])=>[A(e,"dt",{text:n}),A(e,"dd",{text:r})]))}function IA(e,t){const n=e.ownerDocument,r=AA(t.structuredContent);let i,o,s;return r.kind==="wallet"?(o="Wallet allowance",s=`${xi(r.wallet)} · ${r.tier==="subscriber"?"Subscriber":"No active subscription"}`,i=[jp(n,r.consumedUsd,r.allowanceUsd,"Share of today's allowance used"),ku(n,[["Daily allowance",Gp(r.allowanceUsd)],["Used today",Gp(r.consumedUsd)],["Window ends",_u(r.windowEnd)]])]):r.kind==="free"?(o="Free tier",s=`No wallet · counted per ${r.identifierKind==="ip"||!r.identifierKind?"network address":r.identifierKind}`,i=r.noLimit?[A(n,"p",{class:"cv-balance-note","data-no-limit":"",text:"Free access, no daily limit"}),ku(n,[["Daily allowance","No daily limit"],["Used today",Jo(r.used,r.unit)],["Window ends",_u(r.resetAt)]])]:[jp(n,r.used,r.limit,"Share of today's free allowance used"),ku(n,[["Daily allowance",Jo(r.limit,r.unit)],["Used today",Jo(r.used,r.unit)],["Left today",Jo(r.remaining,r.unit)],["Window ends",_u(r.resetAt)]])]):(o="Usage",s="The server sent no allowance figures.",i=[A(n,"p",{class:"cv-muted",text:Wr(t)||"Nothing to show."})]),e.replaceChildren(A(n,"section",{class:"cv-card cv-balance-view","data-view":"balance","data-balance":r.kind,"aria-label":o},A(n,"header",{class:"cv-card-head"},A(n,"strong",{text:o}),A(n,"span",{class:"cv-muted",text:s})),...i)),r}function Ti(e,t,n="No drawing for this answer."){const r=e.ownerDocument,i=c_(t);if(i!=null){d_(e,xA(i),{kind:"refused",view:"text",full:i});return}const o=Wr(t);e.replaceChildren(A(r,"section",{class:"cv-card cv-text-view","data-view":"text"},A(r,"p",{text:n}),o?A(r,"p",{class:"cv-muted cv-text-body",text:o.length>600?`${o.slice(0,599)}…`:o}):null))}function ch(e,t="Loading the Chain Insights view"){const n=e.ownerDocument;e.replaceChildren(A(n,"section",{class:"cv-card cv-skeleton","data-view":"loading","aria-busy":"true","aria-label":t},A(n,"span",{class:"cv-sr",text:t}),A(n,"div",{class:"cv-skel-line cv-skel-title"}),A(n,"div",{class:"cv-skel-line cv-skel-sub"}),A(n,"div",{class:"cv-skel-block"})))}const NA="http://www.w3.org/2000/svg",mc=720,RA=320,LA=6,zA=420,Zp=4,PA=120,di={left:70,right:18,top:6},gc=18,f_=16,h_=6,p_=26,DA=170,OA=82,MA=28,FA=80,Vn=1e3,En=60*Vn,sr=60*En,tn=24*sr,UA=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function m_(e,t,n){if(n==="ETH")return"eth";if(/usd/i.test(e))return"usd";const r=t.filter(i=>i!=null);return r.length>0&&r.every(Number.isInteger)?"count":"number"}const GA=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}),jA=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumSignificantDigits:2}),ZA=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",notation:"compact",maximumFractionDigits:1}),Ci=new Intl.NumberFormat("en-US",{maximumFractionDigits:0}),BA=new Intl.NumberFormat("en-US",{maximumFractionDigits:4}),g_=new Intl.NumberFormat("en-US",{maximumSignificantDigits:3}),y_=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:2}),HA=new Intl.NumberFormat("en-US",{maximumFractionDigits:6}),VA=new Intl.NumberFormat("en-US",{maximumSignificantDigits:4}),qA=new Intl.NumberFormat("en-US",{maximumSignificantDigits:6}),lh=e=>e.name??e.column;function fi(e,t){if(e==null)return"—";if(t==="eth")return`${qA.format(e)} ETH`;const n=e!==0&&Math.abs(e)<.01;return t==="usd"?n?jA.format(e):GA.format(e):t==="count"?Ci.format(e):n?g_.format(e):BA.format(e)}function WA(e){return e!==0&&Math.abs(e)<.01?g_.format(e):Math.abs(e)<1e3?HA.format(Math.round(e*100)/100):y_.format(e)}function Es(e,t){return t==="eth"?`${VA.format(e)} ETH`:t==="usd"?Math.abs(e)<1e3?fi(e,"usd"):ZA.format(e):t==="count"?Math.abs(e)<1e3?Ci.format(e):y_.format(e):WA(e)}function KA(e,t){const n=new Date(e).toISOString();return t?`${n.slice(0,10)} (UTC day)`:`${n.slice(0,10)} ${n.slice(11,19)} UTC`}function v_(e){return e<=tn?"time":e<=PA*tn?"day":"month"}const JA=[Vn,2*Vn,5*Vn,10*Vn,15*Vn,30*Vn,En,2*En,5*En,10*En,15*En,30*En,sr,2*sr,3*sr,6*sr,12*sr,tn],YA=[1,2,3,7,14,30,60].map(e=>e*tn),XA=[1,2,3,6,12,24,60,120],Bp=4*tn,QA={time:76,day:84,month:72},e1=e=>new Date(e).getUTCFullYear()*12+new Date(e).getUTCMonth(),Su=e=>Date.UTC(Math.floor(e/12),e%12,1);function t1(e,t,n){const r=t-e,i=v_(r);if(r<=0)return{unit:i,step:0,times:[e]};const o=Math.max(2,Math.floor(n));if(i==="month"){for(const s of XA){const a=[];let u=e1(e);for(Su(u)<e&&u++;Su(u)<=t;u++)u%s===0&&a.push(Su(u));if(a.length<=o&&a.length>0)return{unit:i,step:s,times:a}}return{unit:i,step:0,times:[e,t]}}for(const s of i==="time"?JA:YA){const a=s===7*tn||s===14*tn?Math.ceil((e-Bp)/s)*s+Bp:i==="day"?Math.ceil(e/tn)*tn:Math.ceil(e/s)*s,u=a>t?0:Math.floor((t-a)/s)+1;if(u>0&&u<=o)return{unit:i,step:s,times:Array.from({length:u},(c,l)=>a+l*s)}}return{unit:i,step:0,times:[e,t]}}function n1(e,t,n){const r=new Date(e),i=r.toISOString();return t==="month"?n>=12?i.slice(0,4):`${UA[r.getUTCMonth()]} ${r.getUTCFullYear()}`:t==="day"||e%tn===0?i.slice(0,10):n>0&&n<En?i.slice(11,19):i.slice(11,16)}function r1(e){return e.series.map(t=>{let n=0,r=null,i=null,o=null,s=null;return t.values.forEach((a,u)=>{a!=null&&(n+=a,(r==null||a>r)&&(r=a,i=e.times[u]??null),o=a,s=e.times[u]??null)}),{column:t.column,name:lh(t),kind:m_(t.column,t.values,t.unit),total:n,peak:r,peakTime:i,latest:o,latestTime:s}})}const Dt=e=>new Date(e).toISOString(),b_=(e,t)=>Dt(e).slice(0,10)===Dt(t).slice(0,10);function i1(e){const t=e.times[0],n=e.times[e.times.length-1];if(t==null||n==null)return"no points";if(e.daily)return t===n?`${Dt(t).slice(0,10)} UTC`:`${Dt(t).slice(0,10)} to ${Dt(n).slice(0,10)} UTC`;const r=i=>`${Dt(i).slice(0,10)} ${Dt(i).slice(11,16)}`;return t===n?`${r(t)} UTC`:b_(t,n)?`${r(t)} to ${Dt(n).slice(11,16)} UTC`:`${r(t)} to ${r(n)} UTC`}function o1(e,t=new Set){const n=e.times.map((u,c)=>e.series.some(l=>l.values[c]!=null)),r=n.filter(Boolean).length,i=e.rowCounts.reduce((u,c,l)=>u+(n[l]?c:0),0),o=[i1(e),`${Ci.format(r)} ${r===1?"point":"points"}${i>r?` from ${Ci.format(i)} transfers`:""}`],s=e.times[0]??0,a=e.times[e.times.length-1]??0;for(const u of r1(e)){if(t.has(u.column))continue;if(u.peak==null||u.peakTime==null){o.push(`${u.name}: no values`);continue}const c=d=>e.daily?`on ${Dt(d).slice(0,10)}`:b_(s,a)?`at ${Dt(d).slice(11,19)}`:`at ${Dt(d).slice(0,10)} ${Dt(d).slice(11,16)}`,l=`peak ${fi(u.peak,u.kind)} ${c(u.peakTime)}`;u.kind==="eth"&&u.latestTime!=null?o.push(`${u.name}: latest ${fi(u.latest,u.kind)} ${c(u.latestTime)}, ${l}`):o.push(`${u.name}: total ${fi(u.total,u.kind)}, ${l}`)}return e.failures.length&&o.push(`no answer for ${e.failures.map(u=>`${u.day} (${u.code})`).join(", ")}`),o.join(" · ")}function s1(e,t){if(e.length===0)return-1;let n=0,r=e.length-1;for(;n<r;){const i=n+r>>1;(e[i]??0)<t?n=i+1:r=i}return n>0&&Math.abs(t-(e[n-1]??0))<=Math.abs((e[n]??0)-t)?n-1:n}function a1(e,t,n){const r=Math.min(t,n),i=Math.max(t,n);let o=-1,s=-1;return e.forEach((a,u)=>{a<r||a>i||(o<0&&(o=u),s=u)}),o>=0&&s-o>=1?{start:o,end:s}:null}function u1(e,t,n){const r=Math.max(0,t),i=Math.min(e.times.length-1,n)+1,o=e.times.slice(r,i),s=o[0]??0,a=o[o.length-1]??0;return{...e,times:o,rowCounts:e.rowCounts.slice(r,i),series:e.series.map(u=>({...u,values:u.values.slice(r,i)})),failures:e.failures.filter(u=>u.time>=s&&u.time<=a)}}function c1(e,t,n){if(e.has(t)){const r=new Set(e);return r.delete(t),r}return n.filter(r=>!e.has(r)).length<=1?e:new Set([...e,t])}const w_=e=>`var(--cia-graph-series-${e%LA+1})`;function $s(e,t){const n=e.last-e.first,r=e.plotRight-e.plotLeft;return n>0?e.plotLeft+(t-e.first)/n*r:e.plotLeft+r/2}function xu(e,t){const n=e.plotRight-e.plotLeft,r=Math.min(e.plotRight,Math.max(e.plotLeft,t));return n>0?e.first+(r-e.plotLeft)/n*(e.last-e.first):e.first}function __(e,t){return e.plotBottom-(t-e.min)/(e.max-e.min||1)*(e.plotBottom-e.plotTop)}function l1(e){if(e<=1)return DA;const t=Math.floor((zA-di.top-h_-p_-(e-1)*f_)/e)-gc;return Math.max(MA,Math.min(OA,t))}const d1=6.6,f1=3,h1=12;function p1(e){let t=0;for(const n of e)t+=/[.,\s]/.test(n)?f1:d1;return t}function m1(e){const t=e.reduce((n,r)=>Math.max(n,p1(r)),0);return Math.max(di.left,Math.ceil(t+h1))}function Hp(e,t=mc,n=new Set){const r=e.series.map((m,y)=>({series:m,index:y})).filter(({series:m})=>!n.has(m.column)),i=r.map(({series:m})=>{const y=m.values.filter(w=>w!=null),b=Math.min(0,...y),g=Math.max(...y,b+1e-9);return{min:b,max:g,kind:m_(m.column,m.values,m.unit)}}),o=m1(i.flatMap(({min:m,max:y,kind:b})=>[Es(m,b),Es(y,b)])),s=t-di.right,a=e.times[0]??0,u=e.times[e.times.length-1]??a,c={plotLeft:o,plotRight:s,first:a,last:u},l=l1(r.length),d=r.map(({series:m,index:y},b)=>{const g=di.top+b*(gc+l+f_),w=g+gc,v=w+l,{min:_,max:k,kind:x}=i[b],N={plotTop:w,plotBottom:v,min:_,max:k},M=[],F=[];let B=[];return m.values.forEach((ee,ce)=>{if(ee==null){B.length&&F.push(B),B=[];return}const me=e.times[ce]??a,$e={x:$s(c,me),y:__(N,ee),time:me,value:ee,index:ce};M.push($e),B.push($e)}),B.length&&F.push(B),{column:m.column,name:lh(m),index:y,kind:x,color:w_(y),top:g,plotTop:w,plotBottom:v,min:_,max:k,runs:F,points:M}}),f=(d[d.length-1]?.plotBottom??di.top)+h_,h=v_(u-a),p=[];if(e.times.length){const m=t1(a,u,(s-o)/QA[h]);for(const y of m.times){const b=$s(c,y),g=b-o<34?"start":s-b<34?"end":"middle";p.push({x:b,label:n1(y,m.unit,m.step),anchor:g})}}return{width:t,height:f+p_,plotLeft:o,plotRight:s,first:a,last:u,unit:h,lanes:d,ticks:p,axisY:f}}function ot(e,t,n={}){const r=e.createElementNS(NA,t);for(const[i,o]of Object.entries(n))r.setAttribute(i,String(o));return r}const qt=e=>Math.round(e*10)/10;let g1=0;const y1="Time series plot. Left and Right arrows read the points one by one, Home and End jump to the ends, Escape hides the read-out. Drag across the plot to zoom.";function v1(e,t,n={}){const r=e.ownerDocument,i=t.series.map(I=>I.column),o={start:0,end:t.times.length-1};let s=new Set,a=o,u=null,c=null,l=mc,d=t,f=Hp(t,l);const h=A(r,"span",{class:"cv-muted cv-chart-summary","data-chart-summary":""}),p=t.series.map((I,z)=>{const G=A(r,"span",{class:"cv-chart-key","aria-hidden":"true"});G.style.setProperty("--cv-key",w_(z));const fe=A(r,"button",{type:"button",class:"cv-chart-series","data-series":I.column,"aria-pressed":"true"},G,A(r,"span",{text:lh(I)}));return fe.addEventListener("click",()=>{const ie=c1(s,I.column,i);ie!==s&&(s=ie,F())}),fe}),m=A(r,"div",{class:"cv-chart-legend",role:"group","aria-label":"Show or hide a series"},...p),y=A(r,"button",{type:"button",class:"cv-chart-reset","data-reset-zoom":"",hidden:!0,text:"Reset zoom"}),b=ot(r,"svg",{class:"cv-chart-svg",role:"img",preserveAspectRatio:"xMidYMid meet"}),g=A(r,"div",{class:"cv-chart-readout",id:`cv-chart-readout-${++g1}`,"data-chart-readout":"",role:"status","aria-live":"polite",hidden:!0}),w=A(r,"div",{class:"cv-chart-plot",tabindex:0,role:"group","aria-label":y1,"aria-describedby":g.id},b),v=A(r,"div",{class:"cv-chart-body"},w,g),_=ot(r,"rect",{class:"cv-chart-brush"}),k=ot(r,"g",{class:"cv-chart-cross","aria-hidden":"true"}),x=[t.omittedColumns.length?`${t.omittedColumns.length} more number ${t.omittedColumns.length===1?"column is":"columns are"} only in the table: ${t.omittedColumns.join(", ")}.`:"",t.skippedRows?`${t.skippedRows} ${t.skippedRows===1?"row has":"rows have"} no usable ${t.xColumn} and ${t.skippedRows===1?"is":"are"} only in the table.`:""].filter(Boolean),N=A(r,"section",{class:"cv-chart cia-graph-surface","data-view":"chart","aria-label":`Time series by ${t.xColumn}`},A(r,"header",{class:"cv-flows-head"},A(r,"div",{class:"cv-title"},A(r,"strong",{text:"Time series"}),h)),x.length?A(r,"p",{class:"cv-note",role:"note","data-chart-note":"",text:x.join(" ")}):null,A(r,"div",{class:"cv-chart-bar"},m,y,n.toggle??null),v);e.replaceChildren(N);function M(){const I=[],z=f.lanes[0]?.plotTop??0,G=d.times.length>1?(f.plotRight-f.plotLeft)/(d.times.length-1):24,fe=Math.max(6,Math.min(24,G*.6));for(const Y of d.failures){const oe=$s(f,Y.time),he=ot(r,"rect",{class:"cv-chart-failure","data-failure":Y.day,x:qt(oe-fe/2),y:z,width:qt(fe),height:Math.max(0,f.axisY-z)});I.push(he)}for(const Y of f.lanes){const oe=ot(r,"g",{class:"cv-chart-lane","data-series":Y.column}),he=ot(r,"rect",{class:"cv-chart-swatch",x:f.plotLeft,y:Y.top+4,width:14,height:4,rx:2});he.style.fill=Y.color;const Ae=ot(r,"text",{class:"cv-chart-name",x:f.plotLeft+20,y:Y.top+11});Ae.textContent=Y.name,oe.append(he,Ae,ot(r,"line",{class:"cv-chart-grid",x1:f.plotLeft,x2:f.plotRight,y1:Y.plotTop,y2:Y.plotTop}),ot(r,"line",{class:"cv-chart-base",x1:f.plotLeft,x2:f.plotRight,y1:Y.plotBottom,y2:Y.plotBottom}));const O=ot(r,"text",{class:"cv-chart-tick",x:f.plotLeft-8,y:Y.plotTop+4,"text-anchor":"end"});O.textContent=Es(Y.max,Y.kind);const j=ot(r,"text",{class:"cv-chart-tick",x:f.plotLeft-8,y:Y.plotBottom+4,"text-anchor":"end"});j.textContent=Es(Y.min,Y.kind),oe.append(O,j);for(const q of Y.runs){if(q.length<2)continue;const J=ot(r,"polyline",{class:"cv-chart-line",points:q.map(Te=>`${qt(Te.x)},${qt(Te.y)}`).join(" "),fill:"none"});J.style.stroke=Y.color,oe.append(J)}if(Y.points.length<=FA)for(const q of Y.points){const J=ot(r,"circle",{class:"cv-chart-dot",cx:qt(q.x),cy:qt(q.y),r:3,"data-index":a.start+q.index,"data-time":q.time});J.style.fill=Y.color,oe.append(J)}I.push(oe)}const ie=ot(r,"g",{class:"cv-chart-axis"});for(const Y of f.ticks){const oe=ot(r,"text",{class:"cv-chart-tick",x:qt(Y.x),y:f.axisY+14,"text-anchor":Y.anchor});oe.textContent=Y.label,ie.append(oe)}return I.push(ie),I}function F(){d=u1(t,a.start,a.end),f=Hp(d,l,s);const I=f.lanes.map(G=>G.name);b.setAttribute("viewBox",`0 0 ${f.width} ${f.height}`),b.setAttribute("aria-label",`Line chart of ${I.join(", ")} by ${t.xColumn}, ${d.times.length} ${d.times.length===1?"point":"points"}`),b.replaceChildren(_,...M(),k),h.textContent=o1(d,s);for(const G of p){const fe=!s.has(G.dataset.series??"");G.setAttribute("aria-pressed",String(fe)),fe&&I.length===1?(G.setAttribute("aria-disabled","true"),G.title="At least one series stays visible"):(G.removeAttribute("aria-disabled"),G.removeAttribute("title"))}const z=a.start!==o.start||a.end!==o.end;y.hidden=!z,N.dataset.zoomed=String(z),B(),ee()}function B(){if(!c||Math.abs(c.to-c.from)<Zp){_.style.display="none";return}const I=f.lanes[0]?.plotTop??0,z=Math.max(f.plotLeft,Math.min(c.from,c.to)),G=Math.min(f.plotRight,Math.max(c.from,c.to));_.setAttribute("x",String(qt(z))),_.setAttribute("width",String(qt(Math.max(0,G-z)))),_.setAttribute("y",String(I)),_.setAttribute("height",String(Math.max(0,f.axisY-I))),_.style.display=""}function ee(){if(k.replaceChildren(),u==null||u<a.start||u>a.end){u=null,k.style.display="none",g.hidden=!0,g.replaceChildren(),delete w.dataset.focus;return}const I=u-a.start,z=d.times[I]??f.first,G=qt($s(f,z)),fe=f.lanes[0]?.plotTop??0;k.append(ot(r,"line",{class:"cv-chart-crossline",x1:G,x2:G,y1:fe,y2:f.axisY}));const ie=[];for(const he of f.lanes){const Ae=d.series[he.index]?.values[I]??null;if(Ae!=null){const j=ot(r,"circle",{class:"cv-chart-focus",cx:G,cy:qt(__(he,Ae)),r:4.5});j.style.fill=he.color,k.append(j)}const O=A(r,"span",{class:"cv-chart-key","aria-hidden":"true"});O.style.setProperty("--cv-key",he.color),ie.push(A(r,"dt",{},O,he.name),A(r,"dd",{"data-value":he.column,text:fi(Ae,he.kind)}))}k.style.display="",k.dataset.index=String(u),k.dataset.time=String(z),w.dataset.focus=String(u);const Y=d.failures.find(he=>he.time===z),oe=d.rowCounts[I]??1;g.replaceChildren(...[A(r,"time",{datetime:new Date(z).toISOString(),text:KA(z,d.daily)}),Y?A(r,"p",{class:"cv-chart-readout-note","data-failure":Y.code,text:`No answer: ${Y.code}`}):null,oe>1?A(r,"p",{class:"cv-chart-readout-note","data-rows":oe,text:`${Ci.format(oe)} transfers`}):null,A(r,"dl",{},...ie)].filter(he=>he!=null)),g.hidden=!1,ce(G,fe)}function ce(I,z){const G=b.getBoundingClientRect(),fe=v.getBoundingClientRect(),ie=G.width>0?G.width/f.width:1,Y=G.left-fe.left+I*ie,oe=I>(f.plotLeft+f.plotRight)/2;g.style.left=`${Math.round(oe?Y-12:Y+12)}px`,g.style.top=`${Math.round(G.top-fe.top+z*ie)}px`,g.dataset.side=oe?"left":"right"}const me=I=>{const z=b.getBoundingClientRect();return z.width>0?(I-z.left)*f.width/z.width:Number.NaN},$e=I=>a.start+s1(d.times,xu(f,I));w.addEventListener("pointermove",I=>{const z=me(I.clientX);Number.isFinite(z)&&(c&&(c.to=z,B()),u=$e(z),ee())}),w.addEventListener("pointerdown",I=>{if(I.button!==0)return;const z=me(I.clientX);if(Number.isFinite(z)){I.preventDefault(),w.focus({preventScroll:!0}),c={from:z,to:z,pointer:I.pointerId};try{w.setPointerCapture(I.pointerId)}catch{}}});const U=I=>{if(!c)return;const{from:z,to:G,pointer:fe}=c;c=null;try{w.releasePointerCapture(fe)}catch{}if(B(),!I||Math.abs(G-z)<Zp)return;const ie=a1(t.times,xu(f,z),xu(f,G));!ie||ie.start===a.start&&ie.end===a.end||(a=ie,u=$e(G),F())};w.addEventListener("pointerup",()=>U(!0)),w.addEventListener("pointercancel",()=>U(!1)),w.addEventListener("pointerleave",()=>{c||(u=null,ee())}),w.addEventListener("keydown",I=>{let z;if(I.key==="ArrowRight")z=u==null?a.start:Math.min(a.end,u+1);else if(I.key==="ArrowLeft")z=u==null?a.end:Math.max(a.start,u-1);else if(I.key==="Home")z=a.start;else if(I.key==="End")z=a.end;else if(I.key==="Escape"){if(u==null&&!c)return;c&&U(!1),z=null}else return;I.preventDefault(),u=z,ee()}),y.addEventListener("click",()=>{a=o,u=null,F(),w.focus({preventScroll:!0})});const H=()=>{const I=Math.round(w.clientWidth);return I>0?Math.max(RA,I):null},K=()=>{const I=H();I==null||I===l||(l=I,F())};l=H()??mc,F();const de=r.defaultView?.ResizeObserver,te=de?new de(()=>K()):null;return te?.observe(w),{root:N,get layout(){return f},refit:K,destroy(){te?.disconnect()}}}const b1="chain-insights.transfers.v1",w1="graph_expand",k_=25;function _1(e,t,n,r,i={}){const o=i.cursor??{day:r,skip:0};return{network:e,from:t,to:n,day:o.day,...o.skip?{skip:o.skip}:{},...i.firstDay?{first_day:i.firstDay}:{},limit:i.limit??k_}}function k1(e,t){const n=typeof e.first_seen_timestamp=="number"&&e.first_seen_timestamp>0?cs(e.first_seen_timestamp):null,r=typeof e.last_seen_timestamp=="number"&&e.last_seen_timestamp>0?cs(e.last_seen_timestamp):cs(t);return{first:n,last:n&&r<n?n:r}}function S1(e){if(!e)return"no answer";const t=Wr(e);return e.isError?t||"the server refused the read":/query_timeout|topology_busy/.test(t)?t:S_(e.structuredContent)?null:t||"the answer held no transfers"}function S_(e){const t=e;if(!t||t.schema!==b1||!Array.isArray(t.transfers)||typeof t.from!="string"||typeof t.to!="string"||!xs(t.day))return null;const n=[];for(const o of t.transfers){if(!o||typeof o!="object")continue;const s=o;if(typeof s.tx_id!="string")continue;const a=Qt(s.block_timestamp);n.push({tx_id:s.tx_id,block_timestamp:a,amount:typeof s.amount=="string"?s.amount:typeof s.amount=="number"?String(s.amount):null,asset_symbol:typeof s.asset_symbol=="string"&&s.asset_symbol?s.asset_symbol:null,amount_usd:Qt(s.amount_usd)})}const r=t.next,i=r&&typeof r=="object"&&xs(r.day)?{day:r.day,skip:Math.max(0,Math.floor(Qt(r.skip)??0))}:null;return{network:typeof t.network=="string"?t.network:null,from:t.from,to:t.to,day:t.day,transfers:n,truncated:t.truncated===!0,next:i}}function x1(e){return[...e].sort((t,n)=>(n.block_timestamp??0)-(t.block_timestamp??0)||t.tx_id.localeCompare(n.tx_id))}function E1(e){if(e==null)return"—";const t=e.trim().match(/^(-?)(\d+)(?:\.(\d+))?$/);if(!t)return e;const[,n="",r="0",i=""]=t,o=i.replace(/0+$/,"");return`${n}${r.replace(/\B(?=(\d{3})+(?!\d))/g,",")}${o?`.${o}`:""}`}function $1(e){return e==null?"—":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:e!==0&&Math.abs(e)<.01?6:2}).format(e)}function T1(e){return e==null?"—":`${new Date(ah(e)).toISOString().slice(11,19)} UTC`}function Eu(e){return new Intl.DateTimeFormat("en-GB",{dateStyle:"medium",timeZone:"UTC"}).format(new Date(`${e}T00:00:00Z`))}function C1(e,t){const n=new Map;for(const r of e){const i=r.block_timestamp==null?t:cs(r.block_timestamp);n.has(i)||n.set(i,[]),n.get(i).push(r)}return[...n.entries()].sort(([r],[i])=>i.localeCompare(r)).map(([r,i])=>({day:r,transfers:i}))}function A1(e,t){const n=t.now??Date.now,r=A(e,"strong",{"data-link-title":"",text:"Transfers"}),i=A(e,"button",{type:"button",class:"cv-button cv-icon","data-link-close":"","aria-label":"Close the transfers",text:"×"}),o=A(e,"p",{class:"cv-link-pair","data-link-pair":""}),s=A(e,"div",{class:"cv-link-body","data-link-body":"",role:"status","aria-live":"polite"}),a=A(e,"button",{type:"button",class:"cv-button","data-link-more":"",text:"More transfers"}),u=A(e,"section",{class:"cv-linkpanel cv-linkpanel-embedded","data-link-panel":"","aria-label":"Transfers of the selected link",hidden:!0},A(e,"header",{class:"cv-link-head"},r,null),o,s,a);let c=null,l=0;function d(){if(!c){u.hidden=!0;return}u.hidden=!1,o.replaceChildren(A(e,"code",{"data-link-from":"",text:c.from})," → ",A(e,"code",{"data-link-to":"",text:c.to}));const y=c.transfers.length;r.textContent=y?`Transfers · ${y} listed`:"Transfers",a.hidden=!c.next||c.status==="error",a.disabled=c.status==="loading",a.textContent=c.status==="loading"&&c.pages?"Loading…":"More transfers",a.setAttribute("aria-label",c.next?`More transfers: the ${k_} before ${Eu(c.next.day)}`:"More transfers");const b=[];if(y)for(const g of C1(c.transfers,c.day))b.push(A(e,"p",{class:"cv-link-day","data-link-day":g.day,text:`${Eu(g.day)} (UTC)`})),b.push(A(e,"ol",{class:"cv-transfers"},...g.transfers.map(w=>I1(e,w,t.host))));c.status==="loading"?b.push(A(e,"p",{class:"cv-muted","data-link-loading":"",text:y?"Loading older transfers…":`Loading the transfers from ${Eu(c.day)} back…`})):c.status==="error"?b.push(A(e,"p",{class:"cv-link-error","data-link-error":"",role:"alert",text:c.error??"The transfers could not be read."})):y||b.push(A(e,"p",{class:"cv-muted","data-link-empty":"",text:"No transfers between these two addresses in the days read."})),c.status==="ready"&&c.truncated&&b.push(A(e,"p",{class:"cv-muted","data-link-truncated":"",text:"A day held more transfers than one read lists; its oldest are not shown."})),c.status==="ready"&&!c.next&&y&&b.push(A(e,"p",{class:"cv-muted","data-link-first":"",text:c.firstDay?"Every transfer back to the day the link was first seen is listed.":"No older transfers were found."})),s.replaceChildren(...b)}async function f(y){const b=++l,g=c;g.status="loading",g.error=null,d(),t.onLayout?.();let w=null;try{w=await t.host.callServerTool({name:w1,arguments:_1(t.network,g.from,g.to,g.day,{firstDay:g.firstDay,cursor:y})})}catch(_){w={isError:!0,content:[{type:"text",text:_ instanceof Error?_.message:String(_)}]}}if(b!==l||c!==g)return g;const v=S1(w);if(v)g.status="error",g.error=v.length>300?`${v.slice(0,299)}…`:v;else{const _=S_(w.structuredContent),k=new Set(g.transfers.map(x=>x.tx_id+String(x.block_timestamp)));g.status="ready",g.transfers=[...g.transfers,...x1(_.transfers).filter(x=>!k.has(x.tx_id+String(x.block_timestamp)))],g.truncated=g.truncated||_.truncated,g.next=_.next,g.pages+=1}return d(),t.onLayout?.(),g}const h=()=>m.close(),p=()=>{m.more()};i.addEventListener("click",h),a.addEventListener("click",p);const m={element:u,open(y){const b=k1(y,n());return c={from:y.from,to:y.to,day:b.last,firstDay:b.first,status:"loading",transfers:[],next:null,pages:0,truncated:!1,error:null},f(null)},async more(){return!c||c.status==="loading"||!c.next?null:f(c.next)},close(){l++,c=null,d(),t.onLayout?.()},state:()=>c?{...c,transfers:[...c.transfers]}:null,destroy(){l++,i.removeEventListener("click",h),a.removeEventListener("click",p)}};return m}function I1(e,t,n){const r=Yw(t.tx_id),i=n.openLink,o=r&&i?A(e,"button",{type:"button",class:"cia-graph-explorer-link","data-explorer":r,"aria-label":`Transaction ${t.tx_id} (opens the explorer)`,title:t.tx_id,text:xi(t.tx_id)}):A(e,"code",{title:t.tx_id,text:xi(t.tx_id)});return r&&i&&o.addEventListener("click",()=>{i.call(n,{url:r}).catch(()=>{})}),A(e,"li",{class:"cv-transfer","data-tx":t.tx_id},A(e,"span",{class:"cv-transfer-time",text:T1(t.block_timestamp)}),A(e,"span",{class:"cv-transfer-amount",text:`${E1(t.amount)}${t.asset_symbol?` ${t.asset_symbol}`:""}`}),A(e,"span",{class:"cv-transfer-usd",text:t.amount_usd==null?"— USD":$1(t.amount_usd)}),o)}const N1="chain-insights.refusal.v1",R1=.2;function si(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function hi(e){const t=typeof e=="number"?e:typeof e=="string"?Number(e):NaN;return Number.isFinite(t)?t:null}function L1(e){return(e?.content??[]).filter(t=>t.type==="text").map(t=>t.text??"").join(`
|
|
110
|
-
`)}function x_(e){const t=si(e);if(!t)return null;const n=si(t.facts);return si(n?.usage)??si(t.usage)}function Vp(e){if(!e?.isError)return null;const t=si(e.structuredContent);if(t&&t.schema===N1){const r=x_(t);if(t.code==="free_tier_spent")return{kind:"free_tier_spent",used:hi(r?.daily_units_used),limit:hi(r?.daily_units_limit),resetAt:typeof r?.reset_at=="string"?r.reset_at:null};if(t.code==="payment_failed")return{kind:"payment_failed"}}const n=L1(e);if(/free tier for today is used up|free units/i.test(n)){const r=/([\d,]+) of ([\d,]+) free units/.exec(n),i=/resets at (\d{4}-\d{2}-\d{2} \d{2}:\d{2}) UTC/.exec(n),o=s=>s==null?null:Number(s.replace(/,/g,""));return{kind:"free_tier_spent",used:o(r?.[1]),limit:o(r?.[2]),resetAt:i?.[1]?`${i[1].replace(" ","T")}:00Z`:null}}return/x402 payment failed|insufficient_funds|payment required|\b402\b/i.test(n)?{kind:"payment_failed"}:null}function E_(e,t){if(!e)return"midnight UTC";const n=Date.parse(e);return Number.isFinite(n)?new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit"}).format(new Date(n)):"midnight UTC"}const pi=e=>e==null?null:new Intl.NumberFormat("en-US").format(e);function qp(e,t){return e.kind==="payment_failed"?"This call is paid and the wallet could not pay for it. Run `cia wallet ready` in a terminal to see what it needs.":`Out of free credits: ${e.used!=null&&e.limit!=null?`${pi(e.used)} of ${pi(e.limit)} free units used today`:"every free unit used today"}. They are back at ${E_(e.resetAt)} your time. Until then each click is a paid call.`}function z1(e){if(!e||e.isError)return null;const t=x_(e.structuredContent);if(!t||t.access_mode!=="public_free")return null;const n=hi(t.daily_units_used),r=hi(t.daily_units_limit);if(n==null||r==null||r<=0)return null;const i=hi(t.remaining_units)??Math.max(0,r-n);return{used:n,limit:r,remaining:i,resetAt:typeof t.reset_at=="string"?t.reset_at:null,warn:i/r<R1,spent:i<=0}}function P1(e,t){return e.spent?`Free credits today: 0 of ${pi(e.limit)} left, back at ${E_(e.resetAt)} your time`:`Free credits today: ${pi(e.remaining)} of ${pi(e.limit)} left`}const Wp="graph_expand",D1="meta_usage_status",Yo="too busy to expand",$_=640,O1=300,$u=.45,M1="Full screen shows the whole graph",F1="Open in browser",Tu="The host did not open the link.",U1="If nothing opened, copy this link into your browser:",Kp=400,G1=9e3,Cu="expanded",T_=5e3,j1="Click an address for its details. Double-click it to load its senders and receivers, and again to fold them back. Click a link to list its transfers.",Z1="chain-insights.address.v1";function B1(e,t){return{network:e,address:t,details:!0}}function H1(e){const t=e;if(!t||t.schema!==Z1||typeof t.address!="string")return null;const n=i=>typeof i=="number"&&Number.isFinite(i)?i:null,r={address:t.address.toLowerCase(),total_in_usd:n(t.total_in_usd),total_out_usd:n(t.total_out_usd),degree_in:n(t.degree_in),degree_out:n(t.degree_out)};return Array.isArray(t.labels)&&(r.labels=t.labels.filter(i=>typeof i=="string")),typeof t.role=="string"&&qr.includes(t.role)&&(r.role=t.role),r}function V1(e){return e.total_in_usd==null&&e.total_out_usd==null&&e.degree_in==null&&e.degree_out==null}const yc=new Intl.NumberFormat("en-US");function Jp(e){const t=e.remaining;if(!t||typeof t!="object")return null;const n=Number(t.senders),r=Number(t.receivers);return!Number.isFinite(n)||!Number.isFinite(r)?null:{senders:Math.max(0,n),receivers:Math.max(0,r)}}function q1(e){if(!e||e.senders+e.receivers<=0)return null;const t=(n,r)=>`${yc.format(n)} more ${r}${n===1?"":"s"}`;return`${t(e.senders,"sender")}, ${t(e.receivers,"receiver")} not loaded`}function W1(e,t,n=T_){return`Not loaded: ${yc.format(e)} ${e===1?"link":"links"} of ${t} would take the picture past ${yc.format(n)} addresses. Fold another address to make room.`}const Yp=e=>!!(e&&(e.truncated||e.remaining&&e.remaining.senders+e.remaining.receivers>0));let K1=0;const J1=[["scam","Scam"],["sanctioned","Sanctioned"],["exchange","Exchange"],["victim","Victim"],["pool","Pool"],["other","Other"]];function dh(e){return typeof e=="string"&&/^http:\/\/(?:127\.0\.0\.1|localhost):\d+(?:[/?#]|$)/.test(e)}function Y1(e){return!e.browser&&!!e.host.openLink&&dh(e.viewUrl)}function X1(e,t,n){return{network:e,address:t,in_offset:n?.in_offset??0,out_offset:n?.out_offset??0}}function Q1(e){const t=Wr(e);return e?e.isError?t||"the server refused the expansion":/query_timeout|topology_busy/.test(t)?t:rh(e.structuredContent)?null:t||"the answer held no money flows":"no answer"}function eI(e,t,n,r=$_,i=O1){if(!e||t<=0)return{height:r,fits:!0};const o=Math.max(1,e.x2-e.x1),s=Math.max(1,e.y2-e.y1),a=Math.max($u,Math.min(1,(t-Si*2)/o)),u=Math.ceil(n+s*a+Si*2),c=Math.min(r,Math.max(i,u));return Ep(e,t,c-n)>=$u?{height:c,fits:!0}:{height:r,fits:Ep(e,t,r-n)>=$u}}function tI(e){return/query_timeout|topology_busy|timed? ?out/i.test(e)}function Xp(e){const t=e.split(`
|
|
110
|
+
`)}function x_(e){const t=si(e);if(!t)return null;const n=si(t.facts);return si(n?.usage)??si(t.usage)}function Vp(e){if(!e?.isError)return null;const t=si(e.structuredContent);if(t&&t.schema===N1){const r=x_(t);if(t.code==="free_tier_spent")return{kind:"free_tier_spent",used:hi(r?.daily_units_used),limit:hi(r?.daily_units_limit),resetAt:typeof r?.reset_at=="string"?r.reset_at:null};if(t.code==="payment_failed")return{kind:"payment_failed"}}const n=L1(e);if(/free tier for today is used up|free units/i.test(n)){const r=/([\d,]+) of ([\d,]+) free units/.exec(n),i=/resets at (\d{4}-\d{2}-\d{2} \d{2}:\d{2}) UTC/.exec(n),o=s=>s==null?null:Number(s.replace(/,/g,""));return{kind:"free_tier_spent",used:o(r?.[1]),limit:o(r?.[2]),resetAt:i?.[1]?`${i[1].replace(" ","T")}:00Z`:null}}return/x402 payment failed|insufficient_funds|payment required|\b402\b/i.test(n)?{kind:"payment_failed"}:null}function E_(e,t){if(!e)return"midnight UTC";const n=Date.parse(e);return Number.isFinite(n)?new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit"}).format(new Date(n)):"midnight UTC"}const pi=e=>e==null?null:new Intl.NumberFormat("en-US").format(e);function qp(e,t){return e.kind==="payment_failed"?"This call is paid and the wallet could not pay for it. Run `cia wallet ready` in a terminal to see what it needs.":`Out of free credits: ${e.used!=null&&e.limit!=null?`${pi(e.used)} of ${pi(e.limit)} free units used today`:"every free unit used today"}. They are back at ${E_(e.resetAt)} your time. Until then each click is a paid call.`}function z1(e){if(!e||e.isError)return null;const t=x_(e.structuredContent);if(!t||t.access_mode!=="public_free")return null;const n=hi(t.daily_units_used),r=hi(t.daily_units_limit);if(n==null||r==null||r<=0)return null;const i=hi(t.remaining_units)??Math.max(0,r-n);return{used:n,limit:r,remaining:i,resetAt:typeof t.reset_at=="string"?t.reset_at:null,warn:i/r<R1,spent:i<=0}}function P1(e,t){return e.spent?`Free credits today: 0 of ${pi(e.limit)} left, back at ${E_(e.resetAt)} your time`:`Free credits today: ${pi(e.remaining)} of ${pi(e.limit)} left`}const Wp="graph_expand",D1="meta_usage_status",Yo="too busy to expand",$_=640,O1=300,$u=.45,M1="Full screen shows the whole graph",F1="Open in browser",Tu="The host did not open the link.",U1="If nothing opened, copy this link into your browser:",Kp=400,G1=9e3,Cu="expanded",T_=5e3,j1="Click an address for its details. Double-click it to load its senders and receivers, and again to fold them back. Click a link to list its transfers.",Z1="chain-insights.address.v1";function B1(e,t){return{network:e,address:t,details:!0}}function H1(e){const t=e;if(!t||t.schema!==Z1||typeof t.address!="string")return null;const n=i=>typeof i=="number"&&Number.isFinite(i)?i:null,r={address:t.address.toLowerCase(),total_in_usd:n(t.total_in_usd),total_out_usd:n(t.total_out_usd),degree_in:n(t.degree_in),degree_out:n(t.degree_out)};return Array.isArray(t.labels)&&(r.labels=t.labels.filter(i=>typeof i=="string")),typeof t.role=="string"&&qr.includes(t.role)&&(r.role=t.role),r}function V1(e){return e.total_in_usd==null&&e.total_out_usd==null&&e.degree_in==null&&e.degree_out==null}const yc=new Intl.NumberFormat("en-US");function Jp(e){const t=e.remaining;if(!t||typeof t!="object")return null;const n=Number(t.senders),r=Number(t.receivers);return!Number.isFinite(n)||!Number.isFinite(r)?null:{senders:Math.max(0,n),receivers:Math.max(0,r)}}function q1(e){if(!e||e.senders+e.receivers<=0)return null;const t=(n,r)=>`${yc.format(n)} more ${r}${n===1?"":"s"}`;return`${t(e.senders,"sender")}, ${t(e.receivers,"receiver")} not loaded`}function W1(e,t,n=T_){return`Not loaded: ${yc.format(e)} ${e===1?"link":"links"} of ${t} would take the picture past ${yc.format(n)} addresses. Fold another address to make room.`}const Yp=e=>!!(e&&(e.truncated||e.remaining&&e.remaining.senders+e.remaining.receivers>0));let K1=0;const J1=[["scam","Scam"],["sanctioned","Sanctioned"],["exchange","Exchange"],["victim","Victim"],["pool","Pool"],["self_trader","Self-trading contract"],["other","Other"]];function dh(e){return typeof e=="string"&&/^http:\/\/(?:127\.0\.0\.1|localhost):\d+(?:[/?#]|$)/.test(e)}function Y1(e){return!e.browser&&!!e.host.openLink&&dh(e.viewUrl)}function X1(e,t,n){return{network:e,address:t,in_offset:n?.in_offset??0,out_offset:n?.out_offset??0}}function Q1(e){const t=Wr(e);return e?e.isError?t||"the server refused the expansion":/query_timeout|topology_busy/.test(t)?t:rh(e.structuredContent)?null:t||"the answer held no money flows":"no answer"}function eI(e,t,n,r=$_,i=O1){if(!e||t<=0)return{height:r,fits:!0};const o=Math.max(1,e.x2-e.x1),s=Math.max(1,e.y2-e.y1),a=Math.max($u,Math.min(1,(t-Si*2)/o)),u=Math.ceil(n+s*a+Si*2),c=Math.min(r,Math.max(i,u));return Ep(e,t,c-n)>=$u?{height:c,fits:!0}:{height:r,fits:Ep(e,t,r-n)>=$u}}function tI(e){return/query_timeout|topology_busy|timed? ?out/i.test(e)}function Xp(e){const t=e.split(`
|
|
111
111
|
`)[0].trim();return t.length>200?`${t.slice(0,199)}…`:t}function nI(e,t){return`investigator expanded ${e}: ${t} new addresses`}function rI(e,t){const n=e.nodes.find(r=>r.address.toLowerCase()===t.toLowerCase());return n&&Do({role:n.role??null,labels:n.labels??[]})||"Other"}function C_(e,t,n){const r=e.ownerDocument,i=t.network??"robinhood",o=t.center.toLowerCase(),s=n.maxAddresses??T_,a=()=>new Map(t.cursor?[[o,{cursor:t.cursor,truncated:!!t.truncated,remaining:Jp(t)}]]:[]);let u=a();const c=new Set,l=new Set;let d=[];const f=new Set;let h=null,p=null;const m=n.now??Date.now,y=n.title??"Money flow graph",b=A(r,"p",{class:"cv-status",role:"status","aria-live":"polite",text:j1}),g=A(r,"div",{class:"cv-toast",role:"alert","data-toast":"",hidden:!0});let w=null;function v(L){w&&clearTimeout(w),g.textContent=L,g.hidden=!1,w=setTimeout(()=>{g.hidden=!0,w=null},G1)}const _=A(r,"span",{class:"cv-usage","data-usage":"",hidden:!0});async function k(){if(n.usageMeter===!1)return;let L=null;try{L=await n.host.callServerTool({name:D1,arguments:{}})}catch{L=null}const X=z1(L);_.hidden=!X,X&&(_.textContent=P1(X),_.classList.toggle("cv-usage--warn",X.warn&&!X.spent),_.classList.toggle("cv-usage--spent",X.spent))}const x=A(r,"p",{class:"cv-side-note","data-side-note":"",hidden:!0});function N(L){x.hidden=!L,x.textContent=L??""}const M=A(r,"ul",{class:"cv-roles","aria-label":"Address roles"}),F=A(r,"div",{class:"cv-canvas","data-graph":""}),B=A(r,"div",{class:"cv-detail","aria-label":"Selection"},A(r,"strong",{"data-selection-title":""}),A(r,"code",{"data-selection-identity":""}),A(r,"div",{class:"cv-detail-meta","data-selection-meta":""})),ee=A(r,"strong",{"data-side-title":"",text:"Details"}),ce=A(r,"button",{type:"button",class:"cv-button cv-icon","data-side-close":"","aria-label":"Close the details",text:"×"}),me=A(r,"button",{type:"button",class:"cv-button","data-toggle-expand":"",hidden:!0,text:"Expand"}),$e=A(r,"button",{type:"button",class:"cv-button","data-more":"",hidden:!0,text:"More flows"}),U=A(r,"p",{class:"cv-remaining cv-muted","data-remaining":"",hidden:!0}),H=A1(r,{host:n.host,network:i,now:n.now,embedded:!0,onLayout:()=>xt()}),K=A(r,"aside",{class:"cv-side","data-side-panel":"","aria-label":"Details of the selection",hidden:!0},A(r,"header",{class:"cv-side-head"},ee,ce),x,B,U,A(r,"div",{class:"cv-side-actions"},me,$e),H.element),de=A(r,"button",{type:"button",class:"cv-button","data-fullscreen":"",hidden:!0,"aria-label":"Open full screen",text:"Full screen"}),te=A(r,"button",{type:"button",class:"cv-button","data-reset":"","aria-label":"Reset: fold every expansion back and draw the first answer again",title:"Fold every expansion back and draw the first answer again",text:"Reset"}),I=A(r,"span",{class:"cv-hint","data-fullscreen-hint":"",hidden:!0,text:M1}),z=A(r,"button",{type:"button",class:"cv-button","data-open-browser":"",hidden:!Y1(n),"aria-label":"Open the graph in your browser",title:"Open the graph in your browser",text:F1}),G=A(r,"div",{class:"cv-toggle",role:"group","aria-label":"Layout"},A(r,"button",{type:"button",class:"cv-toggle-button","data-layout":"gravity","aria-pressed":"true",title:"Linked addresses pull together; an expansion settles around the address you opened",text:"Gravity"}),A(r,"button",{type:"button",class:"cv-toggle-button","data-layout":"tree","aria-pressed":"false",title:"Senders left, receivers right, newest activity first",text:"Tree"})),fe=A(r,"div",{class:"cv-actions"},G,A(r,"button",{type:"button",class:"cv-button cv-icon","data-zoom":"out","aria-label":"Zoom out",text:"−"}),A(r,"button",{type:"button",class:"cv-button cv-icon","data-zoom":"in","aria-label":"Zoom in",text:"+"}),A(r,"button",{type:"button",class:"cv-button","data-zoom":"fit","aria-label":"Fit the graph",text:"Fit"}),te,I,de,z),ie=A(r,"span",{class:"cv-muted","data-subtitle":""}),Y=`cv-addresses-${++K1}`,oe=A(r,"div",{class:"cv-visually-hidden",role:"listbox",tabindex:"0",id:Y,"data-address-list":"","aria-label":"Drawn addresses. Down and Up move, Enter shows the details, Shift+Enter expands or folds."});let he=[],Ae=-1;const O=A(r,"section",{class:"cv-flows cia-graph-surface","data-view":"flows","aria-label":`${y} of ${o}`},A(r,"header",{class:"cv-flows-head"},A(r,"div",{class:"cv-title"},A(r,"strong",{text:y}),ie,_),n.toggle??null,fe),M,n.note?A(r,"p",{class:"cv-note",role:"note","data-left-out":"",text:n.note}):null,A(r,"div",{class:"cv-body"},oe,F,K,g),b);e.replaceChildren(O);function j(){const L=ke.model(),X=L.truncated?" · more flows than shown":"";ie.textContent=`${o} · ${rI(t,o)} · ${i} · ${L.nodes.length} addresses${X}`;const ge=new Set(L.nodes.map(je=>je.role??"other")),Me=J1.filter(([je])=>je!=="other"&&ge.has(je));M.hidden=Me.length===0,M.replaceChildren(...Me.map(([je,nt])=>{const Ze=A(r,"i",{"aria-hidden":"true"});return Ze.style.background=`var(--cia-graph-role-${je})`,A(r,"li",{"data-role":je},Ze,nt)})),q()}function q(){const L=ke.model().nodes,X=he[Ae]??null;he=L.map(Me=>Me.address.toLowerCase()),oe.replaceChildren(...L.map((Me,je)=>A(r,"div",{role:"option",id:`${Y}-${je}`,"data-list-address":he[je],"aria-selected":"false",text:`${Me.address} ${Do({role:Me.role??null,labels:Me.labels??[]})||"Other"}`})));const ge=X?he.indexOf(X):-1;Ae=ge>=0?ge:he.length?Math.min(Math.max(Ae,-1),he.length-1):-1,J()}function J(){for(const X of oe.children)X.setAttribute("aria-selected",String(X.id===`${Y}-${Ae}`));Ae>=0?oe.setAttribute("aria-activedescendant",`${Y}-${Ae}`):oe.removeAttribute("aria-activedescendant");const L=r.activeElement===oe;ke.highlight(L?he[Ae]??null:null)}function Te(L){return L?ke.model().nodes.find(X=>X.id===L)?.address.toLowerCase()??null:null}const se=L=>{const X=L.target,ge=L.key==="Enter"||L.key===" ",Me=X?.closest?.("[data-node-id]");if(ge&&L.shiftKey&&Me){L.preventDefault();const je=Te(Me.dataset.nodeId);je&&Oo(je)}};F.addEventListener("keydown",se,!0);function ye(L){he.length&&(Ae=Math.max(0,Math.min(he.length-1,L)),J())}const Oe=()=>{Ae<0&&he.length&&(Ae=0),J()},ae=()=>ke.highlight(null),ze=L=>{const X=he[Ae];switch(L.key){case"ArrowDown":L.preventDefault(),ye(Ae+1);return;case"ArrowUp":L.preventDefault(),ye(Ae-1);return;case"Home":L.preventDefault(),ye(0);return;case"End":L.preventDefault(),ye(he.length-1);return;case"Escape":lu();return;case"Enter":case" ":if(L.preventDefault(),!X)return;L.shiftKey?Oo(X):ke.select(X);return}};oe.addEventListener("focus",Oe),oe.addEventListener("blur",ae),oe.addEventListener("keydown",ze);function qe(){const L=p;if(!L){me.hidden=!0,$e.hidden=!0,U.hidden=!0;return}const X=f.has(L),ge=X?q1(u.get(L)?.remaining??null):null;U.hidden=!ge,U.textContent=ge??"",me.hidden=!1,me.disabled=c.has(L)||l.has(L),me.textContent=c.has(L)?"Too busy to expand":X?"Collapse":"Expand",me.setAttribute("aria-label",`${me.textContent} ${L}`),$e.hidden=!(X&&Yp(u.get(L)))}function tt(L){const X=K.hidden;if(K.hidden=L.kind==null,L.kind==="node"&&L.node){const ge=L.node.address.toLowerCase();ge!==p&&N(null),p=ge,ee.textContent="Address details",H.close(),V1(L.node)&&St(p)}else p=null,N(null),L.kind==="edge"?ee.textContent="Link details":H.close();qe(),X!==K.hidden&&xt()}const Ye=new Set;async function St(L){if(Ye.has(L))return;Ye.add(L);let X=null;try{X=await n.host.callServerTool({name:Wp,arguments:B1(i,L)})}catch(nt){X={isError:!0,content:[{type:"text",text:nt instanceof Error?nt.message:String(nt)}]}}const ge=X&&!X.isError?H1(X.structuredContent):null;if(!ge){Ye.delete(L);const nt=Vp(X),Ze=nt?qp(nt):Xp(X&&Wr(X)||"no answer");b.textContent=`The totals of ${L} could not be read: ${Ze}`,p===L&&N(`The totals could not be read. ${Ze}`),v(Ze),k();return}k();const{address:Me,...je}=ge;ke.patchNode(L,je)&&p===L&&ke.select(L)}let T=null;function D(){T&&clearTimeout(T),T=null}function ne(L){const X=L.source==="pointer"&&L.kind==="node"&&L.node,ge=L.source!=="program"&&L.kind==="edge"&&L.edge;if(D(),X){const Me=L.node.address.toLowerCase(),je=m();h&&h.address===Me&&je-h.at<=Kp?(h=null,lu(),Oo(Me)):(h={address:Me,at:je},T=setTimeout(()=>{T=null,tt(L)},Kp));return}L.kind!=="node"&&(h=null),tt(L),ge&&H.open(L.edge)}const Se=n.height??$_,ve=`${y} of ${o}: senders on the left, receivers on the right. Select an address for its details; double-click it, or press Shift+Enter, to load its senders and receivers, and again to fold them back. Select a link to list its transfers.`;function dt(){return GC(F,t,{layout:n.layout??"gravity",width:n.width??720,height:Se,now:n.now,controls:fe,selectionRoot:B,onSelect:ne,openLink:L=>{n.host.openLink?.({url:L}).catch(()=>{b.textContent=Tu})},label:ve})}let ke=dt();j(),k();let yt=n.displayMode??"inline",nr=n.availableDisplayModes??[];const Dn=()=>!n.browser&&!!n.host.requestDisplayMode&&(nr.length===0||nr.includes("fullscreen"));function xt(){if(yt==="fullscreen"){O.style.removeProperty("height"),I.hidden=!0;return}const L=F.clientWidth||n.width||720,X=Math.max(0,O.offsetHeight-F.offsetHeight)||140,{height:ge,fits:Me}=eI(ke.contentBounds(),L,X);O.style.height=`${ge}px`,I.hidden=Me||!Dn(),O.dataset.fits=String(Me),ke.fit()}async function Ht(L){try{await n.host.updateModelContext?.({content:[{type:"text",text:L}]})}catch{}}async function Vt(L,X=!1){const ge=L.toLowerCase();if(c.has(ge))return b.textContent=`${ge} is ${Yo}.`,{added:[],refused:Yo};if(l.has(ge))return{added:[],refused:null};const Me=u.get(ge);if(Me&&!Yp(Me))return b.textContent=`Every recent flow of ${ge} is drawn.`,{added:[],refused:null};l.add(ge),qe(),b.textContent=`Loading the flows of ${ge}…`;let je=null;try{je=await n.host.callServerTool({name:Wp,arguments:X1(i,ge,X||Me?Me?.cursor:null)})}catch(ft){je={isError:!0,content:[{type:"text",text:ft instanceof Error?ft.message:String(ft)}]}}finally{l.delete(ge)}const nt=Q1(je);if(nt){if(tI(nt))c.add(ge),ke.markNode(ge,Yo),b.textContent=`${ge} is ${Yo}. The drawing is kept.`;else{const ft=Vp(je),Mn=ft?qp(ft):Xp(nt);b.textContent=`${ge} could not be expanded: ${Mn} The drawing is kept; try again.`,v(Mn),k()}return qe(),{added:[],refused:nt}}const Ze=je.structuredContent,du=ke.model(),On=new Set(du.nodes.map(ft=>ft.address.toLowerCase())),fu=new Set;for(const ft of Ze.nodes)On.has(ft.address.toLowerCase())||fu.add(ft.address.toLowerCase());for(const ft of Ze.edges)for(const Mn of[ft.from,ft.to])On.has(Mn.toLowerCase())||fu.add(Mn.toLowerCase());if(On.size+fu.size>s){const ft=new Set(du.edges.map(Fn=>`${Fn.from.toLowerCase()}->${Fn.to.toLowerCase()}`)),Mn=new Set(Ze.edges.map(Fn=>`${Fn.from.toLowerCase()}->${Fn.to.toLowerCase()}`).filter(Fn=>!ft.has(Fn))).size,$h=W1(Mn,ge,s);return b.textContent=$h,qe(),{added:[],refused:$h}}const Mo=ke.merge(Ze,ge);return d.push({address:ge,page:Ze}),f.add(ge),ke.flagNode(ge,Cu,!0),u.set(ge,{cursor:Ze.cursor??null,truncated:!!Ze.truncated,remaining:Jp(Ze)}),j(),xt(),qe(),b.textContent=`${Mo.length} new ${Mo.length===1?"address":"addresses"} linked to ${ge}. Double-click it again to fold them back.`,k(),await Ht(nI(ge,Mo.length)),{added:Mo,refused:null}}function vh(L){const X=L.toLowerCase();if(!f.has(X))return{removed:0};const ge=ke.model().nodes.length;f.delete(X),u.delete(X);const Me=d.filter(Ze=>Ze.address!==X),je=[];ke.batch(()=>{ke.flagNode(X,Cu,!1),ke.update(t);for(const Ze of Me)ke.model().nodes.some(On=>On.address.toLowerCase()===Ze.address)?(ke.merge(Ze.page,Ze.address),je.push(Ze)):je.some(On=>On.address===Ze.address)||(ke.flagNode(Ze.address,Cu,!1),f.delete(Ze.address),u.delete(Ze.address))}),d=je;const nt=Math.max(0,ge-ke.model().nodes.length);return p&&!ke.model().nodes.some(Ze=>Ze.address.toLowerCase()===p)&&(K.hidden=!0,p=null),j(),xt(),qe(),b.textContent=`Folded ${X} back: ${nt} ${nt===1?"address":"addresses"} removed.`,Ht(`investigator collapsed ${X}: ${nt} addresses removed`),{removed:nt}}async function Oo(L){f.has(L)?vh(L):await Vt(L)}function bh(){D(),ke.destroy(),d=[],f.clear(),c.clear(),l.clear(),u=a(),Ye.clear(),h=null,p=null,H.close(),K.hidden=!0,ke=dt(),j(),xt(),qe(),b.textContent="The first answer again: every expansion folded back."}function uu(L,X){L&&(yt=L),X&&(nr=X),O.dataset.displayMode=yt,de.hidden=!Dn(),de.textContent=yt==="fullscreen"?"Exit full screen":"Full screen",de.setAttribute("aria-label",yt==="fullscreen"?"Back to the inline view":"Open full screen"),xt()}uu(yt);const wh=async()=>{const L=yt==="fullscreen"?"inline":"fullscreen";try{const X=await n.host.requestDisplayMode?.({mode:L});uu(X?.mode??L)}catch{b.textContent="The host did not change the display mode."}},cu=(L,X)=>{b.replaceChildren(A(r,"span",{text:`${L} `}),A(r,"code",{class:"cv-view-link","data-view-link":"",text:X}))},_h=async()=>{const L=n.viewUrl;if(!(!dh(L)||!n.host.openLink)){cu(U1,L);try{(await n.host.openLink({url:L}))?.isError===!0&&cu(Tu,L)}catch{cu(Tu,L)}}},kh=()=>bh();function lu(){D();const L=!K.hidden;ke.select(null),H.close(),K.hidden=!0,p=null,qe(),L&&xt()}const Sh=()=>lu(),xh=()=>{p&&Oo(p)},Eh=()=>{p&&Vt(p,!0)};return de.addEventListener("click",wh),z.addEventListener("click",_h),te.addEventListener("click",kh),ce.addEventListener("click",Sh),me.addEventListener("click",xh),$e.addEventListener("click",Eh),{root:O,get graph(){return ke},expand:L=>Vt(L),collapse:vh,reset:bh,expanded:()=>[...f],setLayout:L=>ke.setLayout(L),linkPanel:H,openLink(L,X){const ge=ke.model().edges.find(Me=>Me.from===L.toLowerCase()&&Me.to===X.toLowerCase());return ge?(ke.select(ge.id),H.open(ge)):Promise.resolve(null)},setTheme(L){ke.setTheme(L)},setDisplayMode:uu,refit:xt,destroy(){D(),w&&clearTimeout(w),F.removeEventListener("keydown",se,!0),oe.removeEventListener("focus",Oe),oe.removeEventListener("blur",ae),oe.removeEventListener("keydown",ze),de.removeEventListener("click",wh),z.removeEventListener("click",_h),te.removeEventListener("click",kh),ce.removeEventListener("click",Sh),me.removeEventListener("click",xh),$e.removeEventListener("click",Eh),H.destroy(),ke.destroy()}}}function vc(e){return{kind:e,flows:()=>[],setTheme(){},setDisplayMode(){},refit(){},destroy(){}}}function iI(e,t){return{kind:e,flows:()=>{const n=t();return n?[n]:[]},setTheme(n){t()?.setTheme(n)},setDisplayMode(n,r){t()?.setDisplayMode(n,r)},refit(){t()?.refit()},destroy(){t()?.destroy()}}}const A_=e=>({host:e.host,availableDisplayModes:e.availableDisplayModes,displayMode:e.displayMode,now:e.now,width:e.width,height:e.height,viewUrl:e.browser?null:e.viewUrl??null,browser:e.browser===!0});function oI(e){return typeof e?.query=="string"&&e.query?e.query:null}function sI(e,t,n){const r=Array.isArray(e?.queries)?e.queries:[],i=s=>{const a=s?.query;return typeof a=="string"&&a?a:null},o=r.find(s=>s?.id===t);return i(o||r[n])}function aI(e,t){const n=e.structuredContent;if(!t||!n?.facts?.query)return e;const r=pA(nu(n),t);return r?{...e,structuredContent:{...n,facts:{...n.facts,query:{...n.facts.query,results:r}}}}:e}function uI(e,t){if(e<=0)return null;const n=new Intl.NumberFormat("en-US");return`${n.format(e)} of ${n.format(t)} rows ${e===1?"is":"are"} not drawn: a graph holds at most ${n.format(t_)} addresses. The table has the rows.`}function cI(e,t,n){const r=[];let i="picture";const o=s=>{for(const a of s.querySelectorAll("[data-show]"))a.setAttribute("aria-pressed",String(a.dataset.show===i))};return{make(){const s=A(e,"button",{type:"button",class:"cv-toggle-button","data-show":"picture",text:t}),a=A(e,"button",{type:"button",class:"cv-toggle-button","data-show":"table",text:"Table"});s.addEventListener("click",()=>n("picture")),a.addEventListener("click",()=>n("table"));const u=A(e,"div",{class:"cv-toggle",role:"group","aria-label":"Show the rows as"},s,a);return r.push(u),o(u),u},set(s){i=s,r.forEach(o)}}}function lI(e,t){const n=t?.facts?.subject;return{content:[],structuredContent:{schema:tu,tool:"graph_query",facts:{...n?{subject:n}:{},query:{results:e,count:e.length,truncated:!1}}}}}function dI(e){const t=s_(e.structuredContent);if(t)return{model:t.model,table:lI(t.rows,e.structuredContent)};const n=uh(nu(e.structuredContent));return n?{model:n,table:e}:null}function I_(e,t,n,r=null){const i=e.ownerDocument,o=aI(t,r),s=l_(o),a=s==="chart"?dI(o):null;if(s!=="graph"&&!a)return s==="table"?Up(e,o):Ti(e,o),vc(s==="table"?"table":"text");const u=o.structuredContent,c=nu(u),l=a?.table??t,d=A(i,"div",{class:"cv-face","data-face":"picture"}),f=A(i,"div",{class:"cv-face","data-face":"table",hidden:!0});e.replaceChildren(d,f);const h=cI(i,s==="graph"?"Graph":"Chart",g=>b(g));let p=null,m=null,y=-1;if(s==="graph"){const g=vA(c,HC(u),a_(r)?.address);p=C_(d,g.view,{...A_(n),title:"Money flow graph",toggle:h.make(),note:uI(g.rowsLeftOut,g.rowsTotal)})}else m=v1(d,a.model,{toggle:h.make()});function b(g){if(d.hidden=g!=="picture",f.hidden=g!=="table",g==="table"){const w=p?.expanded().length?p.graph.model():null,v=w?w.nodes.length*100003+w.edges.length:0;y!==v&&(y=v,Up(f,w?fI(w,l):l,{toggle:h.make()}))}h.set(g),g==="picture"&&(p?.refit(),m?.refit())}return{kind:s,flows:()=>p?[p]:[],setTheme(g){p?.setTheme(g)},setDisplayMode(g,w){p?.setDisplayMode(g,w)},refit(){d.hidden||(p?.refit(),m?.refit())},destroy(){p?.destroy(),m?.destroy()}}}function fI(e,t){const n=new Map(e.nodes.map(o=>[o.address,o.labels??[]])),r=e.edges.map(o=>({from_address:o.from,to_address:o.to,amount_usd_sum:o.amount_usd_sum,tx_count:o.tx_count,first_seen_timestamp:o.first_seen_timestamp,last_seen_timestamp:o.last_seen_timestamp,from_labels:n.get(o.from)??[],to_labels:n.get(o.to)??[]})),i=t.structuredContent?.facts?.subject;return{content:[],structuredContent:{schema:tu,tool:"graph_query",facts:{...i?{subject:i}:{},query:{results:r,count:r.length,truncated:!!e.truncated,elapsed_ms:null}}}}}function hI(e,t){if(!e.ok)return{isError:!0,content:[{type:"text",text:e.error??"The query failed."}]};const n=t?.facts?.subject;return{content:[],structuredContent:{schema:tu,tool:"graph_query",facts:{...n?{subject:n}:{},query:{results:e.rows,count:e.count??e.rows.length,truncated:e.truncated,elapsed_ms:e.elapsedMs}}}}}function pI(e,t,n){const r=e.ownerDocument,i=u_(t.structuredContent),o=i.map((p,m)=>A(r,"button",{type:"button",role:"tab",class:"cv-tab",id:`cv-tab-${m}`,"data-tab":p.id,"aria-controls":`cv-panel-${m}`,"aria-selected":"false",tabindex:-1,text:p.ok?p.id:`${p.id} (failed)`})),s=i.map((p,m)=>A(r,"div",{class:"cv-tabpanel",role:"tabpanel",id:`cv-panel-${m}`,"aria-labelledby":`cv-tab-${m}`,hidden:!0})),a=A(r,"div",{class:"cv-tabs",role:"tablist","aria-label":"Queries of the batch"},...o);e.replaceChildren(a,...s);const u=i.map(()=>null);let c=n.displayMode,l=n.availableDisplayModes,d=-1;const f=()=>e.style.setProperty("--cv-tabs-h",`${a.offsetHeight}px`);function h(p){const m=i[p],y=s[p];if(!m||!y)return;d=p,o.forEach((g,w)=>{g.setAttribute("aria-selected",String(w===p)),g.tabIndex=w===p?0:-1}),s.forEach((g,w)=>{g.hidden=w!==p});const b=u[p];if(b)b.refit();else{const g=m.query??sI(n.toolInput,m.id,p),w=I_(y,hI(m,t.structuredContent),{...n,displayMode:c,availableDisplayModes:l},g);u[p]=w,y.dataset.view=w.kind}f()}return o.forEach((p,m)=>{p.addEventListener("click",()=>h(m)),p.addEventListener("keydown",y=>{const b=o.length-1,g=y.key==="ArrowRight"?m===b?0:m+1:y.key==="ArrowLeft"?m===0?b:m-1:y.key==="Home"?0:y.key==="End"?b:null;g!=null&&(y.preventDefault(),h(g),o[g]?.focus())})}),h(0),{kind:"batch",flows:()=>u.flatMap(p=>p?.flows()??[]),setTheme(p){for(const m of u)m?.setTheme(p)},setDisplayMode(p,m){p&&(c=p),m&&(l=m);for(const y of u)y?.setDisplayMode(p,m);f()},refit(){d>=0&&u[d]?.refit()},destroy(){for(const p of u)p?.destroy()}}}function mI(e){const t=e?.structuredContent?.view_url;return dh(t)?t:null}function N_(e,t,n){const r={...n,viewUrl:n.viewUrl??mI(t)},i=l_(t);if(i==="flows"){const o=C_(e,t.structuredContent,A_(r));return iI("flows",()=>o)}return i==="graph"||i==="chart"||i==="table"?I_(e,t,r,oI(r.toolInput)):i==="batch"?pI(e,t,r):i==="balance"?(IA(e,t),vc("balance")):(Ti(e,t),vc("text"))}function gI(e){return e==="light"||e==="dark"}function yI(e,t=()=>!1){return gI(e?.theme)?e.theme:t()?"dark":"light"}function Au(e,t){const n={...e??{},...t??{}};return(e?.styles||t?.styles)&&(n.styles={...e?.styles??{},...t?.styles??{},variables:{...e?.styles?.variables??{},...t?.styles?.variables??{}}}),n}function Ts(e,t,n={}){const r=e.documentElement,i=yI(t,n.prefersDark);r.setAttribute("data-theme",i),r.style.colorScheme=i;const o=t?.styles?.variables;o&&n.applyVariables&&n.applyVariables(o,r);const s=t?.styles?.css?.fonts;return s&&n.applyFonts&&n.applyFonts(s),i}function vI(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Xo={exports:{}},Qp;function bI(){if(Qp)return Xo.exports;Qp=1;var e=typeof Reflect=="object"?Reflect:null,t=e&&typeof e.apply=="function"?e.apply:function(_,k,x){return Function.prototype.apply.call(_,k,x)},n;e&&typeof e.ownKeys=="function"?n=e.ownKeys:Object.getOwnPropertySymbols?n=function(_){return Object.getOwnPropertyNames(_).concat(Object.getOwnPropertySymbols(_))}:n=function(_){return Object.getOwnPropertyNames(_)};function r(v){console&&console.warn&&console.warn(v)}var i=Number.isNaN||function(_){return _!==_};function o(){o.init.call(this)}Xo.exports=o,Xo.exports.once=b,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(v){if(typeof v!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof v)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(v){if(typeof v!="number"||v<0||i(v))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+v+".");s=v}}),o.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(_){if(typeof _!="number"||_<0||i(_))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+_+".");return this._maxListeners=_,this};function u(v){return v._maxListeners===void 0?o.defaultMaxListeners:v._maxListeners}o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(_){for(var k=[],x=1;x<arguments.length;x++)k.push(arguments[x]);var N=_==="error",M=this._events;if(M!==void 0)N=N&&M.error===void 0;else if(!N)return!1;if(N){var F;if(k.length>0&&(F=k[0]),F instanceof Error)throw F;var B=new Error("Unhandled error."+(F?" ("+F.message+")":""));throw B.context=F,B}var ee=M[_];if(ee===void 0)return!1;if(typeof ee=="function")t(ee,this,k);else for(var ce=ee.length,me=p(ee,ce),x=0;x<ce;++x)t(me[x],this,k);return!0};function c(v,_,k,x){var N,M,F;if(a(k),M=v._events,M===void 0?(M=v._events=Object.create(null),v._eventsCount=0):(M.newListener!==void 0&&(v.emit("newListener",_,k.listener?k.listener:k),M=v._events),F=M[_]),F===void 0)F=M[_]=k,++v._eventsCount;else if(typeof F=="function"?F=M[_]=x?[k,F]:[F,k]:x?F.unshift(k):F.push(k),N=u(v),N>0&&F.length>N&&!F.warned){F.warned=!0;var B=new Error("Possible EventEmitter memory leak detected. "+F.length+" "+String(_)+" listeners added. Use emitter.setMaxListeners() to increase limit");B.name="MaxListenersExceededWarning",B.emitter=v,B.type=_,B.count=F.length,r(B)}return v}o.prototype.addListener=function(_,k){return c(this,_,k,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(_,k){return c(this,_,k,!0)};function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(v,_,k){var x={fired:!1,wrapFn:void 0,target:v,type:_,listener:k},N=l.bind(x);return N.listener=k,x.wrapFn=N,N}o.prototype.once=function(_,k){return a(k),this.on(_,d(this,_,k)),this},o.prototype.prependOnceListener=function(_,k){return a(k),this.prependListener(_,d(this,_,k)),this},o.prototype.removeListener=function(_,k){var x,N,M,F,B;if(a(k),N=this._events,N===void 0)return this;if(x=N[_],x===void 0)return this;if(x===k||x.listener===k)--this._eventsCount===0?this._events=Object.create(null):(delete N[_],N.removeListener&&this.emit("removeListener",_,x.listener||k));else if(typeof x!="function"){for(M=-1,F=x.length-1;F>=0;F--)if(x[F]===k||x[F].listener===k){B=x[F].listener,M=F;break}if(M<0)return this;M===0?x.shift():m(x,M),x.length===1&&(N[_]=x[0]),N.removeListener!==void 0&&this.emit("removeListener",_,B||k)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(_){var k,x,N;if(x=this._events,x===void 0)return this;if(x.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):x[_]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete x[_]),this;if(arguments.length===0){var M=Object.keys(x),F;for(N=0;N<M.length;++N)F=M[N],F!=="removeListener"&&this.removeAllListeners(F);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(k=x[_],typeof k=="function")this.removeListener(_,k);else if(k!==void 0)for(N=k.length-1;N>=0;N--)this.removeListener(_,k[N]);return this};function f(v,_,k){var x=v._events;if(x===void 0)return[];var N=x[_];return N===void 0?[]:typeof N=="function"?k?[N.listener||N]:[N]:k?y(N):p(N,N.length)}o.prototype.listeners=function(_){return f(this,_,!0)},o.prototype.rawListeners=function(_){return f(this,_,!1)},o.listenerCount=function(v,_){return typeof v.listenerCount=="function"?v.listenerCount(_):h.call(v,_)},o.prototype.listenerCount=h;function h(v){var _=this._events;if(_!==void 0){var k=_[v];if(typeof k=="function")return 1;if(k!==void 0)return k.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function p(v,_){for(var k=new Array(_),x=0;x<_;++x)k[x]=v[x];return k}function m(v,_){for(;_+1<v.length;_++)v[_]=v[_+1];v.pop()}function y(v){for(var _=new Array(v.length),k=0;k<_.length;++k)_[k]=v[k].listener||v[k];return _}function b(v,_){return new Promise(function(k,x){function N(F){v.removeListener(_,M),x(F)}function M(){typeof v.removeListener=="function"&&v.removeListener("error",N),k([].slice.call(arguments))}w(v,_,M,{once:!0}),_!=="error"&&g(v,N,{once:!0})})}function g(v,_,k){typeof v.on=="function"&&w(v,"error",_,k)}function w(v,_,k,x){if(typeof v.on=="function")x.once?v.once(_,k):v.on(_,k);else if(typeof v.addEventListener=="function")v.addEventListener(_,function N(M){x.once&&v.removeEventListener(_,N),k(M)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof v)}return Xo.exports}var R_=bI();function wI(){const e=arguments[0];for(let t=1,n=arguments.length;t<n;t++)if(arguments[t])for(const r in arguments[t])e[r]=arguments[t][r];return e}let Xe=wI;typeof Object.assign=="function"&&(Xe=Object.assign);function Ft(e,t,n,r){const i=e._nodes.get(t);let o=null;return i&&(r==="mixed"?o=i.out&&i.out[n]||i.undirected&&i.undirected[n]:r==="directed"?o=i.out&&i.out[n]:o=i.undirected&&i.undirected[n]),o}function st(e){return typeof e=="object"&&e!==null}function L_(e){let t;for(t in e)return!1;return!0}function zt(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function Wt(e,t,n){const r={enumerable:!0,configurable:!0};typeof n=="function"?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(e,t,r)}function em(e){return!(!st(e)||e.attributes&&!Array.isArray(e.attributes))}function _I(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function un(){const e=arguments;let t=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(t===null){if(n++,n>=e.length)return{done:!0};t=e[n][Symbol.iterator]()}if(r=t.next(),r.done){t=null;continue}break}while(!0);return r}}}function Kr(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class fh extends Error{constructor(t){super(),this.name="GraphError",this.message=t}}class W extends fh{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,W.prototype.constructor)}}class Z extends fh{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Z.prototype.constructor)}}class ue extends fh{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,ue.prototype.constructor)}}function z_(e,t){this.key=e,this.attributes=t,this.clear()}z_.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function P_(e,t){this.key=e,this.attributes=t,this.clear()}P_.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function D_(e,t){this.key=e,this.attributes=t,this.clear()}D_.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Jr(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}Jr.prototype.attach=function(){let e="out",t="in";this.undirected&&(e=t="undirected");const n=this.source.key,r=this.target.key;this.source[e][r]=this,!(this.undirected&&n===r)&&(this.target[t][n]=this)};Jr.prototype.attachMulti=function(){let e="out",t="in";const n=this.source.key,r=this.target.key;this.undirected&&(e=t="undirected");const i=this.source[e],o=i[r];if(typeof o>"u"){i[r]=this,this.undirected&&n===r||(this.target[t][n]=this);return}o.previous=this,this.next=o,i[r]=this,this.target[t][n]=this};Jr.prototype.detach=function(){const e=this.source.key,t=this.target.key;let n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][t],delete this.target[r][e]};Jr.prototype.detachMulti=function(){const e=this.source.key,t=this.target.key;let n="out",r="in";this.undirected&&(n=r="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[n][t],delete this.target[r][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[r][e]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const O_=0,M_=1,kI=2,F_=3;function yn(e,t,n,r,i,o,s){let a,u,c,l;if(r=""+r,n===O_){if(a=e._nodes.get(r),!a)throw new Z(`Graph.${t}: could not find the "${r}" node in the graph.`);c=i,l=o}else if(n===F_){if(i=""+i,u=e._edges.get(i),!u)throw new Z(`Graph.${t}: could not find the "${i}" edge in the graph.`);const d=u.source.key,f=u.target.key;if(r===d)a=u.target;else if(r===f)a=u.source;else throw new Z(`Graph.${t}: the "${r}" node is not attached to the "${i}" edge (${d}, ${f}).`);c=o,l=s}else{if(u=e._edges.get(r),!u)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`);n===M_?a=u.source:a=u.target,c=i,l=o}return[a,c,l]}function SI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=yn(this,t,n,r,i,o);return s.attributes[a]}}function xI(e,t,n){e.prototype[t]=function(r,i){const[o]=yn(this,t,n,r,i);return o.attributes}}function EI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=yn(this,t,n,r,i,o);return s.attributes.hasOwnProperty(a)}}function $I(e,t,n){e.prototype[t]=function(r,i,o,s){const[a,u,c]=yn(this,t,n,r,i,o,s);return a.attributes[u]=c,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:u}),this}}function TI(e,t,n){e.prototype[t]=function(r,i,o,s){const[a,u,c]=yn(this,t,n,r,i,o,s);if(typeof c!="function")throw new W(`Graph.${t}: updater should be a function.`);const l=a.attributes,d=c(l[u]);return l[u]=d,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:u}),this}}function CI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=yn(this,t,n,r,i,o);return delete s.attributes[a],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:a}),this}}function AI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=yn(this,t,n,r,i,o);if(!st(a))throw new W(`Graph.${t}: provided attributes are not a plain object.`);return s.attributes=a,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function II(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=yn(this,t,n,r,i,o);if(!st(a))throw new W(`Graph.${t}: provided attributes are not a plain object.`);return Xe(s.attributes,a),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:a}),this}}function NI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=yn(this,t,n,r,i,o);if(typeof a!="function")throw new W(`Graph.${t}: provided updater is not a function.`);return s.attributes=a(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}const RI=[{name:e=>`get${e}Attribute`,attacher:SI},{name:e=>`get${e}Attributes`,attacher:xI},{name:e=>`has${e}Attribute`,attacher:EI},{name:e=>`set${e}Attribute`,attacher:$I},{name:e=>`update${e}Attribute`,attacher:TI},{name:e=>`remove${e}Attribute`,attacher:CI},{name:e=>`replace${e}Attributes`,attacher:AI},{name:e=>`merge${e}Attributes`,attacher:II},{name:e=>`update${e}Attributes`,attacher:NI}];function LI(e){RI.forEach(function({name:t,attacher:n}){n(e,t("Node"),O_),n(e,t("Source"),M_),n(e,t("Target"),kI),n(e,t("Opposite"),F_)})}function zI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new ue(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ue(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,a=""+i;if(i=arguments[2],o=Ft(this,s,a,n),!o)throw new Z(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new ue(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function PI(e,t,n){e.prototype[t]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new ue(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new ue(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+r,s=""+arguments[1];if(i=Ft(this,o,s,n),!i)throw new Z(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new ue(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,i=this._edges.get(r),!i)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function DI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new ue(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ue(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,a=""+i;if(i=arguments[2],o=Ft(this,s,a,n),!o)throw new Z(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new ue(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function OI(e,t,n){e.prototype[t]=function(r,i,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new ue(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new ue(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+r,u=""+i;if(i=arguments[2],o=arguments[3],s=Ft(this,a,u,n),!s)throw new Z(`Graph.${t}: could not find an edge for the given path ("${a}" - "${u}").`)}else{if(n!=="mixed")throw new ue(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,s=this._edges.get(r),!s)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return s.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:i}),this}}function MI(e,t,n){e.prototype[t]=function(r,i,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new ue(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new ue(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+r,u=""+i;if(i=arguments[2],o=arguments[3],s=Ft(this,a,u,n),!s)throw new Z(`Graph.${t}: could not find an edge for the given path ("${a}" - "${u}").`)}else{if(n!=="mixed")throw new ue(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,s=this._edges.get(r),!s)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new W(`Graph.${t}: updater should be a function.`);return s.attributes[i]=o(s.attributes[i]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:i}),this}}function FI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new ue(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ue(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,a=""+i;if(i=arguments[2],o=Ft(this,s,a,n),!o)throw new Z(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new ue(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}function UI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new ue(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ue(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,a=""+i;if(i=arguments[2],o=Ft(this,s,a,n),!o)throw new Z(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new ue(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!st(i))throw new W(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function GI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new ue(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ue(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,a=""+i;if(i=arguments[2],o=Ft(this,s,a,n),!o)throw new Z(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new ue(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!st(i))throw new W(`Graph.${t}: provided attributes are not a plain object.`);return Xe(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function jI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new ue(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new ue(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,a=""+i;if(i=arguments[2],o=Ft(this,s,a,n),!o)throw new Z(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new ue(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new W(`Graph.${t}: provided updater is not a function.`);return o.attributes=i(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const ZI=[{name:e=>`get${e}Attribute`,attacher:zI},{name:e=>`get${e}Attributes`,attacher:PI},{name:e=>`has${e}Attribute`,attacher:DI},{name:e=>`set${e}Attribute`,attacher:OI},{name:e=>`update${e}Attribute`,attacher:MI},{name:e=>`remove${e}Attribute`,attacher:FI},{name:e=>`replace${e}Attributes`,attacher:UI},{name:e=>`merge${e}Attributes`,attacher:GI},{name:e=>`update${e}Attributes`,attacher:jI}];function BI(e){ZI.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}const HI=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function VI(e,t,n,r){let i=!1;for(const o in t){if(o===r)continue;const s=t[o];if(i=n(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),e&&i)return s.key}}function qI(e,t,n,r){let i,o,s,a=!1;for(const u in t)if(u!==r){i=t[u];do{if(o=i.source,s=i.target,a=n(i.key,i.attributes,o.key,s.key,o.attributes,s.attributes,i.undirected),e&&a)return i.key;i=i.next}while(i!==void 0)}}function Iu(e,t){const n=Object.keys(e),r=n.length;let i,o=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(o>=r)return{done:!0};const s=n[o++];if(s===t){i=void 0;continue}i=e[s]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function WI(e,t,n,r){const i=t[n];if(!i)return;const o=i.source,s=i.target;if(r(i.key,i.attributes,o.key,s.key,o.attributes,s.attributes,i.undirected)&&e)return i.key}function KI(e,t,n,r){let i=t[n];if(!i)return;let o=!1;do{if(o=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),e&&o)return i.key;i=i.next}while(i!==void 0)}function Nu(e,t){let n=e[t];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};const i={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:i}}};let r=!1;return{[Symbol.iterator](){return this},next(){return r===!0?{done:!0}:(r=!0,{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}})}}}function JI(e,t){if(e.size===0)return[];if(t==="mixed"||t===e.type)return Array.from(e._edges.keys());const n=t==="undirected"?e.undirectedSize:e.directedSize,r=new Array(n),i=t==="undirected",o=e._edges.values();let s=0,a,u;for(;a=o.next(),a.done!==!0;)u=a.value,u.undirected===i&&(r[s++]=u.key);return r}function U_(e,t,n,r){if(t.size===0)return;const i=n!=="mixed"&&n!==t.type,o=n==="undirected";let s,a,u=!1;const c=t._edges.values();for(;s=c.next(),s.done!==!0;){if(a=s.value,i&&a.undirected!==o)continue;const{key:l,attributes:d,source:f,target:h}=a;if(u=r(l,d,f.key,h.key,f.attributes,h.attributes,a.undirected),e&&u)return l}}function YI(e,t){if(e.size===0)return Kr();const n=t!=="mixed"&&t!==e.type,r=t==="undirected",i=e._edges.values();return{[Symbol.iterator](){return this},next(){let o,s;for(;;){if(o=i.next(),o.done)return o;if(s=o.value,!(n&&s.undirected!==r))break}return{value:{edge:s.key,attributes:s.attributes,source:s.source.key,target:s.target.key,sourceAttributes:s.source.attributes,targetAttributes:s.target.attributes,undirected:s.undirected},done:!1}}}}function hh(e,t,n,r,i,o){const s=t?qI:VI;let a;if(n!=="undirected"&&(r!=="out"&&(a=s(e,i.in,o),e&&a)||r!=="in"&&(a=s(e,i.out,o,r?void 0:i.key),e&&a))||n!=="directed"&&(a=s(e,i.undirected,o),e&&a))return a}function XI(e,t,n,r){const i=[];return hh(!1,e,t,n,r,function(o){i.push(o)}),i}function QI(e,t,n){let r=Kr();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=un(r,Iu(n.in))),t!=="in"&&typeof n.out<"u"&&(r=un(r,Iu(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=un(r,Iu(n.undirected))),r}function ph(e,t,n,r,i,o,s){const a=n?KI:WI;let u;if(t!=="undirected"&&(typeof i.in<"u"&&r!=="out"&&(u=a(e,i.in,o,s),e&&u)||typeof i.out<"u"&&r!=="in"&&(r||i.key!==o)&&(u=a(e,i.out,o,s),e&&u))||t!=="directed"&&typeof i.undirected<"u"&&(u=a(e,i.undirected,o,s),e&&u))return u}function eN(e,t,n,r,i){const o=[];return ph(!1,e,t,n,r,i,function(s){o.push(s)}),o}function tN(e,t,n,r){let i=Kr();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(i=un(i,Nu(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(i=un(i,Nu(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=un(i,Nu(n.undirected,r))),i}function nN(e,t){const{name:n,type:r,direction:i}=t;e.prototype[n]=function(o,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return JI(this,r);if(arguments.length===1){o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new Z(`Graph.${n}: could not find the "${o}" node in the graph.`);return XI(this.multi,r==="mixed"?this.type:r,i,a)}if(arguments.length===2){o=""+o,s=""+s;const a=this._nodes.get(o);if(!a)throw new Z(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new Z(`Graph.${n}: could not find the "${s}" target node in the graph.`);return eN(r,this.multi,i,a,s)}throw new W(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function rN(e,t){const{name:n,type:r,direction:i}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(c,l,d){if(!(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)){if(arguments.length===1)return d=c,U_(!1,this,r,d);if(arguments.length===2){c=""+c,d=l;const f=this._nodes.get(c);if(typeof f>"u")throw new Z(`Graph.${o}: could not find the "${c}" node in the graph.`);return hh(!1,this.multi,r==="mixed"?this.type:r,i,f,d)}if(arguments.length===3){c=""+c,l=""+l;const f=this._nodes.get(c);if(!f)throw new Z(`Graph.${o}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(l))throw new Z(`Graph.${o}: could not find the "${l}" target node in the graph.`);return ph(!1,r,this.multi,i,f,l,d)}throw new W(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){const c=Array.prototype.slice.call(arguments),l=c.pop();let d;if(c.length===0){let f=0;r!=="directed"&&(f+=this.undirectedSize),r!=="undirected"&&(f+=this.directedSize),d=new Array(f);let h=0;c.push((p,m,y,b,g,w,v)=>{d[h++]=l(p,m,y,b,g,w,v)})}else d=[],c.push((f,h,p,m,y,b,g)=>{d.push(l(f,h,p,m,y,b,g))});return this[o].apply(this,c),d};const a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(){const c=Array.prototype.slice.call(arguments),l=c.pop(),d=[];return c.push((f,h,p,m,y,b,g)=>{l(f,h,p,m,y,b,g)&&d.push(f)}),this[o].apply(this,c),d};const u="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[u]=function(){let c=Array.prototype.slice.call(arguments);if(c.length<2||c.length>4)throw new W(`Graph.${u}: invalid number of arguments (expecting 2, 3 or 4 and got ${c.length}).`);if(typeof c[c.length-1]=="function"&&typeof c[c.length-2]!="function")throw new W(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let l,d;c.length===2?(l=c[0],d=c[1],c=[]):c.length===3?(l=c[1],d=c[2],c=[c[0]]):c.length===4&&(l=c[2],d=c[3],c=[c[0],c[1]]);let f=d;return c.push((h,p,m,y,b,g,w)=>{f=l(f,h,p,m,y,b,g,w)}),this[o].apply(this,c),f}}function iN(e,t){const{name:n,type:r,direction:i}=t,o="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(u,c,l){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return l=u,U_(!0,this,r,l);if(arguments.length===2){u=""+u,l=c;const d=this._nodes.get(u);if(typeof d>"u")throw new Z(`Graph.${o}: could not find the "${u}" node in the graph.`);return hh(!0,this.multi,r==="mixed"?this.type:r,i,d,l)}if(arguments.length===3){u=""+u,c=""+c;const d=this._nodes.get(u);if(!d)throw new Z(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(c))throw new Z(`Graph.${o}: could not find the "${c}" target node in the graph.`);return ph(!0,r,this.multi,i,d,c,l)}throw new W(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const s="some"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){const u=Array.prototype.slice.call(arguments),c=u.pop();return u.push((d,f,h,p,m,y,b)=>c(d,f,h,p,m,y,b)),!!this[o].apply(this,u)};const a="every"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(){const u=Array.prototype.slice.call(arguments),c=u.pop();return u.push((d,f,h,p,m,y,b)=>!c(d,f,h,p,m,y,b)),!this[o].apply(this,u)}}function oN(e,t){const{name:n,type:r,direction:i}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(s,a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Kr();if(!arguments.length)return YI(this,r);if(arguments.length===1){s=""+s;const u=this._nodes.get(s);if(!u)throw new Z(`Graph.${o}: could not find the "${s}" node in the graph.`);return QI(r,i,u)}if(arguments.length===2){s=""+s,a=""+a;const u=this._nodes.get(s);if(!u)throw new Z(`Graph.${o}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(a))throw new Z(`Graph.${o}: could not find the "${a}" target node in the graph.`);return tN(r,i,u,a)}throw new W(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function sN(e){HI.forEach(t=>{nN(e,t),rN(e,t),iN(e,t),oN(e,t)})}const aN=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function ru(){this.A=null,this.B=null}ru.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};ru.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function ei(e,t,n,r,i){for(const o in r){const s=r[o],a=s.source,u=s.target,c=a===n?u:a;if(t&&t.has(c.key))continue;const l=i(c.key,c.attributes);if(e&&l)return c.key}}function mh(e,t,n,r,i){if(t!=="mixed"){if(t==="undirected")return ei(e,null,r,r.undirected,i);if(typeof n=="string")return ei(e,null,r,r[n],i)}const o=new ru;let s;if(t!=="undirected"){if(n!=="out"){if(s=ei(e,null,r,r.in,i),e&&s)return s;o.wrap(r.in)}if(n!=="in"){if(s=ei(e,o,r,r.out,i),e&&s)return s;o.wrap(r.out)}}if(t!=="directed"&&(s=ei(e,o,r,r.undirected,i),e&&s))return s}function uN(e,t,n){if(e!=="mixed"){if(e==="undirected")return Object.keys(n.undirected);if(typeof t=="string")return Object.keys(n[t])}const r=[];return mh(!1,e,t,n,function(i){r.push(i)}),r}function ti(e,t,n){const r=Object.keys(n),i=r.length;let o=0;return{[Symbol.iterator](){return this},next(){let s=null;do{if(o>=i)return e&&e.wrap(n),{done:!0};const a=n[r[o++]],u=a.source,c=a.target;if(s=u===t?c:u,e&&e.has(s.key)){s=null;continue}}while(s===null);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}}}}function cN(e,t,n){if(e!=="mixed"){if(e==="undirected")return ti(null,n,n.undirected);if(typeof t=="string")return ti(null,n,n[t])}let r=Kr();const i=new ru;return e!=="undirected"&&(t!=="out"&&(r=un(r,ti(i,n,n.in))),t!=="in"&&(r=un(r,ti(i,n,n.out)))),e!=="directed"&&(r=un(r,ti(i,n,n.undirected))),r}function lN(e,t){const{name:n,type:r,direction:i}=t;e.prototype[n]=function(o){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new Z(`Graph.${n}: could not find the "${o}" node in the graph.`);return uN(r==="mixed"?this.type:r,i,s)}}function dN(e,t){const{name:n,type:r,direction:i}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(c,l){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;c=""+c;const d=this._nodes.get(c);if(typeof d>"u")throw new Z(`Graph.${o}: could not find the "${c}" node in the graph.`);mh(!1,r==="mixed"?this.type:r,i,d,l)};const s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(c,l){const d=[];return this[o](c,(f,h)=>{d.push(l(f,h))}),d};const a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(c,l){const d=[];return this[o](c,(f,h)=>{l(f,h)&&d.push(f)}),d};const u="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[u]=function(c,l,d){if(arguments.length<3)throw new W(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let f=d;return this[o](c,(h,p)=>{f=l(f,h,p)}),f}}function fN(e,t){const{name:n,type:r,direction:i}=t,o=n[0].toUpperCase()+n.slice(1,-1),s="find"+o;e.prototype[s]=function(c,l){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;c=""+c;const d=this._nodes.get(c);if(typeof d>"u")throw new Z(`Graph.${s}: could not find the "${c}" node in the graph.`);return mh(!0,r==="mixed"?this.type:r,i,d,l)};const a="some"+o;e.prototype[a]=function(c,l){return!!this[s](c,l)};const u="every"+o;e.prototype[u]=function(c,l){return!this[s](c,(f,h)=>!l(f,h))}}function hN(e,t){const{name:n,type:r,direction:i}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Kr();s=""+s;const a=this._nodes.get(s);if(typeof a>"u")throw new Z(`Graph.${o}: could not find the "${s}" node in the graph.`);return cN(r==="mixed"?this.type:r,i,a)}}function pN(e){aN.forEach(t=>{lN(e,t),dN(e,t),fN(e,t),hN(e,t)})}function Qo(e,t,n,r,i){const o=r._nodes.values(),s=r.type;let a,u,c,l,d,f;for(;a=o.next(),a.done!==!0;){let h=!1;if(u=a.value,s!=="undirected"){l=u.out;for(c in l){d=l[c];do f=d.target,h=!0,i(u.key,f.key,u.attributes,f.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}if(s!=="directed"){l=u.undirected;for(c in l)if(!(t&&u.key>c)){d=l[c];do f=d.target,f.key!==c&&(f=d.source),h=!0,i(u.key,f.key,u.attributes,f.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}n&&!h&&i(u.key,null,u.attributes,null,null,null,null)}}function mN(e,t){const n={key:e};return L_(t.attributes)||(n.attributes=Xe({},t.attributes)),n}function gN(e,t,n){const r={key:t,source:n.source.key,target:n.target.key};return L_(n.attributes)||(r.attributes=Xe({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function yN(e){if(!st(e))throw new W('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in e))throw new W("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!st(e.attributes)||e.attributes===null))throw new W("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function vN(e){if(!st(e))throw new W('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in e))throw new W("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new W("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!st(e.attributes)||e.attributes===null))throw new W("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!="boolean")throw new W("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const bN=_I(),wN=new Set(["directed","undirected","mixed"]),tm=new Set(["domain","_events","_eventsCount","_maxListeners"]),_N=[{name:e=>`${e}Edge`,generateKey:!0},{name:e=>`${e}DirectedEdge`,generateKey:!0,type:"directed"},{name:e=>`${e}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:e=>`${e}EdgeWithKey`},{name:e=>`${e}DirectedEdgeWithKey`,type:"directed"},{name:e=>`${e}UndirectedEdgeWithKey`,type:"undirected"}],kN={allowSelfLoops:!0,multi:!1,type:"mixed"};function SN(e,t,n){if(n&&!st(n))throw new W(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new ue(`Graph.addNode: the "${t}" node already exist in the graph.`);const r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}function nm(e,t,n){const r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}function G_(e,t,n,r,i,o,s,a){if(!r&&e.type==="undirected")throw new ue(`Graph.${t}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&e.type==="directed")throw new ue(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(a&&!st(a))throw new W(`Graph.${t}: invalid attributes. Expecting an object but got "${a}"`);if(o=""+o,s=""+s,a=a||{},!e.allowSelfLoops&&o===s)throw new ue(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const u=e._nodes.get(o),c=e._nodes.get(s);if(!u)throw new Z(`Graph.${t}: source node "${o}" not found.`);if(!c)throw new Z(`Graph.${t}: target node "${s}" not found.`);const l={key:null,undirected:r,source:o,target:s,attributes:a};if(n)i=e._edgeKeyGenerator();else if(i=""+i,e._edges.has(i))throw new ue(`Graph.${t}: the "${i}" edge already exists in the graph.`);if(!e.multi&&(r?typeof u.undirected[s]<"u":typeof u.out[s]<"u"))throw new ue(`Graph.${t}: an edge linking "${o}" to "${s}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const d=new Jr(r,i,u,c,a);e._edges.set(i,d);const f=o===s;return r?(u.undirectedDegree++,c.undirectedDegree++,f&&(u.undirectedLoops++,e._undirectedSelfLoopCount++)):(u.outDegree++,c.inDegree++,f&&(u.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),r?e._undirectedSize++:e._directedSize++,l.key=i,e.emit("edgeAdded",l),i}function xN(e,t,n,r,i,o,s,a,u){if(!r&&e.type==="undirected")throw new ue(`Graph.${t}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(r&&e.type==="directed")throw new ue(`Graph.${t}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(a){if(u){if(typeof a!="function")throw new W(`Graph.${t}: invalid updater function. Expecting a function but got "${a}"`)}else if(!st(a))throw new W(`Graph.${t}: invalid attributes. Expecting an object but got "${a}"`)}o=""+o,s=""+s;let c;if(u&&(c=a,a=void 0),!e.allowSelfLoops&&o===s)throw new ue(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=e._nodes.get(o),d=e._nodes.get(s),f,h;if(!n&&(f=e._edges.get(i),f)){if((f.source.key!==o||f.target.key!==s)&&(!r||f.source.key!==s||f.target.key!==o))throw new ue(`Graph.${t}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${s}" target vs. ("${f.source.key}", "${f.target.key}").`);h=f}if(!h&&!e.multi&&l&&(h=r?l.undirected[s]:l.out[s]),h){const g=[h.key,!1,!1,!1];if(u?!c:!a)return g;if(u){const w=h.attributes;h.attributes=c(w),e.emit("edgeAttributesUpdated",{type:"replace",key:h.key,attributes:h.attributes})}else Xe(h.attributes,a),e.emit("edgeAttributesUpdated",{type:"merge",key:h.key,attributes:h.attributes,data:a});return g}a=a||{},u&&c&&(a=c(a));const p={key:null,undirected:r,source:o,target:s,attributes:a};if(n)i=e._edgeKeyGenerator();else if(i=""+i,e._edges.has(i))throw new ue(`Graph.${t}: the "${i}" edge already exists in the graph.`);let m=!1,y=!1;l||(l=nm(e,o,{}),m=!0,o===s&&(d=l,y=!0)),d||(d=nm(e,s,{}),y=!0),f=new Jr(r,i,l,d,a),e._edges.set(i,f);const b=o===s;return r?(l.undirectedDegree++,d.undirectedDegree++,b&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,d.inDegree++,b&&(l.directedLoops++,e._directedSelfLoopCount++)),e.multi?f.attachMulti():f.attach(),r?e._undirectedSize++:e._directedSize++,p.key=i,e.emit("edgeAdded",p),[i,!0,m,y]}function rr(e,t){e._edges.delete(t.key);const{source:n,target:r,attributes:i}=t,o=t.undirected,s=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,s&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,s&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),o?e._undirectedSize--:e._directedSize--,e.emit("edgeDropped",{key:t.key,attributes:i,source:n.key,target:r.key,undirected:o})}class Ue extends R_.EventEmitter{constructor(t){if(super(),t=Xe({},kN,t),typeof t.multi!="boolean")throw new W(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!wN.has(t.type))throw new W(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new W(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);const n=t.type==="mixed"?z_:t.type==="directed"?P_:D_;zt(this,"NodeDataClass",n);const r="geid_"+bN()+"_";let i=0;const o=()=>{let s;do s=r+i++;while(this._edges.has(s));return s};zt(this,"_attributes",{}),zt(this,"_nodes",new Map),zt(this,"_edges",new Map),zt(this,"_directedSize",0),zt(this,"_undirectedSize",0),zt(this,"_directedSelfLoopCount",0),zt(this,"_undirectedSelfLoopCount",0),zt(this,"_edgeKeyGenerator",o),zt(this,"_options",t),tm.forEach(s=>zt(this,s,this[s])),Wt(this,"order",()=>this._nodes.size),Wt(this,"size",()=>this._edges.size),Wt(this,"directedSize",()=>this._directedSize),Wt(this,"undirectedSize",()=>this._undirectedSize),Wt(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Wt(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Wt(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Wt(this,"multi",this._options.multi),Wt(this,"type",this._options.type),Wt(this,"allowSelfLoops",this._options.allowSelfLoops),Wt(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(t){return this._nodes.has(""+t)}hasDirectedEdge(t,n){if(this.type==="undirected")return!1;if(arguments.length===1){const r=""+t,i=this._edges.get(r);return!!i&&!i.undirected}else if(arguments.length===2){t=""+t,n=""+n;const r=this._nodes.get(t);return r?r.out.hasOwnProperty(n):!1}throw new W(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(t,n){if(this.type==="directed")return!1;if(arguments.length===1){const r=""+t,i=this._edges.get(r);return!!i&&i.undirected}else if(arguments.length===2){t=""+t,n=""+n;const r=this._nodes.get(t);return r?r.undirected.hasOwnProperty(n):!1}throw new W(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(t,n){if(arguments.length===1){const r=""+t;return this._edges.has(r)}else if(arguments.length===2){t=""+t,n=""+n;const r=this._nodes.get(t);return r?typeof r.out<"u"&&r.out.hasOwnProperty(n)||typeof r.undirected<"u"&&r.undirected.hasOwnProperty(n):!1}throw new W(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(t,n){if(this.type==="undirected")return;if(t=""+t,n=""+n,this.multi)throw new ue("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const r=this._nodes.get(t);if(!r)throw new Z(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new Z(`Graph.directedEdge: could not find the "${n}" target node in the graph.`);const i=r.out&&r.out[n]||void 0;if(i)return i.key}undirectedEdge(t,n){if(this.type==="directed")return;if(t=""+t,n=""+n,this.multi)throw new ue("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const r=this._nodes.get(t);if(!r)throw new Z(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new Z(`Graph.undirectedEdge: could not find the "${n}" target node in the graph.`);const i=r.undirected&&r.undirected[n]||void 0;if(i)return i.key}edge(t,n){if(this.multi)throw new ue("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new Z(`Graph.edge: could not find the "${n}" target node in the graph.`);const i=r.out&&r.out[n]||r.undirected&&r.undirected[n]||void 0;if(i)return i.key}areDirectedNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areDirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.in||n in r.out}areOutNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areOutNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.out}areInNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areInNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.in}areUndirectedNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areUndirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="directed"?!1:n in r.undirected}areNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&(n in r.in||n in r.out)||this.type!=="directed"&&n in r.undirected}areInboundNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areInboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in r.in||this.type!=="directed"&&n in r.undirected}areOutboundNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areOutboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in r.out||this.type!=="directed"&&n in r.undirected}inDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.inDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree}outDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.outDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree}directedDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.directedDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree}undirectedDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.undirectedDegree: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree}inboundDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.inboundDegree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree),r}outboundDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.outboundDegree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.outDegree),r}degree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.degree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree),r}inDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.inDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree-n.directedLoops}outDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.outDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree-n.directedLoops}directedDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.directedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree-n.directedLoops*2}undirectedDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree-n.undirectedLoops*2}inboundDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree,i+=n.directedLoops),r-i}outboundDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.outDegree,i+=n.directedLoops),r-i}degreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.degreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree,i+=n.directedLoops*2),r-i}source(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Z(`Graph.source: could not find the "${t}" edge in the graph.`);return n.source.key}target(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Z(`Graph.target: could not find the "${t}" edge in the graph.`);return n.target.key}extremities(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Z(`Graph.extremities: could not find the "${t}" edge in the graph.`);return[n.source.key,n.target.key]}opposite(t,n){t=""+t,n=""+n;const r=this._edges.get(n);if(!r)throw new Z(`Graph.opposite: could not find the "${n}" edge in the graph.`);const i=r.source.key,o=r.target.key;if(t===i)return o;if(t===o)return i;throw new Z(`Graph.opposite: the "${t}" node is not attached to the "${n}" edge (${i}, ${o}).`)}hasExtremity(t,n){t=""+t,n=""+n;const r=this._edges.get(t);if(!r)throw new Z(`Graph.hasExtremity: could not find the "${t}" edge in the graph.`);return r.source.key===n||r.target.key===n}isUndirected(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Z(`Graph.isUndirected: could not find the "${t}" edge in the graph.`);return n.undirected}isDirected(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Z(`Graph.isDirected: could not find the "${t}" edge in the graph.`);return!n.undirected}isSelfLoop(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Z(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return SN(this,t,n).key}mergeNode(t,n){if(n&&!st(n))throw new W(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);t=""+t,n=n||{};let r=this._nodes.get(t);return r?(n&&(Xe(r.attributes,n),this.emit("nodeAttributesUpdated",{type:"merge",key:t,attributes:r.attributes,data:n})),[t,!1]):(r=new this.NodeDataClass(t,n),this._nodes.set(t,r),this.emit("nodeAdded",{key:t,attributes:n}),[t,!0])}updateNode(t,n){if(n&&typeof n!="function")throw new W(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);t=""+t;let r=this._nodes.get(t);if(r){if(n){const o=r.attributes;r.attributes=n(o),this.emit("nodeAttributesUpdated",{type:"replace",key:t,attributes:r.attributes})}return[t,!1]}const i=n?n({}):{};return r=new this.NodeDataClass(t,i),this._nodes.set(t,r),this.emit("nodeAdded",{key:t,attributes:i}),[t,!0]}dropNode(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.dropNode: could not find the "${t}" node in the graph.`);let r;if(this.type!=="undirected"){for(const i in n.out){r=n.out[i];do rr(this,r),r=r.next;while(r)}for(const i in n.in){r=n.in[i];do rr(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(const i in n.undirected){r=n.undirected[i];do rr(this,r),r=r.next;while(r)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:n.attributes})}dropEdge(t){let n;if(arguments.length>1){const r=""+arguments[0],i=""+arguments[1];if(n=Ft(this,r,i,this.type),!n)throw new Z(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new Z(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return rr(this,n),this}dropDirectedEdge(t,n){if(arguments.length<2)throw new ue("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new ue("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");t=""+t,n=""+n;const r=Ft(this,t,n,"directed");if(!r)throw new Z(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return rr(this,r),this}dropUndirectedEdge(t,n){if(arguments.length<2)throw new ue("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new ue("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const r=Ft(this,t,n,"undirected");if(!r)throw new Z(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return rr(this,r),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const t=this._nodes.values();let n;for(;n=t.next(),n.done!==!0;)n.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(t){return this._attributes[t]}getAttributes(){return this._attributes}hasAttribute(t){return this._attributes.hasOwnProperty(t)}setAttribute(t,n){return this._attributes[t]=n,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}updateAttribute(t,n){if(typeof n!="function")throw new W("Graph.updateAttribute: updater should be a function.");const r=this._attributes[t];return this._attributes[t]=n(r),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}removeAttribute(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this}replaceAttributes(t){if(!st(t))throw new W("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(t){if(!st(t))throw new W("Graph.mergeAttributes: provided attributes are not a plain object.");return Xe(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new W("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(t,n){if(typeof t!="function")throw new W("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!em(n))throw new W("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const r=this._nodes.values();let i,o;for(;i=r.next(),i.done!==!0;)o=i.value,o.attributes=t(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(t,n){if(typeof t!="function")throw new W("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!em(n))throw new W("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const r=this._edges.values();let i,o,s,a;for(;i=r.next(),i.done!==!0;)o=i.value,s=o.source,a=o.target,o.attributes=t(o.key,o.attributes,s.key,a.key,s.attributes,a.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(t){if(typeof t!="function")throw new W("Graph.forEachAdjacencyEntry: expecting a callback.");Qo(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new W("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Qo(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new W("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Qo(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new W("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Qo(!1,!0,!0,this,t)}nodes(){return Array.from(this._nodes.keys())}forEachNode(t){if(typeof t!="function")throw new W("Graph.forEachNode: expecting a callback.");const n=this._nodes.values();let r,i;for(;r=n.next(),r.done!==!0;)i=r.value,t(i.key,i.attributes)}findNode(t){if(typeof t!="function")throw new W("Graph.findNode: expecting a callback.");const n=this._nodes.values();let r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,t(i.key,i.attributes))return i.key}mapNodes(t){if(typeof t!="function")throw new W("Graph.mapNode: expecting a callback.");const n=this._nodes.values();let r,i;const o=new Array(this.order);let s=0;for(;r=n.next(),r.done!==!0;)i=r.value,o[s++]=t(i.key,i.attributes);return o}someNode(t){if(typeof t!="function")throw new W("Graph.someNode: expecting a callback.");const n=this._nodes.values();let r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,t(i.key,i.attributes))return!0;return!1}everyNode(t){if(typeof t!="function")throw new W("Graph.everyNode: expecting a callback.");const n=this._nodes.values();let r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,!t(i.key,i.attributes))return!1;return!0}filterNodes(t){if(typeof t!="function")throw new W("Graph.filterNodes: expecting a callback.");const n=this._nodes.values();let r,i;const o=[];for(;r=n.next(),r.done!==!0;)i=r.value,t(i.key,i.attributes)&&o.push(i.key);return o}reduceNodes(t,n){if(typeof t!="function")throw new W("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new W("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let r=n;const i=this._nodes.values();let o,s;for(;o=i.next(),o.done!==!0;)s=o.value,r=t(r,s.key,s.attributes);return r}nodeEntries(){const t=this._nodes.values();return{[Symbol.iterator](){return this},next(){const n=t.next();if(n.done)return n;const r=n.value;return{value:{node:r.key,attributes:r.attributes},done:!1}}}}export(){const t=new Array(this._nodes.size);let n=0;this._nodes.forEach((i,o)=>{t[n++]=mN(o,i)});const r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=gN(this.type,o,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:t,edges:r}}import(t,n=!1){if(t instanceof Ue)return t.forEachNode((u,c)=>{n?this.mergeNode(u,c):this.addNode(u,c)}),t.forEachEdge((u,c,l,d,f,h,p)=>{n?p?this.mergeUndirectedEdgeWithKey(u,l,d,c):this.mergeDirectedEdgeWithKey(u,l,d,c):p?this.addUndirectedEdgeWithKey(u,l,d,c):this.addDirectedEdgeWithKey(u,l,d,c)}),this;if(!st(t))throw new W("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!st(t.attributes))throw new W("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let r,i,o,s,a;if(t.nodes){if(o=t.nodes,!Array.isArray(o))throw new W("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],yN(s);const{key:u,attributes:c}=s;n?this.mergeNode(u,c):this.addNode(u,c)}}if(t.edges){let u=!1;if(this.type==="undirected"&&(u=!0),o=t.edges,!Array.isArray(o))throw new W("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],vN(a);const{source:c,target:l,attributes:d,undirected:f=u}=a;let h;"key"in a?(h=n?f?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:f?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,h.call(this,a.key,c,l,d)):(h=n?f?this.mergeUndirectedEdge:this.mergeDirectedEdge:f?this.addUndirectedEdge:this.addDirectedEdge,h.call(this,c,l,d))}}return this}nullCopy(t){const n=new Ue(Xe({},this._options,t));return n.replaceAttributes(Xe({},this.getAttributes())),n}emptyCopy(t){const n=this.nullCopy(t);return this._nodes.forEach((r,i)=>{const o=Xe({},r.attributes);r=new n.NodeDataClass(i,o),n._nodes.set(i,r)}),n}copy(t){if(t=t||{},typeof t.type=="string"&&t.type!==this.type&&t.type!=="mixed")throw new ue(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${t.type}" because this would mean losing information about the current graph.`);if(typeof t.multi=="boolean"&&t.multi!==this.multi&&t.multi!==!0)throw new ue("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof t.allowSelfLoops=="boolean"&&t.allowSelfLoops!==this.allowSelfLoops&&t.allowSelfLoops!==!0)throw new ue("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const n=this.emptyCopy(t),r=this._edges.values();let i,o;for(;i=r.next(),i.done!==!0;)o=i.value,G_(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,Xe({},o.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const t={};this._nodes.forEach((o,s)=>{t[s]=o.attributes});const n={},r={};this._edges.forEach((o,s)=>{const a=o.undirected?"--":"->";let u="",c=o.source.key,l=o.target.key,d;o.undirected&&c>l&&(d=c,c=l,l=d);const f=`(${c})${a}(${l})`;s.startsWith("geid_")?this.multi&&(typeof r[f]>"u"?r[f]=0:r[f]++,u+=`${r[f]}. `):u+=`[${s}]: `,u+=f,n[u]=o.attributes});const i={};for(const o in this)this.hasOwnProperty(o)&&!tm.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=t,i.edges=n,zt(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(Ue.prototype[Symbol.for("nodejs.util.inspect.custom")]=Ue.prototype.inspect);_N.forEach(e=>{["add","merge","update"].forEach(t=>{const n=e.name(t),r=t==="add"?G_:xN;e.generateKey?Ue.prototype[n]=function(i,o,s){return r(this,n,!0,(e.type||this.type)==="undirected",null,i,o,s,t==="update")}:Ue.prototype[n]=function(i,o,s,a){return r(this,n,!1,(e.type||this.type)==="undirected",i,o,s,a,t==="update")}})});LI(Ue);BI(Ue);sN(Ue);pN(Ue);class j_ extends Ue{constructor(t){const n=Xe({type:"directed"},t);if("multi"in n&&n.multi!==!1)throw new W("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new W('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class Z_ extends Ue{constructor(t){const n=Xe({type:"undirected"},t);if("multi"in n&&n.multi!==!1)throw new W("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new W('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class B_ extends Ue{constructor(t){const n=Xe({multi:!0},t);if("multi"in n&&n.multi!==!0)throw new W("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}}class H_ extends Ue{constructor(t){const n=Xe({type:"directed",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new W("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new W('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class V_ extends Ue{constructor(t){const n=Xe({type:"undirected",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new W("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new W('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}function Yr(e){e.from=function(t,n){const r=Xe({},t.options,n),i=new e(r);return i.import(t),i}}Yr(Ue);Yr(j_);Yr(Z_);Yr(B_);Yr(H_);Yr(V_);Ue.Graph=Ue;Ue.DirectedGraph=j_;Ue.UndirectedGraph=Z_;Ue.MultiGraph=B_;Ue.MultiDirectedGraph=H_;Ue.MultiUndirectedGraph=V_;Ue.InvalidArgumentsGraphError=W;Ue.NotFoundGraphError=Z;Ue.UsageGraphError=ue;function EN(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function mi(e){var t=EN(e,"string");return typeof t=="symbol"?t:t+""}function mt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function rm(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,mi(r.key),r)}}function gt(e,t,n){return t&&rm(e.prototype,t),n&&rm(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Sr(e){return Sr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Sr(e)}function q_(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(q_=function(){return!!e})()}function $N(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function TN(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return $N(e)}function Zt(e,t,n){return t=Sr(t),TN(e,q_()?Reflect.construct(t,n||[],Sr(e).constructor):t.apply(e,n))}function bc(e,t){return bc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},bc(e,t)}function Bt(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&bc(e,t)}function CN(e){if(Array.isArray(e))return e}function AN(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,s,a=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(a.push(r.value),a.length!==t);u=!0);}catch(l){c=!0,i=l}finally{try{if(!u&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw i}}return a}}function wc(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function W_(e,t){if(e){if(typeof e=="string")return wc(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?wc(e,t):void 0}}function IN(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
112
112
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xr(e,t){return CN(e)||AN(e,t)||W_(e,t)||IN()}var Ru={black:"#000000",silver:"#C0C0C0",gray:"#808080",grey:"#808080",white:"#FFFFFF",maroon:"#800000",red:"#FF0000",purple:"#800080",fuchsia:"#FF00FF",green:"#008000",lime:"#00FF00",olive:"#808000",yellow:"#FFFF00",navy:"#000080",blue:"#0000FF",teal:"#008080",aqua:"#00FFFF",darkblue:"#00008B",mediumblue:"#0000CD",darkgreen:"#006400",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",springgreen:"#00FF7F",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",rebeccapurple:"#663399",mediumaquamarine:"#66CDAA",dimgray:"#696969",dimgrey:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",slategrey:"#708090",lightslategray:"#778899",lightslategrey:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370DB",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",palevioletred:"#DB7093",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",lightyellow:"#FFFFE0",ivory:"#FFFFF0"},K_=new Int8Array(4),ls=new Int32Array(K_.buffer,0,1),J_=new Float32Array(K_.buffer,0,1),NN=/^\s*rgba?\s*\(/,RN=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function LN(e){var t=0,n=0,r=0,i=1;if(e[0]==="#")e.length===4?(t=parseInt(e.charAt(1)+e.charAt(1),16),n=parseInt(e.charAt(2)+e.charAt(2),16),r=parseInt(e.charAt(3)+e.charAt(3),16)):(t=parseInt(e.charAt(1)+e.charAt(2),16),n=parseInt(e.charAt(3)+e.charAt(4),16),r=parseInt(e.charAt(5)+e.charAt(6),16)),e.length===9&&(i=parseInt(e.charAt(7)+e.charAt(8),16)/255);else if(NN.test(e)){var o=e.match(RN);o&&(t=+o[1],n=+o[2],r=+o[3],o[4]&&(i=+o[4]))}return{r:t,g:n,b:r,a:i}}var cr={};for(var es in Ru)cr[es]=Pn(Ru[es]),cr[Ru[es]]=cr[es];function Y_(e,t,n,r,i){return ls[0]=r<<24|n<<16|t<<8|e,ls[0]=ls[0]&4278190079,J_[0]}function Pn(e){if(e=e.toLowerCase(),typeof cr[e]<"u")return cr[e];var t=LN(e),n=t.r,r=t.g,i=t.b,o=t.a;o=o*255|0;var s=Y_(n,r,i,o);return cr[e]=s,s}function zN(e,t){J_[0]=Pn(e);var n=ls[0],r=n&255,i=n>>8&255,o=n>>16&255,s=n>>24&255;return[r,i,o,s]}var Lu={};function X_(e){if(typeof Lu[e]<"u")return Lu[e];var t=(e&16711680)>>>16,n=(e&65280)>>>8,r=e&255,i=255,o=Y_(t,n,r,i);return Lu[e]=o,o}function im(e,t,n,r){return n+(t<<8)+(e<<16)}function om(e,t,n,r,i,o){var s=Math.floor(n/o*i),a=Math.floor(e.drawingBufferHeight/o-r/o*i),u=new Uint8Array(4);e.bindFramebuffer(e.FRAMEBUFFER,t),e.readPixels(s,a,1,1,e.RGBA,e.UNSIGNED_BYTE,u);var c=xr(u,4),l=c[0],d=c[1],f=c[2],h=c[3];return[l,d,f,h]}function P(e,t,n){return(t=mi(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sm(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?sm(Object(n),!0).forEach(function(r){P(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sm(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function PN(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=Sr(e))!==null;);return e}function _c(){return _c=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=PN(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},_c.apply(null,arguments)}function Q_(e,t,n,r){var i=_c(Sr(e.prototype),t,n);return typeof i=="function"?function(o){return i.apply(n,o)}:i}function DN(e){return e.normalized?1:e.size}function zu(e){var t=0;return e.forEach(function(n){return t+=DN(n)}),t}function ek(e,t,n){var r=e==="VERTEX"?t.VERTEX_SHADER:t.FRAGMENT_SHADER,i=t.createShader(r);if(i===null)throw new Error("loadShader: error while creating the shader");t.shaderSource(i,n),t.compileShader(i);var o=t.getShaderParameter(i,t.COMPILE_STATUS);if(!o){var s=t.getShaderInfoLog(i);throw t.deleteShader(i),new Error(`loadShader: error while compiling the shader:
|
|
113
113
|
`.concat(s,`
|
|
@@ -719,7 +719,7 @@ void main() {
|
|
|
719
719
|
}
|
|
720
720
|
`);return n}var xk=WebGLRenderingContext,Nm=xk.UNSIGNED_BYTE,is=xk.FLOAT;function Ek(e){var t,n=Im(Im({},EL),e||{}),r=n.borders,i=n.drawLabel,o=n.drawHover,s=["u_sizeRatio","u_correctionRatio","u_matrix"].concat(Gu(r.flatMap(function(a,u){var c=a.color;return"value"in c?["u_borderColor_".concat(u+1)]:[]})));return t=(function(a){wL(u,a);function u(){var c;pL(this,u);for(var l=arguments.length,d=new Array(l),f=0;f<l;f++)d[f]=arguments[f];return c=bL(this,u,[].concat(d)),ar(Tc(c),"drawLabel",i),ar(Tc(c),"drawHover",o),c}return yL(u,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:CL(n),FRAGMENT_SHADER_SOURCE:TL(n),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:s,ATTRIBUTES:[{name:"a_position",size:2,type:is},{name:"a_id",size:4,type:Nm,normalized:!0},{name:"a_size",size:1,type:is}].concat(Gu(r.flatMap(function(l,d){var f=l.color;return"attribute"in f?[{name:"a_borderColor_".concat(d+1),size:4,type:Nm,normalized:!0}]:[]})),Gu(r.flatMap(function(l,d){var f=l.size;return"attribute"in f?[{name:"a_borderSize_".concat(d+1),size:1,type:is}]:[]}))),CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:is}],CONSTANT_DATA:[[u.ANGLE_1],[u.ANGLE_2],[u.ANGLE_3]]}}},{key:"processVisibleItem",value:function(l,d,f){var h=this.array;h[d++]=f.x,h[d++]=f.y,h[d++]=l,h[d++]=f.size,r.forEach(function(p){var m=p.color;"attribute"in m&&(h[d++]=Pn(f[m.attribute]||m.defaultValue||$L))}),r.forEach(function(p){var m=p.size;"attribute"in m&&(h[d++]=f[m.attribute]||m.defaultValue)})}},{key:"setUniforms",value:function(l,d){var f=d.gl,h=d.uniformLocations,p=h.u_sizeRatio,m=h.u_correctionRatio,y=h.u_matrix;f.uniform1f(m,l.correctionRatio),f.uniform1f(p,l.sizeRatio),f.uniformMatrix3fv(y,!1,l.matrix),r.forEach(function(b,g){var w=b.color;if("value"in w){var v=h["u_borderColor_".concat(g+1)],_=zN(w.value),k=hL(_,4),x=k[0],N=k[1],M=k[2],F=k[3];f.uniform4f(v,x/255,N/255,M/255,F/255)}})}}]),u})(nk),ar(t,"ANGLE_1",0),ar(t,"ANGLE_2",2*Math.PI/3),ar(t,"ANGLE_3",4*Math.PI/3),t}Ek();const Ns=.18,AL=500,IL=2,NL=3,os={rest:2,selected:4,expanded:5},RL=6,ju=2,LL=8,Rm=6,Zu=400,zL=2e3,PL={x:[0,1e3],y:[0,1e3]},Bu=1e3,Lm=500,DL={role:{size:13,font:e=>`600 ${e}px Inter, system-ui, sans-serif`},address:{size:11,font:e=>`400 ${e}px ui-monospace, monospace`},note:{size:11,font:e=>`italic 400 ${e}px Inter, system-ui, sans-serif`}};function ss(e){return Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0")}function OL(e,t,n){const r=Math.min(1,Math.max(0,n));return{r:e.r+(t.r-e.r)*r,g:e.g+(t.g-e.g)*r,b:e.b+(t.b-e.b)*r,a:1}}function Pt(e,t=1){return`#${ss(e.r)}${ss(e.g)}${ss(e.b)}${ss(e.a*t*255)}`}function $k(e,t,n,r){const i=1-r;return{x:i*i*e.x+2*i*r*t.x+r*r*n.x,y:i*i*e.y+2*i*r*t.y+r*r*n.y}}function Tk(e,t,n=Ns){const r=t.x-e.x,i=t.y-e.y;return{x:(e.x+t.x)/2+i*n,y:(e.y+t.y)/2-r*n}}function Ck(e,t,n){const r=n.x-t.x,i=n.y-t.y,o=r*r+i*i,s=o?Math.max(0,Math.min(1,((e.x-t.x)*r+(e.y-t.y)*i)/o)):0;return Math.hypot(e.x-(t.x+s*r),e.y-(t.y+s*i))}function ML(e,t,n,r=Ns){const i=Tk(t,n,r);let o=1/0,s=t;for(let a=1;a<=12;a++){const u=$k(t,i,n,a/12);o=Math.min(o,Ck(e,s,u)),s=u}return o}function FL(e,t,n,r){const i=e.ownerDocument,o=i.defaultView,s=i.createElement("div");s.className="cia-graph-webgl",s.tabIndex=0,s.setAttribute("role","group"),s.setAttribute("aria-label",r.label??"Money-flow graph. Drag the background or use arrow keys to pan, plus and minus to zoom. Select an address or a link for details.");const a=i.createElement("span");a.hidden=!0,s.append(a),e.append(s);const u=new Map;function c(O){const j=u.get(O);if(j)return j;a.style.color="",a.style.color=O;const q=o.getComputedStyle(a).color.match(/[\d.]+/g)?.map(Number)??[0,0,0],J={r:q[0]??0,g:q[1]??0,b:q[2]??0,a:q[3]??1};return u.set(O,J),J}const l=O=>c(`var(--cia-graph-${O})`);let d;function f(){u.clear(),d={node:l("node"),edge:l("edge"),halo:l("halo"),selected:l("selected"),expanded:l("expanded"),text:l("text"),muted:l("muted"),canvas:l("canvas")}}f();function h(O,j){if(!j.texts?.length||!j.outer)return;const q=j.size/j.outer;O.textAlign="center",O.textBaseline="alphabetic",O.lineJoin="round";for(const J of j.texts){const Te=DL[J.kind],se=Te.size*q;if(se<Rm)continue;O.font=Te.font(se);const ye=j.y+J.y*q;O.lineWidth=4*q,O.strokeStyle=j.haloColor??"#000",O.strokeText(J.text,j.x,ye),O.fillStyle=J.kind==="role"?j.toneColor??"#fff":J.kind==="address"?j.mutedColor??"#aaa":j.textColor??"#fff",O.fillText(J.text,j.x,ye)}}const p=()=>{},m=Ek({borders:[{size:{attribute:"ringSize",defaultValue:0},color:{attribute:"ringColor"}},{size:{attribute:"gapSize",defaultValue:0},color:{transparent:!0}},{size:{attribute:"strokeSize",defaultValue:.1},color:{attribute:"strokeColor"}},{size:{fill:!0},color:{attribute:"bodyColor"}},{size:{attribute:"dotSize",defaultValue:.25},color:{attribute:"dotColor"}}],drawLabel:h,drawHover:p}),y=au({arrowHead:{extremity:"target",lengthToThicknessRatio:6,widenessToThicknessRatio:4}}),b=lk({lengthToThicknessRatio:6,widenessToThicknessRatio:4});let g=new Ue({type:"directed",multi:!1,allowSelfLoops:!1}),w=!0;const v=new qR(g,s,{allowInvalidContainer:!0,autoRescale:!0,stagePadding:0,itemSizesReference:"positions",zoomToSizeRatioFunction:O=>O,enableCameraPanning:!0,enableCameraZooming:!0,enableCameraRotation:!1,enableEdgeEvents:!1,hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderEdgeLabels:!0,edgeLabelSize:10,edgeLabelFont:"Inter, system-ui, sans-serif",edgeLabelWeight:"500",renderLabels:!0,labelRenderedSizeThreshold:Rm,labelDensity:1,labelGridCellSize:120,minEdgeThickness:1.6,defaultNodeType:"address",defaultEdgeType:"link",nodeProgramClasses:{address:m},edgeProgramClasses:{link:y,straight:b},defaultDrawNodeLabel:h,defaultDrawNodeHover:p});v.setCustomBBox(PL);const _=v.getMouseCaptor(),k=v.getTouchCaptor();_.removeAllListeners(),k.removeAllListeners(),_.enabled=!1,k.enabled=!1;const x=new Map;let N=Ns;function M(O){const j=t.flags().get(O),q=t.selected();return j?.has("expanded")?{width:os.expanded,color:d.expanded}:q?.kind==="node"&&q.id===O||t.highlighted()===O?{width:os.selected,color:d.selected}:{width:os.rest,color:c(t.colorOf(x.get(O)))}}function F(O,j,q){const J=t.model(),Te=t.notes().get(O.id)??null,se=Rn(O,J.checked_address,Te),ye=c(t.colorOf(O)),Oe=M(O.id),ae=se.radius+Oe.width/2,ze=se.ring?se.radius+RL+ju/2:ae,qe=se.ring?ju/ze:0,tt=se.ring?Math.max(0,ze-ju-ae)/ze:0,Ye=t.selected(),St=se.ring||Oe.width!==os.rest||Ye?.kind==="node"&&Ye.id===O.id;return{x:j.x,y:-j.y,size:ze,label:se.texts.find(T=>T.kind==="address")?.text??O.address,color:Pt(ye),forceLabel:!q||St,ringColor:Pt(d.edge),ringSize:qe,gapSize:tt,strokeColor:Pt(Oe.color,Te?.5:1),strokeSize:Oe.width/ze,bodyColor:Pt(d.node),dotColor:Pt(ye),dotSize:se.dot/ze,outer:ze,texts:se.texts,toneColor:Pt(ye),mutedColor:Pt(d.muted),textColor:Pt(d.text),haloColor:Pt(d.halo)}}function B(O,j){const q=t.selected(),J=q?.kind==="node"?x.get(q.id)?.address??null:null,Te=q?.kind==="edge"&&q.id===O.id,se=q?.kind==="edge"?Te?Jt.related:Jt.faded:Ww(O,J),ye=c(t.colorOf(j)),Oe=se===Jt.faded?Pt(OL(ye,d.canvas,1-se)):Pt(ye,se),ae=w?Qw(O):"";return{size:Te?NL:IL,color:Oe,curvature:N,type:N?"link":"straight",...ae?{label:ae}:{}}}function ee(){const O=t.model(),j=t.positions(),{width:q,height:J}=t.dimensions();x.clear();for(const ae of O.nodes)x.set(ae.id,ae);const Te=O.nodes.length>Zu;N=O.edges.length>AL?0:Ns,w=O.edges.length<=Xw,v.setSetting("edgeLabelColor",{color:Pt(d.muted)});const se=new Ue({type:"directed",multi:!1,allowSelfLoops:!1}),ye=new Map(O.nodes.map(ae=>[ae.address,ae]));for(const ae of O.nodes)se.addNode(ae.id,F(ae,j[ae.id]??{x:q/2,y:J/2},Te));for(const ae of O.edges){const ze=ye.get(ae.from),qe=ye.get(ae.to);!ze||!qe||ze.id===qe.id||se.hasEdge(ae.id)||se.hasDirectedEdge(ze.id,qe.id)||se.addDirectedEdgeWithKey(ae.id,ze.id,qe.id,B(ae,ze))}g=se;const Oe=t.selected();$e=[Oe?.kind==="node"?Oe.id:null,t.highlighted()].filter(ae=>!!ae),v.setGraph(g),K()}function ce(){const j=t.model().nodes.length>Zu,q=t.positions();g.updateEachNodeAttributes((J,Te)=>{const se=x.get(J);return se?F(se,q[J]??{x:Te.x,y:-Te.y},j):Te}),H()}function me(O){const j=O?x.get(O):null;if(!j||!g.hasNode(j.id))return;const q=t.positions()[j.id],J=g.getNodeAttributes(j.id);g.replaceNodeAttributes(j.id,F(j,q??{x:J.x,y:-J.y},t.model().nodes.length>Zu))}let $e=[];function U(){const O=t.selected(),j=[O?.kind==="node"?O.id:null,t.highlighted()].filter(q=>!!q);for(const q of new Set([...$e,...j]))me(q);$e=j,H()}function H(){const O=t.model(),j=new Map(O.nodes.map(J=>[J.address,J])),q=new Map(O.edges.map(J=>[J.id,J]));g.updateEachEdgeAttributes((J,Te)=>{const se=q.get(J),ye=se&&j.get(se.from);return se&&ye?B(se,ye):Te})}function K(){const{width:O,height:j}=t.dimensions(),q=v.getDimensions();if(!q.width||!q.height)return;const J=Math.min(q.width/O,q.height/j),Te=t.transform(),se=Te.scale*J,ye=(q.width-O*J)/2+Te.x*J,Oe=(q.height-j*J)/2+Te.y*J,ae={x:.5,y:.5,ratio:1,angle:0},ze=v.framedGraphToViewport({x:.5,y:.5},{cameraState:ae}),qe=(v.framedGraphToViewport({x:.6,y:.5},{cameraState:ae}).x-ze.x)/.1,tt=(v.framedGraphToViewport({x:.5,y:.6},{cameraState:ae}).y-ze.y)/.1,Ye=qe/(Bu*se);v.getCamera().setState({ratio:Ye,angle:0,x:.5-Lm/Bu-(ye-ze.x)*Ye/qe,y:.5-Lm/Bu-(Oe-ze.y)*Ye/tt})}function de(O){const j=t.transform(),q={x:(O.x-j.x)/j.scale,y:(O.y-j.y)/j.scale},J=t.positions();let Te=null,se=1/0;if(g.forEachNode((ze,qe)=>{const tt=J[ze];if(!tt)return;const Ye=Math.hypot(q.x-tt.x,q.y-tt.y);Ye<=qe.size+1/j.scale&&Ye<se&&(Te=ze,se=Ye)}),Te)return{kind:"node",id:Te};const ye=LL/j.scale;let Oe=null,ae=1/0;return g.forEachEdge((ze,qe,tt,Ye)=>{const St=J[tt],T=J[Ye];if(!St||!T)return;const D=Math.hypot(T.x-St.x,T.y-St.y)*(.5+N)+ye;if(Math.hypot(q.x-(St.x+T.x)/2,q.y-(St.y+T.y)/2)>D)return;const ne=N?ML(q,St,T,N):Ck(q,St,T);ne<=ye&&ne<ae&&(Oe=ze,ae=ne)}),Oe?{kind:"edge",id:Oe}:{kind:"canvas",id:null}}let te=0,I=null,z=null;const G=O=>{O.buttons||(z=O,!te&&(te=o.requestAnimationFrame(()=>{te=0;const j=z;if(!j)return;const q=s.getBoundingClientRect(),{width:J,height:Te}=t.dimensions(),se=Math.min(q.width/J,q.height/Te)||1,ye=de({x:(j.clientX-q.left-(q.width-J*se)/2)/se,y:(j.clientY-q.top-(q.height-Te*se)/2)/se}),Oe=ye.kind==="canvas"?null:`${ye.kind}:${ye.id}`;if(s.style.cursor=Oe?"pointer":"",Oe!==I){if(I=Oe,!Oe){n.hideTooltip();return}if(ye.kind==="node"){const ae=x.get(ye.id);ae&&n.showTooltip(j,fc(ae))}else{const ae=t.model().edges.find(ze=>ze.id===ye.id);ae&&n.showTooltip(j,hc(ae,t.now()))}}})))},fe=()=>{I=null,s.style.cursor="",n.hideTooltip()};s.addEventListener("pointermove",G),s.addEventListener("pointerleave",fe);let ie=null;const Y=O=>{O.preventDefault(),!ie&&(ie=setTimeout(()=>{ie=null,n.lost()},zL))},oe=()=>{ie&&clearTimeout(ie),ie=null,n.lost()},he=Object.values(v.getCanvases());for(const O of he)O.addEventListener("webglcontextlost",Y),O.addEventListener("webglcontextrestored",oe);function Ae(){const O=t.positions();let j=null;return g.forEachEdge((q,J,Te,se)=>{const ye=O[Te],Oe=O[se];if(!ye||!Oe||!N)return;const ae=$k(ye,Tk(ye,Oe,N),Oe,.5);j=j??{x1:ae.x,y1:ae.y,x2:ae.x,y2:ae.y},j.x1=Math.min(j.x1,ae.x),j.y1=Math.min(j.y1,ae.y),j.x2=Math.max(j.x2,ae.x),j.y2=Math.max(j.y2,ae.y)}),j}return{kind:"webgl",surface:s,build:ee,geometry(){const O=t.positions();g.updateEachNodeAttributes((j,q)=>{const J=O[j];return J?{...q,x:J.x,y:-J.y}:q},{attributes:["x","y"]}),K()},moveNode(O){const j=t.positions()[O];j&&g.hasNode(O)&&g.mergeNodeAttributes(O,{x:j.x,y:-j.y})},endMove(){},camera:K,selection:U,flag:O=>me(O),theme(){f(),ce()},resize(){v.resize(!0),K()},pick:de,linkBounds:Ae,destroy(){ie&&clearTimeout(ie),te&&o.cancelAnimationFrame(te),s.removeEventListener("pointermove",G),s.removeEventListener("pointerleave",fe);for(const O of he)O.removeEventListener("webglcontextlost",Y),O.removeEventListener("webglcontextrestored",oe);v.kill(),s.remove()}}}ET("webgl",FL);const Cn=document.getElementById("view"),Rs=()=>typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches;let xn={},sn=Ts(document,xn,{prefersDark:Rs}),bt=null,zm=null;ch(Cn);const Pm=kT(location);Pm?UL(Pm):GL();async function UL(e){document.documentElement.dataset.mode="browser",document.title=yT,sn=Ts(document,{},{prefersDark:Rs}),typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").addEventListener?.("change",()=>{const n=sn;sn=Ts(document,{},{prefersDark:Rs}),bt&&sn!==n&&bt.setTheme(sn)}),ch(Cn,"Loading the graph");const t=await ST(e,(n,r)=>fetch(n,r),document);if(!t){Ti(Cn,null,vT),document.documentElement.dataset.view="text";return}bt=N_(Cn,t.result,{host:xT((n,r)=>fetch(n,r),(n,r,i)=>window.open(n,r,i)),displayMode:"fullscreen",availableDisplayModes:["fullscreen"],toolInput:t.arguments,browser:!0}),document.documentElement.dataset.view=bt.kind}function GL(){const e=new th({name:"chain-insights-view",version:"1.0.0"},{});function t(r){const i=sn;sn=Ts(document,r,{prefersDark:Rs,applyVariables:(o,s)=>mT(o,s),applyFonts:gT}),bt&&sn!==i&&bt.setTheme(sn),bt?.setDisplayMode(r.displayMode,r.availableDisplayModes)}function n(r){bt?.destroy(),bt=null;const i=Au(e.getHostContext(),xn);bt=N_(Cn,r,{host:e,availableDisplayModes:i.availableDisplayModes,displayMode:i.displayMode,toolInput:zm}),document.documentElement.dataset.view=bt.kind}e.ontoolinput=r=>{zm=r.arguments&&typeof r.arguments=="object"?r.arguments:null;const i=typeof r.arguments?.address=="string"?r.arguments.address:null;bt||ch(Cn,i?`Loading the graph of ${i}`:"Loading the Chain Insights view")},e.ontoolresult=r=>{n(r)},e.ontoolcancelled=()=>{bt||Ti(Cn,null,"The tool call was cancelled. Nothing to draw.")},e.onhostcontextchanged=r=>{xn=Au(xn,r),t(xn)},e.onteardown=async()=>(bt?.destroy(),bt=null,{}),e.onerror=r=>{console.warn("chain-insights-view:",r)},e.connect(new Mw(window.parent,window.parent)).then(()=>{xn=Au(xn,e.getHostContext()),t(xn)},r=>{console.warn("chain-insights-view: no host answered",r),Ti(Cn,null,"This view opens inside Claude, next to a Chain Insights tool answer.")})}
|
|
721
721
|
</script>
|
|
722
|
-
<style>.cia-graph-surface{--cia-graph-surface:linear-gradient(140deg,#171a20,#0d0f13);--cia-graph-canvas:#101318;--cia-graph-dot:#f2dda621;--cia-graph-text:#e2e8f0;--cia-graph-muted:#adb1ba;--cia-graph-border:#f2dda640;--cia-graph-divider:#ffffff10;--cia-graph-control:#14161a;--cia-graph-hover:#f2dda626;--cia-graph-active:#f2dda6;--cia-graph-active-text:#0b0e13;--cia-graph-node:#14161a;--cia-graph-edge:#f2dda6;--cia-graph-halo:#07090d;--cia-graph-selected:#ffffff;--cia-graph-expanded:#4da3ff;--cia-graph-danger:#d89087;--cia-graph-target:#8bb6b0;--cia-graph-trail:#b49bc4;--cia-graph-infrastructure:#94b58b;--cia-graph-neutral:#f2dda6;--cia-graph-critical:#d89087;--cia-graph-high:#d6a07d;--cia-graph-medium:#b49bc4;--cia-graph-low:#94b58b;--cia-graph-role-exchange:var(--cia-graph-infrastructure);--cia-graph-role-scam:var(--cia-graph-danger);--cia-graph-role-sanctioned:var(--cia-graph-danger);--cia-graph-role-victim:var(--cia-graph-target);--cia-graph-role-pool:var(--cia-graph-trail);--cia-graph-role-other:var(--cia-graph-neutral);--cia-graph-series-1:var(--cia-graph-edge);--cia-graph-series-2:var(--cia-graph-target);--cia-graph-series-3:var(--cia-graph-trail);--cia-graph-series-4:var(--cia-graph-infrastructure);--cia-graph-series-5:var(--cia-graph-danger);--cia-graph-series-6:var(--cia-graph-high);color:var(--cia-graph-text);background:var(--cia-graph-surface);border:1px solid var(--cia-graph-border);border-radius:14px;overflow:hidden}html[data-theme=light] .cia-graph-surface{--cia-graph-surface:#f9f9f9;--cia-graph-canvas:#fff;--cia-graph-dot:#dedede;--cia-graph-text:#242424;--cia-graph-muted:#686868;--cia-graph-border:#dedede;--cia-graph-divider:#e6e6e6;--cia-graph-control:#fff;--cia-graph-hover:#ececec;--cia-graph-active:#4e708a;--cia-graph-active-text:#fff;--cia-graph-node:#fff;--cia-graph-edge:#4e708a;--cia-graph-halo:#fff;--cia-graph-selected:#242424;--cia-graph-expanded:#0057d9;--cia-graph-danger:#a64d4b;--cia-graph-target:#356e68;--cia-graph-trail:#78538f;--cia-graph-infrastructure:#416c4a;--cia-graph-neutral:#4e708a;--cia-graph-critical:#a64d4b;--cia-graph-high:#a15432;--cia-graph-medium:#78538f;--cia-graph-low:#416c4a}.cia-graph-canvas{background:radial-gradient(circle,var(--cia-graph-dot) 1px,transparent 1px) 0 0/24px 24px,var(--cia-graph-canvas)}.graph-detail{border-top:1px solid var(--cia-graph-divider,#ffffff10);padding:1rem 1.5rem;font-size:.85rem;color:var(--cia-graph-muted,#adb1ba);line-height:1.6}.graph-detail strong{color:var(--cia-graph-text,#f2dda6)}.graph-detail p{margin:0}.graph-detail ul{padding-left:1.25rem;margin-bottom:0}.graph-detail strong,.graph-detail li{overflow-wrap:anywhere}.graph-legend{border-top:1px solid var(--cia-graph-divider,#ffffff10);padding:1rem 1.5rem;font-size:.85rem}.graph-legend summary{cursor:pointer}.graph-legend ul{list-style:none;padding:0}.graph-legend li{display:flex;flex-wrap:wrap;gap:.4rem 1rem;padding:.6rem 0;border-bottom:1px solid var(--cia-graph-divider,#ffffff0a)}.graph-legend button{color:var(--cia-graph-edge,#f2dda6);background:none;border:0;padding:0;text-align:left;cursor:pointer;font:inherit;font-family:ui-monospace,monospace;overflow-wrap:anywhere;max-width:100%}.graph-legend span{color:var(--cia-graph-muted,#adb1ba)}.graph-detail a,.graph-legend a{color:var(--cia-graph-edge,#f2dda6);text-decoration:none;border-bottom:1px solid var(--cia-graph-border,#f2dda659)}.graph-detail a:hover,.graph-legend a:hover{border-bottom-color:var(--cia-graph-edge,#f2dda6)}.graph-legend .graph-legend-link{overflow-wrap:normal;flex:none}.cia-graph-node-body{fill:var(--cia-graph-node,#14161a)}.cia-graph-node-ring{stroke:var(--cia-graph-edge,#f2dda6)}.cia-graph-node-address{fill:var(--cia-graph-muted,#adb1ba)}.cia-graph-edge-underlay{stroke:var(--cia-graph-halo,#07090d)}.cia-graph-edge-direction{stroke:var(--cia-graph-edge,#f2dda6)}.cia-graph-edge-arrow{fill:var(--cia-graph-edge,#f2dda6);stroke:var(--cia-graph-halo,#07090d)}.cia-graph-surface .graph-tooltip{background:var(--cia-graph-control);color:var(--cia-graph-text);border-color:var(--cia-graph-border)}.cia-graph-engine{position:relative;min-height:240px}.cia-graph-svg{display:block;width:100%;height:100%;touch-action:none;font-family:Inter,system-ui,sans-serif;outline:none}.cia-graph-svg:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:-2px}.cia-graph-backdrop{fill:var(--cia-graph-canvas)}.cia-graph-dot{fill:var(--cia-graph-dot)}.cia-graph-edge{cursor:pointer;outline:none;transition:opacity .15s}.cia-graph-edge-hit{fill:none;stroke:transparent}.cia-graph-edge-line{fill:none;stroke:var(--edge-tone,var(--cia-graph-edge));stroke-linecap:round}.cia-graph-edge:focus-visible .cia-graph-edge-line,.cia-graph-edge[aria-pressed=true] .cia-graph-edge-line{stroke-width:3}.cia-graph-node{cursor:pointer;outline:none}.cia-graph-engine .cia-graph-node-body{fill:var(--cia-graph-node);stroke:var(--node-tone,var(--cia-graph-neutral));stroke-width:2}.cia-graph-engine .cia-graph-node-ring{fill:none;stroke:var(--cia-graph-edge);stroke-width:2}.cia-graph-node-dot{fill:var(--node-tone,var(--cia-graph-neutral))}.cia-graph-node.is-selected .cia-graph-node-body,.cia-graph-node.is-focused .cia-graph-node-body,.cia-graph-node:focus-visible .cia-graph-node-body{stroke:var(--cia-graph-selected);stroke-width:4}.cia-graph-node text{paint-order:stroke;stroke:var(--cia-graph-halo);stroke-width:4px;stroke-linejoin:round}.cia-graph-node-role{fill:var(--node-tone,var(--cia-graph-neutral));font-size:13px;font-weight:600}.cia-graph-engine .cia-graph-node-address{fill:var(--cia-graph-muted);font:400 11px ui-monospace,monospace}.cia-graph-node-note{fill:var(--cia-graph-text);font-size:11px;font-style:italic}.cia-graph-node[data-state=refused] .cia-graph-node-body{stroke-dasharray:4 3}.cia-graph-engine .cia-graph-node[data-flag-expanded] .cia-graph-node-body{stroke:var(--cia-graph-expanded);stroke-width:5}.cia-graph-engine>.graph-tooltip{position:absolute;z-index:2;max-width:320px;padding:.5rem .65rem;border:1px solid;border-radius:6px;font:12px/1.45 Inter,system-ui,sans-serif;overflow-wrap:anywhere;pointer-events:none}.cia-graph-webgl{position:relative;display:block;width:100%;height:100%;min-height:inherit;touch-action:none;outline:none;overflow:hidden;background:radial-gradient(circle,var(--cia-graph-dot) 1px,transparent 1px) 0 0/24px 24px,var(--cia-graph-canvas)}.cia-graph-webgl:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:-2px}.cia-graph-edge-caption{font:500 10px var(--font-sans,Inter,system-ui,sans-serif);fill:var(--cia-graph-muted);paint-order:stroke;stroke:var(--cia-graph-canvas);stroke-width:3px;stroke-linejoin:round;-webkit-user-select:none;user-select:none}.cia-graph-edge[data-state=faded] .cia-graph-edge-caption{opacity:.35}:root{color-scheme:light dark}html,body{margin:0;padding:0;background:transparent}html[data-theme=dark]{color-scheme:dark;--cv-text:var(--color-text-primary,#ececec);--cv-muted:var(--color-text-secondary,#b4b4b4);--cv-surface:var(--color-background-secondary,#262624);--cv-raised:var(--color-background-tertiary,#30302e);--cv-border:var(--color-border-primary,#4a4a46);--cv-ring:var(--color-ring-primary,#8fb5ff);--cv-skeleton:#3a3a37}html[data-theme=light]{color-scheme:light;--cv-text:var(--color-text-primary,#1f1f1e);--cv-muted:var(--color-text-secondary,#5c5c58);--cv-surface:var(--color-background-secondary,#f5f4ef);--cv-raised:var(--color-background-tertiary,#ecebe5);--cv-border:var(--color-border-primary,#d6d4cc);--cv-ring:var(--color-ring-primary,#2f5fb8);--cv-skeleton:#e4e2db}body{color:var(--cv-text);font-family:var(--font-sans,system-ui,-apple-system,"Segoe UI",sans-serif);font-size:var(--font-text-sm-size,14px);line-height:var(--font-text-sm-line-height,1.45)}.cv-root{display:block}.cv-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.cv-visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap}.cv-muted{color:var(--cv-muted)}button:focus-visible{outline:2px solid var(--cv-ring);outline-offset:2px}.cv-card{box-sizing:border-box;border:var(--border-width-regular,1px) solid var(--cv-border);border-radius:var(--border-radius-lg,12px);background:var(--cv-surface);padding:14px 16px;overflow:hidden}.cv-card-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 12px;margin-bottom:10px}.cv-card-head strong{font-size:var(--font-text-md-size,15px);font-weight:var(--font-weight-semibold,600)}.cv-note{margin:0 0 10px;padding:6px 10px;border-radius:var(--border-radius-sm,6px);background:var(--color-background-warning,var(--cv-raised));color:var(--color-text-warning,var(--cv-text))}.cv-text-view p{margin:0 0 6px}.cv-text-body{white-space:pre-wrap;overflow-wrap:anywhere}.cia-graph-surface.cv-notice{box-sizing:border-box;margin:0;padding:6px 12px;border-radius:8px;font:400 13px/1.4 var(--font-sans,system-ui,-apple-system,"Segoe UI",sans-serif)}.cia-graph-surface.cv-notice-refused{border-left:3px solid var(--cia-graph-danger)}.cv-notice-empty{color:var(--cia-graph-muted)}.cv-notice p{margin:0}.cv-notice-line{overflow-wrap:anywhere}.cv-notice summary{cursor:pointer}.cv-notice summary:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:2px}.cv-notice-full{margin:4px 0 0;color:var(--cia-graph-muted);white-space:pre-wrap;overflow-wrap:anywhere}.cv-skeleton{min-height:220px}.cv-skel-line,.cv-skel-block{background:var(--cv-skeleton);border-radius:6px;margin-bottom:10px}.cv-skel-title{width:32%;height:16px}.cv-skel-sub{width:54%;height:12px}.cv-skel-block{height:160px;border-radius:10px}@media(prefers-reduced-motion:no-preference){.cv-skel-line,.cv-skel-block{animation:cv-pulse 1.6s ease-in-out infinite}}@keyframes cv-pulse{50%{opacity:.55}}.cv-table-wrap{overflow-x:auto}.cv-table{width:100%;border-collapse:collapse;font-variant-numeric:tabular-nums}.cv-table th{position:sticky;top:0;text-align:left;font-weight:var(--font-weight-semibold,600);color:var(--cv-muted);background:var(--cv-surface);border-bottom:1px solid var(--cv-border);padding:6px 10px;white-space:nowrap}.cv-table td{padding:5px 10px;border-bottom:1px solid var(--color-border-secondary,var(--cv-border));white-space:nowrap}.cv-table tr:last-child td{border-bottom:0}.cv-null{color:var(--cv-muted)}.cv-addr-cell{display:inline-flex;align-items:center;gap:6px}.cv-addr{font-family:var(--font-mono,ui-monospace,monospace);font-size:.92em}.cv-addr.is-full{-webkit-user-select:all;user-select:all}.cv-copy{font:inherit;font-size:.8em;padding:1px 7px;border:1px solid var(--cv-border);border-radius:var(--border-radius-sm,5px);background:transparent;color:var(--cv-muted);cursor:pointer}.cv-copy:hover{color:var(--cv-text);background:var(--cv-raised)}.cv-meter{height:8px;border-radius:999px;background:var(--cv-raised);overflow:hidden;margin:2px 0 12px}.cv-meter span{display:block;height:100%;background:var(--cv-ring)}.cv-balance-note{margin:2px 0 12px;font-weight:var(--font-weight-semibold,600)}.cv-facts{display:grid;grid-template-columns:max-content 1fr;gap:6px 18px;margin:0}.cv-facts dt{color:var(--cv-muted)}.cv-facts dd{margin:0;font-weight:var(--font-weight-medium,500)}.cv-flows{box-sizing:border-box;display:flex;flex-direction:column;height:640px;max-height:640px;font-family:var(--font-sans,system-ui,sans-serif)}.cv-flows[data-display-mode=fullscreen]{height:calc(100vh - var(--cv-tabs-h,0px));max-height:none;border-radius:0}.cv-flows-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px 12px;padding:10px 14px 6px}.cv-title{display:flex;flex-direction:column;min-width:0}.cv-title strong{font-size:15px;font-weight:600}.cv-title .cv-muted,.cv-flows .cv-muted{color:var(--cia-graph-muted);font-size:12px;overflow-wrap:anywhere}.cv-actions{display:flex;gap:6px;align-items:center;flex-wrap:wrap;justify-content:flex-end}.cv-hint{font-size:12px;color:var(--cia-graph-muted);margin-right:2px}.cv-hint[hidden]{display:none}.cv-button{min-height:30px;min-width:30px;padding:0 10px;border:1px solid var(--cia-graph-border);border-radius:6px;background:var(--cia-graph-control);color:var(--cia-graph-text);font:500 12px var(--font-sans,system-ui,sans-serif);cursor:pointer}.cv-button:hover{background:var(--cia-graph-hover)}.cv-button:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:1px}.cv-icon{padding:0;font-size:16px;line-height:1}.cv-roles{display:flex;flex-wrap:wrap;gap:4px 14px;margin:0;padding:0 14px 6px;list-style:none;font-size:12px;color:var(--cia-graph-muted)}.cv-roles li{display:inline-flex;align-items:center;gap:5px}.cv-roles i{width:9px;height:9px;border-radius:50%}.cv-canvas{position:relative;flex:1;min-height:0;border-top:1px solid var(--cia-graph-divider);border-bottom:1px solid var(--cia-graph-divider)}.cv-canvas.cia-graph-engine{min-height:0}.cv-canvas .cia-graph-svg{font-family:var(--font-sans,Inter,system-ui,sans-serif)}.cv-status{margin:0;padding:6px 14px 8px;font-size:12px;color:var(--cia-graph-muted)}.cv-detail{flex:none;padding:0 0 8px;color:var(--cia-graph-text);font-size:12px;display:flex;flex-direction:column;gap:4px}.cv-detail[hidden]{display:none}.cv-detail>strong{color:var(--cia-graph-muted);font-weight:500}.cv-detail>code{font:11px var(--font-mono,ui-monospace,monospace);overflow-wrap:anywhere;word-break:break-all}.cv-detail-meta{display:flex;flex-direction:column;gap:3px}.cv-detail-meta .meta-item{display:inline-flex;gap:5px;align-items:baseline}.cv-detail-meta .meta-item span{color:var(--cia-graph-muted)}.cv-detail-meta .meta-item strong{color:var(--cia-graph-text);font-weight:600;overflow-wrap:anywhere}.cv-detail-meta .cia-graph-explorer-link{font:inherit;font-weight:600;padding:0;border:0;border-bottom:1px solid var(--cia-graph-border);background:none;color:var(--cia-graph-edge);cursor:pointer;overflow-wrap:anywhere;text-align:left}.cv-detail-meta .cia-graph-explorer-link:hover{border-bottom-color:var(--cia-graph-edge)}.cv-face[hidden],.cv-tabpanel[hidden]{display:none}.cv-toggle{display:inline-flex;flex:none;border:1px solid var(--cia-graph-border,var(--cv-border));border-radius:6px;overflow:hidden}.cv-card-head .cv-toggle{margin-left:auto}.cv-toggle-button{min-height:28px;padding:0 12px;border:0;background:var(--cia-graph-control,var(--cv-raised));color:var(--cia-graph-text,var(--cv-text));font:500 12px var(--font-sans,system-ui,sans-serif);cursor:pointer}.cv-toggle-button+.cv-toggle-button{border-left:1px solid var(--cia-graph-border,var(--cv-border))}.cv-toggle-button:hover{background:var(--cia-graph-hover,var(--cv-border))}.cv-toggle-button[aria-pressed=true]{background:var(--cia-graph-active,var(--cv-text));color:var(--cia-graph-active-text,var(--cv-surface))}.cv-toggle-button:focus-visible{outline:2px solid var(--cia-graph-active,var(--cv-ring));outline-offset:-2px}.cia-graph-surface .cv-note{margin:0 14px 6px;background:var(--cia-graph-control);color:var(--cia-graph-text);border:1px solid var(--cia-graph-border)}.cv-tabs{display:flex;flex-wrap:wrap;gap:4px;margin:0 0 8px}.cv-tab{padding:6px 12px;border:1px solid var(--cv-border);border-radius:var(--border-radius-md,8px);background:transparent;color:var(--cv-muted);font:500 13px var(--font-sans,system-ui,sans-serif);cursor:pointer}.cv-tab:hover{color:var(--cv-text)}.cv-tab[aria-selected=true]{background:var(--cv-raised);color:var(--cv-text);border-color:var(--cv-ring)}.cv-tab:focus-visible{outline:2px solid var(--cv-ring);outline-offset:2px}.cv-chart{box-sizing:border-box;max-height:640px;overflow:auto;font-family:var(--font-sans,system-ui,sans-serif)}.cv-chart .cv-muted{color:var(--cia-graph-muted);font-size:12px}.cv-chart-summary{line-height:1.45}.cv-chart-bar{display:flex;flex-wrap:wrap;align-items:center;gap:6px 8px;padding:2px 14px 4px}.cv-chart-legend{display:flex;flex-wrap:wrap;gap:6px}.cv-chart-series,.cv-chart-reset{display:inline-flex;align-items:center;gap:6px;min-height:28px;padding:0 10px;border:1px solid var(--cia-graph-border);border-radius:6px;background:var(--cia-graph-control);color:var(--cia-graph-text);font:500 12px var(--font-sans,system-ui,sans-serif);cursor:pointer}.cv-chart-series:hover,.cv-chart-reset:hover{background:var(--cia-graph-hover)}.cv-chart-series[aria-pressed=false]{color:var(--cia-graph-muted);text-decoration:line-through}.cv-chart-series[aria-disabled=true]{cursor:default}.cv-chart-reset{margin-left:auto}.cv-chart-bar>.cv-toggle{margin-left:auto}.cv-chart-reset:not([hidden])+.cv-toggle{margin-left:0}.cv-chart-failure{fill:var(--cia-graph-hover)}.cv-chart-reset[hidden]{display:none}.cv-chart-key{display:inline-block;flex:none;width:10px;height:10px;box-sizing:border-box;border-radius:3px;border:2px solid var(--cv-key);background:var(--cv-key)}.cv-chart-series[aria-pressed=false] .cv-chart-key{background:transparent}.cv-chart-series:focus-visible,.cv-chart-reset:focus-visible,.cv-chart-plot:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:2px}.cv-chart-body{position:relative;padding:4px 14px 12px}.cv-chart-plot{border-radius:4px;cursor:crosshair;touch-action:pan-y;user-select:none;-webkit-user-select:none}.cv-chart-svg{display:block;width:100%;height:auto}.cv-chart-brush{fill:var(--cia-graph-hover);stroke:var(--cia-graph-active);stroke-width:1}.cv-chart-crossline{stroke:var(--cia-graph-muted);stroke-width:1;stroke-dasharray:3 3}.cv-chart-focus{stroke:var(--cia-graph-canvas);stroke-width:2}.cv-chart-readout{position:absolute;z-index:2;box-sizing:border-box;min-width:170px;max-width:280px;padding:8px 10px;border:1px solid var(--cia-graph-border);border-radius:8px;background:var(--cia-graph-canvas);color:var(--cia-graph-text);font:12px/1.4 var(--font-sans,system-ui,sans-serif);pointer-events:none}.cv-chart-readout[hidden]{display:none}.cv-chart-readout[data-side=left]{transform:translate(-100%)}.cv-chart-readout time{display:block;margin-bottom:4px;font-weight:600}.cv-chart-readout-note{margin:0 0 4px;color:var(--cia-graph-muted)}.cv-chart-readout dl{display:grid;grid-template-columns:auto auto;gap:2px 12px;margin:0}.cv-chart-readout dt{display:flex;align-items:center;gap:6px;min-width:0;color:var(--cia-graph-muted);overflow-wrap:anywhere}.cv-chart-readout dd{margin:0;text-align:right;font-variant-numeric:tabular-nums;font-weight:600}.cv-chart-name{fill:var(--cia-graph-text);font:600 12px var(--font-sans,Inter,system-ui,sans-serif)}.cv-chart-tick{fill:var(--cia-graph-muted);font:400 11px var(--font-sans,Inter,system-ui,sans-serif)}.cv-chart-grid{stroke:var(--cia-graph-divider);stroke-width:1}.cv-chart-base{stroke:var(--cia-graph-border);stroke-width:1}.cv-chart-line{stroke-width:2;stroke-linejoin:round;stroke-linecap:round}.cv-body{position:relative;display:flex;flex:1;min-height:0;min-width:0}.cv-body>.cv-canvas{flex:1;min-width:0}.cv-linkpanel{display:flex;flex-direction:column;flex:none;box-sizing:border-box;width:min(46%,320px);overflow:hidden;padding:10px 12px;border-top:1px solid var(--cia-graph-divider);border-bottom:1px solid var(--cia-graph-divider);border-left:1px solid var(--cia-graph-divider);font-size:12px;color:var(--cia-graph-text)}.cv-linkpanel[hidden]{display:none}.cv-link-body{flex:1;min-height:0;overflow:auto}.cv-linkpanel>[data-link-more]{flex:none;align-self:flex-start;margin-top:8px}.cv-linkpanel>[data-link-more][hidden]{display:none}.cv-link-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:4px}.cv-link-head strong{font-size:13px}.cv-link-pair{margin:0;color:var(--cia-graph-muted)}.cv-link-pair code{font:11px var(--font-mono,ui-monospace,monospace)}.cv-link-day{margin:6px 0 4px;font-weight:600}.cv-transfers+.cv-link-day{margin-top:10px}.cv-link-body p{margin:0 0 8px}.cv-link-error{color:var(--cia-graph-danger);overflow-wrap:anywhere}.cv-transfers{list-style:none;margin:0 0 8px;padding:0}.cv-transfer{display:grid;grid-template-columns:auto 1fr auto;gap:2px 8px;padding:6px 0;border-bottom:1px solid var(--cia-graph-divider)}.cv-transfer-time{color:var(--cia-graph-muted);font-variant-numeric:tabular-nums}.cv-transfer-amount{font-weight:600;overflow-wrap:anywhere}.cv-transfer-usd{text-align:right;font-variant-numeric:tabular-nums}.cv-transfer>code,.cv-transfer>.cia-graph-explorer-link{grid-column:1/-1;font:11px var(--font-mono,ui-monospace,monospace);color:var(--cia-graph-muted)}.cv-transfer>.cia-graph-explorer-link{padding:0;border:0;border-bottom:1px solid var(--cia-graph-border);background:none;text-align:left;cursor:pointer;justify-self:start;color:var(--cia-graph-edge)}.cv-transfer>.cia-graph-explorer-link:hover{border-bottom-color:var(--cia-graph-edge)}.cv-linkpanel .cv-button:disabled{opacity:.5;cursor:default}@media(max-width:560px){.cv-linkpanel{position:absolute;inset:0;width:auto;border-left:0;background:var(--cia-graph-surface)}}.cv-side{display:flex;flex-direction:column;flex:none;box-sizing:border-box;width:min(46%,340px);overflow:hidden;padding:10px 12px;border-top:1px solid var(--cia-graph-divider);border-bottom:1px solid var(--cia-graph-divider);border-left:1px solid var(--cia-graph-divider);font-size:12px;color:var(--cia-graph-text)}.cv-side[hidden]{display:none}.cv-side-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}.cv-side-head strong{font-size:13px}.cv-side-actions{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:8px}.cv-remaining{margin:0 0 8px;font-size:12px;color:var(--cia-graph-muted)}.cv-remaining[hidden]{display:none}.cv-side-actions:not(:has(button:not([hidden]))){display:none}.cv-side .cv-button:disabled{opacity:.5;cursor:default}.cv-linkpanel-embedded{flex:1;min-height:0;width:auto;padding:8px 0 0;border:0;border-top:1px solid var(--cia-graph-divider);overflow:hidden}.cv-side>.cv-detail{max-height:40%;overflow:auto}.cv-linkpanel-embedded>[data-link-pair]{display:none}.cv-linkpanel-embedded .cv-link-body{min-height:44px}.cv-side:not(:has(.cv-linkpanel-embedded:not([hidden])))>.cv-detail{max-height:none}.cv-link-pair code{word-break:break-all}@media(max-width:560px){.cv-side{position:absolute;inset:0;width:auto;border-left:0;background:var(--cia-graph-surface)}.cv-side .cv-linkpanel-embedded{position:static;width:auto;border:0;border-top:1px solid var(--cia-graph-divider);background:none}}html[data-mode=browser],html[data-mode=browser] body{height:100%}html[data-mode=browser] body{background:var(--cv-surface)}.cv-view-link{user-select:all;-webkit-user-select:all;overflow-wrap:anywhere;font-size:.85em}
|
|
722
|
+
<style>.cia-graph-surface{--cia-graph-surface:linear-gradient(140deg,#171a20,#0d0f13);--cia-graph-canvas:#101318;--cia-graph-dot:#f2dda621;--cia-graph-text:#e2e8f0;--cia-graph-muted:#adb1ba;--cia-graph-border:#f2dda640;--cia-graph-divider:#ffffff10;--cia-graph-control:#14161a;--cia-graph-hover:#f2dda626;--cia-graph-active:#f2dda6;--cia-graph-active-text:#0b0e13;--cia-graph-node:#14161a;--cia-graph-edge:#f2dda6;--cia-graph-halo:#07090d;--cia-graph-selected:#ffffff;--cia-graph-expanded:#4da3ff;--cia-graph-danger:#d89087;--cia-graph-target:#8bb6b0;--cia-graph-trail:#b49bc4;--cia-graph-infrastructure:#94b58b;--cia-graph-neutral:#f2dda6;--cia-graph-critical:#d89087;--cia-graph-high:#d6a07d;--cia-graph-medium:#b49bc4;--cia-graph-low:#94b58b;--cia-graph-role-exchange:var(--cia-graph-infrastructure);--cia-graph-role-scam:var(--cia-graph-danger);--cia-graph-role-sanctioned:var(--cia-graph-danger);--cia-graph-role-victim:var(--cia-graph-target);--cia-graph-role-pool:var(--cia-graph-trail);--cia-graph-role-self_trader:var(--cia-graph-infrastructure);--cia-graph-role-other:var(--cia-graph-neutral);--cia-graph-series-1:var(--cia-graph-edge);--cia-graph-series-2:var(--cia-graph-target);--cia-graph-series-3:var(--cia-graph-trail);--cia-graph-series-4:var(--cia-graph-infrastructure);--cia-graph-series-5:var(--cia-graph-danger);--cia-graph-series-6:var(--cia-graph-high);color:var(--cia-graph-text);background:var(--cia-graph-surface);border:1px solid var(--cia-graph-border);border-radius:14px;overflow:hidden}html[data-theme=light] .cia-graph-surface{--cia-graph-surface:#f9f9f9;--cia-graph-canvas:#fff;--cia-graph-dot:#dedede;--cia-graph-text:#242424;--cia-graph-muted:#686868;--cia-graph-border:#dedede;--cia-graph-divider:#e6e6e6;--cia-graph-control:#fff;--cia-graph-hover:#ececec;--cia-graph-active:#4e708a;--cia-graph-active-text:#fff;--cia-graph-node:#fff;--cia-graph-edge:#4e708a;--cia-graph-halo:#fff;--cia-graph-selected:#242424;--cia-graph-expanded:#0057d9;--cia-graph-danger:#a64d4b;--cia-graph-target:#356e68;--cia-graph-trail:#78538f;--cia-graph-infrastructure:#416c4a;--cia-graph-neutral:#4e708a;--cia-graph-critical:#a64d4b;--cia-graph-high:#a15432;--cia-graph-medium:#78538f;--cia-graph-low:#416c4a}.cia-graph-canvas{background:radial-gradient(circle,var(--cia-graph-dot) 1px,transparent 1px) 0 0/24px 24px,var(--cia-graph-canvas)}.graph-detail{border-top:1px solid var(--cia-graph-divider,#ffffff10);padding:1rem 1.5rem;font-size:.85rem;color:var(--cia-graph-muted,#adb1ba);line-height:1.6}.graph-detail strong{color:var(--cia-graph-text,#f2dda6)}.graph-detail p{margin:0}.graph-detail ul{padding-left:1.25rem;margin-bottom:0}.graph-detail strong,.graph-detail li{overflow-wrap:anywhere}.graph-legend{border-top:1px solid var(--cia-graph-divider,#ffffff10);padding:1rem 1.5rem;font-size:.85rem}.graph-legend summary{cursor:pointer}.graph-legend ul{list-style:none;padding:0}.graph-legend li{display:flex;flex-wrap:wrap;gap:.4rem 1rem;padding:.6rem 0;border-bottom:1px solid var(--cia-graph-divider,#ffffff0a)}.graph-legend button{color:var(--cia-graph-edge,#f2dda6);background:none;border:0;padding:0;text-align:left;cursor:pointer;font:inherit;font-family:ui-monospace,monospace;overflow-wrap:anywhere;max-width:100%}.graph-legend span{color:var(--cia-graph-muted,#adb1ba)}.graph-detail a,.graph-legend a{color:var(--cia-graph-edge,#f2dda6);text-decoration:none;border-bottom:1px solid var(--cia-graph-border,#f2dda659)}.graph-detail a:hover,.graph-legend a:hover{border-bottom-color:var(--cia-graph-edge,#f2dda6)}.graph-legend .graph-legend-link{overflow-wrap:normal;flex:none}.cia-graph-node-body{fill:var(--cia-graph-node,#14161a)}.cia-graph-node-ring{stroke:var(--cia-graph-edge,#f2dda6)}.cia-graph-node-address{fill:var(--cia-graph-muted,#adb1ba)}.cia-graph-edge-underlay{stroke:var(--cia-graph-halo,#07090d)}.cia-graph-edge-direction{stroke:var(--cia-graph-edge,#f2dda6)}.cia-graph-edge-arrow{fill:var(--cia-graph-edge,#f2dda6);stroke:var(--cia-graph-halo,#07090d)}.cia-graph-surface .graph-tooltip{background:var(--cia-graph-control);color:var(--cia-graph-text);border-color:var(--cia-graph-border)}.cia-graph-engine{position:relative;min-height:240px}.cia-graph-svg{display:block;width:100%;height:100%;touch-action:none;font-family:Inter,system-ui,sans-serif;outline:none}.cia-graph-svg:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:-2px}.cia-graph-backdrop{fill:var(--cia-graph-canvas)}.cia-graph-dot{fill:var(--cia-graph-dot)}.cia-graph-edge{cursor:pointer;outline:none;transition:opacity .15s}.cia-graph-edge-hit{fill:none;stroke:transparent}.cia-graph-edge-line{fill:none;stroke:var(--edge-tone,var(--cia-graph-edge));stroke-linecap:round}.cia-graph-edge:focus-visible .cia-graph-edge-line,.cia-graph-edge[aria-pressed=true] .cia-graph-edge-line{stroke-width:3}.cia-graph-node{cursor:pointer;outline:none}.cia-graph-engine .cia-graph-node-body{fill:var(--cia-graph-node);stroke:var(--node-tone,var(--cia-graph-neutral));stroke-width:2}.cia-graph-engine .cia-graph-node-ring{fill:none;stroke:var(--cia-graph-edge);stroke-width:2}.cia-graph-node-dot{fill:var(--node-tone,var(--cia-graph-neutral))}.cia-graph-node.is-selected .cia-graph-node-body,.cia-graph-node.is-focused .cia-graph-node-body,.cia-graph-node:focus-visible .cia-graph-node-body{stroke:var(--cia-graph-selected);stroke-width:4}.cia-graph-node text{paint-order:stroke;stroke:var(--cia-graph-halo);stroke-width:4px;stroke-linejoin:round}.cia-graph-node-role{fill:var(--node-tone,var(--cia-graph-neutral));font-size:13px;font-weight:600}.cia-graph-engine .cia-graph-node-address{fill:var(--cia-graph-muted);font:400 11px ui-monospace,monospace}.cia-graph-node-note{fill:var(--cia-graph-text);font-size:11px;font-style:italic}.cia-graph-node[data-state=refused] .cia-graph-node-body{stroke-dasharray:4 3}.cia-graph-engine .cia-graph-node[data-flag-expanded] .cia-graph-node-body{stroke:var(--cia-graph-expanded);stroke-width:5}.cia-graph-engine>.graph-tooltip{position:absolute;z-index:2;max-width:320px;padding:.5rem .65rem;border:1px solid;border-radius:6px;font:12px/1.45 Inter,system-ui,sans-serif;overflow-wrap:anywhere;pointer-events:none}.cia-graph-webgl{position:relative;display:block;width:100%;height:100%;min-height:inherit;touch-action:none;outline:none;overflow:hidden;background:radial-gradient(circle,var(--cia-graph-dot) 1px,transparent 1px) 0 0/24px 24px,var(--cia-graph-canvas)}.cia-graph-webgl:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:-2px}.cia-graph-edge-caption{font:500 10px var(--font-sans,Inter,system-ui,sans-serif);fill:var(--cia-graph-muted);paint-order:stroke;stroke:var(--cia-graph-canvas);stroke-width:3px;stroke-linejoin:round;-webkit-user-select:none;user-select:none}.cia-graph-edge[data-state=faded] .cia-graph-edge-caption{opacity:.35}:root{color-scheme:light dark}html,body{margin:0;padding:0;background:transparent}html[data-theme=dark]{color-scheme:dark;--cv-text:var(--color-text-primary,#ececec);--cv-muted:var(--color-text-secondary,#b4b4b4);--cv-surface:var(--color-background-secondary,#262624);--cv-raised:var(--color-background-tertiary,#30302e);--cv-border:var(--color-border-primary,#4a4a46);--cv-ring:var(--color-ring-primary,#8fb5ff);--cv-skeleton:#3a3a37}html[data-theme=light]{color-scheme:light;--cv-text:var(--color-text-primary,#1f1f1e);--cv-muted:var(--color-text-secondary,#5c5c58);--cv-surface:var(--color-background-secondary,#f5f4ef);--cv-raised:var(--color-background-tertiary,#ecebe5);--cv-border:var(--color-border-primary,#d6d4cc);--cv-ring:var(--color-ring-primary,#2f5fb8);--cv-skeleton:#e4e2db}body{color:var(--cv-text);font-family:var(--font-sans,system-ui,-apple-system,"Segoe UI",sans-serif);font-size:var(--font-text-sm-size,14px);line-height:var(--font-text-sm-line-height,1.45)}.cv-root{display:block}.cv-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.cv-visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap}.cv-muted{color:var(--cv-muted)}button:focus-visible{outline:2px solid var(--cv-ring);outline-offset:2px}.cv-card{box-sizing:border-box;border:var(--border-width-regular,1px) solid var(--cv-border);border-radius:var(--border-radius-lg,12px);background:var(--cv-surface);padding:14px 16px;overflow:hidden}.cv-card-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 12px;margin-bottom:10px}.cv-card-head strong{font-size:var(--font-text-md-size,15px);font-weight:var(--font-weight-semibold,600)}.cv-note{margin:0 0 10px;padding:6px 10px;border-radius:var(--border-radius-sm,6px);background:var(--color-background-warning,var(--cv-raised));color:var(--color-text-warning,var(--cv-text))}.cv-text-view p{margin:0 0 6px}.cv-text-body{white-space:pre-wrap;overflow-wrap:anywhere}.cia-graph-surface.cv-notice{box-sizing:border-box;margin:0;padding:6px 12px;border-radius:8px;font:400 13px/1.4 var(--font-sans,system-ui,-apple-system,"Segoe UI",sans-serif)}.cia-graph-surface.cv-notice-refused{border-left:3px solid var(--cia-graph-danger)}.cv-notice-empty{color:var(--cia-graph-muted)}.cv-notice p{margin:0}.cv-notice-line{overflow-wrap:anywhere}.cv-notice summary{cursor:pointer}.cv-notice summary:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:2px}.cv-notice-full{margin:4px 0 0;color:var(--cia-graph-muted);white-space:pre-wrap;overflow-wrap:anywhere}.cv-skeleton{min-height:220px}.cv-skel-line,.cv-skel-block{background:var(--cv-skeleton);border-radius:6px;margin-bottom:10px}.cv-skel-title{width:32%;height:16px}.cv-skel-sub{width:54%;height:12px}.cv-skel-block{height:160px;border-radius:10px}@media(prefers-reduced-motion:no-preference){.cv-skel-line,.cv-skel-block{animation:cv-pulse 1.6s ease-in-out infinite}}@keyframes cv-pulse{50%{opacity:.55}}.cv-table-wrap{overflow-x:auto}.cv-table{width:100%;border-collapse:collapse;font-variant-numeric:tabular-nums}.cv-table th{position:sticky;top:0;text-align:left;font-weight:var(--font-weight-semibold,600);color:var(--cv-muted);background:var(--cv-surface);border-bottom:1px solid var(--cv-border);padding:6px 10px;white-space:nowrap}.cv-table td{padding:5px 10px;border-bottom:1px solid var(--color-border-secondary,var(--cv-border));white-space:nowrap}.cv-table tr:last-child td{border-bottom:0}.cv-null{color:var(--cv-muted)}.cv-addr-cell{display:inline-flex;align-items:center;gap:6px}.cv-addr{font-family:var(--font-mono,ui-monospace,monospace);font-size:.92em}.cv-addr.is-full{-webkit-user-select:all;user-select:all}.cv-copy{font:inherit;font-size:.8em;padding:1px 7px;border:1px solid var(--cv-border);border-radius:var(--border-radius-sm,5px);background:transparent;color:var(--cv-muted);cursor:pointer}.cv-copy:hover{color:var(--cv-text);background:var(--cv-raised)}.cv-meter{height:8px;border-radius:999px;background:var(--cv-raised);overflow:hidden;margin:2px 0 12px}.cv-meter span{display:block;height:100%;background:var(--cv-ring)}.cv-balance-note{margin:2px 0 12px;font-weight:var(--font-weight-semibold,600)}.cv-facts{display:grid;grid-template-columns:max-content 1fr;gap:6px 18px;margin:0}.cv-facts dt{color:var(--cv-muted)}.cv-facts dd{margin:0;font-weight:var(--font-weight-medium,500)}.cv-flows{box-sizing:border-box;display:flex;flex-direction:column;height:640px;max-height:640px;font-family:var(--font-sans,system-ui,sans-serif)}.cv-flows[data-display-mode=fullscreen]{height:calc(100vh - var(--cv-tabs-h,0px));max-height:none;border-radius:0}.cv-flows-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px 12px;padding:10px 14px 6px}.cv-title{display:flex;flex-direction:column;min-width:0}.cv-title strong{font-size:15px;font-weight:600}.cv-title .cv-muted,.cv-flows .cv-muted{color:var(--cia-graph-muted);font-size:12px;overflow-wrap:anywhere}.cv-actions{display:flex;gap:6px;align-items:center;flex-wrap:wrap;justify-content:flex-end}.cv-hint{font-size:12px;color:var(--cia-graph-muted);margin-right:2px}.cv-hint[hidden]{display:none}.cv-button{min-height:30px;min-width:30px;padding:0 10px;border:1px solid var(--cia-graph-border);border-radius:6px;background:var(--cia-graph-control);color:var(--cia-graph-text);font:500 12px var(--font-sans,system-ui,sans-serif);cursor:pointer}.cv-button:hover{background:var(--cia-graph-hover)}.cv-button:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:1px}.cv-icon{padding:0;font-size:16px;line-height:1}.cv-roles{display:flex;flex-wrap:wrap;gap:4px 14px;margin:0;padding:0 14px 6px;list-style:none;font-size:12px;color:var(--cia-graph-muted)}.cv-roles li{display:inline-flex;align-items:center;gap:5px}.cv-roles i{width:9px;height:9px;border-radius:50%}.cv-canvas{position:relative;flex:1;min-height:0;border-top:1px solid var(--cia-graph-divider);border-bottom:1px solid var(--cia-graph-divider)}.cv-canvas.cia-graph-engine{min-height:0}.cv-canvas .cia-graph-svg{font-family:var(--font-sans,Inter,system-ui,sans-serif)}.cv-status{margin:0;padding:6px 14px 8px;font-size:12px;color:var(--cia-graph-muted)}.cv-detail{flex:none;padding:0 0 8px;color:var(--cia-graph-text);font-size:12px;display:flex;flex-direction:column;gap:4px}.cv-detail[hidden]{display:none}.cv-detail>strong{color:var(--cia-graph-muted);font-weight:500}.cv-detail>code{font:11px var(--font-mono,ui-monospace,monospace);overflow-wrap:anywhere;word-break:break-all}.cv-detail-meta{display:flex;flex-direction:column;gap:3px}.cv-detail-meta .meta-item{display:inline-flex;gap:5px;align-items:baseline}.cv-detail-meta .meta-item span{color:var(--cia-graph-muted)}.cv-detail-meta .meta-item strong{color:var(--cia-graph-text);font-weight:600;overflow-wrap:anywhere}.cv-detail-meta .cia-graph-explorer-link{font:inherit;font-weight:600;padding:0;border:0;border-bottom:1px solid var(--cia-graph-border);background:none;color:var(--cia-graph-edge);cursor:pointer;overflow-wrap:anywhere;text-align:left}.cv-detail-meta .cia-graph-explorer-link:hover{border-bottom-color:var(--cia-graph-edge)}.cv-face[hidden],.cv-tabpanel[hidden]{display:none}.cv-toggle{display:inline-flex;flex:none;border:1px solid var(--cia-graph-border,var(--cv-border));border-radius:6px;overflow:hidden}.cv-card-head .cv-toggle{margin-left:auto}.cv-toggle-button{min-height:28px;padding:0 12px;border:0;background:var(--cia-graph-control,var(--cv-raised));color:var(--cia-graph-text,var(--cv-text));font:500 12px var(--font-sans,system-ui,sans-serif);cursor:pointer}.cv-toggle-button+.cv-toggle-button{border-left:1px solid var(--cia-graph-border,var(--cv-border))}.cv-toggle-button:hover{background:var(--cia-graph-hover,var(--cv-border))}.cv-toggle-button[aria-pressed=true]{background:var(--cia-graph-active,var(--cv-text));color:var(--cia-graph-active-text,var(--cv-surface))}.cv-toggle-button:focus-visible{outline:2px solid var(--cia-graph-active,var(--cv-ring));outline-offset:-2px}.cia-graph-surface .cv-note{margin:0 14px 6px;background:var(--cia-graph-control);color:var(--cia-graph-text);border:1px solid var(--cia-graph-border)}.cv-tabs{display:flex;flex-wrap:wrap;gap:4px;margin:0 0 8px}.cv-tab{padding:6px 12px;border:1px solid var(--cv-border);border-radius:var(--border-radius-md,8px);background:transparent;color:var(--cv-muted);font:500 13px var(--font-sans,system-ui,sans-serif);cursor:pointer}.cv-tab:hover{color:var(--cv-text)}.cv-tab[aria-selected=true]{background:var(--cv-raised);color:var(--cv-text);border-color:var(--cv-ring)}.cv-tab:focus-visible{outline:2px solid var(--cv-ring);outline-offset:2px}.cv-chart{box-sizing:border-box;max-height:640px;overflow:auto;font-family:var(--font-sans,system-ui,sans-serif)}.cv-chart .cv-muted{color:var(--cia-graph-muted);font-size:12px}.cv-chart-summary{line-height:1.45}.cv-chart-bar{display:flex;flex-wrap:wrap;align-items:center;gap:6px 8px;padding:2px 14px 4px}.cv-chart-legend{display:flex;flex-wrap:wrap;gap:6px}.cv-chart-series,.cv-chart-reset{display:inline-flex;align-items:center;gap:6px;min-height:28px;padding:0 10px;border:1px solid var(--cia-graph-border);border-radius:6px;background:var(--cia-graph-control);color:var(--cia-graph-text);font:500 12px var(--font-sans,system-ui,sans-serif);cursor:pointer}.cv-chart-series:hover,.cv-chart-reset:hover{background:var(--cia-graph-hover)}.cv-chart-series[aria-pressed=false]{color:var(--cia-graph-muted);text-decoration:line-through}.cv-chart-series[aria-disabled=true]{cursor:default}.cv-chart-reset{margin-left:auto}.cv-chart-bar>.cv-toggle{margin-left:auto}.cv-chart-reset:not([hidden])+.cv-toggle{margin-left:0}.cv-chart-failure{fill:var(--cia-graph-hover)}.cv-chart-reset[hidden]{display:none}.cv-chart-key{display:inline-block;flex:none;width:10px;height:10px;box-sizing:border-box;border-radius:3px;border:2px solid var(--cv-key);background:var(--cv-key)}.cv-chart-series[aria-pressed=false] .cv-chart-key{background:transparent}.cv-chart-series:focus-visible,.cv-chart-reset:focus-visible,.cv-chart-plot:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:2px}.cv-chart-body{position:relative;padding:4px 14px 12px}.cv-chart-plot{border-radius:4px;cursor:crosshair;touch-action:pan-y;user-select:none;-webkit-user-select:none}.cv-chart-svg{display:block;width:100%;height:auto}.cv-chart-brush{fill:var(--cia-graph-hover);stroke:var(--cia-graph-active);stroke-width:1}.cv-chart-crossline{stroke:var(--cia-graph-muted);stroke-width:1;stroke-dasharray:3 3}.cv-chart-focus{stroke:var(--cia-graph-canvas);stroke-width:2}.cv-chart-readout{position:absolute;z-index:2;box-sizing:border-box;min-width:170px;max-width:280px;padding:8px 10px;border:1px solid var(--cia-graph-border);border-radius:8px;background:var(--cia-graph-canvas);color:var(--cia-graph-text);font:12px/1.4 var(--font-sans,system-ui,sans-serif);pointer-events:none}.cv-chart-readout[hidden]{display:none}.cv-chart-readout[data-side=left]{transform:translate(-100%)}.cv-chart-readout time{display:block;margin-bottom:4px;font-weight:600}.cv-chart-readout-note{margin:0 0 4px;color:var(--cia-graph-muted)}.cv-chart-readout dl{display:grid;grid-template-columns:auto auto;gap:2px 12px;margin:0}.cv-chart-readout dt{display:flex;align-items:center;gap:6px;min-width:0;color:var(--cia-graph-muted);overflow-wrap:anywhere}.cv-chart-readout dd{margin:0;text-align:right;font-variant-numeric:tabular-nums;font-weight:600}.cv-chart-name{fill:var(--cia-graph-text);font:600 12px var(--font-sans,Inter,system-ui,sans-serif)}.cv-chart-tick{fill:var(--cia-graph-muted);font:400 11px var(--font-sans,Inter,system-ui,sans-serif)}.cv-chart-grid{stroke:var(--cia-graph-divider);stroke-width:1}.cv-chart-base{stroke:var(--cia-graph-border);stroke-width:1}.cv-chart-line{stroke-width:2;stroke-linejoin:round;stroke-linecap:round}.cv-body{position:relative;display:flex;flex:1;min-height:0;min-width:0}.cv-body>.cv-canvas{flex:1;min-width:0}.cv-linkpanel{display:flex;flex-direction:column;flex:none;box-sizing:border-box;width:min(46%,320px);overflow:hidden;padding:10px 12px;border-top:1px solid var(--cia-graph-divider);border-bottom:1px solid var(--cia-graph-divider);border-left:1px solid var(--cia-graph-divider);font-size:12px;color:var(--cia-graph-text)}.cv-linkpanel[hidden]{display:none}.cv-link-body{flex:1;min-height:0;overflow:auto}.cv-linkpanel>[data-link-more]{flex:none;align-self:flex-start;margin-top:8px}.cv-linkpanel>[data-link-more][hidden]{display:none}.cv-link-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:4px}.cv-link-head strong{font-size:13px}.cv-link-pair{margin:0;color:var(--cia-graph-muted)}.cv-link-pair code{font:11px var(--font-mono,ui-monospace,monospace)}.cv-link-day{margin:6px 0 4px;font-weight:600}.cv-transfers+.cv-link-day{margin-top:10px}.cv-link-body p{margin:0 0 8px}.cv-link-error{color:var(--cia-graph-danger);overflow-wrap:anywhere}.cv-transfers{list-style:none;margin:0 0 8px;padding:0}.cv-transfer{display:grid;grid-template-columns:auto 1fr auto;gap:2px 8px;padding:6px 0;border-bottom:1px solid var(--cia-graph-divider)}.cv-transfer-time{color:var(--cia-graph-muted);font-variant-numeric:tabular-nums}.cv-transfer-amount{font-weight:600;overflow-wrap:anywhere}.cv-transfer-usd{text-align:right;font-variant-numeric:tabular-nums}.cv-transfer>code,.cv-transfer>.cia-graph-explorer-link{grid-column:1/-1;font:11px var(--font-mono,ui-monospace,monospace);color:var(--cia-graph-muted)}.cv-transfer>.cia-graph-explorer-link{padding:0;border:0;border-bottom:1px solid var(--cia-graph-border);background:none;text-align:left;cursor:pointer;justify-self:start;color:var(--cia-graph-edge)}.cv-transfer>.cia-graph-explorer-link:hover{border-bottom-color:var(--cia-graph-edge)}.cv-linkpanel .cv-button:disabled{opacity:.5;cursor:default}@media(max-width:560px){.cv-linkpanel{position:absolute;inset:0;width:auto;border-left:0;background:var(--cia-graph-surface)}}.cv-side{display:flex;flex-direction:column;flex:none;box-sizing:border-box;width:min(46%,340px);overflow:hidden;padding:10px 12px;border-top:1px solid var(--cia-graph-divider);border-bottom:1px solid var(--cia-graph-divider);border-left:1px solid var(--cia-graph-divider);font-size:12px;color:var(--cia-graph-text)}.cv-side[hidden]{display:none}.cv-side-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}.cv-side-head strong{font-size:13px}.cv-side-actions{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:8px}.cv-remaining{margin:0 0 8px;font-size:12px;color:var(--cia-graph-muted)}.cv-remaining[hidden]{display:none}.cv-side-actions:not(:has(button:not([hidden]))){display:none}.cv-side .cv-button:disabled{opacity:.5;cursor:default}.cv-linkpanel-embedded{flex:1;min-height:0;width:auto;padding:8px 0 0;border:0;border-top:1px solid var(--cia-graph-divider);overflow:hidden}.cv-side>.cv-detail{max-height:40%;overflow:auto}.cv-linkpanel-embedded>[data-link-pair]{display:none}.cv-linkpanel-embedded .cv-link-body{min-height:44px}.cv-side:not(:has(.cv-linkpanel-embedded:not([hidden])))>.cv-detail{max-height:none}.cv-link-pair code{word-break:break-all}@media(max-width:560px){.cv-side{position:absolute;inset:0;width:auto;border-left:0;background:var(--cia-graph-surface)}.cv-side .cv-linkpanel-embedded{position:static;width:auto;border:0;border-top:1px solid var(--cia-graph-divider);background:none}}html[data-mode=browser],html[data-mode=browser] body{height:100%}html[data-mode=browser] body{background:var(--cv-surface)}.cv-view-link{user-select:all;-webkit-user-select:all;overflow-wrap:anywhere;font-size:.85em}
|
|
723
723
|
</style>
|
|
724
724
|
</head>
|
|
725
725
|
<body>
|