chain-insights 0.83.0 → 0.83.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- <!-- Chain Insights UI 7ce05b736087f012bf97333cff1cd678767200f9 (npm run build:claude-view); refresh with scripts/refresh-claude-view.mjs, never edit by hand -->
1
+ <!-- Chain Insights UI f13e1e38a368693a58c5efaf86db63ee181c9ddf (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>
@@ -6,24 +6,24 @@
6
6
  <meta name="viewport" content="width=device-width,initial-scale=1">
7
7
  <meta name="color-scheme" content="light dark">
8
8
  <title>Chain Insights view</title>
9
- <script type="module">const Ak=(function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"})(),Ik=function(e,t){return new URL(e,t).href},Th={},Nk=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let c=function(l){return Promise.all(l.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};const s=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),u=a?.nonce||a?.getAttribute("nonce");i=c(n.map(l=>{if(l=Ik(l,r),l in Th)return;Th[l]=!0;const d=l.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(r)for(let p=s.length-1;p>=0;p--){const m=s[p];if(m.href===l&&(!d||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${f}`))return;const h=document.createElement("link");if(h.rel=d?"stylesheet":Ak,d||(h.as="script"),h.crossOrigin="",h.href=l,u&&h.setAttribute("nonce",u),document.head.appendChild(h),d)return new Promise((p,m)=>{h.addEventListener("load",p),h.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${l}`)))})}))}function o(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return i.then(s=>{for(const a of s||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})};function Rk(e){return e}function Lk(e){return e}function Ls(){return e=>e}function zk(e){}function Pk(e){throw new Error("Unexpected value in exhaustive check")}function Dk(e){}function fs(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function Hu(e,t="|"){return e.map(n=>Rc(n)).join(t)}function hs(e,t){return typeof t=="bigint"?t.toString():t}class Ok{constructor(t){this._getter=t,this._value=void 0}get value(){const t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}}function Ai(e){return new Ok(e)}function Ac(e){return e==null}function An(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Ic(e,t){const n=e/t,r=Math.round(n),i=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}const Ch=Symbol("evaluating");function Dm(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Ch)return r===void 0&&(r=Ch,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Mk(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Nt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function zs(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function cn(e){return zs(e._zod.def)??e._zod.def.shape}function Om(e,t,n){Object.defineProperty(e,t,{get(){const r=n();return Nt(this,t,r),r},enumerable:!0,configurable:!0})}function Mm(e,t,n){t in e?Nt(e,t,n):e[t]=n}function qn(e,t,n,r){const i=cn(t);for(const o of n){const s=Object.getOwnPropertyDescriptor(i,o);s.enumerable&&(s.get?Om(e,o,()=>{const a=t._zod.def.shape[o];return r?r(a,o):a}):Mm(e,o,r?r(s.value,o):s.value))}}function Fk(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Om(e,n,()=>t[n]):Mm(e,n,r.value))}}function ht(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Uk(e){return ht(e._zod.def)}function Gk(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function jk(e){const t=Object.keys(e),n=t.map(r=>e[r]);return Promise.all(n).then(r=>{const i={};for(let o=0;o<t.length;o++)i[t[o]]=r[o];return i})}function Zk(e=10){const t="abcdefghijklmnopqrstuvwxyz";let n="";for(let r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}function Ct(e){return JSON.stringify(e)}function Fm(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Nc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function lr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Um=Ai(()=>{if(_t.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function ln(e){if(lr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(lr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Ii(e){return ln(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Bk(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const Hk=e=>{const t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},ps=new Set(["string","number","symbol"]),Gm=new Set(["string","number","bigint","boolean","symbol","undefined"]);function dn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function He(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function R(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Vk(e){let t;return new Proxy({},{get(n,r,i){return t??(t=e()),Reflect.get(t,r,i)},set(n,r,i,o){return t??(t=e()),Reflect.set(t,r,i,o)},has(n,r){return t??(t=e()),Reflect.has(t,r)},deleteProperty(n,r){return t??(t=e()),Reflect.deleteProperty(t,r)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,i){return t??(t=e()),Reflect.defineProperty(t,r,i)}})}function Rc(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function jm(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const Lc={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},zc={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Zm(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o={};return qn(o,e,Ps(e,t)),He(e,ht(n,{shape:o,checks:[]}))}function Ps(e,t){const n=cn(e),r=[];for(const i of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,i)?.enumerable)throw new Error(`Unrecognized key: "${String(i)}"`);t[i]&&r.push(i)}return r}function Bm(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=new Set(Ps(e,t)),s={};return qn(s,e,Reflect.ownKeys(cn(e)).filter(a=>!o.has(a))),He(e,ht(n,{shape:s,checks:[]}))}function Hm(e,t){if(!ln(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=cn(e);for(const o of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return He(e,ht(e._zod.def,{shape:Vm(e,t)}))}function Vm(e,t){const n={};return qn(n,e,Reflect.ownKeys(cn(e))),Fk(n,t),n}function qm(e,t){if(!ln(t))throw new Error("Invalid input to safeExtend: expected a plain object");return He(e,ht(e._zod.def,{shape:Vm(e,t)}))}function Wm(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n={};qn(n,e,Reflect.ownKeys(cn(e))),qn(n,t,Reflect.ownKeys(cn(t)));const r=ht(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return He(e,r)}function Vu(e,t,n,r="partial"){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const a=n?new Set(Ps(t,n)):void 0,u={};return qn(u,t,Reflect.ownKeys(cn(t)),e&&((c,l)=>a&&!a.has(l)?c:new e({type:"optional",innerType:c}))),He(t,ht(t._zod.def,{shape:u,checks:[]}))}function Km(e,t,n){const r=n?new Set(Ps(t,n)):void 0,i={};return qn(i,t,Reflect.ownKeys(cn(t)),(o,s)=>r&&!r.has(s)?o:new e({type:"nonoptional",innerType:o})),He(t,ht(t._zod.def,{shape:i}))}function Et(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Jm(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Ot(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function ir(e){return typeof e=="string"?e:e?.message}function qu(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Ut(e,t,n){var r;const i=e.inst?._zod?.traits;i?.has("$ZodType")&&(i.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const o=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:ir(e.inst?._zod.def?.error?.(e))??ir(o?.(e))??ir(t?.error?.(e))??ir(n.customError?.(e))??ir(n.localeError?.(e))??"Invalid input",a={};for(const u of Object.keys(e))u==="inst"||u==="schema"||u==="continue"||u==="input"||u==="__proto__"||(a[u]=e[u]);return a.path??(a.path=[]),a.message=s,t?.reportInput&&(a.input=e.input),a}function Ds(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}const qk=/[\uD800-\uDBFF]/;function Ni(e){const t=e.length;if(!qk.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320&&(n--,r++);return n}function Os(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ym(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";const n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function dr(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function Wk(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Xm(e){const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function Qm(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function Kk(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return Xm(t+n)}function Jk(e){return Qm(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Yk(e){const t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");const n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=Number.parseInt(t.slice(r,r+2),16);return n}function Xk(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class Qk{constructor(...t){}}function eg(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):eS(e,n,r.value)}}function fn(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Ms(e,t,n){return fn(e,t,n,!1)}function Ri(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return fn(this,n,r(this))},set(i){fn(this,n,i)}})}return t}function eS(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:fn(this,t,n.bind(this))},set(r){fn(this,t,r)}})}function tS(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let hu,_n=!1;const nS={configurable:!0,get(){_n=!0}};function Ee(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&hu!==e._zod){hu=void 0;return}hu=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,nS);const i=_n;_n=!1;try{const o=n(this);return _n?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o}),_n=_n||i,o}catch(o){throw delete this[t],_n=_n||i,o}},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i})}})}function tg(e,t,n,r){const i=tS(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){const o={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,o),o.value=n(this),Object.defineProperty(this,t,o),o.value},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:o})}})}const Pc="~constantCatch";function Dc(e){const t=()=>e;return t[Pc]=!0,t}const Oc=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:zc,CONSTANT_CATCH:Pc,Class:Qk,NUMBER_FORMAT_RANGES:Lc,aborted:Et,allowsEval:Um,assert:Dk,assertEqual:Rk,assertIs:zk,assertNever:Pk,assertNotEqual:Lk,assignProp:Nt,attachSchema:qu,base64ToUint8Array:Xm,base64urlToUint8Array:Kk,cached:Ai,captureStackTrace:Nc,cleanEnum:Wk,cleanRegex:An,clone:He,cloneDef:Uk,codePointLength:Ni,constantCatch:Dc,createTransparentProxy:Vk,defineLazy:Dm,defineLazyInternal:Ee,derived:Ri,esc:Ct,escapeRegex:dn,explicitlyAborted:Jm,extend:Hm,finalizeIssue:Ut,floatSafeRemainder:Ic,getElementAtPath:Gk,getEnumValues:fs,getLengthableOrigin:Os,getParsedType:Hk,getSizableOrigin:Ds,hexToUint8Array:Yk,hide:Ms,installLazyProp:tg,isObject:lr,isPlainObject:ln,issue:dr,joinValues:Hu,jsonStringifyReplacer:hs,members:eg,merge:Wm,mergeDefs:ht,normalizeParams:R,nullish:Ac,numKeys:Bk,objectClone:Mk,omit:Bm,optionalKeys:jm,own:fn,parsedType:Ym,partial:Vu,pick:Zm,prefixIssues:Ot,primitiveTypes:Gm,promiseAllObject:jk,propertyKeyTypes:ps,randomString:Zk,rawShape:zs,required:Km,safeExtend:qm,shallowClone:Ii,slugify:Fm,stringifyPrimitive:Rc,toZod:Ls,uint8ArrayToBase64:Qm,uint8ArrayToBase64url:Jk,uint8ArrayToHex:Xk,unwrapMessage:ir},Symbol.toStringTag,{value:"Module"}));var Ah;const Mc=Object.freeze({status:"aborted"}),pu={value:void 0,enumerable:!1};let Ih="captureStackTrace"in Error?Error:null;function rS(e){const t=Ih;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return Ih=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function S(e,t,n,r){const i={};function o(f){this.def=f,this.constr=d,this.traits=new Set}o.prototype=i;const s=n,a=s&&new WeakSet;function u(f,h){if(f._zod){if(f._zod.traits.has(e))return}else{pu.value=new o(h);try{Object.defineProperty(f,"_zod",pu)}finally{pu.value=void 0}}if(f._zod.traits.add(e),t(f,h),a){const m=Object.getPrototypeOf(f),y=f._zod.constr.prototype;let b=m;for(;b&&b!==y;)b=Object.getPrototypeOf(b);const g=b??m;a.has(g)||(a.add(g),eg(g,s))}const p=d.prototype;for(const m in p)Object.prototype.hasOwnProperty.call(p,m)&&(m in f||(f[m]=p[m].bind(f)))}const c=r?.Parent??Object;class l extends c{}Object.defineProperty(l,"name",{value:e});function d(f){const h=r?.Parent?rS(l):this;u(h,f);const p=h._zod.deferred;if(p){for(const y of p)y();h._zod.deferred=void 0}const m=globalThis.__zod_globalConfig?.postProcessor;return m&&m(h),h}return Object.defineProperty(d,"init",{value:u}),Object.defineProperty(d,Symbol.hasInstance,{value:f=>r?.Parent&&f instanceof r.Parent?!0:f?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}const Fc=Symbol("zod_brand");class an extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Fs extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Ah=globalThis).__zod_globalConfig??(Ah.__zod_globalConfig={});const _t=globalThis.__zod_globalConfig;function et(e){return e&&Object.assign(_t,e),_t}function iS(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,hs,2)),e.message}function oS(e){this._zod.message=e}const sS={get:iS,set:oS,enumerable:!0,configurable:!0},mu={value:void 0,enumerable:!1},Nh=new WeakSet([Object.prototype,Error.prototype]),ng=(e,t)=>{e.name="$ZodError",mu.value=t,Object.defineProperty(e,"issues",mu),mu.value=void 0,Object.defineProperty(e,"message",sS);const n=Object.getPrototypeOf(e);Nh.has(n)||(Nh.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},rg=S("$ZodError",ng),Rt=S("$ZodError",ng,void 0,{Parent:Error});function aS(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Us(e,t=n=>n.message){const n={},r=[];for(const i of e.issues)i.path.length>0?aS(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Gs(e,t=n=>n.message){const n={_errors:[]},r=(i,o=[])=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a},[...o,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...o,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...o,...s.path]);else{const a=[...o,...s.path];if(a.length===0)n._errors.push(t(s));else{let u=n,c=0;for(;c<a.length;){const l=a[c],d=c===a.length-1;if(l==="_errors"){d&&u._errors.push(t(s)),c++;continue}Object.prototype.hasOwnProperty.call(u,l)||Object.defineProperty(u,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const f=u[l];d&&f._errors.push(t(s)),u=f,c++}}}};return r(e),n}function Uc(e,t=n=>n.message){const n={errors:[]},r=(i,o=[])=>{var s;for(const a of i.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(u=>r({issues:u},[...o,...a.path]));else if(a.code==="invalid_key")r({issues:a.issues},[...o,...a.path]);else if(a.code==="invalid_element")r({issues:a.issues},[...o,...a.path]);else{const u=[...o,...a.path];if(u.length===0){n.errors.push(t(a));continue}let c=n,l=0;for(;l<u.length;){const d=u[l],f=l===u.length-1;typeof d=="string"?(c.properties??(c.properties={}),Object.prototype.hasOwnProperty.call(c.properties,d)||Object.defineProperty(c.properties,d,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),c=c.properties[d]):(c.items??(c.items=[]),(s=c.items)[d]??(s[d]={errors:[]}),c=c.items[d]),f&&c.errors.push(t(a)),l++}}};return r(e),n}function ig(e){const t=[],n=e.map(r=>typeof r=="object"?r.key:r);for(const r of n)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function Gc(e){const t=[],n=[...e.issues].sort((r,i)=>(r.path??[]).length-(i.path??[]).length);for(const r of n)t.push(`✖ ${r.message}`),r.path?.length&&t.push(` → at ${ig(r.path)}`);return t.join(`
10
- `)}function js(e,t){return{callee:t?.callee??e,Err:t?.Err}}const Li=e=>{const t=(n,r,i,o)=>{const s=i?{...i,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new an;if(a.issues.length){const u=new(o?.Err??e)(a.issues.map(c=>Ut(c,s,et())));throw Nc(u,o?.callee??t),u}return a.value};return t},Wu=Li(Rt),zi=e=>{const t=async(n,r,i,o)=>{const s=i?{...i,async:!0}:{async:!0};let a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const u=new(o?.Err??e)(a.issues.map(c=>Ut(c,s,et())));throw Nc(u,o?.callee??t),u}return a.value};return t},Ku=zi(Rt),Pi=e=>(t,n,r)=>{const i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new an;return o.issues.length?sg(e,o.issues,i):{success:!0,data:o.value}},og=Pi(Rt);function sg(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(i=>Ut(i,n,et()))),t=void 0,n=void 0),r},set error(i){r=i,t=void 0,n=void 0}}}const Di=e=>async(t,n,r)=>{const i=r?{...r,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?sg(e,o.issues,i):{success:!0,data:o.value}},uS=Di(Rt),cS=Symbol.for("zod.compile.invalid"),lS=Symbol.for("zod.compile.fallback"),Zs=((e,t,n)=>{const r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==cS)return!0;if(r.definite===!0&&n===void 0)return!1}return dS(e,t,n)});function dS(e,t,n){const r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun;let o;if(i?(r[lS]=!0,o=i({value:t,issues:[]},r)):o=e._zod.run({value:t,issues:[]},r),o instanceof Promise)throw new an;return o.issues.length===0}const Bs=async(e,t,n)=>{const r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},jc=e=>{const t=Li(e),n=(r,i,o,s)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return t(r,i,a,js(n,s))};return n},fS=jc(Rt),Zc=e=>{const t=Li(e),n=(r,i,o,s)=>t(r,i,o,js(n,s));return n},hS=Zc(Rt),Bc=e=>{const t=zi(e),n=async(r,i,o,s)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return await t(r,i,a,js(n,s))};return n},pS=Bc(Rt),Hc=e=>{const t=zi(e),n=async(r,i,o,s)=>await t(r,i,o,js(n,s));return n},mS=Hc(Rt),Vc=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return Pi(e)(t,n,i)},gS=Vc(Rt),qc=e=>(t,n,r)=>Pi(e)(t,n,r),yS=qc(Rt),Wc=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return Di(e)(t,n,i)},vS=Wc(Rt),Kc=e=>async(t,n,r)=>Di(e)(t,n,r),bS=Kc(Rt),ag=/^[cC][0-9a-z]{6,}$/,ug=/^[0-9a-z]+$/,cg=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,lg=/^[0-9a-vA-V]{20}$/,dg=/^[A-Za-z0-9]{27}$/,fg=/^[a-zA-Z0-9_-]{21}$/;function hg(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const pg=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,wS=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,mg=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,fr=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,_S=fr(4),kS=fr(6),SS=fr(7),gg=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,xS=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,ES=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,yg=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,$S=yg,TS=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,CS="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function vg(){return new RegExp(CS,"u")}const bg=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,wg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,_g=e=>{const t=dn(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},kg=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Sg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,xg=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Eg=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,$g=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Tg=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,Jc=/^https?$/,Cg=/^\+[1-9]\d{6,14}$/,Yc=/^\d(?:[ -]?\d){11,18}$/,Ag=/^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/,Xc=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,Ig="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function AS(e){return new RegExp(`^${e}$`)}const Ng=AS(Ig);function Ju(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Rg(e){return new RegExp(`^${Ju(e)}$`)}function Lg(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${Ju({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${Ju({precision:e.precision})}`:n;return new RegExp(`^${Ig}T(?:${r})$`)}const zg=/^[\s\S]{0,}$/,Pg=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Dg=/^-?\d+n?$/,Qc=/^-?\d+$/,Er=/^-?\d+(?:\.\d+)?$/,Og=/^(?:true|false)$/i,Mg=/^null$/i,Fg=/^undefined$/i,Ug=/^[^A-Z]*$/,Gg=/^[^a-z]*$/,jg=/^[0-9a-fA-F]*$/;function Oi(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Mi(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const IS=/^[0-9a-fA-F]{32}$/,NS=Oi(22,"=="),RS=Mi(22),LS=/^[0-9a-fA-F]{40}$/,zS=Oi(27,"="),PS=Mi(27),DS=/^[0-9a-fA-F]{64}$/,OS=Oi(43,"="),MS=Mi(43),FS=/^[0-9a-fA-F]{96}$/,US=Oi(64,""),GS=Mi(64),jS=/^[0-9a-fA-F]{128}$/,ZS=Oi(86,"=="),BS=Mi(86),Hs=Object.freeze(Object.defineProperty({__proto__:null,anyString:zg,base64:xg,base64url:Eg,bigint:Dg,boolean:Og,browserEmail:TS,cidrv4:kg,cidrv6:Sg,creditCard:Yc,cuid:ag,cuid2:ug,currencyCode:Ag,date:Ng,datetime:Lg,domain:Tg,duration:pg,e164:Cg,email:gg,emoji:vg,extendedDuration:wS,guid:mg,hex:jg,hostname:$g,html5Email:xS,httpProtocol:Jc,iban:Xc,idnEmail:$S,integer:Qc,ipv4:bg,ipv6:wg,ksuid:dg,lowercase:Ug,mac:_g,md5_base64:NS,md5_base64url:RS,md5_hex:IS,nanoid:fg,nanoidOfLength:hg,null:Mg,number:Er,rfc5322Email:ES,sha1_base64:zS,sha1_base64url:PS,sha1_hex:LS,sha256_base64:OS,sha256_base64url:MS,sha256_hex:DS,sha384_base64:US,sha384_base64url:GS,sha384_hex:FS,sha512_base64:ZS,sha512_base64url:BS,sha512_hex:jS,string:Pg,time:Rg,ulid:cg,undefined:Fg,unicodeEmail:yg,uppercase:Gg,uuid:fr,uuid4:_S,uuid6:kS,uuid7:SS,xid:lg},Symbol.toStringTag,{value:"Module"})),Ve=S("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),el=e=>{const t=e.value;return!Ac(t)&&t.size!==void 0},tl=e=>{const t=e.value;return!Ac(t)&&t.length!==void 0},ms={number:"number",bigint:"bigint",object:"date"},nl=S("$ZodCheckLessThan",(e,t)=>{Ve.init(e,t);const n=ms[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:ms[typeof r.value]??n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),rl=S("$ZodCheckGreaterThan",(e,t)=>{Ve.init(e,t);const n=ms[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:ms[typeof r.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Zg=S("$ZodCheckMultipleOf",(e,t)=>{Ve.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Ic(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Bg=S("$ZodCheckNumberFormat",(e,t)=>{Ve.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[i,o]=Lc[t.format];e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}a<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),Hg=S("$ZodCheckBigIntFormat",(e,t)=>{Ve.init(e,t);const[n,r]=zc[t.format];e._zod.check=i=>{const o=i.value;o<n&&i.issues.push({origin:"bigint",input:o,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),o>r&&i.issues.push({origin:"bigint",input:o,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),Vg=S("$ZodCheckMaxSize",(e,t)=>{var n;Ve.init(e,t),(n=e._zod.def).when??(n.when=el),e._zod.check=r=>{const i=r.value;i.size<=t.maximum||r.issues.push({origin:Ds(i),code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),qg=S("$ZodCheckMinSize",(e,t)=>{var n;Ve.init(e,t),(n=e._zod.def).when??(n.when=el),e._zod.check=r=>{const i=r.value;i.size>=t.minimum||r.issues.push({origin:Ds(i),code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Wg=S("$ZodCheckSizeEquals",(e,t)=>{var n;Ve.init(e,t),(n=e._zod.def).when??(n.when=el),e._zod.check=r=>{const i=r.value,o=i.size;if(o===t.size)return;const s=o>t.size;r.issues.push({origin:Ds(i),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Kg=S("$ZodCheckMaxLength",(e,t)=>{var n;Ve.init(e,t),(n=e._zod.def).when??(n.when=tl),e._zod.check=r=>{const i=r.value,o=i.length;if((typeof i=="string"&&o>t.maximum?Ni(i):o)<=t.maximum)return;const a=Os(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Jg=S("$ZodCheckMinLength",(e,t)=>{var n;Ve.init(e,t),(n=e._zod.def).when??(n.when=tl),e._zod.check=r=>{const i=r.value,o=i.length;if((typeof i=="string"&&o>=t.minimum&&o<t.minimum*2?Ni(i):o)>=t.minimum)return;const a=Os(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Yg=S("$ZodCheckLengthEquals",(e,t)=>{var n;Ve.init(e,t),(n=e._zod.def).when??(n.when=tl),e._zod.check=r=>{const i=r.value,o=i.length,s=typeof i=="string"&&o>=t.length&&o<=t.length*2?Ni(i):o;if(s===t.length)return;const a=Os(i),u=s>t.length;r.issues.push({origin:a,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Fi=S("$ZodCheckStringFormat",(e,t)=>{var n,r;Ve.init(e,t),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Xg=S("$ZodCheckRegex",(e,t)=>{Fi.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Qg=S("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ug),Fi.init(e,t)}),ey=S("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Gg),Fi.init(e,t)}),ty=S("$ZodCheckIncludes",(e,t)=>{Ve.init(e,t);const n=dn(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),ny=S("$ZodCheckStartsWith",(e,t)=>{Ve.init(e,t);const n=new RegExp(`^${dn(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),ry=S("$ZodCheckEndsWith",(e,t)=>{Ve.init(e,t);const n=new RegExp(`.*${dn(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});function gs(e,t,n){e.issues.length&&t.issues.push(...Ot(n,e.issues))}const iy=S("$ZodCheckProperty",(e,t)=>{Ve.init(e,t),e._zod.check=n=>{const r=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(r instanceof Promise)return r.then(i=>gs(i,n,t.property));gs(r,n,t.property)}}),oy=S("$ZodCheckProperties",(e,t)=>{Ve.init(e,t),Ms(e,Symbol.iterator,function*(){yield e});let n;e._zod.check=r=>{if(r.value==null){r.issues.push({expected:"object",code:"invalid_type",input:r.value,inst:e});return}n??(n=Reflect.ownKeys(t.shape).map(s=>[s,t.shape[s]]));const i=r.value;let o;for(const[s,a]of n){const u=a._zod.run({value:i[s],issues:[]},{});u instanceof Promise?(o??(o=[]),o.push(u.then(c=>gs(c,r,s)))):gs(u,r,s)}if(o)return Promise.all(o).then(()=>{})}}),sy=S("$ZodCheckMimeType",(e,t)=>{Ve.init(e,t);const n=new Set(t.mime);e._zod.check=r=>{n.has(r.value.type)||r.issues.push({code:"invalid_value",values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),ay=S("$ZodCheckOverwrite",(e,t)=>{Ve.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class il{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
9
+ <script type="module">const Fk=(function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"})(),Uk=function(e,t){return new URL(e,t).href},Oh={},Gk=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let c=function(l){return Promise.all(l.map(d=>Promise.resolve(d).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};const s=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),u=a?.nonce||a?.getAttribute("nonce");i=c(n.map(l=>{if(l=Uk(l,r),l in Oh)return;Oh[l]=!0;const d=l.endsWith(".css"),h=d?'[rel="stylesheet"]':"";if(r)for(let p=s.length-1;p>=0;p--){const m=s[p];if(m.href===l&&(!d||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${h}`))return;const f=document.createElement("link");if(f.rel=d?"stylesheet":Fk,d||(f.as="script"),f.crossOrigin="",f.href=l,u&&f.setAttribute("nonce",u),document.head.appendChild(f),d)return new Promise((p,m)=>{f.addEventListener("load",p),f.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${l}`)))})}))}function o(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return i.then(s=>{for(const a of s||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})};function jk(e){return e}function Zk(e){return e}function Us(){return e=>e}function Bk(e){}function Hk(e){throw new Error("Unexpected value in exhaustive check")}function Vk(e){}function bs(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function Yu(e,t="|"){return e.map(n=>Fc(n)).join(t)}function ws(e,t){return typeof t=="bigint"?t.toString():t}class qk{constructor(t){this._getter=t,this._value=void 0}get value(){const t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}}function zi(e){return new qk(e)}function Oc(e){return e==null}function In(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Pc(e,t){const n=e/t,r=Math.round(n),i=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}const Ph=Symbol("evaluating");function Bm(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Ph)return r===void 0&&(r=Ph,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Wk(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Lt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Gs(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function dn(e){return Gs(e._zod.def)??e._zod.def.shape}function Hm(e,t,n){Object.defineProperty(e,t,{get(){const r=n();return Lt(this,t,r),r},enumerable:!0,configurable:!0})}function Vm(e,t,n){t in e?Lt(e,t,n):e[t]=n}function qn(e,t,n,r){const i=dn(t);for(const o of n){const s=Object.getOwnPropertyDescriptor(i,o);s.enumerable&&(s.get?Hm(e,o,()=>{const a=t._zod.def.shape[o];return r?r(a,o):a}):Vm(e,o,r?r(s.value,o):s.value))}}function Kk(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Hm(e,n,()=>t[n]):Vm(e,n,r.value))}}function pt(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Jk(e){return pt(e._zod.def)}function Yk(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function Xk(e){const t=Object.keys(e),n=t.map(r=>e[r]);return Promise.all(n).then(r=>{const i={};for(let o=0;o<t.length;o++)i[t[o]]=r[o];return i})}function Qk(e=10){const t="abcdefghijklmnopqrstuvwxyz";let n="";for(let r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}function It(e){return JSON.stringify(e)}function qm(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Mc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function lr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Wm=zi(()=>{if(kt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function fn(e){if(lr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(lr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Di(e){return fn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function eS(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const tS=e=>{const t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},_s=new Set(["string","number","symbol"]),Km=new Set(["string","number","bigint","boolean","symbol","undefined"]);function hn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function He(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function z(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function nS(e){let t;return new Proxy({},{get(n,r,i){return t??(t=e()),Reflect.get(t,r,i)},set(n,r,i,o){return t??(t=e()),Reflect.set(t,r,i,o)},has(n,r){return t??(t=e()),Reflect.has(t,r)},deleteProperty(n,r){return t??(t=e()),Reflect.deleteProperty(t,r)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,i){return t??(t=e()),Reflect.defineProperty(t,r,i)}})}function Fc(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Jm(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const Uc={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Gc={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Ym(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o={};return qn(o,e,js(e,t)),He(e,pt(n,{shape:o,checks:[]}))}function js(e,t){const n=dn(e),r=[];for(const i of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,i)?.enumerable)throw new Error(`Unrecognized key: "${String(i)}"`);t[i]&&r.push(i)}return r}function Xm(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=new Set(js(e,t)),s={};return qn(s,e,Reflect.ownKeys(dn(e)).filter(a=>!o.has(a))),He(e,pt(n,{shape:s,checks:[]}))}function Qm(e,t){if(!fn(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=dn(e);for(const o of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return He(e,pt(e._zod.def,{shape:eg(e,t)}))}function eg(e,t){const n={};return qn(n,e,Reflect.ownKeys(dn(e))),Kk(n,t),n}function tg(e,t){if(!fn(t))throw new Error("Invalid input to safeExtend: expected a plain object");return He(e,pt(e._zod.def,{shape:eg(e,t)}))}function ng(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n={};qn(n,e,Reflect.ownKeys(dn(e))),qn(n,t,Reflect.ownKeys(dn(t)));const r=pt(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return He(e,r)}function Xu(e,t,n,r="partial"){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const a=n?new Set(js(t,n)):void 0,u={};return qn(u,t,Reflect.ownKeys(dn(t)),e&&((c,l)=>a&&!a.has(l)?c:new e({type:"optional",innerType:c}))),He(t,pt(t._zod.def,{shape:u,checks:[]}))}function rg(e,t,n){const r=n?new Set(js(t,n)):void 0,i={};return qn(i,t,Reflect.ownKeys(dn(t)),(o,s)=>r&&!r.has(s)?o:new e({type:"nonoptional",innerType:o})),He(t,pt(t._zod.def,{shape:i}))}function Et(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function ig(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Mt(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function ir(e){return typeof e=="string"?e:e?.message}function Qu(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Gt(e,t,n){var r;const i=e.inst?._zod?.traits;i?.has("$ZodType")&&(i.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const o=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:ir(e.inst?._zod.def?.error?.(e))??ir(o?.(e))??ir(t?.error?.(e))??ir(n.customError?.(e))??ir(n.localeError?.(e))??"Invalid input",a={};for(const u of Object.keys(e))u==="inst"||u==="schema"||u==="continue"||u==="input"||u==="__proto__"||(a[u]=e[u]);return a.path??(a.path=[]),a.message=s,t?.reportInput&&(a.input=e.input),a}function Zs(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}const rS=/[\uD800-\uDBFF]/;function Oi(e){const t=e.length;if(!rS.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320&&(n--,r++);return n}function Bs(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function og(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";const n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function dr(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function iS(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function sg(e){const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function ag(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function oS(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return sg(t+n)}function sS(e){return ag(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function aS(e){const t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");const n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=Number.parseInt(t.slice(r,r+2),16);return n}function uS(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class cS{constructor(...t){}}function ug(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):lS(e,n,r.value)}}function pn(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Hs(e,t,n){return pn(e,t,n,!1)}function Pi(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return pn(this,n,r(this))},set(i){pn(this,n,i)}})}return t}function lS(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:pn(this,t,n.bind(this))},set(r){pn(this,t,r)}})}function dS(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let bu,kn=!1;const fS={configurable:!0,get(){kn=!0}};function Ce(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&bu!==e._zod){bu=void 0;return}bu=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,fS);const i=kn;kn=!1;try{const o=n(this);return kn?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o}),kn=kn||i,o}catch(o){throw delete this[t],kn=kn||i,o}},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i})}})}function cg(e,t,n,r){const i=dS(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){const o={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,o),o.value=n(this),Object.defineProperty(this,t,o),o.value},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:o})}})}const jc="~constantCatch";function Zc(e){const t=()=>e;return t[jc]=!0,t}const Bc=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:Gc,CONSTANT_CATCH:jc,Class:cS,NUMBER_FORMAT_RANGES:Uc,aborted:Et,allowsEval:Wm,assert:Vk,assertEqual:jk,assertIs:Bk,assertNever:Hk,assertNotEqual:Zk,assignProp:Lt,attachSchema:Qu,base64ToUint8Array:sg,base64urlToUint8Array:oS,cached:zi,captureStackTrace:Mc,cleanEnum:iS,cleanRegex:In,clone:He,cloneDef:Jk,codePointLength:Oi,constantCatch:Zc,createTransparentProxy:nS,defineLazy:Bm,defineLazyInternal:Ce,derived:Pi,esc:It,escapeRegex:hn,explicitlyAborted:ig,extend:Qm,finalizeIssue:Gt,floatSafeRemainder:Pc,getElementAtPath:Yk,getEnumValues:bs,getLengthableOrigin:Bs,getParsedType:tS,getSizableOrigin:Zs,hexToUint8Array:aS,hide:Hs,installLazyProp:cg,isObject:lr,isPlainObject:fn,issue:dr,joinValues:Yu,jsonStringifyReplacer:ws,members:ug,merge:ng,mergeDefs:pt,normalizeParams:z,nullish:Oc,numKeys:eS,objectClone:Wk,omit:Xm,optionalKeys:Jm,own:pn,parsedType:og,partial:Xu,pick:Ym,prefixIssues:Mt,primitiveTypes:Km,promiseAllObject:Xk,propertyKeyTypes:_s,randomString:Qk,rawShape:Gs,required:rg,safeExtend:tg,shallowClone:Di,slugify:qm,stringifyPrimitive:Fc,toZod:Us,uint8ArrayToBase64:ag,uint8ArrayToBase64url:sS,uint8ArrayToHex:uS,unwrapMessage:ir},Symbol.toStringTag,{value:"Module"}));var Mh;const Hc=Object.freeze({status:"aborted"}),wu={value:void 0,enumerable:!1};let Fh="captureStackTrace"in Error?Error:null;function hS(e){const t=Fh;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return Fh=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function S(e,t,n,r){const i={};function o(h){this.def=h,this.constr=d,this.traits=new Set}o.prototype=i;const s=n,a=s&&new WeakSet;function u(h,f){if(h._zod){if(h._zod.traits.has(e))return}else{wu.value=new o(f);try{Object.defineProperty(h,"_zod",wu)}finally{wu.value=void 0}}if(h._zod.traits.add(e),t(h,f),a){const m=Object.getPrototypeOf(h),y=h._zod.constr.prototype;let b=m;for(;b&&b!==y;)b=Object.getPrototypeOf(b);const g=b??m;a.has(g)||(a.add(g),ug(g,s))}const p=d.prototype;for(const m in p)Object.prototype.hasOwnProperty.call(p,m)&&(m in h||(h[m]=p[m].bind(h)))}const c=r?.Parent??Object;class l extends c{}Object.defineProperty(l,"name",{value:e});function d(h){const f=r?.Parent?hS(l):this;u(f,h);const p=f._zod.deferred;if(p){for(const y of p)y();f._zod.deferred=void 0}const m=globalThis.__zod_globalConfig?.postProcessor;return m&&m(f),f}return Object.defineProperty(d,"init",{value:u}),Object.defineProperty(d,Symbol.hasInstance,{value:h=>r?.Parent&&h instanceof r.Parent?!0:h?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}const Vc=Symbol("zod_brand");class cn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Vs extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Mh=globalThis).__zod_globalConfig??(Mh.__zod_globalConfig={});const kt=globalThis.__zod_globalConfig;function nt(e){return e&&Object.assign(kt,e),kt}function pS(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,ws,2)),e.message}function mS(e){this._zod.message=e}const gS={get:pS,set:mS,enumerable:!0,configurable:!0},_u={value:void 0,enumerable:!1},Uh=new WeakSet([Object.prototype,Error.prototype]),lg=(e,t)=>{e.name="$ZodError",_u.value=t,Object.defineProperty(e,"issues",_u),_u.value=void 0,Object.defineProperty(e,"message",gS);const n=Object.getPrototypeOf(e);Uh.has(n)||(Uh.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},dg=S("$ZodError",lg),zt=S("$ZodError",lg,void 0,{Parent:Error});function yS(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function qs(e,t=n=>n.message){const n={},r=[];for(const i of e.issues)i.path.length>0?yS(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ws(e,t=n=>n.message){const n={_errors:[]},r=(i,o=[])=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a},[...o,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...o,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...o,...s.path]);else{const a=[...o,...s.path];if(a.length===0)n._errors.push(t(s));else{let u=n,c=0;for(;c<a.length;){const l=a[c],d=c===a.length-1;if(l==="_errors"){d&&u._errors.push(t(s)),c++;continue}Object.prototype.hasOwnProperty.call(u,l)||Object.defineProperty(u,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const h=u[l];d&&h._errors.push(t(s)),u=h,c++}}}};return r(e),n}function qc(e,t=n=>n.message){const n={errors:[]},r=(i,o=[])=>{var s;for(const a of i.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(u=>r({issues:u},[...o,...a.path]));else if(a.code==="invalid_key")r({issues:a.issues},[...o,...a.path]);else if(a.code==="invalid_element")r({issues:a.issues},[...o,...a.path]);else{const u=[...o,...a.path];if(u.length===0){n.errors.push(t(a));continue}let c=n,l=0;for(;l<u.length;){const d=u[l],h=l===u.length-1;typeof d=="string"?(c.properties??(c.properties={}),Object.prototype.hasOwnProperty.call(c.properties,d)||Object.defineProperty(c.properties,d,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),c=c.properties[d]):(c.items??(c.items=[]),(s=c.items)[d]??(s[d]={errors:[]}),c=c.items[d]),h&&c.errors.push(t(a)),l++}}};return r(e),n}function fg(e){const t=[],n=e.map(r=>typeof r=="object"?r.key:r);for(const r of n)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function Wc(e){const t=[],n=[...e.issues].sort((r,i)=>(r.path??[]).length-(i.path??[]).length);for(const r of n)t.push(`✖ ${r.message}`),r.path?.length&&t.push(` → at ${fg(r.path)}`);return t.join(`
10
+ `)}function Ks(e,t){return{callee:t?.callee??e,Err:t?.Err}}const Mi=e=>{const t=(n,r,i,o)=>{const s=i?{...i,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new cn;if(a.issues.length){const u=new(o?.Err??e)(a.issues.map(c=>Gt(c,s,nt())));throw Mc(u,o?.callee??t),u}return a.value};return t},ec=Mi(zt),Fi=e=>{const t=async(n,r,i,o)=>{const s=i?{...i,async:!0}:{async:!0};let a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const u=new(o?.Err??e)(a.issues.map(c=>Gt(c,s,nt())));throw Mc(u,o?.callee??t),u}return a.value};return t},tc=Fi(zt),Ui=e=>(t,n,r)=>{const i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new cn;return o.issues.length?pg(e,o.issues,i):{success:!0,data:o.value}},hg=Ui(zt);function pg(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(i=>Gt(i,n,nt()))),t=void 0,n=void 0),r},set error(i){r=i,t=void 0,n=void 0}}}const Gi=e=>async(t,n,r)=>{const i=r?{...r,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?pg(e,o.issues,i):{success:!0,data:o.value}},vS=Gi(zt),bS=Symbol.for("zod.compile.invalid"),wS=Symbol.for("zod.compile.fallback"),Js=((e,t,n)=>{const r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==bS)return!0;if(r.definite===!0&&n===void 0)return!1}return _S(e,t,n)});function _S(e,t,n){const r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun;let o;if(i?(r[wS]=!0,o=i({value:t,issues:[]},r)):o=e._zod.run({value:t,issues:[]},r),o instanceof Promise)throw new cn;return o.issues.length===0}const Ys=async(e,t,n)=>{const r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Kc=e=>{const t=Mi(e),n=(r,i,o,s)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return t(r,i,a,Ks(n,s))};return n},kS=Kc(zt),Jc=e=>{const t=Mi(e),n=(r,i,o,s)=>t(r,i,o,Ks(n,s));return n},SS=Jc(zt),Yc=e=>{const t=Fi(e),n=async(r,i,o,s)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return await t(r,i,a,Ks(n,s))};return n},xS=Yc(zt),Xc=e=>{const t=Fi(e),n=async(r,i,o,s)=>await t(r,i,o,Ks(n,s));return n},ES=Xc(zt),Qc=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return Ui(e)(t,n,i)},$S=Qc(zt),el=e=>(t,n,r)=>Ui(e)(t,n,r),TS=el(zt),tl=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return Gi(e)(t,n,i)},CS=tl(zt),nl=e=>async(t,n,r)=>Gi(e)(t,n,r),AS=nl(zt),mg=/^[cC][0-9a-z]{6,}$/,gg=/^[0-9a-z]+$/,yg=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,vg=/^[0-9a-vA-V]{20}$/,bg=/^[A-Za-z0-9]{27}$/,wg=/^[a-zA-Z0-9_-]{21}$/;function _g(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const kg=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,IS=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Sg=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,fr=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,NS=fr(4),RS=fr(6),LS=fr(7),xg=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,zS=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,DS=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,Eg=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,OS=Eg,PS=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,MS="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function $g(){return new RegExp(MS,"u")}const Tg=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Cg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Ag=e=>{const t=hn(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},Ig=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ng=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Rg=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Lg=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,zg=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Dg=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,rl=/^https?$/,Og=/^\+[1-9]\d{6,14}$/,il=/^\d(?:[ -]?\d){11,18}$/,Pg=/^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/,ol=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,Mg="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function FS(e){return new RegExp(`^${e}$`)}const Fg=FS(Mg);function nc(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ug(e){return new RegExp(`^${nc(e)}$`)}function Gg(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${nc({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${nc({precision:e.precision})}`:n;return new RegExp(`^${Mg}T(?:${r})$`)}const jg=/^[\s\S]{0,}$/,Zg=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Bg=/^-?\d+n?$/,sl=/^-?\d+$/,$r=/^-?\d+(?:\.\d+)?$/,Hg=/^(?:true|false)$/i,Vg=/^null$/i,qg=/^undefined$/i,Wg=/^[^A-Z]*$/,Kg=/^[^a-z]*$/,Jg=/^[0-9a-fA-F]*$/;function ji(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Zi(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const US=/^[0-9a-fA-F]{32}$/,GS=ji(22,"=="),jS=Zi(22),ZS=/^[0-9a-fA-F]{40}$/,BS=ji(27,"="),HS=Zi(27),VS=/^[0-9a-fA-F]{64}$/,qS=ji(43,"="),WS=Zi(43),KS=/^[0-9a-fA-F]{96}$/,JS=ji(64,""),YS=Zi(64),XS=/^[0-9a-fA-F]{128}$/,QS=ji(86,"=="),e0=Zi(86),Xs=Object.freeze(Object.defineProperty({__proto__:null,anyString:jg,base64:Rg,base64url:Lg,bigint:Bg,boolean:Hg,browserEmail:PS,cidrv4:Ig,cidrv6:Ng,creditCard:il,cuid:mg,cuid2:gg,currencyCode:Pg,date:Fg,datetime:Gg,domain:Dg,duration:kg,e164:Og,email:xg,emoji:$g,extendedDuration:IS,guid:Sg,hex:Jg,hostname:zg,html5Email:zS,httpProtocol:rl,iban:ol,idnEmail:OS,integer:sl,ipv4:Tg,ipv6:Cg,ksuid:bg,lowercase:Wg,mac:Ag,md5_base64:GS,md5_base64url:jS,md5_hex:US,nanoid:wg,nanoidOfLength:_g,null:Vg,number:$r,rfc5322Email:DS,sha1_base64:BS,sha1_base64url:HS,sha1_hex:ZS,sha256_base64:qS,sha256_base64url:WS,sha256_hex:VS,sha384_base64:JS,sha384_base64url:YS,sha384_hex:KS,sha512_base64:QS,sha512_base64url:e0,sha512_hex:XS,string:Zg,time:Ug,ulid:yg,undefined:qg,unicodeEmail:Eg,uppercase:Kg,uuid:fr,uuid4:NS,uuid6:RS,uuid7:LS,xid:vg},Symbol.toStringTag,{value:"Module"})),Ve=S("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),al=e=>{const t=e.value;return!Oc(t)&&t.size!==void 0},ul=e=>{const t=e.value;return!Oc(t)&&t.length!==void 0},ks={number:"number",bigint:"bigint",object:"date"},cl=S("$ZodCheckLessThan",(e,t)=>{Ve.init(e,t);const n=ks[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:ks[typeof r.value]??n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ll=S("$ZodCheckGreaterThan",(e,t)=>{Ve.init(e,t);const n=ks[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:ks[typeof r.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Yg=S("$ZodCheckMultipleOf",(e,t)=>{Ve.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Pc(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Xg=S("$ZodCheckNumberFormat",(e,t)=>{Ve.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[i,o]=Uc[t.format];e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}a<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),Qg=S("$ZodCheckBigIntFormat",(e,t)=>{Ve.init(e,t);const[n,r]=Gc[t.format];e._zod.check=i=>{const o=i.value;o<n&&i.issues.push({origin:"bigint",input:o,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),o>r&&i.issues.push({origin:"bigint",input:o,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),ey=S("$ZodCheckMaxSize",(e,t)=>{var n;Ve.init(e,t),(n=e._zod.def).when??(n.when=al),e._zod.check=r=>{const i=r.value;i.size<=t.maximum||r.issues.push({origin:Zs(i),code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),ty=S("$ZodCheckMinSize",(e,t)=>{var n;Ve.init(e,t),(n=e._zod.def).when??(n.when=al),e._zod.check=r=>{const i=r.value;i.size>=t.minimum||r.issues.push({origin:Zs(i),code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),ny=S("$ZodCheckSizeEquals",(e,t)=>{var n;Ve.init(e,t),(n=e._zod.def).when??(n.when=al),e._zod.check=r=>{const i=r.value,o=i.size;if(o===t.size)return;const s=o>t.size;r.issues.push({origin:Zs(i),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),ry=S("$ZodCheckMaxLength",(e,t)=>{var n;Ve.init(e,t),(n=e._zod.def).when??(n.when=ul),e._zod.check=r=>{const i=r.value,o=i.length;if((typeof i=="string"&&o>t.maximum?Oi(i):o)<=t.maximum)return;const a=Bs(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),iy=S("$ZodCheckMinLength",(e,t)=>{var n;Ve.init(e,t),(n=e._zod.def).when??(n.when=ul),e._zod.check=r=>{const i=r.value,o=i.length;if((typeof i=="string"&&o>=t.minimum&&o<t.minimum*2?Oi(i):o)>=t.minimum)return;const a=Bs(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),oy=S("$ZodCheckLengthEquals",(e,t)=>{var n;Ve.init(e,t),(n=e._zod.def).when??(n.when=ul),e._zod.check=r=>{const i=r.value,o=i.length,s=typeof i=="string"&&o>=t.length&&o<=t.length*2?Oi(i):o;if(s===t.length)return;const a=Bs(i),u=s>t.length;r.issues.push({origin:a,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Bi=S("$ZodCheckStringFormat",(e,t)=>{var n,r;Ve.init(e,t),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),sy=S("$ZodCheckRegex",(e,t)=>{Bi.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ay=S("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Wg),Bi.init(e,t)}),uy=S("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Kg),Bi.init(e,t)}),cy=S("$ZodCheckIncludes",(e,t)=>{Ve.init(e,t);const n=hn(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),ly=S("$ZodCheckStartsWith",(e,t)=>{Ve.init(e,t);const n=new RegExp(`^${hn(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),dy=S("$ZodCheckEndsWith",(e,t)=>{Ve.init(e,t);const n=new RegExp(`.*${hn(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});function Ss(e,t,n){e.issues.length&&t.issues.push(...Mt(n,e.issues))}const fy=S("$ZodCheckProperty",(e,t)=>{Ve.init(e,t),e._zod.check=n=>{const r=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(r instanceof Promise)return r.then(i=>Ss(i,n,t.property));Ss(r,n,t.property)}}),hy=S("$ZodCheckProperties",(e,t)=>{Ve.init(e,t),Hs(e,Symbol.iterator,function*(){yield e});let n;e._zod.check=r=>{if(r.value==null){r.issues.push({expected:"object",code:"invalid_type",input:r.value,inst:e});return}n??(n=Reflect.ownKeys(t.shape).map(s=>[s,t.shape[s]]));const i=r.value;let o;for(const[s,a]of n){const u=a._zod.run({value:i[s],issues:[]},{});u instanceof Promise?(o??(o=[]),o.push(u.then(c=>Ss(c,r,s)))):Ss(u,r,s)}if(o)return Promise.all(o).then(()=>{})}}),py=S("$ZodCheckMimeType",(e,t)=>{Ve.init(e,t);const n=new Set(t.mime);e._zod.check=r=>{n.has(r.value.type)||r.issues.push({code:"invalid_value",values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),my=S("$ZodCheckOverwrite",(e,t)=>{Ve.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class dl{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
11
11
  `).filter(s=>s),i=Math.min(...r.map(s=>s.length-s.trimStart().length)),o=r.map(s=>s.slice(i)).map(s=>" ".repeat(this.indent*2)+s);for(const s of o)this.content.push(s)}compile(){const t=Function,n=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
12
12
  ${n.join(`
13
13
  `)}
14
- };`)(...Object.values(this.closed))}}const uy={major:4,minor:6,patch:5},be=S("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=uy;const r=e._zod.def.checks,i=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(const o of i)for(const s of o._zod.onattach)s(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,u,c)=>{if(a.memo)return a;let l=Et(a),d;for(const f of u){if(f._zod.def.when){if(Jm(a)||!f._zod.def.when(a))continue}else if(l)continue;const h=a.issues.length,p=f._zod.check(a);if(p instanceof Promise&&c?.async===!1)throw new an;if(d||p instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await p,a.issues.length!==h&&(qu(a.issues,h,e),l||(l=Et(a,h)))});else{if(a.issues.length===h)continue;qu(a.issues,h,e),l||(l=Et(a,h))}}return d?d.then(()=>a):a},s=(a,u,c)=>{if(Et(a))return a.aborted=!0,a;const l=o(u,i,c);if(l instanceof Promise){if(c.async===!1)throw new an;return l.then(d=>e._zod.parse(d,c))}return e._zod.parse(l,c)};e._zod.run=(a,u)=>{if(u.skipChecks)return e._zod.parse(a,u);if(u.direction==="backward"){const l=e._zod.parse({value:a.value,issues:[]},{...u,skipChecks:!0});return l instanceof Promise?l.then(d=>s(d,a,u)):s(l,a,u)}const c=e._zod.parse(a,u);if(c instanceof Promise){if(u.async===!1)throw new an;return c.then(l=>o(l,i,u))}return o(c,i,u)}}},{get"~standard"(){return Ms(this,"~standard",ol(this))},set"~standard"(e){fn(this,"~standard",e)}}),cy=(e,t)=>e.issues.length?{issues:e.issues.map(n=>Ut(n,t,et()))}:{value:e.value};async function HS(e,t){const n={async:!0};return cy(await e._zod.run({value:t,issues:[]},n),n)}function ol(e){return{validate:t=>{const n={async:!1};try{const r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return cy(r,n)}catch{}return HS(e,t)},vendor:"zod",version:1}}const Ui=S("$ZodString",(e,t)=>{be.init(e,t),e._zod.pattern=t.pattern??zg,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Ge=S("$ZodStringFormat",(e,t)=>{Fi.init(e,t),Ui.init(e,t)}),ly=S("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=mg),Ge.init(e,t)}),dy=S("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=fr(r))}else t.pattern??(t.pattern=fr());Ge.init(e,t)}),fy=S("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=gg),Ge.init(e,t)}),sl=1,gi=2;function al(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function ul(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?al(e)||gi:hy(e,t)}function hy(e,t){if(!t.normalize&&t.protocol?.source===Jc.source&&!/^https?:\/\//i.test(e))return sl;try{if(typeof URL<"u"){const n=URL;if(typeof n.parse=="function")return n.parse(e)??gi}return new URL(e)}catch{return gi}}const VS=/[\t\n\r]/g;function ys(e){return e.replace(VS,"")}function cl(e,t){return t.lastIndex=0,t.test(e.hostname)}function ll(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const py=S("$ZodURL",(e,t)=>{Ge.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),i=ul(r,t);if(i===sl){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(i===gi){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=ys(r);return}t.hostname&&!cl(i,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!ll(i,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:ys(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),my=S("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=vg()),Ge.init(e,t)}),gy=S("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?fg:hg(t.length)),Ge.init(e,t)}),yy=S("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ag),Ge.init(e,t)}),vy=S("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ug),Ge.init(e,t)}),by=S("$ZodULID",(e,t)=>{t.pattern??(t.pattern=cg),Ge.init(e,t)}),wy=S("$ZodXID",(e,t)=>{t.pattern??(t.pattern=lg),Ge.init(e,t)}),_y=S("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=dg),Ge.init(e,t)}),ky=S("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Lg(t)),Ge.init(e,t)}),Sy=S("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ng),Ge.init(e,t)}),xy=S("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Rg(t)),Ge.init(e,t)}),Ey=S("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=pg),Ge.init(e,t)}),$y=S("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=bg),Ge.init(e,t)}),qS=/^[0-9a-fA-F:.]+$/;function Vs(e){return qS.test(e)?al(`http://[${e}]`):!1}const Ty=S("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=wg),Ge.init(e,t),e._zod.check=n=>{Vs(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),Cy=S("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=_g(t.delimiter)),Ge.init(e,t)}),Ay=S("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=kg),Ge.init(e,t)});function dl(e){const t=e.split("/");if(t.length!==2)return!1;const[n,r]=t;if(!r)return!1;const i=Number(r);return`${i}`!==r||i<0||i>128?!1:Vs(n)}const Iy=S("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Sg),Ge.init(e,t),e._zod.check=n=>{dl(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function qs(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const fl=/^[0-9a-zA-Z+/]*={0,2}$/,Ny=S("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=fl),Ge.init(e,t),e._zod.check=n=>{qs(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Ws=/^[A-Za-z0-9_-]*$/;function hl(e){if(!Ws.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return qs(n)}const Ry=S("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ws),Ge.init(e,t),e._zod.check=n=>{hl(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Ly=S("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Cg),Ge.init(e,t)}),WS=/[- ]/g;function KS(e){let t=e.length,n=1,r=0;for(;t;){const i=e.charCodeAt(--t)-48;n^=1,r+=n?[0,2,4,6,8,1,3,5,7,9][i]:i}return r%10===0}function pl(e){return Yc.test(e)?KS(e.replace(WS,"")):!1}const zy=S("$ZodCreditCard",(e,t)=>{t.pattern??(t.pattern=Yc),Ge.init(e,t),e._zod.check=n=>{pl(n.value)||n.issues.push({code:"invalid_format",format:"credit_card",input:n.value,inst:e,continue:!t.abort})}});function JS(e){let t=0;const n=e.length;for(let r=4;r<n;r++){const i=e.charCodeAt(r);t=(i>=65?t*100+(i-55):t*10+(i-48))%97}for(let r=0;r<4;r++){const i=e.charCodeAt(r);t=(i>=65?t*100+(i-55):t*10+(i-48))%97}return t===1}function ml(e){return Xc.test(e)?JS(e):!1}const Py=S("$ZodIBAN",(e,t)=>{t.pattern??(t.pattern=Xc),Ge.init(e,t),e._zod.check=n=>{ml(n.value)||n.issues.push({code:"invalid_format",format:"iban",input:n.value,inst:e,continue:!t.abort})}});function gl(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const Dy=S("$ZodJWT",(e,t)=>{Ge.init(e,t),e._zod.check=n=>{gl(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Oy=S("$ZodCustomStringFormat",(e,t)=>{Ge.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),yl=S("$ZodNumber",(e,t)=>{be.init(e,t),e._zod.pattern=Er,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),My=S("$ZodNumberFormat",(e,t)=>{Bg.init(e,t),yl.init(e,t)}),vl=S("$ZodBoolean",(e,t)=>{be.init(e,t),e._zod.pattern=Og,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),bl=S("$ZodBigInt",(e,t)=>{be.init(e,t),e._zod.pattern=Dg,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),Fy=S("$ZodBigIntFormat",(e,t)=>{Hg.init(e,t),bl.init(e,t)}),Uy=S("$ZodSymbol",(e,t)=>{be.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;return typeof i=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:i,inst:e}),n}}),Gy=S("$ZodUndefined",(e,t)=>{be.init(e,t),e._zod.pattern=Fg,e._zod.values=new Set([void 0]),e._zod.parse=(n,r)=>{const i=n.value;return typeof i>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:i,inst:e}),n}}),jy=S("$ZodNull",(e,t)=>{be.init(e,t),e._zod.pattern=Mg,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const i=n.value;return i===null||n.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),n}}),Zy=S("$ZodAny",(e,t)=>{be.init(e,t),e._zod.parse=n=>n}),By=S("$ZodUnknown",(e,t)=>{be.init(e,t),e._zod.parse=n=>n}),Hy=S("$ZodNever",(e,t)=>{be.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),Vy=S("$ZodVoid",(e,t)=>{be.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;return typeof i>"u"||n.issues.push({expected:"void",code:"invalid_type",input:i,inst:e}),n}}),qy=S("$ZodDate",(e,t)=>{be.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}const i=n.value,o=i instanceof Date;return o&&!Number.isNaN(i.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:i,...o?{received:"Invalid Date"}:{},inst:e}),n}});function Rh(e,t,n){e.issues.length&&t.issues.push(...Ot(n,e.issues)),t.value[n]=e.value}const Wy=S("$ZodArray",(e,t)=>{be.init(e,t);const n=_t.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=n?n.alloc(e,r,Array(o.length),i):Array(o.length);const s=[],a=i?.abortEarly;for(let u=0;u<o.length;u++){const c=o[u],l=t.element._zod.run({value:c,issues:[]},i);if(l instanceof Promise)s.push(l.then(d=>Rh(d,r,u)));else if(Rh(l,r,u),a&&l.issues.length!==0&&Et(l))break}return s.length?Promise.all(s).then(()=>r):r}});function vs(e,t,n,r,i,o){const s=n in r,a=o==="optional";if(!(!s&&a&&i==="optional")){if(e.issues.length){if(i!==void 0&&a&&!s)return;t.issues.push(...Ot(n,e.issues))}if(!s&&i===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?(s||i==="defaulted"&&!a)&&(t.value[n]=void 0):t.value[n]=e.value}}const YS=[];function Ky(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:YS,i=r.length?[...t,...r]:t;for(const s of i)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);const o=jm(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function Jy(e,t,n,r,i,o,s){const a=[],u=i.keySet,c=i.catchall._zod,l=c.def.type,d=c.optin,f=c.optout;let h=0;for(const p in t){if(s&&n.issues.length!==h){if(Et(n,h))break;h=n.issues.length}if(u.has(p))continue;if(p==="__proto__"){l==="never"&&a.push(p);continue}if(l==="never"){a.push(p);continue}const m=c.run({value:t[p],issues:[]},r);m instanceof Promise?e.push(m.then(y=>vs(y,n,p,t,d,f))):vs(m,n,p,t,d,f)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:o,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const Yy=S("$ZodObject",(e,t)=>{be.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){const c=()=>{const l={...r};return Object.defineProperty(t,"shape",{value:l}),c.raw=l,l};c.raw=r,Object.defineProperty(t,"shape",{get:c})}const i=Ai(()=>Ky(t));Ee(e,"propValues",c=>{const l=c.def.shape,d={};for(const f in l){const h=l[f]._zod;if(h.values){Object.prototype.hasOwnProperty.call(d,f)||Nt(d,f,new Set);for(const p of h.values)d[f].add(p);h.optin!==void 0&&d[f].add(void 0)}}return d});const o=lr,s=t.catchall;let a;const u=_t.memoizer;u?.attach(e),e._zod.parse=(c,l)=>{a??(a=i.value);const d=c.value;if(!o(d))return c.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),c;c.value=u?u.alloc(e,c,{},l):{};const f=[],h=a.shape,p=l?.abortEarly;let m=c.issues.length;for(const y of a.allKeys){if(p&&c.issues.length!==m){if(Et(c,m))break;m=c.issues.length}if(y==="__proto__")continue;const b=h[y],g=b._zod.optin,w=b._zod.optout,v=b._zod.run({value:d[y],issues:[]},l);v instanceof Promise?f.push(v.then(_=>vs(_,c,y,d,g,w))):vs(v,c,y,d,g,w)}return s?Jy(f,d,c,l,i.value,e,p===!0):f.length?Promise.all(f).then(()=>c):c}}),Xy=S("$ZodObjectJIT",(e,t)=>{Yy.init(e,t);const n=e._zod.parse,r=Ai(()=>Ky(t)),i=_t.memoizer,o=h=>{const p=r.value,m=p.symbolKeys,y=new il(["payload","ctx"],{shape:h,inst:e,memo:i,syms:m}),b=_=>`shape[${_}]._zod.run({ value: input[${_}], issues: [] }, ctx)`,g=(_,k)=>`
15
- let ${_}_ab = false;
16
- for (let i = 0; i < ${_}.issues.length; i++) {
17
- const iss = ${_}.issues[i];
14
+ };`)(...Object.values(this.closed))}}const gy={major:4,minor:6,patch:5},we=S("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=gy;const r=e._zod.def.checks,i=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(const o of i)for(const s of o._zod.onattach)s(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,u,c)=>{if(a.memo)return a;let l=Et(a),d;for(const h of u){if(h._zod.def.when){if(ig(a)||!h._zod.def.when(a))continue}else if(l)continue;const f=a.issues.length,p=h._zod.check(a);if(p instanceof Promise&&c?.async===!1)throw new cn;if(d||p instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await p,a.issues.length!==f&&(Qu(a.issues,f,e),l||(l=Et(a,f)))});else{if(a.issues.length===f)continue;Qu(a.issues,f,e),l||(l=Et(a,f))}}return d?d.then(()=>a):a},s=(a,u,c)=>{if(Et(a))return a.aborted=!0,a;const l=o(u,i,c);if(l instanceof Promise){if(c.async===!1)throw new cn;return l.then(d=>e._zod.parse(d,c))}return e._zod.parse(l,c)};e._zod.run=(a,u)=>{if(u.skipChecks)return e._zod.parse(a,u);if(u.direction==="backward"){const l=e._zod.parse({value:a.value,issues:[]},{...u,skipChecks:!0});return l instanceof Promise?l.then(d=>s(d,a,u)):s(l,a,u)}const c=e._zod.parse(a,u);if(c instanceof Promise){if(u.async===!1)throw new cn;return c.then(l=>o(l,i,u))}return o(c,i,u)}}},{get"~standard"(){return Hs(this,"~standard",fl(this))},set"~standard"(e){pn(this,"~standard",e)}}),yy=(e,t)=>e.issues.length?{issues:e.issues.map(n=>Gt(n,t,nt()))}:{value:e.value};async function t0(e,t){const n={async:!0};return yy(await e._zod.run({value:t,issues:[]},n),n)}function fl(e){return{validate:t=>{const n={async:!1};try{const r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return yy(r,n)}catch{}return t0(e,t)},vendor:"zod",version:1}}const Hi=S("$ZodString",(e,t)=>{we.init(e,t),e._zod.pattern=t.pattern??jg,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),je=S("$ZodStringFormat",(e,t)=>{Bi.init(e,t),Hi.init(e,t)}),vy=S("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Sg),je.init(e,t)}),by=S("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=fr(r))}else t.pattern??(t.pattern=fr());je.init(e,t)}),wy=S("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=xg),je.init(e,t)}),hl=1,wi=2;function pl(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function ml(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?pl(e)||wi:_y(e,t)}function _y(e,t){if(!t.normalize&&t.protocol?.source===rl.source&&!/^https?:\/\//i.test(e))return hl;try{if(typeof URL<"u"){const n=URL;if(typeof n.parse=="function")return n.parse(e)??wi}return new URL(e)}catch{return wi}}const n0=/[\t\n\r]/g;function xs(e){return e.replace(n0,"")}function gl(e,t){return t.lastIndex=0,t.test(e.hostname)}function yl(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const ky=S("$ZodURL",(e,t)=>{je.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),i=ml(r,t);if(i===hl){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(i===wi){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=xs(r);return}t.hostname&&!gl(i,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!yl(i,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:xs(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Sy=S("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=$g()),je.init(e,t)}),xy=S("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?wg:_g(t.length)),je.init(e,t)}),Ey=S("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=mg),je.init(e,t)}),$y=S("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=gg),je.init(e,t)}),Ty=S("$ZodULID",(e,t)=>{t.pattern??(t.pattern=yg),je.init(e,t)}),Cy=S("$ZodXID",(e,t)=>{t.pattern??(t.pattern=vg),je.init(e,t)}),Ay=S("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=bg),je.init(e,t)}),Iy=S("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Gg(t)),je.init(e,t)}),Ny=S("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Fg),je.init(e,t)}),Ry=S("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ug(t)),je.init(e,t)}),Ly=S("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=kg),je.init(e,t)}),zy=S("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Tg),je.init(e,t)}),r0=/^[0-9a-fA-F:.]+$/;function Qs(e){return r0.test(e)?pl(`http://[${e}]`):!1}const Dy=S("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Cg),je.init(e,t),e._zod.check=n=>{Qs(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),Oy=S("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=Ag(t.delimiter)),je.init(e,t)}),Py=S("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ig),je.init(e,t)});function vl(e){const t=e.split("/");if(t.length!==2)return!1;const[n,r]=t;if(!r)return!1;const i=Number(r);return`${i}`!==r||i<0||i>128?!1:Qs(n)}const My=S("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ng),je.init(e,t),e._zod.check=n=>{vl(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function ea(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const bl=/^[0-9a-zA-Z+/]*={0,2}$/,Fy=S("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=bl),je.init(e,t),e._zod.check=n=>{ea(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),ta=/^[A-Za-z0-9_-]*$/;function wl(e){if(!ta.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return ea(n)}const Uy=S("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ta),je.init(e,t),e._zod.check=n=>{wl(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Gy=S("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Og),je.init(e,t)}),i0=/[- ]/g;function o0(e){let t=e.length,n=1,r=0;for(;t;){const i=e.charCodeAt(--t)-48;n^=1,r+=n?[0,2,4,6,8,1,3,5,7,9][i]:i}return r%10===0}function _l(e){return il.test(e)?o0(e.replace(i0,"")):!1}const jy=S("$ZodCreditCard",(e,t)=>{t.pattern??(t.pattern=il),je.init(e,t),e._zod.check=n=>{_l(n.value)||n.issues.push({code:"invalid_format",format:"credit_card",input:n.value,inst:e,continue:!t.abort})}});function s0(e){let t=0;const n=e.length;for(let r=4;r<n;r++){const i=e.charCodeAt(r);t=(i>=65?t*100+(i-55):t*10+(i-48))%97}for(let r=0;r<4;r++){const i=e.charCodeAt(r);t=(i>=65?t*100+(i-55):t*10+(i-48))%97}return t===1}function kl(e){return ol.test(e)?s0(e):!1}const Zy=S("$ZodIBAN",(e,t)=>{t.pattern??(t.pattern=ol),je.init(e,t),e._zod.check=n=>{kl(n.value)||n.issues.push({code:"invalid_format",format:"iban",input:n.value,inst:e,continue:!t.abort})}});function Sl(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const By=S("$ZodJWT",(e,t)=>{je.init(e,t),e._zod.check=n=>{Sl(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Hy=S("$ZodCustomStringFormat",(e,t)=>{je.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),xl=S("$ZodNumber",(e,t)=>{we.init(e,t),e._zod.pattern=$r,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),Vy=S("$ZodNumberFormat",(e,t)=>{Xg.init(e,t),xl.init(e,t)}),El=S("$ZodBoolean",(e,t)=>{we.init(e,t),e._zod.pattern=Hg,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),$l=S("$ZodBigInt",(e,t)=>{we.init(e,t),e._zod.pattern=Bg,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),qy=S("$ZodBigIntFormat",(e,t)=>{Qg.init(e,t),$l.init(e,t)}),Wy=S("$ZodSymbol",(e,t)=>{we.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;return typeof i=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:i,inst:e}),n}}),Ky=S("$ZodUndefined",(e,t)=>{we.init(e,t),e._zod.pattern=qg,e._zod.values=new Set([void 0]),e._zod.parse=(n,r)=>{const i=n.value;return typeof i>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:i,inst:e}),n}}),Jy=S("$ZodNull",(e,t)=>{we.init(e,t),e._zod.pattern=Vg,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const i=n.value;return i===null||n.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),n}}),Yy=S("$ZodAny",(e,t)=>{we.init(e,t),e._zod.parse=n=>n}),Xy=S("$ZodUnknown",(e,t)=>{we.init(e,t),e._zod.parse=n=>n}),Qy=S("$ZodNever",(e,t)=>{we.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),ev=S("$ZodVoid",(e,t)=>{we.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;return typeof i>"u"||n.issues.push({expected:"void",code:"invalid_type",input:i,inst:e}),n}}),tv=S("$ZodDate",(e,t)=>{we.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}const i=n.value,o=i instanceof Date;return o&&!Number.isNaN(i.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:i,...o?{received:"Invalid Date"}:{},inst:e}),n}});function Gh(e,t,n){e.issues.length&&t.issues.push(...Mt(n,e.issues)),t.value[n]=e.value}const nv=S("$ZodArray",(e,t)=>{we.init(e,t);const n=kt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=n?n.alloc(e,r,Array(o.length),i):Array(o.length);const s=[],a=i?.abortEarly;for(let u=0;u<o.length;u++){const c=o[u],l=t.element._zod.run({value:c,issues:[]},i);if(l instanceof Promise)s.push(l.then(d=>Gh(d,r,u)));else if(Gh(l,r,u),a&&l.issues.length!==0&&Et(l))break}return s.length?Promise.all(s).then(()=>r):r}});function Es(e,t,n,r,i,o){const s=n in r,a=o==="optional";if(!(!s&&a&&i==="optional")){if(e.issues.length){if(i!==void 0&&a&&!s)return;t.issues.push(...Mt(n,e.issues))}if(!s&&i===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?(s||i==="defaulted"&&!a)&&(t.value[n]=void 0):t.value[n]=e.value}}const a0=[];function rv(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:a0,i=r.length?[...t,...r]:t;for(const s of i)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);const o=Jm(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function iv(e,t,n,r,i,o,s){const a=[],u=i.keySet,c=i.catchall._zod,l=c.def.type,d=c.optin,h=c.optout;let f=0;for(const p in t){if(s&&n.issues.length!==f){if(Et(n,f))break;f=n.issues.length}if(u.has(p))continue;if(p==="__proto__"){l==="never"&&a.push(p);continue}if(l==="never"){a.push(p);continue}const m=c.run({value:t[p],issues:[]},r);m instanceof Promise?e.push(m.then(y=>Es(y,n,p,t,d,h))):Es(m,n,p,t,d,h)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:o,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const ov=S("$ZodObject",(e,t)=>{we.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){const c=()=>{const l={...r};return Object.defineProperty(t,"shape",{value:l}),c.raw=l,l};c.raw=r,Object.defineProperty(t,"shape",{get:c})}const i=zi(()=>rv(t));Ce(e,"propValues",c=>{const l=c.def.shape,d={};for(const h in l){const f=l[h]._zod;if(f.values){Object.prototype.hasOwnProperty.call(d,h)||Lt(d,h,new Set);for(const p of f.values)d[h].add(p);f.optin!==void 0&&d[h].add(void 0)}}return d});const o=lr,s=t.catchall;let a;const u=kt.memoizer;u?.attach(e),e._zod.parse=(c,l)=>{a??(a=i.value);const d=c.value;if(!o(d))return c.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),c;c.value=u?u.alloc(e,c,{},l):{};const h=[],f=a.shape,p=l?.abortEarly;let m=c.issues.length;for(const y of a.allKeys){if(p&&c.issues.length!==m){if(Et(c,m))break;m=c.issues.length}if(y==="__proto__")continue;const b=f[y],g=b._zod.optin,_=b._zod.optout,v=b._zod.run({value:d[y],issues:[]},l);v instanceof Promise?h.push(v.then(w=>Es(w,c,y,d,g,_))):Es(v,c,y,d,g,_)}return s?iv(h,d,c,l,i.value,e,p===!0):h.length?Promise.all(h).then(()=>c):c}}),sv=S("$ZodObjectJIT",(e,t)=>{ov.init(e,t);const n=e._zod.parse,r=zi(()=>rv(t)),i=kt.memoizer,o=f=>{const p=r.value,m=p.symbolKeys,y=new dl(["payload","ctx"],{shape:f,inst:e,memo:i,syms:m}),b=w=>`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`,g=(w,k)=>`
15
+ let ${w}_ab = false;
16
+ for (let i = 0; i < ${w}.issues.length; i++) {
17
+ const iss = ${w}.issues[i];
18
18
  iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
19
19
  payload.issues.push(iss);
20
- if (iss.continue !== true) ${_}_ab = true;
20
+ if (iss.continue !== true) ${w}_ab = true;
21
21
  }
22
- if (${_}_ab && ctx && ctx.abortEarly) {
22
+ if (${w}_ab && ctx && ctx.abortEarly) {
23
23
  payload.value = newResult;
24
24
  return payload;
25
- }`;y.write("const input = payload.value;");const w=Object.create(null);let v=0;for(const _ of p.allKeys)w[_]=`key_${v++}`;y.write(i?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const _ of p.allKeys){if(_==="__proto__")continue;const k=w[_],x=typeof _=="symbol"?`syms[${m.indexOf(_)}]`:Ct(_),N=`${x} in input`,M=h[_],F=M?._zod?.optin,B=F!==void 0,ee=M?._zod?.optout==="optional";if(y.write(`const ${k} = ${b(x)};`),B&&ee){const ce=F==="optional"?`${k}_present`:`${k}.value !== undefined || ${k}_present`;y.write(`
26
- const ${k}_present = ${N};
25
+ }`;y.write("const input = payload.value;");const _=Object.create(null);let v=0;for(const w of p.allKeys)_[w]=`key_${v++}`;y.write(i?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const w of p.allKeys){if(w==="__proto__")continue;const k=_[w],x=typeof w=="symbol"?`syms[${m.indexOf(w)}]`:It(w),D=`${x} in input`,F=f[w],M=F?._zod?.optin,Z=M!==void 0,ne=F?._zod?.optout==="optional";if(y.write(`const ${k} = ${b(x)};`),Z&&ne){const ce=M==="optional"?`${k}_present`:`${k}.value !== undefined || ${k}_present`;y.write(`
26
+ const ${k}_present = ${D};
27
27
  if (!${k}.issues.length || ${k}_present) {
28
28
  if (${k}.issues.length) {${g(k,x)}
29
29
  }
@@ -33,15 +33,15 @@ ${n.join(`
33
33
  }
34
34
  }
35
35
 
36
- `)}else B?(y.write(`
36
+ `)}else Z?(y.write(`
37
37
  if (${k}.issues.length) {${g(k,x)}
38
38
  }
39
- `),F==="defaulted"?y.write(`newResult[${x}] = ${k}.value;`):y.write(`
40
- if (${k}.value !== undefined || ${N}) {
39
+ `),M==="defaulted"?y.write(`newResult[${x}] = ${k}.value;`):y.write(`
40
+ if (${k}.value !== undefined || ${D}) {
41
41
  newResult[${x}] = ${k}.value;
42
42
  }
43
43
  `)):y.write(`
44
- const ${k}_present = ${N};
44
+ const ${k}_present = ${D};
45
45
  if (${k}.issues.length) {${g(k,x)}
46
46
  }
47
47
  if (!${k}_present && !${k}.issues.length) {
@@ -61,19 +61,19 @@ ${n.join(`
61
61
  newResult[${x}] = ${k}.value;
62
62
  }
63
63
 
64
- `)}return y.write("payload.value = newResult;"),y.write("return payload;"),y.compile()};let s;const a=lr,u=!_t.jitless,l=u&&Um.value,d=t.catchall;let f;e._zod.parse=(h,p)=>{f??(f=r.value);const m=h.value;return a(m)?u&&l&&p?.async===!1&&p.jitless!==!0?(s||(s=o(t.shape)),h=s(h,p),d?Jy([],m,h,p,f,e,p?.abortEarly===!0):h):n(h,p):(h.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),h)}});function Lh(e,t,n,r){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const i=e.filter(o=>!Et(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(s=>Ut(s,r,et())))}),t)}const Ks=S("$ZodUnion",(e,t)=>{be.init(e,t),Ee(e,"optin",r=>r.def.options.some(i=>i._zod.optin==="defaulted")?"defaulted":r.def.options.some(i=>i._zod.optin!==void 0)?"optional":void 0),Ee(e,"optout",r=>r.def.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Ee(e,"values",r=>{if(r.def.options.every(i=>i._zod.values))return new Set(r.def.options.flatMap(i=>Array.from(i._zod.values)))}),Ee(e,"pattern",r=>{if(r.def.options.every(i=>i._zod.pattern)){const i=r.def.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>An(o.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let o=!1;const s=[];for(const a of t.options){const u=a._zod.run({value:r.value,issues:[]},i);if(u instanceof Promise)s.push(u),o=!0;else{if(u.issues.length===0)return u;s.push(u)}}return o?Promise.all(s).then(a=>Lh(a,r,e,i)):Lh(s,r,e,i)}});function zh(e,t,n,r){const i=[];for(let o=0;o<e.length;o++)e[o].issues.length===0&&i.push(o);return i.length===1?(t.value=e[i[0]].value,t):(i.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(s=>Ut(s,r,et())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1,matches:i}),t)}const Qy=S("$ZodXor",(e,t)=>{Ks.init(e,t),t.inclusive=!1;const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let o=!1;const s=[];for(const a of t.options){const u=a._zod.run({value:r.value,issues:[]},i);u instanceof Promise?(s.push(u),o=!0):s.push(u)}return o?Promise.all(s).then(a=>zh(a,r,e,i)):zh(s,r,e,i)}});function wl(e,t){const n=e._zod;let r=n.bag.optionsMap;r||(r=ev(n.def),n.bag.optionsMap=r);const i=r.get(t);if(i===null)throw new Error(`Ambiguous discriminator value "${String(t)}"`);return i}function ev(e){const t=new Map;for(const n of e.options){const r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(const i of r)if(t.has(i)){if(i!==void 0)throw new Error(`Duplicate discriminator value "${String(i)}"`);t.set(i,null)}else t.set(i,n)}return t}const tv=S("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ks.init(e,t);const n=e._zod.parse;Ee(e,"propValues",i=>{const o={};let s=0;for(const a of i.def.options){const u=a._zod.propValues;if(!u||Object.keys(u).length===0)throw new Error(`Invalid discriminated union option at index "${i.def.options.indexOf(a)}"`);u[i.def.discriminator]?.has(void 0)&&s++;for(const[c,l]of Object.entries(u)){Object.prototype.hasOwnProperty.call(o,c)||Nt(o,c,new Set);for(const d of l)o[c].add(d)}}return!i.def.unionFallback&&s>1&&o[i.def.discriminator]?.delete(void 0),o}),t.options.forEach((i,o)=>{const s=zs(i._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw new Error(`Invalid discriminated union option at index "${o}"`)});const r=Ai(()=>ev(t));e._zod.parse=(i,o)=>{const s=i.value;if(!lr(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),i;const a=s?.[t.discriminator],u=r.value.get(a);return u&&(a!==void 0||o.direction!=="backward")?u._zod.run(i,o):t.unionFallback||o.direction==="backward"?n(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(c=>r.value.get(c)!==null),input:s,path:[t.discriminator],inst:e}),i)}}),nv=S("$ZodIntersection",(e,t)=>{be.init(e,t),e._zod.parse=(n,r)=>{const i=n.value,o=t.left._zod.run({value:i,issues:[]},r),s=t.right._zod.run({value:i,issues:[]},r);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([u,c])=>Ph(n,u,c)):Ph(n,o,s)}});function yi(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ln(e)&&ln(t)){const n=Object.keys(t),r=Object.keys(e).filter(o=>n.indexOf(o)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,"__proto__")&&delete i.__proto__;for(const o of r){if(o==="__proto__")continue;const s=yi(e[o],t[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};i[o]=s.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const i=e[r],o=t[r],s=yi(i,o);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ph(e,t,n){const r=new Map;let i;const o=new Map,s=(c,l)=>{let d;if(c.code==="unrecognized_keys"&&!c.path?.length)i??(i=c),d=c.keys;else if(c.code==="invalid_key"&&c.origin==="record"&&c.path?.length===1){const f=String(c.path[0]);o.has(f)||o.set(f,c),d=[f]}else return!1;for(const f of d)r.has(f)||r.set(f,{}),r.get(f)[l]=!0;return!0};for(const c of t.issues)s(c,"l")||e.issues.push(c);for(const c of n.issues)s(c,"r")||e.issues.push(c);const a=[...r].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(a.length){const c=i?a.filter(l=>i.keys.includes(l)):[];c.length&&e.issues.push({...i,keys:c});for(const l of a)!c.includes(l)&&o.has(l)&&e.issues.push(o.get(l))}const u=yi(t.value,n.value);if(!u.valid){if(Et(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const _l=S("$ZodTuple",(e,t)=>{be.init(e,t);const n=t.items,r=_t.memoizer;r?.attach(e),e._zod.parse=(i,o)=>{const s=i.value;if(!Array.isArray(s))return i.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),i;i.value=r?r.alloc(e,i,[],o):[];const a=[],u=Dh(n,"optin"),c=Dh(n,"optout");if(!t.rest){if(s.length<u)return i.issues.push({code:"too_small",minimum:u,inclusive:!0,input:s,inst:e,origin:"array"}),i;s.length>n.length&&i.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:s,inst:e,origin:"array"})}const l=new Array(n.length),d=t.rest?o?.abortEarly:void 0;let f=!1;for(let h=0;h<n.length;h++){const p=n[h]._zod.run({value:s[h],issues:[]},o);p instanceof Promise?a.push(p.then(m=>{l[h]=m})):(l[h]=p,d&&!f&&p.issues.length&&(f=Et(p)))}if(t.rest&&!f){let h=n.length-1;const p=s.slice(n.length);let m=i.issues.length;for(const y of p){if(d&&i.issues.length!==m){if(Et(i,m))break;m=i.issues.length}h++;const b=t.rest._zod.run({value:y,issues:[]},o);b instanceof Promise?a.push(b.then(g=>Oh(g,i,h))):Oh(b,i,h)}}return a.length?Promise.all(a).then(()=>Mh(l,i,n,s,c)):Mh(l,i,n,s,c)}});function Dh(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function Oh(e,t,n){e.issues.length&&t.issues.push(...Ot(n,e.issues)),t.value[n]=e.value}function Mh(e,t,n,r,i){for(let o=0;o<n.length;o++){const s=e[o],a=o<r.length;if(!a&&o>=i&&n[o]._zod.optin==="optional"){t.value.length=o;break}if(s.issues.length){if(!a&&o>=i){t.value.length=o;break}t.issues.push(...Ot(o,s.issues))}t.value[o]=s.value}for(let o=t.value.length-1;o>=r.length&&(n[o]._zod.optout==="optional"&&t.value[o]===void 0);o--)t.value.length=o;return t}const rv=S("$ZodRecord",(e,t)=>{be.init(e,t);const n=_t.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!ln(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;const s=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};const u=new Set;for(const l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(u.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;const d=t.keyType._zod.run({value:l,issues:[]},i);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(p=>Ut(p,i,et())),input:l,path:[l],inst:e});continue}const f=d.value;if(f==="__proto__")continue;const h=t.valueType._zod.run({value:o[l],issues:[]},i);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&r.issues.push(...Ot(l,p.issues)),r.value[f]=p.value})):(h.issues.length&&r.issues.push(...Ot(l,h.issues)),r.value[f]=h.value)}let c;for(const l in o)if(!u.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;r.value[l]=o[l]}else c=c??[],c.push(l);c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let u;for(const c of Reflect.ownKeys(o)){if(c==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,c))continue;let l=t.keyType._zod.run({value:c,issues:[]},i);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&Er.test(c)&&l.issues.length){const p=t.keyType._zod.run({value:Number(c),issues:[]},i);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(l=p)}if(l.issues.length){t.mode==="loose"?r.value[c]=o[c]:a?(u=u??[],u.push(c)):r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(p=>Ut(p,i,et())),input:c,path:[c],inst:e});continue}const f=l.value;if(f==="__proto__")continue;const h=t.valueType._zod.run({value:o[c],issues:[]},i);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&r.issues.push(...Ot(c,p.issues)),r.value[f]=p.value})):(h.issues.length&&r.issues.push(...Ot(c,h.issues)),r.value[f]=h.value)}u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:u,continue:!0})}return s.length?Promise.all(s).then(()=>r):r}}),iv=S("$ZodMap",(e,t)=>{be.init(e,t);const n=_t.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!(o instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:o,inst:e}),r;const s=[];r.value=n?n.alloc(e,r,new Map,i):new Map;const a=i?.abortEarly;let u=r.issues.length;for(const[c,l]of o){if(a&&r.issues.length!==u){if(Et(r,u))break;u=r.issues.length}const d=t.keyType._zod.run({value:c,issues:[]},i),f=t.valueType._zod.run({value:l,issues:[]},i);d instanceof Promise||f instanceof Promise?s.push(Promise.all([d,f]).then(([h,p])=>{Fh(h,p,r,c,o,e,i)})):Fh(d,f,r,c,o,e,i)}return s.length?Promise.all(s).then(()=>r):r}});function Fh(e,t,n,r,i,o,s){e.issues.length&&(ps.has(typeof r)?n.issues.push(...Ot(r,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:i,inst:o,issues:e.issues.map(a=>Ut(a,s,et()))})),t.issues.length&&(ps.has(typeof r)?n.issues.push(...Ot(r,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:i,inst:o,key:r,issues:t.issues.map(a=>Ut(a,s,et()))})),n.value.set(e.value,t.value)}const ov=S("$ZodSet",(e,t)=>{be.init(e,t);const n=_t.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!(o instanceof Set))return r.issues.push({input:o,inst:e,expected:"set",code:"invalid_type"}),r;const s=[];r.value=n?n.alloc(e,r,new Set,i):new Set;const a=i?.abortEarly;let u=r.issues.length;for(const c of o){if(a&&r.issues.length!==u){if(Et(r,u))break;u=r.issues.length}const l=t.valueType._zod.run({value:c,issues:[]},i);l instanceof Promise?s.push(l.then(d=>Uh(d,r))):Uh(l,r)}return s.length?Promise.all(s).then(()=>r):r}});function Uh(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const sv=S("$ZodEnum",(e,t)=>{be.init(e,t);const n=fs(t.entries),r=new Set(n);e._zod.values=r,Ee(e,"pattern",i=>{const o=fs(i.def.entries).filter(s=>ps.has(typeof s));return new RegExp(o.length?`^(${o.map(s=>dn(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,o)=>{const s=i.value;return r.has(s)||i.issues.push({code:"invalid_value",values:n,input:s,inst:e}),i}}),av=S("$ZodLiteral",(e,t)=>{be.init(e,t);const n=new Set(t.values);e._zod.values=n,Ee(e,"pattern",r=>{const i=r.def.values;return new RegExp(i.length?`^(${i.map(o=>typeof o=="string"?dn(o):o?dn(o.toString()):String(o)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,i)=>{const o=r.value;return n.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}}),uv=S("$ZodFile",(e,t)=>{be.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;return i instanceof File||n.issues.push({expected:"file",code:"invalid_type",input:i,inst:e}),n}}),cv=S("$ZodTransform",(e,t)=>{be.init(e,t),e._zod.optin="optional",_t.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Fs(e.constructor.name);const i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(s=>(n.value=s,n));if(i instanceof Promise)throw new an;return n.value=i,n}});function Gh(e,t){return e.value=t.issues.length?void 0:t.value,e}const kl=S("$ZodOptional",(e,t)=>{be.init(e,t),Ee(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",Ee(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),Ee(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${An(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;const i=t.innerType._zod.run({value:n.value,issues:[]},r);return i instanceof Promise?i.then(o=>Gh(n,o)):Gh(n,i)}return t.innerType._zod.run(n,r)}}),lv=S("$ZodExactOptional",(e,t)=>{kl.init(e,t),Ee(e,"values",n=>n.def.innerType._zod.values),Ee(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),dv=S("$ZodNullable",(e,t)=>{be.init(e,t),Ee(e,"optin",n=>n.def.innerType._zod.optin),Ee(e,"optout",n=>n.def.innerType._zod.optout),Ee(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${An(r.source)}|null)$`):void 0}),Ee(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),fv=S("$ZodDefault",(e,t)=>{be.init(e,t),e._zod.optin="defaulted",Ee(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>jh(o,t)):jh(i,t)}});function jh(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const hv=S("$ZodPrefault",(e,t)=>{be.init(e,t),e._zod.optin="defaulted",Ee(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),pv=S("$ZodNonOptional",(e,t)=>{be.init(e,t),Ee(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r].filter(i=>i!==void 0)):void 0}),e._zod.parse=(n,r)=>{const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>Zh(o,e)):Zh(i,e)}});function Zh(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const mv=S("$ZodSuccess",(e,t)=>{be.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Fs("ZodSuccess");const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>(n.value=o.issues.length===0,n)):(n.value=i.issues.length===0,n)}});function Bh(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(i=>Ut(i,r,et()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const gv=S("$ZodCatch",(e,t)=>{be.init(e,t),Ee(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),Ee(e,"optout",n=>n.def.innerType._zod.optout),Ee(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run({value:n.value,issues:[]},r);return i instanceof Promise?i.then(o=>Bh(n,o,t,r)):Bh(n,i,t,r)}}),yv=S("$ZodNaN",(e,t)=>{be.init(e,t),e._zod.parse=(n,r)=>((typeof n.value!="number"||!Number.isNaN(n.value))&&n.issues.push({input:n.value,inst:e,expected:"nan",code:"invalid_type"}),n)}),Sl=S("$ZodPipe",(e,t)=>{be.init(e,t),Ee(e,"values",n=>n.def.in._zod.values),Ee(e,"optin",n=>n.def.in._zod.optin),Ee(e,"optout",n=>n.def.out._zod.optout),Ee(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const o=t.out._zod.run(n,r);return o instanceof Promise?o.then(s=>Fo(s,t.in,r)):Fo(o,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(o=>Fo(o,t.out,r)):Fo(i,t.out,r)}});function Fo(e,t,n){return e.issues.some(r=>r.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const xl=S("$ZodCodec",(e,t)=>{be.init(e,t),Ee(e,"values",n=>n.def.in._zod.values),Ee(e,"optin",n=>n.def.in._zod.optin),Ee(e,"optout",n=>n.def.out._zod.optout),Ee(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if((r.direction||"forward")==="forward"){const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>Uo(s,t,r)):Uo(o,t,r)}else{const o=t.out._zod.run(n,r);return o instanceof Promise?o.then(s=>Uo(s,t,r)):Uo(o,t,r)}}});function Uo(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){const i=t.transform(e.value,e);return i instanceof Promise?i.then(o=>Go(e,o,t.out,n)):Go(e,i,t.out,n)}else{const i=t.reverseTransform(e.value,e);return i instanceof Promise?i.then(o=>Go(e,o,t.in,n)):Go(e,i,t.in,n)}}function Go(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}const vv=S("$ZodPreprocess",(e,t)=>{Sl.init(e,t)}),bv=S("$ZodReadonly",(e,t)=>{be.init(e,t),Ee(e,"propValues",n=>n.def.innerType._zod.propValues),Ee(e,"values",n=>n.def.innerType._zod.values),Ee(e,"optin",n=>n.def.innerType?._zod?.optin),Ee(e,"optout",n=>n.def.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(Hh):Hh(i)}});function Hh(e){return e.memo||(e.value=Object.freeze(e.value)),e}function XS(e){const t=e._zod.def;let n=t.pattern,r=!!t.format?.includes("int"),i,o;for(const a of t.checks??[]){const u=a._zod.def;u.pattern&&(n=u.pattern),r||(r=!!u.format?.includes("int"));const c=u.minimum??u.length,l=u.maximum??u.length;c!==void 0&&(i===void 0||c>i)&&(i=c),l!==void 0&&(o===void 0||l<o)&&(o=l)}if(n)return n.source;if(i!==void 0&&o!==void 0&&i>o)return"(?!)";if(i!==void 0||o!==void 0)return Pg({minimum:i,maximum:o}).source;const s=e._zod.pattern;return(r&&s===Er?Qc:s)?.source}function Yu(e){const t=e._zod.def,n=e._zod.pattern?.source,r=t.innerType??e._zod.innerType;if(r){const i=r._zod.pattern?.source,o=Yu(r);return n&&i&&o&&o!==i?n.replace(An(i),()=>An(o)):n}if(t.options){const i=t.options.map(Yu);if(i.every(Boolean))return`^(${i.map(o=>An(o)).join("|")})$`}return XS(e)}const wv=S("$ZodTemplateLiteral",(e,t)=>{be.init(e,t);const n=[];for(const r of t.parts)if(typeof r=="object"&&r!==null){const i=Yu(r);if(!i)throw new Error(`Invalid template literal part, no pattern found: ${[...r._zod.traits].shift()}`);n.push(An(i))}else if(r===null||Gm.has(typeof r))n.push(dn(`${r}`));else throw new Error(`Invalid template literal part: ${r}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(r,i)=>typeof r.value!="string"?(r.issues.push({input:r.value,inst:e,expected:"string",code:"invalid_type"}),r):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(r.value)||r.issues.push({input:r.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),r)}),_v=S("$ZodFunction",(e,t)=>(be.init(e,t),Object.defineProperty(e,"_def",{value:t}),e._zod.def=t,e.implement=n=>{if(typeof n!="function")throw new Error("implement() must be called with a function");return Object.defineProperty(function(...r){const i=e._def.input?Wu(e._def.input,r):r,o=Reflect.apply(n,this,i);return e._def.output?Wu(e._def.output,o):o},"_zod",{value:e._zod,enumerable:!1})},e.implementAsync=n=>{if(typeof n!="function")throw new Error("implementAsync() must be called with a function");return Object.defineProperty(async function(...r){const i=e._def.input?await Ku(e._def.input,r):r,o=await Reflect.apply(n,this,i);return e._def.output?await Ku(e._def.output,o):o},"_zod",{value:e._zod,enumerable:!1})},e._zod.parse=(n,r)=>typeof n.value!="function"?(n.issues.push({code:"invalid_type",expected:"function",input:n.value,inst:e}),n):(e._def.output&&e._def.output._zod.def.type==="promise"?n.value=e.implementAsync(n.value):n.value=e.implement(n.value),n),e.input=(...n)=>{const r=e.constructor;return Array.isArray(n[0])?new r({type:"function",input:new _l({type:"tuple",items:n[0],rest:n[1]}),output:e._def.output}):new r({type:"function",input:n[0],output:e._def.output})},e.output=n=>{const r=e.constructor;return new r({type:"function",input:e._def.input,output:n})},e)),kv=S("$ZodPromise",(e,t)=>{be.init(e,t),e._zod.parse=(n,r)=>Promise.resolve(n.value).then(i=>t.innerType._zod.run({value:i,issues:[]},r))}),El=S("$ZodLazy",(e,t)=>{be.init(e,t),Dm(e._zod,"innerType",()=>{const n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),Ee(e,"pattern",n=>n.innerType?._zod?.pattern),Ee(e,"propValues",n=>n.innerType?._zod?.propValues),Ee(e,"optin",n=>n.innerType?._zod?.optin??void 0),Ee(e,"optout",n=>n.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),Sv=S("$ZodCustom",(e,t)=>{Ve.init(e,t),be.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(o=>Vh(o,n,r,e));Vh(i,n,r,e)}});function Vh(e,t,n,r){if(!e){const i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(dr(i))}}class xv extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Xu="~memo",qh=[];function Ev(e){return e!==null&&typeof e=="object"}function gu(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const $v=new WeakMap,ur=0,as=1,ai=2;function ui(e,t,n){const r=$v.get(e);if(r!==void 0)return r?ai:ur;if(t.has(e))return ai;t.add(e);let i=ur;const o=l=>{if(i!==ai&&l?._zod){const d=ui(l,t,n);d>i&&(i=d)}},s=(l,d)=>{let f=ur;for(const h of Reflect.ownKeys(l)){const p=Object.getOwnPropertyDescriptor(l,h);if(!p.enumerable)continue;const m=p.get?as:p.value?._zod?ui(p.value,t,n):ur;m>f&&(f=m)}return f},a=l=>{l>i&&(i=l)},u=e._zod.def;switch(u.type){case"object":{const l=zs(u);a(l?s(l):as),o(u.catchall);break}case"array":o(u.element);break;case"tuple":for(const l of u.items)o(l);o(u.rest);break;case"record":case"map":o(u.keyType),o(u.valueType);break;case"set":o(u.valueType);break;case"union":for(const l of u.options)o(l);break;case"intersection":o(u.left),o(u.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(u.innerType);break;case"pipe":o(u.in),o(u.out);break;case"function":o(u.input),o(u.output);break;case"lazy":{const l=u._cachedInner??(n?e._zod.innerType:void 0);a(l?ui(l,t,!1):as);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const l in u){const d=Object.getOwnPropertyDescriptor(u,l);if(!d||d.get)continue;const f=d.value;if(!(!f||typeof f!="object")){if(f._zod)o(f);else if(Array.isArray(f))for(const h of f)o(h)}}}return t.delete(e),QS(e,i)}function QS(e,t){return t!==as&&$v.set(e,t===ai),t}function $l(e){return ui(e,new Set,!0)!==ur}function e0(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let jo;const Zo=[],t0={alloc(e,t,n){const r=jo;if(!r)return n;jo=void 0;const i={value:n,issues:null};return r.set(t.value,i),Zo.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,r=(i,o)=>{if(o.direction!=="backward"&&Tl(o,i.value))throw new xv;return n(i,o)};e._zod.parse=r,e._zod.run===n&&(e._zod.run=r)})},attach(e){var t;let n,r=!1,i,o;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const s=e._zod.parse,a=(u,c)=>{if(n===void 0){const b=ui(e,new Set,!1);if(b===ur)return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(u,c);b===ai||r?n=!0:r=!0}const l=u.value;if(!Ev(l))return s(u,c);let d=c[Xu];d||(d={buckets:new WeakMap,backEdges:void 0},c[Xu]=d);let f;i===c?f=o:(f=e0(d,e),i=c,o=f);const h=f.get(l);if(h)return u.value=h.value,h.issues?h.issues.length&&u.issues.push(...gu(h.issues)):(u.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(h.value)),u;jo=f;const p=Zo.length,m=s(u,c);jo=void 0;const y=Zo.length>p?Zo.pop():void 0;return m instanceof Promise?m.then(b=>(y&&(y.issues=b.issues.length?gu(b.issues):qh),b)):(y&&(y.issues=m.issues.length?gu(m.issues):qh),m)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function Js(){return t0}function Tl(e,t){const n=e[Xu]?.backEdges;return n!==void 0&&Ev(t)&&n.has(t)}const Cl=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));var Wh;const Al=Symbol("ZodOutput"),Il=Symbol("ZodInput");class Tv{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const i={...r,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Ys(){return new Tv}(Wh=globalThis).__zod_globalRegistry??(Wh.__zod_globalRegistry=Ys());const Tt=globalThis.__zod_globalRegistry,kt=Symbol.for("zod.compile.invalid"),Kh=Symbol.for("zod.compile.fallback");class hn extends Error{constructor(t="z.compile does not support async refinements, transforms, or checks"){super(t),this.name="ZodCompileAsyncError"}}class Ne extends Error{constructor(t,n=!0){super(`z.compile does not support ${t}; this schema must use the runtime parser`),this.name="ZodCompileUnsupportedError",this.islandable=n}}function n0(e,t){try{return Qs(e,{assertOnly:!0})}catch{return t}}function Nl(e,t){try{const n=Qs(e),r=Xs(e,n);return r._zod.bag.validator=n0(e,n),r}catch(n){if(t?.strict)throw n;return e}}function Xs(e,t){if($l(e))throw new Ne("a schema whose subtree contains a reference cycle");const n=He(e),r=e._zod.run,i=r.__originalRun??r,o=(s,a)=>{if(a?.async||a?.direction==="backward"||a?.skipChecks||a?.[Kh]||a&&Tl(a,s.value))return i(s,a);const u=t(s.value);return u!==kt?(s.value=u,s):(a&&(a[Kh]=!0),i(s,a))};return o.__originalRun=i,n._zod.bag.fallbackRun=i,n._zod.bag.validator=t,n._zod.run=o,r.__originalRun||r0(n,e,t),n}function r0(e,t,n){const r=e,i=t;if(typeof i.safeParse=="function"){const o=i.safeParse;r.safeParse=(s,a)=>{const u=n(s);return u!==kt?{success:!0,data:u}:o(s,a)}}if(typeof i.parse=="function"){const o=i.parse;r.parse=(s,a)=>{const u=n(s);return u!==kt?u:o(s,a)}}}function Qs(e,t){let n=!0;try{n=$l(e)}catch{}if(n)throw new Ne("a schema whose subtree contains a reference cycle");const r={constants:new Map,constantCounter:0,varCounter:0,definite:!0},i=new il(["input"]),o=We(i,r,e,"input",!t?.assertOnly);i.write(o===null?"return true;":`return ${o};`);const s=["INVALID",...r.constants.keys()],a=[kt,...r.constants.values()],u=i.content.join(`
64
+ `)}return y.write("payload.value = newResult;"),y.write("return payload;"),y.compile()};let s;const a=lr,u=!kt.jitless,l=u&&Wm.value,d=t.catchall;let h;e._zod.parse=(f,p)=>{h??(h=r.value);const m=f.value;return a(m)?u&&l&&p?.async===!1&&p.jitless!==!0?(s||(s=o(t.shape)),f=s(f,p),d?iv([],m,f,p,h,e,p?.abortEarly===!0):f):n(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),f)}});function jh(e,t,n,r){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const i=e.filter(o=>!Et(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(s=>Gt(s,r,nt())))}),t)}const na=S("$ZodUnion",(e,t)=>{we.init(e,t),Ce(e,"optin",r=>r.def.options.some(i=>i._zod.optin==="defaulted")?"defaulted":r.def.options.some(i=>i._zod.optin!==void 0)?"optional":void 0),Ce(e,"optout",r=>r.def.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Ce(e,"values",r=>{if(r.def.options.every(i=>i._zod.values))return new Set(r.def.options.flatMap(i=>Array.from(i._zod.values)))}),Ce(e,"pattern",r=>{if(r.def.options.every(i=>i._zod.pattern)){const i=r.def.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>In(o.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let o=!1;const s=[];for(const a of t.options){const u=a._zod.run({value:r.value,issues:[]},i);if(u instanceof Promise)s.push(u),o=!0;else{if(u.issues.length===0)return u;s.push(u)}}return o?Promise.all(s).then(a=>jh(a,r,e,i)):jh(s,r,e,i)}});function Zh(e,t,n,r){const i=[];for(let o=0;o<e.length;o++)e[o].issues.length===0&&i.push(o);return i.length===1?(t.value=e[i[0]].value,t):(i.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(s=>Gt(s,r,nt())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1,matches:i}),t)}const av=S("$ZodXor",(e,t)=>{na.init(e,t),t.inclusive=!1;const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let o=!1;const s=[];for(const a of t.options){const u=a._zod.run({value:r.value,issues:[]},i);u instanceof Promise?(s.push(u),o=!0):s.push(u)}return o?Promise.all(s).then(a=>Zh(a,r,e,i)):Zh(s,r,e,i)}});function Tl(e,t){const n=e._zod;let r=n.bag.optionsMap;r||(r=uv(n.def),n.bag.optionsMap=r);const i=r.get(t);if(i===null)throw new Error(`Ambiguous discriminator value "${String(t)}"`);return i}function uv(e){const t=new Map;for(const n of e.options){const r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(const i of r)if(t.has(i)){if(i!==void 0)throw new Error(`Duplicate discriminator value "${String(i)}"`);t.set(i,null)}else t.set(i,n)}return t}const cv=S("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,na.init(e,t);const n=e._zod.parse;Ce(e,"propValues",i=>{const o={};let s=0;for(const a of i.def.options){const u=a._zod.propValues;if(!u||Object.keys(u).length===0)throw new Error(`Invalid discriminated union option at index "${i.def.options.indexOf(a)}"`);u[i.def.discriminator]?.has(void 0)&&s++;for(const[c,l]of Object.entries(u)){Object.prototype.hasOwnProperty.call(o,c)||Lt(o,c,new Set);for(const d of l)o[c].add(d)}}return!i.def.unionFallback&&s>1&&o[i.def.discriminator]?.delete(void 0),o}),t.options.forEach((i,o)=>{const s=Gs(i._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw new Error(`Invalid discriminated union option at index "${o}"`)});const r=zi(()=>uv(t));e._zod.parse=(i,o)=>{const s=i.value;if(!lr(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),i;const a=s?.[t.discriminator],u=r.value.get(a);return u&&(a!==void 0||o.direction!=="backward")?u._zod.run(i,o):t.unionFallback||o.direction==="backward"?n(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(c=>r.value.get(c)!==null),input:s,path:[t.discriminator],inst:e}),i)}}),lv=S("$ZodIntersection",(e,t)=>{we.init(e,t),e._zod.parse=(n,r)=>{const i=n.value,o=t.left._zod.run({value:i,issues:[]},r),s=t.right._zod.run({value:i,issues:[]},r);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([u,c])=>Bh(n,u,c)):Bh(n,o,s)}});function _i(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(fn(e)&&fn(t)){const n=Object.keys(t),r=Object.keys(e).filter(o=>n.indexOf(o)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,"__proto__")&&delete i.__proto__;for(const o of r){if(o==="__proto__")continue;const s=_i(e[o],t[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};i[o]=s.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const i=e[r],o=t[r],s=_i(i,o);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Bh(e,t,n){const r=new Map;let i;const o=new Map,s=(c,l)=>{let d;if(c.code==="unrecognized_keys"&&!c.path?.length)i??(i=c),d=c.keys;else if(c.code==="invalid_key"&&c.origin==="record"&&c.path?.length===1){const h=String(c.path[0]);o.has(h)||o.set(h,c),d=[h]}else return!1;for(const h of d)r.has(h)||r.set(h,{}),r.get(h)[l]=!0;return!0};for(const c of t.issues)s(c,"l")||e.issues.push(c);for(const c of n.issues)s(c,"r")||e.issues.push(c);const a=[...r].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(a.length){const c=i?a.filter(l=>i.keys.includes(l)):[];c.length&&e.issues.push({...i,keys:c});for(const l of a)!c.includes(l)&&o.has(l)&&e.issues.push(o.get(l))}const u=_i(t.value,n.value);if(!u.valid){if(Et(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const Cl=S("$ZodTuple",(e,t)=>{we.init(e,t);const n=t.items,r=kt.memoizer;r?.attach(e),e._zod.parse=(i,o)=>{const s=i.value;if(!Array.isArray(s))return i.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),i;i.value=r?r.alloc(e,i,[],o):[];const a=[],u=Hh(n,"optin"),c=Hh(n,"optout");if(!t.rest){if(s.length<u)return i.issues.push({code:"too_small",minimum:u,inclusive:!0,input:s,inst:e,origin:"array"}),i;s.length>n.length&&i.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:s,inst:e,origin:"array"})}const l=new Array(n.length),d=t.rest?o?.abortEarly:void 0;let h=!1;for(let f=0;f<n.length;f++){const p=n[f]._zod.run({value:s[f],issues:[]},o);p instanceof Promise?a.push(p.then(m=>{l[f]=m})):(l[f]=p,d&&!h&&p.issues.length&&(h=Et(p)))}if(t.rest&&!h){let f=n.length-1;const p=s.slice(n.length);let m=i.issues.length;for(const y of p){if(d&&i.issues.length!==m){if(Et(i,m))break;m=i.issues.length}f++;const b=t.rest._zod.run({value:y,issues:[]},o);b instanceof Promise?a.push(b.then(g=>Vh(g,i,f))):Vh(b,i,f)}}return a.length?Promise.all(a).then(()=>qh(l,i,n,s,c)):qh(l,i,n,s,c)}});function Hh(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function Vh(e,t,n){e.issues.length&&t.issues.push(...Mt(n,e.issues)),t.value[n]=e.value}function qh(e,t,n,r,i){for(let o=0;o<n.length;o++){const s=e[o],a=o<r.length;if(!a&&o>=i&&n[o]._zod.optin==="optional"){t.value.length=o;break}if(s.issues.length){if(!a&&o>=i){t.value.length=o;break}t.issues.push(...Mt(o,s.issues))}t.value[o]=s.value}for(let o=t.value.length-1;o>=r.length&&(n[o]._zod.optout==="optional"&&t.value[o]===void 0);o--)t.value.length=o;return t}const dv=S("$ZodRecord",(e,t)=>{we.init(e,t);const n=kt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!fn(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;const s=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};const u=new Set;for(const l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(u.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;const d=t.keyType._zod.run({value:l,issues:[]},i);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(p=>Gt(p,i,nt())),input:l,path:[l],inst:e});continue}const h=d.value;if(h==="__proto__")continue;const f=t.valueType._zod.run({value:o[l],issues:[]},i);f instanceof Promise?s.push(f.then(p=>{p.issues.length&&r.issues.push(...Mt(l,p.issues)),r.value[h]=p.value})):(f.issues.length&&r.issues.push(...Mt(l,f.issues)),r.value[h]=f.value)}let c;for(const l in o)if(!u.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;r.value[l]=o[l]}else c=c??[],c.push(l);c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let u;for(const c of Reflect.ownKeys(o)){if(c==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,c))continue;let l=t.keyType._zod.run({value:c,issues:[]},i);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&$r.test(c)&&l.issues.length){const p=t.keyType._zod.run({value:Number(c),issues:[]},i);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(l=p)}if(l.issues.length){t.mode==="loose"?r.value[c]=o[c]:a?(u=u??[],u.push(c)):r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(p=>Gt(p,i,nt())),input:c,path:[c],inst:e});continue}const h=l.value;if(h==="__proto__")continue;const f=t.valueType._zod.run({value:o[c],issues:[]},i);f instanceof Promise?s.push(f.then(p=>{p.issues.length&&r.issues.push(...Mt(c,p.issues)),r.value[h]=p.value})):(f.issues.length&&r.issues.push(...Mt(c,f.issues)),r.value[h]=f.value)}u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:u,continue:!0})}return s.length?Promise.all(s).then(()=>r):r}}),fv=S("$ZodMap",(e,t)=>{we.init(e,t);const n=kt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!(o instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:o,inst:e}),r;const s=[];r.value=n?n.alloc(e,r,new Map,i):new Map;const a=i?.abortEarly;let u=r.issues.length;for(const[c,l]of o){if(a&&r.issues.length!==u){if(Et(r,u))break;u=r.issues.length}const d=t.keyType._zod.run({value:c,issues:[]},i),h=t.valueType._zod.run({value:l,issues:[]},i);d instanceof Promise||h instanceof Promise?s.push(Promise.all([d,h]).then(([f,p])=>{Wh(f,p,r,c,o,e,i)})):Wh(d,h,r,c,o,e,i)}return s.length?Promise.all(s).then(()=>r):r}});function Wh(e,t,n,r,i,o,s){e.issues.length&&(_s.has(typeof r)?n.issues.push(...Mt(r,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:i,inst:o,issues:e.issues.map(a=>Gt(a,s,nt()))})),t.issues.length&&(_s.has(typeof r)?n.issues.push(...Mt(r,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:i,inst:o,key:r,issues:t.issues.map(a=>Gt(a,s,nt()))})),n.value.set(e.value,t.value)}const hv=S("$ZodSet",(e,t)=>{we.init(e,t);const n=kt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!(o instanceof Set))return r.issues.push({input:o,inst:e,expected:"set",code:"invalid_type"}),r;const s=[];r.value=n?n.alloc(e,r,new Set,i):new Set;const a=i?.abortEarly;let u=r.issues.length;for(const c of o){if(a&&r.issues.length!==u){if(Et(r,u))break;u=r.issues.length}const l=t.valueType._zod.run({value:c,issues:[]},i);l instanceof Promise?s.push(l.then(d=>Kh(d,r))):Kh(l,r)}return s.length?Promise.all(s).then(()=>r):r}});function Kh(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const pv=S("$ZodEnum",(e,t)=>{we.init(e,t);const n=bs(t.entries),r=new Set(n);e._zod.values=r,Ce(e,"pattern",i=>{const o=bs(i.def.entries).filter(s=>_s.has(typeof s));return new RegExp(o.length?`^(${o.map(s=>hn(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,o)=>{const s=i.value;return r.has(s)||i.issues.push({code:"invalid_value",values:n,input:s,inst:e}),i}}),mv=S("$ZodLiteral",(e,t)=>{we.init(e,t);const n=new Set(t.values);e._zod.values=n,Ce(e,"pattern",r=>{const i=r.def.values;return new RegExp(i.length?`^(${i.map(o=>typeof o=="string"?hn(o):o?hn(o.toString()):String(o)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,i)=>{const o=r.value;return n.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}}),gv=S("$ZodFile",(e,t)=>{we.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;return i instanceof File||n.issues.push({expected:"file",code:"invalid_type",input:i,inst:e}),n}}),yv=S("$ZodTransform",(e,t)=>{we.init(e,t),e._zod.optin="optional",kt.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Vs(e.constructor.name);const i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(s=>(n.value=s,n));if(i instanceof Promise)throw new cn;return n.value=i,n}});function Jh(e,t){return e.value=t.issues.length?void 0:t.value,e}const Al=S("$ZodOptional",(e,t)=>{we.init(e,t),Ce(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",Ce(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),Ce(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${In(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;const i=t.innerType._zod.run({value:n.value,issues:[]},r);return i instanceof Promise?i.then(o=>Jh(n,o)):Jh(n,i)}return t.innerType._zod.run(n,r)}}),vv=S("$ZodExactOptional",(e,t)=>{Al.init(e,t),Ce(e,"values",n=>n.def.innerType._zod.values),Ce(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),bv=S("$ZodNullable",(e,t)=>{we.init(e,t),Ce(e,"optin",n=>n.def.innerType._zod.optin),Ce(e,"optout",n=>n.def.innerType._zod.optout),Ce(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${In(r.source)}|null)$`):void 0}),Ce(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),wv=S("$ZodDefault",(e,t)=>{we.init(e,t),e._zod.optin="defaulted",Ce(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>Yh(o,t)):Yh(i,t)}});function Yh(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const _v=S("$ZodPrefault",(e,t)=>{we.init(e,t),e._zod.optin="defaulted",Ce(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),kv=S("$ZodNonOptional",(e,t)=>{we.init(e,t),Ce(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r].filter(i=>i!==void 0)):void 0}),e._zod.parse=(n,r)=>{const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>Xh(o,e)):Xh(i,e)}});function Xh(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Sv=S("$ZodSuccess",(e,t)=>{we.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Vs("ZodSuccess");const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>(n.value=o.issues.length===0,n)):(n.value=i.issues.length===0,n)}});function Qh(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(i=>Gt(i,r,nt()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const xv=S("$ZodCatch",(e,t)=>{we.init(e,t),Ce(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),Ce(e,"optout",n=>n.def.innerType._zod.optout),Ce(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run({value:n.value,issues:[]},r);return i instanceof Promise?i.then(o=>Qh(n,o,t,r)):Qh(n,i,t,r)}}),Ev=S("$ZodNaN",(e,t)=>{we.init(e,t),e._zod.parse=(n,r)=>((typeof n.value!="number"||!Number.isNaN(n.value))&&n.issues.push({input:n.value,inst:e,expected:"nan",code:"invalid_type"}),n)}),Il=S("$ZodPipe",(e,t)=>{we.init(e,t),Ce(e,"values",n=>n.def.in._zod.values),Ce(e,"optin",n=>n.def.in._zod.optin),Ce(e,"optout",n=>n.def.out._zod.optout),Ce(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const o=t.out._zod.run(n,r);return o instanceof Promise?o.then(s=>Bo(s,t.in,r)):Bo(o,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(o=>Bo(o,t.out,r)):Bo(i,t.out,r)}});function Bo(e,t,n){return e.issues.some(r=>r.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Nl=S("$ZodCodec",(e,t)=>{we.init(e,t),Ce(e,"values",n=>n.def.in._zod.values),Ce(e,"optin",n=>n.def.in._zod.optin),Ce(e,"optout",n=>n.def.out._zod.optout),Ce(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if((r.direction||"forward")==="forward"){const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>Ho(s,t,r)):Ho(o,t,r)}else{const o=t.out._zod.run(n,r);return o instanceof Promise?o.then(s=>Ho(s,t,r)):Ho(o,t,r)}}});function Ho(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){const i=t.transform(e.value,e);return i instanceof Promise?i.then(o=>Vo(e,o,t.out,n)):Vo(e,i,t.out,n)}else{const i=t.reverseTransform(e.value,e);return i instanceof Promise?i.then(o=>Vo(e,o,t.in,n)):Vo(e,i,t.in,n)}}function Vo(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}const $v=S("$ZodPreprocess",(e,t)=>{Il.init(e,t)}),Tv=S("$ZodReadonly",(e,t)=>{we.init(e,t),Ce(e,"propValues",n=>n.def.innerType._zod.propValues),Ce(e,"values",n=>n.def.innerType._zod.values),Ce(e,"optin",n=>n.def.innerType?._zod?.optin),Ce(e,"optout",n=>n.def.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(ep):ep(i)}});function ep(e){return e.memo||(e.value=Object.freeze(e.value)),e}function u0(e){const t=e._zod.def;let n=t.pattern,r=!!t.format?.includes("int"),i,o;for(const a of t.checks??[]){const u=a._zod.def;u.pattern&&(n=u.pattern),r||(r=!!u.format?.includes("int"));const c=u.minimum??u.length,l=u.maximum??u.length;c!==void 0&&(i===void 0||c>i)&&(i=c),l!==void 0&&(o===void 0||l<o)&&(o=l)}if(n)return n.source;if(i!==void 0&&o!==void 0&&i>o)return"(?!)";if(i!==void 0||o!==void 0)return Zg({minimum:i,maximum:o}).source;const s=e._zod.pattern;return(r&&s===$r?sl:s)?.source}function rc(e){const t=e._zod.def,n=e._zod.pattern?.source,r=t.innerType??e._zod.innerType;if(r){const i=r._zod.pattern?.source,o=rc(r);return n&&i&&o&&o!==i?n.replace(In(i),()=>In(o)):n}if(t.options){const i=t.options.map(rc);if(i.every(Boolean))return`^(${i.map(o=>In(o)).join("|")})$`}return u0(e)}const Cv=S("$ZodTemplateLiteral",(e,t)=>{we.init(e,t);const n=[];for(const r of t.parts)if(typeof r=="object"&&r!==null){const i=rc(r);if(!i)throw new Error(`Invalid template literal part, no pattern found: ${[...r._zod.traits].shift()}`);n.push(In(i))}else if(r===null||Km.has(typeof r))n.push(hn(`${r}`));else throw new Error(`Invalid template literal part: ${r}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(r,i)=>typeof r.value!="string"?(r.issues.push({input:r.value,inst:e,expected:"string",code:"invalid_type"}),r):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(r.value)||r.issues.push({input:r.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),r)}),Av=S("$ZodFunction",(e,t)=>(we.init(e,t),Object.defineProperty(e,"_def",{value:t}),e._zod.def=t,e.implement=n=>{if(typeof n!="function")throw new Error("implement() must be called with a function");return Object.defineProperty(function(...r){const i=e._def.input?ec(e._def.input,r):r,o=Reflect.apply(n,this,i);return e._def.output?ec(e._def.output,o):o},"_zod",{value:e._zod,enumerable:!1})},e.implementAsync=n=>{if(typeof n!="function")throw new Error("implementAsync() must be called with a function");return Object.defineProperty(async function(...r){const i=e._def.input?await tc(e._def.input,r):r,o=await Reflect.apply(n,this,i);return e._def.output?await tc(e._def.output,o):o},"_zod",{value:e._zod,enumerable:!1})},e._zod.parse=(n,r)=>typeof n.value!="function"?(n.issues.push({code:"invalid_type",expected:"function",input:n.value,inst:e}),n):(e._def.output&&e._def.output._zod.def.type==="promise"?n.value=e.implementAsync(n.value):n.value=e.implement(n.value),n),e.input=(...n)=>{const r=e.constructor;return Array.isArray(n[0])?new r({type:"function",input:new Cl({type:"tuple",items:n[0],rest:n[1]}),output:e._def.output}):new r({type:"function",input:n[0],output:e._def.output})},e.output=n=>{const r=e.constructor;return new r({type:"function",input:e._def.input,output:n})},e)),Iv=S("$ZodPromise",(e,t)=>{we.init(e,t),e._zod.parse=(n,r)=>Promise.resolve(n.value).then(i=>t.innerType._zod.run({value:i,issues:[]},r))}),Rl=S("$ZodLazy",(e,t)=>{we.init(e,t),Bm(e._zod,"innerType",()=>{const n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),Ce(e,"pattern",n=>n.innerType?._zod?.pattern),Ce(e,"propValues",n=>n.innerType?._zod?.propValues),Ce(e,"optin",n=>n.innerType?._zod?.optin??void 0),Ce(e,"optout",n=>n.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),Nv=S("$ZodCustom",(e,t)=>{Ve.init(e,t),we.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(o=>tp(o,n,r,e));tp(i,n,r,e)}});function tp(e,t,n,r){if(!e){const i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(dr(i))}}class Rv extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const ic="~memo",np=[];function Lv(e){return e!==null&&typeof e=="object"}function ku(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const zv=new WeakMap,ur=0,hs=1,ci=2;function li(e,t,n){const r=zv.get(e);if(r!==void 0)return r?ci:ur;if(t.has(e))return ci;t.add(e);let i=ur;const o=l=>{if(i!==ci&&l?._zod){const d=li(l,t,n);d>i&&(i=d)}},s=(l,d)=>{let h=ur;for(const f of Reflect.ownKeys(l)){const p=Object.getOwnPropertyDescriptor(l,f);if(!p.enumerable)continue;const m=p.get?hs:p.value?._zod?li(p.value,t,n):ur;m>h&&(h=m)}return h},a=l=>{l>i&&(i=l)},u=e._zod.def;switch(u.type){case"object":{const l=Gs(u);a(l?s(l):hs),o(u.catchall);break}case"array":o(u.element);break;case"tuple":for(const l of u.items)o(l);o(u.rest);break;case"record":case"map":o(u.keyType),o(u.valueType);break;case"set":o(u.valueType);break;case"union":for(const l of u.options)o(l);break;case"intersection":o(u.left),o(u.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(u.innerType);break;case"pipe":o(u.in),o(u.out);break;case"function":o(u.input),o(u.output);break;case"lazy":{const l=u._cachedInner??(n?e._zod.innerType:void 0);a(l?li(l,t,!1):hs);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const l in u){const d=Object.getOwnPropertyDescriptor(u,l);if(!d||d.get)continue;const h=d.value;if(!(!h||typeof h!="object")){if(h._zod)o(h);else if(Array.isArray(h))for(const f of h)o(f)}}}return t.delete(e),c0(e,i)}function c0(e,t){return t!==hs&&zv.set(e,t===ci),t}function Ll(e){return li(e,new Set,!0)!==ur}function l0(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let qo;const Wo=[],d0={alloc(e,t,n){const r=qo;if(!r)return n;qo=void 0;const i={value:n,issues:null};return r.set(t.value,i),Wo.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,r=(i,o)=>{if(o.direction!=="backward"&&zl(o,i.value))throw new Rv;return n(i,o)};e._zod.parse=r,e._zod.run===n&&(e._zod.run=r)})},attach(e){var t;let n,r=!1,i,o;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const s=e._zod.parse,a=(u,c)=>{if(n===void 0){const b=li(e,new Set,!1);if(b===ur)return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(u,c);b===ci||r?n=!0:r=!0}const l=u.value;if(!Lv(l))return s(u,c);let d=c[ic];d||(d={buckets:new WeakMap,backEdges:void 0},c[ic]=d);let h;i===c?h=o:(h=l0(d,e),i=c,o=h);const f=h.get(l);if(f)return u.value=f.value,f.issues?f.issues.length&&u.issues.push(...ku(f.issues)):(u.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(f.value)),u;qo=h;const p=Wo.length,m=s(u,c);qo=void 0;const y=Wo.length>p?Wo.pop():void 0;return m instanceof Promise?m.then(b=>(y&&(y.issues=b.issues.length?ku(b.issues):np),b)):(y&&(y.issues=m.issues.length?ku(m.issues):np),m)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function ra(){return d0}function zl(e,t){const n=e[ic]?.backEdges;return n!==void 0&&Lv(t)&&n.has(t)}const Dl=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));var rp;const Ol=Symbol("ZodOutput"),Pl=Symbol("ZodInput");class Dv{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const i={...r,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function ia(){return new Dv}(rp=globalThis).__zod_globalRegistry??(rp.__zod_globalRegistry=ia());const At=globalThis.__zod_globalRegistry,St=Symbol.for("zod.compile.invalid"),ip=Symbol.for("zod.compile.fallback");class mn extends Error{constructor(t="z.compile does not support async refinements, transforms, or checks"){super(t),this.name="ZodCompileAsyncError"}}class ze extends Error{constructor(t,n=!0){super(`z.compile does not support ${t}; this schema must use the runtime parser`),this.name="ZodCompileUnsupportedError",this.islandable=n}}function f0(e,t){try{return sa(e,{assertOnly:!0})}catch{return t}}function Ml(e,t){try{const n=sa(e),r=oa(e,n);return r._zod.bag.validator=f0(e,n),r}catch(n){if(t?.strict)throw n;return e}}function oa(e,t){if(Ll(e))throw new ze("a schema whose subtree contains a reference cycle");const n=He(e),r=e._zod.run,i=r.__originalRun??r,o=(s,a)=>{if(a?.async||a?.direction==="backward"||a?.skipChecks||a?.[ip]||a&&zl(a,s.value))return i(s,a);const u=t(s.value);return u!==St?(s.value=u,s):(a&&(a[ip]=!0),i(s,a))};return o.__originalRun=i,n._zod.bag.fallbackRun=i,n._zod.bag.validator=t,n._zod.run=o,r.__originalRun||h0(n,e,t),n}function h0(e,t,n){const r=e,i=t;if(typeof i.safeParse=="function"){const o=i.safeParse;r.safeParse=(s,a)=>{const u=n(s);return u!==St?{success:!0,data:u}:o(s,a)}}if(typeof i.parse=="function"){const o=i.parse;r.parse=(s,a)=>{const u=n(s);return u!==St?u:o(s,a)}}}function sa(e,t){let n=!0;try{n=Ll(e)}catch{}if(n)throw new ze("a schema whose subtree contains a reference cycle");const r={constants:new Map,constantCounter:0,varCounter:0,definite:!0},i=new dl(["input"]),o=qe(i,r,e,"input",!t?.assertOnly);i.write(o===null?"return true;":`return ${o};`);const s=["INVALID",...r.constants.keys()],a=[St,...r.constants.values()],u=i.content.join(`
65
65
  `),c=t?.debug?s.length>0?`// Constants: ${s.join(", ")}
66
66
  ${u}`:u:"",l=Function,d=`return (input) => {
67
67
  ${u}
68
- }`;let f;try{f=new l(...s,d)(...a)}catch(h){throw new Ne(`this schema (generated code failed to evaluate: ${h.message})`)}return t?.debug&&(f.code=c),f.definite=r.definite,f}function pe(e,t){for(const[r,i]of e.constants)if(i===t)return r;const n=`c${e.constantCounter++}`;return e.constants.set(n,t),n}function Wn(e,t){return e.definite=!1,pe(e,t)}function re(e){return`v${e.varCounter++}`}function i0(e,t){const n=e._zod.run({value:t,issues:[]},{});if(n&&typeof n.then=="function")return kt;const r=n;return r.issues.length===0?r.value:kt}function pt(e,t,n,r,i=!0){const o=e.content.length,s=t.constants.size,a=t.constantCounter,u=t.varCounter;try{return We(e,t,n,r,i)}catch(c){if(!(c instanceof Ne)||!c.islandable)throw c;if(e.content.length=o,t.constants.size>s){const l=Array.from(t.constants.keys()).slice(s);for(const d of l)t.constants.delete(d)}return t.constantCounter=a,t.varCounter=u,o0(e,t,n,r)}}function o0(e,t,n,r){t.definite=!1;const i=pe(t,n),o=pe(t,i0),s=re(t);return e.write(`const ${s} = ${o}(${i}, ${r});`),e.write(`if (${s} === INVALID) return INVALID;`),s}const s0=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function a0(e,t,n,r){const i=n._zod.def.checks;if(!i||i.length===0)return r;let o=r;for(const s of i){const a=s._zod.def;if(a.when&&!s0.has(a.check))throw new Ne('check with a custom "when" condition');switch(a.check){case"greater_than":u0(e,t,a,o);break;case"less_than":c0(e,t,a,o);break;case"multiple_of":l0(e,t,a,o);break;case"number_format":Av(e,a,o);break;case"min_length":{const u=jn(a.minimum,"min_length"),c=yu(e,t,o,`${o}.length >= ${u} && ${o}.length < ${a.minimum*2}`);e.write(`if (${c} < ${u}) return INVALID;`);break}case"max_length":{const u=jn(a.maximum,"max_length"),c=yu(e,t,o,`${o}.length > ${u}`);e.write(`if (${c} > ${u}) return INVALID;`);break}case"length_equals":{const u=jn(a.length,"length_equals"),c=yu(e,t,o,`${o}.length >= ${u} && ${o}.length <= ${a.length*2}`);e.write(`if (${c} !== ${u}) return INVALID;`);break}case"min_size":e.write(`if (${o}.size < ${jn(a.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${o}.size > ${jn(a.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${o}.size !== ${jn(a.size,"size_equals")}) return INVALID;`);break;case"string_format":o=Iv(e,t,a,o);break;case"custom":o=g0(e,t,s,o);break;case"bigint_format":d0(e,a,o);break;case"mime_type":f0(e,t,a,o);break;case"property":p0(e,t,a,o);break;case"properties":h0(e,t,a,o);break;case"overwrite":{const u=re(t);m0(e,t,s,o,u),o=u;break}default:throw new Ne(`check type ${a.check}`)}}return o}function yu(e,t,n,r){const i=pe(t,Ni),o=re(t);return e.write(`const ${o} = typeof ${n} === "string" && ${r} ? ${i}(${n}) : ${n}.length;`),o}function jn(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new Ne(`${t} bound of type ${typeof e}`);return`${e}`}function Cv(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new Ne("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new Ne("comparison check with Invalid Date bound");return pe(e,t)}throw new Ne(`comparison check bound of type ${typeof t}`)}function u0(e,t,n,r){const i=n.inclusive?"<":"<=";e.write(`if (${r} ${i} ${Cv(t,n.value)}) return INVALID;`)}function c0(e,t,n,r){const i=n.inclusive?">":">=";e.write(`if (${r} ${i} ${Cv(t,n.value)}) return INVALID;`)}function l0(e,t,n,r){if(typeof n.value=="bigint"){if(n.value===BigInt(0))throw new Ne("multiple_of check with a zero divisor");e.write(`if (${r} % ${n.value}n !== 0n) return INVALID;`)}else{const i=pe(t,Ic);e.write(`if (${i}(${r}, ${jn(n.value,"multiple_of")}) !== 0) return INVALID;`)}}function Av(e,t,n){const r=t.format;switch(r){case"safeint":e.write(`if (!Number.isSafeInteger(${n})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${n}) || ${n} < -2147483648 || ${n} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${n}) || ${n} < 0 || ${n} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${n}) || ${n} < -3.4028234663852886e38 || ${n} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${n})) return INVALID;`);break;default:throw new Ne(`number format ${r}`)}}function d0(e,t,n){const r=t.format;if(r)switch(r){case"int64":e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break;default:throw new Ne(`bigint format ${r}`)}}function f0(e,t,n,r){const i=n.mime;if(i&&i.length>0){const o=pe(t,new Set(i));e.write(`if (!${o}.has(${r}.type)) return INVALID;`)}}function h0(e,t,n,r){if(n.when)throw new Ne('check with a custom "when" condition');e.write(`if (${r} == null) return INVALID;`);const i=n.shape;for(const o of Reflect.ownKeys(i)){const s=typeof o=="symbol"?pe(t,o):Ct(o),a=re(t);e.write(`const ${a} = ${r}[${s}];`),pt(e,t,i[o],a,!1)}}function p0(e,t,n,r){const i=`${r}[${JSON.stringify(n.property)}]`;We(e,t,n.schema,i)}function m0(e,t,n,r,i){const o=n._zod.def.tx;if(!o)throw new Ne("overwrite check without a transform function");if(Kn(o))throw new hn("z.compile: async overwrite transforms are not supported");const s=pe(t,o);e.write(`const ${i} = ${s}(${r});`)}function Qu(){throw new an}function Rl(e){this.issues.push(e)}function g0(e,t,n,r){const i=n._zod.def;if(i.fn){if(Kn(i.fn))throw new hn("z.compile: async .refine() predicates are not supported");const o=Wn(t,i.fn),s=pe(t,Qu),a=re(t);return e.write(`const ${a} = ${o}(${r});`),e.write(`if (${a} instanceof Promise) ${s}();`),e.write(`if (!${a}) return INVALID;`),r}if(n._zod.check){if(Kn(n._zod.check))throw new hn("z.compile: async .superRefine() / check functions are not supported");const o=n._zod.check,a=Wn(t,c=>{const l={value:c,issues:[],addIssue:Rl};return o(l)instanceof Promise&&Qu(),l.issues.length===0?l.value:kt}),u=re(t);return e.write(`const ${u} = ${a}(${r});`),e.write(`if (${u} === INVALID) return INVALID;`),u}throw new Ne("custom check without a predicate or check function")}const y0=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function Iv(e,t,n,r,i=!0){const o=n.format;if(o==="base64"){const c=pe(t,qs);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="base64url"){const c=pe(t,hl);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="jwt"){const c=pe(t,gl),l=pe(t,n.alg??null);return e.write(`if (!${c}(${r}, ${l})) return INVALID;`),r}if(o==="ipv6"){const c=pe(t,Vs);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="cidrv6"){const c=pe(t,dl);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="credit_card"){const c=pe(t,pl);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="iban"){const c=pe(t,ml);return e.write(`if (!${c}(${r})) return INVALID;`),r}const s=n;if(o==="url"||o==="httpurl"||s.normalize||s.hostname!==void 0||s.protocol!==void 0){const c=pe(t,ul),l=pe(t,n),d=re(t),f=re(t);if(e.write(`const ${d} = ${r}.trim();`),e.write(`const ${f} = ${c}(${d}, ${l});`),e.write(`if (typeof ${f} === "number") return INVALID;`),s.hostname!==void 0){const m=pe(t,cl);e.write(`if (!${m}(${f}, ${l}.hostname)) return INVALID;`)}if(s.protocol!==void 0){const m=pe(t,ll);e.write(`if (!${m}(${f}, ${l}.protocol)) return INVALID;`)}if(!i)return null;const h=re(t),p=s.normalize?`${f}.href`:`${pe(t,ys)}(${d})`;return e.write(`const ${h} = ${p};`),h}const a=n.fn;if(a){if(Kn(a))throw new Ne(`async string format ${o}`);const c=pe(t,a);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(y0.has(o)&&n.pattern){const c=pe(t,n.pattern);return e.write(`${c}.lastIndex = 0;`),e.write(`if (!${c}.test(${r})) return INVALID;`),r}const u=n.format;switch(u){case"regex":throw new Ne("regex format without a pattern");case"lowercase":e.write(`if (${r} !== ${r}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${r} !== ${r}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${r}.includes(${Ct(n.includes)})) return INVALID;`);break;case"starts_with":{const c=n.prefix;e.write(`if (${r}.slice(0, ${c.length}) !== ${Ct(c)}) return INVALID;`);break}case"ends_with":{const c=n.suffix;e.write(`if (${r}.slice(-${c.length}) !== ${Ct(c)}) return INVALID;`);break}default:throw new Ne(`string format ${u}`)}return r}function We(e,t,n,r,i=!0){const o=n._zod.def,s=o.type;if(o.coerce)throw new Ne(`coercion (z.coerce.${s}())`);const a=i||!!o.checks?.length;let u;switch(s){case"string":u=v0(e,t,n,r,a);break;case"number":u=b0(e,n,r);break;case"boolean":u=w0(e,r);break;case"bigint":u=_0(e,n,r);break;case"symbol":u=k0(e,r);break;case"undefined":u=S0(e,r);break;case"null":u=x0(e,r);break;case"any":case"unknown":u=r;break;case"never":e.write("return INVALID;"),u=r;break;case"void":u=E0(e,r);break;case"nan":u=$0(e,r);break;case"date":u=T0(e,r);break;case"object":u=C0(e,t,n,r,a);break;case"optional":u=A0(e,t,n,r,a);break;case"nullable":u=R0(e,t,n,r,a);break;case"array":u=L0(e,t,n,r,a);break;case"literal":u=z0(e,t,n,r);break;case"enum":u=P0(e,t,n,r);break;case"readonly":{const c=Yh(e,t,n,r),l=re(t);e.write(`const ${l} = Object.freeze(${c});`),u=l;break}case"success":Yh(e,t,n,r),u="true";break;case"default":case"prefault":u=D0(e,t,n,r);break;case"nonoptional":u=O0(e,t,n,r);break;case"tuple":u=M0(e,t,n,r);break;case"union":u=F0(e,t,n,r);break;case"intersection":u=j0(e,t,n,r);break;case"record":u=Z0(e,t,n,r);break;case"map":u=H0(e,t,n,r);break;case"set":u=V0(e,t,n,r);break;case"file":u=q0(e,r);break;case"template_literal":u=W0(e,t,n,r);break;case"lazy":u=K0(e,t,n,r);break;case"pipe":u=J0(e,t,n,r);break;case"custom":u=Y0(e,t,n,r);break;case"transform":u=ex(e,t,n,r);break;case"catch":u=Q0(e,t,n,r);break;default:throw new Ne(`schema type ${s}`)}return u===null?null:a0(e,t,n,u)}function v0(e,t,n,r,i=!0){e.write(`if (typeof ${r} !== "string") return INVALID;`);const o=n._zod.def;return o.format===void 0?r:Iv(e,t,o,r,i)}function b0(e,t,n){e.write(`if (typeof ${n} !== "number" || !Number.isFinite(${n})) return INVALID;`);const r=t._zod.def;return r.check==="number_format"&&r.format&&Av(e,{format:r.format},n),n}function w0(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function _0(e,t,n){e.write(`if (typeof ${n} !== "bigint") return INVALID;`);const r=t._zod.def;if(r.format)switch(r.format){case"int64":e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break}return n}function k0(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function S0(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function x0(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function E0(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function $0(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function T0(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function C0(e,t,n,r,i=!0){const o=n._zod.def;e.write(`if (typeof ${r} !== "object" || ${r} === null || Array.isArray(${r})) return INVALID;`);const s=o.shape,a=Object.keys(s),u=Object.getOwnPropertySymbols(s),c=u.length?[...a,...u]:a,l=g=>typeof g=="symbol"?pe(t,g):Ct(g),d=g=>typeof g=="symbol"?`[${l(g)}]`:Ct(g),f=s;if(a.includes("__proto__"))throw new Ne('object shape key "__proto__"');const h=new Map;for(const g of c){const w=f[g],v=l(g),_=re(t);if(e.write(`const ${_} = ${r}[${v}];`),w._zod.optin!==void 0){const k=re(t);e.write(`let ${k} = (() => {`),e.indented(x=>{const N=pt(x,t,w,_);x.write(`return ${N};`)}),e.write("})();"),w._zod.optout==="optional"?(e.write(`if (${k} === INVALID) {`),e.indented(x=>{x.write(`if (${v} in ${r}) return INVALID;`),x.write(`${k} = undefined;`)}),e.write("}")):e.write(`if (${k} === INVALID) return INVALID;`),h.set(g,k)}else{N0(w)&&e.write(`if (!(${v} in ${r})) return INVALID;`);const k=pt(e,t,w,_,i);k!==null&&h.set(g,k)}}const p=o.catchall;let m="none";if(p){const g=p._zod.def.type;if(g==="never"){const w=a.map(v=>`k !== ${Ct(v)}`).join(" && ")||"true";e.write(`for (const k in ${r}) {`),e.indented(v=>{v.write(`if (${w}) return INVALID;`)}),e.write("}")}else(g==="unknown"||g==="any")&&!p._zod.def.checks?.length?m="passthrough":m="schema"}const y=re(t),b=c.some(g=>Jh(f[g])||ec(f[g]));if(!i){if(m==="schema"){const g=a.length>0?pe(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(w=>{w.write('if (k === "__proto__") continue;'),g&&w.write(`if (${g}.has(k)) continue;`);const v=re(t);w.write(`const ${v} = ${r}[k];`),pt(w,t,p,v,!1)}),e.write("}")}return null}if(b){e.write(`const ${y} = {};`);for(const g of c){const w=l(g),v=h.get(g);ec(f[g])?e.write(`if (${w} in ${r}) ${y}[${w}] = ${v};`):Jh(f[g])?e.write(`if (${v} !== undefined || ${w} in ${r}) ${y}[${w}] = ${v};`):e.write(`${y}[${w}] = ${v};`)}}else{const g=c.map(w=>`${d(w)}: ${h.get(w)}`).join(", ");e.write(`const ${y} = { ${g} };`)}if(m!=="none"){const g=a.length>0?pe(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(w=>{if(w.write('if (k === "__proto__") continue;'),g&&w.write(`if (${g}.has(k)) continue;`),m==="passthrough")w.write(`${y}[k] = ${r}[k];`);else{const v=re(t);w.write(`const ${v} = ${r}[k];`);const _=pt(w,t,p,v);w.write(`${y}[k] = ${_};`)}}),e.write("}")}return y}function A0(e,t,n,r,i=!0){const o=n._zod.def;if(I0(n))return We(e,t,o.innerType,r,i);if(o.innerType._zod.optin==="defaulted"){const a=re(t),u=re(t);return e.write(`let ${a};`),e.write(`if (${r} === undefined) {`),e.indented(c=>{c.write(`const ${u} = (() => {`),c.indented(l=>{const d=We(l,t,o.innerType,r);l.write(`return ${d};`)}),c.write("})();"),c.write(`if (${u} !== INVALID) ${a} = ${u};`)}),e.write("} else {"),e.indented(c=>{const l=We(c,t,o.innerType,r);c.write(`${a} = ${l};`)}),e.write("}"),a}const s=i?re(t):null;return s&&e.write(`let ${s};`),e.write(`if (${r} !== undefined) {`),e.indented(a=>{const u=We(a,t,o.innerType,r,i);s&&u!==null&&a.write(`${s} = ${u};`)}),e.write("}"),s}function I0(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function N0(e){return e._zod.optin===void 0&&Zn(e)}function Zn(e){if(e._zod.def.coerce)return!0;const t=e._zod.def;switch(t.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return t.innerType?Zn(t.innerType):!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return t.innerType?Zn(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(Zn):!0;case"intersection":return!t.left||!t.right?!0:Zn(t.left)&&Zn(t.right);case"pipe":return t.in?Zn(t.in):!0;default:return!0}}function ec(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function Jh(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&or(e)}function or(e){const t=e._zod.def;switch(t.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return t.innerType?or(t.innerType):!0;case"union":return t.options?t.options.some(or):!0;case"intersection":return!t.left||!t.right||or(t.left)||or(t.right);case"pipe":return t.out?or(t.out):!0;default:return!0}}function R0(e,t,n,r,i=!0){const o=n._zod.def,s=i?re(t):null;return s&&e.write(`let ${s} = null;`),e.write(`if (${r} !== null) {`),e.indented(a=>{const u=We(a,t,o.innerType,r,i);s&&u!==null&&a.write(`${s} = ${u};`)}),e.write("}"),s}function L0(e,t,n,r,i=!0){const o=n._zod.def;e.write(`if (!Array.isArray(${r})) return INVALID;`);const s=i?re(t):null,a=re(t),u=re(t);return s&&e.write(`const ${s} = new Array(${r}.length);`),e.write(`for (let ${a} = 0; ${a} < ${r}.length; ${a}++) {`),e.indented(c=>{c.write(`const ${u} = ${r}[${a}];`);const l=pt(c,t,o.element,u,i);s&&l!==null&&c.write(`${s}[${a}] = ${l};`)}),e.write("}"),s}function z0(e,t,n,r){const o=n._zod.def.values;if(o.length!==1){const a=pe(t,new Set(o));return e.write(`if (!${a}.has(${r})) return INVALID;`),r}const s=o[0];if(typeof s=="number"&&Number.isNaN(s)){const a=pe(t,new Set(o));return e.write(`if (!${a}.has(${r})) return INVALID;`),r}if(typeof s=="string")e.write(`if (${r} !== ${Ct(s)}) return INVALID;`);else if(typeof s=="number"||typeof s=="boolean")e.write(`if (${r} !== ${s}) return INVALID;`);else if(s===null)e.write(`if (${r} !== null) return INVALID;`);else if(s===void 0)e.write(`if (${r} !== undefined) return INVALID;`);else if(typeof s=="bigint")e.write(`if (${r} !== ${s}n) return INVALID;`);else throw new Ne(`literal type ${typeof s}`);return r}function P0(e,t,n,r){const i=n._zod.values;if(!i)throw new Ne("enum schema without enumerated values");const o=pe(t,i);return e.write(`if (!${o}.has(${r})) return INVALID;`),r}function Yh(e,t,n,r){const i=n._zod.def;return We(e,t,i.innerType,r)}function D0(e,t,n,r){const i=n._zod.def,s=Object.getOwnPropertyDescriptor(n._zod.def,"defaultValue")?()=>n._zod.def.defaultValue:void 0;if(n._zod.def.type==="prefault"){if(!s)return We(e,t,i.innerType,r);const u=pe(t,s),c=re(t);return e.write(`let ${c} = ${r};`),e.write(`if (${r} === undefined) ${c} = ${u}();`),We(e,t,i.innerType,c)}const a=re(t);if(s){const u=pe(t,s),c=pe(t,Ii);e.write(`let ${a};`),e.write(`if (${r} === undefined) {`),e.indented(l=>{l.write(`${a} = ${c}(${u}());`)}),e.write("} else {"),e.indented(l=>{const d=We(l,t,i.innerType,r);l.write(`${a} = ${d} === undefined ? ${c}(${u}()) : ${d};`)}),e.write("}")}else e.write(`let ${a};`),e.write(`if (${r} !== undefined) {`),e.indented(u=>{const c=We(u,t,i.innerType,r);u.write(`${a} = ${c};`)}),e.write("}");return a}function O0(e,t,n,r){const i=n._zod.def,o=We(e,t,i.innerType,r),s=re(t);return e.write(`const ${s} = ${o};`),e.write(`if (${s} === undefined) return INVALID;`),s}function M0(e,t,n,r){const i=n._zod.def,o=i.items,s=i.rest;e.write(`if (!Array.isArray(${r})) return INVALID;`);const a=Xh(o,"optin"),u=Xh(o,"optout");s?e.write(`if (${r}.length < ${a}) return INVALID;`):e.write(`if (${r}.length < ${a} || ${r}.length > ${o.length}) return INVALID;`);const c=re(t);e.write(`const ${c} = [];`);for(let l=0;l<o.length;l++){const d=o[l];if(l>=u)e.write(`if (${c}.length === ${l}) {`),e.indented(f=>{f.write(`if (${l} < ${r}.length) {`),f.indented(h=>{const p=re(t);h.write(`const ${p} = ${r}[${l}];`);const m=pt(h,t,d,p);h.write(`${c}[${l}] = ${m};`)}),f.write("} else {"),f.indented(h=>{if(ec(d)){h.write(`${c}.length = ${l};`);return}const p=re(t),m=re(t);h.write(`const ${p} = undefined;`),h.write(`const ${m} = (() => {`),h.indented(y=>{const b=pt(y,t,d,p);y.write(`return ${b};`)}),h.write("})();"),h.write(`if (${m} === INVALID || ${m} === undefined) ${c}.length = ${l};`),h.write(`else ${c}[${l}] = ${m};`)}),f.write("}")}),e.write("}");else{const f=re(t);e.write(`const ${f} = ${r}[${l}];`);const h=pt(e,t,d,f);e.write(`${c}[${l}] = ${h};`)}}if(s){const l=re(t),d=re(t);e.write(`for (let ${l} = ${o.length}; ${l} < ${r}.length; ${l}++) {`),e.indented(f=>{f.write(`const ${d} = ${r}[${l}];`);const h=pt(f,t,s,d);f.write(`${c}[${l}] = ${h};`)}),e.write("}")}return c}function Xh(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function F0(e,t,n,r){const i=n._zod.def,o=i.options;if(i.discriminator)return U0(e,t,i,r);if(i.inclusive===!1)throw new Ne("exclusive unions (z.xor)");if(o.length===0)return e.write("return INVALID;"),r;if(o.length===1)return We(e,t,o[0],r);if(o.every(u=>u._zod.def.type==="literal"&&!u._zod.def.checks?.length)){const u=new Set(o.flatMap(l=>l._zod.def.values)),c=pe(t,u);return e.write(`if (!${c}.has(${r})) return INVALID;`),r}const a=re(t);e.write(`let ${a};`);for(let u=0;u<o.length;u++){const c=o[u];u===0?e.write(`${a} = (() => {`):e.write(`if (${a} === INVALID) ${a} = (() => {`),e.indented(l=>{const d=We(l,t,c,r);l.write(`return ${d};`)}),e.write("})();")}return e.write(`if (${a} === INVALID) return INVALID;`),a}function U0(e,t,n,r){if(n.unionFallback)throw new Ne("discriminated union with unionFallback");if(n.options.length===0)return e.write("return INVALID;"),r;const i=re(t),o=re(t);e.write(`const ${i} = ${r}?.[${Ct(n.discriminator)}];`),e.write(`let ${o};`);let s=!0;const a=new Set;for(const u of n.options){const c=u._zod.propValues?.[n.discriminator];if(!c||c.size===0)throw new Ne("discriminated union option without static discriminator values");for(const f of c){if(a.has(f))throw new Ne(`duplicate discriminator value ${String(f)}`);a.add(f)}const l=Array.from(c,f=>G0(t,i,f)),d=s?"if":"else if";e.write(`${d} (${l.join(" || ")}) {`),e.indented(f=>{const h=We(f,t,u,r);f.write(`${o} = ${h};`)}),e.write("}"),s=!1}return e.write("else { return INVALID; }"),o}function G0(e,t,n){if(typeof n=="string")return`${t} === ${Ct(n)}`;if(typeof n=="number")return Number.isNaN(n)?`Number.isNaN(${t})`:`${t} === ${n}`;if(typeof n=="boolean")return`${t} === ${n}`;if(n===null)return`${t} === null`;if(n===void 0)return`${t} === undefined`;if(typeof n=="bigint")return`${t} === ${n}n`;if(typeof n=="symbol"){const r=pe(e,n);return`${t} === ${r}`}throw new Ne(`literal discriminator value ${String(n)}`)}function j0(e,t,n,r){const i=n._zod.def;t.definite=!1;const o=pt(e,t,i.left,r),s=pt(e,t,i.right,r),a=pe(t,yi),u=re(t);return e.write(`const ${u} = ${a}(${o}, ${s});`),e.write(`if (!${u}.valid) return INVALID;`),`${u}.data`}function Z0(e,t,n,r){const i=n._zod.def,o=pe(t,ln);e.write(`if (!${o}(${r})) return INVALID;`);const s=re(t),a=re(t),u=re(t);e.write(`const ${s} = {};`);const c=i,l=c.partial?void 0:i.keyType._zod.values;if(l){const h=[];for(const m of l){if(!(typeof m=="string"||typeof m=="number"||typeof m=="symbol"))throw new Ne(`record key value ${String(m)}`);const y=typeof m=="number"?m.toString():m;if(y==="__proto__")throw new Ne('record key "__proto__"');h.push(y);const b=pe(t,m),g=We(e,t,i.keyType,b),w=re(t);e.write(`const ${w} = ${r}[${B0(t,y)}];`);const v=pt(e,t,i.valueType,w);e.write(`${s}[${g}] = ${v};`)}const p=pe(t,new Set(h));return e.write(`for (const ${a} in ${r}) {`),e.indented(m=>{m.write(`if (${p}.has(${a})) continue;`),c.mode==="loose"?m.write(`if (${a} !== "__proto__") ${s}[${a}] = ${r}[${a}];`):m.write("return INVALID;")}),e.write("}"),s}const d=i.keyType._zod.def;if(!(d.type==="string"&&d.format===void 0&&!d.coerce&&(d.checks?.length??0)===0)){const h=i.mode==="loose",p=Qs(i.keyType);p.definite===!1&&(t.definite=!1);const m=pe(t,p),y=pe(t,Er),b=re(t);return Qh(e,t,r,a,g=>{g.write(`let ${b} = ${m}(${a});`),g.write(`if (${b} === INVALID && typeof ${a} === "string" && ${y}.test(${a})) ${b} = ${m}(Number(${a}));`),h?g.write(`if (${b} === INVALID) { ${s}[${a}] = ${r}[${a}]; continue; }`):g.write(`if (${b} === INVALID) return INVALID;`),g.write(`if (${b} === "__proto__") continue;`);const w=re(t);g.write(`const ${w} = ${r}[${a}];`);const v=pt(g,t,i.valueType,w);g.write(`${s}[${b}] = ${v};`)}),s}return Qh(e,t,r,a,h=>{h.write(`const ${u} = ${r}[${a}];`);const p=pt(h,t,i.valueType,u);h.write(`${s}[${a}] = ${p};`)},"return INVALID;"),s}function Qh(e,t,n,r,i,o){const s=pe(t,Object.prototype.propertyIsEnumerable),a=re(t),u=re(t),c=re(t);e.write(`const ${a} = Object.getOwnPropertySymbols(${n});`),e.write(`const ${u} = Object.getOwnPropertyNames(${n});`),e.write(`for (let ${c} = 0; ${c} < ${u}.length; ${c}++) {`),e.indented(l=>{l.write(`const ${r} = ${u}[${c}];`),l.write(`if (${r} === "__proto__" || !${s}.call(${n}, ${r})) continue;`),i(l)}),e.write("}"),e.write(`for (let ${c} = 0; ${c} < ${a}.length; ${c}++) {`),e.indented(l=>{l.write(`const ${r} = ${a}[${c}];`),l.write(`if (!${s}.call(${n}, ${r})) continue;`),o?l.write(o):i(l)}),e.write("}")}function B0(e,t){return typeof t=="string"?Ct(t):pe(e,t)}function H0(e,t,n,r){const i=n._zod.def;e.write(`if (!(${r} instanceof Map)) return INVALID;`);const o=re(t),s=re(t),a=re(t);return e.write(`const ${o} = new Map();`),e.write(`for (const [${s}, ${a}] of ${r}) {`),e.indented(u=>{const c=We(u,t,i.keyType,s),l=We(u,t,i.valueType,a);u.write(`${o}.set(${c}, ${l});`)}),e.write("}"),o}function V0(e,t,n,r){const i=n._zod.def;e.write(`if (!(${r} instanceof Set)) return INVALID;`);const o=re(t),s=re(t);return e.write(`const ${o} = new Set();`),e.write(`for (const ${s} of ${r}) {`),e.indented(a=>{const u=We(a,t,i.valueType,s);a.write(`${o}.add(${u});`)}),e.write("}"),o}function q0(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function W0(e,t,n,r){e.write(`if (typeof ${r} !== "string") return INVALID;`);const i=n._zod.pattern;if(i){const o=pe(t,i);e.write(`${o}.lastIndex = 0;`),e.write(`if (!${o}.test(${r})) return INVALID;`)}return r}function K0(e,t,n,r){const i=n._zod.def,o=Wn(t,i.getter),s=pe(t,{parser:null});e.write(`if (!${s}.parser) {`),e.indented(u=>{u.write(`const inner = ${o}();`),u.write(`${s}.parser = function(input) {`),u.indented(c=>{c.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),c.write("return result.issues.length === 0 ? result.value : INVALID;")}),u.write("};")}),e.write("}");const a=re(t);return e.write(`const ${a} = ${s}.parser(${r});`),e.write(`if (${a} === INVALID) return INVALID;`),a}function J0(e,t,n,r){const i=n._zod.def,o=We(e,t,i.in,r);if(i.transform){if(Kn(i.transform))throw new hn("z.compile: async transforms in pipes are not supported");const s=i.transform,u=Wn(t,l=>{const d={value:l,issues:[],addIssue:Rl},f=s(l,d);return f instanceof Promise?kt:d.issues.length===0?f:kt}),c=re(t);return e.write(`const ${c} = ${u}(${o});`),e.write(`if (${c} === INVALID) return INVALID;`),We(e,t,i.out,c)}else return We(e,t,i.out,o)}function Kn(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function Y0(e,t,n,r){const i=n._zod.def;if(i.fn){if(Kn(i.fn))throw new hn("z.compile: async custom predicates are not supported");const o=Wn(t,i.fn),s=pe(t,Qu),a=re(t);e.write(`const ${a} = ${o}(${r});`),e.write(`if (${a} instanceof Promise) ${s}();`),e.write(`if (!${a}) return INVALID;`)}else throw new Ne("custom schema without a predicate function");return r}function X0(e,t,n){const r=e._zod.run({value:n,issues:[]},{});if(r&&typeof r.then=="function")return kt;const i=r;return i.issues.length===0?i.value:t()}function Q0(e,t,n,r){const i=n._zod.def;if(!i.catchValue[Pc])throw new Ne("catch with a callback (only a constant catch value compiles)",!1);const o=re(t);e.write(`let ${o} = (() => {`),e.indented(c=>{const l=pt(c,t,i.innerType,r);c.write(`return ${l};`)}),e.write("})();");const s=pe(t,i.innerType),a=Wn(t,i.catchValue),u=pe(t,X0);return e.write(`if (${o} === INVALID) {`),e.indented(c=>{c.write(`${o} = ${u}(${s}, ${a}, ${r});`),c.write(`if (${o} === INVALID) return INVALID;`)}),e.write("}"),o}function ex(e,t,n,r){const i=n._zod.def;if(i.transform){if(Kn(i.transform))throw new hn("z.compile: async transforms are not supported");const o=i.transform,a=Wn(t,c=>{const l={value:c,issues:[],addIssue:Rl},d=o(c,l);return d instanceof Promise?kt:l.issues.length===0?d:kt}),u=re(t);return e.write(`const ${u} = ${a}(${r});`),e.write(`if (${u} === INVALID) return INVALID;`),u}return r}function ea(e){return e.checks&&(e.checks=[...e.checks]),e}function Nv(e,t){return new e(ea({type:"string",...R(t)}))}function Rv(e,t){return new e(ea({type:"string",coerce:!0,...R(t)}))}function Ll(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...R(t)})}function zl(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...R(t)})}function Pl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...R(t)})}function Dl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...R(t)})}function Ol(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...R(t)})}function Ml(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...R(t)})}function ta(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...R(t)})}function Fl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...R(t)})}function Ul(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...R(t)})}function Gl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...R(t)})}function jl(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...R(t)})}function Zl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...R(t)})}function Bl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...R(t)})}function Hl(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...R(t)})}function Vl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...R(t)})}function ql(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...R(t)})}function Lv(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...R(t)})}function Wl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...R(t)})}function Kl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...R(t)})}function Jl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...R(t)})}function Yl(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...R(t)})}function Xl(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...R(t)})}function zv(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...R(t)})}function Pv(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...R(t)})}function Ql(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...R(t)})}const ed={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function td(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...R(t)})}function nd(e,t){return new e({type:"string",format:"date",check:"string_format",...R(t)})}function rd(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...R(t)})}function id(e,t){return new e({type:"string",format:"duration",check:"string_format",...R(t)})}function Dv(e,t){return new e(ea({type:"number",checks:[],...R(t)}))}function Ov(e,t){return new e(ea({type:"number",coerce:!0,checks:[],...R(t)}))}function Mv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...R(t)})}function Fv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...R(t)})}function Uv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...R(t)})}function Gv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...R(t)})}function jv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...R(t)})}function Zv(e,t){return new e({type:"boolean",...R(t)})}function Bv(e,t){return new e({type:"boolean",coerce:!0,...R(t)})}function Hv(e,t){return new e({type:"bigint",...R(t)})}function Vv(e,t){return new e({type:"bigint",coerce:!0,...R(t)})}function qv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...R(t)})}function Wv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...R(t)})}function Kv(e,t){return new e({type:"symbol",...R(t)})}function Jv(e,t){return new e({type:"undefined",...R(t)})}function Yv(e,t){return new e({type:"null",...R(t)})}function Xv(e){return new e({type:"any"})}function Qv(e){return new e({type:"unknown"})}function eb(e,t){return new e({type:"never",...R(t)})}function tb(e,t){return new e({type:"void",...R(t)})}function nb(e,t){return new e({type:"date",...R(t)})}function rb(e,t){return new e({type:"date",coerce:!0,...R(t)})}function ib(e,t){return new e({type:"nan",...R(t)})}function pn(e,t){return new nl({check:"less_than",...R(t),value:e,inclusive:!1})}function At(e,t){return new nl({check:"less_than",...R(t),value:e,inclusive:!0})}function mn(e,t){return new rl({check:"greater_than",...R(t),value:e,inclusive:!1})}function It(e,t){return new rl({check:"greater_than",...R(t),value:e,inclusive:!0})}function na(e){return mn(0,e)}function ra(e){return pn(0,e)}function ia(e){return At(0,e)}function oa(e){return It(0,e)}function Jn(e,t){return new Zg({check:"multiple_of",...R(t),value:e})}function er(e,t){return new Vg({check:"max_size",...R(t),maximum:e})}function gn(e,t){return new qg({check:"min_size",...R(t),minimum:e})}function $r(e,t){return new Wg({check:"size_equals",...R(t),size:e})}function Tr(e,t){return new Kg({check:"max_length",...R(t),maximum:e})}function Nn(e,t){return new Jg({check:"min_length",...R(t),minimum:e})}function Cr(e,t){return new Yg({check:"length_equals",...R(t),length:e})}function Gi(e,t){return new Xg({check:"string_format",format:"regex",...R(t),pattern:e})}function ji(e){return new Qg({check:"string_format",format:"lowercase",...R(e)})}function Zi(e){return new ey({check:"string_format",format:"uppercase",...R(e)})}function Bi(e,t){return new ty({check:"string_format",format:"includes",...R(t),includes:e})}function Hi(e,t){return new ny({check:"string_format",format:"starts_with",...R(t),prefix:e})}function Vi(e,t){return new ry({check:"string_format",format:"ends_with",...R(t),suffix:e})}function sa(e,t,n){return new iy({check:"property",property:e,schema:t,...R(n)})}function qi(e,t){return new oy({check:"properties",shape:e,...R(t)})}function Wi(e,t){return new sy({check:"mime_type",mime:e,...R(t)})}function nn(e){return new ay({check:"overwrite",tx:e})}function Ki(e){return nn(t=>t.normalize(e))}function Ji(){return nn(e=>e.trim())}function Yi(){return nn(e=>e.toLowerCase())}function Xi(){return nn(e=>e.toUpperCase())}function Qi(){return nn(e=>Fm(e))}function ob(e,t,n){return new e({type:"array",element:t,...R(n)})}function tx(e,t,n){return new e({type:"union",options:t,...R(n)})}function nx(e,t,n){return new e({type:"union",options:t,inclusive:!1,...R(n)})}function rx(e,t,n,r){return new e({type:"union",options:n,discriminator:t,...R(r)})}function ix(e,t,n){return new e({type:"intersection",left:t,right:n})}function ox(e,t,n,r){const i=n instanceof be,o=i?r:n,s=i?n:null;return new e({type:"tuple",items:t,rest:s,...R(o)})}function sx(e,t,n,r){return new e({type:"record",keyType:t,valueType:n,...R(r)})}function ax(e,t,n,r){return new e({type:"map",keyType:t,valueType:n,...R(r)})}function ux(e,t,n){return new e({type:"set",valueType:t,...R(n)})}function cx(e,t,n){const r=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new e({type:"enum",entries:r,...R(n)})}function lx(e,t,n){return new e({type:"enum",entries:t,...R(n)})}function dx(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...R(n)})}function sb(e,t){return new e({type:"file",...R(t)})}function fx(e,t){return new e({type:"transform",transform:t})}function hx(e,t){return new e({type:"optional",innerType:t})}function px(e,t){return new e({type:"nullable",innerType:t})}function mx(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():Ii(n)}})}function gx(e,t,n){return new e({type:"nonoptional",innerType:t,...R(n)})}function yx(e,t){return new e({type:"success",innerType:t})}function vx(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:Dc(n)})}function bx(e,t,n){return new e({type:"pipe",in:t,out:n})}function wx(e,t){return new e({type:"readonly",innerType:t})}function _x(e,t,n){return new e({type:"template_literal",parts:t,...R(n)})}function kx(e,t){return new e({type:"lazy",getter:t})}function Sx(e,t){return new e({type:"promise",innerType:t})}function ab(e,t,n){const r=R(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function ub(e,t,n){return new e({type:"custom",check:"custom",fn:t,...R(n)})}function cb(e,t){const n=lb(r=>(r.addIssue=i=>{if(typeof i=="string")r.issues.push(dr(i,r.value,n._zod.def));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=r.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),r.issues.push(dr(o))}},e(r.value,r)),t);return n}function lb(e,t){const n=new Ve({check:"custom",...R(t)});return n._zod.check=e,n}function db(e){const t=new Ve({check:"describe"});return t._zod.onattach=[n=>{const r=Tt.get(n)??{};Tt.add(n,{...r,description:e})}],t._zod.check=()=>{},t}function fb(e){const t=new Ve({check:"meta"});return t._zod.onattach=[n=>{const r=Tt.get(n)??{};Tt.add(n,{...r,...e})}],t._zod.check=()=>{},t}function hb(e,t){const n=R(t);let r=n.truthy??["true","1","yes","on","y","enabled"],i=n.falsy??["false","0","no","off","n","disabled"];n.case!=="sensitive"&&(r=r.map(h=>typeof h=="string"?h.toLowerCase():h),i=i.map(h=>typeof h=="string"?h.toLowerCase():h));const o=new Set(r),s=new Set(i),a=e.Codec??xl,u=e.Boolean??vl,c=e.String??Ui,l=new c({type:"string",error:n.error}),d=new u({type:"boolean",error:n.error}),f=new a({type:"pipe",in:l,out:d,transform:((h,p)=>{let m=h;return n.case!=="sensitive"&&(m=m.toLowerCase()),o.has(m)?!0:s.has(m)?!1:(p.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...s],input:p.value,inst:f,continue:!1}),{})}),reverseTransform:((h,p)=>h===!0?r[0]||"true":i[0]||"false"),error:n.error});return f._zod.bag.truthy=r,f._zod.bag.falsy=i,f._zod.bag.case=n.case??"insensitive",f}function Ar(e,t,n,r={}){const i=R(r),o={check:"string_format",type:"string",format:t,fn:typeof n=="function"?n:a=>n.test(a),...i};return n instanceof RegExp&&(o.pattern=n),new e(o)}function ci(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&Nt(e,r,n[r]);return e}function hr(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Tt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function it(e,t,n,r,i){const o=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(i);return Object.assign(n,o),!0}function Fe(e,t,n={path:[],schemaPath:[]}){var r;const i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const l={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,l);else{const f=s.schema,h=t.processors[i.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);h(e,t,f,l)}const d=e._zod.parent;d&&(s.ref||(s.ref=d),Fe(d,t,l),t.seen.get(d).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&ci(s.schema,u),t.io==="input"&&vt(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function ep(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function pr(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const s of e.seen.entries()){const a=e.metadataRegistry.get(s[0])?.id;if(a){const u=r.get(a);if(u&&u!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}const i=s=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const d=e.external.registry.get(s[0])?.id,f=e.external.uri??(p=>p);if(d)return{ref:f(d)};const h=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=h,{defId:h,ref:`${f("__shared")}#/${a}/${ep(h)}`}}const u="#",c=`${u}/${a}/`;if(s[1]===n&&!s[1].schema.id)return{ref:u};const l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:c+ep(l)}},o=s=>{if(s[1].schema.$ref)return;const a=s[1],{ref:u,defId:c}=i(s);a.def={...a.schema},c&&(a.defId=c);const l=a.schema;for(const d in l)delete l[d];l.$ref=u};if(e.cycles==="throw")for(const s of e.seen.entries()){const a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
68
+ }`;let h;try{h=new l(...s,d)(...a)}catch(f){throw new ze(`this schema (generated code failed to evaluate: ${f.message})`)}return t?.debug&&(h.code=c),h.definite=r.definite,h}function he(e,t){for(const[r,i]of e.constants)if(i===t)return r;const n=`c${e.constantCounter++}`;return e.constants.set(n,t),n}function Wn(e,t){return e.definite=!1,he(e,t)}function se(e){return`v${e.varCounter++}`}function p0(e,t){const n=e._zod.run({value:t,issues:[]},{});if(n&&typeof n.then=="function")return St;const r=n;return r.issues.length===0?r.value:St}function mt(e,t,n,r,i=!0){const o=e.content.length,s=t.constants.size,a=t.constantCounter,u=t.varCounter;try{return qe(e,t,n,r,i)}catch(c){if(!(c instanceof ze)||!c.islandable)throw c;if(e.content.length=o,t.constants.size>s){const l=Array.from(t.constants.keys()).slice(s);for(const d of l)t.constants.delete(d)}return t.constantCounter=a,t.varCounter=u,m0(e,t,n,r)}}function m0(e,t,n,r){t.definite=!1;const i=he(t,n),o=he(t,p0),s=se(t);return e.write(`const ${s} = ${o}(${i}, ${r});`),e.write(`if (${s} === INVALID) return INVALID;`),s}const g0=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function y0(e,t,n,r){const i=n._zod.def.checks;if(!i||i.length===0)return r;let o=r;for(const s of i){const a=s._zod.def;if(a.when&&!g0.has(a.check))throw new ze('check with a custom "when" condition');switch(a.check){case"greater_than":v0(e,t,a,o);break;case"less_than":b0(e,t,a,o);break;case"multiple_of":w0(e,t,a,o);break;case"number_format":Pv(e,a,o);break;case"min_length":{const u=jn(a.minimum,"min_length"),c=Su(e,t,o,`${o}.length >= ${u} && ${o}.length < ${a.minimum*2}`);e.write(`if (${c} < ${u}) return INVALID;`);break}case"max_length":{const u=jn(a.maximum,"max_length"),c=Su(e,t,o,`${o}.length > ${u}`);e.write(`if (${c} > ${u}) return INVALID;`);break}case"length_equals":{const u=jn(a.length,"length_equals"),c=Su(e,t,o,`${o}.length >= ${u} && ${o}.length <= ${a.length*2}`);e.write(`if (${c} !== ${u}) return INVALID;`);break}case"min_size":e.write(`if (${o}.size < ${jn(a.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${o}.size > ${jn(a.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${o}.size !== ${jn(a.size,"size_equals")}) return INVALID;`);break;case"string_format":o=Mv(e,t,a,o);break;case"custom":o=$0(e,t,s,o);break;case"bigint_format":_0(e,a,o);break;case"mime_type":k0(e,t,a,o);break;case"property":x0(e,t,a,o);break;case"properties":S0(e,t,a,o);break;case"overwrite":{const u=se(t);E0(e,t,s,o,u),o=u;break}default:throw new ze(`check type ${a.check}`)}}return o}function Su(e,t,n,r){const i=he(t,Oi),o=se(t);return e.write(`const ${o} = typeof ${n} === "string" && ${r} ? ${i}(${n}) : ${n}.length;`),o}function jn(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new ze(`${t} bound of type ${typeof e}`);return`${e}`}function Ov(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new ze("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new ze("comparison check with Invalid Date bound");return he(e,t)}throw new ze(`comparison check bound of type ${typeof t}`)}function v0(e,t,n,r){const i=n.inclusive?"<":"<=";e.write(`if (${r} ${i} ${Ov(t,n.value)}) return INVALID;`)}function b0(e,t,n,r){const i=n.inclusive?">":">=";e.write(`if (${r} ${i} ${Ov(t,n.value)}) return INVALID;`)}function w0(e,t,n,r){if(typeof n.value=="bigint"){if(n.value===BigInt(0))throw new ze("multiple_of check with a zero divisor");e.write(`if (${r} % ${n.value}n !== 0n) return INVALID;`)}else{const i=he(t,Pc);e.write(`if (${i}(${r}, ${jn(n.value,"multiple_of")}) !== 0) return INVALID;`)}}function Pv(e,t,n){const r=t.format;switch(r){case"safeint":e.write(`if (!Number.isSafeInteger(${n})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${n}) || ${n} < -2147483648 || ${n} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${n}) || ${n} < 0 || ${n} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${n}) || ${n} < -3.4028234663852886e38 || ${n} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${n})) return INVALID;`);break;default:throw new ze(`number format ${r}`)}}function _0(e,t,n){const r=t.format;if(r)switch(r){case"int64":e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break;default:throw new ze(`bigint format ${r}`)}}function k0(e,t,n,r){const i=n.mime;if(i&&i.length>0){const o=he(t,new Set(i));e.write(`if (!${o}.has(${r}.type)) return INVALID;`)}}function S0(e,t,n,r){if(n.when)throw new ze('check with a custom "when" condition');e.write(`if (${r} == null) return INVALID;`);const i=n.shape;for(const o of Reflect.ownKeys(i)){const s=typeof o=="symbol"?he(t,o):It(o),a=se(t);e.write(`const ${a} = ${r}[${s}];`),mt(e,t,i[o],a,!1)}}function x0(e,t,n,r){const i=`${r}[${JSON.stringify(n.property)}]`;qe(e,t,n.schema,i)}function E0(e,t,n,r,i){const o=n._zod.def.tx;if(!o)throw new ze("overwrite check without a transform function");if(Kn(o))throw new mn("z.compile: async overwrite transforms are not supported");const s=he(t,o);e.write(`const ${i} = ${s}(${r});`)}function oc(){throw new cn}function Fl(e){this.issues.push(e)}function $0(e,t,n,r){const i=n._zod.def;if(i.fn){if(Kn(i.fn))throw new mn("z.compile: async .refine() predicates are not supported");const o=Wn(t,i.fn),s=he(t,oc),a=se(t);return e.write(`const ${a} = ${o}(${r});`),e.write(`if (${a} instanceof Promise) ${s}();`),e.write(`if (!${a}) return INVALID;`),r}if(n._zod.check){if(Kn(n._zod.check))throw new mn("z.compile: async .superRefine() / check functions are not supported");const o=n._zod.check,a=Wn(t,c=>{const l={value:c,issues:[],addIssue:Fl};return o(l)instanceof Promise&&oc(),l.issues.length===0?l.value:St}),u=se(t);return e.write(`const ${u} = ${a}(${r});`),e.write(`if (${u} === INVALID) return INVALID;`),u}throw new ze("custom check without a predicate or check function")}const T0=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function Mv(e,t,n,r,i=!0){const o=n.format;if(o==="base64"){const c=he(t,ea);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="base64url"){const c=he(t,wl);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="jwt"){const c=he(t,Sl),l=he(t,n.alg??null);return e.write(`if (!${c}(${r}, ${l})) return INVALID;`),r}if(o==="ipv6"){const c=he(t,Qs);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="cidrv6"){const c=he(t,vl);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="credit_card"){const c=he(t,_l);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="iban"){const c=he(t,kl);return e.write(`if (!${c}(${r})) return INVALID;`),r}const s=n;if(o==="url"||o==="httpurl"||s.normalize||s.hostname!==void 0||s.protocol!==void 0){const c=he(t,ml),l=he(t,n),d=se(t),h=se(t);if(e.write(`const ${d} = ${r}.trim();`),e.write(`const ${h} = ${c}(${d}, ${l});`),e.write(`if (typeof ${h} === "number") return INVALID;`),s.hostname!==void 0){const m=he(t,gl);e.write(`if (!${m}(${h}, ${l}.hostname)) return INVALID;`)}if(s.protocol!==void 0){const m=he(t,yl);e.write(`if (!${m}(${h}, ${l}.protocol)) return INVALID;`)}if(!i)return null;const f=se(t),p=s.normalize?`${h}.href`:`${he(t,xs)}(${d})`;return e.write(`const ${f} = ${p};`),f}const a=n.fn;if(a){if(Kn(a))throw new ze(`async string format ${o}`);const c=he(t,a);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(T0.has(o)&&n.pattern){const c=he(t,n.pattern);return e.write(`${c}.lastIndex = 0;`),e.write(`if (!${c}.test(${r})) return INVALID;`),r}const u=n.format;switch(u){case"regex":throw new ze("regex format without a pattern");case"lowercase":e.write(`if (${r} !== ${r}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${r} !== ${r}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${r}.includes(${It(n.includes)})) return INVALID;`);break;case"starts_with":{const c=n.prefix;e.write(`if (${r}.slice(0, ${c.length}) !== ${It(c)}) return INVALID;`);break}case"ends_with":{const c=n.suffix;e.write(`if (${r}.slice(-${c.length}) !== ${It(c)}) return INVALID;`);break}default:throw new ze(`string format ${u}`)}return r}function qe(e,t,n,r,i=!0){const o=n._zod.def,s=o.type;if(o.coerce)throw new ze(`coercion (z.coerce.${s}())`);const a=i||!!o.checks?.length;let u;switch(s){case"string":u=C0(e,t,n,r,a);break;case"number":u=A0(e,n,r);break;case"boolean":u=I0(e,r);break;case"bigint":u=N0(e,n,r);break;case"symbol":u=R0(e,r);break;case"undefined":u=L0(e,r);break;case"null":u=z0(e,r);break;case"any":case"unknown":u=r;break;case"never":e.write("return INVALID;"),u=r;break;case"void":u=D0(e,r);break;case"nan":u=O0(e,r);break;case"date":u=P0(e,r);break;case"object":u=M0(e,t,n,r,a);break;case"optional":u=F0(e,t,n,r,a);break;case"nullable":u=j0(e,t,n,r,a);break;case"array":u=Z0(e,t,n,r,a);break;case"literal":u=B0(e,t,n,r);break;case"enum":u=H0(e,t,n,r);break;case"readonly":{const c=sp(e,t,n,r),l=se(t);e.write(`const ${l} = Object.freeze(${c});`),u=l;break}case"success":sp(e,t,n,r),u="true";break;case"default":case"prefault":u=V0(e,t,n,r);break;case"nonoptional":u=q0(e,t,n,r);break;case"tuple":u=W0(e,t,n,r);break;case"union":u=K0(e,t,n,r);break;case"intersection":u=X0(e,t,n,r);break;case"record":u=Q0(e,t,n,r);break;case"map":u=tx(e,t,n,r);break;case"set":u=nx(e,t,n,r);break;case"file":u=rx(e,r);break;case"template_literal":u=ix(e,t,n,r);break;case"lazy":u=ox(e,t,n,r);break;case"pipe":u=sx(e,t,n,r);break;case"custom":u=ax(e,t,n,r);break;case"transform":u=lx(e,t,n,r);break;case"catch":u=cx(e,t,n,r);break;default:throw new ze(`schema type ${s}`)}return u===null?null:y0(e,t,n,u)}function C0(e,t,n,r,i=!0){e.write(`if (typeof ${r} !== "string") return INVALID;`);const o=n._zod.def;return o.format===void 0?r:Mv(e,t,o,r,i)}function A0(e,t,n){e.write(`if (typeof ${n} !== "number" || !Number.isFinite(${n})) return INVALID;`);const r=t._zod.def;return r.check==="number_format"&&r.format&&Pv(e,{format:r.format},n),n}function I0(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function N0(e,t,n){e.write(`if (typeof ${n} !== "bigint") return INVALID;`);const r=t._zod.def;if(r.format)switch(r.format){case"int64":e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break}return n}function R0(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function L0(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function z0(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function D0(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function O0(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function P0(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function M0(e,t,n,r,i=!0){const o=n._zod.def;e.write(`if (typeof ${r} !== "object" || ${r} === null || Array.isArray(${r})) return INVALID;`);const s=o.shape,a=Object.keys(s),u=Object.getOwnPropertySymbols(s),c=u.length?[...a,...u]:a,l=g=>typeof g=="symbol"?he(t,g):It(g),d=g=>typeof g=="symbol"?`[${l(g)}]`:It(g),h=s;if(a.includes("__proto__"))throw new ze('object shape key "__proto__"');const f=new Map;for(const g of c){const _=h[g],v=l(g),w=se(t);if(e.write(`const ${w} = ${r}[${v}];`),_._zod.optin!==void 0){const k=se(t);e.write(`let ${k} = (() => {`),e.indented(x=>{const D=mt(x,t,_,w);x.write(`return ${D};`)}),e.write("})();"),_._zod.optout==="optional"?(e.write(`if (${k} === INVALID) {`),e.indented(x=>{x.write(`if (${v} in ${r}) return INVALID;`),x.write(`${k} = undefined;`)}),e.write("}")):e.write(`if (${k} === INVALID) return INVALID;`),f.set(g,k)}else{G0(_)&&e.write(`if (!(${v} in ${r})) return INVALID;`);const k=mt(e,t,_,w,i);k!==null&&f.set(g,k)}}const p=o.catchall;let m="none";if(p){const g=p._zod.def.type;if(g==="never"){const _=a.map(v=>`k !== ${It(v)}`).join(" && ")||"true";e.write(`for (const k in ${r}) {`),e.indented(v=>{v.write(`if (${_}) return INVALID;`)}),e.write("}")}else(g==="unknown"||g==="any")&&!p._zod.def.checks?.length?m="passthrough":m="schema"}const y=se(t),b=c.some(g=>op(h[g])||sc(h[g]));if(!i){if(m==="schema"){const g=a.length>0?he(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(_=>{_.write('if (k === "__proto__") continue;'),g&&_.write(`if (${g}.has(k)) continue;`);const v=se(t);_.write(`const ${v} = ${r}[k];`),mt(_,t,p,v,!1)}),e.write("}")}return null}if(b){e.write(`const ${y} = {};`);for(const g of c){const _=l(g),v=f.get(g);sc(h[g])?e.write(`if (${_} in ${r}) ${y}[${_}] = ${v};`):op(h[g])?e.write(`if (${v} !== undefined || ${_} in ${r}) ${y}[${_}] = ${v};`):e.write(`${y}[${_}] = ${v};`)}}else{const g=c.map(_=>`${d(_)}: ${f.get(_)}`).join(", ");e.write(`const ${y} = { ${g} };`)}if(m!=="none"){const g=a.length>0?he(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(_=>{if(_.write('if (k === "__proto__") continue;'),g&&_.write(`if (${g}.has(k)) continue;`),m==="passthrough")_.write(`${y}[k] = ${r}[k];`);else{const v=se(t);_.write(`const ${v} = ${r}[k];`);const w=mt(_,t,p,v);_.write(`${y}[k] = ${w};`)}}),e.write("}")}return y}function F0(e,t,n,r,i=!0){const o=n._zod.def;if(U0(n))return qe(e,t,o.innerType,r,i);if(o.innerType._zod.optin==="defaulted"){const a=se(t),u=se(t);return e.write(`let ${a};`),e.write(`if (${r} === undefined) {`),e.indented(c=>{c.write(`const ${u} = (() => {`),c.indented(l=>{const d=qe(l,t,o.innerType,r);l.write(`return ${d};`)}),c.write("})();"),c.write(`if (${u} !== INVALID) ${a} = ${u};`)}),e.write("} else {"),e.indented(c=>{const l=qe(c,t,o.innerType,r);c.write(`${a} = ${l};`)}),e.write("}"),a}const s=i?se(t):null;return s&&e.write(`let ${s};`),e.write(`if (${r} !== undefined) {`),e.indented(a=>{const u=qe(a,t,o.innerType,r,i);s&&u!==null&&a.write(`${s} = ${u};`)}),e.write("}"),s}function U0(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function G0(e){return e._zod.optin===void 0&&Zn(e)}function Zn(e){if(e._zod.def.coerce)return!0;const t=e._zod.def;switch(t.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return t.innerType?Zn(t.innerType):!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return t.innerType?Zn(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(Zn):!0;case"intersection":return!t.left||!t.right?!0:Zn(t.left)&&Zn(t.right);case"pipe":return t.in?Zn(t.in):!0;default:return!0}}function sc(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function op(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&or(e)}function or(e){const t=e._zod.def;switch(t.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return t.innerType?or(t.innerType):!0;case"union":return t.options?t.options.some(or):!0;case"intersection":return!t.left||!t.right||or(t.left)||or(t.right);case"pipe":return t.out?or(t.out):!0;default:return!0}}function j0(e,t,n,r,i=!0){const o=n._zod.def,s=i?se(t):null;return s&&e.write(`let ${s} = null;`),e.write(`if (${r} !== null) {`),e.indented(a=>{const u=qe(a,t,o.innerType,r,i);s&&u!==null&&a.write(`${s} = ${u};`)}),e.write("}"),s}function Z0(e,t,n,r,i=!0){const o=n._zod.def;e.write(`if (!Array.isArray(${r})) return INVALID;`);const s=i?se(t):null,a=se(t),u=se(t);return s&&e.write(`const ${s} = new Array(${r}.length);`),e.write(`for (let ${a} = 0; ${a} < ${r}.length; ${a}++) {`),e.indented(c=>{c.write(`const ${u} = ${r}[${a}];`);const l=mt(c,t,o.element,u,i);s&&l!==null&&c.write(`${s}[${a}] = ${l};`)}),e.write("}"),s}function B0(e,t,n,r){const o=n._zod.def.values;if(o.length!==1){const a=he(t,new Set(o));return e.write(`if (!${a}.has(${r})) return INVALID;`),r}const s=o[0];if(typeof s=="number"&&Number.isNaN(s)){const a=he(t,new Set(o));return e.write(`if (!${a}.has(${r})) return INVALID;`),r}if(typeof s=="string")e.write(`if (${r} !== ${It(s)}) return INVALID;`);else if(typeof s=="number"||typeof s=="boolean")e.write(`if (${r} !== ${s}) return INVALID;`);else if(s===null)e.write(`if (${r} !== null) return INVALID;`);else if(s===void 0)e.write(`if (${r} !== undefined) return INVALID;`);else if(typeof s=="bigint")e.write(`if (${r} !== ${s}n) return INVALID;`);else throw new ze(`literal type ${typeof s}`);return r}function H0(e,t,n,r){const i=n._zod.values;if(!i)throw new ze("enum schema without enumerated values");const o=he(t,i);return e.write(`if (!${o}.has(${r})) return INVALID;`),r}function sp(e,t,n,r){const i=n._zod.def;return qe(e,t,i.innerType,r)}function V0(e,t,n,r){const i=n._zod.def,s=Object.getOwnPropertyDescriptor(n._zod.def,"defaultValue")?()=>n._zod.def.defaultValue:void 0;if(n._zod.def.type==="prefault"){if(!s)return qe(e,t,i.innerType,r);const u=he(t,s),c=se(t);return e.write(`let ${c} = ${r};`),e.write(`if (${r} === undefined) ${c} = ${u}();`),qe(e,t,i.innerType,c)}const a=se(t);if(s){const u=he(t,s),c=he(t,Di);e.write(`let ${a};`),e.write(`if (${r} === undefined) {`),e.indented(l=>{l.write(`${a} = ${c}(${u}());`)}),e.write("} else {"),e.indented(l=>{const d=qe(l,t,i.innerType,r);l.write(`${a} = ${d} === undefined ? ${c}(${u}()) : ${d};`)}),e.write("}")}else e.write(`let ${a};`),e.write(`if (${r} !== undefined) {`),e.indented(u=>{const c=qe(u,t,i.innerType,r);u.write(`${a} = ${c};`)}),e.write("}");return a}function q0(e,t,n,r){const i=n._zod.def,o=qe(e,t,i.innerType,r),s=se(t);return e.write(`const ${s} = ${o};`),e.write(`if (${s} === undefined) return INVALID;`),s}function W0(e,t,n,r){const i=n._zod.def,o=i.items,s=i.rest;e.write(`if (!Array.isArray(${r})) return INVALID;`);const a=ap(o,"optin"),u=ap(o,"optout");s?e.write(`if (${r}.length < ${a}) return INVALID;`):e.write(`if (${r}.length < ${a} || ${r}.length > ${o.length}) return INVALID;`);const c=se(t);e.write(`const ${c} = [];`);for(let l=0;l<o.length;l++){const d=o[l];if(l>=u)e.write(`if (${c}.length === ${l}) {`),e.indented(h=>{h.write(`if (${l} < ${r}.length) {`),h.indented(f=>{const p=se(t);f.write(`const ${p} = ${r}[${l}];`);const m=mt(f,t,d,p);f.write(`${c}[${l}] = ${m};`)}),h.write("} else {"),h.indented(f=>{if(sc(d)){f.write(`${c}.length = ${l};`);return}const p=se(t),m=se(t);f.write(`const ${p} = undefined;`),f.write(`const ${m} = (() => {`),f.indented(y=>{const b=mt(y,t,d,p);y.write(`return ${b};`)}),f.write("})();"),f.write(`if (${m} === INVALID || ${m} === undefined) ${c}.length = ${l};`),f.write(`else ${c}[${l}] = ${m};`)}),h.write("}")}),e.write("}");else{const h=se(t);e.write(`const ${h} = ${r}[${l}];`);const f=mt(e,t,d,h);e.write(`${c}[${l}] = ${f};`)}}if(s){const l=se(t),d=se(t);e.write(`for (let ${l} = ${o.length}; ${l} < ${r}.length; ${l}++) {`),e.indented(h=>{h.write(`const ${d} = ${r}[${l}];`);const f=mt(h,t,s,d);h.write(`${c}[${l}] = ${f};`)}),e.write("}")}return c}function ap(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function K0(e,t,n,r){const i=n._zod.def,o=i.options;if(i.discriminator)return J0(e,t,i,r);if(i.inclusive===!1)throw new ze("exclusive unions (z.xor)");if(o.length===0)return e.write("return INVALID;"),r;if(o.length===1)return qe(e,t,o[0],r);if(o.every(u=>u._zod.def.type==="literal"&&!u._zod.def.checks?.length)){const u=new Set(o.flatMap(l=>l._zod.def.values)),c=he(t,u);return e.write(`if (!${c}.has(${r})) return INVALID;`),r}const a=se(t);e.write(`let ${a};`);for(let u=0;u<o.length;u++){const c=o[u];u===0?e.write(`${a} = (() => {`):e.write(`if (${a} === INVALID) ${a} = (() => {`),e.indented(l=>{const d=qe(l,t,c,r);l.write(`return ${d};`)}),e.write("})();")}return e.write(`if (${a} === INVALID) return INVALID;`),a}function J0(e,t,n,r){if(n.unionFallback)throw new ze("discriminated union with unionFallback");if(n.options.length===0)return e.write("return INVALID;"),r;const i=se(t),o=se(t);e.write(`const ${i} = ${r}?.[${It(n.discriminator)}];`),e.write(`let ${o};`);let s=!0;const a=new Set;for(const u of n.options){const c=u._zod.propValues?.[n.discriminator];if(!c||c.size===0)throw new ze("discriminated union option without static discriminator values");for(const h of c){if(a.has(h))throw new ze(`duplicate discriminator value ${String(h)}`);a.add(h)}const l=Array.from(c,h=>Y0(t,i,h)),d=s?"if":"else if";e.write(`${d} (${l.join(" || ")}) {`),e.indented(h=>{const f=qe(h,t,u,r);h.write(`${o} = ${f};`)}),e.write("}"),s=!1}return e.write("else { return INVALID; }"),o}function Y0(e,t,n){if(typeof n=="string")return`${t} === ${It(n)}`;if(typeof n=="number")return Number.isNaN(n)?`Number.isNaN(${t})`:`${t} === ${n}`;if(typeof n=="boolean")return`${t} === ${n}`;if(n===null)return`${t} === null`;if(n===void 0)return`${t} === undefined`;if(typeof n=="bigint")return`${t} === ${n}n`;if(typeof n=="symbol"){const r=he(e,n);return`${t} === ${r}`}throw new ze(`literal discriminator value ${String(n)}`)}function X0(e,t,n,r){const i=n._zod.def;t.definite=!1;const o=mt(e,t,i.left,r),s=mt(e,t,i.right,r),a=he(t,_i),u=se(t);return e.write(`const ${u} = ${a}(${o}, ${s});`),e.write(`if (!${u}.valid) return INVALID;`),`${u}.data`}function Q0(e,t,n,r){const i=n._zod.def,o=he(t,fn);e.write(`if (!${o}(${r})) return INVALID;`);const s=se(t),a=se(t),u=se(t);e.write(`const ${s} = {};`);const c=i,l=c.partial?void 0:i.keyType._zod.values;if(l){const f=[];for(const m of l){if(!(typeof m=="string"||typeof m=="number"||typeof m=="symbol"))throw new ze(`record key value ${String(m)}`);const y=typeof m=="number"?m.toString():m;if(y==="__proto__")throw new ze('record key "__proto__"');f.push(y);const b=he(t,m),g=qe(e,t,i.keyType,b),_=se(t);e.write(`const ${_} = ${r}[${ex(t,y)}];`);const v=mt(e,t,i.valueType,_);e.write(`${s}[${g}] = ${v};`)}const p=he(t,new Set(f));return e.write(`for (const ${a} in ${r}) {`),e.indented(m=>{m.write(`if (${p}.has(${a})) continue;`),c.mode==="loose"?m.write(`if (${a} !== "__proto__") ${s}[${a}] = ${r}[${a}];`):m.write("return INVALID;")}),e.write("}"),s}const d=i.keyType._zod.def;if(!(d.type==="string"&&d.format===void 0&&!d.coerce&&(d.checks?.length??0)===0)){const f=i.mode==="loose",p=sa(i.keyType);p.definite===!1&&(t.definite=!1);const m=he(t,p),y=he(t,$r),b=se(t);return up(e,t,r,a,g=>{g.write(`let ${b} = ${m}(${a});`),g.write(`if (${b} === INVALID && typeof ${a} === "string" && ${y}.test(${a})) ${b} = ${m}(Number(${a}));`),f?g.write(`if (${b} === INVALID) { ${s}[${a}] = ${r}[${a}]; continue; }`):g.write(`if (${b} === INVALID) return INVALID;`),g.write(`if (${b} === "__proto__") continue;`);const _=se(t);g.write(`const ${_} = ${r}[${a}];`);const v=mt(g,t,i.valueType,_);g.write(`${s}[${b}] = ${v};`)}),s}return up(e,t,r,a,f=>{f.write(`const ${u} = ${r}[${a}];`);const p=mt(f,t,i.valueType,u);f.write(`${s}[${a}] = ${p};`)},"return INVALID;"),s}function up(e,t,n,r,i,o){const s=he(t,Object.prototype.propertyIsEnumerable),a=se(t),u=se(t),c=se(t);e.write(`const ${a} = Object.getOwnPropertySymbols(${n});`),e.write(`const ${u} = Object.getOwnPropertyNames(${n});`),e.write(`for (let ${c} = 0; ${c} < ${u}.length; ${c}++) {`),e.indented(l=>{l.write(`const ${r} = ${u}[${c}];`),l.write(`if (${r} === "__proto__" || !${s}.call(${n}, ${r})) continue;`),i(l)}),e.write("}"),e.write(`for (let ${c} = 0; ${c} < ${a}.length; ${c}++) {`),e.indented(l=>{l.write(`const ${r} = ${a}[${c}];`),l.write(`if (!${s}.call(${n}, ${r})) continue;`),o?l.write(o):i(l)}),e.write("}")}function ex(e,t){return typeof t=="string"?It(t):he(e,t)}function tx(e,t,n,r){const i=n._zod.def;e.write(`if (!(${r} instanceof Map)) return INVALID;`);const o=se(t),s=se(t),a=se(t);return e.write(`const ${o} = new Map();`),e.write(`for (const [${s}, ${a}] of ${r}) {`),e.indented(u=>{const c=qe(u,t,i.keyType,s),l=qe(u,t,i.valueType,a);u.write(`${o}.set(${c}, ${l});`)}),e.write("}"),o}function nx(e,t,n,r){const i=n._zod.def;e.write(`if (!(${r} instanceof Set)) return INVALID;`);const o=se(t),s=se(t);return e.write(`const ${o} = new Set();`),e.write(`for (const ${s} of ${r}) {`),e.indented(a=>{const u=qe(a,t,i.valueType,s);a.write(`${o}.add(${u});`)}),e.write("}"),o}function rx(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function ix(e,t,n,r){e.write(`if (typeof ${r} !== "string") return INVALID;`);const i=n._zod.pattern;if(i){const o=he(t,i);e.write(`${o}.lastIndex = 0;`),e.write(`if (!${o}.test(${r})) return INVALID;`)}return r}function ox(e,t,n,r){const i=n._zod.def,o=Wn(t,i.getter),s=he(t,{parser:null});e.write(`if (!${s}.parser) {`),e.indented(u=>{u.write(`const inner = ${o}();`),u.write(`${s}.parser = function(input) {`),u.indented(c=>{c.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),c.write("return result.issues.length === 0 ? result.value : INVALID;")}),u.write("};")}),e.write("}");const a=se(t);return e.write(`const ${a} = ${s}.parser(${r});`),e.write(`if (${a} === INVALID) return INVALID;`),a}function sx(e,t,n,r){const i=n._zod.def,o=qe(e,t,i.in,r);if(i.transform){if(Kn(i.transform))throw new mn("z.compile: async transforms in pipes are not supported");const s=i.transform,u=Wn(t,l=>{const d={value:l,issues:[],addIssue:Fl},h=s(l,d);return h instanceof Promise?St:d.issues.length===0?h:St}),c=se(t);return e.write(`const ${c} = ${u}(${o});`),e.write(`if (${c} === INVALID) return INVALID;`),qe(e,t,i.out,c)}else return qe(e,t,i.out,o)}function Kn(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function ax(e,t,n,r){const i=n._zod.def;if(i.fn){if(Kn(i.fn))throw new mn("z.compile: async custom predicates are not supported");const o=Wn(t,i.fn),s=he(t,oc),a=se(t);e.write(`const ${a} = ${o}(${r});`),e.write(`if (${a} instanceof Promise) ${s}();`),e.write(`if (!${a}) return INVALID;`)}else throw new ze("custom schema without a predicate function");return r}function ux(e,t,n){const r=e._zod.run({value:n,issues:[]},{});if(r&&typeof r.then=="function")return St;const i=r;return i.issues.length===0?i.value:t()}function cx(e,t,n,r){const i=n._zod.def;if(!i.catchValue[jc])throw new ze("catch with a callback (only a constant catch value compiles)",!1);const o=se(t);e.write(`let ${o} = (() => {`),e.indented(c=>{const l=mt(c,t,i.innerType,r);c.write(`return ${l};`)}),e.write("})();");const s=he(t,i.innerType),a=Wn(t,i.catchValue),u=he(t,ux);return e.write(`if (${o} === INVALID) {`),e.indented(c=>{c.write(`${o} = ${u}(${s}, ${a}, ${r});`),c.write(`if (${o} === INVALID) return INVALID;`)}),e.write("}"),o}function lx(e,t,n,r){const i=n._zod.def;if(i.transform){if(Kn(i.transform))throw new mn("z.compile: async transforms are not supported");const o=i.transform,a=Wn(t,c=>{const l={value:c,issues:[],addIssue:Fl},d=o(c,l);return d instanceof Promise?St:l.issues.length===0?d:St}),u=se(t);return e.write(`const ${u} = ${a}(${r});`),e.write(`if (${u} === INVALID) return INVALID;`),u}return r}function aa(e){return e.checks&&(e.checks=[...e.checks]),e}function Fv(e,t){return new e(aa({type:"string",...z(t)}))}function Uv(e,t){return new e(aa({type:"string",coerce:!0,...z(t)}))}function Ul(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...z(t)})}function Gl(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...z(t)})}function jl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...z(t)})}function Zl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(t)})}function Bl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(t)})}function Hl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(t)})}function ua(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...z(t)})}function Vl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...z(t)})}function ql(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(t)})}function Wl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...z(t)})}function Kl(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(t)})}function Jl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...z(t)})}function Yl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...z(t)})}function Xl(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(t)})}function Ql(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(t)})}function ed(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(t)})}function Gv(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...z(t)})}function td(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(t)})}function nd(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(t)})}function rd(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...z(t)})}function id(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...z(t)})}function od(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...z(t)})}function jv(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...z(t)})}function Zv(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...z(t)})}function sd(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...z(t)})}const ad={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function ud(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(t)})}function cd(e,t){return new e({type:"string",format:"date",check:"string_format",...z(t)})}function ld(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...z(t)})}function dd(e,t){return new e({type:"string",format:"duration",check:"string_format",...z(t)})}function Bv(e,t){return new e(aa({type:"number",checks:[],...z(t)}))}function Hv(e,t){return new e(aa({type:"number",coerce:!0,checks:[],...z(t)}))}function Vv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...z(t)})}function qv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...z(t)})}function Wv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...z(t)})}function Kv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...z(t)})}function Jv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...z(t)})}function Yv(e,t){return new e({type:"boolean",...z(t)})}function Xv(e,t){return new e({type:"boolean",coerce:!0,...z(t)})}function Qv(e,t){return new e({type:"bigint",...z(t)})}function eb(e,t){return new e({type:"bigint",coerce:!0,...z(t)})}function tb(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...z(t)})}function nb(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...z(t)})}function rb(e,t){return new e({type:"symbol",...z(t)})}function ib(e,t){return new e({type:"undefined",...z(t)})}function ob(e,t){return new e({type:"null",...z(t)})}function sb(e){return new e({type:"any"})}function ab(e){return new e({type:"unknown"})}function ub(e,t){return new e({type:"never",...z(t)})}function cb(e,t){return new e({type:"void",...z(t)})}function lb(e,t){return new e({type:"date",...z(t)})}function db(e,t){return new e({type:"date",coerce:!0,...z(t)})}function fb(e,t){return new e({type:"nan",...z(t)})}function gn(e,t){return new cl({check:"less_than",...z(t),value:e,inclusive:!1})}function Nt(e,t){return new cl({check:"less_than",...z(t),value:e,inclusive:!0})}function yn(e,t){return new ll({check:"greater_than",...z(t),value:e,inclusive:!1})}function Rt(e,t){return new ll({check:"greater_than",...z(t),value:e,inclusive:!0})}function ca(e){return yn(0,e)}function la(e){return gn(0,e)}function da(e){return Nt(0,e)}function fa(e){return Rt(0,e)}function Jn(e,t){return new Yg({check:"multiple_of",...z(t),value:e})}function er(e,t){return new ey({check:"max_size",...z(t),maximum:e})}function vn(e,t){return new ty({check:"min_size",...z(t),minimum:e})}function Tr(e,t){return new ny({check:"size_equals",...z(t),size:e})}function Cr(e,t){return new ry({check:"max_length",...z(t),maximum:e})}function Rn(e,t){return new iy({check:"min_length",...z(t),minimum:e})}function Ar(e,t){return new oy({check:"length_equals",...z(t),length:e})}function Vi(e,t){return new sy({check:"string_format",format:"regex",...z(t),pattern:e})}function qi(e){return new ay({check:"string_format",format:"lowercase",...z(e)})}function Wi(e){return new uy({check:"string_format",format:"uppercase",...z(e)})}function Ki(e,t){return new cy({check:"string_format",format:"includes",...z(t),includes:e})}function Ji(e,t){return new ly({check:"string_format",format:"starts_with",...z(t),prefix:e})}function Yi(e,t){return new dy({check:"string_format",format:"ends_with",...z(t),suffix:e})}function ha(e,t,n){return new fy({check:"property",property:e,schema:t,...z(n)})}function Xi(e,t){return new hy({check:"properties",shape:e,...z(t)})}function Qi(e,t){return new py({check:"mime_type",mime:e,...z(t)})}function on(e){return new my({check:"overwrite",tx:e})}function eo(e){return on(t=>t.normalize(e))}function to(){return on(e=>e.trim())}function no(){return on(e=>e.toLowerCase())}function ro(){return on(e=>e.toUpperCase())}function io(){return on(e=>qm(e))}function hb(e,t,n){return new e({type:"array",element:t,...z(n)})}function dx(e,t,n){return new e({type:"union",options:t,...z(n)})}function fx(e,t,n){return new e({type:"union",options:t,inclusive:!1,...z(n)})}function hx(e,t,n,r){return new e({type:"union",options:n,discriminator:t,...z(r)})}function px(e,t,n){return new e({type:"intersection",left:t,right:n})}function mx(e,t,n,r){const i=n instanceof we,o=i?r:n,s=i?n:null;return new e({type:"tuple",items:t,rest:s,...z(o)})}function gx(e,t,n,r){return new e({type:"record",keyType:t,valueType:n,...z(r)})}function yx(e,t,n,r){return new e({type:"map",keyType:t,valueType:n,...z(r)})}function vx(e,t,n){return new e({type:"set",valueType:t,...z(n)})}function bx(e,t,n){const r=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new e({type:"enum",entries:r,...z(n)})}function wx(e,t,n){return new e({type:"enum",entries:t,...z(n)})}function _x(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...z(n)})}function pb(e,t){return new e({type:"file",...z(t)})}function kx(e,t){return new e({type:"transform",transform:t})}function Sx(e,t){return new e({type:"optional",innerType:t})}function xx(e,t){return new e({type:"nullable",innerType:t})}function Ex(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():Di(n)}})}function $x(e,t,n){return new e({type:"nonoptional",innerType:t,...z(n)})}function Tx(e,t){return new e({type:"success",innerType:t})}function Cx(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:Zc(n)})}function Ax(e,t,n){return new e({type:"pipe",in:t,out:n})}function Ix(e,t){return new e({type:"readonly",innerType:t})}function Nx(e,t,n){return new e({type:"template_literal",parts:t,...z(n)})}function Rx(e,t){return new e({type:"lazy",getter:t})}function Lx(e,t){return new e({type:"promise",innerType:t})}function mb(e,t,n){const r=z(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function gb(e,t,n){return new e({type:"custom",check:"custom",fn:t,...z(n)})}function yb(e,t){const n=vb(r=>(r.addIssue=i=>{if(typeof i=="string")r.issues.push(dr(i,r.value,n._zod.def));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=r.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),r.issues.push(dr(o))}},e(r.value,r)),t);return n}function vb(e,t){const n=new Ve({check:"custom",...z(t)});return n._zod.check=e,n}function bb(e){const t=new Ve({check:"describe"});return t._zod.onattach=[n=>{const r=At.get(n)??{};At.add(n,{...r,description:e})}],t._zod.check=()=>{},t}function wb(e){const t=new Ve({check:"meta"});return t._zod.onattach=[n=>{const r=At.get(n)??{};At.add(n,{...r,...e})}],t._zod.check=()=>{},t}function _b(e,t){const n=z(t);let r=n.truthy??["true","1","yes","on","y","enabled"],i=n.falsy??["false","0","no","off","n","disabled"];n.case!=="sensitive"&&(r=r.map(f=>typeof f=="string"?f.toLowerCase():f),i=i.map(f=>typeof f=="string"?f.toLowerCase():f));const o=new Set(r),s=new Set(i),a=e.Codec??Nl,u=e.Boolean??El,c=e.String??Hi,l=new c({type:"string",error:n.error}),d=new u({type:"boolean",error:n.error}),h=new a({type:"pipe",in:l,out:d,transform:((f,p)=>{let m=f;return n.case!=="sensitive"&&(m=m.toLowerCase()),o.has(m)?!0:s.has(m)?!1:(p.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...s],input:p.value,inst:h,continue:!1}),{})}),reverseTransform:((f,p)=>f===!0?r[0]||"true":i[0]||"false"),error:n.error});return h._zod.bag.truthy=r,h._zod.bag.falsy=i,h._zod.bag.case=n.case??"insensitive",h}function Ir(e,t,n,r={}){const i=z(r),o={check:"string_format",type:"string",format:t,fn:typeof n=="function"?n:a=>n.test(a),...i};return n instanceof RegExp&&(o.pattern=n),new e(o)}function di(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&Lt(e,r,n[r]);return e}function hr(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??At,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function ot(e,t,n,r,i){const o=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(i);return Object.assign(n,o),!0}function Ue(e,t,n={path:[],schemaPath:[]}){var r;const i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const l={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,l);else{const h=s.schema,f=t.processors[i.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);f(e,t,h,l)}const d=e._zod.parent;d&&(s.ref||(s.ref=d),Ue(d,t,l),t.seen.get(d).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&di(s.schema,u),t.io==="input"&&bt(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function cp(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function pr(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const s of e.seen.entries()){const a=e.metadataRegistry.get(s[0])?.id;if(a){const u=r.get(a);if(u&&u!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}const i=s=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const d=e.external.registry.get(s[0])?.id,h=e.external.uri??(p=>p);if(d)return{ref:h(d)};const f=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=f,{defId:f,ref:`${h("__shared")}#/${a}/${cp(f)}`}}const u="#",c=`${u}/${a}/`;if(s[1]===n&&!s[1].schema.id)return{ref:u};const l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:c+cp(l)}},o=s=>{if(s[1].schema.$ref)return;const a=s[1],{ref:u,defId:c}=i(s);a.def={...a.schema},c&&(a.defId=c);const l=a.schema;for(const d in l)delete l[d];l.$ref=u};if(e.cycles==="throw")for(const s of e.seen.entries()){const a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
69
69
 
70
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const a=s[1];if(t===s[0]){o(s);continue}if(e.external){const c=e.external.registry.get(s[0])?.id;if(t!==s[0]&&c){o(s);continue}}if(e.metadataRegistry.get(s[0])?.id){o(s);continue}if(a.cycle){o(s);continue}a.count>1&&e.reused==="ref"&&o(s)}e.external&&(e.sharedDefsExtractedFor=e.external)}function pb(e){const t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;const n=[];for(const r of t){if(!r||typeof r!="object")return;pb(r);const i=Object.keys(r);if(i.length!==1||i[0]!=="type")return;const o=r.type;for(const s of Array.isArray(o)?o:[o]){if(typeof s!="string")return;n.includes(s)||n.push(s)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const mb=new Set(["type","properties","required","additionalProperties"]),tp=["oneOf","anyOf"];function np(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function tc(e){const t=[];for(const o of e){if(typeof o!="object"||o.type!=="object")return null;for(const s in o)if(!mb.has(s))return null;t.push(o)}const n={},r=new Set;for(const o of t){for(const s in o.properties){if(Object.prototype.hasOwnProperty.call(n,s))continue;const a=[];for(const c of t){const l=c.properties?.[s]??np(c);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}const u=a.length===1?a[0]:tc(a)??{allOf:a};Nt(n,s,u)}for(const s of o.required??[])r.add(s)}const i={type:"object",properties:n};if(r.size&&(i.required=[...r]),t.every(o=>o.additionalProperties===!1))i.additionalProperties=!1;else{const o=[];for(const s of t){const a=np(s);a&&!o.some(u=>JSON.stringify(u)===JSON.stringify(a))&&o.push(a)}o.length===1?i.additionalProperties=o[0]:o.length>1&&(i.additionalProperties={allOf:o})}return i}function xx(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const i of mb)if(i in e)return;const n=t.filter(i=>tp.some(o=>Array.isArray(i[o])));let r=null;if(!n.length)r=tc(t);else{const i=n[0],o=tp.find(u=>Array.isArray(i[u]));if(Object.keys(i).length!==1)return;const s=t.filter(u=>u!==i),a=i[o].map(u=>tc([...s,u]));if(a.some(u=>!u))return;r={[o]:a}}r&&(delete e.allOf,ci(e,r))}function mr(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=a=>{const u=e.seen.get(a);if(u.ref===null)return;const c=u.def??u.schema,l={...c},d=u.ref;if(u.ref=null,d){r(d);const h=e.seen.get(d),p=h.schema;if(p.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(p)):ci(c,p),ci(c,l),a._zod.parent===d)for(const y in c)y==="$ref"||y==="allOf"||y in l||delete c[y];if(p.$ref&&h.def)for(const y in c)y==="$ref"||y==="allOf"||y in h.def&&JSON.stringify(c[y])===JSON.stringify(h.def[y])&&delete c[y]}const f=a._zod.parent;if(f&&f!==d){r(f);const h=e.seen.get(f);if(h?.schema.$ref&&(c.$ref=h.schema.$ref,h.def))for(const p in c)p==="$ref"||p==="allOf"||p in h.def&&JSON.stringify(c[p])===JSON.stringify(h.def[p])&&delete c[p]}e.override({zodSchema:a,jsonSchema:c,path:u.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const a of[...e.seen.entries()].reverse())r(a[0]);if(e.target!=="openapi-3.0")for(const a of e.seen.entries())pb(a[1].def??a[1].schema);for(const a of e.deferred)a();if(e.intersections.length){const a=new Map;for(const u of e.seen.values())for(const c of[u.schema,u.def]){const l=c?.allOf;if(!Array.isArray(l))continue;const d=a.get(l);d?d.push(c):a.set(l,[c])}for(const u of e.intersections)for(const c of a.get(u)??[])xx(c)}}const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(a)}ci(i,n.defId?n.schema:n.def??n.schema);const o=e.metadataRegistry.get(t)?.id;o!==void 0&&i.id===o&&delete i.id;const s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const a of e.seen.entries()){const u=a[1];u.def&&u.defId&&(u.def.id===u.defId&&delete u.def.id,Nt(s,u.defId,u.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const a=JSON.parse(JSON.stringify(i));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:vi(t,"input",e.processors),output:vi(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function vt(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return vt(r.element,n);if(r.type==="set")return vt(r.valueType,n);if(r.type==="lazy")return vt(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return vt(r.innerType,n);if(r.type==="intersection")return vt(r.left,n)||vt(r.right,n);if(r.type==="record"||r.type==="map")return vt(r.keyType,n)||vt(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:vt(r.in,n)||vt(r.out,n);if(r.type==="object"){for(const i in r.shape)if(vt(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(vt(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(vt(i,n))return!0;return!!(r.rest&&vt(r.rest,n))}return!1}const gb=(e,t={})=>n=>{const r=hr({...n,processors:t});return Fe(e,r),pr(r,e),mr(r,e)},vi=(e,t,n={})=>r=>{const{libraryOptions:i,target:o}=r??{},s=hr({...i??{},target:o,io:t,processors:n});return Fe(e,s),pr(s,e),mr(s,e)},gr=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},yr=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},rp=(e,t)=>{gr(e,"minimum",t),yr(e,"maximum",t)},yb=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},vb=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},bb=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},wb=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},ip=(e,t)=>gr(e,"minimum",t.minimum),op=(e,t)=>yr(e,"maximum",t.maximum),sp=e=>(t,n)=>{wb(t,n.format);const[r,i]=e[n.format];gr(t,"minimum",r),yr(t,"maximum",i)},Ex={greater_than:(e,t)=>gr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>yr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>yb(e,t.value),number_format:sp(Lc),bigint_format:sp(zc),min_length:ip,max_length:op,length_equals:(e,t)=>rp(e,t.length),min_size:ip,max_size:op,size_equals:(e,t)=>rp(e,t.size),string_format:(e,t)=>{wb(e,t.format),t.pattern&&vb(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>bb(e,t.mime)};function rt(e){const t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(const o of r)Ex[o._zod.def.check]?.(t,o._zod.def);const i=e._zod.bag;i.minimum!==void 0&&gr(t,"minimum",i.minimum),i.exclusiveMinimum!==void 0&&gr(t,"exclusiveMinimum",i.exclusiveMinimum),i.maximum!==void 0&&yr(t,"maximum",i.maximum),i.exclusiveMaximum!==void 0&&yr(t,"exclusiveMaximum",i.exclusiveMaximum),i.multipleOf!==void 0&&yb(t,i.multipleOf),i.format!==void 0&&(t.format??(t.format=i.format),i.format.includes("int")&&(t.isInt=!0)),i.mime&&bb(t,i.mime);for(const o of i.patterns??[])vb(t,o);return t}const $x={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Tx=new Map([[fl,xg],[Ws,Eg]]),_b=e=>Tx.get(e)??e,kb=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:o,maximum:s,format:a,patterns:u,contentEncoding:c,laxFormat:l}=rt(e);if(typeof o=="number"&&(i.minLength=o),typeof s=="number"&&(i.maxLength=s),a&&(i.format=$x[a]??a,i.format===""&&delete i.format,(a==="time"||l)&&delete i.format),c&&(i.contentEncoding=c),u&&u.size>0){const d=[...u].map(_b);d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Sb=(e,t,n,r)=>{const i=n,{minimum:o,maximum:s,multipleOf:a,exclusiveMaximum:u,exclusiveMinimum:c,isInt:l}=rt(e);i.type=l?"integer":"number";const d=typeof c=="number"&&c>=(o??Number.NEGATIVE_INFINITY),f=typeof u=="number"&&u<=(s??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(d?h?(i.minimum=c,i.exclusiveMinimum=!0):i.exclusiveMinimum=c:typeof o=="number"&&(i.minimum=o),f?h?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u:typeof s=="number"&&(i.maximum=s),a){const p=new Set;for(const b of a)Number.isFinite(b)&&b!==0?p.add(Math.abs(b)):it(e,t,i,r,`A multipleOf divisor of ${b} cannot be represented in JSON Schema`);const[m,...y]=p;m!==void 0&&(i.multipleOf=m),y.length&&(i.allOf=[...i.allOf??[],...y.map(b=>({multipleOf:b}))])}},xb=(e,t,n,r)=>{n.type="boolean"},Eb=(e,t,n,r)=>{it(e,t,n,r,"BigInt cannot be represented in JSON Schema")},$b=(e,t,n,r)=>{it(e,t,n,r,"Symbols cannot be represented in JSON Schema")},Tb=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},Cb=(e,t,n,r)=>{it(e,t,n,r,"Undefined cannot be represented in JSON Schema")},Ab=(e,t,n,r)=>{it(e,t,n,r,"Void cannot be represented in JSON Schema")},Ib=(e,t,n,r)=>{n.not={}},Nb=(e,t,n,r)=>{},Rb=(e,t,n,r)=>{},Lb=(e,t,n,r)=>{it(e,t,n,r,"Date cannot be represented in JSON Schema")},zb=(e,t,n,r)=>{const i=e._zod.def,o=fs(i.entries);if(o.length===0){n.not={};return}o.every(s=>typeof s=="number")&&(n.type="number"),o.every(s=>typeof s=="string")&&(n.type="string"),n.enum=o},Pb=(e,t,n,r)=>{const i=e._zod.def;if(i.values.length===0){n.not={};return}const o=[];for(const s of i.values)if(s===void 0){if(it(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s=="bigint"){if(it(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(s))}else o.push(s);if(o.length!==0)if(o.length===1){const s=o[0];n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[s]:n.const=s}else o.every(s=>typeof s=="number")&&(n.type="number"),o.every(s=>typeof s=="string")&&(n.type="string"),o.every(s=>typeof s=="boolean")&&(n.type="boolean"),o.every(s=>s===null)&&(n.type="null"),n.enum=o},Db=(e,t,n,r)=>{it(e,t,n,r,"NaN cannot be represented in JSON Schema")},Ob=(e,t,n,r)=>{const i=n,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=o.source},Mb=(e,t,n,r)=>{const i=n;i.type="string",i.format="binary",i.contentEncoding="binary";const{minimum:o,maximum:s,mime:a}=rt(e);o!==void 0&&(i.minLength=o),s!==void 0&&(i.maxLength=s),a&&(a.length===0?i.not={}:a.length===1?i.contentMediaType=a[0]:i.anyOf=a.map(u=>({contentMediaType:u})))},Fb=(e,t,n,r)=>{n.type="boolean"},Ub=(e,t,n,r)=>{it(e,t,n,r,"Custom types cannot be represented in JSON Schema")},Gb=(e,t,n,r)=>{it(e,t,n,r,"Function types cannot be represented in JSON Schema")},jb=(e,t,n,r)=>{it(e,t,n,r,"Transforms cannot be represented in JSON Schema")},Zb=(e,t,n,r)=>{it(e,t,n,r,"Map cannot be represented in JSON Schema")},Bb=(e,t,n,r)=>{it(e,t,n,r,"Set cannot be represented in JSON Schema")},Hb=(e,t,n,r)=>{const i=n,o=e._zod.def,{minimum:s,maximum:a}=rt(e);typeof s=="number"&&(i.minItems=s),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=Fe(o.element,t,{...r,path:[...r.path,"items"]})};function bi(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?bi(t.out):t.type==="catch"?bi(t.innerType):e._zod.optin}const Vb=(e,t,n,r)=>{const i=n,o=e._zod.def,s=o.shape;if(Object.getOwnPropertySymbols(s).length&&it(e,t,i,r,"Symbol keys cannot be represented in JSON Schema"))return;i.type="object",i.properties={};for(const c in s)Nt(i.properties,c,Fe(s[c],t,{...r,path:[...r.path,"properties",c]}));const u=[];for(const c of Object.keys(s)){const l=o.shape[c];(t.io==="input"?bi(l)===void 0:l._zod.optout===void 0)&&u.push(c)}u.length>0&&(i.required=u),o.catchall?._zod.def.type==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=Fe(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},od=(e,t,n,r)=>{const i=e._zod.def,o=i.inclusive===!1,s=i.options.map((a,u)=>Fe(a,t,{...r,path:[...r.path,o?"oneOf":"anyOf",u]}));o?n.oneOf=s:n.anyOf=s},qb=(e,t,n,r)=>{const i=e._zod.def,o=Fe(i.left,t,{...r,path:[...r.path,"allOf",0]}),s=Fe(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1,u=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]];n.allOf=u,t.intersections.push(u)},Wb=(e,t,n,r)=>{const i=n,o=e._zod.def;i.type="array";const s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",u=o.items.map((m,y)=>Fe(m,t,{...r,path:[...r.path,s,y]})),c=o.rest?Fe(o.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null;let l=o.items.length;for(;l>0;){const m=o.items[l-1];if(!(t.io==="input"?bi(m)!==void 0:m._zod.optout==="optional"))break;l--}const d=o.items.length,f=!o.rest;t.target==="draft-2020-12"?(i.prefixItems=u,f?i.items=!1:c&&(i.items=c),l>0&&(i.minItems=l),f&&(i.maxItems=d)):t.target==="openapi-3.0"?(i.items={anyOf:u},c&&i.items.anyOf.push(c),l>0&&(i.minItems=l),f&&(i.maxItems=d)):(i.items=u,f?i.additionalItems=!1:c&&(i.additionalItems=c),l>0&&(i.minItems=l),f&&(i.maxItems=d));const{minimum:h,maximum:p}=rt(e);typeof h=="number"&&(i.minItems=h),typeof p=="number"&&(i.maxItems=p)};function nc(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);const p=e.get(t)?.def;if(!p)return t;const m=nc(e,p,n);return m===p?t:m}for(const p of["anyOf","oneOf"]){const m=t[p];if(!Array.isArray(m))continue;const y=m.map(b=>nc(e,b,n));y.some((b,g)=>b!==m[g])&&(t={...t,[p]:y})}const r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes("string")&&r.some(p=>p==="number"||p==="integer"),o=t.enum??(t.const!==void 0?[t.const]:void 0);if(!i&&!o?.some(p=>typeof p=="number"))return t;const{minimum:s,maximum:a,exclusiveMinimum:u,exclusiveMaximum:c,multipleOf:l,format:d,id:f,...h}=t;return h.enum?h.enum=h.enum.map(p=>typeof p=="number"?String(p):p):typeof h.const=="number"&&(h.const=String(h.const)),i&&(h.type="string",o||(h.pattern=(r.includes("number")?Er:Qc).source)),h}const rc=new WeakMap;function Cx(e){const t=new Map;for(const r of e.seen.values())r.def&&!t.has(r.schema)&&t.set(r.schema,r);const n=new Map;for(const r of rc.get(e)??[]){const i=e.seen.get(r),o=(i?.def??i?.schema)?.propertyNames;if(!o||o===!0||n.has(o))continue;const s=nc(t,o,new Set);s!==o&&n.set(o,s)}if(n.size)for(const r of e.seen.values())for(const i of[r.schema,r.def]){const o=i&&n.get(i.propertyNames);o&&(i.propertyNames=o)}}const Kb=(e,t,n,r)=>{const i=n,o=e._zod.def;i.type="object";const s=o.keyType,a=rt(s).patterns;if(o.mode==="loose"&&a&&a.size>0){const l=Fe(o.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const d of a)Nt(i.patternProperties,_b(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){i.propertyNames=Fe(o.keyType,t,{...r,path:[...r.path,"propertyNames"]});let l=rc.get(t);l||(l=[],rc.set(t,l),t.deferred.push(()=>Cx(t))),l.push(e)}i.additionalProperties=Fe(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}const u=s._zod.values,c=t.io==="input"&&bi(o.valueType)!==void 0;if(u&&!o.partial&&!c){const l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(i.required=l.map(String))}},Jb=(e,t,n,r)=>{const i=e._zod.def,o=Fe(i.innerType,t,r),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},Yb=(e,t,n,r)=>{const i=e._zod.def;Fe(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},sd=Symbol();function Xb(e,t,n,r,i){let o=!1;const s=JSON.stringify(e,(a,u)=>typeof u!="bigint"?u:(o=!0,null));return o?(it(t,n,r,i,"BigInt defaults cannot be represented in JSON Schema"),sd):JSON.parse(s)}const Qb=(e,t,n,r)=>{const i=e._zod.def;Fe(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType;const s=Xb(i.defaultValue,e,t,n,r);s!==sd&&(n.default=s)},ew=(e,t,n,r)=>{const i=e._zod.def;Fe(i.innerType,t,r);const o=t.seen.get(e);if(o.ref=i.innerType,t.io!=="input")return;const s=Xb(i.defaultValue,e,t,n,r);s!==sd&&(n._prefault=s)},tw=(e,t,n,r)=>{const i=e._zod.def;Fe(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType;let s;try{s=i.catchValue(void 0)}catch{it(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},nw=(e,t,n,r)=>{const i=e._zod.def,o=i.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?o?i.out:i.in:i.out;Fe(s,t,r);const a=t.seen.get(e);a.ref=s},rw=(e,t,n,r)=>{const i=e._zod.def;Fe(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType,n.readOnly=!0},iw=(e,t,n,r)=>{const i=e._zod.def;Fe(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},ad=(e,t,n,r)=>{const i=e._zod.def;Fe(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},ow=(e,t,n,r)=>{const i=e._zod.innerType;Fe(i,t,r);const o=t.seen.get(e);o.ref=i},ic={string:kb,number:Sb,boolean:xb,bigint:Eb,symbol:$b,null:Tb,undefined:Cb,void:Ab,never:Ib,any:Nb,unknown:Rb,date:Lb,enum:zb,literal:Pb,nan:Db,template_literal:Ob,file:Mb,success:Fb,custom:Ub,function:Gb,transform:jb,map:Zb,set:Bb,array:Hb,object:Vb,union:od,intersection:qb,tuple:Wb,record:Kb,nullable:Jb,nonoptional:Yb,default:Qb,prefault:ew,catch:tw,pipe:nw,readonly:rw,promise:iw,optional:ad,lazy:ow};function ud(e,t){if("_idmap"in e){const r=e,i=hr({...t,processors:ic}),o={};for(const u of r._idmap.entries()){const[c,l]=u;Fe(l,i)}const s={},a={registry:r,uri:t?.uri,defs:o};i.external=a;for(const u of r._idmap.entries()){const[c,l]=u;pr(i,l),Nt(s,c,mr(i,l))}if(Object.keys(o).length>0){const u=i.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[u]:o}}return{schemas:s}}const n=hr({...t,processors:ic});return Fe(e,n),pr(n,e),mr(n,e)}class Ax{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let n=t?.target??"draft-2020-12";n==="draft-4"&&(n="draft-04"),n==="draft-7"&&(n="draft-07"),this.ctx=hr({processors:ic,target:n,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,n={path:[],schemaPath:[]}){return Fe(t,this.ctx,n)}emit(t,n){n&&(n.cycles&&(this.ctx.cycles=n.cycles),n.reused&&(this.ctx.reused=n.reused),n.external&&(this.ctx.external=n.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,pr(this.ctx,t);const r=mr(this.ctx,t),{"~standard":i,...o}=r;return o}}const Ix=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),sw=Object.freeze(Object.defineProperty({__proto__:null,$ZodAny:Zy,$ZodArray:Wy,$ZodAsyncError:an,$ZodBase64:Ny,$ZodBase64URL:Ry,$ZodBigInt:bl,$ZodBigIntFormat:Fy,$ZodBoolean:vl,$ZodCIDRv4:Ay,$ZodCIDRv6:Iy,$ZodCUID:yy,$ZodCUID2:vy,$ZodCatch:gv,$ZodCheck:Ve,$ZodCheckBigIntFormat:Hg,$ZodCheckEndsWith:ry,$ZodCheckGreaterThan:rl,$ZodCheckIncludes:ty,$ZodCheckLengthEquals:Yg,$ZodCheckLessThan:nl,$ZodCheckLowerCase:Qg,$ZodCheckMaxLength:Kg,$ZodCheckMaxSize:Vg,$ZodCheckMimeType:sy,$ZodCheckMinLength:Jg,$ZodCheckMinSize:qg,$ZodCheckMultipleOf:Zg,$ZodCheckNumberFormat:Bg,$ZodCheckOverwrite:ay,$ZodCheckProperties:oy,$ZodCheckProperty:iy,$ZodCheckRegex:Xg,$ZodCheckSizeEquals:Wg,$ZodCheckStartsWith:ny,$ZodCheckStringFormat:Fi,$ZodCheckUpperCase:ey,$ZodCodec:xl,$ZodCreditCard:zy,$ZodCustom:Sv,$ZodCustomStringFormat:Oy,$ZodCyclicError:xv,$ZodDate:qy,$ZodDefault:fv,$ZodDiscriminatedUnion:tv,$ZodE164:Ly,$ZodEmail:fy,$ZodEmoji:my,$ZodEncodeError:Fs,$ZodEnum:sv,$ZodError:rg,$ZodExactOptional:lv,$ZodFile:uv,$ZodFunction:_v,$ZodGUID:ly,$ZodIBAN:Py,$ZodIPv4:$y,$ZodIPv6:Ty,$ZodISODate:Sy,$ZodISODateTime:ky,$ZodISODuration:Ey,$ZodISOTime:xy,$ZodIntersection:nv,$ZodJWT:Dy,$ZodKSUID:_y,$ZodLazy:El,$ZodLiteral:av,$ZodMAC:Cy,$ZodMap:iv,$ZodNaN:yv,$ZodNanoID:gy,$ZodNever:Hy,$ZodNonOptional:pv,$ZodNull:jy,$ZodNullable:dv,$ZodNumber:yl,$ZodNumberFormat:My,$ZodObject:Yy,$ZodObjectJIT:Xy,$ZodOptional:kl,$ZodPipe:Sl,$ZodPrefault:hv,$ZodPreprocess:vv,$ZodPromise:kv,$ZodReadonly:bv,$ZodRealError:Rt,$ZodRecord:rv,$ZodRegistry:Tv,$ZodSet:ov,$ZodString:Ui,$ZodStringFormat:Ge,$ZodSuccess:mv,$ZodSymbol:Uy,$ZodTemplateLiteral:wv,$ZodTransform:cv,$ZodTuple:_l,$ZodType:be,$ZodULID:by,$ZodURL:py,$ZodUUID:dy,$ZodUndefined:Gy,$ZodUnion:Ks,$ZodUnknown:By,$ZodVoid:Vy,$ZodXID:wy,$ZodXor:Qy,$brand:Fc,$constructor:S,$input:Il,$output:Al,Doc:il,INVALID:kt,JSONSchema:Ix,JSONSchemaGenerator:Ax,NEVER:Mc,TimePrecision:ed,URL_BAD_FORMAT:sl,URL_UNPARSEABLE:gi,ZodCompileAsyncError:hn,ZodCompileUnsupportedError:Ne,_any:Xv,_array:ob,_base64:Jl,_base64url:Yl,_bigint:Hv,_boolean:Zv,_catch:vx,_check:lb,_cidrv4:Wl,_cidrv6:Kl,_coercedBigint:Vv,_coercedBoolean:Bv,_coercedDate:rb,_coercedNumber:Ov,_coercedString:Rv,_creditCard:zv,_cuid:Gl,_cuid2:jl,_custom:ab,_date:nb,_decode:Zc,_decodeAsync:Hc,_default:mx,_discriminatedUnion:rx,_e164:Xl,_email:Ll,_emoji:Fl,_encode:jc,_encodeAsync:Bc,_endsWith:Vi,_enum:cx,_file:sb,_float32:Fv,_float64:Uv,_gt:mn,_gte:It,_guid:zl,_iban:Pv,_includes:Bi,_int:Mv,_int32:Gv,_int64:qv,_intersection:ix,_ipv4:Vl,_ipv6:ql,_isoDate:nd,_isoDateTime:td,_isoDuration:id,_isoTime:rd,_jwt:Ql,_ksuid:Hl,_lazy:kx,_length:Cr,_literal:dx,_lowercase:ji,_lt:pn,_lte:At,_mac:Lv,_map:ax,_max:At,_maxLength:Tr,_maxSize:er,_mime:Wi,_min:It,_minLength:Nn,_minSize:gn,_multipleOf:Jn,_nan:ib,_nanoid:Ul,_nativeEnum:lx,_negative:ra,_never:eb,_nonnegative:oa,_nonoptional:gx,_nonpositive:ia,_normalize:Ki,_null:Yv,_nullable:px,_number:Dv,_optional:hx,_overwrite:nn,_parse:Li,_parseAsync:zi,_pipe:bx,_positive:na,_promise:Sx,_properties:qi,_property:sa,_readonly:wx,_record:sx,_refine:ub,_regex:Gi,_safeDecode:qc,_safeDecodeAsync:Kc,_safeEncode:Vc,_safeEncodeAsync:Wc,_safeParse:Pi,_safeParseAsync:Di,_set:ux,_size:$r,_slugify:Qi,_startsWith:Hi,_string:Nv,_stringFormat:Ar,_stringbool:hb,_success:yx,_superRefine:cb,_symbol:Kv,_templateLiteral:_x,_toLowerCase:Yi,_toUpperCase:Xi,_transform:fx,_trim:Ji,_tuple:ox,_uint32:jv,_uint64:Wv,_ulid:Zl,_undefined:Jv,_union:tx,_unknown:Qv,_uppercase:Zi,_url:ta,_uuid:Pl,_uuidv4:Dl,_uuidv6:Ol,_uuidv7:Ml,_void:tb,_xid:Bl,_xor:nx,base64Charset:fl,base64urlCharset:Ws,canParseURL:al,clone:He,compile:Nl,compileFn:Qs,config:et,createStandardJSONSchemaMethod:vi,createToJSONSchemaMethod:gb,decode:hS,decodeAsync:mS,describe:db,encode:fS,encodeAsync:pS,extractDefs:pr,finalize:mr,flattenError:Us,formatError:Gs,getDiscriminatedOption:wl,globalConfig:_t,globalRegistry:Tt,handleUnrepresentable:it,initializeContext:hr,isBackEdge:Tl,isRecursiveSchema:$l,isValidBase64:qs,isValidBase64URL:hl,isValidCIDRv6:dl,isValidCreditCard:pl,isValidIBAN:ml,isValidIPv6:Vs,isValidJWT:gl,locales:Cl,memoizer:Js,mergeValues:yi,meta:fb,parse:Wu,parseAsync:Ku,parseURLObject:hy,prettifyError:Gc,process:Fe,processSchema:Fe,regexes:Hs,registry:Ys,safeDecode:yS,safeDecodeAsync:bS,safeEncode:gS,safeEncodeAsync:vS,safeParse:og,safeParseAsync:uS,standardProps:ol,stripTabAndNewline:ys,toDotPath:ig,toJSONSchema:ud,toZod:Ls,treeifyError:Uc,urlHostnameOk:cl,urlProtocolOk:ll,util:Oc,validate:Zs,validateAsync:Bs,validateURL:ul,version:uy,withParser:Xs},Symbol.toStringTag,{value:"Module"})),ap=Symbol("z.visit/resolving");function cd(e,t){const n=typeof t=="function"?t:(s,a)=>{const u=t[s._zod.def.type];return u?u(s,a):s},r=new Map;function i(s){const a=r.get(s);if(a===ap)return new El({type:"lazy",getter:()=>r.get(s)});if(a!==void 0)return a;r.set(s,ap);const u=o(s),c=n(u,u!==s);return r.set(s,c),c}function o(s){const a=s._zod.def;switch(a.type){case"object":{const c=a.shape,l=Object.keys(c);let d=!1;const f={};for(const p of l){const m=i(c[p]);m!==c[p]&&(d=!0),f[p]=m}let h=a.catchall;return a.catchall&&(h=i(a.catchall),h!==a.catchall&&(d=!0)),d?He(s,{...a,shape:f,catchall:h}):s}case"array":{const c=i(a.element);return c===a.element?s:He(s,{...a,element:c})}case"tuple":{const c=a.items;let l=!1;const d=[];for(const h of c){const p=i(h);p!==h&&(l=!0),d.push(p)}let f=a.rest;return a.rest&&(f=i(a.rest),f!==a.rest&&(l=!0)),l?He(s,{...a,items:d,rest:f}):s}case"record":case"map":{const c=i(a.keyType),l=i(a.valueType);return c===a.keyType&&l===a.valueType?s:He(s,{...a,keyType:c,valueType:l})}case"set":{const c=i(a.valueType);return c===a.valueType?s:He(s,{...a,valueType:c})}case"union":{const c=a.options;let l=!1;const d=[];for(const f of c){const h=i(f);h!==f&&(l=!0),d.push(h)}return l?He(s,{...a,options:d}):s}case"intersection":{const c=i(a.left),l=i(a.right);return c===a.left&&l===a.right?s:He(s,{...a,left:c,right:l})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{const c=i(a.innerType);return c===a.innerType?s:He(s,{...a,innerType:c})}case"pipe":{const c=i(a.in),l=i(a.out);return c===a.in&&l===a.out?s:He(s,{...a,in:c,out:l})}case"function":{const c=i(a.input),l=i(a.output);return c===a.input&&l===a.output?s:He(s,{...a,input:c,output:l})}case"lazy":{const c=a.getter,{_cachedInner:l,...d}=a;return He(s,{...d,getter:()=>i(c())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return s;default:return s}}return i(e)}function ld(e){return!!e._zod}function aw(e,t){return ld(e)?og(e,t):e.safeParse(t)}function Nx(e){if(!e)return;let t;if(ld(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Rx(e){if(ld(e)){const o=e._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}const n=e._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}const r=e.value;if(r!==void 0)return r}const Lx=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(o){return e[o]??null}const n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function i(o,s){return o==="number"&&typeof s=="number"&&!Number.isFinite(s)?String(s):r[o]??o}return o=>{switch(o.code){case"invalid_type":{const s=i(o.expected),a=Ym(o.input),u=i(a,o.input);return`Invalid input: expected ${s}, received ${u}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${Rc(o.values[0])}`:`Invalid option: expected one of ${Hu(o.values,"|")}`;case"too_big":{const s=o.exact?"exactly ":o.inclusive?"<=":"<",a=t(o.origin);return a?`Too big: expected ${o.origin??"value"} to have ${s}${o.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${s}${o.maximum.toString()}`}case"too_small":{const s=o.exact?"exactly ":o.inclusive?">=":">",a=t(o.origin);return a?`Too small: expected ${o.origin} to have ${s}${o.minimum.toString()} ${a.unit}`:`Too small: expected ${o.origin} to be ${s}${o.minimum.toString()}`}case"invalid_format":{const s=o;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${n[s.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${Hu(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(a=>`'${a}'`).join(" | ")}`:o.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function zx(){return{localeError:Lx()}}const Px=Object.freeze(Object.defineProperty({__proto__:null,endsWith:Vi,gt:mn,gte:It,includes:Bi,length:Cr,lowercase:ji,lt:pn,lte:At,maxLength:Tr,maxSize:er,mime:Wi,minLength:Nn,minSize:gn,multipleOf:Jn,negative:ra,nonnegative:oa,nonpositive:ia,normalize:Ki,overwrite:nn,positive:na,properties:qi,property:sa,regex:Gi,size:$r,slugify:Qi,startsWith:Hi,toLowerCase:Yi,toUpperCase:Xi,trim:Ji,uppercase:Zi},Symbol.toStringTag,{value:"Module"})),up=new WeakSet([Object.prototype,Error.prototype]);function Bo(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}const uw=(e,t)=>{rg.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);up.has(n)||(up.add(n),Bo(n,"format",r=>i=>Gs(r,i)),Bo(n,"flatten",r=>i=>Us(r,i)),Bo(n,"addIssue",r=>i=>{r.issues.push(i),r.message=JSON.stringify(r.issues,hs,2)}),Bo(n,"addIssues",r=>i=>{r.issues.push(...i),r.message=JSON.stringify(r.issues,hs,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},cw=S("ZodError",uw),$t=S("ZodError",uw,void 0,{Parent:Error}),dd=Li($t),fd=zi($t),hd=Pi($t),pd=Di($t),md=jc($t),gd=Zc($t),yd=Bc($t),vd=Hc($t),bd=Vc($t),wd=qc($t),_d=Wc($t),kd=Kc($t);function Dx(){_t.localeError||et(zx())}function tr(){_t.memoizer||et({memoizer:Js()})}const _e=S("ZodType",(e,t)=>(Dx(),be.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(ht(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return He(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Wa(e,t))},superRefine(e,t){return this.check(Ka(e,t))},overwrite(e){return this.check(nn(e))},optional(){return Be(this)},exactOptional(){return Ca(this)},nullable(){return br(this)},nullish(){return Be(br(this))},nonoptional(e){return za(this,e)},array(){return le(this)},or(e){return xe([this,e])},and(e){return Gr(this,e)},transform(e){return _i(this,xo(e))},default(e){return Na(this,e)},prefault(e){return La(this,e)},catch(e){return Oa(this,e)},pipe(e){return _i(this,e)},readonly(){return Ga(this)},describe(e){const t=this.clone();return Tt.add(t,{description:e}),t},meta(...e){if(e.length===0)return Tt.get(this);const t=this.clone();return Tt.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Ms(this,"~standard",{...ol(this),jsonSchema:{input:vi(this,"input"),output:vi(this,"output")}})},set"~standard"(e){fn(this,"~standard",e)},parse:function e(t,n){return dd(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await fd(this,t,n,{callee:e})},safeParse(e,t){return hd(this,e,t)},async safeParseAsync(e,t){return pd(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){fn(this,"spa",e)},validate(e,t){return Zs(this,e,t)},validateAsync(e,t){return Bs(this,e,t)},encode:function e(t,n){return md(this,t,n,{callee:e})},decode:function e(t,n){return gd(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await yd(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await vd(this,t,n,{callee:e})},safeEncode(e,t){return bd(this,e,t)},safeDecode(e,t){return wd(this,e,t)},async safeEncodeAsync(e,t){return _d(this,e,t)},async safeDecodeAsync(e,t){return kd(this,e,t)},toJSONSchema(e){return gb(this,{})(e)},get description(){return Tt.get(this)?.description},get _def(){return this._zod.def}}),eo=S("_ZodString",(e,t)=>{Ui.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>kb(e,n,r)},Ri({format:e=>rt(e).format??null,minLength:e=>rt(e).minimum??null,maxLength:e=>rt(e).maximum??null},{regex(...e){return this.check(Gi(...e))},includes(...e){return this.check(Bi(...e))},startsWith(...e){return this.check(Hi(...e))},endsWith(...e){return this.check(Vi(...e))},min(...e){return this.check(Nn(...e))},max(...e){return this.check(Tr(...e))},length(...e){return this.check(Cr(...e))},nonempty(...e){return this.check(Nn(1,...e))},lowercase(e){return this.check(ji(e))},uppercase(e){return this.check(Zi(e))},trim(){return this.check(Ji())},normalize(...e){return this.check(Ki(...e))},toLowerCase(){return this.check(Yi())},toUpperCase(){return this.check(Xi())},slugify(){return this.check(Qi())}})),Ir=S("ZodString",(e,t)=>{Ui.init(e,t),eo.init(e,t)},{email(e){return this.check(Ll(to,e))},url(e){return this.check(ta(Pr,e))},jwt(e){return this.check(Ql(vo,e))},emoji(e){return this.check(Fl(ro,e))},guid(e){return this.check(zl(no,e))},uuid(e){return this.check(Pl(Xt,e))},uuidv4(e){return this.check(Dl(Xt,e))},uuidv6(e){return this.check(Ol(Xt,e))},uuidv7(e){return this.check(Ml(Xt,e))},nanoid(e){return this.check(Ul(io,e))},cuid(e){return this.check(Gl(oo,e))},cuid2(e){return this.check(jl(so,e))},ulid(e){return this.check(Zl(ao,e))},base64(e){return this.check(Jl(mo,e))},base64url(e){return this.check(Yl(go,e))},xid(e){return this.check(Bl(uo,e))},ksuid(e){return this.check(Hl(co,e))},ipv4(e){return this.check(Vl(lo,e))},ipv6(e){return this.check(ql(fo,e))},cidrv4(e){return this.check(Wl(ho,e))},cidrv6(e){return this.check(Kl(po,e))},e164(e){return this.check(Xl(yo,e))},datetime(e){return this.check(td(Nr,e))},date(e){return this.check(nd(Rr,e))},time(e){return this.check(rd(Lr,e))},duration(e){return this.check(id(zr,e))}});function E(e){return Nv(Ir,e)}const De=S("ZodStringFormat",(e,t)=>{Ge.init(e,t),eo.init(e,t)}),Nr=S("ZodISODateTime",(e,t)=>{ky.init(e,t),De.init(e,t)}),Rr=S("ZodISODate",(e,t)=>{Sy.init(e,t),De.init(e,t)}),Lr=S("ZodISOTime",(e,t)=>{xy.init(e,t),De.init(e,t)}),zr=S("ZodISODuration",(e,t)=>{Ey.init(e,t),De.init(e,t)}),to=S("ZodEmail",(e,t)=>{fy.init(e,t),De.init(e,t)});function Sd(e){return Ll(to,e)}const no=S("ZodGUID",(e,t)=>{ly.init(e,t),De.init(e,t)});function xd(e){return zl(no,e)}const Xt=S("ZodUUID",(e,t)=>{dy.init(e,t),De.init(e,t)});function Ed(e){return Pl(Xt,e)}function $d(e){return Dl(Xt,e)}function Td(e){return Ol(Xt,e)}function Cd(e){return Ml(Xt,e)}const Pr=S("ZodURL",(e,t)=>{py.init(e,t),De.init(e,t)});function Ad(e){return ta(Pr,e)}function Id(e){return ta(Pr,{protocol:Jc,hostname:Tg,...R(e)})}const ro=S("ZodEmoji",(e,t)=>{my.init(e,t),De.init(e,t)});function Nd(e){return Fl(ro,e)}const io=S("ZodNanoID",(e,t)=>{gy.init(e,t),De.init(e,t)});function Rd(e){return Ul(io,e)}const oo=S("ZodCUID",(e,t)=>{yy.init(e,t),De.init(e,t)});function Ld(e){return Gl(oo,e)}const so=S("ZodCUID2",(e,t)=>{vy.init(e,t),De.init(e,t)});function zd(e){return jl(so,e)}const ao=S("ZodULID",(e,t)=>{by.init(e,t),De.init(e,t)});function Pd(e){return Zl(ao,e)}const uo=S("ZodXID",(e,t)=>{wy.init(e,t),De.init(e,t)});function Dd(e){return Bl(uo,e)}const co=S("ZodKSUID",(e,t)=>{_y.init(e,t),De.init(e,t)});function Od(e){return Hl(co,e)}const lo=S("ZodIPv4",(e,t)=>{$y.init(e,t),De.init(e,t)});function Md(e){return Vl(lo,e)}const aa=S("ZodMAC",(e,t)=>{Cy.init(e,t),De.init(e,t)});function Fd(e){return Lv(aa,e)}const fo=S("ZodIPv6",(e,t)=>{Ty.init(e,t),De.init(e,t)});function Ud(e){return ql(fo,e)}const ho=S("ZodCIDRv4",(e,t)=>{Ay.init(e,t),De.init(e,t)});function Gd(e){return Wl(ho,e)}const po=S("ZodCIDRv6",(e,t)=>{Iy.init(e,t),De.init(e,t)});function jd(e){return Kl(po,e)}const mo=S("ZodBase64",(e,t)=>{Ny.init(e,t),De.init(e,t)});function Zd(e){return Jl(mo,e)}const go=S("ZodBase64URL",(e,t)=>{Ry.init(e,t),De.init(e,t)});function Bd(e){return Yl(go,e)}const yo=S("ZodE164",(e,t)=>{Ly.init(e,t),De.init(e,t)});function Hd(e){return Xl(yo,e)}const ua=S("ZodCreditCard",(e,t)=>{zy.init(e,t),De.init(e,t)});function Vd(e){return zv(ua,e)}const ca=S("ZodIBAN",(e,t)=>{Py.init(e,t),De.init(e,t)});function qd(e){return Pv(ca,e)}const vo=S("ZodJWT",(e,t)=>{Dy.init(e,t),De.init(e,t)});function Wd(e){return Ql(vo,e)}const Ln=S("ZodCustomStringFormat",(e,t)=>{Oy.init(e,t),De.init(e,t)});function Kd(e,t,n={}){return Ar(Ln,e,t,n)}function Jd(e){return Ar(Ln,"hostname",$g,e)}function Yd(e){return Ar(Ln,"hex",jg,e)}function Xd(e){return Ar(Ln,"currency_code",Ag,e)}function Qd(e,t){const n=t?.enc??"hex",r=`${e}_${n}`,i=Hs[r];if(!i)throw new Error(`Unrecognized hash format: ${r}`);return Ar(Ln,r,i,t)}const Dr=S("ZodNumber",(e,t)=>{yl.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Sb(e,n,r,i),e.isFinite=!0},Ri({minValue:e=>{const{minimum:t,exclusiveMinimum:n}=rt(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{const{maximum:t,exclusiveMaximum:n}=rt(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{const{isInt:t,multipleOf:n}=rt(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>rt(e).format??null},{gt(e,t){return this.check(mn(e,t))},gte(e,t){return this.check(It(e,t))},min(e,t){return this.check(It(e,t))},lt(e,t){return this.check(pn(e,t))},lte(e,t){return this.check(At(e,t))},max(e,t){return this.check(At(e,t))},int(e){return this.check(wi(e))},safe(e){return this.check(wi(e))},positive(e){return this.check(mn(0,e))},nonnegative(e){return this.check(It(0,e))},negative(e){return this.check(pn(0,e))},nonpositive(e){return this.check(At(0,e))},multipleOf(e,t){return this.check(Jn(e,t))},step(e,t){return this.check(Jn(e,t))},finite(){return this}}));function we(e){return Dv(Dr,e)}const zn=S("ZodNumberFormat",(e,t)=>{My.init(e,t),Dr.init(e,t)});function wi(e){return Mv(zn,e)}function ef(e){return Fv(zn,e)}function tf(e){return Uv(zn,e)}function nf(e){return Gv(zn,e)}function rf(e){return jv(zn,e)}const Or=S("ZodBoolean",(e,t)=>{vl.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>xb(e,n,r)});function Pe(e){return Zv(Or,e)}const Mr=S("ZodBigInt",(e,t)=>{bl.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Eb(e,n,r,i)},Ri({minValue:e=>rt(e).minimum??null,maxValue:e=>rt(e).maximum??null,format:e=>rt(e).format??null},{gte(e,t){return this.check(It(e,t))},min(e,t){return this.check(It(e,t))},gt(e,t){return this.check(mn(e,t))},lt(e,t){return this.check(pn(e,t))},lte(e,t){return this.check(At(e,t))},max(e,t){return this.check(At(e,t))},positive(e){return this.check(mn(BigInt(0),e))},negative(e){return this.check(pn(BigInt(0),e))},nonpositive(e){return this.check(At(BigInt(0),e))},nonnegative(e){return this.check(It(BigInt(0),e))},multipleOf(e,t){return this.check(Jn(e,t))}}));function of(e){return Hv(Mr,e)}const bo=S("ZodBigIntFormat",(e,t)=>{Fy.init(e,t),Mr.init(e,t)});function sf(e){return qv(bo,e)}function af(e){return Wv(bo,e)}const la=S("ZodSymbol",(e,t)=>{Uy.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>$b(e,n,r,i)});function uf(e){return Kv(la,e)}const da=S("ZodUndefined",(e,t)=>{Gy.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Cb(e,n,r,i)});function vr(e){return Jv(da,e)}const fa=S("ZodNull",(e,t)=>{jy.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Tb(e,n,r)});function wo(e){return Yv(fa,e)}const ha=S("ZodAny",(e,t)=>{Zy.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Nb()});function _o(){return Xv(ha)}const pa=S("ZodUnknown",(e,t)=>{By.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Rb()});function Le(){return Qv(pa)}const ma=S("ZodNever",(e,t)=>{Hy.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ib(e,n,r)});function Yn(e){return eb(ma,e)}const ga=S("ZodVoid",(e,t)=>{Vy.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ab(e,n,r,i)});function cf(e){return tb(ga,e)}const ko=S("ZodDate",(e,t)=>{qy.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Lb(e,n,r,i),e.min=(n,r)=>e.check(It(n,r)),e.max=(n,r)=>e.check(At(n,r))},Ri({minDate:e=>{const{minimum:t}=rt(e);return t?new Date(t):null},maxDate:e=>{const{maximum:t}=rt(e);return t?new Date(t):null}},{}));function lf(e){return nb(ko,e)}const ya=S("ZodArray",(e,t)=>{tr(),Wy.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Hb(e,n,r,i),e.element=t.element},{min(e,t){return this.check(Nn(e,t))},nonempty(e){return this.check(Nn(1,e))},max(e,t){return this.check(Tr(e,t))},length(e,t){return this.check(Cr(e,t))},unwrap(){return this.element}});function le(e,t){return ob(ya,e,t)}function df(e){const t=e._zod.def.shape;return ut(Object.keys(t))}const Fr=S("ZodObject",(e,t)=>{tr(),Xy.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Vb(e,n,r,i),tg(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return ut(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ht(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ht(this._zod.def,{catchall:Le()}))},loose(){return this.clone(ht(this._zod.def,{catchall:Le()}))},strict(){return this.clone(ht(this._zod.def,{catchall:Yn()}))},strip(){return this.clone(ht(this._zod.def,{catchall:void 0}))},extend(e){return Hm(this,e)},safeExtend(e){return qm(this,e)},merge(e){return Wm(this,e)},pick(e){return Zm(this,e)},omit(e){return Bm(this,e)},partial(...e){return Vu(jr,this,e[0])},exactPartial(...e){return Vu(Eo,this,e[0],"exactPartial")},required(...e){return Km($o,this,e[0])}});function C(e,t){const n={type:"object",shape:e??{},...R(t)};return new Fr(n)}function ff(e,t){return new Fr({type:"object",shape:e,catchall:Yn(),...R(t)})}function at(e,t){return new Fr({type:"object",shape:e,catchall:Le(),...R(t)})}const Ur=S("ZodUnion",(e,t)=>{Ks.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>od(e,n,r,i),e.options=t.options});function xe(e,t){return new Ur({type:"union",options:e,...R(t)})}const va=S("ZodXor",(e,t)=>{Ur.init(e,t),Qy.init(e,t),e._zod.processJSONSchema=(n,r,i)=>od(e,n,r,i),e.options=t.options});function hf(e,t){return new va({type:"union",options:e,inclusive:!1,...R(t)})}const ba=S("ZodDiscriminatedUnion",(e,t)=>{Ur.init(e,t),tv.init(e,t)});function So(e,t,n){return new ba({type:"union",options:t,discriminator:e,...R(n)})}const wa=S("ZodIntersection",(e,t)=>{nv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>qb(e,n,r,i)});function Gr(e,t){return new wa({type:"intersection",left:e,right:t})}const _a=S("ZodTuple",(e,t)=>{tr(),_l.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Wb(e,n,r,i)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){const e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new jr({type:"optional",innerType:t}))})}});function ka(e,t,n){const r=t instanceof be,i=r?n:t,o=r?t:null;return new _a({type:"tuple",items:e,rest:o,...R(i)})}const Xn=S("ZodRecord",(e,t)=>{tr(),rv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Kb(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function Ce(e,t,n){return!t||!t._zod?new Xn({type:"record",keyType:E(),valueType:e,...R(t)}):new Xn({type:"record",keyType:e,valueType:t,...R(n)})}function pf(e,t,n){return new Xn({type:"record",keyType:e,valueType:t,...R(n),partial:!0})}function mf(e,t,n){return new Xn({type:"record",keyType:e,valueType:t,mode:"loose",...R(n)})}const Sa=S("ZodMap",(e,t)=>{tr(),iv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Zb(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(gn(...n)),e.nonempty=n=>e.check(gn(1,n)),e.max=(...n)=>e.check(er(...n)),e.size=(...n)=>e.check($r(...n))});function gf(e,t,n){return new Sa({type:"map",keyType:e,valueType:t,...R(n)})}const xa=S("ZodSet",(e,t)=>{tr(),ov.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Bb(e,n,r,i),e.min=(...n)=>e.check(gn(...n)),e.nonempty=n=>e.check(gn(1,n)),e.max=(...n)=>e.check(er(...n)),e.size=(...n)=>e.check($r(...n))});function yf(e,t){return new xa({type:"set",valueType:e,...R(t)})}const Qn=S("ZodEnum",(e,t)=>{sv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(r,i,o)=>zb(e,r,i),e.enum=t.entries,e.options=[...e._zod.values];const n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{const o={};for(const s of r)if(n.has(s))o[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Qn({...t,checks:[],...R(i),entries:o})},e.exclude=(r,i)=>{const o={...t.entries};for(const s of r)if(n.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new Qn({...t,checks:[],...R(i),entries:o})}});function ut(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Qn({type:"enum",entries:n,...R(t)})}function vf(e,t){return new Qn({type:"enum",entries:e,...R(t)})}const Ea=S("ZodLiteral",(e,t)=>{av.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Pb(e,n,r,i),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $(e,t){return new Ea({type:"literal",values:Array.isArray(e)?e:[e],...R(t)})}const $a=S("ZodFile",(e,t)=>{uv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Mb(e,n,r),e.min=(n,r)=>e.check(gn(n,r)),e.max=(n,r)=>e.check(er(n,r)),e.mime=(n,r)=>e.check(Wi(Array.isArray(n)?n:[n],r))});function bf(e){return sb($a,e)}const Ta=S("ZodTransform",(e,t)=>{tr(),cv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>jb(e,n,r,i),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Fs(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(dr(o,n.value,t));else{const s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=e),n.issues.push(dr(s))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(o=>(n.value=o,n)):(n.value=i,n)}});function xo(e){return new Ta({type:"transform",transform:e})}const jr=S("ZodOptional",(e,t)=>{kl.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ad(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Be(e){return new jr({type:"optional",innerType:e})}const Eo=S("ZodExactOptional",(e,t)=>{lv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ad(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Ca(e){return new Eo({type:"optional",innerType:e})}const Aa=S("ZodNullable",(e,t)=>{dv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Jb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function br(e){return new Aa({type:"nullable",innerType:e})}function wf(e){return Be(br(e))}const Ia=S("ZodDefault",(e,t)=>{fv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Qb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Na(e,t){return new Ia({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Ii(t)}})}const Ra=S("ZodPrefault",(e,t)=>{hv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ew(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function La(e,t){return new Ra({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Ii(t)}})}const $o=S("ZodNonOptional",(e,t)=>{pv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Yb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function za(e,t){return new $o({type:"nonoptional",innerType:e,...R(t)})}const Pa=S("ZodSuccess",(e,t)=>{mv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Fb(e,n,r),e.unwrap=()=>e._zod.def.innerType});function _f(e){return new Pa({type:"success",innerType:e})}const Da=S("ZodCatch",(e,t)=>{gv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>tw(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Oa(e,t){return new Da({type:"catch",innerType:e,catchValue:typeof t=="function"?t:Dc(t)})}const Ma=S("ZodNaN",(e,t)=>{yv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Db(e,n,r,i)});function kf(e){return ib(Ma,e)}const Zr=S("ZodPipe",(e,t)=>{Sl.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nw(e,n,r,i),e.in=t.in,e.out=t.out});function _i(e,t){return new Zr({type:"pipe",in:e,out:t})}const Br=S("ZodCodec",(e,t)=>{Zr.init(e,t),xl.init(e,t)});function Sf(e,t,n){return new Br({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function xf(e){const t=e._zod.def;return new Br({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}const Fa=S("ZodPreprocess",(e,t)=>{Zr.init(e,t),vv.init(e,t)}),Ua=S("ZodReadonly",(e,t)=>{bv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rw(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Ga(e){return new Ua({type:"readonly",innerType:e})}const ja=S("ZodTemplateLiteral",(e,t)=>{wv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ob(e,n,r)});function Ef(e,t){return new ja({type:"template_literal",parts:e,...R(t)})}const Za=S("ZodLazy",(e,t)=>{El.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ow(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function Ba(e){return new Za({type:"lazy",getter:e})}const Ha=S("ZodPromise",(e,t)=>{kv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>iw(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function $f(e){return new Ha({type:"promise",innerType:e})}const Va=S("ZodFunction",(e,t)=>{_v.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Gb(e,n,r,i)});function wr(e){return new Va({type:"function",input:Array.isArray(e?.input)?ka(e?.input):e?.input??le(Le()),output:e?.output??Le()})}const Hr=S("ZodCustom",(e,t)=>{Sv.init(e,t),_e.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ub(e,n,r,i)});function Tf(e){const t=new Ve({check:"custom"});return t._zod.check=e,t}function qa(e,t){return ab(Hr,e??(()=>!0),t)}function Wa(e,t={}){return ub(Hr,e,t)}function Ka(e,t){return cb(e,t)}const Cf=db,Af=fb,Ja=S("ZodInstanceOf",(e,t)=>{Hr.init(e,t)},{properties(e,t){return this.check(qi(e,t))}});function If(e,t={}){const n=new Ja({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...R(t)});return n._zod.bag.Class=e,n._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}const Nf=(...e)=>hb({Codec:Br,Boolean:Or,String:Ir},...e);function Rf(e){const t=Ba(()=>xe([E(e),we(),Pe(),wo(),le(t),Ce(E(),t)]));return t}function To(e,t){return new Fa({type:"pipe",in:xo(e),out:t})}const Ox=Object.freeze(Object.defineProperty({__proto__:null,ZodAny:ha,ZodArray:ya,ZodBase64:mo,ZodBase64URL:go,ZodBigInt:Mr,ZodBigIntFormat:bo,ZodBoolean:Or,ZodCIDRv4:ho,ZodCIDRv6:po,ZodCUID:oo,ZodCUID2:so,ZodCatch:Da,ZodCodec:Br,ZodCreditCard:ua,ZodCustom:Hr,ZodCustomStringFormat:Ln,ZodDate:ko,ZodDefault:Ia,ZodDiscriminatedUnion:ba,ZodE164:yo,ZodEmail:to,ZodEmoji:ro,ZodEnum:Qn,ZodExactOptional:Eo,ZodFile:$a,ZodFunction:Va,ZodGUID:no,ZodIBAN:ca,ZodIPv4:lo,ZodIPv6:fo,ZodISODate:Rr,ZodISODateTime:Nr,ZodISODuration:zr,ZodISOTime:Lr,ZodInstanceOf:Ja,ZodIntersection:wa,ZodJWT:vo,ZodKSUID:co,ZodLazy:Za,ZodLiteral:Ea,ZodMAC:aa,ZodMap:Sa,ZodNaN:Ma,ZodNanoID:io,ZodNever:ma,ZodNonOptional:$o,ZodNull:fa,ZodNullable:Aa,ZodNumber:Dr,ZodNumberFormat:zn,ZodObject:Fr,ZodOptional:jr,ZodPipe:Zr,ZodPrefault:Ra,ZodPreprocess:Fa,ZodPromise:Ha,ZodReadonly:Ua,ZodRecord:Xn,ZodSet:xa,ZodString:Ir,ZodStringFormat:De,ZodSuccess:Pa,ZodSymbol:la,ZodTemplateLiteral:ja,ZodTransform:Ta,ZodTuple:_a,ZodType:_e,ZodULID:ao,ZodURL:Pr,ZodUUID:Xt,ZodUndefined:da,ZodUnion:Ur,ZodUnknown:pa,ZodVoid:ga,ZodXID:uo,ZodXor:va,_ZodString:eo,_default:Na,_function:wr,any:_o,array:le,base64:Zd,base64url:Bd,bigint:of,boolean:Pe,catch:Oa,check:Tf,cidrv4:Gd,cidrv6:jd,codec:Sf,creditCard:Vd,cuid:Ld,cuid2:zd,currencyCode:Xd,custom:qa,date:lf,describe:Cf,discriminatedUnion:So,e164:Hd,email:Sd,emoji:Nd,enum:ut,exactOptional:Ca,file:bf,float32:ef,float64:tf,function:wr,guid:xd,hash:Qd,hex:Yd,hostname:Jd,httpUrl:Id,iban:qd,instanceof:If,int:wi,int32:nf,int64:sf,intersection:Gr,invertCodec:xf,ipv4:Md,ipv6:Ud,json:Rf,jwt:Wd,keyof:df,ksuid:Od,lazy:Ba,literal:$,looseObject:at,looseRecord:mf,mac:Fd,map:gf,meta:Af,nan:kf,nanoid:Rd,nativeEnum:vf,never:Yn,nonoptional:za,null:wo,nullable:br,nullish:wf,number:we,object:C,optional:Be,partialRecord:pf,pipe:_i,prefault:La,preprocess:To,promise:$f,readonly:Ga,record:Ce,refine:Wa,set:yf,strictObject:ff,string:E,stringFormat:Kd,stringbool:Nf,success:_f,superRefine:Ka,symbol:uf,templateLiteral:Ef,transform:xo,tuple:ka,uint32:rf,uint64:af,ulid:Pd,undefined:vr,union:xe,unknown:Le,url:Ad,uuid:Ed,uuidv4:$d,uuidv6:Td,uuidv7:Cd,void:cf,xid:Dd,xor:hf},Symbol.toStringTag,{value:"Module"})),lw={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function dw(e){et({customError:e})}function fw(){return et().customError}var bs;bs||(bs={});function hw(e){return td(Nr,e)}function Mx(e){return nd(Rr,e)}function Fx(e){return rd(Lr,e)}function Ux(e){return id(zr,e)}const Lf=Object.freeze(Object.defineProperty({__proto__:null,ZodISODate:Rr,ZodISODateTime:Nr,ZodISODuration:zr,ZodISOTime:Lr,date:Mx,datetime:hw,duration:Ux,time:Fx},Symbol.toStringTag,{value:"Module"})),V={...Ox,...Px,iso:Lf},Gx=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function jx(e,t){const n=e.$schema;return n==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":n==="http://json-schema.org/draft-07/schema#"?"draft-7":n==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function cp(e,t){return e.map((n,r)=>r<t?n:n.optional())}function Zx(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Bx(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");const n=e.slice(1).split("/").filter(Boolean);if(n.length===0)return t.rootSchema;const r=t.version==="draft-2020-12"?"$defs":"definitions";if(n[0]===r){const i=n[1]===void 0?void 0:Zx(n[1]);if(!i||!t.defs[i])throw new Error(`Reference not found: ${e}`);return t.defs[i]}throw new Error(`Reference not found: ${e}`)}function Hx(e,t){return V.transform(r=>r).check(r=>{const i=r.value;if(typeof i!="object"||i===null||Array.isArray(i))return;const o=Object.getOwnPropertyNames(i);if(t.minProperties!==void 0&&o.length<t.minProperties&&r.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:i,inst:e,continue:!0}),t.maxProperties!==void 0&&o.length>t.maxProperties&&r.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:i,inst:e,continue:!0}),t.keySchema)for(const s of o){const a=t.keySchema.safeParse(s);a.success||r.issues.push({code:"invalid_key",origin:"record",issues:a.error.issues,input:s,path:[s],continue:!0})}}).pipe(e)}function oc(e,t){if(e===null)return"z";const n=typeof e;if(n!=="object"){if(n==="number"&&Number.isNaN(e))return null;const r=String(e);return`${n[0]}${r.length}:${r}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){const o=[];for(const s of e){const a=oc(s,t);if(a===null)return null;o.push(a)}return`a${o.length}:[${o.join(",")}]`}const r=Object.keys(e).sort(),i=[];for(const o of r){const s=oc(e[o],t);if(s===null)return null;i.push(`${o.length}:${o}=${s}`)}return`o${i.length}:{${i.join(",")}}`}finally{t.delete(e)}}const Vx=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),qx=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function li(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(li):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,n])=>Vx.has(t)?li(n):!qx.has(t)||typeof n!="object"||n===null?!1:Object.values(n).some(li))}function lp(e){return e===1?"element":"elements"}function Wx(e,t){return V.transform(r=>r).check(r=>{const i=r.value;if(Array.isArray(i)){if(t.uniqueItems===!0){const o=new Map;for(let s=0;s<i.length;s++){const a=oc(i[s],new Set);if(a===null)continue;const u=o.get(a);if(u===void 0){o.set(a,s);continue}r.issues.push({code:"custom",message:`Array items must be unique: element at index ${s} duplicates the one at index ${u}`,input:i,path:[s],continue:!0})}}if(t.containsSchema){const o=t.minContains??1,s=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY;let a=0;for(const u of i)if(t.containsSchema.safeParse(u).success&&++a>=s)break;a<o&&r.issues.push({code:"custom",message:`Array must contain at least ${o} matching ${lp(o)}; found ${a}`,input:i,continue:!0}),t.maxContains!==void 0&&a>t.maxContains&&r.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${lp(t.maxContains)}`,input:i,continue:!0})}}}).pipe(e)}function dp(e,t){if(e!==!1)return e===void 0||e===!0?V.any():wt(e,t)}const Kx=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function pw(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return V.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){const i=e.$ref;if(t.refs.has(i))return t.refs.get(i);if(t.processing.has(i))return V.lazy(()=>{if(!t.refs.has(i))throw new Error(`Circular reference not resolved: ${i}`);return t.refs.get(i)});t.processing.add(i);const o=Bx(i,t),s=wt(o,t);return t.refs.set(i,s),t.processing.delete(i),s}if(e.enum!==void 0){const i=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&i.length===1&&i[0]===null)return V.null();if(i.length===0)return V.never();if(i.length===1)return V.literal(i[0]);if(i.every(s=>typeof s=="string"))return V.enum(i);const o=i.map(s=>V.literal(s));return o.length<2?o[0]:V.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return V.literal(e.const);const n=e.type;if(Array.isArray(n)){const i=n.map(o=>{const s={...e,type:o};return pw(s,t)});return i.length===0?V.never():i.length===1?i[0]:V.union(i)}if(!n)return V.any();let r;switch(n){case"string":{let i=V.string();if(e.format){const o=e.format;o==="email"?i=i.check(V.email()):o==="uri"||o==="uri-reference"?i=i.check(V.url()):o==="uuid"||o==="guid"?i=i.check(V.uuid()):o==="date-time"?i=i.check(V.iso.datetime({offset:!0})):o==="date"?i=i.check(V.iso.date()):o==="time"?i=i.check(V.regex(Kx)):o==="duration"?i=i.check(V.iso.duration()):o==="hostname"?i=i.check(V.hostname()):o==="ipv4"?i=i.check(V.ipv4()):o==="ipv6"?i=i.check(V.ipv6()):o==="mac"?i=i.check(V.mac()):o==="cidr"?i=i.check(V.cidrv4()):o==="cidr-v6"?i=i.check(V.cidrv6()):o==="base64"?i=i.check(V.base64()):o==="base64url"?i=i.check(V.base64url()):o==="e164"?i=i.check(V.e164()):o==="credit_card"?i=i.check(V.creditCard()):o==="iban"?i=i.check(V.iban()):o==="jwt"?i=i.check(V.jwt()):o==="emoji"?i=i.check(V.emoji()):o==="nanoid"?i=i.check(V.nanoid()):o==="cuid"?i=i.check(V.cuid()):o==="cuid2"?i=i.check(V.cuid2()):o==="ulid"?i=i.check(V.ulid()):o==="xid"?i=i.check(V.xid()):o==="ksuid"&&(i=i.check(V.ksuid()))}typeof e.minLength=="number"&&(i=i.min(e.minLength)),typeof e.maxLength=="number"&&(i=i.max(e.maxLength)),e.pattern&&(i=i.regex(new RegExp(e.pattern))),r=i;break}case"number":case"integer":{let i=n==="integer"?V.number().int():V.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(i=i.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(i=i.max(e.maximum)),typeof e.exclusiveMinimum=="number"?i=i.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(i=i.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?i=i.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(i=i.lt(e.maximum)),typeof e.multipleOf=="number"&&(i=i.multipleOf(e.multipleOf)),r=i;break}case"boolean":{r=V.boolean();break}case"null":{r=V.null();break}case"object":{const i={},o=e.properties||{},s=new Set(e.required||[]),a=typeof e.additionalProperties=="object"?wt(e.additionalProperties,t):void 0;for(const[d,f]of Object.entries(o)){const h=wt(f,t);Nt(i,d,s.has(d)?h:h.optional())}if(e.patternProperties){const d=e.patternProperties,f=Object.keys(d),h=[];for(const m of f){const y=wt(d[m],t),b=V.string().regex(new RegExp(m));h.push(V.looseRecord(b,y))}const p=[];if(Object.keys(i).length>0&&p.push(V.object(i).passthrough()),p.push(...h),p.length===0)r=V.object({}).passthrough();else if(p.length===1)r=p[0];else{let m=V.intersection(p[0],p[1]);for(let y=2;y<p.length;y++)m=V.intersection(m,p[y]);r=m}if(e.additionalProperties===!1){const m=Object.keys(i),y=f.map(g=>new RegExp(g)),b=r;r=r.check(g=>{if(!ln(g.value))return;const w=[];for(const v of Object.keys(g.value))m.includes(v)||y.some(_=>_.test(v))||w.push(v);w.length&&g.issues.push({code:"unrecognized_keys",keys:w,input:g.value,inst:b})})}}else{const d=V.object(i);e.additionalProperties===!1?r=d.strict():a?r=d.catchall(a):r=d.passthrough()}const u=e.propertyNames!==void 0&&e.propertyNames!==!0,c=typeof e.minProperties=="number"?e.minProperties:void 0,l=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(u||c!==void 0||l!==void 0){let d;if(u){const f=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;d=wt(f,t)}r=Hx(r,{keySchema:d,minProperties:c,maxProperties:l})}break}case"array":{const i=e.prefixItems,o=e.items;if(i&&Array.isArray(i)){const s=typeof e.minItems=="number"?e.minItems:0,a=i.map(d=>wt(d,t)),u=cp(a,s),c=Array.isArray(o)?void 0:dp(o,t),l=V.tuple(u);r=c?l.rest(c):l,typeof e.minItems=="number"&&(r=r.check(V.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(V.maxLength(e.maxItems)))}else if(Array.isArray(o)){const s=typeof e.minItems=="number"?e.minItems:0,a=o.map(d=>wt(d,t)),u=cp(a,s),c=dp(e.additionalItems,t),l=V.tuple(u);r=c?l.rest(c):l,typeof e.minItems=="number"&&(r=r.check(V.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(V.maxLength(e.maxItems)))}else if(o!==void 0){const s=wt(o,t);let a=V.array(s);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),r=a}else r=V.array(V.any());(e.uniqueItems===!0||e.contains!==void 0)&&(r=Wx(r,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?wt(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${n}`)}return r}function wt(e,t){if(typeof e=="boolean")return e?V.any():V.never();let n=pw(e,t);const r=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){const a=e.anyOf.map(c=>wt(c,t)),u=V.union(a);n=r?V.intersection(n,u):u}if(e.oneOf&&Array.isArray(e.oneOf)){const a=e.oneOf.map(c=>wt(c,t)),u=V.xor(a);n=r?V.intersection(n,u):u}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=r?n:V.any();else{let a=r?n:wt(e.allOf[0],t);const u=r?0:1;for(let c=u;c<e.allOf.length;c++)a=V.intersection(a,wt(e.allOf[c],t));n=a}e.nullable===!0&&t.version==="openapi-3.0"&&(n=V.nullable(n)),e.readOnly===!0&&(n=V.readonly(n)),e.default!==void 0&&(n=n.default(e.default));const i={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(const a of o)a in e&&(i[a]=e[a]);const s=["contentEncoding","contentMediaType","contentSchema"];for(const a of s)a in e&&(i[a]=e[a]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!li(e.propertyNames)&&(i.propertyNames=e.propertyNames);for(const a of["minProperties","maxProperties"])e[a]!==void 0&&(i[a]=e[a])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!li(e.contains)&&(i.contains=e.contains);for(const a of["uniqueItems","minContains","maxContains"])e[a]!==void 0&&(i[a]=e[a])}for(const a of Object.keys(e))Gx.has(a)||Nt(i,a,e[a]);return Object.keys(i).length>0&&t.registry.add(n,i),e.description&&(n=n.describe(e.description)),n}function mw(e,t){if(typeof e=="boolean")return e?V.any():V.never();let n;try{n=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}const r=jx(n,t?.defaultTarget),i=n.$defs||n.definitions||{},o={version:r,defs:i,refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??Tt};return wt(n,o)}function gw(e){return cd(e,{object:t=>t.partial(),union:t=>{const n=t._zod.def;return n.discriminator===void 0?t:xe(n.options)}})}function Jx(e,t){if(!t?.length)return e;const n=e._zod.def;return He(e,ht(n,{checks:[...n.checks??[],...t]}),{parent:!0})}function yw(e){return Jx(e.out,e.checks)}function Yx(e){return e.in._zod.traits.has("$ZodTransform")?yw(e):e.in}function vw(e){return cd(e,{pipe:t=>Yx(t._zod.def),default:(t,n)=>n?Be(t._zod.def.innerType):t,catch:(t,n)=>n?t._zod.def.innerType:t})}function bw(e){return cd(e,{pipe:t=>yw(t._zod.def),prefault:(t,n)=>n?t._zod.def.innerType:t})}function Xx(e){return Rv(Ir,e)}function Qx(e){return Ov(Dr,e)}function eE(e){return Bv(Or,e)}function tE(e){return Vv(Mr,e)}function nE(e){return rb(ko,e)}const ww=Object.freeze(Object.defineProperty({__proto__:null,bigint:tE,boolean:eE,date:nE,number:Qx,string:Xx},Symbol.toStringTag,{value:"Module"})),fp=Object.freeze(Object.defineProperty({__proto__:null,$brand:Fc,$input:Il,$output:Al,INVALID:kt,NEVER:Mc,TimePrecision:ed,ZodAny:ha,ZodArray:ya,ZodBase64:mo,ZodBase64URL:go,ZodBigInt:Mr,ZodBigIntFormat:bo,ZodBoolean:Or,ZodCIDRv4:ho,ZodCIDRv6:po,ZodCUID:oo,ZodCUID2:so,ZodCatch:Da,ZodCodec:Br,ZodCompileAsyncError:hn,ZodCompileUnsupportedError:Ne,ZodCreditCard:ua,ZodCustom:Hr,ZodCustomStringFormat:Ln,ZodDate:ko,ZodDefault:Ia,ZodDiscriminatedUnion:ba,ZodE164:yo,ZodEmail:to,ZodEmoji:ro,ZodEnum:Qn,ZodError:cw,ZodExactOptional:Eo,ZodFile:$a,get ZodFirstPartyTypeKind(){return bs},ZodFunction:Va,ZodGUID:no,ZodIBAN:ca,ZodIPv4:lo,ZodIPv6:fo,ZodISODate:Rr,ZodISODateTime:Nr,ZodISODuration:zr,ZodISOTime:Lr,ZodInstanceOf:Ja,ZodIntersection:wa,ZodIssueCode:lw,ZodJWT:vo,ZodKSUID:co,ZodLazy:Za,ZodLiteral:Ea,ZodMAC:aa,ZodMap:Sa,ZodNaN:Ma,ZodNanoID:io,ZodNever:ma,ZodNonOptional:$o,ZodNull:fa,ZodNullable:Aa,ZodNumber:Dr,ZodNumberFormat:zn,ZodObject:Fr,ZodOptional:jr,ZodPipe:Zr,ZodPrefault:Ra,ZodPreprocess:Fa,ZodPromise:Ha,ZodReadonly:Ua,ZodRealError:$t,ZodRecord:Xn,ZodSet:xa,ZodString:Ir,ZodStringFormat:De,ZodSuccess:Pa,ZodSymbol:la,ZodTemplateLiteral:ja,ZodTransform:Ta,ZodTuple:_a,ZodType:_e,ZodULID:ao,ZodURL:Pr,ZodUUID:Xt,ZodUndefined:da,ZodUnion:Ur,ZodUnknown:pa,ZodVoid:ga,ZodXID:uo,ZodXor:va,_ZodString:eo,_default:Na,_function:wr,any:_o,array:le,base64:Zd,base64url:Bd,bigint:of,boolean:Pe,catch:Oa,check:Tf,cidrv4:Gd,cidrv6:jd,clone:He,codec:Sf,coerce:ww,compile:Nl,config:et,core:sw,creditCard:Vd,cuid:Ld,cuid2:zd,currencyCode:Xd,custom:qa,date:lf,decode:gd,decodeAsync:vd,deepPartial:gw,describe:Cf,discriminatedUnion:So,e164:Hd,email:Sd,emoji:Nd,encode:md,encodeAsync:yd,endsWith:Vi,enum:ut,exactOptional:Ca,file:bf,flattenError:Us,float32:ef,float64:tf,formatError:Gs,fromJSONSchema:mw,function:wr,getDiscriminatedOption:wl,getErrorMap:fw,globalRegistry:Tt,gt:mn,gte:It,guid:xd,hash:Qd,hex:Yd,hostname:Jd,httpUrl:Id,iban:qd,includes:Bi,input:vw,instanceof:If,int:wi,int32:nf,int64:sf,intersection:Gr,invertCodec:xf,ipv4:Md,ipv6:Ud,iso:Lf,json:Rf,jwt:Wd,keyof:df,ksuid:Od,lazy:Ba,length:Cr,literal:$,locales:Cl,looseObject:at,looseRecord:mf,lowercase:ji,lt:pn,lte:At,mac:Fd,map:gf,maxLength:Tr,maxSize:er,memoizer:Js,meta:Af,mime:Wi,minLength:Nn,minSize:gn,multipleOf:Jn,nan:kf,nanoid:Rd,nativeEnum:vf,negative:ra,never:Yn,nonnegative:oa,nonoptional:za,nonpositive:ia,normalize:Ki,null:wo,nullable:br,nullish:wf,number:we,object:C,optional:Be,output:bw,overwrite:nn,parse:dd,parseAsync:fd,partialRecord:pf,pipe:_i,positive:na,prefault:La,preprocess:To,prettifyError:Gc,promise:$f,properties:qi,property:sa,readonly:Ga,record:Ce,refine:Wa,regex:Gi,regexes:Hs,registry:Ys,safeDecode:wd,safeDecodeAsync:kd,safeEncode:bd,safeEncodeAsync:_d,safeParse:hd,safeParseAsync:pd,set:yf,setErrorMap:dw,size:$r,slugify:Qi,startsWith:Hi,strictObject:ff,string:E,stringFormat:Kd,stringbool:Nf,success:_f,superRefine:Ka,symbol:uf,templateLiteral:Ef,toJSONSchema:ud,toLowerCase:Yi,toUpperCase:Xi,toZod:Ls,transform:xo,treeifyError:Uc,trim:Ji,tuple:ka,uint32:rf,uint64:af,ulid:Pd,undefined:vr,union:xe,unknown:Le,uppercase:Zi,url:Ad,util:Oc,uuid:Ed,uuidv4:$d,uuidv6:Td,uuidv7:Cd,validate:Zs,validateAsync:Bs,void:cf,withParser:Xs,xid:Dd,xor:hf},Symbol.toStringTag,{value:"Module"})),rE=Object.freeze(Object.defineProperty({__proto__:null,$brand:Fc,$input:Il,$output:Al,INVALID:kt,NEVER:Mc,TimePrecision:ed,ZodAny:ha,ZodArray:ya,ZodBase64:mo,ZodBase64URL:go,ZodBigInt:Mr,ZodBigIntFormat:bo,ZodBoolean:Or,ZodCIDRv4:ho,ZodCIDRv6:po,ZodCUID:oo,ZodCUID2:so,ZodCatch:Da,ZodCodec:Br,ZodCompileAsyncError:hn,ZodCompileUnsupportedError:Ne,ZodCreditCard:ua,ZodCustom:Hr,ZodCustomStringFormat:Ln,ZodDate:ko,ZodDefault:Ia,ZodDiscriminatedUnion:ba,ZodE164:yo,ZodEmail:to,ZodEmoji:ro,ZodEnum:Qn,ZodError:cw,ZodExactOptional:Eo,ZodFile:$a,get ZodFirstPartyTypeKind(){return bs},ZodFunction:Va,ZodGUID:no,ZodIBAN:ca,ZodIPv4:lo,ZodIPv6:fo,ZodISODate:Rr,ZodISODateTime:Nr,ZodISODuration:zr,ZodISOTime:Lr,ZodInstanceOf:Ja,ZodIntersection:wa,ZodIssueCode:lw,ZodJWT:vo,ZodKSUID:co,ZodLazy:Za,ZodLiteral:Ea,ZodMAC:aa,ZodMap:Sa,ZodNaN:Ma,ZodNanoID:io,ZodNever:ma,ZodNonOptional:$o,ZodNull:fa,ZodNullable:Aa,ZodNumber:Dr,ZodNumberFormat:zn,ZodObject:Fr,ZodOptional:jr,ZodPipe:Zr,ZodPrefault:Ra,ZodPreprocess:Fa,ZodPromise:Ha,ZodReadonly:Ua,ZodRealError:$t,ZodRecord:Xn,ZodSet:xa,ZodString:Ir,ZodStringFormat:De,ZodSuccess:Pa,ZodSymbol:la,ZodTemplateLiteral:ja,ZodTransform:Ta,ZodTuple:_a,ZodType:_e,ZodULID:ao,ZodURL:Pr,ZodUUID:Xt,ZodUndefined:da,ZodUnion:Ur,ZodUnknown:pa,ZodVoid:ga,ZodXID:uo,ZodXor:va,_ZodString:eo,_default:Na,_function:wr,any:_o,array:le,base64:Zd,base64url:Bd,bigint:of,boolean:Pe,catch:Oa,check:Tf,cidrv4:Gd,cidrv6:jd,clone:He,codec:Sf,coerce:ww,compile:Nl,config:et,core:sw,creditCard:Vd,cuid:Ld,cuid2:zd,currencyCode:Xd,custom:qa,date:lf,decode:gd,decodeAsync:vd,deepPartial:gw,default:fp,describe:Cf,discriminatedUnion:So,e164:Hd,email:Sd,emoji:Nd,encode:md,encodeAsync:yd,endsWith:Vi,enum:ut,exactOptional:Ca,file:bf,flattenError:Us,float32:ef,float64:tf,formatError:Gs,fromJSONSchema:mw,function:wr,getDiscriminatedOption:wl,getErrorMap:fw,globalRegistry:Tt,gt:mn,gte:It,guid:xd,hash:Qd,hex:Yd,hostname:Jd,httpUrl:Id,iban:qd,includes:Bi,input:vw,instanceof:If,int:wi,int32:nf,int64:sf,intersection:Gr,invertCodec:xf,ipv4:Md,ipv6:Ud,iso:Lf,json:Rf,jwt:Wd,keyof:df,ksuid:Od,lazy:Ba,length:Cr,literal:$,locales:Cl,looseObject:at,looseRecord:mf,lowercase:ji,lt:pn,lte:At,mac:Fd,map:gf,maxLength:Tr,maxSize:er,memoizer:Js,meta:Af,mime:Wi,minLength:Nn,minSize:gn,multipleOf:Jn,nan:kf,nanoid:Rd,nativeEnum:vf,negative:ra,never:Yn,nonnegative:oa,nonoptional:za,nonpositive:ia,normalize:Ki,null:wo,nullable:br,nullish:wf,number:we,object:C,optional:Be,output:bw,overwrite:nn,parse:dd,parseAsync:fd,partialRecord:pf,pipe:_i,positive:na,prefault:La,preprocess:To,prettifyError:Gc,promise:$f,properties:qi,property:sa,readonly:Ga,record:Ce,refine:Wa,regex:Gi,regexes:Hs,registry:Ys,safeDecode:wd,safeDecodeAsync:kd,safeEncode:bd,safeEncodeAsync:_d,safeParse:hd,safeParseAsync:pd,set:yf,setErrorMap:dw,size:$r,slugify:Qi,startsWith:Hi,strictObject:ff,string:E,stringFormat:Kd,stringbool:Nf,success:_f,superRefine:Ka,symbol:uf,templateLiteral:Ef,toJSONSchema:ud,toLowerCase:Yi,toUpperCase:Xi,toZod:Ls,transform:xo,treeifyError:Uc,trim:Ji,tuple:ka,uint32:rf,uint64:af,ulid:Pd,undefined:vr,union:xe,unknown:Le,uppercase:Zi,url:Ad,util:Oc,uuid:Ed,uuidv4:$d,uuidv6:Td,uuidv7:Cd,validate:Zs,validateAsync:Bs,void:cf,withParser:Xs,xid:Dd,xor:hf,z:fp},Symbol.toStringTag,{value:"Module"})),Bn="io.modelcontextprotocol/related-task",Ya="2.0",Qe=qa(e=>e!==null&&(typeof e=="object"||typeof e=="function")),_w=xe([E(),we().int()]),kw=E();at({ttl:we().optional(),pollInterval:we().optional()});const iE=C({ttl:we().optional()}),oE=C({taskId:E()}),zf=at({progressToken:_w.optional(),[Bn]:oE.optional()}),Lt=C({_meta:zf.optional()}),Co=Lt.extend({task:iE.optional()}),sE=e=>Co.safeParse(e).success,ct=C({method:E(),params:Lt.loose().optional()}),Gt=C({_meta:zf.optional()}),jt=C({method:E(),params:Gt.loose().optional()}),lt=at({_meta:zf.optional()}),Ao=xe([E(),we().int()]),Sw=C({jsonrpc:$(Ya),id:Ao,...ct.shape}).strict(),hp=e=>Sw.safeParse(e).success,xw=C({jsonrpc:$(Ya),...jt.shape}).strict(),aE=e=>xw.safeParse(e).success,Pf=C({jsonrpc:$(Ya),id:Ao,result:lt}).strict(),Ho=e=>Pf.safeParse(e).success;var Re;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(Re||(Re={}));const Df=C({jsonrpc:$(Ya),id:Ao.optional(),error:C({code:we().int(),message:E(),data:Le().optional()})}).strict(),uE=e=>Df.safeParse(e).success,cE=xe([Sw,xw,Pf,Df]);xe([Pf,Df]);const Of=lt.strict(),lE=Gt.extend({requestId:Ao.optional(),reason:E().optional()}),Mf=jt.extend({method:$("notifications/cancelled"),params:lE}),dE=C({src:E(),mimeType:E().optional(),sizes:le(E()).optional(),theme:ut(["light","dark"]).optional()}),Io=C({icons:le(dE).optional()}),_r=C({name:E(),title:E().optional()}),Xa=_r.extend({..._r.shape,...Io.shape,version:E(),websiteUrl:E().optional(),description:E().optional()}),fE=Gr(C({applyDefaults:Pe().optional()}),Ce(E(),Le())),hE=To(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Gr(C({form:fE.optional(),url:Qe.optional()}),Ce(E(),Le()).optional())),pE=at({list:Qe.optional(),cancel:Qe.optional(),requests:at({sampling:at({createMessage:Qe.optional()}).optional(),elicitation:at({create:Qe.optional()}).optional()}).optional()}),mE=at({list:Qe.optional(),cancel:Qe.optional(),requests:at({tools:at({call:Qe.optional()}).optional()}).optional()}),gE=C({experimental:Ce(E(),Qe).optional(),sampling:C({context:Qe.optional(),tools:Qe.optional()}).optional(),elicitation:hE.optional(),roots:C({listChanged:Pe().optional()}).optional(),tasks:pE.optional(),extensions:Ce(E(),Qe).optional()}),yE=Lt.extend({protocolVersion:E(),capabilities:gE,clientInfo:Xa}),vE=ct.extend({method:$("initialize"),params:yE}),bE=C({experimental:Ce(E(),Qe).optional(),logging:Qe.optional(),completions:Qe.optional(),prompts:C({listChanged:Pe().optional()}).optional(),resources:C({subscribe:Pe().optional(),listChanged:Pe().optional()}).optional(),tools:C({listChanged:Pe().optional()}).optional(),tasks:mE.optional(),extensions:Ce(E(),Qe).optional()}),wE=lt.extend({protocolVersion:E(),capabilities:bE,serverInfo:Xa,instructions:E().optional()}),_E=jt.extend({method:$("notifications/initialized"),params:Gt.optional()}),Qa=ct.extend({method:$("ping"),params:Lt.optional()}),kE=C({progress:we(),total:Be(we()),message:Be(E())}),SE=C({...Gt.shape,...kE.shape,progressToken:_w}),Ff=jt.extend({method:$("notifications/progress"),params:SE}),xE=Lt.extend({cursor:kw.optional()}),No=ct.extend({params:xE.optional()}),Ro=lt.extend({nextCursor:kw.optional()}),EE=ut(["working","input_required","completed","failed","cancelled"]),Lo=C({taskId:E(),status:EE,ttl:xe([we(),wo()]),createdAt:E(),lastUpdatedAt:E(),pollInterval:Be(we()),statusMessage:Be(E())}),Uf=lt.extend({task:Lo}),$E=Gt.merge(Lo),ws=jt.extend({method:$("notifications/tasks/status"),params:$E}),Gf=ct.extend({method:$("tasks/get"),params:Lt.extend({taskId:E()})}),jf=lt.merge(Lo),Zf=ct.extend({method:$("tasks/result"),params:Lt.extend({taskId:E()})});lt.loose();const Bf=No.extend({method:$("tasks/list")}),Hf=Ro.extend({tasks:le(Lo)}),Vf=ct.extend({method:$("tasks/cancel"),params:Lt.extend({taskId:E()})}),TE=lt.merge(Lo),Ew=C({uri:E(),mimeType:Be(E()),_meta:Ce(E(),Le()).optional()}),$w=Ew.extend({text:E()}),qf=E().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Tw=Ew.extend({blob:qf}),zo=ut(["user","assistant"]),Vr=C({audience:le(zo).optional(),priority:we().min(0).max(1).optional(),lastModified:hw({offset:!0}).optional()}),Cw=C({..._r.shape,...Io.shape,uri:E(),description:Be(E()),mimeType:Be(E()),size:Be(we()),annotations:Vr.optional(),_meta:Be(at({}))}),CE=C({..._r.shape,...Io.shape,uriTemplate:E(),description:Be(E()),mimeType:Be(E()),annotations:Vr.optional(),_meta:Be(at({}))}),AE=No.extend({method:$("resources/list")}),Aw=Ro.extend({resources:le(Cw)}),IE=No.extend({method:$("resources/templates/list")}),NE=Ro.extend({resourceTemplates:le(CE)}),Wf=Lt.extend({uri:E()}),RE=Wf,LE=ct.extend({method:$("resources/read"),params:RE}),Iw=lt.extend({contents:le(xe([$w,Tw]))}),zE=jt.extend({method:$("notifications/resources/list_changed"),params:Gt.optional()}),PE=Wf,DE=ct.extend({method:$("resources/subscribe"),params:PE}),OE=Wf,ME=ct.extend({method:$("resources/unsubscribe"),params:OE}),FE=Gt.extend({uri:E()}),UE=jt.extend({method:$("notifications/resources/updated"),params:FE}),GE=C({name:E(),description:Be(E()),required:Be(Pe())}),jE=C({..._r.shape,...Io.shape,description:Be(E()),arguments:Be(le(GE)),_meta:Be(at({}))}),ZE=No.extend({method:$("prompts/list")}),BE=Ro.extend({prompts:le(jE)}),HE=Lt.extend({name:E(),arguments:Ce(E(),E()).optional()}),VE=ct.extend({method:$("prompts/get"),params:HE}),Kf=C({type:$("text"),text:E(),annotations:Vr.optional(),_meta:Ce(E(),Le()).optional()}),Jf=C({type:$("image"),data:qf,mimeType:E(),annotations:Vr.optional(),_meta:Ce(E(),Le()).optional()}),Yf=C({type:$("audio"),data:qf,mimeType:E(),annotations:Vr.optional(),_meta:Ce(E(),Le()).optional()}),qE=C({type:$("tool_use"),name:E(),id:E(),input:Ce(E(),Le()),_meta:Ce(E(),Le()).optional()}),Nw=C({type:$("resource"),resource:xe([$w,Tw]),annotations:Vr.optional(),_meta:Ce(E(),Le()).optional()}),Rw=Cw.extend({type:$("resource_link")}),Po=xe([Kf,Jf,Yf,Rw,Nw]),WE=C({role:zo,content:Po}),KE=lt.extend({description:E().optional(),messages:le(WE)}),JE=jt.extend({method:$("notifications/prompts/list_changed"),params:Gt.optional()}),YE=C({title:E().optional(),readOnlyHint:Pe().optional(),destructiveHint:Pe().optional(),idempotentHint:Pe().optional(),openWorldHint:Pe().optional()}),XE=C({taskSupport:ut(["required","optional","forbidden"]).optional()}),Xf=C({..._r.shape,...Io.shape,description:E().optional(),inputSchema:C({type:$("object"),properties:Ce(E(),Qe).optional(),required:le(E()).optional()}).catchall(Le()),outputSchema:C({type:$("object"),properties:Ce(E(),Qe).optional(),required:le(E()).optional()}).catchall(Le()).optional(),annotations:YE.optional(),execution:XE.optional(),_meta:Ce(E(),Le()).optional()}),Lw=No.extend({method:$("tools/list")}),QE=Ro.extend({tools:le(Xf)}),eu=lt.extend({content:le(Po).default([]),structuredContent:Ce(E(),Le()).optional(),isError:Pe().optional()});eu.or(lt.extend({toolResult:Le()}));const e$=Co.extend({name:E(),arguments:Ce(E(),Le()).optional()}),zw=ct.extend({method:$("tools/call"),params:e$}),t$=jt.extend({method:$("notifications/tools/list_changed"),params:Gt.optional()});C({autoRefresh:Pe().default(!0),debounceMs:we().int().nonnegative().default(300)});const Pw=ut(["debug","info","notice","warning","error","critical","alert","emergency"]),n$=Lt.extend({level:Pw}),r$=ct.extend({method:$("logging/setLevel"),params:n$}),i$=Gt.extend({level:Pw,logger:E().optional(),data:Le()}),o$=jt.extend({method:$("notifications/message"),params:i$}),s$=C({name:E().optional()}),a$=C({hints:le(s$).optional(),costPriority:we().min(0).max(1).optional(),speedPriority:we().min(0).max(1).optional(),intelligencePriority:we().min(0).max(1).optional()}),u$=C({mode:ut(["auto","required","none"]).optional()}),c$=C({type:$("tool_result"),toolUseId:E().describe("The unique identifier for the corresponding tool call."),content:le(Po).default([]),structuredContent:C({}).loose().optional(),isError:Pe().optional(),_meta:Ce(E(),Le()).optional()}),l$=So("type",[Kf,Jf,Yf]),_s=So("type",[Kf,Jf,Yf,qE,c$]),d$=C({role:zo,content:xe([_s,le(_s)]),_meta:Ce(E(),Le()).optional()}),f$=Co.extend({messages:le(d$),modelPreferences:a$.optional(),systemPrompt:E().optional(),includeContext:ut(["none","thisServer","allServers"]).optional(),temperature:we().optional(),maxTokens:we().int(),stopSequences:le(E()).optional(),metadata:Qe.optional(),tools:le(Xf).optional(),toolChoice:u$.optional()}),h$=ct.extend({method:$("sampling/createMessage"),params:f$}),Dw=lt.extend({model:E(),stopReason:Be(ut(["endTurn","stopSequence","maxTokens"]).or(E())),role:zo,content:l$}),Ow=lt.extend({model:E(),stopReason:Be(ut(["endTurn","stopSequence","maxTokens","toolUse"]).or(E())),role:zo,content:xe([_s,le(_s)])}),p$=C({type:$("boolean"),title:E().optional(),description:E().optional(),default:Pe().optional()}),m$=C({type:$("string"),title:E().optional(),description:E().optional(),minLength:we().optional(),maxLength:we().optional(),format:ut(["email","uri","date","date-time"]).optional(),default:E().optional()}),g$=C({type:ut(["number","integer"]),title:E().optional(),description:E().optional(),minimum:we().optional(),maximum:we().optional(),default:we().optional()}),y$=C({type:$("string"),title:E().optional(),description:E().optional(),enum:le(E()),default:E().optional()}),v$=C({type:$("string"),title:E().optional(),description:E().optional(),oneOf:le(C({const:E(),title:E()})),default:E().optional()}),b$=C({type:$("string"),title:E().optional(),description:E().optional(),enum:le(E()),enumNames:le(E()).optional(),default:E().optional()}),w$=xe([y$,v$]),_$=C({type:$("array"),title:E().optional(),description:E().optional(),minItems:we().optional(),maxItems:we().optional(),items:C({type:$("string"),enum:le(E())}),default:le(E()).optional()}),k$=C({type:$("array"),title:E().optional(),description:E().optional(),minItems:we().optional(),maxItems:we().optional(),items:C({anyOf:le(C({const:E(),title:E()}))}),default:le(E()).optional()}),S$=xe([_$,k$]),x$=xe([b$,w$,S$]),E$=xe([x$,p$,m$,g$]),$$=Co.extend({mode:$("form").optional(),message:E(),requestedSchema:C({type:$("object"),properties:Ce(E(),E$),required:le(E()).optional()})}),T$=Co.extend({mode:$("url"),message:E(),elicitationId:E(),url:E().url()}),C$=xe([$$,T$]),A$=ct.extend({method:$("elicitation/create"),params:C$}),I$=Gt.extend({elicitationId:E()}),N$=jt.extend({method:$("notifications/elicitation/complete"),params:I$}),R$=lt.extend({action:ut(["accept","decline","cancel"]),content:To(e=>e===null?void 0:e,Ce(E(),xe([E(),we(),Pe(),le(E())])).optional())}),L$=C({type:$("ref/resource"),uri:E()}),z$=C({type:$("ref/prompt"),name:E()}),P$=Lt.extend({ref:xe([z$,L$]),argument:C({name:E(),value:E()}),context:C({arguments:Ce(E(),E()).optional()}).optional()}),D$=ct.extend({method:$("completion/complete"),params:P$}),O$=lt.extend({completion:at({values:le(E()).max(100),total:Be(we().int()),hasMore:Be(Pe())})}),M$=C({uri:E().startsWith("file://"),name:E().optional(),_meta:Ce(E(),Le()).optional()}),F$=ct.extend({method:$("roots/list"),params:Lt.optional()}),U$=lt.extend({roots:le(M$)}),G$=jt.extend({method:$("notifications/roots/list_changed"),params:Gt.optional()});xe([Qa,vE,D$,r$,VE,ZE,AE,IE,LE,DE,ME,zw,Lw,Gf,Zf,Bf,Vf]);xe([Mf,Ff,_E,G$,ws]);xe([Of,Dw,Ow,R$,U$,jf,Hf,Uf]);xe([Qa,h$,A$,F$,Gf,Zf,Bf,Vf]);xe([Mf,Ff,o$,UE,zE,t$,JE,ws,N$]);xe([Of,wE,O$,KE,BE,Aw,NE,Iw,eu,QE,jf,Hf,Uf]);class Ie extends Error{constructor(t,n,r){super(`MCP error ${t}: ${n}`),this.code=t,this.data=r,this.name="McpError"}static fromError(t,n,r){if(t===Re.UrlElicitationRequired&&r){const i=r;if(i.elicitations)return new j$(i.elicitations,n)}return new Ie(t,n,r)}}class j$ extends Ie{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(Re.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}}function Un(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function pp(e){const n=Nx(e)?.method;if(!n)throw new Error("Schema is missing a method literal");const r=Rx(n);if(typeof r!="string")throw new Error("Schema method literal must be a string");return r}function mp(e,t){const n=aw(e,t);if(!n.success)throw n.error;return n.data}const Z$=6e4;class B${constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Mf,n=>{this._oncancel(n)}),this.setNotificationHandler(Ff,n=>{this._onprogress(n)}),this.setRequestHandler(Qa,n=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Gf,async(n,r)=>{const i=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!i)throw new Ie(Re.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(Zf,async(n,r)=>{const i=async()=>{const o=n.params.taskId;if(!await this._taskStore.getTask(o,r.sessionId))throw new Ie(Re.InvalidParams,`Task not found: ${o}`);if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(o,r.sessionId);){if(a.type==="response"||a.type==="error"){const u=a.message,c=u.id,l=this._requestResolvers.get(c);if(l)if(this._requestResolvers.delete(c),a.type==="response")l(u);else{const d=u,f=new Ie(d.error.code,d.error.message,d.error.data);l(f)}else{const d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${c}`))}continue}await this._transport?.send(a.message,{relatedRequestId:r.requestId})}}const s=await this._taskStore.getTask(o,r.sessionId);if(!s)throw new Ie(Re.InvalidParams,`Task not found: ${o}`);if(!Un(s.status))return await this._waitForTaskUpdate(o,r.signal,r.sessionId),await i();if(Un(s.status)){const a=await this._taskStore.getTaskResult(o,r.sessionId);return this._clearTaskQueue(o,r.sessionId),{...a,_meta:{...a._meta,[Bn]:{taskId:o}}}}return await i()};return await i()}),this.setRequestHandler(Bf,async(n,r)=>{try{const{tasks:i,nextCursor:o}=await this._taskStore.listTasks(n.params?.cursor,r.sessionId);return{tasks:i,nextCursor:o,_meta:{}}}catch(i){throw new Ie(Re.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(Vf,async(n,r)=>{try{const i=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!i)throw new Ie(Re.InvalidParams,`Task not found: ${n.params.taskId}`);if(Un(i.status))throw new Ie(Re.InvalidParams,`Cannot cancel task in terminal status: ${i.status}`);await this._taskStore.updateTaskStatus(n.params.taskId,"cancelled","Client cancelled task execution.",r.sessionId),this._clearTaskQueue(n.params.taskId,r.sessionId);const o=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!o)throw new Ie(Re.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...o}}catch(i){throw i instanceof Ie?i:new Ie(Re.InvalidRequest,`Failed to cancel task: ${i instanceof Error?i.message:String(i)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,n,r,i,o=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(i,n),startTime:Date.now(),timeout:n,maxTotalTimeout:r,resetTimeoutOnProgress:o,onTimeout:i})}_resetTimeout(t){const n=this._timeoutInfo.get(t);if(!n)return!1;const r=Date.now()-n.startTime;if(n.maxTotalTimeout&&r>=n.maxTotalTimeout)throw this._timeoutInfo.delete(t),Ie.fromError(Re.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:r});return clearTimeout(n.timeoutId),n.timeoutId=setTimeout(n.onTimeout,n.timeout),!0}_cleanupTimeout(t){const n=this._timeoutInfo.get(t);n&&(clearTimeout(n.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;const n=this.transport?.onclose;this._transport.onclose=()=>{n?.(),this._onclose()};const r=this.transport?.onerror;this._transport.onerror=o=>{r?.(o),this._onerror(o)};const i=this._transport?.onmessage;this._transport.onmessage=(o,s)=>{i?.(o,s),Ho(o)||uE(o)?this._onresponse(o):hp(o)?this._onrequest(o,s):aE(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const r of this._timeoutInfo.values())clearTimeout(r.timeoutId);this._timeoutInfo.clear();for(const r of this._requestHandlerAbortControllers.values())r.abort();this._requestHandlerAbortControllers.clear();const n=Ie.fromError(Re.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const r of t.values())r(n)}_onerror(t){this.onerror?.(t)}_onnotification(t){const n=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(t)).catch(r=>this._onerror(new Error(`Uncaught error in notification handler: ${r}`)))}_onrequest(t,n){const r=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,i=this._transport,o=t.params?._meta?.[Bn]?.taskId,s=i?.sessionId,a=this._taskStore;let u=!0,c;if(o&&a&&this._taskMessageQueue&&s!==void 0&&(u=!1,c=(async()=>{if(!await a.getTask(o,s))throw new Ie(Re.InvalidParams,`Task not found: ${o}`);u=!0})()),r===void 0){const p={jsonrpc:"2.0",id:t.id,error:{code:Re.MethodNotFound,message:"Method not found"}};if(o&&c){const m={type:"error",message:p,timestamp:Date.now()};c.then(()=>this._enqueueTaskMessage(o,m,s),()=>i?.send(p)).catch(y=>this._onerror(new Error(`Failed to send an error response: ${y}`)))}else o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:p,timestamp:Date.now()},i?.sessionId).catch(m=>this._onerror(new Error(`Failed to enqueue error response: ${m}`))):i?.send(p).catch(m=>this._onerror(new Error(`Failed to send an error response: ${m}`)));return}const l=new AbortController;this._requestHandlerAbortControllers.set(t.id,l);const d=sE(t.params)?t.params.task:void 0,f=this._taskStore?this.requestTaskStore(t,i?.sessionId):void 0,h={signal:l.signal,sessionId:i?.sessionId,_meta:t.params?._meta,sendNotification:async p=>{if(l.signal.aborted)return;const m={relatedRequestId:t.id};o&&(m.relatedTask={taskId:o}),await this.notification(p,m)},sendRequest:async(p,m,y)=>{if(l.signal.aborted)throw new Ie(Re.ConnectionClosed,"Request was cancelled");const b={...y,relatedRequestId:t.id};o&&!b.relatedTask&&(b.relatedTask={taskId:o});const g=b.relatedTask?.taskId??o;return g&&f&&await f.updateTaskStatus(g,"input_required"),await this.request(p,m,b)},authInfo:n?.authInfo,requestId:t.id,requestInfo:n?.requestInfo,taskId:o,taskStore:f,taskRequestedTtl:d?.ttl,closeSSEStream:n?.closeSSEStream,closeStandaloneSSEStream:n?.closeStandaloneSSEStream};(c??Promise.resolve()).then(()=>{if(c&&l.signal.aborted)throw new Ie(Re.ConnectionClosed,"Request was cancelled");d&&this.assertTaskHandlerCapability(t.method)}).then(()=>r(t,h)).then(async p=>{if(l.signal.aborted)return;const m={result:p,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:m,timestamp:Date.now()},i?.sessionId):await i?.send(m)},async p=>{if(l.signal.aborted)return;const m={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(p.code)?p.code:Re.InternalError,message:p.message??"Internal error",...p.data!==void 0&&{data:p.data}}};o&&this._taskMessageQueue&&u?await this._enqueueTaskMessage(o,{type:"error",message:m,timestamp:Date.now()},i?.sessionId):await i?.send(m)}).catch(p=>this._onerror(new Error(`Failed to send response: ${p}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===l&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:n,...r}=t.params,i=Number(n),o=this._progressHandlers.get(i);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const s=this._responseHandlers.get(i),a=this._timeoutInfo.get(i);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(u){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),s(u);return}o(r)}_onresponse(t){const n=Number(t.id),r=this._requestResolvers.get(n);if(r){if(this._requestResolvers.delete(n),Ho(t))r(t);else{const s=new Ie(t.error.code,t.error.message,t.error.data);r(s)}return}const i=this._responseHandlers.get(n);if(i===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(n),this._cleanupTimeout(n);let o=!1;if(Ho(t)&&t.result&&typeof t.result=="object"){const s=t.result;if(s.task&&typeof s.task=="object"){const a=s.task;typeof a.taskId=="string"&&(o=!0,this._taskProgressTokens.set(a.taskId,n))}}if(o||this._progressHandlers.delete(n),Ho(t))i(t);else{const s=Ie.fromError(t.error.code,t.error.message,t.error.data);i(s)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,n,r){const{task:i}=r??{};if(!i){try{yield{type:"result",result:await this.request(t,n,r)}}catch(s){yield{type:"error",error:s instanceof Ie?s:new Ie(Re.InternalError,String(s))}}return}let o;try{const s=await this.request(t,Uf,r);if(s.task)o=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new Ie(Re.InternalError,"Task creation did not return a task");for(;;){const a=await this.getTask({taskId:o},r);if(yield{type:"taskStatus",task:a},Un(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},n,r)}:a.status==="failed"?yield{type:"error",error:new Ie(Re.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new Ie(Re.InternalError,`Task ${o} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},n,r)};return}const u=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(c=>setTimeout(c,u)),r?.signal?.throwIfAborted()}}catch(s){yield{type:"error",error:s instanceof Ie?s:new Ie(Re.InternalError,String(s))}}}request(t,n,r){const{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s,task:a,relatedTask:u}=r??{};return new Promise((c,l)=>{const d=g=>{l(g)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(g){d(g);return}r?.signal?.throwIfAborted();const f=this._requestMessageId++,h={...t,jsonrpc:"2.0",id:f};r?.onprogress&&(this._progressHandlers.set(f,r.onprogress),h.params={...t.params,_meta:{...t.params?._meta||{},progressToken:f}}),a&&(h.params={...h.params,task:a}),u&&(h.params={...h.params,_meta:{...h.params?._meta||{},[Bn]:u}});const p=g=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(g)}},{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(v=>this._onerror(new Error(`Failed to send cancellation: ${v}`)));const w=g instanceof Ie?g:new Ie(Re.RequestTimeout,String(g));l(w)};this._responseHandlers.set(f,g=>{if(!r?.signal?.aborted){if(g instanceof Error)return l(g);try{const w=aw(n,g.result);w.success?c(w.data):l(w.error)}catch(w){l(w)}}}),r?.signal?.addEventListener("abort",()=>{p(r?.signal?.reason)});const m=r?.timeout??Z$,y=()=>p(Ie.fromError(Re.RequestTimeout,"Request timed out",{timeout:m}));this._setupTimeout(f,m,r?.maxTotalTimeout,y,r?.resetTimeoutOnProgress??!1);const b=u?.taskId;if(b){const g=w=>{const v=this._responseHandlers.get(f);v?v(w):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,g),this._enqueueTaskMessage(b,{type:"request",message:h,timestamp:Date.now()}).catch(w=>{this._cleanupTimeout(f),l(w)})}else this._transport.send(h,{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(g=>{this._cleanupTimeout(f),l(g)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},jf,n)}async getTaskResult(t,n,r){return this.request({method:"tasks/result",params:t},n,r)}async listTasks(t,n){return this.request({method:"tasks/list",params:t},Hf,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},TE,n)}async notification(t,n){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const r=n?.relatedTask?.taskId;if(r){const a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Bn]:n.relatedTask}}};await this._enqueueTaskMessage(r,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!n?.relatedRequestId&&!n?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};n?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Bn]:n.relatedTask}}}),this._transport?.send(a,n).catch(u=>this._onerror(u))});return}let s={...t,jsonrpc:"2.0"};n?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[Bn]:n.relatedTask}}}),await this._transport.send(s,n)}setRequestHandler(t,n){const r=pp(t);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(i,o)=>{const s=mp(t,i);return Promise.resolve(n(s,o))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,n){const r=pp(t);this._notificationHandlers.set(r,i=>{const o=mp(t,i);return Promise.resolve(n(o))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){const n=this._taskProgressTokens.get(t);n!==void 0&&(this._progressHandlers.delete(n),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,n,r){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const i=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,n,r??this._transport?.sessionId,i)}async _clearTaskQueue(t,n){if(this._taskMessageQueue){const r=await this._taskMessageQueue.dequeueAll(t,n);for(const i of r)if(i.type==="request"&&hp(i.message)){const o=i.message.id,s=this._requestResolvers.get(o);s?(s(new Ie(Re.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,n,r){let i=this._options?.defaultTaskPollInterval??1e3;try{const o=await this._taskStore?.getTask(t,r);o?.pollInterval&&(i=o.pollInterval)}catch{}return new Promise((o,s)=>{if(n.aborted){s(new Ie(Re.InvalidRequest,"Request cancelled"));return}const a=setTimeout(o,i);n.addEventListener("abort",()=>{clearTimeout(a),s(new Ie(Re.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,n){const r=this._taskStore;if(!r)throw new Error("No task store configured");return{createTask:async i=>{if(!t)throw new Error("No request provided");return await r.createTask(i,t.id,{method:t.method,params:t.params},n)},getTask:async i=>{const o=await r.getTask(i,n);if(!o)throw new Ie(Re.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(i,o,s)=>{await r.storeTaskResult(i,o,s,n);const a=await r.getTask(i,n);if(a){const u=ws.parse({method:"notifications/tasks/status",params:a});await this.notification(u),Un(a.status)&&this._cleanupTaskProgressHandler(i)}},getTaskResult:i=>r.getTaskResult(i,n),updateTaskStatus:async(i,o,s)=>{const a=await r.getTask(i,n);if(!a)throw new Ie(Re.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(Un(a.status))throw new Ie(Re.InvalidParams,`Cannot update task "${i}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await r.updateTaskStatus(i,o,s,n);const u=await r.getTask(i,n);if(u){const c=ws.parse({method:"notifications/tasks/status",params:u});await this.notification(c),Un(u.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>r.listTasks(i,n)}}}function gp(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function H$(e,t){const n={...e};for(const r in t){const i=r,o=t[i];if(o===void 0)continue;const s=n[i];gp(s)&&gp(o)?n[i]={...s,...o}:n[i]=o}return n}(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});class V$ extends B${_registeredMethods=new Set;_eventSlots=new Map;onEventDispatch(t,n){}_ensureEventSlot(t){let n=this._eventSlots.get(t);if(!n){let r=this.eventSchemas[t];if(!r)throw Error(`Unknown event: ${String(t)}`);n={listeners:[]},this._eventSlots.set(t,n);let i=r.shape.method.value;this._registeredMethods.add(i);let o=n;super.setNotificationHandler(r,s=>{let a=s.params;this.onEventDispatch(t,a),o.onHandler?.(a);for(let u of[...o.listeners])u(a)})}return n}setEventHandler(t,n){let r=this._ensureEventSlot(t);r.onHandler&&n&&console.warn(`[MCP Apps] on${String(t)} handler replaced. Use addEventListener("${String(t)}", …) to add multiple listeners without replacing.`),r.onHandler=n}getEventHandler(t){return this._eventSlots.get(t)?.onHandler}addEventListener(t,n){this._ensureEventSlot(t).listeners.push(n)}removeEventListener(t,n){let r=this._eventSlots.get(t);if(!r)return;let i=r.listeners.indexOf(n);i!==-1&&r.listeners.splice(i,1)}setRequestHandler=(t,n)=>{this._assertMethodNotRegistered(t,"setRequestHandler"),super.setRequestHandler(t,n)};setNotificationHandler=(t,n)=>{this._assertMethodNotRegistered(t,"setNotificationHandler"),super.setNotificationHandler(t,n)};warnIfRequestHandlerReplaced(t,n,r){n&&r&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}replaceRequestHandler=(t,n)=>{let r=t.shape.method.value;this._registeredMethods.add(r),super.setRequestHandler(t,n)};_assertMethodNotRegistered(t,n){let r=t.shape.method.value;if(this._registeredMethods.has(r))throw Error(`Handler for "${r}" already registered (via ${n}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(r)}}var q$="2026-01-26",W$="ui/notifications/tool-input-partial";class Mw{eventTarget;eventSource;messageListener;constructor(t=window.parent,n){this.eventTarget=t,this.eventSource=n,this.messageListener=r=>{if(n&&r.source!==this.eventSource){console.debug("Ignoring message from unknown source",r);return}let i=cE.safeParse(r.data);i.success?(console.debug("Parsed message",i.data),this.onmessage?.(i.data)):r.data?.jsonrpc!=="2.0"?console.debug("Ignoring non-JSON-RPC message",i.error.message,r):(console.error("Failed to parse message",i.error.message,r),this.onerror?.(Error("Invalid JSON-RPC message received: "+i.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,n){t.method!==W$&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var K$=xe([$("light"),$("dark")]).describe("Color theme preference for the host environment."),ki=xe([$("inline"),$("fullscreen"),$("pip")]).describe("Display mode for UI presentation."),J$=xe([$("--color-background-primary"),$("--color-background-secondary"),$("--color-background-tertiary"),$("--color-background-inverse"),$("--color-background-ghost"),$("--color-background-info"),$("--color-background-danger"),$("--color-background-success"),$("--color-background-warning"),$("--color-background-disabled"),$("--color-text-primary"),$("--color-text-secondary"),$("--color-text-tertiary"),$("--color-text-inverse"),$("--color-text-ghost"),$("--color-text-info"),$("--color-text-danger"),$("--color-text-success"),$("--color-text-warning"),$("--color-text-disabled"),$("--color-border-primary"),$("--color-border-secondary"),$("--color-border-tertiary"),$("--color-border-inverse"),$("--color-border-ghost"),$("--color-border-info"),$("--color-border-danger"),$("--color-border-success"),$("--color-border-warning"),$("--color-border-disabled"),$("--color-ring-primary"),$("--color-ring-secondary"),$("--color-ring-inverse"),$("--color-ring-info"),$("--color-ring-danger"),$("--color-ring-success"),$("--color-ring-warning"),$("--font-sans"),$("--font-mono"),$("--font-weight-normal"),$("--font-weight-medium"),$("--font-weight-semibold"),$("--font-weight-bold"),$("--font-text-xs-size"),$("--font-text-sm-size"),$("--font-text-md-size"),$("--font-text-lg-size"),$("--font-heading-xs-size"),$("--font-heading-sm-size"),$("--font-heading-md-size"),$("--font-heading-lg-size"),$("--font-heading-xl-size"),$("--font-heading-2xl-size"),$("--font-heading-3xl-size"),$("--font-text-xs-line-height"),$("--font-text-sm-line-height"),$("--font-text-md-line-height"),$("--font-text-lg-line-height"),$("--font-heading-xs-line-height"),$("--font-heading-sm-line-height"),$("--font-heading-md-line-height"),$("--font-heading-lg-line-height"),$("--font-heading-xl-line-height"),$("--font-heading-2xl-line-height"),$("--font-heading-3xl-line-height"),$("--border-radius-xs"),$("--border-radius-sm"),$("--border-radius-md"),$("--border-radius-lg"),$("--border-radius-xl"),$("--border-radius-full"),$("--border-width-regular"),$("--shadow-hairline"),$("--shadow-sm"),$("--shadow-md"),$("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),Y$=Ce(J$.describe(`Style variables for theming MCP apps.
70
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const a=s[1];if(t===s[0]){o(s);continue}if(e.external){const c=e.external.registry.get(s[0])?.id;if(t!==s[0]&&c){o(s);continue}}if(e.metadataRegistry.get(s[0])?.id){o(s);continue}if(a.cycle){o(s);continue}a.count>1&&e.reused==="ref"&&o(s)}e.external&&(e.sharedDefsExtractedFor=e.external)}function kb(e){const t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;const n=[];for(const r of t){if(!r||typeof r!="object")return;kb(r);const i=Object.keys(r);if(i.length!==1||i[0]!=="type")return;const o=r.type;for(const s of Array.isArray(o)?o:[o]){if(typeof s!="string")return;n.includes(s)||n.push(s)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const Sb=new Set(["type","properties","required","additionalProperties"]),lp=["oneOf","anyOf"];function dp(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function ac(e){const t=[];for(const o of e){if(typeof o!="object"||o.type!=="object")return null;for(const s in o)if(!Sb.has(s))return null;t.push(o)}const n={},r=new Set;for(const o of t){for(const s in o.properties){if(Object.prototype.hasOwnProperty.call(n,s))continue;const a=[];for(const c of t){const l=c.properties?.[s]??dp(c);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}const u=a.length===1?a[0]:ac(a)??{allOf:a};Lt(n,s,u)}for(const s of o.required??[])r.add(s)}const i={type:"object",properties:n};if(r.size&&(i.required=[...r]),t.every(o=>o.additionalProperties===!1))i.additionalProperties=!1;else{const o=[];for(const s of t){const a=dp(s);a&&!o.some(u=>JSON.stringify(u)===JSON.stringify(a))&&o.push(a)}o.length===1?i.additionalProperties=o[0]:o.length>1&&(i.additionalProperties={allOf:o})}return i}function zx(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const i of Sb)if(i in e)return;const n=t.filter(i=>lp.some(o=>Array.isArray(i[o])));let r=null;if(!n.length)r=ac(t);else{const i=n[0],o=lp.find(u=>Array.isArray(i[u]));if(Object.keys(i).length!==1)return;const s=t.filter(u=>u!==i),a=i[o].map(u=>ac([...s,u]));if(a.some(u=>!u))return;r={[o]:a}}r&&(delete e.allOf,di(e,r))}function mr(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=a=>{const u=e.seen.get(a);if(u.ref===null)return;const c=u.def??u.schema,l={...c},d=u.ref;if(u.ref=null,d){r(d);const f=e.seen.get(d),p=f.schema;if(p.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(p)):di(c,p),di(c,l),a._zod.parent===d)for(const y in c)y==="$ref"||y==="allOf"||y in l||delete c[y];if(p.$ref&&f.def)for(const y in c)y==="$ref"||y==="allOf"||y in f.def&&JSON.stringify(c[y])===JSON.stringify(f.def[y])&&delete c[y]}const h=a._zod.parent;if(h&&h!==d){r(h);const f=e.seen.get(h);if(f?.schema.$ref&&(c.$ref=f.schema.$ref,f.def))for(const p in c)p==="$ref"||p==="allOf"||p in f.def&&JSON.stringify(c[p])===JSON.stringify(f.def[p])&&delete c[p]}e.override({zodSchema:a,jsonSchema:c,path:u.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const a of[...e.seen.entries()].reverse())r(a[0]);if(e.target!=="openapi-3.0")for(const a of e.seen.entries())kb(a[1].def??a[1].schema);for(const a of e.deferred)a();if(e.intersections.length){const a=new Map;for(const u of e.seen.values())for(const c of[u.schema,u.def]){const l=c?.allOf;if(!Array.isArray(l))continue;const d=a.get(l);d?d.push(c):a.set(l,[c])}for(const u of e.intersections)for(const c of a.get(u)??[])zx(c)}}const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(a)}di(i,n.defId?n.schema:n.def??n.schema);const o=e.metadataRegistry.get(t)?.id;o!==void 0&&i.id===o&&delete i.id;const s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const a of e.seen.entries()){const u=a[1];u.def&&u.defId&&(u.def.id===u.defId&&delete u.def.id,Lt(s,u.defId,u.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const a=JSON.parse(JSON.stringify(i));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:ki(t,"input",e.processors),output:ki(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function bt(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return bt(r.element,n);if(r.type==="set")return bt(r.valueType,n);if(r.type==="lazy")return bt(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return bt(r.innerType,n);if(r.type==="intersection")return bt(r.left,n)||bt(r.right,n);if(r.type==="record"||r.type==="map")return bt(r.keyType,n)||bt(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:bt(r.in,n)||bt(r.out,n);if(r.type==="object"){for(const i in r.shape)if(bt(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(bt(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(bt(i,n))return!0;return!!(r.rest&&bt(r.rest,n))}return!1}const xb=(e,t={})=>n=>{const r=hr({...n,processors:t});return Ue(e,r),pr(r,e),mr(r,e)},ki=(e,t,n={})=>r=>{const{libraryOptions:i,target:o}=r??{},s=hr({...i??{},target:o,io:t,processors:n});return Ue(e,s),pr(s,e),mr(s,e)},gr=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},yr=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},fp=(e,t)=>{gr(e,"minimum",t),yr(e,"maximum",t)},Eb=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},$b=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Tb=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},Cb=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},hp=(e,t)=>gr(e,"minimum",t.minimum),pp=(e,t)=>yr(e,"maximum",t.maximum),mp=e=>(t,n)=>{Cb(t,n.format);const[r,i]=e[n.format];gr(t,"minimum",r),yr(t,"maximum",i)},Dx={greater_than:(e,t)=>gr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>yr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Eb(e,t.value),number_format:mp(Uc),bigint_format:mp(Gc),min_length:hp,max_length:pp,length_equals:(e,t)=>fp(e,t.length),min_size:hp,max_size:pp,size_equals:(e,t)=>fp(e,t.size),string_format:(e,t)=>{Cb(e,t.format),t.pattern&&$b(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Tb(e,t.mime)};function it(e){const t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(const o of r)Dx[o._zod.def.check]?.(t,o._zod.def);const i=e._zod.bag;i.minimum!==void 0&&gr(t,"minimum",i.minimum),i.exclusiveMinimum!==void 0&&gr(t,"exclusiveMinimum",i.exclusiveMinimum),i.maximum!==void 0&&yr(t,"maximum",i.maximum),i.exclusiveMaximum!==void 0&&yr(t,"exclusiveMaximum",i.exclusiveMaximum),i.multipleOf!==void 0&&Eb(t,i.multipleOf),i.format!==void 0&&(t.format??(t.format=i.format),i.format.includes("int")&&(t.isInt=!0)),i.mime&&Tb(t,i.mime);for(const o of i.patterns??[])$b(t,o);return t}const Ox={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Px=new Map([[bl,Rg],[ta,Lg]]),Ab=e=>Px.get(e)??e,Ib=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:o,maximum:s,format:a,patterns:u,contentEncoding:c,laxFormat:l}=it(e);if(typeof o=="number"&&(i.minLength=o),typeof s=="number"&&(i.maxLength=s),a&&(i.format=Ox[a]??a,i.format===""&&delete i.format,(a==="time"||l)&&delete i.format),c&&(i.contentEncoding=c),u&&u.size>0){const d=[...u].map(Ab);d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},Nb=(e,t,n,r)=>{const i=n,{minimum:o,maximum:s,multipleOf:a,exclusiveMaximum:u,exclusiveMinimum:c,isInt:l}=it(e);i.type=l?"integer":"number";const d=typeof c=="number"&&c>=(o??Number.NEGATIVE_INFINITY),h=typeof u=="number"&&u<=(s??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(d?f?(i.minimum=c,i.exclusiveMinimum=!0):i.exclusiveMinimum=c:typeof o=="number"&&(i.minimum=o),h?f?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u:typeof s=="number"&&(i.maximum=s),a){const p=new Set;for(const b of a)Number.isFinite(b)&&b!==0?p.add(Math.abs(b)):ot(e,t,i,r,`A multipleOf divisor of ${b} cannot be represented in JSON Schema`);const[m,...y]=p;m!==void 0&&(i.multipleOf=m),y.length&&(i.allOf=[...i.allOf??[],...y.map(b=>({multipleOf:b}))])}},Rb=(e,t,n,r)=>{n.type="boolean"},Lb=(e,t,n,r)=>{ot(e,t,n,r,"BigInt cannot be represented in JSON Schema")},zb=(e,t,n,r)=>{ot(e,t,n,r,"Symbols cannot be represented in JSON Schema")},Db=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},Ob=(e,t,n,r)=>{ot(e,t,n,r,"Undefined cannot be represented in JSON Schema")},Pb=(e,t,n,r)=>{ot(e,t,n,r,"Void cannot be represented in JSON Schema")},Mb=(e,t,n,r)=>{n.not={}},Fb=(e,t,n,r)=>{},Ub=(e,t,n,r)=>{},Gb=(e,t,n,r)=>{ot(e,t,n,r,"Date cannot be represented in JSON Schema")},jb=(e,t,n,r)=>{const i=e._zod.def,o=bs(i.entries);if(o.length===0){n.not={};return}o.every(s=>typeof s=="number")&&(n.type="number"),o.every(s=>typeof s=="string")&&(n.type="string"),n.enum=o},Zb=(e,t,n,r)=>{const i=e._zod.def;if(i.values.length===0){n.not={};return}const o=[];for(const s of i.values)if(s===void 0){if(ot(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s=="bigint"){if(ot(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(s))}else o.push(s);if(o.length!==0)if(o.length===1){const s=o[0];n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[s]:n.const=s}else o.every(s=>typeof s=="number")&&(n.type="number"),o.every(s=>typeof s=="string")&&(n.type="string"),o.every(s=>typeof s=="boolean")&&(n.type="boolean"),o.every(s=>s===null)&&(n.type="null"),n.enum=o},Bb=(e,t,n,r)=>{ot(e,t,n,r,"NaN cannot be represented in JSON Schema")},Hb=(e,t,n,r)=>{const i=n,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=o.source},Vb=(e,t,n,r)=>{const i=n;i.type="string",i.format="binary",i.contentEncoding="binary";const{minimum:o,maximum:s,mime:a}=it(e);o!==void 0&&(i.minLength=o),s!==void 0&&(i.maxLength=s),a&&(a.length===0?i.not={}:a.length===1?i.contentMediaType=a[0]:i.anyOf=a.map(u=>({contentMediaType:u})))},qb=(e,t,n,r)=>{n.type="boolean"},Wb=(e,t,n,r)=>{ot(e,t,n,r,"Custom types cannot be represented in JSON Schema")},Kb=(e,t,n,r)=>{ot(e,t,n,r,"Function types cannot be represented in JSON Schema")},Jb=(e,t,n,r)=>{ot(e,t,n,r,"Transforms cannot be represented in JSON Schema")},Yb=(e,t,n,r)=>{ot(e,t,n,r,"Map cannot be represented in JSON Schema")},Xb=(e,t,n,r)=>{ot(e,t,n,r,"Set cannot be represented in JSON Schema")},Qb=(e,t,n,r)=>{const i=n,o=e._zod.def,{minimum:s,maximum:a}=it(e);typeof s=="number"&&(i.minItems=s),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=Ue(o.element,t,{...r,path:[...r.path,"items"]})};function Si(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Si(t.out):t.type==="catch"?Si(t.innerType):e._zod.optin}const ew=(e,t,n,r)=>{const i=n,o=e._zod.def,s=o.shape;if(Object.getOwnPropertySymbols(s).length&&ot(e,t,i,r,"Symbol keys cannot be represented in JSON Schema"))return;i.type="object",i.properties={};for(const c in s)Lt(i.properties,c,Ue(s[c],t,{...r,path:[...r.path,"properties",c]}));const u=[];for(const c of Object.keys(s)){const l=o.shape[c];(t.io==="input"?Si(l)===void 0:l._zod.optout===void 0)&&u.push(c)}u.length>0&&(i.required=u),o.catchall?._zod.def.type==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=Ue(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},fd=(e,t,n,r)=>{const i=e._zod.def,o=i.inclusive===!1,s=i.options.map((a,u)=>Ue(a,t,{...r,path:[...r.path,o?"oneOf":"anyOf",u]}));o?n.oneOf=s:n.anyOf=s},tw=(e,t,n,r)=>{const i=e._zod.def,o=Ue(i.left,t,{...r,path:[...r.path,"allOf",0]}),s=Ue(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1,u=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]];n.allOf=u,t.intersections.push(u)},nw=(e,t,n,r)=>{const i=n,o=e._zod.def;i.type="array";const s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",u=o.items.map((m,y)=>Ue(m,t,{...r,path:[...r.path,s,y]})),c=o.rest?Ue(o.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null;let l=o.items.length;for(;l>0;){const m=o.items[l-1];if(!(t.io==="input"?Si(m)!==void 0:m._zod.optout==="optional"))break;l--}const d=o.items.length,h=!o.rest;t.target==="draft-2020-12"?(i.prefixItems=u,h?i.items=!1:c&&(i.items=c),l>0&&(i.minItems=l),h&&(i.maxItems=d)):t.target==="openapi-3.0"?(i.items={anyOf:u},c&&i.items.anyOf.push(c),l>0&&(i.minItems=l),h&&(i.maxItems=d)):(i.items=u,h?i.additionalItems=!1:c&&(i.additionalItems=c),l>0&&(i.minItems=l),h&&(i.maxItems=d));const{minimum:f,maximum:p}=it(e);typeof f=="number"&&(i.minItems=f),typeof p=="number"&&(i.maxItems=p)};function uc(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);const p=e.get(t)?.def;if(!p)return t;const m=uc(e,p,n);return m===p?t:m}for(const p of["anyOf","oneOf"]){const m=t[p];if(!Array.isArray(m))continue;const y=m.map(b=>uc(e,b,n));y.some((b,g)=>b!==m[g])&&(t={...t,[p]:y})}const r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes("string")&&r.some(p=>p==="number"||p==="integer"),o=t.enum??(t.const!==void 0?[t.const]:void 0);if(!i&&!o?.some(p=>typeof p=="number"))return t;const{minimum:s,maximum:a,exclusiveMinimum:u,exclusiveMaximum:c,multipleOf:l,format:d,id:h,...f}=t;return f.enum?f.enum=f.enum.map(p=>typeof p=="number"?String(p):p):typeof f.const=="number"&&(f.const=String(f.const)),i&&(f.type="string",o||(f.pattern=(r.includes("number")?$r:sl).source)),f}const cc=new WeakMap;function Mx(e){const t=new Map;for(const r of e.seen.values())r.def&&!t.has(r.schema)&&t.set(r.schema,r);const n=new Map;for(const r of cc.get(e)??[]){const i=e.seen.get(r),o=(i?.def??i?.schema)?.propertyNames;if(!o||o===!0||n.has(o))continue;const s=uc(t,o,new Set);s!==o&&n.set(o,s)}if(n.size)for(const r of e.seen.values())for(const i of[r.schema,r.def]){const o=i&&n.get(i.propertyNames);o&&(i.propertyNames=o)}}const rw=(e,t,n,r)=>{const i=n,o=e._zod.def;i.type="object";const s=o.keyType,a=it(s).patterns;if(o.mode==="loose"&&a&&a.size>0){const l=Ue(o.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const d of a)Lt(i.patternProperties,Ab(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){i.propertyNames=Ue(o.keyType,t,{...r,path:[...r.path,"propertyNames"]});let l=cc.get(t);l||(l=[],cc.set(t,l),t.deferred.push(()=>Mx(t))),l.push(e)}i.additionalProperties=Ue(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}const u=s._zod.values,c=t.io==="input"&&Si(o.valueType)!==void 0;if(u&&!o.partial&&!c){const l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(i.required=l.map(String))}},iw=(e,t,n,r)=>{const i=e._zod.def,o=Ue(i.innerType,t,r),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},ow=(e,t,n,r)=>{const i=e._zod.def;Ue(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},hd=Symbol();function sw(e,t,n,r,i){let o=!1;const s=JSON.stringify(e,(a,u)=>typeof u!="bigint"?u:(o=!0,null));return o?(ot(t,n,r,i,"BigInt defaults cannot be represented in JSON Schema"),hd):JSON.parse(s)}const aw=(e,t,n,r)=>{const i=e._zod.def;Ue(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType;const s=sw(i.defaultValue,e,t,n,r);s!==hd&&(n.default=s)},uw=(e,t,n,r)=>{const i=e._zod.def;Ue(i.innerType,t,r);const o=t.seen.get(e);if(o.ref=i.innerType,t.io!=="input")return;const s=sw(i.defaultValue,e,t,n,r);s!==hd&&(n._prefault=s)},cw=(e,t,n,r)=>{const i=e._zod.def;Ue(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType;let s;try{s=i.catchValue(void 0)}catch{ot(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},lw=(e,t,n,r)=>{const i=e._zod.def,o=i.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?o?i.out:i.in:i.out;Ue(s,t,r);const a=t.seen.get(e);a.ref=s},dw=(e,t,n,r)=>{const i=e._zod.def;Ue(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType,n.readOnly=!0},fw=(e,t,n,r)=>{const i=e._zod.def;Ue(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},pd=(e,t,n,r)=>{const i=e._zod.def;Ue(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},hw=(e,t,n,r)=>{const i=e._zod.innerType;Ue(i,t,r);const o=t.seen.get(e);o.ref=i},lc={string:Ib,number:Nb,boolean:Rb,bigint:Lb,symbol:zb,null:Db,undefined:Ob,void:Pb,never:Mb,any:Fb,unknown:Ub,date:Gb,enum:jb,literal:Zb,nan:Bb,template_literal:Hb,file:Vb,success:qb,custom:Wb,function:Kb,transform:Jb,map:Yb,set:Xb,array:Qb,object:ew,union:fd,intersection:tw,tuple:nw,record:rw,nullable:iw,nonoptional:ow,default:aw,prefault:uw,catch:cw,pipe:lw,readonly:dw,promise:fw,optional:pd,lazy:hw};function md(e,t){if("_idmap"in e){const r=e,i=hr({...t,processors:lc}),o={};for(const u of r._idmap.entries()){const[c,l]=u;Ue(l,i)}const s={},a={registry:r,uri:t?.uri,defs:o};i.external=a;for(const u of r._idmap.entries()){const[c,l]=u;pr(i,l),Lt(s,c,mr(i,l))}if(Object.keys(o).length>0){const u=i.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[u]:o}}return{schemas:s}}const n=hr({...t,processors:lc});return Ue(e,n),pr(n,e),mr(n,e)}class Fx{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let n=t?.target??"draft-2020-12";n==="draft-4"&&(n="draft-04"),n==="draft-7"&&(n="draft-07"),this.ctx=hr({processors:lc,target:n,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,n={path:[],schemaPath:[]}){return Ue(t,this.ctx,n)}emit(t,n){n&&(n.cycles&&(this.ctx.cycles=n.cycles),n.reused&&(this.ctx.reused=n.reused),n.external&&(this.ctx.external=n.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,pr(this.ctx,t);const r=mr(this.ctx,t),{"~standard":i,...o}=r;return o}}const Ux=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),pw=Object.freeze(Object.defineProperty({__proto__:null,$ZodAny:Yy,$ZodArray:nv,$ZodAsyncError:cn,$ZodBase64:Fy,$ZodBase64URL:Uy,$ZodBigInt:$l,$ZodBigIntFormat:qy,$ZodBoolean:El,$ZodCIDRv4:Py,$ZodCIDRv6:My,$ZodCUID:Ey,$ZodCUID2:$y,$ZodCatch:xv,$ZodCheck:Ve,$ZodCheckBigIntFormat:Qg,$ZodCheckEndsWith:dy,$ZodCheckGreaterThan:ll,$ZodCheckIncludes:cy,$ZodCheckLengthEquals:oy,$ZodCheckLessThan:cl,$ZodCheckLowerCase:ay,$ZodCheckMaxLength:ry,$ZodCheckMaxSize:ey,$ZodCheckMimeType:py,$ZodCheckMinLength:iy,$ZodCheckMinSize:ty,$ZodCheckMultipleOf:Yg,$ZodCheckNumberFormat:Xg,$ZodCheckOverwrite:my,$ZodCheckProperties:hy,$ZodCheckProperty:fy,$ZodCheckRegex:sy,$ZodCheckSizeEquals:ny,$ZodCheckStartsWith:ly,$ZodCheckStringFormat:Bi,$ZodCheckUpperCase:uy,$ZodCodec:Nl,$ZodCreditCard:jy,$ZodCustom:Nv,$ZodCustomStringFormat:Hy,$ZodCyclicError:Rv,$ZodDate:tv,$ZodDefault:wv,$ZodDiscriminatedUnion:cv,$ZodE164:Gy,$ZodEmail:wy,$ZodEmoji:Sy,$ZodEncodeError:Vs,$ZodEnum:pv,$ZodError:dg,$ZodExactOptional:vv,$ZodFile:gv,$ZodFunction:Av,$ZodGUID:vy,$ZodIBAN:Zy,$ZodIPv4:zy,$ZodIPv6:Dy,$ZodISODate:Ny,$ZodISODateTime:Iy,$ZodISODuration:Ly,$ZodISOTime:Ry,$ZodIntersection:lv,$ZodJWT:By,$ZodKSUID:Ay,$ZodLazy:Rl,$ZodLiteral:mv,$ZodMAC:Oy,$ZodMap:fv,$ZodNaN:Ev,$ZodNanoID:xy,$ZodNever:Qy,$ZodNonOptional:kv,$ZodNull:Jy,$ZodNullable:bv,$ZodNumber:xl,$ZodNumberFormat:Vy,$ZodObject:ov,$ZodObjectJIT:sv,$ZodOptional:Al,$ZodPipe:Il,$ZodPrefault:_v,$ZodPreprocess:$v,$ZodPromise:Iv,$ZodReadonly:Tv,$ZodRealError:zt,$ZodRecord:dv,$ZodRegistry:Dv,$ZodSet:hv,$ZodString:Hi,$ZodStringFormat:je,$ZodSuccess:Sv,$ZodSymbol:Wy,$ZodTemplateLiteral:Cv,$ZodTransform:yv,$ZodTuple:Cl,$ZodType:we,$ZodULID:Ty,$ZodURL:ky,$ZodUUID:by,$ZodUndefined:Ky,$ZodUnion:na,$ZodUnknown:Xy,$ZodVoid:ev,$ZodXID:Cy,$ZodXor:av,$brand:Vc,$constructor:S,$input:Pl,$output:Ol,Doc:dl,INVALID:St,JSONSchema:Ux,JSONSchemaGenerator:Fx,NEVER:Hc,TimePrecision:ad,URL_BAD_FORMAT:hl,URL_UNPARSEABLE:wi,ZodCompileAsyncError:mn,ZodCompileUnsupportedError:ze,_any:sb,_array:hb,_base64:rd,_base64url:id,_bigint:Qv,_boolean:Yv,_catch:Cx,_check:vb,_cidrv4:td,_cidrv6:nd,_coercedBigint:eb,_coercedBoolean:Xv,_coercedDate:db,_coercedNumber:Hv,_coercedString:Uv,_creditCard:jv,_cuid:Wl,_cuid2:Kl,_custom:mb,_date:lb,_decode:Jc,_decodeAsync:Xc,_default:Ex,_discriminatedUnion:hx,_e164:od,_email:Ul,_emoji:Vl,_encode:Kc,_encodeAsync:Yc,_endsWith:Yi,_enum:bx,_file:pb,_float32:qv,_float64:Wv,_gt:yn,_gte:Rt,_guid:Gl,_iban:Zv,_includes:Ki,_int:Vv,_int32:Kv,_int64:tb,_intersection:px,_ipv4:Ql,_ipv6:ed,_isoDate:cd,_isoDateTime:ud,_isoDuration:dd,_isoTime:ld,_jwt:sd,_ksuid:Xl,_lazy:Rx,_length:Ar,_literal:_x,_lowercase:qi,_lt:gn,_lte:Nt,_mac:Gv,_map:yx,_max:Nt,_maxLength:Cr,_maxSize:er,_mime:Qi,_min:Rt,_minLength:Rn,_minSize:vn,_multipleOf:Jn,_nan:fb,_nanoid:ql,_nativeEnum:wx,_negative:la,_never:ub,_nonnegative:fa,_nonoptional:$x,_nonpositive:da,_normalize:eo,_null:ob,_nullable:xx,_number:Bv,_optional:Sx,_overwrite:on,_parse:Mi,_parseAsync:Fi,_pipe:Ax,_positive:ca,_promise:Lx,_properties:Xi,_property:ha,_readonly:Ix,_record:gx,_refine:gb,_regex:Vi,_safeDecode:el,_safeDecodeAsync:nl,_safeEncode:Qc,_safeEncodeAsync:tl,_safeParse:Ui,_safeParseAsync:Gi,_set:vx,_size:Tr,_slugify:io,_startsWith:Ji,_string:Fv,_stringFormat:Ir,_stringbool:_b,_success:Tx,_superRefine:yb,_symbol:rb,_templateLiteral:Nx,_toLowerCase:no,_toUpperCase:ro,_transform:kx,_trim:to,_tuple:mx,_uint32:Jv,_uint64:nb,_ulid:Jl,_undefined:ib,_union:dx,_unknown:ab,_uppercase:Wi,_url:ua,_uuid:jl,_uuidv4:Zl,_uuidv6:Bl,_uuidv7:Hl,_void:cb,_xid:Yl,_xor:fx,base64Charset:bl,base64urlCharset:ta,canParseURL:pl,clone:He,compile:Ml,compileFn:sa,config:nt,createStandardJSONSchemaMethod:ki,createToJSONSchemaMethod:xb,decode:SS,decodeAsync:ES,describe:bb,encode:kS,encodeAsync:xS,extractDefs:pr,finalize:mr,flattenError:qs,formatError:Ws,getDiscriminatedOption:Tl,globalConfig:kt,globalRegistry:At,handleUnrepresentable:ot,initializeContext:hr,isBackEdge:zl,isRecursiveSchema:Ll,isValidBase64:ea,isValidBase64URL:wl,isValidCIDRv6:vl,isValidCreditCard:_l,isValidIBAN:kl,isValidIPv6:Qs,isValidJWT:Sl,locales:Dl,memoizer:ra,mergeValues:_i,meta:wb,parse:ec,parseAsync:tc,parseURLObject:_y,prettifyError:Wc,process:Ue,processSchema:Ue,regexes:Xs,registry:ia,safeDecode:TS,safeDecodeAsync:AS,safeEncode:$S,safeEncodeAsync:CS,safeParse:hg,safeParseAsync:vS,standardProps:fl,stripTabAndNewline:xs,toDotPath:fg,toJSONSchema:md,toZod:Us,treeifyError:qc,urlHostnameOk:gl,urlProtocolOk:yl,util:Bc,validate:Js,validateAsync:Ys,validateURL:ml,version:gy,withParser:oa},Symbol.toStringTag,{value:"Module"})),gp=Symbol("z.visit/resolving");function gd(e,t){const n=typeof t=="function"?t:(s,a)=>{const u=t[s._zod.def.type];return u?u(s,a):s},r=new Map;function i(s){const a=r.get(s);if(a===gp)return new Rl({type:"lazy",getter:()=>r.get(s)});if(a!==void 0)return a;r.set(s,gp);const u=o(s),c=n(u,u!==s);return r.set(s,c),c}function o(s){const a=s._zod.def;switch(a.type){case"object":{const c=a.shape,l=Object.keys(c);let d=!1;const h={};for(const p of l){const m=i(c[p]);m!==c[p]&&(d=!0),h[p]=m}let f=a.catchall;return a.catchall&&(f=i(a.catchall),f!==a.catchall&&(d=!0)),d?He(s,{...a,shape:h,catchall:f}):s}case"array":{const c=i(a.element);return c===a.element?s:He(s,{...a,element:c})}case"tuple":{const c=a.items;let l=!1;const d=[];for(const f of c){const p=i(f);p!==f&&(l=!0),d.push(p)}let h=a.rest;return a.rest&&(h=i(a.rest),h!==a.rest&&(l=!0)),l?He(s,{...a,items:d,rest:h}):s}case"record":case"map":{const c=i(a.keyType),l=i(a.valueType);return c===a.keyType&&l===a.valueType?s:He(s,{...a,keyType:c,valueType:l})}case"set":{const c=i(a.valueType);return c===a.valueType?s:He(s,{...a,valueType:c})}case"union":{const c=a.options;let l=!1;const d=[];for(const h of c){const f=i(h);f!==h&&(l=!0),d.push(f)}return l?He(s,{...a,options:d}):s}case"intersection":{const c=i(a.left),l=i(a.right);return c===a.left&&l===a.right?s:He(s,{...a,left:c,right:l})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{const c=i(a.innerType);return c===a.innerType?s:He(s,{...a,innerType:c})}case"pipe":{const c=i(a.in),l=i(a.out);return c===a.in&&l===a.out?s:He(s,{...a,in:c,out:l})}case"function":{const c=i(a.input),l=i(a.output);return c===a.input&&l===a.output?s:He(s,{...a,input:c,output:l})}case"lazy":{const c=a.getter,{_cachedInner:l,...d}=a;return He(s,{...d,getter:()=>i(c())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return s;default:return s}}return i(e)}function yd(e){return!!e._zod}function mw(e,t){return yd(e)?hg(e,t):e.safeParse(t)}function Gx(e){if(!e)return;let t;if(yd(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function jx(e){if(yd(e)){const o=e._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}const n=e._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}const r=e.value;if(r!==void 0)return r}const Zx=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(o){return e[o]??null}const n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function i(o,s){return o==="number"&&typeof s=="number"&&!Number.isFinite(s)?String(s):r[o]??o}return o=>{switch(o.code){case"invalid_type":{const s=i(o.expected),a=og(o.input),u=i(a,o.input);return`Invalid input: expected ${s}, received ${u}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${Fc(o.values[0])}`:`Invalid option: expected one of ${Yu(o.values,"|")}`;case"too_big":{const s=o.exact?"exactly ":o.inclusive?"<=":"<",a=t(o.origin);return a?`Too big: expected ${o.origin??"value"} to have ${s}${o.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${s}${o.maximum.toString()}`}case"too_small":{const s=o.exact?"exactly ":o.inclusive?">=":">",a=t(o.origin);return a?`Too small: expected ${o.origin} to have ${s}${o.minimum.toString()} ${a.unit}`:`Too small: expected ${o.origin} to be ${s}${o.minimum.toString()}`}case"invalid_format":{const s=o;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${n[s.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${Yu(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(a=>`'${a}'`).join(" | ")}`:o.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function Bx(){return{localeError:Zx()}}const Hx=Object.freeze(Object.defineProperty({__proto__:null,endsWith:Yi,gt:yn,gte:Rt,includes:Ki,length:Ar,lowercase:qi,lt:gn,lte:Nt,maxLength:Cr,maxSize:er,mime:Qi,minLength:Rn,minSize:vn,multipleOf:Jn,negative:la,nonnegative:fa,nonpositive:da,normalize:eo,overwrite:on,positive:ca,properties:Xi,property:ha,regex:Vi,size:Tr,slugify:io,startsWith:Ji,toLowerCase:no,toUpperCase:ro,trim:to,uppercase:Wi},Symbol.toStringTag,{value:"Module"})),yp=new WeakSet([Object.prototype,Error.prototype]);function Ko(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}const gw=(e,t)=>{dg.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);yp.has(n)||(yp.add(n),Ko(n,"format",r=>i=>Ws(r,i)),Ko(n,"flatten",r=>i=>qs(r,i)),Ko(n,"addIssue",r=>i=>{r.issues.push(i),r.message=JSON.stringify(r.issues,ws,2)}),Ko(n,"addIssues",r=>i=>{r.issues.push(...i),r.message=JSON.stringify(r.issues,ws,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},yw=S("ZodError",gw),$t=S("ZodError",gw,void 0,{Parent:Error}),vd=Mi($t),bd=Fi($t),wd=Ui($t),_d=Gi($t),kd=Kc($t),Sd=Jc($t),xd=Yc($t),Ed=Xc($t),$d=Qc($t),Td=el($t),Cd=tl($t),Ad=nl($t);function Vx(){kt.localeError||nt(Bx())}function tr(){kt.memoizer||nt({memoizer:ra()})}const ke=S("ZodType",(e,t)=>(Vx(),we.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(pt(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return He(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(tu(e,t))},superRefine(e,t){return this.check(nu(e,t))},overwrite(e){return this.check(on(e))},optional(){return Ze(this)},exactOptional(){return Da(this)},nullable(){return br(this)},nullish(){return Ze(br(this))},nonoptional(e){return Ga(this,e)},array(){return fe(this)},or(e){return Te([this,e])},and(e){return jr(this,e)},transform(e){return Ei(this,Ao(e))},default(e){return Ma(this,e)},prefault(e){return Ua(this,e)},catch(e){return Ba(this,e)},pipe(e){return Ei(this,e)},readonly(){return Wa(this)},describe(e){const t=this.clone();return At.add(t,{description:e}),t},meta(...e){if(e.length===0)return At.get(this);const t=this.clone();return At.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Hs(this,"~standard",{...fl(this),jsonSchema:{input:ki(this,"input"),output:ki(this,"output")}})},set"~standard"(e){pn(this,"~standard",e)},parse:function e(t,n){return vd(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await bd(this,t,n,{callee:e})},safeParse(e,t){return wd(this,e,t)},async safeParseAsync(e,t){return _d(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){pn(this,"spa",e)},validate(e,t){return Js(this,e,t)},validateAsync(e,t){return Ys(this,e,t)},encode:function e(t,n){return kd(this,t,n,{callee:e})},decode:function e(t,n){return Sd(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await xd(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Ed(this,t,n,{callee:e})},safeEncode(e,t){return $d(this,e,t)},safeDecode(e,t){return Td(this,e,t)},async safeEncodeAsync(e,t){return Cd(this,e,t)},async safeDecodeAsync(e,t){return Ad(this,e,t)},toJSONSchema(e){return xb(this,{})(e)},get description(){return At.get(this)?.description},get _def(){return this._zod.def}}),oo=S("_ZodString",(e,t)=>{Hi.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ib(e,n,r)},Pi({format:e=>it(e).format??null,minLength:e=>it(e).minimum??null,maxLength:e=>it(e).maximum??null},{regex(...e){return this.check(Vi(...e))},includes(...e){return this.check(Ki(...e))},startsWith(...e){return this.check(Ji(...e))},endsWith(...e){return this.check(Yi(...e))},min(...e){return this.check(Rn(...e))},max(...e){return this.check(Cr(...e))},length(...e){return this.check(Ar(...e))},nonempty(...e){return this.check(Rn(1,...e))},lowercase(e){return this.check(qi(e))},uppercase(e){return this.check(Wi(e))},trim(){return this.check(to())},normalize(...e){return this.check(eo(...e))},toLowerCase(){return this.check(no())},toUpperCase(){return this.check(ro())},slugify(){return this.check(io())}})),Nr=S("ZodString",(e,t)=>{Hi.init(e,t),oo.init(e,t)},{email(e){return this.check(Ul(so,e))},url(e){return this.check(ua(Or,e))},jwt(e){return this.check(sd(So,e))},emoji(e){return this.check(Vl(uo,e))},guid(e){return this.check(Gl(ao,e))},uuid(e){return this.check(jl(en,e))},uuidv4(e){return this.check(Zl(en,e))},uuidv6(e){return this.check(Bl(en,e))},uuidv7(e){return this.check(Hl(en,e))},nanoid(e){return this.check(ql(co,e))},cuid(e){return this.check(Wl(lo,e))},cuid2(e){return this.check(Kl(fo,e))},ulid(e){return this.check(Jl(ho,e))},base64(e){return this.check(rd(wo,e))},base64url(e){return this.check(id(_o,e))},xid(e){return this.check(Yl(po,e))},ksuid(e){return this.check(Xl(mo,e))},ipv4(e){return this.check(Ql(go,e))},ipv6(e){return this.check(ed(yo,e))},cidrv4(e){return this.check(td(vo,e))},cidrv6(e){return this.check(nd(bo,e))},e164(e){return this.check(od(ko,e))},datetime(e){return this.check(ud(Rr,e))},date(e){return this.check(cd(Lr,e))},time(e){return this.check(ld(zr,e))},duration(e){return this.check(dd(Dr,e))}});function E(e){return Fv(Nr,e)}const Me=S("ZodStringFormat",(e,t)=>{je.init(e,t),oo.init(e,t)}),Rr=S("ZodISODateTime",(e,t)=>{Iy.init(e,t),Me.init(e,t)}),Lr=S("ZodISODate",(e,t)=>{Ny.init(e,t),Me.init(e,t)}),zr=S("ZodISOTime",(e,t)=>{Ry.init(e,t),Me.init(e,t)}),Dr=S("ZodISODuration",(e,t)=>{Ly.init(e,t),Me.init(e,t)}),so=S("ZodEmail",(e,t)=>{wy.init(e,t),Me.init(e,t)});function Id(e){return Ul(so,e)}const ao=S("ZodGUID",(e,t)=>{vy.init(e,t),Me.init(e,t)});function Nd(e){return Gl(ao,e)}const en=S("ZodUUID",(e,t)=>{by.init(e,t),Me.init(e,t)});function Rd(e){return jl(en,e)}function Ld(e){return Zl(en,e)}function zd(e){return Bl(en,e)}function Dd(e){return Hl(en,e)}const Or=S("ZodURL",(e,t)=>{ky.init(e,t),Me.init(e,t)});function Od(e){return ua(Or,e)}function Pd(e){return ua(Or,{protocol:rl,hostname:Dg,...z(e)})}const uo=S("ZodEmoji",(e,t)=>{Sy.init(e,t),Me.init(e,t)});function Md(e){return Vl(uo,e)}const co=S("ZodNanoID",(e,t)=>{xy.init(e,t),Me.init(e,t)});function Fd(e){return ql(co,e)}const lo=S("ZodCUID",(e,t)=>{Ey.init(e,t),Me.init(e,t)});function Ud(e){return Wl(lo,e)}const fo=S("ZodCUID2",(e,t)=>{$y.init(e,t),Me.init(e,t)});function Gd(e){return Kl(fo,e)}const ho=S("ZodULID",(e,t)=>{Ty.init(e,t),Me.init(e,t)});function jd(e){return Jl(ho,e)}const po=S("ZodXID",(e,t)=>{Cy.init(e,t),Me.init(e,t)});function Zd(e){return Yl(po,e)}const mo=S("ZodKSUID",(e,t)=>{Ay.init(e,t),Me.init(e,t)});function Bd(e){return Xl(mo,e)}const go=S("ZodIPv4",(e,t)=>{zy.init(e,t),Me.init(e,t)});function Hd(e){return Ql(go,e)}const pa=S("ZodMAC",(e,t)=>{Oy.init(e,t),Me.init(e,t)});function Vd(e){return Gv(pa,e)}const yo=S("ZodIPv6",(e,t)=>{Dy.init(e,t),Me.init(e,t)});function qd(e){return ed(yo,e)}const vo=S("ZodCIDRv4",(e,t)=>{Py.init(e,t),Me.init(e,t)});function Wd(e){return td(vo,e)}const bo=S("ZodCIDRv6",(e,t)=>{My.init(e,t),Me.init(e,t)});function Kd(e){return nd(bo,e)}const wo=S("ZodBase64",(e,t)=>{Fy.init(e,t),Me.init(e,t)});function Jd(e){return rd(wo,e)}const _o=S("ZodBase64URL",(e,t)=>{Uy.init(e,t),Me.init(e,t)});function Yd(e){return id(_o,e)}const ko=S("ZodE164",(e,t)=>{Gy.init(e,t),Me.init(e,t)});function Xd(e){return od(ko,e)}const ma=S("ZodCreditCard",(e,t)=>{jy.init(e,t),Me.init(e,t)});function Qd(e){return jv(ma,e)}const ga=S("ZodIBAN",(e,t)=>{Zy.init(e,t),Me.init(e,t)});function ef(e){return Zv(ga,e)}const So=S("ZodJWT",(e,t)=>{By.init(e,t),Me.init(e,t)});function tf(e){return sd(So,e)}const zn=S("ZodCustomStringFormat",(e,t)=>{Hy.init(e,t),Me.init(e,t)});function nf(e,t,n={}){return Ir(zn,e,t,n)}function rf(e){return Ir(zn,"hostname",zg,e)}function of(e){return Ir(zn,"hex",Jg,e)}function sf(e){return Ir(zn,"currency_code",Pg,e)}function af(e,t){const n=t?.enc??"hex",r=`${e}_${n}`,i=Xs[r];if(!i)throw new Error(`Unrecognized hash format: ${r}`);return Ir(zn,r,i,t)}const Pr=S("ZodNumber",(e,t)=>{xl.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Nb(e,n,r,i),e.isFinite=!0},Pi({minValue:e=>{const{minimum:t,exclusiveMinimum:n}=it(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{const{maximum:t,exclusiveMaximum:n}=it(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{const{isInt:t,multipleOf:n}=it(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>it(e).format??null},{gt(e,t){return this.check(yn(e,t))},gte(e,t){return this.check(Rt(e,t))},min(e,t){return this.check(Rt(e,t))},lt(e,t){return this.check(gn(e,t))},lte(e,t){return this.check(Nt(e,t))},max(e,t){return this.check(Nt(e,t))},int(e){return this.check(xi(e))},safe(e){return this.check(xi(e))},positive(e){return this.check(yn(0,e))},nonnegative(e){return this.check(Rt(0,e))},negative(e){return this.check(gn(0,e))},nonpositive(e){return this.check(Nt(0,e))},multipleOf(e,t){return this.check(Jn(e,t))},step(e,t){return this.check(Jn(e,t))},finite(){return this}}));function _e(e){return Bv(Pr,e)}const Dn=S("ZodNumberFormat",(e,t)=>{Vy.init(e,t),Pr.init(e,t)});function xi(e){return Vv(Dn,e)}function uf(e){return qv(Dn,e)}function cf(e){return Wv(Dn,e)}function lf(e){return Kv(Dn,e)}function df(e){return Jv(Dn,e)}const Mr=S("ZodBoolean",(e,t)=>{El.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Rb(e,n,r)});function Pe(e){return Yv(Mr,e)}const Fr=S("ZodBigInt",(e,t)=>{$l.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Lb(e,n,r,i)},Pi({minValue:e=>it(e).minimum??null,maxValue:e=>it(e).maximum??null,format:e=>it(e).format??null},{gte(e,t){return this.check(Rt(e,t))},min(e,t){return this.check(Rt(e,t))},gt(e,t){return this.check(yn(e,t))},lt(e,t){return this.check(gn(e,t))},lte(e,t){return this.check(Nt(e,t))},max(e,t){return this.check(Nt(e,t))},positive(e){return this.check(yn(BigInt(0),e))},negative(e){return this.check(gn(BigInt(0),e))},nonpositive(e){return this.check(Nt(BigInt(0),e))},nonnegative(e){return this.check(Rt(BigInt(0),e))},multipleOf(e,t){return this.check(Jn(e,t))}}));function ff(e){return Qv(Fr,e)}const xo=S("ZodBigIntFormat",(e,t)=>{qy.init(e,t),Fr.init(e,t)});function hf(e){return tb(xo,e)}function pf(e){return nb(xo,e)}const ya=S("ZodSymbol",(e,t)=>{Wy.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>zb(e,n,r,i)});function mf(e){return rb(ya,e)}const va=S("ZodUndefined",(e,t)=>{Ky.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ob(e,n,r,i)});function vr(e){return ib(va,e)}const ba=S("ZodNull",(e,t)=>{Jy.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Db(e,n,r)});function Eo(e){return ob(ba,e)}const wa=S("ZodAny",(e,t)=>{Yy.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Fb()});function $o(){return sb(wa)}const _a=S("ZodUnknown",(e,t)=>{Xy.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ub()});function Oe(){return ab(_a)}const ka=S("ZodNever",(e,t)=>{Qy.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Mb(e,n,r)});function Yn(e){return ub(ka,e)}const Sa=S("ZodVoid",(e,t)=>{ev.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Pb(e,n,r,i)});function gf(e){return cb(Sa,e)}const To=S("ZodDate",(e,t)=>{tv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Gb(e,n,r,i),e.min=(n,r)=>e.check(Rt(n,r)),e.max=(n,r)=>e.check(Nt(n,r))},Pi({minDate:e=>{const{minimum:t}=it(e);return t?new Date(t):null},maxDate:e=>{const{maximum:t}=it(e);return t?new Date(t):null}},{}));function yf(e){return lb(To,e)}const xa=S("ZodArray",(e,t)=>{tr(),nv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Qb(e,n,r,i),e.element=t.element},{min(e,t){return this.check(Rn(e,t))},nonempty(e){return this.check(Rn(1,e))},max(e,t){return this.check(Cr(e,t))},length(e,t){return this.check(Ar(e,t))},unwrap(){return this.element}});function fe(e,t){return hb(xa,e,t)}function vf(e){const t=e._zod.def.shape;return lt(Object.keys(t))}const Ur=S("ZodObject",(e,t)=>{tr(),sv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ew(e,n,r,i),cg(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return lt(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(pt(this._zod.def,{catchall:e}))},passthrough(){return this.clone(pt(this._zod.def,{catchall:Oe()}))},loose(){return this.clone(pt(this._zod.def,{catchall:Oe()}))},strict(){return this.clone(pt(this._zod.def,{catchall:Yn()}))},strip(){return this.clone(pt(this._zod.def,{catchall:void 0}))},extend(e){return Qm(this,e)},safeExtend(e){return tg(this,e)},merge(e){return ng(this,e)},pick(e){return Ym(this,e)},omit(e){return Xm(this,e)},partial(...e){return Xu(Zr,this,e[0])},exactPartial(...e){return Xu(Io,this,e[0],"exactPartial")},required(...e){return rg(No,this,e[0])}});function C(e,t){const n={type:"object",shape:e??{},...z(t)};return new Ur(n)}function bf(e,t){return new Ur({type:"object",shape:e,catchall:Yn(),...z(t)})}function ct(e,t){return new Ur({type:"object",shape:e,catchall:Oe(),...z(t)})}const Gr=S("ZodUnion",(e,t)=>{na.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fd(e,n,r,i),e.options=t.options});function Te(e,t){return new Gr({type:"union",options:e,...z(t)})}const Ea=S("ZodXor",(e,t)=>{Gr.init(e,t),av.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fd(e,n,r,i),e.options=t.options});function wf(e,t){return new Ea({type:"union",options:e,inclusive:!1,...z(t)})}const $a=S("ZodDiscriminatedUnion",(e,t)=>{Gr.init(e,t),cv.init(e,t)});function Co(e,t,n){return new $a({type:"union",options:t,discriminator:e,...z(n)})}const Ta=S("ZodIntersection",(e,t)=>{lv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>tw(e,n,r,i)});function jr(e,t){return new Ta({type:"intersection",left:e,right:t})}const Ca=S("ZodTuple",(e,t)=>{tr(),Cl.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nw(e,n,r,i)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){const e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new Zr({type:"optional",innerType:t}))})}});function Aa(e,t,n){const r=t instanceof we,i=r?n:t,o=r?t:null;return new Ca({type:"tuple",items:e,rest:o,...z(i)})}const Xn=S("ZodRecord",(e,t)=>{tr(),dv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rw(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function Ie(e,t,n){return!t||!t._zod?new Xn({type:"record",keyType:E(),valueType:e,...z(t)}):new Xn({type:"record",keyType:e,valueType:t,...z(n)})}function _f(e,t,n){return new Xn({type:"record",keyType:e,valueType:t,...z(n),partial:!0})}function kf(e,t,n){return new Xn({type:"record",keyType:e,valueType:t,mode:"loose",...z(n)})}const Ia=S("ZodMap",(e,t)=>{tr(),fv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Yb(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(vn(...n)),e.nonempty=n=>e.check(vn(1,n)),e.max=(...n)=>e.check(er(...n)),e.size=(...n)=>e.check(Tr(...n))});function Sf(e,t,n){return new Ia({type:"map",keyType:e,valueType:t,...z(n)})}const Na=S("ZodSet",(e,t)=>{tr(),hv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Xb(e,n,r,i),e.min=(...n)=>e.check(vn(...n)),e.nonempty=n=>e.check(vn(1,n)),e.max=(...n)=>e.check(er(...n)),e.size=(...n)=>e.check(Tr(...n))});function xf(e,t){return new Na({type:"set",valueType:e,...z(t)})}const Qn=S("ZodEnum",(e,t)=>{pv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(r,i,o)=>jb(e,r,i),e.enum=t.entries,e.options=[...e._zod.values];const n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{const o={};for(const s of r)if(n.has(s))o[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Qn({...t,checks:[],...z(i),entries:o})},e.exclude=(r,i)=>{const o={...t.entries};for(const s of r)if(n.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new Qn({...t,checks:[],...z(i),entries:o})}});function lt(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Qn({type:"enum",entries:n,...z(t)})}function Ef(e,t){return new Qn({type:"enum",entries:e,...z(t)})}const Ra=S("ZodLiteral",(e,t)=>{mv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Zb(e,n,r,i),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $(e,t){return new Ra({type:"literal",values:Array.isArray(e)?e:[e],...z(t)})}const La=S("ZodFile",(e,t)=>{gv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Vb(e,n,r),e.min=(n,r)=>e.check(vn(n,r)),e.max=(n,r)=>e.check(er(n,r)),e.mime=(n,r)=>e.check(Qi(Array.isArray(n)?n:[n],r))});function $f(e){return pb(La,e)}const za=S("ZodTransform",(e,t)=>{tr(),yv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Jb(e,n,r,i),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Vs(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(dr(o,n.value,t));else{const s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=e),n.issues.push(dr(s))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(o=>(n.value=o,n)):(n.value=i,n)}});function Ao(e){return new za({type:"transform",transform:e})}const Zr=S("ZodOptional",(e,t)=>{Al.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>pd(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Ze(e){return new Zr({type:"optional",innerType:e})}const Io=S("ZodExactOptional",(e,t)=>{vv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>pd(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Da(e){return new Io({type:"optional",innerType:e})}const Oa=S("ZodNullable",(e,t)=>{bv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>iw(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function br(e){return new Oa({type:"nullable",innerType:e})}function Tf(e){return Ze(br(e))}const Pa=S("ZodDefault",(e,t)=>{wv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>aw(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ma(e,t){return new Pa({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Di(t)}})}const Fa=S("ZodPrefault",(e,t)=>{_v.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>uw(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Ua(e,t){return new Fa({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Di(t)}})}const No=S("ZodNonOptional",(e,t)=>{kv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ow(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Ga(e,t){return new No({type:"nonoptional",innerType:e,...z(t)})}const ja=S("ZodSuccess",(e,t)=>{Sv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>qb(e,n,r),e.unwrap=()=>e._zod.def.innerType});function Cf(e){return new ja({type:"success",innerType:e})}const Za=S("ZodCatch",(e,t)=>{xv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>cw(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ba(e,t){return new Za({type:"catch",innerType:e,catchValue:typeof t=="function"?t:Zc(t)})}const Ha=S("ZodNaN",(e,t)=>{Ev.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Bb(e,n,r,i)});function Af(e){return fb(Ha,e)}const Br=S("ZodPipe",(e,t)=>{Il.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lw(e,n,r,i),e.in=t.in,e.out=t.out});function Ei(e,t){return new Br({type:"pipe",in:e,out:t})}const Hr=S("ZodCodec",(e,t)=>{Br.init(e,t),Nl.init(e,t)});function If(e,t,n){return new Hr({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function Nf(e){const t=e._zod.def;return new Hr({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}const Va=S("ZodPreprocess",(e,t)=>{Br.init(e,t),$v.init(e,t)}),qa=S("ZodReadonly",(e,t)=>{Tv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>dw(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Wa(e){return new qa({type:"readonly",innerType:e})}const Ka=S("ZodTemplateLiteral",(e,t)=>{Cv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Hb(e,n,r)});function Rf(e,t){return new Ka({type:"template_literal",parts:e,...z(t)})}const Ja=S("ZodLazy",(e,t)=>{Rl.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hw(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function Ya(e){return new Ja({type:"lazy",getter:e})}const Xa=S("ZodPromise",(e,t)=>{Iv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fw(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Lf(e){return new Xa({type:"promise",innerType:e})}const Qa=S("ZodFunction",(e,t)=>{Av.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Kb(e,n,r,i)});function wr(e){return new Qa({type:"function",input:Array.isArray(e?.input)?Aa(e?.input):e?.input??fe(Oe()),output:e?.output??Oe()})}const Vr=S("ZodCustom",(e,t)=>{Nv.init(e,t),ke.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Wb(e,n,r,i)});function zf(e){const t=new Ve({check:"custom"});return t._zod.check=e,t}function eu(e,t){return mb(Vr,e??(()=>!0),t)}function tu(e,t={}){return gb(Vr,e,t)}function nu(e,t){return yb(e,t)}const Df=bb,Of=wb,ru=S("ZodInstanceOf",(e,t)=>{Vr.init(e,t)},{properties(e,t){return this.check(Xi(e,t))}});function Pf(e,t={}){const n=new ru({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...z(t)});return n._zod.bag.Class=e,n._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}const Mf=(...e)=>_b({Codec:Hr,Boolean:Mr,String:Nr},...e);function Ff(e){const t=Ya(()=>Te([E(e),_e(),Pe(),Eo(),fe(t),Ie(E(),t)]));return t}function Ro(e,t){return new Va({type:"pipe",in:Ao(e),out:t})}const qx=Object.freeze(Object.defineProperty({__proto__:null,ZodAny:wa,ZodArray:xa,ZodBase64:wo,ZodBase64URL:_o,ZodBigInt:Fr,ZodBigIntFormat:xo,ZodBoolean:Mr,ZodCIDRv4:vo,ZodCIDRv6:bo,ZodCUID:lo,ZodCUID2:fo,ZodCatch:Za,ZodCodec:Hr,ZodCreditCard:ma,ZodCustom:Vr,ZodCustomStringFormat:zn,ZodDate:To,ZodDefault:Pa,ZodDiscriminatedUnion:$a,ZodE164:ko,ZodEmail:so,ZodEmoji:uo,ZodEnum:Qn,ZodExactOptional:Io,ZodFile:La,ZodFunction:Qa,ZodGUID:ao,ZodIBAN:ga,ZodIPv4:go,ZodIPv6:yo,ZodISODate:Lr,ZodISODateTime:Rr,ZodISODuration:Dr,ZodISOTime:zr,ZodInstanceOf:ru,ZodIntersection:Ta,ZodJWT:So,ZodKSUID:mo,ZodLazy:Ja,ZodLiteral:Ra,ZodMAC:pa,ZodMap:Ia,ZodNaN:Ha,ZodNanoID:co,ZodNever:ka,ZodNonOptional:No,ZodNull:ba,ZodNullable:Oa,ZodNumber:Pr,ZodNumberFormat:Dn,ZodObject:Ur,ZodOptional:Zr,ZodPipe:Br,ZodPrefault:Fa,ZodPreprocess:Va,ZodPromise:Xa,ZodReadonly:qa,ZodRecord:Xn,ZodSet:Na,ZodString:Nr,ZodStringFormat:Me,ZodSuccess:ja,ZodSymbol:ya,ZodTemplateLiteral:Ka,ZodTransform:za,ZodTuple:Ca,ZodType:ke,ZodULID:ho,ZodURL:Or,ZodUUID:en,ZodUndefined:va,ZodUnion:Gr,ZodUnknown:_a,ZodVoid:Sa,ZodXID:po,ZodXor:Ea,_ZodString:oo,_default:Ma,_function:wr,any:$o,array:fe,base64:Jd,base64url:Yd,bigint:ff,boolean:Pe,catch:Ba,check:zf,cidrv4:Wd,cidrv6:Kd,codec:If,creditCard:Qd,cuid:Ud,cuid2:Gd,currencyCode:sf,custom:eu,date:yf,describe:Df,discriminatedUnion:Co,e164:Xd,email:Id,emoji:Md,enum:lt,exactOptional:Da,file:$f,float32:uf,float64:cf,function:wr,guid:Nd,hash:af,hex:of,hostname:rf,httpUrl:Pd,iban:ef,instanceof:Pf,int:xi,int32:lf,int64:hf,intersection:jr,invertCodec:Nf,ipv4:Hd,ipv6:qd,json:Ff,jwt:tf,keyof:vf,ksuid:Bd,lazy:Ya,literal:$,looseObject:ct,looseRecord:kf,mac:Vd,map:Sf,meta:Of,nan:Af,nanoid:Fd,nativeEnum:Ef,never:Yn,nonoptional:Ga,null:Eo,nullable:br,nullish:Tf,number:_e,object:C,optional:Ze,partialRecord:_f,pipe:Ei,prefault:Ua,preprocess:Ro,promise:Lf,readonly:Wa,record:Ie,refine:tu,set:xf,strictObject:bf,string:E,stringFormat:nf,stringbool:Mf,success:Cf,superRefine:nu,symbol:mf,templateLiteral:Rf,transform:Ao,tuple:Aa,uint32:df,uint64:pf,ulid:jd,undefined:vr,union:Te,unknown:Oe,url:Od,uuid:Rd,uuidv4:Ld,uuidv6:zd,uuidv7:Dd,void:gf,xid:Zd,xor:wf},Symbol.toStringTag,{value:"Module"})),vw={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function bw(e){nt({customError:e})}function ww(){return nt().customError}var $s;$s||($s={});function _w(e){return ud(Rr,e)}function Wx(e){return cd(Lr,e)}function Kx(e){return ld(zr,e)}function Jx(e){return dd(Dr,e)}const Uf=Object.freeze(Object.defineProperty({__proto__:null,ZodISODate:Lr,ZodISODateTime:Rr,ZodISODuration:Dr,ZodISOTime:zr,date:Wx,datetime:_w,duration:Jx,time:Kx},Symbol.toStringTag,{value:"Module"})),W={...qx,...Hx,iso:Uf},Yx=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function Xx(e,t){const n=e.$schema;return n==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":n==="http://json-schema.org/draft-07/schema#"?"draft-7":n==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function vp(e,t){return e.map((n,r)=>r<t?n:n.optional())}function Qx(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function eE(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");const n=e.slice(1).split("/").filter(Boolean);if(n.length===0)return t.rootSchema;const r=t.version==="draft-2020-12"?"$defs":"definitions";if(n[0]===r){const i=n[1]===void 0?void 0:Qx(n[1]);if(!i||!t.defs[i])throw new Error(`Reference not found: ${e}`);return t.defs[i]}throw new Error(`Reference not found: ${e}`)}function tE(e,t){return W.transform(r=>r).check(r=>{const i=r.value;if(typeof i!="object"||i===null||Array.isArray(i))return;const o=Object.getOwnPropertyNames(i);if(t.minProperties!==void 0&&o.length<t.minProperties&&r.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:i,inst:e,continue:!0}),t.maxProperties!==void 0&&o.length>t.maxProperties&&r.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:i,inst:e,continue:!0}),t.keySchema)for(const s of o){const a=t.keySchema.safeParse(s);a.success||r.issues.push({code:"invalid_key",origin:"record",issues:a.error.issues,input:s,path:[s],continue:!0})}}).pipe(e)}function dc(e,t){if(e===null)return"z";const n=typeof e;if(n!=="object"){if(n==="number"&&Number.isNaN(e))return null;const r=String(e);return`${n[0]}${r.length}:${r}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){const o=[];for(const s of e){const a=dc(s,t);if(a===null)return null;o.push(a)}return`a${o.length}:[${o.join(",")}]`}const r=Object.keys(e).sort(),i=[];for(const o of r){const s=dc(e[o],t);if(s===null)return null;i.push(`${o.length}:${o}=${s}`)}return`o${i.length}:{${i.join(",")}}`}finally{t.delete(e)}}const nE=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),rE=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function fi(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(fi):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,n])=>nE.has(t)?fi(n):!rE.has(t)||typeof n!="object"||n===null?!1:Object.values(n).some(fi))}function bp(e){return e===1?"element":"elements"}function iE(e,t){return W.transform(r=>r).check(r=>{const i=r.value;if(Array.isArray(i)){if(t.uniqueItems===!0){const o=new Map;for(let s=0;s<i.length;s++){const a=dc(i[s],new Set);if(a===null)continue;const u=o.get(a);if(u===void 0){o.set(a,s);continue}r.issues.push({code:"custom",message:`Array items must be unique: element at index ${s} duplicates the one at index ${u}`,input:i,path:[s],continue:!0})}}if(t.containsSchema){const o=t.minContains??1,s=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY;let a=0;for(const u of i)if(t.containsSchema.safeParse(u).success&&++a>=s)break;a<o&&r.issues.push({code:"custom",message:`Array must contain at least ${o} matching ${bp(o)}; found ${a}`,input:i,continue:!0}),t.maxContains!==void 0&&a>t.maxContains&&r.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${bp(t.maxContains)}`,input:i,continue:!0})}}}).pipe(e)}function wp(e,t){if(e!==!1)return e===void 0||e===!0?W.any():_t(e,t)}const oE=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function kw(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return W.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){const i=e.$ref;if(t.refs.has(i))return t.refs.get(i);if(t.processing.has(i))return W.lazy(()=>{if(!t.refs.has(i))throw new Error(`Circular reference not resolved: ${i}`);return t.refs.get(i)});t.processing.add(i);const o=eE(i,t),s=_t(o,t);return t.refs.set(i,s),t.processing.delete(i),s}if(e.enum!==void 0){const i=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&i.length===1&&i[0]===null)return W.null();if(i.length===0)return W.never();if(i.length===1)return W.literal(i[0]);if(i.every(s=>typeof s=="string"))return W.enum(i);const o=i.map(s=>W.literal(s));return o.length<2?o[0]:W.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return W.literal(e.const);const n=e.type;if(Array.isArray(n)){const i=n.map(o=>{const s={...e,type:o};return kw(s,t)});return i.length===0?W.never():i.length===1?i[0]:W.union(i)}if(!n)return W.any();let r;switch(n){case"string":{let i=W.string();if(e.format){const o=e.format;o==="email"?i=i.check(W.email()):o==="uri"||o==="uri-reference"?i=i.check(W.url()):o==="uuid"||o==="guid"?i=i.check(W.uuid()):o==="date-time"?i=i.check(W.iso.datetime({offset:!0})):o==="date"?i=i.check(W.iso.date()):o==="time"?i=i.check(W.regex(oE)):o==="duration"?i=i.check(W.iso.duration()):o==="hostname"?i=i.check(W.hostname()):o==="ipv4"?i=i.check(W.ipv4()):o==="ipv6"?i=i.check(W.ipv6()):o==="mac"?i=i.check(W.mac()):o==="cidr"?i=i.check(W.cidrv4()):o==="cidr-v6"?i=i.check(W.cidrv6()):o==="base64"?i=i.check(W.base64()):o==="base64url"?i=i.check(W.base64url()):o==="e164"?i=i.check(W.e164()):o==="credit_card"?i=i.check(W.creditCard()):o==="iban"?i=i.check(W.iban()):o==="jwt"?i=i.check(W.jwt()):o==="emoji"?i=i.check(W.emoji()):o==="nanoid"?i=i.check(W.nanoid()):o==="cuid"?i=i.check(W.cuid()):o==="cuid2"?i=i.check(W.cuid2()):o==="ulid"?i=i.check(W.ulid()):o==="xid"?i=i.check(W.xid()):o==="ksuid"&&(i=i.check(W.ksuid()))}typeof e.minLength=="number"&&(i=i.min(e.minLength)),typeof e.maxLength=="number"&&(i=i.max(e.maxLength)),e.pattern&&(i=i.regex(new RegExp(e.pattern))),r=i;break}case"number":case"integer":{let i=n==="integer"?W.number().int():W.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(i=i.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(i=i.max(e.maximum)),typeof e.exclusiveMinimum=="number"?i=i.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(i=i.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?i=i.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(i=i.lt(e.maximum)),typeof e.multipleOf=="number"&&(i=i.multipleOf(e.multipleOf)),r=i;break}case"boolean":{r=W.boolean();break}case"null":{r=W.null();break}case"object":{const i={},o=e.properties||{},s=new Set(e.required||[]),a=typeof e.additionalProperties=="object"?_t(e.additionalProperties,t):void 0;for(const[d,h]of Object.entries(o)){const f=_t(h,t);Lt(i,d,s.has(d)?f:f.optional())}if(e.patternProperties){const d=e.patternProperties,h=Object.keys(d),f=[];for(const m of h){const y=_t(d[m],t),b=W.string().regex(new RegExp(m));f.push(W.looseRecord(b,y))}const p=[];if(Object.keys(i).length>0&&p.push(W.object(i).passthrough()),p.push(...f),p.length===0)r=W.object({}).passthrough();else if(p.length===1)r=p[0];else{let m=W.intersection(p[0],p[1]);for(let y=2;y<p.length;y++)m=W.intersection(m,p[y]);r=m}if(e.additionalProperties===!1){const m=Object.keys(i),y=h.map(g=>new RegExp(g)),b=r;r=r.check(g=>{if(!fn(g.value))return;const _=[];for(const v of Object.keys(g.value))m.includes(v)||y.some(w=>w.test(v))||_.push(v);_.length&&g.issues.push({code:"unrecognized_keys",keys:_,input:g.value,inst:b})})}}else{const d=W.object(i);e.additionalProperties===!1?r=d.strict():a?r=d.catchall(a):r=d.passthrough()}const u=e.propertyNames!==void 0&&e.propertyNames!==!0,c=typeof e.minProperties=="number"?e.minProperties:void 0,l=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(u||c!==void 0||l!==void 0){let d;if(u){const h=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;d=_t(h,t)}r=tE(r,{keySchema:d,minProperties:c,maxProperties:l})}break}case"array":{const i=e.prefixItems,o=e.items;if(i&&Array.isArray(i)){const s=typeof e.minItems=="number"?e.minItems:0,a=i.map(d=>_t(d,t)),u=vp(a,s),c=Array.isArray(o)?void 0:wp(o,t),l=W.tuple(u);r=c?l.rest(c):l,typeof e.minItems=="number"&&(r=r.check(W.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(W.maxLength(e.maxItems)))}else if(Array.isArray(o)){const s=typeof e.minItems=="number"?e.minItems:0,a=o.map(d=>_t(d,t)),u=vp(a,s),c=wp(e.additionalItems,t),l=W.tuple(u);r=c?l.rest(c):l,typeof e.minItems=="number"&&(r=r.check(W.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(W.maxLength(e.maxItems)))}else if(o!==void 0){const s=_t(o,t);let a=W.array(s);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),r=a}else r=W.array(W.any());(e.uniqueItems===!0||e.contains!==void 0)&&(r=iE(r,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?_t(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${n}`)}return r}function _t(e,t){if(typeof e=="boolean")return e?W.any():W.never();let n=kw(e,t);const r=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){const a=e.anyOf.map(c=>_t(c,t)),u=W.union(a);n=r?W.intersection(n,u):u}if(e.oneOf&&Array.isArray(e.oneOf)){const a=e.oneOf.map(c=>_t(c,t)),u=W.xor(a);n=r?W.intersection(n,u):u}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=r?n:W.any();else{let a=r?n:_t(e.allOf[0],t);const u=r?0:1;for(let c=u;c<e.allOf.length;c++)a=W.intersection(a,_t(e.allOf[c],t));n=a}e.nullable===!0&&t.version==="openapi-3.0"&&(n=W.nullable(n)),e.readOnly===!0&&(n=W.readonly(n)),e.default!==void 0&&(n=n.default(e.default));const i={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(const a of o)a in e&&(i[a]=e[a]);const s=["contentEncoding","contentMediaType","contentSchema"];for(const a of s)a in e&&(i[a]=e[a]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!fi(e.propertyNames)&&(i.propertyNames=e.propertyNames);for(const a of["minProperties","maxProperties"])e[a]!==void 0&&(i[a]=e[a])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!fi(e.contains)&&(i.contains=e.contains);for(const a of["uniqueItems","minContains","maxContains"])e[a]!==void 0&&(i[a]=e[a])}for(const a of Object.keys(e))Yx.has(a)||Lt(i,a,e[a]);return Object.keys(i).length>0&&t.registry.add(n,i),e.description&&(n=n.describe(e.description)),n}function Sw(e,t){if(typeof e=="boolean")return e?W.any():W.never();let n;try{n=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}const r=Xx(n,t?.defaultTarget),i=n.$defs||n.definitions||{},o={version:r,defs:i,refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??At};return _t(n,o)}function xw(e){return gd(e,{object:t=>t.partial(),union:t=>{const n=t._zod.def;return n.discriminator===void 0?t:Te(n.options)}})}function sE(e,t){if(!t?.length)return e;const n=e._zod.def;return He(e,pt(n,{checks:[...n.checks??[],...t]}),{parent:!0})}function Ew(e){return sE(e.out,e.checks)}function aE(e){return e.in._zod.traits.has("$ZodTransform")?Ew(e):e.in}function $w(e){return gd(e,{pipe:t=>aE(t._zod.def),default:(t,n)=>n?Ze(t._zod.def.innerType):t,catch:(t,n)=>n?t._zod.def.innerType:t})}function Tw(e){return gd(e,{pipe:t=>Ew(t._zod.def),prefault:(t,n)=>n?t._zod.def.innerType:t})}function uE(e){return Uv(Nr,e)}function cE(e){return Hv(Pr,e)}function lE(e){return Xv(Mr,e)}function dE(e){return eb(Fr,e)}function fE(e){return db(To,e)}const Cw=Object.freeze(Object.defineProperty({__proto__:null,bigint:dE,boolean:lE,date:fE,number:cE,string:uE},Symbol.toStringTag,{value:"Module"})),_p=Object.freeze(Object.defineProperty({__proto__:null,$brand:Vc,$input:Pl,$output:Ol,INVALID:St,NEVER:Hc,TimePrecision:ad,ZodAny:wa,ZodArray:xa,ZodBase64:wo,ZodBase64URL:_o,ZodBigInt:Fr,ZodBigIntFormat:xo,ZodBoolean:Mr,ZodCIDRv4:vo,ZodCIDRv6:bo,ZodCUID:lo,ZodCUID2:fo,ZodCatch:Za,ZodCodec:Hr,ZodCompileAsyncError:mn,ZodCompileUnsupportedError:ze,ZodCreditCard:ma,ZodCustom:Vr,ZodCustomStringFormat:zn,ZodDate:To,ZodDefault:Pa,ZodDiscriminatedUnion:$a,ZodE164:ko,ZodEmail:so,ZodEmoji:uo,ZodEnum:Qn,ZodError:yw,ZodExactOptional:Io,ZodFile:La,get ZodFirstPartyTypeKind(){return $s},ZodFunction:Qa,ZodGUID:ao,ZodIBAN:ga,ZodIPv4:go,ZodIPv6:yo,ZodISODate:Lr,ZodISODateTime:Rr,ZodISODuration:Dr,ZodISOTime:zr,ZodInstanceOf:ru,ZodIntersection:Ta,ZodIssueCode:vw,ZodJWT:So,ZodKSUID:mo,ZodLazy:Ja,ZodLiteral:Ra,ZodMAC:pa,ZodMap:Ia,ZodNaN:Ha,ZodNanoID:co,ZodNever:ka,ZodNonOptional:No,ZodNull:ba,ZodNullable:Oa,ZodNumber:Pr,ZodNumberFormat:Dn,ZodObject:Ur,ZodOptional:Zr,ZodPipe:Br,ZodPrefault:Fa,ZodPreprocess:Va,ZodPromise:Xa,ZodReadonly:qa,ZodRealError:$t,ZodRecord:Xn,ZodSet:Na,ZodString:Nr,ZodStringFormat:Me,ZodSuccess:ja,ZodSymbol:ya,ZodTemplateLiteral:Ka,ZodTransform:za,ZodTuple:Ca,ZodType:ke,ZodULID:ho,ZodURL:Or,ZodUUID:en,ZodUndefined:va,ZodUnion:Gr,ZodUnknown:_a,ZodVoid:Sa,ZodXID:po,ZodXor:Ea,_ZodString:oo,_default:Ma,_function:wr,any:$o,array:fe,base64:Jd,base64url:Yd,bigint:ff,boolean:Pe,catch:Ba,check:zf,cidrv4:Wd,cidrv6:Kd,clone:He,codec:If,coerce:Cw,compile:Ml,config:nt,core:pw,creditCard:Qd,cuid:Ud,cuid2:Gd,currencyCode:sf,custom:eu,date:yf,decode:Sd,decodeAsync:Ed,deepPartial:xw,describe:Df,discriminatedUnion:Co,e164:Xd,email:Id,emoji:Md,encode:kd,encodeAsync:xd,endsWith:Yi,enum:lt,exactOptional:Da,file:$f,flattenError:qs,float32:uf,float64:cf,formatError:Ws,fromJSONSchema:Sw,function:wr,getDiscriminatedOption:Tl,getErrorMap:ww,globalRegistry:At,gt:yn,gte:Rt,guid:Nd,hash:af,hex:of,hostname:rf,httpUrl:Pd,iban:ef,includes:Ki,input:$w,instanceof:Pf,int:xi,int32:lf,int64:hf,intersection:jr,invertCodec:Nf,ipv4:Hd,ipv6:qd,iso:Uf,json:Ff,jwt:tf,keyof:vf,ksuid:Bd,lazy:Ya,length:Ar,literal:$,locales:Dl,looseObject:ct,looseRecord:kf,lowercase:qi,lt:gn,lte:Nt,mac:Vd,map:Sf,maxLength:Cr,maxSize:er,memoizer:ra,meta:Of,mime:Qi,minLength:Rn,minSize:vn,multipleOf:Jn,nan:Af,nanoid:Fd,nativeEnum:Ef,negative:la,never:Yn,nonnegative:fa,nonoptional:Ga,nonpositive:da,normalize:eo,null:Eo,nullable:br,nullish:Tf,number:_e,object:C,optional:Ze,output:Tw,overwrite:on,parse:vd,parseAsync:bd,partialRecord:_f,pipe:Ei,positive:ca,prefault:Ua,preprocess:Ro,prettifyError:Wc,promise:Lf,properties:Xi,property:ha,readonly:Wa,record:Ie,refine:tu,regex:Vi,regexes:Xs,registry:ia,safeDecode:Td,safeDecodeAsync:Ad,safeEncode:$d,safeEncodeAsync:Cd,safeParse:wd,safeParseAsync:_d,set:xf,setErrorMap:bw,size:Tr,slugify:io,startsWith:Ji,strictObject:bf,string:E,stringFormat:nf,stringbool:Mf,success:Cf,superRefine:nu,symbol:mf,templateLiteral:Rf,toJSONSchema:md,toLowerCase:no,toUpperCase:ro,toZod:Us,transform:Ao,treeifyError:qc,trim:to,tuple:Aa,uint32:df,uint64:pf,ulid:jd,undefined:vr,union:Te,unknown:Oe,uppercase:Wi,url:Od,util:Bc,uuid:Rd,uuidv4:Ld,uuidv6:zd,uuidv7:Dd,validate:Js,validateAsync:Ys,void:gf,withParser:oa,xid:Zd,xor:wf},Symbol.toStringTag,{value:"Module"})),hE=Object.freeze(Object.defineProperty({__proto__:null,$brand:Vc,$input:Pl,$output:Ol,INVALID:St,NEVER:Hc,TimePrecision:ad,ZodAny:wa,ZodArray:xa,ZodBase64:wo,ZodBase64URL:_o,ZodBigInt:Fr,ZodBigIntFormat:xo,ZodBoolean:Mr,ZodCIDRv4:vo,ZodCIDRv6:bo,ZodCUID:lo,ZodCUID2:fo,ZodCatch:Za,ZodCodec:Hr,ZodCompileAsyncError:mn,ZodCompileUnsupportedError:ze,ZodCreditCard:ma,ZodCustom:Vr,ZodCustomStringFormat:zn,ZodDate:To,ZodDefault:Pa,ZodDiscriminatedUnion:$a,ZodE164:ko,ZodEmail:so,ZodEmoji:uo,ZodEnum:Qn,ZodError:yw,ZodExactOptional:Io,ZodFile:La,get ZodFirstPartyTypeKind(){return $s},ZodFunction:Qa,ZodGUID:ao,ZodIBAN:ga,ZodIPv4:go,ZodIPv6:yo,ZodISODate:Lr,ZodISODateTime:Rr,ZodISODuration:Dr,ZodISOTime:zr,ZodInstanceOf:ru,ZodIntersection:Ta,ZodIssueCode:vw,ZodJWT:So,ZodKSUID:mo,ZodLazy:Ja,ZodLiteral:Ra,ZodMAC:pa,ZodMap:Ia,ZodNaN:Ha,ZodNanoID:co,ZodNever:ka,ZodNonOptional:No,ZodNull:ba,ZodNullable:Oa,ZodNumber:Pr,ZodNumberFormat:Dn,ZodObject:Ur,ZodOptional:Zr,ZodPipe:Br,ZodPrefault:Fa,ZodPreprocess:Va,ZodPromise:Xa,ZodReadonly:qa,ZodRealError:$t,ZodRecord:Xn,ZodSet:Na,ZodString:Nr,ZodStringFormat:Me,ZodSuccess:ja,ZodSymbol:ya,ZodTemplateLiteral:Ka,ZodTransform:za,ZodTuple:Ca,ZodType:ke,ZodULID:ho,ZodURL:Or,ZodUUID:en,ZodUndefined:va,ZodUnion:Gr,ZodUnknown:_a,ZodVoid:Sa,ZodXID:po,ZodXor:Ea,_ZodString:oo,_default:Ma,_function:wr,any:$o,array:fe,base64:Jd,base64url:Yd,bigint:ff,boolean:Pe,catch:Ba,check:zf,cidrv4:Wd,cidrv6:Kd,clone:He,codec:If,coerce:Cw,compile:Ml,config:nt,core:pw,creditCard:Qd,cuid:Ud,cuid2:Gd,currencyCode:sf,custom:eu,date:yf,decode:Sd,decodeAsync:Ed,deepPartial:xw,default:_p,describe:Df,discriminatedUnion:Co,e164:Xd,email:Id,emoji:Md,encode:kd,encodeAsync:xd,endsWith:Yi,enum:lt,exactOptional:Da,file:$f,flattenError:qs,float32:uf,float64:cf,formatError:Ws,fromJSONSchema:Sw,function:wr,getDiscriminatedOption:Tl,getErrorMap:ww,globalRegistry:At,gt:yn,gte:Rt,guid:Nd,hash:af,hex:of,hostname:rf,httpUrl:Pd,iban:ef,includes:Ki,input:$w,instanceof:Pf,int:xi,int32:lf,int64:hf,intersection:jr,invertCodec:Nf,ipv4:Hd,ipv6:qd,iso:Uf,json:Ff,jwt:tf,keyof:vf,ksuid:Bd,lazy:Ya,length:Ar,literal:$,locales:Dl,looseObject:ct,looseRecord:kf,lowercase:qi,lt:gn,lte:Nt,mac:Vd,map:Sf,maxLength:Cr,maxSize:er,memoizer:ra,meta:Of,mime:Qi,minLength:Rn,minSize:vn,multipleOf:Jn,nan:Af,nanoid:Fd,nativeEnum:Ef,negative:la,never:Yn,nonnegative:fa,nonoptional:Ga,nonpositive:da,normalize:eo,null:Eo,nullable:br,nullish:Tf,number:_e,object:C,optional:Ze,output:Tw,overwrite:on,parse:vd,parseAsync:bd,partialRecord:_f,pipe:Ei,positive:ca,prefault:Ua,preprocess:Ro,prettifyError:Wc,promise:Lf,properties:Xi,property:ha,readonly:Wa,record:Ie,refine:tu,regex:Vi,regexes:Xs,registry:ia,safeDecode:Td,safeDecodeAsync:Ad,safeEncode:$d,safeEncodeAsync:Cd,safeParse:wd,safeParseAsync:_d,set:xf,setErrorMap:bw,size:Tr,slugify:io,startsWith:Ji,strictObject:bf,string:E,stringFormat:nf,stringbool:Mf,success:Cf,superRefine:nu,symbol:mf,templateLiteral:Rf,toJSONSchema:md,toLowerCase:no,toUpperCase:ro,toZod:Us,transform:Ao,treeifyError:qc,trim:to,tuple:Aa,uint32:df,uint64:pf,ulid:jd,undefined:vr,union:Te,unknown:Oe,uppercase:Wi,url:Od,util:Bc,uuid:Rd,uuidv4:Ld,uuidv6:zd,uuidv7:Dd,validate:Js,validateAsync:Ys,void:gf,withParser:oa,xid:Zd,xor:wf,z:_p},Symbol.toStringTag,{value:"Module"})),Bn="io.modelcontextprotocol/related-task",iu="2.0",tt=eu(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Aw=Te([E(),_e().int()]),Iw=E();ct({ttl:_e().optional(),pollInterval:_e().optional()});const pE=C({ttl:_e().optional()}),mE=C({taskId:E()}),Gf=ct({progressToken:Aw.optional(),[Bn]:mE.optional()}),Dt=C({_meta:Gf.optional()}),Lo=Dt.extend({task:pE.optional()}),gE=e=>Lo.safeParse(e).success,dt=C({method:E(),params:Dt.loose().optional()}),jt=C({_meta:Gf.optional()}),Zt=C({method:E(),params:jt.loose().optional()}),ft=ct({_meta:Gf.optional()}),zo=Te([E(),_e().int()]),Nw=C({jsonrpc:$(iu),id:zo,...dt.shape}).strict(),kp=e=>Nw.safeParse(e).success,Rw=C({jsonrpc:$(iu),...Zt.shape}).strict(),yE=e=>Rw.safeParse(e).success,jf=C({jsonrpc:$(iu),id:zo,result:ft}).strict(),Jo=e=>jf.safeParse(e).success;var De;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(De||(De={}));const Zf=C({jsonrpc:$(iu),id:zo.optional(),error:C({code:_e().int(),message:E(),data:Oe().optional()})}).strict(),vE=e=>Zf.safeParse(e).success,bE=Te([Nw,Rw,jf,Zf]);Te([jf,Zf]);const Bf=ft.strict(),wE=jt.extend({requestId:zo.optional(),reason:E().optional()}),Hf=Zt.extend({method:$("notifications/cancelled"),params:wE}),_E=C({src:E(),mimeType:E().optional(),sizes:fe(E()).optional(),theme:lt(["light","dark"]).optional()}),Do=C({icons:fe(_E).optional()}),_r=C({name:E(),title:E().optional()}),ou=_r.extend({..._r.shape,...Do.shape,version:E(),websiteUrl:E().optional(),description:E().optional()}),kE=jr(C({applyDefaults:Pe().optional()}),Ie(E(),Oe())),SE=Ro(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,jr(C({form:kE.optional(),url:tt.optional()}),Ie(E(),Oe()).optional())),xE=ct({list:tt.optional(),cancel:tt.optional(),requests:ct({sampling:ct({createMessage:tt.optional()}).optional(),elicitation:ct({create:tt.optional()}).optional()}).optional()}),EE=ct({list:tt.optional(),cancel:tt.optional(),requests:ct({tools:ct({call:tt.optional()}).optional()}).optional()}),$E=C({experimental:Ie(E(),tt).optional(),sampling:C({context:tt.optional(),tools:tt.optional()}).optional(),elicitation:SE.optional(),roots:C({listChanged:Pe().optional()}).optional(),tasks:xE.optional(),extensions:Ie(E(),tt).optional()}),TE=Dt.extend({protocolVersion:E(),capabilities:$E,clientInfo:ou}),CE=dt.extend({method:$("initialize"),params:TE}),AE=C({experimental:Ie(E(),tt).optional(),logging:tt.optional(),completions:tt.optional(),prompts:C({listChanged:Pe().optional()}).optional(),resources:C({subscribe:Pe().optional(),listChanged:Pe().optional()}).optional(),tools:C({listChanged:Pe().optional()}).optional(),tasks:EE.optional(),extensions:Ie(E(),tt).optional()}),IE=ft.extend({protocolVersion:E(),capabilities:AE,serverInfo:ou,instructions:E().optional()}),NE=Zt.extend({method:$("notifications/initialized"),params:jt.optional()}),su=dt.extend({method:$("ping"),params:Dt.optional()}),RE=C({progress:_e(),total:Ze(_e()),message:Ze(E())}),LE=C({...jt.shape,...RE.shape,progressToken:Aw}),Vf=Zt.extend({method:$("notifications/progress"),params:LE}),zE=Dt.extend({cursor:Iw.optional()}),Oo=dt.extend({params:zE.optional()}),Po=ft.extend({nextCursor:Iw.optional()}),DE=lt(["working","input_required","completed","failed","cancelled"]),Mo=C({taskId:E(),status:DE,ttl:Te([_e(),Eo()]),createdAt:E(),lastUpdatedAt:E(),pollInterval:Ze(_e()),statusMessage:Ze(E())}),qf=ft.extend({task:Mo}),OE=jt.merge(Mo),Ts=Zt.extend({method:$("notifications/tasks/status"),params:OE}),Wf=dt.extend({method:$("tasks/get"),params:Dt.extend({taskId:E()})}),Kf=ft.merge(Mo),Jf=dt.extend({method:$("tasks/result"),params:Dt.extend({taskId:E()})});ft.loose();const Yf=Oo.extend({method:$("tasks/list")}),Xf=Po.extend({tasks:fe(Mo)}),Qf=dt.extend({method:$("tasks/cancel"),params:Dt.extend({taskId:E()})}),PE=ft.merge(Mo),Lw=C({uri:E(),mimeType:Ze(E()),_meta:Ie(E(),Oe()).optional()}),zw=Lw.extend({text:E()}),eh=E().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Dw=Lw.extend({blob:eh}),Fo=lt(["user","assistant"]),qr=C({audience:fe(Fo).optional(),priority:_e().min(0).max(1).optional(),lastModified:_w({offset:!0}).optional()}),Ow=C({..._r.shape,...Do.shape,uri:E(),description:Ze(E()),mimeType:Ze(E()),size:Ze(_e()),annotations:qr.optional(),_meta:Ze(ct({}))}),ME=C({..._r.shape,...Do.shape,uriTemplate:E(),description:Ze(E()),mimeType:Ze(E()),annotations:qr.optional(),_meta:Ze(ct({}))}),FE=Oo.extend({method:$("resources/list")}),Pw=Po.extend({resources:fe(Ow)}),UE=Oo.extend({method:$("resources/templates/list")}),GE=Po.extend({resourceTemplates:fe(ME)}),th=Dt.extend({uri:E()}),jE=th,ZE=dt.extend({method:$("resources/read"),params:jE}),Mw=ft.extend({contents:fe(Te([zw,Dw]))}),BE=Zt.extend({method:$("notifications/resources/list_changed"),params:jt.optional()}),HE=th,VE=dt.extend({method:$("resources/subscribe"),params:HE}),qE=th,WE=dt.extend({method:$("resources/unsubscribe"),params:qE}),KE=jt.extend({uri:E()}),JE=Zt.extend({method:$("notifications/resources/updated"),params:KE}),YE=C({name:E(),description:Ze(E()),required:Ze(Pe())}),XE=C({..._r.shape,...Do.shape,description:Ze(E()),arguments:Ze(fe(YE)),_meta:Ze(ct({}))}),QE=Oo.extend({method:$("prompts/list")}),e$=Po.extend({prompts:fe(XE)}),t$=Dt.extend({name:E(),arguments:Ie(E(),E()).optional()}),n$=dt.extend({method:$("prompts/get"),params:t$}),nh=C({type:$("text"),text:E(),annotations:qr.optional(),_meta:Ie(E(),Oe()).optional()}),rh=C({type:$("image"),data:eh,mimeType:E(),annotations:qr.optional(),_meta:Ie(E(),Oe()).optional()}),ih=C({type:$("audio"),data:eh,mimeType:E(),annotations:qr.optional(),_meta:Ie(E(),Oe()).optional()}),r$=C({type:$("tool_use"),name:E(),id:E(),input:Ie(E(),Oe()),_meta:Ie(E(),Oe()).optional()}),Fw=C({type:$("resource"),resource:Te([zw,Dw]),annotations:qr.optional(),_meta:Ie(E(),Oe()).optional()}),Uw=Ow.extend({type:$("resource_link")}),Uo=Te([nh,rh,ih,Uw,Fw]),i$=C({role:Fo,content:Uo}),o$=ft.extend({description:E().optional(),messages:fe(i$)}),s$=Zt.extend({method:$("notifications/prompts/list_changed"),params:jt.optional()}),a$=C({title:E().optional(),readOnlyHint:Pe().optional(),destructiveHint:Pe().optional(),idempotentHint:Pe().optional(),openWorldHint:Pe().optional()}),u$=C({taskSupport:lt(["required","optional","forbidden"]).optional()}),oh=C({..._r.shape,...Do.shape,description:E().optional(),inputSchema:C({type:$("object"),properties:Ie(E(),tt).optional(),required:fe(E()).optional()}).catchall(Oe()),outputSchema:C({type:$("object"),properties:Ie(E(),tt).optional(),required:fe(E()).optional()}).catchall(Oe()).optional(),annotations:a$.optional(),execution:u$.optional(),_meta:Ie(E(),Oe()).optional()}),Gw=Oo.extend({method:$("tools/list")}),c$=Po.extend({tools:fe(oh)}),au=ft.extend({content:fe(Uo).default([]),structuredContent:Ie(E(),Oe()).optional(),isError:Pe().optional()});au.or(ft.extend({toolResult:Oe()}));const l$=Lo.extend({name:E(),arguments:Ie(E(),Oe()).optional()}),jw=dt.extend({method:$("tools/call"),params:l$}),d$=Zt.extend({method:$("notifications/tools/list_changed"),params:jt.optional()});C({autoRefresh:Pe().default(!0),debounceMs:_e().int().nonnegative().default(300)});const Zw=lt(["debug","info","notice","warning","error","critical","alert","emergency"]),f$=Dt.extend({level:Zw}),h$=dt.extend({method:$("logging/setLevel"),params:f$}),p$=jt.extend({level:Zw,logger:E().optional(),data:Oe()}),m$=Zt.extend({method:$("notifications/message"),params:p$}),g$=C({name:E().optional()}),y$=C({hints:fe(g$).optional(),costPriority:_e().min(0).max(1).optional(),speedPriority:_e().min(0).max(1).optional(),intelligencePriority:_e().min(0).max(1).optional()}),v$=C({mode:lt(["auto","required","none"]).optional()}),b$=C({type:$("tool_result"),toolUseId:E().describe("The unique identifier for the corresponding tool call."),content:fe(Uo).default([]),structuredContent:C({}).loose().optional(),isError:Pe().optional(),_meta:Ie(E(),Oe()).optional()}),w$=Co("type",[nh,rh,ih]),Cs=Co("type",[nh,rh,ih,r$,b$]),_$=C({role:Fo,content:Te([Cs,fe(Cs)]),_meta:Ie(E(),Oe()).optional()}),k$=Lo.extend({messages:fe(_$),modelPreferences:y$.optional(),systemPrompt:E().optional(),includeContext:lt(["none","thisServer","allServers"]).optional(),temperature:_e().optional(),maxTokens:_e().int(),stopSequences:fe(E()).optional(),metadata:tt.optional(),tools:fe(oh).optional(),toolChoice:v$.optional()}),S$=dt.extend({method:$("sampling/createMessage"),params:k$}),Bw=ft.extend({model:E(),stopReason:Ze(lt(["endTurn","stopSequence","maxTokens"]).or(E())),role:Fo,content:w$}),Hw=ft.extend({model:E(),stopReason:Ze(lt(["endTurn","stopSequence","maxTokens","toolUse"]).or(E())),role:Fo,content:Te([Cs,fe(Cs)])}),x$=C({type:$("boolean"),title:E().optional(),description:E().optional(),default:Pe().optional()}),E$=C({type:$("string"),title:E().optional(),description:E().optional(),minLength:_e().optional(),maxLength:_e().optional(),format:lt(["email","uri","date","date-time"]).optional(),default:E().optional()}),$$=C({type:lt(["number","integer"]),title:E().optional(),description:E().optional(),minimum:_e().optional(),maximum:_e().optional(),default:_e().optional()}),T$=C({type:$("string"),title:E().optional(),description:E().optional(),enum:fe(E()),default:E().optional()}),C$=C({type:$("string"),title:E().optional(),description:E().optional(),oneOf:fe(C({const:E(),title:E()})),default:E().optional()}),A$=C({type:$("string"),title:E().optional(),description:E().optional(),enum:fe(E()),enumNames:fe(E()).optional(),default:E().optional()}),I$=Te([T$,C$]),N$=C({type:$("array"),title:E().optional(),description:E().optional(),minItems:_e().optional(),maxItems:_e().optional(),items:C({type:$("string"),enum:fe(E())}),default:fe(E()).optional()}),R$=C({type:$("array"),title:E().optional(),description:E().optional(),minItems:_e().optional(),maxItems:_e().optional(),items:C({anyOf:fe(C({const:E(),title:E()}))}),default:fe(E()).optional()}),L$=Te([N$,R$]),z$=Te([A$,I$,L$]),D$=Te([z$,x$,E$,$$]),O$=Lo.extend({mode:$("form").optional(),message:E(),requestedSchema:C({type:$("object"),properties:Ie(E(),D$),required:fe(E()).optional()})}),P$=Lo.extend({mode:$("url"),message:E(),elicitationId:E(),url:E().url()}),M$=Te([O$,P$]),F$=dt.extend({method:$("elicitation/create"),params:M$}),U$=jt.extend({elicitationId:E()}),G$=Zt.extend({method:$("notifications/elicitation/complete"),params:U$}),j$=ft.extend({action:lt(["accept","decline","cancel"]),content:Ro(e=>e===null?void 0:e,Ie(E(),Te([E(),_e(),Pe(),fe(E())])).optional())}),Z$=C({type:$("ref/resource"),uri:E()}),B$=C({type:$("ref/prompt"),name:E()}),H$=Dt.extend({ref:Te([B$,Z$]),argument:C({name:E(),value:E()}),context:C({arguments:Ie(E(),E()).optional()}).optional()}),V$=dt.extend({method:$("completion/complete"),params:H$}),q$=ft.extend({completion:ct({values:fe(E()).max(100),total:Ze(_e().int()),hasMore:Ze(Pe())})}),W$=C({uri:E().startsWith("file://"),name:E().optional(),_meta:Ie(E(),Oe()).optional()}),K$=dt.extend({method:$("roots/list"),params:Dt.optional()}),J$=ft.extend({roots:fe(W$)}),Y$=Zt.extend({method:$("notifications/roots/list_changed"),params:jt.optional()});Te([su,CE,V$,h$,n$,QE,FE,UE,ZE,VE,WE,jw,Gw,Wf,Jf,Yf,Qf]);Te([Hf,Vf,NE,Y$,Ts]);Te([Bf,Bw,Hw,j$,J$,Kf,Xf,qf]);Te([su,S$,F$,K$,Wf,Jf,Yf,Qf]);Te([Hf,Vf,m$,JE,BE,d$,s$,Ts,G$]);Te([Bf,IE,q$,o$,e$,Pw,GE,Mw,au,c$,Kf,Xf,qf]);class Le extends Error{constructor(t,n,r){super(`MCP error ${t}: ${n}`),this.code=t,this.data=r,this.name="McpError"}static fromError(t,n,r){if(t===De.UrlElicitationRequired&&r){const i=r;if(i.elicitations)return new X$(i.elicitations,n)}return new Le(t,n,r)}}class X$ extends Le{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(De.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}}function Un(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Sp(e){const n=Gx(e)?.method;if(!n)throw new Error("Schema is missing a method literal");const r=jx(n);if(typeof r!="string")throw new Error("Schema method literal must be a string");return r}function xp(e,t){const n=mw(e,t);if(!n.success)throw n.error;return n.data}const Q$=6e4;class eT{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Hf,n=>{this._oncancel(n)}),this.setNotificationHandler(Vf,n=>{this._onprogress(n)}),this.setRequestHandler(su,n=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Wf,async(n,r)=>{const i=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!i)throw new Le(De.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(Jf,async(n,r)=>{const i=async()=>{const o=n.params.taskId;if(!await this._taskStore.getTask(o,r.sessionId))throw new Le(De.InvalidParams,`Task not found: ${o}`);if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(o,r.sessionId);){if(a.type==="response"||a.type==="error"){const u=a.message,c=u.id,l=this._requestResolvers.get(c);if(l)if(this._requestResolvers.delete(c),a.type==="response")l(u);else{const d=u,h=new Le(d.error.code,d.error.message,d.error.data);l(h)}else{const d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${c}`))}continue}await this._transport?.send(a.message,{relatedRequestId:r.requestId})}}const s=await this._taskStore.getTask(o,r.sessionId);if(!s)throw new Le(De.InvalidParams,`Task not found: ${o}`);if(!Un(s.status))return await this._waitForTaskUpdate(o,r.signal,r.sessionId),await i();if(Un(s.status)){const a=await this._taskStore.getTaskResult(o,r.sessionId);return this._clearTaskQueue(o,r.sessionId),{...a,_meta:{...a._meta,[Bn]:{taskId:o}}}}return await i()};return await i()}),this.setRequestHandler(Yf,async(n,r)=>{try{const{tasks:i,nextCursor:o}=await this._taskStore.listTasks(n.params?.cursor,r.sessionId);return{tasks:i,nextCursor:o,_meta:{}}}catch(i){throw new Le(De.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(Qf,async(n,r)=>{try{const i=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!i)throw new Le(De.InvalidParams,`Task not found: ${n.params.taskId}`);if(Un(i.status))throw new Le(De.InvalidParams,`Cannot cancel task in terminal status: ${i.status}`);await this._taskStore.updateTaskStatus(n.params.taskId,"cancelled","Client cancelled task execution.",r.sessionId),this._clearTaskQueue(n.params.taskId,r.sessionId);const o=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!o)throw new Le(De.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...o}}catch(i){throw i instanceof Le?i:new Le(De.InvalidRequest,`Failed to cancel task: ${i instanceof Error?i.message:String(i)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,n,r,i,o=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(i,n),startTime:Date.now(),timeout:n,maxTotalTimeout:r,resetTimeoutOnProgress:o,onTimeout:i})}_resetTimeout(t){const n=this._timeoutInfo.get(t);if(!n)return!1;const r=Date.now()-n.startTime;if(n.maxTotalTimeout&&r>=n.maxTotalTimeout)throw this._timeoutInfo.delete(t),Le.fromError(De.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:r});return clearTimeout(n.timeoutId),n.timeoutId=setTimeout(n.onTimeout,n.timeout),!0}_cleanupTimeout(t){const n=this._timeoutInfo.get(t);n&&(clearTimeout(n.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;const n=this.transport?.onclose;this._transport.onclose=()=>{n?.(),this._onclose()};const r=this.transport?.onerror;this._transport.onerror=o=>{r?.(o),this._onerror(o)};const i=this._transport?.onmessage;this._transport.onmessage=(o,s)=>{i?.(o,s),Jo(o)||vE(o)?this._onresponse(o):kp(o)?this._onrequest(o,s):yE(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const r of this._timeoutInfo.values())clearTimeout(r.timeoutId);this._timeoutInfo.clear();for(const r of this._requestHandlerAbortControllers.values())r.abort();this._requestHandlerAbortControllers.clear();const n=Le.fromError(De.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const r of t.values())r(n)}_onerror(t){this.onerror?.(t)}_onnotification(t){const n=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(t)).catch(r=>this._onerror(new Error(`Uncaught error in notification handler: ${r}`)))}_onrequest(t,n){const r=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,i=this._transport,o=t.params?._meta?.[Bn]?.taskId,s=i?.sessionId,a=this._taskStore;let u=!0,c;if(o&&a&&this._taskMessageQueue&&s!==void 0&&(u=!1,c=(async()=>{if(!await a.getTask(o,s))throw new Le(De.InvalidParams,`Task not found: ${o}`);u=!0})()),r===void 0){const p={jsonrpc:"2.0",id:t.id,error:{code:De.MethodNotFound,message:"Method not found"}};if(o&&c){const m={type:"error",message:p,timestamp:Date.now()};c.then(()=>this._enqueueTaskMessage(o,m,s),()=>i?.send(p)).catch(y=>this._onerror(new Error(`Failed to send an error response: ${y}`)))}else o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:p,timestamp:Date.now()},i?.sessionId).catch(m=>this._onerror(new Error(`Failed to enqueue error response: ${m}`))):i?.send(p).catch(m=>this._onerror(new Error(`Failed to send an error response: ${m}`)));return}const l=new AbortController;this._requestHandlerAbortControllers.set(t.id,l);const d=gE(t.params)?t.params.task:void 0,h=this._taskStore?this.requestTaskStore(t,i?.sessionId):void 0,f={signal:l.signal,sessionId:i?.sessionId,_meta:t.params?._meta,sendNotification:async p=>{if(l.signal.aborted)return;const m={relatedRequestId:t.id};o&&(m.relatedTask={taskId:o}),await this.notification(p,m)},sendRequest:async(p,m,y)=>{if(l.signal.aborted)throw new Le(De.ConnectionClosed,"Request was cancelled");const b={...y,relatedRequestId:t.id};o&&!b.relatedTask&&(b.relatedTask={taskId:o});const g=b.relatedTask?.taskId??o;return g&&h&&await h.updateTaskStatus(g,"input_required"),await this.request(p,m,b)},authInfo:n?.authInfo,requestId:t.id,requestInfo:n?.requestInfo,taskId:o,taskStore:h,taskRequestedTtl:d?.ttl,closeSSEStream:n?.closeSSEStream,closeStandaloneSSEStream:n?.closeStandaloneSSEStream};(c??Promise.resolve()).then(()=>{if(c&&l.signal.aborted)throw new Le(De.ConnectionClosed,"Request was cancelled");d&&this.assertTaskHandlerCapability(t.method)}).then(()=>r(t,f)).then(async p=>{if(l.signal.aborted)return;const m={result:p,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:m,timestamp:Date.now()},i?.sessionId):await i?.send(m)},async p=>{if(l.signal.aborted)return;const m={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(p.code)?p.code:De.InternalError,message:p.message??"Internal error",...p.data!==void 0&&{data:p.data}}};o&&this._taskMessageQueue&&u?await this._enqueueTaskMessage(o,{type:"error",message:m,timestamp:Date.now()},i?.sessionId):await i?.send(m)}).catch(p=>this._onerror(new Error(`Failed to send response: ${p}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===l&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:n,...r}=t.params,i=Number(n),o=this._progressHandlers.get(i);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const s=this._responseHandlers.get(i),a=this._timeoutInfo.get(i);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(u){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),s(u);return}o(r)}_onresponse(t){const n=Number(t.id),r=this._requestResolvers.get(n);if(r){if(this._requestResolvers.delete(n),Jo(t))r(t);else{const s=new Le(t.error.code,t.error.message,t.error.data);r(s)}return}const i=this._responseHandlers.get(n);if(i===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(n),this._cleanupTimeout(n);let o=!1;if(Jo(t)&&t.result&&typeof t.result=="object"){const s=t.result;if(s.task&&typeof s.task=="object"){const a=s.task;typeof a.taskId=="string"&&(o=!0,this._taskProgressTokens.set(a.taskId,n))}}if(o||this._progressHandlers.delete(n),Jo(t))i(t);else{const s=Le.fromError(t.error.code,t.error.message,t.error.data);i(s)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,n,r){const{task:i}=r??{};if(!i){try{yield{type:"result",result:await this.request(t,n,r)}}catch(s){yield{type:"error",error:s instanceof Le?s:new Le(De.InternalError,String(s))}}return}let o;try{const s=await this.request(t,qf,r);if(s.task)o=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new Le(De.InternalError,"Task creation did not return a task");for(;;){const a=await this.getTask({taskId:o},r);if(yield{type:"taskStatus",task:a},Un(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},n,r)}:a.status==="failed"?yield{type:"error",error:new Le(De.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new Le(De.InternalError,`Task ${o} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},n,r)};return}const u=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(c=>setTimeout(c,u)),r?.signal?.throwIfAborted()}}catch(s){yield{type:"error",error:s instanceof Le?s:new Le(De.InternalError,String(s))}}}request(t,n,r){const{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s,task:a,relatedTask:u}=r??{};return new Promise((c,l)=>{const d=g=>{l(g)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(g){d(g);return}r?.signal?.throwIfAborted();const h=this._requestMessageId++,f={...t,jsonrpc:"2.0",id:h};r?.onprogress&&(this._progressHandlers.set(h,r.onprogress),f.params={...t.params,_meta:{...t.params?._meta||{},progressToken:h}}),a&&(f.params={...f.params,task:a}),u&&(f.params={...f.params,_meta:{...f.params?._meta||{},[Bn]:u}});const p=g=>{this._responseHandlers.delete(h),this._progressHandlers.delete(h),this._cleanupTimeout(h),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:h,reason:String(g)}},{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(v=>this._onerror(new Error(`Failed to send cancellation: ${v}`)));const _=g instanceof Le?g:new Le(De.RequestTimeout,String(g));l(_)};this._responseHandlers.set(h,g=>{if(!r?.signal?.aborted){if(g instanceof Error)return l(g);try{const _=mw(n,g.result);_.success?c(_.data):l(_.error)}catch(_){l(_)}}}),r?.signal?.addEventListener("abort",()=>{p(r?.signal?.reason)});const m=r?.timeout??Q$,y=()=>p(Le.fromError(De.RequestTimeout,"Request timed out",{timeout:m}));this._setupTimeout(h,m,r?.maxTotalTimeout,y,r?.resetTimeoutOnProgress??!1);const b=u?.taskId;if(b){const g=_=>{const v=this._responseHandlers.get(h);v?v(_):this._onerror(new Error(`Response handler missing for side-channeled request ${h}`))};this._requestResolvers.set(h,g),this._enqueueTaskMessage(b,{type:"request",message:f,timestamp:Date.now()}).catch(_=>{this._cleanupTimeout(h),l(_)})}else this._transport.send(f,{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(g=>{this._cleanupTimeout(h),l(g)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},Kf,n)}async getTaskResult(t,n,r){return this.request({method:"tasks/result",params:t},n,r)}async listTasks(t,n){return this.request({method:"tasks/list",params:t},Xf,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},PE,n)}async notification(t,n){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const r=n?.relatedTask?.taskId;if(r){const a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Bn]:n.relatedTask}}};await this._enqueueTaskMessage(r,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!n?.relatedRequestId&&!n?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};n?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Bn]:n.relatedTask}}}),this._transport?.send(a,n).catch(u=>this._onerror(u))});return}let s={...t,jsonrpc:"2.0"};n?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[Bn]:n.relatedTask}}}),await this._transport.send(s,n)}setRequestHandler(t,n){const r=Sp(t);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(i,o)=>{const s=xp(t,i);return Promise.resolve(n(s,o))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,n){const r=Sp(t);this._notificationHandlers.set(r,i=>{const o=xp(t,i);return Promise.resolve(n(o))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){const n=this._taskProgressTokens.get(t);n!==void 0&&(this._progressHandlers.delete(n),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,n,r){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const i=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,n,r??this._transport?.sessionId,i)}async _clearTaskQueue(t,n){if(this._taskMessageQueue){const r=await this._taskMessageQueue.dequeueAll(t,n);for(const i of r)if(i.type==="request"&&kp(i.message)){const o=i.message.id,s=this._requestResolvers.get(o);s?(s(new Le(De.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,n,r){let i=this._options?.defaultTaskPollInterval??1e3;try{const o=await this._taskStore?.getTask(t,r);o?.pollInterval&&(i=o.pollInterval)}catch{}return new Promise((o,s)=>{if(n.aborted){s(new Le(De.InvalidRequest,"Request cancelled"));return}const a=setTimeout(o,i);n.addEventListener("abort",()=>{clearTimeout(a),s(new Le(De.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,n){const r=this._taskStore;if(!r)throw new Error("No task store configured");return{createTask:async i=>{if(!t)throw new Error("No request provided");return await r.createTask(i,t.id,{method:t.method,params:t.params},n)},getTask:async i=>{const o=await r.getTask(i,n);if(!o)throw new Le(De.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(i,o,s)=>{await r.storeTaskResult(i,o,s,n);const a=await r.getTask(i,n);if(a){const u=Ts.parse({method:"notifications/tasks/status",params:a});await this.notification(u),Un(a.status)&&this._cleanupTaskProgressHandler(i)}},getTaskResult:i=>r.getTaskResult(i,n),updateTaskStatus:async(i,o,s)=>{const a=await r.getTask(i,n);if(!a)throw new Le(De.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(Un(a.status))throw new Le(De.InvalidParams,`Cannot update task "${i}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await r.updateTaskStatus(i,o,s,n);const u=await r.getTask(i,n);if(u){const c=Ts.parse({method:"notifications/tasks/status",params:u});await this.notification(c),Un(u.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>r.listTasks(i,n)}}}function Ep(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function tT(e,t){const n={...e};for(const r in t){const i=r,o=t[i];if(o===void 0)continue;const s=n[i];Ep(s)&&Ep(o)?n[i]={...s,...o}:n[i]=o}return n}(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});class nT extends eT{_registeredMethods=new Set;_eventSlots=new Map;onEventDispatch(t,n){}_ensureEventSlot(t){let n=this._eventSlots.get(t);if(!n){let r=this.eventSchemas[t];if(!r)throw Error(`Unknown event: ${String(t)}`);n={listeners:[]},this._eventSlots.set(t,n);let i=r.shape.method.value;this._registeredMethods.add(i);let o=n;super.setNotificationHandler(r,s=>{let a=s.params;this.onEventDispatch(t,a),o.onHandler?.(a);for(let u of[...o.listeners])u(a)})}return n}setEventHandler(t,n){let r=this._ensureEventSlot(t);r.onHandler&&n&&console.warn(`[MCP Apps] on${String(t)} handler replaced. Use addEventListener("${String(t)}", …) to add multiple listeners without replacing.`),r.onHandler=n}getEventHandler(t){return this._eventSlots.get(t)?.onHandler}addEventListener(t,n){this._ensureEventSlot(t).listeners.push(n)}removeEventListener(t,n){let r=this._eventSlots.get(t);if(!r)return;let i=r.listeners.indexOf(n);i!==-1&&r.listeners.splice(i,1)}setRequestHandler=(t,n)=>{this._assertMethodNotRegistered(t,"setRequestHandler"),super.setRequestHandler(t,n)};setNotificationHandler=(t,n)=>{this._assertMethodNotRegistered(t,"setNotificationHandler"),super.setNotificationHandler(t,n)};warnIfRequestHandlerReplaced(t,n,r){n&&r&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}replaceRequestHandler=(t,n)=>{let r=t.shape.method.value;this._registeredMethods.add(r),super.setRequestHandler(t,n)};_assertMethodNotRegistered(t,n){let r=t.shape.method.value;if(this._registeredMethods.has(r))throw Error(`Handler for "${r}" already registered (via ${n}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(r)}}var rT="2026-01-26",iT="ui/notifications/tool-input-partial";class Vw{eventTarget;eventSource;messageListener;constructor(t=window.parent,n){this.eventTarget=t,this.eventSource=n,this.messageListener=r=>{if(n&&r.source!==this.eventSource){console.debug("Ignoring message from unknown source",r);return}let i=bE.safeParse(r.data);i.success?(console.debug("Parsed message",i.data),this.onmessage?.(i.data)):r.data?.jsonrpc!=="2.0"?console.debug("Ignoring non-JSON-RPC message",i.error.message,r):(console.error("Failed to parse message",i.error.message,r),this.onerror?.(Error("Invalid JSON-RPC message received: "+i.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,n){t.method!==iT&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var oT=Te([$("light"),$("dark")]).describe("Color theme preference for the host environment."),$i=Te([$("inline"),$("fullscreen"),$("pip")]).describe("Display mode for UI presentation."),sT=Te([$("--color-background-primary"),$("--color-background-secondary"),$("--color-background-tertiary"),$("--color-background-inverse"),$("--color-background-ghost"),$("--color-background-info"),$("--color-background-danger"),$("--color-background-success"),$("--color-background-warning"),$("--color-background-disabled"),$("--color-text-primary"),$("--color-text-secondary"),$("--color-text-tertiary"),$("--color-text-inverse"),$("--color-text-ghost"),$("--color-text-info"),$("--color-text-danger"),$("--color-text-success"),$("--color-text-warning"),$("--color-text-disabled"),$("--color-border-primary"),$("--color-border-secondary"),$("--color-border-tertiary"),$("--color-border-inverse"),$("--color-border-ghost"),$("--color-border-info"),$("--color-border-danger"),$("--color-border-success"),$("--color-border-warning"),$("--color-border-disabled"),$("--color-ring-primary"),$("--color-ring-secondary"),$("--color-ring-inverse"),$("--color-ring-info"),$("--color-ring-danger"),$("--color-ring-success"),$("--color-ring-warning"),$("--font-sans"),$("--font-mono"),$("--font-weight-normal"),$("--font-weight-medium"),$("--font-weight-semibold"),$("--font-weight-bold"),$("--font-text-xs-size"),$("--font-text-sm-size"),$("--font-text-md-size"),$("--font-text-lg-size"),$("--font-heading-xs-size"),$("--font-heading-sm-size"),$("--font-heading-md-size"),$("--font-heading-lg-size"),$("--font-heading-xl-size"),$("--font-heading-2xl-size"),$("--font-heading-3xl-size"),$("--font-text-xs-line-height"),$("--font-text-sm-line-height"),$("--font-text-md-line-height"),$("--font-text-lg-line-height"),$("--font-heading-xs-line-height"),$("--font-heading-sm-line-height"),$("--font-heading-md-line-height"),$("--font-heading-lg-line-height"),$("--font-heading-xl-line-height"),$("--font-heading-2xl-line-height"),$("--font-heading-3xl-line-height"),$("--border-radius-xs"),$("--border-radius-sm"),$("--border-radius-md"),$("--border-radius-lg"),$("--border-radius-xl"),$("--border-radius-full"),$("--border-width-regular"),$("--shadow-hairline"),$("--shadow-sm"),$("--shadow-md"),$("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),aT=Ie(sT.describe(`Style variables for theming MCP apps.
71
71
 
72
72
  Individual style keys are optional - hosts may provide any subset of these values.
73
73
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
74
74
 
75
75
  Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
76
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),xe([E(),vr()]).describe(`Style variables for theming MCP apps.
76
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),Te([E(),vr()]).describe(`Style variables for theming MCP apps.
77
77
 
78
78
  Individual style keys are optional - hosts may provide any subset of these values.
79
79
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
@@ -85,10 +85,10 @@ Individual style keys are optional - hosts may provide any subset of these value
85
85
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
86
86
 
87
87
  Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
88
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);C({method:$("ui/open-link"),params:C({url:E().describe("URL to open in the host's browser")})});var X$=C({isError:Pe().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),Q$=C({isError:Pe().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),eT=C({isError:Pe().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();C({method:$("ui/notifications/sandbox-proxy-ready"),params:C({})});var Qf=C({connectDomains:le(E()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
88
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);C({method:$("ui/open-link"),params:C({url:E().describe("URL to open in the host's browser")})});var uT=C({isError:Pe().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),cT=C({isError:Pe().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),lT=C({isError:Pe().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();C({method:$("ui/notifications/sandbox-proxy-ready"),params:C({})});var sh=C({connectDomains:fe(E()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
89
89
 
90
90
  - Maps to CSP \`connect-src\` directive
91
- - Empty or omitted → no network connections (secure default)`),resourceDomains:le(E()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:le(E()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:le(E()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),eh=C({camera:C({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:C({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:C({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:C({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")});C({method:$("ui/notifications/size-changed"),params:C({width:we().optional().describe("New width in pixels."),height:we().optional().describe("New height in pixels.")})});var tT=C({method:$("ui/notifications/tool-input"),params:C({arguments:Ce(E(),Le().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),nT=C({method:$("ui/notifications/tool-input-partial"),params:C({arguments:Ce(E(),Le().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),rT=C({method:$("ui/notifications/tool-cancelled"),params:C({reason:E().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),iT=C({fonts:E().optional()}),oT=C({variables:Y$.optional().describe("CSS variables for theming the app."),css:iT.optional().describe("CSS blocks that apps can inject.")}),sT=C({method:$("ui/resource-teardown"),params:C({})});Ce(E(),Le());var yp=C({text:C({}).optional().describe("Host supports text content blocks."),image:C({}).optional().describe("Host supports image content blocks."),audio:C({}).optional().describe("Host supports audio content blocks."),resource:C({}).optional().describe("Host supports resource content blocks."),resourceLink:C({}).optional().describe("Host supports resource link content blocks."),structuredContent:C({}).optional().describe("Host supports structured content.")});C({method:$("ui/notifications/request-teardown"),params:C({}).optional()});var aT=C({experimental:Ce(E(),Ce(E(),_o()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:C({}).optional().describe("Host supports opening external URLs."),downloadFile:C({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:C({listChanged:Pe().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:C({listChanged:Pe().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:C({}).optional().describe("Host accepts log messages."),sandbox:C({permissions:eh.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Qf.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:yp.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:yp.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:C({tools:C({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),uT=C({experimental:Ce(E(),Ce(E(),_o()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:C({listChanged:Pe().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:le(ki).optional().describe("Display modes the app supports.")});C({method:$("ui/notifications/initialized"),params:C({}).optional()});C({csp:Qf.optional().describe("Content Security Policy configuration for UI resources."),permissions:eh.optional().describe("Sandbox permissions requested by the UI resource."),domain:E().optional().describe(`Dedicated origin for view sandbox.
91
+ - Empty or omitted → no network connections (secure default)`),resourceDomains:fe(E()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:fe(E()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:fe(E()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),ah=C({camera:C({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:C({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:C({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:C({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")});C({method:$("ui/notifications/size-changed"),params:C({width:_e().optional().describe("New width in pixels."),height:_e().optional().describe("New height in pixels.")})});var dT=C({method:$("ui/notifications/tool-input"),params:C({arguments:Ie(E(),Oe().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),fT=C({method:$("ui/notifications/tool-input-partial"),params:C({arguments:Ie(E(),Oe().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),hT=C({method:$("ui/notifications/tool-cancelled"),params:C({reason:E().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),pT=C({fonts:E().optional()}),mT=C({variables:aT.optional().describe("CSS variables for theming the app."),css:pT.optional().describe("CSS blocks that apps can inject.")}),gT=C({method:$("ui/resource-teardown"),params:C({})});Ie(E(),Oe());var $p=C({text:C({}).optional().describe("Host supports text content blocks."),image:C({}).optional().describe("Host supports image content blocks."),audio:C({}).optional().describe("Host supports audio content blocks."),resource:C({}).optional().describe("Host supports resource content blocks."),resourceLink:C({}).optional().describe("Host supports resource link content blocks."),structuredContent:C({}).optional().describe("Host supports structured content.")});C({method:$("ui/notifications/request-teardown"),params:C({}).optional()});var yT=C({experimental:Ie(E(),Ie(E(),$o()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:C({}).optional().describe("Host supports opening external URLs."),downloadFile:C({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:C({listChanged:Pe().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:C({listChanged:Pe().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:C({}).optional().describe("Host accepts log messages."),sandbox:C({permissions:ah.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:sh.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:$p.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:$p.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:C({tools:C({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),vT=C({experimental:Ie(E(),Ie(E(),$o()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:C({listChanged:Pe().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:fe($i).optional().describe("Display modes the app supports.")});C({method:$("ui/notifications/initialized"),params:C({}).optional()});C({csp:sh.optional().describe("Content Security Policy configuration for UI resources."),permissions:ah.optional().describe("Sandbox permissions requested by the UI resource."),domain:E().optional().describe(`Dedicated origin for view sandbox.
92
92
 
93
93
  Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
94
94
 
@@ -102,17 +102,17 @@ Boolean requesting whether a visible border and background is provided by the ho
102
102
 
103
103
  - \`true\`: request visible border + background
104
104
  - \`false\`: request no visible border + background
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"]
105
+ - omitted: host decides border`)});C({method:$("ui/request-display-mode"),params:C({mode:$i.describe("The display mode being requested.")})});var bT=C({mode:$i.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),wT=Te([$("model"),$("app")]).describe("Tool visibility scope - who can access the tool.");C({resourceUri:E().optional(),visibility:fe(wT).optional().describe(`Who can access this tool. Default: ["model", "app"]
106
106
  - "model": Tool visible to and callable by the agent
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"],["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
- `).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"],["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
- `)[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
- 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:
107
+ - "app": Tool callable by the app from this server only`),csp:Yn().optional(),permissions:Yn().optional()});C({mimeTypes:fe(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:fe(Te([Fw,Uw])).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:fe(Uo).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:sh.optional().describe("CSP configuration from resource metadata."),permissions:ah.optional().describe("Sandbox permissions from resource metadata.")})});var _T=C({method:$("ui/notifications/tool-result"),params:au.describe("Standard MCP tool execution result.")}),qw=C({toolInfo:C({id:zo.optional().describe("JSON-RPC id of the tools/call request."),tool:oh.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:oT.optional().describe("Current color theme preference."),styles:mT.optional().describe("Style configuration for theming the app."),displayMode:$i.optional().describe("How the UI is currently displayed."),availableDisplayModes:fe($i).optional().describe("Display modes the host supports."),containerDimensions:Te([C({height:_e().describe("Fixed container height in pixels.")}),C({maxHeight:Te([_e(),vr()]).optional().describe("Maximum container height in pixels.")})]).and(Te([C({width:_e().describe("Fixed container width in pixels.")}),C({maxWidth:Te([_e(),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:Te([$("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:_e().describe("Top safe area inset in pixels."),right:_e().describe("Right safe area inset in pixels."),bottom:_e().describe("Bottom safe area inset in pixels."),left:_e().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),kT=C({method:$("ui/notifications/host-context-changed"),params:qw.describe("Partial context update containing only changed fields.")});C({method:$("ui/update-model-context"),params:C({content:fe(Uo).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:Ie(E(),Oe().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});C({method:$("ui/initialize"),params:C({appInfo:ou.describe("App identification (name and version)."),appCapabilities:vT.describe("Features and capabilities this app provides."),protocolVersion:E().describe("Protocol version this app supports.")})});var ST=C({protocolVersion:E().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:ou.describe("Host application identification and version."),hostCapabilities:yT.describe("Features and capabilities provided by the host."),hostContext:qw.describe("Rich context about the host environment.")}).passthrough(),xT={target:"draft-2020-12"};async function Tp(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](xT);if(n.vendor==="zod"){let{z:r}=await Gk(()=>Promise.resolve().then(()=>hE),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 Cp(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 ET(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function $T(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 uh extends nT{_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:dT,toolinputpartial:fT,toolresult:_T,toolcancelled:hT,hostcontextchanged:kT};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(t){if(!uh.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||nt({jitless:!0}),this.setRequestHandler(su,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=tT(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,h=d?await Cp(d,u??{},`Invalid input for tool ${t}: `):u??{};l=await r(h,c)}else l=await r(c);return a.outputSchema&&!l.isError&&(l.structuredContent=await Cp(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 Tp(i.inputSchema,"input"):{type:"object",properties:{}}};return i.outputSchema&&(o.outputSchema=await Tp(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(gT,(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(jw,(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(Gw,(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},au,{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(t,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},Mw,n)}async listServerResources(t,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},Pw,n)}async createSamplingMessage(t,n){this._assertInitialized("createSamplingMessage");let r=t.tools?Hw:Bw;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},lT,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},Bf,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},uT,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},cT,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},bT,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 Vw(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:rT}},ST,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 TT="Chain Insights graph",CT="This graph is no longer available. Ask for it again.",Ap="data-chain-insights-view",AT="This window cannot reach the local Chain Insights page. Open the link in your own browser for clicks that load more",ps=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Ww=e=>!ps(e)||!ps(e.result)?null:{arguments:ps(e.arguments)?e.arguments:null,result:e.result};function IT(e,t){const n=t.querySelector(`script[type="application/json"][${Ap}]`);if(!n||n.getAttribute(Ap)!==e)return null;try{return Ww(JSON.parse(n.textContent??""))}catch{return null}}const NT=new Set(["127.0.0.1","localhost","[::1]","::1"]);function RT(e){const t=new URLSearchParams(e.search).get("view");if(t&&t.trim())return t.trim();if(!NT.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 LT(e,t,n){const r=n?IT(e,n):null;if(r)return r;try{const i=await t(`/api/view/${encodeURIComponent(e)}`,{headers:{Accept:"application/json"}});return i.ok?Ww(await i.json()):null}catch{return null}}function zT(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(AT)}let o=null;try{o=await i.json()}catch{o=null}if(ps(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 Kw=new Map;function DT(e,t){Kw.set(e,t)}function Ip(e){return Kw.get(e)??null}const OT=/swiftshader|llvmpipe|softpipe|software|microsoft basic render/i;function PT(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 OT.test(o)?(r.getExtension?.("WEBGL_lose_context")?.loseContext(),!1):(r.getExtension?.("WEBGL_lose_context")?.loseContext(),!0)}catch{return!1}}const MT="http://www.w3.org/2000/svg";let FT=0;function Yo(e){return Math.round(e*10)/10}function UT(e,t,n={}){const r=e.createElementNS(MT,t);for(const[i,o]of Object.entries(n))r.setAttribute(i,String(o));return r}function Np(e,t,n,r){const i=`cia-graph-svg-${++FT}`,o=e.ownerDocument,s=(U,H)=>UT(o,U,H),a=(U,H,Y)=>{const me=s("text",{x:0,y:H,"text-anchor":"middle",class:Y,"pointer-events":"none"});return me.textContent=U,me},{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"),h=s("pattern",{id:`${i}-dots`,width:24,height:24,patternUnits:"userSpaceOnUse"});h.append(s("circle",{class:"cia-graph-dot",cx:1,cy:1,r:1})),d.append(h);const f=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,f,p,m),e.append(l);const g=new Map,_=new Map,v=new Map;let w=null;function k(){if(w)return w;const U=t.model(),H=t.positions(),Y=new Map;w=Y;const me=U.nodes.length>PC,ie=new Map(U.nodes.map(O=>[O.address,O])),I=me?[]:CC(U,H,t.notes());for(const O of U.edges){const G=ie.get(O.from),ae=ie.get(O.to),de=G&&H[G.id],te=ae&&H[ae.id];if(!G||!ae||!de||!te){Y.set(O.id,null);continue}if(me){Y.set(O.id,mc(de,te,Hn(G,U.checked_address),Hn(ae,U.checked_address)));continue}const ge=I.filter(X=>X.id!==G.id&&X.id!==ae.id);Y.set(O.id,MC(de,te,Hn(G,U.checked_address),Hn(ae,U.checked_address),ge))}return Y}function x(U){let H=g.get(U);if(H)return H;H=`${i}-arrow-${g.size}`;const Y=s("marker",{id:H,viewBox:"0 0 10 10",refX:9,refY:5,markerWidth:6,markerHeight:6,orient:"auto-start-reverse",markerUnits:"strokeWidth"}),me=s("path",{d:"M0 0L10 5L0 10Z",class:"cia-graph-arrowhead"});return me.style.fill=U,Y.append(me),d.append(Y),g.set(U,H),H}function D(){return[...t.model().nodes??[]].sort((U,H)=>String(U.id).localeCompare(String(H.id)))}function F(){w=null;const U=t.model();y.replaceChildren(),b.replaceChildren(),_.clear(),v.clear();const H=new Map(U.nodes.map(Y=>[Y.address,Y]));for(const Y of U.edges){const me=H.get(Y.from);if(!me||!H.get(Y.to))continue;const ie=t.colorOf(me),I=s("g",{class:"cia-graph-edge graph-edge",tabindex:0,role:"button","aria-label":wc(Y,t.now())});I.dataset.edgeId=Y.id,I.style.setProperty("--edge-tone",ie);const O=UC(),G=s("path",{class:"cia-graph-edge-hit","stroke-width":O.hit.width,"pointer-events":"stroke"}),ae=s("path",{class:"cia-graph-edge-line","stroke-width":O.line.width,"marker-end":`url(#${x(ie)})`,"pointer-events":"none"});I.append(G,ae);const de=kr(Y);if(de.link){I.dataset.link=de.link,de.dash&&ae.setAttribute("stroke-dasharray",de.dash),ae.id=`${i}-edge-${v.size}`;const X=s("textPath",{href:`#${ae.id}`,startOffset:"50%","text-anchor":"middle"});X.textContent=de.mark;const be=s("text",{class:"cia-graph-edge-mark",dy:"4","pointer-events":"none","aria-hidden":"true"});be.append(X),I.append(be)}const te=U.edges.length<=a_?u_(Y):"";let ge;if(te){ae.id=`${i}-edge-${v.size}`;const X=s("textPath",{href:`#${ae.id}`,startOffset:"50%","text-anchor":"middle"});X.textContent=te;const be=s("text",{class:"cia-graph-edge-caption",dy:"-4","pointer-events":"none","aria-hidden":"true"});be.append(X),I.append(be),ge=be}I.addEventListener("keydown",X=>{Fp(X.key)&&(X.preventDefault(),n.selectEdge(Y.id,"keyboard"))}),I.addEventListener("pointerenter",X=>n.showTooltip(X,wc(Y,t.now()))),I.addEventListener("pointerleave",()=>n.hideTooltip()),y.append(I),v.set(Y.id,{group:I,hit:G,line:ae,...ge?{caption:ge}:{}})}for(const Y of D())b.append(M(Y));ne(),pe()}function M(U){const H=t.model(),Y=U.address===H.checked_address,me=t.notes().get(U.id),ie=Ln(U,H.checked_address,me),I=ie.radius,O=s("g",{class:"cia-graph-node graph-node",tabindex:0,role:"button","aria-label":bc(U),"aria-pressed":"false"});O.dataset.nodeId=U.id,Y&&(O.dataset.checked=""),O.style.setProperty("--node-tone",t.colorOf(U)),Y&&O.append(s("circle",{class:"cia-graph-node-ring",r:I+6})),O.append(s("circle",{class:"cia-graph-node-body",r:I})),O.append(s("circle",{class:"cia-graph-node-dot",r:ie.dot}));for(const G of ie.texts)O.append(a(G.text,G.y,`cia-graph-node-${G.kind}`));me&&(O.dataset.state="refused");for(const G of t.flags().get(U.id)??[])O.setAttribute(`data-flag-${G}`,"");return O.addEventListener("keydown",G=>{Fp(G.key)&&(G.preventDefault(),n.selectNode(U.id,"keyboard"))}),O.addEventListener("pointerenter",G=>n.showTooltip(G,bc(U))),O.addEventListener("pointerleave",()=>n.hideTooltip()),_.set(U.id,O),O}function Z(){const U=t.transform();m.setAttribute("transform",`translate(${U.x} ${U.y}) scale(${U.scale})`)}function ne(){Z();const U=t.positions(),{width:H,height:Y}=t.dimensions();for(const[ie,I]of _){const O=U[ie]??{x:H/2,y:Y/2};I.setAttribute("transform",`translate(${Yo(O.x)} ${Yo(O.y)})`)}const me=k();for(const ie of t.model().edges){const I=v.get(ie.id);if(!I)continue;const O=me.get(ie.id)??null;I.group.style.display=O?"":"none",O&&(I.hit.setAttribute("d",O.d),I.line.setAttribute("d",O.d),I.caption&&(I.caption.style.display=O.kind==="forward"||O.kind==="vertical"||O.kind==="straight"?"":"none"))}}function ce(U){const H=t.model(),Y=t.positions(),me=Y[U],ie=_.get(U);if(!me||!ie)return;ie.setAttribute("transform",`translate(${Yo(me.x)} ${Yo(me.y)})`);const I=H.nodes.find(G=>G.id===U);if(!I)return;const O=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 ae=v.get(G.id),de=O.get(G.from),te=O.get(G.to),ge=de&&Y[de.id],X=te&&Y[te.id];if(!ae||!de||!te||!ge||!X)continue;const be=mc(ge,X,Hn(de,H.checked_address),Hn(te,H.checked_address));ae.group.style.display=be?"":"none",be&&(ae.hit.setAttribute("d",be.d),ae.line.setAttribute("d",be.d))}}function pe(){const U=t.model(),H=t.selected(),Y=t.highlighted(),me=H?.kind==="node"?U.nodes.find(ie=>ie.id===H.id)?.address??null:null;for(const ie of U.edges){const I=v.get(ie.id);if(!I)continue;const O=H?.kind==="edge"&&H.id===ie.id,G=H?.kind==="edge"?O?Xt.related:Xt.faded:r_(ie,me),ae=G===Xt.faded;I.group.setAttribute("opacity",ae?String(G):"1"),I.line.setAttribute("stroke-opacity",ae?"1":String(G)),I.group.dataset.opacity=String(G),I.group.dataset.state=G===Xt.rest?"rest":G===Xt.related?"related":"faded",I.group.setAttribute("aria-pressed",String(O))}for(const[ie,I]of _){const O=H?.kind==="node"&&H.id===ie;I.classList.toggle("is-selected",O),I.classList.toggle("is-focused",Y===ie),I.setAttribute("aria-pressed",String(O))}}function Re(){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:F,geometry(){w=null,ne()},moveNode:ce,endMove(){w=null,ne()},camera:Z,selection:pe,flag(U,H,Y){_.get(U)?.toggleAttribute(`data-flag-${H}`,Y)},theme(){for(const U of t.model().nodes)_.get(U.id)?.style.setProperty("--node-tone",t.colorOf(U))},resize(U,H){l.setAttribute("viewBox",`0 0 ${U} ${H}`)},pick:()=>null,linkBounds:Re,destroy(){l.remove()}}}const GT=.1,jT=2.5,ZT=5,BT="chain-insights.flows.v1",ch="cia-graph-model",HT=300,Xt={rest:.6,related:.95,faded:.25},Rp={checked:24,other:19},Ti=16,VT=[["Sanctioned","Sanctioned"],["Scam","Scam"],["Poisoned","Poisoned"],["OnMoneyTrail","On money trail"],["Mixer","Mixer"],["Bridge","Bridge"],["Exchange","Exchange"],["Victim","Victim"],["Targeted","Targeted"],["SelfTrader","Self-trading contract"]],Wr=["exchange","scam","sanctioned","victim","pool","self_trader","other"],qT={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 lh(e){return!!e&&e.schema===BT}function WT(e){return!!e&&e.kind===ch}function Be(e){return String(e??"").trim().toLowerCase()}function KT(e){const t=Be(e);return Wr.includes(t)?t:"other"}function Jt(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function fc(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function JT(e){const t=String(e??"").toUpperCase();return t==="IN"||t==="OUT"||t==="MIXED"||t==="CHECKED"?t:"OUT"}function Ft(e){return WT(e)?e:lh(e)?YT(e):oC(e)}function YT(e){const t=Be(e.center),n=new Map;for(const u of e.nodes??[]){const c=Be(u?.address);c&&!n.has(c)&&n.set(c,u)}const r=[],i=new Set,o=new Map;for(const u of e.edges??[]){const c=Be(u?.from),l=Be(u?.to);if(!n.has(c)||!n.has(l))continue;const d=As(u.link_kind).includes(dh);if(c===l){d&&o.set(c,eC(o.get(c),u));continue}const h=`${c}->${l}`;i.has(h)||(i.add(h),r.push({id:h,from:c,to:l,source:"flows",amount_usd_sum:Jt(u.usd),tx_count:Jt(u.tx_count),first_seen_timestamp:Jt(u.first_seen_ms),last_seen_timestamp:Jt(u.last_seen_ms),...typeof u.link_kind=="string"&&u.link_kind?{link_kind:u.link_kind}:{},...d?{bought_usd:Jt(u.bought_usd),swap_count:Jt(u.swap_count)}:{}}))}const s=iC(t,[...n.keys()],r),a=[...n.entries()].map(([u,c])=>{const l=s.get(u)??{direction:"OUT",hop:2};return{id:u,address:u,direction:u===t?"CHECKED":l.direction,hop:u===t?0:l.hop,labels:fc(c.labels),taxonomy:[],role:KT(c.role),total_in_usd:Jt(c.total_in_usd),total_out_usd:Jt(c.total_out_usd),degree_in:Jt(c.degree_in),degree_out:Jt(c.degree_out),...o.has(u)?{self_route:o.get(u)}:{}}});return{kind:ch,checked_address:t,network:e.network??null,nodes:a,edges:r,truncated:!!e.truncated,cursor:e.cursor??null}}const XT="FLOWED_TO",dh="ROUTED_TO",Ci="⇄",Yw="Swap route: the asset changed on the way",QT="Funds sent";function As(e){return typeof e=="string"?e.split(",").map(t=>t.trim()).filter(Boolean):[]}function kr(e){const t=As(e.link_kind);if(!t.includes(dh))return{link:null,dash:null,mark:null};const n=t.includes(XT);return{link:n?"both":"route",dash:n?null:"6 4",mark:Ci}}function eC(e,t){const n=(r,i)=>{const o=Jt(i);return r==null?o:o==null?r:r+o};return{usd:n(e?.usd,t.usd),bought_usd:n(e?.bought_usd,t.bought_usd),swap_count:n(e?.swap_count,t.swap_count)}}function hi(e){if(e==null||!Number.isFinite(e))return"an unknown amount in USD";const t=Math.abs(e)>=100?0:2;return`about ${new Intl.NumberFormat("en-US",{maximumFractionDigits:t}).format(e)} USD`}const fh=e=>e==null?"swaps":`${new Intl.NumberFormat("en-US").format(e)} ${e===1?"swap":"swaps"}`,hc="The routers and pools in between are not shown as holders.";function tC(e){const t=kr(e);if(!t.link)return null;const n=`the receiver got tokens worth ${hi(e.bought_usd)}, in ${fh(e.swap_count)}`;return t.link==="both"?`Funds sent and a swap route: tokens worth ${hi(e.amount_usd_sum)} given in all. On the route ${n}. ${hc}`:`Swap route: the sender gave tokens worth ${hi(e.amount_usd_sum)}, and ${n}. ${hc}`}function nC(e){return`It swapped for itself: it gave tokens worth ${hi(e.usd)} and got tokens worth ${hi(e.bought_usd)} back, in ${fh(e.swap_count)}. ${hc}`}function rC(e){return e?e.swap_count==null?`${Ci} Swapped for itself`:`${Ci} Swapped for itself, ${fh(e.swap_count)}`:null}function iC(e,t,n){const r=new Map,i=new Map,o=new Map,s=(d,h,f)=>d.set(h,[...d.get(h)??[],f]);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 h=new Map([[e,0]]);for(let f=[e];f.length;){const p=[];for(const m of f)for(const y of d.get(m)??[])h.has(y)||(h.set(y,(h.get(m)??0)+1),p.push(y));f=p}return h},u=a(r),c=a(i),l=new Map;for(const d of t){if(d===e)continue;const h=u.get(d),f=c.get(d);if(h==null&&f==null)continue;const p=h!=null&&f!=null?h<f?"OUT":f<h?"IN":"MIXED":h!=null?"OUT":"IN";l.set(d,{direction:p,hop:Math.min(2,Math.min(h??1/0,f??1/0))})}for(let d=!0;d;){d=!1;for(const h of t){if(h===e||l.has(h))continue;const f=(o.get(h)??[]).find(m=>m!==e&&l.has(m));if(f==null)continue;const p=l.get(f);l.set(h,{direction:p.direction==="MIXED"?"OUT":p.direction,hop:2}),d=!0}}return l}function oC(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":JT(r.direction),labels:fc(r.labels),taxonomy:fc(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:ch,checked_address:e?.checked_address??"",network:null,nodes:t,edges:n,truncated:!1,cursor:null}}function sC(e,t,n){const r=Ft(t),i=Sn(e,n??r.checked_address),o=e.nodes.find(f=>f.id===i),s=new Map(e.nodes.map(f=>[Be(f.address),f])),a=[],u=new Map(r.nodes.filter(f=>f.self_route).map(f=>[Be(f.address),f.self_route])),c=u.size?e.nodes.map(f=>!f.self_route&&u.has(Be(f.address))?{...f,self_route:u.get(Be(f.address))}:f):e.nodes;for(const f of c)s.set(Be(f.address),f);for(const f of r.nodes){if(s.has(Be(f.address)))continue;const p=!o||o.direction==="CHECKED"?f.direction==="CHECKED"?"OUT":f.direction:o.direction,m={...f,id:f.id,direction:p,hop:Math.min(2,(o?.hop??0)+1)};a.push(m),s.set(Be(f.address),m)}const l=new Set(e.edges.map(f=>f.id)),d=new Set(e.edges.map(f=>`${Be(f.from)}->${Be(f.to)}`)),h=[...e.edges];for(const f of r.edges){const p=`${Be(f.from)}->${Be(f.to)}`;if(l.has(f.id)||d.has(p)||!s.has(Be(f.from))||!s.has(Be(f.to)))continue;const m=s.get(Be(f.from)).address,y=s.get(Be(f.to)).address;h.push({...f,from:m,to:y}),l.add(f.id),d.add(p)}return{model:{...e,nodes:[...c,...a],edges:h,truncated:e.truncated||r.truncated},added:a.map(f=>f.id)}}function Sn(e,t){if(t==null)return null;const n=Be(t);return e.nodes.find(i=>i.id===t||Be(i.address)===n)?.id??null}function Ai(e){return typeof e!="string"||e.length<=12?e:`${e.slice(0,6)}…${e.slice(-4)}`}function hh(e){return String(e??"").trim().replace(/\s+/g," ")}function Is(e){return hh(e).replaceAll(" ","").toLowerCase()}function Nn(e){const t=[...e.taxonomy??[],...e.labels??[]],n=new Set,r=[];for(const i of t){const o=hh(i),s=o.toLowerCase();!o||s==="address"||n.has(s)||(n.add(s),r.push(o))}return r}function Xo(e,t){const n=new Set(Nn(e).map(Is));return t.some(r=>n.has(Is(r)))}function aC(e){if(e.role&&Wr.includes(e.role))return qT[e.role];if(Xo(e,["Sanctioned","Scam","Poisoned"]))return"danger";if(Xo(e,["Victim","Targeted"]))return"target";if(Xo(e,["OnMoneyTrail","Mixer"]))return"trail";if(Xo(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 Ye(e){return`var(--cia-graph-${e})`}const uC={semantic:{danger:{stroke:Ye("danger"),fill:Ye("node")},target:{stroke:Ye("target"),fill:Ye("node")},trail:{stroke:Ye("trail"),fill:Ye("node")},infrastructure:{stroke:Ye("infrastructure"),fill:Ye("node")},neutral:{stroke:Ye("neutral"),fill:Ye("node")}},risk:{CRITICAL:{stroke:Ye("critical"),fill:Ye("node")},HIGH:{stroke:Ye("high"),fill:Ye("node")},MEDIUM:{stroke:Ye("medium"),fill:Ye("node")},LOW:{stroke:Ye("low"),fill:Ye("node")}}};function cC(e,t=uC){const n=aC(e);return n==="critical"||n==="high"||n==="medium"||n==="low"?t.risk[n.toUpperCase()]??t.semantic.neutral:t.semantic[n]}function lC(e){return e.role&&Wr.includes(e.role)?Ye(`role-${e.role}`):cC(e).stroke}function Go(e){if(e.role&&e.role!=="other"&&Wr.includes(e.role))return Jw[e.role];const t=Nn(e);for(const[r,i]of VT)if(t.some(o=>Is(o)===Is(r)))return i;return(Array.isArray(e.labels)?e.labels.map(hh).filter(Boolean).sort((r,i)=>r.localeCompare(i)):[])[0]??""}function pc(e){return Math.min(jT,Math.max(GT,e))}function ph(e){return[...e.nodes??[]].sort((t,n)=>String(t.id).localeCompare(String(n.id)))}function Xw(e,t=ph(e)){return t.find(n=>n.address===e.checked_address)??t[0]}function Lp(e,t){return e.address===t?43:e.hop>=2?25:30}function Hn(e,t){return e.address===t?Rp.checked:Rp.other}function Ln(e,t,n){const r=e.address===t,i=Hn(e,t),o=Go(e),s=[];o&&s.push({kind:"role",text:nA(o),y:i+17}),s.push({kind:"address",text:Ai(e.address),y:i+(o?33:17)});const a=n??rC(e.self_route);return a&&s.push({kind:"note",text:a,y:i+(o?48:32)}),{radius:i,ring:r,dot:r?8:5,texts:s}}const dC={role:{size:13,advance:.68},address:{size:11,advance:.62},note:{size:11,advance:.6}},xu=2;function mh(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=dC[r.kind],o=[...r.text].length*i.size*i.advance/2+xu;n.push({kind:r.kind,box:{x1:-o,y1:r.y-i.size*.8-xu,x2:o,y2:r.y+i.size*.25+xu}})}return n}function Qw(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 Ns(e){return Qw(mh(e).map(t=>t.box))}const Ii=(e,t)=>(e instanceof Map?e.get(t):e?.[t])??null;function fC(e,t,n){const r=Ft(e),i=[];for(const o of r.nodes){const s=t[o.id];if(s)for(const{kind:a,box:u}of mh(Ln(o,r.checked_address,Ii(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 hC(e,t,n){return Qw(fC(e,t,n))}function pC(e,t){return e.x1<t.x2&&t.x1<e.x2&&e.y1<t.y2&&t.y1<e.y2}function mC(e){let t=0;for(const n of String(e))t=(t<<5)-t+n.charCodeAt(0)|0;return Math.abs(t)}function gC(e,t,n){const r=Ft(e),i={x:t/2,y:n/2},o={},s=ph(r),a=Xw(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=mC(l.id)%2?-1:1);const h=Math.min(2,Math.max(1,Number(l.hop)||1)),f=`${d}:${h}`;u.has(f)||u.set(f,[]),u.get(f).push(l)}const c=yC(r);for(const[l,d]of u){const[h,f]=l.split(":"),p=Number(h),m=Number(f),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,vC(d,y,i.y,r.checked_address))}return o}function yC(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 vC(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=>Ns(Ln(u,r)),a=(u,c)=>Math.max(Lp(u,r)+Lp(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 h=o[d-1],f=o[d];!h||!f||(f.y=Math.max(f.y,h.y+a(h.node,f.node)))}for(let d=o.length-2;d>=0;d--){const h=o[d],f=o[d+1];!h||!f||(h.y=Math.min(h.y,f.y-a(h.node,f.node)))}const c=o[0],l=o[o.length-1];if(c&&l){const d=(c.y+l.y)/2,h=n-d;for(const f of o)f.y+=h}}return Object.fromEntries(o.map(u=>[u.node.id,{x:u.x,y:u.y}]))}function bC(e,t,n){const r=Ft(e),i={x:t/2,y:n/2},o={},s=ph(r),a=Xw(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)+(Sr(c.id)-.5)*.3,h=(c.hop>=2?Math.min(t,n)*.39:Math.min(t,n)*.27)*(.85+Sr(c.id+"/r")*.3);o[c.id]={x:i.x+Math.cos(d)*h,y:i.y+Math.sin(d)*h}}),o}function Sr(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 xn={link:150,repel:50,reach:300,spring:.06,centre:.02};function wC(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],h=t[d.id],f=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-h.x,g=y.y-h.y;!b&&!g&&(b=Sr(d.id+p.id)-.5,g=Sr(p.id+d.id)-.5);const _=Math.max(8,Math.hypot(b,g));if(_>=xn.reach)continue;const v=xn.repel*xn.repel/_*(1-_/xn.reach),w=b/_*v,k=g/_*v;if(f.x-=w,f.y-=k,m!==void 0){const x=s.get(p.id);x.x+=w,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),h=c.get(l.to);if(!d||!h||d===h)continue;const f=t[d.id],p=t[h.id],m=p.x-f.x,y=p.y-f.y,b=Math.max(1,Math.hypot(m,y)),g=(b-xn.link)*xn.spring,_=m/b*g,v=y/b*g,w=s.get(d.id);w.x+=_,w.y+=v;const k=s.get(h.id);k.x-=_,k.y-=v}for(const l of o){if(!n.has(l.id))continue;const d=t[l.id],h=s.get(l.id),f=xn.centre/Math.max(1,l.hop);h.x+=(r.x-d.x)*f,h.y+=(r.y-d.y)*f;const p=Math.hypot(h.x,h.y),m=30*i,y=p>m?m/p:1;d.x+=h.x*y*Math.min(1,i*4),d.y+=h.y*y*Math.min(1,i*4)}}function e_(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++)wC(e,t,n,r,u),u*=a;return t}function _C(e,t,n,r=HT){const i=Ft(e),o=bC(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 e_(i,o,a,{x:t/2,y:n/2},r),s&&(o[s.id]={x:t/2,y:n/2}),t_(i,o,a)}function Qo(e,t,n,r){return t==="tree"?gC(e,n,r):_C(e,n,r)}function t_(e,t,n,r,i=22,o=60){const s=Ft(e),a=s.nodes.filter(d=>t[d.id]),u=new Map(a.map(d=>[d.id,Ns(Ln(d,s.checked_address,Ii(r,d.id)))])),c=a.filter(d=>n.has(d.id)),l=new Map(c.map((d,h)=>[d.id,h]));for(let d=0;d<o;d++){let h=!1;for(let f=0;f<c.length;f++)for(const p of a){const m=c[f];if(p===m)continue;const y=l.get(p.id);if(y!==void 0&&y<f)continue;const b=t[m.id],g=t[p.id],_=u.get(m.id),v=u.get(p.id),w=Math.min(b.x+_.x2,g.x+v.x2)-Math.max(b.x+_.x1,g.x+v.x1)+i,k=Math.min(b.y+_.y2,g.y+v.y2)-Math.max(b.y+_.y1,g.y+v.y1)+i;if(w<=0||k<=0)continue;h=!0;const x=w<k,D=x?g.x>=b.x?1:-1:g.y>=b.y?1:-1,F=(x?w:k)/2+.5,Z=n.has(m.id)&&n.has(p.id)?F:F*2;n.has(m.id)&&(x?b.x-=D*Z:b.y-=D*Z),n.has(p.id)&&(x?g.x+=D*Z:g.y+=D*Z)}if(!h)break}return t}const kC=300;function SC(e,t,n,r,i={}){const o=i.steps??kC,s=Ft(e),a=t[n],u={...t};if(!a)return u;const c=new Map(s.nodes.map(w=>[w.id,w])),l=[...r].sort().filter(w=>!u[w]&&c.has(w));if(!l.length)return u;const d=c.get(n)?.address,h=new Set(s.edges.filter(w=>w.to===d).map(w=>w.from)),f=new Set(s.edges.filter(w=>w.from===d).map(w=>w.to)),p=w=>{const k=c.get(w).address;return h.has(k)&&!f.has(k)},m=l.filter(p),y=l.filter(w=>!p(w)),b=(w,k)=>{w.forEach((D,F)=>{const M=Math.floor(F/10),Z=Math.min(10,w.length-M*10),ne=F-M*10,ce=Math.PI*.8,pe=(Z===1?0:-ce/2+ne*ce/(Z-1))+(Sr(D)-.5)*.2,Re=(xn.link+M*110)*(.9+Sr(D+"/r")*.2);u[D]={x:a.x+k*Math.cos(pe)*Re,y:a.y+Math.sin(pe)*Re}})};b(m,-1),b(y,1);const g=s.nodes.filter(w=>t[w.id]&&!l.includes(w.id)).map(w=>({point:t[w.id],box:Ns(Ln(w,s.checked_address,Ii(i.notes,w.id)))})),_=(w,k)=>{if(!w.length)return;const x=w.map(D=>({id:D,box:Ns(Ln(c.get(D),s.checked_address,Ii(i.notes,D)))}));for(let D=0;D<12;D++){const F={x1:1/0,y1:1/0,x2:-1/0,y2:-1/0};for(const{id:Z,box:ne}of x){const ce=u[Z];F.x1=Math.min(F.x1,ce.x+ne.x1),F.x2=Math.max(F.x2,ce.x+ne.x2),F.y1=Math.min(F.y1,ce.y+ne.y1),F.y2=Math.max(F.y2,ce.y+ne.y2)}let M=0;for(const Z of g){if(Math.min(F.y2,Z.point.y+Z.box.y2)-Math.max(F.y1,Z.point.y+Z.box.y1)+12<=0)continue;const ce=k<0?F.x2+24-(Z.point.x+Z.box.x1):Z.point.x+Z.box.x2+24-F.x1;ce>M&&(M=ce)}if(M<=0)break;for(const Z of w)u[Z].x+=k*M}},v=new Set(l);return e_(s,u,v,{x:a.x,y:a.y},o),t_(s,u,v,i.notes),_(m,-1),_(y,1),u}function xC(e,t,n,r=Ti){const i=Math.max(1,e.x2-e.x1),o=Math.max(1,e.y2-e.y1),s=pc(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 zp(e,t,n,r=Ti){return Math.min((t-r*2)/Math.max(1,e.x2-e.x1),(n-r*2)/Math.max(1,e.y2-e.y1))}function EC(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 Tn(e){return Math.round(e*100)/100}function Eu(e,t,n,r,i){const o=s=>`${Tn(s.x)},${Tn(s.y)}`;return{kind:e,start:t,end:i,controls:[n,r],d:`M${o(t)} C${o(n)} ${o(r)} ${o(i)}`}}function mc(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 h={x:e.x+n+i,y:e.y},f={x:t.x-r-i,y:t.y},p=f.x-h.x,m=Math.max(p*.45,Math.min(65,p));return Eu("forward",h,{x:h.x+m,y:h.y},{x:f.x-m,y:f.y},f)}if(o<=-u){const h={x:e.x,y:e.y-n-i},f={x:t.x,y:t.y-r-i},p=Math.max(100,Math.abs(o)*.2);return Eu("backward",h,{x:h.x+85,y:h.y-p},{x:f.x+85,y:f.y-p},f)}if(Math.abs(s)>u){const h=s>0?1:-1,f={x:e.x,y:e.y+h*(n+i)},p={x:t.x,y:t.y-h*(r+i)},m=Math.abs(p.y-f.y),y=Math.max(m*.45,Math.min(40,m));return Eu("vertical",f,{x:f.x,y:f.y+h*y},{x:p.x,y:p.y-h*y},p)}const c=EC(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${Tn(l.x)},${Tn(l.y)} L${Tn(d.x)},${Tn(d.y)}`}}const $C=6,$u=$C+3,nn=14,Dp=10,TC=3,Op=6;function CC(e,t,n){const r=Ft(e),i=[];for(const o of r.nodes){const s=t[o.id];if(s)for(const{kind:a,box:u}of mh(Ln(o,r.checked_address,Ii(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 AC(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 IC(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 NC(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 RC(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 n_(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 LC(e,t){const n=[];for(const r of e){const i=Math.max(1,Math.ceil(n_(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(NC(r.points,s))}}return n}function Pp(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 LC(e,TC))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)&&AC(a,l)<r)return!1}return!0}function zC(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(n_(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 h=l/(s-1===0?1:2),f=d/(s===r.length-1?1:2),p=Math.min(nn,h,f),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 DC(e){const t=i=>`${Tn(i.x)},${Tn(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 Mp(e,t,n,r,i){const o=Math.min(e.y,n)-nn,s=Math.max(e.y,n)+nn,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 h=t===1?d.x1:d.x2,f=t===1?d.x2:d.x1;a(f)>0&&(u=Math.min(u,Math.max(0,a(h))))}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,h)=>d[0]-h[0]);let l=r;for(const[d,h]of[...c,[1/0,1/0]]){if(d>l+1){const f=Math.min(d,u);if(f<=l+1)return null;const p=Number.isFinite(f)&&f-l<80?(l+f)/2:l+40;return e.x+t*p}if(l=Math.max(l,h),l>=u)return null}return null}function OC(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 PC=120;function MC(e,t,n,r,i,o=4){const s=mc(e,t,n,r,o);if(!s||!i.length)return s;const a=i.map(h=>IC(h,$u));if(Pp(RC(s),i,a,$u))return s;const u=new Set([e.y,t.y]),c=h=>Math.abs(h-e.y)<Op?e.y:Math.abs(h-t.y)<Op?t.y:h;for(const h of a)u.add(c(Math.round(h.y1)-nn-1)),u.add(c(Math.round(h.y2)+nn+1));const l=t.x>=e.x?1:-1,d=[[l,l],[l,-l],[-l,l],[-l,-l]];for(const[h,f]of d){const p={x:e.x+h*(n+o),y:e.y},m={x:t.x-f*(r+o),y:t.y},y=[];for(const b of u){const g=Math.abs(b-p.y)<.01?p.x:Mp(p,h,b,nn,a);if(g===null)continue;const _=Math.abs(b-m.y)<.01?m.x:Mp(m,-f,b,nn+Dp,a);if(_===null||Math.abs(b-m.y)<.01&&(m.x-g)*f<nn+Dp||Math.abs(b-p.y)<.01&&(_-p.x)*h<nn)continue;const v=OC([p,{x:g,y:p.y},{x:g,y:b},{x:_,y:b},{x:_,y:m.y},m]);if(!FC(v,a))continue;let w=(v.length-2)*nn,k;for(const x of v)k&&(w+=Math.abs(x.x-k.x)+Math.abs(x.y-k.y)),k=x;y.push({points:v,length:w})}y.sort((b,g)=>{const _=b.points[2]?.y,v=g.points[2]?.y;return b.length-g.length||(_===void 0||v===void 0?0:_-v)});for(const b of y){const g=zC(b.points);if(!Pp(g,i,a,$u))continue;const _=b.points,v=_[0],w=_[_.length-1];if(!v||!w)continue;const k={x1:Math.min(..._.map(x=>x.x)),y1:Math.min(..._.map(x=>x.y)),x2:Math.max(..._.map(x=>x.x)),y2:Math.max(..._.map(x=>x.y))};return{kind:"routed",start:v,end:w,controls:null,d:DC(g),bounds:k}}}return s}function FC(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(pC(i,o))return!1}n=r}return!0}function r_(e,t){if(!t)return Xt.rest;const n=Be(t);return Be(e.from)===n||Be(e.to)===n?Xt.related:Xt.faded}function UC(){return{hit:{stroke:"transparent",width:16},line:{stroke:Ye("edge"),width:1.6},arrow:{fill:Ye("edge")}}}function GC(e,t,n){return e!=="gravity"&&e!=="tree"?null:{layout:e,id:t,pointerId:n}}function jC(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 ZC(e,t,n,r=ZT){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 BC(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 Fp(e){return e==="Enter"||e===" "}function HC(e,t){return{x:(e.x-t.x)/t.scale,y:(e.y-t.y)/t.scale}}function VC(e,t,n,r,i){return!t||t.pointerId!==n||!Object.hasOwn(e,t.id)?!1:(e[t.id]=HC(r,i),!0)}function qC(e,t){return e?.pointerId===t?null:e}function WC(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 KC(e,t,n){const r=new Map;let i=null,o=null,s=null;function a(f){if(f===e)return{kind:"canvas",id:null};const p=f;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(f){if(f.pointerType==="mouse"&&f.button!==0)return;const p=n?n(f):a(f.target);if(!p)return;const m=t.point(f);if(r.set(f.pointerId,m),e.setPointerCapture(f.pointerId),p.kind!=="canvas"&&(f.preventDefault(),f.stopPropagation()),r.size===1){i=jC(p.kind,p.id,f.pointerId,{x:f.clientX,y:f.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(f){if(!r.has(f.pointerId))return;const p=t.point(f);if(r.set(f.pointerId,p),s){const[m,y]=[...r.values()];m&&y&&t.pinch(s,[m,y],f);return}if(i?.pointerId===f.pointerId){if(i=ZC(i,f.pointerId,{x:f.clientX,y:f.clientY}),!i?.moved)return;if(i.kind==="node"){t.drag(i.id??"",f.pointerId,p,f);return}if(i.kind==="edge")return}o&&t.pan(o,p,f)}function l(f,p=!1){const m=BC(i,f.pointerId,p);m&&t.select(m),i?.pointerId===f.pointerId&&(i=null),t.endDrag(f.pointerId),r.delete(f.pointerId),r.size||(i=null,o=null,s=null),e.hasPointerCapture(f.pointerId)&&e.releasePointerCapture(f.pointerId)}const d=f=>l(f),h=f=>l(f,!0);return e.addEventListener("pointerdown",u,!0),e.addEventListener("pointermove",c),e.addEventListener("pointerup",d),e.addEventListener("pointercancel",h),()=>{e.removeEventListener("pointerdown",u,!0),e.removeEventListener("pointermove",c),e.removeEventListener("pointerup",d),e.removeEventListener("pointercancel",h)}}function JC(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 i_(e){const t=String(e??"").toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):"Unknown"}function gc(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e)}function yc(e){return e==null?"Unavailable":new Intl.NumberFormat("en-US").format(e)}function Cn(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 o_(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 vc(e){if(e.amount_usd_sum==null||e.price_coverage_ratio===0)return"Unavailable";const t=e.price_coverage_ratio;return gc(e.amount_usd_sum)+(t!=null&&t>0&&t<1?" (priced portion)":"")}function YC(e){const t=[["Incoming amount (USD)",e.total_in_usd==null?"Unavailable":gc(e.total_in_usd)],["Outgoing amount (USD)",e.total_out_usd==null?"Unavailable":gc(e.total_out_usd)]];return e.role&&Wr.includes(e.role)?[["Role",Jw[e.role]||"Other"],...t,["Senders",yc(e.degree_in)],["Receivers",yc(e.degree_out)],["Labels",Nn(e).join(", ")||"No labels"],...e.self_route?[["Swapped for itself",nC(e.self_route)]]:[]]:[["Address risk",e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} · ${i_(e.risk_level)}`],["Confidence","Unavailable"],...t,["First activity (UTC)",Cn(e.first_activity_timestamp)],["Last activity (UTC)",Cn(e.last_activity_timestamp)],["Labels",Nn(e).join(", ")||"No labels"]]}function XC(e,t){if(e.source==="flows"){const r=tC(e);return[["From",e.from||"Unavailable"],["To",e.to||"Unavailable"],...r?[["Swap route",r]]:[],["Value (USD)",vc(e)],["Transfers",yc(e.tx_count)],["First seen (UTC)",Cn(e.first_seen_timestamp)],["Last seen (UTC)",Cn(e.last_seen_timestamp)],["Since last seen",o_(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)",vc(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)",Cn(e.first_seen_timestamp)],["Last seen (UTC)",Cn(e.last_seen_timestamp)],["First transaction",e.first_tx_id||"Unavailable"],["Last transaction",e.last_tx_id||"Unavailable"]]}function s_(e){return typeof e!="string"||!/^0x[a-fA-F0-9]{64}$/.test(e)?null:`https://robinhoodchain.blockscout.com/tx/${e.toLowerCase()}`}function bc(e){const t=Go(e);if(e.role)return`${e.address}. ${t||"Other"}.${Nn(e).length?` Labels: ${Nn(e).join(", ")}.`:""}`;const n=e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} ${i_(e.risk_level)} risk`,r=Nn(e).join(", ");return`${e.address}. ${n}.${r?` Labels: ${r}.`:""}`}const a_=80;function QC(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 eA(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 u_(e){const t=e.amount_usd_sum!=null&&e.price_coverage_ratio!==0?QC(e.amount_usd_sum):"",n=eA(e.first_seen_timestamp,e.last_seen_timestamp);return[t,n].filter(Boolean).join(" · ")}function wc(e,t){const n=kr(e).link?` ${Yw}.`:"",r=`${e.from} to ${e.to}.${n} Aggregate value ${vc(e)}. ${e.tx_count??0} ${e.tx_count===1?"transfer":"transfers"}.`;return e.source==="flows"&&e.last_seen_timestamp?`${r} Last seen ${o_(e.last_seen_timestamp,t)}.`:r}function tA(e,t){return Ft(e).nodes.map(n=>{const r={id:n.address,label:Nn(n).join(", ")||Go(n)};n.role&&(r.role=n.role);const i=t?.(n.address);return i&&(r.href=i),r})}function nA(e,t=22){return e.length>t?`${e.slice(0,t-1)}…`:e}function rA(e,t,n={}){const r=e.ownerDocument;let i=Ft(t),o=n.layout??(lh(t)?"tree":"gravity");const s={width:e.clientWidth||n.width||820,height:e.clientHeight||n.height||430};let a=Qo(i,o,s.width,s.height);const u=new Map,c=new Map;let l={x:0,y:0,scale:1},d=null,h=null,f=null;const p=n.now??(()=>Date.now()),m=T=>n.nodeStyle?.(T).stroke??lC(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:()=>h,colorOf:m,now:p,dimensions:()=>s},b={selectNode:(T,R)=>H(T,R),selectEdge:(T,R)=>Y(T,R),showTooltip:(T,R)=>G(T,R),hideTooltip:()=>ae(),lost:()=>j()};function g(T){const R=T==="webgl"?Ip("webgl"):null;if(R)try{return R(e,y,b,{label:n.label})}catch{}return Np(e,y,b,{label:n.label})}const _=n.renderer??(Ip("webgl")&&PT(r)?"webgl":"svg");let v=g(_);e.dataset.renderer=v.kind;const w=()=>{const T=hC(i,a,u);if(!T)return null;const R=v.linkBounds();return R&&(T.x1=Math.min(T.x1,R.x1),T.y1=Math.min(T.y1,R.y1),T.x2=Math.max(T.x2,R.x2),T.y2=Math.max(T.y2,R.y2)),T},k=()=>{const T=w();return T?xC(T,s.width,s.height,Ti):{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 D=0,F=!1,M=!1;function Z(){if(D){F=!0;return}v.build()}function ne(){if(D){M=!0;return}l=k(),ce()}function ce(){v.camera()}function pe(T="program"){const R=tA(i,n.href),J=d?.kind==="node"?i.nodes.find(ye=>ye.id===d.id)??null:null,oe=d?.kind==="edge"?i.edges.find(ye=>ye.id===d.id)??null:null;if(J){const ye=i.edges.filter(Xe=>Xe.from===J.address||Xe.to===J.address);return{kind:"node",id:J.id,selectedId:J.address,nodes:R,title:"Selected address",identity:J.address,values:YC(J),related:ye,node:J,edge:null,source:T}}return oe?{kind:"edge",id:oe.id,selectedId:null,nodes:R,title:"Selected aggregate flow",identity:`${oe.from} → ${oe.to}`,values:XC(oe,p()),related:[oe],node:null,edge:oe,source:T}:{kind:null,id:null,selectedId:null,nodes:R,title:"Nothing selected",identity:"",values:[],related:[],node:null,edge:null,source:T}}function Re(T){const R=pe(T);U(R),n.onSelect?.(R)}function U(T){const R=n.selectionRoot,J=R?.querySelector("[data-selection-title]"),oe=R?.querySelector("[data-selection-identity]"),ye=R?.querySelector("[data-selection-meta]");!J||!oe||!ye||(J.textContent=T.title,oe.textContent=T.identity,ye.replaceChildren(...T.values.map(([Xe,Se])=>{const vt=r.createElement("div");vt.className="meta-item",Se!=="Unavailable"&&(["From","To","First transaction","Last transaction"].includes(Xe)&&vt.classList.add("meta-item--identity"),Xe==="Incoming amount (USD)"&&vt.classList.add("meta-item--incoming"),Xe==="Outgoing amount (USD)"&&vt.classList.add("meta-item--outgoing")),["From","To","First transaction","Last transaction","Labels"].includes(Xe)&&vt.classList.add("meta-item--wide");const nr=r.createElement("span");nr.textContent=Xe;const Pn=r.createElement("strong"),xt=["First transaction","Last transaction"].includes(Xe)?s_(Se):null;if(xt&&n.openLink){const Vt=n.openLink,qt=r.createElement("button");qt.type="button",qt.className="cia-graph-explorer-link",qt.dataset.explorer=xt,qt.textContent=Se,qt.setAttribute("aria-label",`${Xe}: ${Se} (opens the explorer)`),qt.addEventListener("click",()=>Vt(xt)),Pn.append(qt)}else if(xt){const Vt=r.createElement("a");Vt.href=xt,Vt.target="_blank",Vt.rel="noopener noreferrer",Vt.textContent=Se,Vt.setAttribute("aria-label",`${Xe}: ${Se} (opens in new tab)`),Pn.append(Vt)}else Pn.textContent=Se;return vt.append(nr,Pn),vt})))}function H(T,R="program"){d=T?{kind:"node",id:T}:null,v.selection(),Re(R)}function Y(T,R="program"){d=T?{kind:"edge",id:T}:null,v.selection(),Re(R)}function me(T){if(T==null)return H(null);const R=Sn(i,T);if(R)return H(R);if(i.edges.some(J=>J.id===T))return Y(T)}function ie(){l=k(),ce()}function I(T,R={x:s.width/2,y:s.height/2}){const J=pc(l.scale*(1+T)),oe=J/l.scale;l={x:R.x-(R.x-l.x)*oe,y:R.y-(R.y-l.y)*oe,scale:J},ce()}function O(T){o=T,n.controls?.querySelectorAll("[data-layout]").forEach(R=>{R.classList.toggle("active",R.dataset.layout===T),R.setAttribute("aria-pressed",String(R.dataset.layout===T))}),n.onLayoutChange?.(T),a=Qo(i,o,s.width,s.height),v.geometry(),ie()}function G(T,R){x.textContent=R,x.hidden=!1;const J=e.getBoundingClientRect();x.style.left=`${Math.min(J.width-330,Math.max(8,T.clientX-J.left+12))}px`,x.style.top=`${Math.max(8,T.clientY-J.top+12)}px`}function ae(){x.hidden=!0}function de(T){return WC({x:T.clientX,y:T.clientY},v.surface.getBoundingClientRect(),s.width,s.height)}const te={point:de,transform:()=>l,select(T){T.type==="select-node"?H(T.id,"pointer"):T.type==="select-edge"?Y(T.id,"pointer"):H(null,"canvas")},drag(T,R,J){!f&&(f=GC(o,T,R),!f)||VC(a,f,R,J,l)&&(ge=!0,v.moveNode(f.id))},endDrag(T){const R=f?.pointerId===T&&ge;f=qC(f,T),R&&(ge=!1,v.endMove())},pan(T,R){l={x:T.transform.x+R.x-T.point.x,y:T.transform.y+R.y-T.point.y,scale:l.scale},ce()},startPinch(){f=null},pinch(T,[R,J]){const oe=Math.hypot(J.x-R.x,J.y-R.y),ye=pc(T.scale*oe/Math.max(1,T.distance));I(ye/l.scale-1,{x:(R.x+J.x)/2,y:(R.y+J.y)/2})}};let ge=!1;const X=T=>{T.preventDefault(),I(T.deltaY>0?-.12:.12,de(T))},be={ArrowLeft:[60,0],ArrowRight:[-60,0],ArrowUp:[0,60],ArrowDown:[0,-60]},We=T=>{if(T.target!==v.surface)return;const R=be[T.key];R?(T.preventDefault(),l={...l,x:l.x+R[0],y:l.y+R[1]},ce()):T.key==="+"||T.key==="="?I(.18):T.key==="-"?I(-.18):T.key==="0"&&ie()};let rt=()=>{};function st(){const T=v.surface,R=J=>v.pick(de(J));rt=KC(T,te,v.kind==="svg"?void 0:R),T.addEventListener("wheel",X,{passive:!1}),T.addEventListener("keydown",We)}function N(){rt(),v.surface.removeEventListener("wheel",X),v.surface.removeEventListener("keydown",We)}st();function j(){v.kind!=="svg"&&(N(),v.destroy(),v=Np(e,y,b,{label:n.label}),e.dataset.renderer=v.kind,e.append(x),st(),Z())}const V=n.controls?.querySelector("[data-expand]")??null,q=n.panel&&V?JC(n.panel,V,r.body):null,xe=()=>{q?.toggle(),n.onExpansionChange?.(q?.isOpen()??!1),requestAnimationFrame(ie)},ue=n.panel??e,Ee=T=>{if(T.key==="Tab"&&q?.isOpen()&&n.panel){const R=Array.from(n.panel.querySelectorAll('button,a[href],[tabindex="0"],summary')).filter(ye=>ye.checkVisibility()),J=R[0],oe=R.at(-1);T.shiftKey&&r.activeElement===J?(T.preventDefault(),oe?.focus()):!T.shiftKey&&r.activeElement===oe&&(T.preventDefault(),J?.focus())}if(T.key==="Escape"){if(q?.isOpen()){q.close(),n.onExpansionChange?.(!1),requestAnimationFrame(ie);return}H(null,"keyboard")}};ue.addEventListener("keydown",Ee);const $e=[],re=(T,R)=>{T&&(T.addEventListener("click",R),$e.push([T,R]))};n.controls?.querySelectorAll("[data-layout]").forEach(T=>re(T,()=>O(T.dataset.layout==="tree"?"tree":"gravity"))),re(n.controls?.querySelector("[data-zoom='in']"),()=>I(.18)),re(n.controls?.querySelector("[data-zoom='out']"),()=>I(-.18)),re(n.controls?.querySelector("[data-zoom='fit']"),ie),q&&re(V,xe);const Ae=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const T=e.clientWidth,R=e.clientHeight;!T||!R||T===s.width&&R===s.height||(s.width=T,s.height=R,v.resize(T,R),ie())});Ae?.observe(e),Z(),n.selected&&me(n.selected);const Ke={update(T){const R=a;i=Ft(T);const J=i.nodes.every(ye=>R[ye.id])?{}:Qo(i,o,s.width,s.height);a=Object.fromEntries(i.nodes.map(ye=>[ye.id,R[ye.id]??J[ye.id]]).filter(([,ye])=>ye)),d&&!(d.kind==="node"?i.nodes.some(ye=>ye.id===d.id):i.edges.some(ye=>ye.id===d.id))&&(d=null),h&&!i.nodes.some(ye=>ye.id===h)&&(h=null);const oe=new Set(i.nodes.map(ye=>ye.id));for(const ye of[...c.keys()])oe.has(ye)||c.delete(ye);Z(),ne()},merge(T,R){const J=sC(i,T,R);i=J.model;const oe=Sn(i,R??Ft(T).checked_address);return a=oe&&o==="gravity"?SC(i,a,oe,J.added,{notes:u}):Qo(i,o,s.width,s.height),Z(),J.added.length&&ne(),J.added},batch(T){D++;try{T()}finally{D--,!D&&F&&(F=!1,v.build()),!D&&M&&(M=!1,l=k(),ce())}},setTheme(T){T&&r.documentElement.setAttribute("data-theme",T),v.theme()},select:me,destroy(){Ae?.disconnect(),N(),ue.removeEventListener("keydown",Ee);for(const[T,R]of $e)T.removeEventListener("click",R);q?.close({restoreFocus:!1}),v.destroy(),x.remove(),e.classList.remove("cia-graph-engine"),delete e.dataset.renderer,delete e.ciaGraph},fit:ie,zoom:T=>I(T),setLayout:O,markNode(T,R){const J=Sn(i,T);J&&(R?u.set(J,R):u.delete(J),Z())},patchNode(T,R){const J=Sn(i,T),oe=J?i.nodes.find(ye=>ye.id===J):null;return oe?(Object.assign(oe,R),v.selection(),!0):!1},flagNode(T,R,J){const oe=Sn(i,T);if(!oe)return;const ye=c.get(oe)??new Set;J?ye.add(R):ye.delete(R),ye.size?c.set(oe,ye):c.delete(oe),D?F=!0:v.flag(oe,R,J)},positions:()=>structuredClone(a),model:()=>i,contentBounds:()=>w(),transform:()=>({...l}),highlight(T){h=T==null?null:Sn(i,T),v.selection()},renderer:()=>v.kind,clientPoint(T){const R=Sn(i,T),J=R?a[R]:null;if(!J)return null;const oe=v.surface.getBoundingClientRect(),ye=Math.min(oe.width/s.width,oe.height/s.height)||1,Xe=oe.left+(oe.width-s.width*ye)/2,Se=oe.top+(oe.height-s.height*ye)/2;return{x:Xe+(J.x*l.scale+l.x)*ye,y:Se+(J.y*l.scale+l.y)*ye}}};return Object.defineProperty(e,"ciaGraph",{value:Ke,configurable:!0}),Ke}const c_="chain-insights.flows.v1",uu="chain-insights.result.v1",l_=5e3,Up=6,iA=3,d_=/^0x[0-9a-fA-F]{40}$/,oA=/^0x[0-9a-fA-F]{64}$/;function sA(e){return typeof e=="string"&&(d_.test(e)||oA.test(e))}function Ni(e){return typeof e=="string"&&d_.test(e)}function _c(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function cu(e){const t=e?.facts?.query?.results;return Array.isArray(t)?t.filter(_c):[]}function aA(e){const t=e?.facts;return typeof t?.subject?.network=="string"&&t.subject.network?t.subject.network:"robinhood"}function Ct(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 gh(e){return e<1e11?e*1e3:e}const f_=/^\d{4}-\d{2}-\d{2}$/,uA=Date.UTC(2009,0,1),cA=Date.UTC(2100,0,1);function ms(e){return new Date(gh(e)).toISOString().slice(0,10)}function Rs(e){if(typeof e!="string"||!f_.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 lA=new Set(["day","date","hour","week","month"]),dA=["_timestamp","_time","_at"];function Gp(e){return lA.has(e)||dA.some(t=>e.endsWith(t))}function h_(e){const t=[];for(const n of e)for(const r of Object.keys(n))t.includes(r)||t.push(r);return t}function fA(e){return Array.isArray(e)?e.some(Ni):Ni(e)}function hA(e){return e.some(t=>Object.values(t).some(fA))}function p_(e){return e.length>0&&e.every(t=>Ni(t.from_address)&&Ni(t.to_address))}const pA=/^(\d{4})-(\d{2})$/,mA=/^(\d{4})-W(\d{2})$/,gA=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/,yA=/(?:Z|[+-]\d{2}:?\d{2})$/i;function vA(e,t){const n=Date.UTC(e,0,4);return n-(new Date(n).getUTCDay()+6)%7*864e5+(t-1)*7*864e5}function jp(e){if(typeof e=="string"){const r=e.trim();if(f_.test(r))return Rs(r)?Date.parse(`${r}T00:00:00Z`):null;const i=pA.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=mA.exec(r);if(o){const s=Number(o[2]);return s>=1&&s<=53?vA(Number(o[1]),s):null}if(gA.test(r)){const s=r.replace(" ","T"),a=Date.parse(yA.test(s)?s:`${s}Z`);return Number.isFinite(a)?a:null}}const t=Ct(e);if(t==null)return null;const n=gh(t);return n>=uA&&n<cA?n:null}const bA=1e18,Zp=13,wA=/^-?0*(\d+)(?:\.0+)?$/;function _A(e){const t=e.toLowerCase();return t==="balance"||t.endsWith("_balance")||t.endsWith("_wei")}function kA(e){if(typeof e=="string"){const t=wA.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 SA(e,t){if(!_A(e))return!1;if(e.toLowerCase().endsWith("_wei"))return!0;const n=t.filter(r=>r!=null).map(kA);return n.includes("wei")&&n.every(r=>r!=null)}function xA(e){return`${e.replace(/_wei$/i,"")} (ETH)`}function yh(e,t={}){if(e.length===0||hA(e))return null;const n=h_(e),i=n.filter(Gp).find(d=>e.some(h=>jp(h[d])!=null));if(!i)return null;const o=n.filter(d=>{if(Gp(d))return!1;const h=e.map(f=>f[d]).filter(f=>f!=null);return h.length>0&&h.every(f=>Ct(f)!=null)});if(o.length===0)return null;const s=o.slice(0,Up),a=new Map;let u=0;for(const d of e){const h=jp(d[i]);if(h==null)continue;u++;const f=a.get(h)??{count:0,sums:s.map(()=>null)};f.count++,s.forEach((p,m)=>{const y=Ct(d[p]);y!=null&&(f.sums[m]=(f.sums[m]??0)+y)}),a.set(h,f)}const c=[...a.entries()].sort((d,h)=>d[0]-h[0]);return c.filter(([,d])=>d.sums.some(h=>h!=null)).length<(t.minPoints??iA)?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,h)=>{const f=c.map(([,p])=>p.sums[h]??null);return SA(d,e.map(p=>p[d]))?{column:d,name:xA(d),unit:"ETH",values:f.map(p=>p==null?null:p/bA)}:{column:d,values:f}}),omittedColumns:o.slice(Up),skippedRows:e.length-u,failures:[]}}function EA(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 $A=e=>e==null||Ct(e)!=null;function m_(e){const t=y_(e);if(t.length<3||!t.every(c=>Rs(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($A))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:EA(c.error)})),u=yh(s,{minPoints:1});return u?{rows:s,columns:r,failures:a,model:{...u,failures:a}}:null}const TA=/\baddress\s*:\s*(["'])(0x[0-9a-fA-F]{40})\1/g,CA=/^\s*(<)?-(?:\[[^\]]*\])?-(>)?/,AA=/(<)?-(?:\[[^\]]*\])?-(>)?\s*$/;function Bp(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 g_(e){if(typeof e!="string"||!e)return null;const t=[...e.matchAll(TA)];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=[Bp(AA.exec(e.slice(0,o)),"before"),Bp(CA.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 IA(e,t){if(e.length===0||p_(e))return null;const n=g_(t);if(!n)return null;const r=n.address.toLowerCase(),i=h_(e).filter(s=>e.every(a=>Ni(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 NA(e){return p_(e)?"graph":yh(e)?"chart":"table"}const RA=[["sanctioned","sanctioned"],["scam","scam"],["victim","victim"],["pool","pool"],["exchange","exchange"],["selftrader","self_trader"]];function Hp(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim()!=="").map(t=>t.trim()):[]}function LA(e,t){if(t)return"exchange";const n=new Set(e.map(r=>r.replace(/\s+/g,"").toLowerCase()));for(const[r,i]of RA)if(n.has(r))return i;return"other"}const es=(e,t)=>e==null?t:t==null?e:e+t;function zA(e,t="robinhood",n){const r=new Map;for(const f of e)for(const p of new Set([String(f.from_address).toLowerCase(),String(f.to_address).toLowerCase()]))r.set(p,(r.get(p)??0)+1);let i="",o=0;for(const[f,p]of r)p>o&&(i=f,o=p);const s=n?.toLowerCase();s&&r.has(s)&&(i=s);const a=new Map,u=new Map,c=(f,p,m)=>{const y=a.get(f)??{address:f,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(f,y)};i&&a.set(i,{address:i,labels:[],exchange:!1});let l=0;for(const f of e){const p=String(f.from_address).toLowerCase(),m=String(f.to_address).toLowerCase(),y=[p,m].filter((w,k,x)=>!a.has(w)&&x.indexOf(w)===k).length;if(a.size+y>l_||(l++,c(p,Hp(f.from_labels),f.from_is_exchange===!0),c(m,Hp(f.to_labels),f.to_is_exchange===!0),p===m&&!As(f.link_kind).includes(dh)))continue;const b=`${p}->${m}`,g=u.get(b)??{from:p,to:m,usd:null,tx:null,first:null,last:null,kinds:[],bought:null,swaps:null};g.usd=es(g.usd,Ct(f.amount_usd_sum)),g.tx=es(g.tx,Ct(f.tx_count));const _=Ct(f.first_seen_timestamp),v=Ct(f.last_seen_timestamp);_!=null&&(g.first=g.first==null?_:Math.min(g.first,_)),v!=null&&(g.last=g.last==null?v:Math.max(g.last,v));for(const w of As(f.link_kind))g.kinds.includes(w)||g.kinds.push(w);g.bought=es(g.bought,Ct(f.bought_usd??f.bought_usd_sum)),g.swaps=es(g.swaps,Ct(f.swap_count)),u.set(b,g)}const d=[...a.values()].map(f=>({address:f.address,role:LA(f.labels,f.exchange),labels:f.labels})),h=[...u.values()].map(f=>({from:f.from,to:f.to,usd:f.usd,tx_count:f.tx,first_seen_ms:f.first,last_seen_ms:f.last,...f.kinds.length?{link_kind:f.kinds.join(", ")}:{},...f.bought!=null?{bought_usd:f.bought}:{},...f.swaps!=null?{swap_count:f.swaps}:{}}));return{view:{schema:c_,network:t,center:i,nodes:d,edges:h,truncated:!1},rowsTotal:e.length,rowsDrawn:l,rowsLeftOut:e.length-l,addresses:a.size}}function y_(e){const t=e?.facts?.queries;return Array.isArray(t)?t.filter(_c).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(_c):[],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 Vp=200;function Kr(e){return(e?.content??[]).filter(t=>t?.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
109
+ `).trim()}function ei(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 v_(e){if(!e)return null;const t=e.structuredContent,n=ei(t?.error)??ei(t?.facts?.error)??ei(t?.facts?.query?.error);if(!e.isError||n)return n;const r=Kr(e);if(r.startsWith("{"))try{const i=JSON.parse(r),o=ei(i?.error)??ei(i);if(o)return o}catch{}return r||"The tool answered with an error."}const DA=new Set(["usage_status","subscription_status","meta_usage_status","meta_subscription_status"]);function b_(e){if(!e||v_(e)!=null)return"text";const t=e.structuredContent;if(t?.schema===c_)return"flows";if(t?.schema===uu){if(t.tool==="graph_query")return NA(cu(t));if(t.tool==="graph_query_batch")return!Array.isArray(t.facts?.queries)||t.facts.queries.length===0?"text":m_(t)?"chart":"batch";if(typeof t.tool=="string"&&DA.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 OA(e,t){const n=A(e,"code",{class:"cv-addr",title:t,"data-full":t,text:Ai(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",()=>{PA(e,t,n,r)}),A(e,"span",{class:"cv-addr-cell"},n,r)}async function PA(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 MA(e,t){return/(timestamp|seen|_at|_ms|time)$/i.test(t)&&e>1e9?Cn(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 FA=160,qp=2e3;function UA(e,t=FA){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 w_(e,t,n){const r=e.ownerDocument,i=n.full!=null&&n.full.length>qp?`${n.full.slice(0,qp-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 GA(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,Vp),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>Vp||t?.truncated===!0,elapsedMs:typeof t?.elapsed_ms=="number"?t.elapsed_ms:null}}function jA(e,t,n){return t==null?A(e,"span",{class:"cv-null","aria-label":"empty",text:"—"}):sA(t)?OA(e,t):typeof t=="number"?e.createTextNode(MA(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 ZA={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 BA(e){const t=ZA[e];if(t)return t;const n=e.replace(/_/g," ").trim();return n?n[0].toUpperCase()+n.slice(1):e}function Wp(e,t,n={}){const r=e.ownerDocument,i=GA(t.structuredContent),o=i.rows.length;if(i.total===0)return w_(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:BA(u)})))),A(r,"tbody",{},...i.rows.map(u=>A(r,"tr",{},...i.columns.map(c=>A(r,"td",{},jA(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 ti=(e,t=0)=>typeof e=="number"&&Number.isFinite(e)?e:t,ts=e=>typeof e=="string"&&e?e:null;function HA(e){const t=e?.facts??{};if(typeof t.wallet=="string"&&t.wallet)return{kind:"wallet",wallet:t.wallet,tier:String(t.tier??"anonymous"),allowanceUsd:ti(t.allowance_usd),consumedUsd:ti(t.consumed_usd),windowEnd:ts(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=ts(n.access_mode);return{kind:"free",unit:r?"units":"seconds",used:ti(r?n.daily_units_used:n.daily_seconds_used),limit:ti(r?n.daily_units_limit:n.daily_seconds_limit),remaining:ti(r?n.remaining_units:n.remaining_seconds),resetAt:ts(n.reset_at),identifierKind:ts(n.identifier_kind),accessMode:i,noLimit:!r&&i==="public_free"&&n.daily_seconds_limit===0}}return{kind:"unknown"}}const Kp=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e),ns=(e,t)=>`${new Intl.NumberFormat("en-US").format(e)} ${t==="units"?e===1?"unit":"units":e===1?"second":"seconds"}`;function Tu(e){if(!e)return"No active window";const t=Date.parse(e);return Number.isFinite(t)?`${Cn(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 Cu(e,t){return A(e,"dl",{class:"cv-facts"},...t.flatMap(([n,r])=>[A(e,"dt",{text:n}),A(e,"dd",{text:r})]))}function VA(e,t){const n=e.ownerDocument,r=HA(t.structuredContent);let i,o,s;return r.kind==="wallet"?(o="Wallet allowance",s=`${Ai(r.wallet)} · ${r.tier==="subscriber"?"Subscriber":"No active subscription"}`,i=[Jp(n,r.consumedUsd,r.allowanceUsd,"Share of today's allowance used"),Cu(n,[["Daily allowance",Kp(r.allowanceUsd)],["Used today",Kp(r.consumedUsd)],["Window ends",Tu(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"}),Cu(n,[["Daily allowance","No daily limit"],["Used today",ns(r.used,r.unit)],["Window ends",Tu(r.resetAt)]])]:[Jp(n,r.used,r.limit,"Share of today's free allowance used"),Cu(n,[["Daily allowance",ns(r.limit,r.unit)],["Used today",ns(r.used,r.unit)],["Left today",ns(r.remaining,r.unit)],["Window ends",Tu(r.resetAt)]])]):(o="Usage",s="The server sent no allowance figures.",i=[A(n,"p",{class:"cv-muted",text:Kr(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 Ri(e,t,n="No drawing for this answer."){const r=e.ownerDocument,i=v_(t);if(i!=null){w_(e,UA(i),{kind:"refused",view:"text",full:i});return}const o=Kr(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 vh(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 qA="http://www.w3.org/2000/svg",kc=720,WA=320,KA=6,JA=420,Yp=4,YA=120,pi={left:70,right:18,top:6},Sc=18,__=16,k_=6,S_=26,XA=170,QA=82,e1=28,t1=80,Vn=1e3,$n=60*Vn,sr=60*$n,rn=24*sr,n1=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function x_(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 r1=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}),i1=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumSignificantDigits:2}),o1=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",notation:"compact",maximumFractionDigits:1}),Li=new Intl.NumberFormat("en-US",{maximumFractionDigits:0}),s1=new Intl.NumberFormat("en-US",{maximumFractionDigits:4}),E_=new Intl.NumberFormat("en-US",{maximumSignificantDigits:3}),$_=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:2}),a1=new Intl.NumberFormat("en-US",{maximumFractionDigits:6}),u1=new Intl.NumberFormat("en-US",{maximumSignificantDigits:4}),c1=new Intl.NumberFormat("en-US",{maximumSignificantDigits:6}),bh=e=>e.name??e.column;function mi(e,t){if(e==null)return"—";if(t==="eth")return`${c1.format(e)} ETH`;const n=e!==0&&Math.abs(e)<.01;return t==="usd"?n?i1.format(e):r1.format(e):t==="count"?Li.format(e):n?E_.format(e):s1.format(e)}function l1(e){return e!==0&&Math.abs(e)<.01?E_.format(e):Math.abs(e)<1e3?a1.format(Math.round(e*100)/100):$_.format(e)}function Ls(e,t){return t==="eth"?`${u1.format(e)} ETH`:t==="usd"?Math.abs(e)<1e3?mi(e,"usd"):o1.format(e):t==="count"?Math.abs(e)<1e3?Li.format(e):$_.format(e):l1(e)}function d1(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 T_(e){return e<=rn?"time":e<=YA*rn?"day":"month"}const f1=[Vn,2*Vn,5*Vn,10*Vn,15*Vn,30*Vn,$n,2*$n,5*$n,10*$n,15*$n,30*$n,sr,2*sr,3*sr,6*sr,12*sr,rn],h1=[1,2,3,7,14,30,60].map(e=>e*rn),p1=[1,2,3,6,12,24,60,120],Xp=4*rn,m1={time:76,day:84,month:72},g1=e=>new Date(e).getUTCFullYear()*12+new Date(e).getUTCMonth(),Au=e=>Date.UTC(Math.floor(e/12),e%12,1);function y1(e,t,n){const r=t-e,i=T_(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 p1){const a=[];let u=g1(e);for(Au(u)<e&&u++;Au(u)<=t;u++)u%s===0&&a.push(Au(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"?f1:h1){const a=s===7*rn||s===14*rn?Math.ceil((e-Xp)/s)*s+Xp:i==="day"?Math.ceil(e/rn)*rn: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 v1(e,t,n){const r=new Date(e),i=r.toISOString();return t==="month"?n>=12?i.slice(0,4):`${n1[r.getUTCMonth()]} ${r.getUTCFullYear()}`:t==="day"||e%rn===0?i.slice(0,10):n>0&&n<$n?i.slice(11,19):i.slice(11,16)}function b1(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:bh(t),kind:x_(t.column,t.values,t.unit),total:n,peak:r,peakTime:i,latest:o,latestTime:s}})}const Pt=e=>new Date(e).toISOString(),C_=(e,t)=>Pt(e).slice(0,10)===Pt(t).slice(0,10);function w1(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?`${Pt(t).slice(0,10)} UTC`:`${Pt(t).slice(0,10)} to ${Pt(n).slice(0,10)} UTC`;const r=i=>`${Pt(i).slice(0,10)} ${Pt(i).slice(11,16)}`;return t===n?`${r(t)} UTC`:C_(t,n)?`${r(t)} to ${Pt(n).slice(11,16)} UTC`:`${r(t)} to ${r(n)} UTC`}function _1(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=[w1(e),`${Li.format(r)} ${r===1?"point":"points"}${i>r?` from ${Li.format(i)} transfers`:""}`],s=e.times[0]??0,a=e.times[e.times.length-1]??0;for(const u of b1(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 ${Pt(d).slice(0,10)}`:C_(s,a)?`at ${Pt(d).slice(11,19)}`:`at ${Pt(d).slice(0,10)} ${Pt(d).slice(11,16)}`,l=`peak ${mi(u.peak,u.kind)} ${c(u.peakTime)}`;u.kind==="eth"&&u.latestTime!=null?o.push(`${u.name}: latest ${mi(u.latest,u.kind)} ${c(u.latestTime)}, ${l}`):o.push(`${u.name}: total ${mi(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 k1(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 S1(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 x1(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 E1(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 A_=e=>`var(--cia-graph-series-${e%KA+1})`;function zs(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 Iu(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 I_(e,t){return e.plotBottom-(t-e.min)/(e.max-e.min||1)*(e.plotBottom-e.plotTop)}function $1(e){if(e<=1)return XA;const t=Math.floor((JA-pi.top-k_-S_-(e-1)*__)/e)-Sc;return Math.max(e1,Math.min(QA,t))}const T1=6.6,C1=3,A1=12;function I1(e){let t=0;for(const n of e)t+=/[.,\s]/.test(n)?C1:T1;return t}function N1(e){const t=e.reduce((n,r)=>Math.max(n,I1(r)),0);return Math.max(pi.left,Math.ceil(t+A1))}function Qp(e,t=kc,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(_=>_!=null),b=Math.min(0,...y),g=Math.max(...y,b+1e-9);return{min:b,max:g,kind:x_(m.column,m.values,m.unit)}}),o=N1(i.flatMap(({min:m,max:y,kind:b})=>[Ls(m,b),Ls(y,b)])),s=t-pi.right,a=e.times[0]??0,u=e.times[e.times.length-1]??a,c={plotLeft:o,plotRight:s,first:a,last:u},l=$1(r.length),d=r.map(({series:m,index:y},b)=>{const g=pi.top+b*(Sc+l+__),_=g+Sc,v=_+l,{min:w,max:k,kind:x}=i[b],D={plotTop:_,plotBottom:v,min:w,max:k},F=[],M=[];let Z=[];return m.values.forEach((ne,ce)=>{if(ne==null){Z.length&&M.push(Z),Z=[];return}const pe=e.times[ce]??a,Re={x:zs(c,pe),y:I_(D,ne),time:pe,value:ne,index:ce};F.push(Re),Z.push(Re)}),Z.length&&M.push(Z),{column:m.column,name:bh(m),index:y,kind:x,color:A_(y),top:g,plotTop:_,plotBottom:v,min:w,max:k,runs:M,points:F}}),h=(d[d.length-1]?.plotBottom??pi.top)+k_,f=T_(u-a),p=[];if(e.times.length){const m=y1(a,u,(s-o)/m1[f]);for(const y of m.times){const b=zs(c,y),g=b-o<34?"start":s-b<34?"end":"middle";p.push({x:b,label:v1(y,m.unit,m.step),anchor:g})}}return{width:t,height:h+S_,plotLeft:o,plotRight:s,first:a,last:u,unit:f,lanes:d,ticks:p,axisY:h}}function at(e,t,n={}){const r=e.createElementNS(qA,t);for(const[i,o]of Object.entries(n))r.setAttribute(i,String(o));return r}const Wt=e=>Math.round(e*10)/10;let R1=0;const L1="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 z1(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=kc,d=t,h=Qp(t,l);const f=A(r,"span",{class:"cv-muted cv-chart-summary","data-chart-summary":""}),p=t.series.map((I,O)=>{const G=A(r,"span",{class:"cv-chart-key","aria-hidden":"true"});G.style.setProperty("--cv-key",A_(O));const ae=A(r,"button",{type:"button",class:"cv-chart-series","data-series":I.column,"aria-pressed":"true"},G,A(r,"span",{text:bh(I)}));return ae.addEventListener("click",()=>{const de=E1(s,I.column,i);de!==s&&(s=de,M())}),ae}),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=at(r,"svg",{class:"cv-chart-svg",role:"img",preserveAspectRatio:"xMidYMid meet"}),g=A(r,"div",{class:"cv-chart-readout",id:`cv-chart-readout-${++R1}`,"data-chart-readout":"",role:"status","aria-live":"polite",hidden:!0}),_=A(r,"div",{class:"cv-chart-plot",tabindex:0,role:"group","aria-label":L1,"aria-describedby":g.id},b),v=A(r,"div",{class:"cv-chart-body"},_,g),w=at(r,"rect",{class:"cv-chart-brush"}),k=at(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),D=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"}),f)),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(D);function F(){const I=[],O=h.lanes[0]?.plotTop??0,G=d.times.length>1?(h.plotRight-h.plotLeft)/(d.times.length-1):24,ae=Math.max(6,Math.min(24,G*.6));for(const te of d.failures){const ge=zs(h,te.time),X=at(r,"rect",{class:"cv-chart-failure","data-failure":te.day,x:Wt(ge-ae/2),y:O,width:Wt(ae),height:Math.max(0,h.axisY-O)});I.push(X)}for(const te of h.lanes){const ge=at(r,"g",{class:"cv-chart-lane","data-series":te.column}),X=at(r,"rect",{class:"cv-chart-swatch",x:h.plotLeft,y:te.top+4,width:14,height:4,rx:2});X.style.fill=te.color;const be=at(r,"text",{class:"cv-chart-name",x:h.plotLeft+20,y:te.top+11});be.textContent=te.name,ge.append(X,be,at(r,"line",{class:"cv-chart-grid",x1:h.plotLeft,x2:h.plotRight,y1:te.plotTop,y2:te.plotTop}),at(r,"line",{class:"cv-chart-base",x1:h.plotLeft,x2:h.plotRight,y1:te.plotBottom,y2:te.plotBottom}));const We=at(r,"text",{class:"cv-chart-tick",x:h.plotLeft-8,y:te.plotTop+4,"text-anchor":"end"});We.textContent=Ls(te.max,te.kind);const rt=at(r,"text",{class:"cv-chart-tick",x:h.plotLeft-8,y:te.plotBottom+4,"text-anchor":"end"});rt.textContent=Ls(te.min,te.kind),ge.append(We,rt);for(const st of te.runs){if(st.length<2)continue;const N=at(r,"polyline",{class:"cv-chart-line",points:st.map(j=>`${Wt(j.x)},${Wt(j.y)}`).join(" "),fill:"none"});N.style.stroke=te.color,ge.append(N)}if(te.points.length<=t1)for(const st of te.points){const N=at(r,"circle",{class:"cv-chart-dot",cx:Wt(st.x),cy:Wt(st.y),r:3,"data-index":a.start+st.index,"data-time":st.time});N.style.fill=te.color,ge.append(N)}I.push(ge)}const de=at(r,"g",{class:"cv-chart-axis"});for(const te of h.ticks){const ge=at(r,"text",{class:"cv-chart-tick",x:Wt(te.x),y:h.axisY+14,"text-anchor":te.anchor});ge.textContent=te.label,de.append(ge)}return I.push(de),I}function M(){d=x1(t,a.start,a.end),h=Qp(d,l,s);const I=h.lanes.map(G=>G.name);b.setAttribute("viewBox",`0 0 ${h.width} ${h.height}`),b.setAttribute("aria-label",`Line chart of ${I.join(", ")} by ${t.xColumn}, ${d.times.length} ${d.times.length===1?"point":"points"}`),b.replaceChildren(w,...F(),k),f.textContent=_1(d,s);for(const G of p){const ae=!s.has(G.dataset.series??"");G.setAttribute("aria-pressed",String(ae)),ae&&I.length===1?(G.setAttribute("aria-disabled","true"),G.title="At least one series stays visible"):(G.removeAttribute("aria-disabled"),G.removeAttribute("title"))}const O=a.start!==o.start||a.end!==o.end;y.hidden=!O,D.dataset.zoomed=String(O),Z(),ne()}function Z(){if(!c||Math.abs(c.to-c.from)<Yp){w.style.display="none";return}const I=h.lanes[0]?.plotTop??0,O=Math.max(h.plotLeft,Math.min(c.from,c.to)),G=Math.min(h.plotRight,Math.max(c.from,c.to));w.setAttribute("x",String(Wt(O))),w.setAttribute("width",String(Wt(Math.max(0,G-O)))),w.setAttribute("y",String(I)),w.setAttribute("height",String(Math.max(0,h.axisY-I))),w.style.display=""}function ne(){if(k.replaceChildren(),u==null||u<a.start||u>a.end){u=null,k.style.display="none",g.hidden=!0,g.replaceChildren(),delete _.dataset.focus;return}const I=u-a.start,O=d.times[I]??h.first,G=Wt(zs(h,O)),ae=h.lanes[0]?.plotTop??0;k.append(at(r,"line",{class:"cv-chart-crossline",x1:G,x2:G,y1:ae,y2:h.axisY}));const de=[];for(const X of h.lanes){const be=d.series[X.index]?.values[I]??null;if(be!=null){const rt=at(r,"circle",{class:"cv-chart-focus",cx:G,cy:Wt(I_(X,be)),r:4.5});rt.style.fill=X.color,k.append(rt)}const We=A(r,"span",{class:"cv-chart-key","aria-hidden":"true"});We.style.setProperty("--cv-key",X.color),de.push(A(r,"dt",{},We,X.name),A(r,"dd",{"data-value":X.column,text:mi(be,X.kind)}))}k.style.display="",k.dataset.index=String(u),k.dataset.time=String(O),_.dataset.focus=String(u);const te=d.failures.find(X=>X.time===O),ge=d.rowCounts[I]??1;g.replaceChildren(...[A(r,"time",{datetime:new Date(O).toISOString(),text:d1(O,d.daily)}),te?A(r,"p",{class:"cv-chart-readout-note","data-failure":te.code,text:`No answer: ${te.code}`}):null,ge>1?A(r,"p",{class:"cv-chart-readout-note","data-rows":ge,text:`${Li.format(ge)} transfers`}):null,A(r,"dl",{},...de)].filter(X=>X!=null)),g.hidden=!1,ce(G,ae)}function ce(I,O){const G=b.getBoundingClientRect(),ae=v.getBoundingClientRect(),de=G.width>0?G.width/h.width:1,te=G.left-ae.left+I*de,ge=I>(h.plotLeft+h.plotRight)/2;g.style.left=`${Math.round(ge?te-12:te+12)}px`,g.style.top=`${Math.round(G.top-ae.top+O*de)}px`,g.dataset.side=ge?"left":"right"}const pe=I=>{const O=b.getBoundingClientRect();return O.width>0?(I-O.left)*h.width/O.width:Number.NaN},Re=I=>a.start+k1(d.times,Iu(h,I));_.addEventListener("pointermove",I=>{const O=pe(I.clientX);Number.isFinite(O)&&(c&&(c.to=O,Z()),u=Re(O),ne())}),_.addEventListener("pointerdown",I=>{if(I.button!==0)return;const O=pe(I.clientX);if(Number.isFinite(O)){I.preventDefault(),_.focus({preventScroll:!0}),c={from:O,to:O,pointer:I.pointerId};try{_.setPointerCapture(I.pointerId)}catch{}}});const U=I=>{if(!c)return;const{from:O,to:G,pointer:ae}=c;c=null;try{_.releasePointerCapture(ae)}catch{}if(Z(),!I||Math.abs(G-O)<Yp)return;const de=S1(t.times,Iu(h,O),Iu(h,G));!de||de.start===a.start&&de.end===a.end||(a=de,u=Re(G),M())};_.addEventListener("pointerup",()=>U(!0)),_.addEventListener("pointercancel",()=>U(!1)),_.addEventListener("pointerleave",()=>{c||(u=null,ne())}),_.addEventListener("keydown",I=>{let O;if(I.key==="ArrowRight")O=u==null?a.start:Math.min(a.end,u+1);else if(I.key==="ArrowLeft")O=u==null?a.end:Math.max(a.start,u-1);else if(I.key==="Home")O=a.start;else if(I.key==="End")O=a.end;else if(I.key==="Escape"){if(u==null&&!c)return;c&&U(!1),O=null}else return;I.preventDefault(),u=O,ne()}),y.addEventListener("click",()=>{a=o,u=null,M(),_.focus({preventScroll:!0})});const H=()=>{const I=Math.round(_.clientWidth);return I>0?Math.max(WA,I):null},Y=()=>{const I=H();I==null||I===l||(l=I,M())};l=H()??kc,M();const me=r.defaultView?.ResizeObserver,ie=me?new me(()=>Y()):null;return ie?.observe(_),{root:D,get layout(){return h},refit:Y,destroy(){ie?.disconnect()}}}const D1="chain-insights.transfers.v1",O1="graph_expand",N_=25;function P1(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??N_}}function M1(e,t){const n=typeof e.first_seen_timestamp=="number"&&e.first_seen_timestamp>0?ms(e.first_seen_timestamp):null,r=typeof e.last_seen_timestamp=="number"&&e.last_seen_timestamp>0?ms(e.last_seen_timestamp):ms(t);return{first:n,last:n&&r<n?n:r}}function F1(e){if(!e)return"no answer";const t=Kr(e);return e.isError?t||"the server refused the read":/query_timeout|topology_busy/.test(t)?t:R_(e.structuredContent)?null:t||"the answer held no transfers"}function R_(e){const t=e;if(!t||t.schema!==D1||!Array.isArray(t.transfers)||typeof t.from!="string"||typeof t.to!="string"||!Rs(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=Ct(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:Ct(s.amount_usd)})}const r=t.next,i=r&&typeof r=="object"&&Rs(r.day)?{day:r.day,skip:Math.max(0,Math.floor(Ct(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 U1(e){return[...e].sort((t,n)=>(n.block_timestamp??0)-(t.block_timestamp??0)||t.tx_id.localeCompare(n.tx_id))}function G1(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 j1(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 Z1(e){return e==null?"—":`${new Date(gh(e)).toISOString().slice(11,19)} UTC`}function Nu(e){return new Intl.DateTimeFormat("en-GB",{dateStyle:"medium",timeZone:"UTC"}).format(new Date(`${e}T00:00:00Z`))}function B1(e,t){const n=new Map;for(const r of e){const i=r.block_timestamp==null?t:ms(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 H1(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 ${N_} before ${Nu(c.next.day)}`:"More transfers");const b=[];if(y)for(const g of B1(c.transfers,c.day))b.push(A(e,"p",{class:"cv-link-day","data-link-day":g.day,text:`${Nu(g.day)} (UTC)`})),b.push(A(e,"ol",{class:"cv-transfers"},...g.transfers.map(_=>V1(e,_,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 ${Nu(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 h(y){const b=++l,g=c;g.status="loading",g.error=null,d(),t.onLayout?.();let _=null;try{_=await t.host.callServerTool({name:O1,arguments:P1(t.network,g.from,g.to,g.day,{firstDay:g.firstDay,cursor:y})})}catch(w){_={isError:!0,content:[{type:"text",text:w instanceof Error?w.message:String(w)}]}}if(b!==l||c!==g)return g;const v=F1(_);if(v)g.status="error",g.error=v.length>300?`${v.slice(0,299)}…`:v;else{const w=R_(_.structuredContent),k=new Set(g.transfers.map(x=>x.tx_id+String(x.block_timestamp)));g.status="ready",g.transfers=[...g.transfers,...U1(w.transfers).filter(x=>!k.has(x.tx_id+String(x.block_timestamp)))],g.truncated=g.truncated||w.truncated,g.next=w.next,g.pages+=1}return d(),t.onLayout?.(),g}const f=()=>m.close(),p=()=>{m.more()};i.addEventListener("click",f),a.addEventListener("click",p);const m={element:u,open(y){const b=M1(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},h(null)},async more(){return!c||c.status==="loading"||!c.next?null:h(c.next)},close(){l++,c=null,d(),t.onLayout?.()},state:()=>c?{...c,transfers:[...c.transfers]}:null,destroy(){l++,i.removeEventListener("click",f),a.removeEventListener("click",p)}};return m}function V1(e,t,n){const r=s_(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:Ai(t.tx_id)}):A(e,"code",{title:t.tx_id,text:Ai(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:Z1(t.block_timestamp)}),A(e,"span",{class:"cv-transfer-amount",text:`${G1(t.amount)}${t.asset_symbol?` ${t.asset_symbol}`:""}`}),A(e,"span",{class:"cv-transfer-usd",text:t.amount_usd==null?"— USD":j1(t.amount_usd)}),o)}const q1="chain-insights.refusal.v1",W1=.2;function ui(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function gi(e){const t=typeof e=="number"?e:typeof e=="string"?Number(e):NaN;return Number.isFinite(t)?t:null}function K1(e){return(e?.content??[]).filter(t=>t.type==="text").map(t=>t.text??"").join(`
110
+ `)}function L_(e){const t=ui(e);if(!t)return null;const n=ui(t.facts);return ui(n?.usage)??ui(t.usage)}function em(e){if(!e?.isError)return null;const t=ui(e.structuredContent);if(t&&t.schema===q1){const r=L_(t);if(t.code==="free_tier_spent")return{kind:"free_tier_spent",used:gi(r?.daily_units_used),limit:gi(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=K1(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 z_(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 yi=e=>e==null?null:new Intl.NumberFormat("en-US").format(e);function tm(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?`${yi(e.used)} of ${yi(e.limit)} free units used today`:"every free unit used today"}. They are back at ${z_(e.resetAt)} your time. Until then each click is a paid call.`}function J1(e){if(!e||e.isError)return null;const t=L_(e.structuredContent);if(!t||t.access_mode!=="public_free")return null;const n=gi(t.daily_units_used),r=gi(t.daily_units_limit);if(n==null||r==null||r<=0)return null;const i=gi(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<W1,spent:i<=0}}function Y1(e,t){return e.spent?`Free credits today: 0 of ${yi(e.limit)} left, back at ${z_(e.resetAt)} your time`:`Free credits today: ${yi(e.remaining)} of ${yi(e.limit)} left`}const nm="graph_expand",X1="meta_usage_status",rs="too busy to expand",D_=640,Q1=300,Ru=.45,eI="Full screen shows the whole graph",tI="Open in browser",Lu="The host did not open the link.",nI="If nothing opened, copy this link into your browser:",rm=400,rI=9e3,zu="expanded",O_=5e3,iI="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.",oI="chain-insights.address.v1";function sI(e,t){return{network:e,address:t,details:!0}}function aI(e){const t=e;if(!t||t.schema!==oI||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"&&Wr.includes(t.role)&&(r.role=t.role),r}function uI(e){return e.total_in_usd==null&&e.total_out_usd==null&&e.degree_in==null&&e.degree_out==null}const xc=new Intl.NumberFormat("en-US");function im(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 cI(e){if(!e||e.senders+e.receivers<=0)return null;const t=(n,r)=>`${xc.format(n)} more ${r}${n===1?"":"s"}`;return`${t(e.senders,"sender")}, ${t(e.receivers,"receiver")} not loaded`}function lI(e,t,n=O_){return`Not loaded: ${xc.format(e)} ${e===1?"link":"links"} of ${t} would take the picture past ${xc.format(n)} addresses. Fold another address to make room.`}const om=e=>!!(e&&(e.truncated||e.remaining&&e.remaining.senders+e.remaining.receivers>0));let dI=0;const fI=[["scam","Scam"],["sanctioned","Sanctioned"],["exchange","Exchange"],["victim","Victim"],["pool","Pool"],["self_trader","Self-trading contract"],["other","Other"]];function wh(e){return typeof e=="string"&&/^http:\/\/(?:127\.0\.0\.1|localhost):\d+(?:[/?#]|$)/.test(e)}function hI(e){return!e.browser&&!!e.host.openLink&&wh(e.viewUrl)}function pI(e,t,n){return{network:e,address:t,in_offset:n?.in_offset??0,out_offset:n?.out_offset??0}}function mI(e){const t=Kr(e);return e?e.isError?t||"the server refused the expansion":/query_timeout|topology_busy/.test(t)?t:lh(e.structuredContent)?null:t||"the answer held no money flows":"no answer"}function gI(e,t,n,r=D_,i=Q1){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(Ru,Math.min(1,(t-Ti*2)/o)),u=Math.ceil(n+s*a+Ti*2),c=Math.min(r,Math.max(i,u));return zp(e,t,c-n)>=Ru?{height:c,fits:!0}:{height:r,fits:zp(e,t,r-n)>=Ru}}function yI(e){return/query_timeout|topology_busy|timed? ?out/i.test(e)}function sm(e){const t=e.split(`
111
+ `)[0].trim();return t.length>200?`${t.slice(0,199)}…`:t}function vI(e,t){return`investigator expanded ${e}: ${t} new addresses`}function bI(e,t){const n=e.nodes.find(r=>r.address.toLowerCase()===t.toLowerCase());return n&&Go({role:n.role??null,labels:n.labels??[]})||"Other"}function P_(e,t,n){const r=e.ownerDocument,i=t.network??"robinhood",o=t.center.toLowerCase(),s=n.maxAddresses??O_,a=()=>new Map(t.cursor?[[o,{cursor:t.cursor,truncated:!!t.truncated,remaining:im(t)}]]:[]);let u=a();const c=new Set,l=new Set;let d=[];const h=new Set;let f=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:iI}),g=A(r,"div",{class:"cv-toast",role:"alert","data-toast":"",hidden:!0});let _=null;function v(L){_&&clearTimeout(_),g.textContent=L,g.hidden=!1,_=setTimeout(()=>{g.hidden=!0,_=null},rI)}const w=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:X1,arguments:{}})}catch{L=null}const Q=J1(L);w.hidden=!Q,Q&&(w.textContent=Y1(Q),w.classList.toggle("cv-usage--warn",Q.warn&&!Q.spent),w.classList.toggle("cv-usage--spent",Q.spent))}const x=A(r,"p",{class:"cv-side-note","data-side-note":"",hidden:!0});function D(L){x.hidden=!L,x.textContent=L??""}const F=A(r,"ul",{class:"cv-roles","aria-label":"Legend: address roles and link kinds"}),M=A(r,"div",{class:"cv-canvas","data-graph":""}),Z=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":""})),ne=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:"×"}),pe=A(r,"button",{type:"button",class:"cv-button","data-toggle-expand":"",hidden:!0,text:"Expand"}),Re=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=H1(r,{host:n.host,network:i,now:n.now,embedded:!0,onLayout:()=>xt()}),Y=A(r,"aside",{class:"cv-side","data-side-panel":"","aria-label":"Details of the selection",hidden:!0},A(r,"header",{class:"cv-side-head"},ne,ce),x,Z,U,A(r,"div",{class:"cv-side-actions"},pe,Re),H.element),me=A(r,"button",{type:"button",class:"cv-button","data-fullscreen":"",hidden:!0,"aria-label":"Open full screen",text:"Full screen"}),ie=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:eI}),O=A(r,"button",{type:"button",class:"cv-button","data-open-browser":"",hidden:!hI(n),"aria-label":"Open the graph in your browser",title:"Open the graph in your browser",text:tI}),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"})),ae=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"}),ie,I,me,O),de=A(r,"span",{class:"cv-muted","data-subtitle":""}),te=`cv-addresses-${++dI}`,ge=A(r,"div",{class:"cv-visually-hidden",role:"listbox",tabindex:"0",id:te,"data-address-list":"","aria-label":"Drawn addresses. Down and Up move, Enter shows the details, Shift+Enter expands or folds."});let X=[],be=-1;const We=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}),de,w),n.toggle??null,ae),F,n.note?A(r,"p",{class:"cv-note",role:"note","data-left-out":"",text:n.note}):null,A(r,"div",{class:"cv-body"},ge,M,Y,g),b);e.replaceChildren(We);function rt(){const L=Se.model(),Q=L.truncated?" · more flows than shown":"";de.textContent=`${o} · ${bI(t,o)} · ${i} · ${L.nodes.length} addresses${Q}`;const ve=new Set(L.nodes.map(Ne=>Ne.role??"other")),Fe=fI.filter(([Ne])=>Ne!=="other"&&ve.has(Ne)),Qe=L.edges.some(Ne=>kr(Ne).link)||L.nodes.some(Ne=>Ne.self_route)?[A(r,"li",{"data-link":"funds"},A(r,"i",{class:"cv-link-swatch","aria-hidden":"true"}),QT),A(r,"li",{"data-link":"route"},A(r,"i",{class:"cv-link-swatch","aria-hidden":"true"}),A(r,"span",{class:"cv-link-mark","aria-hidden":"true",text:Ci}),Yw)]:[];F.hidden=Fe.length===0&&Qe.length===0,F.replaceChildren(...Fe.map(([Ne,Qr])=>{const tn=A(r,"i",{"aria-hidden":"true"});return tn.style.background=`var(--cia-graph-role-${Ne})`,A(r,"li",{"data-role":Ne},tn,Qr)}),...Qe),st()}function st(){const L=Se.model().nodes,Q=X[be]??null;X=L.map(Fe=>Fe.address.toLowerCase()),ge.replaceChildren(...L.map((Fe,Je)=>A(r,"div",{role:"option",id:`${te}-${Je}`,"data-list-address":X[Je],"aria-selected":"false",text:`${Fe.address} ${Go({role:Fe.role??null,labels:Fe.labels??[]})||"Other"}`})));const ve=Q?X.indexOf(Q):-1;be=ve>=0?ve:X.length?Math.min(Math.max(be,-1),X.length-1):-1,N()}function N(){for(const Q of ge.children)Q.setAttribute("aria-selected",String(Q.id===`${te}-${be}`));be>=0?ge.setAttribute("aria-activedescendant",`${te}-${be}`):ge.removeAttribute("aria-activedescendant");const L=r.activeElement===ge;Se.highlight(L?X[be]??null:null)}function j(L){return L?Se.model().nodes.find(Q=>Q.id===L)?.address.toLowerCase()??null:null}const V=L=>{const Q=L.target,ve=L.key==="Enter"||L.key===" ",Fe=Q?.closest?.("[data-node-id]");if(ve&&L.shiftKey&&Fe){L.preventDefault();const Je=j(Fe.dataset.nodeId);Je&&jo(Je)}};M.addEventListener("keydown",V,!0);function q(L){X.length&&(be=Math.max(0,Math.min(X.length-1,L)),N())}const xe=()=>{be<0&&X.length&&(be=0),N()},ue=()=>Se.highlight(null),Ee=L=>{const Q=X[be];switch(L.key){case"ArrowDown":L.preventDefault(),q(be+1);return;case"ArrowUp":L.preventDefault(),q(be-1);return;case"Home":L.preventDefault(),q(0);return;case"End":L.preventDefault(),q(X.length-1);return;case"Escape":yu();return;case"Enter":case" ":if(L.preventDefault(),!Q)return;L.shiftKey?jo(Q):Se.select(Q);return}};ge.addEventListener("focus",xe),ge.addEventListener("blur",ue),ge.addEventListener("keydown",Ee);function $e(){const L=p;if(!L){pe.hidden=!0,Re.hidden=!0,U.hidden=!0;return}const Q=h.has(L),ve=Q?cI(u.get(L)?.remaining??null):null;U.hidden=!ve,U.textContent=ve??"",pe.hidden=!1,pe.disabled=c.has(L)||l.has(L),pe.textContent=c.has(L)?"Too busy to expand":Q?"Collapse":"Expand",pe.setAttribute("aria-label",`${pe.textContent} ${L}`),Re.hidden=!(Q&&om(u.get(L)))}function re(L){const Q=Y.hidden;if(Y.hidden=L.kind==null,L.kind==="node"&&L.node){const ve=L.node.address.toLowerCase();ve!==p&&D(null),p=ve,ne.textContent="Address details",H.close(),uI(L.node)&&Ke(p)}else p=null,D(null),L.kind==="edge"?ne.textContent="Link details":H.close();$e(),Q!==Y.hidden&&xt()}const Ae=new Set;async function Ke(L){if(Ae.has(L))return;Ae.add(L);let Q=null;try{Q=await n.host.callServerTool({name:nm,arguments:sI(i,L)})}catch(Qe){Q={isError:!0,content:[{type:"text",text:Qe instanceof Error?Qe.message:String(Qe)}]}}const ve=Q&&!Q.isError?aI(Q.structuredContent):null;if(!ve){Ae.delete(L);const Qe=em(Q),Ne=Qe?tm(Qe):sm(Q&&Kr(Q)||"no answer");b.textContent=`The totals of ${L} could not be read: ${Ne}`,p===L&&D(`The totals could not be read. ${Ne}`),v(Ne),k();return}k();const{address:Fe,...Je}=ve;Se.patchNode(L,Je)&&p===L&&Se.select(L)}let T=null;function R(){T&&clearTimeout(T),T=null}function J(L){const Q=L.source==="pointer"&&L.kind==="node"&&L.node,ve=L.source!=="program"&&L.kind==="edge"&&L.edge&&kr(L.edge).link!=="route";if(R(),Q){const Fe=L.node.address.toLowerCase(),Je=m();f&&f.address===Fe&&Je-f.at<=rm?(f=null,yu(),jo(Fe)):(f={address:Fe,at:Je},T=setTimeout(()=>{T=null,re(L)},rm));return}L.kind!=="node"&&(f=null),re(L),ve&&H.open(L.edge)}const oe=n.height??D_,ye=`${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 Xe(){return rA(M,t,{layout:n.layout??"gravity",width:n.width??720,height:oe,now:n.now,controls:ae,selectionRoot:Z,onSelect:J,openLink:L=>{n.host.openLink?.({url:L}).catch(()=>{b.textContent=Lu})},label:ye})}let Se=Xe();rt(),k();let vt=n.displayMode??"inline",nr=n.availableDisplayModes??[];const Pn=()=>!n.browser&&!!n.host.requestDisplayMode&&(nr.length===0||nr.includes("fullscreen"));function xt(){if(vt==="fullscreen"){We.style.removeProperty("height"),I.hidden=!0;return}const L=M.clientWidth||n.width||720,Q=Math.max(0,We.offsetHeight-M.offsetHeight)||140,{height:ve,fits:Fe}=gI(Se.contentBounds(),L,Q);We.style.height=`${ve}px`,I.hidden=Fe||!Pn(),We.dataset.fits=String(Fe),Se.fit()}async function Vt(L){try{await n.host.updateModelContext?.({content:[{type:"text",text:L}]})}catch{}}async function qt(L,Q=!1){const ve=L.toLowerCase();if(c.has(ve))return b.textContent=`${ve} is ${rs}.`,{added:[],refused:rs};if(l.has(ve))return{added:[],refused:null};const Fe=u.get(ve);if(Fe&&!om(Fe))return b.textContent=`Every recent flow of ${ve} is drawn.`,{added:[],refused:null};l.add(ve),$e(),b.textContent=`Loading the flows of ${ve}…`;let Je=null;try{Je=await n.host.callServerTool({name:nm,arguments:pI(i,ve,Q||Fe?Fe?.cursor:null)})}catch(ht){Je={isError:!0,content:[{type:"text",text:ht instanceof Error?ht.message:String(ht)}]}}finally{l.delete(ve)}const Qe=mI(Je);if(Qe){if(yI(Qe))c.add(ve),Se.markNode(ve,rs),b.textContent=`${ve} is ${rs}. The drawing is kept.`;else{const ht=em(Je),Mn=ht?tm(ht):sm(Qe);b.textContent=`${ve} could not be expanded: ${Mn} The drawing is kept; try again.`,v(Mn),k()}return $e(),{added:[],refused:Qe}}const Ne=Je.structuredContent,Qr=Se.model(),tn=new Set(Qr.nodes.map(ht=>ht.address.toLowerCase())),vu=new Set;for(const ht of Ne.nodes)tn.has(ht.address.toLowerCase())||vu.add(ht.address.toLowerCase());for(const ht of Ne.edges)for(const Mn of[ht.from,ht.to])tn.has(Mn.toLowerCase())||vu.add(Mn.toLowerCase());if(tn.size+vu.size>s){const ht=new Set(Qr.edges.map(Fn=>`${Fn.from.toLowerCase()}->${Fn.to.toLowerCase()}`)),Mn=new Set(Ne.edges.map(Fn=>`${Fn.from.toLowerCase()}->${Fn.to.toLowerCase()}`).filter(Fn=>!ht.has(Fn))).size,Dh=lI(Mn,ve,s);return b.textContent=Dh,$e(),{added:[],refused:Dh}}const Zo=Se.merge(Ne,ve);return d.push({address:ve,page:Ne}),h.add(ve),Se.flagNode(ve,zu,!0),u.set(ve,{cursor:Ne.cursor??null,truncated:!!Ne.truncated,remaining:im(Ne)}),rt(),xt(),$e(),b.textContent=`${Zo.length} new ${Zo.length===1?"address":"addresses"} linked to ${ve}. Double-click it again to fold them back.`,k(),await Vt(vI(ve,Zo.length)),{added:Zo,refused:null}}function Th(L){const Q=L.toLowerCase();if(!h.has(Q))return{removed:0};const ve=Se.model().nodes.length;h.delete(Q),u.delete(Q);const Fe=d.filter(Ne=>Ne.address!==Q),Je=[];Se.batch(()=>{Se.flagNode(Q,zu,!1),Se.update(t);for(const Ne of Fe)Se.model().nodes.some(tn=>tn.address.toLowerCase()===Ne.address)?(Se.merge(Ne.page,Ne.address),Je.push(Ne)):Je.some(tn=>tn.address===Ne.address)||(Se.flagNode(Ne.address,zu,!1),h.delete(Ne.address),u.delete(Ne.address))}),d=Je;const Qe=Math.max(0,ve-Se.model().nodes.length);return p&&!Se.model().nodes.some(Ne=>Ne.address.toLowerCase()===p)&&(Y.hidden=!0,p=null),rt(),xt(),$e(),b.textContent=`Folded ${Q} back: ${Qe} ${Qe===1?"address":"addresses"} removed.`,Vt(`investigator collapsed ${Q}: ${Qe} addresses removed`),{removed:Qe}}async function jo(L){h.has(L)?Th(L):await qt(L)}function Ch(){R(),Se.destroy(),d=[],h.clear(),c.clear(),l.clear(),u=a(),Ae.clear(),f=null,p=null,H.close(),Y.hidden=!0,Se=Xe(),rt(),xt(),$e(),b.textContent="The first answer again: every expansion folded back."}function mu(L,Q){L&&(vt=L),Q&&(nr=Q),We.dataset.displayMode=vt,me.hidden=!Pn(),me.textContent=vt==="fullscreen"?"Exit full screen":"Full screen",me.setAttribute("aria-label",vt==="fullscreen"?"Back to the inline view":"Open full screen"),xt()}mu(vt);const Ah=async()=>{const L=vt==="fullscreen"?"inline":"fullscreen";try{const Q=await n.host.requestDisplayMode?.({mode:L});mu(Q?.mode??L)}catch{b.textContent="The host did not change the display mode."}},gu=(L,Q)=>{b.replaceChildren(A(r,"span",{text:`${L} `}),A(r,"code",{class:"cv-view-link","data-view-link":"",text:Q}))},Ih=async()=>{const L=n.viewUrl;if(!(!wh(L)||!n.host.openLink)){gu(nI,L);try{(await n.host.openLink({url:L}))?.isError===!0&&gu(Lu,L)}catch{gu(Lu,L)}}},Nh=()=>Ch();function yu(){R();const L=!Y.hidden;Se.select(null),H.close(),Y.hidden=!0,p=null,$e(),L&&xt()}const Rh=()=>yu(),Lh=()=>{p&&jo(p)},zh=()=>{p&&qt(p,!0)};return me.addEventListener("click",Ah),O.addEventListener("click",Ih),ie.addEventListener("click",Nh),ce.addEventListener("click",Rh),pe.addEventListener("click",Lh),Re.addEventListener("click",zh),{root:We,get graph(){return Se},expand:L=>qt(L),collapse:Th,reset:Ch,expanded:()=>[...h],setLayout:L=>Se.setLayout(L),linkPanel:H,openLink(L,Q){const ve=Se.model().edges.find(Fe=>Fe.from===L.toLowerCase()&&Fe.to===Q.toLowerCase());return ve?(Se.select(ve.id),H.open(ve)):Promise.resolve(null)},setTheme(L){Se.setTheme(L)},setDisplayMode:mu,refit:xt,destroy(){R(),_&&clearTimeout(_),M.removeEventListener("keydown",V,!0),ge.removeEventListener("focus",xe),ge.removeEventListener("blur",ue),ge.removeEventListener("keydown",Ee),me.removeEventListener("click",Ah),O.removeEventListener("click",Ih),ie.removeEventListener("click",Nh),ce.removeEventListener("click",Rh),pe.removeEventListener("click",Lh),Re.removeEventListener("click",zh),H.destroy(),Se.destroy()}}}function Ec(e){return{kind:e,flows:()=>[],setTheme(){},setDisplayMode(){},refit(){},destroy(){}}}function wI(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 M_=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 _I(e){return typeof e?.query=="string"&&e.query?e.query:null}function kI(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 SI(e,t){const n=e.structuredContent;if(!t||!n?.facts?.query)return e;const r=IA(cu(n),t);return r?{...e,structuredContent:{...n,facts:{...n.facts,query:{...n.facts.query,results:r}}}}:e}function xI(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(l_)} addresses. The table has the rows.`}function EI(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 $I(e,t){const n=t?.facts?.subject;return{content:[],structuredContent:{schema:uu,tool:"graph_query",facts:{...n?{subject:n}:{},query:{results:e,count:e.length,truncated:!1}}}}}function TI(e){const t=m_(e.structuredContent);if(t)return{model:t.model,table:$I(t.rows,e.structuredContent)};const n=yh(cu(e.structuredContent));return n?{model:n,table:e}:null}function F_(e,t,n,r=null){const i=e.ownerDocument,o=SI(t,r),s=b_(o),a=s==="chart"?TI(o):null;if(s!=="graph"&&!a)return s==="table"?Wp(e,o):Ri(e,o),Ec(s==="table"?"table":"text");const u=o.structuredContent,c=cu(u),l=a?.table??t,d=A(i,"div",{class:"cv-face","data-face":"picture"}),h=A(i,"div",{class:"cv-face","data-face":"table",hidden:!0});e.replaceChildren(d,h);const f=EI(i,s==="graph"?"Graph":"Chart",g=>b(g));let p=null,m=null,y=-1;if(s==="graph"){const g=zA(c,aA(u),g_(r)?.address);p=P_(d,g.view,{...M_(n),title:"Money flow graph",toggle:f.make(),note:xI(g.rowsLeftOut,g.rowsTotal)})}else m=z1(d,a.model,{toggle:f.make()});function b(g){if(d.hidden=g!=="picture",h.hidden=g!=="table",g==="table"){const _=p?.expanded().length?p.graph.model():null,v=_?_.nodes.length*100003+_.edges.length:0;y!==v&&(y=v,Wp(h,_?CI(_,l):l,{toggle:f.make()}))}f.set(g),g==="picture"&&(p?.refit(),m?.refit())}return{kind:s,flows:()=>p?[p]:[],setTheme(g){p?.setTheme(g)},setDisplayMode(g,_){p?.setDisplayMode(g,_)},refit(){d.hidden||(p?.refit(),m?.refit())},destroy(){p?.destroy(),m?.destroy()}}}function CI(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:uu,tool:"graph_query",facts:{...i?{subject:i}:{},query:{results:r,count:r.length,truncated:!!e.truncated,elapsed_ms:null}}}}}function AI(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:uu,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 II(e,t,n){const r=e.ownerDocument,i=y_(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 h=()=>e.style.setProperty("--cv-tabs-h",`${a.offsetHeight}px`);function f(p){const m=i[p],y=s[p];if(!m||!y)return;d=p,o.forEach((g,_)=>{g.setAttribute("aria-selected",String(_===p)),g.tabIndex=_===p?0:-1}),s.forEach((g,_)=>{g.hidden=_!==p});const b=u[p];if(b)b.refit();else{const g=m.query??kI(n.toolInput,m.id,p),_=F_(y,AI(m,t.structuredContent),{...n,displayMode:c,availableDisplayModes:l},g);u[p]=_,y.dataset.view=_.kind}h()}return o.forEach((p,m)=>{p.addEventListener("click",()=>f(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(),f(g),o[g]?.focus())})}),f(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);h()},refit(){d>=0&&u[d]?.refit()},destroy(){for(const p of u)p?.destroy()}}}function NI(e){const t=e?.structuredContent?.view_url;return wh(t)?t:null}function U_(e,t,n){const r={...n,viewUrl:n.viewUrl??NI(t)},i=b_(t);if(i==="flows"){const o=P_(e,t.structuredContent,M_(r));return wI("flows",()=>o)}return i==="graph"||i==="chart"||i==="table"?F_(e,t,r,_I(r.toolInput)):i==="batch"?II(e,t,r):i==="balance"?(VA(e,t),Ec("balance")):(Ri(e,t),Ec("text"))}function RI(e){return e==="light"||e==="dark"}function LI(e,t=()=>!1){return RI(e?.theme)?e.theme:t()?"dark":"light"}function Du(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 Ds(e,t,n={}){const r=e.documentElement,i=LI(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 zI(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var is={exports:{}},am;function DI(){if(am)return is.exports;am=1;var e=typeof Reflect=="object"?Reflect:null,t=e&&typeof e.apply=="function"?e.apply:function(w,k,x){return Function.prototype.apply.call(w,k,x)},n;e&&typeof e.ownKeys=="function"?n=e.ownKeys:Object.getOwnPropertySymbols?n=function(w){return Object.getOwnPropertyNames(w).concat(Object.getOwnPropertySymbols(w))}:n=function(w){return Object.getOwnPropertyNames(w)};function r(v){console&&console.warn&&console.warn(v)}var i=Number.isNaN||function(w){return w!==w};function o(){o.init.call(this)}is.exports=o,is.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(w){if(typeof w!="number"||w<0||i(w))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+w+".");return this._maxListeners=w,this};function u(v){return v._maxListeners===void 0?o.defaultMaxListeners:v._maxListeners}o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(w){for(var k=[],x=1;x<arguments.length;x++)k.push(arguments[x]);var D=w==="error",F=this._events;if(F!==void 0)D=D&&F.error===void 0;else if(!D)return!1;if(D){var M;if(k.length>0&&(M=k[0]),M instanceof Error)throw M;var Z=new Error("Unhandled error."+(M?" ("+M.message+")":""));throw Z.context=M,Z}var ne=F[w];if(ne===void 0)return!1;if(typeof ne=="function")t(ne,this,k);else for(var ce=ne.length,pe=p(ne,ce),x=0;x<ce;++x)t(pe[x],this,k);return!0};function c(v,w,k,x){var D,F,M;if(a(k),F=v._events,F===void 0?(F=v._events=Object.create(null),v._eventsCount=0):(F.newListener!==void 0&&(v.emit("newListener",w,k.listener?k.listener:k),F=v._events),M=F[w]),M===void 0)M=F[w]=k,++v._eventsCount;else if(typeof M=="function"?M=F[w]=x?[k,M]:[M,k]:x?M.unshift(k):M.push(k),D=u(v),D>0&&M.length>D&&!M.warned){M.warned=!0;var Z=new Error("Possible EventEmitter memory leak detected. "+M.length+" "+String(w)+" listeners added. Use emitter.setMaxListeners() to increase limit");Z.name="MaxListenersExceededWarning",Z.emitter=v,Z.type=w,Z.count=M.length,r(Z)}return v}o.prototype.addListener=function(w,k){return c(this,w,k,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(w,k){return c(this,w,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,w,k){var x={fired:!1,wrapFn:void 0,target:v,type:w,listener:k},D=l.bind(x);return D.listener=k,x.wrapFn=D,D}o.prototype.once=function(w,k){return a(k),this.on(w,d(this,w,k)),this},o.prototype.prependOnceListener=function(w,k){return a(k),this.prependListener(w,d(this,w,k)),this},o.prototype.removeListener=function(w,k){var x,D,F,M,Z;if(a(k),D=this._events,D===void 0)return this;if(x=D[w],x===void 0)return this;if(x===k||x.listener===k)--this._eventsCount===0?this._events=Object.create(null):(delete D[w],D.removeListener&&this.emit("removeListener",w,x.listener||k));else if(typeof x!="function"){for(F=-1,M=x.length-1;M>=0;M--)if(x[M]===k||x[M].listener===k){Z=x[M].listener,F=M;break}if(F<0)return this;F===0?x.shift():m(x,F),x.length===1&&(D[w]=x[0]),D.removeListener!==void 0&&this.emit("removeListener",w,Z||k)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(w){var k,x,D;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[w]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete x[w]),this;if(arguments.length===0){var F=Object.keys(x),M;for(D=0;D<F.length;++D)M=F[D],M!=="removeListener"&&this.removeAllListeners(M);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(k=x[w],typeof k=="function")this.removeListener(w,k);else if(k!==void 0)for(D=k.length-1;D>=0;D--)this.removeListener(w,k[D]);return this};function h(v,w,k){var x=v._events;if(x===void 0)return[];var D=x[w];return D===void 0?[]:typeof D=="function"?k?[D.listener||D]:[D]:k?y(D):p(D,D.length)}o.prototype.listeners=function(w){return h(this,w,!0)},o.prototype.rawListeners=function(w){return h(this,w,!1)},o.listenerCount=function(v,w){return typeof v.listenerCount=="function"?v.listenerCount(w):f.call(v,w)},o.prototype.listenerCount=f;function f(v){var w=this._events;if(w!==void 0){var k=w[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,w){for(var k=new Array(w),x=0;x<w;++x)k[x]=v[x];return k}function m(v,w){for(;w+1<v.length;w++)v[w]=v[w+1];v.pop()}function y(v){for(var w=new Array(v.length),k=0;k<w.length;++k)w[k]=v[k].listener||v[k];return w}function b(v,w){return new Promise(function(k,x){function D(M){v.removeListener(w,F),x(M)}function F(){typeof v.removeListener=="function"&&v.removeListener("error",D),k([].slice.call(arguments))}_(v,w,F,{once:!0}),w!=="error"&&g(v,D,{once:!0})})}function g(v,w,k){typeof v.on=="function"&&_(v,"error",w,k)}function _(v,w,k,x){if(typeof v.on=="function")x.once?v.once(w,k):v.on(w,k);else if(typeof v.addEventListener=="function")v.addEventListener(w,function D(F){x.once&&v.removeEventListener(w,D),k(F)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof v)}return is.exports}var G_=DI();function OI(){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 et=OI;typeof Object.assign=="function"&&(et=Object.assign);function Ut(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 ut(e){return typeof e=="object"&&e!==null}function j_(e){let t;for(t in e)return!1;return!0}function Ot(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function Kt(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 um(e){return!(!ut(e)||e.attributes&&!Array.isArray(e.attributes))}function PI(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function ln(){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 Jr(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class _h extends Error{constructor(t){super(),this.name="GraphError",this.message=t}}class K extends _h{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,K.prototype.constructor)}}class B extends _h{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,B.prototype.constructor)}}class le extends _h{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,le.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 B_(e,t){this.key=e,this.attributes=t,this.clear()}B_.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function H_(e,t){this.key=e,this.attributes=t,this.clear()}H_.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Yr(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}Yr.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)};Yr.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};Yr.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]};Yr.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 V_=0,q_=1,MI=2,W_=3;function bn(e,t,n,r,i,o,s){let a,u,c,l;if(r=""+r,n===V_){if(a=e._nodes.get(r),!a)throw new B(`Graph.${t}: could not find the "${r}" node in the graph.`);c=i,l=o}else if(n===W_){if(i=""+i,u=e._edges.get(i),!u)throw new B(`Graph.${t}: could not find the "${i}" edge in the graph.`);const d=u.source.key,h=u.target.key;if(r===d)a=u.target;else if(r===h)a=u.source;else throw new B(`Graph.${t}: the "${r}" node is not attached to the "${i}" edge (${d}, ${h}).`);c=o,l=s}else{if(u=e._edges.get(r),!u)throw new B(`Graph.${t}: could not find the "${r}" edge in the graph.`);n===q_?a=u.source:a=u.target,c=i,l=o}return[a,c,l]}function FI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=bn(this,t,n,r,i,o);return s.attributes[a]}}function UI(e,t,n){e.prototype[t]=function(r,i){const[o]=bn(this,t,n,r,i);return o.attributes}}function GI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=bn(this,t,n,r,i,o);return s.attributes.hasOwnProperty(a)}}function jI(e,t,n){e.prototype[t]=function(r,i,o,s){const[a,u,c]=bn(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 ZI(e,t,n){e.prototype[t]=function(r,i,o,s){const[a,u,c]=bn(this,t,n,r,i,o,s);if(typeof c!="function")throw new K(`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 BI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=bn(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 HI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=bn(this,t,n,r,i,o);if(!ut(a))throw new K(`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 VI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=bn(this,t,n,r,i,o);if(!ut(a))throw new K(`Graph.${t}: provided attributes are not a plain object.`);return et(s.attributes,a),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:a}),this}}function qI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=bn(this,t,n,r,i,o);if(typeof a!="function")throw new K(`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 WI=[{name:e=>`get${e}Attribute`,attacher:FI},{name:e=>`get${e}Attributes`,attacher:UI},{name:e=>`has${e}Attribute`,attacher:GI},{name:e=>`set${e}Attribute`,attacher:jI},{name:e=>`update${e}Attribute`,attacher:ZI},{name:e=>`remove${e}Attribute`,attacher:BI},{name:e=>`replace${e}Attributes`,attacher:HI},{name:e=>`merge${e}Attributes`,attacher:VI},{name:e=>`update${e}Attributes`,attacher:qI}];function KI(e){WI.forEach(function({name:t,attacher:n}){n(e,t("Node"),V_),n(e,t("Source"),q_),n(e,t("Target"),MI),n(e,t("Opposite"),W_)})}function JI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new le(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new le(`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=Ut(this,s,a,n),!o)throw new B(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new le(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function YI(e,t,n){e.prototype[t]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new le(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new le(`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=Ut(this,o,s,n),!i)throw new B(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new le(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function XI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new le(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new le(`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=Ut(this,s,a,n),!o)throw new B(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new le(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function QI(e,t,n){e.prototype[t]=function(r,i,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new le(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new le(`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=Ut(this,a,u,n),!s)throw new B(`Graph.${t}: could not find an edge for the given path ("${a}" - "${u}").`)}else{if(n!=="mixed")throw new le(`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 B(`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 eN(e,t,n){e.prototype[t]=function(r,i,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new le(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new le(`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=Ut(this,a,u,n),!s)throw new B(`Graph.${t}: could not find an edge for the given path ("${a}" - "${u}").`)}else{if(n!=="mixed")throw new le(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new K(`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 tN(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new le(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new le(`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=Ut(this,s,a,n),!o)throw new B(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new le(`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 B(`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 nN(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new le(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new le(`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=Ut(this,s,a,n),!o)throw new B(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new le(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!ut(i))throw new K(`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 rN(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new le(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new le(`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=Ut(this,s,a,n),!o)throw new B(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new le(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!ut(i))throw new K(`Graph.${t}: provided attributes are not a plain object.`);return et(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function iN(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new le(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new le(`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=Ut(this,s,a,n),!o)throw new B(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new le(`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 B(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new K(`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 oN=[{name:e=>`get${e}Attribute`,attacher:JI},{name:e=>`get${e}Attributes`,attacher:YI},{name:e=>`has${e}Attribute`,attacher:XI},{name:e=>`set${e}Attribute`,attacher:QI},{name:e=>`update${e}Attribute`,attacher:eN},{name:e=>`remove${e}Attribute`,attacher:tN},{name:e=>`replace${e}Attributes`,attacher:nN},{name:e=>`merge${e}Attributes`,attacher:rN},{name:e=>`update${e}Attributes`,attacher:iN}];function sN(e){oN.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}const aN=[{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 uN(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 cN(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 Ou(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 lN(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 dN(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 Pu(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 fN(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 K_(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:h,target:f}=a;if(u=r(l,d,h.key,f.key,h.attributes,f.attributes,a.undirected),e&&u)return l}}function hN(e,t){if(e.size===0)return Jr();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 kh(e,t,n,r,i,o){const s=t?cN:uN;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 pN(e,t,n,r){const i=[];return kh(!1,e,t,n,r,function(o){i.push(o)}),i}function mN(e,t,n){let r=Jr();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=ln(r,Ou(n.in))),t!=="in"&&typeof n.out<"u"&&(r=ln(r,Ou(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=ln(r,Ou(n.undirected))),r}function Sh(e,t,n,r,i,o,s){const a=n?dN:lN;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 gN(e,t,n,r,i){const o=[];return Sh(!1,e,t,n,r,i,function(s){o.push(s)}),o}function yN(e,t,n,r){let i=Jr();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(i=ln(i,Pu(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(i=ln(i,Pu(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=ln(i,Pu(n.undirected,r))),i}function vN(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 fN(this,r);if(arguments.length===1){o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new B(`Graph.${n}: could not find the "${o}" node in the graph.`);return pN(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 B(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new B(`Graph.${n}: could not find the "${s}" target node in the graph.`);return gN(r,this.multi,i,a,s)}throw new K(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function bN(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,K_(!1,this,r,d);if(arguments.length===2){c=""+c,d=l;const h=this._nodes.get(c);if(typeof h>"u")throw new B(`Graph.${o}: could not find the "${c}" node in the graph.`);return kh(!1,this.multi,r==="mixed"?this.type:r,i,h,d)}if(arguments.length===3){c=""+c,l=""+l;const h=this._nodes.get(c);if(!h)throw new B(`Graph.${o}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(l))throw new B(`Graph.${o}: could not find the "${l}" target node in the graph.`);return Sh(!1,r,this.multi,i,h,l,d)}throw new K(`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 h=0;r!=="directed"&&(h+=this.undirectedSize),r!=="undirected"&&(h+=this.directedSize),d=new Array(h);let f=0;c.push((p,m,y,b,g,_,v)=>{d[f++]=l(p,m,y,b,g,_,v)})}else d=[],c.push((h,f,p,m,y,b,g)=>{d.push(l(h,f,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((h,f,p,m,y,b,g)=>{l(h,f,p,m,y,b,g)&&d.push(h)}),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 K(`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 K(`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 h=d;return c.push((f,p,m,y,b,g,_)=>{h=l(h,f,p,m,y,b,g,_)}),this[o].apply(this,c),h}}function wN(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,K_(!0,this,r,l);if(arguments.length===2){u=""+u,l=c;const d=this._nodes.get(u);if(typeof d>"u")throw new B(`Graph.${o}: could not find the "${u}" node in the graph.`);return kh(!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 B(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(c))throw new B(`Graph.${o}: could not find the "${c}" target node in the graph.`);return Sh(!0,r,this.multi,i,d,c,l)}throw new K(`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,h,f,p,m,y,b)=>c(d,h,f,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,h,f,p,m,y,b)=>!c(d,h,f,p,m,y,b)),!this[o].apply(this,u)}}function _N(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 Jr();if(!arguments.length)return hN(this,r);if(arguments.length===1){s=""+s;const u=this._nodes.get(s);if(!u)throw new B(`Graph.${o}: could not find the "${s}" node in the graph.`);return mN(r,i,u)}if(arguments.length===2){s=""+s,a=""+a;const u=this._nodes.get(s);if(!u)throw new B(`Graph.${o}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(a))throw new B(`Graph.${o}: could not find the "${a}" target node in the graph.`);return yN(r,i,u,a)}throw new K(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function kN(e){aN.forEach(t=>{vN(e,t),bN(e,t),wN(e,t),_N(e,t)})}const SN=[{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 lu(){this.A=null,this.B=null}lu.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};lu.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function ni(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 xh(e,t,n,r,i){if(t!=="mixed"){if(t==="undirected")return ni(e,null,r,r.undirected,i);if(typeof n=="string")return ni(e,null,r,r[n],i)}const o=new lu;let s;if(t!=="undirected"){if(n!=="out"){if(s=ni(e,null,r,r.in,i),e&&s)return s;o.wrap(r.in)}if(n!=="in"){if(s=ni(e,o,r,r.out,i),e&&s)return s;o.wrap(r.out)}}if(t!=="directed"&&(s=ni(e,o,r,r.undirected,i),e&&s))return s}function xN(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 xh(!1,e,t,n,function(i){r.push(i)}),r}function ri(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 EN(e,t,n){if(e!=="mixed"){if(e==="undirected")return ri(null,n,n.undirected);if(typeof t=="string")return ri(null,n,n[t])}let r=Jr();const i=new lu;return e!=="undirected"&&(t!=="out"&&(r=ln(r,ri(i,n,n.in))),t!=="in"&&(r=ln(r,ri(i,n,n.out)))),e!=="directed"&&(r=ln(r,ri(i,n,n.undirected))),r}function $N(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 B(`Graph.${n}: could not find the "${o}" node in the graph.`);return xN(r==="mixed"?this.type:r,i,s)}}function TN(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 B(`Graph.${o}: could not find the "${c}" node in the graph.`);xh(!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,(h,f)=>{d.push(l(h,f))}),d};const a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(c,l){const d=[];return this[o](c,(h,f)=>{l(h,f)&&d.push(h)}),d};const u="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[u]=function(c,l,d){if(arguments.length<3)throw new K(`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 h=d;return this[o](c,(f,p)=>{h=l(h,f,p)}),h}}function CN(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 B(`Graph.${s}: could not find the "${c}" node in the graph.`);return xh(!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,(h,f)=>!l(h,f))}}function AN(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 Jr();s=""+s;const a=this._nodes.get(s);if(typeof a>"u")throw new B(`Graph.${o}: could not find the "${s}" node in the graph.`);return EN(r==="mixed"?this.type:r,i,a)}}function IN(e){SN.forEach(t=>{$N(e,t),TN(e,t),CN(e,t),AN(e,t)})}function os(e,t,n,r,i){const o=r._nodes.values(),s=r.type;let a,u,c,l,d,h;for(;a=o.next(),a.done!==!0;){let f=!1;if(u=a.value,s!=="undirected"){l=u.out;for(c in l){d=l[c];do h=d.target,f=!0,i(u.key,h.key,u.attributes,h.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 h=d.target,h.key!==c&&(h=d.source),f=!0,i(u.key,h.key,u.attributes,h.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}n&&!f&&i(u.key,null,u.attributes,null,null,null,null)}}function NN(e,t){const n={key:e};return j_(t.attributes)||(n.attributes=et({},t.attributes)),n}function RN(e,t,n){const r={key:t,source:n.source.key,target:n.target.key};return j_(n.attributes)||(r.attributes=et({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function LN(e){if(!ut(e))throw new K('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 K("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!ut(e.attributes)||e.attributes===null))throw new K("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function zN(e){if(!ut(e))throw new K('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 K("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new K("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!ut(e.attributes)||e.attributes===null))throw new K("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!="boolean")throw new K("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const DN=PI(),ON=new Set(["directed","undirected","mixed"]),cm=new Set(["domain","_events","_eventsCount","_maxListeners"]),PN=[{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"}],MN={allowSelfLoops:!0,multi:!1,type:"mixed"};function FN(e,t,n){if(n&&!ut(n))throw new K(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new le(`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 lm(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 J_(e,t,n,r,i,o,s,a){if(!r&&e.type==="undirected")throw new le(`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 le(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(a&&!ut(a))throw new K(`Graph.${t}: invalid attributes. Expecting an object but got "${a}"`);if(o=""+o,s=""+s,a=a||{},!e.allowSelfLoops&&o===s)throw new le(`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 B(`Graph.${t}: source node "${o}" not found.`);if(!c)throw new B(`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 le(`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 le(`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 Yr(r,i,u,c,a);e._edges.set(i,d);const h=o===s;return r?(u.undirectedDegree++,c.undirectedDegree++,h&&(u.undirectedLoops++,e._undirectedSelfLoopCount++)):(u.outDegree++,c.inDegree++,h&&(u.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),r?e._undirectedSize++:e._directedSize++,l.key=i,e.emit("edgeAdded",l),i}function UN(e,t,n,r,i,o,s,a,u){if(!r&&e.type==="undirected")throw new le(`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 le(`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 K(`Graph.${t}: invalid updater function. Expecting a function but got "${a}"`)}else if(!ut(a))throw new K(`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 le(`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),h,f;if(!n&&(h=e._edges.get(i),h)){if((h.source.key!==o||h.target.key!==s)&&(!r||h.source.key!==s||h.target.key!==o))throw new le(`Graph.${t}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${s}" target vs. ("${h.source.key}", "${h.target.key}").`);f=h}if(!f&&!e.multi&&l&&(f=r?l.undirected[s]:l.out[s]),f){const g=[f.key,!1,!1,!1];if(u?!c:!a)return g;if(u){const _=f.attributes;f.attributes=c(_),e.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else et(f.attributes,a),e.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.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 le(`Graph.${t}: the "${i}" edge already exists in the graph.`);let m=!1,y=!1;l||(l=lm(e,o,{}),m=!0,o===s&&(d=l,y=!0)),d||(d=lm(e,s,{}),y=!0),h=new Yr(r,i,l,d,a),e._edges.set(i,h);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?h.attachMulti():h.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 Ge extends G_.EventEmitter{constructor(t){if(super(),t=et({},MN,t),typeof t.multi!="boolean")throw new K(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!ON.has(t.type))throw new K(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new K(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);const n=t.type==="mixed"?Z_:t.type==="directed"?B_:H_;Ot(this,"NodeDataClass",n);const r="geid_"+DN()+"_";let i=0;const o=()=>{let s;do s=r+i++;while(this._edges.has(s));return s};Ot(this,"_attributes",{}),Ot(this,"_nodes",new Map),Ot(this,"_edges",new Map),Ot(this,"_directedSize",0),Ot(this,"_undirectedSize",0),Ot(this,"_directedSelfLoopCount",0),Ot(this,"_undirectedSelfLoopCount",0),Ot(this,"_edgeKeyGenerator",o),Ot(this,"_options",t),cm.forEach(s=>Ot(this,s,this[s])),Kt(this,"order",()=>this._nodes.size),Kt(this,"size",()=>this._edges.size),Kt(this,"directedSize",()=>this._directedSize),Kt(this,"undirectedSize",()=>this._undirectedSize),Kt(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Kt(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Kt(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Kt(this,"multi",this._options.multi),Kt(this,"type",this._options.type),Kt(this,"allowSelfLoops",this._options.allowSelfLoops),Kt(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 K(`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 K(`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 K(`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 le("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 B(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new B(`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 le("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 B(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new B(`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 le("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 B(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`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 B(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return FN(this,t,n).key}mergeNode(t,n){if(n&&!ut(n))throw new K(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);t=""+t,n=n||{};let r=this._nodes.get(t);return r?(n&&(et(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 K(`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 B(`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=Ut(this,r,i,this.type),!n)throw new B(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new B(`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 le("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 le("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=Ut(this,t,n,"directed");if(!r)throw new B(`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 le("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 le("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=Ut(this,t,n,"undirected");if(!r)throw new B(`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 K("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(!ut(t))throw new K("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(!ut(t))throw new K("Graph.mergeAttributes: provided attributes are not a plain object.");return et(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new K("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 K("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!um(n))throw new K("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 K("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!um(n))throw new K("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 K("Graph.forEachAdjacencyEntry: expecting a callback.");os(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new K("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");os(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new K("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");os(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new K("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");os(!1,!0,!0,this,t)}nodes(){return Array.from(this._nodes.keys())}forEachNode(t){if(typeof t!="function")throw new K("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 K("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 K("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 K("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 K("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 K("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 K("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new K("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++]=NN(o,i)});const r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=RN(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 Ge)return t.forEachNode((u,c)=>{n?this.mergeNode(u,c):this.addNode(u,c)}),t.forEachEdge((u,c,l,d,h,f,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(!ut(t))throw new K("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!ut(t.attributes))throw new K("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 K("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],LN(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 K("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],zN(a);const{source:c,target:l,attributes:d,undirected:h=u}=a;let f;"key"in a?(f=n?h?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:h?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,a.key,c,l,d)):(f=n?h?this.mergeUndirectedEdge:this.mergeDirectedEdge:h?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,c,l,d))}}return this}nullCopy(t){const n=new Ge(et({},this._options,t));return n.replaceAttributes(et({},this.getAttributes())),n}emptyCopy(t){const n=this.nullCopy(t);return this._nodes.forEach((r,i)=>{const o=et({},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 le(`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 le("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 le("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,J_(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,et({},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 h=`(${c})${a}(${l})`;s.startsWith("geid_")?this.multi&&(typeof r[h]>"u"?r[h]=0:r[h]++,u+=`${r[h]}. `):u+=`[${s}]: `,u+=h,n[u]=o.attributes});const i={};for(const o in this)this.hasOwnProperty(o)&&!cm.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=t,i.edges=n,Ot(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(Ge.prototype[Symbol.for("nodejs.util.inspect.custom")]=Ge.prototype.inspect);PN.forEach(e=>{["add","merge","update"].forEach(t=>{const n=e.name(t),r=t==="add"?J_:UN;e.generateKey?Ge.prototype[n]=function(i,o,s){return r(this,n,!0,(e.type||this.type)==="undirected",null,i,o,s,t==="update")}:Ge.prototype[n]=function(i,o,s,a){return r(this,n,!1,(e.type||this.type)==="undirected",i,o,s,a,t==="update")}})});KI(Ge);sN(Ge);kN(Ge);IN(Ge);class Y_ extends Ge{constructor(t){const n=et({type:"directed"},t);if("multi"in n&&n.multi!==!1)throw new K("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new K('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class X_ extends Ge{constructor(t){const n=et({type:"undirected"},t);if("multi"in n&&n.multi!==!1)throw new K("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new K('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class Q_ extends Ge{constructor(t){const n=et({multi:!0},t);if("multi"in n&&n.multi!==!0)throw new K("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}}class ek extends Ge{constructor(t){const n=et({type:"directed",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new K("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new K('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class tk extends Ge{constructor(t){const n=et({type:"undirected",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new K("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new K('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}function Xr(e){e.from=function(t,n){const r=et({},t.options,n),i=new e(r);return i.import(t),i}}Xr(Ge);Xr(Y_);Xr(X_);Xr(Q_);Xr(ek);Xr(tk);Ge.Graph=Ge;Ge.DirectedGraph=Y_;Ge.UndirectedGraph=X_;Ge.MultiGraph=Q_;Ge.MultiDirectedGraph=ek;Ge.MultiUndirectedGraph=tk;Ge.InvalidArgumentsGraphError=K;Ge.NotFoundGraphError=B;Ge.UsageGraphError=le;function GN(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 vi(e){var t=GN(e,"string");return typeof t=="symbol"?t:t+""}function gt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function dm(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,vi(r.key),r)}}function yt(e,t,n){return t&&dm(e.prototype,t),n&&dm(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function xr(e){return xr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},xr(e)}function nk(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(nk=function(){return!!e})()}function jN(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ZN(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 jN(e)}function Bt(e,t,n){return t=xr(t),ZN(e,nk()?Reflect.construct(t,n||[],xr(e).constructor):t.apply(e,n))}function $c(e,t){return $c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},$c(e,t)}function Ht(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&&$c(e,t)}function BN(e){if(Array.isArray(e))return e}function HN(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 Tc(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 rk(e,t){if(e){if(typeof e=="string")return Tc(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)?Tc(e,t):void 0}}function VN(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
112
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Er(e,t){return BN(e)||HN(e,t)||rk(e,t)||VN()}var Mu={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"},ik=new Int8Array(4),gs=new Int32Array(ik.buffer,0,1),ok=new Float32Array(ik.buffer,0,1),qN=/^\s*rgba?\s*\(/,WN=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function KN(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(qN.test(e)){var o=e.match(WN);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 ss in Mu)cr[ss]=On(Mu[ss]),cr[Mu[ss]]=cr[ss];function sk(e,t,n,r,i){return gs[0]=r<<24|n<<16|t<<8|e,gs[0]=gs[0]&4278190079,ok[0]}function On(e){if(e=e.toLowerCase(),typeof cr[e]<"u")return cr[e];var t=KN(e),n=t.r,r=t.g,i=t.b,o=t.a;o=o*255|0;var s=sk(n,r,i,o);return cr[e]=s,s}function JN(e,t){ok[0]=On(e);var n=gs[0],r=n&255,i=n>>8&255,o=n>>16&255,s=n>>24&255;return[r,i,o,s]}var Fu={};function ak(e){if(typeof Fu[e]<"u")return Fu[e];var t=(e&16711680)>>>16,n=(e&65280)>>>8,r=e&255,i=255,o=sk(t,n,r,i);return Fu[e]=o,o}function fm(e,t,n,r){return n+(t<<8)+(e<<16)}function hm(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=Er(u,4),l=c[0],d=c[1],h=c[2],f=c[3];return[l,d,h,f]}function P(e,t,n){return(t=vi(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function pm(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 ee(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?pm(Object(n),!0).forEach(function(r){P(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pm(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function YN(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=xr(e))!==null;);return e}function Cc(){return Cc=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=YN(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},Cc.apply(null,arguments)}function uk(e,t,n,r){var i=Cc(xr(e.prototype),t,n);return typeof i=="function"?function(o){return i.apply(n,o)}:i}function XN(e){return e.normalized?1:e.size}function Uu(e){var t=0;return e.forEach(function(n){return t+=XN(n)}),t}function ck(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,`
114
- `).concat(n))}return i}function ON(e,t){return ek("VERTEX",e,t)}function MN(e,t){return ek("FRAGMENT",e,t)}function FN(e,t){var n=e.createProgram();if(n===null)throw new Error("loadProgram: error while creating the program.");var r,i;for(r=0,i=t.length;r<i;r++)e.attachShader(n,t[r]);e.linkProgram(n);var o=e.getProgramParameter(n,e.LINK_STATUS);if(!o){var s=e.getProgramInfoLog(n);throw e.deleteProgram(n),new Error("loadProgram: error while linking the program: ".concat(s))}return n}function am(e){var t=e.gl,n=e.buffer,r=e.program,i=e.vertexShader,o=e.fragmentShader;t.deleteShader(i),t.deleteShader(o),t.deleteProgram(r),t.deleteBuffer(n)}function um(e){return e%1===0?e.toFixed(1):e.toString()}var cm=`#define PICKING_MODE
115
- `,UN=P(P(P(P(P(P(P(P({},WebGL2RenderingContext.BOOL,1),WebGL2RenderingContext.BYTE,1),WebGL2RenderingContext.UNSIGNED_BYTE,1),WebGL2RenderingContext.SHORT,2),WebGL2RenderingContext.UNSIGNED_SHORT,2),WebGL2RenderingContext.INT,4),WebGL2RenderingContext.UNSIGNED_INT,4),WebGL2RenderingContext.FLOAT,4),tk=(function(){function e(t,n,r){mt(this,e),P(this,"array",new Float32Array),P(this,"constantArray",new Float32Array),P(this,"capacity",0),P(this,"verticesCount",0);var i=this.getDefinition();if(this.VERTICES=i.VERTICES,this.VERTEX_SHADER_SOURCE=i.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=i.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=i.UNIFORMS,this.ATTRIBUTES=i.ATTRIBUTES,this.METHOD=i.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in i?i.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in i?i.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in i,this.ATTRIBUTES_ITEMS_COUNT=zu(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=r,this.normalProgram=this.getProgramInfo("normal",t,i.VERTEX_SHADER_SOURCE,i.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=n?this.getProgramInfo("pick",t,cm+i.VERTEX_SHADER_SOURCE,cm+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var o=zu(this.CONSTANT_ATTRIBUTES);if(this.CONSTANT_DATA.length!==this.VERTICES)throw new Error("Program: error while getting constant data (expected ".concat(this.VERTICES," items, received ").concat(this.CONSTANT_DATA.length," instead)"));this.constantArray=new Float32Array(this.CONSTANT_DATA.length*o);for(var s=0;s<this.CONSTANT_DATA.length;s++){var a=this.CONSTANT_DATA[s];if(a.length!==o)throw new Error("Program: error while getting constant data (one vector has ".concat(a.length," items instead of ").concat(o,")"));for(var u=0;u<a.length;u++)this.constantArray[s*o+u]=a[u]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return gt(e,[{key:"kill",value:function(){am(this.normalProgram),this.pickProgram&&(am(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(n,r,i,o,s){var a=this.getDefinition(),u=r.createBuffer();if(u===null)throw new Error("Program: error while creating the WebGL buffer.");var c=ON(r,i),l=MN(r,o),d=FN(r,[c,l]),f={};a.UNIFORMS.forEach(function(m){var y=r.getUniformLocation(d,m);y&&(f[m]=y)});var h={};a.ATTRIBUTES.forEach(function(m){h[m.name]=r.getAttribLocation(d,m.name)});var p;if("CONSTANT_ATTRIBUTES"in a&&(a.CONSTANT_ATTRIBUTES.forEach(function(m){h[m.name]=r.getAttribLocation(d,m.name)}),p=r.createBuffer(),p===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:n,program:d,gl:r,frameBuffer:s,buffer:u,constantBuffer:p||{},uniformLocations:f,attributeLocations:h,isPicking:n==="pick",vertexShader:c,fragmentShader:l}}},{key:"bindProgram",value:function(n){var r=this,i=0,o=n.gl,s=n.buffer;this.isInstanced?(o.bindBuffer(o.ARRAY_BUFFER,n.constantBuffer),i=0,this.CONSTANT_ATTRIBUTES.forEach(function(a){return i+=r.bindAttribute(a,n,i,!1)}),o.bufferData(o.ARRAY_BUFFER,this.constantArray,o.STATIC_DRAW),o.bindBuffer(o.ARRAY_BUFFER,n.buffer),i=0,this.ATTRIBUTES.forEach(function(a){return i+=r.bindAttribute(a,n,i,!0)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)):(o.bindBuffer(o.ARRAY_BUFFER,s),i=0,this.ATTRIBUTES.forEach(function(a){return i+=r.bindAttribute(a,n,i)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)),o.bindBuffer(o.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(n){var r=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n,!1)}),this.ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n,!0)})):this.ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n)})}},{key:"bindAttribute",value:function(n,r,i,o){var s=UN[n.type];if(typeof s!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(n.type,'"'));var a=r.attributeLocations[n.name],u=r.gl;if(a!==-1){u.enableVertexAttribArray(a);var c=this.isInstanced?(o?this.ATTRIBUTES_ITEMS_COUNT:zu(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(u.vertexAttribPointer(a,n.size,n.type,n.normalized||!1,c,i),this.isInstanced&&o)if(u instanceof WebGL2RenderingContext)u.vertexAttribDivisor(a,1);else{var l=u.getExtension("ANGLE_instanced_arrays");l&&l.vertexAttribDivisorANGLE(a,1)}}return n.size*s}},{key:"unbindAttribute",value:function(n,r,i){var o=r.attributeLocations[n.name],s=r.gl;if(o!==-1&&(s.disableVertexAttribArray(o),this.isInstanced&&i))if(s instanceof WebGL2RenderingContext)s.vertexAttribDivisor(o,0);else{var a=s.getExtension("ANGLE_instanced_arrays");a&&a.vertexAttribDivisorANGLE(o,0)}}},{key:"reallocate",value:function(n){n!==this.capacity&&(this.capacity=n,this.verticesCount=this.VERTICES*n,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}},{key:"hasNothingToRender",value:function(){return this.verticesCount===0}},{key:"renderProgram",value:function(n,r){var i=r.gl,o=r.program;i.enable(i.BLEND),i.useProgram(o),this.setUniforms(n,r),this.drawWebGL(this.METHOD,r)}},{key:"render",value:function(n){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,n.width*n.pixelRatio/n.downSizingRatio,n.height*n.pixelRatio/n.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram(Q(Q({},n),{},{pixelRatio:n.pixelRatio/n.downSizingRatio}),this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,n.width*n.pixelRatio,n.height*n.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(n,this.normalProgram),this.unbindProgram(this.normalProgram))}},{key:"drawWebGL",value:function(n,r){var i=r.gl,o=r.frameBuffer;if(i.bindFramebuffer(i.FRAMEBUFFER,o),!this.isInstanced)i.drawArrays(n,0,this.verticesCount);else if(i instanceof WebGL2RenderingContext)i.drawArraysInstanced(n,0,this.VERTICES,this.capacity);else{var s=i.getExtension("ANGLE_instanced_arrays");s&&s.drawArraysInstancedANGLE(n,0,this.VERTICES,this.capacity)}}}])})(),nk=(function(e){function t(){return mt(this,t),Zt(this,t,arguments)}return Bt(t,e),gt(t,[{key:"kill",value:function(){Q_(t,"kill",this)([])}},{key:"process",value:function(r,i,o){var s=i*this.STRIDE;if(o.hidden){for(var a=s+this.STRIDE;s<a;s++)this.array[s]=0;return}return this.processVisibleItem(X_(r),s,o)}}])})(tk),iu=(function(e){function t(){var n;mt(this,t);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=Zt(this,t,[].concat(i)),P(n,"drawLabel",void 0),n}return Bt(t,e),gt(t,[{key:"kill",value:function(){Q_(t,"kill",this)([])}},{key:"process",value:function(r,i,o,s,a){var u=i*this.STRIDE;if(a.hidden||o.hidden||s.hidden){for(var c=u+this.STRIDE;u<c;u++)this.array[u]=0;return}return this.processVisibleItem(X_(r),u,o,s,a)}}])})(tk);function GN(e,t){return(function(){function n(r,i,o){mt(this,n),P(this,"drawLabel",t),this.programs=e.map(function(s){return new s(r,i,o)})}return gt(n,[{key:"reallocate",value:function(i){this.programs.forEach(function(o){return o.reallocate(i)})}},{key:"process",value:function(i,o,s,a,u){this.programs.forEach(function(c){return c.process(i,o,s,a,u)})}},{key:"render",value:function(i){this.programs.forEach(function(o){return o.render(i)})}},{key:"kill",value:function(){this.programs.forEach(function(i){return i.kill()})}}])})()}function jN(e,t,n,r,i){var o=i.edgeLabelSize,s=i.edgeLabelFont,a=i.edgeLabelWeight,u=i.edgeLabelColor.attribute?t[i.edgeLabelColor.attribute]||i.edgeLabelColor.color||"#000":i.edgeLabelColor.color,c=t.label;if(c){e.fillStyle=u,e.font="".concat(a," ").concat(o,"px ").concat(s);var l=n.size,d=r.size,f=n.x,h=n.y,p=r.x,m=r.y,y=(f+p)/2,b=(h+m)/2,g=p-f,w=m-h,v=Math.sqrt(g*g+w*w);if(!(v<l+d)){f+=g*l/v,h+=w*l/v,p-=g*d/v,m-=w*d/v,y=(f+p)/2,b=(h+m)/2,g=p-f,w=m-h,v=Math.sqrt(g*g+w*w);var _=e.measureText(c).width;if(_>v){var k="…";for(c=c+k,_=e.measureText(c).width;_>v&&c.length>1;)c=c.slice(0,-2)+k,_=e.measureText(c).width;if(c.length<4)return}var x;g>0?w>0?x=Math.acos(g/v):x=Math.asin(w/v):w>0?x=Math.acos(g/v)+Math.PI:x=Math.asin(g/v)+Math.PI/2,e.save(),e.translate(y,b),e.rotate(x),e.fillText(c,-_/2,t.size/2+o),e.restore()}}}function rk(e,t,n){if(t.label){var r=n.labelSize,i=n.labelFont,o=n.labelWeight,s=n.labelColor.attribute?t[n.labelColor.attribute]||n.labelColor.color||"#000":n.labelColor.color;e.fillStyle=s,e.font="".concat(o," ").concat(r,"px ").concat(i),e.fillText(t.label,t.x+t.size+3,t.y+r/3)}}function ZN(e,t,n){var r=n.labelSize,i=n.labelFont,o=n.labelWeight;e.font="".concat(o," ").concat(r,"px ").concat(i),e.fillStyle="#FFF",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=8,e.shadowColor="#000";var s=2;if(typeof t.label=="string"){var a=e.measureText(t.label).width,u=Math.round(a+5),c=Math.round(r+2*s),l=Math.max(t.size,r/2)+s,d=Math.asin(c/2/l),f=Math.sqrt(Math.abs(Math.pow(l,2)-Math.pow(c/2,2)));e.beginPath(),e.moveTo(t.x+f,t.y+c/2),e.lineTo(t.x+l+u,t.y+c/2),e.lineTo(t.x+l+u,t.y-c/2),e.lineTo(t.x+f,t.y-c/2),e.arc(t.x,t.y,l,d,-d),e.closePath(),e.fill()}else e.beginPath(),e.arc(t.x,t.y,t.size+s,0,Math.PI*2),e.closePath(),e.fill();e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,rk(e,t,n)}var BN=`
114
+ `).concat(n))}return i}function QN(e,t){return ck("VERTEX",e,t)}function eR(e,t){return ck("FRAGMENT",e,t)}function tR(e,t){var n=e.createProgram();if(n===null)throw new Error("loadProgram: error while creating the program.");var r,i;for(r=0,i=t.length;r<i;r++)e.attachShader(n,t[r]);e.linkProgram(n);var o=e.getProgramParameter(n,e.LINK_STATUS);if(!o){var s=e.getProgramInfoLog(n);throw e.deleteProgram(n),new Error("loadProgram: error while linking the program: ".concat(s))}return n}function mm(e){var t=e.gl,n=e.buffer,r=e.program,i=e.vertexShader,o=e.fragmentShader;t.deleteShader(i),t.deleteShader(o),t.deleteProgram(r),t.deleteBuffer(n)}function gm(e){return e%1===0?e.toFixed(1):e.toString()}var ym=`#define PICKING_MODE
115
+ `,nR=P(P(P(P(P(P(P(P({},WebGL2RenderingContext.BOOL,1),WebGL2RenderingContext.BYTE,1),WebGL2RenderingContext.UNSIGNED_BYTE,1),WebGL2RenderingContext.SHORT,2),WebGL2RenderingContext.UNSIGNED_SHORT,2),WebGL2RenderingContext.INT,4),WebGL2RenderingContext.UNSIGNED_INT,4),WebGL2RenderingContext.FLOAT,4),lk=(function(){function e(t,n,r){gt(this,e),P(this,"array",new Float32Array),P(this,"constantArray",new Float32Array),P(this,"capacity",0),P(this,"verticesCount",0);var i=this.getDefinition();if(this.VERTICES=i.VERTICES,this.VERTEX_SHADER_SOURCE=i.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=i.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=i.UNIFORMS,this.ATTRIBUTES=i.ATTRIBUTES,this.METHOD=i.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in i?i.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in i?i.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in i,this.ATTRIBUTES_ITEMS_COUNT=Uu(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=r,this.normalProgram=this.getProgramInfo("normal",t,i.VERTEX_SHADER_SOURCE,i.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=n?this.getProgramInfo("pick",t,ym+i.VERTEX_SHADER_SOURCE,ym+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var o=Uu(this.CONSTANT_ATTRIBUTES);if(this.CONSTANT_DATA.length!==this.VERTICES)throw new Error("Program: error while getting constant data (expected ".concat(this.VERTICES," items, received ").concat(this.CONSTANT_DATA.length," instead)"));this.constantArray=new Float32Array(this.CONSTANT_DATA.length*o);for(var s=0;s<this.CONSTANT_DATA.length;s++){var a=this.CONSTANT_DATA[s];if(a.length!==o)throw new Error("Program: error while getting constant data (one vector has ".concat(a.length," items instead of ").concat(o,")"));for(var u=0;u<a.length;u++)this.constantArray[s*o+u]=a[u]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return yt(e,[{key:"kill",value:function(){mm(this.normalProgram),this.pickProgram&&(mm(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(n,r,i,o,s){var a=this.getDefinition(),u=r.createBuffer();if(u===null)throw new Error("Program: error while creating the WebGL buffer.");var c=QN(r,i),l=eR(r,o),d=tR(r,[c,l]),h={};a.UNIFORMS.forEach(function(m){var y=r.getUniformLocation(d,m);y&&(h[m]=y)});var f={};a.ATTRIBUTES.forEach(function(m){f[m.name]=r.getAttribLocation(d,m.name)});var p;if("CONSTANT_ATTRIBUTES"in a&&(a.CONSTANT_ATTRIBUTES.forEach(function(m){f[m.name]=r.getAttribLocation(d,m.name)}),p=r.createBuffer(),p===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:n,program:d,gl:r,frameBuffer:s,buffer:u,constantBuffer:p||{},uniformLocations:h,attributeLocations:f,isPicking:n==="pick",vertexShader:c,fragmentShader:l}}},{key:"bindProgram",value:function(n){var r=this,i=0,o=n.gl,s=n.buffer;this.isInstanced?(o.bindBuffer(o.ARRAY_BUFFER,n.constantBuffer),i=0,this.CONSTANT_ATTRIBUTES.forEach(function(a){return i+=r.bindAttribute(a,n,i,!1)}),o.bufferData(o.ARRAY_BUFFER,this.constantArray,o.STATIC_DRAW),o.bindBuffer(o.ARRAY_BUFFER,n.buffer),i=0,this.ATTRIBUTES.forEach(function(a){return i+=r.bindAttribute(a,n,i,!0)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)):(o.bindBuffer(o.ARRAY_BUFFER,s),i=0,this.ATTRIBUTES.forEach(function(a){return i+=r.bindAttribute(a,n,i)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)),o.bindBuffer(o.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(n){var r=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n,!1)}),this.ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n,!0)})):this.ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n)})}},{key:"bindAttribute",value:function(n,r,i,o){var s=nR[n.type];if(typeof s!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(n.type,'"'));var a=r.attributeLocations[n.name],u=r.gl;if(a!==-1){u.enableVertexAttribArray(a);var c=this.isInstanced?(o?this.ATTRIBUTES_ITEMS_COUNT:Uu(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(u.vertexAttribPointer(a,n.size,n.type,n.normalized||!1,c,i),this.isInstanced&&o)if(u instanceof WebGL2RenderingContext)u.vertexAttribDivisor(a,1);else{var l=u.getExtension("ANGLE_instanced_arrays");l&&l.vertexAttribDivisorANGLE(a,1)}}return n.size*s}},{key:"unbindAttribute",value:function(n,r,i){var o=r.attributeLocations[n.name],s=r.gl;if(o!==-1&&(s.disableVertexAttribArray(o),this.isInstanced&&i))if(s instanceof WebGL2RenderingContext)s.vertexAttribDivisor(o,0);else{var a=s.getExtension("ANGLE_instanced_arrays");a&&a.vertexAttribDivisorANGLE(o,0)}}},{key:"reallocate",value:function(n){n!==this.capacity&&(this.capacity=n,this.verticesCount=this.VERTICES*n,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}},{key:"hasNothingToRender",value:function(){return this.verticesCount===0}},{key:"renderProgram",value:function(n,r){var i=r.gl,o=r.program;i.enable(i.BLEND),i.useProgram(o),this.setUniforms(n,r),this.drawWebGL(this.METHOD,r)}},{key:"render",value:function(n){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,n.width*n.pixelRatio/n.downSizingRatio,n.height*n.pixelRatio/n.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram(ee(ee({},n),{},{pixelRatio:n.pixelRatio/n.downSizingRatio}),this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,n.width*n.pixelRatio,n.height*n.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(n,this.normalProgram),this.unbindProgram(this.normalProgram))}},{key:"drawWebGL",value:function(n,r){var i=r.gl,o=r.frameBuffer;if(i.bindFramebuffer(i.FRAMEBUFFER,o),!this.isInstanced)i.drawArrays(n,0,this.verticesCount);else if(i instanceof WebGL2RenderingContext)i.drawArraysInstanced(n,0,this.VERTICES,this.capacity);else{var s=i.getExtension("ANGLE_instanced_arrays");s&&s.drawArraysInstancedANGLE(n,0,this.VERTICES,this.capacity)}}}])})(),dk=(function(e){function t(){return gt(this,t),Bt(this,t,arguments)}return Ht(t,e),yt(t,[{key:"kill",value:function(){uk(t,"kill",this)([])}},{key:"process",value:function(r,i,o){var s=i*this.STRIDE;if(o.hidden){for(var a=s+this.STRIDE;s<a;s++)this.array[s]=0;return}return this.processVisibleItem(ak(r),s,o)}}])})(lk),du=(function(e){function t(){var n;gt(this,t);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=Bt(this,t,[].concat(i)),P(n,"drawLabel",void 0),n}return Ht(t,e),yt(t,[{key:"kill",value:function(){uk(t,"kill",this)([])}},{key:"process",value:function(r,i,o,s,a){var u=i*this.STRIDE;if(a.hidden||o.hidden||s.hidden){for(var c=u+this.STRIDE;u<c;u++)this.array[u]=0;return}return this.processVisibleItem(ak(r),u,o,s,a)}}])})(lk);function rR(e,t){return(function(){function n(r,i,o){gt(this,n),P(this,"drawLabel",t),this.programs=e.map(function(s){return new s(r,i,o)})}return yt(n,[{key:"reallocate",value:function(i){this.programs.forEach(function(o){return o.reallocate(i)})}},{key:"process",value:function(i,o,s,a,u){this.programs.forEach(function(c){return c.process(i,o,s,a,u)})}},{key:"render",value:function(i){this.programs.forEach(function(o){return o.render(i)})}},{key:"kill",value:function(){this.programs.forEach(function(i){return i.kill()})}}])})()}function fk(e,t,n,r,i){var o=i.edgeLabelSize,s=i.edgeLabelFont,a=i.edgeLabelWeight,u=i.edgeLabelColor.attribute?t[i.edgeLabelColor.attribute]||i.edgeLabelColor.color||"#000":i.edgeLabelColor.color,c=t.label;if(c){e.fillStyle=u,e.font="".concat(a," ").concat(o,"px ").concat(s);var l=n.size,d=r.size,h=n.x,f=n.y,p=r.x,m=r.y,y=(h+p)/2,b=(f+m)/2,g=p-h,_=m-f,v=Math.sqrt(g*g+_*_);if(!(v<l+d)){h+=g*l/v,f+=_*l/v,p-=g*d/v,m-=_*d/v,y=(h+p)/2,b=(f+m)/2,g=p-h,_=m-f,v=Math.sqrt(g*g+_*_);var w=e.measureText(c).width;if(w>v){var k="…";for(c=c+k,w=e.measureText(c).width;w>v&&c.length>1;)c=c.slice(0,-2)+k,w=e.measureText(c).width;if(c.length<4)return}var x;g>0?_>0?x=Math.acos(g/v):x=Math.asin(_/v):_>0?x=Math.acos(g/v)+Math.PI:x=Math.asin(g/v)+Math.PI/2,e.save(),e.translate(y,b),e.rotate(x),e.fillText(c,-w/2,t.size/2+o),e.restore()}}}function hk(e,t,n){if(t.label){var r=n.labelSize,i=n.labelFont,o=n.labelWeight,s=n.labelColor.attribute?t[n.labelColor.attribute]||n.labelColor.color||"#000":n.labelColor.color;e.fillStyle=s,e.font="".concat(o," ").concat(r,"px ").concat(i),e.fillText(t.label,t.x+t.size+3,t.y+r/3)}}function iR(e,t,n){var r=n.labelSize,i=n.labelFont,o=n.labelWeight;e.font="".concat(o," ").concat(r,"px ").concat(i),e.fillStyle="#FFF",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=8,e.shadowColor="#000";var s=2;if(typeof t.label=="string"){var a=e.measureText(t.label).width,u=Math.round(a+5),c=Math.round(r+2*s),l=Math.max(t.size,r/2)+s,d=Math.asin(c/2/l),h=Math.sqrt(Math.abs(Math.pow(l,2)-Math.pow(c/2,2)));e.beginPath(),e.moveTo(t.x+h,t.y+c/2),e.lineTo(t.x+l+u,t.y+c/2),e.lineTo(t.x+l+u,t.y-c/2),e.lineTo(t.x+h,t.y-c/2),e.arc(t.x,t.y,l,d,-d),e.closePath(),e.fill()}else e.beginPath(),e.arc(t.x,t.y,t.size+s,0,Math.PI*2),e.closePath(),e.fill();e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,hk(e,t,n)}var oR=`
116
116
  precision highp float;
117
117
 
118
118
  varying vec4 v_color;
@@ -144,7 +144,7 @@ void main(void) {
144
144
  gl_FragColor = mix(v_color, transparent, t);
145
145
  #endif
146
146
  }
147
- `,HN=BN,VN=`
147
+ `,sR=oR,aR=`
148
148
  attribute vec4 a_id;
149
149
  attribute vec4 a_color;
150
150
  attribute vec2 a_position;
@@ -185,7 +185,7 @@ void main() {
185
185
 
186
186
  v_color.a *= bias;
187
187
  }
188
- `,qN=VN,ik=WebGLRenderingContext,lm=ik.UNSIGNED_BYTE,Pu=ik.FLOAT,WN=["u_sizeRatio","u_correctionRatio","u_matrix"],ou=(function(e){function t(){return mt(this,t),Zt(this,t,arguments)}return Bt(t,e),gt(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:qN,FRAGMENT_SHADER_SOURCE:HN,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:WN,ATTRIBUTES:[{name:"a_position",size:2,type:Pu},{name:"a_size",size:1,type:Pu},{name:"a_color",size:4,type:lm,normalized:!0},{name:"a_id",size:4,type:lm,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Pu}],CONSTANT_DATA:[[t.ANGLE_1],[t.ANGLE_2],[t.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,o){var s=this.array,a=Pn(o.color);s[i++]=o.x,s[i++]=o.y,s[i++]=o.size,s[i++]=a,s[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,s=i.uniformLocations,a=s.u_sizeRatio,u=s.u_correctionRatio,c=s.u_matrix;o.uniform1f(u,r.correctionRatio),o.uniform1f(a,r.sizeRatio),o.uniformMatrix3fv(c,!1,r.matrix)}}])})(nk);P(ou,"ANGLE_1",0);P(ou,"ANGLE_2",2*Math.PI/3);P(ou,"ANGLE_3",4*Math.PI/3);var KN=`
188
+ `,uR=aR,pk=WebGLRenderingContext,vm=pk.UNSIGNED_BYTE,Gu=pk.FLOAT,cR=["u_sizeRatio","u_correctionRatio","u_matrix"],fu=(function(e){function t(){return gt(this,t),Bt(this,t,arguments)}return Ht(t,e),yt(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:uR,FRAGMENT_SHADER_SOURCE:sR,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:cR,ATTRIBUTES:[{name:"a_position",size:2,type:Gu},{name:"a_size",size:1,type:Gu},{name:"a_color",size:4,type:vm,normalized:!0},{name:"a_id",size:4,type:vm,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Gu}],CONSTANT_DATA:[[t.ANGLE_1],[t.ANGLE_2],[t.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,o){var s=this.array,a=On(o.color);s[i++]=o.x,s[i++]=o.y,s[i++]=o.size,s[i++]=a,s[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,s=i.uniformLocations,a=s.u_sizeRatio,u=s.u_correctionRatio,c=s.u_matrix;o.uniform1f(u,r.correctionRatio),o.uniform1f(a,r.sizeRatio),o.uniformMatrix3fv(c,!1,r.matrix)}}])})(dk);P(fu,"ANGLE_1",0);P(fu,"ANGLE_2",2*Math.PI/3);P(fu,"ANGLE_3",4*Math.PI/3);var lR=`
189
189
  precision mediump float;
190
190
 
191
191
  varying vec4 v_color;
@@ -193,7 +193,7 @@ varying vec4 v_color;
193
193
  void main(void) {
194
194
  gl_FragColor = v_color;
195
195
  }
196
- `,JN=KN,YN=`
196
+ `,dR=lR,fR=`
197
197
  attribute vec2 a_position;
198
198
  attribute vec2 a_normal;
199
199
  attribute float a_radius;
@@ -259,7 +259,7 @@ void main() {
259
259
 
260
260
  v_color.a *= bias;
261
261
  }
262
- `,XN=YN,ok=WebGLRenderingContext,dm=ok.UNSIGNED_BYTE,ts=ok.FLOAT,QN=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],su={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function sk(e){var t=Q(Q({},su),e||{});return(function(n){function r(){return mt(this,r),Zt(this,r,arguments)}return Bt(r,n),gt(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:XN,FRAGMENT_SHADER_SOURCE:JN,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:QN,ATTRIBUTES:[{name:"a_position",size:2,type:ts},{name:"a_normal",size:2,type:ts},{name:"a_radius",size:1,type:ts},{name:"a_color",size:4,type:dm,normalized:!0},{name:"a_id",size:4,type:dm,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:ts}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(o,s,a,u,c){if(t.extremity==="source"){var l=[u,a];a=l[0],u=l[1]}var d=c.size||1,f=u.size||1,h=a.x,p=a.y,m=u.x,y=u.y,b=Pn(c.color),g=m-h,w=y-p,v=g*g+w*w,_=0,k=0;v&&(v=1/Math.sqrt(v),_=-w*v*d,k=g*v*d);var x=this.array;x[s++]=m,x[s++]=y,x[s++]=-_,x[s++]=-k,x[s++]=f,x[s++]=b,x[s++]=o}},{key:"setUniforms",value:function(o,s){var a=s.gl,u=s.uniformLocations,c=u.u_matrix,l=u.u_sizeRatio,d=u.u_correctionRatio,f=u.u_minEdgeThickness,h=u.u_lengthToThicknessRatio,p=u.u_widenessToThicknessRatio;a.uniformMatrix3fv(c,!1,o.matrix),a.uniform1f(l,o.sizeRatio),a.uniform1f(d,o.correctionRatio),a.uniform1f(f,o.minEdgeThickness),a.uniform1f(h,t.lengthToThicknessRatio),a.uniform1f(p,t.widenessToThicknessRatio)}}])})(iu)}sk();var eR=`
262
+ `,hR=fR,mk=WebGLRenderingContext,bm=mk.UNSIGNED_BYTE,as=mk.FLOAT,pR=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],hu={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function gk(e){var t=ee(ee({},hu),e||{});return(function(n){function r(){return gt(this,r),Bt(this,r,arguments)}return Ht(r,n),yt(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:hR,FRAGMENT_SHADER_SOURCE:dR,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:pR,ATTRIBUTES:[{name:"a_position",size:2,type:as},{name:"a_normal",size:2,type:as},{name:"a_radius",size:1,type:as},{name:"a_color",size:4,type:bm,normalized:!0},{name:"a_id",size:4,type:bm,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:as}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(o,s,a,u,c){if(t.extremity==="source"){var l=[u,a];a=l[0],u=l[1]}var d=c.size||1,h=u.size||1,f=a.x,p=a.y,m=u.x,y=u.y,b=On(c.color),g=m-f,_=y-p,v=g*g+_*_,w=0,k=0;v&&(v=1/Math.sqrt(v),w=-_*v*d,k=g*v*d);var x=this.array;x[s++]=m,x[s++]=y,x[s++]=-w,x[s++]=-k,x[s++]=h,x[s++]=b,x[s++]=o}},{key:"setUniforms",value:function(o,s){var a=s.gl,u=s.uniformLocations,c=u.u_matrix,l=u.u_sizeRatio,d=u.u_correctionRatio,h=u.u_minEdgeThickness,f=u.u_lengthToThicknessRatio,p=u.u_widenessToThicknessRatio;a.uniformMatrix3fv(c,!1,o.matrix),a.uniform1f(l,o.sizeRatio),a.uniform1f(d,o.correctionRatio),a.uniform1f(h,o.minEdgeThickness),a.uniform1f(f,t.lengthToThicknessRatio),a.uniform1f(p,t.widenessToThicknessRatio)}}])})(du)}gk();var mR=`
263
263
  precision mediump float;
264
264
 
265
265
  varying vec4 v_color;
@@ -285,7 +285,7 @@ void main(void) {
285
285
  gl_FragColor = mix(v_color, transparent, t);
286
286
  #endif
287
287
  }
288
- `,ak=eR,tR=`
288
+ `,yk=mR,gR=`
289
289
  attribute vec4 a_id;
290
290
  attribute vec4 a_color;
291
291
  attribute vec2 a_normal;
@@ -353,7 +353,7 @@ void main() {
353
353
 
354
354
  v_color.a *= bias;
355
355
  }
356
- `,nR=tR,uk=WebGLRenderingContext,fm=uk.UNSIGNED_BYTE,Gn=uk.FLOAT,rR=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],iR={lengthToThicknessRatio:su.lengthToThicknessRatio};function ck(e){var t=Q(Q({},iR),e||{});return(function(n){function r(){return mt(this,r),Zt(this,r,arguments)}return Bt(r,n),gt(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:nR,FRAGMENT_SHADER_SOURCE:ak,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:rR,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Gn},{name:"a_positionEnd",size:2,type:Gn},{name:"a_normal",size:2,type:Gn},{name:"a_color",size:4,type:fm,normalized:!0},{name:"a_id",size:4,type:fm,normalized:!0},{name:"a_radius",size:1,type:Gn}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Gn},{name:"a_normalCoef",size:1,type:Gn},{name:"a_radiusCoef",size:1,type:Gn}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(o,s,a,u,c){var l=c.size||1,d=a.x,f=a.y,h=u.x,p=u.y,m=Pn(c.color),y=h-d,b=p-f,g=u.size||1,w=y*y+b*b,v=0,_=0;w&&(w=1/Math.sqrt(w),v=-b*w*l,_=y*w*l);var k=this.array;k[s++]=d,k[s++]=f,k[s++]=h,k[s++]=p,k[s++]=v,k[s++]=_,k[s++]=m,k[s++]=o,k[s++]=g}},{key:"setUniforms",value:function(o,s){var a=s.gl,u=s.uniformLocations,c=u.u_matrix,l=u.u_zoomRatio,d=u.u_feather,f=u.u_pixelRatio,h=u.u_correctionRatio,p=u.u_sizeRatio,m=u.u_minEdgeThickness,y=u.u_lengthToThicknessRatio;a.uniformMatrix3fv(c,!1,o.matrix),a.uniform1f(l,o.zoomRatio),a.uniform1f(p,o.sizeRatio),a.uniform1f(h,o.correctionRatio),a.uniform1f(f,o.pixelRatio),a.uniform1f(d,o.antiAliasingFeather),a.uniform1f(m,o.minEdgeThickness),a.uniform1f(y,t.lengthToThicknessRatio)}}])})(iu)}ck();function lk(e){return GN([ck(e),sk(e)])}var oR=lk(),sR=oR,aR=`
356
+ `,yR=gR,vk=WebGLRenderingContext,wm=vk.UNSIGNED_BYTE,Gn=vk.FLOAT,vR=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],bR={lengthToThicknessRatio:hu.lengthToThicknessRatio};function bk(e){var t=ee(ee({},bR),e||{});return(function(n){function r(){return gt(this,r),Bt(this,r,arguments)}return Ht(r,n),yt(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:yR,FRAGMENT_SHADER_SOURCE:yk,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:vR,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Gn},{name:"a_positionEnd",size:2,type:Gn},{name:"a_normal",size:2,type:Gn},{name:"a_color",size:4,type:wm,normalized:!0},{name:"a_id",size:4,type:wm,normalized:!0},{name:"a_radius",size:1,type:Gn}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Gn},{name:"a_normalCoef",size:1,type:Gn},{name:"a_radiusCoef",size:1,type:Gn}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(o,s,a,u,c){var l=c.size||1,d=a.x,h=a.y,f=u.x,p=u.y,m=On(c.color),y=f-d,b=p-h,g=u.size||1,_=y*y+b*b,v=0,w=0;_&&(_=1/Math.sqrt(_),v=-b*_*l,w=y*_*l);var k=this.array;k[s++]=d,k[s++]=h,k[s++]=f,k[s++]=p,k[s++]=v,k[s++]=w,k[s++]=m,k[s++]=o,k[s++]=g}},{key:"setUniforms",value:function(o,s){var a=s.gl,u=s.uniformLocations,c=u.u_matrix,l=u.u_zoomRatio,d=u.u_feather,h=u.u_pixelRatio,f=u.u_correctionRatio,p=u.u_sizeRatio,m=u.u_minEdgeThickness,y=u.u_lengthToThicknessRatio;a.uniformMatrix3fv(c,!1,o.matrix),a.uniform1f(l,o.zoomRatio),a.uniform1f(p,o.sizeRatio),a.uniform1f(f,o.correctionRatio),a.uniform1f(h,o.pixelRatio),a.uniform1f(d,o.antiAliasingFeather),a.uniform1f(m,o.minEdgeThickness),a.uniform1f(y,t.lengthToThicknessRatio)}}])})(du)}bk();function wk(e){return rR([bk(e),gk(e)])}var wR=wk(),_R=wR,kR=`
357
357
  attribute vec4 a_id;
358
358
  attribute vec4 a_color;
359
359
  attribute vec2 a_normal;
@@ -418,9 +418,9 @@ void main() {
418
418
 
419
419
  v_color.a *= bias;
420
420
  }
421
- `,uR=aR,dk=WebGLRenderingContext,hm=dk.UNSIGNED_BYTE,ni=dk.FLOAT,cR=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],lR=(function(e){function t(){return mt(this,t),Zt(this,t,arguments)}return Bt(t,e),gt(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:uR,FRAGMENT_SHADER_SOURCE:ak,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:cR,ATTRIBUTES:[{name:"a_positionStart",size:2,type:ni},{name:"a_positionEnd",size:2,type:ni},{name:"a_normal",size:2,type:ni},{name:"a_color",size:4,type:hm,normalized:!0},{name:"a_id",size:4,type:hm,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:ni},{name:"a_normalCoef",size:1,type:ni}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(r,i,o,s,a){var u=a.size||1,c=o.x,l=o.y,d=s.x,f=s.y,h=Pn(a.color),p=d-c,m=f-l,y=p*p+m*m,b=0,g=0;y&&(y=1/Math.sqrt(y),b=-m*y*u,g=p*y*u);var w=this.array;w[i++]=c,w[i++]=l,w[i++]=d,w[i++]=f,w[i++]=b,w[i++]=g,w[i++]=h,w[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,s=i.uniformLocations,a=s.u_matrix,u=s.u_zoomRatio,c=s.u_feather,l=s.u_pixelRatio,d=s.u_correctionRatio,f=s.u_sizeRatio,h=s.u_minEdgeThickness;o.uniformMatrix3fv(a,!1,r.matrix),o.uniform1f(u,r.zoomRatio),o.uniform1f(f,r.sizeRatio),o.uniform1f(d,r.correctionRatio),o.uniform1f(l,r.pixelRatio),o.uniform1f(c,r.antiAliasingFeather),o.uniform1f(h,r.minEdgeThickness)}}])})(iu),gh=(function(e){function t(){var n;return mt(this,t),n=Zt(this,t),n.rawEmitter=n,n}return Bt(t,e),gt(t)})(R_.EventEmitter),Du,pm;function dR(){return pm||(pm=1,Du=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}),Du}var fR=dR();const hR=vI(fR);var pR=function(t){return t},mR=function(t){return t*t},gR=function(t){return t*(2-t)},yR=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},vR=function(t){return t*t*t},bR=function(t){return--t*t*t+1},wR=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},_R={linear:pR,quadraticIn:mR,quadraticOut:gR,quadraticInOut:yR,cubicIn:vR,cubicOut:bR,cubicInOut:wR},kR={easing:"quadraticInOut",duration:150};function Kt(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function ns(e,t,n){return e[0]=t,e[4]=typeof n=="number"?n:t,e}function mm(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[3]=-n,e[4]=r,e}function gm(e,t,n){return e[6]=t,e[7]=n,e}function bn(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],s=e[4],a=e[5],u=e[6],c=e[7],l=e[8],d=t[0],f=t[1],h=t[2],p=t[3],m=t[4],y=t[5],b=t[6],g=t[7],w=t[8];return e[0]=d*n+f*o+h*u,e[1]=d*r+f*s+h*c,e[2]=d*i+f*a+h*l,e[3]=p*n+m*o+y*u,e[4]=p*r+m*s+y*c,e[5]=p*i+m*a+y*l,e[6]=b*n+g*o+w*u,e[7]=b*r+g*s+w*c,e[8]=b*i+g*a+w*l,e}function kc(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=e[0],i=e[1],o=e[3],s=e[4],a=e[6],u=e[7],c=t.x,l=t.y;return{x:c*r+l*o+a*n,y:c*i+l*s+u*n}}function SR(e,t){var n=e.height/e.width,r=t.height/t.width;return n<1&&r>1||n>1&&r<1?1:Math.min(Math.max(r,1/r),Math.max(1/n,n))}function ri(e,t,n,r,i){var o=e.angle,s=e.ratio,a=e.x,u=e.y,c=t.width,l=t.height,d=Kt(),f=Math.min(c,l)-2*r,h=SR(t,n);return i?(bn(d,gm(Kt(),a,u)),bn(d,ns(Kt(),s)),bn(d,mm(Kt(),o)),bn(d,ns(Kt(),c/f/2/h,l/f/2/h))):(bn(d,ns(Kt(),2*(f/c)*h,2*(f/l)*h)),bn(d,mm(Kt(),-o)),bn(d,ns(Kt(),1/s)),bn(d,gm(Kt(),-a,-u))),d}function xR(e,t,n){var r=kc(e,{x:Math.cos(t.angle),y:Math.sin(t.angle)},0),i=r.x,o=r.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(o,2))/n.width}function ER(e){if(!e.order)return{x:[0,1],y:[0,1]};var t=1/0,n=-1/0,r=1/0,i=-1/0;return e.forEachNode(function(o,s){var a=s.x,u=s.y;a<t&&(t=a),a>n&&(n=a),u<r&&(r=u),u>i&&(i=u)}),{x:[t,n],y:[r,i]}}function $R(e){if(!hR(e))throw new Error("Sigma: invalid graph instance.");e.forEachNode(function(t,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y))throw new Error("Sigma: Coordinates of node ".concat(t," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function TR(e,t,n){var r=document.createElement(e);if(t)for(var i in t)r.style[i]=t[i];if(n)for(var o in n)r.setAttribute(o,n[o]);return r}function ym(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function vm(e,t,n){return n.sort(function(r,i){var o=t(r)||0,s=t(i)||0;return o<s?-1:o>s?1:0})}function bm(e){var t=xr(e.x,2),n=t[0],r=t[1],i=xr(e.y,2),o=i[0],s=i[1],a=Math.max(r-n,s-o),u=(r+n)/2,c=(s+o)/2;(a===0||Math.abs(a)===1/0||isNaN(a))&&(a=1),isNaN(u)&&(u=0),isNaN(c)&&(c=0);var l=function(f){return{x:.5+(f.x-u)/a,y:.5+(f.y-c)/a}};return l.applyTo=function(d){d.x=.5+(d.x-u)/a,d.y=.5+(d.y-c)/a},l.inverse=function(d){return{x:u+a*(d.x-.5),y:c+a*(d.y-.5)}},l.ratio=a,l}function Sc(e){"@babel/helpers - typeof";return Sc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Sc(e)}function wm(e,t){var n=t.size;if(n!==0){var r=e.length;e.length+=n;var i=0;t.forEach(function(o){e[r+i]=o,i++})}}function Ou(e){e=e||{};for(var t=0,n=arguments.length<=1?0:arguments.length-1;t<n;t++){var r=t+1<1||arguments.length<=t+1?void 0:arguments[t+1];r&&Object.assign(e,r)}return e}var yh={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:"#999",defaultNodeType:"circle",defaultEdgeColor:"#ccc",defaultEdgeType:"line",labelFont:"Arial",labelSize:14,labelWeight:"normal",labelColor:{color:"#000"},edgeLabelFont:"Arial",edgeLabelSize:14,edgeLabelWeight:"normal",edgeLabelColor:{attribute:"color"},stagePadding:30,defaultDrawEdgeLabel:jN,defaultDrawNodeLabel:rk,defaultDrawNodeHover:ZN,minEdgeThickness:1.7,antiAliasingFeather:1,dragTimeout:100,draggedEventsTolerance:3,inertiaDuration:200,inertiaRatio:3,zoomDuration:250,zoomingRatio:1.7,doubleClickTimeout:300,doubleClickZoomingRatio:2.2,doubleClickZoomingDuration:200,tapMoveTolerance:10,zoomToSizeRatioFunction:Math.sqrt,itemSizesReference:"screen",autoRescale:!0,autoCenter:!0,labelDensity:1,labelGridCellSize:100,labelRenderedSizeThreshold:6,nodeReducer:null,edgeReducer:null,zIndex:!1,minCameraRatio:null,maxCameraRatio:null,enableCameraZooming:!0,enableCameraPanning:!0,enableCameraRotation:!0,cameraPanBoundaries:null,allowInvalidContainer:!1,nodeProgramClasses:{},nodeHoverProgramClasses:{},edgeProgramClasses:{}},CR={circle:ou},AR={arrow:sR,line:lR};function Mu(e){if(typeof e.labelDensity!="number"||e.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var t=e.minCameraRatio,n=e.maxCameraRatio;if(typeof t=="number"&&typeof n=="number"&&n<t)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function IR(e){var t=Ou({},yh,e);return t.nodeProgramClasses=Ou({},CR,t.nodeProgramClasses),t.edgeProgramClasses=Ou({},AR,t.edgeProgramClasses),t}var rs=1.5,_m=(function(e){function t(){var n;return mt(this,t),n=Zt(this,t),P(n,"x",.5),P(n,"y",.5),P(n,"angle",0),P(n,"ratio",1),P(n,"minRatio",null),P(n,"maxRatio",null),P(n,"enabledZooming",!0),P(n,"enabledPanning",!0),P(n,"enabledRotation",!0),P(n,"clean",null),P(n,"nextFrame",null),P(n,"previousState",null),P(n,"enabled",!0),n.previousState=n.getState(),n}return Bt(t,e),gt(t,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(r){return this.x===r.x&&this.y===r.y&&this.ratio===r.ratio&&this.angle===r.angle}},{key:"getPreviousState",value:function(){var r=this.previousState;return r?{x:r.x,y:r.y,angle:r.angle,ratio:r.ratio}:null}},{key:"getBoundedRatio",value:function(r){var i=r;return typeof this.minRatio=="number"&&(i=Math.max(i,this.minRatio)),typeof this.maxRatio=="number"&&(i=Math.min(i,this.maxRatio)),i}},{key:"validateState",value:function(r){var i={};return this.enabledPanning&&typeof r.x=="number"&&(i.x=r.x),this.enabledPanning&&typeof r.y=="number"&&(i.y=r.y),this.enabledZooming&&typeof r.ratio=="number"&&(i.ratio=this.getBoundedRatio(r.ratio)),this.enabledRotation&&typeof r.angle=="number"&&(i.angle=r.angle),this.clean?this.clean(Q(Q({},this.getState()),i)):i}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(r){if(!this.enabled)return this;this.previousState=this.getState();var i=this.validateState(r);return typeof i.x=="number"&&(this.x=i.x),typeof i.y=="number"&&(this.y=i.y),typeof i.ratio=="number"&&(this.ratio=i.ratio),typeof i.angle=="number"&&(this.angle=i.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(r){return this.setState(r(this.getState())),this}},{key:"animate",value:function(r){var i=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;if(!s)return new Promise(function(h){return i.animate(r,o,h)});if(this.enabled){var a=Q(Q({},kR),o),u=this.validateState(r),c=typeof a.easing=="function"?a.easing:_R[a.easing],l=Date.now(),d=this.getState(),f=function(){var p=(Date.now()-l)/a.duration;if(p>=1){i.nextFrame=null,i.setState(u),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var m=c(p),y={};typeof u.x=="number"&&(y.x=d.x+(u.x-d.x)*m),typeof u.y=="number"&&(y.y=d.y+(u.y-d.y)*m),i.enabledRotation&&typeof u.angle=="number"&&(y.angle=d.angle+(u.angle-d.angle)*m),typeof u.ratio=="number"&&(y.ratio=d.ratio+(u.ratio-d.ratio)*m),i.setState(y),i.nextFrame=requestAnimationFrame(f)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(f)):f(),this.animationCallback=s}}},{key:"animatedZoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio/r}):this.animate({ratio:this.ratio/(r.factor||rs)},r):this.animate({ratio:this.ratio/rs})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||rs)},r):this.animate({ratio:this.ratio*rs})}},{key:"animatedReset",value:function(r){return this.animate({x:.5,y:.5,ratio:1,angle:0},r)}},{key:"copy",value:function(){return t.from(this.getState())}}],[{key:"from",value:function(r){var i=new t;return i.setState(r)}}])})(gh);function Yt(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function rn(e,t){var n=Q(Q({},Yt(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function ii(e){var t="x"in e?e:Q(Q({},e.touches[0]||e.previousTouches[0]),{},{original:e.original,sigmaDefaultPrevented:e.sigmaDefaultPrevented,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0,t.sigmaDefaultPrevented=!0}});return t}function NR(e,t){return Q(Q({},rn(e,t)),{},{delta:fk(e)})}var RR=2;function ds(e){for(var t=[],n=0,r=Math.min(e.length,RR);n<r;n++)t.push(e[n]);return t}function oi(e,t,n){var r={touches:ds(e.touches).map(function(i){return Yt(i,n)}),previousTouches:t.map(function(i){return Yt(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:e};return r}function fk(e){if(typeof e.deltaY<"u")return e.deltaY*-3/360;if(typeof e.detail<"u")return e.detail/-9;throw new Error("Captor: could not extract delta from event.")}var hk=(function(e){function t(n,r){var i;return mt(this,t),i=Zt(this,t),i.container=n,i.renderer=r,i}return Bt(t,e),gt(t)})(gh),LR=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],zR=LR.reduce(function(e,t){return Q(Q({},e),{},P({},t,yh[t]))},{}),PR=(function(e){function t(n,r){var i;return mt(this,t),i=Zt(this,t,[n,r]),P(i,"enabled",!0),P(i,"draggedEvents",0),P(i,"downStartTime",null),P(i,"lastMouseX",null),P(i,"lastMouseY",null),P(i,"isMouseDown",!1),P(i,"isMoving",!1),P(i,"movingTimeout",null),P(i,"startCameraState",null),P(i,"clicks",0),P(i,"doubleClickTimeout",null),P(i,"currentWheelDirection",0),P(i,"settings",zR),i.handleClick=i.handleClick.bind(i),i.handleRightClick=i.handleRightClick.bind(i),i.handleDown=i.handleDown.bind(i),i.handleUp=i.handleUp.bind(i),i.handleMove=i.handleMove.bind(i),i.handleWheel=i.handleWheel.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleEnter=i.handleEnter.bind(i),n.addEventListener("click",i.handleClick,{capture:!1}),n.addEventListener("contextmenu",i.handleRightClick,{capture:!1}),n.addEventListener("mousedown",i.handleDown,{capture:!1}),n.addEventListener("wheel",i.handleWheel,{capture:!1}),n.addEventListener("mouseleave",i.handleLeave,{capture:!1}),n.addEventListener("mouseenter",i.handleEnter,{capture:!1}),document.addEventListener("mousemove",i.handleMove,{capture:!1}),document.addEventListener("mouseup",i.handleUp,{capture:!1}),i}return Bt(t,e),gt(t,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("click",this.handleClick),r.removeEventListener("contextmenu",this.handleRightClick),r.removeEventListener("mousedown",this.handleDown),r.removeEventListener("wheel",this.handleWheel),r.removeEventListener("mouseleave",this.handleLeave),r.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(r){var i=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(r);setTimeout(function(){i.clicks=0,i.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",rn(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",rn(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=rn(r,this.container);if(this.emit("doubleClick",i),!i.sigmaDefaultPrevented){var o=this.renderer.getCamera(),s=o.getBoundedRatio(o.getState().ratio/this.settings.doubleClickZoomingRatio);o.animate(this.renderer.getViewportZoomedState(Yt(r,this.container),s),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(r){if(this.enabled){if(r.button===0){this.startCameraState=this.renderer.getCamera().getState();var i=Yt(r,this.container),o=i.x,s=i.y;this.lastMouseX=o,this.lastMouseY=s,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",rn(r,this.container))}}},{key:"handleUp",value:function(r){var i=this;if(!(!this.enabled||!this.isMouseDown)){var o=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var s=Yt(r,this.container),a=s.x,u=s.y,c=o.getState(),l=o.getPreviousState()||{x:0,y:0};this.isMoving?o.animate({x:c.x+this.settings.inertiaRatio*(c.x-l.x),y:c.y+this.settings.inertiaRatio*(c.y-l.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==a||this.lastMouseY!==u)&&o.setState({x:c.x,y:c.y}),this.isMoving=!1,setTimeout(function(){var d=i.draggedEvents>0;i.draggedEvents=0,d&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",rn(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=rn(r,this.container);if(this.emit("mousemovebody",o),(r.target===this.container||r.composedPath()[0]===this.container)&&this.emit("mousemove",o),!o.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.movingTimeout=null,i.isMoving=!1},this.settings.dragTimeout);var s=this.renderer.getCamera(),a=Yt(r,this.container),u=a.x,c=a.y,l=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),d=this.renderer.viewportToFramedGraph({x:u,y:c}),f=l.x-d.x,h=l.y-d.y,p=s.getState(),m=p.x+f,y=p.y+h;s.setState({x:m,y}),this.lastMouseX=u,this.lastMouseY=c,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",rn(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",rn(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var s=fk(r);if(s){var a=NR(r,this.container);if(this.emit("wheel",a),a.sigmaDefaultPrevented){r.preventDefault(),r.stopPropagation();return}var u=o.getState().ratio,c=s>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,l=o.getBoundedRatio(u*c),d=s>0?1:-1,f=Date.now();u!==l&&(r.preventDefault(),r.stopPropagation(),!(this.currentWheelDirection===d&&this.lastWheelTriggerTime&&f-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(Yt(r,this.container),l),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=d,this.lastWheelTriggerTime=f))}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(hk),DR=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],OR=DR.reduce(function(e,t){return Q(Q({},e),{},P({},t,yh[t]))},{}),MR=(function(e){function t(n,r){var i;return mt(this,t),i=Zt(this,t,[n,r]),P(i,"enabled",!0),P(i,"isMoving",!1),P(i,"hasMoved",!1),P(i,"touchMode",0),P(i,"startTouchesPositions",[]),P(i,"lastTouches",[]),P(i,"lastTap",null),P(i,"settings",OR),i.handleStart=i.handleStart.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleMove=i.handleMove.bind(i),n.addEventListener("touchstart",i.handleStart,{capture:!1}),n.addEventListener("touchcancel",i.handleLeave,{capture:!1}),document.addEventListener("touchend",i.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",i.handleMove,{capture:!1,passive:!1}),i}return Bt(t,e),gt(t,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("touchstart",this.handleStart),r.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(r){var i=this;if(this.enabled){r.preventDefault();var o=ds(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(h){return Yt(h,i.container)}),this.touchMode===2){var s=xr(this.startTouchesPositions,2),a=s[0],u=a.x,c=a.y,l=s[1],d=l.x,f=l.y;this.startTouchesAngle=Math.atan2(f-c,d-u),this.startTouchesDistance=Math.sqrt(Math.pow(d-u,2)+Math.pow(f-c,2))}this.emit("touchdown",oi(r,this.lastTouches,this.container)),this.lastTouches=o,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(r){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(r.cancelable&&r.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(r.touches.length===1){this.handleStart(r),r.preventDefault();break}case 1:if(this.isMoving){var i=this.renderer.getCamera(),o=i.getState(),s=i.getPreviousState()||{x:0,y:0};i.animate({x:o.x+this.settings.inertiaRatio*(o.x-s.x),y:o.y+this.settings.inertiaRatio*(o.y-s.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",oi(r,this.lastTouches,this.container)),!r.touches.length){var a=Yt(this.lastTouches[0],this.container),u=this.startTouchesPositions[0],c=Math.pow(a.x-u.x,2)+Math.pow(a.y-u.y,2);if(!r.touches.length&&c<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var l=oi(r,this.lastTouches,this.container);if(this.emit("doubletap",l),this.lastTap=null,!l.sigmaDefaultPrevented){var d=this.renderer.getCamera(),f=d.getBoundedRatio(d.getState().ratio/this.settings.doubleClickZoomingRatio);d.animate(this.renderer.getViewportZoomedState(a,f),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var h=oi(r,this.lastTouches,this.container);this.emit("tap",h),this.lastTap={time:Date.now(),position:h.touches[0]||h.previousTouches[0]}}}this.lastTouches=ds(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=ds(r.touches),s=o.map(function(I){return Yt(I,i.container)}),a=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=s;var u=oi(r,a,this.container);if(this.emit("touchmove",u),!u.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=s.some(function(I,z){var G=i.startTouchesPositions[z];return G&&(I.x!==G.x||I.y!==G.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var c=this.renderer.getCamera(),l=this.startCameraState,d=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var f=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),h=f.x,p=f.y,m=this.renderer.viewportToFramedGraph(s[0]),y=m.x,b=m.y;c.setState({x:l.x+h-y,y:l.y+p-b});break}case 2:{var g={x:.5,y:.5,angle:0,ratio:1},w=s[0],v=w.x,_=w.y,k=s[1],x=k.x,N=k.y,M=Math.atan2(N-_,x-v)-this.startTouchesAngle,F=Math.hypot(N-_,x-v)/this.startTouchesDistance,B=c.getBoundedRatio(l.ratio/F);g.ratio=B,g.angle=l.angle+M;var ee=this.getDimensions(),ce=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:l}),me=Math.min(ee.width,ee.height)-2*d,$e=me/ee.width,U=me/ee.height,H=B/me,K=v-me/2/$e,de=_-me/2/U,te=[K*Math.cos(-g.angle)-de*Math.sin(-g.angle),de*Math.cos(-g.angle)+K*Math.sin(-g.angle)];K=te[0],de=te[1],g.x=ce.x-K*H,g.y=ce.y+de*H,c.setState(g);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(hk);function FR(e){if(Array.isArray(e))return wc(e)}function UR(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function GR(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
422
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function km(e){return FR(e)||UR(e)||W_(e)||GR()}function jR(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Fu(e,t){if(e==null)return{};var n,r,i=jR(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var Sm=(function(){function e(t,n){mt(this,e),this.key=t,this.size=n}return gt(e,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),xm=(function(){function e(){mt(this,e),P(this,"width",0),P(this,"height",0),P(this,"cellSize",0),P(this,"columns",0),P(this,"rows",0),P(this,"cells",{})}return gt(e,[{key:"resizeAndClear",value:function(n,r){this.width=n.width,this.height=n.height,this.cellSize=r,this.columns=Math.ceil(n.width/r),this.rows=Math.ceil(n.height/r),this.cells={}}},{key:"getIndex",value:function(n){var r=Math.floor(n.x/this.cellSize),i=Math.floor(n.y/this.cellSize);return i*this.columns+r}},{key:"add",value:function(n,r,i){var o=new Sm(n,r),s=this.getIndex(i),a=this.cells[s];a||(a=[],this.cells[s]=a),a.push(o)}},{key:"organize",value:function(){for(var n in this.cells){var r=this.cells[n];r.sort(Sm.compare)}}},{key:"getLabelsToDisplay",value:function(n,r){var i=this.cellSize*this.cellSize,o=i/n/n,s=o*r/i,a=Math.ceil(s),u=[];for(var c in this.cells)for(var l=this.cells[c],d=0;d<Math.min(a,l.length);d++)u.push(l[d].key);return u}}])})();function ZR(e){var t=e.graph,n=e.hoveredNode,r=e.highlightedNodes,i=e.displayedNodeLabels,o=[];return t.forEachEdge(function(s,a,u,c){(u===n||c===n||r.has(u)||r.has(c)||i.has(u)&&i.has(c))&&o.push(s)}),o}var Em=150,$m=50,on=Object.prototype.hasOwnProperty;function BR(e,t,n){if(!on.call(n,"x")||!on.call(n,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(t,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return n.color||(n.color=e.defaultNodeColor),!n.label&&n.label!==""&&(n.label=null),n.label!==void 0&&n.label!==null?n.label=""+n.label:n.label=null,n.size||(n.size=2),on.call(n,"hidden")||(n.hidden=!1),on.call(n,"highlighted")||(n.highlighted=!1),on.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultNodeType),n.zIndex||(n.zIndex=0),n}function HR(e,t,n){return n.color||(n.color=e.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),on.call(n,"hidden")||(n.hidden=!1),on.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var VR=(function(e){function t(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(mt(this,t),i=Zt(this,t),P(i,"elements",{}),P(i,"canvasContexts",{}),P(i,"webGLContexts",{}),P(i,"pickingLayers",new Set),P(i,"textures",{}),P(i,"frameBuffers",{}),P(i,"activeListeners",{}),P(i,"labelGrid",new xm),P(i,"nodeDataCache",{}),P(i,"edgeDataCache",{}),P(i,"nodeProgramIndex",{}),P(i,"edgeProgramIndex",{}),P(i,"nodesWithForcedLabels",new Set),P(i,"edgesWithForcedLabels",new Set),P(i,"nodeExtent",{x:[0,1],y:[0,1]}),P(i,"nodeZExtent",[1/0,-1/0]),P(i,"edgeZExtent",[1/0,-1/0]),P(i,"matrix",Kt()),P(i,"invMatrix",Kt()),P(i,"correctionRatio",1),P(i,"customBBox",null),P(i,"normalizationFunction",bm({x:[0,1],y:[0,1]})),P(i,"graphToViewportRatio",1),P(i,"itemIDsIndex",{}),P(i,"nodeIndices",{}),P(i,"edgeIndices",{}),P(i,"width",0),P(i,"height",0),P(i,"pixelRatio",ym()),P(i,"pickingDownSizingRatio",2*i.pixelRatio),P(i,"displayedNodeLabels",new Set),P(i,"displayedEdgeLabels",new Set),P(i,"highlightedNodes",new Set),P(i,"hoveredNode",null),P(i,"hoveredEdge",null),P(i,"renderFrame",null),P(i,"renderHighlightedNodesFrame",null),P(i,"needToProcess",!1),P(i,"checkEdgesEventsFrame",null),P(i,"nodePrograms",{}),P(i,"nodeHoverPrograms",{}),P(i,"edgePrograms",{}),i.settings=IR(o),Mu(i.settings),$R(n),!(r instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=n,i.container=r,i.createWebGLContext("edges",{picking:o.enableEdgeEvents}),i.createCanvasContext("edgeLabels"),i.createWebGLContext("nodes",{picking:!0}),i.createCanvasContext("labels"),i.createCanvasContext("hovers"),i.createWebGLContext("hoverNodes"),i.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),i.resize();for(var s in i.settings.nodeProgramClasses)i.registerNodeProgram(s,i.settings.nodeProgramClasses[s],i.settings.nodeHoverProgramClasses[s]);for(var a in i.settings.edgeProgramClasses)i.registerEdgeProgram(a,i.settings.edgeProgramClasses[a]);return i.camera=new _m,i.bindCameraHandlers(),i.mouseCaptor=new PR(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new MR(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Bt(t,e),gt(t,[{key:"registerNodeProgram",value:function(r,i,o){return this.nodePrograms[r]&&this.nodePrograms[r].kill(),this.nodeHoverPrograms[r]&&this.nodeHoverPrograms[r].kill(),this.nodePrograms[r]=new i(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[r]=new(o||i)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(r,i){return this.edgePrograms[r]&&this.edgePrograms[r].kill(),this.edgePrograms[r]=new i(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(r){if(this.nodePrograms[r]){var i=this.nodePrograms,o=i[r],s=Fu(i,[r].map(mi));o.kill(),this.nodePrograms=s}if(this.nodeHoverPrograms[r]){var a=this.nodeHoverPrograms,u=a[r],c=Fu(a,[r].map(mi));u.kill(),this.nodePrograms=c}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],s=Fu(i,[r].map(mi));o.kill(),this.edgePrograms=s}return this}},{key:"resetWebGLTexture",value:function(r){var i=this.webGLContexts[r],o=this.frameBuffers[r],s=this.textures[r];s&&i.deleteTexture(s);var a=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,o),i.bindTexture(i.TEXTURE_2D,a),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,a,0),this.textures[r]=a,this}},{key:"bindCameraHandlers",value:function(){var r=this;return this.activeListeners.camera=function(){r.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(r){var i=r.x,o=r.y,s=om(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),a=im.apply(void 0,km(s)),u=this.itemIDsIndex[a];return u&&u.type==="node"?u.id:null}},{key:"bindEventHandlers",value:function(){var r=this;this.activeListeners.handleResize=function(){r.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(o){var s=ii(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}},u=r.getNodeAtPosition(s);if(u&&r.hoveredNode!==u&&!r.nodeDataCache[u].hidden){r.hoveredNode&&r.emit("leaveNode",Q(Q({},a),{},{node:r.hoveredNode})),r.hoveredNode=u,r.emit("enterNode",Q(Q({},a),{},{node:u})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(s)!==r.hoveredNode){var c=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",Q(Q({},a),{},{node:c})),r.scheduleHighlightedNodesRender();return}if(r.settings.enableEdgeEvents){var l=r.hoveredNode?null:r.getEdgeAtPoint(a.event.x,a.event.y);l!==r.hoveredEdge&&(r.hoveredEdge&&r.emit("leaveEdge",Q(Q({},a),{},{edge:r.hoveredEdge})),l&&r.emit("enterEdge",Q(Q({},a),{},{edge:l})),r.hoveredEdge=l)}},this.activeListeners.handleMoveBody=function(o){var s=ii(o);r.emit("moveBody",{event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var s=ii(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",Q(Q({},a),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",Q(Q({},a),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",Q({},a))},this.activeListeners.handleEnter=function(o){var s=ii(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};r.emit("enterStage",Q({},a))};var i=function(s){return function(a){var u=ii(a),c={event:u,preventSigmaDefault:function(){u.preventSigmaDefault()}},l=r.getNodeAtPosition(u);if(l)return r.emit("".concat(s,"Node"),Q(Q({},c),{},{node:l}));if(r.settings.enableEdgeEvents){var d=r.getEdgeAtPoint(u.x,u.y);if(d)return r.emit("".concat(s,"Edge"),Q(Q({},c),{},{edge:d}))}return r.emit("".concat(s,"Stage"),c)}};return this.activeListeners.handleClick=i("click"),this.activeListeners.handleRightClick=i("rightClick"),this.activeListeners.handleDoubleClick=i("doubleClick"),this.activeListeners.handleWheel=i("wheel"),this.activeListeners.handleDown=i("down"),this.activeListeners.handleUp=i("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var r=this,i=this.graph,o=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(s){var a,u=(a=s.hints)===null||a===void 0?void 0:a.attributes;r.graph.forEachNode(function(l){return r.updateNode(l)});var c=!u||u.some(function(l){return o.has(l)});r.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!c,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(s){var a,u=(a=s.hints)===null||a===void 0?void 0:a.attributes;r.graph.forEachEdge(function(l){return r.updateEdge(l)});var c=u&&["zIndex","type"].some(function(l){return u?.includes(l)});r.refresh({partialGraph:{edges:i.edges()},skipIndexation:!c,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(s){var a=s.key;r.addNode(a),r.refresh({partialGraph:{nodes:[a]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(s){var a=s.key;r.refresh({partialGraph:{nodes:[a]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(s){var a=s.key;r.removeNode(a),r.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(s){var a=s.key;r.addEdge(a),r.refresh({partialGraph:{edges:[a]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(s){var a=s.key;r.refresh({partialGraph:{edges:[a]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(s){var a=s.key;r.removeEdge(a),r.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){r.clearEdgeState(),r.clearEdgeIndices(),r.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){r.clearEdgeState(),r.clearNodeState(),r.clearEdgeIndices(),r.clearNodeIndices(),r.refresh({schedule:!0})},i.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var r=this.graph;r.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),r.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),r.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),r.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),r.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),r.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),r.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),r.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),r.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),r.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(r,i){var o=om(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),s=im.apply(void 0,km(o)),a=this.itemIDsIndex[s];return a&&a.type==="edge"?a.id:null}},{key:"process",value:function(){var r=this;this.emit("beforeProcess");var i=this.graph,o=this.settings,s=this.getDimensions();if(this.nodeExtent=ER(this.graph),!this.settings.autoRescale){var a=s.width,u=s.height,c=this.nodeExtent,l=c.x,d=c.y;this.nodeExtent={x:[(l[0]+l[1])/2-a/2,(l[0]+l[1])/2+a/2],y:[(d[0]+d[1])/2-u/2,(d[0]+d[1])/2+u/2]}}this.normalizationFunction=bm(this.customBBox||this.nodeExtent);var f=new _m,h=ri(f.getState(),s,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(s,o.labelGridCellSize);for(var p={},m={},y={},b={},g=1,w=i.nodes(),v=0,_=w.length;v<_;v++){var k=w[v],x=this.nodeDataCache[k],N=i.getNodeAttributes(k);x.x=N.x,x.y=N.y,this.normalizationFunction.applyTo(x),typeof x.label=="string"&&!x.hidden&&this.labelGrid.add(k,x.size,this.framedGraphToViewport(x,{matrix:h})),p[x.type]=(p[x.type]||0)+1}this.labelGrid.organize();for(var M in this.nodePrograms){if(!on.call(this.nodePrograms,M))throw new Error('Sigma: could not find a suitable program for node type "'.concat(M,'"!'));this.nodePrograms[M].reallocate(p[M]||0),p[M]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(w=vm(this.nodeZExtent,function(ie){return r.nodeDataCache[ie].zIndex},w));for(var F=0,B=w.length;F<B;F++){var ee=w[F];m[ee]=g,b[m[ee]]={type:"node",id:ee},g++;var ce=this.nodeDataCache[ee];this.addNodeToProgram(ee,m[ee],p[ce.type]++)}for(var me={},$e=i.edges(),U=0,H=$e.length;U<H;U++){var K=$e[U],de=this.edgeDataCache[K];me[de.type]=(me[de.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&($e=vm(this.edgeZExtent,function(ie){return r.edgeDataCache[ie].zIndex},$e));for(var te in this.edgePrograms){if(!on.call(this.edgePrograms,te))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(te,'"!'));this.edgePrograms[te].reallocate(me[te]||0),me[te]=0}for(var I=0,z=$e.length;I<z;I++){var G=$e[I];y[G]=g,b[y[G]]={type:"edge",id:G},g++;var fe=this.edgeDataCache[G];this.addEdgeToProgram(G,y[G],me[fe.type]++)}return this.itemIDsIndex=b,this.nodeIndices=m,this.edgeIndices=y,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(r){var i=this,o=this.settings;if(this.camera.minRatio=o.minCameraRatio,this.camera.maxRatio=o.maxCameraRatio,this.camera.enabledZooming=o.enableCameraZooming,this.camera.enabledPanning=o.enableCameraPanning,this.camera.enabledRotation=o.enableCameraRotation,o.cameraPanBoundaries?this.camera.clean=function(l){return i.cleanCameraState(l,o.cameraPanBoundaries&&Sc(o.cameraPanBoundaries)==="object"?o.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),r){if(r.edgeProgramClasses!==o.edgeProgramClasses){for(var s in o.edgeProgramClasses)o.edgeProgramClasses[s]!==r.edgeProgramClasses[s]&&this.registerEdgeProgram(s,o.edgeProgramClasses[s]);for(var a in r.edgeProgramClasses)o.edgeProgramClasses[a]||this.unregisterEdgeProgram(a)}if(r.nodeProgramClasses!==o.nodeProgramClasses||r.nodeHoverProgramClasses!==o.nodeHoverProgramClasses){for(var u in o.nodeProgramClasses)(o.nodeProgramClasses[u]!==r.nodeProgramClasses[u]||o.nodeHoverProgramClasses[u]!==r.nodeHoverProgramClasses[u])&&this.registerNodeProgram(u,o.nodeProgramClasses[u],o.nodeHoverProgramClasses[u]);for(var c in r.nodeProgramClasses)o.nodeProgramClasses[c]||this.unregisterNodeProgram(c)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i.tolerance,s=o===void 0?0:o,a=i.boundaries,u=Q({},r),c=a||this.nodeExtent,l=xr(c.x,2),d=l[0],f=l[1],h=xr(c.y,2),p=h[0],m=h[1],y=[this.graphToViewport({x:d,y:p},{cameraState:r}),this.graphToViewport({x:f,y:p},{cameraState:r}),this.graphToViewport({x:d,y:m},{cameraState:r}),this.graphToViewport({x:f,y:m},{cameraState:r})],b=1/0,g=-1/0,w=1/0,v=-1/0;y.forEach(function(me){var $e=me.x,U=me.y;b=Math.min(b,$e),g=Math.max(g,$e),w=Math.min(w,U),v=Math.max(v,U)});var _=g-b,k=v-w,x=this.getDimensions(),N=x.width,M=x.height,F=0,B=0;if(_>=N?g<N-s?F=g-(N-s):b>s&&(F=b-s):g>N+s?F=g-(N+s):b<-s&&(F=b+s),k>=M?v<M-s?B=v-(M-s):w>s&&(B=w-s):v>M+s?B=v-(M+s):w<-s&&(B=w+s),F||B){var ee=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),ce=this.viewportToFramedGraph({x:F,y:B},{cameraState:r});F=ce.x-ee.x,B=ce.y-ee.y,u.x+=F,u.y+=B}return u}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var r=this.camera.getState(),i=this.labelGrid.getLabelsToDisplay(r.ratio,this.settings.labelDensity);wm(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,s=0,a=i.length;s<a;s++){var u=i[s],c=this.nodeDataCache[u];if(!this.displayedNodeLabels.has(u)&&!c.hidden){var l=this.framedGraphToViewport(c),d=l.x,f=l.y,h=this.scaleSize(c.size);if(!(!c.forceLabel&&h<this.settings.labelRenderedSizeThreshold)&&!(d<-Em||d>this.width+Em||f<-$m||f>this.height+$m)){this.displayedNodeLabels.add(u);var p=this.settings.defaultDrawNodeLabel,m=this.nodePrograms[c.type],y=m?.drawLabel||p;y(o,Q(Q({key:u},c),{},{size:h,x:d,y:f}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var r=this.canvasContexts.edgeLabels;r.clearRect(0,0,this.width,this.height);var i=ZR({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});wm(i,this.edgesWithForcedLabels);for(var o=new Set,s=0,a=i.length;s<a;s++){var u=i[s],c=this.graph.extremities(u),l=this.nodeDataCache[c[0]],d=this.nodeDataCache[c[1]],f=this.edgeDataCache[u];if(!o.has(u)&&!(f.hidden||l.hidden||d.hidden)){var h=this.settings.defaultDrawEdgeLabel,p=this.edgePrograms[f.type],m=p?.drawLabel||h;m(r,Q(Q({key:u},f),{},{size:this.scaleSize(f.size)}),Q(Q(Q({key:c[0]},l),this.framedGraphToViewport(l)),{},{size:this.scaleSize(l.size)}),Q(Q(Q({key:c[1]},d),this.framedGraphToViewport(d)),{},{size:this.scaleSize(d.size)}),this.settings),o.add(u)}}return this.displayedEdgeLabels=o,this}},{key:"renderHighlightedNodes",value:function(){var r=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var o=function(h){var p=r.nodeDataCache[h],m=r.framedGraphToViewport(p),y=m.x,b=m.y,g=r.scaleSize(p.size),w=r.settings.defaultDrawNodeHover,v=r.nodePrograms[p.type],_=v?.drawHover||w;_(i,Q(Q({key:h},p),{},{size:g,x:y,y:b}),r.settings)},s=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&s.push(this.hoveredNode),this.highlightedNodes.forEach(function(f){f!==r.hoveredNode&&s.push(f)}),s.forEach(function(f){return o(f)});var a={};s.forEach(function(f){var h=r.nodeDataCache[f].type;a[h]=(a[h]||0)+1});for(var u in this.nodeHoverPrograms)this.nodeHoverPrograms[u].reallocate(a[u]||0),a[u]=0;s.forEach(function(f){var h=r.nodeDataCache[f];r.nodeHoverPrograms[h.type].process(0,a[h.type]++,h)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var c=this.getRenderParams();for(var l in this.nodeHoverPrograms){var d=this.nodeHoverPrograms[l];d.render(c)}}},{key:"scheduleHighlightedNodesRender",value:function(){var r=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){r.renderHighlightedNodesFrame=null,r.renderHighlightedNodes(),r.renderEdgeLabels()}))}},{key:"render",value:function(){var r=this;this.emit("beforeRender");var i=function(){return r.emit("afterRender"),r};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(y){return r.resetWebGLTexture(y)}),!this.graph.order)return i();var o=this.mouseCaptor,s=this.camera.isAnimated()||o.isMoving||o.draggedEvents||o.currentWheelDirection,a=this.camera.getState(),u=this.getDimensions(),c=this.getGraphDimensions(),l=this.getStagePadding();this.matrix=ri(a,u,c,l),this.invMatrix=ri(a,u,c,l,!0),this.correctionRatio=xR(this.matrix,a,u),this.graphToViewportRatio=this.getGraphToViewportRatio();var d=this.getRenderParams();for(var f in this.nodePrograms){var h=this.nodePrograms[f];h.render(d)}if(!this.settings.hideEdgesOnMove||!s)for(var p in this.edgePrograms){var m=this.edgePrograms[p];m.render(d)}return this.settings.hideLabelsOnMove&&s||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),i()}},{key:"addNode",value:function(r){var i=Object.assign({},this.graph.getNodeAttributes(r));this.settings.nodeReducer&&(i=this.settings.nodeReducer(r,i));var o=BR(this.settings,r,i);this.nodeDataCache[r]=o,this.nodesWithForcedLabels.delete(r),o.forceLabel&&!o.hidden&&this.nodesWithForcedLabels.add(r),this.highlightedNodes.delete(r),o.highlighted&&!o.hidden&&this.highlightedNodes.add(r),this.settings.zIndex&&(o.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=o.zIndex),o.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=o.zIndex))}},{key:"updateNode",value:function(r){this.addNode(r);var i=this.nodeDataCache[r];this.normalizationFunction.applyTo(i)}},{key:"removeNode",value:function(r){delete this.nodeDataCache[r],delete this.nodeProgramIndex[r],this.highlightedNodes.delete(r),this.hoveredNode===r&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(r)}},{key:"addEdge",value:function(r){var i=Object.assign({},this.graph.getEdgeAttributes(r));this.settings.edgeReducer&&(i=this.settings.edgeReducer(r,i));var o=HR(this.settings,r,i);this.edgeDataCache[r]=o,this.edgesWithForcedLabels.delete(r),o.forceLabel&&!o.hidden&&this.edgesWithForcedLabels.add(r),this.settings.zIndex&&(o.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=o.zIndex),o.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=o.zIndex))}},{key:"updateEdge",value:function(r){this.addEdge(r)}},{key:"removeEdge",value:function(r){delete this.edgeDataCache[r],delete this.edgeProgramIndex[r],this.hoveredEdge===r&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(r)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new xm,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(r,i,o){var s=this.nodeDataCache[r],a=this.nodePrograms[s.type];if(!a)throw new Error('Sigma: could not find a suitable program for node type "'.concat(s.type,'"!'));a.process(i,o,s),this.nodeProgramIndex[r]=o}},{key:"addEdgeToProgram",value:function(r,i,o){var s=this.edgeDataCache[r],a=this.edgePrograms[s.type];if(!a)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(s.type,'"!'));var u=this.graph.extremities(r),c=this.nodeDataCache[u[0]],l=this.nodeDataCache[u[1]];a.process(i,o,c,l,s),this.edgeProgramIndex[r]=o}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var r=this.settings,i=r.stagePadding,o=r.autoRescale;return o&&i||0}},{key:"createLayer",value:function(r,i){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[r])throw new Error('Sigma: a layer named "'.concat(r,'" already exists'));var s=TR(i,{position:"absolute"},{class:"sigma-".concat(r)});return o.style&&Object.assign(s.style,o.style),this.elements[r]=s,"beforeLayer"in o&&o.beforeLayer?this.elements[o.beforeLayer].before(s):"afterLayer"in o&&o.afterLayer?this.elements[o.afterLayer].after(s):this.container.appendChild(s),s}},{key:"createCanvas",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(r,"canvas",i)}},{key:"createCanvasContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.createCanvas(r,i),s={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[r]=o.getContext("2d",s),this}},{key:"createWebGLContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i?.canvas||this.createCanvas(r,i);i.hidden&&o.remove();var s=Q({preserveDrawingBuffer:!1,antialias:!1},i),a;a=o.getContext("webgl2",s),a||(a=o.getContext("webgl",s)),a||(a=o.getContext("experimental-webgl",s));var u=a;if(this.webGLContexts[r]=u,u.blendFunc(u.ONE,u.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(r);var c=u.createFramebuffer();if(!c)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(r));this.frameBuffers[r]=c}return u}},{key:"killLayer",value:function(r){var i=this.elements[r];if(!i)throw new Error("Sigma: cannot kill layer ".concat(r,", which does not exist"));if(this.webGLContexts[r]){var o,s=this.webGLContexts[r];(o=s.getExtension("WEBGL_lose_context"))===null||o===void 0||o.loseContext(),delete this.webGLContexts[r]}else this.canvasContexts[r]&&delete this.canvasContexts[r];return i.remove(),delete this.elements[r],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(r){this.unbindCameraHandlers(),this.camera=r,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(r){r!==this.graph&&(this.hoveredNode&&!r.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!r.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=r,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var r=this.customBBox||this.nodeExtent;return{width:r.x[1]-r.x[0]||1,height:r.y[1]-r.y[0]||1}}},{key:"getNodeDisplayData",value:function(r){var i=this.nodeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getEdgeDisplayData",value:function(r){var i=this.edgeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return Q({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=Q({},this.settings);return this.settings[r]=i,Mu(this.settings),this.handleSettingsUpdate(o),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(r,i){return this.setSetting(r,i(this.settings[r])),this}},{key:"setSettings",value:function(r){var i=Q({},this.settings);return this.settings=Q(Q({},this.settings),r),Mu(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(r){var i=this.width,o=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=ym(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!r&&i===this.width&&o===this.height)return this;for(var s in this.elements){var a=this.elements[s];a.style.width=this.width+"px",a.style.height=this.height+"px"}for(var u in this.canvasContexts)this.elements[u].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[u].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[u].scale(this.pixelRatio,this.pixelRatio);for(var c in this.webGLContexts){this.elements[c].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[c].setAttribute("height",this.height*this.pixelRatio+"px");var l=this.webGLContexts[c];if(l.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(c)){var d=this.textures[c];d&&l.deleteTexture(d)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(r){var i=this,o=r?.skipIndexation!==void 0?r?.skipIndexation:!1,s=r?.schedule!==void 0?r.schedule:!1,a=!r||!r.partialGraph;if(a)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(v){return i.addNode(v)}),this.graph.forEachEdge(function(v){return i.addEdge(v)});else{for(var u,c,l=((u=r.partialGraph)===null||u===void 0?void 0:u.nodes)||[],d=0,f=l?.length||0;d<f;d++){var h=l[d];if(this.updateNode(h),o){var p=this.nodeProgramIndex[h];if(p===void 0)throw new Error('Sigma: node "'.concat(h,`" can't be repaint`));this.addNodeToProgram(h,this.nodeIndices[h],p)}}for(var m=(r==null||(c=r.partialGraph)===null||c===void 0?void 0:c.edges)||[],y=0,b=m.length;y<b;y++){var g=m[y];if(this.updateEdge(g),o){var w=this.edgeProgramIndex[g];if(w===void 0)throw new Error('Sigma: edge "'.concat(g,`" can't be repaint`));this.addEdgeToProgram(g,this.edgeIndices[g],w)}}}return(a||!o)&&(this.needToProcess=!0),s?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var r=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){r.render()})),this}},{key:"scheduleRefresh",value:function(r){return this.refresh(Q(Q({},r),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(r,i){var o=this.camera.getState(),s=o.ratio,a=o.angle,u=o.x,c=o.y,l=this.settings,d=l.minCameraRatio,f=l.maxCameraRatio;typeof f=="number"&&(i=Math.min(i,f)),typeof d=="number"&&(i=Math.max(i,d));var h=i/s,p={x:this.width/2,y:this.height/2},m=this.viewportToFramedGraph(r),y=this.viewportToFramedGraph(p);return{angle:a,x:(m.x-y.x)*(1-h)+u,y:(m.y-y.y)*(1-h)+c,ratio:i}}},{key:"viewRectangle",value:function(){var r=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),o=this.viewportToFramedGraph({x:0,y:this.height});return{x1:r.x,y1:r.y,x2:i.x,y2:i.y,height:i.y-o.y}}},{key:"framedGraphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,s=i.matrix?i.matrix:o?ri(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,a=kc(s,r);return{x:(1+a.x)*this.width/2,y:(1-a.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,s=i.matrix?i.matrix:o?ri(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,a=kc(s,{x:r.x/this.width*2-1,y:1-r.y/this.height*2});return isNaN(a.x)&&(a.x=0),isNaN(a.y)&&(a.y=0),a}},{key:"viewportToGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(r,i))}},{key:"graphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(r),i)}},{key:"getGraphToViewportRatio",value:function(){var r={x:0,y:0},i={x:1,y:1},o=Math.sqrt(Math.pow(r.x-i.x,2)+Math.pow(r.y-i.y,2)),s=this.graphToViewport(r),a=this.graphToViewport(i),u=Math.sqrt(Math.pow(s.x-a.x,2)+Math.pow(s.y-a.y,2));return u/o}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(r){return this.customBBox=r,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var r=this.container;r.firstChild;)r.removeChild(r.firstChild);for(var i in this.nodePrograms)this.nodePrograms[i].kill();for(var o in this.nodeHoverPrograms)this.nodeHoverPrograms[o].kill();for(var s in this.edgePrograms)this.edgePrograms[s].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var a in this.elements)this.killLayer(a);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return r/this.settings.zoomToSizeRatioFunction(i)*(this.getSetting("itemSizesReference")==="positions"?i*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var r={};for(var i in this.elements)this.elements[i]instanceof HTMLCanvasElement&&(r[i]=this.elements[i]);return r}}])})(gh),qR=VR;function WR(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 pk(e){var t=WR(e,"string");return typeof t=="symbol"?t:t+""}function mk(e,t,n){return(t=pk(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Tm(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 Cs(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Tm(Object(n),!0).forEach(function(r){mk(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Tm(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function KR(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function JR(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,pk(r.key),r)}}function YR(e,t,n){return t&&JR(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function As(e){return As=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},As(e)}function gk(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(gk=function(){return!!e})()}function yk(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function XR(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 yk(e)}function QR(e,t,n){return t=As(t),XR(e,gk()?Reflect.construct(t,n||[],As(e).constructor):t.apply(e,n))}function xc(e,t){return xc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},xc(e,t)}function eL(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&&xc(e,t)}function Ec(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 tL(e){if(Array.isArray(e))return Ec(e)}function nL(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function rL(e,t){if(e){if(typeof e=="string")return Ec(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)?Ec(e,t):void 0}}function iL(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
423
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Uu(e){return tL(e)||nL(e)||rL(e)||iL()}function vk(e,t,n,r){var i=Math.pow(1-e,2)*t.x+2*(1-e)*e*n.x+Math.pow(e,2)*r.x,o=Math.pow(1-e,2)*t.y+2*(1-e)*e*n.y+Math.pow(e,2)*r.y;return{x:i,y:o}}function oL(e,t,n){for(var r=20,i=0,o=e,s=0;s<r;s++){var a=vk((s+1)/r,e,t,n);i+=Math.sqrt(Math.pow(o.x-a.x,2)+Math.pow(o.y-a.y,2)),o=a}return i}function sL(e){var t=e.curvatureAttribute,n=e.defaultCurvature,r=e.keepLabelUpright,i=r===void 0?!0:r;return function(o,s,a,u,c){var l=c.edgeLabelSize,d=s[t]||n,f=c.edgeLabelFont,h=c.edgeLabelWeight,p=c.edgeLabelColor.attribute?s[c.edgeLabelColor.attribute]||c.edgeLabelColor.color||"#000":c.edgeLabelColor.color,m=s.label;if(m){o.fillStyle=p,o.font="".concat(h," ").concat(l,"px ").concat(f);var y=!i||a.x<u.x,b=y?a.x:u.x,g=y?a.y:u.y,w=y?u.x:a.x,v=y?u.y:a.y,_=(b+w)/2,k=(g+v)/2,x=w-b,N=v-g,M=Math.sqrt(Math.pow(x,2)+Math.pow(N,2)),F=y?1:-1,B=_+N*d*F,ee=k-x*d*F,ce=s.size*.7+5,me={x:ee-g,y:-(B-b)},$e=Math.sqrt(Math.pow(me.x,2)+Math.pow(me.y,2)),U={x:v-ee,y:-(w-B)},H=Math.sqrt(Math.pow(U.x,2)+Math.pow(U.y,2));b+=ce*me.x/$e,g+=ce*me.y/$e,w+=ce*U.x/H,v+=ce*U.y/H,B+=ce*N/M,ee-=ce*x/M;var K={x:B,y:ee},de={x:b,y:g},te={x:w,y:v},I=oL(de,K,te);if(!(I<a.size+u.size)){var z=o.measureText(m).width,G=I-a.size-u.size;if(z>G){var fe="…";for(m=m+fe,z=o.measureText(m).width;z>G&&m.length>1;)m=m.slice(0,-2)+fe,z=o.measureText(m).width;if(m.length<4)return}for(var ie={},Y=0,oe=m.length;Y<oe;Y++){var he=m[Y];ie[he]||(ie[he]=o.measureText(he).width*(1+d*.35))}for(var Ae=.5-z/I/2,O=0,j=m.length;O<j;O++){var q=m[O],J=vk(Ae,de,K,te),Te=2*(1-Ae)*(B-b)+2*Ae*(w-B),se=2*(1-Ae)*(ee-g)+2*Ae*(v-ee),ye=Math.atan2(se,Te);o.save(),o.translate(J.x,J.y),o.rotate(ye),o.fillText(q,0,0),o.restore(),Ae+=ie[q]/I}}}}}function aL(e){var t=e.arrowHead,n=t?.extremity==="target"||t?.extremity==="both",r=t?.extremity==="source"||t?.extremity==="both",i=`
421
+ `,SR=kR,_k=WebGLRenderingContext,_m=_k.UNSIGNED_BYTE,ii=_k.FLOAT,xR=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],ER=(function(e){function t(){return gt(this,t),Bt(this,t,arguments)}return Ht(t,e),yt(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:SR,FRAGMENT_SHADER_SOURCE:yk,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:xR,ATTRIBUTES:[{name:"a_positionStart",size:2,type:ii},{name:"a_positionEnd",size:2,type:ii},{name:"a_normal",size:2,type:ii},{name:"a_color",size:4,type:_m,normalized:!0},{name:"a_id",size:4,type:_m,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:ii},{name:"a_normalCoef",size:1,type:ii}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(r,i,o,s,a){var u=a.size||1,c=o.x,l=o.y,d=s.x,h=s.y,f=On(a.color),p=d-c,m=h-l,y=p*p+m*m,b=0,g=0;y&&(y=1/Math.sqrt(y),b=-m*y*u,g=p*y*u);var _=this.array;_[i++]=c,_[i++]=l,_[i++]=d,_[i++]=h,_[i++]=b,_[i++]=g,_[i++]=f,_[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,s=i.uniformLocations,a=s.u_matrix,u=s.u_zoomRatio,c=s.u_feather,l=s.u_pixelRatio,d=s.u_correctionRatio,h=s.u_sizeRatio,f=s.u_minEdgeThickness;o.uniformMatrix3fv(a,!1,r.matrix),o.uniform1f(u,r.zoomRatio),o.uniform1f(h,r.sizeRatio),o.uniform1f(d,r.correctionRatio),o.uniform1f(l,r.pixelRatio),o.uniform1f(c,r.antiAliasingFeather),o.uniform1f(f,r.minEdgeThickness)}}])})(du),Eh=(function(e){function t(){var n;return gt(this,t),n=Bt(this,t),n.rawEmitter=n,n}return Ht(t,e),yt(t)})(G_.EventEmitter),ju,km;function $R(){return km||(km=1,ju=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}),ju}var TR=$R();const CR=zI(TR);var AR=function(t){return t},IR=function(t){return t*t},NR=function(t){return t*(2-t)},RR=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},LR=function(t){return t*t*t},zR=function(t){return--t*t*t+1},DR=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},OR={linear:AR,quadraticIn:IR,quadraticOut:NR,quadraticInOut:RR,cubicIn:LR,cubicOut:zR,cubicInOut:DR},PR={easing:"quadraticInOut",duration:150};function Yt(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function us(e,t,n){return e[0]=t,e[4]=typeof n=="number"?n:t,e}function Sm(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[3]=-n,e[4]=r,e}function xm(e,t,n){return e[6]=t,e[7]=n,e}function wn(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],s=e[4],a=e[5],u=e[6],c=e[7],l=e[8],d=t[0],h=t[1],f=t[2],p=t[3],m=t[4],y=t[5],b=t[6],g=t[7],_=t[8];return e[0]=d*n+h*o+f*u,e[1]=d*r+h*s+f*c,e[2]=d*i+h*a+f*l,e[3]=p*n+m*o+y*u,e[4]=p*r+m*s+y*c,e[5]=p*i+m*a+y*l,e[6]=b*n+g*o+_*u,e[7]=b*r+g*s+_*c,e[8]=b*i+g*a+_*l,e}function Ac(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=e[0],i=e[1],o=e[3],s=e[4],a=e[6],u=e[7],c=t.x,l=t.y;return{x:c*r+l*o+a*n,y:c*i+l*s+u*n}}function MR(e,t){var n=e.height/e.width,r=t.height/t.width;return n<1&&r>1||n>1&&r<1?1:Math.min(Math.max(r,1/r),Math.max(1/n,n))}function oi(e,t,n,r,i){var o=e.angle,s=e.ratio,a=e.x,u=e.y,c=t.width,l=t.height,d=Yt(),h=Math.min(c,l)-2*r,f=MR(t,n);return i?(wn(d,xm(Yt(),a,u)),wn(d,us(Yt(),s)),wn(d,Sm(Yt(),o)),wn(d,us(Yt(),c/h/2/f,l/h/2/f))):(wn(d,us(Yt(),2*(h/c)*f,2*(h/l)*f)),wn(d,Sm(Yt(),-o)),wn(d,us(Yt(),1/s)),wn(d,xm(Yt(),-a,-u))),d}function FR(e,t,n){var r=Ac(e,{x:Math.cos(t.angle),y:Math.sin(t.angle)},0),i=r.x,o=r.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(o,2))/n.width}function UR(e){if(!e.order)return{x:[0,1],y:[0,1]};var t=1/0,n=-1/0,r=1/0,i=-1/0;return e.forEachNode(function(o,s){var a=s.x,u=s.y;a<t&&(t=a),a>n&&(n=a),u<r&&(r=u),u>i&&(i=u)}),{x:[t,n],y:[r,i]}}function GR(e){if(!CR(e))throw new Error("Sigma: invalid graph instance.");e.forEachNode(function(t,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y))throw new Error("Sigma: Coordinates of node ".concat(t," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function jR(e,t,n){var r=document.createElement(e);if(t)for(var i in t)r.style[i]=t[i];if(n)for(var o in n)r.setAttribute(o,n[o]);return r}function Em(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function $m(e,t,n){return n.sort(function(r,i){var o=t(r)||0,s=t(i)||0;return o<s?-1:o>s?1:0})}function Tm(e){var t=Er(e.x,2),n=t[0],r=t[1],i=Er(e.y,2),o=i[0],s=i[1],a=Math.max(r-n,s-o),u=(r+n)/2,c=(s+o)/2;(a===0||Math.abs(a)===1/0||isNaN(a))&&(a=1),isNaN(u)&&(u=0),isNaN(c)&&(c=0);var l=function(h){return{x:.5+(h.x-u)/a,y:.5+(h.y-c)/a}};return l.applyTo=function(d){d.x=.5+(d.x-u)/a,d.y=.5+(d.y-c)/a},l.inverse=function(d){return{x:u+a*(d.x-.5),y:c+a*(d.y-.5)}},l.ratio=a,l}function Ic(e){"@babel/helpers - typeof";return Ic=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ic(e)}function Cm(e,t){var n=t.size;if(n!==0){var r=e.length;e.length+=n;var i=0;t.forEach(function(o){e[r+i]=o,i++})}}function Zu(e){e=e||{};for(var t=0,n=arguments.length<=1?0:arguments.length-1;t<n;t++){var r=t+1<1||arguments.length<=t+1?void 0:arguments[t+1];r&&Object.assign(e,r)}return e}var $h={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:"#999",defaultNodeType:"circle",defaultEdgeColor:"#ccc",defaultEdgeType:"line",labelFont:"Arial",labelSize:14,labelWeight:"normal",labelColor:{color:"#000"},edgeLabelFont:"Arial",edgeLabelSize:14,edgeLabelWeight:"normal",edgeLabelColor:{attribute:"color"},stagePadding:30,defaultDrawEdgeLabel:fk,defaultDrawNodeLabel:hk,defaultDrawNodeHover:iR,minEdgeThickness:1.7,antiAliasingFeather:1,dragTimeout:100,draggedEventsTolerance:3,inertiaDuration:200,inertiaRatio:3,zoomDuration:250,zoomingRatio:1.7,doubleClickTimeout:300,doubleClickZoomingRatio:2.2,doubleClickZoomingDuration:200,tapMoveTolerance:10,zoomToSizeRatioFunction:Math.sqrt,itemSizesReference:"screen",autoRescale:!0,autoCenter:!0,labelDensity:1,labelGridCellSize:100,labelRenderedSizeThreshold:6,nodeReducer:null,edgeReducer:null,zIndex:!1,minCameraRatio:null,maxCameraRatio:null,enableCameraZooming:!0,enableCameraPanning:!0,enableCameraRotation:!0,cameraPanBoundaries:null,allowInvalidContainer:!1,nodeProgramClasses:{},nodeHoverProgramClasses:{},edgeProgramClasses:{}},ZR={circle:fu},BR={arrow:_R,line:ER};function Bu(e){if(typeof e.labelDensity!="number"||e.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var t=e.minCameraRatio,n=e.maxCameraRatio;if(typeof t=="number"&&typeof n=="number"&&n<t)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function HR(e){var t=Zu({},$h,e);return t.nodeProgramClasses=Zu({},ZR,t.nodeProgramClasses),t.edgeProgramClasses=Zu({},BR,t.edgeProgramClasses),t}var cs=1.5,Am=(function(e){function t(){var n;return gt(this,t),n=Bt(this,t),P(n,"x",.5),P(n,"y",.5),P(n,"angle",0),P(n,"ratio",1),P(n,"minRatio",null),P(n,"maxRatio",null),P(n,"enabledZooming",!0),P(n,"enabledPanning",!0),P(n,"enabledRotation",!0),P(n,"clean",null),P(n,"nextFrame",null),P(n,"previousState",null),P(n,"enabled",!0),n.previousState=n.getState(),n}return Ht(t,e),yt(t,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(r){return this.x===r.x&&this.y===r.y&&this.ratio===r.ratio&&this.angle===r.angle}},{key:"getPreviousState",value:function(){var r=this.previousState;return r?{x:r.x,y:r.y,angle:r.angle,ratio:r.ratio}:null}},{key:"getBoundedRatio",value:function(r){var i=r;return typeof this.minRatio=="number"&&(i=Math.max(i,this.minRatio)),typeof this.maxRatio=="number"&&(i=Math.min(i,this.maxRatio)),i}},{key:"validateState",value:function(r){var i={};return this.enabledPanning&&typeof r.x=="number"&&(i.x=r.x),this.enabledPanning&&typeof r.y=="number"&&(i.y=r.y),this.enabledZooming&&typeof r.ratio=="number"&&(i.ratio=this.getBoundedRatio(r.ratio)),this.enabledRotation&&typeof r.angle=="number"&&(i.angle=r.angle),this.clean?this.clean(ee(ee({},this.getState()),i)):i}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(r){if(!this.enabled)return this;this.previousState=this.getState();var i=this.validateState(r);return typeof i.x=="number"&&(this.x=i.x),typeof i.y=="number"&&(this.y=i.y),typeof i.ratio=="number"&&(this.ratio=i.ratio),typeof i.angle=="number"&&(this.angle=i.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(r){return this.setState(r(this.getState())),this}},{key:"animate",value:function(r){var i=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;if(!s)return new Promise(function(f){return i.animate(r,o,f)});if(this.enabled){var a=ee(ee({},PR),o),u=this.validateState(r),c=typeof a.easing=="function"?a.easing:OR[a.easing],l=Date.now(),d=this.getState(),h=function(){var p=(Date.now()-l)/a.duration;if(p>=1){i.nextFrame=null,i.setState(u),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var m=c(p),y={};typeof u.x=="number"&&(y.x=d.x+(u.x-d.x)*m),typeof u.y=="number"&&(y.y=d.y+(u.y-d.y)*m),i.enabledRotation&&typeof u.angle=="number"&&(y.angle=d.angle+(u.angle-d.angle)*m),typeof u.ratio=="number"&&(y.ratio=d.ratio+(u.ratio-d.ratio)*m),i.setState(y),i.nextFrame=requestAnimationFrame(h)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(h)):h(),this.animationCallback=s}}},{key:"animatedZoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio/r}):this.animate({ratio:this.ratio/(r.factor||cs)},r):this.animate({ratio:this.ratio/cs})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||cs)},r):this.animate({ratio:this.ratio*cs})}},{key:"animatedReset",value:function(r){return this.animate({x:.5,y:.5,ratio:1,angle:0},r)}},{key:"copy",value:function(){return t.from(this.getState())}}],[{key:"from",value:function(r){var i=new t;return i.setState(r)}}])})(Eh);function Qt(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function sn(e,t){var n=ee(ee({},Qt(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function si(e){var t="x"in e?e:ee(ee({},e.touches[0]||e.previousTouches[0]),{},{original:e.original,sigmaDefaultPrevented:e.sigmaDefaultPrevented,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0,t.sigmaDefaultPrevented=!0}});return t}function VR(e,t){return ee(ee({},sn(e,t)),{},{delta:kk(e)})}var qR=2;function ys(e){for(var t=[],n=0,r=Math.min(e.length,qR);n<r;n++)t.push(e[n]);return t}function ai(e,t,n){var r={touches:ys(e.touches).map(function(i){return Qt(i,n)}),previousTouches:t.map(function(i){return Qt(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:e};return r}function kk(e){if(typeof e.deltaY<"u")return e.deltaY*-3/360;if(typeof e.detail<"u")return e.detail/-9;throw new Error("Captor: could not extract delta from event.")}var Sk=(function(e){function t(n,r){var i;return gt(this,t),i=Bt(this,t),i.container=n,i.renderer=r,i}return Ht(t,e),yt(t)})(Eh),WR=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],KR=WR.reduce(function(e,t){return ee(ee({},e),{},P({},t,$h[t]))},{}),JR=(function(e){function t(n,r){var i;return gt(this,t),i=Bt(this,t,[n,r]),P(i,"enabled",!0),P(i,"draggedEvents",0),P(i,"downStartTime",null),P(i,"lastMouseX",null),P(i,"lastMouseY",null),P(i,"isMouseDown",!1),P(i,"isMoving",!1),P(i,"movingTimeout",null),P(i,"startCameraState",null),P(i,"clicks",0),P(i,"doubleClickTimeout",null),P(i,"currentWheelDirection",0),P(i,"settings",KR),i.handleClick=i.handleClick.bind(i),i.handleRightClick=i.handleRightClick.bind(i),i.handleDown=i.handleDown.bind(i),i.handleUp=i.handleUp.bind(i),i.handleMove=i.handleMove.bind(i),i.handleWheel=i.handleWheel.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleEnter=i.handleEnter.bind(i),n.addEventListener("click",i.handleClick,{capture:!1}),n.addEventListener("contextmenu",i.handleRightClick,{capture:!1}),n.addEventListener("mousedown",i.handleDown,{capture:!1}),n.addEventListener("wheel",i.handleWheel,{capture:!1}),n.addEventListener("mouseleave",i.handleLeave,{capture:!1}),n.addEventListener("mouseenter",i.handleEnter,{capture:!1}),document.addEventListener("mousemove",i.handleMove,{capture:!1}),document.addEventListener("mouseup",i.handleUp,{capture:!1}),i}return Ht(t,e),yt(t,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("click",this.handleClick),r.removeEventListener("contextmenu",this.handleRightClick),r.removeEventListener("mousedown",this.handleDown),r.removeEventListener("wheel",this.handleWheel),r.removeEventListener("mouseleave",this.handleLeave),r.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(r){var i=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(r);setTimeout(function(){i.clicks=0,i.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",sn(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",sn(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=sn(r,this.container);if(this.emit("doubleClick",i),!i.sigmaDefaultPrevented){var o=this.renderer.getCamera(),s=o.getBoundedRatio(o.getState().ratio/this.settings.doubleClickZoomingRatio);o.animate(this.renderer.getViewportZoomedState(Qt(r,this.container),s),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(r){if(this.enabled){if(r.button===0){this.startCameraState=this.renderer.getCamera().getState();var i=Qt(r,this.container),o=i.x,s=i.y;this.lastMouseX=o,this.lastMouseY=s,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",sn(r,this.container))}}},{key:"handleUp",value:function(r){var i=this;if(!(!this.enabled||!this.isMouseDown)){var o=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var s=Qt(r,this.container),a=s.x,u=s.y,c=o.getState(),l=o.getPreviousState()||{x:0,y:0};this.isMoving?o.animate({x:c.x+this.settings.inertiaRatio*(c.x-l.x),y:c.y+this.settings.inertiaRatio*(c.y-l.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==a||this.lastMouseY!==u)&&o.setState({x:c.x,y:c.y}),this.isMoving=!1,setTimeout(function(){var d=i.draggedEvents>0;i.draggedEvents=0,d&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",sn(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=sn(r,this.container);if(this.emit("mousemovebody",o),(r.target===this.container||r.composedPath()[0]===this.container)&&this.emit("mousemove",o),!o.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.movingTimeout=null,i.isMoving=!1},this.settings.dragTimeout);var s=this.renderer.getCamera(),a=Qt(r,this.container),u=a.x,c=a.y,l=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),d=this.renderer.viewportToFramedGraph({x:u,y:c}),h=l.x-d.x,f=l.y-d.y,p=s.getState(),m=p.x+h,y=p.y+f;s.setState({x:m,y}),this.lastMouseX=u,this.lastMouseY=c,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",sn(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",sn(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var s=kk(r);if(s){var a=VR(r,this.container);if(this.emit("wheel",a),a.sigmaDefaultPrevented){r.preventDefault(),r.stopPropagation();return}var u=o.getState().ratio,c=s>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,l=o.getBoundedRatio(u*c),d=s>0?1:-1,h=Date.now();u!==l&&(r.preventDefault(),r.stopPropagation(),!(this.currentWheelDirection===d&&this.lastWheelTriggerTime&&h-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(Qt(r,this.container),l),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=d,this.lastWheelTriggerTime=h))}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Sk),YR=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],XR=YR.reduce(function(e,t){return ee(ee({},e),{},P({},t,$h[t]))},{}),QR=(function(e){function t(n,r){var i;return gt(this,t),i=Bt(this,t,[n,r]),P(i,"enabled",!0),P(i,"isMoving",!1),P(i,"hasMoved",!1),P(i,"touchMode",0),P(i,"startTouchesPositions",[]),P(i,"lastTouches",[]),P(i,"lastTap",null),P(i,"settings",XR),i.handleStart=i.handleStart.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleMove=i.handleMove.bind(i),n.addEventListener("touchstart",i.handleStart,{capture:!1}),n.addEventListener("touchcancel",i.handleLeave,{capture:!1}),document.addEventListener("touchend",i.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",i.handleMove,{capture:!1,passive:!1}),i}return Ht(t,e),yt(t,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("touchstart",this.handleStart),r.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(r){var i=this;if(this.enabled){r.preventDefault();var o=ys(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(f){return Qt(f,i.container)}),this.touchMode===2){var s=Er(this.startTouchesPositions,2),a=s[0],u=a.x,c=a.y,l=s[1],d=l.x,h=l.y;this.startTouchesAngle=Math.atan2(h-c,d-u),this.startTouchesDistance=Math.sqrt(Math.pow(d-u,2)+Math.pow(h-c,2))}this.emit("touchdown",ai(r,this.lastTouches,this.container)),this.lastTouches=o,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(r){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(r.cancelable&&r.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(r.touches.length===1){this.handleStart(r),r.preventDefault();break}case 1:if(this.isMoving){var i=this.renderer.getCamera(),o=i.getState(),s=i.getPreviousState()||{x:0,y:0};i.animate({x:o.x+this.settings.inertiaRatio*(o.x-s.x),y:o.y+this.settings.inertiaRatio*(o.y-s.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",ai(r,this.lastTouches,this.container)),!r.touches.length){var a=Qt(this.lastTouches[0],this.container),u=this.startTouchesPositions[0],c=Math.pow(a.x-u.x,2)+Math.pow(a.y-u.y,2);if(!r.touches.length&&c<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var l=ai(r,this.lastTouches,this.container);if(this.emit("doubletap",l),this.lastTap=null,!l.sigmaDefaultPrevented){var d=this.renderer.getCamera(),h=d.getBoundedRatio(d.getState().ratio/this.settings.doubleClickZoomingRatio);d.animate(this.renderer.getViewportZoomedState(a,h),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var f=ai(r,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=ys(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=ys(r.touches),s=o.map(function(I){return Qt(I,i.container)}),a=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=s;var u=ai(r,a,this.container);if(this.emit("touchmove",u),!u.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=s.some(function(I,O){var G=i.startTouchesPositions[O];return G&&(I.x!==G.x||I.y!==G.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var c=this.renderer.getCamera(),l=this.startCameraState,d=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var h=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),f=h.x,p=h.y,m=this.renderer.viewportToFramedGraph(s[0]),y=m.x,b=m.y;c.setState({x:l.x+f-y,y:l.y+p-b});break}case 2:{var g={x:.5,y:.5,angle:0,ratio:1},_=s[0],v=_.x,w=_.y,k=s[1],x=k.x,D=k.y,F=Math.atan2(D-w,x-v)-this.startTouchesAngle,M=Math.hypot(D-w,x-v)/this.startTouchesDistance,Z=c.getBoundedRatio(l.ratio/M);g.ratio=Z,g.angle=l.angle+F;var ne=this.getDimensions(),ce=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:l}),pe=Math.min(ne.width,ne.height)-2*d,Re=pe/ne.width,U=pe/ne.height,H=Z/pe,Y=v-pe/2/Re,me=w-pe/2/U,ie=[Y*Math.cos(-g.angle)-me*Math.sin(-g.angle),me*Math.cos(-g.angle)+Y*Math.sin(-g.angle)];Y=ie[0],me=ie[1],g.x=ce.x-Y*H,g.y=ce.y+me*H,c.setState(g);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Sk);function eL(e){if(Array.isArray(e))return Tc(e)}function tL(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function nL(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
422
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Im(e){return eL(e)||tL(e)||rk(e)||nL()}function rL(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Hu(e,t){if(e==null)return{};var n,r,i=rL(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var Nm=(function(){function e(t,n){gt(this,e),this.key=t,this.size=n}return yt(e,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),Rm=(function(){function e(){gt(this,e),P(this,"width",0),P(this,"height",0),P(this,"cellSize",0),P(this,"columns",0),P(this,"rows",0),P(this,"cells",{})}return yt(e,[{key:"resizeAndClear",value:function(n,r){this.width=n.width,this.height=n.height,this.cellSize=r,this.columns=Math.ceil(n.width/r),this.rows=Math.ceil(n.height/r),this.cells={}}},{key:"getIndex",value:function(n){var r=Math.floor(n.x/this.cellSize),i=Math.floor(n.y/this.cellSize);return i*this.columns+r}},{key:"add",value:function(n,r,i){var o=new Nm(n,r),s=this.getIndex(i),a=this.cells[s];a||(a=[],this.cells[s]=a),a.push(o)}},{key:"organize",value:function(){for(var n in this.cells){var r=this.cells[n];r.sort(Nm.compare)}}},{key:"getLabelsToDisplay",value:function(n,r){var i=this.cellSize*this.cellSize,o=i/n/n,s=o*r/i,a=Math.ceil(s),u=[];for(var c in this.cells)for(var l=this.cells[c],d=0;d<Math.min(a,l.length);d++)u.push(l[d].key);return u}}])})();function iL(e){var t=e.graph,n=e.hoveredNode,r=e.highlightedNodes,i=e.displayedNodeLabels,o=[];return t.forEachEdge(function(s,a,u,c){(u===n||c===n||r.has(u)||r.has(c)||i.has(u)&&i.has(c))&&o.push(s)}),o}var Lm=150,zm=50,an=Object.prototype.hasOwnProperty;function oL(e,t,n){if(!an.call(n,"x")||!an.call(n,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(t,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return n.color||(n.color=e.defaultNodeColor),!n.label&&n.label!==""&&(n.label=null),n.label!==void 0&&n.label!==null?n.label=""+n.label:n.label=null,n.size||(n.size=2),an.call(n,"hidden")||(n.hidden=!1),an.call(n,"highlighted")||(n.highlighted=!1),an.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultNodeType),n.zIndex||(n.zIndex=0),n}function sL(e,t,n){return n.color||(n.color=e.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),an.call(n,"hidden")||(n.hidden=!1),an.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var aL=(function(e){function t(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(gt(this,t),i=Bt(this,t),P(i,"elements",{}),P(i,"canvasContexts",{}),P(i,"webGLContexts",{}),P(i,"pickingLayers",new Set),P(i,"textures",{}),P(i,"frameBuffers",{}),P(i,"activeListeners",{}),P(i,"labelGrid",new Rm),P(i,"nodeDataCache",{}),P(i,"edgeDataCache",{}),P(i,"nodeProgramIndex",{}),P(i,"edgeProgramIndex",{}),P(i,"nodesWithForcedLabels",new Set),P(i,"edgesWithForcedLabels",new Set),P(i,"nodeExtent",{x:[0,1],y:[0,1]}),P(i,"nodeZExtent",[1/0,-1/0]),P(i,"edgeZExtent",[1/0,-1/0]),P(i,"matrix",Yt()),P(i,"invMatrix",Yt()),P(i,"correctionRatio",1),P(i,"customBBox",null),P(i,"normalizationFunction",Tm({x:[0,1],y:[0,1]})),P(i,"graphToViewportRatio",1),P(i,"itemIDsIndex",{}),P(i,"nodeIndices",{}),P(i,"edgeIndices",{}),P(i,"width",0),P(i,"height",0),P(i,"pixelRatio",Em()),P(i,"pickingDownSizingRatio",2*i.pixelRatio),P(i,"displayedNodeLabels",new Set),P(i,"displayedEdgeLabels",new Set),P(i,"highlightedNodes",new Set),P(i,"hoveredNode",null),P(i,"hoveredEdge",null),P(i,"renderFrame",null),P(i,"renderHighlightedNodesFrame",null),P(i,"needToProcess",!1),P(i,"checkEdgesEventsFrame",null),P(i,"nodePrograms",{}),P(i,"nodeHoverPrograms",{}),P(i,"edgePrograms",{}),i.settings=HR(o),Bu(i.settings),GR(n),!(r instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=n,i.container=r,i.createWebGLContext("edges",{picking:o.enableEdgeEvents}),i.createCanvasContext("edgeLabels"),i.createWebGLContext("nodes",{picking:!0}),i.createCanvasContext("labels"),i.createCanvasContext("hovers"),i.createWebGLContext("hoverNodes"),i.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),i.resize();for(var s in i.settings.nodeProgramClasses)i.registerNodeProgram(s,i.settings.nodeProgramClasses[s],i.settings.nodeHoverProgramClasses[s]);for(var a in i.settings.edgeProgramClasses)i.registerEdgeProgram(a,i.settings.edgeProgramClasses[a]);return i.camera=new Am,i.bindCameraHandlers(),i.mouseCaptor=new JR(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new QR(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Ht(t,e),yt(t,[{key:"registerNodeProgram",value:function(r,i,o){return this.nodePrograms[r]&&this.nodePrograms[r].kill(),this.nodeHoverPrograms[r]&&this.nodeHoverPrograms[r].kill(),this.nodePrograms[r]=new i(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[r]=new(o||i)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(r,i){return this.edgePrograms[r]&&this.edgePrograms[r].kill(),this.edgePrograms[r]=new i(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(r){if(this.nodePrograms[r]){var i=this.nodePrograms,o=i[r],s=Hu(i,[r].map(vi));o.kill(),this.nodePrograms=s}if(this.nodeHoverPrograms[r]){var a=this.nodeHoverPrograms,u=a[r],c=Hu(a,[r].map(vi));u.kill(),this.nodePrograms=c}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],s=Hu(i,[r].map(vi));o.kill(),this.edgePrograms=s}return this}},{key:"resetWebGLTexture",value:function(r){var i=this.webGLContexts[r],o=this.frameBuffers[r],s=this.textures[r];s&&i.deleteTexture(s);var a=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,o),i.bindTexture(i.TEXTURE_2D,a),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,a,0),this.textures[r]=a,this}},{key:"bindCameraHandlers",value:function(){var r=this;return this.activeListeners.camera=function(){r.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(r){var i=r.x,o=r.y,s=hm(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),a=fm.apply(void 0,Im(s)),u=this.itemIDsIndex[a];return u&&u.type==="node"?u.id:null}},{key:"bindEventHandlers",value:function(){var r=this;this.activeListeners.handleResize=function(){r.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(o){var s=si(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}},u=r.getNodeAtPosition(s);if(u&&r.hoveredNode!==u&&!r.nodeDataCache[u].hidden){r.hoveredNode&&r.emit("leaveNode",ee(ee({},a),{},{node:r.hoveredNode})),r.hoveredNode=u,r.emit("enterNode",ee(ee({},a),{},{node:u})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(s)!==r.hoveredNode){var c=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",ee(ee({},a),{},{node:c})),r.scheduleHighlightedNodesRender();return}if(r.settings.enableEdgeEvents){var l=r.hoveredNode?null:r.getEdgeAtPoint(a.event.x,a.event.y);l!==r.hoveredEdge&&(r.hoveredEdge&&r.emit("leaveEdge",ee(ee({},a),{},{edge:r.hoveredEdge})),l&&r.emit("enterEdge",ee(ee({},a),{},{edge:l})),r.hoveredEdge=l)}},this.activeListeners.handleMoveBody=function(o){var s=si(o);r.emit("moveBody",{event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var s=si(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",ee(ee({},a),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",ee(ee({},a),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",ee({},a))},this.activeListeners.handleEnter=function(o){var s=si(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};r.emit("enterStage",ee({},a))};var i=function(s){return function(a){var u=si(a),c={event:u,preventSigmaDefault:function(){u.preventSigmaDefault()}},l=r.getNodeAtPosition(u);if(l)return r.emit("".concat(s,"Node"),ee(ee({},c),{},{node:l}));if(r.settings.enableEdgeEvents){var d=r.getEdgeAtPoint(u.x,u.y);if(d)return r.emit("".concat(s,"Edge"),ee(ee({},c),{},{edge:d}))}return r.emit("".concat(s,"Stage"),c)}};return this.activeListeners.handleClick=i("click"),this.activeListeners.handleRightClick=i("rightClick"),this.activeListeners.handleDoubleClick=i("doubleClick"),this.activeListeners.handleWheel=i("wheel"),this.activeListeners.handleDown=i("down"),this.activeListeners.handleUp=i("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var r=this,i=this.graph,o=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(s){var a,u=(a=s.hints)===null||a===void 0?void 0:a.attributes;r.graph.forEachNode(function(l){return r.updateNode(l)});var c=!u||u.some(function(l){return o.has(l)});r.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!c,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(s){var a,u=(a=s.hints)===null||a===void 0?void 0:a.attributes;r.graph.forEachEdge(function(l){return r.updateEdge(l)});var c=u&&["zIndex","type"].some(function(l){return u?.includes(l)});r.refresh({partialGraph:{edges:i.edges()},skipIndexation:!c,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(s){var a=s.key;r.addNode(a),r.refresh({partialGraph:{nodes:[a]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(s){var a=s.key;r.refresh({partialGraph:{nodes:[a]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(s){var a=s.key;r.removeNode(a),r.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(s){var a=s.key;r.addEdge(a),r.refresh({partialGraph:{edges:[a]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(s){var a=s.key;r.refresh({partialGraph:{edges:[a]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(s){var a=s.key;r.removeEdge(a),r.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){r.clearEdgeState(),r.clearEdgeIndices(),r.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){r.clearEdgeState(),r.clearNodeState(),r.clearEdgeIndices(),r.clearNodeIndices(),r.refresh({schedule:!0})},i.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var r=this.graph;r.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),r.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),r.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),r.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),r.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),r.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),r.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),r.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),r.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),r.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(r,i){var o=hm(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),s=fm.apply(void 0,Im(o)),a=this.itemIDsIndex[s];return a&&a.type==="edge"?a.id:null}},{key:"process",value:function(){var r=this;this.emit("beforeProcess");var i=this.graph,o=this.settings,s=this.getDimensions();if(this.nodeExtent=UR(this.graph),!this.settings.autoRescale){var a=s.width,u=s.height,c=this.nodeExtent,l=c.x,d=c.y;this.nodeExtent={x:[(l[0]+l[1])/2-a/2,(l[0]+l[1])/2+a/2],y:[(d[0]+d[1])/2-u/2,(d[0]+d[1])/2+u/2]}}this.normalizationFunction=Tm(this.customBBox||this.nodeExtent);var h=new Am,f=oi(h.getState(),s,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(s,o.labelGridCellSize);for(var p={},m={},y={},b={},g=1,_=i.nodes(),v=0,w=_.length;v<w;v++){var k=_[v],x=this.nodeDataCache[k],D=i.getNodeAttributes(k);x.x=D.x,x.y=D.y,this.normalizationFunction.applyTo(x),typeof x.label=="string"&&!x.hidden&&this.labelGrid.add(k,x.size,this.framedGraphToViewport(x,{matrix:f})),p[x.type]=(p[x.type]||0)+1}this.labelGrid.organize();for(var F in this.nodePrograms){if(!an.call(this.nodePrograms,F))throw new Error('Sigma: could not find a suitable program for node type "'.concat(F,'"!'));this.nodePrograms[F].reallocate(p[F]||0),p[F]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(_=$m(this.nodeZExtent,function(de){return r.nodeDataCache[de].zIndex},_));for(var M=0,Z=_.length;M<Z;M++){var ne=_[M];m[ne]=g,b[m[ne]]={type:"node",id:ne},g++;var ce=this.nodeDataCache[ne];this.addNodeToProgram(ne,m[ne],p[ce.type]++)}for(var pe={},Re=i.edges(),U=0,H=Re.length;U<H;U++){var Y=Re[U],me=this.edgeDataCache[Y];pe[me.type]=(pe[me.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(Re=$m(this.edgeZExtent,function(de){return r.edgeDataCache[de].zIndex},Re));for(var ie in this.edgePrograms){if(!an.call(this.edgePrograms,ie))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(ie,'"!'));this.edgePrograms[ie].reallocate(pe[ie]||0),pe[ie]=0}for(var I=0,O=Re.length;I<O;I++){var G=Re[I];y[G]=g,b[y[G]]={type:"edge",id:G},g++;var ae=this.edgeDataCache[G];this.addEdgeToProgram(G,y[G],pe[ae.type]++)}return this.itemIDsIndex=b,this.nodeIndices=m,this.edgeIndices=y,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(r){var i=this,o=this.settings;if(this.camera.minRatio=o.minCameraRatio,this.camera.maxRatio=o.maxCameraRatio,this.camera.enabledZooming=o.enableCameraZooming,this.camera.enabledPanning=o.enableCameraPanning,this.camera.enabledRotation=o.enableCameraRotation,o.cameraPanBoundaries?this.camera.clean=function(l){return i.cleanCameraState(l,o.cameraPanBoundaries&&Ic(o.cameraPanBoundaries)==="object"?o.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),r){if(r.edgeProgramClasses!==o.edgeProgramClasses){for(var s in o.edgeProgramClasses)o.edgeProgramClasses[s]!==r.edgeProgramClasses[s]&&this.registerEdgeProgram(s,o.edgeProgramClasses[s]);for(var a in r.edgeProgramClasses)o.edgeProgramClasses[a]||this.unregisterEdgeProgram(a)}if(r.nodeProgramClasses!==o.nodeProgramClasses||r.nodeHoverProgramClasses!==o.nodeHoverProgramClasses){for(var u in o.nodeProgramClasses)(o.nodeProgramClasses[u]!==r.nodeProgramClasses[u]||o.nodeHoverProgramClasses[u]!==r.nodeHoverProgramClasses[u])&&this.registerNodeProgram(u,o.nodeProgramClasses[u],o.nodeHoverProgramClasses[u]);for(var c in r.nodeProgramClasses)o.nodeProgramClasses[c]||this.unregisterNodeProgram(c)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i.tolerance,s=o===void 0?0:o,a=i.boundaries,u=ee({},r),c=a||this.nodeExtent,l=Er(c.x,2),d=l[0],h=l[1],f=Er(c.y,2),p=f[0],m=f[1],y=[this.graphToViewport({x:d,y:p},{cameraState:r}),this.graphToViewport({x:h,y:p},{cameraState:r}),this.graphToViewport({x:d,y:m},{cameraState:r}),this.graphToViewport({x:h,y:m},{cameraState:r})],b=1/0,g=-1/0,_=1/0,v=-1/0;y.forEach(function(pe){var Re=pe.x,U=pe.y;b=Math.min(b,Re),g=Math.max(g,Re),_=Math.min(_,U),v=Math.max(v,U)});var w=g-b,k=v-_,x=this.getDimensions(),D=x.width,F=x.height,M=0,Z=0;if(w>=D?g<D-s?M=g-(D-s):b>s&&(M=b-s):g>D+s?M=g-(D+s):b<-s&&(M=b+s),k>=F?v<F-s?Z=v-(F-s):_>s&&(Z=_-s):v>F+s?Z=v-(F+s):_<-s&&(Z=_+s),M||Z){var ne=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),ce=this.viewportToFramedGraph({x:M,y:Z},{cameraState:r});M=ce.x-ne.x,Z=ce.y-ne.y,u.x+=M,u.y+=Z}return u}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var r=this.camera.getState(),i=this.labelGrid.getLabelsToDisplay(r.ratio,this.settings.labelDensity);Cm(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,s=0,a=i.length;s<a;s++){var u=i[s],c=this.nodeDataCache[u];if(!this.displayedNodeLabels.has(u)&&!c.hidden){var l=this.framedGraphToViewport(c),d=l.x,h=l.y,f=this.scaleSize(c.size);if(!(!c.forceLabel&&f<this.settings.labelRenderedSizeThreshold)&&!(d<-Lm||d>this.width+Lm||h<-zm||h>this.height+zm)){this.displayedNodeLabels.add(u);var p=this.settings.defaultDrawNodeLabel,m=this.nodePrograms[c.type],y=m?.drawLabel||p;y(o,ee(ee({key:u},c),{},{size:f,x:d,y:h}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var r=this.canvasContexts.edgeLabels;r.clearRect(0,0,this.width,this.height);var i=iL({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});Cm(i,this.edgesWithForcedLabels);for(var o=new Set,s=0,a=i.length;s<a;s++){var u=i[s],c=this.graph.extremities(u),l=this.nodeDataCache[c[0]],d=this.nodeDataCache[c[1]],h=this.edgeDataCache[u];if(!o.has(u)&&!(h.hidden||l.hidden||d.hidden)){var f=this.settings.defaultDrawEdgeLabel,p=this.edgePrograms[h.type],m=p?.drawLabel||f;m(r,ee(ee({key:u},h),{},{size:this.scaleSize(h.size)}),ee(ee(ee({key:c[0]},l),this.framedGraphToViewport(l)),{},{size:this.scaleSize(l.size)}),ee(ee(ee({key:c[1]},d),this.framedGraphToViewport(d)),{},{size:this.scaleSize(d.size)}),this.settings),o.add(u)}}return this.displayedEdgeLabels=o,this}},{key:"renderHighlightedNodes",value:function(){var r=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var o=function(f){var p=r.nodeDataCache[f],m=r.framedGraphToViewport(p),y=m.x,b=m.y,g=r.scaleSize(p.size),_=r.settings.defaultDrawNodeHover,v=r.nodePrograms[p.type],w=v?.drawHover||_;w(i,ee(ee({key:f},p),{},{size:g,x:y,y:b}),r.settings)},s=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&s.push(this.hoveredNode),this.highlightedNodes.forEach(function(h){h!==r.hoveredNode&&s.push(h)}),s.forEach(function(h){return o(h)});var a={};s.forEach(function(h){var f=r.nodeDataCache[h].type;a[f]=(a[f]||0)+1});for(var u in this.nodeHoverPrograms)this.nodeHoverPrograms[u].reallocate(a[u]||0),a[u]=0;s.forEach(function(h){var f=r.nodeDataCache[h];r.nodeHoverPrograms[f.type].process(0,a[f.type]++,f)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var c=this.getRenderParams();for(var l in this.nodeHoverPrograms){var d=this.nodeHoverPrograms[l];d.render(c)}}},{key:"scheduleHighlightedNodesRender",value:function(){var r=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){r.renderHighlightedNodesFrame=null,r.renderHighlightedNodes(),r.renderEdgeLabels()}))}},{key:"render",value:function(){var r=this;this.emit("beforeRender");var i=function(){return r.emit("afterRender"),r};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(y){return r.resetWebGLTexture(y)}),!this.graph.order)return i();var o=this.mouseCaptor,s=this.camera.isAnimated()||o.isMoving||o.draggedEvents||o.currentWheelDirection,a=this.camera.getState(),u=this.getDimensions(),c=this.getGraphDimensions(),l=this.getStagePadding();this.matrix=oi(a,u,c,l),this.invMatrix=oi(a,u,c,l,!0),this.correctionRatio=FR(this.matrix,a,u),this.graphToViewportRatio=this.getGraphToViewportRatio();var d=this.getRenderParams();for(var h in this.nodePrograms){var f=this.nodePrograms[h];f.render(d)}if(!this.settings.hideEdgesOnMove||!s)for(var p in this.edgePrograms){var m=this.edgePrograms[p];m.render(d)}return this.settings.hideLabelsOnMove&&s||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),i()}},{key:"addNode",value:function(r){var i=Object.assign({},this.graph.getNodeAttributes(r));this.settings.nodeReducer&&(i=this.settings.nodeReducer(r,i));var o=oL(this.settings,r,i);this.nodeDataCache[r]=o,this.nodesWithForcedLabels.delete(r),o.forceLabel&&!o.hidden&&this.nodesWithForcedLabels.add(r),this.highlightedNodes.delete(r),o.highlighted&&!o.hidden&&this.highlightedNodes.add(r),this.settings.zIndex&&(o.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=o.zIndex),o.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=o.zIndex))}},{key:"updateNode",value:function(r){this.addNode(r);var i=this.nodeDataCache[r];this.normalizationFunction.applyTo(i)}},{key:"removeNode",value:function(r){delete this.nodeDataCache[r],delete this.nodeProgramIndex[r],this.highlightedNodes.delete(r),this.hoveredNode===r&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(r)}},{key:"addEdge",value:function(r){var i=Object.assign({},this.graph.getEdgeAttributes(r));this.settings.edgeReducer&&(i=this.settings.edgeReducer(r,i));var o=sL(this.settings,r,i);this.edgeDataCache[r]=o,this.edgesWithForcedLabels.delete(r),o.forceLabel&&!o.hidden&&this.edgesWithForcedLabels.add(r),this.settings.zIndex&&(o.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=o.zIndex),o.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=o.zIndex))}},{key:"updateEdge",value:function(r){this.addEdge(r)}},{key:"removeEdge",value:function(r){delete this.edgeDataCache[r],delete this.edgeProgramIndex[r],this.hoveredEdge===r&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(r)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new Rm,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(r,i,o){var s=this.nodeDataCache[r],a=this.nodePrograms[s.type];if(!a)throw new Error('Sigma: could not find a suitable program for node type "'.concat(s.type,'"!'));a.process(i,o,s),this.nodeProgramIndex[r]=o}},{key:"addEdgeToProgram",value:function(r,i,o){var s=this.edgeDataCache[r],a=this.edgePrograms[s.type];if(!a)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(s.type,'"!'));var u=this.graph.extremities(r),c=this.nodeDataCache[u[0]],l=this.nodeDataCache[u[1]];a.process(i,o,c,l,s),this.edgeProgramIndex[r]=o}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var r=this.settings,i=r.stagePadding,o=r.autoRescale;return o&&i||0}},{key:"createLayer",value:function(r,i){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[r])throw new Error('Sigma: a layer named "'.concat(r,'" already exists'));var s=jR(i,{position:"absolute"},{class:"sigma-".concat(r)});return o.style&&Object.assign(s.style,o.style),this.elements[r]=s,"beforeLayer"in o&&o.beforeLayer?this.elements[o.beforeLayer].before(s):"afterLayer"in o&&o.afterLayer?this.elements[o.afterLayer].after(s):this.container.appendChild(s),s}},{key:"createCanvas",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(r,"canvas",i)}},{key:"createCanvasContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.createCanvas(r,i),s={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[r]=o.getContext("2d",s),this}},{key:"createWebGLContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i?.canvas||this.createCanvas(r,i);i.hidden&&o.remove();var s=ee({preserveDrawingBuffer:!1,antialias:!1},i),a;a=o.getContext("webgl2",s),a||(a=o.getContext("webgl",s)),a||(a=o.getContext("experimental-webgl",s));var u=a;if(this.webGLContexts[r]=u,u.blendFunc(u.ONE,u.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(r);var c=u.createFramebuffer();if(!c)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(r));this.frameBuffers[r]=c}return u}},{key:"killLayer",value:function(r){var i=this.elements[r];if(!i)throw new Error("Sigma: cannot kill layer ".concat(r,", which does not exist"));if(this.webGLContexts[r]){var o,s=this.webGLContexts[r];(o=s.getExtension("WEBGL_lose_context"))===null||o===void 0||o.loseContext(),delete this.webGLContexts[r]}else this.canvasContexts[r]&&delete this.canvasContexts[r];return i.remove(),delete this.elements[r],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(r){this.unbindCameraHandlers(),this.camera=r,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(r){r!==this.graph&&(this.hoveredNode&&!r.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!r.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=r,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var r=this.customBBox||this.nodeExtent;return{width:r.x[1]-r.x[0]||1,height:r.y[1]-r.y[0]||1}}},{key:"getNodeDisplayData",value:function(r){var i=this.nodeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getEdgeDisplayData",value:function(r){var i=this.edgeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return ee({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=ee({},this.settings);return this.settings[r]=i,Bu(this.settings),this.handleSettingsUpdate(o),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(r,i){return this.setSetting(r,i(this.settings[r])),this}},{key:"setSettings",value:function(r){var i=ee({},this.settings);return this.settings=ee(ee({},this.settings),r),Bu(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(r){var i=this.width,o=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=Em(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!r&&i===this.width&&o===this.height)return this;for(var s in this.elements){var a=this.elements[s];a.style.width=this.width+"px",a.style.height=this.height+"px"}for(var u in this.canvasContexts)this.elements[u].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[u].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[u].scale(this.pixelRatio,this.pixelRatio);for(var c in this.webGLContexts){this.elements[c].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[c].setAttribute("height",this.height*this.pixelRatio+"px");var l=this.webGLContexts[c];if(l.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(c)){var d=this.textures[c];d&&l.deleteTexture(d)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(r){var i=this,o=r?.skipIndexation!==void 0?r?.skipIndexation:!1,s=r?.schedule!==void 0?r.schedule:!1,a=!r||!r.partialGraph;if(a)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(v){return i.addNode(v)}),this.graph.forEachEdge(function(v){return i.addEdge(v)});else{for(var u,c,l=((u=r.partialGraph)===null||u===void 0?void 0:u.nodes)||[],d=0,h=l?.length||0;d<h;d++){var f=l[d];if(this.updateNode(f),o){var p=this.nodeProgramIndex[f];if(p===void 0)throw new Error('Sigma: node "'.concat(f,`" can't be repaint`));this.addNodeToProgram(f,this.nodeIndices[f],p)}}for(var m=(r==null||(c=r.partialGraph)===null||c===void 0?void 0:c.edges)||[],y=0,b=m.length;y<b;y++){var g=m[y];if(this.updateEdge(g),o){var _=this.edgeProgramIndex[g];if(_===void 0)throw new Error('Sigma: edge "'.concat(g,`" can't be repaint`));this.addEdgeToProgram(g,this.edgeIndices[g],_)}}}return(a||!o)&&(this.needToProcess=!0),s?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var r=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){r.render()})),this}},{key:"scheduleRefresh",value:function(r){return this.refresh(ee(ee({},r),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(r,i){var o=this.camera.getState(),s=o.ratio,a=o.angle,u=o.x,c=o.y,l=this.settings,d=l.minCameraRatio,h=l.maxCameraRatio;typeof h=="number"&&(i=Math.min(i,h)),typeof d=="number"&&(i=Math.max(i,d));var f=i/s,p={x:this.width/2,y:this.height/2},m=this.viewportToFramedGraph(r),y=this.viewportToFramedGraph(p);return{angle:a,x:(m.x-y.x)*(1-f)+u,y:(m.y-y.y)*(1-f)+c,ratio:i}}},{key:"viewRectangle",value:function(){var r=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),o=this.viewportToFramedGraph({x:0,y:this.height});return{x1:r.x,y1:r.y,x2:i.x,y2:i.y,height:i.y-o.y}}},{key:"framedGraphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,s=i.matrix?i.matrix:o?oi(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,a=Ac(s,r);return{x:(1+a.x)*this.width/2,y:(1-a.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,s=i.matrix?i.matrix:o?oi(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,a=Ac(s,{x:r.x/this.width*2-1,y:1-r.y/this.height*2});return isNaN(a.x)&&(a.x=0),isNaN(a.y)&&(a.y=0),a}},{key:"viewportToGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(r,i))}},{key:"graphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(r),i)}},{key:"getGraphToViewportRatio",value:function(){var r={x:0,y:0},i={x:1,y:1},o=Math.sqrt(Math.pow(r.x-i.x,2)+Math.pow(r.y-i.y,2)),s=this.graphToViewport(r),a=this.graphToViewport(i),u=Math.sqrt(Math.pow(s.x-a.x,2)+Math.pow(s.y-a.y,2));return u/o}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(r){return this.customBBox=r,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var r=this.container;r.firstChild;)r.removeChild(r.firstChild);for(var i in this.nodePrograms)this.nodePrograms[i].kill();for(var o in this.nodeHoverPrograms)this.nodeHoverPrograms[o].kill();for(var s in this.edgePrograms)this.edgePrograms[s].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var a in this.elements)this.killLayer(a);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return r/this.settings.zoomToSizeRatioFunction(i)*(this.getSetting("itemSizesReference")==="positions"?i*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var r={};for(var i in this.elements)this.elements[i]instanceof HTMLCanvasElement&&(r[i]=this.elements[i]);return r}}])})(Eh),uL=aL;function cL(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 xk(e){var t=cL(e,"string");return typeof t=="symbol"?t:t+""}function Ek(e,t,n){return(t=xk(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Dm(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 Os(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Dm(Object(n),!0).forEach(function(r){Ek(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Dm(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function lL(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function dL(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,xk(r.key),r)}}function fL(e,t,n){return t&&dL(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ps(e){return Ps=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ps(e)}function $k(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return($k=function(){return!!e})()}function Tk(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function hL(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 Tk(e)}function pL(e,t,n){return t=Ps(t),hL(e,$k()?Reflect.construct(t,n||[],Ps(e).constructor):t.apply(e,n))}function Nc(e,t){return Nc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Nc(e,t)}function mL(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&&Nc(e,t)}function Rc(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 gL(e){if(Array.isArray(e))return Rc(e)}function yL(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function vL(e,t){if(e){if(typeof e=="string")return Rc(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)?Rc(e,t):void 0}}function bL(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
423
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Vu(e){return gL(e)||yL(e)||vL(e)||bL()}function Ck(e,t,n,r){var i=Math.pow(1-e,2)*t.x+2*(1-e)*e*n.x+Math.pow(e,2)*r.x,o=Math.pow(1-e,2)*t.y+2*(1-e)*e*n.y+Math.pow(e,2)*r.y;return{x:i,y:o}}function wL(e,t,n){for(var r=20,i=0,o=e,s=0;s<r;s++){var a=Ck((s+1)/r,e,t,n);i+=Math.sqrt(Math.pow(o.x-a.x,2)+Math.pow(o.y-a.y,2)),o=a}return i}function Ak(e){var t=e.curvatureAttribute,n=e.defaultCurvature,r=e.keepLabelUpright,i=r===void 0?!0:r;return function(o,s,a,u,c){var l=c.edgeLabelSize,d=s[t]||n,h=c.edgeLabelFont,f=c.edgeLabelWeight,p=c.edgeLabelColor.attribute?s[c.edgeLabelColor.attribute]||c.edgeLabelColor.color||"#000":c.edgeLabelColor.color,m=s.label;if(m){o.fillStyle=p,o.font="".concat(f," ").concat(l,"px ").concat(h);var y=!i||a.x<u.x,b=y?a.x:u.x,g=y?a.y:u.y,_=y?u.x:a.x,v=y?u.y:a.y,w=(b+_)/2,k=(g+v)/2,x=_-b,D=v-g,F=Math.sqrt(Math.pow(x,2)+Math.pow(D,2)),M=y?1:-1,Z=w+D*d*M,ne=k-x*d*M,ce=s.size*.7+5,pe={x:ne-g,y:-(Z-b)},Re=Math.sqrt(Math.pow(pe.x,2)+Math.pow(pe.y,2)),U={x:v-ne,y:-(_-Z)},H=Math.sqrt(Math.pow(U.x,2)+Math.pow(U.y,2));b+=ce*pe.x/Re,g+=ce*pe.y/Re,_+=ce*U.x/H,v+=ce*U.y/H,Z+=ce*D/F,ne-=ce*x/F;var Y={x:Z,y:ne},me={x:b,y:g},ie={x:_,y:v},I=wL(me,Y,ie);if(!(I<a.size+u.size)){var O=o.measureText(m).width,G=I-a.size-u.size;if(O>G){var ae="…";for(m=m+ae,O=o.measureText(m).width;O>G&&m.length>1;)m=m.slice(0,-2)+ae,O=o.measureText(m).width;if(m.length<4)return}for(var de={},te=0,ge=m.length;te<ge;te++){var X=m[te];de[X]||(de[X]=o.measureText(X).width*(1+d*.35))}for(var be=.5-O/I/2,We=0,rt=m.length;We<rt;We++){var st=m[We],N=Ck(be,me,Y,ie),j=2*(1-be)*(Z-b)+2*be*(_-Z),V=2*(1-be)*(ne-g)+2*be*(v-ne),q=Math.atan2(V,j);o.save(),o.translate(N.x,N.y),o.rotate(q),o.fillText(st,0,0),o.restore(),be+=de[st]/I}}}}}function _L(e){var t=e.arrowHead,n=t?.extremity==="target"||t?.extremity==="both",r=t?.extremity==="source"||t?.extremity==="both",i=`
424
424
  precision highp float;
425
425
 
426
426
  varying vec4 v_color;
@@ -495,7 +495,7 @@ void main(void) {
495
495
  gl_FragColor = transparent;
496
496
  }
497
497
  }
498
- `);return i}function uL(e){var t=e.arrowHead,n=t?.extremity==="target"||t?.extremity==="both",r=t?.extremity==="source"||t?.extremity==="both",i=`
498
+ `);return i}function kL(e){var t=e.arrowHead,n=t?.extremity==="target"||t?.extremity==="both",r=t?.extremity==="source"||t?.extremity==="both",i=`
499
499
  attribute vec4 a_id;
500
500
  attribute vec4 a_color;
501
501
  attribute float a_direction;
@@ -605,9 +605,9 @@ void main() {
605
605
 
606
606
  v_color.a *= bias;
607
607
  }
608
- `);return i}var bk=.25,cL={arrowHead:null,curvatureAttribute:"curvature",defaultCurvature:bk},wk=WebGLRenderingContext,Cm=wk.UNSIGNED_BYTE,wn=wk.FLOAT;function au(e){var t=Cs(Cs({},cL),e||{}),n=t,r=n.arrowHead,i=n.curvatureAttribute,o=n.drawLabel,s=r?.extremity==="target"||r?.extremity==="both",a=r?.extremity==="source"||r?.extremity==="both",u=["u_matrix","u_sizeRatio","u_dimensions","u_pixelRatio","u_feather","u_minEdgeThickness"].concat(Uu(r?["u_lengthToThicknessRatio","u_widenessToThicknessRatio"]:[]));return(function(c){eL(l,c);function l(){var d;KR(this,l);for(var f=arguments.length,h=new Array(f),p=0;p<f;p++)h[p]=arguments[p];return d=QR(this,l,[].concat(h)),mk(yk(d),"drawLabel",o||sL(t)),d}return YR(l,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:uL(t),FRAGMENT_SHADER_SOURCE:aL(t),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:u,ATTRIBUTES:[{name:"a_source",size:2,type:wn},{name:"a_target",size:2,type:wn}].concat(Uu(s?[{name:"a_targetSize",size:1,type:wn}]:[]),Uu(a?[{name:"a_sourceSize",size:1,type:wn}]:[]),[{name:"a_thickness",size:1,type:wn},{name:"a_curvature",size:1,type:wn},{name:"a_color",size:4,type:Cm,normalized:!0},{name:"a_id",size:4,type:Cm,normalized:!0}]),CONSTANT_ATTRIBUTES:[{name:"a_current",size:1,type:wn},{name:"a_direction",size:1,type:wn}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[0,-1],[1,1],[1,-1]]}}},{key:"processVisibleItem",value:function(f,h,p,m,y){var b,g=y.size||1,w=p.x,v=p.y,_=m.x,k=m.y,x=Pn(y.color),N=(b=y[i])!==null&&b!==void 0?b:bk,M=this.array;M[h++]=w,M[h++]=v,M[h++]=_,M[h++]=k,s&&(M[h++]=m.size),a&&(M[h++]=p.size),M[h++]=g,M[h++]=N,M[h++]=x,M[h++]=f}},{key:"setUniforms",value:function(f,h){var p=h.gl,m=h.uniformLocations,y=m.u_matrix,b=m.u_pixelRatio,g=m.u_feather,w=m.u_sizeRatio,v=m.u_dimensions,_=m.u_minEdgeThickness;if(p.uniformMatrix3fv(y,!1,f.matrix),p.uniform1f(b,f.pixelRatio),p.uniform1f(w,f.sizeRatio),p.uniform1f(g,f.antiAliasingFeather),p.uniform2f(v,f.width*f.pixelRatio,f.height*f.pixelRatio),p.uniform1f(_,f.minEdgeThickness),r){var k=m.u_lengthToThicknessRatio,x=m.u_widenessToThicknessRatio;p.uniform1f(k,r.lengthToThicknessRatio),p.uniform1f(x,r.widenessToThicknessRatio)}}}]),l})(iu)}au();au({arrowHead:su});au({arrowHead:Cs(Cs({},su),{},{extremity:"both"})});function lL(e){if(Array.isArray(e))return e}function dL(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)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 $c(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 _k(e,t){if(e){if(typeof e=="string")return $c(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)?$c(e,t):void 0}}function fL(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
609
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hL(e,t){return lL(e)||dL(e,t)||_k(e,t)||fL()}function pL(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function mL(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 kk(e){var t=mL(e,"string");return typeof t=="symbol"?t:t+""}function gL(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,kk(r.key),r)}}function yL(e,t,n){return t&&gL(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Is(e){return Is=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Is(e)}function Sk(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Sk=function(){return!!e})()}function Tc(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function vL(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 Tc(e)}function bL(e,t,n){return t=Is(t),vL(e,Sk()?Reflect.construct(t,n||[],Is(e).constructor):t.apply(e,n))}function Cc(e,t){return Cc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Cc(e,t)}function wL(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&&Cc(e,t)}function ar(e,t,n){return(t=kk(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _L(e){if(Array.isArray(e))return $c(e)}function kL(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function SL(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
610
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Gu(e){return _L(e)||kL(e)||_k(e)||SL()}function Am(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 Im(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Am(Object(n),!0).forEach(function(r){ar(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Am(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var xL="relative",EL={drawLabel:void 0,drawHover:void 0,borders:[{size:{value:.1},color:{attribute:"borderColor"}},{size:{fill:!0},color:{attribute:"color"}}]},$L="#000000";function TL(e){var t=e.borders,n=um(t.filter(function(i){var o=i.size;return"fill"in o}).length),r=`
608
+ `);return i}var Ik=.25,SL={arrowHead:null,curvatureAttribute:"curvature",defaultCurvature:Ik},Nk=WebGLRenderingContext,Om=Nk.UNSIGNED_BYTE,_n=Nk.FLOAT;function pu(e){var t=Os(Os({},SL),e||{}),n=t,r=n.arrowHead,i=n.curvatureAttribute,o=n.drawLabel,s=r?.extremity==="target"||r?.extremity==="both",a=r?.extremity==="source"||r?.extremity==="both",u=["u_matrix","u_sizeRatio","u_dimensions","u_pixelRatio","u_feather","u_minEdgeThickness"].concat(Vu(r?["u_lengthToThicknessRatio","u_widenessToThicknessRatio"]:[]));return(function(c){mL(l,c);function l(){var d;lL(this,l);for(var h=arguments.length,f=new Array(h),p=0;p<h;p++)f[p]=arguments[p];return d=pL(this,l,[].concat(f)),Ek(Tk(d),"drawLabel",o||Ak(t)),d}return fL(l,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:kL(t),FRAGMENT_SHADER_SOURCE:_L(t),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:u,ATTRIBUTES:[{name:"a_source",size:2,type:_n},{name:"a_target",size:2,type:_n}].concat(Vu(s?[{name:"a_targetSize",size:1,type:_n}]:[]),Vu(a?[{name:"a_sourceSize",size:1,type:_n}]:[]),[{name:"a_thickness",size:1,type:_n},{name:"a_curvature",size:1,type:_n},{name:"a_color",size:4,type:Om,normalized:!0},{name:"a_id",size:4,type:Om,normalized:!0}]),CONSTANT_ATTRIBUTES:[{name:"a_current",size:1,type:_n},{name:"a_direction",size:1,type:_n}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[0,-1],[1,1],[1,-1]]}}},{key:"processVisibleItem",value:function(h,f,p,m,y){var b,g=y.size||1,_=p.x,v=p.y,w=m.x,k=m.y,x=On(y.color),D=(b=y[i])!==null&&b!==void 0?b:Ik,F=this.array;F[f++]=_,F[f++]=v,F[f++]=w,F[f++]=k,s&&(F[f++]=m.size),a&&(F[f++]=p.size),F[f++]=g,F[f++]=D,F[f++]=x,F[f++]=h}},{key:"setUniforms",value:function(h,f){var p=f.gl,m=f.uniformLocations,y=m.u_matrix,b=m.u_pixelRatio,g=m.u_feather,_=m.u_sizeRatio,v=m.u_dimensions,w=m.u_minEdgeThickness;if(p.uniformMatrix3fv(y,!1,h.matrix),p.uniform1f(b,h.pixelRatio),p.uniform1f(_,h.sizeRatio),p.uniform1f(g,h.antiAliasingFeather),p.uniform2f(v,h.width*h.pixelRatio,h.height*h.pixelRatio),p.uniform1f(w,h.minEdgeThickness),r){var k=m.u_lengthToThicknessRatio,x=m.u_widenessToThicknessRatio;p.uniform1f(k,r.lengthToThicknessRatio),p.uniform1f(x,r.widenessToThicknessRatio)}}}]),l})(du)}pu();pu({arrowHead:hu});pu({arrowHead:Os(Os({},hu),{},{extremity:"both"})});function xL(e){if(Array.isArray(e))return e}function EL(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)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 Lc(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 Rk(e,t){if(e){if(typeof e=="string")return Lc(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)?Lc(e,t):void 0}}function $L(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
609
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function TL(e,t){return xL(e)||EL(e,t)||Rk(e,t)||$L()}function CL(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function AL(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 Lk(e){var t=AL(e,"string");return typeof t=="symbol"?t:t+""}function IL(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,Lk(r.key),r)}}function NL(e,t,n){return t&&IL(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ms(e){return Ms=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ms(e)}function zk(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(zk=function(){return!!e})()}function zc(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function RL(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 zc(e)}function LL(e,t,n){return t=Ms(t),RL(e,zk()?Reflect.construct(t,n||[],Ms(e).constructor):t.apply(e,n))}function Dc(e,t){return Dc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Dc(e,t)}function zL(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&&Dc(e,t)}function ar(e,t,n){return(t=Lk(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function DL(e){if(Array.isArray(e))return Lc(e)}function OL(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function PL(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
610
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function qu(e){return DL(e)||OL(e)||Rk(e)||PL()}function Pm(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 Mm(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Pm(Object(n),!0).forEach(function(r){ar(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Pm(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var ML="relative",FL={drawLabel:void 0,drawHover:void 0,borders:[{size:{value:.1},color:{attribute:"borderColor"}},{size:{fill:!0},color:{attribute:"color"}}]},UL="#000000";function GL(e){var t=e.borders,n=gm(t.filter(function(i){var o=i.size;return"fill"in o}).length),r=`
611
611
  precision highp float;
612
612
 
613
613
  varying vec2 v_diffVector;
@@ -644,7 +644,7 @@ void main(void) {
644
644
  }
645
645
  #else
646
646
  // Sizes:
647
- `).concat(t.flatMap(function(i,o){var s=i.size;if("fill"in s)return[];s=s;var a="attribute"in s?"v_borderSize_".concat(o+1):um(s.value),u=(s.mode||xL)==="pixels"?"u_correctionRatio":"v_radius";return[" float borderSize_".concat(o+1," = ").concat(u," * ").concat(a,";")]}).join(`
647
+ `).concat(t.flatMap(function(i,o){var s=i.size;if("fill"in s)return[];s=s;var a="attribute"in s?"v_borderSize_".concat(o+1):gm(s.value),u=(s.mode||ML)==="pixels"?"u_correctionRatio":"v_radius";return[" float borderSize_".concat(o+1," = ").concat(u," * ").concat(a,";")]}).join(`
648
648
  `),`
649
649
  // Now, let's split the remaining space between "fill" borders:
650
650
  float fillBorderSize = (v_radius - (`).concat(t.flatMap(function(i,o){var s=i.size;return"fill"in s?[]:["borderSize_".concat(o+1)]}).join(" + "),") ) / ").concat(n,`;
@@ -670,7 +670,7 @@ void main(void) {
670
670
  } else `)}).join(""),` { /* Nothing to add here */ }
671
671
  #endif
672
672
  }
673
- `);return r}function CL(e){var t=e.borders,n=`
673
+ `);return r}function jL(e){var t=e.borders,n=`
674
674
  attribute vec2 a_position;
675
675
  attribute float a_size;
676
676
  attribute float a_angle;
@@ -717,9 +717,9 @@ void main() {
717
717
  `),`
718
718
  #endif
719
719
  }
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.")})}
720
+ `);return n}var Dk=WebGLRenderingContext,Fm=Dk.UNSIGNED_BYTE,ls=Dk.FLOAT;function Ok(e){var t,n=Mm(Mm({},FL),e||{}),r=n.borders,i=n.drawLabel,o=n.drawHover,s=["u_sizeRatio","u_correctionRatio","u_matrix"].concat(qu(r.flatMap(function(a,u){var c=a.color;return"value"in c?["u_borderColor_".concat(u+1)]:[]})));return t=(function(a){zL(u,a);function u(){var c;CL(this,u);for(var l=arguments.length,d=new Array(l),h=0;h<l;h++)d[h]=arguments[h];return c=LL(this,u,[].concat(d)),ar(zc(c),"drawLabel",i),ar(zc(c),"drawHover",o),c}return NL(u,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:jL(n),FRAGMENT_SHADER_SOURCE:GL(n),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:s,ATTRIBUTES:[{name:"a_position",size:2,type:ls},{name:"a_id",size:4,type:Fm,normalized:!0},{name:"a_size",size:1,type:ls}].concat(qu(r.flatMap(function(l,d){var h=l.color;return"attribute"in h?[{name:"a_borderColor_".concat(d+1),size:4,type:Fm,normalized:!0}]:[]})),qu(r.flatMap(function(l,d){var h=l.size;return"attribute"in h?[{name:"a_borderSize_".concat(d+1),size:1,type:ls}]:[]}))),CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:ls}],CONSTANT_DATA:[[u.ANGLE_1],[u.ANGLE_2],[u.ANGLE_3]]}}},{key:"processVisibleItem",value:function(l,d,h){var f=this.array;f[d++]=h.x,f[d++]=h.y,f[d++]=l,f[d++]=h.size,r.forEach(function(p){var m=p.color;"attribute"in m&&(f[d++]=On(h[m.attribute]||m.defaultValue||UL))}),r.forEach(function(p){var m=p.size;"attribute"in m&&(f[d++]=h[m.attribute]||m.defaultValue)})}},{key:"setUniforms",value:function(l,d){var h=d.gl,f=d.uniformLocations,p=f.u_sizeRatio,m=f.u_correctionRatio,y=f.u_matrix;h.uniform1f(m,l.correctionRatio),h.uniform1f(p,l.sizeRatio),h.uniformMatrix3fv(y,!1,l.matrix),r.forEach(function(b,g){var _=b.color;if("value"in _){var v=f["u_borderColor_".concat(g+1)],w=JN(_.value),k=TL(w,4),x=k[0],D=k[1],F=k[2],M=k[3];h.uniform4f(v,x/255,D/255,F/255,M/255)}})}}]),u})(dk),ar(t,"ANGLE_1",0),ar(t,"ANGLE_2",2*Math.PI/3),ar(t,"ANGLE_3",4*Math.PI/3),t}Ok();const bi=.18,ZL=500,BL=2,HL=3,ds={rest:2,selected:4,expanded:5},VL=6,Wu=2,qL=8,Um=6,Ku=400,WL=2e3,KL={x:[0,1e3],y:[0,1e3]},Ju=1e3,Gm=500,JL={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 fs(e){return Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0")}function YL(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 Tt(e,t=1){return`#${fs(e.r)}${fs(e.g)}${fs(e.b)}${fs(e.a*t*255)}`}function vs(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 Pk(e,t,n=bi){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 Mk(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 XL(e,t,n,r=bi){const i=Pk(t,n,r);let o=1/0,s=t;for(let a=1;a<=12;a++){const u=vs(t,i,n,a/12);o=Math.min(o,Mk(e,s,u)),s=u}return o}function QL(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(N){const j=u.get(N);if(j)return j;a.style.color="",a.style.color=N;const V=o.getComputedStyle(a).color.match(/[\d.]+/g)?.map(Number)??[0,0,0],q={r:V[0]??0,g:V[1]??0,b:V[2]??0,a:V[3]??1};return u.set(N,q),q}const l=N=>c(`var(--cia-graph-${N})`);let d;function h(){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")}}h();function f(N,j){if(!j.texts?.length||!j.outer)return;const V=j.size/j.outer;N.textAlign="center",N.textBaseline="alphabetic",N.lineJoin="round";for(const q of j.texts){const xe=JL[q.kind],ue=xe.size*V;if(ue<Um)continue;N.font=xe.font(ue);const Ee=j.y+q.y*V;N.lineWidth=4*V,N.strokeStyle=j.haloColor??"#000",N.strokeText(q.text,j.x,Ee),N.fillStyle=q.kind==="role"?j.toneColor??"#fff":q.kind==="address"?j.mutedColor??"#aaa":j.textColor??"#fff",N.fillText(q.text,j.x,Ee)}}const p=()=>{};function m(N,j,V,q){if(!j.route)return;const xe=j.curvature??0,ue=q.x-V.x,Ee=q.y-V.y,$e=Math.hypot(ue,Ee);if($e<V.size+q.size+24)return;const re={x:(V.x+q.x)/2+Ee*xe,y:(V.y+q.y)/2-ue*xe},Ae=Tt(d.canvas);if(j.route==="route"){const T=(V.size+3)/$e,R=1-(q.size+j.size*6+3)/$e;if(R>T){N.save(),N.strokeStyle=Ae,N.lineWidth=j.size+2,N.lineCap="butt",N.setLineDash([4,6]),N.beginPath();for(let J=0;J<=32;J++){const oe=vs(V,re,q,T+(R-T)*J/32);J?N.lineTo(oe.x,oe.y):N.moveTo(oe.x,oe.y)}N.stroke(),N.restore()}}const Ke=vs(V,re,q,.5);N.save(),N.beginPath(),N.arc(Ke.x,Ke.y,9,0,Math.PI*2),N.fillStyle=Ae,N.fill(),N.lineWidth=1.5,N.strokeStyle=j.color,N.stroke(),N.fillStyle=j.color,N.font="700 12px Inter, system-ui, sans-serif",N.textAlign="center",N.textBaseline="middle",N.fillText(Ci,Ke.x,Ke.y+.5),N.restore()}const y=N=>(j,V,q,xe,ue)=>{m(j,V,q,xe),N(j,V,q,xe,ue)},b=Ok({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:f,drawHover:p}),_=pu({arrowHead:{extremity:"target",lengthToThicknessRatio:6,widenessToThicknessRatio:4},drawLabel:y(Ak({curvatureAttribute:"curvature",defaultCurvature:bi}))}),v=wk({lengthToThicknessRatio:6,widenessToThicknessRatio:4});let w=new Ge({type:"directed",multi:!1,allowSelfLoops:!1}),k=!0;const x=new uL(w,s,{allowInvalidContainer:!0,autoRescale:!0,stagePadding:0,itemSizesReference:"positions",zoomToSizeRatioFunction:N=>N,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:Um,labelDensity:1,labelGridCellSize:120,minEdgeThickness:1.6,defaultNodeType:"address",defaultEdgeType:"link",nodeProgramClasses:{address:b},edgeProgramClasses:{link:_,straight:v},defaultDrawNodeLabel:f,defaultDrawNodeHover:p,defaultDrawEdgeLabel:y(fk)});x.setCustomBBox(KL);const D=x.getMouseCaptor(),F=x.getTouchCaptor();D.removeAllListeners(),F.removeAllListeners(),D.enabled=!1,F.enabled=!1;const M=new Map;let Z=bi;function ne(N){const j=t.flags().get(N),V=t.selected();return j?.has("expanded")?{width:ds.expanded,color:d.expanded}:V?.kind==="node"&&V.id===N||t.highlighted()===N?{width:ds.selected,color:d.selected}:{width:ds.rest,color:c(t.colorOf(M.get(N)))}}function ce(N,j,V){const q=t.model(),xe=t.notes().get(N.id)??null,ue=Ln(N,q.checked_address,xe),Ee=c(t.colorOf(N)),$e=ne(N.id),re=ue.radius+$e.width/2,Ae=ue.ring?ue.radius+VL+Wu/2:re,Ke=ue.ring?Wu/Ae:0,T=ue.ring?Math.max(0,Ae-Wu-re)/Ae:0,R=t.selected(),J=ue.ring||$e.width!==ds.rest||R?.kind==="node"&&R.id===N.id;return{x:j.x,y:-j.y,size:Ae,label:ue.texts.find(oe=>oe.kind==="address")?.text??N.address,color:Tt(Ee),forceLabel:!V||J,ringColor:Tt(d.edge),ringSize:Ke,gapSize:T,strokeColor:Tt($e.color,xe?.5:1),strokeSize:$e.width/Ae,bodyColor:Tt(d.node),dotColor:Tt(Ee),dotSize:ue.dot/Ae,outer:Ae,texts:ue.texts,toneColor:Tt(Ee),mutedColor:Tt(d.muted),textColor:Tt(d.text),haloColor:Tt(d.halo)}}function pe(N,j){const V=t.selected(),q=V?.kind==="node"?M.get(V.id)?.address??null:null,xe=V?.kind==="edge"&&V.id===N.id,ue=V?.kind==="edge"?xe?Xt.related:Xt.faded:r_(N,q),Ee=c(t.colorOf(j)),$e=ue===Xt.faded?Tt(YL(Ee,d.canvas,1-ue)):Tt(Ee,ue),re=k?u_(N):"",Ae=kr(N).link;return{size:xe?HL:BL,color:$e,curvature:Z,type:Z?"link":"straight",...re?{label:re}:{},...Ae?{route:Ae}:{}}}function Re(){const N=t.model(),j=t.positions(),{width:V,height:q}=t.dimensions();M.clear();for(const re of N.nodes)M.set(re.id,re);const xe=N.nodes.length>Ku;Z=N.edges.length>ZL?0:bi,k=N.edges.length<=a_,x.setSetting("edgeLabelColor",{color:Tt(d.muted)});const ue=new Ge({type:"directed",multi:!1,allowSelfLoops:!1}),Ee=new Map(N.nodes.map(re=>[re.address,re]));for(const re of N.nodes)ue.addNode(re.id,ce(re,j[re.id]??{x:V/2,y:q/2},xe));for(const re of N.edges){const Ae=Ee.get(re.from),Ke=Ee.get(re.to);!Ae||!Ke||Ae.id===Ke.id||ue.hasEdge(re.id)||ue.hasDirectedEdge(Ae.id,Ke.id)||ue.addDirectedEdgeWithKey(re.id,Ae.id,Ke.id,pe(re,Ae))}w=ue;const $e=t.selected();Y=[$e?.kind==="node"?$e.id:null,t.highlighted()].filter(re=>!!re),x.setGraph(w),I()}function U(){const j=t.model().nodes.length>Ku,V=t.positions();w.updateEachNodeAttributes((q,xe)=>{const ue=M.get(q);return ue?ce(ue,V[q]??{x:xe.x,y:-xe.y},j):xe}),ie()}function H(N){const j=N?M.get(N):null;if(!j||!w.hasNode(j.id))return;const V=t.positions()[j.id],q=w.getNodeAttributes(j.id);w.replaceNodeAttributes(j.id,ce(j,V??{x:q.x,y:-q.y},t.model().nodes.length>Ku))}let Y=[];function me(){const N=t.selected(),j=[N?.kind==="node"?N.id:null,t.highlighted()].filter(V=>!!V);for(const V of new Set([...Y,...j]))H(V);Y=j,ie()}function ie(){const N=t.model(),j=new Map(N.nodes.map(q=>[q.address,q])),V=new Map(N.edges.map(q=>[q.id,q]));w.updateEachEdgeAttributes((q,xe)=>{const ue=V.get(q),Ee=ue&&j.get(ue.from);return ue&&Ee?pe(ue,Ee):xe})}function I(){const{width:N,height:j}=t.dimensions(),V=x.getDimensions();if(!V.width||!V.height)return;const q=Math.min(V.width/N,V.height/j),xe=t.transform(),ue=xe.scale*q,Ee=(V.width-N*q)/2+xe.x*q,$e=(V.height-j*q)/2+xe.y*q,re={x:.5,y:.5,ratio:1,angle:0},Ae=x.framedGraphToViewport({x:.5,y:.5},{cameraState:re}),Ke=(x.framedGraphToViewport({x:.6,y:.5},{cameraState:re}).x-Ae.x)/.1,T=(x.framedGraphToViewport({x:.5,y:.6},{cameraState:re}).y-Ae.y)/.1,R=Ke/(Ju*ue);x.getCamera().setState({ratio:R,angle:0,x:.5-Gm/Ju-(Ee-Ae.x)*R/Ke,y:.5-Gm/Ju-($e-Ae.y)*R/T})}function O(N){const j=t.transform(),V={x:(N.x-j.x)/j.scale,y:(N.y-j.y)/j.scale},q=t.positions();let xe=null,ue=1/0;if(w.forEachNode((Ae,Ke)=>{const T=q[Ae];if(!T)return;const R=Math.hypot(V.x-T.x,V.y-T.y);R<=Ke.size+1/j.scale&&R<ue&&(xe=Ae,ue=R)}),xe)return{kind:"node",id:xe};const Ee=qL/j.scale;let $e=null,re=1/0;return w.forEachEdge((Ae,Ke,T,R)=>{const J=q[T],oe=q[R];if(!J||!oe)return;const ye=Math.hypot(oe.x-J.x,oe.y-J.y)*(.5+Z)+Ee;if(Math.hypot(V.x-(J.x+oe.x)/2,V.y-(J.y+oe.y)/2)>ye)return;const Xe=Z?XL(V,J,oe,Z):Mk(V,J,oe);Xe<=Ee&&Xe<re&&($e=Ae,re=Xe)}),$e?{kind:"edge",id:$e}:{kind:"canvas",id:null}}let G=0,ae=null,de=null;const te=N=>{N.buttons||(de=N,!G&&(G=o.requestAnimationFrame(()=>{G=0;const j=de;if(!j)return;const V=s.getBoundingClientRect(),{width:q,height:xe}=t.dimensions(),ue=Math.min(V.width/q,V.height/xe)||1,Ee=O({x:(j.clientX-V.left-(V.width-q*ue)/2)/ue,y:(j.clientY-V.top-(V.height-xe*ue)/2)/ue}),$e=Ee.kind==="canvas"?null:`${Ee.kind}:${Ee.id}`;if(s.style.cursor=$e?"pointer":"",$e!==ae){if(ae=$e,!$e){n.hideTooltip();return}if(Ee.kind==="node"){const re=M.get(Ee.id);re&&n.showTooltip(j,bc(re))}else{const re=t.model().edges.find(Ae=>Ae.id===Ee.id);re&&n.showTooltip(j,wc(re,t.now()))}}})))},ge=()=>{ae=null,s.style.cursor="",n.hideTooltip()};s.addEventListener("pointermove",te),s.addEventListener("pointerleave",ge);let X=null;const be=N=>{N.preventDefault(),!X&&(X=setTimeout(()=>{X=null,n.lost()},WL))},We=()=>{X&&clearTimeout(X),X=null,n.lost()},rt=Object.values(x.getCanvases());for(const N of rt)N.addEventListener("webglcontextlost",be),N.addEventListener("webglcontextrestored",We);function st(){const N=t.positions();let j=null;return w.forEachEdge((V,q,xe,ue)=>{const Ee=N[xe],$e=N[ue];if(!Ee||!$e||!Z)return;const re=vs(Ee,Pk(Ee,$e,Z),$e,.5);j=j??{x1:re.x,y1:re.y,x2:re.x,y2:re.y},j.x1=Math.min(j.x1,re.x),j.y1=Math.min(j.y1,re.y),j.x2=Math.max(j.x2,re.x),j.y2=Math.max(j.y2,re.y)}),j}return{kind:"webgl",surface:s,build:Re,geometry(){const N=t.positions();w.updateEachNodeAttributes((j,V)=>{const q=N[j];return q?{...V,x:q.x,y:-q.y}:V},{attributes:["x","y"]}),I()},moveNode(N){const j=t.positions()[N];j&&w.hasNode(N)&&w.mergeNodeAttributes(N,{x:j.x,y:-j.y})},endMove(){},camera:I,selection:me,flag:N=>H(N),theme(){h(),U()},resize(){x.resize(!0),I()},pick:O,linkBounds:st,destroy(){X&&clearTimeout(X),G&&o.cancelAnimationFrame(G),s.removeEventListener("pointermove",te),s.removeEventListener("pointerleave",ge);for(const N of rt)N.removeEventListener("webglcontextlost",be),N.removeEventListener("webglcontextrestored",We);x.kill(),s.remove()}}}DT("webgl",QL);const An=document.getElementById("view"),Fs=()=>typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches;let En={},un=Ds(document,En,{prefersDark:Fs}),wt=null,jm=null;vh(An);const Zm=RT(location);Zm?ez(Zm):tz();async function ez(e){document.documentElement.dataset.mode="browser",document.title=TT,un=Ds(document,{},{prefersDark:Fs}),typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").addEventListener?.("change",()=>{const n=un;un=Ds(document,{},{prefersDark:Fs}),wt&&un!==n&&wt.setTheme(un)}),vh(An,"Loading the graph");const t=await LT(e,(n,r)=>fetch(n,r),document);if(!t){Ri(An,null,CT),document.documentElement.dataset.view="text";return}wt=U_(An,t.result,{host:zT((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=wt.kind}function tz(){const e=new uh({name:"chain-insights-view",version:"1.0.0"},{});function t(r){const i=un;un=Ds(document,r,{prefersDark:Fs,applyVariables:(o,s)=>ET(o,s),applyFonts:$T}),wt&&un!==i&&wt.setTheme(un),wt?.setDisplayMode(r.displayMode,r.availableDisplayModes)}function n(r){wt?.destroy(),wt=null;const i=Du(e.getHostContext(),En);wt=U_(An,r,{host:e,availableDisplayModes:i.availableDisplayModes,displayMode:i.displayMode,toolInput:jm}),document.documentElement.dataset.view=wt.kind}e.ontoolinput=r=>{jm=r.arguments&&typeof r.arguments=="object"?r.arguments:null;const i=typeof r.arguments?.address=="string"?r.arguments.address:null;wt||vh(An,i?`Loading the graph of ${i}`:"Loading the Chain Insights view")},e.ontoolresult=r=>{n(r)},e.ontoolcancelled=()=>{wt||Ri(An,null,"The tool call was cancelled. Nothing to draw.")},e.onhostcontextchanged=r=>{En=Du(En,r),t(En)},e.onteardown=async()=>(wt?.destroy(),wt=null,{}),e.onerror=r=>{console.warn("chain-insights-view:",r)},e.connect(new Vw(window.parent,window.parent)).then(()=>{En=Du(En,e.getHostContext()),t(En)},r=>{console.warn("chain-insights-view: no host answered",r),Ri(An,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-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}
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}.cia-graph-edge-mark{font:700 13px var(--font-sans,Inter,system-ui,sans-serif);fill:var(--edge-tone,var(--cia-graph-edge));paint-order:stroke;stroke:var(--cia-graph-canvas);stroke-width:4px;stroke-linejoin:round;-webkit-user-select:none;user-select:none}.cia-graph-edge[data-state=faded] .cia-graph-edge-mark{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-roles .cv-link-swatch{width:18px;height:0;border-radius:0;border-top:2px solid var(--cia-graph-edge)}.cv-roles [data-link=route] .cv-link-swatch{border-top-style:dashed}.cv-roles .cv-link-mark{font-weight:700;color:var(--cia-graph-edge)}.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>